@dust-tt/sparkle 0.2.576 → 0.2.577-rc-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.
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/Dialog.d.ts +1 -0
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js +10 -2
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/Dropdown.d.ts +1 -1
- package/dist/esm/components/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown.js +9 -3
- package/dist/esm/components/Dropdown.js.map +1 -1
- package/dist/esm/components/MultiPageDialog.d.ts +1 -0
- package/dist/esm/components/MultiPageDialog.d.ts.map +1 -1
- package/dist/esm/components/MultiPageDialog.js +2 -2
- package/dist/esm/components/MultiPageDialog.js.map +1 -1
- package/dist/esm/components/Popover.d.ts +1 -0
- package/dist/esm/components/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover.js +9 -3
- package/dist/esm/components/Popover.js.map +1 -1
- package/dist/esm/components/SearchDropdownMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchDropdownMenu.js +1 -3
- package/dist/esm/components/SearchDropdownMenu.js.map +1 -1
- package/dist/esm/components/Sheet.d.ts +1 -0
- package/dist/esm/components/Sheet.d.ts.map +1 -1
- package/dist/esm/components/Sheet.js +8 -2
- package/dist/esm/components/Sheet.js.map +1 -1
- package/dist/esm/stories/Dropdown.stories.d.ts.map +1 -1
- package/dist/esm/stories/Dropdown.stories.js +1 -1
- package/dist/esm/stories/Dropdown.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Dialog.tsx +35 -17
- package/src/components/Dropdown.tsx +14 -1
- package/src/components/MultiPageDialog.tsx +3 -0
- package/src/components/Popover.tsx +13 -0
- package/src/components/SearchDropdownMenu.tsx +0 -3
- package/src/components/Sheet.tsx +46 -18
- package/src/stories/Dropdown.stories.tsx +6 -1
|
@@ -78,6 +78,7 @@ interface DialogContentProps
|
|
|
78
78
|
height?: DialogHeightType;
|
|
79
79
|
trapFocusScope?: boolean;
|
|
80
80
|
isAlertDialog?: boolean;
|
|
81
|
+
preventAutoFocusOnClose?: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const DialogContent = React.forwardRef<
|
|
@@ -92,26 +93,43 @@ const DialogContent = React.forwardRef<
|
|
|
92
93
|
height,
|
|
93
94
|
trapFocusScope,
|
|
94
95
|
isAlertDialog,
|
|
96
|
+
preventAutoFocusOnClose = true,
|
|
97
|
+
onCloseAutoFocus,
|
|
95
98
|
...props
|
|
96
99
|
},
|
|
97
100
|
ref
|
|
98
|
-
) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
) => {
|
|
102
|
+
const handleCloseAutoFocus = React.useCallback(
|
|
103
|
+
(event: Event) => {
|
|
104
|
+
if (preventAutoFocusOnClose) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
}
|
|
107
|
+
onCloseAutoFocus?.(event);
|
|
108
|
+
},
|
|
109
|
+
[preventAutoFocusOnClose, onCloseAutoFocus]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<DialogPortal>
|
|
114
|
+
<DialogOverlay />
|
|
115
|
+
<FocusScope trapped={trapFocusScope} asChild>
|
|
116
|
+
<DialogPrimitive.Content
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn(dialogVariants({ size, height }), className)}
|
|
119
|
+
onInteractOutside={
|
|
120
|
+
isAlertDialog
|
|
121
|
+
? (e) => e.preventDefault()
|
|
122
|
+
: props.onInteractOutside
|
|
123
|
+
}
|
|
124
|
+
onCloseAutoFocus={handleCloseAutoFocus}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</DialogPrimitive.Content>
|
|
129
|
+
</FocusScope>
|
|
130
|
+
</DialogPortal>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
115
133
|
);
|
|
116
134
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
117
135
|
|
|
@@ -244,7 +244,7 @@ interface DropdownMenuContentProps
|
|
|
244
244
|
mountPortal?: boolean;
|
|
245
245
|
mountPortalContainer?: HTMLElement;
|
|
246
246
|
dropdownHeaders?: React.ReactNode;
|
|
247
|
-
|
|
247
|
+
preventAutoFocusOnClose?: boolean;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
const DropdownMenuContent = React.forwardRef<
|
|
@@ -258,11 +258,23 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
258
258
|
mountPortal = true,
|
|
259
259
|
mountPortalContainer,
|
|
260
260
|
dropdownHeaders,
|
|
261
|
+
preventAutoFocusOnClose = true,
|
|
262
|
+
onCloseAutoFocus,
|
|
261
263
|
children,
|
|
262
264
|
...props
|
|
263
265
|
},
|
|
264
266
|
ref
|
|
265
267
|
) => {
|
|
268
|
+
const handleCloseAutoFocus = React.useCallback(
|
|
269
|
+
(event: Event) => {
|
|
270
|
+
if (preventAutoFocusOnClose) {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
}
|
|
273
|
+
onCloseAutoFocus?.(event);
|
|
274
|
+
},
|
|
275
|
+
[preventAutoFocusOnClose, onCloseAutoFocus]
|
|
276
|
+
);
|
|
277
|
+
|
|
266
278
|
const content = (
|
|
267
279
|
<DropdownMenuPrimitive.Content
|
|
268
280
|
ref={ref}
|
|
@@ -273,6 +285,7 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
273
285
|
dropdownHeaders && "s-h-80 xs:s-h-96", // We use dropdownHeaders for putting search bar, so we can set the height for the container
|
|
274
286
|
className
|
|
275
287
|
)}
|
|
288
|
+
onCloseAutoFocus={handleCloseAutoFocus}
|
|
276
289
|
{...props}
|
|
277
290
|
>
|
|
278
291
|
<div className="s-sticky s-top-0 s-bg-background dark:s-bg-background-night">
|
|
@@ -85,6 +85,7 @@ interface MultiPageDialogProps {
|
|
|
85
85
|
height?: React.ComponentProps<typeof DialogContent>["height"];
|
|
86
86
|
trapFocusScope?: boolean;
|
|
87
87
|
isAlertDialog?: boolean;
|
|
88
|
+
preventAutoFocusOnClose?: boolean;
|
|
88
89
|
showNavigation?: boolean;
|
|
89
90
|
showHeaderNavigation?: boolean;
|
|
90
91
|
className?: string;
|
|
@@ -113,6 +114,7 @@ const MultiPageDialogContent = React.forwardRef<
|
|
|
113
114
|
height,
|
|
114
115
|
trapFocusScope,
|
|
115
116
|
isAlertDialog,
|
|
117
|
+
preventAutoFocusOnClose,
|
|
116
118
|
showNavigation = true,
|
|
117
119
|
showHeaderNavigation = true,
|
|
118
120
|
className,
|
|
@@ -179,6 +181,7 @@ const MultiPageDialogContent = React.forwardRef<
|
|
|
179
181
|
height={height}
|
|
180
182
|
trapFocusScope={trapFocusScope}
|
|
181
183
|
isAlertDialog={isAlertDialog}
|
|
184
|
+
preventAutoFocusOnClose={preventAutoFocusOnClose}
|
|
182
185
|
className={className}
|
|
183
186
|
{...props}
|
|
184
187
|
>
|
|
@@ -14,6 +14,7 @@ export interface PopoverContentProps
|
|
|
14
14
|
fullWidth?: boolean;
|
|
15
15
|
mountPortal?: boolean;
|
|
16
16
|
mountPortalContainer?: HTMLElement;
|
|
17
|
+
preventAutoFocusOnClose?: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const PopoverContent = React.forwardRef<
|
|
@@ -28,10 +29,21 @@ const PopoverContent = React.forwardRef<
|
|
|
28
29
|
mountPortal = true,
|
|
29
30
|
mountPortalContainer,
|
|
30
31
|
fullWidth = false,
|
|
32
|
+
preventAutoFocusOnClose = true,
|
|
33
|
+
onCloseAutoFocus,
|
|
31
34
|
...props
|
|
32
35
|
},
|
|
33
36
|
ref
|
|
34
37
|
) => {
|
|
38
|
+
const handleCloseAutoFocus = React.useCallback(
|
|
39
|
+
(event: Event) => {
|
|
40
|
+
if (preventAutoFocusOnClose) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
}
|
|
43
|
+
onCloseAutoFocus?.(event);
|
|
44
|
+
},
|
|
45
|
+
[preventAutoFocusOnClose, onCloseAutoFocus]
|
|
46
|
+
);
|
|
35
47
|
const content = (
|
|
36
48
|
<PopoverPrimitive.Content
|
|
37
49
|
ref={ref}
|
|
@@ -51,6 +63,7 @@ const PopoverContent = React.forwardRef<
|
|
|
51
63
|
fullWidth ? "s-grow" : "s-w-72 s-p-4",
|
|
52
64
|
className
|
|
53
65
|
)}
|
|
66
|
+
onCloseAutoFocus={handleCloseAutoFocus}
|
|
54
67
|
{...props}
|
|
55
68
|
/>
|
|
56
69
|
);
|
package/src/components/Sheet.tsx
CHANGED
|
@@ -87,29 +87,57 @@ interface SheetContentProps
|
|
|
87
87
|
size?: SheetSizeType;
|
|
88
88
|
trapFocusScope?: boolean;
|
|
89
89
|
side?: SheetSideType;
|
|
90
|
+
preventAutoFocusOnClose?: boolean;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
const SheetContent = React.forwardRef<
|
|
93
94
|
React.ElementRef<typeof SheetPrimitive.Content>,
|
|
94
95
|
SheetContentProps
|
|
95
|
-
>(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
96
|
+
>(
|
|
97
|
+
(
|
|
98
|
+
{
|
|
99
|
+
className,
|
|
100
|
+
children,
|
|
101
|
+
size,
|
|
102
|
+
side,
|
|
103
|
+
trapFocusScope,
|
|
104
|
+
preventAutoFocusOnClose = true,
|
|
105
|
+
onCloseAutoFocus,
|
|
106
|
+
...props
|
|
107
|
+
},
|
|
108
|
+
ref
|
|
109
|
+
) => {
|
|
110
|
+
const handleCloseAutoFocus = React.useCallback(
|
|
111
|
+
(event: Event) => {
|
|
112
|
+
if (preventAutoFocusOnClose) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
}
|
|
115
|
+
onCloseAutoFocus?.(event);
|
|
116
|
+
},
|
|
117
|
+
[preventAutoFocusOnClose, onCloseAutoFocus]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<SheetPortal>
|
|
122
|
+
<SheetOverlay />
|
|
123
|
+
<FocusScope trapped={trapFocusScope} asChild>
|
|
124
|
+
<SheetPrimitive.Content
|
|
125
|
+
ref={ref}
|
|
126
|
+
className={cn(
|
|
127
|
+
sheetVariants({ size, side }),
|
|
128
|
+
className,
|
|
129
|
+
"s-sheet s-text-foreground dark:s-text-foreground-night"
|
|
130
|
+
)}
|
|
131
|
+
onCloseAutoFocus={handleCloseAutoFocus}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
{children}
|
|
135
|
+
</SheetPrimitive.Content>
|
|
136
|
+
</FocusScope>
|
|
137
|
+
</SheetPortal>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
113
141
|
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
114
142
|
|
|
115
143
|
interface SheetHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -309,7 +309,12 @@ function ModelsDropdownDemo() {
|
|
|
309
309
|
return (
|
|
310
310
|
<DropdownMenu>
|
|
311
311
|
<DropdownMenuTrigger asChild>
|
|
312
|
-
<Button
|
|
312
|
+
<Button
|
|
313
|
+
label={selectedModel}
|
|
314
|
+
variant="outline"
|
|
315
|
+
size="sm"
|
|
316
|
+
tooltip="Test"
|
|
317
|
+
/>
|
|
313
318
|
</DropdownMenuTrigger>
|
|
314
319
|
<DropdownMenuContent>
|
|
315
320
|
<DropdownMenuLabel label="Best performing models" />
|