@k3-universe/react-kit 0.0.10 → 0.0.11

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 (48) hide show
  1. package/dist/index.js +1303 -75
  2. package/dist/kit/builder/form/components/FormBuilder.d.ts +5 -1
  3. package/dist/kit/builder/form/components/FormBuilder.d.ts.map +1 -1
  4. package/dist/kit/builder/form/components/FormBuilderField.d.ts.map +1 -1
  5. package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts +4 -0
  6. package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts.map +1 -0
  7. package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts +4 -0
  8. package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts.map +1 -0
  9. package/dist/kit/builder/form/components/fields/TimePickerField.d.ts +4 -0
  10. package/dist/kit/builder/form/components/fields/TimePickerField.d.ts.map +1 -0
  11. package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts +4 -0
  12. package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts.map +1 -0
  13. package/dist/kit/builder/form/components/fields/index.d.ts +4 -0
  14. package/dist/kit/builder/form/components/fields/index.d.ts.map +1 -1
  15. package/dist/kit/components/datetimepicker/DateTimePicker.d.ts +32 -0
  16. package/dist/kit/components/datetimepicker/DateTimePicker.d.ts.map +1 -0
  17. package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts +39 -0
  18. package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts.map +1 -0
  19. package/dist/kit/components/datetimepicker/index.d.ts +5 -0
  20. package/dist/kit/components/datetimepicker/index.d.ts.map +1 -0
  21. package/dist/kit/components/timepicker/TimePicker.d.ts +26 -0
  22. package/dist/kit/components/timepicker/TimePicker.d.ts.map +1 -0
  23. package/dist/kit/components/timepicker/TimeRangePicker.d.ts +31 -0
  24. package/dist/kit/components/timepicker/TimeRangePicker.d.ts.map +1 -0
  25. package/dist/kit/components/timepicker/index.d.ts +5 -0
  26. package/dist/kit/components/timepicker/index.d.ts.map +1 -0
  27. package/dist/kit/themes/clean-slate.css +16 -0
  28. package/dist/kit/themes/default.css +16 -0
  29. package/dist/kit/themes/minimal-modern.css +16 -0
  30. package/dist/kit/themes/spotify.css +16 -0
  31. package/package.json +1 -1
  32. package/src/kit/builder/form/components/FormBuilder.tsx +17 -0
  33. package/src/kit/builder/form/components/FormBuilderField.tsx +48 -0
  34. package/src/kit/builder/form/components/fields/DateTimePickerField.tsx +33 -0
  35. package/src/kit/builder/form/components/fields/DateTimeRangePickerField.tsx +42 -0
  36. package/src/kit/builder/form/components/fields/TimePickerField.tsx +30 -0
  37. package/src/kit/builder/form/components/fields/TimeRangePickerField.tsx +37 -0
  38. package/src/kit/builder/form/components/fields/index.ts +4 -0
  39. package/src/kit/components/datetimepicker/DateTimePicker.tsx +314 -0
  40. package/src/kit/components/datetimepicker/DateTimeRangePicker.tsx +486 -0
  41. package/src/kit/components/datetimepicker/index.ts +3 -0
  42. package/src/kit/components/timepicker/TimePicker.tsx +311 -0
  43. package/src/kit/components/timepicker/TimeRangePicker.tsx +291 -0
  44. package/src/kit/components/timepicker/index.ts +3 -0
  45. package/src/stories/kit/builder/Form.DateTime.stories.tsx +66 -0
  46. package/src/stories/kit/builder/Form.Time.stories.tsx +64 -0
  47. package/src/stories/kit/components/TimePicker.stories.tsx +69 -0
  48. package/src/stories/kit/components/TimeRangePicker.stories.tsx +37 -0
package/dist/index.js CHANGED
@@ -3097,116 +3097,127 @@ const createLucideIcon = (iconName, iconNode) => {
3097
3097
  * This source code is licensed under the ISC license.
3098
3098
  * See the LICENSE file in the root directory of this source tree.
3099
3099
  */
3100
- const __iconNode$s = [
3100
+ const __iconNode$t = [
3101
3101
  ["path", { d: "M12 5v14", key: "s699le" }],
3102
3102
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
3103
3103
  ];
3104
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$s);
3104
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$t);
3105
3105
  /**
3106
3106
  * @license lucide-react v0.540.0 - ISC
3107
3107
  *
3108
3108
  * This source code is licensed under the ISC license.
3109
3109
  * See the LICENSE file in the root directory of this source tree.
3110
3110
  */
3111
- const __iconNode$r = [
3111
+ const __iconNode$s = [
3112
3112
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
3113
3113
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
3114
3114
  ];
3115
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$r);
3115
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$s);
3116
3116
  /**
3117
3117
  * @license lucide-react v0.540.0 - ISC
3118
3118
  *
3119
3119
  * This source code is licensed under the ISC license.
3120
3120
  * See the LICENSE file in the root directory of this source tree.
3121
3121
  */
3122
- const __iconNode$q = [
3122
+ const __iconNode$r = [
3123
3123
  ["path", { d: "M8 2v4", key: "1cmpym" }],
3124
3124
  ["path", { d: "M16 2v4", key: "4m81vk" }],
3125
3125
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
3126
3126
  ["path", { d: "M3 10h18", key: "8toen8" }]
3127
3127
  ];
3128
- const Calendar$1 = createLucideIcon("calendar", __iconNode$q);
3128
+ const Calendar$1 = createLucideIcon("calendar", __iconNode$r);
3129
3129
  /**
3130
3130
  * @license lucide-react v0.540.0 - ISC
3131
3131
  *
3132
3132
  * This source code is licensed under the ISC license.
3133
3133
  * See the LICENSE file in the root directory of this source tree.
3134
3134
  */
3135
- const __iconNode$p = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
3136
- const Check = createLucideIcon("check", __iconNode$p);
3135
+ const __iconNode$q = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
3136
+ const Check = createLucideIcon("check", __iconNode$q);
3137
3137
  /**
3138
3138
  * @license lucide-react v0.540.0 - ISC
3139
3139
  *
3140
3140
  * This source code is licensed under the ISC license.
3141
3141
  * See the LICENSE file in the root directory of this source tree.
3142
3142
  */
3143
- const __iconNode$o = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
3144
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$o);
3143
+ const __iconNode$p = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
3144
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$p);
3145
3145
  /**
3146
3146
  * @license lucide-react v0.540.0 - ISC
3147
3147
  *
3148
3148
  * This source code is licensed under the ISC license.
3149
3149
  * See the LICENSE file in the root directory of this source tree.
3150
3150
  */
3151
- const __iconNode$n = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
3152
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode$n);
3151
+ const __iconNode$o = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
3152
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$o);
3153
3153
  /**
3154
3154
  * @license lucide-react v0.540.0 - ISC
3155
3155
  *
3156
3156
  * This source code is licensed under the ISC license.
3157
3157
  * See the LICENSE file in the root directory of this source tree.
3158
3158
  */
3159
- const __iconNode$m = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
3160
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$m);
3159
+ const __iconNode$n = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
3160
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode$n);
3161
3161
  /**
3162
3162
  * @license lucide-react v0.540.0 - ISC
3163
3163
  *
3164
3164
  * This source code is licensed under the ISC license.
3165
3165
  * See the LICENSE file in the root directory of this source tree.
3166
3166
  */
3167
- const __iconNode$l = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
3168
- const ChevronUp = createLucideIcon("chevron-up", __iconNode$l);
3167
+ const __iconNode$m = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
3168
+ const ChevronUp = createLucideIcon("chevron-up", __iconNode$m);
3169
3169
  /**
3170
3170
  * @license lucide-react v0.540.0 - ISC
3171
3171
  *
3172
3172
  * This source code is licensed under the ISC license.
3173
3173
  * See the LICENSE file in the root directory of this source tree.
3174
3174
  */
