@choice-ui/react 1.9.9 → 2.0.1

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.
@@ -1 +1 @@
1
- export { AllotmentProps, Allotment as Splitter, AllotmentHandle as SplitterHandle } from 'allotment';
1
+ export { Allotment as Splitter, AllotmentHandle as SplitterHandle, AllotmentProps as SplitterProps } from 'allotment';
@@ -1,3 +1,4 @@
1
+ import { Description } from '../../description/src';
1
2
  import { InputProps } from '../../input/src';
2
3
  import { Label } from '../../label/src';
3
4
  import { default as react__default, HTMLProps, ReactNode } from 'react';
@@ -10,13 +11,11 @@ interface FieldAddonProps extends HTMLProps<HTMLDivElement> {
10
11
  }
11
12
  declare const FieldAddon: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<FieldAddonProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
12
13
 
13
- declare const FieldDescription: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>>;
14
-
15
14
  interface TextFieldProps extends Omit<InputProps, "children"> {
16
15
  children?: ReactNode;
17
16
  }
18
17
  interface TextFieldComponent extends react__default.ForwardRefExoticComponent<TextFieldProps & react__default.RefAttributes<HTMLInputElement>> {
19
- Description: typeof FieldDescription;
18
+ Description: typeof Description;
20
19
  Label: typeof Label;
21
20
  Prefix: typeof FieldAddon;
22
21
  Suffix: typeof FieldAddon;
@@ -1,6 +1,7 @@
1
+ import { Description } from "../../description/dist/index.js";
1
2
  import { Input } from "../../input/dist/index.js";
2
3
  import { Label } from "../../label/dist/index.js";
3
- import { forwardRef, memo, Children, isValidElement, useId, cloneElement } from "react";
4
+ import { forwardRef, Children, isValidElement, useId, cloneElement, memo } from "react";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { tcv, tcx } from "../../../shared/utils/tcx/tcx.js";
6
7
  var FieldAddon = memo(
@@ -17,17 +18,6 @@ var FieldAddon = memo(
17
18
  })
18
19
  );
19
20
  FieldAddon.displayName = "FieldAddon";
