@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.
Files changed (247) hide show
  1. package/README.md +107 -2
  2. package/dist/components/address-picker.d.ts +18 -0
  3. package/dist/components/address-picker.js +46 -0
  4. package/dist/components/card-date-filter.d.ts +12 -0
  5. package/dist/components/card-date-filter.js +95 -0
  6. package/dist/components/date-time-picker.d.ts +12 -0
  7. package/dist/components/date-time-picker.js +96 -0
  8. package/dist/components/detail-dialog.d.ts +48 -0
  9. package/dist/components/detail-dialog.js +97 -0
  10. package/dist/components/document-links.d.ts +13 -0
  11. package/dist/components/document-links.js +19 -0
  12. package/dist/components/draft-row-actions.d.ts +14 -0
  13. package/dist/components/draft-row-actions.js +70 -0
  14. package/dist/components/error-boundary.d.ts +14 -0
  15. package/dist/components/error-boundary.js +35 -0
  16. package/dist/components/glow-card.d.ts +13 -0
  17. package/dist/components/glow-card.js +48 -0
  18. package/dist/components/org-picker.d.ts +17 -0
  19. package/dist/components/org-picker.js +56 -0
  20. package/dist/components/overflow-row-actions.d.ts +29 -0
  21. package/dist/components/overflow-row-actions.js +135 -0
  22. package/dist/components/page-header.d.ts +21 -0
  23. package/dist/components/page-header.js +21 -0
  24. package/dist/components/permission-button.d.ts +4 -0
  25. package/dist/components/permission-button.js +17 -0
  26. package/dist/components/permission-context.d.ts +12 -0
  27. package/dist/components/permission-context.js +17 -0
  28. package/dist/components/person-picker.d.ts +20 -0
  29. package/dist/components/person-picker.js +38 -0
  30. package/dist/components/process-flow-bar.d.ts +15 -0
  31. package/dist/components/process-flow-bar.js +19 -0
  32. package/dist/components/product-picker.d.ts +19 -0
  33. package/dist/components/product-picker.js +155 -0
  34. package/dist/components/ref-doc-picker.d.ts +24 -0
  35. package/dist/components/ref-doc-picker.js +139 -0
  36. package/dist/components/scroll-to-top.d.ts +1 -0
  37. package/dist/components/scroll-to-top.js +20 -0
  38. package/dist/components/state-view.d.ts +26 -0
  39. package/dist/components/state-view.js +75 -0
  40. package/dist/components/theme-switcher.d.ts +27 -0
  41. package/dist/components/theme-switcher.js +77 -0
  42. package/dist/components/time-filter.d.ts +7 -0
  43. package/dist/components/time-filter.js +65 -0
  44. package/dist/components/ui/accordion.d.ts +7 -0
  45. package/dist/components/ui/accordion.js +64 -0
  46. package/dist/components/ui/alert-dialog.d.ts +15 -0
  47. package/dist/components/ui/alert-dialog.js +160 -0
  48. package/dist/components/ui/alert.d.ts +12 -0
  49. package/dist/components/ui/alert.js +66 -0
  50. package/dist/components/ui/aspect-ratio.d.ts +3 -0
  51. package/dist/components/ui/aspect-ratio.js +10 -0
  52. package/dist/components/ui/avatar.d.ts +6 -0
  53. package/dist/components/ui/avatar.js +53 -0
  54. package/dist/components/ui/badge.d.ts +12 -0
  55. package/dist/components/ui/badge.js +44 -0
  56. package/dist/components/ui/breadcrumb.d.ts +11 -0
  57. package/dist/components/ui/breadcrumb.js +103 -0
  58. package/dist/components/ui/button-group.d.ts +14 -0
  59. package/dist/components/ui/button-group.js +76 -0
  60. package/dist/components/ui/button.d.ts +20 -0
  61. package/dist/components/ui/button.js +93 -0
  62. package/dist/components/ui/calendar.d.ts +73 -0
  63. package/dist/components/ui/calendar.js +103 -0
  64. package/dist/components/ui/card.d.ts +9 -0
  65. package/dist/components/ui/card.js +90 -0
  66. package/dist/components/ui/carousel.d.ts +14 -0
  67. package/dist/components/ui/carousel.js +200 -0
  68. package/dist/components/ui/chart.d.ts +43 -0
  69. package/dist/components/ui/chart.js +252 -0
  70. package/dist/components/ui/checkbox.d.ts +4 -0
  71. package/dist/components/ui/checkbox.js +31 -0
  72. package/dist/components/ui/collapsible.d.ts +5 -0
  73. package/dist/components/ui/collapsible.js +34 -0
  74. package/dist/components/ui/command.d.ts +18 -0
  75. package/dist/components/ui/command.js +170 -0
  76. package/dist/components/ui/context-menu.d.ts +26 -0
  77. package/dist/components/ui/context-menu.js +237 -0
  78. package/dist/components/ui/dialog.d.ts +17 -0
  79. package/dist/components/ui/dialog.js +139 -0
  80. package/dist/components/ui/drawer.d.ts +13 -0
  81. package/dist/components/ui/drawer.js +129 -0
  82. package/dist/components/ui/dropdown-menu.d.ts +26 -0
  83. package/dist/components/ui/dropdown-menu.js +245 -0
  84. package/dist/components/ui/empty.d.ts +14 -0
  85. package/dist/components/ui/empty.js +102 -0
  86. package/dist/components/ui/field.d.ts +27 -0
  87. package/dist/components/ui/field.js +229 -0
  88. package/dist/components/ui/form.d.ts +26 -0
  89. package/dist/components/ui/form.js +118 -0
  90. package/dist/components/ui/hover-card.d.ts +6 -0
  91. package/dist/components/ui/hover-card.js +39 -0
  92. package/dist/components/ui/input-group.d.ts +22 -0
  93. package/dist/components/ui/input-group.js +156 -0
  94. package/dist/components/ui/input-otp.d.ts +11 -0
  95. package/dist/components/ui/input-otp.js +66 -0
  96. package/dist/components/ui/input.d.ts +3 -0
  97. package/dist/components/ui/input.js +21 -0
  98. package/dist/components/ui/item.d.ts +29 -0
  99. package/dist/components/ui/item.js +187 -0
  100. package/dist/components/ui/kbd.d.ts +3 -0
  101. package/dist/components/ui/kbd.js +31 -0
  102. package/dist/components/ui/label.d.ts +4 -0
  103. package/dist/components/ui/label.js +22 -0
  104. package/dist/components/ui/menubar.d.ts +26 -0
  105. package/dist/components/ui/menubar.js +252 -0
  106. package/dist/components/ui/navigation-menu.d.ts +17 -0
  107. package/dist/components/ui/navigation-menu.js +170 -0
  108. package/dist/components/ui/pagination.d.ts +13 -0
  109. package/dist/components/ui/pagination.js +118 -0
  110. package/dist/components/ui/popover.d.ts +8 -0
  111. package/dist/components/ui/popover.js +47 -0
  112. package/dist/components/ui/progress.d.ts +4 -0
  113. package/dist/components/ui/progress.js +34 -0
  114. package/dist/components/ui/radio-group.d.ts +5 -0
  115. package/dist/components/ui/radio-group.js +45 -0
  116. package/dist/components/ui/resizable.d.ts +7 -0
  117. package/dist/components/ui/resizable.js +49 -0
  118. package/dist/components/ui/scroll-area.d.ts +5 -0
  119. package/dist/components/ui/scroll-area.js +60 -0
  120. package/dist/components/ui/select.d.ts +17 -0
  121. package/dist/components/ui/select.js +215 -0
  122. package/dist/components/ui/separator.d.ts +4 -0
  123. package/dist/components/ui/separator.js +26 -0
  124. package/dist/components/ui/sheet.d.ts +13 -0
  125. package/dist/components/ui/sheet.js +127 -0
  126. package/dist/components/ui/sidebar.d.ts +72 -0
  127. package/dist/components/ui/sidebar.js +656 -0
  128. package/dist/components/ui/skeleton.d.ts +2 -0
  129. package/dist/components/ui/skeleton.js +15 -0
  130. package/dist/components/ui/slider.d.ts +4 -0
  131. package/dist/components/ui/slider.js +63 -0
  132. package/dist/components/ui/sonner.d.ts +4 -0
  133. package/dist/components/ui/sonner.js +34 -0
  134. package/dist/components/ui/spinner.d.ts +2 -0
  135. package/dist/components/ui/spinner.js +17 -0
  136. package/dist/components/ui/switch.d.ts +4 -0
  137. package/dist/components/ui/switch.js +31 -0
  138. package/dist/components/ui/table.d.ts +10 -0
  139. package/dist/components/ui/table.js +114 -0
  140. package/dist/components/ui/tabs.d.ts +7 -0
  141. package/dist/components/ui/tabs.js +67 -0
  142. package/dist/components/ui/textarea.d.ts +3 -0
  143. package/dist/components/ui/textarea.js +18 -0
  144. package/dist/components/ui/toggle-group.d.ts +9 -0
  145. package/dist/components/ui/toggle-group.js +68 -0
  146. package/dist/components/ui/toggle.d.ts +12 -0
  147. package/dist/components/ui/toggle.js +43 -0
  148. package/dist/components/ui/tooltip.d.ts +7 -0
  149. package/dist/components/ui/tooltip.js +56 -0
  150. package/dist/hooks/use-mobile.d.ts +1 -0
  151. package/dist/hooks/use-mobile.js +18 -0
  152. package/dist/icons/index.d.ts +57 -0
  153. package/dist/icons/index.js +115 -0
  154. package/dist/icons/paths.d.ts +556 -0
  155. package/dist/icons/paths.js +231 -0
  156. package/dist/index.d.ts +68 -0
  157. package/dist/index.js +399 -0
  158. package/dist/internal/selection-base.d.ts +37 -0
  159. package/dist/internal/selection-base.js +40 -0
  160. package/dist/lib/class-names.d.ts +6 -0
  161. package/dist/lib/class-names.js +159 -0
  162. package/dist/lib/utils.d.ts +3 -0
  163. package/dist/lib/utils.js +7 -0
  164. package/dist/lib/variants.d.ts +21 -0
  165. package/dist/lib/variants.js +21 -0
  166. package/dist/primitives/accordion.d.ts +29 -0
  167. package/dist/primitives/accordion.js +49 -0
  168. package/dist/primitives/alert-dialog.d.ts +10 -0
  169. package/dist/primitives/alert-dialog.js +22 -0
  170. package/dist/primitives/aspect-ratio.d.ts +4 -0
  171. package/dist/primitives/aspect-ratio.js +7 -0
  172. package/dist/primitives/avatar.d.ts +8 -0
  173. package/dist/primitives/avatar.js +45 -0
  174. package/dist/primitives/carousel.d.ts +22 -0
  175. package/dist/primitives/carousel.js +78 -0
  176. package/dist/primitives/chart.d.ts +71 -0
  177. package/dist/primitives/chart.js +125 -0
  178. package/dist/primitives/checkbox.d.ts +13 -0
  179. package/dist/primitives/checkbox.js +24 -0
  180. package/dist/primitives/collapsible.d.ts +14 -0
  181. package/dist/primitives/collapsible.js +29 -0
  182. package/dist/primitives/command.d.ts +43 -0
  183. package/dist/primitives/command.js +98 -0
  184. package/dist/primitives/context-menu.d.ts +24 -0
  185. package/dist/primitives/context-menu.js +19 -0
  186. package/dist/primitives/core.d.ts +25 -0
  187. package/dist/primitives/core.js +89 -0
  188. package/dist/primitives/dialog.d.ts +7 -0
  189. package/dist/primitives/dialog.js +15 -0
  190. package/dist/primitives/drawer.d.ts +30 -0
  191. package/dist/primitives/drawer.js +39 -0
  192. package/dist/primitives/dropdown-menu.d.ts +24 -0
  193. package/dist/primitives/dropdown-menu.js +19 -0
  194. package/dist/primitives/form.d.ts +154 -0
  195. package/dist/primitives/form.js +139 -0
  196. package/dist/primitives/hover-card.d.ts +4 -0
  197. package/dist/primitives/hover-card.js +8 -0
  198. package/dist/primitives/input-otp.d.ts +21 -0
  199. package/dist/primitives/input-otp.js +78 -0
  200. package/dist/primitives/label.d.ts +2 -0
  201. package/dist/primitives/label.js +7 -0
  202. package/dist/primitives/layer.d.ts +84 -0
  203. package/dist/primitives/layer.js +300 -0
  204. package/dist/primitives/menu.d.ts +56 -0
  205. package/dist/primitives/menu.js +126 -0
  206. package/dist/primitives/menubar.d.ts +91 -0
  207. package/dist/primitives/menubar.js +44 -0
  208. package/dist/primitives/navigation-menu.d.ts +32 -0
  209. package/dist/primitives/navigation-menu.js +121 -0
  210. package/dist/primitives/popover.d.ts +4 -0
  211. package/dist/primitives/popover.js +12 -0
  212. package/dist/primitives/progress.d.ts +7 -0
  213. package/dist/primitives/progress.js +13 -0
  214. package/dist/primitives/radio-group.d.ts +18 -0
  215. package/dist/primitives/radio-group.js +36 -0
  216. package/dist/primitives/resizable.d.ts +19 -0
  217. package/dist/primitives/resizable.js +91 -0
  218. package/dist/primitives/scroll-area.d.ts +12 -0
  219. package/dist/primitives/scroll-area.js +26 -0
  220. package/dist/primitives/select.d.ts +42 -0
  221. package/dist/primitives/select.js +167 -0
  222. package/dist/primitives/separator.d.ts +5 -0
  223. package/dist/primitives/separator.js +7 -0
  224. package/dist/primitives/slider.d.ts +25 -0
  225. package/dist/primitives/slider.js +98 -0
  226. package/dist/primitives/slot.d.ts +1 -0
  227. package/dist/primitives/slot.js +4 -0
  228. package/dist/primitives/switch.d.ts +11 -0
  229. package/dist/primitives/switch.js +22 -0
  230. package/dist/primitives/tabs.d.ts +23 -0
  231. package/dist/primitives/tabs.js +38 -0
  232. package/dist/primitives/toast.d.ts +55 -0
  233. package/dist/primitives/toast.js +86 -0
  234. package/dist/primitives/toggle-group.d.ts +24 -0
  235. package/dist/primitives/toggle-group.js +33 -0
  236. package/dist/primitives/toggle.d.ts +7 -0
  237. package/dist/primitives/toggle.js +13 -0
  238. package/dist/primitives/tooltip.d.ts +7 -0
  239. package/dist/primitives/tooltip.js +10 -0
  240. package/dist/style-entry.d.ts +1 -0
  241. package/dist/style-entry.js +1 -0
  242. package/dist/styles.css +7016 -0
  243. package/dist/styles.js +1 -0
  244. package/dist/theme/index.d.ts +110 -0
  245. package/dist/theme/index.js +199 -0
  246. package/licenses/Lucide.txt +15 -0
  247. package/package.json +67 -4
