@uipath/apollo-wind 2.80.1 → 2.81.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/dist/components/ui/calendar.cjs +5 -2
- package/dist/components/ui/calendar.d.ts +1 -1
- package/dist/components/ui/calendar.js +5 -2
- package/dist/components/ui/date-picker.cjs +27 -14
- package/dist/components/ui/date-picker.d.ts +16 -0
- package/dist/components/ui/date-picker.js +28 -15
- package/dist/components/ui/datetime-picker.cjs +41 -28
- package/dist/components/ui/datetime-picker.d.ts +13 -0
- package/dist/components/ui/datetime-picker.js +42 -29
- package/dist/components/ui/editable-cell.cjs +5 -1
- package/dist/components/ui/editable-cell.js +5 -1
- package/dist/components/ui/index.cjs +179 -166
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/locale-provider.cjs +124 -0
- package/dist/components/ui/locale-provider.d.ts +57 -0
- package/dist/components/ui/locale-provider.js +78 -0
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +3 -1
- package/dist/components/ui/quick-form-field/quick-form-field.js +3 -1
- package/dist/components/ui/quick-form-field/utils.cjs +2 -2
- package/dist/components/ui/quick-form-field/utils.d.ts +2 -1
- package/dist/components/ui/quick-form-field/utils.js +2 -2
- package/dist/components/ui/time-field.cjs +191 -0
- package/dist/components/ui/time-field.d.ts +24 -0
- package/dist/components/ui/time-field.js +157 -0
- package/dist/index.cjs +18 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -1
- package/dist/lib/date-locale.cjs +184 -0
- package/dist/lib/date-locale.d.ts +31 -0
- package/dist/lib/date-locale.js +129 -0
- package/dist/styles.css +23 -0
- package/package.json +8 -8
|
@@ -34,14 +34,17 @@ const external_react_namespaceObject = require("react");
|
|
|
34
34
|
const external_react_day_picker_namespaceObject = require("react-day-picker");
|
|
35
35
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
36
36
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
37
|
-
|
|
37
|
+
const external_locale_provider_cjs_namespaceObject = require("./locale-provider.cjs");
|
|
38
|
+
function Calendar({ className, classNames, showOutsideDays = true, captionLayout = 'label', buttonVariant = 'ghost', formatters, components, locale, ...props }) {
|
|
38
39
|
const defaultClassNames = (0, external_react_day_picker_namespaceObject.getDefaultClassNames)();
|
|
40
|
+
const inheritedLocale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)();
|
|
39
41
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_day_picker_namespaceObject.DayPicker, {
|
|
40
42
|
showOutsideDays: showOutsideDays,
|
|
41
43
|
className: (0, index_cjs_namespaceObject.cn)('bg-background group/calendar p-4 [--cell-size:2.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent', String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className),
|
|
42
44
|
captionLayout: captionLayout,
|
|
45
|
+
locale: locale ?? inheritedLocale,
|
|
43
46
|
formatters: {
|
|
44
|
-
formatMonthDropdown: (date)=>date.toLocaleString('
|
|
47
|
+
formatMonthDropdown: (date, dateLib)=>dateLib ? dateLib.format(date, 'LLL') : date.toLocaleString('en-US', {
|
|
45
48
|
month: 'short'
|
|
46
49
|
}),
|
|
47
50
|
...formatters
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DayButton, DayPicker } from 'react-day-picker';
|
|
3
3
|
import { Button } from './button';
|
|
4
|
-
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
4
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, locale, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
5
5
|
buttonVariant?: React.ComponentProps<typeof Button>['variant'];
|
|
6
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
declare function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,14 +5,17 @@ import { useEffect, useRef } from "react";
|
|
|
5
5
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
6
6
|
import { Button, buttonVariants } from "./button.js";
|
|
7
7
|
import { cn } from "../../lib/index.js";
|
|
8
|
-
|
|
8
|
+
import { useDateLocale } from "./locale-provider.js";
|
|
9
|
+
function Calendar({ className, classNames, showOutsideDays = true, captionLayout = 'label', buttonVariant = 'ghost', formatters, components, locale, ...props }) {
|
|
9
10
|
const defaultClassNames = getDefaultClassNames();
|
|
11
|
+
const inheritedLocale = useDateLocale();
|
|
10
12
|
return /*#__PURE__*/ jsx(DayPicker, {
|
|
11
13
|
showOutsideDays: showOutsideDays,
|
|
12
14
|
className: cn('bg-background group/calendar p-4 [--cell-size:2.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent', String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className),
|
|
13
15
|
captionLayout: captionLayout,
|
|
16
|
+
locale: locale ?? inheritedLocale,
|
|
14
17
|
formatters: {
|
|
15
|
-
formatMonthDropdown: (date)=>date.toLocaleString('
|
|
18
|
+
formatMonthDropdown: (date, dateLib)=>dateLib ? dateLib.format(date, 'LLL') : date.toLocaleString('en-US', {
|
|
16
19
|
month: 'short'
|
|
17
20
|
}),
|
|
18
21
|
...formatters
|
|
@@ -37,12 +37,18 @@ const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
|
37
37
|
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
38
38
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
39
39
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
40
|
+
const date_locale_cjs_namespaceObject = require("../../lib/date-locale.cjs");
|
|
40
41
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
41
42
|
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
42
|
-
const
|
|
43
|
+
const external_locale_provider_cjs_namespaceObject = require("./locale-provider.cjs");
|
|
44
|
+
const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder: placeholderProp, className, locale: localeProp, strings: stringsProp, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
43
45
|
const generatedId = external_react_namespaceObject.useId();
|
|
44
46
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
45
47
|
const date = value instanceof Date && (0, external_date_fns_namespaceObject.isValid)(value) ? value : void 0;
|
|
48
|
+
const locale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)(localeProp);
|
|
49
|
+
const strings = (0, external_locale_provider_cjs_namespaceObject.useDatePickerStrings)(stringsProp);
|
|
50
|
+
const placeholder = placeholderProp ?? strings.pickDate;
|
|
51
|
+
const displayValue = date ? (0, date_locale_cjs_namespaceObject.formatLongDate)(date, locale) : void 0;
|
|
46
52
|
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
47
53
|
const grouped = group.inGroup;
|
|
48
54
|
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
@@ -54,7 +60,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
54
60
|
});
|
|
55
61
|
const triggerProps = {
|
|
56
62
|
id,
|
|
57
|
-
'aria-label': id || ariaLabelledBy ? void 0 :
|
|
63
|
+
'aria-label': id || ariaLabelledBy ? void 0 : displayValue ? strings.selectedDate(displayValue) : placeholder,
|
|
58
64
|
'aria-labelledby': ariaLabelledBy,
|
|
59
65
|
...validation.aria,
|
|
60
66
|
disabled: disabled || group.disabled
|
|
@@ -69,9 +75,9 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
69
75
|
...triggerProps,
|
|
70
76
|
className: className,
|
|
71
77
|
placeholder: placeholder,
|
|
72
|
-
children:
|
|
78
|
+
children: displayValue && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
73
79
|
className: "truncate",
|
|
74
|
-
children:
|
|
80
|
+
children: displayValue
|
|
75
81
|
})
|
|
76
82
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
77
83
|
asChild: true,
|
|
@@ -82,7 +88,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
82
88
|
className: (0, index_cjs_namespaceObject.cn)('w-full justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
83
89
|
children: [
|
|
84
90
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
85
|
-
|
|
91
|
+
displayValue ?? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
86
92
|
className: "text-foreground-muted",
|
|
87
93
|
children: placeholder
|
|
88
94
|
})
|
|
@@ -97,6 +103,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
97
103
|
selected: date,
|
|
98
104
|
onSelect: onValueChange,
|
|
99
105
|
initialFocus: true,
|
|
106
|
+
locale: locale,
|
|
100
107
|
...calendarProps
|
|
101
108
|
})
|
|
102
109
|
})
|
|
@@ -109,10 +116,15 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
109
116
|
]
|
|
110
117
|
});
|
|
111
118
|
});
|
|
112
|
-
const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder
|
|
119
|
+
const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder: placeholderProp, className, locale: localeProp, strings: stringsProp, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
113
120
|
const generatedId = external_react_namespaceObject.useId();
|
|
114
121
|
const validationId = errorId ?? `${id ?? `date-range-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
115
|
-
const
|
|
122
|
+
const locale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)(localeProp);
|
|
123
|
+
const strings = (0, external_locale_provider_cjs_namespaceObject.useDatePickerStrings)(stringsProp);
|
|
124
|
+
const placeholder = placeholderProp ?? strings.pickDateRange;
|
|
125
|
+
const from = value?.from ? (0, date_locale_cjs_namespaceObject.formatMediumDate)(value.from, locale) : void 0;
|
|
126
|
+
const to = value?.to ? (0, date_locale_cjs_namespaceObject.formatMediumDate)(value.to, locale) : void 0;
|
|
127
|
+
const computedLabel = from ? to ? strings.selectedRange(from, to) : strings.selectedDate(from) : placeholder;
|
|
116
128
|
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
117
129
|
const grouped = group.inGroup;
|
|
118
130
|
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
@@ -139,11 +151,11 @@ const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject
|
|
|
139
151
|
...triggerProps,
|
|
140
152
|
className: className,
|
|
141
153
|
placeholder: placeholder,
|
|
142
|
-
children:
|
|
154
|
+
children: from && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
143
155
|
className: "truncate",
|
|
144
156
|
children: [
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
from,
|
|
158
|
+
to && ` - ${to}`
|
|
147
159
|
]
|
|
148
160
|
})
|
|
149
161
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
@@ -155,13 +167,13 @@ const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject
|
|
|
155
167
|
className: (0, index_cjs_namespaceObject.cn)('w-[300px] justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
156
168
|
children: [
|
|
157
169
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
158
|
-
|
|
170
|
+
from ? to ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
159
171
|
children: [
|
|
160
|
-
|
|
172
|
+
from,
|
|
161
173
|
" - ",
|
|
162
|
-
|
|
174
|
+
to
|
|
163
175
|
]
|
|
164
|
-
}) :
|
|
176
|
+
}) : from : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
165
177
|
className: "text-foreground-muted",
|
|
166
178
|
children: placeholder
|
|
167
179
|
})
|
|
@@ -179,6 +191,7 @@ const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject
|
|
|
179
191
|
onSelect: onValueChange,
|
|
180
192
|
numberOfMonths: 2,
|
|
181
193
|
required: false,
|
|
194
|
+
locale: locale,
|
|
182
195
|
...calendarProps
|
|
183
196
|
})
|
|
184
197
|
})
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { DateRange } from 'react-day-picker';
|
|
3
3
|
import { Calendar } from './calendar';
|
|
4
|
+
import { type DateLocale } from '../../lib/date-locale';
|
|
5
|
+
import { type DatePickerStrings } from './locale-provider';
|
|
4
6
|
export interface DatePickerProps {
|
|
5
7
|
/** Applied to the trigger button, so a `<label htmlFor>` pointing at it associates correctly. */
|
|
6
8
|
id?: string;
|
|
@@ -21,6 +23,13 @@ export interface DatePickerProps {
|
|
|
21
23
|
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
22
24
|
'aria-describedby'?: string;
|
|
23
25
|
'aria-errormessage'?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Language tag or locale for this picker, over the nearest `LocaleProvider`'s.
|
|
28
|
+
* @see LocaleProvider
|
|
29
|
+
*/
|
|
30
|
+
locale?: string | DateLocale;
|
|
31
|
+
/** Translations for this picker, over the nearest `LocaleProvider`'s. */
|
|
32
|
+
strings?: Partial<DatePickerStrings>;
|
|
24
33
|
calendarProps?: Omit<React.ComponentProps<typeof Calendar>, 'mode' | 'selected' | 'onSelect' | 'initialFocus'>;
|
|
25
34
|
}
|
|
26
35
|
export declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -44,6 +53,13 @@ export interface DateRangePickerProps {
|
|
|
44
53
|
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
45
54
|
'aria-describedby'?: string;
|
|
46
55
|
'aria-errormessage'?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Language tag or locale for this picker, over the nearest `LocaleProvider`'s.
|
|
58
|
+
* @see LocaleProvider
|
|
59
|
+
*/
|
|
60
|
+
locale?: string | DateLocale;
|
|
61
|
+
/** Translations for this picker, over the nearest `LocaleProvider`'s. */
|
|
62
|
+
strings?: Partial<DatePickerStrings>;
|
|
47
63
|
calendarProps?: Omit<React.ComponentProps<typeof Calendar>, 'mode' | 'selected' | 'onSelect' | 'initialFocus' | 'defaultMonth' | 'numberOfMonths' | 'required'>;
|
|
48
64
|
}
|
|
49
65
|
export declare const DateRangePicker: React.ForwardRefExoticComponent<DateRangePickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { isValid } from "date-fns";
|
|
4
4
|
import { CalendarIcon } from "lucide-react";
|
|
5
5
|
import { forwardRef, useId } from "react";
|
|
6
6
|
import { Button } from "./button.js";
|
|
@@ -8,12 +8,18 @@ import { Calendar } from "./calendar.js";
|
|
|
8
8
|
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
9
9
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
10
10
|
import { cn } from "../../lib/index.js";
|
|
11
|
+
import { formatLongDate, formatMediumDate } from "../../lib/date-locale.js";
|
|
11
12
|
import { FormFieldError } from "./form-field.js";
|
|
12
13
|
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
13
|
-
|
|
14
|
+
import { useDateLocale, useDatePickerStrings } from "./locale-provider.js";
|
|
15
|
+
const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder: placeholderProp, className, locale: localeProp, strings: stringsProp, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
14
16
|
const generatedId = useId();
|
|
15
17
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
16
18
|
const date = value instanceof Date && isValid(value) ? value : void 0;
|
|
19
|
+
const locale = useDateLocale(localeProp);
|
|
20
|
+
const strings = useDatePickerStrings(stringsProp);
|
|
21
|
+
const placeholder = placeholderProp ?? strings.pickDate;
|
|
22
|
+
const displayValue = date ? formatLongDate(date, locale) : void 0;
|
|
17
23
|
const group = useInputGroup();
|
|
18
24
|
const grouped = group.inGroup;
|
|
19
25
|
const validation = useControlValidation(group, {
|
|
@@ -25,7 +31,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
25
31
|
});
|
|
26
32
|
const triggerProps = {
|
|
27
33
|
id,
|
|
28
|
-
'aria-label': id || ariaLabelledBy ? void 0 :
|
|
34
|
+
'aria-label': id || ariaLabelledBy ? void 0 : displayValue ? strings.selectedDate(displayValue) : placeholder,
|
|
29
35
|
'aria-labelledby': ariaLabelledBy,
|
|
30
36
|
...validation.aria,
|
|
31
37
|
disabled: disabled || group.disabled
|
|
@@ -40,9 +46,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
40
46
|
...triggerProps,
|
|
41
47
|
className: className,
|
|
42
48
|
placeholder: placeholder,
|
|
43
|
-
children:
|
|
49
|
+
children: displayValue && /*#__PURE__*/ jsx("span", {
|
|
44
50
|
className: "truncate",
|
|
45
|
-
children:
|
|
51
|
+
children: displayValue
|
|
46
52
|
})
|
|
47
53
|
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
48
54
|
asChild: true,
|
|
@@ -53,7 +59,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
53
59
|
className: cn('w-full justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
54
60
|
children: [
|
|
55
61
|
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
56
|
-
|
|
62
|
+
displayValue ?? /*#__PURE__*/ jsx("span", {
|
|
57
63
|
className: "text-foreground-muted",
|
|
58
64
|
children: placeholder
|
|
59
65
|
})
|
|
@@ -68,6 +74,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
68
74
|
selected: date,
|
|
69
75
|
onSelect: onValueChange,
|
|
70
76
|
initialFocus: true,
|
|
77
|
+
locale: locale,
|
|
71
78
|
...calendarProps
|
|
72
79
|
})
|
|
73
80
|
})
|
|
@@ -80,10 +87,15 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
80
87
|
]
|
|
81
88
|
});
|
|
82
89
|
});
|
|
83
|
-
const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder
|
|
90
|
+
const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder: placeholderProp, className, locale: localeProp, strings: stringsProp, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
84
91
|
const generatedId = useId();
|
|
85
92
|
const validationId = errorId ?? `${id ?? `date-range-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
86
|
-
const
|
|
93
|
+
const locale = useDateLocale(localeProp);
|
|
94
|
+
const strings = useDatePickerStrings(stringsProp);
|
|
95
|
+
const placeholder = placeholderProp ?? strings.pickDateRange;
|
|
96
|
+
const from = value?.from ? formatMediumDate(value.from, locale) : void 0;
|
|
97
|
+
const to = value?.to ? formatMediumDate(value.to, locale) : void 0;
|
|
98
|
+
const computedLabel = from ? to ? strings.selectedRange(from, to) : strings.selectedDate(from) : placeholder;
|
|
87
99
|
const group = useInputGroup();
|
|
88
100
|
const grouped = group.inGroup;
|
|
89
101
|
const validation = useControlValidation(group, {
|
|
@@ -110,11 +122,11 @@ const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, valu
|
|
|
110
122
|
...triggerProps,
|
|
111
123
|
className: className,
|
|
112
124
|
placeholder: placeholder,
|
|
113
|
-
children:
|
|
125
|
+
children: from && /*#__PURE__*/ jsxs("span", {
|
|
114
126
|
className: "truncate",
|
|
115
127
|
children: [
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
from,
|
|
129
|
+
to && ` - ${to}`
|
|
118
130
|
]
|
|
119
131
|
})
|
|
120
132
|
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
@@ -126,13 +138,13 @@ const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, valu
|
|
|
126
138
|
className: cn('w-[300px] justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
127
139
|
children: [
|
|
128
140
|
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
129
|
-
|
|
141
|
+
from ? to ? /*#__PURE__*/ jsxs(Fragment, {
|
|
130
142
|
children: [
|
|
131
|
-
|
|
143
|
+
from,
|
|
132
144
|
" - ",
|
|
133
|
-
|
|
145
|
+
to
|
|
134
146
|
]
|
|
135
|
-
}) :
|
|
147
|
+
}) : from : /*#__PURE__*/ jsx("span", {
|
|
136
148
|
className: "text-foreground-muted",
|
|
137
149
|
children: placeholder
|
|
138
150
|
})
|
|
@@ -150,6 +162,7 @@ const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, valu
|
|
|
150
162
|
onSelect: onValueChange,
|
|
151
163
|
numberOfMonths: 2,
|
|
152
164
|
required: false,
|
|
165
|
+
locale: locale,
|
|
153
166
|
...calendarProps
|
|
154
167
|
})
|
|
155
168
|
})
|
|
@@ -32,30 +32,42 @@ const external_lucide_react_namespaceObject = require("lucide-react");
|
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
34
34
|
const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
35
|
-
const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
36
35
|
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
37
|
-
const external_label_cjs_namespaceObject = require("./label.cjs");
|
|
38
36
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
39
37
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
38
|
+
const date_locale_cjs_namespaceObject = require("../../lib/date-locale.cjs");
|
|
40
39
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
41
40
|
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
42
|
-
const
|
|
41
|
+
const external_locale_provider_cjs_namespaceObject = require("./locale-provider.cjs");
|
|
42
|
+
const external_time_field_cjs_namespaceObject = require("./time-field.cjs");
|
|
43
|
+
function timeOf(date) {
|
|
44
|
+
return date ? {
|
|
45
|
+
hours: date.getHours(),
|
|
46
|
+
minutes: date.getMinutes()
|
|
47
|
+
} : void 0;
|
|
48
|
+
}
|
|
49
|
+
const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ value, onValueChange, onOpenChange, disabled, placeholder: placeholderProp, className, use12Hour: use12HourProp, locale: localeProp, strings: stringsProp, id, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
43
50
|
const [open, setOpenState] = external_react_namespaceObject.useState(false);
|
|
44
51
|
const setOpen = (next)=>{
|
|
45
52
|
setOpenState(next);
|
|
46
53
|
onOpenChange?.(next);
|
|
47
54
|
};
|
|
48
55
|
const generatedId = external_react_namespaceObject.useId();
|
|
49
|
-
const
|
|
56
|
+
const baseId = id ?? `datetime-picker-${generatedId.replace(/:/g, '')}`;
|
|
57
|
+
const validationId = errorId ?? `${baseId}-error`;
|
|
58
|
+
const timeLabelId = `${baseId}-time-label`;
|
|
59
|
+
const locale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)(localeProp);
|
|
60
|
+
const strings = (0, external_locale_provider_cjs_namespaceObject.useDatePickerStrings)(stringsProp);
|
|
61
|
+
const placeholder = placeholderProp ?? strings.pickDateTime;
|
|
50
62
|
const date = value instanceof Date && (0, external_date_fns_namespaceObject.isValid)(value) ? value : void 0;
|
|
51
63
|
const [selectedDate, setSelectedDate] = external_react_namespaceObject.useState(date);
|
|
52
|
-
const [
|
|
64
|
+
const [time, setTime] = external_react_namespaceObject.useState(()=>timeOf(date));
|
|
53
65
|
const valueTime = date?.getTime();
|
|
54
66
|
const [seededTime, setSeededTime] = external_react_namespaceObject.useState(valueTime);
|
|
55
67
|
if (!Object.is(valueTime, seededTime)) {
|
|
56
68
|
setSeededTime(valueTime);
|
|
57
69
|
setSelectedDate(date);
|
|
58
|
-
|
|
70
|
+
setTime(timeOf(date));
|
|
59
71
|
}
|
|
60
72
|
const handleDateSelect = (date)=>{
|
|
61
73
|
if (!date) return;
|
|
@@ -64,26 +76,22 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
64
76
|
date.setMinutes(selectedDate.getMinutes());
|
|
65
77
|
date.setSeconds(selectedDate.getSeconds());
|
|
66
78
|
date.setMilliseconds(selectedDate.getMilliseconds());
|
|
67
|
-
}
|
|
79
|
+
} else if (time) date.setHours(time.hours, time.minutes);
|
|
68
80
|
setSelectedDate(date);
|
|
69
81
|
onValueChange?.(date);
|
|
70
82
|
};
|
|
71
|
-
const handleTimeChange = (
|
|
72
|
-
|
|
73
|
-
setTimeValue(time);
|
|
83
|
+
const handleTimeChange = (next)=>{
|
|
84
|
+
setTime(next);
|
|
74
85
|
if (!selectedDate) return;
|
|
75
|
-
const [hours, minutes] = time.split(':').map(Number);
|
|
76
86
|
const newDate = new Date(selectedDate);
|
|
77
|
-
newDate.setHours(hours);
|
|
78
|
-
newDate.setMinutes(minutes);
|
|
87
|
+
newDate.setHours(next.hours);
|
|
88
|
+
newDate.setMinutes(next.minutes);
|
|
79
89
|
setSelectedDate(newDate);
|
|
80
90
|
onValueChange?.(newDate);
|
|
81
91
|
};
|
|
82
92
|
const formatDisplayValue = ()=>{
|
|
83
93
|
if (!selectedDate) return null;
|
|
84
|
-
|
|
85
|
-
const timePart = (0, external_date_fns_namespaceObject.format)(selectedDate, use12Hour ? 'hh:mm a' : 'HH:mm');
|
|
86
|
-
return `${datePart} at ${timePart}`;
|
|
94
|
+
return (0, date_locale_cjs_namespaceObject.formatDateTime)(selectedDate, locale, use12HourProp);
|
|
87
95
|
};
|
|
88
96
|
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
89
97
|
const grouped = group.inGroup;
|
|
@@ -144,25 +152,30 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
144
152
|
mode: "single",
|
|
145
153
|
selected: selectedDate,
|
|
146
154
|
onSelect: handleDateSelect,
|
|
147
|
-
initialFocus: true
|
|
155
|
+
initialFocus: true,
|
|
156
|
+
locale: locale
|
|
148
157
|
}),
|
|
149
158
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
150
159
|
className: "border-t pt-3 space-y-2",
|
|
151
160
|
children: [
|
|
152
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(
|
|
161
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
162
|
+
id: timeLabelId,
|
|
153
163
|
className: "text-sm font-medium flex items-center gap-2",
|
|
154
164
|
children: [
|
|
155
165
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Clock, {
|
|
156
|
-
className: "h-4 w-4"
|
|
166
|
+
className: "h-4 w-4",
|
|
167
|
+
"aria-hidden": "true"
|
|
157
168
|
}),
|
|
158
|
-
|
|
169
|
+
strings.time
|
|
159
170
|
]
|
|
160
171
|
}),
|
|
161
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
162
|
-
|
|
163
|
-
value:
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_time_field_cjs_namespaceObject.TimeField, {
|
|
173
|
+
"aria-labelledby": timeLabelId,
|
|
174
|
+
value: time,
|
|
175
|
+
onValueChange: handleTimeChange,
|
|
176
|
+
use12Hour: (0, date_locale_cjs_namespaceObject.resolveUse12Hour)(use12HourProp, locale),
|
|
177
|
+
locale: locale,
|
|
178
|
+
strings: strings
|
|
166
179
|
})
|
|
167
180
|
]
|
|
168
181
|
}),
|
|
@@ -174,17 +187,17 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
174
187
|
className: "w-full",
|
|
175
188
|
onClick: ()=>{
|
|
176
189
|
setSelectedDate(void 0);
|
|
177
|
-
|
|
190
|
+
setTime(void 0);
|
|
178
191
|
onValueChange?.(void 0);
|
|
179
192
|
setOpen(false);
|
|
180
193
|
},
|
|
181
|
-
children:
|
|
194
|
+
children: strings.clear
|
|
182
195
|
}),
|
|
183
196
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
184
197
|
className: "w-full",
|
|
185
198
|
onClick: ()=>setOpen(false),
|
|
186
199
|
disabled: !selectedDate,
|
|
187
|
-
children:
|
|
200
|
+
children: strings.done
|
|
188
201
|
})
|
|
189
202
|
]
|
|
190
203
|
})
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type DateLocale } from '../../lib/date-locale';
|
|
3
|
+
import { type DatePickerStrings } from './locale-provider';
|
|
2
4
|
export interface DateTimePickerProps {
|
|
3
5
|
/** Applied to the trigger button, so a `<label htmlFor>` pointing at it associates correctly. */
|
|
4
6
|
id?: string;
|
|
@@ -9,7 +11,18 @@ export interface DateTimePickerProps {
|
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
placeholder?: string;
|
|
11
13
|
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Shows a 12-hour clock with AM/PM. Unset, the clock follows the locale when one is set
|
|
16
|
+
* (here or on a `LocaleProvider`), else 24-hour.
|
|
17
|
+
*/
|
|
12
18
|
use12Hour?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Language tag or locale for this picker, over the nearest `LocaleProvider`'s.
|
|
21
|
+
* @see LocaleProvider
|
|
22
|
+
*/
|
|
23
|
+
locale?: string | DateLocale;
|
|
24
|
+
/** Translations for this picker, over the nearest `LocaleProvider`'s. */
|
|
25
|
+
strings?: Partial<DatePickerStrings>;
|
|
13
26
|
/**
|
|
14
27
|
* Field-specific feedback rendered immediately below the trigger.
|
|
15
28
|
* Keep the message focused on what went wrong and how to resolve it.
|