@povio/ui 0.0.2 → 0.0.3
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/package.json +67 -10
- package/src/assets/icons/AlignCenter.tsx +16 -0
- package/src/assets/icons/AlignLeft.tsx +16 -0
- package/src/assets/icons/AlignLeftRight.tsx +16 -0
- package/src/assets/icons/AlignRight.tsx +16 -0
- package/src/assets/icons/ArrowDropDown.tsx +16 -0
- package/src/assets/icons/ArrowDropUp.tsx +16 -0
- package/src/assets/icons/ArrowLeft.tsx +16 -0
- package/src/assets/icons/ArrowRight.tsx +16 -0
- package/src/assets/icons/Bold.tsx +16 -0
- package/src/assets/icons/BulletedList.tsx +16 -0
- package/src/assets/icons/Calendar.tsx +18 -0
- package/src/assets/icons/Check.tsx +18 -0
- package/src/assets/icons/CheckCircle.tsx +16 -0
- package/src/assets/icons/CheckboxCheckmark.tsx +19 -0
- package/src/assets/icons/CheckboxIndeterminate.tsx +19 -0
- package/src/assets/icons/ChevronDown.tsx +18 -0
- package/src/assets/icons/ChevronLeft.tsx +18 -0
- package/src/assets/icons/ChevronRight.tsx +18 -0
- package/src/assets/icons/ChevronUp.tsx +18 -0
- package/src/assets/icons/ChevronsLeft.tsx +24 -0
- package/src/assets/icons/ChevronsRight.tsx +24 -0
- package/src/assets/icons/Clock.tsx +16 -0
- package/src/assets/icons/Close.tsx +16 -0
- package/src/assets/icons/DateTime.tsx +20 -0
- package/src/assets/icons/Drag.tsx +16 -0
- package/src/assets/icons/File.tsx +18 -0
- package/src/assets/icons/Highlight.tsx +16 -0
- package/src/assets/icons/HighlightOn.tsx +26 -0
- package/src/assets/icons/Info.tsx +24 -0
- package/src/assets/icons/Italic.tsx +16 -0
- package/src/assets/icons/Link.tsx +16 -0
- package/src/assets/icons/Menu.tsx +18 -0
- package/src/assets/icons/NumberedList.tsx +16 -0
- package/src/assets/icons/PointerHorizontal.tsx +16 -0
- package/src/assets/icons/PointerVertical.tsx +16 -0
- package/src/assets/icons/Send.tsx +18 -0
- package/src/assets/icons/Strikethrough.tsx +16 -0
- package/src/assets/icons/TextColor.tsx +24 -0
- package/src/assets/icons/Today.tsx +16 -0
- package/src/assets/icons/Underlined.tsx +18 -0
- package/src/assets/icons/Upload.tsx +20 -0
- package/src/assets/icons/View.tsx +16 -0
- package/src/assets/icons/ViewOff.tsx +16 -0
- package/src/assets/icons/Warningfilled.tsx +18 -0
- package/src/assets/locales/en/translation.json +156 -0
- package/src/assets/locales/sl/translation.json +152 -0
- package/src/components/Menu/Menu.tsx +29 -0
- package/src/components/Menu/MenuDesktop.tsx +68 -0
- package/src/components/Menu/MenuItem.tsx +33 -0
- package/src/components/Menu/MenuMobile.tsx +81 -0
- package/src/components/Menu/MenuPopover.tsx +45 -0
- package/src/components/buttons/Button/Button.tsx +108 -0
- package/src/components/buttons/Button/button.cva.ts +678 -0
- package/src/components/buttons/IconButton/IconButton.tsx +25 -0
- package/src/components/buttons/InlineIconButton/InlineIconButton.tsx +27 -0
- package/src/components/buttons/PillButton/PillButton.tsx +70 -0
- package/src/components/buttons/PillButton/pillButton.cva.ts +88 -0
- package/src/components/buttons/SplitButton/SplitButton.tsx +61 -0
- package/src/components/buttons/TextButton/TextButton.tsx +29 -0
- package/src/components/buttons/ToggleButton/ToggleButton.tsx +28 -0
- package/src/components/buttons/shared/ButtonContent.tsx +61 -0
- package/src/components/buttons/shared/buttonContent.cva.ts +18 -0
- package/src/components/inputs/Checkbox/Checkbox.tsx +101 -0
- package/src/components/inputs/Checkbox/CheckboxCheckmark.tsx +47 -0
- package/src/components/inputs/Checkbox/checkbox.cva.ts +51 -0
- package/src/components/inputs/DateTime/DatePicker/DatePicker.tsx +269 -0
- package/src/components/inputs/DateTime/DateRangePicker/DateRangePicker.tsx +808 -0
- package/src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx +291 -0
- package/src/components/inputs/DateTime/TimePicker/TimePicker.tsx +255 -0
- package/src/components/inputs/DateTime/shared/Calendar.tsx +104 -0
- package/src/components/inputs/DateTime/shared/CalendarCell.tsx +247 -0
- package/src/components/inputs/DateTime/shared/CalendarGrid.tsx +102 -0
- package/src/components/inputs/DateTime/shared/CalendarHeader.tsx +110 -0
- package/src/components/inputs/DateTime/shared/CalendarSelectHeader.tsx +228 -0
- package/src/components/inputs/DateTime/shared/DateField.tsx +83 -0
- package/src/components/inputs/DateTime/shared/DatePickerInput.tsx +170 -0
- package/src/components/inputs/DateTime/shared/DateSegmentItem.tsx +65 -0
- package/src/components/inputs/DateTime/shared/DateTimeDialog.tsx +87 -0
- package/src/components/inputs/DateTime/shared/DateTimeDialogFooter.tsx +42 -0
- package/src/components/inputs/DateTime/shared/MonthPicker.tsx +91 -0
- package/src/components/inputs/DateTime/shared/RangeCalendar.tsx +160 -0
- package/src/components/inputs/DateTime/shared/TimeField.tsx +36 -0
- package/src/components/inputs/DateTime/shared/TimePickerForm.tsx +222 -0
- package/src/components/inputs/DateTime/shared/TimePickerInput.tsx +114 -0
- package/src/components/inputs/DateTime/shared/YearPicker.tsx +100 -0
- package/src/components/inputs/File/FileUpload.tsx +285 -0
- package/src/components/inputs/File/FileUploadContainer.tsx +16 -0
- package/src/components/inputs/File/InputUpload.tsx +196 -0
- package/src/components/inputs/File/fileUpload.types.ts +100 -0
- package/src/components/inputs/File/index.ts +15 -0
- package/src/components/inputs/File/inputUpload.types.ts +41 -0
- package/src/components/inputs/File/shared/FileCard.tsx +72 -0
- package/src/components/inputs/File/shared/FileCardList.tsx +30 -0
- package/src/components/inputs/File/shared/FileProgressBar.tsx +25 -0
- package/src/components/inputs/File/shared/FileUploadContent.tsx +99 -0
- package/src/components/inputs/File/shared/FileUploadContentEmpty.tsx +94 -0
- package/src/components/inputs/File/shared/FileUploadContentError.tsx +170 -0
- package/src/components/inputs/File/shared/FileUploadContentFilled.tsx +179 -0
- package/src/components/inputs/File/shared/FileUploadContentLoading.tsx +115 -0
- package/src/components/inputs/File/shared/InputUploadContent.tsx +68 -0
- package/src/components/inputs/File/shared/InputUploadFilled.tsx +32 -0
- package/src/components/inputs/File/shared/fileUpload.cva.ts +59 -0
- package/src/components/inputs/File/shared/inputUploadButton.cva.ts +48 -0
- package/src/components/inputs/FormField/FormField.tsx +69 -0
- package/src/components/inputs/FormField/FormFieldError.tsx +21 -0
- package/src/components/inputs/FormField/FormFieldHeader.tsx +75 -0
- package/src/components/inputs/FormField/FormFieldHeaderClose.tsx +23 -0
- package/src/components/inputs/FormField/FormFieldLabel.tsx +41 -0
- package/src/components/inputs/Input/NumberInput/NumberInput.tsx +180 -0
- package/src/components/inputs/Input/PasswordInput/PasswordInput.tsx +34 -0
- package/src/components/inputs/Input/TextArea/TextArea.tsx +166 -0
- package/src/components/inputs/Input/TextInput/TextInput.tsx +181 -0
- package/src/components/inputs/Input/shared/InputContent.tsx +154 -0
- package/src/components/inputs/Inputs/Form.tsx +129 -0
- package/src/components/inputs/Inputs/InputItem.tsx +127 -0
- package/src/components/inputs/Inputs/Inputs.tsx +43 -0
- package/src/components/inputs/RadioGroup/RadioGroup.tsx +139 -0
- package/src/components/inputs/RadioGroup/radio.cva.ts +51 -0
- package/src/components/inputs/Selection/Autocomplete/Autocomplete.tsx +61 -0
- package/src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx +58 -0
- package/src/components/inputs/Selection/Select/Select.tsx +59 -0
- package/src/components/inputs/Selection/shared/SelectBase.tsx +69 -0
- package/src/components/inputs/Selection/shared/SelectDesktop.tsx +236 -0
- package/src/components/inputs/Selection/shared/SelectInput.tsx +278 -0
- package/src/components/inputs/Selection/shared/SelectListBox.tsx +121 -0
- package/src/components/inputs/Selection/shared/SelectListBoxItem.tsx +79 -0
- package/src/components/inputs/Selection/shared/SelectListBoxItemSelectAll.tsx +40 -0
- package/src/components/inputs/Selection/shared/SelectListBoxLoadingItem.tsx +52 -0
- package/src/components/inputs/Selection/shared/SelectListBoxSelectionBar.tsx +39 -0
- package/src/components/inputs/Selection/shared/SelectMobile.tsx +169 -0
- package/src/components/inputs/Selection/shared/select.context.tsx +316 -0
- package/src/components/inputs/Selection/shared/select.types.ts +75 -0
- package/src/components/inputs/Selection/shared/useSelectItems.tsx +127 -0
- package/src/components/inputs/Slider/Slider.tsx +174 -0
- package/src/components/inputs/TextEditor/TextEditor.tsx +239 -0
- package/src/components/inputs/TextEditor/Toolbar/ColorPicker.tsx +34 -0
- package/src/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.tsx +74 -0
- package/src/components/inputs/TextEditor/Toolbar/HyperlinkAction.tsx +87 -0
- package/src/components/inputs/TextEditor/Toolbar/TextAlignSelect.tsx +64 -0
- package/src/components/inputs/TextEditor/Toolbar/TextColorSelect.tsx +30 -0
- package/src/components/inputs/TextEditor/Toolbar/TextEditorToolbar.tsx +40 -0
- package/src/components/inputs/TextEditor/Toolbar/TextHighlightSelect.tsx +39 -0
- package/src/components/inputs/TextEditor/Toolbar/TextListActions.tsx +57 -0
- package/src/components/inputs/TextEditor/Toolbar/TextMarksActions.tsx +79 -0
- package/src/components/inputs/TextEditor/Toolbar/TextStyleSelect.tsx +73 -0
- package/src/components/inputs/TextEditor/textEditor.types.ts +43 -0
- package/src/components/inputs/Toggle/Toggle.tsx +80 -0
- package/src/components/inputs/Toggle/toggle.cva.ts +48 -0
- package/src/components/inputs/shared/CheckContent.tsx +26 -0
- package/src/components/inputs/shared/InputClear.tsx +29 -0
- package/src/components/inputs/shared/form.types.ts +28 -0
- package/src/components/inputs/shared/input.cva.ts +182 -0
- package/src/components/inputs/shared/label.cva.ts +146 -0
- package/src/components/outline.clsx.ts +9 -0
- package/src/components/overlays/ActionModal/ActionModal.tsx +93 -0
- package/src/components/overlays/BottomSheet/BottomSheet.tsx +270 -0
- package/src/components/overlays/Drawer/Drawer.tsx +93 -0
- package/src/components/overlays/Modal/Modal.tsx +63 -0
- package/src/components/overlays/Modal/modal.cva.ts +55 -0
- package/src/components/overlays/ResponsivePopover/ResponsivePopover.tsx +77 -0
- package/src/components/overlays/Tooltip/Tooltip.tsx +47 -0
- package/src/components/overlays/Tooltip/TooltipEllipsis.tsx +35 -0
- package/src/components/segment/Segment.tsx +121 -0
- package/src/components/segment/SegmentItem.tsx +41 -0
- package/src/components/segment/segment.types.ts +44 -0
- package/src/components/shared/pagination/Pagination.tsx +75 -0
- package/src/components/shared/pagination/PaginationList.tsx +174 -0
- package/src/components/shared/pagination/minWidth.cva.ts +13 -0
- package/src/components/status/Alert/Alert.tsx +58 -0
- package/src/components/status/Alert/alert.cva.ts +66 -0
- package/src/components/status/Loader/Loader.tsx +32 -0
- package/src/components/status/Loader/loader.cva.ts +29 -0
- package/src/components/status/Toast/Toast.tsx +86 -0
- package/src/components/status/Toast/toast.cva.ts +154 -0
- package/src/components/status/Toast/useToast.tsx +77 -0
- package/src/components/status/shared/status.cva.ts +60 -0
- package/src/components/table/CellText.tsx +23 -0
- package/src/components/table/ColumnConfig.tsx +145 -0
- package/src/components/table/HeaderText.tsx +18 -0
- package/src/components/table/InfiniteTable.tsx +51 -0
- package/src/components/table/PaginatedTable.tsx +38 -0
- package/src/components/table/Table.tsx +456 -0
- package/src/components/table/table.cva.ts +47 -0
- package/src/components/text/Link/Link.tsx +21 -0
- package/src/components/text/Link/link.cva.ts +21 -0
- package/src/components/text/Tag/Tag.tsx +59 -0
- package/src/components/text/Tag/tag.cva.ts +62 -0
- package/src/components/text/Typography/Typography.tsx +33 -0
- package/src/components/text/Typography/typography.cva.ts +102 -0
- package/src/config/confirmation.context.tsx +133 -0
- package/src/config/i18n.ts +12 -0
- package/src/config/router.context.tsx +66 -0
- package/src/config/uiConfig.context.tsx +89 -0
- package/src/config/uiStyle.context.tsx +100 -0
- package/src/helpers/dynamicColumns.ts +567 -0
- package/src/helpers/dynamicInputs.ts +392 -0
- package/src/hooks/useAutosave.ts +109 -0
- package/src/hooks/useBreakpoint.ts +26 -0
- package/src/hooks/useDebounceCallback.ts +35 -0
- package/src/hooks/useDeepCompare.ts +27 -0
- package/src/hooks/useFilters.ts +154 -0
- package/src/hooks/useForm.ts +54 -0
- package/src/hooks/useFormAutosave.ts +100 -0
- package/src/hooks/useIntersectionObserver.ts +33 -0
- package/src/hooks/useLocalStorage.ts +81 -0
- package/src/hooks/useLongPressRepeat.ts +40 -0
- package/src/hooks/usePagination.ts +41 -0
- package/src/hooks/useScrollableListBox.ts +35 -0
- package/src/hooks/useSingletonMutation.ts +30 -0
- package/src/hooks/useSorting.ts +39 -0
- package/src/hooks/useStateAndRef.ts +20 -0
- package/src/hooks/useTableColumnConfig.ts +86 -0
- package/src/hooks/useTableNav.ts +615 -0
- package/src/hooks/useTranslationMemo.ts +17 -0
- package/src/index.ts +252 -0
- package/src/types/{common.d.ts → common.ts} +15 -4
- package/src/types/i18next.d.ts +11 -0
- package/src/types/react-query.ts +48 -0
- package/src/types/table.d.ts +17 -0
- package/src/utils/array.utils.spec.ts +16 -0
- package/src/utils/array.utils.ts +9 -0
- package/src/utils/compoundMapper.spec.ts +91 -0
- package/src/utils/compoundMapper.ts +42 -0
- package/src/utils/date-time.utils.spec.ts +48 -0
- package/src/utils/date-time.utils.ts +85 -0
- package/src/utils/date.utils.spec.ts +12 -0
- package/src/utils/date.utils.ts +9 -0
- package/src/utils/dom.utils.ts +16 -0
- package/src/utils/file.utils.ts +73 -0
- package/src/utils/isEqual.ts +153 -0
- package/src/utils/logger.ts +19 -0
- package/src/utils/object.utils.ts +62 -0
- package/src/utils/queries.utils.ts +10 -0
- package/src/utils/rest/interceptors/logging.interceptor.ts +16 -0
- package/src/utils/rest/interceptors/response.interceptor.ts +27 -0
- package/src/utils/rest/interceptors/rest-interceptor.ts +22 -0
- package/src/utils/rest/rest-client.ts +125 -0
- package/src/utils/rest/rest.utils.ts +65 -0
- package/src/utils/routing.utils.ts +12 -0
- package/src/utils/string.utils.ts +9 -0
- package/src/utils/vendor/error-handling.ts +170 -0
- package/src/utils/zod.utils.ts +95 -0
- package/index.js +0 -61206
- package/povio-ui-0.0.2.tgz +0 -0
- package/src/assets/icons/AlignCenter.d.ts +0 -2
- package/src/assets/icons/AlignLeft.d.ts +0 -2
- package/src/assets/icons/AlignLeftRight.d.ts +0 -2
- package/src/assets/icons/AlignRight.d.ts +0 -2
- package/src/assets/icons/ArrowDropDown.d.ts +0 -2
- package/src/assets/icons/ArrowDropUp.d.ts +0 -2
- package/src/assets/icons/ArrowLeft.d.ts +0 -2
- package/src/assets/icons/ArrowRight.d.ts +0 -2
- package/src/assets/icons/Bold.d.ts +0 -2
- package/src/assets/icons/BulletedList.d.ts +0 -2
- package/src/assets/icons/Calendar.d.ts +0 -2
- package/src/assets/icons/Check.d.ts +0 -2
- package/src/assets/icons/CheckCircle.d.ts +0 -2
- package/src/assets/icons/CheckboxCheckmark.d.ts +0 -2
- package/src/assets/icons/CheckboxIndeterminate.d.ts +0 -2
- package/src/assets/icons/ChevronDown.d.ts +0 -2
- package/src/assets/icons/ChevronLeft.d.ts +0 -2
- package/src/assets/icons/ChevronRight.d.ts +0 -2
- package/src/assets/icons/ChevronUp.d.ts +0 -2
- package/src/assets/icons/ChevronsLeft.d.ts +0 -2
- package/src/assets/icons/ChevronsRight.d.ts +0 -2
- package/src/assets/icons/Clock.d.ts +0 -2
- package/src/assets/icons/Close.d.ts +0 -2
- package/src/assets/icons/DateTime.d.ts +0 -2
- package/src/assets/icons/Drag.d.ts +0 -2
- package/src/assets/icons/File.d.ts +0 -2
- package/src/assets/icons/Highlight.d.ts +0 -2
- package/src/assets/icons/HighlightOn.d.ts +0 -6
- package/src/assets/icons/Info.d.ts +0 -2
- package/src/assets/icons/Italic.d.ts +0 -2
- package/src/assets/icons/Link.d.ts +0 -2
- package/src/assets/icons/Menu.d.ts +0 -2
- package/src/assets/icons/NumberedList.d.ts +0 -2
- package/src/assets/icons/PointerHorizontal.d.ts +0 -2
- package/src/assets/icons/PointerVertical.d.ts +0 -2
- package/src/assets/icons/Send.d.ts +0 -2
- package/src/assets/icons/Strikethrough.d.ts +0 -2
- package/src/assets/icons/TextColor.d.ts +0 -6
- package/src/assets/icons/Today.d.ts +0 -2
- package/src/assets/icons/Underlined.d.ts +0 -2
- package/src/assets/icons/Upload.d.ts +0 -2
- package/src/assets/icons/View.d.ts +0 -2
- package/src/assets/icons/ViewOff.d.ts +0 -2
- package/src/assets/icons/Warningfilled.d.ts +0 -2
- package/src/components/Menu/Menu.d.ts +0 -14
- package/src/components/Menu/MenuDesktop.d.ts +0 -2
- package/src/components/Menu/MenuItem.d.ts +0 -5
- package/src/components/Menu/MenuMobile.d.ts +0 -2
- package/src/components/Menu/MenuPopover.d.ts +0 -5
- package/src/components/buttons/Button/Button.d.ts +0 -27
- package/src/components/buttons/Button/button.cva.d.ts +0 -30
- package/src/components/buttons/IconButton/IconButton.d.ts +0 -10
- package/src/components/buttons/InlineIconButton/InlineIconButton.d.ts +0 -11
- package/src/components/buttons/PillButton/PillButton.d.ts +0 -11
- package/src/components/buttons/PillButton/pillButton.cva.d.ts +0 -14
- package/src/components/buttons/SplitButton/SplitButton.d.ts +0 -10
- package/src/components/buttons/TextButton/TextButton.d.ts +0 -11
- package/src/components/buttons/ToggleButton/ToggleButton.d.ts +0 -9
- package/src/components/buttons/shared/ButtonContent.d.ts +0 -16
- package/src/components/buttons/shared/buttonContent.cva.d.ts +0 -6
- package/src/components/inputs/Checkbox/Checkbox.d.ts +0 -17
- package/src/components/inputs/Checkbox/CheckboxCheckmark.d.ts +0 -9
- package/src/components/inputs/Checkbox/checkbox.cva.d.ts +0 -11
- package/src/components/inputs/DateTime/DatePicker/DatePicker.d.ts +0 -24
- package/src/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +0 -32
- package/src/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +0 -22
- package/src/components/inputs/DateTime/TimePicker/TimePicker.d.ts +0 -20
- package/src/components/inputs/DateTime/shared/Calendar.d.ts +0 -20
- package/src/components/inputs/DateTime/shared/CalendarCell.d.ts +0 -20
- package/src/components/inputs/DateTime/shared/CalendarGrid.d.ts +0 -25
- package/src/components/inputs/DateTime/shared/CalendarHeader.d.ts +0 -16
- package/src/components/inputs/DateTime/shared/CalendarSelectHeader.d.ts +0 -17
- package/src/components/inputs/DateTime/shared/DateField.d.ts +0 -12
- package/src/components/inputs/DateTime/shared/DatePickerInput.d.ts +0 -20
- package/src/components/inputs/DateTime/shared/DateSegmentItem.d.ts +0 -11
- package/src/components/inputs/DateTime/shared/DateTimeDialog.d.ts +0 -15
- package/src/components/inputs/DateTime/shared/DateTimeDialogFooter.d.ts +0 -7
- package/src/components/inputs/DateTime/shared/MonthPicker.d.ts +0 -7
- package/src/components/inputs/DateTime/shared/RangeCalendar.d.ts +0 -26
- package/src/components/inputs/DateTime/shared/TimeField.d.ts +0 -12
- package/src/components/inputs/DateTime/shared/TimePickerForm.d.ts +0 -10
- package/src/components/inputs/DateTime/shared/TimePickerInput.d.ts +0 -18
- package/src/components/inputs/DateTime/shared/YearPicker.d.ts +0 -8
- package/src/components/inputs/File/FileUpload.d.ts +0 -4
- package/src/components/inputs/File/FileUploadContainer.d.ts +0 -3
- package/src/components/inputs/File/InputUpload.d.ts +0 -4
- package/src/components/inputs/File/fileUpload.types.d.ts +0 -79
- package/src/components/inputs/File/index.d.ts +0 -9
- package/src/components/inputs/File/inputUpload.types.d.ts +0 -30
- package/src/components/inputs/File/shared/FileCard.d.ts +0 -9
- package/src/components/inputs/File/shared/FileCardList.d.ts +0 -9
- package/src/components/inputs/File/shared/FileProgressBar.d.ts +0 -3
- package/src/components/inputs/File/shared/FileUploadContent.d.ts +0 -10
- package/src/components/inputs/File/shared/FileUploadContentEmpty.d.ts +0 -9
- package/src/components/inputs/File/shared/FileUploadContentError.d.ts +0 -11
- package/src/components/inputs/File/shared/FileUploadContentFilled.d.ts +0 -11
- package/src/components/inputs/File/shared/FileUploadContentLoading.d.ts +0 -9
- package/src/components/inputs/File/shared/InputUploadContent.d.ts +0 -8
- package/src/components/inputs/File/shared/InputUploadFilled.d.ts +0 -7
- package/src/components/inputs/File/shared/fileUpload.cva.d.ts +0 -11
- package/src/components/inputs/File/shared/inputUploadButton.cva.d.ts +0 -10
- package/src/components/inputs/FormField/FormField.d.ts +0 -17
- package/src/components/inputs/FormField/FormFieldError.d.ts +0 -7
- package/src/components/inputs/FormField/FormFieldHeader.d.ts +0 -14
- package/src/components/inputs/FormField/FormFieldHeaderClose.d.ts +0 -5
- package/src/components/inputs/FormField/FormFieldLabel.d.ts +0 -11
- package/src/components/inputs/Input/NumberInput/NumberInput.d.ts +0 -18
- package/src/components/inputs/Input/PasswordInput/PasswordInput.d.ts +0 -7
- package/src/components/inputs/Input/TextArea/TextArea.d.ts +0 -17
- package/src/components/inputs/Input/TextInput/TextInput.d.ts +0 -19
- package/src/components/inputs/Input/shared/InputContent.d.ts +0 -27
- package/src/components/inputs/Inputs/Form.d.ts +0 -26
- package/src/components/inputs/Inputs/InputItem.d.ts +0 -73
- package/src/components/inputs/Inputs/Inputs.d.ts +0 -10
- package/src/components/inputs/RadioGroup/RadioGroup.d.ts +0 -18
- package/src/components/inputs/RadioGroup/radio.cva.d.ts +0 -11
- package/src/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +0 -8
- package/src/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +0 -19
- package/src/components/inputs/Selection/Select/Select.d.ts +0 -8
- package/src/components/inputs/Selection/shared/SelectBase.d.ts +0 -24
- package/src/components/inputs/Selection/shared/SelectDesktop.d.ts +0 -5
- package/src/components/inputs/Selection/shared/SelectInput.d.ts +0 -15
- package/src/components/inputs/Selection/shared/SelectListBox.d.ts +0 -9
- package/src/components/inputs/Selection/shared/SelectListBoxItem.d.ts +0 -8
- package/src/components/inputs/Selection/shared/SelectListBoxItemSelectAll.d.ts +0 -4
- package/src/components/inputs/Selection/shared/SelectListBoxLoadingItem.d.ts +0 -6
- package/src/components/inputs/Selection/shared/SelectListBoxSelectionBar.d.ts +0 -5
- package/src/components/inputs/Selection/shared/SelectMobile.d.ts +0 -5
- package/src/components/inputs/Selection/shared/select.context.d.ts +0 -30
- package/src/components/inputs/Selection/shared/select.types.d.ts +0 -55
- package/src/components/inputs/Selection/shared/useSelectItems.d.ts +0 -23
- package/src/components/inputs/Slider/Slider.d.ts +0 -18
- package/src/components/inputs/TextEditor/TextEditor.d.ts +0 -20
- package/src/components/inputs/TextEditor/Toolbar/ColorPicker.d.ts +0 -7
- package/src/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.d.ts +0 -10
- package/src/components/inputs/TextEditor/Toolbar/HyperlinkAction.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextAlignSelect.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextColorSelect.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextEditorToolbar.d.ts +0 -6
- package/src/components/inputs/TextEditor/Toolbar/TextHighlightSelect.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextListActions.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextMarksActions.d.ts +0 -2
- package/src/components/inputs/TextEditor/Toolbar/TextStyleSelect.d.ts +0 -2
- package/src/components/inputs/TextEditor/textEditor.types.d.ts +0 -5
- package/src/components/inputs/Toggle/Toggle.d.ts +0 -14
- package/src/components/inputs/Toggle/toggle.cva.d.ts +0 -10
- package/src/components/inputs/shared/CheckContent.d.ts +0 -7
- package/src/components/inputs/shared/InputClear.d.ts +0 -6
- package/src/components/inputs/shared/form.types.d.ts +0 -12
- package/src/components/inputs/shared/input.cva.d.ts +0 -22
- package/src/components/inputs/shared/label.cva.d.ts +0 -10
- package/src/components/outline.clsx.d.ts +0 -2
- package/src/components/overlays/ActionModal/ActionModal.d.ts +0 -19
- package/src/components/overlays/BottomSheet/BottomSheet.d.ts +0 -21
- package/src/components/overlays/Drawer/Drawer.d.ts +0 -13
- package/src/components/overlays/Modal/Modal.d.ts +0 -11
- package/src/components/overlays/Modal/modal.cva.d.ts +0 -12
- package/src/components/overlays/ResponsivePopover/ResponsivePopover.d.ts +0 -10
- package/src/components/overlays/Tooltip/Tooltip.d.ts +0 -9
- package/src/components/overlays/Tooltip/TooltipEllipsis.d.ts +0 -7
- package/src/components/segment/Segment.d.ts +0 -4
- package/src/components/segment/SegmentItem.d.ts +0 -2
- package/src/components/segment/segment.types.d.ts +0 -34
- package/src/components/shared/pagination/Pagination.d.ts +0 -9
- package/src/components/shared/pagination/PaginationList.d.ts +0 -15
- package/src/components/shared/pagination/minWidth.cva.d.ts +0 -3
- package/src/components/status/Alert/Alert.d.ts +0 -11
- package/src/components/status/Alert/alert.cva.d.ts +0 -7
- package/src/components/status/Loader/Loader.d.ts +0 -5
- package/src/components/status/Loader/loader.cva.d.ts +0 -9
- package/src/components/status/Toast/Toast.d.ts +0 -14
- package/src/components/status/Toast/toast.cva.d.ts +0 -18
- package/src/components/status/Toast/useToast.d.ts +0 -12
- package/src/components/status/shared/status.cva.d.ts +0 -8
- package/src/components/table/CellText.d.ts +0 -7
- package/src/components/table/ColumnConfig.d.ts +0 -10
- package/src/components/table/HeaderText.d.ts +0 -5
- package/src/components/table/InfiniteTable.d.ts +0 -9
- package/src/components/table/PaginatedTable.d.ts +0 -11
- package/src/components/table/Table.d.ts +0 -37
- package/src/components/table/table.cva.d.ts +0 -15
- package/src/components/text/Link/Link.d.ts +0 -7
- package/src/components/text/Link/link.cva.d.ts +0 -6
- package/src/components/text/Tag/Tag.d.ts +0 -10
- package/src/components/text/Tag/tag.cva.d.ts +0 -6
- package/src/components/text/Typography/Typography.d.ts +0 -11
- package/src/components/text/Typography/typography.cva.d.ts +0 -8
- package/src/config/confirmation.context.d.ts +0 -20
- package/src/config/i18n.d.ts +0 -315
- package/src/config/router.context.d.ts +0 -20
- package/src/config/uiConfig.context.d.ts +0 -28
- package/src/config/uiStyle.context.d.ts +0 -84
- package/src/helpers/dynamicColumns.d.ts +0 -44
- package/src/helpers/dynamicInputs.d.ts +0 -83
- package/src/hooks/useAutosave.d.ts +0 -9
- package/src/hooks/useBreakpoint.d.ts +0 -3
- package/src/hooks/useDebounceCallback.d.ts +0 -6
- package/src/hooks/useDeepCompare.d.ts +0 -4
- package/src/hooks/useFilters.d.ts +0 -7
- package/src/hooks/useForm.d.ts +0 -18
- package/src/hooks/useFormAutosave.d.ts +0 -13
- package/src/hooks/useIntersectionObserver.d.ts +0 -7
- package/src/hooks/useLocalStorage.d.ts +0 -13
- package/src/hooks/useLongPressRepeat.d.ts +0 -9
- package/src/hooks/usePagination.d.ts +0 -7
- package/src/hooks/useScrollableListBox.d.ts +0 -3
- package/src/hooks/useSingletonMutation.d.ts +0 -2
- package/src/hooks/useSorting.d.ts +0 -6
- package/src/hooks/useStateAndRef.d.ts +0 -4
- package/src/hooks/useTableColumnConfig.d.ts +0 -16
- package/src/hooks/useTableNav.d.ts +0 -84
- package/src/hooks/useTranslationMemo.d.ts +0 -4
- package/src/index.d.ts +0 -205
- package/src/types/react-query.d.ts +0 -6
- package/src/utils/array.utils.d.ts +0 -3
- package/src/utils/array.utils.spec.d.ts +0 -1
- package/src/utils/compoundMapper.d.ts +0 -19
- package/src/utils/compoundMapper.spec.d.ts +0 -1
- package/src/utils/date-time.utils.d.ts +0 -14
- package/src/utils/date-time.utils.spec.d.ts +0 -1
- package/src/utils/date.utils.d.ts +0 -3
- package/src/utils/date.utils.spec.d.ts +0 -1
- package/src/utils/dom.utils.d.ts +0 -5
- package/src/utils/file.utils.d.ts +0 -9
- package/src/utils/isEqual.d.ts +0 -1
- package/src/utils/logger.d.ts +0 -7
- package/src/utils/object.utils.d.ts +0 -10
- package/src/utils/queries.utils.d.ts +0 -4
- package/src/utils/rest/interceptors/logging.interceptor.d.ts +0 -2
- package/src/utils/rest/interceptors/response.interceptor.d.ts +0 -2
- package/src/utils/rest/interceptors/rest-interceptor.d.ts +0 -8
- package/src/utils/rest/rest-client.d.ts +0 -29
- package/src/utils/rest/rest.utils.d.ts +0 -10
- package/src/utils/routing.utils.d.ts +0 -3
- package/src/utils/string.utils.d.ts +0 -4
- package/src/utils/vendor/error-handling.d.ts +0 -21
- package/src/utils/zod.utils.d.ts +0 -19
- package/vite.config.d.ts +0 -2
- /package/{styles → src/styles}/editor.css +0 -0
- /package/{styles → src/styles}/index.css +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useLabel } from "react-aria";
|
|
4
|
+
import {
|
|
5
|
+
DialogTrigger as AriaDialogTrigger,
|
|
6
|
+
type DialogTriggerProps as AriaDialogTriggerProps,
|
|
7
|
+
type Key,
|
|
8
|
+
} from "react-aria-components";
|
|
9
|
+
|
|
10
|
+
import { FormField, type FormFieldProps } from "#ui/components/inputs/FormField/FormField";
|
|
11
|
+
import { FormFieldHeader, type FormFieldHeaderProps } from "#ui/components/inputs/FormField/FormFieldHeader";
|
|
12
|
+
import { FormFieldHeaderClose } from "#ui/components/inputs/FormField/FormFieldHeaderClose";
|
|
13
|
+
import { TextInput } from "#ui/components/inputs/Input/TextInput/TextInput";
|
|
14
|
+
import type { SelectBaseProps } from "#ui/components/inputs/Selection/shared/SelectBase";
|
|
15
|
+
import { SelectInput } from "#ui/components/inputs/Selection/shared/SelectInput";
|
|
16
|
+
import { SelectListBox } from "#ui/components/inputs/Selection/shared/SelectListBox";
|
|
17
|
+
import { SelectListBoxSelectionBar } from "#ui/components/inputs/Selection/shared/SelectListBoxSelectionBar";
|
|
18
|
+
import { SelectContext } from "#ui/components/inputs/Selection/shared/select.context";
|
|
19
|
+
import { BottomSheet } from "#ui/components/overlays/BottomSheet/BottomSheet";
|
|
20
|
+
|
|
21
|
+
type SelectMobileProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
|
|
22
|
+
|
|
23
|
+
export const SelectMobile = <TKey extends Key = Key>({
|
|
24
|
+
ref,
|
|
25
|
+
error,
|
|
26
|
+
showSelectionContent,
|
|
27
|
+
inputClassName,
|
|
28
|
+
containerClassName,
|
|
29
|
+
customTrigger,
|
|
30
|
+
onBlur,
|
|
31
|
+
...props
|
|
32
|
+
}: SelectMobileProps<TKey>) => {
|
|
33
|
+
const {
|
|
34
|
+
label,
|
|
35
|
+
tooltipText,
|
|
36
|
+
helperText,
|
|
37
|
+
isRequired,
|
|
38
|
+
rightContent,
|
|
39
|
+
isHeaderHidden,
|
|
40
|
+
headerClassName,
|
|
41
|
+
errorClassName,
|
|
42
|
+
placeholder,
|
|
43
|
+
variant,
|
|
44
|
+
isDisabled,
|
|
45
|
+
className,
|
|
46
|
+
hideLabel,
|
|
47
|
+
hideDropdownIcon,
|
|
48
|
+
isSearchable,
|
|
49
|
+
isClearable,
|
|
50
|
+
as,
|
|
51
|
+
} = props;
|
|
52
|
+
|
|
53
|
+
const formFieldProps: FormFieldProps = {
|
|
54
|
+
error,
|
|
55
|
+
label,
|
|
56
|
+
tooltipText,
|
|
57
|
+
helperText,
|
|
58
|
+
isRequired,
|
|
59
|
+
rightContent,
|
|
60
|
+
isHeaderHidden: isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
61
|
+
hideLabel,
|
|
62
|
+
isDisabled,
|
|
63
|
+
headerClassName,
|
|
64
|
+
errorClassName,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const { labelProps, fieldProps } = useLabel({ label });
|
|
68
|
+
|
|
69
|
+
const headerProps: FormFieldHeaderProps = {
|
|
70
|
+
label,
|
|
71
|
+
tooltipText,
|
|
72
|
+
helperText,
|
|
73
|
+
isRequired,
|
|
74
|
+
rightContent,
|
|
75
|
+
isHeaderHidden: hideLabel || isHeaderHidden,
|
|
76
|
+
isDisabled,
|
|
77
|
+
className: headerClassName,
|
|
78
|
+
labelProps,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const { fieldState, isOpen, setIsOpen, onInputChange, isMultiple } = SelectContext.useSelect();
|
|
82
|
+
|
|
83
|
+
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
84
|
+
|
|
85
|
+
const dialogTriggerProps: Omit<AriaDialogTriggerProps, "children"> = {
|
|
86
|
+
isOpen,
|
|
87
|
+
onOpenChange: setIsOpen,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<FormField
|
|
92
|
+
{...formFieldProps}
|
|
93
|
+
as={as}
|
|
94
|
+
labelProps={labelProps}
|
|
95
|
+
className={clsx("w-full", containerClassName)}
|
|
96
|
+
>
|
|
97
|
+
<AriaDialogTrigger {...dialogTriggerProps}>
|
|
98
|
+
{customTrigger ? (
|
|
99
|
+
<div
|
|
100
|
+
{...fieldProps}
|
|
101
|
+
ref={ref}
|
|
102
|
+
>
|
|
103
|
+
{customTrigger}
|
|
104
|
+
</div>
|
|
105
|
+
) : (
|
|
106
|
+
<SelectInput
|
|
107
|
+
ref={ref}
|
|
108
|
+
placeholder={placeholder}
|
|
109
|
+
variant={variant}
|
|
110
|
+
as={as}
|
|
111
|
+
isDisabled={isDisabled}
|
|
112
|
+
isInvalid={!!error}
|
|
113
|
+
className={className}
|
|
114
|
+
hideDropdownIcon={hideDropdownIcon}
|
|
115
|
+
isSearchable={false}
|
|
116
|
+
isClearable={isClearable}
|
|
117
|
+
showSelectionContent={showSelectionContent}
|
|
118
|
+
onBlur={onBlur}
|
|
119
|
+
fieldProps={fieldProps}
|
|
120
|
+
headerProps={headerProps}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
<BottomSheet
|
|
125
|
+
isOpen={isOpen}
|
|
126
|
+
onOpenChange={setIsOpen}
|
|
127
|
+
onStateChange={(state) => {
|
|
128
|
+
if (state === "opened") {
|
|
129
|
+
searchInputRef.current?.focus();
|
|
130
|
+
}
|
|
131
|
+
}}
|
|
132
|
+
label={label}
|
|
133
|
+
footer={isMultiple && <SelectListBoxSelectionBar />}
|
|
134
|
+
isDismissable
|
|
135
|
+
>
|
|
136
|
+
{(close) => (
|
|
137
|
+
<div className="flex flex-col">
|
|
138
|
+
{isSearchable ? (
|
|
139
|
+
<TextInput
|
|
140
|
+
ref={searchInputRef}
|
|
141
|
+
label={label}
|
|
142
|
+
placeholder={placeholder}
|
|
143
|
+
value={fieldState.inputValue}
|
|
144
|
+
onChange={onInputChange}
|
|
145
|
+
rightContent={<FormFieldHeaderClose onClose={close} />}
|
|
146
|
+
inputClassName={inputClassName}
|
|
147
|
+
className="mb-1-5 px-4 pt-3"
|
|
148
|
+
/>
|
|
149
|
+
) : (
|
|
150
|
+
<FormFieldHeader
|
|
151
|
+
label={label}
|
|
152
|
+
rightContent={<FormFieldHeaderClose onClose={close} />}
|
|
153
|
+
className="!mb-1-5 px-4 pt-3"
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
<SelectListBox
|
|
158
|
+
{...props}
|
|
159
|
+
autoFocus={!isSearchable}
|
|
160
|
+
isScrollable={false}
|
|
161
|
+
onClose={close}
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
)}
|
|
165
|
+
</BottomSheet>
|
|
166
|
+
</AriaDialogTrigger>
|
|
167
|
+
</FormField>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { type PropsWithChildren, createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import type { Key } from "react-aria-components";
|
|
3
|
+
|
|
4
|
+
import type { SelectBaseProps } from "#ui/components/inputs/Selection/shared/SelectBase";
|
|
5
|
+
import type {
|
|
6
|
+
ExtendedSelectItem,
|
|
7
|
+
GroupedSelectProps,
|
|
8
|
+
SelectItem,
|
|
9
|
+
} from "#ui/components/inputs/Selection/shared/select.types";
|
|
10
|
+
import { NewItemId, useSelectItems } from "#ui/components/inputs/Selection/shared/useSelectItems";
|
|
11
|
+
import { useDebounceCallback } from "#ui/hooks/useDebounceCallback";
|
|
12
|
+
|
|
13
|
+
export namespace SelectContext {
|
|
14
|
+
interface FieldState {
|
|
15
|
+
value: Key | Key[] | null;
|
|
16
|
+
inputValue: string;
|
|
17
|
+
searchValue: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Type = {
|
|
21
|
+
fieldState: FieldState;
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
24
|
+
isDebouncing: boolean;
|
|
25
|
+
onChange: (val: Key | Key[]) => void;
|
|
26
|
+
onClear: () => void;
|
|
27
|
+
onSelectAll: () => void;
|
|
28
|
+
onRemove: (val: Key) => void;
|
|
29
|
+
listItems: ExtendedSelectItem[];
|
|
30
|
+
selectableListItems: SelectItem[];
|
|
31
|
+
selectedItems: SelectItem[];
|
|
32
|
+
selectedIds: Key[];
|
|
33
|
+
isMultiple: boolean;
|
|
34
|
+
} & Pick<SelectBaseProps, "onInputChange" | "isLoading" | "hasLoadMore">;
|
|
35
|
+
|
|
36
|
+
const Context = createContext<Type>({} as never);
|
|
37
|
+
|
|
38
|
+
const defaultMapInitialToSelectItem = (item: { id: Key; label?: string; name?: string }) =>
|
|
39
|
+
({
|
|
40
|
+
id: item.id,
|
|
41
|
+
label: item.label ?? item.name ?? "",
|
|
42
|
+
}) as SelectItem;
|
|
43
|
+
|
|
44
|
+
export type ProviderProps = GroupedSelectProps &
|
|
45
|
+
Pick<
|
|
46
|
+
SelectBaseProps,
|
|
47
|
+
| "items"
|
|
48
|
+
| "onInputChange"
|
|
49
|
+
| "onSearchChange"
|
|
50
|
+
| "showSelectAllOption"
|
|
51
|
+
| "showNewItemOption"
|
|
52
|
+
| "newItemMinLength"
|
|
53
|
+
| "onNewItemOption"
|
|
54
|
+
| "isLoading"
|
|
55
|
+
| "hasLoadMore"
|
|
56
|
+
| "mapInitialToSelectItem"
|
|
57
|
+
| "isSearchable"
|
|
58
|
+
| "isClientSearchDisabled"
|
|
59
|
+
>;
|
|
60
|
+
|
|
61
|
+
export const Provider = ({
|
|
62
|
+
items,
|
|
63
|
+
onInputChange,
|
|
64
|
+
onSearchChange,
|
|
65
|
+
showSelectAllOption,
|
|
66
|
+
showNewItemOption,
|
|
67
|
+
newItemMinLength,
|
|
68
|
+
onNewItemOption,
|
|
69
|
+
isLoading,
|
|
70
|
+
hasLoadMore,
|
|
71
|
+
isClientSearchDisabled,
|
|
72
|
+
children,
|
|
73
|
+
mapInitialToSelectItem = defaultMapInitialToSelectItem,
|
|
74
|
+
...props
|
|
75
|
+
}: PropsWithChildren<ProviderProps>) => {
|
|
76
|
+
const isMultiple = props.selectionMode === "multiple";
|
|
77
|
+
|
|
78
|
+
const initialSelectedItems = useMemo(() => {
|
|
79
|
+
if (!props.initialSelection) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(props.initialSelection)) {
|
|
83
|
+
return props.initialSelection.map(mapInitialToSelectItem);
|
|
84
|
+
}
|
|
85
|
+
return mapInitialToSelectItem(props.initialSelection);
|
|
86
|
+
}, [props.initialSelection, mapInitialToSelectItem]);
|
|
87
|
+
|
|
88
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
89
|
+
const [fieldState, setFieldState] = useState<FieldState>({
|
|
90
|
+
value: props.value ?? (isMultiple ? [] : null),
|
|
91
|
+
inputValue: "",
|
|
92
|
+
searchValue: "",
|
|
93
|
+
});
|
|
94
|
+
const { callback: onSearchChangeDebounced, isDebouncing } = useDebounceCallback(onSearchChange);
|
|
95
|
+
const [showAll, setShowAll] = useState(false);
|
|
96
|
+
const [cachedItems, setCachedItems] = useState<SelectItem[]>(items);
|
|
97
|
+
const valueRef = useRef(initialSelectedItems);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!isLoading) {
|
|
101
|
+
setCachedItems(items);
|
|
102
|
+
}
|
|
103
|
+
}, [isLoading, items]);
|
|
104
|
+
|
|
105
|
+
const { allItems, allListItems, listItems, selectableListItems } = useSelectItems({
|
|
106
|
+
initialSelectedItems,
|
|
107
|
+
selectedItems: valueRef.current,
|
|
108
|
+
cachedItems,
|
|
109
|
+
inputValue: fieldState.inputValue,
|
|
110
|
+
showAll,
|
|
111
|
+
isMultiple,
|
|
112
|
+
showSelectAllOption,
|
|
113
|
+
showNewItemOption,
|
|
114
|
+
newItemMinLength,
|
|
115
|
+
isLoading,
|
|
116
|
+
hasLoadMore,
|
|
117
|
+
isClientSearchDisabled,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const selectedItems = useMemo(
|
|
121
|
+
() =>
|
|
122
|
+
allItems.filter(({ id }) =>
|
|
123
|
+
Array.isArray(fieldState.value) ? fieldState.value.includes(id) : id === fieldState.value,
|
|
124
|
+
),
|
|
125
|
+
[allItems, fieldState.value],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const selectedIds = useMemo(() => selectedItems.map(({ id }) => id), [selectedItems]);
|
|
129
|
+
|
|
130
|
+
const getItem = useCallback(
|
|
131
|
+
(value: Key | null) => allItems.find((item) => item && item.id === value) ?? null,
|
|
132
|
+
[allItems],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const updateValue = useCallback(
|
|
136
|
+
(value: Key[] | Key | null) => {
|
|
137
|
+
if (Array.isArray(value)) {
|
|
138
|
+
valueRef.current = value.map((id) => getItem(id)).filter((item): item is SelectItem => item !== null);
|
|
139
|
+
} else {
|
|
140
|
+
valueRef.current = getItem(value);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[getItem],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const getValueIds = () =>
|
|
147
|
+
Array.isArray(valueRef.current) ? valueRef.current.map(({ id }) => id) : (valueRef.current?.id ?? null);
|
|
148
|
+
|
|
149
|
+
const emitStateChanges = useCallback(
|
|
150
|
+
(changes: FieldState, skipSelectionChange?: boolean) => {
|
|
151
|
+
const valueChanged = JSON.stringify(changes.value) !== JSON.stringify(getValueIds());
|
|
152
|
+
if (valueChanged) {
|
|
153
|
+
updateValue(changes.value);
|
|
154
|
+
|
|
155
|
+
if (!skipSelectionChange) {
|
|
156
|
+
if (isMultiple) {
|
|
157
|
+
props.onChange?.(changes.value as Key[]);
|
|
158
|
+
} else {
|
|
159
|
+
props.onChange?.(changes.value as Key);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (changes.inputValue !== fieldState.inputValue) {
|
|
164
|
+
onInputChange?.(changes.inputValue);
|
|
165
|
+
}
|
|
166
|
+
if (changes.searchValue !== fieldState.searchValue) {
|
|
167
|
+
onSearchChangeDebounced?.(changes.searchValue);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
[fieldState, isMultiple, props, onInputChange, onSearchChangeDebounced, updateValue],
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const syncFieldState = (value: Key | Key[] | null) => {
|
|
174
|
+
const newFieldState = {
|
|
175
|
+
value,
|
|
176
|
+
inputValue: isMultiple || Array.isArray(value) ? fieldState.inputValue : (getItem(value)?.label ?? ""),
|
|
177
|
+
searchValue: "",
|
|
178
|
+
};
|
|
179
|
+
setFieldState(newFieldState);
|
|
180
|
+
emitStateChanges(newFieldState, true);
|
|
181
|
+
if (!isMultiple) {
|
|
182
|
+
setShowAll(true);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
const value = props.value ?? null;
|
|
188
|
+
if (JSON.stringify(value) !== JSON.stringify(fieldState.value)) {
|
|
189
|
+
syncFieldState(value);
|
|
190
|
+
} else {
|
|
191
|
+
updateValue(value);
|
|
192
|
+
}
|
|
193
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
194
|
+
}, [props.value]);
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (!isMultiple && fieldState.value && fieldState.inputValue === "" && getItem(fieldState.value as Key)?.label) {
|
|
198
|
+
syncFieldState(fieldState.value);
|
|
199
|
+
}
|
|
200
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
201
|
+
}, [allListItems]);
|
|
202
|
+
|
|
203
|
+
const handleInputChange = useCallback(
|
|
204
|
+
(inputValue: string) => {
|
|
205
|
+
const newFieldState = {
|
|
206
|
+
value: isMultiple || inputValue !== "" ? fieldState.value : null,
|
|
207
|
+
inputValue,
|
|
208
|
+
searchValue: inputValue,
|
|
209
|
+
};
|
|
210
|
+
setFieldState(newFieldState);
|
|
211
|
+
emitStateChanges(newFieldState);
|
|
212
|
+
setShowAll(false);
|
|
213
|
+
if (!isOpen && inputValue !== "" && props.isSearchable) {
|
|
214
|
+
setIsOpen(true);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[emitStateChanges, fieldState.value, isMultiple],
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const onChange = useCallback(
|
|
221
|
+
(value: Key | Key[] | null) => {
|
|
222
|
+
if (value === NewItemId) {
|
|
223
|
+
onNewItemOption?.(fieldState.inputValue);
|
|
224
|
+
} else {
|
|
225
|
+
const newFieldState = {
|
|
226
|
+
value,
|
|
227
|
+
inputValue: isMultiple || Array.isArray(value) ? "" : (getItem(value)?.label ?? ""),
|
|
228
|
+
searchValue: "",
|
|
229
|
+
};
|
|
230
|
+
setFieldState(newFieldState);
|
|
231
|
+
emitStateChanges(newFieldState);
|
|
232
|
+
}
|
|
233
|
+
if (!isMultiple) {
|
|
234
|
+
setIsOpen(false);
|
|
235
|
+
setShowAll(true);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
[emitStateChanges, onNewItemOption, fieldState.inputValue, getItem, isMultiple],
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const onClear = useCallback(() => {
|
|
242
|
+
if (!valueRef.current || (Array.isArray(valueRef.current) && valueRef.current.length === 0)) {
|
|
243
|
+
setFieldState((prev) => ({
|
|
244
|
+
...prev,
|
|
245
|
+
inputValue: "",
|
|
246
|
+
}));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (isMultiple) {
|
|
251
|
+
onChange([]);
|
|
252
|
+
} else {
|
|
253
|
+
onChange(null);
|
|
254
|
+
}
|
|
255
|
+
}, [isMultiple, onChange]);
|
|
256
|
+
|
|
257
|
+
const onSelectAll = useCallback(() => {
|
|
258
|
+
onChange(selectableListItems.map(({ id }) => id));
|
|
259
|
+
}, [selectableListItems, onChange]);
|
|
260
|
+
|
|
261
|
+
const onRemove = useCallback(
|
|
262
|
+
(value: Key) => {
|
|
263
|
+
if (isMultiple && Array.isArray(fieldState.value)) {
|
|
264
|
+
onChange(fieldState.value.filter((id) => id !== value));
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
[isMultiple, fieldState.value, onChange],
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const value = useMemo(
|
|
271
|
+
(): Type => ({
|
|
272
|
+
fieldState,
|
|
273
|
+
isOpen,
|
|
274
|
+
setIsOpen,
|
|
275
|
+
isDebouncing,
|
|
276
|
+
onInputChange: handleInputChange,
|
|
277
|
+
onChange,
|
|
278
|
+
onClear,
|
|
279
|
+
onSelectAll,
|
|
280
|
+
onRemove,
|
|
281
|
+
listItems,
|
|
282
|
+
selectableListItems,
|
|
283
|
+
selectedItems,
|
|
284
|
+
selectedIds,
|
|
285
|
+
isMultiple,
|
|
286
|
+
isLoading,
|
|
287
|
+
hasLoadMore,
|
|
288
|
+
}),
|
|
289
|
+
[
|
|
290
|
+
fieldState,
|
|
291
|
+
isOpen,
|
|
292
|
+
setIsOpen,
|
|
293
|
+
isDebouncing,
|
|
294
|
+
handleInputChange,
|
|
295
|
+
onChange,
|
|
296
|
+
onClear,
|
|
297
|
+
onSelectAll,
|
|
298
|
+
onRemove,
|
|
299
|
+
listItems,
|
|
300
|
+
selectableListItems,
|
|
301
|
+
selectedIds,
|
|
302
|
+
selectedItems,
|
|
303
|
+
isMultiple,
|
|
304
|
+
isLoading,
|
|
305
|
+
hasLoadMore,
|
|
306
|
+
],
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
return <Context.Provider value={value}>{children}</Context.Provider>;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export const useSelect = () => {
|
|
313
|
+
const select = use(Context);
|
|
314
|
+
return select;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { Key } from "react-aria-components";
|
|
3
|
+
import type { FieldValues } from "react-hook-form";
|
|
4
|
+
|
|
5
|
+
import type { ControlProps } from "#ui/components/inputs/shared/form.types";
|
|
6
|
+
|
|
7
|
+
export interface SelectItem<TKey extends Key = Key> {
|
|
8
|
+
id: TKey;
|
|
9
|
+
label: string;
|
|
10
|
+
content?: string | ReactElement;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ExtendedSelectItem<TKey extends Key = Key> extends SelectItem<TKey> {
|
|
15
|
+
isNewItem?: boolean;
|
|
16
|
+
isSelectAllItem?: boolean;
|
|
17
|
+
isLoadingItem?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DefaultInitialSelectItem<TKey extends Key = Key> {
|
|
21
|
+
id: TKey;
|
|
22
|
+
label?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SingleSelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> {
|
|
27
|
+
selectionMode?: "single";
|
|
28
|
+
value?: TKey | undefined | null;
|
|
29
|
+
onChange?: (value: TKey | null) => void;
|
|
30
|
+
showSelectionBar?: never;
|
|
31
|
+
showSelectAllOption?: never;
|
|
32
|
+
initialSelection?: TInitialSelectItem | null;
|
|
33
|
+
showSelectionContent?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface MultiSelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> {
|
|
37
|
+
selectionMode: "multiple";
|
|
38
|
+
value?: TKey[];
|
|
39
|
+
onChange?: (value: TKey[]) => void;
|
|
40
|
+
showSelectionBar?: boolean;
|
|
41
|
+
showSelectAllOption?: boolean;
|
|
42
|
+
initialSelection?: TInitialSelectItem[] | null;
|
|
43
|
+
showSelectionContent?: never;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type GroupedSelectProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> =
|
|
47
|
+
| MultiSelectProps<TKey, TInitialSelectItem>
|
|
48
|
+
| SingleSelectProps<TKey, TInitialSelectItem>;
|
|
49
|
+
|
|
50
|
+
export type GroupedSelectControlProps<
|
|
51
|
+
TFieldValues extends FieldValues,
|
|
52
|
+
TKey extends Key = Key,
|
|
53
|
+
TInitialSelectItem = DefaultInitialSelectItem<TKey>,
|
|
54
|
+
> =
|
|
55
|
+
| ({ selectionMode: MultiSelectProps["selectionMode"] } & ControlProps<
|
|
56
|
+
MultiSelectProps<TKey, TInitialSelectItem>,
|
|
57
|
+
TFieldValues
|
|
58
|
+
>)
|
|
59
|
+
| ({ selectionMode?: SingleSelectProps["selectionMode"] } & ControlProps<
|
|
60
|
+
SingleSelectProps<TKey, TInitialSelectItem>,
|
|
61
|
+
TFieldValues
|
|
62
|
+
>);
|
|
63
|
+
|
|
64
|
+
export interface SelectNewItemProps {
|
|
65
|
+
showNewItemOption?: boolean;
|
|
66
|
+
newItemMinLength?: number;
|
|
67
|
+
onNewItemOption?: (value: string) => void;
|
|
68
|
+
newItemRender?: (label: string) => ReactElement;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface SelectAsyncProps {
|
|
72
|
+
isLoading?: boolean;
|
|
73
|
+
hasLoadMore?: boolean;
|
|
74
|
+
onLoadMore?: () => void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { type Key, useFilter } from "react-aria-components";
|
|
3
|
+
|
|
4
|
+
import type { SelectBaseProps } from "#ui/components/inputs/Selection/shared/SelectBase";
|
|
5
|
+
import type { ExtendedSelectItem, SelectItem } from "#ui/components/inputs/Selection/shared/select.types";
|
|
6
|
+
|
|
7
|
+
export const SelectAllItemId = "all-item-id";
|
|
8
|
+
const SelectAllItem = (inputValue: string) => ({
|
|
9
|
+
id: SelectAllItemId,
|
|
10
|
+
label: inputValue,
|
|
11
|
+
isSelectAllItem: true,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const NewItemId = "new-item-id";
|
|
15
|
+
const NewItem = (inputValue: string) => ({
|
|
16
|
+
id: NewItemId,
|
|
17
|
+
label: inputValue,
|
|
18
|
+
isNewItem: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const LoadingItemId = "loading-item-id";
|
|
22
|
+
const LoadingItem = (inputValue: string) => ({
|
|
23
|
+
id: LoadingItemId,
|
|
24
|
+
label: inputValue,
|
|
25
|
+
isLoadingItem: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const ReservedItemIds = [SelectAllItemId, NewItemId, LoadingItemId];
|
|
29
|
+
|
|
30
|
+
interface UseSelectItemsProps
|
|
31
|
+
extends Pick<
|
|
32
|
+
SelectBaseProps,
|
|
33
|
+
| "showSelectAllOption"
|
|
34
|
+
| "showNewItemOption"
|
|
35
|
+
| "newItemMinLength"
|
|
36
|
+
| "isLoading"
|
|
37
|
+
| "hasLoadMore"
|
|
38
|
+
| "isClientSearchDisabled"
|
|
39
|
+
> {
|
|
40
|
+
initialSelectedItems?: SelectItem[] | SelectItem | null;
|
|
41
|
+
selectedItems?: SelectItem[] | SelectItem | null;
|
|
42
|
+
cachedItems: SelectItem[];
|
|
43
|
+
inputValue: string;
|
|
44
|
+
showAll: boolean;
|
|
45
|
+
isMultiple: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useSelectItems({
|
|
49
|
+
initialSelectedItems,
|
|
50
|
+
selectedItems,
|
|
51
|
+
cachedItems,
|
|
52
|
+
inputValue,
|
|
53
|
+
showAll,
|
|
54
|
+
isMultiple,
|
|
55
|
+
showSelectAllOption,
|
|
56
|
+
showNewItemOption,
|
|
57
|
+
newItemMinLength = 3,
|
|
58
|
+
isLoading,
|
|
59
|
+
hasLoadMore,
|
|
60
|
+
isClientSearchDisabled,
|
|
61
|
+
}: UseSelectItemsProps) {
|
|
62
|
+
// oxlint-disable-next-line @typescript-eslint/unbound-method
|
|
63
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
64
|
+
|
|
65
|
+
const allListItems: ExtendedSelectItem[] = useMemo(() => {
|
|
66
|
+
const showSelectAllItem = isMultiple && showSelectAllOption && inputValue.length === 0 && !hasLoadMore;
|
|
67
|
+
|
|
68
|
+
const showNewItem =
|
|
69
|
+
showNewItemOption &&
|
|
70
|
+
inputValue.length >= newItemMinLength &&
|
|
71
|
+
!cachedItems.find((item) => contains(item.label, inputValue));
|
|
72
|
+
|
|
73
|
+
const showLoadingItem = isLoading || hasLoadMore;
|
|
74
|
+
|
|
75
|
+
return [
|
|
76
|
+
...(showSelectAllItem ? [SelectAllItem(inputValue)] : []),
|
|
77
|
+
...cachedItems,
|
|
78
|
+
...(showNewItem ? [NewItem(inputValue)] : []),
|
|
79
|
+
...(showLoadingItem ? [LoadingItem(inputValue)] : []),
|
|
80
|
+
];
|
|
81
|
+
}, [
|
|
82
|
+
isMultiple,
|
|
83
|
+
showNewItemOption,
|
|
84
|
+
inputValue,
|
|
85
|
+
newItemMinLength,
|
|
86
|
+
cachedItems,
|
|
87
|
+
contains,
|
|
88
|
+
isLoading,
|
|
89
|
+
hasLoadMore,
|
|
90
|
+
showSelectAllOption,
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const allItems = useMemo(() => {
|
|
94
|
+
const items = [
|
|
95
|
+
...(Array.isArray(initialSelectedItems) ? initialSelectedItems : [initialSelectedItems]),
|
|
96
|
+
...(Array.isArray(selectedItems) ? selectedItems : [selectedItems]),
|
|
97
|
+
...allListItems,
|
|
98
|
+
].filter((item): item is SelectItem => !!item);
|
|
99
|
+
|
|
100
|
+
const allItemsMap = new Map<Key, SelectItem>();
|
|
101
|
+
items.forEach((item) => allItemsMap.set(item.id, item));
|
|
102
|
+
return Array.from(allItemsMap.values());
|
|
103
|
+
}, [allListItems, initialSelectedItems, selectedItems]);
|
|
104
|
+
|
|
105
|
+
const filteredListItems = useMemo(
|
|
106
|
+
() => allListItems.filter((item) => contains(item.label, inputValue)),
|
|
107
|
+
[allListItems, contains, inputValue],
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const listItems = useMemo(
|
|
111
|
+
() => (showAll || isClientSearchDisabled ? allListItems : filteredListItems),
|
|
112
|
+
[showAll, isClientSearchDisabled, allListItems, filteredListItems],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const selectableListItems = useMemo(
|
|
116
|
+
() => listItems.filter((item) => !item.isDisabled && !ReservedItemIds.includes(String(item.id))),
|
|
117
|
+
[listItems],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
allItems,
|
|
122
|
+
allListItems,
|
|
123
|
+
filteredListItems,
|
|
124
|
+
listItems,
|
|
125
|
+
selectableListItems,
|
|
126
|
+
};
|
|
127
|
+
}
|