Compare commits

...

No commits in common. '6f914a8db3d8ed839bdacf622dee0a642c6e5392' and '7821db8d3f30a418cff42c5e93a7c90f0da75e86' have entirely different histories.

@ -0,0 +1,28 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-typescript",
{
"isTSX": true,
"allExtensions": true
}
],
[
"@babel/preset-react",
{
"runtime": "automatic"
}],
[
"@babel/preset-env",
{
"targets": {
"chrome": 100,
"safari": 15,
"firefox": 91
}
}
]
],
"plugins": []
}

@ -0,0 +1,2 @@
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-static.git

7
.gitignore vendored

@ -0,0 +1,7 @@
.idea
dist
node_modules
.yalc
yalc.lock
storybook-static
src/catalyst

@ -0,0 +1,10 @@
.storybook
.idea
src
tailwind.config.js
tsup.config.ts
tsconfig.json
jest.config.js
.buildpacks
static.json
storybook-static

@ -0,0 +1,2 @@
legacy-peer-deps=true
@j0lv3r4:registry=https://npm.pkg.github.com

@ -0,0 +1,25 @@
module.exports = {
stories: [
"../src/components/**/*.stories.mdx",
"../src/components/**/*.stories.@(js|jsx|ts|tsx)",
"../src/examples/**/*.stories.@(js|jsx|ts|tsx)",
// "../src/examples/**/*.stories.mdx",
// "../src/examples/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
// "storybook-dark-mode",
],
docs: {
autodocs: true,
},
framework: {
name: "@storybook/react-webpack5",
options: {},
},
};

File diff suppressed because it is too large Load Diff

@ -0,0 +1,6 @@
<style>
html,
body {
height: 100%;
}
</style>

@ -0,0 +1,16 @@
import "./output.css";
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
darkMode: {
darkClass: "dark",
classTarget: "html",
stylePreview: true,
},
};

@ -1,9 +0,0 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,2 +1,7 @@
# monoui ## Getting started
Install Tailwind CSS via npm:
```bash
```

@ -0,0 +1,194 @@
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/_s/lk3nyf2127b85xch4yk9tlx00000gn/T/jest_dx",
// Automatically clear mock calls, instances, contexts and results before every test
// clearMocks: false,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
// coverageDirectory: undefined,
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
// Indicates which provider should be used to instrument code for coverage
// coverageProvider: "babel",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
// globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// presets: undefined,
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state before every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state and implementation before every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "jsdom",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[tj]s?(x)"],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.tsx?$": "ts-jest",
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};