@@ -0,0 +1,91 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useMergedRef } from "./core.js";
4
+ const Context = React.createContext({ orientation: "horizontal", panels: { current: /* @__PURE__ */ new Map() }, group: { current: null }, changed: (_sizes) => {
5
+ } });
6
+ const percentage = (value, fallback) => typeof value === "number" ? value : value?.endsWith("%") ? Number.parseFloat(value) : fallback;
7
+ function Group({ orientation = "horizontal", onLayoutChange, children, ref, ...props }) {
8
+ const group = React.useRef(null), panels = React.useRef(/* @__PURE__ */ new Map()), merged = useMergedRef(ref, group);
9
+ return /* @__PURE__ */ jsx(Context.Provider, { value: { orientation, group, panels, changed: (sizes) => onLayoutChange?.(sizes) }, children: /* @__PURE__ */ jsx("div", { ...props, ref: merged, children }) });
10
+ }
11
+ function Panel({ id, defaultSize = "50%", minSize = 0, maxSize = 100, onResize, ref, style, ...props }) {
12
+ const generated = React.useId(), key = id ?? generated, state = React.useContext(Context), node = React.useRef(null), merged = useMergedRef(ref, node);
13
+ const [size, setSize] = React.useState(defaultSize), latest = React.useRef(onResize);
14
+ latest.current = onResize;
15
+ React.useEffect(() => {
16
+ if (!node.current) return;
17
+ state.panels.current.set(key, { node: node.current, size: percentage(defaultSize, NaN), set: (next) => {
18
+ const panel = state.panels.current.get(key);
19
+ if (panel) panel.size = next;
20
+ setSize(next);
21
+ latest.current?.(next);
22
+ }, min: Math.max(0, percentage(minSize, 0)), max: Math.min(100, percentage(maxSize, 100)) });
23
+ return () => {
24
+ state.panels.current.delete(key);
25
+ };
26
+ }, [key, minSize, maxSize, state.panels]);
27
+ return /* @__PURE__ */ jsx("div", { ...props, id: key, ref: merged, "data-panel-id": key, style: { flex: `0 0 ${typeof size === "number" ? `${size}%` : size}`, minWidth: 0, minHeight: 0, overflow: "auto", ...style } });
28
+ }
29
+ function Separator({ disabled = false, onPointerDown, onKeyDown, style, ref, ...props }) {
30
+ const state = React.useContext(Context), vertical = state.orientation === "vertical", cleanup = React.useRef(void 0);
31
+ const [range, setRange] = React.useState({ value: 50, min: 0, max: 100, controls: void 0 });
32
+ const separator = React.useRef(null);
33
+ const merged = useMergedRef(ref, separator);
34
+ React.useEffect(() => {
35
+ const before = separator.current?.previousElementSibling;
36
+ const panel = [...state.panels.current.values()].find((item) => item.node === before);
37
+ if (panel) setRange({ value: Number.isFinite(panel.size) ? panel.size : 50, min: panel.min, max: panel.max, controls: panel.node.id });
38
+ }, [state.panels]);
39
+ React.useEffect(() => () => cleanup.current?.(), []);
40
+ const resize = (handle, delta) => {
41
+ const entries = [...state.panels.current.entries()], before = entries.find(([, panel]) => panel.node === handle.previousElementSibling), after = entries.find(([, panel]) => panel.node === handle.nextElementSibling), group = state.group.current;
42
+ if (!before || !after || !group) return;
43
+ const dimension = vertical ? "height" : "width", total = group.getBoundingClientRect()[dimension];
44
+ if (!total) return;
45
+ const a = Number.isFinite(before[1].size) ? before[1].size : before[1].node.getBoundingClientRect()[dimension] / total * 100, b = Number.isFinite(after[1].size) ? after[1].size : after[1].node.getBoundingClientRect()[dimension] / total * 100;
46
+ const change = Math.max(Math.max(before[1].min - a, b - after[1].max), Math.min(Math.min(before[1].max - a, b - after[1].min), delta));
47
+ setRange({ value: a + change, min: before[1].min, max: before[1].max, controls: before[1].node.id });
48
+ before[1].set(a + change);
49
+ after[1].set(b - change);
50
+ state.changed(Object.fromEntries(entries.map(([key, panel]) => [key, key === before[0] ? a + change : key === after[0] ? b - change : panel.node.getBoundingClientRect()[dimension] / total * 100])));
51
+ };
52
+ return /* @__PURE__ */ jsx("div", { ...props, ref: merged, role: "separator", "aria-valuenow": range.value, "aria-valuemin": range.min, "aria-valuemax": range.max, "aria-controls": range.controls, tabIndex: disabled ? -1 : 0, "aria-disabled": disabled, "aria-orientation": vertical ? "horizontal" : "vertical", "data-panel-group-direction": state.orientation, style: { cursor: vertical ? "row-resize" : "col-resize", flexShrink: 0, touchAction: "none", ...style }, onKeyDown: (event) => {
53
+ onKeyDown?.(event);
54
+ if (event.defaultPrevented || disabled) return;
55
+ const forward = vertical ? "ArrowDown" : "ArrowRight", backward = vertical ? "ArrowUp" : "ArrowLeft";
56
+ if ([forward, backward, "Home", "End"].includes(event.key)) {
57
+ event.preventDefault();
58
+ resize(event.currentTarget, event.key === "Home" ? -100 : event.key === "End" ? 100 : (event.key === forward ? 1 : -1) * (event.shiftKey ? 10 : 5));
59
+ }
60
+ }, onPointerDown: (event) => {
61
+ onPointerDown?.(event);
62
+ if (event.defaultPrevented || disabled || event.button !== 0) return;
63
+ event.preventDefault();
64
+ event.currentTarget.focus();
65
+ const handle = event.currentTarget, group = state.group.current, size = group?.getBoundingClientRect()[vertical ? "height" : "width"] ?? 0;
66
+ if (!size) return;
67
+ let previous = vertical ? event.clientY : event.clientX;
68
+ const move = (next) => {
69
+ if (next.pointerId !== event.pointerId) return;
70
+ const current = vertical ? next.clientY : next.clientX;
71
+ resize(handle, (current - previous) / size * 100);
72
+ previous = current;
73
+ };
74
+ const end = () => {
75
+ window.removeEventListener("pointermove", move);
76
+ window.removeEventListener("pointerup", end);
77
+ window.removeEventListener("pointercancel", end);
78
+ cleanup.current = void 0;
79
+ };
80
+ cleanup.current?.();
81
+ cleanup.current = end;
82
+ window.addEventListener("pointermove", move);
83
+ window.addEventListener("pointerup", end);
84
+ window.addEventListener("pointercancel", end);
85
+ } });
86
+ }
87
+ export {
88
+ Group,
89
+ Panel,
90
+ Separator
91
+ };
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ export declare function Root({ type, style, ...props }: React.ComponentProps<'div'> & {
3
+ type?: 'auto' | 'always';
4
+ }): React.JSX.Element;
5
+ export declare function Viewport({ style, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
6
+ /** Native scrollbars supply pointer dragging, wheel, touch and keyboard behavior. */
7
+ export declare function ScrollAreaScrollbar({ orientation: _orientation, forceMount: _force, ...props }: React.ComponentProps<'div'> & {
8
+ orientation?: 'horizontal' | 'vertical';
9
+ forceMount?: true;
10
+ }): React.JSX.Element;
11
+ export declare function ScrollAreaThumb(props: React.ComponentProps<'div'>): React.JSX.Element;
12
+ export declare function Corner(): null;
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ const Context = React.createContext("auto");
4
+ function Root({ type = "auto", style, ...props }) {
5
+ return /* @__PURE__ */ jsx(Context.Provider, { value: type, children: /* @__PURE__ */ jsx("div", { ...props, style: { overflow: "hidden", ...style } }) });
6
+ }
7
+ function Viewport({ style, ...props }) {
8
+ const type = React.useContext(Context);
9
+ return /* @__PURE__ */ jsx("div", { ...props, tabIndex: 0, "data-aaas-scroll-viewport": "", style: { overflow: type === "always" ? "scroll" : "auto", scrollbarWidth: "thin", scrollbarColor: "var(--border) transparent", ...style } });
10
+ }
11
+ function ScrollAreaScrollbar({ orientation: _orientation = "vertical", forceMount: _force, ...props }) {
12
+ return /* @__PURE__ */ jsx("div", { ...props, hidden: true, "aria-hidden": "true" });
13
+ }
14
+ function ScrollAreaThumb(props) {
15
+ return /* @__PURE__ */ jsx("div", { ...props });
16
+ }
17
+ function Corner() {
18
+ return null;
19
+ }
20
+ export {
21
+ Corner,
22
+ Root,
23
+ ScrollAreaScrollbar,
24
+ ScrollAreaThumb,
25
+ Viewport
26
+ };
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { type LayerContentProps, type ModalRootProps } from './layer';
3
+ import { type ButtonProps, type DivProps } from './core';
4
+ /** Internal styling adapter; selection remains owned by Root. */
5
+ export declare function useSelectState(): {
6
+ value: string;
7
+ disabled: boolean;
8
+ };
9
+ export interface SelectProps extends ModalRootProps {
10
+ value?: string;
11
+ defaultValue?: string;
12
+ onValueChange?: (value: string) => void;
13
+ disabled?: boolean;
14
+ required?: boolean;
15
+ name?: string;
16
+ autoComplete?: string;
17
+ dir?: 'ltr' | 'rtl';
18
+ }
19
+ export declare function Root({ value, defaultValue, onValueChange, disabled, required, name, autoComplete, dir, children, ...props }: SelectProps): React.JSX.Element;
20
+ export declare function Trigger(props: ButtonProps): React.JSX.Element;
21
+ export declare function Value({ placeholder, children, ...props }: React.ComponentProps<'span'> & {
22
+ placeholder?: React.ReactNode;
23
+ }): React.JSX.Element;
24
+ export declare function Content({ position: _position, onOpenAutoFocus, onKeyDown, style, ref, ...props }: LayerContentProps & {
25
+ position?: 'popper';
26
+ }): React.JSX.Element;
27
+ export declare function Viewport({ ref, style, ...props }: DivProps): React.JSX.Element;
28
+ export declare function Group(props: DivProps): React.JSX.Element;
29
+ export declare function Label(props: DivProps): React.JSX.Element;
30
+ export declare function Item({ value, textValue, disabled, onClick, children, ...props }: ButtonProps & {
31
+ value: string;
32
+ textValue?: string;
33
+ }): React.JSX.Element;
34
+ export declare function ItemText(props: React.ComponentProps<'span'>): React.JSX.Element;
35
+ export declare function ItemIndicator(props: React.ComponentProps<'span'>): React.JSX.Element | null;
36
+ export declare function Icon({ asChild, ...props }: React.ComponentProps<'span'> & {
37
+ asChild?: boolean;
38
+ }): React.JSX.Element;
39
+ export declare function Separator(props: DivProps): React.JSX.Element;
40
+ export declare function ScrollUpButton(props: ButtonProps): React.JSX.Element;
41
+ export declare function ScrollDownButton(props: ButtonProps): React.JSX.Element;
42
+ export declare const Portal: ({ children, container, forceMount }: import("./layer").PortalProps) => React.ReactPortal | null;
@@ -0,0 +1,167 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { createLayer } from "./layer.js";
4
+ import { useMergedRef, moveFocus, DivPart, Slot, ButtonPart, useControllable } from "./core.js";
5
+ const family = createLayer({ role: "listbox" });
6
+ const Context = React.createContext({ value: "", set: (_value) => {
7
+ }, disabled: false, dir: "ltr", labels: /* @__PURE__ */ new Map(), viewport: null, setViewport: (_node) => {
8
+ } });
9
+ const Selected = React.createContext(false);
10
+ function useSelectState() {
11
+ const { value, disabled } = React.useContext(Context);
12
+ return { value, disabled };
13
+ }
14
+ function collect(children, labels) {
15
+ React.Children.forEach(children, (child) => {
16
+ if (!React.isValidElement(child))
17
+ return;
18
+ const props = child.props;
19
+ if (typeof props.value === "string")
20
+ labels.set(props.value, props.children);
21
+ else if (props.children)
22
+ collect(props.children, labels);
23
+ });
24
+ }
25
+ function Root({ value, defaultValue = "", onValueChange, disabled = false, required, name, autoComplete, dir = "ltr", children, ...props }) {
26
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
27
+ const labels = /* @__PURE__ */ new Map();
28
+ collect(children, labels);
29
+ const [viewport, setViewport] = React.useState(null);
30
+ return /* @__PURE__ */ jsx(family.Root, { ...props, children: /* @__PURE__ */ jsxs(Context.Provider, { value: { value: current, set, disabled, dir, labels, viewport, setViewport }, children: [
31
+ children,
32
+ name && /* @__PURE__ */ jsxs("select", { name, required, disabled, autoComplete, tabIndex: -1, "aria-hidden": "true", value: current, onChange: (event) => set(event.target.value), style: { position: "absolute", opacity: 0, width: 1, height: 1, pointerEvents: "none" }, children: [
33
+ /* @__PURE__ */ jsx("option", { value: "" }),
34
+ [...labels].map(([key]) => /* @__PURE__ */ jsx("option", { value: key, children: key }, key))
35
+ ] })
36
+ ] }) });
37
+ }
38
+ function Trigger(props) {
39
+ const state = React.useContext(Context);
40
+ return /* @__PURE__ */ jsx(family.Trigger, { ...props, role: "combobox", dir: state.dir, disabled: props.disabled || state.disabled, "data-placeholder": !state.value ? "" : void 0 });
41
+ }
42
+ function Value({ placeholder, children, ...props }) {
43
+ const state = React.useContext(Context);
44
+ return /* @__PURE__ */ jsx("span", { ...props, "data-placeholder": !state.value ? "" : void 0, children: children ?? (state.value ? state.labels.get(state.value) ?? state.value : placeholder) });
45
+ }
46
+ function Content({ position: _position = "popper", onOpenAutoFocus, onKeyDown, style, ref, ...props }) {
47
+ const local = React.useRef(null), merged = useMergedRef(ref, local);
48
+ return /* @__PURE__ */ jsx(family.Content, { ...props, ref: merged, style: { minWidth: "var(--aaas-trigger-width)", ...style }, onOpenAutoFocus: (event) => {
49
+ onOpenAutoFocus?.(event);
50
+ if (!event.defaultPrevented) {
51
+ const chosen = local.current?.querySelector('[role="option"][aria-selected="true"]:not(:disabled)');
52
+ if (chosen) {
53
+ chosen.focus();
54
+ event.preventDefault();
55
+ }
56
+ }
57
+ }, onKeyDown: (event) => {
58
+ onKeyDown?.(event);
59
+ if (event.defaultPrevented)
60
+ return;
61
+ moveFocus(event, '[role="option"]', { vertical: true });
62
+ if (event.key.length === 1 && event.key !== " ") {
63
+ const options = [...event.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')];
64
+ options.find((n) => (n.getAttribute("data-text-value") ?? n.textContent)?.trim().toLocaleLowerCase().startsWith(event.key.toLocaleLowerCase()))?.focus();
65
+ }
66
+ } });
67
+ }
68
+ function Viewport({ ref, style, ...props }) {
69
+ const state = React.useContext(Context);
70
+ const merged = useMergedRef(ref, state.setViewport);
71
+ return /* @__PURE__ */ jsx(DivPart, { ...props, ref: merged, style: { overflowY: "auto", maxHeight: "var(--aaas-content-available-height)", ...style } });
72
+ }
73
+ function Group(props) {
74
+ return /* @__PURE__ */ jsx(DivPart, { ...props, role: "group" });
75
+ }
76
+ function Label(props) {
77
+ return /* @__PURE__ */ jsx(DivPart, { ...props });
78
+ }
79
+ function Item({ value, textValue, disabled, onClick, children, ...props }) {
80
+ const state = React.useContext(Context), layer = family.useLayer(), checked = state.value === value;
81
+ return /* @__PURE__ */ jsx(Selected.Provider, { value: checked, children: /* @__PURE__ */ jsx(ButtonPart, { ...props, role: "option", "data-text-value": textValue, tabIndex: -1, "aria-selected": checked, disabled: disabled || state.disabled, "data-disabled": disabled ? "" : void 0, "data-state": checked ? "checked" : "unchecked", onClick: (event) => {
82
+ onClick?.(event);
83
+ if (!event.defaultPrevented) {
84
+ state.set(value);
85
+ layer.setOpen(false);
86
+ }
87
+ }, children }) });
88
+ }
89
+ function ItemText(props) {
90
+ return /* @__PURE__ */ jsx("span", { ...props });
91
+ }
92
+ function ItemIndicator(props) {
93
+ return React.useContext(Selected) ? /* @__PURE__ */ jsx("span", { ...props }) : null;
94
+ }
95
+ function Icon({ asChild, ...props }) {
96
+ return asChild ? /* @__PURE__ */ jsx(Slot, { ...props, ref: props.ref }) : /* @__PURE__ */ jsx("span", { ...props, "aria-hidden": "true" });
97
+ }
98
+ function Separator(props) {
99
+ return /* @__PURE__ */ jsx(DivPart, { ...props, role: "separator" });
100
+ }
101
+ function ScrollButton({ up, onClick, onMouseDown, ...props }) {
102
+ const state = React.useContext(Context), layer = family.useLayer();
103
+ const [visible, setVisible] = React.useState(false);
104
+ React.useLayoutEffect(() => {
105
+ const viewport = state.viewport;
106
+ if (!layer.open || !viewport) {
107
+ setVisible(false);
108
+ return;
109
+ }
110
+ const measure = () => {
111
+ const maximum = viewport.scrollHeight - viewport.clientHeight;
112
+ const actions = [...viewport.parentElement?.querySelectorAll("[data-aaas-select-scroll]") ?? []];
113
+ const actionHeight = actions.reduce((height, node) => height + node.getBoundingClientRect().height, 0);
114
+ setVisible(maximum > actionHeight + 1 && (up ? viewport.scrollTop > 1 : viewport.scrollTop < maximum - 1));
115
+ };
116
+ measure();
117
+ viewport.addEventListener("scroll", measure, { passive: true });
118
+ window.addEventListener("resize", measure);
119
+ const resize = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
120
+ resize?.observe(viewport);
121
+ for (const child of viewport.children) resize?.observe(child);
122
+ const mutation = new MutationObserver(() => {
123
+ for (const child of viewport.children) resize?.observe(child);
124
+ measure();
125
+ });
126
+ mutation.observe(viewport, { childList: true, subtree: true, characterData: true });
127
+ return () => {
128
+ viewport.removeEventListener("scroll", measure);
129
+ window.removeEventListener("resize", measure);
130
+ resize?.disconnect();
131
+ mutation.disconnect();
132
+ };
133
+ }, [layer.open, state.viewport, up]);
134
+ if (!visible) return null;
135
+ return /* @__PURE__ */ jsx(ButtonPart, { ...props, "data-aaas-select-scroll": "", tabIndex: -1, "aria-label": up ? "向上滚动选项" : "向下滚动选项", onMouseDown: (event) => {
136
+ onMouseDown?.(event);
137
+ event.preventDefault();
138
+ }, onClick: (event) => {
139
+ onClick?.(event);
140
+ if (!event.defaultPrevented) state.viewport?.scrollBy({ top: up ? -120 : 120 });
141
+ } });
142
+ }
143
+ function ScrollUpButton(props) {
144
+ return /* @__PURE__ */ jsx(ScrollButton, { ...props, up: true });
145
+ }
146
+ function ScrollDownButton(props) {
147
+ return /* @__PURE__ */ jsx(ScrollButton, { ...props, up: false });
148
+ }
149
+ const Portal = family.Portal;
150
+ export {
151
+ Content,
152
+ Group,
153
+ Icon,
154
+ Item,
155
+ ItemIndicator,
156
+ ItemText,
157
+ Label,
158
+ Portal,
159
+ Root,
160
+ ScrollDownButton,
161
+ ScrollUpButton,
162
+ Separator,
163
+ Trigger,
164
+ Value,
165
+ Viewport,
166
+ useSelectState
167
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export declare function Root({ orientation, decorative, ...props }: React.ComponentProps<'div'> & {
3
+ orientation?: 'horizontal' | 'vertical';
4
+ decorative?: boolean;
5
+ }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ function Root({ orientation = "horizontal", decorative = true, ...props }) {
3
+ return /* @__PURE__ */ jsx("div", { ...props, role: decorative ? "none" : "separator", "aria-orientation": decorative ? void 0 : orientation, "data-orientation": orientation });
4
+ }
5
+ export {
6
+ Root
7
+ };
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { type DivProps } from './core';
3
+ export interface SliderProps extends Omit<DivProps, 'defaultValue' | 'onChange'> {
4
+ value?: number[];
5
+ defaultValue?: number[];
6
+ onValueChange?: (value: number[]) => void;
7
+ onValueCommit?: (value: number[]) => void;
8
+ min?: number;
9
+ max?: number;
10
+ step?: number;
11
+ minStepsBetweenThumbs?: number;
12
+ disabled?: boolean;
13
+ name?: string;
14
+ orientation?: 'horizontal' | 'vertical';
15
+ dir?: 'ltr' | 'rtl';
16
+ inverted?: boolean;
17
+ }
18
+ export declare function Root({ value, defaultValue, onValueChange, onValueCommit, min, max, step, minStepsBetweenThumbs, disabled, name, orientation, dir, inverted, children, style, onPointerDown, ...props }: SliderProps): React.JSX.Element;
19
+ export declare function Track(props: React.ComponentProps<'div'>): React.JSX.Element;
20
+ export declare function Range({ style, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
21
+ interface ThumbProps extends React.ComponentProps<'span'> {
22
+ index?: number;
23
+ }
24
+ export declare function Thumb({ index, style, onKeyDown, ...props }: ThumbProps): React.JSX.Element;
25
+ export {};
@@ -0,0 +1,98 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useControllable } from "./core.js";
4
+ const Context = React.createContext({ values: [], min: 0, max: 100, disabled: false, vertical: false, reversed: false, change: () => {
5
+ }, step: 1, spacing: 0 });
6
+ function Root({ value, defaultValue, onValueChange, onValueCommit, min = 0, max = 100, step = 1, minStepsBetweenThumbs = 0, disabled = false, name, orientation = "horizontal", dir = "ltr", inverted = false, children, style, onPointerDown, ...props }) {
7
+ const limit = Math.max(min, max), increment = step > 0 ? step : 1, vertical = orientation === "vertical", reversed = inverted !== (dir === "rtl" && !vertical);
8
+ const [values, set] = useControllable(value, defaultValue ?? [min, limit], onValueChange);
9
+ const latest = React.useRef(values);
10
+ latest.current = values;
11
+ const change = (index2, number, commit = false) => {
12
+ const current = latest.current, spacing = Math.max(0, minStepsBetweenThumbs) * increment;
13
+ const lower = index2 ? current[index2 - 1] + spacing : min, upper = index2 < current.length - 1 ? current[index2 + 1] - spacing : limit;
14
+ if (lower > upper)
15
+ return;
16
+ const snapped = Math.round((number - min) / increment) * increment + min;
17
+ const rounded = Number(Math.max(lower, Math.min(upper, snapped)).toFixed(10));
18
+ const next = current.map((v, i) => i === index2 ? rounded : v);
19
+ latest.current = next;
20
+ set(next);
21
+ if (commit)
22
+ onValueCommit?.(next);
23
+ };
24
+ const dragging = React.useRef(null);
25
+ React.useEffect(() => () => dragging.current?.(), []);
26
+ let index = 0;
27
+ const parts = React.Children.map(children, (child) => React.isValidElement(child) && child.type === Thumb ? React.cloneElement(child, { index: index++ }) : child);
28
+ return /* @__PURE__ */ jsx(Context.Provider, { value: { values, min, max: limit, step: increment, disabled, vertical, reversed, change, spacing: Math.max(0, minStepsBetweenThumbs) * increment, label: props["aria-label"], labelledBy: props["aria-labelledby"] }, children: /* @__PURE__ */ jsxs("div", { ...props, "data-orientation": orientation, "data-disabled": disabled ? "" : void 0, style: { minHeight: vertical ? void 0 : 18, ...style }, onPointerDown: (event) => {
29
+ onPointerDown?.(event);
30
+ if (event.defaultPrevented || disabled || event.button !== 0)
31
+ return;
32
+ const rect = event.currentTarget.getBoundingClientRect();
33
+ const calculate = (x, y) => {
34
+ let ratio = vertical ? 1 - (y - rect.top) / (rect.height || 1) : (x - rect.left) / (rect.width || 1);
35
+ if (reversed)
36
+ ratio = 1 - ratio;
37
+ return min + Math.max(0, Math.min(1, ratio)) * (limit - min);
38
+ };
39
+ const number = calculate(event.clientX, event.clientY), targetIndex = values.reduce((best, v, i) => Math.abs(v - number) < Math.abs(values[best] - number) ? i : best, 0);
40
+ event.preventDefault();
41
+ event.currentTarget.querySelectorAll('[role="slider"]')[targetIndex]?.focus();
42
+ change(targetIndex, number);
43
+ const move = (e) => {
44
+ if (e.pointerId === event.pointerId)
45
+ change(targetIndex, calculate(e.clientX, e.clientY));
46
+ };
47
+ const cleanup = () => {
48
+ window.removeEventListener("pointermove", move);
49
+ window.removeEventListener("pointerup", end);
50
+ window.removeEventListener("pointercancel", end);
51
+ dragging.current = null;
52
+ };
53
+ const end = (e) => {
54
+ if (e.pointerId !== event.pointerId)
55
+ return;
56
+ cleanup();
57
+ onValueCommit?.(latest.current);
58
+ };
59
+ dragging.current?.();
60
+ dragging.current = cleanup;
61
+ window.addEventListener("pointermove", move);
62
+ window.addEventListener("pointerup", end);
63
+ window.addEventListener("pointercancel", end);
64
+ }, children: [
65
+ parts,
66
+ name && values.map((number, i) => /* @__PURE__ */ jsx("input", { type: "hidden", name: values.length > 1 ? `${name}[]` : name, value: number, disabled }, i))
67
+ ] }) });
68
+ }
69
+ function Track(props) {
70
+ const state = React.useContext(Context);
71
+ return /* @__PURE__ */ jsx("div", { ...props, "data-orientation": state.vertical ? "vertical" : "horizontal" });
72
+ }
73
+ const percent = (v, state) => state.max === state.min ? 0 : Math.max(0, Math.min(100, (v - state.min) / (state.max - state.min) * 100));
74
+ function Range({ style, ...props }) {
75
+ const state = React.useContext(Context), start = state.values.length > 1 ? percent(state.values[0], state) : 0, end = percent(state.values.at(-1) ?? 0, state);
76
+ return /* @__PURE__ */ jsx("div", { ...props, "data-orientation": state.vertical ? "vertical" : "horizontal", style: { ...state.vertical ? { bottom: `${state.reversed ? 100 - end : start}%`, height: `${end - start}%` } : { left: `${state.reversed ? 100 - end : start}%`, width: `${end - start}%` }, ...style } });
77
+ }
78
+ function Thumb({ index = 0, style, onKeyDown, ...props }) {
79
+ const state = React.useContext(Context), value = state.values[index] ?? state.min, position = percent(value, state), lower = index ? state.values[index - 1] + state.spacing : state.min, upper = index < state.values.length - 1 ? state.values[index + 1] - state.spacing : state.max;
80
+ return /* @__PURE__ */ jsx("span", { ...props, role: "slider", "aria-label": props["aria-label"] ?? (state.label ? `${state.label}${state.values.length > 1 ? ` ${index + 1}` : ""}` : void 0), "aria-labelledby": props["aria-labelledby"] ?? state.labelledBy, tabIndex: state.disabled ? -1 : 0, "aria-disabled": state.disabled, "aria-valuemin": lower, "aria-valuemax": upper, "aria-valuenow": value, "aria-orientation": state.vertical ? "vertical" : "horizontal", "data-orientation": state.vertical ? "vertical" : "horizontal", "data-disabled": state.disabled ? "" : void 0, style: { position: "absolute", ...state.vertical ? { bottom: `${state.reversed ? 100 - position : position}%`, transform: "translateY(50%)" } : { left: `${state.reversed ? 100 - position : position}%`, transform: "translateX(-50%)" }, ...style }, onKeyDown: (event) => {
81
+ onKeyDown?.(event);
82
+ if (event.defaultPrevented || state.disabled)
83
+ return;
84
+ const positive = event.key === "ArrowUp" || event.key === "ArrowRight" || event.key === "PageUp";
85
+ const negative = event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "PageDown";
86
+ if (positive || negative || event.key === "Home" || event.key === "End") {
87
+ event.preventDefault();
88
+ const next = event.key === "Home" ? lower : event.key === "End" ? upper : value + (positive !== state.reversed ? 1 : -1) * state.step * (event.key.startsWith("Page") || event.shiftKey ? 10 : 1);
89
+ state.change(index, next, true);
90
+ }
91
+ } });
92
+ }
93
+ export {
94
+ Range,
95
+ Root,
96
+ Thumb,
97
+ Track
98
+ };
@@ -0,0 +1 @@
1
+ export { Slot } from './core';
@@ -0,0 +1,4 @@
1
+ import { Slot } from "./core.js";
2
+ export {
3
+ Slot
4
+ };
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { type ButtonProps } from './core';
3
+ interface SwitchProps extends ButtonProps {
4
+ checked?: boolean;
5
+ defaultChecked?: boolean;
6
+ onCheckedChange?: (checked: boolean) => void;
7
+ required?: boolean;
8
+ }
9
+ export declare function Root({ checked, defaultChecked, onCheckedChange, children, onClick, name, value, required, ...props }: SwitchProps): React.JSX.Element;
10
+ export declare function Thumb(props: React.ComponentProps<'span'>): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useControllable, ButtonPart } from "./core.js";
4
+ const Context = React.createContext(false);
5
+ function Root({ checked, defaultChecked = false, onCheckedChange, children, onClick, name, value = "on", required, ...props }) {
6
+ const [current, set] = useControllable(checked, defaultChecked, onCheckedChange);
7
+ return /* @__PURE__ */ jsxs(Context.Provider, { value: current, children: [
8
+ /* @__PURE__ */ jsx(ButtonPart, { ...props, role: "switch", "aria-checked": current, "aria-required": required, "data-state": current ? "checked" : "unchecked", "data-disabled": props.disabled ? "" : void 0, onClick: (event) => {
9
+ onClick?.(event);
10
+ if (!event.defaultPrevented)
11
+ set(!current);
12
+ }, children }),
13
+ name && /* @__PURE__ */ jsx("input", { type: "checkbox", name, value, checked: current, required, form: props.form, disabled: props.disabled, onChange: (event) => set(event.target.checked), tabIndex: -1, "aria-hidden": "true", style: { position: "absolute", opacity: 0, width: 1, height: 1, pointerEvents: "none" } })
14
+ ] });
15
+ }
16
+ function Thumb(props) {
17
+ return /* @__PURE__ */ jsx("span", { ...props, "data-state": React.useContext(Context) ? "checked" : "unchecked" });
18
+ }
19
+ export {
20
+ Root,
21
+ Thumb
22
+ };
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { type ButtonProps, type DivProps } from './core';
3
+ type Orientation = 'horizontal' | 'vertical';
4
+ export interface TabsProps extends Omit<DivProps, 'defaultValue'> {
5
+ value?: string;
6
+ defaultValue?: string;
7
+ onValueChange?: (value: string) => void;
8
+ orientation?: Orientation;
9
+ activationMode?: 'automatic' | 'manual';
10
+ dir?: 'ltr' | 'rtl';
11
+ }
12
+ export declare function Root({ value, defaultValue, onValueChange, orientation, activationMode, dir, ...props }: TabsProps): React.JSX.Element;
13
+ export declare function List({ loop, onKeyDown, ...props }: DivProps & {
14
+ loop?: boolean;
15
+ }): React.JSX.Element;
16
+ export declare function Trigger({ value, onClick, ...props }: ButtonProps & {
17
+ value: string;
18
+ }): React.JSX.Element;
19
+ export declare function Content({ value, forceMount, ...props }: DivProps & {
20
+ value: string;
21
+ forceMount?: true;
22
+ }): React.JSX.Element | null;
23
+ export {};
@@ -0,0 +1,38 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { DivPart, moveFocus, useControllable, ButtonPart } from "./core.js";
4
+ const Context = React.createContext({ value: "", set: (_value) => {
5
+ }, id: "", orientation: "horizontal", activationMode: "automatic", dir: "ltr" });
6
+ function Root({ value, defaultValue = "", onValueChange, orientation = "horizontal", activationMode = "automatic", dir = "ltr", ...props }) {
7
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
8
+ const id = React.useId();
9
+ return /* @__PURE__ */ jsx(Context.Provider, { value: { value: current, set, id, orientation, activationMode, dir }, children: /* @__PURE__ */ jsx(DivPart, { ...props, dir, "data-orientation": orientation }) });
10
+ }
11
+ function List({ loop = true, onKeyDown, ...props }) {
12
+ const state = React.useContext(Context);
13
+ return /* @__PURE__ */ jsx(DivPart, { ...props, role: "tablist", "aria-orientation": state.orientation, onKeyDown: (event) => {
14
+ onKeyDown?.(event);
15
+ if (!event.defaultPrevented)
16
+ moveFocus(event, '[role="tab"]', { vertical: state.orientation === "vertical", loop, select: state.activationMode === "automatic" });
17
+ } });
18
+ }
19
+ function Trigger({ value, onClick, ...props }) {
20
+ const state = React.useContext(Context);
21
+ const active = value === state.value;
22
+ return /* @__PURE__ */ jsx(ButtonPart, { ...props, role: "tab", id: `${state.id}-tab-${value}`, "aria-selected": active, "aria-controls": `${state.id}-panel-${value}`, tabIndex: active || !state.value ? 0 : -1, "data-state": active ? "active" : "inactive", "data-orientation": state.orientation, onClick: (event) => {
23
+ onClick?.(event);
24
+ if (!event.defaultPrevented)
25
+ state.set(value);
26
+ } });
27
+ }
28
+ function Content({ value, forceMount, ...props }) {
29
+ const state = React.useContext(Context);
30
+ const active = value === state.value;
31
+ return active || forceMount ? /* @__PURE__ */ jsx(DivPart, { ...props, role: "tabpanel", id: `${state.id}-panel-${value}`, "aria-labelledby": `${state.id}-tab-${value}`, tabIndex: 0, hidden: !active, "data-state": active ? "active" : "inactive", "data-orientation": state.orientation }) : null;
32
+ }
33
+ export {
34
+ Content,
35
+ List,
36
+ Root,
37
+ Trigger
38
+ };
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ export type ToastId = string | number;
3
+ type ToastType = 'message' | 'success' | 'info' | 'warning' | 'error' | 'loading';
4
+ export interface ToastOptions {
5
+ id?: ToastId;
6
+ toasterId?: string;
7
+ description?: React.ReactNode;
8
+ duration?: number;
9
+ dismissible?: boolean;
10
+ action?: {
11
+ label: React.ReactNode;
12
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
13
+ };
14
+ cancel?: {
15
+ label: React.ReactNode;
16
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
17
+ };
18
+ onDismiss?: (toast: ToastRecord) => void;
19
+ onAutoClose?: (toast: ToastRecord) => void;
20
+ }
21
+ export interface ToastRecord extends ToastOptions {
22
+ id: ToastId;
23
+ title: React.ReactNode;
24
+ type: ToastType;
25
+ }
26
+ declare function dismiss(id?: ToastId, automatic?: boolean): void;
27
+ export declare const toast: ((title: React.ReactNode, options?: ToastOptions) => ToastId) & {
28
+ message: (title: React.ReactNode, options?: ToastOptions) => ToastId;
29
+ success: (title: React.ReactNode, options?: ToastOptions) => ToastId;
30
+ error: (title: React.ReactNode, options?: ToastOptions) => ToastId;
31
+ warning: (title: React.ReactNode, options?: ToastOptions) => ToastId;
32
+ info: (title: React.ReactNode, options?: ToastOptions) => ToastId;
33
+ loading: (title: React.ReactNode, options?: ToastOptions) => ToastId;
34
+ dismiss: typeof dismiss;
35
+ custom: (render: (id: ToastId) => React.ReactNode, options?: ToastOptions) => ToastId;
36
+ promise: <T>(promise: Promise<T> | (() => Promise<T>), options: ToastOptions & {
37
+ loading?: React.ReactNode;
38
+ success?: React.ReactNode | ((value: T) => React.ReactNode);
39
+ error?: React.ReactNode | ((error: unknown) => React.ReactNode);
40
+ }) => ToastId;
41
+ };
42
+ export interface ToasterProps extends Omit<React.ComponentProps<'div'>, 'id'> {
43
+ id?: string;
44
+ position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
45
+ duration?: number;
46
+ visibleToasts?: number;
47
+ closeButton?: boolean;
48
+ richColors?: boolean;
49
+ theme?: 'light' | 'dark' | 'system';
50
+ icons?: Partial<Record<ToastType, React.ReactNode>>;
51
+ toastOptions?: ToastOptions;
52
+ offset?: number | string;
53
+ }
54
+ export declare function Toaster({ id, position, duration, visibleToasts, closeButton, richColors, theme, icons, toastOptions, offset, style, className, ...props }: ToasterProps): React.JSX.Element;
55
+ export {};