@uipath/apollo-wind 2.55.0 → 2.57.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/combobox.cjs +33 -15
- package/dist/components/ui/combobox.js +33 -15
- package/dist/components/ui/date-picker.cjs +62 -26
- package/dist/components/ui/date-picker.js +62 -26
- package/dist/components/ui/datetime-picker.cjs +29 -12
- package/dist/components/ui/datetime-picker.js +29 -12
- package/dist/components/ui/dropdown-menu.cjs +12 -8
- package/dist/components/ui/dropdown-menu.js +12 -8
- package/dist/components/ui/field-actions/ai-assist-action.cjs +121 -0
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +21 -0
- package/dist/components/ui/field-actions/ai-assist-action.js +84 -0
- package/dist/components/ui/field-actions/collapse.cjs +44 -0
- package/dist/components/ui/field-actions/collapse.d.ts +6 -0
- package/dist/components/ui/field-actions/collapse.js +4 -0
- package/dist/components/ui/field-actions/index.cjs +46 -0
- package/dist/components/ui/field-actions/index.d.ts +2 -0
- package/dist/components/ui/field-actions/index.js +3 -0
- package/dist/components/ui/field-actions/insert-variable-action.cjs +94 -0
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +22 -0
- package/dist/components/ui/field-actions/insert-variable-action.js +57 -0
- package/dist/components/ui/field-addons/index.cjs +50 -0
- package/dist/components/ui/field-addons/index.d.ts +3 -0
- package/dist/components/ui/field-addons/index.js +4 -0
- package/dist/components/ui/field-addons/value-mode-indicator.cjs +57 -0
- package/dist/components/ui/field-addons/value-mode-indicator.d.ts +13 -0
- package/dist/components/ui/field-addons/value-mode-indicator.js +23 -0
- package/dist/components/ui/field-addons/value-mode-menu.cjs +149 -0
- package/dist/components/ui/field-addons/value-mode-menu.d.ts +69 -0
- package/dist/components/ui/field-addons/value-mode-menu.js +112 -0
- package/dist/components/ui/field-addons/value-mode-strings.cjs +69 -0
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +32 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +29 -0
- package/dist/components/ui/form-field.cjs +42 -5
- package/dist/components/ui/form-field.d.ts +21 -1
- package/dist/components/ui/form-field.js +36 -2
- package/dist/components/ui/index.cjs +156 -126
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +3 -0
- package/dist/components/ui/input-group-context.cjs +91 -0
- package/dist/components/ui/input-group-context.d.ts +69 -0
- package/dist/components/ui/input-group-context.js +42 -0
- package/dist/components/ui/input-group.cjs +303 -56
- package/dist/components/ui/input-group.d.ts +70 -3
- package/dist/components/ui/input-group.js +285 -56
- package/dist/components/ui/input.cjs +28 -17
- package/dist/components/ui/input.js +28 -17
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +16 -114
- package/dist/components/ui/lockable-value-field/components/field-header.js +14 -112
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +4 -12
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +4 -12
- package/dist/components/ui/model-picker/ModelPicker.cjs +495 -0
- package/dist/components/ui/model-picker/ModelPicker.d.ts +304 -0
- package/dist/components/ui/model-picker/ModelPicker.js +451 -0
- package/dist/components/ui/model-picker/ModelTagChip.cjs +101 -0
- package/dist/components/ui/model-picker/ModelTagChip.d.ts +29 -0
- package/dist/components/ui/model-picker/ModelTagChip.js +67 -0
- package/dist/components/ui/model-picker/badges.cjs +52 -0
- package/dist/components/ui/model-picker/badges.d.ts +41 -0
- package/dist/components/ui/model-picker/badges.js +18 -0
- package/dist/components/ui/model-picker/index.cjs +117 -0
- package/dist/components/ui/model-picker/index.d.ts +27 -0
- package/dist/components/ui/model-picker/index.js +14 -0
- package/dist/components/ui/model-picker/labels.cjs +107 -0
- package/dist/components/ui/model-picker/labels.d.ts +81 -0
- package/dist/components/ui/model-picker/labels.js +67 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.cjs +108 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.d.ts +38 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.js +74 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.cjs +84 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.d.ts +64 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.js +50 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.cjs +178 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.d.ts +95 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.js +135 -0
- package/dist/components/ui/model-picker/primitives/OptionList.cjs +295 -0
- package/dist/components/ui/model-picker/primitives/OptionList.d.ts +87 -0
- package/dist/components/ui/model-picker/primitives/OptionList.js +242 -0
- package/dist/components/ui/{lockable-value-field/components/mode-menu-item.cjs → model-picker/primitives/PickerPopup.cjs} +25 -24
- package/dist/components/ui/model-picker/primitives/PickerPopup.d.ts +39 -0
- package/dist/components/ui/model-picker/primitives/PickerPopup.js +30 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.cjs +77 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.d.ts +43 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.js +43 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.cjs +112 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.d.ts +73 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.js +78 -0
- package/dist/components/ui/model-picker/types.cjs +18 -0
- package/dist/components/ui/model-picker/types.d.ts +154 -0
- package/dist/components/ui/model-picker/types.js +0 -0
- package/dist/components/ui/model-picker/useModelPickerState.cjs +250 -0
- package/dist/components/ui/model-picker/useModelPickerState.d.ts +135 -0
- package/dist/components/ui/model-picker/useModelPickerState.js +216 -0
- package/dist/components/ui/model-picker/utils.cjs +327 -0
- package/dist/components/ui/model-picker/utils.d.ts +121 -0
- package/dist/components/ui/model-picker/utils.js +272 -0
- package/dist/components/ui/multi-select.cjs +82 -58
- package/dist/components/ui/multi-select.js +84 -60
- package/dist/components/ui/popover.cjs +13 -9
- package/dist/components/ui/popover.js +13 -9
- package/dist/components/ui/select.cjs +89 -27
- package/dist/components/ui/select.d.ts +4 -0
- package/dist/components/ui/select.js +90 -28
- package/dist/components/ui/textarea.cjs +16 -11
- package/dist/components/ui/textarea.js +16 -11
- package/dist/index.cjs +144 -21
- package/dist/index.d.ts +10 -4
- package/dist/index.js +6 -3
- package/dist/styles.css +350 -5
- package/package.json +2 -1
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +0 -9
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +0 -29
|
@@ -32,18 +32,33 @@ 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_command_cjs_namespaceObject = require("./command.cjs");
|
|
35
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
35
36
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
36
37
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
37
38
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
39
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
38
40
|
const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.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) {
|
|
39
41
|
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
42
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
43
|
+
const grouped = group.inGroup;
|
|
40
44
|
const generatedId = external_react_namespaceObject.useId();
|
|
41
45
|
const validationId = errorId ?? `${id ?? `combobox-${generatedId.replace(/:/g, '')}`}-error`;
|
|
42
|
-
const describedBy = [
|
|
43
|
-
ariaDescribedBy,
|
|
44
|
-
error ? validationId : void 0
|
|
45
|
-
].filter(Boolean).join(' ');
|
|
46
46
|
const selectedItem = items.find((item)=>item.value === value);
|
|
47
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
48
|
+
error,
|
|
49
|
+
errorId: validationId,
|
|
50
|
+
'aria-invalid': ariaInvalid,
|
|
51
|
+
'aria-describedby': ariaDescribedBy,
|
|
52
|
+
'aria-errormessage': ariaErrorMessage
|
|
53
|
+
});
|
|
54
|
+
const triggerProps = {
|
|
55
|
+
id,
|
|
56
|
+
role: 'combobox',
|
|
57
|
+
'aria-expanded': open,
|
|
58
|
+
'aria-label': id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
59
|
+
...validation.aria,
|
|
60
|
+
disabled: disabled || group.disabled
|
|
61
|
+
};
|
|
47
62
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
48
63
|
children: [
|
|
49
64
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
@@ -51,20 +66,22 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
51
66
|
open: open,
|
|
52
67
|
onOpenChange: setOpen,
|
|
53
68
|
children: [
|
|
54
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
69
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
70
|
+
ref: ref,
|
|
71
|
+
...triggerProps,
|
|
72
|
+
className: className,
|
|
73
|
+
placeholder: placeholder,
|
|
74
|
+
children: selectedItem && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
75
|
+
className: "truncate",
|
|
76
|
+
children: selectedItem.label
|
|
77
|
+
})
|
|
78
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
55
79
|
asChild: true,
|
|
56
80
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
57
81
|
ref: ref,
|
|
58
|
-
id: id,
|
|
59
82
|
variant: "outline",
|
|
60
|
-
|
|
61
|
-
"aria-expanded": open,
|
|
62
|
-
"aria-label": id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
63
|
-
"aria-describedby": describedBy || void 0,
|
|
64
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
65
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
83
|
+
...triggerProps,
|
|
66
84
|
className: (0, index_cjs_namespaceObject.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),
|
|
67
|
-
disabled: disabled,
|
|
68
85
|
children: [
|
|
69
86
|
selectedItem ? selectedItem.label : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
70
87
|
className: "text-foreground-muted",
|
|
@@ -77,7 +94,8 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
77
94
|
})
|
|
78
95
|
}),
|
|
79
96
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
80
|
-
className:
|
|
97
|
+
className: (0, index_cjs_namespaceObject.cn)('p-0', grouped ? 'w-(--radix-popover-trigger-width)' : 'w-[280px]'),
|
|
98
|
+
align: grouped ? 'start' : void 0,
|
|
81
99
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command, {
|
|
82
100
|
children: [
|
|
83
101
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandInput, {
|
|
@@ -110,7 +128,7 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
110
128
|
})
|
|
111
129
|
]
|
|
112
130
|
}),
|
|
113
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
131
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
114
132
|
id: validationId,
|
|
115
133
|
children: error
|
|
116
134
|
})
|
|
@@ -4,18 +4,33 @@ import { Check, ChevronDown } from "lucide-react";
|
|
|
4
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
|
+
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
7
8
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
9
|
import { cn } from "../../lib/index.js";
|
|
9
10
|
import { FormFieldError } from "./form-field.js";
|
|
11
|
+
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
10
12
|
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) {
|
|
11
13
|
const [open, setOpen] = useState(false);
|
|
14
|
+
const group = useInputGroup();
|
|
15
|
+
const grouped = group.inGroup;
|
|
12
16
|
const generatedId = useId();
|
|
13
17
|
const validationId = errorId ?? `${id ?? `combobox-${generatedId.replace(/:/g, '')}`}-error`;
|
|
14
|
-
const describedBy = [
|
|
15
|
-
ariaDescribedBy,
|
|
16
|
-
error ? validationId : void 0
|
|
17
|
-
].filter(Boolean).join(' ');
|
|
18
18
|
const selectedItem = items.find((item)=>item.value === value);
|
|
19
|
+
const validation = useControlValidation(group, {
|
|
20
|
+
error,
|
|
21
|
+
errorId: validationId,
|
|
22
|
+
'aria-invalid': ariaInvalid,
|
|
23
|
+
'aria-describedby': ariaDescribedBy,
|
|
24
|
+
'aria-errormessage': ariaErrorMessage
|
|
25
|
+
});
|
|
26
|
+
const triggerProps = {
|
|
27
|
+
id,
|
|
28
|
+
role: 'combobox',
|
|
29
|
+
'aria-expanded': open,
|
|
30
|
+
'aria-label': id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
31
|
+
...validation.aria,
|
|
32
|
+
disabled: disabled || group.disabled
|
|
33
|
+
};
|
|
19
34
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
20
35
|
children: [
|
|
21
36
|
/*#__PURE__*/ jsxs(Popover, {
|
|
@@ -23,20 +38,22 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
23
38
|
open: open,
|
|
24
39
|
onOpenChange: setOpen,
|
|
25
40
|
children: [
|
|
26
|
-
/*#__PURE__*/ jsx(
|
|
41
|
+
grouped ? /*#__PURE__*/ jsx(InputGroupPopoverTrigger, {
|
|
42
|
+
ref: ref,
|
|
43
|
+
...triggerProps,
|
|
44
|
+
className: className,
|
|
45
|
+
placeholder: placeholder,
|
|
46
|
+
children: selectedItem && /*#__PURE__*/ jsx("span", {
|
|
47
|
+
className: "truncate",
|
|
48
|
+
children: selectedItem.label
|
|
49
|
+
})
|
|
50
|
+
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
27
51
|
asChild: true,
|
|
28
52
|
children: /*#__PURE__*/ jsxs(Button, {
|
|
29
53
|
ref: ref,
|
|
30
|
-
id: id,
|
|
31
54
|
variant: "outline",
|
|
32
|
-
|
|
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,
|
|
55
|
+
...triggerProps,
|
|
38
56
|
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
57
|
children: [
|
|
41
58
|
selectedItem ? selectedItem.label : /*#__PURE__*/ jsx("span", {
|
|
42
59
|
className: "text-foreground-muted",
|
|
@@ -49,7 +66,8 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
49
66
|
})
|
|
50
67
|
}),
|
|
51
68
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
52
|
-
className:
|
|
69
|
+
className: cn('p-0', grouped ? 'w-(--radix-popover-trigger-width)' : 'w-[280px]'),
|
|
70
|
+
align: grouped ? 'start' : void 0,
|
|
53
71
|
children: /*#__PURE__*/ jsxs(Command, {
|
|
54
72
|
children: [
|
|
55
73
|
/*#__PURE__*/ jsx(CommandInput, {
|
|
@@ -82,7 +100,7 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
82
100
|
})
|
|
83
101
|
]
|
|
84
102
|
}),
|
|
85
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
103
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
86
104
|
id: validationId,
|
|
87
105
|
children: error
|
|
88
106
|
})
|
|
@@ -34,34 +34,51 @@ const external_lucide_react_namespaceObject = require("lucide-react");
|
|
|
34
34
|
const external_react_namespaceObject = require("react");
|
|
35
35
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
36
36
|
const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
37
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
37
38
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
38
39
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
39
40
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
41
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
40
42
|
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
43
|
const generatedId = external_react_namespaceObject.useId();
|
|
42
44
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
46
|
+
const grouped = group.inGroup;
|
|
47
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
48
|
+
error,
|
|
49
|
+
errorId: validationId,
|
|
50
|
+
'aria-invalid': ariaInvalid,
|
|
51
|
+
'aria-describedby': ariaDescribedBy,
|
|
52
|
+
'aria-errormessage': ariaErrorMessage
|
|
53
|
+
});
|
|
54
|
+
const triggerProps = {
|
|
55
|
+
id,
|
|
56
|
+
'aria-label': id || ariaLabelledBy ? void 0 : value ? `Selected date: ${(0, external_date_fns_namespaceObject.format)(value, 'PPP')}` : placeholder,
|
|
57
|
+
'aria-labelledby': ariaLabelledBy,
|
|
58
|
+
...validation.aria,
|
|
59
|
+
disabled: disabled || group.disabled
|
|
60
|
+
};
|
|
47
61
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
48
62
|
children: [
|
|
49
63
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
50
64
|
"data-slot": "date-picker",
|
|
51
65
|
children: [
|
|
52
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
66
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
67
|
+
ref: ref,
|
|
68
|
+
...triggerProps,
|
|
69
|
+
className: className,
|
|
70
|
+
placeholder: placeholder,
|
|
71
|
+
children: value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
72
|
+
className: "truncate",
|
|
73
|
+
children: (0, external_date_fns_namespaceObject.format)(value, 'PPP')
|
|
74
|
+
})
|
|
75
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
53
76
|
asChild: true,
|
|
54
77
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
78
|
+
...triggerProps,
|
|
55
79
|
ref: ref,
|
|
56
|
-
id: id,
|
|
57
80
|
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
81
|
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
82
|
children: [
|
|
66
83
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
67
84
|
value ? (0, external_date_fns_namespaceObject.format)(value, 'PPP') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
@@ -73,6 +90,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
73
90
|
}),
|
|
74
91
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
75
92
|
className: "w-auto p-0",
|
|
93
|
+
align: grouped ? 'start' : void 0,
|
|
76
94
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
77
95
|
mode: "single",
|
|
78
96
|
selected: value,
|
|
@@ -83,7 +101,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
83
101
|
})
|
|
84
102
|
]
|
|
85
103
|
}),
|
|
86
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
104
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
87
105
|
id: validationId,
|
|
88
106
|
children: error
|
|
89
107
|
})
|
|
@@ -93,29 +111,47 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
93
111
|
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
112
|
const generatedId = external_react_namespaceObject.useId();
|
|
95
113
|
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
114
|
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;
|
|
115
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
116
|
+
const grouped = group.inGroup;
|
|
117
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
118
|
+
error,
|
|
119
|
+
errorId: validationId,
|
|
120
|
+
'aria-invalid': ariaInvalid,
|
|
121
|
+
'aria-describedby': ariaDescribedBy,
|
|
122
|
+
'aria-errormessage': ariaErrorMessage
|
|
123
|
+
});
|
|
124
|
+
const triggerProps = {
|
|
125
|
+
id,
|
|
126
|
+
'aria-label': id || ariaLabelledBy ? void 0 : computedLabel,
|
|
127
|
+
'aria-labelledby': ariaLabelledBy,
|
|
128
|
+
...validation.aria,
|
|
129
|
+
disabled: disabled || group.disabled
|
|
130
|
+
};
|
|
101
131
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
102
132
|
children: [
|
|
103
133
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
104
134
|
"data-slot": "date-range-picker",
|
|
105
135
|
children: [
|
|
106
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
136
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
137
|
+
ref: ref,
|
|
138
|
+
...triggerProps,
|
|
139
|
+
className: className,
|
|
140
|
+
placeholder: placeholder,
|
|
141
|
+
children: value?.from && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
142
|
+
className: "truncate",
|
|
143
|
+
children: [
|
|
144
|
+
(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y'),
|
|
145
|
+
value.to && ` - ${(0, external_date_fns_namespaceObject.format)(value.to, 'LLL dd, y')}`
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
107
149
|
asChild: true,
|
|
108
150
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
151
|
+
...triggerProps,
|
|
109
152
|
ref: ref,
|
|
110
|
-
id: id,
|
|
111
153
|
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
154
|
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,
|
|
119
155
|
children: [
|
|
120
156
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
121
157
|
value?.from ? value.to ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
@@ -147,7 +183,7 @@ const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject
|
|
|
147
183
|
})
|
|
148
184
|
]
|
|
149
185
|
}),
|
|
150
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
186
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
151
187
|
id: validationId,
|
|
152
188
|
children: error
|
|
153
189
|
})
|
|
@@ -5,34 +5,51 @@ import { CalendarIcon } from "lucide-react";
|
|
|
5
5
|
import { forwardRef, useId } from "react";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
7
|
import { Calendar } from "./calendar.js";
|
|
8
|
+
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
8
9
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
10
|
import { cn } from "../../lib/index.js";
|
|
10
11
|
import { FormFieldError } from "./form-field.js";
|
|
12
|
+
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
11
13
|
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
14
|
const generatedId = useId();
|
|
13
15
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const group = useInputGroup();
|
|
17
|
+
const grouped = group.inGroup;
|
|
18
|
+
const validation = useControlValidation(group, {
|
|
19
|
+
error,
|
|
20
|
+
errorId: validationId,
|
|
21
|
+
'aria-invalid': ariaInvalid,
|
|
22
|
+
'aria-describedby': ariaDescribedBy,
|
|
23
|
+
'aria-errormessage': ariaErrorMessage
|
|
24
|
+
});
|
|
25
|
+
const triggerProps = {
|
|
26
|
+
id,
|
|
27
|
+
'aria-label': id || ariaLabelledBy ? void 0 : value ? `Selected date: ${format(value, 'PPP')}` : placeholder,
|
|
28
|
+
'aria-labelledby': ariaLabelledBy,
|
|
29
|
+
...validation.aria,
|
|
30
|
+
disabled: disabled || group.disabled
|
|
31
|
+
};
|
|
18
32
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
19
33
|
children: [
|
|
20
34
|
/*#__PURE__*/ jsxs(Popover, {
|
|
21
35
|
"data-slot": "date-picker",
|
|
22
36
|
children: [
|
|
23
|
-
/*#__PURE__*/ jsx(
|
|
37
|
+
grouped ? /*#__PURE__*/ jsx(InputGroupPopoverTrigger, {
|
|
38
|
+
ref: ref,
|
|
39
|
+
...triggerProps,
|
|
40
|
+
className: className,
|
|
41
|
+
placeholder: placeholder,
|
|
42
|
+
children: value && /*#__PURE__*/ jsx("span", {
|
|
43
|
+
className: "truncate",
|
|
44
|
+
children: format(value, 'PPP')
|
|
45
|
+
})
|
|
46
|
+
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
24
47
|
asChild: true,
|
|
25
48
|
children: /*#__PURE__*/ jsxs(Button, {
|
|
49
|
+
...triggerProps,
|
|
26
50
|
ref: ref,
|
|
27
|
-
id: id,
|
|
28
51
|
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
52
|
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
53
|
children: [
|
|
37
54
|
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
38
55
|
value ? format(value, 'PPP') : /*#__PURE__*/ jsx("span", {
|
|
@@ -44,6 +61,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
44
61
|
}),
|
|
45
62
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
46
63
|
className: "w-auto p-0",
|
|
64
|
+
align: grouped ? 'start' : void 0,
|
|
47
65
|
children: /*#__PURE__*/ jsx(Calendar, {
|
|
48
66
|
mode: "single",
|
|
49
67
|
selected: value,
|
|
@@ -54,7 +72,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
54
72
|
})
|
|
55
73
|
]
|
|
56
74
|
}),
|
|
57
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
75
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
58
76
|
id: validationId,
|
|
59
77
|
children: error
|
|
60
78
|
})
|
|
@@ -64,29 +82,47 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
64
82
|
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
83
|
const generatedId = useId();
|
|
66
84
|
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
85
|
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;
|
|
86
|
+
const group = useInputGroup();
|
|
87
|
+
const grouped = group.inGroup;
|
|
88
|
+
const validation = useControlValidation(group, {
|
|
89
|
+
error,
|
|
90
|
+
errorId: validationId,
|
|
91
|
+
'aria-invalid': ariaInvalid,
|
|
92
|
+
'aria-describedby': ariaDescribedBy,
|
|
93
|
+
'aria-errormessage': ariaErrorMessage
|
|
94
|
+
});
|
|
95
|
+
const triggerProps = {
|
|
96
|
+
id,
|
|
97
|
+
'aria-label': id || ariaLabelledBy ? void 0 : computedLabel,
|
|
98
|
+
'aria-labelledby': ariaLabelledBy,
|
|
99
|
+
...validation.aria,
|
|
100
|
+
disabled: disabled || group.disabled
|
|
101
|
+
};
|
|
72
102
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
73
103
|
children: [
|
|
74
104
|
/*#__PURE__*/ jsxs(Popover, {
|
|
75
105
|
"data-slot": "date-range-picker",
|
|
76
106
|
children: [
|
|
77
|
-
/*#__PURE__*/ jsx(
|
|
107
|
+
grouped ? /*#__PURE__*/ jsx(InputGroupPopoverTrigger, {
|
|
108
|
+
ref: ref,
|
|
109
|
+
...triggerProps,
|
|
110
|
+
className: className,
|
|
111
|
+
placeholder: placeholder,
|
|
112
|
+
children: value?.from && /*#__PURE__*/ jsxs("span", {
|
|
113
|
+
className: "truncate",
|
|
114
|
+
children: [
|
|
115
|
+
format(value.from, 'LLL dd, y'),
|
|
116
|
+
value.to && ` - ${format(value.to, 'LLL dd, y')}`
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
78
120
|
asChild: true,
|
|
79
121
|
children: /*#__PURE__*/ jsxs(Button, {
|
|
122
|
+
...triggerProps,
|
|
80
123
|
ref: ref,
|
|
81
|
-
id: id,
|
|
82
124
|
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
125
|
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,
|
|
90
126
|
children: [
|
|
91
127
|
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
92
128
|
value?.from ? value.to ? /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -118,7 +154,7 @@ const date_picker_DateRangePicker = /*#__PURE__*/ forwardRef(function({ id, valu
|
|
|
118
154
|
})
|
|
119
155
|
]
|
|
120
156
|
}),
|
|
121
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
157
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
122
158
|
id: validationId,
|
|
123
159
|
children: error
|
|
124
160
|
})
|
|
@@ -33,18 +33,16 @@ 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
35
|
const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
36
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
36
37
|
const external_label_cjs_namespaceObject = require("./label.cjs");
|
|
37
38
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
38
39
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
39
40
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
41
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
40
42
|
const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ value, onValueChange, disabled, placeholder = 'Pick a date and time', className, use12Hour = false, id, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
41
43
|
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
42
44
|
const generatedId = external_react_namespaceObject.useId();
|
|
43
45
|
const validationId = errorId ?? `${id ?? `datetime-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
44
|
-
const describedBy = [
|
|
45
|
-
ariaDescribedBy,
|
|
46
|
-
error ? validationId : void 0
|
|
47
|
-
].filter(Boolean).join(' ');
|
|
48
46
|
const [selectedDate, setSelectedDate] = external_react_namespaceObject.useState(value);
|
|
49
47
|
const [timeValue, setTimeValue] = external_react_namespaceObject.useState(value ? (0, external_date_fns_namespaceObject.format)(value, use12Hour ? 'hh:mm a' : 'HH:mm') : '');
|
|
50
48
|
const handleDateSelect = (date)=>{
|
|
@@ -74,6 +72,21 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
74
72
|
const timePart = (0, external_date_fns_namespaceObject.format)(selectedDate, use12Hour ? 'hh:mm a' : 'HH:mm');
|
|
75
73
|
return `${datePart} at ${timePart}`;
|
|
76
74
|
};
|
|
75
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
76
|
+
const grouped = group.inGroup;
|
|
77
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
78
|
+
error,
|
|
79
|
+
errorId: validationId,
|
|
80
|
+
'aria-invalid': ariaInvalid,
|
|
81
|
+
'aria-describedby': ariaDescribedBy,
|
|
82
|
+
'aria-errormessage': ariaErrorMessage
|
|
83
|
+
});
|
|
84
|
+
const triggerProps = {
|
|
85
|
+
id,
|
|
86
|
+
'aria-labelledby': ariaLabelledBy,
|
|
87
|
+
...validation.aria,
|
|
88
|
+
disabled: disabled || group.disabled
|
|
89
|
+
};
|
|
77
90
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
78
91
|
children: [
|
|
79
92
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
@@ -81,18 +94,22 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
81
94
|
open: open,
|
|
82
95
|
onOpenChange: setOpen,
|
|
83
96
|
children: [
|
|
84
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
97
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
98
|
+
ref: ref,
|
|
99
|
+
...triggerProps,
|
|
100
|
+
className: className,
|
|
101
|
+
placeholder: placeholder,
|
|
102
|
+
children: selectedDate && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
103
|
+
className: "truncate",
|
|
104
|
+
children: formatDisplayValue()
|
|
105
|
+
})
|
|
106
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
85
107
|
asChild: true,
|
|
86
108
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
109
|
+
...triggerProps,
|
|
87
110
|
ref: ref,
|
|
88
|
-
id: id,
|
|
89
|
-
"aria-labelledby": ariaLabelledBy,
|
|
90
|
-
"aria-describedby": describedBy || void 0,
|
|
91
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
92
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
93
111
|
variant: "outline",
|
|
94
112
|
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),
|
|
95
|
-
disabled: disabled,
|
|
96
113
|
children: [
|
|
97
114
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {
|
|
98
115
|
className: "mr-2 h-4 w-4"
|
|
@@ -163,7 +180,7 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ external_react_namespaceObj
|
|
|
163
180
|
})
|
|
164
181
|
]
|
|
165
182
|
}),
|
|
166
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
183
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
167
184
|
id: validationId,
|
|
168
185
|
children: error
|
|
169
186
|
})
|
|
@@ -5,18 +5,16 @@ import { forwardRef, useId, useState } from "react";
|
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { Calendar } from "./calendar.js";
|
|
7
7
|
import { Input } from "./input.js";
|
|
8
|
+
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
8
9
|
import { Label } from "./label.js";
|
|
9
10
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
10
11
|
import { cn } from "../../lib/index.js";
|
|
11
12
|
import { FormFieldError } from "./form-field.js";
|
|
13
|
+
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
12
14
|
const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value, onValueChange, disabled, placeholder = 'Pick a date and time', className, use12Hour = false, id, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
13
15
|
const [open, setOpen] = useState(false);
|
|
14
16
|
const generatedId = useId();
|
|
15
17
|
const validationId = errorId ?? `${id ?? `datetime-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
16
|
-
const describedBy = [
|
|
17
|
-
ariaDescribedBy,
|
|
18
|
-
error ? validationId : void 0
|
|
19
|
-
].filter(Boolean).join(' ');
|
|
20
18
|
const [selectedDate, setSelectedDate] = useState(value);
|
|
21
19
|
const [timeValue, setTimeValue] = useState(value ? format(value, use12Hour ? 'hh:mm a' : 'HH:mm') : '');
|
|
22
20
|
const handleDateSelect = (date)=>{
|
|
@@ -46,6 +44,21 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
46
44
|
const timePart = format(selectedDate, use12Hour ? 'hh:mm a' : 'HH:mm');
|
|
47
45
|
return `${datePart} at ${timePart}`;
|
|
48
46
|
};
|
|
47
|
+
const group = useInputGroup();
|
|
48
|
+
const grouped = group.inGroup;
|
|
49
|
+
const validation = useControlValidation(group, {
|
|
50
|
+
error,
|
|
51
|
+
errorId: validationId,
|
|
52
|
+
'aria-invalid': ariaInvalid,
|
|
53
|
+
'aria-describedby': ariaDescribedBy,
|
|
54
|
+
'aria-errormessage': ariaErrorMessage
|
|
55
|
+
});
|
|
56
|
+
const triggerProps = {
|
|
57
|
+
id,
|
|
58
|
+
'aria-labelledby': ariaLabelledBy,
|
|
59
|
+
...validation.aria,
|
|
60
|
+
disabled: disabled || group.disabled
|
|
61
|
+
};
|
|
49
62
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
50
63
|
children: [
|
|
51
64
|
/*#__PURE__*/ jsxs(Popover, {
|
|
@@ -53,18 +66,22 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
53
66
|
open: open,
|
|
54
67
|
onOpenChange: setOpen,
|
|
55
68
|
children: [
|
|
56
|
-
/*#__PURE__*/ jsx(
|
|
69
|
+
grouped ? /*#__PURE__*/ jsx(InputGroupPopoverTrigger, {
|
|
70
|
+
ref: ref,
|
|
71
|
+
...triggerProps,
|
|
72
|
+
className: className,
|
|
73
|
+
placeholder: placeholder,
|
|
74
|
+
children: selectedDate && /*#__PURE__*/ jsx("span", {
|
|
75
|
+
className: "truncate",
|
|
76
|
+
children: formatDisplayValue()
|
|
77
|
+
})
|
|
78
|
+
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
57
79
|
asChild: true,
|
|
58
80
|
children: /*#__PURE__*/ jsxs(Button, {
|
|
81
|
+
...triggerProps,
|
|
59
82
|
ref: ref,
|
|
60
|
-
id: id,
|
|
61
|
-
"aria-labelledby": ariaLabelledBy,
|
|
62
|
-
"aria-describedby": describedBy || void 0,
|
|
63
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
64
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
65
83
|
variant: "outline",
|
|
66
84
|
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),
|
|
67
|
-
disabled: disabled,
|
|
68
85
|
children: [
|
|
69
86
|
/*#__PURE__*/ jsx(CalendarIcon, {
|
|
70
87
|
className: "mr-2 h-4 w-4"
|
|
@@ -135,7 +152,7 @@ const datetime_picker_DateTimePicker = /*#__PURE__*/ forwardRef(function({ value
|
|
|
135
152
|
})
|
|
136
153
|
]
|
|
137
154
|
}),
|
|
138
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
155
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
139
156
|
id: validationId,
|
|
140
157
|
children: error
|
|
141
158
|
})
|