@oddmash/ui 0.3.0 → 0.4.1
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 +5 -2
- package/dist/accordion.js +1 -1
- package/dist/alert.d.ts +19 -3
- package/dist/alert.js +7 -3
- package/dist/chunk-BMVVSFAU.js +68 -0
- package/dist/chunk-ITEJEMEF.js +196 -0
- package/dist/{chunk-7A5VK567.js → chunk-OGJ3KIBM.js} +2 -0
- package/dist/{chunk-33GOGIXE.js → chunk-Q56KMGGG.js} +1 -1
- package/dist/chunk-U2Y2DJXG.js +14 -0
- package/dist/chunk-WODRU2UN.js +69 -0
- package/dist/{chunk-CWGH75FA.js → chunk-Z6HKBFCS.js} +3 -11
- package/dist/command-palette.d.ts +24 -0
- package/dist/command-palette.js +10 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +42 -31
- package/dist/select.d.ts +8 -10
- package/dist/select.js +3 -4
- package/dist/slider.d.ts +8 -0
- package/dist/slider.js +8 -0
- package/dist/styles.css +429 -38
- package/dist/toast.d.ts +7 -4
- package/dist/toast.js +5 -3
- package/dist/tokens.css +15 -7
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.js +1 -1
- package/package.json +15 -4
- package/tokens/primitive.json +25 -11
- package/tokens/semantic/dark.json +8 -0
- package/tokens/semantic/light.json +8 -0
- package/dist/chunk-2YEAAOWL.js +0 -24
- package/dist/chunk-WJ7V6SRX.js +0 -38
package/README.md
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
Oddmash UI is the shared interface foundation for Oddmash products. It gives small React developer tools a consistent visual language, accessible interaction patterns, and themeable design tokens without deciding the product layout for them.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/playground-dark.png">
|
|
9
|
+
<img alt="Oddmash UI documentation with its patterns and component index" src="docs/assets/playground.png">
|
|
10
|
+
</picture>
|
|
8
11
|
|
|
9
12
|
## What it provides
|
|
10
13
|
|
|
@@ -28,6 +31,6 @@ Oddmash UI is for focused tools such as Interaction Inspector: products that nee
|
|
|
28
31
|
|
|
29
32
|
## Current scope
|
|
30
33
|
|
|
31
|
-
Oddmash UI is under active pre-1.0 development. Version 0.
|
|
34
|
+
Oddmash UI is under active pre-1.0 development. Version 0.4.1 includes 24 component families, including Toast.
|
|
32
35
|
|
|
33
36
|
[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)
|
package/dist/accordion.js
CHANGED
package/dist/alert.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { DialogContentProps } from './dialog.js';
|
|
4
|
+
import '@radix-ui/react-dialog';
|
|
3
5
|
|
|
4
6
|
type AlertProps = ComponentPropsWithoutRef<'div'> & {
|
|
5
7
|
tone?: 'neutral' | 'danger';
|
|
@@ -7,6 +9,20 @@ type AlertProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
7
9
|
declare const Alert: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
10
|
tone?: "neutral" | "danger";
|
|
9
11
|
} & react.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
type AlertDialogProps = Omit<DialogContentProps, 'title' | 'children' | 'role' | 'onEscapeKeyDown' | 'onPointerDownOutside' | 'onInteractOutside'> & {
|
|
13
|
+
open: boolean;
|
|
14
|
+
title: string;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
confirmLabel?: string;
|
|
17
|
+
onConfirm: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare const AlertDialog: react.ForwardRefExoticComponent<Omit<DialogContentProps, "title" | "role" | "children" | "onEscapeKeyDown" | "onPointerDownOutside" | "onInteractOutside"> & {
|
|
20
|
+
open: boolean;
|
|
21
|
+
title: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
confirmLabel?: string;
|
|
24
|
+
onConfirm: () => void;
|
|
25
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
10
26
|
|
|
11
|
-
export { Alert };
|
|
12
|
-
export type { AlertProps };
|
|
27
|
+
export { Alert, AlertDialog };
|
|
28
|
+
export type { AlertDialogProps, AlertProps };
|
package/dist/alert.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
Alert
|
|
4
|
-
|
|
3
|
+
Alert,
|
|
4
|
+
AlertDialog
|
|
5
|
+
} from "./chunk-BMVVSFAU.js";
|
|
6
|
+
import "./chunk-3TIYT55P.js";
|
|
7
|
+
import "./chunk-ME34NDSX.js";
|
|
5
8
|
import "./chunk-54STG2JB.js";
|
|
6
9
|
export {
|
|
7
|
-
Alert
|
|
10
|
+
Alert,
|
|
11
|
+
AlertDialog
|
|
8
12
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Button
|
|
4
|
+
} from "./chunk-3TIYT55P.js";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogTitle
|
|
10
|
+
} from "./chunk-ME34NDSX.js";
|
|
11
|
+
import {
|
|
12
|
+
cx
|
|
13
|
+
} from "./chunk-54STG2JB.js";
|
|
14
|
+
|
|
15
|
+
// src/alert.tsx
|
|
16
|
+
import { forwardRef, useRef } from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var Alert = /* @__PURE__ */ forwardRef(
|
|
19
|
+
({ className, tone = "neutral", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
ref,
|
|
24
|
+
"data-tone": tone,
|
|
25
|
+
className: cx("om-alert", className)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
Alert.displayName = "Alert";
|
|
30
|
+
var AlertDialog = /* @__PURE__ */ forwardRef(
|
|
31
|
+
({ open, title, children, confirmLabel = "OK", onConfirm, className, onOpenAutoFocus, onCloseAutoFocus, ...props }, ref) => {
|
|
32
|
+
const previousFocus = useRef(null);
|
|
33
|
+
return /* @__PURE__ */ jsx(Dialog, { open, children: /* @__PURE__ */ jsxs(
|
|
34
|
+
DialogContent,
|
|
35
|
+
{
|
|
36
|
+
...props,
|
|
37
|
+
ref,
|
|
38
|
+
role: "alertdialog",
|
|
39
|
+
className: cx("om-alert-dialog", className),
|
|
40
|
+
onOpenAutoFocus: (event) => {
|
|
41
|
+
previousFocus.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
42
|
+
onOpenAutoFocus?.(event);
|
|
43
|
+
},
|
|
44
|
+
onCloseAutoFocus: (event) => {
|
|
45
|
+
onCloseAutoFocus?.(event);
|
|
46
|
+
if (!event.defaultPrevented && previousFocus.current?.isConnected) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
previousFocus.current.focus();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
onEscapeKeyDown: (event) => event.preventDefault(),
|
|
52
|
+
onPointerDownOutside: (event) => event.preventDefault(),
|
|
53
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
56
|
+
/* @__PURE__ */ jsx(DialogDescription, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "om-alert-dialog-description", children }) }),
|
|
57
|
+
/* @__PURE__ */ jsx("div", { className: "om-alert-dialog-actions", children: /* @__PURE__ */ jsx(Button, { onClick: onConfirm, children: confirmLabel }) })
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
) });
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
AlertDialog.displayName = "AlertDialog";
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
Alert,
|
|
67
|
+
AlertDialog
|
|
68
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/toast.tsx
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
useEffect,
|
|
10
|
+
useImperativeHandle,
|
|
11
|
+
useRef,
|
|
12
|
+
useState
|
|
13
|
+
} from "react";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var EXIT_DURATION = 220;
|
|
16
|
+
var STACK_GAP = 8;
|
|
17
|
+
var STACK_PEEK = 12;
|
|
18
|
+
var ToastViewport = /* @__PURE__ */ forwardRef(
|
|
19
|
+
({ className, ...props }, ref) => {
|
|
20
|
+
const root = useRef(null);
|
|
21
|
+
useImperativeHandle(ref, () => root.current, []);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const viewport = root.current;
|
|
24
|
+
const view = viewport?.ownerDocument.defaultView;
|
|
25
|
+
if (!viewport || !view || typeof view.matchMedia !== "function" || typeof view.requestAnimationFrame !== "function" || typeof view.cancelAnimationFrame !== "function" || typeof view.MutationObserver !== "function") return;
|
|
26
|
+
const browser = view;
|
|
27
|
+
const reduced = browser.matchMedia("(prefers-reduced-motion: reduce)");
|
|
28
|
+
const hover = browser.matchMedia("(hover: hover) and (pointer: fine)");
|
|
29
|
+
let pointer = false;
|
|
30
|
+
let focused = false;
|
|
31
|
+
let frame = 0;
|
|
32
|
+
const observed = /* @__PURE__ */ new Set();
|
|
33
|
+
const resize = typeof browser.ResizeObserver === "undefined" ? void 0 : new browser.ResizeObserver(() => schedule());
|
|
34
|
+
const layout = () => {
|
|
35
|
+
const regions = Array.from(viewport.children).filter(
|
|
36
|
+
(element) => element instanceof browser.HTMLElement && element.classList.contains("om-toast-region")
|
|
37
|
+
);
|
|
38
|
+
const cards = regions.flatMap((region) => {
|
|
39
|
+
const card = region.querySelector(".om-toast");
|
|
40
|
+
return card ? [{ region, card }] : [];
|
|
41
|
+
});
|
|
42
|
+
const active = cards.filter(({ region }) => region.dataset.state === "open");
|
|
43
|
+
for (const element of observed) {
|
|
44
|
+
if (!cards.some(({ card }) => card === element)) {
|
|
45
|
+
resize?.unobserve(element);
|
|
46
|
+
observed.delete(element);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const { card } of cards) {
|
|
50
|
+
if (!observed.has(card)) {
|
|
51
|
+
observed.add(card);
|
|
52
|
+
resize?.observe(card);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const fullHeight = active.reduce((sum, { card }) => sum + card.offsetHeight + STACK_GAP, 0) - STACK_GAP;
|
|
56
|
+
const frontHeight = active.at(-1)?.card.offsetHeight ?? 0;
|
|
57
|
+
const maxHeight = browser.innerHeight - 32;
|
|
58
|
+
const expanded = reduced.matches || !hover.matches || pointer || focused || frontHeight + 2 * STACK_PEEK > maxHeight;
|
|
59
|
+
const overflow = expanded && fullHeight > maxHeight;
|
|
60
|
+
let offset = 0;
|
|
61
|
+
active.slice().reverse().forEach(({ region, card }, index) => {
|
|
62
|
+
const depth = Math.min(index, 2);
|
|
63
|
+
const scale = expanded ? 1 : 1 - depth * 0.045;
|
|
64
|
+
const collapsedHeight = Math.min(card.offsetHeight, frontHeight) * scale;
|
|
65
|
+
const collapsedOffset = depth === 0 ? 0 : frontHeight + depth * STACK_PEEK - collapsedHeight;
|
|
66
|
+
region.style.setProperty("--om-toast-offset", `${expanded ? offset : collapsedOffset}px`);
|
|
67
|
+
region.style.setProperty("--om-toast-scale", String(scale));
|
|
68
|
+
region.style.setProperty("--om-toast-layer", String(active.length - index));
|
|
69
|
+
region.style.setProperty("--om-toast-front-height", `${frontHeight}px`);
|
|
70
|
+
region.dataset.stackBack = String(!expanded && index > 0);
|
|
71
|
+
region.dataset.stackHidden = String(!expanded && index > 2);
|
|
72
|
+
offset += card.offsetHeight + STACK_GAP;
|
|
73
|
+
});
|
|
74
|
+
viewport.style.setProperty("--om-toast-stack-height", `${Math.max(0, expanded ? fullHeight : frontHeight + Math.min(Math.max(0, active.length - 1), 2) * STACK_PEEK)}px`);
|
|
75
|
+
viewport.dataset.stackReady = "true";
|
|
76
|
+
viewport.dataset.stackExpanded = String(expanded);
|
|
77
|
+
viewport.dataset.stackOverflow = String(overflow);
|
|
78
|
+
viewport.dataset.stackActive = String(active.length > 0);
|
|
79
|
+
};
|
|
80
|
+
function schedule() {
|
|
81
|
+
if (frame) browser.cancelAnimationFrame(frame);
|
|
82
|
+
frame = browser.requestAnimationFrame(() => {
|
|
83
|
+
frame = 0;
|
|
84
|
+
layout();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const mutation = new browser.MutationObserver(schedule);
|
|
88
|
+
mutation.observe(viewport, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-state"] });
|
|
89
|
+
const enter = (event) => {
|
|
90
|
+
if (event.pointerType === "mouse") {
|
|
91
|
+
pointer = true;
|
|
92
|
+
schedule();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const leave = () => {
|
|
96
|
+
pointer = false;
|
|
97
|
+
schedule();
|
|
98
|
+
};
|
|
99
|
+
const focusIn = () => {
|
|
100
|
+
focused = true;
|
|
101
|
+
schedule();
|
|
102
|
+
};
|
|
103
|
+
const focusOut = (event) => {
|
|
104
|
+
focused = event.relatedTarget instanceof browser.Node && viewport.contains(event.relatedTarget);
|
|
105
|
+
schedule();
|
|
106
|
+
};
|
|
107
|
+
viewport.addEventListener("pointerenter", enter);
|
|
108
|
+
viewport.addEventListener("pointerleave", leave);
|
|
109
|
+
viewport.addEventListener("focusin", focusIn);
|
|
110
|
+
viewport.addEventListener("focusout", focusOut);
|
|
111
|
+
reduced.addEventListener("change", schedule);
|
|
112
|
+
hover.addEventListener("change", schedule);
|
|
113
|
+
browser.addEventListener("resize", schedule);
|
|
114
|
+
schedule();
|
|
115
|
+
return () => {
|
|
116
|
+
if (frame) browser.cancelAnimationFrame(frame);
|
|
117
|
+
mutation.disconnect();
|
|
118
|
+
resize?.disconnect();
|
|
119
|
+
viewport.removeEventListener("pointerenter", enter);
|
|
120
|
+
viewport.removeEventListener("pointerleave", leave);
|
|
121
|
+
viewport.removeEventListener("focusin", focusIn);
|
|
122
|
+
viewport.removeEventListener("focusout", focusOut);
|
|
123
|
+
reduced.removeEventListener("change", schedule);
|
|
124
|
+
hover.removeEventListener("change", schedule);
|
|
125
|
+
browser.removeEventListener("resize", schedule);
|
|
126
|
+
};
|
|
127
|
+
}, []);
|
|
128
|
+
return /* @__PURE__ */ jsx("div", { ...props, ref: root, className: cx("om-toast-viewport", className) });
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
ToastViewport.displayName = "ToastViewport";
|
|
132
|
+
var ToastIcon = ({ tone }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "data-icon": tone, children: tone === "neutral" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
133
|
+
/* @__PURE__ */ jsx("path", { d: "M18 8a6 6 0 0 0-12 0c0 6-2 7-2 9h16c0-2-2-3-2-9" }),
|
|
134
|
+
/* @__PURE__ */ jsx("path", { d: "M10 20h4" })
|
|
135
|
+
] }) : tone === "success" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
136
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
|
|
137
|
+
/* @__PURE__ */ jsx("path", { d: "m8 12 2.5 2.5L16 9" })
|
|
138
|
+
] }) : tone === "warning" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
/* @__PURE__ */ jsx("path", { d: "M10.3 4.7a2 2 0 0 1 3.4 0l7 12.1a2 2 0 0 1-1.7 3H5a2 2 0 0 1-1.7-3z" }),
|
|
140
|
+
/* @__PURE__ */ jsx("path", { d: "M12 9v4m0 3h.01" })
|
|
141
|
+
] }) : tone === "loading" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
142
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", opacity: ".24" }),
|
|
143
|
+
/* @__PURE__ */ jsx("path", { d: "M12 3a9 9 0 0 1 9 9" })
|
|
144
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
145
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
|
|
146
|
+
/* @__PURE__ */ jsx("path", { d: tone === "info" ? "M12 11v5m0-8h.01" : "m9 9 6 6m0-6-6 6" })
|
|
147
|
+
] }) });
|
|
148
|
+
var Toast = /* @__PURE__ */ forwardRef(
|
|
149
|
+
({
|
|
150
|
+
open,
|
|
151
|
+
title,
|
|
152
|
+
onDismiss,
|
|
153
|
+
dismissLabel = "Dismiss notification",
|
|
154
|
+
tone = "neutral",
|
|
155
|
+
icon,
|
|
156
|
+
children,
|
|
157
|
+
className,
|
|
158
|
+
...props
|
|
159
|
+
}, ref) => {
|
|
160
|
+
const [present, setPresent] = useState(open);
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
if (open) {
|
|
163
|
+
setPresent(true);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const reduced = typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
167
|
+
const timer = window.setTimeout(() => setPresent(false), reduced ? 0 : EXIT_DURATION);
|
|
168
|
+
return () => window.clearTimeout(timer);
|
|
169
|
+
}, [open]);
|
|
170
|
+
const visible = open || present;
|
|
171
|
+
const urgent = tone === "danger" || tone === "error";
|
|
172
|
+
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
|
+
visible && icon !== null && /* @__PURE__ */ jsx("span", { className: "om-toast-icon", "aria-hidden": "true", ref: (element) => {
|
|
174
|
+
element?.setAttribute("inert", "");
|
|
175
|
+
}, children: icon === void 0 ? /* @__PURE__ */ jsx(ToastIcon, { tone }) : icon }),
|
|
176
|
+
/* @__PURE__ */ jsx("div", { role: urgent ? "alert" : "status", "aria-atomic": "true", children: open && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
177
|
+
/* @__PURE__ */ jsx("strong", { children: title }),
|
|
178
|
+
children && /* @__PURE__ */ jsx("div", { children })
|
|
179
|
+
] }) }),
|
|
180
|
+
!open && visible && /* @__PURE__ */ jsxs("div", { "aria-hidden": "true", className: "om-toast-exit-copy", ref: (element) => {
|
|
181
|
+
element?.setAttribute("inert", "");
|
|
182
|
+
}, children: [
|
|
183
|
+
/* @__PURE__ */ jsx("strong", { children: title }),
|
|
184
|
+
children && /* @__PURE__ */ jsx("div", { children })
|
|
185
|
+
] }),
|
|
186
|
+
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" })
|
|
188
|
+
] }) });
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
Toast.displayName = "Toast";
|
|
192
|
+
|
|
193
|
+
export {
|
|
194
|
+
ToastViewport,
|
|
195
|
+
Toast
|
|
196
|
+
};
|
|
@@ -24,6 +24,8 @@ var tokens = {
|
|
|
24
24
|
"radius.sm": "var(--om-semantic-radius-sm)",
|
|
25
25
|
"radius.md": "var(--om-semantic-radius-md)",
|
|
26
26
|
"radius.lg": "var(--om-semantic-radius-lg)",
|
|
27
|
+
"radius.xl": "var(--om-semantic-radius-xl)",
|
|
28
|
+
"radius.2xl": "var(--om-semantic-radius-2xl)",
|
|
27
29
|
"radius.pill": "var(--om-semantic-radius-pill)",
|
|
28
30
|
"font.family": "var(--om-semantic-font-family)",
|
|
29
31
|
"font.size": "var(--om-semantic-font-size)",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
var Accordion = /* @__PURE__ */ forwardRef(({ className, summary, children, ...props }, ref) => /* @__PURE__ */ jsxs("details", { ...props, ref, className: cx("om-accordion", className), children: [
|
|
12
12
|
/* @__PURE__ */ jsx("summary", { children: summary }),
|
|
13
|
-
/* @__PURE__ */ jsx("div", { className: "om-accordion-content", children })
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "om-accordion-content", children: /* @__PURE__ */ jsx("div", { children }) })
|
|
14
14
|
] }));
|
|
15
15
|
Accordion.displayName = "Accordion";
|
|
16
16
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/slider.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Slider = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, ref, type: "range", className: cx("om-slider", className) }));
|
|
10
|
+
Slider.displayName = "Slider";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Slider
|
|
14
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogDescription,
|
|
6
|
+
DialogTitle,
|
|
7
|
+
DialogTrigger
|
|
8
|
+
} from "./chunk-ME34NDSX.js";
|
|
9
|
+
import {
|
|
10
|
+
Input
|
|
11
|
+
} from "./chunk-5NGRPREI.js";
|
|
12
|
+
|
|
13
|
+
// src/command-palette.tsx
|
|
14
|
+
import { useEffect, useId, useState } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var CommandPalette = ({ trigger, title, description, searchLabel, emptyLabel, items, theme, container }) => {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const [query, setQuery] = useState("");
|
|
19
|
+
const [active, setActive] = useState(null);
|
|
20
|
+
const id = useId();
|
|
21
|
+
const list = items.filter((item) => [item.label, ...item.keywords ?? []].join(" ").toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()));
|
|
22
|
+
const available = list.filter((item) => !item.disabled);
|
|
23
|
+
const selected = available.find((item) => item.id === active) ?? available[0];
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (open && selected) document.getElementById(`${id}-${list.indexOf(selected)}`)?.scrollIntoView?.({ block: "nearest" });
|
|
26
|
+
}, [open, selected, id, list]);
|
|
27
|
+
const select = (item) => {
|
|
28
|
+
if (item.disabled) return;
|
|
29
|
+
setOpen(false);
|
|
30
|
+
setQuery("");
|
|
31
|
+
setActive(null);
|
|
32
|
+
item.onSelect();
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: (value) => {
|
|
35
|
+
setOpen(value);
|
|
36
|
+
if (!value) {
|
|
37
|
+
setQuery("");
|
|
38
|
+
setActive(null);
|
|
39
|
+
}
|
|
40
|
+
}, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: trigger }),
|
|
42
|
+
/* @__PURE__ */ jsxs(DialogContent, { theme, container, className: "om-command-palette", children: [
|
|
43
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
44
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: description }),
|
|
45
|
+
/* @__PURE__ */ jsx(Input, { role: "combobox", "aria-label": searchLabel, "aria-autocomplete": "list", "aria-expanded": "true", "aria-controls": id, "aria-activedescendant": selected ? `${id}-${list.indexOf(selected)}` : void 0, value: query, onChange: (event) => {
|
|
46
|
+
setQuery(event.target.value);
|
|
47
|
+
setActive(null);
|
|
48
|
+
}, onKeyDown: (event) => {
|
|
49
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
if (!available.length) return;
|
|
52
|
+
const index = selected ? available.indexOf(selected) : 0;
|
|
53
|
+
setActive(available[(index + (event.key === "ArrowDown" ? 1 : available.length - 1)) % available.length].id);
|
|
54
|
+
} else if (event.key === "Enter" && selected && !event.nativeEvent.isComposing) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
select(selected);
|
|
57
|
+
}
|
|
58
|
+
} }),
|
|
59
|
+
/* @__PURE__ */ jsx("div", { role: "listbox", id, "aria-label": title, className: "om-command-list", children: list.map((item, index) => /* @__PURE__ */ jsx("div", { id: `${id}-${index}`, role: "option", "aria-selected": selected?.id === item.id, "aria-disabled": item.disabled || void 0, onPointerMove: () => {
|
|
60
|
+
if (!item.disabled) setActive(item.id);
|
|
61
|
+
}, onMouseDown: (event) => event.preventDefault(), onClick: () => select(item), children: item.label }, item.id)) }),
|
|
62
|
+
!list.length && /* @__PURE__ */ jsx("p", { role: "status", children: emptyLabel })
|
|
63
|
+
] })
|
|
64
|
+
] });
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
CommandPalette
|
|
69
|
+
};
|
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
cx
|
|
4
4
|
} from "./chunk-54STG2JB.js";
|
|
5
5
|
|
|
6
|
-
// src/select.tsx
|
|
7
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
8
|
-
|
|
9
6
|
// src/select-dropdown.tsx
|
|
10
7
|
import {
|
|
11
8
|
forwardRef,
|
|
@@ -15,7 +12,7 @@ import {
|
|
|
15
12
|
useState
|
|
16
13
|
} from "react";
|
|
17
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
var
|
|
15
|
+
var Select = /* @__PURE__ */ forwardRef(
|
|
19
16
|
({
|
|
20
17
|
options,
|
|
21
18
|
name,
|
|
@@ -182,7 +179,7 @@ var SelectDropdown = /* @__PURE__ */ forwardRef(
|
|
|
182
179
|
{
|
|
183
180
|
id: listId,
|
|
184
181
|
role: "listbox",
|
|
185
|
-
"aria-label": "Options",
|
|
182
|
+
"aria-label": props["aria-label"] ?? "Options",
|
|
186
183
|
ref: list,
|
|
187
184
|
hidden: !expanded,
|
|
188
185
|
children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
@@ -192,6 +189,7 @@ var SelectDropdown = /* @__PURE__ */ forwardRef(
|
|
|
192
189
|
role: "option",
|
|
193
190
|
"aria-selected": selected === index,
|
|
194
191
|
"aria-disabled": option.disabled || void 0,
|
|
192
|
+
lang: option.lang,
|
|
195
193
|
"data-active": activeIndex === index || void 0,
|
|
196
194
|
onMouseDown: (event) => event.preventDefault(),
|
|
197
195
|
onClick: () => choose(index),
|
|
@@ -204,14 +202,8 @@ var SelectDropdown = /* @__PURE__ */ forwardRef(
|
|
|
204
202
|
] });
|
|
205
203
|
}
|
|
206
204
|
);
|
|
207
|
-
SelectDropdown.displayName = "SelectDropdown";
|
|
208
|
-
|
|
209
|
-
// src/select.tsx
|
|
210
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
211
|
-
var Select = /* @__PURE__ */ forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("select", { ...props, ref, className: cx("om-select", className) }));
|
|
212
205
|
Select.displayName = "Select";
|
|
213
206
|
|
|
214
207
|
export {
|
|
215
|
-
SelectDropdown,
|
|
216
208
|
Select
|
|
217
209
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type CommandPaletteItem = {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
keywords?: readonly string[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onSelect: () => void;
|
|
10
|
+
};
|
|
11
|
+
type CommandPaletteProps = {
|
|
12
|
+
trigger: ReactNode;
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
searchLabel: string;
|
|
16
|
+
emptyLabel: string;
|
|
17
|
+
items: readonly CommandPaletteItem[];
|
|
18
|
+
theme?: 'light' | 'dark';
|
|
19
|
+
container?: HTMLElement | null;
|
|
20
|
+
};
|
|
21
|
+
declare const CommandPalette: ({ trigger, title, description, searchLabel, emptyLabel, items, theme, container }: CommandPaletteProps) => react.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { CommandPalette };
|
|
24
|
+
export type { CommandPaletteItem, CommandPaletteProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Badge, BadgeProps } from './badge.js';
|
|
|
5
5
|
export { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs.js';
|
|
6
6
|
export { Dialog, DialogClose, DialogContent, DialogContentProps, DialogDescription, DialogTitle, DialogTrigger } from './dialog.js';
|
|
7
7
|
export { Textarea, TextareaProps } from './textarea.js';
|
|
8
|
-
export { Select, SelectDropdown, SelectDropdownOption, SelectDropdownProps, SelectProps } from './select.js';
|
|
8
|
+
export { Select, Select as SelectDropdown, SelectDropdownOption, SelectDropdownProps, SelectDropdownOption as SelectOption, SelectDropdownProps as SelectProps } from './select.js';
|
|
9
9
|
export { Checkbox, CheckboxProps } from './checkbox.js';
|
|
10
10
|
export { Radio, RadioProps } from './radio.js';
|
|
11
11
|
export { Switch, SwitchProps } from './switch.js';
|
|
@@ -15,14 +15,16 @@ export { Progress, ProgressProps } from './progress.js';
|
|
|
15
15
|
export { Table, TableProps } from './table.js';
|
|
16
16
|
export { Field, FieldProps } from './field.js';
|
|
17
17
|
export { Accordion, AccordionProps } from './accordion.js';
|
|
18
|
-
export { Alert, AlertProps } from './alert.js';
|
|
18
|
+
export { Alert, AlertDialog, AlertDialogProps, AlertProps } from './alert.js';
|
|
19
19
|
export { Avatar, AvatarProps } from './avatar.js';
|
|
20
20
|
export { Spinner, SpinnerProps } from './spinner.js';
|
|
21
21
|
export { Breadcrumbs, BreadcrumbsProps } from './breadcrumbs.js';
|
|
22
22
|
export { Pagination, PaginationProps } from './pagination.js';
|
|
23
23
|
export { EmptyState, EmptyStateProps } from './empty-state.js';
|
|
24
24
|
export { TokenName, tokens } from './tokens.js';
|
|
25
|
-
export { Toast, ToastProps } from './toast.js';
|
|
25
|
+
export { Toast, ToastProps, ToastViewport } from './toast.js';
|
|
26
|
+
export { Slider, SliderProps } from './slider.js';
|
|
27
|
+
export { CommandPalette, CommandPaletteItem, CommandPaletteProps } from './command-palette.js';
|
|
26
28
|
import 'react';
|
|
27
29
|
import '@radix-ui/react-tabs';
|
|
28
30
|
import '@radix-ui/react-dialog';
|