@uipath/apollo-wind 2.52.3 → 2.53.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/forms/field-renderer.cjs +42 -3
- package/dist/components/forms/field-renderer.js +42 -3
- package/dist/components/forms/string-list-field.cjs +3 -0
- package/dist/components/forms/string-list-field.js +3 -0
- package/dist/components/ui/button.cjs +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/checkbox.cjs +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.cjs +70 -51
- package/dist/components/ui/combobox.d.ts +12 -0
- package/dist/components/ui/combobox.js +72 -53
- package/dist/components/ui/date-picker.cjs +102 -62
- package/dist/components/ui/date-picker.d.ts +28 -0
- package/dist/components/ui/date-picker.js +103 -63
- package/dist/components/ui/datetime-picker.cjs +90 -72
- package/dist/components/ui/datetime-picker.d.ts +12 -2
- package/dist/components/ui/datetime-picker.js +92 -74
- package/dist/components/ui/file-upload.cjs +21 -8
- package/dist/components/ui/file-upload.d.ts +7 -0
- package/dist/components/ui/file-upload.js +22 -9
- package/dist/components/ui/form-field.cjs +3 -3
- package/dist/components/ui/form-field.d.ts +11 -0
- package/dist/components/ui/form-field.js +3 -3
- package/dist/components/ui/index.cjs +26 -26
- package/dist/components/ui/input-group.cjs +0 -2
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +0 -2
- package/dist/components/ui/input.cjs +0 -2
- package/dist/components/ui/input.js +0 -2
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +1 -1
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +1 -1
- package/dist/components/ui/multi-select.cjs +125 -112
- package/dist/components/ui/multi-select.d.ts +7 -0
- package/dist/components/ui/multi-select.js +126 -113
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +0 -2
- package/dist/components/ui/prompt-editor/prompt-editor.js +0 -2
- package/dist/components/ui/radio-group.cjs +2 -2
- package/dist/components/ui/radio-group.js +2 -2
- package/dist/components/ui/search.cjs +3 -1
- package/dist/components/ui/search.d.ts +4 -0
- package/dist/components/ui/search.js +3 -1
- package/dist/components/ui/select.cjs +33 -12
- package/dist/components/ui/select.d.ts +10 -1
- package/dist/components/ui/select.js +35 -14
- package/dist/components/ui/slider.cjs +7 -2
- package/dist/components/ui/slider.js +7 -2
- package/dist/components/ui/switch.cjs +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/textarea.cjs +30 -11
- package/dist/components/ui/textarea.d.ts +7 -0
- package/dist/components/ui/textarea.js +32 -13
- package/dist/index.cjs +4 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -2
- package/dist/styles.css +74 -0
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ export interface ComboboxItem {
|
|
|
4
4
|
label: string;
|
|
5
5
|
}
|
|
6
6
|
export interface ComboboxProps {
|
|
7
|
+
/** Applied to the trigger button, so a `<label htmlFor>` pointing at it associates correctly. */
|
|
8
|
+
id?: string;
|
|
7
9
|
items: ComboboxItem[];
|
|
8
10
|
value?: string;
|
|
9
11
|
onValueChange?: (value: string) => void;
|
|
@@ -12,5 +14,15 @@ export interface ComboboxProps {
|
|
|
12
14
|
emptyText?: string;
|
|
13
15
|
disabled?: boolean;
|
|
14
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Field-specific feedback rendered immediately below the trigger.
|
|
19
|
+
* Keep the message focused on what went wrong and how to resolve it.
|
|
20
|
+
*/
|
|
21
|
+
error?: React.ReactNode;
|
|
22
|
+
/** Optional id for the inline validation message. */
|
|
23
|
+
errorId?: string;
|
|
24
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
25
|
+
'aria-describedby'?: string;
|
|
26
|
+
'aria-errormessage'?: string;
|
|
15
27
|
}
|
|
16
28
|
export declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,71 +1,90 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Check, ChevronDown } from "lucide-react";
|
|
4
|
-
import { forwardRef, useState } from "react";
|
|
4
|
+
import { forwardRef, useId, useState } from "react";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
8
|
import { cn } from "../../lib/index.js";
|
|
9
|
-
|
|
9
|
+
import { FormFieldError } from "./form-field.js";
|
|
10
|
+
const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value, onValueChange, placeholder = 'Select an option...', searchPlaceholder = 'Search...', emptyText = 'No results found.', disabled, className, error, errorId, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
10
11
|
const [open, setOpen] = useState(false);
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const validationId = errorId ?? `${id ?? `combobox-${generatedId.replace(/:/g, '')}`}-error`;
|
|
14
|
+
const describedBy = [
|
|
15
|
+
ariaDescribedBy,
|
|
16
|
+
error ? validationId : void 0
|
|
17
|
+
].filter(Boolean).join(' ');
|
|
11
18
|
const selectedItem = items.find((item)=>item.value === value);
|
|
12
|
-
return /*#__PURE__*/ jsxs(
|
|
13
|
-
"data-slot": "combobox",
|
|
14
|
-
open: open,
|
|
15
|
-
onOpenChange: setOpen,
|
|
19
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
16
20
|
children: [
|
|
17
|
-
/*#__PURE__*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
/*#__PURE__*/ jsxs(Popover, {
|
|
22
|
+
"data-slot": "combobox",
|
|
23
|
+
open: open,
|
|
24
|
+
onOpenChange: setOpen,
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
27
|
+
asChild: true,
|
|
28
|
+
children: /*#__PURE__*/ jsxs(Button, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
id: id,
|
|
31
|
+
variant: "outline",
|
|
32
|
+
role: "combobox",
|
|
33
|
+
"aria-expanded": open,
|
|
34
|
+
"aria-label": id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
35
|
+
"aria-describedby": describedBy || void 0,
|
|
36
|
+
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
37
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
38
|
+
className: cn('w-[280px] justify-between future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
39
|
+
disabled: disabled,
|
|
40
|
+
children: [
|
|
41
|
+
selectedItem ? selectedItem.label : /*#__PURE__*/ jsx("span", {
|
|
42
|
+
className: "text-foreground-muted",
|
|
43
|
+
children: placeholder
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
46
|
+
className: "opacity-50"
|
|
47
|
+
})
|
|
48
|
+
]
|
|
34
49
|
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
className: "w-[280px] p-0",
|
|
40
|
-
children: /*#__PURE__*/ jsxs(Command, {
|
|
41
|
-
children: [
|
|
42
|
-
/*#__PURE__*/ jsx(CommandInput, {
|
|
43
|
-
placeholder: searchPlaceholder
|
|
44
|
-
}),
|
|
45
|
-
/*#__PURE__*/ jsxs(CommandList, {
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ jsx(PopoverContent, {
|
|
52
|
+
className: "w-[280px] p-0",
|
|
53
|
+
children: /*#__PURE__*/ jsxs(Command, {
|
|
46
54
|
children: [
|
|
47
|
-
/*#__PURE__*/ jsx(
|
|
48
|
-
|
|
55
|
+
/*#__PURE__*/ jsx(CommandInput, {
|
|
56
|
+
placeholder: searchPlaceholder
|
|
49
57
|
}),
|
|
50
|
-
/*#__PURE__*/
|
|
51
|
-
children:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
/*#__PURE__*/ jsxs(CommandList, {
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ jsx(CommandEmpty, {
|
|
61
|
+
children: emptyText
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ jsx(CommandGroup, {
|
|
64
|
+
children: items.map((item)=>/*#__PURE__*/ jsxs(CommandItem, {
|
|
65
|
+
value: item.value,
|
|
66
|
+
onSelect: (currentValue)=>{
|
|
67
|
+
onValueChange?.(currentValue === value ? '' : currentValue);
|
|
68
|
+
setOpen(false);
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
item.label,
|
|
72
|
+
/*#__PURE__*/ jsx(Check, {
|
|
73
|
+
className: cn('ml-auto', value === item.value ? 'opacity-100' : 'opacity-0')
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}, item.value))
|
|
77
|
+
})
|
|
78
|
+
]
|
|
64
79
|
})
|
|
65
80
|
]
|
|
66
81
|
})
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
86
|
+
id: validationId,
|
|
87
|
+
children: error
|
|
69
88
|
})
|
|
70
89
|
]
|
|
71
90
|
});
|
|
@@ -36,80 +36,120 @@ const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
|
36
36
|
const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
37
37
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
38
38
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
40
|
+
const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
41
|
+
const generatedId = external_react_namespaceObject.useId();
|
|
42
|
+
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
43
|
+
const describedBy = [
|
|
44
|
+
ariaDescribedBy,
|
|
45
|
+
error ? validationId : void 0
|
|
46
|
+
].filter(Boolean).join(' ');
|
|
47
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
42
48
|
children: [
|
|
43
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
44
|
-
|
|
45
|
-
children:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
50
|
+
"data-slot": "date-picker",
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
53
|
+
asChild: true,
|
|
54
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
55
|
+
ref: ref,
|
|
56
|
+
id: id,
|
|
57
|
+
variant: "outline",
|
|
58
|
+
"aria-label": id || ariaLabelledBy ? void 0 : value ? `Selected date: ${(0, external_date_fns_namespaceObject.format)(value, 'PPP')}` : placeholder,
|
|
59
|
+
"aria-labelledby": ariaLabelledBy,
|
|
60
|
+
"aria-describedby": describedBy || void 0,
|
|
61
|
+
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
62
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
63
|
+
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),
|
|
64
|
+
disabled: disabled,
|
|
65
|
+
children: [
|
|
66
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
67
|
+
value ? (0, external_date_fns_namespaceObject.format)(value, 'PPP') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
68
|
+
className: "text-foreground-muted",
|
|
69
|
+
children: placeholder
|
|
70
|
+
})
|
|
71
|
+
]
|
|
56
72
|
})
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
75
|
+
className: "w-auto p-0",
|
|
76
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
77
|
+
mode: "single",
|
|
78
|
+
selected: value,
|
|
79
|
+
onSelect: onValueChange,
|
|
80
|
+
initialFocus: true,
|
|
81
|
+
...calendarProps
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
]
|
|
59
85
|
}),
|
|
60
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
61
|
-
|
|
62
|
-
children:
|
|
63
|
-
mode: "single",
|
|
64
|
-
selected: value,
|
|
65
|
-
onSelect: onValueChange,
|
|
66
|
-
initialFocus: true,
|
|
67
|
-
...calendarProps
|
|
68
|
-
})
|
|
86
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
87
|
+
id: validationId,
|
|
88
|
+
children: error
|
|
69
89
|
})
|
|
70
90
|
]
|
|
71
91
|
});
|
|
72
92
|
});
|
|
73
|
-
const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ value, onValueChange, disabled, placeholder = 'Pick a date range', className, calendarProps }, ref) {
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date range', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
94
|
+
const generatedId = external_react_namespaceObject.useId();
|
|
95
|
+
const validationId = errorId ?? `${id ?? `date-range-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
96
|
+
const describedBy = [
|
|
97
|
+
ariaDescribedBy,
|
|
98
|
+
error ? validationId : void 0
|
|
99
|
+
].filter(Boolean).join(' ');
|
|
100
|
+
const computedLabel = value?.from ? value.to ? `Selected range: ${(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y')} to ${(0, external_date_fns_namespaceObject.format)(value.to, 'LLL dd, y')}` : `Selected date: ${(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y')}` : placeholder;
|
|
101
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
76
102
|
children: [
|
|
77
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
78
|
-
|
|
79
|
-
children:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
104
|
+
"data-slot": "date-range-picker",
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
107
|
+
asChild: true,
|
|
108
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
109
|
+
ref: ref,
|
|
110
|
+
id: id,
|
|
111
|
+
variant: "outline",
|
|
112
|
+
"aria-label": id || ariaLabelledBy ? void 0 : computedLabel,
|
|
113
|
+
"aria-labelledby": ariaLabelledBy,
|
|
114
|
+
"aria-describedby": describedBy || void 0,
|
|
115
|
+
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
116
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
117
|
+
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),
|
|
118
|
+
disabled: disabled,
|
|
88
119
|
children: [
|
|
89
|
-
(0,
|
|
90
|
-
|
|
91
|
-
|
|
120
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
121
|
+
value?.from ? value.to ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
122
|
+
children: [
|
|
123
|
+
(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y'),
|
|
124
|
+
" - ",
|
|
125
|
+
(0, external_date_fns_namespaceObject.format)(value.to, 'LLL dd, y')
|
|
126
|
+
]
|
|
127
|
+
}) : (0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
128
|
+
className: "text-foreground-muted",
|
|
129
|
+
children: placeholder
|
|
130
|
+
})
|
|
92
131
|
]
|
|
93
|
-
}) : (0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
94
|
-
className: "text-foreground-muted",
|
|
95
|
-
children: placeholder
|
|
96
132
|
})
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
135
|
+
className: "w-auto p-0",
|
|
136
|
+
align: "start",
|
|
137
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
138
|
+
initialFocus: true,
|
|
139
|
+
mode: "range",
|
|
140
|
+
defaultMonth: value?.from,
|
|
141
|
+
selected: value,
|
|
142
|
+
onSelect: onValueChange,
|
|
143
|
+
numberOfMonths: 2,
|
|
144
|
+
required: false,
|
|
145
|
+
...calendarProps
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
]
|
|
99
149
|
}),
|
|
100
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
104
|
-
initialFocus: true,
|
|
105
|
-
mode: "range",
|
|
106
|
-
defaultMonth: value?.from,
|
|
107
|
-
selected: value,
|
|
108
|
-
onSelect: onValueChange,
|
|
109
|
-
numberOfMonths: 2,
|
|
110
|
-
required: false,
|
|
111
|
-
...calendarProps
|
|
112
|
-
})
|
|
150
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
151
|
+
id: validationId,
|
|
152
|
+
children: error
|
|
113
153
|
})
|
|
114
154
|
]
|
|
115
155
|
});
|
|
@@ -2,20 +2,48 @@ import * as React from 'react';
|
|
|
2
2
|
import type { DateRange } from 'react-day-picker';
|
|
3
3
|
import { Calendar } from './calendar';
|
|
4
4
|
export interface DatePickerProps {
|
|
5
|
+
/** Applied to the trigger button, so a `<label htmlFor>` pointing at it associates correctly. */
|
|
6
|
+
id?: string;
|
|
5
7
|
value?: Date;
|
|
6
8
|
onValueChange?: (date: Date | undefined) => void;
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
placeholder?: string;
|
|
9
11
|
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Field-specific feedback rendered immediately below the trigger.
|
|
14
|
+
* Keep the message focused on what went wrong and how to resolve it.
|
|
15
|
+
*/
|
|
16
|
+
error?: React.ReactNode;
|
|
17
|
+
/** Optional id for the inline validation message. */
|
|
18
|
+
errorId?: string;
|
|
19
|
+
/** Id of the element naming this control, forwarded to the trigger button. */
|
|
20
|
+
'aria-labelledby'?: string;
|
|
21
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
22
|
+
'aria-describedby'?: string;
|
|
23
|
+
'aria-errormessage'?: string;
|
|
10
24
|
calendarProps?: Omit<React.ComponentProps<typeof Calendar>, 'mode' | 'selected' | 'onSelect' | 'initialFocus'>;
|
|
11
25
|
}
|
|
12
26
|
export declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
27
|
export interface DateRangePickerProps {
|
|
28
|
+
/** Applied to the trigger button, so a `<label htmlFor>` pointing at it associates correctly. */
|
|
29
|
+
id?: string;
|
|
14
30
|
value?: DateRange;
|
|
15
31
|
onValueChange?: (range: DateRange | undefined) => void;
|
|
16
32
|
disabled?: boolean;
|
|
17
33
|
placeholder?: string;
|
|
18
34
|
className?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Field-specific feedback rendered immediately below the trigger.
|
|
37
|
+
* Keep the message focused on what went wrong and how to resolve it.
|
|
38
|
+
*/
|
|
39
|
+
error?: React.ReactNode;
|
|
40
|
+
/** Optional id for the inline validation message. */
|
|
41
|
+
errorId?: string;
|
|
42
|
+
/** Id of the element naming this control, forwarded to the trigger button. */
|
|
43
|
+
'aria-labelledby'?: string;
|
|
44
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
45
|
+
'aria-describedby'?: string;
|
|
46
|
+
'aria-errormessage'?: string;
|
|
19
47
|
calendarProps?: Omit<React.ComponentProps<typeof Calendar>, 'mode' | 'selected' | 'onSelect' | 'initialFocus' | 'defaultMonth' | 'numberOfMonths' | 'required'>;
|
|
20
48
|
}
|
|
21
49
|
export declare const DateRangePicker: React.ForwardRefExoticComponent<DateRangePickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -2,85 +2,125 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { format } from "date-fns";
|
|
4
4
|
import { CalendarIcon } from "lucide-react";
|
|
5
|
-
import { forwardRef } from "react";
|
|
5
|
+
import { forwardRef, useId } from "react";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
7
|
import { Calendar } from "./calendar.js";
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
9
|
import { cn } from "../../lib/index.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { FormFieldError } from "./form-field.js";
|
|
11
|
+
const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
14
|
+
const describedBy = [
|
|
15
|
+
ariaDescribedBy,
|
|
16
|
+
error ? validationId : void 0
|
|
17
|
+
].filter(Boolean).join(' ');
|
|
18
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
13
19
|
children: [
|
|
14
|
-
/*#__PURE__*/
|
|
15
|
-
|
|
16
|
-
children:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
/*#__PURE__*/ jsxs(Popover, {
|
|
21
|
+
"data-slot": "date-picker",
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
24
|
+
asChild: true,
|
|
25
|
+
children: /*#__PURE__*/ jsxs(Button, {
|
|
26
|
+
ref: ref,
|
|
27
|
+
id: id,
|
|
28
|
+
variant: "outline",
|
|
29
|
+
"aria-label": id || ariaLabelledBy ? void 0 : value ? `Selected date: ${format(value, 'PPP')}` : placeholder,
|
|
30
|
+
"aria-labelledby": ariaLabelledBy,
|
|
31
|
+
"aria-describedby": describedBy || void 0,
|
|
32
|
+
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
33
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
34
|
+
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),
|
|
35
|
+
disabled: disabled,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
38
|
+
value ? format(value, 'PPP') : /*#__PURE__*/ jsx("span", {
|
|
39
|
+
className: "text-foreground-muted",
|
|
40
|
+
children: placeholder
|
|
41
|
+
})
|
|
42
|
+
]
|
|
27
43
|
})
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsx(PopoverContent, {
|
|
46
|
+
className: "w-auto p-0",
|
|
47
|
+
children: /*#__PURE__*/ jsx(Calendar, {
|
|
48
|
+
mode: "single",
|
|
49
|
+
selected: value,
|
|
50
|
+
onSelect: onValueChange,
|
|
51
|
+
initialFocus: true,
|
|
52
|
+
...calendarProps
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
]
|
|
30
56
|
}),
|
|
31
|
-
/*#__PURE__*/ jsx(
|
|
32
|
-
|
|
33
|
-
children:
|
|
34
|
-
mode: "single",
|
|
35
|
-
selected: value,
|
|
36
|
-
onSelect: onValueChange,
|
|
37
|
-
initialFocus: true,
|
|
38
|
-
...calendarProps
|
|
39
|
-
})
|
|
57
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
58
|
+
id: validationId,
|
|
59
|
+
children: error
|
|
40
60
|
})
|
|
41
61
|
]
|
|
42
62
|
});
|
|
43
63
|
});
|
|
44
|
-
const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ value, onValueChange, disabled, placeholder = 'Pick a date range', className, calendarProps }, ref) {
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date range', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
65
|
+
const generatedId = useId();
|
|
66
|
+
const validationId = errorId ?? `${id ?? `date-range-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
67
|
+
const describedBy = [
|
|
68
|
+
ariaDescribedBy,
|
|
69
|
+
error ? validationId : void 0
|
|
70
|
+
].filter(Boolean).join(' ');
|
|
71
|
+
const computedLabel = value?.from ? value.to ? `Selected range: ${format(value.from, 'LLL dd, y')} to ${format(value.to, 'LLL dd, y')}` : `Selected date: ${format(value.from, 'LLL dd, y')}` : placeholder;
|
|
72
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
47
73
|
children: [
|
|
48
|
-
/*#__PURE__*/
|
|
49
|
-
|
|
50
|
-
children:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
74
|
+
/*#__PURE__*/ jsxs(Popover, {
|
|
75
|
+
"data-slot": "date-range-picker",
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
78
|
+
asChild: true,
|
|
79
|
+
children: /*#__PURE__*/ jsxs(Button, {
|
|
80
|
+
ref: ref,
|
|
81
|
+
id: id,
|
|
82
|
+
variant: "outline",
|
|
83
|
+
"aria-label": id || ariaLabelledBy ? void 0 : computedLabel,
|
|
84
|
+
"aria-labelledby": ariaLabelledBy,
|
|
85
|
+
"aria-describedby": describedBy || void 0,
|
|
86
|
+
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
87
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
88
|
+
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),
|
|
89
|
+
disabled: disabled,
|
|
59
90
|
children: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
92
|
+
value?.from ? value.to ? /*#__PURE__*/ jsxs(Fragment, {
|
|
93
|
+
children: [
|
|
94
|
+
format(value.from, 'LLL dd, y'),
|
|
95
|
+
" - ",
|
|
96
|
+
format(value.to, 'LLL dd, y')
|
|
97
|
+
]
|
|
98
|
+
}) : format(value.from, 'LLL dd, y') : /*#__PURE__*/ jsx("span", {
|
|
99
|
+
className: "text-foreground-muted",
|
|
100
|
+
children: placeholder
|
|
101
|
+
})
|
|
63
102
|
]
|
|
64
|
-
}) : format(value.from, 'LLL dd, y') : /*#__PURE__*/ jsx("span", {
|
|
65
|
-
className: "text-foreground-muted",
|
|
66
|
-
children: placeholder
|
|
67
103
|
})
|
|
68
|
-
|
|
69
|
-
|
|
104
|
+
}),
|
|
105
|
+
/*#__PURE__*/ jsx(PopoverContent, {
|
|
106
|
+
className: "w-auto p-0",
|
|
107
|
+
align: "start",
|
|
108
|
+
children: /*#__PURE__*/ jsx(Calendar, {
|
|
109
|
+
initialFocus: true,
|
|
110
|
+
mode: "range",
|
|
111
|
+
defaultMonth: value?.from,
|
|
112
|
+
selected: value,
|
|
113
|
+
onSelect: onValueChange,
|
|
114
|
+
numberOfMonths: 2,
|
|
115
|
+
required: false,
|
|
116
|
+
...calendarProps
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
]
|
|
70
120
|
}),
|
|
71
|
-
/*#__PURE__*/ jsx(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children: /*#__PURE__*/ jsx(Calendar, {
|
|
75
|
-
initialFocus: true,
|
|
76
|
-
mode: "range",
|
|
77
|
-
defaultMonth: value?.from,
|
|
78
|
-
selected: value,
|
|
79
|
-
onSelect: onValueChange,
|
|
80
|
-
numberOfMonths: 2,
|
|
81
|
-
required: false,
|
|
82
|
-
...calendarProps
|
|
83
|
-
})
|
|
121
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
122
|
+
id: validationId,
|
|
123
|
+
children: error
|
|
84
124
|
})
|
|
85
125
|
]
|
|
86
126
|
});
|