@react-aria/datepicker 3.15.0 → 3.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AC2BA,sCAAsC,CAAC,SAAS,SAAS,CAAE,SAAQ,IAAI,CAAC,mBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,kBAAkB,GAAG,UAAU,CAAC;IACnM,mEAAmE;IACnE,QAAQ,CAAC,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC9C;AAED,8BAA+B,SAAQ,gBAAgB;IACpD,2DAA2D;IAC5D,UAAU,EAAE,aAAa,CAAC;IACzB,4CAA4C;IAC7C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,mEAAmE;IACnE,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAiBD;;;;GAIG;AACH,6BAA6B,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,aAAa,CAmItJ;AAED,+BAAsC,CAAC,SAAS,SAAS,CAAE,SAAQ,mBAAmB,CAAC,CAAC;IACtF,mEAAmE;IACnE,QAAQ,CAAC,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC9C;AAED;;;;GAIG;AACH,6BAA6B,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,aAAa,CAItJ;ACtLD,+BAAgC,SAAQ,gBAAgB;IACtD,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AC;IAC7B,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,WAAW,EAAE,eAAe,CAAC;IAC7B,8DAA8D;IAC9D,aAAa,EAAE,mBAAmB,SAAS,CAAC,CAAA;CAC7C;AAED;;;;GAIG;AACH,mCAAmC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,mBAAmB,CAwL5K;AC9ND,YAAY,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAKhJ,YAAY,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC","sources":["packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePickerGroup.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateField.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDisplayNames.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateSegment.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateRangePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/index.ts","packages/@react-aria/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\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\nexport {useDatePicker} from './useDatePicker';\nexport {useDateSegment} from './useDateSegment';\nexport {useDateField, useTimeField} from './useDateField';\nexport {useDateRangePicker} from './useDateRangePicker';\nexport {useDisplayNames} from './useDisplayNames';\n\nexport type {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, DateRange, DateValue, TimeValue} from '@react-types/datepicker';\nexport type {AriaDateFieldOptions, DateFieldAria} from './useDateField';\nexport type {DatePickerAria} from './useDatePicker';\nexport type {DateRangePickerAria} from './useDateRangePicker';\nexport type {DateSegmentAria} from './useDateSegment';\nexport type {AriaTimeFieldProps} from '@react-types/datepicker';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;;AC2BA,sCAAsC,CAAC,SAAS,SAAS,CAAE,SAAQ,IAAI,CAAC,mBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,kBAAkB,GAAG,UAAU,CAAC;IACnM,mEAAmE;IACnE,QAAQ,CAAC,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC9C;AAED,8BAA+B,SAAQ,gBAAgB;IACpD,2DAA2D;IAC5D,UAAU,EAAE,aAAa,CAAC;IACzB,4CAA4C;IAC7C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,mEAAmE;IACnE,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAiBD;;;;GAIG;AACH,6BAA6B,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,aAAa,CAmItJ;AAED,+BAAsC,CAAC,SAAS,SAAS,CAA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GAAG,IAAI,CAAC,GAAG,eAAe,CA0Y/H;AC7YD,oCAAqC,SAAQ,gBAAgB;IAC3D,uEAAuE;IACvE,UAAU,EAAE,aAAa,CAAC;IAC1B,4EAA4E;IAC5E,UAAU,EAAE,kBAAkB,CAAC;IAC/B,sCAAsC;IACtC,eAAe,EAAE,oBAAoB,SAAS,CAAC,CAAC;IAChD,oCAAoC;IACpC,aAAa,EAAE,oBAAoB,SAAS,CAAC,CAAC;IAC9C,4CAA4C;IAC5C,WAAW,EAAE,eAAe,CAAC;IAC7B,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,WAAW,EAAE,eAAe,CAAC;IAC7B,8DAA8D;IAC9D,aAAa,EAAE,mBAAmB,SAAS,CAAC,CAAA;CAC7C;AAED;;;;GAIG;AACH,mCAAmC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,mBAAmB,CA0L5K;AChOD,YAAY,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAKhJ,YAAY,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC","sources":["packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePickerGroup.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateField.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDisplayNames.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateSegment.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateRangePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/index.ts","packages/@react-aria/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\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\nexport {useDatePicker} from './useDatePicker';\nexport {useDateSegment} from './useDateSegment';\nexport {useDateField, useTimeField} from './useDateField';\nexport {useDateRangePicker} from './useDateRangePicker';\nexport {useDisplayNames} from './useDisplayNames';\n\nexport type {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, DateRange, DateValue, TimeValue} from '@react-types/datepicker';\nexport type {AriaDateFieldOptions, DateFieldAria} from './useDateField';\nexport type {DatePickerAria} from './useDatePicker';\nexport type {DateRangePickerAria} from './useDateRangePicker';\nexport type {DateSegmentAria} from './useDateSegment';\nexport type {AriaTimeFieldProps} from '@react-types/datepicker';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -164,7 +164,9 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
164
164
  isDateUnavailable: props.isDateUnavailable,
