@oddmash/ui 0.1.0 → 0.2.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 +5 -3
- package/dist/accordion.d.ts +12 -0
- package/dist/accordion.js +8 -0
- package/dist/alert.d.ts +12 -0
- package/dist/alert.js +8 -0
- package/dist/avatar.d.ts +14 -0
- package/dist/avatar.js +8 -0
- package/dist/breadcrumbs.d.ts +8 -0
- package/dist/breadcrumbs.js +8 -0
- package/dist/checkbox.d.ts +8 -0
- package/dist/checkbox.js +8 -0
- package/dist/chunk-24TAPSJO.js +14 -0
- package/dist/chunk-2YEAAOWL.js +24 -0
- package/dist/chunk-33GOGIXE.js +19 -0
- package/dist/chunk-46VRJZNH.js +24 -0
- package/dist/chunk-4AQXNXAQ.js +16 -0
- package/dist/chunk-4VBYIXGA.js +22 -0
- package/dist/{chunk-YGBV3KG6.js → chunk-7A5VK567.js} +1 -0
- package/dist/chunk-AVQGR5G7.js +22 -0
- package/dist/chunk-B3VPCEGX.js +14 -0
- package/dist/chunk-CWGH75FA.js +217 -0
- package/dist/chunk-JA3X5LJF.js +14 -0
- package/dist/chunk-L53J65C4.js +23 -0
- package/dist/chunk-LFWQDF6U.js +25 -0
- package/dist/chunk-QB6NCURJ.js +24 -0
- package/dist/chunk-SDU26SU7.js +43 -0
- package/dist/chunk-UJJUFR7B.js +22 -0
- package/dist/chunk-XYGNNGM2.js +14 -0
- package/dist/chunk-ZEQLZCOY.js +19 -0
- package/dist/empty-state.d.ts +8 -0
- package/dist/empty-state.js +8 -0
- package/dist/field.d.ts +12 -0
- package/dist/field.js +8 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +71 -1
- package/dist/pagination.d.ts +8 -0
- package/dist/pagination.js +8 -0
- package/dist/progress.d.ts +8 -0
- package/dist/progress.js +8 -0
- package/dist/radio.d.ts +8 -0
- package/dist/radio.js +8 -0
- package/dist/select.d.ts +30 -0
- package/dist/select.js +10 -0
- package/dist/separator.d.ts +8 -0
- package/dist/separator.js +8 -0
- package/dist/skeleton.d.ts +8 -0
- package/dist/skeleton.js +8 -0
- package/dist/spinner.d.ts +12 -0
- package/dist/spinner.js +8 -0
- package/dist/styles.css +443 -41
- package/dist/switch.d.ts +8 -0
- package/dist/switch.js +8 -0
- package/dist/table.d.ts +8 -0
- package/dist/table.js +8 -0
- package/dist/textarea.d.ts +8 -0
- package/dist/textarea.js +8 -0
- package/dist/tokens.css +51 -41
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +1 -1
- package/package.json +74 -10
- package/tokens/primitive.json +107 -55
- package/tokens/semantic/dark.json +8 -4
- package/tokens/semantic/light.json +7 -3
package/README.md
CHANGED
|
@@ -8,10 +8,11 @@ Oddmash UI is the shared interface foundation for Oddmash products. It gives sma
|
|
|
8
8
|
|
|
9
9
|
## What it provides
|
|
10
10
|
|
|
11
|
-
- Accessible React
|
|
11
|
+
- Accessible React components for forms, feedback, navigation, overlays, and data display.
|
|
12
12
|
- JSON design tokens for color, typography, spacing, radius, shadow, border, and motion.
|
|
13
13
|
- Light and dark themes that can be applied to a whole app or a single subtree.
|
|
14
14
|
- A documentation site with live examples, API guidance, accessibility notes, and a token explorer.
|
|
15
|
+
- An Interaction Lab that shows how the components work together in a developer-tool interface.
|
|
15
16
|
|
|
16
17
|
## Who it is for
|
|
17
18
|
|
|
@@ -20,12 +21,13 @@ Oddmash UI is for focused tools such as Interaction Inspector: products that nee
|
|
|
20
21
|
## Design principles
|
|
21
22
|
|
|
22
23
|
- **Consistent by default.** Shared components and semantic tokens make Oddmash tools feel related.
|
|
24
|
+
- **Color signals interaction.** Neutral surfaces and controls carry the interface. Blue indicates focus and red indicates errors.
|
|
23
25
|
- **Accessible in behavior.** Keyboard interaction, focus handling, reduced motion, and forced colors are part of the component contract.
|
|
24
26
|
- **Themeable, not prescriptive.** Products can override semantic tokens without forking the components.
|
|
25
27
|
- **Small on purpose.** The system grows from real product needs rather than trying to cover every UI pattern.
|
|
26
28
|
|
|
27
29
|
## Current scope
|
|
28
30
|
|
|
29
|
-
Oddmash UI is under active pre-1.0 development.
|
|
31
|
+
Oddmash UI is under active pre-1.0 development. Version 0.2.0 provides 23 component families through npm and the live documentation.
|
|
30
32
|
|
|
31
|
-
[Contributor guide](CONTRIBUTING.md) · [MIT License](LICENSE)
|
|
33
|
+
[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,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type AccordionProps = ComponentPropsWithoutRef<'details'> & {
|
|
5
|
+
summary: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
declare const Accordion: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "ref"> & {
|
|
8
|
+
summary: ReactNode;
|
|
9
|
+
} & react.RefAttributes<HTMLDetailsElement>>;
|
|
10
|
+
|
|
11
|
+
export { Accordion };
|
|
12
|
+
export type { AccordionProps };
|
package/dist/alert.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type AlertProps = ComponentPropsWithoutRef<'div'> & {
|
|
5
|
+
tone?: 'neutral' | 'danger';
|
|
6
|
+
};
|
|
7
|
+
declare const Alert: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
|
+
tone?: "neutral" | "danger";
|
|
9
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
|
|
11
|
+
export { Alert };
|
|
12
|
+
export type { AlertProps };
|
package/dist/alert.js
ADDED
package/dist/avatar.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type AvatarProps = ComponentPropsWithoutRef<'span'> & {
|
|
5
|
+
src?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Avatar: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
9
|
+
src?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
} & react.RefAttributes<HTMLSpanElement>>;
|
|
12
|
+
|
|
13
|
+
export { Avatar };
|
|
14
|
+
export type { AvatarProps };
|
package/dist/avatar.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type BreadcrumbsProps = ComponentPropsWithoutRef<'nav'>;
|
|
5
|
+
declare const Breadcrumbs: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & react.RefAttributes<HTMLElement>>;
|
|
6
|
+
|
|
7
|
+
export { Breadcrumbs };
|
|
8
|
+
export type { BreadcrumbsProps };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role' | 'aria-checked'>;
|
|
5
|
+
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
|
|
6
|
+
|
|
7
|
+
export { Checkbox };
|
|
8
|
+
export type { CheckboxProps };
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/progress.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Progress = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("progress", { ...props, ref, className: cx("om-progress", className) }));
|
|
10
|
+
Progress.displayName = "Progress";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Progress
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/alert.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Alert = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, tone = "neutral", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
"data-tone": tone,
|
|
16
|
+
className: cx("om-alert", className)
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
Alert.displayName = "Alert";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
Alert
|
|
24
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/accordion.tsx
|
|
7
|
+
import {
|
|
8
|
+
forwardRef
|
|
9
|
+
} from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var Accordion = /* @__PURE__ */ forwardRef(({ className, summary, children, ...props }, ref) => /* @__PURE__ */ jsxs("details", { ...props, ref, className: cx("om-accordion", className), children: [
|
|
12
|
+
/* @__PURE__ */ jsx("summary", { children: summary }),
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "om-accordion-content", children })
|
|
14
|
+
] }));
|
|
15
|
+
Accordion.displayName = "Accordion";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
Accordion
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/radio.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Radio = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
11
|
+
"input",
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
type: "radio",
|
|
16
|
+
className: cx("om-radio", className)
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
Radio.displayName = "Radio";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
Radio
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/table.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Table = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("table", { ...props, ref, className: cx("om-table", className) })
|
|
11
|
+
);
|
|
12
|
+
Table.displayName = "Table";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
Table
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/pagination.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Pagination = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
10
|
+
"nav",
|
|
11
|
+
{
|
|
12
|
+
"aria-label": "Pagination",
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
className: cx("om-pagination", className)
|
|
16
|
+
}
|
|
17
|
+
));
|
|
18
|
+
Pagination.displayName = "Pagination";
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
Pagination
|
|
22
|
+
};
|
|
@@ -31,6 +31,7 @@ var tokens = {
|
|
|
31
31
|
"font.heading": "var(--om-semantic-font-heading)",
|
|
32
32
|
"font.weight": "var(--om-semantic-font-weight)",
|
|
33
33
|
"font.line": "var(--om-semantic-font-line)",
|
|
34
|
+
"font.mono-family": "var(--om-semantic-font-mono-family)",
|
|
34
35
|
"border.default": "var(--om-semantic-border-default)",
|
|
35
36
|
"border.width": "var(--om-semantic-border-width)",
|
|
36
37
|
"border.style": "var(--om-semantic-border-style)",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/skeleton.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Skeleton = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
...props,
|
|
13
|
+
ref,
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
className: cx("om-skeleton", className)
|
|
16
|
+
}
|
|
17
|
+
));
|
|
18
|
+
Skeleton.displayName = "Skeleton";
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
Skeleton
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/textarea.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Textarea = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("textarea", { ...props, ref, className: cx("om-textarea", className) }));
|
|
10
|
+
Textarea.displayName = "Textarea";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Textarea
|
|
14
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/select.tsx
|
|
7
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
8
|
+
|
|
9
|
+
// src/select-dropdown.tsx
|
|
10
|
+
import {
|
|
11
|
+
forwardRef,
|
|
12
|
+
useEffect,
|
|
13
|
+
useId,
|
|
14
|
+
useRef,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var SelectDropdown = /* @__PURE__ */ forwardRef(
|
|
19
|
+
({
|
|
20
|
+
options,
|
|
21
|
+
name,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
placeholder = "Choose an option",
|
|
25
|
+
onValueChange,
|
|
26
|
+
disabled,
|
|
27
|
+
form,
|
|
28
|
+
className,
|
|
29
|
+
onClick,
|
|
30
|
+
onKeyDown,
|
|
31
|
+
onBlur,
|
|
32
|
+
...props
|
|
33
|
+
}, ref) => {
|
|
34
|
+
const listId = useId();
|
|
35
|
+
const root = useRef(null);
|
|
36
|
+
const list = useRef(null);
|
|
37
|
+
const search = useRef({ text: "", time: 0 });
|
|
38
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
39
|
+
const [open, setOpen] = useState(false);
|
|
40
|
+
const [active, setActive] = useState();
|
|
41
|
+
const selected = options.findIndex(
|
|
42
|
+
(option) => option.value === (value ?? internal)
|
|
43
|
+
);
|
|
44
|
+
const enabled = options.flatMap(
|
|
45
|
+
(option, index) => option.disabled ? [] : [index]
|
|
46
|
+
);
|
|
47
|
+
const expanded = open && !disabled && enabled.length > 0;
|
|
48
|
+
const activeIndex = active !== void 0 && enabled.includes(active) ? active : void 0;
|
|
49
|
+
const close = () => {
|
|
50
|
+
setOpen(false);
|
|
51
|
+
setActive(void 0);
|
|
52
|
+
search.current.text = "";
|
|
53
|
+
};
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!expanded) return;
|
|
56
|
+
const container = root.current;
|
|
57
|
+
const scope = container?.getRootNode();
|
|
58
|
+
const dismiss = (event) => {
|
|
59
|
+
if (container && !event.composedPath().includes(container)) close();
|
|
60
|
+
};
|
|
61
|
+
scope?.addEventListener("pointerdown", dismiss, true);
|
|
62
|
+
return () => scope?.removeEventListener("pointerdown", dismiss, true);
|
|
63
|
+
}, [expanded]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const menu = list.current;
|
|
66
|
+
const item = activeIndex === void 0 ? void 0 : menu?.children[activeIndex];
|
|
67
|
+
if (!expanded || !menu || !item) return;
|
|
68
|
+
const visible = menu.getBoundingClientRect();
|
|
69
|
+
const option = item.getBoundingClientRect();
|
|
70
|
+
if (option.top < visible.top) menu.scrollTop -= visible.top - option.top;
|
|
71
|
+
if (option.bottom > visible.bottom)
|
|
72
|
+
menu.scrollTop += option.bottom - visible.bottom;
|
|
73
|
+
}, [activeIndex, expanded]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const owner = root.current?.querySelector("button")?.form;
|
|
76
|
+
const reset = () => {
|
|
77
|
+
if (value === void 0) setInternal(defaultValue);
|
|
78
|
+
close();
|
|
79
|
+
};
|
|
80
|
+
owner?.addEventListener("reset", reset);
|
|
81
|
+
return () => owner?.removeEventListener("reset", reset);
|
|
82
|
+
}, [defaultValue, form, value]);
|
|
83
|
+
const initial = (last = false) => enabled.includes(selected) ? selected : last ? enabled.at(-1) : enabled[0];
|
|
84
|
+
const choose = (index) => {
|
|
85
|
+
if (index === void 0 || !enabled.includes(index)) return;
|
|
86
|
+
const next = options[index].value;
|
|
87
|
+
if (value === void 0) setInternal(next);
|
|
88
|
+
if (index !== selected) onValueChange?.(next);
|
|
89
|
+
close();
|
|
90
|
+
};
|
|
91
|
+
const handleKeys = (event) => {
|
|
92
|
+
onKeyDown?.(event);
|
|
93
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || !enabled.length)
|
|
94
|
+
return;
|
|
95
|
+
const { key } = event;
|
|
96
|
+
if (key === "Escape" && expanded) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
close();
|
|
100
|
+
} else if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
const previous = activeIndex === void 0 ? -1 : enabled.indexOf(activeIndex);
|
|
103
|
+
const next = key === "Home" ? enabled[0] : key === "End" ? enabled.at(-1) : previous < 0 ? initial(key === "ArrowUp") : enabled[Math.max(
|
|
104
|
+
0,
|
|
105
|
+
Math.min(
|
|
106
|
+
enabled.length - 1,
|
|
107
|
+
previous + (key === "ArrowDown" ? 1 : -1)
|
|
108
|
+
)
|
|
109
|
+
)];
|
|
110
|
+
setActive(next);
|
|
111
|
+
setOpen(true);
|
|
112
|
+
} else if (key === "Enter" || key === " ") {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (expanded) choose(activeIndex);
|
|
115
|
+
else {
|
|
116
|
+
setActive(initial());
|
|
117
|
+
setOpen(true);
|
|
118
|
+
}
|
|
119
|
+
} else if (key.length === 1) {
|
|
120
|
+
const time = Date.now();
|
|
121
|
+
const char = key.toLocaleLowerCase();
|
|
122
|
+
const previous = time - search.current.time < 500 ? search.current.text : "";
|
|
123
|
+
const text = previous + char;
|
|
124
|
+
search.current = { text, time };
|
|
125
|
+
const repeated = [...text].every((letter) => letter === char);
|
|
126
|
+
const start = enabled.indexOf(activeIndex ?? selected);
|
|
127
|
+
const first = repeated || previous === "" ? start + 1 : Math.max(0, start);
|
|
128
|
+
const ordered = [...enabled.slice(first), ...enabled.slice(0, first)];
|
|
129
|
+
const match = ordered.find(
|
|
130
|
+
(index) => options[index].label.toLocaleLowerCase().startsWith(repeated ? char : text)
|
|
131
|
+
);
|
|
132
|
+
if (match === void 0) return;
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
setActive(match);
|
|
135
|
+
setOpen(true);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ jsxs("div", { className: "om-select-dropdown", ref: root, children: [
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
...props,
|
|
143
|
+
ref,
|
|
144
|
+
type: "button",
|
|
145
|
+
role: "combobox",
|
|
146
|
+
form,
|
|
147
|
+
disabled,
|
|
148
|
+
"aria-disabled": !enabled.length || void 0,
|
|
149
|
+
"aria-expanded": expanded,
|
|
150
|
+
"aria-controls": listId,
|
|
151
|
+
"aria-activedescendant": expanded && activeIndex !== void 0 ? `${listId}-${activeIndex}` : void 0,
|
|
152
|
+
className: cx("om-select", "om-select-dropdown-trigger", className),
|
|
153
|
+
onKeyDown: handleKeys,
|
|
154
|
+
onBlur: (event) => {
|
|
155
|
+
onBlur?.(event);
|
|
156
|
+
close();
|
|
157
|
+
},
|
|
158
|
+
onClick: (event) => {
|
|
159
|
+
onClick?.(event);
|
|
160
|
+
if (event.defaultPrevented || !enabled.length) return;
|
|
161
|
+
if (expanded) close();
|
|
162
|
+
else {
|
|
163
|
+
setActive(initial());
|
|
164
|
+
setOpen(true);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
children: options[selected]?.label ?? placeholder
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
name && selected !== -1 && /* @__PURE__ */ jsx(
|
|
171
|
+
"input",
|
|
172
|
+
{
|
|
173
|
+
type: "hidden",
|
|
174
|
+
name,
|
|
175
|
+
value: options[selected].value,
|
|
176
|
+
disabled,
|
|
177
|
+
form
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"ul",
|
|
182
|
+
{
|
|
183
|
+
id: listId,
|
|
184
|
+
role: "listbox",
|
|
185
|
+
"aria-label": "Options",
|
|
186
|
+
ref: list,
|
|
187
|
+
hidden: !expanded,
|
|
188
|
+
children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
189
|
+
"li",
|
|
190
|
+
{
|
|
191
|
+
id: `${listId}-${index}`,
|
|
192
|
+
role: "option",
|
|
193
|
+
"aria-selected": selected === index,
|
|
194
|
+
"aria-disabled": option.disabled || void 0,
|
|
195
|
+
"data-active": activeIndex === index || void 0,
|
|
196
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
197
|
+
onClick: () => choose(index),
|
|
198
|
+
children: option.label
|
|
199
|
+
},
|
|
200
|
+
option.value
|
|
201
|
+
))
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
);
|
|
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
|
+
Select.displayName = "Select";
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
SelectDropdown,
|
|
216
|
+
Select
|
|
217
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/separator.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Separator = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("hr", { ...props, ref, className: cx("om-separator", className) }));
|
|
10
|
+
Separator.displayName = "Separator";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Separator
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/breadcrumbs.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Breadcrumbs = /* @__PURE__ */ forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
10
|
+
"nav",
|
|
11
|
+
{
|
|
12
|
+
"aria-label": "Breadcrumb",
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
className: cx("om-breadcrumbs", className),
|
|
16
|
+
children: /* @__PURE__ */ jsx("ol", { role: "list", children })
|
|
17
|
+
}
|
|
18
|
+
));
|
|
19
|
+
Breadcrumbs.displayName = "Breadcrumbs";
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
Breadcrumbs
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/switch.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Switch = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
11
|
+
"input",
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
type: "checkbox",
|
|
16
|
+
role: "switch",
|
|
17
|
+
className: cx("om-switch", className)
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
Switch.displayName = "Switch";
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
Switch
|
|
25
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/spinner.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Spinner = /* @__PURE__ */ forwardRef(({ className, label, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
role: label ? "status" : void 0,
|
|
13
|
+
"aria-hidden": label ? void 0 : true,
|
|
14
|
+
...props,
|
|
15
|
+
ref,
|
|
16
|
+
className: cx("om-spinner", className),
|
|
17
|
+
children: label && /* @__PURE__ */ jsx("span", { className: "om-spinner-label", children: label })
|
|
18
|
+
}
|
|
19
|
+
));
|
|
20
|
+
Spinner.displayName = "Spinner";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
Spinner
|
|
24
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/avatar.tsx
|
|
7
|
+
import { forwardRef, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var AvatarImage = ({ src }) => {
|
|
10
|
+
const [visible, setVisible] = useState(false);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"img",
|
|
13
|
+
{
|
|
14
|
+
src,
|
|
15
|
+
alt: "",
|
|
16
|
+
hidden: !visible,
|
|
17
|
+
onLoad: () => setVisible(true),
|
|
18
|
+
onError: () => setVisible(false)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
var Avatar = /* @__PURE__ */ forwardRef(
|
|
23
|
+
({ className, src, label, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
24
|
+
"span",
|
|
25
|
+
{
|
|
26
|
+
role: label ? "img" : void 0,
|
|
27
|
+
"aria-label": label,
|
|
28
|
+
"aria-hidden": label ? void 0 : true,
|
|
29
|
+
...props,
|
|
30
|
+
ref,
|
|
31
|
+
className: cx("om-avatar", className),
|
|
32
|
+
children: [
|
|
33
|
+
children,
|
|
34
|
+
src && /* @__PURE__ */ jsx(AvatarImage, { src }, src)
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
Avatar.displayName = "Avatar";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
Avatar
|
|
43
|
+
};
|