@fuf-stack/uniform 1.22.0 → 1.22.1

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 (85) hide show
  1. package/dist/Select/index.d.cts +1 -1
  2. package/dist/Select/index.d.ts +1 -1
  3. package/dist/Slider/index.d.cts +1 -1
  4. package/dist/Slider/index.d.ts +1 -1
  5. package/dist/Switch/index.d.cts +1 -1
  6. package/dist/Switch/index.d.ts +1 -1
  7. package/dist/Time/index.cjs +1 -1
  8. package/dist/Time/index.js +1 -1
  9. package/dist/{Time-CC2O-VD1.js → Time-CDptQ3CK.js} +8 -4
  10. package/dist/Time-CDptQ3CK.js.map +1 -0
  11. package/dist/{Time-D2-bRv-T.cjs → Time-mmSE7FJg.cjs} +7 -3
  12. package/dist/Time-mmSE7FJg.cjs.map +1 -0
  13. package/dist/helpers/index.d.cts +2 -224
  14. package/dist/helpers/index.d.ts +2 -224
  15. package/dist/hooks/useClientValidation/index.d.cts +1 -1
  16. package/dist/hooks/useClientValidation/index.d.ts +1 -1
  17. package/dist/hooks/useController/index.d.cts +1 -1
  18. package/dist/hooks/useController/index.d.ts +1 -1
  19. package/dist/hooks/useUniformField/index.d.cts +1 -1
  20. package/dist/hooks/useUniformField/index.d.ts +1 -1
  21. package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
  22. package/dist/hooks/useUniformFieldArray/index.d.ts +1 -1
  23. package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
  24. package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
  25. package/dist/{index-Ct5-g-RZ.d.ts → index-2VnDgA2J.d.ts} +10 -10
  26. package/dist/{index-Ct5-g-RZ.d.ts.map → index-2VnDgA2J.d.ts.map} +1 -1
  27. package/dist/index-BAg613AJ.d.cts +224 -0
  28. package/dist/index-BAg613AJ.d.cts.map +1 -0
  29. package/dist/{index-CmOkjok9.d.cts → index-BjKXOuyP.d.cts} +10 -10
  30. package/dist/{index-CmOkjok9.d.cts.map → index-BjKXOuyP.d.cts.map} +1 -1
  31. package/dist/{index-BZqqP2U8.d.ts → index-BpaOeWBo.d.ts} +7 -7
  32. package/dist/{index-BZqqP2U8.d.ts.map → index-BpaOeWBo.d.ts.map} +1 -1
  33. package/dist/{index-BM4O3yE9.d.cts → index-BqiVSpJW.d.cts} +1 -1
  34. package/dist/{index-BM4O3yE9.d.cts.map → index-BqiVSpJW.d.cts.map} +1 -1
  35. package/dist/index-BvCTs-LU.d.ts +224 -0
  36. package/dist/index-BvCTs-LU.d.ts.map +1 -0
  37. package/dist/{index-ClRcSBRW.d.cts → index-C9EqOSHz.d.cts} +7 -7
  38. package/dist/{index-ClRcSBRW.d.cts.map → index-C9EqOSHz.d.cts.map} +1 -1
  39. package/dist/{index-Bf_19w5d2.d.ts → index-COBktROL2.d.ts} +1 -1
  40. package/dist/{index-Bf_19w5d2.d.ts.map → index-COBktROL2.d.ts.map} +1 -1
  41. package/dist/{index-6mOo2unD.d.cts → index-CqyMqRhI.d.cts} +1 -1
  42. package/dist/{index-6mOo2unD.d.cts.map → index-CqyMqRhI.d.cts.map} +1 -1
  43. package/dist/{index-9jGNsUbr2.d.ts → index-D1m6qfLO2.d.ts} +1 -1
  44. package/dist/{index-9jGNsUbr2.d.ts.map → index-D1m6qfLO2.d.ts.map} +1 -1
  45. package/dist/{index-DKpPzE3w.d.ts → index-Dhlp1At5.d.ts} +16 -16
  46. package/dist/{index-DKpPzE3w.d.ts.map → index-Dhlp1At5.d.ts.map} +1 -1
  47. package/dist/{index-D9FemJbE.d.cts → index-DuOH2kzW.d.cts} +16 -16
  48. package/dist/{index-D9FemJbE.d.cts.map → index-DuOH2kzW.d.cts.map} +1 -1
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.d.cts +11 -11
  51. package/dist/index.d.ts +11 -11
  52. package/dist/index.js +1 -1
  53. package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
  54. package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
  55. package/dist/partials/FieldValidationError/index.d.cts +1 -1
  56. package/dist/partials/FieldValidationError/index.d.ts +1 -1
  57. package/dist/{useClientValidation-qRq2_spX.d.ts → useClientValidation-BkIsMCEl.d.ts} +1 -1
  58. package/dist/{useClientValidation-qRq2_spX.d.ts.map → useClientValidation-BkIsMCEl.d.ts.map} +1 -1
  59. package/dist/{useClientValidation-C2dLJnDI.d.cts → useClientValidation-DW5pYWyi.d.cts} +1 -1
  60. package/dist/{useClientValidation-C2dLJnDI.d.cts.map → useClientValidation-DW5pYWyi.d.cts.map} +1 -1
  61. package/dist/{useController-CzP0aVFC.d.ts → useController-Bl0Qup0s.d.ts} +1 -1
  62. package/dist/{useController-CzP0aVFC.d.ts.map → useController-Bl0Qup0s.d.ts.map} +1 -1
  63. package/dist/{useController-BT3Fd0IO.d.cts → useController-C8DLa8j5.d.cts} +1 -1
  64. package/dist/{useController-BT3Fd0IO.d.cts.map → useController-C8DLa8j5.d.cts.map} +1 -1
  65. package/dist/{useUniformField-CFonAaLK.d.ts → useUniformField-BWef-AXr.d.ts} +2 -2
  66. package/dist/{useUniformField-CFonAaLK.d.ts.map → useUniformField-BWef-AXr.d.ts.map} +1 -1
  67. package/dist/{useUniformField-DAUNqJiM.d.cts → useUniformField-CXK_23F9.d.cts} +2 -2
  68. package/dist/{useUniformField-DAUNqJiM.d.cts.map → useUniformField-CXK_23F9.d.cts.map} +1 -1
  69. package/dist/{useUniformFieldArray-C5L45Xt5.d.ts → useUniformFieldArray-9kCb5G9q.d.ts} +2 -2
  70. package/dist/useUniformFieldArray-9kCb5G9q.d.ts.map +1 -0
  71. package/dist/{useUniformFieldArray-B7kOxpV0.d.cts → useUniformFieldArray-Bx7v1U2d.d.cts} +2 -2
  72. package/dist/useUniformFieldArray-Bx7v1U2d.d.cts.map +1 -0
  73. package/dist/{useWatchUserChange-CpQ-pWRM.d.ts → useWatchUserChange-CpyZz2i7.d.ts} +1 -1
  74. package/dist/{useWatchUserChange-CpQ-pWRM.d.ts.map → useWatchUserChange-CpyZz2i7.d.ts.map} +1 -1
  75. package/dist/{useWatchUserChange-BgO4melQ.d.cts → useWatchUserChange-DSAboNCs.d.cts} +1 -1
  76. package/dist/{useWatchUserChange-BgO4melQ.d.cts.map → useWatchUserChange-DSAboNCs.d.cts.map} +1 -1
  77. package/package.json +3 -3
  78. package/dist/Time-CC2O-VD1.js.map +0 -1
  79. package/dist/Time-D2-bRv-T.cjs.map +0 -1
  80. package/dist/helpers/index.d.cts.map +0 -1
  81. package/dist/helpers/index.d.ts.map +0 -1
  82. package/dist/index-C2gUMYkE.d.cts +0 -1
  83. package/dist/index-h64gcVNJ.d.ts +0 -1
  84. package/dist/useUniformFieldArray-B7kOxpV0.d.cts.map +0 -1
  85. package/dist/useUniformFieldArray-C5L45Xt5.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { n as SelectProps, t as Select } from "../index-ClRcSBRW.cjs";
