react-stately 3.46.0 → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/Color.cjs.map +1 -1
- package/dist/exports/Color.js.map +1 -1
- package/dist/exports/Color.mjs.map +1 -1
- package/dist/exports/index.cjs.map +1 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/private/autocomplete/useAutocompleteState.cjs.map +1 -1
- package/dist/exports/private/autocomplete/useAutocompleteState.js.map +1 -1
- package/dist/exports/private/autocomplete/useAutocompleteState.mjs.map +1 -1
- package/dist/exports/private/collections/getChildNodes.cjs.map +1 -1
- package/dist/exports/private/collections/getChildNodes.js.map +1 -1
- package/dist/exports/private/collections/getChildNodes.mjs.map +1 -1
- package/dist/exports/private/flags/flags.cjs.map +1 -1
- package/dist/exports/private/flags/flags.js.map +1 -1
- package/dist/exports/private/flags/flags.mjs.map +1 -1
- package/dist/exports/private/form/useFormValidationState.cjs.map +1 -1
- package/dist/exports/private/form/useFormValidationState.js.map +1 -1
- package/dist/exports/private/form/useFormValidationState.mjs.map +1 -1
- package/dist/exports/private/grid/GridCollection.cjs.map +1 -1
- package/dist/exports/private/grid/GridCollection.js.map +1 -1
- package/dist/exports/private/grid/GridCollection.mjs.map +1 -1
- package/dist/exports/private/steplist/useStepListState.cjs.map +1 -1
- package/dist/exports/private/steplist/useStepListState.js.map +1 -1
- package/dist/exports/private/steplist/useStepListState.mjs.map +1 -1
- package/dist/exports/private/table/TableCollection.cjs.map +1 -1
- package/dist/exports/private/table/TableCollection.js.map +1 -1
- package/dist/exports/private/table/TableCollection.mjs.map +1 -1
- package/dist/exports/private/table/useTreeGridState.cjs.map +1 -1
- package/dist/exports/private/table/useTreeGridState.js.map +1 -1
- package/dist/exports/private/table/useTreeGridState.mjs.map +1 -1
- package/dist/exports/useAsyncList.cjs.map +1 -1
- package/dist/exports/useAsyncList.js.map +1 -1
- package/dist/exports/useAsyncList.mjs.map +1 -1
- package/dist/exports/useCalendarState.cjs.map +1 -1
- package/dist/exports/useCalendarState.js.map +1 -1
- package/dist/exports/useCalendarState.mjs.map +1 -1
- package/dist/exports/useColorAreaState.cjs.map +1 -1
- package/dist/exports/useColorAreaState.js.map +1 -1
- package/dist/exports/useColorAreaState.mjs.map +1 -1
- package/dist/exports/useColorFieldState.cjs.map +1 -1
- package/dist/exports/useColorFieldState.js.map +1 -1
- package/dist/exports/useColorFieldState.mjs.map +1 -1
- package/dist/exports/useColorPickerState.cjs.map +1 -1
- package/dist/exports/useColorPickerState.js.map +1 -1
- package/dist/exports/useColorPickerState.mjs.map +1 -1
- package/dist/exports/useColorSliderState.cjs.map +1 -1
- package/dist/exports/useColorSliderState.js.map +1 -1
- package/dist/exports/useColorSliderState.mjs.map +1 -1
- package/dist/exports/useColorWheelState.cjs.map +1 -1
- package/dist/exports/useColorWheelState.js.map +1 -1
- package/dist/exports/useColorWheelState.mjs.map +1 -1
- package/dist/exports/useComboBoxState.cjs +1 -1
- package/dist/exports/useComboBoxState.cjs.map +1 -1
- package/dist/exports/useComboBoxState.js +1 -1
- package/dist/exports/useComboBoxState.js.map +1 -1
- package/dist/exports/useComboBoxState.mjs +1 -1
- package/dist/exports/useComboBoxState.mjs.map +1 -1
- package/dist/exports/useDateFieldState.cjs.map +1 -1
- package/dist/exports/useDateFieldState.js.map +1 -1
- package/dist/exports/useDateFieldState.mjs.map +1 -1
- package/dist/exports/useDatePickerState.cjs.map +1 -1
- package/dist/exports/useDatePickerState.js.map +1 -1
- package/dist/exports/useDatePickerState.mjs.map +1 -1
- package/dist/exports/useDateRangePickerState.cjs.map +1 -1
- package/dist/exports/useDateRangePickerState.js.map +1 -1
- package/dist/exports/useDateRangePickerState.mjs.map +1 -1
- package/dist/exports/useDisclosureGroupState.cjs.map +1 -1
- package/dist/exports/useDisclosureGroupState.js.map +1 -1
- package/dist/exports/useDisclosureGroupState.mjs.map +1 -1
- package/dist/exports/useDraggableCollectionState.cjs.map +1 -1
- package/dist/exports/useDraggableCollectionState.js.map +1 -1
- package/dist/exports/useDraggableCollectionState.mjs.map +1 -1
- package/dist/exports/useDroppableCollectionState.cjs.map +1 -1
- package/dist/exports/useDroppableCollectionState.js.map +1 -1
- package/dist/exports/useDroppableCollectionState.mjs.map +1 -1
- package/dist/exports/useMenuTriggerState.cjs.map +1 -1
- package/dist/exports/useMenuTriggerState.js.map +1 -1
- package/dist/exports/useMenuTriggerState.mjs.map +1 -1
- package/dist/exports/useMultipleSelectionState.cjs.map +1 -1
- package/dist/exports/useMultipleSelectionState.js.map +1 -1
- package/dist/exports/useMultipleSelectionState.mjs.map +1 -1
- package/dist/exports/useOverlayTriggerState.cjs.map +1 -1
- package/dist/exports/useOverlayTriggerState.js.map +1 -1
- package/dist/exports/useOverlayTriggerState.mjs.map +1 -1
- package/dist/exports/useRangeCalendarState.cjs.map +1 -1
- package/dist/exports/useRangeCalendarState.js.map +1 -1
- package/dist/exports/useRangeCalendarState.mjs.map +1 -1
- package/dist/exports/useSelectState.cjs.map +1 -1
- package/dist/exports/useSelectState.js.map +1 -1
- package/dist/exports/useSelectState.mjs.map +1 -1
- package/dist/exports/useSingleSelectListState.cjs.map +1 -1
- package/dist/exports/useSingleSelectListState.js.map +1 -1
- package/dist/exports/useSingleSelectListState.mjs.map +1 -1
- package/dist/exports/useTableState.cjs.map +1 -1
- package/dist/exports/useTableState.js.map +1 -1
- package/dist/exports/useTableState.mjs.map +1 -1
- package/dist/exports/useTimeFieldState.cjs.map +1 -1
- package/dist/exports/useTimeFieldState.js.map +1 -1
- package/dist/exports/useTimeFieldState.mjs.map +1 -1
- package/dist/exports/useToastState.cjs.map +1 -1
- package/dist/exports/useToastState.js.map +1 -1
- package/dist/exports/useToastState.mjs.map +1 -1
- package/dist/private/autocomplete/useAutocompleteState.cjs.map +1 -1
- package/dist/private/autocomplete/useAutocompleteState.js.map +1 -1
- package/dist/private/autocomplete/useAutocompleteState.mjs.map +1 -1
- package/dist/private/calendar/useCalendarState.cjs +82 -30
- package/dist/private/calendar/useCalendarState.cjs.map +1 -1
- package/dist/private/calendar/useCalendarState.js +85 -32
- package/dist/private/calendar/useCalendarState.js.map +1 -1
- package/dist/private/calendar/useCalendarState.mjs +84 -32
- package/dist/private/calendar/useCalendarState.mjs.map +1 -1
- package/dist/private/calendar/useRangeCalendarState.cjs +53 -40
- package/dist/private/calendar/useRangeCalendarState.cjs.map +1 -1
- package/dist/private/calendar/useRangeCalendarState.js +55 -43
- package/dist/private/calendar/useRangeCalendarState.js.map +1 -1
- package/dist/private/calendar/useRangeCalendarState.mjs +55 -42
- package/dist/private/calendar/useRangeCalendarState.mjs.map +1 -1
- package/dist/private/calendar/utils.cjs +6 -1
- package/dist/private/calendar/utils.cjs.map +1 -1
- package/dist/private/calendar/utils.js +6 -2
- package/dist/private/calendar/utils.js.map +1 -1
- package/dist/private/calendar/utils.mjs +6 -2
- package/dist/private/calendar/utils.mjs.map +1 -1
- package/dist/private/checkbox/useCheckboxGroupState.cjs.map +1 -1
- package/dist/private/checkbox/useCheckboxGroupState.js.map +1 -1
- package/dist/private/checkbox/useCheckboxGroupState.mjs.map +1 -1
- package/dist/private/collections/CollectionBuilder.cjs.map +1 -1
- package/dist/private/collections/CollectionBuilder.js.map +1 -1
- package/dist/private/collections/CollectionBuilder.mjs.map +1 -1
- package/dist/private/collections/Item.cjs +1 -0
- package/dist/private/collections/Item.cjs.map +1 -1
- package/dist/private/collections/Item.js +1 -0
- package/dist/private/collections/Item.js.map +1 -1
- package/dist/private/collections/Item.mjs +1 -0
- package/dist/private/collections/Item.mjs.map +1 -1
- package/dist/private/collections/Section.cjs +1 -0
- package/dist/private/collections/Section.cjs.map +1 -1
- package/dist/private/collections/Section.js +1 -0
- package/dist/private/collections/Section.js.map +1 -1
- package/dist/private/collections/Section.mjs +1 -0
- package/dist/private/collections/Section.mjs.map +1 -1
- package/dist/private/collections/getChildNodes.cjs.map +1 -1
- package/dist/private/collections/getChildNodes.js.map +1 -1
- package/dist/private/collections/getChildNodes.mjs.map +1 -1
- package/dist/private/collections/useCollection.cjs.map +1 -1
- package/dist/private/collections/useCollection.js.map +1 -1
- package/dist/private/collections/useCollection.mjs.map +1 -1
- package/dist/private/color/Color.cjs +15 -9
- package/dist/private/color/Color.cjs.map +1 -1
- package/dist/private/color/Color.js +15 -9
- package/dist/private/color/Color.js.map +1 -1
- package/dist/private/color/Color.mjs +15 -9
- package/dist/private/color/Color.mjs.map +1 -1
- package/dist/private/color/useColorAreaState.cjs.map +1 -1
- package/dist/private/color/useColorAreaState.js.map +1 -1
- package/dist/private/color/useColorAreaState.mjs.map +1 -1
- package/dist/private/color/useColorChannelFieldState.cjs.map +1 -1
- package/dist/private/color/useColorChannelFieldState.js.map +1 -1
- package/dist/private/color/useColorChannelFieldState.mjs.map +1 -1
- package/dist/private/color/useColorFieldState.cjs.map +1 -1
- package/dist/private/color/useColorFieldState.js.map +1 -1
- package/dist/private/color/useColorFieldState.mjs.map +1 -1
- package/dist/private/color/useColorPickerState.cjs.map +1 -1
- package/dist/private/color/useColorPickerState.js.map +1 -1
- package/dist/private/color/useColorPickerState.mjs.map +1 -1
- package/dist/private/color/useColorSliderState.cjs +5 -3
- package/dist/private/color/useColorSliderState.cjs.map +1 -1
- package/dist/private/color/useColorSliderState.js +5 -3
- package/dist/private/color/useColorSliderState.js.map +1 -1
- package/dist/private/color/useColorSliderState.mjs +5 -3
- package/dist/private/color/useColorSliderState.mjs.map +1 -1
- package/dist/private/color/useColorWheelState.cjs.map +1 -1
- package/dist/private/color/useColorWheelState.js.map +1 -1
- package/dist/private/color/useColorWheelState.mjs.map +1 -1
- package/dist/private/combobox/useComboBoxState.cjs +8 -2
- package/dist/private/combobox/useComboBoxState.cjs.map +1 -1
- package/dist/private/combobox/useComboBoxState.js +8 -2
- package/dist/private/combobox/useComboBoxState.js.map +1 -1
- package/dist/private/combobox/useComboBoxState.mjs +8 -2
- package/dist/private/combobox/useComboBoxState.mjs.map +1 -1
- package/dist/private/data/useAsyncList.cjs.map +1 -1
- package/dist/private/data/useAsyncList.js.map +1 -1
- package/dist/private/data/useAsyncList.mjs.map +1 -1
- package/dist/private/data/useListData.cjs.map +1 -1
- package/dist/private/data/useListData.js.map +1 -1
- package/dist/private/data/useListData.mjs.map +1 -1
- package/dist/private/data/useTreeData.cjs.map +1 -1
- package/dist/private/data/useTreeData.js.map +1 -1
- package/dist/private/data/useTreeData.mjs.map +1 -1
- package/dist/private/datepicker/IncompleteDate.cjs +8 -2
- package/dist/private/datepicker/IncompleteDate.cjs.map +1 -1
- package/dist/private/datepicker/IncompleteDate.js +8 -2
- package/dist/private/datepicker/IncompleteDate.js.map +1 -1
- package/dist/private/datepicker/IncompleteDate.mjs +8 -2
- package/dist/private/datepicker/IncompleteDate.mjs.map +1 -1
- package/dist/private/datepicker/placeholders.cjs +5 -0
- package/dist/private/datepicker/placeholders.cjs.map +1 -1
- package/dist/private/datepicker/placeholders.js +5 -0
- package/dist/private/datepicker/placeholders.js.map +1 -1
- package/dist/private/datepicker/placeholders.mjs +5 -0
- package/dist/private/datepicker/placeholders.mjs.map +1 -1
- package/dist/private/datepicker/useDateFieldState.cjs.map +1 -1
- package/dist/private/datepicker/useDateFieldState.js.map +1 -1
- package/dist/private/datepicker/useDateFieldState.mjs.map +1 -1
- package/dist/private/datepicker/useDatePickerState.cjs.map +1 -1
- package/dist/private/datepicker/useDatePickerState.js.map +1 -1
- package/dist/private/datepicker/useDatePickerState.mjs.map +1 -1
- package/dist/private/datepicker/useDateRangePickerState.cjs +1 -1
- package/dist/private/datepicker/useDateRangePickerState.cjs.map +1 -1
- package/dist/private/datepicker/useDateRangePickerState.js +1 -1
- package/dist/private/datepicker/useDateRangePickerState.js.map +1 -1
- package/dist/private/datepicker/useDateRangePickerState.mjs +1 -1
- package/dist/private/datepicker/useDateRangePickerState.mjs.map +1 -1
- package/dist/private/datepicker/useTimeFieldState.cjs.map +1 -1
- package/dist/private/datepicker/useTimeFieldState.js.map +1 -1
- package/dist/private/datepicker/useTimeFieldState.mjs.map +1 -1
- package/dist/private/datepicker/utils.cjs +2 -2
- package/dist/private/datepicker/utils.cjs.map +1 -1
- package/dist/private/datepicker/utils.js +2 -2
- package/dist/private/datepicker/utils.js.map +1 -1
- package/dist/private/datepicker/utils.mjs +2 -2
- package/dist/private/datepicker/utils.mjs.map +1 -1
- package/dist/private/disclosure/useDisclosureGroupState.cjs.map +1 -1
- package/dist/private/disclosure/useDisclosureGroupState.js.map +1 -1
- package/dist/private/disclosure/useDisclosureGroupState.mjs.map +1 -1
- package/dist/private/disclosure/useDisclosureState.cjs.map +1 -1
- package/dist/private/disclosure/useDisclosureState.js.map +1 -1
- package/dist/private/disclosure/useDisclosureState.mjs.map +1 -1
- package/dist/private/dnd/useDraggableCollectionState.cjs.map +1 -1
- package/dist/private/dnd/useDraggableCollectionState.js.map +1 -1
- package/dist/private/dnd/useDraggableCollectionState.mjs.map +1 -1
- package/dist/private/dnd/useDroppableCollectionState.cjs.map +1 -1
- package/dist/private/dnd/useDroppableCollectionState.js.map +1 -1
- package/dist/private/dnd/useDroppableCollectionState.mjs.map +1 -1
- package/dist/private/form/useFormValidationState.cjs.map +1 -1
- package/dist/private/form/useFormValidationState.js.map +1 -1
- package/dist/private/form/useFormValidationState.mjs.map +1 -1
- package/dist/private/grid/GridCollection.cjs.map +1 -1
- package/dist/private/grid/GridCollection.js.map +1 -1
- package/dist/private/grid/GridCollection.mjs.map +1 -1
- package/dist/private/grid/useGridState.cjs.map +1 -1
- package/dist/private/grid/useGridState.js.map +1 -1
- package/dist/private/grid/useGridState.mjs.map +1 -1
- package/dist/private/layout/GridLayout.cjs +8 -3
- package/dist/private/layout/GridLayout.cjs.map +1 -1
- package/dist/private/layout/GridLayout.js +8 -3
- package/dist/private/layout/GridLayout.js.map +1 -1
- package/dist/private/layout/GridLayout.mjs +8 -3
- package/dist/private/layout/GridLayout.mjs.map +1 -1
- package/dist/private/layout/ListLayout.cjs +1 -1
- package/dist/private/layout/ListLayout.cjs.map +1 -1
- package/dist/private/layout/ListLayout.js +2 -1
- package/dist/private/layout/ListLayout.js.map +1 -1
- package/dist/private/layout/ListLayout.mjs +1 -1
- package/dist/private/layout/ListLayout.mjs.map +1 -1
- package/dist/private/layout/TableLayout.cjs +60 -35
- package/dist/private/layout/TableLayout.cjs.map +1 -1
- package/dist/private/layout/TableLayout.js +65 -38
- package/dist/private/layout/TableLayout.js.map +1 -1
- package/dist/private/layout/TableLayout.mjs +61 -36
- package/dist/private/layout/TableLayout.mjs.map +1 -1
- package/dist/private/layout/WaterfallLayout.cjs.map +1 -1
- package/dist/private/layout/WaterfallLayout.js.map +1 -1
- package/dist/private/layout/WaterfallLayout.mjs.map +1 -1
- package/dist/private/list/ListCollection.cjs.map +1 -1
- package/dist/private/list/ListCollection.js.map +1 -1
- package/dist/private/list/ListCollection.mjs.map +1 -1
- package/dist/private/list/useListState.cjs.map +1 -1
- package/dist/private/list/useListState.js.map +1 -1
- package/dist/private/list/useListState.mjs.map +1 -1
- package/dist/private/list/useSingleSelectListState.cjs.map +1 -1
- package/dist/private/list/useSingleSelectListState.js.map +1 -1
- package/dist/private/list/useSingleSelectListState.mjs.map +1 -1
- package/dist/private/menu/useMenuTriggerState.cjs.map +1 -1
- package/dist/private/menu/useMenuTriggerState.js.map +1 -1
- package/dist/private/menu/useMenuTriggerState.mjs.map +1 -1
- package/dist/private/menu/useSubmenuTriggerState.cjs.map +1 -1
- package/dist/private/menu/useSubmenuTriggerState.js.map +1 -1
- package/dist/private/menu/useSubmenuTriggerState.mjs.map +1 -1
- package/dist/private/numberfield/useNumberFieldState.cjs +13 -1
- package/dist/private/numberfield/useNumberFieldState.cjs.map +1 -1
- package/dist/private/numberfield/useNumberFieldState.js +13 -1
- package/dist/private/numberfield/useNumberFieldState.js.map +1 -1
- package/dist/private/numberfield/useNumberFieldState.mjs +13 -1
- package/dist/private/numberfield/useNumberFieldState.mjs.map +1 -1
- package/dist/private/overlays/useOverlayTriggerState.cjs.map +1 -1
- package/dist/private/overlays/useOverlayTriggerState.js.map +1 -1
- package/dist/private/overlays/useOverlayTriggerState.mjs.map +1 -1
- package/dist/private/radio/useRadioGroupState.cjs.map +1 -1
- package/dist/private/radio/useRadioGroupState.js.map +1 -1
- package/dist/private/radio/useRadioGroupState.mjs.map +1 -1
- package/dist/private/searchfield/useSearchFieldState.cjs.map +1 -1
- package/dist/private/searchfield/useSearchFieldState.js.map +1 -1
- package/dist/private/searchfield/useSearchFieldState.mjs.map +1 -1
- package/dist/private/select/useSelectState.cjs.map +1 -1
- package/dist/private/select/useSelectState.js.map +1 -1
- package/dist/private/select/useSelectState.mjs.map +1 -1
- package/dist/private/selection/SelectionManager.cjs +2 -1
- package/dist/private/selection/SelectionManager.cjs.map +1 -1
- package/dist/private/selection/SelectionManager.js +3 -2
- package/dist/private/selection/SelectionManager.js.map +1 -1
- package/dist/private/selection/SelectionManager.mjs +2 -1
- package/dist/private/selection/SelectionManager.mjs.map +1 -1
- package/dist/private/selection/useMultipleSelectionState.cjs.map +1 -1
- package/dist/private/selection/useMultipleSelectionState.js.map +1 -1
- package/dist/private/selection/useMultipleSelectionState.mjs.map +1 -1
- package/dist/private/slider/useSliderState.cjs +22 -2
- package/dist/private/slider/useSliderState.cjs.map +1 -1
- package/dist/private/slider/useSliderState.js +22 -2
- package/dist/private/slider/useSliderState.js.map +1 -1
- package/dist/private/slider/useSliderState.mjs +22 -2
- package/dist/private/slider/useSliderState.mjs.map +1 -1
- package/dist/private/steplist/useStepListState.cjs.map +1 -1
- package/dist/private/steplist/useStepListState.js.map +1 -1
- package/dist/private/steplist/useStepListState.mjs.map +1 -1
- package/dist/private/table/Cell.cjs +2 -1
- package/dist/private/table/Cell.cjs.map +1 -1
- package/dist/private/table/Cell.js +2 -1
- package/dist/private/table/Cell.js.map +1 -1
- package/dist/private/table/Cell.mjs +2 -1
- package/dist/private/table/Cell.mjs.map +1 -1
- package/dist/private/table/Column.cjs +1 -0
- package/dist/private/table/Column.cjs.map +1 -1
- package/dist/private/table/Column.js +1 -0
- package/dist/private/table/Column.js.map +1 -1
- package/dist/private/table/Column.mjs +1 -0
- package/dist/private/table/Column.mjs.map +1 -1
- package/dist/private/table/Row.cjs +2 -1
- package/dist/private/table/Row.cjs.map +1 -1
- package/dist/private/table/Row.js +2 -1
- package/dist/private/table/Row.js.map +1 -1
- package/dist/private/table/Row.mjs +2 -1
- package/dist/private/table/Row.mjs.map +1 -1
- package/dist/private/table/TableBody.cjs +4 -2
- package/dist/private/table/TableBody.cjs.map +1 -1
- package/dist/private/table/TableBody.js +4 -2
- package/dist/private/table/TableBody.js.map +1 -1
- package/dist/private/table/TableBody.mjs +4 -2
- package/dist/private/table/TableBody.mjs.map +1 -1
- package/dist/private/table/TableCollection.cjs +1 -1
- package/dist/private/table/TableCollection.cjs.map +1 -1
- package/dist/private/table/TableCollection.js +1 -1
- package/dist/private/table/TableCollection.js.map +1 -1
- package/dist/private/table/TableCollection.mjs +1 -1
- package/dist/private/table/TableCollection.mjs.map +1 -1
- package/dist/private/table/TableColumnLayout.cjs +4 -1
- package/dist/private/table/TableColumnLayout.cjs.map +1 -1
- package/dist/private/table/TableColumnLayout.js +4 -1
- package/dist/private/table/TableColumnLayout.js.map +1 -1
- package/dist/private/table/TableColumnLayout.mjs +4 -1
- package/dist/private/table/TableColumnLayout.mjs.map +1 -1
- package/dist/private/table/TableHeader.cjs +4 -2
- package/dist/private/table/TableHeader.cjs.map +1 -1
- package/dist/private/table/TableHeader.js +4 -2
- package/dist/private/table/TableHeader.js.map +1 -1
- package/dist/private/table/TableHeader.mjs +4 -2
- package/dist/private/table/TableHeader.mjs.map +1 -1
- package/dist/private/table/TableUtils.cjs +1 -1
- package/dist/private/table/TableUtils.cjs.map +1 -1
- package/dist/private/table/TableUtils.js +1 -1
- package/dist/private/table/TableUtils.js.map +1 -1
- package/dist/private/table/TableUtils.mjs +1 -1
- package/dist/private/table/TableUtils.mjs.map +1 -1
- package/dist/private/table/useTableColumnResizeState.cjs.map +1 -1
- package/dist/private/table/useTableColumnResizeState.js.map +1 -1
- package/dist/private/table/useTableColumnResizeState.mjs.map +1 -1
- package/dist/private/table/useTableState.cjs +2 -1
- package/dist/private/table/useTableState.cjs.map +1 -1
- package/dist/private/table/useTableState.js +2 -1
- package/dist/private/table/useTableState.js.map +1 -1
- package/dist/private/table/useTableState.mjs +2 -1
- package/dist/private/table/useTableState.mjs.map +1 -1
- package/dist/private/table/useTreeGridState.cjs +2 -1
- package/dist/private/table/useTreeGridState.cjs.map +1 -1
- package/dist/private/table/useTreeGridState.js +2 -1
- package/dist/private/table/useTreeGridState.js.map +1 -1
- package/dist/private/table/useTreeGridState.mjs +2 -1
- package/dist/private/table/useTreeGridState.mjs.map +1 -1
- package/dist/private/tabs/useTabListState.cjs.map +1 -1
- package/dist/private/tabs/useTabListState.js.map +1 -1
- package/dist/private/tabs/useTabListState.mjs.map +1 -1
- package/dist/private/toast/useToastState.cjs.map +1 -1
- package/dist/private/toast/useToastState.js.map +1 -1
- package/dist/private/toast/useToastState.mjs.map +1 -1
- package/dist/private/toggle/useToggleGroupState.cjs.map +1 -1
- package/dist/private/toggle/useToggleGroupState.js.map +1 -1
- package/dist/private/toggle/useToggleGroupState.mjs.map +1 -1
- package/dist/private/toggle/useToggleState.cjs.map +1 -1
- package/dist/private/toggle/useToggleState.js.map +1 -1
- package/dist/private/toggle/useToggleState.mjs.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.cjs.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.js.map +1 -1
- package/dist/private/tooltip/useTooltipTriggerState.mjs.map +1 -1
- package/dist/private/tree/TreeCollection.cjs.map +1 -1
- package/dist/private/tree/TreeCollection.js.map +1 -1
- package/dist/private/tree/TreeCollection.mjs.map +1 -1
- package/dist/private/tree/useTreeState.cjs.map +1 -1
- package/dist/private/tree/useTreeState.js.map +1 -1
- package/dist/private/tree/useTreeState.mjs.map +1 -1
- package/dist/private/utils/number.cjs +2 -1
- package/dist/private/utils/number.cjs.map +1 -1
- package/dist/private/utils/number.js +2 -1
- package/dist/private/utils/number.js.map +1 -1
- package/dist/private/utils/number.mjs +2 -1
- package/dist/private/utils/number.mjs.map +1 -1
- package/dist/private/utils/useControlledState.cjs.map +1 -1
- package/dist/private/utils/useControlledState.js.map +1 -1
- package/dist/private/utils/useControlledState.mjs.map +1 -1
- package/dist/private/virtualizer/Layout.cjs.map +1 -1
- package/dist/private/virtualizer/Layout.js.map +1 -1
- package/dist/private/virtualizer/Layout.mjs.map +1 -1
- package/dist/private/virtualizer/LayoutInfo.cjs +4 -2
- package/dist/private/virtualizer/LayoutInfo.cjs.map +1 -1
- package/dist/private/virtualizer/LayoutInfo.js +4 -2
- package/dist/private/virtualizer/LayoutInfo.js.map +1 -1
- package/dist/private/virtualizer/LayoutInfo.mjs +4 -2
- package/dist/private/virtualizer/LayoutInfo.mjs.map +1 -1
- package/dist/private/virtualizer/Rect.cjs +4 -0
- package/dist/private/virtualizer/Rect.cjs.map +1 -1
- package/dist/private/virtualizer/Rect.js +4 -0
- package/dist/private/virtualizer/Rect.js.map +1 -1
- package/dist/private/virtualizer/Rect.mjs +4 -0
- package/dist/private/virtualizer/Rect.mjs.map +1 -1
- package/dist/private/virtualizer/ReusableView.cjs.map +1 -1
- package/dist/private/virtualizer/ReusableView.js.map +1 -1
- package/dist/private/virtualizer/ReusableView.mjs.map +1 -1
- package/dist/private/virtualizer/Size.cjs.map +1 -1
- package/dist/private/virtualizer/Size.js.map +1 -1
- package/dist/private/virtualizer/Size.mjs.map +1 -1
- package/dist/private/virtualizer/Virtualizer.cjs +4 -4
- package/dist/private/virtualizer/Virtualizer.cjs.map +1 -1
- package/dist/private/virtualizer/Virtualizer.js +4 -4
- package/dist/private/virtualizer/Virtualizer.js.map +1 -1
- package/dist/private/virtualizer/Virtualizer.mjs +4 -4
- package/dist/private/virtualizer/Virtualizer.mjs.map +1 -1
- package/dist/private/virtualizer/useVirtualizerState.cjs.map +1 -1
- package/dist/private/virtualizer/useVirtualizerState.js.map +1 -1
- package/dist/private/virtualizer/useVirtualizerState.mjs.map +1 -1
- package/dist/types/exports/useCalendarState.d.ts +1 -1
- package/dist/types/src/autocomplete/useAutocompleteState.d.ts +4 -1
- package/dist/types/src/calendar/types.d.ts +50 -14
- package/dist/types/src/calendar/useCalendarState.d.ts +20 -6
- package/dist/types/src/calendar/useRangeCalendarState.d.ts +14 -5
- package/dist/types/src/calendar/utils.d.ts +1 -0
- package/dist/types/src/checkbox/useCheckboxGroupState.d.ts +1 -0
- package/dist/types/src/collections/useCollection.d.ts +1 -1
- package/dist/types/src/color/useColorAreaState.d.ts +21 -8
- package/dist/types/src/color/useColorFieldState.d.ts +2 -3
- package/dist/types/src/color/useColorSliderState.d.ts +4 -1
- package/dist/types/src/color/useColorWheelState.d.ts +5 -1
- package/dist/types/src/combobox/useComboBoxState.d.ts +19 -6
- package/dist/types/src/data/useAsyncList.d.ts +2 -2
- package/dist/types/src/data/useListData.d.ts +13 -1
- package/dist/types/src/data/useTreeData.d.ts +11 -0
- package/dist/types/src/datepicker/IncompleteDate.d.ts +11 -5
- package/dist/types/src/datepicker/types.d.ts +37 -11
- package/dist/types/src/datepicker/useDateFieldState.d.ts +13 -4
- package/dist/types/src/datepicker/useDatePickerState.d.ts +10 -4
- package/dist/types/src/datepicker/useDateRangePickerState.d.ts +12 -3
- package/dist/types/src/dnd/useDraggableCollectionState.d.ts +4 -1
- package/dist/types/src/form/useFormValidationState.d.ts +4 -1
- package/dist/types/src/grid/GridCollection.d.ts +2 -1
- package/dist/types/src/grid/useGridState.d.ts +7 -3
- package/dist/types/src/layout/GridLayout.d.ts +18 -2
- package/dist/types/src/layout/ListLayout.d.ts +34 -12
- package/dist/types/src/layout/TableLayout.d.ts +11 -4
- package/dist/types/src/layout/WaterfallLayout.d.ts +9 -2
- package/dist/types/src/list/useListState.d.ts +2 -2
- package/dist/types/src/menu/useMenuTriggerState.d.ts +3 -1
- package/dist/types/src/menu/useSubmenuTriggerState.d.ts +2 -2
- package/dist/types/src/numberfield/useNumberFieldState.d.ts +15 -11
- package/dist/types/src/radio/useRadioGroupState.d.ts +4 -1
- package/dist/types/src/select/useSelectState.d.ts +13 -2
- package/dist/types/src/selection/types.d.ts +4 -1
- package/dist/types/src/selection/useMultipleSelectionState.d.ts +2 -0
- package/dist/types/src/slider/useSliderState.d.ts +22 -2
- package/dist/types/src/table/Column.d.ts +4 -1
- package/dist/types/src/table/Row.d.ts +5 -3
- package/dist/types/src/table/TableBody.d.ts +3 -2
- package/dist/types/src/table/TableCollection.d.ts +4 -1
- package/dist/types/src/table/TableColumnLayout.d.ts +4 -1
- package/dist/types/src/table/TableHeader.d.ts +7 -3
- package/dist/types/src/table/TableUtils.d.ts +19 -16
- package/dist/types/src/table/useTableColumnResizeState.d.ts +5 -3
- package/dist/types/src/table/useTableState.d.ts +15 -6
- package/dist/types/src/table/useTreeGridState.d.ts +3 -2
- package/dist/types/src/toggle/useToggleGroupState.d.ts +1 -0
- package/dist/types/src/toggle/useToggleState.d.ts +2 -1
- package/dist/types/src/tooltip/useTooltipTriggerState.d.ts +8 -2
- package/dist/types/src/tree/useTreeState.d.ts +1 -1
- package/dist/types/src/utils/number.d.ts +2 -1
- package/dist/types/src/virtualizer/Layout.d.ts +5 -2
- package/dist/types/src/virtualizer/LayoutInfo.d.ts +10 -3
- package/dist/types/src/virtualizer/Rect.d.ts +4 -0
- package/dist/types/src/virtualizer/Virtualizer.d.ts +5 -4
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAWD,MAAM,mCAAa,IAAI,CAAA,GAAA,gCAAwB,EAAE,CAAA,GAAA,8CAAW;AAE5D,SAAS;IACP,8GAA8G;IAC9G,qEAAqE;IACrE,aAAa;IACb,IAAI,SAAS,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KAAM;IAEnG,IAAI;QACF,KAAK,cAAc,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,QAAQ;QACR,aAAa;IACf,IAAI;IAEJ,IAAI,gBAAgB,UAAU,gBAAgB,WAAW,gBAAgB,OACvE,OAAO,CAAA,GAAA,qBAAa,EAAE;IAGxB,IAAI,CAAC,UACH,OAAO,CAAA,GAAA,yBAAiB,EAAE;IAG5B,OAAO;AACT;AAEO,SAAS,0CAAgB,CAAmB,EAAE,WAAoC;IACvF,6GAA6G;IAC7G,IAAI,kBAAmB,KAAK,cAAc,IAAI,EAAE,QAAQ,GAAG;IAC3D,IAAI,qBAAmC,KAAK,YAAY,IAAI,WAAW;IAEvE,yEAAyE;IACzE,IAAI,KAAK,eAAe,CAAE,CAAA,eAAe,CAAA,GACvC,MAAM,IAAI,MAAM,yBAAyB,cAAc,gBAAgB,EAAE,QAAQ;IAGnF,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAqC;QAAC;QAAoB;KAAgB;IAEjH,kEAAkE;IAClE,IAAI,KAAM,CAAA,SAAS,CAAC,EAAE,KAAK,sBAAsB,SAAS,CAAC,EAAE,KAAK,eAAc,GAC9E,aAAa;QAAC;QAAoB;KAAgB;IAGpD,IAAI,CAAC,aACH,cAAc,IAAI,qBAAqB,SAAS,CAAC,EAAE;IAGrD,IAAI,WAAW,IAAI,kBAAkB,SAAS,CAAC,EAAE;IACjD,OAAO;QAAC;QAAa;KAAS;AAChC","sources":["packages/react-stately/src/datepicker/utils.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 {Calendar, DateFormatter, getLocalTimeZone, now, Time, toCalendar, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DatePickerProps, DateValue, Granularity, TimeValue} from './types';\n// @ts-ignore\nimport i18nMessages from '../../intl/datepicker/*.json';\nimport {LocalizedStringDictionary, LocalizedStringFormatter} from '@internationalized/string';\nimport {mergeValidation, VALID_VALIDITY_STATE} from '../form/useFormValidationState';\nimport {RangeValue, ValidationResult} from '@react-types/shared';\nimport {useState} from 'react';\n\nconst dictionary = new LocalizedStringDictionary(i18nMessages);\n\nfunction getLocale() {\n // Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided\n // validation messages, which to not respect our provider's language.\n // @ts-ignore\n let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return locale;\n}\n\nexport function getValidationResult(\n value: DateValue | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;\n let rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;\n let isUnavailable = (value != null && isDateUnavailable?.(value)) || false;\n let isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;\n let errors: string[] = [];\n\n if (isInvalid) {\n let locale = getLocale();\n let strings = LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') || dictionary;\n let formatter = new LocalizedStringFormatter(locale, strings);\n let dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));\n let timeZone = dateFormatter.resolvedOptions().timeZone;\n\n if (rangeUnderflow && minValue != null) {\n errors.push(formatter.format('rangeUnderflow', {minValue: dateFormatter.format(minValue.toDate(timeZone))}));\n }\n\n if (rangeOverflow && maxValue != null) {\n errors.push(formatter.format('rangeOverflow', {maxValue: dateFormatter.format(maxValue.toDate(timeZone))}));\n }\n\n if (isUnavailable) {\n errors.push(formatter.format('unavailableDate'));\n }\n }\n\n return {\n isInvalid,\n validationErrors: errors,\n validationDetails: {\n badInput: isUnavailable,\n customError: false,\n patternMismatch: false,\n rangeOverflow,\n rangeUnderflow,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: !isInvalid\n }\n };\n}\n\nexport function getRangeValidationResult(\n value: RangeValue<DateValue | null> | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let startValidation = getValidationResult(\n value?.start ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let endValidation = getValidationResult(\n value?.end ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let result = mergeValidation(startValidation, endValidation);\n if (value?.end != null && value.start != null && value.end.compare(value.start) < 0) {\n let strings = LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') || dictionary;\n result = mergeValidation(result, {\n isInvalid: true,\n validationErrors: [strings.getStringForLocale('rangeReversed', getLocale())],\n validationDetails: {\n ...VALID_VALIDITY_STATE,\n rangeUnderflow: true,\n rangeOverflow: true,\n valid: false\n }\n });\n }\n\n return result;\n}\n\nexport type FieldOptions = Pick<Intl.DateTimeFormatOptions, 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'>;\nexport interface FormatterOptions {\n timeZone?: string,\n hideTimeZone?: boolean,\n granularity?: DatePickerProps<any>['granularity'],\n maxGranularity?: 'year' | 'month' | DatePickerProps<any>['granularity'],\n hourCycle?: 12 | 24,\n showEra?: boolean,\n shouldForceLeadingZeros?: boolean\n}\n\nconst DEFAULT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n second: '2-digit'\n};\n\nconst TWO_DIGIT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit'\n};\n\nexport function getFormatOptions(\n fieldOptions: FieldOptions,\n options: FormatterOptions\n): Intl.DateTimeFormatOptions {\n let defaultFieldOptions = options.shouldForceLeadingZeros ? TWO_DIGIT_FIELD_OPTIONS : DEFAULT_FIELD_OPTIONS;\n fieldOptions = {...defaultFieldOptions, ...fieldOptions};\n let granularity = options.granularity || 'minute';\n let keys = Object.keys(fieldOptions);\n let startIdx = keys.indexOf(options.maxGranularity ?? 'year');\n if (startIdx < 0) {\n startIdx = 0;\n }\n\n let endIdx = keys.indexOf(granularity);\n if (endIdx < 0) {\n endIdx = 2;\n }\n\n if (startIdx > endIdx) {\n throw new Error('maxGranularity must be greater than granularity');\n }\n\n let opts: Intl.DateTimeFormatOptions = keys.slice(startIdx, endIdx + 1).reduce((opts, key) => {\n opts[key] = fieldOptions[key];\n return opts;\n }, {});\n\n if (options.hourCycle != null) {\n opts.hour12 = options.hourCycle === 12;\n }\n\n opts.timeZone = options.timeZone || 'UTC';\n\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n if (hasTime && options.timeZone && !options.hideTimeZone) {\n opts.timeZoneName = 'short';\n }\n\n if (options.showEra && startIdx === 0) {\n opts.era = 'short';\n }\n\n return opts;\n}\n\nexport function getPlaceholderTime(placeholderValue: DateValue | null | undefined): TimeValue {\n if (placeholderValue && 'hour' in placeholderValue) {\n return placeholderValue;\n }\n\n return new Time();\n}\n\nexport function convertValue(value: DateValue | null | undefined, calendar: Calendar): DateValue | null | undefined {\n if (value === null) {\n return null;\n }\n\n if (!value) {\n return undefined;\n }\n\n return toCalendar(value, calendar);\n}\n\n\nexport function createPlaceholderDate(placeholderValue: DateValue | null | undefined, granularity: string, calendar: Calendar, timeZone: string | undefined): DateValue {\n if (placeholderValue) {\n return convertValue(placeholderValue, calendar)!;\n }\n\n let date = toCalendar(now(timeZone ?? getLocalTimeZone()).set({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0\n }), calendar);\n\n if (granularity === 'year' || granularity === 'month' || granularity === 'day') {\n return toCalendarDate(date);\n }\n\n if (!timeZone) {\n return toCalendarDateTime(date);\n }\n\n return date;\n}\n\nexport function useDefaultProps(v: DateValue | null, granularity: Granularity | undefined): [Granularity, string | undefined] {\n // Compute default granularity and time zone from the value. If the value becomes null, keep the last values.\n let defaultTimeZone = (v && 'timeZone' in v ? v.timeZone : undefined);\n let defaultGranularity: Granularity = (v && 'minute' in v ? 'minute' : 'day');\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && granularity && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let [lastValue, setLastValue] = useState<[Granularity, string | undefined]>([defaultGranularity, defaultTimeZone]);\n\n // If the granularity or time zone changed, update the last value.\n if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone)) {\n setLastValue([defaultGranularity, defaultTimeZone]);\n }\n\n if (!granularity) {\n granularity = v ? defaultGranularity : lastValue[0];\n }\n\n let timeZone = v ? defaultTimeZone : lastValue[1];\n return [granularity, timeZone];\n}\n"],"names":[],"version":3,"file":"utils.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAoBD,MAAM,mCAAa,IAAI,CAAA,GAAA,gCAAwB,EAAE,CAAA,GAAA,8CAAW;AAE5D,SAAS;IACP,8GAA8G;IAC9G,qEAAqE;IACrE,IAAI,SAEF,AADA,aAAa;IACZ,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KAAO;IAE1F,IAAI;QACF,KAAK,cAAc,CAAC,kBAAkB,CAAC;YAAC;SAAO;IACjD,EAAE,OAAM;QACN,SAAS;IACX;IACA,OAAO;AACT;AAEO,SAAS,0CACd,KAAuB,EACvB,QAAsC,EACtC,QAAsC,EACtC,iBAA0D,EAC1D,OAAyB;IAEzB,IAAI,gBAAgB,SAAS,QAAQ,YAAY,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nB,WAAoC;IAEpC,6GAA6G;IAC7G,IAAI,kBAAkB,KAAK,cAAc,IAAI,EAAE,QAAQ,GAAG;IAC1D,IAAI,qBAAkC,KAAK,YAAY,IAAI,WAAW;IAEtE,yEAAyE;IACzE,IAAI,KAAK,eAAe,CAAE,CAAA,eAAe,CAAA,GACvC,MAAM,IAAI,MAAM,yBAAyB,cAAc,gBAAgB,EAAE,QAAQ;IAGnF,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAqC;QAC1E;QACA;KACD;IAED,kEAAkE;IAClE,IAAI,KAAM,CAAA,SAAS,CAAC,EAAE,KAAK,sBAAsB,SAAS,CAAC,EAAE,KAAK,eAAc,GAC9E,aAAa;QAAC;QAAoB;KAAgB;IAGpD,IAAI,CAAC,aACH,cAAc,IAAI,qBAAqB,SAAS,CAAC,EAAE;IAGrD,IAAI,WAAW,IAAI,kBAAkB,SAAS,CAAC,EAAE;IACjD,OAAO;QAAC;QAAa;KAAS;AAChC","sources":["packages/react-stately/src/datepicker/utils.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 {\n Calendar,\n DateFormatter,\n getLocalTimeZone,\n now,\n Time,\n toCalendar,\n toCalendarDate,\n toCalendarDateTime\n} from '@internationalized/date';\nimport {DatePickerProps, DateValue, Granularity, TimeValue} from './types';\n// @ts-ignore\nimport i18nMessages from '../../intl/datepicker/*.json';\nimport {LocalizedStringDictionary, LocalizedStringFormatter} from '@internationalized/string';\nimport {mergeValidation, VALID_VALIDITY_STATE} from '../form/useFormValidationState';\nimport {RangeValue, ValidationResult} from '@react-types/shared';\nimport {useState} from 'react';\n\nconst dictionary = new LocalizedStringDictionary(i18nMessages);\n\nfunction getLocale() {\n // Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided\n // validation messages, which to not respect our provider's language.\n let locale =\n // @ts-ignore\n (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return locale;\n}\n\nexport function getValidationResult(\n value: DateValue | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;\n let rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;\n let isUnavailable = (value != null && isDateUnavailable?.(value)) || false;\n let isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;\n let errors: string[] = [];\n\n if (isInvalid) {\n let locale = getLocale();\n let strings =\n LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') ||\n dictionary;\n let formatter = new LocalizedStringFormatter(locale, strings);\n let dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));\n let timeZone = dateFormatter.resolvedOptions().timeZone;\n\n if (rangeUnderflow && minValue != null) {\n errors.push(\n formatter.format('rangeUnderflow', {\n minValue: dateFormatter.format(minValue.toDate(timeZone))\n })\n );\n }\n\n if (rangeOverflow && maxValue != null) {\n errors.push(\n formatter.format('rangeOverflow', {\n maxValue: dateFormatter.format(maxValue.toDate(timeZone))\n })\n );\n }\n\n if (isUnavailable) {\n errors.push(formatter.format('unavailableDate'));\n }\n }\n\n return {\n isInvalid,\n validationErrors: errors,\n validationDetails: {\n badInput: isUnavailable,\n customError: false,\n patternMismatch: false,\n rangeOverflow,\n rangeUnderflow,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: !isInvalid\n }\n };\n}\n\nexport function getRangeValidationResult(\n value: RangeValue<DateValue | null> | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let startValidation = getValidationResult(\n value?.start ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let endValidation = getValidationResult(\n value?.end ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let result = mergeValidation(startValidation, endValidation);\n if (value?.end != null && value.start != null && value.end.compare(value.start) < 0) {\n let strings =\n LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') ||\n dictionary;\n result = mergeValidation(result, {\n isInvalid: true,\n validationErrors: [strings.getStringForLocale('rangeReversed', getLocale())],\n validationDetails: {\n ...VALID_VALIDITY_STATE,\n rangeUnderflow: true,\n rangeOverflow: true,\n valid: false\n }\n });\n }\n\n return result;\n}\n\nexport type FieldOptions = Pick<\n Intl.DateTimeFormatOptions,\n 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'\n>;\nexport interface FormatterOptions {\n timeZone?: string;\n hideTimeZone?: boolean;\n granularity?: DatePickerProps<any>['granularity'];\n maxGranularity?: 'year' | 'month' | DatePickerProps<any>['granularity'];\n hourCycle?: 12 | 24;\n showEra?: boolean;\n shouldForceLeadingZeros?: boolean;\n}\n\nconst DEFAULT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n second: '2-digit'\n};\n\nconst TWO_DIGIT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit'\n};\n\nexport function getFormatOptions(\n fieldOptions: FieldOptions,\n options: FormatterOptions\n): Intl.DateTimeFormatOptions {\n let defaultFieldOptions = options.shouldForceLeadingZeros\n ? TWO_DIGIT_FIELD_OPTIONS\n : DEFAULT_FIELD_OPTIONS;\n fieldOptions = {...defaultFieldOptions, ...fieldOptions};\n let granularity = options.granularity || 'minute';\n let keys = Object.keys(fieldOptions);\n let startIdx = keys.indexOf(options.maxGranularity ?? 'year');\n if (startIdx < 0) {\n startIdx = 0;\n }\n\n let endIdx = keys.indexOf(granularity);\n if (endIdx < 0) {\n endIdx = 2;\n }\n\n if (startIdx > endIdx) {\n throw new Error('maxGranularity must be greater than granularity');\n }\n\n let opts: Intl.DateTimeFormatOptions = keys.slice(startIdx, endIdx + 1).reduce((opts, key) => {\n opts[key] = fieldOptions[key];\n return opts;\n }, {});\n\n if (options.hourCycle != null) {\n opts.hour12 = options.hourCycle === 12;\n }\n\n opts.timeZone = options.timeZone || 'UTC';\n\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n if (hasTime && options.timeZone && !options.hideTimeZone) {\n opts.timeZoneName = 'short';\n }\n\n if (options.showEra && startIdx === 0) {\n opts.era = 'short';\n }\n\n return opts;\n}\n\nexport function getPlaceholderTime(placeholderValue: DateValue | null | undefined): TimeValue {\n if (placeholderValue && 'hour' in placeholderValue) {\n return placeholderValue;\n }\n\n return new Time();\n}\n\nexport function convertValue(\n value: DateValue | null | undefined,\n calendar: Calendar\n): DateValue | null | undefined {\n if (value === null) {\n return null;\n }\n\n if (!value) {\n return undefined;\n }\n\n return toCalendar(value, calendar);\n}\n\nexport function createPlaceholderDate(\n placeholderValue: DateValue | null | undefined,\n granularity: string,\n calendar: Calendar,\n timeZone: string | undefined\n): DateValue {\n if (placeholderValue) {\n return convertValue(placeholderValue, calendar)!;\n }\n\n let date = toCalendar(\n now(timeZone ?? getLocalTimeZone()).set({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0\n }),\n calendar\n );\n\n if (granularity === 'year' || granularity === 'month' || granularity === 'day') {\n return toCalendarDate(date);\n }\n\n if (!timeZone) {\n return toCalendarDateTime(date);\n }\n\n return date;\n}\n\nexport function useDefaultProps(\n v: DateValue | null,\n granularity: Granularity | undefined\n): [Granularity, string | undefined] {\n // Compute default granularity and time zone from the value. If the value becomes null, keep the last values.\n let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;\n let defaultGranularity: Granularity = v && 'minute' in v ? 'minute' : 'day';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && granularity && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let [lastValue, setLastValue] = useState<[Granularity, string | undefined]>([\n defaultGranularity,\n defaultTimeZone\n ]);\n\n // If the granularity or time zone changed, update the last value.\n if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone)) {\n setLastValue([defaultGranularity, defaultTimeZone]);\n }\n\n if (!granularity) {\n granularity = v ? defaultGranularity : lastValue[0];\n }\n\n let timeZone = v ? defaultTimeZone : lastValue[1];\n return [granularity, timeZone];\n}\n"],"names":[],"version":3,"file":"utils.js.map"}
|
|
@@ -27,8 +27,8 @@ const $8b141f2f71e88f85$var$dictionary = new (0, $7hc54$LocalizedStringDictionar
|
|
|
27
27
|
function $8b141f2f71e88f85$var$getLocale() {
|
|
28
28
|
// Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
|
|
29
29
|
// validation messages, which to not respect our provider's language.
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
|
|
30
|
+
let locale = // @ts-ignore
|
|
31
|
+
typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
32
32
|
try {
|
|
33
33
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
34
34
|
locale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAWD,MAAM,mCAAa,IAAI,CAAA,GAAA,gCAAwB,EAAE,CAAA,GAAA,+CAAW;AAE5D,SAAS;IACP,8GAA8G;IAC9G,qEAAqE;IACrE,aAAa;IACb,IAAI,SAAS,OAAO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AA,qBAAa,EAAE;IAGxB,IAAI,CAAC,UACH,OAAO,CAAA,GAAA,yBAAiB,EAAE;IAG5B,OAAO;AACT;AAEO,SAAS,0CAAgB,CAAmB,EAAE,WAAoC;IACvF,6GAA6G;IAC7G,IAAI,kBAAmB,KAAK,cAAc,IAAI,EAAE,QAAQ,GAAG;IAC3D,IAAI,qBAAmC,KAAK,YAAY,IAAI,WAAW;IAEvE,yEAAyE;IACzE,IAAI,KAAK,eAAe,CAAE,CAAA,eAAe,CAAA,GACvC,MAAM,IAAI,MAAM,yBAAyB,cAAc,gBAAgB,EAAE,QAAQ;IAGnF,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAqC;QAAC;QAAoB;KAAgB;IAEjH,kEAAkE;IAClE,IAAI,KAAM,CAAA,SAAS,CAAC,EAAE,KAAK,sBAAsB,SAAS,CAAC,EAAE,KAAK,eAAc,GAC9E,aAAa;QAAC;QAAoB;KAAgB;IAGpD,IAAI,CAAC,aACH,cAAc,IAAI,qBAAqB,SAAS,CAAC,EAAE;IAGrD,IAAI,WAAW,IAAI,kBAAkB,SAAS,CAAC,EAAE;IACjD,OAAO;QAAC;QAAa;KAAS;AAChC","sources":["packages/react-stately/src/datepicker/utils.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 {Calendar, DateFormatter, getLocalTimeZone, now, Time, toCalendar, toCalendarDate, toCalendarDateTime} from '@internationalized/date';\nimport {DatePickerProps, DateValue, Granularity, TimeValue} from './types';\n// @ts-ignore\nimport i18nMessages from '../../intl/datepicker/*.json';\nimport {LocalizedStringDictionary, LocalizedStringFormatter} from '@internationalized/string';\nimport {mergeValidation, VALID_VALIDITY_STATE} from '../form/useFormValidationState';\nimport {RangeValue, ValidationResult} from '@react-types/shared';\nimport {useState} from 'react';\n\nconst dictionary = new LocalizedStringDictionary(i18nMessages);\n\nfunction getLocale() {\n // Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided\n // validation messages, which to not respect our provider's language.\n // @ts-ignore\n let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return locale;\n}\n\nexport function getValidationResult(\n value: DateValue | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;\n let rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;\n let isUnavailable = (value != null && isDateUnavailable?.(value)) || false;\n let isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;\n let errors: string[] = [];\n\n if (isInvalid) {\n let locale = getLocale();\n let strings = LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') || dictionary;\n let formatter = new LocalizedStringFormatter(locale, strings);\n let dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));\n let timeZone = dateFormatter.resolvedOptions().timeZone;\n\n if (rangeUnderflow && minValue != null) {\n errors.push(formatter.format('rangeUnderflow', {minValue: dateFormatter.format(minValue.toDate(timeZone))}));\n }\n\n if (rangeOverflow && maxValue != null) {\n errors.push(formatter.format('rangeOverflow', {maxValue: dateFormatter.format(maxValue.toDate(timeZone))}));\n }\n\n if (isUnavailable) {\n errors.push(formatter.format('unavailableDate'));\n }\n }\n\n return {\n isInvalid,\n validationErrors: errors,\n validationDetails: {\n badInput: isUnavailable,\n customError: false,\n patternMismatch: false,\n rangeOverflow,\n rangeUnderflow,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: !isInvalid\n }\n };\n}\n\nexport function getRangeValidationResult(\n value: RangeValue<DateValue | null> | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let startValidation = getValidationResult(\n value?.start ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let endValidation = getValidationResult(\n value?.end ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let result = mergeValidation(startValidation, endValidation);\n if (value?.end != null && value.start != null && value.end.compare(value.start) < 0) {\n let strings = LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') || dictionary;\n result = mergeValidation(result, {\n isInvalid: true,\n validationErrors: [strings.getStringForLocale('rangeReversed', getLocale())],\n validationDetails: {\n ...VALID_VALIDITY_STATE,\n rangeUnderflow: true,\n rangeOverflow: true,\n valid: false\n }\n });\n }\n\n return result;\n}\n\nexport type FieldOptions = Pick<Intl.DateTimeFormatOptions, 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'>;\nexport interface FormatterOptions {\n timeZone?: string,\n hideTimeZone?: boolean,\n granularity?: DatePickerProps<any>['granularity'],\n maxGranularity?: 'year' | 'month' | DatePickerProps<any>['granularity'],\n hourCycle?: 12 | 24,\n showEra?: boolean,\n shouldForceLeadingZeros?: boolean\n}\n\nconst DEFAULT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n second: '2-digit'\n};\n\nconst TWO_DIGIT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit'\n};\n\nexport function getFormatOptions(\n fieldOptions: FieldOptions,\n options: FormatterOptions\n): Intl.DateTimeFormatOptions {\n let defaultFieldOptions = options.shouldForceLeadingZeros ? TWO_DIGIT_FIELD_OPTIONS : DEFAULT_FIELD_OPTIONS;\n fieldOptions = {...defaultFieldOptions, ...fieldOptions};\n let granularity = options.granularity || 'minute';\n let keys = Object.keys(fieldOptions);\n let startIdx = keys.indexOf(options.maxGranularity ?? 'year');\n if (startIdx < 0) {\n startIdx = 0;\n }\n\n let endIdx = keys.indexOf(granularity);\n if (endIdx < 0) {\n endIdx = 2;\n }\n\n if (startIdx > endIdx) {\n throw new Error('maxGranularity must be greater than granularity');\n }\n\n let opts: Intl.DateTimeFormatOptions = keys.slice(startIdx, endIdx + 1).reduce((opts, key) => {\n opts[key] = fieldOptions[key];\n return opts;\n }, {});\n\n if (options.hourCycle != null) {\n opts.hour12 = options.hourCycle === 12;\n }\n\n opts.timeZone = options.timeZone || 'UTC';\n\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n if (hasTime && options.timeZone && !options.hideTimeZone) {\n opts.timeZoneName = 'short';\n }\n\n if (options.showEra && startIdx === 0) {\n opts.era = 'short';\n }\n\n return opts;\n}\n\nexport function getPlaceholderTime(placeholderValue: DateValue | null | undefined): TimeValue {\n if (placeholderValue && 'hour' in placeholderValue) {\n return placeholderValue;\n }\n\n return new Time();\n}\n\nexport function convertValue(value: DateValue | null | undefined, calendar: Calendar): DateValue | null | undefined {\n if (value === null) {\n return null;\n }\n\n if (!value) {\n return undefined;\n }\n\n return toCalendar(value, calendar);\n}\n\n\nexport function createPlaceholderDate(placeholderValue: DateValue | null | undefined, granularity: string, calendar: Calendar, timeZone: string | undefined): DateValue {\n if (placeholderValue) {\n return convertValue(placeholderValue, calendar)!;\n }\n\n let date = toCalendar(now(timeZone ?? getLocalTimeZone()).set({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0\n }), calendar);\n\n if (granularity === 'year' || granularity === 'month' || granularity === 'day') {\n return toCalendarDate(date);\n }\n\n if (!timeZone) {\n return toCalendarDateTime(date);\n }\n\n return date;\n}\n\nexport function useDefaultProps(v: DateValue | null, granularity: Granularity | undefined): [Granularity, string | undefined] {\n // Compute default granularity and time zone from the value. If the value becomes null, keep the last values.\n let defaultTimeZone = (v && 'timeZone' in v ? v.timeZone : undefined);\n let defaultGranularity: Granularity = (v && 'minute' in v ? 'minute' : 'day');\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && granularity && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let [lastValue, setLastValue] = useState<[Granularity, string | undefined]>([defaultGranularity, defaultTimeZone]);\n\n // If the granularity or time zone changed, update the last value.\n if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone)) {\n setLastValue([defaultGranularity, defaultTimeZone]);\n }\n\n if (!granularity) {\n granularity = v ? defaultGranularity : lastValue[0];\n }\n\n let timeZone = v ? defaultTimeZone : lastValue[1];\n return [granularity, timeZone];\n}\n"],"names":[],"version":3,"file":"utils.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAoBD,MAAM,mCAAa,IAAI,CAAA,GAAA,gCAAwB,EAAE,CAAA,GAAA,+CAAW;AAE5D,SAAS;IACP,8GAA8G;IAC9G,qEAAqE;IACrE,IAAI,SAEF,AADA,aAAa;IACZ,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KAAO;IAE1F,IAAI;QACF,KAAK,cAAc,CAAC,kBAAkB,CAAC;YAAC;SAAO;IACjD,EAAE,OAAM;QACN,SAAS;IACX;IACA,OAAO;AACT;AAEO,SAAS,0CACd,KAAuB,EACvB,QAAsC,EACtC,QAAsC,EACtC,iBAA0D,EAC1D,OAAyB;IAEzB,IAAI,gBAAgB,SAAS,QAAQ,YAAY,QAAQ,MAAM,OAAO,CAAC,YAAY;IACnF,IAAI,iBAAiB,SAAS,QAAQ,YAAY,QAAQ,MAAM,OAAO,CAAC,YA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AAA,GAAA,eAAO,EAAqC;QAC1E;QACA;KACD;IAED,kEAAkE;IAClE,IAAI,KAAM,CAAA,SAAS,CAAC,EAAE,KAAK,sBAAsB,SAAS,CAAC,EAAE,KAAK,eAAc,GAC9E,aAAa;QAAC;QAAoB;KAAgB;IAGpD,IAAI,CAAC,aACH,cAAc,IAAI,qBAAqB,SAAS,CAAC,EAAE;IAGrD,IAAI,WAAW,IAAI,kBAAkB,SAAS,CAAC,EAAE;IACjD,OAAO;QAAC;QAAa;KAAS;AAChC","sources":["packages/react-stately/src/datepicker/utils.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 {\n Calendar,\n DateFormatter,\n getLocalTimeZone,\n now,\n Time,\n toCalendar,\n toCalendarDate,\n toCalendarDateTime\n} from '@internationalized/date';\nimport {DatePickerProps, DateValue, Granularity, TimeValue} from './types';\n// @ts-ignore\nimport i18nMessages from '../../intl/datepicker/*.json';\nimport {LocalizedStringDictionary, LocalizedStringFormatter} from '@internationalized/string';\nimport {mergeValidation, VALID_VALIDITY_STATE} from '../form/useFormValidationState';\nimport {RangeValue, ValidationResult} from '@react-types/shared';\nimport {useState} from 'react';\n\nconst dictionary = new LocalizedStringDictionary(i18nMessages);\n\nfunction getLocale() {\n // Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided\n // validation messages, which to not respect our provider's language.\n let locale =\n // @ts-ignore\n (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return locale;\n}\n\nexport function getValidationResult(\n value: DateValue | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;\n let rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;\n let isUnavailable = (value != null && isDateUnavailable?.(value)) || false;\n let isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;\n let errors: string[] = [];\n\n if (isInvalid) {\n let locale = getLocale();\n let strings =\n LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') ||\n dictionary;\n let formatter = new LocalizedStringFormatter(locale, strings);\n let dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));\n let timeZone = dateFormatter.resolvedOptions().timeZone;\n\n if (rangeUnderflow && minValue != null) {\n errors.push(\n formatter.format('rangeUnderflow', {\n minValue: dateFormatter.format(minValue.toDate(timeZone))\n })\n );\n }\n\n if (rangeOverflow && maxValue != null) {\n errors.push(\n formatter.format('rangeOverflow', {\n maxValue: dateFormatter.format(maxValue.toDate(timeZone))\n })\n );\n }\n\n if (isUnavailable) {\n errors.push(formatter.format('unavailableDate'));\n }\n }\n\n return {\n isInvalid,\n validationErrors: errors,\n validationDetails: {\n badInput: isUnavailable,\n customError: false,\n patternMismatch: false,\n rangeOverflow,\n rangeUnderflow,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: !isInvalid\n }\n };\n}\n\nexport function getRangeValidationResult(\n value: RangeValue<DateValue | null> | null,\n minValue: DateValue | null | undefined,\n maxValue: DateValue | null | undefined,\n isDateUnavailable: ((v: DateValue) => boolean) | undefined,\n options: FormatterOptions\n): ValidationResult {\n let startValidation = getValidationResult(\n value?.start ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let endValidation = getValidationResult(\n value?.end ?? null,\n minValue,\n maxValue,\n isDateUnavailable,\n options\n );\n\n let result = mergeValidation(startValidation, endValidation);\n if (value?.end != null && value.start != null && value.end.compare(value.start) < 0) {\n let strings =\n LocalizedStringDictionary.getGlobalDictionaryForPackage('@react-stately/datepicker') ||\n dictionary;\n result = mergeValidation(result, {\n isInvalid: true,\n validationErrors: [strings.getStringForLocale('rangeReversed', getLocale())],\n validationDetails: {\n ...VALID_VALIDITY_STATE,\n rangeUnderflow: true,\n rangeOverflow: true,\n valid: false\n }\n });\n }\n\n return result;\n}\n\nexport type FieldOptions = Pick<\n Intl.DateTimeFormatOptions,\n 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'\n>;\nexport interface FormatterOptions {\n timeZone?: string;\n hideTimeZone?: boolean;\n granularity?: DatePickerProps<any>['granularity'];\n maxGranularity?: 'year' | 'month' | DatePickerProps<any>['granularity'];\n hourCycle?: 12 | 24;\n showEra?: boolean;\n shouldForceLeadingZeros?: boolean;\n}\n\nconst DEFAULT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n second: '2-digit'\n};\n\nconst TWO_DIGIT_FIELD_OPTIONS: FieldOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit'\n};\n\nexport function getFormatOptions(\n fieldOptions: FieldOptions,\n options: FormatterOptions\n): Intl.DateTimeFormatOptions {\n let defaultFieldOptions = options.shouldForceLeadingZeros\n ? TWO_DIGIT_FIELD_OPTIONS\n : DEFAULT_FIELD_OPTIONS;\n fieldOptions = {...defaultFieldOptions, ...fieldOptions};\n let granularity = options.granularity || 'minute';\n let keys = Object.keys(fieldOptions);\n let startIdx = keys.indexOf(options.maxGranularity ?? 'year');\n if (startIdx < 0) {\n startIdx = 0;\n }\n\n let endIdx = keys.indexOf(granularity);\n if (endIdx < 0) {\n endIdx = 2;\n }\n\n if (startIdx > endIdx) {\n throw new Error('maxGranularity must be greater than granularity');\n }\n\n let opts: Intl.DateTimeFormatOptions = keys.slice(startIdx, endIdx + 1).reduce((opts, key) => {\n opts[key] = fieldOptions[key];\n return opts;\n }, {});\n\n if (options.hourCycle != null) {\n opts.hour12 = options.hourCycle === 12;\n }\n\n opts.timeZone = options.timeZone || 'UTC';\n\n let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';\n if (hasTime && options.timeZone && !options.hideTimeZone) {\n opts.timeZoneName = 'short';\n }\n\n if (options.showEra && startIdx === 0) {\n opts.era = 'short';\n }\n\n return opts;\n}\n\nexport function getPlaceholderTime(placeholderValue: DateValue | null | undefined): TimeValue {\n if (placeholderValue && 'hour' in placeholderValue) {\n return placeholderValue;\n }\n\n return new Time();\n}\n\nexport function convertValue(\n value: DateValue | null | undefined,\n calendar: Calendar\n): DateValue | null | undefined {\n if (value === null) {\n return null;\n }\n\n if (!value) {\n return undefined;\n }\n\n return toCalendar(value, calendar);\n}\n\nexport function createPlaceholderDate(\n placeholderValue: DateValue | null | undefined,\n granularity: string,\n calendar: Calendar,\n timeZone: string | undefined\n): DateValue {\n if (placeholderValue) {\n return convertValue(placeholderValue, calendar)!;\n }\n\n let date = toCalendar(\n now(timeZone ?? getLocalTimeZone()).set({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0\n }),\n calendar\n );\n\n if (granularity === 'year' || granularity === 'month' || granularity === 'day') {\n return toCalendarDate(date);\n }\n\n if (!timeZone) {\n return toCalendarDateTime(date);\n }\n\n return date;\n}\n\nexport function useDefaultProps(\n v: DateValue | null,\n granularity: Granularity | undefined\n): [Granularity, string | undefined] {\n // Compute default granularity and time zone from the value. If the value becomes null, keep the last values.\n let defaultTimeZone = v && 'timeZone' in v ? v.timeZone : undefined;\n let defaultGranularity: Granularity = v && 'minute' in v ? 'minute' : 'day';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && granularity && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let [lastValue, setLastValue] = useState<[Granularity, string | undefined]>([\n defaultGranularity,\n defaultTimeZone\n ]);\n\n // If the granularity or time zone changed, update the last value.\n if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone)) {\n setLastValue([defaultGranularity, defaultTimeZone]);\n }\n\n if (!granularity) {\n granularity = v ? defaultGranularity : lastValue[0];\n }\n\n let timeZone = v ? defaultTimeZone : lastValue[1];\n return [granularity, timeZone];\n}\n"],"names":[],"version":3,"file":"utils.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,4CAAiB,EACrD,CAAA,GAAA,oBAAM,
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,4CAAiB,EACrD,CAAA,GAAA,oBAAM,EACJ,IAAO,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,WAC1D;QAAC,MAAM,YAAY;KAAC,GAEtB,CAAA,GAAA,oBAAM,EACJ,IAAO,MAAM,mBAAmB,GAAG,IAAI,IAAI,MAAM,mBAAmB,IAAI,IAAI,OAC5E;QAAC,MAAM,mBAAmB;KAAC,GAE7B,MAAM,gBAAgB;IAGxB,CAAA,GAAA,sBAAQ,EAAE;QACR,uEAAuE;QACvE,IAAI,CAAC,0BAA0B,aAAa,IAAI,GAAG,GAAG;YACpD,IAAI,WAAW,aAAa,MAAM,GAAG,IAAI,GAAG,KAAK;YACjD,IAAI,YAAY,MACd,gBAAgB,IAAI,IAAI;gBAAC;aAAS;QAEtC;IACF;IAEA,OAAO;gCACL;oBACA;sBACA;yBACA;QACA,WAAU,GAAG;YACX,IAAI;YACJ,IAAI,wBAAwB;gBAC1B,OAAO,IAAI,IAAI;gBACf,IAAI,KAAK,GAAG,CAAC,MACX,KAAK,MAAM,CAAC;qBAEZ,KAAK,GAAG,CAAC;YAEb,OACE,OAAO,IAAI,IAAI,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG;gBAAC;aAAI;YAGnD,gBAAgB;QAClB;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureGroupState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {Key} from '@react-types/shared';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useEffect, useMemo} from 'react';\n\nexport interface DisclosureGroupProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>;\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>;\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => any;\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean;\n\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>;\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void;\n\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void;\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function useDisclosureGroupState(props: DisclosureGroupProps): DisclosureGroupState {\n let {allowsMultipleExpanded = false, isDisabled = false} = props;\n let [expandedKeys, setExpandedKeys] = useControlledState(\n useMemo(\n () => (props.expandedKeys ? new Set(props.expandedKeys) : undefined),\n [props.expandedKeys]\n ),\n useMemo(\n () => (props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set()),\n [props.defaultExpandedKeys]\n ),\n props.onExpandedChange\n );\n\n useEffect(() => {\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n if (!allowsMultipleExpanded && expandedKeys.size > 1) {\n let firstKey = expandedKeys.values().next().value;\n if (firstKey != null) {\n setExpandedKeys(new Set([firstKey]));\n }\n }\n });\n\n return {\n allowsMultipleExpanded,\n isDisabled,\n expandedKeys,\n setExpandedKeys,\n toggleKey(key) {\n let keys: Set<Key>;\n if (allowsMultipleExpanded) {\n keys = new Set(expandedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n } else {\n keys.add(key);\n }\n } else {\n keys = new Set(expandedKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(keys);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureGroupState.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,yCAAiB,EACrD,CAAA,GAAA,cAAM,
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,yCAAiB,EACrD,CAAA,GAAA,cAAM,EACJ,IAAO,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,WAC1D;QAAC,MAAM,YAAY;KAAC,GAEtB,CAAA,GAAA,cAAM,EACJ,IAAO,MAAM,mBAAmB,GAAG,IAAI,IAAI,MAAM,mBAAmB,IAAI,IAAI,OAC5E;QAAC,MAAM,mBAAmB;KAAC,GAE7B,MAAM,gBAAgB;IAGxB,CAAA,GAAA,gBAAQ,EAAE;QACR,uEAAuE;QACvE,IAAI,CAAC,0BAA0B,aAAa,IAAI,GAAG,GAAG;YACpD,IAAI,WAAW,aAAa,MAAM,GAAG,IAAI,GAAG,KAAK;YACjD,IAAI,YAAY,MACd,gBAAgB,IAAI,IAAI;gBAAC;aAAS;QAEtC;IACF;IAEA,OAAO;gCACL;oBACA;sBACA;yBACA;QACA,WAAU,GAAG;YACX,IAAI;YACJ,IAAI,wBAAwB;gBAC1B,OAAO,IAAI,IAAI;gBACf,IAAI,KAAK,GAAG,CAAC,MACX,KAAK,MAAM,CAAC;qBAEZ,KAAK,GAAG,CAAC;YAEb,OACE,OAAO,IAAI,IAAI,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG;gBAAC;aAAI;YAGnD,gBAAgB;QAClB;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureGroupState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {Key} from '@react-types/shared';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useEffect, useMemo} from 'react';\n\nexport interface DisclosureGroupProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>;\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>;\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => any;\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean;\n\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>;\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void;\n\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void;\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function useDisclosureGroupState(props: DisclosureGroupProps): DisclosureGroupState {\n let {allowsMultipleExpanded = false, isDisabled = false} = props;\n let [expandedKeys, setExpandedKeys] = useControlledState(\n useMemo(\n () => (props.expandedKeys ? new Set(props.expandedKeys) : undefined),\n [props.expandedKeys]\n ),\n useMemo(\n () => (props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set()),\n [props.defaultExpandedKeys]\n ),\n props.onExpandedChange\n );\n\n useEffect(() => {\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n if (!allowsMultipleExpanded && expandedKeys.size > 1) {\n let firstKey = expandedKeys.values().next().value;\n if (firstKey != null) {\n setExpandedKeys(new Set([firstKey]));\n }\n }\n });\n\n return {\n allowsMultipleExpanded,\n isDisabled,\n expandedKeys,\n setExpandedKeys,\n toggleKey(key) {\n let keys: Set<Key>;\n if (allowsMultipleExpanded) {\n keys = new Set(expandedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n } else {\n keys.add(key);\n }\n } else {\n keys = new Set(expandedKeys.has(key) ? [] : [key]);\n }\n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AAG;gBAAC;aAAI;YAGnD,gBAAgB;QAClB;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureGroupState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {Key} from '@react-types/shared';\nimport {useControlledState} from '../utils/useControlledState';\nimport {useEffect, useMemo} from 'react';\n\nexport interface DisclosureGroupProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>;\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>;\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => any;\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean;\n\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>;\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void;\n\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void;\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function useDisclosureGroupState(props: DisclosureGroupProps): DisclosureGroupState {\n let {allowsMultipleExpanded = false, isDisabled = false} = props;\n let [expandedKeys, setExpandedKeys] = useControlledState(\n useMemo(\n () => (props.expandedKeys ? new Set(props.expandedKeys) : undefined),\n [props.expandedKeys]\n ),\n useMemo(\n () => (props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set()),\n [props.defaultExpandedKeys]\n ),\n props.onExpandedChange\n );\n\n useEffect(() => {\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n if (!allowsMultipleExpanded && expandedKeys.size > 1) {\n let firstKey = expandedKeys.values().next().value;\n if (firstKey != null) {\n setExpandedKeys(new Set([firstKey]));\n }\n }\n });\n\n return {\n allowsMultipleExpanded,\n isDisabled,\n expandedKeys,\n setExpandedKeys,\n toggleKey(key) {\n let keys: Set<Key>;\n if (allowsMultipleExpanded) {\n keys = new Set(expandedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n } else {\n keys.add(key);\n }\n } else {\n keys = new Set(expandedKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(keys);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureGroupState.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA+BM,SAAS,0CAAmB,KAAsB;IACvD,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,4CAAiB,EAC/C,MAAM,UAAU,EAChB,MAAM,eAAe,IAAI,OACzB,MAAM,gBAAgB;IAGxB,MAAM,SAAS,CAAA,GAAA,wBAAU,EAAE;QACzB,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,WAAW,CAAA,GAAA,wBAAU,EAAE;QAC3B,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,SAAS,CAAA,GAAA,wBAAU,EAAE;QACzB,YAAY,CAAC;IACf,GAAG;QAAC;QAAa;KAAW;IAE5B,OAAO;oBACL;qBACA;gBACA;kBACA;gBACA;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {useCallback} from 'react';\nimport {useControlledState} from '../utils/useControlledState';\n\nexport interface DisclosureProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: boolean;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides\n * methods to toggle this state.\n */\nexport function useDisclosureState(props: DisclosureProps): DisclosureState {\n let [isExpanded, setExpanded] = useControlledState(\n props.isExpanded,\n props.defaultExpanded || false,\n props.onExpandedChange\n );\n\n const expand = useCallback(() => {\n setExpanded(true);\n }, [setExpanded]);\n\n const collapse = useCallback(() => {\n setExpanded(false);\n }, [setExpanded]);\n\n const toggle = useCallback(() => {\n setExpanded(!isExpanded);\n }, [setExpanded, isExpanded]);\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureState.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA+BM,SAAS,0CAAmB,KAAsB;IACvD,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,yCAAiB,EAC/C,MAAM,UAAU,EAChB,MAAM,eAAe,IAAI,OACzB,MAAM,gBAAgB;IAGxB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,WAAW,CAAA,GAAA,kBAAU,EAAE;QAC3B,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY,CAAC;IACf,GAAG;QAAC;QAAa;KAAW;IAE5B,OAAO;oBACL;qBACA;gBACA;kBACA;gBACA;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {useCallback} from 'react';\nimport {useControlledState} from '../utils/useControlledState';\n\nexport interface DisclosureProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: boolean;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides\n * methods to toggle this state.\n */\nexport function useDisclosureState(props: DisclosureProps): DisclosureState {\n let [isExpanded, setExpanded] = useControlledState(\n props.isExpanded,\n props.defaultExpanded || false,\n props.onExpandedChange\n );\n\n const expand = useCallback(() => {\n setExpanded(true);\n }, [setExpanded]);\n\n const collapse = useCallback(() => {\n setExpanded(false);\n }, [setExpanded]);\n\n const toggle = useCallback(() => {\n setExpanded(!isExpanded);\n }, [setExpanded, isExpanded]);\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureState.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA+BM,SAAS,0CAAmB,KAAsB;IACvD,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,yCAAiB,EAC/C,MAAM,UAAU,EAChB,MAAM,eAAe,IAAI,OACzB,MAAM,gBAAgB;IAGxB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,WAAW,CAAA,GAAA,kBAAU,EAAE;QAC3B,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY,CAAC;IACf,GAAG;QAAC;QAAa;KAAW;IAE5B,OAAO;oBACL;qBACA;gBACA;kBACA;gBACA;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {useCallback} from 'react';\nimport {useControlledState} from '../utils/useControlledState';\n\nexport interface DisclosureProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: boolean;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides\n * methods to toggle this state.\n */\nexport function useDisclosureState(props: DisclosureProps): DisclosureState {\n let [isExpanded, setExpanded] = useControlledState(\n props.isExpanded,\n props.defaultExpanded || false,\n props.onExpandedChange\n );\n\n const expand = useCallback(() => {\n setExpanded(true);\n }, [setExpanded]);\n\n const collapse = useCallback(() => {\n setExpanded(false);\n }, [setExpanded]);\n\n const toggle = useCallback(() => {\n setExpanded(!isExpanded);\n }, [setExpanded, isExpanded]);\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureState.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA8DM,SAAS,0CACd,KAAyC;IAEzC,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/B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U,CAAC;YAC5B,YAAY;YACZ,IAAI,OAAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cAAC,UAAU,EAAC,GAAG;YAEnB,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/react-stately/src/dnd/useDraggableCollectionState.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 {\n Collection,\n DraggableCollectionEndEvent,\n DraggableCollectionProps,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n Key,\n Node,\n RefObject\n} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null;\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>;\n /** Whether drag events are disabled. */\n isDisabled?: boolean;\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean;\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>;\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[];\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>;\n /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void;\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void;\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void;\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState<T = object>(\n props: DraggableCollectionStateOptions<T>\n): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef<Key | null>(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, then only the clicked\n // item is dragged. This matches native macOS behavior.\n // Additionally, we filter out any keys that are children of any of the other selected keys\n let keys = new Set<Key>();\n if (selectionManager.isSelected(key)) {\n for (let currentKey of selectionManager.selectedKeys) {\n let node = collection.getItem(currentKey);\n if (node) {\n let isChild = false;\n let parentKey = node.parentKey;\n while (parentKey != null) {\n // eslint-disable-next-line max-depth\n if (selectionManager.selectedKeys.has(parentKey)) {\n isChild = true;\n break;\n }\n let parentNode = collection.getItem(parentKey);\n parentKey = parentNode ? parentNode.parentKey : null;\n }\n\n if (!isChild) {\n keys.add(currentKey);\n }\n }\n }\n } else {\n keys.add(key);\n }\n\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n let keys = getKeys(key);\n let items: any[] = [];\n for (let key of keys) {\n let value = collection.getItem(key)?.value;\n if (value != null) {\n items.push(value);\n }\n }\n\n return getItems(getKeys(key), items);\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {isInternal} = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AA8DM,SAAS,0CACd,KAAyC;IAEzC,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAA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AAO,gBAAgB,YACzB,YAAY;gBACV,GAAG,KAAK;sBACR;YACF;QAEJ;QACA,UAAS,KAAK;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cAAC,UAAU,EAAC,GAAG;YAEnB,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/react-stately/src/dnd/useDraggableCollectionState.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 {\n Collection,\n DraggableCollectionEndEvent,\n DraggableCollectionProps,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n Key,\n Node,\n RefObject\n} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null;\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>;\n /** Whether drag events are disabled. */\n isDisabled?: boolean;\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean;\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>;\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[];\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>;\n /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void;\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void;\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void;\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState<T = object>(\n props: DraggableCollectionStateOptions<T>\n): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef<Key | null>(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, then only the clicked\n // item is dragged. This matches native macOS behavior.\n // Additionally, we filter out any keys that are children of any of the other selected keys\n let keys = new Set<Key>();\n if (selectionManager.isSelected(key)) {\n for (let currentKey of selectionManager.selectedKeys) {\n let node = collection.getItem(currentKey);\n if (node) {\n let isChild = false;\n let parentKey = node.parentKey;\n while (parentKey != null) {\n // eslint-disable-next-line max-depth\n if (selectionManager.selectedKeys.has(parentKey)) {\n isChild = true;\n break;\n }\n let parentNode = collection.getItem(parentKey);\n parentKey = parentNode ? parentNode.parentKey : null;\n }\n\n if (!isChild) {\n keys.add(currentKey);\n }\n }\n }\n } else {\n keys.add(key);\n }\n\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n let keys = getKeys(key);\n let items: any[] = [];\n for (let key of keys) {\n let value = collection.getItem(key)?.value;\n if (value != null) {\n items.push(value);\n }\n }\n\n return getItems(getKeys(key), items);\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {isInternal} = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AA8DM,SAAS,0CACd,KAAyC;IAEzC,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,oBACV,gBAAgB,eAChB,WAAW,cACX,UAAU,aACV,SAAS,WACT,OAAO,4BACP,wBAAwB,EACzB,GAAG;IACJ,IAAI,GAAG,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/B,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE,IAAI;IAC9B,IAAI,aAAa,CAAA,GAAA,aAAK,EAAc;IACpC,IAAI,UAAU,CAAC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;YACZ,IAAI,OAAO,eAAe,YACxB,WAAW;gBACT,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;YAC5B;QAEJ;QACA,SAAQ,KAAK;YACX,IAAI,cAAC,UAAU,EAAC,GAAG;YAEnB,IAAI,OAAO,cAAc,YACvB,UAAU;gBACR,GAAG,KAAK;gBACR,MAAM,aAAa,OAAO;4BAC1B;YACF;YAGF,aAAa,OAAO,GAAG,IAAI;YAC3B,WAAW,OAAO,GAAG;YACrB,YAAY;QACd;IACF;AACF","sources":["packages/react-stately/src/dnd/useDraggableCollectionState.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 {\n Collection,\n DraggableCollectionEndEvent,\n DraggableCollectionProps,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n Key,\n Node,\n RefObject\n} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useRef, useState} from 'react';\n\nexport interface DraggableCollectionStateOptions<T = object> extends DraggableCollectionProps<T> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** Whether the drag events should be disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DraggableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** The key of the item that initiated a drag. */\n draggedKey: Key | null;\n /** The keys of the items that are currently being dragged. */\n draggingKeys: Set<Key>;\n /** Whether drag events are disabled. */\n isDisabled?: boolean;\n /** Returns whether the given key is currently being dragged. */\n isDragging(key: Key): boolean;\n /** Returns the keys of the items that will be dragged with the given key (e.g. selected items). */\n getKeysForDrag(key: Key): Set<Key>;\n /** Returns the items to drag for the given key. */\n getItems(key: Key): DragItem[];\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>;\n /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /** Begins a drag for the given key. This triggers the onDragStart event. */\n startDrag(key: Key, event: DragStartEvent): void;\n /** Triggers an onDragMove event. */\n moveDrag(event: DragMoveEvent): void;\n /** Ends the current drag, and emits an onDragEnd event. */\n endDrag(event: DraggableCollectionEndEvent): void;\n}\n\n/**\n * Manages state for a draggable collection.\n */\nexport function useDraggableCollectionState<T = object>(\n props: DraggableCollectionStateOptions<T>\n): DraggableCollectionState {\n let {\n getItems,\n isDisabled,\n collection,\n selectionManager,\n onDragStart,\n onDragMove,\n onDragEnd,\n preview,\n getAllowedDropOperations\n } = props;\n let [, setDragging] = useState(false);\n let draggingKeys = useRef(new Set<Key>());\n let draggedKey = useRef<Key | null>(null);\n let getKeys = (key: Key) => {\n // The clicked item is always added to the drag. If it is selected, then all of the\n // other selected items are also dragged. If it is not selected, then only the clicked\n // item is dragged. This matches native macOS behavior.\n // Additionally, we filter out any keys that are children of any of the other selected keys\n let keys = new Set<Key>();\n if (selectionManager.isSelected(key)) {\n for (let currentKey of selectionManager.selectedKeys) {\n let node = collection.getItem(currentKey);\n if (node) {\n let isChild = false;\n let parentKey = node.parentKey;\n while (parentKey != null) {\n // eslint-disable-next-line max-depth\n if (selectionManager.selectedKeys.has(parentKey)) {\n isChild = true;\n break;\n }\n let parentNode = collection.getItem(parentKey);\n parentKey = parentNode ? parentNode.parentKey : null;\n }\n\n if (!isChild) {\n keys.add(currentKey);\n }\n }\n }\n } else {\n keys.add(key);\n }\n\n return keys;\n };\n\n return {\n collection,\n selectionManager,\n get draggedKey() {\n return draggedKey.current;\n },\n get draggingKeys() {\n return draggingKeys.current;\n },\n isDragging(key) {\n return draggingKeys.current.has(key);\n },\n getKeysForDrag: getKeys,\n getItems(key) {\n let keys = getKeys(key);\n let items: any[] = [];\n for (let key of keys) {\n let value = collection.getItem(key)?.value;\n if (value != null) {\n items.push(value);\n }\n }\n\n return getItems(getKeys(key), items);\n },\n isDisabled,\n preview,\n getAllowedDropOperations,\n startDrag(key, event) {\n let keys = getKeys(key);\n draggingKeys.current = keys;\n draggedKey.current = key;\n selectionManager.setFocused(false);\n setDragging(true);\n if (typeof onDragStart === 'function') {\n onDragStart({\n ...event,\n keys\n });\n }\n },\n moveDrag(event) {\n if (typeof onDragMove === 'function') {\n onDragMove({\n ...event,\n keys: draggingKeys.current\n });\n }\n },\n endDrag(event) {\n let {isInternal} = event;\n\n if (typeof onDragEnd === 'function') {\n onDragEnd({\n ...event,\n keys: draggingKeys.current,\n isInternal\n });\n }\n\n draggingKeys.current = new Set();\n draggedKey.current = null;\n setDragging(false);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableCollectionState.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA2CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,UACT,MAAM,wBACN,oBAAoB,cACpB,UAAU,oBACV,gBAAgB,eAChB,WAAW,oBACX,gBAAgB,UAChB,MAAM,EACP,GAAG;IACJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,qBAAO,EAAqB;IACtD,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAqB;IAE1C,IAAI,oBAAoB,CAAC;QACvB,IAAI,OAAO,YAAY,KAAK,UAAU;YACpC,IAAI,OAAO,WAAW,OAAO,CAAC,OAAO,GAAG;YACxC,O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AC,OAAO,GAAG,KAAK,OAAO,YAAY,KAAK,MAC1D,OAAO;gBAGT,IAAI,aAAyB,OAAO,GAAG;gBACvC,MAAO,cAAc,KAAM;oBACzB,IAAI,OAAO,WAAW,OAAO,CAAC;oBAC9B,IAAI,YAAY,MAAM;oBACtB,IAAI,aAAa,QAAQ,aAAa,GAAG,CAAC,YACxC,OAAO;oBAET,aAAa,aAAa;gBAC5B;YACF;YAEA,OAAO,wBAAwB;QACjC;IACF;AACF;AAEA,SAAS,wCAAkB,CAAqB,EAAE,CAAqB;IACrE,IAAI,CAAC,GACH,OAAO,CAAC;IAGV,OAAQ,EAAE,IAAI;QACZ,KAAK;YACH,OAAO,GAAG,SAAS;QACrB,KAAK;YACH,OAAO,GAAG,SAAS,UAAU,GAAG,QAAQ,EAAE,GAAG,IAAI,GAAG,iBAAiB,EAAE,YAAY;IACvF;AACF;AAEA,SAAS,6CAAuB,UAAqC,EAAE,MAAsB,EAAE,YAAsB;IACnH,IAAI,aAAa,WAAW,OAAO,CAAC,OAAO,GAAG;IAE9C,KAAK,IAAI,OAAO,aAAc;QAC5B,IAAI,OAAO,WAAW,OAAO,CAAC;QAC9B,IAAI,MAAM,cAAc,YAAY,WAClC,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/react-stately/src/dnd/useDroppableCollectionState.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 {Collection, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n onMove,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let node = collection.getItem(target.key);\n return node && node.prevKey != null\n ? {type: 'item', key: node.prevKey, dropPosition: 'after'} \n : null;\n } else if (target.dropPosition === 'after') {\n let node = collection.getItem(target.key);\n return node && node.nextKey != null\n ? {type: 'item', key: node.nextKey, dropPosition: 'before'} \n : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder\n && target.type === 'item'\n && isInternal\n && (target.dropPosition === 'before' || target.dropPosition === 'after')\n && isDraggingWithinParent(collection, target, draggingKeys);\n\n let isItemDropAllowed = target.type !== 'item'\n || target.dropPosition !== 'on'\n || (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n let isValidMove = onMove\n && target.type === 'item'\n && isInternal\n && isItemDropAllowed;\n\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n \n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop \n && target.type === 'item' \n && target.dropPosition === 'on' \n && !(isInternal && target.key != null && draggingKeys.has(target.key)) \n && isItemDropAllowed;\n\n if (onDrop || isValidInsert || isValidReorder || isValidMove || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, collection, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onMove, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n let {target, isInternal, draggingKeys} = e;\n\n // Prevent dropping items onto themselves or their descendants\n if (isInternal && target.type === 'item' && draggingKeys.size > 0) {\n if (draggingKeys.has(target.key) && target.dropPosition === 'on') {\n return 'cancel';\n }\n\n let currentKey: Key | null = target.key;\n while (currentKey != null) {\n let item = collection.getItem(currentKey);\n let parentKey = item?.parentKey;\n if (parentKey != null && draggingKeys.has(parentKey)) {\n return 'cancel';\n }\n currentKey = parentKey ?? null;\n }\n }\n\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n\nfunction isDraggingWithinParent(collection: Collection<Node<unknown>>, target: ItemDropTarget, draggingKeys: Set<Key>) {\n let targetNode = collection.getItem(target.key);\n\n for (let key of draggingKeys) {\n let node = collection.getItem(key);\n if (node?.parentKey !== targetNode?.parentKey) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAuDM,SAAS,0CACd,KAAsC;IAEtC,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,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AAK,QAC5B,OAAO,YAAY,KAAK,MAExB,OACE,wCAAkB,kBAAkB,aAAa,WACjD,wCAAkB,YAAY,kBAAkB;YAIpD,OAAO;QACT;QACA,kBAAiB,CAAC;YAChB,IAAI,UAAC,MAAM,cAAE,UAAU,gBAAE,YAAY,EAAC,GAAG;YAEzC,8DAA8D;YAC9D,IAAI,cAAc,OAAO,IAAI,KAAK,UAAU,aAAa,IAAI,GAAG,GAAG;gBACjE,IAAI,aAAa,GAAG,CAAC,OAAO,GAAG,KAAK,OAAO,YAAY,KAAK,MAC1D,OAAO;gBAGT,IAAI,aAAyB,OAAO,GAAG;gBACvC,MAAO,cAAc,KAAM;oBACzB,IAAI,OAAO,WAAW,OAAO,CAAC;oBAC9B,IAAI,YAAY,MAAM;oBACtB,IAAI,aAAa,QAAQ,aAAa,GAAG,CAAC,YACxC,OAAO;oBAET,aAAa,aAAa;gBAC5B;YACF;YAEA,OAAO,wBAAwB;QACjC;IACF;AACF;AAEA,SAAS,wCAAkB,CAAqB,EAAE,CAAqB;IACrE,IAAI,CAAC,GACH,OAAO,CAAC;IAGV,OAAQ,EAAE,IAAI;QACZ,KAAK;YACH,OAAO,GAAG,SAAS;QACrB,KAAK;YACH,OAAO,GAAG,SAAS,UAAU,GAAG,QAAQ,EAAE,GAAG,IAAI,GAAG,iBAAiB,EAAE,YAAY;IACvF;AACF;AAEA,SAAS,6CACP,UAAqC,EACrC,MAAsB,EACtB,YAAsB;IAEtB,IAAI,aAAa,WAAW,OAAO,CAAC,OAAO,GAAG;IAE9C,KAAK,IAAI,OAAO,aAAc;QAC5B,IAAI,OAAO,WAAW,OAAO,CAAC;QAC9B,IAAI,MAAM,cAAc,YAAY,WAClC,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/react-stately/src/dnd/useDroppableCollectionState.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 {\n Collection,\n DragTypes,\n DropOperation,\n DroppableCollectionProps,\n DropTarget,\n ItemDropTarget,\n Key,\n Node\n} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget;\n types: DragTypes;\n allowedOperations: DropOperation[];\n isInternal: boolean;\n draggingKeys: Set<Key>;\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<\n DroppableCollectionProps,\n 'onDropMove' | 'onDropActivate'\n> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** Whether the drop events should be disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DroppableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** The current drop target. */\n target: DropTarget | null;\n /** Whether drop events are disabled. */\n isDisabled?: boolean;\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void;\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean;\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation;\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(\n props: DroppableCollectionStateOptions\n): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n onMove,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let node = collection.getItem(target.key);\n return node && node.prevKey != null\n ? {type: 'item', key: node.prevKey, dropPosition: 'after'}\n : null;\n } else if (target.dropPosition === 'after') {\n let node = collection.getItem(target.key);\n return node && node.nextKey != null\n ? {type: 'item', key: node.nextKey, dropPosition: 'before'}\n : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback(\n (e: DropOperationEvent) => {\n let {target, types, allowedOperations, isInternal, draggingKeys} = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert =\n onInsert &&\n target.type === 'item' &&\n !isInternal &&\n (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder =\n onReorder &&\n target.type === 'item' &&\n isInternal &&\n (target.dropPosition === 'before' || target.dropPosition === 'after') &&\n isDraggingWithinParent(collection, target, draggingKeys);\n\n let isItemDropAllowed =\n target.type !== 'item' ||\n target.dropPosition !== 'on' ||\n !shouldAcceptItemDrop ||\n shouldAcceptItemDrop(target, types);\n\n let isValidMove = onMove && target.type === 'item' && isInternal && isItemDropAllowed;\n\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop =\n onItemDrop &&\n target.type === 'item' &&\n target.dropPosition === 'on' &&\n !(isInternal && target.key != null && draggingKeys.has(target.key)) &&\n isItemDropAllowed;\n\n if (\n onDrop ||\n isValidInsert ||\n isValidReorder ||\n isValidMove ||\n isValidRootDrop ||\n isValidOnItemDrop\n ) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n },\n [\n isDisabled,\n collection,\n acceptedDragTypes,\n getDropOperation,\n onInsert,\n onRootDrop,\n onItemDrop,\n shouldAcceptItemDrop,\n onReorder,\n onMove,\n onDrop\n ]\n );\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return (\n isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target))\n );\n }\n\n return false;\n },\n getDropOperation(e) {\n let {target, isInternal, draggingKeys} = e;\n\n // Prevent dropping items onto themselves or their descendants\n if (isInternal && target.type === 'item' && draggingKeys.size > 0) {\n if (draggingKeys.has(target.key) && target.dropPosition === 'on') {\n return 'cancel';\n }\n\n let currentKey: Key | null = target.key;\n while (currentKey != null) {\n let item = collection.getItem(currentKey);\n let parentKey = item?.parentKey;\n if (parentKey != null && draggingKeys.has(parentKey)) {\n return 'cancel';\n }\n currentKey = parentKey ?? null;\n }\n }\n\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n\nfunction isDraggingWithinParent(\n collection: Collection<Node<unknown>>,\n target: ItemDropTarget,\n draggingKeys: Set<Key>\n) {\n let targetNode = collection.getItem(target.key);\n\n for (let key of draggingKeys) {\n let node = collection.getItem(key);\n if (node?.parentKey !== targetNode?.parentKey) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AA2CM,SAAS,0CAA4B,KAAsC;IAChF,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,UACT,MAAM,wBACN,oBAAoB,cACpB,UAAU,oBACV,gBAAgB,eAChB,WAAW,oBACX,gBAAgB,UAChB,MAAM,EACP,GAAG;IACJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAqB;IACtD,IAAI,YAAY,CAAA,GAAA,aAAK,EAAqB;IAE1C,IAAI,oBAAoB,CAAC;QACvB,IAAI,OAAO,YAAY,KAAK,UAAU;YACpC,IAAI,OAAO,WAAW,OAAO,CAAC,OAAO,GAAG;YACxC,OAAO,QAAQ,KAAK,OAAO,IAAI,OAC3B;gBAAC,MAAM;gBAAQ,KAAK,KAAK,OAAO;gBAAE,cAAc;YAAO,IACvD;QACN,OAAO,IAAI,OAAO,YAAY,KAAK,SAAS;YAC1C,IAAI,OAAO,WAAW,OAAO,CAAC,OAAO,GAAG;YACxC,OAAO,QAAQ,KAAK,OAAO,IAAI,OAC3B;gBAAC,MAAM;gBAAQ,KAAK,KAAK,OAAO;gBAAE,cAAc;YAAQ,IACxD;QACN;QACA,OAAO;IACT;IAEA,IAAI,0BAA0B,CAAA,GAAA,kBAAU,EAAE,CAAC;QACzC,IAAI,UACF,MAAM,SACN,KAAK,qBACL,iBAAiB,cACjB,UAAU,gBAC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AqB,EAAE,CAAqB;IACrE,IAAI,CAAC,GACH,OAAO,CAAC;IAGV,OAAQ,EAAE,IAAI;QACZ,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK;QACrB,KAAK;YACH,OAAO,CAAA,cAAA,wBAAA,EAAG,IAAI,MAAK,UAAU,CAAA,cAAA,wBAAA,EAAG,GAAG,MAAK,EAAE,GAAG,IAAI,CAAA,cAAA,wBAAA,EAAG,YAAY,MAAK,EAAE,YAAY;IACvF;AACF;AAEA,SAAS,6CAAuB,UAAqC,EAAE,MAAsB,EAAE,YAAsB;IACnH,IAAI,aAAa,WAAW,OAAO,CAAC,OAAO,GAAG;IAE9C,KAAK,IAAI,OAAO,aAAc;QAC5B,IAAI,OAAO,WAAW,OAAO,CAAC;QAC9B,IAAI,CAAA,iBAAA,2BAAA,KAAM,SAAS,OAAK,uBAAA,iCAAA,WAAY,SAAS,GAC3C,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/react-stately/src/dnd/useDroppableCollectionState.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 {Collection, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<Key>\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<DroppableCollectionProps, 'onDropMove' | 'onDropActivate'> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** Whether the drop events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface DroppableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>,\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager,\n /** The current drop target. */\n target: DropTarget | null,\n /** Whether drop events are disabled. */\n isDisabled?: boolean,\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void,\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean,\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(props: DroppableCollectionStateOptions): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n onMove,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let node = collection.getItem(target.key);\n return node && node.prevKey != null\n ? {type: 'item', key: node.prevKey, dropPosition: 'after'} \n : null;\n } else if (target.dropPosition === 'after') {\n let node = collection.getItem(target.key);\n return node && node.nextKey != null\n ? {type: 'item', key: node.nextKey, dropPosition: 'before'} \n : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {\n let {\n target,\n types,\n allowedOperations,\n isInternal,\n draggingKeys\n } = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder = onReorder\n && target.type === 'item'\n && isInternal\n && (target.dropPosition === 'before' || target.dropPosition === 'after')\n && isDraggingWithinParent(collection, target, draggingKeys);\n\n let isItemDropAllowed = target.type !== 'item'\n || target.dropPosition !== 'on'\n || (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));\n\n let isValidMove = onMove\n && target.type === 'item'\n && isInternal\n && isItemDropAllowed;\n\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n \n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop = onItemDrop \n && target.type === 'item' \n && target.dropPosition === 'on' \n && !(isInternal && target.key != null && draggingKeys.has(target.key)) \n && isItemDropAllowed;\n\n if (onDrop || isValidInsert || isValidReorder || isValidMove || isValidRootDrop || isValidOnItemDrop) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n }, [isDisabled, collection, acceptedDragTypes, getDropOperation, onInsert, onRootDrop, onItemDrop, shouldAcceptItemDrop, onReorder, onMove, onDrop]);\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target));\n }\n\n return false;\n },\n getDropOperation(e) {\n let {target, isInternal, draggingKeys} = e;\n\n // Prevent dropping items onto themselves or their descendants\n if (isInternal && target.type === 'item' && draggingKeys.size > 0) {\n if (draggingKeys.has(target.key) && target.dropPosition === 'on') {\n return 'cancel';\n }\n\n let currentKey: Key | null = target.key;\n while (currentKey != null) {\n let item = collection.getItem(currentKey);\n let parentKey = item?.parentKey;\n if (parentKey != null && draggingKeys.has(parentKey)) {\n return 'cancel';\n }\n currentKey = parentKey ?? null;\n }\n }\n\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n\nfunction isDraggingWithinParent(collection: Collection<Node<unknown>>, target: ItemDropTarget, draggingKeys: Set<Key>) {\n let targetNode = collection.getItem(target.key);\n\n for (let key of draggingKeys) {\n let node = collection.getItem(key);\n if (node?.parentKey !== targetNode?.parentKey) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.js.map"}
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAuDM,SAAS,0CACd,KAAsC;IAEtC,IAAI,qBACF,oBAAoB,mBACpB,UAAU,YACV,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,UACT,MAAM,wBACN,oBAAoB,cACpB,UAAU,oBACV,gBAAgB,eAChB,WAAW,oBACX,gBAAgB,UAChB,MAAM,EACP,GAAG;IACJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAqB;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ights 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 {\n Collection,\n DragTypes,\n DropOperation,\n DroppableCollectionProps,\n DropTarget,\n ItemDropTarget,\n Key,\n Node\n} from '@react-types/shared';\nimport {MultipleSelectionManager} from '../selection/types';\nimport {useCallback, useRef, useState} from 'react';\n\ninterface DropOperationEvent {\n target: DropTarget;\n types: DragTypes;\n allowedOperations: DropOperation[];\n isInternal: boolean;\n draggingKeys: Set<Key>;\n}\n\nexport interface DroppableCollectionStateOptions extends Omit<\n DroppableCollectionProps,\n 'onDropMove' | 'onDropActivate'\n> {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** Whether the drop events should be disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DroppableCollectionState {\n /** A collection of items. */\n collection: Collection<Node<unknown>>;\n /** An interface for reading and updating multiple selection state. */\n selectionManager: MultipleSelectionManager;\n /** The current drop target. */\n target: DropTarget | null;\n /** Whether drop events are disabled. */\n isDisabled?: boolean;\n /** Sets the current drop target. */\n setTarget(target: DropTarget | null): void;\n /** Returns whether the given target is equivalent to the current drop target. */\n isDropTarget(target: DropTarget | null): boolean;\n /** Returns the drop operation for the given parameters. */\n getDropOperation(e: DropOperationEvent): DropOperation;\n}\n\n/**\n * Manages state for a droppable collection.\n */\nexport function useDroppableCollectionState(\n props: DroppableCollectionStateOptions\n): DroppableCollectionState {\n let {\n acceptedDragTypes = 'all',\n isDisabled,\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n onMove,\n shouldAcceptItemDrop,\n collection,\n selectionManager,\n onDropEnter,\n getDropOperation,\n onDrop\n } = props;\n let [target, setTarget] = useState<DropTarget | null>(null);\n let targetRef = useRef<DropTarget | null>(null);\n\n let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {\n if (target.dropPosition === 'before') {\n let node = collection.getItem(target.key);\n return node && node.prevKey != null\n ? {type: 'item', key: node.prevKey, dropPosition: 'after'}\n : null;\n } else if (target.dropPosition === 'after') {\n let node = collection.getItem(target.key);\n return node && node.nextKey != null\n ? {type: 'item', key: node.nextKey, dropPosition: 'before'}\n : null;\n }\n return null;\n };\n\n let defaultGetDropOperation = useCallback(\n (e: DropOperationEvent) => {\n let {target, types, allowedOperations, isInternal, draggingKeys} = e;\n\n if (isDisabled || !target) {\n return 'cancel';\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {\n let isValidInsert =\n onInsert &&\n target.type === 'item' &&\n !isInternal &&\n (target.dropPosition === 'before' || target.dropPosition === 'after');\n let isValidReorder =\n onReorder &&\n target.type === 'item' &&\n isInternal &&\n (target.dropPosition === 'before' || target.dropPosition === 'after') &&\n isDraggingWithinParent(collection, target, draggingKeys);\n\n let isItemDropAllowed =\n target.type !== 'item' ||\n target.dropPosition !== 'on' ||\n !shouldAcceptItemDrop ||\n shouldAcceptItemDrop(target, types);\n\n let isValidMove = onMove && target.type === 'item' && isInternal && isItemDropAllowed;\n\n // Feedback was that internal root drop was weird so preventing that from happening\n let isValidRootDrop = onRootDrop && target.type === 'root' && !isInternal;\n\n // Automatically prevent items (i.e. folders) from being dropped on themselves.\n let isValidOnItemDrop =\n onItemDrop &&\n target.type === 'item' &&\n target.dropPosition === 'on' &&\n !(isInternal && target.key != null && draggingKeys.has(target.key)) &&\n isItemDropAllowed;\n\n if (\n onDrop ||\n isValidInsert ||\n isValidReorder ||\n isValidMove ||\n isValidRootDrop ||\n isValidOnItemDrop\n ) {\n if (getDropOperation) {\n return getDropOperation(target, types, allowedOperations);\n } else {\n return allowedOperations[0];\n }\n }\n }\n\n return 'cancel';\n },\n [\n isDisabled,\n collection,\n acceptedDragTypes,\n getDropOperation,\n onInsert,\n onRootDrop,\n onItemDrop,\n shouldAcceptItemDrop,\n onReorder,\n onMove,\n onDrop\n ]\n );\n\n return {\n collection,\n selectionManager,\n isDisabled,\n target,\n setTarget(newTarget) {\n if (this.isDropTarget(newTarget)) {\n return;\n }\n\n let target = targetRef.current;\n if (target && typeof props.onDropExit === 'function') {\n props.onDropExit({\n type: 'dropexit',\n x: 0, // todo\n y: 0,\n target\n });\n }\n\n if (newTarget && typeof onDropEnter === 'function') {\n onDropEnter({\n type: 'dropenter',\n x: 0, // todo\n y: 0,\n target: newTarget\n });\n }\n\n targetRef.current = newTarget ?? null;\n setTarget(newTarget ?? null);\n },\n isDropTarget(dropTarget) {\n let target = targetRef.current;\n if (!target || !dropTarget) {\n return false;\n }\n if (isEqualDropTarget(dropTarget, target)) {\n return true;\n }\n\n // Check if the targets point at the same point between two items, one referring before, and the other after.\n if (\n dropTarget?.type === 'item' &&\n target?.type === 'item' &&\n dropTarget.key !== target.key &&\n dropTarget.dropPosition !== target.dropPosition &&\n dropTarget.dropPosition !== 'on' &&\n target.dropPosition !== 'on'\n ) {\n return (\n isEqualDropTarget(getOppositeTarget(dropTarget), target) ||\n isEqualDropTarget(dropTarget, getOppositeTarget(target))\n );\n }\n\n return false;\n },\n getDropOperation(e) {\n let {target, isInternal, draggingKeys} = e;\n\n // Prevent dropping items onto themselves or their descendants\n if (isInternal && target.type === 'item' && draggingKeys.size > 0) {\n if (draggingKeys.has(target.key) && target.dropPosition === 'on') {\n return 'cancel';\n }\n\n let currentKey: Key | null = target.key;\n while (currentKey != null) {\n let item = collection.getItem(currentKey);\n let parentKey = item?.parentKey;\n if (parentKey != null && draggingKeys.has(parentKey)) {\n return 'cancel';\n }\n currentKey = parentKey ?? null;\n }\n }\n\n return defaultGetDropOperation(e);\n }\n };\n}\n\nfunction isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {\n if (!a) {\n return !b;\n }\n\n switch (a.type) {\n case 'root':\n return b?.type === 'root';\n case 'item':\n return b?.type === 'item' && b?.key === a.key && b?.dropPosition === a.dropPosition;\n }\n}\n\nfunction isDraggingWithinParent(\n collection: Collection<Node<unknown>>,\n target: ItemDropTarget,\n draggingKeys: Set<Key>\n) {\n let targetNode = collection.getItem(target.key);\n\n for (let key of draggingKeys) {\n let node = collection.getItem(key);\n if (node?.parentKey !== targetNode?.parentKey) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"useDroppableCollectionState.js.map"}
|