25852
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,114 @@
{
"name": "@j0lv3r4/monoui",
"version": "0.1.3",
"description": "Mono UI",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"engines": {
"npm": ">=9.6.7",
"node": ">=18.17.1"
},
"scripts": {
"build": "tsup",
"watch": "tsup --watch",
"test": "jest",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"watch:storybook": "storybook dev -p 6006",
"watch:tailwind": "npx tailwindcss -i ./src/input.css -o ./.storybook/output.css --watch",
"dev": "npm-run-all --parallel watch:*",
"release": "np --no-2fa",
"heroku-postbuild": "npm run build-storybook"
},
"repository": {
"type": "git",
"url": "git+git@github.com:j0lv3r4/monoui.git"
},
"keywords": [
"React",
"UI",
"Components"
],
"author": "Juan Olvera",
"license": "MIT",
"bugs": {
"url": "https://github.com/j0lv3r4/monoui/issues"
},
"homepage": "https://github.com/j0lv3r4/monoui#readme",
"devDependencies": {
"@babel/preset-env": "^7.23.7",
"@storybook/addon-actions": "^7.6.7",
"@storybook/addon-essentials": "^7.6.7",
"@storybook/addon-interactions": "^7.6.7",
"@storybook/addon-links": "^7.6.7",
"@storybook/react": "^7.6.7",
"@storybook/react-webpack5": "^7.6.7",
"@storybook/testing-library": "^0.2.2",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.9",
"@tanstack/react-query": "^4.24.3",
"@tanstack/react-query-devtools": "^4.24.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/dashify": "^1.0.1",
"@types/jest": "^29.4.0",
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.0.27",
"autoprefixer": "^10.4.13",
"class-variance-authority": "^0.4.0",
"clsx": "^1.2.1",
"color": "^4.2.3",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"lodash-es": "^4.17.21",
"np": "^7.6.3",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.33",
"prettier": "^2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.43.2",
"rollup": "^3.12.0",
"storybook": "^7.6.7",
"tailwind-merge": "^1.11.0",
"tailwindcss": "^3.2.4",
"tailwindcss-animate": "^1.0.7",
"ts-jest": "^29.0.5",
"tsup": "^6.5.0",
"typescript": "^5.1.6",
"webpack": "^5.77.0"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-primitive": "^1.0.3",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toggle": "^1.0.3",
"@react-spring/web": "^9.7.1",
"cmdk": "^0.2.0",
"dashify": "^2.0.0",
"react-icons": "^4.12.0",
"react-number-format": "^5.1.4",
"ts-pattern": "^5.0.6",
"zustand": "^4.3.7"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"np": {
"yarn": false
},
"resolutions": {
"@storybook/{app}/webpack": "^5"
}
}

@ -0,0 +1,38 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "./Box";
import { Input } from "../Input";
import { Button } from "../Button";
import { Divider } from "../Divider";
import { cx } from "../../utils";
const meta: Meta<typeof Box> = {
title: "UI/Box",
component: Box,
};
export default meta;
type Story = StoryObj<typeof Box>;
export const Default: Story = {
render: () => <Box>Hello world</Box>,
};
export const AsForm: Story = {
render: () => (
<Box asChild className={cx(["w-56"])}>
<form
onSubmit={(event) => {
event.preventDefault();
console.log("event", event);
}}
>
<Input label="Username" />
<Divider />
<Button type="submit" intent="primary">
Submit
</Button>
</form>
</Box>
),
};

@ -0,0 +1,7 @@
import { cva } from "class-variance-authority";
const base = ["box-border", "m-0", "min-w-0", "w-full"];
const boxStyles = cva(base);
export { boxStyles };

@ -0,0 +1,13 @@
import React, { HTMLAttributes } from "react";
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { Box } from "./Box";
describe("Box", () => {
test("Check component renders", () => {
render(<Box data-testid="box">Hello world</Box>);
const box = screen.getByTestId("box") as HTMLDivElement;
expect(box.innerHTML).toBe("Hello world");
});
});

@ -0,0 +1,18 @@
import React, { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
import { Primitive } from "@radix-ui/react-primitive";
import { boxStyles } from "./Box.styles";
import { cx } from "../../utils";
const Box = forwardRef<
ElementRef<typeof Primitive.div>, // renderer function
ComponentPropsWithoutRef<typeof Primitive.div> // exotic component (not fn components just objects) ref: https://stackoverflow.com/a/64239113
>(({ children, ...props }, forwardedRef) => {
const styles = cx(boxStyles, props.className);
return (
<Primitive.div {...props} className={styles} ref={forwardedRef}>
{children}
</Primitive.div>
);
});
export { Box };

@ -0,0 +1,2 @@
export * from "./Box";
export * from "./Box.types";

@ -0,0 +1,82 @@
import React from "react";
import { FaBeer, FaApple } from "react-icons/fa";
import { Meta, StoryObj } from "@storybook/react";
import { Button } from "./Button";
import { Box } from "../Box";
import { cx } from "../../utils";
const meta: Meta<typeof Button> = {
title: "UI/Button",
component: Button,
};
export default meta;
type Story = StoryObj<typeof Button>;
export const Default: Story = {
render: () => <Button>Click me</Button>,
};
export const Primary: Story = {
render: () => <Button intent="primary">Click me</Button>,
};
export const Secondary: Story = {
render: () => <Button intent="secondary">Click me</Button>,
};
export const Plain: Story = {
render: () => <Button intent="plain">Click me</Button>,
};
export const Sizes: Story = {
render: () => (
<Box className={cx(["space-x-2"])}>
<Button size="sm">Click me</Button>
<Button size="md">Click me</Button>
<Button size="lg">Click me</Button>
</Box>
),
};
export const WithIcon: Story = {
render: () => (
<Box className={cx(["space-x-2"])}>
<Button>
<FaBeer />
Click me
</Button>
<Button intent="primary">
<FaApple />
Click me
</Button>
</Box>
),
};
export const OnlyIcon: Story = {
render: () => (
<Box className={cx(["space-x-2"])}>
<Button onlyIcon aria-label="Click me">
<FaBeer />
</Button>
<Button intent="primary" onlyIcon aria-label="Click me">
<FaApple />
</Button>
</Box>
),
};
export const Loading: Story = {
render: () => (
<Box className={cx(["space-x-2"])}>
<Button intent="primary" loading>
Click me
</Button>
</Box>
),
};

@ -0,0 +1,74 @@
import { cva } from "class-variance-authority";
const base = [
// Base
"relative isolate inline-flex items-center justify-center gap-x-2 rounded-lg border-2 text-base/6 font-semibold",
// Focus
"focus:outline-none",
"data-[focus]:outline",
"focus-visible:ring-2",
"focus-visible:ring-offset-2",
"focus-visible:ring-mono-primary",
// Icon
// "[&>[data-slot=icon]]:-mx-0.5 [&>[data-slot=icon]]:my-0.5 [&>[data-slot=icon]]:size-5 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[--btn-icon] [&>[data-slot=icon]]:sm:my-1 [&>[data-slot=icon]]:sm:size-4 forced-colors:[--btn-icon:ButtonText] forced-colors:data-[hover]:[--btn-icon:ButtonText]",
];
const size = {
sm: ["py-0.5", "px-1.5", "text-sm"],
md: ["py-1", "px-2"],
lg: ["py-1.5", "px-3.5", "text-base"],
};
const DEFAULT = [
"bg-white",
"hover:bg-gray-100",
"text-mono-primary",
"border-mono-border",
];
const primary = [
"bg-mono-primary",
"hover:bg-mono-primary-hover",
"border-mono-primary",
"text-white",
];
const secondary = ["bg-mono-hover", "hover:bg-transparent"];
const plain = ["bg-transparent", "border-transparent", "hover:bg-gray-100"];
const onlyIcon = ["rounded-full", "p-1"];
const buttonStyles = cva(base, {
variants: {
primary: {
true: primary,
},
intent: {
primary,
secondary,
DEFAULT,
plain,
},
size,
fullWidth: {
true: "w-full",
},
disabled: {
true: ["data-[disabled]:opacity-50"],
},
onlyIcon: {
true: onlyIcon,
},
},
defaultVariants: {
size: "md",
primary: false,
intent: "DEFAULT",
},
});
export { buttonStyles };

@ -0,0 +1,45 @@
import React, { forwardRef } from "react";
import { match, P } from "ts-pattern";
import { Primitive } from "@radix-ui/react-primitive";
import { CgSpinner } from "react-icons/cg";
import * as styles from "./Button.styles";
import type * as T from "./Button.types";
import { cx } from "../../utils";
const Button = forwardRef<T.ButtonElement, T.ButtonProps>(
(
{ size, onlyIcon, intent, primary, loading = false, children, ...props },
forwardedRef
) => {
const classes = cx(
styles.buttonStyles({ size, intent, primary, onlyIcon }),
props.className
);
return (
<Primitive.button {...props} className={classes} ref={forwardedRef}>
{match({ loading, onlyIcon })
.with({ loading: true }, () => (
<>
<span
className={cx([
"absolute",
"top-[50%]",
"left-[50%]",
"-translate-x-2/4",
"-translate-y-2/4",
])}
>
<CgSpinner className={cx("motion-safe:animate-spin")} />
</span>
<span className={cx(["opacity-0"])}>{children}</span>
</>
))
// .with({ onlyIcon: true }, () => <span>{children}</span>)
.otherwise(() => children)}
</Primitive.button>
);
}
);
export { Button };

@ -0,0 +1,13 @@
import { VariantProps } from "class-variance-authority";
import type { buttonStyles } from "./Button.styles";
import { ComponentPropsWithoutRef, ElementRef } from "react";
import { Primitive } from "@radix-ui/react-primitive";
type ButtonElement = ElementRef<typeof Primitive.button>;
type ButtonProps = ComponentPropsWithoutRef<typeof Primitive.button> &
VariantProps<typeof buttonStyles> & {
loading?: boolean;
};
export type { ButtonElement, ButtonProps };

@ -0,0 +1,2 @@
export * from "./Button";
export * from "./Button.types";

@ -0,0 +1,59 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import * as Card from "./Card";
import { Box } from "../Box";
import { Input } from "../Input";
import { Button } from "../Button";
import { cx } from "../../utils";
const meta: Meta<typeof Card.$> = {
title: "UI/Card",
component: Card.$,
};
export default meta;
type Story = StoryObj<typeof Card>;
export const Default: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Card.$ paddless>
<Card.Header>
<Card.Title>Create account</Card.Title>
<Card.Description>
Manage all your transactions in one place.
</Card.Description>
</Card.Header>
<Card.Body>
<form onSubmit={(event) => event.preventDefault()}>
<Input label="Name" />
<Box className={cx(["py-2"])} />
<Input label="Type" />
<Box className={cx(["py-2"])} />
<Input label="Balance" money />
</form>
</Card.Body>
<Card.Footer className={cx(["flex", "justify-between"])}>
<Button>Cancel</Button>
<Button intent="primary">Save</Button>
</Card.Footer>
</Card.$>
</Box>
),
};
// Another way to use this component alone is to import the named export
// import { Card } from './Card';
export const Paddless: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Card.$>
<p>Dummy content while we create the input components.</p>
</Card.$>
</Box>
),
};

@ -0,0 +1,29 @@
import { cva } from "class-variance-authority";
const base = [
"overflow-hidden",
"rounded-lg",
"bg-white",
"divide-y",
"divide-y-2",
"text-mono-text",
];
const cardStyles = cva(base, {
variants: {
paddless: {
true: ["p-0"],
false: ["px-4", "py-4", "sm:px-6", "divide-y-0"],
},
borderless: {
true: ["border-0"],
false: ["border-2"],
},
},
defaultVariants: {
paddless: false,
borderless: false,
},
});
export { cardStyles };

@ -0,0 +1,24 @@
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import * as T from "./Card.types";
import { cardStyles } from "./Card.styles";
import { Header, Title, Description, Body, Footer } from "./components";
import { cx } from "../../utils";
const Card = React.forwardRef<T.CardElement, T.CardProps>(
({ children, paddless, borderless = false, ...props }, forwardedRef) => {
const classes = cx(cardStyles({ paddless, borderless }), props.className);
return (
<Primitive.div {...props} className={classes} ref={forwardedRef}>
{children}
</Primitive.div>
);
}
);
// Root element
const $ = Card;
export { $, Card, Header, Title, Body, Description, Footer };

@ -0,0 +1,13 @@
import { ComponentPropsWithRef, ElementRef } from "react";
import { Primitive } from "@radix-ui/react-primitive";
import { VariantProps } from "class-variance-authority";
import { cardStyles } from "./Card.styles";
type CardElement = ElementRef<typeof Primitive.div>;
type CardProps = Omit<ComponentPropsWithRef<typeof Primitive.div>, "asChild"> &
VariantProps<typeof cardStyles> & {
paddless?: boolean;
};
export type { CardElement, CardProps };