165
165
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
166
166
  isInvalid: state.isInvalid,
167
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
167
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
168
+ firstDayOfWeek: props.firstDayOfWeek,
169
+ pageBehavior: props.pageBehavior
168
170
  },
169
171
  isInvalid: isInvalid,
170
172
  validationErrors: validationErrors,
@@ -1 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020 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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n defaultValue: state.defaultValue,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name,\n form: props.form\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;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AAyB,MAAM,uBAAuB;YACtD,aAAa,MAAM,WAAW;YAC9B,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,oBAAoB,MAAM,kBAAkB;YAC5C,2DAA2D;YAC3D,CAAC,CAAA,GAAA,kDAAyB,EAAE,EAAE;YAC9B,WAAW,MAAM,SAAS;YAC1B,MAAM,MAAM,IAAI;YAChB,MAAM,MAAM,IAAI;QAClB;0BACA;2BACA;QACA,aAAa;YACX,GAAG,SAAS;YACZ,IAAI;YACJ,iBAAiB;YACjB,cAAc,gBAAgB,MAAM,CAAC;YACrC,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;YAC9C,oBAAoB;YACpB,iBAAiB,MAAM,MAAM;YAC7B,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;YAChD,SAAS,IAAM,MAAM,OAAO,CAAC;QAC/B;QACA,aAAa;YACX,IAAI;YACJ,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;QAChD;QACA,eAAe;YACb,WAAW;YACX,OAAO,MAAM,SAAS;YACtB,UAAU,MAAM,YAAY;YAC5B,UAAU,MAAM,QAAQ;YACxB,UAAU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDatePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n defaultValue: state.defaultValue,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name,\n form: props.form\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),\n firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.main.js.map"}
@@ -158,7 +158,9 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
158
158
  isDateUnavailable: props.isDateUnavailable,
159
159
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
160
160
  isInvalid: state.isInvalid,
161
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
161
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
162
+ firstDayOfWeek: props.firstDayOfWeek,
163
+ pageBehavior: props.pageBehavior
162
164
  },
163
165
  isInvalid: isInvalid,
164
166
  validationErrors: validationErrors,
@@ -158,7 +158,9 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
158
158
  isDateUnavailable: props.isDateUnavailable,
159
159
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
160
160
  isInvalid: state.isInvalid,
161
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
161
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
162
+ firstDayOfWeek: props.firstDayOfWeek,
163
+ pageBehavior: props.pageBehavior
162
164
  },
163
165
  isInvalid: isInvalid,
164
166
  validationErrors: validationErrors,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,GAA8B;IACtI,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBA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G,SAAS;YACZ,IAAI;YACJ,iBAAiB;YACjB,cAAc,gBAAgB,MAAM,CAAC;YACrC,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;YAC9C,oBAAoB;YACpB,iBAAiB,MAAM,MAAM;YAC7B,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;YAChD,SAAS,IAAM,MAAM,OAAO,CAAC;QAC/B;QACA,aAAa;YACX,IAAI;YACJ,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;QAChD;QACA,eAAe;YACb,WAAW;YACX,OAAO,MAAM,SAAS;YACtB,UAAU,MAAM,YAAY;YAC5B,UAAU,MAAM,QAAQ;YACxB,UAAU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC9K;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDatePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n defaultValue: state.defaultValue,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name,\n form: props.form\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,GAA8B;IACtI,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAA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AAS,CAAC,EAAE,YAAY;YAC9C,oBAAoB;YACpB,iBAAiB,MAAM,MAAM;YAC7B,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;YAChD,SAAS,IAAM,MAAM,OAAO,CAAC;QAC/B;QACA,aAAa;YACX,IAAI;YACJ,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;QAChD;QACA,eAAe;YACb,WAAW;YACX,OAAO,MAAM,SAAS;YACtB,UAAU,MAAM,YAAY;YAC5B,UAAU,MAAM,QAAQ;YACxB,UAAU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDatePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n defaultValue: state.defaultValue,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name,\n form: props.form\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),\n firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.module.js.map"}
