@react-aria/datepicker 3.16.1 → 3.17.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 (221) hide show
  1. package/dist/import.mjs +6 -6
  2. package/dist/main.js +11 -11
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +12 -0
  7. package/package.json +16 -28
  8. package/src/index.ts +13 -11
  9. package/dist/ar-AE.main.js +0 -21
  10. package/dist/ar-AE.main.js.map +0 -1
  11. package/dist/ar-AE.mjs +0 -23
  12. package/dist/ar-AE.module.js +0 -23
  13. package/dist/ar-AE.module.js.map +0 -1
  14. package/dist/bg-BG.main.js +0 -21
  15. package/dist/bg-BG.main.js.map +0 -1
  16. package/dist/bg-BG.mjs +0 -23
  17. package/dist/bg-BG.module.js +0 -23
  18. package/dist/bg-BG.module.js.map +0 -1
  19. package/dist/cs-CZ.main.js +0 -21
  20. package/dist/cs-CZ.main.js.map +0 -1
  21. package/dist/cs-CZ.mjs +0 -23
  22. package/dist/cs-CZ.module.js +0 -23
  23. package/dist/cs-CZ.module.js.map +0 -1
  24. package/dist/da-DK.main.js +0 -21
  25. package/dist/da-DK.main.js.map +0 -1
  26. package/dist/da-DK.mjs +0 -23
  27. package/dist/da-DK.module.js +0 -23
  28. package/dist/da-DK.module.js.map +0 -1
  29. package/dist/de-DE.main.js +0 -21
  30. package/dist/de-DE.main.js.map +0 -1
  31. package/dist/de-DE.mjs +0 -23
  32. package/dist/de-DE.module.js +0 -23
  33. package/dist/de-DE.module.js.map +0 -1
  34. package/dist/el-GR.main.js +0 -21
  35. package/dist/el-GR.main.js.map +0 -1
  36. package/dist/el-GR.mjs +0 -23
  37. package/dist/el-GR.module.js +0 -23
  38. package/dist/el-GR.module.js.map +0 -1
  39. package/dist/en-US.main.js +0 -21
  40. package/dist/en-US.main.js.map +0 -1
  41. package/dist/en-US.mjs +0 -23
  42. package/dist/en-US.module.js +0 -23
  43. package/dist/en-US.module.js.map +0 -1
  44. package/dist/es-ES.main.js +0 -21
  45. package/dist/es-ES.main.js.map +0 -1
  46. package/dist/es-ES.mjs +0 -23
  47. package/dist/es-ES.module.js +0 -23
  48. package/dist/es-ES.module.js.map +0 -1
  49. package/dist/et-EE.main.js +0 -21
  50. package/dist/et-EE.main.js.map +0 -1
  51. package/dist/et-EE.mjs +0 -23
  52. package/dist/et-EE.module.js +0 -23
  53. package/dist/et-EE.module.js.map +0 -1
  54. package/dist/fi-FI.main.js +0 -21
  55. package/dist/fi-FI.main.js.map +0 -1
  56. package/dist/fi-FI.mjs +0 -23
  57. package/dist/fi-FI.module.js +0 -23
  58. package/dist/fi-FI.module.js.map +0 -1
  59. package/dist/fr-FR.main.js +0 -21
  60. package/dist/fr-FR.main.js.map +0 -1
  61. package/dist/fr-FR.mjs +0 -23
  62. package/dist/fr-FR.module.js +0 -23
  63. package/dist/fr-FR.module.js.map +0 -1
  64. package/dist/he-IL.main.js +0 -21
  65. package/dist/he-IL.main.js.map +0 -1
  66. package/dist/he-IL.mjs +0 -23
  67. package/dist/he-IL.module.js +0 -23
  68. package/dist/he-IL.module.js.map +0 -1
  69. package/dist/hr-HR.main.js +0 -21
  70. package/dist/hr-HR.main.js.map +0 -1
  71. package/dist/hr-HR.mjs +0 -23
  72. package/dist/hr-HR.module.js +0 -23
  73. package/dist/hr-HR.module.js.map +0 -1
  74. package/dist/hu-HU.main.js +0 -21
  75. package/dist/hu-HU.main.js.map +0 -1
  76. package/dist/hu-HU.mjs +0 -23
  77. package/dist/hu-HU.module.js +0 -23
  78. package/dist/hu-HU.module.js.map +0 -1
  79. package/dist/intlStrings.main.js +0 -108
  80. package/dist/intlStrings.main.js.map +0 -1
  81. package/dist/intlStrings.mjs +0 -110
  82. package/dist/intlStrings.module.js +0 -110
  83. package/dist/intlStrings.module.js.map +0 -1
  84. package/dist/it-IT.main.js +0 -21
  85. package/dist/it-IT.main.js.map +0 -1
  86. package/dist/it-IT.mjs +0 -23
  87. package/dist/it-IT.module.js +0 -23
  88. package/dist/it-IT.module.js.map +0 -1
  89. package/dist/ja-JP.main.js +0 -21
  90. package/dist/ja-JP.main.js.map +0 -1
  91. package/dist/ja-JP.mjs +0 -23
  92. package/dist/ja-JP.module.js +0 -23
  93. package/dist/ja-JP.module.js.map +0 -1
  94. package/dist/ko-KR.main.js +0 -21
  95. package/dist/ko-KR.main.js.map +0 -1
  96. package/dist/ko-KR.mjs +0 -23
  97. package/dist/ko-KR.module.js +0 -23
  98. package/dist/ko-KR.module.js.map +0 -1
  99. package/dist/lt-LT.main.js +0 -21
  100. package/dist/lt-LT.main.js.map +0 -1
  101. package/dist/lt-LT.mjs +0 -23
  102. package/dist/lt-LT.module.js +0 -23
  103. package/dist/lt-LT.module.js.map +0 -1
  104. package/dist/lv-LV.main.js +0 -21
  105. package/dist/lv-LV.main.js.map +0 -1
  106. package/dist/lv-LV.mjs +0 -23
  107. package/dist/lv-LV.module.js +0 -23
  108. package/dist/lv-LV.module.js.map +0 -1
  109. package/dist/nb-NO.main.js +0 -21
  110. package/dist/nb-NO.main.js.map +0 -1
  111. package/dist/nb-NO.mjs +0 -23
  112. package/dist/nb-NO.module.js +0 -23
  113. package/dist/nb-NO.module.js.map +0 -1
  114. package/dist/nl-NL.main.js +0 -21
  115. package/dist/nl-NL.main.js.map +0 -1
  116. package/dist/nl-NL.mjs +0 -23
  117. package/dist/nl-NL.module.js +0 -23
  118. package/dist/nl-NL.module.js.map +0 -1
  119. package/dist/pl-PL.main.js +0 -21
  120. package/dist/pl-PL.main.js.map +0 -1
  121. package/dist/pl-PL.mjs +0 -23
  122. package/dist/pl-PL.module.js +0 -23
  123. package/dist/pl-PL.module.js.map +0 -1
  124. package/dist/pt-BR.main.js +0 -21
  125. package/dist/pt-BR.main.js.map +0 -1
  126. package/dist/pt-BR.mjs +0 -23
  127. package/dist/pt-BR.module.js +0 -23
  128. package/dist/pt-BR.module.js.map +0 -1
  129. package/dist/pt-PT.main.js +0 -21
  130. package/dist/pt-PT.main.js.map +0 -1
  131. package/dist/pt-PT.mjs +0 -23
  132. package/dist/pt-PT.module.js +0 -23
  133. package/dist/pt-PT.module.js.map +0 -1
  134. package/dist/ro-RO.main.js +0 -21
  135. package/dist/ro-RO.main.js.map +0 -1
  136. package/dist/ro-RO.mjs +0 -23
  137. package/dist/ro-RO.module.js +0 -23
  138. package/dist/ro-RO.module.js.map +0 -1
  139. package/dist/ru-RU.main.js +0 -21
  140. package/dist/ru-RU.main.js.map +0 -1
  141. package/dist/ru-RU.mjs +0 -23
  142. package/dist/ru-RU.module.js +0 -23
  143. package/dist/ru-RU.module.js.map +0 -1
  144. package/dist/sk-SK.main.js +0 -21
  145. package/dist/sk-SK.main.js.map +0 -1
  146. package/dist/sk-SK.mjs +0 -23
  147. package/dist/sk-SK.module.js +0 -23
  148. package/dist/sk-SK.module.js.map +0 -1
  149. package/dist/sl-SI.main.js +0 -21
  150. package/dist/sl-SI.main.js.map +0 -1
  151. package/dist/sl-SI.mjs +0 -23
  152. package/dist/sl-SI.module.js +0 -23
  153. package/dist/sl-SI.module.js.map +0 -1
  154. package/dist/sr-SP.main.js +0 -21
  155. package/dist/sr-SP.main.js.map +0 -1
  156. package/dist/sr-SP.mjs +0 -23
  157. package/dist/sr-SP.module.js +0 -23
  158. package/dist/sr-SP.module.js.map +0 -1
  159. package/dist/sv-SE.main.js +0 -21
  160. package/dist/sv-SE.main.js.map +0 -1
  161. package/dist/sv-SE.mjs +0 -23
  162. package/dist/sv-SE.module.js +0 -23
  163. package/dist/sv-SE.module.js.map +0 -1
  164. package/dist/tr-TR.main.js +0 -21
  165. package/dist/tr-TR.main.js.map +0 -1
  166. package/dist/tr-TR.mjs +0 -23
  167. package/dist/tr-TR.module.js +0 -23
  168. package/dist/tr-TR.module.js.map +0 -1
  169. package/dist/types.d.ts +0 -108
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/uk-UA.main.js +0 -21
  172. package/dist/uk-UA.main.js.map +0 -1
  173. package/dist/uk-UA.mjs +0 -23
  174. package/dist/uk-UA.module.js +0 -23
  175. package/dist/uk-UA.module.js.map +0 -1
  176. package/dist/useDateField.main.js +0 -181
  177. package/dist/useDateField.main.js.map +0 -1
  178. package/dist/useDateField.mjs +0 -172
  179. package/dist/useDateField.module.js +0 -172
  180. package/dist/useDateField.module.js.map +0 -1
  181. package/dist/useDatePicker.main.js +0 -178
  182. package/dist/useDatePicker.main.js.map +0 -1
  183. package/dist/useDatePicker.mjs +0 -173
  184. package/dist/useDatePicker.module.js +0 -173
  185. package/dist/useDatePicker.module.js.map +0 -1
  186. package/dist/useDatePickerGroup.main.js +0 -120
  187. package/dist/useDatePickerGroup.main.js.map +0 -1
  188. package/dist/useDatePickerGroup.mjs +0 -115
  189. package/dist/useDatePickerGroup.module.js +0 -115
  190. package/dist/useDatePickerGroup.module.js.map +0 -1
  191. package/dist/useDateRangePicker.main.js +0 -224
  192. package/dist/useDateRangePicker.main.js.map +0 -1
  193. package/dist/useDateRangePicker.mjs +0 -219
  194. package/dist/useDateRangePicker.module.js +0 -219
  195. package/dist/useDateRangePicker.module.js.map +0 -1
  196. package/dist/useDateSegment.main.js +0 -370
  197. package/dist/useDateSegment.main.js.map +0 -1
  198. package/dist/useDateSegment.mjs +0 -361
  199. package/dist/useDateSegment.module.js +0 -361
  200. package/dist/useDateSegment.module.js.map +0 -1
  201. package/dist/useDisplayNames.main.js +0 -58
  202. package/dist/useDisplayNames.main.js.map +0 -1
  203. package/dist/useDisplayNames.mjs +0 -53
  204. package/dist/useDisplayNames.module.js +0 -53
  205. package/dist/useDisplayNames.module.js.map +0 -1
  206. package/dist/zh-CN.main.js +0 -21
  207. package/dist/zh-CN.main.js.map +0 -1
  208. package/dist/zh-CN.mjs +0 -23
  209. package/dist/zh-CN.module.js +0 -23
  210. package/dist/zh-CN.module.js.map +0 -1
  211. package/dist/zh-TW.main.js +0 -21
  212. package/dist/zh-TW.main.js.map +0 -1
  213. package/dist/zh-TW.mjs +0 -23
  214. package/dist/zh-TW.module.js +0 -23
  215. package/dist/zh-TW.module.js.map +0 -1
  216. package/src/useDateField.ts +0 -213
  217. package/src/useDatePicker.ts +0 -192
  218. package/src/useDatePickerGroup.ts +0 -138
  219. package/src/useDateRangePicker.ts +0 -243
  220. package/src/useDateSegment.ts +0 -413
  221. package/src/useDisplayNames.ts +0 -51
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAuBM,SAAS,yCAAe,OAAoB,EAAE,KAAqB,EAAE,GAAkC;IAC5G,IAAI,cAAc,CAAA,GAAA,mBAAK,EAAE;IACzB,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAClC,IAAI,eAAe,CAAA,GAAA,yCAAc;IACjC,IAAI,aAAC,SAAS,kBAAE,cAAc,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC;IAE9E,IAAI,YAAY,QAAQ,aAAa,GAAG,KAAK,QAAQ,IAAI;IACzD,IAAI,UAAU,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,aAAa,CAAC,eAAe,IAAI;QAAC,MAAM,aAAa;KAAC;IACxF,IAAI,qBAAqB,CAAA,GAAA,qCAAe,EAAE;QAAC,OAAO;QAAQ,UAAU,QAAQ,QAAQ;IAAA;IACpF,IAAI,oBAAoB,CAAA,GAAA,qCAAe,EAAE;QACvC,MAAM;QACN,QAAQ,QAAQ,MAAM;QACtB,UAAU,QAAQ,QAAQ;IAC5B;IAEA,IAAI,QAAQ,IAAI,KAAK,WAAW,CAAC,QAAQ,aAAa,EAAE;QACtD,IAAI,iBAAiB,mBAAmB,MAAM,CAAC,MAAM,SAAS;QAC9D,YAAY,mBAAmB,YAAY,GAAG,UAAU,UAAG,EAAE,gBAAgB,GAAG;IAClF,OAAO,IAAI,QAAQ,IAAI,KAAK,UAAU,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aAAa,SAAS,GAAG;IAE7B;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,iBAAiB,YAAY;gBACpD;YACA,GAAG,kBAAkB;YACrB,gBAAgB,MAAM,SAAS,GAAG,SAAS;YAC3C,oBAAoB;YACpB,iBAAiB,MAAM,UAAU,IAAI,CAAC,QAAQ,UAAU,GAAG,SAAS;YACpE,oBAAoB,QAAQ,aAAa,IAAI;YAC7C,iBAAiB;YACjB,gCAAgC;YAChC,YAAY,aAAa,UAAU;YACnC,aAAa,aAAa,QAAQ;YAClC,4CAA4C;YAC5C,CAAC,SAAS,CAAA,GAAA,sCAAI,EAAE,OAAO,EAAE,OAAO,KAAK,iBAAiB,eAAe,EAAE,aAAa,SAAS;YAC7F,WAAW,MAAM,UAAU,IAAI,QAAQ,IAAI,KAAK,eAAe,QAAQ,IAAI,KAAK,SAAS,CAAC,aAAa,YAAY;YACnH,UAAU,MAAM,UAAU,GAAG,YAAY;uBACzC;qBACA;YACA,OAAO;YACP,mHAAmH;YACnH,eAAc,CAAC;gBACb,EAAE,eAAe;YACnB;YACA,aAAY,CAAC;gBACX,EAAE,eAAe;YACnB;QACF;IACF;AACF;AAEA,SAAS,yCAAmB,OAAiB;IAC3C,gGAAgG;IAChG,QAAQ,IAAI;IACZ,IAAI,QAAQ,OAAO,CAAC,EAAE;IACtB,IAAI,OAAO,OAAO,CAAC,QAAQ,MAAM,GAAG,EAAE;IACtC,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EACtB,OAAO;IAEX;IACA,OAAO;AACT","sources":["packages/@react-aria/datepicker/src/useDateSegment.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, toCalendar} from '@internationalized/date';\nimport {DateFieldState, DateSegment} from '@react-stately/datepicker';\nimport {getActiveElement, getScrollParent, isIOS, isMac, mergeProps, nodeContains, scrollIntoViewport, useEvent, useId, useLabels, useLayoutEffect} from '@react-aria/utils';\nimport {hookData} from './useDateField';\nimport {NumberParser} from '@internationalized/number';\nimport React, {CSSProperties, useMemo, useRef} from 'react';\nimport {RefObject} from '@react-types/shared';\nimport {useDateFormatter, useFilter, useLocale} from '@react-aria/i18n';\nimport {useDisplayNames} from './useDisplayNames';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface DateSegmentAria {\n /** Props for the segment element. */\n segmentProps: React.HTMLAttributes<HTMLDivElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a segment in a date field.\n * A date segment displays an individual unit of a date and time, and allows users to edit\n * the value by typing or using the arrow keys to increment and decrement.\n */\nexport function useDateSegment(segment: DateSegment, state: DateFieldState, ref: RefObject<HTMLElement | null>): DateSegmentAria {\n let enteredKeys = useRef('');\n let {locale, direction} = useLocale();\n let displayNames = useDisplayNames();\n let {ariaLabel, ariaLabelledBy, ariaDescribedBy, focusManager} = hookData.get(state)!;\n\n let textValue = segment.isPlaceholder ? '' : segment.text;\n let options = useMemo(() => state.dateFormatter.resolvedOptions(), [state.dateFormatter]);\n let monthDateFormatter = useDateFormatter({month: 'long', timeZone: options.timeZone});\n let hourDateFormatter = useDateFormatter({\n hour: 'numeric',\n hour12: options.hour12,\n timeZone: options.timeZone\n });\n\n if (segment.type === 'month' && !segment.isPlaceholder) {\n let monthTextValue = monthDateFormatter.format(state.dateValue);\n textValue = monthTextValue !== textValue ? `${textValue} – ${monthTextValue}` : monthTextValue;\n } else if (segment.type === 'hour' && !segment.isPlaceholder) {\n textValue = hourDateFormatter.format(state.dateValue);\n }\n\n let {spinButtonProps} = useSpinButton({\n // The ARIA spec says aria-valuenow is optional if there's no value, but aXe seems to require it.\n // This doesn't seem to have any negative effects with real AT since we also use aria-valuetext.\n // https://github.com/dequelabs/axe-core/issues/3505\n value: segment.value ?? undefined,\n textValue,\n minValue: segment.minValue,\n maxValue: segment.maxValue,\n isDisabled: state.isDisabled,\n isReadOnly: state.isReadOnly || !segment.isEditable,\n isRequired: state.isRequired,\n onIncrement: () => {\n enteredKeys.current = '';\n state.increment(segment.type);\n },\n onDecrement: () => {\n enteredKeys.current = '';\n state.decrement(segment.type);\n },\n onIncrementPage: () => {\n enteredKeys.current = '';\n state.incrementPage(segment.type);\n },\n onDecrementPage: () => {\n enteredKeys.current = '';\n state.decrementPage(segment.type);\n },\n onIncrementToMax: () => {\n enteredKeys.current = '';\n state.incrementToMax(segment.type);\n },\n onDecrementToMin: () => {\n enteredKeys.current = '';\n state.decrementToMin(segment.type);\n }\n });\n\n let parser = useMemo(() => new NumberParser(locale, {maximumFractionDigits: 0}), [locale]);\n\n let backspace = () => {\n if (segment.text === segment.placeholder) {\n focusManager.focusPrevious();\n }\n if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly && !segment.isPlaceholder) {\n let newValue = segment.text.slice(0, -1);\n let parsed = parser.parse(newValue);\n newValue = parsed === 0 ? '' : newValue;\n if (newValue.length === 0 || parsed === 0) {\n state.clearSegment(segment.type);\n } else {\n state.setSegment(segment.type, parsed);\n }\n enteredKeys.current = newValue;\n } else if (segment.type === 'dayPeriod' || segment.type === 'era') {\n state.clearSegment(segment.type);\n }\n };\n\n let onKeyDown = (e) => {\n // Firefox does not fire selectstart for Ctrl/Cmd + A\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1742153\n if (e.key === 'a' && (isMac() ? e.metaKey : e.ctrlKey)) {\n e.preventDefault();\n }\n\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) {\n return;\n }\n\n switch (e.key) {\n case 'Backspace':\n case 'Delete': {\n // Safari on iOS does not fire beforeinput for the backspace key because the cursor is at the start.\n e.preventDefault();\n e.stopPropagation();\n backspace();\n break;\n }\n }\n };\n\n // Safari dayPeriod option doesn't work...\n let {startsWith} = useFilter({sensitivity: 'base'});\n let amPmFormatter = useDateFormatter({hour: 'numeric', hour12: true});\n let am = useMemo(() => {\n let date = new Date();\n date.setHours(0);\n return amPmFormatter.formatToParts(date).find(part => part.type === 'dayPeriod')!.value;\n }, [amPmFormatter]);\n\n let pm = useMemo(() => {\n let date = new Date();\n date.setHours(12);\n return amPmFormatter.formatToParts(date).find(part => part.type === 'dayPeriod')!.value;\n }, [amPmFormatter]);\n\n // Get a list of formatted era names so users can type the first character to choose one.\n let eraFormatter = useDateFormatter({year: 'numeric', era: 'narrow', timeZone: 'UTC'});\n let eras = useMemo(() => {\n if (segment.type !== 'era') {\n return [];\n }\n\n let date = toCalendar(new CalendarDate(1, 1, 1), state.calendar);\n let eras = state.calendar.getEras().map(era => {\n let eraDate = date.set({year: 1, month: 1, day: 1, era}).toDate('UTC');\n let parts = eraFormatter.formatToParts(eraDate);\n let formatted = parts.find(p => p.type === 'era')!.value;\n return {era, formatted};\n });\n\n // Remove the common prefix from formatted values. This is so that in calendars with eras like\n // ERA0 and ERA1 (e.g. Ethiopic), users can press \"0\" and \"1\" to select an era. In other cases,\n // the first letter is used.\n let prefixLength = commonPrefixLength(eras.map(era => era.formatted));\n if (prefixLength) {\n for (let era of eras) {\n era.formatted = era.formatted.slice(prefixLength);\n }\n }\n\n return eras;\n }, [eraFormatter, state.calendar, segment.type]);\n\n let onInput = (key: string) => {\n if (state.isDisabled || state.isReadOnly) {\n return;\n }\n\n let newValue = enteredKeys.current + key;\n\n switch (segment.type) {\n case 'dayPeriod':\n if (startsWith(am, key)) {\n state.setSegment('dayPeriod', 0);\n } else if (startsWith(pm, key)) {\n state.setSegment('dayPeriod', 1);\n } else {\n break;\n }\n focusManager.focusNext();\n break;\n case 'era': {\n let matched = eras.find(e => startsWith(e.formatted, key));\n if (matched) {\n state.setSegment('era', matched.era);\n focusManager.focusNext();\n }\n break;\n }\n case 'day':\n case 'hour':\n case 'minute':\n case 'second':\n case 'month':\n case 'year': {\n if (!parser.isValidPartialNumber(newValue)) {\n return;\n }\n\n let numberValue = parser.parse(newValue);\n let segmentValue = numberValue;\n if (segment.maxValue !== undefined && numberValue > segment.maxValue) {\n segmentValue = parser.parse(key);\n }\n\n if (isNaN(numberValue)) {\n return;\n }\n\n state.setSegment(segment.type, segmentValue);\n\n if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {\n enteredKeys.current = '';\n focusManager.focusNext();\n } else {\n enteredKeys.current = newValue;\n }\n break;\n }\n }\n };\n\n let onFocus = () => {\n enteredKeys.current = '';\n if (ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n\n // Collapse selection to start or Chrome won't fire input events.\n let selection = window.getSelection();\n selection?.collapse(ref.current);\n };\n\n let documentRef = useRef(typeof document !== 'undefined' ? document : null);\n useEvent(documentRef, 'selectionchange', () => {\n // Enforce that the selection is collapsed when inside a date segment.\n // Otherwise, when tapping on a segment in Android Chrome and then entering text,\n // composition events will be fired that break the DOM structure and crash the page.\n let selection = window.getSelection();\n if (selection?.anchorNode && nodeContains(ref.current, selection?.anchorNode)) {\n selection.collapse(ref.current);\n }\n });\n\n let compositionRef = useRef<string | null>('');\n useEvent(ref, 'beforeinput', e => {\n if (!ref.current) {\n return;\n }\n e.preventDefault();\n\n switch (e.inputType) {\n case 'deleteContentBackward':\n case 'deleteContentForward':\n if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly) {\n backspace();\n }\n break;\n case 'insertCompositionText':\n // insertCompositionText cannot be canceled.\n // Record the current state of the element so we can restore it in the `input` event below.\n compositionRef.current = ref.current.textContent;\n\n // Safari gets stuck in a composition state unless we also assign to the value here.\n // eslint-disable-next-line no-self-assign\n ref.current.textContent = ref.current.textContent;\n break;\n default:\n if (e.data != null) {\n onInput(e.data);\n }\n break;\n }\n });\n\n useEvent(ref, 'input', e => {\n let {inputType, data} = e as InputEvent;\n switch (inputType) {\n case 'insertCompositionText':\n // Reset the DOM to how it was in the beforeinput event.\n if (ref.current) {\n ref.current.textContent = compositionRef.current;\n }\n\n // Android sometimes fires key presses of letters as composition events. Need to handle am/pm keys here too.\n // Can also happen e.g. with Pinyin keyboard on iOS.\n if (data != null && (startsWith(am, data) || startsWith(pm, data))) {\n onInput(data);\n }\n break;\n }\n });\n\n useLayoutEffect(() => {\n let element = ref.current;\n return () => {\n // If the focused segment is removed, focus the previous one, or the next one if there was no previous one.\n if (getActiveElement() === element) {\n let prev = focusManager.focusPrevious();\n if (!prev) {\n focusManager.focusNext();\n }\n }\n };\n }, [ref, focusManager]);\n\n // spinbuttons cannot be focused with VoiceOver on iOS.\n let touchPropOverrides = isIOS() || segment.type === 'timeZoneName' ? {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuetext': null,\n 'aria-valuenow': null\n } : {};\n\n // Only apply aria-describedby to the first segment, unless the field is invalid. This avoids it being\n // read every time the user navigates to a new segment.\n let firstSegment = useMemo(() => state.segments.find(s => s.isEditable), [state.segments]);\n if (segment !== firstSegment && !state.isInvalid) {\n ariaDescribedBy = undefined;\n }\n\n let id = useId();\n let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;\n\n // Prepend the label passed from the field to each segment name.\n // This is needed because VoiceOver on iOS does not announce groups.\n let name = segment.type === 'literal' ? '' : displayNames.of(segment.type);\n let labelProps = useLabels({\n 'aria-label': `${name}${ariaLabel ? `, ${ariaLabel}` : ''}${ariaLabelledBy ? ', ' : ''}`,\n 'aria-labelledby': ariaLabelledBy\n });\n\n // Literal segments should not be visible to screen readers. We don't really need any of the above,\n // but the rules of hooks mean hooks cannot be conditional so we have to put this condition here.\n if (segment.type === 'literal') {\n return {\n segmentProps: {\n 'aria-hidden': true\n }\n };\n }\n\n let segmentStyle: CSSProperties = {caretColor: 'transparent'};\n if (direction === 'rtl') {\n // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings. \n // To ensure placeholder render in correct format, we apply the CSS equivalent of LRE (left-to-right embedding). See https://www.unicode.org/reports/tr9/#Explicit_Directional_Embeddings.\n // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise. \n segmentStyle.unicodeBidi = 'embed';\n let format = options[segment.type];\n if (format === 'numeric' || format === '2-digit') {\n segmentStyle.direction = 'ltr';\n }\n }\n\n return {\n segmentProps: mergeProps(spinButtonProps, labelProps, {\n id,\n ...touchPropOverrides,\n 'aria-invalid': state.isInvalid ? 'true' : undefined,\n 'aria-describedby': ariaDescribedBy,\n 'aria-readonly': state.isReadOnly || !segment.isEditable ? 'true' : undefined,\n 'data-placeholder': segment.isPlaceholder || undefined,\n contentEditable: isEditable,\n suppressContentEditableWarning: isEditable,\n spellCheck: isEditable ? 'false' : undefined,\n autoCorrect: isEditable ? 'off' : undefined,\n // Capitalization was changed in React 17...\n [parseInt(React.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,\n inputMode: state.isDisabled || segment.type === 'dayPeriod' || segment.type === 'era' || !isEditable ? undefined : 'numeric',\n tabIndex: state.isDisabled ? undefined : 0,\n onKeyDown,\n onFocus,\n style: segmentStyle,\n // Prevent pointer events from reaching useDatePickerGroup, and allow native browser behavior to focus the segment.\n onPointerDown(e) {\n e.stopPropagation();\n },\n onMouseDown(e) {\n e.stopPropagation();\n }\n })\n };\n}\n\nfunction commonPrefixLength(strings: string[]): number {\n // Sort the strings, and compare the characters in the first and last to find the common prefix.\n strings.sort();\n let first = strings[0];\n let last = strings[strings.length - 1];\n for (let i = 0; i < first.length; i++) {\n if (first[i] !== last[i]) {\n return i;\n }\n }\n return 0;\n}\n"],"names":[],"version":3,"file":"useDateSegment.main.js.map"}
@@ -1,361 +0,0 @@
1
- import {hookData as $16f0b7bb276bc17e$export$653eddfc964b0f8a} from "./useDateField.mjs";
2
- import {useDisplayNames as $3aeceb3a64eb8358$export$d42c60378c8168f8} from "./useDisplayNames.mjs";
3
- import {toCalendar as $4d1jn$toCalendar, CalendarDate as $4d1jn$CalendarDate} from "@internationalized/date";
4
- import {isMac as $4d1jn$isMac, scrollIntoViewport as $4d1jn$scrollIntoViewport, getScrollParent as $4d1jn$getScrollParent, useEvent as $4d1jn$useEvent, nodeContains as $4d1jn$nodeContains, useLayoutEffect as $4d1jn$useLayoutEffect, getActiveElement as $4d1jn$getActiveElement, isIOS as $4d1jn$isIOS, useId as $4d1jn$useId, useLabels as $4d1jn$useLabels, mergeProps as $4d1jn$mergeProps} from "@react-aria/utils";
5
- import {NumberParser as $4d1jn$NumberParser} from "@internationalized/number";
6
- import $4d1jn$react, {useRef as $4d1jn$useRef, useMemo as $4d1jn$useMemo} from "react";
7
- import {useLocale as $4d1jn$useLocale, useDateFormatter as $4d1jn$useDateFormatter, useFilter as $4d1jn$useFilter} from "@react-aria/i18n";
8
- import {useSpinButton as $4d1jn$useSpinButton} from "@react-aria/spinbutton";
9
-
10
- /*
11
- * Copyright 2020 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
- function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
29
- let enteredKeys = (0, $4d1jn$useRef)('');
30
- let { locale: locale, direction: direction } = (0, $4d1jn$useLocale)();
31
- let displayNames = (0, $3aeceb3a64eb8358$export$d42c60378c8168f8)();
32
- let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy, ariaDescribedBy: ariaDescribedBy, focusManager: focusManager } = (0, $16f0b7bb276bc17e$export$653eddfc964b0f8a).get(state);
33
- let textValue = segment.isPlaceholder ? '' : segment.text;
34
- let options = (0, $4d1jn$useMemo)(()=>state.dateFormatter.resolvedOptions(), [
35
- state.dateFormatter
36
- ]);
37
- let monthDateFormatter = (0, $4d1jn$useDateFormatter)({
38
- month: 'long',
39
- timeZone: options.timeZone
40
- });
41
- let hourDateFormatter = (0, $4d1jn$useDateFormatter)({
42
- hour: 'numeric',
43
- hour12: options.hour12,
44
- timeZone: options.timeZone
45
- });
46
- if (segment.type === 'month' && !segment.isPlaceholder) {
47
- let monthTextValue = monthDateFormatter.format(state.dateValue);
48
- textValue = monthTextValue !== textValue ? `${textValue} \u{2013} ${monthTextValue}` : monthTextValue;
49
- } else if (segment.type === 'hour' && !segment.isPlaceholder) textValue = hourDateFormatter.format(state.dateValue);
50
- var _segment_value;
51
- let { spinButtonProps: spinButtonProps } = (0, $4d1jn$useSpinButton)({
52
- // The ARIA spec says aria-valuenow is optional if there's no value, but aXe seems to require it.
53
- // This doesn't seem to have any negative effects with real AT since we also use aria-valuetext.
54
- // https://github.com/dequelabs/axe-core/issues/3505
55
- value: (_segment_value = segment.value) !== null && _segment_value !== void 0 ? _segment_value : undefined,
56
- textValue: textValue,
57
- minValue: segment.minValue,
58
- maxValue: segment.maxValue,
59
- isDisabled: state.isDisabled,
60
- isReadOnly: state.isReadOnly || !segment.isEditable,
61
- isRequired: state.isRequired,
62
- onIncrement: ()=>{
63
- enteredKeys.current = '';
64
- state.increment(segment.type);
65
- },
66
- onDecrement: ()=>{
67
- enteredKeys.current = '';
68
- state.decrement(segment.type);
69
- },
70
- onIncrementPage: ()=>{
71
- enteredKeys.current = '';
72
- state.incrementPage(segment.type);
73
- },
74
- onDecrementPage: ()=>{
75
- enteredKeys.current = '';
76
- state.decrementPage(segment.type);
77
- },
78
- onIncrementToMax: ()=>{
79
- enteredKeys.current = '';
80
- state.incrementToMax(segment.type);
81
- },
82
- onDecrementToMin: ()=>{
83
- enteredKeys.current = '';
84
- state.decrementToMin(segment.type);
85
- }
86
- });
87
- let parser = (0, $4d1jn$useMemo)(()=>new (0, $4d1jn$NumberParser)(locale, {
88
- maximumFractionDigits: 0
89
- }), [
90
- locale
91
- ]);
92
- let backspace = ()=>{
93
- if (segment.text === segment.placeholder) focusManager.focusPrevious();
94
- if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly && !segment.isPlaceholder) {
95
- let newValue = segment.text.slice(0, -1);
96
- let parsed = parser.parse(newValue);
97
- newValue = parsed === 0 ? '' : newValue;
98
- if (newValue.length === 0 || parsed === 0) state.clearSegment(segment.type);
99
- else state.setSegment(segment.type, parsed);
100
- enteredKeys.current = newValue;
101
- } else if (segment.type === 'dayPeriod' || segment.type === 'era') state.clearSegment(segment.type);
102
- };
103
- let onKeyDown = (e)=>{
104
- // Firefox does not fire selectstart for Ctrl/Cmd + A
105
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1742153
106
- if (e.key === 'a' && ((0, $4d1jn$isMac)() ? e.metaKey : e.ctrlKey)) e.preventDefault();
107
- if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;
108
- switch(e.key){
109
- case 'Backspace':
110
- case 'Delete':
111
- // Safari on iOS does not fire beforeinput for the backspace key because the cursor is at the start.
112
- e.preventDefault();
113
- e.stopPropagation();
114
- backspace();
115
- break;
116
- }
117
- };
118
- // Safari dayPeriod option doesn't work...
119
- let { startsWith: startsWith } = (0, $4d1jn$useFilter)({
120
- sensitivity: 'base'
121
- });
122
- let amPmFormatter = (0, $4d1jn$useDateFormatter)({
123
- hour: 'numeric',
124
- hour12: true
125
- });
126
- let am = (0, $4d1jn$useMemo)(()=>{
127
- let date = new Date();
128
- date.setHours(0);
129
- return amPmFormatter.formatToParts(date).find((part)=>part.type === 'dayPeriod').value;
130
- }, [
131
- amPmFormatter
132
- ]);
133
- let pm = (0, $4d1jn$useMemo)(()=>{
134
- let date = new Date();
135
- date.setHours(12);
136
- return amPmFormatter.formatToParts(date).find((part)=>part.type === 'dayPeriod').value;
137
- }, [
138
- amPmFormatter
139
- ]);
140
- // Get a list of formatted era names so users can type the first character to choose one.
141
- let eraFormatter = (0, $4d1jn$useDateFormatter)({
142
- year: 'numeric',
143
- era: 'narrow',
144
- timeZone: 'UTC'
145
- });
146
- let eras = (0, $4d1jn$useMemo)(()=>{
147
- if (segment.type !== 'era') return [];
148
- let date = (0, $4d1jn$toCalendar)(new (0, $4d1jn$CalendarDate)(1, 1, 1), state.calendar);
149
- let eras = state.calendar.getEras().map((era)=>{
150
- let eraDate = date.set({
151
- year: 1,
152
- month: 1,
153
- day: 1,
154
- era: era
155
- }).toDate('UTC');
156
- let parts = eraFormatter.formatToParts(eraDate);
157
- let formatted = parts.find((p)=>p.type === 'era').value;
158
- return {
159
- era: era,
160
- formatted: formatted
161
- };
162
- });
163
- // Remove the common prefix from formatted values. This is so that in calendars with eras like
164
- // ERA0 and ERA1 (e.g. Ethiopic), users can press "0" and "1" to select an era. In other cases,
165
- // the first letter is used.
166
- let prefixLength = $32489daedd52963e$var$commonPrefixLength(eras.map((era)=>era.formatted));
167
- if (prefixLength) for (let era of eras)era.formatted = era.formatted.slice(prefixLength);
168
- return eras;
169
- }, [
170
- eraFormatter,
171
- state.calendar,
172
- segment.type
173
- ]);
174
- let onInput = (key)=>{
175
- if (state.isDisabled || state.isReadOnly) return;
176
- let newValue = enteredKeys.current + key;
177
- switch(segment.type){
178
- case 'dayPeriod':
179
- if (startsWith(am, key)) state.setSegment('dayPeriod', 0);
180
- else if (startsWith(pm, key)) state.setSegment('dayPeriod', 1);
181
- else break;
182
- focusManager.focusNext();
183
- break;
184
- case 'era':
185
- {
186
- let matched = eras.find((e)=>startsWith(e.formatted, key));
187
- if (matched) {
188
- state.setSegment('era', matched.era);
189
- focusManager.focusNext();
190
- }
191
- break;
192
- }
193
- case 'day':
194
- case 'hour':
195
- case 'minute':
196
- case 'second':
197
- case 'month':
198
- case 'year':
199
- {
200
- if (!parser.isValidPartialNumber(newValue)) return;
201
- let numberValue = parser.parse(newValue);
202
- let segmentValue = numberValue;
203
- if (segment.maxValue !== undefined && numberValue > segment.maxValue) segmentValue = parser.parse(key);
204
- if (isNaN(numberValue)) return;
205
- state.setSegment(segment.type, segmentValue);
206
- if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {
207
- enteredKeys.current = '';
208
- focusManager.focusNext();
209
- } else enteredKeys.current = newValue;
210
- break;
211
- }
212
- }
213
- };
214
- let onFocus = ()=>{
215
- enteredKeys.current = '';
216
- if (ref.current) (0, $4d1jn$scrollIntoViewport)(ref.current, {
217
- containingElement: (0, $4d1jn$getScrollParent)(ref.current)
218
- });
219
- // Collapse selection to start or Chrome won't fire input events.
220
- let selection = window.getSelection();
221
- selection === null || selection === void 0 ? void 0 : selection.collapse(ref.current);
222
- };
223
- let documentRef = (0, $4d1jn$useRef)(typeof document !== 'undefined' ? document : null);
224
- (0, $4d1jn$useEvent)(documentRef, 'selectionchange', ()=>{
225
- // Enforce that the selection is collapsed when inside a date segment.
226
- // Otherwise, when tapping on a segment in Android Chrome and then entering text,
227
- // composition events will be fired that break the DOM structure and crash the page.
228
- let selection = window.getSelection();
229
- if ((selection === null || selection === void 0 ? void 0 : selection.anchorNode) && (0, $4d1jn$nodeContains)(ref.current, selection === null || selection === void 0 ? void 0 : selection.anchorNode)) selection.collapse(ref.current);
230
- });
231
- let compositionRef = (0, $4d1jn$useRef)('');
232
- (0, $4d1jn$useEvent)(ref, 'beforeinput', (e)=>{
233
- if (!ref.current) return;
234
- e.preventDefault();
235
- switch(e.inputType){
236
- case 'deleteContentBackward':
237
- case 'deleteContentForward':
238
- if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly) backspace();
239
- break;
240
- case 'insertCompositionText':
241
- // insertCompositionText cannot be canceled.
242
- // Record the current state of the element so we can restore it in the `input` event below.
243
- compositionRef.current = ref.current.textContent;
244
- // Safari gets stuck in a composition state unless we also assign to the value here.
245
- // eslint-disable-next-line no-self-assign
246
- ref.current.textContent = ref.current.textContent;
247
- break;
248
- default:
249
- if (e.data != null) onInput(e.data);
250
- break;
251
- }
252
- });
253
- (0, $4d1jn$useEvent)(ref, 'input', (e)=>{
254
- let { inputType: inputType, data: data } = e;
255
- switch(inputType){
256
- case 'insertCompositionText':
257
- // Reset the DOM to how it was in the beforeinput event.
258
- if (ref.current) ref.current.textContent = compositionRef.current;
259
- // Android sometimes fires key presses of letters as composition events. Need to handle am/pm keys here too.
260
- // Can also happen e.g. with Pinyin keyboard on iOS.
261
- if (data != null && (startsWith(am, data) || startsWith(pm, data))) onInput(data);
262
- break;
263
- }
264
- });
265
- (0, $4d1jn$useLayoutEffect)(()=>{
266
- let element = ref.current;
267
- return ()=>{
268
- // If the focused segment is removed, focus the previous one, or the next one if there was no previous one.
269
- if ((0, $4d1jn$getActiveElement)() === element) {
270
- let prev = focusManager.focusPrevious();
271
- if (!prev) focusManager.focusNext();
272
- }
273
- };
274
- }, [
275
- ref,
276
- focusManager
277
- ]);
278
- // spinbuttons cannot be focused with VoiceOver on iOS.
279
- let touchPropOverrides = (0, $4d1jn$isIOS)() || segment.type === 'timeZoneName' ? {
280
- role: 'textbox',
281
- 'aria-valuemax': null,
282
- 'aria-valuemin': null,
283
- 'aria-valuetext': null,
284
- 'aria-valuenow': null
285
- } : {};
286
- // Only apply aria-describedby to the first segment, unless the field is invalid. This avoids it being
287
- // read every time the user navigates to a new segment.
288
- let firstSegment = (0, $4d1jn$useMemo)(()=>state.segments.find((s)=>s.isEditable), [
289
- state.segments
290
- ]);
291
- if (segment !== firstSegment && !state.isInvalid) ariaDescribedBy = undefined;
292
- let id = (0, $4d1jn$useId)();
293
- let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
294
- // Prepend the label passed from the field to each segment name.
295
- // This is needed because VoiceOver on iOS does not announce groups.
296
- let name = segment.type === 'literal' ? '' : displayNames.of(segment.type);
297
- let labelProps = (0, $4d1jn$useLabels)({
298
- 'aria-label': `${name}${ariaLabel ? `, ${ariaLabel}` : ''}${ariaLabelledBy ? ', ' : ''}`,
299
- 'aria-labelledby': ariaLabelledBy
300
- });
301
- // Literal segments should not be visible to screen readers. We don't really need any of the above,
302
- // but the rules of hooks mean hooks cannot be conditional so we have to put this condition here.
303
- if (segment.type === 'literal') return {
304
- segmentProps: {
305
- 'aria-hidden': true
306
- }
307
- };
308
- let segmentStyle = {
309
- caretColor: 'transparent'
310
- };
311
- if (direction === 'rtl') {
312
- // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
313
- // To ensure placeholder render in correct format, we apply the CSS equivalent of LRE (left-to-right embedding). See https://www.unicode.org/reports/tr9/#Explicit_Directional_Embeddings.
314
- // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
315
- segmentStyle.unicodeBidi = 'embed';
316
- let format = options[segment.type];
317
- if (format === 'numeric' || format === '2-digit') segmentStyle.direction = 'ltr';
318
- }
319
- return {
320
- segmentProps: (0, $4d1jn$mergeProps)(spinButtonProps, labelProps, {
321
- id: id,
322
- ...touchPropOverrides,
323
- 'aria-invalid': state.isInvalid ? 'true' : undefined,
324
- 'aria-describedby': ariaDescribedBy,
325
- 'aria-readonly': state.isReadOnly || !segment.isEditable ? 'true' : undefined,
326
- 'data-placeholder': segment.isPlaceholder || undefined,
327
- contentEditable: isEditable,
328
- suppressContentEditableWarning: isEditable,
329
- spellCheck: isEditable ? 'false' : undefined,
330
- autoCorrect: isEditable ? 'off' : undefined,
331
- // Capitalization was changed in React 17...
332
- [parseInt((0, $4d1jn$react).version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,
333
- inputMode: state.isDisabled || segment.type === 'dayPeriod' || segment.type === 'era' || !isEditable ? undefined : 'numeric',
334
- tabIndex: state.isDisabled ? undefined : 0,
335
- onKeyDown: onKeyDown,
336
- onFocus: onFocus,
337
- style: segmentStyle,
338
- // Prevent pointer events from reaching useDatePickerGroup, and allow native browser behavior to focus the segment.
339
- onPointerDown (e) {
340
- e.stopPropagation();
341
- },
342
- onMouseDown (e) {
343
- e.stopPropagation();
344
- }
345
- })
346
- };
347
- }
348
- function $32489daedd52963e$var$commonPrefixLength(strings) {
349
- // Sort the strings, and compare the characters in the first and last to find the common prefix.
350
- strings.sort();
351
- let first = strings[0];
352
- let last = strings[strings.length - 1];
353
- for(let i = 0; i < first.length; i++){
354
- if (first[i] !== last[i]) return i;
355
- }
356
- return 0;
357
- }
358
-
359
-
360
- export {$32489daedd52963e$export$1315d136e6f7581 as useDateSegment};
361
- //# sourceMappingURL=useDateSegment.module.js.map