@ -0,0 +1,20 @@
import * as React from "react";
import { Box } from "../../Box";
import { cx } from "../../../utils";
import { styles } from "./styles";
import { HTMLAttributes } from "react";
type BodyProps = HTMLAttributes<HTMLDivElement> & React.PropsWithChildren<{}>;
type Body = (props: BodyProps) => React.ReactElement | null;
const Body: Body = ({ children, ...props }) => {
const classes = cx(styles, props.className);
return (
<Box {...props} className={classes}>
{children}
</Box>
);
};
export { Body };

@ -0,0 +1,13 @@
import * as React from "react";
import { Box } from "../../Box";
import { cx } from "../../../utils";
type Description = (
props: React.PropsWithChildren<{}>
) => React.ReactElement | null;
const Description: Description = ({ children }) => {
return <Box className={cx(["mt-1"])}>{children}</Box>;
};
export { Description };

@ -0,0 +1,21 @@
import * as React from "react";
import { Box } from "../../Box";
import { cx } from "../../../utils";
import { styles } from "./styles";
import { HTMLAttributes } from "react";
import { cva } from "class-variance-authority";
type FooterProps = HTMLAttributes<HTMLDivElement> & React.PropsWithChildren<{}>;
type Footer = (props: FooterProps) => React.ReactElement | null;
const Footer: Footer = ({ children, ...props }) => {
const classes = cx(styles, props.className);
return (
<Box {...props} className={classes}>
{children}
</Box>
);
};
export { Footer };

@ -0,0 +1,21 @@
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import { styles } from "./styles";
import { cx } from "../../../utils";
type HTMLTableHeader = React.ElementRef<typeof Primitive.div>;
type HeaderProps = React.ComponentPropsWithoutRef<typeof Primitive.div> & {};
const Header = React.forwardRef<HTMLTableHeader, HeaderProps>(
({ children, ...props }, forwardRef) => {
const classes = cx(styles, props.className);
return (
<Primitive.div {...props} className={classes} ref={forwardRef}>
{children}
</Primitive.div>
);
}
);
export { Header };

@ -0,0 +1,26 @@
import { Primitive } from "@radix-ui/react-primitive";
import * as React from "react";
import { cva, VariantProps } from "class-variance-authority";
import { cx } from "../../../utils";
const base = ["text-lg", "font-semibold", "leading-6", "text-mono-primary"];
const titleStyles = cva(base);
type TitleElement = React.ElementRef<typeof Primitive.h3>;
type TitleProps = React.ComponentPropsWithoutRef<typeof Primitive.h3> &
VariantProps<typeof titleStyles> & {};
const Title = React.forwardRef<TitleElement, TitleProps>(
({ children, ...props }, forwardRef) => {
const classes = cx(titleStyles(), props.className);
return (
<Primitive.h3 {...props} className={classes} ref={forwardRef}>
{children}
</Primitive.h3>
);
}
);
export { Title };

@ -0,0 +1,5 @@
export * from "./Header";
export * from "./Title";
export * from "./Body";
export * from "./Description";
export * from "./Footer";

@ -0,0 +1,3 @@
const styles = ["px-4", "py-4", "sm:px-6"];
export { styles };

@ -0,0 +1 @@
export * from "./Card";

@ -0,0 +1,64 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "../Box";
import { Combobox } from "./Combobox";
import { cx } from "../../utils";
const meta: Meta<typeof Combobox> = {
title: "UI/Combobox",
component: Combobox,
};
export default meta;
type Story = StoryObj<typeof Combobox>;
const animals = [
{ label: "Cat", value: "cat" },
{ label: "Dog", value: "dog" },
{ label: "Bird", value: "bird" },
{ label: "Elephant", value: "elephant" },
{ label: "Mouse", value: "mouse" },
{ label: "Rabbit", value: "rabbit" },
{ label: "Tiger", value: "tiger" },
{ label: "Lion", value: "lion" },
{ label: "Monkey", value: "monkey" },
{ label: "Panda", value: "panda" },
{ label: "Car", value: "car" },
{ label: "Car Payment", value: "car_payment" },
];
export const Default: Story = {
render: () => <Combobox label="Animals" options={animals} />,
};
export const WithHelpText: Story = {
render: () => (
<Combobox
label="Animals"
options={animals}
helpText="Please select an option."
/>
),
};
export const Loading: Story = {
render: () => (
<Combobox
label="Animals"
options={animals}
helpText="Please select an option."
isLoading
/>
),
};
export const WithError: Story = {
render: () => (
<Combobox
label="Animals"
options={animals}
hasError
helpText="Please select an option."
/>
),
};

@ -0,0 +1,59 @@
import { cva } from "class-variance-authority";
const base = [""];
const command = [
"bg-white",
"flex",
"h-full",
"w-full",
"flex-col",
"overflow-hidden",
"rounded-lg",
"border-2",
"border-mono-border",
];
const input = [
"flex",
"w-full",
"rounded-md",
"bg-transparent",
"outline-none",
"border-0",
"placeholder:text-muted-foreground",
"focus:outline-none",
"focus:ring-0",
"disabled:cursor-not-allowed",
"disabled:opacity-50",
];
const item = [
"relative",
"flex",
"cursor-default",
"select-none",
"items-center",
"px-2",
"py-1",
"outline-none",
"rounded-sm",
"aria-selected:bg-mono-primary",
"aria-selected:text-white",
"data-[disabled]:pointer-events-none",
"data-[disabled]:opacity-50",
];
const checkedIcon = ["opacity-0", "absolute", "right-2"];
const comboboxStyles = cva(base, {
variants: {
hasError: {
true: ["border-mono-error"],
},
},
defaultVariants: {
hasError: false,
},
});
export { comboboxStyles, command, input, item, checkedIcon };

