@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.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -0
- package/components/Accordion.d.ts +1 -1
- package/components/Accordion.js +1 -0
- package/components/AccountItem.js +1 -0
- package/components/ActionSheet.js +1 -0
- package/components/Alert.js +1 -0
- package/components/AppShell.js +1 -0
- package/components/AppearanceSettings.js +1 -0
- package/components/AuthLayout.js +1 -0
- package/components/Avatar.js +1 -0
- package/components/AvatarGroup.js +1 -0
- package/components/Badge.js +1 -0
- package/components/Banner.d.ts +3 -3
- package/components/Banner.js +12 -4
- package/components/BarChart.js +1 -0
- package/components/BlockedTab.js +1 -0
- package/components/Breadcrumb.js +1 -0
- package/components/Button.d.ts +4 -2
- package/components/Button.js +24 -0
- package/components/Calendar.js +19 -13
- package/components/Card.d.ts +5 -4
- package/components/Card.js +8 -4
- package/components/Card.module.css +10 -0
- package/components/Cascader.js +1 -0
- package/components/CatalogIcon.js +1 -0
- package/components/CharacterPicker.js +1 -0
- package/components/Checkbox.d.ts +5 -3
- package/components/Checkbox.js +17 -5
- package/components/ColorField.js +1 -0
- package/components/ColorPicker.js +1 -0
- package/components/Combobox.d.ts +4 -2
- package/components/Combobox.js +10 -3
- package/components/CommandPalette.js +1 -0
- package/components/ContextMenu.js +1 -0
- package/components/ContextMenuPanel.js +1 -0
- package/components/ContributionCalendar.js +1 -0
- package/components/ContributionCell.js +1 -0
- package/components/CopyButton.js +1 -0
- package/components/DataTable.js +1 -0
- package/components/DatePicker.js +8 -4
- package/components/DateRangePicker.js +1 -0
- package/components/Descriptions.js +1 -0
- package/components/Dialog.d.ts +9 -3
- package/components/Dialog.js +33 -11
- package/components/DialogVariants.js +1 -0
- package/components/DisclosureChevron.js +1 -0
- package/components/Divider.js +1 -0
- package/components/Drawer.d.ts +5 -2
- package/components/Drawer.js +20 -5
- package/components/EmojiPicker.js +1 -0
- package/components/EmptyState.js +1 -0
- package/components/FieldLabel.d.ts +2 -1
- package/components/FieldLabel.js +1 -0
- package/components/FieldMessages.d.ts +3 -2
- package/components/FieldMessages.js +1 -0
- package/components/FileDropOverlay.js +1 -0
- package/components/FileDropZone.js +1 -0
- package/components/FilePicker.d.ts +3 -2
- package/components/FilePicker.js +21 -5
- package/components/FileSelectionFeedback.js +1 -0
- package/components/FileTree.js +1 -0
- package/components/Form.js +1 -0
- package/components/FormErrorSummary.js +1 -0
- package/components/FormField.js +1 -0
- package/components/FormGroup.js +1 -0
- package/components/FormLayout.js +1 -0
- package/components/IconButton.js +1 -0
- package/components/IconPicker.js +1 -0
- package/components/Indicator.js +1 -0
- package/components/Input.js +1 -0
- package/components/Layout.js +1 -0
- package/components/LoadingOverlay.js +1 -0
- package/components/LoadingState.js +1 -0
- package/components/Markdown.js +1 -0
- package/components/Menu.js +1 -0
- package/components/MenuItem.d.ts +8 -3
- package/components/MenuItem.js +24 -1
- package/components/MenuItemContent.js +1 -0
- package/components/MultiSelect.js +1 -0
- package/components/NavBar.d.ts +2 -1
- package/components/NavBar.js +3 -1
- package/components/NumberInput.js +1 -0
- package/components/Page.d.ts +2 -1
- package/components/Page.js +4 -2
- package/components/Page.module.css +9 -0
- package/components/Pagination.d.ts +4 -1
- package/components/Pagination.js +28 -14
- package/components/PasskeyItem.js +1 -0
- package/components/PasswordField.js +1 -0
- package/components/PinInput.js +1 -0
- package/components/Placeholder.js +1 -0
- package/components/Popconfirm.js +1 -0
- package/components/Popover.d.ts +3 -2
- package/components/Popover.js +9 -2
- package/components/Progress.js +1 -0
- package/components/RadioGroup.js +1 -0
- package/components/RangeSlider.js +1 -0
- package/components/ResizablePanel.js +1 -0
- package/components/ResourceCard.js +1 -0
- package/components/SearchField.js +1 -0
- package/components/Section.js +1 -0
- package/components/Segmented.d.ts +1 -0
- package/components/Segmented.js +32 -20
- package/components/Select.d.ts +3 -1
- package/components/Select.js +12 -2
- package/components/SelectOptionContent.js +1 -0
- package/components/SelectSettingRow.js +1 -0
- package/components/SelectTrigger.js +1 -0
- package/components/SelectionTag.js +1 -0
- package/components/SessionItem.js +1 -0
- package/components/SettingRow.d.ts +3 -2
- package/components/SettingRow.js +9 -2
- package/components/SettingsLayout.js +1 -0
- package/components/ShortcutInput.js +1 -0
- package/components/SideBar.js +1 -0
- package/components/SidebarNavigation.js +1 -0
- package/components/Skeleton.js +1 -0
- package/components/SkeletonRows.js +1 -0
- package/components/SkinTonePicker.js +1 -0
- package/components/Slider.js +1 -0
- package/components/Spinner.js +1 -0
- package/components/SplitButton.js +1 -0
- package/components/Statistic.js +1 -0
- package/components/Steps.js +1 -0
- package/components/Switch.d.ts +5 -0
- package/components/Switch.js +26 -2
- package/components/Switch.module.css +101 -59
- package/components/SwitchSettingRow.js +1 -0
- package/components/SymbolPicker.js +1 -0
- package/components/TabList.js +1 -0
- package/components/Table.js +1 -0
- package/components/TableColumnFilter.js +1 -0
- package/components/TableColumnVisibility.js +1 -0
- package/components/TableMarkup.d.ts +2 -2
- package/components/TableMarkup.js +5 -2
- package/components/TableOfContents.js +1 -0
- package/components/Tabs.js +1 -0
- package/components/TagInput.js +1 -0
- package/components/TextAreaSettingRow.js +1 -0
- package/components/TextSettingRow.js +1 -0
- package/components/Textarea.js +1 -0
- package/components/ThemePicker.js +1 -0
- package/components/ThemeProvider.js +1 -0
- package/components/ThemeStylePicker.js +1 -0
- package/components/TimeColumns.js +8 -1
- package/components/Timeline.js +1 -0
- package/components/Toast.js +4 -1
- package/components/ToastProvider.js +1 -0
- package/components/Tooltip.js +7 -3
- package/components/TreeGuides.js +1 -0
- package/components/TreeSelect.js +1 -0
- package/components/TreeTable.js +1 -0
- package/components/UIProvider.d.ts +1 -0
- package/components/UIProvider.js +2 -0
- package/components/UnderlinedTab.js +1 -0
- package/components/Upload.js +1 -0
- package/components/UploadList.js +1 -0
- package/components/UploadListItem.js +1 -0
- package/components/UptimeChart.js +1 -0
- package/components/VirtualPickerList.js +1 -0
- package/components/appearance.js +1 -0
- package/components/calendarNow.js +1 -0
- package/components/characterCatalog.js +1 -0
- package/components/color.js +1 -0
- package/components/contribution.js +1 -0
- package/components/createToaster.js +1 -0
- package/components/dateConstraints.js +1 -0
- package/components/field.d.ts +7 -7
- package/components/field.js +3 -2
- package/components/fileSelection.js +1 -0
- package/components/hierarchy.js +1 -0
- package/components/iconCatalog.js +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +3 -0
- package/components/menuFocus.js +1 -0
- package/components/menuPointer.js +1 -0
- package/components/menuTypes.js +1 -0
- package/components/motion.js +1 -0
- package/components/rangeMath.js +1 -0
- package/components/settingRowControl.js +1 -0
- package/components/surfacePortal.js +1 -0
- package/components/tooltipState.js +1 -0
- package/components/types.js +1 -0
- package/components/uploadTypes.js +1 -0
- package/components/useFormState.js +1 -0
- package/components/useHierarchy.js +1 -0
- package/components/useMenuLayers.js +1 -0
- package/components/useModalFocus.d.ts +1 -1
- package/components/useModalFocus.js +9 -3
- package/components/useModalScrollLock.js +1 -0
- package/components/usePopover.js +1 -0
- package/components/usePortalRoot.d.ts +2 -0
- package/components/usePortalRoot.js +12 -0
- package/components/useTabIndicator.js +1 -0
- package/components/useUIText.d.ts +5 -0
- package/components/useUIText.js +14 -0
- package/components/useUploadQueue.js +1 -0
- 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 起提供。
|
package/components/Accordion.js
CHANGED
package/components/Alert.js
CHANGED
package/components/AppShell.js
CHANGED
package/components/AuthLayout.js
CHANGED
package/components/Avatar.js
CHANGED
package/components/Badge.js
CHANGED
package/components/Banner.d.ts
CHANGED
|
@@ -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;
|
package/components/Banner.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
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
|
|
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 }),
|
package/components/BarChart.js
CHANGED
package/components/BlockedTab.js
CHANGED
package/components/Breadcrumb.js
CHANGED
package/components/Button.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type
|
|
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 {};
|
package/components/Button.js
CHANGED
|
@@ -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;
|
package/components/Calendar.js
CHANGED
|
@@ -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__ */
|
|
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
|
-
|
|
114
|
-
|
|
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" :
|
|
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 :
|
|
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
|
);
|
package/components/Card.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
export declare function Card({ title, description, action, children, className, onClick, }: {
|
|
3
|
-
title?:
|
|
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
|
-
|
|
8
|
+
bodyClassName?: string;
|
|
9
|
+
padding?: "normal" | "compact" | "none";
|
|
9
10
|
}): import("react").JSX.Element;
|
package/components/Card.js
CHANGED
|
@@ -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
|
|
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
|
package/components/Cascader.js
CHANGED
package/components/Checkbox.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type FieldOptions } from "./field";
|
|
2
|
-
|
|
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
|
|
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;
|
package/components/Checkbox.js
CHANGED
|
@@ -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
|
-
|
|
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)
|
|
65
|
+
if (!field.readOnly) {
|
|
66
|
+
inputProps?.onChange?.(e);
|
|
67
|
+
onChange?.(e.target.checked);
|
|
68
|
+
}
|
|
57
69
|
},
|
|
58
70
|
disabled: field.disabled
|
|
59
71
|
}
|
package/components/ColorField.js
CHANGED
package/components/Combobox.d.ts
CHANGED
|
@@ -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;
|
package/components/Combobox.js
CHANGED
|
@@ -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);
|
package/components/CopyButton.js
CHANGED
package/components/DataTable.js
CHANGED