@aaas-pro/library 0.0.0-stage → 0.1.0
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/README.md +107 -2
- package/dist/components/address-picker.d.ts +18 -0
- package/dist/components/address-picker.js +46 -0
- package/dist/components/card-date-filter.d.ts +12 -0
- package/dist/components/card-date-filter.js +95 -0
- package/dist/components/date-time-picker.d.ts +12 -0
- package/dist/components/date-time-picker.js +96 -0
- package/dist/components/detail-dialog.d.ts +48 -0
- package/dist/components/detail-dialog.js +97 -0
- package/dist/components/document-links.d.ts +13 -0
- package/dist/components/document-links.js +19 -0
- package/dist/components/draft-row-actions.d.ts +14 -0
- package/dist/components/draft-row-actions.js +70 -0
- package/dist/components/error-boundary.d.ts +14 -0
- package/dist/components/error-boundary.js +35 -0
- package/dist/components/glow-card.d.ts +13 -0
- package/dist/components/glow-card.js +48 -0
- package/dist/components/org-picker.d.ts +17 -0
- package/dist/components/org-picker.js +56 -0
- package/dist/components/overflow-row-actions.d.ts +29 -0
- package/dist/components/overflow-row-actions.js +135 -0
- package/dist/components/page-header.d.ts +21 -0
- package/dist/components/page-header.js +21 -0
- package/dist/components/permission-button.d.ts +4 -0
- package/dist/components/permission-button.js +17 -0
- package/dist/components/permission-context.d.ts +12 -0
- package/dist/components/permission-context.js +17 -0
- package/dist/components/person-picker.d.ts +20 -0
- package/dist/components/person-picker.js +38 -0
- package/dist/components/process-flow-bar.d.ts +15 -0
- package/dist/components/process-flow-bar.js +19 -0
- package/dist/components/product-picker.d.ts +19 -0
- package/dist/components/product-picker.js +155 -0
- package/dist/components/ref-doc-picker.d.ts +24 -0
- package/dist/components/ref-doc-picker.js +139 -0
- package/dist/components/scroll-to-top.d.ts +1 -0
- package/dist/components/scroll-to-top.js +20 -0
- package/dist/components/state-view.d.ts +26 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/theme-switcher.d.ts +27 -0
- package/dist/components/theme-switcher.js +77 -0
- package/dist/components/time-filter.d.ts +7 -0
- package/dist/components/time-filter.js +65 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +64 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.js +160 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +66 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +10 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/avatar.js +53 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +44 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb.js +103 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.js +76 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +93 -0
- package/dist/components/ui/calendar.d.ts +73 -0
- package/dist/components/ui/calendar.js +103 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.js +90 -0
- package/dist/components/ui/carousel.d.ts +14 -0
- package/dist/components/ui/carousel.js +200 -0
- package/dist/components/ui/chart.d.ts +43 -0
- package/dist/components/ui/chart.js +252 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +34 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/command.js +170 -0
- package/dist/components/ui/context-menu.d.ts +26 -0
- package/dist/components/ui/context-menu.js +237 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +139 -0
- package/dist/components/ui/drawer.d.ts +13 -0
- package/dist/components/ui/drawer.js +129 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.js +245 -0
- package/dist/components/ui/empty.d.ts +14 -0
- package/dist/components/ui/empty.js +102 -0
- package/dist/components/ui/field.d.ts +27 -0
- package/dist/components/ui/field.js +229 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/form.js +118 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +39 -0
- package/dist/components/ui/input-group.d.ts +22 -0
- package/dist/components/ui/input-group.js +156 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +66 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +21 -0
- package/dist/components/ui/item.d.ts +29 -0
- package/dist/components/ui/item.js +187 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +31 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +22 -0
- package/dist/components/ui/menubar.d.ts +26 -0
- package/dist/components/ui/menubar.js +252 -0
- package/dist/components/ui/navigation-menu.d.ts +17 -0
- package/dist/components/ui/navigation-menu.js +170 -0
- package/dist/components/ui/pagination.d.ts +13 -0
- package/dist/components/ui/pagination.js +118 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.js +47 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/progress.js +34 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +45 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +49 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +60 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +215 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +26 -0
- package/dist/components/ui/sheet.d.ts +13 -0
- package/dist/components/ui/sheet.js +127 -0
- package/dist/components/ui/sidebar.d.ts +72 -0
- package/dist/components/ui/sidebar.js +656 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +63 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +34 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +17 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +31 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +114 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +67 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +9 -0
- package/dist/components/ui/toggle-group.js +68 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +43 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +56 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +115 -0
- package/dist/icons/paths.d.ts +556 -0
- package/dist/icons/paths.js +231 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +399 -0
- package/dist/internal/selection-base.d.ts +37 -0
- package/dist/internal/selection-base.js +40 -0
- package/dist/lib/class-names.d.ts +6 -0
- package/dist/lib/class-names.js +159 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/variants.d.ts +21 -0
- package/dist/lib/variants.js +21 -0
- package/dist/primitives/accordion.d.ts +29 -0
- package/dist/primitives/accordion.js +49 -0
- package/dist/primitives/alert-dialog.d.ts +10 -0
- package/dist/primitives/alert-dialog.js +22 -0
- package/dist/primitives/aspect-ratio.d.ts +4 -0
- package/dist/primitives/aspect-ratio.js +7 -0
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +45 -0
- package/dist/primitives/carousel.d.ts +22 -0
- package/dist/primitives/carousel.js +78 -0
- package/dist/primitives/chart.d.ts +71 -0
- package/dist/primitives/chart.js +125 -0
- package/dist/primitives/checkbox.d.ts +13 -0
- package/dist/primitives/checkbox.js +24 -0
- package/dist/primitives/collapsible.d.ts +14 -0
- package/dist/primitives/collapsible.js +29 -0
- package/dist/primitives/command.d.ts +43 -0
- package/dist/primitives/command.js +98 -0
- package/dist/primitives/context-menu.d.ts +24 -0
- package/dist/primitives/context-menu.js +19 -0
- package/dist/primitives/core.d.ts +25 -0
- package/dist/primitives/core.js +89 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +15 -0
- package/dist/primitives/drawer.d.ts +30 -0
- package/dist/primitives/drawer.js +39 -0
- package/dist/primitives/dropdown-menu.d.ts +24 -0
- package/dist/primitives/dropdown-menu.js +19 -0
- package/dist/primitives/form.d.ts +154 -0
- package/dist/primitives/form.js +139 -0
- package/dist/primitives/hover-card.d.ts +4 -0
- package/dist/primitives/hover-card.js +8 -0
- package/dist/primitives/input-otp.d.ts +21 -0
- package/dist/primitives/input-otp.js +78 -0
- package/dist/primitives/label.d.ts +2 -0
- package/dist/primitives/label.js +7 -0
- package/dist/primitives/layer.d.ts +84 -0
- package/dist/primitives/layer.js +300 -0
- package/dist/primitives/menu.d.ts +56 -0
- package/dist/primitives/menu.js +126 -0
- package/dist/primitives/menubar.d.ts +91 -0
- package/dist/primitives/menubar.js +44 -0
- package/dist/primitives/navigation-menu.d.ts +32 -0
- package/dist/primitives/navigation-menu.js +121 -0
- package/dist/primitives/popover.d.ts +4 -0
- package/dist/primitives/popover.js +12 -0
- package/dist/primitives/progress.d.ts +7 -0
- package/dist/primitives/progress.js +13 -0
- package/dist/primitives/radio-group.d.ts +18 -0
- package/dist/primitives/radio-group.js +36 -0
- package/dist/primitives/resizable.d.ts +19 -0
- package/dist/primitives/resizable.js +91 -0
- package/dist/primitives/scroll-area.d.ts +12 -0
- package/dist/primitives/scroll-area.js +26 -0
- package/dist/primitives/select.d.ts +42 -0
- package/dist/primitives/select.js +167 -0
- package/dist/primitives/separator.d.ts +5 -0
- package/dist/primitives/separator.js +7 -0
- package/dist/primitives/slider.d.ts +25 -0
- package/dist/primitives/slider.js +98 -0
- package/dist/primitives/slot.d.ts +1 -0
- package/dist/primitives/slot.js +4 -0
- package/dist/primitives/switch.d.ts +11 -0
- package/dist/primitives/switch.js +22 -0
- package/dist/primitives/tabs.d.ts +23 -0
- package/dist/primitives/tabs.js +38 -0
- package/dist/primitives/toast.d.ts +55 -0
- package/dist/primitives/toast.js +86 -0
- package/dist/primitives/toggle-group.d.ts +24 -0
- package/dist/primitives/toggle-group.js +33 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +13 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +10 -0
- package/dist/style-entry.d.ts +1 -0
- package/dist/style-entry.js +1 -0
- package/dist/styles.css +7016 -0
- package/dist/styles.js +1 -0
- package/dist/theme/index.d.ts +110 -0
- package/dist/theme/index.js +199 -0
- package/licenses/Lucide.txt +15 -0
- package/package.json +67 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type LayerContentProps, type ModalRootProps } from './layer';
|
|
3
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
4
|
+
export declare function createMenu(contextMenu?: boolean): {
|
|
5
|
+
Root: (props: ModalRootProps) => React.ReactElement;
|
|
6
|
+
Sub: (props: ModalRootProps) => React.ReactElement;
|
|
7
|
+
Trigger: ({ onContextMenu, ref, disabled, ...props }: ButtonProps) => React.JSX.Element;
|
|
8
|
+
Content: ({ onKeyDown, loop, ...props }: LayerContentProps & {
|
|
9
|
+
loop?: boolean;
|
|
10
|
+
}) => React.JSX.Element;
|
|
11
|
+
Item: ({ onSelect, textValue: _text, onClick, onPointerMove, ...props }: Omit<ButtonProps, "onSelect"> & {
|
|
12
|
+
onSelect?: (event: Event) => void;
|
|
13
|
+
textValue?: string;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
CheckboxItem: ({ checked, defaultChecked, onCheckedChange, children, onSelect, ...props }: (Omit<ButtonProps, "onSelect"> & {
|
|
16
|
+
onSelect?: (event: Event) => void;
|
|
17
|
+
textValue?: string;
|
|
18
|
+
}) & {
|
|
19
|
+
checked?: boolean | "indeterminate";
|
|
20
|
+
defaultChecked?: boolean;
|
|
21
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
22
|
+
}) => React.JSX.Element;
|
|
23
|
+
RadioGroup: ({ value, defaultValue, onValueChange, ...props }: Omit<DivProps, "defaultValue"> & {
|
|
24
|
+
value?: string;
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
onValueChange?: (value: string) => void;
|
|
27
|
+
}) => React.JSX.Element;
|
|
28
|
+
RadioItem: ({ value, children, onSelect, ...props }: (Omit<ButtonProps, "onSelect"> & {
|
|
29
|
+
onSelect?: (event: Event) => void;
|
|
30
|
+
textValue?: string;
|
|
31
|
+
}) & {
|
|
32
|
+
value: string;
|
|
33
|
+
}) => React.JSX.Element;
|
|
34
|
+
ItemIndicator: ({ forceMount, ...props }: React.ComponentProps<"span"> & {
|
|
35
|
+
forceMount?: true;
|
|
36
|
+
}) => React.JSX.Element | null;
|
|
37
|
+
Group: (props: DivProps) => React.JSX.Element;
|
|
38
|
+
Label: (props: DivProps) => React.JSX.Element;
|
|
39
|
+
Separator: (props: DivProps) => React.JSX.Element;
|
|
40
|
+
SubTrigger: ({ onClick, onPointerEnter, onKeyDown, ref, ...props }: ButtonProps) => React.JSX.Element;
|
|
41
|
+
SubContent: ({ onKeyDown, ...props }: LayerContentProps) => React.JSX.Element;
|
|
42
|
+
Provider: ({ children, delayDuration }: {
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
delayDuration?: number;
|
|
45
|
+
}) => React.JSX.Element;
|
|
46
|
+
Anchor: ({ ref, ...props }: DivProps) => React.JSX.Element;
|
|
47
|
+
Close: ({ onClick, ...props }: ButtonProps) => React.JSX.Element;
|
|
48
|
+
Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null;
|
|
49
|
+
Overlay: ({ forceMount, ...props }: DivProps & {
|
|
50
|
+
forceMount?: true;
|
|
51
|
+
}) => React.JSX.Element | null;
|
|
52
|
+
Title: (props: React.ComponentProps<"h2">) => React.JSX.Element;
|
|
53
|
+
Description: (props: React.ComponentProps<"p">) => React.JSX.Element;
|
|
54
|
+
Arrow: (props: React.ComponentProps<"span">) => React.JSX.Element;
|
|
55
|
+
useLayer: () => import("./layer").LayerState;
|
|
56
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { createLayer } from "./layer.js";
|
|
4
|
+
import { useMergedRef, ButtonPart, DivPart, useControllable, selectionEvent, moveFocus } from "./core.js";
|
|
5
|
+
import { useThemePortalContainer } from "../theme/index.js";
|
|
6
|
+
function createMenu(contextMenu = false) {
|
|
7
|
+
const family = createLayer({ role: "menu", contextMenu });
|
|
8
|
+
const Selected = React.createContext(false);
|
|
9
|
+
const Radio = React.createContext({ value: "", set: (_value) => {
|
|
10
|
+
} });
|
|
11
|
+
function closeAll(state) {
|
|
12
|
+
state.setOpen(false);
|
|
13
|
+
if (state.sub && state.parent)
|
|
14
|
+
closeAll(state.parent);
|
|
15
|
+
}
|
|
16
|
+
function Trigger({ onContextMenu, ref, disabled, ...props }) {
|
|
17
|
+
const state = family.useLayer();
|
|
18
|
+
const merged = useMergedRef(ref, state.trigger);
|
|
19
|
+
return contextMenu ? /* @__PURE__ */ jsx(DivPart, { ...props, ref: merged, tabIndex: disabled ? -1 : props.tabIndex ?? 0, "aria-disabled": disabled || void 0, "aria-haspopup": "menu", "aria-expanded": state.open, "data-state": state.open ? "open" : "closed", onContextMenu: (event) => {
|
|
20
|
+
onContextMenu?.(event);
|
|
21
|
+
if (!disabled && !event.defaultPrevented) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
state.point.current = { x: event.clientX, y: event.clientY };
|
|
24
|
+
state.setOpen(true);
|
|
25
|
+
}
|
|
26
|
+
}, onKeyDown: (event) => {
|
|
27
|
+
props.onKeyDown?.(event);
|
|
28
|
+
if (!event.defaultPrevented && !disabled && (event.key === "ContextMenu" || event.shiftKey && event.key === "F10")) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
state.point.current = null;
|
|
31
|
+
state.setOpen(true);
|
|
32
|
+
}
|
|
33
|
+
} }) : /* @__PURE__ */ jsx(family.Trigger, { ...props, ref: merged, disabled });
|
|
34
|
+
}
|
|
35
|
+
function Content({ onKeyDown, loop = true, ...props }) {
|
|
36
|
+
return /* @__PURE__ */ jsx(family.Content, { ...props, onKeyDown: (event) => {
|
|
37
|
+
onKeyDown?.(event);
|
|
38
|
+
if (event.defaultPrevented)
|
|
39
|
+
return;
|
|
40
|
+
moveFocus(event, '[role^="menuitem"]', { vertical: true, loop });
|
|
41
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && event.key !== " ") {
|
|
42
|
+
const items = [...event.currentTarget.querySelectorAll('[role^="menuitem"]')].filter((n) => !n.matches(":disabled,[aria-disabled=true]"));
|
|
43
|
+
const from = items.indexOf(document.activeElement);
|
|
44
|
+
const ordered = [...items.slice(from + 1), ...items.slice(0, from + 1)];
|
|
45
|
+
ordered.find((n) => n.textContent?.trim().toLocaleLowerCase().startsWith(event.key.toLocaleLowerCase()))?.focus();
|
|
46
|
+
}
|
|
47
|
+
} });
|
|
48
|
+
}
|
|
49
|
+
function Item({ onSelect, textValue: _text, onClick, onPointerMove, ...props }) {
|
|
50
|
+
const state = family.useLayer();
|
|
51
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, role: props.role ?? "menuitem", tabIndex: -1, "aria-disabled": props.disabled || void 0, "data-disabled": props.disabled ? "" : void 0, onPointerMove: (event) => {
|
|
52
|
+
onPointerMove?.(event);
|
|
53
|
+
if (!props.disabled && event.pointerType !== "touch")
|
|
54
|
+
event.currentTarget.focus();
|
|
55
|
+
}, onClick: (event) => {
|
|
56
|
+
onClick?.(event);
|
|
57
|
+
if (!event.defaultPrevented && !selectionEvent(onSelect))
|
|
58
|
+
closeAll(state);
|
|
59
|
+
} });
|
|
60
|
+
}
|
|
61
|
+
function CheckboxItem({ checked, defaultChecked = false, onCheckedChange, children, onSelect, ...props }) {
|
|
62
|
+
const [current, set] = useControllable(checked, defaultChecked, (next) => onCheckedChange?.(next === true));
|
|
63
|
+
return /* @__PURE__ */ jsx(Selected.Provider, { value: current !== false, children: /* @__PURE__ */ jsx(Item, { ...props, role: "menuitemcheckbox", "aria-checked": current === "indeterminate" ? "mixed" : current, "data-state": current ? "checked" : "unchecked", onSelect: (event) => {
|
|
64
|
+
onSelect?.(event);
|
|
65
|
+
set(current !== true);
|
|
66
|
+
}, children }) });
|
|
67
|
+
}
|
|
68
|
+
function RadioGroup({ value, defaultValue = "", onValueChange, ...props }) {
|
|
69
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
70
|
+
return /* @__PURE__ */ jsx(Radio.Provider, { value: { value: current, set }, children: /* @__PURE__ */ jsx(DivPart, { ...props, role: "group" }) });
|
|
71
|
+
}
|
|
72
|
+
function RadioItem({ value, children, onSelect, ...props }) {
|
|
73
|
+
const state = React.useContext(Radio), checked = state.value === value;
|
|
74
|
+
return /* @__PURE__ */ jsx(Selected.Provider, { value: checked, children: /* @__PURE__ */ jsx(Item, { ...props, role: "menuitemradio", "aria-checked": checked, "data-state": checked ? "checked" : "unchecked", onSelect: (event) => {
|
|
75
|
+
onSelect?.(event);
|
|
76
|
+
state.set(value);
|
|
77
|
+
}, children }) });
|
|
78
|
+
}
|
|
79
|
+
function ItemIndicator({ forceMount, ...props }) {
|
|
80
|
+
const selected = React.useContext(Selected);
|
|
81
|
+
return selected || forceMount ? /* @__PURE__ */ jsx("span", { ...props, hidden: !selected }) : null;
|
|
82
|
+
}
|
|
83
|
+
function Group(props) {
|
|
84
|
+
return /* @__PURE__ */ jsx(DivPart, { ...props, role: "group" });
|
|
85
|
+
}
|
|
86
|
+
function Label(props) {
|
|
87
|
+
return /* @__PURE__ */ jsx(DivPart, { ...props });
|
|
88
|
+
}
|
|
89
|
+
function Separator(props) {
|
|
90
|
+
return /* @__PURE__ */ jsx(DivPart, { ...props, role: "separator" });
|
|
91
|
+
}
|
|
92
|
+
function SubTrigger({ onClick, onPointerEnter, onKeyDown, ref, ...props }) {
|
|
93
|
+
const state = family.useLayer();
|
|
94
|
+
const merged = useMergedRef(ref, state.trigger);
|
|
95
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, ref: merged, role: "menuitem", tabIndex: -1, "aria-haspopup": "menu", "aria-expanded": state.open, "data-state": state.open ? "open" : "closed", onClick: (event) => {
|
|
96
|
+
onClick?.(event);
|
|
97
|
+
if (!event.defaultPrevented)
|
|
98
|
+
state.setOpen(!state.open);
|
|
99
|
+
}, onPointerEnter: (event) => {
|
|
100
|
+
onPointerEnter?.(event);
|
|
101
|
+
if (!props.disabled)
|
|
102
|
+
state.setOpen(true);
|
|
103
|
+
}, onKeyDown: (event) => {
|
|
104
|
+
onKeyDown?.(event);
|
|
105
|
+
if (!event.defaultPrevented && event.key === "ArrowRight") {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
state.setOpen(true);
|
|
108
|
+
}
|
|
109
|
+
} });
|
|
110
|
+
}
|
|
111
|
+
function SubContent({ onKeyDown, ...props }) {
|
|
112
|
+
const state = family.useLayer();
|
|
113
|
+
const container = useThemePortalContainer();
|
|
114
|
+
return /* @__PURE__ */ jsx(family.Portal, { container, children: /* @__PURE__ */ jsx(Content, { ...props, side: "right", align: "start", onKeyDown: (event) => {
|
|
115
|
+
onKeyDown?.(event);
|
|
116
|
+
if (!event.defaultPrevented && event.key === "ArrowLeft") {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
state.setOpen(false);
|
|
119
|
+
}
|
|
120
|
+
} }) });
|
|
121
|
+
}
|
|
122
|
+
return { ...family, Root: family.Root, Sub: family.Sub, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, ItemIndicator, Group, Label, Separator, SubTrigger, SubContent };
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
createMenu
|
|
126
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type DivProps } from './core';
|
|
3
|
+
import type { ModalRootProps } from './layer';
|
|
4
|
+
declare const menu: {
|
|
5
|
+
Root: (props: ModalRootProps) => React.ReactElement;
|
|
6
|
+
Sub: (props: ModalRootProps) => React.ReactElement;
|
|
7
|
+
Trigger: ({ onContextMenu, ref, disabled, ...props }: import("./core").ButtonProps) => React.JSX.Element;
|
|
8
|
+
Content: ({ onKeyDown, loop, ...props }: import("./layer").LayerContentProps & {
|
|
9
|
+
loop?: boolean;
|
|
10
|
+
}) => React.JSX.Element;
|
|
11
|
+
Item: ({ onSelect, textValue: _text, onClick, onPointerMove, ...props }: Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
12
|
+
onSelect?: (event: Event) => void;
|
|
13
|
+
textValue?: string;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
CheckboxItem: ({ checked, defaultChecked, onCheckedChange, children, onSelect, ...props }: (Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
16
|
+
onSelect?: (event: Event) => void;
|
|
17
|
+
textValue?: string;
|
|
18
|
+
}) & {
|
|
19
|
+
checked?: boolean | "indeterminate";
|
|
20
|
+
defaultChecked?: boolean;
|
|
21
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
22
|
+
}) => React.JSX.Element;
|
|
23
|
+
RadioGroup: ({ value, defaultValue, onValueChange, ...props }: Omit<DivProps, "defaultValue"> & {
|
|
24
|
+
value?: string;
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
onValueChange?: (value: string) => void;
|
|
27
|
+
}) => React.JSX.Element;
|
|
28
|
+
RadioItem: ({ value, children, onSelect, ...props }: (Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
29
|
+
onSelect?: (event: Event) => void;
|
|
30
|
+
textValue?: string;
|
|
31
|
+
}) & {
|
|
32
|
+
value: string;
|
|
33
|
+
}) => React.JSX.Element;
|
|
34
|
+
ItemIndicator: ({ forceMount, ...props }: React.ComponentProps<"span"> & {
|
|
35
|
+
forceMount?: true;
|
|
36
|
+
}) => React.JSX.Element | null;
|
|
37
|
+
Group: (props: DivProps) => React.JSX.Element;
|
|
38
|
+
Label: (props: DivProps) => React.JSX.Element;
|
|
39
|
+
Separator: (props: DivProps) => React.JSX.Element;
|
|
40
|
+
SubTrigger: ({ onClick, onPointerEnter, onKeyDown, ref, ...props }: import("./core").ButtonProps) => React.JSX.Element;
|
|
41
|
+
SubContent: ({ onKeyDown, ...props }: import("./layer").LayerContentProps) => React.JSX.Element;
|
|
42
|
+
Provider: ({ children, delayDuration }: {
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
delayDuration?: number;
|
|
45
|
+
}) => React.JSX.Element;
|
|
46
|
+
Anchor: ({ ref, ...props }: DivProps) => React.JSX.Element;
|
|
47
|
+
Close: ({ onClick, ...props }: import("./core").ButtonProps) => React.JSX.Element;
|
|
48
|
+
Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null;
|
|
49
|
+
Overlay: ({ forceMount, ...props }: DivProps & {
|
|
50
|
+
forceMount?: true;
|
|
51
|
+
}) => React.JSX.Element | null;
|
|
52
|
+
Title: (props: React.ComponentProps<"h2">) => React.JSX.Element;
|
|
53
|
+
Description: (props: React.ComponentProps<"p">) => React.JSX.Element;
|
|
54
|
+
Arrow: (props: React.ComponentProps<"span">) => React.JSX.Element;
|
|
55
|
+
useLayer: () => import("./layer").LayerState;
|
|
56
|
+
};
|
|
57
|
+
export declare function Root({ value, defaultValue, onValueChange, onKeyDown, loop, ...props }: Omit<DivProps, 'defaultValue'> & {
|
|
58
|
+
value?: string;
|
|
59
|
+
defaultValue?: string;
|
|
60
|
+
onValueChange?: (value: string) => void;
|
|
61
|
+
loop?: boolean;
|
|
62
|
+
}): React.JSX.Element;
|
|
63
|
+
export declare function Menu({ value, open, defaultOpen, onOpenChange, ...props }: ModalRootProps & {
|
|
64
|
+
value?: string;
|
|
65
|
+
}): React.JSX.Element;
|
|
66
|
+
export declare function Trigger(props: React.ComponentProps<typeof menu.Trigger>): React.JSX.Element;
|
|
67
|
+
export declare const Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null, Content: ({ onKeyDown, loop, ...props }: import("./layer").LayerContentProps & {
|
|
68
|
+
loop?: boolean;
|
|
69
|
+
}) => React.JSX.Element, Group: (props: DivProps) => React.JSX.Element, Label: (props: DivProps) => React.JSX.Element, Item: ({ onSelect, textValue: _text, onClick, onPointerMove, ...props }: Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
70
|
+
onSelect?: (event: Event) => void;
|
|
71
|
+
textValue?: string;
|
|
72
|
+
}) => React.JSX.Element, CheckboxItem: ({ checked, defaultChecked, onCheckedChange, children, onSelect, ...props }: (Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
73
|
+
onSelect?: (event: Event) => void;
|
|
74
|
+
textValue?: string;
|
|
75
|
+
}) & {
|
|
76
|
+
checked?: boolean | "indeterminate";
|
|
77
|
+
defaultChecked?: boolean;
|
|
78
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
79
|
+
}) => React.JSX.Element, RadioGroup: ({ value, defaultValue, onValueChange, ...props }: Omit<DivProps, "defaultValue"> & {
|
|
80
|
+
value?: string;
|
|
81
|
+
defaultValue?: string;
|
|
82
|
+
onValueChange?: (value: string) => void;
|
|
83
|
+
}) => React.JSX.Element, RadioItem: ({ value, children, onSelect, ...props }: (Omit<import("./core").ButtonProps, "onSelect"> & {
|
|
84
|
+
onSelect?: (event: Event) => void;
|
|
85
|
+
textValue?: string;
|
|
86
|
+
}) & {
|
|
87
|
+
value: string;
|
|
88
|
+
}) => React.JSX.Element, Separator: (props: DivProps) => React.JSX.Element, ItemIndicator: ({ forceMount, ...props }: React.ComponentProps<"span"> & {
|
|
89
|
+
forceMount?: true;
|
|
90
|
+
}) => React.JSX.Element | null, Sub: (props: ModalRootProps) => React.ReactElement, SubTrigger: ({ onClick, onPointerEnter, onKeyDown, ref, ...props }: import("./core").ButtonProps) => React.JSX.Element, SubContent: ({ onKeyDown, ...props }: import("./layer").LayerContentProps) => React.JSX.Element;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { createMenu } from "./menu.js";
|
|
4
|
+
import { useControllable, DivPart, moveFocus } from "./core.js";
|
|
5
|
+
const menu = createMenu();
|
|
6
|
+
const Context = React.createContext({ value: "", set: (_value) => {
|
|
7
|
+
} });
|
|
8
|
+
function Root({ value, defaultValue = "", onValueChange, onKeyDown, loop = true, ...props }) {
|
|
9
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
10
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { value: current, set }, children: /* @__PURE__ */ jsx(DivPart, { ...props, role: "menubar", onKeyDown: (event) => {
|
|
11
|
+
onKeyDown?.(event);
|
|
12
|
+
if (!event.defaultPrevented)
|
|
13
|
+
moveFocus(event, "[data-menubar-trigger]", { select: !!current, loop });
|
|
14
|
+
} }) });
|
|
15
|
+
}
|
|
16
|
+
function Menu({ value, open, defaultOpen, onOpenChange, ...props }) {
|
|
17
|
+
const state = React.useContext(Context), generated = React.useId(), key = value ?? generated;
|
|
18
|
+
return /* @__PURE__ */ jsx(menu.Root, { ...props, open: open ?? state.value === key, defaultOpen, onOpenChange: (next) => {
|
|
19
|
+
state.set(next ? key : "");
|
|
20
|
+
onOpenChange?.(next);
|
|
21
|
+
} });
|
|
22
|
+
}
|
|
23
|
+
function Trigger(props) {
|
|
24
|
+
return /* @__PURE__ */ jsx(menu.Trigger, { ...props, role: "menuitem", "data-menubar-trigger": "" });
|
|
25
|
+
}
|
|
26
|
+
const { Portal, Content, Group, Label, Item, CheckboxItem, RadioGroup, RadioItem, Separator, ItemIndicator, Sub, SubTrigger, SubContent } = menu;
|
|
27
|
+
export {
|
|
28
|
+
CheckboxItem,
|
|
29
|
+
Content,
|
|
30
|
+
Group,
|
|
31
|
+
Item,
|
|
32
|
+
ItemIndicator,
|
|
33
|
+
Label,
|
|
34
|
+
Menu,
|
|
35
|
+
Portal,
|
|
36
|
+
RadioGroup,
|
|
37
|
+
RadioItem,
|
|
38
|
+
Root,
|
|
39
|
+
Separator,
|
|
40
|
+
Sub,
|
|
41
|
+
SubContent,
|
|
42
|
+
SubTrigger,
|
|
43
|
+
Trigger
|
|
44
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
3
|
+
import type { OutsideEvent } from './layer';
|
|
4
|
+
interface RootProps extends Omit<React.ComponentProps<'nav'>, 'defaultValue'> {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
orientation?: 'horizontal' | 'vertical';
|
|
9
|
+
}
|
|
10
|
+
export declare function Root({ value, defaultValue, onValueChange, orientation, onKeyDown, ...props }: RootProps): React.JSX.Element;
|
|
11
|
+
export declare function List(props: React.ComponentProps<'ul'>): React.JSX.Element;
|
|
12
|
+
export declare function Item({ value, ...props }: React.ComponentProps<'li'> & {
|
|
13
|
+
value?: string;
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
export declare function Trigger({ onClick, onKeyDown, ...props }: ButtonProps): React.JSX.Element;
|
|
16
|
+
export declare function Content({ forceMount, style, ref, onKeyDown, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, ...props }: DivProps & {
|
|
17
|
+
forceMount?: true;
|
|
18
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
19
|
+
onPointerDownOutside?: (event: OutsideEvent) => void;
|
|
20
|
+
onFocusOutside?: (event: OutsideEvent) => void;
|
|
21
|
+
onInteractOutside?: (event: OutsideEvent) => void;
|
|
22
|
+
}): React.JSX.Element | null;
|
|
23
|
+
export declare function Viewport({ ref, style, ...props }: DivProps): React.JSX.Element;
|
|
24
|
+
export declare function Link({ asChild, active, onSelect, onClick, ...props }: Omit<React.ComponentProps<'a'>, 'onSelect'> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
active?: boolean;
|
|
27
|
+
onSelect?: (event: Event) => void;
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
export declare function Indicator({ forceMount, ...props }: DivProps & {
|
|
30
|
+
forceMount?: true;
|
|
31
|
+
}): React.JSX.Element | null;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { useMergedRef, DivPart, Slot, useControllable, moveFocus, ButtonPart, selectionEvent } from "./core.js";
|
|
5
|
+
const Context = React.createContext({ value: "", set: (_value) => {
|
|
6
|
+
}, viewport: null, setViewport: (_node) => {
|
|
7
|
+
} });
|
|
8
|
+
const ItemContext = React.createContext("");
|
|
9
|
+
function Root({ value, defaultValue = "", onValueChange, orientation = "horizontal", onKeyDown, ...props }) {
|
|
10
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange), [viewport, setViewport] = React.useState(null);
|
|
11
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { value: current, set, viewport, setViewport }, children: /* @__PURE__ */ jsx("nav", { ...props, "aria-label": props["aria-label"] ?? "导航菜单", onKeyDown: (event) => {
|
|
12
|
+
onKeyDown?.(event);
|
|
13
|
+
if (!event.defaultPrevented) {
|
|
14
|
+
if (event.key === "Escape") {
|
|
15
|
+
set("");
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
} else if (event.target.closest("[data-navigation-trigger]"))
|
|
18
|
+
moveFocus(event, "[data-navigation-trigger]", { vertical: orientation === "vertical" });
|
|
19
|
+
}
|
|
20
|
+
} }) });
|
|
21
|
+
}
|
|
22
|
+
function List(props) {
|
|
23
|
+
return /* @__PURE__ */ jsx("ul", { ...props });
|
|
24
|
+
}
|
|
25
|
+
function Item({ value, ...props }) {
|
|
26
|
+
const id = React.useId();
|
|
27
|
+
return /* @__PURE__ */ jsx(ItemContext.Provider, { value: value ?? id, children: /* @__PURE__ */ jsx("li", { ...props }) });
|
|
28
|
+
}
|
|
29
|
+
function Trigger({ onClick, onKeyDown, ...props }) {
|
|
30
|
+
const state = React.useContext(Context), value = React.useContext(ItemContext), open = state.value === value;
|
|
31
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, "data-navigation-trigger": "", "aria-expanded": open, "aria-controls": `${value}-navigation-content`, "data-state": open ? "open" : "closed", onClick: (event) => {
|
|
32
|
+
onClick?.(event);
|
|
33
|
+
if (!event.defaultPrevented)
|
|
34
|
+
state.set(open ? "" : value);
|
|
35
|
+
}, onKeyDown: (event) => {
|
|
36
|
+
onKeyDown?.(event);
|
|
37
|
+
if (!event.defaultPrevented && event.key === "ArrowDown") {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
state.set(value);
|
|
40
|
+
queueMicrotask(() => document.getElementById(`${value}-navigation-content`)?.querySelector("a,button")?.focus());
|
|
41
|
+
}
|
|
42
|
+
} });
|
|
43
|
+
}
|
|
44
|
+
function Content({ forceMount, style, ref, onKeyDown, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, ...props }) {
|
|
45
|
+
const state = React.useContext(Context), value = React.useContext(ItemContext), open = state.value === value;
|
|
46
|
+
const local = React.useRef(null), merged = useMergedRef(ref, local);
|
|
47
|
+
const latest = React.useRef({ onPointerDownOutside, onFocusOutside, onInteractOutside });
|
|
48
|
+
latest.current = { onPointerDownOutside, onFocusOutside, onInteractOutside };
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (!open)
|
|
51
|
+
return;
|
|
52
|
+
const outside = (originalEvent) => {
|
|
53
|
+
const node = local.current, target = originalEvent.target;
|
|
54
|
+
if (!node || node.contains(target) || node.closest("nav")?.contains(target))
|
|
55
|
+
return;
|
|
56
|
+
const event = new CustomEvent("interactOutside", { cancelable: true, detail: { originalEvent } });
|
|
57
|
+
if (originalEvent.type === "pointerdown")
|
|
58
|
+
latest.current.onPointerDownOutside?.(event);
|
|
59
|
+
else
|
|
60
|
+
latest.current.onFocusOutside?.(event);
|
|
61
|
+
latest.current.onInteractOutside?.(event);
|
|
62
|
+
if (!event.defaultPrevented)
|
|
63
|
+
state.set("");
|
|
64
|
+
};
|
|
65
|
+
document.addEventListener("pointerdown", outside);
|
|
66
|
+
document.addEventListener("focusin", outside);
|
|
67
|
+
return () => {
|
|
68
|
+
document.removeEventListener("pointerdown", outside);
|
|
69
|
+
document.removeEventListener("focusin", outside);
|
|
70
|
+
};
|
|
71
|
+
}, [open, state.set]);
|
|
72
|
+
if (!open && !forceMount)
|
|
73
|
+
return null;
|
|
74
|
+
const content = /* @__PURE__ */ jsx(DivPart, { ...props, ref: merged, id: `${value}-navigation-content`, hidden: !open, "data-state": open ? "open" : "closed", onKeyDown: (event) => {
|
|
75
|
+
onKeyDown?.(event);
|
|
76
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
onEscapeKeyDown?.(event.nativeEvent);
|
|
79
|
+
if (!event.nativeEvent.defaultPrevented) {
|
|
80
|
+
const nav = local.current?.closest("nav");
|
|
81
|
+
const trigger = [...nav?.querySelectorAll("[data-navigation-trigger]") ?? []].find((node) => node.getAttribute("aria-controls") === `${value}-navigation-content`);
|
|
82
|
+
state.set("");
|
|
83
|
+
trigger?.focus();
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, style: { position: state.viewport ? "relative" : "absolute", top: state.viewport ? void 0 : "100%", zIndex: 80, ...style } });
|
|
88
|
+
return state.viewport ? createPortal(content, state.viewport) : content;
|
|
89
|
+
}
|
|
90
|
+
function Viewport({ ref, style, ...props }) {
|
|
91
|
+
const state = React.useContext(Context);
|
|
92
|
+
return /* @__PURE__ */ jsx(DivPart, { ...props, ref: React.useCallback((node) => {
|
|
93
|
+
state.setViewport(node);
|
|
94
|
+
if (typeof ref === "function")
|
|
95
|
+
ref(node);
|
|
96
|
+
else if (ref)
|
|
97
|
+
ref.current = node;
|
|
98
|
+
}, [state.setViewport, ref]), hidden: !state.value, "data-state": state.value ? "open" : "closed", style: { width: "max-content", height: "auto", ...style } });
|
|
99
|
+
}
|
|
100
|
+
function Link({ asChild, active, onSelect, onClick, ...props }) {
|
|
101
|
+
const state = React.useContext(Context), attrs = { ...props, "data-active": active, "aria-current": active ? "page" : void 0, onClick: (event) => {
|
|
102
|
+
onClick?.(event);
|
|
103
|
+
if (!event.defaultPrevented && !selectionEvent(onSelect))
|
|
104
|
+
state.set("");
|
|
105
|
+
} };
|
|
106
|
+
return asChild ? /* @__PURE__ */ jsx(Slot, { ...attrs, ref: props.ref }) : /* @__PURE__ */ jsx("a", { ...attrs });
|
|
107
|
+
}
|
|
108
|
+
function Indicator({ forceMount, ...props }) {
|
|
109
|
+
const state = React.useContext(Context);
|
|
110
|
+
return state.value || forceMount ? /* @__PURE__ */ jsx(DivPart, { ...props, hidden: !state.value, "data-state": state.value ? "visible" : "hidden" }) : null;
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
Content,
|
|
114
|
+
Indicator,
|
|
115
|
+
Item,
|
|
116
|
+
Link,
|
|
117
|
+
List,
|
|
118
|
+
Root,
|
|
119
|
+
Trigger,
|
|
120
|
+
Viewport
|
|
121
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ModalRootProps } from './layer';
|
|
3
|
+
export declare const Trigger: ({ onClick, onKeyDown, onPointerEnter, onPointerLeave, onFocus, onBlur, onContextMenu, ref, disabled, ...props }: import("./core").ButtonProps) => React.JSX.Element, Anchor: ({ ref, ...props }: import("./core").DivProps) => React.JSX.Element, Close: ({ onClick, ...props }: import("./core").ButtonProps) => React.JSX.Element, Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null, Content: ({ forceMount, side, align, sideOffset, alignOffset, avoidCollisions, collisionPadding, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, ref, style, onKeyDown, onPointerEnter, onPointerLeave, ...props }: import("./layer").LayerContentProps) => React.JSX.Element | null;
|
|
4
|
+
export declare const Root: (props: ModalRootProps) => React.ReactElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function Root({ value, max, getValueLabel, ...props }: React.ComponentProps<'div'> & {
|
|
3
|
+
value?: number | null;
|
|
4
|
+
max?: number;
|
|
5
|
+
getValueLabel?: (value: number, max: number) => string;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
export declare function Indicator(props: React.ComponentProps<'div'>): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function Root({ value = null, max = 100, getValueLabel, ...props }) {
|
|
3
|
+
const limit = max > 0 ? max : 100;
|
|
4
|
+
const current = value === null ? null : Math.max(0, Math.min(limit, value));
|
|
5
|
+
return /* @__PURE__ */ jsx("div", { ...props, role: "progressbar", "aria-valuemin": 0, "aria-valuemax": limit, "aria-valuenow": current ?? void 0, "aria-valuetext": current === null ? void 0 : getValueLabel?.(current, limit), "data-state": current === null ? "indeterminate" : current === limit ? "complete" : "loading" });
|
|
6
|
+
}
|
|
7
|
+
function Indicator(props) {
|
|
8
|
+
return /* @__PURE__ */ jsx("div", { ...props });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
Indicator,
|
|
12
|
+
Root
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
3
|
+
export interface RadioGroupProps extends Omit<DivProps, 'defaultValue'> {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
orientation?: 'horizontal' | 'vertical';
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Root({ value, defaultValue, onValueChange, disabled, required, name, orientation, loop, onKeyDown, children, ...props }: RadioGroupProps): React.JSX.Element;
|
|
14
|
+
export declare function Item({ value, required, onClick, ...props }: ButtonProps & {
|
|
15
|
+
value: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
export declare function Indicator(props: React.ComponentProps<'span'>): React.JSX.Element | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ButtonPart, useControllable, DivPart, moveFocus } from "./core.js";
|
|
4
|
+
const Context = React.createContext({ value: "", set: (_value) => {
|
|
5
|
+
}, disabled: false, name: void 0, required: false });
|
|
6
|
+
const Checked = React.createContext(false);
|
|
7
|
+
function Root({ value, defaultValue = "", onValueChange, disabled = false, required = false, name, orientation = "vertical", loop = true, onKeyDown, children, ...props }) {
|
|
8
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
9
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { value: current, set, disabled, name, required }, children: /* @__PURE__ */ jsx(DivPart, { ...props, role: "radiogroup", "aria-required": required, "aria-orientation": orientation, onKeyDown: (event) => {
|
|
10
|
+
onKeyDown?.(event);
|
|
11
|
+
if (!event.defaultPrevented)
|
|
12
|
+
moveFocus(event, '[role="radio"]', { vertical: orientation === "vertical", loop, select: true });
|
|
13
|
+
}, children }) });
|
|
14
|
+
}
|
|
15
|
+
function Item({ value, required = false, onClick, ...props }) {
|
|
16
|
+
const state = React.useContext(Context);
|
|
17
|
+
const checked = state.value === value;
|
|
18
|
+
return /* @__PURE__ */ jsxs(Checked.Provider, { value: checked, children: [
|
|
19
|
+
/* @__PURE__ */ jsx(ButtonPart, { ...props, role: "radio", "aria-checked": checked, disabled: state.disabled || props.disabled, "data-state": checked ? "checked" : "unchecked", tabIndex: checked || !state.value ? 0 : -1, onClick: (event) => {
|
|
20
|
+
onClick?.(event);
|
|
21
|
+
if (!event.defaultPrevented)
|
|
22
|
+
state.set(value);
|
|
23
|
+
} }),
|
|
24
|
+
state.name && /* @__PURE__ */ jsx("input", { type: "radio", name: state.name, value, required: state.required || required, form: props.form, disabled: state.disabled || props.disabled, checked, onChange: (event) => {
|
|
25
|
+
if (event.target.checked) state.set(value);
|
|
26
|
+
}, tabIndex: -1, "aria-hidden": "true", style: { position: "absolute", opacity: 0, width: 1, height: 1, pointerEvents: "none" } })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
function Indicator(props) {
|
|
30
|
+
return React.useContext(Checked) ? /* @__PURE__ */ jsx("span", { ...props }) : null;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
Indicator,
|
|
34
|
+
Item,
|
|
35
|
+
Root
|
|
36
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
3
|
+
export interface GroupProps extends React.ComponentProps<'div'> {
|
|
4
|
+
orientation?: Orientation;
|
|
5
|
+
onLayoutChange?: (sizes: Record<string, number>) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface PanelProps extends Omit<React.ComponentProps<'div'>, 'onResize'> {
|
|
8
|
+
defaultSize?: number | string;
|
|
9
|
+
minSize?: number | string;
|
|
10
|
+
maxSize?: number | string;
|
|
11
|
+
onResize?: (size: number) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface SeparatorProps extends React.ComponentProps<'div'> {
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function Group({ orientation, onLayoutChange, children, ref, ...props }: GroupProps): React.JSX.Element;
|
|
17
|
+
export declare function Panel({ id, defaultSize, minSize, maxSize, onResize, ref, style, ...props }: PanelProps): React.JSX.Element;
|
|
18
|
+
export declare function Separator({ disabled, onPointerDown, onKeyDown, style, ref, ...props }: SeparatorProps): React.JSX.Element;
|
|
19
|
+
export {};
|