@@ -210,7 +210,9 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
210
210
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
211
211
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
212
212
  isInvalid: state.isInvalid,
213
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
213
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
214
+ firstDayOfWeek: props.firstDayOfWeek,
215
+ pageBehavior: props.pageBehavior
214
216
  },
215
217
  isInvalid: isInvalid,
216
218
  validationErrors: validationErrors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YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,2BAA2B,MAAM,yBAAyB;YAC1D,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC9K;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDateRangePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DateRange, RangeCalendarProps} from '@react-types/calendar';\nimport {DateRangePickerState} from '@react-stately/datepicker';\nimport {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateRangePickerAria extends ValidationResult {\n /** Props for the date range picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date fields and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the start date field. */\n startFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the end date field. */\n endFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the range calendar within the popover dialog. */\n calendarProps: RangeCalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element | null>): DateRangePickerAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let range = state.formatValue(locale, {month: 'long'});\n let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';\n let descProps = useDescription(description);\n\n let startFieldProps = {\n 'aria-label': stringFormatter.format('startDate'),\n 'aria-labelledby': labelledBy\n };\n\n let endFieldProps = {\n 'aria-label': stringFormatter.format('endDate'),\n 'aria-labelledby': labelledBy\n };\n\n let buttonId = useId();\n let dialogId = useId();\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let focusManager = useMemo(() => createFocusManager(ref, {\n // Exclude the button from the focus manager.\n accept: element => element.id !== buttonId\n }), [ref, buttonId]);\n\n let commonFieldProps = {\n [focusManagerSymbol]: focusManager,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n granularity: props.granularity,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior\n };\n\n let domProps = filterDOMProps(props);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n startFieldProps: {\n ...startFieldProps,\n ...commonFieldProps,\n value: state.value?.start ?? null,\n defaultValue: state.defaultValue?.start,\n onChange: start => state.setDateTime('start', start),\n autoFocus: props.autoFocus,\n name: props.startName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n startFieldValidation.current = e;\n state.updateValidation(mergeValidation(e, endFieldValidation.current));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n endFieldProps: {\n ...endFieldProps,\n ...commonFieldProps,\n value: state.value?.end ?? null,\n defaultValue: state.defaultValue?.end,\n onChange: end => state.setDateTime('end', end),\n name: props.endName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n endFieldValidation.current = e;\n state.updateValidation(mergeValidation(startFieldValidation.current, e));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n descriptionProps,\n errorMessageProps,\n calendarProps: {\n autoFocus: true,\n value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,\n onChange: state.setDateRange,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationEr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B,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,2BAA2B,MAAM,yBAAyB;YAC1D,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDateRangePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DateRange, RangeCalendarProps} from '@react-types/calendar';\nimport {DateRangePickerState} from '@react-stately/datepicker';\nimport {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateRangePickerAria extends ValidationResult {\n /** Props for the date range picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date fields and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the start date field. */\n startFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the end date field. */\n endFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the range calendar within the popover dialog. */\n calendarProps: RangeCalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element | null>): DateRangePickerAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let range = state.formatValue(locale, {month: 'long'});\n let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';\n let descProps = useDescription(description);\n\n let startFieldProps = {\n 'aria-label': stringFormatter.format('startDate'),\n 'aria-labelledby': labelledBy\n };\n\n let endFieldProps = {\n 'aria-label': stringFormatter.format('endDate'),\n 'aria-labelledby': labelledBy\n };\n\n let buttonId = useId();\n let dialogId = useId();\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let focusManager = useMemo(() => createFocusManager(ref, {\n // Exclude the button from the focus manager.\n accept: element => element.id !== buttonId\n }), [ref, buttonId]);\n\n let commonFieldProps = {\n [focusManagerSymbol]: focusManager,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n granularity: props.granularity,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior\n };\n\n let domProps = filterDOMProps(props);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n startFieldProps: {\n ...startFieldProps,\n ...commonFieldProps,\n value: state.value?.start ?? null,\n defaultValue: state.defaultValue?.start,\n onChange: start => state.setDateTime('start', start),\n autoFocus: props.autoFocus,\n name: props.startName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n startFieldValidation.current = e;\n state.updateValidation(mergeValidation(e, endFieldValidation.current));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n endFieldProps: {\n ...endFieldProps,\n ...commonFieldProps,\n value: state.value?.end ?? null,\n defaultValue: state.defaultValue?.end,\n onChange: end => state.setDateTime('end', end),\n name: props.endName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n endFieldValidation.current = e;\n state.updateValidation(mergeValidation(startFieldValidation.current, e));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n descriptionProps,\n errorMessageProps,\n calendarProps: {\n autoFocus: true,\n value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,\n onChange: state.setDateRange,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),\n firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDateRangePicker.main.js.map"}
@@ -204,7 +204,9 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
204
204
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
205
205
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
206
206
  isInvalid: state.isInvalid,
207
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
207
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
208
+ firstDayOfWeek: props.firstDayOfWeek,
209
+ pageBehavior: props.pageBehavior
208
210
  },
209
211
  isInvalid: isInvalid,
210
212
  validationErrors: validationErrors,
@@ -204,7 +204,9 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
204
204
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
205
205
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
206
206
  isInvalid: state.isInvalid,
207
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
207
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
208
+ firstDayOfWeek: props.firstDayOfWeek,
209
+ pageBehavior: props.pageBehavior
208
210
  },
209
211
  isInvalid: isInvalid,
210
212
  validationErrors: validationErrors,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA8CM,SAAS,0CAAwC,KAAkC,EAAE,KA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SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC9K;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDateRangePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DateRange, RangeCalendarProps} from '@react-types/calendar';\nimport {DateRangePickerState} from '@react-stately/datepicker';\nimport {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateRangePickerAria extends ValidationResult {\n /** Props for the date range picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date fields and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the start date field. */\n startFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the end date field. */\n endFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the range calendar within the popover dialog. */\n calendarProps: RangeCalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element | null>): DateRangePickerAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let range = state.formatValue(locale, {month: 'long'});\n let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';\n let descProps = useDescription(description);\n\n let startFieldProps = {\n 'aria-label': stringFormatter.format('startDate'),\n 'aria-labelledby': labelledBy\n };\n\n let endFieldProps = {\n 'aria-label': stringFormatter.format('endDate'),\n 'aria-labelledby': labelledBy\n };\n\n let buttonId = useId();\n let dialogId = useId();\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let focusManager = useMemo(() => createFocusManager(ref, {\n // Exclude the button from the focus manager.\n accept: element => element.id !== buttonId\n }), [ref, buttonId]);\n\n let commonFieldProps = {\n [focusManagerSymbol]: focusManager,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n granularity: props.granularity,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior\n };\n\n let domProps = filterDOMProps(props);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n startFieldProps: {\n ...startFieldProps,\n ...commonFieldProps,\n value: state.value?.start ?? null,\n defaultValue: state.defaultValue?.start,\n onChange: start => state.setDateTime('start', start),\n autoFocus: props.autoFocus,\n name: props.startName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n startFieldValidation.current = e;\n state.updateValidation(mergeValidation(e, endFieldValidation.current));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n endFieldProps: {\n ...endFieldProps,\n ...commonFieldProps,\n value: state.value?.end ?? null,\n defaultValue: state.defaultValue?.end,\n onChange: end => state.setDateTime('end', end),\n name: props.endName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n endFieldValidation.current = e;\n state.updateValidation(mergeValidation(startFieldValidation.current, e));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n descriptionProps,\n errorMessageProps,\n calendarProps: {\n autoFocus: true,\n value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,\n onChange: state.setDateRange,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDateRangePicker.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA8CM,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AM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDateRangePicker.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DateRange, RangeCalendarProps} from '@react-types/calendar';\nimport {DateRangePickerState} from '@react-stately/datepicker';\nimport {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateRangePickerAria extends ValidationResult {\n /** Props for the date range picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date fields and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the start date field. */\n startFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the end date field. */\n endFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the range calendar within the popover dialog. */\n calendarProps: RangeCalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element | null>): DateRangePickerAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let range = state.formatValue(locale, {month: 'long'});\n let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';\n let descProps = useDescription(description);\n\n let startFieldProps = {\n 'aria-label': stringFormatter.format('startDate'),\n 'aria-labelledby': labelledBy\n };\n\n let endFieldProps = {\n 'aria-label': stringFormatter.format('endDate'),\n 'aria-labelledby': labelledBy\n };\n\n let buttonId = useId();\n let dialogId = useId();\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let focusManager = useMemo(() => createFocusManager(ref, {\n // Exclude the button from the focus manager.\n accept: element => element.id !== buttonId\n }), [ref, buttonId]);\n\n let commonFieldProps = {\n [focusManagerSymbol]: focusManager,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n granularity: props.granularity,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior\n };\n\n let domProps = filterDOMProps(props);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!dialog?.contains(e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n startFieldProps: {\n ...startFieldProps,\n ...commonFieldProps,\n value: state.value?.start ?? null,\n defaultValue: state.defaultValue?.start,\n onChange: start => state.setDateTime('start', start),\n autoFocus: props.autoFocus,\n name: props.startName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n startFieldValidation.current = e;\n state.updateValidation(mergeValidation(e, endFieldValidation.current));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n endFieldProps: {\n ...endFieldProps,\n ...commonFieldProps,\n value: state.value?.end ?? null,\n defaultValue: state.defaultValue?.end,\n onChange: end => state.setDateTime('end', end),\n name: props.endName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n endFieldValidation.current = e;\n state.updateValidation(mergeValidation(startFieldValidation.current, e));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n descriptionProps,\n errorMessageProps,\n calendarProps: {\n autoFocus: true,\n value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,\n onChange: state.setDateRange,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),\n firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDateRangePicker.module.js.map"}
@@ -228,8 +228,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
228
228
  if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {
229
229
  enteredKeys.current = '';
230
230
  if (shouldSetValue) focusManager.focusNext();
231
- } else if (shouldSetValue) // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)
232
- enteredKeys.current = newValue;
231
+ } else enteredKeys.current = newValue;
233
232
  break;
234
233
  }
235
234
  }
@@ -333,9 +332,9 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
333
332
  caretColor: 'transparent'
334
333
  };
335
334
  if (direction === 'rtl') {
336
- // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
335
+ // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
337
336
  // 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.
338
- // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
337
+ // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
339
338
  segmentStyle.unicodeBidi = 'embed';
340
339
  let format = options[segment.type];
341
340
  if (format === 'numeric' || format === '2-digit') segmentStyle.direction = 'ltr';
@@ -1 +1 @@
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,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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 {getScrollParent, isIOS, isMac, mergeProps, 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,\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 if (segment.maxValue !== undefined) {\n state.setSegment(segment.type, segment.maxValue);\n }\n },\n onDecrementToMin: () => {\n enteredKeys.current = '';\n if (segment.minValue !== undefined) {\n state.setSegment(segment.type, segment.minValue);\n }\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') {\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', 12);\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 let allowsZero = segment.minValue === 0;\n if (segment.type === 'hour' && state.dateFormatter.resolvedOptions().hour12) {\n switch (state.dateFormatter.resolvedOptions().hourCycle) {\n case 'h11':\n if (numberValue > 11) {\n segmentValue = parser.parse(key);\n }\n break;\n case 'h12':\n allowsZero = false;\n if (numberValue > 12) {\n segmentValue = parser.parse(key);\n }\n break;\n }\n\n if (segment.value !== undefined && segment.value >= 12 && numberValue > 1) {\n numberValue += 12;\n }\n } else if (segment.maxValue !== undefined && numberValue > segment.maxValue) {\n segmentValue = parser.parse(key);\n }\n\n if (isNaN(numberValue)) {\n return;\n }\n\n let shouldSetValue = segmentValue !== 0 || allowsZero;\n if (shouldSetValue) {\n state.setSegment(segment.type, segmentValue);\n }\n\n if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {\n enteredKeys.current = '';\n if (shouldSetValue) {\n focusManager.focusNext();\n }\n } else if (shouldSetValue) {\n // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)\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 && ref.current?.contains(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 // 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 (document.activeElement === 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
+ {"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,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C,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 {getScrollParent, isIOS, isMac, mergeProps, 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,\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 if (segment.maxValue !== undefined) {\n state.setSegment(segment.type, segment.maxValue);\n }\n },\n onDecrementToMin: () => {\n enteredKeys.current = '';\n if (segment.minValue !== undefined) {\n state.setSegment(segment.type, segment.minValue);\n }\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') {\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', 12);\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 let allowsZero = segment.minValue === 0;\n if (segment.type === 'hour' && state.dateFormatter.resolvedOptions().hour12) {\n switch (state.dateFormatter.resolvedOptions().hourCycle) {\n case 'h11':\n if (numberValue > 11) {\n segmentValue = parser.parse(key);\n }\n break;\n case 'h12':\n allowsZero = false;\n if (numberValue > 12) {\n segmentValue = parser.parse(key);\n }\n break;\n }\n\n if (segment.value !== undefined && segment.value >= 12 && numberValue > 1) {\n numberValue += 12;\n }\n } else if (segment.maxValue !== undefined && numberValue > segment.maxValue) {\n segmentValue = parser.parse(key);\n }\n\n if (isNaN(numberValue)) {\n return;\n }\n\n let shouldSetValue = segmentValue !== 0 || allowsZero;\n if (shouldSetValue) {\n state.setSegment(segment.type, segmentValue);\n }\n\n if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {\n enteredKeys.current = '';\n if (shouldSetValue) {\n focusManager.focusNext();\n }\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 && ref.current?.contains(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 (document.activeElement === 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"}
@@ -218,8 +218,7 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
218
218
  if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {
219
219
  enteredKeys.current = '';
220
220
  if (shouldSetValue) focusManager.focusNext();
221
- } else if (shouldSetValue) // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)
222
- enteredKeys.current = newValue;
221
+ } else enteredKeys.current = newValue;
223
222
  break;
224
223
  }
225
224
  }
