@godxjp/ui 20.0.0 → 20.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/app/app-provider.js +37 -21
- package/dist/app/index.d.ts +2 -0
- package/dist/app/index.js +2 -0
- package/dist/app/storage.d.ts +17 -0
- package/dist/app/storage.js +28 -0
- package/dist/app/theme-axes.d.ts +2 -0
- package/dist/app/theme-axes.js +45 -0
- package/dist/components/charts/chart-cartesian.d.ts +2 -1
- package/dist/components/charts/chart-cartesian.js +52 -3
- package/dist/components/charts/chart-category-axis.d.ts +55 -0
- package/dist/components/charts/chart-category-axis.js +93 -0
- package/dist/components/charts/chart-frame.d.ts +10 -1
- package/dist/components/charts/chart-frame.js +19 -3
- package/dist/components/charts/compact-bar-trend.d.ts +1 -1
- package/dist/components/charts/compact-bar-trend.js +2 -0
- package/dist/components/charts/pie-chart.d.ts +1 -1
- package/dist/components/charts/pie-chart.js +12 -1
- package/dist/components/charts/recharts-peer.d.ts +49 -0
- package/dist/components/charts/recharts-peer.js +45 -0
- package/dist/components/data-display/card.d.ts +12 -1
- package/dist/components/data-display/card.js +22 -4
- package/dist/components/data-display/code-block.js +6 -2
- package/dist/components/data-display/data-table.d.ts +39 -4
- package/dist/components/data-display/data-table.js +802 -270
- package/dist/components/data-display/descriptions.d.ts +27 -6
- package/dist/components/data-display/descriptions.js +58 -17
- package/dist/components/data-display/index.d.ts +2 -0
- package/dist/components/data-display/index.js +2 -0
- package/dist/components/data-display/list-row.d.ts +10 -1
- package/dist/components/data-display/list-row.js +7 -1
- package/dist/components/data-display/popover.d.ts +9 -3
- package/dist/components/data-display/popover.js +65 -11
- package/dist/components/data-display/range-timeline.d.ts +38 -0
- package/dist/components/data-display/range-timeline.js +161 -0
- package/dist/components/data-display/scroll-area.js +13 -2
- package/dist/components/data-display/service-launcher-card.js +14 -12
- package/dist/components/data-display/table.d.ts +71 -3
- package/dist/components/data-display/table.js +56 -18
- package/dist/components/data-display/tree-list.js +4 -9
- package/dist/components/data-entry/calendar.d.ts +2 -2
- package/dist/components/data-entry/calendar.js +23 -3
- package/dist/components/data-entry/cascader.d.ts +1 -1
- package/dist/components/data-entry/cascader.js +188 -24
- package/dist/components/data-entry/color-picker.d.ts +1 -1
- package/dist/components/data-entry/color-picker.js +17 -5
- package/dist/components/data-entry/control-appearance.d.ts +64 -0
- package/dist/components/data-entry/control-appearance.js +39 -0
- package/dist/components/data-entry/control-surface.d.ts +61 -0
- package/dist/components/data-entry/control-surface.js +39 -0
- package/dist/components/data-entry/date-picker.d.ts +1 -1
- package/dist/components/data-entry/date-picker.js +344 -113
- package/dist/components/data-entry/date-range-picker.d.ts +1 -1
- package/dist/components/data-entry/date-range-picker.js +278 -140
- package/dist/components/data-entry/form-field.d.ts +1 -1
- package/dist/components/data-entry/form-field.js +39 -4
- package/dist/components/data-entry/form.d.ts +4 -0
- package/dist/components/data-entry/form.js +4 -2
- package/dist/components/data-entry/index.d.ts +7 -3
- package/dist/components/data-entry/index.js +10 -1
- package/dist/components/data-entry/input-otp.d.ts +1 -1
- package/dist/components/data-entry/input.d.ts +12 -34
- package/dist/components/data-entry/input.js +92 -24
- package/dist/components/data-entry/month-picker.d.ts +1 -1
- package/dist/components/data-entry/month-picker.js +47 -10
- package/dist/components/data-entry/month-range-picker.d.ts +1 -1
- package/dist/components/data-entry/month-range-picker.js +51 -11
- package/dist/components/data-entry/number-input.d.ts +7 -0
- package/dist/components/data-entry/number-input.js +147 -98
- package/dist/components/data-entry/password-input.d.ts +1 -1
- package/dist/components/data-entry/radio.d.ts +1 -1
- package/dist/components/data-entry/radio.js +61 -13
- package/dist/components/data-entry/search-input.d.ts +1 -1
- package/dist/components/data-entry/search-input.js +16 -2
- package/dist/components/data-entry/search-select.d.ts +2 -2
- package/dist/components/data-entry/search-select.js +209 -78
- package/dist/components/data-entry/select.d.ts +22 -4
- package/dist/components/data-entry/select.js +215 -163
- package/dist/components/data-entry/slider.d.ts +9 -1
- package/dist/components/data-entry/slider.js +87 -9
- package/dist/components/data-entry/switch.d.ts +3 -0
- package/dist/components/data-entry/switch.js +29 -3
- package/dist/components/data-entry/textarea.d.ts +14 -56
- package/dist/components/data-entry/textarea.js +80 -33
- package/dist/components/data-entry/time-picker.d.ts +2 -2
- package/dist/components/data-entry/time-picker.js +333 -109
- package/dist/components/data-entry/time-range-picker.d.ts +5 -0
- package/dist/components/data-entry/time-range-picker.js +89 -0
- package/dist/components/data-entry/transfer.d.ts +1 -1
- package/dist/components/data-entry/transfer.js +86 -28
- package/dist/components/data-entry/tree-select.d.ts +1 -1
- package/dist/components/data-entry/tree-select.js +201 -113
- package/dist/components/data-entry/tree-utils.js +7 -14
- package/dist/components/data-entry/upload-files.d.ts +2 -0
- package/dist/components/data-entry/upload-files.js +31 -0
- package/dist/components/data-entry/upload-request.d.ts +4 -0
- package/dist/components/data-entry/upload-request.js +53 -0
- package/dist/components/data-entry/upload-types.d.ts +28 -0
- package/dist/components/data-entry/upload-types.js +2 -0
- package/dist/components/data-entry/upload.d.ts +2 -2
- package/dist/components/data-entry/upload.js +475 -115
- package/dist/components/feedback/dialog.js +19 -19
- package/dist/components/feedback/sheet.js +3 -0
- package/dist/components/feedback/tooltip.js +3 -0
- package/dist/components/general/button.d.ts +2 -1
- package/dist/components/general/button.js +7 -1
- package/dist/components/general/index.d.ts +1 -0
- package/dist/components/general/index.js +2 -0
- package/dist/components/general/typography.d.ts +3 -0
- package/dist/components/general/typography.js +15 -1
- package/dist/components/general/visually-hidden.d.ts +3 -0
- package/dist/components/general/visually-hidden.js +9 -0
- package/dist/components/layout/app-launcher.d.ts +34 -0
- package/dist/components/layout/app-launcher.js +261 -0
- package/dist/components/layout/app-shell.d.ts +3 -1
- package/dist/components/layout/app-shell.js +34 -14
- package/dist/components/layout/auth-shell.d.ts +1 -1
- package/dist/components/layout/auth-shell.js +2 -0
- package/dist/components/layout/breadcrumb.d.ts +14 -2
- package/dist/components/layout/breadcrumb.js +46 -4
- package/dist/components/layout/flex.d.ts +1 -1
- package/dist/components/layout/flex.js +23 -2
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +5 -1
- package/dist/components/layout/org-switcher.js +20 -1
- package/dist/components/layout/page-container.d.ts +1 -1
- package/dist/components/layout/page-container.js +5 -3
- package/dist/components/layout/responsive-grid.d.ts +16 -2
- package/dist/components/layout/responsive-grid.js +29 -2
- package/dist/components/layout/sidebar.js +2 -1
- package/dist/components/layout/topbar-item.d.ts +3 -0
- package/dist/components/layout/topbar-item.js +18 -3
- package/dist/components/layout/topbar.d.ts +1 -1
- package/dist/components/layout/topbar.js +27 -6
- package/dist/components/navigation/dropdown-menu.d.ts +30 -2
- package/dist/components/navigation/dropdown-menu.js +73 -11
- package/dist/components/navigation/pagination.d.ts +2 -2
- package/dist/components/navigation/pagination.js +155 -83
- package/dist/components/navigation/steps.d.ts +2 -2
- package/dist/components/navigation/steps.js +29 -4
- package/dist/components/navigation/tabs.d.ts +5 -33
- package/dist/components/navigation/tabs.js +232 -64
- package/dist/components/ui/hover-card.js +3 -0
- package/dist/components/ui/input-otp.d.ts +26 -28
- package/dist/components/ui/input-otp.js +50 -7
- package/dist/components/ui/password-input.d.ts +36 -2
- package/dist/components/ui/password-input.js +27 -7
- package/dist/components/ui/rating.d.ts +25 -0
- package/dist/components/ui/rating.js +67 -27
- package/dist/components/ui/segmented.d.ts +9 -0
- package/dist/components/ui/segmented.js +17 -2
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +13 -0
- package/dist/components/ui/tag-input.d.ts +45 -0
- package/dist/components/ui/tag-input.js +109 -27
- package/dist/form/form-context.d.ts +29 -0
- package/dist/form/form-context.js +44 -4
- package/dist/form/form-field-array.d.ts +22 -0
- package/dist/form/form-field-array.js +50 -0
- package/dist/form/form-field-control.d.ts +2 -1
- package/dist/form/form-field-control.js +116 -40
- package/dist/form/form-root.d.ts +2 -1
- package/dist/form/form-root.js +142 -23
- package/dist/form/index.d.ts +3 -1
- package/dist/form/index.js +12 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +3 -1
- package/dist/i18n/messages/en.json +59 -6
- package/dist/i18n/messages/ja.json +59 -6
- package/dist/i18n/messages/vi.json +59 -6
- package/dist/i18n/translate.d.ts +19 -0
- package/dist/i18n/translate.js +24 -0
- package/dist/inertia/index.d.ts +20 -0
- package/dist/inertia/index.js +60 -1
- package/dist/lib/control-styles.d.ts +25 -3
- package/dist/lib/control-styles.js +9 -3
- package/dist/lib/datetime/picker-format.d.ts +8 -0
- package/dist/lib/datetime/picker-format.js +54 -0
- package/dist/lib/overlay-portal.d.ts +18 -0
- package/dist/lib/overlay-portal.js +17 -0
- package/dist/props/components/app.prop.d.ts +13 -2
- package/dist/props/components/charts.prop.d.ts +21 -0
- package/dist/props/components/data-display.prop.d.ts +55 -4
- package/dist/props/components/data-entry.prop.d.ts +687 -43
- package/dist/props/components/form.prop.d.ts +142 -4
- package/dist/props/components/general.prop.d.ts +30 -1
- package/dist/props/components/index.d.ts +2 -2
- package/dist/props/components/layout.prop.d.ts +255 -8
- package/dist/props/components/navigation.prop.d.ts +113 -3
- package/dist/props/registry.d.ts +376 -10
- package/dist/props/registry.js +493 -9
- package/dist/props/vocabulary/data.prop.d.ts +179 -1
- package/dist/props/vocabulary/index.d.ts +4 -4
- package/dist/props/vocabulary/interaction.prop.d.ts +51 -2
- package/dist/props/vocabulary/navigation.prop.d.ts +40 -0
- package/dist/props/vocabulary/shared.prop.d.ts +33 -0
- package/dist/styles/badge-layout.css +2 -1
- package/dist/styles/card-layout.css +36 -5
- package/dist/styles/chart-layout.css +17 -1
- package/dist/styles/control.css +520 -14
- package/dist/styles/data-display-layout.css +248 -7
- package/dist/styles/data-entry-layout.css +13 -0
- package/dist/styles/layout.css +221 -4
- package/dist/styles/navigation-layout.css +230 -1
- package/dist/styles/shell-layout.css +690 -21
- package/dist/styles/table-layout.css +95 -6
- package/dist/styles/text-layout.css +5 -0
- package/dist/tokens/base.css +1 -0
- package/dist/tokens/components/badge.css +1 -0
- package/dist/tokens/components/chart.css +6 -0
- package/dist/tokens/components/control.css +81 -3
- package/dist/tokens/components/data-display.css +9 -0
- package/dist/tokens/components/descriptions.css +11 -0
- package/dist/tokens/components/flex.css +8 -0
- package/dist/tokens/components/navigation.css +55 -0
- package/dist/tokens/components/shell.css +100 -5
- package/dist/tokens/components/table.css +14 -0
- package/dist/tokens/foundation.css +2 -0
- package/dist/tokens/semantic/layout.css +9 -0
- package/docs/CONSUMER-RULES.md +13 -0
- package/docs/DESIGN-AUTHORITY.md +43 -6
- package/docs/DEVELOPMENT.md +4 -3
- package/docs/FORMS.md +151 -6
- package/docs/FRAME-COVERAGE-REPORT.md +29 -16
- package/docs/README.md +1 -1
- package/docs/STANDARDS-vocabulary-tokens.md +1 -1
- package/docs/TESTING.md +15 -6
- package/docs/charts/cjk-category-axis.tsx +81 -0
- package/docs/data-display/card/index.tsx +22 -0
- package/docs/data-display/data-table/examples/antd-parity.tsx +257 -0
- package/docs/data-display/data-table/index.tsx +23 -0
- package/docs/data-display/descriptions.tsx +41 -0
- package/docs/data-display/list-row.tsx +6 -6
- package/docs/data-display/scroll-area.tsx +31 -25
- package/docs/data-display/table.tsx +104 -45
- package/docs/data-display/timeline.tsx +41 -0
- package/docs/data-entry/date-picker.tsx +85 -0
- package/docs/data-entry/date-range-picker.tsx +26 -0
- package/docs/data-entry/form-dynamic-fields.tsx +199 -0
- package/docs/data-entry/form.tsx +74 -4
- package/docs/data-entry/input-otp.tsx +24 -0
- package/docs/data-entry/input.tsx +46 -1
- package/docs/data-entry/month-range-picker.tsx +1 -1
- package/docs/data-entry/select.tsx +27 -0
- package/docs/data-entry/switch.tsx +41 -0
- package/docs/data-entry/textarea.tsx +38 -0
- package/docs/data-entry/time-picker.tsx +85 -1
- package/docs/data-entry/time-range-picker.tsx +55 -0
- package/docs/data-entry/transfer.tsx +17 -0
- package/docs/data-entry/upload.tsx +56 -12
- package/docs/feedback/tooltip.tsx +1 -1
- package/docs/general/activity.tsx +2 -2
- package/docs/general/button/index.tsx +14 -1
- package/docs/general/typography.tsx +14 -1
- package/docs/layout/app-launcher.tsx +195 -0
- package/docs/layout/app-shell-arrangements.tsx +5 -5
- package/docs/layout/app-shell.tsx +11 -0
- package/docs/layout/flex.tsx +50 -0
- package/docs/layout/responsive-grid.tsx +21 -1
- package/docs/layout/topbar.tsx +5 -9
- package/docs/navigation/app-setting-picker.tsx +11 -0
- package/docs/navigation/breadcrumb.tsx +48 -0
- package/docs/navigation/dropdown-menu.tsx +21 -0
- package/docs/navigation/pagination.tsx +52 -0
- package/docs/navigation/steps.tsx +37 -0
- package/docs/navigation/tabs.tsx +97 -1
- package/docs/query/button-refetch.tsx +1 -0
- package/docs/showcase/settings-security-mfa.tsx +3 -3
- package/package.json +24 -4
- package/scripts/_agent-setup.mjs +76 -9
- package/scripts/init-guinea-pig.mjs +26 -4
- package/scripts/ui-audit.mjs +243 -30
- package/scripts/visual-audit.mjs +45 -7
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useTranslation } from "../../i18n/use-translation.js";
|
|
5
|
+
import { useControlledLatch } from "../../lib/hooks.js";
|
|
6
|
+
import { pickGroupFieldA11y } from "../../lib/field-a11y.js";
|
|
7
|
+
import { Flex } from "../layout/flex.js";
|
|
8
|
+
import { TimePicker } from "./time-picker.js";
|
|
9
|
+
function edgeAllowClear(allowClear, edgeAllowsEmpty) {
|
|
10
|
+
if (!edgeAllowsEmpty || allowClear === false) return false;
|
|
11
|
+
return allowClear ?? true;
|
|
12
|
+
}
|
|
13
|
+
function TimeRangePicker({
|
|
14
|
+
value: controlledValue,
|
|
15
|
+
defaultValue,
|
|
16
|
+
onValueChange,
|
|
17
|
+
order = true,
|
|
18
|
+
open: openProp,
|
|
19
|
+
defaultOpen = false,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
allowEmpty = [true, true],
|
|
22
|
+
name,
|
|
23
|
+
id,
|
|
24
|
+
placeholder,
|
|
25
|
+
className,
|
|
26
|
+
ref,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
const autoId = React.useId();
|
|
31
|
+
const groupId = id ?? autoId;
|
|
32
|
+
const controlled = useControlledLatch(controlledValue !== void 0);
|
|
33
|
+
const [internal, setInternal] = React.useState(defaultValue ?? ["", ""]);
|
|
34
|
+
const value = controlled ? controlledValue ?? ["", ""] : internal;
|
|
35
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
36
|
+
const [activeEdge, setActiveEdge] = React.useState(0);
|
|
37
|
+
const open = openProp ?? internalOpen;
|
|
38
|
+
const changeOpen = (edge, next) => {
|
|
39
|
+
if (next) setActiveEdge(edge);
|
|
40
|
+
if (openProp === void 0) setInternalOpen(next);
|
|
41
|
+
onOpenChange?.(next);
|
|
42
|
+
};
|
|
43
|
+
const choose = (edge, time) => {
|
|
44
|
+
if (!time && !allowEmpty[edge]) return;
|
|
45
|
+
const next = [value[0], value[1]];
|
|
46
|
+
next[edge] = time;
|
|
47
|
+
if (order && next[0] && next[1] && next[0] > next[1]) next.reverse();
|
|
48
|
+
if (!controlled) setInternal(next);
|
|
49
|
+
onValueChange?.(next);
|
|
50
|
+
};
|
|
51
|
+
return /* @__PURE__ */ jsxs(Flex, { role: "group", id: groupId, className, gap: "sm", ...pickGroupFieldA11y(props), children: [
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
TimePicker,
|
|
54
|
+
{
|
|
55
|
+
...props,
|
|
56
|
+
open: open && activeEdge === 0,
|
|
57
|
+
onOpenChange: (next) => changeOpen(0, next),
|
|
58
|
+
ref,
|
|
59
|
+
id: `${groupId}-from`,
|
|
60
|
+
name: name ? `${name}_from` : void 0,
|
|
61
|
+
"aria-labelledby": void 0,
|
|
62
|
+
"aria-label": t("dataEntry.dateRangePicker.from"),
|
|
63
|
+
placeholder: placeholder?.[0],
|
|
64
|
+
value: value[0],
|
|
65
|
+
onValueChange: (time) => choose(0, time),
|
|
66
|
+
allowClear: edgeAllowClear(props.allowClear, allowEmpty[0])
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
TimePicker,
|
|
71
|
+
{
|
|
72
|
+
...props,
|
|
73
|
+
open: open && activeEdge === 1,
|
|
74
|
+
onOpenChange: (next) => changeOpen(1, next),
|
|
75
|
+
id: `${groupId}-to`,
|
|
76
|
+
name: name ? `${name}_to` : void 0,
|
|
77
|
+
"aria-labelledby": void 0,
|
|
78
|
+
"aria-label": t("dataEntry.dateRangePicker.to"),
|
|
79
|
+
placeholder: placeholder?.[1],
|
|
80
|
+
value: value[1],
|
|
81
|
+
onValueChange: (time) => choose(1, time),
|
|
82
|
+
allowClear: edgeAllowClear(props.allowClear, allowEmpty[1])
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
TimeRangePicker
|
|
89
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { TransferProp } from "../../props/components/data-entry.prop.js";
|
|
3
3
|
export type { TransferProp, TransferProp as TransferProps, TransferItemProp, } from "../../props/components/data-entry.prop.js";
|
|
4
|
-
export declare function Transfer({ dataSource, targetKeys, onValueChange, titles, showSearch, oneWay, disabled, id, className, selectedKeys: selectedKeysProp, onSelectChange, ...ariaProps }: TransferProp): React.JSX.Element;
|
|
4
|
+
export declare function Transfer({ dataSource, targetKeys: legacyTargetKeys, value, defaultValue, name, readOnly, pagination, defaultTargetKeys, onValueChange, titles, showSearch, showSelectAll, filterOption, render, oneWay, disabled, id, className, selectedKeys: selectedKeysProp, onSelectChange, ...ariaProps }: TransferProp): React.JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
5
|
import { useTranslation } from "../../i18n/use-translation.js";
|
|
6
6
|
import { cn } from "../../lib/utils.js";
|
|
7
7
|
import { pickGroupFieldA11y } from "../../lib/field-a11y.js";
|
|
8
8
|
import { Button } from "../general/button.js";
|
|
9
|
+
import { Pagination } from "../navigation/pagination.js";
|
|
9
10
|
import { ScrollArea } from "../data-display/scroll-area.js";
|
|
10
11
|
import { Checkbox } from "./checkbox.js";
|
|
11
12
|
import { SearchInput } from "./search-input.js";
|
|
@@ -15,8 +16,11 @@ function TransferPanel({
|
|
|
15
16
|
items,
|
|
16
17
|
selectedKeys,
|
|
17
18
|
onSelectChange,
|
|
18
|
-
onSelectAll,
|
|
19
19
|
showSearch,
|
|
20
|
+
showSelectAll,
|
|
21
|
+
filterOption,
|
|
22
|
+
render,
|
|
23
|
+
pagination,
|
|
20
24
|
disabled,
|
|
21
25
|
searchPlaceholder,
|
|
22
26
|
emptyText,
|
|
@@ -26,15 +30,21 @@ function TransferPanel({
|
|
|
26
30
|
const titleId = React.useId();
|
|
27
31
|
const [query, setQuery] = React.useState("");
|
|
28
32
|
const filtered = React.useMemo(() => {
|
|
29
|
-
const q = query.trim()
|
|
33
|
+
const q = query.trim();
|
|
30
34
|
if (!q) return items;
|
|
35
|
+
if (filterOption) return items.filter((item) => filterOption(q, item));
|
|
36
|
+
const needle = q.toLowerCase();
|
|
31
37
|
return items.filter((item) => {
|
|
32
|
-
const titleMatch = reactNodeText(item.title).toLowerCase().includes(
|
|
33
|
-
const descMatch = item.description ? reactNodeText(item.description).toLowerCase().includes(
|
|
38
|
+
const titleMatch = reactNodeText(item.title).toLowerCase().includes(needle);
|
|
39
|
+
const descMatch = item.description ? reactNodeText(item.description).toLowerCase().includes(needle) : false;
|
|
34
40
|
return titleMatch || descMatch;
|
|
35
41
|
});
|
|
36
|
-
}, [items, query]);
|
|
37
|
-
const
|
|
42
|
+
}, [items, query, filterOption]);
|
|
43
|
+
const [page, setPage] = React.useState(1);
|
|
44
|
+
const pageSize = typeof pagination === "object" ? Math.max(1, Math.floor(pagination.pageSize ?? 10)) : 10;
|
|
45
|
+
const currentPage = Math.min(page, Math.max(1, Math.ceil(filtered.length / pageSize)));
|
|
46
|
+
const visible = pagination ? filtered.slice((currentPage - 1) * pageSize, currentPage * pageSize) : filtered;
|
|
47
|
+
const enabledItems = visible.filter((i) => !i.disabled);
|
|
38
48
|
const allChecked = enabledItems.length > 0 && enabledItems.every((i) => selectedKeys.includes(i.key));
|
|
39
49
|
const indeterminate = !allChecked && enabledItems.some((i) => selectedKeys.includes(i.key));
|
|
40
50
|
const toggleKey = (key, checked) => {
|
|
@@ -43,15 +53,20 @@ function TransferPanel({
|
|
|
43
53
|
return /* @__PURE__ */ jsxs("div", { className: "ui-transfer-pane", children: [
|
|
44
54
|
/* @__PURE__ */ jsxs("div", { className: "ui-transfer-pane-header", children: [
|
|
45
55
|
/* @__PURE__ */ jsxs("div", { className: "ui-transfer-pane-check", children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
56
|
+
showSelectAll ? /* @__PURE__ */ jsx(
|
|
47
57
|
Checkbox,
|
|
48
58
|
{
|
|
49
59
|
checked: allChecked ? true : indeterminate ? "indeterminate" : false,
|
|
50
60
|
disabled: Boolean(disabled) || enabledItems.length === 0,
|
|
51
|
-
onCheckedChange: (v) =>
|
|
61
|
+
onCheckedChange: (v) => {
|
|
62
|
+
const keys = enabledItems.map((item) => item.key);
|
|
63
|
+
onSelectChange(
|
|
64
|
+
v === true ? [.../* @__PURE__ */ new Set([...selectedKeys, ...keys])] : selectedKeys.filter((key) => !keys.includes(key))
|
|
65
|
+
);
|
|
66
|
+
},
|
|
52
67
|
"aria-label": direction === "left" ? t("dataEntry.transfer.selectAllSource") : t("dataEntry.transfer.selectAllTarget")
|
|
53
68
|
}
|
|
54
|
-
),
|
|
69
|
+
) : null,
|
|
55
70
|
/* @__PURE__ */ jsx("span", { id: titleId, children: title })
|
|
56
71
|
] }),
|
|
57
72
|
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
@@ -63,13 +78,17 @@ function TransferPanel({
|
|
|
63
78
|
showSearch && /* @__PURE__ */ jsx("div", { className: "ui-transfer-search", "data-disabled": disabled ? "" : void 0, children: /* @__PURE__ */ jsx(
|
|
64
79
|
SearchInput,
|
|
65
80
|
{
|
|
66
|
-
onSearch:
|
|
81
|
+
onSearch: (next) => {
|
|
82
|
+
setQuery(next);
|
|
83
|
+
setPage(1);
|
|
84
|
+
},
|
|
85
|
+
disabled,
|
|
67
86
|
placeholder: searchPlaceholder,
|
|
68
87
|
ariaLabel: searchPlaceholder,
|
|
69
88
|
debounce: 0
|
|
70
89
|
}
|
|
71
90
|
) }),
|
|
72
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsx("ul", { className: "ui-transfer-list", "aria-labelledby": titleId, children: filtered.length === 0 ? /* @__PURE__ */ jsx("li", { className: "ui-transfer-empty", children: emptyText }) :
|
|
91
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsx("ul", { className: "ui-transfer-list", "aria-labelledby": titleId, children: filtered.length === 0 ? /* @__PURE__ */ jsx("li", { className: "ui-transfer-empty", children: emptyText }) : visible.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
73
92
|
"div",
|
|
74
93
|
{
|
|
75
94
|
className: cn(
|
|
@@ -89,29 +108,50 @@ function TransferPanel({
|
|
|
89
108
|
className: "ui-transfer-row-check"
|
|
90
109
|
}
|
|
91
110
|
),
|
|
92
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
93
112
|
"label",
|
|
94
113
|
{
|
|
95
114
|
className: "ui-transfer-row-body",
|
|
96
115
|
id: `${titleId}-${item.key}`,
|
|
97
116
|
htmlFor: `${titleId}-${item.key}-box`,
|
|
98
|
-
children: [
|
|
117
|
+
children: render ? render(item) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
99
118
|
/* @__PURE__ */ jsx("span", { className: "block truncate font-medium", children: item.title }),
|
|
100
119
|
item.description && /* @__PURE__ */ jsx("span", { className: "ui-transfer-row-description text-muted-foreground block truncate", children: item.description })
|
|
101
|
-
]
|
|
120
|
+
] })
|
|
102
121
|
}
|
|
103
122
|
)
|
|
104
123
|
]
|
|
105
124
|
}
|
|
106
|
-
) }, item.key)) }) })
|
|
125
|
+
) }, item.key)) }) }),
|
|
126
|
+
pagination && filtered.length > pageSize ? /* @__PURE__ */ jsx(
|
|
127
|
+
Pagination,
|
|
128
|
+
{
|
|
129
|
+
value: currentPage,
|
|
130
|
+
pageSize,
|
|
131
|
+
total: filtered.length,
|
|
132
|
+
onValueChange: setPage,
|
|
133
|
+
showSizeChanger: false,
|
|
134
|
+
simple: true,
|
|
135
|
+
disabled
|
|
136
|
+
}
|
|
137
|
+
) : null
|
|
107
138
|
] });
|
|
108
139
|
}
|
|
109
140
|
function Transfer({
|
|
110
141
|
dataSource,
|
|
111
|
-
targetKeys,
|
|
142
|
+
targetKeys: legacyTargetKeys,
|
|
143
|
+
value,
|
|
144
|
+
defaultValue,
|
|
145
|
+
name,
|
|
146
|
+
readOnly,
|
|
147
|
+
pagination,
|
|
148
|
+
defaultTargetKeys,
|
|
112
149
|
onValueChange,
|
|
113
150
|
titles,
|
|
114
151
|
showSearch,
|
|
152
|
+
showSelectAll = true,
|
|
153
|
+
filterOption,
|
|
154
|
+
render,
|
|
115
155
|
oneWay,
|
|
116
156
|
disabled,
|
|
117
157
|
id,
|
|
@@ -124,22 +164,33 @@ function Transfer({
|
|
|
124
164
|
const groupA11y = pickGroupFieldA11y(ariaProps);
|
|
125
165
|
const [internalSelected, setInternalSelected] = React.useState([[], []]);
|
|
126
166
|
const selected = selectedKeysProp ?? internalSelected;
|
|
167
|
+
const [internalTargetKeys, setInternalTargetKeys] = React.useState(
|
|
168
|
+
defaultValue ?? defaultTargetKeys ?? []
|
|
169
|
+
);
|
|
170
|
+
const targetKeysProp = value ?? legacyTargetKeys;
|
|
171
|
+
const isTargetControlled = targetKeysProp !== void 0;
|
|
172
|
+
const targetKeys = isTargetControlled ? targetKeysProp : internalTargetKeys;
|
|
127
173
|
const sourceItems = dataSource.filter((item) => !targetKeys.includes(item.key));
|
|
128
174
|
const targetItems = dataSource.filter((item) => targetKeys.includes(item.key));
|
|
129
175
|
const setSelected = (side, keys) => {
|
|
130
176
|
const next = side === 0 ? [keys, selected[1]] : [selected[0], keys];
|
|
131
|
-
if (selectedKeysProp)
|
|
132
|
-
|
|
177
|
+
if (!selectedKeysProp) setInternalSelected(next);
|
|
178
|
+
onSelectChange?.(next[0], next[1]);
|
|
133
179
|
};
|
|
134
180
|
const move = (direction) => {
|
|
135
181
|
const fromSide = direction === "right" ? 0 : 1;
|
|
136
|
-
|
|
182
|
+
if (disabled || readOnly) return;
|
|
183
|
+
const available = direction === "right" ? sourceItems : targetItems;
|
|
184
|
+
const keys = selected[fromSide].filter(
|
|
185
|
+
(key) => available.some((item) => item.key === key && !item.disabled)
|
|
186
|
+
);
|
|
137
187
|
if (!keys.length) return;
|
|
138
188
|
const nextTarget = direction === "right" ? [...targetKeys, ...keys.filter((k) => !targetKeys.includes(k))] : targetKeys.filter((k) => !keys.includes(k));
|
|
189
|
+
if (!isTargetControlled) setInternalTargetKeys(nextTarget);
|
|
139
190
|
onValueChange?.(nextTarget, direction, keys);
|
|
140
191
|
const cleared = fromSide === 0 ? [[], selected[1]] : [selected[0], []];
|
|
141
|
-
if (selectedKeysProp)
|
|
142
|
-
|
|
192
|
+
if (!selectedKeysProp) setInternalSelected(cleared);
|
|
193
|
+
onSelectChange?.(cleared[0], cleared[1]);
|
|
143
194
|
};
|
|
144
195
|
const leftTitle = titles?.[0] ?? t("dataEntry.transfer.source");
|
|
145
196
|
const rightTitle = titles?.[1] ?? t("dataEntry.transfer.target");
|
|
@@ -152,6 +203,7 @@ function Transfer({
|
|
|
152
203
|
"aria-disabled": disabled ? true : void 0,
|
|
153
204
|
className: cn("ui-transfer", className),
|
|
154
205
|
children: [
|
|
206
|
+
name && !disabled ? targetKeys.map((key) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: key }, key)) : null,
|
|
155
207
|
/* @__PURE__ */ jsx(
|
|
156
208
|
TransferPanel,
|
|
157
209
|
{
|
|
@@ -160,9 +212,12 @@ function Transfer({
|
|
|
160
212
|
items: sourceItems,
|
|
161
213
|
selectedKeys: selected[0],
|
|
162
214
|
onSelectChange: (keys) => setSelected(0, keys),
|
|
163
|
-
onSelectAll: (checked) => setSelected(0, checked ? sourceItems.filter((i) => !i.disabled).map((i) => i.key) : []),
|
|
164
215
|
showSearch,
|
|
165
|
-
|
|
216
|
+
showSelectAll,
|
|
217
|
+
filterOption,
|
|
218
|
+
render,
|
|
219
|
+
disabled: disabled || readOnly,
|
|
220
|
+
pagination,
|
|
166
221
|
searchPlaceholder: t("dataEntry.transfer.searchPlaceholder"),
|
|
167
222
|
emptyText: t("dataEntry.transfer.empty")
|
|
168
223
|
}
|
|
@@ -174,7 +229,7 @@ function Transfer({
|
|
|
174
229
|
type: "button",
|
|
175
230
|
size: "icon",
|
|
176
231
|
variant: "outline",
|
|
177
|
-
disabled: Boolean(disabled) || selected[0].length === 0,
|
|
232
|
+
disabled: Boolean(disabled || readOnly) || selected[0].length === 0,
|
|
178
233
|
"aria-label": t("dataEntry.transfer.moveRight"),
|
|
179
234
|
onClick: () => move("right"),
|
|
180
235
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "ui-transfer-action-icon", "aria-hidden": "true" })
|
|
@@ -186,7 +241,7 @@ function Transfer({
|
|
|
186
241
|
type: "button",
|
|
187
242
|
size: "icon",
|
|
188
243
|
variant: "outline",
|
|
189
|
-
disabled: Boolean(disabled) || selected[1].length === 0,
|
|
244
|
+
disabled: Boolean(disabled || readOnly) || selected[1].length === 0,
|
|
190
245
|
"aria-label": t("dataEntry.transfer.moveLeft"),
|
|
191
246
|
onClick: () => move("left"),
|
|
192
247
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ui-transfer-action-icon", "aria-hidden": "true" })
|
|
@@ -201,9 +256,12 @@ function Transfer({
|
|
|
201
256
|
items: targetItems,
|
|
202
257
|
selectedKeys: selected[1],
|
|
203
258
|
onSelectChange: (keys) => setSelected(1, keys),
|
|
204
|
-
onSelectAll: (checked) => setSelected(1, checked ? targetItems.filter((i) => !i.disabled).map((i) => i.key) : []),
|
|
205
259
|
showSearch,
|
|
206
|
-
|
|
260
|
+
showSelectAll,
|
|
261
|
+
filterOption,
|
|
262
|
+
render,
|
|
263
|
+
disabled: disabled || readOnly,
|
|
264
|
+
pagination,
|
|
207
265
|
searchPlaceholder: t("dataEntry.transfer.searchPlaceholder"),
|
|
208
266
|
emptyText: t("dataEntry.transfer.empty")
|
|
209
267
|
}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { TreeSelectProp } from "../../props/components/data-entry.prop.js";
|
|
3
3
|
export type { TreeSelectProp, TreeSelectProp as TreeSelectProps, } from "../../props/components/data-entry.prop.js";
|
|
4
4
|
export { SHOW_CHILD, SHOW_PARENT, SHOW_ALL } from "./tree-select-strategy.js";
|
|
5
|
-
declare function TreeSelectRoot({ treeData: treeDataProp, value, defaultValue, onValueChange, multiple, treeCheckable, treeCheckStrictly, showSearch, showCheckedStrategy, treeDefaultExpandAll, placeholder, disabled, allowClear, className, id, fieldNames, ...ariaProps }: TreeSelectProp): React.JSX.Element;
|
|
5
|
+
declare function TreeSelectRoot({ treeData: treeDataProp, value, defaultValue, onValueChange, multiple, treeCheckable, treeCheckStrictly, showSearch, showCheckedStrategy, treeDefaultExpandAll, placeholder, disabled, readOnly, name, allowClear, className, id, fieldNames, size, status, variant, loading, open: openProp, defaultOpen, onOpenChange, loadData, treeTitleRender, maxTagCount, maxTagPlaceholder, notFoundContent, autoClearSearchValue, search: searchProp, onSearchChange, ...ariaProps }: TreeSelectProp): React.JSX.Element;
|
|
6
6
|
export declare const TreeSelect: typeof TreeSelectRoot & {
|
|
7
7
|
SHOW_CHILD: "SHOW_CHILD";
|
|
8
8
|
SHOW_PARENT: "SHOW_PARENT";
|