@cube-dev/ui-kit 0.131.0 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +32 -0
- package/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.js +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.js +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.js +1 -1
- package/dist/components/actions/ItemActionContext.js +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/Item/Item.js +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +60 -45
- package/dist/components/content/Tree/Tree.js.map +1 -1
- package/dist/components/content/Tree/TreeNode.js +90 -20
- package/dist/components/content/Tree/TreeNode.js.map +1 -1
- package/dist/components/content/Tree/index.d.ts +1 -1
- package/dist/components/content/Tree/styled.js +26 -4
- package/dist/components/content/Tree/styled.js.map +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/types.d.ts +67 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.js +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.js +1 -1
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/intl.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +5 -3
- package/dist/components/fields/FilterListBox/FilterListBox.js.map +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +4 -2
- package/dist/components/fields/FilterPicker/FilterPicker.js.map +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +24 -0
- package/dist/components/fields/ListBox/DraggableListBox.js.map +1 -0
- package/dist/components/fields/ListBox/ListBox.d.ts +11 -0
- package/dist/components/fields/ListBox/ListBox.js +153 -38
- package/dist/components/fields/ListBox/ListBox.js.map +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +1 -1
- package/dist/components/fields/Select/Select.js +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/FieldWrapper/extract-field-wrapper-props.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/wrapper.js +1 -1
- package/dist/components/helpers/DisplayTransition/DisplayTransition.js +1 -1
- package/dist/components/helpers/IconSwitch/IconSwitch.js +1 -1
- package/dist/components/layout/Flex.js +1 -1
- package/dist/components/layout/Flow.js +1 -1
- package/dist/components/layout/Grid.js +1 -1
- package/dist/components/layout/Panel.js +1 -1
- package/dist/components/layout/Prefix.js +1 -1
- package/dist/components/layout/ResizablePanel.js +1 -1
- package/dist/components/layout/Space.js +1 -1
- package/dist/components/layout/Suffix.js +1 -1
- package/dist/components/navigation/Tabs/DraggableTabList.js +11 -60
- package/dist/components/navigation/Tabs/DraggableTabList.js.map +1 -1
- package/dist/components/navigation/Tabs/EditableTitle.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +3 -10
- package/dist/components/navigation/Tabs/TabButton.js.map +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +4 -2
- package/dist/components/navigation/Tabs/TabPicker.js.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +4 -2
- package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.d.ts +2 -0
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/types.js.map +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/FileTabs/FileTabs.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/CloudLogo/CloudLogo.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +142 -0
- package/dist/components/shared/DraggableCollection.js.map +1 -0
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.d.ts +12 -0
- package/dist/icons/GripVerticalIcon.js +11 -0
- package/dist/icons/GripVerticalIcon.js.map +1 -0
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/components/content/Tree.md +115 -32
- package/docs/components/fields/FilterPicker.md +27 -0
- package/docs/components/fields/ListBox.md +33 -0
- package/docs/components/navigation/Tabs.md +127 -51
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListBox.js","names":["mergeProps","BaseSection","useFocus"],"sources":["../../../../src/components/fields/FilterListBox/FilterListBox.tsx"],"sourcesContent":["import { Key } from '@react-types/shared';\nimport {\n BASE_STYLES,\n COLOR_STYLES,\n OUTER_STYLES,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n cloneElement,\n ForwardedRef,\n forwardRef,\n isValidElement,\n ReactElement,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFilter, useKeyboard } from 'react-aria';\nimport { Section as BaseSection, Item, useListState } from 'react-stately';\nimport { CubeCollectionItemProps } from 'src/components/CollectionItem';\n\nimport { LoadingIcon } from '../../../icons';\nimport { useProviderProps } from '../../../provider';\nimport { mergeProps, modAttrs, useCombinedRefs } from '../../../utils/react';\nimport { useFocus } from '../../../utils/react/interactions';\nimport { extractStyles } from '../../../utils/styles';\nimport { StyledHeader } from '../../actions/Menu/styled';\nimport { useFieldProps, useFormProps, wrapWithField } from '../../form';\nimport { CubeListBoxProps, ListBox } from '../ListBox/ListBox';\nimport {\n DEFAULT_INPUT_STYLES,\n INPUT_WRAPPER_STYLES,\n} from '../TextInput/TextInputBase';\n\nimport type { Collection, Node } from '@react-types/shared';\nimport type { FieldBaseProps } from '../../../shared';\n\ntype FilterFn = (textValue: string, inputValue: string) => boolean;\n\nconst FilterListBoxWrapperElement = tasty({\n styles: {\n display: 'grid',\n flow: 'column',\n gridColumns: '1sf',\n gridRows: 'max-content max-content 1sf',\n gap: 0,\n position: 'relative',\n radius: true,\n color: '#dark-02',\n transition: 'theme',\n outline: {\n '': '#purple-03.0',\n 'invalid & focused': '#danger.50',\n focused: '#purple-03',\n },\n border: {\n '': true,\n focused: '#primary-text',\n valid: '#success-text.50',\n invalid: '#danger-text.50',\n disabled: true,\n popover: false,\n },\n },\n});\n\nconst SearchWrapperElement = tasty({\n qa: 'FilterListBoxSearchWrapper',\n styles: {\n ...INPUT_WRAPPER_STYLES,\n border: 'bottom',\n radius: '1r top',\n fill: '#clear',\n height: '($size + 1x)',\n $size: {\n '': '$size-md',\n 'size=small': '$size-sm',\n 'size=medium': '$size-md',\n 'size=large': '$size-lg',\n },\n },\n});\n\nconst SearchInputElement = tasty({\n as: 'input',\n styles: {\n ...DEFAULT_INPUT_STYLES,\n fill: '#clear',\n padding: {\n '': '.5x 1.5x',\n prefix: '0 1.5x 0 .5x',\n suffix: '.5x .5x .5x 1.5x',\n 'prefix & suffix': '0 .5x 0 .5x',\n },\n },\n});\n\nconst StyledHeaderWithoutBorder = tasty(StyledHeader, {\n styles: {\n border: false,\n },\n});\n\nexport interface CubeFilterListBoxProps<T>\n extends Omit<CubeListBoxProps<T>, 'filter'>,\n FieldBaseProps {\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the search input should have autofocus */\n autoFocus?: boolean;\n /**\n * Custom filter function for determining if an option should be included in search results.\n * Pass `false` to disable internal filtering completely (useful for external filtering).\n */\n filter?: FilterFn | false;\n /** Label shown when the list is empty. When provided, overrides both the \"No results found\" and \"No items\" defaults. */\n emptyLabel?: ReactNode;\n /** Custom styles for the search input */\n searchInputStyles?: Styles;\n /** Whether the FilterListBox is in loading state (shows loading icon in search input) */\n isLoading?: boolean;\n /** Whether items are currently loading. Shows a loading icon in the search input suffix. */\n isLoadingItems?: boolean;\n /** Ref for accessing the search input element */\n searchInputRef?: RefObject<HTMLInputElement | null>;\n /** Whether to allow entering custom values that are not present in the predefined options */\n allowsCustomValue?: boolean;\n /** Additional modifiers for styling the FilterListBox */\n mods?: Record<string, boolean>;\n /** Custom styles for the list box */\n listBoxStyles?: Styles;\n\n /**\n * Callback fired when the user presses Escape key while the search input is empty.\n * Can be used by parent components (e.g. FilterPicker) to close an enclosing Dialog.\n */\n onEscape?: () => void;\n\n /**\n * Whether to show checkboxes for multiple selection mode.\n * This adds a checkbox icon to the left of each option.\n */\n isCheckable?: boolean;\n\n /**\n * Callback fired when an option is clicked but not on the checkbox area.\n * Used by FilterPicker to close the popover on non-checkbox clicks.\n */\n onOptionClick?: (key: Key) => void;\n\n /**\n * Props to apply to existing custom values (values that are already selected but not in the predefined options).\n */\n customValueProps?: Partial<CubeCollectionItemProps<T>>;\n\n /**\n * Props to apply to new custom values (values typed in the search input that are about to be added).\n * These are merged with customValueProps for new custom values.\n */\n newCustomValueProps?: Partial<CubeCollectionItemProps<T>>;\n\n /**\n * Controlled search value. When provided, the search input becomes controlled.\n * Use with `onSearchChange` to manage the search state externally.\n */\n searchValue?: string;\n\n /**\n * Callback fired when the search input value changes.\n * Use with `searchValue` for controlled search input.\n */\n onSearchChange?: (value: string) => void;\n\n /**\n * Pre-built collection to use instead of creating a new one.\n * Used internally by FilterPicker to avoid duplicate collection creation.\n * @internal\n */\n _internalCollection?: Collection<Node<any>>;\n}\n\nconst PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];\n\nexport const FilterListBox = forwardRef(function FilterListBox<\n T extends object,\n>(props: CubeFilterListBoxProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n props = useFieldProps(props, {\n valuePropsMapper: ({ value, onChange }) => {\n const fieldProps: any = {};\n\n if (props.selectionMode === 'multiple') {\n fieldProps.selectedKeys = value || [];\n } else {\n fieldProps.selectedKey = value ?? null;\n }\n\n fieldProps.onSelectionChange = (key: any) => {\n if (props.selectionMode === 'multiple') {\n // Handle \"all\" selection and array selections\n if (key === 'all') {\n onChange('all');\n } else {\n onChange(key ? (Array.isArray(key) ? key : [key]) : []);\n }\n } else {\n onChange(Array.isArray(key) ? key[0] : key);\n }\n };\n\n return fieldProps;\n },\n });\n\n let {\n qa,\n label,\n extra,\n id,\n labelStyles,\n isRequired,\n necessityIndicator,\n validationState,\n isDisabled,\n isLoading,\n isLoadingItems,\n searchPlaceholder = 'Search...',\n autoFocus,\n filter,\n mods: externalMods,\n emptyLabel,\n searchInputStyles,\n listStyles,\n optionStyles,\n sectionStyles,\n headingStyles,\n searchInputRef,\n listRef,\n message,\n description,\n styles,\n focusOnHover,\n shouldFocusWrap,\n labelSuffix,\n selectedKey,\n defaultSelectedKey,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange: externalOnSelectionChange,\n allowsCustomValue = false,\n showSelectAll,\n selectAllLabel,\n header,\n footer,\n size = 'medium',\n headerStyles,\n footerStyles,\n listBoxStyles,\n items,\n children: renderChildren,\n onEscape,\n isCheckable,\n onOptionClick,\n selectionMode = 'single',\n allValueProps,\n customValueProps,\n newCustomValueProps,\n searchValue: controlledSearchValue,\n onSearchChange,\n _internalCollection,\n form,\n ...otherProps\n } = props;\n\n // Preserve the original `children` (may be a render function) before we\n // potentially overwrite it.\n let children: ReactNode = renderChildren as ReactNode;\n\n const renderFn = renderChildren as unknown;\n\n if (items && typeof renderFn === 'function') {\n try {\n const itemsArray = Array.from(items as Iterable<any>);\n // Execute the render function for each item to obtain <Item/> / <Section/> nodes.\n children = itemsArray.map((item, idx) => {\n const rendered = (renderFn as (it: any) => ReactNode)(item);\n // Ensure every element has a stable key: rely on the user-provided key\n // inside the render function, otherwise fall back to the item itself or\n // the index. This mirrors React Aria examples where the render function\n // is expected to set keys, but we add a fallback for robustness.\n if (\n isValidElement(rendered) &&\n (rendered as ReactElement).key == null\n ) {\n return cloneElement(rendered as ReactElement, {\n key: (rendered as any)?.key ?? item?.key ?? idx,\n });\n }\n\n return rendered as ReactNode;\n });\n } catch {\n // If conversion fails for some reason, we silently ignore and proceed\n // with the original children value so we don't break runtime.\n }\n }\n\n // Use provided collection from FilterPicker or create our own\n // Hook call order is stable: _internalCollection is consistent per component instance\n const localCollectionState = _internalCollection\n ? { collection: _internalCollection }\n : useListState({\n children: children as any,\n items: items as any,\n selectionMode: 'none' as any,\n });\n\n // Collect original option keys to avoid duplicating them as custom values.\n const originalKeys = useMemo(() => {\n const keys = new Set<string>();\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n keys.add(String(item.key));\n }\n }\n return keys;\n }, [localCollectionState.collection]);\n\n // State to keep track of custom (user-entered) items that were selected.\n const [customKeys, setCustomKeys] = useState<Set<string>>(new Set());\n\n // Controlled/uncontrolled search value pattern\n const [internalSearchValue, setInternalSearchValue] = useState('');\n const isSearchControlled = controlledSearchValue !== undefined;\n const searchValue = isSearchControlled\n ? controlledSearchValue\n : internalSearchValue;\n\n const { contains } = useFilter({ sensitivity: 'base' });\n\n // Initialize custom keys from current selection\n useEffect(() => {\n if (!allowsCustomValue) return;\n\n const currentSelectedKeys = selectedKeys\n ? selectedKeys === 'all'\n ? [] // Skip custom key detection when 'all' is selected\n : Array.from(selectedKeys).map(String)\n : selectedKey != null\n ? [String(selectedKey)]\n : [];\n\n if (currentSelectedKeys.length === 0) return;\n\n const keysToAdd = currentSelectedKeys.filter((k) => !originalKeys.has(k));\n\n if (keysToAdd.length) {\n setCustomKeys((prev) => new Set([...Array.from(prev), ...keysToAdd]));\n }\n }, [allowsCustomValue, selectedKeys, selectedKey, originalKeys]);\n\n // Merge original children with any custom items so they persist in the list.\n // If there are selected custom values, they should appear on top with other\n // selected items (which are already sorted by the parent component, e.g. FilterPicker).\n const mergedChildren: ReactNode = useMemo(() => {\n if (!children && customKeys.size === 0) return children;\n\n // Selected custom values are injected by FilterListBox itself, not by the\n // parent. They must respect the search input regardless of the `filter`\n // prop — `filter={false}` only describes the parent's authority over its\n // own items. Filter them with the user-provided filter (if any) or the\n // default `contains`.\n const term = searchValue.trim();\n const localFilter: FilterFn =\n typeof filter === 'function' ? filter : contains;\n\n // Build React elements for custom values (kept stable via their key).\n const customArray = Array.from(customKeys)\n .filter((key) => !term || localFilter(key, term))\n .map((key) => (\n <Item key={key} textValue={key} {...customValueProps}>\n {key}\n </Item>\n ));\n\n // Identify which custom keys are currently selected so we can promote them.\n const selectedKeysSet = new Set<string>();\n\n if (selectionMode === 'multiple') {\n if (selectedKeys === 'all') {\n // When 'all' is selected, no custom items should be treated as selected\n // since 'all' means all available items, not custom ones\n } else {\n Array.from(selectedKeys ?? []).forEach((k) =>\n selectedKeysSet.add(String(k)),\n );\n }\n } else {\n if (selectedKey != null) selectedKeysSet.add(String(selectedKey));\n }\n\n const selectedCustom: ReactNode[] = [];\n const unselectedCustom: ReactNode[] = [];\n\n customArray.forEach((item: any) => {\n if (selectedKeysSet.has(String(item.key))) {\n selectedCustom.push(item);\n } else {\n unselectedCustom.push(item);\n }\n });\n\n if (!children) {\n // No original items – just return selected custom followed by the rest.\n return [...selectedCustom, ...unselectedCustom];\n }\n\n const originalArray = Array.isArray(children) ? children : [children];\n\n // Final order: selected custom items -> original array (already possibly\n // sorted by parent) -> unselected custom items.\n return [...selectedCustom, ...originalArray, ...unselectedCustom];\n }, [\n children,\n customKeys,\n selectionMode,\n selectedKey,\n selectedKeys,\n searchValue,\n filter,\n contains,\n customValueProps,\n ]);\n\n // Determine an aria-label for the internal ListBox to avoid React Aria warnings.\n const innerAriaLabel =\n (props as any)['aria-label'] ||\n (typeof label === 'string' ? label : undefined);\n\n const handleSearchChange = useCallback(\n (value: string) => {\n if (!isSearchControlled) {\n setInternalSearchValue(value);\n }\n onSearchChange?.(value);\n },\n [isSearchControlled, onSearchChange],\n );\n\n // Choose the text filter function: user-provided `filter` prop (if any),\n // or the default `contains` helper from `useFilter`.\n // When `filter={false}`, the parent owns filtering — we normally pass items\n // through unchanged. The exception is when `isLoadingItems` is `true`: a\n // server fetch is in flight and currently visible items are stale, so we\n // fall back to client-side `contains` to hide non-matching stale items\n // until the new items arrive.\n const textFilterFn = useMemo<FilterFn>(() => {\n if (filter === false) {\n return isLoadingItems ? contains : () => true;\n }\n return filter || contains;\n }, [filter, contains, isLoadingItems]);\n\n // Create a filter function for collection nodes (similar to ComboBox pattern)\n const filterFn = useCallback(\n (nodes: Iterable<any>) => {\n // Server-side filtering with no fetch in flight — items are\n // authoritative and shown as-is.\n if (filter === false && !isLoadingItems) return nodes;\n\n const term = searchValue.trim();\n\n if (!term) {\n return nodes;\n }\n\n // Filter nodes based on their textValue and preserve section structure\n return [...nodes]\n .map((node: any) => {\n if (node.type === 'section' && node.childNodes) {\n const filteredNodes = [...node.childNodes].filter((child: any) =>\n textFilterFn(child.textValue || '', term),\n );\n\n if (filteredNodes.length === 0) {\n return null;\n }\n\n return {\n ...node,\n childNodes: filteredNodes,\n hasChildNodes: true,\n };\n }\n\n return textFilterFn(node.textValue || '', term) ? node : null;\n })\n .filter(Boolean);\n },\n [filter, searchValue, textFilterFn, isLoadingItems],\n );\n\n // Handle custom values if allowed\n const enhancedChildren = useMemo(() => {\n let childrenToProcess = mergedChildren;\n\n // Handle custom values if allowed\n if (!allowsCustomValue) return childrenToProcess;\n\n const term = searchValue.trim();\n if (!term) return childrenToProcess;\n\n // Helper to determine if the term is already present (exact match on rendered textValue or the key).\n const doesTermExist = (term: string): boolean => {\n // Check if term exists in custom keys\n if (customKeys.has(term)) {\n return true;\n }\n\n // Check if term exists in original collection\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n const textValue = item.textValue || String(item.rendered || '');\n if (term === textValue || String(item.key) === term) {\n return true;\n }\n }\n }\n return false;\n };\n\n if (doesTermExist(term)) {\n return childrenToProcess;\n }\n\n // Check if there are any items that will match the filter.\n // This determines whether we need to visually separate the custom value\n // from real items (i.e. render a divider between sections). When there\n // are no visible items, we skip the section wrapper so no divider is\n // drawn above a lone custom-value option.\n //\n // Selected custom values (from `customKeys`) are filtered by `localFilter`\n // in `mergedChildren` regardless of `filter={false}`, so this check must\n // use the same logic — otherwise we'd report \"items visible\" and draw a\n // divider while the actual collection only contains the custom value.\n const localFilter: FilterFn =\n typeof filter === 'function' ? filter : contains;\n\n const hasVisibleFilteredItems = (() => {\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n const textValue = item.textValue || String(item.rendered || '');\n if (textFilterFn(textValue, term)) {\n return true;\n }\n } else if (item.type === 'section' && item.childNodes) {\n for (const child of item.childNodes) {\n const textValue = child.textValue || String(child.rendered || '');\n if (textFilterFn(textValue, term)) {\n return true;\n }\n }\n }\n }\n\n for (const customKey of customKeys) {\n if (localFilter(customKey, term)) {\n return true;\n }\n }\n\n return false;\n })();\n\n // Create the custom option\n const customOption = (\n <Item\n key={term}\n textValue={term}\n {...mergeProps(customValueProps, newCustomValueProps)}\n >\n {term}\n </Item>\n );\n\n // If there are visible filtered items, add visual separation for custom value\n if (hasVisibleFilteredItems && childrenToProcess) {\n // Check if the collection contains any sections\n // If it does, we can't wrap childrenToProcess in another section (would create nested sections)\n const hasSections = [...localCollectionState.collection].some(\n (item) => item.type === 'section',\n );\n\n const customValueSection = (\n <BaseSection key=\"__custom_value__\" aria-label=\"Custom value\">\n {customOption}\n </BaseSection>\n );\n\n if (hasSections) {\n // Collection has sections - just append the custom value section without wrapping\n if (Array.isArray(childrenToProcess)) {\n return [...childrenToProcess, customValueSection];\n }\n return [childrenToProcess, customValueSection];\n }\n\n // No sections in collection - wrap items in a section for visual separation\n const filteredItemsSection = (\n <BaseSection key=\"__filtered_items__\" aria-label=\"Filtered items\">\n {childrenToProcess}\n </BaseSection>\n );\n\n return [filteredItemsSection, customValueSection];\n }\n\n // No visible filtered items, just return the custom option without sections\n if (Array.isArray(childrenToProcess)) {\n return [...childrenToProcess, customOption];\n }\n\n if (childrenToProcess) {\n return [childrenToProcess, customOption];\n }\n\n return customOption;\n }, [\n allowsCustomValue,\n mergedChildren,\n searchValue,\n customKeys,\n localCollectionState.collection,\n customValueProps,\n newCustomValueProps,\n textFilterFn,\n filter,\n contains,\n ]);\n\n styles = extractStyles(otherProps, PROP_STYLES, styles);\n\n ref = useCombinedRefs(ref);\n searchInputRef = useCombinedRefs(searchInputRef);\n listRef = useCombinedRefs(listRef);\n\n const { isFocused, focusProps } = useFocus({ isDisabled });\n const isInvalid = validationState === 'invalid';\n\n const listBoxRef = useRef<HTMLDivElement>(null);\n\n // Ref to access internal ListBox state (selection manager, etc.)\n const listStateRef = useRef<any>(null);\n\n // No separate focusedKey state needed; rely directly on selectionManager.focusedKey.\n\n // When the search value changes, the visible collection of items may change as well.\n // If the currently focused item is no longer visible, move virtual focus to the first\n // available item so that arrow navigation and Enter behaviour continue to work.\n // If there are no available items, reset the selection so Enter won't select anything.\n // Priority: focus on selected items first, then fall back to first visible item.\n useLayoutEffect(() => {\n const listState = listStateRef.current;\n\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Walk the collection and:\n // 1. Collect visible item keys (supports sections).\n // 2. Detect the synthetic \"new custom value\" option — the one generated\n // from the current search term when `allowsCustomValue` is true.\n //\n // The custom value is rendered in one of two layouts depending on whether\n // any real item text-matches the search term (`hasVisibleFilteredItems`\n // in `enhancedChildren`):\n // • Some items match → wrapped in a `__custom_value__` section\n // (`customValueHasMatches = true`)\n // • No items match → appended at the top level with key === term\n // (`customValueHasMatches = false`)\n //\n // The layout itself is the signal we use to decide whether the custom\n // value should be the focus target (no matches) or whether focus should\n // move to a real item (matches present).\n const term = searchValue.trim();\n let newCustomValueKey: Key | null = null;\n let customValueHasMatches = false;\n\n const collectVisibleKeys = (\n nodes: Iterable<any>,\n out: Key[],\n inCustomSection = false,\n ) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n if (inCustomSection) {\n newCustomValueKey = node.key;\n customValueHasMatches = true;\n }\n } else if (node.childNodes) {\n const isCustomSection =\n inCustomSection || node.key === '__custom_value__';\n collectVisibleKeys(node.childNodes, out, isCustomSection);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n // Detect the appended-at-top-level case (no items text-match). The custom\n // option is added with key === trimmed search term and lives directly in\n // the top-level collection (not nested in any section).\n if (newCustomValueKey == null && allowsCustomValue && term) {\n for (const node of collection) {\n if (node.type === 'item' && String(node.key) === term) {\n newCustomValueKey = node.key;\n customValueHasMatches = false;\n break;\n }\n }\n }\n\n // If there are no visible items, reset the focused key so Enter won't select anything\n if (visibleKeys.length === 0) {\n selectionManager.setFocusedKey(null);\n return;\n }\n\n // The custom value should be the focus target when it exists and there\n // are no real text-matches — the user's typed value is then the only\n // actionable option. During an in-flight server fetch (`filter === false`\n // + `isLoadingItems`) `textFilterFn` falls back to client-side `contains`\n // so non-matching stale items are hidden, which keeps this signal honest.\n const customValueShouldBeFocused =\n newCustomValueKey != null && !customValueHasMatches;\n\n // Decide whether the current focus is already on the right thing. If yes,\n // don't disturb it. Otherwise fall through and re-pick a focus target.\n const currentFocused = selectionManager.focusedKey;\n if (currentFocused != null && visibleKeys.includes(currentFocused)) {\n const currentIsNewCustomValue =\n newCustomValueKey != null && currentFocused === newCustomValueKey;\n if (customValueShouldBeFocused) {\n if (currentIsNewCustomValue) return;\n } else if (newCustomValueKey != null) {\n // Custom value exists but isn't the priority (matches available) —\n // any non-custom focus is fine.\n if (!currentIsNewCustomValue) return;\n } else {\n // No custom value involved at all.\n return;\n }\n }\n\n // Helper to find the first selected item that's visible\n const findFirstVisibleSelectedKey = (): Key | null => {\n if (selectionMode === 'single') {\n // Single selection: check if selectedKey is visible\n if (selectedKey != null) {\n const selectedKeyStr = String(selectedKey);\n if (visibleKeys.some((k) => String(k) === selectedKeyStr)) {\n return selectedKey;\n }\n }\n } else if (selectionMode === 'multiple') {\n // Multiple selection: find first selected key that's visible\n if (selectedKeys && selectedKeys !== 'all') {\n for (const key of selectedKeys) {\n const keyStr = String(key);\n if (visibleKeys.some((k) => String(k) === keyStr)) {\n return key;\n }\n }\n }\n }\n return null;\n };\n\n // Determine which key to focus\n let keyToFocus: Key | null = null;\n\n if (customValueShouldBeFocused) {\n // No real matches — promote the custom value over any selected/stale\n // item so the user can press Enter to add the value they just typed.\n keyToFocus = newCustomValueKey;\n } else {\n keyToFocus = findFirstVisibleSelectedKey();\n\n // Fallback to first visible item if no selected item found. Prefer the\n // first real (non-custom-value) item so focus doesn't land on the\n // bottom-of-list custom-value suggestion when real items are available.\n if (keyToFocus == null) {\n const firstRealKey = visibleKeys.find((k) => k !== newCustomValueKey);\n keyToFocus = firstRealKey ?? visibleKeys[0];\n }\n }\n\n // Mark this focus change as keyboard navigation so ListBox will scroll to it\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n\n // Set focus to the determined key\n selectionManager.setFocusedKey(keyToFocus);\n }, [\n searchValue,\n enhancedChildren,\n selectionMode,\n selectedKey,\n selectedKeys,\n allowsCustomValue,\n ]);\n\n // Keyboard navigation handler for search input\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n e.preventDefault();\n\n const listState = listStateRef.current;\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Helper to collect visible item keys (supports sections)\n // Collection is already filtered by React Stately via filterFn\n const collectVisibleKeys = (nodes: Iterable<any>, out: Key[]) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n } else if (node.childNodes) {\n collectVisibleKeys(node.childNodes, out);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n if (visibleKeys.length === 0) return;\n\n const isArrowDown = e.key === 'ArrowDown';\n const direction = isArrowDown ? 1 : -1;\n\n const currentKey = selectionManager.focusedKey;\n\n let nextKey: Key | null = null;\n\n if (currentKey == null) {\n // If nothing focused yet, pick first/last depending on direction\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n } else {\n const currentIndex = visibleKeys.indexOf(currentKey);\n if (currentIndex !== -1) {\n const newIndex = currentIndex + direction;\n if (newIndex >= 0 && newIndex < visibleKeys.length) {\n nextKey = visibleKeys[newIndex];\n } else if (shouldFocusWrap) {\n // Wrap around\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n }\n } else {\n // Fallback\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n }\n }\n\n if (nextKey != null) {\n // Mark this focus change as keyboard navigation\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n selectionManager.setFocusedKey(nextKey);\n }\n } else if (\n e.key === 'Home' ||\n e.key === 'End' ||\n e.key === 'PageUp' ||\n e.key === 'PageDown'\n ) {\n e.preventDefault();\n\n const listState = listStateRef.current;\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Helper to collect visible item keys (supports sections)\n // Collection is already filtered by React Stately via filterFn\n const collectVisibleKeys = (nodes: Iterable<any>, out: Key[]) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n } else if (node.childNodes) {\n collectVisibleKeys(node.childNodes, out);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n if (visibleKeys.length === 0) return;\n\n const targetKey =\n e.key === 'Home' || e.key === 'PageUp'\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n\n // Mark this focus change as keyboard navigation\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n selectionManager.setFocusedKey(targetKey);\n } else if (e.key === 'Enter' || (e.key === ' ' && !searchValue)) {\n const listState = listStateRef.current;\n\n if (!listState) return;\n\n const keyToSelect = listState.selectionManager.focusedKey;\n\n if (keyToSelect != null) {\n e.preventDefault();\n listState.selectionManager.select(keyToSelect, e);\n\n if (\n e.key === 'Enter' &&\n isCheckable &&\n onEscape &&\n selectionMode === 'multiple'\n ) {\n onEscape();\n }\n }\n } else if (e.key === 'Escape') {\n if (searchValue) {\n // Clear the current search if any text is present.\n e.preventDefault();\n handleSearchChange('');\n } else {\n // Notify parent that Escape was pressed on an empty input.\n if (onEscape) {\n e.preventDefault();\n onEscape();\n }\n }\n }\n },\n });\n\n const mods = useMemo(\n () => ({\n invalid: isInvalid,\n valid: validationState === 'valid',\n disabled: !!isDisabled,\n focused: isFocused,\n loading: !!isLoading,\n 'loading-items': !!isLoadingItems,\n searchable: true,\n prefix: !!isLoading,\n suffix: !!isLoadingItems,\n ...externalMods,\n }),\n [\n isInvalid,\n validationState,\n isDisabled,\n isFocused,\n isLoading,\n isLoadingItems,\n externalMods,\n ],\n );\n\n // Handler must be defined before we render ListBox so we can pass it.\n const handleSelectionChange = (selection: any) => {\n if (allowsCustomValue) {\n // Normalize current selection into an array of string keys\n let selectedValues: string[] = [];\n\n if (selection != null) {\n if (Array.isArray(selection)) {\n selectedValues = selection.map(String);\n } else {\n selectedValues = [String(selection)];\n }\n }\n\n // Build next custom keys set based on selected values\n const nextSet = new Set<string>();\n\n selectedValues.forEach((val) => {\n if (!originalKeys.has(val)) {\n nextSet.add(val);\n }\n });\n\n // Update internal custom keys state\n setCustomKeys(nextSet);\n }\n\n if (externalOnSelectionChange) {\n (externalOnSelectionChange as any)(selection);\n }\n };\n\n // Custom option click handler that ensures search input receives focus\n const handleOptionClick = (key: Key) => {\n // Focus the search input to enable keyboard navigation\n // Use setTimeout to ensure this happens after React state updates\n setTimeout(() => {\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n }, 0);\n\n // Call the original onOptionClick if provided\n if (onOptionClick) {\n onOptionClick(key);\n }\n };\n\n const searchInput = (\n <SearchWrapperElement mods={mods} data-size={size}>\n {isLoading && (\n <div data-element=\"Prefix\">\n <div data-element=\"InputIcon\">\n {isLoading ? <LoadingIcon /> : null}\n </div>\n </div>\n )}\n <SearchInputElement\n ref={searchInputRef}\n qa={qa || 'FilterListBox'}\n id={id}\n data-prefix={isLoading ? '' : undefined}\n data-suffix={isLoadingItems ? '' : undefined}\n type=\"search\"\n placeholder={searchPlaceholder}\n value={searchValue}\n disabled={isDisabled}\n autoFocus={autoFocus}\n data-autofocus={autoFocus ? '' : undefined}\n styles={searchInputStyles}\n data-size={size}\n data-input-type=\"filterlistbox\"\n role=\"combobox\"\n aria-expanded=\"true\"\n aria-haspopup=\"listbox\"\n aria-activedescendant={\n listStateRef.current?.selectionManager.focusedKey != null\n ? `ListBoxItem-${listStateRef.current?.selectionManager.focusedKey}`\n : undefined\n }\n onChange={(e) => {\n handleSearchChange(e.target.value);\n }}\n {...keyboardProps}\n {...modAttrs(mods)}\n />\n {isLoadingItems && (\n <div data-element=\"Suffix\">\n <LoadingIcon data-element=\"InputIcon\" />\n </div>\n )}\n </SearchWrapperElement>\n );\n\n const filterListBoxField = (\n <FilterListBoxWrapperElement\n ref={ref}\n qa=\"FilterListBoxWrapper\"\n {...modAttrs(mods)}\n styles={styles}\n {...focusProps}\n >\n {header ? (\n <StyledHeaderWithoutBorder data-size={size} styles={headerStyles}>\n {header}\n </StyledHeaderWithoutBorder>\n ) : (\n <div role=\"presentation\" />\n )}\n {searchInput}\n <ListBox\n ref={listBoxRef}\n aria-label={innerAriaLabel}\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n selectedKeys={selectedKeys}\n defaultSelectedKeys={defaultSelectedKeys}\n selectionMode={selectionMode}\n isDisabled={isDisabled}\n listRef={listRef}\n stateRef={listStateRef}\n listStyles={listStyles}\n shouldFocusWrap={shouldFocusWrap}\n optionStyles={optionStyles}\n sectionStyles={sectionStyles}\n headingStyles={headingStyles}\n validationState={validationState}\n disallowEmptySelection={props.disallowEmptySelection}\n disabledKeys={props.disabledKeys}\n focusOnHover={focusOnHover}\n shouldUseVirtualFocus={true}\n showSelectAll={showSelectAll}\n selectAllLabel={selectAllLabel}\n footer={footer}\n footerStyles={footerStyles}\n mods={mods}\n size=\"medium\"\n styles={listBoxStyles}\n isCheckable={isCheckable}\n items={items as any}\n allValueProps={allValueProps}\n filter={filterFn}\n emptyLabel={\n emptyLabel !== undefined\n ? emptyLabel\n : searchValue.trim()\n ? 'No results found'\n : 'No items'\n }\n onSelectionChange={handleSelectionChange}\n onEscape={onEscape}\n onOptionClick={handleOptionClick}\n >\n {enhancedChildren as any}\n </ListBox>\n </FilterListBoxWrapperElement>\n );\n\n return wrapWithField<Omit<CubeFilterListBoxProps<T>, 'children'>>(\n filterListBoxField,\n ref,\n props,\n );\n}) as unknown as (<T>(\n props: CubeFilterListBoxProps<T> & { ref?: ForwardedRef<HTMLDivElement> },\n) => ReactElement) & { Item: typeof Item; Section: typeof BaseSection };\n\nFilterListBox.Item = ListBox.Item;\n\nFilterListBox.Section = BaseSection;\n\nObject.defineProperty(FilterListBox, 'cubeInputType', {\n value: 'FilterListBox',\n enumerable: false,\n configurable: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,8BAA8B,MAAM,EACxC,QAAQ;CACN,SAAS;CACT,MAAM;CACN,aAAa;CACb,UAAU;CACV,KAAK;CACL,UAAU;CACV,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,SAAS;EACP,IAAI;EACJ,qBAAqB;EACrB,SAAS;EACV;CACD,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,OAAO;EACP,SAAS;EACT,UAAU;EACV,SAAS;EACV;CACF,EACF,CAAC;AAE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,aAAa,SAAS,iBAAiB,cAAc,OACjD,eAAe,aAAa,SAAS,iBAAiB,eACtD;IAEN,WAAW,MAAM;AACf,wBAAmB,EAAE,OAAO,MAAM;;IAEpC,GAAI;IACJ,GAAI,SAAS,KAAK;KAClB;GACD,kBACC,oBAAC;IAAI,gBAAa;cAChB,oBAAC,eAAY,gBAAa,cAAc;KACpC;;GAEa;AAmEzB,QAAO,cA/DL,qBAAC;EACM;EACL,IAAG;EACH,GAAI,SAAS,KAAK;EACV;EACR,GAAI;;GAEH,SACC,oBAAC;IAA0B,aAAW;IAAM,QAAQ;cACjD;KACyB,GAE5B,oBAAC,SAAI,MAAK,iBAAiB;GAE5B;GACD,oBAAC;IACC,KAAK;IACL,cAAY;IACC;IACO;IACN;IACO;IACN;IACH;IACH;IACT,UAAU;IACE;IACK;IACH;IACC;IACA;IACE;IACjB,wBAAwB,MAAM;IAC9B,cAAc,MAAM;IACN;IACd,uBAAuB;IACR;IACC;IACR;IACM;IACR;IACN,MAAK;IACL,QAAQ;IACK;IACN;IACQ;IACf,QAAQ;IACR,YACE,eAAe,SACX,aACA,YAAY,MAAM,GAChB,qBACA;IAER,mBAAmB;IACT;IACV,eAAe;cAEd;KACO;;GACkB,EAK9B,KACA,MACD;EACD;AAIF,cAAc,OAAO,QAAQ;AAE7B,cAAc,UAAUD;AAExB,OAAO,eAAe,eAAe,iBAAiB;CACpD,OAAO;CACP,YAAY;CACZ,cAAc;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"FilterListBox.js","names":["mergeProps","BaseSection","useFocus"],"sources":["../../../../src/components/fields/FilterListBox/FilterListBox.tsx"],"sourcesContent":["import { Key } from '@react-types/shared';\nimport {\n BASE_STYLES,\n COLOR_STYLES,\n OUTER_STYLES,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n cloneElement,\n ForwardedRef,\n forwardRef,\n isValidElement,\n ReactElement,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFilter, useKeyboard } from 'react-aria';\nimport { Section as BaseSection, Item, useListState } from 'react-stately';\nimport { CubeCollectionItemProps } from 'src/components/CollectionItem';\n\nimport { LoadingIcon } from '../../../icons';\nimport { useProviderProps } from '../../../provider';\nimport { mergeProps, modAttrs, useCombinedRefs } from '../../../utils/react';\nimport { useFocus } from '../../../utils/react/interactions';\nimport { extractStyles } from '../../../utils/styles';\nimport { StyledHeader } from '../../actions/Menu/styled';\nimport { useFieldProps, useFormProps, wrapWithField } from '../../form';\nimport { CubeListBoxProps, ListBox } from '../ListBox/ListBox';\nimport {\n DEFAULT_INPUT_STYLES,\n INPUT_WRAPPER_STYLES,\n} from '../TextInput/TextInputBase';\n\nimport type { Collection, Node } from '@react-types/shared';\nimport type { FieldBaseProps } from '../../../shared';\n\ntype FilterFn = (textValue: string, inputValue: string) => boolean;\n\nconst FilterListBoxWrapperElement = tasty({\n styles: {\n display: 'grid',\n flow: 'column',\n gridColumns: '1sf',\n gridRows: 'max-content max-content 1sf',\n gap: 0,\n position: 'relative',\n radius: true,\n color: '#dark-02',\n transition: 'theme',\n outline: {\n '': '#purple-03.0',\n 'invalid & focused': '#danger.50',\n focused: '#purple-03',\n },\n border: {\n '': true,\n focused: '#primary-text',\n valid: '#success-text.50',\n invalid: '#danger-text.50',\n disabled: true,\n popover: false,\n },\n },\n});\n\nconst SearchWrapperElement = tasty({\n qa: 'FilterListBoxSearchWrapper',\n styles: {\n ...INPUT_WRAPPER_STYLES,\n border: 'bottom',\n radius: '1r top',\n fill: '#clear',\n height: '($size + 1x)',\n $size: {\n '': '$size-md',\n 'size=small': '$size-sm',\n 'size=medium': '$size-md',\n 'size=large': '$size-lg',\n },\n },\n});\n\nconst SearchInputElement = tasty({\n as: 'input',\n styles: {\n ...DEFAULT_INPUT_STYLES,\n fill: '#clear',\n padding: {\n '': '.5x 1.5x',\n prefix: '0 1.5x 0 .5x',\n suffix: '.5x .5x .5x 1.5x',\n 'prefix & suffix': '0 .5x 0 .5x',\n },\n },\n});\n\nconst StyledHeaderWithoutBorder = tasty(StyledHeader, {\n styles: {\n border: false,\n },\n});\n\nexport interface CubeFilterListBoxProps<T>\n extends Omit<CubeListBoxProps<T>, 'filter'>,\n FieldBaseProps {\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the search input should have autofocus */\n autoFocus?: boolean;\n /**\n * Custom filter function for determining if an option should be included in search results.\n * Pass `false` to disable internal filtering completely (useful for external filtering).\n */\n filter?: FilterFn | false;\n /** Label shown when the list is empty. When provided, overrides both the \"No results found\" and \"No items\" defaults. */\n emptyLabel?: ReactNode;\n /** Custom styles for the search input */\n searchInputStyles?: Styles;\n /** Whether the FilterListBox is in loading state (shows loading icon in search input) */\n isLoading?: boolean;\n /** Whether items are currently loading. Shows a loading icon in the search input suffix. */\n isLoadingItems?: boolean;\n /** Ref for accessing the search input element */\n searchInputRef?: RefObject<HTMLInputElement | null>;\n /** Whether to allow entering custom values that are not present in the predefined options */\n allowsCustomValue?: boolean;\n /** Additional modifiers for styling the FilterListBox */\n mods?: Record<string, boolean>;\n /** Custom styles for the list box */\n listBoxStyles?: Styles;\n\n /**\n * Callback fired when the user presses Escape key while the search input is empty.\n * Can be used by parent components (e.g. FilterPicker) to close an enclosing Dialog.\n */\n onEscape?: () => void;\n\n /**\n * Whether to show checkboxes for multiple selection mode.\n * This adds a checkbox icon to the left of each option.\n */\n isCheckable?: boolean;\n\n /**\n * Callback fired when an option is clicked but not on the checkbox area.\n * Used by FilterPicker to close the popover on non-checkbox clicks.\n */\n onOptionClick?: (key: Key) => void;\n\n /**\n * Props to apply to existing custom values (values that are already selected but not in the predefined options).\n */\n customValueProps?: Partial<CubeCollectionItemProps<T>>;\n\n /**\n * Props to apply to new custom values (values typed in the search input that are about to be added).\n * These are merged with customValueProps for new custom values.\n */\n newCustomValueProps?: Partial<CubeCollectionItemProps<T>>;\n\n /**\n * Controlled search value. When provided, the search input becomes controlled.\n * Use with `onSearchChange` to manage the search state externally.\n */\n searchValue?: string;\n\n /**\n * Callback fired when the search input value changes.\n * Use with `searchValue` for controlled search input.\n */\n onSearchChange?: (value: string) => void;\n\n /**\n * Pre-built collection to use instead of creating a new one.\n * Used internally by FilterPicker to avoid duplicate collection creation.\n * @internal\n */\n _internalCollection?: Collection<Node<any>>;\n}\n\nconst PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];\n\nexport const FilterListBox = forwardRef(function FilterListBox<\n T extends object,\n>(props: CubeFilterListBoxProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n props = useFieldProps(props, {\n valuePropsMapper: ({ value, onChange }) => {\n const fieldProps: any = {};\n\n if (props.selectionMode === 'multiple') {\n fieldProps.selectedKeys = value || [];\n } else {\n fieldProps.selectedKey = value ?? null;\n }\n\n fieldProps.onSelectionChange = (key: any) => {\n if (props.selectionMode === 'multiple') {\n // Handle \"all\" selection and array selections\n if (key === 'all') {\n onChange('all');\n } else {\n onChange(key ? (Array.isArray(key) ? key : [key]) : []);\n }\n } else {\n onChange(Array.isArray(key) ? key[0] : key);\n }\n };\n\n return fieldProps;\n },\n });\n\n let {\n qa,\n label,\n extra,\n id,\n labelStyles,\n isRequired,\n necessityIndicator,\n validationState,\n isDisabled,\n isLoading,\n isLoadingItems,\n searchPlaceholder = 'Search...',\n autoFocus,\n filter,\n mods: externalMods,\n emptyLabel,\n searchInputStyles,\n listStyles,\n optionStyles,\n sectionStyles,\n headingStyles,\n searchInputRef,\n listRef,\n message,\n description,\n styles,\n focusOnHover,\n shouldFocusWrap,\n labelSuffix,\n selectedKey,\n defaultSelectedKey,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange: externalOnSelectionChange,\n allowsCustomValue = false,\n showSelectAll,\n selectAllLabel,\n header,\n footer,\n size = 'medium',\n headerStyles,\n footerStyles,\n listBoxStyles,\n items,\n children: renderChildren,\n onEscape,\n isCheckable,\n onOptionClick,\n selectionMode = 'single',\n allValueProps,\n customValueProps,\n newCustomValueProps,\n searchValue: controlledSearchValue,\n onSearchChange,\n _internalCollection,\n isReorderable = false,\n onReorder,\n form,\n ...otherProps\n } = props;\n\n // Preserve the original `children` (may be a render function) before we\n // potentially overwrite it.\n let children: ReactNode = renderChildren as ReactNode;\n\n const renderFn = renderChildren as unknown;\n\n if (items && typeof renderFn === 'function') {\n try {\n const itemsArray = Array.from(items as Iterable<any>);\n // Execute the render function for each item to obtain <Item/> / <Section/> nodes.\n children = itemsArray.map((item, idx) => {\n const rendered = (renderFn as (it: any) => ReactNode)(item);\n // Ensure every element has a stable key: rely on the user-provided key\n // inside the render function, otherwise fall back to the item itself or\n // the index. This mirrors React Aria examples where the render function\n // is expected to set keys, but we add a fallback for robustness.\n if (\n isValidElement(rendered) &&\n (rendered as ReactElement).key == null\n ) {\n return cloneElement(rendered as ReactElement, {\n key: (rendered as any)?.key ?? item?.key ?? idx,\n });\n }\n\n return rendered as ReactNode;\n });\n } catch {\n // If conversion fails for some reason, we silently ignore and proceed\n // with the original children value so we don't break runtime.\n }\n }\n\n // Use provided collection from FilterPicker or create our own\n // Hook call order is stable: _internalCollection is consistent per component instance\n const localCollectionState = _internalCollection\n ? { collection: _internalCollection }\n : useListState({\n children: children as any,\n items: items as any,\n selectionMode: 'none' as any,\n });\n\n // Collect original option keys to avoid duplicating them as custom values.\n const originalKeys = useMemo(() => {\n const keys = new Set<string>();\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n keys.add(String(item.key));\n }\n }\n return keys;\n }, [localCollectionState.collection]);\n\n // State to keep track of custom (user-entered) items that were selected.\n const [customKeys, setCustomKeys] = useState<Set<string>>(new Set());\n\n // Controlled/uncontrolled search value pattern\n const [internalSearchValue, setInternalSearchValue] = useState('');\n const isSearchControlled = controlledSearchValue !== undefined;\n const searchValue = isSearchControlled\n ? controlledSearchValue\n : internalSearchValue;\n\n const { contains } = useFilter({ sensitivity: 'base' });\n\n // Initialize custom keys from current selection\n useEffect(() => {\n if (!allowsCustomValue) return;\n\n const currentSelectedKeys = selectedKeys\n ? selectedKeys === 'all'\n ? [] // Skip custom key detection when 'all' is selected\n : Array.from(selectedKeys).map(String)\n : selectedKey != null\n ? [String(selectedKey)]\n : [];\n\n if (currentSelectedKeys.length === 0) return;\n\n const keysToAdd = currentSelectedKeys.filter((k) => !originalKeys.has(k));\n\n if (keysToAdd.length) {\n setCustomKeys((prev) => new Set([...Array.from(prev), ...keysToAdd]));\n }\n }, [allowsCustomValue, selectedKeys, selectedKey, originalKeys]);\n\n // Merge original children with any custom items so they persist in the list.\n // If there are selected custom values, they should appear on top with other\n // selected items (which are already sorted by the parent component, e.g. FilterPicker).\n const mergedChildren: ReactNode = useMemo(() => {\n if (!children && customKeys.size === 0) return children;\n\n // Selected custom values are injected by FilterListBox itself, not by the\n // parent. They must respect the search input regardless of the `filter`\n // prop — `filter={false}` only describes the parent's authority over its\n // own items. Filter them with the user-provided filter (if any) or the\n // default `contains`.\n const term = searchValue.trim();\n const localFilter: FilterFn =\n typeof filter === 'function' ? filter : contains;\n\n // Build React elements for custom values (kept stable via their key).\n const customArray = Array.from(customKeys)\n .filter((key) => !term || localFilter(key, term))\n .map((key) => (\n <Item key={key} textValue={key} {...customValueProps}>\n {key}\n </Item>\n ));\n\n // Identify which custom keys are currently selected so we can promote them.\n const selectedKeysSet = new Set<string>();\n\n if (selectionMode === 'multiple') {\n if (selectedKeys === 'all') {\n // When 'all' is selected, no custom items should be treated as selected\n // since 'all' means all available items, not custom ones\n } else {\n Array.from(selectedKeys ?? []).forEach((k) =>\n selectedKeysSet.add(String(k)),\n );\n }\n } else {\n if (selectedKey != null) selectedKeysSet.add(String(selectedKey));\n }\n\n const selectedCustom: ReactNode[] = [];\n const unselectedCustom: ReactNode[] = [];\n\n customArray.forEach((item: any) => {\n if (selectedKeysSet.has(String(item.key))) {\n selectedCustom.push(item);\n } else {\n unselectedCustom.push(item);\n }\n });\n\n if (!children) {\n // No original items – just return selected custom followed by the rest.\n return [...selectedCustom, ...unselectedCustom];\n }\n\n const originalArray = Array.isArray(children) ? children : [children];\n\n // Final order: selected custom items -> original array (already possibly\n // sorted by parent) -> unselected custom items.\n return [...selectedCustom, ...originalArray, ...unselectedCustom];\n }, [\n children,\n customKeys,\n selectionMode,\n selectedKey,\n selectedKeys,\n searchValue,\n filter,\n contains,\n customValueProps,\n ]);\n\n // Determine an aria-label for the internal ListBox to avoid React Aria warnings.\n const innerAriaLabel =\n (props as any)['aria-label'] ||\n (typeof label === 'string' ? label : undefined);\n\n const handleSearchChange = useCallback(\n (value: string) => {\n if (!isSearchControlled) {\n setInternalSearchValue(value);\n }\n onSearchChange?.(value);\n },\n [isSearchControlled, onSearchChange],\n );\n\n // Choose the text filter function: user-provided `filter` prop (if any),\n // or the default `contains` helper from `useFilter`.\n // When `filter={false}`, the parent owns filtering — we normally pass items\n // through unchanged. The exception is when `isLoadingItems` is `true`: a\n // server fetch is in flight and currently visible items are stale, so we\n // fall back to client-side `contains` to hide non-matching stale items\n // until the new items arrive.\n const textFilterFn = useMemo<FilterFn>(() => {\n if (filter === false) {\n return isLoadingItems ? contains : () => true;\n }\n return filter || contains;\n }, [filter, contains, isLoadingItems]);\n\n // Create a filter function for collection nodes (similar to ComboBox pattern)\n const filterFn = useCallback(\n (nodes: Iterable<any>) => {\n // Server-side filtering with no fetch in flight — items are\n // authoritative and shown as-is.\n if (filter === false && !isLoadingItems) return nodes;\n\n const term = searchValue.trim();\n\n if (!term) {\n return nodes;\n }\n\n // Filter nodes based on their textValue and preserve section structure\n return [...nodes]\n .map((node: any) => {\n if (node.type === 'section' && node.childNodes) {\n const filteredNodes = [...node.childNodes].filter((child: any) =>\n textFilterFn(child.textValue || '', term),\n );\n\n if (filteredNodes.length === 0) {\n return null;\n }\n\n return {\n ...node,\n childNodes: filteredNodes,\n hasChildNodes: true,\n };\n }\n\n return textFilterFn(node.textValue || '', term) ? node : null;\n })\n .filter(Boolean);\n },\n [filter, searchValue, textFilterFn, isLoadingItems],\n );\n\n // Handle custom values if allowed\n const enhancedChildren = useMemo(() => {\n let childrenToProcess = mergedChildren;\n\n // Handle custom values if allowed\n if (!allowsCustomValue) return childrenToProcess;\n\n const term = searchValue.trim();\n if (!term) return childrenToProcess;\n\n // Helper to determine if the term is already present (exact match on rendered textValue or the key).\n const doesTermExist = (term: string): boolean => {\n // Check if term exists in custom keys\n if (customKeys.has(term)) {\n return true;\n }\n\n // Check if term exists in original collection\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n const textValue = item.textValue || String(item.rendered || '');\n if (term === textValue || String(item.key) === term) {\n return true;\n }\n }\n }\n return false;\n };\n\n if (doesTermExist(term)) {\n return childrenToProcess;\n }\n\n // Check if there are any items that will match the filter.\n // This determines whether we need to visually separate the custom value\n // from real items (i.e. render a divider between sections). When there\n // are no visible items, we skip the section wrapper so no divider is\n // drawn above a lone custom-value option.\n //\n // Selected custom values (from `customKeys`) are filtered by `localFilter`\n // in `mergedChildren` regardless of `filter={false}`, so this check must\n // use the same logic — otherwise we'd report \"items visible\" and draw a\n // divider while the actual collection only contains the custom value.\n const localFilter: FilterFn =\n typeof filter === 'function' ? filter : contains;\n\n const hasVisibleFilteredItems = (() => {\n for (const item of localCollectionState.collection) {\n if (item.type === 'item') {\n const textValue = item.textValue || String(item.rendered || '');\n if (textFilterFn(textValue, term)) {\n return true;\n }\n } else if (item.type === 'section' && item.childNodes) {\n for (const child of item.childNodes) {\n const textValue = child.textValue || String(child.rendered || '');\n if (textFilterFn(textValue, term)) {\n return true;\n }\n }\n }\n }\n\n for (const customKey of customKeys) {\n if (localFilter(customKey, term)) {\n return true;\n }\n }\n\n return false;\n })();\n\n // Create the custom option\n const customOption = (\n <Item\n key={term}\n textValue={term}\n {...mergeProps(customValueProps, newCustomValueProps)}\n >\n {term}\n </Item>\n );\n\n // If there are visible filtered items, add visual separation for custom value\n if (hasVisibleFilteredItems && childrenToProcess) {\n // Check if the collection contains any sections\n // If it does, we can't wrap childrenToProcess in another section (would create nested sections)\n const hasSections = [...localCollectionState.collection].some(\n (item) => item.type === 'section',\n );\n\n const customValueSection = (\n <BaseSection key=\"__custom_value__\" aria-label=\"Custom value\">\n {customOption}\n </BaseSection>\n );\n\n if (hasSections) {\n // Collection has sections - just append the custom value section without wrapping\n if (Array.isArray(childrenToProcess)) {\n return [...childrenToProcess, customValueSection];\n }\n return [childrenToProcess, customValueSection];\n }\n\n // No sections in collection - wrap items in a section for visual separation\n const filteredItemsSection = (\n <BaseSection key=\"__filtered_items__\" aria-label=\"Filtered items\">\n {childrenToProcess}\n </BaseSection>\n );\n\n return [filteredItemsSection, customValueSection];\n }\n\n // No visible filtered items, just return the custom option without sections\n if (Array.isArray(childrenToProcess)) {\n return [...childrenToProcess, customOption];\n }\n\n if (childrenToProcess) {\n return [childrenToProcess, customOption];\n }\n\n return customOption;\n }, [\n allowsCustomValue,\n mergedChildren,\n searchValue,\n customKeys,\n localCollectionState.collection,\n customValueProps,\n newCustomValueProps,\n textFilterFn,\n filter,\n contains,\n ]);\n\n styles = extractStyles(otherProps, PROP_STYLES, styles);\n\n ref = useCombinedRefs(ref);\n searchInputRef = useCombinedRefs(searchInputRef);\n listRef = useCombinedRefs(listRef);\n\n const { isFocused, focusProps } = useFocus({ isDisabled });\n const isInvalid = validationState === 'invalid';\n\n const listBoxRef = useRef<HTMLDivElement>(null);\n\n // Ref to access internal ListBox state (selection manager, etc.)\n const listStateRef = useRef<any>(null);\n\n // No separate focusedKey state needed; rely directly on selectionManager.focusedKey.\n\n // When the search value changes, the visible collection of items may change as well.\n // If the currently focused item is no longer visible, move virtual focus to the first\n // available item so that arrow navigation and Enter behaviour continue to work.\n // If there are no available items, reset the selection so Enter won't select anything.\n // Priority: focus on selected items first, then fall back to first visible item.\n useLayoutEffect(() => {\n const listState = listStateRef.current;\n\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Walk the collection and:\n // 1. Collect visible item keys (supports sections).\n // 2. Detect the synthetic \"new custom value\" option — the one generated\n // from the current search term when `allowsCustomValue` is true.\n //\n // The custom value is rendered in one of two layouts depending on whether\n // any real item text-matches the search term (`hasVisibleFilteredItems`\n // in `enhancedChildren`):\n // • Some items match → wrapped in a `__custom_value__` section\n // (`customValueHasMatches = true`)\n // • No items match → appended at the top level with key === term\n // (`customValueHasMatches = false`)\n //\n // The layout itself is the signal we use to decide whether the custom\n // value should be the focus target (no matches) or whether focus should\n // move to a real item (matches present).\n const term = searchValue.trim();\n let newCustomValueKey: Key | null = null;\n let customValueHasMatches = false;\n\n const collectVisibleKeys = (\n nodes: Iterable<any>,\n out: Key[],\n inCustomSection = false,\n ) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n if (inCustomSection) {\n newCustomValueKey = node.key;\n customValueHasMatches = true;\n }\n } else if (node.childNodes) {\n const isCustomSection =\n inCustomSection || node.key === '__custom_value__';\n collectVisibleKeys(node.childNodes, out, isCustomSection);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n // Detect the appended-at-top-level case (no items text-match). The custom\n // option is added with key === trimmed search term and lives directly in\n // the top-level collection (not nested in any section).\n if (newCustomValueKey == null && allowsCustomValue && term) {\n for (const node of collection) {\n if (node.type === 'item' && String(node.key) === term) {\n newCustomValueKey = node.key;\n customValueHasMatches = false;\n break;\n }\n }\n }\n\n // If there are no visible items, reset the focused key so Enter won't select anything\n if (visibleKeys.length === 0) {\n selectionManager.setFocusedKey(null);\n return;\n }\n\n // The custom value should be the focus target when it exists and there\n // are no real text-matches — the user's typed value is then the only\n // actionable option. During an in-flight server fetch (`filter === false`\n // + `isLoadingItems`) `textFilterFn` falls back to client-side `contains`\n // so non-matching stale items are hidden, which keeps this signal honest.\n const customValueShouldBeFocused =\n newCustomValueKey != null && !customValueHasMatches;\n\n // Decide whether the current focus is already on the right thing. If yes,\n // don't disturb it. Otherwise fall through and re-pick a focus target.\n const currentFocused = selectionManager.focusedKey;\n if (currentFocused != null && visibleKeys.includes(currentFocused)) {\n const currentIsNewCustomValue =\n newCustomValueKey != null && currentFocused === newCustomValueKey;\n if (customValueShouldBeFocused) {\n if (currentIsNewCustomValue) return;\n } else if (newCustomValueKey != null) {\n // Custom value exists but isn't the priority (matches available) —\n // any non-custom focus is fine.\n if (!currentIsNewCustomValue) return;\n } else {\n // No custom value involved at all.\n return;\n }\n }\n\n // Helper to find the first selected item that's visible\n const findFirstVisibleSelectedKey = (): Key | null => {\n if (selectionMode === 'single') {\n // Single selection: check if selectedKey is visible\n if (selectedKey != null) {\n const selectedKeyStr = String(selectedKey);\n if (visibleKeys.some((k) => String(k) === selectedKeyStr)) {\n return selectedKey;\n }\n }\n } else if (selectionMode === 'multiple') {\n // Multiple selection: find first selected key that's visible\n if (selectedKeys && selectedKeys !== 'all') {\n for (const key of selectedKeys) {\n const keyStr = String(key);\n if (visibleKeys.some((k) => String(k) === keyStr)) {\n return key;\n }\n }\n }\n }\n return null;\n };\n\n // Determine which key to focus\n let keyToFocus: Key | null = null;\n\n if (customValueShouldBeFocused) {\n // No real matches — promote the custom value over any selected/stale\n // item so the user can press Enter to add the value they just typed.\n keyToFocus = newCustomValueKey;\n } else {\n keyToFocus = findFirstVisibleSelectedKey();\n\n // Fallback to first visible item if no selected item found. Prefer the\n // first real (non-custom-value) item so focus doesn't land on the\n // bottom-of-list custom-value suggestion when real items are available.\n if (keyToFocus == null) {\n const firstRealKey = visibleKeys.find((k) => k !== newCustomValueKey);\n keyToFocus = firstRealKey ?? visibleKeys[0];\n }\n }\n\n // Mark this focus change as keyboard navigation so ListBox will scroll to it\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n\n // Set focus to the determined key\n selectionManager.setFocusedKey(keyToFocus);\n }, [\n searchValue,\n enhancedChildren,\n selectionMode,\n selectedKey,\n selectedKeys,\n allowsCustomValue,\n ]);\n\n // Keyboard navigation handler for search input\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n e.preventDefault();\n\n const listState = listStateRef.current;\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Helper to collect visible item keys (supports sections)\n // Collection is already filtered by React Stately via filterFn\n const collectVisibleKeys = (nodes: Iterable<any>, out: Key[]) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n } else if (node.childNodes) {\n collectVisibleKeys(node.childNodes, out);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n if (visibleKeys.length === 0) return;\n\n const isArrowDown = e.key === 'ArrowDown';\n const direction = isArrowDown ? 1 : -1;\n\n const currentKey = selectionManager.focusedKey;\n\n let nextKey: Key | null = null;\n\n if (currentKey == null) {\n // If nothing focused yet, pick first/last depending on direction\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n } else {\n const currentIndex = visibleKeys.indexOf(currentKey);\n if (currentIndex !== -1) {\n const newIndex = currentIndex + direction;\n if (newIndex >= 0 && newIndex < visibleKeys.length) {\n nextKey = visibleKeys[newIndex];\n } else if (shouldFocusWrap) {\n // Wrap around\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n }\n } else {\n // Fallback\n nextKey = isArrowDown\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n }\n }\n\n if (nextKey != null) {\n // Mark this focus change as keyboard navigation\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n selectionManager.setFocusedKey(nextKey);\n }\n } else if (\n e.key === 'Home' ||\n e.key === 'End' ||\n e.key === 'PageUp' ||\n e.key === 'PageDown'\n ) {\n e.preventDefault();\n\n const listState = listStateRef.current;\n if (!listState) return;\n\n const { selectionManager, collection } = listState;\n\n // Helper to collect visible item keys (supports sections)\n // Collection is already filtered by React Stately via filterFn\n const collectVisibleKeys = (nodes: Iterable<any>, out: Key[]) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n out.push(node.key);\n } else if (node.childNodes) {\n collectVisibleKeys(node.childNodes, out);\n }\n }\n };\n\n const visibleKeys: Key[] = [];\n collectVisibleKeys(collection, visibleKeys);\n\n if (visibleKeys.length === 0) return;\n\n const targetKey =\n e.key === 'Home' || e.key === 'PageUp'\n ? visibleKeys[0]\n : visibleKeys[visibleKeys.length - 1];\n\n // Mark this focus change as keyboard navigation\n if (listState.lastFocusSourceRef) {\n listState.lastFocusSourceRef.current = 'keyboard';\n }\n selectionManager.setFocusedKey(targetKey);\n } else if (e.key === 'Enter' || (e.key === ' ' && !searchValue)) {\n const listState = listStateRef.current;\n\n if (!listState) return;\n\n const keyToSelect = listState.selectionManager.focusedKey;\n\n if (keyToSelect != null) {\n e.preventDefault();\n listState.selectionManager.select(keyToSelect, e);\n\n if (\n e.key === 'Enter' &&\n isCheckable &&\n onEscape &&\n selectionMode === 'multiple'\n ) {\n onEscape();\n }\n }\n } else if (e.key === 'Escape') {\n if (searchValue) {\n // Clear the current search if any text is present.\n e.preventDefault();\n handleSearchChange('');\n } else {\n // Notify parent that Escape was pressed on an empty input.\n if (onEscape) {\n e.preventDefault();\n onEscape();\n }\n }\n }\n },\n });\n\n const mods = useMemo(\n () => ({\n invalid: isInvalid,\n valid: validationState === 'valid',\n disabled: !!isDisabled,\n focused: isFocused,\n loading: !!isLoading,\n 'loading-items': !!isLoadingItems,\n searchable: true,\n prefix: !!isLoading,\n suffix: !!isLoadingItems,\n ...externalMods,\n }),\n [\n isInvalid,\n validationState,\n isDisabled,\n isFocused,\n isLoading,\n isLoadingItems,\n externalMods,\n ],\n );\n\n // Handler must be defined before we render ListBox so we can pass it.\n const handleSelectionChange = (selection: any) => {\n if (allowsCustomValue) {\n // Normalize current selection into an array of string keys\n let selectedValues: string[] = [];\n\n if (selection != null) {\n if (Array.isArray(selection)) {\n selectedValues = selection.map(String);\n } else {\n selectedValues = [String(selection)];\n }\n }\n\n // Build next custom keys set based on selected values\n const nextSet = new Set<string>();\n\n selectedValues.forEach((val) => {\n if (!originalKeys.has(val)) {\n nextSet.add(val);\n }\n });\n\n // Update internal custom keys state\n setCustomKeys(nextSet);\n }\n\n if (externalOnSelectionChange) {\n (externalOnSelectionChange as any)(selection);\n }\n };\n\n // Custom option click handler that ensures search input receives focus\n const handleOptionClick = (key: Key) => {\n // Focus the search input to enable keyboard navigation\n // Use setTimeout to ensure this happens after React state updates\n setTimeout(() => {\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n }, 0);\n\n // Call the original onOptionClick if provided\n if (onOptionClick) {\n onOptionClick(key);\n }\n };\n\n const searchInput = (\n <SearchWrapperElement mods={mods} data-size={size}>\n {isLoading && (\n <div data-element=\"Prefix\">\n <div data-element=\"InputIcon\">\n {isLoading ? <LoadingIcon /> : null}\n </div>\n </div>\n )}\n <SearchInputElement\n ref={searchInputRef}\n qa={qa || 'FilterListBox'}\n id={id}\n data-prefix={isLoading ? '' : undefined}\n data-suffix={isLoadingItems ? '' : undefined}\n type=\"search\"\n placeholder={searchPlaceholder}\n value={searchValue}\n disabled={isDisabled}\n autoFocus={autoFocus}\n data-autofocus={autoFocus ? '' : undefined}\n styles={searchInputStyles}\n data-size={size}\n data-input-type=\"filterlistbox\"\n role=\"combobox\"\n aria-expanded=\"true\"\n aria-haspopup=\"listbox\"\n aria-activedescendant={\n listStateRef.current?.selectionManager.focusedKey != null\n ? `ListBoxItem-${listStateRef.current?.selectionManager.focusedKey}`\n : undefined\n }\n onChange={(e) => {\n handleSearchChange(e.target.value);\n }}\n {...keyboardProps}\n {...modAttrs(mods)}\n />\n {isLoadingItems && (\n <div data-element=\"Suffix\">\n <LoadingIcon data-element=\"InputIcon\" />\n </div>\n )}\n </SearchWrapperElement>\n );\n\n const filterListBoxField = (\n <FilterListBoxWrapperElement\n ref={ref}\n qa=\"FilterListBoxWrapper\"\n {...modAttrs(mods)}\n styles={styles}\n {...focusProps}\n >\n {header ? (\n <StyledHeaderWithoutBorder data-size={size} styles={headerStyles}>\n {header}\n </StyledHeaderWithoutBorder>\n ) : (\n <div role=\"presentation\" />\n )}\n {searchInput}\n <ListBox\n ref={listBoxRef}\n aria-label={innerAriaLabel}\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n selectedKeys={selectedKeys}\n defaultSelectedKeys={defaultSelectedKeys}\n selectionMode={selectionMode}\n isDisabled={isDisabled}\n listRef={listRef}\n stateRef={listStateRef}\n listStyles={listStyles}\n shouldFocusWrap={shouldFocusWrap}\n optionStyles={optionStyles}\n sectionStyles={sectionStyles}\n headingStyles={headingStyles}\n validationState={validationState}\n disallowEmptySelection={props.disallowEmptySelection}\n disabledKeys={props.disabledKeys}\n focusOnHover={focusOnHover}\n shouldUseVirtualFocus={!(isReorderable && !searchValue.trim())}\n showSelectAll={showSelectAll}\n selectAllLabel={selectAllLabel}\n footer={footer}\n footerStyles={footerStyles}\n mods={mods}\n size=\"medium\"\n styles={listBoxStyles}\n isCheckable={isCheckable}\n items={items as any}\n allValueProps={allValueProps}\n filter={filterFn}\n emptyLabel={\n emptyLabel !== undefined\n ? emptyLabel\n : searchValue.trim()\n ? 'No results found'\n : 'No items'\n }\n isReorderable={isReorderable && !searchValue.trim()}\n onReorder={onReorder}\n onSelectionChange={handleSelectionChange}\n onEscape={onEscape}\n onOptionClick={handleOptionClick}\n >\n {enhancedChildren as any}\n </ListBox>\n </FilterListBoxWrapperElement>\n );\n\n return wrapWithField<Omit<CubeFilterListBoxProps<T>, 'children'>>(\n filterListBoxField,\n ref,\n props,\n );\n}) as unknown as (<T>(\n props: CubeFilterListBoxProps<T> & { ref?: ForwardedRef<HTMLDivElement> },\n) => ReactElement) & { Item: typeof Item; Section: typeof BaseSection };\n\nFilterListBox.Item = ListBox.Item;\n\nFilterListBox.Section = BaseSection;\n\nObject.defineProperty(FilterListBox, 'cubeInputType', {\n value: 'FilterListBox',\n enumerable: false,\n configurable: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,8BAA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ACpD,OAAO;CACP,YAAY;CACZ,cAAc;CACf,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.133.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useEventBus } from "../../../utils/react/useEventBus.js";
|
|
4
4
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
@@ -55,7 +55,7 @@ const FilterPicker = forwardRef(function FilterPicker(props, ref) {
|
|
|
55
55
|
};
|
|
56
56
|
return fieldProps;
|
|
57
57
|
} });
|
|
58
|
-
let { qa, label, extra, id, icon, rightIcon, prefix, suffix, hotkeys, triggerTooltip, triggerDescription, labelStyles, isRequired, necessityIndicator, validationState, isDisabled, isLoading, message, mods: externalMods, description, descriptionPlacement, placeholder, size = "medium", styles, listBoxStyles, popoverStyles, type = "outline", theme = "default", shape, labelSuffix, shouldFocusWrap, children, shouldFlip = true, containerPadding = 8, selectedKey, defaultSelectedKey, selectedKeys, defaultSelectedKeys, disabledKeys, onSelectionChange, selectionMode = "single", listStateRef, focusOnHover, showSelectAll, selectAllLabel = "All", items, header, footer, headerStyles, footerStyles, triggerStyles, allowsCustomValue, renderSummary, isCheckable, allValueProps, customValueProps, newCustomValueProps, searchPlaceholder, autoFocus, filter, emptyLabel, searchInputStyles, searchInputRef, listStyles, optionStyles, sectionStyles, headingStyles, listRef, disallowEmptySelection, shouldUseVirtualFocus, onEscape, onOptionClick, isClearable, isLoadingItems, searchValue, onSearchChange, sortSelectedToTop: sortSelectedToTopProp, onOpenChange, form, ...otherProps } = props;
|
|
58
|
+
let { qa, label, extra, id, icon, rightIcon, prefix, suffix, hotkeys, triggerTooltip, triggerDescription, labelStyles, isRequired, necessityIndicator, validationState, isDisabled, isLoading, message, mods: externalMods, description, descriptionPlacement, placeholder, size = "medium", styles, listBoxStyles, popoverStyles, type = "outline", theme = "default", shape, labelSuffix, shouldFocusWrap, children, shouldFlip = true, containerPadding = 8, selectedKey, defaultSelectedKey, selectedKeys, defaultSelectedKeys, disabledKeys, onSelectionChange, selectionMode = "single", listStateRef, focusOnHover, showSelectAll, selectAllLabel = "All", items, header, footer, headerStyles, footerStyles, triggerStyles, allowsCustomValue, renderSummary, isCheckable, allValueProps, customValueProps, newCustomValueProps, searchPlaceholder, autoFocus, filter, emptyLabel, searchInputStyles, searchInputRef, listStyles, optionStyles, sectionStyles, headingStyles, listRef, disallowEmptySelection, shouldUseVirtualFocus, onEscape, onOptionClick, isClearable, isLoadingItems, searchValue, onSearchChange, sortSelectedToTop: sortSelectedToTopProp, onOpenChange, isReorderable, onReorder, form, ...otherProps } = props;
|
|
59
59
|
const sortSelectedToTopExplicit = sortSelectedToTopProp !== void 0;
|
|
60
60
|
const sortSelectedToTop = sortSelectedToTopProp ?? (items ? true : false);
|
|
61
61
|
styles = extractStyles(otherProps, PROP_STYLES, styles);
|
|
@@ -414,7 +414,9 @@ const FilterPicker = forwardRef(function FilterPicker(props, ref) {
|
|
|
414
414
|
allValueProps,
|
|
415
415
|
customValueProps,
|
|
416
416
|
newCustomValueProps,
|
|
417
|
+
isReorderable,
|
|
417
418
|
onSearchChange,
|
|
419
|
+
onReorder,
|
|
418
420
|
onEscape: handleEscape,
|
|
419
421
|
onOptionClick: handleOptionClick,
|
|
420
422
|
onSelectionChange: handleSelectionChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPicker.js","names":["Text","ItemButton","BaseSection"],"sources":["../../../../src/components/fields/FilterPicker/FilterPicker.tsx"],"sourcesContent":["import { CollectionChildren, FocusableRefValue } from '@react-types/shared';\nimport {\n BASE_STYLES,\n BasePropsWithoutChildren,\n BaseStyleProps,\n COLOR_STYLES,\n ColorStyleProps,\n filterBaseProps,\n OUTER_STYLES,\n OuterStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n ForwardedRef,\n forwardRef,\n ReactElement,\n ReactNode,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FocusScope, Key, useKeyboard } from 'react-aria';\nimport { Section as BaseSection, ListState, useListState } from 'react-stately';\n\nimport { useEvent } from '../../../_internal';\nimport { useWarn } from '../../../_internal/hooks/use-warn';\nimport { CloseIcon, DirectionIcon, LoadingIcon } from '../../../icons';\nimport { useProviderProps } from '../../../provider';\nimport { generateRandomId } from '../../../utils/random';\nimport { useEventBus } from '../../../utils/react/useEventBus';\nimport { processSelectionArray } from '../../../utils/selection';\nimport { extractStyles } from '../../../utils/styles';\nimport { CubeItemButtonProps, ItemAction, ItemButton } from '../../actions';\nimport { CubeItemProps } from '../../content/Item';\nimport { Text } from '../../content/Text';\nimport { useFieldProps, useFormProps, wrapWithField } from '../../form';\nimport { Dialog, DialogTrigger } from '../../overlays/Dialog';\nimport {\n CubeFilterListBoxProps,\n FilterListBox,\n} from '../FilterListBox/FilterListBox';\nimport { ListBox } from '../ListBox';\n\nimport type { FieldBaseProps } from '../../../shared';\n\ninterface ItemWithKey {\n key?: string | number;\n id?: string | number;\n textValue?: string;\n children?: ItemWithKey[];\n [key: string]: unknown;\n}\n\nexport interface CubeFilterPickerProps<T>\n extends Omit<CubeFilterListBoxProps<T>, 'size' | 'tooltip' | 'shape'>,\n Omit<CubeItemProps, 'children' | 'size'>,\n BasePropsWithoutChildren,\n BaseStyleProps,\n OuterStyleProps,\n ColorStyleProps,\n Omit<FieldBaseProps, 'tooltip'>,\n Pick<\n CubeItemButtonProps,\n | 'type'\n | 'theme'\n | 'icon'\n | 'rightIcon'\n | 'prefix'\n | 'suffix'\n | 'hotkeys'\n | 'shape'\n > {\n /** Placeholder text when no selection is made */\n placeholder?: string;\n /** Size of the picker component */\n size?: 'small' | 'medium' | 'large';\n /** Custom styles for the list box popover */\n listBoxStyles?: Styles;\n /** Custom styles for the popover container */\n popoverStyles?: Styles;\n /** Custom styles for the trigger button */\n triggerStyles?: Styles;\n /** Whether to show checkboxes for multiple selection mode */\n isCheckable?: boolean;\n /** Whether to flip the popover placement */\n shouldFlip?: boolean;\n /** Minimum padding in pixels between the popover and viewport edges */\n containerPadding?: number;\n /** Tooltip for the trigger button (separate from field tooltip) */\n triggerTooltip?: CubeItemProps['tooltip'];\n /** Description for the trigger button (separate from field description) */\n triggerDescription?: CubeItemProps['description'];\n\n /**\n * Custom renderer for the summary shown inside the trigger when there is a selection.\n *\n * For `selectionMode=\"multiple\"` the function receives:\n * - `selectedLabels`: array of labels of the selected items.\n * - `selectedKeys`: array of keys of the selected items or \"all\".\n *\n * For `selectionMode=\"single\"` the function receives:\n * - `selectedLabel`: label of the selected item.\n * - `selectedKey`: key of the selected item.\n *\n * The function should return a `ReactNode` that will be rendered inside the trigger.\n * Set to `false` to hide the summary text completely.\n */\n renderSummary?:\n | ((args: {\n selectedLabels?: string[];\n selectedKeys?: 'all' | (string | number)[];\n selectedLabel?: string;\n selectedKey?: string | number | null;\n selectionMode?: 'single' | 'multiple';\n }) => ReactNode)\n | false;\n\n /** Ref to access internal ListBox state (from FilterListBox) */\n listStateRef?: RefObject<ListState<T>>;\n /** Additional modifiers for styling the FilterPicker */\n mods?: Record<string, boolean>;\n /** Whether the filter picker is clearable using a clear button in the rightIcon slot */\n isClearable?: boolean;\n /** Callback called when the clear button is pressed */\n onClear?: () => void;\n /**\n * Whether items are currently loading. Shows a loading spinner in the search\n * input suffix inside the popover. Unlike `isLoading`, this does NOT disable\n * the trigger.\n */\n isLoadingItems?: boolean;\n /**\n * Sort selected items to the top when the popover opens.\n * Only works when using the `items` prop (data-driven mode).\n * Ignored when using JSX children.\n * @default true when items are provided, false when using JSX children\n */\n sortSelectedToTop?: boolean;\n /** Callback called when the popover open state changes */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nconst PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];\n\nconst FilterPickerWrapper = tasty({\n qa: 'FilterPicker',\n styles: {\n display: 'inline-grid',\n flow: 'column',\n gridRows: '1sf',\n placeContent: 'stretch',\n placeItems: 'stretch',\n },\n});\n\nexport const FilterPicker = forwardRef(function FilterPicker<T extends object>(\n props: CubeFilterPickerProps<T>,\n ref: ForwardedRef<HTMLElement>,\n) {\n props = useProviderProps(props);\n props = useFormProps(props);\n props = useFieldProps(props, {\n valuePropsMapper: ({ value, onChange }) => {\n const fieldProps: Record<string, unknown> = {};\n\n if (props.selectionMode === 'multiple') {\n fieldProps.selectedKeys = value || [];\n } else {\n fieldProps.selectedKey = value ?? null;\n }\n\n fieldProps.onSelectionChange = (key: Key | null | 'all' | Key[]) => {\n if (props.selectionMode === 'multiple') {\n if (key === 'all') {\n onChange('all');\n } else {\n onChange(key ? (Array.isArray(key) ? key : [key]) : []);\n }\n } else {\n onChange(Array.isArray(key) ? key[0] : key);\n }\n };\n\n return fieldProps;\n },\n });\n\n let {\n qa,\n label,\n extra,\n id,\n icon,\n rightIcon,\n prefix,\n suffix,\n hotkeys,\n triggerTooltip,\n triggerDescription,\n labelStyles,\n isRequired,\n necessityIndicator,\n validationState,\n isDisabled,\n isLoading,\n message,\n mods: externalMods,\n description,\n descriptionPlacement,\n placeholder,\n size = 'medium',\n styles,\n listBoxStyles,\n popoverStyles,\n type = 'outline',\n theme = 'default',\n shape,\n labelSuffix,\n shouldFocusWrap,\n children,\n shouldFlip = true,\n containerPadding = 8,\n selectedKey,\n defaultSelectedKey,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onSelectionChange,\n selectionMode = 'single',\n listStateRef,\n focusOnHover,\n showSelectAll,\n selectAllLabel = 'All',\n items,\n header,\n footer,\n headerStyles,\n footerStyles,\n triggerStyles,\n allowsCustomValue,\n renderSummary,\n isCheckable,\n allValueProps,\n customValueProps,\n newCustomValueProps,\n searchPlaceholder,\n autoFocus,\n filter,\n emptyLabel,\n searchInputStyles,\n searchInputRef,\n listStyles,\n optionStyles,\n sectionStyles,\n headingStyles,\n listRef,\n disallowEmptySelection,\n shouldUseVirtualFocus,\n onEscape,\n onOptionClick,\n isClearable,\n isLoadingItems,\n searchValue,\n onSearchChange,\n sortSelectedToTop: sortSelectedToTopProp,\n onOpenChange,\n form,\n ...otherProps\n } = props;\n\n const sortSelectedToTopExplicit = sortSelectedToTopProp !== undefined;\n const sortSelectedToTop = sortSelectedToTopProp ?? (items ? true : false);\n\n styles = extractStyles(otherProps, PROP_STYLES, styles);\n\n const filterPickerId = useMemo(() => generateRandomId(), []);\n\n const { emit, on } = useEventBus();\n\n useWarn(isCheckable === false && selectionMode === 'single', {\n key: ['filterpicker-checkable-single-mode'],\n args: [\n 'CubeUIKit: isCheckable=false is not recommended in single selection mode as it may confuse users about selection behavior.',\n ],\n });\n\n useWarn(sortSelectedToTopExplicit && sortSelectedToTop && !items, {\n key: ['filterpicker-sort-selected-to-top-children'],\n args: [\n 'FilterPicker: sortSelectedToTop only works with the items prop. Sorting will be skipped when using JSX children.',\n ],\n });\n\n // Internal selection state (uncontrolled scenario)\n const [internalSelectedKey, setInternalSelectedKey] = useState<Key | null>(\n defaultSelectedKey ?? null,\n );\n const [internalSelectedKeys, setInternalSelectedKeys] = useState<\n 'all' | Key[]\n >(defaultSelectedKeys ?? []);\n\n // Popover state — used as controlled prop for DialogTrigger\n const [isPopoverOpen, setIsPopoverOpen] = useState(false);\n const cachedItemsOrder = useRef<T[] | null>(null);\n const triggerRef = useRef<FocusableRefValue<HTMLButtonElement>>(null);\n // Measured lazily on popover open instead of on every render\n const triggerWidthRef = useRef<number | undefined>(undefined);\n\n useEffect(() => {\n cachedItemsOrder.current = null;\n }, [items]);\n\n const isControlledSingle = selectedKey !== undefined;\n const isControlledMultiple = selectedKeys !== undefined;\n\n const effectiveSelectedKey = isControlledSingle\n ? selectedKey\n : internalSelectedKey;\n const effectiveSelectedKeys = isControlledMultiple\n ? selectedKeys\n : internalSelectedKeys;\n\n // Collection for label extraction (shared with FilterListBox via _internalCollection)\n const localCollectionState = useListState({\n children: children as any,\n items: items as any,\n selectionMode: 'none' as any,\n });\n\n // Build Maps for O(1) label and key lookups from the collection\n const { labelMap, keyMap } = useMemo(() => {\n const lm = new Map<string, string>();\n const km = new Map<string, Key>();\n\n const traverse = (nodes: Iterable<any>) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n const strKey = String(node.key);\n lm.set(strKey, node.textValue || strKey);\n km.set(strKey, node.key);\n } else if (node.childNodes) {\n traverse(node.childNodes);\n }\n }\n };\n\n traverse(localCollectionState.collection);\n return { labelMap: lm, keyMap: km };\n }, [localCollectionState.collection]);\n\n // O(1) key mapping via Map (replaces O(n) iteration per key)\n const mappedSelectedKey = useMemo(() => {\n if (selectionMode !== 'single' || effectiveSelectedKey == null) return null;\n const strKey = String(effectiveSelectedKey);\n return keyMap.get(strKey) ?? effectiveSelectedKey;\n }, [selectionMode, effectiveSelectedKey, keyMap]);\n\n const mappedSelectedKeys = useMemo(() => {\n if (selectionMode !== 'multiple') return undefined;\n if (effectiveSelectedKeys === 'all') return 'all' as const;\n if (Array.isArray(effectiveSelectedKeys)) {\n return effectiveSelectedKeys.map((k) => {\n const strKey = String(k);\n return keyMap.get(strKey) ?? k;\n });\n }\n return effectiveSelectedKeys;\n }, [selectionMode, effectiveSelectedKeys, keyMap]);\n\n // Memoized label extraction using the labelMap\n const selectedLabels = useMemo(() => {\n if (selectionMode === 'multiple' && effectiveSelectedKeys === 'all') {\n return Array.from(labelMap.values());\n }\n\n const selectedKeyStrs =\n selectionMode === 'multiple' && effectiveSelectedKeys !== 'all'\n ? (effectiveSelectedKeys || []).map(String)\n : effectiveSelectedKey != null\n ? [String(effectiveSelectedKey)]\n : [];\n\n return selectedKeyStrs.map((k) => labelMap.get(k) ?? k);\n }, [selectionMode, effectiveSelectedKey, effectiveSelectedKeys, labelMap]);\n\n const hasSelection = selectedLabels.length > 0;\n\n // Refs for tracking selection state synchronously\n const latestSelectionRef = useRef<{\n single: string | null;\n multiple: 'all' | string[];\n }>({\n single: effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n });\n\n useEffect(() => {\n latestSelectionRef.current = {\n single:\n effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n };\n }, [effectiveSelectedKey, effectiveSelectedKeys]);\n\n const selectionsWhenClosed = useRef<{\n single: string | null;\n multiple: 'all' | string[];\n }>({ single: null, multiple: [] });\n\n useEffect(() => {\n if (!isPopoverOpen) {\n selectionsWhenClosed.current = {\n single:\n effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n };\n }\n }, [effectiveSelectedKey, effectiveSelectedKeys, isPopoverOpen]);\n\n // ---------------------------------------------------------------------------\n // Popover lifecycle — all effects moved out of the inline renderTrigger\n // function so they have a stable component identity and don't tear\n // down/setup on every parent re-render.\n // DialogTrigger is controlled via isOpen/onOpenChange.\n // ---------------------------------------------------------------------------\n\n const handleOpenChange = useEvent((isOpen: boolean) => {\n if (isOpen === isPopoverOpen) return;\n\n if (isOpen) {\n triggerWidthRef.current =\n triggerRef?.current?.UNSAFE_getDOMNode()?.offsetWidth;\n }\n setIsPopoverOpen(isOpen);\n if (!isOpen) {\n selectionsWhenClosed.current = { ...latestSelectionRef.current };\n cachedItemsOrder.current = null;\n onSearchChange?.('');\n }\n onOpenChange?.(isOpen);\n });\n\n // Close this picker when another menu opens (event bus)\n useEffect(() => {\n return on('popover:open', (data: { menuId: string }) => {\n if (data.menuId !== filterPickerId && isPopoverOpen) {\n handleOpenChange(false);\n }\n });\n }, [on, filterPickerId, isPopoverOpen, handleOpenChange]);\n\n // Emit event when this picker opens\n useEffect(() => {\n if (isPopoverOpen) {\n emit('popover:open', { menuId: filterPickerId });\n }\n }, [isPopoverOpen, emit, filterPickerId]);\n\n // Keyboard handler for arrow keys to open popover\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && !isPopoverOpen) {\n e.preventDefault();\n handleOpenChange(true);\n }\n },\n });\n\n // Clear handler\n const clearValue = useEvent(() => {\n if (selectionMode === 'multiple') {\n if (!isControlledMultiple) {\n setInternalSelectedKeys([]);\n }\n onSelectionChange?.([]);\n } else {\n if (!isControlledSingle) {\n setInternalSelectedKey(null);\n }\n onSelectionChange?.(null);\n }\n\n handleOpenChange(false);\n triggerRef?.current?.focus?.();\n props.onClear?.();\n\n return false;\n });\n\n // ---------------------------------------------------------------------------\n // Sorting\n // ---------------------------------------------------------------------------\n\n // Ref values (selectionsWhenClosed.current) are read synchronously inside\n // the memo body; isPopoverOpen changing triggers recomputation at the right\n // time (the ref is updated before the next render).\n const finalItems = useMemo(() => {\n if (!items) return items;\n if (!sortSelectedToTop) return items;\n if (!isPopoverOpen) return items;\n if (cachedItemsOrder.current) return cachedItemsOrder.current;\n\n const selectedSet = new Set<string>();\n\n const addSelected = (key: Key) => {\n if (key != null) selectedSet.add(String(key));\n };\n\n if (selectionMode === 'multiple') {\n if (selectionsWhenClosed.current.multiple === 'all') {\n return items;\n }\n (selectionsWhenClosed.current.multiple as string[]).forEach(addSelected);\n } else {\n if (selectionsWhenClosed.current.single != null) {\n addSelected(selectionsWhenClosed.current.single);\n }\n }\n\n if (selectedSet.size === 0) {\n return items;\n }\n\n const getItemKey = (obj: unknown): string | undefined => {\n if (obj == null || typeof obj !== 'object') return undefined;\n\n const item = obj as ItemWithKey;\n if (item.key != null) return String(item.key);\n if (item.id != null) return String(item.id);\n return undefined;\n };\n\n const sortArray = (arr: unknown[]): unknown[] => {\n const selectedArr: unknown[] = [];\n const unselectedArr: unknown[] = [];\n\n arr.forEach((obj) => {\n const item = obj as ItemWithKey;\n if (obj && Array.isArray(item.children)) {\n const sortedChildren = sortArray(item.children);\n unselectedArr.push({ ...item, children: sortedChildren });\n } else {\n const key = getItemKey(obj);\n if (key && selectedSet.has(key)) {\n selectedArr.push(obj);\n } else {\n unselectedArr.push(obj);\n }\n }\n });\n\n return [...selectedArr, ...unselectedArr];\n };\n\n const itemsArray = Array.isArray(items)\n ? items\n : Array.from(items as Iterable<unknown>);\n const sorted = sortArray(itemsArray) as T[];\n\n cachedItemsOrder.current = sorted;\n\n return sorted;\n }, [items, sortSelectedToTop, selectionMode, isPopoverOpen]);\n\n // ---------------------------------------------------------------------------\n // Trigger content\n // ---------------------------------------------------------------------------\n\n const triggerContent = useMemo((): ReactNode => {\n if (typeof renderSummary === 'function') {\n if (selectionMode === 'single') {\n return renderSummary({\n selectedLabel: selectedLabels[0],\n selectedKey: effectiveSelectedKey ?? null,\n selectedLabels,\n selectedKeys: effectiveSelectedKeys,\n selectionMode: 'single',\n });\n }\n\n return renderSummary({\n selectedLabels,\n selectedKeys: effectiveSelectedKeys,\n selectionMode: 'multiple',\n });\n } else if (renderSummary === false) {\n return null;\n }\n\n if (!hasSelection) {\n return <Text.Placeholder>{placeholder}</Text.Placeholder>;\n } else if (selectionMode === 'single') {\n return selectedLabels[0] || null;\n } else if (effectiveSelectedKeys === 'all') {\n return selectAllLabel;\n } else {\n return selectedLabels.join(', ') || null;\n }\n }, [\n renderSummary,\n selectionMode,\n selectedLabels,\n effectiveSelectedKey,\n effectiveSelectedKeys,\n hasSelection,\n placeholder,\n selectAllLabel,\n ]);\n\n const showClearButton =\n isClearable && hasSelection && !isDisabled && !props.isReadOnly;\n\n // Trigger element — plain JSX with no hooks.\n // The element type (ItemButton) is stable so React can reconcile efficiently.\n const triggerElement = (\n <ItemButton\n ref={triggerRef as any}\n data-popover-trigger\n qa={qa || 'FilterPicker'}\n id={id}\n type={type}\n theme={validationState === 'invalid' ? 'danger' : theme}\n size={size}\n shape={shape}\n isDisabled={isDisabled || isLoading}\n data-input-type=\"filterpicker\"\n mods={{\n placeholder: !hasSelection,\n ...externalMods,\n }}\n icon={icon}\n rightIcon={\n isLoading ? (\n <LoadingIcon />\n ) : rightIcon !== undefined ? (\n rightIcon\n ) : showClearButton ? (\n <ItemAction\n icon={<CloseIcon />}\n size={size}\n theme={validationState === 'invalid' ? 'danger' : undefined}\n qa=\"FilterPickerClearButton\"\n mods={{ pressed: false }}\n onPress={clearValue}\n />\n ) : (\n <DirectionIcon to={isPopoverOpen ? 'top' : 'bottom'} />\n )\n }\n prefix={prefix}\n suffix={suffix}\n hotkeys={hotkeys}\n tooltip={triggerTooltip}\n description={triggerDescription}\n descriptionPlacement={descriptionPlacement}\n styles={triggerStyles}\n {...keyboardProps}\n aria-label={`${props['aria-label'] ?? props.label ?? ''}`}\n >\n {triggerContent}\n </ItemButton>\n );\n\n // ---------------------------------------------------------------------------\n // Selection change handler\n // ---------------------------------------------------------------------------\n\n const handleSelectionChange = useEvent((selection: any) => {\n if (selectionMode === 'single') {\n if (!isControlledSingle) {\n setInternalSelectedKey(selection as Key | null);\n }\n } else {\n if (!isControlledMultiple) {\n let normalized: 'all' | Key[] = selection;\n\n if (selection === 'all') {\n normalized = 'all';\n } else if (Array.isArray(selection)) {\n normalized = processSelectionArray(selection);\n } else if (\n selection &&\n typeof selection === 'object' &&\n selection instanceof Set\n ) {\n normalized = processSelectionArray(selection as Set<Key>);\n }\n\n setInternalSelectedKeys(normalized);\n }\n }\n\n // Update latest selection ref synchronously\n if (selectionMode === 'single') {\n latestSelectionRef.current.single =\n selection != null ? String(selection) : null;\n } else {\n if (selection === 'all') {\n latestSelectionRef.current.multiple = 'all';\n } else if (Array.isArray(selection)) {\n latestSelectionRef.current.multiple = Array.from(\n new Set(processSelectionArray(selection)),\n );\n } else if (\n selection &&\n typeof selection === 'object' &&\n selection instanceof Set\n ) {\n latestSelectionRef.current.multiple = Array.from(\n new Set(processSelectionArray(selection as Set<Key>)),\n );\n } else {\n latestSelectionRef.current.multiple =\n selection === 'all'\n ? 'all'\n : Array.isArray(selection)\n ? selection.map(String)\n : [];\n }\n }\n\n onSelectionChange?.(selection);\n\n if (selectionMode === 'single') {\n handleOpenChange(false);\n }\n });\n\n // Stable callbacks for popover content (avoid inline closures that change every render)\n const handleEscape = useEvent(() => {\n handleOpenChange(false);\n });\n\n const handleOptionClick = useEvent((key: Key) => {\n if ((selectionMode === 'multiple' && isCheckable) || key === '__ALL__') {\n handleOpenChange(false);\n }\n });\n\n const filterPickerField = (\n <FilterPickerWrapper\n qa=\"FilterPickerWrapper\"\n styles={styles}\n {...filterBaseProps(otherProps, { eventProps: true })}\n >\n <DialogTrigger\n isDismissable\n type=\"popover\"\n placement=\"bottom start\"\n isOpen={isPopoverOpen}\n containerPadding={containerPadding}\n shouldFlip={shouldFlip}\n shouldCloseOnInteractOutside={(el) => {\n const menuTriggerEl = el.closest('[data-popover-trigger]');\n if (!menuTriggerEl) return true;\n if (menuTriggerEl === triggerRef?.current?.UNSAFE_getDOMNode())\n return true;\n return false;\n }}\n onOpenChange={handleOpenChange}\n >\n {triggerElement}\n {() => (\n <Dialog\n qa=\"FilterPickerOverlay\"\n display=\"grid\"\n styles={{\n gridRows: '1sf',\n width: 'max($overlay-min-width, 30x) max-content 50vw',\n '$overlay-min-width': '30x',\n ...popoverStyles,\n }}\n style={\n triggerWidthRef.current\n ? ({\n '--overlay-min-width': `${triggerWidthRef.current}px`,\n } as any)\n : undefined\n }\n >\n <FocusScope restoreFocus>\n <FilterListBox\n autoFocus\n items={items ? (finalItems as typeof props.items) : undefined}\n aria-label={`${props['aria-label'] ?? props.label ?? ''} Picker`}\n _internalCollection={localCollectionState.collection}\n selectedKey={\n selectionMode === 'single' ? mappedSelectedKey : undefined\n }\n selectedKeys={\n selectionMode === 'multiple' ? mappedSelectedKeys : undefined\n }\n searchPlaceholder={searchPlaceholder}\n filter={filter}\n searchValue={searchValue}\n listStyles={listStyles}\n optionStyles={optionStyles}\n sectionStyles={sectionStyles}\n headingStyles={headingStyles}\n listRef={listRef}\n disallowEmptySelection={disallowEmptySelection}\n emptyLabel={emptyLabel}\n searchInputStyles={searchInputStyles}\n searchInputRef={searchInputRef}\n disabledKeys={disabledKeys}\n focusOnHover={focusOnHover}\n shouldFocusWrap={shouldFocusWrap}\n allowsCustomValue={allowsCustomValue}\n selectionMode={selectionMode}\n validationState={validationState}\n isDisabled={isDisabled}\n isLoading={isLoading}\n isLoadingItems={isLoadingItems}\n stateRef={listStateRef}\n isCheckable={isCheckable}\n mods={{\n popover: true,\n }}\n size={size === 'small' ? 'medium' : size}\n showSelectAll={showSelectAll}\n selectAllLabel={selectAllLabel}\n header={header}\n footer={footer}\n headerStyles={headerStyles}\n footerStyles={footerStyles}\n allValueProps={allValueProps}\n customValueProps={customValueProps}\n newCustomValueProps={newCustomValueProps}\n onSearchChange={onSearchChange}\n onEscape={handleEscape}\n onOptionClick={handleOptionClick}\n onSelectionChange={handleSelectionChange}\n >\n {\n (children\n ? (children as CollectionChildren<T>)\n : undefined) as CollectionChildren<T>\n }\n </FilterListBox>\n </FocusScope>\n </Dialog>\n )}\n </DialogTrigger>\n </FilterPickerWrapper>\n );\n\n return wrapWithField<Omit<CubeFilterPickerProps<T>, 'children' | 'tooltip'>>(\n filterPickerField,\n ref as any,\n props,\n );\n}) as unknown as (<T>(\n props: CubeFilterPickerProps<T> & { ref?: ForwardedRef<HTMLElement> },\n) => ReactElement) & { Item: typeof ListBox.Item; Section: typeof BaseSection };\n\nFilterPicker.Item = ListBox.Item;\n\nFilterPicker.Section = BaseSection;\n\nObject.defineProperty(FilterPicker, 'cubeInputType', {\n value: 'FilterPicker',\n enumerable: false,\n configurable: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiJA,MAAM,cAAc;CAAC,GAAG;CAAa,GAAG;CAAc,GAAG;CAAa;AAEtE,MAAM,sBAAsB,MAAM;CAChC,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,MAAM;EACN,UAAU;EACV,cAAc;EACd,YAAY;EACb;CACF,CAAC;AAEF,MAAa,eAAe,WAAW,SAAS,aAC9C,OACA,KACA;AACA,SAAQ,iBAAiB,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,oBAAC;MACC;MACA,OAAO,QAAS,aAAoC;MACpD,cAAY,GAAG,MAAM,iBAAiB,MAAM,SAAS,GAAG;MACxD,qBAAqB,qBAAqB;MAC1C,aACE,kBAAkB,WAAW,oBAAoB;MAEnD,cACE,kBAAkB,aAAa,qBAAqB;MAEnC;MACX;MACK;MACD;MACE;MACC;MACA;MACN;MACe;MACZ;MACO;MACH;MACF;MACA;MACG;MACE;MACJ;MACE;MACL;MACD;MACK;MAChB,UAAU;MACG;MACb,MAAM,EACJ,SAAS,MACV;MACD,MAAM,SAAS,UAAU,WAAW;MACrB;MACC;MACR;MACA;MACM;MACA;MACC;MACG;MACG;MACL;MAChB,UAAU;MACV,eAAe;MACf,mBAAmB;gBAGhB,WACI,WACD;OAEQ;MACL;KACN;IAEG;GACI,EAKtB,KACA,MACD;EACD;AAIF,aAAa,OAAO,QAAQ;AAE5B,aAAa,UAAUC;AAEvB,OAAO,eAAe,cAAc,iBAAiB;CACnD,OAAO;CACP,YAAY;CACZ,cAAc;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"FilterPicker.js","names":["Text","ItemButton","BaseSection"],"sources":["../../../../src/components/fields/FilterPicker/FilterPicker.tsx"],"sourcesContent":["import { CollectionChildren, FocusableRefValue } from '@react-types/shared';\nimport {\n BASE_STYLES,\n BasePropsWithoutChildren,\n BaseStyleProps,\n COLOR_STYLES,\n ColorStyleProps,\n filterBaseProps,\n OUTER_STYLES,\n OuterStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n ForwardedRef,\n forwardRef,\n ReactElement,\n ReactNode,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FocusScope, Key, useKeyboard } from 'react-aria';\nimport { Section as BaseSection, ListState, useListState } from 'react-stately';\n\nimport { useEvent } from '../../../_internal';\nimport { useWarn } from '../../../_internal/hooks/use-warn';\nimport { CloseIcon, DirectionIcon, LoadingIcon } from '../../../icons';\nimport { useProviderProps } from '../../../provider';\nimport { generateRandomId } from '../../../utils/random';\nimport { useEventBus } from '../../../utils/react/useEventBus';\nimport { processSelectionArray } from '../../../utils/selection';\nimport { extractStyles } from '../../../utils/styles';\nimport { CubeItemButtonProps, ItemAction, ItemButton } from '../../actions';\nimport { CubeItemProps } from '../../content/Item';\nimport { Text } from '../../content/Text';\nimport { useFieldProps, useFormProps, wrapWithField } from '../../form';\nimport { Dialog, DialogTrigger } from '../../overlays/Dialog';\nimport {\n CubeFilterListBoxProps,\n FilterListBox,\n} from '../FilterListBox/FilterListBox';\nimport { ListBox } from '../ListBox';\n\nimport type { FieldBaseProps } from '../../../shared';\n\ninterface ItemWithKey {\n key?: string | number;\n id?: string | number;\n textValue?: string;\n children?: ItemWithKey[];\n [key: string]: unknown;\n}\n\nexport interface CubeFilterPickerProps<T>\n extends Omit<CubeFilterListBoxProps<T>, 'size' | 'tooltip' | 'shape'>,\n Omit<CubeItemProps, 'children' | 'size'>,\n BasePropsWithoutChildren,\n BaseStyleProps,\n OuterStyleProps,\n ColorStyleProps,\n Omit<FieldBaseProps, 'tooltip'>,\n Pick<\n CubeItemButtonProps,\n | 'type'\n | 'theme'\n | 'icon'\n | 'rightIcon'\n | 'prefix'\n | 'suffix'\n | 'hotkeys'\n | 'shape'\n > {\n /** Placeholder text when no selection is made */\n placeholder?: string;\n /** Size of the picker component */\n size?: 'small' | 'medium' | 'large';\n /** Custom styles for the list box popover */\n listBoxStyles?: Styles;\n /** Custom styles for the popover container */\n popoverStyles?: Styles;\n /** Custom styles for the trigger button */\n triggerStyles?: Styles;\n /** Whether to show checkboxes for multiple selection mode */\n isCheckable?: boolean;\n /** Whether to flip the popover placement */\n shouldFlip?: boolean;\n /** Minimum padding in pixels between the popover and viewport edges */\n containerPadding?: number;\n /** Tooltip for the trigger button (separate from field tooltip) */\n triggerTooltip?: CubeItemProps['tooltip'];\n /** Description for the trigger button (separate from field description) */\n triggerDescription?: CubeItemProps['description'];\n\n /**\n * Custom renderer for the summary shown inside the trigger when there is a selection.\n *\n * For `selectionMode=\"multiple\"` the function receives:\n * - `selectedLabels`: array of labels of the selected items.\n * - `selectedKeys`: array of keys of the selected items or \"all\".\n *\n * For `selectionMode=\"single\"` the function receives:\n * - `selectedLabel`: label of the selected item.\n * - `selectedKey`: key of the selected item.\n *\n * The function should return a `ReactNode` that will be rendered inside the trigger.\n * Set to `false` to hide the summary text completely.\n */\n renderSummary?:\n | ((args: {\n selectedLabels?: string[];\n selectedKeys?: 'all' | (string | number)[];\n selectedLabel?: string;\n selectedKey?: string | number | null;\n selectionMode?: 'single' | 'multiple';\n }) => ReactNode)\n | false;\n\n /** Ref to access internal ListBox state (from FilterListBox) */\n listStateRef?: RefObject<ListState<T>>;\n /** Additional modifiers for styling the FilterPicker */\n mods?: Record<string, boolean>;\n /** Whether the filter picker is clearable using a clear button in the rightIcon slot */\n isClearable?: boolean;\n /** Callback called when the clear button is pressed */\n onClear?: () => void;\n /**\n * Whether items are currently loading. Shows a loading spinner in the search\n * input suffix inside the popover. Unlike `isLoading`, this does NOT disable\n * the trigger.\n */\n isLoadingItems?: boolean;\n /**\n * Sort selected items to the top when the popover opens.\n * Only works when using the `items` prop (data-driven mode).\n * Ignored when using JSX children.\n * @default true when items are provided, false when using JSX children\n */\n sortSelectedToTop?: boolean;\n /** Callback called when the popover open state changes */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nconst PROP_STYLES = [...BASE_STYLES, ...OUTER_STYLES, ...COLOR_STYLES];\n\nconst FilterPickerWrapper = tasty({\n qa: 'FilterPicker',\n styles: {\n display: 'inline-grid',\n flow: 'column',\n gridRows: '1sf',\n placeContent: 'stretch',\n placeItems: 'stretch',\n },\n});\n\nexport const FilterPicker = forwardRef(function FilterPicker<T extends object>(\n props: CubeFilterPickerProps<T>,\n ref: ForwardedRef<HTMLElement>,\n) {\n props = useProviderProps(props);\n props = useFormProps(props);\n props = useFieldProps(props, {\n valuePropsMapper: ({ value, onChange }) => {\n const fieldProps: Record<string, unknown> = {};\n\n if (props.selectionMode === 'multiple') {\n fieldProps.selectedKeys = value || [];\n } else {\n fieldProps.selectedKey = value ?? null;\n }\n\n fieldProps.onSelectionChange = (key: Key | null | 'all' | Key[]) => {\n if (props.selectionMode === 'multiple') {\n if (key === 'all') {\n onChange('all');\n } else {\n onChange(key ? (Array.isArray(key) ? key : [key]) : []);\n }\n } else {\n onChange(Array.isArray(key) ? key[0] : key);\n }\n };\n\n return fieldProps;\n },\n });\n\n let {\n qa,\n label,\n extra,\n id,\n icon,\n rightIcon,\n prefix,\n suffix,\n hotkeys,\n triggerTooltip,\n triggerDescription,\n labelStyles,\n isRequired,\n necessityIndicator,\n validationState,\n isDisabled,\n isLoading,\n message,\n mods: externalMods,\n description,\n descriptionPlacement,\n placeholder,\n size = 'medium',\n styles,\n listBoxStyles,\n popoverStyles,\n type = 'outline',\n theme = 'default',\n shape,\n labelSuffix,\n shouldFocusWrap,\n children,\n shouldFlip = true,\n containerPadding = 8,\n selectedKey,\n defaultSelectedKey,\n selectedKeys,\n defaultSelectedKeys,\n disabledKeys,\n onSelectionChange,\n selectionMode = 'single',\n listStateRef,\n focusOnHover,\n showSelectAll,\n selectAllLabel = 'All',\n items,\n header,\n footer,\n headerStyles,\n footerStyles,\n triggerStyles,\n allowsCustomValue,\n renderSummary,\n isCheckable,\n allValueProps,\n customValueProps,\n newCustomValueProps,\n searchPlaceholder,\n autoFocus,\n filter,\n emptyLabel,\n searchInputStyles,\n searchInputRef,\n listStyles,\n optionStyles,\n sectionStyles,\n headingStyles,\n listRef,\n disallowEmptySelection,\n shouldUseVirtualFocus,\n onEscape,\n onOptionClick,\n isClearable,\n isLoadingItems,\n searchValue,\n onSearchChange,\n sortSelectedToTop: sortSelectedToTopProp,\n onOpenChange,\n isReorderable,\n onReorder,\n form,\n ...otherProps\n } = props;\n\n const sortSelectedToTopExplicit = sortSelectedToTopProp !== undefined;\n const sortSelectedToTop = sortSelectedToTopProp ?? (items ? true : false);\n\n styles = extractStyles(otherProps, PROP_STYLES, styles);\n\n const filterPickerId = useMemo(() => generateRandomId(), []);\n\n const { emit, on } = useEventBus();\n\n useWarn(isCheckable === false && selectionMode === 'single', {\n key: ['filterpicker-checkable-single-mode'],\n args: [\n 'CubeUIKit: isCheckable=false is not recommended in single selection mode as it may confuse users about selection behavior.',\n ],\n });\n\n useWarn(sortSelectedToTopExplicit && sortSelectedToTop && !items, {\n key: ['filterpicker-sort-selected-to-top-children'],\n args: [\n 'FilterPicker: sortSelectedToTop only works with the items prop. Sorting will be skipped when using JSX children.',\n ],\n });\n\n // Internal selection state (uncontrolled scenario)\n const [internalSelectedKey, setInternalSelectedKey] = useState<Key | null>(\n defaultSelectedKey ?? null,\n );\n const [internalSelectedKeys, setInternalSelectedKeys] = useState<\n 'all' | Key[]\n >(defaultSelectedKeys ?? []);\n\n // Popover state — used as controlled prop for DialogTrigger\n const [isPopoverOpen, setIsPopoverOpen] = useState(false);\n const cachedItemsOrder = useRef<T[] | null>(null);\n const triggerRef = useRef<FocusableRefValue<HTMLButtonElement>>(null);\n // Measured lazily on popover open instead of on every render\n const triggerWidthRef = useRef<number | undefined>(undefined);\n\n useEffect(() => {\n cachedItemsOrder.current = null;\n }, [items]);\n\n const isControlledSingle = selectedKey !== undefined;\n const isControlledMultiple = selectedKeys !== undefined;\n\n const effectiveSelectedKey = isControlledSingle\n ? selectedKey\n : internalSelectedKey;\n const effectiveSelectedKeys = isControlledMultiple\n ? selectedKeys\n : internalSelectedKeys;\n\n // Collection for label extraction (shared with FilterListBox via _internalCollection)\n const localCollectionState = useListState({\n children: children as any,\n items: items as any,\n selectionMode: 'none' as any,\n });\n\n // Build Maps for O(1) label and key lookups from the collection\n const { labelMap, keyMap } = useMemo(() => {\n const lm = new Map<string, string>();\n const km = new Map<string, Key>();\n\n const traverse = (nodes: Iterable<any>) => {\n for (const node of nodes) {\n if (node.type === 'item') {\n const strKey = String(node.key);\n lm.set(strKey, node.textValue || strKey);\n km.set(strKey, node.key);\n } else if (node.childNodes) {\n traverse(node.childNodes);\n }\n }\n };\n\n traverse(localCollectionState.collection);\n return { labelMap: lm, keyMap: km };\n }, [localCollectionState.collection]);\n\n // O(1) key mapping via Map (replaces O(n) iteration per key)\n const mappedSelectedKey = useMemo(() => {\n if (selectionMode !== 'single' || effectiveSelectedKey == null) return null;\n const strKey = String(effectiveSelectedKey);\n return keyMap.get(strKey) ?? effectiveSelectedKey;\n }, [selectionMode, effectiveSelectedKey, keyMap]);\n\n const mappedSelectedKeys = useMemo(() => {\n if (selectionMode !== 'multiple') return undefined;\n if (effectiveSelectedKeys === 'all') return 'all' as const;\n if (Array.isArray(effectiveSelectedKeys)) {\n return effectiveSelectedKeys.map((k) => {\n const strKey = String(k);\n return keyMap.get(strKey) ?? k;\n });\n }\n return effectiveSelectedKeys;\n }, [selectionMode, effectiveSelectedKeys, keyMap]);\n\n // Memoized label extraction using the labelMap\n const selectedLabels = useMemo(() => {\n if (selectionMode === 'multiple' && effectiveSelectedKeys === 'all') {\n return Array.from(labelMap.values());\n }\n\n const selectedKeyStrs =\n selectionMode === 'multiple' && effectiveSelectedKeys !== 'all'\n ? (effectiveSelectedKeys || []).map(String)\n : effectiveSelectedKey != null\n ? [String(effectiveSelectedKey)]\n : [];\n\n return selectedKeyStrs.map((k) => labelMap.get(k) ?? k);\n }, [selectionMode, effectiveSelectedKey, effectiveSelectedKeys, labelMap]);\n\n const hasSelection = selectedLabels.length > 0;\n\n // Refs for tracking selection state synchronously\n const latestSelectionRef = useRef<{\n single: string | null;\n multiple: 'all' | string[];\n }>({\n single: effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n });\n\n useEffect(() => {\n latestSelectionRef.current = {\n single:\n effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n };\n }, [effectiveSelectedKey, effectiveSelectedKeys]);\n\n const selectionsWhenClosed = useRef<{\n single: string | null;\n multiple: 'all' | string[];\n }>({ single: null, multiple: [] });\n\n useEffect(() => {\n if (!isPopoverOpen) {\n selectionsWhenClosed.current = {\n single:\n effectiveSelectedKey != null ? String(effectiveSelectedKey) : null,\n multiple:\n effectiveSelectedKeys === 'all'\n ? 'all'\n : (effectiveSelectedKeys ?? []).map(String),\n };\n }\n }, [effectiveSelectedKey, effectiveSelectedKeys, isPopoverOpen]);\n\n // ---------------------------------------------------------------------------\n // Popover lifecycle — all effects moved out of the inline renderTrigger\n // function so they have a stable component identity and don't tear\n // down/setup on every parent re-render.\n // DialogTrigger is controlled via isOpen/onOpenChange.\n // ---------------------------------------------------------------------------\n\n const handleOpenChange = useEvent((isOpen: boolean) => {\n if (isOpen === isPopoverOpen) return;\n\n if (isOpen) {\n triggerWidthRef.current =\n triggerRef?.current?.UNSAFE_getDOMNode()?.offsetWidth;\n }\n setIsPopoverOpen(isOpen);\n if (!isOpen) {\n selectionsWhenClosed.current = { ...latestSelectionRef.current };\n cachedItemsOrder.current = null;\n onSearchChange?.('');\n }\n onOpenChange?.(isOpen);\n });\n\n // Close this picker when another menu opens (event bus)\n useEffect(() => {\n return on('popover:open', (data: { menuId: string }) => {\n if (data.menuId !== filterPickerId && isPopoverOpen) {\n handleOpenChange(false);\n }\n });\n }, [on, filterPickerId, isPopoverOpen, handleOpenChange]);\n\n // Emit event when this picker opens\n useEffect(() => {\n if (isPopoverOpen) {\n emit('popover:open', { menuId: filterPickerId });\n }\n }, [isPopoverOpen, emit, filterPickerId]);\n\n // Keyboard handler for arrow keys to open popover\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && !isPopoverOpen) {\n e.preventDefault();\n handleOpenChange(true);\n }\n },\n });\n\n // Clear handler\n const clearValue = useEvent(() => {\n if (selectionMode === 'multiple') {\n if (!isControlledMultiple) {\n setInternalSelectedKeys([]);\n }\n onSelectionChange?.([]);\n } else {\n if (!isControlledSingle) {\n setInternalSelectedKey(null);\n }\n onSelectionChange?.(null);\n }\n\n handleOpenChange(false);\n triggerRef?.current?.focus?.();\n props.onClear?.();\n\n return false;\n });\n\n // ---------------------------------------------------------------------------\n // Sorting\n // ---------------------------------------------------------------------------\n\n // Ref values (selectionsWhenClosed.current) are read synchronously inside\n // the memo body; isPopoverOpen changing triggers recomputation at the right\n // time (the ref is updated before the next render).\n const finalItems = useMemo(() => {\n if (!items) return items;\n if (!sortSelectedToTop) return items;\n if (!isPopoverOpen) return items;\n if (cachedItemsOrder.current) return cachedItemsOrder.current;\n\n const selectedSet = new Set<string>();\n\n const addSelected = (key: Key) => {\n if (key != null) selectedSet.add(String(key));\n };\n\n if (selectionMode === 'multiple') {\n if (selectionsWhenClosed.current.multiple === 'all') {\n return items;\n }\n (selectionsWhenClosed.current.multiple as string[]).forEach(addSelected);\n } else {\n if (selectionsWhenClosed.current.single != null) {\n addSelected(selectionsWhenClosed.current.single);\n }\n }\n\n if (selectedSet.size === 0) {\n return items;\n }\n\n const getItemKey = (obj: unknown): string | undefined => {\n if (obj == null || typeof obj !== 'object') return undefined;\n\n const item = obj as ItemWithKey;\n if (item.key != null) return String(item.key);\n if (item.id != null) return String(item.id);\n return undefined;\n };\n\n const sortArray = (arr: unknown[]): unknown[] => {\n const selectedArr: unknown[] = [];\n const unselectedArr: unknown[] = [];\n\n arr.forEach((obj) => {\n const item = obj as ItemWithKey;\n if (obj && Array.isArray(item.children)) {\n const sortedChildren = sortArray(item.children);\n unselectedArr.push({ ...item, children: sortedChildren });\n } else {\n const key = getItemKey(obj);\n if (key && selectedSet.has(key)) {\n selectedArr.push(obj);\n } else {\n unselectedArr.push(obj);\n }\n }\n });\n\n return [...selectedArr, ...unselectedArr];\n };\n\n const itemsArray = Array.isArray(items)\n ? items\n : Array.from(items as Iterable<unknown>);\n const sorted = sortArray(itemsArray) as T[];\n\n cachedItemsOrder.current = sorted;\n\n return sorted;\n }, [items, sortSelectedToTop, selectionMode, isPopoverOpen]);\n\n // ---------------------------------------------------------------------------\n // Trigger content\n // ---------------------------------------------------------------------------\n\n const triggerContent = useMemo((): ReactNode => {\n if (typeof renderSummary === 'function') {\n if (selectionMode === 'single') {\n return renderSummary({\n selectedLabel: selectedLabels[0],\n selectedKey: effectiveSelectedKey ?? null,\n selectedLabels,\n selectedKeys: effectiveSelectedKeys,\n selectionMode: 'single',\n });\n }\n\n return renderSummary({\n selectedLabels,\n selectedKeys: effectiveSelectedKeys,\n selectionMode: 'multiple',\n });\n } else if (renderSummary === false) {\n return null;\n }\n\n if (!hasSelection) {\n return <Text.Placeholder>{placeholder}</Text.Placeholder>;\n } else if (selectionMode === 'single') {\n return selectedLabels[0] || null;\n } else if (effectiveSelectedKeys === 'all') {\n return selectAllLabel;\n } else {\n return selectedLabels.join(', ') || null;\n }\n }, [\n renderSummary,\n selectionMode,\n selectedLabels,\n effectiveSelectedKey,\n effectiveSelectedKeys,\n hasSelection,\n placeholder,\n selectAllLabel,\n ]);\n\n const showClearButton =\n isClearable && hasSelection && !isDisabled && !props.isReadOnly;\n\n // Trigger element — plain JSX with no hooks.\n // The element type (ItemButton) is stable so React can reconcile efficiently.\n const triggerElement = (\n <ItemButton\n ref={triggerRef as any}\n data-popover-trigger\n qa={qa || 'FilterPicker'}\n id={id}\n type={type}\n theme={validationState === 'invalid' ? 'danger' : theme}\n size={size}\n shape={shape}\n isDisabled={isDisabled || isLoading}\n data-input-type=\"filterpicker\"\n mods={{\n placeholder: !hasSelection,\n ...externalMods,\n }}\n icon={icon}\n rightIcon={\n isLoading ? (\n <LoadingIcon />\n ) : rightIcon !== undefined ? (\n rightIcon\n ) : showClearButton ? (\n <ItemAction\n icon={<CloseIcon />}\n size={size}\n theme={validationState === 'invalid' ? 'danger' : undefined}\n qa=\"FilterPickerClearButton\"\n mods={{ pressed: false }}\n onPress={clearValue}\n />\n ) : (\n <DirectionIcon to={isPopoverOpen ? 'top' : 'bottom'} />\n )\n }\n prefix={prefix}\n suffix={suffix}\n hotkeys={hotkeys}\n tooltip={triggerTooltip}\n description={triggerDescription}\n descriptionPlacement={descriptionPlacement}\n styles={triggerStyles}\n {...keyboardProps}\n aria-label={`${props['aria-label'] ?? props.label ?? ''}`}\n >\n {triggerContent}\n </ItemButton>\n );\n\n // ---------------------------------------------------------------------------\n // Selection change handler\n // ---------------------------------------------------------------------------\n\n const handleSelectionChange = useEvent((selection: any) => {\n if (selectionMode === 'single') {\n if (!isControlledSingle) {\n setInternalSelectedKey(selection as Key | null);\n }\n } else {\n if (!isControlledMultiple) {\n let normalized: 'all' | Key[] = selection;\n\n if (selection === 'all') {\n normalized = 'all';\n } else if (Array.isArray(selection)) {\n normalized = processSelectionArray(selection);\n } else if (\n selection &&\n typeof selection === 'object' &&\n selection instanceof Set\n ) {\n normalized = processSelectionArray(selection as Set<Key>);\n }\n\n setInternalSelectedKeys(normalized);\n }\n }\n\n // Update latest selection ref synchronously\n if (selectionMode === 'single') {\n latestSelectionRef.current.single =\n selection != null ? String(selection) : null;\n } else {\n if (selection === 'all') {\n latestSelectionRef.current.multiple = 'all';\n } else if (Array.isArray(selection)) {\n latestSelectionRef.current.multiple = Array.from(\n new Set(processSelectionArray(selection)),\n );\n } else if (\n selection &&\n typeof selection === 'object' &&\n selection instanceof Set\n ) {\n latestSelectionRef.current.multiple = Array.from(\n new Set(processSelectionArray(selection as Set<Key>)),\n );\n } else {\n latestSelectionRef.current.multiple =\n selection === 'all'\n ? 'all'\n : Array.isArray(selection)\n ? selection.map(String)\n : [];\n }\n }\n\n onSelectionChange?.(selection);\n\n if (selectionMode === 'single') {\n handleOpenChange(false);\n }\n });\n\n // Stable callbacks for popover content (avoid inline closures that change every render)\n const handleEscape = useEvent(() => {\n handleOpenChange(false);\n });\n\n const handleOptionClick = useEvent((key: Key) => {\n if ((selectionMode === 'multiple' && isCheckable) || key === '__ALL__') {\n handleOpenChange(false);\n }\n });\n\n const filterPickerField = (\n <FilterPickerWrapper\n qa=\"FilterPickerWrapper\"\n styles={styles}\n {...filterBaseProps(otherProps, { eventProps: true })}\n >\n <DialogTrigger\n isDismissable\n type=\"popover\"\n placement=\"bottom start\"\n isOpen={isPopoverOpen}\n containerPadding={containerPadding}\n shouldFlip={shouldFlip}\n shouldCloseOnInteractOutside={(el) => {\n const menuTriggerEl = el.closest('[data-popover-trigger]');\n if (!menuTriggerEl) return true;\n if (menuTriggerEl === triggerRef?.current?.UNSAFE_getDOMNode())\n return true;\n return false;\n }}\n onOpenChange={handleOpenChange}\n >\n {triggerElement}\n {() => (\n <Dialog\n qa=\"FilterPickerOverlay\"\n display=\"grid\"\n styles={{\n gridRows: '1sf',\n width: 'max($overlay-min-width, 30x) max-content 50vw',\n '$overlay-min-width': '30x',\n ...popoverStyles,\n }}\n style={\n triggerWidthRef.current\n ? ({\n '--overlay-min-width': `${triggerWidthRef.current}px`,\n } as any)\n : undefined\n }\n >\n <FocusScope restoreFocus>\n <FilterListBox\n autoFocus\n items={items ? (finalItems as typeof props.items) : undefined}\n aria-label={`${props['aria-label'] ?? props.label ?? ''} Picker`}\n _internalCollection={localCollectionState.collection}\n selectedKey={\n selectionMode === 'single' ? mappedSelectedKey : undefined\n }\n selectedKeys={\n selectionMode === 'multiple' ? mappedSelectedKeys : undefined\n }\n searchPlaceholder={searchPlaceholder}\n filter={filter}\n searchValue={searchValue}\n listStyles={listStyles}\n optionStyles={optionStyles}\n sectionStyles={sectionStyles}\n headingStyles={headingStyles}\n listRef={listRef}\n disallowEmptySelection={disallowEmptySelection}\n emptyLabel={emptyLabel}\n searchInputStyles={searchInputStyles}\n searchInputRef={searchInputRef}\n disabledKeys={disabledKeys}\n focusOnHover={focusOnHover}\n shouldFocusWrap={shouldFocusWrap}\n allowsCustomValue={allowsCustomValue}\n selectionMode={selectionMode}\n validationState={validationState}\n isDisabled={isDisabled}\n isLoading={isLoading}\n isLoadingItems={isLoadingItems}\n stateRef={listStateRef}\n isCheckable={isCheckable}\n mods={{\n popover: true,\n }}\n size={size === 'small' ? 'medium' : size}\n showSelectAll={showSelectAll}\n selectAllLabel={selectAllLabel}\n header={header}\n footer={footer}\n headerStyles={headerStyles}\n footerStyles={footerStyles}\n allValueProps={allValueProps}\n customValueProps={customValueProps}\n newCustomValueProps={newCustomValueProps}\n isReorderable={isReorderable}\n onSearchChange={onSearchChange}\n onReorder={onReorder}\n onEscape={handleEscape}\n onOptionClick={handleOptionClick}\n onSelectionChange={handleSelectionChange}\n >\n {\n (children\n ? (children as CollectionChildren<T>)\n : undefined) as CollectionChildren<T>\n }\n </FilterListBox>\n </FocusScope>\n </Dialog>\n )}\n </DialogTrigger>\n </FilterPickerWrapper>\n );\n\n return wrapWithField<Omit<CubeFilterPickerProps<T>, 'children' | 'tooltip'>>(\n filterPickerField,\n ref as any,\n props,\n );\n}) as unknown as (<T>(\n props: CubeFilterPickerProps<T> & { ref?: ForwardedRef<HTMLElement> },\n) => ReactElement) & { Item: typeof ListBox.Item; Section: typeof BaseSection };\n\nFilterPicker.Item = ListBox.Item;\n\nFilterPicker.Section = BaseSection;\n\nObject.defineProperty(FilterPicker, 'cubeInputType', {\n value: 'FilterPicker',\n enumerable: false,\n configurable: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiJA,MAAM,cAAc;CAAC,GAAG;CAAa,GAAG;CAAc,GAAG;CAAa;AAEtE,MAAM,sBAAsB,MAAM;CAChC,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,MAAM;EACN,UAAU;EACV,cAAc;EACd,YAAY;EACb;CACF,CAAC;AAEF,MAAa,eAAe,WAAW,SAAS,aAC9C,OACA,KACA;AACA,SAAQ,iBAAiB,MAAM;AAC/B,SAAQ,aAAa,MAAM;AAC3B,SAAQ,cAAc,OAAO,EAC3B,mBAAmB,EAAE,OAAO,eAAe;EACzC,MAAM,aAAsC,EAAE;AAE9C,MAAI,MAAM,kBAAkB,WAC1B,YAAW,eAAe,SAAS,EAAE;MAErC,YAAW,cAAc,SAAS;AAGpC,aAAW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ACE;MACC;MACA;MACN;MACe;MACZ;MACO;MACH;MACF;MACA;MACG;MACE;MACJ;MACE;MACL;MACD;MACK;MAChB,UAAU;MACG;MACb,MAAM,EACJ,SAAS,MACV;MACD,MAAM,SAAS,UAAU,WAAW;MACrB;MACC;MACR;MACA;MACM;MACA;MACC;MACG;MACG;MACN;MACC;MACL;MACX,UAAU;MACV,eAAe;MACf,mBAAmB;gBAGhB,WACI,WACD;OAEQ;MACL;KACN;IAEG;GACI,EAKtB,KACA,MACD;EACD;AAIF,aAAa,OAAO,QAAQ;AAE5B,aAAa,UAAUC;AAEvB,OAAO,eAAe,cAAc,iBAAiB;CACnD,OAAO;CACP,YAAY;CACZ,cAAc;CACf,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.133.0 | Cube Dev Team */
|
|
2
2
|
import { _FileInput } from "../FileInput/FileInput.js";
|
|
3
3
|
import { TextInput } from "../TextInput/TextInput.js";
|
|
4
4
|
import { _NumberInput } from "../NumberInput/NumberInput.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.133.0 | Cube Dev Team */
|
|
2
|
+
import { DraggableCollection } from "../../shared/DraggableCollection.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/fields/ListBox/DraggableListBox.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper that enables drag-and-drop reordering for a vertical ListBox.
|
|
8
|
+
*
|
|
9
|
+
* Thin wrapper around DraggableCollection with vertical orientation.
|
|
10
|
+
*/
|
|
11
|
+
function DraggableListBox({ state, listRef, orderedKeys, onReorder, children }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(DraggableCollection, {
|
|
13
|
+
state,
|
|
14
|
+
listRef,
|
|
15
|
+
orderedKeys,
|
|
16
|
+
orientation: "vertical",
|
|
17
|
+
onReorder,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DraggableListBox };
|
|
24
|
+
//# sourceMappingURL=DraggableListBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraggableListBox.js","names":[],"sources":["../../../../src/components/fields/ListBox/DraggableListBox.tsx"],"sourcesContent":["import { ReactNode, RefObject } from 'react';\nimport {\n DraggableCollectionState,\n DroppableCollectionState,\n ListState,\n} from 'react-stately';\n\nimport { DraggableCollection } from '../../shared/DraggableCollection';\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface DraggableListBoxProps {\n /** List state from React Stately (useListState) */\n state: Pick<\n ListState<any>,\n 'collection' | 'selectionManager' | 'disabledKeys'\n >;\n /** Ref to the list container element */\n listRef: RefObject<HTMLElement | null>;\n /** Current ordered keys */\n orderedKeys: string[];\n /** Callback when items are reordered */\n onReorder?: (newOrder: string[]) => void;\n /** Render function that receives drag/drop states */\n children: (\n dragState: DraggableCollectionState,\n dropState: DroppableCollectionState,\n collectionProps: Record<string, unknown>,\n ) => ReactNode;\n}\n\n// =============================================================================\n// Component\n// =============================================================================\n\n/**\n * Wrapper that enables drag-and-drop reordering for a vertical ListBox.\n *\n * Thin wrapper around DraggableCollection with vertical orientation.\n */\nexport function DraggableListBox({\n state,\n listRef,\n orderedKeys,\n onReorder,\n children,\n}: DraggableListBoxProps) {\n return (\n <DraggableCollection\n state={state}\n listRef={listRef}\n orderedKeys={orderedKeys}\n orientation=\"vertical\"\n onReorder={onReorder}\n >\n {children}\n </DraggableCollection>\n );\n}\n"],"mappings":";;;;;;;;;;AA0CA,SAAgB,iBAAiB,EAC/B,OACA,SACA,aACA,WACA,YACwB;AACxB,QACE,oBAAC;EACQ;EACE;EACI;EACb,aAAY;EACD;EAEV;GACmB"}
|
|
@@ -119,6 +119,17 @@ interface CubeListBoxProps<T> extends AriaListBoxProps<T>, CollectionBase<T>, Fi
|
|
|
119
119
|
* Defaults to 'card'.
|
|
120
120
|
*/
|
|
121
121
|
shape?: 'card' | 'plain' | 'popover';
|
|
122
|
+
/**
|
|
123
|
+
* Enable drag-and-drop reordering of list items.
|
|
124
|
+
* When enabled, virtualization is disabled and each item gets a drag handle.
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
isReorderable?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Callback when items are reordered via drag-and-drop.
|
|
130
|
+
* Called with the new array of item keys in their new order.
|
|
131
|
+
*/
|
|
132
|
+
onReorder?: (newOrder: string[]) => void;
|
|
122
133
|
}
|
|
123
134
|
declare const ListBox: (<T>(props: CubeListBoxProps<T> & {
|
|
124
135
|
ref?: ForwardedRef<HTMLDivElement>;
|