@@ -323,9 +322,9 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
323
322
  caretColor: 'transparent'
324
323
  };
325
324
  if (direction === 'rtl') {
326
- // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
325
+ // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
327
326
  // 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.
328
- // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
327
+ // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
329
328
  segmentStyle.unicodeBidi = 'embed';
330
329
  let format = options[segment.type];
331
330
  if (format === 'numeric' || format === '2-digit') segmentStyle.direction = 'ltr';
@@ -218,8 +218,7 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
218
218
  if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {
219
219
  enteredKeys.current = '';
220
220
  if (shouldSetValue) focusManager.focusNext();
221
- } else if (shouldSetValue) // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)
222
- enteredKeys.current = newValue;
221
+ } else enteredKeys.current = newValue;
223
222
  break;
224
223
  }
225
224
  }
@@ -323,9 +322,9 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
323
322
  caretColor: 'transparent'
324
323
  };
325
324
  if (direction === 'rtl') {
326
- // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
325
+ // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
327
326
  // 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.
328
- // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
327
+ // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
329
328
  segmentStyle.unicodeBidi = 'embed';
330
329
  let format = options[segment.type];
331
330
  if (format === 'numeric' || format === '2-digit') segmentStyle.direction = 'ltr';
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAuBM,SAAS,yCAAe,OAAoB,EAAE,KAAqB,EAAE,GAAkC;IAC5G,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAClC,IAAI,eAAe,CAAA,GAAA,yCAAc;IACjC,IAAI,aAAC,SAAS,kBAAE,cAAc,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;IAE9E,IAAI,YAAY,QAAQ,aAAa,GAAG,KAAK,QAAQ,IAAI;IACzD,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAM,MAAM,aAAa,CAAC,eAAe,IAAI;QAAC,MAAM,aAAa;KAAC;IACxF,IAAI,qBAAqB,CAAA,GAAA,uBAAe,EAAE;QAAC,OAAO;QAAQ,UAAU,QAAQ,QAAQ;IAAA;IACpF,IAAI,oBAAoB,CAAA,GAAA,uBAAe,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,IAA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ACA,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 {getScrollParent, isIOS, isMac, mergeProps, 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,\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 if (segment.maxValue !== undefined) {\n state.setSegment(segment.type, segment.maxValue);\n }\n },\n onDecrementToMin: () => {\n enteredKeys.current = '';\n if (segment.minValue !== undefined) {\n state.setSegment(segment.type, segment.minValue);\n }\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') {\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', 12);\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 let allowsZero = segment.minValue === 0;\n if (segment.type === 'hour' && state.dateFormatter.resolvedOptions().hour12) {\n switch (state.dateFormatter.resolvedOptions().hourCycle) {\n case 'h11':\n if (numberValue > 11) {\n segmentValue = parser.parse(key);\n }\n break;\n case 'h12':\n allowsZero = false;\n if (numberValue > 12) {\n segmentValue = parser.parse(key);\n }\n break;\n }\n\n if (segment.value !== undefined && segment.value >= 12 && numberValue > 1) {\n numberValue += 12;\n }\n } else if (segment.maxValue !== undefined && numberValue > segment.maxValue) {\n segmentValue = parser.parse(key);\n }\n\n if (isNaN(numberValue)) {\n return;\n }\n\n let shouldSetValue = segmentValue !== 0 || allowsZero;\n if (shouldSetValue) {\n state.setSegment(segment.type, segmentValue);\n }\n\n if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {\n enteredKeys.current = '';\n if (shouldSetValue) {\n focusManager.focusNext();\n }\n } else if (shouldSetValue) {\n // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)\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 && ref.current?.contains(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 // 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 (document.activeElement === 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.module.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAuBM,SAAS,yCAAe,OAAoB,EAAE,KAAqB,EAAE,GAAkC;IAC5G,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAClC,IAAI,eAAe,CAAA,GAAA,yCAAc;IACjC,IAAI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B;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,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,YAAI,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 {getScrollParent, isIOS, isMac, mergeProps, 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,\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 if (segment.maxValue !== undefined) {\n state.setSegment(segment.type, segment.maxValue);\n }\n },\n onDecrementToMin: () => {\n enteredKeys.current = '';\n if (segment.minValue !== undefined) {\n state.setSegment(segment.type, segment.minValue);\n }\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') {\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', 12);\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 let allowsZero = segment.minValue === 0;\n if (segment.type === 'hour' && state.dateFormatter.resolvedOptions().hour12) {\n switch (state.dateFormatter.resolvedOptions().hourCycle) {\n case 'h11':\n if (numberValue > 11) {\n segmentValue = parser.parse(key);\n }\n break;\n case 'h12':\n allowsZero = false;\n if (numberValue > 12) {\n segmentValue = parser.parse(key);\n }\n break;\n }\n\n if (segment.value !== undefined && segment.value >= 12 && numberValue > 1) {\n numberValue += 12;\n }\n } else if (segment.maxValue !== undefined && numberValue > segment.maxValue) {\n segmentValue = parser.parse(key);\n }\n\n if (isNaN(numberValue)) {\n return;\n }\n\n let shouldSetValue = segmentValue !== 0 || allowsZero;\n if (shouldSetValue) {\n state.setSegment(segment.type, segmentValue);\n }\n\n if (segment.maxValue !== undefined && (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {\n enteredKeys.current = '';\n if (shouldSetValue) {\n focusManager.focusNext();\n }\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 && ref.current?.contains(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 (document.activeElement === 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.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/datepicker",
3
- "version": "3.15.0",
3
+ "version": "3.15.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -26,23 +26,23 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@internationalized/date": "^3.8.2",
30
- "@internationalized/number": "^3.6.4",
29
+ "@internationalized/date": "^3.10.0",
30
+ "@internationalized/number": "^3.6.5",
31
31
  "@internationalized/string": "^3.2.7",
32
- "@react-aria/focus": "^3.21.0",
33
- "@react-aria/form": "^3.1.0",
34
- "@react-aria/i18n": "^3.12.11",
35
- "@react-aria/interactions": "^3.25.4",
36
- "@react-aria/label": "^3.7.20",
37
- "@react-aria/spinbutton": "^3.6.17",
38
- "@react-aria/utils": "^3.30.0",
39
- "@react-stately/datepicker": "^3.15.0",
40
- "@react-stately/form": "^3.2.0",
41
- "@react-types/button": "^3.13.0",
42
- "@react-types/calendar": "^3.7.3",
43
- "@react-types/datepicker": "^3.13.0",
44
- "@react-types/dialog": "^3.5.20",
45
- "@react-types/shared": "^3.31.0",
32
+ "@react-aria/focus": "^3.21.2",
33
+ "@react-aria/form": "^3.1.2",
34
+ "@react-aria/i18n": "^3.12.13",
35
+ "@react-aria/interactions": "^3.25.6",
36
+ "@react-aria/label": "^3.7.22",
37
+ "@react-aria/spinbutton": "^3.6.19",
38
+ "@react-aria/utils": "^3.31.0",
39
+ "@react-stately/datepicker": "^3.15.2",
40
+ "@react-stately/form": "^3.2.2",
41
+ "@react-types/button": "^3.14.1",
42
+ "@react-types/calendar": "^3.8.0",
43
+ "@react-types/datepicker": "^3.13.2",
44
+ "@react-types/dialog": "^3.5.22",
45
+ "@react-types/shared": "^3.32.1",
46
46
  "@swc/helpers": "^0.5.0"
47
47
  },
48
48
  "peerDependencies": {
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
55
+ "gitHead": "0bda51183baa23306342af32a82012ea0fe0f2dc"
56
56
  }
@@ -181,7 +181,9 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
181
181
  isDateUnavailable: props.isDateUnavailable,
182
182
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
183
183
  isInvalid: state.isInvalid,
184
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))
184
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),
185
+ firstDayOfWeek: props.firstDayOfWeek,
186
+ pageBehavior: props.pageBehavior
185
187
  },
