@robert-stackflow/oneui 0.6.18 → 0.6.20

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 (199) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -0
  3. package/components/Accordion.d.ts +1 -1
  4. package/components/Accordion.js +1 -0
  5. package/components/AccountItem.js +1 -0
  6. package/components/ActionSheet.js +1 -0
  7. package/components/Alert.js +1 -0
  8. package/components/AppShell.js +1 -0
  9. package/components/AppearanceSettings.js +1 -0
  10. package/components/AuthLayout.js +1 -0
  11. package/components/Avatar.js +1 -0
  12. package/components/AvatarGroup.js +1 -0
  13. package/components/Badge.js +1 -0
  14. package/components/Banner.d.ts +3 -3
  15. package/components/Banner.js +12 -4
  16. package/components/BarChart.js +1 -0
  17. package/components/BlockedTab.js +1 -0
  18. package/components/Breadcrumb.js +1 -0
  19. package/components/Button.d.ts +4 -2
  20. package/components/Button.js +24 -0
  21. package/components/Calendar.js +19 -13
  22. package/components/Card.d.ts +5 -4
  23. package/components/Card.js +8 -4
  24. package/components/Card.module.css +10 -0
  25. package/components/Cascader.js +1 -0
  26. package/components/CatalogIcon.js +1 -0
  27. package/components/CharacterPicker.js +1 -0
  28. package/components/Checkbox.d.ts +5 -3
  29. package/components/Checkbox.js +17 -5
  30. package/components/ColorField.js +1 -0
  31. package/components/ColorPicker.js +1 -0
  32. package/components/Combobox.d.ts +4 -2
  33. package/components/Combobox.js +10 -3
  34. package/components/CommandPalette.js +1 -0
  35. package/components/ContextMenu.js +1 -0
  36. package/components/ContextMenuPanel.js +1 -0
  37. package/components/ContributionCalendar.js +1 -0
  38. package/components/ContributionCell.js +1 -0
  39. package/components/CopyButton.js +1 -0
  40. package/components/DataTable.js +1 -0
  41. package/components/DatePicker.js +8 -4
  42. package/components/DateRangePicker.js +1 -0
  43. package/components/Descriptions.js +1 -0
  44. package/components/Dialog.d.ts +9 -3
  45. package/components/Dialog.js +33 -11
  46. package/components/DialogVariants.js +1 -0
  47. package/components/DisclosureChevron.js +1 -0
  48. package/components/Divider.js +1 -0
  49. package/components/Drawer.d.ts +5 -2
  50. package/components/Drawer.js +20 -5
  51. package/components/EmojiPicker.js +1 -0
  52. package/components/EmptyState.js +1 -0
  53. package/components/FieldLabel.d.ts +2 -1
  54. package/components/FieldLabel.js +1 -0
  55. package/components/FieldMessages.d.ts +3 -2
  56. package/components/FieldMessages.js +1 -0
  57. package/components/FileDropOverlay.js +1 -0
  58. package/components/FileDropZone.js +1 -0
  59. package/components/FilePicker.d.ts +3 -2
  60. package/components/FilePicker.js +21 -5
  61. package/components/FileSelectionFeedback.js +1 -0
  62. package/components/FileTree.js +1 -0
  63. package/components/Form.js +1 -0
  64. package/components/FormErrorSummary.js +1 -0
  65. package/components/FormField.js +1 -0
  66. package/components/FormGroup.js +1 -0
  67. package/components/FormLayout.js +1 -0
  68. package/components/IconButton.js +1 -0
  69. package/components/IconPicker.js +1 -0
  70. package/components/Indicator.js +1 -0
  71. package/components/Input.js +1 -0
  72. package/components/Layout.js +1 -0
  73. package/components/LoadingOverlay.js +1 -0
  74. package/components/LoadingState.js +1 -0
  75. package/components/Markdown.js +1 -0
  76. package/components/Menu.js +1 -0
  77. package/components/MenuItem.d.ts +8 -3
  78. package/components/MenuItem.js +24 -1
  79. package/components/MenuItemContent.js +1 -0
  80. package/components/MultiSelect.js +1 -0
  81. package/components/NavBar.d.ts +2 -1
  82. package/components/NavBar.js +3 -1
  83. package/components/NumberInput.js +1 -0
  84. package/components/Page.d.ts +2 -1
  85. package/components/Page.js +4 -2
  86. package/components/Page.module.css +9 -0
  87. package/components/Pagination.d.ts +4 -1
  88. package/components/Pagination.js +28 -14
  89. package/components/PasskeyItem.js +1 -0
  90. package/components/PasswordField.js +1 -0
  91. package/components/PinInput.js +1 -0
  92. package/components/Placeholder.js +1 -0
  93. package/components/Popconfirm.js +1 -0
  94. package/components/Popover.d.ts +3 -2
  95. package/components/Popover.js +9 -2
  96. package/components/Progress.js +1 -0
  97. package/components/RadioGroup.js +1 -0
  98. package/components/RangeSlider.js +1 -0
  99. package/components/ResizablePanel.js +1 -0
  100. package/components/ResourceCard.js +1 -0
  101. package/components/SearchField.js +1 -0
  102. package/components/Section.js +1 -0
  103. package/components/Segmented.d.ts +1 -0
  104. package/components/Segmented.js +32 -20
  105. package/components/Select.d.ts +3 -1
  106. package/components/Select.js +12 -2
  107. package/components/SelectOptionContent.js +1 -0
  108. package/components/SelectSettingRow.js +1 -0
  109. package/components/SelectTrigger.js +1 -0
  110. package/components/SelectionTag.js +1 -0
  111. package/components/SessionItem.js +1 -0
  112. package/components/SettingRow.d.ts +3 -2
  113. package/components/SettingRow.js +9 -2
  114. package/components/SettingsLayout.js +1 -0
  115. package/components/ShortcutInput.js +1 -0
  116. package/components/SideBar.js +1 -0
  117. package/components/SidebarNavigation.js +1 -0
  118. package/components/Skeleton.js +1 -0
  119. package/components/SkeletonRows.js +1 -0
  120. package/components/SkinTonePicker.js +1 -0
  121. package/components/Slider.js +1 -0
  122. package/components/Spinner.js +1 -0
  123. package/components/SplitButton.js +1 -0
  124. package/components/Statistic.js +1 -0
  125. package/components/Steps.js +1 -0
  126. package/components/Switch.d.ts +5 -0
  127. package/components/Switch.js +26 -2
  128. package/components/Switch.module.css +101 -59
  129. package/components/SwitchSettingRow.js +1 -0
  130. package/components/SymbolPicker.js +1 -0
  131. package/components/TabList.js +1 -0
  132. package/components/Table.js +1 -0
  133. package/components/TableColumnFilter.js +1 -0
  134. package/components/TableColumnVisibility.js +1 -0
  135. package/components/TableMarkup.d.ts +2 -2
  136. package/components/TableMarkup.js +5 -2
  137. package/components/TableOfContents.js +1 -0
  138. package/components/Tabs.js +1 -0
  139. package/components/TagInput.js +1 -0
  140. package/components/TextAreaSettingRow.js +1 -0
  141. package/components/TextSettingRow.js +1 -0
  142. package/components/Textarea.js +1 -0
  143. package/components/ThemePicker.js +1 -0
  144. package/components/ThemeProvider.js +1 -0
  145. package/components/ThemeStylePicker.js +1 -0
  146. package/components/TimeColumns.js +8 -1
  147. package/components/Timeline.js +1 -0
  148. package/components/Toast.js +4 -1
  149. package/components/ToastProvider.js +1 -0
  150. package/components/Tooltip.js +7 -3
  151. package/components/TreeGuides.js +1 -0
  152. package/components/TreeSelect.js +1 -0
  153. package/components/TreeTable.js +1 -0
  154. package/components/UIProvider.d.ts +1 -0
  155. package/components/UIProvider.js +2 -0
  156. package/components/UnderlinedTab.js +1 -0
  157. package/components/Upload.js +1 -0
  158. package/components/UploadList.js +1 -0
  159. package/components/UploadListItem.js +1 -0
  160. package/components/UptimeChart.js +1 -0
  161. package/components/VirtualPickerList.js +1 -0
  162. package/components/appearance.js +1 -0
  163. package/components/calendarNow.js +1 -0
  164. package/components/characterCatalog.js +1 -0
  165. package/components/color.js +1 -0
  166. package/components/contribution.js +1 -0
  167. package/components/createToaster.js +1 -0
  168. package/components/dateConstraints.js +1 -0
  169. package/components/field.d.ts +7 -7
  170. package/components/field.js +3 -2
  171. package/components/fileSelection.js +1 -0
  172. package/components/hierarchy.js +1 -0
  173. package/components/iconCatalog.js +1 -0
  174. package/components/index.d.ts +1 -0
  175. package/components/index.js +3 -0
  176. package/components/menuFocus.js +1 -0
  177. package/components/menuPointer.js +1 -0
  178. package/components/menuTypes.js +1 -0
  179. package/components/motion.js +1 -0
  180. package/components/rangeMath.js +1 -0
  181. package/components/settingRowControl.js +1 -0
  182. package/components/surfacePortal.js +1 -0
  183. package/components/tooltipState.js +1 -0
  184. package/components/types.js +1 -0
  185. package/components/uploadTypes.js +1 -0
  186. package/components/useFormState.js +1 -0
  187. package/components/useHierarchy.js +1 -0
  188. package/components/useMenuLayers.js +1 -0
  189. package/components/useModalFocus.d.ts +1 -1
  190. package/components/useModalFocus.js +9 -3
  191. package/components/useModalScrollLock.js +1 -0
  192. package/components/usePopover.js +1 -0
  193. package/components/usePortalRoot.d.ts +2 -0
  194. package/components/usePortalRoot.js +12 -0
  195. package/components/useTabIndicator.js +1 -0
  196. package/components/useUIText.d.ts +5 -0
  197. package/components/useUIText.js +14 -0
  198. package/components/useUploadQueue.js +1 -0
  199. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { createElement } from "react";
