@choice-ui/react 2.0.0 → 2.0.2

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.
Files changed (53) hide show
  1. package/dist/components/button/dist/index.d.ts +2 -9
  2. package/dist/components/button/dist/index.js +45 -19
  3. package/dist/components/checkbox/dist/index.d.ts +10 -1
  4. package/dist/components/checkbox/dist/index.js +49 -5
  5. package/dist/components/code-block/dist/index.d.ts +11 -14
  6. package/dist/components/code-block/dist/index.js +120 -93
  7. package/dist/components/colors/dist/index.d.ts +39 -6
  8. package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
  9. package/dist/components/dropdown/dist/index.d.ts +6 -0
  10. package/dist/components/dropdown/dist/index.js +20 -10
  11. package/dist/components/emoji-picker/dist/index.d.ts +30 -1
  12. package/dist/components/emoji-picker/dist/index.js +148 -44
  13. package/dist/components/form/src/adapters/range-adapter.js +2 -2
  14. package/dist/components/icon-button/dist/index.d.ts +1 -1
  15. package/dist/components/icon-button/dist/index.js +39 -0
  16. package/dist/components/list/dist/index.d.ts +1 -1
  17. package/dist/components/md-render/dist/index.d.ts +2 -1
  18. package/dist/components/md-render/dist/index.js +5 -9
  19. package/dist/components/md-render/src/components/markdown-block.d.ts +3 -0
  20. package/dist/components/md-render/src/md-render.js +4 -0
  21. package/dist/components/md-render/src/types.d.ts +3 -0
  22. package/dist/components/menus/dist/index.d.ts +5 -0
  23. package/dist/components/menus/dist/index.js +32 -3
  24. package/dist/components/modal/dist/index.js +2 -2
  25. package/dist/components/notifications/dist/index.d.ts +1 -5
  26. package/dist/components/numeric-input/dist/index.d.ts +27 -10
  27. package/dist/components/numeric-input/dist/index.js +132 -34
  28. package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -1
  29. package/dist/components/numeric-input/src/hooks/use-input-interactions.js +7 -3
  30. package/dist/components/numeric-input/src/hooks/use-numeric-input.js +15 -4
  31. package/dist/components/numeric-input/src/numeric-input.js +5 -4
  32. package/dist/components/numeric-input/src/utils/value-comparator.js +1 -5
  33. package/dist/components/panel/dist/index.d.ts +16 -16
  34. package/dist/components/picture-preview/dist/index.d.ts +5 -0
  35. package/dist/components/picture-preview/dist/index.js +287 -140
  36. package/dist/components/popover/dist/index.d.ts +5 -0
  37. package/dist/components/popover/dist/index.js +21 -2
  38. package/dist/components/radio/dist/index.d.ts +9 -1
  39. package/dist/components/radio/dist/index.js +50 -6
  40. package/dist/components/range/dist/index.d.ts +276 -20
  41. package/dist/components/range/dist/index.js +1030 -602
  42. package/dist/components/scroll-area/dist/index.d.ts +4 -27
  43. package/dist/components/scroll-area/dist/index.js +96 -123
  44. package/dist/components/separator/dist/index.d.ts +1 -8
  45. package/dist/components/splitter/dist/index.d.ts +1 -1
  46. package/dist/components/text-field/dist/index.d.ts +2 -3
  47. package/dist/components/text-field/dist/index.js +4 -19
  48. package/dist/components/textarea/dist/index.js +3 -1
  49. package/dist/components/toast/dist/index.d.ts +274 -0
  50. package/dist/components/tooltip/dist/index.d.ts +2 -0
  51. package/dist/components/tooltip/dist/index.js +23 -5
  52. package/dist/components/virtual-select/dist/index.d.ts +48 -0
  53. package/package.json +3 -3
