@povio/ui 2.3.0-rc.3 → 2.3.0-rc.33

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.
Files changed (218) hide show
  1. package/dist/assets/icons/AlignCenter.js +26 -11
  2. package/dist/assets/icons/AlignLeft.js +26 -11
  3. package/dist/assets/icons/AlignLeftRight.js +26 -11
  4. package/dist/assets/icons/AlignRight.js +26 -11
  5. package/dist/assets/icons/ArrowDropDown.js +26 -11
  6. package/dist/assets/icons/ArrowDropUp.js +26 -11
  7. package/dist/assets/icons/ArrowLeft.js +26 -11
  8. package/dist/assets/icons/ArrowRight.js +26 -11
  9. package/dist/assets/icons/Bold.js +26 -11
  10. package/dist/assets/icons/BulletedList.js +26 -11
  11. package/dist/assets/icons/Calendar.js +28 -13
  12. package/dist/assets/icons/Check.js +28 -13
  13. package/dist/assets/icons/CheckCircle.js +26 -11
  14. package/dist/assets/icons/CheckboxCheckmark.js +29 -14
  15. package/dist/assets/icons/CheckboxIndeterminate.js +29 -14
  16. package/dist/assets/icons/ChevronDown.js +28 -13
  17. package/dist/assets/icons/ChevronLeft.js +28 -13
  18. package/dist/assets/icons/ChevronRight.js +28 -13
  19. package/dist/assets/icons/ChevronUp.js +28 -13
  20. package/dist/assets/icons/ChevronsLeft.js +28 -13
  21. package/dist/assets/icons/ChevronsRight.js +28 -13
  22. package/dist/assets/icons/Clock.js +26 -11
  23. package/dist/assets/icons/Close.js +26 -11
  24. package/dist/assets/icons/DateTime.js +35 -14
  25. package/dist/assets/icons/DragIndicator.js +26 -11
  26. package/dist/assets/icons/File.js +28 -13
  27. package/dist/assets/icons/Highlight.js +26 -11
  28. package/dist/assets/icons/HighlightOn.js +49 -15
  29. package/dist/assets/icons/Home.js +26 -11
  30. package/dist/assets/icons/Info.js +37 -16
  31. package/dist/assets/icons/Italic.js +26 -11
  32. package/dist/assets/icons/Link.js +26 -11
  33. package/dist/assets/icons/Menu.js +26 -11
  34. package/dist/assets/icons/NumberedList.js +26 -11
  35. package/dist/assets/icons/PointerHorizontal.js +26 -11
  36. package/dist/assets/icons/PointerVertical.js +26 -11
  37. package/dist/assets/icons/Search.js +26 -11
  38. package/dist/assets/icons/Send.js +28 -13
  39. package/dist/assets/icons/Strikethrough.js +26 -11
  40. package/dist/assets/icons/TextColor.js +48 -14
  41. package/dist/assets/icons/Today.js +26 -11
  42. package/dist/assets/icons/Underlined.js +28 -13
  43. package/dist/assets/icons/Upload.js +35 -14
  44. package/dist/assets/icons/Visibility.js +26 -11
  45. package/dist/assets/icons/VisibilityOff.js +26 -11
  46. package/dist/assets/icons/WarningFilled.js +28 -13
  47. package/dist/components/Breadcrumbs/Breadcrumbs.js +207 -56
  48. package/dist/components/Menu/Menu.js +18 -2
  49. package/dist/components/Menu/MenuDesktop.js +41 -7
  50. package/dist/components/Menu/MenuItem.js +32 -9
  51. package/dist/components/Menu/MenuMobile.js +97 -38
  52. package/dist/components/Menu/MenuPopover.js +105 -29
  53. package/dist/components/buttons/IconButton/IconButton.js +40 -8
  54. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +34 -9
  55. package/dist/components/buttons/PillButton/PillButton.js +55 -17
  56. package/dist/components/buttons/SplitButton/SplitButton.js +103 -18
  57. package/dist/components/buttons/TextButton/TextButton.js +30 -8
  58. package/dist/components/buttons/ToggleButton/ToggleButton.js +28 -8
  59. package/dist/components/buttons/shared/ButtonContent.js +80 -22
  60. package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -0
  61. package/dist/components/inputs/Checkbox/Checkbox.js +188 -34
  62. package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +24 -10
  63. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -0
  64. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +268 -87
  65. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -0
  66. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +348 -182
  67. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -0
  68. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +178 -69
  69. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -0
  70. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +530 -157
  71. package/dist/components/inputs/DateTime/shared/Calendar.js +333 -137
  72. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +2 -1
  73. package/dist/components/inputs/DateTime/shared/CalendarCell.js +301 -102
  74. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +2 -1
  75. package/dist/components/inputs/DateTime/shared/CalendarGrid.js +146 -33
  76. package/dist/components/inputs/DateTime/shared/CalendarHeader.js +245 -90
  77. package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +318 -137
  78. package/dist/components/inputs/DateTime/shared/DateField.js +311 -112
  79. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +7 -1
  80. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +376 -146
  81. package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +94 -21
  82. package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +81 -27
  83. package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +59 -10
  84. package/dist/components/inputs/DateTime/shared/MonthPicker.js +103 -58
  85. package/dist/components/inputs/DateTime/shared/RangeCalendar.js +193 -82
  86. package/dist/components/inputs/DateTime/shared/TimeField.js +27 -8
  87. package/dist/components/inputs/DateTime/shared/TimePickerForm.js +279 -110
  88. package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +3 -1
  89. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +208 -70
  90. package/dist/components/inputs/DateTime/shared/YearPicker.js +119 -68
  91. package/dist/components/inputs/File/FileUpload.js +86 -44
  92. package/dist/components/inputs/File/FileUploadContainer.js +15 -7
  93. package/dist/components/inputs/File/InputUpload.js +317 -79
  94. package/dist/components/inputs/File/shared/FileCard.js +104 -41
  95. package/dist/components/inputs/File/shared/FileCardList.js +47 -12
  96. package/dist/components/inputs/File/shared/FileUploadContent.js +175 -44
  97. package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +149 -46
  98. package/dist/components/inputs/File/shared/FileUploadContentError.js +234 -93
  99. package/dist/components/inputs/File/shared/FileUploadContentFilled.js +230 -97
  100. package/dist/components/inputs/File/shared/FileUploadContentLoading.js +199 -55
  101. package/dist/components/inputs/File/shared/InputUploadContent.js +148 -35
  102. package/dist/components/inputs/File/shared/InputUploadFilled.js +49 -8
  103. package/dist/components/inputs/File/shared/ProgressBar.js +48 -9
  104. package/dist/components/inputs/FormField/FormField.js +119 -37
  105. package/dist/components/inputs/FormField/FormFieldError.js +25 -5
  106. package/dist/components/inputs/FormField/FormFieldHeader.js +79 -22
  107. package/dist/components/inputs/FormField/FormFieldHeaderClose.js +31 -7
  108. package/dist/components/inputs/FormField/FormFieldHelper.js +26 -6
  109. package/dist/components/inputs/FormField/FormFieldLabel.js +40 -9
  110. package/dist/components/inputs/Input/NumberInput/NumberInput.js +392 -123
  111. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +541 -116
  112. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +463 -146
  113. package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +48 -9
  114. package/dist/components/inputs/Input/TextArea/TextArea.js +298 -89
  115. package/dist/components/inputs/Input/TextInput/TextInput.js +370 -121
  116. package/dist/components/inputs/Input/shared/InputContent.js +190 -58
  117. package/dist/components/inputs/Inputs/Form.js +40 -11
  118. package/dist/components/inputs/Inputs/InputItem.d.ts +0 -1
  119. package/dist/components/inputs/Inputs/InputItem.js +65 -16
  120. package/dist/components/inputs/Inputs/Inputs.js +37 -11
  121. package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -0
  122. package/dist/components/inputs/RadioGroup/RadioGroup.js +333 -107
  123. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +145 -50
  124. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +3 -2
  125. package/dist/components/inputs/Selection/Select/QuerySelect.js +107 -27
  126. package/dist/components/inputs/Selection/Select/Select.js +139 -44
  127. package/dist/components/inputs/Selection/shared/SelectBase.js +69 -20
  128. package/dist/components/inputs/Selection/shared/SelectDesktop.js +390 -143
  129. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  130. package/dist/components/inputs/Selection/shared/SelectInput.js +326 -136
  131. package/dist/components/inputs/Selection/shared/SelectInputTags.js +99 -25
  132. package/dist/components/inputs/Selection/shared/SelectListBox.js +163 -51
  133. package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +85 -35
  134. package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +69 -16
  135. package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +70 -21
  136. package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +58 -9
  137. package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +9 -0
  138. package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +47 -0
  139. package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
  140. package/dist/components/inputs/Selection/shared/select.context.js +44 -38
  141. package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +5 -0
  142. package/dist/components/inputs/Selection/shared/selectInput.cva.js +5 -0
  143. package/dist/components/inputs/Selection/shared/useSelectItems.js +109 -49
  144. package/dist/components/inputs/Skeleton/InputFrame.d.ts +2 -0
  145. package/dist/components/inputs/Skeleton/InputFrame.js +444 -124
  146. package/dist/components/inputs/Slider/Slider.js +247 -74
  147. package/dist/components/inputs/TextEditor/TextEditor.js +447 -103
  148. package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +37 -11
  149. package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +102 -30
  150. package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +194 -45
  151. package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +88 -28
  152. package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +48 -14
  153. package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +66 -19
  154. package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +49 -15
  155. package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +92 -32
  156. package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +126 -54
  157. package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +141 -38
  158. package/dist/components/inputs/Toggle/Toggle.d.ts +1 -0
  159. package/dist/components/inputs/Toggle/Toggle.js +206 -41
  160. package/dist/components/inputs/shared/CheckContent.js +21 -10
  161. package/dist/components/inputs/shared/InputClear.js +78 -21
  162. package/dist/components/inputs/shared/TooltipWrapper.js +47 -12
  163. package/dist/components/inputs/shared/input.cva.js +13 -3
  164. package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +1 -0
  165. package/dist/components/inputs/shared/useStaticInputHandoff.js +87 -34
  166. package/dist/components/navigation/Accordion/Accordion.js +69 -22
  167. package/dist/components/navigation/Accordion/AccordionItem.js +86 -41
  168. package/dist/components/navigation/Stepper/Stepper.js +67 -22
  169. package/dist/components/navigation/Stepper/StepperItem.js +104 -31
  170. package/dist/components/navigation/Stepper/StepperSeparator.js +23 -5
  171. package/dist/components/overlays/ActionModal/ActionModal.js +169 -35
  172. package/dist/components/overlays/BottomSheet/BottomSheet.js +96 -23
  173. package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +48 -8
  174. package/dist/components/overlays/Drawer/Drawer.js +62 -20
  175. package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +83 -27
  176. package/dist/components/overlays/Tooltip/Tooltip.js +137 -28
  177. package/dist/components/overlays/Tooltip/TooltipEllipsis.js +37 -12
  178. package/dist/components/segment/Segment.js +218 -57
  179. package/dist/components/segment/SegmentItem.js +67 -10
  180. package/dist/components/shared/pagination/Pagination.js +108 -22
  181. package/dist/components/shared/pagination/PaginationList.js +167 -64
  182. package/dist/components/status/Alert/Alert.js +97 -30
  183. package/dist/components/status/Loader/Loader.js +77 -22
  184. package/dist/components/status/Toast/Toast.js +21 -13
  185. package/dist/components/status/Toast/useToast.js +62 -57
  186. package/dist/components/table/ColumnConfig.js +158 -54
  187. package/dist/components/table/InfiniteTable.js +67 -16
  188. package/dist/components/table/PaginatedTable.js +84 -18
  189. package/dist/components/table/Table.js +28 -27
  190. package/dist/components/text/Link/Link.js +19 -7
  191. package/dist/components/text/Typography/Typography.js +23 -8
  192. package/dist/config/confirmation.context.js +1 -1
  193. package/dist/config/link.context.js +23 -9
  194. package/dist/config/router.context.js +42 -16
  195. package/dist/config/theme.context.js +98 -45
  196. package/dist/config/uiConfig.context.d.ts +4 -4
  197. package/dist/config/uiConfig.context.js +50 -11
  198. package/dist/config/uiStyle.context.js +15 -5
  199. package/dist/helpers/dynamicInputs.d.ts +1 -1
  200. package/dist/hooks/useBreakpoint.js +16 -3
  201. package/dist/hooks/useDebounceCallback.js +51 -17
  202. package/dist/hooks/useFilters.js +125 -64
  203. package/dist/hooks/useForm.js +42 -8
  204. package/dist/hooks/useFormAutosave.js +101 -30
  205. package/dist/hooks/useIntersectionObserver.js +86 -32
  206. package/dist/hooks/useLocalStorage.js +43 -10
  207. package/dist/hooks/useLongPressRepeat.js +55 -20
  208. package/dist/hooks/usePagination.js +49 -19
  209. package/dist/hooks/useQueryAutocomplete.js +1 -0
  210. package/dist/hooks/useScrollableListBox.js +37 -16
  211. package/dist/hooks/useSorting.js +69 -28
  212. package/dist/hooks/useStateAndRef.js +21 -7
  213. package/dist/hooks/useTableColumnConfig.js +124 -31
  214. package/dist/hooks/useTranslationMemo.js +25 -5
  215. package/dist/index.js +2 -2
  216. package/dist/utils/date-time.utils.d.ts +2 -0
  217. package/dist/utils/date-time.utils.js +17 -13
  218. package/package.json +1 -1