20
- var FieldDescription = memo(
21
- forwardRef(function FieldDescription2(props, ref) {
22
- return /* @__PURE__ */ jsx(
23
- "div",
24
- {
25
- ref,
26
- ...props
27
- }
28
- );
29
- })
30
- );
31
21
  var TextFieldTv = tcv({
32
22
  slots: {
33
23
  container: ["flex min-w-0 flex-col items-start gap-2"],
@@ -41,12 +31,7 @@ var TextFieldTv = tcv({
41
31
  input: "[grid-area:input]",
42
32
  prefix: "[grid-area:prefix]",
43
33
  suffix: "[grid-area:suffix]",
44
- description: [
45
- "text-body-medium mt-1",
46
- "px-0.5",
47
- "break-words whitespace-pre-wrap",
48
- "text-secondary-foreground"
49
- ]
34
+ description: ""
50
35
  },
51
36
  variants: {
52
37
  variant: {
@@ -257,7 +242,7 @@ var TextField = Object.assign(TextFieldBase, {
257
242
  Prefix: PrefixComponent,
258
243
  Suffix: SuffixComponent,
259
244
  Label,
260
- Description: FieldDescription
245
+ Description
261
246
  });
262
247
  export {
263
248
  TextField
@@ -0,0 +1,274 @@
1
+ import { ReactNode } from 'react';
2
+ import * as react from 'react';
3
+
4
+ type ToastType = "info" | "success" | "warning" | "error" | "loading" | "default";
5
+ type ToastVariant = "default" | "accent" | "success" | "warning" | "error" | "assistive" | "reset";
6
+ type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
7
+
8
+ interface ToastAction {
9
+ label: ReactNode;
10
+ onClick: () => void;
11
+ }
12
+ interface ToastCancel {
13
+ label: ReactNode;
14
+ onClick?: () => void;
15
+ }
16
+ /**
17
+ * Props for Toaster.Item slot component
18
+ */
19
+ interface ToasterItemSlotProps {
20
+ className?: string;
21
+ style?: React.CSSProperties;
22
+ children?: ReactNode;
23
+ }
24
+ /**
25
+ * Slot component for customizing toast item container
26
+ */
27
+ declare const ToasterItemSlot: react.ForwardRefExoticComponent<ToasterItemSlotProps & react.RefAttributes<HTMLDivElement>>;
28
+ /**
29
+ * Props for Toaster.Icon slot component
30
+ */
31
+ interface ToasterIconSlotProps {
32
+ className?: string;
33
+ style?: React.CSSProperties;
34
+ /** Custom render function - receives type and default icon */
35
+ children?: (type: ToastType, defaultIcon: ReactNode) => ReactNode;
36
+ }
37
+ /**
38
+ * Slot component for customizing toast icon
39
+ */
40
+ declare const ToasterIconSlot: react.ForwardRefExoticComponent<ToasterIconSlotProps & react.RefAttributes<HTMLDivElement>>;
41
+ /**
42
+ * Props for Toaster.Title slot component
43
+ */
44
+ interface ToasterTitleSlotProps {
45
+ className?: string;
46
+ style?: React.CSSProperties;
47
+ }
48
+ /**
49
+ * Slot component for customizing toast title
50
+ */
51
+ declare const ToasterTitleSlot: react.ForwardRefExoticComponent<ToasterTitleSlotProps & react.RefAttributes<HTMLDivElement>>;
52
+ /**
53
+ * Props for Toaster.Description slot component
54
+ */
55
+ interface ToasterDescriptionSlotProps {
56
+ className?: string;
57
+ style?: React.CSSProperties;
58
+ }
59
+ /**
60
+ * Slot component for customizing toast description
61
+ */
62
+ declare const ToasterDescriptionSlot: react.ForwardRefExoticComponent<ToasterDescriptionSlotProps & react.RefAttributes<HTMLDivElement>>;
63
+ /**
64
+ * Props for Toaster.Actions slot component
65
+ */
66
+ interface ToasterActionsSlotProps {
67
+ className?: string;
68
+ style?: React.CSSProperties;
69
+ /** Custom render function for actions */
70
+ children?: (action: ToastAction | undefined, cancel: ToastCancel | undefined, close: () => void) => ReactNode;
71
+ }
72
+ /**
73
+ * Slot component for customizing toast actions
74
+ */
75
+ declare const ToasterActionsSlot: react.ForwardRefExoticComponent<ToasterActionsSlotProps & react.RefAttributes<HTMLDivElement>>;
76
+
77
+ interface ToastData {
78
+ id: string;
79
+ type: ToastType;
80
+ variant?: ToastVariant;
81
+ /**
82
+ * Title content. Supports:
83
+ * - Plain string: rendered as text
84
+ * - HTML string (containing tags like `<b>`, `<strong>`, etc.): rendered as HTML
85
+ * - ReactNode: rendered as React component
86
+ */
87
+ title?: React.ReactNode;
88
+ /**
89
+ * Description content. Supports:
90
+ * - Plain string: rendered as text
91
+ * - HTML string (containing tags like `<b>`, `<strong>`, etc.): rendered as HTML
92
+ * - ReactNode: rendered as React component
93
+ */
94
+ description?: React.ReactNode;
95
+ duration?: number;
96
+ icon?: React.ReactNode;
97
+ action?: {
98
+ label: React.ReactNode;
99
+ onClick: () => void;
100
+ };
101
+ cancel?: {
102
+ label: React.ReactNode;
103
+ onClick?: () => void;
104
+ };
105
+ onClose?: () => void;
106
+ onAutoClose?: () => void;
107
+ dismissible?: boolean;
108
+ /**
109
+ * Show progress bar for this toast. Overrides Toaster's showProgress setting.
110
+ * - `true`: Always show progress bar
111
+ * - `false`: Never show progress bar
112
+ * - `undefined`: Use Toaster's showProgress setting
113
+ */
114
+ progress?: boolean;
115
+ createdAt: number;
116
+ height?: number;
117
+ removing?: boolean;
118
+ swipeDirection?: "left" | "right" | "up" | "down";
119
+ }
120
+ interface ToastOptions {
121
+ id?: string;
122
+ variant?: ToastVariant;
123
+ /**
124
+ * Description content. Supports:
125
+ * - Plain string: rendered as text
126
+ * - HTML string (containing tags like `<b>`, `<strong>`, etc.): rendered as HTML
127
+ * - ReactNode: rendered as React component
128
+ */
129
+ description?: React.ReactNode;
130
+ duration?: number;
131
+ icon?: React.ReactNode;
132
+ action?: {
133
+ label: React.ReactNode;
134
+ onClick: () => void;
135
+ };
136
+ cancel?: {
137
+ label: React.ReactNode;
138
+ onClick?: () => void;
139
+ };
140
+ onClose?: () => void;
141
+ onAutoClose?: () => void;
142
+ dismissible?: boolean;
143
+ /**
144
+ * Show progress bar for this toast. Overrides Toaster's showProgress setting.
145
+ * - `true`: Always show progress bar
146
+ * - `false`: Never show progress bar
147
+ * - `undefined`: Use Toaster's showProgress setting
148
+ */
149
+ progress?: boolean;
150
+ }
151
+ interface PromiseOptions<T> {
152
+ loading: string | (ToastOptions & {
153
+ title: string;
154
+ });
155
+ success: string | (ToastOptions & {
156
+ title: string;
157
+ }) | ((data: T) => string | (ToastOptions & {
158
+ title: string;
159
+ }));
160
+ error: string | (ToastOptions & {
161
+ title: string;
162
+ }) | ((err: unknown) => string | (ToastOptions & {
163
+ title: string;
164
+ }));
165
+ }
166
+ type ToastFunction = {
167
+ (title: string, options?: ToastOptions): string;
168
+ success: (title: string, options?: ToastOptions) => string;
169
+ error: (title: string, options?: ToastOptions) => string;
170
+ warning: (title: string, options?: ToastOptions) => string;
171
+ info: (title: string, options?: ToastOptions) => string;
172
+ loading: (title: string, options?: ToastOptions) => string;
173
+ promise: <T>(promise: Promise<T>, options: PromiseOptions<T>) => Promise<T>;
174
+ dismiss: (id: string) => void;
175
+ dismissAll: () => void;
176
+ use: (toasterId: string) => {
177
+ (title: string, options?: ToastOptions): string;
178
+ success: (title: string, options?: ToastOptions) => string;
179
+ error: (title: string, options?: ToastOptions) => string;
180
+ warning: (title: string, options?: ToastOptions) => string;
181
+ info: (title: string, options?: ToastOptions) => string;
182
+ loading: (title: string, options?: ToastOptions) => string;
183
+ promise: <T>(promise: Promise<T>, options: PromiseOptions<T>) => Promise<T>;
184
+ dismiss: (id: string) => void;
185
+ dismissAll: () => void;
186
+ };
187
+ };
188
+ declare const toast: ToastFunction;
189
+
190
+ interface ToasterProps {
191
+ /**
192
+ * Unique ID for this Toaster instance
193
+ * Use this to have multiple Toaster instances in the same app
194
+ * @default "default"
195
+ */
196
+ id?: string;
197
+ /**
198
+ * Position of the toaster
199
+ * @default "bottom-right"
200
+ */
201
+ position?: ToastPosition;
202
+ /**
203
+ * Render toasts into a custom container
204
+ */
205
+ container?: HTMLElement | null;
206
+ /**
207
+ * Label for accessibility
208
+ * @default "Notifications"
209
+ */
210
+ label?: string;
211
+ /**
212
+ * Whether to use a portal for rendering
213
+ * @default true
214
+ */
215
+ portal?: boolean;
216
+ /**
217
+ * Offset from viewport edges in pixels
218
+ * @default 16
219
+ */
220
+ offset?: number;
221
+ /**
222
+ * Default duration for toasts in ms
223
+ * @default 5000
224
+ */
225
+ duration?: number;
226
+ /**
227
+ * Maximum number of visible toasts
228
+ * @default 3
229
+ */
230
+ visibleToasts?: number;
231
+ /**
232
+ * Additional class name
233
+ */
234
+ className?: string;
235
+ /**
236
+ * Children - use Toaster.Item to customize toast rendering
237
+ */
238
+ children?: ReactNode;
239
+ /**
240
+ * Show countdown progress bar at the bottom of each toast
241
+ * @default false
242
+ */
243
+ showProgress?: boolean;
244
+ /**
245
+ * Layout mode for toasts
246
+ * @default "default"
247
+ */
248
+ layout?: "default" | "compact";
249
+ }
250
+ interface ToasterComponent extends React.MemoExoticComponent<React.ForwardRefExoticComponent<ToasterProps & React.RefAttributes<HTMLDivElement>>> {
251
+ Item: typeof ToasterItemSlot;
252
+ Icon: typeof ToasterIconSlot;
253
+ Title: typeof ToasterTitleSlot;
254
+ Description: typeof ToasterDescriptionSlot;
255
+ Actions: typeof ToasterActionsSlot;
256
+ }
257
+ /**
258
+ * Toaster component with compound pattern
259
+ *
260
+ * @example
261
+ * ```tsx
262
+ * <Toaster id="my-toaster">
263
+ * <Toaster.Item className="custom-class">
264
+ * <Toaster.Icon>{(type, defaultIcon) => <CustomIcon type={type} />}</Toaster.Icon>
265
+ * <Toaster.Title className="font-bold uppercase" />
266
+ * <Toaster.Description className="text-sm" />
267
+ * <Toaster.Actions>{(action, cancel, close) => <CustomActions />}</Toaster.Actions>
268
+ * </Toaster.Item>
269
+ * </Toaster>
270
+ * ```
271
+ */
272
+ declare const Toaster: ToasterComponent;
273
+
274
+ export { type ToastData, type ToastOptions, type ToastPosition, type ToastType, type ToastVariant, Toaster, type ToasterProps, toast };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.9.9",
3
+ "version": "2.0.1",
4
4
  "description": "A desktop-first React UI component library built for professional desktop applications with comprehensive documentation",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "source": "./app/index.ts",
8
8
  "main": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
9
+ "types": "./app/index.ts",
10
10
  "files": [
11
11
  "dist",
12
12
  "README.md",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "exports": {
16
16
  ".": {
17
- "types": "./dist/index.d.ts",
17
+ "types": "./app/index.ts",
18
18
  "import": "./dist/index.js"
19
19
  },
20
20
  "./styles/*": "./dist/styles/*",
@@ -22,10 +22,36 @@
22
22
  "./llms.txt": "./dist/llms.txt"
23
23
  },
24
24
  "publishConfig": {
25
- "access": "public"
25
+ "access": "public",
26
+ "types": "./dist/index.d.ts",
27
+ "main": "./dist/index.js",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./styles/*": "./dist/styles/*",
34
+ "./tailwind.css": "./dist/tailwind.css",
35
+ "./llms.txt": "./dist/llms.txt"
36
+ }
37
+ },
38
+ "scripts": {
39
+ "build": "pnpm run clean && pnpm --filter @choice-ui/shared build && vite build",
40
+ "build:watch": "vite build --watch",
41
+ "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
42
+ "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
43
+ "lint:types": "tsc",
44
+ "clean": "rimraf dist",
45
+ "prepublishOnly": "pnpm run build",
46
+ "plop": "pnpm dlx plop",
47
+ "test": "jest",
48
+ "test:watch": "jest --watch",
49
+ "test:coverage": "jest --coverage",
50
+ "madge": "npx madge --circular --extensions ts app/"
26
51
  },
27
52
  "dependencies": {
28
53
  "@choiceform/icons-react": "^1.3.8",
54
+ "@choice-ui/design-tokens": "workspace:*",
29
55
  "classnames": "^2.5.1",
30
56
  "tailwind-merge": "^3.3.1",
31
57
  "tailwind-variants": "^3.1.0",
@@ -54,13 +80,12 @@
54
80
  "use-stick-to-bottom": "^1.0.43",
55
81
  "usehooks-ts": "^3.1.0",
56
82
  "zod": "^4.0.5",
57
- "react-markdown": "^9.0.3",
83
+ "react-markdown": "^10.1.0",
58
84
  "remark-gfm": "^4.0.1",
59
85
  "remark-breaks": "^4.0.0",
60
86
  "remark-math": "^6.0.0",
61
- "harden-react-markdown": "^1.0.4",
62
- "shiki": "^3.9.2",
63
- "@choice-ui/design-tokens": "0.2.16"
87
+ "harden-react-markdown": "^1.1.8",
88
+ "shiki": "^3.9.2"
64
89
  },
65
90
  "devDependencies": {
66
91
  "@babel/core": "^7.27.1",
@@ -111,18 +136,5 @@
111
136
  "peerDependencies": {
112
137
  "react": ">=18.0.0",
113
138
  "react-dom": ">=18.0.0"
114
- },
115
- "scripts": {
116
- "build": "pnpm run clean && pnpm --filter @choice-ui/shared build && vite build",
117
- "build:watch": "vite build --watch",
118
- "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
119
- "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
120
- "lint:types": "tsc",
121
- "clean": "rimraf dist",
122
- "plop": "pnpm dlx plop",
123
- "test": "jest",
124
- "test:watch": "jest --watch",
125
- "test:coverage": "jest --coverage",
126
- "madge": "npx madge --circular --extensions ts app/"
127
139
  }
128
140
  }