3175
- const __iconNode$k = [
3175
+ const __iconNode$l = [
3176
3176
  ["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
3177
3177
  ["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
3178
3178
  ];
3179
- const ChevronsLeft = createLucideIcon("chevrons-left", __iconNode$k);
3179
+ const ChevronsLeft = createLucideIcon("chevrons-left", __iconNode$l);
3180
3180
  /**
3181
3181
  * @license lucide-react v0.540.0 - ISC
3182
3182
  *
3183
3183
  * This source code is licensed under the ISC license.
3184
3184
  * See the LICENSE file in the root directory of this source tree.
3185
3185
  */
3186
- const __iconNode$j = [
3186
+ const __iconNode$k = [
3187
3187
  ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
3188
3188
  ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
3189
3189
  ];
3190
- const ChevronsRight = createLucideIcon("chevrons-right", __iconNode$j);
3190
+ const ChevronsRight = createLucideIcon("chevrons-right", __iconNode$k);
3191
3191
  /**
3192
3192
  * @license lucide-react v0.540.0 - ISC
3193
3193
  *
3194
3194
  * This source code is licensed under the ISC license.
3195
3195
  * See the LICENSE file in the root directory of this source tree.
3196
3196
  */
3197
- const __iconNode$i = [
3197
+ const __iconNode$j = [
3198
3198
  ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
3199
3199
  ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
3200
3200
  ];
3201
- const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$i);
3201
+ const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$j);
3202
+ /**
3203
+ * @license lucide-react v0.540.0 - ISC
3204
+ *
3205
+ * This source code is licensed under the ISC license.
3206
+ * See the LICENSE file in the root directory of this source tree.
3207
+ */
3208
+ const __iconNode$i = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
3209
+ const Circle = createLucideIcon("circle", __iconNode$i);
3202
3210
  /**
3203
3211
  * @license lucide-react v0.540.0 - ISC
3204
3212
  *
3205
3213
  * This source code is licensed under the ISC license.
3206
3214
  * See the LICENSE file in the root directory of this source tree.
3207
3215
  */
3208
- const __iconNode$h = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
3209
- const Circle = createLucideIcon("circle", __iconNode$h);
3216
+ const __iconNode$h = [
3217
+ ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
3218
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
3219
+ ];
3220
+ const Clock = createLucideIcon("clock", __iconNode$h);
3210
3221
  /**
3211
3222
  * @license lucide-react v0.540.0 - ISC
3212
3223
  *
@@ -13719,7 +13730,7 @@ const oppositeAlignmentMap = {
13719
13730
  start: "end",
13720
13731
  end: "start"
13721
13732
  };
13722
- function clamp$1(start, value, end) {
13733
+ function clamp$2(start, value, end) {
13723
13734
  return max$1(start, min$1(value, end));
13724
13735
  }
13725
13736
  function evaluate(value, param) {
@@ -14070,7 +14081,7 @@ const arrow$3 = (options) => ({
14070
14081
  const min$1$1 = minPadding;
14071
14082
  const max2 = clientSize - arrowDimensions[length] - maxPadding;
14072
14083
  const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
14073
- const offset2 = clamp$1(min$1$1, center, max2);
14084
+ const offset2 = clamp$2(min$1$1, center, max2);
14074
14085
  const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
14075
14086
  const alignmentOffset = shouldAddOffset ? center < min$1$1 ? center - min$1$1 : center - max2 : 0;
14076
14087
  return {
@@ -14367,14 +14378,14 @@ const shift$2 = function(options) {
14367
14378
  const maxSide = mainAxis === "y" ? "bottom" : "right";
14368
14379
  const min2 = mainAxisCoord + overflow[minSide];
14369
14380
  const max2 = mainAxisCoord - overflow[maxSide];
14370
- mainAxisCoord = clamp$1(min2, mainAxisCoord, max2);
14381
+ mainAxisCoord = clamp$2(min2, mainAxisCoord, max2);
14371
14382
  }
14372
14383
  if (checkCrossAxis) {
14373
14384
  const minSide = crossAxis === "y" ? "top" : "left";
14374
14385
  const maxSide = crossAxis === "y" ? "bottom" : "right";
14375
14386
  const min2 = crossAxisCoord + overflow[minSide];
14376
14387
  const max2 = crossAxisCoord - overflow[maxSide];
14377
- crossAxisCoord = clamp$1(min2, crossAxisCoord, max2);
14388
+ crossAxisCoord = clamp$2(min2, crossAxisCoord, max2);
14378
14389
  }
14379
14390
  const limitedCoords = limiter.fn({
14380
14391
  ...state,
@@ -18647,7 +18658,7 @@ function TextareaField({ field, value, onChange, className }) {
18647
18658
  }
18648
18659
  );
18649
18660
  }
18650
- function clamp(value, [min2, max2]) {
18661
+ function clamp$1(value, [min2, max2]) {
18651
18662
  return Math.min(max2, Math.max(min2, value));
18652
18663
  }
18653
18664
  var VISUALLY_HIDDEN_STYLES = Object.freeze({
@@ -19185,7 +19196,7 @@ var SelectItemAlignedPosition = React.forwardRef((props2, forwardedRef) => {
19185
19196
  const minContentWidth = triggerRect.width + leftDelta;
19186
19197
  const contentWidth = Math.max(minContentWidth, contentRect.width);
19187
19198
  const rightEdge = window.innerWidth - CONTENT_MARGIN;
19188
- const clampedLeft = clamp(left, [
19199
+ const clampedLeft = clamp$1(left, [
19189
19200
  CONTENT_MARGIN,
19190
19201
  // Prevents the content from going off the starting edge of the
19191
19202
  // viewport. It may still go off the ending edge, but this can be
@@ -19203,7 +19214,7 @@ var SelectItemAlignedPosition = React.forwardRef((props2, forwardedRef) => {
19203
19214
  const minContentWidth = triggerRect.width + rightDelta;
19204
19215
  const contentWidth = Math.max(minContentWidth, contentRect.width);
19205
19216
  const leftEdge = window.innerWidth - CONTENT_MARGIN;
19206
- const clampedRight = clamp(right, [
19217
+ const clampedRight = clamp$1(right, [
19207
19218
  CONTENT_MARGIN,
19208
19219
  Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
19209
19220
  ]);
@@ -21127,7 +21138,7 @@ function normalizeDates(context, ...dates) {
21127
21138
  );
21128
21139
  return dates.map(normalize);
21129
21140
  }
21130
- function startOfDay$2(date2, options) {
21141
+ function startOfDay$4(date2, options) {
21131
21142
  const _date2 = toDate(date2, options == null ? void 0 : options.in);
21132
21143
  _date2.setHours(0, 0, 0, 0);
21133
21144
  return _date2;
@@ -21138,8 +21149,8 @@ function differenceInCalendarDays(laterDate, earlierDate, options) {
21138
21149
  laterDate,
21139
21150
  earlierDate
21140
21151
  );
21141
- const laterStartOfDay = startOfDay$2(laterDate_);
21142
- const earlierStartOfDay = startOfDay$2(earlierDate_);
21152
+ const laterStartOfDay = startOfDay$4(laterDate_);
21153
+ const earlierStartOfDay = startOfDay$4(earlierDate_);
21143
21154
  const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
21144
21155
  const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
21145
21156
  return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
@@ -21185,7 +21196,7 @@ function isSameDay(laterDate, earlierDate, options) {
21185
21196
  laterDate,
21186
21197
  earlierDate
21187
21198
  );
21188
- return +startOfDay$2(dateLeft_) === +startOfDay$2(dateRight_);
21199
+ return +startOfDay$4(dateLeft_) === +startOfDay$4(dateRight_);
21189
21200
  }
21190
21201
  function isDate(value) {
21191
21202
  return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
@@ -22658,10 +22669,10 @@ function getMonth(date2, options) {
22658
22669
  function getYear(date2, options) {
22659
22670
  return toDate(date2, options == null ? void 0 : options.in).getFullYear();
22660
22671
  }
22661
- function isAfter$2(date2, dateToCompare) {
22672
+ function isAfter$4(date2, dateToCompare) {
22662
22673
  return +toDate(date2) > +toDate(dateToCompare);
22663
22674
  }
22664
- function isBefore$2(date2, dateToCompare) {
22675
+ function isBefore$4(date2, dateToCompare) {
22665
22676
  return +toDate(date2) < +toDate(dateToCompare);
22666
22677
  }
22667
22678
  function isSameMonth(laterDate, earlierDate, options) {
@@ -22827,11 +22838,11 @@ class DateLib {
22827
22838
  };
22828
22839
  this.isAfter = (date2, dateToCompare) => {
22829
22840
  var _a;
22830
- return ((_a = this.overrides) == null ? void 0 : _a.isAfter) ? this.overrides.isAfter(date2, dateToCompare) : isAfter$2(date2, dateToCompare);
22841
+ return ((_a = this.overrides) == null ? void 0 : _a.isAfter) ? this.overrides.isAfter(date2, dateToCompare) : isAfter$4(date2, dateToCompare);
22831
22842
  };
22832
22843
  this.isBefore = (date2, dateToCompare) => {
22833
22844
  var _a;
22834
- return ((_a = this.overrides) == null ? void 0 : _a.isBefore) ? this.overrides.isBefore(date2, dateToCompare) : isBefore$2(date2, dateToCompare);
22845
+ return ((_a = this.overrides) == null ? void 0 : _a.isBefore) ? this.overrides.isBefore(date2, dateToCompare) : isBefore$4(date2, dateToCompare);
22835
22846
  };
22836
22847
  this.isDate = (value) => {
22837
22848
  var _a;
@@ -22871,7 +22882,7 @@ class DateLib {
22871
22882
  };
22872
22883
  this.startOfDay = (date2) => {
22873
22884
  var _a;
22874
- return ((_a = this.overrides) == null ? void 0 : _a.startOfDay) ? this.overrides.startOfDay(date2) : startOfDay$2(date2);
22885
+ return ((_a = this.overrides) == null ? void 0 : _a.startOfDay) ? this.overrides.startOfDay(date2) : startOfDay$4(date2);
22875
22886
  };
22876
22887
  this.startOfISOWeek = (date2) => {
22877
22888
  var _a;
@@ -24706,27 +24717,27 @@ function CalendarDayButton({
24706
24717
  }
24707
24718
  );
24708
24719
  }
24709
- function isBefore$1(date2, min2) {
24720
+ function isBefore$3(date2, min2) {
24710
24721
  return !!(min2 && date2 < new Date(min2.getFullYear(), min2.getMonth(), min2.getDate()));
24711
24722
  }
24712
- function isAfter$1(date2, max2) {
24723
+ function isAfter$3(date2, max2) {
24713
24724
  return !!(max2 && date2 > new Date(max2.getFullYear(), max2.getMonth(), max2.getDate()));
24714
24725
  }
24715
- function startOfDay$1(d) {
24726
+ function startOfDay$3(d) {
24716
24727
  return new Date(d.getFullYear(), d.getMonth(), d.getDate());
24717
24728
  }
24718
- function sameDay$1(a2, b2) {
24729
+ function sameDay$3(a2, b2) {
24719
24730
  return a2.getFullYear() === b2.getFullYear() && a2.getMonth() === b2.getMonth() && a2.getDate() === b2.getDate();
24720
24731
  }
24721
- function inDisabled$1(date2, items) {
24732
+ function inDisabled$3(date2, items) {
24722
24733
  if (!items || items.length === 0) return false;
24723
- const d = startOfDay$1(date2);
24734
+ const d = startOfDay$3(date2);
24724
24735
  for (const it of items) {
24725
24736
  if (it instanceof Date) {
24726
- if (sameDay$1(d, it)) return true;
24737
+ if (sameDay$3(d, it)) return true;
24727
24738
  } else if (it && "from" in it && "to" in it) {
24728
- const from = startOfDay$1(it.from);
24729
- const to = startOfDay$1(it.to);
24739
+ const from = startOfDay$3(it.from);
24740
+ const to = startOfDay$3(it.to);
24730
24741
  if (d >= from && d <= to) return true;
24731
24742
  }
24732
24743
  }
@@ -24749,8 +24760,8 @@ function DatePicker({
24749
24760
  const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
24750
24761
  const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
24751
24762
  const isDisabled = (date2) => {
24752
- if (isBefore$1(date2, minDate) || isAfter$1(date2, maxDate)) return true;
24753
- if (inDisabled$1(date2, disabledDates)) return true;
24763
+ if (isBefore$3(date2, minDate) || isAfter$3(date2, maxDate)) return true;
24764
+ if (inDisabled$3(date2, disabledDates)) return true;
24754
24765
  return false;
24755
24766
  };
24756
24767
  const label = value ? format2 ? format2(value) : value.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" }) : placeholder;
@@ -24837,42 +24848,42 @@ function DatePickerField({ field, value, onChange, className }) {
24837
24848
  }
24838
24849
  );
24839
24850
  }
24840
- function sameDay(a2, b2) {
24851
+ function sameDay$2(a2, b2) {
24841
24852
  return a2.getFullYear() === b2.getFullYear() && a2.getMonth() === b2.getMonth() && a2.getDate() === b2.getDate();
24842
24853
  }
24843
- function isBefore(date2, min2) {
24854
+ function isBefore$2(date2, min2) {
24844
24855
  return !!(min2 && date2 < new Date(min2.getFullYear(), min2.getMonth(), min2.getDate()));
24845
24856
  }
24846
- function isAfter(date2, max2) {
24857
+ function isAfter$2(date2, max2) {
24847
24858
  return !!(max2 && date2 > new Date(max2.getFullYear(), max2.getMonth(), max2.getDate()));
24848
24859
  }
24849
- function startOfDay(d) {
24860
+ function startOfDay$2(d) {
24850
24861
  return new Date(d.getFullYear(), d.getMonth(), d.getDate());
24851
24862
  }
24852
- function inDisabled(date2, items) {
24863
+ function inDisabled$2(date2, items) {
24853
24864
  if (!items || items.length === 0) return false;
24854
- const d = startOfDay(date2);
24865
+ const d = startOfDay$2(date2);
24855
24866
  for (const it of items) {
24856
24867
  if (it instanceof Date) {
24857
- if (sameDay(d, it)) return true;
24868
+ if (sameDay$2(d, it)) return true;
24858
24869
  } else if (it && "from" in it && "to" in it) {
24859
- const from = startOfDay(it.from);
24860
- const to = startOfDay(it.to);
24870
+ const from = startOfDay$2(it.from);
24871
+ const to = startOfDay$2(it.to);
24861
24872
  if (d >= from && d <= to) return true;
24862
24873
  }
24863
24874
  }
24864
24875
  return false;
24865
24876
  }
24866
- function rangeContainsDisabled(from, to, items) {
24877
+ function rangeContainsDisabled$1(from, to, items) {
24867
24878
  if (!from || !to) return false;
24868
24879
  if (!items || items.length === 0) return false;
24869
- const a2 = startOfDay(from);
24870
- const b2 = startOfDay(to);
24880
+ const a2 = startOfDay$2(from);
24881
+ const b2 = startOfDay$2(to);
24871
24882
  const start = a2 <= b2 ? a2 : b2;
24872
24883
  const end = a2 <= b2 ? b2 : a2;
24873
24884
  let cur = start;
24874
24885
  while (cur <= end) {
24875
- if (inDisabled(cur, items)) return true;
24886
+ if (inDisabled$2(cur, items)) return true;
24876
24887
  cur = new Date(cur.getFullYear(), cur.getMonth(), cur.getDate() + 1);
24877
24888
  }
24878
24889
  return false;
@@ -24895,8 +24906,8 @@ function DateRangePicker({
24895
24906
  const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
24896
24907
  const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
24897
24908
  const isDisabled = (date2) => {
24898
- if (isBefore(date2, minDate) || isAfter(date2, maxDate)) return true;
24899
- if (inDisabled(date2, disabledDates)) return true;
24909
+ if (isBefore$2(date2, minDate) || isAfter$2(date2, maxDate)) return true;
24910
+ if (inDisabled$2(date2, disabledDates)) return true;
24900
24911
  return false;
24901
24912
  };
24902
24913
  const label = (value == null ? void 0 : value.from) ? format2 ? format2(value.from, value.to) : value.to ? `${value.from.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" })} – ${value.to.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" })}` : `${value.from.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" })} – …` : placeholder;
@@ -24942,7 +24953,7 @@ function DateRangePicker({
24942
24953
  const out = new Date(yyyy, mm - 1, dd);
24943
24954
  if (minDate && out < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return void 0;
24944
24955
  if (maxDate && out > new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate())) return void 0;
24945
- if (inDisabled(out, disabledDates)) return void 0;
24956
+ if (inDisabled$2(out, disabledDates)) return void 0;
24946
24957
  return out;
24947
24958
  };
24948
24959
  const onFromChange = (val) => {
@@ -24959,7 +24970,7 @@ function DateRangePicker({
24959
24970
  const toInvalid = toTouched && !!toInput && !toParsed;
24960
24971
  const mergedFrom = fromParsed ?? (draft == null ? void 0 : draft.from) ?? void 0;
24961
24972
  const mergedTo = toParsed ?? (draft == null ? void 0 : draft.to) ?? void 0;
24962
- const invalidRange = !mergedFrom || !mergedTo || isDisabled(mergedFrom) || isDisabled(mergedTo) || mergedFrom > mergedTo || rangeContainsDisabled(mergedFrom, mergedTo, disabledDates);
24973
+ const invalidRange = !mergedFrom || !mergedTo || isDisabled(mergedFrom) || isDisabled(mergedTo) || mergedFrom > mergedTo || rangeContainsDisabled$1(mergedFrom, mergedTo, disabledDates);
24963
24974
  const applyFromInput = () => {
24964
24975
  setFromTouched(true);
24965
24976
  if (!fromParsed) return;
@@ -24970,7 +24981,7 @@ function DateRangePicker({
24970
24981
  if (!toParsed) return;
24971
24982
  setDraft((prev) => ({ from: prev == null ? void 0 : prev.from, to: toParsed }));
24972
24983
  };
24973
- const draftInvalidForSelection = !!(draft == null ? void 0 : draft.from) && isDisabled(draft.from) || !!(draft == null ? void 0 : draft.to) && isDisabled(draft.to) || !!(draft == null ? void 0 : draft.from) && !!(draft == null ? void 0 : draft.to) && rangeContainsDisabled(draft.from, draft.to, disabledDates);
24984
+ const draftInvalidForSelection = !!(draft == null ? void 0 : draft.from) && isDisabled(draft.from) || !!(draft == null ? void 0 : draft.to) && isDisabled(draft.to) || !!(draft == null ? void 0 : draft.from) && !!(draft == null ? void 0 : draft.to) && rangeContainsDisabled$1(draft.from, draft.to, disabledDates);
24974
24985
  const selectedRange = draftInvalidForSelection ? void 0 : draft ?? void 0;
24975
24986
  const startOfDay2 = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
24976
24987
  const startOfWeek2 = (d) => {
@@ -25063,7 +25074,7 @@ function DateRangePicker({
25063
25074
  const presets = (props2.presets ?? props2.quickSelectors ?? defaultPresets).filter(Boolean);
25064
25075
  const eqRange = (a2, b2) => {
25065
25076
  if (!(a2 == null ? void 0 : a2.from) || !(a2 == null ? void 0 : a2.to) || !(b2 == null ? void 0 : b2.from) || !(b2 == null ? void 0 : b2.to)) return false;
25066
- return sameDay(a2.from, b2.from) && sameDay(a2.to, b2.to);
25077
+ return sameDay$2(a2.from, b2.from) && sameDay$2(a2.to, b2.to);
25067
25078
  };
25068
25079
  return /* @__PURE__ */ jsx("div", { className: cn$1("w-fit", className), ...props2, children: /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: (o2) => !disabled && setOpen(o2), children: [
25069
25080
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
@@ -25136,7 +25147,7 @@ function DateRangePicker({
25136
25147
  setDraft({ from, to: void 0 });
25137
25148
  return;
25138
25149
  }
25139
- if (from && to && rangeContainsDisabled(from, to, disabledDates)) {
25150
+ if (from && to && rangeContainsDisabled$1(from, to, disabledDates)) {
25140
25151
  setDraft(null);
25141
25152
  setFromTouched(true);
25142
25153
  setToTouched(true);
@@ -25168,7 +25179,7 @@ function DateRangePicker({
25168
25179
  variant: active ? "secondary" : "ghost",
25169
25180
  className: "justify-between w-full",
25170
25181
  onClick: () => {
25171
- if (rangeContainsDisabled(pr.from, pr.to, disabledDates)) return;
25182
+ if (rangeContainsDisabled$1(pr.from, pr.to, disabledDates)) return;
25172
25183
  setDraft(pr);
25173
25184
  setFromTouched(false);
25174
25185
  setToTouched(false);
@@ -25907,6 +25918,1167 @@ function MonthRangePickerField({ field, value, onChange, className }) {
25907
25918
  }
25908
25919
  );
25909
25920
  }
25921
+ const clamp = (n2, min2, max2) => Math.max(min2, Math.min(max2, n2));
25922
+ const pad2$3 = (n2) => String(n2).padStart(2, "0");
25923
+ function TimePicker({
25924
+ value,
25925
+ onChange,
25926
+ placeholder = "Pick a time",
25927
+ disabled,
25928
+ precision = "minute",
25929
+ hourCycle = 24,
25930
+ minuteStep = 5,
25931
+ secondStep = 5,
25932
+ className,
25933
+ buttonVariant = "outline",
25934
+ ...props2
25935
+ }) {
25936
+ const [internalOpen, setInternalOpen] = React.useState(false);
25937
+ const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
25938
+ const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
25939
+ const [draft, setDraft] = React.useState(value ?? null);
25940
+ React.useEffect(() => {
25941
+ if (isOpen) setDraft(value ?? null);
25942
+ }, [isOpen, value]);
25943
+ const fmtLabel = (d) => {
25944
+ if (!d) return placeholder;
25945
+ const h = d.getHours();
25946
+ const m2 = d.getMinutes();
25947
+ const s2 = d.getSeconds();
25948
+ if (hourCycle === 12) {
25949
+ const period = h >= 12 ? "PM" : "AM";
25950
+ const hour12 = h % 12 === 0 ? 12 : h % 12;
25951
+ if (precision === "hour") return `${hour12} ${period}`;
25952
+ if (precision === "minute") return `${hour12}:${pad2$3(m2)} ${period}`;
25953
+ return `${hour12}:${pad2$3(m2)}:${pad2$3(s2)} ${period}`;
25954
+ }
25955
+ if (precision === "hour") return `${pad2$3(h)}`;
25956
+ if (precision === "minute") return `${pad2$3(h)}:${pad2$3(m2)}`;
25957
+ return `${pad2$3(h)}:${pad2$3(m2)}:${pad2$3(s2)}`;
25958
+ };
25959
+ const setDraftPart = (part, val) => {
25960
+ setDraft((prev) => {
25961
+ const base = prev ? new Date(prev) : (() => {
25962
+ const n2 = /* @__PURE__ */ new Date();
25963
+ return new Date(
25964
+ n2.getFullYear(),
25965
+ n2.getMonth(),
25966
+ n2.getDate(),
25967
+ 0,
25968
+ 0,
25969
+ 0,
25970
+ 0
25971
+ );
25972
+ })();
25973
+ if (part === "hour") {
25974
+ let h = Number(val);
25975
+ if (hourCycle === 12) {
25976
+ const isPM = base.getHours() >= 12;
25977
+ h = h % 12;
25978
+ base.setHours(isPM ? h === 12 ? 12 : h + 12 : h === 12 ? 0 : h);
25979
+ } else {
25980
+ base.setHours(clamp(h, 0, 23));
25981
+ }
25982
+ } else if (part === "minute") {
25983
+ base.setMinutes(clamp(Number(val), 0, 59));
25984
+ } else if (part === "second") {
25985
+ base.setSeconds(clamp(Number(val), 0, 59));
25986
+ } else if (part === "period" && (val === "AM" || val === "PM")) {
25987
+ const curH = base.getHours();
25988
+ const isAMNow = curH < 12;
25989
+ if (val === "AM" && !isAMNow) base.setHours(curH - 12);
25990
+ if (val === "PM" && isAMNow) base.setHours(curH + 12);
25991
+ }
25992
+ base.setMilliseconds(0);
25993
+ return new Date(base);
25994
+ });
25995
+ };
25996
+ const hours = React.useMemo(() => {
25997
+ return hourCycle === 12 ? Array.from({ length: 12 }, (_2, i2) => i2 + 1) : Array.from({ length: 24 }, (_2, i2) => i2);
25998
+ }, [hourCycle]);
25999
+ const minutes = React.useMemo(
26000
+ () => Array.from(
26001
+ { length: Math.ceil(60 / minuteStep) },
26002
+ (_2, i2) => i2 * minuteStep
26003
+ ),
26004
+ [minuteStep]
26005
+ );
26006
+ const seconds = React.useMemo(
26007
+ () => Array.from(
26008
+ { length: Math.ceil(60 / secondStep) },
26009
+ (_2, i2) => i2 * secondStep
26010
+ ),
26011
+ [secondStep]
26012
+ );
26013
+ const selectedHour = React.useMemo(() => {
26014
+ if (!draft) return hourCycle === 12 ? 12 : 0;
26015
+ const h = draft.getHours();
26016
+ return hourCycle === 12 ? h % 12 === 0 ? 12 : h % 12 : h;
26017
+ }, [draft, hourCycle]);
26018
+ const selectedMinute = (draft == null ? void 0 : draft.getMinutes()) ?? 0;
26019
+ const selectedSecond = (draft == null ? void 0 : draft.getSeconds()) ?? 0;
26020
+ const selectedPeriod = draft && draft.getHours() >= 12 ? "PM" : "AM";
26021
+ const label = fmtLabel(value ?? null);
26022
+ return /* @__PURE__ */ jsx("div", { className: cn$1("w-fit", className), ...props2, children: /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: setOpen, children: [
26023
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
26024
+ Button$1,
26025
+ {
26026
+ type: "button",
26027
+ disabled,
26028
+ variant: buttonVariant,
26029
+ className: cn$1(
26030
+ "w-[240px] justify-start text-left font-normal",
26031
+ !value && "text-muted-foreground"
26032
+ ),
26033
+ children: [
26034
+ /* @__PURE__ */ jsx(Clock, { className: "mr-2 h-4 w-4" }),
26035
+ label
26036
+ ]
26037
+ }
26038
+ ) }),
26039
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "p-3 w-auto", align: "start", children: [
26040
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26041
+ /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26042
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Hour" }),
26043
+ /* @__PURE__ */ jsxs(
26044
+ Select$1,
26045
+ {
26046
+ disabled,
26047
+ value: String(selectedHour),
26048
+ onValueChange: (v) => setDraftPart("hour", Number(v)),
26049
+ children: [
26050
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Hour", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26051
+ /* @__PURE__ */ jsx(SelectContent, { children: hours.map((h) => /* @__PURE__ */ jsx(SelectItem, { value: String(h), children: hourCycle === 12 ? h : pad2$3(h) }, h)) })
26052
+ ]
26053
+ }
26054
+ )
26055
+ ] }),
26056
+ (precision === "minute" || precision === "second") && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26057
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Minute" }),
26058
+ /* @__PURE__ */ jsxs(
26059
+ Select$1,
26060
+ {
26061
+ disabled,
26062
+ value: String(selectedMinute - selectedMinute % minuteStep),
26063
+ onValueChange: (v) => setDraftPart("minute", Number(v)),
26064
+ children: [
26065
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Minute", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26066
+ /* @__PURE__ */ jsx(SelectContent, { children: minutes.map((m2) => /* @__PURE__ */ jsx(SelectItem, { value: String(m2), children: pad2$3(m2) }, m2)) })
26067
+ ]
26068
+ }
26069
+ )
26070
+ ] }),
26071
+ precision === "second" && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26072
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Second" }),
26073
+ /* @__PURE__ */ jsxs(
26074
+ Select$1,
26075
+ {
26076
+ disabled,
26077
+ value: String(selectedSecond - selectedSecond % secondStep),
26078
+ onValueChange: (v) => setDraftPart("second", Number(v)),
26079
+ children: [
26080
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Second", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26081
+ /* @__PURE__ */ jsx(SelectContent, { children: seconds.map((s2) => /* @__PURE__ */ jsx(SelectItem, { value: String(s2), children: pad2$3(s2) }, s2)) })
26082
+ ]
26083
+ }
26084
+ )
26085
+ ] }),
26086
+ hourCycle === 12 && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26087
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Period" }),
26088
+ /* @__PURE__ */ jsxs(
26089
+ Select$1,
26090
+ {
26091
+ disabled,
26092
+ value: selectedPeriod,
26093
+ onValueChange: (v) => setDraftPart("period", v),
26094
+ children: [
26095
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Period", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26096
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
26097
+ /* @__PURE__ */ jsx(SelectItem, { value: "AM", children: "AM" }),
26098
+ /* @__PURE__ */ jsx(SelectItem, { value: "PM", children: "PM" })
26099
+ ] })
26100
+ ]
26101
+ }
26102
+ )
26103
+ ] })
26104
+ ] }),
26105
+ (props2.showFooter ?? true) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 pt-3 mt-3 border-t", children: [
26106
+ /* @__PURE__ */ jsx(
26107
+ Button$1,
26108
+ {
26109
+ type: "button",
26110
+ variant: "outline",
26111
+ size: "sm",
26112
+ onClick: () => setOpen(false),
26113
+ disabled,
26114
+ children: props2.cancelLabel ?? "Cancel"
26115
+ }
26116
+ ),
26117
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
26118
+ /* @__PURE__ */ jsx(
26119
+ Button$1,
26120
+ {
26121
+ type: "button",
26122
+ variant: "ghost",
26123
+ size: "sm",
26124
+ onClick: () => onChange == null ? void 0 : onChange(null),
26125
+ disabled,
26126
+ children: props2.clearLabel ?? "Clear"
26127
+ }
26128
+ ),
26129
+ /* @__PURE__ */ jsx(
26130
+ Button$1,
26131
+ {
26132
+ type: "button",
26133
+ variant: "default",
26134
+ size: "sm",
26135
+ onClick: () => {
26136
+ onChange == null ? void 0 : onChange(draft ?? null);
26137
+ setOpen(false);
26138
+ },
26139
+ children: props2.applyLabel ?? "Apply"
26140
+ }
26141
+ )
26142
+ ] })
26143
+ ] })
26144
+ ] })
26145
+ ] }) });
26146
+ }
26147
+ TimePicker.displayName = "TimePicker";
26148
+ function TimePickerField({ field, value, onChange, className }) {
26149
+ const v = React.useMemo(() => {
26150
+ if (!value) return null;
26151
+ if (value instanceof Date) return value;
26152
+ const d = new Date(value);
26153
+ return Number.isNaN(d.getTime()) ? null : d;
26154
+ }, [value]);
26155
+ return /* @__PURE__ */ jsx(
26156
+ TimePicker,
26157
+ {
26158
+ className,
26159
+ value: v,
26160
+ onChange: (d) => onChange(d),
26161
+ placeholder: field.placeholder,
26162
+ precision: field.timePrecision ?? "minute",
26163
+ hourCycle: field.hourCycle ?? 24,
26164
+ minuteStep: field.minuteStep ?? 5,
26165
+ secondStep: field.secondStep ?? 5,
26166
+ showFooter: field.showFooter,
26167
+ cancelLabel: field.cancelLabel,
26168
+ applyLabel: field.applyLabel
26169
+ }
26170
+ );
26171
+ }
26172
+ const pad2$2 = (n2) => String(n2).padStart(2, "0");
26173
+ function TimeUnitSelector({
26174
+ label,
26175
+ hourCycle,
26176
+ precision,
26177
+ minuteStep,
26178
+ secondStep,
26179
+ disabled,
26180
+ value,
26181
+ onChange
26182
+ }) {
26183
+ const hours = React.useMemo(() => hourCycle === 12 ? Array.from({ length: 12 }, (_2, i2) => i2 + 1) : Array.from({ length: 24 }, (_2, i2) => i2), [hourCycle]);
26184
+ const minutes = React.useMemo(() => Array.from({ length: Math.ceil(60 / minuteStep) }, (_2, i2) => i2 * minuteStep), [minuteStep]);
26185
+ const seconds = React.useMemo(() => Array.from({ length: Math.ceil(60 / secondStep) }, (_2, i2) => i2 * secondStep), [secondStep]);
26186
+ const selectedHour = React.useMemo(() => {
26187
+ if (!value) return hourCycle === 12 ? 12 : 0;
26188
+ const h = value.getHours();
26189
+ return hourCycle === 12 ? h % 12 === 0 ? 12 : h % 12 : h;
26190
+ }, [value, hourCycle]);
26191
+ const selectedMinute = (value == null ? void 0 : value.getMinutes()) ?? 0;
26192
+ const selectedSecond = (value == null ? void 0 : value.getSeconds()) ?? 0;
26193
+ const selectedPeriod = value && value.getHours() >= 12 ? "PM" : "AM";
26194
+ const setPart = (part, v) => {
26195
+ const base = value ? new Date(value) : (() => {
26196
+ const n2 = /* @__PURE__ */ new Date();
26197
+ return new Date(n2.getFullYear(), n2.getMonth(), n2.getDate(), 0, 0, 0, 0);
26198
+ })();
26199
+ if (part === "hour") {
26200
+ let h = Number(v);
26201
+ if (hourCycle === 12) {
26202
+ const isPM = base.getHours() >= 12;
26203
+ h = h % 12;
26204
+ base.setHours(isPM ? h === 12 ? 12 : h + 12 : h === 12 ? 0 : h);
26205
+ } else {
26206
+ base.setHours(h);
26207
+ }
26208
+ } else if (part === "minute") {
26209
+ base.setMinutes(Number(v));
26210
+ } else if (part === "second") {
26211
+ base.setSeconds(Number(v));
26212
+ } else if (part === "period" && (v === "AM" || v === "PM")) {
26213
+ const curH = base.getHours();
26214
+ const isAMNow = curH < 12;
26215
+ if (v === "AM" && !isAMNow) base.setHours(curH - 12);
26216
+ if (v === "PM" && isAMNow) base.setHours(curH + 12);
26217
+ }
26218
+ base.setMilliseconds(0);
26219
+ onChange(base);
26220
+ };
26221
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
26222
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: label }),
26223
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26224
+ /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26225
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Hour" }),
26226
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedHour), onValueChange: (v) => setPart("hour", Number(v)), children: [
26227
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} hour`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26228
+ /* @__PURE__ */ jsx(SelectContent, { children: hours.map((h) => /* @__PURE__ */ jsx(SelectItem, { value: String(h), children: hourCycle === 12 ? h : pad2$2(h) }, h)) })
26229
+ ] })
26230
+ ] }),
26231
+ (precision === "minute" || precision === "second") && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26232
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Minute" }),
26233
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedMinute - selectedMinute % minuteStep), onValueChange: (v) => setPart("minute", Number(v)), children: [
26234
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} minute`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26235
+ /* @__PURE__ */ jsx(SelectContent, { children: minutes.map((m2) => /* @__PURE__ */ jsx(SelectItem, { value: String(m2), children: pad2$2(m2) }, m2)) })
26236
+ ] })
26237
+ ] }),
26238
+ precision === "second" && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26239
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Second" }),
26240
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedSecond - selectedSecond % secondStep), onValueChange: (v) => setPart("second", Number(v)), children: [
26241
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} second`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26242
+ /* @__PURE__ */ jsx(SelectContent, { children: seconds.map((s2) => /* @__PURE__ */ jsx(SelectItem, { value: String(s2), children: pad2$2(s2) }, s2)) })
26243
+ ] })
26244
+ ] }),
26245
+ hourCycle === 12 && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26246
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Period" }),
26247
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: selectedPeriod, onValueChange: (v) => setPart("period", v), children: [
26248
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} period`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26249
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
26250
+ /* @__PURE__ */ jsx(SelectItem, { value: "AM", children: "AM" }),
26251
+ /* @__PURE__ */ jsx(SelectItem, { value: "PM", children: "PM" })
26252
+ ] })
26253
+ ] })
26254
+ ] })
26255
+ ] })
26256
+ ] });
26257
+ }
26258
+ function TimeRangePicker({
26259
+ value,
26260
+ onChange,
26261
+ placeholder = "Pick a time range",
26262
+ disabled,
26263
+ precision = "minute",
26264
+ hourCycle = 24,
26265
+ minuteStep = 5,
26266
+ secondStep = 5,
26267
+ className,
26268
+ buttonVariant = "outline",
26269
+ format: format2,
26270
+ ...props2
26271
+ }) {
26272
+ const [internalOpen, setInternalOpen] = React.useState(false);
26273
+ const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
26274
+ const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
26275
+ const [draft, setDraft] = React.useState(value ?? null);
26276
+ React.useEffect(() => {
26277
+ if (isOpen) setDraft(value ?? null);
26278
+ }, [isOpen, value]);
26279
+ const label = React.useMemo(() => {
26280
+ const f = (draft == null ? void 0 : draft.from) ?? (value == null ? void 0 : value.from) ?? null;
26281
+ const t2 = (draft == null ? void 0 : draft.to) ?? (value == null ? void 0 : value.to) ?? null;
26282
+ if (format2) return format2(f ?? null, t2 ?? null);
26283
+ const fs = f ? hourCycle === 12 ? `${f.getHours() % 12 || 12}:${pad2$2(f.getMinutes())}${precision === "second" ? `:${pad2$2(f.getSeconds())}` : ""} ${f.getHours() >= 12 ? "PM" : "AM"}` : `${pad2$2(f.getHours())}:${pad2$2(f.getMinutes())}${precision === "second" ? `:${pad2$2(f.getSeconds())}` : ""}` : null;
26284
+ const ts = t2 ? hourCycle === 12 ? `${t2.getHours() % 12 || 12}:${pad2$2(t2.getMinutes())}${precision === "second" ? `:${pad2$2(t2.getSeconds())}` : ""} ${t2.getHours() >= 12 ? "PM" : "AM"}` : `${pad2$2(t2.getHours())}:${pad2$2(t2.getMinutes())}${precision === "second" ? `:${pad2$2(t2.getSeconds())}` : ""}` : null;
26285
+ return fs && ts ? `${fs} – ${ts}` : placeholder;
26286
+ }, [draft, value, format2, hourCycle, precision, placeholder]);
26287
+ return /* @__PURE__ */ jsx("div", { className: cn$1("w-fit", className), ...props2, children: /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: setOpen, children: [
26288
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
26289
+ Button$1,
26290
+ {
26291
+ type: "button",
26292
+ disabled,
26293
+ variant: buttonVariant,
26294
+ className: cn$1("w-[280px] justify-start text-left font-normal", !value && "text-muted-foreground"),
26295
+ children: [
26296
+ /* @__PURE__ */ jsx(Clock, { className: "mr-2 h-4 w-4" }),
26297
+ label
26298
+ ]
26299
+ }
26300
+ ) }),
26301
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "p-3 w-auto", align: "start", children: [
26302
+ /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
26303
+ /* @__PURE__ */ jsx(
26304
+ TimeUnitSelector,
26305
+ {
26306
+ label: "From",
26307
+ value: (draft == null ? void 0 : draft.from) ?? null,
26308
+ onChange: (d) => setDraft((prev) => ({ ...prev ?? {}, from: d })),
26309
+ hourCycle,
26310
+ precision,
26311
+ minuteStep,
26312
+ secondStep,
26313
+ disabled
26314
+ }
26315
+ ),
26316
+ /* @__PURE__ */ jsx(
26317
+ TimeUnitSelector,
26318
+ {
26319
+ label: "To",
26320
+ value: (draft == null ? void 0 : draft.to) ?? null,
26321
+ onChange: (d) => setDraft((prev) => ({ ...prev ?? {}, to: d })),
26322
+ hourCycle,
26323
+ precision,
26324
+ minuteStep,
26325
+ secondStep,
26326
+ disabled
26327
+ }
26328
+ )
26329
+ ] }),
26330
+ (props2.showFooter ?? true) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 pt-3 mt-3 border-t", children: [
26331
+ /* @__PURE__ */ jsx(
26332
+ Button$1,
26333
+ {
26334
+ type: "button",
26335
+ variant: "outline",
26336
+ size: "sm",
26337
+ onClick: () => setOpen(false),
26338
+ disabled,
26339
+ children: props2.cancelLabel ?? "Cancel"
26340
+ }
26341
+ ),
26342
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
26343
+ /* @__PURE__ */ jsx(
26344
+ Button$1,
26345
+ {
26346
+ type: "button",
26347
+ variant: "ghost",
26348
+ size: "sm",
26349
+ onClick: () => onChange == null ? void 0 : onChange(null),
26350
+ disabled,
26351
+ children: props2.clearLabel ?? "Clear"
26352
+ }
26353
+ ),
26354
+ /* @__PURE__ */ jsx(
26355
+ Button$1,
26356
+ {
26357
+ type: "button",
26358
+ variant: "default",
26359
+ size: "sm",
26360
+ onClick: () => {
26361
+ onChange == null ? void 0 : onChange(draft ?? null);
26362
+ setOpen(false);
26363
+ },
26364
+ children: props2.applyLabel ?? "Apply"
26365
+ }
26366
+ )
26367
+ ] })
26368
+ ] })
26369
+ ] })
26370
+ ] }) });
26371
+ }
26372
+ TimeRangePicker.displayName = "TimeRangePicker";
26373
+ function TimeRangePickerField({ field, value, onChange, className }) {
26374
+ const v = React.useMemo(() => {
26375
+ if (!value || typeof value !== "object") return null;
26376
+ const anyVal = value;
26377
+ const toDate2 = (x2) => {
26378
+ if (!x2) return void 0;
26379
+ if (x2 instanceof Date) return x2;
26380
+ const d = new Date(x2);
26381
+ return Number.isNaN(d.getTime()) ? void 0 : d;
26382
+ };
26383
+ const from = toDate2(anyVal.from) ?? null;
26384
+ const to = toDate2(anyVal.to) ?? null;
26385
+ return { from, to };
26386
+ }, [value]);
26387
+ return /* @__PURE__ */ jsx(
26388
+ TimeRangePicker,
26389
+ {
26390
+ className,
26391
+ value: v,
26392
+ onChange: (range) => onChange(range),
26393
+ placeholder: field.placeholder,
26394
+ precision: field.timePrecision ?? "minute",
26395
+ hourCycle: field.hourCycle ?? 24,
26396
+ minuteStep: field.minuteStep ?? 5,
26397
+ secondStep: field.secondStep ?? 5,
26398
+ showFooter: field.showFooter,
26399
+ cancelLabel: field.cancelLabel,
26400
+ applyLabel: field.applyLabel
26401
+ }
26402
+ );
26403
+ }
26404
+ const startOfDay$1 = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
26405
+ const pad2$1 = (n2) => String(n2).padStart(2, "0");
26406
+ const isBefore$1 = (date2, min2) => !!(min2 && date2 < startOfDay$1(min2));
26407
+ const isAfter$1 = (date2, max2) => !!(max2 && date2 > startOfDay$1(max2));
26408
+ function sameDay$1(a2, b2) {
26409
+ return a2.getFullYear() === b2.getFullYear() && a2.getMonth() === b2.getMonth() && a2.getDate() === b2.getDate();
26410
+ }
26411
+ function inDisabled$1(date2, items) {
26412
+ if (!items || items.length === 0) return false;
26413
+ const d = startOfDay$1(date2);
26414
+ for (const it of items) {
26415
+ if (it instanceof Date) {
26416
+ if (sameDay$1(d, it)) return true;
26417
+ } else if (it && "from" in it && "to" in it) {
26418
+ const from = startOfDay$1(it.from);
26419
+ const to = startOfDay$1(it.to);
26420
+ if (d >= from && d <= to) return true;
26421
+ }
26422
+ }
26423
+ return false;
26424
+ }
26425
+ function TimeSelectors$1({
26426
+ value,
26427
+ onChange,
26428
+ precision,
26429
+ hourCycle,
26430
+ minuteStep,
26431
+ secondStep,
26432
+ disabled
26433
+ }) {
26434
+ const hours = React.useMemo(() => hourCycle === 12 ? Array.from({ length: 12 }, (_2, i2) => i2 + 1) : Array.from({ length: 24 }, (_2, i2) => i2), [hourCycle]);
26435
+ const minutes = React.useMemo(() => Array.from({ length: Math.ceil(60 / minuteStep) }, (_2, i2) => i2 * minuteStep), [minuteStep]);
26436
+ const seconds = React.useMemo(() => Array.from({ length: Math.ceil(60 / secondStep) }, (_2, i2) => i2 * secondStep), [secondStep]);
26437
+ const selectedHour = React.useMemo(() => {
26438
+ if (!value) return hourCycle === 12 ? 12 : 0;
26439
+ const h = value.getHours();
26440
+ return hourCycle === 12 ? h % 12 === 0 ? 12 : h % 12 : h;
26441
+ }, [value, hourCycle]);
26442
+ const selectedMinute = (value == null ? void 0 : value.getMinutes()) ?? 0;
26443
+ const selectedSecond = (value == null ? void 0 : value.getSeconds()) ?? 0;
26444
+ const selectedPeriod = value && value.getHours() >= 12 ? "PM" : "AM";
26445
+ const setPart = (part, v) => {
26446
+ const base = value ? new Date(value) : (() => {
26447
+ const n2 = /* @__PURE__ */ new Date();
26448
+ return new Date(n2.getFullYear(), n2.getMonth(), n2.getDate(), 0, 0, 0, 0);
26449
+ })();
26450
+ if (part === "hour") {
26451
+ let h = Number(v);
26452
+ if (hourCycle === 12) {
26453
+ const isPM = base.getHours() >= 12;
26454
+ h = h % 12;
26455
+ base.setHours(isPM ? h === 12 ? 12 : h + 12 : h === 12 ? 0 : h);
26456
+ } else {
26457
+ base.setHours(h);
26458
+ }
26459
+ } else if (part === "minute") {
26460
+ base.setMinutes(Number(v));
26461
+ } else if (part === "second") {
26462
+ base.setSeconds(Number(v));
26463
+ } else if (part === "period" && (v === "AM" || v === "PM")) {
26464
+ const curH = base.getHours();
26465
+ const isAMNow = curH < 12;
26466
+ if (v === "AM" && !isAMNow) base.setHours(curH - 12);
26467
+ if (v === "PM" && isAMNow) base.setHours(curH + 12);
26468
+ }
26469
+ base.setMilliseconds(0);
26470
+ onChange(base);
26471
+ };
26472
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26473
+ /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26474
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Hour" }),
26475
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedHour), onValueChange: (v) => setPart("hour", Number(v)), children: [
26476
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Hour", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26477
+ /* @__PURE__ */ jsx(SelectContent, { children: hours.map((h) => /* @__PURE__ */ jsx(SelectItem, { value: String(h), children: hourCycle === 12 ? h : pad2$1(h) }, h)) })
26478
+ ] })
26479
+ ] }),
26480
+ (precision === "minute" || precision === "second") && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26481
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Minute" }),
26482
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedMinute - selectedMinute % minuteStep), onValueChange: (v) => setPart("minute", Number(v)), children: [
26483
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Minute", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26484
+ /* @__PURE__ */ jsx(SelectContent, { children: minutes.map((m2) => /* @__PURE__ */ jsx(SelectItem, { value: String(m2), children: pad2$1(m2) }, m2)) })
26485
+ ] })
26486
+ ] }),
26487
+ precision === "second" && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26488
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Second" }),
26489
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedSecond - selectedSecond % secondStep), onValueChange: (v) => setPart("second", Number(v)), children: [
26490
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Second", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26491
+ /* @__PURE__ */ jsx(SelectContent, { children: seconds.map((s2) => /* @__PURE__ */ jsx(SelectItem, { value: String(s2), children: pad2$1(s2) }, s2)) })
26492
+ ] })
26493
+ ] }),
26494
+ hourCycle === 12 && /* @__PURE__ */ jsxs("div", { className: "w-24", children: [
26495
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Period" }),
26496
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: selectedPeriod, onValueChange: (v) => setPart("period", v), children: [
26497
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": "Period", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26498
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
26499
+ /* @__PURE__ */ jsx(SelectItem, { value: "AM", children: "AM" }),
26500
+ /* @__PURE__ */ jsx(SelectItem, { value: "PM", children: "PM" })
26501
+ ] })
26502
+ ] })
26503
+ ] })
26504
+ ] });
26505
+ }
26506
+ function DateTimePicker({
26507
+ value,
26508
+ onChange,
26509
+ placeholder = "Pick a date & time",
26510
+ disabled,
26511
+ minDate,
26512
+ maxDate,
26513
+ disabledDates,
26514
+ timePrecision = "minute",
26515
+ hourCycle = 24,
26516
+ minuteStep = 5,
26517
+ secondStep = 5,
26518
+ className,
26519
+ buttonVariant = "outline",
26520
+ ...props2
26521
+ }) {
26522
+ const [internalOpen, setInternalOpen] = React.useState(false);
26523
+ const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
26524
+ const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
26525
+ const [draft, setDraft] = React.useState(value ?? null);
26526
+ React.useEffect(() => {
26527
+ if (isOpen) setDraft(value ?? null);
26528
+ }, [isOpen, value]);
26529
+ const isDisabled = (date2) => {
26530
+ if (isBefore$1(date2, minDate) || isAfter$1(date2, maxDate)) return true;
26531
+ if (inDisabled$1(date2, disabledDates)) return true;
26532
+ return false;
26533
+ };
26534
+ const fmtLabel = (d) => {
26535
+ if (!d) return placeholder;
26536
+ const dateStr = d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" });
26537
+ const h = d.getHours();
26538
+ const m2 = d.getMinutes();
26539
+ const s2 = d.getSeconds();
26540
+ const timeStr = hourCycle === 12 ? `${h % 12 || 12}:${pad2$1(m2)}${timePrecision === "second" ? `:${pad2$1(s2)}` : ""} ${h >= 12 ? "PM" : "AM"}` : `${pad2$1(h)}:${pad2$1(m2)}${timePrecision === "second" ? `:${pad2$1(s2)}` : ""}`;
26541
+ return `${dateStr} ${timeStr}`;
26542
+ };
26543
+ const label = fmtLabel(value ?? null);
26544
+ return /* @__PURE__ */ jsx("div", { className: cn$1("w-fit", className), ...props2, children: /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: setOpen, children: [
26545
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
26546
+ Button$1,
26547
+ {
26548
+ type: "button",
26549
+ disabled,
26550
+ variant: buttonVariant,
26551
+ className: cn$1("w-[280px] justify-start text-left font-normal", !value && "text-muted-foreground"),
26552
+ children: [
26553
+ /* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }),
26554
+ label
26555
+ ]
26556
+ }
26557
+ ) }),
26558
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "p-0", align: "start", children: [
26559
+ /* @__PURE__ */ jsxs("div", { className: "p-3 space-y-3", children: [
26560
+ /* @__PURE__ */ jsx(
26561
+ Calendar,
26562
+ {
26563
+ mode: "single",
26564
+ selected: draft ?? void 0,
26565
+ onSelect: (d) => {
26566
+ if (disabled) return;
26567
+ if (!d) return;
26568
+ if (isDisabled(d)) return;
26569
+ if (draft) {
26570
+ const nd = new Date(d.getFullYear(), d.getMonth(), d.getDate(), draft.getHours(), draft.getMinutes(), draft.getSeconds());
26571
+ setDraft(nd);
26572
+ } else {
26573
+ setDraft(new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0));
26574
+ }
26575
+ },
26576
+ defaultMonth: draft ?? /* @__PURE__ */ new Date(),
26577
+ disabled: isDisabled,
26578
+ buttonVariant: "ghost",
26579
+ showOutsideDays: true
26580
+ }
26581
+ ),
26582
+ /* @__PURE__ */ jsxs("div", { children: [
26583
+ /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Time" }),
26584
+ /* @__PURE__ */ jsx(
26585
+ TimeSelectors$1,
26586
+ {
26587
+ value: draft,
26588
+ onChange: (d) => setDraft(d),
26589
+ precision: timePrecision,
26590
+ hourCycle,
26591
+ minuteStep,
26592
+ secondStep,
26593
+ disabled
26594
+ }
26595
+ )
26596
+ ] })
26597
+ ] }),
26598
+ (props2.showFooter ?? true) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 p-2 border-t", children: [
26599
+ /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "outline", size: "sm", onClick: () => setOpen(false), disabled, children: props2.cancelLabel ?? "Cancel" }),
26600
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
26601
+ /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "ghost", size: "sm", onClick: () => onChange == null ? void 0 : onChange(null), disabled, children: props2.clearLabel ?? "Clear" }),
26602
+ /* @__PURE__ */ jsx(
26603
+ Button$1,
26604
+ {
26605
+ type: "button",
26606
+ variant: "default",
26607
+ size: "sm",
26608
+ onClick: () => {
26609
+ onChange == null ? void 0 : onChange(draft ?? null);
26610
+ setOpen(false);
26611
+ },
26612
+ children: props2.applyLabel ?? "Apply"
26613
+ }
26614
+ )
26615
+ ] })
26616
+ ] })
26617
+ ] })
26618
+ ] }) });
26619
+ }
26620
+ DateTimePicker.displayName = "DateTimePicker";
26621
+ function DateTimePickerField({ field, value, onChange, className }) {
26622
+ const v = React.useMemo(() => {
26623
+ if (!value) return null;
26624
+ if (value instanceof Date) return value;
26625
+ const d = new Date(value);
26626
+ return Number.isNaN(d.getTime()) ? null : d;
26627
+ }, [value]);
26628
+ return /* @__PURE__ */ jsx(
26629
+ DateTimePicker,
26630
+ {
26631
+ className,
26632
+ value: v,
26633
+ onChange: (d) => onChange(d),
26634
+ placeholder: field.placeholder,
26635
+ minDate: field.minDate,
26636
+ maxDate: field.maxDate,
26637
+ disabledDates: field.disabledDates,
26638
+ timePrecision: field.timePrecision ?? "minute",
26639
+ hourCycle: field.hourCycle ?? 24,
26640
+ minuteStep: field.minuteStep ?? 5,
26641
+ secondStep: field.secondStep ?? 5,
26642
+ showFooter: field.showFooter,
26643
+ cancelLabel: field.cancelLabel,
26644
+ applyLabel: field.applyLabel
26645
+ }
26646
+ );
26647
+ }
26648
+ const pad2 = (n2) => String(n2).padStart(2, "0");
26649
+ function startOfDay(d) {
26650
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
26651
+ }
26652
+ function sameDay(a2, b2) {
26653
+ return a2.getFullYear() === b2.getFullYear() && a2.getMonth() === b2.getMonth() && a2.getDate() === b2.getDate();
26654
+ }
26655
+ function isBefore(date2, min2) {
26656
+ return !!(min2 && date2 < startOfDay(min2));
26657
+ }
26658
+ function isAfter(date2, max2) {
26659
+ return !!(max2 && date2 > startOfDay(max2));
26660
+ }
26661
+ function inDisabled(date2, items) {
26662
+ if (!items || items.length === 0) return false;
26663
+ const d = startOfDay(date2);
26664
+ for (const it of items) {
26665
+ if (it instanceof Date) {
26666
+ if (sameDay(d, it)) return true;
26667
+ } else if (it && "from" in it && "to" in it) {
26668
+ const from = startOfDay(it.from);
26669
+ const to = startOfDay(it.to);
26670
+ if (d >= from && d <= to) return true;
26671
+ }
26672
+ }
26673
+ return false;
26674
+ }
26675
+ function rangeContainsDisabled(from, to, items) {
26676
+ if (!from || !to) return false;
26677
+ if (!items || items.length === 0) return false;
26678
+ const a2 = startOfDay(from);
26679
+ const b2 = startOfDay(to);
26680
+ const start = a2 <= b2 ? a2 : b2;
26681
+ const end = a2 <= b2 ? b2 : a2;
26682
+ let cur = start;
26683
+ while (cur <= end) {
26684
+ if (inDisabled(cur, items)) return true;
26685
+ cur = new Date(cur.getFullYear(), cur.getMonth(), cur.getDate() + 1);
26686
+ }
26687
+ return false;
26688
+ }
26689
+ function TimeSelectors({
26690
+ label,
26691
+ value,
26692
+ onChange,
26693
+ precision,
26694
+ hourCycle,
26695
+ minuteStep,
26696
+ secondStep,
26697
+ disabled,
26698
+ compact: compact2
26699
+ }) {
26700
+ const hours = React.useMemo(() => hourCycle === 12 ? Array.from({ length: 12 }, (_2, i2) => i2 + 1) : Array.from({ length: 24 }, (_2, i2) => i2), [hourCycle]);
26701
+ const minutes = React.useMemo(() => Array.from({ length: Math.ceil(60 / minuteStep) }, (_2, i2) => i2 * minuteStep), [minuteStep]);
26702
+ const seconds = React.useMemo(() => Array.from({ length: Math.ceil(60 / secondStep) }, (_2, i2) => i2 * secondStep), [secondStep]);
26703
+ const selectedHour = React.useMemo(() => {
26704
+ if (!value) return hourCycle === 12 ? 12 : 0;
26705
+ const h = value.getHours();
26706
+ return hourCycle === 12 ? h % 12 === 0 ? 12 : h % 12 : h;
26707
+ }, [value, hourCycle]);
26708
+ const selectedMinute = (value == null ? void 0 : value.getMinutes()) ?? 0;
26709
+ const selectedSecond = (value == null ? void 0 : value.getSeconds()) ?? 0;
26710
+ const selectedPeriod = value && value.getHours() >= 12 ? "PM" : "AM";
26711
+ const setPart = (part, v) => {
26712
+ const base = value ? new Date(value) : (() => {
26713
+ const n2 = /* @__PURE__ */ new Date();
26714
+ return new Date(n2.getFullYear(), n2.getMonth(), n2.getDate(), 0, 0, 0, 0);
26715
+ })();
26716
+ if (part === "hour") {
26717
+ let h = Number(v);
26718
+ if (hourCycle === 12) {
26719
+ const isPM = base.getHours() >= 12;
26720
+ h = h % 12;
26721
+ base.setHours(isPM ? h === 12 ? 12 : h + 12 : h === 12 ? 0 : h);
26722
+ } else {
26723
+ base.setHours(h);
26724
+ }
26725
+ } else if (part === "minute") {
26726
+ base.setMinutes(Number(v));
26727
+ } else if (part === "second") {
26728
+ base.setSeconds(Number(v));
26729
+ } else if (part === "period" && (v === "AM" || v === "PM")) {
26730
+ const curH = base.getHours();
26731
+ const isAMNow = curH < 12;
26732
+ if (v === "AM" && !isAMNow) base.setHours(curH - 12);
26733
+ if (v === "PM" && isAMNow) base.setHours(curH + 12);
26734
+ }
26735
+ base.setMilliseconds(0);
26736
+ onChange(base);
26737
+ };
26738
+ const widthClass = compact2 ? "w-16" : "w-24";
26739
+ return /* @__PURE__ */ jsxs("div", { className: compact2 ? "" : "space-y-1", children: [
26740
+ !compact2 && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: label }),
26741
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26742
+ /* @__PURE__ */ jsxs("div", { className: widthClass, children: [
26743
+ !compact2 && /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Hour" }),
26744
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedHour), onValueChange: (v) => setPart("hour", Number(v)), children: [
26745
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} hour`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26746
+ /* @__PURE__ */ jsx(SelectContent, { children: hours.map((h) => /* @__PURE__ */ jsx(SelectItem, { value: String(h), children: hourCycle === 12 ? h : pad2(h) }, h)) })
26747
+ ] })
26748
+ ] }),
26749
+ (precision === "minute" || precision === "second") && /* @__PURE__ */ jsxs("div", { className: widthClass, children: [
26750
+ !compact2 && /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Minute" }),
26751
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedMinute - selectedMinute % minuteStep), onValueChange: (v) => setPart("minute", Number(v)), children: [
26752
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} minute`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26753
+ /* @__PURE__ */ jsx(SelectContent, { children: minutes.map((m2) => /* @__PURE__ */ jsx(SelectItem, { value: String(m2), children: pad2(m2) }, m2)) })
26754
+ ] })
26755
+ ] }),
26756
+ precision === "second" && /* @__PURE__ */ jsxs("div", { className: widthClass, children: [
26757
+ !compact2 && /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Second" }),
26758
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: String(selectedSecond - selectedSecond % secondStep), onValueChange: (v) => setPart("second", Number(v)), children: [
26759
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} second`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26760
+ /* @__PURE__ */ jsx(SelectContent, { children: seconds.map((s2) => /* @__PURE__ */ jsx(SelectItem, { value: String(s2), children: pad2(s2) }, s2)) })
26761
+ ] })
26762
+ ] }),
26763
+ hourCycle === 12 && /* @__PURE__ */ jsxs("div", { className: widthClass, children: [
26764
+ !compact2 && /* @__PURE__ */ jsx("div", { className: "mb-1 block text-xs text-muted-foreground", children: "Period" }),
26765
+ /* @__PURE__ */ jsxs(Select$1, { disabled, value: selectedPeriod, onValueChange: (v) => setPart("period", v), children: [
26766
+ /* @__PURE__ */ jsx(SelectTrigger, { "aria-label": `${label} period`, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
26767
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
26768
+ /* @__PURE__ */ jsx(SelectItem, { value: "AM", children: "AM" }),
26769
+ /* @__PURE__ */ jsx(SelectItem, { value: "PM", children: "PM" })
26770
+ ] })
26771
+ ] })
26772
+ ] })
26773
+ ] })
26774
+ ] });
26775
+ }
26776
+ function DateTimeRangePicker({
26777
+ value,
26778
+ onChange,
26779
+ placeholder = "Pick a date & time range",
26780
+ disabled,
26781
+ minDate,
26782
+ maxDate,
26783
+ disabledDates,
26784
+ numberOfMonths = 2,
26785
+ popoverSide,
26786
+ timePrecision = "minute",
26787
+ hourCycle = 24,
26788
+ minuteStep = 5,
26789
+ secondStep = 5,
26790
+ className,
26791
+ buttonVariant = "outline",
26792
+ contentClassName,
26793
+ ...props2
26794
+ }) {
26795
+ const [internalOpen, setInternalOpen] = React.useState(false);
26796
+ const isOpen = typeof props2.open === "boolean" ? props2.open : internalOpen;
26797
+ const setOpen = (o2) => props2.onOpenChange ? props2.onOpenChange(o2) : setInternalOpen(o2);
26798
+ const [draft, setDraft] = React.useState(value ?? null);
26799
+ React.useEffect(() => {
26800
+ if (isOpen) setDraft(value ?? null);
26801
+ }, [isOpen, value]);
26802
+ const fmtTime = React.useCallback((d) => {
26803
+ if (!d) return "";
26804
+ const h = d.getHours();
26805
+ const m2 = d.getMinutes();
26806
+ const s2 = d.getSeconds();
26807
+ return hourCycle === 12 ? `${h % 12 || 12}:${pad2(m2)}${timePrecision === "second" ? `:${pad2(s2)}` : ""} ${h >= 12 ? "PM" : "AM"}` : `${pad2(h)}:${pad2(m2)}${timePrecision === "second" ? `:${pad2(s2)}` : ""}`;
26808
+ }, [hourCycle, timePrecision]);
26809
+ const label = React.useMemo(() => {
26810
+ const f = (draft == null ? void 0 : draft.from) ?? (value == null ? void 0 : value.from) ?? null;
26811
+ const t2 = (draft == null ? void 0 : draft.to) ?? (value == null ? void 0 : value.to) ?? null;
26812
+ if (f && t2) {
26813
+ const fd = f.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" });
26814
+ const td = t2.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "2-digit" });
26815
+ return `${fd} ${fmtTime(f)} – ${td} ${fmtTime(t2)}`;
26816
+ }
26817
+ return placeholder;
26818
+ }, [draft, value, placeholder, fmtTime]);
26819
+ const fmtDate = React.useCallback((d) => {
26820
+ if (!d) return "";
26821
+ const dd = String(d.getDate()).padStart(2, "0");
26822
+ const mm = String(d.getMonth() + 1).padStart(2, "0");
26823
+ const yyyy = d.getFullYear();
26824
+ return `${dd} / ${mm} / ${yyyy}`;
26825
+ }, []);
26826
+ const [fromInput, setFromInput] = React.useState(fmtDate((draft == null ? void 0 : draft.from) ?? (value == null ? void 0 : value.from) ?? null));
26827
+ const [toInput, setToInput] = React.useState(fmtDate((draft == null ? void 0 : draft.to) ?? (value == null ? void 0 : value.to) ?? null));
26828
+ React.useEffect(() => {
26829
+ if (isOpen) {
26830
+ setFromInput(fmtDate((value == null ? void 0 : value.from) ?? null));
26831
+ setToInput(fmtDate((value == null ? void 0 : value.to) ?? null));
26832
+ }
26833
+ }, [isOpen, value, fmtDate]);
26834
+ const maskDate = (raw) => {
26835
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
26836
+ const parts = [];
26837
+ const dd = digits.slice(0, Math.min(2, digits.length));
26838
+ if (dd) parts.push(dd);
26839
+ const mm = digits.length > 2 ? digits.slice(2, Math.min(4, digits.length)) : "";
26840
+ if (mm) parts.push(mm);
26841
+ const yyyy = digits.length > 4 ? digits.slice(4) : "";
26842
+ if (yyyy) parts.push(yyyy);
26843
+ return parts.join(" / ");
26844
+ };
26845
+ const parseMasked = (masked) => {
26846
+ const m2 = masked.match(/^(\d{1,2})\s*\/\s*(\d{1,2})\s*\/\s*(\d{4})$/);
26847
+ if (!m2) return void 0;
26848
+ const dd = Number(m2[1]);
26849
+ const mm = Number(m2[2]);
26850
+ const yyyy = Number(m2[3]);
26851
+ if (mm < 1 || mm > 12) return void 0;
26852
+ const lastDay = new Date(yyyy, mm, 0).getDate();
26853
+ if (dd < 1 || dd > lastDay) return void 0;
26854
+ const out = new Date(yyyy, mm - 1, dd);
26855
+ if (isBefore(out, minDate) || isAfter(out, maxDate) || inDisabled(out, disabledDates)) return void 0;
26856
+ return out;
26857
+ };
26858
+ const fromParsed = parseMasked(fromInput);
26859
+ const toParsed = parseMasked(toInput);
26860
+ const mergedFrom = React.useMemo(() => {
26861
+ if (fromParsed) {
26862
+ const base = (draft == null ? void 0 : draft.from) ?? (value == null ? void 0 : value.from) ?? null;
26863
+ if (base) {
26864
+ return new Date(
26865
+ fromParsed.getFullYear(),
26866
+ fromParsed.getMonth(),
26867
+ fromParsed.getDate(),
26868
+ base.getHours(),
26869
+ base.getMinutes(),
26870
+ base.getSeconds()
26871
+ );
26872
+ }
26873
+ return fromParsed;
26874
+ }
26875
+ return (draft == null ? void 0 : draft.from) ?? void 0;
26876
+ }, [fromParsed, draft, value]);
26877
+ const mergedTo = React.useMemo(() => {
26878
+ if (toParsed) {
26879
+ const base = (draft == null ? void 0 : draft.to) ?? (value == null ? void 0 : value.to) ?? null;
26880
+ if (base) {
26881
+ return new Date(
26882
+ toParsed.getFullYear(),
26883
+ toParsed.getMonth(),
26884
+ toParsed.getDate(),
26885
+ base.getHours(),
26886
+ base.getMinutes(),
26887
+ base.getSeconds()
26888
+ );
26889
+ }
26890
+ return toParsed;
26891
+ }
26892
+ return (draft == null ? void 0 : draft.to) ?? void 0;
26893
+ }, [toParsed, draft, value]);
26894
+ const invalidRange = !mergedFrom || !mergedTo || isBefore(mergedFrom, minDate) || isAfter(mergedTo, maxDate) || mergedFrom > mergedTo || rangeContainsDisabled(mergedFrom, mergedTo, disabledDates);
26895
+ return /* @__PURE__ */ jsx("div", { className: cn$1("w-fit", className), ...props2, children: /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: setOpen, children: [
26896
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button$1, { type: "button", disabled, variant: buttonVariant, className: cn$1("w-[360px] justify-start text-left font-normal", !value && "text-muted-foreground"), children: [
26897
+ /* @__PURE__ */ jsx(Calendar$1, { className: "mr-2 h-4 w-4" }),
26898
+ label
26899
+ ] }) }),
26900
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-auto max-w-none p-4", align: "start", side: popoverSide ?? "bottom", sideOffset: 8, children: [
26901
+ /* @__PURE__ */ jsxs("div", { className: cn$1("w-fit min-w-0", contentClassName), children: [
26902
+ /* @__PURE__ */ jsx("div", { className: "mb-3 rounded-md border border-input bg-background/50 px-3 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [
26903
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26904
+ /* @__PURE__ */ jsx(
26905
+ "input",
26906
+ {
26907
+ type: "text",
26908
+ inputMode: "numeric",
26909
+ value: fromInput,
26910
+ onChange: (e) => setFromInput(maskDate(e.target.value)),
26911
+ onBlur: () => {
26912
+ const p2 = parseMasked(fromInput);
26913
+ if (p2) {
26914
+ const prev = (draft == null ? void 0 : draft.from) ?? null;
26915
+ const withTime = new Date(
26916
+ p2.getFullYear(),
26917
+ p2.getMonth(),
26918
+ p2.getDate(),
26919
+ prev ? prev.getHours() : 0,
26920
+ prev ? prev.getMinutes() : 0,
26921
+ prev ? prev.getSeconds() : 0
26922
+ );
26923
+ setDraft((d) => ({ ...d ?? {}, from: withTime }));
26924
+ }
26925
+ },
26926
+ placeholder: "dd/mm/yyyy",
26927
+ className: "h-9 w-40 rounded-md border bg-background px-3 text-sm shadow-xs outline-hidden"
26928
+ }
26929
+ ),
26930
+ /* @__PURE__ */ jsx(
26931
+ TimeSelectors,
26932
+ {
26933
+ label: "From",
26934
+ compact: true,
26935
+ value: (draft == null ? void 0 : draft.from) ?? null,
26936
+ onChange: (d) => setDraft((prev) => ({ ...prev ?? {}, from: d })),
26937
+ precision: timePrecision,
26938
+ hourCycle,
26939
+ minuteStep,
26940
+ secondStep,
26941
+ disabled
26942
+ }
26943
+ )
26944
+ ] }),
26945
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "–" }),
26946
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
26947
+ /* @__PURE__ */ jsx(
26948
+ "input",
26949
+ {
26950
+ type: "text",
26951
+ inputMode: "numeric",
26952
+ value: toInput,
26953
+ onChange: (e) => setToInput(maskDate(e.target.value)),
26954
+ onBlur: () => {
26955
+ const p2 = parseMasked(toInput);
26956
+ if (p2) {
26957
+ const prev = (draft == null ? void 0 : draft.to) ?? null;
26958
+ const withTime = new Date(
26959
+ p2.getFullYear(),
26960
+ p2.getMonth(),
26961
+ p2.getDate(),
26962
+ prev ? prev.getHours() : 0,
26963
+ prev ? prev.getMinutes() : 0,
26964
+ prev ? prev.getSeconds() : 0
26965
+ );
26966
+ setDraft((d) => ({ ...d ?? {}, to: withTime }));
26967
+ }
26968
+ },
26969
+ placeholder: "dd/mm/yyyy",
26970
+ className: "h-9 w-40 rounded-md border bg-background px-3 text-sm shadow-xs outline-hidden"
26971
+ }
26972
+ ),
26973
+ /* @__PURE__ */ jsx(
26974
+ TimeSelectors,
26975
+ {
26976
+ label: "To",
26977
+ compact: true,
26978
+ value: (draft == null ? void 0 : draft.to) ?? null,
26979
+ onChange: (d) => setDraft((prev) => ({ ...prev ?? {}, to: d })),
26980
+ precision: timePrecision,
26981
+ hourCycle,
26982
+ minuteStep,
26983
+ secondStep,
26984
+ disabled
26985
+ }
26986
+ )
26987
+ ] })
26988
+ ] }) }),
26989
+ /* @__PURE__ */ jsx(
26990
+ Calendar,
26991
+ {
26992
+ mode: "range",
26993
+ numberOfMonths,
26994
+ selected: (draft == null ? void 0 : draft.from) && (draft == null ? void 0 : draft.to) ? { from: draft.from, to: draft.to } : void 0,
26995
+ onSelect: (range) => {
26996
+ var _a, _b, _c, _d, _e2, _f;
26997
+ if (disabled) return;
26998
+ if (!range) {
26999
+ setDraft(null);
27000
+ return;
27001
+ }
27002
+ const { from, to } = range;
27003
+ if (from && (isBefore(from, minDate) || isAfter(from, maxDate))) return;
27004
+ if (to && (isBefore(to, minDate) || isAfter(to, maxDate))) return;
27005
+ if (from && to && rangeContainsDisabled(from, to, disabledDates)) return;
27006
+ const prevFrom = (draft == null ? void 0 : draft.from) ?? from;
27007
+ const prevTo = (draft == null ? void 0 : draft.to) ?? to;
27008
+ const nextFrom = from ? new Date(from.getFullYear(), from.getMonth(), from.getDate(), ((_a = prevFrom == null ? void 0 : prevFrom.getHours) == null ? void 0 : _a.call(prevFrom)) ?? 0, ((_b = prevFrom == null ? void 0 : prevFrom.getMinutes) == null ? void 0 : _b.call(prevFrom)) ?? 0, ((_c = prevFrom == null ? void 0 : prevFrom.getSeconds) == null ? void 0 : _c.call(prevFrom)) ?? 0) : void 0;
27009
+ const nextTo = to ? new Date(to.getFullYear(), to.getMonth(), to.getDate(), ((_d = prevTo == null ? void 0 : prevTo.getHours) == null ? void 0 : _d.call(prevTo)) ?? 0, ((_e2 = prevTo == null ? void 0 : prevTo.getMinutes) == null ? void 0 : _e2.call(prevTo)) ?? 0, ((_f = prevTo == null ? void 0 : prevTo.getSeconds) == null ? void 0 : _f.call(prevTo)) ?? 0) : void 0;
27010
+ setDraft({ from: nextFrom ?? null, to: nextTo ?? null });
27011
+ setFromInput(fmtDate(nextFrom ?? null));
27012
+ setToInput(fmtDate(nextTo ?? null));
27013
+ },
27014
+ defaultMonth: (draft == null ? void 0 : draft.from) ?? (value == null ? void 0 : value.from) ?? /* @__PURE__ */ new Date(),
27015
+ disabled: (d) => isBefore(d, minDate) || isAfter(d, maxDate) || inDisabled(d, disabledDates),
27016
+ buttonVariant: "ghost",
27017
+ showOutsideDays: true
27018
+ }
27019
+ )
27020
+ ] }),
27021
+ (props2.showFooter ?? true) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 pt-3 mt-3 border-t", children: [
27022
+ /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "outline", size: "sm", onClick: () => setOpen(false), disabled, children: props2.cancelLabel ?? "Cancel" }),
27023
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
27024
+ /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "ghost", size: "sm", onClick: () => onChange == null ? void 0 : onChange(null), disabled, children: props2.clearLabel ?? "Clear" }),
27025
+ /* @__PURE__ */ jsx(
27026
+ Button$1,
27027
+ {
27028
+ type: "button",
27029
+ variant: "default",
27030
+ size: "sm",
27031
+ onClick: () => {
27032
+ if (invalidRange || !mergedFrom || !mergedTo) return;
27033
+ onChange == null ? void 0 : onChange({ from: mergedFrom, to: mergedTo });
27034
+ setOpen(false);
27035
+ },
27036
+ disabled: disabled || invalidRange,
27037
+ children: props2.applyLabel ?? "Apply"
27038
+ }
27039
+ )
27040
+ ] })
27041
+ ] })
27042
+ ] })
27043
+ ] }) });
27044
+ }
27045
+ DateTimeRangePicker.displayName = "DateTimeRangePicker";
27046
+ function DateTimeRangePickerField({ field, value, onChange, className }) {
27047
+ const v = React.useMemo(() => {
27048
+ if (!value || typeof value !== "object") return null;
27049
+ const anyVal = value;
27050
+ const toDate2 = (x2) => {
27051
+ if (!x2) return void 0;
27052
+ if (x2 instanceof Date) return x2;
27053
+ const d = new Date(x2);
27054
+ return Number.isNaN(d.getTime()) ? void 0 : d;
27055
+ };
27056
+ const from = toDate2(anyVal.from) ?? null;
27057
+ const to = toDate2(anyVal.to) ?? null;
27058
+ return { from, to };
27059
+ }, [value]);
27060
+ return /* @__PURE__ */ jsx(
27061
+ DateTimeRangePicker,
27062
+ {
27063
+ className,
27064
+ value: v,
27065
+ onChange: (range) => onChange(range),
27066
+ placeholder: field.placeholder,
27067
+ minDate: field.minDate,
27068
+ maxDate: field.maxDate,
27069
+ disabledDates: field.disabledDates,
27070
+ numberOfMonths: field.numberOfMonths ?? 2,
27071
+ popoverSide: field.popoverSide,
27072
+ timePrecision: field.timePrecision ?? "minute",
27073
+ hourCycle: field.hourCycle ?? 24,
27074
+ minuteStep: field.minuteStep ?? 5,
27075
+ secondStep: field.secondStep ?? 5,
27076
+ showFooter: field.showFooter,
27077
+ cancelLabel: field.cancelLabel,
27078
+ applyLabel: field.applyLabel
27079
+ }
27080
+ );
27081
+ }
25910
27082
  function FileField({ field, onChange, className }) {
25911
27083
  return /* @__PURE__ */ jsx(
25912
27084
  Input,
@@ -26339,6 +27511,54 @@ function FormBuilderField({ field, control, onChange, parentPath }) {
26339
27511
  className: baseClassName
26340
27512
  }
26341
27513
  );
27514
+ case "time":
27515
+ return /* @__PURE__ */ jsx(
27516
+ TimePickerField,
27517
+ {
27518
+ field,
27519
+ control,
27520
+ fieldPath,
27521
+ value: controllerField.value,
27522
+ onChange: handleChange,
27523
+ className: baseClassName
27524
+ }
27525
+ );
27526
+ case "time_range":
27527
+ return /* @__PURE__ */ jsx(
27528
+ TimeRangePickerField,
27529
+ {
27530
+ field,
27531
+ control,
27532
+ fieldPath,
27533
+ value: controllerField.value,
27534
+ onChange: handleChange,
27535
+ className: baseClassName
27536
+ }
27537
+ );
27538
+ case "date_time":
27539
+ return /* @__PURE__ */ jsx(
27540
+ DateTimePickerField,
27541
+ {
27542
+ field,
27543
+ control,
27544
+ fieldPath,
27545
+ value: controllerField.value,
27546
+ onChange: handleChange,
27547
+ className: baseClassName
27548
+ }
27549
+ );
27550
+ case "date_time_range":
27551
+ return /* @__PURE__ */ jsx(
27552
+ DateTimeRangePickerField,
27553
+ {
27554
+ field,
27555
+ control,
27556
+ fieldPath,
27557
+ value: controllerField.value,
27558
+ onChange: handleChange,
27559
+ className: baseClassName
27560
+ }
27561
+ );
26342
27562
  case "file":
26343
27563
  return /* @__PURE__ */ jsx(
26344
27564
  FileField,
@@ -27027,9 +28247,13 @@ function FormBuilder({
27027
28247
  case "date_picker":
27028
28248
  case "month":
27029
28249
  case "date":
28250
+ case "time":
28251
+ case "date_time":
27030
28252
  baseSchema = date();
27031
28253
  break;
27032
28254
  case "date_range":
28255
+ case "time_range":
28256
+ case "date_time_range":
27033
28257
  baseSchema = object({ from: date().optional().nullable(), to: date().optional().nullable() }).nullable();
27034
28258
  break;
27035
28259
  case "month_range":
@@ -27093,9 +28317,13 @@ function FormBuilder({
27093
28317
  case "date_picker":
27094
28318
  case "month":
27095
28319
  case "date":
28320
+ case "time":
28321
+ case "date_time":
27096
28322
  fieldSchema = date();
27097
28323
  break;
27098
28324
  case "date_range":
28325
+ case "time_range":
28326
+ case "date_time_range":
27099
28327
  fieldSchema = object({ from: date().optional().nullable(), to: date().optional().nullable() }).nullable();
27100
28328
  break;
27101
28329
  case "month_range":
@@ -52728,7 +53956,7 @@ function getThumbOffsetFromScroll(scrollPos, sizes, dir = "ltr") {
52728
53956
  const maxScrollPos = sizes.content - sizes.viewport;
52729
53957
  const maxThumbPos = scrollbar - thumbSizePx;
52730
53958
  const scrollClampRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
52731
- const scrollWithoutMomentum = clamp(scrollPos, scrollClampRange);
53959
+ const scrollWithoutMomentum = clamp$1(scrollPos, scrollClampRange);
52732
53960
  const interpolate = linearScale$1([0, maxScrollPos], [0, maxThumbPos]);
52733
53961
  return interpolate(scrollWithoutMomentum);
52734
53962
  }
@@ -52903,7 +54131,7 @@ var Slider$1 = React.forwardRef(
52903
54131
  function updateValues(value2, atIndex, { commit } = { commit: false }) {
52904
54132
  const decimalCount = getDecimalCount(step);
52905
54133
  const snapToStep = roundValue(Math.round((value2 - min2) / step) * step + min2, decimalCount);
52906
- const nextValue = clamp(snapToStep, [min2, max2]);
54134
+ const nextValue = clamp$1(snapToStep, [min2, max2]);
52907
54135
  setValues((prevValues = []) => {
52908
54136
  const nextValues = getNextSortedValues(prevValues, nextValue, atIndex);
52909
54137
  if (hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) {
@@ -53326,7 +54554,7 @@ function convertValueToPercentage(value, min2, max2) {
53326
54554
  const maxSteps = max2 - min2;
53327
54555
  const percentPerStep = 100 / maxSteps;
53328
54556
  const percentage = percentPerStep * (value - min2);
53329
- return clamp(percentage, [0, 100]);
54557
+ return clamp$1(percentage, [0, 100]);
53330
54558
  }
53331
54559
  function getLabel(index2, totalValues) {
53332
54560
  if (totalValues > 2) {