@ -0,0 +1,181 @@
import * as _ from "lodash-es";
import * as React from "react";
import * as Popover from "@radix-ui/react-popover";
import { match, P } from "ts-pattern";
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "cmdk";
import type * as T from "./Combobox.types";
import * as styles from "./Combobox.styles";
import { Divider } from "../Divider";
import { HelpText, Label } from "../Common";
import { Button } from "../Button";
import { Box } from "../Box";
import { cx } from "../../utils";
import { FaCheck, FaChevronDown, FaSistrix } from "react-icons/fa";
import { CgSpinner } from "react-icons/cg";
const Combobox = React.forwardRef<T.ComboboxElement, T.ComboboxProps>(
(
{
isLoading = false,
label,
hideLabel,
helpText,
options,
onSelect,
onUnselect,
hasError,
defaultValue,
...props
},
forwardedRef
) => {
const [open, setOpen] = React.useState(false);
const [selected, setSelected] = React.useState(defaultValue);
const classes = cx(styles.comboboxStyles({ hasError }), props.className);
const handleOnSelect = (selectedValue: string) => {
const option = options.find(
(option) => option.label.toLowerCase() === selectedValue
);
if (!_.isNil(option)) {
// If same option then unselect it.
if (option?.label === selected) {
// Unselect logic
setSelected(undefined);
onUnselect?.(option);
} else {
// Select logic
setSelected(option.label);
onSelect?.(option);
}
}
setOpen(false);
};
return (
<Popover.Root open={open} onOpenChange={setOpen}>
<Box>
<Label className={cx([], { "sr-only": hideLabel })}>{label}</Label>
</Box>
<Popover.Trigger asChild>
<Button
role="combobox"
className={cx(classes, ["font-normal"], { "mt-2": !hideLabel })}
>
{match([selected, props.placeholder])
// Use selected value if available
.with([P.not(P.nullish), P._], () => <span>{selected}</span>)
// Use placeholder if value is not available and placeholder is
.with([P.nullish, P.not(P.nullish)], () => (
<span>{props.placeholder}</span>
))
// Use default placeholder if value and placeholder are not available
.with(P.array(P.nullish), () => <span>Select option...</span>)
.exhaustive()}
{isLoading ? (
<CgSpinner
className={cx(["motion-safe:animate-spin", "ml-auto"])}
/>
) : (
<FaChevronDown />
)}
</Button>
</Popover.Trigger>
<Popover.Portal>
<Popover.Content
sideOffset={4}
align="start"
{...props}
ref={forwardedRef}
>
<Command className={cx([styles.command])}>
<Box
className={cx(["flex", "items-center", "px-2"])}
cmdk-input-wrapper=""
>
<FaSistrix
className={cx([
"h-4",
"w-4",
"shrink-0",
"font-bold",
"text-lg",
])}
/>
<CommandInput
placeholder="Search Option..."
className={cx([styles.input])}
/>
</Box>
<Divider border size="sm" className={cx(["py-0"])} />
<CommandList>
<CommandEmpty>
<Box>Nothing here</Box>
</CommandEmpty>
{options.map((option, index) => {
// Handle sections
if (Array.isArray(option.value)) {
const nestedOptions = option.value;
const key = `${label}-${index}`;
return (
<CommandGroup key={key} heading={option.label}>
{nestedOptions.map((nestedOption, nestedIndex) => (
<CommandItem
key={String(nestedOption.value)}
className={cx([styles.item])}
onSelect={handleOnSelect}
>
{nestedOption.label}
<FaCheck
className={cx([styles.checkedIcon], {
"opacity-100": selected === option.label,
})}
/>
</CommandItem>
))}
</CommandGroup>
);
}
return (
<CommandGroup>
<CommandItem
key={option.value}
className={cx([styles.item])}
onSelect={handleOnSelect}
>
{option.label}
<FaCheck
className={cx([styles.checkedIcon], {
"opacity-100": selected === option.label,
})}
/>
</CommandItem>
</CommandGroup>
);
})}
</CommandList>
</Command>
</Popover.Content>
</Popover.Portal>
{match(helpText)
.with(P.not(P.nullish), (helpText) => (
<HelpText hasError={hasError}>{helpText}</HelpText>
))
.otherwise(() => null)}
</Popover.Root>
);
}
);
export { Combobox };

@ -0,0 +1,23 @@
import * as React from "react";
import { InputProps } from "../Common/Common.types";
type ComboboxOption = {
label: string;
value: string | ComboboxOption[];
};
type ComboboxElement = React.ElementRef<"div">;
type ComboboxProps = React.ComponentPropsWithoutRef<"div"> &
InputProps & {
isLoading?: boolean;
options: ComboboxOption[];
allowCreate?: boolean;
onSelect?: (option: ComboboxOption) => void;
onUnselect?: (option: ComboboxOption) => void;
onCreate?: (option: ComboboxOption) => void;
// Updates the selected option when optimistic updates happen.
onSync?: (option: ComboboxOption) => void;
};
export type { ComboboxElement, ComboboxProps, ComboboxOption };

@ -0,0 +1,2 @@
export * from './Combobox';
export * from './Combobox.types';

@ -0,0 +1,8 @@
type InputProps = {
label: string;
hideLabel?: boolean;
helpText?: string;
hasError?: boolean;
};
export type { InputProps };

@ -0,0 +1,35 @@
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import { cva, VariantProps } from "class-variance-authority";
import { cx } from "../../utils";
import * as Common from "./index";
type HelpTextElement = React.ElementRef<typeof Primitive.p>;
type HelpTextProps = React.ComponentPropsWithoutRef<typeof Primitive.p> &
VariantProps<typeof styles> &
Pick<Common.T.InputProps, "hasError"> & {};
const styles = cva(["mt-2", "text-sm", "text-mono-text"], {
variants: {
hasError: {
true: ["text-mono-error"],
},
},
defaultVariants: {
hasError: false,
},
});
const HelpText = React.forwardRef<HelpTextElement, HelpTextProps>(
({ hasError, children, ...props }, forwardedRef) => {
const classes = cx(styles({ hasError }));
return (
<p {...props} className={classes} ref={forwardedRef}>
{children}
</p>
);
}
);
export { HelpText };

@ -0,0 +1,28 @@
import * as React from "react";
import * as $ from "@radix-ui/react-label";
import { cva } from "class-variance-authority";
import { cx } from "../../utils";
type LabelElement = React.ElementRef<typeof $.Root>;
type LabelProps = React.ComponentPropsWithoutRef<typeof $.Root>;
const styles = cva([
"text-sm",
"font-semibold",
"leading-6",
"text-mono-primary",
]);
const Label = React.forwardRef<LabelElement, LabelProps>(
({ children, ...props }, forwardRef) => {
const classes = cx(styles(), props.className);
return (
<$.Root {...props} className={classes} ref={forwardRef}>
{children}
</$.Root>
);
}
);
export { Label };

@ -0,0 +1,5 @@
import * as T from "./Common.types";
export * from "./HelpText";
export * from "./Label";
export type { T };

@ -0,0 +1,58 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "../Box";
import { Divider } from "./Divider";
import * as Card from "../Card";
import { cx } from "../../utils";
const meta: Meta<typeof Divider> = {
title: "UI/Divider",
component: Divider,
};
export default meta;
type Story = StoryObj<typeof Divider>;
export const Default: Story = {
render: () => (
<Box>
Hello world
<Divider />
Hello world
</Box>
),
};
export const WithBorder: Story = {
render: () => (
<Box>
<Box>
Hello world
<Divider border />
Hello world
</Box>
<Divider />
<Box className={cx(["flex"])}>
Hello world
<Divider border orientation="vertical" size="xl" />
Hello world
</Box>
</Box>
),
};
export const OnCard: Story = {
render: () => (
<Box className={cx(["lead"])}>
<Card.$>
<p>
The first rule of Fight Club is: You do not talk about Fight Club.
</p>
<Divider border />
<p>The second rule of Fight Club is: Always bring cupcakes.</p>
</Card.$>
</Box>
),
};

@ -0,0 +1,30 @@
import { cva } from "class-variance-authority";
const base = ["block"];
const horizontal = [""];
const vertical = [""];
const dividerStyles = cva(base, {
variants: {
size: {
sm: ["p-1"],
md: ["p-2"],
lg: ["p-3"],
xl: ["p-4"],
},
border: {
true: [""],
},
orientation: {
horizontal,
vertical,
},
},
defaultVariants: {
size: "md",
orientation: "horizontal",
},
});
export { dividerStyles, horizontal, vertical };

@ -0,0 +1,45 @@
import * as React from "react";
import { match, P } from "ts-pattern";
import * as T from "./Divider.types";
import { Box } from "../Box";
import { cx } from "../../utils";
import * as styles from "./Divider.styles";
const Divider = React.forwardRef<
HTMLDivElement | HTMLHRElement,
T.DividerProps
>(
(
{ children, border = false, orientation = "horizontal", size, ...props },
forwardedRef
) => {
const classes = cx(
styles.dividerStyles({ orientation, size, border }),
props.className
);
return match({ border })
.with({ border: true }, () => (
<Box
{...props}
className={cx([classes], {
"py-0": orientation === "vertical",
"px-0": orientation === "horizontal",
})}
>
<Box
className={cx(["border", "border-mono-border"], {
"w-full h-px": orientation === "horizontal",
"h-full w-px": orientation === "vertical",
})}
/>
</Box>
))
.otherwise(() => (
<div {...props} className={classes} ref={forwardedRef} />
));
}
);
// const horizontal = ["w-6", "h-px"];
// const vertical = ["h-6", "w-px"];
export { Divider };