@@ -12,19 +12,22 @@ import { FormField } from "../../FormField/FormField.js";
12
12
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
13
13
  import { InputFrame } from "../../Skeleton/InputFrame.js";
14
14
  import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
15
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
16
+ import { c } from "react/compiler-runtime";
15
17
  import { jsx, jsxs } from "react/jsx-runtime";
16
18
  import { clsx } from "clsx";
17
19
  import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
18
20
  import { useDatePicker, useLocale } from "react-aria";
19
21
  import { mergeRefs } from "@react-aria/utils";
20
- import { Controller, useWatch } from "react-hook-form";
21
- import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
22
+ import { Controller } from "react-hook-form";
23
+ import { createCalendar, toCalendarDate, today } from "@internationalized/date";
22
24
  import { DateTime } from "luxon";
23
25
  import { useCalendarState, useDatePickerState } from "react-stately";
24
26
  //#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
27
+ var DATE_PICKER_TIME_ZONE = "UTC";
25
28
  var DatePickerBase = (props) => {
26
29
  const ui = UIConfig.useConfig();
27
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as: asProp, hideLabel: hideLabelProp, variant: variantProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, granularity: granularityProp, autoFixYear: autoFixYearProp, format, ...rest } = props;
30
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as: asProp, hideLabel: hideLabelProp, variant: variantProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, granularity: granularityProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, format, ...rest } = props;
28
31
  const as = asProp ?? ui.input.as;
