@uipath/apollo-wind 2.80.1 → 2.82.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 +176 -163
- 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 +5 -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
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isValid } from "date-fns";
|
|
3
3
|
import { CalendarIcon, Clock } from "lucide-react";
|
|
4
4
|
import { forwardRef, useId, useState } from "react";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { Calendar } from "./calendar.js";
|
|
7
|
-
import { Input } from "./input.js";
|
|
8
7
|
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
9
|
-
import { Label } from "./label.js";
|
|
10
8
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
11
9
|
import { cn } from "../../lib/index.js";
|
|
10
|
+
import { formatDateTime, resolveUse12Hour } from "../../lib/date-locale.js";
|
|
12
11
|
import { FormFieldError } from "./form-field.js";
|
|
13
12
|
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
14
|
-
|
|
13
|
+
import { useDateLocale, useDatePickerStrings } from "./locale-provider.js";
|
|
14
|
+
import { TimeField } from "./time-field.js";
|
|
15
|
+
function timeOf(date) {
|
|
16
|
+
return date ? {
|
|
17
|
+
hours: date.getHours(),
|
|
18
|
+
minutes: date.getMinutes()
|
|
19
|
+
} : void 0;
|
|
20
|
+
}
|
|
21
|
+
const datetime_picker_DateTimePicker = /*#__PURE__*/ 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) {
|
|
15
22
|
const [open, setOpenState] = useState(false);
|
|
16
23
|
const setOpen = (next)=>{
|
|
17
24
|
setOpenState(next);
|
|
18
25
|
onOpenChange?.(next);
|
|
19
26
|
};
|
|
20
27
|
const generatedId = useId();
|
|
21
|
-
const
|
|
28
|
+
const baseId = id ?? `datetime-picker-${generatedId.replace(/:/g, '')}`;
|
|
29
|
+
const validationId = errorId ?? `${baseId}-error`;
|
|
30
|
+
const timeLabelId = `${baseId}-time-label`;
|
|
31
|
+
const locale = useDateLocale(localeProp);
|
|
32
|
+
const strings = useDatePickerStrings(stringsProp);
|
|
33
|
+
const placeholder = placeholderProp ?? strings.pickDateTime;
|
|
22
34
|
const date = value instanceof Date && isValid(value) ? value : void 0;
|
|
23
35
|
const [selectedDate, setSelectedDate] = useState(date);
|
|
24
|
-
const [
|
|
36
|
+
const [time, setTime] = useState(()=>timeOf(date));
|
|
25
37
|
const valueTime = date?.getTime();
|
|
26
38
|
const [seededTime, setSeededTime] = useState(valueTime);
|
|
27
39
|
if (!Object.is(valueTime, seededTime)) {
|
|
28
40
|
setSeededTime(valueTime);
|
|
29
41
|
setSelectedDate(date);
|
|
30
|
-
|
|
42
|
+
setTime(timeOf(date));
|
|
31
43
|
}
|
|
32
44
|
const handleDateSelect = (date)=>{
|
|
33
45
|
if (!date) return;
|
|
@@ -36,26 +48,22 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
36
48
|
date.setMinutes(selectedDate.getMinutes());
|
|
37
49
|
date.setSeconds(selectedDate.getSeconds());
|
|
38
50
|
date.setMilliseconds(selectedDate.getMilliseconds());
|
|
39
|
-
}
|
|
51
|
+
} else if (time) date.setHours(time.hours, time.minutes);
|
|
40
52
|
setSelectedDate(date);
|
|
41
53
|
onValueChange?.(date);
|
|
42
54
|
};
|
|
43
|
-
const handleTimeChange = (
|
|
44
|
-
|
|
45
|
-
setTimeValue(time);
|
|
55
|
+
const handleTimeChange = (next)=>{
|
|
56
|
+
setTime(next);
|
|
46
57
|
if (!selectedDate) return;
|
|
47
|
-
const [hours, minutes] = time.split(':').map(Number);
|
|
48
58
|
const newDate = new Date(selectedDate);
|
|
49
|
-
newDate.setHours(hours);
|
|
50
|
-
newDate.setMinutes(minutes);
|
|
59
|
+
newDate.setHours(next.hours);
|
|
60
|
+
newDate.setMinutes(next.minutes);
|
|
51
61
|
setSelectedDate(newDate);
|
|
52
62
|
onValueChange?.(newDate);
|
|
53
63
|
};
|
|
54
64
|
const formatDisplayValue = ()=>{
|
|
55
65
|
if (!selectedDate) return null;
|
|
56
|
-
|
|
57
|
-
const timePart = format(selectedDate, use12Hour ? 'hh:mm a' : 'HH:mm');
|
|
58
|
-
return `${datePart} at ${timePart}`;
|
|
66
|
+
return formatDateTime(selectedDate, locale, use12HourProp);
|
|
59
67
|
};
|
|
60
68
|
const group = useInputGroup();
|
|
61
69
|
const grouped = group.inGroup;
|
|
@@ -116,25 +124,30 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
116
124
|
mode: "single",
|
|
117
125
|
selected: selectedDate,
|
|
118
126
|
onSelect: handleDateSelect,
|
|
119
|
-
initialFocus: true
|
|
127
|
+
initialFocus: true,
|
|
128
|
+
locale: locale
|
|
120
129
|
}),
|
|
121
130
|
/*#__PURE__*/ jsxs("div", {
|
|
122
131
|
className: "border-t pt-3 space-y-2",
|
|
123
132
|
children: [
|
|
124
|
-
/*#__PURE__*/ jsxs(
|
|
133
|
+
/*#__PURE__*/ jsxs("div", {
|
|
134
|
+
id: timeLabelId,
|
|
125
135
|
className: "text-sm font-medium flex items-center gap-2",
|
|
126
136
|
children: [
|
|
127
137
|
/*#__PURE__*/ jsx(Clock, {
|
|
128
|
-
className: "h-4 w-4"
|
|
138
|
+
className: "h-4 w-4",
|
|
139
|
+
"aria-hidden": "true"
|
|
129
140
|
}),
|
|
130
|
-
|
|
141
|
+
strings.time
|
|
131
142
|
]
|
|
132
143
|
}),
|
|
133
|
-
/*#__PURE__*/ jsx(
|
|
134
|
-
|
|
135
|
-
value:
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
/*#__PURE__*/ jsx(TimeField, {
|
|
145
|
+
"aria-labelledby": timeLabelId,
|
|
146
|
+
value: time,
|
|
147
|
+
onValueChange: handleTimeChange,
|
|
148
|
+
use12Hour: resolveUse12Hour(use12HourProp, locale),
|
|
149
|
+
locale: locale,
|
|
150
|
+
strings: strings
|
|
138
151
|
})
|
|
139
152
|
]
|
|
140
153
|
}),
|
|
@@ -146,17 +159,17 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
146
159
|
className: "w-full",
|
|
147
160
|
onClick: ()=>{
|
|
148
161
|
setSelectedDate(void 0);
|
|
149
|
-
|
|
162
|
+
setTime(void 0);
|
|
150
163
|
onValueChange?.(void 0);
|
|
151
164
|
setOpen(false);
|
|
152
165
|
},
|
|
153
|
-
children:
|
|
166
|
+
children: strings.clear
|
|
154
167
|
}),
|
|
155
168
|
/*#__PURE__*/ jsx(Button, {
|
|
156
169
|
className: "w-full",
|
|
157
170
|
onClick: ()=>setOpen(false),
|
|
158
171
|
disabled: !selectedDate,
|
|
159
|
-
children:
|
|
172
|
+
children: strings.done
|
|
160
173
|
})
|
|
161
174
|
]
|
|
162
175
|
})
|
|
@@ -36,6 +36,7 @@ const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
|
36
36
|
const external_checkbox_cjs_namespaceObject = require("./checkbox.cjs");
|
|
37
37
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
38
38
|
const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
39
|
+
const external_locale_provider_cjs_namespaceObject = require("./locale-provider.cjs");
|
|
39
40
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
40
41
|
const external_select_cjs_namespaceObject = require("./select.cjs");
|
|
41
42
|
function EditableCell({ cell, onUpdate }) {
|
|
@@ -200,6 +201,7 @@ function createEditableColumn(accessorKey, header, meta) {
|
|
|
200
201
|
}
|
|
201
202
|
function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
|
|
202
203
|
const [open, setOpen] = external_react_namespaceObject.useState(true);
|
|
204
|
+
const locale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)();
|
|
203
205
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
204
206
|
open: open,
|
|
205
207
|
onOpenChange: (isOpen)=>{
|
|
@@ -218,7 +220,9 @@ function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
|
|
|
218
220
|
}),
|
|
219
221
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
220
222
|
className: "truncate",
|
|
221
|
-
children: value ? (0, external_date_fns_namespaceObject.format)(value, 'PP'
|
|
223
|
+
children: value ? (0, external_date_fns_namespaceObject.format)(value, 'PP', {
|
|
224
|
+
locale
|
|
225
|
+
}) : placeholder
|
|
222
226
|
})
|
|
223
227
|
]
|
|
224
228
|
})
|
|
@@ -7,6 +7,7 @@ import { Input } from "./input.js";
|
|
|
7
7
|
import { Checkbox } from "./checkbox.js";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
9
|
import { Calendar } from "./calendar.js";
|
|
10
|
+
import { useDateLocale } from "./locale-provider.js";
|
|
10
11
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
11
12
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
12
13
|
function EditableCell({ cell, onUpdate }) {
|
|
@@ -171,6 +172,7 @@ function createEditableColumn(accessorKey, header, meta) {
|
|
|
171
172
|
}
|
|
172
173
|
function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
|
|
173
174
|
const [open, setOpen] = useState(true);
|
|
175
|
+
const locale = useDateLocale();
|
|
174
176
|
return /*#__PURE__*/ jsxs(Popover, {
|
|
175
177
|
open: open,
|
|
176
178
|
onOpenChange: (isOpen)=>{
|
|
@@ -189,7 +191,9 @@ function DatePickerCell({ value, onValueChange, onClose, placeholder }) {
|
|
|
189
191
|
}),
|
|
190
192
|
/*#__PURE__*/ jsx("span", {
|
|
191
193
|
className: "truncate",
|
|
192
|
-
children: value ? format(value, 'PP'
|
|
194
|
+
children: value ? format(value, 'PP', {
|
|
195
|
+
locale
|
|
196
|
+
}) : placeholder
|
|
193
197
|
})
|
|
194
198
|
]
|
|
195
199
|
})
|