@ -0,0 +1,10 @@
import { VariantProps } from "class-variance-authority";
import { dividerStyles } from "./Divider.styles";
import { HTMLAttributes } from "react";
type DividerProps = VariantProps<typeof dividerStyles> &
HTMLAttributes<HTMLDivElement> & {
border?: boolean;
};
export { DividerProps };

@ -0,0 +1,2 @@
export * from "./Divider";
export * from "./Divider.types";

@ -0,0 +1,30 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Dropdown } from "./Dropdown";
import { Button } from "../Button";
import { cx } from "../../utils";
const meta: Meta<typeof Dropdown> = {
title: "UI / Dropdown",
component: Dropdown,
};
export default meta;
type Story = StoryObj<typeof Dropdown>;
export const Default: Story = {
render: () => (
<Dropdown
options={[
{ label: "Profile", value: "/profile" },
{
label: "Sign out",
value: "/sign-out",
onSelect: (value) => console.log("sign out!", value),
},
]}
>
<Button>Open</Button>
</Dropdown>
),
};

@ -0,0 +1,43 @@
const content = [
"relative",
"max-h-96",
"min-w-[8rem]",
"p-1",
"border-2",
"border-mono-border",
"overflow-hidden",
"rounded-lg",
"bg-white",
// Animation
"data-[state=open]:animate-in",
"data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0",
"data-[state=open]:fade-in-0",
"data-[state=closed]:zoom-out-95",
"data-[state=open]:zoom-in-95",
"data-[side=bottom]:slide-in-from-top-2",
"data-[side=left]:slide-in-from-right-2",
"data-[side=right]:slide-in-from-left-2",
"data-[side=top]:slide-in-from-bottom-2",
];
const item = [
"relative",
"flex",
"w-full",
"cursor-default",
"select-none",
"items-center",
"py-0.5",
"px-2",
"rounded-sm",
"data-[disabled]:pointer-events-none",
"data-[disabled]:text-mono-text/50",
"outline-none",
"focus:rounded-md",
"focus:bg-mono-primary",
"focus:text-white",
"focus:border-mono-primary",
];
export { item, content };

@ -0,0 +1,33 @@
import * as React from "react";
import * as $ from "@radix-ui/react-dropdown-menu";
import * as T from "./Dropdown.types";
import * as styles from "./Dropdown.styles";
import { cx } from "../../utils";
const Dropdown = React.forwardRef<T.DropdownElement, T.DropdownProps>(
({ children, options, ...props }, forwardedRef) => {
return (
<$.Root>
<$.Trigger asChild>{children}</$.Trigger>
<$.Content
sideOffset={4}
{...props}
className={cx([styles.content, props.className])}
ref={forwardedRef}
>
{options?.map(({ label, value, icon: Icon, onSelect }) => (
<$.Item
className={cx([styles.item])}
onSelect={() => onSelect?.(value)}
>
{Icon && <Icon className={cx(["mr-2"])} />}
{label}
</$.Item>
))}
</$.Content>
</$.Root>
);
}
);
export { Dropdown };

@ -0,0 +1,18 @@
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import { IconType } from "react-icons";
type DropdownOption = {
label: string;
value: string;
icon?: IconType;
onSelect?: (value: string) => void;
};
type DropdownElement = React.ElementRef<typeof Primitive.div>;
type DropdownProps = React.ComponentPropsWithoutRef<typeof Primitive.div> & {
options: DropdownOption[];
};
export type { DropdownElement, DropdownProps };

@ -0,0 +1,2 @@
export * from "./Dropdown";
export * from "./Dropdown.types";

@ -0,0 +1,48 @@
import * as React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "../Box";
import { Button } from "../Button";
import * as Card from "../Card";
import { Flyout } from "./Flyout";
import { cx } from "../../utils";
import { Input } from "../Input";
const meta: Meta<typeof Flyout> = {
title: "UI/Flyout",
component: Flyout,
};
export default meta;
type Story = StoryObj<typeof Flyout>;
export const Default: Story = {
render: () => (
<Flyout>
<Card.$ paddless borderless>
<Card.Header>
<Card.Title>Hello, world.</Card.Title>
<Card.Description>This is a modal example.</Card.Description>
</Card.Header>
<Card.Body>
<form onSubmit={(event) => event.preventDefault()}>
<Input label="Name" />
<Box className={cx(["py-2"])} />
<Input label="Type" />
<Box className={cx(["py-2"])} />
<Input label="Balance" money />
</form>
</Card.Body>
<Card.Footer className={cx(["flex", "justify-between", "mt-auto"])}>
<Button>Cancel</Button>
<Button intent="primary">Save</Button>
</Card.Footer>
</Card.$>
</Flyout>
),
};

@ -0,0 +1,71 @@
import { cva } from "class-variance-authority";
const description = ["text-mono-text"];
const overlay = [
"fixed",
"inset-0",
"z-50",
"bg-black/80",
"data-[state=open]:animate-in",
"data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0",
"data-[state=open]:fade-in-0",
];
const base = [
"fixed",
"z-50",
"gap-4",
"bg-white",
"shadow-lg",
"transition",
"ease-in-out",
"group",
"data-[state=open]:animate-in",
"data-[state=closed]:animate-out",
"data-[state=closed]:duration-300",
"data-[state=open]:duration-500",
];
const close = [
"absolute",
"top-3",
"-right-10",
"bg-transparent",
"hover:bg-transparent",
"text-xl",
"text-gray-200",
];
const flyoutStyles = cva(base, {
variants: {
side: {
left: [
"inset-y-0",
"left-0",
"h-full",
"w-3/4",
"border-r",
"data-[state=closed]:slide-out-to-left",
"data-[state=open]:slide-in-from-left",
"sm:max-w-sm",
],
right: [
"inset-y-0",
"right-0",
"h-full",
"w-3/4",
"border-l",
"data-[state=closed]:slide-out-to-right",
"data-[state=open]:slide-in-from-right",
"sm:max-w-sm",
],
},
},
defaultVariants: {
side: "right",
},
});
export { flyoutStyles, description, overlay, close };

@ -0,0 +1,53 @@
import * as React from "react";
import { FaCircleXmark } from "react-icons/fa6";
import { match, P } from "ts-pattern";
import * as $ from "@radix-ui/react-dialog";
import * as T from "./Flyout.types";
import * as styles from "./Flyout.styles";
import { Button } from "../Button";
import { cx } from "../../utils";
import { Box } from "../Box";
import { FaTimes } from "react-icons/fa";
const Flyout = React.forwardRef<T.FlyoutElement, T.FlyoutProps>(
({ trigger, side, children, ...props }, forwardedRef) => {
const [open, setOpen] = React.useState(false);
const classes = cx(styles.flyoutStyles({ side }), props.className);
return (
<$.Root open={open} onOpenChange={setOpen}>
<$.Trigger asChild>
{match(trigger)
.with(P.not(P.nullish), (t) => t)
.otherwise(() => (
<Button>Open</Button>
))}
</$.Trigger>
<$.Portal>
<$.Overlay className={cx([styles.overlay])} />
<$.Content {...props} className={classes}>
<Box>{children}</Box>
<$.Close asChild>
<Button
aria-label="Close"
className={cx([
styles.close,
"border-0",
"p-0",
"animate",
{
"animate-in fade-in duration-300": open,
"animate-out fade-out duration-300": !open,
},
])}
>
<FaTimes />
</Button>
</$.Close>
</$.Content>
</$.Portal>
</$.Root>
);
}
);
export { Flyout };

