@gemologic/sheen 0.1.0-rc.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/LICENSE +19 -0
- package/README.md +32 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.js +29 -0
- package/dist/formisch.d.ts +5 -0
- package/dist/formisch.js +22 -0
- package/dist/forms.d.ts +34 -0
- package/dist/forms.js +18 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +75 -0
- package/dist/layout/Layout.d.ts +28 -0
- package/dist/layout/Layout.js +121 -0
- package/dist/metadata.d.ts +46 -0
- package/dist/metadata.js +47 -0
- package/dist/navigation.d.ts +30 -0
- package/dist/navigation.js +16 -0
- package/dist/overlays.d.ts +28 -0
- package/dist/overlays.js +15 -0
- package/dist/primitives/Accordion.d.ts +16 -0
- package/dist/primitives/Accordion.js +223 -0
- package/dist/primitives/ActivityTimeline.d.ts +20 -0
- package/dist/primitives/ActivityTimeline.js +104 -0
- package/dist/primitives/AlertDialog.d.ts +7 -0
- package/dist/primitives/AlertDialog.js +8 -0
- package/dist/primitives/Avatar.d.ts +22 -0
- package/dist/primitives/Avatar.js +115 -0
- package/dist/primitives/Breadcrumb.d.ts +11 -0
- package/dist/primitives/Breadcrumb.js +66 -0
- package/dist/primitives/Button.d.ts +11 -0
- package/dist/primitives/Button.js +59 -0
- package/dist/primitives/ButtonGroup.d.ts +7 -0
- package/dist/primitives/ButtonGroup.js +33 -0
- package/dist/primitives/Checkbox.d.ts +22 -0
- package/dist/primitives/Checkbox.js +93 -0
- package/dist/primitives/CheckboxGroup.d.ts +18 -0
- package/dist/primitives/CheckboxGroup.js +122 -0
- package/dist/primitives/Collapsible.d.ts +9 -0
- package/dist/primitives/Collapsible.js +72 -0
- package/dist/primitives/Combobox.d.ts +41 -0
- package/dist/primitives/Combobox.js +684 -0
- package/dist/primitives/CommandPalette.d.ts +42 -0
- package/dist/primitives/CommandPalette.js +319 -0
- package/dist/primitives/ConfirmDialog.d.ts +11 -0
- package/dist/primitives/ConfirmDialog.js +42 -0
- package/dist/primitives/ContextMenu.d.ts +16 -0
- package/dist/primitives/ContextMenu.js +132 -0
- package/dist/primitives/DescriptionList.d.ts +11 -0
- package/dist/primitives/DescriptionList.js +44 -0
- package/dist/primitives/Dialog.d.ts +21 -0
- package/dist/primitives/Dialog.js +141 -0
- package/dist/primitives/Drawer.d.ts +9 -0
- package/dist/primitives/Drawer.js +21 -0
- package/dist/primitives/DropdownMenu.d.ts +59 -0
- package/dist/primitives/DropdownMenu.js +441 -0
- package/dist/primitives/EditableTextField.d.ts +11 -0
- package/dist/primitives/EditableTextField.js +126 -0
- package/dist/primitives/EmptyState.d.ts +7 -0
- package/dist/primitives/EmptyState.js +45 -0
- package/dist/primitives/Field.d.ts +18 -0
- package/dist/primitives/Field.js +72 -0
- package/dist/primitives/FileDropzone.d.ts +40 -0
- package/dist/primitives/FileDropzone.js +261 -0
- package/dist/primitives/IconButton.d.ts +8 -0
- package/dist/primitives/IconButton.js +34 -0
- package/dist/primitives/Input.d.ts +7 -0
- package/dist/primitives/Input.js +55 -0
- package/dist/primitives/InputGroup.d.ts +7 -0
- package/dist/primitives/InputGroup.js +73 -0
- package/dist/primitives/Link.d.ts +7 -0
- package/dist/primitives/Link.js +35 -0
- package/dist/primitives/LinkTooltip.d.ts +11 -0
- package/dist/primitives/LinkTooltip.js +88 -0
- package/dist/primitives/NavList.d.ts +17 -0
- package/dist/primitives/NavList.js +143 -0
- package/dist/primitives/Notice.d.ts +8 -0
- package/dist/primitives/Notice.js +64 -0
- package/dist/primitives/NumberField.d.ts +22 -0
- package/dist/primitives/NumberField.js +177 -0
- package/dist/primitives/Pagination.d.ts +12 -0
- package/dist/primitives/Pagination.js +127 -0
- package/dist/primitives/Popover.d.ts +12 -0
- package/dist/primitives/Popover.js +103 -0
- package/dist/primitives/Progress.d.ts +17 -0
- package/dist/primitives/Progress.js +98 -0
- package/dist/primitives/RadioGroup.d.ts +19 -0
- package/dist/primitives/RadioGroup.js +173 -0
- package/dist/primitives/Resizable.d.ts +36 -0
- package/dist/primitives/Resizable.js +196 -0
- package/dist/primitives/ScrollArea.d.ts +6 -0
- package/dist/primitives/ScrollArea.js +178 -0
- package/dist/primitives/SearchInput.d.ts +12 -0
- package/dist/primitives/SearchInput.js +89 -0
- package/dist/primitives/SegmentedControl.d.ts +25 -0
- package/dist/primitives/SegmentedControl.js +188 -0
- package/dist/primitives/Select.d.ts +24 -0
- package/dist/primitives/Select.js +320 -0
- package/dist/primitives/Separator.d.ts +6 -0
- package/dist/primitives/Separator.js +31 -0
- package/dist/primitives/ShortcutPending.d.ts +6 -0
- package/dist/primitives/ShortcutPending.js +40 -0
- package/dist/primitives/ShortcutProvider.d.ts +32 -0
- package/dist/primitives/ShortcutProvider.js +172 -0
- package/dist/primitives/ShortcutScope.d.ts +6 -0
- package/dist/primitives/ShortcutScope.js +29 -0
- package/dist/primitives/ShortcutSheet.d.ts +5 -0
- package/dist/primitives/ShortcutSheet.js +87 -0
- package/dist/primitives/Skeleton.d.ts +5 -0
- package/dist/primitives/Skeleton.js +23 -0
- package/dist/primitives/Slider.d.ts +35 -0
- package/dist/primitives/Slider.js +210 -0
- package/dist/primitives/Spinner.d.ts +7 -0
- package/dist/primitives/Spinner.js +44 -0
- package/dist/primitives/Status.d.ts +15 -0
- package/dist/primitives/Status.js +78 -0
- package/dist/primitives/Stepper.d.ts +32 -0
- package/dist/primitives/Stepper.js +147 -0
- package/dist/primitives/Surface.d.ts +11 -0
- package/dist/primitives/Surface.js +58 -0
- package/dist/primitives/Switch.d.ts +4 -0
- package/dist/primitives/Switch.js +7 -0
- package/dist/primitives/Table.d.ts +23 -0
- package/dist/primitives/Table.js +101 -0
- package/dist/primitives/Tabs.d.ts +17 -0
- package/dist/primitives/Tabs.js +157 -0
- package/dist/primitives/TagInput.d.ts +33 -0
- package/dist/primitives/TagInput.js +288 -0
- package/dist/primitives/Textarea.d.ts +8 -0
- package/dist/primitives/Textarea.js +106 -0
- package/dist/primitives/Toast.d.ts +10 -0
- package/dist/primitives/Toast.js +78 -0
- package/dist/primitives/Toaster.d.ts +9 -0
- package/dist/primitives/Toaster.js +183 -0
- package/dist/primitives/Tooltip.d.ts +13 -0
- package/dist/primitives/Tooltip.js +84 -0
- package/dist/primitives/Tree.d.ts +23 -0
- package/dist/primitives/Tree.js +275 -0
- package/dist/primitives/Typography.d.ts +16 -0
- package/dist/primitives/Typography.js +82 -0
- package/dist/primitives/boolean-input-state.d.ts +14 -0
- package/dist/primitives/boolean-input-state.js +39 -0
- package/dist/primitives/button-variants.d.ts +9 -0
- package/dist/primitives/button-variants.js +7 -0
- package/dist/primitives/choice-options.d.ts +7 -0
- package/dist/primitives/choice-options.js +35 -0
- package/dist/primitives/create-confirm.d.ts +15 -0
- package/dist/primitives/create-confirm.js +49 -0
- package/dist/primitives/create-toaster.d.ts +51 -0
- package/dist/primitives/create-toaster.js +87 -0
- package/dist/primitives/link-focus.d.ts +2 -0
- package/dist/primitives/link-focus.js +38 -0
- package/dist/primitives/menu-focus.d.ts +3 -0
- package/dist/primitives/menu-focus.js +32 -0
- package/dist/primitives/tooltip-layer.d.ts +14 -0
- package/dist/primitives/tooltip-layer.js +84 -0
- package/dist/theme/ThemeProvider.d.ts +59 -0
- package/dist/theme/ThemeProvider.js +239 -0
- package/dist/theme/intl.d.ts +6 -0
- package/dist/theme/intl.js +13 -0
- package/dist/theme/keyboard-script.d.ts +2 -0
- package/dist/theme/keyboard-script.js +6 -0
- package/dist/theme/layers.d.ts +7 -0
- package/dist/theme/layers.js +23 -0
- package/dist/theme/messages.d.ts +235 -0
- package/dist/theme/messages.js +115 -0
- package/dist/theme/script.d.ts +9 -0
- package/dist/theme/script.js +49 -0
- package/dist/theme/state.d.ts +27 -0
- package/dist/theme/state.js +55 -0
- package/dist/utils/browser-status.d.ts +5 -0
- package/dist/utils/browser-status.js +22 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +7 -0
- package/dist/utils/optimistic.d.ts +6 -0
- package/dist/utils/optimistic.js +16 -0
- package/dist/utils/polymorphic.d.ts +1 -0
- package/dist/utils/shortcut-platform.d.ts +2 -0
- package/dist/utils/shortcut-platform.js +10 -0
- package/dist/utils/shortcut-registry.d.ts +61 -0
- package/dist/utils/shortcut-registry.js +186 -0
- package/package.json +100 -0
- package/src/core.ts +55 -0
- package/src/formisch.ts +28 -0
- package/src/forms.ts +34 -0
- package/src/index.ts +144 -0
- package/src/layout/Layout.tsx +43 -0
- package/src/metadata.d.ts +46 -0
- package/src/metadata.ts +66 -0
- package/src/navigation.ts +30 -0
- package/src/overlays.ts +28 -0
- package/src/primitives/Accordion.tsx +145 -0
- package/src/primitives/ActivityTimeline.tsx +72 -0
- package/src/primitives/AlertDialog.tsx +8 -0
- package/src/primitives/Avatar.tsx +85 -0
- package/src/primitives/Breadcrumb.tsx +41 -0
- package/src/primitives/Button.tsx +27 -0
- package/src/primitives/ButtonGroup.tsx +18 -0
- package/src/primitives/Checkbox.tsx +51 -0
- package/src/primitives/CheckboxGroup.tsx +73 -0
- package/src/primitives/Collapsible.tsx +43 -0
- package/src/primitives/Combobox.tsx +402 -0
- package/src/primitives/CommandPalette.tsx +234 -0
- package/src/primitives/ConfirmDialog.tsx +25 -0
- package/src/primitives/ContextMenu.tsx +100 -0
- package/src/primitives/DescriptionList.tsx +26 -0
- package/src/primitives/Dialog.tsx +81 -0
- package/src/primitives/Drawer.tsx +26 -0
- package/src/primitives/DropdownMenu.tsx +221 -0
- package/src/primitives/EditableTextField.tsx +91 -0
- package/src/primitives/EmptyState.tsx +21 -0
- package/src/primitives/Field.tsx +38 -0
- package/src/primitives/FileDropzone.tsx +189 -0
- package/src/primitives/IconButton.tsx +22 -0
- package/src/primitives/Input.tsx +17 -0
- package/src/primitives/InputGroup.tsx +23 -0
- package/src/primitives/Link.tsx +19 -0
- package/src/primitives/LinkTooltip.tsx +31 -0
- package/src/primitives/NavList.tsx +58 -0
- package/src/primitives/Notice.tsx +25 -0
- package/src/primitives/NumberField.tsx +168 -0
- package/src/primitives/Pagination.tsx +64 -0
- package/src/primitives/Popover.tsx +44 -0
- package/src/primitives/Progress.tsx +62 -0
- package/src/primitives/RadioGroup.tsx +104 -0
- package/src/primitives/Resizable.tsx +170 -0
- package/src/primitives/ScrollArea.tsx +115 -0
- package/src/primitives/SearchInput.tsx +98 -0
- package/src/primitives/SegmentedControl.tsx +140 -0
- package/src/primitives/Select.tsx +171 -0
- package/src/primitives/Separator.tsx +13 -0
- package/src/primitives/ShortcutPending.tsx +21 -0
- package/src/primitives/ShortcutProvider.tsx +179 -0
- package/src/primitives/ShortcutScope.tsx +17 -0
- package/src/primitives/ShortcutSheet.tsx +35 -0
- package/src/primitives/Skeleton.tsx +12 -0
- package/src/primitives/Slider.tsx +153 -0
- package/src/primitives/Spinner.tsx +19 -0
- package/src/primitives/Status.tsx +33 -0
- package/src/primitives/Stepper.tsx +106 -0
- package/src/primitives/Surface.tsx +21 -0
- package/src/primitives/Switch.tsx +9 -0
- package/src/primitives/Table.tsx +57 -0
- package/src/primitives/Tabs.tsx +96 -0
- package/src/primitives/TagInput.tsx +282 -0
- package/src/primitives/Textarea.tsx +77 -0
- package/src/primitives/Toast.tsx +36 -0
- package/src/primitives/Toaster.tsx +175 -0
- package/src/primitives/Tooltip.tsx +41 -0
- package/src/primitives/Tree.tsx +256 -0
- package/src/primitives/Typography.tsx +39 -0
- package/src/primitives/boolean-input-state.ts +65 -0
- package/src/primitives/button-variants.ts +20 -0
- package/src/primitives/choice-options.ts +39 -0
- package/src/primitives/create-confirm.tsx +56 -0
- package/src/primitives/create-toaster.ts +128 -0
- package/src/primitives/link-focus.ts +38 -0
- package/src/primitives/menu-focus.ts +43 -0
- package/src/primitives/tooltip-layer.tsx +53 -0
- package/src/styles.css +655 -0
- package/src/theme/ThemeProvider.tsx +215 -0
- package/src/theme/intl.ts +14 -0
- package/src/theme/keyboard-script.ts +4 -0
- package/src/theme/layers.ts +16 -0
- package/src/theme/messages.ts +157 -0
- package/src/theme/script.ts +70 -0
- package/src/theme/state.ts +48 -0
- package/src/utils/browser-status.ts +36 -0
- package/src/utils/cn.ts +5 -0
- package/src/utils/optimistic.ts +22 -0
- package/src/utils/polymorphic.ts +1 -0
- package/src/utils/shortcut-platform.ts +4 -0
- package/src/utils/shortcut-registry.ts +216 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
import type { ButtonProps } from "./Button.tsx";
|
|
3
|
+
import type { ShortcutAction } from "../utils/shortcut-registry.ts";
|
|
4
|
+
export interface TooltipProps extends Omit<ButtonProps, "type" | "shortcut"> {
|
|
5
|
+
type?: "button" | "submit" | "reset";
|
|
6
|
+
content: string;
|
|
7
|
+
shortcut?: string | ShortcutAction;
|
|
8
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
9
|
+
openDelay?: number;
|
|
10
|
+
closeDelay?: number;
|
|
11
|
+
}
|
|
12
|
+
/** A native action button with noninteractive supporting text. */
|
|
13
|
+
export declare function Tooltip(props: TooltipProps): JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Button as e } from "./Button.js";
|
|
2
|
+
import { TooltipLayer as t, createTooltipLayer as n } from "./tooltip-layer.js";
|
|
3
|
+
import { createComponent as r, mergeProps as i } from "solid-js/web";
|
|
4
|
+
import { splitProps as a } from "solid-js";
|
|
5
|
+
import * as o from "@kobalte/core/tooltip";
|
|
6
|
+
//#region src/primitives/Tooltip.tsx
|
|
7
|
+
function s(s) {
|
|
8
|
+
let [c, l] = a(s, [
|
|
9
|
+
"content",
|
|
10
|
+
"shortcut",
|
|
11
|
+
"placement",
|
|
12
|
+
"openDelay",
|
|
13
|
+
"closeDelay",
|
|
14
|
+
"ref",
|
|
15
|
+
"children",
|
|
16
|
+
"aria-describedby"
|
|
17
|
+
]), u, d = () => l.disabled || l.loading || !1, f = n(() => u, d), p = () => typeof c.shortcut == "string" ? void 0 : c.shortcut, m = () => (f.open(), typeof c.shortcut == "string" ? c.shortcut : u?.getAttribute("data-sheen-shortcut") ?? c.shortcut?.keys);
|
|
18
|
+
return r(o.Root, {
|
|
19
|
+
get open() {
|
|
20
|
+
return f.open();
|
|
21
|
+
},
|
|
22
|
+
get onOpenChange() {
|
|
23
|
+
return f.change;
|
|
24
|
+
},
|
|
25
|
+
get disabled() {
|
|
26
|
+
return d();
|
|
27
|
+
},
|
|
28
|
+
get placement() {
|
|
29
|
+
return c.placement ?? "top";
|
|
30
|
+
},
|
|
31
|
+
get openDelay() {
|
|
32
|
+
return c.openDelay ?? 500;
|
|
33
|
+
},
|
|
34
|
+
get closeDelay() {
|
|
35
|
+
return c.closeDelay ?? 100;
|
|
36
|
+
},
|
|
37
|
+
gutter: 6,
|
|
38
|
+
get children() {
|
|
39
|
+
return [r(o.Trigger, i({ as: e }, l, {
|
|
40
|
+
get shortcut() {
|
|
41
|
+
return p();
|
|
42
|
+
},
|
|
43
|
+
get type() {
|
|
44
|
+
return l.type ?? "button";
|
|
45
|
+
},
|
|
46
|
+
get "aria-describedby"() {
|
|
47
|
+
return [c["aria-describedby"], f.open() ? `${f.id}-content` : void 0].filter(Boolean).join(" ") || void 0;
|
|
48
|
+
},
|
|
49
|
+
get onClick() {
|
|
50
|
+
return l.onClick ?? (() => {});
|
|
51
|
+
},
|
|
52
|
+
get onFocus() {
|
|
53
|
+
return l.onFocus ?? (() => {});
|
|
54
|
+
},
|
|
55
|
+
get onBlur() {
|
|
56
|
+
return l.onBlur ?? (() => {});
|
|
57
|
+
},
|
|
58
|
+
get onPointerDown() {
|
|
59
|
+
return l.onPointerDown ?? (() => {});
|
|
60
|
+
},
|
|
61
|
+
get onPointerEnter() {
|
|
62
|
+
return l.onPointerEnter ?? (() => {});
|
|
63
|
+
},
|
|
64
|
+
get onPointerLeave() {
|
|
65
|
+
return l.onPointerLeave ?? (() => {});
|
|
66
|
+
},
|
|
67
|
+
ref: (e) => {
|
|
68
|
+
u = e, typeof c.ref == "function" && c.ref(e);
|
|
69
|
+
},
|
|
70
|
+
get children() {
|
|
71
|
+
return c.children;
|
|
72
|
+
}
|
|
73
|
+
})), r(t, {
|
|
74
|
+
state: f,
|
|
75
|
+
get content() {
|
|
76
|
+
return c.content;
|
|
77
|
+
},
|
|
78
|
+
shortcut: m
|
|
79
|
+
})];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { s as Tooltip };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export type TreeSelectionMode = "none" | "single" | "multiple";
|
|
3
|
+
export interface TreeProps extends Omit<JSX.HTMLAttributes<HTMLUListElement>, "aria-label" | "onChange" | "onKeyDown" | "onSelect" | "onSelectionChange"> {
|
|
4
|
+
label: string;
|
|
5
|
+
selectionMode?: TreeSelectionMode;
|
|
6
|
+
selectedValues?: readonly string[];
|
|
7
|
+
defaultSelectedValues?: readonly string[];
|
|
8
|
+
onSelectionChange?: (values: readonly string[]) => void;
|
|
9
|
+
expandedValues?: readonly string[];
|
|
10
|
+
defaultExpandedValues?: readonly string[];
|
|
11
|
+
onExpandedChange?: (values: readonly string[]) => void;
|
|
12
|
+
onActivate?: (value: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface TreeItemProps extends Omit<JSX.LiHTMLAttributes<HTMLLIElement>, "children" | "onClick" | "onDblClick" | "onKeyDown" | "onSelect" | "value"> {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
children?: JSX.Element;
|
|
19
|
+
}
|
|
20
|
+
/** A hierarchical, explicitly selected treeview with roving focus and retained subtrees. */
|
|
21
|
+
export declare function Tree(props: TreeProps): JSX.Element;
|
|
22
|
+
/** A stable branch or leaf identity owned by Tree. Child items remain mounted while collapsed. */
|
|
23
|
+
export declare function TreeItem(props: TreeItemProps): JSX.Element;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { useTheme as e } from "../theme/ThemeProvider.js";
|
|
2
|
+
import { cn as t } from "../utils/cn.js";
|
|
3
|
+
import { createComponent as n, delegateEvents as r, effect as i, insert as a, memo as o, mergeProps as s, setAttribute as c, spread as l, template as u, use as d } from "solid-js/web";
|
|
4
|
+
import { createContext as f, createEffect as p, createMemo as m, createSignal as h, createUniqueId as g, onCleanup as _, onMount as v, splitProps as y, useContext as b } from "solid-js";
|
|
5
|
+
//#region src/primitives/Tree.tsx
|
|
6
|
+
var x = /*#__PURE__*/ u("<ul>"), S = /*#__PURE__*/ u("<li><div class=sheen-tree-item-row><span class=sheen-tree-item-label>"), C = /*#__PURE__*/ u("<button type=button tabindex=-1 class=sheen-tree-expander><span aria-hidden=true>"), w = /*#__PURE__*/ u("<span class=sheen-tree-leaf aria-hidden=true>"), T = /*#__PURE__*/ u("<ul role=group class=sheen-tree-group>"), E = f();
|
|
7
|
+
function D(e, t) {
|
|
8
|
+
if (t.some((e) => !e.trim())) throw Error(`Tree ${e} values must be nonempty`);
|
|
9
|
+
if (new Set(t).size !== t.length) throw Error(`Tree ${e} values must be unique`);
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
function O(e) {
|
|
13
|
+
return [...e.querySelectorAll("[role=\"treeitem\"]")].filter((t) => t.closest("[role=\"tree\"]") === e && t.closest("[hidden], [inert]") === null);
|
|
14
|
+
}
|
|
15
|
+
function k(e) {
|
|
16
|
+
let t = [...e.children].find((e) => e.getAttribute("role") === "group");
|
|
17
|
+
return t instanceof HTMLElement ? t : void 0;
|
|
18
|
+
}
|
|
19
|
+
function A(e) {
|
|
20
|
+
let t = e.dataset.sheenTreeValue;
|
|
21
|
+
if (t === void 0) throw Error("Sheen Tree encountered an item without an identity");
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
function j(r) {
|
|
25
|
+
let [i, o] = y(r, [
|
|
26
|
+
"label",
|
|
27
|
+
"selectionMode",
|
|
28
|
+
"selectedValues",
|
|
29
|
+
"defaultSelectedValues",
|
|
30
|
+
"onSelectionChange",
|
|
31
|
+
"expandedValues",
|
|
32
|
+
"defaultExpandedValues",
|
|
33
|
+
"onExpandedChange",
|
|
34
|
+
"onActivate",
|
|
35
|
+
"class",
|
|
36
|
+
"ref",
|
|
37
|
+
"children"
|
|
38
|
+
]), c = /* @__PURE__ */ new Map(), u = e(), [f, p] = h([...i.defaultSelectedValues ?? []]), [g, b] = h([...i.defaultExpandedValues ?? []]), [S, C] = h(""), w = () => i.selectionMode ?? "single", T = m(() => {
|
|
39
|
+
let e = D("selected", i.selectedValues ?? f());
|
|
40
|
+
if (w() === "none" && e.length) throw Error("Tree selectionMode none cannot contain selected values");
|
|
41
|
+
if (w() === "single" && e.length > 1) throw Error("Tree single selection accepts at most one value");
|
|
42
|
+
return e;
|
|
43
|
+
}), j = m(() => D("expanded", i.expandedValues ?? g())), M = m(() => new Set(T())), N = m(() => new Set(j())), P = (e, t) => {
|
|
44
|
+
if (c.has(e)) throw Error(`Tree duplicate item value: ${e}`);
|
|
45
|
+
c.set(e, t), S() || C(e);
|
|
46
|
+
}, F = (e) => {
|
|
47
|
+
c.delete(e);
|
|
48
|
+
}, I = (e) => {
|
|
49
|
+
let t = c.get(e);
|
|
50
|
+
if (w() === "none" || !t || t.disabled() || w() === "single" && M().has(e)) return;
|
|
51
|
+
let n;
|
|
52
|
+
n = w() === "single" ? [e] : M().has(e) ? T().filter((t) => t !== e) : [...T(), e], i.selectedValues === void 0 && p(n), i.onSelectionChange?.(n);
|
|
53
|
+
}, L = (e) => {
|
|
54
|
+
i.expandedValues === void 0 && b(e), i.onExpandedChange?.(e);
|
|
55
|
+
}, R = (e) => {
|
|
56
|
+
let t = c.get(e);
|
|
57
|
+
t?.branch && !t.disabled() && L(N().has(e) ? j().filter((t) => t !== e) : [...j(), e]);
|
|
58
|
+
}, z = {
|
|
59
|
+
selectionMode: w,
|
|
60
|
+
selected: M,
|
|
61
|
+
expanded: N,
|
|
62
|
+
focused: S,
|
|
63
|
+
setFocused: C,
|
|
64
|
+
register: P,
|
|
65
|
+
unregister: F,
|
|
66
|
+
select: I,
|
|
67
|
+
toggleExpanded: R,
|
|
68
|
+
expand: (e) => {
|
|
69
|
+
let t = e.filter((e) => {
|
|
70
|
+
let t = c.get(e);
|
|
71
|
+
return t?.branch && !t.disabled() && !N().has(e);
|
|
72
|
+
});
|
|
73
|
+
t.length && L([...j(), ...t]);
|
|
74
|
+
},
|
|
75
|
+
activate: (e) => {
|
|
76
|
+
let t = c.get(e);
|
|
77
|
+
t && !t.disabled() && (i.onActivate ? i.onActivate(e) : t.branch && R(e));
|
|
78
|
+
}
|
|
79
|
+
}, B, V = "", H, U = (e) => {
|
|
80
|
+
e && (C(A(e)), e.focus());
|
|
81
|
+
}, W = (e) => {
|
|
82
|
+
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.isComposing) return;
|
|
83
|
+
let t = e.target;
|
|
84
|
+
if (!(t instanceof HTMLElement)) return;
|
|
85
|
+
let n = t.closest("[role=\"treeitem\"]");
|
|
86
|
+
if (!n || n.closest("[role=\"tree\"]") !== e.currentTarget) return;
|
|
87
|
+
let r = O(e.currentTarget), i = r.indexOf(n);
|
|
88
|
+
if (i < 0) return;
|
|
89
|
+
let a = A(n), o;
|
|
90
|
+
switch (e.key) {
|
|
91
|
+
case "ArrowDown":
|
|
92
|
+
o = r[i + 1];
|
|
93
|
+
break;
|
|
94
|
+
case "ArrowUp":
|
|
95
|
+
o = r[i - 1];
|
|
96
|
+
break;
|
|
97
|
+
case "Home":
|
|
98
|
+
o = r[0];
|
|
99
|
+
break;
|
|
100
|
+
case "End":
|
|
101
|
+
o = r.at(-1);
|
|
102
|
+
break;
|
|
103
|
+
case "ArrowRight":
|
|
104
|
+
n.getAttribute("aria-expanded") === "false" ? z.toggleExpanded(a) : n.getAttribute("aria-expanded") === "true" && (o = k(n)?.querySelector("[role=\"treeitem\"]") ?? void 0);
|
|
105
|
+
break;
|
|
106
|
+
case "ArrowLeft":
|
|
107
|
+
n.getAttribute("aria-expanded") === "true" ? z.toggleExpanded(a) : o = n.parentElement?.closest("[role=\"treeitem\"]") ?? void 0;
|
|
108
|
+
break;
|
|
109
|
+
case "*": {
|
|
110
|
+
let e = [...n.parentElement?.children ?? []].filter((e) => e instanceof HTMLElement && e.hasAttribute("aria-expanded")).map(A);
|
|
111
|
+
z.expand(e);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case " ":
|
|
115
|
+
z.select(a);
|
|
116
|
+
break;
|
|
117
|
+
case "Enter":
|
|
118
|
+
z.activate(a);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
if (e.key.length !== 1) return;
|
|
122
|
+
V += e.key.toLocaleLowerCase(u.state().locale), [...V].every((e) => e === V[0]) && (V = V[0] ?? ""), H !== void 0 && clearTimeout(H), H = setTimeout(() => {
|
|
123
|
+
V = "";
|
|
124
|
+
}, 500), o = [...r.slice(i + 1), ...r.slice(0, i + 1)].find((e) => (e.dataset.sheenTreeLabel ?? "").toLocaleLowerCase(u.state().locale).startsWith(V));
|
|
125
|
+
}
|
|
126
|
+
e.preventDefault(), U(o);
|
|
127
|
+
};
|
|
128
|
+
v(() => {
|
|
129
|
+
let e = B;
|
|
130
|
+
if (!e) return;
|
|
131
|
+
let t = O(e), n = new MutationObserver(() => {
|
|
132
|
+
let n = O(e), r = e.ownerDocument.activeElement;
|
|
133
|
+
if (e.isConnected && r === e.ownerDocument.body && !n.some((e) => e.dataset.sheenTreeValue === S())) {
|
|
134
|
+
let e = t.findIndex((e) => e.dataset.sheenTreeValue === S());
|
|
135
|
+
U(n[Math.min(Math.max(e, 0), Math.max(n.length - 1, 0))]);
|
|
136
|
+
}
|
|
137
|
+
t = n;
|
|
138
|
+
});
|
|
139
|
+
n.observe(e, {
|
|
140
|
+
childList: !0,
|
|
141
|
+
subtree: !0,
|
|
142
|
+
attributes: !0,
|
|
143
|
+
attributeFilter: ["hidden", "inert"]
|
|
144
|
+
}), _(() => n.disconnect());
|
|
145
|
+
}), _(() => {
|
|
146
|
+
H !== void 0 && clearTimeout(H);
|
|
147
|
+
});
|
|
148
|
+
let G = m(() => {
|
|
149
|
+
if (!i.label.trim()) throw Error("Tree requires a nonempty accessible label");
|
|
150
|
+
return i.label;
|
|
151
|
+
});
|
|
152
|
+
return n(E.Provider, {
|
|
153
|
+
value: z,
|
|
154
|
+
get children() {
|
|
155
|
+
var e = x();
|
|
156
|
+
return d((e) => {
|
|
157
|
+
B = e, typeof i.ref == "function" && i.ref(e);
|
|
158
|
+
}, e), l(e, s(o, {
|
|
159
|
+
role: "tree",
|
|
160
|
+
get "aria-label"() {
|
|
161
|
+
return G();
|
|
162
|
+
},
|
|
163
|
+
get "aria-multiselectable"() {
|
|
164
|
+
return w() === "multiple" ? "true" : void 0;
|
|
165
|
+
},
|
|
166
|
+
get class() {
|
|
167
|
+
return t("sheen-tree", i.class);
|
|
168
|
+
},
|
|
169
|
+
onKeyDown: W
|
|
170
|
+
}), !1, !0), a(e, () => i.children), e;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function M(n) {
|
|
175
|
+
let r = b(E);
|
|
176
|
+
if (!r) throw Error("TreeItem requires a Tree owner");
|
|
177
|
+
let u = e(), f = Object.prototype.hasOwnProperty.call(n, "children"), [m, h] = y(n, [
|
|
178
|
+
"value",
|
|
179
|
+
"label",
|
|
180
|
+
"disabled",
|
|
181
|
+
"class",
|
|
182
|
+
"id",
|
|
183
|
+
"children",
|
|
184
|
+
"ref"
|
|
185
|
+
]), v = g(), x = () => `${m.id ?? v}-label`, D = m.value;
|
|
186
|
+
if (!D.trim() || !m.label.trim()) throw Error("TreeItem requires nonempty values and labels");
|
|
187
|
+
r.register(D, {
|
|
188
|
+
branch: f,
|
|
189
|
+
disabled: () => m.disabled ?? !1
|
|
190
|
+
}), _(() => r.unregister(D));
|
|
191
|
+
let O = () => {
|
|
192
|
+
if (m.value !== D) throw Error("TreeItem value is a stable identity and cannot change after registration");
|
|
193
|
+
if (!m.label.trim()) throw Error("TreeItem requires nonempty values and labels");
|
|
194
|
+
return D;
|
|
195
|
+
}, k = () => f && r.expanded().has(O()), A = () => r.selected().has(O()), j, M;
|
|
196
|
+
p(() => {
|
|
197
|
+
!k() && j && M?.contains(j.ownerDocument.activeElement) && (r.setFocused(O()), j.focus({ preventScroll: !0 }));
|
|
198
|
+
});
|
|
199
|
+
let N = () => {
|
|
200
|
+
r.setFocused(O());
|
|
201
|
+
}, P = () => {
|
|
202
|
+
N(), m.disabled || r.select(O());
|
|
203
|
+
};
|
|
204
|
+
return (() => {
|
|
205
|
+
var e = S(), n = e.firstChild, p = n.firstChild;
|
|
206
|
+
return d((e) => {
|
|
207
|
+
j = e, typeof m.ref == "function" && m.ref(e);
|
|
208
|
+
}, e), l(e, s(h, {
|
|
209
|
+
get id() {
|
|
210
|
+
return m.id;
|
|
211
|
+
},
|
|
212
|
+
role: "treeitem",
|
|
213
|
+
get tabIndex() {
|
|
214
|
+
return r.focused() === O() ? 0 : -1;
|
|
215
|
+
},
|
|
216
|
+
get "aria-labelledby"() {
|
|
217
|
+
return x();
|
|
218
|
+
},
|
|
219
|
+
get "aria-expanded"() {
|
|
220
|
+
return f ? k() : void 0;
|
|
221
|
+
},
|
|
222
|
+
get "aria-selected"() {
|
|
223
|
+
return o(() => r.selectionMode() === "none")() ? void 0 : A();
|
|
224
|
+
},
|
|
225
|
+
get "aria-disabled"() {
|
|
226
|
+
return m.disabled || void 0;
|
|
227
|
+
},
|
|
228
|
+
get class() {
|
|
229
|
+
return t("sheen-tree-item", m.class);
|
|
230
|
+
},
|
|
231
|
+
get "data-sheen-tree-value"() {
|
|
232
|
+
return O();
|
|
233
|
+
},
|
|
234
|
+
get "data-sheen-tree-label"() {
|
|
235
|
+
return m.label;
|
|
236
|
+
},
|
|
237
|
+
get "data-selected"() {
|
|
238
|
+
return A() ? "" : void 0;
|
|
239
|
+
},
|
|
240
|
+
get "data-disabled"() {
|
|
241
|
+
return m.disabled ? "" : void 0;
|
|
242
|
+
},
|
|
243
|
+
onFocus: N,
|
|
244
|
+
onClick: (e) => {
|
|
245
|
+
e.target instanceof Element && e.target.closest("[role=\"treeitem\"]") === e.currentTarget && P();
|
|
246
|
+
},
|
|
247
|
+
onDblClick: (e) => {
|
|
248
|
+
!m.disabled && f && e.target instanceof Element && e.target.closest("[role=\"treeitem\"]") === e.currentTarget && r.toggleExpanded(O());
|
|
249
|
+
}
|
|
250
|
+
}), !1, !0), a(n, f ? (() => {
|
|
251
|
+
var e = C();
|
|
252
|
+
return e.$$click = (e) => {
|
|
253
|
+
e.stopPropagation(), N(), j?.focus(), r.toggleExpanded(O());
|
|
254
|
+
}, i((t) => {
|
|
255
|
+
var n = (k() ? u.messages().collapseTreeItem : u.messages().expandTreeItem).replace("{label}", m.label), r = m.disabled;
|
|
256
|
+
return n !== t.e && c(e, "aria-label", t.e = n), r !== t.t && (e.disabled = t.t = r), t;
|
|
257
|
+
}, {
|
|
258
|
+
e: void 0,
|
|
259
|
+
t: void 0
|
|
260
|
+
}), e;
|
|
261
|
+
})() : w(), p), a(p, () => m.label), a(e, f ? (() => {
|
|
262
|
+
var e = T(), t = M;
|
|
263
|
+
return typeof t == "function" ? d(t, e) : M = e, a(e, () => m.children), i((t) => {
|
|
264
|
+
var n = !k(), r = !k();
|
|
265
|
+
return n !== t.e && (e.hidden = t.e = n), r !== t.t && (e.inert = t.t = r), t;
|
|
266
|
+
}, {
|
|
267
|
+
e: void 0,
|
|
268
|
+
t: void 0
|
|
269
|
+
}), e;
|
|
270
|
+
})() : null, null), i(() => c(p, "id", x())), e;
|
|
271
|
+
})();
|
|
272
|
+
}
|
|
273
|
+
r(["click"]);
|
|
274
|
+
//#endregion
|
|
275
|
+
export { j as Tree, M as TreeItem };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export interface TextProps extends JSX.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
size?: "caption" | "ui-sm" | "ui" | "body";
|
|
4
|
+
tone?: "default" | "muted";
|
|
5
|
+
numeric?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function Text(props: TextProps): JSX.Element;
|
|
8
|
+
export interface HeadingProps extends JSX.HTMLAttributes<HTMLHeadingElement> {
|
|
9
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
10
|
+
size?: "h1" | "h2" | "h3" | "h4";
|
|
11
|
+
}
|
|
12
|
+
export declare function Heading(props: HeadingProps): JSX.Element;
|
|
13
|
+
export type CodeProps = JSX.HTMLAttributes<HTMLElement>;
|
|
14
|
+
export declare function Code(props: CodeProps): JSX.Element;
|
|
15
|
+
export type KbdProps = JSX.HTMLAttributes<HTMLElement>;
|
|
16
|
+
export declare function Kbd(props: KbdProps): JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { cn as e } from "../utils/cn.js";
|
|
2
|
+
import { Dynamic as t, createComponent as n, mergeProps as r, spread as i, template as a } from "solid-js/web";
|
|
3
|
+
import { splitProps as o } from "solid-js";
|
|
4
|
+
//#region src/primitives/Typography.tsx
|
|
5
|
+
var s = /*#__PURE__*/ a("<span>"), c = /*#__PURE__*/ a("<code>"), l = /*#__PURE__*/ a("<kbd>");
|
|
6
|
+
function u(t) {
|
|
7
|
+
let [n, a] = o(t, [
|
|
8
|
+
"class",
|
|
9
|
+
"size",
|
|
10
|
+
"tone",
|
|
11
|
+
"numeric"
|
|
12
|
+
]);
|
|
13
|
+
return (() => {
|
|
14
|
+
var t = s();
|
|
15
|
+
return i(t, r(a, {
|
|
16
|
+
get class() {
|
|
17
|
+
return e("sheen-text", n.class);
|
|
18
|
+
},
|
|
19
|
+
get "data-size"() {
|
|
20
|
+
return n.size ?? "ui";
|
|
21
|
+
},
|
|
22
|
+
get "data-tone"() {
|
|
23
|
+
return n.tone ?? "default";
|
|
24
|
+
},
|
|
25
|
+
get "data-numeric"() {
|
|
26
|
+
return n.numeric || void 0;
|
|
27
|
+
}
|
|
28
|
+
}), !1, !1), t;
|
|
29
|
+
})();
|
|
30
|
+
}
|
|
31
|
+
var d = {
|
|
32
|
+
1: "h1",
|
|
33
|
+
2: "h2",
|
|
34
|
+
3: "h3",
|
|
35
|
+
4: "h4",
|
|
36
|
+
5: "h5",
|
|
37
|
+
6: "h6"
|
|
38
|
+
}, f = {
|
|
39
|
+
1: "h1",
|
|
40
|
+
2: "h2",
|
|
41
|
+
3: "h3",
|
|
42
|
+
4: "h4",
|
|
43
|
+
5: "h4",
|
|
44
|
+
6: "h4"
|
|
45
|
+
};
|
|
46
|
+
function p(i) {
|
|
47
|
+
let [a, s] = o(i, [
|
|
48
|
+
"class",
|
|
49
|
+
"level",
|
|
50
|
+
"size"
|
|
51
|
+
]);
|
|
52
|
+
return n(t, r({ get component() {
|
|
53
|
+
return d[a.level];
|
|
54
|
+
} }, s, {
|
|
55
|
+
get class() {
|
|
56
|
+
return e("sheen-heading", a.class);
|
|
57
|
+
},
|
|
58
|
+
get "data-size"() {
|
|
59
|
+
return a.size ?? f[a.level];
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function m(t) {
|
|
64
|
+
let [n, a] = o(t, ["class"]);
|
|
65
|
+
return (() => {
|
|
66
|
+
var t = c();
|
|
67
|
+
return i(t, r(a, { get class() {
|
|
68
|
+
return e("sheen-code", n.class);
|
|
69
|
+
} }), !1, !1), t;
|
|
70
|
+
})();
|
|
71
|
+
}
|
|
72
|
+
function h(t) {
|
|
73
|
+
let [n, a] = o(t, ["class"]);
|
|
74
|
+
return (() => {
|
|
75
|
+
var t = l();
|
|
76
|
+
return i(t, r(a, { get class() {
|
|
77
|
+
return e("sheen-kbd", n.class);
|
|
78
|
+
} }), !1, !1), t;
|
|
79
|
+
})();
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { m as Code, p as Heading, h as Kbd, u as Text };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface BooleanInputOptions {
|
|
2
|
+
checked?: boolean;
|
|
3
|
+
defaultChecked?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
indeterminate?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Shared ownership for native boolean inputs, including pre-hydration edits and reset. */
|
|
9
|
+
export declare function createBooleanInputState(options: BooleanInputOptions, onChange: (next: boolean) => void): {
|
|
10
|
+
checked: () => boolean;
|
|
11
|
+
requestChange: (element: HTMLInputElement) => void;
|
|
12
|
+
setInput: (element: HTMLInputElement) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createEffect as e, createMemo as t, createSignal as n, onCleanup as r, onMount as i } from "solid-js";
|
|
2
|
+
//#region src/primitives/boolean-input-state.ts
|
|
3
|
+
function a(a, o) {
|
|
4
|
+
let s = a.defaultChecked ?? !1, [c, l] = n(s), u = t(() => a.checked), d = () => u() ?? c(), [f, p] = n(!1), m, h = (e) => {
|
|
5
|
+
e !== d() && (u() === void 0 && l(e), o(e));
|
|
6
|
+
};
|
|
7
|
+
return i(() => {
|
|
8
|
+
let e = m, t = e?.ownerDocument.defaultView;
|
|
9
|
+
if (!e || !t) return;
|
|
10
|
+
!a.disabled && !a.readOnly && h(e.checked), e.checked = d(), e.indeterminate = a.indeterminate ?? !1, p(!0);
|
|
11
|
+
let n = /* @__PURE__ */ new Set(), i = (r) => {
|
|
12
|
+
if (r.target !== e.form) return;
|
|
13
|
+
let i = t.setTimeout(() => {
|
|
14
|
+
n.delete(i), !r.defaultPrevented && (u() === void 0 && h(s), e.checked = d(), e.indeterminate = a.indeterminate ?? !1);
|
|
15
|
+
}, 0);
|
|
16
|
+
n.add(i);
|
|
17
|
+
};
|
|
18
|
+
e.ownerDocument.addEventListener("reset", i, !0), r(() => {
|
|
19
|
+
e.ownerDocument.removeEventListener("reset", i, !0);
|
|
20
|
+
for (let e of n) t.clearTimeout(e);
|
|
21
|
+
});
|
|
22
|
+
}), e(() => {
|
|
23
|
+
f() && m && (m.checked = d(), m.indeterminate = a.indeterminate ?? !1);
|
|
24
|
+
}), {
|
|
25
|
+
checked: d,
|
|
26
|
+
requestChange: (e) => {
|
|
27
|
+
if (a.disabled || a.readOnly) {
|
|
28
|
+
e.checked = d();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
h(e.checked), e.checked = d();
|
|
32
|
+
},
|
|
33
|
+
setInput: (e) => {
|
|
34
|
+
m = e;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { a as createBooleanInputState };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassValue } from "clsx";
|
|
2
|
+
/** Class-only composition for native controls; behavior belongs to the component. */
|
|
3
|
+
export interface ButtonVariantProps {
|
|
4
|
+
readonly variant?: "solid" | "soft" | "outline" | "ghost" | "link" | undefined;
|
|
5
|
+
readonly tone?: "neutral" | "accent" | "danger" | "success" | undefined;
|
|
6
|
+
readonly size?: "xs" | "sm" | "md" | "lg" | undefined;
|
|
7
|
+
readonly class?: ClassValue | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function buttonVariants(options?: ButtonVariantProps): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cn as e } from "../utils/cn.js";
|
|
2
|
+
//#region src/primitives/button-variants.ts
|
|
3
|
+
function t(t = {}) {
|
|
4
|
+
return e("sheen-button", `sheen-button-${t.variant ?? "ghost"}`, `sheen-button-${t.tone ?? "neutral"}`, `sheen-button-${t.size ?? "md"}`, t.class);
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { t as buttonVariants };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Accessor } from "solid-js";
|
|
2
|
+
export declare function createChoiceOptions<Option extends {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
}>(source: Accessor<readonly Option[]>, root: Accessor<HTMLElement | undefined>, component: string): {
|
|
5
|
+
byValue: Accessor<Map<string, Option>>;
|
|
6
|
+
keys: Accessor<string[]>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createMemo as e, onCleanup as t } from "solid-js";
|
|
2
|
+
//#region src/primitives/choice-options.ts
|
|
3
|
+
function n(n, r, i) {
|
|
4
|
+
let a = !1;
|
|
5
|
+
t(() => {
|
|
6
|
+
a = !0;
|
|
7
|
+
});
|
|
8
|
+
let o = e(() => {
|
|
9
|
+
let e = /* @__PURE__ */ new Map();
|
|
10
|
+
for (let t of n()) {
|
|
11
|
+
if (e.has(t.value)) throw Error(`${i}: duplicate option value ${JSON.stringify(t.value)}`);
|
|
12
|
+
e.set(t.value, t);
|
|
13
|
+
}
|
|
14
|
+
return e;
|
|
15
|
+
}), s = [];
|
|
16
|
+
return {
|
|
17
|
+
byValue: o,
|
|
18
|
+
keys: e(() => {
|
|
19
|
+
let e = [...o().keys()], t = r(), n = t?.querySelector("input:focus");
|
|
20
|
+
if (t && n) {
|
|
21
|
+
let e = s.indexOf(n.value);
|
|
22
|
+
t.ownerDocument.defaultView?.queueMicrotask(() => {
|
|
23
|
+
if (a || !t.isConnected) return;
|
|
24
|
+
let r = t.ownerDocument.activeElement;
|
|
25
|
+
if (r !== t.ownerDocument.body && r !== n) return;
|
|
26
|
+
let i = [...t.querySelectorAll("input[type=checkbox], input[type=radio]")], o = (e) => !e.matches(":disabled"), s = i.find((e) => e.value === n.value && o(e)), c = Math.max(0, e), l = i.slice(c).find(o) ?? i.slice(0, c).reverse().find(o);
|
|
27
|
+
(s ?? l ?? t).focus({ preventScroll: !0 });
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return s = e, e;
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { n as createChoiceOptions };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export interface ConfirmOptions {
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly confirmLabel?: string;
|
|
6
|
+
readonly cancelLabel?: string;
|
|
7
|
+
readonly tone?: "accent" | "danger";
|
|
8
|
+
readonly signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfirmController {
|
|
11
|
+
readonly confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
12
|
+
readonly Dialog: () => JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
/** Create inside a Solid owner and mount Dialog once within that owner's theme scope. */
|
|
15
|
+
export declare function createConfirm(): ConfirmController;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ConfirmDialog as e } from "./ConfirmDialog.js";
|
|
2
|
+
import { createComponent as t, mergeProps as n } from "solid-js/web";
|
|
3
|
+
import { Show as r, createSignal as i, getOwner as a, onCleanup as o } from "solid-js";
|
|
4
|
+
//#region src/primitives/create-confirm.tsx
|
|
5
|
+
function s() {
|
|
6
|
+
if (!a()) throw Error("createConfirm requires a Solid owner");
|
|
7
|
+
let s = !1, [c, l] = i();
|
|
8
|
+
o(() => {
|
|
9
|
+
s = !0, c()?.settle(!1);
|
|
10
|
+
});
|
|
11
|
+
function u(e) {
|
|
12
|
+
if (s || e.signal?.aborted) return Promise.resolve(!1);
|
|
13
|
+
if (c()?.open()) return Promise.reject(/* @__PURE__ */ Error("createConfirm already has an unanswered request"));
|
|
14
|
+
let t = { ...e }, n = typeof document > "u" ? void 0 : document.activeElement, r = typeof HTMLElement < "u" && n instanceof HTMLElement ? n : void 0;
|
|
15
|
+
return new Promise((e) => {
|
|
16
|
+
let [n, a] = i(!0), o = !1, s = () => c(!1), c = (n) => {
|
|
17
|
+
o || (o = !0, t.signal?.removeEventListener("abort", s), a(!1), e(n));
|
|
18
|
+
};
|
|
19
|
+
t.signal?.addEventListener("abort", s, { once: !0 }), l({
|
|
20
|
+
options: t,
|
|
21
|
+
opener: r,
|
|
22
|
+
open: n,
|
|
23
|
+
settle: c
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function d() {
|
|
28
|
+
return t(r, {
|
|
29
|
+
get when() {
|
|
30
|
+
return c();
|
|
31
|
+
},
|
|
32
|
+
keyed: !0,
|
|
33
|
+
children: (r) => t(e, n(() => r.options, {
|
|
34
|
+
get open() {
|
|
35
|
+
return r.open();
|
|
36
|
+
},
|
|
37
|
+
returnFocus: () => r.opener,
|
|
38
|
+
onConfirm: () => r.settle(!0),
|
|
39
|
+
onCancel: () => r.settle(!1)
|
|
40
|
+
}))
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
confirm: u,
|
|
45
|
+
Dialog: d
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { s as createConfirm };
|