29
32
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
30
33
  const variant = variantProp ?? ui.input.variant;
@@ -38,6 +41,7 @@ var DatePickerBase = (props) => {
38
41
  const shouldUpdateDateOnMonthYearChange = shouldUpdateDateOnMonthYearChangeProp ?? ui.dateInput.shouldUpdateDateOnMonthYearChange;
39
42
  const granularity = granularityProp ?? ui.dateInput.granularity;
40
43
  const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
44
+ const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
41
45
  const normalizeByGranularity = useCallback((date) => {
42
46
  if (granularity === "year") return date.set({
43
47
  month: 1,
@@ -63,36 +67,42 @@ var DatePickerBase = (props) => {
63
67
  const datePickerRef = useMemo(() => ({ get current() {
64
68
  return datePickerInputRef.current?.getContainer?.() || null;
65
69
  } }), []);
66
- useImperativeHandle(ref, () => ({ clear: () => {
67
- datePickerInputRef.current?.clear();
68
- } }));
70
+ useImperativeHandle(ref, () => ({
71
+ clear: () => {
72
+ datePickerInputRef.current?.clear();
73
+ },
74
+ getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
75
+ }));
69
76
  const handleBlur = (val) => {
70
77
  onBlur?.({ target: { value: val } });
71
78
  };
79
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
80
+ const normalizedValue = value ?? null;
72
81
  const dialogState = useDatePickerState({
73
82
  ...rest,
74
- defaultValue: value || rest.defaultValue,
83
+ defaultValue: normalizedValue ?? rest.defaultValue ?? null,
75
84
  shouldCloseOnSelect: false,
76
85
  shouldForceLeadingZeros
77
86
  });
78
87
  const state = useDatePickerState({
79
88
  ...rest,
80
89
  shouldForceLeadingZeros,
81
- value,
82
- onChange: (val) => {
83
- let normalizedValue = val;
84
- if (val) normalizedValue = normalizeByGranularity(val);
85
- if (normalizedValue && (rest.minValue && normalizedValue < rest?.minValue || rest?.maxValue && normalizedValue > rest?.maxValue)) {
90
+ value: normalizedValue,
91
+ onChange: (val_0) => {
92
+ let normalizedValue_0 = val_0;
93
+ if (val_0) normalizedValue_0 = normalizeByGranularity(val_0);
94
+ if (normalizedValue_0 && (rest.minValue && normalizedValue_0 < rest?.minValue || rest?.maxValue && normalizedValue_0 > rest?.maxValue)) {
86
95
  state.setValue(state.value);
87
96
  return;
88
97
  }
89
- onChange?.(normalizedValue);
90
- dialogState.setValue(normalizedValue);
91
- if (normalizedValue) {
92
- calendarState.setFocusedDate(normalizedValue);
98
+ onChange?.(normalizedValue_0);
99
+ dialogState.setValue(normalizedValue_0);
100
+ if (fireBlurOnChange) debouncedBlur(normalizedValue_0);
101
+ if (normalizedValue_0) {
102
+ calendarState.setFocusedDate(normalizedValue_0);
93
103
  return;
94
104
  }
95
- calendarState.setFocusedDate(today(getLocalTimeZone()));
105
+ calendarState.setFocusedDate(today(DATE_PICKER_TIME_ZONE));
96
106
  },
97
107
  shouldCloseOnSelect: false
98
108
  });
@@ -127,11 +137,11 @@ var DatePickerBase = (props) => {
127
137
  const newValue = dialogState.value ? normalizeByGranularity(dialogState.value) : dialogState.value;
128
138
  state.setValue(newValue);
129
139
  state.toggle();
130
- handleBlur(newValue);
140
+ if (fireBlurOnChange) handleBlur(newValue);
131
141
  };
132
142
  const onMonthYearChange = (selectedDate) => {
133
143
  if (!(shouldUpdateDateOnMonthYearChange || granularity !== "day")) return;
134
- const updatedDate = normalizeByGranularity((dialogState.value || state.value || today(getLocalTimeZone())).set({
144
+ const updatedDate = normalizeByGranularity((dialogState.value || state.value || today(DATE_PICKER_TIME_ZONE)).set({
135
145
  year: selectedDate.year,
136
146
  month: selectedDate.month
137
147
  }));
@@ -142,15 +152,22 @@ var DatePickerBase = (props) => {
142
152
  onApply();
143
153
  };
144
154
  const onTodayPress = () => {
145
- const todayValue = normalizeByGranularity(today(getLocalTimeZone()));
155
+ const todayValue = normalizeByGranularity(today(DATE_PICKER_TIME_ZONE));
146
156
  dialogState.setValue(todayValue);
147
157
  calendarState.setFocusedDate(todayValue);
148
158
  };
159
+ const onInputClear = () => {
160
+ onChange?.(null);
161
+ state.setValue(null);
162
+ dialogState.setValue(null);
163
+ calendarState.setFocusedDate(today(DATE_PICKER_TIME_ZONE));
164
+ if (fireBlurOnChange) handleBlur(null);
165
+ };
149
166
  useEffect(() => {
150
167
  if (!state.isOpen) return;
151
168
  if (granularity !== "year") return;
152
169
  if (dialogState.value) return;
153
- const defaultYearValue = normalizeByGranularity(today(getLocalTimeZone()));
170
+ const defaultYearValue = normalizeByGranularity(today(DATE_PICKER_TIME_ZONE));
154
171
  dialogState.setValue(defaultYearValue);
155
172
  calendarState.setFocusedDate(defaultYearValue);
156
173
  }, [
@@ -164,7 +181,7 @@ var DatePickerBase = (props) => {
164
181
  const onOpenChange = (isOpen) => {
165
182
  state.toggle();
166
183
  if (state.value) calendarState.setFocusedDate(normalizeByGranularity(state.value));
167
- if (!state.value) calendarState.setFocusedDate(today(getLocalTimeZone()));
184
+ if (!state.value) calendarState.setFocusedDate(today(DATE_PICKER_TIME_ZONE));
168
185
  if (!isOpen) dialogState.setValue(state.value);
169
186
  };
170
187
  return /* @__PURE__ */ jsx(TooltipWrapper, {
@@ -182,6 +199,9 @@ var DatePickerBase = (props) => {
182
199
  as,
183
200
  groupProps,
184
201
  fieldProps,
202
+ fieldValue: normalizedValue,
203
+ isValueControlled: true,
204
+ hasValue: normalizedValue != null,
185
205
  buttonProps,
186
206
  isDirty,
187
207
  isDisabled,
@@ -200,7 +220,10 @@ var DatePickerBase = (props) => {
200
220
  placeholder,
201
221
  className: inputClassName,
202
222
  dateGranularity: granularity,
203
- format
223
+ format,
224
+ timeZone: DATE_PICKER_TIME_ZONE,
225
+ fireBlurOnChange,
226
+ onClear: onInputClear
204
227
  }), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
205
228
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
206
229
  isDisabled,
@@ -226,7 +249,11 @@ var DatePickerBase = (props) => {
226
249
  })
227
250
  });
228
251
  };
229
- var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, renderStaticInput, ...props }) => {
252
+ var DatePickerInner = (t0) => {
253
+ const $ = c(28);
254
+ const { fullIso: t1, granularity: t2, minValue, maxValue, renderStaticInput, isFormControlDisabled, ...props } = t0;
255
+ const fullIso = t1 === void 0 ? true : t1;
256
+ const granularity = t2 === void 0 ? "day" : t2;
230
257
  const ui = UIConfig.useConfig();
231
258
  const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
232
259
  const { locale } = useLocale();
@@ -237,44 +264,77 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ren
237
264
  inputRef,
238
265
  renderInput,
239
266
  setRenderInput,
240
- getFocusTarget: (input) => {
241
- return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
242
- }
267
+ getFocusTarget: _temp
243
268
  });
244
- const watchedValue = "formControl" in props && props.formControl ? useWatch({
245
- control: props.formControl.control,
246
- name: props.formControl.name
247
- }) : props.value;
248
- let isFormControlDisabled = false;
249
- if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
250
- const rawValue = watchedValue ?? props.value ?? null;
251
- const normalizeByGranularity = (date) => {
252
- if (granularity === "year") return date.set({
253
- month: 1,
254
- day: 1
255
- });
256
- if (granularity === "month") return date.set({ day: 1 });
257
- return date;
258
- };
259
- const formatCalendarDate = (calendarDate) => {
260
- if (calendarDate === null) return null;
261
- const normalizedDate = normalizeByGranularity(calendarDate);
262
- if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(normalizedDate);
263
- const date = DateTimeUtils.fromDateValueToLocal(normalizedDate);
264
- return DateTime.fromJSDate(date).toISODate();
265
- };
266
- const parseCalendarDate = (formattedDate) => {
267
- if (formattedDate == null) return formattedDate;
268
- if (fullIso) return normalizeByGranularity(DateTimeUtils.fromUTCISOToCalendarDate(formattedDate));
269
- const date = DateTime.fromISO(formattedDate).toJSDate();
270
- return normalizeByGranularity(toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date)));
271
- };
272
- const dateLimits = {
273
- minValue: typeof minValue === "string" ? parseCalendarDate(minValue) : minValue,
274
- maxValue: typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue
275
- };
269
+ const normalizedValue = props.value ?? null;
270
+ let t3;
271
+ if ($[0] !== granularity) {
272
+ t3 = (date) => {
273
+ if (granularity === "year") return date.set({
274
+ month: 1,
275
+ day: 1
276
+ });
277
+ if (granularity === "month") return date.set({ day: 1 });
278
+ return date;
279
+ };
280
+ $[0] = granularity;
281
+ $[1] = t3;
282
+ } else t3 = $[1];
283
+ const normalizeByGranularity = t3;
284
+ let t4;
285
+ if ($[2] !== fullIso || $[3] !== normalizeByGranularity) {
286
+ t4 = (calendarDate) => {
287
+ if (calendarDate === null) return null;
288
+ const normalizedDate = normalizeByGranularity(calendarDate);
289
+ if (fullIso) return DateTimeUtils.fromCalendarDateToUTCISO(normalizedDate);
290
+ const date_0 = DateTimeUtils.fromDateValueToLocal(normalizedDate, "UTC");
291
+ return DateTime.fromJSDate(date_0, { zone: "UTC" }).toISODate();
292
+ };
293
+ $[2] = fullIso;
294
+ $[3] = normalizeByGranularity;
295
+ $[4] = t4;
296
+ } else t4 = $[4];
297
+ const formatCalendarDate = t4;
298
+ let t5;
299
+ if ($[5] !== fullIso || $[6] !== normalizeByGranularity) {
300
+ t5 = (formattedDate) => {
301
+ if (formattedDate == null) return formattedDate;
302
+ if (fullIso) return normalizeByGranularity(DateTimeUtils.fromUTCISOToCalendarDate(formattedDate));
303
+ const date_1 = DateTime.fromISO(formattedDate, { zone: "UTC" }).toJSDate();
304
+ return normalizeByGranularity(toCalendarDate(DateTimeUtils.fromLocalToZonedDateTime(date_1, "UTC")));
305
+ };
306
+ $[5] = fullIso;
307
+ $[6] = normalizeByGranularity;
308
+ $[7] = t5;
309
+ } else t5 = $[7];
310
+ const parseCalendarDate = t5;
311
+ let t6;
312
+ if ($[8] !== minValue || $[9] !== parseCalendarDate) {
313
+ t6 = typeof minValue === "string" ? parseCalendarDate(minValue) : minValue;
314
+ $[8] = minValue;
315
+ $[9] = parseCalendarDate;
316
+ $[10] = t6;
317
+ } else t6 = $[10];
318
+ let t7;
319
+ if ($[11] !== maxValue || $[12] !== parseCalendarDate) {
320
+ t7 = typeof maxValue === "string" ? parseCalendarDate(maxValue) : maxValue;
321
+ $[11] = maxValue;
322
+ $[12] = parseCalendarDate;
323
+ $[13] = t7;
324
+ } else t7 = $[13];
325
+ let t8;
326
+ if ($[14] !== t6 || $[15] !== t7) {
327
+ t8 = {
328
+ minValue: t6,
329
+ maxValue: t7
330
+ };
331
+ $[14] = t6;
332
+ $[15] = t7;
333
+ $[16] = t8;
334
+ } else t8 = $[16];
335
+ const dateLimits = t8;
276
336
  if (!renderInput) {
277
- const dateValue = rawValue ? parseCalendarDate(rawValue) : null;
337
+ const dateValue = normalizedValue ? parseCalendarDate(normalizedValue) : null;
278
338
  const as = props.as ?? ui.input.as;
279
339
  const size = props.size ?? ui.input.size;
280
340
  const isDisabled = isFormControlDisabled || !!props.isDisabled;
@@ -300,50 +360,171 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ren
300
360
  contentWrapperClassName: datePickerInputContentRowCva({ size }),
301
361
  labelPlacement: "content-row",
302
362
  dataAttributes: {
303
- dataIsEmpty: dateValue === null,
304
- dataIsFilled: dateValue !== null,
363
+ dataIsEmpty: dateValue == null,
364
+ dataIsFilled: dateValue != null,
305
365
  dataIsDirty: props.isDirty,
306
366
  dataIsRequired: props.isRequired,
307
367
  dataIsDisabled: isDisabled,
308
368
  dataDisabled: isDisabled,
309
369
  dataInvalid: !!props.error,
310
- dataHasSelection: dateValue !== null
370
+ dataHasSelection: dateValue != null
311
371
  },
312
372
  renderStatic: true,
313
373
  onStaticInteract: renderRealInput,
314
374
  actionContent: staticTodayIcon,
315
375
  actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
376
+ wrapContentAndTrailing: true,
377
+ contentAndTrailingClassName: "gap-2!",
316
378
  trailingClassName: "py-0! pl-0!",
317
379
  trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
318
380
  children: staticSegments
319
381
  });
320
382
  }
321
- if ("formControl" in props && props.formControl) {
322
- const { formControl, ref, ...innerProps } = props;
323
- return /* @__PURE__ */ jsx(Controller, {
324
- control: formControl.control,
325
- name: formControl.name,
326
- render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerBase, {
327
- ...innerProps,
328
- ...dateLimits,
329
- ref: mergeRefs(ref, field.ref, inputRef),
330
- value: parseCalendarDate(field.value),
331
- onChange: (value) => field.onChange(formatCalendarDate(value)),
332
- onBlur: field.onBlur,
333
- isDirty,
334
- isDisabled: field.disabled || props.isDisabled,
335
- error: props.error ?? error?.message
336
- })
383
+ const T0 = DatePickerBase;
384
+ const t9 = mergeRefs(props.ref, inputRef);
385
+ const t10 = parseCalendarDate(normalizedValue);
386
+ let t11;
387
+ if ($[17] !== formatCalendarDate || $[18] !== props) {
388
+ t11 = (value) => props.onChange?.(formatCalendarDate(value));
389
+ $[17] = formatCalendarDate;
390
+ $[18] = props;
391
+ $[19] = t11;
392
+ } else t11 = $[19];
393
+ let t12;
394
+ if ($[20] !== T0 || $[21] !== dateLimits || $[22] !== granularity || $[23] !== props || $[24] !== t10 || $[25] !== t11 || $[26] !== t9) {
395
+ t12 = /* @__PURE__ */ jsx(T0, {
396
+ ...props,
397
+ ...dateLimits,
398
+ ref: t9,
399
+ granularity,
400
+ value: t10,
401
+ onChange: t11
337
402
  });
403
+ $[20] = T0;
404
+ $[21] = dateLimits;
405
+ $[22] = granularity;
406
+ $[23] = props;
407
+ $[24] = t10;
408
+ $[25] = t11;
409
+ $[26] = t9;
410
+ $[27] = t12;
411
+ } else t12 = $[27];
412
+ return t12;
413
+ };
414
+ var DatePicker = (t0) => {
415
+ const $ = c(33);
416
+ let maxValue;
417
+ let minValue;
418
+ let props;
419
+ let renderStaticInput;
420
+ let t1;
421
+ let t2;
422
+ if ($[0] !== t0) {
423
+ ({fullIso: t1, granularity: t2, minValue, maxValue, renderStaticInput, ...props} = t0);
424
+ $[0] = t0;
425
+ $[1] = maxValue;
426
+ $[2] = minValue;
427
+ $[3] = props;
428
+ $[4] = renderStaticInput;
429
+ $[5] = t1;
430
+ $[6] = t2;
431
+ } else {
432
+ maxValue = $[1];
433
+ minValue = $[2];
434
+ props = $[3];
435
+ renderStaticInput = $[4];
436
+ t1 = $[5];
437
+ t2 = $[6];
338
438
  }
339
- return /* @__PURE__ */ jsx(DatePickerBase, {
340
- ...props,
341
- ...dateLimits,
342
- ref: mergeRefs(props.ref, inputRef),
343
- granularity,
344
- value: parseCalendarDate(props.value),
345
- onChange: (value) => props.onChange?.(formatCalendarDate(value))
346
- });
439
+ const fullIso = t1 === void 0 ? true : t1;
440
+ const granularity = t2 === void 0 ? "day" : t2;
441
+ if ("formControl" in props && props.formControl) {
442
+ let formControl;
443
+ let innerProps;
444
+ let ref;
445
+ if ($[7] !== props) {
446
+ ({formControl, ref, ...innerProps} = props);
447
+ $[7] = props;
448
+ $[8] = formControl;
449
+ $[9] = innerProps;
450
+ $[10] = ref;
451
+ } else {
452
+ formControl = $[8];
453
+ innerProps = $[9];
454
+ ref = $[10];
455
+ }
456
+ const controlWithOptions = formControl.control;
457
+ let t3;
458
+ if ($[11] !== controlWithOptions._options?.disabled || $[12] !== fullIso || $[13] !== granularity || $[14] !== innerProps || $[15] !== maxValue || $[16] !== minValue || $[17] !== props.error || $[18] !== props.isDisabled || $[19] !== ref || $[20] !== renderStaticInput) {
459
+ t3 = (t4) => {
460
+ const { field, fieldState: t5 } = t4;
461
+ const { error, isDirty } = t5;
462
+ return /* @__PURE__ */ jsx(DatePickerInner, {
463
+ ...innerProps,
464
+ ref: mergeRefs(ref, field.ref),
465
+ value: field.value,
466
+ onChange: field.onChange,
467
+ onBlur: field.onBlur,
468
+ isDirty,
469
+ isDisabled: field.disabled || props.isDisabled,
470
+ isFormControlDisabled: !!controlWithOptions._options?.disabled,
471
+ error: props.error ?? error?.message,
472
+ fullIso,
473
+ granularity,
474
+ minValue,
475
+ maxValue,
476
+ renderStaticInput
477
+ });
478
+ };
479
+ $[11] = controlWithOptions._options?.disabled;
480
+ $[12] = fullIso;
481
+ $[13] = granularity;
482
+ $[14] = innerProps;
483
+ $[15] = maxValue;
484
+ $[16] = minValue;
485
+ $[17] = props.error;
486
+ $[18] = props.isDisabled;
487
+ $[19] = ref;
488
+ $[20] = renderStaticInput;
489
+ $[21] = t3;
490
+ } else t3 = $[21];
491
+ let t4;
492
+ if ($[22] !== formControl.control || $[23] !== formControl.name || $[24] !== t3) {
493
+ t4 = /* @__PURE__ */ jsx(Controller, {
494
+ control: formControl.control,
495
+ name: formControl.name,
496
+ render: t3
497
+ });
498
+ $[22] = formControl.control;
499
+ $[23] = formControl.name;
500
+ $[24] = t3;
501
+ $[25] = t4;
502
+ } else t4 = $[25];
503
+ return t4;
504
+ }
505
+ let t3;
506
+ if ($[26] !== fullIso || $[27] !== granularity || $[28] !== maxValue || $[29] !== minValue || $[30] !== props || $[31] !== renderStaticInput) {
507
+ t3 = /* @__PURE__ */ jsx(DatePickerInner, {
508
+ ...props,
509
+ fullIso,
510
+ granularity,
511
+ minValue,
512
+ maxValue,
513
+ renderStaticInput
514
+ });
515
+ $[26] = fullIso;
516
+ $[27] = granularity;
517
+ $[28] = maxValue;
518
+ $[29] = minValue;
519
+ $[30] = props;
520
+ $[31] = renderStaticInput;
521
+ $[32] = t3;
522
+ } else t3 = $[32];
523
+ return t3;
347
524
  };
525
+ function _temp(input) {
526
+ const container = input.getContainer?.() ?? input;
527
+ return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
528
+ }
348
529
  //#endregion
349
530
  export { DatePicker };
@@ -23,6 +23,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
23
23
  placeholder?: string;
24
24
  inputClassName?: string;
25
25
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
26
+ fireBlurOnChange?: boolean;
26
27
  }
27
28
  export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
28
29
  value?: {