@payfit/unity-components 2.0.0 → 2.1.4
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/esm/components/alert/Alert.js +41 -29
- package/dist/esm/components/alert/parts/AlertTitle.js +8 -8
- package/dist/esm/components/app-layout/AppLayout.d.ts +2 -0
- package/dist/esm/components/app-menu/parts/AppMenuFooter.js +23 -23
- package/dist/esm/components/app-menu/parts/AppMenuHeader.d.ts +1 -1
- package/dist/esm/components/app-menu/parts/AppMenuHeader.js +9 -9
- package/dist/esm/components/autocomplete/Autocomplete.d.ts +0 -9
- package/dist/esm/components/autocomplete/Autocomplete.js +54 -57
- package/dist/esm/components/autocomplete/parts/AutocompleteItem.js +8 -8
- package/dist/esm/components/avatar/Avatar.variants.js +1 -1
- package/dist/esm/components/avatar/parts/AvatarFallback.js +26 -27
- package/dist/esm/components/badge/Badge.js +1 -1
- package/dist/esm/components/breadcrumbs/Breadcrumbs.variant.js +1 -1
- package/dist/esm/components/button/Button.js +6 -6
- package/dist/esm/components/button/Button.variants.d.ts +1 -0
- package/dist/esm/components/button/Button.variants.js +22 -15
- package/dist/esm/components/card/Card.context.d.ts +5 -0
- package/dist/esm/components/card/Card.context.js +14 -0
- package/dist/esm/components/card/Card.d.ts +210 -0
- package/dist/esm/components/card/Card.js +93 -0
- package/dist/esm/components/card/parts/CardContent.d.ts +37 -0
- package/dist/esm/components/card/parts/CardContent.js +8 -0
- package/dist/esm/components/card/parts/CardTitle.d.ts +55 -0
- package/dist/esm/components/card/parts/CardTitle.js +33 -0
- package/dist/esm/components/checkbox/Checkbox.js +38 -30
- package/dist/esm/components/checkbox/Checkbox.variants.d.ts +9 -9
- package/dist/esm/components/checkbox/Checkbox.variants.js +23 -7
- package/dist/esm/components/checkbox/TanstackCheckbox.d.ts +28 -0
- package/dist/esm/components/checkbox/TanstackCheckbox.js +51 -0
- package/dist/esm/components/checkbox/parts/CheckboxIndicator.js +7 -7
- package/dist/esm/components/checkbox-field/CheckboxField.d.ts +2 -0
- package/dist/esm/components/checkbox-field/TanstackCheckboxField.d.ts +14 -0
- package/dist/esm/components/checkbox-field/TanstackCheckboxField.js +40 -0
- package/dist/esm/components/checkbox-group/TanstackCheckboxGroup.d.ts +4 -0
- package/dist/esm/components/checkbox-group/TanstackCheckboxGroup.js +37 -0
- package/dist/esm/components/checkbox-group-field/CheckboxGroupField.d.ts +2 -0
- package/dist/esm/components/checkbox-group-field/TanstackCheckGroupField.d.ts +72 -0
- package/dist/esm/components/checkbox-group-field/TanstackCheckGroupField.js +40 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationNavButton.js +1 -1
- package/dist/esm/components/client-side-pagination/parts/RawPaginationLink.js +10 -10
- package/dist/esm/components/collapsible/parts/CollapsibleContent.js +5 -5
- package/dist/esm/components/collapsible/parts/CollapsibleTitle.js +8 -8
- package/dist/esm/components/data-table/DataTable.d.ts +109 -16
- package/dist/esm/components/data-table/DataTable.js +107 -93
- package/dist/esm/components/data-table/mocks/employee-data.d.ts +1 -0
- package/dist/esm/components/date-calendar/DateCalendar.js +1 -1
- package/dist/esm/components/date-calendar/parts/DateSegmentSelect.js +1 -1
- package/dist/esm/components/date-picker/DatePicker.d.ts +1 -1
- package/dist/esm/components/date-picker/DatePicker.js +59 -50
- package/dist/esm/components/date-picker/TanstackDatePicker.d.ts +22 -0
- package/dist/esm/components/date-picker/TanstackDatePicker.js +53 -0
- package/dist/esm/components/date-picker/parts/DateInput.js +4 -4
- package/dist/esm/components/date-picker-field/DatePickerField.d.ts +2 -0
- package/dist/esm/components/date-picker-field/TanstackDatePickerField.d.ts +71 -0
- package/dist/esm/components/date-picker-field/TanstackDatePickerField.js +41 -0
- package/dist/esm/components/definition-list/DefinitionList.context.d.ts +19 -0
- package/dist/esm/components/definition-list/DefinitionList.d.ts +24 -0
- package/dist/esm/components/definition-list/parts/DefinitionItem.d.ts +25 -0
- package/dist/esm/components/dialog/Dialog.d.ts +34 -22
- package/dist/esm/components/dialog/Dialog.js +90 -52
- package/dist/esm/components/dialog/parts/DialogActions.js +6 -6
- package/dist/esm/components/dialog/parts/DialogTitle.js +7 -4
- package/dist/esm/components/dialog/test-utils.d.ts +28 -0
- package/dist/esm/components/dialog/test-utils.js +78 -0
- package/dist/esm/components/error-state/ErrorState.js +7 -7
- package/dist/esm/components/filter/Filter.controls.d.ts +192 -0
- package/dist/esm/components/filter/Filter.controls.js +45 -0
- package/dist/esm/components/filter/Filter.d.ts +189 -0
- package/dist/esm/components/filter/Filter.js +147 -0
- package/dist/esm/components/filter/Filter.types.d.ts +121 -0
- package/dist/esm/components/filter/hooks/useFilterIds.d.ts +49 -0
- package/dist/esm/components/filter/hooks/useFilterIds.js +13 -0
- package/dist/esm/components/filter/hooks/useFilterState.d.ts +74 -0
- package/dist/esm/components/filter/hooks/useFilterState.js +23 -0
- package/dist/esm/components/filter/hooks/useFilterValue.d.ts +61 -0
- package/dist/esm/components/filter/hooks/useFilterValue.js +31 -0
- package/dist/esm/components/filter/parts/FilterButton.d.ts +75 -0
- package/dist/esm/components/filter/parts/FilterButton.js +55 -0
- package/dist/esm/components/filter/parts/FilterLabel.d.ts +96 -0
- package/dist/esm/components/filter/parts/FilterLabel.js +57 -0
- package/dist/esm/components/filter/parts/FilterPopover.d.ts +95 -0
- package/dist/esm/components/filter/parts/FilterPopover.js +79 -0
- package/dist/esm/components/filter/utils/value-formatters.d.ts +62 -0
- package/dist/esm/components/filter/utils/value-formatters.js +14 -0
- package/dist/esm/components/filter-toolbar/FilterToolbar.d.ts +110 -0
- package/dist/esm/components/filter-toolbar/FilterToolbar.js +172 -0
- package/dist/esm/components/filter-toolbar/FilterToolbar.types.d.ts +119 -0
- package/dist/esm/components/filter-toolbar/hooks/use-filter-toolbar-state.d.ts +96 -0
- package/dist/esm/components/filter-toolbar/hooks/use-filter-toolbar-state.js +132 -0
- package/dist/esm/components/filter-toolbar/parts/AddFilter.d.ts +63 -0
- package/dist/esm/components/filter-toolbar/parts/AddFilter.js +107 -0
- package/dist/esm/components/filter-toolbar/parts/AddFilterItem.d.ts +18 -0
- package/dist/esm/components/filter-toolbar/parts/AddFilterItem.js +18 -0
- package/dist/esm/components/filter-toolbar/utils/filter-adapters.d.ts +93 -0
- package/dist/esm/components/filter-toolbar/utils/filter-adapters.js +88 -0
- package/dist/esm/components/filter-toolbar/utils/normalize-filter-value.d.ts +24 -0
- package/dist/esm/components/filter-toolbar/utils/normalize-filter-value.js +19 -0
- package/dist/esm/components/form/Form.d.ts +2 -0
- package/dist/esm/components/form/TanstackForm.d.ts +24 -0
- package/dist/esm/components/form/TanstackForm.js +29 -0
- package/dist/esm/components/form-field/FormField.d.ts +2 -0
- package/dist/esm/components/form-field/TanstackFormField.context.d.ts +10 -0
- package/dist/esm/components/form-field/TanstackFormField.context.js +14 -0
- package/dist/esm/components/form-field/TanstackFormField.d.ts +49 -0
- package/dist/esm/components/form-field/TanstackFormField.js +46 -0
- package/dist/esm/components/form-field/parts/FormControl.d.ts +2 -0
- package/dist/esm/components/form-field/parts/FormFeedbackText.d.ts +2 -0
- package/dist/esm/components/form-field/parts/FormHelperText.d.ts +2 -0
- package/dist/esm/components/form-field/parts/FormLabel.d.ts +2 -0
- package/dist/esm/components/form-field/parts/RawFormContextualLink.d.ts +2 -0
- package/dist/esm/components/form-field/parts/TanstackFormFeedbackText.d.ts +12 -0
- package/dist/esm/components/form-field/parts/TanstackFormFeedbackText.js +32 -0
- package/dist/esm/components/form-field/parts/TanstackFormHelperText.d.ts +11 -0
- package/dist/esm/components/form-field/parts/TanstackFormHelperText.js +25 -0
- package/dist/esm/components/form-field/parts/TanstackFormLabel.d.ts +8 -0
- package/dist/esm/components/form-field/parts/TanstackFormLabel.js +26 -0
- package/dist/esm/components/form-field/parts/TanstackRawFormContextualLink.d.ts +26 -0
- package/dist/esm/components/form-field/parts/TanstackRawFormContextualLink.js +45 -0
- package/dist/esm/components/icon-button/CircularIconButton.d.ts +9 -9
- package/dist/esm/components/icon-button/CircularIconButton.js +53 -36
- package/dist/esm/components/icon-button/IconButton.variants.d.ts +1 -0
- package/dist/esm/components/icon-button/IconButton.variants.js +44 -28
- package/dist/esm/components/input/Input.js +36 -35
- package/dist/esm/components/input/TanstackInput.d.ts +22 -0
- package/dist/esm/components/input/TanstackInput.js +38 -0
- package/dist/esm/components/label/Label.js +12 -12
- package/dist/esm/components/link/RawLink.js +38 -31
- package/dist/esm/components/list-view/ListView.d.ts +56 -0
- package/dist/esm/components/list-view/ListView.fixtures.d.ts +20 -0
- package/dist/esm/components/list-view/ListView.js +44 -0
- package/dist/esm/components/list-view/parts/ListViewItemLabel.d.ts +34 -0
- package/dist/esm/components/list-view/parts/ListViewItemLabel.js +22 -0
- package/dist/esm/components/list-view/parts/ListViewItemText.d.ts +33 -0
- package/dist/esm/components/list-view/parts/ListViewItemText.js +22 -0
- package/dist/esm/components/list-view/parts/ListViewSection.d.ts +14 -0
- package/dist/esm/components/list-view/parts/ListViewSection.js +21 -0
- package/dist/esm/components/list-view/parts/RawListViewItem.d.ts +102 -0
- package/dist/esm/components/list-view/parts/RawListViewItem.js +80 -0
- package/dist/esm/components/multi-select/MultiSelect.d.ts +5 -7
- package/dist/esm/components/multi-select/MultiSelect.js +199 -176
- package/dist/esm/components/multi-select/MultiselectTypes.d.ts +114 -0
- package/dist/esm/components/multi-select/TanstackMultiSelect.d.ts +7 -0
- package/dist/esm/components/multi-select/TanstackMultiSelect.js +41 -0
- package/dist/esm/components/multi-select/parts/MultiSelectButton.d.ts +2 -0
- package/dist/esm/components/multi-select/parts/MultiSelectButton.js +62 -46
- package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +15 -15
- package/dist/esm/components/multi-select-field/MultiSelectField.d.ts +45 -12
- package/dist/esm/components/multi-select-field/MultiSelectField.js +56 -66
- package/dist/esm/components/multi-select-field/TanstackMultiSelectField.d.ts +92 -0
- package/dist/esm/components/multi-select-field/TanstackMultiSelectField.js +48 -0
- package/dist/esm/components/multi-select-field/test-utils.d.ts +17 -0
- package/dist/esm/components/multi-select-field/test-utils.js +45 -0
- package/dist/esm/components/nav/parts/RawNavItem.js +6 -6
- package/dist/esm/components/navigation-card/NavigationCard.context.d.ts +31 -0
- package/dist/esm/components/navigation-card/NavigationCard.context.js +13 -0
- package/dist/esm/components/navigation-card/NavigationCard.d.ts +46 -0
- package/dist/esm/components/navigation-card/NavigationCard.js +62 -0
- package/dist/esm/components/navigation-card/NavigationCard.types.d.ts +37 -0
- package/dist/esm/components/navigation-card/NavigationCard.variants.d.ts +1147 -0
- package/dist/esm/components/navigation-card/NavigationCard.variants.js +164 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardDescription.d.ts +39 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardDescription.js +22 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardGroup.d.ts +146 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardGroup.js +93 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardLabel.d.ts +32 -0
- package/dist/esm/components/navigation-card/parts/NavigationCardLabel.js +24 -0
- package/dist/esm/components/number-field/NumberField.d.ts +2 -0
- package/dist/esm/components/number-field/TanstackNumberField.d.ts +74 -0
- package/dist/esm/components/number-field/TanstackNumberField.js +44 -0
- package/dist/esm/components/number-input/NumberInput.js +31 -29
- package/dist/esm/components/number-input/TanstackNumberInput.d.ts +58 -0
- package/dist/esm/components/number-input/TanstackNumberInput.js +38 -0
- package/dist/esm/components/page/Page.js +12 -11
- package/dist/esm/components/pagination/parts/RawPaginationLink.js +22 -22
- package/dist/esm/components/pagination/parts/RawPaginationNext.js +13 -13
- package/dist/esm/components/pagination/parts/RawPaginationPrevious.js +10 -10
- package/dist/esm/components/payfit-brand/PayFitBrand.d.ts +4 -0
- package/dist/esm/components/payfit-brand/PayFitBrand.js +30 -22
- package/dist/esm/components/payfit-brand/PayFitPreprod.js +25 -25
- package/dist/esm/components/phone-number/PhoneNumberInput.d.ts +67 -0
- package/dist/esm/components/phone-number/PhoneNumberInput.js +322 -0
- package/dist/esm/components/phone-number/TanstackPhoneNumberInput.d.ts +64 -0
- package/dist/esm/components/phone-number/TanstackPhoneNumberInput.js +33 -0
- package/dist/esm/components/phone-number/parts/PhoneNumberItem.d.ts +42 -0
- package/dist/esm/components/phone-number/parts/PhoneNumberItem.js +68 -0
- package/dist/esm/components/phone-number/unknownFlag.svg.js +4 -0
- package/dist/esm/components/phone-number-field/TanstackPhoneNumberField.d.ts +15 -0
- package/dist/esm/components/phone-number-field/TanstackPhoneNumberField.js +32 -0
- package/dist/esm/components/pill/Pill.d.ts +2 -2
- package/dist/esm/components/pill/Pill.js +8 -8
- package/dist/esm/components/popover/Popover.js +6 -6
- package/dist/esm/components/promo-dialog/PromoDialog.d.ts +149 -0
- package/dist/esm/components/promo-dialog/PromoDialog.js +219 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogActions.d.ts +44 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogActions.js +29 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogContent.d.ts +43 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogContent.js +20 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogHero.d.ts +47 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogHero.js +25 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogSubtitle.d.ts +53 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogSubtitle.js +21 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogTitle.d.ts +6 -0
- package/dist/esm/components/promo-dialog/parts/PromoDialogTitle.js +18 -0
- package/dist/esm/components/radio-button-group/TanstackRadioButtonGroup.d.ts +13 -0
- package/dist/esm/components/radio-button-group/TanstackRadioButtonGroup.js +43 -0
- package/dist/esm/components/radio-button-group/parts/RadioButton.d.ts +29 -11
- package/dist/esm/components/radio-button-group/parts/RadioButton.js +53 -51
- package/dist/esm/components/radio-button-group-field/RadioButtonGroupField.d.ts +2 -0
- package/dist/esm/components/radio-button-group-field/TanstackRadioButtonGroupField.d.ts +13 -0
- package/dist/esm/components/radio-button-group-field/TanstackRadioButtonGroupField.js +38 -0
- package/dist/esm/components/search/Search.js +46 -46
- package/dist/esm/components/segmented-button-group/parts/ToggleButton.js +5 -5
- package/dist/esm/components/select/Select.d.ts +5 -4
- package/dist/esm/components/select/Select.js +53 -45
- package/dist/esm/components/select/TanstackSelect.d.ts +80 -0
- package/dist/esm/components/select/TanstackSelect.js +34 -0
- package/dist/esm/components/select/parts/SearchInput.d.ts +4 -1
- package/dist/esm/components/select/parts/SearchInput.js +49 -31
- package/dist/esm/components/select/parts/SelectButton.js +19 -17
- package/dist/esm/components/select-field/SelectField.d.ts +2 -0
- package/dist/esm/components/select-field/SelectField.js +8 -9
- package/dist/esm/components/select-field/TanstackSelectField.d.ts +124 -0
- package/dist/esm/components/select-field/TanstackSelectField.js +44 -0
- package/dist/esm/components/select-list/SelectList.d.ts +95 -0
- package/dist/esm/components/select-list/SelectList.js +79 -0
- package/dist/esm/components/select-list/SelectList.types.d.ts +29 -0
- package/dist/esm/components/select-list/constants.d.ts +36 -0
- package/dist/esm/components/select-list/constants.js +29 -0
- package/dist/esm/components/select-list/helpers.d.ts +42 -0
- package/dist/esm/components/select-list/helpers.js +48 -0
- package/dist/esm/components/select-list/hooks/useControlledSelection.d.ts +23 -0
- package/dist/esm/components/select-list/hooks/useControlledSelection.js +16 -0
- package/dist/esm/components/select-list/hooks/useSelectedFirstSorting.d.ts +23 -0
- package/dist/esm/components/select-list/hooks/useSelectedFirstSorting.js +31 -0
- package/dist/esm/components/select-list/parts/SelectListEmptyState.d.ts +8 -0
- package/dist/esm/components/select-list/parts/SelectListEmptyState.js +25 -0
- package/dist/esm/components/select-list/parts/SelectListOptGroup.d.ts +118 -0
- package/dist/esm/components/select-list/parts/SelectListOptGroup.js +28 -0
- package/dist/esm/components/select-list/parts/SelectListOption.d.ts +24 -0
- package/dist/esm/components/select-list/parts/SelectListOption.js +72 -0
- package/dist/esm/components/select-list/parts/SelectListSearchInput.d.ts +2 -0
- package/dist/esm/components/select-list/parts/SelectListSearchInput.js +43 -0
- package/dist/esm/components/select-list/parts/SelectedItemsSection.d.ts +54 -0
- package/dist/esm/components/select-list/parts/SelectedItemsSection.js +35 -0
- package/dist/esm/components/select-list/utils/partition.d.ts +13 -0
- package/dist/esm/components/select-list/utils/partition.js +9 -0
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.context.d.ts +1 -5
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.d.ts +6 -1
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +23 -23
- package/dist/esm/components/selectable-button-group/TanstackSelectableButtonGroup.d.ts +27 -0
- package/dist/esm/components/selectable-button-group/TanstackSelectableButtonGroup.js +34 -0
- package/dist/esm/components/selectable-button-group/parts/SelectableButton.d.ts +1 -16
- package/dist/esm/components/selectable-button-group/parts/SelectableButton.js +56 -57
- package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +2 -0
- package/dist/esm/components/selectable-button-group-field/TanstackSelectableButtonGroupField.d.ts +81 -0
- package/dist/esm/components/selectable-button-group-field/TanstackSelectableButtonGroupField.js +47 -0
- package/dist/esm/components/selectable-card/internals/Description.js +1 -1
- package/dist/esm/components/selectable-card/selectable-card-checkbox-group/SelectableCardCheckboxGroup.js +1 -1
- package/dist/esm/components/selectable-card/selectable-card-checkbox-group/TanstackSelectableCardCheckboxGroup.d.ts +26 -0
- package/dist/esm/components/selectable-card/selectable-card-checkbox-group/TanstackSelectableCardCheckboxGroup.js +32 -0
- package/dist/esm/components/selectable-card/selectable-card-checkbox-group/parts/SelectableCardCheckbox.js +24 -24
- package/dist/esm/components/selectable-card/selectable-card-radio-group/SelectableCardRadioGroup.d.ts +2 -0
- package/dist/esm/components/selectable-card/selectable-card-radio-group/SelectableCardRadioGroup.js +12 -14
- package/dist/esm/components/selectable-card/selectable-card-radio-group/TanstackSelectableCardRadioGroup.d.ts +28 -0
- package/dist/esm/components/selectable-card/selectable-card-radio-group/TanstackSelectableCardRadioGroup.js +32 -0
- package/dist/esm/components/selectable-card/selectable-card-radio-group/parts/RadioIndicator.js +14 -13
- package/dist/esm/components/selectable-card/selectable-card-radio-group/parts/SelectableCardRadio.js +27 -25
- package/dist/esm/components/selectable-card/selectableCard.variant.js +5 -5
- package/dist/esm/components/selectable-card-checkbox-group-field/SelectableCardCheckboxGroupField.d.ts +2 -0
- package/dist/esm/components/selectable-card-checkbox-group-field/TanstackSelectableCardCheckboxGroupField.d.ts +10 -0
- package/dist/esm/components/selectable-card-checkbox-group-field/TanstackSelectableCardCheckboxGroupField.js +38 -0
- package/dist/esm/components/selectable-card-radio-group-field/SelectableCardRadioGroupField.d.ts +2 -0
- package/dist/esm/components/selectable-card-radio-group-field/TanstackSelectableCardRadioGroupField.d.ts +10 -0
- package/dist/esm/components/selectable-card-radio-group-field/TanstackSelectableCardRadioGroupField.js +38 -0
- package/dist/esm/components/table/Table.context.d.ts +5 -0
- package/dist/esm/components/table/Table.context.js +14 -13
- package/dist/esm/components/table/Table.d.ts +93 -0
- package/dist/esm/components/table/Table.js +135 -107
- package/dist/esm/components/table/parts/TableBody.js +83 -21
- package/dist/esm/components/table/parts/TableEmptyState.js +6 -6
- package/dist/esm/components/table/parts/TableHeader.js +1 -1
- package/dist/esm/components/table/parts/TablePagination.js +1 -1
- package/dist/esm/components/table/parts/TableRow.js +1 -0
- package/dist/esm/components/tabs/Tabs.variant.d.ts +0 -6
- package/dist/esm/components/tabs/Tabs.variant.js +11 -12
- package/dist/esm/components/task-menu/parts/RawSubTask.js +26 -26
- package/dist/esm/components/task-menu/parts/RawTask.js +32 -28
- package/dist/esm/components/task-menu/parts/TaskGroup.js +30 -26
- package/dist/esm/components/task-menu/parts/task.variants.js +4 -2
- package/dist/esm/components/text/Text.d.ts +11 -1
- package/dist/esm/components/text/Text.js +41 -31
- package/dist/esm/components/text/Text.variants.d.ts +12 -0
- package/dist/esm/components/text/Text.variants.js +4 -0
- package/dist/esm/components/text-area/TanstackTextArea.d.ts +21 -0
- package/dist/esm/components/text-area/TanstackTextArea.js +35 -0
- package/dist/esm/components/text-area/TextArea.js +31 -29
- package/dist/esm/components/text-field/TanstackTextField.d.ts +79 -0
- package/dist/esm/components/text-field/TanstackTextField.js +60 -0
- package/dist/esm/components/text-field/TextField.d.ts +2 -0
- package/dist/esm/components/toast/UnityToast.js +5 -5
- package/dist/esm/components/toast/test-utils.d.ts +36 -0
- package/dist/esm/components/toast/test-utils.js +118 -0
- package/dist/esm/components/toggle-switch/TanstackToggleSwitch.d.ts +46 -0
- package/dist/esm/components/toggle-switch/TanstackToggleSwitch.js +25 -0
- package/dist/esm/components/toggle-switch/ToggleSwitch.d.ts +21 -9
- package/dist/esm/components/toggle-switch/ToggleSwitch.js +71 -32
- package/dist/esm/components/toggle-switch-field/TanstackToggleSwitchField.d.ts +11 -0
- package/dist/esm/components/toggle-switch-field/TanstackToggleSwitchField.js +34 -0
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +2 -0
- package/dist/esm/components/toggle-switch-group/TanstackToggleSwitchGroup.d.ts +57 -0
- package/dist/esm/components/toggle-switch-group/TanstackToggleSwitchGroup.js +23 -0
- package/dist/esm/components/toggle-switch-group/ToggleSwitchGroup.js +1 -1
- package/dist/esm/components/toggle-switch-group-field/TanstackToggleSwitchGroupField.d.ts +19 -0
- package/dist/esm/components/toggle-switch-group-field/TanstackToggleSwitchGroupField.js +50 -0
- package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.d.ts +2 -0
- package/dist/esm/docs/{table → examples/data}/mocks/employee-columns.d.ts +1 -1
- package/dist/esm/hooks/tanstack-form-context.d.ts +1 -0
- package/dist/esm/hooks/tanstack-form-context.js +8 -0
- package/dist/esm/hooks/use-form.d.ts +2 -0
- package/dist/esm/hooks/use-has-scroll.d.ts +71 -0
- package/dist/esm/hooks/use-has-scroll.js +75 -0
- package/dist/esm/hooks/use-tanstack-form.d.ts +369 -0
- package/dist/esm/hooks/use-tanstack-form.js +209 -0
- package/dist/esm/index.d.ts +44 -20
- package/dist/esm/index.js +457 -394
- package/dist/esm/index.storybook-testing.d.ts +3 -0
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.d.ts +6 -1
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/TanstackFormContextualLink.d.ts +43 -0
- package/dist/esm/integrations/tanstack-router/components/list-view/ListView.d.ts +34 -0
- package/dist/esm/integrations/tanstack-router/components/list-view/ListView.js +25 -0
- package/dist/esm/integrations/tanstack-router/components/list-view/parts/ListViewItem.d.ts +51 -0
- package/dist/esm/integrations/tanstack-router/components/list-view/parts/ListViewItem.js +32 -0
- package/dist/esm/integrations/tanstack-router/components/navigation-card/NavigationCard.d.ts +73 -0
- package/dist/esm/integrations/tanstack-router/components/navigation-card/NavigationCard.js +37 -0
- package/dist/esm/integrations/tanstack-router/index.d.ts +3 -0
- package/dist/esm/integrations/tanstack-router/utils/decorators.d.ts +1 -1
- package/dist/esm/integrations/tanstack-router.js +32 -26
- package/dist/esm/mocks/employees.d.ts +1 -5
- package/dist/esm/storybook-testing.js +8 -2
- package/dist/esm/storybook-utilities/previewTransform.d.ts +1 -0
- package/dist/esm/utils/scroll-detection.d.ts +77 -0
- package/dist/esm/utils/scroll-detection.js +33 -0
- package/dist/esm/utils/spacing.d.ts +63 -0
- package/dist/esm/utils/spacing.js +15 -0
- package/i18n/en-GB.json +21 -8
- package/i18n/es-ES.json +23 -10
- package/i18n/fr-FR.json +24 -11
- package/package.json +41 -42
- package/dist/esm/components/multi-select/Multiselect.types.d.ts +0 -109
- package/dist/esm/integrations/react-router/v5/UnityReactRouterV5Provider.d.ts +0 -6
- package/dist/esm/integrations/react-router/v5/UnityReactRouterV5Provider.js +0 -28
- package/dist/esm/integrations/react-router/v5/index.d.ts +0 -1
- package/dist/esm/integrations/react-router/v5.js +0 -4
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { JSX, Ref } from 'react';
|
|
2
|
+
import { FilterProps } from './Filter.types.js';
|
|
3
|
+
import { selectListFilter, selectListLabel } from './Filter.controls.js';
|
|
4
|
+
/**
|
|
5
|
+
* Tailwind variants for the Filter container.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const filterContainer: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
9
|
+
export declare const filterDismissButton: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
10
|
+
type FilterComponent = {
|
|
11
|
+
<TType>(props: FilterProps<TType> & {
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The `Filter` component allows users to refine data by selecting specific criteria from a customizable control.
|
|
18
|
+
* It provides a consistent, accessible interface for filtering operations across the application, reducing the need
|
|
19
|
+
* to build custom filter UIs for each data set. The component automatically handles common filtering patterns like
|
|
20
|
+
* multi-select, value display, and popover management, letting you focus on the filtering logic itself.
|
|
21
|
+
* The Filter component offers flexible value selection through the `renderControl` prop, which can render any
|
|
22
|
+
* interactive control (SelectList, DateCalendar, CheckboxGroup, etc.). It displays selected values with smart
|
|
23
|
+
* formatting: showing the values inline when few are selected, or displaying a numeric badge when many values
|
|
24
|
+
* are selected. The component includes built-in internationalization support and follows accessibility best practices
|
|
25
|
+
* with proper ARIA attributes and keyboard navigation.
|
|
26
|
+
* @template TType - The type of the filter value. Use `Set<string>` for multi-select filters or primitive types
|
|
27
|
+
* for single-value filters. This ensures type safety across value, onChange, and renderControl.
|
|
28
|
+
* @param {FilterProps<TType>} props - The component props
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { Filter, selectListFilter } from '@payfit/unity-components'
|
|
32
|
+
* import { useState } from 'react'
|
|
33
|
+
*
|
|
34
|
+
* // Define your filter items
|
|
35
|
+
* const statusItems = [
|
|
36
|
+
* { id: 'active', label: 'Active' },
|
|
37
|
+
* { id: 'inactive', label: 'Inactive' },
|
|
38
|
+
* { id: 'pending', label: 'Pending' },
|
|
39
|
+
* ]
|
|
40
|
+
*
|
|
41
|
+
* function EmployeeFilters() {
|
|
42
|
+
* const [status, setStatus] = useState<Set<string>>(new Set())
|
|
43
|
+
*
|
|
44
|
+
* return (
|
|
45
|
+
* <Filter
|
|
46
|
+
* label="Status"
|
|
47
|
+
* value={status}
|
|
48
|
+
* onChange={setStatus}
|
|
49
|
+
* renderControl={selectListFilter(statusItems, {})}
|
|
50
|
+
* />
|
|
51
|
+
* )
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* // Multi-select filter with grouped items and custom formatting
|
|
57
|
+
* import { Filter, selectListFilter } from '@payfit/unity-components'
|
|
58
|
+
* import { useState } from 'react'
|
|
59
|
+
*
|
|
60
|
+
* const departmentGroups = [
|
|
61
|
+
* {
|
|
62
|
+
* id: 'business',
|
|
63
|
+
* label: 'Business',
|
|
64
|
+
* children: [
|
|
65
|
+
* { id: 'sales', label: 'Sales' },
|
|
66
|
+
* { id: 'marketing', label: 'Marketing' },
|
|
67
|
+
* ],
|
|
68
|
+
* },
|
|
69
|
+
* {
|
|
70
|
+
* id: 'tech',
|
|
71
|
+
* label: 'Tech',
|
|
72
|
+
* children: [
|
|
73
|
+
* { id: 'engineering', label: 'Engineering' },
|
|
74
|
+
* { id: 'product', label: 'Product' },
|
|
75
|
+
* ],
|
|
76
|
+
* },
|
|
77
|
+
* ]
|
|
78
|
+
*
|
|
79
|
+
* function DepartmentFilter() {
|
|
80
|
+
* const [selected, setSelected] = useState<Set<string>>(new Set(['sales']))
|
|
81
|
+
*
|
|
82
|
+
* return (
|
|
83
|
+
* <Filter
|
|
84
|
+
* label="Departments"
|
|
85
|
+
* prefixIcon="BusinessCenterOutlined"
|
|
86
|
+
* value={selected}
|
|
87
|
+
* onChange={setSelected}
|
|
88
|
+
* maxVisibleValues={2}
|
|
89
|
+
* renderControl={selectListFilter(departmentGroups, {})}
|
|
90
|
+
* renderLabel={(values) =>
|
|
91
|
+
* Array.from(values)
|
|
92
|
+
* .map((v) => v.charAt(0).toUpperCase() + v.slice(1))
|
|
93
|
+
* .join(' • ')
|
|
94
|
+
* }
|
|
95
|
+
* />
|
|
96
|
+
* )
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
* @remarks
|
|
100
|
+
* - Use the `renderControl` prop to provide the interactive element for value selection. The helper function
|
|
101
|
+
* `selectListFilter` simplifies this for common SelectList-based filters, but you can render any control
|
|
102
|
+
* like DateCalendar, CheckboxGroup, or custom components
|
|
103
|
+
* - Customize the display of selected values by providing a `renderLabel` function. This function receives
|
|
104
|
+
* the current `value` and should return a string representation for display in the filter button
|
|
105
|
+
* - Control badge visibility with the `maxVisibleValues` prop (default: 3). When the number of selected values
|
|
106
|
+
* exceeds this threshold, the filter automatically shows a numeric badge instead of listing all values
|
|
107
|
+
* - Set `isDismissable={true}` and provide an `onDismiss` callback to allow users to remove the filter entirely.
|
|
108
|
+
* This is useful for optional filters that can be added/removed dynamically
|
|
109
|
+
* - The component is fully internationalized with support for English, French, and Spanish. The "Clear" and
|
|
110
|
+
* "Apply" button labels adapt automatically based on the user's locale
|
|
111
|
+
* @see {@link FilterProps} for all available props
|
|
112
|
+
* @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/components/filter GitHub}
|
|
113
|
+
* @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=8976-13410&t=Hd2aEwwHm7cNU2L5-4 Figma}
|
|
114
|
+
* @see Design docs in {@link https://www.payfit.design/ Payfit.design}
|
|
115
|
+
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/docs/components-filter--docs unity-components.payfit.io}
|
|
116
|
+
*/
|
|
117
|
+
declare const Filter: FilterComponent;
|
|
118
|
+
/**
|
|
119
|
+
* This module contains preconfigured render functions
|
|
120
|
+
* that are ready to be used for the `Filter` component's `renderControl` prop.
|
|
121
|
+
* @remarks
|
|
122
|
+
* - Contains utilities for rendering controls: SelectList
|
|
123
|
+
* - These render functions are higher-order function. When called, they return a function matching the `Filter` component's `renderLabel` signature
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* import { Filter, FilterControls } from '@payfit/unity-components'
|
|
127
|
+
* import { useState } from 'react'
|
|
128
|
+
*
|
|
129
|
+
* // Define your filter items
|
|
130
|
+
* const statusItems = [
|
|
131
|
+
* { id: 'active', label: 'Active' },
|
|
132
|
+
* { id: 'inactive', label: 'Inactive' },
|
|
133
|
+
* { id: 'pending', label: 'Pending' },
|
|
134
|
+
* ]
|
|
135
|
+
*
|
|
136
|
+
* function EmployeeFilters() {
|
|
137
|
+
* const [status, setStatus] = useState<Set<string>>(new Set())
|
|
138
|
+
*
|
|
139
|
+
* return (
|
|
140
|
+
* <Filter
|
|
141
|
+
* label="Status"
|
|
142
|
+
* value={status}
|
|
143
|
+
* onChange={setStatus}
|
|
144
|
+
* renderControl={FilterControls.selectList(statusItems, {})}
|
|
145
|
+
* />
|
|
146
|
+
* )
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const FilterControls: {
|
|
151
|
+
selectList: typeof selectListFilter;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* This module contains preconfigured render functions that are ready to be used for `Filter` component's `renderLabel` prop.
|
|
155
|
+
* @remarks
|
|
156
|
+
* - Contains utilities for rendering labels managed by: SelectList
|
|
157
|
+
* - These render functions are higher-order function. When called, they return a function matching the `Filter` component's `renderLabel` signature
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* import { Filter, FilterControls, FilterLabels } from '@payfit/unity-components'
|
|
161
|
+
* import { useState } from 'react'
|
|
162
|
+
*
|
|
163
|
+
* // Define your filter items
|
|
164
|
+
* const statusItems = [
|
|
165
|
+
* { id: 'active', label: 'Active' },
|
|
166
|
+
* { id: 'inactive', label: 'Inactive' },
|
|
167
|
+
* { id: 'pending', label: 'Pending' },
|
|
168
|
+
* ]
|
|
169
|
+
*
|
|
170
|
+
* function EmployeeFilters() {
|
|
171
|
+
* const [status, setStatus] = useState<Set<string>>(new Set())
|
|
172
|
+
*
|
|
173
|
+
* return (
|
|
174
|
+
* <Filter
|
|
175
|
+
* label="Status"
|
|
176
|
+
* value={status}
|
|
177
|
+
* onChange={setStatus}
|
|
178
|
+
* renderControl={FilterControls.selectList(statusItems, {})}
|
|
179
|
+
* renderLabel={FilterLabels.selectList(statusItems)}
|
|
180
|
+
* />
|
|
181
|
+
* )
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export declare const FilterLabels: {
|
|
186
|
+
selectList: typeof selectListLabel;
|
|
187
|
+
};
|
|
188
|
+
export { Filter };
|
|
189
|
+
export type { FilterProps } from './Filter.types.js';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as A, useCallback as D } from "react";
|
|
3
|
+
import { uyTv as c } from "@payfit/unity-themes";
|
|
4
|
+
import { DialogTrigger as E } from "react-aria-components";
|
|
5
|
+
import { useIntl as G } from "react-intl";
|
|
6
|
+
import { CircularIconButton as H } from "../icon-button/CircularIconButton.js";
|
|
7
|
+
import { selectListFilter as J, selectListLabel as K } from "./Filter.controls.js";
|
|
8
|
+
import { useFilterIds as Q } from "./hooks/useFilterIds.js";
|
|
9
|
+
import { useFilterState as U } from "./hooks/useFilterState.js";
|
|
10
|
+
import { useFilterValue as V } from "./hooks/useFilterValue.js";
|
|
11
|
+
import { FilterButton as W } from "./parts/FilterButton.js";
|
|
12
|
+
import { FilterLabel as X } from "./parts/FilterLabel.js";
|
|
13
|
+
import { FilterPopover as Y } from "./parts/FilterPopover.js";
|
|
14
|
+
import { defaultRenderLabel as Z } from "./utils/value-formatters.js";
|
|
15
|
+
const _ = c({
|
|
16
|
+
base: [
|
|
17
|
+
"uy:group uy:transition-colors",
|
|
18
|
+
"uy:flex uy:items-center",
|
|
19
|
+
"uy:rounded-md uy:sm:rounded-sm",
|
|
20
|
+
"uy:border uy:border-solid",
|
|
21
|
+
"uy:cursor-pointer uy:aria-[disabled=true]:cursor-not-allowed",
|
|
22
|
+
"uy:w-fit",
|
|
23
|
+
"uy:border-border-form-enabled uy:bg-surface-form-enabled uy:text-content-form-enabled",
|
|
24
|
+
"uy:has-data-[hovered]:border-border-form-hover uy:has-data-[hovered]:bg-surface-form-hover",
|
|
25
|
+
"uy:has-data-[pressed]:border-border-form-pressed uy:has-data-[pressed]:bg-surface-form-pressed",
|
|
26
|
+
"uy:aria-[disabled=true]:border-border-form-disabled uy:aria-[disabled=true]:bg-surface-form-disabled uy:aria-[disabled=true]:text-content-form-disabled",
|
|
27
|
+
"uy:data-[status=active]:text-content-primary-enabled",
|
|
28
|
+
"uy:focus-within:outline-2 uy:focus-within:outline-offset-2 uy:focus-within:outline-utility-focus-ring",
|
|
29
|
+
'uy:[&:not(:has([data-unity-slot="dismiss"]))]:pr-1.5'
|
|
30
|
+
]
|
|
31
|
+
}), $ = c({
|
|
32
|
+
base: [
|
|
33
|
+
"uy:rounded-r-sm uy:leading-0",
|
|
34
|
+
"uy:pl-0.25 uy:py-1 uy:pr-1 uy:h-full"
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
function ee({
|
|
38
|
+
id: y,
|
|
39
|
+
label: p,
|
|
40
|
+
prefixIcon: b,
|
|
41
|
+
onDismiss: h,
|
|
42
|
+
renderControl: g,
|
|
43
|
+
value: t,
|
|
44
|
+
onChange: v,
|
|
45
|
+
isDismissable: F = !0,
|
|
46
|
+
isDisabled: r = !1,
|
|
47
|
+
isActive: I = !1,
|
|
48
|
+
renderLabel: w = Z,
|
|
49
|
+
maxVisibleValues: i = 3,
|
|
50
|
+
shouldCloseOnConfirm: C = !0,
|
|
51
|
+
onClearSelection: L,
|
|
52
|
+
shouldCloseOnClear: x = !0,
|
|
53
|
+
onConfirmSelection: B,
|
|
54
|
+
onFilterOpen: s,
|
|
55
|
+
onFilterClose: a,
|
|
56
|
+
isDefaultOpen: O = !1,
|
|
57
|
+
...N
|
|
58
|
+
}, R) {
|
|
59
|
+
const j = G(), { rootId: l, labelId: o, valueId: d, dismissButtonId: M } = Q(y), { isOpen: u, setIsOpen: n, confirm: P, clear: S } = U({
|
|
60
|
+
initialIsOpen: O,
|
|
61
|
+
shouldCloseOnConfirm: C,
|
|
62
|
+
shouldCloseOnClear: x,
|
|
63
|
+
onConfirmSelection: B,
|
|
64
|
+
onClearSelection: L
|
|
65
|
+
}), T = D(
|
|
66
|
+
(m) => {
|
|
67
|
+
n(m), m ? s?.() : a?.();
|
|
68
|
+
},
|
|
69
|
+
[n, s, a]
|
|
70
|
+
), { valuesCount: k, shouldShowBadge: q, formattedValue: z } = V(
|
|
71
|
+
t,
|
|
72
|
+
i,
|
|
73
|
+
w
|
|
74
|
+
);
|
|
75
|
+
return /* @__PURE__ */ f(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
ref: R,
|
|
79
|
+
role: "group",
|
|
80
|
+
id: l,
|
|
81
|
+
className: _(),
|
|
82
|
+
"aria-labelledby": o,
|
|
83
|
+
"aria-describedby": d,
|
|
84
|
+
"aria-disabled": r,
|
|
85
|
+
"data-dd-privacy": "allow",
|
|
86
|
+
"data-status": I || u ? "active" : "idle",
|
|
87
|
+
"data-unity-component": "Filter",
|
|
88
|
+
...N,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ f(E, { isOpen: u, onOpenChange: T, children: [
|
|
91
|
+
/* @__PURE__ */ e(
|
|
92
|
+
W,
|
|
93
|
+
{
|
|
94
|
+
labelId: o,
|
|
95
|
+
prefixIcon: b,
|
|
96
|
+
isDisabled: r,
|
|
97
|
+
children: /* @__PURE__ */ e(
|
|
98
|
+
X,
|
|
99
|
+
{
|
|
100
|
+
labelId: o,
|
|
101
|
+
valueId: d,
|
|
102
|
+
label: p,
|
|
103
|
+
value: t,
|
|
104
|
+
valuesCount: k,
|
|
105
|
+
shouldShowBadge: q,
|
|
106
|
+
formattedValue: z,
|
|
107
|
+
maxVisibleValues: i,
|
|
108
|
+
isDisabled: r
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ e(Y, { onConfirm: P, onClear: S, children: g(t, v) })
|
|
114
|
+
] }),
|
|
115
|
+
F && /* @__PURE__ */ e("div", { "data-unity-slot": "dismiss", className: $(), children: /* @__PURE__ */ e(
|
|
116
|
+
H,
|
|
117
|
+
{
|
|
118
|
+
icon: "CloseOutlined",
|
|
119
|
+
color: "content.neutral.lowest",
|
|
120
|
+
title: j.formatMessage({
|
|
121
|
+
id: "unity:component:filter:dismiss:title",
|
|
122
|
+
defaultMessage: "Remove filter"
|
|
123
|
+
}),
|
|
124
|
+
onPress: h,
|
|
125
|
+
id: M,
|
|
126
|
+
"aria-controls": l,
|
|
127
|
+
isDisabled: r
|
|
128
|
+
}
|
|
129
|
+
) })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
const re = A(ee);
|
|
135
|
+
re.displayName = "Filter";
|
|
136
|
+
const be = {
|
|
137
|
+
selectList: J
|
|
138
|
+
}, he = {
|
|
139
|
+
selectList: K
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
re as Filter,
|
|
143
|
+
be as FilterControls,
|
|
144
|
+
he as FilterLabels,
|
|
145
|
+
_ as filterContainer,
|
|
146
|
+
$ as filterDismissButton
|
|
147
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { UnityIcon } from '@payfit/unity-icons';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
type Prettify<T> = {
|
|
4
|
+
[K in keyof T]: T[K];
|
|
5
|
+
} & {};
|
|
6
|
+
export interface FilterEventProps {
|
|
7
|
+
/**
|
|
8
|
+
* Callback function invoked when the filter popover opens.
|
|
9
|
+
* @default undefined
|
|
10
|
+
*/
|
|
11
|
+
onFilterOpen?: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Callback function invoked when the filter popover closes.
|
|
14
|
+
* @default undefined
|
|
15
|
+
*/
|
|
16
|
+
onFilterClose?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Callback function called when the user presses "confirm" or "apply" button.
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
onConfirmSelection?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback function called when the user presses "clear" button.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
onClearSelection?: () => void;
|
|
27
|
+
}
|
|
28
|
+
export interface FilterDisplayProps {
|
|
29
|
+
/**
|
|
30
|
+
* The label for the filter.
|
|
31
|
+
*/
|
|
32
|
+
label: string;
|
|
33
|
+
/**
|
|
34
|
+
* The prefix icon show at the start of the filter.
|
|
35
|
+
* @default undefined
|
|
36
|
+
*/
|
|
37
|
+
prefixIcon?: UnityIcon;
|
|
38
|
+
/**
|
|
39
|
+
* The maximum number of visible selected values in the filter label.
|
|
40
|
+
* If there are more selected values than this number, the label will be hidden and a counter badge will be shown instead.
|
|
41
|
+
* @default 3
|
|
42
|
+
*/
|
|
43
|
+
maxVisibleValues?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the filter is disabled.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
isDisabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the filter is active.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
isActive?: boolean;
|
|
54
|
+
}
|
|
55
|
+
type FilterDismissProps = {
|
|
56
|
+
/**
|
|
57
|
+
* Whether the filter is dismissable by the user. Shows a dismiss button at the end of the filter.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
isDismissable: true;
|
|
61
|
+
/**
|
|
62
|
+
* Callback function called when the user dismisses the filter.
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
onDismiss: () => void;
|
|
66
|
+
} | {
|
|
67
|
+
isDismissable: false;
|
|
68
|
+
onDismiss?: never;
|
|
69
|
+
} | {
|
|
70
|
+
isDismissable?: undefined;
|
|
71
|
+
onDismiss?: never;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Filter component props supporting both controlled and uncontrolled modes
|
|
75
|
+
* @template TType - The type of the filter value
|
|
76
|
+
*/
|
|
77
|
+
export type FilterProps<TType> = Prettify<FilterEventProps & FilterDisplayProps & FilterDismissProps & {
|
|
78
|
+
/**
|
|
79
|
+
* The unique identifier for the filter.
|
|
80
|
+
*/
|
|
81
|
+
id?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The value of the filter.
|
|
84
|
+
* @default undefined
|
|
85
|
+
*/
|
|
86
|
+
value: TType;
|
|
87
|
+
/**
|
|
88
|
+
* Callback function to handle changes in the filter value.
|
|
89
|
+
* @param value - The new value of the filter
|
|
90
|
+
*/
|
|
91
|
+
onChange: (value: TType) => void;
|
|
92
|
+
/**
|
|
93
|
+
* render prop to render the controlling component for filter value selection
|
|
94
|
+
* @param value
|
|
95
|
+
* @param onChange
|
|
96
|
+
*/
|
|
97
|
+
renderControl: (value: TType, onChange: (value: TType) => void) => ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* render prop to render the label for the filter value selection. By default, it will render the value as a string.
|
|
100
|
+
* If the value is iterable, it will render the values as a comma-separated string.
|
|
101
|
+
* @param value
|
|
102
|
+
*/
|
|
103
|
+
renderLabel?: (value: TType) => ReactNode;
|
|
104
|
+
/**
|
|
105
|
+
* whether the filter should close when the user confirms the selection.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
shouldCloseOnConfirm?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* whether the filter should close when the user clears the selection.
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
shouldCloseOnClear?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the filter popover should be open by default when the component first mounts.
|
|
116
|
+
* This only affects the initial state on mount - the component manages its own state after that.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
isDefaultOpen?: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return value of the filter IDs hook.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface UseFilterIdsReturn {
|
|
6
|
+
/**
|
|
7
|
+
* ID for the filter's root container element.
|
|
8
|
+
*/
|
|
9
|
+
rootId: string;
|
|
10
|
+
/**
|
|
11
|
+
* ID for the filter's label element.
|
|
12
|
+
*/
|
|
13
|
+
labelId: string;
|
|
14
|
+
/**
|
|
15
|
+
* ID for the filter's value element.
|
|
16
|
+
*/
|
|
17
|
+
valueId: string;
|
|
18
|
+
/**
|
|
19
|
+
* ID for the dismiss button element.
|
|
20
|
+
*/
|
|
21
|
+
dismissButtonId: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Custom hook to generate consistent accessibility IDs for the filter component.
|
|
25
|
+
* This hook ensures that all filter elements have unique, properly associated IDs
|
|
26
|
+
* for accessibility purposes. If no ID is provided, it generates one using React
|
|
27
|
+
* Aria's `useId` hook. All generated IDs follow the pattern: `filter-{id}__{suffix}`.
|
|
28
|
+
* These IDs are used for ARIA attributes like `aria-labelledby`, `aria-describedby`,
|
|
29
|
+
* and `aria-controls` to create proper semantic relationships between elements.
|
|
30
|
+
* @param id - Optional custom ID for the filter. If not provided, a unique ID will be generated.
|
|
31
|
+
* @returns An object containing all necessary IDs for the filter component
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // With custom ID
|
|
35
|
+
* const { rootId, labelId, dismissButtonId } = useFilterIds('status-filter')
|
|
36
|
+
* // rootId: 'filter-status-filter'
|
|
37
|
+
* // labelId: 'filter-status-filter__label'
|
|
38
|
+
* // dismissButtonId: 'filter-status-filter__dismiss-button'
|
|
39
|
+
*
|
|
40
|
+
* // With auto-generated ID
|
|
41
|
+
* const ids = useFilterIds()
|
|
42
|
+
* // rootId: 'filter-react-aria-123'
|
|
43
|
+
* // labelId: 'filter-react-aria-123__label'
|
|
44
|
+
* // valueId: 'filter-react-aria-123__value'
|
|
45
|
+
* // dismissButtonId: 'filter-react-aria-123__dismiss-button'
|
|
46
|
+
* ```
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function useFilterIds(id?: string): UseFilterIdsReturn;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useId as i } from "react-aria";
|
|
2
|
+
function d(e) {
|
|
3
|
+
const r = i(), t = e ?? r;
|
|
4
|
+
return {
|
|
5
|
+
rootId: `filter-${t}`,
|
|
6
|
+
labelId: `filter-${t}__label`,
|
|
7
|
+
valueId: `filter-${t}__value`,
|
|
8
|
+
dismissButtonId: `filter-${t}__dismiss-button`
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
d as useFilterIds
|
|
13
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the filter state hook.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface UseFilterStateOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the popover should be open by default when the component first mounts.
|
|
8
|
+
* This only affects the initial state on mount - the component manages its own state after that.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
initialIsOpen?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the popover should close when the user confirms the selection.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
shouldCloseOnConfirm?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the popover should close when the user clears the selection.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
shouldCloseOnClear?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Callback function invoked when the user confirms their selection.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
onConfirmSelection?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback function invoked when the user clears their selection.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
onClearSelection?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return value of the filter state hook.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface UseFilterStateReturn {
|
|
38
|
+
/**
|
|
39
|
+
* Whether the filter popover is currently open.
|
|
40
|
+
*/
|
|
41
|
+
isOpen: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Function to control the open/close state of the popover.
|
|
44
|
+
*/
|
|
45
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Function to confirm the current selection. Invokes the `onConfirmSelection` callback
|
|
48
|
+
* and closes the popover if `shouldCloseOnConfirm` is true.
|
|
49
|
+
*/
|
|
50
|
+
confirm: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Function to clear the current selection. Invokes the `onClearSelection` callback
|
|
53
|
+
* and closes the popover if `shouldCloseOnClear` is true.
|
|
54
|
+
*/
|
|
55
|
+
clear: () => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Custom hook to manage the filter popover state and user actions.
|
|
59
|
+
* This hook encapsulates the logic for opening/closing the filter popover
|
|
60
|
+
* and handling confirm and clear actions with their associated callbacks.
|
|
61
|
+
* @param options - Configuration options for the filter state
|
|
62
|
+
* @returns An object containing the popover state and action handlers
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* const { isOpen, setIsOpen, confirm, clear } = useFilterState({
|
|
66
|
+
* shouldCloseOnConfirm: true,
|
|
67
|
+
* shouldCloseOnClear: true,
|
|
68
|
+
* onConfirmSelection: () => console.log('Confirmed'),
|
|
69
|
+
* onClearSelection: () => console.log('Cleared'),
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function useFilterState(options?: UseFilterStateOptions): UseFilterStateReturn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useState as u, useCallback as l } from "react";
|
|
2
|
+
function m(i = {}) {
|
|
3
|
+
const {
|
|
4
|
+
initialIsOpen: r = !1,
|
|
5
|
+
shouldCloseOnConfirm: n = !0,
|
|
6
|
+
shouldCloseOnClear: o = !0,
|
|
7
|
+
onConfirmSelection: t,
|
|
8
|
+
onClearSelection: s
|
|
9
|
+
} = i, [a, e] = u(r), c = l(() => {
|
|
10
|
+
n && e(!1), t?.();
|
|
11
|
+
}, [n, t]), f = l(() => {
|
|
12
|
+
o && e(!1), s?.();
|
|
13
|
+
}, [o, s]);
|
|
14
|
+
return {
|
|
15
|
+
isOpen: a,
|
|
16
|
+
setIsOpen: e,
|
|
17
|
+
confirm: c,
|
|
18
|
+
clear: f
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
m as useFilterState
|
|
23
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return value of the filter value hook.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface UseFilterValueReturn {
|
|
6
|
+
/**
|
|
7
|
+
* The number of selected values in the filter.
|
|
8
|
+
* Returns 1 for non-iterable values, or the count of items for iterables.
|
|
9
|
+
*/
|
|
10
|
+
valuesCount: number;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a badge should be displayed instead of the formatted value.
|
|
13
|
+
* True when the count exceeds maxVisibleValues.
|
|
14
|
+
*/
|
|
15
|
+
shouldShowBadge: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The formatted string representation of the value.
|
|
18
|
+
* Only populated when shouldShowBadge is false.
|
|
19
|
+
*/
|
|
20
|
+
formattedValue: string | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook to calculate display metadata for filter values.
|
|
24
|
+
* This hook determines how many values are selected, whether to show a badge
|
|
25
|
+
* indicating the count, and provides a formatted string representation of the
|
|
26
|
+
* value for display in the filter label.
|
|
27
|
+
* The hook uses memoization to prevent unnecessary recalculations when the
|
|
28
|
+
* value, maxVisibleValues, or renderLabel function haven't changed.
|
|
29
|
+
* @param value - The current filter value (can be single value or iterable)
|
|
30
|
+
* @param maxVisibleValues - Maximum number of values to display before showing a badge
|
|
31
|
+
* @param renderLabel - Function to format the value as a string
|
|
32
|
+
* @returns Metadata about the value for display purposes
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* // Single value
|
|
36
|
+
* const { valuesCount, shouldShowBadge, formattedValue } = useFilterValue(
|
|
37
|
+
* 'active',
|
|
38
|
+
* 3,
|
|
39
|
+
* (v) => String(v)
|
|
40
|
+
* )
|
|
41
|
+
* // valuesCount: 1, shouldShowBadge: false, formattedValue: 'active'
|
|
42
|
+
*
|
|
43
|
+
* // Multiple values within threshold
|
|
44
|
+
* const result = useFilterValue(
|
|
45
|
+
* ['apple', 'banana'],
|
|
46
|
+
* 3,
|
|
47
|
+
* (v) => v.join(', ')
|
|
48
|
+
* )
|
|
49
|
+
* // valuesCount: 2, shouldShowBadge: false, formattedValue: 'apple, banana'
|
|
50
|
+
*
|
|
51
|
+
* // Multiple values exceeding threshold
|
|
52
|
+
* const result = useFilterValue(
|
|
53
|
+
* ['a', 'b', 'c', 'd'],
|
|
54
|
+
* 3,
|
|
55
|
+
* (v) => v.join(', ')
|
|
56
|
+
* )
|
|
57
|
+
* // valuesCount: 4, shouldShowBadge: true, formattedValue: null
|
|
58
|
+
* ```
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare function useFilterValue<TType>(value: TType, maxVisibleValues: number, renderLabel: (value: TType) => string): UseFilterValueReturn;
|