3
4
  import { fieldTriggerProps, useFieldControl } from "./field.js";
@@ -9,6 +10,7 @@ import { Calendar } from "./Calendar.js";
9
10
  import { TimeColumns } from "./TimeColumns.js";
10
11
  import { Button } from "./Button.js";
11
12
  import s from "./DatePicker.module.css";
13
+ import { useUIText } from "./useUIText.js";
12
14
  import {
13
15
  boundedDate,
14
16
  isDateAllowed
@@ -26,7 +28,7 @@ function SingleDatePicker({
26
28
  seconds = false,
27
29
  timeZone,
28
30
  clearable = false,
29
- placeholder = "\u8BF7\u9009\u62E9",
31
+ placeholder,
30
32
  disabled,
31
33
  readOnly,
32
34
  name,
@@ -39,6 +41,8 @@ function SingleDatePicker({
39
41
  disabledDate,
40
42
  ...aria
41
43
  }) {
44
+ const { text } = useUIText();
45
+ placeholder ??= text("\u8BF7\u9009\u62E9", "Select", "\u8ACB\u9078\u64C7");
42
46
  const constraints = { minDate, maxDate, disabledDate };
43
47
  const field = useFieldControl({
44
48
  id: controlId,
@@ -168,7 +172,7 @@ function SingleDatePicker({
168
172
  close();
169
173
  }
170
174
  },
171
- children: mode === "date" ? "\u4ECA\u5929" : "\u6B64\u523B"
175
+ children: mode === "date" ? text("\u4ECA\u5929", "Today") : text("\u6B64\u523B", "Now")
172
176
  }
173
177
  ),
174
178
  (clearable || mode !== "date") && /* @__PURE__ */ jsxs("div", { className: s.rangeActions, children: [
@@ -182,7 +186,7 @@ function SingleDatePicker({
182
186
  onChange("");
183
187
  close();
184
188
  },
185
- children: "\u6E05\u7A7A"
189
+ children: text("\u6E05\u7A7A", "Clear")
186
190
  }
187
191
  ),
188
192
  mode !== "date" && /* @__PURE__ */ jsx(
@@ -192,7 +196,7 @@ function SingleDatePicker({
192
196
  size: "small",
193
197
  onClick: commit,
194
198
  disabled: mode !== "time" && !isDateAllowed(date, constraints),
195
- children: "\u786E\u5B9A"
199
+ children: text("\u786E\u5B9A", "Apply", "\u78BA\u5B9A")
196
200
  }
197
201
  )
198
202
  ] })
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useId, useState } from "react";
3
4
  import { CalendarDays, ArrowRight } from "lucide-react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  Fragment,
@@ -1,8 +1,8 @@
1
1
  import { type ReactNode, type RefObject } from "react";
2
- export declare function Dialog({ open: requestedOpen, onClose, title, children, footer, wide, size, role, descriptionId, busy, variant, headerIcon, tone, returnFocus, }: {
2
+ export declare function Dialog({ open: requestedOpen, onClose, title, children, footer, wide, size, role, descriptionId, busy, variant, headerIcon, tone, initialFocus, onAfterClose, className, returnFocus, fallbackFocus, portalContainer, closeLabel, }: {
3
3
  open: boolean;
4
4
  onClose(): void;
5
- title: string;
5
+ title: ReactNode;
6
6
  children: ReactNode;
7
7
  footer?: ReactNode;
8
8
  wide?: boolean;
@@ -14,5 +14,11 @@ export declare function Dialog({ open: requestedOpen, onClose, title, children,
14
14
  headerIcon?: ReactNode;
15
15
  tone?: "neutral" | "info" | "success" | "warning" | "danger";
16
16
  /** Trigger to focus after closing, including surfaces opened asynchronously. */
17
+ initialFocus?: RefObject<HTMLElement | null>;
18
+ onAfterClose?(): void;
19
+ className?: string;
17
20
  returnFocus?: RefObject<HTMLElement | null>;
18
- }): import("react").ReactPortal;
21
+ fallbackFocus?: RefObject<HTMLElement | null>;
22
+ closeLabel?: string;
23
+ portalContainer?: HTMLElement | null;
24
+ }): import("react").ReactPortal | null;
@@ -1,4 +1,6 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { usePortalRoot } from "./usePortalRoot.js";
2
4
  import {
3
5
  useId,
4
6
  useEffect,
@@ -33,12 +35,26 @@ function Dialog({
33
35
  variant = "default",
34
36
  headerIcon,
35
37
  tone = "neutral",
36
- returnFocus
38
+ initialFocus,
39
+ onAfterClose,
40
+ className = "",
41
+ returnFocus,
42
+ fallbackFocus,
43
+ portalContainer,
44
+ closeLabel = "\u5173\u95ED\u5F39\u7A97"
37
45
  }) {
46
+ const defaultRoot = usePortalRoot();
47
+ const portalRoot = portalContainer ?? defaultRoot;
38
48
  const owner = useSurfacePortal(), open = requestedOpen && owner?.active !== false;
39
49
  const { ref, host, setRef } = useSurfaceHost();
40
50
  const titleId = useId();
41
- const { rememberFocus, restoreFocus } = useModalFocus(ref, returnFocus);
51
+ const afterClose = useRef(onAfterClose);
52
+ afterClose.current = onAfterClose;
53
+ const { rememberFocus, restoreFocus } = useModalFocus(
54
+ ref,
55
+ returnFocus,
56
+ fallbackFocus
57
+ );
42
58
  const [closing, setClosing] = useState(false);
43
59
  useModalScrollLock(open || closing);
44
60
  const opened = useRef(open);
@@ -51,20 +67,24 @@ function Dialog({
51
67
  }, [requestedOpen, owner?.active, onClose]);
52
68
  useEffect(() => {
53
69
  const node = ref.current;
70
+ if (!node) return;
54
71
  return () => cancelMotion(node);
55
- }, []);
72
+ }, [portalRoot]);
56
73
  useLayoutEffect(() => {
57
74
  const element = ref.current;
75
+ if (!element) return;
58
76
  if (open) {
59
77
  element.inert = false;
60
78
  setClosing(false);
61
79
  if (!element.open) {
62
80
  rememberFocus();
63
81
  element.showModal();
64
- element.querySelector(
65
- "[data-dialog-initial-focus]:not(:disabled)"
66
- )?.focus({ preventScroll: true });
67
- if (!element.querySelector("[data-dialog-initial-focus]:not(:disabled)"))
82
+ initialFocus?.current?.focus({ preventScroll: true });
83
+ if (!initialFocus?.current)
84
+ element.querySelector(
85
+ "[data-dialog-initial-focus]:not(:disabled)"
86
+ )?.focus({ preventScroll: true });
87
+ if (!initialFocus?.current && !element.querySelector("[data-dialog-initial-focus]:not(:disabled)"))
68
88
  element.querySelector(
69
89
  'input:not([disabled]):not([readonly]):not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]),textarea:not([disabled]),[role="combobox"]'
70
90
  )?.focus({ preventScroll: true });
@@ -80,13 +100,15 @@ function Dialog({
80
100
  element.close();
81
101
  restoreFocus();
82
102
  setClosing(false);
103
+ afterClose.current?.();
83
104
  });
84
- }, [open, rememberFocus, restoreFocus]);
105
+ }, [open, portalRoot, initialFocus, rememberFocus, restoreFocus]);
85
106
  const backdropDown = useRef(false);
86
107
  const outside = (event) => {
87
108
  const rect = event.currentTarget.getBoundingClientRect();
88
109
  return event.target === event.currentTarget && (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom);
89
110
  };
111
+ if (!portalRoot) return null;
90
112
  return createPortal(
91
113
  /* @__PURE__ */ jsx(SurfacePortalContext, { value: { host, active: open }, children: /* @__PURE__ */ jsx(FieldContext, { value: null, children: /* @__PURE__ */ jsxs(
92
114
  "dialog",
@@ -99,7 +121,7 @@ function Dialog({
99
121
  "data-variant": variant,
100
122
  "data-tone": content.tone,
101
123
  "data-header-icon": !!content.headerIcon,
102
- className: `${s.dialog} ${wide || size === "large" ? s.wide : ""} ${size === "small" ? s.small : ""} ${closing ? s.closing : ""}`,
124
+ className: `${s.dialog} ${className} ${wide || size === "large" ? s.wide : ""} ${size === "small" ? s.small : ""} ${closing ? s.closing : ""}`,
103
125
  onCancel: (e) => {
104
126
  e.preventDefault();
105
127
  e.stopPropagation();
@@ -118,14 +140,14 @@ function Dialog({
118
140
  content.headerIcon && /* @__PURE__ */ jsx("span", { className: s.dialogIcon, "aria-hidden": "true", children: content.headerIcon }),
119
141
  /* @__PURE__ */ jsx("h2", { id: titleId, children: content.title })
120
142
  ] }),
121
- /* @__PURE__ */ jsx(IconButton, { label: "\u5173\u95ED\u5F39\u7A97", onClick: onClose, disabled: busy, children: /* @__PURE__ */ jsx(X, {}) })
143
+ /* @__PURE__ */ jsx(IconButton, { label: closeLabel, onClick: onClose, disabled: busy, children: /* @__PURE__ */ jsx(X, {}) })
122
144
  ] }),
123
145
  /* @__PURE__ */ jsx("div", { className: s.dialogBody, children: content.children }),
124
146
  content.footer && /* @__PURE__ */ jsx("footer", { className: s.dialogFooter, children: content.footer })
125
147
  ]
126
148
  }
127
149
  ) }) }),
128
- document.body
150
+ portalRoot
129
151
  );
130
152
  }
131
153
  export {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useId,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import s from "./DisclosureChevron.module.css";
3
4
  function DisclosureChevron({ expanded }) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import s from "./Divider.module.css";
3
4
  function Divider({
@@ -4,7 +4,7 @@ export type DrawerProps = {
4
4
  open: boolean;
5
5
  onClose(): void;
6
6
  onAfterClose?(): void;
7
- title: string;
7
+ title: ReactNode;
8
8
  description?: ReactNode;
9
9
  children: ReactNode;
10
10
  footer?: ReactNode;
@@ -15,6 +15,9 @@ export type DrawerProps = {
15
15
  closeOnBackdrop?: boolean;
16
16
  initialFocus?: RefObject<HTMLElement | null>;
17
17
  returnFocus?: RefObject<HTMLElement | null>;
18
+ fallbackFocus?: RefObject<HTMLElement | null>;
19
+ closeLabel?: string;
20
+ portalContainer?: HTMLElement | null;
18
21
  className?: string;
19
22
  };
20
- export declare function Drawer({ open: requestedOpen, onClose, onAfterClose, title, description, children, footer, placement, size, closable, closeOnEscape, closeOnBackdrop, initialFocus, returnFocus, className, }: DrawerProps): import("react").ReactPortal;
23
+ export declare function Drawer({ open: requestedOpen, onClose, onAfterClose, title, description, children, footer, placement, size, closable, closeOnEscape, closeOnBackdrop, initialFocus, returnFocus, fallbackFocus, portalContainer, closeLabel, className, }: DrawerProps): import("react").ReactPortal | null;
@@ -1,4 +1,6 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { usePortalRoot } from "./usePortalRoot.js";
2
4
  import {
3
5
  useEffect,
4
6
  useId,
@@ -40,11 +42,20 @@ function Drawer({
40
42
  closeOnBackdrop = true,
41
43
  initialFocus,
42
44
  returnFocus,
45
+ fallbackFocus,
46
+ portalContainer,
47
+ closeLabel = "\u5173\u95ED\u5F39\u7A97",
43
48
  className = ""
44
49
  }) {
50
+ const defaultRoot = usePortalRoot();
51
+ const portalRoot = portalContainer ?? defaultRoot;
45
52
  const owner = useSurfacePortal(), open = requestedOpen && owner?.active !== false;
46
53
  const { ref, host, setRef } = useSurfaceHost();
47
- const { rememberFocus, restoreFocus } = useModalFocus(ref, returnFocus);
54
+ const { rememberFocus, restoreFocus } = useModalFocus(
55
+ ref,
56
+ returnFocus,
57
+ fallbackFocus
58
+ );
48
59
  const opened = useRef(open), backdropDown = useRef(false), titleId = useId(), descriptionId = useId();
49
60
  const [closing, setClosing] = useState(false);
50
61
  const afterClose = useRef(onAfterClose);
@@ -56,12 +67,14 @@ function Drawer({
56
67
  }, [requestedOpen, owner?.active, onClose]);
57
68
  useEffect(() => {
58
69
  const node = ref.current;
70
+ if (!node) return;
59
71
  return () => {
60
72
  cancelMotion(node);
61
73
  };
62
- }, []);
74
+ }, [portalRoot]);
63
75
  useLayoutEffect(() => {
64
76
  const node = ref.current;
77
+ if (!node) return;
65
78
  if (open) {
66
79
  node.inert = false;
67
80
  setClosing(false);
@@ -92,16 +105,18 @@ function Drawer({
92
105
  setClosing(false);
93
106
  afterClose.current?.();
94
107
  });
95
- }, [open, placement, initialFocus, rememberFocus, restoreFocus]);
108
+ }, [open, portalRoot, placement, initialFocus, rememberFocus, restoreFocus]);
96
109
  const outside = (event) => {
97
110
  const rect = event.currentTarget.getBoundingClientRect();
98
111
  return event.target === event.currentTarget && (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom);
99
112
  };
100
113
  const length = typeof size === "number" ? `${Number.isFinite(size) ? Math.max(180, size) : 420}px` : size;
114
+ if (!portalRoot) return null;
101
115
  return createPortal(
102
116
  /* @__PURE__ */ jsx(SurfacePortalContext, { value: { host, active: open }, children: /* @__PURE__ */ jsx(FieldContext, { value: null, children: /* @__PURE__ */ jsxs(
103
117
  "dialog",
104
118
  {
119
+ role: "dialog",
105
120
  ref: setRef,
106
121
  tabIndex: -1,
107
122
  "aria-labelledby": titleId,
@@ -131,14 +146,14 @@ function Drawer({
131
146
  /* @__PURE__ */ jsx("h2", { id: titleId, children: title }),
132
147
  description != null && /* @__PURE__ */ jsx("div", { id: descriptionId, className: s.description, children: description })
133
148
  ] }),
134
- closable && /* @__PURE__ */ jsx(IconButton, { label: "\u5173\u95ED\u62BD\u5C49", onClick: onClose, children: /* @__PURE__ */ jsx(X, {}) })
149
+ closable && /* @__PURE__ */ jsx(IconButton, { label: closeLabel, onClick: onClose, children: /* @__PURE__ */ jsx(X, {}) })
135
150
  ] }),
136
151
  /* @__PURE__ */ jsx("div", { className: s.body, "data-drawer-body": true, children }),
137
152
  footer && /* @__PURE__ */ jsx("footer", { className: s.footer, children: footer })
138
153
  ]
139
154
  }
140
155
  ) }) }),
