@razorpay/blade 12.110.0 → 12.119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/spark/colorama-center-gradient-map-dark.jpg +0 -0
- package/assets/spark/colorama-gradient-map-dark.png +0 -0
- package/build/lib/native/components/AnimateInteractions/AnimateInteractions.native.js +5 -5
- package/build/lib/native/components/AnimateInteractions/AnimateInteractions.native.js.map +1 -1
- package/build/lib/native/components/AnimateInteractions/AnimateInteractionsProvider.js +6 -0
- package/build/lib/native/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -0
- package/build/lib/native/components/BaseMotion/BaseMotion.native.js +22 -0
- package/build/lib/native/components/BaseMotion/BaseMotion.native.js.map +1 -0
- package/build/lib/native/components/BaseMotion/baseMotionInterpreter.native.js +11 -0
- package/build/lib/native/components/BaseMotion/baseMotionInterpreter.native.js.map +1 -0
- package/build/lib/native/components/BaseMotion/baseMotionUtils.js +4 -0
- package/build/lib/native/components/BaseMotion/baseMotionUtils.js.map +1 -0
- package/build/lib/native/components/BaseMotion/index.js +3 -0
- package/build/lib/native/components/BaseMotion/index.js.map +1 -0
- package/build/lib/native/components/BaseMotion/types.js +2 -0
- package/build/lib/native/components/BaseMotion/types.js.map +1 -0
- package/build/lib/native/components/Button/BaseButton/BaseButton.js +3 -3
- package/build/lib/native/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/native/components/Button/BaseButton/buttonTokens.js +1 -1
- package/build/lib/native/components/Button/BaseButton/buttonTokens.js.map +1 -1
- package/build/lib/native/components/Charts/AreaChart/AreaChart.native.js +2 -1
- package/build/lib/native/components/Charts/AreaChart/AreaChart.native.js.map +1 -1
- package/build/lib/native/components/Charts/CommonChartComponents/CommonChartComponents.native.js +2 -2
- package/build/lib/native/components/Charts/CommonChartComponents/CommonChartComponents.native.js.map +1 -1
- package/build/lib/native/components/Charts/CommonChartComponents/index.js +1 -1
- package/build/lib/native/components/Charts/CommonChartComponents/tokens.js +2 -2
- package/build/lib/native/components/Charts/CommonChartComponents/tokens.js.map +1 -1
- package/build/lib/native/components/Charts/LineChart/LineChart.native.js +4 -2
- package/build/lib/native/components/Charts/LineChart/LineChart.native.js.map +1 -1
- package/build/lib/native/components/Charts/utils/nullBridgeUtils.js +4 -0
- package/build/lib/native/components/Charts/utils/nullBridgeUtils.js.map +1 -0
- package/build/lib/native/components/Charts/utils/referenceBandUtils.js +6 -0
- package/build/lib/native/components/Charts/utils/referenceBandUtils.js.map +1 -0
- package/build/lib/native/components/CounterInput/CounterInput.native.js +3 -2
- package/build/lib/native/components/CounterInput/CounterInput.native.js.map +1 -1
- package/build/lib/native/components/CounterInput/token.js +2 -2
- package/build/lib/native/components/CounterInput/token.js.map +1 -1
- package/build/lib/native/components/DatePicker/Calendar.native.js +2 -2
- package/build/lib/native/components/DatePicker/Calendar.native.js.map +1 -1
- package/build/lib/native/components/DatePicker/utils.js +2 -2
- package/build/lib/native/components/DatePicker/utils.js.map +1 -1
- package/build/lib/native/components/Dropdown/Dropdown.js +1 -1
- package/build/lib/native/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js +2 -1
- package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js.map +1 -1
- package/build/lib/native/components/Dropdown/dropdownUtils.js +1 -1
- package/build/lib/native/components/Dropdown/dropdownUtils.js.map +1 -1
- package/build/lib/native/components/Dropdown/filterChipSelectInputUtils.js +4 -0
- package/build/lib/native/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/native/components/Dropdown/useDropdown.js +1 -1
- package/build/lib/native/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/native/components/Fade/Fade.native.js +7 -5
- package/build/lib/native/components/Fade/Fade.native.js.map +1 -1
- package/build/lib/native/components/FilterChip/BaseFilterChip.native.js +2 -2
- package/build/lib/native/components/FilterChip/BaseFilterChip.native.js.map +1 -1
- package/build/lib/native/components/FloatingActionButton/FloatingActionButton.js +14 -0
- package/build/lib/native/components/FloatingActionButton/FloatingActionButton.js.map +1 -0
- package/build/lib/native/components/FloatingActionButton/FloatingActionButtonContainer.native.js +20 -0
- package/build/lib/native/components/FloatingActionButton/FloatingActionButtonContainer.native.js.map +1 -0
- package/build/lib/native/components/FloatingActionButton/index.js +2 -0
- package/build/lib/native/components/FloatingActionButton/index.js.map +1 -0
- package/build/lib/native/components/GenUI/GenUIContext.native.js +2 -2
- package/build/lib/native/components/GenUI/GenUIContext.native.js.map +1 -1
- package/build/lib/native/components/GenUI/index.js +1 -1
- package/build/lib/native/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js +14 -0
- package/build/lib/native/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js.map +1 -0
- package/build/lib/native/components/Icons/BookmarkFilledIcon/index.js +2 -0
- package/build/lib/native/components/Icons/BookmarkFilledIcon/index.js.map +1 -0
- package/build/lib/native/components/Icons/index.js +1 -0
- package/build/lib/native/components/Icons/index.js.map +1 -1
- package/build/lib/native/components/Input/BaseInput/StyledBaseInput.native.js +1 -1
- package/build/lib/native/components/Input/BaseInput/StyledBaseInput.native.js.map +1 -1
- package/build/lib/native/components/Input/OTPInput/OTPInput.js +1 -1
- package/build/lib/native/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/native/components/Morph/Morph.native.js +9 -5
- package/build/lib/native/components/Morph/Morph.native.js.map +1 -1
- package/build/lib/native/components/Move/Move.native.js +8 -5
- package/build/lib/native/components/Move/Move.native.js.map +1 -1
- package/build/lib/native/components/Scale/Scale.native.js +7 -5
- package/build/lib/native/components/Scale/Scale.native.js.map +1 -1
- package/build/lib/native/components/SegmentedControl/SegmentedControl.native.js +27 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControl.native.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlContext.js +8 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlItem.native.js +18 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlItem.native.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/index.js +3 -0
- package/build/lib/native/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/segmentedControlTokens.js +4 -0
- package/build/lib/native/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/native/components/Slide/Slide.native.js +7 -5
- package/build/lib/native/components/Slide/Slide.native.js.map +1 -1
- package/build/lib/native/components/Spark/RzpGlass/utils.native.js +1 -1
- package/build/lib/native/components/Spark/RzpGlass/utils.native.js.map +1 -1
- package/build/lib/native/components/Stagger/Stagger.native.js +10 -5
- package/build/lib/native/components/Stagger/Stagger.native.js.map +1 -1
- package/build/lib/native/components/Stagger/StaggerProvider.js +6 -0
- package/build/lib/native/components/Stagger/StaggerProvider.js.map +1 -0
- package/build/lib/native/components/TreeView/TreeView.native.js +4 -0
- package/build/lib/native/components/TreeView/TreeView.native.js.map +1 -0
- package/build/lib/native/components/TreeView/index.native.js +2 -0
- package/build/lib/native/components/TreeView/index.native.js.map +1 -0
- package/build/lib/native/components/index.js +10 -2
- package/build/lib/native/components/index.js.map +1 -1
- package/build/lib/native/tokens/global/colors.js +1 -1
- package/build/lib/native/tokens/global/colors.js.map +1 -1
- package/build/lib/native/tokens/index.js +1 -0
- package/build/lib/native/tokens/index.js.map +1 -1
- package/build/lib/native/tokens/theme/bladeNeutralTheme.js +15 -0
- package/build/lib/native/tokens/theme/bladeNeutralTheme.js.map +1 -0
- package/build/lib/native/tokens/theme/bladeTheme.js +1 -1
- package/build/lib/native/tokens/theme/bladeTheme.js.map +1 -1
- package/build/lib/native/tokens/theme/index.js +1 -0
- package/build/lib/native/tokens/theme/index.js.map +1 -1
- package/build/lib/native/tokens/theme/theme.js.map +1 -1
- package/build/lib/native/utils/componentZIndices.js +1 -1
- package/build/lib/native/utils/componentZIndices.js.map +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/native/utils/msToSeconds.js +4 -0
- package/build/lib/native/utils/msToSeconds.js.map +1 -0
- package/build/lib/native/utils/useControlledDropdownInput/useControlledDropdownInput.js +1 -1
- package/build/lib/native/utils/useControlledDropdownInput/useControlledDropdownInput.js.map +1 -1
- package/build/lib/web/development/_virtual/flatten.js +1 -1
- package/build/lib/web/development/_virtual/flatten3.js +1 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractions.web.js +1 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractionsProvider.js +2 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -1
- package/build/lib/web/development/components/AnimateInteractions/{useFocusWithin.js → useFocusWithin.web.js} +1 -1
- package/build/lib/web/development/components/AnimateInteractions/useFocusWithin.web.js.map +1 -0
- package/build/lib/web/development/components/Button/BaseButton/BaseButton.js +124 -73
- package/build/lib/web/development/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/web/development/components/Button/BaseButton/buttonTokens.js +68 -2
- package/build/lib/web/development/components/Button/BaseButton/buttonTokens.js.map +1 -1
- package/build/lib/web/development/components/Charts/AreaChart/AreaChart.web.js +206 -18
- package/build/lib/web/development/components/Charts/AreaChart/AreaChart.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/CommonChartComponents.web.js +159 -43
- package/build/lib/web/development/components/Charts/CommonChartComponents/CommonChartComponents.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/index.js +1 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/tokens.js +15 -2
- package/build/lib/web/development/components/Charts/CommonChartComponents/tokens.js.map +1 -1
- package/build/lib/web/development/components/Charts/LineChart/LineChart.web.js +272 -15
- package/build/lib/web/development/components/Charts/LineChart/LineChart.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/LineChart/useReferenceBand.js +195 -0
- package/build/lib/web/development/components/Charts/LineChart/useReferenceBand.js.map +1 -0
- package/build/lib/web/development/components/Charts/utils/nullBridgeUtils.js +175 -0
- package/build/lib/web/development/components/Charts/utils/nullBridgeUtils.js.map +1 -0
- package/build/lib/web/development/components/Charts/utils/referenceBandUtils.js +66 -0
- package/build/lib/web/development/components/Charts/utils/referenceBandUtils.js.map +1 -0
- package/build/lib/web/development/components/CounterInput/CounterInput.web.js +29 -5
- package/build/lib/web/development/components/CounterInput/CounterInput.web.js.map +1 -1
- package/build/lib/web/development/components/CounterInput/StyledCounterInput.js +20 -4
- package/build/lib/web/development/components/CounterInput/StyledCounterInput.js.map +1 -1
- package/build/lib/web/development/components/CounterInput/token.js +6 -1
- package/build/lib/web/development/components/CounterInput/token.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js +28 -1
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/Calendar.web.js +9 -2
- package/build/lib/web/development/components/DatePicker/Calendar.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +4 -1
- package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/utils.js +21 -1
- package/build/lib/web/development/components/DatePicker/utils.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/Dropdown.js +4 -1
- package/build/lib/web/development/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js +40 -5
- package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js +30 -32
- package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/dropdownUtils.js +28 -2
- package/build/lib/web/development/components/Dropdown/dropdownUtils.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/filterChipSelectInputUtils.js +60 -0
- package/build/lib/web/development/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/web/development/components/Dropdown/useDropdown.js +91 -5
- package/build/lib/web/development/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js +35 -11
- package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js.map +1 -1
- package/build/lib/web/development/components/FloatingActionButton/FloatingActionButton.js +126 -0
- package/build/lib/web/development/components/FloatingActionButton/FloatingActionButton.js.map +1 -0
- package/build/lib/web/development/components/FloatingActionButton/FloatingActionButtonContainer.web.js +45 -0
- package/build/lib/web/development/components/FloatingActionButton/FloatingActionButtonContainer.web.js.map +1 -0
- package/build/lib/web/development/components/FloatingActionButton/index.js +2 -0
- package/build/lib/web/development/components/FloatingActionButton/index.js.map +1 -0
- package/build/lib/web/development/components/GenUI/GenUIComponents.web.js.map +1 -1
- package/build/lib/web/development/components/GenUI/GenUIContext.web.js +9 -1
- package/build/lib/web/development/components/GenUI/GenUIContext.web.js.map +1 -1
- package/build/lib/web/development/components/GenUI/GenUIProvider.web.js +17 -0
- package/build/lib/web/development/components/GenUI/GenUIProvider.web.js.map +1 -1
- package/build/lib/web/development/components/GenUI/GenUISchemaRenderer.web.js +31 -6
- package/build/lib/web/development/components/GenUI/GenUISchemaRenderer.web.js.map +1 -1
- package/build/lib/web/development/components/GenUI/index.js +1 -1
- package/build/lib/web/development/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js +44 -0
- package/build/lib/web/development/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js.map +1 -0
- package/build/lib/web/development/components/Icons/BookmarkFilledIcon/index.js +2 -0
- package/build/lib/web/development/components/Icons/BookmarkFilledIcon/index.js.map +1 -0
- package/build/lib/web/development/components/Icons/index.js +1 -0
- package/build/lib/web/development/components/Icons/index.js.map +1 -1
- package/build/lib/web/development/components/Input/OTPInput/OTPInput.js +3 -0
- package/build/lib/web/development/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/web/development/components/PopupArrow/PopupArrow.web.js +7 -1
- package/build/lib/web/development/components/PopupArrow/PopupArrow.web.js.map +1 -1
- package/build/lib/web/development/components/RollingText/RollingText.web.js +27 -20
- package/build/lib/web/development/components/RollingText/RollingText.web.js.map +1 -1
- package/build/lib/web/development/components/SegmentedControl/SegmentedControl.web.js +196 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControl.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlContext.js +18 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlIndicator.web.js +109 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlIndicator.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlItem.web.js +170 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlItem.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/index.js +3 -0
- package/build/lib/web/development/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/segmentedControlTokens.js +53 -0
- package/build/lib/web/development/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/web/development/components/Spark/RzpGlass/RzpGlass.js +16 -7
- package/build/lib/web/development/components/Spark/RzpGlass/RzpGlass.js.map +1 -1
- package/build/lib/web/development/components/Spark/RzpGlass/RzpGlassMount.js +24 -6
- package/build/lib/web/development/components/Spark/RzpGlass/RzpGlassMount.js.map +1 -1
- package/build/lib/web/development/components/Spark/RzpGlass/presets.js +30 -1
- package/build/lib/web/development/components/Spark/RzpGlass/presets.js.map +1 -1
- package/build/lib/web/development/components/Spark/RzpGlass/rzpGlassShader.js +1 -1
- package/build/lib/web/development/components/Spark/RzpGlass/rzpGlassShader.js.map +1 -1
- package/build/lib/web/development/components/Spark/RzpGlass/utils.js +26 -10
- package/build/lib/web/development/components/Spark/RzpGlass/utils.js.map +1 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/Tour.web.js +31 -18
- package/build/lib/web/development/components/SpotlightPopoverTour/Tour.web.js.map +1 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/TourMask.web.js +14 -3
- package/build/lib/web/development/components/SpotlightPopoverTour/TourMask.web.js.map +1 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js +23 -4
- package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/utils.js +58 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/utils.js.map +1 -1
- package/build/lib/web/development/components/Stagger/StaggerProvider.js.map +1 -1
- package/build/lib/web/development/components/TreeView/StyledTreeViewRow.web.js +41 -0
- package/build/lib/web/development/components/TreeView/StyledTreeViewRow.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/TreeView.web.js +696 -0
- package/build/lib/web/development/components/TreeView/TreeView.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/TreeViewAnimator.web.js +184 -0
- package/build/lib/web/development/components/TreeView/TreeViewAnimator.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/TreeViewChevron.web.js +73 -0
- package/build/lib/web/development/components/TreeView/TreeViewChevron.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/TreeViewItem.web.js +295 -0
- package/build/lib/web/development/components/TreeView/TreeViewItem.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/TreeViewLoadMore.web.js +173 -0
- package/build/lib/web/development/components/TreeView/TreeViewLoadMore.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/componentIds.js +8 -0
- package/build/lib/web/development/components/TreeView/componentIds.js.map +1 -0
- package/build/lib/web/development/components/TreeView/index.web.js +4 -0
- package/build/lib/web/development/components/TreeView/index.web.js.map +1 -0
- package/build/lib/web/development/components/TreeView/treeViewUtils.js +475 -0
- package/build/lib/web/development/components/TreeView/treeViewUtils.js.map +1 -0
- package/build/lib/web/development/components/TreeView/useTreeView.js +24 -0
- package/build/lib/web/development/components/TreeView/useTreeView.js.map +1 -0
- package/build/lib/web/development/components/index.js +12 -2
- package/build/lib/web/development/components/index.js.map +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/array/flatten.js +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/flatten.js +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/sortBy.js +2 -2
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/object/omit.js +2 -2
- package/build/lib/web/development/tokens/global/colors.js +2 -2
- package/build/lib/web/development/tokens/global/colors.js.map +1 -1
- package/build/lib/web/development/tokens/index.js +1 -0
- package/build/lib/web/development/tokens/index.js.map +1 -1
- package/build/lib/web/development/tokens/theme/bladeNeutralTheme.js +1439 -0
- package/build/lib/web/development/tokens/theme/bladeNeutralTheme.js.map +1 -0
- package/build/lib/web/development/tokens/theme/bladeTheme.js +48 -12
- package/build/lib/web/development/tokens/theme/bladeTheme.js.map +1 -1
- package/build/lib/web/development/tokens/theme/index.js +1 -0
- package/build/lib/web/development/tokens/theme/index.js.map +1 -1
- package/build/lib/web/development/tokens/theme/theme.js.map +1 -1
- package/build/lib/web/development/utils/componentZIndices.js +2 -0
- package/build/lib/web/development/utils/componentZIndices.js.map +1 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js +7 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/development/utils/useControlledDropdownInput/useControlledDropdownInput.js +12 -4
- package/build/lib/web/development/utils/useControlledDropdownInput/useControlledDropdownInput.js.map +1 -1
- package/build/lib/web/development/utils/useTruncationTitle/useTruncationTitle.web.js +2 -2
- package/build/lib/web/development/utils/useTruncationTitle/useTruncationTitle.web.js.map +1 -1
- package/build/lib/web/production/_virtual/flatten.js +1 -1
- package/build/lib/web/production/_virtual/flatten3.js +1 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractions.web.js +1 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractionsProvider.js +2 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -1
- package/build/lib/web/production/components/AnimateInteractions/{useFocusWithin.js → useFocusWithin.web.js} +1 -1
- package/build/lib/web/production/components/AnimateInteractions/useFocusWithin.web.js.map +1 -0
- package/build/lib/web/production/components/Button/BaseButton/BaseButton.js +124 -73
- package/build/lib/web/production/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/web/production/components/Button/BaseButton/buttonTokens.js +68 -2
- package/build/lib/web/production/components/Button/BaseButton/buttonTokens.js.map +1 -1
- package/build/lib/web/production/components/Charts/AreaChart/AreaChart.web.js +206 -18
- package/build/lib/web/production/components/Charts/AreaChart/AreaChart.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/CommonChartComponents.web.js +159 -43
- package/build/lib/web/production/components/Charts/CommonChartComponents/CommonChartComponents.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/index.js +1 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/tokens.js +15 -2
- package/build/lib/web/production/components/Charts/CommonChartComponents/tokens.js.map +1 -1
- package/build/lib/web/production/components/Charts/LineChart/LineChart.web.js +272 -15
- package/build/lib/web/production/components/Charts/LineChart/LineChart.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/LineChart/useReferenceBand.js +195 -0
- package/build/lib/web/production/components/Charts/LineChart/useReferenceBand.js.map +1 -0
- package/build/lib/web/production/components/Charts/utils/nullBridgeUtils.js +175 -0
- package/build/lib/web/production/components/Charts/utils/nullBridgeUtils.js.map +1 -0
- package/build/lib/web/production/components/Charts/utils/referenceBandUtils.js +66 -0
- package/build/lib/web/production/components/Charts/utils/referenceBandUtils.js.map +1 -0
- package/build/lib/web/production/components/CounterInput/CounterInput.web.js +29 -5
- package/build/lib/web/production/components/CounterInput/CounterInput.web.js.map +1 -1
- package/build/lib/web/production/components/CounterInput/StyledCounterInput.js +20 -4
- package/build/lib/web/production/components/CounterInput/StyledCounterInput.js.map +1 -1
- package/build/lib/web/production/components/CounterInput/token.js +6 -1
- package/build/lib/web/production/components/CounterInput/token.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js +28 -1
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/Calendar.web.js +9 -2
- package/build/lib/web/production/components/DatePicker/Calendar.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +4 -1
- package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/utils.js +21 -1
- package/build/lib/web/production/components/DatePicker/utils.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/Dropdown.js +4 -1
- package/build/lib/web/production/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js +40 -5
- package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js +30 -32
- package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/dropdownUtils.js +28 -2
- package/build/lib/web/production/components/Dropdown/dropdownUtils.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/filterChipSelectInputUtils.js +60 -0
- package/build/lib/web/production/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/web/production/components/Dropdown/useDropdown.js +91 -5
- package/build/lib/web/production/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js +35 -11
- package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js.map +1 -1
- package/build/lib/web/production/components/FloatingActionButton/FloatingActionButton.js +126 -0
- package/build/lib/web/production/components/FloatingActionButton/FloatingActionButton.js.map +1 -0
- package/build/lib/web/production/components/FloatingActionButton/FloatingActionButtonContainer.web.js +45 -0
- package/build/lib/web/production/components/FloatingActionButton/FloatingActionButtonContainer.web.js.map +1 -0
- package/build/lib/web/production/components/FloatingActionButton/index.js +2 -0
- package/build/lib/web/production/components/FloatingActionButton/index.js.map +1 -0
- package/build/lib/web/production/components/GenUI/GenUIComponents.web.js.map +1 -1
- package/build/lib/web/production/components/GenUI/GenUIContext.web.js +9 -1
- package/build/lib/web/production/components/GenUI/GenUIContext.web.js.map +1 -1
- package/build/lib/web/production/components/GenUI/GenUIProvider.web.js +17 -0
- package/build/lib/web/production/components/GenUI/GenUIProvider.web.js.map +1 -1
- package/build/lib/web/production/components/GenUI/GenUISchemaRenderer.web.js +31 -6
- package/build/lib/web/production/components/GenUI/GenUISchemaRenderer.web.js.map +1 -1
- package/build/lib/web/production/components/GenUI/index.js +1 -1
- package/build/lib/web/production/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js +44 -0
- package/build/lib/web/production/components/Icons/BookmarkFilledIcon/BookmarkFilledIcon.js.map +1 -0
- package/build/lib/web/production/components/Icons/BookmarkFilledIcon/index.js +2 -0
- package/build/lib/web/production/components/Icons/BookmarkFilledIcon/index.js.map +1 -0
- package/build/lib/web/production/components/Icons/index.js +1 -0
- package/build/lib/web/production/components/Icons/index.js.map +1 -1
- package/build/lib/web/production/components/Input/OTPInput/OTPInput.js +3 -0
- package/build/lib/web/production/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/web/production/components/PopupArrow/PopupArrow.web.js +7 -1
- package/build/lib/web/production/components/PopupArrow/PopupArrow.web.js.map +1 -1
- package/build/lib/web/production/components/RollingText/RollingText.web.js +27 -20
- package/build/lib/web/production/components/RollingText/RollingText.web.js.map +1 -1
- package/build/lib/web/production/components/SegmentedControl/SegmentedControl.web.js +196 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControl.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlContext.js +18 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlIndicator.web.js +109 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlIndicator.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlItem.web.js +170 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlItem.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/index.js +3 -0
- package/build/lib/web/production/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/segmentedControlTokens.js +53 -0
- package/build/lib/web/production/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/web/production/components/Spark/RzpGlass/RzpGlass.js +16 -7
- package/build/lib/web/production/components/Spark/RzpGlass/RzpGlass.js.map +1 -1
- package/build/lib/web/production/components/Spark/RzpGlass/RzpGlassMount.js +24 -6
- package/build/lib/web/production/components/Spark/RzpGlass/RzpGlassMount.js.map +1 -1
- package/build/lib/web/production/components/Spark/RzpGlass/presets.js +30 -1
- package/build/lib/web/production/components/Spark/RzpGlass/presets.js.map +1 -1
- package/build/lib/web/production/components/Spark/RzpGlass/rzpGlassShader.js +1 -1
- package/build/lib/web/production/components/Spark/RzpGlass/rzpGlassShader.js.map +1 -1
- package/build/lib/web/production/components/Spark/RzpGlass/utils.js +26 -10
- package/build/lib/web/production/components/Spark/RzpGlass/utils.js.map +1 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/Tour.web.js +31 -18
- package/build/lib/web/production/components/SpotlightPopoverTour/Tour.web.js.map +1 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/TourMask.web.js +14 -3
- package/build/lib/web/production/components/SpotlightPopoverTour/TourMask.web.js.map +1 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js +23 -4
- package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/utils.js +58 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/utils.js.map +1 -1
- package/build/lib/web/production/components/Stagger/StaggerProvider.js.map +1 -1
- package/build/lib/web/production/components/TreeView/StyledTreeViewRow.web.js +41 -0
- package/build/lib/web/production/components/TreeView/StyledTreeViewRow.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/TreeView.web.js +696 -0
- package/build/lib/web/production/components/TreeView/TreeView.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/TreeViewAnimator.web.js +184 -0
- package/build/lib/web/production/components/TreeView/TreeViewAnimator.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/TreeViewChevron.web.js +73 -0
- package/build/lib/web/production/components/TreeView/TreeViewChevron.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/TreeViewItem.web.js +295 -0
- package/build/lib/web/production/components/TreeView/TreeViewItem.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/TreeViewLoadMore.web.js +173 -0
- package/build/lib/web/production/components/TreeView/TreeViewLoadMore.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/componentIds.js +8 -0
- package/build/lib/web/production/components/TreeView/componentIds.js.map +1 -0
- package/build/lib/web/production/components/TreeView/index.web.js +4 -0
- package/build/lib/web/production/components/TreeView/index.web.js.map +1 -0
- package/build/lib/web/production/components/TreeView/treeViewUtils.js +475 -0
- package/build/lib/web/production/components/TreeView/treeViewUtils.js.map +1 -0
- package/build/lib/web/production/components/TreeView/useTreeView.js +24 -0
- package/build/lib/web/production/components/TreeView/useTreeView.js.map +1 -0
- package/build/lib/web/production/components/index.js +12 -2
- package/build/lib/web/production/components/index.js.map +1 -1
- package/build/lib/web/production/node_modules/es-toolkit/dist/array/flatten.js +1 -1
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/array/flatten.js +1 -1
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/array/sortBy.js +2 -2
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/object/omit.js +2 -2
- package/build/lib/web/production/tokens/global/colors.js +2 -2
- package/build/lib/web/production/tokens/global/colors.js.map +1 -1
- package/build/lib/web/production/tokens/index.js +1 -0
- package/build/lib/web/production/tokens/index.js.map +1 -1
- package/build/lib/web/production/tokens/theme/bladeNeutralTheme.js +1439 -0
- package/build/lib/web/production/tokens/theme/bladeNeutralTheme.js.map +1 -0
- package/build/lib/web/production/tokens/theme/bladeTheme.js +48 -12
- package/build/lib/web/production/tokens/theme/bladeTheme.js.map +1 -1
- package/build/lib/web/production/tokens/theme/index.js +1 -0
- package/build/lib/web/production/tokens/theme/index.js.map +1 -1
- package/build/lib/web/production/tokens/theme/theme.js.map +1 -1
- package/build/lib/web/production/utils/componentZIndices.js +2 -0
- package/build/lib/web/production/utils/componentZIndices.js.map +1 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js +7 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/production/utils/useControlledDropdownInput/useControlledDropdownInput.js +12 -4
- package/build/lib/web/production/utils/useControlledDropdownInput/useControlledDropdownInput.js.map +1 -1
- package/build/lib/web/production/utils/useTruncationTitle/useTruncationTitle.web.js +2 -2
- package/build/lib/web/production/utils/useTruncationTitle/useTruncationTitle.web.js.map +1 -1
- package/build/types/components/index.d.ts +794 -25
- package/build/types/components/index.native.d.ts +872 -29
- package/build/types/tokens/index.d.ts +11 -4
- package/build/types/tokens/index.native.d.ts +11 -4
- package/build/types/utils/index.d.ts +8 -3
- package/build/types/utils/index.native.d.ts +8 -3
- package/package.json +2 -2
- package/build/lib/web/development/components/AnimateInteractions/useFocusWithin.js.map +0 -1
- package/build/lib/web/production/components/AnimateInteractions/useFocusWithin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterChipSelectInput.native.js","sources":["../../../../../src/components/Dropdown/FilterChipSelectInput.native.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\n\nimport React, { useEffect } from 'react';\nimport { useDropdown } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useFilterChipGroupContext } from './FilterChipGroupContext';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport { getActionListContainerRole } from '~components/ActionList/getA11yRoles';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\nimport { useId } from '~utils/useId';\nimport { useListViewFilterContext } from '~components/ListView/ListViewFiltersContext';\nimport { useFirstRender } from '~utils/useFirstRender';\n\ntype FilterChipSelectInputProps = Pick<\n BaseFilterChipProps,\n 'onKeyDown' | 'value' | 'label' | 'testID' | 'onClick' | 'selectionType' | 'onBlur'\n> & {\n accessibilityLabel?: string;\n onChange?: (props: { name: string; values: string[] }) => void;\n name?: string;\n onClearButtonClick?: (props: { name: string; values: string[] }) => void;\n isDisabled?: boolean;\n} & DataAnalyticsAttribute;\n\nconst _FilterChipSelectInput = (props: FilterChipSelectInputProps): React.ReactElement => {\n const idBase = useId('filter-chip-select-input');\n const {\n onClick,\n onBlur,\n onKeyDown,\n accessibilityLabel,\n testID,\n value,\n onClearButtonClick,\n label,\n onChange,\n name,\n isDisabled,\n ...rest\n } = props;\n const [uncontrolledInputValue, setUncontrolledInputValue] = React.useState<string[]>([]);\n const isFirstRender = useFirstRender();\n\n const {\n options,\n selectedIndices,\n onTriggerClick,\n onTriggerKeydown,\n dropdownBaseId,\n isOpen,\n activeIndex,\n hasFooterAction,\n triggererRef,\n selectionType,\n isControlled,\n setSelectedIndices,\n controlledValueIndices,\n changeCallbackTriggerer,\n } = useDropdown();\n const valueTitle = options.find((option) => option.value === value)?.title ?? value;\n\n const isUnControlled = options.length > 0 && props.value === undefined;\n const { listViewSelectedFilters, setListViewSelectedFilters } = useListViewFilterContext();\n const {\n clearFilterCallbackTriggerer,\n setFilterChipGroupSelectedFilters,\n } = useFilterChipGroupContext();\n\n const getValuesArrayFromIndices = (): string[] => {\n let indices: number[] = [];\n if (isControlled) {\n indices = controlledValueIndices;\n } else {\n indices = selectedIndices;\n }\n\n return indices.map((i) => options[i]?.value).filter((v): v is string => v !== undefined);\n };\n\n useEffect(() => {\n const valueNotEmpty =\n (typeof value === 'string' && value.trim() !== '') ||\n (Array.isArray(value) && value.length > 0);\n\n const currentSelectedValues = selectedIndices.map((i) => options[i]?.value);\n const isSingleValueSynced =\n typeof value === 'string' &&\n currentSelectedValues.length === 1 &&\n currentSelectedValues[0] === value;\n\n const isMultiValueSynced =\n Array.isArray(value) &&\n value.length === currentSelectedValues.length &&\n value.every((v) => currentSelectedValues.includes(v));\n\n const isValueAndSelectedIndicesSynced = isSingleValueSynced || isMultiValueSynced;\n\n if (isUnControlled) {\n if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n const inputValue = savedIndices\n .map((i) => options[i]?.value)\n .filter((v): v is string => v !== undefined);\n setUncontrolledInputValue(inputValue);\n setFilterChipGroupSelectedFilters((prev) =>\n prev.includes(label) ? prev : [...prev, label],\n );\n } else {\n setSelectedIndices([]);\n }\n } else if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n } else if (valueNotEmpty && !isValueAndSelectedIndicesSynced && options.length > 0) {\n const newSelectedIndices =\n typeof value === 'string'\n ? [options.findIndex((option) => option.value === value)]\n : options\n .map((option, index) => (value.includes(option.value) ? index : -1))\n .filter((index) => index !== -1);\n setSelectedIndices(newSelectedIndices);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isUnControlled, options, value]);\n\n const getTitleFromValue = (value: string): string => {\n const option = options.find((option) => option.value === value);\n return option ? option.title : '';\n };\n\n const getUnControlledFilterChipValue = (): string | string[] => {\n if (selectionType === 'single') {\n if (uncontrolledInputValue.length > 0) {\n return getTitleFromValue(uncontrolledInputValue[0]);\n }\n return '';\n }\n return uncontrolledInputValue;\n };\n\n const handleClearButtonClick = (): void => {\n const currentValues = getValuesArrayFromIndices();\n onClearButtonClick?.({ name: name ?? idBase, values: currentValues });\n onChange?.({ name: name ?? idBase, values: [] });\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n setUncontrolledInputValue([]);\n setSelectedIndices([]);\n };\n\n useEffect(() => {\n if (clearFilterCallbackTriggerer) {\n handleClearButtonClick();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clearFilterCallbackTriggerer]);\n\n useEffect(() => {\n if (!isFirstRender) {\n props.onChange?.({\n name: props.name || idBase,\n values: getValuesArrayFromIndices(),\n });\n if (isUnControlled) {\n setUncontrolledInputValue(getValuesArrayFromIndices());\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n useEffect(() => {\n const isValueEmpty = selectedIndices.length === 0;\n if (!isFirstRender && !isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => (prev.includes(label) ? prev : [...prev, label]));\n setListViewSelectedFilters((prev) => ({\n ...prev,\n [label]: selectedIndices as number[],\n }));\n } else if (!isFirstRender && isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n const handleKeyDown = (e: React.KeyboardEvent<Element>): void => {\n onKeyDown?.(e);\n onTriggerKeydown?.({ event: e as React.KeyboardEvent<HTMLInputElement> });\n\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n }\n\n if ((e.key === 'Enter' || e.key === ' ') && !isOpen) {\n e.preventDefault();\n e.stopPropagation();\n onTriggerClick();\n }\n };\n\n return (\n <BaseFilterChip\n label={label}\n value={valueTitle ?? getUnControlledFilterChipValue()}\n onClearButtonClick={handleClearButtonClick}\n selectionType={selectionType}\n {...rest}\n testID={testID}\n ref={triggererRef as any}\n onKeyDown={handleKeyDown}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: getActionListContainerRole(hasFooterAction, 'FilterChipSelectInput'),\n expanded: isOpen,\n controls: `${dropdownBaseId}-actionlist`,\n activeDescendant: activeIndex >= 0 ? `${dropdownBaseId}-${activeIndex}` : undefined,\n }}\n onClick={(e) => {\n onTriggerClick();\n onClick?.(e);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n }}\n isDisabled={isDisabled}\n />\n );\n};\n\nconst FilterChipSelectInput = assignWithoutSideEffects(_FilterChipSelectInput, {\n componentId: dropdownComponentIds.triggers.FilterChipSelectInput,\n});\n\nexport { FilterChipSelectInput };\n"],"names":["this","_FilterChipSelectInput","props","_options$find$title","_options$find","idBase","useId","onClick","onBlur","onKeyDown","accessibilityLabel","testID","value","onClearButtonClick","label","onChange","name","isDisabled","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","uncontrolledInputValue","setUncontrolledInputValue","isFirstRender","useFirstRender","_useDropdown","useDropdown","options","selectedIndices","onTriggerClick","onTriggerKeydown","dropdownBaseId","isOpen","activeIndex","hasFooterAction","triggererRef","selectionType","isControlled","setSelectedIndices","controlledValueIndices","changeCallbackTriggerer","valueTitle","find","option","title","isUnControlled","length","undefined","_useListViewFilterCon","useListViewFilterContext","listViewSelectedFilters","setListViewSelectedFilters","_useFilterChipGroupCo","useFilterChipGroupContext","clearFilterCallbackTriggerer","setFilterChipGroupSelectedFilters","getValuesArrayFromIndices","indices","map","i","_options$i","filter","v","useEffect","valueNotEmpty","trim","Array","isArray","currentSelectedValues","_options$i2","isSingleValueSynced","isMultiValueSynced","every","includes","isValueAndSelectedIndicesSynced","savedIndices","inputValue","_options$i3","prev","concat","_toConsumableArray","newSelectedIndices","findIndex","index","getTitleFromValue","getUnControlledFilterChipValue","handleClearButtonClick","currentValues","values","_","updatedFilters","_toPropertyKey","isValueEmpty","Object","assign","_defineProperty","handleKeyDown","e","event","key","preventDefault","stopPropagation","_jsx","BaseFilterChip","ref","accessibilityProps","hasPopup","getActionListContainerRole","expanded","controls","activeDescendant","FilterChipSelectInput","assignWithoutSideEffects","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAA,SAAA,CAAA,CAAA,SAAA,CAAA,QAAA,CAAA,WAAA,CAAA,oBAAA,CAAA,QAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,OAAA,CAAA,UAAA,CAAA,MAAA,CAAA,YAAA,CAAA,CAAA,IAAA,KAAA,CAAAA,SAAA,CAAA,YAAA,CAAA,uGAAA,CAAA,SAAA,cAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,OAAA,QAAA,EAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,SAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,QAAA,EAAA,OAAA,CAAA,EAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,WAAA,CAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,GAAA,QAAA,EAAA,OAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,IAAA,SAAA,CAAA,8CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,QAAA,GAAA,CAAA,CAAA,MAAA,CAAA,MAAA,EAAA,CAAA,CAAA,CAAA,CAwBA,IAAMC,sBAAsB,CAAG,S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AAAV,MAAA,CAAAC,MAAA,EACbrF,KAAK,CAAEA,KAAM,CACbF,KAAK,CAAEkC,UAAU,OAAVA,UAAU,CAAI4C,8BAA8B,EAAG,CACtD7E,kBAAkB,CAAE8E,sBAAuB,CAC3ClD,aAAa,CAAEA,aAAc,EACzBvB,IAAI,CAAA,CACRP,MAAM,CAAEA,MAAO,CACfkG,GAAG,CAAErE,YAAoB,CACzB/B,SAAS,CAAE4F,aAAc,CACzBS,kBAAkB,CAAE,CAClBhG,KAAK,CAAEJ,kBAAkB,EAAA,IAAA,CAAlBA,kBAAkB,CAAII,KAAK,CAClCiG,QAAQ,CAAEC,0BAA0B,CAACzE,eAAe,CAAE,uBAAuB,CAAC,CAC9E0E,QAAQ,CAAE5E,MAAM,CAChB6E,QAAQ,CAAE,CAAA,EAAG9E,cAAc,CAAa,WAAA,CAAA,CACxC+E,gBAAgB,CAAE7E,WAAW,EAAI,CAAC,CAAG,CAAGF,EAAAA,cAAc,IAAIE,WAAW,CAAA,CAAE,CAAGc,SAC5E,CAAE,CACF7C,OAAO,CAAE,SAATA,OAAOA,CAAG+F,CAAC,CAAK,CACdpE,cAAc,EAAE,CAChB3B,QAAO,EAAPA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,QAAO,CAAG+F,CAAC,CAAC,CACd,CAAE,CACF9F,MAAM,CAAE,SAARA,MAAMA,CAAG8F,CAAC,CAAK,CACb9F,OAAM,EAAA,IAAA,CAAA,KAAA,CAAA,CAANA,OAAM,CAAG8F,CAAC,CAAC,CACb,CAAE,CACFrF,UAAU,CAAEA,UAAW,CAAA,CACxB,CAAC,CAEN,CAAC,CAEK,IAAAmG,qBAAqB,CAAGC,wBAAwB,CAACpH,sBAAsB,CAAE,CAC7EqH,WAAW,CAAEC,oBAAoB,CAACC,QAAQ,CAACJ,qBAC7C,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"FilterChipSelectInput.native.js","sources":["../../../../../src/components/Dropdown/FilterChipSelectInput.native.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\n\nimport React, { useEffect } from 'react';\nimport { useDropdown } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { getFilterChipDisplayValue } from './filterChipSelectInputUtils';\nimport { useFilterChipGroupContext } from './FilterChipGroupContext';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport { getActionListContainerRole } from '~components/ActionList/getA11yRoles';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\nimport { useId } from '~utils/useId';\nimport { useListViewFilterContext } from '~components/ListView/ListViewFiltersContext';\nimport { useFirstRender } from '~utils/useFirstRender';\n\ntype FilterChipSelectInputProps = Pick<\n BaseFilterChipProps,\n | 'onKeyDown'\n | 'value'\n | 'label'\n | 'testID'\n | 'onClick'\n | 'selectionType'\n | 'onBlur'\n | 'showClearButton'\n> & {\n accessibilityLabel?: string;\n onChange?: (props: { name: string; values: string[] }) => void;\n name?: string;\n onClearButtonClick?: (props: { name: string; values: string[] }) => void;\n isDisabled?: boolean;\n} & DataAnalyticsAttribute;\n\nconst _FilterChipSelectInput = (props: FilterChipSelectInputProps): React.ReactElement => {\n const idBase = useId('filter-chip-select-input');\n const {\n onClick,\n onBlur,\n onKeyDown,\n accessibilityLabel,\n testID,\n value,\n onClearButtonClick,\n label,\n onChange,\n name,\n isDisabled,\n showClearButton = true,\n ...rest\n } = props;\n const [uncontrolledInputValue, setUncontrolledInputValue] = React.useState<string[]>([]);\n const isFirstRender = useFirstRender();\n\n const {\n options,\n selectedIndices,\n onTriggerClick,\n onTriggerKeydown,\n dropdownBaseId,\n isOpen,\n activeIndex,\n hasFooterAction,\n triggererRef,\n selectionType,\n isControlled,\n setSelectedIndices,\n controlledValueIndices,\n changeCallbackTriggerer,\n } = useDropdown();\n const isUnControlled = options.length > 0 && props.value === undefined;\n const { listViewSelectedFilters, setListViewSelectedFilters } = useListViewFilterContext();\n const {\n clearFilterCallbackTriggerer,\n setFilterChipGroupSelectedFilters,\n } = useFilterChipGroupContext();\n\n const getValuesArrayFromIndices = (): string[] => {\n let indices: number[] = [];\n if (isControlled) {\n indices = controlledValueIndices;\n } else {\n indices = selectedIndices;\n }\n\n return indices.map((i) => options[i]?.value).filter((v): v is string => v !== undefined);\n };\n\n useEffect(() => {\n const valueNotEmpty =\n (typeof value === 'string' && value.trim() !== '') ||\n (Array.isArray(value) && value.length > 0);\n\n const currentSelectedValues = selectedIndices.map((i) => options[i]?.value);\n const isSingleValueSynced =\n typeof value === 'string' &&\n currentSelectedValues.length === 1 &&\n currentSelectedValues[0] === value;\n\n const isMultiValueSynced =\n Array.isArray(value) &&\n value.length === currentSelectedValues.length &&\n value.every((v) => currentSelectedValues.includes(v));\n\n const isValueAndSelectedIndicesSynced = isSingleValueSynced || isMultiValueSynced;\n\n if (isUnControlled) {\n if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n const inputValue = savedIndices\n .map((i) => options[i]?.value)\n .filter((v): v is string => v !== undefined);\n setUncontrolledInputValue(inputValue);\n setFilterChipGroupSelectedFilters((prev) =>\n prev.includes(label) ? prev : [...prev, label],\n );\n } else {\n setSelectedIndices([]);\n }\n } else if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n // An emptied value clears the selection too, so consumers can reset from outside the chip\n // (e.g. a Clear button in the dropdown footer)\n } else if (!isValueAndSelectedIndicesSynced && options.length > 0) {\n const newSelectedIndices = !valueNotEmpty\n ? []\n : options\n .map((option, index) => {\n const isSelected =\n typeof value === 'string'\n ? option.value === value\n : Array.isArray(value) && value.includes(option.value);\n return isSelected ? index : -1;\n })\n .filter((index) => index !== -1);\n setSelectedIndices(newSelectedIndices);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isUnControlled, options, value]);\n\n const handleClearButtonClick = (): void => {\n const currentValues = getValuesArrayFromIndices();\n onClearButtonClick?.({ name: name ?? idBase, values: currentValues });\n onChange?.({ name: name ?? idBase, values: [] });\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n setUncontrolledInputValue([]);\n setSelectedIndices([]);\n };\n\n useEffect(() => {\n if (clearFilterCallbackTriggerer) {\n handleClearButtonClick();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clearFilterCallbackTriggerer]);\n\n useEffect(() => {\n if (!isFirstRender) {\n props.onChange?.({\n name: props.name || idBase,\n values: getValuesArrayFromIndices(),\n });\n if (isUnControlled) {\n setUncontrolledInputValue(getValuesArrayFromIndices());\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n useEffect(() => {\n const isValueEmpty = selectedIndices.length === 0;\n if (!isFirstRender && !isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => (prev.includes(label) ? prev : [...prev, label]));\n setListViewSelectedFilters((prev) => ({\n ...prev,\n [label]: selectedIndices as number[],\n }));\n } else if (!isFirstRender && isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n const handleKeyDown = (e: React.KeyboardEvent<Element>): void => {\n onKeyDown?.(e);\n onTriggerKeydown?.({ event: e as React.KeyboardEvent<HTMLInputElement> });\n\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n }\n\n if ((e.key === 'Enter' || e.key === ' ') && !isOpen) {\n e.preventDefault();\n e.stopPropagation();\n onTriggerClick();\n }\n };\n\n return (\n <BaseFilterChip\n label={label}\n value={getFilterChipDisplayValue({\n value: props.value,\n options,\n selectionType,\n uncontrolledInputValue,\n })}\n onClearButtonClick={handleClearButtonClick}\n showClearButton={showClearButton}\n selectionType={selectionType}\n {...rest}\n testID={testID}\n ref={triggererRef as any}\n onKeyDown={handleKeyDown}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: getActionListContainerRole(hasFooterAction, 'FilterChipSelectInput'),\n expanded: isOpen,\n controls: `${dropdownBaseId}-actionlist`,\n activeDescendant: activeIndex >= 0 ? `${dropdownBaseId}-${activeIndex}` : undefined,\n }}\n onClick={(e) => {\n onTriggerClick();\n onClick?.(e);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n }}\n isDisabled={isDisabled}\n />\n );\n};\n\nconst FilterChipSelectInput = assignWithoutSideEffects(_FilterChipSelectInput, {\n componentId: dropdownComponentIds.triggers.FilterChipSelectInput,\n});\n\nexport { FilterChipSelectInput };\n"],"names":["this","_FilterChipSelectInput","props","idBase","useId","onClick","onBlur","onKeyDown","accessibilityLabel","testID","value","onClearButtonClick","label","onChange","name","isDisabled","_props$showClearButto","showClearButton","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","uncontrolledInputValue","setUncontrolledInputValue","isFirstRender","useFirstRender","_useDropdown","useDropdown","options","selectedIndices","onTriggerClick","onTriggerKeydown","dropdownBaseId","isOpen","activeIndex","hasFooterAction","triggererRef","selectionType","isControlled","setSelectedIndices","controlledValueIndices","changeCallbackTriggerer","isUnControlled","length","undefined","_useListViewFilterCon","useListViewFilterContext","listViewSelectedFilters","setListViewSelectedFilters","_useFilterChipGroupCo","useFilterChipGroupContext","clearFilterCallbackTriggerer","setFilterChipGroupSelectedFilters","getValuesArrayFromIndices","indices","map","i","_options$i","filter","v","useEffect","valueNotEmpty","trim","Array","isArray","currentSelectedValues","_options$i2","isSingleValueSynced","isMultiValueSynced","every","includes","isValueAndSelectedIndicesSynced","savedIndices","inputValue","_options$i3","prev","concat","_toConsumableArray","newSelectedIndices","option","index","isSelected","handleClearButtonClick","currentValues","values","_","updatedFilters","_toPropertyKey","isValueEmpty","Object","assign","_defineProperty","handleKeyDown","e","event","key","preventDefault","stopPropagation","_jsx","BaseFilterChip","getFilterChipDisplayValue","ref","accessibilityProps","hasPopup","getActionListContainerRole","expanded","controls","activeDescendant","FilterChipSelectInput","assignWithoutSideEffects","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,IAAA,SAAA,CAAA,CAAA,SAAA,CAAA,QAAA,CAAA,WAAA,CAAA,oBAAA,CAAA,QAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,OAAA,CAAA,UAAA,CAAA,MAAA,CAAA,YAAA,CAAA,iBAAA,CAAA,CAAA,IAAA,KAAA,CAAAA,SAAA,CAAA,YAAA,CAAA,uGAAA,CAAA,SAAA,cAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,OAAA,QAAA,EAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,SAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,QAAA,EAAA,OAAA,CAAA,EAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,WAAA,CAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,GAAA,QAAA,EAAA,OAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,IAAA,SAAA,CAAA,8CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,QAAA,GAAA,CAAA,CAAA,MAAA,CAAA,MAAA,EAAA,CAAA,CAAA,CAAA,CAgCA,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M,CAChByE,QAAQ,CAAE,CAAA,EAAG1E,cAAc,CAAa,WAAA,CAAA,CACxC2E,gBAAgB,CAAEzE,WAAW,EAAI,CAAC,CAAG,CAAA,EAAGF,cAAc,CAAIE,CAAAA,EAAAA,WAAW,CAAE,CAAA,CAAGU,SAC5E,CAAE,CACF3C,OAAO,CAAE,SAATA,OAAOA,CAAG4F,CAAC,CAAK,CACd/D,cAAc,EAAE,CAChB7B,QAAO,EAAPA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,QAAO,CAAG4F,CAAC,CAAC,CACd,CAAE,CACF3F,MAAM,CAAE,SAARA,MAAMA,CAAG2F,CAAC,CAAK,CACb3F,OAAM,EAANA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,OAAM,CAAG2F,CAAC,CAAC,CACb,CAAE,CACFlF,UAAU,CAAEA,UAAW,CACxB,CAAA,CAAC,CAEN,CAAC,CAEK,IAAAiG,qBAAqB,CAAGC,wBAAwB,CAAChH,sBAAsB,CAAE,CAC7EiH,WAAW,CAAEC,oBAAoB,CAACC,QAAQ,CAACJ,qBAC7C,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import { dropdownComponentIds } from './dropdownComponentIds.js';
|
|
3
3
|
|
|
4
|
-
var SelectActions={Close:'Close',CloseSelect:'CloseSelect',First:'First',Last:'Last',Next:'Next',Open:'Open',PageDown:'PageDown',PageUp:'PageUp',Previous:'Previous',Select:'Select',Type:'Type'};function filterOptions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var filter=arguments.length>1?arguments[1]:undefined;var exclude=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];return options.filter(function(option){var matches=String(option).toLowerCase().startsWith(filter.toLowerCase());return matches&&!exclude.includes(option);});}function getActionFromKey(e,isOpen,dropdownTriggerer){if(!e){return undefined;}var altKey=e.altKey,ctrlKey=e.ctrlKey,metaKey=e.metaKey;var key='';if('key'in e){key=e.key;}var openKeys=['ArrowDown','ArrowUp','Enter',' '];if(!key)return undefined;if(!isOpen&&key&&openKeys.includes(key)){return SelectActions.Open;}if(key==='Home'){return SelectActions.First;}if(key==='End'){return SelectActions.Last;}if(key==='Backspace'||key==='Clear'||key.length===1&&key!==' '&&!altKey&&!ctrlKey&&!metaKey){return SelectActions.Type;}if(isOpen){if(key==='ArrowUp'&&altKey){return SelectActions.CloseSelect;}else if(key==='ArrowDown'&&!altKey){return SelectActions.Next;}else if(key==='ArrowUp'){return SelectActions.Previous;}else if(key==='PageUp'){return SelectActions.PageUp;}else if(key==='PageDown'){return SelectActions.PageDown;}else if(key==='Escape'){return SelectActions.Close;}else if(key==='Enter'||dropdownTriggerer!==dropdownComponentIds.triggers.AutoComplete&&dropdownTriggerer!==dropdownComponentIds.triggers.SearchInput&&key===' '){return SelectActions.CloseSelect;}}return undefined;}function getIndexByLetter(options,filter){var startIndex=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var orderedOptions=[].concat(_toConsumableArray(options.slice(startIndex)),_toConsumableArray(options.slice(0,startIndex)));var firstMatch=filterOptions(orderedOptions,filter)[0];var allSameLetter=function allSameLetter(array){return array.every(function(letter){return letter===array[0];});};if(firstMatch){return options.indexOf(firstMatch);}else if(allSameLetter(filter.split(''))){var matches=filterOptions(orderedOptions,filter[0]);return options.indexOf(matches[0]);}else {return -1;}}function getUpdatedIndex(_ref){var currentIndex=_ref.currentIndex,maxIndex=_ref.maxIndex,actionType=_ref.actionType;var pageSize=10;switch(actionType){case SelectActions.First:return 0;case SelectActions.Last:return maxIndex;case SelectActions.Previous:return Math.max(0,currentIndex-1);case SelectActions.Next:return Math.min(maxIndex,currentIndex+1);case SelectActions.PageUp:return Math.max(0,currentIndex-pageSize);case SelectActions.PageDown:return Math.min(maxIndex,currentIndex+pageSize);default:return currentIndex;}}function isElementVisibleOnScreen(element){var bounding=element.getBoundingClientRect();return bounding.top>=0&&bounding.left>=0&&bounding.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&bounding.right<=(window.innerWidth||document.documentElement.clientWidth);}function isElementVisible(container,element){var containerRect=container.getBoundingClientRect();var elementRect=element.getBoundingClientRect();var isVerticalVisible=elementRect.top>=containerRect.top&&elementRect.bottom<=containerRect.bottom;return isVerticalVisible;}function isScrollable(element){return element&&element.clientHeight<element.scrollHeight;}var performAction=function performAction(action,payload,actions){var event=payload.event;switch(action){case SelectActions.Last:case SelectActions.First:actions.setIsOpen(true);case SelectActions.Next:case SelectActions.Previous:case SelectActions.PageUp:case SelectActions.PageDown:event.preventDefault();actions.onOptionChange(action);return true;case SelectActions.CloseSelect:event.preventDefault();actions.selectCurrentOption();return true;case SelectActions.Close:event.preventDefault();actions.close();return true;case SelectActions.Type:actions.onComboType(event.key,action);return true;case SelectActions.Open:event.preventDefault();actions.setIsOpen(true);return true;default:break;}return false;};var ensureScrollVisiblity=function ensureScrollVisiblity(newActiveIndex,containerElement,options){if(containerElement){if(isScrollable(containerElement)){var optionEl=containerElement.querySelectorAll('[role="option"], [role="menuitem"]');if(newActiveIndex>=0&&optionEl[newActiveIndex].dataset.value===options[newActiveIndex]){var activeElement=optionEl[newActiveIndex];if(!isElementVisible(containerElement,activeElement)){activeElement.scrollIntoView({inline:'nearest'});}if(!isElementVisibleOnScreen(optionEl[newActiveIndex])){activeElement.scrollIntoView({behavior:'smooth'});}}}}};var makeInputValue=function makeInputValue(selectedIndices,options){if(options.length===0){return '';}return selectedIndices.map(function(selectedIndex){var _options$selectedInde;return (_options$selectedInde=options[selectedIndex])==null?void 0:_options$selectedInde.value;}).join(', ');};var makeInputDisplayValue=function makeInputDisplayValue(selectedIndices,options){if(options.length===0||selectedIndices.length===0){return '';}if(selectedIndices.length===1){var _options$selectedIndi;return (_options$selectedIndi=options[selectedIndices[0]])==null?void 0:_options$selectedIndi.title;}return `${selectedIndices.length} items selected`;};
|
|
4
|
+
var SelectActions={Close:'Close',CloseSelect:'CloseSelect',Expand:'Expand',Collapse:'Collapse',First:'First',Last:'Last',Next:'Next',Open:'Open',PageDown:'PageDown',PageUp:'PageUp',Previous:'Previous',Select:'Select',Type:'Type'};function filterOptions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var filter=arguments.length>1?arguments[1]:undefined;var exclude=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];return options.filter(function(option){var matches=String(option).toLowerCase().startsWith(filter.toLowerCase());return matches&&!exclude.includes(option);});}function getActionFromKey(e,isOpen,dropdownTriggerer){if(!e){return undefined;}var altKey=e.altKey,ctrlKey=e.ctrlKey,metaKey=e.metaKey;var key='';if('key'in e){key=e.key;}var openKeys=['ArrowDown','ArrowUp','Enter',' '];if(!key)return undefined;if(!isOpen&&key&&openKeys.includes(key)){return SelectActions.Open;}if(key==='Home'){return SelectActions.First;}if(key==='End'){return SelectActions.Last;}if(key==='Backspace'||key==='Clear'||key.length===1&&key!==' '&&!altKey&&!ctrlKey&&!metaKey){return SelectActions.Type;}if(isOpen){if(key==='ArrowUp'&&altKey){return SelectActions.CloseSelect;}else if(key==='ArrowDown'&&!altKey){return SelectActions.Next;}else if(key==='ArrowUp'){return SelectActions.Previous;}else if(key==='ArrowRight'&&!altKey){return SelectActions.Expand;}else if(key==='ArrowLeft'&&!altKey){return SelectActions.Collapse;}else if(key==='PageUp'){return SelectActions.PageUp;}else if(key==='PageDown'){return SelectActions.PageDown;}else if(key==='Escape'){return SelectActions.Close;}else if(key==='Enter'||dropdownTriggerer!==dropdownComponentIds.triggers.AutoComplete&&dropdownTriggerer!==dropdownComponentIds.triggers.SearchInput&&key===' '){return SelectActions.CloseSelect;}}return undefined;}function getIndexByLetter(options,filter){var startIndex=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var orderedOptions=[].concat(_toConsumableArray(options.slice(startIndex)),_toConsumableArray(options.slice(0,startIndex)));var firstMatch=filterOptions(orderedOptions,filter)[0];var allSameLetter=function allSameLetter(array){return array.every(function(letter){return letter===array[0];});};if(firstMatch){return options.indexOf(firstMatch);}else if(allSameLetter(filter.split(''))){var matches=filterOptions(orderedOptions,filter[0]);return options.indexOf(matches[0]);}else {return -1;}}function getUpdatedIndex(_ref){var currentIndex=_ref.currentIndex,maxIndex=_ref.maxIndex,actionType=_ref.actionType;var pageSize=10;switch(actionType){case SelectActions.First:return 0;case SelectActions.Last:return maxIndex;case SelectActions.Previous:return Math.max(0,currentIndex-1);case SelectActions.Next:return Math.min(maxIndex,currentIndex+1);case SelectActions.PageUp:return Math.max(0,currentIndex-pageSize);case SelectActions.PageDown:return Math.min(maxIndex,currentIndex+pageSize);default:return currentIndex;}}function isElementVisibleOnScreen(element){var bounding=element.getBoundingClientRect();return bounding.top>=0&&bounding.left>=0&&bounding.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&bounding.right<=(window.innerWidth||document.documentElement.clientWidth);}function isElementVisible(container,element){var containerRect=container.getBoundingClientRect();var elementRect=element.getBoundingClientRect();var isVerticalVisible=elementRect.top>=containerRect.top&&elementRect.bottom<=containerRect.bottom;return isVerticalVisible;}function isScrollable(element){return element&&element.clientHeight<element.scrollHeight;}var performAction=function performAction(action,payload,actions){var event=payload.event;switch(action){case SelectActions.Last:case SelectActions.First:actions.setIsOpen(true);case SelectActions.Next:case SelectActions.Previous:case SelectActions.PageUp:case SelectActions.PageDown:event.preventDefault();actions.onOptionChange(action);return true;case SelectActions.CloseSelect:event.preventDefault();actions.selectCurrentOption(event);return true;case SelectActions.Expand:case SelectActions.Collapse:if(actions.onTreeExpandCollapse){event.preventDefault();actions.onTreeExpandCollapse(action);return true;}return false;case SelectActions.Close:event.preventDefault();actions.close();return true;case SelectActions.Type:actions.onComboType(event.key,action);return true;case SelectActions.Open:event.preventDefault();actions.setIsOpen(true);return true;default:break;}return false;};var ensureScrollVisiblity=function ensureScrollVisiblity(newActiveIndex,containerElement,options){if(containerElement){if(isScrollable(containerElement)){var optionEl=containerElement.querySelectorAll('[role="option"], [role="menuitem"]');if(newActiveIndex>=0&&optionEl[newActiveIndex].dataset.value===options[newActiveIndex]){var activeElement=optionEl[newActiveIndex];if(!isElementVisible(containerElement,activeElement)){activeElement.scrollIntoView({inline:'nearest'});}if(!isElementVisibleOnScreen(optionEl[newActiveIndex])){activeElement.scrollIntoView({behavior:'smooth'});}}}}};var makeInputValue=function makeInputValue(selectedIndices,options){if(options.length===0){return '';}return selectedIndices.map(function(selectedIndex){var _options$selectedInde;return (_options$selectedInde=options[selectedIndex])==null?void 0:_options$selectedInde.value;}).join(', ');};var makeInputDisplayValue=function makeInputDisplayValue(selectedIndices,options,displayOverride){if(displayOverride&&selectedIndices.length>0){if(displayOverride.count===1){return displayOverride.label;}return `${displayOverride.count} items selected`;}if(options.length===0||selectedIndices.length===0){return '';}if(selectedIndices.length===1){var _options$selectedIndi;return (_options$selectedIndi=options[selectedIndices[0]])==null?void 0:_options$selectedIndi.title;}return `${selectedIndices.length} items selected`;};
|
|
5
5
|
|
|
6
6
|
export { ensureScrollVisiblity, filterOptions, getActionFromKey, getIndexByLetter, getUpdatedIndex, isElementVisibleOnScreen, isScrollable, makeInputDisplayValue, makeInputValue, performAction };
|
|
7
7
|
//# sourceMappingURL=dropdownUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdownUtils.js","sources":["../../../../../src/components/Dropdown/dropdownUtils.ts"],"sourcesContent":["/*\n * This content is licensed according to the W3C Software License at\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n *\n * This software or document includes material copied from or derived from\n * https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html.\n * Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang)\n */\n\nimport type { DropdownContextType, OptionsType } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { SpacingValueType } from '~components/Box/BaseBox';\n\nexport type SelectActionsType =\n | 'Close'\n | 'CloseSelect'\n | 'First'\n | 'Last'\n | 'Next'\n | 'Open'\n | 'PageDown'\n | 'PageUp'\n | 'Previous'\n | 'Select'\n | 'Type';\n\n// Save a list of named combobox actions, for future readability\nconst SelectActions: Record<SelectActionsType, SelectActionsType> = {\n Close: 'Close',\n CloseSelect: 'CloseSelect',\n First: 'First',\n Last: 'Last',\n Next: 'Next',\n Open: 'Open',\n PageDown: 'PageDown',\n PageUp: 'PageUp',\n Previous: 'Previous',\n Select: 'Select',\n Type: 'Type',\n};\n\n/**\n * Filter an array of options against an input string\n * returns an array of options that begin with the filter string, case-independent\n *\n */\nexport function filterOptions(\n options: string[] = [],\n filter: string,\n exclude: string[] = [],\n): string[] {\n return options.filter((option) => {\n const matches = String(option).toLowerCase().startsWith(filter.toLowerCase());\n return matches && !exclude.includes(option);\n });\n}\n\n/**\n * Map a keypress to action\n */\nexport function getActionFromKey(\n e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n isOpen: boolean,\n dropdownTriggerer: DropdownContextType['dropdownTriggerer'],\n): SelectActionsType | undefined {\n if (!e) {\n return undefined;\n }\n\n const { altKey, ctrlKey, metaKey } = e;\n let key = '';\n if ('key' in e) {\n key = e.key;\n }\n const openKeys = ['ArrowDown', 'ArrowUp', 'Enter', ' ']; // all keys that will do the default open action\n if (!key) return undefined;\n // handle opening when closed\n if (!isOpen && key && openKeys.includes(key)) {\n return SelectActions.Open;\n }\n\n // home and end move the selected option when open or closed\n if (key === 'Home') {\n return SelectActions.First;\n }\n if (key === 'End') {\n return SelectActions.Last;\n }\n\n // handle typing characters when open or closed\n if (\n key === 'Backspace' ||\n key === 'Clear' ||\n (key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey)\n ) {\n return SelectActions.Type;\n }\n\n // handle keys when open\n if (isOpen) {\n if (key === 'ArrowUp' && altKey) {\n return SelectActions.CloseSelect;\n } else if (key === 'ArrowDown' && !altKey) {\n return SelectActions.Next;\n } else if (key === 'ArrowUp') {\n return SelectActions.Previous;\n } else if (key === 'PageUp') {\n return SelectActions.PageUp;\n } else if (key === 'PageDown') {\n return SelectActions.PageDown;\n } else if (key === 'Escape') {\n return SelectActions.Close;\n } else if (\n key === 'Enter' ||\n // we ignore the spacebar select in autocomplete since hitting spacebar might be expected while typing\n (dropdownTriggerer !== dropdownComponentIds.triggers.AutoComplete &&\n dropdownTriggerer !== dropdownComponentIds.triggers.SearchInput &&\n key === ' ')\n ) {\n return SelectActions.CloseSelect;\n }\n }\n\n return undefined;\n}\n\n/**\n * Return the index of an option from an array of options, based on a search string\n *\n * if the filter is multiple iterations of the same letter (e.g \"aaa\"), then cycle through first-letter matches\n **/\nexport function getIndexByLetter(options: string[], filter: string, startIndex = 0): number {\n const orderedOptions = [...options.slice(startIndex), ...options.slice(0, startIndex)];\n const firstMatch = filterOptions(orderedOptions, filter)[0];\n const allSameLetter = (array: string[]): boolean => array.every((letter) => letter === array[0]);\n\n // first check if there is an exact match for the typed string\n if (firstMatch) {\n return options.indexOf(firstMatch);\n }\n\n // if the same letter is being repeated, cycle through first-letter matches\n else if (allSameLetter(filter.split(''))) {\n const matches = filterOptions(orderedOptions, filter[0]);\n return options.indexOf(matches[0]);\n }\n\n // if no matches, return -1\n else {\n return -1;\n }\n}\n\n/**\n * This functions makes sure the optionsIndex is not going out of possible options\n */\nexport function getUpdatedIndex({\n currentIndex,\n maxIndex,\n actionType,\n}: {\n currentIndex: number;\n maxIndex: number;\n actionType: SelectActionsType;\n}): number {\n // On PageUP or PageDown, we jump focus by 10 items or to the first or last element\n // Details: https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html#:~:text=PageUp,to%20last%20option).\n const pageSize = 10;\n\n switch (actionType) {\n case SelectActions.First:\n return 0;\n case SelectActions.Last:\n return maxIndex;\n case SelectActions.Previous:\n return Math.max(0, currentIndex - 1);\n case SelectActions.Next:\n return Math.min(maxIndex, currentIndex + 1);\n case SelectActions.PageUp:\n return Math.max(0, currentIndex - pageSize);\n case SelectActions.PageDown:\n return Math.min(maxIndex, currentIndex + pageSize);\n default:\n return currentIndex;\n }\n}\n\n/**\n * Checks if the given HTML element is visible on screen\n */\nexport function isElementVisibleOnScreen(element: HTMLElement): boolean {\n const bounding = element.getBoundingClientRect();\n\n return (\n bounding.top >= 0 &&\n bounding.left >= 0 &&\n bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\n bounding.right <= (window.innerWidth || document.documentElement.clientWidth)\n );\n}\n\n/**\n * Checks if element is visible inside the given container\n */\nfunction isElementVisible(container: HTMLElement, element: HTMLElement): boolean {\n const containerRect = container.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n const isVerticalVisible =\n elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;\n\n return isVerticalVisible;\n}\n\n/**\n * Checks if the dropdown is scrollable\n */\nexport function isScrollable(element: HTMLElement): boolean {\n return element && element.clientHeight < element.scrollHeight;\n}\n\ntype ActionsType = {\n setIsOpen: DropdownContextType['setIsOpen'];\n close: DropdownContextType['close'];\n selectCurrentOption: () => void;\n onOptionChange: (action: SelectActionsType) => void;\n onComboType: (letter: string, action: SelectActionsType) => void;\n};\n/**\n * Performs the action when actionType is passed\n *\n * This function handles all the keydown actions.\n */\nexport const performAction = (\n action: SelectActionsType,\n payload: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n },\n actions: ActionsType,\n): boolean => {\n const { event } = payload;\n\n switch (action) {\n case SelectActions.Last:\n // @ts-expect-error: intentional fallthrough, ignoring the warning\n case SelectActions.First:\n actions.setIsOpen(true);\n // intentional fallthrough\n case SelectActions.Next:\n case SelectActions.Previous:\n case SelectActions.PageUp:\n case SelectActions.PageDown:\n event.preventDefault();\n actions.onOptionChange(action);\n return true;\n case SelectActions.CloseSelect:\n event.preventDefault();\n actions.selectCurrentOption();\n return true;\n case SelectActions.Close:\n event.preventDefault();\n actions.close();\n return true;\n case SelectActions.Type:\n actions.onComboType(event.key, action);\n return true;\n case SelectActions.Open:\n event.preventDefault();\n actions.setIsOpen(true);\n return true;\n\n default:\n break;\n }\n\n return false;\n};\n\n/**\n * When options list is large, it can have a scrollbar.\n *\n * This function ensures the active option is always in the viewport\n */\nexport const ensureScrollVisiblity = (\n newActiveIndex: number,\n containerElement: HTMLElement | null,\n options: string[],\n): void => {\n // ensure the new option is in view\n if (containerElement) {\n if (isScrollable(containerElement)) {\n const optionEl = containerElement.querySelectorAll<HTMLElement>(\n '[role=\"option\"], [role=\"menuitem\"]',\n );\n // Making sure its the same element as the one from options state\n if (\n newActiveIndex >= 0 &&\n optionEl[newActiveIndex].dataset.value === options[newActiveIndex]\n ) {\n const activeElement = optionEl[newActiveIndex];\n\n if (!isElementVisible(containerElement, activeElement)) {\n activeElement.scrollIntoView({ inline: 'nearest' });\n }\n\n if (!isElementVisibleOnScreen(optionEl[newActiveIndex])) {\n activeElement.scrollIntoView({ behavior: 'smooth' });\n }\n }\n }\n }\n};\n\n/**\n * value that is set in the actual form input\n */\nexport const makeInputValue = (selectedIndices: number[], options: OptionsType): string => {\n if (options.length === 0) {\n return '';\n }\n return selectedIndices.map((selectedIndex) => options[selectedIndex]?.value).join(', ');\n};\n\n/**\n * Value that is displayed inside the select field\n */\nexport const makeInputDisplayValue = (selectedIndices: number[], options: OptionsType): string => {\n // When no item is selected or no item is present\n if (options.length === 0 || selectedIndices.length === 0) {\n return '';\n }\n\n // When one item is selected, we display that item's title in input\n if (selectedIndices.length === 1) {\n return options[selectedIndices[0]]?.title;\n }\n\n // When more than one item is selected, we display the count of items\n return `${selectedIndices.length} items selected`;\n};\n\nexport type DropdownPosition = {\n top?: SpacingValueType;\n bottom?: SpacingValueType;\n left?: SpacingValueType;\n right?: SpacingValueType;\n};\n"],"names":["SelectActions","Close","CloseSelect","First","Last","Next","Open","PageDown","PageUp","Previous","Select","Type","filterOptions","options","arguments","length","undefined","filter","exclude","option","matches","String","toLowerCase","startsWith","includes","getActionFromKey","e","isOpen","dropdownTriggerer","altKey","ctrlKey","metaKey","key","openKeys","dropdownComponentIds","triggers","AutoComplete","SearchInput","getIndexByLetter","startIndex","orderedOptions","concat","_toConsumableArray","slice","firstMatch","allSameLetter","array","every","letter","indexOf","split","getUpdatedIndex","_ref","currentIndex","maxIndex","actionType","pageSize","Math","max","min","isElementVisibleOnScreen","element","bounding","getBoundingClientRect","top","left","bottom","window","innerHeight","document","documentElement","clientHeight","right","innerWidth","clientWidth","isElementVisible","container","containerRect","elementRect","isVerticalVisible","isScrollable","scrollHeight","performAction","action","payload","actions","event","setIsOpen","preventDefault","onOptionChange","selectCurrentOption","close","onComboType","ensureScrollVisiblity","newActiveIndex","containerElement","optionEl","querySelectorAll","dataset","value","activeElement","scrollIntoView","inline","behavior","makeInputValue","selectedIndices","map","selectedIndex","_options$selectedInde","join","makeInputDisplayValue","_options$selectedIndi","title"],"mappings":";;;AA2BA,IAAMA,aAA2D,CAAG,CAClEC,KAAK,CAAE,OAAO,CACdC,WAAW,CAAE,aAAa,CAC1BC,KAAK,CAAE,OAAO,CACdC,IAAI,CAAE,MAAM,CACZC,IAAI,CAAE,MAAM,CACZC,IAAI,CAAE,MAAM,CACZC,QAAQ,CAAE,UAAU,CACpBC,MAAM,CAAE,QAAQ,CAChBC,QAAQ,CAAE,UAAU,CACpBC,MAAM,CAAE,QAAQ,CAChBC,IAAI,CAAE,MACR,CAAC,CAOe,SAAAC,aAAaA,EAIjB,CAHV,IAAAC,OAAiB,CAAAC,SAAA,CAAAC,MAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,GAAAE,SAAA,CAAAF,SAAA,CAAG,CAAA,CAAA,CAAA,EAAE,KACtBG,MAAc,CAAAH,SAAA,CAAAC,MAAA,CAAA,CAAA,CAAAD,SAAA,CAAAE,CAAAA,CAAAA,CAAAA,SAAA,CACd,IAAAE,OAAiB,CAAAJ,SAAA,CAAAC,MAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,GAAAE,SAAA,CAAAF,SAAA,CAAG,CAAA,CAAA,CAAA,EAAE,CAEtB,OAAOD,OAAO,CAACI,MAAM,CAAC,SAACE,MAAM,CAAK,CAChC,IAAMC,OAAO,CA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CAAC,CAAEC,MAAM,CAAE,SAAU,CAAC,CAAC,CACrD,CAEA,GAAI,CAAC1C,wBAAwB,CAACoC,QAAQ,CAACF,cAAc,CAAC,CAAC,CAAE,CACvDM,aAAa,CAACC,cAAc,CAAC,CAAEE,QAAQ,CAAE,QAAS,CAAC,CAAC,CACtD,CACF,CACF,CACF,CACF,EAKa,IAAAC,cAAc,CAAG,SAAjBA,cAAcA,CAAIC,eAAyB,CAAE5F,OAAoB,CAAa,CACzF,GAAIA,OAAO,CAACE,MAAM,GAAK,CAAC,CAAE,CACxB,OAAO,EAAE,CACX,CACA,OAAO0F,eAAe,CAACC,GAAG,CAAC,SAACC,aAAa,CAAA,CAAA,IAAAC,qBAAA,CAAAA,OAAAA,CAAAA,qBAAA,CAAK/F,OAAO,CAAC8F,aAAa,CAAC,eAAtBC,qBAAA,CAAwBT,KAAK,CAAA,CAAA,CAAC,CAACU,IAAI,CAAC,IAAI,CAAC,CACzF,EAKa,IAAAC,qBAAqB,CAAG,SAAxBA,qBAAqBA,CAAIL,eAAyB,CAAE5F,OAAoB,CAAa,CAEhG,GAAIA,OAAO,CAACE,MAAM,GAAK,CAAC,EAAI0F,eAAe,CAAC1F,MAAM,GAAK,CAAC,CAAE,CACxD,OAAO,EAAE,CACX,CAGA,GAAI0F,eAAe,CAAC1F,MAAM,GAAK,CAAC,CAAE,CAAAgG,IAAAA,qBAAA,CAChC,OAAA,CAAAA,qBAAA,CAAOlG,OAAO,CAAC4F,eAAe,CAAC,CAAC,CAAC,CAAC,GAAA,IAAA,CAAA,KAAA,CAAA,CAA3BM,qBAAA,CAA6BC,KAAK,CAC3C,CAGA,OAAO,CAAGP,EAAAA,eAAe,CAAC1F,MAAM,CAAA,eAAA,CAAiB,CACnD;;;;"}
|
|
1
|
+
{"version":3,"file":"dropdownUtils.js","sources":["../../../../../src/components/Dropdown/dropdownUtils.ts"],"sourcesContent":["/*\n * This content is licensed according to the W3C Software License at\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n *\n * This software or document includes material copied from or derived from\n * https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html.\n * Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang)\n */\n\nimport type { DropdownContextType, OptionsType } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { SpacingValueType } from '~components/Box/BaseBox';\n\nexport type SelectActionsType =\n | 'Close'\n | 'CloseSelect'\n | 'Expand'\n | 'Collapse'\n | 'First'\n | 'Last'\n | 'Next'\n | 'Open'\n | 'PageDown'\n | 'PageUp'\n | 'Previous'\n | 'Select'\n | 'Type';\n\n// Save a list of named combobox actions, for future readability\nconst SelectActions: Record<SelectActionsType, SelectActionsType> = {\n Close: 'Close',\n CloseSelect: 'CloseSelect',\n // Expand / Collapse are only acted upon when overlay content is a TreeView (see performAction)\n Expand: 'Expand',\n Collapse: 'Collapse',\n First: 'First',\n Last: 'Last',\n Next: 'Next',\n Open: 'Open',\n PageDown: 'PageDown',\n PageUp: 'PageUp',\n Previous: 'Previous',\n Select: 'Select',\n Type: 'Type',\n};\n\n/**\n * Filter an array of options against an input string\n * returns an array of options that begin with the filter string, case-independent\n *\n */\nexport function filterOptions(\n options: string[] = [],\n filter: string,\n exclude: string[] = [],\n): string[] {\n return options.filter((option) => {\n const matches = String(option).toLowerCase().startsWith(filter.toLowerCase());\n return matches && !exclude.includes(option);\n });\n}\n\n/**\n * Map a keypress to action\n */\nexport function getActionFromKey(\n e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n isOpen: boolean,\n dropdownTriggerer: DropdownContextType['dropdownTriggerer'],\n): SelectActionsType | undefined {\n if (!e) {\n return undefined;\n }\n\n const { altKey, ctrlKey, metaKey } = e;\n let key = '';\n if ('key' in e) {\n key = e.key;\n }\n const openKeys = ['ArrowDown', 'ArrowUp', 'Enter', ' ']; // all keys that will do the default open action\n if (!key) return undefined;\n // handle opening when closed\n if (!isOpen && key && openKeys.includes(key)) {\n return SelectActions.Open;\n }\n\n // home and end move the selected option when open or closed\n if (key === 'Home') {\n return SelectActions.First;\n }\n if (key === 'End') {\n return SelectActions.Last;\n }\n\n // handle typing characters when open or closed\n if (\n key === 'Backspace' ||\n key === 'Clear' ||\n (key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey)\n ) {\n return SelectActions.Type;\n }\n\n // handle keys when open\n if (isOpen) {\n if (key === 'ArrowUp' && altKey) {\n return SelectActions.CloseSelect;\n } else if (key === 'ArrowDown' && !altKey) {\n return SelectActions.Next;\n } else if (key === 'ArrowUp') {\n return SelectActions.Previous;\n } else if (key === 'ArrowRight' && !altKey) {\n // acted upon only when overlay content is a TreeView (no-op otherwise, see performAction)\n return SelectActions.Expand;\n } else if (key === 'ArrowLeft' && !altKey) {\n return SelectActions.Collapse;\n } else if (key === 'PageUp') {\n return SelectActions.PageUp;\n } else if (key === 'PageDown') {\n return SelectActions.PageDown;\n } else if (key === 'Escape') {\n return SelectActions.Close;\n } else if (\n key === 'Enter' ||\n // we ignore the spacebar select in autocomplete since hitting spacebar might be expected while typing\n (dropdownTriggerer !== dropdownComponentIds.triggers.AutoComplete &&\n dropdownTriggerer !== dropdownComponentIds.triggers.SearchInput &&\n key === ' ')\n ) {\n return SelectActions.CloseSelect;\n }\n }\n\n return undefined;\n}\n\n/**\n * Return the index of an option from an array of options, based on a search string\n *\n * if the filter is multiple iterations of the same letter (e.g \"aaa\"), then cycle through first-letter matches\n **/\nexport function getIndexByLetter(options: string[], filter: string, startIndex = 0): number {\n const orderedOptions = [...options.slice(startIndex), ...options.slice(0, startIndex)];\n const firstMatch = filterOptions(orderedOptions, filter)[0];\n const allSameLetter = (array: string[]): boolean => array.every((letter) => letter === array[0]);\n\n // first check if there is an exact match for the typed string\n if (firstMatch) {\n return options.indexOf(firstMatch);\n }\n\n // if the same letter is being repeated, cycle through first-letter matches\n else if (allSameLetter(filter.split(''))) {\n const matches = filterOptions(orderedOptions, filter[0]);\n return options.indexOf(matches[0]);\n }\n\n // if no matches, return -1\n else {\n return -1;\n }\n}\n\n/**\n * This functions makes sure the optionsIndex is not going out of possible options\n */\nexport function getUpdatedIndex({\n currentIndex,\n maxIndex,\n actionType,\n}: {\n currentIndex: number;\n maxIndex: number;\n actionType: SelectActionsType;\n}): number {\n // On PageUP or PageDown, we jump focus by 10 items or to the first or last element\n // Details: https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html#:~:text=PageUp,to%20last%20option).\n const pageSize = 10;\n\n switch (actionType) {\n case SelectActions.First:\n return 0;\n case SelectActions.Last:\n return maxIndex;\n case SelectActions.Previous:\n return Math.max(0, currentIndex - 1);\n case SelectActions.Next:\n return Math.min(maxIndex, currentIndex + 1);\n case SelectActions.PageUp:\n return Math.max(0, currentIndex - pageSize);\n case SelectActions.PageDown:\n return Math.min(maxIndex, currentIndex + pageSize);\n default:\n return currentIndex;\n }\n}\n\n/**\n * Checks if the given HTML element is visible on screen\n */\nexport function isElementVisibleOnScreen(element: HTMLElement): boolean {\n const bounding = element.getBoundingClientRect();\n\n return (\n bounding.top >= 0 &&\n bounding.left >= 0 &&\n bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\n bounding.right <= (window.innerWidth || document.documentElement.clientWidth)\n );\n}\n\n/**\n * Checks if element is visible inside the given container\n */\nfunction isElementVisible(container: HTMLElement, element: HTMLElement): boolean {\n const containerRect = container.getBoundingClientRect();\n const elementRect = element.getBoundingClientRect();\n\n const isVerticalVisible =\n elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;\n\n return isVerticalVisible;\n}\n\n/**\n * Checks if the dropdown is scrollable\n */\nexport function isScrollable(element: HTMLElement): boolean {\n return element && element.clientHeight < element.scrollHeight;\n}\n\ntype ActionsType = {\n setIsOpen: DropdownContextType['setIsOpen'];\n close: DropdownContextType['close'];\n selectCurrentOption: (event?: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>) => void;\n onOptionChange: (action: SelectActionsType) => void;\n onComboType: (letter: string, action: SelectActionsType) => void;\n /**\n * Present only when overlay content is a TreeView. When absent, Expand / Collapse\n * actions are ignored without preventing default (ArrowLeft / ArrowRight keep their\n * existing behaviour for ActionList, AutoComplete, and other content)\n */\n onTreeExpandCollapse?: (action: SelectActionsType) => void;\n};\n/**\n * Performs the action when actionType is passed\n *\n * This function handles all the keydown actions.\n */\nexport const performAction = (\n action: SelectActionsType,\n payload: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n },\n actions: ActionsType,\n): boolean => {\n const { event } = payload;\n\n switch (action) {\n case SelectActions.Last:\n // @ts-expect-error: intentional fallthrough, ignoring the warning\n case SelectActions.First:\n actions.setIsOpen(true);\n // intentional fallthrough\n case SelectActions.Next:\n case SelectActions.Previous:\n case SelectActions.PageUp:\n case SelectActions.PageDown:\n event.preventDefault();\n actions.onOptionChange(action);\n return true;\n case SelectActions.CloseSelect:\n event.preventDefault();\n actions.selectCurrentOption(event);\n return true;\n case SelectActions.Expand:\n case SelectActions.Collapse:\n if (actions.onTreeExpandCollapse) {\n event.preventDefault();\n actions.onTreeExpandCollapse(action);\n return true;\n }\n return false;\n case SelectActions.Close:\n event.preventDefault();\n actions.close();\n return true;\n case SelectActions.Type:\n actions.onComboType(event.key, action);\n return true;\n case SelectActions.Open:\n event.preventDefault();\n actions.setIsOpen(true);\n return true;\n\n default:\n break;\n }\n\n return false;\n};\n\n/**\n * When options list is large, it can have a scrollbar.\n *\n * This function ensures the active option is always in the viewport\n */\nexport const ensureScrollVisiblity = (\n newActiveIndex: number,\n containerElement: HTMLElement | null,\n options: string[],\n): void => {\n // ensure the new option is in view\n if (containerElement) {\n if (isScrollable(containerElement)) {\n const optionEl = containerElement.querySelectorAll<HTMLElement>(\n '[role=\"option\"], [role=\"menuitem\"]',\n );\n // Making sure its the same element as the one from options state\n if (\n newActiveIndex >= 0 &&\n optionEl[newActiveIndex].dataset.value === options[newActiveIndex]\n ) {\n const activeElement = optionEl[newActiveIndex];\n\n if (!isElementVisible(containerElement, activeElement)) {\n activeElement.scrollIntoView({ inline: 'nearest' });\n }\n\n if (!isElementVisibleOnScreen(optionEl[newActiveIndex])) {\n activeElement.scrollIntoView({ behavior: 'smooth' });\n }\n }\n }\n }\n};\n\n/**\n * value that is set in the actual form input\n */\nexport const makeInputValue = (selectedIndices: number[], options: OptionsType): string => {\n if (options.length === 0) {\n return '';\n }\n return selectedIndices.map((selectedIndex) => options[selectedIndex]?.value).join(', ');\n};\n\n/**\n * Value that is displayed inside the select field\n *\n * `displayOverride` is published by TreeView (D5: smallest describing set - a fully\n * selected branch counts as 1). Absent for every other overlay content\n */\nexport const makeInputDisplayValue = (\n selectedIndices: number[],\n options: OptionsType,\n displayOverride?: { label: string; count: number },\n): string => {\n if (displayOverride && selectedIndices.length > 0) {\n if (displayOverride.count === 1) {\n return displayOverride.label;\n }\n return `${displayOverride.count} items selected`;\n }\n\n // When no item is selected or no item is present\n if (options.length === 0 || selectedIndices.length === 0) {\n return '';\n }\n\n // When one item is selected, we display that item's title in input\n if (selectedIndices.length === 1) {\n return options[selectedIndices[0]]?.title;\n }\n\n // When more than one item is selected, we display the count of items\n return `${selectedIndices.length} items selected`;\n};\n\nexport type DropdownPosition = {\n top?: SpacingValueType;\n bottom?: SpacingValueType;\n left?: SpacingValueType;\n right?: SpacingValueType;\n};\n"],"names":["SelectActions","Close","CloseSelect","Expand","Collapse","First","Last","Next","Open","PageDown","PageUp","Previous","Select","Type","filterOptions","options","arguments","length","undefined","filter","exclude","option","matches","String","toLowerCase","startsWith","includes","getActionFromKey","e","isOpen","dropdownTriggerer","altKey","ctrlKey","metaKey","key","openKeys","dropdownComponentIds","triggers","AutoComplete","SearchInput","getIndexByLetter","startIndex","orderedOptions","concat","_toConsumableArray","slice","firstMatch","allSameLetter","array","every","letter","indexOf","split","getUpdatedIndex","_ref","currentIndex","maxIndex","actionType","pageSize","Math","max","min","isElementVisibleOnScreen","element","bounding","getBoundingClientRect","top","left","bottom","window","innerHeight","document","documentElement","clientHeight","right","innerWidth","clientWidth","isElementVisible","container","containerRect","elementRect","isVerticalVisible","isScrollable","scrollHeight","performAction","action","payload","actions","event","setIsOpen","preventDefault","onOptionChange","selectCurrentOption","onTreeExpandCollapse","close","onComboType","ensureScrollVisiblity","newActiveIndex","containerElement","optionEl","querySelectorAll","dataset","value","activeElement","scrollIntoView","inline","behavior","makeInputValue","selectedIndices","map","selectedIndex","_options$selectedInde","join","makeInputDisplayValue","displayOverride","count","label","_options$selectedIndi","title"],"mappings":";;;AA6BA,IAAMA,aAA2D,CAAG,CAClEC,KAAK,CAAE,OAAO,CACdC,WAAW,CAAE,aAAa,CAE1BC,MAAM,CAAE,QAAQ,CAChBC,QAAQ,CAAE,UAAU,CACpBC,KAAK,CAAE,OAAO,CACdC,IAAI,CAAE,MAAM,CACZC,IAAI,CAAE,MAAM,CACZC,IAAI,CAAE,MAAM,CACZC,QAAQ,CAAE,UAAU,CACpBC,MAAM,CAAE,QAAQ,CAChBC,QAAQ,CAAE,UAAU,CACpBC,MAAM,CAAE,QAAQ,CAChBC,IAAI,CAAE,MACR,CAAC,UAOeC,aAAaA,EAIjB,KAHVC,OAAiB,CAAAC,SAAA,CAAAC,MAAA,CAAAD,CAAAA,EAAAA,SAAA,CAAAE,CAAAA,CAAAA,GAAAA,SAAA,CAAAF,SAAA,CAAA,CAAA,CAAA,CAAG,EAAE,CACtB,IAAAG,MAAc,CAAAH,SAAA,CAAAC,MAAA,GAAAD,SAAA,CAAA,CAAA,CAAA,CAAAE,SAAA,CACd,IAAAE,OAAiB,CAAAJ,SAAA,CAAAC,MAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,GAAAE,SAAA,CAAAF,SAAA,IAAG,EAAE,CAEtB,OAAOD,OAAO,CAACI,MAAM,CAAC,SAACE,MAAM,CAAK,CAChC,IAAMC,OAAO,CAAGC,MAAM,CAACF,MAAM,CAAC,CAACG,WAAW,EAAE,CAACC,UAAU,CAACN,MAAM,CAACK,WAAW,EAAE,CAAC,CAC7E,OAAO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AAA,CAAA,CAClD,CAGA,GAAIpG,OAAO,CAACE,MAAM,GAAK,CAAC,EAAI2F,eAAe,CAAC3F,MAAM,GAAK,CAAC,CAAE,CACxD,OAAO,EAAE,CACX,CAGA,GAAI2F,eAAe,CAAC3F,MAAM,GAAK,CAAC,CAAE,CAAAoG,IAAAA,qBAAA,CAChC,OAAAA,CAAAA,qBAAA,CAAOtG,OAAO,CAAC6F,eAAe,CAAC,CAAC,CAAC,CAAC,eAA3BS,qBAAA,CAA6BC,KAAK,CAC3C,CAGA,OAAO,CAAGV,EAAAA,eAAe,CAAC3F,MAAM,CAAA,eAAA,CAAiB,CACnD;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var getTitleFromValue=function getTitleFromValue(options,value){var option=options.find(function(currentOption){return currentOption.value===value;});return option?option.title:'';};var getFilterChipDisplayValue=function getFilterChipDisplayValue(_ref){var value=_ref.value,options=_ref.options,selectionType=_ref.selectionType,uncontrolledInputValue=_ref.uncontrolledInputValue,displayOverride=_ref.displayOverride;var titleForValue=function titleForValue(selectionValue){return getTitleFromValue(options,selectionValue)||selectionValue;};if(displayOverride){if(selectionType==='single'){return displayOverride.label;}return Array.from({length:displayOverride.count},function(_,index){return index===0?displayOverride.label:'';});}if(value===undefined){if(selectionType==='single'){return uncontrolledInputValue.length>0?titleForValue(uncontrolledInputValue[0]):'';}return uncontrolledInputValue.map(titleForValue);}if(Array.isArray(value)){return value.map(titleForValue);}return titleForValue(value);};
|
|
2
|
+
|
|
3
|
+
export { getFilterChipDisplayValue };
|
|
4
|
+
//# sourceMappingURL=filterChipSelectInputUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterChipSelectInputUtils.js","sources":["../../../../../src/components/Dropdown/filterChipSelectInputUtils.ts"],"sourcesContent":["import type { OptionsType } from './useDropdown';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\n\n/**\n * Resolves an option's human-readable title from its value. Returns an empty string when the\n * option isn't found so callers can decide on a fallback.\n */\nconst getTitleFromValue = (options: OptionsType, value: string): string => {\n const option = options.find((currentOption) => currentOption.value === value);\n return option ? option.title : '';\n};\n\ntype GetFilterChipDisplayValueParams = {\n /** Controlled value from props (option value or values). `undefined` when uncontrolled. */\n value: BaseFilterChipProps['value'];\n /** All options currently registered in the dropdown. */\n options: OptionsType;\n selectionType: BaseFilterChipProps['selectionType'];\n /** Internally tracked selection used in the uncontrolled case. */\n uncontrolledInputValue: string[];\n /**\n * Published by TreeView (D5): smallest describing set of the current selection where a\n * fully-selected branch counts as 1. Absent for every other overlay content\n */\n displayOverride?: { label: string; count: number };\n};\n\n/**\n * Resolves the value shown inside the filter chip as option title(s).\n *\n * Shared by the web and native `FilterChipSelectInput` implementations to keep the (non-trivial)\n * controlled-vs-uncontrolled / string-vs-array branching in a single source of truth. In every\n * branch we fall back to the raw value when the title can't be resolved (e.g. options loaded or\n * changed after a selection) so the chip never renders an empty string.\n */\nconst getFilterChipDisplayValue = ({\n value,\n options,\n selectionType,\n uncontrolledInputValue,\n displayOverride,\n}: GetFilterChipDisplayValueParams): string | string[] => {\n const titleForValue = (selectionValue: string): string =>\n getTitleFromValue(options, selectionValue) || selectionValue;\n\n if (displayOverride) {\n if (selectionType === 'single') {\n return displayOverride.label;\n }\n // BaseFilterChip renders the single name at length 1 and a Counter of the array\n // length at 2+, so we synthesize an array of the override's count (only the first\n // entry is ever rendered as text)\n return Array.from({ length: displayOverride.count }, (_, index) =>\n index === 0 ? displayOverride.label : '',\n );\n }\n\n // Uncontrolled: derive display value from the internally tracked selection.\n if (value === undefined) {\n if (selectionType === 'single') {\n return uncontrolledInputValue.length > 0 ? titleForValue(uncontrolledInputValue[0]) : '';\n }\n // For multiple selection, hand the chip the option titles (not the raw values) so it can\n // render the selected option name(s) instead of a bare count.\n return uncontrolledInputValue.map(titleForValue);\n }\n\n // Controlled: consumer passes option value(s); map them to titles for display.\n if (Array.isArray(value)) {\n return value.map(titleForValue);\n }\n return titleForValue(value);\n};\n\nexport { getFilterChipDisplayValue };\n"],"names":["getTitleFromValue","options","value","option","find","currentOption","title","getFilterChipDisplayValue","_ref","selectionType","uncontrolledInputValue","displayOverride","titleForValue","selectionValue","label","Array","from","length","count","_","index","undefined","map","isArray"],"mappings":"AAOA,IAAMA,iBAAiB,CAAG,SAApBA,iBAAiBA,CAAIC,OAAoB,CAAEC,KAAa,CAAa,CACzE,IAAMC,MAAM,CAAGF,OAAO,CAACG,IAAI,CAAC,SAACC,aAAa,CAAK,CAAA,OAAAA,aAAa,CAACH,KAAK,GAAKA,KAAK,CAAC,CAAA,CAAA,CAC7E,OAAOC,MAAM,CAAGA,MAAM,CAACG,KAAK,CAAG,EAAE,CACnC,CAAC,CAyBK,IAAAC,yBAAyB,CAAG,SAA5BA,yBAAyBA,CAAAC,IAAA,CAM2B,CALxD,IAAAN,KAAK,CAAAM,IAAA,CAALN,KAAK,CACLD,OAAO,CAAAO,IAAA,CAAPP,OAAO,CACPQ,aAAa,CAAAD,IAAA,CAAbC,aAAa,CACbC,sBAAsB,CAAAF,IAAA,CAAtBE,sBAAsB,CACtBC,eAAe,CAAAH,IAAA,CAAfG,eAAe,CAEf,IAAMC,aAAa,CAAG,SAAhBA,aAAaA,CAAIC,cAAsB,CAAA,CAAA,OAC3Cb,iBAAiB,CAACC,OAAO,CAAEY,cAAc,CAAC,EAAIA,cAAc,CAE9D,CAAA,CAAA,GAAIF,eAAe,CAAE,CACnB,GAAIF,aAAa,GAAK,QAAQ,CAAE,CAC9B,OAAOE,eAAe,CAACG,KAAK,CAC9B,CAIA,OAAOC,KAAK,CAACC,IAAI,CAAC,CAAEC,MAAM,CAAEN,eAAe,CAACO,KAAM,CAAC,CAAE,SAACC,CAAC,CAAEC,KAAK,SAC5DA,KAAK,GAAK,CAAC,CAAGT,eAAe,CAACG,KAAK,CAAG,EAAE,CAAA,CAC1C,CAAC,CACH,CAGA,GAAIZ,KAAK,GAAKmB,SAAS,CAAE,CACvB,GAAIZ,aAAa,GAAK,QAAQ,CAAE,CAC9B,OAAOC,sBAAsB,CAACO,MAAM,CAAG,CAAC,CAAGL,aAAa,CAACF,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAG,EAAE,CAC1F,CAGA,OAAOA,sBAAsB,CAACY,GAAG,CAACV,aAAa,CAAC,CAClD,CAGA,GAAIG,KAAK,CAACQ,OAAO,CAACrB,KAAK,CAAC,CAAE,CACxB,OAAOA,KAAK,CAACoB,GAAG,CAACV,aAAa,CAAC,CACjC,CACA,OAAOA,aAAa,CAACV,KAAK,CAAC,CAC7B;;;;"}
|
|
@@ -9,7 +9,7 @@ import { isBrowser } from '../../utils/platform/isBrowser.js';
|
|
|
9
9
|
import { fireNativeEvent } from '../../utils/fireNativeEvent/fireNativeEvent.native.js';
|
|
10
10
|
import { isReactNative } from '../../utils/platform/isReactNative.js';
|
|
11
11
|
|
|
12
|
-
var _excluded=["isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","visibleTagsCountRef","isKeydownPressed","setIsKeydownPressed","options","selectionType","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setControlledValueIndices","filteredValues","dropdownTriggerer"];var noop=function noop(){};var DropdownContext=React__default.createContext({isOpen:false,setIsOpen:noop,close:noop,selectedIndices:[],setSelectedIndices:noop,controlledValueIndices:[],setControlledValueIndices:noop,options:[],setOptions:noop,filteredValues:[],setFilteredValues:noop,activeIndex:-1,setActiveIndex:noop,activeTagIndex:-1,setActiveTagIndex:noop,shouldIgnoreBlurAnimation:false,setShouldIgnoreBlurAnimation:noop,hasFooterAction:false,setHasFooterAction:noop,hasAutoCompleteInHeader:false,setHasAutoCompleteInHeader:noop,isKeydownPressed:false,setIsKeydownPressed:noop,changeCallbackTriggerer:0,setChangeCallbackTriggerer:noop,isControlled:false,setIsControlled:noop,dropdownBaseId:'',actionListItemRef:{current:null},triggererRef:{current:null},headerAutoCompleteRef:{current:null},isTagDismissedRef:{current:null},visibleTagsCountRef:{current:null},triggererWrapperRef:{current:null}});var searchTimeout;var searchString='';var useDropdown=function useDropdown(){var _React$useContext=React__default.useContext(DropdownContext),isOpen=_React$useContext.isOpen,setIsOpen=_React$useContext.setIsOpen,close=_React$useContext.close,selectedIndices=_React$useContext.selectedIndices,setSelectedIndices=_React$useContext.setSelectedIndices,activeIndex=_React$useContext.activeIndex,setActiveIndex=_React$useContext.setActiveIndex,activeTagIndex=_React$useContext.activeTagIndex,setActiveTagIndex=_React$useContext.setActiveTagIndex,visibleTagsCountRef=_React$useContext.visibleTagsCountRef,isKeydownPressed=_React$useContext.isKeydownPressed,setIsKeydownPressed=_React$useContext.setIsKeydownPressed,options=_React$useContext.options,selectionType=_React$useContext.selectionType,changeCallbackTriggerer=_React$useContext.changeCallbackTriggerer,setChangeCallbackTriggerer=_React$useContext.setChangeCallbackTriggerer,isControlled=_React$useContext.isControlled,setControlledValueIndices=_React$useContext.setControlledValueIndices,filteredValues=_React$useContext.filteredValues,dropdownTriggerer=_React$useContext.dropdownTriggerer,rest=_objectWithoutProperties(_React$useContext,_excluded);var setIndices=function setIndices(indices){if(isControlled){setControlledValueIndices(indices);}else {setSelectedIndices(indices);}};var removeOption=function removeOption(index){var existingItemIndex=selectedIndices.indexOf(index);if(existingItemIndex<0){return;}setIndices([].concat(_toConsumableArray(selectedIndices.slice(0,existingItemIndex)),_toConsumableArray(selectedIndices.slice(existingItemIndex+1))));};var selectOption=function selectOption(index){var properties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{closeOnSelection:true};var isSelected=false;if(index<0||index>options.length-1){return isSelected;}if(selectionType==='multiple'){if(selectedIndices.includes(index)){removeOption(index);isSelected=false;}else {setIndices([].concat(_toConsumableArray(selectedIndices),[index]));isSelected=true;}}else {setIndices([index]);isSelected=true;}setChangeCallbackTriggerer(changeCallbackTriggerer+1);if(activeIndex!==index){setActiveIndex(index);}if(properties!=null&&properties.closeOnSelection&&selectionType!=='multiple'){close();}return isSelected;};var onTriggerClick=function onTriggerClick(){if(isOpen){close();}else {setIsOpen(true);}};var onOptionChange=function onOptionChange(actionType,index){setActiveTagIndex(-1);var newIndex=index!=null?index:activeIndex;var updatedIndex;var hasAutoComplete=rest.hasAutoCompleteInHeader||dropdownTriggerer===dropdownComponentIds.triggers.AutoComplete;if(hasAutoComplete&&filteredValues.length>0){var filteredIndexes=filteredValues.map(function(filteredValue){return options.findIndex(function(option){return option.value===filteredValue;});}).sort(function(a,b){return a-b;});updatedIndex=filteredIndexes[getUpdatedIndex({currentIndex:filteredIndexes.indexOf(newIndex),maxIndex:filteredIndexes.length-1,actionType:actionType})];}else {updatedIndex=getUpdatedIndex({currentIndex:newIndex,maxIndex:options.length-1,actionType:actionType});}setActiveIndex(updatedIndex);var optionValues=options.map(function(option){return option.value;});ensureScrollVisiblity(updatedIndex,rest.actionListItemRef.current,optionValues);if(isBrowser()){fireNativeEvent(rest.actionListItemRef,['change','input']);}};var onOptionClick=function onOptionClick(e,index){setIsKeydownPressed(false);var actionType=getActionFromKey(e,isOpen,dropdownTriggerer);if(typeof actionType==='number'){onOptionChange(actionType,index);}selectOption(index);if(!isReactNative()){if(rest.hasAutoCompleteInHeader){var _rest$headerAutoCompl;(_rest$headerAutoCompl=rest.headerAutoCompleteRef.current)==null?void 0:_rest$headerAutoCompl.focus();}else {var _rest$triggererRef$cu;(_rest$triggererRef$cu=rest.triggererRef.current)==null?void 0:_rest$triggererRef$cu.focus();}}};var onComboType=function onComboType(letter,actionType){setIsOpen(true);if(rest.hasAutoCompleteInHeader||dropdownTriggerer===dropdownComponentIds.triggers.AutoComplete){return;}if(typeof searchTimeout==='number'){window.clearTimeout(searchTimeout);}searchTimeout=window.setTimeout(function(){searchString='';},500);searchString=searchString+letter;var optionTitles=options.map(function(option){return option.title;});var searchIndex=getIndexByLetter(optionTitles,searchString,activeIndex+1);if(searchIndex>=0){onOptionChange(actionType,searchIndex);}else {window.clearTimeout(searchTimeout);searchString='';}};var onTriggerKeydown=function onTriggerKeydown(e){if(!isKeydownPressed&&![' ','Enter','Escape','Meta'].includes(e.event.key)){setIsKeydownPressed(true);}var actionType=getActionFromKey(e.event,isOpen,dropdownTriggerer);if(actionType){performAction(actionType,e,{setIsOpen:setIsOpen,close:close,onOptionChange:onOptionChange,onComboType:onComboType,selectCurrentOption:function selectCurrentOption(){var _options$activeIndex$,_options$activeIndex;if(activeIndex<0){return;}var isSelected=selectOption(activeIndex);if(rest.hasFooterAction&&!isReactNative()){var _rest$triggererRef$cu2;(_rest$triggererRef$cu2=rest.triggererRef.current)==null?void 0:_rest$triggererRef$cu2.focus();}(_options$activeIndex$=(_options$activeIndex=options[activeIndex]).onClickTrigger)==null?void 0:_options$activeIndex$.call(_options$activeIndex,isSelected);}});}};return Object.assign({isOpen:isOpen,setIsOpen:setIsOpen,close:close,selectedIndices:selectedIndices,setSelectedIndices:setSelectedIndices,filteredValues:filteredValues,removeOption:removeOption,setControlledValueIndices:setControlledValueIndices,onTriggerClick:onTriggerClick,onTriggerKeydown:onTriggerKeydown,onOptionClick:onOptionClick,activeIndex:activeIndex,setActiveIndex:setActiveIndex,activeTagIndex:activeTagIndex,setActiveTagIndex:setActiveTagIndex,visibleTagsCountRef:visibleTagsCountRef,isKeydownPressed:isKeydownPressed,setIsKeydownPressed:setIsKeydownPressed,changeCallbackTriggerer:changeCallbackTriggerer,setChangeCallbackTriggerer:setChangeCallbackTriggerer,isControlled:isControlled,options:options,value:makeInputValue(selectedIndices,options),displayValue:makeInputDisplayValue(selectedIndices,options),selectionType:selectionType,dropdownTriggerer:dropdownTriggerer},rest);};
|
|
12
|
+
var _excluded=["isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","visibleTagsCountRef","isKeydownPressed","setIsKeydownPressed","options","selectionType","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setControlledValueIndices","filteredValues","dropdownTriggerer"];var noop=function noop(){};var DropdownContext=React__default.createContext({isOpen:false,setIsOpen:noop,close:noop,selectedIndices:[],setSelectedIndices:noop,controlledValueIndices:[],setControlledValueIndices:noop,options:[],setOptions:noop,filteredValues:[],setFilteredValues:noop,activeIndex:-1,setActiveIndex:noop,activeTagIndex:-1,setActiveTagIndex:noop,shouldIgnoreBlurAnimation:false,setShouldIgnoreBlurAnimation:noop,hasFooterAction:false,setHasFooterAction:noop,hasAutoCompleteInHeader:false,setHasAutoCompleteInHeader:noop,isKeydownPressed:false,setIsKeydownPressed:noop,changeCallbackTriggerer:0,setChangeCallbackTriggerer:noop,isControlled:false,setIsControlled:noop,dropdownBaseId:'',actionListItemRef:{current:null},triggererRef:{current:null},headerAutoCompleteRef:{current:null},isTagDismissedRef:{current:null},visibleTagsCountRef:{current:null},triggererWrapperRef:{current:null},treeViewControllerRef:{current:null}});var searchTimeout;var searchString='';var useDropdown=function useDropdown(){var _rest$treeViewControl6,_rest$treeViewControl7;var _React$useContext=React__default.useContext(DropdownContext),isOpen=_React$useContext.isOpen,setIsOpen=_React$useContext.setIsOpen,close=_React$useContext.close,selectedIndices=_React$useContext.selectedIndices,setSelectedIndices=_React$useContext.setSelectedIndices,activeIndex=_React$useContext.activeIndex,setActiveIndex=_React$useContext.setActiveIndex,activeTagIndex=_React$useContext.activeTagIndex,setActiveTagIndex=_React$useContext.setActiveTagIndex,visibleTagsCountRef=_React$useContext.visibleTagsCountRef,isKeydownPressed=_React$useContext.isKeydownPressed,setIsKeydownPressed=_React$useContext.setIsKeydownPressed,options=_React$useContext.options,selectionType=_React$useContext.selectionType,changeCallbackTriggerer=_React$useContext.changeCallbackTriggerer,setChangeCallbackTriggerer=_React$useContext.setChangeCallbackTriggerer,isControlled=_React$useContext.isControlled,setControlledValueIndices=_React$useContext.setControlledValueIndices,filteredValues=_React$useContext.filteredValues,dropdownTriggerer=_React$useContext.dropdownTriggerer,rest=_objectWithoutProperties(_React$useContext,_excluded);var setIndices=function setIndices(indices){if(isControlled){setControlledValueIndices(indices);}else {setSelectedIndices(indices);}};var removeOption=function removeOption(index){var existingItemIndex=selectedIndices.indexOf(index);if(existingItemIndex<0){return;}setIndices([].concat(_toConsumableArray(selectedIndices.slice(0,existingItemIndex)),_toConsumableArray(selectedIndices.slice(existingItemIndex+1))));};var selectOption=function selectOption(index){var properties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{closeOnSelection:true};var isSelected=false;if(index<0||index>options.length-1){return isSelected;}if(selectionType==='multiple'){if(selectedIndices.includes(index)){removeOption(index);isSelected=false;}else {setIndices([].concat(_toConsumableArray(selectedIndices),[index]));isSelected=true;}}else {setIndices([index]);isSelected=true;}setChangeCallbackTriggerer(changeCallbackTriggerer+1);if(activeIndex!==index){setActiveIndex(index);}if(properties!=null&&properties.closeOnSelection&&selectionType!=='multiple'){close();}return isSelected;};var selectOptionsBatch=function selectOptionsBatch(indices,action){if(indices.length===0){return;}var updatedIndices;if(action==='select'){updatedIndices=_toConsumableArray(selectedIndices);for(var _index of indices){if(_index>=0&&_index<=options.length-1&&!updatedIndices.includes(_index)){updatedIndices.push(_index);}}}else {updatedIndices=selectedIndices.filter(function(selectedIndex){return !indices.includes(selectedIndex);});}setIndices(updatedIndices);setChangeCallbackTriggerer(changeCallbackTriggerer+1);};var onTriggerClick=function onTriggerClick(){if(isOpen){close();}else {setIsOpen(true);}};var onOptionChange=function onOptionChange(actionType,index){var _rest$treeViewControl;setActiveTagIndex(-1);var newIndex=index!=null?index:activeIndex;var updatedIndex;var hasAutoComplete=rest.hasAutoCompleteInHeader||dropdownTriggerer===dropdownComponentIds.triggers.AutoComplete;var treeViewController=(_rest$treeViewControl=rest.treeViewControllerRef)==null?void 0:_rest$treeViewControl.current;if(treeViewController){var _visibleIndexes$getUp;var visibleIndexes=treeViewController.getVisibleOptionIndices();updatedIndex=(_visibleIndexes$getUp=visibleIndexes[getUpdatedIndex({currentIndex:visibleIndexes.indexOf(newIndex),maxIndex:visibleIndexes.length-1,actionType:actionType})])!=null?_visibleIndexes$getUp:newIndex;}else if(hasAutoComplete&&filteredValues.length>0){var filteredIndexes=filteredValues.map(function(filteredValue){return options.findIndex(function(option){return option.value===filteredValue;});}).sort(function(a,b){return a-b;});updatedIndex=filteredIndexes[getUpdatedIndex({currentIndex:filteredIndexes.indexOf(newIndex),maxIndex:filteredIndexes.length-1,actionType:actionType})];}else {updatedIndex=getUpdatedIndex({currentIndex:newIndex,maxIndex:options.length-1,actionType:actionType});}setActiveIndex(updatedIndex);var optionValues=options.map(function(option){return option.value;});ensureScrollVisiblity(updatedIndex,rest.actionListItemRef.current,optionValues);if(isBrowser()){fireNativeEvent(rest.actionListItemRef,['change','input']);}};var onOptionClick=function onOptionClick(e,index){setIsKeydownPressed(false);var actionType=getActionFromKey(e,isOpen,dropdownTriggerer);if(typeof actionType==='number'){onOptionChange(actionType,index);}selectOption(index);if(!isReactNative()){if(rest.hasAutoCompleteInHeader){var _rest$headerAutoCompl;(_rest$headerAutoCompl=rest.headerAutoCompleteRef.current)==null?void 0:_rest$headerAutoCompl.focus();}else {var _rest$triggererRef$cu;(_rest$triggererRef$cu=rest.triggererRef.current)==null?void 0:_rest$triggererRef$cu.focus();}}};var onComboType=function onComboType(letter,actionType){setIsOpen(true);if(rest.hasAutoCompleteInHeader||dropdownTriggerer===dropdownComponentIds.triggers.AutoComplete){return;}if(typeof searchTimeout==='number'){window.clearTimeout(searchTimeout);}searchTimeout=window.setTimeout(function(){searchString='';},500);searchString=searchString+letter;var optionTitles=options.map(function(option){return option.title;});var searchIndex=getIndexByLetter(optionTitles,searchString,activeIndex+1);if(searchIndex>=0){onOptionChange(actionType,searchIndex);}else {window.clearTimeout(searchTimeout);searchString='';}};var onTriggerKeydown=function onTriggerKeydown(e){if(!isKeydownPressed&&![' ','Enter','Escape','Meta'].includes(e.event.key)){setIsKeydownPressed(true);}var actionType=getActionFromKey(e.event,isOpen,dropdownTriggerer);if(actionType){var _rest$treeViewControl3;performAction(actionType,e,{setIsOpen:setIsOpen,close:close,onOptionChange:onOptionChange,onComboType:onComboType,selectCurrentOption:function selectCurrentOption(event){var _rest$treeViewControl2,_options$activeIndex$,_options$activeIndex;if(activeIndex<0){return;}var treeViewController=(_rest$treeViewControl2=rest.treeViewControllerRef)==null?void 0:_rest$treeViewControl2.current;if(treeViewController!=null&&treeViewController.handleOptionSelect(activeIndex,{key:event==null?void 0:event.key})){return;}var isSelected=selectOption(activeIndex);if(rest.hasFooterAction&&!isReactNative()){var _rest$triggererRef$cu2;(_rest$triggererRef$cu2=rest.triggererRef.current)==null?void 0:_rest$triggererRef$cu2.focus();}(_options$activeIndex$=(_options$activeIndex=options[activeIndex]).onClickTrigger)==null?void 0:_options$activeIndex$.call(_options$activeIndex,isSelected);},onTreeExpandCollapse:(_rest$treeViewControl3=rest.treeViewControllerRef)!=null&&_rest$treeViewControl3.current?function(action){if(action==='Expand'){var _rest$treeViewControl4;(_rest$treeViewControl4=rest.treeViewControllerRef.current)==null?void 0:_rest$treeViewControl4.onArrowRightKeydown(activeIndex);}else {var _rest$treeViewControl5;(_rest$treeViewControl5=rest.treeViewControllerRef.current)==null?void 0:_rest$treeViewControl5.onArrowLeftKeydown(activeIndex);}}:undefined});}};return Object.assign({isOpen:isOpen,setIsOpen:setIsOpen,close:close,selectedIndices:selectedIndices,setSelectedIndices:setSelectedIndices,filteredValues:filteredValues,removeOption:removeOption,selectOptionsBatch:selectOptionsBatch,setControlledValueIndices:setControlledValueIndices,onTriggerClick:onTriggerClick,onTriggerKeydown:onTriggerKeydown,onOptionClick:onOptionClick,activeIndex:activeIndex,setActiveIndex:setActiveIndex,activeTagIndex:activeTagIndex,setActiveTagIndex:setActiveTagIndex,visibleTagsCountRef:visibleTagsCountRef,isKeydownPressed:isKeydownPressed,setIsKeydownPressed:setIsKeydownPressed,changeCallbackTriggerer:changeCallbackTriggerer,setChangeCallbackTriggerer:setChangeCallbackTriggerer,isControlled:isControlled,options:options,value:makeInputValue(selectedIndices,options),displayValue:makeInputDisplayValue(selectedIndices,options,(_rest$treeViewControl6=rest.treeViewControllerRef)==null?void 0:(_rest$treeViewControl7=_rest$treeViewControl6.current)==null?void 0:_rest$treeViewControl7.getDisplayOverride(selectedIndices)),selectionType:selectionType,dropdownTriggerer:dropdownTriggerer},rest);};
|
|
13
13
|
|
|
14
14
|
export { DropdownContext, useDropdown };
|
|
15
15
|
//# sourceMappingURL=useDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdown.js","sources":["../../../../../src/components/Dropdown/useDropdown.ts"],"sourcesContent":["import React from 'react';\n\nimport {\n ensureScrollVisiblity,\n getActionFromKey,\n getIndexByLetter,\n getUpdatedIndex,\n makeInputDisplayValue,\n makeInputValue,\n performAction,\n} from './dropdownUtils';\nimport type { SelectActionsType } from './dropdownUtils';\nimport type { DropdownProps } from './types';\n\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { FormInputHandleOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { isReactNative, isBrowser } from '~utils';\nimport type { ContainerElementType } from '~utils/types';\nimport { fireNativeEvent } from '~utils/fireNativeEvent';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\ntype OptionsType = {\n title: string;\n value: string;\n onClickTrigger?: (isSelected: boolean) => void;\n}[];\n\ntype DropdownContextType = {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n close: () => void;\n /**\n * contains the indexes of selected items\n */\n selectedIndices: number[];\n setSelectedIndices: (value: number[]) => void;\n /**\n * contains the indexes of selected items during controlled selection\n */\n controlledValueIndices: number[];\n setControlledValueIndices: (value: number[]) => void;\n /**\n * contains information about all the options inside actionlist\n */\n options: OptionsType;\n setOptions: (value: OptionsType) => void;\n\n /**\n * Filtered values for AutoComplete Inputs\n */\n filteredValues: string[];\n setFilteredValues: (values: string[]) => void;\n\n /** Currently active (focussed) index */\n activeIndex: number;\n setActiveIndex: (value: number) => void;\n\n /** Currently active (focussed) tag */\n activeTagIndex: number;\n setActiveTagIndex: (value: number) => void;\n\n /**\n * Sometimes we want to ignore the blur event to keep dropdown open but not ignore the blur animation from selectinput\n * E.g. When someone clicks on Footer, we just want to ignore the blur event and not the blur animation\n */\n shouldIgnoreBlurAnimation: boolean;\n setShouldIgnoreBlurAnimation: (value: boolean) => void;\n /** Tells you if keyboard was used. Its false by default and turns into true when keydown is called */\n isKeydownPressed: boolean;\n setIsKeydownPressed: (value: boolean) => void;\n /** common baseId which is prepended to multiple other ids inside this dropdown */\n dropdownBaseId: string;\n /** Which element has triggered the dropdown */\n dropdownTriggerer?:\n | 'SelectInput'\n | 'DropdownButton'\n | 'DropdownIconButton'\n | 'AutoComplete'\n | 'DropdownLink'\n | 'SearchInput'\n | 'FilterChipSelectInput'\n | 'InputDropdownButton';\n\n /** ref of triggerer. Used to call focus in certain places */\n triggererRef: React.MutableRefObject<HTMLButtonElement | null>;\n headerAutoCompleteRef: React.MutableRefObject<HTMLButtonElement | null>;\n triggererWrapperRef: React.MutableRefObject<ContainerElementType | null>;\n actionListItemRef: React.RefObject<HTMLDivElement | null>;\n isTagDismissedRef: React.RefObject<{ value: boolean } | null>;\n visibleTagsCountRef: React.RefObject<{ value: number } | null>;\n\n selectionType?: DropdownProps['selectionType'];\n /** whether footer has an action item.\n * certain a11y behaviour changes happen here\n * E.g. tabbing moves focus to that action instead of outside\n */\n hasFooterAction: boolean;\n setHasFooterAction: (value: boolean) => void;\n\n /**\n * Apart from dropdownTriggerer prop, we also set this boolean because in BottomSheetHeader and DropdownHeader, the trigger can be Select but they can also have autocomplete inside of header\n */\n hasAutoCompleteInHeader: boolean;\n setHasAutoCompleteInHeader: (value: boolean) => void;\n\n /**\n * A value that can be used in dependency array to know when Dropdown value is changed.\n *\n * E.g.\n * ```ts\n * useEffect(() => {\n * console.log('Uncontrolled value change');\n * }, [changeCallbackTriggerer])\n * ```\n */\n changeCallbackTriggerer: number;\n setChangeCallbackTriggerer: (changeCallbackTriggerer: number) => void;\n\n /**\n * true when SelectInput has `value` prop (when it is controlled)\n */\n isControlled: boolean;\n setIsControlled: (isControlled: boolean) => void;\n};\n\nconst DropdownContext = React.createContext<DropdownContextType>({\n isOpen: false,\n setIsOpen: noop,\n close: noop,\n selectedIndices: [],\n setSelectedIndices: noop,\n controlledValueIndices: [],\n setControlledValueIndices: noop,\n options: [],\n setOptions: noop,\n filteredValues: [],\n setFilteredValues: noop,\n activeIndex: -1,\n setActiveIndex: noop,\n activeTagIndex: -1,\n setActiveTagIndex: noop,\n shouldIgnoreBlurAnimation: false,\n setShouldIgnoreBlurAnimation: noop,\n hasFooterAction: false,\n setHasFooterAction: noop,\n hasAutoCompleteInHeader: false,\n setHasAutoCompleteInHeader: noop,\n isKeydownPressed: false,\n setIsKeydownPressed: noop,\n changeCallbackTriggerer: 0,\n setChangeCallbackTriggerer: noop,\n isControlled: false,\n setIsControlled: noop,\n dropdownBaseId: '',\n actionListItemRef: {\n current: null,\n },\n triggererRef: {\n current: null,\n },\n headerAutoCompleteRef: {\n current: null,\n },\n isTagDismissedRef: {\n current: null,\n },\n visibleTagsCountRef: {\n current: null,\n },\n triggererWrapperRef: {\n current: null,\n },\n});\n\nlet searchTimeout: number;\nlet searchString = '';\n\ntype UseDropdownReturnValue = DropdownContextType & {\n /**\n * Click event on combobox. Toggles the dropdown\n */\n onTriggerClick: () => void;\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n onTriggerKeydown: FormInputHandleOnKeyDownEvent | undefined;\n\n /**\n * Handles the click even on option.\n *\n * Contains the logic that selects the option, moves the focus, etc\n */\n onOptionClick: (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ) => void;\n\n /**\n * Removes the option with given optionsIndex\n */\n removeOption: (index: number) => void;\n\n /**\n * value that is used during form submissions\n */\n value: string;\n /**\n * This is the value that is displayed inside select after selection\n */\n displayValue: string;\n};\n\n/**\n * Handles almost all the functionality of dropdown.\n *\n * Returns the values from DropdownContext along with some helper functions and event handlers\n *\n */\nconst useDropdown = (): UseDropdownReturnValue => {\n const {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n options,\n selectionType,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setControlledValueIndices,\n filteredValues,\n dropdownTriggerer,\n ...rest\n } = React.useContext(DropdownContext);\n\n type SelectOptionType = (\n index: number,\n properties?: {\n closeOnSelection?: boolean;\n },\n ) => boolean;\n\n const setIndices = (indices: number[]): void => {\n if (isControlled) {\n setControlledValueIndices(indices);\n } else {\n setSelectedIndices(indices);\n }\n };\n\n const removeOption = (index: number): void => {\n // remove existing item\n const existingItemIndex = selectedIndices.indexOf(index);\n if (existingItemIndex < 0) {\n return;\n }\n\n setIndices([\n ...selectedIndices.slice(0, existingItemIndex),\n ...selectedIndices.slice(existingItemIndex + 1),\n ]);\n };\n\n /**\n * Marks the given index as selected.\n *\n * In single select, it also closes the menu.\n * In multiselect, it keeps the menu open for more selections\n */\n const selectOption: SelectOptionType = (\n index,\n properties = {\n closeOnSelection: true,\n },\n ) => {\n let isSelected = false;\n\n if (index < 0 || index > options.length - 1) {\n return isSelected;\n }\n\n if (selectionType === 'multiple') {\n if (selectedIndices.includes(index)) {\n removeOption(index);\n isSelected = false;\n } else {\n setIndices([...selectedIndices, index]);\n isSelected = true;\n }\n } else {\n setIndices([index]);\n isSelected = true;\n }\n\n // Triggers `onChange` on SelectInput\n setChangeCallbackTriggerer(changeCallbackTriggerer + 1);\n\n if (activeIndex !== index) {\n setActiveIndex(index);\n }\n\n if (properties?.closeOnSelection && selectionType !== 'multiple') {\n close();\n }\n\n return isSelected;\n };\n\n /**\n * Click listener for combobox (or any triggerer of the dropdown)\n */\n const onTriggerClick = (): void => {\n if (isOpen) {\n close();\n } else {\n setIsOpen(true);\n }\n };\n\n /**\n * Function that we call when we want to move focus from one option to other\n */\n const onOptionChange = (actionType: SelectActionsType, index?: number): void => {\n setActiveTagIndex(-1);\n const newIndex = index ?? activeIndex;\n let updatedIndex: number;\n const hasAutoComplete =\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete;\n if (hasAutoComplete && filteredValues.length > 0) {\n // When its autocomplete, we don't loop over all options. We only loop on filtered options\n\n const filteredIndexes = filteredValues\n .map((filteredValue) => options.findIndex((option) => option.value === filteredValue))\n .sort((a, b) => a - b);\n\n updatedIndex =\n filteredIndexes[\n getUpdatedIndex({\n currentIndex: filteredIndexes.indexOf(newIndex),\n maxIndex: filteredIndexes.length - 1,\n actionType,\n })\n ];\n } else {\n updatedIndex = getUpdatedIndex({\n currentIndex: newIndex,\n maxIndex: options.length - 1,\n actionType,\n });\n }\n setActiveIndex(updatedIndex);\n\n const optionValues = options.map((option) => option.value);\n ensureScrollVisiblity(updatedIndex, rest.actionListItemRef.current, optionValues);\n if (isBrowser()) {\n fireNativeEvent(rest.actionListItemRef as React.RefObject<HTMLElement>, ['change', 'input']);\n }\n };\n\n /**\n * Click handler when user clicks on any particular option.\n *\n * It\n * - changes the option focus\n * - selects that option\n * - moves focus to combobox\n */\n const onOptionClick = (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ): void => {\n setIsKeydownPressed(false);\n const actionType = getActionFromKey(e, isOpen, dropdownTriggerer);\n if (typeof actionType === 'number') {\n onOptionChange(actionType, index);\n }\n selectOption(index);\n\n if (!isReactNative()) {\n if (rest.hasAutoCompleteInHeader) {\n // move focus to autocomplete\n rest.headerAutoCompleteRef.current?.focus();\n } else {\n rest.triggererRef.current?.focus();\n }\n }\n };\n\n /**\n * Function we call to handle the typeahead.\n *\n * It takes a letter, stores that letter in searchString (and clears it after timeout) to maintain a word\n *\n * Then searches for that word in options and moves focus there.\n */\n const onComboType = (letter: string, actionType: SelectActionsType): void => {\n // open the listbox if it is closed\n setIsOpen(true);\n\n if (\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete\n ) {\n return;\n }\n\n if (typeof searchTimeout === 'number') {\n window.clearTimeout(searchTimeout);\n }\n\n searchTimeout = window.setTimeout(() => {\n searchString = '';\n }, 500);\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n searchString = searchString + letter;\n const optionTitles = options.map((option) => option.title);\n const searchIndex = getIndexByLetter(optionTitles, searchString, activeIndex + 1);\n\n // if a match was found, go to it\n if (searchIndex >= 0) {\n onOptionChange(actionType, searchIndex);\n }\n // if no matches, clear the timeout and search string\n else {\n window.clearTimeout(searchTimeout);\n searchString = '';\n }\n };\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n const onTriggerKeydown = (e: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n }): void => {\n if (!isKeydownPressed && ![' ', 'Enter', 'Escape', 'Meta'].includes(e.event.key)) {\n // When keydown is not already pressed and its not Enter, Space, Command, or Escape key (those are generic keys and we only want to handle arrow keys or home buttons etc)\n setIsKeydownPressed(true);\n }\n\n const actionType = getActionFromKey(e.event, isOpen, dropdownTriggerer);\n\n if (actionType) {\n performAction(actionType, e, {\n setIsOpen,\n close,\n onOptionChange,\n onComboType,\n selectCurrentOption: () => {\n if (activeIndex < 0) {\n return;\n }\n\n const isSelected = selectOption(activeIndex);\n if (rest.hasFooterAction && !isReactNative()) {\n rest.triggererRef.current?.focus();\n }\n\n options[activeIndex].onClickTrigger?.(isSelected);\n },\n });\n }\n };\n\n return {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n filteredValues,\n removeOption,\n setControlledValueIndices,\n onTriggerClick,\n onTriggerKeydown,\n onOptionClick,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n options,\n value: makeInputValue(selectedIndices, options),\n displayValue: makeInputDisplayValue(selectedIndices, options),\n selectionType,\n dropdownTriggerer,\n ...rest,\n };\n};\n\nexport type { DropdownContextType, OptionsType };\nexport { useDropdown, DropdownContext };\n"],"names":["noop","DropdownContext","React","createContext","isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","controlledValueIndices","setControlledValueIndices","options","setOptions","filteredValues","setFilteredValues","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","hasFooterAction","setHasFooterAction","hasAutoCompleteInHeader","setHasAutoCompleteInHeader","isKeydownPressed","setIsKeydownPressed","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setIsControlled","dropdownBaseId","actionListItemRef","current","triggererRef","headerAutoCompleteRef","isTagDismissedRef","visibleTagsCountRef","triggererWrapperRef","searchTimeout","searchString","useDropdown","_React$useContext","useContext","selectionType","dropdownTriggerer","rest","_objectWithoutProperties","_excluded","setIndices","indices","removeOption","index","existingItemIndex","indexOf","concat","_toConsumableArray","slice","selectOption","properties","arguments","length","undefined","closeOnSelection","isSelected","includes","onTriggerClick","onOptionChange","actionType","newIndex","updatedIndex","hasAutoComplete","dropdownComponentIds","triggers","AutoComplete","filteredIndexes","map","filteredValue","findIndex","option","value","sort","a","b","getUpdatedIndex","currentIndex","maxIndex","optionValues","ensureScrollVisiblity","isBrowser","fireNativeEvent","onOptionClick","e","getActionFromKey","isReactNative","_rest$headerAutoCompl","focus","_rest$triggererRef$cu","onComboType","letter","window","clearTimeout","setTimeout","optionTitles","title","searchIndex","getIndexByLetter","onTriggerKeydown","event","key","performAction","selectCurrentOption","_options$activeIndex$","_options$activeIndex","_rest$triggererRef$cu2","onClickTrigger","call","Object","assign","makeInputValue","displayValue","makeInputDisplayValue"],"mappings":";;;;;;;;;;;AAAA,IAAA,SAAA,CAAA,CAAA,QAAA,CAAA,WAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,oBAAA,CAAA,aAAA,CAAA,gBAA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,CAALA,KAAK,CACLC,eAAe,CAAfA,eAAe,CACfC,kBAAkB,CAAlBA,kBAAkB,CAClBK,cAAc,CAAdA,cAAc,CACdsC,YAAY,CAAZA,YAAY,CACZzC,yBAAyB,CAAzBA,yBAAyB,CACzBwD,cAAc,CAAdA,cAAc,CACdyC,gBAAgB,CAAhBA,gBAAgB,CAChBhB,aAAa,CAAbA,aAAa,CACb5E,WAAW,CAAXA,WAAW,CACXC,cAAc,CAAdA,cAAc,CACdC,cAAc,CAAdA,cAAc,CACdC,iBAAiB,CAAjBA,iBAAiB,CACjBmB,mBAAmB,CAAnBA,mBAAmB,CACnBZ,gBAAgB,CAAhBA,gBAAgB,CAChBC,mBAAmB,CAAnBA,mBAAmB,CACnBC,uBAAuB,CAAvBA,uBAAuB,CACvBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,YAAY,CAAZA,YAAY,CACZlB,OAAO,CAAPA,OAAO,CACPqE,KAAK,CAAEuC,cAAc,CAAChH,eAAe,CAAEI,OAAO,CAAC,CAC/C6G,YAAY,CAAEC,qBAAqB,CAAClH,eAAe,CAAEI,OAAO,CAAC,CAC7DiC,aAAa,CAAbA,aAAa,CACbC,iBAAiB,CAAjBA,iBAAiB,CAAA,CACdC,IAAI,CAEX,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"useDropdown.js","sources":["../../../../../src/components/Dropdown/useDropdown.ts"],"sourcesContent":["import React from 'react';\n\nimport {\n ensureScrollVisiblity,\n getActionFromKey,\n getIndexByLetter,\n getUpdatedIndex,\n makeInputDisplayValue,\n makeInputValue,\n performAction,\n} from './dropdownUtils';\nimport type { SelectActionsType } from './dropdownUtils';\nimport type { DropdownProps } from './types';\n\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { FormInputHandleOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { isReactNative, isBrowser } from '~utils';\nimport type { ContainerElementType } from '~utils/types';\nimport { fireNativeEvent } from '~utils/fireNativeEvent';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\ntype OptionsType = {\n title: string;\n value: string;\n onClickTrigger?: (isSelected: boolean) => void;\n}[];\n\n/**\n * Controller published by TreeView when it is rendered as Dropdown overlay content.\n *\n * All tree-specific behaviour inside Dropdown is gated on this being present, so\n * ActionList (and any other overlay content) paths stay behaviourally identical\n */\ntype TreeViewDropdownControllerType = {\n /**\n * Option indices of rows that are currently traversable (not hidden under a collapsed branch).\n * Used for visibility-aware keyboard traversal (same idea as AutoComplete's filteredValues)\n */\n getVisibleOptionIndices: () => number[];\n /**\n * ArrowRight: expand the active collapsed branch, or move to its first child\n */\n onArrowRightKeydown: (activeIndex: number) => void;\n /**\n * ArrowLeft: collapse the active expanded branch, or move to its parent\n */\n onArrowLeftKeydown: (activeIndex: number) => void;\n /**\n * Returns true when the tree handled the selection itself\n * (branch cascade toggle in multiple selection / load-more activation).\n * Returning false falls through to the default selectOption path\n */\n handleOptionSelect: (index: number, properties?: { key?: string }) => boolean;\n /**\n * Values of the topmost fully-selected branches, included in the trigger's onChange payload\n */\n getSelectedGroups: (selectedIndices: number[]) => string[];\n /**\n * Smallest describing set for the trigger display (D5)\n */\n getDisplayOverride: (selectedIndices: number[]) => { label: string; count: number } | undefined;\n};\n\ntype DropdownContextType = {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n close: () => void;\n /**\n * contains the indexes of selected items\n */\n selectedIndices: number[];\n setSelectedIndices: (value: number[]) => void;\n /**\n * contains the indexes of selected items during controlled selection\n */\n controlledValueIndices: number[];\n setControlledValueIndices: (value: number[]) => void;\n /**\n * contains information about all the options inside actionlist\n */\n options: OptionsType;\n setOptions: (value: OptionsType) => void;\n\n /**\n * Filtered values for AutoComplete Inputs\n */\n filteredValues: string[];\n setFilteredValues: (values: string[]) => void;\n\n /** Currently active (focussed) index */\n activeIndex: number;\n setActiveIndex: (value: number) => void;\n\n /** Currently active (focussed) tag */\n activeTagIndex: number;\n setActiveTagIndex: (value: number) => void;\n\n /**\n * Sometimes we want to ignore the blur event to keep dropdown open but not ignore the blur animation from selectinput\n * E.g. When someone clicks on Footer, we just want to ignore the blur event and not the blur animation\n */\n shouldIgnoreBlurAnimation: boolean;\n setShouldIgnoreBlurAnimation: (value: boolean) => void;\n /** Tells you if keyboard was used. Its false by default and turns into true when keydown is called */\n isKeydownPressed: boolean;\n setIsKeydownPressed: (value: boolean) => void;\n /** common baseId which is prepended to multiple other ids inside this dropdown */\n dropdownBaseId: string;\n /** Which element has triggered the dropdown */\n dropdownTriggerer?:\n | 'SelectInput'\n | 'DropdownButton'\n | 'DropdownIconButton'\n | 'AutoComplete'\n | 'DropdownLink'\n | 'SearchInput'\n | 'FilterChipSelectInput'\n | 'InputDropdownButton';\n\n /** ref of triggerer. Used to call focus in certain places */\n triggererRef: React.MutableRefObject<HTMLButtonElement | null>;\n headerAutoCompleteRef: React.MutableRefObject<HTMLButtonElement | null>;\n triggererWrapperRef: React.MutableRefObject<ContainerElementType | null>;\n actionListItemRef: React.RefObject<HTMLDivElement | null>;\n isTagDismissedRef: React.RefObject<{ value: boolean } | null>;\n visibleTagsCountRef: React.RefObject<{ value: number } | null>;\n\n selectionType?: DropdownProps['selectionType'];\n /** whether footer has an action item.\n * certain a11y behaviour changes happen here\n * E.g. tabbing moves focus to that action instead of outside\n */\n hasFooterAction: boolean;\n setHasFooterAction: (value: boolean) => void;\n\n /**\n * Apart from dropdownTriggerer prop, we also set this boolean because in BottomSheetHeader and DropdownHeader, the trigger can be Select but they can also have autocomplete inside of header\n */\n hasAutoCompleteInHeader: boolean;\n setHasAutoCompleteInHeader: (value: boolean) => void;\n\n /**\n * A value that can be used in dependency array to know when Dropdown value is changed.\n *\n * E.g.\n * ```ts\n * useEffect(() => {\n * console.log('Uncontrolled value change');\n * }, [changeCallbackTriggerer])\n * ```\n */\n changeCallbackTriggerer: number;\n setChangeCallbackTriggerer: (changeCallbackTriggerer: number) => void;\n\n /**\n * true when SelectInput has `value` prop (when it is controlled)\n */\n isControlled: boolean;\n setIsControlled: (isControlled: boolean) => void;\n\n /**\n * Set by TreeView when it is rendered as the overlay content. null for every other\n * overlay content (ActionList, Menu, custom slots)\n */\n treeViewControllerRef: React.MutableRefObject<TreeViewDropdownControllerType | null>;\n};\n\nconst DropdownContext = React.createContext<DropdownContextType>({\n isOpen: false,\n setIsOpen: noop,\n close: noop,\n selectedIndices: [],\n setSelectedIndices: noop,\n controlledValueIndices: [],\n setControlledValueIndices: noop,\n options: [],\n setOptions: noop,\n filteredValues: [],\n setFilteredValues: noop,\n activeIndex: -1,\n setActiveIndex: noop,\n activeTagIndex: -1,\n setActiveTagIndex: noop,\n shouldIgnoreBlurAnimation: false,\n setShouldIgnoreBlurAnimation: noop,\n hasFooterAction: false,\n setHasFooterAction: noop,\n hasAutoCompleteInHeader: false,\n setHasAutoCompleteInHeader: noop,\n isKeydownPressed: false,\n setIsKeydownPressed: noop,\n changeCallbackTriggerer: 0,\n setChangeCallbackTriggerer: noop,\n isControlled: false,\n setIsControlled: noop,\n dropdownBaseId: '',\n actionListItemRef: {\n current: null,\n },\n triggererRef: {\n current: null,\n },\n headerAutoCompleteRef: {\n current: null,\n },\n isTagDismissedRef: {\n current: null,\n },\n visibleTagsCountRef: {\n current: null,\n },\n triggererWrapperRef: {\n current: null,\n },\n treeViewControllerRef: {\n current: null,\n },\n});\n\nlet searchTimeout: number;\nlet searchString = '';\n\ntype UseDropdownReturnValue = DropdownContextType & {\n /**\n * Click event on combobox. Toggles the dropdown\n */\n onTriggerClick: () => void;\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n onTriggerKeydown: FormInputHandleOnKeyDownEvent | undefined;\n\n /**\n * Handles the click even on option.\n *\n * Contains the logic that selects the option, moves the focus, etc\n */\n onOptionClick: (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ) => void;\n\n /**\n * Removes the option with given optionsIndex\n */\n removeOption: (index: number) => void;\n\n /**\n * Selects / deselects multiple options in one state update with a single onChange.\n * Used by TreeView branch cascade toggles\n */\n selectOptionsBatch: (indices: number[], action: 'select' | 'deselect') => void;\n\n /**\n * value that is used during form submissions\n */\n value: string;\n /**\n * This is the value that is displayed inside select after selection\n */\n displayValue: string;\n};\n\n/**\n * Handles almost all the functionality of dropdown.\n *\n * Returns the values from DropdownContext along with some helper functions and event handlers\n *\n */\nconst useDropdown = (): UseDropdownReturnValue => {\n const {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n options,\n selectionType,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setControlledValueIndices,\n filteredValues,\n dropdownTriggerer,\n ...rest\n } = React.useContext(DropdownContext);\n\n type SelectOptionType = (\n index: number,\n properties?: {\n closeOnSelection?: boolean;\n },\n ) => boolean;\n\n const setIndices = (indices: number[]): void => {\n if (isControlled) {\n setControlledValueIndices(indices);\n } else {\n setSelectedIndices(indices);\n }\n };\n\n const removeOption = (index: number): void => {\n // remove existing item\n const existingItemIndex = selectedIndices.indexOf(index);\n if (existingItemIndex < 0) {\n return;\n }\n\n setIndices([\n ...selectedIndices.slice(0, existingItemIndex),\n ...selectedIndices.slice(existingItemIndex + 1),\n ]);\n };\n\n /**\n * Marks the given index as selected.\n *\n * In single select, it also closes the menu.\n * In multiselect, it keeps the menu open for more selections\n */\n const selectOption: SelectOptionType = (\n index,\n properties = {\n closeOnSelection: true,\n },\n ) => {\n let isSelected = false;\n\n if (index < 0 || index > options.length - 1) {\n return isSelected;\n }\n\n if (selectionType === 'multiple') {\n if (selectedIndices.includes(index)) {\n removeOption(index);\n isSelected = false;\n } else {\n setIndices([...selectedIndices, index]);\n isSelected = true;\n }\n } else {\n setIndices([index]);\n isSelected = true;\n }\n\n // Triggers `onChange` on SelectInput\n setChangeCallbackTriggerer(changeCallbackTriggerer + 1);\n\n if (activeIndex !== index) {\n setActiveIndex(index);\n }\n\n if (properties?.closeOnSelection && selectionType !== 'multiple') {\n close();\n }\n\n return isSelected;\n };\n\n /**\n * Marks multiple indices as selected / deselected in a single state update and\n * bumps the change callback triggerer exactly once.\n *\n * Used by TreeView for branch cascade toggles (one branch toggle mutates many leaf\n * indices but must fire a single `onChange`). Routes through the same controlled /\n * uncontrolled fork as `selectOption`. ActionList does not use this\n */\n const selectOptionsBatch = (indices: number[], action: 'select' | 'deselect'): void => {\n if (indices.length === 0) {\n return;\n }\n\n let updatedIndices: number[];\n if (action === 'select') {\n updatedIndices = [...selectedIndices];\n for (const index of indices) {\n if (index >= 0 && index <= options.length - 1 && !updatedIndices.includes(index)) {\n updatedIndices.push(index);\n }\n }\n } else {\n updatedIndices = selectedIndices.filter((selectedIndex) => !indices.includes(selectedIndex));\n }\n\n setIndices(updatedIndices);\n setChangeCallbackTriggerer(changeCallbackTriggerer + 1);\n };\n\n /**\n * Click listener for combobox (or any triggerer of the dropdown)\n */\n const onTriggerClick = (): void => {\n if (isOpen) {\n close();\n } else {\n setIsOpen(true);\n }\n };\n\n /**\n * Function that we call when we want to move focus from one option to other\n */\n const onOptionChange = (actionType: SelectActionsType, index?: number): void => {\n setActiveTagIndex(-1);\n const newIndex = index ?? activeIndex;\n let updatedIndex: number;\n const hasAutoComplete =\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete;\n const treeViewController = rest.treeViewControllerRef?.current;\n if (treeViewController) {\n // When overlay content is a TreeView, traversal skips rows hidden under collapsed\n // branches (indices stay stable across expand / collapse, only traversal changes)\n const visibleIndexes = treeViewController.getVisibleOptionIndices();\n updatedIndex =\n visibleIndexes[\n getUpdatedIndex({\n currentIndex: visibleIndexes.indexOf(newIndex),\n maxIndex: visibleIndexes.length - 1,\n actionType,\n })\n ] ?? newIndex;\n } else if (hasAutoComplete && filteredValues.length > 0) {\n // When its autocomplete, we don't loop over all options. We only loop on filtered options\n\n const filteredIndexes = filteredValues\n .map((filteredValue) => options.findIndex((option) => option.value === filteredValue))\n .sort((a, b) => a - b);\n\n updatedIndex =\n filteredIndexes[\n getUpdatedIndex({\n currentIndex: filteredIndexes.indexOf(newIndex),\n maxIndex: filteredIndexes.length - 1,\n actionType,\n })\n ];\n } else {\n updatedIndex = getUpdatedIndex({\n currentIndex: newIndex,\n maxIndex: options.length - 1,\n actionType,\n });\n }\n setActiveIndex(updatedIndex);\n\n const optionValues = options.map((option) => option.value);\n ensureScrollVisiblity(updatedIndex, rest.actionListItemRef.current, optionValues);\n if (isBrowser()) {\n fireNativeEvent(rest.actionListItemRef as React.RefObject<HTMLElement>, ['change', 'input']);\n }\n };\n\n /**\n * Click handler when user clicks on any particular option.\n *\n * It\n * - changes the option focus\n * - selects that option\n * - moves focus to combobox\n */\n const onOptionClick = (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ): void => {\n setIsKeydownPressed(false);\n const actionType = getActionFromKey(e, isOpen, dropdownTriggerer);\n if (typeof actionType === 'number') {\n onOptionChange(actionType, index);\n }\n selectOption(index);\n\n if (!isReactNative()) {\n if (rest.hasAutoCompleteInHeader) {\n // move focus to autocomplete\n rest.headerAutoCompleteRef.current?.focus();\n } else {\n rest.triggererRef.current?.focus();\n }\n }\n };\n\n /**\n * Function we call to handle the typeahead.\n *\n * It takes a letter, stores that letter in searchString (and clears it after timeout) to maintain a word\n *\n * Then searches for that word in options and moves focus there.\n */\n const onComboType = (letter: string, actionType: SelectActionsType): void => {\n // open the listbox if it is closed\n setIsOpen(true);\n\n if (\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete\n ) {\n return;\n }\n\n if (typeof searchTimeout === 'number') {\n window.clearTimeout(searchTimeout);\n }\n\n searchTimeout = window.setTimeout(() => {\n searchString = '';\n }, 500);\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n searchString = searchString + letter;\n const optionTitles = options.map((option) => option.title);\n const searchIndex = getIndexByLetter(optionTitles, searchString, activeIndex + 1);\n\n // if a match was found, go to it\n if (searchIndex >= 0) {\n onOptionChange(actionType, searchIndex);\n }\n // if no matches, clear the timeout and search string\n else {\n window.clearTimeout(searchTimeout);\n searchString = '';\n }\n };\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n const onTriggerKeydown = (e: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n }): void => {\n if (!isKeydownPressed && ![' ', 'Enter', 'Escape', 'Meta'].includes(e.event.key)) {\n // When keydown is not already pressed and its not Enter, Space, Command, or Escape key (those are generic keys and we only want to handle arrow keys or home buttons etc)\n setIsKeydownPressed(true);\n }\n\n const actionType = getActionFromKey(e.event, isOpen, dropdownTriggerer);\n\n if (actionType) {\n performAction(actionType, e, {\n setIsOpen,\n close,\n onOptionChange,\n onComboType,\n selectCurrentOption: (event) => {\n if (activeIndex < 0) {\n return;\n }\n\n // TreeView handles branch cascade toggles and load-more rows itself\n const treeViewController = rest.treeViewControllerRef?.current;\n if (treeViewController?.handleOptionSelect(activeIndex, { key: event?.key })) {\n return;\n }\n\n const isSelected = selectOption(activeIndex);\n if (rest.hasFooterAction && !isReactNative()) {\n rest.triggererRef.current?.focus();\n }\n\n options[activeIndex].onClickTrigger?.(isSelected);\n },\n // present only when overlay content is a TreeView; undefined keeps\n // ArrowLeft / ArrowRight behaviour unchanged for every other content\n onTreeExpandCollapse: rest.treeViewControllerRef?.current\n ? (action) => {\n if (action === 'Expand') {\n rest.treeViewControllerRef.current?.onArrowRightKeydown(activeIndex);\n } else {\n rest.treeViewControllerRef.current?.onArrowLeftKeydown(activeIndex);\n }\n }\n : undefined,\n });\n }\n };\n\n return {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n filteredValues,\n removeOption,\n selectOptionsBatch,\n setControlledValueIndices,\n onTriggerClick,\n onTriggerKeydown,\n onOptionClick,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n options,\n value: makeInputValue(selectedIndices, options),\n displayValue: makeInputDisplayValue(\n selectedIndices,\n options,\n rest.treeViewControllerRef?.current?.getDisplayOverride(selectedIndices),\n ),\n selectionType,\n dropdownTriggerer,\n ...rest,\n };\n};\n\nexport type { DropdownContextType, OptionsType, TreeViewDropdownControllerType };\nexport { useDropdown, DropdownContext };\n"],"names":["noop","DropdownContext","React","createContext","isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","controlledValueIndices","setControlledValueIndices","options","setOptions","filteredValues","setFilteredValues","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","hasFooterAction","setHasFooterAction","hasAutoCompleteInHeader","setHasAutoCompleteInHeader","isKeydownPressed","setIsKeydownPressed","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setIsControlled","dropdownBaseId","actionListItemRef","current","triggererRef","headerAutoCompleteRef","isTagDismissedRef","visibleTagsCountRef","triggererWrapperRef","treeViewControllerRef","searchTimeout","searchString","useDropdown","_rest$treeViewControl6","_rest$treeViewControl7","_React$useContext","useContext","selectionType","dropdownTriggerer","rest","_objectWithoutProperties","_excluded","setIndices","indices","removeOption","index","existingItemIndex","indexOf","concat","_toConsumableArray","slice","selectOption","properties","arguments","length","undefined","closeOnSelection","isSelected","includes","selectOptionsBatch","action","updatedIndices","push","filter","selectedIndex","onTriggerClick","onOptionChange","actionType","_rest$treeViewControl","newIndex","updatedIndex","hasAutoComplete","dropdownComponentIds","triggers","AutoComplete","treeViewController","_visibleIndexes$getUp","visibleIndexes","getVisibleOptionIndices","getUpdatedIndex","currentIndex","maxIndex","filteredIndexes","map","filteredValue","findIndex","option","value","sort","a","b","optionValues","ensureScrollVisiblity","isBrowser","fireNativeEvent","onOptionClick","e","getActionFromKey","isReactNative","_rest$headerAutoCompl","focus","_rest$triggererRef$cu","onComboType","letter","window","clearTimeout","setTimeout","optionTitles","title","searchIndex","getIndexByLetter","onTriggerKeydown","event","key","_rest$treeViewControl3","performAction","selectCurrentOption","_rest$treeViewControl2","_options$activeIndex$","_options$activeIndex","handleOptionSelect","_rest$triggererRef$cu2","onClickTrigger","call","onTreeExpandCollapse","_rest$treeViewControl4","onArrowRightKeydown","_rest$treeViewControl5","onArrowLeftKeydown","Object","assign","makeInputValue","displayValue","makeInputDisplayValue","getDisplayOverride"],"mappings":";;;;;;;;;;;wXAqBA,IAAMA,IAAI,CAAG,SAAPA,IAAIA,EAAe,EAAE,CAoJrB,IAAAC,eAAe,CAAGC,cAAK,CAACC,aAAa,CAAsB,CAC/DC,MAAM,CAAE,KAAK,CACbC,SAAS,CAAEL,IAAI,CACfM,KAAK,CAAEN,IAAI,CACXO,eAAe,CAAE,EAAE,CACnBC,kBAAkB,CAAER,IAAI,CACxBS,sBAAsB,CAAE,EAAE,CAC1BC,yBAAyB,CAAEV,IAAI,CAC/BW,OAAO,CAAE,EAAE,CACXC,UAAU,CAAEZ,IAAI,CAChBa,cAAc,CAAE,EAAE,CAClBC,iBAAiB,CAAEd,IAAI,CACvBe,WAAW,CAAE,CAAC,CAAC,CACfC,cAAc,CAAEhB,IAAI,CACpBiB,cAAc,CAAE,CAAC,CAAC,CAClBC,iBAAiB,CAAElB,IAAI,CACvBmB,yBAAyB,CAAE,KAAK,CAChCC,4BAA4B,CAAEpB,IAAI,CAClCqB,eAAe,CAAE,KAAK,CACtBC,kBAAkB,CAAEtB,IAAI,CACxBuB,uBAAuB,CAAE,KAAK,CAC9BC,0BAA0B,CAAExB,IAAI,CAChCyB,gBAAgB,CAAE,KAAK,CACvBC,mBAAmB,CAAE1B,IAAI,CACzB2B,uBAAuB,CAAE,CAAC,CAC1BC,0BAA0B,CAAE5B,IAAI,CAChC6B,YAAY,CAAE,KAAK,CACnBC,eAAe,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KAAK,CAALA,KAAK,CACLC,eAAe,CAAfA,eAAe,CACfC,kBAAkB,CAAlBA,kBAAkB,CAClBK,cAAc,CAAdA,cAAc,CACdyC,YAAY,CAAZA,YAAY,CACZe,kBAAkB,CAAlBA,kBAAkB,CAClB3D,yBAAyB,CAAzBA,yBAAyB,CACzBiE,cAAc,CAAdA,cAAc,CACd8C,gBAAgB,CAAhBA,gBAAgB,CAChBhB,aAAa,CAAbA,aAAa,CACb1F,WAAW,CAAXA,WAAW,CACXC,cAAc,CAAdA,cAAc,CACdC,cAAc,CAAdA,cAAc,CACdC,iBAAiB,CAAjBA,iBAAiB,CACjBmB,mBAAmB,CAAnBA,mBAAmB,CACnBZ,gBAAgB,CAAhBA,gBAAgB,CAChBC,mBAAmB,CAAnBA,mBAAmB,CACnBC,uBAAuB,CAAvBA,uBAAuB,CACvBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,YAAY,CAAZA,YAAY,CACZlB,OAAO,CAAPA,OAAO,CACPsF,KAAK,CAAE4C,cAAc,CAACtI,eAAe,CAAEI,OAAO,CAAC,CAC/CmI,YAAY,CAAEC,qBAAqB,CACjCxI,eAAe,CACfI,OAAO,CAAA,CAAAgC,sBAAA,CACPM,IAAI,CAACV,qBAAqB,GAAAK,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,sBAAA,CAA1BD,sBAAA,CAA4BV,OAAO,GAAA,IAAA,CAAA,KAAA,CAAA,CAAnCW,sBAAA,CAAqCoG,kBAAkB,CAACzI,eAAe,CACzE,CAAC,CACDwC,aAAa,CAAbA,aAAa,CACbC,iBAAiB,CAAjBA,iBAAiB,CAAA,CACdC,IAAI,CAAA,CAEX;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '
|
|
1
|
+
import 'react';
|
|
2
|
+
import '../BaseMotion/index.js';
|
|
3
|
+
import '../../utils/index.js';
|
|
4
|
+
import { msToSeconds } from '../../utils/msToSeconds.js';
|
|
3
5
|
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
+
import useTheme from '../BladeProvider/useTheme.js';
|
|
7
|
+
import { BaseMotionEntryExit } from '../BaseMotion/BaseMotion.native.js';
|
|
6
8
|
|
|
7
|
-
var _this=undefined,_jsxFileName="/home/runner/work/blade/blade/packages/blade/src/components/Fade/Fade.native.tsx";var Fade=function Fade(
|
|
9
|
+
var _this=undefined,_jsxFileName="/home/runner/work/blade/blade/packages/blade/src/components/Fade/Fade.native.tsx";var ENTRANCE_EASING=[0,0,0.2,1];var EXIT_EASING=[0.17,0,1,1];var Fade=function Fade(_ref){var children=_ref.children,isVisible=_ref.isVisible,_ref$type=_ref.type,type=_ref$type===void 0?'inout':_ref$type,_ref$motionTriggers=_ref.motionTriggers,motionTriggers=_ref$motionTriggers===void 0?['mount']:_ref$motionTriggers,shouldUnmountWhenHidden=_ref.shouldUnmountWhenHidden,delay=_ref.delay;var _useTheme=useTheme(),theme=_useTheme.theme;var enterDelay=typeof delay==='object'?delay.enter:delay;var exitDelay=typeof delay==='object'?delay.exit:delay;var fadeVariants={initial:{opacity:0},animate:{opacity:1,transition:Object.assign({},enterDelay?{delay:msToSeconds(theme.motion.delay[enterDelay])}:{},{duration:msToSeconds(theme.motion.duration.xquick),ease:ENTRANCE_EASING})},exit:{opacity:0,transition:Object.assign({},exitDelay?{delay:msToSeconds(theme.motion.delay[exitDelay])}:{},{duration:msToSeconds(theme.motion.duration.xquick),ease:EXIT_EASING})}};return jsx(BaseMotionEntryExit,{motionVariants:fadeVariants,type:type,isVisible:isVisible,motionTriggers:motionTriggers,shouldUnmountWhenHidden:shouldUnmountWhenHidden,children:children});};
|
|
8
10
|
|
|
9
11
|
export { Fade };
|
|
10
12
|
//# sourceMappingURL=Fade.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fade.native.js","sources":["../../../../../src/components/Fade/Fade.native.tsx"],"sourcesContent":["import type { FadeProps } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"Fade.native.js","sources":["../../../../../src/components/Fade/Fade.native.tsx"],"sourcesContent":["import React from 'react';\nimport type { FadeProps } from './types';\nimport { BaseMotionEntryExit } from '~components/BaseMotion';\nimport type { MotionVariantsType } from '~components/BaseMotion';\nimport { useTheme } from '~utils';\nimport { msToSeconds } from '~utils/msToSeconds';\n\n/**\n * On native, `theme.motion.easing.*` resolves to a reanimated `EasingFactoryFn` (not a\n * `cubic-bezier(...)` string), so the web approach of `cssBezierToArray(castWebType(...))` would\n * crash. Instead we supply `ease` as the 4-number bezier control-point array that the native\n * interpreter's `getTiming` feeds into `Easing.bezier(...ease)`.\n *\n * These arrays mirror the exact control points of the `entrance` / `exit` easing tokens defined in\n * `~tokens/global/motion`:\n * - entrance → `cubic-bezier(0, 0, 0.2, 1)`\n * - exit → `cubic-bezier(0.17, 0, 1, 1)`\n *\n * **Sync risk:** These are hardcoded duplicates of the token values. If the token definitions\n * change, these arrays must be updated manually. The same pattern exists in `Move.native.tsx`\n * and `Scale.native.tsx`. There is currently no automated sync mechanism — a unit test should be\n * added to assert these arrays match the token definitions.\n */\nconst ENTRANCE_EASING: [number, number, number, number] = [0, 0, 0.2, 1];\nconst EXIT_EASING: [number, number, number, number] = [0.17, 0, 1, 1];\n\n/**\n * ## Fade\n *\n * Fade is one of the motion presets that we expose from blade to help you fade in / fade out components easily.\n *\n * ### Usage\n *\n * #### Fade in on mount\n *\n * ```jsx\n * <Fade>\n * <Card />\n * </Fade>\n * ```\n *\n * #### Conditionally fade based on state\n *\n * ```jsx\n * <Fade isVisible={isVisibleState}>\n * <Card />\n * </Fade>\n * ```\n */\nconst Fade = ({\n children,\n isVisible,\n type = 'inout',\n motionTriggers = ['mount'],\n shouldUnmountWhenHidden,\n delay,\n}: FadeProps): React.ReactElement => {\n const { theme } = useTheme();\n const enterDelay = typeof delay === 'object' ? delay.enter : delay;\n const exitDelay = typeof delay === 'object' ? delay.exit : delay;\n\n const fadeVariants: MotionVariantsType = {\n initial: {\n opacity: 0,\n },\n animate: {\n opacity: 1,\n transition: {\n // We have to make sure we don't add delay prop because if we define it, it takes precedence in stagger.\n // Even setting `undefined` would break the stagger\n ...(enterDelay ? { delay: msToSeconds(theme.motion.delay[enterDelay]) } : {}),\n duration: msToSeconds(theme.motion.duration.xquick),\n ease: ENTRANCE_EASING,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n ...(exitDelay ? { delay: msToSeconds(theme.motion.delay[exitDelay]) } : {}),\n duration: msToSeconds(theme.motion.duration.xquick),\n ease: EXIT_EASING,\n },\n },\n };\n\n return (\n <BaseMotionEntryExit\n motionVariants={fadeVariants}\n type={type}\n isVisible={isVisible}\n motionTriggers={motionTriggers}\n shouldUnmountWhenHidden={shouldUnmountWhenHidden}\n children={children}\n />\n );\n};\n\nexport { Fade };\n"],"names":["this","ENTRANCE_EASING","EXIT_EASING","Fade","_ref","children","isVisible","_ref$type","type","_ref$motionTriggers","motionTriggers","shouldUnmountWhenHidden","delay","_useTheme","useTheme","theme","enterDelay","enter","exitDelay","exit","fadeVariants","initial","opacity","animate","transition","Object","assign","msToSeconds","motion","duration","xquick","ease","_jsx","BaseMotionEntryExit","motionVariants"],"mappings":";;;;;;;;AAAA,IAAA,KAAA,CAAAA,SAAA,CAAA,YAAA,CAAA,kFAAA,CAuBA,IAAMC,eAAiD,CAAG,CAAC,CAAC,CAAE,CAAC,CAAE,GAAG,CAAE,CAAC,CAAC,CACxE,IAAMC,WAA6C,CAAG,CAAC,IAAI,CAAE,CAAC,CAAE,CAAC,CAAE,CAAC,CAAC,CAyB/D,IAAAC,IAAI,CAAG,SAAPA,IAAIA,CAAAC,IAAA,CAO2B,CANnC,IAAAC,QAAQ,CAAAD,IAAA,CAARC,QAAQ,CACRC,SAAS,CAAAF,IAAA,CAATE,SAAS,CAAAC,SAAA,CAAAH,IAAA,CACTI,IAAI,CAAJA,IAAI,CAAAD,SAAA,GAAA,KAAA,CAAA,CAAG,OAAO,CAAAA,S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AAE7B,WAAW,CAAA,CAErB,CACF,CAAC,CAED,OACE8B,GAAA,CAACC,mBAAmB,CAClBC,CAAAA,cAAc,CAAEd,YAAa,CAC7BZ,IAAI,CAAEA,IAAK,CACXF,SAAS,CAAEA,SAAU,CACrBI,cAAc,CAAEA,cAAe,CAC/BC,uBAAuB,CAAEA,uBAAwB,CACjDN,QAAQ,CAAEA,QAAS,CACpB,CAAC,CAEN;;;;"}
|
|
@@ -19,9 +19,9 @@ import '../BladeProvider/index.js';
|
|
|
19
19
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
20
20
|
import { size } from '../../tokens/global/size.js';
|
|
21
21
|
import { makeBorderSize } from '../../utils/makeBorderSize/makeBorderSize.native.js';
|
|
22
|
+
import { Text } from '../Typography/Text/Text.js';
|
|
22
23
|
import { Box } from '../Box/Box.js';
|
|
23
24
|
import { Counter } from '../Counter/Counter.js';
|
|
24
|
-
import { Text } from '../Typography/Text/Text.js';
|
|
25
25
|
import useTheme from '../BladeProvider/useTheme.js';
|
|
26
26
|
import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.native.js';
|
|
27
27
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
@@ -32,7 +32,7 @@ import CloseIcon from '../Icons/CloseIcon/CloseIcon.js';
|
|
|
32
32
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
33
33
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
34
34
|
|
|
35
|
-
var _excluded=["value","onClearButtonClick","label","isDisabled","selectionType","onClick","onKeyDown","accessibilityProps","id"];var _this=undefined,_jsxFileName="/home/runner/work/blade/blade/packages/blade/src/components/FilterChip/BaseFilterChip.native.tsx";var FILTER_CHIP_HEIGHT_NATIVE=size['28'];var DashedBorder=function DashedBorder(_ref){var width=_ref.width,height=_ref.height,borderRadius=_ref.borderRadius,strokeWidth=_ref.strokeWidth,color=_ref.color;if(width<=0||height<=0){return null;}var inset=strokeWidth/2;var rectWidth=width-strokeWidth;var rectHeight=height-strokeWidth;var radius=Math.max(borderRadius-inset,0);var straightWidth=Math.max(rectWidth-2*radius,0);var straightHeight=Math.max(rectHeight-2*radius,0);var perimeter=2*straightWidth+2*straightHeight+2*Math.PI*radius;var targetSegment=4;var segmentCount=Math.max(1,Math.round(perimeter/targetSegment));var segmentLength=perimeter/segmentCount;var dashLength=segmentLength/2;return jsx(View,{style:StyleSheet.absoluteFill,pointerEvents:"none",children:jsx(Svg,{width:width,height:height,children:jsx(Rect,{x:inset,y:inset,width:rectWidth,height:rectHeight,rx:radius,ry:radius,fill:"none",stroke:color,strokeWidth:strokeWidth,strokeDasharray:[dashLength,segmentLength-dashLength]})})});};var StyledFilterChip=styled(View)(function(_ref2){var theme=_ref2.theme,$isDisabled=_ref2.$isDisabled,$isSelected=_ref2.$isSelected;return {borderWidth:$isSelected?makeBorderSize(theme.border.width.thin):0,borderColor:$isSelected?theme.colors.interactive.border.gray[$isDisabled?'disabled':'faded']:'transparent',height:FILTER_CHIP_HEIGHT_NATIVE,borderRadius:theme.border.radius.small,borderStyle:'solid',backgroundColor:theme.colors.surface.background.gray.intense,flexDirection:'row',alignSelf:'flex-start',overflow:$isSelected?'hidden':'visible'};});var StyledFilterTrigger=styled(Pressable)(function(_ref3){var theme=_ref3.theme,$
|
|
35
|
+
var _excluded=["value","onClearButtonClick","label","isDisabled","selectionType","showClearButton","onClick","onKeyDown","accessibilityProps","id"];var _this=undefined,_jsxFileName="/home/runner/work/blade/blade/packages/blade/src/components/FilterChip/BaseFilterChip.native.tsx";var FILTER_CHIP_HEIGHT_NATIVE=size['28'];var DashedBorder=function DashedBorder(_ref){var width=_ref.width,height=_ref.height,borderRadius=_ref.borderRadius,strokeWidth=_ref.strokeWidth,color=_ref.color;if(width<=0||height<=0){return null;}var inset=strokeWidth/2;var rectWidth=width-strokeWidth;var rectHeight=height-strokeWidth;var radius=Math.max(borderRadius-inset,0);var straightWidth=Math.max(rectWidth-2*radius,0);var straightHeight=Math.max(rectHeight-2*radius,0);var perimeter=2*straightWidth+2*straightHeight+2*Math.PI*radius;var targetSegment=4;var segmentCount=Math.max(1,Math.round(perimeter/targetSegment));var segmentLength=perimeter/segmentCount;var dashLength=segmentLength/2;return jsx(View,{style:StyleSheet.absoluteFill,pointerEvents:"none",children:jsx(Svg,{width:width,height:height,children:jsx(Rect,{x:inset,y:inset,width:rectWidth,height:rectHeight,rx:radius,ry:radius,fill:"none",stroke:color,strokeWidth:strokeWidth,strokeDasharray:[dashLength,segmentLength-dashLength]})})});};var StyledFilterChip=styled(View)(function(_ref2){var theme=_ref2.theme,$isDisabled=_ref2.$isDisabled,$isSelected=_ref2.$isSelected;return {borderWidth:$isSelected?makeBorderSize(theme.border.width.thin):0,borderColor:$isSelected?theme.colors.interactive.border.gray[$isDisabled?'disabled':'faded']:'transparent',height:FILTER_CHIP_HEIGHT_NATIVE,borderRadius:theme.border.radius.small,borderStyle:'solid',backgroundColor:theme.colors.surface.background.gray.intense,flexDirection:'row',alignSelf:'flex-start',overflow:$isSelected?'hidden':'visible'};});var StyledFilterTrigger=styled(Pressable)(function(_ref3){var theme=_ref3.theme,$hasClearButton=_ref3.$hasClearButton;var spacing=theme.spacing;return {backgroundColor:'transparent',borderRadius:$hasClearButton?0:theme.border.radius.small,borderTopLeftRadius:theme.border.radius.small,borderBottomLeftRadius:theme.border.radius.small,paddingLeft:spacing[4],paddingRight:$hasClearButton?spacing[2]:spacing[3],flexDirection:'row',alignItems:'center',height:'100%',gap:spacing[2]};});var StyledFilterCloseButton=styled(Pressable)(function(_ref4){var theme=_ref4.theme;return {backgroundColor:'transparent',borderTopRightRadius:theme.border.radius.small,borderBottomRightRadius:theme.border.radius.small,paddingLeft:theme.spacing[2]+theme.spacing[1],paddingRight:theme.spacing[2]+theme.spacing[1],justifyContent:'center',alignItems:'center',height:'100%'};});var renderValue=function renderValue(selectionType,value,isDisabled){var valueColor=isDisabled?'interactive.text.gray.disabled':'interactive.text.gray.normal';if(selectionType==='multiple'){var valueArray=Array.isArray(value)?value:value!=null?[value]:[];if(valueArray.length===1){var _valueArray$;return jsx(Text,{size:"small",weight:"medium",color:valueColor,truncateAfterLines:1,children:String((_valueArray$=valueArray[0])!=null?_valueArray$:'')});}return jsx(Box,{alignItems:"center",flexDirection:"row",children:jsx(Counter,{value:valueArray.length,color:"neutral",size:"small"})});}return jsx(Text,{size:"small",weight:"medium",color:valueColor,children:value!=null?String(value):''});};var _BaseFilterChip=function _BaseFilterChip(_ref5,ref){var _accessibilityProps$r;var value=_ref5.value,onClearButtonClick=_ref5.onClearButtonClick,label=_ref5.label,isDisabled=_ref5.isDisabled,_ref5$selectionType=_ref5.selectionType,selectionType=_ref5$selectionType===void 0?'single':_ref5$selectionType,_ref5$showClearButton=_ref5.showClearButton,showClearButton=_ref5$showClearButton===void 0?true:_ref5$showClearButton,onClick=_ref5.onClick,onKeyDown=_ref5.onKeyDown,accessibilityProps=_ref5.accessibilityProps,id=_ref5.id,rest=_objectWithoutProperties(_ref5,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var isSelected=selectionType==='multiple'?Array.isArray(value)&&value.length>0:!!value;var shouldShowClearButton=isSelected&&showClearButton;var _React$useState=React__default.useState({width:0,height:0}),_React$useState2=_slicedToArray(_React$useState,2),chipSize=_React$useState2[0],setChipSize=_React$useState2[1];var handleLayout=function handleLayout(event){var _event$nativeEvent$la=event.nativeEvent.layout,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height;setChipSize(function(prev){return prev.width===width&&prev.height===height?prev:{width:width,height:height};});};return jsxs(StyledFilterChip,{$isDisabled:isDisabled,$isSelected:isSelected,ref:ref,onLayout:isSelected?undefined:handleLayout,children:[jsxs(StyledFilterTrigger,Object.assign({$hasClearButton:shouldShowClearButton,disabled:isDisabled,id:id,onPress:isDisabled?undefined:function(e){onClick==null?void 0:onClick(e);},onKeyDown:isDisabled?undefined:function(e){onKeyDown==null?void 0:onKeyDown(e);}},makeAccessible(Object.assign({},accessibilityProps,{role:(_accessibilityProps$r=accessibilityProps==null?void 0:accessibilityProps.role)!=null?_accessibilityProps$r:'button'})),makeAnalyticsAttribute(rest),metaAttribute({name:'filter-chip-trigger',testID:rest.testID}),{children:[jsxs(Box,{flexDirection:"row",gap:"spacing.2",alignItems:"center",children:[jsxs(Text,{size:"small",weight:"medium",color:"interactive.text.gray.subtle",truncateAfterLines:1,children:[label,isSelected?':':null]}),isSelected?renderValue(selectionType,value,isDisabled):null]}),jsx(Box,{flexDirection:"row",alignItems:"center",paddingRight:"spacing.1",children:jsx(ChevronDownIcon,{size:"small",color:"interactive.icon.gray.muted"})})]})),shouldShowClearButton?jsxs(Fragment,{children:[jsx(Divider,{orientation:"vertical",variant:isDisabled?'muted':'subtle'}),jsx(StyledFilterCloseButton,Object.assign({},makeAccessible({label:`Clear ${label} value`,role:'button'}),{onPress:isDisabled?undefined:function(){return onClearButtonClick==null?void 0:onClearButtonClick({value:value!=null?value:''});},disabled:isDisabled},metaAttribute({name:'filter-chip-close-button'}),{children:jsx(CloseIcon,{size:"small",color:"interactive.icon.gray.muted"})}))]}):null,isSelected?null:jsx(DashedBorder,{width:chipSize.width,height:chipSize.height,borderRadius:theme.border.radius.small,strokeWidth:makeBorderSize(theme.border.width.thin),color:theme.colors.interactive.border.gray[isDisabled?'disabled':'faded']})]});};var BaseFilterChip=assignWithoutSideEffects(React__default.forwardRef(_BaseFilterChip),{componentId:MetaConstants.BaseFilterChip});
|
|
36
36
|
|
|
37
37
|
export { BaseFilterChip };
|
|
38
38
|
//# sourceMappingURL=BaseFilterChip.native.js.map
|