@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/components/NavBar.js
CHANGED
|
@@ -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 { ChevronDown, Menu as MenuIcon } from "lucide-react";
|
|
@@ -14,6 +15,7 @@ function follow(event, path, onNavigate) {
|
|
|
14
15
|
onNavigate(path);
|
|
15
16
|
}
|
|
16
17
|
function NavBar({
|
|
18
|
+
as: Root = "header",
|
|
17
19
|
items,
|
|
18
20
|
active,
|
|
19
21
|
onNavigate,
|
|
@@ -24,7 +26,7 @@ function NavBar({
|
|
|
24
26
|
className = ""
|
|
25
27
|
}) {
|
|
26
28
|
const [mobile, setMobile] = useState(false);
|
|
27
|
-
return /* @__PURE__ */ jsxs(
|
|
29
|
+
return /* @__PURE__ */ jsxs(Root, { className: `${s.bar} ${className}`, children: [
|
|
28
30
|
brand && /* @__PURE__ */ jsx(
|
|
29
31
|
"a",
|
|
30
32
|
{
|
package/components/Page.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
export declare function PageHeading({ title, description, actions, titleExtra, }: {
|
|
2
|
+
export declare function PageHeading({ title, description, actions, titleExtra, compact, }: {
|
|
3
3
|
title?: ReactNode;
|
|
4
4
|
description?: string;
|
|
5
5
|
actions?: ReactNode;
|
|
6
6
|
titleExtra?: ReactNode;
|
|
7
|
+
compact?: boolean;
|
|
7
8
|
}): import("react").JSX.Element | null;
|
|
8
9
|
export declare function Page({ title, description, actions, children, }: {
|
|
9
10
|
title?: ReactNode;
|
package/components/Page.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import s from "./Page.module.css";
|
|
3
4
|
function PageHeading({
|
|
4
5
|
title,
|
|
5
6
|
description,
|
|
6
7
|
actions,
|
|
7
|
-
titleExtra
|
|
8
|
+
titleExtra,
|
|
9
|
+
compact = false
|
|
8
10
|
}) {
|
|
9
11
|
if (!title && !description && !actions && !titleExtra) return null;
|
|
10
|
-
return /* @__PURE__ */ jsxs("header", { className: s.heading
|
|
12
|
+
return /* @__PURE__ */ jsxs("header", { className: `${s.heading} ${compact ? s.compact : ""}`, children: [
|
|
11
13
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
12
14
|
/* @__PURE__ */ jsxs("div", { className: s.title, children: [
|
|
13
15
|
title && /* @__PURE__ */ jsx("h1", { children: title }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
export declare function Pagination({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizes, summary, resetPageOnSizeChange, compact, size: controlSize, className, showSummary, }: {
|
|
2
|
+
export declare function Pagination({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizes, summary, resetPageOnSizeChange, compact, size: controlSize, className, showSummary, label, previousLabel, nextLabel, }: {
|
|
3
3
|
page: number;
|
|
4
4
|
pageSize: number;
|
|
5
5
|
total: number;
|
|
@@ -13,4 +13,7 @@ export declare function Pagination({ page, pageSize, total, onPageChange, onPage
|
|
|
13
13
|
size?: "default" | "small";
|
|
14
14
|
className?: string;
|
|
15
15
|
showSummary?: boolean;
|
|
16
|
+
label?: string;
|
|
17
|
+
previousLabel?: string;
|
|
18
|
+
nextLabel?: string;
|
|
16
19
|
}): import("react").JSX.Element;
|
package/components/Pagination.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useEffect, useId, useState } from "react";
|
|
3
4
|
import {
|
|
@@ -10,6 +11,7 @@ import { Button } from "./Button.js";
|
|
|
10
11
|
import { Select } from "./Select.js";
|
|
11
12
|
import control from "./Control.module.css";
|
|
12
13
|
import s from "./Pagination.module.css";
|
|
14
|
+
import { useUIText } from "./useUIText.js";
|
|
13
15
|
function Pagination({
|
|
14
16
|
page,
|
|
15
17
|
pageSize,
|
|
@@ -22,8 +24,12 @@ function Pagination({
|
|
|
22
24
|
compact = false,
|
|
23
25
|
size: controlSize = "default",
|
|
24
26
|
className = "",
|
|
25
|
-
showSummary = true
|
|
27
|
+
showSummary = true,
|
|
28
|
+
label,
|
|
29
|
+
previousLabel,
|
|
30
|
+
nextLabel
|
|
26
31
|
}) {
|
|
32
|
+
const { text, english } = useUIText();
|
|
27
33
|
const size = Math.max(1, pageSize), pages = Math.max(1, Math.ceil(total / size)), current = Math.min(pages, Math.max(1, page)), id = useId(), [draft, setDraft] = useState(String(current));
|
|
28
34
|
useEffect(() => setDraft(String(current)), [current]);
|
|
29
35
|
const jump = () => {
|
|
@@ -49,27 +55,31 @@ function Pagination({
|
|
|
49
55
|
"nav",
|
|
50
56
|
{
|
|
51
57
|
className: `${s.pagination} ${compact ? s.compact : ""} ${controlSize === "small" ? s.small : ""} ${className}`,
|
|
52
|
-
"aria-label": "\u5206\u9875",
|
|
58
|
+
"aria-label": label ?? text("\u5206\u9875", "Pages", "\u5206\u9801"),
|
|
53
59
|
children: [
|
|
54
60
|
showSummary && /* @__PURE__ */ jsxs("span", { className: s.summary, children: [
|
|
55
61
|
total ? (current - 1) * size + 1 + "\u2013" + Math.min(current * size, total) : 0,
|
|
56
62
|
" ",
|
|
57
63
|
"/ ",
|
|
58
64
|
total,
|
|
59
|
-
"
|
|
65
|
+
" ",
|
|
66
|
+
text("\u9879", "items", "\u9805"),
|
|
60
67
|
summary
|
|
61
68
|
] }),
|
|
62
69
|
/* @__PURE__ */ jsxs("div", { className: s.controls, children: [
|
|
63
70
|
onPageSizeChange && /* @__PURE__ */ jsx(
|
|
64
71
|
Select,
|
|
65
72
|
{
|
|
66
|
-
label: "\u6BCF\u9875\u6761\u6570",
|
|
73
|
+
label: text("\u6BCF\u9875\u6761\u6570", "Page size", "\u6BCF\u9801\u7B46\u6578"),
|
|
67
74
|
value: String(size),
|
|
68
75
|
onChange: (v) => {
|
|
69
76
|
onPageSizeChange(Number(v));
|
|
70
77
|
if (resetPageOnSizeChange) onPageChange(1);
|
|
71
78
|
},
|
|
72
|
-
options: [.../* @__PURE__ */ new Set([...pageSizes, size])].sort((a, b) => a - b).map((n) => ({
|
|
79
|
+
options: [.../* @__PURE__ */ new Set([...pageSizes, size])].sort((a, b) => a - b).map((n) => ({
|
|
80
|
+
value: String(n),
|
|
81
|
+
label: n + text(" / \u9875", " / page", " / \u9801")
|
|
82
|
+
}))
|
|
73
83
|
}
|
|
74
84
|
),
|
|
75
85
|
/* @__PURE__ */ jsxs("div", { className: s.pages, children: [
|
|
@@ -77,7 +87,7 @@ function Pagination({
|
|
|
77
87
|
Button,
|
|
78
88
|
{
|
|
79
89
|
className: s.arrow,
|
|
80
|
-
"aria-label": "\u7B2C\u4E00\u9875",
|
|
90
|
+
"aria-label": text("\u7B2C\u4E00\u9875", "First page", "\u7B2C\u4E00\u9801"),
|
|
81
91
|
disabled: current === 1,
|
|
82
92
|
onClick: () => onPageChange(1),
|
|
83
93
|
children: /* @__PURE__ */ jsx(ChevronsLeft, {})
|
|
@@ -87,7 +97,7 @@ function Pagination({
|
|
|
87
97
|
Button,
|
|
88
98
|
{
|
|
89
99
|
className: s.arrow,
|
|
90
|
-
"aria-label": "\u4E0A\u4E00\u9875",
|
|
100
|
+
"aria-label": previousLabel ?? text("\u4E0A\u4E00\u9875", "Previous", "\u4E0A\u4E00\u9801"),
|
|
91
101
|
disabled: current === 1,
|
|
92
102
|
onClick: () => onPageChange(current - 1),
|
|
93
103
|
children: /* @__PURE__ */ jsx(ChevronLeft, {})
|
|
@@ -99,7 +109,7 @@ function Pagination({
|
|
|
99
109
|
Button,
|
|
100
110
|
{
|
|
101
111
|
className: s.page,
|
|
102
|
-
"aria-label": "\u7B2C " + n + " \u9875",
|
|
112
|
+
"aria-label": english ? "Page " + n : "\u7B2C " + n + text(" \u9875", "", " \u9801"),
|
|
103
113
|
"aria-current": n === current ? "page" : void 0,
|
|
104
114
|
variant: n === current ? "primary" : "ghost",
|
|
105
115
|
onClick: () => onPageChange(n),
|
|
@@ -111,7 +121,7 @@ function Pagination({
|
|
|
111
121
|
Button,
|
|
112
122
|
{
|
|
113
123
|
className: s.arrow,
|
|
114
|
-
"aria-label": "\u4E0B\u4E00\u9875",
|
|
124
|
+
"aria-label": nextLabel ?? text("\u4E0B\u4E00\u9875", "Next", "\u4E0B\u4E00\u9801"),
|
|
115
125
|
disabled: current === pages,
|
|
116
126
|
onClick: () => onPageChange(current + 1),
|
|
117
127
|
children: /* @__PURE__ */ jsx(ChevronRight, {})
|
|
@@ -121,7 +131,7 @@ function Pagination({
|
|
|
121
131
|
Button,
|
|
122
132
|
{
|
|
123
133
|
className: s.arrow,
|
|
124
|
-
"aria-label": "\u6700\u540E\u4E00\u9875",
|
|
134
|
+
"aria-label": text("\u6700\u540E\u4E00\u9875", "Last page", "\u6700\u5F8C\u4E00\u9801"),
|
|
125
135
|
disabled: current === pages,
|
|
126
136
|
onClick: () => onPageChange(pages),
|
|
127
137
|
children: /* @__PURE__ */ jsx(ChevronsRight, {})
|
|
@@ -137,14 +147,18 @@ function Pagination({
|
|
|
137
147
|
jump();
|
|
138
148
|
},
|
|
139
149
|
children: [
|
|
140
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "\u8DF3\u81F3" }),
|
|
150
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, children: text("\u8DF3\u81F3", "Go to") }),
|
|
141
151
|
/* @__PURE__ */ jsx(
|
|
142
152
|
"input",
|
|
143
153
|
{
|
|
144
154
|
id,
|
|
145
155
|
className: control.surface,
|
|
146
|
-
"aria-label": "\u8DF3\u8F6C\u9875\u7801",
|
|
147
|
-
"aria-description":
|
|
156
|
+
"aria-label": text("\u8DF3\u8F6C\u9875\u7801", "Page number", "\u8DF3\u8F49\u9801\u78BC"),
|
|
157
|
+
"aria-description": text(
|
|
158
|
+
"\u8F93\u5165\u9875\u7801\u540E\u6309\u56DE\u8F66\u786E\u8BA4",
|
|
159
|
+
"Enter a page number and press Enter",
|
|
160
|
+
"\u8F38\u5165\u9801\u78BC\u5F8C\u6309 Enter \u78BA\u8A8D"
|
|
161
|
+
),
|
|
148
162
|
inputMode: "numeric",
|
|
149
163
|
value: draft,
|
|
150
164
|
onChange: (e) => setDraft(e.target.value),
|
|
@@ -157,7 +171,7 @@ function Pagination({
|
|
|
157
171
|
}
|
|
158
172
|
}
|
|
159
173
|
),
|
|
160
|
-
/* @__PURE__ */ jsx("span", { children: "\u9875" })
|
|
174
|
+
/* @__PURE__ */ jsx("span", { children: text("\u9875", "", "\u9801") })
|
|
161
175
|
]
|
|
162
176
|
}
|
|
163
177
|
)
|
package/components/PinInput.js
CHANGED
package/components/Popconfirm.js
CHANGED
package/components/Popover.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode, type RefObject } from "react";
|
|
2
2
|
import { type MenuSide } from "./motion";
|
|
3
|
-
export declare function Popover({ open: requestedOpen, onClose, anchor, children, width, maxHeight, scrollable, side, align, label, role, id, onKeyDown, descriptionId, autoFocus, matchAnchorWidth, className, }: {
|
|
3
|
+
export declare function Popover({ open: requestedOpen, onClose, anchor, children, width, maxHeight, scrollable, side, align, label, role, id, onKeyDown, descriptionId, autoFocus, matchAnchorWidth, className, portalContainer, }: {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onClose(): void;
|
|
6
6
|
anchor: RefObject<HTMLElement | null>;
|
|
@@ -20,4 +20,5 @@ export declare function Popover({ open: requestedOpen, onClose, anchor, children
|
|
|
20
20
|
autoFocus?: boolean;
|
|
21
21
|
matchAnchorWidth?: boolean;
|
|
22
22
|
className?: string;
|
|
23
|
-
|
|
23
|
+
portalContainer?: HTMLElement | null;
|
|
24
|
+
}): import("react").ReactPortal | null;
|
package/components/Popover.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { usePortalRoot } from "./usePortalRoot.js";
|
|
2
4
|
import { FieldContext } from "./field.js";
|
|
3
5
|
import {
|
|
4
6
|
useLayoutEffect,
|
|
@@ -26,9 +28,11 @@ function Popover({
|
|
|
26
28
|
descriptionId,
|
|
27
29
|
autoFocus = true,
|
|
28
30
|
matchAnchorWidth = false,
|
|
29
|
-
className = ""
|
|
31
|
+
className = "",
|
|
32
|
+
portalContainer
|
|
30
33
|
}) {
|
|
31
|
-
const
|
|
34
|
+
const root = usePortalRoot();
|
|
35
|
+
const owner = useSurfacePortal(), portalHost = portalContainer || owner?.host || root, open = requestedOpen && owner?.active !== false;
|
|
32
36
|
const ref = useRef(null), close = useRef(onClose);
|
|
33
37
|
close.current = onClose;
|
|
34
38
|
const opened = useRef(open);
|
|
@@ -38,10 +42,12 @@ function Popover({
|
|
|
38
42
|
}, [requestedOpen, owner?.active]);
|
|
39
43
|
useEffect(() => {
|
|
40
44
|
const node = ref.current;
|
|
45
|
+
if (!node) return;
|
|
41
46
|
return () => cancelMotion(node);
|
|
42
47
|
}, [portalHost]);
|
|
43
48
|
useLayoutEffect(() => {
|
|
44
49
|
const surface = ref.current, trigger = anchor.current;
|
|
50
|
+
if (!surface) return;
|
|
45
51
|
if (!open) {
|
|
46
52
|
if (!surface.matches(":popover-open")) return;
|
|
47
53
|
surface.inert = true;
|
|
@@ -160,6 +166,7 @@ function Popover({
|
|
|
160
166
|
side,
|
|
161
167
|
align
|
|
162
168
|
]);
|
|
169
|
+
if (!portalHost) return null;
|
|
163
170
|
return createPortal(
|
|
164
171
|
/* @__PURE__ */ jsx(
|
|
165
172
|
"div",
|
package/components/Progress.js
CHANGED
package/components/RadioGroup.js
CHANGED
package/components/Section.js
CHANGED
package/components/Segmented.js
CHANGED
|
@@ -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 "./Segmented.module.css";
|
|
@@ -52,26 +53,37 @@ function Segmented({
|
|
|
52
53
|
onChange(enabled[target].value);
|
|
53
54
|
buttons.current.get(enabled[target].value)?.focus();
|
|
54
55
|
};
|
|
55
|
-
return /* @__PURE__ */ jsxs(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
ref: root,
|
|
60
|
+
className: s.segmented,
|
|
61
|
+
"data-full-width": fullWidth || void 0,
|
|
62
|
+
role: "group",
|
|
63
|
+
"aria-label": label,
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx("span", { className: s.indicator, "aria-hidden": "true", "data-segment-indicator": true }),
|
|
66
|
+
options.map((option, index) => /* @__PURE__ */ jsx(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
type: "button",
|
|
70
|
+
ref: (node) => {
|
|
71
|
+
if (node) buttons.current.set(option.value, node);
|
|
72
|
+
else buttons.current.delete(option.value);
|
|
73
|
+
},
|
|
74
|
+
"aria-label": option.textValue,
|
|
75
|
+
"aria-pressed": value === option.value,
|
|
76
|
+
disabled: option.disabled,
|
|
77
|
+
tabIndex: (options.some((item) => item.value === value && !item.disabled) ? value === option.value : option === options.find((item) => !item.disabled)) ? 0 : -1,
|
|
78
|
+
onKeyDown: (event) => keyboard(event, index),
|
|
79
|
+
onClick: () => onChange(option.value),
|
|
80
|
+
children: option.label
|
|
81
|
+
},
|
|
82
|
+
option.value
|
|
83
|
+
))
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
75
87
|
}
|
|
76
88
|
export {
|
|
77
89
|
Segmented
|
package/components/Select.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FieldOptions } from "./field";
|
|
2
2
|
import type { SelectOption } from "./types";
|
|
3
|
-
export declare function Select({ value, onChange, options, label, disabled, id: controlId, name, required, readOnly, error, hint, placeholder, emptyText, ...aria }: FieldOptions & {
|
|
3
|
+
export declare function Select({ value, onChange, options, label, disabled, id: controlId, name, required, readOnly, error, hint, placeholder, emptyText, portalContainer, onCloseAutoFocus, ...aria }: FieldOptions & {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange(value: string): void;
|
|
6
6
|
options: SelectOption[];
|
|
@@ -8,4 +8,6 @@ export declare function Select({ value, onChange, options, label, disabled, id:
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
emptyText?: string;
|
|
11
|
+
portalContainer?: HTMLElement | null;
|
|
12
|
+
onCloseAutoFocus?(event: Event): void;
|
|
11
13
|
}): import("react").JSX.Element;
|
package/components/Select.js
CHANGED
|
@@ -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 { MenuItem } from "./MenuItem.js";
|
|
@@ -20,6 +21,8 @@ function Select({
|
|
|
20
21
|
hint,
|
|
21
22
|
placeholder = "\u8BF7\u9009\u62E9",
|
|
22
23
|
emptyText = "\u6CA1\u6709\u53EF\u7528\u9009\u9879",
|
|
24
|
+
portalContainer,
|
|
25
|
+
onCloseAutoFocus,
|
|
23
26
|
...aria
|
|
24
27
|
}) {
|
|
25
28
|
const field = useFieldControl({
|
|
@@ -34,6 +37,12 @@ function Select({
|
|
|
34
37
|
...aria
|
|
35
38
|
});
|
|
36
39
|
const pop = usePopover(field.disabled || field.readOnly), ref = pop.anchor, open = pop.open, [active, setActive] = useState(0), id = useId();
|
|
40
|
+
const close = () => {
|
|
41
|
+
pop.close();
|
|
42
|
+
const event = new Event("closeAutoFocus", { cancelable: true });
|
|
43
|
+
onCloseAutoFocus?.(event);
|
|
44
|
+
if (!event.defaultPrevented) ref.current?.focus({ preventScroll: true });
|
|
45
|
+
};
|
|
37
46
|
const reserveIcon = options.some((option) => !!option.icon);
|
|
38
47
|
const selected = options.findIndex((v) => v.value === value);
|
|
39
48
|
const show = () => {
|
|
@@ -45,7 +54,7 @@ function Select({
|
|
|
45
54
|
const choose = (index) => {
|
|
46
55
|
if (!field.disabled && !field.readOnly && options[index] && !options[index].disabled) {
|
|
47
56
|
onChange(options[index].value);
|
|
48
|
-
|
|
57
|
+
close();
|
|
49
58
|
}
|
|
50
59
|
};
|
|
51
60
|
const move = (delta) => {
|
|
@@ -128,7 +137,8 @@ function Select({
|
|
|
128
137
|
{
|
|
129
138
|
id,
|
|
130
139
|
open,
|
|
131
|
-
onClose:
|
|
140
|
+
onClose: close,
|
|
141
|
+
portalContainer,
|
|
132
142
|
anchor: ref,
|
|
133
143
|
width: Math.max(
|
|
134
144
|
options.some((option) => option.description || option.shortcut) ? 280 : 200,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
export type SettingRowProps = {
|
|
3
3
|
title: string;
|
|
4
|
+
className?: string;
|
|
4
5
|
description?: string;
|
|
5
6
|
children: ReactNode;
|
|
6
7
|
divider?: boolean;
|
|
@@ -10,4 +11,4 @@ export type SettingRowProps = {
|
|
|
10
11
|
controlId?: string;
|
|
11
12
|
descriptionId?: string;
|
|
12
13
|
};
|
|
13
|
-
export declare function SettingRow({ title, description, children, divider, titleBold, align, controlWidth, controlId, descriptionId, }: SettingRowProps): import("react").JSX.Element;
|
|
14
|
+
export declare function SettingRow({ title, className, description, children, divider, titleBold, align, controlWidth, controlId, descriptionId, }: SettingRowProps): import("react").JSX.Element;
|
package/components/SettingRow.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
2
4
|
import s from "./SettingRow.module.css";
|
|
3
5
|
function SettingRow({
|
|
4
6
|
title,
|
|
7
|
+
className = "",
|
|
5
8
|
description,
|
|
6
9
|
children,
|
|
7
10
|
divider = true,
|
|
@@ -11,17 +14,21 @@ function SettingRow({
|
|
|
11
14
|
controlId,
|
|
12
15
|
descriptionId
|
|
13
16
|
}) {
|
|
17
|
+
const titleId = useId();
|
|
14
18
|
return /* @__PURE__ */ jsxs(
|
|
15
19
|
"div",
|
|
16
20
|
{
|
|
17
|
-
className: s.settingRow
|
|
21
|
+
className: `${s.settingRow} ${className}`,
|
|
22
|
+
role: controlId ? void 0 : "group",
|
|
23
|
+
"aria-labelledby": controlId ? void 0 : titleId,
|
|
24
|
+
"aria-describedby": !controlId && description ? descriptionId : void 0,
|
|
18
25
|
"data-divider": divider,
|
|
19
26
|
"data-title-bold": titleBold,
|
|
20
27
|
"data-align": align,
|
|
21
28
|
"data-sized": controlWidth !== void 0,
|
|
22
29
|
children: [
|
|
23
30
|
/* @__PURE__ */ jsxs("div", { className: s.settingCopy, children: [
|
|
24
|
-
/* @__PURE__ */ jsx("h3", { children: controlId ? /* @__PURE__ */ jsx("label", { htmlFor: controlId, children: title }) : title }),
|
|
31
|
+
/* @__PURE__ */ jsx("h3", { id: titleId, children: controlId ? /* @__PURE__ */ jsx("label", { htmlFor: controlId, children: title }) : title }),
|
|
25
32
|
description && /* @__PURE__ */ jsx("p", { id: descriptionId, children: description })
|
|
26
33
|
] }),
|
|
27
34
|
/* @__PURE__ */ jsx(
|
package/components/SideBar.js
CHANGED
package/components/Skeleton.js
CHANGED
package/components/Slider.js
CHANGED
package/components/Spinner.js
CHANGED
package/components/Statistic.js
CHANGED