@mitcsutt/kiln-ui 0.5.0 → 0.7.0

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 (188) hide show
  1. package/dist/components/actions/CopyButton/CopyButton.d.ts +58 -0
  2. package/dist/components/actions/CopyButton/CopyButton.js +63 -0
  3. package/dist/components/actions/CopyButton/CopyButton.js.map +1 -0
  4. package/dist/components/actions/CopyButton/CopyButton.module.js +9 -0
  5. package/dist/components/actions/CopyButton/CopyButton.module.js.map +1 -0
  6. package/dist/components/actions/CopyButton/index.d.ts +4 -0
  7. package/dist/components/actions/CopyButton/useClipboard.d.ts +35 -0
  8. package/dist/components/actions/CopyButton/useClipboard.js +62 -0
  9. package/dist/components/actions/CopyButton/useClipboard.js.map +1 -0
  10. package/dist/components/actions/ToggleChip/ToggleChip.d.ts +6 -0
  11. package/dist/components/actions/ToggleChip/ToggleChip.js +26 -24
  12. package/dist/components/actions/ToggleChip/ToggleChip.js.map +1 -1
  13. package/dist/components/display/Badge/Badge.d.ts +6 -0
  14. package/dist/components/display/Badge/Badge.js +16 -15
  15. package/dist/components/display/Badge/Badge.js.map +1 -1
  16. package/dist/components/display/CodeBlock/CodeBlock.d.ts +44 -3
  17. package/dist/components/display/CodeBlock/CodeBlock.js +39 -47
  18. package/dist/components/display/CodeBlock/CodeBlock.js.map +1 -1
  19. package/dist/components/display/CodeBlock/CodeBlock.module.js +4 -3
  20. package/dist/components/display/CodeBlock/CodeBlock.module.js.map +1 -1
  21. package/dist/components/display/CodeBlock/index.d.ts +1 -1
  22. package/dist/components/display/Swatch/Swatch.d.ts +52 -0
  23. package/dist/components/display/Swatch/Swatch.js +27 -0
  24. package/dist/components/display/Swatch/Swatch.js.map +1 -0
  25. package/dist/components/display/Swatch/Swatch.module.js +6 -0
  26. package/dist/components/display/Swatch/Swatch.module.js.map +1 -0
  27. package/dist/components/display/Swatch/index.d.ts +2 -0
  28. package/dist/components/display/Tag/Tag.d.ts +7 -0
  29. package/dist/components/display/Tag/Tag.js +31 -26
  30. package/dist/components/display/Tag/Tag.js.map +1 -1
  31. package/dist/components/feedback/Indicator/Indicator.d.ts +74 -0
  32. package/dist/components/feedback/Indicator/Indicator.js +50 -0
  33. package/dist/components/feedback/Indicator/Indicator.js.map +1 -0
  34. package/dist/components/feedback/Indicator/Indicator.module.js +12 -0
  35. package/dist/components/feedback/Indicator/Indicator.module.js.map +1 -0
  36. package/dist/components/feedback/Indicator/index.d.ts +2 -0
  37. package/dist/components/feedback/Toaster/Toaster.d.ts +71 -0
  38. package/dist/components/feedback/Toaster/Toaster.js +121 -0
  39. package/dist/components/feedback/Toaster/Toaster.js.map +1 -0
  40. package/dist/components/feedback/Toaster/Toaster.module.js +20 -0
  41. package/dist/components/feedback/Toaster/Toaster.module.js.map +1 -0
  42. package/dist/components/feedback/Toaster/index.d.ts +4 -0
  43. package/dist/components/feedback/Toaster/toast.d.ts +96 -0
  44. package/dist/components/feedback/Toaster/toast.js +131 -0
  45. package/dist/components/feedback/Toaster/toast.js.map +1 -0
  46. package/dist/components/inputs/Calendar/Calendar.d.ts +87 -0
  47. package/dist/components/inputs/Calendar/Calendar.js +217 -0
  48. package/dist/components/inputs/Calendar/Calendar.js.map +1 -0
  49. package/dist/components/inputs/Calendar/Calendar.module.js +18 -0
  50. package/dist/components/inputs/Calendar/Calendar.module.js.map +1 -0
  51. package/dist/components/inputs/Calendar/index.d.ts +2 -0
  52. package/dist/components/inputs/Combobox/Combobox.js +36 -44
  53. package/dist/components/inputs/Combobox/Combobox.js.map +1 -1
  54. package/dist/components/inputs/DateField/DateField.d.ts +17 -0
  55. package/dist/components/inputs/DateField/DateField.js +26 -0
  56. package/dist/components/inputs/DateField/DateField.js.map +1 -0
  57. package/dist/components/inputs/DateField/index.d.ts +2 -0
  58. package/dist/components/inputs/DateInput/DateInput.d.ts +75 -0
  59. package/dist/components/inputs/DateInput/DateInput.js +139 -0
  60. package/dist/components/inputs/DateInput/DateInput.js.map +1 -0
  61. package/dist/components/inputs/DateInput/index.d.ts +3 -0
  62. package/dist/components/inputs/DateRangeField/DateRangeField.d.ts +18 -3
  63. package/dist/components/inputs/DateRangeField/DateRangeField.js.map +1 -1
  64. package/dist/components/inputs/DateRangeField/DateRangeField.module.js +8 -3
  65. package/dist/components/inputs/DateRangeField/DateRangeField.module.js.map +1 -1
  66. package/dist/components/inputs/DateRangeField/DateRangePickerField.d.ts +48 -0
  67. package/dist/components/inputs/DateRangeField/DateRangePickerField.js +246 -0
  68. package/dist/components/inputs/DateRangeField/DateRangePickerField.js.map +1 -0
  69. package/dist/components/inputs/DateRangeField/index.d.ts +2 -0
  70. package/dist/components/inputs/DateTimeField/DateTimeField.d.ts +17 -0
  71. package/dist/components/inputs/DateTimeField/DateTimeField.js +26 -0
  72. package/dist/components/inputs/DateTimeField/DateTimeField.js.map +1 -0
  73. package/dist/components/inputs/DateTimeField/index.d.ts +2 -0
  74. package/dist/components/inputs/DateTimeInput/DateTimeInput.d.ts +83 -0
  75. package/dist/components/inputs/DateTimeInput/DateTimeInput.js +216 -0
  76. package/dist/components/inputs/DateTimeInput/DateTimeInput.js.map +1 -0
  77. package/dist/components/inputs/DateTimeInput/index.d.ts +2 -0
  78. package/dist/components/inputs/JsonField/JsonField.d.ts +23 -0
  79. package/dist/components/inputs/JsonField/JsonField.js +33 -0
  80. package/dist/components/inputs/JsonField/JsonField.js.map +1 -0
  81. package/dist/components/inputs/JsonField/index.d.ts +2 -0
  82. package/dist/components/inputs/JsonInput/JsonInput.d.ts +119 -0
  83. package/dist/components/inputs/JsonInput/JsonInput.js +282 -0
  84. package/dist/components/inputs/JsonInput/JsonInput.js.map +1 -0
  85. package/dist/components/inputs/JsonInput/JsonInput.module.js +16 -0
  86. package/dist/components/inputs/JsonInput/JsonInput.module.js.map +1 -0
  87. package/dist/components/inputs/JsonInput/index.d.ts +4 -0
  88. package/dist/components/inputs/JsonInput/json.d.ts +59 -0
  89. package/dist/components/inputs/JsonInput/json.js +231 -0
  90. package/dist/components/inputs/JsonInput/json.js.map +1 -0
  91. package/dist/components/inputs/TagsInput/TagsInput.js +5 -5
  92. package/dist/components/inputs/TimeField/TimeField.d.ts +17 -0
  93. package/dist/components/inputs/TimeField/TimeField.js +26 -0
  94. package/dist/components/inputs/TimeField/TimeField.js.map +1 -0
  95. package/dist/components/inputs/TimeField/index.d.ts +2 -0
  96. package/dist/components/inputs/TimeInput/TimeInput.d.ts +54 -0
  97. package/dist/components/inputs/TimeInput/TimeInput.js +107 -0
  98. package/dist/components/inputs/TimeInput/TimeInput.js.map +1 -0
  99. package/dist/components/inputs/TimeInput/index.d.ts +2 -0
  100. package/dist/components/inputs/internal/DateSegments.d.ts +80 -0
  101. package/dist/components/inputs/internal/DateSegments.js +345 -0
  102. package/dist/components/inputs/internal/DateSegments.js.map +1 -0
  103. package/dist/components/inputs/internal/dates.d.ts +101 -0
  104. package/dist/components/inputs/internal/dates.js +262 -0
  105. package/dist/components/inputs/internal/dates.js.map +1 -0
  106. package/dist/components/inputs/internal/filterOptions.d.ts +22 -1
  107. package/dist/components/inputs/internal/filterOptions.js +32 -1
  108. package/dist/components/inputs/internal/filterOptions.js.map +1 -1
  109. package/dist/components/inputs/internal/picker.d.ts +31 -0
  110. package/dist/components/inputs/internal/picker.js +29 -0
  111. package/dist/components/inputs/internal/picker.js.map +1 -0
  112. package/dist/components/inputs/internal/picker.module.js +15 -0
  113. package/dist/components/inputs/internal/picker.module.js.map +1 -0
  114. package/dist/components/inputs/internal/segments.module.js +10 -0
  115. package/dist/components/inputs/internal/segments.module.js.map +1 -0
  116. package/dist/components/layout/Collapse/Collapse.d.ts +39 -0
  117. package/dist/components/layout/Collapse/Collapse.js +24 -0
  118. package/dist/components/layout/Collapse/Collapse.js.map +1 -0
  119. package/dist/components/layout/Collapse/Collapse.module.js +6 -0
  120. package/dist/components/layout/Collapse/Collapse.module.js.map +1 -0
  121. package/dist/components/layout/Collapse/index.d.ts +2 -0
  122. package/dist/components/layout/Collapse/useHeightMotion.d.ts +16 -0
  123. package/dist/components/layout/Collapse/useHeightMotion.js +60 -0
  124. package/dist/components/layout/Collapse/useHeightMotion.js.map +1 -0
  125. package/dist/components/layout/ShowMore/ShowMore.d.ts +59 -0
  126. package/dist/components/layout/ShowMore/ShowMore.js +114 -0
  127. package/dist/components/layout/ShowMore/ShowMore.js.map +1 -0
  128. package/dist/components/layout/ShowMore/ShowMore.module.js +12 -0
  129. package/dist/components/layout/ShowMore/ShowMore.module.js.map +1 -0
  130. package/dist/components/layout/ShowMore/index.d.ts +2 -0
  131. package/dist/components/layout/Transition/Transition.d.ts +63 -0
  132. package/dist/components/layout/Transition/Transition.js +63 -0
  133. package/dist/components/layout/Transition/Transition.js.map +1 -0
  134. package/dist/components/layout/Transition/Transition.module.js +17 -0
  135. package/dist/components/layout/Transition/Transition.module.js.map +1 -0
  136. package/dist/components/layout/Transition/index.d.ts +2 -0
  137. package/dist/components/navigation/Collapsible/Collapsible.d.ts +49 -0
  138. package/dist/components/navigation/Collapsible/Collapsible.js +83 -0
  139. package/dist/components/navigation/Collapsible/Collapsible.js.map +1 -0
  140. package/dist/components/navigation/Collapsible/Collapsible.module.js +11 -0
  141. package/dist/components/navigation/Collapsible/Collapsible.module.js.map +1 -0
  142. package/dist/components/navigation/Collapsible/index.d.ts +2 -0
  143. package/dist/components/navigation/NavLinks/NavLinks.d.ts +32 -4
  144. package/dist/components/navigation/NavLinks/NavLinks.js +69 -39
  145. package/dist/components/navigation/NavLinks/NavLinks.js.map +1 -1
  146. package/dist/components/navigation/NavLinks/NavLinks.module.js +13 -3
  147. package/dist/components/navigation/NavLinks/NavLinks.module.js.map +1 -1
  148. package/dist/components/navigation/NavLinks/NavLinksGroup.d.ts +49 -0
  149. package/dist/components/navigation/NavLinks/NavLinksGroup.js +185 -0
  150. package/dist/components/navigation/NavLinks/NavLinksGroup.js.map +1 -0
  151. package/dist/components/navigation/NavLinks/context.d.ts +28 -0
  152. package/dist/components/navigation/NavLinks/context.js +13 -0
  153. package/dist/components/navigation/NavLinks/context.js.map +1 -0
  154. package/dist/components/navigation/NavLinks/index.d.ts +2 -0
  155. package/dist/components/navigation/NavLinks/treeKeys.d.ts +8 -0
  156. package/dist/components/navigation/NavLinks/treeKeys.js +57 -0
  157. package/dist/components/navigation/NavLinks/treeKeys.js.map +1 -0
  158. package/dist/components/overlays/CommandPalette/CommandPalette.d.ts +120 -0
  159. package/dist/components/overlays/CommandPalette/CommandPalette.js +386 -0
  160. package/dist/components/overlays/CommandPalette/CommandPalette.js.map +1 -0
  161. package/dist/components/overlays/CommandPalette/CommandPalette.module.js +31 -0
  162. package/dist/components/overlays/CommandPalette/CommandPalette.module.js.map +1 -0
  163. package/dist/components/overlays/CommandPalette/index.d.ts +2 -0
  164. package/dist/components/overlays/CommandPalette/shortcut.d.ts +28 -0
  165. package/dist/components/overlays/CommandPalette/shortcut.js +104 -0
  166. package/dist/components/overlays/CommandPalette/shortcut.js.map +1 -0
  167. package/dist/highlight/index.d.ts +18 -0
  168. package/dist/highlight/index.js +103 -0
  169. package/dist/highlight/index.js.map +1 -0
  170. package/dist/index.d.ts +41 -5
  171. package/dist/index.js +123 -100
  172. package/dist/styles.css +1 -1
  173. package/dist/themes/fiesta.css +1 -1
  174. package/dist/themes/flightdeck.css +1 -1
  175. package/dist/themes/ledger.css +1 -1
  176. package/dist/themes/monograph.css +1 -1
  177. package/dist/themes/riso.css +1 -1
  178. package/dist/utils/newlines.d.ts +2 -0
  179. package/dist/utils/newlines.js +10 -0
  180. package/dist/utils/newlines.js.map +1 -0
  181. package/package.json +13 -2
  182. package/skills/custom-theme/SKILL.md +32 -0
  183. package/skills/custom-theme/references/colour.md +20 -0
  184. package/skills/custom-theme/references/motion.md +9 -0
  185. package/skills/custom-theme/references/tokens.md +35 -0
  186. package/skills/design-rules/SKILL.md +5 -2
  187. package/skills/setup-and-theming/SKILL.md +2 -1
  188. package/skills/setup-and-theming/references/paper.md +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangeField.js","names":["styles","DateRangeField_module_default","EMPTY","DateRangeField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","fieldsetProps","valueProp","restProps","internal","setInternal","useState","defaultValue","value","update","readOnly","nextValue","part","next","onValueChange","handleBlur","event","onBlur","invalid","hasError","required","busy","Fieldset","label","labelHidden","description","hint","cx","className","Field","startLabel","id","Input","name","max","endLabel","min"],"sources":["../../../../src/components/inputs/DateRangeField/DateRangeField.tsx"],"sourcesContent":["import {\n forwardRef,\n useState,\n type FocusEvent,\n type FocusEventHandler,\n type HTMLAttributes,\n} from 'react'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { Fieldset } from '#components/inputs/Fieldset'\nimport { Input } from '#components/inputs/Input'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { hasError } from '#components/inputs/internal/errors'\nimport styles from './DateRangeField.module.css'\n\n/** Two ISO dates (`YYYY-MM-DD`); `''` for an unset end. */\nexport interface DateRangeValue {\n start: string\n end: string\n}\n\nexport interface DateRangeFieldProps\n extends\n FieldLabelProps,\n Omit<\n HTMLAttributes<HTMLFieldSetElement>,\n 'onChange' | 'defaultValue' | 'onBlur' | keyof FieldLabelProps\n > {\n value?: DateRangeValue\n defaultValue?: DateRangeValue\n onValueChange?: (value: DateRangeValue) => void\n /** Earliest date either end may take (`YYYY-MM-DD`). */\n min?: string\n /** Latest date either end may take (`YYYY-MM-DD`). */\n max?: string\n /** Label of the first input. Default `'Start date'`. */\n startLabel?: string\n /** Label of the second input. Default `'End date'`. */\n endLabel?: string\n /** Submits `${name}.start` and `${name}.end`. */\n name?: string\n disabled?: boolean\n readOnly?: boolean\n /** Fires when focus leaves both inputs (not when it moves from start to end). */\n onBlur?: FocusEventHandler\n size?: Size\n}\n\nconst EMPTY: DateRangeValue = { start: '', end: '' }\n\n/**\n * A start and end date as two native date inputs under one legend.\n *\n * @remarks\n * `DateRangeField` is two native date inputs, side by side and wrapping on a phone, under one\n * legend. Native inputs mean the platform's own date picker and its accessibility.\n *\n * @privateRemarks\n * A date range as two native date inputs under one legend, side by side and wrapping\n * when narrow. The start can't pass the end and the end can't come before the start\n * (each input's `min`/`max` follows the other). `id` goes to the start input; the ref to\n * the fieldset.\n *\n * <DateRangeField label=\"Trip dates\" value={dates} onValueChange={setDates} />\n */\nexport const DateRangeField = forwardRef<HTMLFieldSetElement, DateRangeFieldProps>(\n function DateRangeField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n // `layout` goes to the Fieldset (legend column for `horizontal`); the two inputs always\n // sit side by side.\n const { label, labelHidden, hint, description, readOnly = false, ...fieldsetProps } = fieldProps\n const {\n value: valueProp,\n defaultValue,\n onValueChange,\n min,\n max,\n startLabel = 'Start date',\n endLabel = 'End date',\n name,\n disabled = false,\n onBlur,\n size,\n id,\n className,\n ...restProps\n } = rest\n\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue ?? EMPTY)\n const value = valueProp ?? internal\n\n const update = (part: keyof DateRangeValue, next: string) => {\n if (readOnly) return\n const nextValue = { ...value, [part]: next }\n if (valueProp === undefined) setInternal(nextValue)\n onValueChange?.(nextValue)\n }\n\n const handleBlur = (event: FocusEvent<HTMLFieldSetElement>) => {\n if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))\n return\n onBlur?.(event)\n }\n\n const invalid = hasError(fieldsetProps.error) || undefined\n const required = fieldsetProps.required\n const busy = fieldsetProps.validating ? true : undefined\n\n return (\n <Fieldset\n ref={ref}\n {...restProps}\n {...fieldsetProps}\n legend={label}\n legendHidden={labelHidden}\n description={description ?? hint}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(styles.root, className)}\n onBlur={handleBlur}\n >\n <div className={styles.parts}>\n <Field\n label={startLabel}\n htmlFor={id}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n <Input\n id={id}\n type=\"date\"\n size={size}\n name={name != null ? `${name}.start` : undefined}\n value={value.start}\n min={min}\n max={value.end || max}\n required={required}\n aria-busy={busy}\n onChange={(event) => {\n update('start', event.target.value)\n }}\n />\n </Field>\n <Field\n label={endLabel}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n <Input\n type=\"date\"\n size={size}\n name={name != null ? `${name}.end` : undefined}\n value={value.end}\n min={value.start || min}\n max={max}\n required={required}\n aria-busy={busy}\n onChange={(event) => {\n update('end', event.target.value)\n }}\n />\n </Field>\n </div>\n </Fieldset>\n )\n },\n)\n"],"mappings":";;;;;;;;;;AAiDA,IAAME,IAAwB;CAAE,OAAO;CAAI,KAAK;AAAG,GAiBtCC,IAAiBC,EAC5B,SAAwB,GAAO,GAAK;CAClC,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAG/C,EAAE,UAAO,gBAAa,SAAM,gBAAa,cAAW,IAAO,GAAGC,MAAkBJ,GAChF,EACJ,OAAOK,GACP,iBACA,kBACA,QACA,QACA,gBAAa,cACb,cAAW,YACX,SACA,cAAW,IACX,WACA,SACA,OACA,cACA,GAAGC,MACDL,GAEE,CAACM,GAAUC,KAAeC,EAAyBC,KAAgBb,CAAK,GACxEc,IAAQN,KAAaE,GAErBK,KAAU,GAA4B,MAAiB;EAC3D,IAAIC,GAAU;EACd,IAAMC,IAAY;GAAE,GAAGH;IAAQI,IAAOC;EAAK;EAE3C,AADIX,MAAc,KAAA,KAAWG,EAAYM,CAAS,GAClDG,IAAgBH,CAAS;CAC3B,GAEMI,KAAc,MAA2C;EAC7D,AAAIC,EAAM,yBAAyB,QAAQA,EAAM,cAAc,SAASA,EAAM,aAAa,KAE3FC,IAASD,CAAK;CAChB,GAEME,IAAUC,EAASlB,EAAc,KAAK,KAAK,KAAA,GAC3CmB,IAAWnB,EAAc,UACzBoB,IAAOpB,EAAc,aAAa,KAAO,KAAA;CAE/C,OACE,kBAACqB,GAAD;EACO;EACL,GAAInB;EACJ,GAAIF;EACJ,QAAQsB;EACR,cAAcC;EACd,aAAaC,KAAeC;EAClB;EACA;EACV,WAAWC,EAAGnC,EAAO,MAAMoC,CAAS;EACpC,QAAQb;EAER,UAAA,kBAAC,OAAD;GAAK,WAAWvB,EAAO;GAAvB,UAAA,CACE,kBAACqC,GAAD;IACE,OAAOC;IACP,SAASC;IACT,WAAWvC,EAAO;IAClB,OAAO0B;IACP,aAAA;IACU;IACA;IAEV,UAAA,kBAACc,GAAD;KACM;KACJ,MAAK;KACC;KACN,MAAMC,KAAQ,OAAyB,KAAA,IAAlB,GAAGA,EAAK;KAC7B,OAAOzB,EAAM;KACR;KACL,KAAKA,EAAM,OAAO0B;KACR;KACV,aAAWb;KACX,WAAW,MAAU;MACnB,EAAO,SAASL,EAAM,OAAO,KAAK;KACpC;IACD,CAAA;GACI,CAAA,GACP,kBAACa,GAAD;IACE,OAAOM;IACP,WAAW3C,EAAO;IAClB,OAAO0B;IACP,aAAA;IACU;IACA;IAEV,UAAA,kBAACc,GAAD;KACE,MAAK;KACC;KACN,MAAMC,KAAQ,OAAuB,KAAA,IAAhB,GAAGA,EAAK;KAC7B,OAAOzB,EAAM;KACb,KAAKA,EAAM,SAAS4B;KACf;KACK;KACV,aAAWf;KACX,WAAW,MAAU;MACnB,EAAO,OAAOL,EAAM,OAAO,KAAK;KAClC;IACD,CAAA;GACI,CAAA,CACJ;;CACG,CAAA;AAEd,CACF"}
1
+ {"version":3,"file":"DateRangeField.js","names":["styles","DateRangeField_module_default","EMPTY","DateRangeField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","fieldsetProps","valueProp","restProps","internal","setInternal","useState","defaultValue","value","update","readOnly","nextValue","part","next","onValueChange","handleBlur","event","onBlur","invalid","hasError","required","busy","Fieldset","label","labelHidden","description","hint","cx","className","Field","startLabel","id","Input","name","max","endLabel","min"],"sources":["../../../../src/components/inputs/DateRangeField/DateRangeField.tsx"],"sourcesContent":["import {\n forwardRef,\n useState,\n type FocusEvent,\n type FocusEventHandler,\n type HTMLAttributes,\n} from 'react'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { Fieldset } from '#components/inputs/Fieldset'\nimport { Input } from '#components/inputs/Input'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { hasError } from '#components/inputs/internal/errors'\nimport styles from './DateRangeField.module.css'\n\n/**\n * Two ISO dates (`YYYY-MM-DD`); `''` for an unset end. With a time `granularity` on\n * `DateRangePickerField`, each end is a date-time in the same form as\n * {@link DateTimeInput | DateTimeInput}'s value.\n */\nexport interface DateRangeValue {\n start: string\n end: string\n}\n\nexport interface DateRangeFieldProps\n extends\n FieldLabelProps,\n Omit<\n HTMLAttributes<HTMLFieldSetElement>,\n 'onChange' | 'defaultValue' | 'onBlur' | keyof FieldLabelProps\n > {\n value?: DateRangeValue\n defaultValue?: DateRangeValue\n onValueChange?: (value: DateRangeValue) => void\n /** Earliest date either end may take (`YYYY-MM-DD`). */\n min?: string\n /** Latest date either end may take (`YYYY-MM-DD`). */\n max?: string\n /** Label of the first input. Default `'Start date'`. */\n startLabel?: string\n /** Label of the second input. Default `'End date'`. */\n endLabel?: string\n /** Submits `${name}.start` and `${name}.end`. */\n name?: string\n disabled?: boolean\n readOnly?: boolean\n /** Fires when focus leaves both inputs (not when it moves from start to end). */\n onBlur?: FocusEventHandler\n size?: Size\n}\n\nconst EMPTY: DateRangeValue = { start: '', end: '' }\n\n/**\n * A start and end date under one legend: two native date inputs, or with `DateRangePickerField`\n * typed dates with one calendar for the range, optional times and preset ranges.\n *\n * @remarks\n * `DateRangeField` is two native date inputs, side by side and wrapping on a phone, under one\n * legend. Native inputs mean the platform's own date picker and its accessibility.\n *\n * `DateRangePickerField` takes the same props and types the two ends like\n * {@link DateInput | DateInput}, and one button opens a two-month {@link Calendar | Calendar}: the\n * first pick sets the start, the second the end. `granularity=\"minute\"` adds a time to each end (a\n * new range runs from the start of its first day to the end of its last), and `presets` lists\n * ranges such as \"Last 7 days\" beside the calendar. It's a separate import, so a native\n * `DateRangeField` doesn't carry the calendar.\n *\n * Whichever you use, the start can't pass the end and the end can't come before the start.\n *\n * @privateRemarks\n * A date range as two native date inputs under one legend, side by side and wrapping\n * when narrow. The start can't pass the end and the end can't come before the start\n * (each input's `min`/`max` follows the other). `id` goes to the start input; the ref to\n * the fieldset. The calendar picker is its own component, DateRangePickerField, so the native\n * markup, behaviour and import size stay exactly as they were for existing callers (ADR 0044).\n *\n * <DateRangeField label=\"Trip dates\" value={dates} onValueChange={setDates} />\n */\nexport const DateRangeField = forwardRef<HTMLFieldSetElement, DateRangeFieldProps>(\n function DateRangeField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n // `layout` goes to the Fieldset (legend column for `horizontal`); the two inputs always\n // sit side by side.\n const { label, labelHidden, hint, description, readOnly = false, ...fieldsetProps } = fieldProps\n const {\n value: valueProp,\n defaultValue,\n onValueChange,\n min,\n max,\n startLabel = 'Start date',\n endLabel = 'End date',\n name,\n disabled = false,\n onBlur,\n size,\n id,\n className,\n ...restProps\n } = rest\n\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue ?? EMPTY)\n const value = valueProp ?? internal\n\n const update = (part: keyof DateRangeValue, next: string) => {\n if (readOnly) return\n const nextValue = { ...value, [part]: next }\n if (valueProp === undefined) setInternal(nextValue)\n onValueChange?.(nextValue)\n }\n\n const handleBlur = (event: FocusEvent<HTMLFieldSetElement>) => {\n if (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))\n return\n onBlur?.(event)\n }\n\n const invalid = hasError(fieldsetProps.error) || undefined\n const required = fieldsetProps.required\n const busy = fieldsetProps.validating ? true : undefined\n\n return (\n <Fieldset\n ref={ref}\n {...restProps}\n {...fieldsetProps}\n legend={label}\n legendHidden={labelHidden}\n description={description ?? hint}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(styles.root, className)}\n onBlur={handleBlur}\n >\n <div className={styles.parts}>\n <Field\n label={startLabel}\n htmlFor={id}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n <Input\n id={id}\n type=\"date\"\n size={size}\n name={name != null ? `${name}.start` : undefined}\n value={value.start}\n min={min}\n max={value.end || max}\n required={required}\n aria-busy={busy}\n onChange={(event) => {\n update('start', event.target.value)\n }}\n />\n </Field>\n <Field\n label={endLabel}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n <Input\n type=\"date\"\n size={size}\n name={name != null ? `${name}.end` : undefined}\n value={value.end}\n min={value.start || min}\n max={max}\n required={required}\n aria-busy={busy}\n onChange={(event) => {\n update('end', event.target.value)\n }}\n />\n </Field>\n </div>\n </Fieldset>\n )\n },\n)\n"],"mappings":";;;;;;;;;;AAqDA,IAAME,IAAwB;CAAE,OAAO;CAAI,KAAK;AAAG,GA4BtCC,IAAiBC,EAC5B,SAAwB,GAAO,GAAK;CAClC,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAG/C,EAAE,UAAO,gBAAa,SAAM,gBAAa,cAAW,IAAO,GAAGC,MAAkBJ,GAChF,EACJ,OAAOK,GACP,iBACA,kBACA,QACA,QACA,gBAAa,cACb,cAAW,YACX,SACA,cAAW,IACX,WACA,SACA,OACA,cACA,GAAGC,MACDL,GAEE,CAACM,GAAUC,KAAeC,EAAyBC,KAAgBb,CAAK,GACxEc,IAAQN,KAAaE,GAErBK,KAAU,GAA4B,MAAiB;EAC3D,IAAIC,GAAU;EACd,IAAMC,IAAY;GAAE,GAAGH;IAAQI,IAAOC;EAAK;EAE3C,AADIX,MAAc,KAAA,KAAWG,EAAYM,CAAS,GAClDG,IAAgBH,CAAS;CAC3B,GAEMI,KAAc,MAA2C;EAC7D,AAAIC,EAAM,yBAAyB,QAAQA,EAAM,cAAc,SAASA,EAAM,aAAa,KAE3FC,IAASD,CAAK;CAChB,GAEME,IAAUC,EAASlB,EAAc,KAAK,KAAK,KAAA,GAC3CmB,IAAWnB,EAAc,UACzBoB,IAAOpB,EAAc,aAAa,KAAO,KAAA;CAE/C,OACE,kBAACqB,GAAD;EACO;EACL,GAAInB;EACJ,GAAIF;EACJ,QAAQsB;EACR,cAAcC;EACd,aAAaC,KAAeC;EAClB;EACA;EACV,WAAWC,EAAGnC,EAAO,MAAMoC,CAAS;EACpC,QAAQb;EAER,UAAA,kBAAC,OAAD;GAAK,WAAWvB,EAAO;GAAvB,UAAA,CACE,kBAACqC,GAAD;IACE,OAAOC;IACP,SAASC;IACT,WAAWvC,EAAO;IAClB,OAAO0B;IACP,aAAA;IACU;IACA;IAEV,UAAA,kBAACc,GAAD;KACM;KACJ,MAAK;KACC;KACN,MAAMC,KAAQ,OAAyB,KAAA,IAAlB,GAAGA,EAAK;KAC7B,OAAOzB,EAAM;KACR;KACL,KAAKA,EAAM,OAAO0B;KACR;KACV,aAAWb;KACX,WAAW,MAAU;MACnB,EAAO,SAASL,EAAM,OAAO,KAAK;KACpC;IACD,CAAA;GACI,CAAA,GACP,kBAACa,GAAD;IACE,OAAOM;IACP,WAAW3C,EAAO;IAClB,OAAO0B;IACP,aAAA;IACU;IACA;IAEV,UAAA,kBAACc,GAAD;KACE,MAAK;KACC;KACN,MAAMC,KAAQ,OAAuB,KAAA,IAAhB,GAAGA,EAAK;KAC7B,OAAOzB,EAAM;KACb,KAAKA,EAAM,SAAS4B;KACf;KACK;KACV,aAAWf;KACX,WAAW,MAAU;MACnB,EAAO,OAAOL,EAAM,OAAO,KAAK;KAClC;IACD,CAAA;GACI,CAAA,CACJ;;CACG,CAAA;AAEd,CACF"}
@@ -1,10 +1,15 @@
1
1
  //#region src/components/inputs/DateRangeField/DateRangeField.module.css
2
- var e = "kiln-DateRangeField__root", t = "kiln-DateRangeField__parts", n = "kiln-DateRangeField__part", r = {
2
+ var e = "kiln-DateRangeField__root", t = "kiln-DateRangeField__parts", n = "kiln-DateRangeField__part", r = "kiln-DateRangeField__trigger", i = "kiln-DateRangeField__panel", a = "kiln-DateRangeField__presets", o = "kiln-DateRangeField__preset", s = "kiln-DateRangeField__times", c = {
3
3
  root: e,
4
4
  parts: t,
5
- part: n
5
+ part: n,
6
+ trigger: r,
7
+ panel: i,
8
+ presets: a,
9
+ preset: o,
10
+ times: s
6
11
  };
7
12
  //#endregion
8
- export { r as default, n as part, t as parts, e as root };
13
+ export { c as default, i as panel, n as part, t as parts, o as preset, a as presets, e as root, s as times, r as trigger };
9
14
 
10
15
  //# sourceMappingURL=DateRangeField.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangeField.module.js","names":["root","parts","part","DateRangeField_module_default"],"sources":["../../../../src/components/inputs/DateRangeField/DateRangeField.module.css"],"sourcesContent":["/*\n * Start and end side by side, each at least --space-11 wide, wrapping to a stack when the\n * column is narrower than both.\n */\n.root {\n min-inline-size: 0;\n}\n\n.parts {\n display: flex;\n flex-wrap: wrap;\n gap: var(--space-3);\n}\n\n.part {\n flex: 1 1 var(--space-11);\n min-inline-size: 0;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"DateRangeField.module.js","names":["root","parts","part","trigger","panel","presets","preset","times","DateRangeField_module_default"],"sources":["../../../../src/components/inputs/DateRangeField/DateRangeField.module.css"],"sourcesContent":["/*\n * Start and end side by side, each at least --space-11 wide, wrapping to a stack when the\n * column is narrower than both.\n */\n.root {\n min-inline-size: 0;\n}\n\n.parts {\n display: flex;\n flex-wrap: wrap;\n gap: var(--space-3);\n}\n\n.part {\n flex: 1 1 var(--space-11);\n min-inline-size: 0;\n}\n\n/* Calendar picker: one calendar button after the two ends, level with their boxes. */\n.trigger {\n flex: none;\n align-self: flex-end;\n}\n\n.panel {\n display: flex;\n flex-wrap: wrap;\n gap: var(--space-4);\n}\n\n.presets {\n display: flex;\n flex-direction: column;\n gap: var(--space-1);\n min-inline-size: 9rem;\n padding-inline-end: var(--space-4);\n border-inline-end: var(--border-width) solid var(--color-line);\n}\n\n.preset {\n justify-content: flex-start;\n}\n.preset[aria-pressed='true'] {\n background-color: var(--color-accent-soft);\n}\n\n.times {\n display: flex;\n flex-direction: column;\n gap: var(--space-2);\n}\n"],"mappings":""}
@@ -0,0 +1,48 @@
1
+ import { type TimeGranularity } from '../internal/dates.js';
2
+ import { type DateTimeLabels } from '../internal/picker.js';
3
+ import type { DateRangeFieldProps, DateRangeValue } from './DateRangeField.js';
4
+ /** A range offered beside the calendar: "Last 7 days", "This month". */
5
+ export interface DateRangePreset {
6
+ label: string;
7
+ /**
8
+ * The range, or a function that works it out when picked (so "today" is always today). With a
9
+ * time `granularity`, a date-only end runs from the start of its first day to the end of its last.
10
+ */
11
+ value: DateRangeValue | (() => DateRangeValue);
12
+ }
13
+ export interface DateRangePickerFieldProps extends DateRangeFieldProps {
14
+ /** `day` (default), or `minute`/`second` to give each end a time. */
15
+ granularity?: 'day' | TimeGranularity;
16
+ /** Ranges to offer beside the calendar. */
17
+ presets?: readonly DateRangePreset[];
18
+ /** Show a clear button in each input. */
19
+ clearable?: boolean;
20
+ /** Marks dates unavailable. */
21
+ isDateDisabled?: (date: string) => boolean;
22
+ /** 0 (Sunday) to 6 (Saturday). Defaults to the locale's week. */
23
+ firstDayOfWeek?: number;
24
+ /** BCP 47 locale for the parts and names. Default `en-AU`. */
25
+ locale?: string;
26
+ /**
27
+ * The zone "today" is read in. With a time `granularity`, each end becomes a UTC instant typed as
28
+ * this zone's clock, as in {@link DateTimeInput | DateTimeInput}.
29
+ */
30
+ timeZone?: string;
31
+ /** With a time `granularity`: 12 or 24. Defaults to the locale's clock. */
32
+ hourCycle?: 12 | 24;
33
+ /** Words for another language or wording. */
34
+ labels?: Partial<DateTimeLabels>;
35
+ }
36
+ /**
37
+ * A start and end date typed part by part under one legend, with one two-month calendar for the
38
+ * range, optional times and preset ranges.
39
+ *
40
+ * @privateRemarks
41
+ * The calendar picker for a range, documented on {@link DateRangeField | DateRangeField}'s page. It
42
+ * is a separate export rather than a `picker` prop on DateRangeField, so importing DateRangeField
43
+ * alone doesn't bring Popover, Calendar and the typed inputs (ADR 0044). The ref goes to the
44
+ * fieldset and `id` to the start input, as in DateRangeField.
45
+ *
46
+ * <DateRangePickerField label="Stay" presets={presets} value={dates} onValueChange={setDates} />
47
+ */
48
+ export declare const DateRangePickerField: import("react").ForwardRefExoticComponent<DateRangePickerFieldProps & import("react").RefAttributes<HTMLFieldSetElement>>;
@@ -0,0 +1,246 @@
1
+ import { cx as e } from "../../../utils/cx.js";
2
+ import { CalendarIcon as t } from "../../../icons/icons.js";
3
+ import { Button as n } from "../../actions/Button/Button.js";
4
+ import { IconButton as r } from "../../actions/IconButton/IconButton.js";
5
+ import { FieldContext as ee } from "../internal/FieldContext.js";
6
+ import { hasError as te } from "../internal/errors.js";
7
+ import { Field as i } from "../Field/Field.js";
8
+ import { Fieldset as ne } from "../Fieldset/Fieldset.js";
9
+ import { splitFieldLabelProps as re } from "../internal/fieldProps.js";
10
+ import a from "./DateRangeField.module.js";
11
+ import { Popover as o } from "../../overlays/Popover/Popover.js";
12
+ import { DEFAULT_LOCALE as ie, dateOf as s, defaultHourCycle as ae, formatDate as c, formatDateTime as oe, formatTime as se, parseDate as l, parseDateTime as ce, parseTime as le } from "../internal/dates.js";
13
+ import { Calendar as ue } from "../Calendar/Calendar.js";
14
+ import { DEFAULT_DATE_TIME_LABELS as de } from "../internal/picker.js";
15
+ import u from "../internal/picker.module.js";
16
+ import { DateInput as d } from "../DateInput/DateInput.js";
17
+ import { TimeInput as fe } from "../TimeInput/TimeInput.js";
18
+ import { DateTimeInput as f } from "../DateTimeInput/DateTimeInput.js";
19
+ import { forwardRef as p, useRef as pe, useState as m } from "react";
20
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
21
+ //#region src/components/inputs/DateRangeField/DateRangePickerField.tsx
22
+ var me = {
23
+ start: "",
24
+ end: ""
25
+ }, _ = {
26
+ hour: 0,
27
+ minute: 0,
28
+ second: 0
29
+ }, v = {
30
+ hour: 23,
31
+ minute: 59,
32
+ second: 59
33
+ }, he = (e) => typeof e.value == "function" ? e.value() : e.value, y = p(function(p, y) {
34
+ let [ge, _e] = re(p), { label: ve, labelHidden: ye, hint: be, description: xe, readOnly: b = !1, ...x } = ge, { value: S, defaultValue: Se, onValueChange: Ce, min: C, max: w, startLabel: we = "Start date", endLabel: Te = "End date", name: T, disabled: E = !1, onBlur: Ee, size: D, id: O, className: De, granularity: k = "day", presets: A, clearable: Oe = !1, isDateDisabled: j, firstDayOfWeek: M, locale: N = ie, timeZone: P, hourCycle: F, labels: ke, ...Ae } = _e, [je, Me] = m(Se ?? me), [Ne, I] = m(!1), L = pe(null), R = S ?? je, z = (e) => {
35
+ b || (S === void 0 && Me(e), Ce?.(e));
36
+ }, B = (e, t) => {
37
+ z({
38
+ ...R,
39
+ [e]: t
40
+ });
41
+ }, Pe = (e) => {
42
+ let t = e.relatedTarget;
43
+ t instanceof Node && (e.currentTarget.contains(t) || L.current?.contains(t)) || Ee?.(e);
44
+ }, V = te(x.error) || void 0, Fe = x.required, Ie = x.validating ? !0 : void 0, H = {
45
+ ...de,
46
+ ...ke
47
+ }, U = k !== "day", W = k === "second" ? "second" : "minute", G = F ?? ae(N), K = !E && !b, q = s(R.start, P), J = s(R.end, P), Y = (e) => ce(e, P)?.time ?? null, X = (e, t) => {
48
+ let n = l(e);
49
+ return n ? oe({
50
+ date: n,
51
+ time: t
52
+ }, W, P) : "";
53
+ }, Le = J ? c(J) : w, Re = q ? c(q) : C, Z = (e, t) => U && e ? X(e, t) : e, ze = (e) => {
54
+ if (!U) {
55
+ z(e), e.start && e.end && I(!1);
56
+ return;
57
+ }
58
+ z({
59
+ start: e.start ? X(e.start, Y(R.start) ?? _) : "",
60
+ end: e.end ? X(e.end, Y(R.end) ?? v) : ""
61
+ });
62
+ }, Q = (e) => {
63
+ let t = he(e);
64
+ return U ? {
65
+ start: l(t.start) ? X(t.start, _) : t.start,
66
+ end: l(t.end) ? X(t.end, v) : t.end
67
+ } : t;
68
+ }, Be = (e, t) => {
69
+ let n = le(t), r = e === "start" ? q : J;
70
+ n && r && B(e, X(c(r), n));
71
+ }, $ = (e) => ({
72
+ size: D,
73
+ name: T == null ? void 0 : `${T}.${e}`,
74
+ value: R[e],
75
+ required: Fe,
76
+ clearable: Oe,
77
+ isDateDisabled: j,
78
+ firstDayOfWeek: M,
79
+ locale: N,
80
+ timeZone: P,
81
+ labels: H,
82
+ calendar: !1,
83
+ "aria-busy": Ie,
84
+ onValueChange: (t) => {
85
+ B(e, t);
86
+ }
87
+ });
88
+ return /* @__PURE__ */ h(ne, {
89
+ ref: y,
90
+ ...Ae,
91
+ ...x,
92
+ legend: ve,
93
+ legendHidden: ye,
94
+ description: xe ?? be,
95
+ disabled: E,
96
+ readOnly: b,
97
+ className: e(a.root, De),
98
+ onBlur: Pe,
99
+ "data-picker": "calendar",
100
+ children: /* @__PURE__ */ g(o, {
101
+ open: Ne && K,
102
+ onOpenChange: I,
103
+ children: [/* @__PURE__ */ h(o.Anchor, {
104
+ asChild: !0,
105
+ children: /* @__PURE__ */ g("div", {
106
+ className: a.parts,
107
+ children: [
108
+ /* @__PURE__ */ h(i, {
109
+ label: we,
110
+ htmlFor: O,
111
+ className: a.part,
112
+ error: V,
113
+ errorHidden: !0,
114
+ disabled: E,
115
+ readOnly: b,
116
+ children: U ? /* @__PURE__ */ h(f, {
117
+ id: O,
118
+ ...$("start"),
119
+ granularity: W,
120
+ hourCycle: G,
121
+ min: Z(C, _),
122
+ max: R.end || Z(w, v)
123
+ }) : /* @__PURE__ */ h(d, {
124
+ id: O,
125
+ ...$("start"),
126
+ min: C,
127
+ max: Le
128
+ })
129
+ }),
130
+ /* @__PURE__ */ h(i, {
131
+ label: Te,
132
+ className: a.part,
133
+ error: V,
134
+ errorHidden: !0,
135
+ disabled: E,
136
+ readOnly: b,
137
+ children: U ? /* @__PURE__ */ h(f, {
138
+ ...$("end"),
139
+ granularity: W,
140
+ hourCycle: G,
141
+ min: R.start || Z(C, _),
142
+ max: Z(w, v)
143
+ }) : /* @__PURE__ */ h(d, {
144
+ ...$("end"),
145
+ min: Re,
146
+ max: w
147
+ })
148
+ }),
149
+ /* @__PURE__ */ h(o.Trigger, {
150
+ asChild: !0,
151
+ children: /* @__PURE__ */ h(r, {
152
+ className: a.trigger,
153
+ variant: "outline",
154
+ size: D,
155
+ shape: "square",
156
+ label: H.openCalendar,
157
+ icon: /* @__PURE__ */ h(t, {}),
158
+ disabled: !K
159
+ })
160
+ })
161
+ ]
162
+ })
163
+ }), /* @__PURE__ */ h(o.Content, {
164
+ ref: L,
165
+ className: u.popover,
166
+ align: "end",
167
+ "aria-label": H.openCalendar,
168
+ onOpenAutoFocus: (e) => {
169
+ e.preventDefault();
170
+ },
171
+ children: /* @__PURE__ */ h(ee.Provider, {
172
+ value: null,
173
+ children: /* @__PURE__ */ g("div", {
174
+ className: a.panel,
175
+ children: [A && A.length > 0 ? /* @__PURE__ */ h("div", {
176
+ role: "group",
177
+ "aria-label": H.presets,
178
+ className: a.presets,
179
+ children: A.map((e) => {
180
+ let t = Q(e), r = t.start === R.start && t.end === R.end;
181
+ return /* @__PURE__ */ h(n, {
182
+ variant: "ghost",
183
+ size: "sm",
184
+ className: a.preset,
185
+ "aria-pressed": r,
186
+ onClick: () => {
187
+ z(Q(e)), I(!1);
188
+ },
189
+ children: e.label
190
+ }, e.label);
191
+ })
192
+ }) : null, /* @__PURE__ */ g("div", {
193
+ className: u.panel,
194
+ children: [/* @__PURE__ */ h(ue, {
195
+ mode: "range",
196
+ months: 2,
197
+ autoFocus: !0,
198
+ value: {
199
+ start: q ? c(q) : "",
200
+ end: J ? c(J) : ""
201
+ },
202
+ min: C,
203
+ max: w,
204
+ isDateDisabled: j,
205
+ firstDayOfWeek: M,
206
+ locale: N,
207
+ timeZone: P,
208
+ labels: H,
209
+ onValueChange: ze
210
+ }), U ? /* @__PURE__ */ h("div", {
211
+ className: a.times,
212
+ children: ["start", "end"].map((e) => {
213
+ let t = Y(R[e]);
214
+ return /* @__PURE__ */ g("div", {
215
+ className: u.timeRow,
216
+ children: [/* @__PURE__ */ h("span", {
217
+ className: u.timeLabel,
218
+ "aria-hidden": "true",
219
+ children: e === "start" ? H.startTime : H.endTime
220
+ }), /* @__PURE__ */ h(fe, {
221
+ "aria-label": e === "start" ? H.startTime : H.endTime,
222
+ value: t ? se(t, W) : "",
223
+ granularity: W,
224
+ hourCycle: G,
225
+ locale: N,
226
+ size: "sm",
227
+ labels: H,
228
+ disabled: (e === "start" ? q : J) === null,
229
+ onValueChange: (t) => {
230
+ Be(e, t);
231
+ }
232
+ })]
233
+ }, e);
234
+ })
235
+ }) : null]
236
+ })]
237
+ })
238
+ })
239
+ })]
240
+ })
241
+ });
242
+ });
243
+ //#endregion
244
+ export { y as DateRangePickerField };
245
+
246
+ //# sourceMappingURL=DateRangePickerField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangePickerField.js","names":["styles","picker","DateRangeField_module_default","picker_module_default","EMPTY","MIDNIGHT","LAST_SECOND","resolvePreset","preset","DateRangePickerField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","fieldsetProps","valueProp","DEFAULT_LOCALE","labelsProp","restProps","internal","setInternal","useState","defaultValue","open","setOpen","panelRef","useRef","value","setRange","readOnly","nextValue","onValueChange","update","part","next","handleBlur","event","onBlur","invalid","hasError","required","busy","labels","DEFAULT_DATE_TIME_LABELS","withTime","granularity","timeGranularity","clock","hourCycle","defaultHourCycle","locale","interactive","disabled","startDate","dateOf","timeZone","endDate","timeOf","parseDateTime","text","join","day","parseDate","date","formatDateTime","startMax","formatDate","max","endMin","min","boundOf","time","pickRange","presetRange","range","setTime","parseTime","partProps","name","Fieldset","label","labelHidden","description","hint","cx","className","Popover","Field","startLabel","id","DateTimeInput","DateInput","endLabel","IconButton","CalendarIcon","FieldContext","presets","current","Button","Calendar","TimeInput","formatTime"],"sources":["../../../../src/components/inputs/DateRangeField/DateRangePickerField.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type FocusEvent } from 'react'\nimport { CalendarIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport { Button } from '#components/actions/Button'\nimport { IconButton } from '#components/actions/IconButton'\nimport { Popover } from '#components/overlays/Popover'\nimport { Calendar } from '#components/inputs/Calendar'\nimport { DateInput } from '#components/inputs/DateInput'\nimport { DateTimeInput } from '#components/inputs/DateTimeInput'\nimport { Field } from '#components/inputs/Field'\nimport { Fieldset } from '#components/inputs/Fieldset'\nimport { TimeInput } from '#components/inputs/TimeInput'\nimport { FieldContext } from '#components/inputs/internal/FieldContext'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { hasError } from '#components/inputs/internal/errors'\nimport {\n DEFAULT_LOCALE,\n dateOf,\n defaultHourCycle,\n formatDate,\n formatDateTime,\n formatTime,\n parseDate,\n parseDateTime,\n parseTime,\n type TimeGranularity,\n type TimeOfDay,\n} from '#components/inputs/internal/dates'\nimport { DEFAULT_DATE_TIME_LABELS, type DateTimeLabels } from '#components/inputs/internal/picker'\nimport picker from '#components/inputs/internal/picker.module.css'\nimport type { DateRangeFieldProps, DateRangeValue } from './DateRangeField'\nimport styles from './DateRangeField.module.css'\n\n/** A range offered beside the calendar: \"Last 7 days\", \"This month\". */\nexport interface DateRangePreset {\n label: string\n /**\n * The range, or a function that works it out when picked (so \"today\" is always today). With a\n * time `granularity`, a date-only end runs from the start of its first day to the end of its last.\n */\n value: DateRangeValue | (() => DateRangeValue)\n}\n\nexport interface DateRangePickerFieldProps extends DateRangeFieldProps {\n /** `day` (default), or `minute`/`second` to give each end a time. */\n granularity?: 'day' | TimeGranularity\n /** Ranges to offer beside the calendar. */\n presets?: readonly DateRangePreset[]\n /** Show a clear button in each input. */\n clearable?: boolean\n /** Marks dates unavailable. */\n isDateDisabled?: (date: string) => boolean\n /** 0 (Sunday) to 6 (Saturday). Defaults to the locale's week. */\n firstDayOfWeek?: number\n /** BCP 47 locale for the parts and names. Default `en-AU`. */\n locale?: string\n /**\n * The zone \"today\" is read in. With a time `granularity`, each end becomes a UTC instant typed as\n * this zone's clock, as in {@link DateTimeInput | DateTimeInput}.\n */\n timeZone?: string\n /** With a time `granularity`: 12 or 24. Defaults to the locale's clock. */\n hourCycle?: 12 | 24\n /** Words for another language or wording. */\n labels?: Partial<DateTimeLabels>\n}\n\nconst EMPTY: DateRangeValue = { start: '', end: '' }\nconst MIDNIGHT: TimeOfDay = { hour: 0, minute: 0, second: 0 }\nconst LAST_SECOND: TimeOfDay = { hour: 23, minute: 59, second: 59 }\n\nconst resolvePreset = (preset: DateRangePreset): DateRangeValue =>\n typeof preset.value === 'function' ? preset.value() : preset.value\n\n/**\n * A start and end date typed part by part under one legend, with one two-month calendar for the\n * range, optional times and preset ranges.\n *\n * @privateRemarks\n * The calendar picker for a range, documented on {@link DateRangeField | DateRangeField}'s page. It\n * is a separate export rather than a `picker` prop on DateRangeField, so importing DateRangeField\n * alone doesn't bring Popover, Calendar and the typed inputs (ADR 0044). The ref goes to the\n * fieldset and `id` to the start input, as in DateRangeField.\n *\n * <DateRangePickerField label=\"Stay\" presets={presets} value={dates} onValueChange={setDates} />\n */\nexport const DateRangePickerField = forwardRef<HTMLFieldSetElement, DateRangePickerFieldProps>(\n function DateRangePickerField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n // `layout` goes to the Fieldset (legend column for `horizontal`); the two inputs always\n // sit side by side.\n const { label, labelHidden, hint, description, readOnly = false, ...fieldsetProps } = fieldProps\n const {\n value: valueProp,\n defaultValue,\n onValueChange,\n min,\n max,\n startLabel = 'Start date',\n endLabel = 'End date',\n name,\n disabled = false,\n onBlur,\n size,\n id,\n className,\n granularity = 'day',\n presets,\n clearable = false,\n isDateDisabled,\n firstDayOfWeek,\n locale = DEFAULT_LOCALE,\n timeZone,\n hourCycle,\n labels: labelsProp,\n ...restProps\n } = rest\n\n const [internal, setInternal] = useState<DateRangeValue>(defaultValue ?? EMPTY)\n const [open, setOpen] = useState(false)\n const panelRef = useRef<HTMLDivElement>(null)\n const value = valueProp ?? internal\n\n const setRange = (nextValue: DateRangeValue) => {\n if (readOnly) return\n if (valueProp === undefined) setInternal(nextValue)\n onValueChange?.(nextValue)\n }\n const update = (part: keyof DateRangeValue, next: string) => {\n setRange({ ...value, [part]: next })\n }\n\n const handleBlur = (event: FocusEvent<HTMLFieldSetElement>) => {\n const next = event.relatedTarget\n if (\n next instanceof Node &&\n (event.currentTarget.contains(next) || panelRef.current?.contains(next))\n )\n return\n onBlur?.(event)\n }\n\n const invalid = hasError(fieldsetProps.error) || undefined\n const required = fieldsetProps.required\n const busy = fieldsetProps.validating ? true : undefined\n\n const labels = { ...DEFAULT_DATE_TIME_LABELS, ...labelsProp }\n const withTime = granularity !== 'day'\n const timeGranularity: TimeGranularity = granularity === 'second' ? 'second' : 'minute'\n const clock = hourCycle ?? defaultHourCycle(locale)\n const interactive = !disabled && !readOnly\n const startDate = dateOf(value.start, timeZone)\n const endDate = dateOf(value.end, timeZone)\n const timeOf = (text: string) => parseDateTime(text, timeZone)?.time ?? null\n const join = (date: string, time: TimeOfDay) => {\n const day = parseDate(date)\n return day ? formatDateTime({ date: day, time }, timeGranularity, timeZone) : ''\n }\n // An end's date bounds the other end's calendar and typing; its time doesn't.\n const startMax = endDate ? formatDate(endDate) : max\n const endMin = startDate ? formatDate(startDate) : min\n const boundOf = (date: string | undefined, time: TimeOfDay) =>\n withTime && date ? join(date, time) : date\n\n const pickRange = (next: DateRangeValue) => {\n if (!withTime) {\n setRange(next)\n if (next.start && next.end) setOpen(false)\n return\n }\n setRange({\n start: next.start ? join(next.start, timeOf(value.start) ?? MIDNIGHT) : '',\n end: next.end ? join(next.end, timeOf(value.end) ?? LAST_SECOND) : '',\n })\n }\n const presetRange = (preset: DateRangePreset): DateRangeValue => {\n const range = resolvePreset(preset)\n if (!withTime) return range\n return {\n start: parseDate(range.start) ? join(range.start, MIDNIGHT) : range.start,\n end: parseDate(range.end) ? join(range.end, LAST_SECOND) : range.end,\n }\n }\n const setTime = (part: keyof DateRangeValue, text: string) => {\n const time = parseTime(text)\n const date = part === 'start' ? startDate : endDate\n if (time && date) update(part, join(formatDate(date), time))\n }\n\n const partProps = (part: keyof DateRangeValue) => ({\n size,\n name: name != null ? `${name}.${part}` : undefined,\n value: value[part],\n required,\n clearable,\n isDateDisabled,\n firstDayOfWeek,\n locale,\n timeZone,\n labels,\n calendar: false,\n 'aria-busy': busy,\n onValueChange: (next: string) => {\n update(part, next)\n },\n })\n\n return (\n <Fieldset\n ref={ref}\n {...restProps}\n {...fieldsetProps}\n legend={label}\n legendHidden={labelHidden}\n description={description ?? hint}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(styles.root, className)}\n onBlur={handleBlur}\n data-picker=\"calendar\"\n >\n <Popover open={open && interactive} onOpenChange={setOpen}>\n <Popover.Anchor asChild>\n <div className={styles.parts}>\n <Field\n label={startLabel}\n htmlFor={id}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n {withTime ? (\n <DateTimeInput\n id={id}\n {...partProps('start')}\n granularity={timeGranularity}\n hourCycle={clock}\n min={boundOf(min, MIDNIGHT)}\n max={value.end || boundOf(max, LAST_SECOND)}\n />\n ) : (\n <DateInput id={id} {...partProps('start')} min={min} max={startMax} />\n )}\n </Field>\n <Field\n label={endLabel}\n className={styles.part}\n error={invalid}\n errorHidden\n disabled={disabled}\n readOnly={readOnly}\n >\n {withTime ? (\n <DateTimeInput\n {...partProps('end')}\n granularity={timeGranularity}\n hourCycle={clock}\n min={value.start || boundOf(min, MIDNIGHT)}\n max={boundOf(max, LAST_SECOND)}\n />\n ) : (\n <DateInput {...partProps('end')} min={endMin} max={max} />\n )}\n </Field>\n <Popover.Trigger asChild>\n <IconButton\n className={styles.trigger}\n variant=\"outline\"\n size={size}\n shape=\"square\"\n label={labels.openCalendar}\n icon={<CalendarIcon />}\n disabled={!interactive}\n />\n </Popover.Trigger>\n </div>\n </Popover.Anchor>\n <Popover.Content\n ref={panelRef}\n className={picker.popover}\n align=\"end\"\n aria-label={labels.openCalendar}\n onOpenAutoFocus={(event) => {\n event.preventDefault()\n }}\n >\n {/* The panel's own controls aren't the fieldset's: no label, error or id from it. */}\n <FieldContext.Provider value={null}>\n <div className={styles.panel}>\n {presets && presets.length > 0 ? (\n <div role=\"group\" aria-label={labels.presets} className={styles.presets}>\n {presets.map((preset) => {\n const range = presetRange(preset)\n const current = range.start === value.start && range.end === value.end\n return (\n <Button\n key={preset.label}\n variant=\"ghost\"\n size=\"sm\"\n className={styles.preset}\n aria-pressed={current}\n onClick={() => {\n setRange(presetRange(preset))\n setOpen(false)\n }}\n >\n {preset.label}\n </Button>\n )\n })}\n </div>\n ) : null}\n <div className={picker.panel}>\n <Calendar\n mode=\"range\"\n months={2}\n // The panel is a dialog: opening it moves focus to its current day.\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n value={{\n start: startDate ? formatDate(startDate) : '',\n end: endDate ? formatDate(endDate) : '',\n }}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n firstDayOfWeek={firstDayOfWeek}\n locale={locale}\n timeZone={timeZone}\n labels={labels}\n onValueChange={pickRange}\n />\n {withTime ? (\n <div className={styles.times}>\n {(['start', 'end'] as const).map((part) => {\n const time = timeOf(value[part])\n return (\n <div key={part} className={picker.timeRow}>\n <span className={picker.timeLabel} aria-hidden=\"true\">\n {part === 'start' ? labels.startTime : labels.endTime}\n </span>\n <TimeInput\n aria-label={part === 'start' ? labels.startTime : labels.endTime}\n value={time ? formatTime(time, timeGranularity) : ''}\n granularity={timeGranularity}\n hourCycle={clock}\n locale={locale}\n size=\"sm\"\n labels={labels}\n disabled={(part === 'start' ? startDate : endDate) === null}\n onValueChange={(next) => {\n setTime(part, next)\n }}\n />\n </div>\n )\n })}\n </div>\n ) : null}\n </div>\n </div>\n </FieldContext.Provider>\n </Popover.Content>\n </Popover>\n </Fieldset>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmEA,IAAMI,KAAwB;CAAE,OAAO;CAAI,KAAK;AAAG,GAC7CC,IAAsB;CAA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A;QACA,OAAO;SACL,OAAO9C,IAAYa,EAAWb,CAAS,IAAI;SAC3C,KAAKG,IAAUU,EAAWV,CAAO,IAAI;QACvC;QACK;QACA;QACW;QACA;QACR;QACE;QACF;QACR,eAAegB;OAChB,CAAA,GACA5B,IACC,kBAAC,OAAD;QAAK,WAAW7C,EAAO;QACnB,UAAA,CAAC,SAAS,KAAK,CAAC,CAAW,KAAK,MAAS;SACzC,IAAMwE,IAAOd,EAAO9B,EAAMM,EAAK;SAC/B,OACE,kBAAC,OAAD;UAAgB,WAAWjC,EAAO;UAAlC,UAAA,CACE,kBAAC,QAAD;WAAM,WAAWA,EAAO;WAAW,eAAY;WAC5C,UAAAiC,MAAS,UAAUS,EAAO,YAAYA,EAAO;UAC1C,CAAA,GACN,kBAAC0D,IAAD;WACE,cAAYnE,MAAS,UAAUS,EAAO,YAAYA,EAAO;WACzD,OAAO6B,IAAO8B,GAAW9B,GAAMzB,CAAe,IAAI;WAClD,aAAaA;WACb,WAAWC;WACH;WACR,MAAK;WACG;WACR,WAAWd,MAAS,UAAUoB,IAAYG,OAAa;WACvD,gBAAgB,MAAS;YACvB,GAAQvB,GAAMC,CAAI;WACpB;UACD,CAAA,CACE;SAjBK,GAAAD,CAiBL;QAET,CAAC;OACE,CAAA,IACH,IACD;MACF,CAAA,CAAA;;IACgB,CAAA;GACR,CAAA,CACV;;CACD,CAAA;AAEd,CACF"}
@@ -1,2 +1,4 @@
1
1
  export { DateRangeField } from './DateRangeField.js';
2
2
  export type { DateRangeFieldProps, DateRangeValue } from './DateRangeField.js';
3
+ export { DateRangePickerField } from './DateRangePickerField.js';
4
+ export type { DateRangePickerFieldProps, DateRangePreset } from './DateRangePickerField.js';
@@ -0,0 +1,17 @@
1
+ import { type FieldLabelProps } from '../Field/index.js';
2
+ import { type DateTimeInputProps } from '../DateTimeInput/index.js';
3
+ export interface DateTimeFieldProps extends FieldLabelProps, Omit<DateTimeInputProps, 'invalid' | keyof FieldLabelProps> {
4
+ }
5
+ /**
6
+ * A labelled date and time, typed part by part or picked from a calendar.
7
+ *
8
+ * @remarks
9
+ * `DateTimeField` is a {@link Field | Field} around a {@link DateTimeInput | DateTimeInput}.
10
+ *
11
+ * @privateRemarks
12
+ * Label + DateTimeInput + description + error. Input props (`value`, `timeZone`…) and the ref
13
+ * go to the input's box; `className`/`style` go to the wrapper.
14
+ *
15
+ * <DateTimeField label="Publish at" timeZone="UTC" value={at} onValueChange={setAt} />
16
+ */
17
+ export declare const DateTimeField: import("react").ForwardRefExoticComponent<DateTimeFieldProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,26 @@
1
+ import { Field as e } from "../Field/Field.js";
2
+ import { splitFieldLabelProps as t } from "../internal/fieldProps.js";
3
+ import { DateTimeInput as n } from "../DateTimeInput/DateTimeInput.js";
4
+ import { forwardRef as r } from "react";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ //#region src/components/inputs/DateTimeField/DateTimeField.tsx
7
+ var a = r(function(r, a) {
8
+ let [o, s] = t(r), { id: c, disabled: l, className: u, style: d, ...f } = s;
9
+ return /* @__PURE__ */ i(e, {
10
+ ...o,
11
+ htmlFor: c,
12
+ disabled: l,
13
+ className: u,
14
+ style: d,
15
+ children: /* @__PURE__ */ i(n, {
16
+ ref: a,
17
+ id: c,
18
+ disabled: l,
19
+ ...f
20
+ })
21
+ });
22
+ });
23
+ //#endregion
24
+ export { a as DateTimeField };
25
+
26
+ //# sourceMappingURL=DateTimeField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateTimeField.js","names":["DateTimeField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","inputRest","Field","id","DateTimeInput"],"sources":["../../../../src/components/inputs/DateTimeField/DateTimeField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { DateTimeInput, type DateTimeInputProps } from '#components/inputs/DateTimeInput'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport interface DateTimeFieldProps\n extends FieldLabelProps, Omit<DateTimeInputProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled date and time, typed part by part or picked from a calendar.\n *\n * @remarks\n * `DateTimeField` is a {@link Field | Field} around a {@link DateTimeInput | DateTimeInput}.\n *\n * @privateRemarks\n * Label + DateTimeInput + description + error. Input props (`value`, `timeZone`…) and the ref\n * go to the input's box; `className`/`style` go to the wrapper.\n *\n * <DateTimeField label=\"Publish at\" timeZone=\"UTC\" value={at} onValueChange={setAt} />\n */\nexport const DateTimeField = forwardRef<HTMLDivElement, DateTimeFieldProps>(\n function DateTimeField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const { id, disabled, className, style, ...inputRest } = rest\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <DateTimeInput ref={ref} id={id} disabled={disabled} {...inputRest} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAoBA,IAAaA,IAAgBC,EAC3B,SAAuB,GAAO,GAAK;CACjC,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAC/C,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,MAAcH;CACzD,OACE,kBAACI,GAAD;EAAO,GAAIL;EAAY,SAASM;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAoB;GAAS;GAAc;GAAU,GAAIH;EAAY,CAAA;CAChE,CAAA;AAEX,CACF"}
@@ -0,0 +1,2 @@
1
+ export { DateTimeField } from './DateTimeField.js';
2
+ export type { DateTimeFieldProps } from './DateTimeField.js';
@@ -0,0 +1,83 @@
1
+ import { type FocusEventHandler, type HTMLAttributes } from 'react';
2
+ import type { Size } from '../../../utils/tokens.js';
3
+ import { type TimeGranularity } from '../internal/dates.js';
4
+ import { type DateTimeLabels } from '../internal/picker.js';
5
+ export interface DateTimeInputProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'onBlur' | 'onFocus'> {
6
+ /**
7
+ * `YYYY-MM-DDTHH:mm` (a wall-clock time, like `datetime-local`), or with `timeZone` the UTC
8
+ * instant `YYYY-MM-DDTHH:mm:ssZ`. `''` until every part is filled in.
9
+ */
10
+ value?: string;
11
+ defaultValue?: string;
12
+ onValueChange?: (value: string) => void;
13
+ /**
14
+ * Makes the value an instant: it's shown and typed as the wall clock in this zone (an IANA
15
+ * name such as `Australia/Perth`, or `UTC`) and reported in UTC. The zone's short name shows
16
+ * in the box.
17
+ */
18
+ timeZone?: string;
19
+ /** `minute` (default) or `second`: the smallest part shown and kept. */
20
+ granularity?: TimeGranularity;
21
+ /** 12 (with am/pm) or 24. Defaults to the locale's own clock. */
22
+ hourCycle?: 12 | 24;
23
+ /** Earliest date-time, in the same form as `value`. Earlier days can't be picked. */
24
+ min?: string;
25
+ /** Latest date-time, in the same form as `value`. */
26
+ max?: string;
27
+ /** Marks dates unavailable, in the calendar and when typed. */
28
+ isDateDisabled?: (date: string) => boolean;
29
+ /** 0 (Sunday) to 6 (Saturday). Defaults to the locale's own week. */
30
+ firstDayOfWeek?: number;
31
+ /** BCP 47 locale for the order of the parts, the clock and the calendar. Default `en-AU`. */
32
+ locale?: string;
33
+ /** Show the calendar button. Default `true`. */
34
+ calendar?: boolean;
35
+ /** Show a clear button while there's a value. */
36
+ clearable?: boolean;
37
+ /** Submits the value (`''` when incomplete). */
38
+ name?: string;
39
+ form?: string;
40
+ size?: Size;
41
+ disabled?: boolean;
42
+ readOnly?: boolean;
43
+ required?: boolean;
44
+ /** Critical border + `aria-invalid`. Inside a `<Field error>` this is set for you. */
45
+ invalid?: boolean;
46
+ open?: boolean;
47
+ defaultOpen?: boolean;
48
+ onOpenChange?: (open: boolean) => void;
49
+ /** Fires once focus leaves the whole control, calendar included. */
50
+ onBlur?: FocusEventHandler<HTMLElement>;
51
+ onFocus?: FocusEventHandler<HTMLElement>;
52
+ labels?: Partial<DateTimeLabels>;
53
+ }
54
+ /** Whether a date-time `value` falls outside `min`/`max` or on a disabled date. */
55
+ export declare function isDateTimeOutOfRange(value: string, { min, max, isDateDisabled, timeZone, }: {
56
+ min?: string;
57
+ max?: string;
58
+ isDateDisabled?: (date: string) => boolean;
59
+ timeZone?: string;
60
+ }): boolean;
61
+ /**
62
+ * A date and a time typed part by part, with a calendar and the time together in one panel.
63
+ *
64
+ * @remarks
65
+ * `DateTimeInput` holds a moment as an ISO string. Without `timeZone` it's a wall-clock time
66
+ * (`2026-10-15T14:30`), the same as a native `datetime-local`: right for "the meeting is at 2:30"
67
+ * wherever the reader is. With `timeZone` it's an instant (`2026-10-15T03:30:00Z`), shown and typed
68
+ * as the clock in that zone, with the zone's name in the box: right for logs, deadlines and
69
+ * anything stored as a timestamp.
70
+ *
71
+ * The parts type like {@link DateInput | DateInput} and {@link TimeInput | TimeInput}. The
72
+ * calendar button opens a {@link Calendar | Calendar} with the time beneath it; picking a day keeps
73
+ * the time (or starts at midnight), and the panel stays open to set the time. For the usual
74
+ * labelled field, use {@link DateTimeField | DateTimeField}.
75
+ *
76
+ * @privateRemarks
77
+ * One draft holds the date and time; the panel's Calendar and TimeInput are views of it. A
78
+ * zoned value is converted to wall time on the way in (`parseDateTime`) and back to UTC on the
79
+ * way out (`formatDateTime`), so the parts always show the zone's clock. The ref goes to the box.
80
+ *
81
+ * <DateTimeInput timeZone="UTC" value={publishAt} onValueChange={setPublishAt} />
82
+ */
83
+ export declare const DateTimeInput: import("react").ForwardRefExoticComponent<DateTimeInputProps & import("react").RefAttributes<HTMLDivElement>>;