@ -0,0 +1,13 @@
import React from "react";
import * as $ from "@radix-ui/react-dialog";
import { VariantProps } from "class-variance-authority";
import * as styles from "./Flyout.styles";
type FlyoutElement = React.ElementRef<typeof $.Content>;
type FlyoutProps = React.ComponentProps<typeof $.Content> &
VariantProps<typeof styles.flyoutStyles> & {
trigger?: React.ReactNode;
};
export type { FlyoutElement, FlyoutProps };

@ -0,0 +1,2 @@
export * from "./Flyout";
export * from "./Flyout.types";

@ -0,0 +1,49 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "../Box";
import { Input } from "./Input";
import { cx } from "../../utils";
const meta: Meta<typeof Input> = {
title: "UI/Input",
component: Input,
};
export default meta;
type Story = StoryObj<typeof Input>;
export const Default: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Input label="Name" />
</Box>
),
};
export const Money: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Input label="Balance" money />
</Box>
),
};
export const helpText: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Input label="Address" helpText="Provide full address and zip code." />
</Box>
),
};
export const WithError: Story = {
render: () => (
<Box className={cx(["w-96"])}>
<Input
label="Address"
hasError
helpText="Provide full address and zip code."
/>
</Box>
),
};

@ -0,0 +1,29 @@
import { cva } from "class-variance-authority";
const base = [
"block",
"w-full",
"rounded-lg",
"border-2",
"border-mono-border",
"py-1.5",
"px-2",
"text-left",
"text-mono-text",
"text-ellipsis",
"placeholder:text-mono-border",
"outline-none",
"focus:ring-0",
"focus:border-mono-primary",
];
const inputStyles = cva(base, {
variants: {
hasError: {
true: "border-mono-error",
},
},
defaultVariants: {},
});
export { inputStyles };

@ -0,0 +1,104 @@
import * as React from "react";
import dashify from "dashify";
import { NumericFormat } from "react-number-format";
import type * as T from "./Input.types";
import { Box } from "../Box";
import { Label, HelpText } from "../Common";
import { cx } from "../../utils";
import { inputStyles } from "./Input.styles";
import { match, P } from "ts-pattern";
const Input = React.forwardRef<HTMLInputElement, T.InputProps>(
(
{
label,
helpText,
money,
numericFormatOptions,
hideLabel = false,
symbol = "$",
currency = "USD",
hasError = false,
...props
},
forwardedRef
) => {
const htmlId = dashify(label);
const classes = cx(
inputStyles({ hasError }),
{
"pr-12": currency,
"text-right": money,
},
props.className
);
const moneyDecoratorsClasses = [
"pointer-events-none",
"absolute",
"inset-y-0",
"flex",
"items-center",
];
return (
<Box className={cx(["relative"])}>
<Label
className={cx({
"sr-only": hideLabel,
})}
htmlFor={htmlId}
>
{label}
</Label>
<Box
className={cx(["relative"], {
"mt-1": !hideLabel,
})}
>
{match(money)
.with(true, () => (
<>
<Box className={cx(["left-0", "pl-3"], moneyDecoratorsClasses)}>
<span className={cx(["text-mono-primary", "sm:text-sm"])}>
{symbol}
</span>
</Box>
<NumericFormat
id={htmlId}
className={classes}
valueIsNumericString
{...numericFormatOptions}
{...props}
// prefix={"$"}
getInputRef={forwardedRef}
/>
<Box
className={cx(["right-0", "pr-3"], moneyDecoratorsClasses)}
>
<span className={cx(["text-mono-primary", "sm:text-sm"])}>
{currency}
</span>
</Box>
</>
))
.otherwise(() => (
<input
{...props}
id={htmlId}
className={classes}
ref={forwardedRef}
/>
))}
</Box>
{match(helpText)
.with(P.not(P.nullish), (helpText) => (
<HelpText hasError={hasError}>{helpText}</HelpText>
))
.otherwise(() => null)}
</Box>
);
}
);
export { Input };

@ -0,0 +1,22 @@
import { InputHTMLAttributes } from "react";
import { NumericFormatProps } from "react-number-format";
import { VariantProps } from "class-variance-authority";
import * as Common from "../Common";
import { inputStyles } from "./Input.styles";
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size"> &
VariantProps<typeof inputStyles> &
Common.T.InputProps & {
money?: boolean;
type?: NumericFormatProps["type"];
value?: HTMLInputElement["value"] | NumericFormatProps["value"];
defaultValue?:
| HTMLInputElement["defaultValue"]
| NumericFormatProps["defaultValue"];
onValueChange?: NumericFormatProps["onValueChange"];
numericFormatOptions?: NumericFormatProps;
symbol?: string;
currency?: string;
};
export { InputProps };

@ -0,0 +1,2 @@
export * from "./Input";
export * from "./Input.types";

@ -0,0 +1,48 @@
import * as React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Box } from "../Box";
import { Button } from "../Button";
import * as Card from "../Card";
import { Modal } from "./Modal";
import { cx } from "../../utils";
import { Input } from "../Input";
const meta: Meta<typeof Modal> = {
title: "UI/Modal",
component: Modal,
};
export default meta;
type Story = StoryObj<typeof Modal>;
export const Default: Story = {
render: () => (
<Modal>
<Card.$ paddless borderless>
<Card.Header>
<Card.Title>Hello, world.</Card.Title>
<Card.Description>This is a modal example.</Card.Description>
</Card.Header>
<Card.Body>
<form onSubmit={(event) => event.preventDefault()}>
<Input label="Name" />
<Box className={cx(["py-2"])} />
<Input label="Type" />
<Box className={cx(["py-2"])} />
<Input label="Balance" money />
</form>
</Card.Body>
<Card.Footer className={cx(["flex", "justify-between"])}>
<Button>Cancel</Button>
<Button intent="primary">Save</Button>
</Card.Footer>
</Card.$>
</Modal>
),
};

@ -0,0 +1,27 @@
import { cva } from "class-variance-authority";
const base = [""];
const title = ["text-lg", "font-semibold"];
const description = ["text-mono-text"];
const overlay = ["fixed", "inset-0", "bg-black", "bg-opacity-50"];
const content = [
"fixed",
"top-1/2",
"left-1/2",
"transform",
"-translate-x-1/2",
"-translate-y-1/2",
"bg-transparent",
"w-96",
"rounded-md",
];
const close = ["absolute", "top-3", "right-3", "text-xl"];
const modalStyles = cva(base);
export { modalStyles, title, description, overlay, content, close };

@ -0,0 +1,45 @@
import * as React from "react";
import { FaCircleXmark } from "react-icons/fa6";
import { match, P } from "ts-pattern";
import * as $ from "@radix-ui/react-dialog";
import * as T from "./Modal.types";
import * as styles from "./Modal.styles";
import { Button } from "../Button";
import { cx } from "../../utils";
import { Box } from "../Box";
const Modal = React.forwardRef<T.ModalElement, T.ModalProps>(
({ trigger, children, ...props }, forwardedRef) => {
return (
<$.Root>
<$.Trigger asChild>
{match(trigger)
.with(P.not(P.nullish), (t) => <>{t}</>)
.otherwise(() => (
<Button>Open</Button>
))}
</$.Trigger>
<$.Portal>
<$.Overlay className={cx([styles.overlay])} />
<$.Content
className={cx([styles.content, props.className])}
{...props}
>
<Box>{children}</Box>
<$.Close asChild>
<Button
aria-label="Close"
onlyIcon
className={cx([styles.close, "border-0", "p-0"])}
>
<FaCircleXmark />
</Button>
</$.Close>
</$.Content>
</$.Portal>
</$.Root>
);
}
);
export { Modal };

