@aaas-pro/library 0.0.0-stage → 0.1.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 +107 -2
- package/dist/components/address-picker.d.ts +18 -0
- package/dist/components/address-picker.js +46 -0
- package/dist/components/card-date-filter.d.ts +12 -0
- package/dist/components/card-date-filter.js +95 -0
- package/dist/components/date-time-picker.d.ts +12 -0
- package/dist/components/date-time-picker.js +96 -0
- package/dist/components/detail-dialog.d.ts +48 -0
- package/dist/components/detail-dialog.js +97 -0
- package/dist/components/document-links.d.ts +13 -0
- package/dist/components/document-links.js +19 -0
- package/dist/components/draft-row-actions.d.ts +14 -0
- package/dist/components/draft-row-actions.js +70 -0
- package/dist/components/error-boundary.d.ts +14 -0
- package/dist/components/error-boundary.js +35 -0
- package/dist/components/glow-card.d.ts +13 -0
- package/dist/components/glow-card.js +48 -0
- package/dist/components/org-picker.d.ts +17 -0
- package/dist/components/org-picker.js +56 -0
- package/dist/components/overflow-row-actions.d.ts +29 -0
- package/dist/components/overflow-row-actions.js +135 -0
- package/dist/components/page-header.d.ts +21 -0
- package/dist/components/page-header.js +21 -0
- package/dist/components/permission-button.d.ts +4 -0
- package/dist/components/permission-button.js +17 -0
- package/dist/components/permission-context.d.ts +12 -0
- package/dist/components/permission-context.js +17 -0
- package/dist/components/person-picker.d.ts +20 -0
- package/dist/components/person-picker.js +38 -0
- package/dist/components/process-flow-bar.d.ts +15 -0
- package/dist/components/process-flow-bar.js +19 -0
- package/dist/components/product-picker.d.ts +19 -0
- package/dist/components/product-picker.js +155 -0
- package/dist/components/ref-doc-picker.d.ts +24 -0
- package/dist/components/ref-doc-picker.js +139 -0
- package/dist/components/scroll-to-top.d.ts +1 -0
- package/dist/components/scroll-to-top.js +20 -0
- package/dist/components/state-view.d.ts +26 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/theme-switcher.d.ts +27 -0
- package/dist/components/theme-switcher.js +77 -0
- package/dist/components/time-filter.d.ts +7 -0
- package/dist/components/time-filter.js +65 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +64 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.js +160 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +66 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +10 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/avatar.js +53 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +44 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb.js +103 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.js +76 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +93 -0
- package/dist/components/ui/calendar.d.ts +73 -0
- package/dist/components/ui/calendar.js +103 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.js +90 -0
- package/dist/components/ui/carousel.d.ts +14 -0
- package/dist/components/ui/carousel.js +200 -0
- package/dist/components/ui/chart.d.ts +43 -0
- package/dist/components/ui/chart.js +252 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +34 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/command.js +170 -0
- package/dist/components/ui/context-menu.d.ts +26 -0
- package/dist/components/ui/context-menu.js +237 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +139 -0
- package/dist/components/ui/drawer.d.ts +13 -0
- package/dist/components/ui/drawer.js +129 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.js +245 -0
- package/dist/components/ui/empty.d.ts +14 -0
- package/dist/components/ui/empty.js +102 -0
- package/dist/components/ui/field.d.ts +27 -0
- package/dist/components/ui/field.js +229 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/form.js +118 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +39 -0
- package/dist/components/ui/input-group.d.ts +22 -0
- package/dist/components/ui/input-group.js +156 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +66 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +21 -0
- package/dist/components/ui/item.d.ts +29 -0
- package/dist/components/ui/item.js +187 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +31 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +22 -0
- package/dist/components/ui/menubar.d.ts +26 -0
- package/dist/components/ui/menubar.js +252 -0
- package/dist/components/ui/navigation-menu.d.ts +17 -0
- package/dist/components/ui/navigation-menu.js +170 -0
- package/dist/components/ui/pagination.d.ts +13 -0
- package/dist/components/ui/pagination.js +118 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.js +47 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/progress.js +34 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +45 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +49 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +60 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +215 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +26 -0
- package/dist/components/ui/sheet.d.ts +13 -0
- package/dist/components/ui/sheet.js +127 -0
- package/dist/components/ui/sidebar.d.ts +72 -0
- package/dist/components/ui/sidebar.js +656 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +63 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +34 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +17 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +31 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +114 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +67 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +9 -0
- package/dist/components/ui/toggle-group.js +68 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +43 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +56 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +115 -0
- package/dist/icons/paths.d.ts +556 -0
- package/dist/icons/paths.js +231 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +399 -0
- package/dist/internal/selection-base.d.ts +37 -0
- package/dist/internal/selection-base.js +40 -0
- package/dist/lib/class-names.d.ts +6 -0
- package/dist/lib/class-names.js +159 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/variants.d.ts +21 -0
- package/dist/lib/variants.js +21 -0
- package/dist/primitives/accordion.d.ts +29 -0
- package/dist/primitives/accordion.js +49 -0
- package/dist/primitives/alert-dialog.d.ts +10 -0
- package/dist/primitives/alert-dialog.js +22 -0
- package/dist/primitives/aspect-ratio.d.ts +4 -0
- package/dist/primitives/aspect-ratio.js +7 -0
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +45 -0
- package/dist/primitives/carousel.d.ts +22 -0
- package/dist/primitives/carousel.js +78 -0
- package/dist/primitives/chart.d.ts +71 -0
- package/dist/primitives/chart.js +125 -0
- package/dist/primitives/checkbox.d.ts +13 -0
- package/dist/primitives/checkbox.js +24 -0
- package/dist/primitives/collapsible.d.ts +14 -0
- package/dist/primitives/collapsible.js +29 -0
- package/dist/primitives/command.d.ts +43 -0
- package/dist/primitives/command.js +98 -0
- package/dist/primitives/context-menu.d.ts +24 -0
- package/dist/primitives/context-menu.js +19 -0
- package/dist/primitives/core.d.ts +25 -0
- package/dist/primitives/core.js +89 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +15 -0
- package/dist/primitives/drawer.d.ts +30 -0
- package/dist/primitives/drawer.js +39 -0
- package/dist/primitives/dropdown-menu.d.ts +24 -0
- package/dist/primitives/dropdown-menu.js +19 -0
- package/dist/primitives/form.d.ts +154 -0
- package/dist/primitives/form.js +139 -0
- package/dist/primitives/hover-card.d.ts +4 -0
- package/dist/primitives/hover-card.js +8 -0
- package/dist/primitives/input-otp.d.ts +21 -0
- package/dist/primitives/input-otp.js +78 -0
- package/dist/primitives/label.d.ts +2 -0
- package/dist/primitives/label.js +7 -0
- package/dist/primitives/layer.d.ts +84 -0
- package/dist/primitives/layer.js +300 -0
- package/dist/primitives/menu.d.ts +56 -0
- package/dist/primitives/menu.js +126 -0
- package/dist/primitives/menubar.d.ts +91 -0
- package/dist/primitives/menubar.js +44 -0
- package/dist/primitives/navigation-menu.d.ts +32 -0
- package/dist/primitives/navigation-menu.js +121 -0
- package/dist/primitives/popover.d.ts +4 -0
- package/dist/primitives/popover.js +12 -0
- package/dist/primitives/progress.d.ts +7 -0
- package/dist/primitives/progress.js +13 -0
- package/dist/primitives/radio-group.d.ts +18 -0
- package/dist/primitives/radio-group.js +36 -0
- package/dist/primitives/resizable.d.ts +19 -0
- package/dist/primitives/resizable.js +91 -0
- package/dist/primitives/scroll-area.d.ts +12 -0
- package/dist/primitives/scroll-area.js +26 -0
- package/dist/primitives/select.d.ts +42 -0
- package/dist/primitives/select.js +167 -0
- package/dist/primitives/separator.d.ts +5 -0
- package/dist/primitives/separator.js +7 -0
- package/dist/primitives/slider.d.ts +25 -0
- package/dist/primitives/slider.js +98 -0
- package/dist/primitives/slot.d.ts +1 -0
- package/dist/primitives/slot.js +4 -0
- package/dist/primitives/switch.d.ts +11 -0
- package/dist/primitives/switch.js +22 -0
- package/dist/primitives/tabs.d.ts +23 -0
- package/dist/primitives/tabs.js +38 -0
- package/dist/primitives/toast.d.ts +55 -0
- package/dist/primitives/toast.js +86 -0
- package/dist/primitives/toggle-group.d.ts +24 -0
- package/dist/primitives/toggle-group.js +33 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +13 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +10 -0
- package/dist/style-entry.d.ts +1 -0
- package/dist/style-entry.js +1 -0
- package/dist/styles.css +7016 -0
- package/dist/styles.js +1 -0
- package/dist/theme/index.d.ts +110 -0
- package/dist/theme/index.js +199 -0
- package/licenses/Lucide.txt +15 -0
- package/package.json +67 -4
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
let sequence = 0, snapshot = [];
|
|
4
|
+
const subscribers = /* @__PURE__ */ new Set(), timers = /* @__PURE__ */ new Map();
|
|
5
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
6
|
+
const empty = [];
|
|
7
|
+
const notify = () => subscribers.forEach((callback) => callback());
|
|
8
|
+
function dismiss(id, automatic = false) {
|
|
9
|
+
const removed = snapshot.filter((item) => id === void 0 || item.id === id);
|
|
10
|
+
snapshot = snapshot.filter((item) => !removed.includes(item));
|
|
11
|
+
removed.forEach((item) => {
|
|
12
|
+
clearTimeout(timers.get(item.id));
|
|
13
|
+
timers.delete(item.id);
|
|
14
|
+
automatic ? item.onAutoClose?.(item) : item.onDismiss?.(item);
|
|
15
|
+
});
|
|
16
|
+
notify();
|
|
17
|
+
}
|
|
18
|
+
function add(type, title, options = {}) {
|
|
19
|
+
options = { ...defaults.get(options.toasterId), ...options, ...type === "loading" && options.duration === void 0 ? { duration: Infinity } : {} };
|
|
20
|
+
const id = options.id ?? ++sequence, item = { ...options, id, title, type };
|
|
21
|
+
clearTimeout(timers.get(id));
|
|
22
|
+
snapshot = [...snapshot.filter((item2) => item2.id !== id), item];
|
|
23
|
+
notify();
|
|
24
|
+
const duration = options.duration ?? (type === "loading" ? Infinity : 4e3);
|
|
25
|
+
if (Number.isFinite(duration) && duration > 0) timers.set(id, setTimeout(() => dismiss(id, true), duration));
|
|
26
|
+
return id;
|
|
27
|
+
}
|
|
28
|
+
const toast = Object.assign((title, options) => add("message", title, options), {
|
|
29
|
+
message: (title, options) => add("message", title, options),
|
|
30
|
+
success: (title, options) => add("success", title, options),
|
|
31
|
+
error: (title, options) => add("error", title, options),
|
|
32
|
+
warning: (title, options) => add("warning", title, options),
|
|
33
|
+
info: (title, options) => add("info", title, options),
|
|
34
|
+
loading: (title, options) => add("loading", title, options),
|
|
35
|
+
dismiss,
|
|
36
|
+
custom: (render, options = {}) => {
|
|
37
|
+
const id = options.id ?? ++sequence;
|
|
38
|
+
return add("message", render(id), { ...options, id });
|
|
39
|
+
},
|
|
40
|
+
promise: (promise, options) => {
|
|
41
|
+
const id = add("loading", options.loading ?? "处理中…", options);
|
|
42
|
+
const task = typeof promise === "function" ? promise() : promise;
|
|
43
|
+
task.then((value) => add("success", typeof options.success === "function" ? options.success(value) : options.success ?? "操作完成", { ...options, id }), (error) => add("error", typeof options.error === "function" ? options.error(error) : options.error ?? "操作失败", { ...options, id }));
|
|
44
|
+
return id;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
function Toaster({ id, position = "bottom-right", duration = 4e3, visibleToasts = 3, closeButton = true, richColors = false, theme, icons, toastOptions, offset = 24, style, className, ...props }) {
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const options = { duration, ...toastOptions };
|
|
50
|
+
defaults.set(id, options);
|
|
51
|
+
return () => {
|
|
52
|
+
if (defaults.get(id) === options) defaults.delete(id);
|
|
53
|
+
};
|
|
54
|
+
}, [id, duration, toastOptions]);
|
|
55
|
+
const records = React.useSyncExternalStore(React.useCallback((callback) => {
|
|
56
|
+
subscribers.add(callback);
|
|
57
|
+
return () => {
|
|
58
|
+
subscribers.delete(callback);
|
|
59
|
+
};
|
|
60
|
+
}, []), () => snapshot, () => empty).filter((item) => item.toasterId === id).slice(-Math.max(1, visibleToasts));
|
|
61
|
+
const center = position.endsWith("center"), left = position.endsWith("left");
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { ...props, "data-aaas-toaster": id ?? "default", "data-theme": theme, className, "aria-label": "消息通知", style: { position: "fixed", colorScheme: theme === "system" ? "light dark" : theme, zIndex: 1e3, [position.startsWith("top") ? "top" : "bottom"]: offset, left: center ? "50%" : left ? offset : void 0, right: !center && !left ? offset : void 0, transform: center ? "translateX(-50%)" : void 0, width: "min(360px, calc(100vw - 32px))", display: "grid", gap: 8, pointerEvents: "none", ...style }, children: records.map((item) => /* @__PURE__ */ jsxs("div", { "data-toast-type": item.type, role: item.type === "error" ? "alert" : "status", "aria-live": item.type === "error" ? "assertive" : "polite", style: { background: richColors && item.type !== "message" && item.type !== "loading" ? `color-mix(in srgb, ${item.type === "error" ? "var(--destructive)" : item.type === "success" ? "var(--success, #16a34a)" : item.type === "warning" ? "var(--warning, #d97706)" : "var(--info, #2563eb)"} 12%, var(--normal-bg, var(--popover)))` : "var(--normal-bg, var(--popover))", color: "var(--normal-text, var(--popover-foreground))", border: "1px solid var(--normal-border, var(--border))", borderRadius: "var(--radius)", padding: 16, boxShadow: "0 8px 28px #0002", pointerEvents: "auto" }, children: [
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 10, alignItems: "center" }, children: [
|
|
64
|
+
icons?.[item.type],
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
|
|
66
|
+
/* @__PURE__ */ jsx("strong", { children: item.title }),
|
|
67
|
+
item.description && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, opacity: 0.75, marginTop: 4 }, children: item.description })
|
|
68
|
+
] }),
|
|
69
|
+
closeButton && item.dismissible !== false && /* @__PURE__ */ jsx("button", { type: "button", "aria-label": "关闭通知", onClick: () => dismiss(item.id), children: "×" })
|
|
70
|
+
] }),
|
|
71
|
+
(item.action || item.cancel) && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 12, marginTop: 8 }, children: [
|
|
72
|
+
item.action && /* @__PURE__ */ jsx("button", { type: "button", onClick: (event) => {
|
|
73
|
+
item.action?.onClick(event);
|
|
74
|
+
if (!event.defaultPrevented) dismiss(item.id);
|
|
75
|
+
}, children: item.action.label }),
|
|
76
|
+
item.cancel && /* @__PURE__ */ jsx("button", { type: "button", onClick: (event) => {
|
|
77
|
+
item.cancel?.onClick?.(event);
|
|
78
|
+
if (!event.defaultPrevented) dismiss(item.id);
|
|
79
|
+
}, children: item.cancel.label })
|
|
80
|
+
] })
|
|
81
|
+
] }, item.id)) });
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
Toaster,
|
|
85
|
+
toast
|
|
86
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ButtonProps, type DivProps } from './core';
|
|
3
|
+
type Selection = {
|
|
4
|
+
type: 'single';
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'multiple';
|
|
10
|
+
value?: string[];
|
|
11
|
+
defaultValue?: string[];
|
|
12
|
+
onValueChange?: (value: string[]) => void;
|
|
13
|
+
};
|
|
14
|
+
type GroupProps = Omit<DivProps, 'defaultValue'> & Selection & {
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
orientation?: 'horizontal' | 'vertical';
|
|
17
|
+
loop?: boolean;
|
|
18
|
+
rovingFocus?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function Root({ type, value, defaultValue, onValueChange, disabled, orientation, loop, rovingFocus, onKeyDown, ...props }: GroupProps): React.JSX.Element;
|
|
21
|
+
export declare function Item({ value, onClick, ...props }: ButtonProps & {
|
|
22
|
+
value: string;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ButtonPart, useControllable, DivPart, moveFocus } from "./core.js";
|
|
4
|
+
const Context = React.createContext({ values: [], toggle: (_v) => {
|
|
5
|
+
}, disabled: false, single: false });
|
|
6
|
+
function Root({ type, value, defaultValue, onValueChange, disabled = false, orientation = "horizontal", loop = true, rovingFocus = true, onKeyDown, ...props }) {
|
|
7
|
+
const [current, set] = useControllable(value, defaultValue ?? (type === "single" ? "" : []), (next) => {
|
|
8
|
+
if (type === "single")
|
|
9
|
+
onValueChange?.(next);
|
|
10
|
+
else
|
|
11
|
+
onValueChange?.(next);
|
|
12
|
+
});
|
|
13
|
+
const values = Array.isArray(current) ? current : current ? [current] : [];
|
|
14
|
+
const toggle = (key) => set(type === "single" ? values.includes(key) ? "" : key : values.includes(key) ? values.filter((v) => v !== key) : [...values, key]);
|
|
15
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { values, toggle, disabled, single: type === "single" }, children: /* @__PURE__ */ jsx(DivPart, { ...props, role: "group", "data-orientation": orientation, onKeyDown: (event) => {
|
|
16
|
+
onKeyDown?.(event);
|
|
17
|
+
if (!event.defaultPrevented && rovingFocus)
|
|
18
|
+
moveFocus(event, "button", { vertical: orientation === "vertical", loop });
|
|
19
|
+
} }) });
|
|
20
|
+
}
|
|
21
|
+
function Item({ value, onClick, ...props }) {
|
|
22
|
+
const state = React.useContext(Context);
|
|
23
|
+
const on = state.values.includes(value);
|
|
24
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, disabled: props.disabled || state.disabled, "aria-pressed": on, "data-state": on ? "on" : "off", onClick: (event) => {
|
|
25
|
+
onClick?.(event);
|
|
26
|
+
if (!event.defaultPrevented)
|
|
27
|
+
state.toggle(value);
|
|
28
|
+
} });
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Item,
|
|
32
|
+
Root
|
|
33
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ButtonProps } from './core';
|
|
2
|
+
export interface ToggleProps extends ButtonProps {
|
|
3
|
+
pressed?: boolean;
|
|
4
|
+
defaultPressed?: boolean;
|
|
5
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function Root({ pressed, defaultPressed, onPressedChange, onClick, ...props }: ToggleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useControllable, ButtonPart } from "./core.js";
|
|
3
|
+
function Root({ pressed, defaultPressed = false, onPressedChange, onClick, ...props }) {
|
|
4
|
+
const [current, set] = useControllable(pressed, defaultPressed, onPressedChange);
|
|
5
|
+
return /* @__PURE__ */ jsx(ButtonPart, { ...props, "aria-pressed": current, "data-state": current ? "on" : "off", onClick: (event) => {
|
|
6
|
+
onClick?.(event);
|
|
7
|
+
if (!event.defaultPrevented)
|
|
8
|
+
set(!current);
|
|
9
|
+
} });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
Root
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const Root: ({ children, open: controlled, defaultOpen, onOpenChange, modal: isModal, delayDuration, openDelay, closeDelay, ...rest }: import("./layer").LayerRootProps & {
|
|
2
|
+
sub?: boolean;
|
|
3
|
+
direction?: import("./layer").LayerState["direction"];
|
|
4
|
+
}) => import("react").JSX.Element, Trigger: ({ onClick, onKeyDown, onPointerEnter, onPointerLeave, onFocus, onBlur, onContextMenu, ref, disabled, ...props }: import("./core").ButtonProps) => import("react").JSX.Element, Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => import("react").ReactPortal | null, Content: ({ forceMount, side, align, sideOffset, alignOffset, avoidCollisions, collisionPadding, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, ref, style, onKeyDown, onPointerEnter, onPointerLeave, ...props }: import("./layer").LayerContentProps) => import("react").JSX.Element | null, Arrow: (props: React.ComponentProps<"span">) => import("react").JSX.Element, Provider: ({ children, delayDuration }: {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
delayDuration?: number;
|
|
7
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './styles.css';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* empty css */
|