141
- document.body
156
+ portalRoot
142
157
  );
143
158
  }
144
159
  export {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { CharacterPicker } from "./CharacterPicker.js";
3
4
  import { useCharacterCatalog } from "./characterCatalog.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { Inbox } from "lucide-react";
3
4
  import s from "./EmptyState.module.css";
@@ -1,5 +1,6 @@
1
+ import type { ReactNode } from "react";
1
2
  export declare function FieldLabel({ label, htmlFor, required, indicator, optional, as, }: {
2
- label: string;
3
+ label: ReactNode;
3
4
  htmlFor?: string;
4
5
  required?: boolean;
5
6
  indicator?: "asterisk" | "text" | "none";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./FormField.module.css";
3
4
  function FieldLabel({
@@ -1,5 +1,6 @@
1
+ import type { ReactNode } from "react";
1
2
  export declare function FieldMessages({ id, hint, error, }: {
2
3
  id: string;
3
- hint?: string;
4
- error?: string;
4
+ hint?: ReactNode;
5
+ error?: ReactNode;
5
6
  }): import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./FormField.module.css";
3
4
  function FieldMessages({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { FolderOpen } from "lucide-react";
3
4
  import s from "./FileDropOverlay.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useEffect, useRef, useState } from "react";
3
4
  import { FileDropOverlay } from "./FileDropOverlay.js";
@@ -1,5 +1,6 @@
1
1
  import { type FileConstraints, type FileRejection, type FileSelectionResult } from "./fileSelection";
2
- export type FilePickerProps = FileConstraints & {
2
+ import { type FieldOptions } from "./field";
3
+ export type FilePickerProps = FileConstraints & Pick<FieldOptions, "id" | "disabled" | "aria-describedby" | "aria-invalid"> & {
3
4
  onFiles(files: File[]): void;
4
5
  onReject?(rejections: FileRejection[]): void;
5
6
  onValidation?(result: FileSelectionResult): void;
@@ -7,4 +8,4 @@ export type FilePickerProps = FileConstraints & {
7
8
  label?: string;
8
9
  showErrors?: boolean;
9
10
  };
10
- export declare function FilePicker({ onFiles, onReject, onValidation, disabled, label, showErrors, ...constraints }: FilePickerProps): import("react").JSX.Element;
11
+ export declare function FilePicker({ onFiles, onReject, onValidation, disabled, id: controlId, "aria-describedby": describedBy, "aria-invalid": invalid, label, showErrors, ...constraints }: FilePickerProps): import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useId, useRef, useState } from "react";
3
4
  import { Upload } from "lucide-react";
@@ -6,15 +7,25 @@ import {
6
7
  validateFiles
7
8
  } from "./fileSelection.js";
8
9
  import { FileSelectionFeedback } from "./FileSelectionFeedback.js";
10
+ import { useFieldControl, joinIds } from "./field.js";
9
11
  function FilePicker({
10
12
  onFiles,
11
13
  onReject,
12
14
  onValidation,
13
- disabled = false,
15
+ disabled,
16
+ id: controlId,
17
+ "aria-describedby": describedBy,
18
+ "aria-invalid": invalid,
14
19
  label = "\u9009\u62E9\u6587\u4EF6",
15
20
  showErrors = true,
16
21
  ...constraints
17
22
  }) {
23
+ const field = useFieldControl({
24
+ id: controlId,
25
+ disabled,
26
+ "aria-describedby": describedBy,
27
+ "aria-invalid": invalid
28
+ });
18
29
  const ref = useRef(null), id = useId(), [rejections, setRejections] = useState([]);
19
30
  return /* @__PURE__ */ jsxs(Fragment, { children: [
20
31
  /* @__PURE__ */ jsx(
@@ -24,11 +35,11 @@ function FilePicker({
24
35
  type: "file",
25
36
  multiple: constraints.multiple !== false,
26
37
  accept: constraints.accept,
27
- disabled,
38
+ disabled: field.disabled,
28
39
  hidden: true,
29
40
  onChange: (e) => {
30
41
  const files = Array.from(e.target.files || []);
31
- if (files.length && !disabled) {
42
+ if (files.length && !field.disabled && !e.currentTarget.matches(":disabled")) {
32
43
  const result = validateFiles(files, constraints);
33
44
  setRejections(result.rejected);
34
45
  onValidation?.(result);
@@ -42,8 +53,13 @@ function FilePicker({
42
53
  /* @__PURE__ */ jsxs(
43
54
  Button,
44
55
  {
45
- disabled,
46
- "aria-describedby": showErrors && rejections.length ? id : void 0,
56
+ id: field.id,
57
+ disabled: field.disabled,
58
+ "aria-invalid": field.invalid,
59
+ "aria-describedby": joinIds(
60
+ field.descriptionId,
61
+ showErrors && rejections.length ? id : void 0
62
+ ),
47
63
  onClick: () => ref.current?.click(),
48
64
  children: [
49
65
  /* @__PURE__ */ jsx(Upload, {}),
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./FileSelectionFeedback.module.css";
3
4
  function FileSelectionFeedback({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useMemo, useRef, useState } from "react";
3
4
  import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import s from "./Form.module.css";
3
4
  import { FormLayoutContext } from "./FormLayout.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./FormErrorSummary.module.css";
3
4
  function FormErrorSummary({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useUIConfig } from "./UIProvider.js";
3
4
  import { FieldMessages } from "./FieldMessages.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { FieldMessages } from "./FieldMessages.js";
3
4
  import { useId } from "react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { createContext } from "react";
2
3
  const FormLayoutContext = createContext({
3
4
  layout: "stacked"
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { Spinner } from "./Spinner.js";
3
4
  import { Tooltip } from "./Tooltip.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useCallback, useMemo, useState } from "react";
3
4
  import { Popover } from "./Popover.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useLayoutEffect, useRef } from "react";
3
4
  import s from "./Indicator.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { FormField } from "./FormField.js";
3
4
  import { fieldInputProps, useFieldControl } from "./field.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import s from "./Layout.module.css";
3
4
  import card from "./Card.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { LoadingState } from "./LoadingState.js";
3
4
  import s from "./LoadingOverlay.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { Spinner } from "./Spinner.js";
3
4
  import { SkeletonRows } from "./SkeletonRows.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useId,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useId } from "react";
3
4
  import { ChevronDown, MoreHorizontal } from "lucide-react";
@@ -1,7 +1,12 @@
1
1
  import { type MenuItemContentProps } from "./MenuItemContent";
2
- import type { HTMLAttributes, ReactNode } from "react";
2
+ import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
3
3
  export type MenuItemProps = Omit<HTMLAttributes<HTMLElement>, "children" | "prefix"> & MenuItemContentProps & {
4
- as?: "button" | "div";
4
+ as?: "button" | "div" | "a";
5
+ asChild?: boolean;
6
+ children?: ReactElement<HTMLAttributes<HTMLElement>>;
7
+ href?: string;
8
+ target?: string;
9
+ rel?: string;
5
10
  prefix?: ReactNode;
6
11
  shortcut?: string;
7
12
  trailing?: ReactNode;
@@ -12,4 +17,4 @@ export type MenuItemProps = Omit<HTMLAttributes<HTMLElement>, "children" | "pref
12
17
  selection?: "check" | "checkbox" | "radio";
13
18
  tone?: "default" | "danger";
14
19
  };
15
- export declare function MenuItem({ as, prefix, label, description, icon, reserveIcon, shortcut, trailing, meta, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
20
+ export declare function MenuItem({ as, asChild, children, prefix, label, description, icon, reserveIcon, shortcut, trailing, meta, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
@@ -1,9 +1,16 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { MenuItemContent } from "./MenuItemContent.js";
4
+ import {
5
+ cloneElement,
6
+ isValidElement
7
+ } from "react";
3
8
  import { Check } from "lucide-react";
4
9
  import s from "./MenuItem.module.css";
5
10
  function MenuItem({
6
11
  as = "button",
12
+ asChild = false,
13
+ children,
7
14
  prefix,
8
15
  label,
9
16
  description,
@@ -44,7 +51,23 @@ function MenuItem({
44
51
  "data-tone": tone,
45
52
  "aria-disabled": disabled || void 0
46
53
  };
47
- return as === "div" ? /* @__PURE__ */ jsx("div", { ...common, children: content }) : /* @__PURE__ */ jsx("button", { type: "button", ...common, disabled, children: content });
54
+ if (asChild && isValidElement(children)) {
55
+ return cloneElement(children, {
56
+ ...common,
57
+ className: `${common.className} ${children.props.className ?? ""}`,
58
+ tabIndex: disabled ? -1 : props.tabIndex ?? children.props.tabIndex,
59
+ onClick: (event) => {
60
+ if (disabled) {
61
+ event.preventDefault();
62
+ return;
63
+ }
64
+ children.props.onClick?.(event);
65
+ if (!event.defaultPrevented) props.onClick?.(event);
66
+ },
67
+ children: content
68
+ });
69
+ }
70
+ return as === "a" ? /* @__PURE__ */ jsx("a", { ...common, tabIndex: disabled ? -1 : props.tabIndex, children: content }) : as === "div" ? /* @__PURE__ */ jsx("div", { ...common, children: content }) : /* @__PURE__ */ jsx("button", { type: "button", ...common, disabled, children: content });
48
71
  }
49
72
  export {
50
73
  MenuItem
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./MenuItem.module.css";
3
4
  function MenuItemContent({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { moveMenuFocus } from "./menuFocus.js";
3
4
  import { fieldTriggerProps, useFieldControl } from "./field.js";
@@ -8,6 +8,7 @@ export type NavBarItem = NavigationItem | {
8
8
  children: readonly NavigationItem[];
9
9
  };
10
10
  export type NavBarProps = {
11
+ as?: "header" | "div";
11
12
  items: readonly NavBarItem[];
12
13
  active: string;
13
14
  onNavigate?(path: string): void;
@@ -17,4 +18,4 @@ export type NavBarProps = {
17
18
  label?: string;
18
19
  className?: string;
19
20
  };
20
- export declare function NavBar({ items, active, onNavigate, brand, homePath, actions, label, className, }: NavBarProps): import("react").JSX.Element;
21
+ export declare function NavBar({ as: Root, items, active, onNavigate, brand, homePath, actions, label, className, }: NavBarProps): import("react").JSX.Element;