@ -0,0 +1,13 @@
import React from "react";
import * as $ from "@radix-ui/react-dialog";
import { VariantProps } from "class-variance-authority";
import { modalStyles } from "./Modal.styles";
type ModalElement = React.ElementRef<typeof $.Content>;
type ModalProps = React.ComponentProps<typeof $.Content> &
VariantProps<typeof modalStyles> & {
trigger?: React.ReactNode;
};
export type { ModalElement, ModalProps };

@ -0,0 +1,2 @@
export * from "./Modal";
export * from "./Modal.types";

@ -0,0 +1,64 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Select, SelectItem } from "./Select";
const meta: Meta<typeof Select> = {
title: "UI/Select",
component: Select,
};
export default meta;
type Story = StoryObj<typeof Select>;
const options = [
{ label: "Banana", value: "banana" },
{ label: "Apple", value: "apple" },
{ label: "Pear", value: "pear" },
];
export const Default: Story = {
render: () => (
<Select label="Fruits" placeholder="Select a fruit" tabIndex={0}>
{options.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</Select>
),
};
export const HelpText: Story = {
render: () => (
<Select
label="Fruits"
placeholder="Select a fruit"
tabIndex={0}
helpText="Select from an approved list of fruits."
>
{options.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</Select>
),
};
export const WithError: Story = {
render: () => (
<Select
label="Fruits"
placeholder="Select a fruit"
tabIndex={0}
hasError
helpText="You must select one fruit."
>
{options.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</Select>
),
};

@ -0,0 +1,97 @@
import { cva } from "class-variance-authority";
// trigger
const base = [
"inline-flex",
"items-center",
"justify-between",
"border-2",
"border-mono-border",
"py-1.5",
"px-2",
"rounded-lg",
"focus:outline-none",
"focus:border-mono-primary",
];
const viewport = ["p-1"];
const content = [
"relative",
"max-h-96",
"min-w-[8rem]",
// "py-1.5",
// "px-2",
"border-2",
"border-mono-border",
"overflow-hidden",
"rounded-lg",
"bg-white",
// Animation
"data-[state=open]:animate-in",
"data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0",
"data-[state=open]:fade-in-0",
"data-[state=closed]:zoom-out-95",
"data-[state=open]:zoom-in-95",
"data-[side=bottom]:slide-in-from-top-2",
"data-[side=left]:slide-in-from-right-2",
"data-[side=right]:slide-in-from-left-2",
"data-[side=top]:slide-in-from-bottom-2",
];
const scroll = [
"flex",
"cursor-default",
"items-center",
"justify-center",
"py-1",
];
const indicator = [
"absolute",
"top-1/2",
"-translate-y-1/2",
"right-2",
"inline-flex",
"items-center",
"justify-center",
];
const selectStyles = cva(base, {
variants: {
fullWidth: {
true: "w-full",
},
hasError: {
true: "border-mono-error",
},
},
defaultVariants: {
fullWidth: false,
},
});
const item = [
"relative",
"flex",
"w-full",
"cursor-default",
"select-none",
"items-center",
"py-0.5",
"px-2",
"rounded-sm",
"data-[disabled]:pointer-events-none",
"data-[disabled]:text-mono-text/50",
"outline-none",
"focus:rounded-md",
"focus:bg-mono-primary",
"focus:text-white",
"focus:border-mono-primary",
];
const itemStyles = cva(item);
export { selectStyles, itemStyles, viewport, content, indicator, scroll };

@ -0,0 +1,89 @@
import * as React from "react";
import * as $ from "@radix-ui/react-select";
import { match, P } from "ts-pattern";
import { FaCheck, FaChevronDown, FaChevronUp } from "react-icons/fa";
import * as T from "./Select.types";
import * as styles from "./Select.styles";
import { cx } from "../../utils";
import { Box } from "../Box";
import { Label, HelpText } from "../Common";
const Select = React.forwardRef<T.SelectElement, T.SelectProps>(
(
{
label,
hideLabel = false,
helpText,
fullWidth,
hasError,
children,
className,
...props
},
ref
) => {
const classes = cx(
[styles.selectStyles({ fullWidth, hasError })],
className
);
return (
<Box className={cx(["relative"])}>
<Label
htmlFor={"select"}
className={cx([""], {
"sr-only": hideLabel,
})}
>
{label}
</Label>
<Box className={cx(["mt-1"])}>
<$.Root>
<$.Trigger id="select" {...props} className={classes} ref={ref}>
<$.Value placeholder={props.placeholder} />
<$.Icon className={cx(["ml-2"])} asChild>
<FaChevronDown />
</$.Icon>
</$.Trigger>
<$.Portal>
<$.Content className={cx([styles.content])} position="popper">
<$.ScrollUpButton className={cx([styles.scroll])}>
<FaChevronUp />
</$.ScrollUpButton>
<$.Viewport className={cx([styles.viewport])}>
{children}
</$.Viewport>
<$.ScrollDownButton className={cx([styles.scroll])}>
<FaChevronDown />
</$.ScrollDownButton>
<$.Arrow />
</$.Content>
</$.Portal>
</$.Root>
</Box>
{match(helpText)
.with(P.not(P.nullish), (helpText) => (
<HelpText hasError={hasError}>{helpText}</HelpText>
))
.otherwise(() => null)}
</Box>
);
}
);
const SelectItem = React.forwardRef<T.SelectItemElement, T.SelectItemProps>(
({ children, className, ...props }, forwardedRef) => {
const classes = cx([styles.itemStyles()], className);
return (
<$.Item {...props} className={classes} ref={forwardedRef}>
<$.ItemText>{children}</$.ItemText>
<$.ItemIndicator className={cx([styles.indicator])}>
<FaCheck />
</$.ItemIndicator>{" "}
</$.Item>
);
}
);
export { Select, SelectItem };

@ -0,0 +1,34 @@
import * as React from "react";
import * as $ from "@radix-ui/react-select";
import * as Common from "../Common";
import { VariantProps } from "class-variance-authority";
import { selectStyles } from "./Select.styles";
type SelectOption = {
label: string;
value: string;
};
type SelectSection = {
label: string;
value: SelectOption[];
};
type SelectElement = React.ElementRef<typeof $.Trigger>;
type SelectProps = React.ComponentPropsWithoutRef<typeof $.Trigger> &
VariantProps<typeof selectStyles> &
Common.T.InputProps & {};
type SelectItemElement = React.ElementRef<typeof $.Item>;
type SelectItemProps = React.ComponentPropsWithoutRef<typeof $.Item> & {};
export {
SelectOption,
SelectSection,
SelectElement,
SelectProps,
SelectItemElement,
SelectItemProps,
};

@ -0,0 +1,2 @@
export * from "./Select";
export * from "./Select.types";

@ -0,0 +1,21 @@
import * as React from "react";
import { Box } from "../../components/Box";
import { cx } from "../../utils";
import { Header } from "./Header";
const Content = () => {
return (
<>
<Header />
<Box className={cx(["py-10"])} asChild>
<main>
<Box className={cx(["px-4", "sm:px-6", "lg:px-8"])}>
<p className={cx(["text-mono-text"])}>Dashboard content</p>
</Box>
</main>
</Box>
</>
);
};
export { Content };

@ -0,0 +1,19 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { Dashboard } from "./Dashboard";
const meta: Meta<typeof Dashboard> = {
title: "Examples / Dashboard",
component: Dashboard,
};
export default meta;
type Story = StoryObj<typeof Dashboard>;
export const Default: Story = {
render: () => <Dashboard />,
};
Default.parameters = {
layout: "fullscreen",
};

@ -0,0 +1,30 @@
import * as React from "react";
import { Box, cx } from '../../index';
import { Sidebar } from "./Sidebar";
import { Content } from "./Content";
const Dashboard = () => {
return (
<Box className={cx(["flex", "flex-col"])}>
<Box
className={cx([
"hidden",
"lg:fixed",
"lg:inset-y-0",
"lg:z-50",
"lg:flex",
"lg:w-72",
"lg:flex-col",
])}
>
<Sidebar />
</Box>
<Box className={cx(["lg:pl-72"])}>
<Content />
</Box>
</Box>
);
};
export { Dashboard };

@ -0,0 +1,83 @@
import * as React from "react";
import { FaCog } from "react-icons/fa";
import { FaBars, FaDoorOpen, FaUserLarge } from "react-icons/fa6";
import { Box } from "../../components/Box";
import { cx } from "../../utils";
import { Button } from "../../components/Button";
import { Divider } from "../../components/Divider";
import { Dropdown } from "../../components/Dropdown";
import { Flyout } from "../../components/Flyout";
import { Sidebar } from "./Sidebar";
const userNav = [
{
label: "Your Profile",
value: "/profile",
icon: FaUserLarge,
},
{
label: "Settings",
value: "/settings",
icon: FaCog,
},
{
label: "Sign out",
value: "/sign-out",
icon: FaDoorOpen,
},
];
const Header = () => {
return (
<Box
className={cx([
"sticky",
"top-0",
"z-40",
"flex",
"h-16",
"shrink-0",
"items-center",
"gap-x-4",
"border-b-2",
"border-mono-border",
"bg-white",
"px-4",
"sm:gap-x-6",
"sm:px-6",
"lg:px-8",
])}
>
<Box className={cx(["flex", "w-full"])}>
<Flyout
side="left"
className={cx(["border-0"])}
trigger={
<Button intent="plain" aria-label="Open sidebar">
<FaBars />
</Button>
}
>
<Sidebar />
</Flyout>
<Divider
className={cx(["ml-auto"])}
border
orientation="vertical"
size="xl"
/>
<Box>
<Dropdown options={userNav}>
<Button intent="plain">
<FaUserLarge />
</Button>
</Dropdown>
</Box>
</Box>
</Box>
);
};
export { Header };

@ -0,0 +1,48 @@
const base = [
"flex",
"grow",
"flex-col",
"gap-y-5",
"overflow-y-auto",
"border-r-2",
"border-mono-border",
"px-6",
"pb-4",
];
const logoContainer = ["flex", "h-16", "shrink-0", "items-center"];
const logo = ["h-8", "w-auto"];
const navItem = [
"text-mono-primary",
"hover:bg-mono-hover",
"group",
"flex",
"gap-x-3",
"rounded-md",
"p-2",
"leading-6",
"font-semibold",
"flex",
"items-center",
];
const listContainer = ["flex", "flex-1", "flex-col"];
const list = ["flex", "flex-col", "flex-1", "gap-y-1"];
const subList = ["-mx-2", "space-y-1"];
const icon = ["w-5", "h-5"];
export {
base,
logoContainer,
logo,
listContainer,
list,
subList,
navItem,
icon,
};

@ -0,0 +1,52 @@
import * as React from "react";
import { FaHome, FaUsers, FaCog } from "react-icons/fa";
import { Box } from "../../components/Box";
import { cx } from "../../utils";
import * as styles from "./Sidebar.styles";
const Sidebar = () => {
return (
<Box className={cx([styles.base])}>
<Box className={cx([styles.logoContainer])}>
<img
className={cx([styles.logo])}
src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=500"
alt="Your Company"
/>
</Box>
<Box className={cx([styles.listContainer])} asChild>
<nav>
<ul role="list" className={cx([styles.list])}>
<li>
<ul role="list" className={cx([styles.subList])}>
<li>
<a className={cx([styles.navItem])} href="#">
<FaHome className={cx([styles.icon])} />
Dashboard
</a>
</li>
<li>
<a className={cx([styles.navItem])} href="#">
<FaUsers className={cx([styles.icon])} />
Team
</a>
</li>
<li>
<a className={cx([styles.navItem])} href="#">
<FaCog className={cx([styles.icon])} />
Projects
</a>
</li>
</ul>
</li>
</ul>
</nav>
</Box>
</Box>
);
};
export { Sidebar };

@ -0,0 +1,19 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { SignUp } from "./SignUp";
const meta: Meta<typeof SignUp> = {
title: "Examples / SignUp",
component: SignUp,
};
export default meta;
type Story = StoryObj<typeof SignUp>;
export const Default: Story = {
render: () => <SignUp />,
};
Default.parameters = {
layout: "fullscreen",
};

@ -0,0 +1,27 @@
import * as React from "react";
import { Box, Button, Card, Input, cx } from "../../index";
const SignUp = () => {
return (
<Box className={cx(["w-1/3", "mx-auto", "p-5"])}>
<Card.$ paddless>
<Card.Header>
<Card.Title>Sign up</Card.Title>
<Card.Description>Create a new account.</Card.Description>
</Card.Header>
<Card.Body>
<Box>
<Input label={"Email address"} />
</Box>
</Card.Body>
<Card.Footer>
<Button>Sign Up</Button>
</Card.Footer>
</Card.$>
</Box>
);
};
export { SignUp };

@ -0,0 +1,10 @@
import * as Card from "./components/Card";
export { Card };
export { Box } from "./components/Box";
export { Button } from "./components/Button";
export { Divider } from "./components/Divider";
export { Input } from "./components/Input";
export { Modal } from "./components/Modal";
export { Select } from "./components/Select";
export { Dropdown } from "./components/Dropdown";
export { cx } from "./utils";

@ -0,0 +1,8 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
html {
font-size: 14px;
}

@ -0,0 +1,6 @@
import { ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
const cx = (...classes: ClassValue[]) => twMerge(clsx(classes));
export { cx };

@ -0,0 +1,7 @@
{
"root": "storybook-static/",
"clean_urls": true,
"routes": {
"/**": "index.html"
}
}

@ -0,0 +1,45 @@
const colors = require("tailwindcss/colors");
const defaultTheme = require("tailwindcss/defaultTheme");
const Color = require("color");
// https://github.com/tailwindlabs/discuss/issues/392#issuecomment-559305633
const alpha = (clr, val) => Color(clr).alpha(val).rgb().string();
const lighen = (clr, val) => Color(clr).lighten(val).rgb().string();
const darken = (clr, val) => Color(clr).darken(val).rgb().string();
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: "class",
content: [
"./src/components/**/*.{ts,tsx}",
"./src/examples/**/*.{ts,tsx}",
"./src/index.ts",
],
theme: {
extend: {
colors: {
"mono-primary": {
DEFAULT: colors.zinc[800],
hover: colors.zinc[700],
},
"mono-border": {
DEFAULT: colors.gray["300"],
},
"mono-text": {
DEFAULT: colors.gray["500"],
},
"mono-hover": {
DEFAULT: colors.gray[200],
},
"mono-rounded": {
DEFAULT: defaultTheme.borderRadius["lg"],
},
"mono-error": {
DEFAULT: colors.red[500],
hover: colors.red[400],
},
},
},
},
plugins: [require("@tailwindcss/forms"), require("tailwindcss-animate")],
};

@ -0,0 +1,104 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
"declarationDir": "types", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": ["dist", "node_modules", "src/**/*.test.tsx", "src/**/*.stories.tsx"]
}

@ -0,0 +1,17 @@
import { defineConfig } from "tsup";
export default defineConfig({
outExtension({ format }) {
return {
js: `.${format}.js`,
};
},
entry: ["src/index.ts"],
format: ["esm", "cjs"],
dts: true,
splitting: false,
sourcemap: true,
clean: true,
minify: true,
noExternal: ["react-icons"],
});
Loading…
Cancel
Save