1
+ import { n as SelectProps, t as Select } from "../index-C9EqOSHz.cjs";
2
2
  export { Select, Select as default, type SelectProps };
@@ -1,2 +1,2 @@
1
- import { n as SelectProps, t as Select } from "../index-BZqqP2U8.js";
1
+ import { n as SelectProps, t as Select } from "../index-BpaOeWBo.js";
2
2
  export { Select, Select as default, type SelectProps };
@@ -1,2 +1,2 @@
1
- import { n as SliderProps, t as Slider } from "../index-D9FemJbE.cjs";
1
+ import { n as SliderProps, t as Slider } from "../index-DuOH2kzW.cjs";
2
2
  export { Slider, Slider as default, type SliderProps };
@@ -1,2 +1,2 @@
1
- import { n as SliderProps, t as Slider } from "../index-DKpPzE3w.js";
1
+ import { n as SliderProps, t as Slider } from "../index-Dhlp1At5.js";
2
2
  export { Slider, Slider as default, type SliderProps };
@@ -1,2 +1,2 @@
1
- import { n as SwitchProps, t as Switch } from "../index-CmOkjok9.cjs";
1
+ import { n as SwitchProps, t as Switch } from "../index-BjKXOuyP.cjs";
2
2
  export { Switch, Switch as default, type SwitchProps };
@@ -1,2 +1,2 @@
1
- import { n as SwitchProps, t as Switch } from "../index-Ct5-g-RZ.js";
1
+ import { n as SwitchProps, t as Switch } from "../index-2VnDgA2J.js";
2
2
  export { Switch, Switch as default, type SwitchProps };
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Time = require("../Time-D2-bRv-T.cjs");
2
+ const require_Time = require("../Time-mmSE7FJg.cjs");
3
3
  exports.Time = require_Time.Time;
@@ -1,2 +1,2 @@
1
- import { t as Time } from "../Time-CC2O-VD1.js";
1
+ import { t as Time } from "../Time-CDptQ3CK.js";
2
2
  export { Time };
@@ -1,7 +1,7 @@
1
1
  import { useUniformField } from "./hooks/useUniformField/index.js";
2
2
  import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
3
3
  import { jsx } from "react/jsx-runtime";
4
- import { getLocalTimeZone, now, parseAbsolute, parseAbsoluteToLocal, parseDateTime, parseZonedDateTime } from "@internationalized/date";
4
+ import { getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal, parseDateTime, parseZonedDateTime } from "@internationalized/date";
5
5
  import { TimeInput } from "@heroui/date-input";
6
6
  //#region src/Time/timeHelpers.ts
7
7
  /** Cast unknown input to the TimeInput value union type. */
