@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
|
@@ -1,36 +1,92 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { CalendarIcon, X } from "lucide-react";
|
|
4
|
+
import { CalendarIcon, ChevronLeft, ChevronRight, X } from "lucide-react";
|
|
5
5
|
import { usePickerLocales, useTranslation } from "../../i18n/use-translation.js";
|
|
6
|
-
import {
|
|
6
|
+
import { toIsoDate } from "../../lib/datetime/parse.js";
|
|
7
|
+
import {
|
|
8
|
+
formatPickerDate,
|
|
9
|
+
parsePickerDate,
|
|
10
|
+
pickerDateAllowed,
|
|
11
|
+
pickerPeriodStart
|
|
12
|
+
} from "../../lib/datetime/picker-format.js";
|
|
13
|
+
import { Button } from "../general/button.js";
|
|
14
|
+
import { Flex } from "../layout/flex.js";
|
|
15
|
+
import { TimePicker } from "./time-picker.js";
|
|
7
16
|
import { useControlledLatch } from "../../lib/hooks.js";
|
|
8
17
|
import { pickFieldA11y, useFieldIdentity } from "../../lib/field-a11y.js";
|
|
9
18
|
import { cn } from "../../lib/utils.js";
|
|
19
|
+
import { resolveAllowClear } from "./control-surface.js";
|
|
10
20
|
import { Input } from "./input.js";
|
|
11
21
|
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "../data-display/popover.js";
|
|
12
22
|
import { Calendar } from "./calendar.js";
|
|
13
23
|
const ISO_HINT = "yyyy-mm-dd";
|
|
14
|
-
function DatePicker({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
function DatePicker(props) {
|
|
25
|
+
const {
|
|
26
|
+
value: valueProp,
|
|
27
|
+
defaultValue,
|
|
28
|
+
placeholder,
|
|
29
|
+
disabled,
|
|
30
|
+
className,
|
|
31
|
+
id,
|
|
32
|
+
name,
|
|
33
|
+
locale: localeProp,
|
|
34
|
+
showToday,
|
|
35
|
+
showClose,
|
|
36
|
+
fromDate,
|
|
37
|
+
toDate,
|
|
38
|
+
disabledDate,
|
|
39
|
+
cellRender,
|
|
40
|
+
allowClear,
|
|
41
|
+
format: formatProp,
|
|
42
|
+
parseFormat,
|
|
43
|
+
minDate,
|
|
44
|
+
maxDate,
|
|
45
|
+
showWeek,
|
|
46
|
+
showTime,
|
|
47
|
+
presets,
|
|
48
|
+
multiple = false,
|
|
49
|
+
picker = "date",
|
|
50
|
+
order = true,
|
|
51
|
+
needConfirm = Boolean(showTime),
|
|
52
|
+
open: openProp,
|
|
53
|
+
defaultOpen = false,
|
|
54
|
+
onOpenChange,
|
|
55
|
+
inputReadOnly,
|
|
56
|
+
preserveInvalidOnBlur,
|
|
57
|
+
placement = "bottom-start",
|
|
58
|
+
renderExtraFooter,
|
|
59
|
+
size,
|
|
60
|
+
status,
|
|
61
|
+
variant,
|
|
62
|
+
ref,
|
|
63
|
+
...ariaProps
|
|
64
|
+
} = props;
|
|
65
|
+
const format = formatProp ?? (typeof showTime === "object" && showTime.showSeconds ? "yyyy-MM-dd HH:mm:ss" : void 0);
|
|
31
66
|
const { t } = useTranslation();
|
|
32
|
-
const { dayPickerLocale } = usePickerLocales(localeProp);
|
|
33
|
-
const [
|
|
67
|
+
const { dayPickerLocale, locale } = usePickerLocales(localeProp);
|
|
68
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
69
|
+
const open = !disabled && (openProp ?? internalOpen);
|
|
70
|
+
const [pending, setPending] = React.useState();
|
|
71
|
+
const [hasPending, setHasPending] = React.useState(false);
|
|
72
|
+
const setOpen = (next) => {
|
|
73
|
+
if (disabled && next) return;
|
|
74
|
+
if (openProp === void 0) setInternalOpen(next);
|
|
75
|
+
onOpenChange?.(next);
|
|
76
|
+
if (!next) {
|
|
77
|
+
setHasPending(false);
|
|
78
|
+
setPending(void 0);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const timeAllowed = (date) => {
|
|
82
|
+
const rules = typeof showTime === "object" ? showTime.disabledTime?.() : void 0;
|
|
83
|
+
return !(rules?.disabledHours?.().includes(date.getHours()) || rules?.disabledMinutes?.(date.getHours()).includes(date.getMinutes()) || rules?.disabledSeconds?.(date.getHours(), date.getMinutes()).includes(date.getSeconds()));
|
|
84
|
+
};
|
|
85
|
+
const minimum = minDate ?? fromDate;
|
|
86
|
+
const maximum = maxDate ?? toDate;
|
|
87
|
+
const allowed = (date) => pickerDateAllowed(date, minimum, maximum, disabledDate);
|
|
88
|
+
const display = (date) => Array.isArray(date) ? date.map((day) => formatPickerDate(day, format, locale)).join(", ") : formatPickerDate(date, format, locale, Boolean(showTime));
|
|
89
|
+
const parse = (text2) => parsePickerDate(text2, format, parseFormat, Boolean(showTime));
|
|
34
90
|
const fieldA11y = pickFieldA11y(ariaProps);
|
|
35
91
|
const identity = useFieldIdentity({ id, name, "data-field": fieldA11y["data-field"] });
|
|
36
92
|
const resolvedName = name ?? identity.name;
|
|
@@ -40,63 +96,106 @@ function DatePicker({
|
|
|
40
96
|
const isControlled = useControlledLatch(valueProp !== void 0);
|
|
41
97
|
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
42
98
|
const value = isControlled ? valueProp : internalValue;
|
|
99
|
+
const working = hasPending ? pending : value;
|
|
100
|
+
const selectedDate = Array.isArray(working) ? working[0] : working;
|
|
101
|
+
const [viewYear, setViewYear] = React.useState((selectedDate ?? /* @__PURE__ */ new Date()).getFullYear());
|
|
102
|
+
const periodDate = (date) => pickerPeriodStart(date, picker, dayPickerLocale);
|
|
43
103
|
const emit = (next) => {
|
|
44
104
|
if (!isControlled) setInternalValue(next);
|
|
45
|
-
|
|
105
|
+
if (props.multiple)
|
|
106
|
+
props.onValueChange?.(Array.isArray(next) ? next : next ? [next] : void 0);
|
|
107
|
+
else props.onValueChange?.(Array.isArray(next) ? next[0] : next);
|
|
46
108
|
};
|
|
47
|
-
const [text, setText] = React.useState(() =>
|
|
109
|
+
const [text, setText] = React.useState(() => display(value));
|
|
48
110
|
React.useEffect(() => {
|
|
49
|
-
setText(
|
|
50
|
-
|
|
111
|
+
setText(
|
|
112
|
+
Array.isArray(value) ? value.map((date) => formatPickerDate(date, format, locale)).join(", ") : formatPickerDate(value, format, locale, Boolean(showTime))
|
|
113
|
+
);
|
|
114
|
+
}, [value, format, locale, showTime]);
|
|
51
115
|
const resolvedPlaceholder = placeholder ?? t("dataEntry.datePicker.placeholder") ?? ISO_HINT;
|
|
52
116
|
const clear = () => {
|
|
53
117
|
emit(void 0);
|
|
54
118
|
setText("");
|
|
55
119
|
};
|
|
56
|
-
const
|
|
120
|
+
const clearControl = resolveAllowClear(allowClear, true, t("common.clear") ?? "Clear");
|
|
121
|
+
const showClear = clearControl.enabled && text !== "" && !disabled;
|
|
122
|
+
const choose = (input) => {
|
|
123
|
+
let date = input;
|
|
124
|
+
if (Array.isArray(date)) {
|
|
125
|
+
if (date.some((day) => !allowed(day))) return;
|
|
126
|
+
if (order) date = [...date].sort((a, b) => +a - +b);
|
|
127
|
+
} else if (date) {
|
|
128
|
+
date = periodDate(date);
|
|
129
|
+
if (!allowed(date) || !needConfirm && !timeAllowed(date)) return;
|
|
130
|
+
if (multiple) {
|
|
131
|
+
const current = Array.isArray(working) ? working : [];
|
|
132
|
+
date = current.some((day) => +day === +date) ? current.filter((day) => +day !== +date) : [...current, date];
|
|
133
|
+
if (order) date.sort((a, b) => +a - +b);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (needConfirm) {
|
|
137
|
+
setPending(date);
|
|
138
|
+
setHasPending(true);
|
|
139
|
+
} else {
|
|
140
|
+
emit(date);
|
|
141
|
+
setText(display(date));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
57
144
|
const commit = (raw) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
emit(void 0);
|
|
145
|
+
if (!raw.trim()) {
|
|
146
|
+
choose(void 0);
|
|
61
147
|
return;
|
|
62
148
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (parsed) {
|
|
66
|
-
emit(parsed);
|
|
67
|
-
}
|
|
149
|
+
const parsed = parse(raw);
|
|
150
|
+
if (parsed && allowed(parsed)) choose(parsed);
|
|
68
151
|
};
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */ jsx(
|
|
71
|
-
|
|
152
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
153
|
+
(format || showTime || multiple || needConfirm || preserveInvalidOnBlur) && resolvedName ? /* @__PURE__ */ jsx(
|
|
154
|
+
"input",
|
|
72
155
|
{
|
|
73
|
-
|
|
74
|
-
name: resolvedName,
|
|
75
|
-
"data-field": resolvedField,
|
|
76
|
-
value: text,
|
|
156
|
+
type: "hidden",
|
|
77
157
|
disabled,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
158
|
+
name: resolvedName,
|
|
159
|
+
value: showTime ? (Array.isArray(value) ? value[0] : value)?.toISOString() ?? "" : Array.isArray(value) ? value.map(toIsoDate).join(",") : toIsoDate(value)
|
|
160
|
+
}
|
|
161
|
+
) : null,
|
|
162
|
+
/* @__PURE__ */ jsx(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
163
|
+
/* @__PURE__ */ jsx(
|
|
164
|
+
Input,
|
|
165
|
+
{
|
|
166
|
+
id,
|
|
167
|
+
name: format || showTime || multiple || needConfirm || preserveInvalidOnBlur ? "" : resolvedName,
|
|
168
|
+
ref,
|
|
169
|
+
size,
|
|
170
|
+
status,
|
|
171
|
+
variant,
|
|
172
|
+
readOnly: inputReadOnly || multiple,
|
|
173
|
+
"data-field": resolvedField,
|
|
174
|
+
value: text,
|
|
175
|
+
disabled,
|
|
176
|
+
placeholder: resolvedPlaceholder,
|
|
177
|
+
inputMode: "numeric",
|
|
178
|
+
autoComplete: "off",
|
|
179
|
+
role: "combobox",
|
|
180
|
+
"aria-expanded": open,
|
|
181
|
+
"aria-haspopup": "dialog",
|
|
182
|
+
"aria-controls": open ? dialogId : void 0,
|
|
183
|
+
...fieldA11y,
|
|
184
|
+
trailingIcon: /* @__PURE__ */ jsx("span", { className: "ui-time-picker-affix", children: showClear ? /* @__PURE__ */ jsx(
|
|
89
185
|
"button",
|
|
90
186
|
{
|
|
91
187
|
type: "button",
|
|
92
188
|
tabIndex: -1,
|
|
93
|
-
"aria-label":
|
|
94
|
-
onClick:
|
|
189
|
+
"aria-label": clearControl.label,
|
|
190
|
+
onClick: (event) => {
|
|
191
|
+
event.stopPropagation();
|
|
192
|
+
event.currentTarget.closest("div")?.querySelector("input:not([type=hidden])")?.focus();
|
|
193
|
+
clear();
|
|
194
|
+
},
|
|
95
195
|
className: "ui-control-inline-affix-action",
|
|
96
|
-
children: /* @__PURE__ */ jsx(X, { className: "ui-control-inline-affix-icon", "aria-hidden": "true" })
|
|
196
|
+
children: clearControl.clearIcon ?? /* @__PURE__ */ jsx(X, { className: "ui-control-inline-affix-icon", "aria-hidden": "true" })
|
|
97
197
|
}
|
|
98
|
-
) :
|
|
99
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
198
|
+
) : /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
100
199
|
"button",
|
|
101
200
|
{
|
|
102
201
|
type: "button",
|
|
@@ -106,64 +205,196 @@ function DatePicker({
|
|
|
106
205
|
className: "ui-control-inline-affix-action",
|
|
107
206
|
children: /* @__PURE__ */ jsx(CalendarIcon, { className: "ui-control-inline-affix-icon", "aria-hidden": "true" })
|
|
108
207
|
}
|
|
109
|
-
) })
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
onBlur: (event) => {
|
|
127
|
-
const parsed = parseDateInput(event.target.value.trim());
|
|
128
|
-
setText(parsed ? toIsoDate(parsed) : toIsoDate(value));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
/* @__PURE__ */ jsx(
|
|
133
|
-
PopoverContent,
|
|
134
|
-
{
|
|
135
|
-
id: dialogId,
|
|
136
|
-
role: "dialog",
|
|
137
|
-
"aria-label": t("dataEntry.datePicker.openCalendar") ?? "Calendar",
|
|
138
|
-
className: "ui-control-panel-flush",
|
|
139
|
-
align: "start",
|
|
140
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
141
|
-
children: /* @__PURE__ */ jsx(
|
|
142
|
-
Calendar,
|
|
143
|
-
{
|
|
144
|
-
mode: "single",
|
|
145
|
-
selected: value,
|
|
146
|
-
defaultMonth: value,
|
|
147
|
-
onSelect: (date) => {
|
|
148
|
-
emit(date);
|
|
149
|
-
setText(toIsoDate(date));
|
|
208
|
+
) }) }),
|
|
209
|
+
onClick: () => {
|
|
210
|
+
if (!disabled) setOpen(true);
|
|
211
|
+
},
|
|
212
|
+
onKeyDown: (event) => {
|
|
213
|
+
if (event.key === "ArrowDown") {
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
setOpen(true);
|
|
216
|
+
} else if (event.key === "Enter") {
|
|
217
|
+
const parsed = parse(text);
|
|
218
|
+
if (parsed && allowed(parsed) && timeAllowed(parsed)) {
|
|
219
|
+
const next = periodDate(parsed);
|
|
220
|
+
emit(next);
|
|
221
|
+
setText(display(parsed));
|
|
222
|
+
setOpen(false);
|
|
223
|
+
}
|
|
224
|
+
} else if (event.key === "Escape" && open) {
|
|
150
225
|
setOpen(false);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
onClose: () => setOpen(false)
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
onChange: (event) => {
|
|
229
|
+
setText(event.target.value);
|
|
230
|
+
commit(event.target.value);
|
|
231
|
+
},
|
|
232
|
+
onBlur: (event) => {
|
|
233
|
+
const parsed = parse(event.target.value);
|
|
234
|
+
const accepted = parsed && allowed(parsed) && timeAllowed(parsed) ? parsed : void 0;
|
|
235
|
+
if (!preserveInvalidOnBlur) setText(accepted ? display(accepted) : display(value));
|
|
162
236
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
/* @__PURE__ */ jsxs(
|
|
240
|
+
PopoverContent,
|
|
241
|
+
{
|
|
242
|
+
id: dialogId,
|
|
243
|
+
role: "dialog",
|
|
244
|
+
"aria-label": t("dataEntry.datePicker.openCalendar") ?? "Calendar",
|
|
245
|
+
className: "ui-control-panel-flush",
|
|
246
|
+
side: placement.startsWith("top") ? "top" : "bottom",
|
|
247
|
+
align: placement.endsWith("end") ? "end" : "start",
|
|
248
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
249
|
+
children: [
|
|
250
|
+
presets?.length ? /* @__PURE__ */ jsx(Flex, { wrap: true, gap: "xs", pad: "sm", children: presets.map((preset, index) => /* @__PURE__ */ jsx(
|
|
251
|
+
Button,
|
|
252
|
+
{
|
|
253
|
+
variant: "ghost",
|
|
254
|
+
size: "sm",
|
|
255
|
+
type: "button",
|
|
256
|
+
onClick: () => {
|
|
257
|
+
const date = typeof preset.value === "function" ? preset.value() : preset.value;
|
|
258
|
+
if (!allowed(date)) return;
|
|
259
|
+
choose(date);
|
|
260
|
+
if (!needConfirm && !multiple) setOpen(false);
|
|
261
|
+
},
|
|
262
|
+
children: preset.label
|
|
263
|
+
},
|
|
264
|
+
index
|
|
265
|
+
)) }) : null,
|
|
266
|
+
picker === "date" || picker === "week" ? multiple ? /* @__PURE__ */ jsx(
|
|
267
|
+
Calendar,
|
|
268
|
+
{
|
|
269
|
+
mode: "multiple",
|
|
270
|
+
selected: Array.isArray(working) ? working : [],
|
|
271
|
+
defaultMonth: selectedDate,
|
|
272
|
+
locale: dayPickerLocale,
|
|
273
|
+
onSelect: choose,
|
|
274
|
+
disabled: (day) => !allowed(day),
|
|
275
|
+
cellRender,
|
|
276
|
+
showWeekNumber: showWeek,
|
|
277
|
+
startMonth: minimum,
|
|
278
|
+
endMonth: maximum,
|
|
279
|
+
showToday,
|
|
280
|
+
showClose,
|
|
281
|
+
onClose: () => setOpen(false)
|
|
282
|
+
}
|
|
283
|
+
) : /* @__PURE__ */ jsx(
|
|
284
|
+
Calendar,
|
|
285
|
+
{
|
|
286
|
+
mode: "single",
|
|
287
|
+
selected: selectedDate,
|
|
288
|
+
defaultMonth: selectedDate,
|
|
289
|
+
showWeekNumber: showWeek,
|
|
290
|
+
onSelect: (date) => {
|
|
291
|
+
if (date && showTime && selectedDate)
|
|
292
|
+
date.setHours(
|
|
293
|
+
selectedDate.getHours(),
|
|
294
|
+
selectedDate.getMinutes(),
|
|
295
|
+
selectedDate.getSeconds()
|
|
296
|
+
);
|
|
297
|
+
choose(date);
|
|
298
|
+
if (!needConfirm && !multiple) setOpen(false);
|
|
299
|
+
},
|
|
300
|
+
locale: dayPickerLocale,
|
|
301
|
+
disabled: [
|
|
302
|
+
...minimum ? [{ before: minimum }] : [],
|
|
303
|
+
...maximum ? [{ after: maximum }] : [],
|
|
304
|
+
...disabledDate ? [disabledDate] : []
|
|
305
|
+
],
|
|
306
|
+
cellRender,
|
|
307
|
+
startMonth: minimum,
|
|
308
|
+
endMonth: maximum,
|
|
309
|
+
showToday,
|
|
310
|
+
showClose,
|
|
311
|
+
onClose: () => setOpen(false)
|
|
312
|
+
}
|
|
313
|
+
) : /* @__PURE__ */ jsxs("div", { className: "ui-month-picker-panel", children: [
|
|
314
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", align: "center", children: [
|
|
315
|
+
/* @__PURE__ */ jsx(
|
|
316
|
+
Button,
|
|
317
|
+
{
|
|
318
|
+
type: "button",
|
|
319
|
+
variant: "ghost",
|
|
320
|
+
"aria-label": t("dataEntry.monthPicker.previousYear"),
|
|
321
|
+
onClick: () => setViewYear(viewYear - (picker === "year" ? 12 : 1)),
|
|
322
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": "true" })
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
/* @__PURE__ */ jsx("span", { "aria-live": "polite", children: new Intl.NumberFormat(locale, { useGrouping: false }).format(viewYear) }),
|
|
326
|
+
/* @__PURE__ */ jsx(
|
|
327
|
+
Button,
|
|
328
|
+
{
|
|
329
|
+
type: "button",
|
|
330
|
+
variant: "ghost",
|
|
331
|
+
"aria-label": t("dataEntry.monthPicker.nextYear"),
|
|
332
|
+
onClick: () => setViewYear(viewYear + (picker === "year" ? 12 : 1)),
|
|
333
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true" })
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
] }),
|
|
337
|
+
/* @__PURE__ */ jsx("div", { className: "ui-month-picker-grid", children: Array.from({ length: picker === "quarter" ? 4 : 12 }, (_, index) => {
|
|
338
|
+
const date = picker === "year" ? new Date(viewYear + index, 0, 1) : new Date(viewYear, index * (picker === "quarter" ? 3 : 1), 1);
|
|
339
|
+
const label = picker === "year" ? new Intl.DateTimeFormat(locale, { year: "numeric" }).format(date) : picker === "quarter" ? t("dataEntry.datePicker.quarter", { quarter: index + 1 }) : new Intl.DateTimeFormat(locale, { month: "short" }).format(date);
|
|
340
|
+
const selected = (Array.isArray(working) ? working : working ? [working] : []).some((day) => +periodDate(day) === +date);
|
|
341
|
+
return /* @__PURE__ */ jsx(
|
|
342
|
+
Button,
|
|
343
|
+
{
|
|
344
|
+
type: "button",
|
|
345
|
+
variant: selected ? "default" : "ghost",
|
|
346
|
+
"aria-pressed": selected,
|
|
347
|
+
disabled: !allowed(date),
|
|
348
|
+
onClick: () => {
|
|
349
|
+
choose(date);
|
|
350
|
+
if (!needConfirm && !multiple) setOpen(false);
|
|
351
|
+
},
|
|
352
|
+
children: label
|
|
353
|
+
},
|
|
354
|
+
index
|
|
355
|
+
);
|
|
356
|
+
}) })
|
|
357
|
+
] }),
|
|
358
|
+
showTime ? /* @__PURE__ */ jsx(Flex, { pad: "sm", children: /* @__PURE__ */ jsx(
|
|
359
|
+
TimePicker,
|
|
360
|
+
{
|
|
361
|
+
...typeof showTime === "object" ? showTime : {},
|
|
362
|
+
"aria-label": t("dataEntry.timePicker.openPicker"),
|
|
363
|
+
value: selectedDate ? [
|
|
364
|
+
selectedDate.getHours(),
|
|
365
|
+
selectedDate.getMinutes(),
|
|
366
|
+
...typeof showTime === "object" && showTime.showSeconds ? [selectedDate.getSeconds()] : []
|
|
367
|
+
].map((n) => String(n).padStart(2, "0")).join(":") : "",
|
|
368
|
+
onValueChange: (time) => {
|
|
369
|
+
if (!time) return;
|
|
370
|
+
const date = new Date(selectedDate ?? /* @__PURE__ */ new Date());
|
|
371
|
+
const [h, m, sec = 0] = time.split(":").map(Number);
|
|
372
|
+
date.setHours(h, m, sec, 0);
|
|
373
|
+
choose(date);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
) }) : null,
|
|
377
|
+
needConfirm ? /* @__PURE__ */ jsx(Flex, { pad: "sm", justify: "end", children: /* @__PURE__ */ jsx(
|
|
378
|
+
Button,
|
|
379
|
+
{
|
|
380
|
+
type: "button",
|
|
381
|
+
disabled: !selectedDate || !allowed(selectedDate) || !timeAllowed(selectedDate),
|
|
382
|
+
onClick: () => {
|
|
383
|
+
if (selectedDate && allowed(selectedDate) && timeAllowed(selectedDate)) {
|
|
384
|
+
emit(working);
|
|
385
|
+
setText(display(working));
|
|
386
|
+
setOpen(false);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
children: t("dataEntry.timePicker.confirm")
|
|
390
|
+
}
|
|
391
|
+
) }) : null,
|
|
392
|
+
renderExtraFooter?.()
|
|
393
|
+
]
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] }) })
|
|
397
|
+
] });
|
|
167
398
|
}
|
|
168
399
|
export {
|
|
169
400
|
DatePicker
|
|
@@ -8,4 +8,4 @@ export type { DateRangePickerProp, DateRangePickerProp as DateRangePickerProps,
|
|
|
8
8
|
* `${name}_to`, screen-reader friendly, e2e-testable by filling either input); the
|
|
9
9
|
* range calendar is the visual affordance.
|
|
10
10
|
*/
|
|
11
|
-
export declare function DateRangePicker({ value: valueProp, defaultValue, onValueChange, placeholder, disabled, className, id, name, locale: localeProp, showToday, showClose, fromDate, toDate, allowClear, ...ariaProps }: DateRangePickerProp): React.JSX.Element;
|
|
11
|
+
export declare function DateRangePicker({ value: valueProp, defaultValue, onValueChange, placeholder, disabled, className, id, name, locale: localeProp, showToday, showClose, fromDate, toDate, disabledDate, cellRender, allowClear, format, parseFormat, minDate, maxDate, showWeek, presets, needConfirm, allowEmpty, order, open: openProp, defaultOpen, onOpenChange, inputReadOnly, preserveInvalidOnBlur, placement, renderExtraFooter, size, status, variant, ref, ...ariaProps }: DateRangePickerProp): React.JSX.Element;
|