@oddmash/ui 0.4.1 → 0.6.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 +2 -1
- package/dist/alert.js +2 -2
- package/dist/badge.d.ts +2 -2
- package/dist/button.d.ts +22 -7
- package/dist/button.js +9 -3
- package/dist/chunk-77W2JTCK.js +116 -0
- package/dist/chunk-A3PPKK5J.js +23 -0
- package/dist/chunk-BAJCEDO3.js +17 -0
- package/dist/chunk-DOCL5Y45.js +14 -0
- package/dist/chunk-FKO6T5XG.js +71 -0
- package/dist/chunk-GRQMKQRL.js +21 -0
- package/dist/chunk-I5VJBLHP.js +36 -0
- package/dist/{chunk-OGJ3KIBM.js → chunk-LKCU6TJK.js} +3 -0
- package/dist/chunk-OJKYDXOE.js +223 -0
- package/dist/chunk-OUFCQ2JE.js +126 -0
- package/dist/chunk-PG3JE6RB.js +160 -0
- package/dist/chunk-QW7IHDAG.js +36 -0
- package/dist/{chunk-BMVVSFAU.js → chunk-TZHTKOPH.js} +3 -3
- package/dist/chunk-U7RNP366.js +16 -0
- package/dist/chunk-WHFF7XSS.js +224 -0
- package/dist/chunk-ZRMUD4KO.js +57 -0
- package/dist/clipboard-button.d.ts +28 -0
- package/dist/clipboard-button.js +11 -0
- package/dist/code-block.d.ts +16 -0
- package/dist/code-block.js +16 -0
- package/dist/command-palette.d.ts +10 -1
- package/dist/command-palette.js +2 -1
- package/dist/docs-navigation.d.ts +64 -0
- package/dist/docs-navigation.js +15 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +109 -27
- package/dist/kbd.d.ts +8 -0
- package/dist/kbd.js +8 -0
- package/dist/link-card.d.ts +8 -0
- package/dist/link-card.js +8 -0
- package/dist/locale-picker.d.ts +18 -0
- package/dist/locale-picker.js +9 -0
- package/dist/platform-link.d.ts +15 -0
- package/dist/platform-link.js +10 -0
- package/dist/prose.d.ts +10 -0
- package/dist/prose.js +10 -0
- package/dist/scroll-header.d.ts +17 -0
- package/dist/scroll-header.js +10 -0
- package/dist/site-layout.d.ts +16 -0
- package/dist/site-layout.js +16 -0
- package/dist/slider.js +1 -1
- package/dist/styles.css +785 -0
- package/dist/toast-provider.d.ts +30 -0
- package/dist/toast-provider.js +11 -0
- package/dist/tokens.css +10 -0
- package/dist/tokens.d.ts +3 -0
- package/dist/tokens.js +1 -1
- package/package.json +45 -1
- package/tokens/primitive.json +18 -0
- package/tokens/semantic/dark.json +12 -0
- package/tokens/semantic/light.json +12 -0
- package/dist/chunk-3TIYT55P.js +0 -14
- package/dist/chunk-U2Y2DJXG.js +0 -14
- package/dist/chunk-WODRU2UN.js +0 -69
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Oddmash UI is the shared interface foundation for Oddmash products. It gives sma
|
|
|
16
16
|
- Light and dark themes that can be applied to a whole app or a single subtree.
|
|
17
17
|
- A documentation site with live examples, API guidance, accessibility notes, and a token explorer.
|
|
18
18
|
- An Interaction Lab that shows how the components work together in a developer-tool interface.
|
|
19
|
+
- Documentation and landing primitives for linked cards, code examples, site navigation, rendered Markdown, platform/icon links, copy feedback, managed notifications, language selection, scroll-aware headers, and grouped search, with static HTML class contracts.
|
|
19
20
|
|
|
20
21
|
## Who it is for
|
|
21
22
|
|
|
@@ -31,6 +32,6 @@ Oddmash UI is for focused tools such as Interaction Inspector: products that nee
|
|
|
31
32
|
|
|
32
33
|
## Current scope
|
|
33
34
|
|
|
34
|
-
Oddmash UI is under active pre-1.0 development. Version 0.
|
|
35
|
+
Oddmash UI is under active pre-1.0 development. Version 0.6.0 adds semantic state badges, consistent native range styling and an optional localized command dismiss action alongside improvements to documentation navigation and code copying. React 18.3.1 and React 19 remain supported.
|
|
35
36
|
|
|
36
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)
|
package/dist/alert.js
CHANGED
package/dist/badge.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentPropsWithoutRef } from 'react';
|
|
3
3
|
|
|
4
4
|
type BadgeProps = ComponentPropsWithoutRef<'span'> & {
|
|
5
|
-
tone?: 'neutral' | 'accent';
|
|
5
|
+
tone?: 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'error' | 'info' | 'active';
|
|
6
6
|
};
|
|
7
7
|
declare const Badge: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
8
|
-
tone?: "neutral" | "accent";
|
|
8
|
+
tone?: "neutral" | "accent" | "success" | "warning" | "danger" | "error" | "info" | "active";
|
|
9
9
|
} & react.RefAttributes<HTMLSpanElement>>;
|
|
10
10
|
|
|
11
11
|
export { Badge };
|
package/dist/button.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef } from 'react';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type ButtonAppearance = {
|
|
5
5
|
variant?: 'primary' | 'secondary' | 'ghost';
|
|
6
6
|
size?: 'sm' | 'md';
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
type ButtonProps = ComponentPropsWithoutRef<'button'> & ButtonAppearance;
|
|
9
|
+
declare const Button: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & ButtonAppearance & react.RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
type ButtonLinkProps = ComponentPropsWithoutRef<'a'> & ButtonAppearance & {
|
|
11
|
+
href: string;
|
|
12
|
+
};
|
|
13
|
+
declare const ButtonLink: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & ButtonAppearance & {
|
|
14
|
+
href: string;
|
|
15
|
+
} & react.RefAttributes<HTMLAnchorElement>>;
|
|
16
|
+
type IconControlName = {
|
|
17
|
+
'aria-label': string;
|
|
18
|
+
'aria-labelledby'?: string;
|
|
19
|
+
} | {
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
'aria-labelledby': string;
|
|
22
|
+
};
|
|
23
|
+
type IconButtonProps = Omit<ButtonProps, 'aria-label' | 'aria-labelledby'> & IconControlName;
|
|
24
|
+
declare const IconButton: react.ForwardRefExoticComponent<IconButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
type IconLinkProps = Omit<ButtonLinkProps, 'aria-label' | 'aria-labelledby'> & IconControlName;
|
|
26
|
+
declare const IconLink: react.ForwardRefExoticComponent<IconLinkProps & react.RefAttributes<HTMLAnchorElement>>;
|
|
12
27
|
|
|
13
|
-
export { Button };
|
|
14
|
-
export type { ButtonProps };
|
|
28
|
+
export { Button, ButtonLink, IconButton, IconLink };
|
|
29
|
+
export type { ButtonLinkProps, ButtonProps, IconButtonProps, IconControlName, IconLinkProps };
|
package/dist/button.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
Button
|
|
4
|
-
|
|
3
|
+
Button,
|
|
4
|
+
ButtonLink,
|
|
5
|
+
IconButton,
|
|
6
|
+
IconLink
|
|
7
|
+
} from "./chunk-A3PPKK5J.js";
|
|
5
8
|
import "./chunk-54STG2JB.js";
|
|
6
9
|
export {
|
|
7
|
-
Button
|
|
10
|
+
Button,
|
|
11
|
+
ButtonLink,
|
|
12
|
+
IconButton,
|
|
13
|
+
IconLink
|
|
8
14
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Button
|
|
4
|
+
} from "./chunk-A3PPKK5J.js";
|
|
5
|
+
import {
|
|
6
|
+
cx
|
|
7
|
+
} from "./chunk-54STG2JB.js";
|
|
8
|
+
|
|
9
|
+
// src/clipboard-button.tsx
|
|
10
|
+
import {
|
|
11
|
+
forwardRef,
|
|
12
|
+
useEffect,
|
|
13
|
+
useImperativeHandle,
|
|
14
|
+
useRef,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var defaultLabels = {
|
|
19
|
+
idle: "Copy",
|
|
20
|
+
pending: "Copying",
|
|
21
|
+
copied: "Copied",
|
|
22
|
+
error: "Could not copy. Select the text and copy it manually."
|
|
23
|
+
};
|
|
24
|
+
var copyText = async (text) => {
|
|
25
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
26
|
+
if (!clipboard || typeof clipboard.writeText !== "function") {
|
|
27
|
+
throw new Error("Clipboard writing is unavailable.");
|
|
28
|
+
}
|
|
29
|
+
await clipboard.writeText(text);
|
|
30
|
+
};
|
|
31
|
+
var ClipboardButton = /* @__PURE__ */ forwardRef(
|
|
32
|
+
({
|
|
33
|
+
text,
|
|
34
|
+
labels = defaultLabels,
|
|
35
|
+
children,
|
|
36
|
+
resetDelay = 2500,
|
|
37
|
+
announce = true,
|
|
38
|
+
onCopied,
|
|
39
|
+
onCopyError,
|
|
40
|
+
onClick,
|
|
41
|
+
className,
|
|
42
|
+
variant = "secondary",
|
|
43
|
+
...props
|
|
44
|
+
}, ref) => {
|
|
45
|
+
const [state, setState] = useState("idle");
|
|
46
|
+
const button = useRef(null);
|
|
47
|
+
useImperativeHandle(ref, () => button.current, []);
|
|
48
|
+
const currentText = useRef(text);
|
|
49
|
+
const pending = useRef(false);
|
|
50
|
+
const reset = useRef(void 0);
|
|
51
|
+
useEffect(() => () => clearTimeout(reset.current), []);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
currentText.current = text;
|
|
54
|
+
clearTimeout(reset.current);
|
|
55
|
+
if (!pending.current) setState("idle");
|
|
56
|
+
}, [text]);
|
|
57
|
+
const click = (event) => {
|
|
58
|
+
onClick?.(event);
|
|
59
|
+
if (event.defaultPrevented || pending.current || props.disabled) return;
|
|
60
|
+
pending.current = true;
|
|
61
|
+
clearTimeout(reset.current);
|
|
62
|
+
setState("pending");
|
|
63
|
+
const complete = async () => {
|
|
64
|
+
let result;
|
|
65
|
+
try {
|
|
66
|
+
await copyText(text);
|
|
67
|
+
result = { ok: true };
|
|
68
|
+
} catch (error) {
|
|
69
|
+
result = { ok: false, error };
|
|
70
|
+
}
|
|
71
|
+
pending.current = false;
|
|
72
|
+
if (!button.current) return;
|
|
73
|
+
if (currentText.current !== text) {
|
|
74
|
+
setState("idle");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (result.ok) {
|
|
78
|
+
setState("copied");
|
|
79
|
+
if (resetDelay !== null && Number.isFinite(resetDelay) && resetDelay >= 0) {
|
|
80
|
+
reset.current = setTimeout(() => {
|
|
81
|
+
if (button.current && !pending.current && currentText.current === text) setState("idle");
|
|
82
|
+
}, resetDelay);
|
|
83
|
+
}
|
|
84
|
+
onCopied?.(text);
|
|
85
|
+
} else {
|
|
86
|
+
setState("error");
|
|
87
|
+
onCopyError?.(result.error);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
void complete();
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
93
|
+
/* @__PURE__ */ jsx(
|
|
94
|
+
Button,
|
|
95
|
+
{
|
|
96
|
+
...props,
|
|
97
|
+
ref: button,
|
|
98
|
+
variant,
|
|
99
|
+
className: cx("om-clipboard-button", className),
|
|
100
|
+
onClick: click,
|
|
101
|
+
"aria-busy": state === "pending" || props["aria-busy"],
|
|
102
|
+
"aria-label": props["aria-label"] ?? labels[state],
|
|
103
|
+
"data-copy-state": state,
|
|
104
|
+
children: typeof children === "function" ? children(state) : children ?? labels[state]
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
announce && /* @__PURE__ */ jsx("span", { className: "om-clipboard-announcement", role: "status", "aria-atomic": "true", children: state === "copied" || state === "error" ? labels[state] : "" })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
ClipboardButton.displayName = "ClipboardButton";
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
copyText,
|
|
115
|
+
ClipboardButton
|
|
116
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/button.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Button = /* @__PURE__ */ forwardRef(({ className, variant = "primary", size = "md", type = "button", ...props }, ref) => /* @__PURE__ */ jsx("button", { ...props, ref, type, className: cx("om-button", `om-button--${variant}`, `om-button--${size}`, className) }));
|
|
10
|
+
Button.displayName = "Button";
|
|
11
|
+
var ButtonLink = /* @__PURE__ */ forwardRef(({ className, variant = "primary", size = "md", ...props }, ref) => /* @__PURE__ */ jsx("a", { ...props, ref, className: cx("om-button", "om-button--link", `om-button--${variant}`, `om-button--${size}`, className) }));
|
|
12
|
+
ButtonLink.displayName = "ButtonLink";
|
|
13
|
+
var IconButton = /* @__PURE__ */ forwardRef(({ className, variant = "ghost", ...props }, ref) => /* @__PURE__ */ jsx(Button, { ...props, ref, variant, className: cx("om-button--icon", className) }));
|
|
14
|
+
IconButton.displayName = "IconButton";
|
|
15
|
+
var IconLink = /* @__PURE__ */ forwardRef(({ className, variant = "ghost", ...props }, ref) => /* @__PURE__ */ jsx(ButtonLink, { ...props, ref, variant, className: cx("om-button--icon", className) }));
|
|
16
|
+
IconLink.displayName = "IconLink";
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
Button,
|
|
20
|
+
ButtonLink,
|
|
21
|
+
IconButton,
|
|
22
|
+
IconLink
|
|
23
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/platform-link.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var PlatformLink = /* @__PURE__ */ forwardRef(({ className, platform, ...props }, ref) => /* @__PURE__ */ jsx("a", { ...props, ref, className: cx("om-platform-link", className), "data-platform": platform, children: platform === "github" ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "24", height: "24", "aria-hidden": "true", focusable: "false", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M12 1.3a10.7 10.7 0 0 0-3.38 20.85c.54.1.73-.23.73-.52V19.6c-2.98.65-3.61-1.27-3.61-1.27-.49-1.23-1.19-1.56-1.19-1.56-.97-.67.08-.66.08-.66 1.08.08 1.65 1.11 1.65 1.11.95 1.64 2.49 1.16 3.1.89.1-.69.37-1.16.67-1.43-2.38-.27-4.88-1.19-4.88-5.29 0-1.17.42-2.13 1.1-2.88-.11-.27-.48-1.36.11-2.84 0 0 .9-.29 2.94 1.1a10.2 10.2 0 0 1 5.36 0c2.04-1.39 2.93-1.1 2.93-1.1.59 1.48.22 2.57.11 2.84.68.75 1.1 1.71 1.1 2.88 0 4.11-2.51 5.01-4.9 5.28.39.34.73 1 .73 2.01v2.95c0 .29.19.63.74.52A10.7 10.7 0 0 0 12 1.3Z" }) }) : /* @__PURE__ */ jsx("svg", { viewBox: "0 0 32 12", width: "32", height: "12", "aria-hidden": "true", focusable: "false", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: "M0 0H32V12H0ZM2 2V10H4V4H6V10H8V2ZM10 2V10H12V8H18V2ZM12 4H16V6H12ZM20 2V10H22V4H24V10H26V4H28V10H30V2Z" }) }) }));
|
|
10
|
+
PlatformLink.displayName = "PlatformLink";
|
|
11
|
+
var PlatformLinks = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ...props, ref, className: cx("om-platform-links", className) }));
|
|
12
|
+
PlatformLinks.displayName = "PlatformLinks";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
PlatformLink,
|
|
16
|
+
PlatformLinks
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/kbd.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Kbd = /* @__PURE__ */ forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("kbd", { ...props, ref, className: cx("om-kbd", className) }));
|
|
10
|
+
Kbd.displayName = "Kbd";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Kbd
|
|
14
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Select
|
|
4
|
+
} from "./chunk-Z6HKBFCS.js";
|
|
5
|
+
import {
|
|
6
|
+
cx
|
|
7
|
+
} from "./chunk-54STG2JB.js";
|
|
8
|
+
|
|
9
|
+
// src/locale-picker.tsx
|
|
10
|
+
import {
|
|
11
|
+
forwardRef,
|
|
12
|
+
useEffect,
|
|
13
|
+
useImperativeHandle,
|
|
14
|
+
useRef,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var LocalePicker = forwardRef(({
|
|
19
|
+
label,
|
|
20
|
+
options,
|
|
21
|
+
value,
|
|
22
|
+
onValueChange,
|
|
23
|
+
className,
|
|
24
|
+
selectProps
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const fallback = useRef(null);
|
|
27
|
+
const trigger = useRef(null);
|
|
28
|
+
const transferFocus = useRef(false);
|
|
29
|
+
const [enhanced, setEnhanced] = useState(false);
|
|
30
|
+
const current = options.find((option) => option.value === value);
|
|
31
|
+
useImperativeHandle(ref, () => trigger.current, [enhanced]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const element = fallback.current;
|
|
34
|
+
transferFocus.current = Boolean(element?.contains(element.ownerDocument.activeElement));
|
|
35
|
+
setEnhanced(true);
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (enhanced && transferFocus.current) {
|
|
39
|
+
trigger.current?.focus({ preventScroll: true });
|
|
40
|
+
transferFocus.current = false;
|
|
41
|
+
}
|
|
42
|
+
}, [enhanced]);
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("om-locale-picker", className), children: [
|
|
44
|
+
/* @__PURE__ */ jsxs("details", { ref: fallback, className: "om-locale-fallback", hidden: enhanced, children: [
|
|
45
|
+
/* @__PURE__ */ jsx("summary", { "aria-label": label, "aria-disabled": selectProps?.disabled || void 0, lang: current?.lang, children: current?.label ?? label }),
|
|
46
|
+
/* @__PURE__ */ jsx("ul", { className: "om-locale-options", role: "list", children: options.map((option) => /* @__PURE__ */ jsx("li", { lang: option.lang, children: option.disabled || selectProps?.disabled ? /* @__PURE__ */ jsx("span", { "aria-disabled": "true", children: option.label }) : /* @__PURE__ */ jsx("a", { href: option.href, hrefLang: option.lang, "aria-current": option.value === value ? "page" : void 0, children: option.label }) }, option.value)) })
|
|
47
|
+
] }),
|
|
48
|
+
enhanced && /* @__PURE__ */ jsx(
|
|
49
|
+
Select,
|
|
50
|
+
{
|
|
51
|
+
...selectProps,
|
|
52
|
+
ref: trigger,
|
|
53
|
+
"aria-label": label,
|
|
54
|
+
lang: selectProps?.lang ?? current?.lang,
|
|
55
|
+
options,
|
|
56
|
+
value,
|
|
57
|
+
onValueChange: (next) => {
|
|
58
|
+
const option = options.find((item) => item.value === next && !item.disabled);
|
|
59
|
+
if (!option) return;
|
|
60
|
+
if (onValueChange) onValueChange(next, option);
|
|
61
|
+
else trigger.current?.ownerDocument.defaultView?.location.assign(option.href);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
66
|
+
});
|
|
67
|
+
LocalePicker.displayName = "LocalePicker";
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
LocalePicker
|
|
71
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/prose.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var Prose = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("article", { ...props, ref, className: cx("om-prose", className) })
|
|
11
|
+
);
|
|
12
|
+
Prose.displayName = "Prose";
|
|
13
|
+
var ProseScroll = /* @__PURE__ */ forwardRef(
|
|
14
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ...props, ref, className: cx("om-prose-scroll", className) })
|
|
15
|
+
);
|
|
16
|
+
ProseScroll.displayName = "ProseScroll";
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
Prose,
|
|
20
|
+
ProseScroll
|
|
21
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cx
|
|
4
|
+
} from "./chunk-54STG2JB.js";
|
|
5
|
+
|
|
6
|
+
// src/code-block.tsx
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var CodeBlock = /* @__PURE__ */ forwardRef(
|
|
10
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ...props, ref, className: cx("om-code-block", className) })
|
|
11
|
+
);
|
|
12
|
+
CodeBlock.displayName = "CodeBlock";
|
|
13
|
+
var CodeBlockHeader = /* @__PURE__ */ forwardRef(
|
|
14
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ...props, ref, className: cx("om-code-block-header", className) })
|
|
15
|
+
);
|
|
16
|
+
CodeBlockHeader.displayName = "CodeBlockHeader";
|
|
17
|
+
var CodeBlockCaption = /* @__PURE__ */ forwardRef(
|
|
18
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("span", { ...props, ref, className: cx("om-code-block-caption", className) })
|
|
19
|
+
);
|
|
20
|
+
CodeBlockCaption.displayName = "CodeBlockCaption";
|
|
21
|
+
var CodeBlockContent = /* @__PURE__ */ forwardRef(
|
|
22
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("pre", { ...props, ref, className: cx("om-code-block-content", className) })
|
|
23
|
+
);
|
|
24
|
+
CodeBlockContent.displayName = "CodeBlockContent";
|
|
25
|
+
var CodeBlockCopy = /* @__PURE__ */ forwardRef(
|
|
26
|
+
({ className, type = "button", ...props }, ref) => /* @__PURE__ */ jsx("button", { ...props, ref, type, className: cx("om-code-block-copy", className) })
|
|
27
|
+
);
|
|
28
|
+
CodeBlockCopy.displayName = "CodeBlockCopy";
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
CodeBlock,
|
|
32
|
+
CodeBlockHeader,
|
|
33
|
+
CodeBlockCaption,
|
|
34
|
+
CodeBlockContent,
|
|
35
|
+
CodeBlockCopy
|
|
36
|
+
};
|
|
@@ -11,6 +11,9 @@ var tokens = {
|
|
|
11
11
|
"color.accent-hover": "var(--om-semantic-color-accent-hover)",
|
|
12
12
|
"color.on-accent": "var(--om-semantic-color-on-accent)",
|
|
13
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)",
|
|
14
17
|
"color.focus": "var(--om-semantic-color-focus)",
|
|
15
18
|
"color.border-subtle": "var(--om-semantic-color-border-subtle)",
|
|
16
19
|
"color.action": "var(--om-semantic-color-action)",
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Button
|
|
4
|
+
} from "./chunk-A3PPKK5J.js";
|
|
5
|
+
import {
|
|
6
|
+
cx
|
|
7
|
+
} from "./chunk-54STG2JB.js";
|
|
8
|
+
|
|
9
|
+
// src/docs-navigation.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 isOrdinaryClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
19
|
+
var useDisclosure = (mobileLabel, defaultOpen = false) => {
|
|
20
|
+
const panelId = useId();
|
|
21
|
+
const toggle = useRef(null);
|
|
22
|
+
const [enhanced, setEnhanced] = useState(false);
|
|
23
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setEnhanced(true);
|
|
26
|
+
}, []);
|
|
27
|
+
const close = (event, heading) => {
|
|
28
|
+
if (!open || !isOrdinaryClick(event)) return;
|
|
29
|
+
setOpen(false);
|
|
30
|
+
const button = toggle.current;
|
|
31
|
+
const view = button?.ownerDocument.defaultView;
|
|
32
|
+
if (!button || view?.getComputedStyle(button).display === "none") return;
|
|
33
|
+
heading?.focus({ preventScroll: true });
|
|
34
|
+
if (!heading || button.ownerDocument.activeElement !== heading) button.focus({ preventScroll: true });
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
panelId,
|
|
38
|
+
toggle,
|
|
39
|
+
open,
|
|
40
|
+
setOpen,
|
|
41
|
+
close,
|
|
42
|
+
attributes: {
|
|
43
|
+
"data-enhanced": enhanced ? "true" : void 0,
|
|
44
|
+
"data-collapsible": mobileLabel ? "true" : void 0,
|
|
45
|
+
"data-expanded": String(open)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var DocsNavigation = forwardRef(({
|
|
50
|
+
groups,
|
|
51
|
+
currentId,
|
|
52
|
+
mobileLabel,
|
|
53
|
+
defaultMobileOpen,
|
|
54
|
+
onNavigate,
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}, ref) => {
|
|
58
|
+
const disclosure = useDisclosure(mobileLabel, defaultMobileOpen);
|
|
59
|
+
return /* @__PURE__ */ jsxs("nav", { ...props, ...disclosure.attributes, ref, className: cx("om-docs-navigation", className), children: [
|
|
60
|
+
mobileLabel && /* @__PURE__ */ jsx(
|
|
61
|
+
Button,
|
|
62
|
+
{
|
|
63
|
+
ref: disclosure.toggle,
|
|
64
|
+
className: "om-docs-toggle",
|
|
65
|
+
variant: "secondary",
|
|
66
|
+
size: "sm",
|
|
67
|
+
"aria-controls": disclosure.panelId,
|
|
68
|
+
"aria-expanded": disclosure.open,
|
|
69
|
+
onClick: () => disclosure.setOpen((open) => !open),
|
|
70
|
+
children: mobileLabel
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx("div", { className: "om-docs-panel", id: disclosure.panelId, children: groups.map((group) => /* @__PURE__ */ jsxs("div", { className: "om-docs-group", children: [
|
|
74
|
+
group.label && /* @__PURE__ */ jsx("p", { className: "om-docs-group-label", children: group.label }),
|
|
75
|
+
/* @__PURE__ */ jsx("ul", { className: "om-docs-links", role: "list", children: group.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
76
|
+
"a",
|
|
77
|
+
{
|
|
78
|
+
href: item.href,
|
|
79
|
+
"aria-current": item.id === currentId ? "page" : void 0,
|
|
80
|
+
onClick: (event) => {
|
|
81
|
+
if (!isOrdinaryClick(event)) return;
|
|
82
|
+
onNavigate?.(item, event);
|
|
83
|
+
disclosure.close(event);
|
|
84
|
+
},
|
|
85
|
+
children: item.label
|
|
86
|
+
}
|
|
87
|
+
) }, item.id)) })
|
|
88
|
+
] }, group.id)) })
|
|
89
|
+
] });
|
|
90
|
+
});
|
|
91
|
+
DocsNavigation.displayName = "DocsNavigation";
|
|
92
|
+
var observeActiveHeading = (content, headingIds, onActiveChange, { offset = 0 } = {}) => {
|
|
93
|
+
const doc = content.ownerDocument;
|
|
94
|
+
const view = doc.defaultView;
|
|
95
|
+
if (!view) return () => {
|
|
96
|
+
};
|
|
97
|
+
const headings = () => headingIds.flatMap((id) => {
|
|
98
|
+
const heading = doc.getElementById(id);
|
|
99
|
+
return heading && content.contains(heading) ? [heading] : [];
|
|
100
|
+
});
|
|
101
|
+
let frame;
|
|
102
|
+
let active;
|
|
103
|
+
let disposed = false;
|
|
104
|
+
const publish = (next) => {
|
|
105
|
+
if (next === active) return;
|
|
106
|
+
active = next;
|
|
107
|
+
onActiveChange(next);
|
|
108
|
+
};
|
|
109
|
+
const update = () => {
|
|
110
|
+
frame = void 0;
|
|
111
|
+
if (disposed) return;
|
|
112
|
+
const sections = headings();
|
|
113
|
+
const current = sections.slice().reverse().find((heading) => {
|
|
114
|
+
const margin = Number.parseFloat(view.getComputedStyle(heading).scrollMarginTop) || 0;
|
|
115
|
+
return heading.getBoundingClientRect().top <= Math.max(offset, margin) + 24;
|
|
116
|
+
});
|
|
117
|
+
publish(current?.id);
|
|
118
|
+
};
|
|
119
|
+
const schedule = () => {
|
|
120
|
+
if (frame !== void 0) return;
|
|
121
|
+
if (typeof view.requestAnimationFrame === "function") frame = view.requestAnimationFrame(update);
|
|
122
|
+
else update();
|
|
123
|
+
};
|
|
124
|
+
const syncHash = () => {
|
|
125
|
+
const hash = view.location.hash.slice(1);
|
|
126
|
+
let id = hash;
|
|
127
|
+
try {
|
|
128
|
+
id = decodeURIComponent(hash);
|
|
129
|
+
} catch {
|
|
130
|
+
id = hash;
|
|
131
|
+
}
|
|
132
|
+
const match = headings().find((heading) => heading.id === id);
|
|
133
|
+
if (match) publish(match.id);
|
|
134
|
+
else schedule();
|
|
135
|
+
};
|
|
136
|
+
const resize = typeof view.ResizeObserver === "undefined" ? void 0 : new view.ResizeObserver(schedule);
|
|
137
|
+
resize?.observe(content);
|
|
138
|
+
view.addEventListener("scroll", schedule, { passive: true });
|
|
139
|
+
view.addEventListener("resize", schedule);
|
|
140
|
+
view.addEventListener("hashchange", syncHash);
|
|
141
|
+
syncHash();
|
|
142
|
+
return () => {
|
|
143
|
+
disposed = true;
|
|
144
|
+
if (frame !== void 0) view.cancelAnimationFrame(frame);
|
|
145
|
+
resize?.disconnect();
|
|
146
|
+
view.removeEventListener("scroll", schedule);
|
|
147
|
+
view.removeEventListener("resize", schedule);
|
|
148
|
+
view.removeEventListener("hashchange", syncHash);
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
var useActiveHeading = (headingIds, {
|
|
152
|
+
contentId,
|
|
153
|
+
offset,
|
|
154
|
+
enabled = true
|
|
155
|
+
} = {}) => {
|
|
156
|
+
const [active, setActive] = useState();
|
|
157
|
+
const key = JSON.stringify(headingIds);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
setActive(void 0);
|
|
160
|
+
if (!enabled) return;
|
|
161
|
+
const content = contentId ? document.getElementById(contentId) : document.body;
|
|
162
|
+
if (!content) return;
|
|
163
|
+
return observeActiveHeading(content, JSON.parse(key), setActive, { offset });
|
|
164
|
+
}, [key, contentId, offset, enabled]);
|
|
165
|
+
return active;
|
|
166
|
+
};
|
|
167
|
+
var TableOfContents = forwardRef(({
|
|
168
|
+
headings,
|
|
169
|
+
label,
|
|
170
|
+
mobileLabel,
|
|
171
|
+
defaultMobileOpen,
|
|
172
|
+
contentId,
|
|
173
|
+
offset,
|
|
174
|
+
activeId,
|
|
175
|
+
onNavigate,
|
|
176
|
+
className,
|
|
177
|
+
...props
|
|
178
|
+
}, ref) => {
|
|
179
|
+
const observed = useActiveHeading(headings.map((heading) => heading.id), {
|
|
180
|
+
contentId,
|
|
181
|
+
offset,
|
|
182
|
+
enabled: activeId === void 0
|
|
183
|
+
});
|
|
184
|
+
const currentId = activeId === void 0 ? observed : activeId;
|
|
185
|
+
const disclosure = useDisclosure(mobileLabel, defaultMobileOpen);
|
|
186
|
+
return /* @__PURE__ */ jsxs("nav", { "aria-label": label, ...props, ...disclosure.attributes, ref, className: cx("om-table-of-contents", className), children: [
|
|
187
|
+
/* @__PURE__ */ jsx("p", { className: "om-toc-label", children: label }),
|
|
188
|
+
mobileLabel && /* @__PURE__ */ jsx(
|
|
189
|
+
Button,
|
|
190
|
+
{
|
|
191
|
+
ref: disclosure.toggle,
|
|
192
|
+
className: "om-docs-toggle",
|
|
193
|
+
variant: "secondary",
|
|
194
|
+
size: "sm",
|
|
195
|
+
"aria-controls": disclosure.panelId,
|
|
196
|
+
"aria-expanded": disclosure.open,
|
|
197
|
+
onClick: () => disclosure.setOpen((open) => !open),
|
|
198
|
+
children: mobileLabel
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ jsx("ul", { className: "om-docs-panel om-toc-links", id: disclosure.panelId, role: "list", children: headings.map((heading) => /* @__PURE__ */ jsx("li", { "data-level": heading.level ?? 2, children: /* @__PURE__ */ jsx(
|
|
202
|
+
"a",
|
|
203
|
+
{
|
|
204
|
+
href: "#" + encodeURIComponent(heading.id),
|
|
205
|
+
"aria-current": heading.id === currentId ? "location" : void 0,
|
|
206
|
+
onClick: (event) => {
|
|
207
|
+
if (!isOrdinaryClick(event)) return;
|
|
208
|
+
onNavigate?.(heading, event);
|
|
209
|
+
disclosure.close(event, event.currentTarget.ownerDocument.getElementById(heading.id));
|
|
210
|
+
},
|
|
211
|
+
children: heading.label
|
|
212
|
+
}
|
|
213
|
+
) }, heading.id)) })
|
|
214
|
+
] });
|
|
215
|
+
});
|
|
216
|
+
TableOfContents.displayName = "TableOfContents";
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
DocsNavigation,
|
|
220
|
+
observeActiveHeading,
|
|
221
|
+
useActiveHeading,
|
|
222
|
+
TableOfContents
|
|
223
|
+
};
|