@seed-design/react 2.0.5 → 2.1.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.
Files changed (76) hide show
  1. package/lib/components/ContentDialog/ContentDialog.cjs +105 -0
  2. package/lib/components/ContentDialog/ContentDialog.d.ts +50 -0
  3. package/lib/components/ContentDialog/ContentDialog.d.ts.map +1 -0
  4. package/lib/components/ContentDialog/ContentDialog.js +91 -0
  5. package/lib/components/ContentDialog/ContentDialog.namespace.cjs +24 -0
  6. package/lib/components/ContentDialog/ContentDialog.namespace.d.ts +2 -0
  7. package/lib/components/ContentDialog/ContentDialog.namespace.d.ts.map +1 -0
  8. package/lib/components/ContentDialog/ContentDialog.namespace.js +19 -0
  9. package/lib/components/ContentDialog/index.cjs +21 -0
  10. package/lib/components/ContentDialog/index.d.ts +3 -0
  11. package/lib/components/ContentDialog/index.d.ts.map +1 -0
  12. package/lib/components/ContentDialog/index.js +3 -0
  13. package/lib/components/Dialog/index.d.ts.map +1 -1
  14. package/lib/components/QuantityPicker/QuantityPicker.cjs +120 -0
  15. package/lib/components/QuantityPicker/QuantityPicker.d.ts +25 -0
  16. package/lib/components/QuantityPicker/QuantityPicker.d.ts.map +1 -0
  17. package/lib/components/QuantityPicker/QuantityPicker.js +113 -0
  18. package/lib/components/QuantityPicker/QuantityPicker.namespace.cjs +17 -0
  19. package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts +2 -0
  20. package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts.map +1 -0
  21. package/lib/components/QuantityPicker/QuantityPicker.namespace.js +12 -0
  22. package/lib/components/QuantityPicker/QuantityPicker.test.d.ts +2 -0
  23. package/lib/components/QuantityPicker/QuantityPicker.test.d.ts.map +1 -0
  24. package/lib/components/QuantityPicker/index.cjs +14 -0
  25. package/lib/components/QuantityPicker/index.d.ts +3 -0
  26. package/lib/components/QuantityPicker/index.d.ts.map +1 -0
  27. package/lib/components/QuantityPicker/index.js +3 -0
  28. package/lib/components/ResponsiveDialog/ResponsiveDialog.cjs +196 -0
  29. package/lib/components/ResponsiveDialog/ResponsiveDialog.d.ts +72 -0
  30. package/lib/components/ResponsiveDialog/ResponsiveDialog.d.ts.map +1 -0
  31. package/lib/components/ResponsiveDialog/ResponsiveDialog.js +181 -0
  32. package/lib/components/ResponsiveDialog/ResponsiveDialog.namespace.cjs +25 -0
  33. package/lib/components/ResponsiveDialog/ResponsiveDialog.namespace.d.ts +2 -0
  34. package/lib/components/ResponsiveDialog/ResponsiveDialog.namespace.d.ts.map +1 -0
  35. package/lib/components/ResponsiveDialog/ResponsiveDialog.namespace.js +20 -0
  36. package/lib/components/ResponsiveDialog/index.cjs +23 -0
  37. package/lib/components/ResponsiveDialog/index.d.ts +3 -0
  38. package/lib/components/ResponsiveDialog/index.d.ts.map +1 -0
  39. package/lib/components/ResponsiveDialog/index.js +3 -0
  40. package/lib/components/Select/Select.cjs +191 -0
  41. package/lib/components/Select/Select.d.ts +89 -0
  42. package/lib/components/Select/Select.d.ts.map +1 -0
  43. package/lib/components/Select/Select.js +171 -0
  44. package/lib/components/Select/Select.namespace.cjs +30 -0
  45. package/lib/components/Select/Select.namespace.d.ts +2 -0
  46. package/lib/components/Select/Select.namespace.d.ts.map +1 -0
  47. package/lib/components/Select/Select.namespace.js +25 -0
  48. package/lib/components/Select/Select.test.d.ts +2 -0
  49. package/lib/components/Select/Select.test.d.ts.map +1 -0
  50. package/lib/components/Select/index.cjs +27 -0
  51. package/lib/components/Select/index.d.ts +3 -0
  52. package/lib/components/Select/index.d.ts.map +1 -0
  53. package/lib/components/Select/index.js +3 -0
  54. package/lib/components/index.cjs +81 -0
  55. package/lib/components/index.d.ts +4 -0
  56. package/lib/components/index.d.ts.map +1 -1
  57. package/lib/components/index.js +9 -1
  58. package/lib/index.cjs +82 -1
  59. package/lib/index.js +10 -2
  60. package/package.json +8 -6
  61. package/src/components/ContentDialog/ContentDialog.namespace.ts +26 -0
  62. package/src/components/ContentDialog/ContentDialog.tsx +222 -0
  63. package/src/components/ContentDialog/index.ts +33 -0
  64. package/src/components/Dialog/index.ts +5 -0
  65. package/src/components/QuantityPicker/QuantityPicker.namespace.ts +12 -0
  66. package/src/components/QuantityPicker/QuantityPicker.test.tsx +108 -0
  67. package/src/components/QuantityPicker/QuantityPicker.tsx +214 -0
  68. package/src/components/QuantityPicker/index.ts +14 -0
  69. package/src/components/ResponsiveDialog/ResponsiveDialog.namespace.ts +28 -0
  70. package/src/components/ResponsiveDialog/ResponsiveDialog.tsx +327 -0
  71. package/src/components/ResponsiveDialog/index.ts +31 -0
  72. package/src/components/Select/Select.namespace.ts +38 -0
  73. package/src/components/Select/Select.test.tsx +451 -0
  74. package/src/components/Select/Select.tsx +443 -0
  75. package/src/components/Select/index.ts +40 -0
  76. package/src/components/index.ts +4 -0
