@hezhijie0327/zjdesign 0.1.3 → 0.1.4-be4bf14
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/dist/hooks/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, ThemeStorage, ThemeStyle, UseThemeOptions, UseThemeResult, applyThemeStyle, cookieThemeStorage, createThemeController, localStorageThemeStorage, readThemeStyle, reducedMotion, setThemeStyle, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
|
1
|
+
import { _ as setThemeStyle, a as THEME_BOOTSTRAP, b as reducedMotion, c as THEME_COLOR_LIGHT, d as applyThemeStyle, f as cookieThemeStorage, g as readThemeStyle, h as nextThemeStyle, i as useExitPresence, l as ThemeStorage, m as localStorageThemeStorage, n as UseThemeResult, o as THEME_COLOR_BLACK, p as createThemeController, r as useTheme, s as THEME_COLOR_DARK, t as UseThemeOptions, u as ThemeStyle, v as watchSystemTheme, y as watchThemeDark } from "../index-BOksroiF.mjs";
|
|
2
|
+
export { THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, ThemeStorage, ThemeStyle, UseThemeOptions, UseThemeResult, applyThemeStyle, cookieThemeStorage, createThemeController, localStorageThemeStorage, nextThemeStyle, readThemeStyle, reducedMotion, setThemeStyle, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as THEME_COLOR_DARK, c as cookieThemeStorage, d as
|
|
1
|
+
import { a as THEME_COLOR_DARK, c as cookieThemeStorage, d as nextThemeStyle, f as readThemeStyle, g as reducedMotion, h as watchThemeDark, i as THEME_COLOR_BLACK, l as createThemeController, m as watchSystemTheme, n as useExitPresence, o as THEME_COLOR_LIGHT, p as setThemeStyle, r as THEME_BOOTSTRAP, s as applyThemeStyle, t as useTheme, u as localStorageThemeStorage } from "../hooks-Clenmhj0.mjs";
|
|
2
2
|
|
|
3
|
-
export { THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, applyThemeStyle, cookieThemeStorage, createThemeController, localStorageThemeStorage, readThemeStyle, reducedMotion, setThemeStyle, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
|
3
|
+
export { THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, applyThemeStyle, cookieThemeStorage, createThemeController, localStorageThemeStorage, nextThemeStyle, readThemeStyle, reducedMotion, setThemeStyle, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
|
@@ -97,12 +97,26 @@ const defaultController = /* @__PURE__ */ createThemeController();
|
|
|
97
97
|
const readThemeStyle = defaultController.readThemeStyle;
|
|
98
98
|
const applyThemeStyle = defaultController.applyThemeStyle;
|
|
99
99
|
const setThemeStyle = defaultController.setThemeStyle;
|
|
100
|
-
/**
|
|
100
|
+
/** Advance a preference along a cycle order (default: the four-state loop
|
|
101
|
+
* including the OLED tier; pass a three-step order for black-less UIs). */
|
|
102
|
+
function nextThemeStyle(style, order = [
|
|
103
|
+
"auto",
|
|
104
|
+
"light",
|
|
105
|
+
"dark",
|
|
106
|
+
"black"
|
|
107
|
+
]) {
|
|
108
|
+
return order[(order.indexOf(style) + 1) % order.length] ?? "auto";
|
|
109
|
+
}
|
|
110
|
+
/** In auto mode, follow the system light/dark switch in real time.
|
|
111
|
+
* Returns an unsubscribe function (call it on teardown). */
|
|
101
112
|
function watchSystemTheme(storage = localStorageThemeStorage()) {
|
|
102
|
-
window.matchMedia("(prefers-color-scheme: dark)")
|
|
113
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
114
|
+
const onChange = () => {
|
|
103
115
|
const controller = createThemeController(storage);
|
|
104
116
|
if (controller.readThemeStyle() === "auto") controller.applyThemeStyle("auto");
|
|
105
|
-
}
|
|
117
|
+
};
|
|
118
|
+
mq.addEventListener("change", onChange);
|
|
119
|
+
return () => mq.removeEventListener("change", onChange);
|
|
106
120
|
}
|
|
107
121
|
/** Subscribe to the dark state (html.dark is the single source of truth; both in-site
|
|
108
122
|
* toggles and system-follow flip it). Returns an unsubscribe function. Heavy theme
|
|
@@ -217,4 +231,4 @@ function useTheme({ storage = localStorageThemeStorage(), order = [
|
|
|
217
231
|
}
|
|
218
232
|
|
|
219
233
|
//#endregion
|
|
220
|
-
export { THEME_COLOR_DARK as a, cookieThemeStorage as c,
|
|
234
|
+
export { THEME_COLOR_DARK as a, cookieThemeStorage as c, nextThemeStyle as d, readThemeStyle as f, reducedMotion as g, watchThemeDark as h, THEME_COLOR_BLACK as i, createThemeController as l, watchSystemTheme as m, useExitPresence as n, THEME_COLOR_LIGHT as o, setThemeStyle as p, THEME_BOOTSTRAP as r, applyThemeStyle as s, useTheme as t, localStorageThemeStorage as u };
|
|
@@ -40,8 +40,12 @@ declare function createThemeController(storage?: ThemeStorage): {
|
|
|
40
40
|
declare const readThemeStyle: () => ThemeStyle;
|
|
41
41
|
declare const applyThemeStyle: (style: ThemeStyle) => void;
|
|
42
42
|
declare const setThemeStyle: (style: ThemeStyle) => void;
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/** Advance a preference along a cycle order (default: the four-state loop
|
|
44
|
+
* including the OLED tier; pass a three-step order for black-less UIs). */
|
|
45
|
+
declare function nextThemeStyle(style: ThemeStyle, order?: ThemeStyle[]): ThemeStyle;
|
|
46
|
+
/** In auto mode, follow the system light/dark switch in real time.
|
|
47
|
+
* Returns an unsubscribe function (call it on teardown). */
|
|
48
|
+
declare function watchSystemTheme(storage?: ThemeStorage): () => void;
|
|
45
49
|
/** Subscribe to the dark state (html.dark is the single source of truth; both in-site
|
|
46
50
|
* toggles and system-follow flip it). Returns an unsubscribe function. Heavy theme
|
|
47
51
|
* dependencies (giscus iframe / mermaid re-render) hook in here — do not attach your own
|
|
@@ -98,4 +102,4 @@ declare function useTheme({
|
|
|
98
102
|
order
|
|
99
103
|
}?: UseThemeOptions): UseThemeResult;
|
|
100
104
|
//#endregion
|
|
101
|
-
export {
|
|
105
|
+
export { setThemeStyle as _, THEME_BOOTSTRAP as a, reducedMotion as b, THEME_COLOR_LIGHT as c, applyThemeStyle as d, cookieThemeStorage as f, readThemeStyle as g, nextThemeStyle as h, useExitPresence as i, ThemeStorage as l, localStorageThemeStorage as m, UseThemeResult as n, THEME_COLOR_BLACK as o, createThemeController as p, useTheme as r, THEME_COLOR_DARK as s, UseThemeOptions as t, ThemeStyle as u, watchSystemTheme as v, watchThemeDark as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import * as
|
|
1
|
+
import { _ as setThemeStyle, a as THEME_BOOTSTRAP, b as reducedMotion, c as THEME_COLOR_LIGHT, d as applyThemeStyle, f as cookieThemeStorage, g as readThemeStyle, h as nextThemeStyle, i as useExitPresence, l as ThemeStorage, m as localStorageThemeStorage, n as UseThemeResult, o as THEME_COLOR_BLACK, p as createThemeController, r as useTheme, s as THEME_COLOR_DARK, t as UseThemeOptions, u as ThemeStyle, v as watchSystemTheme, y as watchThemeDark } from "./index-BOksroiF.mjs";
|
|
2
|
+
import * as react2 from "react";
|
|
3
3
|
import { ButtonHTMLAttributes, ReactNode, RefObject } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Button/Button.d.ts
|
|
@@ -9,7 +9,7 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
9
9
|
}
|
|
10
10
|
/** Pill button in the family language (BTN_PRIMARY / BTN_OUTLINE / BTN_GHOST
|
|
11
11
|
* fragments + the danger state). */
|
|
12
|
-
declare const Button:
|
|
12
|
+
declare const Button: react2.ForwardRefExoticComponent<ButtonProps & react2.RefAttributes<HTMLButtonElement>>;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/components/Collapse/Collapse.d.ts
|
|
15
15
|
/**
|
|
@@ -42,16 +42,18 @@ declare function Collapse({
|
|
|
42
42
|
className?: string;
|
|
43
43
|
id?: string;
|
|
44
44
|
children: ReactNode;
|
|
45
|
-
}):
|
|
45
|
+
}): react2.JSX.Element | null;
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/components/IconButton/IconButton.d.ts
|
|
48
48
|
interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
49
49
|
/** accessibility label (aria-label + title) */
|
|
50
50
|
label: string;
|
|
51
51
|
active?: boolean;
|
|
52
|
+
/** aria-expanded passthrough for triggers (popovers / drawers) */
|
|
53
|
+
expanded?: boolean;
|
|
52
54
|
}
|
|
53
55
|
/** Round icon button (ICON_BTN fragment); `active` lights the accent. */
|
|
54
|
-
declare const IconButton:
|
|
56
|
+
declare const IconButton: react2.ForwardRefExoticComponent<IconButtonProps & react2.RefAttributes<HTMLButtonElement>>;
|
|
55
57
|
//#endregion
|
|
56
58
|
//#region src/components/CopyButton/CopyButton.d.ts
|
|
57
59
|
interface CopyButtonProps extends Omit<IconButtonProps, "label" | "children" | "onClick"> {
|
|
@@ -69,7 +71,7 @@ declare function CopyButton({
|
|
|
69
71
|
label,
|
|
70
72
|
feedbackMs,
|
|
71
73
|
...props
|
|
72
|
-
}: CopyButtonProps):
|
|
74
|
+
}: CopyButtonProps): react2.JSX.Element;
|
|
73
75
|
//#endregion
|
|
74
76
|
//#region src/components/Dropdown/Dropdown.d.ts
|
|
75
77
|
interface DropdownOption {
|
|
@@ -90,7 +92,9 @@ interface DropdownProps {
|
|
|
90
92
|
}
|
|
91
93
|
/** Custom select wearing the family skin: hairline trigger button + CARD
|
|
92
94
|
* popover list (LIST_ROW rows, accent check on the selected option).
|
|
93
|
-
* Replaces every native <select> — the OS dropdown sheet breaks the style.
|
|
95
|
+
* Replaces every native <select> — the OS dropdown sheet breaks the style.
|
|
96
|
+
* Keyboard: ArrowDown/Up opens and moves through options, Home/End jump,
|
|
97
|
+
* Enter picks, Esc closes back to the trigger (APG listbox pattern). */
|
|
94
98
|
declare function Dropdown({
|
|
95
99
|
label,
|
|
96
100
|
value,
|
|
@@ -101,7 +105,7 @@ declare function Dropdown({
|
|
|
101
105
|
menuClassName,
|
|
102
106
|
disabled,
|
|
103
107
|
id
|
|
104
|
-
}: DropdownProps):
|
|
108
|
+
}: DropdownProps): react2.JSX.Element;
|
|
105
109
|
//#endregion
|
|
106
110
|
//#region src/components/Kbd/Kbd.d.ts
|
|
107
111
|
/** Mono chip for keys / states (MONO_CHIP fragment with tighter padding). */
|
|
@@ -111,7 +115,7 @@ declare function Kbd({
|
|
|
111
115
|
}: {
|
|
112
116
|
children: ReactNode;
|
|
113
117
|
className?: string;
|
|
114
|
-
}):
|
|
118
|
+
}): react2.JSX.Element;
|
|
115
119
|
/** Single-line panel row label (text-sm) — the standard row label inside
|
|
116
120
|
* toolbar panels. Never wraps: narrow rows scale via column layout instead. */
|
|
117
121
|
declare const ROW_LABEL = "shrink-0 whitespace-nowrap text-sm text-ink";
|
|
@@ -136,7 +140,7 @@ declare function Modal({
|
|
|
136
140
|
label,
|
|
137
141
|
className,
|
|
138
142
|
children
|
|
139
|
-
}: ModalProps):
|
|
143
|
+
}: ModalProps): react2.ReactPortal | null;
|
|
140
144
|
//#endregion
|
|
141
145
|
//#region src/components/Popover/Popover.d.ts
|
|
142
146
|
interface PopoverProps {
|
|
@@ -160,7 +164,7 @@ declare function Popover({
|
|
|
160
164
|
className,
|
|
161
165
|
children,
|
|
162
166
|
anchorRef
|
|
163
|
-
}: PopoverProps):
|
|
167
|
+
}: PopoverProps): react2.JSX.Element | null;
|
|
164
168
|
//#endregion
|
|
165
169
|
//#region src/components/ProgressBar/ProgressBar.d.ts
|
|
166
170
|
/** Top-of-page loading bar: 2px accent strip riding the `progress` keyframes
|
|
@@ -170,7 +174,7 @@ declare function ProgressBar({
|
|
|
170
174
|
className
|
|
171
175
|
}: {
|
|
172
176
|
className?: string;
|
|
173
|
-
}):
|
|
177
|
+
}): react2.JSX.Element;
|
|
174
178
|
//#endregion
|
|
175
179
|
//#region src/components/Segmented/Segmented.d.ts
|
|
176
180
|
interface SegmentedProps<T extends string | number> {
|
|
@@ -190,7 +194,7 @@ declare function Segmented<T extends string | number>({
|
|
|
190
194
|
onChange,
|
|
191
195
|
label,
|
|
192
196
|
className
|
|
193
|
-
}: SegmentedProps<T>):
|
|
197
|
+
}: SegmentedProps<T>): react2.JSX.Element;
|
|
194
198
|
//#endregion
|
|
195
199
|
//#region src/components/Slider/Slider.d.ts
|
|
196
200
|
interface SliderProps {
|
|
@@ -215,7 +219,7 @@ declare function Slider({
|
|
|
215
219
|
label,
|
|
216
220
|
display,
|
|
217
221
|
className
|
|
218
|
-
}: SliderProps):
|
|
222
|
+
}: SliderProps): react2.JSX.Element;
|
|
219
223
|
//#endregion
|
|
220
224
|
//#region src/components/Switch/Switch.d.ts
|
|
221
225
|
interface SwitchProps {
|
|
@@ -232,12 +236,12 @@ declare function Switch({
|
|
|
232
236
|
label,
|
|
233
237
|
className,
|
|
234
238
|
disabled
|
|
235
|
-
}: SwitchProps):
|
|
239
|
+
}: SwitchProps): react2.JSX.Element;
|
|
236
240
|
//#endregion
|
|
237
241
|
//#region src/components/Toast/Toaster.d.ts
|
|
238
242
|
/** Toast stack: bottom-center paper cards, fade-up in, auto-removed after 3 s.
|
|
239
243
|
* Mount once near the app root. */
|
|
240
|
-
declare function Toaster():
|
|
244
|
+
declare function Toaster(): react2.JSX.Element | null;
|
|
241
245
|
//#endregion
|
|
242
246
|
//#region src/components/Toast/types.d.ts
|
|
243
247
|
interface ToastItem {
|
|
@@ -248,9 +252,8 @@ interface ToastItem {
|
|
|
248
252
|
//#endregion
|
|
249
253
|
//#region src/components/Toast/toast.d.ts
|
|
250
254
|
type Listener = (toasts: ToastItem[]) => void;
|
|
251
|
-
/** Push a toast; `tone` picks the border/text treatment ("ok" default). */
|
|
252
255
|
declare function toast(text: string, tone?: ToastItem["tone"]): void;
|
|
253
256
|
declare function subscribeToasts(listener: Listener): () => void;
|
|
254
257
|
declare function getToasts(): ToastItem[];
|
|
255
258
|
//#endregion
|
|
256
|
-
export { Button, type ButtonProps, Collapse, CopyButton, type CopyButtonProps, Dropdown, type DropdownOption, type DropdownProps, IconButton, type IconButtonProps, Kbd, Modal, type ModalProps, Popover, type PopoverProps, ProgressBar, ROW_LABEL, Segmented, type SegmentedProps, Slider, type SliderProps, Switch, type SwitchProps, THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, ThemeStorage, ThemeStyle, type ToastItem, Toaster, UseThemeOptions, UseThemeResult, applyThemeStyle, cookieThemeStorage, createThemeController, getToasts, localStorageThemeStorage, readThemeStyle, reducedMotion, setThemeStyle, subscribeToasts, toast, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
|
259
|
+
export { Button, type ButtonProps, Collapse, CopyButton, type CopyButtonProps, Dropdown, type DropdownOption, type DropdownProps, IconButton, type IconButtonProps, Kbd, Modal, type ModalProps, Popover, type PopoverProps, ProgressBar, ROW_LABEL, Segmented, type SegmentedProps, Slider, type SliderProps, Switch, type SwitchProps, THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, ThemeStorage, ThemeStyle, type ToastItem, Toaster, UseThemeOptions, UseThemeResult, applyThemeStyle, cookieThemeStorage, createThemeController, getToasts, localStorageThemeStorage, nextThemeStyle, readThemeStyle, reducedMotion, setThemeStyle, subscribeToasts, toast, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as SEGMENT, M as SEGMENT_ITEM_OFF, N as SEGMENT_ITEM_ON, V as cn, _ as META, a as BTN_PRIMARY, b as MODAL_SCRIM, h as LIST_ROW, i as BTN_OUTLINE, o as CARD, p as ICON_BTN, r as BTN_GHOST, x as MONO_CHIP } from "./styles-DhIa1Tm9.mjs";
|
|
2
|
-
import { a as THEME_COLOR_DARK, c as cookieThemeStorage, d as
|
|
2
|
+
import { a as THEME_COLOR_DARK, c as cookieThemeStorage, d as nextThemeStyle, f as readThemeStyle, g as reducedMotion, h as watchThemeDark, i as THEME_COLOR_BLACK, l as createThemeController, m as watchSystemTheme, n as useExitPresence, o as THEME_COLOR_LIGHT, p as setThemeStyle, r as THEME_BOOTSTRAP, s as applyThemeStyle, t as useTheme, u as localStorageThemeStorage } from "./hooks-Clenmhj0.mjs";
|
|
3
3
|
import { forwardRef, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Check, ChevronDown, Copy } from "lucide-react";
|
|
@@ -89,13 +89,14 @@ function Collapse({ open, unmountAfterHide = false, animateOnMount = false, clas
|
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/components/IconButton/IconButton.tsx
|
|
91
91
|
/** Round icon button (ICON_BTN fragment); `active` lights the accent. */
|
|
92
|
-
const IconButton = forwardRef(function IconButton$1({ label, active = false, className, type = "button", children, ...props }, ref) {
|
|
92
|
+
const IconButton = forwardRef(function IconButton$1({ label, active = false, expanded, className, type = "button", children, ...props }, ref) {
|
|
93
93
|
return /* @__PURE__ */ jsx("button", {
|
|
94
94
|
ref,
|
|
95
95
|
type,
|
|
96
96
|
"aria-label": label,
|
|
97
97
|
title: label,
|
|
98
98
|
"aria-pressed": active || void 0,
|
|
99
|
+
"aria-expanded": expanded,
|
|
99
100
|
className: cn(ICON_BTN, active && "bg-accent-soft text-accent hover:text-accent", className),
|
|
100
101
|
...props,
|
|
101
102
|
children
|
|
@@ -171,11 +172,36 @@ function Popover({ open, onClose, side = "bottom", align = "center", className,
|
|
|
171
172
|
//#region src/components/Dropdown/Dropdown.tsx
|
|
172
173
|
/** Custom select wearing the family skin: hairline trigger button + CARD
|
|
173
174
|
* popover list (LIST_ROW rows, accent check on the selected option).
|
|
174
|
-
* Replaces every native <select> — the OS dropdown sheet breaks the style.
|
|
175
|
+
* Replaces every native <select> — the OS dropdown sheet breaks the style.
|
|
176
|
+
* Keyboard: ArrowDown/Up opens and moves through options, Home/End jump,
|
|
177
|
+
* Enter picks, Esc closes back to the trigger (APG listbox pattern). */
|
|
175
178
|
function Dropdown({ label, value, options, onChange, onOpen, className, menuClassName, disabled, id }) {
|
|
176
179
|
const [open, setOpen] = useState(false);
|
|
177
180
|
const buttonRef = useRef(null);
|
|
181
|
+
const listRef = useRef(null);
|
|
178
182
|
const current = options.find((option) => option.value === value);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (!open) return;
|
|
185
|
+
(listRef.current?.querySelector("[aria-selected=\"true\"]") ?? listRef.current?.querySelector("button"))?.focus();
|
|
186
|
+
}, [open]);
|
|
187
|
+
const openMenu = () => {
|
|
188
|
+
if (!open) onOpen?.();
|
|
189
|
+
setOpen(true);
|
|
190
|
+
};
|
|
191
|
+
const moveFocus = (event) => {
|
|
192
|
+
const buttons = [...listRef.current?.querySelectorAll("button[role=option]") ?? []];
|
|
193
|
+
if (buttons.length === 0) return;
|
|
194
|
+
const activeIdx = buttons.indexOf(document.activeElement);
|
|
195
|
+
let next = activeIdx;
|
|
196
|
+
if (event.key === "ArrowDown") next = Math.min(activeIdx + 1, buttons.length - 1);
|
|
197
|
+
else if (event.key === "ArrowUp") next = Math.max(activeIdx - 1, 0);
|
|
198
|
+
else if (event.key === "Home") next = 0;
|
|
199
|
+
else if (event.key === "End") next = buttons.length - 1;
|
|
200
|
+
else return;
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
event.stopPropagation();
|
|
203
|
+
buttons[next]?.focus();
|
|
204
|
+
};
|
|
179
205
|
return /* @__PURE__ */ jsxs("div", {
|
|
180
206
|
className: cn("relative", className),
|
|
181
207
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
@@ -187,9 +213,15 @@ function Dropdown({ label, value, options, onChange, onOpen, className, menuClas
|
|
|
187
213
|
"aria-label": label,
|
|
188
214
|
title: label,
|
|
189
215
|
disabled: disabled || options.length === 0,
|
|
216
|
+
onKeyDown: (event) => {
|
|
217
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
openMenu();
|
|
220
|
+
}
|
|
221
|
+
},
|
|
190
222
|
onClick: () => {
|
|
191
|
-
if (
|
|
192
|
-
|
|
223
|
+
if (open) setOpen(false);
|
|
224
|
+
else openMenu();
|
|
193
225
|
},
|
|
194
226
|
className: "inline-flex h-9 w-full items-center justify-between gap-2 rounded-xl border border-line bg-surface px-3 text-[13px] text-ink transition-colors hover:bg-surface-2 disabled:opacity-50",
|
|
195
227
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -207,8 +239,11 @@ function Dropdown({ label, value, options, onChange, onOpen, className, menuClas
|
|
|
207
239
|
anchorRef: buttonRef,
|
|
208
240
|
className: cn("w-full min-w-44", menuClassName),
|
|
209
241
|
children: /* @__PURE__ */ jsx("div", {
|
|
242
|
+
ref: listRef,
|
|
210
243
|
role: "listbox",
|
|
211
244
|
"aria-label": label,
|
|
245
|
+
tabIndex: -1,
|
|
246
|
+
onKeyDown: moveFocus,
|
|
212
247
|
className: "divide-y divide-line/70",
|
|
213
248
|
children: options.map((option) => {
|
|
214
249
|
const selected = option.value === value;
|
|
@@ -363,7 +398,7 @@ function Switch({ checked, onChange, label, className, disabled }) {
|
|
|
363
398
|
className: cn("relative h-5.5 w-10 shrink-0 rounded-full border transition-colors", checked ? "border-accent-strong bg-accent-strong" : "border-line bg-surface-2", disabled && "cursor-default opacity-50", className),
|
|
364
399
|
children: /* @__PURE__ */ jsx("span", {
|
|
365
400
|
"aria-hidden": "true",
|
|
366
|
-
className: cn("absolute top-1/2 size-4 -translate-y-1/2 rounded-full shadow-card transition-all", checked ? "left-[calc(100%-1.125rem)] bg-
|
|
401
|
+
className: cn("absolute top-1/2 size-4 -translate-y-1/2 rounded-full shadow-card transition-all", checked ? "left-[calc(100%-1.125rem)] bg-surface" : "left-0.5 border border-line bg-surface")
|
|
367
402
|
})
|
|
368
403
|
});
|
|
369
404
|
}
|
|
@@ -376,7 +411,12 @@ let nextId = 1;
|
|
|
376
411
|
function emit() {
|
|
377
412
|
for (const listener of listeners) listener(toasts);
|
|
378
413
|
}
|
|
379
|
-
/** Push a toast; `tone` picks the border/text treatment ("ok" default).
|
|
414
|
+
/** Push a toast; `tone` picks the border/text treatment ("ok" default).
|
|
415
|
+
* Danger lingers longer — failure text that vanishes as fast as success
|
|
416
|
+
* text gets missed, and burst failures would otherwise replace each other
|
|
417
|
+
* unread. */
|
|
418
|
+
const OK_MS = 3e3;
|
|
419
|
+
const DANGER_MS = 6e3;
|
|
380
420
|
function toast(text, tone = "ok") {
|
|
381
421
|
const id = nextId++;
|
|
382
422
|
toasts = [...toasts.slice(-3), {
|
|
@@ -388,7 +428,7 @@ function toast(text, tone = "ok") {
|
|
|
388
428
|
window.setTimeout(() => {
|
|
389
429
|
toasts = toasts.filter((item) => item.id !== id);
|
|
390
430
|
emit();
|
|
391
|
-
},
|
|
431
|
+
}, tone === "danger" ? DANGER_MS : OK_MS);
|
|
392
432
|
}
|
|
393
433
|
function subscribeToasts(listener) {
|
|
394
434
|
listeners.add(listener);
|
|
@@ -418,4 +458,4 @@ function Toaster() {
|
|
|
418
458
|
}
|
|
419
459
|
|
|
420
460
|
//#endregion
|
|
421
|
-
export { Button, Collapse, CopyButton, Dropdown, IconButton, Kbd, Modal, Popover, ProgressBar, ROW_LABEL, Segmented, Slider, Switch, THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, Toaster, applyThemeStyle, cookieThemeStorage, createThemeController, getToasts, localStorageThemeStorage, readThemeStyle, reducedMotion, setThemeStyle, subscribeToasts, toast, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
|
461
|
+
export { Button, Collapse, CopyButton, Dropdown, IconButton, Kbd, Modal, Popover, ProgressBar, ROW_LABEL, Segmented, Slider, Switch, THEME_BOOTSTRAP, THEME_COLOR_BLACK, THEME_COLOR_DARK, THEME_COLOR_LIGHT, Toaster, applyThemeStyle, cookieThemeStorage, createThemeController, getToasts, localStorageThemeStorage, nextThemeStyle, readThemeStyle, reducedMotion, setThemeStyle, subscribeToasts, toast, useExitPresence, useTheme, watchSystemTheme, watchThemeDark };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hezhijie0327/zjdesign",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-be4bf14",
|
|
4
4
|
"description": "ZJ Design — the shared design system of the ZJ product family (warm paper / ink / amber-gold). Tokens, Tailwind fragments, hooks and React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design-system",
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"lint:fix": "biome check --write .",
|
|
66
66
|
"test": "vitest run",
|
|
67
67
|
"dev": "vite serve playground",
|
|
68
|
-
"playground:build": "vite build playground"
|
|
68
|
+
"playground:build": "vite build playground",
|
|
69
|
+
"deploy:playground": "vite build playground --config playground/vite.config.ts && wrangler deploy -c playground/wrangler.jsonc"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
72
|
"clsx": "^2.1.1",
|
|
@@ -93,7 +94,8 @@
|
|
|
93
94
|
"tsdown": "^0.16.0",
|
|
94
95
|
"typescript": "^5.9.0",
|
|
95
96
|
"vite": "^8.3.5",
|
|
96
|
-
"vitest": "^4.0.0"
|
|
97
|
+
"vitest": "^4.0.0",
|
|
98
|
+
"wrangler": "^4.156.2"
|
|
97
99
|
},
|
|
98
100
|
"publishConfig": {
|
|
99
101
|
"registry": "https://registry.npmjs.org/"
|