@zvk/ui 0.1.3 → 0.1.5
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/components/alert-dialog/alert-dialog.d.ts +8 -5
- package/dist/components/alert-dialog/alert-dialog.js +21 -8
- package/dist/components/button/button.d.ts +3 -2
- package/dist/components/button/button.js +5 -1
- package/dist/components/calendar/calendar.d.ts +40 -5
- package/dist/components/calendar/calendar.js +17 -5
- package/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/collapsible/collapsible.d.ts +3 -2
- package/dist/components/collapsible/collapsible.js +5 -1
- package/dist/components/command/command.d.ts +11 -4
- package/dist/components/command/command.js +27 -16
- package/dist/components/command/index.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +17 -6
- package/dist/components/context-menu/context-menu.js +139 -36
- package/dist/components/dialog/dialog.d.ts +6 -4
- package/dist/components/dialog/dialog.js +14 -4
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
- package/dist/components/dropdown-menu/dropdown-menu.js +127 -72
- package/dist/components/hover-card/hover-card.d.ts +8 -2
- package/dist/components/hover-card/hover-card.js +8 -5
- package/dist/components/index.d.ts +7 -7
- package/dist/components/index.js +1 -1
- package/dist/components/menubar/menubar.d.ts +24 -5
- package/dist/components/menubar/menubar.js +182 -33
- package/dist/components/popover/popover.d.ts +8 -3
- package/dist/components/popover/popover.js +14 -5
- package/dist/components/sheet/sheet.d.ts +6 -4
- package/dist/components/sheet/sheet.js +21 -8
- package/dist/components/toast/index.d.ts +2 -2
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast.d.ts +16 -2
- package/dist/components/toast/toast.js +44 -2
- package/dist/components/tooltip/tooltip.d.ts +8 -2
- package/dist/components/tooltip/tooltip.js +8 -5
- package/dist/internal/floating/placement-aliases.d.ts +7 -0
- package/dist/internal/floating/placement-aliases.js +13 -0
- package/dist/internal/slot/index.d.ts +2 -0
- package/dist/internal/slot/index.js +1 -0
- package/dist/internal/slot/slot.d.ts +6 -0
- package/dist/internal/slot/slot.js +53 -0
- package/dist/styles.css +21 -1
- package/package.json +2 -2
|
@@ -7,6 +7,8 @@ import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
|
7
7
|
import { Portal } from "../../internal/portal/index.js";
|
|
8
8
|
import { DismissableLayer } from "../../internal/dismissable-layer/dismissable-layer.js";
|
|
9
9
|
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
10
|
+
import { placementFromSideAlign, placementParts } from "../../internal/floating/placement-aliases.js";
|
|
11
|
+
import { Slot } from "../../internal/slot/index.js";
|
|
10
12
|
const defaultContentPositioning = {
|
|
11
13
|
sideOffset: 8,
|
|
12
14
|
collisionPadding: 0,
|
|
@@ -35,6 +37,18 @@ function composeRefs(...refs) {
|
|
|
35
37
|
function filterEnabledItems(items) {
|
|
36
38
|
return items.filter((item) => !item.disabled && item.ref !== null);
|
|
37
39
|
}
|
|
40
|
+
function setComposedRef(internalRef, externalRef, node) {
|
|
41
|
+
internalRef.current = node;
|
|
42
|
+
if (typeof externalRef === "function") {
|
|
43
|
+
externalRef(node);
|
|
44
|
+
}
|
|
45
|
+
else if (externalRef !== undefined && externalRef !== null) {
|
|
46
|
+
externalRef.current = node;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function isActivationKey(key) {
|
|
50
|
+
return key === " " || key === "Space" || key === "Enter" || key === "Spacebar";
|
|
51
|
+
}
|
|
38
52
|
const DropdownMenuRadioGroupContext = React.createContext(null);
|
|
39
53
|
function DropdownMenuRoot({ children, className, container, defaultOpen = false, onOpenChange, open: openProp, placement = "bottom", sideOffset = 8, collisionPadding = 0, matchTriggerWidth = false, ...props }) {
|
|
40
54
|
const [open, setOpen] = useControllableState({
|
|
@@ -56,7 +70,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
56
70
|
});
|
|
57
71
|
const floating = useFloatingPosition({
|
|
58
72
|
open,
|
|
59
|
-
placement,
|
|
73
|
+
placement: contentPositioning.placement ?? placement,
|
|
60
74
|
strategy: "absolute",
|
|
61
75
|
offset: contentPositioning.sideOffset,
|
|
62
76
|
collisionPadding: contentPositioning.collisionPadding,
|
|
@@ -116,6 +130,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
116
130
|
triggerRef,
|
|
117
131
|
referenceRef: floating.referenceRef,
|
|
118
132
|
floatingRef: floating.floatingRef,
|
|
133
|
+
floatingPlacement: floating.placement,
|
|
119
134
|
floatingStyle: floating.floatingStyle,
|
|
120
135
|
getEnabledItems,
|
|
121
136
|
registerItem,
|
|
@@ -123,25 +138,29 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
123
138
|
...(container === undefined ? {} : { container })
|
|
124
139
|
}, children: _jsx("div", { ...props, className: cn("liano-dropdown-menu", className), "data-state": open ? "open" : "closed", children: children }) }));
|
|
125
140
|
}
|
|
126
|
-
function DropdownMenuTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
|
|
141
|
+
function DropdownMenuTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
127
142
|
const { contentId, open, setOpen, triggerRef, triggerId, referenceRef, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Trigger");
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
const handleClick = () => {
|
|
144
|
+
if (disabled) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const nextOpen = !open;
|
|
148
|
+
setOpen(nextOpen);
|
|
149
|
+
if (!nextOpen) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
queueMicrotask(() => {
|
|
153
|
+
const first = getEnabledItems()[0];
|
|
154
|
+
first?.ref?.focus();
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
if (asChild) {
|
|
158
|
+
return (_jsx(Slot, { ...props, ref: composeRefs(ref, triggerRef, referenceRef), id: triggerId, "aria-controls": contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": open ? "true" : "false", "aria-haspopup": "menu", className: cn("liano-dropdown-menu__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
|
|
159
|
+
}
|
|
160
|
+
return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef, referenceRef), type: type, disabled: disabled, id: triggerId, role: "button", "aria-haspopup": "menu", "aria-expanded": open ? "true" : "false", "aria-controls": contentId, className: cn("liano-dropdown-menu__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
|
|
142
161
|
}
|
|
143
|
-
function DropdownMenuContent({ children, className, forceMount = false, sideOffset = defaultContentPositioning.sideOffset, collisionPadding = defaultContentPositioning.collisionPadding, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, ref, onKeyDown, ...props }) {
|
|
144
|
-
const { container, contentId, open, setOpen, updateContentPositioning, triggerId, floatingRef, floatingStyle, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Content");
|
|
162
|
+
function DropdownMenuContent({ align, alignOffset: _alignOffset, children, className, forceMount = false, side, sideOffset = defaultContentPositioning.sideOffset, collisionPadding = defaultContentPositioning.collisionPadding, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, ref, onKeyDown, ...props }) {
|
|
163
|
+
const { container, contentId, open, setOpen, updateContentPositioning, triggerId, floatingRef, floatingPlacement, floatingStyle, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Content");
|
|
145
164
|
const focusItem = React.useCallback((index, items) => {
|
|
146
165
|
if (items.length === 0) {
|
|
147
166
|
return;
|
|
@@ -181,6 +200,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
|
|
|
181
200
|
}, [getEnabledItems]);
|
|
182
201
|
React.useEffect(() => {
|
|
183
202
|
updateContentPositioning({
|
|
203
|
+
...(side === undefined ? {} : { placement: placementFromSideAlign(side, align, "bottom") }),
|
|
184
204
|
sideOffset,
|
|
185
205
|
collisionPadding,
|
|
186
206
|
matchTriggerWidth
|
|
@@ -188,7 +208,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
|
|
|
188
208
|
return () => {
|
|
189
209
|
updateContentPositioning(defaultContentPositioning);
|
|
190
210
|
};
|
|
191
|
-
}, [collisionPadding, matchTriggerWidth, sideOffset, updateContentPositioning]);
|
|
211
|
+
}, [align, collisionPadding, matchTriggerWidth, side, sideOffset, updateContentPositioning]);
|
|
192
212
|
if (!open && !forceMount) {
|
|
193
213
|
return null;
|
|
194
214
|
}
|
|
@@ -200,7 +220,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
|
|
|
200
220
|
else if (ref) {
|
|
201
221
|
ref.current = node;
|
|
202
222
|
}
|
|
203
|
-
}, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("liano-dropdown-menu__content", className), style: floatingStyle, "data-state": open ? "open" : "closed", hidden: open ? undefined : true, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
223
|
+
}, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("liano-dropdown-menu__content", className), style: floatingStyle, "data-align": placementParts(floatingPlacement).align, "data-side": placementParts(floatingPlacement).side, "data-state": open ? "open" : "closed", hidden: open ? undefined : true, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
204
224
|
if (event.key === "ArrowDown") {
|
|
205
225
|
event.preventDefault();
|
|
206
226
|
moveFocus("next");
|
|
@@ -236,7 +256,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
|
|
|
236
256
|
setOpen(false);
|
|
237
257
|
}, children: content }) }));
|
|
238
258
|
}
|
|
239
|
-
function DropdownMenuItem({ children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }) {
|
|
259
|
+
function DropdownMenuItem({ asChild = false, children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }) {
|
|
240
260
|
const context = useDropdownMenuContext("DropdownMenu.Item");
|
|
241
261
|
const itemRef = React.useRef(null);
|
|
242
262
|
const itemId = React.useId();
|
|
@@ -251,30 +271,39 @@ function DropdownMenuItem({ children, className, disabled, onClick, onSelect, on
|
|
|
251
271
|
context.registerItem(itemRecord);
|
|
252
272
|
return () => context.unregisterItem(itemId);
|
|
253
273
|
}, [context, isDisabled, itemId, onSelect]);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
ref.current = node;
|
|
261
|
-
}
|
|
262
|
-
}, type: "button", role: "menuitem", disabled: isDisabled, "aria-disabled": isDisabled ? "true" : undefined, className: cn("liano-dropdown-menu__item", className), "data-state": isDisabled ? "disabled" : "enabled", onClick: composeEventHandlers(onClick, (event) => {
|
|
263
|
-
if (isDisabled) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
onSelect?.(event);
|
|
274
|
+
const select = (event) => {
|
|
275
|
+
if (isDisabled) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
onSelect?.(event);
|
|
279
|
+
if (!event.defaultPrevented) {
|
|
267
280
|
context.setOpen(false);
|
|
268
|
-
}
|
|
269
|
-
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const itemProps = {
|
|
284
|
+
...props,
|
|
285
|
+
ref: (node) => {
|
|
286
|
+
setComposedRef(itemRef, ref, node);
|
|
287
|
+
},
|
|
288
|
+
role: "menuitem",
|
|
289
|
+
"aria-disabled": isDisabled ? true : undefined,
|
|
290
|
+
className: cn("liano-dropdown-menu__item", className),
|
|
291
|
+
"data-disabled": isDisabled ? "true" : undefined,
|
|
292
|
+
"data-state": isDisabled ? "disabled" : "enabled",
|
|
293
|
+
onClick: composeEventHandlers(onClick, select),
|
|
294
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
295
|
+
if (isActivationKey(event.key)) {
|
|
296
|
+
select(event);
|
|
270
297
|
event.preventDefault();
|
|
271
|
-
if (isDisabled) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
onSelect?.(event);
|
|
275
|
-
context.setOpen(false);
|
|
276
298
|
}
|
|
277
|
-
})
|
|
299
|
+
})
|
|
300
|
+
};
|
|
301
|
+
if (asChild) {
|
|
302
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
303
|
+
}
|
|
304
|
+
return (_jsx("button", { ...props, ref: (node) => {
|
|
305
|
+
setComposedRef(itemRef, ref, node);
|
|
306
|
+
}, type: "button", role: "menuitem", disabled: isDisabled, "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-disabled": itemProps["data-disabled"], "data-state": itemProps["data-state"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: children }));
|
|
278
307
|
}
|
|
279
308
|
function DropdownMenuSeparator({ className, ref, ...props }) {
|
|
280
309
|
return (_jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("liano-dropdown-menu__separator", className) }));
|
|
@@ -285,7 +314,7 @@ function DropdownMenuLabel({ className, ref, ...props }) {
|
|
|
285
314
|
function DropdownMenuShortcut({ className, ref, ...props }) {
|
|
286
315
|
return (_jsx("span", { ...props, ref: ref, className: cn("liano-dropdown-menu__shortcut", className) }));
|
|
287
316
|
}
|
|
288
|
-
function DropdownMenuCheckboxItem({ checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }) {
|
|
317
|
+
function DropdownMenuCheckboxItem({ asChild = false, checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }) {
|
|
289
318
|
const context = useDropdownMenuContext("DropdownMenu.CheckboxItem");
|
|
290
319
|
const itemRef = React.useRef(null);
|
|
291
320
|
const itemId = React.useId();
|
|
@@ -308,24 +337,37 @@ function DropdownMenuCheckboxItem({ checked, children, className, defaultChecked
|
|
|
308
337
|
if (isDisabled) {
|
|
309
338
|
return;
|
|
310
339
|
}
|
|
311
|
-
setCurrentChecked((value) => !value);
|
|
312
340
|
onSelect?.(event);
|
|
313
|
-
|
|
341
|
+
if (!event.defaultPrevented) {
|
|
342
|
+
setCurrentChecked((value) => !value);
|
|
343
|
+
context.setOpen(false);
|
|
344
|
+
}
|
|
314
345
|
};
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
346
|
+
const itemProps = {
|
|
347
|
+
...props,
|
|
348
|
+
ref: (node) => {
|
|
349
|
+
setComposedRef(itemRef, ref, node);
|
|
350
|
+
},
|
|
351
|
+
role: "menuitemcheckbox",
|
|
352
|
+
"aria-checked": currentChecked,
|
|
353
|
+
"aria-disabled": isDisabled ? true : undefined,
|
|
354
|
+
className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__checkbox-item", className),
|
|
355
|
+
"data-checked": currentChecked ? "true" : undefined,
|
|
356
|
+
"data-disabled": isDisabled ? "true" : undefined,
|
|
357
|
+
onClick: composeEventHandlers(onClick, select),
|
|
358
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
359
|
+
if (isActivationKey(event.key)) {
|
|
326
360
|
select(event);
|
|
361
|
+
event.preventDefault();
|
|
327
362
|
}
|
|
328
|
-
})
|
|
363
|
+
})
|
|
364
|
+
};
|
|
365
|
+
if (asChild) {
|
|
366
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
367
|
+
}
|
|
368
|
+
return (_jsxs("button", { ...props, ref: (node) => {
|
|
369
|
+
setComposedRef(itemRef, ref, node);
|
|
370
|
+
}, type: "button", role: "menuitemcheckbox", disabled: isDisabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
|
|
329
371
|
}
|
|
330
372
|
function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value, ...props }) {
|
|
331
373
|
const contextValue = React.useMemo(() => ({
|
|
@@ -334,7 +376,7 @@ function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value
|
|
|
334
376
|
}), [onValueChange, value]);
|
|
335
377
|
return (_jsx(DropdownMenuRadioGroupContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("liano-dropdown-menu__radio-group", className), role: "group", children: children }) }));
|
|
336
378
|
}
|
|
337
|
-
function DropdownMenuRadioItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }) {
|
|
379
|
+
function DropdownMenuRadioItem({ asChild = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }) {
|
|
338
380
|
const context = useDropdownMenuContext("DropdownMenu.RadioItem");
|
|
339
381
|
const radioGroup = React.useContext(DropdownMenuRadioGroupContext);
|
|
340
382
|
const itemRef = React.useRef(null);
|
|
@@ -354,24 +396,37 @@ function DropdownMenuRadioItem({ children, className, disabled, onClick, onKeyDo
|
|
|
354
396
|
if (isDisabled) {
|
|
355
397
|
return;
|
|
356
398
|
}
|
|
357
|
-
radioGroup?.onValueChange?.(value);
|
|
358
399
|
onSelect?.(event);
|
|
359
|
-
|
|
400
|
+
if (!event.defaultPrevented) {
|
|
401
|
+
radioGroup?.onValueChange?.(value);
|
|
402
|
+
context.setOpen(false);
|
|
403
|
+
}
|
|
360
404
|
};
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
405
|
+
const itemProps = {
|
|
406
|
+
...props,
|
|
407
|
+
ref: (node) => {
|
|
408
|
+
setComposedRef(itemRef, ref, node);
|
|
409
|
+
},
|
|
410
|
+
role: "menuitemradio",
|
|
411
|
+
"aria-checked": checked,
|
|
412
|
+
"aria-disabled": isDisabled ? true : undefined,
|
|
413
|
+
className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__radio-item", className),
|
|
414
|
+
"data-checked": checked ? "true" : undefined,
|
|
415
|
+
"data-disabled": isDisabled ? "true" : undefined,
|
|
416
|
+
onClick: composeEventHandlers(onClick, select),
|
|
417
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
418
|
+
if (isActivationKey(event.key)) {
|
|
372
419
|
select(event);
|
|
420
|
+
event.preventDefault();
|
|
373
421
|
}
|
|
374
|
-
})
|
|
422
|
+
})
|
|
423
|
+
};
|
|
424
|
+
if (asChild) {
|
|
425
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
426
|
+
}
|
|
427
|
+
return (_jsxs("button", { ...props, ref: (node) => {
|
|
428
|
+
setComposedRef(itemRef, ref, node);
|
|
429
|
+
}, type: "button", role: "menuitemradio", disabled: isDisabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
|
|
375
430
|
}
|
|
376
431
|
function DropdownMenuSub({ children, className, ref, ...props }) {
|
|
377
432
|
return (_jsx("div", { ...props, ref: ref, className: cn("liano-dropdown-menu__sub", className), children: children }));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { FloatingPlacement } from "../../internal/floating/index.js";
|
|
3
|
+
import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
|
|
3
4
|
import type { PortalProps } from "../../internal/portal/index.js";
|
|
4
5
|
export interface HoverCardProps {
|
|
5
6
|
children?: React.ReactNode;
|
|
@@ -12,9 +13,14 @@ export interface HoverCardProps {
|
|
|
12
13
|
disabled?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export interface HoverCardTriggerProps {
|
|
16
|
+
asChild?: boolean;
|
|
15
17
|
children: React.ReactElement;
|
|
16
18
|
}
|
|
17
19
|
export interface HoverCardContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
placement?: FloatingPlacement;
|
|
21
|
+
side?: FloatingSide;
|
|
22
|
+
align?: FloatingAlign;
|
|
23
|
+
alignOffset?: number;
|
|
18
24
|
sideOffset?: number;
|
|
19
25
|
collisionPadding?: number;
|
|
20
26
|
forceMount?: boolean;
|
|
@@ -22,8 +28,8 @@ export interface HoverCardContentProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
22
28
|
ref?: React.Ref<HTMLDivElement>;
|
|
23
29
|
}
|
|
24
30
|
declare function HoverCardRoot({ children, closeDelay, defaultOpen, disabled, onOpenChange, open: openProp, openDelay, placement }: HoverCardProps): React.JSX.Element;
|
|
25
|
-
declare function HoverCardTrigger({ children }: HoverCardTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
26
|
-
declare function HoverCardContent({ children, className, collisionPadding, container, forceMount, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, ref, sideOffset, style, ...props }: HoverCardContentProps): React.JSX.Element | null;
|
|
31
|
+
declare function HoverCardTrigger({ children, asChild: _asChild }: HoverCardTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
32
|
+
declare function HoverCardContent({ align, alignOffset: _alignOffset, children, className, collisionPadding, container, forceMount, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, placement, ref, side, sideOffset, style, ...props }: HoverCardContentProps): React.JSX.Element | null;
|
|
27
33
|
export declare const HoverCard: typeof HoverCardRoot & {
|
|
28
34
|
Trigger: typeof HoverCardTrigger;
|
|
29
35
|
Content: typeof HoverCardContent;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
|
|
5
5
|
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
6
|
+
import { placementFromSideAlign } from "../../internal/floating/placement-aliases.js";
|
|
6
7
|
import { Portal } from "../../internal/portal/index.js";
|
|
7
8
|
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
8
9
|
import { cn } from "../../utils/cn.js";
|
|
@@ -25,7 +26,7 @@ function composeRefs(...refs) {
|
|
|
25
26
|
if (typeof ref === "function") {
|
|
26
27
|
ref(node);
|
|
27
28
|
}
|
|
28
|
-
else if (ref !== undefined) {
|
|
29
|
+
else if (ref !== undefined && ref !== null) {
|
|
29
30
|
ref.current = node;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -55,7 +56,7 @@ function HoverCardRoot({ children, closeDelay = 300, defaultOpen = false, disabl
|
|
|
55
56
|
const contentElement = React.useRef(null);
|
|
56
57
|
const { floatingRef, floatingStyle, placement: resolvedPlacement, referenceRef, updatePosition } = useFloatingPosition({
|
|
57
58
|
open,
|
|
58
|
-
placement,
|
|
59
|
+
placement: contentPositioning.placement ?? placement,
|
|
59
60
|
offset: contentPositioning.sideOffset,
|
|
60
61
|
collisionPadding: contentPositioning.collisionPadding,
|
|
61
62
|
flip: true,
|
|
@@ -204,7 +205,7 @@ function HoverCardRoot({ children, closeDelay = 300, defaultOpen = false, disabl
|
|
|
204
205
|
]);
|
|
205
206
|
return (_jsx(HoverCardContext.Provider, { value: contextValue, children: children }));
|
|
206
207
|
}
|
|
207
|
-
function HoverCardTrigger({ children }) {
|
|
208
|
+
function HoverCardTrigger({ children, asChild: _asChild = false }) {
|
|
208
209
|
const context = useHoverCardContext("HoverCard.Trigger");
|
|
209
210
|
if (!React.isValidElement(children) || context.disabled) {
|
|
210
211
|
return children;
|
|
@@ -233,18 +234,20 @@ function HoverCardTrigger({ children }) {
|
|
|
233
234
|
onPointerLeave: composeEventHandlers(childProps.onPointerLeave, context.closeWithDelay)
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
|
-
function HoverCardContent({ children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, ref, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
237
|
+
function HoverCardContent({ align, alignOffset: _alignOffset, children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, placement, ref, side, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
237
238
|
const context = useHoverCardContext("HoverCard.Content");
|
|
238
239
|
const contentId = id ?? context.contentId;
|
|
239
240
|
const placementParts = getPlacementParts(context.resolvedPlacement);
|
|
240
241
|
const { setContentPositioning } = context;
|
|
241
242
|
React.useEffect(() => {
|
|
243
|
+
const resolvedPlacement = side === undefined ? placement : placementFromSideAlign(side, align, placement ?? "bottom");
|
|
242
244
|
setContentPositioning({
|
|
245
|
+
...(resolvedPlacement === undefined ? {} : { placement: resolvedPlacement }),
|
|
243
246
|
sideOffset,
|
|
244
247
|
collisionPadding
|
|
245
248
|
});
|
|
246
249
|
return () => setContentPositioning(defaultContentPositioning);
|
|
247
|
-
}, [collisionPadding, setContentPositioning, sideOffset]);
|
|
250
|
+
}, [align, collisionPadding, placement, setContentPositioning, side, sideOffset]);
|
|
248
251
|
if (!context.open && !forceMount) {
|
|
249
252
|
return null;
|
|
250
253
|
}
|
|
@@ -13,7 +13,7 @@ export type { ButtonProps, ButtonSize, ButtonVariant } from "./button/index.js";
|
|
|
13
13
|
export { Card } from "./card/index.js";
|
|
14
14
|
export type { CardDescriptionProps, CardPadding, CardProps, CardSlotProps, CardTitleProps, CardVariant } from "./card/index.js";
|
|
15
15
|
export { Calendar } from "./calendar/index.js";
|
|
16
|
-
export type { CalendarProps } from "./calendar/index.js";
|
|
16
|
+
export type { CalendarClassNames, CalendarMode, CalendarNativeProps, CalendarProps, CalendarSingleProps } from "./calendar/index.js";
|
|
17
17
|
export { Carousel } from "./carousel/index.js";
|
|
18
18
|
export type { CarouselApi, CarouselButtonProps, CarouselOrientation, CarouselPageProps, CarouselProps, CarouselSlideProps, CarouselTrackProps, CarouselViewportProps } from "./carousel/index.js";
|
|
19
19
|
export { Checkbox } from "./checkbox/index.js";
|
|
@@ -29,7 +29,7 @@ export type { DatePickerProps } from "./date-picker/index.js";
|
|
|
29
29
|
export { Dialog } from "./dialog/index.js";
|
|
30
30
|
export type { DialogCloseProps, DialogContentProps, DialogDescriptionProps, DialogFooterProps, DialogHeaderProps, DialogOverlayProps, DialogProps, DialogTitleProps, DialogTriggerProps } from "./dialog/index.js";
|
|
31
31
|
export { DropdownMenu } from "./dropdown-menu/index.js";
|
|
32
|
-
export type { DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuProps, DropdownMenuSeparatorProps, DropdownMenuTriggerProps } from "./dropdown-menu/index.js";
|
|
32
|
+
export type { DropdownMenuCheckboxItemProps, DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuLabelProps, DropdownMenuProps, DropdownMenuRadioGroupProps, DropdownMenuRadioItemProps, DropdownMenuSeparatorProps, DropdownMenuShortcutProps, DropdownMenuSubProps, DropdownMenuTriggerProps } from "./dropdown-menu/index.js";
|
|
33
33
|
export { AlertDialog } from "./alert-dialog/index.js";
|
|
34
34
|
export type { AlertDialogActionProps, AlertDialogCancelProps, AlertDialogContentProps, AlertDialogDescriptionProps, AlertDialogFooterProps, AlertDialogProps, AlertDialogTitleProps, AlertDialogTriggerProps } from "./alert-dialog/index.js";
|
|
35
35
|
export { Sheet } from "./sheet/index.js";
|
|
@@ -37,13 +37,13 @@ export type { SheetCloseProps, SheetContentProps, SheetDescriptionProps, SheetFo
|
|
|
37
37
|
export { ScrollArea } from "./scroll-area/index.js";
|
|
38
38
|
export type { ScrollAreaOrientation, ScrollAreaProps, ScrollAreaType, ScrollBarProps } from "./scroll-area/index.js";
|
|
39
39
|
export { Command, CommandDialog } from "./command/index.js";
|
|
40
|
-
export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps } from "./command/index.js";
|
|
40
|
+
export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps, CommandShortcutProps } from "./command/index.js";
|
|
41
41
|
export { Combobox } from "./combobox/index.js";
|
|
42
42
|
export type { ComboboxOption, ComboboxProps } from "./combobox/index.js";
|
|
43
43
|
export { ContextMenu } from "./context-menu/index.js";
|
|
44
|
-
export type { ContextMenuContentProps, ContextMenuItemProps, ContextMenuProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
44
|
+
export type { ContextMenuCheckboxItemProps, ContextMenuContentProps, ContextMenuItemProps, ContextMenuLabelProps, ContextMenuProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
45
45
|
export { Menubar } from "./menubar/index.js";
|
|
46
|
-
export type { MenubarContentProps, MenubarItemProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
46
|
+
export type { MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
47
47
|
export { EmptyState } from "./empty-state/index.js";
|
|
48
48
|
export type { EmptyStateAlign, EmptyStateProps, EmptyStateSize } from "./empty-state/index.js";
|
|
49
49
|
export { ErrorBoundary, ErrorFallback } from "./error-boundary/index.js";
|
|
@@ -98,8 +98,8 @@ export { TabsWithSidebar } from "./tabs-with-sidebar/index.js";
|
|
|
98
98
|
export type { TabsWithSidebarPanelProps, TabsWithSidebarProps, TabsWithSidebarSidebarProps, TabsWithSidebarWidth } from "./tabs-with-sidebar/index.js";
|
|
99
99
|
export { Textarea } from "./textarea/index.js";
|
|
100
100
|
export type { TextareaProps, TextareaSize } from "./textarea/index.js";
|
|
101
|
-
export { createToastController, Toast, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
102
|
-
export type { ToastActionProps, ToastCloseProps, ToastController, ToastInput, ToastOptions, ToastPlacement, ToastProviderProps, ToastProps, ToastTextProps, ToastTone, ToastViewportProps } from "./toast/index.js";
|
|
101
|
+
export { createToastController, toast, Toast, Toaster, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
102
|
+
export type { ToasterPosition, ToasterProps, ToastActionInput, ToastActionProps, ToastCloseProps, ToastController, ToastInput, ToastOptions, ToastPlacement, ToastProviderProps, ToastProps, ToastTextProps, ToastTone, ToastViewportProps } from "./toast/index.js";
|
|
103
103
|
export { Tooltip } from "./tooltip/index.js";
|
|
104
104
|
export type { TooltipProps } from "./tooltip/index.js";
|
|
105
105
|
export { Toggle } from "./toggle/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export { Table } from "./table/index.js";
|
|
|
48
48
|
export { Tabs } from "./tabs/index.js";
|
|
49
49
|
export { TabsWithSidebar } from "./tabs-with-sidebar/index.js";
|
|
50
50
|
export { Textarea } from "./textarea/index.js";
|
|
51
|
-
export { createToastController, Toast, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
51
|
+
export { createToastController, toast, Toast, Toaster, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
52
52
|
export { Tooltip } from "./tooltip/index.js";
|
|
53
53
|
export { Toggle } from "./toggle/index.js";
|
|
54
54
|
export { ToggleGroup } from "./toggle-group/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
|
|
2
3
|
export interface MenubarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
defaultValue?: string;
|
|
4
5
|
onValueChange?: (value: string | undefined) => void;
|
|
@@ -10,14 +11,28 @@ export interface MenubarMenuProps {
|
|
|
10
11
|
value: string;
|
|
11
12
|
}
|
|
12
13
|
export interface MenubarTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
-
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
14
16
|
}
|
|
15
17
|
export interface MenubarContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
side?: FloatingSide;
|
|
19
|
+
align?: FloatingAlign;
|
|
20
|
+
alignOffset?: number;
|
|
21
|
+
sideOffset?: number;
|
|
16
22
|
ref?: React.Ref<HTMLDivElement>;
|
|
17
23
|
}
|
|
18
24
|
export interface MenubarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
25
|
+
asChild?: boolean;
|
|
19
26
|
onSelect?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
20
|
-
ref?: React.Ref<HTMLButtonElement>;
|
|
27
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
28
|
+
}
|
|
29
|
+
export interface MenubarCheckboxItemProps extends MenubarItemProps {
|
|
30
|
+
checked?: boolean;
|
|
31
|
+
defaultChecked?: boolean;
|
|
32
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface MenubarRadioItemProps extends MenubarItemProps {
|
|
35
|
+
checked?: boolean;
|
|
21
36
|
}
|
|
22
37
|
export interface MenubarSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
38
|
ref?: React.Ref<HTMLDivElement>;
|
|
@@ -30,17 +45,21 @@ export interface MenubarShortcutProps extends React.HTMLAttributes<HTMLSpanEleme
|
|
|
30
45
|
}
|
|
31
46
|
declare function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChange, ref, value, ...props }: MenubarProps): React.JSX.Element;
|
|
32
47
|
declare function MenubarMenu({ children, value }: MenubarMenuProps): React.JSX.Element;
|
|
33
|
-
declare function MenubarTrigger({ children, className, disabled, onClick, onKeyDown, ref, type, ...props }: MenubarTriggerProps): React.JSX.Element;
|
|
34
|
-
declare function MenubarContent({ children, className, onKeyDown, ref, ...props }: MenubarContentProps): React.JSX.Element | null;
|
|
35
|
-
declare function MenubarItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarItemProps): React.JSX.Element;
|
|
48
|
+
declare function MenubarTrigger({ asChild, children, className, disabled, onClick, onKeyDown, ref, type, ...props }: MenubarTriggerProps): React.JSX.Element;
|
|
49
|
+
declare function MenubarContent({ align, alignOffset: _alignOffset, children, className, onKeyDown, ref, side, sideOffset: _sideOffset, ...props }: MenubarContentProps): React.JSX.Element | null;
|
|
50
|
+
declare function MenubarItem({ asChild, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarItemProps): React.JSX.Element;
|
|
51
|
+
declare function MenubarCheckboxItem({ asChild, checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarCheckboxItemProps): React.JSX.Element;
|
|
52
|
+
declare function MenubarRadioItem({ asChild, checked, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarRadioItemProps): React.JSX.Element;
|
|
36
53
|
declare function MenubarSeparator({ className, ref, ...props }: MenubarSeparatorProps): React.JSX.Element;
|
|
37
54
|
declare function MenubarLabel({ className, ref, ...props }: MenubarLabelProps): React.JSX.Element;
|
|
38
55
|
declare function MenubarShortcut({ className, ref, ...props }: MenubarShortcutProps): React.JSX.Element;
|
|
39
56
|
type MenubarComponent = typeof MenubarRoot & {
|
|
57
|
+
CheckboxItem: typeof MenubarCheckboxItem;
|
|
40
58
|
Content: typeof MenubarContent;
|
|
41
59
|
Item: typeof MenubarItem;
|
|
42
60
|
Label: typeof MenubarLabel;
|
|
43
61
|
Menu: typeof MenubarMenu;
|
|
62
|
+
RadioItem: typeof MenubarRadioItem;
|
|
44
63
|
Separator: typeof MenubarSeparator;
|
|
45
64
|
Shortcut: typeof MenubarShortcut;
|
|
46
65
|
Trigger: typeof MenubarTrigger;
|