npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shipengine/elements

v2.35.0

Published

<!-- README for NPM; the one for GitHub is in .github directory. -->

Downloads

1,425

Readme

Creating a New Element

ShipEngine Elements is a collection of React components that provide shipping functionality through a standardized interface. This guide provides the essential steps for creating new elements in the ShipEngine Elements library.

Element Architecture

Each element is composed of:

  • Component: Your main React component logic
  • createElement Wrapper: Provides error boundaries, i18n, and styling
  • Element Provider: Manages global state and configuration

File Structure

libs/elements/src/elements/new-element/
├── index.ts                    # Export file
├── new-element.tsx       # Main element file
├── __stories__/               # Storybook stories
│   └── new-element.stories.tsx
└── __tests__/                 # Jest tests
    └── new-element.test.tsx

Step-by-Step Guide

1. Create the Directory Structure

mkdir -p libs/elements/src/elements/new-element/{__stories__,__tests__}

2. Create the Main Element File

libs/elements/src/elements/new-element/new-element.tsx

import { ErrorFallback } from "@components/error-fallback";
import { Button, Typography } from "@shipengine/giger";
import { useTranslation } from "react-i18next";

import { createElement } from "../../create-element";
import { en } from "../../locales";

/**
 * Props for the NewElement component
 */
export type NewElementProps = {
  /** Optional title to display */
  title?: string;
  /** Callback function when action is performed */
  onClick?: (value: any) => void;
};

/**
 * # NewElement Component
 *
 * Brief description of what this element does and its purpose.
 */
export const Component = ({ title = "New Element Title", onClick }: NewElementProps) => {
  const { t } = useTranslation();

  const handleOnClick = () => {
    const value = { name: "ShipEngine Elements" };
    onClick?.(value);
  };

  return (
    <div>
      <Typography variant="h2">{title}</Typography>

      <Typography variant="body1">{t("description")}</Typography>

      <Button onClick={handleOnClick}>{t("actionButton")}</Button>
    </div>
  );
};

/**
 * # NewElement Element
 *
 * The registered element that can be used directly in applications.
 */
export const Element = createElement(Component, ErrorFallback, {
  css: {
    height: "100%",
    maxWidth: "800px",
    minWidth: "440px",
    width: "100%",
  },
  resources: { en },
});

export type ElementProps = React.ComponentProps<typeof Element>;

3. Create the Index File

libs/elements/src/elements/new-element/index.ts

export * as NewElement from "./new-element";
export type { NewElementProps } from "./new-element";

4. Add Localization Resources

libs/elements/src/locales/en/new-element.json

{
  "description": "This is a new Element!",
  "actionButton": "Continue"
}

5. Create Storybook Stories

libs/elements/src/elements/new-element/__stories__/new-element.stories.tsx

import type { Meta, StoryObj } from "@storybook/react";

import { NewElement } from "../new-element";

const meta: Meta<typeof NewElement.Element> = {
  title: "Elements/NewElement",
  component: NewElement.Element,
  parameters: {
    layout: "centered",
  },
  tags: ["autodocs"],
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
  args: {
    title: "Default Example",
  },
};

export const CustomTitle: Story = {
  args: {
    title: "Custom Element Title",
  },
};

7. Update Package Exports

Add your new element to libs/elements/package.json exports:

{
  "exports": {
    "./new-element": {
      "source": "./src/elements/new-element/index.ts",
      "import": {
        "types": "./dist/types/elements/new-element/index.d.ts",
        "default": "./dist/esm/elements/new-element/index.js"
      },
      "require": {
        "types": "./dist/types/elements/new-element/index.d.ts",
        "default": "./dist/cjs/elements/new-element/index.cjs"
      }
    }
  }
}

8. Update Main Index File

Add your element to libs/elements/src/index.ts:

export * from "./elements/new-element";

Best Practices

  • Use TypeScript with proper type definitions
  • Include JSDoc comments where appropriate
  • Write unit tests for functionality
  • Use i18 translation strings for all user-facing text
  • Follow existing code patterns for consistency
  • Test with Storybook during development