186
188
  isInvalid,
187
189
  validationErrors,
@@ -232,7 +232,9 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
232
232
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
233
233
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
234
234
  isInvalid: state.isInvalid,
235
- errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))
235
+ errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),
236
+ firstDayOfWeek: props.firstDayOfWeek,
237
+ pageBehavior: props.pageBehavior
236
238
  },
237
239
  isInvalid,
238
240
  validationErrors,
@@ -256,8 +256,7 @@ export function useDateSegment(segment: DateSegment, state: DateFieldState, ref:
256
256
  if (shouldSetValue) {
257
257
  focusManager.focusNext();
258
258
  }
259
- } else if (shouldSetValue) {
260
- // Don't accept leading zeros except for fields that accept 0 as a entire value (aka 00 for minutes/seconds/etc)
259
+ } else {
261
260
  enteredKeys.current = newValue;
262
261
  }
263
262
  break;
@@ -326,6 +325,7 @@ export function useDateSegment(segment: DateSegment, state: DateFieldState, ref:
326
325
  if (ref.current) {
327
326
  ref.current.textContent = compositionRef.current;
328
327
  }
328
+
329
329
  // Android sometimes fires key presses of letters as composition events. Need to handle am/pm keys here too.
330
330
  // Can also happen e.g. with Pinyin keyboard on iOS.
331
331
  if (data != null && (startsWith(am, data) || startsWith(pm, data))) {
@@ -387,9 +387,9 @@ export function useDateSegment(segment: DateSegment, state: DateFieldState, ref:
387
387
 
388
388
  let segmentStyle: CSSProperties = {caretColor: 'transparent'};
389
389
  if (direction === 'rtl') {
390
- // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
390
+ // While the bidirectional algorithm seems to work properly on inline elements with actual values, it returns different results for placeholder strings.
391
391
  // 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.
392
- // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
392
+ // However, we apply this to both placeholders and date segments with an actual value because the date segments will shift around when deleting otherwise.
393
393
  segmentStyle.unicodeBidi = 'embed';
394
394
  let format = options[segment.type];
395
395
  if (format === 'numeric' || format === '2-digit') {