@@ -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 };
@@ -10,6 +10,7 @@ interface TooltipProps {
10
10
  className?: string;
11
11
  content?: React.ReactNode;
12
12
  disabled?: boolean;
13
+ interactive?: boolean;
13
14
  offset?: number;
14
15
  onOpenChange?: (open: boolean) => void;
15
16
  open?: boolean;
@@ -23,6 +24,7 @@ interface TooltipProps {
23
24
  withArrow?: boolean;
24
25
  }
25
26
  interface TooltipContentProps extends React.HTMLProps<HTMLDivElement> {
27
+ interactive?: boolean;
26
28
  portalId?: string;
27
29
  variant?: "default" | "light";
28
30
  withArrow?: boolean;
@@ -128,7 +128,15 @@ var TooltipArrow = forwardRef(function TooltipArrow2({ className, variant = "def
128
128
  });
129
129
  var TooltipContent = forwardRef(
130
130
  function TooltipContent2(props, propRef) {
131
- const { className, withArrow = true, variant = "default", children, portalId, ...rest } = props;
131
+ const {
132
+ className,
133
+ withArrow = true,
134
+ variant = "default",
135
+ children,
136
+ portalId,
137
+ interactive = true,
138
+ ...rest
139
+ } = props;
132
140
  const state = useTooltipState();
133
141
  const ref = useMergeRefs([state.refs.setFloating, propRef]);
134
142
  const { isInstantPhase, currentId } = useDelayGroup(state.context, {
@@ -157,19 +165,27 @@ var TooltipContent = forwardRef(
157
165
  });
158
166
  const tv = useMemo(() => tooltipContentVariants({ variant }), [variant]);
159
167
  if (state.disabled || !isMounted) return null;
168
+ const floatingProps = state.getFloatingProps(rest);
160
169
  return /* @__PURE__ */ jsx(FloatingPortal, { id: portalId, children: /* @__PURE__ */ jsx(
161
170
  "div",
162
171
  {
163
172
  ref,
164
- style: state.floatingStyles,
165
- ...state.getFloatingProps(rest),
173
+ style: {
174
+ ...state.floatingStyles,
175
+ pointerEvents: interactive ? void 0 : "none"
176
+ },
177
+ ...floatingProps,
166
178
  className: "z-tooltip",
167
179
  children: /* @__PURE__ */ jsxs(
168
180
  "div",
169
181
  {
170
182
  className: tcx(tv.root({ className })),
171
183
  "data-state": state.open ? "open" : "closed",
172
- style: styles,
184
+ style: {
185
+ ...styles,
186
+ pointerEvents: interactive ? void 0 : "none",
187
+ cursor: interactive ? void 0 : "default"
188
+ },
173
189
  children: [
174
190
  children,
175
191
  withArrow && /* @__PURE__ */ jsx(TooltipArrow, { variant })
@@ -272,7 +288,8 @@ function TooltipRoot(props) {
272
288
  withArrow = true,
273
289
  variant = "default",
274
290
  offset: offset2 = 8,
275
- portalId = PORTAL_ROOT_ID
291
+ portalId = PORTAL_ROOT_ID,
292
+ interactive = true
276
293
  } = props;
277
294
  const tooltip = useTooltip({
278
295
  placement,
@@ -291,6 +308,7 @@ function TooltipRoot(props) {
291
308
  variant,
292
309
  portalId,
293
310
  className,
311
+ interactive,
294
312
  children: [
295
313
  content,
296
314
  shortcut && /* @__PURE__ */ jsx(
@@ -0,0 +1,48 @@
1
+ import { MenuContextContent, MenuDivider, MenuEmpty, MenuContextItem, MenuSearch, MenuTrigger, MenuValue } from '../../menus/src';
2
+ import { FloatingFocusManagerProps } from '@floating-ui/react';
3
+ import { default as React } from 'react';
4
+ interface VirtualSelectOption<T = unknown> {
5
+ value: string;
6
+ label: string;
7
+ disabled?: boolean;
8
+ data?: T;
9
+ }
10
+ interface VirtualSelectProps<T = unknown> {
11
+ className?: string;
12
+ closeOnEscape?: boolean;
13
+ disabled?: boolean;
14
+ emptyText?: string;
15
+ focusManagerProps?: Partial<FloatingFocusManagerProps>;
16
+ matchTriggerWidth?: boolean;
17
+ maxHeight?: number;
18
+ onChange?: (value: string) => void;
19
+ onOpenChange?: (open: boolean) => void;
20
+ open?: boolean;
21
+ options: VirtualSelectOption<T>[];
22
+ overscan?: number;
23
+ placeholder?: string;
24
+ placement?: "bottom-start" | "bottom-end";
25
+ portalId?: string;
26
+ readOnly?: boolean;
27
+ renderOption?: (option: VirtualSelectOption<T>, isSelected: boolean) => React.ReactNode;
28
+ renderValue?: (option: VirtualSelectOption<T> | null) => React.ReactNode;
29
+ root?: HTMLElement | null;
30
+ searchPlaceholder?: string;
31
+ size?: "default" | "large";
32
+ value?: string | null;
33
+ variant?: "default" | "light" | "reset";
34
+ }
35
+ interface VirtualSelectComponentType {
36
+ <T = unknown>(props: VirtualSelectProps<T>): React.ReactElement | null;
37
+ displayName?: string;
38
+ Content: typeof MenuContextContent;
39
+ Divider: typeof MenuDivider;
40
+ Empty: typeof MenuEmpty;
41
+ Item: typeof MenuContextItem;
42
+ Search: typeof MenuSearch;
43
+ Trigger: typeof MenuTrigger;
44
+ Value: typeof MenuValue;
45
+ }
46
+ declare const VirtualSelect: VirtualSelectComponentType;
47
+
48
+ export { VirtualSelect, type VirtualSelectOption, type VirtualSelectProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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",
@@ -54,11 +54,11 @@
54
54
  "use-stick-to-bottom": "^1.0.43",
55
55
  "usehooks-ts": "^3.1.0",
56
56
  "zod": "^4.0.5",
57
- "react-markdown": "^9.0.3",
57
+ "react-markdown": "^10.1.0",
58
58
  "remark-gfm": "^4.0.1",
59
59
  "remark-breaks": "^4.0.0",
60
60
  "remark-math": "^6.0.0",
61
- "harden-react-markdown": "^1.0.4",
61
+ "harden-react-markdown": "^1.1.8",
62
62
  "shiki": "^3.9.2",
63
63
  "@choice-ui/design-tokens": "0.2.16"
64
64
  },