@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
|
@@ -47,6 +47,7 @@ export * from './label';
|
|
|
47
47
|
export * from './layout';
|
|
48
48
|
export * from './live-region';
|
|
49
49
|
export * from './loading-dots';
|
|
50
|
+
export * from './locale-provider';
|
|
50
51
|
export * from './lockable-value-field';
|
|
51
52
|
export * from './markdown';
|
|
52
53
|
export * from './marker';
|
|
@@ -50,6 +50,7 @@ export * from "./label.js";
|
|
|
50
50
|
export * from "./layout/index.js";
|
|
51
51
|
export * from "./live-region.js";
|
|
52
52
|
export * from "./loading-dots.js";
|
|
53
|
+
export * from "./locale-provider.js";
|
|
53
54
|
export * from "./lockable-value-field/index.js";
|
|
54
55
|
export * from "./markdown.js";
|
|
55
56
|
export * from "./marker.js";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
useDatePickerStrings: ()=>useDatePickerStrings,
|
|
29
|
+
DEFAULT_DATE_PICKER_STRINGS: ()=>DEFAULT_DATE_PICKER_STRINGS,
|
|
30
|
+
LocaleProvider: ()=>LocaleProvider,
|
|
31
|
+
useResolvedDateLocale: ()=>useResolvedDateLocale,
|
|
32
|
+
useDateLocale: ()=>useDateLocale
|
|
33
|
+
});
|
|
34
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const date_locale_cjs_namespaceObject = require("../../lib/date-locale.cjs");
|
|
37
|
+
const DEFAULT_DATE_PICKER_STRINGS = {
|
|
38
|
+
pickDate: 'Pick a date',
|
|
39
|
+
pickDateRange: 'Pick a date range',
|
|
40
|
+
pickDateTime: 'Pick a date and time',
|
|
41
|
+
selectedDate: (date)=>`Selected date: ${date}`,
|
|
42
|
+
selectedRange: (from, to)=>`Selected range: ${from} to ${to}`,
|
|
43
|
+
time: 'Time',
|
|
44
|
+
hours: 'Hours',
|
|
45
|
+
minutes: 'Minutes',
|
|
46
|
+
dayPeriod: 'AM/PM',
|
|
47
|
+
clear: 'Clear',
|
|
48
|
+
done: 'Done'
|
|
49
|
+
};
|
|
50
|
+
const LocaleContext = /*#__PURE__*/ external_react_namespaceObject.createContext({
|
|
51
|
+
datePickerStrings: DEFAULT_DATE_PICKER_STRINGS
|
|
52
|
+
});
|
|
53
|
+
function mergeStrings(base, overrides) {
|
|
54
|
+
const merged = {
|
|
55
|
+
...base
|
|
56
|
+
};
|
|
57
|
+
for (const key of Object.keys(overrides)){
|
|
58
|
+
const value = overrides[key];
|
|
59
|
+
if (void 0 !== value) merged[key] = value;
|
|
60
|
+
}
|
|
61
|
+
return merged;
|
|
62
|
+
}
|
|
63
|
+
function useResolvedDateLocale(locale) {
|
|
64
|
+
const tag = 'string' == typeof locale ? locale : void 0;
|
|
65
|
+
const [, rerender] = external_react_namespaceObject.useReducer((n)=>n + 1, 0);
|
|
66
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
67
|
+
if (!tag || (0, date_locale_cjs_namespaceObject.getLoadedDateLocale)(tag)) return;
|
|
68
|
+
let active = true;
|
|
69
|
+
(0, date_locale_cjs_namespaceObject.loadDateLocale)(tag).then(()=>{
|
|
70
|
+
if (active) rerender();
|
|
71
|
+
});
|
|
72
|
+
return ()=>{
|
|
73
|
+
active = false;
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
tag
|
|
77
|
+
]);
|
|
78
|
+
if ('object' == typeof locale) return locale;
|
|
79
|
+
return tag ? (0, date_locale_cjs_namespaceObject.getLoadedDateLocale)(tag) : void 0;
|
|
80
|
+
}
|
|
81
|
+
function useDateLocale(locale) {
|
|
82
|
+
const own = useResolvedDateLocale(locale);
|
|
83
|
+
const inherited = external_react_namespaceObject.useContext(LocaleContext).dateLocale;
|
|
84
|
+
return void 0 === locale ? inherited : own;
|
|
85
|
+
}
|
|
86
|
+
function useDatePickerStrings(overrides) {
|
|
87
|
+
const inherited = external_react_namespaceObject.useContext(LocaleContext).datePickerStrings;
|
|
88
|
+
return external_react_namespaceObject.useMemo(()=>overrides ? mergeStrings(inherited, overrides) : inherited, [
|
|
89
|
+
inherited,
|
|
90
|
+
overrides
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
function LocaleProvider({ locale, datePickerStrings, children }) {
|
|
94
|
+
const outer = external_react_namespaceObject.useContext(LocaleContext);
|
|
95
|
+
const own = useResolvedDateLocale(locale);
|
|
96
|
+
const dateLocale = void 0 === locale ? outer.dateLocale : own;
|
|
97
|
+
const value = external_react_namespaceObject.useMemo(()=>({
|
|
98
|
+
dateLocale,
|
|
99
|
+
datePickerStrings: datePickerStrings ? mergeStrings(outer.datePickerStrings, datePickerStrings) : outer.datePickerStrings
|
|
100
|
+
}), [
|
|
101
|
+
dateLocale,
|
|
102
|
+
datePickerStrings,
|
|
103
|
+
outer.datePickerStrings
|
|
104
|
+
]);
|
|
105
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocaleContext.Provider, {
|
|
106
|
+
value: value,
|
|
107
|
+
children: children
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.DEFAULT_DATE_PICKER_STRINGS = __webpack_exports__.DEFAULT_DATE_PICKER_STRINGS;
|
|
111
|
+
exports.LocaleProvider = __webpack_exports__.LocaleProvider;
|
|
112
|
+
exports.useDateLocale = __webpack_exports__.useDateLocale;
|
|
113
|
+
exports.useDatePickerStrings = __webpack_exports__.useDatePickerStrings;
|
|
114
|
+
exports.useResolvedDateLocale = __webpack_exports__.useResolvedDateLocale;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"DEFAULT_DATE_PICKER_STRINGS",
|
|
117
|
+
"LocaleProvider",
|
|
118
|
+
"useDateLocale",
|
|
119
|
+
"useDatePickerStrings",
|
|
120
|
+
"useResolvedDateLocale"
|
|
121
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
122
|
+
Object.defineProperty(exports, '__esModule', {
|
|
123
|
+
value: true
|
|
124
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type DateLocale } from '../../lib/date-locale';
|
|
3
|
+
/** The English text of the date and time pickers, overridable key by key. */
|
|
4
|
+
export interface DatePickerStrings {
|
|
5
|
+
/** DatePicker placeholder. */
|
|
6
|
+
pickDate: string;
|
|
7
|
+
/** DateRangePicker placeholder. */
|
|
8
|
+
pickDateRange: string;
|
|
9
|
+
/** DateTimePicker placeholder. */
|
|
10
|
+
pickDateTime: string;
|
|
11
|
+
/** Accessible name of a trigger holding a date, when nothing else labels it. */
|
|
12
|
+
selectedDate: (date: string) => string;
|
|
13
|
+
/** Accessible name of a range trigger holding both ends, when nothing else labels it. */
|
|
14
|
+
selectedRange: (from: string, to: string) => string;
|
|
15
|
+
/** Heading of the DateTimePicker time field. */
|
|
16
|
+
time: string;
|
|
17
|
+
/** Accessible name of the hour segment. */
|
|
18
|
+
hours: string;
|
|
19
|
+
/** Accessible name of the minute segment. */
|
|
20
|
+
minutes: string;
|
|
21
|
+
/** Accessible name of the AM/PM choice. */
|
|
22
|
+
dayPeriod: string;
|
|
23
|
+
/** DateTimePicker button that empties the value. */
|
|
24
|
+
clear: string;
|
|
25
|
+
/** DateTimePicker button that closes the panel. */
|
|
26
|
+
done: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_DATE_PICKER_STRINGS: DatePickerStrings;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a language tag to its date locale, loading it on first use. Renders in English
|
|
31
|
+
* until the language arrives; a locale object is used as is.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useResolvedDateLocale(locale: string | DateLocale | undefined): DateLocale | undefined;
|
|
34
|
+
/** The date locale from a component's own `locale` prop, else the nearest `LocaleProvider`. */
|
|
35
|
+
export declare function useDateLocale(locale?: string | DateLocale): DateLocale | undefined;
|
|
36
|
+
/** The date picker strings from the nearest `LocaleProvider`, with a component's overrides on top. */
|
|
37
|
+
export declare function useDatePickerStrings(overrides?: Partial<DatePickerStrings>): DatePickerStrings;
|
|
38
|
+
export interface LocaleProviderProps {
|
|
39
|
+
/**
|
|
40
|
+
* The platform language as a tag (`'de'`, `'pt-BR'`, `'zh-TW'`), or a locale from
|
|
41
|
+
* `react-day-picker/locale`. A tag loads its locale on first use and renders in English until
|
|
42
|
+
* then; await `loadDateLocale(tag)` and pass the result to avoid that. Unset, an outer
|
|
43
|
+
* provider's locale applies, and English without one.
|
|
44
|
+
*/
|
|
45
|
+
locale?: string | DateLocale;
|
|
46
|
+
/** Translations for the date and time pickers, merged over any outer provider's. */
|
|
47
|
+
datePickerStrings?: Partial<DatePickerStrings>;
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the language of the apollo-wind components below it, usually once at the app root.
|
|
52
|
+
* Dates, month and weekday names, the first day of the week, the 12- or 24-hour clock and the
|
|
53
|
+
* calendar's own accessible labels follow `locale`. The pickers' remaining text comes from
|
|
54
|
+
* `datePickerStrings`, in English unless translated. Components also take their own `locale`
|
|
55
|
+
* and `strings`, which win over the provider.
|
|
56
|
+
*/
|
|
57
|
+
export declare function LocaleProvider({ locale, datePickerStrings, children }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useReducer } from "react";
|
|
4
|
+
import { getLoadedDateLocale, loadDateLocale } from "../../lib/date-locale.js";
|
|
5
|
+
const DEFAULT_DATE_PICKER_STRINGS = {
|
|
6
|
+
pickDate: 'Pick a date',
|
|
7
|
+
pickDateRange: 'Pick a date range',
|
|
8
|
+
pickDateTime: 'Pick a date and time',
|
|
9
|
+
selectedDate: (date)=>`Selected date: ${date}`,
|
|
10
|
+
selectedRange: (from, to)=>`Selected range: ${from} to ${to}`,
|
|
11
|
+
time: 'Time',
|
|
12
|
+
hours: 'Hours',
|
|
13
|
+
minutes: 'Minutes',
|
|
14
|
+
dayPeriod: 'AM/PM',
|
|
15
|
+
clear: 'Clear',
|
|
16
|
+
done: 'Done'
|
|
17
|
+
};
|
|
18
|
+
const LocaleContext = /*#__PURE__*/ createContext({
|
|
19
|
+
datePickerStrings: DEFAULT_DATE_PICKER_STRINGS
|
|
20
|
+
});
|
|
21
|
+
function mergeStrings(base, overrides) {
|
|
22
|
+
const merged = {
|
|
23
|
+
...base
|
|
24
|
+
};
|
|
25
|
+
for (const key of Object.keys(overrides)){
|
|
26
|
+
const value = overrides[key];
|
|
27
|
+
if (void 0 !== value) merged[key] = value;
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
}
|
|
31
|
+
function useResolvedDateLocale(locale) {
|
|
32
|
+
const tag = 'string' == typeof locale ? locale : void 0;
|
|
33
|
+
const [, rerender] = useReducer((n)=>n + 1, 0);
|
|
34
|
+
useEffect(()=>{
|
|
35
|
+
if (!tag || getLoadedDateLocale(tag)) return;
|
|
36
|
+
let active = true;
|
|
37
|
+
loadDateLocale(tag).then(()=>{
|
|
38
|
+
if (active) rerender();
|
|
39
|
+
});
|
|
40
|
+
return ()=>{
|
|
41
|
+
active = false;
|
|
42
|
+
};
|
|
43
|
+
}, [
|
|
44
|
+
tag
|
|
45
|
+
]);
|
|
46
|
+
if ('object' == typeof locale) return locale;
|
|
47
|
+
return tag ? getLoadedDateLocale(tag) : void 0;
|
|
48
|
+
}
|
|
49
|
+
function useDateLocale(locale) {
|
|
50
|
+
const own = useResolvedDateLocale(locale);
|
|
51
|
+
const inherited = useContext(LocaleContext).dateLocale;
|
|
52
|
+
return void 0 === locale ? inherited : own;
|
|
53
|
+
}
|
|
54
|
+
function useDatePickerStrings(overrides) {
|
|
55
|
+
const inherited = useContext(LocaleContext).datePickerStrings;
|
|
56
|
+
return useMemo(()=>overrides ? mergeStrings(inherited, overrides) : inherited, [
|
|
57
|
+
inherited,
|
|
58
|
+
overrides
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
function LocaleProvider({ locale, datePickerStrings, children }) {
|
|
62
|
+
const outer = useContext(LocaleContext);
|
|
63
|
+
const own = useResolvedDateLocale(locale);
|
|
64
|
+
const dateLocale = void 0 === locale ? outer.dateLocale : own;
|
|
65
|
+
const value = useMemo(()=>({
|
|
66
|
+
dateLocale,
|
|
67
|
+
datePickerStrings: datePickerStrings ? mergeStrings(outer.datePickerStrings, datePickerStrings) : outer.datePickerStrings
|
|
68
|
+
}), [
|
|
69
|
+
dateLocale,
|
|
70
|
+
datePickerStrings,
|
|
71
|
+
outer.datePickerStrings
|
|
72
|
+
]);
|
|
73
|
+
return /*#__PURE__*/ jsx(LocaleContext.Provider, {
|
|
74
|
+
value: value,
|
|
75
|
+
children: children
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export { DEFAULT_DATE_PICKER_STRINGS, LocaleProvider, useDateLocale, useDatePickerStrings, useResolvedDateLocale };
|
|
@@ -35,6 +35,7 @@ const external_editable_text_cjs_namespaceObject = require("../editable-text.cjs
|
|
|
35
35
|
const external_file_upload_cjs_namespaceObject = require("../file-upload.cjs");
|
|
36
36
|
const external_input_group_cjs_namespaceObject = require("../input-group.cjs");
|
|
37
37
|
const external_label_cjs_namespaceObject = require("../label.cjs");
|
|
38
|
+
const external_locale_provider_cjs_namespaceObject = require("../locale-provider.cjs");
|
|
38
39
|
const external_multi_select_cjs_namespaceObject = require("../multi-select.cjs");
|
|
39
40
|
const external_popover_cjs_namespaceObject = require("../popover.cjs");
|
|
40
41
|
const external_prompt_value_control_cjs_namespaceObject = require("../prompt-value-control.cjs");
|
|
@@ -60,6 +61,7 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
60
61
|
}), [
|
|
61
62
|
stringOverrides
|
|
62
63
|
]);
|
|
64
|
+
const dateLocale = (0, external_locale_provider_cjs_namespaceObject.useDateLocale)();
|
|
63
65
|
const generatedId = (0, external_react_namespaceObject.useId)().replace(/:/g, '');
|
|
64
66
|
const valueInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
65
67
|
const committedRef = (0, external_react_namespaceObject.useRef)(value);
|
|
@@ -260,7 +262,7 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
260
262
|
"aria-errormessage": controlProps['aria-errormessage'],
|
|
261
263
|
disabled: !editableOnValueChange,
|
|
262
264
|
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
263
|
-
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
265
|
+
children: value ? (0, external_utils_cjs_namespaceObject.formatDateValue)(value, dateLocale?.code) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
264
266
|
className: "text-muted-foreground",
|
|
265
267
|
children: strings.pickDate
|
|
266
268
|
})
|
|
@@ -7,6 +7,7 @@ import { EditableText } from "../editable-text.js";
|
|
|
7
7
|
import { FileUpload } from "../file-upload.js";
|
|
8
8
|
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupTextarea } from "../input-group.js";
|
|
9
9
|
import { RequiredIndicator } from "../label.js";
|
|
10
|
+
import { useDateLocale } from "../locale-provider.js";
|
|
10
11
|
import { MultiSelect } from "../multi-select.js";
|
|
11
12
|
import { Popover, PopoverContent, PopoverTrigger } from "../popover.js";
|
|
12
13
|
import { PromptValueControl } from "../prompt-value-control.js";
|
|
@@ -32,6 +33,7 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
32
33
|
}), [
|
|
33
34
|
stringOverrides
|
|
34
35
|
]);
|
|
36
|
+
const dateLocale = useDateLocale();
|
|
35
37
|
const generatedId = useId().replace(/:/g, '');
|
|
36
38
|
const valueInputRef = useRef(null);
|
|
37
39
|
const committedRef = useRef(value);
|
|
@@ -232,7 +234,7 @@ function QuickFormField({ value = '', onValueChange, onValueBlur, locked = true,
|
|
|
232
234
|
"aria-errormessage": controlProps['aria-errormessage'],
|
|
233
235
|
disabled: !editableOnValueChange,
|
|
234
236
|
className: "flex h-full flex-1 items-center text-left text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
235
|
-
children: value ? formatDateValue(value) : /*#__PURE__*/ jsx("span", {
|
|
237
|
+
children: value ? formatDateValue(value, dateLocale?.code) : /*#__PURE__*/ jsx("span", {
|
|
236
238
|
className: "text-muted-foreground",
|
|
237
239
|
children: strings.pickDate
|
|
238
240
|
})
|
|
@@ -59,9 +59,9 @@ function toDateOnlyString(date) {
|
|
|
59
59
|
const day = String(date.getDate()).padStart(2, '0');
|
|
60
60
|
return `${year}-${month}-${day}`;
|
|
61
61
|
}
|
|
62
|
-
function formatDateValue(value) {
|
|
62
|
+
function formatDateValue(value, localeCode) {
|
|
63
63
|
const date = (0, date_value_cjs_namespaceObject.toDateValue)(value);
|
|
64
|
-
return date ? date.toLocaleDateString(
|
|
64
|
+
return date ? date.toLocaleDateString(localeCode, {
|
|
65
65
|
year: 'numeric',
|
|
66
66
|
month: 'long',
|
|
67
67
|
day: 'numeric'
|
|
@@ -5,7 +5,8 @@ export declare function parseListValue(value: string): string[];
|
|
|
5
5
|
/** Formats a Date as a local `YYYY-MM-DD` string, which `toDateValue` reads back as a local date. */
|
|
6
6
|
export declare function toDateOnlyString(date: Date): string;
|
|
7
7
|
/** Formats a date field's value for display, falling back to the raw value if it isn't a valid date. */
|
|
8
|
-
|
|
8
|
+
/** Unset, `localeCode` falls back to the browser's language. */
|
|
9
|
+
export declare function formatDateValue(value: string, localeCode?: string): string;
|
|
9
10
|
export interface VariablePickerSource {
|
|
10
11
|
items: VariablePickerItem[];
|
|
11
12
|
/** The consumer's own entry for a picked item: rebuilding it from the item would drop `type`. */
|
|
@@ -27,9 +27,9 @@ function toDateOnlyString(date) {
|
|
|
27
27
|
const day = String(date.getDate()).padStart(2, '0');
|
|
28
28
|
return `${year}-${month}-${day}`;
|
|
29
29
|
}
|
|
30
|
-
function formatDateValue(value) {
|
|
30
|
+
function formatDateValue(value, localeCode) {
|
|
31
31
|
const date = toDateValue(value);
|
|
32
|
-
return date ? date.toLocaleDateString(
|
|
32
|
+
return date ? date.toLocaleDateString(localeCode, {
|
|
33
33
|
year: 'numeric',
|
|
34
34
|
month: 'long',
|
|
35
35
|
day: 'numeric'
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
TimeField: ()=>TimeField
|
|
29
|
+
});
|
|
30
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
+
const external_date_fns_namespaceObject = require("date-fns");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
34
|
+
const date_locale_cjs_namespaceObject = require("../../lib/date-locale.cjs");
|
|
35
|
+
const external_toggle_group_cjs_namespaceObject = require("./toggle-group.cjs");
|
|
36
|
+
function timeLayout(locale, use12Hour) {
|
|
37
|
+
const pattern = (0, date_locale_cjs_namespaceObject.localeTimePattern)(locale) ?? '';
|
|
38
|
+
const bare = pattern.replace(/'[^']*'/g, '');
|
|
39
|
+
const hourAt = bare.search(/[hHkK]/);
|
|
40
|
+
const periodAt = bare.search(/[aBb]/);
|
|
41
|
+
const separator = /[hHkK]+([^hHkKm]*)m/.exec(pattern)?.[1].replace(/'/g, '').trim() || ':';
|
|
42
|
+
return {
|
|
43
|
+
periodFirst: use12Hour && -1 !== periodAt && periodAt < hourAt,
|
|
44
|
+
separator
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const time_field_TimeSegment = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ value, min, max, label, disabled, onCommit, onFilled }, ref) {
|
|
48
|
+
const [draft, setDraft] = external_react_namespaceObject.useState(null);
|
|
49
|
+
const text = draft ?? (void 0 === value ? '' : String(value).padStart(2, '0'));
|
|
50
|
+
const enter = (digits)=>{
|
|
51
|
+
setDraft(digits);
|
|
52
|
+
if (!digits) return;
|
|
53
|
+
const typed = Number(digits);
|
|
54
|
+
if (typed >= min && typed <= max) onCommit(typed);
|
|
55
|
+
else if (2 === digits.length) onCommit(Math.min(Math.max(typed, min), max));
|
|
56
|
+
if (2 === digits.length || 10 * typed > max) onFilled?.();
|
|
57
|
+
};
|
|
58
|
+
const step = (delta)=>{
|
|
59
|
+
const span = max - min + 1;
|
|
60
|
+
const from = value ?? (delta > 0 ? min - 1 : max + 1);
|
|
61
|
+
setDraft(null);
|
|
62
|
+
onCommit(((from - min + delta) % span + span) % span + min);
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
|
|
65
|
+
ref: ref,
|
|
66
|
+
type: "text",
|
|
67
|
+
inputMode: "numeric",
|
|
68
|
+
role: "spinbutton",
|
|
69
|
+
autoComplete: "off",
|
|
70
|
+
"aria-label": label,
|
|
71
|
+
"aria-valuemin": min,
|
|
72
|
+
"aria-valuemax": max,
|
|
73
|
+
"aria-valuenow": value,
|
|
74
|
+
placeholder: "--",
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
value: text,
|
|
77
|
+
onBlur: ()=>setDraft(null),
|
|
78
|
+
onKeyDown: (e)=>{
|
|
79
|
+
if (/^\d$/.test(e.key)) {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const next = (draft ?? '') + e.key;
|
|
82
|
+
enter(next.length > 2 ? e.key : next);
|
|
83
|
+
} else if ('ArrowUp' === e.key || 'ArrowDown' === e.key) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
step('ArrowUp' === e.key ? 1 : -1);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onChange: (e)=>enter(e.target.value.replace(/\D/g, '').slice(-2)),
|
|
89
|
+
className: "w-[2.5ch] rounded-sm bg-transparent text-center tabular-nums caret-transparent outline-none placeholder:text-muted-foreground focus:bg-accent focus:text-accent-foreground disabled:cursor-not-allowed"
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
function TimeField({ value, onValueChange, use12Hour, locale, strings, 'aria-labelledby': ariaLabelledBy, disabled, className }) {
|
|
93
|
+
const minuteRef = external_react_namespaceObject.useRef(null);
|
|
94
|
+
const { periodFirst, separator } = timeLayout(locale, use12Hour);
|
|
95
|
+
const hours = value?.hours;
|
|
96
|
+
const [pendingPm, setPendingPm] = external_react_namespaceObject.useState(false);
|
|
97
|
+
const pm = void 0 === hours ? pendingPm : hours >= 12;
|
|
98
|
+
const commit = (next)=>onValueChange({
|
|
99
|
+
hours: next.hours ?? hours ?? (use12Hour && pm ? 12 : 0),
|
|
100
|
+
minutes: next.minutes ?? value?.minutes ?? 0
|
|
101
|
+
});
|
|
102
|
+
const setPm = (nextPm)=>{
|
|
103
|
+
setPendingPm(nextPm);
|
|
104
|
+
if (void 0 !== hours) commit({
|
|
105
|
+
hours: hours % 12 + (nextPm ? 12 : 0)
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const period = use12Hour && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_toggle_group_cjs_namespaceObject.ToggleGroup, {
|
|
109
|
+
type: "single",
|
|
110
|
+
variant: "outline",
|
|
111
|
+
size: "sm",
|
|
112
|
+
"aria-label": strings.dayPeriod,
|
|
113
|
+
value: pm ? 'pm' : 'am',
|
|
114
|
+
onValueChange: (next)=>next && setPm('pm' === next),
|
|
115
|
+
disabled: disabled,
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_toggle_group_cjs_namespaceObject.ToggleGroupItem, {
|
|
118
|
+
value: "am",
|
|
119
|
+
className: "future:h-10",
|
|
120
|
+
children: (0, external_date_fns_namespaceObject.format)(new Date(2000, 0, 1, 9), 'a', {
|
|
121
|
+
locale
|
|
122
|
+
})
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_toggle_group_cjs_namespaceObject.ToggleGroupItem, {
|
|
125
|
+
value: "pm",
|
|
126
|
+
className: "future:h-10",
|
|
127
|
+
children: (0, external_date_fns_namespaceObject.format)(new Date(2000, 0, 1, 21), 'a', {
|
|
128
|
+
locale
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("fieldset", {
|
|
134
|
+
"aria-labelledby": ariaLabelledBy,
|
|
135
|
+
"data-slot": "time-field",
|
|
136
|
+
className: (0, index_cjs_namespaceObject.cn)('m-0 flex min-w-0 items-center gap-2 border-0 p-0', className),
|
|
137
|
+
children: [
|
|
138
|
+
periodFirst && period,
|
|
139
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
140
|
+
className: (0, index_cjs_namespaceObject.cn)('flex h-9 flex-1 items-center gap-0.5 rounded-md border border-input bg-transparent px-3 text-base transition-colors focus-within:ring-2 focus-within:ring-ring has-disabled:cursor-not-allowed has-disabled:opacity-50 md:text-sm', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:text-sm future:focus-within:ring-primary future:focus-within:ring-offset-2 future:focus-within:ring-offset-background'),
|
|
141
|
+
children: [
|
|
142
|
+
use12Hour ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(time_field_TimeSegment, {
|
|
143
|
+
label: strings.hours,
|
|
144
|
+
value: void 0 === hours ? void 0 : hours % 12 || 12,
|
|
145
|
+
min: 1,
|
|
146
|
+
max: 12,
|
|
147
|
+
disabled: disabled,
|
|
148
|
+
onCommit: (shown)=>commit({
|
|
149
|
+
hours: shown % 12 + (pm ? 12 : 0)
|
|
150
|
+
}),
|
|
151
|
+
onFilled: ()=>minuteRef.current?.focus()
|
|
152
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(time_field_TimeSegment, {
|
|
153
|
+
label: strings.hours,
|
|
154
|
+
value: hours,
|
|
155
|
+
min: 0,
|
|
156
|
+
max: 23,
|
|
157
|
+
disabled: disabled,
|
|
158
|
+
onCommit: (next)=>commit({
|
|
159
|
+
hours: next
|
|
160
|
+
}),
|
|
161
|
+
onFilled: ()=>minuteRef.current?.focus()
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
className: "text-muted-foreground",
|
|
166
|
+
children: separator
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(time_field_TimeSegment, {
|
|
169
|
+
ref: minuteRef,
|
|
170
|
+
label: strings.minutes,
|
|
171
|
+
value: value?.minutes,
|
|
172
|
+
min: 0,
|
|
173
|
+
max: 59,
|
|
174
|
+
disabled: disabled,
|
|
175
|
+
onCommit: (minutes)=>commit({
|
|
176
|
+
minutes
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
}),
|
|
181
|
+
!periodFirst && period
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
exports.TimeField = __webpack_exports__.TimeField;
|
|
186
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
187
|
+
"TimeField"
|
|
188
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
189
|
+
Object.defineProperty(exports, '__esModule', {
|
|
190
|
+
value: true
|
|
191
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DateLocale } from '../../lib/date-locale';
|
|
2
|
+
import type { DatePickerStrings } from './locale-provider';
|
|
3
|
+
export interface TimeValue {
|
|
4
|
+
/** 0 to 23, whatever the clock shown. */
|
|
5
|
+
hours: number;
|
|
6
|
+
minutes: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TimeFieldProps {
|
|
9
|
+
value: TimeValue | undefined;
|
|
10
|
+
onValueChange: (value: TimeValue) => void;
|
|
11
|
+
use12Hour: boolean;
|
|
12
|
+
/** Supplies the AM/PM words and the segment order. English when unset. */
|
|
13
|
+
locale?: DateLocale;
|
|
14
|
+
strings: Pick<DatePickerStrings, 'hours' | 'minutes' | 'dayPeriod'>;
|
|
15
|
+
/** Id of the element naming the whole field. */
|
|
16
|
+
'aria-labelledby'?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hours and minutes typed as separate segments, with an AM/PM choice on a 12-hour clock. Unlike
|
|
22
|
+
* a native time input it follows the given locale, not the browser's or the OS's settings.
|
|
23
|
+
*/
|
|
24
|
+
export declare function TimeField({ value, onValueChange, use12Hour, locale, strings, 'aria-labelledby': ariaLabelledBy, disabled, className, }: TimeFieldProps): import("react/jsx-runtime").JSX.Element;
|