@godxjp/ui 19.6.0 → 20.1.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/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 +14 -3
- package/dist/components/data-display/card.js +22 -4
- package/dist/components/data-display/code-block.js +6 -2
- package/dist/components/data-display/collapsible.d.ts +23 -4
- package/dist/components/data-display/collapsible.js +119 -4
- 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 +5 -1
- package/dist/components/data-display/index.js +4 -0
- package/dist/components/data-display/legend.d.ts +15 -0
- package/dist/components/data-display/legend.js +11 -0
- package/dist/components/data-display/list-row.d.ts +10 -1
- package/dist/components/data-display/list-row.js +8 -2
- package/dist/components/data-display/popover.d.ts +60 -7
- package/dist/components/data-display/popover.js +268 -39
- package/dist/components/data-display/progress.d.ts +50 -2
- package/dist/components/data-display/progress.js +57 -9
- 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 +10 -10
- package/dist/components/data-display/table.d.ts +11 -3
- package/dist/components/data-display/table.js +48 -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 +79 -33
- package/dist/components/data-entry/cascader.d.ts +1 -1
- package/dist/components/data-entry/cascader.js +188 -24
- package/dist/components/data-entry/checkbox.d.ts +19 -6
- package/dist/components/data-entry/checkbox.js +55 -16
- package/dist/components/data-entry/choice-option.d.ts +1 -1
- 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 +2 -2
- package/dist/components/data-entry/date-range-picker.js +278 -140
- package/dist/components/data-entry/field.js +0 -1
- 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 +5 -3
- 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/label.d.ts +3 -2
- package/dist/components/data-entry/label.js +23 -10
- package/dist/components/data-entry/month-picker.d.ts +2 -2
- package/dist/components/data-entry/month-picker.js +47 -10
- package/dist/components/data-entry/month-range-picker.d.ts +2 -2
- 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 +99 -31
- package/dist/components/data-entry/tree-select-strategy.d.ts +1 -1
- package/dist/components/data-entry/tree-select.d.ts +1 -1
- package/dist/components/data-entry/tree-select.js +197 -92
- package/dist/components/data-entry/tree-utils.d.ts +1 -1
- 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 +482 -117
- package/dist/components/feedback/dialog.d.ts +105 -38
- package/dist/components/feedback/dialog.js +268 -193
- package/dist/components/feedback/overlay-close-focus.d.ts +31 -0
- package/dist/components/feedback/overlay-close-focus.js +31 -0
- package/dist/components/feedback/overlay-header-tone.d.ts +1 -1
- package/dist/components/feedback/sheet.d.ts +53 -11
- package/dist/components/feedback/sheet.js +150 -81
- package/dist/components/feedback/tooltip.d.ts +51 -7
- package/dist/components/feedback/tooltip.js +107 -25
- package/dist/components/general/button.d.ts +1 -1
- package/dist/components/general/button.js +7 -3
- package/dist/components/general/index.d.ts +1 -0
- package/dist/components/general/index.js +2 -0
- package/dist/components/general/logo.d.ts +17 -0
- package/dist/components/general/logo.js +22 -16
- 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 +228 -0
- package/dist/components/layout/app-shell.d.ts +3 -1
- package/dist/components/layout/app-shell.js +69 -12
- package/dist/components/layout/aspect-ratio.js +0 -1
- package/dist/components/layout/auth-divider.js +0 -1
- 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 +41 -3
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +5 -1
- package/dist/components/layout/nav-surface.d.ts +26 -0
- package/dist/components/layout/nav-surface.js +17 -0
- package/dist/components/layout/org-switcher.d.ts +5 -1
- package/dist/components/layout/org-switcher.js +25 -4
- 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/separator.js +0 -1
- package/dist/components/layout/sidebar.js +4 -1
- package/dist/components/layout/split-pane.d.ts +14 -1
- package/dist/components/layout/split-pane.js +26 -13
- package/dist/components/layout/topbar-item.d.ts +3 -0
- package/dist/components/layout/topbar-item.js +19 -5
- package/dist/components/layout/topbar.d.ts +1 -1
- package/dist/components/layout/topbar.js +27 -6
- package/dist/components/navigation/app-setting-picker.js +21 -2
- package/dist/components/navigation/app-setting-toggle.d.ts +16 -0
- package/dist/components/navigation/app-setting-toggle.js +96 -0
- package/dist/components/navigation/dropdown-menu.d.ts +227 -18
- package/dist/components/navigation/dropdown-menu.js +402 -118
- package/dist/components/navigation/index.d.ts +2 -0
- package/dist/components/navigation/index.js +2 -0
- package/dist/components/navigation/pagination-utils.d.ts +2 -1
- 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 +29 -16
- package/dist/components/navigation/tabs.js +374 -144
- package/dist/components/ui/accordion.d.ts +50 -5
- package/dist/components/ui/accordion.js +239 -33
- package/dist/components/ui/aspect-ratio.d.ts +23 -2
- package/dist/components/ui/aspect-ratio.js +15 -13
- package/dist/components/ui/avatar.d.ts +29 -4
- package/dist/components/ui/avatar.js +111 -25
- package/dist/components/ui/hover-card.d.ts +42 -4
- package/dist/components/ui/hover-card.js +183 -27
- package/dist/components/ui/input-otp.d.ts +26 -28
- package/dist/components/ui/input-otp.js +50 -7
- package/dist/components/ui/label.js +0 -1
- 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 +12 -3
- package/dist/components/ui/segmented.js +17 -2
- package/dist/components/ui/separator.d.ts +12 -2
- package/dist/components/ui/separator.js +30 -9
- package/dist/components/ui/tag-input.d.ts +45 -0
- package/dist/components/ui/tag-input.js +109 -27
- package/dist/components/ui/toggle-group.d.ts +50 -5
- package/dist/components/ui/toggle-group.js +79 -20
- package/dist/components/ui/toggle.d.ts +31 -5
- package/dist/components/ui/toggle.js +42 -3
- 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/messages/en.json +64 -5
- package/dist/i18n/messages/ja.json +64 -5
- package/dist/i18n/messages/vi.json +64 -5
- 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/slot.d.ts +32 -0
- package/dist/lib/slot.js +22 -0
- package/dist/lib/variants.d.ts +22 -3
- package/dist/lib/variants.js +56 -1
- package/dist/props/components/app.prop.d.ts +25 -1
- package/dist/props/components/charts.prop.d.ts +21 -0
- package/dist/props/components/data-display.prop.d.ts +72 -4
- package/dist/props/components/data-entry.prop.d.ts +718 -46
- package/dist/props/components/form.prop.d.ts +142 -4
- package/dist/props/components/general.prop.d.ts +17 -1
- package/dist/props/components/index.d.ts +3 -3
- package/dist/props/components/layout.prop.d.ts +281 -11
- package/dist/props/components/navigation.prop.d.ts +114 -4
- package/dist/props/registry.d.ts +397 -11
- package/dist/props/registry.js +526 -11
- package/dist/props/vocabulary/content.prop.d.ts +1 -1
- package/dist/props/vocabulary/data.prop.d.ts +179 -1
- package/dist/props/vocabulary/index.d.ts +5 -5
- package/dist/props/vocabulary/interaction.prop.d.ts +68 -3
- package/dist/props/vocabulary/layout.prop.d.ts +57 -1
- 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 +26 -4
- package/dist/styles/chart-layout.css +15 -0
- package/dist/styles/control.css +657 -15
- package/dist/styles/core.css +5 -2
- package/dist/styles/data-display-layout.css +313 -6
- package/dist/styles/data-entry-layout.css +13 -0
- package/dist/styles/focus-ring.css +4 -0
- package/dist/styles/index.css +5 -2
- package/dist/styles/layout.css +327 -4
- package/dist/styles/navigation-layout.css +227 -0
- package/dist/styles/shell-layout.css +369 -13
- package/dist/styles/table-layout.css +95 -6
- package/dist/styles/text-layout.css +10 -4
- package/dist/tokens/base.css +2 -1
- package/dist/tokens/components/badge.css +1 -0
- package/dist/tokens/components/chart.css +6 -0
- package/dist/tokens/components/control.css +79 -2
- package/dist/tokens/components/data-display.css +20 -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 +53 -3
- 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/COMPONENTS.md +9 -3
- package/docs/CONSUMER-RULES.md +13 -0
- package/docs/DESIGN-AUTHORITY.md +145 -83
- package/docs/DEVELOPMENT.md +4 -3
- package/docs/FORMS.md +151 -6
- package/docs/FRAME-COVERAGE-REPORT.md +32 -17
- package/docs/README.md +15 -15
- package/docs/STANDARDS-vocabulary-tokens.md +1 -1
- package/docs/TESTING.md +15 -6
- package/docs/WHAT-BELONGS-HERE.md +179 -0
- 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/legend.tsx +145 -0
- package/docs/data-display/progress.tsx +32 -0
- 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/segmented.tsx +1 -1
- package/docs/data-entry/select.tsx +29 -2
- 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/sheet.tsx +1 -1
- 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 +151 -0
- package/docs/layout/app-shell-arrangements.tsx +225 -0
- package/docs/layout/app-shell.tsx +11 -0
- package/docs/layout/aspect-ratio.tsx +1 -1
- 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 +37 -1
- package/docs/navigation/app-setting-toggle.tsx +111 -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/package.json +28 -8
- package/scripts/_agent-setup.mjs +182 -3
- package/scripts/consumer-rule.md +98 -0
- package/scripts/guinea-pig-skill.md +322 -0
- package/scripts/init-guinea-pig.mjs +84 -0
- package/scripts/postinstall.mjs +13 -2
- package/scripts/ui-audit.mjs +351 -37
- /package/dist/tokens/{antd.generated.css → derived.css} +0 -0
|
@@ -1,15 +1,22 @@
|
|
|
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
|
-
import { ChevronDown, ChevronRight, ChevronsUpDown, X } from "lucide-react";
|
|
4
|
+
import { ChevronDown, ChevronRight, ChevronsUpDown, Loader2, X } from "lucide-react";
|
|
5
5
|
import { useTranslation } from "../../i18n/use-translation.js";
|
|
6
6
|
import { cn } from "../../lib/utils.js";
|
|
7
7
|
import { pickFieldA11y, useFieldIdentity } from "../../lib/field-a11y.js";
|
|
8
|
-
import {
|
|
8
|
+
import { controlSurfaceTriggerClass } from "../../lib/control-styles.js";
|
|
9
|
+
import {
|
|
10
|
+
applyMaxTagCount,
|
|
11
|
+
controlSurfaceAttrs,
|
|
12
|
+
resolveAllowClear,
|
|
13
|
+
resolveAriaInvalid
|
|
14
|
+
} from "./control-surface.js";
|
|
9
15
|
import { Popover, PopoverContent, PopoverTrigger } from "../data-display/popover.js";
|
|
10
16
|
import { ScrollArea } from "../data-display/scroll-area.js";
|
|
11
17
|
import { Checkbox } from "./checkbox.js";
|
|
12
|
-
import {
|
|
18
|
+
import { SearchInput } from "./search-input.js";
|
|
19
|
+
import { Separator } from "../layout/separator.js";
|
|
13
20
|
import {
|
|
14
21
|
collectAllExpandableKeys,
|
|
15
22
|
filterVisibleTree,
|
|
@@ -54,15 +61,33 @@ function TreeSelectRoot({
|
|
|
54
61
|
treeDefaultExpandAll,
|
|
55
62
|
placeholder,
|
|
56
63
|
disabled,
|
|
57
|
-
|
|
64
|
+
readOnly,
|
|
65
|
+
name,
|
|
66
|
+
allowClear,
|
|
58
67
|
className,
|
|
59
68
|
id,
|
|
60
69
|
fieldNames,
|
|
70
|
+
size,
|
|
71
|
+
status,
|
|
72
|
+
variant,
|
|
73
|
+
loading = false,
|
|
74
|
+
open: openProp,
|
|
75
|
+
defaultOpen = false,
|
|
76
|
+
onOpenChange,
|
|
77
|
+
loadData,
|
|
78
|
+
treeTitleRender,
|
|
79
|
+
maxTagCount,
|
|
80
|
+
maxTagPlaceholder,
|
|
81
|
+
notFoundContent,
|
|
82
|
+
autoClearSearchValue = true,
|
|
83
|
+
search: searchProp,
|
|
84
|
+
onSearchChange,
|
|
61
85
|
...ariaProps
|
|
62
86
|
}) {
|
|
63
87
|
const { t } = useTranslation();
|
|
64
88
|
const fieldA11y = pickFieldA11y(ariaProps);
|
|
65
|
-
const identity = useFieldIdentity({ id, "data-field": fieldA11y["data-field"] });
|
|
89
|
+
const identity = useFieldIdentity({ id, name, "data-field": fieldA11y["data-field"] });
|
|
90
|
+
const resolvedName = name ?? identity.name;
|
|
66
91
|
const reactId = React.useId();
|
|
67
92
|
const treeId = `${id ?? reactId}-tree`;
|
|
68
93
|
const options = React.useMemo(
|
|
@@ -70,8 +95,28 @@ function TreeSelectRoot({
|
|
|
70
95
|
[treeDataProp, fieldNames]
|
|
71
96
|
);
|
|
72
97
|
const checkable = treeCheckable ?? multiple;
|
|
73
|
-
const [
|
|
74
|
-
const
|
|
98
|
+
const [internalSearch, setInternalSearch] = React.useState("");
|
|
99
|
+
const isSearchControlled = searchProp !== void 0;
|
|
100
|
+
const search = isSearchControlled ? searchProp : internalSearch;
|
|
101
|
+
const setSearch = React.useCallback(
|
|
102
|
+
(next) => {
|
|
103
|
+
if (!isSearchControlled) setInternalSearch(next);
|
|
104
|
+
onSearchChange?.(next);
|
|
105
|
+
},
|
|
106
|
+
[isSearchControlled, onSearchChange]
|
|
107
|
+
);
|
|
108
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
109
|
+
const isOpenControlled = openProp !== void 0;
|
|
110
|
+
const open = isOpenControlled ? openProp : internalOpen;
|
|
111
|
+
const setOpen = React.useCallback(
|
|
112
|
+
(next) => {
|
|
113
|
+
if (readOnly && next) return;
|
|
114
|
+
if (!isOpenControlled) setInternalOpen(next);
|
|
115
|
+
onOpenChange?.(next);
|
|
116
|
+
if (!next && autoClearSearchValue) setSearch("");
|
|
117
|
+
},
|
|
118
|
+
[isOpenControlled, onOpenChange, autoClearSearchValue, setSearch, readOnly]
|
|
119
|
+
);
|
|
75
120
|
const [expandedKeys, setExpandedKeys] = React.useState(
|
|
76
121
|
() => new Set(treeDefaultExpandAll ? collectAllExpandableKeys(options) : [])
|
|
77
122
|
);
|
|
@@ -89,7 +134,16 @@ function TreeSelectRoot({
|
|
|
89
134
|
if (!isControlled) setInternal(next);
|
|
90
135
|
onValueChange?.(checkable || multiple ? next : next[0] ?? void 0);
|
|
91
136
|
};
|
|
92
|
-
const
|
|
137
|
+
const requestedLoads = React.useRef(/* @__PURE__ */ new Set());
|
|
138
|
+
const toggleExpand = (node) => {
|
|
139
|
+
const key = node.value;
|
|
140
|
+
const willExpand = !expandedKeys.has(key);
|
|
141
|
+
if (willExpand && loadData && !(node.children?.length ?? 0) && node.isLeaf !== true) {
|
|
142
|
+
if (!requestedLoads.current.has(key)) {
|
|
143
|
+
requestedLoads.current.add(key);
|
|
144
|
+
void loadData(node);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
93
147
|
setExpandedKeys((prev) => {
|
|
94
148
|
const next = new Set(prev);
|
|
95
149
|
if (next.has(key)) next.delete(key);
|
|
@@ -116,10 +170,20 @@ function TreeSelectRoot({
|
|
|
116
170
|
commit(next);
|
|
117
171
|
};
|
|
118
172
|
const displayKeys = displayValues(selected, options, showCheckedStrategy, treeCheckStrictly);
|
|
119
|
-
const
|
|
173
|
+
const displayItems = displayKeys.map((v) => {
|
|
120
174
|
const label = findNodeByValue(options, v)?.label;
|
|
121
|
-
return label ? reactNodeText(label) : v;
|
|
122
|
-
})
|
|
175
|
+
return { value: v, label: label ? reactNodeText(label) : v };
|
|
176
|
+
});
|
|
177
|
+
const {
|
|
178
|
+
visible: visibleItems,
|
|
179
|
+
omitted: omittedItems,
|
|
180
|
+
overflow
|
|
181
|
+
} = applyMaxTagCount(displayItems, maxTagCount, maxTagPlaceholder);
|
|
182
|
+
const displayLabel = omittedItems.length === 0 ? visibleItems.map((item) => item.label).join(", ") : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
183
|
+
visibleItems.map((item) => item.label).join(", "),
|
|
184
|
+
", ",
|
|
185
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "tree-select-overflow", children: overflow ?? t("dataEntry.selection.overflow", { count: omittedItems.length }) })
|
|
186
|
+
] });
|
|
123
187
|
const clearValue = (e) => {
|
|
124
188
|
e.stopPropagation();
|
|
125
189
|
commit([]);
|
|
@@ -150,7 +214,7 @@ function TreeSelectRoot({
|
|
|
150
214
|
case "ArrowRight": {
|
|
151
215
|
event.preventDefault();
|
|
152
216
|
if (hasChildren && !expanded) {
|
|
153
|
-
toggleExpand(node
|
|
217
|
+
toggleExpand(node);
|
|
154
218
|
} else if (hasChildren && expanded) {
|
|
155
219
|
focusByOffset(node.value, 1);
|
|
156
220
|
}
|
|
@@ -159,7 +223,7 @@ function TreeSelectRoot({
|
|
|
159
223
|
case "ArrowLeft": {
|
|
160
224
|
event.preventDefault();
|
|
161
225
|
if (hasChildren && expanded) {
|
|
162
|
-
toggleExpand(node
|
|
226
|
+
toggleExpand(node);
|
|
163
227
|
}
|
|
164
228
|
break;
|
|
165
229
|
}
|
|
@@ -173,6 +237,9 @@ function TreeSelectRoot({
|
|
|
173
237
|
break;
|
|
174
238
|
}
|
|
175
239
|
};
|
|
240
|
+
const clearControl = resolveAllowClear(allowClear, true, t("dataEntry.treeSelect.clear"));
|
|
241
|
+
const showClear = clearControl.enabled && displayKeys.length > 0 && !disabled && !readOnly && !loading;
|
|
242
|
+
const surface = controlSurfaceAttrs({ variant, status, size });
|
|
176
243
|
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
177
244
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
178
245
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
@@ -186,108 +253,146 @@ function TreeSelectRoot({
|
|
|
186
253
|
"aria-haspopup": "tree",
|
|
187
254
|
"aria-controls": open ? treeId : void 0,
|
|
188
255
|
...fieldA11y,
|
|
256
|
+
...surface,
|
|
257
|
+
"aria-invalid": resolveAriaInvalid(fieldA11y["aria-invalid"], status),
|
|
258
|
+
"aria-busy": loading || void 0,
|
|
259
|
+
"aria-readonly": readOnly || void 0,
|
|
189
260
|
disabled,
|
|
190
261
|
className: cn(
|
|
191
|
-
|
|
262
|
+
controlSurfaceTriggerClass,
|
|
192
263
|
"w-full justify-between",
|
|
193
|
-
|
|
264
|
+
showClear && "ui-tree-select-trigger-affixed",
|
|
194
265
|
!displayKeys.length && "text-muted-foreground",
|
|
195
266
|
className
|
|
196
267
|
),
|
|
197
268
|
children: [
|
|
198
269
|
/* @__PURE__ */ jsx("span", { className: "truncate", children: displayKeys.length ? displayLabel : resolvedPlaceholder }),
|
|
199
|
-
/* @__PURE__ */ jsx("span", { className: "ms-2 flex shrink-0 items-center", children:
|
|
270
|
+
/* @__PURE__ */ jsx("span", { className: "ms-2 flex shrink-0 items-center", children: loading ? /* @__PURE__ */ jsx(
|
|
271
|
+
Loader2,
|
|
272
|
+
{
|
|
273
|
+
"data-slot": "tree-select-loading",
|
|
274
|
+
className: "ui-tree-select-chevron animate-spin",
|
|
275
|
+
"aria-hidden": "true"
|
|
276
|
+
}
|
|
277
|
+
) : showClear ? null : /* @__PURE__ */ jsx(ChevronsUpDown, { className: "ui-tree-select-chevron", "aria-hidden": "true" }) })
|
|
200
278
|
]
|
|
201
279
|
}
|
|
202
280
|
) }),
|
|
203
|
-
|
|
281
|
+
showClear && /* @__PURE__ */ jsx(
|
|
204
282
|
"button",
|
|
205
283
|
{
|
|
206
284
|
type: "button",
|
|
207
|
-
"aria-label":
|
|
285
|
+
"aria-label": clearControl.label,
|
|
208
286
|
className: "ui-tree-select-clear",
|
|
209
287
|
onClick: clearValue,
|
|
210
|
-
children: /* @__PURE__ */ jsx(X, { className: "ui-control-affix-icon", "aria-hidden": "true" })
|
|
288
|
+
children: clearControl.clearIcon ?? /* @__PURE__ */ jsx(X, { className: "ui-control-affix-icon", "aria-hidden": "true" })
|
|
211
289
|
}
|
|
212
|
-
)
|
|
290
|
+
),
|
|
291
|
+
resolvedName ? selected.map((entry) => /* @__PURE__ */ jsx("input", { type: "hidden", name: resolvedName, value: entry, readOnly: true }, entry)) : null
|
|
213
292
|
] }),
|
|
214
293
|
/* @__PURE__ */ jsxs(PopoverContent, { className: "ui-tree-select-popover", align: "start", children: [
|
|
215
|
-
showSearch && /* @__PURE__ */
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
className: "ui-tree-select-toggle",
|
|
258
|
-
onClick: () => toggleExpand(node.value),
|
|
259
|
-
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "ui-tree-select-toggle-icon", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "ui-tree-select-toggle-icon", "aria-hidden": "true" })
|
|
260
|
-
}
|
|
261
|
-
),
|
|
262
|
-
checkable ? /* @__PURE__ */ jsxs("label", { className: "ui-tree-select-label", children: [
|
|
294
|
+
showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
|
+
/* @__PURE__ */ jsx(
|
|
296
|
+
SearchInput,
|
|
297
|
+
{
|
|
298
|
+
variant: "borderless",
|
|
299
|
+
ariaLabel: t("dataEntry.treeSelect.searchPlaceholder"),
|
|
300
|
+
placeholder: t("dataEntry.treeSelect.searchPlaceholder"),
|
|
301
|
+
value: search,
|
|
302
|
+
onValueChange: setSearch
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
/* @__PURE__ */ jsx(Separator, {})
|
|
306
|
+
] }),
|
|
307
|
+
/* @__PURE__ */ jsxs(ScrollArea, { className: "ui-tree-select-list", children: [
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
"div",
|
|
310
|
+
{
|
|
311
|
+
id: treeId,
|
|
312
|
+
role: "tree",
|
|
313
|
+
"aria-multiselectable": Boolean(checkable) || Boolean(multiple),
|
|
314
|
+
className: "ui-tree-select-panel",
|
|
315
|
+
children: visible.map(({ node, depth, hasChildren }) => {
|
|
316
|
+
const expanded = showSearch && search.trim() ? hasChildren : expandedKeys.has(node.value);
|
|
317
|
+
const isSelected = selected.includes(node.value);
|
|
318
|
+
const expandable = hasChildren || Boolean(loadData && node.isLeaf === false && !node.children?.length);
|
|
319
|
+
return /* @__PURE__ */ jsxs(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
ref: (el) => {
|
|
323
|
+
treeItemRefs.current.set(node.value, el);
|
|
324
|
+
},
|
|
325
|
+
role: "treeitem",
|
|
326
|
+
tabIndex: node.disabled ? -1 : rovingKey === node.value ? 0 : -1,
|
|
327
|
+
"aria-expanded": expandable ? expanded : void 0,
|
|
328
|
+
"aria-selected": isSelected,
|
|
329
|
+
onFocus: () => setActiveKey(node.value),
|
|
330
|
+
onKeyDown: (event) => onTreeItemKeyDown(event, node, expandable, expanded),
|
|
331
|
+
"data-selected": isSelected ? "true" : "false",
|
|
332
|
+
"data-disabled": node.disabled ? "" : void 0,
|
|
333
|
+
className: "ui-tree-select-row ui-focus-ring",
|
|
334
|
+
style: { "--tree-select-depth": depth },
|
|
335
|
+
children: [
|
|
263
336
|
/* @__PURE__ */ jsx(
|
|
264
|
-
|
|
337
|
+
"button",
|
|
265
338
|
{
|
|
266
|
-
|
|
339
|
+
type: "button",
|
|
267
340
|
tabIndex: -1,
|
|
268
|
-
|
|
269
|
-
|
|
341
|
+
"aria-label": expanded ? t("dataEntry.treeSelect.collapse") : t("dataEntry.treeSelect.expand"),
|
|
342
|
+
"data-leaf": expandable ? void 0 : "",
|
|
343
|
+
className: "ui-tree-select-toggle",
|
|
344
|
+
onClick: () => toggleExpand(node),
|
|
345
|
+
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "ui-tree-select-toggle-icon", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "ui-tree-select-toggle-icon", "aria-hidden": "true" })
|
|
270
346
|
}
|
|
271
347
|
),
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
className: "
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
348
|
+
checkable ? (
|
|
349
|
+
// The row must NOT WRAP the Checkbox in a `<label>`: the Checkbox is itself a
|
|
350
|
+
// `<label>` around a real `<input>`, and a label nested in a label is
|
|
351
|
+
// invalid HTML — the browser resolves neither, so the box loses its
|
|
352
|
+
// accessible name. The node text sits BESIDE the box as a `for=`-associated
|
|
353
|
+
// label instead, which both names it and keeps the text clickable.
|
|
354
|
+
/* @__PURE__ */ jsxs("div", { className: "ui-tree-select-label", children: [
|
|
355
|
+
/* @__PURE__ */ jsx(
|
|
356
|
+
Checkbox,
|
|
357
|
+
{
|
|
358
|
+
id: `${treeId}-${node.value}-box`,
|
|
359
|
+
checked: isSelected,
|
|
360
|
+
tabIndex: -1,
|
|
361
|
+
disabled: Boolean(node.disabled) || Boolean(node.disableCheckbox),
|
|
362
|
+
onCheckedChange: () => toggleSelect(node),
|
|
363
|
+
"aria-labelledby": `${treeId}-${node.value}-label`
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ jsx(
|
|
367
|
+
"label",
|
|
368
|
+
{
|
|
369
|
+
className: "truncate",
|
|
370
|
+
id: `${treeId}-${node.value}-label`,
|
|
371
|
+
htmlFor: `${treeId}-${node.value}-box`,
|
|
372
|
+
children: treeTitleRender ? treeTitleRender(node) : node.label
|
|
373
|
+
}
|
|
374
|
+
)
|
|
375
|
+
] })
|
|
376
|
+
) : /* @__PURE__ */ jsx(
|
|
377
|
+
"button",
|
|
378
|
+
{
|
|
379
|
+
type: "button",
|
|
380
|
+
tabIndex: -1,
|
|
381
|
+
className: "flex-1 truncate text-start",
|
|
382
|
+
disabled: node.disabled,
|
|
383
|
+
onClick: () => toggleSelect(node),
|
|
384
|
+
children: treeTitleRender ? treeTitleRender(node) : node.label
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
node.value
|
|
390
|
+
);
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
visible.length === 0 && /* @__PURE__ */ jsx("p", { role: "status", className: "ui-tree-select-empty", children: notFoundContent ?? t("dataEntry.treeSelect.empty") })
|
|
395
|
+
] })
|
|
291
396
|
] })
|
|
292
397
|
] });
|
|
293
398
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
|
-
/** Normalized tree node —
|
|
2
|
+
/** Normalized tree node — the conventional `treeData` / Cascader `options` shape. */
|
|
3
3
|
export type TreeOption = {
|
|
4
4
|
value: string;
|
|
5
5
|
label: React.ReactNode;
|
|
@@ -108,21 +108,14 @@ function flattenVisibleTree(options, expandedKeys, depth = 0) {
|
|
|
108
108
|
function filterVisibleTree(options, query) {
|
|
109
109
|
const q = query.trim().toLowerCase();
|
|
110
110
|
if (!q) return flattenVisibleTree(options, new Set(collectAllExpandableKeys(options)));
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (selfMatch || childMatch) {
|
|
118
|
-
branchMatch = true;
|
|
119
|
-
if (childMatch) expanded.add(node.value);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return branchMatch;
|
|
111
|
+
function matches(nodes, depth) {
|
|
112
|
+
return nodes.flatMap((node) => {
|
|
113
|
+
const children = node.isLeaf ? [] : matches(node.children ?? [], depth + 1);
|
|
114
|
+
if (!reactNodeText(node.label).toLowerCase().includes(q) && children.length === 0) return [];
|
|
115
|
+
return [{ node, depth, hasChildren: children.length > 0 }, ...children];
|
|
116
|
+
});
|
|
123
117
|
}
|
|
124
|
-
|
|
125
|
-
return flattenVisibleTree(options, expanded);
|
|
118
|
+
return matches(options, 0);
|
|
126
119
|
}
|
|
127
120
|
function collectAllExpandableKeys(options) {
|
|
128
121
|
const keys = [];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
async function readDroppedFiles(transfer, directory) {
|
|
2
|
+
if (!directory || !transfer.items?.length) return Array.from(transfer.files);
|
|
3
|
+
const entries = Array.from(transfer.items).map((item) => item.webkitGetAsEntry?.()).filter((entry) => entry != null);
|
|
4
|
+
if (!entries.length) return Array.from(transfer.files);
|
|
5
|
+
const result = [];
|
|
6
|
+
const visit = async (entry, parent) => {
|
|
7
|
+
const path = parent ? `${parent}/${entry.name}` : entry.name;
|
|
8
|
+
if (entry.isFile) {
|
|
9
|
+
const file = await new Promise(
|
|
10
|
+
(resolve, reject) => entry.file(resolve, reject)
|
|
11
|
+
);
|
|
12
|
+
Object.defineProperty(file, "webkitRelativePath", { value: path, configurable: true });
|
|
13
|
+
result.push(file);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!entry.isDirectory) return;
|
|
17
|
+
const reader = entry.createReader();
|
|
18
|
+
for (; ; ) {
|
|
19
|
+
const children = await new Promise(
|
|
20
|
+
(resolve, reject) => reader.readEntries(resolve, reject)
|
|
21
|
+
);
|
|
22
|
+
if (!children.length) break;
|
|
23
|
+
for (const child of children) await visit(child, path);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
for (const entry of entries) await visit(entry, "");
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
readDroppedFiles
|
|
31
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UploadProp } from "../../props/components/data-entry.prop.js";
|
|
2
|
+
import type { UploadRequestContext, UploadResult } from "./upload-types.js";
|
|
3
|
+
/** Default multipart transport. Custom storage protocols use onUpload with the same abort/progress contract. */
|
|
4
|
+
export declare function uploadRequest(file: File, options: Pick<UploadProp, "action" | "method" | "headers" | "data" | "name" | "withCredentials">, context: UploadRequestContext): Promise<UploadResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
async function uploadRequest(file, options, context) {
|
|
2
|
+
const action = typeof options.action === "function" ? await options.action(file) : options.action;
|
|
3
|
+
const data = typeof options.data === "function" ? await options.data(file) : options.data;
|
|
4
|
+
context.signal.throwIfAborted();
|
|
5
|
+
if (!action) throw new Error("Upload requires action or onUpload");
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const xhr = new XMLHttpRequest();
|
|
8
|
+
const abort = () => xhr.abort();
|
|
9
|
+
const cleanup = () => context.signal.removeEventListener("abort", abort);
|
|
10
|
+
xhr.open(options.method ?? "POST", action);
|
|
11
|
+
xhr.withCredentials = options.withCredentials ?? false;
|
|
12
|
+
for (const [key, value] of Object.entries(options.headers ?? {}))
|
|
13
|
+
xhr.setRequestHeader(key, value);
|
|
14
|
+
xhr.upload.onprogress = (event) => {
|
|
15
|
+
if (event.lengthComputable) context.onProgress(event.loaded / event.total * 100);
|
|
16
|
+
};
|
|
17
|
+
xhr.onload = () => {
|
|
18
|
+
cleanup();
|
|
19
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
20
|
+
reject(new Error(`HTTP ${xhr.status}`));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let response = xhr.responseText;
|
|
24
|
+
try {
|
|
25
|
+
response = JSON.parse(xhr.responseText);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
const result = response && typeof response === "object" ? response : {};
|
|
29
|
+
resolve({
|
|
30
|
+
response,
|
|
31
|
+
mediaId: typeof result.mediaId === "string" ? result.mediaId : void 0,
|
|
32
|
+
url: typeof result.url === "string" ? result.url : void 0,
|
|
33
|
+
previewUrl: typeof result.previewUrl === "string" ? result.previewUrl : void 0
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
xhr.onerror = () => {
|
|
37
|
+
cleanup();
|
|
38
|
+
reject(new Error("Network error"));
|
|
39
|
+
};
|
|
40
|
+
xhr.onabort = () => {
|
|
41
|
+
cleanup();
|
|
42
|
+
reject(new DOMException("Upload aborted", "AbortError"));
|
|
43
|
+
};
|
|
44
|
+
context.signal.addEventListener("abort", abort, { once: true });
|
|
45
|
+
const body = new FormData();
|
|
46
|
+
for (const [key, value] of Object.entries(data ?? {})) body.append(key, value);
|
|
47
|
+
body.append(options.name ?? "file", file, file.name);
|
|
48
|
+
xhr.send(body);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
uploadRequest
|
|
53
|
+
};
|
|
@@ -12,6 +12,10 @@ export type UploadFileItem = {
|
|
|
12
12
|
mediaId?: string;
|
|
13
13
|
status: UploadFileStatus;
|
|
14
14
|
error?: string;
|
|
15
|
+
percent?: number;
|
|
16
|
+
response?: unknown;
|
|
17
|
+
url?: string;
|
|
18
|
+
relativePath?: string;
|
|
15
19
|
/** Local file before / during upload */
|
|
16
20
|
file?: File;
|
|
17
21
|
/** Undo clears this before save — media-service has no restore API. */
|
|
@@ -33,3 +37,27 @@ export type UploadCommitAction = {
|
|
|
33
37
|
export declare function createUploadItem(file: File, partial?: Partial<UploadFileItem>): UploadFileItem;
|
|
34
38
|
export declare function revokePreviewUrl(item: UploadFileItem | null | undefined): void;
|
|
35
39
|
export declare function collectUploadCommitActions(items: UploadFileItem[]): UploadCommitAction;
|
|
40
|
+
/** Returning this from beforeUpload excludes the file entirely. false keeps it staged. */
|
|
41
|
+
export declare const UPLOAD_LIST_IGNORE: unique symbol;
|
|
42
|
+
export type UploadRequestContext = {
|
|
43
|
+
signal: AbortSignal;
|
|
44
|
+
onProgress: (percent: number) => void;
|
|
45
|
+
};
|
|
46
|
+
export type UploadResult = {
|
|
47
|
+
mediaId?: string;
|
|
48
|
+
previewUrl?: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
response?: unknown;
|
|
51
|
+
};
|
|
52
|
+
export type UploadRejection = {
|
|
53
|
+
file: File;
|
|
54
|
+
reason: "accept" | "size" | "count" | "beforeUpload";
|
|
55
|
+
error?: unknown;
|
|
56
|
+
};
|
|
57
|
+
export type UploadItemActions = {
|
|
58
|
+
remove: () => void;
|
|
59
|
+
preview: () => void;
|
|
60
|
+
download: () => void;
|
|
61
|
+
upload: () => void;
|
|
62
|
+
cancel: () => void;
|
|
63
|
+
};
|
|
@@ -34,7 +34,9 @@ function collectUploadCommitActions(items) {
|
|
|
34
34
|
promoteMediaIds: [...new Set(promoteMediaIds)]
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
const UPLOAD_LIST_IGNORE = /* @__PURE__ */ Symbol("upload-list-ignore");
|
|
37
38
|
export {
|
|
39
|
+
UPLOAD_LIST_IGNORE,
|
|
38
40
|
collectUploadCommitActions,
|
|
39
41
|
createUploadItem,
|
|
40
42
|
revokePreviewUrl
|
|
@@ -2,6 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import type { UploadProp } from "../../props/components/data-entry.prop.js";
|
|
3
3
|
export type { UploadProp, UploadProp as UploadProps, UploadFileItemProp, UploadVariantProp, } from "../../props/components/data-entry.prop.js";
|
|
4
4
|
export type { UploadFileItem, UploadVariant, UploadCommitAction } from "./upload-types.js";
|
|
5
|
-
export { collectUploadCommitActions, createUploadItem } from "./upload-types.js";
|
|
5
|
+
export { collectUploadCommitActions, createUploadItem, UPLOAD_LIST_IGNORE } from "./upload-types.js";
|
|
6
6
|
export { useUploadDraft } from "./use-upload-draft.js";
|
|
7
|
-
export declare function Upload({ variant, triggerSize, triggerVariant, value, defaultValue, onValueChange, accept: acceptProp, multiple: multipleProp, maxCount: maxCountProp, maxSizeBytes, disabled, removable, onUpload, id, className, children, ...ariaProps }: UploadProp): React.JSX.Element;
|
|
7
|
+
export declare function Upload({ variant, triggerSize, triggerVariant, value, defaultValue, onValueChange, accept: acceptProp, multiple: multipleProp, maxCount: maxCountProp, maxSizeBytes, disabled: disabledProp, readOnly, directory, pastable, openFileDialogOnClick, name, action, method, headers, data, withCredentials, beforeUpload, onReject, onRemove, onPreview, onDownload, previewFile, onDrop, showUploadList, itemRender, removable, onUpload, id, className, children, ...ariaProps }: UploadProp): React.JSX.Element;
|