@councilbox/councilbox-ui 2.0.54 → 2.0.56

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 (167) hide show
  1. package/Accordion.js +3 -0
  2. package/Alert.js +3 -0
  3. package/Avatar.js +3 -0
  4. package/AvatarGroup.js +3 -0
  5. package/Block.js +3 -0
  6. package/Button.js +3 -0
  7. package/ButtonBasic.js +3 -0
  8. package/Checkbox.js +3 -0
  9. package/DatePicker.js +3 -0
  10. package/DateRangePicker.js +3 -0
  11. package/DateTimePicker.js +3 -0
  12. package/DragDrop.js +3 -0
  13. package/DrawerPanel.js +3 -0
  14. package/DropDown.js +3 -0
  15. package/EnhancedTable.js +3 -0
  16. package/FabButton.js +3 -0
  17. package/Grid.js +3 -0
  18. package/Header.js +3 -0
  19. package/IconButton.js +3 -0
  20. package/IconButtonSquare.js +3 -0
  21. package/IconFont.js +3 -0
  22. package/InputAutocomplete.js +3 -0
  23. package/InputPassword.js +3 -0
  24. package/InputText.js +3 -0
  25. package/InputTextArea.js +3 -0
  26. package/LoadingSection.js +3 -0
  27. package/MenuItem.js +3 -0
  28. package/MenuLateralLeft.js +3 -0
  29. package/MenuLateralRight.js +3 -0
  30. package/Modal.js +3 -0
  31. package/Radio.js +3 -0
  32. package/RichTextInput.js +3 -0
  33. package/Scrollbar.js +3 -0
  34. package/ScrollbarOld.js +3 -0
  35. package/SelectInput.js +3 -0
  36. package/Slider.js +3 -0
  37. package/Spacing.js +3 -0
  38. package/Stars.js +3 -0
  39. package/Stepper.js +3 -0
  40. package/Table.js +3 -0
  41. package/TableBody.js +3 -0
  42. package/TableCell.js +3 -0
  43. package/TableContainer.js +3 -0
  44. package/TableHead.js +3 -0
  45. package/TableRow.js +3 -0
  46. package/TableSortLabel.js +3 -0
  47. package/Tabs.js +3 -0
  48. package/Tag.js +3 -0
  49. package/TextInput.js +3 -0
  50. package/ThemeProvider.js +3 -0
  51. package/TimePicker.js +3 -0
  52. package/Timeline.js +3 -0
  53. package/ToastProvider.js +3 -0
  54. package/Toggle.js +3 -0
  55. package/Tooltip.js +3 -0
  56. package/Typography.js +3 -0
  57. package/dist/HOCs/useDynamicStyles.js +25 -24
  58. package/dist/HOCs/usePopoverPosition.js +2 -0
  59. package/dist/build-index.js +70 -0
  60. package/dist/components/1.Introduction.stories.mdx +4 -1
  61. package/dist/components/2.Changelog.stories.mdx +25 -2
  62. package/dist/components/Button/Button.js +15 -0
  63. package/dist/components/ButtonBasic/ButtonBasic.js +15 -0
  64. package/dist/components/Checkbox/Checkbox.js +2 -2
  65. package/dist/components/DatePicker/Calendar.js +243 -0
  66. package/dist/components/DatePicker/DatePicker.css +197 -0
  67. package/dist/components/DatePicker/DatePicker.js +465 -0
  68. package/dist/components/DatePicker/DatePicker.stories.js +180 -0
  69. package/dist/components/DatePicker/dateUtils.js +525 -0
  70. package/dist/components/DateRangePicker/DateRangePicker.css +41 -0
  71. package/dist/components/DateRangePicker/DateRangePicker.js +530 -0
  72. package/dist/components/DateRangePicker/DateRangePicker.stories.js +147 -0
  73. package/dist/components/DateRangePicker/RangeCalendar.js +188 -0
  74. package/dist/components/DateTimePicker/DateTimePicker.css +4 -0
  75. package/dist/components/DateTimePicker/DateTimePicker.js +541 -0
  76. package/dist/components/DateTimePicker/DateTimePicker.stories.js +144 -0
  77. package/dist/components/DateTimePicker/TimeColumns.css +46 -0
  78. package/dist/components/DateTimePicker/TimeColumns.js +175 -0
  79. package/dist/components/DragDrop/DragDrop.js +21 -5
  80. package/dist/components/DropDown/DesignDropDown.stories.js +8 -0
  81. package/dist/components/DropDown/DropDown.js +14 -4
  82. package/dist/components/Header/Header.js +134 -25
  83. package/dist/components/IconButton/IconButton.js +3 -2
  84. package/dist/components/IconButtonSquare/IconButtonSquare.js +3 -3
  85. package/dist/components/InputAutocomplete/InputAutocomplete.js +17 -2
  86. package/dist/components/InputPassword/InputPassword.js +14 -1
  87. package/dist/components/InputText/InputText.css +10 -5
  88. package/dist/components/InputText/InputText.js +4 -4
  89. package/dist/components/InputTextArea/InputTextArea.js +14 -0
  90. package/dist/components/LoadingSection/LoadingSection.js +16 -4
  91. package/dist/components/MenuItem/MenuItem.js +78 -61
  92. package/dist/components/MenuLateralLeft/MenuLateralLeft.js +16 -2
  93. package/dist/components/MenuLateralRight/MenuLateralRight.js +34 -4
  94. package/dist/components/Modal/Modal.js +16 -1
  95. package/dist/components/RadioButton/Radio.js +15 -0
  96. package/dist/components/RichTextInput/DesignRichTextInput.stories.js +119 -0
  97. package/dist/components/RichTextInput/RichTextInput.css +352 -0
  98. package/dist/components/RichTextInput/RichTextInput.js +1057 -0
  99. package/dist/components/RichTextInput/RichTextInput.stories.js +33 -0
  100. package/dist/components/Ripple/DesignRipple.js +17 -0
  101. package/dist/components/Scrollbar/Scrollbar.css +60 -19
  102. package/dist/components/Scrollbar/Scrollbar.js +384 -62
  103. package/dist/components/ScrollbarOld/DesignScrollbarOld.js +24 -0
  104. package/dist/components/ScrollbarOld/ScrollbarOld.css +38 -0
  105. package/dist/components/ScrollbarOld/ScrollbarOld.js +104 -0
  106. package/dist/components/ScrollbarOld/ScrollbarOld.stories.js +37 -0
  107. package/dist/components/SelectInput/SelectInput.js +112 -86
  108. package/dist/components/Slider/Slider.js +15 -0
  109. package/dist/components/Stars/Stars.js +13 -0
  110. package/dist/components/Stepper/Stepper.js +15 -2
  111. package/dist/components/Table/TableSortLabel.js +11 -0
  112. package/dist/components/Tabs/DesignTabs.js +1 -1
  113. package/dist/components/Tabs/Tabs.js +13 -2
  114. package/dist/components/Tag/Tag.js +16 -0
  115. package/dist/components/TextInput/TextInput.js +13 -0
  116. package/dist/components/TimePicker/TimePicker.css +3 -0
  117. package/dist/components/TimePicker/TimePicker.js +441 -0
  118. package/dist/components/TimePicker/TimePicker.stories.js +132 -0
  119. package/dist/components/Toast/DesignToast.stories.js +174 -0
  120. package/dist/components/Toast/Toast.css +154 -0
  121. package/dist/components/Toast/Toast.js +178 -0
  122. package/dist/components/Toast/Toast.stories.js +33 -0
  123. package/dist/components/Toast/ToastProvider.js +33 -0
  124. package/dist/components/Toast/ToastRoot.js +89 -0
  125. package/dist/components/Toast/toastStore.js +138 -0
  126. package/dist/components/Toast/useToast.js +42 -0
  127. package/dist/components/Toggle/Toggle.js +20 -14
  128. package/dist/components/Tooltip/Tooltip.js +24 -2
  129. package/dist/styles/styleFont.css +1 -1
  130. package/dist/styles/zIndexConsts.css +2 -0
  131. package/package.json +63 -3
  132. package/toast.js +7 -0
  133. package/useCouncilboxTheme.js +7 -0
  134. package/useToast.js +7 -0
  135. package/dist/components/Accordion/AccordionOld.css +0 -16
  136. package/dist/components/Accordion/AccordionOld.js +0 -91
  137. package/dist/components/Avatar/AvatarOld.js +0 -124
  138. package/dist/components/ButtonBasic/ButtonBasicOld.css +0 -41
  139. package/dist/components/ButtonBasic/ButtonBasicOld.js +0 -211
  140. package/dist/components/Checkbox/CheckboxOld.css +0 -31
  141. package/dist/components/Checkbox/CheckboxOld.js +0 -96
  142. package/dist/components/DrawerPanel/DrawerPanelOld.css +0 -56
  143. package/dist/components/DrawerPanel/DrawerPanelOld.js +0 -211
  144. package/dist/components/DropDown/DropDownOld.css +0 -3
  145. package/dist/components/DropDown/DropDownOld.js +0 -154
  146. package/dist/components/Grid/GridItemOld.js +0 -38
  147. package/dist/components/Grid/GridOld.css +0 -0
  148. package/dist/components/Grid/GridOld.js +0 -46
  149. package/dist/components/IconButton/IconButtonOld.css +0 -0
  150. package/dist/components/IconButton/IconButtonOld.js +0 -122
  151. package/dist/components/IconButtonSquare/IconButtonSquareOld.css +0 -43
  152. package/dist/components/IconButtonSquare/IconButtonSquareOld.js +0 -115
  153. package/dist/components/InputAutocomplete/InputAutocompleteOld.css +0 -5
  154. package/dist/components/InputAutocomplete/InputAutocompleteOld.js +0 -159
  155. package/dist/components/InputText/InputTextOld.css +0 -10
  156. package/dist/components/InputText/InputTextOld.js +0 -314
  157. package/dist/components/MenuItem/MenuItemOld.js +0 -123
  158. package/dist/components/Modal/ModalOld.css +0 -3
  159. package/dist/components/Modal/ModalOld.js +0 -213
  160. package/dist/components/RadioButton/RadioOld.css +0 -31
  161. package/dist/components/RadioButton/RadioOld.js +0 -126
  162. package/dist/components/SelectInput/SelectInputOld.css +0 -17
  163. package/dist/components/SelectInput/SelectInputOld.js +0 -296
  164. package/dist/components/Table/TableOld.css +0 -79
  165. package/dist/components/Table/TableOld.js +0 -133
  166. package/dist/components/Tabs/TabsOld.js +0 -78
  167. package/dist/components/Typography/TypographyOld.js +0 -119
