@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,188 @@
|
|
|
1
|
+
import { cn as e } from "../utils/cn.js";
|
|
2
|
+
import { createChoiceOptions as t } from "./choice-options.js";
|
|
3
|
+
import { createComponent as n, delegateEvents as r, effect as i, insert as a, mergeProps as o, setAttribute as s, spread as c, template as l, use as u } from "solid-js/web";
|
|
4
|
+
import { For as d, Show as f, createMemo as p, createSignal as m, createUniqueId as h, onCleanup as g, onMount as _, splitProps as v, untrack as y } from "solid-js";
|
|
5
|
+
//#region src/primitives/SegmentedControl.tsx
|
|
6
|
+
var b = /*#__PURE__*/ l("<span aria-hidden=true> *"), x = /*#__PURE__*/ l("<p class=sheen-segmented-description>"), S = /*#__PURE__*/ l("<p class=sheen-segmented-error>"), C = /*#__PURE__*/ l("<fieldset role=radiogroup><legend class=sheen-segmented-label></legend><div class=sheen-segmented-options>"), w = /*#__PURE__*/ l("<label class=sheen-segmented-item><input type=radio class=sheen-segmented-input><span class=sheen-segmented-item-label>");
|
|
7
|
+
function T(r) {
|
|
8
|
+
let l = h(), [T, E] = v(r, [
|
|
9
|
+
"id",
|
|
10
|
+
"ref",
|
|
11
|
+
"class",
|
|
12
|
+
"name",
|
|
13
|
+
"label",
|
|
14
|
+
"options",
|
|
15
|
+
"value",
|
|
16
|
+
"defaultValue",
|
|
17
|
+
"onValueChange",
|
|
18
|
+
"description",
|
|
19
|
+
"error",
|
|
20
|
+
"disabled",
|
|
21
|
+
"readOnly",
|
|
22
|
+
"required",
|
|
23
|
+
"orientation",
|
|
24
|
+
"size",
|
|
25
|
+
"overflowBehavior",
|
|
26
|
+
"form",
|
|
27
|
+
"aria-label",
|
|
28
|
+
"aria-labelledby",
|
|
29
|
+
"aria-describedby"
|
|
30
|
+
]), D = T.defaultValue ?? null, [O, k] = m(D), A = () => T.value === void 0 ? O() : T.value, j, M = !1;
|
|
31
|
+
g(() => {
|
|
32
|
+
M = !0;
|
|
33
|
+
});
|
|
34
|
+
let { byValue: N, keys: P } = t(() => {
|
|
35
|
+
if (!T.name.trim()) throw Error("SegmentedControl: name must be nonempty for native form submission");
|
|
36
|
+
for (let e of T.options) {
|
|
37
|
+
if (!e.value.trim()) throw Error("SegmentedControl: option values must be nonempty; use null for no selection");
|
|
38
|
+
if (!e.label.trim()) throw Error(`SegmentedControl: option ${JSON.stringify(e.value)} must have a nonempty label`);
|
|
39
|
+
}
|
|
40
|
+
return T.options;
|
|
41
|
+
}, () => j, "SegmentedControl"), F = p(() => {
|
|
42
|
+
let e = A();
|
|
43
|
+
return e !== null && !N().get(e)?.disabled ? e : P().find((e) => !N().get(e)?.disabled);
|
|
44
|
+
}), I = (e) => {
|
|
45
|
+
e !== A() && (T.value === void 0 && k(e), T.onValueChange?.(e));
|
|
46
|
+
}, L = () => {
|
|
47
|
+
if (!M) for (let e of j?.querySelectorAll("input[type=\"radio\"]") ?? []) e.checked = e.value === A();
|
|
48
|
+
}, R = (e) => {
|
|
49
|
+
if (T.disabled || T.readOnly || N().get(e)?.disabled) {
|
|
50
|
+
L();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
I(e), L();
|
|
54
|
+
}, z = (e, t) => {
|
|
55
|
+
let n = j;
|
|
56
|
+
if (!n || T.disabled) return;
|
|
57
|
+
let r = [...n.querySelectorAll("input[type=\"radio\"]")].filter((e) => !e.disabled);
|
|
58
|
+
if (r.length === 0) return;
|
|
59
|
+
let i = Math.max(0, r.indexOf(e.currentTarget)), a = t === "first" ? r[0] : t === "last" ? r.at(-1) : r[(i + t + r.length) % r.length];
|
|
60
|
+
a && (e.preventDefault(), a.focus({ preventScroll: !0 }), a.scrollIntoView({
|
|
61
|
+
block: "nearest",
|
|
62
|
+
inline: "nearest"
|
|
63
|
+
}), T.readOnly || a.click());
|
|
64
|
+
}, B = (e) => {
|
|
65
|
+
e.key === "Home" ? z(e, "first") : e.key === "End" ? z(e, "last") : e.key === "ArrowUp" ? z(e, -1) : e.key === "ArrowDown" ? z(e, 1) : e.key === "ArrowLeft" ? z(e, e.currentTarget.closest("[dir=\"rtl\"]") ? 1 : -1) : e.key === "ArrowRight" && z(e, e.currentTarget.closest("[dir=\"rtl\"]") ? -1 : 1);
|
|
66
|
+
};
|
|
67
|
+
_(() => {
|
|
68
|
+
let e = j, t = e?.ownerDocument.defaultView;
|
|
69
|
+
if (!e || !t) return;
|
|
70
|
+
let n = e.querySelector("input[type=\"radio\"]:checked");
|
|
71
|
+
!T.disabled && !T.readOnly && n && !n.disabled && I(n.value), L();
|
|
72
|
+
let r = /* @__PURE__ */ new Set(), i = (n) => {
|
|
73
|
+
if (n.target !== e.form) return;
|
|
74
|
+
let i = t.setTimeout(() => {
|
|
75
|
+
r.delete(i), !n.defaultPrevented && (T.value === void 0 && I(D), L());
|
|
76
|
+
}, 0);
|
|
77
|
+
r.add(i);
|
|
78
|
+
};
|
|
79
|
+
e.ownerDocument.addEventListener("reset", i, !0), g(() => {
|
|
80
|
+
e.ownerDocument.removeEventListener("reset", i, !0);
|
|
81
|
+
for (let e of r) t.clearTimeout(e);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
let V = () => [
|
|
85
|
+
T.description ? `${l}-description` : "",
|
|
86
|
+
T.error ? `${l}-error` : "",
|
|
87
|
+
T["aria-describedby"]
|
|
88
|
+
].filter(Boolean).join(" ") || void 0;
|
|
89
|
+
return (() => {
|
|
90
|
+
var t = C(), r = t.firstChild, p = r.nextSibling;
|
|
91
|
+
return u((e) => {
|
|
92
|
+
j = e, typeof T.ref == "function" && T.ref(e);
|
|
93
|
+
}, t), c(t, o(E, () => T["aria-label"] === void 0 ? {} : { "aria-label": T["aria-label"] }, {
|
|
94
|
+
get id() {
|
|
95
|
+
return T.id ?? l;
|
|
96
|
+
},
|
|
97
|
+
get form() {
|
|
98
|
+
return T.form;
|
|
99
|
+
},
|
|
100
|
+
get class() {
|
|
101
|
+
return e("sheen-segmented-control", T.class);
|
|
102
|
+
},
|
|
103
|
+
get "aria-labelledby"() {
|
|
104
|
+
return T["aria-labelledby"] ?? `${l}-label`;
|
|
105
|
+
},
|
|
106
|
+
get "aria-describedby"() {
|
|
107
|
+
return V();
|
|
108
|
+
},
|
|
109
|
+
get "aria-invalid"() {
|
|
110
|
+
return T.error ? "true" : void 0;
|
|
111
|
+
},
|
|
112
|
+
get "aria-readonly"() {
|
|
113
|
+
return T.readOnly || void 0;
|
|
114
|
+
},
|
|
115
|
+
get "aria-orientation"() {
|
|
116
|
+
return T.orientation ?? "horizontal";
|
|
117
|
+
},
|
|
118
|
+
get "data-invalid"() {
|
|
119
|
+
return T.error ? "" : void 0;
|
|
120
|
+
},
|
|
121
|
+
get "data-readonly"() {
|
|
122
|
+
return T.readOnly || void 0;
|
|
123
|
+
},
|
|
124
|
+
get "data-size"() {
|
|
125
|
+
return T.size ?? "sm";
|
|
126
|
+
},
|
|
127
|
+
get "data-overflow"() {
|
|
128
|
+
return T.overflowBehavior ?? "scroll";
|
|
129
|
+
},
|
|
130
|
+
get disabled() {
|
|
131
|
+
return T.disabled ?? !1;
|
|
132
|
+
}
|
|
133
|
+
}), !1, !0), s(r, "id", `${l}-label`), a(r, () => T.label, null), a(r, n(f, {
|
|
134
|
+
get when() {
|
|
135
|
+
return T.required;
|
|
136
|
+
},
|
|
137
|
+
get children() {
|
|
138
|
+
return b();
|
|
139
|
+
}
|
|
140
|
+
}), null), a(t, n(f, {
|
|
141
|
+
get when() {
|
|
142
|
+
return T.description;
|
|
143
|
+
},
|
|
144
|
+
get children() {
|
|
145
|
+
var e = x();
|
|
146
|
+
return s(e, "id", `${l}-description`), a(e, () => T.description), e;
|
|
147
|
+
}
|
|
148
|
+
}), p), a(p, n(d, {
|
|
149
|
+
get each() {
|
|
150
|
+
return P();
|
|
151
|
+
},
|
|
152
|
+
children: (e) => {
|
|
153
|
+
let t = y(() => N().get(e));
|
|
154
|
+
if (!t) throw Error("SegmentedControl: missing option during creation");
|
|
155
|
+
let n = () => N().get(e) ?? t, r = h();
|
|
156
|
+
return (() => {
|
|
157
|
+
var t = w(), o = t.firstChild, c = o.nextSibling;
|
|
158
|
+
return o.addEventListener("change", () => R(e)), o.$$click = (e) => {
|
|
159
|
+
T.readOnly && e.preventDefault();
|
|
160
|
+
}, o.$$keydown = B, s(o, "id", `${r}-input`), o.value = e, s(o, "aria-labelledby", `${r}-label`), s(c, "id", `${r}-label`), a(c, () => n().label), i((r) => {
|
|
161
|
+
var i = T.disabled || n().disabled || void 0, a = T.name, c = T.form, l = T.required, u = T.disabled || n().disabled, d = T.readOnly, f = V(), p = !T.disabled && F() === e ? 0 : -1;
|
|
162
|
+
return i !== r.e && s(t, "data-disabled", r.e = i), a !== r.t && s(o, "name", r.t = a), c !== r.a && s(o, "form", r.a = c), l !== r.o && (o.required = r.o = l), u !== r.i && (o.disabled = r.i = u), d !== r.n && (o.readOnly = r.n = d), f !== r.s && s(o, "aria-describedby", r.s = f), p !== r.h && s(o, "tabindex", r.h = p), r;
|
|
163
|
+
}, {
|
|
164
|
+
e: void 0,
|
|
165
|
+
t: void 0,
|
|
166
|
+
a: void 0,
|
|
167
|
+
o: void 0,
|
|
168
|
+
i: void 0,
|
|
169
|
+
n: void 0,
|
|
170
|
+
s: void 0,
|
|
171
|
+
h: void 0
|
|
172
|
+
}), i(() => o.checked = A() === e), t;
|
|
173
|
+
})();
|
|
174
|
+
}
|
|
175
|
+
})), a(t, n(f, {
|
|
176
|
+
get when() {
|
|
177
|
+
return T.error;
|
|
178
|
+
},
|
|
179
|
+
get children() {
|
|
180
|
+
var e = S();
|
|
181
|
+
return s(e, "id", `${l}-error`), a(e, () => T.error), e;
|
|
182
|
+
}
|
|
183
|
+
}), null), t;
|
|
184
|
+
})();
|
|
185
|
+
}
|
|
186
|
+
r(["keydown", "click"]);
|
|
187
|
+
//#endregion
|
|
188
|
+
export { T as SegmentedControl };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> {
|
|
9
|
+
label: string;
|
|
10
|
+
options: readonly SelectOption[];
|
|
11
|
+
value?: string | null;
|
|
12
|
+
defaultValue?: string | null;
|
|
13
|
+
onValueChange?: (value: string | null) => void;
|
|
14
|
+
name?: string;
|
|
15
|
+
form?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Single selection with app-owned values and a contextual listbox. */
|
|
24
|
+
export declare function Select(props: SelectProps): JSX.Element;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { useTheme as e } from "../theme/ThemeProvider.js";
|
|
2
|
+
import { cn as t } from "../utils/cn.js";
|
|
3
|
+
import { useShortcutKeyboardOwner as n } from "./ShortcutProvider.js";
|
|
4
|
+
import { createComponent as r, effect as i, insert as a, mergeProps as o, setAttribute as s, spread as c, template as l, use as u } from "solid-js/web";
|
|
5
|
+
import { For as d, Show as f, createEffect as p, createMemo as m, createSignal as h, createUniqueId as g, onCleanup as _, onMount as v, splitProps as y, untrack as b } from "solid-js";
|
|
6
|
+
import * as x from "@kobalte/core/select";
|
|
7
|
+
//#region src/primitives/Select.tsx
|
|
8
|
+
var S = /*#__PURE__*/ l("<button>"), C = /*#__PURE__*/ l("<span aria-hidden=true> *"), w = /*#__PURE__*/ l("<label class=sheen-field-label>"), T = /*#__PURE__*/ l("<span>"), E = /*#__PURE__*/ l("<span aria-hidden=true>▾"), D = /*#__PURE__*/ l("<select class=sheen-select-native aria-hidden=true tabindex=-1><option value>"), O = /*#__PURE__*/ l("<span class=sheen-field-description>"), ee = /*#__PURE__*/ l("<span class=sheen-field-error>"), te = /*#__PURE__*/ l("<option>"), k = /*#__PURE__*/ l("<p class=sheen-select-empty>");
|
|
9
|
+
function A(l) {
|
|
10
|
+
let [A, j] = y(l, [
|
|
11
|
+
"id",
|
|
12
|
+
"class",
|
|
13
|
+
"label",
|
|
14
|
+
"options",
|
|
15
|
+
"value",
|
|
16
|
+
"defaultValue",
|
|
17
|
+
"onValueChange",
|
|
18
|
+
"name",
|
|
19
|
+
"form",
|
|
20
|
+
"placeholder",
|
|
21
|
+
"description",
|
|
22
|
+
"error",
|
|
23
|
+
"disabled",
|
|
24
|
+
"readOnly",
|
|
25
|
+
"required"
|
|
26
|
+
]), M = e(), N = g(), P = A.defaultValue ?? null, [ne, F] = h(P), [I, L] = h(!1), R = () => A.value === void 0 ? ne() : A.value, [z, B] = h(), [V, H] = h();
|
|
27
|
+
n(z, () => !0), n(V, I);
|
|
28
|
+
let U, W, G = !1, K = !1;
|
|
29
|
+
_(() => {
|
|
30
|
+
G = !0;
|
|
31
|
+
});
|
|
32
|
+
let q = m(() => {
|
|
33
|
+
let e = /* @__PURE__ */ new Map();
|
|
34
|
+
for (let t of A.options) {
|
|
35
|
+
if (!t.value) throw Error("Select: option values must be nonempty");
|
|
36
|
+
if (e.has(t.value)) throw Error(`Select: duplicate option value ${JSON.stringify(t.value)}`);
|
|
37
|
+
e.set(t.value, t);
|
|
38
|
+
}
|
|
39
|
+
return W && (K = !0, W.ownerDocument.defaultView?.queueMicrotask(() => {
|
|
40
|
+
K = !1;
|
|
41
|
+
})), e;
|
|
42
|
+
}), J = [], Y = m(() => {
|
|
43
|
+
let e = [...q().keys()], t = W, n = t?.querySelector("[role=option]:focus");
|
|
44
|
+
if (t && n) {
|
|
45
|
+
let e = n.dataset.key, r = J.indexOf(e ?? "");
|
|
46
|
+
t.ownerDocument.defaultView?.queueMicrotask(() => {
|
|
47
|
+
if (G || !t.isConnected) return;
|
|
48
|
+
let i = t.ownerDocument.activeElement;
|
|
49
|
+
if (i !== t.ownerDocument.body && i !== n && i !== t) return;
|
|
50
|
+
let a = [...t.querySelectorAll("[role=option]")], o = (e) => e.getAttribute("aria-disabled") !== "true", s = a.find((t) => t.dataset.key === e && o(t)), c = Math.max(0, r), l = a.slice(c).find(o) ?? a.slice(0, c).reverse().find(o);
|
|
51
|
+
(s ?? l ?? t).focus({ preventScroll: !0 });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return J = e, e;
|
|
55
|
+
}), X = () => q().get(R() ?? ""), re = () => [A.description ? `${N}-description` : "", A.error ? `${N}-error` : ""].filter(Boolean).join(" ") || void 0, Z = (e) => {
|
|
56
|
+
e !== R() && (A.value === void 0 && F(e), A.onValueChange?.(e));
|
|
57
|
+
}, Q = (e) => {
|
|
58
|
+
!K && e && (A.disabled || A.readOnly || e && q().get(e)?.disabled || (L(!1), Z(e || null)));
|
|
59
|
+
}, $ = () => {
|
|
60
|
+
U && (U.value = X()?.value ?? "");
|
|
61
|
+
};
|
|
62
|
+
p(() => {
|
|
63
|
+
q(), R(), $();
|
|
64
|
+
}), p(() => {
|
|
65
|
+
I() && _(M.layers.register(N));
|
|
66
|
+
}), p(() => {
|
|
67
|
+
A.disabled && L(!1);
|
|
68
|
+
}), v(() => {
|
|
69
|
+
let e = U?.ownerDocument, t = e?.defaultView;
|
|
70
|
+
if (!e || !t) return;
|
|
71
|
+
let n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
72
|
+
if (e.target !== U?.form) return;
|
|
73
|
+
let r = t.setTimeout(() => {
|
|
74
|
+
n.delete(r), !e.defaultPrevented && (A.value === void 0 && Z(P), $());
|
|
75
|
+
}, 0);
|
|
76
|
+
n.add(r);
|
|
77
|
+
};
|
|
78
|
+
e.addEventListener("reset", r, !0), _(() => {
|
|
79
|
+
e.removeEventListener("reset", r, !0);
|
|
80
|
+
for (let e of n) t.clearTimeout(e);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
function ie(e) {
|
|
84
|
+
return (() => {
|
|
85
|
+
var t = S();
|
|
86
|
+
return c(t, o(e, {
|
|
87
|
+
"aria-labelledby": `${N}-label ${N}-value`,
|
|
88
|
+
get "aria-describedby"() {
|
|
89
|
+
return re();
|
|
90
|
+
},
|
|
91
|
+
get "aria-invalid"() {
|
|
92
|
+
return A.error ? !0 : void 0;
|
|
93
|
+
}
|
|
94
|
+
}), !1, !1), t;
|
|
95
|
+
})();
|
|
96
|
+
}
|
|
97
|
+
return r(x.Root, o(j, {
|
|
98
|
+
get id() {
|
|
99
|
+
return A.id ?? `${N}-root`;
|
|
100
|
+
},
|
|
101
|
+
multiple: !1,
|
|
102
|
+
get class() {
|
|
103
|
+
return t("sheen-field sheen-select", A.class);
|
|
104
|
+
},
|
|
105
|
+
get options() {
|
|
106
|
+
return Y();
|
|
107
|
+
},
|
|
108
|
+
optionValue: (e) => e,
|
|
109
|
+
optionTextValue: (e) => q().get(e)?.label ?? e,
|
|
110
|
+
optionDisabled: (e) => q().get(e)?.disabled ?? !1,
|
|
111
|
+
get value() {
|
|
112
|
+
return R();
|
|
113
|
+
},
|
|
114
|
+
get defaultValue() {
|
|
115
|
+
return R() ?? "";
|
|
116
|
+
},
|
|
117
|
+
onChange: Q,
|
|
118
|
+
closeOnSelection: !1,
|
|
119
|
+
disallowEmptySelection: !0,
|
|
120
|
+
get open() {
|
|
121
|
+
return I();
|
|
122
|
+
},
|
|
123
|
+
onOpenChange: (e) => L(e && !A.disabled),
|
|
124
|
+
get disabled() {
|
|
125
|
+
return A.disabled ?? !1;
|
|
126
|
+
},
|
|
127
|
+
get readOnly() {
|
|
128
|
+
return A.readOnly ?? !1;
|
|
129
|
+
},
|
|
130
|
+
get required() {
|
|
131
|
+
return A.required ?? !1;
|
|
132
|
+
},
|
|
133
|
+
get validationState() {
|
|
134
|
+
return A.error ? "invalid" : "valid";
|
|
135
|
+
},
|
|
136
|
+
placement: "bottom-start",
|
|
137
|
+
sameWidth: !0,
|
|
138
|
+
gutter: 4,
|
|
139
|
+
virtualized: !0,
|
|
140
|
+
get children() {
|
|
141
|
+
return [
|
|
142
|
+
(() => {
|
|
143
|
+
var e = w();
|
|
144
|
+
return s(e, "id", `${N}-label`), s(e, "for", `${N}-trigger`), a(e, () => A.label, null), a(e, r(f, {
|
|
145
|
+
get when() {
|
|
146
|
+
return A.required;
|
|
147
|
+
},
|
|
148
|
+
get children() {
|
|
149
|
+
return C();
|
|
150
|
+
}
|
|
151
|
+
}), null), e;
|
|
152
|
+
})(),
|
|
153
|
+
r(x.Trigger, {
|
|
154
|
+
as: ie,
|
|
155
|
+
"data-sheen-select-trigger": "",
|
|
156
|
+
id: `${N}-trigger`,
|
|
157
|
+
ref: B,
|
|
158
|
+
get form() {
|
|
159
|
+
return A.form;
|
|
160
|
+
},
|
|
161
|
+
class: "sheen-input sheen-select-trigger",
|
|
162
|
+
onClick: (e) => {
|
|
163
|
+
!A.disabled && (!e.currentTarget.dataset.pointerType || e.detail === 0) && L((e) => !e);
|
|
164
|
+
},
|
|
165
|
+
get children() {
|
|
166
|
+
return [(() => {
|
|
167
|
+
var e = T();
|
|
168
|
+
return s(e, "id", `${N}-value`), a(e, () => X()?.label ?? A.placeholder ?? M.messages().selectOption), i(() => s(e, "data-placeholder", !X() || void 0)), e;
|
|
169
|
+
})(), E()];
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
(() => {
|
|
173
|
+
var e = D(), t = e.firstChild;
|
|
174
|
+
e.addEventListener("change", (e) => {
|
|
175
|
+
Q(e.currentTarget.value || null), $();
|
|
176
|
+
}), e.addEventListener("invalid", (e) => {
|
|
177
|
+
e.preventDefault(), z()?.focus();
|
|
178
|
+
});
|
|
179
|
+
var n = U;
|
|
180
|
+
return typeof n == "function" ? u(n, e) : U = e, s(e, "id", `${N}-native`), a(e, r(d, {
|
|
181
|
+
get each() {
|
|
182
|
+
return Y();
|
|
183
|
+
},
|
|
184
|
+
children: (e) => (() => {
|
|
185
|
+
var t = te();
|
|
186
|
+
return t.value = e, a(t, () => q().get(e)?.label), i((n) => {
|
|
187
|
+
var r = q().get(e)?.disabled, i = R() === e;
|
|
188
|
+
return r !== n.e && (t.disabled = n.e = r), i !== n.t && (t.selected = n.t = i), n;
|
|
189
|
+
}, {
|
|
190
|
+
e: void 0,
|
|
191
|
+
t: void 0
|
|
192
|
+
}), t;
|
|
193
|
+
})()
|
|
194
|
+
}), null), i((n) => {
|
|
195
|
+
var r = A.name, i = A.form, a = A.required, o = A.disabled, c = A.label, l = !X();
|
|
196
|
+
return r !== n.e && s(e, "name", n.e = r), i !== n.t && s(e, "form", n.t = i), a !== n.a && (e.required = n.a = a), o !== n.o && (e.disabled = n.o = o), c !== n.i && s(e, "aria-label", n.i = c), l !== n.n && (t.selected = n.n = l), n;
|
|
197
|
+
}, {
|
|
198
|
+
e: void 0,
|
|
199
|
+
t: void 0,
|
|
200
|
+
a: void 0,
|
|
201
|
+
o: void 0,
|
|
202
|
+
i: void 0,
|
|
203
|
+
n: void 0
|
|
204
|
+
}), e;
|
|
205
|
+
})(),
|
|
206
|
+
r(f, {
|
|
207
|
+
get when() {
|
|
208
|
+
return A.description;
|
|
209
|
+
},
|
|
210
|
+
get children() {
|
|
211
|
+
var e = O();
|
|
212
|
+
return s(e, "id", `${N}-description`), a(e, () => A.description), e;
|
|
213
|
+
}
|
|
214
|
+
}),
|
|
215
|
+
r(f, {
|
|
216
|
+
get when() {
|
|
217
|
+
return A.error;
|
|
218
|
+
},
|
|
219
|
+
get children() {
|
|
220
|
+
var e = ee();
|
|
221
|
+
return s(e, "id", `${N}-error`), a(e, () => A.error), e;
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
r(f, {
|
|
225
|
+
get when() {
|
|
226
|
+
return M.portal();
|
|
227
|
+
},
|
|
228
|
+
children: (e) => r(x.Portal, {
|
|
229
|
+
get mount() {
|
|
230
|
+
return e();
|
|
231
|
+
},
|
|
232
|
+
get children() {
|
|
233
|
+
return r(x.Content, {
|
|
234
|
+
ref: H,
|
|
235
|
+
"data-kb-top-layer": "true",
|
|
236
|
+
get "aria-hidden"() {
|
|
237
|
+
return !I() || void 0;
|
|
238
|
+
},
|
|
239
|
+
get inert() {
|
|
240
|
+
return !I();
|
|
241
|
+
},
|
|
242
|
+
class: "sheen-select-content",
|
|
243
|
+
get style() {
|
|
244
|
+
return { "z-index": M.layers.zIndex(N) };
|
|
245
|
+
},
|
|
246
|
+
get children() {
|
|
247
|
+
return [r(x.Listbox, {
|
|
248
|
+
ref: (e) => {
|
|
249
|
+
W = e;
|
|
250
|
+
},
|
|
251
|
+
class: "sheen-select-listbox",
|
|
252
|
+
"aria-labelledby": `${N}-label`,
|
|
253
|
+
onFocusIn: (e) => {
|
|
254
|
+
e.target === e.currentTarget && e.currentTarget.querySelector("[role=option][data-highlighted]:not([data-disabled])")?.focus({ preventScroll: !0 });
|
|
255
|
+
},
|
|
256
|
+
scrollToItem: (e) => {
|
|
257
|
+
let t = [...W?.querySelectorAll("[role=option]") ?? []].find((t) => t.dataset.key === e);
|
|
258
|
+
t?.focus({ preventScroll: !0 }), t?.scrollIntoView({
|
|
259
|
+
block: "nearest",
|
|
260
|
+
inline: "nearest"
|
|
261
|
+
});
|
|
262
|
+
},
|
|
263
|
+
children: (e) => r(d, {
|
|
264
|
+
get each() {
|
|
265
|
+
return Y();
|
|
266
|
+
},
|
|
267
|
+
children: (t) => {
|
|
268
|
+
let n = b(() => e().getItem(t));
|
|
269
|
+
if (!n) throw Error(`Select: missing collection item ${JSON.stringify(t)}`);
|
|
270
|
+
return r(x.Item, {
|
|
271
|
+
get item() {
|
|
272
|
+
return e().getItem(t) ?? n;
|
|
273
|
+
},
|
|
274
|
+
class: "sheen-select-option",
|
|
275
|
+
get children() {
|
|
276
|
+
return [
|
|
277
|
+
r(x.ItemLabel, { get children() {
|
|
278
|
+
return q().get(t)?.label;
|
|
279
|
+
} }),
|
|
280
|
+
r(f, {
|
|
281
|
+
get when() {
|
|
282
|
+
return q().get(t)?.description;
|
|
283
|
+
},
|
|
284
|
+
children: (e) => r(x.ItemDescription, {
|
|
285
|
+
class: "sheen-select-option-description",
|
|
286
|
+
get children() {
|
|
287
|
+
return e();
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
}),
|
|
291
|
+
r(x.ItemIndicator, {
|
|
292
|
+
class: "sheen-select-indicator",
|
|
293
|
+
"aria-hidden": "true",
|
|
294
|
+
children: "✓"
|
|
295
|
+
})
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
}), r(f, {
|
|
302
|
+
get when() {
|
|
303
|
+
return !Y().length;
|
|
304
|
+
},
|
|
305
|
+
get children() {
|
|
306
|
+
var e = k();
|
|
307
|
+
return a(e, () => M.messages().noResults), e;
|
|
308
|
+
}
|
|
309
|
+
})];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
export { A as Select };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cn as e } from "../utils/cn.js";
|
|
2
|
+
import { mergeProps as t, spread as n, template as r } from "solid-js/web";
|
|
3
|
+
import { splitProps as i } from "solid-js";
|
|
4
|
+
//#region src/primitives/Separator.tsx
|
|
5
|
+
var a = /*#__PURE__*/ r("<hr>");
|
|
6
|
+
function o(r) {
|
|
7
|
+
let [o, s] = i(r, [
|
|
8
|
+
"class",
|
|
9
|
+
"orientation",
|
|
10
|
+
"decorative"
|
|
11
|
+
]), c = () => o.orientation ?? "horizontal";
|
|
12
|
+
return (() => {
|
|
13
|
+
var r = a();
|
|
14
|
+
return n(r, t(s, {
|
|
15
|
+
get class() {
|
|
16
|
+
return e("sheen-separator", o.class);
|
|
17
|
+
},
|
|
18
|
+
get "data-orientation"() {
|
|
19
|
+
return c();
|
|
20
|
+
},
|
|
21
|
+
get "aria-orientation"() {
|
|
22
|
+
return c();
|
|
23
|
+
},
|
|
24
|
+
get "aria-hidden"() {
|
|
25
|
+
return o.decorative || void 0;
|
|
26
|
+
}
|
|
27
|
+
}), !1, !1), r;
|
|
28
|
+
})();
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { o as Separator };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export interface ShortcutPendingProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
3
|
+
label?: string;
|
|
4
|
+
}
|
|
5
|
+
/** A persistent, single-line status slot; sequence updates never take focus. */
|
|
6
|
+
export declare function ShortcutPending(props: ShortcutPendingProps): JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useTheme as e } from "../theme/ThemeProvider.js";
|
|
2
|
+
import { cn as t } from "../utils/cn.js";
|
|
3
|
+
import { usePendingShortcut as n } from "./ShortcutProvider.js";
|
|
4
|
+
import { Kbd as r } from "./Typography.js";
|
|
5
|
+
import { createComponent as i, insert as a, mergeProps as o, spread as s, template as c } from "solid-js/web";
|
|
6
|
+
import { For as l, splitProps as u } from "solid-js";
|
|
7
|
+
//#region src/primitives/ShortcutPending.tsx
|
|
8
|
+
var d = /*#__PURE__*/ c("<div>"), f = /*#__PURE__*/ c("<span>: ");
|
|
9
|
+
function p(c) {
|
|
10
|
+
let [p, m] = u(c, ["label", "class"]), h = n(), g = e();
|
|
11
|
+
return (() => {
|
|
12
|
+
var e = d();
|
|
13
|
+
return s(e, o(m, {
|
|
14
|
+
get class() {
|
|
15
|
+
return t("sheen-shortcut-pending", p.class);
|
|
16
|
+
},
|
|
17
|
+
role: "status",
|
|
18
|
+
"aria-live": "polite",
|
|
19
|
+
"aria-atomic": "true",
|
|
20
|
+
get "aria-label"() {
|
|
21
|
+
return p.label ?? g.messages().pendingShortcut;
|
|
22
|
+
},
|
|
23
|
+
get "data-pending"() {
|
|
24
|
+
return h().length > 0 || void 0;
|
|
25
|
+
}
|
|
26
|
+
}), !1, !0), a(e, i(l, {
|
|
27
|
+
get each() {
|
|
28
|
+
return h();
|
|
29
|
+
},
|
|
30
|
+
children: (e, t) => (() => {
|
|
31
|
+
var n = f(), o = n.firstChild;
|
|
32
|
+
return a(n, i(r, { get children() {
|
|
33
|
+
return e.displayKeys;
|
|
34
|
+
} }), o), a(n, () => e.label, null), a(n, () => t() < h().length - 1 ? "; " : "", null), n;
|
|
35
|
+
})()
|
|
36
|
+
})), e;
|
|
37
|
+
})();
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { p as ShortcutPending };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Accessor, JSX } from "solid-js";
|
|
2
|
+
import type { PendingShortcut, ShortcutAction, ShortcutBinding, ShortcutDefinition } from "../utils/shortcut-registry.ts";
|
|
3
|
+
export interface ShortcutProviderProps {
|
|
4
|
+
children?: JSX.Element;
|
|
5
|
+
platform?: "mac" | "other";
|
|
6
|
+
development: boolean;
|
|
7
|
+
activeScopes?: readonly string[];
|
|
8
|
+
characterShortcuts?: boolean;
|
|
9
|
+
onError?: (error: unknown) => void;
|
|
10
|
+
}
|
|
11
|
+
/** One provider per document. Dialogs override application-owned base scopes while open. */
|
|
12
|
+
export declare function ShortcutProvider(props: ShortcutProviderProps): JSX.Element;
|
|
13
|
+
/** Register in the nearest provider and release the binding with its Solid owner. */
|
|
14
|
+
export declare function useShortcut(definition: ShortcutDefinition): void;
|
|
15
|
+
/** Internal control binding. Outside a provider the control remains usable without a shortcut. */
|
|
16
|
+
export declare function useShortcutAction(action: Accessor<ShortcutAction | undefined>, run: () => void): Accessor<ShortcutBinding | undefined>;
|
|
17
|
+
/** Read immutable pending candidates to render contextual, localized sequence feedback. */
|
|
18
|
+
export declare function usePendingShortcut(): Accessor<readonly PendingShortcut[]>;
|
|
19
|
+
/** Observe all registered bindings, including inactive scopes and same-scope shadows. */
|
|
20
|
+
export declare function useShortcutBindings(): Accessor<readonly ShortcutBinding[]>;
|
|
21
|
+
/** Execute the current winning registration by its introspected binding ID. */
|
|
22
|
+
export declare function useShortcutCommands(): {
|
|
23
|
+
readonly bindings: Accessor<readonly ShortcutBinding[]>;
|
|
24
|
+
readonly run: (id: number) => boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare function useCharacterShortcuts(): Accessor<boolean>;
|
|
27
|
+
/** Optional integration for modal primitives; standalone dialogs need no shortcut provider. */
|
|
28
|
+
export declare function useModalShortcutScope(scope: Accessor<string>, active: Accessor<boolean>): void;
|
|
29
|
+
/** Internal DOM-bound scope registration. Debug attributes alone do not activate scopes. */
|
|
30
|
+
export declare function useFocusShortcutScope(scope: Accessor<string>, element: Accessor<HTMLElement | undefined>): void;
|
|
31
|
+
/** Optional integration for widgets whose own typeahead/navigation consumes unmodified keys. */
|
|
32
|
+
export declare function useShortcutKeyboardOwner(element: Accessor<HTMLElement | undefined>, active: Accessor<boolean>): void;
|