@choice-ui/react 1.6.8 → 1.6.9

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 (81) hide show
  1. package/dist/components/description/dist/index.d.ts +8 -0
  2. package/dist/components/description/dist/index.js +29 -0
  3. package/dist/components/description/src/description.d.ts +6 -0
  4. package/dist/components/description/src/description.js +18 -0
  5. package/dist/components/description/src/index.d.ts +2 -0
  6. package/dist/components/description/src/tv.d.ts +13 -0
  7. package/dist/components/description/src/tv.js +15 -0
  8. package/dist/components/description/tsup.config.d.ts +2 -0
  9. package/dist/components/emoji-picker/dist/index.d.ts +1 -0
  10. package/dist/components/emoji-picker/dist/index.js +4 -2
  11. package/dist/components/emoji-picker/src/emoji-picker.d.ts +1 -0
  12. package/dist/components/emoji-picker/src/emoji-picker.js +4 -2
  13. package/dist/components/error-message/dist/index.d.ts +8 -0
  14. package/dist/components/error-message/dist/index.js +30 -0
  15. package/dist/components/error-message/src/error-message.d.ts +6 -0
  16. package/dist/components/error-message/src/error-message.js +19 -0
  17. package/dist/components/error-message/src/index.d.ts +2 -0
  18. package/dist/components/error-message/src/tv.d.ts +13 -0
  19. package/dist/components/error-message/src/tv.js +15 -0
  20. package/dist/components/error-message/tsup.config.d.ts +2 -0
  21. package/dist/components/form/src/adapters/base-adapter.js +4 -2
  22. package/dist/components/form/src/tv.d.ts +0 -12
  23. package/dist/components/form/src/tv.js +1 -13
  24. package/dist/components/index.d.ts +3 -0
  25. package/dist/components/md-render/dist/index.d.ts +2 -1
  26. package/dist/components/md-render/dist/index.js +3 -1
  27. package/dist/components/md-render/src/md-render.js +3 -1
  28. package/dist/components/md-render/src/types.d.ts +2 -1
  29. package/dist/components/notifications/dist/index.d.ts +1 -5
  30. package/dist/components/notifications/src/notifications.d.ts +0 -1
  31. package/dist/components/notifications/src/notifications.js +0 -1
  32. package/dist/components/numeric-input/dist/index.d.ts +23 -9
  33. package/dist/components/numeric-input/dist/index.js +26 -3
  34. package/dist/components/numeric-input/src/components/numeric-input-menu-trigger.js +4 -1
  35. package/dist/components/numeric-input/src/hooks/index.d.ts +1 -0
  36. package/dist/components/numeric-input/src/hooks/use-numeric-long-press.d.ts +13 -0
  37. package/dist/components/numeric-input/src/hooks/use-numeric-long-press.js +27 -0
  38. package/dist/components/numeric-input/src/index.d.ts +1 -0
  39. package/dist/components/numeric-input/src/tv.js +22 -2
  40. package/dist/components/picture-preview/dist/index.d.ts +5 -0
  41. package/dist/components/picture-preview/dist/index.js +287 -140
  42. package/dist/components/picture-preview/src/hooks/useWheelHandler.d.ts +6 -1
  43. package/dist/components/picture-preview/src/hooks/useWheelHandler.js +25 -7
  44. package/dist/components/picture-preview/src/picture-preview.d.ts +5 -0
  45. package/dist/components/picture-preview/src/picture-preview.js +214 -123
  46. package/dist/components/picture-preview/src/tv.d.ts +93 -3
  47. package/dist/components/picture-preview/src/tv.js +48 -10
  48. package/dist/components/separator/dist/index.d.ts +1 -8
  49. package/dist/components/separator/src/separator.d.ts +1 -8
  50. package/dist/components/separator/src/separator.js +33 -5
  51. package/dist/components/separator/src/tv.d.ts +39 -18
  52. package/dist/components/separator/src/tv.js +37 -7
  53. package/dist/components/text-field/dist/index.d.ts +2 -3
  54. package/dist/components/text-field/dist/index.js +4 -19
  55. package/dist/components/text-field/src/components/index.d.ts +0 -1
  56. package/dist/components/text-field/src/text-field.d.ts +3 -2
  57. package/dist/components/text-field/src/text-field.js +2 -2
  58. package/dist/components/text-field/src/tv.d.ts +3 -3
  59. package/dist/components/text-field/src/tv.js +1 -6
  60. package/dist/components/toast/dist/index.d.ts +248 -0
  61. package/dist/components/toast/src/components/index.d.ts +3 -0
  62. package/dist/components/toast/src/components/toast-progress-bar.d.ts +7 -0
  63. package/dist/components/toast/src/components/toast-progress-bar.js +53 -0
  64. package/dist/components/toast/src/components/toaster-item.d.ts +26 -0
  65. package/dist/components/toast/src/components/toaster-item.js +416 -0
  66. package/dist/components/toast/src/components/toaster-slots.d.ts +87 -0
  67. package/dist/components/toast/src/components/toaster-slots.js +38 -0
  68. package/dist/components/toast/src/index.d.ts +5 -0
  69. package/dist/components/toast/src/store.d.ts +101 -0
  70. package/dist/components/toast/src/store.js +205 -0
  71. package/dist/components/toast/src/toaster.d.ts +87 -0
  72. package/dist/components/toast/src/toaster.js +271 -0
  73. package/dist/components/toast/src/tv.d.ts +365 -0
  74. package/dist/components/toast/src/tv.js +412 -0
  75. package/dist/components/toast/src/types.d.ts +79 -0
  76. package/dist/components/toast/tsup.config.d.ts +2 -0
  77. package/dist/index.js +11 -2
  78. package/dist/styles/components.css +2 -0
  79. package/package.json +1 -1
  80. package/dist/components/text-field/src/components/field-description.d.ts +0 -2
  81. package/dist/components/text-field/src/components/field-description.js +0 -16
