vueless 0.0.474 → 0.0.475
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/adatper.locale/locales/en.d.ts +289 -0
- package/adatper.locale/vue-i18n.d.ts +9 -0
- package/adatper.locale/vueless.d.ts +11 -0
- package/composables/useAutoPosition.d.ts +15 -0
- package/composables/useBreakpoint.d.ts +7 -0
- package/composables/useBreakpoint.js +1 -1
- package/composables/useLocale.d.ts +3 -0
- package/composables/useMutationObserver.d.ts +7 -0
- package/composables/useUI.d.ts +17 -0
- package/composablesTs/useAutoPosition.d.ts +28 -0
- package/composablesTs/useAutoPosition.ts +115 -0
- package/composablesTs/useBreakpoint.d.ts +7 -0
- package/composablesTs/useBreakpoint.ts +106 -0
- package/composablesTs/useLocale.d.ts +3 -0
- package/composablesTs/useLocale.ts +25 -0
- package/composablesTs/useMutationObserver.d.ts +8 -0
- package/composablesTs/useMutationObserver.ts +50 -0
- package/composablesTs/useUI.d.ts +68 -0
- package/composablesTs/useUI.ts +566 -0
- package/constants.d.ts +42 -0
- package/constants.js +1 -1
- package/constants.ts +73 -0
- package/directives/clickOutside/storybook/stories.d.ts +653 -0
- package/directives/clickOutside/vClickOutside.d.ts +6 -0
- package/directives/clickOutside/vClickOutside.js +2 -2
- package/directives/index.d.ts +2 -0
- package/directives/tooltip/storybook/stories.d.ts +252 -0
- package/directives/tooltip/storybook/stories.js +5 -5
- package/directives/tooltip/vTooltip.d.ts +6 -0
- package/index.d.ts +15 -0
- package/{index.js → index.ts} +9 -6
- package/package.json +28 -17
- package/preset.tailwind.d.ts +116 -0
- package/{preset.tailwind.js → preset.tailwind.ts} +30 -22
- package/types.d.ts +131 -0
- package/types.ts +218 -0
- package/ui.button/UButton.vue.d.ts +73 -0
- package/ui.button/config.d.ts +130 -0
- package/ui.button/constants.d.ts +1 -0
- package/ui.button/storybook/stories.d.ts +3062 -0
- package/ui.button/useAttrs.d.ts +11 -0
- package/ui.button-link/ULink.vue +1 -1
- package/ui.button-link/ULink.vue.d.ts +66 -0
- package/ui.button-link/config.d.ts +101 -0
- package/ui.button-link/constants.d.ts +1 -0
- package/ui.button-link/storybook/stories.d.ts +4567 -0
- package/ui.button-link/useAttrs.d.ts +14 -0
- package/ui.button-toggle/UToggle.vue.d.ts +50 -0
- package/ui.button-toggle/config.d.ts +65 -0
- package/ui.button-toggle/constants.d.ts +3 -0
- package/ui.button-toggle/storybook/stories.d.ts +2683 -0
- package/ui.button-toggle/useAttrs.d.ts +11 -0
- package/ui.button-toggle-item/UToggleItem.vue.d.ts +36 -0
- package/ui.button-toggle-item/config.d.ts +41 -0
- package/ui.button-toggle-item/constants.d.ts +1 -0
- package/ui.button-toggle-item/storybook/stories.d.ts +495 -0
- package/ui.button-toggle-item/useAttrs.d.ts +15 -0
- package/ui.container-accordion/UAccordion.vue.d.ts +32 -0
- package/ui.container-accordion/config.d.ts +40 -0
- package/ui.container-accordion/constants.d.ts +1 -0
- package/ui.container-accordion/storybook/stories.d.ts +732 -0
- package/ui.container-accordion/useAttrs.d.ts +13 -0
- package/ui.container-card/UCard.vue.d.ts +31 -0
- package/ui.container-card/config.d.ts +13 -0
- package/ui.container-card/constants.d.ts +1 -0
- package/ui.container-card/storybook/stories.d.ts +3906 -0
- package/ui.container-card/useAttrs.d.ts +11 -0
- package/ui.container-col/UCol.vue.d.ts +33 -0
- package/ui.container-col/config.d.ts +81 -0
- package/ui.container-col/constants.d.ts +1 -0
- package/ui.container-col/storybook/stories.d.ts +840 -0
- package/ui.container-col/useAttrs.d.ts +11 -0
- package/ui.container-divider/UDivider.vue.d.ts +25 -0
- package/ui.container-divider/config.d.ts +102 -0
- package/ui.container-divider/constants.d.ts +1 -0
- package/ui.container-divider/storybook/stories.d.ts +577 -0
- package/ui.container-divider/useAttrs.d.ts +11 -0
- package/ui.container-group/UGroup.vue.d.ts +33 -0
- package/ui.container-group/config.d.ts +38 -0
- package/ui.container-group/constants.d.ts +1 -0
- package/ui.container-group/storybook/stories.d.ts +2869 -0
- package/ui.container-group/useAttrs.d.ts +11 -0
- package/ui.container-modal/UModal.vue.d.ts +59 -0
- package/ui.container-modal/config.d.ts +77 -0
- package/ui.container-modal/constants.d.ts +1 -0
- package/ui.container-modal/storybook/stories.d.ts +8377 -0
- package/ui.container-modal/useAttrs.d.ts +11 -0
- package/ui.container-modal-confirm/UModalConfirm.vue.d.ts +59 -0
- package/ui.container-modal-confirm/config.d.ts +23 -0
- package/ui.container-modal-confirm/constants.d.ts +1 -0
- package/ui.container-modal-confirm/storybook/stories.d.ts +4494 -0
- package/ui.container-modal-confirm/useAttrs.d.ts +11 -0
- package/ui.container-page/UPage.vue.d.ts +47 -0
- package/ui.container-page/config.d.ts +85 -0
- package/ui.container-page/constants.d.ts +1 -0
- package/ui.container-page/storybook/stories.d.ts +8723 -0
- package/ui.container-page/useAttrs.d.ts +13 -0
- package/ui.container-row/URow.vue.d.ts +35 -0
- package/ui.container-row/config.d.ts +85 -0
- package/ui.container-row/constants.d.ts +1 -0
- package/ui.container-row/storybook/stories.d.ts +2619 -0
- package/ui.container-row/useAttrs.d.ts +11 -0
- package/ui.data-list/UDataList.vue +4 -4
- package/ui.data-list/UDataList.vue.d.ts +74 -0
- package/ui.data-list/config.d.ts +48 -0
- package/ui.data-list/constants.d.ts +1 -0
- package/ui.data-list/storybook/stories.d.ts +3342 -0
- package/ui.data-list/useAttrs.d.ts +11 -0
- package/ui.data-table/UTable.vue.d.ts +90 -0
- package/ui.data-table/UTableRow.vue.d.ts +61 -0
- package/ui.data-table/config.d.ts +128 -0
- package/ui.data-table/constants.d.ts +1 -0
- package/ui.data-table/storybook/stories.d.ts +13069 -0
- package/ui.data-table/useAttrs.d.ts +17 -0
- package/ui.data-table/utilTable.d.ts +9 -0
- package/ui.dropdown-badge/UDropdownBadge.vue.d.ts +145 -0
- package/ui.dropdown-badge/config.d.ts +39 -0
- package/ui.dropdown-badge/constants.d.ts +1 -0
- package/ui.dropdown-badge/storybook/stories.d.ts +1246 -0
- package/ui.dropdown-badge/useAttrs.d.ts +13 -0
- package/ui.dropdown-button/UDropdownButton.vue.d.ts +151 -0
- package/ui.dropdown-button/config.d.ts +52 -0
- package/ui.dropdown-button/constants.d.ts +4 -0
- package/ui.dropdown-button/storybook/stories.d.ts +1912 -0
- package/ui.dropdown-button/useAttrs.d.ts +13 -0
- package/ui.dropdown-link/UDropdownLink.vue.d.ts +149 -0
- package/ui.dropdown-link/config.d.ts +37 -0
- package/ui.dropdown-link/constants.d.ts +1 -0
- package/ui.dropdown-link/storybook/stories.d.ts +1333 -0
- package/ui.dropdown-link/useAttrs.d.ts +13 -0
- package/ui.dropdown-list/UDropdownList.vue.d.ts +59 -0
- package/ui.dropdown-list/config.d.ts +77 -0
- package/ui.dropdown-list/constants.d.ts +1 -0
- package/ui.dropdown-list/storybook/stories.d.ts +783 -0
- package/ui.dropdown-list/useAttrs.d.ts +11 -0
- package/ui.dropdown-list/usePointer.d.ts +8 -0
- package/ui.form-calendar/UCalendar.vue.d.ts +31 -0
- package/ui.form-calendar/UCalendarDayView.vue.d.ts +26 -0
- package/ui.form-calendar/UCalendarMonthView.vue.d.ts +26 -0
- package/ui.form-calendar/UCalendarYearView.vue.d.ts +26 -0
- package/ui.form-calendar/config.d.ts +207 -0
- package/ui.form-calendar/constants.d.ts +66 -0
- package/ui.form-calendar/storybook/stories.d.ts +262 -0
- package/ui.form-calendar/useAttrs.d.ts +11 -0
- package/ui.form-calendar/utilCalendar.d.ts +8 -0
- package/ui.form-calendar/utilDate.d.ts +30 -0
- package/ui.form-calendar/utilFormatting.d.ts +68 -0
- package/ui.form-checkbox/UCheckbox.vue.d.ts +50 -0
- package/ui.form-checkbox/config.d.ts +67 -0
- package/ui.form-checkbox/constants.d.ts +1 -0
- package/ui.form-checkbox/storybook/stories.d.ts +1589 -0
- package/ui.form-checkbox/useAttrs.d.ts +14 -0
- package/ui.form-checkbox-group/UCheckboxGroup.vue.d.ts +40 -0
- package/ui.form-checkbox-group/config.d.ts +21 -0
- package/ui.form-checkbox-group/constants.d.ts +1 -0
- package/ui.form-checkbox-group/storybook/stories.d.ts +2441 -0
- package/ui.form-checkbox-group/useAttrs.d.ts +11 -0
- package/ui.form-checkbox-multi-state/UCheckboxMultiState.vue.d.ts +24 -0
- package/ui.form-checkbox-multi-state/config.d.ts +10 -0
- package/ui.form-checkbox-multi-state/constants.d.ts +1 -0
- package/ui.form-checkbox-multi-state/storybook/stories.d.ts +187 -0
- package/ui.form-checkbox-multi-state/useAttrs.d.ts +13 -0
- package/ui.form-color-picker/UColorPicker.vue.d.ts +28 -0
- package/ui.form-color-picker/config.d.ts +42 -0
- package/ui.form-color-picker/constants.d.ts +1 -0
- package/ui.form-color-picker/storybook/stories.d.ts +316 -0
- package/ui.form-color-picker/useAttrs.d.ts +11 -0
- package/ui.form-date-picker/UDatePicker.vue.d.ts +135 -0
- package/ui.form-date-picker/config.d.ts +184 -0
- package/ui.form-date-picker/constants.d.ts +1 -0
- package/ui.form-date-picker/index.d.ts +1 -0
- package/ui.form-date-picker/storybook/stories.d.ts +3242 -0
- package/ui.form-date-picker/useAttrs.d.ts +14 -0
- package/ui.form-date-picker-range/UDatePickerRange.vue.d.ts +545 -0
- package/ui.form-date-picker-range/UDatePickerRangeInputs.vue.d.ts +6 -0
- package/ui.form-date-picker-range/UDatePickerRangePeriodMenu.vue.d.ts +7 -0
- package/ui.form-date-picker-range/config.d.ts +265 -0
- package/ui.form-date-picker-range/constants.d.ts +20 -0
- package/ui.form-date-picker-range/storybook/stories.d.ts +5545 -0
- package/ui.form-date-picker-range/useAttrs.d.ts +17 -0
- package/ui.form-date-picker-range/useUserFormat.d.ts +3 -0
- package/ui.form-date-picker-range/utilDateRange.d.ts +20 -0
- package/ui.form-date-picker-range/utilValidation.d.ts +3 -0
- package/ui.form-input/UInput.vue +1 -1
- package/ui.form-input/UInput.vue.d.ts +59 -0
- package/ui.form-input/config.d.ts +59 -0
- package/ui.form-input/constants.d.ts +1 -0
- package/ui.form-input/storybook/stories.d.ts +5734 -0
- package/ui.form-input/useAttrs.d.ts +11 -0
- package/ui.form-input-file/UInputFile.vue.d.ts +57 -0
- package/ui.form-input-file/config.d.ts +94 -0
- package/ui.form-input-file/constants.d.ts +1 -0
- package/ui.form-input-file/storybook/stories.d.ts +1116 -0
- package/ui.form-input-file/useAttrs.d.ts +11 -0
- package/ui.form-input-file/utilFileForm.d.ts +1 -0
- package/ui.form-input-money/UInputMoney.vue.d.ts +183 -0
- package/ui.form-input-money/config.d.ts +17 -0
- package/ui.form-input-money/constants.d.ts +1 -0
- package/ui.form-input-money/storybook/stories.d.ts +7519 -0
- package/ui.form-input-money/useAttrs.d.ts +11 -0
- package/ui.form-input-money/useFormatCurrency.d.ts +5 -0
- package/ui.form-input-money/useFormatCurrency.js +1 -1
- package/ui.form-input-money/utilFormat.d.ts +7 -0
- package/ui.form-input-number/UInputNumber.vue +4 -3
- package/ui.form-input-number/UInputNumber.vue.d.ts +30 -0
- package/ui.form-input-number/config.d.ts +40 -0
- package/ui.form-input-number/constants.d.ts +1 -0
- package/ui.form-input-number/storybook/stories.d.ts +363 -0
- package/ui.form-input-number/useAttrs.d.ts +11 -0
- package/ui.form-input-rating/UInputRating.vue.d.ts +49 -0
- package/ui.form-input-rating/config.d.ts +56 -0
- package/ui.form-input-rating/constants.d.ts +1 -0
- package/ui.form-input-rating/storybook/stories.d.ts +1336 -0
- package/ui.form-input-rating/useAttrs.d.ts +11 -0
- package/ui.form-input-search/UInputSearch.vue.d.ts +177 -0
- package/ui.form-input-search/config.d.ts +21 -0
- package/ui.form-input-search/constants.d.ts +1 -0
- package/ui.form-input-search/storybook/stories.d.ts +3325 -0
- package/ui.form-input-search/useAttrs.d.ts +11 -0
- package/ui.form-label/ULabel.vue.d.ts +46 -0
- package/ui.form-label/config.d.ts +139 -0
- package/ui.form-label/config.js +2 -2
- package/ui.form-label/constants.d.ts +8 -0
- package/ui.form-label/storybook/stories.d.ts +1133 -0
- package/ui.form-label/useAttrs.d.ts +11 -0
- package/ui.form-radio/URadio.vue.d.ts +46 -0
- package/ui.form-radio/config.d.ts +30 -0
- package/ui.form-radio/constants.d.ts +1 -0
- package/ui.form-radio/storybook/stories.d.ts +1270 -0
- package/ui.form-radio/useAttrs.d.ts +14 -0
- package/ui.form-radio-group/URadioGroup.vue.d.ts +40 -0
- package/ui.form-radio-group/config.d.ts +21 -0
- package/ui.form-radio-group/constants.d.ts +1 -0
- package/ui.form-radio-group/storybook/stories.d.ts +1239 -0
- package/ui.form-radio-group/useAttrs.d.ts +11 -0
- package/ui.form-select/USelect.vue.d.ts +405 -0
- package/ui.form-select/config.d.ts +146 -0
- package/ui.form-select/constants.d.ts +13 -0
- package/ui.form-select/storybook/stories.d.ts +19025 -0
- package/ui.form-select/useAttrs.d.ts +15 -0
- package/ui.form-select/utilSelect.d.ts +11 -0
- package/ui.form-switch/USwitch.vue.d.ts +30 -0
- package/ui.form-switch/config.d.ts +106 -0
- package/ui.form-switch/constants.d.ts +1 -0
- package/ui.form-switch/storybook/stories.d.ts +703 -0
- package/ui.form-switch/useAttrs.d.ts +13 -0
- package/ui.form-switch/utilVariant.d.ts +169 -0
- package/ui.form-textarea/UTextarea.vue.d.ts +132 -0
- package/ui.form-textarea/config.d.ts +55 -0
- package/ui.form-textarea/constants.d.ts +1 -0
- package/ui.form-textarea/storybook/stories.d.ts +2175 -0
- package/ui.form-textarea/useAttrs.d.ts +11 -0
- package/ui.image-avatar/UAvatar.vue.d.ts +40 -0
- package/ui.image-avatar/config.d.ts +51 -0
- package/ui.image-avatar/constants.d.ts +1 -0
- package/ui.image-avatar/storybook/stories.d.ts +1640 -0
- package/ui.image-avatar/useAttrs.d.ts +11 -0
- package/ui.image-icon/UIcon.vue.d.ts +28 -0
- package/ui.image-icon/config.d.ts +52 -0
- package/ui.image-icon/constants.d.ts +1 -0
- package/ui.image-icon/storybook/stories.d.ts +516 -0
- package/ui.image-icon/useAttrs.d.ts +11 -0
- package/ui.loader/ULoader.vue.d.ts +23 -0
- package/ui.loader/config.d.ts +49 -0
- package/ui.loader/constants.d.ts +2 -0
- package/ui.loader/storybook/stories.d.ts +655 -0
- package/ui.loader/useAttrs.d.ts +11 -0
- package/ui.loader-overlay/ULoaderOverlay.vue.d.ts +21 -0
- package/ui.loader-overlay/config.d.ts +25 -0
- package/ui.loader-overlay/constants.d.ts +1 -0
- package/ui.loader-overlay/storybook/stories.d.ts +362 -0
- package/ui.loader-overlay/useAttrs.d.ts +11 -0
- package/ui.loader-overlay/useLoaderOverlay.d.ts +10 -0
- package/ui.loader-overlay/utilLoaderOverlay.d.ts +2 -0
- package/ui.loader-progress/ULoaderProgress.vue.d.ts +11 -0
- package/ui.loader-progress/config.d.ts +24 -0
- package/ui.loader-progress/constants.d.ts +3 -0
- package/ui.loader-progress/storybook/stories.d.ts +742 -0
- package/ui.loader-progress/useAttrs.d.ts +11 -0
- package/ui.loader-progress/useLoaderProgress.d.ts +15 -0
- package/ui.loader-progress/utilLoaderProgress.d.ts +5 -0
- package/ui.navigation-pagination/UPagination.vue.d.ts +54 -0
- package/ui.navigation-pagination/config.d.ts +41 -0
- package/ui.navigation-pagination/constants.d.ts +1 -0
- package/ui.navigation-pagination/storybook/stories.d.ts +1033 -0
- package/ui.navigation-pagination/useAttrs.d.ts +11 -0
- package/ui.navigation-progress/StepperProgress.vue.d.ts +15 -0
- package/ui.navigation-progress/UProgress.vue.d.ts +41 -0
- package/ui.navigation-progress/config.d.ts +139 -0
- package/ui.navigation-progress/constants.d.ts +5 -0
- package/ui.navigation-progress/storybook/stories.d.ts +2827 -0
- package/ui.navigation-progress/useAttrs.d.ts +11 -0
- package/ui.navigation-tab/UTab.vue.d.ts +27 -0
- package/ui.navigation-tab/config.d.ts +24 -0
- package/ui.navigation-tab/constants.d.ts +1 -0
- package/ui.navigation-tab/storybook/stories.d.ts +316 -0
- package/ui.navigation-tab/useAttrs.d.ts +14 -0
- package/ui.navigation-tabs/UTabs.vue.d.ts +30 -0
- package/ui.navigation-tabs/config.d.ts +24 -0
- package/ui.navigation-tabs/constants.d.ts +1 -0
- package/ui.navigation-tabs/storybook/stories.d.ts +354 -0
- package/ui.navigation-tabs/useAttrs.d.ts +11 -0
- package/ui.other-dot/UDot.vue.d.ts +13 -0
- package/ui.other-dot/config.d.ts +28 -0
- package/ui.other-dot/constants.d.ts +1 -0
- package/ui.other-dot/storybook/stories.d.ts +645 -0
- package/ui.other-dot/useAttrs.d.ts +11 -0
- package/ui.text-alert/UAlert.vue.d.ts +53 -0
- package/ui.text-alert/config.d.ts +75 -0
- package/ui.text-alert/constants.d.ts +1 -0
- package/ui.text-alert/storybook/stories.d.ts +4845 -0
- package/ui.text-alert/useAttrs.d.ts +11 -0
- package/ui.text-badge/UBadge.vue.d.ts +60 -0
- package/ui.text-badge/config.d.ts +102 -0
- package/ui.text-badge/constants.d.ts +1 -0
- package/ui.text-badge/storybook/stories.d.ts +1869 -0
- package/ui.text-badge/useAttrs.d.ts +11 -0
- package/ui.text-block/UText.vue +18 -62
- package/ui.text-block/UText.vue.d.ts +21 -0
- package/ui.text-block/config.d.ts +27 -0
- package/ui.text-block/constants.d.ts +1 -0
- package/ui.text-block/storybook/Docs.mdx +2 -2
- package/ui.text-block/storybook/stories.d.ts +12 -0
- package/ui.text-block/storybook/{stories.js → stories.ts} +12 -7
- package/ui.text-block/types.d.ts +9 -0
- package/ui.text-block/types.ts +33 -0
- package/ui.text-block/useAttrs.d.ts +3 -0
- package/ui.text-block/useAttrs.ts +18 -0
- package/ui.text-empty/UEmpty.vue.d.ts +29 -0
- package/ui.text-empty/config.d.ts +55 -0
- package/ui.text-empty/constants.d.ts +1 -0
- package/ui.text-empty/storybook/stories.d.ts +1212 -0
- package/ui.text-empty/useAttrs.d.ts +11 -0
- package/ui.text-file/UFile.vue +12 -14
- package/ui.text-file/UFile.vue.d.ts +57 -0
- package/ui.text-file/config.d.ts +42 -0
- package/ui.text-file/config.js +12 -2
- package/ui.text-file/constants.d.ts +1 -0
- package/ui.text-file/storybook/stories.d.ts +136 -0
- package/ui.text-file/useAttrs.d.ts +11 -0
- package/ui.text-files/UFiles.vue.d.ts +52 -0
- package/ui.text-files/config.d.ts +10 -0
- package/ui.text-files/config.js +1 -1
- package/ui.text-files/constants.d.ts +1 -0
- package/ui.text-files/storybook/stories.d.ts +131 -0
- package/ui.text-files/useAttrs.d.ts +11 -0
- package/ui.text-header/UHeader.vue.d.ts +33 -0
- package/ui.text-header/config.d.ts +54 -0
- package/ui.text-header/constants.d.ts +1 -0
- package/ui.text-header/storybook/stories.d.ts +694 -0
- package/ui.text-header/useAttrs.d.ts +11 -0
- package/ui.text-money/UMoney.vue.d.ts +48 -0
- package/ui.text-money/config.d.ts +77 -0
- package/ui.text-money/constants.d.ts +1 -0
- package/ui.text-money/storybook/stories.d.ts +2090 -0
- package/ui.text-money/useAttrs.d.ts +11 -0
- package/ui.text-money/utilMoney.d.ts +14 -0
- package/ui.text-money/utilMoney.js +2 -2
- package/ui.text-notify/UNotify.vue.d.ts +13 -0
- package/ui.text-notify/config.d.ts +58 -0
- package/ui.text-notify/constants.d.ts +20 -0
- package/ui.text-notify/storybook/stories.d.ts +653 -0
- package/ui.text-notify/useAttrs.d.ts +11 -0
- package/ui.text-notify/utilNotify.d.ts +7 -0
- package/utils/utilHelper.d.ts +9 -0
- package/utils/utilPlatform.d.ts +6 -0
- package/utils/utilStorybook.d.ts +15 -0
- package/utils/utilUI.d.ts +68 -0
- package/utilsTs/utilHelper.d.ts +9 -0
- package/utilsTs/utilHelper.ts +70 -0
- package/utilsTs/utilPlatform.d.ts +7 -0
- package/utilsTs/utilPlatform.ts +53 -0
- package/utilsTs/utilStorybook.d.ts +24 -0
- package/utilsTs/utilStorybook.ts +292 -0
- package/utilsTs/utilTailwind.d.ts +1 -0
- package/utilsTs/utilTailwind.ts +38 -0
- package/utilsTs/utilTheme.d.ts +8 -0
- package/{utils/utilTheme.js → utilsTs/utilTheme.ts} +31 -27
- package/utilsTs/utilUI.d.ts +67 -0
- package/utilsTs/utilUI.ts +142 -0
- package/web-types.json +30 -120
- package/ui.text-block/useAttrs.js +0 -15
- /package/ui.text-block/{config.js → config.ts} +0 -0
- /package/ui.text-block/{constants.js → constants.ts} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, toValue, watch } from "vue";
|
|
2
|
+
import { isSSR } from "../utils/utilHelper.js";
|
|
3
|
+
|
|
4
|
+
import type { Ref } from "vue";
|
|
5
|
+
|
|
6
|
+
export function useMutationObserver(
|
|
7
|
+
target: Ref<HTMLElement | null>,
|
|
8
|
+
callBack: () => void,
|
|
9
|
+
config = { childList: true, attributes: true, characterData: true },
|
|
10
|
+
) {
|
|
11
|
+
if (isSSR) return;
|
|
12
|
+
|
|
13
|
+
const observer = new MutationObserver(callBack);
|
|
14
|
+
|
|
15
|
+
onMounted(() => {
|
|
16
|
+
if (!toValue(target)) return;
|
|
17
|
+
|
|
18
|
+
if (Array.isArray(toValue(target))) {
|
|
19
|
+
toValue(target).forEach((element) => {
|
|
20
|
+
observer.observe(element, config);
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
observer.observe(toValue(target), config);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => toValue(target),
|
|
29
|
+
() => {
|
|
30
|
+
if (Array.isArray(toValue(target))) {
|
|
31
|
+
toValue(target).forEach((element) => {
|
|
32
|
+
observer.observe(element, config);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
observer.observe(toValue(target), config);
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
deep: true,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
onBeforeUnmount(() => {
|
|
46
|
+
observer.disconnect();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return { observer };
|
|
50
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { setColor, getColor } from "../utilsTs/utilUI";
|
|
2
|
+
import type { Slot, ComputedRef } from "vue";
|
|
3
|
+
import type { BrandColors, Strategies, UnknownObject, Component, CVA, KeysToExtend } from "../types";
|
|
4
|
+
export default function useUI(defaultConfig: Component, propsConfigGetter?: () => typeof defaultConfig | undefined, topLevelClassKey?: string): {
|
|
5
|
+
config: import("vue").Ref<{
|
|
6
|
+
[x: string]: string | object | {
|
|
7
|
+
[x: string]: string | Record<string, string | object>;
|
|
8
|
+
base?: string | undefined;
|
|
9
|
+
variants?: UnknownObject | undefined;
|
|
10
|
+
compoundVariants?: ({
|
|
11
|
+
[x: string]: string | number | null | undefined;
|
|
12
|
+
class: string;
|
|
13
|
+
}[] & never[]) | undefined;
|
|
14
|
+
defaultVariants?: UnknownObject | undefined;
|
|
15
|
+
component: string;
|
|
16
|
+
} | undefined;
|
|
17
|
+
i18n?: UnknownObject | undefined;
|
|
18
|
+
defaults?: UnknownObject | undefined;
|
|
19
|
+
safelist?: (() => import("../types").TailwindSafelist[]) | undefined;
|
|
20
|
+
strategy?: Strategies | undefined;
|
|
21
|
+
transition?: {
|
|
22
|
+
enterFromClass?: string | undefined;
|
|
23
|
+
enterActiveClass?: string | undefined;
|
|
24
|
+
enterToClass?: string | undefined;
|
|
25
|
+
leaveFromClass?: string | undefined;
|
|
26
|
+
leaveActiveClass?: string | undefined;
|
|
27
|
+
leaveToClass?: string | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
safelistColors?: BrandColors | undefined;
|
|
30
|
+
}, Component | {
|
|
31
|
+
[x: string]: string | object | {
|
|
32
|
+
[x: string]: string | Record<string, string | object>;
|
|
33
|
+
base?: string | undefined;
|
|
34
|
+
variants?: UnknownObject | undefined;
|
|
35
|
+
compoundVariants?: ({
|
|
36
|
+
[x: string]: string | number | null | undefined;
|
|
37
|
+
class: string;
|
|
38
|
+
}[] & never[]) | undefined;
|
|
39
|
+
defaultVariants?: UnknownObject | undefined;
|
|
40
|
+
component: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
i18n?: UnknownObject | undefined;
|
|
43
|
+
defaults?: UnknownObject | undefined;
|
|
44
|
+
safelist?: (() => import("../types").TailwindSafelist[]) | undefined;
|
|
45
|
+
strategy?: Strategies | undefined;
|
|
46
|
+
transition?: {
|
|
47
|
+
enterFromClass?: string | undefined;
|
|
48
|
+
enterActiveClass?: string | undefined;
|
|
49
|
+
enterToClass?: string | undefined;
|
|
50
|
+
leaveFromClass?: string | undefined;
|
|
51
|
+
leaveActiveClass?: string | undefined;
|
|
52
|
+
leaveToClass?: string | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
safelistColors?: BrandColors | undefined;
|
|
55
|
+
}>;
|
|
56
|
+
setColor: typeof setColor;
|
|
57
|
+
getColor: typeof getColor;
|
|
58
|
+
getAttrs: (configKey: string, classes: ComputedRef) => import("vue").Ref<{}, {}>;
|
|
59
|
+
getKeysAttrs: (mutatedProps?: {}, extendingKeys?: string[], keysToExtendConfig?: Record<string, KeysToExtend>) => UnknownObject;
|
|
60
|
+
getExtendingKeysClasses: (extendingKeys: string[], mutatedProps?: {}) => UnknownObject;
|
|
61
|
+
isCVA: typeof isCVA;
|
|
62
|
+
isSystemKey: typeof isSystemKey;
|
|
63
|
+
hasSlotContent: typeof hasSlotContent;
|
|
64
|
+
};
|
|
65
|
+
declare function isSystemKey(key: string): boolean;
|
|
66
|
+
declare function isCVA(config: CVA | string): boolean;
|
|
67
|
+
export declare function hasSlotContent(slot: Slot | undefined | null, props?: {}): boolean;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
watch,
|
|
4
|
+
watchEffect,
|
|
5
|
+
getCurrentInstance,
|
|
6
|
+
toValue,
|
|
7
|
+
useAttrs,
|
|
8
|
+
Comment,
|
|
9
|
+
Text,
|
|
10
|
+
Fragment,
|
|
11
|
+
computed,
|
|
12
|
+
} from "vue";
|
|
13
|
+
|
|
14
|
+
import { cx, cva, setColor, getColor, vuelessConfig } from "../utilsTs/utilUI";
|
|
15
|
+
import { cloneDeep, isCSR } from "../utilsTs/utilHelper";
|
|
16
|
+
import {
|
|
17
|
+
STRATEGY_TYPE,
|
|
18
|
+
CVA_CONFIG_KEY,
|
|
19
|
+
SYSTEM_CONFIG_KEY,
|
|
20
|
+
NESTED_COMPONENT_REG_EXP,
|
|
21
|
+
} from "../constants.js";
|
|
22
|
+
|
|
23
|
+
import type { ComponentInternalInstance, Slot, VNode, ComputedRef } from "vue";
|
|
24
|
+
import type {
|
|
25
|
+
BrandColors,
|
|
26
|
+
Strategies,
|
|
27
|
+
UnknownObject,
|
|
28
|
+
VueAttrs,
|
|
29
|
+
Component,
|
|
30
|
+
NestedComponent,
|
|
31
|
+
ComponentNames,
|
|
32
|
+
CVA,
|
|
33
|
+
KeyAttrs,
|
|
34
|
+
KeysToExtend,
|
|
35
|
+
CVACompoundVariants,
|
|
36
|
+
} from "../types";
|
|
37
|
+
|
|
38
|
+
interface GetMergedConfig {
|
|
39
|
+
defaultConfig: Component;
|
|
40
|
+
globalConfig: Component;
|
|
41
|
+
propsConfig?: Component;
|
|
42
|
+
vuelessStrategy?: Strategies;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface MergeConfigs {
|
|
46
|
+
defaultConfig: Component & CVA;
|
|
47
|
+
globalConfig: Component & CVA;
|
|
48
|
+
propsConfig?: Component & CVA;
|
|
49
|
+
config?: Component & CVA;
|
|
50
|
+
isReplace?: boolean;
|
|
51
|
+
isVariants?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Merging component configs in a given sequence (bigger number = bigger priority):
|
|
56
|
+
* 1. Default component config
|
|
57
|
+
* 2. Custom global component config (/vueless.config.{js,ts})
|
|
58
|
+
* 3. Component config (:config="{...}" props)
|
|
59
|
+
* 4. Component classes (class="...")
|
|
60
|
+
*/
|
|
61
|
+
export default function useUI(
|
|
62
|
+
defaultConfig: Component,
|
|
63
|
+
propsConfigGetter?: () => typeof defaultConfig | undefined,
|
|
64
|
+
topLevelClassKey?: string,
|
|
65
|
+
) {
|
|
66
|
+
const { type, props } = getCurrentInstance() as ComponentInternalInstance;
|
|
67
|
+
const componentName = type.__name as ComponentNames;
|
|
68
|
+
let globalConfig = {};
|
|
69
|
+
|
|
70
|
+
if (vuelessConfig.component && componentName) {
|
|
71
|
+
globalConfig = vuelessConfig.component[componentName] as UnknownObject as Component;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const isStrategyValid =
|
|
75
|
+
vuelessConfig.strategy && Object.values(STRATEGY_TYPE).includes(vuelessConfig.strategy);
|
|
76
|
+
|
|
77
|
+
const vuelessStrategy = isStrategyValid
|
|
78
|
+
? (vuelessConfig.strategy as Strategies)
|
|
79
|
+
: (STRATEGY_TYPE.merge as Strategies);
|
|
80
|
+
|
|
81
|
+
const firstClassKey = defaultConfig ? Object.keys(defaultConfig)[0] : "";
|
|
82
|
+
const config = ref({} as Component);
|
|
83
|
+
const attrs = useAttrs();
|
|
84
|
+
|
|
85
|
+
watchEffect(() => {
|
|
86
|
+
const propsConfig = propsConfigGetter ? propsConfigGetter() : {};
|
|
87
|
+
|
|
88
|
+
const mergedConfig = getMergedConfig({
|
|
89
|
+
defaultConfig,
|
|
90
|
+
globalConfig,
|
|
91
|
+
propsConfig,
|
|
92
|
+
vuelessStrategy,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
config.value = mergeClassesIntoConfig(mergedConfig, topLevelClassKey || firstClassKey, attrs);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get classes by given key (including CVA if config set).
|
|
100
|
+
*/
|
|
101
|
+
function getClasses(key: string, mutatedProps: UnknownObject) {
|
|
102
|
+
return computed(() => {
|
|
103
|
+
const color = (toValue(mutatedProps)?.color as BrandColors) || props?.color;
|
|
104
|
+
const value = config.value[key] as CVA & NestedComponent;
|
|
105
|
+
|
|
106
|
+
let classes = "";
|
|
107
|
+
|
|
108
|
+
if (isCVA(value)) {
|
|
109
|
+
classes = cva(value)({
|
|
110
|
+
...props,
|
|
111
|
+
...toValue(mutatedProps),
|
|
112
|
+
...(color ? { color: getColor(color) } : {}),
|
|
113
|
+
});
|
|
114
|
+
} else if (value.component) {
|
|
115
|
+
// If the value of the key contains keys related to the nested component, it should be skipped.
|
|
116
|
+
// Probably this should be fixed later to be possible to extend key with nested component keys.
|
|
117
|
+
return "";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return color ? setColor(classes, color) : value;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get an object where:
|
|
126
|
+
* – key: extendingKey
|
|
127
|
+
* – value: reactive string of extendingKey classes.
|
|
128
|
+
*/
|
|
129
|
+
function getExtendingKeysClasses(extendingKeys: string[], mutatedProps = {}) {
|
|
130
|
+
const extendingClasses: UnknownObject = {};
|
|
131
|
+
|
|
132
|
+
for (const key of extendingKeys) {
|
|
133
|
+
extendingClasses[key] = getClasses(key, mutatedProps);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return extendingClasses;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get an object where:
|
|
141
|
+
* – key: elementKey
|
|
142
|
+
* – value: reactive object of string element attributes (with classes).
|
|
143
|
+
*/
|
|
144
|
+
function getKeysAttrs(
|
|
145
|
+
mutatedProps = {},
|
|
146
|
+
extendingKeys: string[] = [],
|
|
147
|
+
keysToExtendConfig: Record<string, KeysToExtend> = {},
|
|
148
|
+
) {
|
|
149
|
+
const keysToExtend = Object.keys(keysToExtendConfig);
|
|
150
|
+
const keysAttrs: UnknownObject = {};
|
|
151
|
+
|
|
152
|
+
for (const key in defaultConfig) {
|
|
153
|
+
if (isSystemKey(key) || extendingKeys.includes(key)) continue;
|
|
154
|
+
|
|
155
|
+
keysAttrs[`${key}Attrs`] = getAttrs(key, getClasses(key, mutatedProps));
|
|
156
|
+
|
|
157
|
+
if (keysToExtend.includes(key)) {
|
|
158
|
+
const { base, extend } = keysToExtendConfig[key];
|
|
159
|
+
const keyAttrs = keysAttrs[`${key}Attrs`] as ComputedRef<KeyAttrs>;
|
|
160
|
+
|
|
161
|
+
keysAttrs[`${key}Attrs`] = computed(() => ({
|
|
162
|
+
...keyAttrs.value,
|
|
163
|
+
class: cx([
|
|
164
|
+
...(Array.isArray(base) ? toValue(base) : [toValue(base)]),
|
|
165
|
+
keyAttrs.value.class,
|
|
166
|
+
...(Array.isArray(extend) ? toValue(extend) : [toValue(extend)]),
|
|
167
|
+
]),
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return keysAttrs;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get an element attributes for a given key.
|
|
177
|
+
*/
|
|
178
|
+
function getAttrs(configKey: string, classes: ComputedRef) {
|
|
179
|
+
const nestedComponent = getNestedComponent(defaultConfig[configKey] || "");
|
|
180
|
+
|
|
181
|
+
const attrs = useAttrs();
|
|
182
|
+
const isDev = isCSR && import.meta.env?.DEV;
|
|
183
|
+
const vuelessAttrs = ref({});
|
|
184
|
+
const isTopLevelKey = (topLevelClassKey || firstClassKey) === configKey;
|
|
185
|
+
|
|
186
|
+
const commonAttrs: KeyAttrs = {
|
|
187
|
+
...(isTopLevelKey ? attrs : {}),
|
|
188
|
+
"vl-component": isDev ? (attrs["vl-component"] as string) || componentName || null : null,
|
|
189
|
+
"vl-key": isDev ? (attrs["vl-config-key"] as string) || configKey || null : null,
|
|
190
|
+
"vl-child-component":
|
|
191
|
+
isDev && attrs["vl-component"] ? nestedComponent || componentName : null,
|
|
192
|
+
"vl-child-key": isDev && attrs["vl-component"] ? configKey : null,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Delete value key to prevent v-model overwrite
|
|
196
|
+
delete commonAttrs.value;
|
|
197
|
+
|
|
198
|
+
watch(config, updateVuelessAttrs, { immediate: true });
|
|
199
|
+
watch(props, updateVuelessAttrs);
|
|
200
|
+
|
|
201
|
+
if (classes?.value) {
|
|
202
|
+
watch(classes, updateVuelessAttrs);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function updateVuelessAttrs() {
|
|
206
|
+
const configKeyValue = config.value[configKey] as Component | string;
|
|
207
|
+
const isObject = typeof configKeyValue === "object";
|
|
208
|
+
|
|
209
|
+
const configAttrs = {
|
|
210
|
+
config: configKeyValue,
|
|
211
|
+
...(isObject ? configKeyValue.defaults : {}),
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
|
|
215
|
+
const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
|
|
216
|
+
|
|
217
|
+
vuelessAttrs.value = {
|
|
218
|
+
...commonAttrs,
|
|
219
|
+
class: cx([getBaseClasses(toValue(classes)), attrClass]),
|
|
220
|
+
...((isObject && configAttrs) || {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return vuelessAttrs;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
config,
|
|
229
|
+
setColor,
|
|
230
|
+
getColor,
|
|
231
|
+
getAttrs,
|
|
232
|
+
getKeysAttrs,
|
|
233
|
+
getExtendingKeysClasses,
|
|
234
|
+
isCVA,
|
|
235
|
+
isSystemKey,
|
|
236
|
+
hasSlotContent,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get merged config based on config merging strategy.
|
|
242
|
+
*/
|
|
243
|
+
function getMergedConfig({
|
|
244
|
+
defaultConfig,
|
|
245
|
+
globalConfig,
|
|
246
|
+
propsConfig,
|
|
247
|
+
vuelessStrategy,
|
|
248
|
+
}: GetMergedConfig) {
|
|
249
|
+
defaultConfig = cloneDeep(defaultConfig) as Component;
|
|
250
|
+
|
|
251
|
+
let mergedConfig: Component = {};
|
|
252
|
+
const strategy =
|
|
253
|
+
!globalConfig && !propsConfig
|
|
254
|
+
? STRATEGY_TYPE.merge
|
|
255
|
+
: propsConfig?.strategy || globalConfig?.strategy || vuelessStrategy;
|
|
256
|
+
|
|
257
|
+
if (strategy === STRATEGY_TYPE.merge) {
|
|
258
|
+
mergedConfig = mergeConfigs({ defaultConfig, globalConfig, propsConfig });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (strategy === STRATEGY_TYPE.replace) {
|
|
262
|
+
mergedConfig = mergeConfigs({ defaultConfig, globalConfig, propsConfig, isReplace: true });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (strategy === STRATEGY_TYPE.overwrite) {
|
|
266
|
+
const isGlobalConfig = globalConfig && Object.keys(globalConfig).length;
|
|
267
|
+
const isPropsConfig = propsConfig && Object.keys(propsConfig).length;
|
|
268
|
+
|
|
269
|
+
mergedConfig = isPropsConfig ? propsConfig : isGlobalConfig ? globalConfig : defaultConfig;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return mergedConfig;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Recursively merge config objects with removing tailwind classes duplicates.
|
|
277
|
+
* config - final merged config.
|
|
278
|
+
* isReplace - enables class replacement instead of merge.
|
|
279
|
+
* isVariants - if true, prevents adding a "base" key into nested objects.
|
|
280
|
+
*/
|
|
281
|
+
function mergeConfigs({
|
|
282
|
+
defaultConfig,
|
|
283
|
+
globalConfig,
|
|
284
|
+
propsConfig,
|
|
285
|
+
config = {},
|
|
286
|
+
isReplace = false,
|
|
287
|
+
isVariants = false,
|
|
288
|
+
}: MergeConfigs) {
|
|
289
|
+
globalConfig = cloneDeep(globalConfig || {}) as Component;
|
|
290
|
+
propsConfig = cloneDeep(propsConfig || {}) as Component;
|
|
291
|
+
|
|
292
|
+
const isGlobalConfig = Object.keys(globalConfig).length;
|
|
293
|
+
const isPropsConfig = Object.keys(propsConfig).length;
|
|
294
|
+
|
|
295
|
+
// Add unique keys from defaultConfig to composedConfig
|
|
296
|
+
const composedConfig = cloneDeep(defaultConfig) as Component & CVA;
|
|
297
|
+
|
|
298
|
+
// Add unique keys from globalConfig to composedConfig
|
|
299
|
+
for (const key in globalConfig) {
|
|
300
|
+
if (!Object.keys(composedConfig).includes(key)) {
|
|
301
|
+
composedConfig[key] = globalConfig[key];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Add unique keys from propsConfig to composedConfig
|
|
306
|
+
for (const key in propsConfig) {
|
|
307
|
+
if (!Object.keys(composedConfig).includes(key)) {
|
|
308
|
+
composedConfig[key] = propsConfig[key];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const {
|
|
313
|
+
i18n,
|
|
314
|
+
defaults,
|
|
315
|
+
strategy,
|
|
316
|
+
safelist,
|
|
317
|
+
component,
|
|
318
|
+
safelistColors,
|
|
319
|
+
defaultVariants,
|
|
320
|
+
compoundVariants,
|
|
321
|
+
} = SYSTEM_CONFIG_KEY;
|
|
322
|
+
|
|
323
|
+
for (const key in composedConfig) {
|
|
324
|
+
if (isGlobalConfig || isPropsConfig) {
|
|
325
|
+
if (key === safelist || key === safelistColors) {
|
|
326
|
+
if (propsConfig[key]) {
|
|
327
|
+
// eslint-disable-next-line no-console
|
|
328
|
+
console.warn(`Passing '${key}' key in 'config' prop is not allowed.`);
|
|
329
|
+
}
|
|
330
|
+
} else if (key === component) {
|
|
331
|
+
config[key] = propsConfig[key] || defaultConfig[key];
|
|
332
|
+
|
|
333
|
+
if (globalConfig[key]) {
|
|
334
|
+
// eslint-disable-next-line no-console
|
|
335
|
+
console.warn(`Passing '${key}' key in 'config' prop or by global config is not allowed.`);
|
|
336
|
+
}
|
|
337
|
+
} else if (key === strategy) {
|
|
338
|
+
config[key] = propsConfig[key] || globalConfig[key] || defaultConfig[key];
|
|
339
|
+
} else if (key === defaults || key === defaultVariants) {
|
|
340
|
+
config[key] = {
|
|
341
|
+
...(defaultConfig[key] as UnknownObject),
|
|
342
|
+
...(globalConfig[key] as UnknownObject),
|
|
343
|
+
...(propsConfig[key] as UnknownObject),
|
|
344
|
+
};
|
|
345
|
+
} else if (key === compoundVariants) {
|
|
346
|
+
config[key] = mergeCompoundVariants({
|
|
347
|
+
defaultConfig,
|
|
348
|
+
globalConfig,
|
|
349
|
+
propsConfig,
|
|
350
|
+
isReplace,
|
|
351
|
+
});
|
|
352
|
+
} else {
|
|
353
|
+
const isObjectComposedConfig = typeof composedConfig[key] === "object";
|
|
354
|
+
const isObjectGlobalConfig = typeof globalConfig[key] === "object";
|
|
355
|
+
const isObjectPropsConfig = typeof propsConfig[key] === "object";
|
|
356
|
+
|
|
357
|
+
const isObject = isObjectComposedConfig || isObjectGlobalConfig || isObjectPropsConfig;
|
|
358
|
+
const isEmpty = composedConfig[key] === null;
|
|
359
|
+
const isI18n = key === i18n;
|
|
360
|
+
|
|
361
|
+
if (key === "variants" && !isVariants) {
|
|
362
|
+
isVariants = true;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
config[key] =
|
|
366
|
+
isObject && !isEmpty && !isI18n
|
|
367
|
+
? mergeConfigs({
|
|
368
|
+
defaultConfig: stringToObject(composedConfig[key], { addBase: !isVariants }),
|
|
369
|
+
globalConfig: stringToObject(globalConfig[key], { addBase: !isVariants }),
|
|
370
|
+
propsConfig: stringToObject(propsConfig[key], { addBase: !isVariants }),
|
|
371
|
+
config: stringToObject(composedConfig[key], { addBase: !isVariants }),
|
|
372
|
+
isReplace,
|
|
373
|
+
isVariants,
|
|
374
|
+
})
|
|
375
|
+
: isReplace || isI18n
|
|
376
|
+
? propsConfig[key] || globalConfig[key] || defaultConfig[key]
|
|
377
|
+
: cx([defaultConfig[key], globalConfig[key], propsConfig[key]]);
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
config[key] = composedConfig[key];
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return config;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
Turn simplified nested component config to regular config.
|
|
389
|
+
*/
|
|
390
|
+
function stringToObject(
|
|
391
|
+
value: (CVA & Partial<NestedComponent>) | string | undefined,
|
|
392
|
+
{ addBase = false },
|
|
393
|
+
): CVA & Partial<NestedComponent> {
|
|
394
|
+
if (typeof value !== "object" && addBase) {
|
|
395
|
+
return { base: value || "" };
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return typeof value === "object" ? value : addBase ? { base: value || "" } : {};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
interface MergeCompoundVariants {
|
|
402
|
+
defaultConfig: CVA;
|
|
403
|
+
globalConfig: CVA;
|
|
404
|
+
propsConfig: CVA;
|
|
405
|
+
isReplace?: boolean;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Merge CVA compound variants arrays.
|
|
410
|
+
* isReplace - enables class replacement instead of merge.
|
|
411
|
+
*/
|
|
412
|
+
function mergeCompoundVariants({
|
|
413
|
+
defaultConfig,
|
|
414
|
+
globalConfig,
|
|
415
|
+
propsConfig,
|
|
416
|
+
isReplace,
|
|
417
|
+
}: MergeCompoundVariants) {
|
|
418
|
+
if (
|
|
419
|
+
(globalConfig.compoundVariants && !Array.isArray(globalConfig.compoundVariants)) ||
|
|
420
|
+
(propsConfig.compoundVariants && !Array.isArray(propsConfig.compoundVariants)) ||
|
|
421
|
+
(defaultConfig.compoundVariants && !Array.isArray(defaultConfig.compoundVariants))
|
|
422
|
+
) {
|
|
423
|
+
// eslint-disable-next-line no-console
|
|
424
|
+
console.error("CompoundVariants should be an array.");
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const globalConfigUniqueItems = cloneDeep(
|
|
428
|
+
globalConfig.compoundVariants || [],
|
|
429
|
+
) as CVACompoundVariants[];
|
|
430
|
+
const propsConfigUniqueItems = cloneDeep(
|
|
431
|
+
propsConfig.compoundVariants || [],
|
|
432
|
+
) as CVACompoundVariants[];
|
|
433
|
+
|
|
434
|
+
const config = (defaultConfig.compoundVariants as CVACompoundVariants[])?.map(
|
|
435
|
+
(defaultConfigItem) => {
|
|
436
|
+
/**
|
|
437
|
+
* Compare two objects by keys for match.
|
|
438
|
+
*/
|
|
439
|
+
function isSameItem(configItem: UnknownObject) {
|
|
440
|
+
const hasConfigItemKeys = Object.keys(defaultConfigItem)
|
|
441
|
+
.map((key) => defaultConfigItem[key] === configItem[key] || key === "class")
|
|
442
|
+
.every((item) => Boolean(item));
|
|
443
|
+
|
|
444
|
+
const hasDefaultConfigItemKeys = Object.keys(configItem)
|
|
445
|
+
.map((key) => defaultConfigItem[key] === configItem[key] || key === "class")
|
|
446
|
+
.every((item) => Boolean(item));
|
|
447
|
+
|
|
448
|
+
return hasConfigItemKeys && hasDefaultConfigItemKeys;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Find the same compound variant item in custom config if exist.
|
|
453
|
+
*/
|
|
454
|
+
function findItem(config = []): CVACompoundVariants | undefined {
|
|
455
|
+
const globalConfigUniqueItemIndex = globalConfigUniqueItems.findIndex(isSameItem);
|
|
456
|
+
const propsConfigUniqueItemIndex = propsConfigUniqueItems.findIndex(isSameItem);
|
|
457
|
+
|
|
458
|
+
if (~globalConfigUniqueItemIndex) {
|
|
459
|
+
globalConfigUniqueItems.splice(globalConfigUniqueItemIndex, 1);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (~propsConfigUniqueItemIndex) {
|
|
463
|
+
propsConfigUniqueItems.splice(propsConfigUniqueItemIndex, 1);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return config.find(isSameItem);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const globalConfigItem = findItem(globalConfig.compoundVariants);
|
|
470
|
+
const propsConfigItem = findItem(propsConfig.compoundVariants);
|
|
471
|
+
|
|
472
|
+
return globalConfigItem || propsConfigItem
|
|
473
|
+
? {
|
|
474
|
+
...defaultConfigItem,
|
|
475
|
+
class: isReplace
|
|
476
|
+
? propsConfigItem?.class || globalConfigItem?.class || defaultConfigItem.class
|
|
477
|
+
: cx([defaultConfigItem.class, globalConfigItem?.class, propsConfigItem?.class]),
|
|
478
|
+
}
|
|
479
|
+
: defaultConfigItem;
|
|
480
|
+
},
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
return [...config, ...globalConfigUniqueItems, ...propsConfigUniqueItems];
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Merge component classes from "class" attribute into final config.
|
|
488
|
+
*/
|
|
489
|
+
function mergeClassesIntoConfig(config: Component, topLevelClassKey: string, attrs: VueAttrs) {
|
|
490
|
+
const configTopKey = config[topLevelClassKey];
|
|
491
|
+
|
|
492
|
+
if (typeof configTopKey === "object") {
|
|
493
|
+
(configTopKey as CVA).base = cx([(configTopKey as CVA)?.base, attrs.class]);
|
|
494
|
+
|
|
495
|
+
config[topLevelClassKey] = configTopKey;
|
|
496
|
+
} else {
|
|
497
|
+
config[topLevelClassKey] = cx([configTopKey, attrs.class]);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return config;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Return base classes.
|
|
505
|
+
*/
|
|
506
|
+
function getBaseClasses(value: string | CVA | NestedComponent) {
|
|
507
|
+
return typeof value === "object" ? (value.base as string) || "" : value || "";
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Check is config key contains component name and if contains return it.
|
|
512
|
+
*/
|
|
513
|
+
function getNestedComponent(value: string | NestedComponent | CVA) {
|
|
514
|
+
const classes = getBaseClasses(value);
|
|
515
|
+
const component = (value as NestedComponent)?.component as ComponentNames;
|
|
516
|
+
|
|
517
|
+
const match =
|
|
518
|
+
classes.match(NESTED_COMPONENT_REG_EXP) || component?.match(NESTED_COMPONENT_REG_EXP);
|
|
519
|
+
|
|
520
|
+
return match ? match[1] : "";
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Check is config key not contains classes or CVA config object.
|
|
525
|
+
*/
|
|
526
|
+
function isSystemKey(key: string): boolean {
|
|
527
|
+
const isExactKey = Object.values(SYSTEM_CONFIG_KEY).some((value) => value === key);
|
|
528
|
+
|
|
529
|
+
return isExactKey || key.toLowerCase().includes(SYSTEM_CONFIG_KEY.transition.toLowerCase());
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Check is config contains default CVA keys.
|
|
534
|
+
*/
|
|
535
|
+
function isCVA(config: CVA | string): boolean {
|
|
536
|
+
if (typeof config !== "object") return false;
|
|
537
|
+
|
|
538
|
+
return Object.values(CVA_CONFIG_KEY).some((value) =>
|
|
539
|
+
Object.keys(config).some((key) => key === value),
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Check if slot defined, and have a content.
|
|
545
|
+
*/
|
|
546
|
+
export function hasSlotContent(slot: Slot | undefined | null, props = {}): boolean {
|
|
547
|
+
type Args = VNode | VNode[] | undefined | null;
|
|
548
|
+
|
|
549
|
+
const asArray = (arg: Args) => {
|
|
550
|
+
return Array.isArray(arg) ? arg : arg != null ? [arg] : [];
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
const isVNodeEmpty = (vnode: Args) => {
|
|
554
|
+
return (
|
|
555
|
+
!vnode ||
|
|
556
|
+
asArray(vnode).every(
|
|
557
|
+
(vnode) =>
|
|
558
|
+
vnode.type === Comment ||
|
|
559
|
+
(vnode.type === Text && !vnode.children?.length) ||
|
|
560
|
+
(vnode.type === Fragment && !vnode.children?.length),
|
|
561
|
+
)
|
|
562
|
+
);
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
return !isVNodeEmpty(slot?.(props));
|
|
566
|
+
}
|