@rachelallyson/hero-hook-form 2.9.0 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.9.2] - 2026-01-28
6
+
7
+ ### Added
8
+
9
+ - **Date field: Date and ISO string default values** – You can pass a normal JavaScript `Date` or an ISO date string (e.g. `"2025-03-20"`) in `defaultValues` for date fields; the library converts them to `CalendarDate` for HeroUI DateInput.
10
+ - **Shared date coercion** – New `toCalendarDateValue()` in `utils/dateCoercion.ts`; used by `DateField` and `ServerActionForm` so date inputs always receive a valid `CalendarDate | null` and no longer throw "Invalid granularity day" for raw `Date` values.
11
+ - **ConfigProvider: DateInput common defaults** – Date inputs now receive the same `common` defaults (variant, size, radius, labelPlacement) as Input, Textarea, and Select when using `HeroHookFormProvider` with `defaults.common`.
12
+ - **useZodForm** – Merges field-level `defaultValue` from field configs into form `defaultValues`; date values in `config.defaultValues` are converted to `CalendarDate` for date fields.
13
+ - **Docs: Date Input Demo** – Demo page showing Date vs ISO string defaults, shared styles via HeroHookFormProvider, and ZodForm with date defaults.
14
+
15
+ ### Fixed
16
+
17
+ - **Date input default value** – Default values for date fields now work when set via `config.defaultValues`; Date/string values are converted to `CalendarDate`.
18
+ - **Date input styling** – DateInput now receives `common` styling from ConfigProvider so it matches other inputs when using `HeroHookFormProvider`.
19
+ - **"Invalid granularity day" error** – DateField and ServerActionForm coerce Date/string to CalendarDate before passing to HeroUI DateInput, fixing the console error when defaultValues used raw `Date` or the server wasn’t restarted after package changes.
20
+ - **useZodForm config mutation** – Resolver is no longer assigned onto the caller’s config object; a new options object is built instead.
21
+ - **Lint** – Removed unused `shouldRenderConditionalField` (FormField), fixed unused catch binding and type params (fieldArrayMemory).
22
+
23
+ ## [2.9.1] - 2026-01-28
24
+
25
+ ### Fixed
26
+
27
+ - **Cypress Testing: fillInputByLabel clearing behavior**: Fixed issue where `fillInputByLabel` may not properly clear number inputs with default values
28
+ - Refactored to use a single chain ensuring clear operation completes before typing
29
+ - Ensures reliable clearing of all input types, especially number inputs with default values
30
+ - Clearing is now explicitly documented as the default behavior
31
+
5
32
  ## [2.9.0] - 2026-01-22
6
33
 
7
34
  ### Added
@@ -334,7 +334,7 @@ var init_utils = __esm({
334
334
  });
335
335
 
336
336
  // src/cypress/helpers.ts
337
- function fillInputByName(name, value, options = {}) {
337
+ function fillInputByName(name, value, options = { clear: true }) {
338
338
  return withRetry(() => {
339
339
  waitForFormReady();
340
340
  const element = cy.get(`input[name="${name}"], textarea[name="${name}"]`, { timeout: DEFAULT_CONFIG.timeout }).should("exist").should("be.visible");
@@ -347,7 +347,7 @@ function fillInputByName(name, value, options = {}) {
347
347
  });
348
348
  }, DEFAULT_CONFIG);
349
349
  }
