@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,35 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as u } from "react";
|
|
3
|
+
import { useFieldContext as f } from "../../hooks/tanstack-form-context.js";
|
|
4
|
+
import { useFieldA11yContext as x } from "../form-field/TanstackFormField.context.js";
|
|
5
|
+
import { TextArea as p } from "./TextArea.js";
|
|
6
|
+
const T = u(
|
|
7
|
+
({ onChange: i, onBlur: o, isReadOnly: l, isDisabled: d, ...n }, s) => {
|
|
8
|
+
const e = f(), a = x(), m = e.state.meta.isTouched && !e.state.meta.isValid, r = [a.helperTextId, a.feedbackTextId].filter(Boolean).join(" ");
|
|
9
|
+
return /* @__PURE__ */ c(
|
|
10
|
+
p,
|
|
11
|
+
{
|
|
12
|
+
...n,
|
|
13
|
+
ref: s,
|
|
14
|
+
id: a.inputId,
|
|
15
|
+
value: e.state.value,
|
|
16
|
+
onChange: (t) => {
|
|
17
|
+
e.handleChange(t.target.value), i?.(t);
|
|
18
|
+
},
|
|
19
|
+
onBlur: (t) => {
|
|
20
|
+
e.handleBlur(), o?.(t);
|
|
21
|
+
},
|
|
22
|
+
isReadOnly: l,
|
|
23
|
+
isDisabled: d,
|
|
24
|
+
isInvalid: m,
|
|
25
|
+
"aria-labelledby": a.labelId,
|
|
26
|
+
"aria-describedby": r.length > 0 ? r : void 0,
|
|
27
|
+
"aria-details": a.contextualLinkId
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
T.displayName = "TanstackTextArea";
|
|
33
|
+
export {
|
|
34
|
+
T as TanstackTextArea
|
|
35
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as x } from "react";
|
|
3
3
|
import { uyTv as h } from "@payfit/unity-themes";
|
|
4
4
|
import { TextArea as v } from "react-aria-components";
|
|
@@ -6,10 +6,10 @@ import { useIntl as w } from "react-intl";
|
|
|
6
6
|
import { useResizable as M } from "../../hooks/use-resizable.js";
|
|
7
7
|
import { Icon as z } from "../icon/Icon.js";
|
|
8
8
|
import { Spinner as L } from "../spinner/Spinner.js";
|
|
9
|
-
const
|
|
9
|
+
const N = h({
|
|
10
10
|
slots: {
|
|
11
|
-
base: "uy:flex uy:border uy:border-solid uy:rounded-75 uy:focus-within:outline-none uy:focus-within:ring-2 uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2 uy:active:border-border-form-active uy:overflow-hidden uy:relative",
|
|
12
|
-
inputWrapper: "uy:flex uy:gap-50 uy:flex-grow uy:pt-100 uy:pb-100 uy:pl-150 uy:pr-150 uy:rounded-75",
|
|
11
|
+
base: "uy:flex uy:border uy:border-solid uy:rounded-100 uy:sm:rounded-75 uy:focus-within:outline-none uy:focus-within:ring-2 uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2 uy:active:border-border-form-active uy:overflow-hidden uy:relative",
|
|
12
|
+
inputWrapper: "uy:flex uy:gap-50 uy:flex-grow uy:pt-125 uy:sm:pt-100 uy:pb-125 uy:sm:pb-100 uy:pl-150 uy:pr-150 uy:rounded-100 uy:sm:rounded-75",
|
|
13
13
|
input: "uy:flex-grow uy:flex-shrink uy:outline-none uy:typography-body uy:placeholder:text-content-neutral-lowest uy:resize-none",
|
|
14
14
|
state: "uy:flex uy:gap-50 uy:flex-shrink-0 uy:basis-250",
|
|
15
15
|
resizeHandle: "uy:absolute uy:bottom-25 uy:right-25 uy:w-100 uy:h-100 uy:cursor-se-resize uy:flex uy:items-center uy:justify-center"
|
|
@@ -56,24 +56,24 @@ const D = h({
|
|
|
56
56
|
isDisabled: !1,
|
|
57
57
|
isReadOnly: !1
|
|
58
58
|
}
|
|
59
|
-
}),
|
|
59
|
+
}), W = x(
|
|
60
60
|
({
|
|
61
|
-
isInvalid:
|
|
61
|
+
isInvalid: o,
|
|
62
62
|
isLoading: s,
|
|
63
|
-
isDisabled:
|
|
64
|
-
isReadOnly:
|
|
63
|
+
isDisabled: r,
|
|
64
|
+
isReadOnly: t,
|
|
65
65
|
isResizable: i = !1,
|
|
66
66
|
...d
|
|
67
67
|
}, f) => {
|
|
68
|
-
const
|
|
69
|
-
isDisabled: !i ||
|
|
70
|
-
}), { base:
|
|
71
|
-
isInvalid:
|
|
72
|
-
isDisabled:
|
|
73
|
-
isReadOnly:
|
|
68
|
+
const u = w(), { containerRef: l, handleResizeStart: y } = M({
|
|
69
|
+
isDisabled: !i || r || t
|
|
70
|
+
}), { base: m, inputWrapper: b, input: c, state: p, resizeHandle: g } = N({
|
|
71
|
+
isInvalid: o,
|
|
72
|
+
isDisabled: r,
|
|
73
|
+
isReadOnly: t
|
|
74
74
|
});
|
|
75
|
-
return /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ a("div", { ref: l, className: m(), children: [
|
|
76
|
+
/* @__PURE__ */ a("div", { className: b(), children: [
|
|
77
77
|
/* @__PURE__ */ e(
|
|
78
78
|
v,
|
|
79
79
|
{
|
|
@@ -82,27 +82,29 @@ const D = h({
|
|
|
82
82
|
ref: f,
|
|
83
83
|
className: c(),
|
|
84
84
|
"aria-busy": s,
|
|
85
|
-
|
|
85
|
+
"aria-invalid": o,
|
|
86
|
+
readOnly: t,
|
|
87
|
+
disabled: r
|
|
86
88
|
}
|
|
87
89
|
),
|
|
88
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ a("div", { className: p(), children: [
|
|
89
91
|
s && /* @__PURE__ */ e(
|
|
90
92
|
L,
|
|
91
93
|
{
|
|
92
94
|
color: "inherit",
|
|
93
95
|
size: "small",
|
|
94
|
-
label:
|
|
96
|
+
label: u.formatMessage({
|
|
95
97
|
id: "unity:component:form-field:form-input:spinner:label",
|
|
96
98
|
defaultMessage: "Loading"
|
|
97
99
|
})
|
|
98
100
|
}
|
|
99
101
|
),
|
|
100
|
-
|
|
102
|
+
o && /* @__PURE__ */ e(
|
|
101
103
|
z,
|
|
102
104
|
{
|
|
103
105
|
src: "WarningCircleOutlined",
|
|
104
106
|
color: "content.form.invalid",
|
|
105
|
-
alt:
|
|
107
|
+
alt: u.formatMessage({
|
|
106
108
|
id: "unity:component:form-field:form-input:error:alt",
|
|
107
109
|
defaultMessage: "Error"
|
|
108
110
|
})
|
|
@@ -110,21 +112,21 @@ const D = h({
|
|
|
110
112
|
)
|
|
111
113
|
] })
|
|
112
114
|
] }),
|
|
113
|
-
i && !
|
|
115
|
+
i && !r && !t && /* @__PURE__ */ e(
|
|
114
116
|
"div",
|
|
115
117
|
{
|
|
116
118
|
className: g(),
|
|
117
119
|
onMouseDown: y,
|
|
118
120
|
role: "button",
|
|
119
121
|
tabIndex: 0,
|
|
120
|
-
"aria-label":
|
|
122
|
+
"aria-label": u.formatMessage({
|
|
121
123
|
id: "unity:component:form-field:textarea:resize-handle:label",
|
|
122
124
|
defaultMessage: "Resize textarea"
|
|
123
125
|
}),
|
|
124
|
-
onKeyDown: (
|
|
125
|
-
(
|
|
126
|
+
onKeyDown: (n) => {
|
|
127
|
+
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), l.current?.querySelector("textarea")?.focus());
|
|
126
128
|
},
|
|
127
|
-
children: /* @__PURE__ */
|
|
129
|
+
children: /* @__PURE__ */ a(
|
|
128
130
|
"svg",
|
|
129
131
|
{
|
|
130
132
|
role: "presentation",
|
|
@@ -155,8 +157,8 @@ const D = h({
|
|
|
155
157
|
] });
|
|
156
158
|
}
|
|
157
159
|
);
|
|
158
|
-
|
|
160
|
+
W.displayName = "TextArea";
|
|
159
161
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
W as TextArea,
|
|
163
|
+
N as textArea
|
|
162
164
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TanstackInputProps } from '../input/TanstackInput.js';
|
|
3
|
+
import { LabelProps } from '../label/Label.js';
|
|
4
|
+
import { TanstackTextAreaProps } from '../text-area/TanstackTextArea.js';
|
|
5
|
+
interface FieldProps extends Pick<LabelProps, 'isRequired' | 'requiredVariant'> {
|
|
6
|
+
/** The label for the text field. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** If true, the text field will be a multi-line text area. */
|
|
9
|
+
multiline?: boolean;
|
|
10
|
+
/** Helper text to display below the text field. */
|
|
11
|
+
helperText?: ReactNode;
|
|
12
|
+
/** A contextual link to display below the text field. */
|
|
13
|
+
contextualLink?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
interface TextFieldWithInputProps extends FieldProps, TanstackInputProps {
|
|
16
|
+
multiline?: false;
|
|
17
|
+
type?: 'text' | 'password' | 'email' | 'tel' | 'url' | 'search';
|
|
18
|
+
}
|
|
19
|
+
interface TextFieldWithTextAreaProps extends FieldProps, TanstackTextAreaProps {
|
|
20
|
+
multiline?: true;
|
|
21
|
+
type?: never;
|
|
22
|
+
}
|
|
23
|
+
export type TextFieldProps = TextFieldWithInputProps | TextFieldWithTextAreaProps;
|
|
24
|
+
/**
|
|
25
|
+
* The `TanstackTextField` component renders a full field (label, input or textarea)
|
|
26
|
+
* wired to the TanStack Form context. It manages state and accessibility via the
|
|
27
|
+
* context provided by `useTanstackUnityForm` and `<form.AppField name="…">`.
|
|
28
|
+
*
|
|
29
|
+
* Behavior:
|
|
30
|
+
* - Single-line: renders `TanstackInput`.
|
|
31
|
+
* - Multi-line: renders `TanstackTextArea`.
|
|
32
|
+
* - Displays the label (`TanstackFormLabel`), helper text (`TanstackFormHelperText`),
|
|
33
|
+
* feedback messages (`TanstackFormFeedbackText`), and an optional contextual link.
|
|
34
|
+
*
|
|
35
|
+
* Accessibility:
|
|
36
|
+
* - Automatically wires `aria-labelledby`, `aria-describedby` (helper/feedback), and
|
|
37
|
+
* `aria-details` using identifiers from the `a11y` context.
|
|
38
|
+
*
|
|
39
|
+
* Key props:
|
|
40
|
+
* - `label: string` — label text.
|
|
41
|
+
* - `multiline?: boolean` — when true, renders a textarea; otherwise, an input.
|
|
42
|
+
* - `defaultValue?` — initial value passed to the native control (the field remains
|
|
43
|
+
* controlled by the form context afterwards).
|
|
44
|
+
* - `helperText?: ReactNode` — helper text displayed below the field.
|
|
45
|
+
* - `contextualLink?: ReactNode` — optional contextual link, referenced via `aria-details`.
|
|
46
|
+
* - Inherits props from `TanstackInput` or `TanstackTextArea` depending on `multiline`.
|
|
47
|
+
* - `isRequired?`, `requiredVariant?` — control the required indicator in the label.
|
|
48
|
+
*
|
|
49
|
+
* Example:
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { TanstackTextField } from "@/components/text-field/TanstackTextField"
|
|
52
|
+
* import { useTanstackUnityForm } from "@/hooks/use-tanstack-form"
|
|
53
|
+
*
|
|
54
|
+
* function Example() {
|
|
55
|
+
* const schema = z.object({
|
|
56
|
+
* name: z.string(),
|
|
57
|
+
* email: z.string().email()
|
|
58
|
+
* })
|
|
59
|
+
*
|
|
60
|
+
* const form = useTanstackUnityForm<{ name: string }>({ validators: {
|
|
61
|
+
* onBlur: schema,
|
|
62
|
+
* } })
|
|
63
|
+
* return (
|
|
64
|
+
* <form>
|
|
65
|
+
* <form.AppField name="name">
|
|
66
|
+
* {() => (
|
|
67
|
+
* <TanstackTextField label="Name" helperText="Your full name" />
|
|
68
|
+
* )}
|
|
69
|
+
* </form.AppField>
|
|
70
|
+
* </form>
|
|
71
|
+
* )
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
* @remarks Migration from `TextField` (non‑TanStack):
|
|
75
|
+
* - Do not pass a `name` prop to the field: use `<form.AppField name="…">`.
|
|
76
|
+
* - `value`, `defaultValue`, and `isInvalid` are derived from the TanStack form context.
|
|
77
|
+
*/
|
|
78
|
+
declare const TanstackTextField: import('react').ForwardRefExoticComponent<TextFieldProps & import('react').RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
79
|
+
export { TanstackTextField };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs as k, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as F } from "react";
|
|
3
|
+
import { TanstackFormFeedbackText as x } from "../form-field/parts/TanstackFormFeedbackText.js";
|
|
4
|
+
import { TanstackFormHelperText as u } from "../form-field/parts/TanstackFormHelperText.js";
|
|
5
|
+
import { TanstackFormLabel as C } from "../form-field/parts/TanstackFormLabel.js";
|
|
6
|
+
import { TanstackFormField as P } from "../form-field/TanstackFormField.js";
|
|
7
|
+
import { TanstackInput as b } from "../input/TanstackInput.js";
|
|
8
|
+
import { TanstackTextArea as B } from "../text-area/TanstackTextArea.js";
|
|
9
|
+
function h({
|
|
10
|
+
label: m,
|
|
11
|
+
helperText: t,
|
|
12
|
+
contextualLink: s,
|
|
13
|
+
multiline: a,
|
|
14
|
+
isRequired: c,
|
|
15
|
+
isLoading: i,
|
|
16
|
+
isDisabled: l,
|
|
17
|
+
isReadOnly: p,
|
|
18
|
+
requiredVariant: T,
|
|
19
|
+
...r
|
|
20
|
+
}, n) {
|
|
21
|
+
const e = {
|
|
22
|
+
isLoading: i,
|
|
23
|
+
isDisabled: l,
|
|
24
|
+
isReadOnly: p
|
|
25
|
+
}, d = !a, { onClearButtonPress: f } = d ? r : {};
|
|
26
|
+
return /* @__PURE__ */ k(P, { children: [
|
|
27
|
+
/* @__PURE__ */ o(
|
|
28
|
+
C,
|
|
29
|
+
{
|
|
30
|
+
requiredVariant: T,
|
|
31
|
+
isRequired: c,
|
|
32
|
+
children: m
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
t && /* @__PURE__ */ o(u, { children: t }),
|
|
36
|
+
a ? /* @__PURE__ */ o(
|
|
37
|
+
B,
|
|
38
|
+
{
|
|
39
|
+
ref: n,
|
|
40
|
+
...e,
|
|
41
|
+
...r
|
|
42
|
+
}
|
|
43
|
+
) : /* @__PURE__ */ o(
|
|
44
|
+
b,
|
|
45
|
+
{
|
|
46
|
+
ref: n,
|
|
47
|
+
onClearButtonPress: f,
|
|
48
|
+
...e,
|
|
49
|
+
...r
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ o(x, {}),
|
|
53
|
+
s
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
const j = F(h);
|
|
57
|
+
j.displayName = "TanstackTextField";
|
|
58
|
+
export {
|
|
59
|
+
j as TanstackTextField
|
|
60
|
+
};
|
|
@@ -58,6 +58,8 @@ type TextFieldComponent = (<TSchema extends Schema>(props: TextFieldProps<Standa
|
|
|
58
58
|
* }
|
|
59
59
|
* ```
|
|
60
60
|
* @note The schema type parameter is needed to ensure type safety with the form's schema. If you omit it, the `name` prop will not be type-safe.
|
|
61
|
+
* @deprecated React Hook Form components are deprecated. Use the TanStack Form version instead.
|
|
62
|
+
* @see Storybook docs: https://unity-components.payfit.io/?path=/docs/forms-introduction-to-unity-forms--docs
|
|
61
63
|
*/
|
|
62
64
|
declare const TextField: TextFieldComponent;
|
|
63
65
|
export { TextField };
|
|
@@ -6,9 +6,9 @@ import { IconButton as b } from "../icon-button/IconButton.js";
|
|
|
6
6
|
import { Icon as g } from "../icon/Icon.js";
|
|
7
7
|
import { ToastTitle as x } from "./parts/ToastTitle.js";
|
|
8
8
|
import { ToastProvider as T } from "./Toast.context.js";
|
|
9
|
-
const
|
|
9
|
+
const v = p({
|
|
10
10
|
slots: {
|
|
11
|
-
base: "uy:sm:w-[416px] uy:border uy:border-solid uy:rounded-150 uy:text-content-neutral uy:bg-surface-neutral uy:shadow-floating uy:p-100 uy:flex uy:gap-125 uy:border-border-neutral
|
|
11
|
+
base: "uy:sm:w-[416px] uy:border uy:border-solid uy:rounded-150 uy:text-content-neutral uy:bg-surface-neutral uy:shadow-floating uy:p-100 uy:flex uy:gap-125 uy:border-border-neutral",
|
|
12
12
|
contentWrapper: "uy:flex uy:grow uy:ml-125",
|
|
13
13
|
divider: "uy:border-l-[1px] uy:border-solid uy:border-border-neutral uy:self-stretch"
|
|
14
14
|
},
|
|
@@ -26,7 +26,7 @@ const h = p({
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
}),
|
|
29
|
+
}), h = (e) => {
|
|
30
30
|
const s = l(e) && e.type === d ? e.props.children : e;
|
|
31
31
|
if (m.toArray(s).filter(
|
|
32
32
|
(r) => l(r) && r.type === x
|
|
@@ -40,8 +40,8 @@ const h = p({
|
|
|
40
40
|
...i
|
|
41
41
|
}) => {
|
|
42
42
|
const a = f();
|
|
43
|
-
|
|
44
|
-
const { base: u, contentWrapper: c, divider: y } =
|
|
43
|
+
h(e);
|
|
44
|
+
const { base: u, contentWrapper: c, divider: y } = v({
|
|
45
45
|
variant: t,
|
|
46
46
|
isInline: r
|
|
47
47
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl';
|
|
2
|
+
import { PlayCtx } from '../../types/testing.js';
|
|
3
|
+
import { UnityToastProps } from './UnityToast.js';
|
|
4
|
+
/**
|
|
5
|
+
* Factory function returning a set of helpers to test Unity Toast components.
|
|
6
|
+
* It wires Storybook's `Play` context with convenient utilities to query,
|
|
7
|
+
* assert, and interact with toasts rendered on the canvas.
|
|
8
|
+
* @param context The Storybook play context used to group steps and actions.
|
|
9
|
+
* @returns An object of helpers: `getToast`, `closeToast`, `checkIfTextExistsInToast`, and `triggerToastAction`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getTestingUtilsToast: (context: PlayCtx, globalIntl: IntlShape) => {
|
|
12
|
+
findToast: (variant: UnityToastProps["variant"]) => Promise<HTMLElement>;
|
|
13
|
+
findAllToasts: (variant?: UnityToastProps["variant"]) => Promise<HTMLElement[]>;
|
|
14
|
+
getToastContainer: () => HTMLElement;
|
|
15
|
+
closeAllToasts: () => Promise<void>;
|
|
16
|
+
closeToast: ({ variant, toast, }: {
|
|
17
|
+
variant: UnityToastProps["variant"];
|
|
18
|
+
toast?: HTMLElement;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
triggerToastAction: ({ variant, action, closeAtEnd, }: {
|
|
21
|
+
variant: UnityToastProps["variant"];
|
|
22
|
+
action: string;
|
|
23
|
+
closeAtEnd?: boolean;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
assertTextExistsInToast: ({ variant, content, title, closeAtEnd, }: {
|
|
26
|
+
variant: UnityToastProps["variant"];
|
|
27
|
+
title?: string;
|
|
28
|
+
content?: string;
|
|
29
|
+
closeAtEnd?: boolean;
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
assertToastNotInDocument: ({ variant, title, content, }: {
|
|
32
|
+
variant: UnityToastProps["variant"];
|
|
33
|
+
title?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { within as n, expect as w, userEvent as y } from "storybook/test";
|
|
2
|
+
const x = (r, h) => {
|
|
3
|
+
const g = () => (
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
|
|
5
|
+
r.canvasElement.querySelector("#_rht_toaster")
|
|
6
|
+
), p = async (t, e, { timeoutMs: s = 2e3, pollMs: o = 50 } = {}) => {
|
|
7
|
+
let a = await t();
|
|
8
|
+
const i = Math.min(
|
|
9
|
+
200,
|
|
10
|
+
Math.max(1, Math.ceil(s / Math.max(1, o)))
|
|
11
|
+
), c = () => new Promise((f) => {
|
|
12
|
+
let d = !1;
|
|
13
|
+
const T = () => {
|
|
14
|
+
d || (d = !0, f());
|
|
15
|
+
};
|
|
16
|
+
setTimeout(T, o), typeof window < "u" && typeof window.requestAnimationFrame == "function" && window.requestAnimationFrame(T), typeof setImmediate == "function" && setImmediate(T);
|
|
17
|
+
});
|
|
18
|
+
for (let f = 0; f < i && !e(a); f++)
|
|
19
|
+
await c(), a = await t();
|
|
20
|
+
return a;
|
|
21
|
+
}, l = async (t) => {
|
|
22
|
+
const e = g();
|
|
23
|
+
if (!e)
|
|
24
|
+
throw new Error("No toast container found on the page");
|
|
25
|
+
const { errorToasts: s, statusToasts: o } = await p(
|
|
26
|
+
() => {
|
|
27
|
+
const a = n(e).queryAllByRole("alert").filter((c) => c.getAttribute("aria-live") === "assertive"), i = n(e).queryAllByRole("status").filter((c) => c.getAttribute("aria-live") === "polite");
|
|
28
|
+
return { errorToasts: a, statusToasts: i };
|
|
29
|
+
},
|
|
30
|
+
(a) => t ? t === "error" ? a.errorToasts.length > 0 : a.statusToasts.length > 0 : a.errorToasts.length > 0 || a.statusToasts.length > 0
|
|
31
|
+
);
|
|
32
|
+
return t ? t === "error" ? s : o : [...s, ...o];
|
|
33
|
+
}, u = async (t) => {
|
|
34
|
+
const s = (await l(t)).at(0);
|
|
35
|
+
if (!s)
|
|
36
|
+
throw new Error(`Toast with variant: ${t} not found in the page`);
|
|
37
|
+
return s;
|
|
38
|
+
}, B = async () => {
|
|
39
|
+
const t = await l();
|
|
40
|
+
await Promise.all(
|
|
41
|
+
t.map(
|
|
42
|
+
(e) => y.click(
|
|
43
|
+
n(e).getByRole("button", {
|
|
44
|
+
name: h.formatMessage({
|
|
45
|
+
id: "unity:component:common:close:label"
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
}, m = async ({
|
|
52
|
+
variant: t,
|
|
53
|
+
toast: e
|
|
54
|
+
}) => {
|
|
55
|
+
await r.step("Close toast", async () => {
|
|
56
|
+
const s = e ?? await u(t);
|
|
57
|
+
await y.click(
|
|
58
|
+
n(s).getByRole("button", {
|
|
59
|
+
name: h.formatMessage({
|
|
60
|
+
id: "unity:component:common:close:label"
|
|
61
|
+
})
|
|
62
|
+
}),
|
|
63
|
+
{ delay: 100 }
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
findToast: u,
|
|
69
|
+
findAllToasts: l,
|
|
70
|
+
getToastContainer: g,
|
|
71
|
+
closeAllToasts: B,
|
|
72
|
+
closeToast: m,
|
|
73
|
+
triggerToastAction: async ({
|
|
74
|
+
variant: t,
|
|
75
|
+
action: e,
|
|
76
|
+
closeAtEnd: s = !1
|
|
77
|
+
}) => {
|
|
78
|
+
const o = await u(t);
|
|
79
|
+
await r.step("Trigger the action of the toast", async () => {
|
|
80
|
+
await y.click(n(o).getByRole("button", { name: e }));
|
|
81
|
+
}), s && await m({ variant: t });
|
|
82
|
+
},
|
|
83
|
+
assertTextExistsInToast: async ({
|
|
84
|
+
variant: t,
|
|
85
|
+
content: e,
|
|
86
|
+
title: s,
|
|
87
|
+
closeAtEnd: o = !1
|
|
88
|
+
}) => {
|
|
89
|
+
const a = await u(t);
|
|
90
|
+
s && await r.step(`Check if "${s}" is in the toast`, async () => {
|
|
91
|
+
await w(
|
|
92
|
+
n(a).getByRole("heading", { name: s })
|
|
93
|
+
).toBeInTheDocument();
|
|
94
|
+
}), e && await r.step(`Check if "${e}" is in the toast`, async () => {
|
|
95
|
+
await w(n(a).getByText(e)).toBeInTheDocument();
|
|
96
|
+
}), o && await m({ variant: t });
|
|
97
|
+
},
|
|
98
|
+
assertToastNotInDocument: async ({
|
|
99
|
+
variant: t,
|
|
100
|
+
title: e,
|
|
101
|
+
content: s
|
|
102
|
+
}) => {
|
|
103
|
+
const o = (await l(t)).filter(
|
|
104
|
+
(a) => e && n(a).queryByText(e) && s && n(a).queryByText(s)
|
|
105
|
+
);
|
|
106
|
+
for (const a of o) {
|
|
107
|
+
let i = `Toast with variant: ${t}`;
|
|
108
|
+
e && (i += ` and title: ${e}`), s && (i += ` and content: ${s}`), await w(
|
|
109
|
+
a,
|
|
110
|
+
`${i} not in the document`
|
|
111
|
+
).not.toBeInTheDocument();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
x as getTestingUtilsToast
|
|
118
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ToggleSwitch } from './ToggleSwitch.js';
|
|
2
|
+
type BaseToggleSwitchProps = React.ComponentProps<typeof ToggleSwitch>;
|
|
3
|
+
export type TanstackToggleSwitchProps = Omit<BaseToggleSwitchProps, 'isSelected' | 'defaultSelected'>;
|
|
4
|
+
/**
|
|
5
|
+
* TanStack‑controlled toggle switch.
|
|
6
|
+
*
|
|
7
|
+
* `TanstackToggleSwitch` is the Unity `ToggleSwitch` wired to the TanStack Form
|
|
8
|
+
* field context. Its selected state (`isSelected`) is fully controlled by the
|
|
9
|
+
* form and updates through `field.handleChange` on user interaction.
|
|
10
|
+
*
|
|
11
|
+
* Accessibility:
|
|
12
|
+
* - Automatically links to the enclosing `TanstackFormField` feedback text via
|
|
13
|
+
* `aria-describedby`.
|
|
14
|
+
* - Use a plain string `label` (or `isLabelSrOnly` for visually hidden labels)
|
|
15
|
+
* to keep the control accessible.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* - Must be rendered inside `<form.AppField name="…">` from
|
|
19
|
+
* `useTanstackUnityForm`.
|
|
20
|
+
* - Do not pass `isSelected`/`defaultSelected`; use form default values instead.
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { useTanstackUnityForm } from '@/hooks/use-tanstack-form'
|
|
24
|
+
* import { TanstackToggleSwitch } from '@/components/toggle-switch/TanstackToggleSwitch'
|
|
25
|
+
* import * as z from 'zod'
|
|
26
|
+
*
|
|
27
|
+
* const schema = z.object({ newsletter: z.boolean().optional() })
|
|
28
|
+
*
|
|
29
|
+
* export function Example() {
|
|
30
|
+
* const form = useTanstackUnityForm({ validators: { onBlur: schema } })
|
|
31
|
+
* return (
|
|
32
|
+
* <form.AppForm>
|
|
33
|
+
* <form.Form>
|
|
34
|
+
* <form.AppField name="newsletter">
|
|
35
|
+
* {() => (
|
|
36
|
+
* <TanstackToggleSwitch label="Subscribe to newsletter" />
|
|
37
|
+
* )}
|
|
38
|
+
* </form.AppField>
|
|
39
|
+
* </form.Form>
|
|
40
|
+
* </form.AppForm>
|
|
41
|
+
* )
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare const TanstackToggleSwitch: import('react').ForwardRefExoticComponent<Omit<TanstackToggleSwitchProps, "ref"> & import('react').RefAttributes<HTMLLabelElement>>;
|
|
46
|
+
export { TanstackToggleSwitch };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as c } from "react";
|
|
3
|
+
import { useFieldContext as d } from "../../hooks/tanstack-form-context.js";
|
|
4
|
+
import { useFieldA11yContext as l } from "../form-field/TanstackFormField.context.js";
|
|
5
|
+
import { ToggleSwitch as m } from "./ToggleSwitch.js";
|
|
6
|
+
const f = c(({ onChange: i, isDisabled: r, ...a }, n) => {
|
|
7
|
+
const e = d(), o = [l().feedbackTextId].filter(Boolean).join(" ");
|
|
8
|
+
return /* @__PURE__ */ s(
|
|
9
|
+
m,
|
|
10
|
+
{
|
|
11
|
+
...a,
|
|
12
|
+
ref: n,
|
|
13
|
+
isDisabled: r,
|
|
14
|
+
isSelected: e.state.value,
|
|
15
|
+
onChange: (t) => {
|
|
16
|
+
e.handleChange(t), i?.(t);
|
|
17
|
+
},
|
|
18
|
+
"aria-describedby": o.length > 0 ? o : void 0
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
f.displayName = "TanstackToggleSwitch";
|
|
23
|
+
export {
|
|
24
|
+
f as TanstackToggleSwitch
|
|
25
|
+
};
|
|
@@ -7,12 +7,14 @@ export declare const toggleSwitch: import('tailwind-variants').TVReturnType<{
|
|
|
7
7
|
knob: string;
|
|
8
8
|
};
|
|
9
9
|
true: {
|
|
10
|
+
label: string;
|
|
10
11
|
indicator: string;
|
|
11
12
|
knob: string;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
}, {
|
|
15
16
|
container: string[];
|
|
17
|
+
mobileContainer: string[];
|
|
16
18
|
textWrapper: string[];
|
|
17
19
|
label: string[];
|
|
18
20
|
hintText: string[];
|
|
@@ -25,12 +27,14 @@ export declare const toggleSwitch: import('tailwind-variants').TVReturnType<{
|
|
|
25
27
|
knob: string;
|
|
26
28
|
};
|
|
27
29
|
true: {
|
|
30
|
+
label: string;
|
|
28
31
|
indicator: string;
|
|
29
32
|
knob: string;
|
|
30
33
|
};
|
|
31
34
|
};
|
|
32
35
|
}, {
|
|
33
36
|
container: string[];
|
|
37
|
+
mobileContainer: string[];
|
|
34
38
|
textWrapper: string[];
|
|
35
39
|
label: string[];
|
|
36
40
|
hintText: string[];
|
|
@@ -43,19 +47,21 @@ export declare const toggleSwitch: import('tailwind-variants').TVReturnType<{
|
|
|
43
47
|
knob: string;
|
|
44
48
|
};
|
|
45
49
|
true: {
|
|
50
|
+
label: string;
|
|
46
51
|
indicator: string;
|
|
47
52
|
knob: string;
|
|
48
53
|
};
|
|
49
54
|
};
|
|
50
55
|
}, {
|
|
51
56
|
container: string[];
|
|
57
|
+
mobileContainer: string[];
|
|
52
58
|
textWrapper: string[];
|
|
53
59
|
label: string[];
|
|
54
60
|
hintText: string[];
|
|
55
61
|
indicator: string[];
|
|
56
62
|
knob: string[];
|
|
57
63
|
}, undefined, unknown, unknown, undefined>>;
|
|
58
|
-
interface ToggleSwitchProps extends Omit<AriaSwitchProps, 'children' | 'className' | 'style'>, VariantProps<typeof toggleSwitch> {
|
|
64
|
+
export interface ToggleSwitchProps extends Omit<AriaSwitchProps, 'children' | 'className' | 'style'>, VariantProps<typeof toggleSwitch> {
|
|
59
65
|
/** The label for the toggle switch. */
|
|
60
66
|
label: string;
|
|
61
67
|
/** Whether the label is visually hidden and accessible only to screen readers. */
|
|
@@ -64,15 +70,22 @@ interface ToggleSwitchProps extends Omit<AriaSwitchProps, 'children' | 'classNam
|
|
|
64
70
|
helperText?: string;
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
73
|
+
* Binary toggle input with Unity styles and animation.
|
|
74
|
+
*
|
|
75
|
+
* The `ToggleSwitch` lets users toggle between two states. It provides a sliding
|
|
76
|
+
* knob animation and supports disabled, readonly and pressed states. Use it as a
|
|
77
|
+
* standalone input, or within a composed field such as `ToggleSwitchField`.
|
|
78
|
+
*
|
|
79
|
+
* Accessibility:
|
|
80
|
+
* - Renders with the ARIA `switch` role.
|
|
81
|
+
* - Always requires a visible label unless `isLabelSrOnly` is set, in which case
|
|
82
|
+
* the label is visually hidden but remains available to assistive tech.
|
|
83
|
+
* @param props Props for the ToggleSwitch component.
|
|
71
84
|
* @example
|
|
72
85
|
* ```tsx
|
|
73
86
|
* import { ToggleSwitch } from '@payfit/unity-components'
|
|
74
87
|
*
|
|
75
|
-
* function Example() {
|
|
88
|
+
* export function Example() {
|
|
76
89
|
* return (
|
|
77
90
|
* <ToggleSwitch
|
|
78
91
|
* label="Enable notifications"
|
|
@@ -81,9 +94,8 @@ interface ToggleSwitchProps extends Omit<AriaSwitchProps, 'children' | 'classNam
|
|
|
81
94
|
* )
|
|
82
95
|
* }
|
|
83
96
|
* ```
|
|
84
|
-
* @see {@link ToggleSwitchProps}
|
|
97
|
+
* @see {@link ToggleSwitchProps}
|
|
85
98
|
* @remarks
|
|
86
|
-
*
|
|
99
|
+
* Docs: /?path=/docs/inputs-toggleswitch--docs • Story: /?path=/story/inputs-toggleswitch--primary
|
|
87
100
|
*/
|
|
88
101
|
export declare const ToggleSwitch: import('react').ForwardRefExoticComponent<ToggleSwitchProps & import('react').RefAttributes<HTMLLabelElement>>;
|
|
89
|
-
export {};
|