@@ -0,0 +1,525 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toJsDate = exports.startOfDay = exports.setTimeFromDate = exports.setDayFromDate = exports.parseDate = exports.pad2 = exports.isValidDate = exports.isTimeDisabled = exports.isSameMonth = exports.isSameDay = exports.isDateDisabled = exports.isBeforeDay = exports.isAfterDay = exports.getWeekdayNames = exports.getUIText = exports.getMonthNames = exports.getMonthMatrix = exports.getMeridiemText = exports.getLocalePrefersAmPm = exports.getLocaleDateFormat = exports.getDateValueKey = exports.formatDate = exports.addYears = exports.addMonths = exports.addDays = exports.MONTHS_ES = exports.DEFAULT_LOCALE = exports.DAYS_SHORT_ES = void 0;
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ var DEFAULT_LOCALE = 'es-ES';
14
+
15
+ // Fallbacks only used if Intl.DateTimeFormat throws for an unrecognized locale tag.
16
+ exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
17
+ var DAYS_SHORT_ES = ['L', 'M', 'X', 'J', 'V', 'S', 'D'];
18
+ exports.DAYS_SHORT_ES = DAYS_SHORT_ES;
19
+ var MONTHS_ES = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
20
+ exports.MONTHS_ES = MONTHS_ES;
21
+ var UI_TEXT_BY_LANG = {
22
+ es: {
23
+ cancelText: 'Cancelar',
24
+ okText: 'Aceptar',
25
+ clearText: 'Borrar fecha',
26
+ openCalendarText: 'Abrir calendario',
27
+ openDateTimeText: 'Abrir selector de fecha y hora',
28
+ pickerLabel: 'Selector de fecha',
29
+ pickerDateTimeLabel: 'Selector de fecha y hora',
30
+ prevText: 'Anterior',
31
+ nextText: 'Siguiente',
32
+ startLabel: 'Fecha inicio',
33
+ endLabel: 'Fecha fin',
34
+ rangeLabel: 'Selector de rango de fechas',
35
+ openTimeText: 'Abrir selector de hora',
36
+ pickerTimeLabel: 'Selector de hora'
37
+ },
38
+ en: {
39
+ cancelText: 'Cancel',
40
+ okText: 'OK',
41
+ clearText: 'Clear date',
42
+ openCalendarText: 'Open calendar',
43
+ openDateTimeText: 'Open date and time picker',
44
+ pickerLabel: 'Date picker',
45
+ pickerDateTimeLabel: 'Date and time picker',
46
+ prevText: 'Previous',
47
+ nextText: 'Next',
48
+ startLabel: 'Start date',
49
+ endLabel: 'End date',
50
+ rangeLabel: 'Date range picker',
51
+ openTimeText: 'Open time picker',
52
+ pickerTimeLabel: 'Time picker'
53
+ },
54
+ fr: {
55
+ cancelText: 'Annuler',
56
+ okText: 'OK',
57
+ clearText: 'Effacer la date',
58
+ openCalendarText: 'Ouvrir le calendrier',
59
+ openDateTimeText: 'Ouvrir le sélecteur de date et heure',
60
+ pickerLabel: 'Sélecteur de date',
61
+ pickerDateTimeLabel: 'Sélecteur de date et heure',
62
+ prevText: 'Précédent',
63
+ nextText: 'Suivant',
64
+ startLabel: 'Date de début',
65
+ endLabel: 'Date de fin',
66
+ rangeLabel: 'Sélecteur de plage de dates',
67
+ openTimeText: "Ouvrir le sélecteur d'heure",
68
+ pickerTimeLabel: "Sélecteur d'heure"
69
+ },
70
+ de: {
71
+ cancelText: 'Abbrechen',
72
+ okText: 'OK',
73
+ clearText: 'Datum löschen',
74
+ openCalendarText: 'Kalender öffnen',
75
+ openDateTimeText: 'Datums- und Zeitauswahl öffnen',
76
+ pickerLabel: 'Datumsauswahl',
77
+ pickerDateTimeLabel: 'Datums- und Zeitauswahl',
78
+ prevText: 'Zurück',
79
+ nextText: 'Weiter',
80
+ startLabel: 'Startdatum',
81
+ endLabel: 'Enddatum',
82
+ rangeLabel: 'Datumsbereichsauswahl',
83
+ openTimeText: 'Zeitauswahl öffnen',
84
+ pickerTimeLabel: 'Zeitauswahl'
85
+ },
86
+ pt: {
87
+ cancelText: 'Cancelar',
88
+ okText: 'OK',
89
+ clearText: 'Limpar data',
90
+ openCalendarText: 'Abrir calendário',
91
+ openDateTimeText: 'Abrir seletor de data e hora',
92
+ pickerLabel: 'Seletor de data',
93
+ pickerDateTimeLabel: 'Seletor de data e hora',
94
+ prevText: 'Anterior',
95
+ nextText: 'Próximo',
96
+ startLabel: 'Data de início',
97
+ endLabel: 'Data de fim',
98
+ rangeLabel: 'Seletor de intervalo de datas',
99
+ openTimeText: 'Abrir seletor de hora',
100
+ pickerTimeLabel: 'Seletor de hora'
101
+ },
102
+ it: {
103
+ cancelText: 'Annulla',
104
+ okText: 'OK',
105
+ clearText: 'Cancella data',
106
+ openCalendarText: 'Apri calendario',
107
+ openDateTimeText: 'Apri selettore data e ora',
108
+ pickerLabel: 'Selettore data',
109
+ pickerDateTimeLabel: 'Selettore data e ora',
110
+ prevText: 'Precedente',
111
+ nextText: 'Successivo',
112
+ startLabel: 'Data di inizio',
113
+ endLabel: 'Data di fine',
114
+ rangeLabel: 'Selettore intervallo di date',
115
+ openTimeText: 'Apri selettore ora',
116
+ pickerTimeLabel: 'Selettore ora'
117
+ }
118
+ };
119
+ var getLanguage = function getLanguage(locale) {
120
+ return (locale || DEFAULT_LOCALE).slice(0, 2).toLowerCase();
121
+ };
122
+
123
+ // Real, browser-native translations for month/weekday/AM-PM names, for any
124
+ // locale the runtime supports — no moment/date-fns dependency required. A
125
+ // consumer that already uses one of those libraries can still override any
126
+ // of this via the `months`/`weekDays`/`localeText` props (e.g. feeding them
127
+ // moment.months() or a date-fns locale's names).
128
+ var getMonthNames = function getMonthNames() {
129
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
130
+ var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'long';
131
+ try {
132
+ var formatter = new Intl.DateTimeFormat(locale, {
133
+ month: width,
134
+ timeZone: 'UTC'
135
+ });
136
+ return Array.from({
137
+ length: 12
138
+ }, function (_, month) {
139
+ return formatter.format(new Date(Date.UTC(2000, month, 1)));
140
+ });
141
+ } catch (e) {
142
+ return MONTHS_ES;
143
+ }
144
+ };
145
+ exports.getMonthNames = getMonthNames;
146
+ var getWeekdayNames = function getWeekdayNames() {
147
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
148
+ var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'short';
149
+ try {
150
+ var formatter = new Intl.DateTimeFormat(locale, {
151
+ weekday: width,
152
+ timeZone: 'UTC'
153
+ });
154
+ // 2000-01-03 is a Monday (UTC), so this yields Monday-first ordering.
155
+ return Array.from({
156
+ length: 7
157
+ }, function (_, day) {
158
+ return formatter.format(new Date(Date.UTC(2000, 0, 3 + day)));
159
+ });
160
+ } catch (e) {
161
+ return DAYS_SHORT_ES;
162
+ }
163
+ };
164
+ exports.getWeekdayNames = getWeekdayNames;
165
+ var getMeridiemText = function getMeridiemText() {
166
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
167
+ var hours24 = arguments.length > 1 ? arguments[1] : undefined;
168
+ try {
169
+ var parts = new Intl.DateTimeFormat(locale, {
170
+ hour: 'numeric',
171
+ hour12: true
172
+ }).formatToParts(new Date(2000, 0, 1, hours24));
173
+ var dayPeriod = parts.find(function (part) {
174
+ return part.type === 'dayPeriod';
175
+ });
176
+ return dayPeriod ? dayPeriod.value : hours24 < 12 ? 'AM' : 'PM';
177
+ } catch (e) {
178
+ return hours24 < 12 ? 'AM' : 'PM';
179
+ }
180
+ };
181
+
182
+ // Derives the locale's natural day/month/year order (and separators) via
183
+ // Intl, e.g. 'MM/dd/yyyy' for en-US, 'dd/MM/yyyy' for es-ES, 'dd.MM.yyyy' for de-DE.
184
+ exports.getMeridiemText = getMeridiemText;
185
+ var getLocaleDateFormat = function getLocaleDateFormat() {
186
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
187
+ try {
188
+ var parts = new Intl.DateTimeFormat(locale, {
189
+ year: 'numeric',
190
+ month: '2-digit',
191
+ day: '2-digit'
192
+ }).formatToParts(new Date(2000, 0, 1));
193
+ var tokenByType = {
194
+ year: 'yyyy',
195
+ month: 'MM',
196
+ day: 'dd'
197
+ };
198
+ return parts.map(function (part) {
199
+ return tokenByType[part.type] || part.value;
200
+ }).join('');
201
+ } catch (e) {
202
+ return 'dd/MM/yyyy';
203
+ }
204
+ };
205
+ exports.getLocaleDateFormat = getLocaleDateFormat;
206
+ var getLocalePrefersAmPm = function getLocalePrefersAmPm() {
207
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
208
+ try {
209
+ return !!new Intl.DateTimeFormat(locale, {
210
+ hour: 'numeric'
211
+ }).resolvedOptions().hour12;
212
+ } catch (e) {
213
+ return false;
214
+ }
215
+ };
216
+
217
+ // Falls back to English (rather than Spanish) for a language we don't have
218
+ // chrome text for, since English is the safer universal default — a
219
+ // consumer can always override any of these via the `localeText` prop.
220
+ exports.getLocalePrefersAmPm = getLocalePrefersAmPm;
221
+ var getUIText = function getUIText() {
222
+ var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_LOCALE;
223
+ var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
224
+ return _objectSpread(_objectSpread({}, UI_TEXT_BY_LANG[getLanguage(locale)] || UI_TEXT_BY_LANG.en), overrides);
225
+ };
226
+ exports.getUIText = getUIText;
227
+ var isValidDate = function isValidDate(date) {
228
+ return date instanceof Date && !Number.isNaN(date.getTime());
229
+ };
230
+
231
+ // Accepts a native Date, a moment/dayjs instance (duck-typed via `.toDate()`
232
+ // so this library never needs those as a dependency), an ISO string, or a
233
+ // timestamp — and normalizes it to a native Date (or null). Every component
234
+ // runs incoming `value`/`defaultValue`/`minDate`/`maxDate`/etc. through this,
235
+ // so a consumer already using moment or dayjs elsewhere in their app can pass
236
+ // those values straight in without converting them first.
237
+ exports.isValidDate = isValidDate;
238
+ var toJsDate = function toJsDate(value) {
239
+ if (value === null || value === undefined || value === '') return null;
240
+ if (value instanceof Date) return isValidDate(value) ? value : null;
241
+ if (_typeof(value) === 'object' && typeof value.toDate === 'function') {
242
+ var converted = value.toDate();
243
+ return isValidDate(converted) ? converted : null;
244
+ }
245
+ if (typeof value === 'string' || typeof value === 'number') {
246
+ var parsed = new Date(value);
247
+ return isValidDate(parsed) ? parsed : null;
248
+ }
249
+ return null;
250
+ };
251
+
252
+ // A stable primitive to key React deps/memos on, for a value that will be
253
+ // run through toJsDate(). Native Date, moment, and dayjs all override
254
+ // `.valueOf()` to return their millisecond timestamp — a real moment/dayjs
255
+ // instance's `.toDate()` returns a NEW Date object on every call (even for
256
+ // the same instant), so memoizing on the Date reference itself would recompute
257
+ // (and re-render) on every render, indefinitely. Keying on `.valueOf()`
258
+ // instead gives a plain number that stays `===`-stable across renders as
259
+ // long as the underlying instant hasn't actually changed.
260
+ exports.toJsDate = toJsDate;
261
+ var getDateValueKey = function getDateValueKey(value) {
262
+ if (value === null || value === undefined) return value;
263
+ if (_typeof(value) === 'object' && typeof value.valueOf === 'function') return value.valueOf();
264
+ return value;
265
+ };
266
+ exports.getDateValueKey = getDateValueKey;
267
+ var pad2 = function pad2(num) {
268
+ return String(num).padStart(2, '0');
269
+ };
270
+ exports.pad2 = pad2;
271
+ var cloneDate = function cloneDate(date) {
272
+ return new Date(date.getTime());
273
+ };
274
+ var startOfDay = function startOfDay(date) {
275
+ var next = cloneDate(date);
276
+ next.setHours(0, 0, 0, 0);
277
+ return next;
278
+ };
279
+ exports.startOfDay = startOfDay;
280
+ var isSameDay = function isSameDay(a, b) {
281
+ return isValidDate(a) && isValidDate(b) && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
282
+ };
283
+ exports.isSameDay = isSameDay;
284
+ var isSameMonth = function isSameMonth(a, b) {
285
+ return isValidDate(a) && isValidDate(b) && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
286
+ };
287
+ exports.isSameMonth = isSameMonth;
288
+ var isBeforeDay = function isBeforeDay(a, b) {
289
+ return isValidDate(a) && isValidDate(b) && startOfDay(a).getTime() < startOfDay(b).getTime();
290
+ };
291
+ exports.isBeforeDay = isBeforeDay;
292
+ var isAfterDay = function isAfterDay(a, b) {
293
+ return isValidDate(a) && isValidDate(b) && startOfDay(a).getTime() > startOfDay(b).getTime();
294
+ };
295
+ exports.isAfterDay = isAfterDay;
296
+ var addDays = function addDays(date, amount) {
297
+ var next = cloneDate(date);
298
+ next.setDate(next.getDate() + amount);
299
+ return next;
300
+ };
301
+ exports.addDays = addDays;
302
+ var addMonths = function addMonths(date, amount) {
303
+ var next = cloneDate(date);
304
+ var day = next.getDate();
305
+ next.setDate(1);
306
+ next.setMonth(next.getMonth() + amount);
307
+ var daysInTargetMonth = new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate();
308
+ next.setDate(Math.min(day, daysInTargetMonth));
309
+ return next;
310
+ };
311
+ exports.addMonths = addMonths;
312
+ var addYears = function addYears(date, amount) {
313
+ return addMonths(date, amount * 12);
314
+ };
315
+ exports.addYears = addYears;
316
+ var setDayFromDate = function setDayFromDate(base, dayDate) {
317
+ var next = cloneDate(base);
318
+ next.setFullYear(dayDate.getFullYear(), dayDate.getMonth(), dayDate.getDate());
319
+ return next;
320
+ };
321
+ exports.setDayFromDate = setDayFromDate;
322
+ var setTimeFromDate = function setTimeFromDate(base, _ref) {
323
+ var hours = _ref.hours,
324
+ minutes = _ref.minutes,
325
+ seconds = _ref.seconds;
326
+ var next = cloneDate(base);
327
+ if (hours !== undefined) next.setHours(hours);
328
+ if (minutes !== undefined) next.setMinutes(minutes);
329
+ if (seconds !== undefined) next.setSeconds(seconds, 0);
330
+ return next;
331
+ };
332
+ exports.setTimeFromDate = setTimeFromDate;
333
+ var getMonthMatrix = function getMonthMatrix(year, month) {
334
+ var firstOfMonth = new Date(year, month, 1);
335
+ var firstWeekday = (firstOfMonth.getDay() + 6) % 7;
336
+ var cursor = addDays(firstOfMonth, -firstWeekday);
337
+ var weeks = [];
338
+ for (var week = 0; week < 6; week++) {
339
+ var days = [];
340
+ for (var day = 0; day < 7; day++) {
341
+ days.push(cursor);
342
+ cursor = addDays(cursor, 1);
343
+ }
344
+ weeks.push(days);
345
+ }
346
+ return weeks;
347
+ };
348
+ exports.getMonthMatrix = getMonthMatrix;
349
+ var isDateDisabled = function isDateDisabled(date) {
350
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
351
+ minDate = _ref2.minDate,
352
+ maxDate = _ref2.maxDate,
353
+ disablePast = _ref2.disablePast,
354
+ disableFuture = _ref2.disableFuture,
355
+ shouldDisableDate = _ref2.shouldDisableDate;
356
+ if (!isValidDate(date)) return true;
357
+ var day = startOfDay(date);
358
+ if (disablePast && day < startOfDay(new Date())) return true;
359
+ if (disableFuture && day > startOfDay(new Date())) return true;
360
+ if (minDate && isValidDate(minDate) && day < startOfDay(minDate)) return true;
361
+ if (maxDate && isValidDate(maxDate) && day > startOfDay(maxDate)) return true;
362
+ if (shouldDisableDate && shouldDisableDate(day)) return true;
363
+ return false;
364
+ };
365
+ exports.isDateDisabled = isDateDisabled;
366
+ var isTimeDisabled = function isTimeDisabled(date) {
367
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
368
+ minTime = _ref3.minTime,
369
+ maxTime = _ref3.maxTime,
370
+ minDateTime = _ref3.minDateTime,
371
+ maxDateTime = _ref3.maxDateTime;
372
+ if (!isValidDate(date)) return false;
373
+ var min = minDateTime || minTime;
374
+ var max = maxDateTime || maxTime;
375
+ if (min && isValidDate(min) && date < min) return true;
376
+ if (max && isValidDate(max) && date > max) return true;
377
+ return false;
378
+ };
379
+
380
+ // Token set covers both this library's own date-fns-style tokens (yyyy, MM,
381
+ // dd, ...) and moment's equivalents (YYYY, MM, DD, ...) so a consumer coming
382
+ // from either library can pass their existing format string unchanged.
383
+ // Deliberately NOT supported: moment's lowercase `d`/`dd`/`ddd`/`dddd`, which
384
+ // mean day-OF-WEEK in moment — adding them as day-of-month aliases would
385
+ // silently misinterpret any format string that actually meant weekday.
386
+ // Order matters: alternatives that are a prefix of another (MMM of MMMM, MM
387
+ // of MMM, YY of YYYY, D of DD, ...) must list the longer one first, since
388
+ // regex alternation takes the first match, not the longest.
389
+ exports.isTimeDisabled = isTimeDisabled;
390
+ var FORMAT_TOKEN_REGEX = /MMMM|MMM|yyyy|YYYY|yy|YY|MM|M|dd|DD|D|HH|hh|mm|ss|A|a/g;
391
+
392
+ // Intl.DateTimeFormat dateStyle presets, for a locale-appropriate long-form
393
+ // display (e.g. moment's 'LL' -> "11 de septiembre de 2026" / "September 11, 2026")
394
+ // without hand-maintaining per-locale strings ourselves. Only usable for
395
+ // display: parseDate can't reliably reverse-parse free-form localized text,
396
+ // so a field using one of these (or a token format containing MMM/MMMM,
397
+ // which has the same problem) stays calendar/clock-driven rather than typable.
398
+ var DATE_STYLE_KEYWORDS = ['full', 'long', 'medium', 'short'];
399
+ var NAME_BASED_TOKEN_REGEX = /MMMM|MMM/;
400
+
401
+ // A few of moment's "localized format" macros, resolved against the locale
402
+ // before the token engine runs: 'L'/'l' become the locale's own numeric
403
+ // day/month/year order (the same thing getLocaleDateFormat already computes),
404
+ // while 'LL'/'ll' fall through to the Intl dateStyle keywords above.
405
+ var LOCALIZED_FORMAT_MACROS = {
406
+ LL: 'long',
407
+ ll: 'medium'
408
+ };
409
+ var resolveFormat = function resolveFormat(format, locale) {
410
+ if (format === 'L' || format === 'l') return getLocaleDateFormat(locale);
411
+ return LOCALIZED_FORMAT_MACROS[format] || format;
412
+ };
413
+ var formatDate = function formatDate(date, format) {
414
+ var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_LOCALE;
415
+ if (!isValidDate(date) || !format) return '';
416
+ var resolvedFormat = resolveFormat(format, locale);
417
+ if (DATE_STYLE_KEYWORDS.includes(resolvedFormat)) {
418
+ try {
419
+ return new Intl.DateTimeFormat(locale, {
420
+ dateStyle: resolvedFormat
421
+ }).format(date);
422
+ } catch (e) {
423
+ // fall through to token formatting below
424
+ }
425
+ }
426
+ var hours24 = date.getHours();
427
+ var hours12raw = hours24 % 12;
428
+ var hours12 = hours12raw === 0 ? 12 : hours12raw;
429
+ var meridiem = getMeridiemText(locale, hours24);
430
+ var replacements = {
431
+ yyyy: date.getFullYear(),
432
+ YYYY: date.getFullYear(),
433
+ yy: pad2(date.getFullYear() % 100),
434
+ YY: pad2(date.getFullYear() % 100),
435
+ MMMM: getMonthNames(locale, 'long')[date.getMonth()],
436
+ MMM: getMonthNames(locale, 'short')[date.getMonth()],
437
+ MM: pad2(date.getMonth() + 1),
438
+ M: String(date.getMonth() + 1),
439
+ dd: pad2(date.getDate()),
440
+ DD: pad2(date.getDate()),
441
+ D: String(date.getDate()),
442
+ HH: pad2(hours24),
443
+ hh: pad2(hours12),
444
+ mm: pad2(date.getMinutes()),
445
+ ss: pad2(date.getSeconds()),
446
+ a: meridiem.toLowerCase(),
447
+ A: meridiem.toUpperCase()
448
+ };
449
+ return resolvedFormat.replace(FORMAT_TOKEN_REGEX, function (token) {
450
+ return String(replacements[token]);
451
+ });
452
+ };
453
+ exports.formatDate = formatDate;
454
+ var escapeRegExp = function escapeRegExp(str) {
455
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
456
+ };
457
+ var BASE_TOKEN_PATTERNS = {
458
+ yyyy: '(\\d{4})',
459
+ YYYY: '(\\d{4})',
460
+ yy: '(\\d{2})',
461
+ YY: '(\\d{2})',
462
+ MM: '(\\d{1,2})',
463
+ M: '(\\d{1,2})',
464
+ dd: '(\\d{1,2})',
465
+ DD: '(\\d{1,2})',
466
+ D: '(\\d{1,2})',
467
+ HH: '(\\d{1,2})',
468
+ hh: '(\\d{1,2})',
469
+ mm: '(\\d{1,2})',
470
+ ss: '(\\d{1,2})'
471
+ };
472
+ var parseDate = function parseDate(value, format) {
473
+ var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_LOCALE;
474
+ if (!value || !format) return null;
475
+ var resolvedFormat = resolveFormat(format, locale);
476
+ if (DATE_STYLE_KEYWORDS.includes(resolvedFormat) || NAME_BASED_TOKEN_REGEX.test(resolvedFormat)) return null;
477
+ var amText = getMeridiemText(locale, 9);
478
+ var pmText = getMeridiemText(locale, 21);
479
+ var tokenPatterns = _objectSpread(_objectSpread({}, BASE_TOKEN_PATTERNS), {}, {
480
+ // Accept the locale's real AM/PM strings, plus the plain "AM"/"PM"
481
+ // fallback so a formatted value always round-trips through parseDate.
482
+ a: "(".concat(escapeRegExp(amText), "|").concat(escapeRegExp(pmText), "|AM|PM)"),
483
+ A: "(".concat(escapeRegExp(amText), "|").concat(escapeRegExp(pmText), "|AM|PM)")
484
+ });
485
+ var tokens = [];
486
+ var regexStr = '';
487
+ var lastIndex = 0;
488
+ var matches = resolvedFormat.matchAll(new RegExp(FORMAT_TOKEN_REGEX.source, 'g'));
489
+ Array.from(matches).forEach(function (match) {
490
+ regexStr += escapeRegExp(resolvedFormat.slice(lastIndex, match.index));
491
+ regexStr += tokenPatterns[match[0]];
492
+ tokens.push(match[0]);
493
+ lastIndex = match.index + match[0].length;
494
+ });
495
+ regexStr += escapeRegExp(resolvedFormat.slice(lastIndex));
496
+ var matched = value.trim().match(new RegExp("^".concat(regexStr, "$"), 'i'));
497
+ if (!matched) return null;
498
+ var parts = {};
499
+ tokens.forEach(function (token, index) {
500
+ parts[token] = matched[index + 1];
501
+ });
502
+ var yearStr = parts.yyyy || parts.YYYY;
503
+ var shortYearStr = parts.yy || parts.YY;
504
+ var monthStr = parts.MM || parts.M;
505
+ var dayStr = parts.dd || parts.DD || parts.D;
506
+ var meridiemPart = parts.a || parts.A;
507
+ var now = new Date();
508
+ var year = yearStr ? parseInt(yearStr, 10) : shortYearStr ? 2000 + parseInt(shortYearStr, 10) : now.getFullYear();
509
+ var month = monthStr ? parseInt(monthStr, 10) - 1 : 0;
510
+ var day = dayStr ? parseInt(dayStr, 10) : 1;
511
+ var hours = 0;
512
+ if (parts.HH !== undefined) {
513
+ hours = parseInt(parts.HH, 10);
514
+ } else if (parts.hh !== undefined) {
515
+ hours = parseInt(parts.hh, 10) % 12;
516
+ if (meridiemPart && meridiemPart.toLowerCase() === pmText.toLowerCase()) hours += 12;else if (meridiemPart && /^p/i.test(meridiemPart)) hours += 12;
517
+ }
518
+ var minutes = parts.mm ? parseInt(parts.mm, 10) : 0;
519
+ var seconds = parts.ss ? parseInt(parts.ss, 10) : 0;
520
+ if (month < 0 || month > 11 || hours > 23 || minutes > 59 || seconds > 59) return null;
521
+ var result = new Date(year, month, day, hours, minutes, seconds, 0);
522
+ if (result.getFullYear() !== year || result.getMonth() !== month || result.getDate() !== day) return null;
523
+ return result;
524
+ };
525
+ exports.parseDate = parseDate;
@@ -0,0 +1,41 @@
1
+ .cbx-rangeCalendar {
2
+ display: flex;
3
+ align-items: flex-start;
4
+ }
5
+
6
+ .cbx-rangeCalendar-panel {
7
+ padding: var(--spacing16);
8
+ width: 17.5rem;
9
+ max-width: 100%;
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .cbx-rangeCalendar-panel + .cbx-rangeCalendar-panel {
14
+ border-left: 1px solid var(--gray1);
15
+ }
16
+
17
+ .cbx-rangeCalendar-dayCell {
18
+ position: relative;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ height: 2.375rem;
23
+ }
24
+
25
+ .cbx-rangeCalendar-dayCell-inRange {
26
+ background-color: var(--primary10);
27
+ }
28
+
29
+ .cbx-rangeCalendar-dayCell-start {
30
+ background-image: linear-gradient(to right, transparent 50%, var(--primary10) 50%);
31
+ border-radius: 999px 0 0 999px;
32
+ }
33
+
34
+ .cbx-rangeCalendar-dayCell-end {
35
+ background-image: linear-gradient(to left, transparent 50%, var(--primary10) 50%);
36
+ border-radius: 0 999px 999px 0;
37
+ }
38
+
39
+ .cbx-rangeCalendar-day-previewEdge {
40
+ box-shadow: inset 0 0 0 1px var(--primary);
41
+ }