@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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.19
2
+
3
+ - Add opt-in Combobox allowCustomValue input mode: preserve freely typed text on blur, Enter, and async loading or failure; only explicit option selection commits an option. Pass the selected option as the optional second onChange argument.
4
+
1
5
  # 0.6.18
2
6
 
3
7
  - Add Menu iconOnly triggers backed by the shared IconButton, preserving tooltip, focus restoration and keyboard menu interaction without a normal button border or minimum height.
package/README.md CHANGED
@@ -191,6 +191,7 @@ export function App() {
191
191
  - `TreeSelect variant="category"` 在原有树选择交互上增加图标底块、子项数量与层级连线;默认 `variant="tree"` 保留简洁样式。两种样式均支持搜索、父子联动、多选、禁用、异步加载及键盘操作。`HierarchyOption.count` 可单独提供数量。
192
192
  - `TreeTable` 复用 `Table` 的列定义,接收 `rows`、`rowKey`、`getChildren`、`rowLabel`;通过 `expanded` / `onExpandedChange` 控制展开,或使用 `defaultExpanded` / `defaultExpandAll`。`treeColumn` 默认为第一列,支持多级连线、方向键导航及独立行操作。`Column.align`、`Column.width` 可用于对齐和列宽。
193
193
  - `Combobox mode="input"` 直接在触发框输入并在下方显示候选,保留 `loadOptions`、`onCreate` 和键盘选择。输入中的文本只用于搜索;选择候选或创建成功才提交选项值,关闭时恢复已选标签。默认 `mode="panel"` 继续使用弹层内搜索。
194
+ - 需要自由文本补全时加 `allowCustomValue`:每次输入直接更新值,失焦或回车不会强制替换成候选;方向键后回车或点击仍可选择候选。`onChange(value, option?)` 在主动选择时提供对应选项,自由输入时不提供选项,可用于区分手写地点与带坐标的地点候选。
194
195
  - `MultiSelect display="tags"` 在触发框内展示可移除标签,复用 `TagInput` 的标签样式;默认 `display="summary"` 保留文字摘要。两种模式共享连续选择、搜索、数量限制和表单值。只读标签不可移除,禁用选项保持不可操作。
195
196
 
196
197
  菜单项间距统一为 `--menu-item-spacing: 1px`,菜单快捷键为靠右的纯文字提示,不预留空的指示器位置。Desktop 与 Web 共用示例:`/pickers?view=hierarchy`、`/forms?view=advanced`、`/data?view=hierarchy`;层级表格中的增删改仅更新示例内存数据。以上扩展从 0.2.0 起提供。
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
2
  export declare function Accordion({ title, open, onChange, children, }: {
3
- title: string;
3
+ title: ReactNode;
4
4
  open: boolean;
5
5
  onChange(open: boolean): void;
6
6
  children: ReactNode;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useId } from "react";
3
4
  import { DisclosureChevron } from "./DisclosureChevron.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import s from "./AccountItem.module.css";
3
4
  function AccountItem({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useRef, useState } from "react";
3
4
  import { MoreHorizontal } from "lucide-react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Banner } from "./Banner.js";
2
3
  export {
3
4
  Banner as Alert
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useEffect,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { SwitchSettingRow } from "./SwitchSettingRow.js";
3
4
  import { SelectSettingRow } from "./SelectSettingRow.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { Surface, Stack, Heading } from "./Layout.js";
3
4
  import s from "./AuthLayout.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useState } from "react";
3
4
  import { User } from "lucide-react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { moveMenuFocus } from "./menuFocus.js";
3
4
  import { useEffect, useId, useRef } from "react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import s from "./Badge.module.css";
3
4
  function Badge({
@@ -1,5 +1,5 @@
1
- import { type ReactNode } from "react";
2
- export type BannerProps = {
1
+ import { type ReactNode, type ComponentProps } from "react";
2
+ export type BannerProps = Omit<ComponentProps<"div">, "title" | "onClose"> & {
3
3
  tone?: "info" | "success" | "warning" | "danger" | "neutral";
4
4
  variant?: "soft" | "outline" | "filled";
5
5
  title?: ReactNode;
@@ -14,4 +14,4 @@ export type BannerProps = {
14
14
  onExpandedChange?(expanded: boolean): void;
15
15
  className?: string;
16
16
  };
17
- export declare function Banner({ tone, variant, title, children, icon, action, onClose, compact, details, expanded, defaultExpanded, onExpandedChange, className, }: BannerProps): import("react").JSX.Element;
17
+ export declare function Banner({ tone, variant, title, children, icon, action, onClose, compact, details, expanded, defaultExpanded, onExpandedChange, className, role, style, ...props }: BannerProps): import("react").JSX.Element;
@@ -1,5 +1,9 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useId, useState } from "react";
3
+ import {
4
+ useId,
5
+ useState
6
+ } from "react";
3
7
  import {
4
8
  Info,
5
9
  CircleCheck,
@@ -24,7 +28,10 @@ function Banner({
24
28
  expanded,
25
29
  defaultExpanded = false,
26
30
  onExpandedChange,
27
- className = ""
31
+ className = "",
32
+ role = tone === "danger" ? "alert" : "status",
33
+ style,
34
+ ...props
28
35
  }) {
29
36
  const [internal, setInternal] = useState(defaultExpanded);
30
37
  const open = expanded ?? internal;
@@ -34,13 +41,14 @@ function Banner({
34
41
  return /* @__PURE__ */ jsxs(
35
42
  "div",
36
43
  {
44
+ ...props,
37
45
  className: `${s.banner} ${className}`,
38
46
  "data-tone": tone,
39
47
  "data-variant": variant,
40
48
  "data-compact": compact,
41
49
  "data-has-icon": !!icon,
42
- role: tone === "danger" ? "alert" : "status",
43
- style: { "--banner-color": color },
50
+ role,
51
+ style: { "--banner-color": color, ...style },
44
52
  children: [
45
53
  /* @__PURE__ */ jsxs("div", { className: s.main, children: [
46
54
  icon && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", children: icon === true ? /* @__PURE__ */ jsx(Icon, {}) : icon }),
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { Tooltip } from "./Tooltip.js";
3
4
  import s from "./BarChart.module.css";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { memo } from "react";
3
4
  import { TabList } from "./TabList.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { moveMenuFocus } from "./menuFocus.js";
3
4
  import {
@@ -1,13 +1,15 @@
1
- import type { ComponentPropsWithRef } from "react";
1
+ import { type ComponentPropsWithRef } from "react";
2
2
  type ButtonProps = {
3
3
  variant?: "primary" | "secondary" | "ghost" | "danger" | "link";
4
4
  size?: "normal" | "small";
5
5
  loading?: boolean;
6
+ /** Apply button appearance to a router link without replacing its behavior. */
7
+ asChild?: boolean;
6
8
  } & ((ComponentPropsWithRef<"button"> & {
7
9
  href?: never;
8
10
  }) | (ComponentPropsWithRef<"a"> & {
9
11
  href: string;
10
12
  disabled?: boolean;
11
13
  }));
12
- export declare function Button({ variant, size, loading, children, className, ...props }: ButtonProps): import("react").JSX.Element;
14
+ export declare function Button({ variant, size, loading, asChild, children, className, ...props }: ButtonProps): import("react").JSX.Element;
13
15
  export {};
@@ -1,10 +1,16 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ cloneElement,
5
+ isValidElement
6
+ } from "react";
2
7
  import { Spinner } from "./Spinner.js";
3
8
  import s from "./Button.module.css";
4
9
  function Button({
5
10
  variant = "secondary",
6
11
  size = "normal",
7
12
  loading,
13
+ asChild,
8
14
  children,
9
15
  className = "",
10
16
  ...props
@@ -14,6 +20,24 @@ function Button({
14
20
  loading && /* @__PURE__ */ jsx("span", { className: s.loader, children: /* @__PURE__ */ jsx(Spinner, { decorative: true }) })
15
21
  ] });
16
22
  const classes = `${s.button} ${s[variant]} ${size === "small" ? s.small : ""} ${className}`;
23
+ if (asChild && isValidElement(children)) {
24
+ const child = children;
25
+ const blocked = props.disabled || loading;
26
+ return cloneElement(child, {
27
+ ...props,
28
+ ...child.props,
29
+ className: `${classes} ${child.props.className ?? ""}`,
30
+ "aria-disabled": blocked || void 0,
31
+ "aria-busy": loading || void 0,
32
+ tabIndex: blocked ? -1 : child.props.tabIndex,
33
+ onClick: (event) => {
34
+ if (blocked) {
35
+ event.preventDefault();
36
+ event.stopPropagation();
37
+ } else child.props.onClick?.(event);
38
+ }
39
+ });
40
+ }
17
41
  if (typeof props.href === "string") {
18
42
  const { disabled, onClick, ...link } = props;
19
43
  const blocked = disabled || loading;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
4
  import { ChevronLeft, ChevronRight } from "lucide-react";
@@ -11,6 +12,7 @@ import {
11
12
  readDate
12
13
  } from "./dateConstraints.js";
13
14
  import s from "./Calendar.module.css";
15
+ import { useUIText } from "./useUIText.js";
14
16
  import { dateKey as dateKey2, readDate as readDate2 } from "./dateConstraints.js";
15
17
  function Calendar({
16
18
  value,
@@ -23,6 +25,7 @@ function Calendar({
23
25
  disabledDate,
24
26
  today = dateKey(/* @__PURE__ */ new Date())
25
27
  }) {
28
+ const { text, english } = useUIText();
26
29
  const constraints = { minDate, maxDate, disabledDate };
27
30
  const [month, setMonth] = useState(
28
31
  () => readDate(boundedDate(value || today, constraints))
@@ -80,7 +83,7 @@ function Calendar({
80
83
  /* @__PURE__ */ jsx(
81
84
  IconButton,
82
85
  {
83
- label: view === "days" ? "\u4E0A\u4E2A\u6708" : view === "months" ? "\u4E0A\u4E00\u5E74" : "\u524D\u5341\u4E8C\u5E74",
86
+ label: view === "days" ? text("\u4E0A\u4E2A\u6708", "Previous month", "\u4E0A\u500B\u6708") : view === "months" ? text("\u4E0A\u4E00\u5E74", "Previous year") : text("\u524D\u5341\u4E8C\u5E74", "Previous twelve years"),
84
87
  disabled: !periodAllowed(-1),
85
88
  onClick: () => move(-1),
86
89
  children: /* @__PURE__ */ jsx(ChevronLeft, {})
@@ -95,31 +98,30 @@ function Calendar({
95
98
  "button",
96
99
  {
97
100
  type: "button",
98
- "aria-label": "\u9009\u62E9\u5E74\u4EFD",
101
+ "aria-label": text("\u9009\u62E9\u5E74\u4EFD", "Choose year", "\u9078\u64C7\u5E74\u4EFD"),
99
102
  onClick: () => openView("years"),
100
103
  children: [
101
104
  year,
102
- " \u5E74"
105
+ text(" \u5E74", "")
103
106
  ]
104
107
  }
105
108
  ),
106
- /* @__PURE__ */ jsxs(
109
+ /* @__PURE__ */ jsx(
107
110
  "button",
108
111
  {
109
112
  type: "button",
110
- "aria-label": "\u9009\u62E9\u6708\u4EFD",
113
+ "aria-label": text("\u9009\u62E9\u6708\u4EFD", "Choose month", "\u9078\u64C7\u6708\u4EFD"),
111
114
  onClick: () => openView(view === "months" ? "days" : "months"),
112
- children: [
113
- index + 1,
114
- " \u6708"
115
- ]
115
+ children: english ? new Intl.DateTimeFormat("en", { month: "short" }).format(
116
+ month
117
+ ) : `${index + 1} \u6708`
116
118
  }
117
119
  )
118
120
  ] }) }),
119
121
  /* @__PURE__ */ jsx(
120
122
  IconButton,
121
123
  {
122
- label: view === "days" ? "\u4E0B\u4E2A\u6708" : view === "months" ? "\u4E0B\u4E00\u5E74" : "\u540E\u5341\u4E8C\u5E74",
124
+ label: view === "days" ? text("\u4E0B\u4E2A\u6708", "Next month", "\u4E0B\u500B\u6708") : view === "months" ? text("\u4E0B\u4E00\u5E74", "Next year") : text("\u540E\u5341\u4E8C\u5E74", "Next twelve years", "\u5F8C\u5341\u4E8C\u5E74"),
123
125
  disabled: !periodAllowed(1),
124
126
  onClick: () => move(1),
125
127
  children: /* @__PURE__ */ jsx(ChevronRight, {})
@@ -127,7 +129,7 @@ function Calendar({
127
129
  )
128
130
  ] }),
129
131
  /* @__PURE__ */ jsx("div", { className: s.area, children: view === "days" ? /* @__PURE__ */ jsxs(Fragment, { children: [
130
- /* @__PURE__ */ jsx("div", { className: s.week, children: ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"].map((day) => /* @__PURE__ */ jsx("span", { children: day }, day)) }),
132
+ /* @__PURE__ */ jsx("div", { className: s.week, children: (english ? ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] : ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"]).map((day) => /* @__PURE__ */ jsx("span", { children: day }, day)) }),
131
133
  /* @__PURE__ */ jsx(
132
134
  "div",
133
135
  {
@@ -235,7 +237,9 @@ function Calendar({
235
237
  "button",
236
238
  {
237
239
  type: "button",
238
- "aria-label": view === "years" ? choice + " \u5E74" : choice + 1 + " \u6708",
240
+ "aria-label": view === "years" ? choice + text(" \u5E74", "") : english ? new Intl.DateTimeFormat("en", {
241
+ month: "short"
242
+ }).format(calendarDate(year, choice)) : choice + 1 + " \u6708",
239
243
  "aria-pressed": choice === (view === "years" ? year : index),
240
244
  disabled: !enabled,
241
245
  onClick: () => {
@@ -247,7 +251,9 @@ function Calendar({
247
251
  );
248
252
  openView(view === "years" ? "months" : "days");
249
253
  },
250
- children: view === "years" ? choice : choice + 1 + " \u6708"
254
+ children: view === "years" ? choice : english ? new Intl.DateTimeFormat("en", {
255
+ month: "short"
256
+ }).format(calendarDate(year, choice)) : choice + 1 + " \u6708"
251
257
  },
252
258
  choice
253
259
  );
@@ -1,9 +1,10 @@
1
- import type { ReactNode } from "react";
2
- export declare function Card({ title, description, action, children, className, onClick, }: {
3
- title?: string;
1
+ import type { ReactNode, ComponentPropsWithRef } from "react";
2
+ export declare function Card({ title, description, action, children, className, onClick, bodyClassName, padding, ...props }: Omit<ComponentPropsWithRef<"section">, "title"> & {
3
+ title?: ReactNode;
4
4
  description?: ReactNode;
5
5
  action?: ReactNode;
6
6
  children?: ReactNode;
7
7
  className?: string;
8
- onClick?(): void;
8
+ bodyClassName?: string;
9
+ padding?: "normal" | "compact" | "none";
9
10
  }): 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 "./Card.module.css";
3
4
  function Card({
@@ -6,10 +7,13 @@ function Card({
6
7
  action,
7
8
  children,
8
9
  className = "",
9
- onClick
10
+ onClick,
11
+ bodyClassName,
12
+ padding = "normal",
13
+ ...props
10
14
  }) {
11
15
  const hasBody = children != null && children !== false;
12
- const classes = `${s.card} ${!hasBody ? s.headerOnly : ""} ${className}`;
16
+ const classes = `${s.card} ${!hasBody ? s.headerOnly : ""} ${s[padding]} ${className}`;
13
17
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
14
18
  (title || description || action) && /* @__PURE__ */ jsxs("header", { className: s.header, children: [
15
19
  /* @__PURE__ */ jsxs("div", { className: s.heading, children: [
@@ -18,7 +22,7 @@ function Card({
18
22
  ] }),
19
23
  action
20
24
  ] }),
21
- hasBody && /* @__PURE__ */ jsx("div", { className: s.body, "data-card-body": true, children })
25
+ hasBody && /* @__PURE__ */ jsx("div", { className: `${s.body} ${bodyClassName ?? ""}`, "data-card-body": true, children })
22
26
  ] });
23
27
  return onClick ? /* @__PURE__ */ jsx(
24
28
  "button",
@@ -28,7 +32,7 @@ function Card({
28
32
  onClick,
29
33
  children: content
30
34
  }
31
- ) : /* @__PURE__ */ jsx("section", { className: classes, children: content });
35
+ ) : /* @__PURE__ */ jsx("section", { ...props, className: classes, children: content });
32
36
  }
33
37
  export {
34
38
  Card
@@ -65,3 +65,13 @@
65
65
  padding-bottom: 18px;
66
66
  }
67
67
  }
68
+
69
+ .compact {
70
+ --card-space: 18px;
71
+ }
72
+ .none > .body {
73
+ padding: 0;
74
+ }
75
+ .none > .header + .body {
76
+ padding-top: 0;
77
+ }
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useId, useLayoutEffect, useRef, useState } from "react";
3
4
  import { ChevronRight } from "lucide-react";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { Icon, Shapes } from "lucide-react";
3
4
  import { useIconCatalog } from "./iconCatalog.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useCallback, useMemo, useRef, useState } from "react";
3
4
  import { ArrowLeft } from "lucide-react";
@@ -1,8 +1,10 @@
1
1
  import { type FieldOptions } from "./field";
2
- export declare function Checkbox({ label, checked, onChange, disabled, indeterminate, name, value, required, readOnly, id, error, hint, }: FieldOptions & {
2
+ import { type ComponentPropsWithRef } from "react";
3
+ export declare function Checkbox({ label, checked, onChange, disabled, indeterminate, name, value, required, readOnly, id, error, hint, inputProps, }: FieldOptions & {
3
4
  label: string;
4
- checked: boolean;
5
- onChange(value: boolean): void;
5
+ checked?: boolean;
6
+ onChange?(value: boolean): void;
7
+ inputProps?: Omit<ComponentPropsWithRef<"input">, "type">;
6
8
  disabled?: boolean;
7
9
  name?: string;
8
10
  value?: string;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { FieldLabel } from "./FieldLabel.js";
3
4
  import { useFieldControl } from "./field.js";
@@ -15,8 +16,10 @@ function Checkbox({
15
16
  readOnly,
16
17
  id,
17
18
  error,
18
- hint
19
+ hint,
20
+ inputProps
19
21
  }) {
22
+ const Label = label ? "label" : "span";
20
23
  const field = useFieldControl({
21
24
  id,
22
25
  name,
@@ -32,7 +35,7 @@ function Checkbox({
32
35
  if (ref.current) ref.current.indeterminate = indeterminate;
33
36
  }, [indeterminate]);
34
37
  return /* @__PURE__ */ jsxs(
35
- "label",
38
+ Label,
36
39
  {
37
40
  className: s.checkbox,
38
41
  "data-disabled": field.disabled,
@@ -41,10 +44,16 @@ function Checkbox({
41
44
  /* @__PURE__ */ jsx(
42
45
  "input",
43
46
  {
47
+ ...inputProps,
44
48
  id: field.id,
45
49
  "aria-invalid": field.invalid,
46
- "aria-describedby": field.descriptionId,
47
- ref,
50
+ "aria-describedby": [field.descriptionId, inputProps?.["aria-describedby"]].filter(Boolean).join(" ") || void 0,
51
+ ref: (node) => {
52
+ ref.current = node;
53
+ const external = inputProps?.ref;
54
+ if (typeof external === "function") return external(node);
55
+ if (external) external.current = node;
56
+ },
48
57
  "aria-checked": indeterminate ? "mixed" : checked,
49
58
  type: "checkbox",
50
59
  name: field.name,
@@ -53,7 +62,10 @@ function Checkbox({
53
62
  "aria-readonly": field.readOnly || void 0,
54
63
  checked,
55
64
  onChange: (e) => {
56
- if (!field.readOnly) onChange(e.target.checked);
65
+ if (!field.readOnly) {
66
+ inputProps?.onChange?.(e);
67
+ onChange?.(e.target.checked);
68
+ }
57
69
  },
58
70
  disabled: field.disabled
59
71
  }
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { fieldTriggerProps, useFieldControl } from "./field.js";
3
4
  import { useId } from "react";
@@ -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 { Input } from "./Input.js";
@@ -2,12 +2,14 @@ import { type FieldOptions } from "./field";
2
2
  import type { SelectOption } from "./types";
3
3
  export type ComboboxProps = FieldOptions & {
4
4
  value: string;
5
- onChange(value: string): void;
5
+ onChange(value: string, option?: SelectOption): void;
6
6
  options?: SelectOption[];
7
7
  loadOptions?(query: string, signal: AbortSignal): Promise<SelectOption[]>;
8
8
  onCreate?(label: string): string | void | Promise<string | void>;
9
9
  label?: string;
10
10
  placeholder?: string;
11
11
  mode?: "panel" | "input";
12
+ /** In input mode, keep typed text as the value without requiring a choice. */
13
+ allowCustomValue?: boolean;
12
14
  };
13
- export declare function Combobox({ value, onChange, options, loadOptions, onCreate, label, placeholder, mode, ...props }: ComboboxProps): import("react").JSX.Element;
15
+ export declare function Combobox({ value, onChange, options, loadOptions, onCreate, label, placeholder, mode, allowCustomValue, ...props }: ComboboxProps): import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useCallback,
@@ -31,13 +32,14 @@ function Combobox({
31
32
  label = "\u641C\u7D22\u9009\u62E9",
32
33
  placeholder = "\u8BF7\u9009\u62E9",
33
34
  mode = "panel",
35
+ allowCustomValue = false,
34
36
  ...props
35
37
  }) {
36
38
  const field = useFieldControl({ ...props, label }), anchor = useRef(null), list = useRef(null), id = useId();
37
39
  const [open, setOpen] = useState(false), [query, setQuery] = useState(""), [editing, setEditing] = useState(false), [remote, setRemote] = useState([]), [loading, setLoading] = useState(false), [error, setError] = useState(""), [failure, setFailure] = useState("load"), [active, setActive] = useState(-1), [created, setCreated] = useState(), [chosen, setChosen] = useState(), [creating, setCreating] = useState(false), [retry, setRetry] = useState(0);
38
40
  const generation = useRef(0), restoring = useRef(false), loader = useRef(loadOptions);
39
41
  loader.current = loadOptions;
40
- const inline = mode === "input", async = !!loadOptions;
42
+ const inline = mode === "input", freeText = inline && allowCustomValue, async = !!loadOptions;
41
43
  const close = useCallback(() => {
42
44
  generation.current++;
43
45
  setOpen(false);
@@ -95,7 +97,7 @@ function Combobox({
95
97
  const choose = (item) => {
96
98
  if (item.disabled || field.disabled || field.readOnly) return;
97
99
  setChosen(item);
98
- onChange(item.value);
100
+ onChange(item.value, item);
99
101
  close();
100
102
  anchor.current?.focus();
101
103
  };
@@ -114,6 +116,7 @@ function Combobox({
114
116
  generation.current++;
115
117
  setLoading(async);
116
118
  setQuery(text);
119
+ if (freeText) onChange(text);
117
120
  setEditing(true);
118
121
  setActive(inline ? -1 : 0);
119
122
  setError("");
@@ -122,7 +125,7 @@ function Combobox({
122
125
  useEffect(() => {
123
126
  list.current?.querySelector('[data-active="true"]')?.scrollIntoView({ block: "nearest" });
124
127
  }, [activeIndex, query, loading]);
125
- const canCreate = !!onCreate && !!query.trim() && !filtered.some(
128
+ const canCreate = !freeText && !!onCreate && !!query.trim() && !filtered.some(
126
129
  (item) => item.label.toLowerCase() === query.trim().toLowerCase()
127
130
  );
128
131
  const create = async () => {
@@ -171,6 +174,10 @@ function Combobox({
171
174
  }
172
175
  } else if (event.key === "Enter" && open) {
173
176
  event.preventDefault();
177
+ if (freeText && activeIndex < 0) {
178
+ close();
179
+ return;
180
+ }
174
181
  if (!loading && !creating && !error) {
175
182
  const item = filtered[activeIndex < 0 ? first : activeIndex];
176
183
  if (item) choose(item);
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useEffect,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useCallback,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { MenuItem } from "./MenuItem.js";
3
4
  import { menuSurfaceMotion, cancelMotion } from "./motion.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import {
3
4
  useCallback,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { memo } from "react";
3
4
  import { Tooltip } from "./Tooltip.js";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useEffect, useRef, useState } from "react";
2
3
  import { useToast } from "./ToastProvider.js";
3
4
  function CopyButton({
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useMemo, useState } from "react";
3
4
  import { ArrowDown, ArrowUp, ArrowUpDown } from "lucide-react";