@povio/ui 2.3.3 → 3.0.0-rc.2
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/assets/icons/AlignCenter.js +26 -11
- package/dist/assets/icons/AlignLeft.js +26 -11
- package/dist/assets/icons/AlignLeftRight.js +26 -11
- package/dist/assets/icons/AlignRight.js +26 -11
- package/dist/assets/icons/ArrowDropDown.js +26 -11
- package/dist/assets/icons/ArrowDropUp.js +26 -11
- package/dist/assets/icons/ArrowLeft.js +26 -11
- package/dist/assets/icons/ArrowRight.js +26 -11
- package/dist/assets/icons/Bold.js +26 -11
- package/dist/assets/icons/BulletedList.js +26 -11
- package/dist/assets/icons/Calendar.js +28 -13
- package/dist/assets/icons/Check.js +28 -13
- package/dist/assets/icons/CheckCircle.js +26 -11
- package/dist/assets/icons/CheckboxCheckmark.js +29 -14
- package/dist/assets/icons/CheckboxIndeterminate.js +29 -14
- package/dist/assets/icons/ChevronDown.js +28 -13
- package/dist/assets/icons/ChevronLeft.js +28 -13
- package/dist/assets/icons/ChevronRight.js +28 -13
- package/dist/assets/icons/ChevronUp.js +28 -13
- package/dist/assets/icons/ChevronsLeft.js +28 -13
- package/dist/assets/icons/ChevronsRight.js +28 -13
- package/dist/assets/icons/Clock.js +26 -11
- package/dist/assets/icons/Close.js +26 -11
- package/dist/assets/icons/DateTime.js +35 -14
- package/dist/assets/icons/DragIndicator.js +26 -11
- package/dist/assets/icons/File.js +28 -13
- package/dist/assets/icons/Highlight.js +26 -11
- package/dist/assets/icons/HighlightOn.js +49 -15
- package/dist/assets/icons/Home.js +26 -11
- package/dist/assets/icons/Info.js +37 -16
- package/dist/assets/icons/Italic.js +26 -11
- package/dist/assets/icons/Link.js +26 -11
- package/dist/assets/icons/Menu.js +26 -11
- package/dist/assets/icons/NumberedList.js +26 -11
- package/dist/assets/icons/PointerHorizontal.js +26 -11
- package/dist/assets/icons/PointerVertical.js +26 -11
- package/dist/assets/icons/Search.js +26 -11
- package/dist/assets/icons/Send.js +28 -13
- package/dist/assets/icons/Strikethrough.js +26 -11
- package/dist/assets/icons/TextColor.js +48 -14
- package/dist/assets/icons/Today.js +26 -11
- package/dist/assets/icons/Underlined.js +28 -13
- package/dist/assets/icons/Upload.js +35 -14
- package/dist/assets/icons/Visibility.js +26 -11
- package/dist/assets/icons/VisibilityOff.js +26 -11
- package/dist/assets/icons/WarningFilled.js +28 -13
- package/dist/components/Breadcrumbs/Breadcrumbs.js +215 -64
- package/dist/components/Breadcrumbs/breadcrumbs.cva.d.ts +40 -14
- package/dist/components/Breadcrumbs/breadcrumbs.cva.js +21 -18
- package/dist/components/Menu/Menu.js +18 -2
- package/dist/components/Menu/MenuDesktop.js +41 -7
- package/dist/components/Menu/MenuItem.js +35 -12
- package/dist/components/Menu/MenuMobile.js +103 -44
- package/dist/components/Menu/MenuPopover.js +110 -34
- package/dist/components/Menu/menu.cva.d.ts +35 -13
- package/dist/components/Menu/menu.cva.js +30 -24
- package/dist/components/buttons/Button/Button.js +7 -7
- package/dist/components/buttons/Button/button.cva.d.ts +95 -26
- package/dist/components/buttons/Button/button.cva.js +601 -589
- package/dist/components/buttons/IconButton/IconButton.js +40 -8
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +34 -9
- package/dist/components/buttons/PillButton/PillButton.js +59 -21
- package/dist/components/buttons/PillButton/pillButton.cva.d.ts +33 -9
- package/dist/components/buttons/PillButton/pillButton.cva.js +247 -239
- package/dist/components/buttons/SplitButton/SplitButton.js +103 -18
- package/dist/components/buttons/TextButton/TextButton.js +30 -8
- package/dist/components/buttons/ToggleButton/ToggleButton.js +28 -8
- package/dist/components/buttons/shared/ButtonContent.js +83 -25
- package/dist/components/buttons/shared/buttonContent.cva.d.ts +3 -5
- package/dist/components/buttons/shared/buttonContent.cva.js +1 -8
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/inputs/Checkbox/Checkbox.js +203 -37
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +28 -14
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +26 -10
- package/dist/components/inputs/Checkbox/checkbox.cva.js +47 -40
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +12 -5
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +373 -75
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +12 -5
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +492 -186
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +13 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +273 -47
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +7 -3
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +611 -121
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +338 -119
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +4 -2
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +310 -103
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +4 -2
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +150 -33
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +249 -93
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +318 -137
- package/dist/components/inputs/DateTime/shared/DateField.js +286 -112
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +13 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +358 -133
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +15 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +96 -11
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +84 -30
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +59 -10
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +103 -58
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +193 -82
- package/dist/components/inputs/DateTime/shared/TimeField.js +27 -8
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +279 -110
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +4 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +214 -69
- package/dist/components/inputs/DateTime/shared/YearPicker.js +119 -68
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +5 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +27 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +15 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +15 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +32 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +40 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +85 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +1 -0
- package/dist/components/inputs/File/FileUpload.js +87 -44
- package/dist/components/inputs/File/FileUploadContainer.js +15 -7
- package/dist/components/inputs/File/InputUpload.js +317 -79
- package/dist/components/inputs/File/shared/FileCard.js +104 -41
- package/dist/components/inputs/File/shared/FileCardList.js +47 -12
- package/dist/components/inputs/File/shared/FileUploadContent.js +175 -44
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +149 -46
- package/dist/components/inputs/File/shared/FileUploadContentError.js +234 -93
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +230 -97
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +199 -55
- package/dist/components/inputs/File/shared/InputUploadContent.js +151 -37
- package/dist/components/inputs/File/shared/InputUploadFilled.js +51 -10
- package/dist/components/inputs/File/shared/ProgressBar.js +48 -9
- package/dist/components/inputs/File/shared/fileUpload.cva.d.ts +26 -9
- package/dist/components/inputs/File/shared/fileUpload.cva.js +48 -40
- package/dist/components/inputs/File/shared/inputUploadButton.cva.d.ts +23 -6
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +29 -20
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormField.js +119 -37
- package/dist/components/inputs/FormField/FormFieldError.js +27 -7
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +81 -22
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +31 -7
- package/dist/components/inputs/FormField/FormFieldHelper.js +28 -8
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.js +46 -15
- package/dist/components/inputs/FormField/formFieldError.cva.d.ts +12 -5
- package/dist/components/inputs/FormField/formFieldError.cva.js +11 -8
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +22 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +13 -0
- package/dist/components/inputs/FormField/formFieldHelper.cva.d.ts +12 -5
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +11 -8
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +450 -100
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +571 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +575 -0
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +48 -9
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +12 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +309 -94
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +422 -93
- package/dist/components/inputs/Input/shared/InputContent.js +196 -63
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/Form.js +40 -11
- package/dist/components/inputs/Inputs/InputItem.d.ts +15 -21
- package/dist/components/inputs/Inputs/InputItem.js +69 -14
- package/dist/components/inputs/Inputs/Inputs.js +37 -11
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +3 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +356 -64
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +101 -6
- package/dist/components/inputs/RadioGroup/radio.cva.js +74 -24
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +214 -22
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +107 -8
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +37 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +14 -0
- package/dist/components/inputs/Selection/Select/QuerySelect.js +178 -0
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +225 -18
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +8 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +69 -18
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +396 -141
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +398 -119
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +99 -25
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +164 -52
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +88 -38
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +72 -19
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +73 -24
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +58 -9
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +9 -3
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +9 -0
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +47 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +14 -0
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +43 -0
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +67 -36
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +10 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +4 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +5 -0
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/selectItem.cva.d.ts +16 -6
- package/dist/components/inputs/Selection/shared/selectItem.cva.js +21 -18
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/useSelectItems.js +109 -49
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +82 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +548 -0
- package/dist/components/inputs/Slider/Slider.d.ts +2 -1
- package/dist/components/inputs/Slider/Slider.js +265 -76
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +450 -101
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +37 -11
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +105 -33
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +194 -45
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +88 -28
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +48 -14
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +66 -19
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +49 -15
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +92 -32
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +126 -54
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +141 -38
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -0
- package/dist/components/inputs/Toggle/Toggle.js +217 -40
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +15 -6
- package/dist/components/inputs/Toggle/toggle.cva.js +25 -21
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +23 -13
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +88 -12
- package/dist/components/inputs/shared/TooltipWrapper.js +50 -11
- package/dist/components/inputs/shared/input.cva.d.ts +137 -16
- package/dist/components/inputs/shared/input.cva.js +317 -273
- package/dist/components/inputs/shared/label.cva.d.ts +15 -6
- package/dist/components/inputs/shared/label.cva.js +28 -25
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +12 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +4 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +14 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +100 -0
- package/dist/components/navigation/Accordion/Accordion.js +71 -24
- package/dist/components/navigation/Accordion/AccordionItem.js +97 -52
- package/dist/components/navigation/Accordion/accordion.cva.d.ts +109 -44
- package/dist/components/navigation/Accordion/accordion.cva.js +114 -84
- package/dist/components/navigation/Stepper/Stepper.js +69 -24
- package/dist/components/navigation/Stepper/StepperItem.js +112 -39
- package/dist/components/navigation/Stepper/StepperSeparator.js +25 -7
- package/dist/components/navigation/Stepper/stepper.cva.d.ts +86 -30
- package/dist/components/navigation/Stepper/stepper.cva.js +104 -83
- package/dist/components/overlays/ActionModal/ActionModal.js +169 -35
- package/dist/components/overlays/BottomSheet/BottomSheet.js +96 -23
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +48 -8
- package/dist/components/overlays/Drawer/Drawer.js +62 -20
- package/dist/components/overlays/Modal/Modal.js +5 -5
- package/dist/components/overlays/Modal/modal.cva.d.ts +34 -9
- package/dist/components/overlays/Modal/modal.cva.js +38 -27
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +86 -30
- package/dist/components/overlays/Tooltip/Tooltip.js +143 -34
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +37 -12
- package/dist/components/overlays/Tooltip/tooltip.cva.d.ts +45 -17
- package/dist/components/overlays/Tooltip/tooltip.cva.js +38 -26
- package/dist/components/segment/Segment.js +221 -60
- package/dist/components/segment/SegmentItem.js +70 -13
- package/dist/components/segment/segment.cva.d.ts +18 -7
- package/dist/components/segment/segment.cva.js +24 -21
- package/dist/components/shared/pagination/Pagination.js +108 -22
- package/dist/components/shared/pagination/PaginationList.js +167 -64
- package/dist/components/shared/popover.cva.d.ts +7 -3
- package/dist/components/shared/popover.cva.js +3 -3
- package/dist/components/status/Alert/Alert.js +103 -36
- package/dist/components/status/Alert/alert.cva.d.ts +18 -6
- package/dist/components/status/Alert/alert.cva.js +60 -57
- package/dist/components/status/Loader/Loader.js +77 -22
- package/dist/components/status/Loader/loader.cva.d.ts +23 -4
- package/dist/components/status/Loader/loader.cva.js +22 -13
- package/dist/components/status/Toast/Toast.js +27 -20
- package/dist/components/status/Toast/toast.cva.d.ts +61 -10
- package/dist/components/status/Toast/toast.cva.js +129 -64
- package/dist/components/status/Toast/useToast.js +62 -57
- package/dist/components/status/shared/status.cva.d.ts +30 -8
- package/dist/components/status/shared/status.cva.js +56 -50
- package/dist/components/table/CellText.js +3 -3
- package/dist/components/table/ColumnConfig.js +158 -54
- package/dist/components/table/HeaderText.js +3 -3
- package/dist/components/table/InfiniteTable.js +67 -16
- package/dist/components/table/PaginatedTable.js +84 -18
- package/dist/components/table/Table.js +34 -33
- package/dist/components/table/table.cva.d.ts +52 -19
- package/dist/components/table/table.cva.js +44 -35
- package/dist/components/text/Link/Link.js +22 -10
- package/dist/components/text/Link/link.cva.d.ts +11 -5
- package/dist/components/text/Link/link.cva.js +8 -5
- package/dist/components/text/Tag/Tag.js +3 -3
- package/dist/components/text/Tag/tag.cva.d.ts +15 -5
- package/dist/components/text/Tag/tag.cva.js +51 -48
- package/dist/components/text/Typography/Typography.js +25 -10
- package/dist/components/text/Typography/typography.cva.d.ts +93 -7
- package/dist/components/text/Typography/typography.cva.js +126 -122
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +23 -9
- package/dist/config/router.context.js +42 -16
- package/dist/config/theme.context.js +98 -45
- package/dist/config/uiConfig.context.d.ts +20 -6
- package/dist/config/uiConfig.context.js +68 -14
- package/dist/config/uiOverrides.context.d.ts +192 -0
- package/dist/config/uiOverrides.context.js +113 -0
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +3 -0
- package/dist/hooks/useAutosave.d.ts +2 -1
- package/dist/hooks/useAutosave.js +12 -4
- package/dist/hooks/useAutosave.spec.d.ts +1 -0
- package/dist/hooks/useBreakpoint.js +16 -3
- package/dist/hooks/useDebounceCallback.js +51 -17
- package/dist/hooks/useFilters.js +125 -64
- package/dist/hooks/useForm.js +42 -8
- package/dist/hooks/useFormAutosave.d.ts +3 -1
- package/dist/hooks/useFormAutosave.js +122 -30
- package/dist/hooks/useFormAutosave.spec.d.ts +1 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +91 -24
- package/dist/hooks/useKeyInteractions.d.ts +20 -0
- package/dist/hooks/useKeyInteractions.js +54 -0
- package/dist/hooks/useKeyInteractions.spec.d.ts +1 -0
- package/dist/hooks/useLocalStorage.js +43 -10
- package/dist/hooks/useLongPressRepeat.js +55 -20
- package/dist/hooks/usePagination.js +49 -19
- package/dist/hooks/useQueryAutocomplete.d.ts +14 -0
- package/dist/hooks/useQueryAutocomplete.js +72 -0
- package/dist/hooks/useScrollableListBox.js +37 -16
- package/dist/hooks/useSorting.js +69 -28
- package/dist/hooks/useStateAndRef.js +21 -7
- package/dist/hooks/useTableColumnConfig.js +124 -31
- package/dist/hooks/useTranslationMemo.js +25 -5
- package/dist/index.d.ts +37 -1
- package/dist/index.js +34 -3
- package/dist/tw-ui-plugin.js +6 -0
- package/dist/utils/date-time.utils.d.ts +38 -10
- package/dist/utils/date-time.utils.js +136 -22
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/dist/utils/style-merge.util.d.ts +43 -0
- package/dist/utils/style-merge.util.js +233 -0
- package/dist/utils/style-merge.util.spec.d.ts +1 -0
- package/package.json +1 -1
- package/dist/config/uiStyle.context.d.ts +0 -162
- package/dist/config/uiStyle.context.js +0 -30
|
@@ -1,33 +1,137 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime, fromDate, getLocalTimeZone, parseAbsolute } from "@internationalized/date";
|
|
1
|
+
import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute } from "@internationalized/date";
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
//#region src/utils/date-time.utils.ts
|
|
4
4
|
var DateTimeUtils;
|
|
5
5
|
(function(_DateTimeUtils) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
|
|
7
|
+
const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 6, 45));
|
|
8
|
+
const getDayMonthFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
9
|
+
const getTimeHourFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
10
|
+
const getDatePlaceholderFormatter = (locale, options) => new Intl.DateTimeFormat(locale, {
|
|
11
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
12
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
13
|
+
year: "numeric"
|
|
14
|
+
});
|
|
15
|
+
const getTimePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
|
|
16
|
+
hour: "2-digit",
|
|
17
|
+
minute: "2-digit"
|
|
18
|
+
});
|
|
19
|
+
const getResolvedLocale = (locale) => {
|
|
20
|
+
if (locale) return locale;
|
|
21
|
+
return new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
22
|
+
};
|
|
23
|
+
const getDateFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
|
|
24
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
25
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
26
|
+
year: "numeric",
|
|
27
|
+
timeZone: "UTC"
|
|
28
|
+
});
|
|
29
|
+
const getTimeFormatter = (locale, options) => new DateFormatter(getResolvedLocale(locale), {
|
|
30
|
+
hour: getTimeHourFormat(options?.shouldForceLeadingZeros),
|
|
31
|
+
minute: "2-digit",
|
|
32
|
+
timeZone: "UTC"
|
|
33
|
+
});
|
|
34
|
+
const getDateTimeFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
|
|
35
|
+
day: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
36
|
+
month: getDayMonthFormat(options?.shouldForceLeadingZeros),
|
|
37
|
+
year: "numeric",
|
|
38
|
+
hour: getTimeHourFormat(options?.shouldForceLeadingZeros),
|
|
39
|
+
minute: "2-digit",
|
|
40
|
+
timeZone: "UTC"
|
|
41
|
+
});
|
|
42
|
+
const getLocaleDateFormat = (locale) => {
|
|
43
|
+
const sampleDate = new Date(Date.UTC(2e3, 10, 22));
|
|
44
|
+
return new Intl.DateTimeFormat(locale, {
|
|
8
45
|
day: "2-digit",
|
|
9
46
|
month: "2-digit",
|
|
10
|
-
year: "numeric"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (part.type === "
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
47
|
+
year: "numeric",
|
|
48
|
+
timeZone: "UTC"
|
|
49
|
+
}).formatToParts(sampleDate).map((part) => {
|
|
50
|
+
if (part.type === "day") return "dd";
|
|
51
|
+
if (part.type === "month") return "MM";
|
|
52
|
+
if (part.type === "year") return "yyyy";
|
|
53
|
+
return part.value;
|
|
54
|
+
}).join("");
|
|
55
|
+
};
|
|
56
|
+
const repeatLocalizedFieldLabel = (type, length, locale) => {
|
|
57
|
+
const placeholderChar = new Intl.DisplayNames(getResolvedLocale(locale), { type: "dateTimeField" }).of(type)?.trim().charAt(0).toLocaleLowerCase(getResolvedLocale(locale));
|
|
58
|
+
if (!placeholderChar) return null;
|
|
59
|
+
return placeholderChar.repeat(length);
|
|
60
|
+
};
|
|
61
|
+
const mapTypeToPlaceholder = (type, locale) => {
|
|
62
|
+
switch (type) {
|
|
63
|
+
case "day": return repeatLocalizedFieldLabel(type, 2, locale);
|
|
64
|
+
case "month": return repeatLocalizedFieldLabel(type, 2, locale);
|
|
65
|
+
case "year": return repeatLocalizedFieldLabel(type, 4, locale);
|
|
66
|
+
case "hour": return "hh";
|
|
67
|
+
case "minute": return "mm";
|
|
68
|
+
default: return null;
|
|
27
69
|
}
|
|
28
|
-
|
|
29
|
-
|
|
70
|
+
};
|
|
71
|
+
const formatPlaceholder = (formatter, sampleDate) => {
|
|
72
|
+
return formatter.formatToParts(sampleDate).map((part) => mapTypeToPlaceholder(part.type, formatter.resolvedOptions().locale) ?? part.value).join("");
|
|
73
|
+
};
|
|
74
|
+
const removeDateSeparatorSpacing = (value) => value.replace(/([./-])\s+(?=[\p{Letter}\p{Number}])/gu, "$1");
|
|
75
|
+
const formatLocalizedDateParts = (formatter, date) => {
|
|
76
|
+
return removeDateSeparatorSpacing(formatter.format(date));
|
|
77
|
+
};
|
|
78
|
+
const formatLocalizedDatePartList = (formatter, date, isPlaceholder) => {
|
|
79
|
+
const locale = formatter.resolvedOptions().locale;
|
|
80
|
+
return formatter.formatToParts(date).map((part) => {
|
|
81
|
+
const value = part.type === "literal" ? part.value.replace(/([./-])\s+/gu, "$1") : part.value.replace(/\s+/gu, "");
|
|
82
|
+
return {
|
|
83
|
+
type: part.type,
|
|
84
|
+
value,
|
|
85
|
+
placeholder: mapTypeToPlaceholder(part.type, locale) ?? value,
|
|
86
|
+
isPlaceholder
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
function getDatePlaceholder(locale, options) {
|
|
91
|
+
return removeDateSeparatorSpacing(formatPlaceholder(getDatePlaceholderFormatter(locale, options), DATE_SAMPLE_DATE_UTC));
|
|
30
92
|
}
|
|
93
|
+
_DateTimeUtils.getDatePlaceholder = getDatePlaceholder;
|
|
94
|
+
function getTimePlaceholder(locale) {
|
|
95
|
+
return formatPlaceholder(getTimePlaceholderFormatter(locale), TIME_SAMPLE_DATE_UTC);
|
|
96
|
+
}
|
|
97
|
+
_DateTimeUtils.getTimePlaceholder = getTimePlaceholder;
|
|
98
|
+
function getDateTimePlaceholder(locale, options) {
|
|
99
|
+
return `${getDatePlaceholder(locale, options)}, ${getTimePlaceholder(locale)}`;
|
|
100
|
+
}
|
|
101
|
+
_DateTimeUtils.getDateTimePlaceholder = getDateTimePlaceholder;
|
|
102
|
+
function getDateRangePlaceholder(locale, options) {
|
|
103
|
+
const datePlaceholder = getDatePlaceholder(locale, options);
|
|
104
|
+
return `${datePlaceholder} – ${datePlaceholder}`;
|
|
105
|
+
}
|
|
106
|
+
_DateTimeUtils.getDateRangePlaceholder = getDateRangePlaceholder;
|
|
107
|
+
function formatCalendarDateLocalized(calendarDate, locale, options) {
|
|
108
|
+
return formatLocalizedDateParts(getDateFormatter(locale, options), calendarDate.toDate("UTC"));
|
|
109
|
+
}
|
|
110
|
+
_DateTimeUtils.formatCalendarDateLocalized = formatCalendarDateLocalized;
|
|
111
|
+
function formatCalendarDatePartsLocalized(calendarDate, locale, options) {
|
|
112
|
+
return formatLocalizedDatePartList(getDateFormatter(locale, options), calendarDate?.toDate("UTC") ?? DATE_SAMPLE_DATE_UTC, !calendarDate);
|
|
113
|
+
}
|
|
114
|
+
_DateTimeUtils.formatCalendarDatePartsLocalized = formatCalendarDatePartsLocalized;
|
|
115
|
+
function formatCalendarDateTimePartsLocalized(calendarDateTime, locale, options) {
|
|
116
|
+
const normalizedValue = calendarDateTime ? new CalendarDateTime(calendarDateTime.year, calendarDateTime.month, calendarDateTime.day, calendarDateTime.hour, calendarDateTime.minute) : null;
|
|
117
|
+
return formatLocalizedDatePartList(getDateTimeFormatter(locale, options), normalizedValue?.toDate("UTC") ?? TIME_SAMPLE_DATE_UTC, !calendarDateTime);
|
|
118
|
+
}
|
|
119
|
+
_DateTimeUtils.formatCalendarDateTimePartsLocalized = formatCalendarDateTimePartsLocalized;
|
|
120
|
+
function formatTimeLocalized(timeValue, locale, options) {
|
|
121
|
+
const dateTime = new CalendarDateTime(2e3, 11, 22, timeValue.hour, timeValue.minute);
|
|
122
|
+
return getTimeFormatter(locale, options).format(dateTime.toDate("UTC"));
|
|
123
|
+
}
|
|
124
|
+
_DateTimeUtils.formatTimeLocalized = formatTimeLocalized;
|
|
125
|
+
function formatTimePartsLocalized(timeValue, locale, options) {
|
|
126
|
+
const normalizedValue = new CalendarDateTime(2e3, 11, 22, timeValue?.hour ?? 6, timeValue?.minute ?? 45);
|
|
127
|
+
return formatLocalizedDatePartList(getTimeFormatter(locale, options), normalizedValue.toDate("UTC"), !timeValue);
|
|
128
|
+
}
|
|
129
|
+
_DateTimeUtils.formatTimePartsLocalized = formatTimePartsLocalized;
|
|
130
|
+
function formatCalendarDateTimeLocalized(calendarDateTime, locale, options) {
|
|
131
|
+
const normalizedValue = new CalendarDateTime(calendarDateTime.year, calendarDateTime.month, calendarDateTime.day, calendarDateTime.hour, calendarDateTime.minute);
|
|
132
|
+
return formatLocalizedDateParts(getDateTimeFormatter(locale, options), normalizedValue.toDate("UTC"));
|
|
133
|
+
}
|
|
134
|
+
_DateTimeUtils.formatCalendarDateTimeLocalized = formatCalendarDateTimeLocalized;
|
|
31
135
|
function resolveTimeZone(timeZone) {
|
|
32
136
|
if (timeZone) return timeZone;
|
|
33
137
|
return getLocalTimeZone();
|
|
@@ -41,6 +145,16 @@ var DateTimeUtils;
|
|
|
41
145
|
return dateValue.toDate(resolvedTimeZone).toISOString();
|
|
42
146
|
}
|
|
43
147
|
_DateTimeUtils.fromDateValueToISO = fromDateValueToISO;
|
|
148
|
+
function fromDateValueFieldsToUTCISO(dateValue) {
|
|
149
|
+
const dateTimeFields = dateValue;
|
|
150
|
+
return new CalendarDateTime(dateValue.year, dateValue.month, dateValue.day, dateTimeFields.hour ?? 0, dateTimeFields.minute ?? 0, dateTimeFields.second ?? 0, dateTimeFields.millisecond ?? 0).toDate("UTC").toISOString();
|
|
151
|
+
}
|
|
152
|
+
_DateTimeUtils.fromDateValueFieldsToUTCISO = fromDateValueFieldsToUTCISO;
|
|
153
|
+
function getCurrentWallClockCalendarDateTime() {
|
|
154
|
+
const date = /* @__PURE__ */ new Date();
|
|
155
|
+
return new CalendarDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
156
|
+
}
|
|
157
|
+
_DateTimeUtils.getCurrentWallClockCalendarDateTime = getCurrentWallClockCalendarDateTime;
|
|
44
158
|
function fromDateValueToOffsetISO(dateValue, timeZone) {
|
|
45
159
|
const resolvedTimeZone = resolveTimeZone(timeZone);
|
|
46
160
|
const date = dateValue.toDate(resolvedTimeZone);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ClassProp, ClassValue, StringToBoolean } from 'class-variance-authority/types';
|
|
2
|
+
export declare namespace StyleMergeUtils {
|
|
3
|
+
export type OverrideMode = "merge" | "overrideEntry" | "overrideCva";
|
|
4
|
+
export interface CvaVariantMap {
|
|
5
|
+
[variant: string]: {
|
|
6
|
+
[value: string]: ClassValue;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export type ConfigSchema = CvaVariantMap;
|
|
10
|
+
export type ConfigVariants<TSchema extends ConfigSchema> = {
|
|
11
|
+
[K in keyof TSchema]?: StringToBoolean<keyof NonNullable<TSchema[K]>> | null | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type ConfigVariantsMulti<TSchema extends ConfigSchema> = {
|
|
14
|
+
[K in keyof TSchema]?: StringToBoolean<keyof NonNullable<TSchema[K]>> | StringToBoolean<keyof NonNullable<TSchema[K]>>[] | undefined;
|
|
15
|
+
};
|
|
16
|
+
export interface Config<TSchema extends ConfigSchema> {
|
|
17
|
+
variants?: TSchema;
|
|
18
|
+
defaultVariants?: ConfigVariants<TSchema>;
|
|
19
|
+
compoundVariants?: Array<(ConfigVariants<TSchema> | ConfigVariantsMulti<TSchema>) & ClassProp>;
|
|
20
|
+
}
|
|
21
|
+
export interface CvaCompoundEntry {
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
class?: ClassValue;
|
|
24
|
+
className?: ClassValue;
|
|
25
|
+
}
|
|
26
|
+
export interface CvaConfigShape {
|
|
27
|
+
variants?: CvaVariantMap;
|
|
28
|
+
compoundVariants?: CvaCompoundEntry[];
|
|
29
|
+
defaultVariants?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface CvaDefinition<TConfig extends CvaConfigShape> {
|
|
32
|
+
base: string[];
|
|
33
|
+
config?: TConfig;
|
|
34
|
+
}
|
|
35
|
+
type DeepOptionalOverride<T> = T extends string ? string : T extends (infer U)[] ? DeepOptionalOverride<U>[] : T extends object ? {
|
|
36
|
+
[K in keyof T]?: DeepOptionalOverride<T[K]>;
|
|
37
|
+
} : T;
|
|
38
|
+
export type CvaConfigOverride<TConfig extends CvaConfigShape = CvaConfigShape> = DeepOptionalOverride<CvaDefinition<TConfig>> & {
|
|
39
|
+
mode: OverrideMode;
|
|
40
|
+
};
|
|
41
|
+
export const mergeCvaDefinition: <TConfig extends CvaConfigShape>(baseDefinition: CvaDefinition<TConfig>, override?: CvaConfigOverride<TConfig>) => CvaDefinition<TConfig>;
|
|
42
|
+
export {};
|
|
43
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
//#region src/utils/style-merge.util.ts
|
|
3
|
+
var StyleMergeUtils;
|
|
4
|
+
(function(_StyleMergeUtils) {
|
|
5
|
+
const CLASS_NAME_KEY = "className";
|
|
6
|
+
const CLASS_KEY = "class";
|
|
7
|
+
const CLASS_KEYS = new Set([CLASS_KEY, CLASS_NAME_KEY]);
|
|
8
|
+
const isClassKey = (key) => {
|
|
9
|
+
return CLASS_KEYS.has(key);
|
|
10
|
+
};
|
|
11
|
+
const getSelectorEntries = (entry) => {
|
|
12
|
+
const selectors = [];
|
|
13
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
14
|
+
if (isClassKey(key)) continue;
|
|
15
|
+
selectors.push([key, value]);
|
|
16
|
+
}
|
|
17
|
+
return selectors;
|
|
18
|
+
};
|
|
19
|
+
const normalizeToArray = (value) => {
|
|
20
|
+
if (Array.isArray(value)) return value;
|
|
21
|
+
return [value];
|
|
22
|
+
};
|
|
23
|
+
const isSubsetValues = (subset, superset) => {
|
|
24
|
+
const subsetValues = normalizeToArray(subset).map((item) => String(item));
|
|
25
|
+
const supersetSet = new Set(normalizeToArray(superset).map((item) => String(item)));
|
|
26
|
+
for (const value of subsetValues) if (!supersetSet.has(value)) return false;
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const canOverrideCompoundEntry = (baseEntry, overrideEntry) => {
|
|
30
|
+
const baseSelectors = getSelectorEntries(baseEntry);
|
|
31
|
+
const overrideSelectors = getSelectorEntries(overrideEntry);
|
|
32
|
+
if (baseSelectors.length !== overrideSelectors.length) return false;
|
|
33
|
+
const baseSelectorMap = new Map(baseSelectors);
|
|
34
|
+
for (const [overrideKey, overrideValue] of overrideSelectors) {
|
|
35
|
+
if (!baseSelectorMap.has(overrideKey)) return false;
|
|
36
|
+
if (!isSubsetValues(overrideValue, baseSelectorMap.get(overrideKey))) return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
const splitCompoundEntryByOverride = (baseEntry, overrideEntry) => {
|
|
41
|
+
const baseWithoutClass = {};
|
|
42
|
+
for (const [key, value] of Object.entries(baseEntry)) {
|
|
43
|
+
if (isClassKey(key)) continue;
|
|
44
|
+
baseWithoutClass[key] = value;
|
|
45
|
+
}
|
|
46
|
+
let hasSplit = false;
|
|
47
|
+
for (const [key, overrideValue] of getSelectorEntries(overrideEntry)) {
|
|
48
|
+
const baseValue = baseWithoutClass[key];
|
|
49
|
+
if (!Array.isArray(baseValue)) continue;
|
|
50
|
+
const baseValues = [...baseValue];
|
|
51
|
+
const overrideValues = new Set(normalizeToArray(overrideValue).map((item) => String(item)));
|
|
52
|
+
const remainingValues = baseValues.filter((item) => !overrideValues.has(String(item)));
|
|
53
|
+
if (remainingValues.length === baseValues.length) continue;
|
|
54
|
+
hasSplit = true;
|
|
55
|
+
if (remainingValues.length === 1) baseWithoutClass[key] = remainingValues[0];
|
|
56
|
+
else baseWithoutClass[key] = remainingValues;
|
|
57
|
+
}
|
|
58
|
+
if (!hasSplit) return;
|
|
59
|
+
const className = getCompoundClass(baseEntry);
|
|
60
|
+
if (className) baseWithoutClass.className = className;
|
|
61
|
+
return normalizeCompoundEntry(baseWithoutClass);
|
|
62
|
+
};
|
|
63
|
+
const getCompoundClass = (entry) => {
|
|
64
|
+
const fromClassName = entry[CLASS_NAME_KEY];
|
|
65
|
+
if (fromClassName) return clsx(fromClassName);
|
|
66
|
+
const fromClass = entry[CLASS_KEY];
|
|
67
|
+
if (fromClass) return clsx(fromClass);
|
|
68
|
+
return "";
|
|
69
|
+
};
|
|
70
|
+
const normalizeCompoundEntry = (entry) => {
|
|
71
|
+
const normalized = {};
|
|
72
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
73
|
+
if (key === CLASS_KEY || key === CLASS_NAME_KEY) continue;
|
|
74
|
+
normalized[key] = value;
|
|
75
|
+
}
|
|
76
|
+
const className = getCompoundClass(entry);
|
|
77
|
+
if (className) normalized.className = className;
|
|
78
|
+
return normalized;
|
|
79
|
+
};
|
|
80
|
+
const getCompoundIdentity = (entry) => {
|
|
81
|
+
const keys = Object.keys(entry).sort();
|
|
82
|
+
const identityParts = [];
|
|
83
|
+
for (const key of keys) {
|
|
84
|
+
if (isClassKey(key)) continue;
|
|
85
|
+
const value = entry[key];
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
const normalizedValues = value.map((item) => String(item)).sort();
|
|
88
|
+
identityParts.push(`${key}:[${normalizedValues.join(",")}]`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
identityParts.push(`${key}:${String(value)}`);
|
|
92
|
+
}
|
|
93
|
+
return identityParts.join("|");
|
|
94
|
+
};
|
|
95
|
+
const mergeClassNames = (baseClassName, overrideClassName, mode) => {
|
|
96
|
+
if (mode !== "merge") return clsx(overrideClassName);
|
|
97
|
+
return clsx(baseClassName, overrideClassName);
|
|
98
|
+
};
|
|
99
|
+
const mergeClassLists = (baseClassNames, overrideClassNames, mode) => {
|
|
100
|
+
if (mode !== "merge") return [...overrideClassNames];
|
|
101
|
+
return [...baseClassNames, ...overrideClassNames];
|
|
102
|
+
};
|
|
103
|
+
const mergeVariants = (baseVariants, overrideVariants, mode = "merge") => {
|
|
104
|
+
const merged = {};
|
|
105
|
+
if (baseVariants) for (const [variantKey, variantValues] of Object.entries(baseVariants)) merged[variantKey] = { ...variantValues };
|
|
106
|
+
if (!overrideVariants) {
|
|
107
|
+
if (!baseVariants) return;
|
|
108
|
+
return merged;
|
|
109
|
+
}
|
|
110
|
+
for (const [variantKey, overrideValues] of Object.entries(overrideVariants)) {
|
|
111
|
+
if (!overrideValues) continue;
|
|
112
|
+
if (!merged[variantKey]) merged[variantKey] = {};
|
|
113
|
+
for (const [valueKey, overrideValue] of Object.entries(overrideValues)) {
|
|
114
|
+
const baseClass = merged[variantKey][valueKey] ?? "";
|
|
115
|
+
merged[variantKey][valueKey] = mergeClassNames(baseClass, overrideValue, mode);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return merged;
|
|
119
|
+
};
|
|
120
|
+
const mergeCompoundVariants = (baseCompound, overrideCompound, mode = "merge") => {
|
|
121
|
+
if (!baseCompound) {
|
|
122
|
+
if (!overrideCompound) return;
|
|
123
|
+
return overrideCompound.map((entry) => normalizeCompoundEntry(entry));
|
|
124
|
+
}
|
|
125
|
+
const merged = baseCompound.map((entry) => normalizeCompoundEntry(entry));
|
|
126
|
+
if (!overrideCompound) return merged;
|
|
127
|
+
if (mode === "merge") {
|
|
128
|
+
for (const overrideEntry of overrideCompound) {
|
|
129
|
+
const normalizedOverride = normalizeCompoundEntry(overrideEntry);
|
|
130
|
+
const overrideIdentity = getCompoundIdentity(normalizedOverride);
|
|
131
|
+
let index = -1;
|
|
132
|
+
for (let i = 0; i < merged.length; i++) if (getCompoundIdentity(merged[i]) === overrideIdentity) {
|
|
133
|
+
index = i;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (index < 0) {
|
|
137
|
+
merged.push(normalizedOverride);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const mergedClassName = mergeClassNames(getCompoundClass(merged[index]), getCompoundClass(normalizedOverride), "merge");
|
|
141
|
+
const nextEntry = { ...normalizedOverride };
|
|
142
|
+
nextEntry.className = mergedClassName;
|
|
143
|
+
merged[index] = nextEntry;
|
|
144
|
+
}
|
|
145
|
+
return merged;
|
|
146
|
+
}
|
|
147
|
+
for (const overrideEntry of overrideCompound) {
|
|
148
|
+
const normalizedOverride = normalizeCompoundEntry(overrideEntry);
|
|
149
|
+
const overrideIdentity = getCompoundIdentity(normalizedOverride);
|
|
150
|
+
let exactMatchIndex = -1;
|
|
151
|
+
for (let i = 0; i < merged.length; i++) {
|
|
152
|
+
const currentEntry = merged[i];
|
|
153
|
+
if (getCompoundIdentity(currentEntry) === overrideIdentity) {
|
|
154
|
+
exactMatchIndex = i;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (exactMatchIndex >= 0) {
|
|
159
|
+
merged[exactMatchIndex] = normalizedOverride;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let candidateIndex = -1;
|
|
163
|
+
for (let i = 0; i < merged.length; i++) if (canOverrideCompoundEntry(merged[i], normalizedOverride)) {
|
|
164
|
+
candidateIndex = i;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
if (candidateIndex < 0) {
|
|
168
|
+
merged.push(normalizedOverride);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const candidate = merged[candidateIndex];
|
|
172
|
+
const splitBaseEntry = splitCompoundEntryByOverride(candidate, normalizedOverride);
|
|
173
|
+
if (splitBaseEntry) {
|
|
174
|
+
merged[candidateIndex] = splitBaseEntry;
|
|
175
|
+
merged.push(normalizedOverride);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
merged[candidateIndex] = normalizedOverride;
|
|
179
|
+
}
|
|
180
|
+
return merged;
|
|
181
|
+
};
|
|
182
|
+
const mergeDefaultVariants = (baseDefaults, overrideDefaults) => {
|
|
183
|
+
if (!baseDefaults) {
|
|
184
|
+
if (!overrideDefaults) return;
|
|
185
|
+
return { ...overrideDefaults };
|
|
186
|
+
}
|
|
187
|
+
if (!overrideDefaults) return { ...baseDefaults };
|
|
188
|
+
return {
|
|
189
|
+
...baseDefaults,
|
|
190
|
+
...overrideDefaults
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
const hasConfigContent = (config) => {
|
|
194
|
+
if (!config) return false;
|
|
195
|
+
if (config.variants) return true;
|
|
196
|
+
if (config.compoundVariants) return true;
|
|
197
|
+
if (config.defaultVariants) return true;
|
|
198
|
+
return false;
|
|
199
|
+
};
|
|
200
|
+
_StyleMergeUtils.mergeCvaDefinition = (baseDefinition, override) => {
|
|
201
|
+
if (!override) return baseDefinition;
|
|
202
|
+
const mode = override.mode ?? "merge";
|
|
203
|
+
const overrideConfig = override.config;
|
|
204
|
+
if (mode === "overrideCva") {
|
|
205
|
+
const overrideBase = [];
|
|
206
|
+
if (override.base && Array.isArray(override.base)) {
|
|
207
|
+
for (const item of override.base) if (typeof item === "string") overrideBase.push(item);
|
|
208
|
+
}
|
|
209
|
+
let finalOverrideConfig = void 0;
|
|
210
|
+
if (hasConfigContent(overrideConfig)) finalOverrideConfig = overrideConfig;
|
|
211
|
+
return {
|
|
212
|
+
base: overrideBase,
|
|
213
|
+
config: finalOverrideConfig
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
let mergedBase = [...baseDefinition.base];
|
|
217
|
+
if (override.base && Array.isArray(override.base)) mergedBase = mergeClassLists(baseDefinition.base, override.base, mode);
|
|
218
|
+
const baseConfig = baseDefinition.config;
|
|
219
|
+
const mergedConfig = {
|
|
220
|
+
variants: mergeVariants(baseConfig?.variants, overrideConfig?.variants, mode),
|
|
221
|
+
compoundVariants: mergeCompoundVariants(baseConfig?.compoundVariants, overrideConfig?.compoundVariants, mode),
|
|
222
|
+
defaultVariants: mergeDefaultVariants(baseConfig?.defaultVariants, overrideConfig?.defaultVariants)
|
|
223
|
+
};
|
|
224
|
+
let finalConfig = void 0;
|
|
225
|
+
if (hasConfigContent(mergedConfig)) finalConfig = mergedConfig;
|
|
226
|
+
return {
|
|
227
|
+
base: mergedBase,
|
|
228
|
+
config: finalConfig
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
})(StyleMergeUtils || (StyleMergeUtils = {}));
|
|
232
|
+
//#endregion
|
|
233
|
+
export { StyleMergeUtils };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ClassProp } from 'class-variance-authority/types';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { BreadcrumbChevronVariantProps, BreadcrumbIconVariantProps, BreadcrumbItemVariantProps, BreadcrumbSegmentVariantProps, BreadcrumbsVariantProps } from '../components/Breadcrumbs/breadcrumbs.cva';
|
|
4
|
-
import { ButtonVariantProps } from '../components/buttons/Button/button.cva';
|
|
5
|
-
import { PillButtonVariants } from '../components/buttons/PillButton/pillButton.cva';
|
|
6
|
-
import { CheckboxIconVariantProps, CheckboxVariantProps } from '../components/inputs/Checkbox/checkbox.cva';
|
|
7
|
-
import { FormFieldErrorVariantProps } from '../components/inputs/FormField/formFieldError.cva';
|
|
8
|
-
import { FormFieldHelperVariantProps } from '../components/inputs/FormField/formFieldHelper.cva';
|
|
9
|
-
import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
10
|
-
import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
11
|
-
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
12
|
-
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
13
|
-
import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from '../components/Menu/menu.cva';
|
|
14
|
-
import { AccordionChevronVariantProps, AccordionHeadingSubtitleVariantProps, AccordionHeadingTitleVariantProps, AccordionHeadingVariantProps, AccordionIconVariantProps, AccordionItemVariantProps, AccordionPanelContentVariantProps, AccordionPanelVariantProps, AccordionTriggerVariantProps, AccordionVariantProps } from '../components/navigation/Accordion/accordion.cva';
|
|
15
|
-
import { StepperIconVariantProps, StepperItemVariantProps, StepperNumberVariantProps, StepperSeparatorVariantProps, StepperSubtextVariantProps, StepperTitleVariantProps, StepperVariantProps } from '../components/navigation/Stepper/stepper.cva';
|
|
16
|
-
import { ModalVariantProps } from '../components/overlays/Modal/modal.cva';
|
|
17
|
-
import { TooltipPointerHorizontalVariantProps, TooltipPointerVerticalVariantProps, TooltipTextVariantProps, TooltipVariantProps } from '../components/overlays/Tooltip/tooltip.cva';
|
|
18
|
-
import { SegmentItemVariantProps, SegmentVariantProps } from '../components/segment/segment.cva';
|
|
19
|
-
import { PopoverVariantProps } from '../components/shared/popover.cva';
|
|
20
|
-
import { AlertVariantProps } from '../components/status/Alert/alert.cva';
|
|
21
|
-
import { ToastVariantProps } from '../components/status/Toast/toast.cva';
|
|
22
|
-
import { TableCellTextVariantProps, TableDataVariantProps, TableHeadDataVariantProps, TableHeadRowVariantProps, TableHeaderTextVariantProps, TableRowVariantProps } from '../components/table/table.cva';
|
|
23
|
-
import { LinkVariantProps } from '../components/text/Link/link.cva';
|
|
24
|
-
import { TagVariantProps } from '../components/text/Tag/tag.cva';
|
|
25
|
-
import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
|
|
26
|
-
import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
|
|
27
|
-
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
28
|
-
export declare namespace UIStyle {
|
|
29
|
-
export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
|
|
30
|
-
type OptionKey = {
|
|
31
|
-
[K in keyof Options]: Options[K] extends object ? `${K & string}.${keyof Options[K] & string}` : never;
|
|
32
|
-
}[keyof Options];
|
|
33
|
-
interface Options {
|
|
34
|
-
button: {
|
|
35
|
-
cva?: Cva<ButtonVariantProps>;
|
|
36
|
-
sizeCva?: Cva<ButtonVariantProps>;
|
|
37
|
-
contentCva?: Cva<ButtonVariantProps>;
|
|
38
|
-
iconSize?: Cva<Pick<ButtonVariantProps, "size">>;
|
|
39
|
-
typography?: CompoundMapper<TypographyVariantProps, ButtonVariantProps>;
|
|
40
|
-
};
|
|
41
|
-
pillButton: {
|
|
42
|
-
cva?: Cva<PillButtonVariants>;
|
|
43
|
-
typography?: CompoundMapper<TypographyVariantProps, PillButtonVariants>;
|
|
44
|
-
};
|
|
45
|
-
checkbox: {
|
|
46
|
-
cva?: Cva<CheckboxVariantProps>;
|
|
47
|
-
iconCva?: Cva<CheckboxIconVariantProps>;
|
|
48
|
-
typography?: CompoundMapper<TypographyVariantProps, CheckboxVariantProps>;
|
|
49
|
-
};
|
|
50
|
-
radio: {
|
|
51
|
-
cva?: Cva<RadioVariantProps>;
|
|
52
|
-
typography?: CompoundMapper<TypographyVariantProps, RadioVariantProps>;
|
|
53
|
-
};
|
|
54
|
-
status: {
|
|
55
|
-
iconCva?: Cva<ToastVariantProps>;
|
|
56
|
-
separatorCva?: Cva<ToastVariantProps>;
|
|
57
|
-
};
|
|
58
|
-
toast: {
|
|
59
|
-
cva?: Cva<ToastVariantProps>;
|
|
60
|
-
buttonColor?: CompoundMapper<Pick<ButtonVariantProps, "color" | "inverted">, ToastVariantProps>;
|
|
61
|
-
};
|
|
62
|
-
alert: {
|
|
63
|
-
cva?: Cva<AlertVariantProps>;
|
|
64
|
-
};
|
|
65
|
-
input: {
|
|
66
|
-
baseCva?: Cva<InputBaseProps>;
|
|
67
|
-
sizeCva?: Cva<InputSizeProps>;
|
|
68
|
-
sideCva?: Cva<InputSideProps>;
|
|
69
|
-
};
|
|
70
|
-
label: {
|
|
71
|
-
cva?: Cva<LabelBaseProps>;
|
|
72
|
-
typography?: CompoundMapper<TypographyVariantProps, LabelBaseProps>;
|
|
73
|
-
};
|
|
74
|
-
toggle: {
|
|
75
|
-
cva?: Cva<ToggleVariantProps>;
|
|
76
|
-
typography?: CompoundMapper<TypographyVariantProps, ToggleVariantProps>;
|
|
77
|
-
};
|
|
78
|
-
typography: {
|
|
79
|
-
cva?: Cva<TypographyVariantProps>;
|
|
80
|
-
};
|
|
81
|
-
link: {
|
|
82
|
-
cva?: Cva<LinkVariantProps>;
|
|
83
|
-
};
|
|
84
|
-
tag: {
|
|
85
|
-
cva?: Cva<TagVariantProps>;
|
|
86
|
-
};
|
|
87
|
-
table: {
|
|
88
|
-
headRowCva?: Cva<TableHeadRowVariantProps>;
|
|
89
|
-
headDataCva?: Cva<TableHeadDataVariantProps>;
|
|
90
|
-
rowCva?: Cva<TableRowVariantProps>;
|
|
91
|
-
dataCva?: Cva<TableDataVariantProps>;
|
|
92
|
-
headerTextCva?: Cva<TableHeaderTextVariantProps>;
|
|
93
|
-
cellTextCva?: Cva<TableCellTextVariantProps>;
|
|
94
|
-
};
|
|
95
|
-
tooltip: {
|
|
96
|
-
cva?: Cva<TooltipVariantProps>;
|
|
97
|
-
pointerHorizontalCva?: Cva<TooltipPointerHorizontalVariantProps>;
|
|
98
|
-
pointerVerticalCva?: Cva<TooltipPointerVerticalVariantProps>;
|
|
99
|
-
textCva?: Cva<TooltipTextVariantProps>;
|
|
100
|
-
};
|
|
101
|
-
modal: {
|
|
102
|
-
contentCva?: Cva<ModalVariantProps>;
|
|
103
|
-
overlayCva?: Cva<ModalVariantProps>;
|
|
104
|
-
mainCva?: Cva<ModalVariantProps>;
|
|
105
|
-
};
|
|
106
|
-
menu: {
|
|
107
|
-
cva?: Cva<MenuCvaVariantProps>;
|
|
108
|
-
itemCva?: Cva<MenuItemVariantProps>;
|
|
109
|
-
popoverCva?: Cva<MenuPopoverVariantProps>;
|
|
110
|
-
popoverWrapperCva?: Cva<MenuPopoverWrapperVariantProps>;
|
|
111
|
-
};
|
|
112
|
-
segment: {
|
|
113
|
-
cva?: Cva<SegmentVariantProps>;
|
|
114
|
-
itemCva?: Cva<SegmentItemVariantProps>;
|
|
115
|
-
};
|
|
116
|
-
stepper: {
|
|
117
|
-
cva?: Cva<StepperVariantProps>;
|
|
118
|
-
itemCva?: Cva<StepperItemVariantProps>;
|
|
119
|
-
iconCva?: Cva<StepperIconVariantProps>;
|
|
120
|
-
numberCva?: Cva<StepperNumberVariantProps>;
|
|
121
|
-
titleCva?: Cva<StepperTitleVariantProps>;
|
|
122
|
-
subtextCva?: Cva<StepperSubtextVariantProps>;
|
|
123
|
-
separatorCva?: Cva<StepperSeparatorVariantProps>;
|
|
124
|
-
};
|
|
125
|
-
accordion: {
|
|
126
|
-
cva?: Cva<AccordionVariantProps>;
|
|
127
|
-
itemCva?: Cva<AccordionItemVariantProps>;
|
|
128
|
-
triggerCva?: Cva<AccordionTriggerVariantProps>;
|
|
129
|
-
headingCva?: Cva<AccordionHeadingVariantProps>;
|
|
130
|
-
headingTitleCva?: Cva<AccordionHeadingTitleVariantProps>;
|
|
131
|
-
headingSubtitleCva?: Cva<AccordionHeadingSubtitleVariantProps>;
|
|
132
|
-
chevronCva?: Cva<AccordionChevronVariantProps>;
|
|
133
|
-
iconCva?: Cva<AccordionIconVariantProps>;
|
|
134
|
-
panelCva?: Cva<AccordionPanelVariantProps>;
|
|
135
|
-
panelContentCva?: Cva<AccordionPanelContentVariantProps>;
|
|
136
|
-
};
|
|
137
|
-
breadcrumbs: {
|
|
138
|
-
cva?: Cva<BreadcrumbsVariantProps>;
|
|
139
|
-
itemCva?: Cva<BreadcrumbItemVariantProps>;
|
|
140
|
-
segmentCva?: Cva<BreadcrumbSegmentVariantProps>;
|
|
141
|
-
chevronCva?: Cva<BreadcrumbChevronVariantProps>;
|
|
142
|
-
iconCva?: Cva<BreadcrumbIconVariantProps>;
|
|
143
|
-
};
|
|
144
|
-
popover: {
|
|
145
|
-
cva?: Cva<PopoverVariantProps>;
|
|
146
|
-
};
|
|
147
|
-
formField: {
|
|
148
|
-
errorLabelCva?: Cva<FormFieldErrorVariantProps>;
|
|
149
|
-
helperLabelCva?: Cva<FormFieldHelperVariantProps>;
|
|
150
|
-
};
|
|
151
|
-
select: {
|
|
152
|
-
listBoxItemCva?: Cva<SelectListBoxItemCva>;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
interface ProviderProps {
|
|
156
|
-
config?: Partial<Options>;
|
|
157
|
-
}
|
|
158
|
-
export const Provider: ({ children, config }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
159
|
-
export const useCva: <T>(key: OptionKey, fallback: Cva<T>) => Cva<T>;
|
|
160
|
-
export const useMapper: <T, K extends ConfigSchema>(key: OptionKey, fallback: CompoundMapper<T, K>) => CompoundMapper<T, K>;
|
|
161
|
-
export {};
|
|
162
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, use } from "react";
|
|
3
|
-
//#region src/config/uiStyle.context.tsx
|
|
4
|
-
var UIStyle;
|
|
5
|
-
(function(_UIStyle) {
|
|
6
|
-
const Context = createContext(null);
|
|
7
|
-
_UIStyle.Provider = ({ children, config }) => {
|
|
8
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
9
|
-
value: config,
|
|
10
|
-
children
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
const useConfig = () => {
|
|
14
|
-
return use(Context);
|
|
15
|
-
};
|
|
16
|
-
_UIStyle.useCva = (key, fallback) => {
|
|
17
|
-
const uiStyle = useConfig();
|
|
18
|
-
if (!uiStyle) return fallback;
|
|
19
|
-
const [k1, k2] = key.split(".");
|
|
20
|
-
return uiStyle[k1]?.[k2] ?? fallback;
|
|
21
|
-
};
|
|
22
|
-
_UIStyle.useMapper = (key, fallback) => {
|
|
23
|
-
const uiStyle = useConfig();
|
|
24
|
-
if (!uiStyle) return fallback;
|
|
25
|
-
const [k1, k2] = key.split(".");
|
|
26
|
-
return uiStyle[k1]?.[k2] ?? fallback;
|
|
27
|
-
};
|
|
28
|
-
})(UIStyle || (UIStyle = {}));
|
|
29
|
-
//#endregion
|
|
30
|
-
export { UIStyle };
|