350
- function fillInputByType(type, value, index = 0, options = {}) {
350
+ function fillInputByType(type, value, index = 0, options = { clear: true }) {
351
351
  const selector = type === "textarea" ? buildHeroUISelector("textarea") : buildHeroUISelector("input", type);
352
352
  const element = index > 0 ? cy.get(selector).eq(index) : cy.get(selector).first();
353
353
  return withRetry(() => {
@@ -357,7 +357,7 @@ function fillInputByType(type, value, index = 0, options = {}) {
357
357
  return element.type(value, { force: true });
358
358
  }, DEFAULT_CONFIG);
359
359
  }
360
- function fillInputByPlaceholder(placeholder, value, options = {}) {
360
+ function fillInputByPlaceholder(placeholder, value, options = { clear: true }) {
361
361
  const selector = `input[placeholder*="${placeholder}"], textarea[placeholder*="${placeholder}"]`;
362
362
  return withRetry(() => {
363
363
  const element = cy.get(selector);
@@ -367,17 +367,17 @@ function fillInputByPlaceholder(placeholder, value, options = {}) {
367
367
  return element.type(value, { force: true });
368
368
  }, DEFAULT_CONFIG);
369
369
  }
370
- function fillInputByLabel(label, value, options = {}) {
370
+ function fillInputByLabel(label, value, options = { clear: true }) {
371
371
  return withRetry(() => {
372
- return cy.contains("label", label).closest("div").find("input, textarea").first().then(($el) => {
373
- if (options.clear !== false) {
374
- cy.wrap($el).clear({ force: true });
375
- }
376
- return cy.wrap($el).type(value, { force: true });
377
- });
372
+ const element = cy.contains("label", label).closest("div").find("input, textarea").first();
373
+ const shouldClear = options.clear !== false;
374
+ if (shouldClear) {
375
+ element.clear({ force: true });
376
+ }
377
+ return element.type(value, { force: true });
378
378
  }, DEFAULT_CONFIG);
379
379
  }
380
- function fillTextareaByName(name, value, options = {}) {
380
+ function fillTextareaByName(name, value, options = { clear: true }) {
381
381
  return withRetry(() => {
382
382
  const element = cy.get(`textarea[name="${name}"]`);
383
383
  if (options.clear !== false) {
@@ -386,7 +386,7 @@ function fillTextareaByName(name, value, options = {}) {
386
386
  return element.type(value, { force: true });
387
387
  }, DEFAULT_CONFIG);
388
388
  }
389
- function fillTextarea(value, index = 0, options = {}) {
389
+ function fillTextarea(value, index = 0, options = { clear: true }) {
390
390
  const selector = HERO_UI_SELECTORS.textarea;
391
391
  return withRetry(() => {
392
392
  const element = index > 0 ? cy.get(selector).eq(index) : cy.get(selector).first();
package/dist/index.d.ts CHANGED
@@ -1773,7 +1773,8 @@ type TextareaDefaults = Partial<Omit<TextareaProps, "value" | "onValueChange" |
1773
1773
  type CheckboxDefaults = Partial<Omit<React$1.ComponentProps<typeof Checkbox>, "isSelected" | "onValueChange" | "isInvalid" | "errorMessage" | "isDisabled">>;
1774
1774
  type RadioGroupDefaults = Partial<Omit<React$1.ComponentProps<typeof RadioGroup>, "value" | "onValueChange" | "label">>;
1775
1775
  type SelectDefaults = Partial<Omit<SelectProps, "selectedKeys" | "onSelectionChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">>;
1776
- type DateInputDefaults = Partial<Omit<React$1.ComponentProps<typeof DateInput>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">>;
1776
+ type DateInputProps = React$1.ComponentProps<typeof DateInput>;
1777
+ type DateInputDefaults = Partial<Omit<DateInputProps, "value" | "onChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">>;
1777
1778
  type SliderDefaults = Partial<Omit<React$1.ComponentProps<typeof Slider>, "value" | "onValueChange" | "label" | "isInvalid" | "errorMessage" | "isDisabled">>;
1778
1779
  type SwitchDefaults = Partial<Omit<React$1.ComponentProps<typeof Switch>, "isSelected" | "onValueChange" | "isInvalid" | "isDisabled">>;
1779
1780
  type ButtonDefaults = Partial<Omit<React$1.ComponentProps<typeof Button$1>, "type" | "isLoading">>;
@@ -2692,11 +2693,10 @@ declare const FormFieldHelpers: {
2692
2693
  * // Simple date field
2693
2694
  * FormFieldHelpers.date("birthDate", "Birth Date")
2694
2695
  *
2695
- * // With full customization
2696
+ * // With DateInput props (set default via config.defaultValues)
2696
2697
  * FormFieldHelpers.date("birthDate", "Birth Date", {
2697
- * label: "Select your birth date",
2698
2698
  * granularity: "day",
2699
- * minValue: new CalendarDate(1900, 1, 1)
2699
+ * minValue: new CalendarDate(1900, 1, 1),
2700
2700
  * })
2701
2701
  * ```
2702
2702
  */
@@ -4215,7 +4215,7 @@ declare const memorySafeFieldArray: {
4215
4215
  /**
4216
4216
  * Add items to a field array with memory management.
4217
4217
  */
4218
- addItems: <TFieldValues extends FieldValues>(append: (value: any) => void, items: any[], onProgress?: (addedCount: number) => void) => void;
4218
+ addItems: (append: (value: any) => void, items: any[], onProgress?: (addedCount: number) => void) => void;
4219
4219
  /**
4220
4220
  * Clear entire field array with memory cleanup.
4221
4221
  */
@@ -4223,7 +4223,7 @@ declare const memorySafeFieldArray: {
4223
4223
  /**
4224
4224
  * Remove items from a field array with memory cleanup.
4225
4225
  */
4226
- removeItems: <TFieldValues extends FieldValues>(remove: (index: number) => void, indices: number[]) => void;
4226
+ removeItems: (remove: (index: number) => void, indices: number[]) => void;
4227
4227
  };
4228
4228
 
4229
4229
  /**
package/dist/index.js CHANGED
@@ -253,15 +253,49 @@ function extractSelectCommon(common) {
253
253
  }
254
254
  return result;
255
255
  }
256
+ function extractDateInputCommon(common) {
257
+ const result = {};
258
+ if (common.color !== void 0) {
259
+ const color = common.color;
260
+ result.color = color;
261
+ }
262
+ if (common.size !== void 0) {
263
+ const size = common.size;
264
+ result.size = size;
265
+ }
266
+ if (common.variant !== void 0) {
267
+ const variant = common.variant;
268
+ result.variant = variant;
269
+ }
270
+ if (common.radius !== void 0) {
271
+ const radius = common.radius;
272
+ result.radius = radius;
273
+ }
274
+ if (common.labelPlacement !== void 0) {
275
+ const labelPlacement = common.labelPlacement;
276
+ result.labelPlacement = labelPlacement;
277
+ }
278
+ return result;
279
+ }
256
280
  function useHeroHookFormDefaults() {
257
281
  const cfg = useContext(DefaultsContext) ?? {};
258
282
  const common = cfg.common ?? {};
259
283
  const commonInput = extractInputCommon(common);
260
284
  const commonTextarea = extractTextareaCommon(common);
261
285
  const commonSelect = extractSelectCommon(common);
286
+ const commonDateInput = extractDateInputCommon(common);
287
+ const dateInputBase = {
288
+ radius: "md",
289
+ size: "md",
290
+ variant: "bordered"
291
+ };
262
292
  return {
263
293
  checkbox: cfg.checkbox ?? {},
264
- dateInput: cfg.dateInput ?? {},
294
+ dateInput: {
295
+ ...dateInputBase,
296
+ ...commonDateInput,
297
+ ...cfg.dateInput ?? {}
298
+ },
265
299
  input: { ...commonInput, ...cfg.input ?? {} },
266
300
  radioGroup: cfg.radioGroup ?? {},
267
301
  select: { ...commonSelect, ...cfg.select ?? {} },
@@ -446,9 +480,687 @@ function ContentField({
446
480
  // src/fields/DateField.tsx
447
481
  import React7 from "react";
448
482
  import { Controller as Controller4 } from "react-hook-form";
483
+
484
+ // node_modules/@internationalized/date/dist/utils.mjs
485
+ function $2b4dce13dd5a17fa$export$842a2cf37af977e1(amount, numerator) {
486
+ return amount - numerator * Math.floor(amount / numerator);
487
+ }
488
+
489
+ // node_modules/@internationalized/date/dist/GregorianCalendar.mjs
490
+ var $3b62074eb05584b2$var$EPOCH = 1721426;
491
+ function $3b62074eb05584b2$export$f297eb839006d339(era, year, month, day) {
492
+ year = $3b62074eb05584b2$export$c36e0ecb2d4fa69d(era, year);
493
+ let y1 = year - 1;
494
+ let monthOffset = -2;
495
+ if (month <= 2) monthOffset = 0;
496
+ else if ($3b62074eb05584b2$export$553d7fa8e3805fc0(year)) monthOffset = -1;
497
+ return $3b62074eb05584b2$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day);
498
+ }
499
+ function $3b62074eb05584b2$export$553d7fa8e3805fc0(year) {
500
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
501
+ }
502
+ function $3b62074eb05584b2$export$c36e0ecb2d4fa69d(era, year) {
503
+ return era === "BC" ? 1 - year : year;
504
+ }
505
+ function $3b62074eb05584b2$export$4475b7e617eb123c(year) {
506
+ let era = "AD";
507
+ if (year <= 0) {
508
+ era = "BC";
509
+ year = 1 - year;
510
+ }
511
+ return [
512
+ era,
513
+ year
514
+ ];
515
+ }
516
+ var $3b62074eb05584b2$var$daysInMonth = {
517
+ standard: [
518
+ 31,
519
+ 28,
520
+ 31,
521
+ 30,
522
+ 31,
523
+ 30,
524
+ 31,
525
+ 31,
526
+ 30,
527
+ 31,
528
+ 30,
529
+ 31
530
+ ],
531
+ leapyear: [
532
+ 31,
533
+ 29,
534
+ 31,
535
+ 30,
536
+ 31,
537
+ 30,
538
+ 31,
539
+ 31,
540
+ 30,
541
+ 31,
542
+ 30,
543
+ 31
544
+ ]
545
+ };
546
+ var $3b62074eb05584b2$export$80ee6245ec4f29ec = class {
547
+ fromJulianDay(jd) {
548
+ let jd0 = jd;
549
+ let depoch = jd0 - $3b62074eb05584b2$var$EPOCH;
550
+ let quadricent = Math.floor(depoch / 146097);
551
+ let dqc = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(depoch, 146097);
552
+ let cent = Math.floor(dqc / 36524);
553
+ let dcent = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(dqc, 36524);
554
+ let quad = Math.floor(dcent / 1461);
555
+ let dquad = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(dcent, 1461);
556
+ let yindex = Math.floor(dquad / 365);
557
+ let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
558
+ let [era, year] = $3b62074eb05584b2$export$4475b7e617eb123c(extendedYear);
559
+ let yearDay = jd0 - $3b62074eb05584b2$export$f297eb839006d339(era, year, 1, 1);
560
+ let leapAdj = 2;
561
+ if (jd0 < $3b62074eb05584b2$export$f297eb839006d339(era, year, 3, 1)) leapAdj = 0;
562
+ else if ($3b62074eb05584b2$export$553d7fa8e3805fc0(year)) leapAdj = 1;
563
+ let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);
564
+ let day = jd0 - $3b62074eb05584b2$export$f297eb839006d339(era, year, month, 1) + 1;
565
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(era, year, month, day);
566
+ }
567
+ toJulianDay(date) {
568
+ return $3b62074eb05584b2$export$f297eb839006d339(date.era, date.year, date.month, date.day);
569
+ }
570
+ getDaysInMonth(date) {
571
+ return $3b62074eb05584b2$var$daysInMonth[$3b62074eb05584b2$export$553d7fa8e3805fc0(date.year) ? "leapyear" : "standard"][date.month - 1];
572
+ }
573
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
574
+ getMonthsInYear(date) {
575
+ return 12;
576
+ }
577
+ getDaysInYear(date) {
578
+ return $3b62074eb05584b2$export$553d7fa8e3805fc0(date.year) ? 366 : 365;
579
+ }
580
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
581
+ getYearsInEra(date) {
582
+ return 9999;
583
+ }
584
+ getEras() {
585
+ return [
586
+ "BC",
587
+ "AD"
588
+ ];
589
+ }
590
+ isInverseEra(date) {
591
+ return date.era === "BC";
592
+ }
593
+ balanceDate(date) {
594
+ if (date.year <= 0) {
595
+ date.era = date.era === "BC" ? "AD" : "BC";
596
+ date.year = 1 - date.year;
597
+ }
598
+ }
599
+ constructor() {
600
+ this.identifier = "gregory";
601
+ }
602
+ };
603
+
604
+ // node_modules/@internationalized/date/dist/queries.mjs
605
+ function $14e0f24ef4ac5c92$export$dbc69fd56b53d5e(a, b) {
606
+ var _a_isEqual, _b_isEqual;
607
+ var _a_isEqual1, _ref;
608
+ return (_ref = (_a_isEqual1 = (_a_isEqual = a.isEqual) === null || _a_isEqual === void 0 ? void 0 : _a_isEqual.call(a, b)) !== null && _a_isEqual1 !== void 0 ? _a_isEqual1 : (_b_isEqual = b.isEqual) === null || _b_isEqual === void 0 ? void 0 : _b_isEqual.call(b, a)) !== null && _ref !== void 0 ? _ref : a.identifier === b.identifier;
609
+ }
610
+ function $14e0f24ef4ac5c92$export$68781ddf31c0090f(a, b) {
611
+ return a.calendar.toJulianDay(a) - b.calendar.toJulianDay(b);
612
+ }
613
+ function $14e0f24ef4ac5c92$export$c19a80a9721b80f6(a, b) {
614
+ return $14e0f24ef4ac5c92$var$timeToMs(a) - $14e0f24ef4ac5c92$var$timeToMs(b);
615
+ }
616
+ function $14e0f24ef4ac5c92$var$timeToMs(a) {
617
+ return a.hour * 36e5 + a.minute * 6e4 + a.second * 1e3 + a.millisecond;
618
+ }
619
+ var $14e0f24ef4ac5c92$var$localTimeZone = null;
620
+ function $14e0f24ef4ac5c92$export$aa8b41735afcabd2() {
621
+ if ($14e0f24ef4ac5c92$var$localTimeZone == null) $14e0f24ef4ac5c92$var$localTimeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
622
+ return $14e0f24ef4ac5c92$var$localTimeZone;
623
+ }
624
+
625
+ // node_modules/@internationalized/date/dist/conversion.mjs
626
+ function $11d87f3f76e88657$export$bd4fb2bc8bb06fb(date) {
627
+ date = $11d87f3f76e88657$export$b4a036af3fc0b032(date, new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
628
+ let year = (0, $3b62074eb05584b2$export$c36e0ecb2d4fa69d)(date.era, date.year);
629
+ return $11d87f3f76e88657$var$epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
630
+ }
631
+ function $11d87f3f76e88657$var$epochFromParts(year, month, day, hour, minute, second, millisecond) {
632
+ let date = /* @__PURE__ */ new Date();
633
+ date.setUTCHours(hour, minute, second, millisecond);
634
+ date.setUTCFullYear(year, month - 1, day);
635
+ return date.getTime();
636
+ }
637
+ function $11d87f3f76e88657$export$59c99f3515d3493f(ms, timeZone) {
638
+ if (timeZone === "UTC") return 0;
639
+ if (ms > 0 && timeZone === (0, $14e0f24ef4ac5c92$export$aa8b41735afcabd2)()) return new Date(ms).getTimezoneOffset() * -6e4;
640
+ let { year, month, day, hour, minute, second } = $11d87f3f76e88657$var$getTimeZoneParts(ms, timeZone);
641
+ let utc = $11d87f3f76e88657$var$epochFromParts(year, month, day, hour, minute, second, 0);
642
+ return utc - Math.floor(ms / 1e3) * 1e3;
643
+ }
644
+ var $11d87f3f76e88657$var$formattersByTimeZone = /* @__PURE__ */ new Map();
645
+ function $11d87f3f76e88657$var$getTimeZoneParts(ms, timeZone) {
646
+ let formatter = $11d87f3f76e88657$var$formattersByTimeZone.get(timeZone);
647
+ if (!formatter) {
648
+ formatter = new Intl.DateTimeFormat("en-US", {
649
+ timeZone,
650
+ hour12: false,
651
+ era: "short",
652
+ year: "numeric",
653
+ month: "numeric",
654
+ day: "numeric",
655
+ hour: "numeric",
656
+ minute: "numeric",
657
+ second: "numeric"
658
+ });
659
+ $11d87f3f76e88657$var$formattersByTimeZone.set(timeZone, formatter);
660
+ }
661
+ let parts = formatter.formatToParts(new Date(ms));
662
+ let namedParts = {};
663
+ for (let part of parts) if (part.type !== "literal") namedParts[part.type] = part.value;
664
+ return {
665
+ // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
666
+ year: namedParts.era === "BC" || namedParts.era === "B" ? -namedParts.year + 1 : +namedParts.year,
667
+ month: +namedParts.month,
668
+ day: +namedParts.day,
669
+ hour: namedParts.hour === "24" ? 0 : +namedParts.hour,
670
+ minute: +namedParts.minute,
671
+ second: +namedParts.second
672
+ };
673
+ }
674
+ var $11d87f3f76e88657$var$DAYMILLIS = 864e5;
675
+ function $11d87f3f76e88657$var$getValidWallTimes(date, timeZone, earlier, later) {
676
+ let found = earlier === later ? [
677
+ earlier
678
+ ] : [
679
+ earlier,
680
+ later
681
+ ];
682
+ return found.filter((absolute) => $11d87f3f76e88657$var$isValidWallTime(date, timeZone, absolute));
683
+ }
684
+ function $11d87f3f76e88657$var$isValidWallTime(date, timeZone, absolute) {
685
+ let parts = $11d87f3f76e88657$var$getTimeZoneParts(absolute, timeZone);
686
+ return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second;
687
+ }
688
+ function $11d87f3f76e88657$export$5107c82f94518f5c(date, timeZone, disambiguation = "compatible") {
689
+ let dateTime = $11d87f3f76e88657$export$b21e0b124e224484(date);
690
+ if (timeZone === "UTC") return $11d87f3f76e88657$export$bd4fb2bc8bb06fb(dateTime);
691
+ if (timeZone === (0, $14e0f24ef4ac5c92$export$aa8b41735afcabd2)() && disambiguation === "compatible") {
692
+ dateTime = $11d87f3f76e88657$export$b4a036af3fc0b032(dateTime, new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
693
+ let date2 = /* @__PURE__ */ new Date();
694
+ let year = (0, $3b62074eb05584b2$export$c36e0ecb2d4fa69d)(dateTime.era, dateTime.year);
695
+ date2.setFullYear(year, dateTime.month - 1, dateTime.day);
696
+ date2.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
697
+ return date2.getTime();
698
+ }
699
+ let ms = $11d87f3f76e88657$export$bd4fb2bc8bb06fb(dateTime);
700
+ let offsetBefore = $11d87f3f76e88657$export$59c99f3515d3493f(ms - $11d87f3f76e88657$var$DAYMILLIS, timeZone);
701
+ let offsetAfter = $11d87f3f76e88657$export$59c99f3515d3493f(ms + $11d87f3f76e88657$var$DAYMILLIS, timeZone);
702
+ let valid = $11d87f3f76e88657$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);
703
+ if (valid.length === 1) return valid[0];
704
+ if (valid.length > 1) switch (disambiguation) {
705
+ // 'compatible' means 'earlier' for "fall back" transitions
706
+ case "compatible":
707
+ case "earlier":
708
+ return valid[0];
709
+ case "later":
710
+ return valid[valid.length - 1];
711
+ case "reject":
712
+ throw new RangeError("Multiple possible absolute times found");
713
+ }
714
+ switch (disambiguation) {
715
+ case "earlier":
716
+ return Math.min(ms - offsetBefore, ms - offsetAfter);
717
+ // 'compatible' means 'later' for "spring forward" transitions
718
+ case "compatible":
719
+ case "later":
720
+ return Math.max(ms - offsetBefore, ms - offsetAfter);
721
+ case "reject":
722
+ throw new RangeError("No such absolute time found");
723
+ }
724
+ }
725
+ function $11d87f3f76e88657$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = "compatible") {
726
+ return new Date($11d87f3f76e88657$export$5107c82f94518f5c(dateTime, timeZone, disambiguation));
727
+ }
728
+ function $11d87f3f76e88657$export$b21e0b124e224484(date, time) {
729
+ let hour = 0, minute = 0, second = 0, millisecond = 0;
730
+ if ("timeZone" in date) ({ hour, minute, second, millisecond } = date);
731
+ else if ("hour" in date && !time) return date;
732
+ if (time) ({ hour, minute, second, millisecond } = time);
733
+ return new (0, $35ea8db9cb2ccb90$export$ca871e8dbb80966f)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond);
734
+ }
735
+ function $11d87f3f76e88657$export$b4a036af3fc0b032(date, calendar) {
736
+ if ((0, $14e0f24ef4ac5c92$export$dbc69fd56b53d5e)(date.calendar, calendar)) return date;
737
+ let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
738
+ let copy = date.copy();
739
+ copy.calendar = calendar;
740
+ copy.era = calendarDate.era;
741
+ copy.year = calendarDate.year;
742
+ copy.month = calendarDate.month;
743
+ copy.day = calendarDate.day;
744
+ (0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(copy);
745
+ return copy;
746
+ }
747
+
748
+ // node_modules/@internationalized/date/dist/manipulation.mjs
749
+ function $735220c2d4774dd3$export$e16d8520af44a096(date, duration) {
750
+ let mutableDate = date.copy();
751
+ let days = "hour" in mutableDate ? $735220c2d4774dd3$var$addTimeFields(mutableDate, duration) : 0;
752
+ $735220c2d4774dd3$var$addYears(mutableDate, duration.years || 0);
753
+ if (mutableDate.calendar.balanceYearMonth) mutableDate.calendar.balanceYearMonth(mutableDate, date);
754
+ mutableDate.month += duration.months || 0;
755
+ $735220c2d4774dd3$var$balanceYearMonth(mutableDate);
756
+ $735220c2d4774dd3$var$constrainMonthDay(mutableDate);
757
+ mutableDate.day += (duration.weeks || 0) * 7;
758
+ mutableDate.day += duration.days || 0;
759
+ mutableDate.day += days;
760
+ $735220c2d4774dd3$var$balanceDay(mutableDate);
761
+ if (mutableDate.calendar.balanceDate) mutableDate.calendar.balanceDate(mutableDate);
762
+ if (mutableDate.year < 1) {
763
+ mutableDate.year = 1;
764
+ mutableDate.month = 1;
765
+ mutableDate.day = 1;
766
+ }
767
+ let maxYear = mutableDate.calendar.getYearsInEra(mutableDate);
768
+ if (mutableDate.year > maxYear) {
769
+ var _mutableDate_calendar_isInverseEra, _mutableDate_calendar;
770
+ let isInverseEra = (_mutableDate_calendar_isInverseEra = (_mutableDate_calendar = mutableDate.calendar).isInverseEra) === null || _mutableDate_calendar_isInverseEra === void 0 ? void 0 : _mutableDate_calendar_isInverseEra.call(_mutableDate_calendar, mutableDate);
771
+ mutableDate.year = maxYear;
772
+ mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate);
773
+ mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate);
774
+ }
775
+ if (mutableDate.month < 1) {
776
+ mutableDate.month = 1;
777
+ mutableDate.day = 1;
778
+ }
779
+ let maxMonth = mutableDate.calendar.getMonthsInYear(mutableDate);
780
+ if (mutableDate.month > maxMonth) {
781
+ mutableDate.month = maxMonth;
782
+ mutableDate.day = mutableDate.calendar.getDaysInMonth(mutableDate);
783
+ }
784
+ mutableDate.day = Math.max(1, Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day));
785
+ return mutableDate;
786
+ }
787
+ function $735220c2d4774dd3$var$addYears(date, years) {
788
+ var _date_calendar_isInverseEra, _date_calendar;
789
+ if ((_date_calendar_isInverseEra = (_date_calendar = date.calendar).isInverseEra) === null || _date_calendar_isInverseEra === void 0 ? void 0 : _date_calendar_isInverseEra.call(_date_calendar, date)) years = -years;
790
+ date.year += years;
791
+ }
792
+ function $735220c2d4774dd3$var$balanceYearMonth(date) {
793
+ while (date.month < 1) {
794
+ $735220c2d4774dd3$var$addYears(date, -1);
795
+ date.month += date.calendar.getMonthsInYear(date);
796
+ }
797
+ let monthsInYear = 0;
798
+ while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {
799
+ date.month -= monthsInYear;
800
+ $735220c2d4774dd3$var$addYears(date, 1);
801
+ }
802
+ }
803
+ function $735220c2d4774dd3$var$balanceDay(date) {
804
+ while (date.day < 1) {
805
+ date.month--;
806
+ $735220c2d4774dd3$var$balanceYearMonth(date);
807
+ date.day += date.calendar.getDaysInMonth(date);
808
+ }
809
+ while (date.day > date.calendar.getDaysInMonth(date)) {
810
+ date.day -= date.calendar.getDaysInMonth(date);
811
+ date.month++;
812
+ $735220c2d4774dd3$var$balanceYearMonth(date);
813
+ }
814
+ }
815
+ function $735220c2d4774dd3$var$constrainMonthDay(date) {
816
+ date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
817
+ date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
818
+ }
819
+ function $735220c2d4774dd3$export$c4e2ecac49351ef2(date) {
820
+ if (date.calendar.constrainDate) date.calendar.constrainDate(date);
821
+ date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));
822
+ $735220c2d4774dd3$var$constrainMonthDay(date);
823
+ }
824
+ function $735220c2d4774dd3$export$3e2544e88a25bff8(duration) {
825
+ let inverseDuration = {};
826
+ for (let key in duration) if (typeof duration[key] === "number") inverseDuration[key] = -duration[key];
827
+ return inverseDuration;
828
+ }
829
+ function $735220c2d4774dd3$export$4e2d2ead65e5f7e3(date, duration) {
830
+ return $735220c2d4774dd3$export$e16d8520af44a096(date, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
831
+ }
832
+ function $735220c2d4774dd3$export$adaa4cf7ef1b65be(date, fields) {
833
+ let mutableDate = date.copy();
834
+ if (fields.era != null) mutableDate.era = fields.era;
835
+ if (fields.year != null) mutableDate.year = fields.year;
836
+ if (fields.month != null) mutableDate.month = fields.month;
837
+ if (fields.day != null) mutableDate.day = fields.day;
838
+ $735220c2d4774dd3$export$c4e2ecac49351ef2(mutableDate);
839
+ return mutableDate;
840
+ }
841
+ function $735220c2d4774dd3$export$e5d5e1c1822b6e56(value, fields) {
842
+ let mutableValue = value.copy();
843
+ if (fields.hour != null) mutableValue.hour = fields.hour;
844
+ if (fields.minute != null) mutableValue.minute = fields.minute;
845
+ if (fields.second != null) mutableValue.second = fields.second;
846
+ if (fields.millisecond != null) mutableValue.millisecond = fields.millisecond;
847
+ $735220c2d4774dd3$export$7555de1e070510cb(mutableValue);
848
+ return mutableValue;
849
+ }
850
+ function $735220c2d4774dd3$var$balanceTime(time) {
851
+ time.second += Math.floor(time.millisecond / 1e3);
852
+ time.millisecond = $735220c2d4774dd3$var$nonNegativeMod(time.millisecond, 1e3);
853
+ time.minute += Math.floor(time.second / 60);
854
+ time.second = $735220c2d4774dd3$var$nonNegativeMod(time.second, 60);
855
+ time.hour += Math.floor(time.minute / 60);
856
+ time.minute = $735220c2d4774dd3$var$nonNegativeMod(time.minute, 60);
857
+ let days = Math.floor(time.hour / 24);
858
+ time.hour = $735220c2d4774dd3$var$nonNegativeMod(time.hour, 24);
859
+ return days;
860
+ }
861
+ function $735220c2d4774dd3$export$7555de1e070510cb(time) {
862
+ time.millisecond = Math.max(0, Math.min(time.millisecond, 1e3));
863
+ time.second = Math.max(0, Math.min(time.second, 59));
864
+ time.minute = Math.max(0, Math.min(time.minute, 59));
865
+ time.hour = Math.max(0, Math.min(time.hour, 23));
866
+ }
867
+ function $735220c2d4774dd3$var$nonNegativeMod(a, b) {
868
+ let result = a % b;
869
+ if (result < 0) result += b;
870
+ return result;
871
+ }
872
+ function $735220c2d4774dd3$var$addTimeFields(time, duration) {
873
+ time.hour += duration.hours || 0;
874
+ time.minute += duration.minutes || 0;
875
+ time.second += duration.seconds || 0;
876
+ time.millisecond += duration.milliseconds || 0;
877
+ return $735220c2d4774dd3$var$balanceTime(time);
878
+ }
879
+ function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field2, amount, options) {
880
+ let mutable = value.copy();
881
+ switch (field2) {
882
+ case "era": {
883
+ let eras = value.calendar.getEras();
884
+ let eraIndex = eras.indexOf(value.era);
885
+ if (eraIndex < 0) throw new Error("Invalid era: " + value.era);
886
+ eraIndex = $735220c2d4774dd3$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options === null || options === void 0 ? void 0 : options.round);
887
+ mutable.era = eras[eraIndex];
888
+ $735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
889
+ break;
890
+ }
891
+ case "year":
892
+ var _mutable_calendar_isInverseEra, _mutable_calendar;
893
+ if ((_mutable_calendar_isInverseEra = (_mutable_calendar = mutable.calendar).isInverseEra) === null || _mutable_calendar_isInverseEra === void 0 ? void 0 : _mutable_calendar_isInverseEra.call(_mutable_calendar, mutable)) amount = -amount;
894
+ mutable.year = $735220c2d4774dd3$var$cycleValue(value.year, amount, -Infinity, 9999, options === null || options === void 0 ? void 0 : options.round);
895
+ if (mutable.year === -Infinity) mutable.year = 1;
896
+ if (mutable.calendar.balanceYearMonth) mutable.calendar.balanceYearMonth(mutable, value);
897
+ break;
898
+ case "month":
899
+ mutable.month = $735220c2d4774dd3$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options === null || options === void 0 ? void 0 : options.round);
900
+ break;
901
+ case "day":
902
+ mutable.day = $735220c2d4774dd3$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options === null || options === void 0 ? void 0 : options.round);
903
+ break;
904
+ default:
905
+ throw new Error("Unsupported field " + field2);
906
+ }
907
+ if (value.calendar.balanceDate) value.calendar.balanceDate(mutable);
908
+ $735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
909
+ return mutable;
910
+ }
911
+ function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field2, amount, options) {
912
+ let mutable = value.copy();
913
+ switch (field2) {
914
+ case "hour": {
915
+ let hours = value.hour;
916
+ let min = 0;
917
+ let max = 23;
918
+ if ((options === null || options === void 0 ? void 0 : options.hourCycle) === 12) {
919
+ let isPM = hours >= 12;
920
+ min = isPM ? 12 : 0;
921
+ max = isPM ? 23 : 11;
922
+ }
923
+ mutable.hour = $735220c2d4774dd3$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
924
+ break;
925
+ }
926
+ case "minute":
927
+ mutable.minute = $735220c2d4774dd3$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
928
+ break;
929
+ case "second":
930
+ mutable.second = $735220c2d4774dd3$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
931
+ break;
932
+ case "millisecond":
933
+ mutable.millisecond = $735220c2d4774dd3$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
934
+ break;
935
+ default:
936
+ throw new Error("Unsupported field " + field2);
937
+ }
938
+ return mutable;
939
+ }
940
+ function $735220c2d4774dd3$var$cycleValue(value, amount, min, max, round = false) {
941
+ if (round) {
942
+ value += Math.sign(amount);
943
+ if (value < min) value = max;
944
+ let div = Math.abs(amount);
945
+ if (amount > 0) value = Math.ceil(value / div) * div;
946
+ else value = Math.floor(value / div) * div;
947
+ if (value > max) value = min;
948
+ } else {
949
+ value += amount;
950
+ if (value < min) value = max - (min - value - 1);
951
+ else if (value > max) value = min + (value - max - 1);
952
+ }
953
+ return value;
954
+ }
955
+
956
+ // node_modules/@internationalized/date/dist/string.mjs
957
+ var $fae977aafc393c5c$var$requiredDurationTimeGroups = [
958
+ "hours",
959
+ "minutes",
960
+ "seconds"
961
+ ];
962
+ var $fae977aafc393c5c$var$requiredDurationGroups = [
963
+ "years",
964
+ "months",
965
+ "weeks",
966
+ "days",
967
+ ...$fae977aafc393c5c$var$requiredDurationTimeGroups
968
+ ];
969
+ function $fae977aafc393c5c$export$f59dee82248f5ad4(time) {
970
+ return `${String(time.hour).padStart(2, "0")}:${String(time.minute).padStart(2, "0")}:${String(time.second).padStart(2, "0")}${time.millisecond ? String(time.millisecond / 1e3).slice(1) : ""}`;
971
+ }
972
+ function $fae977aafc393c5c$export$60dfd74aa96791bd(date) {
973
+ let gregorianDate = (0, $11d87f3f76e88657$export$b4a036af3fc0b032)(date, new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
974
+ let year;
975
+ if (gregorianDate.era === "BC") year = gregorianDate.year === 1 ? "0000" : "-" + String(Math.abs(1 - gregorianDate.year)).padStart(6, "00");
976
+ else year = String(gregorianDate.year).padStart(4, "0");
977
+ return `${year}-${String(gregorianDate.month).padStart(2, "0")}-${String(gregorianDate.day).padStart(2, "0")}`;
978
+ }
979
+ function $fae977aafc393c5c$export$4223de14708adc63(date) {
980
+ return `${$fae977aafc393c5c$export$60dfd74aa96791bd(date)}T${$fae977aafc393c5c$export$f59dee82248f5ad4(date)}`;
981
+ }
982
+
983
+ // node_modules/@swc/helpers/esm/_check_private_redeclaration.js
984
+ function _check_private_redeclaration(obj, privateCollection) {
985
+ if (privateCollection.has(obj)) {
986
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
987
+ }
988
+ }
989
+
990
+ // node_modules/@swc/helpers/esm/_class_private_field_init.js
991
+ function _class_private_field_init(obj, privateMap, value) {
992
+ _check_private_redeclaration(obj, privateMap);
993
+ privateMap.set(obj, value);
994
+ }
995
+
996
+ // node_modules/@internationalized/date/dist/CalendarDate.mjs
997
+ function $35ea8db9cb2ccb90$var$shiftArgs(args) {
998
+ let calendar = typeof args[0] === "object" ? args.shift() : new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
999
+ let era;
1000
+ if (typeof args[0] === "string") era = args.shift();
1001
+ else {
1002
+ let eras = calendar.getEras();
1003
+ era = eras[eras.length - 1];
1004
+ }
1005
+ let year = args.shift();
1006
+ let month = args.shift();
1007
+ let day = args.shift();
1008
+ return [
1009
+ calendar,
1010
+ era,
1011
+ year,
1012
+ month,
1013
+ day
1014
+ ];
1015
+ }
1016
+ var $35ea8db9cb2ccb90$var$_type = /* @__PURE__ */ new WeakMap();
1017
+ var $35ea8db9cb2ccb90$export$99faa760c7908e4f = class _$35ea8db9cb2ccb90$export$99faa760c7908e4f {
1018
+ /** Returns a copy of this date. */
1019
+ copy() {
1020
+ if (this.era) return new _$35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day);
1021
+ else return new _$35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day);
1022
+ }
1023
+ /** Returns a new `CalendarDate` with the given duration added to it. */
1024
+ add(duration) {
1025
+ return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
1026
+ }
1027
+ /** Returns a new `CalendarDate` with the given duration subtracted from it. */
1028
+ subtract(duration) {
1029
+ return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
1030
+ }
1031
+ /** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
1032
+ set(fields) {
1033
+ return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)(this, fields);
1034
+ }
1035
+ /**
1036
+ * Returns a new `CalendarDate` with the given field adjusted by a specified amount.
1037
+ * When the resulting value reaches the limits of the field, it wraps around.
1038
+ */
1039
+ cycle(field2, amount, options) {
1040
+ return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field2, amount, options);
1041
+ }
1042
+ /** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
1043
+ toDate(timeZone) {
1044
+ return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone);
1045
+ }
1046
+ /** Converts the date to an ISO 8601 formatted string. */
1047
+ toString() {
1048
+ return (0, $fae977aafc393c5c$export$60dfd74aa96791bd)(this);
1049
+ }
1050
+ /** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
1051
+ compare(b) {
1052
+ return (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
1053
+ }
1054
+ constructor(...args) {
1055
+ (0, _class_private_field_init)(this, $35ea8db9cb2ccb90$var$_type, {
1056
+ writable: true,
1057
+ value: void 0
1058
+ });
1059
+ let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
1060
+ this.calendar = calendar;
1061
+ this.era = era;
1062
+ this.year = year;
1063
+ this.month = month;
1064
+ this.day = day;
1065
+ (0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
1066
+ }
1067
+ };
1068
+ var $35ea8db9cb2ccb90$var$_type2 = /* @__PURE__ */ new WeakMap();
1069
+ var $35ea8db9cb2ccb90$export$ca871e8dbb80966f = class _$35ea8db9cb2ccb90$export$ca871e8dbb80966f {
1070
+ /** Returns a copy of this date. */
1071
+ copy() {
1072
+ if (this.era) return new _$35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
1073
+ else return new _$35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
1074
+ }
1075
+ /** Returns a new `CalendarDateTime` with the given duration added to it. */
1076
+ add(duration) {
1077
+ return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
1078
+ }
1079
+ /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */
1080
+ subtract(duration) {
1081
+ return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
1082
+ }
1083
+ /** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
1084
+ set(fields) {
1085
+ return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)((0, $735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields), fields);
1086
+ }
1087
+ /**
1088
+ * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
1089
+ * When the resulting value reaches the limits of the field, it wraps around.
1090
+ */
1091
+ cycle(field2, amount, options) {
1092
+ switch (field2) {
1093
+ case "era":
1094
+ case "year":
1095
+ case "month":
1096
+ case "day":
1097
+ return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field2, amount, options);
1098
+ default:
1099
+ return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field2, amount, options);
1100
+ }
1101
+ }
1102
+ /** Converts the date to a native JavaScript Date object in the given time zone. */
1103
+ toDate(timeZone, disambiguation) {
1104
+ return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone, disambiguation);
1105
+ }
1106
+ /** Converts the date to an ISO 8601 formatted string. */
1107
+ toString() {
1108
+ return (0, $fae977aafc393c5c$export$4223de14708adc63)(this);
1109
+ }
1110
+ /** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
1111
+ compare(b) {
1112
+ let res = (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
1113
+ if (res === 0) return (0, $14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, (0, $11d87f3f76e88657$export$b21e0b124e224484)(b));
1114
+ return res;
1115
+ }
1116
+ constructor(...args) {
1117
+ (0, _class_private_field_init)(this, $35ea8db9cb2ccb90$var$_type2, {
1118
+ writable: true,
1119
+ value: void 0
1120
+ });
1121
+ let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
1122
+ this.calendar = calendar;
1123
+ this.era = era;
1124
+ this.year = year;
1125
+ this.month = month;
1126
+ this.day = day;
1127
+ this.hour = args.shift() || 0;
1128
+ this.minute = args.shift() || 0;
1129
+ this.second = args.shift() || 0;
1130
+ this.millisecond = args.shift() || 0;
1131
+ (0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
1132
+ }
1133
+ };
1134
+
1135
+ // src/utils/dateCoercion.ts
1136
+ function toCalendarDateValue(value) {
1137
+ if (value === null || value === void 0) {
1138
+ return null;
1139
+ }
1140
+ if (typeof value === "object" && "year" in value && "month" in value && "day" in value && typeof value.year === "number") {
1141
+ return value;
1142
+ }
1143
+ if (value instanceof Date) {
1144
+ return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(
1145
+ value.getFullYear(),
1146
+ value.getMonth() + 1,
1147
+ value.getDate()
1148
+ );
1149
+ }
1150
+ if (typeof value === "string") {
1151
+ const d = new Date(value);
1152
+ if (!isNaN(d.getTime())) {
1153
+ return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(d.getFullYear(), d.getMonth() + 1, d.getDate());
1154
+ }
1155
+ }
1156
+ return null;
1157
+ }
1158
+
1159
+ // src/fields/DateField.tsx
449
1160
  function CoercedDateInput(props) {
450
1161
  const { dateProps, description, disabled, errorMessage, field: field2, label } = props;
451
1162
  const defaults = useHeroHookFormDefaults();
1163
+ const dateValue = toCalendarDateValue(field2.value);
452
1164
  return /* @__PURE__ */ React7.createElement(
453
1165
  DateInput,
454
1166
  {
@@ -460,7 +1172,7 @@ function CoercedDateInput(props) {
460
1172
  isInvalid: Boolean(errorMessage),
461
1173
  label,
462
1174
  name: field2.name,
463
- value: field2.value ?? null,
1175
+ value: dateValue,
464
1176
  onBlur: field2.onBlur,
465
1177
  onChange: field2.onChange
466
1178
  }
@@ -1371,10 +2083,8 @@ function FormFieldComponent({
1371
2083
  );
1372
2084
  }
1373
2085
  }
1374
- let shouldRenderConditionalField = true;
1375
2086
  if ("condition" in fieldConfig && fieldConfig.condition && !fieldConfig.condition(watchedValues)) {
1376
2087
  if ("field" in fieldConfig && fieldConfig.field && typeof fieldConfig.field === "object" && "type" in fieldConfig.field && fieldConfig.field.type === "fieldArray" && "alwaysRegistered" in fieldConfig.field && fieldConfig.field.alwaysRegistered === true) {
1377
- shouldRenderConditionalField = true;
1378
2088
  } else {
1379
2089
  return null;
1380
2090
  }
@@ -1541,8 +2251,7 @@ function FormFieldComponent({
1541
2251
  ...baseProps,
1542
2252
  name: fieldConfig.name,
1543
2253
  control,
1544
- dateProps: "dateProps" in fieldConfig ? fieldConfig.dateProps : void 0,
1545
- defaultValue: "defaultValue" in fieldConfig ? fieldConfig.defaultValue : void 0
2254
+ dateProps: "dateProps" in fieldConfig ? fieldConfig.dateProps : void 0
1546
2255
  }
1547
2256
  );
1548
2257
  }
@@ -2272,6 +2981,7 @@ function ServerActionField({
2272
2981
  }
2273
2982
  case "date": {
2274
2983
  const dateConfig = fieldConfig;
2984
+ const dateValue = toCalendarDateValue(value);
2275
2985
  return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement("input", { type: "hidden", name: fieldName, value: value || "" }), /* @__PURE__ */ React21.createElement(
2276
2986
  DateInput,
2277
2987
  {
@@ -2282,7 +2992,7 @@ function ServerActionField({
2282
2992
  isDisabled: baseProps.isDisabled,
2283
2993
  isInvalid: Boolean(errorMessage),
2284
2994
  errorMessage,
2285
- value: value ? value : null,
2995
+ value: dateValue,
2286
2996
  onChange: (date) => {
2287
2997
  const dateString = date ? `${date.year}-${String(date.month).padStart(2, "0")}-${String(date.day).padStart(2, "0")}` : "";
2288
2998
  setValue(dateString);
@@ -2675,11 +3385,80 @@ function createZodResolver(schema) {
2675
3385
  }
2676
3386
  };
2677
3387
  }
3388
+ function toCalendarDate(value) {
3389
+ if (value === null || value === void 0) {
3390
+ return null;
3391
+ }
3392
+ if (typeof value === "object" && "year" in value && "month" in value && "day" in value && typeof value.year === "number") {
3393
+ return value;
3394
+ }
3395
+ if (value instanceof Date) {
3396
+ return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(
3397
+ value.getFullYear(),
3398
+ value.getMonth() + 1,
3399
+ value.getDate()
3400
+ );
3401
+ }
3402
+ if (typeof value === "string") {
3403
+ const date = new Date(value);
3404
+ if (!isNaN(date.getTime())) {
3405
+ return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(
3406
+ date.getFullYear(),
3407
+ date.getMonth() + 1,
3408
+ date.getDate()
3409
+ );
3410
+ }
3411
+ }
3412
+ return value;
3413
+ }
3414
+ function defaultValuesFromFields(fields) {
3415
+ const out = {};
3416
+ const dateFieldNames = /* @__PURE__ */ new Set();
3417
+ for (const field2 of fields) {
3418
+ if ("name" in field2 && field2.name !== void 0 && field2.type === "date") {
3419
+ dateFieldNames.add(String(field2.name));
3420
+ }
3421
+ }
3422
+ for (const field2 of fields) {
3423
+ if ("name" in field2 && field2.name !== void 0 && "defaultValue" in field2 && field2.defaultValue !== void 0) {
3424
+ const fieldName = String(field2.name);
3425
+ let value = field2.defaultValue;
3426
+ if (dateFieldNames.has(fieldName)) {
3427
+ value = toCalendarDate(value);
3428
+ }
3429
+ out[fieldName] = value;
3430
+ }
3431
+ }
3432
+ return out;
3433
+ }
2678
3434
  function useZodForm(config) {
2679
- if (!config.resolver && config.schema) {
2680
- config.resolver = createZodResolver(config.schema);
3435
+ const resolver = config.resolver ?? (config.schema ? createZodResolver(config.schema) : void 0);
3436
+ const fieldDefaults = defaultValuesFromFields(
3437
+ config.fields
3438
+ );
3439
+ const hasFieldDefaults = Object.keys(fieldDefaults).length > 0;
3440
+ const dateFieldNames = /* @__PURE__ */ new Set();
3441
+ for (const field2 of config.fields) {
3442
+ if ("name" in field2 && field2.name !== void 0 && field2.type === "date") {
3443
+ dateFieldNames.add(String(field2.name));
3444
+ }
2681
3445
  }
2682
- return useForm2(config);
3446
+ const convertedConfigDefaults = config.defaultValues ? Object.entries(config.defaultValues).reduce(
3447
+ (acc, [key, value]) => {
3448
+ acc[key] = dateFieldNames.has(key) ? toCalendarDate(value) : value;
3449
+ return acc;
3450
+ },
3451
+ {}
3452
+ ) : void 0;
3453
+ const mergedDefaultValues = hasFieldDefaults || convertedConfigDefaults ? {
3454
+ ...fieldDefaults,
3455
+ ...convertedConfigDefaults
3456
+ } : convertedConfigDefaults;
3457
+ return useForm2({
3458
+ ...config,
3459
+ ...resolver && { resolver },
3460
+ defaultValues: mergedDefaultValues
3461
+ });
2683
3462
  }
2684
3463
  function createZodFormConfig(schema, fields, defaultValues) {
2685
3464
  return {
@@ -3381,16 +4160,15 @@ var FormFieldHelpers = {
3381
4160
  * // Simple date field
3382
4161
  * FormFieldHelpers.date("birthDate", "Birth Date")
3383
4162
  *
3384
- * // With full customization
4163
+ * // With DateInput props (set default via config.defaultValues)
3385
4164
  * FormFieldHelpers.date("birthDate", "Birth Date", {
3386
- * label: "Select your birth date",
3387
4165
  * granularity: "day",
3388
- * minValue: new CalendarDate(1900, 1, 1)
4166
+ * minValue: new CalendarDate(1900, 1, 1),
3389
4167
  * })
3390
4168
  * ```
3391
4169
  */
3392
4170
  date: (name, label, dateProps) => ({
3393
- dateProps,
4171
+ dateProps: Object.keys(dateProps ?? {}).length > 0 ? dateProps : void 0,
3394
4172
  label,
3395
4173
  name,
3396
4174
  type: "date"
@@ -4864,7 +5642,7 @@ function suggestGarbageCollection() {
4864
5642
  if (typeof window !== "undefined" && "gc" in window) {
4865
5643
  try {
4866
5644
  window.gc();
4867
- } catch (error) {
5645
+ } catch {
4868
5646
  }
4869
5647
  }
4870
5648
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachelallyson/hero-hook-form",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
4
4
  "description": "Typed form helpers that combine React Hook Form and HeroUI components.",
5
5
  "author": "Rachel Higley",
6
6
  "homepage": "https://rachelallyson.github.io/hero-hook-form/",