@tomo-inc/tomo-ui 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,217 @@
1
+ # @tomo-inc/tomo-ui
2
+
3
+ Tomo UI is a React-based design system built on top of **HeroUI** and **Tailwind CSS v4**.
4
+ It provides:
5
+
6
+ - A **component layer** (`Button`, `Card`, `Modal`, etc.) with Tomo defaults
7
+ - A **provider layer** (`TomoUIProvider`) and a **theme hook** (`useTheme`)
8
+ - A **Tailwind v4 plugin** that wires HeroUI and Tomo design tokens together
9
+
10
+ It is designed so that **applications only depend on `@tomo-inc/tomo-ui`**, without touching the underlying UI framework directly.
11
+
12
+ ---
13
+
14
+ ## 1. Installation
15
+
16
+ > This package is currently intended for use inside the Tomo monorepo and selected internal projects.
17
+
18
+ Install from your workspace (example uses `pnpm`):
19
+
20
+ ```bash
21
+ pnpm add @tomo-inc/tomo-ui
22
+ ```
23
+
24
+ Peer dependencies (usually already present in the host app):
25
+
26
+ - `react` `>=18`
27
+ - `react-dom` `>=18`
28
+ - `tailwindcss` `^4` (for apps that want to use the Tailwind plugin)
29
+
30
+ ---
31
+
32
+ ## 2. Usage
33
+
34
+ ### 2.1 Basic React usage
35
+
36
+ Wrap your app with `TomoUIProvider` and import components from the root package:
37
+
38
+ ```tsx
39
+ import {
40
+ TomoUIProvider,
41
+ Button,
42
+ Card,
43
+ CardBody,
44
+ CardFooter,
45
+ CardHeader,
46
+ } from "@tomo-inc/tomo-ui";
47
+
48
+ export function App() {
49
+ return (
50
+ <TomoUIProvider>
51
+ <div className="app-root">
52
+ <Card>
53
+ <CardHeader>
54
+ <h1>Tomo UI Starter</h1>
55
+ </CardHeader>
56
+ <CardBody>
57
+ <p>Now you can start building with @tomo-inc/tomo-ui components.</p>
58
+ </CardBody>
59
+ <CardFooter>
60
+ <Button color="primary">Get Started</Button>
61
+ </CardFooter>
62
+ </Card>
63
+ </div>
64
+ </TomoUIProvider>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ### 2.2 Tailwind CSS v4 integration
70
+
71
+ Tomo UI ships a Tailwind v4 plugin that wraps HeroUI and Tomo design tokens.
72
+ In your main CSS entry (for example `src/index.css`):
73
+
74
+ ```css
75
+ @import "tailwindcss";
76
+
77
+ @plugin "@tomo-inc/tomo-ui/tailwind/plugin";
78
+
79
+ @source "./**/*.{js,ts,jsx,tsx,mdx}";
80
+ @source "../node_modules/@tomo-inc/tomo-ui/dist/**/*.{js,mjs}";
81
+ ```
82
+
83
+ Notes:
84
+
85
+ - `@plugin` references the **Tomo UI plugin only**; your app does not need to reference HeroUI directly.
86
+ - `@source` must include:
87
+ - Your application source (so Tailwind can see your class usage)
88
+ - Tomo UI’s `dist` (so Tailwind can generate classes used by Tomo components)
89
+
90
+ Tailwind v4 is configured via PostCSS only. A minimal `postcss.config.(js|mjs|cjs)` looks like:
91
+
92
+ ```js
93
+ export default {
94
+ plugins: {
95
+ "@tailwindcss/postcss": {},
96
+ },
97
+ };
98
+ ```
99
+
100
+ ### 2.3 Dynamic theme configuration
101
+
102
+ Tomo UI allows you to provide a theme configuration at runtime.
103
+ The type is aligned with HeroUI’s theme configuration surface.
104
+
105
+ ```tsx
106
+ import {
107
+ TomoUIProvider,
108
+ useTheme,
109
+ type ThemeConfig,
110
+ } from "@tomo-inc/tomo-ui";
111
+
112
+ const themeConfig: ThemeConfig = {
113
+ themes: {
114
+ light: {
115
+ colors: {
116
+ primary: "#FCD436",
117
+ },
118
+ },
119
+ dark: {
120
+ colors: {
121
+ primary: "#FCD436",
122
+ },
123
+ },
124
+ },
125
+ defaultTheme: "light",
126
+ };
127
+
128
+ export function Root() {
129
+ return (
130
+ <TomoUIProvider themeConfig={themeConfig}>
131
+ <ThemedApp />
132
+ </TomoUIProvider>
133
+ );
134
+ }
135
+
136
+ function ThemedApp() {
137
+ const { theme, setTheme } = useTheme();
138
+
139
+ return (
140
+ <div>
141
+ <p>Current theme: {theme}</p>
142
+ <button onClick={() => setTheme("light")}>Light</button>
143
+ <button onClick={() => setTheme("dark")}>Dark</button>
144
+ </div>
145
+ );
146
+ }
147
+ ```
148
+
149
+ Under the hood, the provider:
150
+
151
+ - Runs the Tomo UI Tailwind plugin at build time to generate base tokens
152
+ - Uses `themeConfigToCSS` at runtime to convert your `ThemeConfig` into CSS variables
153
+ - Scopes the variables to the provider’s DOM subtree, enabling per-subtree theming
154
+
155
+ ---
156
+
157
+ ## 3. Architecture Overview
158
+
159
+ High-level architecture of `@tomo-inc/tomo-ui`:
160
+
161
+ - **React components**
162
+ - Most components are **thin wrappers** around HeroUI components.
163
+ - Props and types are re-exported from the root package so consumers only import from `@tomo-inc/tomo-ui`.
164
+ - Domain-specific primitives (e.g. formatted numbers, QR code, MFA/passcode inputs) live under `src/components`.
165
+
166
+ - **Provider and theming**
167
+ - `TomoUIProvider` wraps `HeroUIProvider` and a custom `ThemeContextProvider`.
168
+ - `ThemeConfig` (a typed wrapper around HeroUI’s theme config) is converted to CSS variables via `themeConfigToCSS`.
169
+ - Theme variables are scoped to a unique DOM node, allowing:
170
+ - Multiple independent theme instances on the same page
171
+ - Runtime theme switching (light/dark or brand-based)
172
+
173
+ - **Tailwind v4 integration**
174
+ - `src/tailwind/plugin.ts` defines `baseConfig` and exports `heroui(baseConfig)` as the Tailwind plugin.
175
+ - The compiled plugin is exposed as `@tomo-inc/tomo-ui/tailwind/plugin`.
176
+ - During build, HeroUI’s theme dist is copied into `dist/theme` so that Tailwind can scan it through Tomo UI’s own package paths.
177
+ - Applications only interact with:
178
+ - `@plugin "@tomo-inc/tomo-ui/tailwind/plugin";`
179
+ - `@source "../node_modules/@tomo-inc/tomo-ui/dist/**/*.{js,mjs}";`
180
+
181
+ - **Dynamic theme vs. build-time theme**
182
+ - **Build-time**: Tailwind + HeroUI produce the base class names and token structure.
183
+ - **Runtime**: `ThemeConfig` controls the concrete colors and layout tokens via CSS variables.
184
+ - This separation allows you to change branding and theme behavior without changing the Tailwind build configuration.
185
+
186
+ ---
187
+
188
+ ## 4. License, Copyright, and Usage
189
+
190
+ > **Important:** This package is primarily intended for internal use within Tomo, Inc. and for selected partners.
191
+ > It is not a general-purpose public UI library unless explicitly documented and licensed as such.
192
+
193
+ - **Ownership**
194
+ - `@tomo-inc/tomo-ui` is owned and maintained by **Tomo, Inc.**.
195
+ - All source code, compiled artifacts, and design assets are copyrighted.
196
+
197
+ - **Usage scope**
198
+ - Intended for:
199
+ - Applications and packages inside the Tomo monorepo
200
+ - Official Tomo products and demos
201
+ - Partner integrations explicitly authorized by Tomo, Inc.
202
+ - Not intended for:
203
+ - Unlicensed redistribution
204
+ - White-label resale as a standalone UI library
205
+
206
+ - **License**
207
+ - Unless otherwise stated in the repository root (e.g. in a `LICENSE` file), usage is governed by Tomo’s internal agreements and partner contracts.
208
+ - If you are unsure whether you are allowed to use this package, please contact the Tomo team or your technical point of contact.
209
+
210
+ ---
211
+
212
+ If you are extending `@tomo-inc/tomo-ui` or integrating it into a new application, please:
213
+
214
+ - Prefer importing from the root package (`@tomo-inc/tomo-ui`) instead of deep imports.
215
+ - Avoid depending on HeroUI directly; treat it as an internal implementation detail.
216
+ - Keep Tailwind integration minimal and aligned with the usage examples above, so that future UI framework changes can remain transparent to applications.
217
+
package/package.json CHANGED
@@ -1,16 +1,29 @@
1
1
  {
2
2
  "name": "@tomo-inc/tomo-ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
- "main": "./src/index.ts",
6
- "module": "./src/index.ts",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
7
  "types": "./src/index.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/tomo-inc"
11
+ },
12
+ "homepage": "https://github.com/tomo-inc",
13
+ "bugs": {
14
+ "url": "https://github.com/tomo-inc/discussions"
15
+ },
8
16
  "exports": {
9
17
  ".": {
10
18
  "types": "./src/index.ts",
11
- "import": "./src/index.ts",
12
- "require": "./src/index.ts",
13
- "default": "./src/index.ts"
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./tailwind/plugin": {
24
+ "import": "./dist/tailwind/plugin.js",
25
+ "require": "./dist/tailwind/plugin.cjs",
26
+ "default": "./dist/tailwind/plugin.js"
14
27
  },
15
28
  "./tailwind/tailwind.css": "./src/tailwind/tailwind.css"
16
29
  },
@@ -19,6 +32,8 @@
19
32
  "@heroui/react": "2.8.5",
20
33
  "@heroui/system": "^2.4.23",
21
34
  "@heroui/theme": "^2.4.23",
35
+ "bignumber.js": "^9.1.2",
36
+ "classnames": "^2.5.1",
22
37
  "color": "^5.0.3",
23
38
  "flat": "^6.0.1",
24
39
  "framer-motion": "^11.5.6",
@@ -42,6 +57,7 @@
42
57
  "vite": "^7.2.4"
43
58
  },
44
59
  "scripts": {
45
- "dev": "vite"
60
+ "dev": "vite",
61
+ "build": "tsup && node ./scripts/copy-heroui-theme.mjs"
46
62
  }
47
63
  }
package/project.json CHANGED
@@ -5,6 +5,13 @@
5
5
  "projectType": "library",
6
6
  "tags": ["scope:uikit", "type:tomo-uikit"],
7
7
  "targets": {
8
+ "version:up": {
9
+ "executor": "nx:run-commands",
10
+ "options": {
11
+ "cwd": "uikits/tomo-ui",
12
+ "command": "npm version patch --no-git-tag-version"
13
+ }
14
+ },
8
15
  "build": {
9
16
  "executor": "nx:run-commands",
10
17
  "outputs": ["{projectRoot}/dist"],
@@ -0,0 +1,9 @@
1
+ export { Drawer, DrawerBody, DrawerContent, DrawerFooter, DrawerHeader } from "@heroui/react";
2
+
3
+ export type {
4
+ DrawerBodyProps,
5
+ DrawerContentProps,
6
+ DrawerFooterProps,
7
+ DrawerHeaderProps,
8
+ DrawerProps,
9
+ } from "@heroui/react";
@@ -0,0 +1,134 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import classNames from "classnames";
3
+ import { useMemo } from "react";
4
+ import { effectiveBalance, isEmpty } from "../../utils/amount";
5
+ import { NumberType } from "./type";
6
+
7
+ export const AdaptiveFormatted = (
8
+ value: string | number | undefined,
9
+ type: NumberType,
10
+ balanceIsSub?: boolean,
11
+ decimalSubLen?: number,
12
+ decimalFlag?: boolean,
13
+ ) => {
14
+ BigNumber.config({
15
+ FORMAT: {
16
+ prefix: "",
17
+ decimalSeparator: ".",
18
+ groupSeparator: ",",
19
+ groupSize: 3,
20
+ secondaryGroupSize: 0,
21
+ fractionGroupSeparator: " ",
22
+ fractionGroupSize: 0,
23
+ suffix: "",
24
+ },
25
+ EXPONENTIAL_AT: [-18, 30],
26
+ });
27
+
28
+ const valueStr = value?.toString() || "";
29
+ if (isEmpty(valueStr) || !value) {
30
+ return {
31
+ formatted: "-",
32
+ ext: undefined,
33
+ };
34
+ }
35
+ if (valueStr === "0") {
36
+ return {
37
+ formatted: type === NumberType.USD ? "0.00" : "0",
38
+ ext: undefined,
39
+ };
40
+ }
41
+
42
+ const bigValue = new BigNumber(value);
43
+ if (type === NumberType.USD) {
44
+ if (bigValue.lt(0.00001)) {
45
+ return {
46
+ formatted: "0.00001",
47
+ ext: undefined,
48
+ pre: "<",
49
+ };
50
+ }
51
+ }
52
+ if (bigValue.lt(0.000001)) {
53
+ return {
54
+ formatted: "0.000001",
55
+ ext: undefined,
56
+ pre: "<",
57
+ };
58
+ }
59
+
60
+ const normalBalance = new BigNumber(valueStr).toString();
61
+ const [intPart, decimalPart] = normalBalance.split(".");
62
+ if (decimalPart && decimalPart.length > 1 && Number(decimalPart) > 0) {
63
+ const leadingZeros = decimalPart.match(/^0+/);
64
+
65
+ if (leadingZeros && leadingZeros[0].length > 4 && (type === NumberType.PRICE || balanceIsSub)) {
66
+ const exponent = parseInt(decimalPart).toString().substring(0, 4);
67
+ return {
68
+ formatted: `${intPart}.0{${leadingZeros[0].length}}${exponent}`,
69
+ ext: [intPart, leadingZeros[0].length, exponent],
70
+ };
71
+ }
72
+ }
73
+ const formatted = effectiveBalance(normalBalance, type === NumberType.USD ? 2 : 4, decimalSubLen, decimalFlag);
74
+
75
+ return {
76
+ formatted,
77
+ ext: undefined,
78
+ };
79
+ };
80
+
81
+ export interface FormattedNumberProps {
82
+ value: string | number;
83
+ type: NumberType;
84
+ className?: string;
85
+ subClassName?: string;
86
+ formatClassName?: string;
87
+ balanceIsSub?: boolean;
88
+ decimalSubLen?: number;
89
+ decimalFlag?: boolean;
90
+ }
91
+
92
+ export const FormattedNumber = ({
93
+ value,
94
+ type,
95
+ className,
96
+ subClassName,
97
+ formatClassName,
98
+ balanceIsSub,
99
+ decimalSubLen,
100
+ decimalFlag,
101
+ }: FormattedNumberProps) => {
102
+ const node = useMemo(() => {
103
+ const adapt = AdaptiveFormatted(value, type, balanceIsSub, decimalSubLen, decimalFlag);
104
+ if (adapt.ext) {
105
+ const ext = adapt.ext as string[];
106
+ return {
107
+ render: (
108
+ <span>
109
+ {ext[0]}.
110
+ <span>
111
+ 0<sub className={subClassName}>{ext[1]}</sub>
112
+ {ext[2]}
113
+ </span>
114
+ </span>
115
+ ),
116
+ pre: adapt.pre,
117
+ };
118
+ }
119
+ return {
120
+ render: <span className={formatClassName}>{adapt.formatted}</span>,
121
+ pre: adapt.pre,
122
+ };
123
+ }, [value, type, balanceIsSub, decimalSubLen, decimalFlag, formatClassName, subClassName]);
124
+
125
+ return (
126
+ <span className={classNames(className)}>
127
+ {node.pre}
128
+ {(type === NumberType.USD || type === NumberType.PRICE) && "$"}
129
+ {node.render}
130
+ </span>
131
+ );
132
+ };
133
+
134
+ export { FormattedNumber as AdaptiveNumber, NumberType };
@@ -0,0 +1,7 @@
1
+ export const NumberType = {
2
+ USD: "USD",
3
+ PRICE: "PRICE",
4
+ BALANCE: "BALANCE",
5
+ } as const;
6
+
7
+ export type NumberType = (typeof NumberType)[keyof typeof NumberType];
@@ -1,15 +1,21 @@
1
1
  export * from "./button";
2
2
  export * from "./card";
3
3
  export * from "./chip";
4
+ export * from "./drawer";
5
+ export * from "./formatted-number";
4
6
  export * from "./image";
7
+ export * from "./info-item";
5
8
  export * from "./input";
6
9
  export * from "./link";
10
+ export * from "./listbox";
7
11
  export * from "./mfaTypeChoose";
8
12
  export * from "./modal";
9
13
  export * from "./passcodeInput";
10
14
  export * from "./qr";
15
+ export * from "./radio";
11
16
  export * from "./select";
12
17
  export * from "./skeleton";
13
18
  export * from "./spinner";
19
+ export * from "./switch";
14
20
  export * from "./tabs";
15
21
  export * from "./toast";
@@ -0,0 +1,23 @@
1
+ export interface InfoItemProps {
2
+ label?: string | React.ReactNode;
3
+ context?: string | React.ReactNode;
4
+ }
5
+
6
+ export const InfoItem = ({ label, context }: InfoItemProps) => {
7
+ return (
8
+ <div className="flex w-full items-center justify-between gap-1">
9
+ <div className="truncate text-xs font-normal text-default-500 ">
10
+ <span className="w-full opacity-100 h-auto will-change-transform transform-none">{label}</span>
11
+ </div>
12
+ <div className="text-xs font-normal text-foreground flex-1 overflow-hidden">
13
+ <div className="w-full flex justify-end">
14
+ <div className="w-fit max-w-full">
15
+ <span className="w-full opacity-100 h-auto will-change-transform transform-none">{context}</span>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ );
21
+ };
22
+
23
+ export { InfoItem as BaseItem };
@@ -0,0 +1,2 @@
1
+ export { Listbox, ListboxItem } from "@heroui/react";
2
+ export type { ListboxItemProps, ListboxProps } from "@heroui/react";
@@ -1,4 +1,5 @@
1
- import { cn, RadioGroup, RadioProps, useRadio, VisuallyHidden } from "@heroui/react";
1
+ import type { RadioProps } from "@heroui/react";
2
+ import { cn, RadioGroup, useRadio, VisuallyHidden } from "@heroui/react";
2
3
  import { useEffect, useState } from "react";
3
4
 
4
5
  interface CustomRadioProps extends RadioProps {
@@ -0,0 +1,2 @@
1
+ export { Radio, RadioGroup } from "@heroui/react";
2
+ export type { RadioGroupProps, RadioProps } from "@heroui/react";
@@ -0,0 +1,2 @@
1
+ export { Switch } from "@heroui/react";
2
+ export type { SwitchProps } from "@heroui/react";
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from "./components";
2
2
  export * from "./icons";
3
3
 
4
- export { TomoUIProvider } from "./theme-provider";
5
4
  export { useTheme } from "./theme-context";
5
+ export { TomoUIProvider } from "./theme-provider";
6
+ export type { ThemeConfig } from "./types";
7
+
@@ -1,22 +1,10 @@
1
- import { heroui, HeroUIPluginConfig } from "@heroui/react";
1
+ import type { HeroUIPluginConfig } from "@heroui/react";
2
+ import { heroui } from "@heroui/react";
2
3
 
3
4
  export const baseConfig: HeroUIPluginConfig = {
4
5
  // Don't change this prefix, some css not working
5
6
  prefix: "heroui",
6
- // prefix: "tomoui",
7
7
  themes: {
8
- // light: {
9
- // colors: {
10
- // foreground: "#000",
11
- // background: "#FFF",
12
- // content1: "#FCFCFD",
13
- // primary: {
14
- // ...generateColorScale("#fe3c9c"),
15
- // DEFAULT: "#fe3c9c",
16
- // foreground: "#fff",
17
- // },
18
- // },
19
- // },
20
8
  light: {
21
9
  colors: {
22
10
  foreground: "#12122A",
@@ -46,183 +34,6 @@ export const baseConfig: HeroUIPluginConfig = {
46
34
  t5: "#EEC41F",
47
35
  } as any,
48
36
  },
49
- dark: {},
50
37
  },
51
38
  };
52
-
53
- export const ThemePlugin = heroui(baseConfig) as any;
54
- export default ThemePlugin;
55
-
56
- // export const ThemePlugin: any = heroui({
57
- // layout: {},
58
- // themes: {
59
- // light: {
60
- // colors: {
61
- // foreground: "#12122A",
62
- // background: "#FFF",
63
- // content1: "#FCFCFD",
64
- // primary: {
65
- // 50: "#FFFBEA",
66
- // 100: "#FFF3C4",
67
- // 200: "#FCE588",
68
- // 300: "#FADB5F",
69
- // 400: "#F7C948",
70
- // 500: "#FCD436",
71
- // 600: "#F0B429",
72
- // 700: "#DE911D",
73
- // 800: "#CB6E17",
74
- // 900: "#B44D12",
75
- // DEFAULT: "#FCD436",
76
- // },
77
- // danger: "#FF5A5A",
78
- // warning: "#FFAD32",
79
- // success: "#079455",
80
- // // Remove no required colors
81
- // // t1: "#12122A",
82
- // // t2: "#616184",
83
- // // t3: "#8989AB",
84
- // // t4: "#C1C0D8",
85
- // // t5: "#EEC41F",
86
- // },
87
- // },
88
- // // doge_light: {
89
- // // colors: {
90
- // // foreground: "#12122A",
91
- // // background: "#FFF",
92
- // // content1: "#FCFCFD",
93
- // // primary: {
94
- // // 50: "#FFFBEA",
95
- // // 100: "#FFF3C4",
96
- // // 200: "#FCE588",
97
- // // 300: "#FADB5F",
98
- // // 400: "#F7C948",
99
- // // 500: "#FCD436",
100
- // // 600: "#F0B429",
101
- // // 700: "#DE911D",
102
- // // 800: "#CB6E17",
103
- // // 900: "#B44D12",
104
- // // foreground: "#12122A",
105
- // // DEFAULT: "#FCD436",
106
- // // },
107
- // // danger: "#FF5A5A",
108
- // // warning: "#FFAD32",
109
- // // success: "#079455",
110
- // // t1: "#12122A",
111
- // // t2: "#616184",
112
- // // t3: "#8989AB",
113
- // // t4: "#C1C0D8",
114
- // // t5: "#EEC41F",
115
- // // } as any,
116
- // // },
117
-
118
- // // mydoge: {
119
- // // colors: {
120
- // // primary: {
121
- // // "50": "#fffef7",
122
- // // "100": "#fffceb",
123
- // // "200": "#fff9d5",
124
- // // "300": "#fff5b8",
125
- // // "400": "#feef8a",
126
- // // "500": "#FED70B",
127
- // // "600": "#e5c009",
128
- // // "700": "#bfa007",
129
- // // "800": "#998006",
130
- // // "900": "#736005",
131
- // // foreground: "#000",
132
- // // DEFAULT: "#FED70B",
133
- // // },
134
- // // secondary: {
135
- // // "50": "#f5f3ff",
136
- // // "100": "#ede9fe",
137
- // // "200": "#ddd6fe",
138
- // // "300": "#c4b5fd",
139
- // // "400": "#a78bfa",
140
- // // "500": "#8b5cf6",
141
- // // "600": "#7c3aed",
142
- // // "700": "#6d28d9",
143
- // // "800": "#5b21b6",
144
- // // "900": "#4c1d95",
145
- // // foreground: "#fff",
146
- // // DEFAULT: "#8b5cf6",
147
- // // },
148
- // // default: {
149
- // // "50": "#0e0e0e",
150
- // // "100": "#1c1c1c",
151
- // // "200": "#2a2a2a",
152
- // // "300": "#383838",
153
- // // "400": "#464646",
154
- // // "500": "#6b6b6b",
155
- // // "600": "#909090",
156
- // // "700": "#b5b5b5",
157
- // // "800": "#dadada",
158
- // // "900": "#ffffff",
159
- // // foreground: "#ffffff",
160
- // // DEFAULT: "#464646",
161
- // // },
162
- // // success: {
163
- // // "50": "#f0fdf4",
164
- // // "100": "#dcfce7",
165
- // // "200": "#bbf7d0",
166
- // // "300": "#86efac",
167
- // // "400": "#4ade80",
168
- // // "500": "#10b981",
169
- // // "600": "#059669",
170
- // // "700": "#047857",
171
- // // "800": "#065f46",
172
- // // "900": "#064e3b",
173
- // // foreground: "#fff",
174
- // // DEFAULT: "#10b981",
175
- // // },
176
- // // warning: {
177
- // // "50": "#fffbeb",
178
- // // "100": "#fef3c7",
179
- // // "200": "#fde68a",
180
- // // "300": "#fcd34d",
181
- // // "400": "#fbbf24",
182
- // // "500": "#f59e0b",
183
- // // "600": "#d97706",
184
- // // "700": "#b45309",
185
- // // "800": "#92400e",
186
- // // "900": "#78350f",
187
- // // foreground: "#000",
188
- // // DEFAULT: "#f59e0b",
189
- // // },
190
- // // danger: {
191
- // // "50": "#fef2f2",
192
- // // "100": "#fee2e2",
193
- // // "200": "#fecaca",
194
- // // "300": "#fca5a5",
195
- // // "400": "#f87171",
196
- // // "500": "#ef4444",
197
- // // "600": "#dc2626",
198
- // // "700": "#b91c1c",
199
- // // "800": "#991b1b",
200
- // // "900": "#7f1d1d",
201
- // // foreground: "#fff",
202
- // // DEFAULT: "#ef4444",
203
- // // },
204
- // // background: "#000000",
205
- // // foreground: "#ffffff",
206
- // // content1: {
207
- // // DEFAULT: "#1A1A1A",
208
- // // foreground: "#fff",
209
- // // },
210
- // // content2: {
211
- // // DEFAULT: "#242424",
212
- // // foreground: "#fff",
213
- // // },
214
- // // content3: {
215
- // // DEFAULT: "#464646",
216
- // // foreground: "#fff",
217
- // // },
218
- // // content4: {
219
- // // DEFAULT: "#666666",
220
- // // foreground: "#fff",
221
- // // },
222
- // // focus: "#FED70B",
223
- // // overlay: "#000000",
224
- // // divider: "#464646",
225
- // // },
226
- // // },
227
- // },
228
- // });
39
+ export default heroui(baseConfig) as any;
@@ -1,4 +1,4 @@
1
- import { createContext, useCallback, useContext, useState, type ReactNode } from "react";
1
+ import { createContext, useCallback, useContext, useEffect, useState, type ReactNode } from "react";
2
2
 
3
3
  type Theme = string;
4
4
 
@@ -19,6 +19,11 @@ interface ThemeContextProviderProps {
19
19
  export function ThemeContextProvider({ children, defaultTheme = "light", forcedTheme }: ThemeContextProviderProps) {
20
20
  const [theme, setThemeState] = useState<Theme>(forcedTheme || defaultTheme);
21
21
 
22
+ useEffect(() => {
23
+ const next = forcedTheme ?? defaultTheme ?? "light";
24
+ setThemeState(next);
25
+ }, [defaultTheme, forcedTheme]);
26
+
22
27
  const setTheme = useCallback(
23
28
  (newTheme: Theme) => {
24
29
  if (!forcedTheme) {
@@ -3,7 +3,7 @@ import { useId, useMemo, type ReactElement, type ReactNode } from "react";
3
3
  import { baseConfig } from "./tailwind/plugin";
4
4
  import { themeConfigToCSS } from "./tailwind/theme-to-css";
5
5
  import { ThemeContextProvider, useTheme } from "./theme-context";
6
- import { ThemeConfig } from "./types";
6
+ import type { ThemeConfig } from "./types";
7
7
 
8
8
  type Props = {
9
9
  children: ReactNode;
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ConfigThemes, DefaultThemeType, LayoutTheme } from "@heroui/theme";
2
2
 
3
3
  export type ThemeConfig = {
4
+ prefix?: string;
4
5
  layout?: LayoutTheme;
5
6
  themes?: ConfigThemes;
6
7
  defaultTheme?: DefaultThemeType;
@@ -0,0 +1,58 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export function effectiveBalance(
4
+ balance: any,
5
+ length: number = 4,
6
+ decimalSubLen: number = 2,
7
+ decimalFlag: boolean = false,
8
+ ) {
9
+ if (isNaN(parseFloat(balance))) {
10
+ return "0.00";
11
+ }
12
+ if (!balance || balance === "0") {
13
+ return 0;
14
+ }
15
+ if (balance < 1 / Math.pow(10, 6)) {
16
+ if (decimalFlag) {
17
+ return BigNumber(balance.toString()).toFixed();
18
+ }
19
+ return "0.00";
20
+ }
21
+ balance = new BigNumber(balance.toString()).toFixed();
22
+ if (balance.split(".").length === 1) {
23
+ return balance > 1000 ? `${Number(balance).toLocaleString()}.00` : `${balance}.00`;
24
+ }
25
+ const integer = balance.split(".")[0];
26
+ const decimal = balance.split(".")[1];
27
+ if (integer > 0) {
28
+ const str = decimal.length === 1 ? `${decimal}0` : decimal.substr(0, decimalSubLen);
29
+ const res = `${integer}.${str}`;
30
+ return Number(res) > 1000 ? `${Number(integer).toLocaleString()}.${str}` : res;
31
+ }
32
+
33
+ const temp: any = [];
34
+ let tempNum = 0;
35
+ let isNotZero = false;
36
+ for (let i = 0; i < decimal.length; i++) {
37
+ if (decimal[i] != "0" && !isNotZero) {
38
+ isNotZero = true;
39
+ }
40
+ if (isNotZero) {
41
+ tempNum++;
42
+ }
43
+ if (tempNum <= length) {
44
+ temp.push(decimal[i]);
45
+ }
46
+ }
47
+ const res = parseFloat(`${integer}.${temp.join("")}`);
48
+ return res > 1000 ? `${Number(integer).toLocaleString()}.${temp.join("")}` : res;
49
+ }
50
+
51
+ export const isEmpty = (data: string | object) => {
52
+ if (data instanceof Array) {
53
+ return !data.length;
54
+ } else if (data instanceof Object) {
55
+ return !Object.keys(data).length;
56
+ }
57
+ return !data;
58
+ };
package/tsup.config.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: "src/index.ts",
6
+ "tailwind/plugin": "src/tailwind/plugin.ts",
7
+ },
8
+ format: ["esm", "cjs"],
9
+ dts: false,
10
+ sourcemap: false,
11
+ clean: true,
12
+ target: "es2019",
13
+ splitting: false,
14
+ external: ["react", "react-dom", "@heroui/react", "@heroui/system", "@heroui/theme", "tailwindcss"],
15
+ });
16
+