@@ -0,0 +1,327 @@
1
+ import type { Breakpoint } from "@seed-design/css/breakpoints";
2
+ import { Drawer } from "@seed-design/react-drawer";
3
+ import * as React from "react";
4
+ import { useBreakpointValue } from "../../hooks/useBreakpointValue";
5
+ import {
6
+ type BottomSheet,
7
+ BottomSheetBackdrop,
8
+ BottomSheetBody,
9
+ BottomSheetCloseButton,
10
+ BottomSheetContent,
11
+ BottomSheetDescription,
12
+ BottomSheetFooter,
13
+ BottomSheetHeader,
14
+ BottomSheetPositioner,
15
+ BottomSheetRoot,
16
+ BottomSheetTitle,
17
+ BottomSheetTrigger,
18
+ } from "../BottomSheet";
19
+ import { BottomSheetHandle } from "../BottomSheetHandle";
20
+ import {
21
+ type ContentDialog,
22
+ ContentDialogAction,
23
+ ContentDialogBackdrop,
24
+ ContentDialogBody,
25
+ ContentDialogCloseButton,
26
+ ContentDialogContent,
27
+ ContentDialogDescription,
28
+ ContentDialogFooter,
29
+ ContentDialogHeader,
30
+ ContentDialogPositioner,
31
+ ContentDialogRoot,
32
+ ContentDialogTitle,
33
+ ContentDialogTrigger,
34
+ } from "../ContentDialog";
35
+
36
+ type SharedProps<ContentDialogProps, BottomSheetProps> = Pick<
37
+ ContentDialogProps,
38
+ Extract<keyof ContentDialogProps, keyof BottomSheetProps>
39
+ > &
40
+ Pick<BottomSheetProps, Extract<keyof BottomSheetProps, keyof ContentDialogProps>>;
41
+
42
+ interface ResponsiveDialogContextValue {
43
+ shouldUseBottomSheet: boolean | undefined;
44
+ }
45
+
46
+ const ResponsiveDialogContext = React.createContext<ResponsiveDialogContextValue | null>(null);
47
+
48
+ export function useResponsiveDialogContext() {
49
+ const ctx = React.useContext(ResponsiveDialogContext);
50
+ if (!ctx) {
51
+ throw new Error("ResponsiveDialog sub-components must be used inside <ResponsiveDialogRoot>");
52
+ }
53
+
54
+ return ctx;
55
+ }
56
+
57
+ export interface ResponsiveDialogRootProps {
58
+ children?: React.ReactNode;
59
+ open?: boolean;
60
+ defaultOpen?: boolean;
61
+ onOpenChange?: (open: boolean) => void;
62
+
63
+ /**
64
+ * Breakpoint at and above which it renders as a Dialog; below it, a
65
+ * BottomSheet. Cannot be `"base"`, which would always be a Dialog.
66
+ * @default "md"
67
+ */
68
+ dialogBreakpoint?: Exclude<Breakpoint, "base">;
69
+
70
+ /** Props forwarded to the underlying ContentDialog root (at and above the breakpoint). */
71
+ dialogRootProps?: Omit<
72
+ ContentDialog.RootProps,
73
+ "children" | "open" | "defaultOpen" | "onOpenChange"
74
+ >;
75
+
76
+ /** Props forwarded to the underlying BottomSheet root (below the breakpoint). */
77
+ bottomSheetRootProps?: Omit<
78
+ BottomSheet.RootProps,
79
+ "children" | "open" | "defaultOpen" | "onOpenChange"
80
+ >;
81
+ }
82
+
83
+ export const ResponsiveDialogRoot = ({
84
+ children,
85
+ open: openProp,
86
+ defaultOpen = false,
87
+ onOpenChange,
88
+ dialogBreakpoint = "md",
89
+ dialogRootProps,
90
+ bottomSheetRootProps,
91
+ }: ResponsiveDialogRootProps) => {
92
+ const shouldUseBottomSheet = useBreakpointValue({ base: true, [dialogBreakpoint]: false });
93
+
94
+ const isControlled = openProp !== undefined;
95
+ const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
96
+ const open = openProp ?? internalOpen;
97
+
98
+ const setOpen = React.useCallback(
99
+ (nextOpen: boolean) => {
100
+ if (nextOpen === open) return;
101
+
102
+ if (!isControlled) {
103
+ setInternalOpen(nextOpen);
104
+ }
105
+
106
+ onOpenChange?.(nextOpen);
107
+ },
108
+ [isControlled, onOpenChange, open],
109
+ );
110
+
111
+ const value = React.useMemo(() => ({ shouldUseBottomSheet }), [shouldUseBottomSheet]);
112
+
113
+ return (
114
+ <ResponsiveDialogContext.Provider value={value}>
115
+ {shouldUseBottomSheet ? (
116
+ <BottomSheetRoot {...bottomSheetRootProps} open={open} onOpenChange={setOpen}>
117
+ {children}
118
+ </BottomSheetRoot>
119
+ ) : (
120
+ <ContentDialogRoot {...dialogRootProps} open={open} onOpenChange={setOpen}>
121
+ {children}
122
+ </ContentDialogRoot>
123
+ )}
124
+ </ResponsiveDialogContext.Provider>
125
+ );
126
+ };
127
+ ResponsiveDialogRoot.displayName = "ResponsiveDialogRoot";
128
+
129
+ export interface ResponsiveDialogTriggerProps
130
+ extends SharedProps<ContentDialog.TriggerProps, BottomSheet.TriggerProps> {}
131
+
132
+ export const ResponsiveDialogTrigger = React.forwardRef<
133
+ HTMLButtonElement,
134
+ ResponsiveDialogTriggerProps
135
+ >((props, ref) => {
136
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
137
+
138
+ return shouldUseBottomSheet ? (
139
+ <BottomSheetTrigger ref={ref} {...props} />
140
+ ) : (
141
+ <ContentDialogTrigger ref={ref} {...props} />
142
+ );
143
+ });
144
+ ResponsiveDialogTrigger.displayName = "ResponsiveDialogTrigger";
145
+
146
+ export interface ResponsiveDialogPositionerProps
147
+ extends SharedProps<ContentDialog.PositionerProps, BottomSheet.PositionerProps> {}
148
+
149
+ export const ResponsiveDialogPositioner = React.forwardRef<
150
+ HTMLDivElement,
151
+ ResponsiveDialogPositionerProps
152
+ >((props, ref) => {
153
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
154
+
155
+ return shouldUseBottomSheet ? (
156
+ <BottomSheetPositioner ref={ref} {...props} />
157
+ ) : (
158
+ <ContentDialogPositioner ref={ref} {...props} />
159
+ );
160
+ });
161
+ ResponsiveDialogPositioner.displayName = "ResponsiveDialogPositioner";
162
+
163
+ export interface ResponsiveDialogBackdropProps
164
+ extends SharedProps<ContentDialog.BackdropProps, BottomSheet.BackdropProps> {}
165
+
166
+ export const ResponsiveDialogBackdrop = React.forwardRef<
167
+ HTMLDivElement,
168
+ ResponsiveDialogBackdropProps
169
+ >((props, ref) => {
170
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
171
+
172
+ return shouldUseBottomSheet ? (
173
+ <BottomSheetBackdrop ref={ref} {...props} />
174
+ ) : (
175
+ <ContentDialogBackdrop ref={ref} {...props} />
176
+ );
177
+ });
178
+ ResponsiveDialogBackdrop.displayName = "ResponsiveDialogBackdrop";
179
+
180
+ export interface ResponsiveDialogContentProps
181
+ extends SharedProps<ContentDialog.ContentProps, BottomSheet.ContentProps> {}
182
+
183
+ export const ResponsiveDialogContent = React.forwardRef<
184
+ HTMLDivElement,
185
+ ResponsiveDialogContentProps
186
+ >((props, ref) => {
187
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
188
+
189
+ return shouldUseBottomSheet ? (
190
+ <BottomSheetContent ref={ref} {...props} />
191
+ ) : (
192
+ <ContentDialogContent ref={ref} {...props} />
193
+ );
194
+ });
195
+ ResponsiveDialogContent.displayName = "ResponsiveDialogContent";
196
+
197
+ export interface ResponsiveDialogHeaderProps
198
+ extends SharedProps<ContentDialog.HeaderProps, BottomSheet.HeaderProps> {}
199
+
200
+ export const ResponsiveDialogHeader = React.forwardRef<HTMLDivElement, ResponsiveDialogHeaderProps>(
201
+ (props, ref) => {
202
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
203
+
204
+ return shouldUseBottomSheet ? (
205
+ <BottomSheetHeader ref={ref} {...props} />
206
+ ) : (
207
+ <ContentDialogHeader ref={ref} {...props} />
208
+ );
209
+ },
210
+ );
211
+ ResponsiveDialogHeader.displayName = "ResponsiveDialogHeader";
212
+
213
+ export interface ResponsiveDialogTitleProps
214
+ extends SharedProps<ContentDialog.TitleProps, BottomSheet.TitleProps> {}
215
+
216
+ export const ResponsiveDialogTitle = React.forwardRef<
217
+ HTMLHeadingElement,
218
+ ResponsiveDialogTitleProps
219
+ >((props, ref) => {
220
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
221
+
222
+ return shouldUseBottomSheet ? (
223
+ <BottomSheetTitle ref={ref} {...props} />
224
+ ) : (
225
+ <ContentDialogTitle ref={ref} {...props} />
226
+ );
227
+ });
228
+ ResponsiveDialogTitle.displayName = "ResponsiveDialogTitle";
229
+
230
+ export interface ResponsiveDialogDescriptionProps
231
+ extends SharedProps<ContentDialog.DescriptionProps, BottomSheet.DescriptionProps> {}
232
+
233
+ export const ResponsiveDialogDescription = React.forwardRef<
234
+ HTMLParagraphElement,
235
+ ResponsiveDialogDescriptionProps
236
+ >((props, ref) => {
237
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
238
+
239
+ return shouldUseBottomSheet ? (
240
+ <BottomSheetDescription ref={ref} {...props} />
241
+ ) : (
242
+ <ContentDialogDescription ref={ref} {...props} />
243
+ );
244
+ });
245
+ ResponsiveDialogDescription.displayName = "ResponsiveDialogDescription";
246
+
247
+ export interface ResponsiveDialogBodyProps
248
+ extends SharedProps<ContentDialog.BodyProps, BottomSheet.BodyProps> {}
249
+
250
+ export const ResponsiveDialogBody = React.forwardRef<HTMLDivElement, ResponsiveDialogBodyProps>(
251
+ (props, ref) => {
252
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
253
+
254
+ return shouldUseBottomSheet ? (
255
+ <BottomSheetBody ref={ref} {...props} />
256
+ ) : (
257
+ <ContentDialogBody ref={ref} {...props} />
258
+ );
259
+ },
260
+ );
261
+ ResponsiveDialogBody.displayName = "ResponsiveDialogBody";
262
+
263
+ export interface ResponsiveDialogFooterProps
264
+ extends SharedProps<ContentDialog.FooterProps, BottomSheet.FooterProps> {}
265
+
266
+ export const ResponsiveDialogFooter = React.forwardRef<HTMLDivElement, ResponsiveDialogFooterProps>(
267
+ (props, ref) => {
268
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
269
+
270
+ return shouldUseBottomSheet ? (
271
+ <BottomSheetFooter ref={ref} {...props} />
272
+ ) : (
273
+ <ContentDialogFooter ref={ref} {...props} />
274
+ );
275
+ },
276
+ );
277
+ ResponsiveDialogFooter.displayName = "ResponsiveDialogFooter";
278
+
279
+ /**
280
+ * Unstyled button that closes the dialog or bottom sheet on click, meant to be
281
+ * composed with an action button via `asChild`.
282
+ */
283
+ export interface ResponsiveDialogActionProps
284
+ extends SharedProps<ContentDialog.ActionProps, Drawer.CloseButtonProps> {}
285
+
286
+ export const ResponsiveDialogAction = React.forwardRef<
287
+ HTMLButtonElement,
288
+ ResponsiveDialogActionProps
289
+ >((props, ref) => {
290
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
291
+
292
+ return shouldUseBottomSheet ? (
293
+ <Drawer.CloseButton ref={ref} {...props} />
294
+ ) : (
295
+ <ContentDialogAction ref={ref} {...props} />
296
+ );
297
+ });
298
+ ResponsiveDialogAction.displayName = "ResponsiveDialogAction";
299
+
300
+ export interface ResponsiveDialogCloseButtonProps
301
+ extends SharedProps<ContentDialog.CloseButtonProps, BottomSheet.CloseButtonProps> {}
302
+
303
+ export const ResponsiveDialogCloseButton = React.forwardRef<
304
+ HTMLButtonElement,
305
+ ResponsiveDialogCloseButtonProps
306
+ >((props, ref) => {
307
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
308
+
309
+ return shouldUseBottomSheet ? (
310
+ <BottomSheetCloseButton ref={ref} {...props} />
311
+ ) : (
312
+ <ContentDialogCloseButton ref={ref} {...props} />
313
+ );
314
+ });
315
+ ResponsiveDialogCloseButton.displayName = "ResponsiveDialogCloseButton";
316
+
317
+ export interface ResponsiveDialogHandleProps extends BottomSheet.HandleProps {}
318
+
319
+ export const ResponsiveDialogHandle = React.forwardRef<HTMLDivElement, ResponsiveDialogHandleProps>(
320
+ (props, ref) => {
321
+ const { shouldUseBottomSheet } = useResponsiveDialogContext();
322
+ if (!shouldUseBottomSheet) return null;
323
+
324
+ return <BottomSheetHandle ref={ref} {...props} />;
325
+ },
326
+ );
327
+ ResponsiveDialogHandle.displayName = "ResponsiveDialogHandle";
@@ -0,0 +1,31 @@
1
+ export {
2
+ ResponsiveDialogAction,
3
+ ResponsiveDialogBackdrop,
4
+ ResponsiveDialogBody,
5
+ ResponsiveDialogContent,
6
+ ResponsiveDialogDescription,
7
+ ResponsiveDialogFooter,
8
+ ResponsiveDialogHandle,
9
+ ResponsiveDialogHeader,
10
+ ResponsiveDialogPositioner,
11
+ ResponsiveDialogRoot,
12
+ ResponsiveDialogTitle,
13
+ ResponsiveDialogTrigger,
14
+ ResponsiveDialogCloseButton,
15
+ useResponsiveDialogContext,
16
+ type ResponsiveDialogActionProps,
17
+ type ResponsiveDialogBackdropProps,
18
+ type ResponsiveDialogBodyProps,
19
+ type ResponsiveDialogContentProps,
20
+ type ResponsiveDialogDescriptionProps,
21
+ type ResponsiveDialogFooterProps,
22
+ type ResponsiveDialogHandleProps,
23
+ type ResponsiveDialogHeaderProps,
24
+ type ResponsiveDialogPositionerProps,
25
+ type ResponsiveDialogRootProps,
26
+ type ResponsiveDialogTitleProps,
27
+ type ResponsiveDialogTriggerProps,
28
+ type ResponsiveDialogCloseButtonProps,
29
+ } from "./ResponsiveDialog";
30
+
31
+ export * as ResponsiveDialog from "./ResponsiveDialog.namespace";
@@ -0,0 +1,38 @@
1
+ export {
2
+ SelectRoot as Root,
3
+ SelectTrigger as Trigger,
4
+ SelectValue as Value,
5
+ SelectPlaceholder as Placeholder,
6
+ SelectPrefixIcon as PrefixIcon,
7
+ SelectSuffixIcon as SuffixIcon,
8
+ SelectPositioner as Positioner,
9
+ SelectContent as Content,
10
+ SelectScrollArea as ScrollArea,
11
+ SelectGroup as Group,
12
+ SelectGroupLabel as GroupLabel,
13
+ SelectItem as Item,
14
+ SelectItemPrefixIcon as ItemPrefixIcon,
15
+ SelectItemBody as ItemBody,
16
+ SelectItemLabel as ItemLabel,
17
+ SelectItemDescription as ItemDescription,
18
+ SelectItemIndicator as ItemIndicator,
19
+ SelectHiddenSelect as HiddenSelect,
20
+ type SelectRootProps as RootProps,
21
+ type SelectTriggerProps as TriggerProps,
22
+ type SelectValueProps as ValueProps,
23
+ type SelectPlaceholderProps as PlaceholderProps,
24
+ type SelectPrefixIconProps as PrefixIconProps,
25
+ type SelectSuffixIconProps as SuffixIconProps,
26
+ type SelectPositionerProps as PositionerProps,
27
+ type SelectContentProps as ContentProps,
28
+ type SelectScrollAreaProps as ScrollAreaProps,
29
+ type SelectGroupProps as GroupProps,
30
+ type SelectGroupLabelProps as GroupLabelProps,
31
+ type SelectItemProps as ItemProps,
32
+ type SelectItemPrefixIconProps as ItemPrefixIconProps,
33
+ type SelectItemBodyProps as ItemBodyProps,
34
+ type SelectItemLabelProps as ItemLabelProps,
35
+ type SelectItemDescriptionProps as ItemDescriptionProps,
36
+ type SelectItemIndicatorProps as ItemIndicatorProps,
37
+ type SelectHiddenSelectProps as HiddenSelectProps,
38
+ } from "./Select";