@@ -100,9 +100,13 @@ const parseTimeValue = (value, timeZone) => {
100
100
  const resolveTimeFieldTimeZone = (timeZone) => {
101
101
  return timeZone ?? getLocalTimeZone();
102
102
  };
103
- /** Build default placeholder value for TimeInput. */
103
+ /**
104
+ * Build default placeholder value for TimeInput.
105
+ *
106
+ * Uses a fixed reference time to keep snapshots deterministic.
107
+ */
104
108
  const getTimeFieldPlaceholderValue = (timeZone) => {
105
- return asTimeValue(now(resolveTimeFieldTimeZone(timeZone)));
109
+ return asTimeValue(parseZonedDateTime(`1970-01-01T00:00:00[${resolveTimeFieldTimeZone(timeZone)}]`));
106
110
  };
107
111
  /**
108
112
  * Convert a TimeValue into a UTC time-only string for form state.
@@ -206,4 +210,4 @@ const Time = ({ className: _className = void 0, granularity = "minute", hideTime
206
210
  //#endregion
207
211
  export { Time as t };
208
212
 
209
- //# sourceMappingURL=Time-CC2O-VD1.js.map
213
+ //# sourceMappingURL=Time-CDptQ3CK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Time-CDptQ3CK.js","names":["HeroTimeInput"],"sources":["../src/Time/timeHelpers.ts","../src/Time/Time.tsx"],"sourcesContent":["import type { TimeInput as HeroTimeInput } from '@heroui/date-input';\nimport type { ComponentProps } from 'react';\n\nimport {\n getLocalTimeZone,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseDateTime,\n parseZonedDateTime,\n} from '@internationalized/date';\n\n/** Value type accepted by HeroUI TimeInput */\nexport type TimeValue = ComponentProps<typeof HeroTimeInput>['value'];\n\n/** Cast unknown input to the TimeInput value union type. */\nconst asTimeValue = (value: unknown): TimeValue => {\n return value as TimeValue;\n};\n\n/** Check whether a value already looks like an @internationalized/date value. */\nconst isTimeValueLike = (value: unknown): value is object => {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n return 'hour' in value || 'calendar' in value;\n};\n\n/** Check if the incoming string represents a plain time (e.g. 09:30 or 09:30:45). */\nconst isTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?$/.test(value);\n};\n\n/** Check if the incoming string is a UTC time-only value (e.g. 09:30Z). */\nconst isUtcTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?Z$/.test(value);\n};\n\n/** Zero-pad integer segments for time serialization. */\nconst pad = (value: number): string => {\n return String(value).padStart(2, '0');\n};\n\n/** Convert an absolute ISO string into UTC time-only store format. */\nconst toUtcTimeString = (\n absoluteIsoString: string,\n granularity: 'hour' | 'minute',\n): string | null => {\n const utcDate = new Date(absoluteIsoString);\n if (Number.isNaN(utcDate.getTime())) {\n return null;\n }\n\n const hour = pad(utcDate.getUTCHours());\n if (granularity === 'hour') {\n return `${hour}:00Z`;\n }\n\n return `${hour}:${pad(utcDate.getUTCMinutes())}Z`;\n};\n\n/** True when an input already carries timezone/offset information. */\nconst hasExplicitTimeZone = (value: string): boolean => {\n if (value.includes('[') && value.includes(']')) {\n return true;\n }\n\n return /(?:[zZ]|[+-]\\d{2}:\\d{2})$/.test(value);\n};\n\n/** True for date-time strings without timezone/offset. */\nconst isNaiveDateTimeString = (value: string): boolean => {\n return /^\\d{4}-\\d{2}-\\d{2}T/.test(value) && !hasExplicitTimeZone(value);\n};\n\n/** Safely run a parser and return `null` on parsing errors. */\nconst tryParse = (parser: () => unknown): TimeValue => {\n try {\n return asTimeValue(parser());\n } catch {\n return null;\n }\n};\n\n/**\n * Parse a form value into a HeroUI TimeInput compatible `TimeValue`.\n *\n * Supports existing `TimeValue` objects, native `Date` instances, plain time\n * strings (`HH:mm[:ss]`), absolute ISO date-time strings, zoned date-time\n * strings, and local date-time strings.\n *\n * Time-only strings are interpreted in the active timezone and normalized to a\n * `ZonedDateTime` (using a fixed reference date) so timezone abbreviations can\n * remain visible in the UI.\n */\nexport const parseTimeValue = (\n value: unknown,\n timeZone?: string,\n): TimeValue => {\n if (value == null || value === '') {\n return null;\n }\n\n if (isTimeValueLike(value)) {\n return asTimeValue(value);\n }\n\n if (value instanceof Date) {\n return asTimeValue(\n timeZone\n ? parseAbsolute(value.toISOString(), timeZone)\n : parseAbsoluteToLocal(value.toISOString()),\n );\n }\n\n if (typeof value !== 'string') {\n return null;\n }\n\n const normalizedValue = value.trim();\n if (normalizedValue === '') {\n return null;\n }\n\n if (isTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const [hourValue, minuteValue, secondValue] = normalizedValue\n .split(':')\n .map(Number);\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const hour = pad(hourValue);\n const minute = pad(minuteValue);\n const second = pad(secondValue ?? 0);\n\n return parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${resolvedTimeZone}]`,\n );\n });\n }\n\n if (isUtcTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return parseAbsolute(`1970-01-01T${normalizedValue}`, resolvedTimeZone);\n });\n }\n\n const parsers: (() => unknown)[] = [\n ...(timeZone && isNaiveDateTimeString(normalizedValue)\n ? [\n () => {\n return parseZonedDateTime(`${normalizedValue}[${timeZone}]`);\n },\n ]\n : []),\n () => {\n return timeZone\n ? parseAbsolute(normalizedValue, timeZone)\n : parseAbsoluteToLocal(normalizedValue);\n },\n () => {\n return parseZonedDateTime(normalizedValue);\n },\n () => {\n return parseDateTime(normalizedValue);\n },\n ];\n\n return (\n parsers\n .map((parser) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return tryParse(parser);\n })\n .find((parsedValue) => {\n return parsedValue != null;\n }) ?? null\n );\n};\n\n/** Resolve the timezone used for parsing and string conversion. */\nexport const resolveTimeFieldTimeZone = (timeZone?: string): string => {\n return timeZone ?? getLocalTimeZone();\n};\n\n/**\n * Build default placeholder value for TimeInput.\n *\n * Uses a fixed reference time to keep snapshots deterministic.\n */\nexport const getTimeFieldPlaceholderValue = (timeZone?: string): TimeValue => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return asTimeValue(\n parseZonedDateTime(`1970-01-01T00:00:00[${resolvedTimeZone}]`),\n );\n};\n\n/**\n * Convert a TimeValue into a UTC time-only string for form state.\n *\n * The stored format is `HH:mmZ` (or `HH:00Z` when granularity is `hour`).\n */\nexport const timeValueToString = (\n value: TimeValue,\n timeZone: string,\n granularity: 'hour' | 'minute' = 'minute',\n): string | null => {\n if (value == null) {\n return null;\n }\n\n const maybeWithAbsoluteString = value as { toAbsoluteString?: () => string };\n if (typeof maybeWithAbsoluteString.toAbsoluteString === 'function') {\n return toUtcTimeString(\n maybeWithAbsoluteString.toAbsoluteString(),\n granularity,\n );\n }\n\n const maybeWithToDate = value as { toDate?: (zone: string) => Date };\n if (typeof maybeWithToDate.toDate === 'function') {\n return toUtcTimeString(\n maybeWithToDate.toDate(timeZone).toISOString(),\n granularity,\n );\n }\n\n const maybeTime = value as {\n hour?: number;\n minute?: number;\n second?: number;\n };\n if (\n typeof maybeTime.hour === 'number' &&\n typeof maybeTime.minute === 'number'\n ) {\n const hour = pad(maybeTime.hour);\n const minute = pad(maybeTime.minute);\n const second = pad(maybeTime.second ?? 0);\n return toUtcTimeString(\n parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${timeZone}]`,\n ).toAbsoluteString(),\n granularity,\n );\n }\n\n return null;\n};\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { TimeValue } from './timeHelpers';\n\nimport { TimeInput as HeroTimeInput } from '@heroui/date-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport {\n getTimeFieldPlaceholderValue,\n parseTimeValue,\n resolveTimeFieldTimeZone,\n timeValueToString,\n} from './timeHelpers';\n\nexport const timeVariants = tv({\n slots: {\n /** wrapper around the whole time input */\n base: '',\n /** helper wrapper for error/description */\n helperWrapper: [\n // set padding to 0 for error message exit animation\n 'p-0',\n ],\n /** the segmented input element */\n input: '',\n /** inner wrapper around segments and optional content */\n innerWrapper: '',\n /** outer input wrapper */\n inputWrapper: 'bg-content1 focus-within:border-focus',\n /** field label */\n label: '',\n /** individual segment */\n segment: '',\n },\n});\n\ntype VariantProps = TVProps<typeof timeVariants>;\ntype ClassName = TVClassName<typeof timeVariants>;\n\nexport interface TimeProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** input is disabled */\n disabled?: boolean;\n /** smallest visible unit in the segmented time input */\n granularity?: 'hour' | 'minute';\n /** hide timezone abbreviation for zoned values */\n hideTimeZone?: boolean;\n /** force hour granularity and store UTC hour as number (0-23) */\n hourAsNumber?: boolean;\n /** hour cycle formatting */\n hourCycle?: 12 | 24;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /**\n * Optional timezone used for parsing date-time strings and serializing values.\n * When omitted, local timezone is used.\n */\n timeZone?: string;\n /** value format stored in form state (`string` stores UTC minute values, e.g. `10:15Z`) */\n valueType?: 'string' | 'timeValue';\n}\n\n/**\n * Time component based on [HeroUI TimeInput](https://v2.heroui.com/docs/components/time-input)\n */\nconst Time = ({\n className: _className = undefined,\n granularity = 'minute',\n hideTimeZone = false,\n hourAsNumber = false,\n hourCycle = undefined,\n name,\n timeZone = undefined,\n valueType = 'string',\n ...uniformFieldProps\n}: TimeProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // classNames from slots\n const variants = timeVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const effectiveGranularity = hourAsNumber ? 'hour' : granularity;\n\n // `hourAsNumber` stores 0-23; convert this into a parseable UTC time for display.\n const normalizedFieldValue =\n hourAsNumber && typeof value === 'number'\n ? `${String(Math.max(0, Math.min(23, value))).padStart(2, '0')}:00Z`\n : value;\n\n // Normalize incoming form value into HeroUI TimeInput value shape.\n const parsedValue = parseTimeValue(normalizedFieldValue, timeZone);\n const placeholderValue = getTimeFieldPlaceholderValue(timeZone);\n\n // Normalize TimeInput output into the configured storage format.\n const handleChange = (nextValue: TimeValue) => {\n if (nextValue == null) {\n onChange(null);\n return;\n }\n\n if (hourAsNumber) {\n const serializedValue = timeValueToString(\n nextValue,\n resolvedTimeZone,\n 'hour',\n );\n\n if (!serializedValue) {\n onChange(null);\n return;\n }\n\n const [hoursSegment] = serializedValue.split(':');\n const parsedHours = Number(hoursSegment);\n onChange(Number.isNaN(parsedHours) ? null : parsedHours);\n return;\n }\n\n if (valueType === 'timeValue') {\n onChange(nextValue);\n return;\n }\n\n onChange(\n timeValueToString(nextValue, resolvedTimeZone, effectiveGranularity) ??\n String(nextValue),\n );\n };\n\n return (\n <HeroTimeInput\n aria-label={label ? undefined : ariaLabel}\n classNames={{\n base: classNames.base,\n helperWrapper: classNames.helperWrapper,\n innerWrapper: classNames.innerWrapper,\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n label: classNames.label,\n segment: classNames.segment,\n }}\n data-testid={testId}\n errorMessage={errorMessage}\n granularity={effectiveGranularity}\n hideTimeZone={hideTimeZone}\n hourCycle={hourCycle}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={handleChange}\n placeholderValue={placeholderValue ?? undefined}\n radius=\"sm\"\n value={parsedValue ?? undefined}\n variant=\"bordered\"\n />\n );\n};\n\nexport default Time;\n"],"mappings":";;;;;;;AAeA,MAAM,eAAe,UAA8B;CACjD,OAAO;AACT;;AAGA,MAAM,mBAAmB,UAAoC;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO;CAGT,OAAO,UAAU,SAAS,cAAc;AAC1C;;AAGA,MAAM,oBAAoB,UAA2B;CACnD,OAAO,yCAAyC,KAAK,KAAK;AAC5D;;AAGA,MAAM,uBAAuB,UAA2B;CACtD,OAAO,0CAA0C,KAAK,KAAK;AAC7D;;AAGA,MAAM,OAAO,UAA0B;CACrC,OAAO,OAAO,KAAK,EAAE,SAAS,GAAG,GAAG;AACtC;;AAGA,MAAM,mBACJ,mBACA,gBACkB;CAClB,MAAM,UAAU,IAAI,KAAK,iBAAiB;CAC1C,IAAI,OAAO,MAAM,QAAQ,QAAQ,CAAC,GAChC,OAAO;CAGT,MAAM,OAAO,IAAI,QAAQ,YAAY,CAAC;CACtC,IAAI,gBAAgB,QAClB,OAAO,GAAG,KAAK;CAGjB,OAAO,GAAG,KAAK,GAAG,IAAI,QAAQ,cAAc,CAAC,EAAE;AACjD;;AA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EACX,YAAY;EACL;EACP,gBAAe;EACT;EACE;EACR,UAAU;EACV,kBAAkB,oBAAoB,KAAA;EACtC,QAAO;EACP,OAAO,eAAe,KAAA;EACtB,SAAQ;CACT,CAAA;AAEL"}
@@ -101,9 +101,13 @@ const parseTimeValue = (value, timeZone) => {
101
101
  const resolveTimeFieldTimeZone = (timeZone) => {
102
102
  return timeZone ?? (0, _internationalized_date.getLocalTimeZone)();
103
103
  };
104
- /** Build default placeholder value for TimeInput. */
104
+ /**
105
+ * Build default placeholder value for TimeInput.
106
+ *
107
+ * Uses a fixed reference time to keep snapshots deterministic.
108
+ */
105
109
  const getTimeFieldPlaceholderValue = (timeZone) => {
106
- return asTimeValue((0, _internationalized_date.now)(resolveTimeFieldTimeZone(timeZone)));
110
+ return asTimeValue((0, _internationalized_date.parseZonedDateTime)(`1970-01-01T00:00:00[${resolveTimeFieldTimeZone(timeZone)}]`));
107
111
  };
108
112
  /**
109
113
  * Convert a TimeValue into a UTC time-only string for form state.
@@ -212,4 +216,4 @@ Object.defineProperty(exports, "Time", {
212
216
  }
213
217
  });
214
218
 
215
- //# sourceMappingURL=Time-D2-bRv-T.cjs.map
219
+ //# sourceMappingURL=Time-mmSE7FJg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Time-mmSE7FJg.cjs","names":["useUniformField","HeroTimeInput"],"sources":["../src/Time/timeHelpers.ts","../src/Time/Time.tsx"],"sourcesContent":["import type { TimeInput as HeroTimeInput } from '@heroui/date-input';\nimport type { ComponentProps } from 'react';\n\nimport {\n getLocalTimeZone,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseDateTime,\n parseZonedDateTime,\n} from '@internationalized/date';\n\n/** Value type accepted by HeroUI TimeInput */\nexport type TimeValue = ComponentProps<typeof HeroTimeInput>['value'];\n\n/** Cast unknown input to the TimeInput value union type. */\nconst asTimeValue = (value: unknown): TimeValue => {\n return value as TimeValue;\n};\n\n/** Check whether a value already looks like an @internationalized/date value. */\nconst isTimeValueLike = (value: unknown): value is object => {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n return 'hour' in value || 'calendar' in value;\n};\n\n/** Check if the incoming string represents a plain time (e.g. 09:30 or 09:30:45). */\nconst isTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?$/.test(value);\n};\n\n/** Check if the incoming string is a UTC time-only value (e.g. 09:30Z). */\nconst isUtcTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?Z$/.test(value);\n};\n\n/** Zero-pad integer segments for time serialization. */\nconst pad = (value: number): string => {\n return String(value).padStart(2, '0');\n};\n\n/** Convert an absolute ISO string into UTC time-only store format. */\nconst toUtcTimeString = (\n absoluteIsoString: string,\n granularity: 'hour' | 'minute',\n): string | null => {\n const utcDate = new Date(absoluteIsoString);\n if (Number.isNaN(utcDate.getTime())) {\n return null;\n }\n\n const hour = pad(utcDate.getUTCHours());\n if (granularity === 'hour') {\n return `${hour}:00Z`;\n }\n\n return `${hour}:${pad(utcDate.getUTCMinutes())}Z`;\n};\n\n/** True when an input already carries timezone/offset information. */\nconst hasExplicitTimeZone = (value: string): boolean => {\n if (value.includes('[') && value.includes(']')) {\n return true;\n }\n\n return /(?:[zZ]|[+-]\\d{2}:\\d{2})$/.test(value);\n};\n\n/** True for date-time strings without timezone/offset. */\nconst isNaiveDateTimeString = (value: string): boolean => {\n return /^\\d{4}-\\d{2}-\\d{2}T/.test(value) && !hasExplicitTimeZone(value);\n};\n\n/** Safely run a parser and return `null` on parsing errors. */\nconst tryParse = (parser: () => unknown): TimeValue => {\n try {\n return asTimeValue(parser());\n } catch {\n return null;\n }\n};\n\n/**\n * Parse a form value into a HeroUI TimeInput compatible `TimeValue`.\n *\n * Supports existing `TimeValue` objects, native `Date` instances, plain time\n * strings (`HH:mm[:ss]`), absolute ISO date-time strings, zoned date-time\n * strings, and local date-time strings.\n *\n * Time-only strings are interpreted in the active timezone and normalized to a\n * `ZonedDateTime` (using a fixed reference date) so timezone abbreviations can\n * remain visible in the UI.\n */\nexport const parseTimeValue = (\n value: unknown,\n timeZone?: string,\n): TimeValue => {\n if (value == null || value === '') {\n return null;\n }\n\n if (isTimeValueLike(value)) {\n return asTimeValue(value);\n }\n\n if (value instanceof Date) {\n return asTimeValue(\n timeZone\n ? parseAbsolute(value.toISOString(), timeZone)\n : parseAbsoluteToLocal(value.toISOString()),\n );\n }\n\n if (typeof value !== 'string') {\n return null;\n }\n\n const normalizedValue = value.trim();\n if (normalizedValue === '') {\n return null;\n }\n\n if (isTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const [hourValue, minuteValue, secondValue] = normalizedValue\n .split(':')\n .map(Number);\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const hour = pad(hourValue);\n const minute = pad(minuteValue);\n const second = pad(secondValue ?? 0);\n\n return parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${resolvedTimeZone}]`,\n );\n });\n }\n\n if (isUtcTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return parseAbsolute(`1970-01-01T${normalizedValue}`, resolvedTimeZone);\n });\n }\n\n const parsers: (() => unknown)[] = [\n ...(timeZone && isNaiveDateTimeString(normalizedValue)\n ? [\n () => {\n return parseZonedDateTime(`${normalizedValue}[${timeZone}]`);\n },\n ]\n : []),\n () => {\n return timeZone\n ? parseAbsolute(normalizedValue, timeZone)\n : parseAbsoluteToLocal(normalizedValue);\n },\n () => {\n return parseZonedDateTime(normalizedValue);\n },\n () => {\n return parseDateTime(normalizedValue);\n },\n ];\n\n return (\n parsers\n .map((parser) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return tryParse(parser);\n })\n .find((parsedValue) => {\n return parsedValue != null;\n }) ?? null\n );\n};\n\n/** Resolve the timezone used for parsing and string conversion. */\nexport const resolveTimeFieldTimeZone = (timeZone?: string): string => {\n return timeZone ?? getLocalTimeZone();\n};\n\n/**\n * Build default placeholder value for TimeInput.\n *\n * Uses a fixed reference time to keep snapshots deterministic.\n */\nexport const getTimeFieldPlaceholderValue = (timeZone?: string): TimeValue => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return asTimeValue(\n parseZonedDateTime(`1970-01-01T00:00:00[${resolvedTimeZone}]`),\n );\n};\n\n/**\n * Convert a TimeValue into a UTC time-only string for form state.\n *\n * The stored format is `HH:mmZ` (or `HH:00Z` when granularity is `hour`).\n */\nexport const timeValueToString = (\n value: TimeValue,\n timeZone: string,\n granularity: 'hour' | 'minute' = 'minute',\n): string | null => {\n if (value == null) {\n return null;\n }\n\n const maybeWithAbsoluteString = value as { toAbsoluteString?: () => string };\n if (typeof maybeWithAbsoluteString.toAbsoluteString === 'function') {\n return toUtcTimeString(\n maybeWithAbsoluteString.toAbsoluteString(),\n granularity,\n );\n }\n\n const maybeWithToDate = value as { toDate?: (zone: string) => Date };\n if (typeof maybeWithToDate.toDate === 'function') {\n return toUtcTimeString(\n maybeWithToDate.toDate(timeZone).toISOString(),\n granularity,\n );\n }\n\n const maybeTime = value as {\n hour?: number;\n minute?: number;\n second?: number;\n };\n if (\n typeof maybeTime.hour === 'number' &&\n typeof maybeTime.minute === 'number'\n ) {\n const hour = pad(maybeTime.hour);\n const minute = pad(maybeTime.minute);\n const second = pad(maybeTime.second ?? 0);\n return toUtcTimeString(\n parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${timeZone}]`,\n ).toAbsoluteString(),\n granularity,\n );\n }\n\n return null;\n};\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { TimeValue } from './timeHelpers';\n\nimport { TimeInput as HeroTimeInput } from '@heroui/date-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport {\n getTimeFieldPlaceholderValue,\n parseTimeValue,\n resolveTimeFieldTimeZone,\n timeValueToString,\n} from './timeHelpers';\n\nexport const timeVariants = tv({\n slots: {\n /** wrapper around the whole time input */\n base: '',\n /** helper wrapper for error/description */\n helperWrapper: [\n // set padding to 0 for error message exit animation\n 'p-0',\n ],\n /** the segmented input element */\n input: '',\n /** inner wrapper around segments and optional content */\n innerWrapper: '',\n /** outer input wrapper */\n inputWrapper: 'bg-content1 focus-within:border-focus',\n /** field label */\n label: '',\n /** individual segment */\n segment: '',\n },\n});\n\ntype VariantProps = TVProps<typeof timeVariants>;\ntype ClassName = TVClassName<typeof timeVariants>;\n\nexport interface TimeProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** input is disabled */\n disabled?: boolean;\n /** smallest visible unit in the segmented time input */\n granularity?: 'hour' | 'minute';\n /** hide timezone abbreviation for zoned values */\n hideTimeZone?: boolean;\n /** force hour granularity and store UTC hour as number (0-23) */\n hourAsNumber?: boolean;\n /** hour cycle formatting */\n hourCycle?: 12 | 24;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /**\n * Optional timezone used for parsing date-time strings and serializing values.\n * When omitted, local timezone is used.\n */\n timeZone?: string;\n /** value format stored in form state (`string` stores UTC minute values, e.g. `10:15Z`) */\n valueType?: 'string' | 'timeValue';\n}\n\n/**\n * Time component based on [HeroUI TimeInput](https://v2.heroui.com/docs/components/time-input)\n */\nconst Time = ({\n className: _className = undefined,\n granularity = 'minute',\n hideTimeZone = false,\n hourAsNumber = false,\n hourCycle = undefined,\n name,\n timeZone = undefined,\n valueType = 'string',\n ...uniformFieldProps\n}: TimeProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // classNames from slots\n const variants = timeVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const effectiveGranularity = hourAsNumber ? 'hour' : granularity;\n\n // `hourAsNumber` stores 0-23; convert this into a parseable UTC time for display.\n const normalizedFieldValue =\n hourAsNumber && typeof value === 'number'\n ? `${String(Math.max(0, Math.min(23, value))).padStart(2, '0')}:00Z`\n : value;\n\n // Normalize incoming form value into HeroUI TimeInput value shape.\n const parsedValue = parseTimeValue(normalizedFieldValue, timeZone);\n const placeholderValue = getTimeFieldPlaceholderValue(timeZone);\n\n // Normalize TimeInput output into the configured storage format.\n const handleChange = (nextValue: TimeValue) => {\n if (nextValue == null) {\n onChange(null);\n return;\n }\n\n if (hourAsNumber) {\n const serializedValue = timeValueToString(\n nextValue,\n resolvedTimeZone,\n 'hour',\n );\n\n if (!serializedValue) {\n onChange(null);\n return;\n }\n\n const [hoursSegment] = serializedValue.split(':');\n const parsedHours = Number(hoursSegment);\n onChange(Number.isNaN(parsedHours) ? null : parsedHours);\n return;\n }\n\n if (valueType === 'timeValue') {\n onChange(nextValue);\n return;\n }\n\n onChange(\n timeValueToString(nextValue, resolvedTimeZone, effectiveGranularity) ??\n String(nextValue),\n );\n };\n\n return (\n <HeroTimeInput\n aria-label={label ? undefined : ariaLabel}\n classNames={{\n base: classNames.base,\n helperWrapper: classNames.helperWrapper,\n innerWrapper: classNames.innerWrapper,\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n label: classNames.label,\n segment: classNames.segment,\n }}\n data-testid={testId}\n errorMessage={errorMessage}\n granularity={effectiveGranularity}\n hideTimeZone={hideTimeZone}\n hourCycle={hourCycle}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={handleChange}\n placeholderValue={placeholderValue ?? undefined}\n radius=\"sm\"\n value={parsedValue ?? undefined}\n variant=\"bordered\"\n />\n );\n};\n\nexport default Time;\n"],"mappings":";;;;;;;;A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IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,QAC7D,OAGmD,QAAQ;CACjE,MAAM,mBAAmB,6BAA6B,QAAQ;CAG9D,MAAM,gBAAgB,cAAyB;EAC7C,IAAI,aAAa,MAAM;GACrB,SAAS,IAAI;GACb;EACF;EAEA,IAAI,cAAc;GAChB,MAAM,kBAAkB,kBACtB,WACA,kBACA,MACF;GAEA,IAAI,CAAC,iBAAiB;IACpB,SAAS,IAAI;IACb;GACF;GAEA,MAAM,CAAC,gBAAgB,gBAAgB,MAAM,GAAG;GAChD,MAAM,cAAc,OAAO,YAAY;GACvC,SAAS,OAAO,MAAM,WAAW,IAAI,OAAO,WAAW;GACvD;EACF;EAEA,IAAI,cAAc,aAAa;GAC7B,SAAS,SAAS;GAClB;EACF;EAEA,SACE,kBAAkB,WAAW,kBAAkB,oBAAoB,KACjE,OAAO,SAAS,CACpB;CACF;CAEA,OACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,WAAD;EACE,cAAY,QAAQ,KAAA,IAAY;EAChC,YAAY;GACV,MAAM,WAAW;GACjB,eAAe,WAAW;GAC1B,cAAc,WAAW;GACzB,OAAO,WAAW;GAClB,cAAc,WAAW;GACzB,OAAO,WAAW;GAClB,SAAS,WAAW;EACtB;EACA,eAAa;EACC;EACd,aAAa;EACC;EACH;EACX,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACL;EACP,gBAAe;EACT;EACE;EACR,UAAU;EACV,kBAAkB,oBAAoB,KAAA;EACtC,QAAO;EACP,OAAO,eAAe,KAAA;EACtB,SAAQ;CACT,CAAA;AAEL"}
@@ -1,224 +1,2 @@
1
- //#region src/helpers/createOptionValueConverter/createOptionValueConverter.d.ts
2
- /**
3
- * Creates a converter function that preserves the original type (string, number, or boolean)
4
- * of option values when converting from string keys back to their original type.
5
- *
6
- * This is useful for radio/select components where the underlying UI library
7
- * uses string keys internally, but we want to preserve number/boolean values in the form state.
8
- *
9
- * @param options - Array of options with a value property that can be string, number, or boolean
10
- * @returns An object with:
11
- * - `convertToOriginalType`: Function to convert a string key back to its original type
12
- * - `numberValueKeys`: Set of string representations of number values (for internal use)
13
- * - `booleanValueKeys`: Map of string representations to boolean values (for internal use)
14
- */
15
- declare const createOptionValueConverter: <T extends {
16
- value: string | number | boolean;
17
- }>(options: T[]) => {
18
- booleanValueKeys: Map<string, boolean>;
19
- convertToOriginalType: (key: string | number | boolean) => string | number | boolean;
20
- numberValueKeys: Set<string>;
21
- };
22
- //#endregion
23
- //#region src/helpers/nullishFields/nullishFields.d.ts
24
- /** Key used to wrap flat array elements when converting to form format */
25
- declare const flatArrayKey = "__FLAT__";
26
- /**
27
- * Checks if a value is considered "empty" for validation display purposes.
28
- *
29
- * Used by useUniformField to determine when to show validation errors.
30
- * Empty values don't trigger immediate error display (user must interact first).
31
- *
32
- * Handles:
33
- * - Primitives: null, undefined, ''
34
- * - Marker strings: __NULL__, __FALSE__, __ZERO__ (converted via fromNullishString)
35
- * - Empty arrays: []
36
- * - Objects with all empty values: {a: null, b: ''}
37
- * - Flat array wrappers: {__FLAT__: null} or {__FLAT__: ''}
38
- *
39
- * @param value - The value to check (will be converted via fromNullishString first)
40
- * @returns true if the value is empty
41
- *
42
- * @example
43
- * isValueEmpty(null) // true
44
- * isValueEmpty('') // true
45
- * isValueEmpty('__NULL__') // true (marker string)
46
- * isValueEmpty([]) // true (empty array)
47
- * isValueEmpty({a: null}) // true (object with all empty values)
48
- * isValueEmpty({__FLAT__: null}) // true (flat array wrapper with empty value)
49
- * isValueEmpty({__FLAT__: ''}) // true
50
- * isValueEmpty('hello') // false
51
- * isValueEmpty([1, 2]) // false
52
- * isValueEmpty({a: 'value'}) // false
53
- * isValueEmpty({__FLAT__: 'value'}) // false
54
- */
55
- declare const isValueEmpty: (value: unknown) => boolean;
56
- /**
57
- * Converts marker strings back to their original values when processing arrays
58
- */
59
- declare const fromNullishString: (value: unknown) => unknown;
60
- /**
61
- * Converts null/falsy values to marker strings for JSON processing
62
- */
63
- declare const toNullishString: (value: unknown) => unknown;
64
- /**
65
- * Converts field values to a format suitable for forms by:
66
- * - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`
67
- * to satisfy RHF's requirement that array fields contain objects
68
- * - Removing empty strings and null values from objects
69
- *
70
- * This conversion is required because React Hook Form does not support arrays with
71
- * flat values (string, number, boolean, null). Array fields must contain objects.
72
- * We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.
73
- *
74
- * @example
75
- * const fields = {
76
- * name: 'John',
77
- * scores: [0, null, 75, false],
78
- * scoresDetailed: [
79
- * { score: 1 },
80
- * { score: null },
81
- * { score: 0 },
82
- * { score: false },
83
- * { score: '' },
84
- * ],
85
- * contact: {
86
- * email: '',
87
- * phone: null,
88
- * address: '123 Main St'
89
- * }
90
- * };
91
- *
92
- * // Result:
93
- * {
94
- * name: 'John',
95
- * scores: [
96
- * { __FLAT__: 0 },
97
- * { __FLAT__: null },
98
- * { __FLAT__: 75 },
99
- * { __FLAT__: false }
100
- * ],
101
- * // Arrays of objects are left as objects; empty/null properties are removed
102
- * scoresDetailed: [
103
- * { score: 1 },
104
- * {}, // null score removed
105
- * { score: 0 },
106
- * { score: false },
107
- * {}, // empty string removed
108
- * ],
109
- * contact: {
110
- * address: '123 Main St'
111
- * }
112
- * }
113
- */
114
- declare const toFormFormat: (fields: Record<string, unknown>) => Record<string, unknown>;
115
- /**
116
- * Converts form state to a format suitable for validation by:
117
- * - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives
118
- * - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values
119
- * - Removing fields whose converted value is empty string or null
120
- * - Removing empty arrays
121
- *
122
- * @example
123
- * const formState = {
124
- * name: 'John',
125
- * scores: [
126
- * { __FLAT__: 75 },
127
- * { __FLAT__: 0 },
128
- * { __FLAT__: null },
129
- * { __FLAT__: false }
130
- * ],
131
- * emptyArray: [],
132
- * scoresDetailed: [
133
- * { score: 1 },
134
- * {},
135
- * { score: 0 },
136
- * { score: false },
137
- * {},
138
- * ],
139
- * contact: {
140
- * address: '123 Main St',
141
- * fax: null
142
- * }
143
- * };
144
- *
145
- * // Result:
146
- * {
147
- * name: 'John',
148
- * scores: [75, 0, null, false],
149
- * // emptyArray is removed
150
- * // Objects inside arrays remain objects; empty entries remain empty objects
151
- * scoresDetailed: [
152
- * { score: 1 },
153
- * {},
154
- * { score: 0 },
155
- * { score: false },
156
- * {},
157
- * ],
158
- * contact: {
159
- * address: '123 Main St'
160
- * }
161
- * }
162
- */
163
- declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
164
- /**
165
- * Converts form state to a format suitable for submission by:
166
- * - Applying all transformations from toValidationFormat
167
- * - Additionally removing empty objects from the result
168
- * - Filtering empty objects from arrays
169
- * - Recursively cleaning nested structures
170
- *
171
- * **Why separate from toValidationFormat?**
172
- *
173
- * Empty objects must be preserved during validation so that custom refinements
174
- * can run. For example, a FieldCard with "at least email or phone required"
175
- * validation needs the object to exist (even if empty) for the refine to execute.
176
- *
177
- * However, for submission, empty objects are meaningless and should be removed
178
- * to produce clean data for APIs.
179
- *
180
- * @example
181
- * const formState = {
182
- * name: 'John',
183
- * contact: {}, // Empty FieldCard - will be removed
184
- * tags: [{}, {}, {}], // All empty - array will be removed
185
- * items: [
186
- * { value: 'a' },
187
- * {}, // Empty entry - will be filtered out
188
- * { value: 'b' }
189
- * ],
190
- * nested: {
191
- * deep: {} // Nested empty - will be removed recursively
192
- * }
193
- * };
194
- *
195
- * // Result:
196
- * {
197
- * name: 'John',
198
- * items: [{ value: 'a' }, { value: 'b' }]
199
- * }
200
- */
201
- declare const toSubmitFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
202
- /**
203
- * Converts a field name to a testId by removing flat array key segments and slugifying.
204
- * Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
205
- *
206
- * This is used to generate stable testIds for form fields that don't include
207
- * the internal `__FLAT__` marker used for flat arrays.
208
- *
209
- * @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])
210
- * @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')
211
- *
212
- * @example
213
- * ```ts
214
- * nameToTestId('tags.0.__FLAT__') // => 'tags_0'
215
- * nameToTestId('array.0.__FLAT__') // => 'array_0'
216
- * nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'
217
- * nameToTestId('simple.field') // => 'simple_field'
218
- * nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'
219
- * ```
220
- */
221
- declare const nameToTestId: (name: string | readonly string[]) => string;
222
- //#endregion
223
- export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
224
- //# sourceMappingURL=index.d.cts.map
1
+ import { a as toFormFormat, c as toValidationFormat, i as nameToTestId, l as createOptionValueConverter, n as fromNullishString, o as toNullishString, r as isValueEmpty, s as toSubmitFormat, t as flatArrayKey } from "../index-BAg613AJ.cjs";
2
+ export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
@@ -1,224 +1,2 @@
1
- //#region src/helpers/createOptionValueConverter/createOptionValueConverter.d.ts
2
- /**
3
- * Creates a converter function that preserves the original type (string, number, or boolean)
4
- * of option values when converting from string keys back to their original type.
5
- *
6
- * This is useful for radio/select components where the underlying UI library
7
- * uses string keys internally, but we want to preserve number/boolean values in the form state.
8
- *
9
- * @param options - Array of options with a value property that can be string, number, or boolean
10
- * @returns An object with:
11
- * - `convertToOriginalType`: Function to convert a string key back to its original type
12
- * - `numberValueKeys`: Set of string representations of number values (for internal use)
13
- * - `booleanValueKeys`: Map of string representations to boolean values (for internal use)
14
- */
15
- declare const createOptionValueConverter: <T extends {
16
- value: string | number | boolean;
17
- }>(options: T[]) => {
18
- booleanValueKeys: Map<string, boolean>;
19
- convertToOriginalType: (key: string | number | boolean) => string | number | boolean;
20
- numberValueKeys: Set<string>;
21
- };
22
- //#endregion
23
- //#region src/helpers/nullishFields/nullishFields.d.ts
24
- /** Key used to wrap flat array elements when converting to form format */
25
- declare const flatArrayKey = "__FLAT__";
26
- /**
27
- * Checks if a value is considered "empty" for validation display purposes.
28
- *
29
- * Used by useUniformField to determine when to show validation errors.
30
- * Empty values don't trigger immediate error display (user must interact first).
31
- *
32
- * Handles:
33
- * - Primitives: null, undefined, ''
34
- * - Marker strings: __NULL__, __FALSE__, __ZERO__ (converted via fromNullishString)
35
- * - Empty arrays: []
36
- * - Objects with all empty values: {a: null, b: ''}
37
- * - Flat array wrappers: {__FLAT__: null} or {__FLAT__: ''}
38
- *
39
- * @param value - The value to check (will be converted via fromNullishString first)
40
- * @returns true if the value is empty
41
- *
42
- * @example
43
- * isValueEmpty(null) // true
44
- * isValueEmpty('') // true
45
- * isValueEmpty('__NULL__') // true (marker string)
46
- * isValueEmpty([]) // true (empty array)
47
- * isValueEmpty({a: null}) // true (object with all empty values)
48
- * isValueEmpty({__FLAT__: null}) // true (flat array wrapper with empty value)
49
- * isValueEmpty({__FLAT__: ''}) // true
50
- * isValueEmpty('hello') // false
51
- * isValueEmpty([1, 2]) // false
52
- * isValueEmpty({a: 'value'}) // false
53
- * isValueEmpty({__FLAT__: 'value'}) // false
54
- */
55
- declare const isValueEmpty: (value: unknown) => boolean;
56
- /**
57
- * Converts marker strings back to their original values when processing arrays
58
- */
59
- declare const fromNullishString: (value: unknown) => unknown;
60
- /**
61
- * Converts null/falsy values to marker strings for JSON processing
62
- */
63
- declare const toNullishString: (value: unknown) => unknown;
64
- /**
65
- * Converts field values to a format suitable for forms by:
66
- * - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`
67
- * to satisfy RHF's requirement that array fields contain objects
68
- * - Removing empty strings and null values from objects
69
- *
70
- * This conversion is required because React Hook Form does not support arrays with
71
- * flat values (string, number, boolean, null). Array fields must contain objects.
72
- * We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.
73
- *
74
- * @example
75
- * const fields = {
76
- * name: 'John',
77
- * scores: [0, null, 75, false],
78
- * scoresDetailed: [
79
- * { score: 1 },
80
- * { score: null },
81
- * { score: 0 },
82
- * { score: false },
83
- * { score: '' },
84
- * ],
85
- * contact: {
86
- * email: '',
87
- * phone: null,
88
- * address: '123 Main St'
89
- * }
90
- * };
91
- *
92
- * // Result:
93
- * {
94
- * name: 'John',
95
- * scores: [
96
- * { __FLAT__: 0 },
97
- * { __FLAT__: null },
98
- * { __FLAT__: 75 },
99
- * { __FLAT__: false }
100
- * ],
101
- * // Arrays of objects are left as objects; empty/null properties are removed
102
- * scoresDetailed: [
103
- * { score: 1 },
104
- * {}, // null score removed
105
- * { score: 0 },
106
- * { score: false },
107
- * {}, // empty string removed
108
- * ],
109
- * contact: {
110
- * address: '123 Main St'
111
- * }
112
- * }
113
- */
114
- declare const toFormFormat: (fields: Record<string, unknown>) => Record<string, unknown>;
115
- /**
116
- * Converts form state to a format suitable for validation by:
117
- * - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives
118
- * - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values
119
- * - Removing fields whose converted value is empty string or null
120
- * - Removing empty arrays
121
- *
122
- * @example
123
- * const formState = {
124
- * name: 'John',
125
- * scores: [
126
- * { __FLAT__: 75 },
127
- * { __FLAT__: 0 },
128
- * { __FLAT__: null },
129
- * { __FLAT__: false }
130
- * ],
131
- * emptyArray: [],
132
- * scoresDetailed: [
133
- * { score: 1 },
134
- * {},
135
- * { score: 0 },
136
- * { score: false },
137
- * {},
138
- * ],
139
- * contact: {
140
- * address: '123 Main St',
141
- * fax: null
142
- * }
143
- * };
144
- *
145
- * // Result:
146
- * {
147
- * name: 'John',
148
- * scores: [75, 0, null, false],
149
- * // emptyArray is removed
150
- * // Objects inside arrays remain objects; empty entries remain empty objects
151
- * scoresDetailed: [
152
- * { score: 1 },
153
- * {},
154
- * { score: 0 },
155
- * { score: false },
156
- * {},
157
- * ],
158
- * contact: {
159
- * address: '123 Main St'
160
- * }
161
- * }
162
- */
163
- declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
164
- /**
165
- * Converts form state to a format suitable for submission by:
166
- * - Applying all transformations from toValidationFormat
167
- * - Additionally removing empty objects from the result
168
- * - Filtering empty objects from arrays
169
- * - Recursively cleaning nested structures
170
- *
171
- * **Why separate from toValidationFormat?**
172
- *
173
- * Empty objects must be preserved during validation so that custom refinements
174
- * can run. For example, a FieldCard with "at least email or phone required"
175
- * validation needs the object to exist (even if empty) for the refine to execute.
176
- *
177
- * However, for submission, empty objects are meaningless and should be removed
178
- * to produce clean data for APIs.
179
- *
180
- * @example
181
- * const formState = {
182
- * name: 'John',
183
- * contact: {}, // Empty FieldCard - will be removed
184
- * tags: [{}, {}, {}], // All empty - array will be removed
185
- * items: [
186
- * { value: 'a' },
187
- * {}, // Empty entry - will be filtered out
188
- * { value: 'b' }
189
- * ],
190
- * nested: {
191
- * deep: {} // Nested empty - will be removed recursively
192
- * }
193
- * };
194
- *
195
- * // Result:
196
- * {
197
- * name: 'John',
198
- * items: [{ value: 'a' }, { value: 'b' }]
199
- * }
200
- */
201
- declare const toSubmitFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
202
- /**
203
- * Converts a field name to a testId by removing flat array key segments and slugifying.
204
- * Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
205
- *
206
- * This is used to generate stable testIds for form fields that don't include
207
- * the internal `__FLAT__` marker used for flat arrays.
208
- *
209
- * @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])
210
- * @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')
211
- *
212
- * @example
213
- * ```ts
214
- * nameToTestId('tags.0.__FLAT__') // => 'tags_0'
215
- * nameToTestId('array.0.__FLAT__') // => 'array_0'
216
- * nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'
217
- * nameToTestId('simple.field') // => 'simple_field'
218
- * nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'
219
- * ```
220
- */
221
- declare const nameToTestId: (name: string | readonly string[]) => string;
222
- //#endregion
223
- export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
224
- //# sourceMappingURL=index.d.ts.map
1
+ import { a as toFormFormat, c as toValidationFormat, i as nameToTestId, l as createOptionValueConverter, n as fromNullishString, o as toNullishString, r as isValueEmpty, s as toSubmitFormat, t as flatArrayKey } from "../index-BvCTs-LU.js";
2
+ export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
@@ -1,2 +1,2 @@
1
- import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-C2dLJnDI.cjs";
1
+ import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-DW5pYWyi.cjs";
2
2
  export { clientValidationSchemaByName, useClientValidation };
@@ -1,2 +1,2 @@
1
- import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-qRq2_spX.js";
1
+ import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-BkIsMCEl.js";
2
2
  export { clientValidationSchemaByName, useClientValidation };
@@ -1,2 +1,2 @@
1
- import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-BT3Fd0IO.cjs";
1
+ import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-C8DLa8j5.cjs";
2
2
  export { UseControllerProps, UseControllerReturn, useController };
@@ -1,2 +1,2 @@
1
- import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-CzP0aVFC.js";
1
+ import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-Bl0Qup0s.js";
2
2
  export { UseControllerProps, UseControllerReturn, useController };