@@ -0,0 +1,248 @@
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
+ title?: React.ReactNode;
82
+ /** HTML string for title - rendered with dangerouslySetInnerHTML */
83
+ titleHtml?: string;
84
+ description?: React.ReactNode;
85
+ /** HTML string for description - rendered with dangerouslySetInnerHTML */
86
+ descriptionHtml?: string;
87
+ duration?: number;
88
+ icon?: React.ReactNode;
89
+ action?: {
90
+ label: React.ReactNode;
91
+ onClick: () => void;
92
+ };
93
+ cancel?: {
94
+ label: React.ReactNode;
95
+ onClick?: () => void;
96
+ };
97
+ onClose?: () => void;
98
+ onAutoClose?: () => void;
99
+ dismissible?: boolean;
100
+ createdAt: number;
101
+ height?: number;
102
+ removing?: boolean;
103
+ swipeDirection?: "left" | "right" | "up" | "down";
104
+ }
105
+ interface ToastOptions {
106
+ id?: string;
107
+ variant?: ToastVariant;
108
+ description?: React.ReactNode;
109
+ /** HTML string for description - rendered with dangerouslySetInnerHTML */
110
+ descriptionHtml?: string;
111
+ duration?: number;
112
+ icon?: React.ReactNode;
113
+ action?: {
114
+ label: React.ReactNode;
115
+ onClick: () => void;
116
+ };
117
+ cancel?: {
118
+ label: React.ReactNode;
119
+ onClick?: () => void;
120
+ };
121
+ onClose?: () => void;
122
+ onAutoClose?: () => void;
123
+ dismissible?: boolean;
124
+ }
125
+ interface PromiseOptions<T> {
126
+ loading: string | (ToastOptions & {
127
+ title: string;
128
+ });
129
+ success: string | (ToastOptions & {
130
+ title: string;
131
+ }) | ((data: T) => string | (ToastOptions & {
132
+ title: string;
133
+ }));
134
+ error: string | (ToastOptions & {
135
+ title: string;
136
+ }) | ((err: unknown) => string | (ToastOptions & {
137
+ title: string;
138
+ }));
139
+ }
140
+ type ToastFunction = {
141
+ (title: string, options?: ToastOptions): string;
142
+ success: (title: string, options?: ToastOptions) => string;
143
+ error: (title: string, options?: ToastOptions) => string;
144
+ warning: (title: string, options?: ToastOptions) => string;
145
+ info: (title: string, options?: ToastOptions) => string;
146
+ loading: (title: string, options?: ToastOptions) => string;
147
+ promise: <T>(promise: Promise<T>, options: PromiseOptions<T>) => Promise<T>;
148
+ dismiss: (id: string) => void;
149
+ dismissAll: () => void;
150
+ use: (toasterId: string) => {
151
+ (title: string, options?: ToastOptions): string;
152
+ success: (title: string, options?: ToastOptions) => string;
153
+ error: (title: string, options?: ToastOptions) => string;
154
+ warning: (title: string, options?: ToastOptions) => string;
155
+ info: (title: string, options?: ToastOptions) => string;
156
+ loading: (title: string, options?: ToastOptions) => string;
157
+ promise: <T>(promise: Promise<T>, options: PromiseOptions<T>) => Promise<T>;
158
+ dismiss: (id: string) => void;
159
+ dismissAll: () => void;
160
+ };
161
+ };
162
+ declare const toast: ToastFunction;
163
+
164
+ interface ToasterProps {
165
+ /**
166
+ * Unique ID for this Toaster instance
167
+ * Use this to have multiple Toaster instances in the same app
168
+ * @default "default"
169
+ */
170
+ id?: string;
171
+ /**
172
+ * Position of the toaster
173
+ * @default "bottom-right"
174
+ */
175
+ position?: ToastPosition;
176
+ /**
177
+ * Render toasts into a custom container
178
+ */
179
+ container?: HTMLElement | null;
180
+ /**
181
+ * Label for accessibility
182
+ * @default "Notifications"
183
+ */
184
+ label?: string;
185
+ /**
186
+ * Whether to use a portal for rendering
187
+ * @default true
188
+ */
189
+ portal?: boolean;
190
+ /**
191
+ * Offset from viewport edges in pixels
192
+ * @default 16
193
+ */
194
+ offset?: number;
195
+ /**
196
+ * Default duration for toasts in ms
197
+ * @default 5000
198
+ */
199
+ duration?: number;
200
+ /**
201
+ * Maximum number of visible toasts
202
+ * @default 3
203
+ */
204
+ visibleToasts?: number;
205
+ /**
206
+ * Additional class name
207
+ */
208
+ className?: string;
209
+ /**
210
+ * Children - use Toaster.Item to customize toast rendering
211
+ */
212
+ children?: ReactNode;
213
+ /**
214
+ * Show countdown progress bar at the bottom of each toast
215
+ * @default false
216
+ */
217
+ showProgress?: boolean;
218
+ /**
219
+ * Layout mode for toasts
220
+ * @default "default"
221
+ */
222
+ layout?: "default" | "compact";
223
+ }
224
+ interface ToasterComponent extends React.MemoExoticComponent<React.ForwardRefExoticComponent<ToasterProps & React.RefAttributes<HTMLDivElement>>> {
225
+ Item: typeof ToasterItemSlot;
226
+ Icon: typeof ToasterIconSlot;
227
+ Title: typeof ToasterTitleSlot;
228
+ Description: typeof ToasterDescriptionSlot;
229
+ Actions: typeof ToasterActionsSlot;
230
+ }
231
+ /**
232
+ * Toaster component with compound pattern
233
+ *
234
+ * @example
235
+ * ```tsx
236
+ * <Toaster id="my-toaster">
237
+ * <Toaster.Item className="custom-class">
238
+ * <Toaster.Icon>{(type, defaultIcon) => <CustomIcon type={type} />}</Toaster.Icon>
239
+ * <Toaster.Title className="font-bold uppercase" />
240
+ * <Toaster.Description className="text-sm" />
241
+ * <Toaster.Actions>{(action, cancel, close) => <CustomActions />}</Toaster.Actions>
242
+ * </Toaster.Item>
243
+ * </Toaster>
244
+ * ```
245
+ */
246
+ declare const Toaster: ToasterComponent;
247
+
248
+ export { type ToastData, type ToastOptions, type ToastPosition, type ToastType, type ToastVariant, Toaster, type ToasterProps, toast };
@@ -0,0 +1,3 @@
1
+ export * from './toast-progress-bar';
2
+ export * from './toaster-slots';
3
+ export * from './toaster-item';
@@ -0,0 +1,7 @@
1
+ import { toastRootTv } from '../tv';
2
+ export interface ToastProgressBarProps {
3
+ duration: number;
4
+ isPaused: boolean;
5
+ tv: ReturnType<typeof toastRootTv>;
6
+ }
7
+ export declare const ToastProgressBar: import('react').NamedExoticComponent<ToastProgressBarProps>;
@@ -0,0 +1,53 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useAnimationControls, motion } from "framer-motion";
3
+ import { memo, useRef, useEffect } from "react";
4
+ const ToastProgressBar = memo(function ToastProgressBar2({
5
+ duration,
6
+ isPaused,
7
+ tv
8
+ }) {
9
+ const controls = useAnimationControls();
10
+ const progressRef = useRef({ elapsed: 0, lastTime: Date.now() });
11
+ useEffect(() => {
12
+ progressRef.current = { elapsed: 0, lastTime: Date.now() };
13
+ controls.start({
14
+ x: "-100%",
15
+ transition: {
16
+ duration: duration / 1e3,
17
+ ease: "linear"
18
+ }
19
+ });
20
+ }, [controls, duration]);
21
+ useEffect(() => {
22
+ const durationSec = duration / 1e3;
23
+ if (isPaused) {
24
+ const now = Date.now();
25
+ progressRef.current.elapsed += (now - progressRef.current.lastTime) / 1e3;
26
+ controls.stop();
27
+ } else {
28
+ const remaining = Math.max(0, durationSec - progressRef.current.elapsed);
29
+ progressRef.current.lastTime = Date.now();
30
+ if (remaining > 0) {
31
+ controls.start({
32
+ x: "-100%",
33
+ transition: {
34
+ duration: remaining,
35
+ ease: "linear"
36
+ }
37
+ });
38
+ }
39
+ }
40
+ }, [isPaused, controls, duration]);
41
+ return /* @__PURE__ */ jsx("div", { className: tv.progressTrack(), children: /* @__PURE__ */ jsx(
42
+ motion.div,
43
+ {
44
+ className: tv.progressIndicator(),
45
+ initial: { x: 0 },
46
+ animate: controls
47
+ }
48
+ ) });
49
+ });
50
+ ToastProgressBar.displayName = "ToastProgressBar";
51
+ export {
52
+ ToastProgressBar
53
+ };
@@ -0,0 +1,26 @@
1
+ import { ToastData } from '../store';
2
+ import { ToastPosition } from '../types';
3
+ import { CollectedSlotProps } from './toaster-slots';
4
+ declare const GAP = 12;
5
+ declare const DEFAULT_HEIGHT = 56;
6
+ export { DEFAULT_HEIGHT, GAP };
7
+ export interface ToasterItemProps {
8
+ toast: ToastData;
9
+ index: number;
10
+ total: number;
11
+ expanded: boolean;
12
+ position: ToastPosition;
13
+ toasterId: string;
14
+ /** Heights of all visible toasts for offset calculation */
15
+ toastHeights: number[];
16
+ /** Collected slot props from Toaster.Item children */
17
+ slotProps: CollectedSlotProps;
18
+ /** Show countdown progress bar */
19
+ showProgress?: boolean;
20
+ /** Default duration from Toaster */
21
+ defaultDuration?: number;
22
+ /** Whether the timer is paused (hovering) */
23
+ isPaused?: boolean;
24
+ layout?: "default" | "compact";
25
+ }
26
+ export declare const ToasterItem: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<ToasterItemProps & import('react').RefAttributes<HTMLDivElement>>>;