@oddmash/ui 0.6.0 → 0.7.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 +1 -1
- package/dist/chunk-7VBNUFSJ.js +109 -0
- package/dist/{chunk-WHFF7XSS.js → chunk-EYG4MUDZ.js} +34 -6
- package/dist/{chunk-ITEJEMEF.js → chunk-GDIRM6CK.js} +7 -2
- package/dist/{chunk-Z6HKBFCS.js → chunk-NPHIUQ3M.js} +84 -0
- package/dist/{chunk-FKO6T5XG.js → chunk-YTXTQWA7.js} +1 -1
- package/dist/index.js +5 -5
- package/dist/locale-picker.js +2 -2
- package/dist/select.js +1 -1
- package/dist/styles.css +445 -174
- package/dist/toast-provider.js +2 -2
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +1 -1
- package/dist/tokens.css +220 -0
- package/dist/tokens.d.ts +56 -0
- package/dist/tokens.js +1 -1
- package/package.json +1 -1
- package/tokens/primitive.json +358 -2
- package/tokens/semantic/dark.json +234 -0
- package/tokens/semantic/light.json +234 -0
- package/dist/chunk-LKCU6TJK.js +0 -53
package/README.md
CHANGED
|
@@ -32,6 +32,6 @@ Oddmash UI is for focused tools such as Interaction Inspector: products that nee
|
|
|
32
32
|
|
|
33
33
|
## Current scope
|
|
34
34
|
|
|
35
|
-
Oddmash UI is under active pre-1.0 development. Version 0.
|
|
35
|
+
Oddmash UI is under active pre-1.0 development. Version 0.7.0 centralizes component dimensions, motion and interaction values in JSON, improves Select keyboard and pointer feedback, and adds managed Toast countdowns. The documentation introduces system theme selection, modal search and expandable previews. React 18.3.1 and React 19 remain supported.
|
|
36
36
|
|
|
37
37
|
[Docs](https://oddmash.github.io/oddmash-ui/) · [npm](https://www.npmjs.com/package/@oddmash/ui) · [GitHub](https://github.com/Oddmash/oddmash-ui) · [Contributor guide](CONTRIBUTING.md) · [MIT License](LICENSE)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/generated/tokens.ts
|
|
4
|
+
var tokens = {
|
|
5
|
+
"color.bg": "var(--om-semantic-color-bg)",
|
|
6
|
+
"color.surface": "var(--om-semantic-color-surface)",
|
|
7
|
+
"color.text": "var(--om-semantic-color-text)",
|
|
8
|
+
"color.muted": "var(--om-semantic-color-muted)",
|
|
9
|
+
"color.border": "var(--om-semantic-color-border)",
|
|
10
|
+
"color.accent": "var(--om-semantic-color-accent)",
|
|
11
|
+
"color.accent-hover": "var(--om-semantic-color-accent-hover)",
|
|
12
|
+
"color.on-accent": "var(--om-semantic-color-on-accent)",
|
|
13
|
+
"color.danger": "var(--om-semantic-color-danger)",
|
|
14
|
+
"color.success": "var(--om-semantic-color-success)",
|
|
15
|
+
"color.warning": "var(--om-semantic-color-warning)",
|
|
16
|
+
"color.info": "var(--om-semantic-color-info)",
|
|
17
|
+
"color.focus": "var(--om-semantic-color-focus)",
|
|
18
|
+
"color.border-subtle": "var(--om-semantic-color-border-subtle)",
|
|
19
|
+
"color.action": "var(--om-semantic-color-action)",
|
|
20
|
+
"color.on-action": "var(--om-semantic-color-on-action)",
|
|
21
|
+
"color.action-hover": "var(--om-semantic-color-action-hover)",
|
|
22
|
+
"space.xs": "var(--om-semantic-space-xs)",
|
|
23
|
+
"space.sm": "var(--om-semantic-space-sm)",
|
|
24
|
+
"space.md": "var(--om-semantic-space-md)",
|
|
25
|
+
"space.lg": "var(--om-semantic-space-lg)",
|
|
26
|
+
"space.xl": "var(--om-semantic-space-xl)",
|
|
27
|
+
"radius.sm": "var(--om-semantic-radius-sm)",
|
|
28
|
+
"radius.md": "var(--om-semantic-radius-md)",
|
|
29
|
+
"radius.lg": "var(--om-semantic-radius-lg)",
|
|
30
|
+
"radius.xl": "var(--om-semantic-radius-xl)",
|
|
31
|
+
"radius.2xl": "var(--om-semantic-radius-2xl)",
|
|
32
|
+
"radius.pill": "var(--om-semantic-radius-pill)",
|
|
33
|
+
"font.family": "var(--om-semantic-font-family)",
|
|
34
|
+
"font.size": "var(--om-semantic-font-size)",
|
|
35
|
+
"font.small": "var(--om-semantic-font-small)",
|
|
36
|
+
"font.heading": "var(--om-semantic-font-heading)",
|
|
37
|
+
"font.weight": "var(--om-semantic-font-weight)",
|
|
38
|
+
"font.line": "var(--om-semantic-font-line)",
|
|
39
|
+
"font.mono-family": "var(--om-semantic-font-mono-family)",
|
|
40
|
+
"border.default": "var(--om-semantic-border-default)",
|
|
41
|
+
"border.width": "var(--om-semantic-border-width)",
|
|
42
|
+
"border.style": "var(--om-semantic-border-style)",
|
|
43
|
+
"shadow": "var(--om-semantic-shadow)",
|
|
44
|
+
"motion.duration": "var(--om-semantic-motion-duration)",
|
|
45
|
+
"motion.ease": "var(--om-semantic-motion-ease)",
|
|
46
|
+
"control.height": "var(--om-semantic-control-height)",
|
|
47
|
+
"control.small": "var(--om-semantic-control-small)",
|
|
48
|
+
"control.touch-target": "var(--om-semantic-control-touch-target)",
|
|
49
|
+
"overlay": "var(--om-semantic-overlay)",
|
|
50
|
+
"dimension.px-2": "var(--om-semantic-dimension-px-2)",
|
|
51
|
+
"dimension.px-1": "var(--om-semantic-dimension-px-1)",
|
|
52
|
+
"dimension.px-440": "var(--om-semantic-dimension-px-440)",
|
|
53
|
+
"dimension.px-32": "var(--om-semantic-dimension-px-32)",
|
|
54
|
+
"dimension.px-3": "var(--om-semantic-dimension-px-3)",
|
|
55
|
+
"dimension.px-480": "var(--om-semantic-dimension-px-480)",
|
|
56
|
+
"dimension.px-240": "var(--om-semantic-dimension-px-240)",
|
|
57
|
+
"dimension.rem-1": "var(--om-semantic-dimension-rem-1)",
|
|
58
|
+
"dimension.rem-0-5": "var(--om-semantic-dimension-rem-0-5)",
|
|
59
|
+
"dimension.rem-0-28": "var(--om-semantic-dimension-rem-0-28)",
|
|
60
|
+
"dimension.rem-0-375": "var(--om-semantic-dimension-rem-0-375)",
|
|
61
|
+
"dimension.rem-2-25": "var(--om-semantic-dimension-rem-2-25)",
|
|
62
|
+
"dimension.rem-1-25": "var(--om-semantic-dimension-rem-1-25)",
|
|
63
|
+
"dimension.rem-0-75": "var(--om-semantic-dimension-rem-0-75)",
|
|
64
|
+
"dimension.rem-1-125": "var(--om-semantic-dimension-rem-1-125)",
|
|
65
|
+
"dimension.rem-2-5": "var(--om-semantic-dimension-rem-2-5)",
|
|
66
|
+
"dimension.px-4": "var(--om-semantic-dimension-px-4)",
|
|
67
|
+
"dimension.rem-12": "var(--om-semantic-dimension-rem-12)",
|
|
68
|
+
"dimension.rem-22": "var(--om-semantic-dimension-rem-22)",
|
|
69
|
+
"dimension.px-0": "var(--om-semantic-dimension-px-0)",
|
|
70
|
+
"dimension.px-20": "var(--om-semantic-dimension-px-20)",
|
|
71
|
+
"dimension.px-28": "var(--om-semantic-dimension-px-28)",
|
|
72
|
+
"dimension.px-5": "var(--om-semantic-dimension-px-5)",
|
|
73
|
+
"dimension.px-16": "var(--om-semantic-dimension-px-16)",
|
|
74
|
+
"dimension.px-12": "var(--om-semantic-dimension-px-12)",
|
|
75
|
+
"dimension.px-8": "var(--om-semantic-dimension-px-8)",
|
|
76
|
+
"dimension.px-360": "var(--om-semantic-dimension-px-360)",
|
|
77
|
+
"dimension.rem-72": "var(--om-semantic-dimension-rem-72)",
|
|
78
|
+
"dimension.px-48": "var(--om-semantic-dimension-px-48)",
|
|
79
|
+
"dimension.rem-4": "var(--om-semantic-dimension-rem-4)",
|
|
80
|
+
"dimension.px-44": "var(--om-semantic-dimension-px-44)",
|
|
81
|
+
"duration.ms-160": "var(--om-semantic-duration-ms-160)",
|
|
82
|
+
"duration.ms-750": "var(--om-semantic-duration-ms-750)",
|
|
83
|
+
"duration.ms-240": "var(--om-semantic-duration-ms-240)",
|
|
84
|
+
"duration.ms-180": "var(--om-semantic-duration-ms-180)",
|
|
85
|
+
"duration.ms-120": "var(--om-semantic-duration-ms-120)",
|
|
86
|
+
"duration.ms-900": "var(--om-semantic-duration-ms-900)",
|
|
87
|
+
"duration.ms-220": "var(--om-semantic-duration-ms-220)",
|
|
88
|
+
"duration.ms-140": "var(--om-semantic-duration-ms-140)",
|
|
89
|
+
"duration.ms-1600": "var(--om-semantic-duration-ms-1600)",
|
|
90
|
+
"duration.ms-950": "var(--om-semantic-duration-ms-950)",
|
|
91
|
+
"number.opacity-0-5": "var(--om-semantic-number-opacity-0-5)",
|
|
92
|
+
"number.layer-1000": "var(--om-semantic-number-layer-1000)",
|
|
93
|
+
"number.layer-1001": "var(--om-semantic-number-layer-1001)",
|
|
94
|
+
"number.weight-650": "var(--om-semantic-number-weight-650)",
|
|
95
|
+
"number.layer-2": "var(--om-semantic-number-layer-2)",
|
|
96
|
+
"number.layer-900": "var(--om-semantic-number-layer-900)",
|
|
97
|
+
"number.weight-600": "var(--om-semantic-number-weight-600)",
|
|
98
|
+
"number.opacity-0-65": "var(--om-semantic-number-opacity-0-65)",
|
|
99
|
+
"easing.curve-0-22-0-8-0-3-1": "var(--om-semantic-easing-curve-0-22-0-8-0-3-1)",
|
|
100
|
+
"easing.curve-0-4-0-0-2-1": "var(--om-semantic-easing-curve-0-4-0-0-2-1)",
|
|
101
|
+
"easing.curve-0-2-0-8-0-2-1": "var(--om-semantic-easing-curve-0-2-0-8-0-2-1)",
|
|
102
|
+
"easing.curve-0-45-0-0-55-1": "var(--om-semantic-easing-curve-0-45-0-0-55-1)",
|
|
103
|
+
"focus.width": "var(--om-semantic-focus-width)",
|
|
104
|
+
"focus.offset": "var(--om-semantic-focus-offset)"
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
tokens
|
|
109
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Toast,
|
|
4
4
|
ToastViewport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GDIRM6CK.js";
|
|
6
6
|
|
|
7
7
|
// src/toast-provider.tsx
|
|
8
8
|
import {
|
|
@@ -64,20 +64,47 @@ var ManagedToast = ({ entry, paused, dismissLabel, register, open, dismiss, exit
|
|
|
64
64
|
return () => view.cancelAnimationFrame(frame);
|
|
65
65
|
}, [id, phase, open]);
|
|
66
66
|
useEffect(() => {
|
|
67
|
-
|
|
68
|
-
const view =
|
|
69
|
-
|
|
67
|
+
const node = root.current;
|
|
68
|
+
const view = node?.ownerDocument.defaultView;
|
|
69
|
+
const duration = entry.duration;
|
|
70
|
+
if (phase !== "open" || !node || !view || duration === null || remaining.current === null) return;
|
|
70
71
|
const time = remaining.current;
|
|
72
|
+
const updateProgress = (value) => {
|
|
73
|
+
node.style.setProperty("--om-toast-remaining", String(Math.min(1, Math.max(0, value / duration))));
|
|
74
|
+
};
|
|
75
|
+
updateProgress(time);
|
|
76
|
+
if (paused) return;
|
|
71
77
|
const started = Date.now();
|
|
78
|
+
const reduced = typeof view.matchMedia === "function" ? view.matchMedia("(prefers-reduced-motion: reduce)") : void 0;
|
|
79
|
+
const getRemaining = () => Math.max(0, time - (Date.now() - started));
|
|
80
|
+
let frame;
|
|
81
|
+
let progressTimeout;
|
|
82
|
+
const update = () => {
|
|
83
|
+
const value = getRemaining();
|
|
84
|
+
updateProgress(value);
|
|
85
|
+
if (value > 0) schedule();
|
|
86
|
+
};
|
|
87
|
+
const schedule = () => {
|
|
88
|
+
if (!reduced?.matches && typeof view.requestAnimationFrame === "function" && typeof view.cancelAnimationFrame === "function") {
|
|
89
|
+
frame = view.requestAnimationFrame(update);
|
|
90
|
+
} else {
|
|
91
|
+
progressTimeout = view.setTimeout(update, Math.min(1e3, getRemaining()));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
schedule();
|
|
72
95
|
const timeout = view.setTimeout(() => {
|
|
73
96
|
remaining.current = 0;
|
|
97
|
+
updateProgress(0);
|
|
74
98
|
dismiss(id);
|
|
75
99
|
}, time);
|
|
76
100
|
return () => {
|
|
77
101
|
view.clearTimeout(timeout);
|
|
78
|
-
|
|
102
|
+
if (frame !== void 0) view.cancelAnimationFrame(frame);
|
|
103
|
+
if (progressTimeout !== void 0) view.clearTimeout(progressTimeout);
|
|
104
|
+
remaining.current = getRemaining();
|
|
105
|
+
updateProgress(remaining.current);
|
|
79
106
|
};
|
|
80
|
-
}, [id, phase, paused, dismiss]);
|
|
107
|
+
}, [id, phase, paused, dismiss, entry.duration]);
|
|
81
108
|
useEffect(() => {
|
|
82
109
|
if (phase !== "closing") return;
|
|
83
110
|
const node = root.current;
|
|
@@ -106,6 +133,7 @@ var ManagedToast = ({ entry, paused, dismissLabel, register, open, dismiss, exit
|
|
|
106
133
|
title: options.title,
|
|
107
134
|
tone: options.tone,
|
|
108
135
|
icon: options.icon,
|
|
136
|
+
progress: entry.duration === null ? void 0 : 1,
|
|
109
137
|
dismissLabel: options.dismissLabel ?? dismissLabel,
|
|
110
138
|
onDismiss: () => dismiss(id),
|
|
111
139
|
"data-toast-id": id,
|
|
@@ -31,6 +31,7 @@ var ToastViewport = /* @__PURE__ */ forwardRef(
|
|
|
31
31
|
let frame = 0;
|
|
32
32
|
const observed = /* @__PURE__ */ new Set();
|
|
33
33
|
const resize = typeof browser.ResizeObserver === "undefined" ? void 0 : new browser.ResizeObserver(() => schedule());
|
|
34
|
+
resize?.observe(viewport);
|
|
34
35
|
const layout = () => {
|
|
35
36
|
const regions = Array.from(viewport.children).filter(
|
|
36
37
|
(element) => element instanceof browser.HTMLElement && element.classList.contains("om-toast-region")
|
|
@@ -54,7 +55,8 @@ var ToastViewport = /* @__PURE__ */ forwardRef(
|
|
|
54
55
|
}
|
|
55
56
|
const fullHeight = active.reduce((sum, { card }) => sum + card.offsetHeight + STACK_GAP, 0) - STACK_GAP;
|
|
56
57
|
const frontHeight = active.at(-1)?.card.offsetHeight ?? 0;
|
|
57
|
-
const
|
|
58
|
+
const blockLimit = browser.getComputedStyle(viewport).maxBlockSize;
|
|
59
|
+
const maxHeight = /^\d+(?:\.\d+)?px$/.test(blockLimit) ? Math.min(browser.innerHeight - 32, Number.parseFloat(blockLimit)) : browser.innerHeight - 32;
|
|
58
60
|
const expanded = reduced.matches || !hover.matches || pointer || focused || frontHeight + 2 * STACK_PEEK > maxHeight;
|
|
59
61
|
const overflow = expanded && fullHeight > maxHeight;
|
|
60
62
|
let offset = 0;
|
|
@@ -153,6 +155,7 @@ var Toast = /* @__PURE__ */ forwardRef(
|
|
|
153
155
|
dismissLabel = "Dismiss notification",
|
|
154
156
|
tone = "neutral",
|
|
155
157
|
icon,
|
|
158
|
+
progress,
|
|
156
159
|
children,
|
|
157
160
|
className,
|
|
158
161
|
...props
|
|
@@ -169,6 +172,7 @@ var Toast = /* @__PURE__ */ forwardRef(
|
|
|
169
172
|
}, [open]);
|
|
170
173
|
const visible = open || present;
|
|
171
174
|
const urgent = tone === "danger" || tone === "error";
|
|
175
|
+
const fraction = progress !== void 0 && Number.isFinite(progress) ? Math.min(1, Math.max(0, progress)) : void 0;
|
|
172
176
|
return /* @__PURE__ */ jsx("div", { ...props, ref, className: cx("om-toast-region", className), "data-state": open ? "open" : visible ? "closing" : "closed", children: /* @__PURE__ */ jsxs("div", { className: visible ? "om-toast" : void 0, "data-tone": visible ? tone : void 0, "data-state": open ? "open" : "closing", children: [
|
|
173
177
|
visible && icon !== null && /* @__PURE__ */ jsx("span", { className: "om-toast-icon", "aria-hidden": "true", ref: (element) => {
|
|
174
178
|
element?.setAttribute("inert", "");
|
|
@@ -184,7 +188,8 @@ var Toast = /* @__PURE__ */ forwardRef(
|
|
|
184
188
|
children && /* @__PURE__ */ jsx("div", { children })
|
|
185
189
|
] }),
|
|
186
190
|
open && /* @__PURE__ */ jsx("button", { type: "button", onClick: onDismiss, "aria-label": dismissLabel, children: /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", children: /* @__PURE__ */ jsx("path", { d: "m6 6 12 12M18 6 6 18" }) }) }),
|
|
187
|
-
!open && visible && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "om-toast-close-placeholder" })
|
|
191
|
+
!open && visible && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "om-toast-close-placeholder" }),
|
|
192
|
+
visible && fraction !== void 0 && /* @__PURE__ */ jsx("span", { className: "om-toast-progress", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { style: { transform: `scaleX(var(--om-toast-remaining, ${fraction}))` } }) })
|
|
188
193
|
] }) });
|
|
189
194
|
}
|
|
190
195
|
);
|
|
@@ -35,6 +35,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
35
35
|
const [internal, setInternal] = useState(defaultValue);
|
|
36
36
|
const [open, setOpen] = useState(false);
|
|
37
37
|
const [active, setActive] = useState();
|
|
38
|
+
const [keyboardActive, setKeyboardActive] = useState(false);
|
|
38
39
|
const selected = options.findIndex(
|
|
39
40
|
(option) => option.value === (value ?? internal)
|
|
40
41
|
);
|
|
@@ -46,6 +47,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
46
47
|
const close = () => {
|
|
47
48
|
setOpen(false);
|
|
48
49
|
setActive(void 0);
|
|
50
|
+
setKeyboardActive(false);
|
|
49
51
|
search.current.text = "";
|
|
50
52
|
};
|
|
51
53
|
useEffect(() => {
|
|
@@ -58,6 +60,78 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
58
60
|
scope?.addEventListener("pointerdown", dismiss, true);
|
|
59
61
|
return () => scope?.removeEventListener("pointerdown", dismiss, true);
|
|
60
62
|
}, [expanded]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const menu = list.current;
|
|
65
|
+
const trigger = root.current?.querySelector("button");
|
|
66
|
+
const view = menu?.ownerDocument.defaultView;
|
|
67
|
+
if (!expanded || !menu || !trigger || !view) return;
|
|
68
|
+
const preventScrollBleed = (event) => {
|
|
69
|
+
if (event.deltaY < 0 && menu.scrollTop <= 0 || event.deltaY > 0 && menu.scrollTop + menu.clientHeight >= menu.scrollHeight - 1) event.preventDefault();
|
|
70
|
+
};
|
|
71
|
+
menu.addEventListener("wheel", preventScrollBleed, { passive: false });
|
|
72
|
+
const viewport = view.visualViewport;
|
|
73
|
+
const position = () => {
|
|
74
|
+
const anchor = trigger.getBoundingClientRect();
|
|
75
|
+
const top = viewport?.offsetTop ?? 0;
|
|
76
|
+
const left = viewport?.offsetLeft ?? 0;
|
|
77
|
+
const right = left + (viewport?.width ?? view.innerWidth);
|
|
78
|
+
const bottom = top + (viewport?.height ?? view.innerHeight);
|
|
79
|
+
if (anchor.bottom <= top || anchor.top >= bottom) {
|
|
80
|
+
close();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const below = Math.max(0, bottom - anchor.bottom);
|
|
84
|
+
const above = Math.max(0, anchor.top - top);
|
|
85
|
+
const opensAbove = below < menu.scrollHeight && above > below;
|
|
86
|
+
const width = Math.min(anchor.width, right - left);
|
|
87
|
+
menu.dataset.placement = opensAbove ? "above" : "below";
|
|
88
|
+
menu.style.setProperty("--om-select-anchor-left", `${Math.max(left, Math.min(anchor.left, right - width))}px`);
|
|
89
|
+
menu.style.setProperty("--om-select-anchor-top", `${Math.max(top, anchor.bottom)}px`);
|
|
90
|
+
menu.style.setProperty("--om-select-anchor-bottom", `${view.innerHeight - Math.min(anchor.top, bottom)}px`);
|
|
91
|
+
menu.style.setProperty("--om-select-anchor-width", `${width}px`);
|
|
92
|
+
menu.style.setProperty("--om-select-available", `${opensAbove ? above : below}px`);
|
|
93
|
+
};
|
|
94
|
+
let positioned = false;
|
|
95
|
+
if (typeof menu.showPopover === "function") {
|
|
96
|
+
menu.setAttribute("popover", "manual");
|
|
97
|
+
try {
|
|
98
|
+
const anchor = trigger.getBoundingClientRect();
|
|
99
|
+
const viewportTop = viewport?.offsetTop ?? 0;
|
|
100
|
+
const viewportBottom = viewportTop + (viewport?.height ?? view.innerHeight);
|
|
101
|
+
if (trigger.matches(":focus") && (anchor.bottom <= viewportTop || anchor.top >= viewportBottom)) trigger.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "instant" });
|
|
102
|
+
menu.showPopover();
|
|
103
|
+
positioned = true;
|
|
104
|
+
menu.dataset.positioned = "true";
|
|
105
|
+
position();
|
|
106
|
+
} catch {
|
|
107
|
+
menu.removeAttribute("popover");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const onScroll = (event) => {
|
|
111
|
+
if (event.target !== menu) position();
|
|
112
|
+
};
|
|
113
|
+
const resize = positioned && typeof ResizeObserver !== "undefined" ? new ResizeObserver(position) : void 0;
|
|
114
|
+
if (positioned) {
|
|
115
|
+
view.addEventListener("resize", position);
|
|
116
|
+
view.addEventListener("scroll", onScroll, true);
|
|
117
|
+
viewport?.addEventListener("resize", position);
|
|
118
|
+
viewport?.addEventListener("scroll", position);
|
|
119
|
+
resize?.observe(trigger);
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
menu.removeEventListener("wheel", preventScrollBleed);
|
|
123
|
+
if (!positioned) return;
|
|
124
|
+
resize?.disconnect();
|
|
125
|
+
view.removeEventListener("resize", position);
|
|
126
|
+
view.removeEventListener("scroll", onScroll, true);
|
|
127
|
+
viewport?.removeEventListener("resize", position);
|
|
128
|
+
viewport?.removeEventListener("scroll", position);
|
|
129
|
+
if (menu.matches(":popover-open")) menu.hidePopover();
|
|
130
|
+
menu.removeAttribute("popover");
|
|
131
|
+
delete menu.dataset.positioned;
|
|
132
|
+
delete menu.dataset.placement;
|
|
133
|
+
};
|
|
134
|
+
}, [expanded]);
|
|
61
135
|
useEffect(() => {
|
|
62
136
|
const menu = list.current;
|
|
63
137
|
const item = activeIndex === void 0 ? void 0 : menu?.children[activeIndex];
|
|
@@ -96,6 +170,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
96
170
|
close();
|
|
97
171
|
} else if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
98
172
|
event.preventDefault();
|
|
173
|
+
setKeyboardActive(true);
|
|
99
174
|
const previous = activeIndex === void 0 ? -1 : enabled.indexOf(activeIndex);
|
|
100
175
|
const next = key === "Home" ? enabled[0] : key === "End" ? enabled.at(-1) : previous < 0 ? initial(key === "ArrowUp") : enabled[Math.max(
|
|
101
176
|
0,
|
|
@@ -110,6 +185,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
110
185
|
event.preventDefault();
|
|
111
186
|
if (expanded) choose(activeIndex);
|
|
112
187
|
else {
|
|
188
|
+
setKeyboardActive(true);
|
|
113
189
|
setActive(initial());
|
|
114
190
|
setOpen(true);
|
|
115
191
|
}
|
|
@@ -128,6 +204,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
128
204
|
);
|
|
129
205
|
if (match === void 0) return;
|
|
130
206
|
event.preventDefault();
|
|
207
|
+
setKeyboardActive(true);
|
|
131
208
|
setActive(match);
|
|
132
209
|
setOpen(true);
|
|
133
210
|
}
|
|
@@ -157,6 +234,7 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
157
234
|
if (event.defaultPrevented || !enabled.length) return;
|
|
158
235
|
if (expanded) close();
|
|
159
236
|
else {
|
|
237
|
+
setKeyboardActive(false);
|
|
160
238
|
setActive(initial());
|
|
161
239
|
setOpen(true);
|
|
162
240
|
}
|
|
@@ -191,6 +269,12 @@ var Select = /* @__PURE__ */ forwardRef(
|
|
|
191
269
|
"aria-disabled": option.disabled || void 0,
|
|
192
270
|
lang: option.lang,
|
|
193
271
|
"data-active": activeIndex === index || void 0,
|
|
272
|
+
"data-keyboard-active": keyboardActive && activeIndex === index || void 0,
|
|
273
|
+
onPointerMove: (event) => {
|
|
274
|
+
if (option.disabled || event.pointerType === "touch") return;
|
|
275
|
+
setKeyboardActive(false);
|
|
276
|
+
setActive(index);
|
|
277
|
+
},
|
|
194
278
|
onMouseDown: (event) => event.preventDefault(),
|
|
195
279
|
onClick: () => choose(index),
|
|
196
280
|
children: option.label
|
package/dist/index.js
CHANGED
|
@@ -45,11 +45,11 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
ToastProvider,
|
|
47
47
|
useToast
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-EYG4MUDZ.js";
|
|
49
49
|
import {
|
|
50
50
|
Toast,
|
|
51
51
|
ToastViewport
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-GDIRM6CK.js";
|
|
53
53
|
import {
|
|
54
54
|
Badge
|
|
55
55
|
} from "./chunk-KU7UNDPK.js";
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
} from "./chunk-4YJMCYQW.js";
|
|
62
62
|
import {
|
|
63
63
|
tokens
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-7VBNUFSJ.js";
|
|
65
65
|
import {
|
|
66
66
|
Textarea
|
|
67
67
|
} from "./chunk-B3VPCEGX.js";
|
|
@@ -98,10 +98,10 @@ import {
|
|
|
98
98
|
} from "./chunk-OUFCQ2JE.js";
|
|
99
99
|
import {
|
|
100
100
|
LocalePicker
|
|
101
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-YTXTQWA7.js";
|
|
102
102
|
import {
|
|
103
103
|
Select
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-NPHIUQ3M.js";
|
|
105
105
|
import {
|
|
106
106
|
ClipboardButton,
|
|
107
107
|
copyText
|
package/dist/locale-picker.js
CHANGED