@livestorm/ui-vue 1.1.2 → 2.0.0
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/README.md +164 -32
- package/components-vite.js +5 -5
- package/components.d.ts +3 -3
- package/dist/UiTimelineItem.vue_vue_type_style_index_0_lang-DOLFRKcb.mjs +5565 -0
- package/dist/a11y-DIdrv5Mn.mjs +66 -0
- package/dist/breakpoints.mjs +9 -0
- package/dist/bus.mjs +5 -0
- package/dist/components.mjs +213 -1550
- package/dist/index.mjs +84 -166
- package/dist/integrations.mjs +8 -0
- package/dist/layouts.mjs +236 -0
- package/dist/responsive.mjs +25 -0
- package/dist/slot.mjs +21 -0
- package/dist/toastDSV2-wMh-UMzW.mjs +74 -0
- package/dist/types/index.d.ts +84 -0
- package/dist/types/src/components/Toast/LayoutToasts.vue.d.ts +3 -0
- package/dist/types/src/components/Toast/ToastMessage.vue.d.ts +21 -0
- package/dist/types/src/components/Toast/toastDSV2.d.ts +102 -0
- package/dist/types/src/components/UiActionBar/UiActionBar.vue.d.ts +44 -0
- package/dist/types/src/components/UiActionBar/UiActionBarItem.vue.d.ts +47 -0
- package/dist/types/src/components/UiActionBar/UiActionBarSeparator.vue.d.ts +3 -0
- package/dist/types/src/components/UiActionBar/index.d.ts +4 -0
- package/dist/types/src/components/UiActionBar/types.d.ts +14 -0
- package/dist/types/src/components/UiAnimatedLogo/UiAnimatedLogo.vue.d.ts +10 -0
- package/dist/types/src/components/UiAnimatedLogo/animations-links.d.ts +3 -0
- package/dist/types/src/components/UiAvatar/UiAvatar.vue.d.ts +55 -0
- package/dist/types/src/components/UiAvatar/index.d.ts +1 -0
- package/dist/types/src/components/UiAvatarList/UiAvatarList.vue.d.ts +28 -0
- package/dist/types/src/components/UiAvatarList/index.d.ts +1 -0
- package/dist/types/src/components/UiBadge/UiBadge.vue.d.ts +47 -0
- package/dist/types/src/components/UiBadge/index.d.ts +1 -0
- package/dist/types/src/components/UiBanner/UiBanner.vue.d.ts +96 -0
- package/dist/types/src/components/UiBanner/index.d.ts +2 -0
- package/dist/types/src/components/UiBreadcrumb/UiBreadcrumb.vue.d.ts +15 -0
- package/dist/types/src/components/UiBreadcrumb/index.d.ts +2 -0
- package/dist/types/src/components/UiButton/UiButton.vue.d.ts +249 -0
- package/dist/types/src/components/UiButtonGroup/UiButtonGroup.vue.d.ts +42 -0
- package/dist/types/src/components/UiButtonGroup/UiButtonGroupItem.vue.d.ts +21 -0
- package/dist/types/src/components/UiButtonGroup/index.d.ts +3 -0
- package/dist/types/src/components/UiButtonGroup/types.d.ts +10 -0
- package/dist/types/src/components/UiCard/UiCard.vue.d.ts +31 -0
- package/dist/types/src/components/UiCarousel/UiCarousel.vue.d.ts +63 -0
- package/dist/types/src/components/UiCarousel/index.d.ts +2 -0
- package/dist/types/src/components/UiColorField/UiColorField.vue.d.ts +19 -0
- package/dist/types/src/components/UiColorField/index.d.ts +2 -0
- package/dist/types/src/components/UiColorField/types.d.ts +29 -0
- package/dist/types/src/components/UiColorPicker/UiColorPicker.vue.d.ts +35 -0
- package/dist/types/src/components/UiColorPicker/index.d.ts +2 -0
- package/dist/types/src/components/UiColorPicker/types.d.ts +97 -0
- package/dist/types/src/components/UiDialog/MarketplaceHeaderExample.vue.d.ts +28 -0
- package/dist/types/src/components/UiDialog/UiDialog.vue.d.ts +18 -0
- package/dist/types/src/components/UiDialog/UiDialogClose.vue.d.ts +10 -0
- package/dist/types/src/components/UiDialog/UiDialogContent.vue.d.ts +54 -0
- package/dist/types/src/components/UiDialog/UiDialogFooter.vue.d.ts +13 -0
- package/dist/types/src/components/UiDialog/UiDialogTrigger.vue.d.ts +14 -0
- package/dist/types/src/components/UiDialog/index.d.ts +7 -0
- package/dist/types/src/components/UiDropdown/UiDropdown.vue.d.ts +42 -0
- package/dist/types/src/components/UiDropdown/UiDropdownContent.vue.d.ts +32 -0
- package/dist/types/src/components/UiDropdown/UiDropdownItem.vue.d.ts +27 -0
- package/dist/types/src/components/UiDropdown/UiDropdownSeparator.vue.d.ts +3 -0
- package/dist/types/src/components/UiDropdown/UiDropdownTrigger.vue.d.ts +45 -0
- package/dist/types/src/components/UiDropdown/context.d.ts +7 -0
- package/dist/types/src/components/UiDropdown/index.d.ts +6 -0
- package/dist/types/src/components/UiEmptyState/UiEmptyState.vue.d.ts +29 -0
- package/dist/types/src/components/UiFieldWrapper/UiFieldWrapper.vue.d.ts +36 -0
- package/dist/types/src/components/UiFieldWrapper/index.d.ts +1 -0
- package/dist/types/src/components/UiForm/UiFormField.types.d.ts +22 -0
- package/dist/types/src/components/UiForm/UiFormField.vue.d.ts +34 -0
- package/dist/types/src/components/UiForm/index.d.ts +3 -0
- package/dist/types/src/components/UiHorizontalSeparator/UiHorizontalSeparator.vue.d.ts +6 -0
- package/dist/types/src/components/UiInputCheckbox/UiInputCheckbox.vue.d.ts +108 -0
- package/dist/types/src/components/UiInputCheckbox/index.d.ts +2 -0
- package/dist/types/src/components/UiInputCheckbox/types.d.ts +1 -0
- package/dist/types/src/components/UiInputSelect/UiInputSelect.vue.d.ts +66 -0
- package/dist/types/src/components/UiInputSelect/index.d.ts +2 -0
- package/dist/types/src/components/UiInputSelect/types.d.ts +1 -0
- package/dist/types/src/components/UiInputTextarea/UiInputTextarea.vue.d.ts +49 -0
- package/dist/types/src/components/UiInputTextarea/index.d.ts +2 -0
- package/dist/types/src/components/UiInputTextarea/types.d.ts +1 -0
- package/dist/types/src/components/UiLabel/UiLabel.vue.d.ts +17 -0
- package/dist/types/src/components/UiList/UiList.vue.d.ts +27 -0
- package/dist/types/src/components/UiListItem/UiListItem.vue.d.ts +35 -0
- package/dist/types/src/components/UiLoader/UiLoader.vue.d.ts +17 -0
- package/dist/types/src/components/UiLogo/UiLogo.vue.d.ts +20 -0
- package/dist/types/src/components/UiLogo/variants/PulseVariant.vue.d.ts +3 -0
- package/dist/types/src/components/UiLogo/variants/TornadoVariant.vue.d.ts +3 -0
- package/dist/types/src/components/UiMenu/UiMenu.vue.d.ts +18 -0
- package/dist/types/src/components/UiMenu/UiMenuContent.vue.d.ts +30 -0
- package/dist/types/src/components/UiMenu/UiMenuGroup.vue.d.ts +16 -0
- package/dist/types/src/components/UiMenu/UiMenuItem.vue.d.ts +18 -0
- package/dist/types/src/components/UiMenu/UiMenuLabel.vue.d.ts +13 -0
- package/dist/types/src/components/UiMenu/UiMenuSeparator.vue.d.ts +13 -0
- package/dist/types/src/components/UiMenu/UiMenuSub.vue.d.ts +18 -0
- package/dist/types/src/components/UiMenu/UiMenuSubContent.vue.d.ts +32 -0
- package/dist/types/src/components/UiMenu/UiMenuSubTrigger.vue.d.ts +14 -0
- package/dist/types/src/components/UiMenu/UiMenuTrigger.vue.d.ts +14 -0
- package/dist/types/src/components/UiMenu/index.d.ts +10 -0
- package/dist/types/src/components/UiPage/UiPage.vue.d.ts +37 -0
- package/dist/types/src/components/UiPageHeader/UiPageHeader.vue.d.ts +33 -0
- package/dist/types/src/components/UiPopover/UiPopover.vue.d.ts +18 -0
- package/dist/types/src/components/UiPopover/UiPopoverAnchor.vue.d.ts +14 -0
- package/dist/types/src/components/UiPopover/UiPopoverContent.vue.d.ts +28 -0
- package/dist/types/src/components/UiPopover/UiPopoverTrigger.vue.d.ts +14 -0
- package/dist/types/src/components/UiProgress/UiProgress.vue.d.ts +15 -0
- package/dist/types/src/components/UiProgress/index.d.ts +2 -0
- package/dist/types/src/components/UiProgress/types.d.ts +4 -0
- package/dist/types/src/components/UiRoomButton/UiRoomButton.vue.d.ts +29 -0
- package/dist/types/src/components/UiShell/UiShell.vue.d.ts +24 -0
- package/dist/types/src/components/UiSideMenu/UiSideMenu.vue.d.ts +64 -0
- package/dist/types/src/components/UiSideMenu/UiSideMenuBottom.vue.d.ts +7 -0
- package/dist/types/src/components/UiSideMenu/UiSideMenuItem.vue.d.ts +53 -0
- package/dist/types/src/components/UiSideMenu/UiSideMenuItemContent.vue.d.ts +43 -0
- package/dist/types/src/components/UiSideMenu/UiSideMenuTop.vue.d.ts +7 -0
- package/dist/types/src/components/UiSideMenu/injection.d.ts +7 -0
- package/dist/types/src/components/UiSideMenu/types.d.ts +39 -0
- package/dist/types/src/components/UiSideMenu/useLabelHidden.d.ts +2 -0
- package/dist/types/src/components/UiSideMenu/useSideMenuLayout.d.ts +7 -0
- package/dist/types/src/components/UiStepper/UiStepper.vue.d.ts +18 -0
- package/dist/types/src/components/UiStepper/UiStepperDescription.vue.d.ts +14 -0
- package/dist/types/src/components/UiStepper/UiStepperIndicator.vue.d.ts +20 -0
- package/dist/types/src/components/UiStepper/UiStepperItem.vue.d.ts +19 -0
- package/dist/types/src/components/UiStepper/UiStepperSeparator.vue.d.ts +10 -0
- package/dist/types/src/components/UiStepper/UiStepperTitle.vue.d.ts +14 -0
- package/dist/types/src/components/UiStepper/index.d.ts +7 -0
- package/dist/types/src/components/UiTable/UiTable.vue.d.ts +20 -0
- package/dist/types/src/components/UiTable/UiTableBody.vue.d.ts +13 -0
- package/dist/types/src/components/UiTable/UiTableCell.vue.d.ts +13 -0
- package/dist/types/src/components/UiTable/UiTableHeader.vue.d.ts +13 -0
- package/dist/types/src/components/UiTable/UiTableHeaderCell.vue.d.ts +13 -0
- package/dist/types/src/components/UiTable/UiTableRow.vue.d.ts +16 -0
- package/dist/types/src/components/UiTable/index.d.ts +6 -0
- package/dist/types/src/components/UiTabs/UiTabs.vue.d.ts +37 -0
- package/dist/types/src/components/UiTabs/index.d.ts +2 -0
- package/dist/types/src/components/UiTag/UiTag.vue.d.ts +43 -0
- package/dist/types/src/components/UiTag/index.d.ts +1 -0
- package/dist/types/src/components/UiTextField/UiTextField.vue.d.ts +65 -0
- package/dist/types/src/components/UiTextField/index.d.ts +2 -0
- package/dist/types/src/components/UiTextField/types.d.ts +2 -0
- package/dist/types/src/components/UiTimeline/UiTimeline.vue.d.ts +19 -0
- package/dist/types/src/components/UiTimeline/UiTimelineItem.vue.d.ts +28 -0
- package/dist/types/src/components/UiTimeline/index.d.ts +2 -0
- package/dist/types/src/components/UiTooltip/UiTooltip.vue.d.ts +18 -0
- package/dist/types/src/components/UiTooltip/UiTooltipContent.vue.d.ts +54 -0
- package/dist/types/src/components/UiTooltip/UiTooltipProvider.vue.d.ts +17 -0
- package/dist/types/src/components/UiTooltip/UiTooltipTrigger.vue.d.ts +14 -0
- package/dist/types/src/components/UiTooltip/index.d.ts +4 -0
- package/dist/types/src/composables/useButtonStyles.d.ts +20 -0
- package/dist/types/src/composables/useMobileMenu.d.ts +11 -0
- package/dist/types/src/composables/useThemeAndModes.d.ts +34 -0
- package/dist/types/src/constants/index.d.ts +2 -0
- package/dist/types/src/constants/sizes.d.ts +2 -0
- package/dist/types/src/constants/themes.d.ts +22 -0
- package/dist/types/src/integrations/index.d.ts +1 -0
- package/dist/types/src/layouts/index.d.ts +2 -0
- package/dist/types/src/mixins/DynamicAction.d.ts +30 -0
- package/dist/types/src/primitives.d.ts +6 -0
- package/dist/types/src/theme.d.ts +1 -0
- package/dist/types/src/utils/a11y.d.ts +2 -0
- package/dist/types/src/utils/breakpoints.d.ts +9 -0
- package/dist/types/src/utils/bus.d.ts +2 -0
- package/dist/types/src/utils/clipboard.d.ts +4 -0
- package/dist/types/src/utils/devices.d.ts +19 -0
- package/dist/types/src/utils/elements.d.ts +1 -0
- package/dist/types/src/utils/index.d.ts +9 -0
- package/dist/types/src/utils/numbers.d.ts +30 -0
- package/dist/types/src/utils/responsive.d.ts +5 -0
- package/dist/types/src/utils/responsive.types.d.ts +12 -0
- package/dist/types/src/utils/router.d.ts +1 -0
- package/dist/types/src/utils/slot.d.ts +8 -0
- package/dist/types/src/utils/stack-view.d.ts +10 -0
- package/dist/types/src/utils/uid.d.ts +1 -0
- package/dist/types/style.d.ts +1 -0
- package/dist/ui-vue.css +1 -0
- package/dist/useThemeAndModes-DY5SDC0a.mjs +109 -0
- package/dist/utils.mjs +111 -0
- package/index.d.ts +88 -2
- package/index.js +169 -16
- package/integrations.d.ts +10 -0
- package/package.json +127 -58
- package/src/components/Toast/LayoutToasts.vue +63 -0
- package/src/components/Toast/ToastMessage.vue +208 -0
- package/src/components/Toast/toastDSV2.ts +151 -0
- package/src/components/UiActionBar/UiActionBar.vue +86 -0
- package/src/components/UiActionBar/UiActionBarItem.vue +179 -0
- package/src/components/UiActionBar/UiActionBarSeparator.vue +18 -0
- package/src/components/UiActionBar/index.ts +4 -0
- package/src/components/UiActionBar/types.ts +24 -0
- package/src/components/UiAnimatedLogo/UiAnimatedLogo.vue +47 -0
- package/src/components/UiAnimatedLogo/animations-links.ts +6 -0
- package/src/components/UiAvatar/UiAvatar.vue +186 -0
- package/src/components/UiAvatar/index.js +1 -0
- package/src/components/UiAvatarList/UiAvatarList.vue +109 -0
- package/src/components/UiAvatarList/index.js +1 -0
- package/src/components/UiBadge/UiBadge.vue +161 -0
- package/src/components/UiBadge/index.ts +2 -0
- package/src/components/UiBanner/UiBanner.vue +363 -0
- package/src/components/UiBanner/index.ts +2 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.vue +93 -0
- package/src/components/UiBreadcrumb/index.ts +2 -0
- package/src/components/UiButton/UiButton.vue +319 -0
- package/src/components/UiButtonGroup/UiButtonGroup.vue +198 -0
- package/src/components/UiButtonGroup/UiButtonGroupItem.vue +123 -0
- package/src/components/UiButtonGroup/index.ts +3 -0
- package/src/components/UiButtonGroup/types.ts +24 -0
- package/src/components/UiCard/UiCard.vue +112 -0
- package/src/components/UiCarousel/UiCarousel.vue +215 -0
- package/src/components/UiCarousel/index.ts +2 -0
- package/src/components/UiColorField/UiColorField.vue +158 -0
- package/src/components/UiColorField/index.ts +2 -0
- package/src/components/UiColorField/types.ts +30 -0
- package/src/components/UiColorPicker/UiColorPicker.vue +487 -0
- package/src/components/UiColorPicker/index.ts +2 -0
- package/src/components/UiColorPicker/types.ts +103 -0
- package/src/components/UiDialog/MarketplaceHeaderExample.vue +217 -0
- package/src/components/UiDialog/UiDialog.md +97 -0
- package/src/components/UiDialog/UiDialog.vue +16 -0
- package/src/components/UiDialog/UiDialogClose.vue +29 -0
- package/src/components/UiDialog/UiDialogContent.vue +238 -0
- package/src/components/UiDialog/UiDialogFooter.vue +9 -0
- package/src/components/UiDialog/UiDialogTrigger.vue +12 -0
- package/src/components/UiDialog/index.ts +18 -0
- package/src/components/UiDropdown/UiDropdown.vue +48 -0
- package/src/components/UiDropdown/UiDropdownContent.vue +72 -0
- package/src/components/UiDropdown/UiDropdownItem.vue +75 -0
- package/src/components/UiDropdown/UiDropdownSeparator.vue +7 -0
- package/src/components/UiDropdown/UiDropdownTrigger.vue +239 -0
- package/src/components/UiDropdown/context.ts +9 -0
- package/src/components/UiDropdown/index.ts +21 -0
- package/src/components/UiEmptyState/UiEmptyState.vue +80 -0
- package/src/components/UiFieldWrapper/UiFieldWrapper.vue +79 -0
- package/src/components/UiFieldWrapper/index.ts +1 -0
- package/src/components/UiForm/UiFormField.types.ts +24 -0
- package/src/components/UiForm/UiFormField.vue +66 -0
- package/src/components/UiForm/index.ts +3 -0
- package/src/components/UiHorizontalSeparator/UiHorizontalSeparator.vue +28 -0
- package/src/components/UiInputCheckbox/UiInputCheckbox.vue +477 -0
- package/src/components/UiInputCheckbox/index.ts +2 -0
- package/src/components/UiInputCheckbox/types.ts +1 -0
- package/src/components/UiInputSelect/UiInputSelect.vue +166 -0
- package/src/components/UiInputSelect/index.ts +2 -0
- package/src/components/UiInputSelect/types.ts +1 -0
- package/src/components/UiInputTextarea/UiInputTextarea.vue +219 -0
- package/src/components/UiInputTextarea/index.ts +2 -0
- package/src/components/UiInputTextarea/types.ts +1 -0
- package/src/components/UiLabel/UiLabel.vue +34 -0
- package/src/components/UiList/UiList.vue +45 -0
- package/src/components/UiListItem/UiListItem.vue +108 -0
- package/src/components/UiLoader/UiLoader.vue +45 -0
- package/src/components/UiLogo/UiLogo.vue +99 -0
- package/src/components/UiLogo/variants/PulseVariant.vue +51 -0
- package/src/components/UiLogo/variants/TornadoVariant.vue +147 -0
- package/src/components/UiMenu/UiMenu.vue +15 -0
- package/src/components/UiMenu/UiMenuContent.vue +25 -0
- package/src/components/UiMenu/UiMenuGroup.vue +19 -0
- package/src/components/UiMenu/UiMenuItem.vue +18 -0
- package/src/components/UiMenu/UiMenuLabel.vue +9 -0
- package/src/components/UiMenu/UiMenuSeparator.vue +9 -0
- package/src/components/UiMenu/UiMenuSub.vue +15 -0
- package/src/components/UiMenu/UiMenuSubContent.vue +23 -0
- package/src/components/UiMenu/UiMenuSubTrigger.vue +17 -0
- package/src/components/UiMenu/UiMenuTrigger.vue +13 -0
- package/src/components/UiMenu/index.ts +10 -0
- package/src/components/UiPage/UiPage.vue +201 -0
- package/src/components/UiPageHeader/UiPageHeader.vue +128 -0
- package/src/components/UiPopover/UiPopover.vue +16 -0
- package/src/components/UiPopover/UiPopoverAnchor.vue +12 -0
- package/src/components/UiPopover/UiPopoverContent.vue +26 -0
- package/src/components/UiPopover/UiPopoverTrigger.vue +19 -0
- package/src/components/UiProgress/UiProgress.vue +92 -0
- package/src/components/UiProgress/index.ts +2 -0
- package/src/components/UiProgress/types.ts +5 -0
- package/src/components/UiRoomButton/UiRoomButton.vue +240 -0
- package/src/components/UiShell/UiShell.vue +88 -0
- package/src/components/UiSideMenu/UiSideMenu.vue +513 -0
- package/src/components/UiSideMenu/UiSideMenuBottom.vue +27 -0
- package/src/components/UiSideMenu/UiSideMenuItem.vue +102 -0
- package/src/components/UiSideMenu/UiSideMenuItemContent.vue +172 -0
- package/src/components/UiSideMenu/UiSideMenuTop.vue +29 -0
- package/src/components/UiSideMenu/injection.ts +9 -0
- package/src/components/UiSideMenu/types.ts +41 -0
- package/src/components/UiSideMenu/useLabelHidden.ts +33 -0
- package/src/components/UiSideMenu/useSideMenuLayout.ts +12 -0
- package/src/components/UiStepper/UiStepper.vue +40 -0
- package/src/components/UiStepper/UiStepperDescription.vue +27 -0
- package/src/components/UiStepper/UiStepperIndicator.vue +93 -0
- package/src/components/UiStepper/UiStepperItem.vue +30 -0
- package/src/components/UiStepper/UiStepperSeparator.vue +49 -0
- package/src/components/UiStepper/UiStepperTitle.vue +24 -0
- package/src/components/UiStepper/index.ts +17 -0
- package/src/components/UiTable/UiTable.vue +24 -0
- package/src/components/UiTable/UiTableBody.vue +5 -0
- package/src/components/UiTable/UiTableCell.vue +26 -0
- package/src/components/UiTable/UiTableHeader.vue +17 -0
- package/src/components/UiTable/UiTableHeaderCell.vue +19 -0
- package/src/components/UiTable/UiTableRow.vue +27 -0
- package/src/components/UiTable/index.ts +6 -0
- package/src/components/UiTabs/UiTabs.vue +218 -0
- package/src/components/UiTabs/index.ts +5 -0
- package/src/components/UiTag/UiTag.vue +187 -0
- package/src/components/UiTag/index.js +1 -0
- package/src/components/UiTextField/UiTextField.vue +370 -0
- package/src/components/UiTextField/index.ts +2 -0
- package/src/components/UiTextField/types.ts +2 -0
- package/src/components/UiTimeline/README.md +169 -0
- package/src/components/UiTimeline/UiTimeline.vue +58 -0
- package/src/components/UiTimeline/UiTimelineItem.vue +141 -0
- package/src/components/UiTimeline/index.ts +2 -0
- package/src/components/UiTooltip/UiTooltip.vue +16 -0
- package/src/components/UiTooltip/UiTooltipContent.vue +86 -0
- package/src/components/UiTooltip/UiTooltipProvider.vue +15 -0
- package/src/components/UiTooltip/UiTooltipTrigger.vue +19 -0
- package/src/components/UiTooltip/index.js +4 -0
- package/src/composables/useButtonStyles.ts +242 -0
- package/src/composables/useMobileMenu.ts +57 -0
- package/src/composables/useThemeAndModes.ts +225 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/sizes.ts +2 -0
- package/src/constants/themes.ts +34 -0
- package/src/css/{body.postcss → body.css} +3 -2
- package/src/css/reka-animations.css +209 -0
- package/src/css/{transitions.postcss → transitions.css} +12 -5
- package/src/global.d.ts +181 -0
- package/src/integrations/index.js +1 -0
- package/src/layouts/index.js +5 -0
- package/src/mixins/DynamicAction.js +5 -3
- package/src/primitives.ts +6 -0
- package/src/theme.ts +1 -0
- package/src/utils/a11y.ts +8 -0
- package/src/utils/{breakpoints.js → breakpoints.ts} +1 -0
- package/src/utils/clipboard.js +2 -2
- package/src/utils/devices.js +0 -3
- package/src/utils/index.js +2 -1
- package/src/utils/numbers.ts +61 -0
- package/src/utils/responsive.types.ts +12 -0
- package/src/utils/{slot.js → slot.ts} +18 -1
- package/style.js +3 -12
- package/theme.d.ts +1 -0
- package/.env +0 -1
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -47
- package/.pkg +0 -11
- package/babel.config.js +0 -5
- package/build/Dockerfile +0 -31
- package/ci/ci.yml +0 -54
- package/components-webpack.js +0 -29
- package/dist/environment-e70e5768.mjs +0 -1664
- package/dist/style.css +0 -1
- package/plugins.js +0 -17
- package/postcss.config.js +0 -1
- package/src/components/BaseAutocomplete/BaseAutocomplete.spec.js +0 -506
- package/src/components/BaseAutocomplete/BaseAutocomplete.stories.js +0 -184
- package/src/components/BaseAutocomplete/BaseAutocomplete.vue +0 -431
- package/src/components/BaseBanner/BaseBanner.spec.js +0 -32
- package/src/components/BaseBanner/BaseBanner.stories.js +0 -133
- package/src/components/BaseBanner/BaseBanner.vue +0 -229
- package/src/components/BaseButton/BaseButton.spec.js +0 -98
- package/src/components/BaseButton/BaseButton.stories.js +0 -291
- package/src/components/BaseButton/BaseButton.vue +0 -193
- package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap +0 -37
- package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap.old +0 -31
- package/src/components/BaseCheckbox/BaseCheckbox.stories.js +0 -82
- package/src/components/BaseCheckbox/BaseCheckbox.vue +0 -161
- package/src/components/BaseDropdownMenu/BaseDropdownMenu.stories.js +0 -84
- package/src/components/BaseDropdownMenu/BaseDropdownMenu.vue +0 -251
- package/src/components/BaseDropdownMenu/BaseDropdownMenuButton.vue +0 -26
- package/src/components/BaseDropdownMenu/BaseDropdownMenuDivider.vue +0 -10
- package/src/components/BaseDropdownMenu/BaseDropdownMenuItem.vue +0 -206
- package/src/components/BaseDropdownMenu/BaseDropdownMenuSearch.vue +0 -49
- package/src/components/BaseDropdownMenu/BaseDropdownMenuTitle.vue +0 -26
- package/src/components/BaseModal/BaseModal.stories.js +0 -143
- package/src/components/BaseModal/BaseModal.vue +0 -187
- package/src/components/BaseModal/BaseModalContent.vue +0 -164
- package/src/components/BaseModal/BaseModalContentOld.vue +0 -242
- package/src/components/BaseRating/BaseRating.spec.js +0 -46
- package/src/components/BaseRating/BaseRating.stories.js +0 -46
- package/src/components/BaseRating/BaseRating.vue +0 -119
- package/src/components/BaseSelect/BaseSelect.stories.js +0 -177
- package/src/components/BaseSelect/BaseSelect.vue +0 -443
- package/src/components/BaseSelect/BaseSelectGroup.vue +0 -34
- package/src/components/BaseSelect/BaseSelectOption.vue +0 -219
- package/src/components/BaseSwitch/BaseSwitch.stories.js +0 -44
- package/src/components/BaseSwitch/BaseSwitch.vue +0 -114
- package/src/components/BaseTag/BaseTag.stories.js +0 -123
- package/src/components/BaseTag/BaseTag.vue +0 -244
- package/src/css/button.postcss +0 -354
- package/src/css/checkbox-radio.postcss +0 -152
- package/src/css/icon.postcss +0 -9
- package/src/css/loader.postcss +0 -120
- package/src/css/popper.postcss +0 -143
- package/src/css/tailwind-utilities.postcss +0 -1
- package/src/css/tailwind.postcss +0 -2
- package/style-postcss.d.ts +0 -3
- package/style-postcss.js +0 -2
- package/tailwind.config.base.cjs +0 -88
- package/tailwind.config.js +0 -9
- package/tsconfig.check.json +0 -13
- package/tsconfig.json +0 -66
- package/vite.config.js +0 -43
- package/vitest.setup.js +0 -26
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="component.is"
|
|
4
|
+
v-bind="component.props"
|
|
5
|
+
:aria-label="!isLink ? labelFinal : undefined"
|
|
6
|
+
class="ui-button group align-center flex justify-center rounded-lg relative transition-all duration-150 focus-indicator-none"
|
|
7
|
+
:class="[
|
|
8
|
+
buttonClasses,
|
|
9
|
+
textClasses,
|
|
10
|
+
borderClasses,
|
|
11
|
+
{ 'cursor-pointer': !finalDisabled },
|
|
12
|
+
{ 'opacity-50 cursor-not-allowed': finalDisabled }
|
|
13
|
+
]"
|
|
14
|
+
data-testid="ui-button"
|
|
15
|
+
@click="onClick"
|
|
16
|
+
@mouseenter="$emit('mouseenter')"
|
|
17
|
+
@mouseleave="$emit('mouseleave')"
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
class="absolute h-full top-0 left-0 z-0 rounded-md w-full"
|
|
21
|
+
:class="[bgClasses, focusRingClasses]"
|
|
22
|
+
/>
|
|
23
|
+
<div
|
|
24
|
+
class="button-overlay absolute h-full top-0 left-0 z-10 rounded-md w-full"
|
|
25
|
+
:class="overlayClasses"
|
|
26
|
+
/>
|
|
27
|
+
<div
|
|
28
|
+
v-tooltip="tooltip"
|
|
29
|
+
class="button-wrapper flex items-center whitespace-nowrap h-full relative z-20"
|
|
30
|
+
>
|
|
31
|
+
<!-- Loader -->
|
|
32
|
+
<UiLoader
|
|
33
|
+
v-if="loading"
|
|
34
|
+
:size="size"
|
|
35
|
+
:class="{ 'mr-2': hasLabel }"
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<!-- Content -->
|
|
39
|
+
<template
|
|
40
|
+
v-else-if="showIconLeft"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
v-if="iconSlot"
|
|
44
|
+
:class="[iconSizeClasses, { 'mr-2': hasLabel }]"
|
|
45
|
+
class="shrink-0"
|
|
46
|
+
>
|
|
47
|
+
<RenderSlot
|
|
48
|
+
:vnodes="iconSlot"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
<div
|
|
52
|
+
v-else-if="imageSource"
|
|
53
|
+
:class="[iconSizeClasses, { 'mr-2': hasLabel }]"
|
|
54
|
+
class="shrink-0"
|
|
55
|
+
>
|
|
56
|
+
<img
|
|
57
|
+
:src="imageSource"
|
|
58
|
+
:alt="`${labelFinal} button image`"
|
|
59
|
+
>
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
v-else-if="icon"
|
|
63
|
+
:class="[icon, iconSizeClasses, { 'mr-2': hasLabel }]"
|
|
64
|
+
class="shrink-0"
|
|
65
|
+
/>
|
|
66
|
+
</template>
|
|
67
|
+
<span
|
|
68
|
+
class="content w-full"
|
|
69
|
+
>
|
|
70
|
+
<RenderSlot
|
|
71
|
+
:vnodes="defaultSlot"
|
|
72
|
+
/>
|
|
73
|
+
</span>
|
|
74
|
+
<div
|
|
75
|
+
v-if="iconRight"
|
|
76
|
+
:class="[iconRight, iconSizeClasses, { 'ml-2': hasLabel }]"
|
|
77
|
+
class="shrink-0"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</component>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script lang="ts">
|
|
84
|
+
import { computed, getCurrentInstance, watch } from 'vue'
|
|
85
|
+
import { useSlotsAsComponents, RenderSlot } from '../../utils/slot'
|
|
86
|
+
import { SIZES, type Size } from '../../constants'
|
|
87
|
+
import { useButtonStyles, BUTTON_COLORS, type ButtonVariant, type ButtonColor } from '../../composables/useButtonStyles'
|
|
88
|
+
import UiLoader from '../UiLoader/UiLoader.vue'
|
|
89
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
90
|
+
|
|
91
|
+
export type Variant = ButtonVariant
|
|
92
|
+
const COLORS = BUTTON_COLORS
|
|
93
|
+
export type Color = ButtonColor
|
|
94
|
+
|
|
95
|
+
export default {
|
|
96
|
+
components: {
|
|
97
|
+
RenderSlot,
|
|
98
|
+
UiLoader,
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
props: {
|
|
102
|
+
variant: {
|
|
103
|
+
type: String as () => Variant,
|
|
104
|
+
default: 'cta',
|
|
105
|
+
},
|
|
106
|
+
size: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: 'md',
|
|
109
|
+
validator: (value: Size) => SIZES.includes(value),
|
|
110
|
+
},
|
|
111
|
+
color: {
|
|
112
|
+
type: String as () => Color,
|
|
113
|
+
default: 'primary',
|
|
114
|
+
validator: (value: Color) => COLORS.includes(value),
|
|
115
|
+
},
|
|
116
|
+
disabled: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false,
|
|
119
|
+
},
|
|
120
|
+
showIconLeft: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: true,
|
|
123
|
+
},
|
|
124
|
+
icon: {
|
|
125
|
+
type: [String, Boolean],
|
|
126
|
+
default: undefined,
|
|
127
|
+
},
|
|
128
|
+
label: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: undefined,
|
|
131
|
+
},
|
|
132
|
+
iconRight: {
|
|
133
|
+
type: [String, Boolean],
|
|
134
|
+
default: undefined,
|
|
135
|
+
},
|
|
136
|
+
loading: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false,
|
|
139
|
+
},
|
|
140
|
+
imageSource: {
|
|
141
|
+
type: String,
|
|
142
|
+
default: undefined,
|
|
143
|
+
},
|
|
144
|
+
tooltip: {
|
|
145
|
+
type: [String, Object],
|
|
146
|
+
default: undefined,
|
|
147
|
+
},
|
|
148
|
+
type: {
|
|
149
|
+
type: String,
|
|
150
|
+
default: 'button',
|
|
151
|
+
},
|
|
152
|
+
href: {
|
|
153
|
+
type: String,
|
|
154
|
+
default: undefined,
|
|
155
|
+
},
|
|
156
|
+
to: {
|
|
157
|
+
type: Object as () => RouteLocationRaw,
|
|
158
|
+
default: undefined,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
emits: [
|
|
163
|
+
'click',
|
|
164
|
+
'mouseenter',
|
|
165
|
+
'mouseleave',
|
|
166
|
+
],
|
|
167
|
+
|
|
168
|
+
// * The script setup syntax would be the better way to have good typing of the props argument.
|
|
169
|
+
setup (props: any) {
|
|
170
|
+
const slots = useSlotsAsComponents()
|
|
171
|
+
const defaultSlot = computed(() => slots.default && slots.default())
|
|
172
|
+
const iconSlot = computed(() => slots.icon && slots.icon())
|
|
173
|
+
const hasLabel = computed<boolean>(() => !!defaultSlot.value)
|
|
174
|
+
const isSquare = computed(() => !hasLabel.value && !defaultSlot.value && (!!props.icon || !!props.iconRight))
|
|
175
|
+
|
|
176
|
+
// Disabled status
|
|
177
|
+
const finalDisabled = computed(() => props.disabled || props.loading)
|
|
178
|
+
|
|
179
|
+
// Can be "<router-link", "<button>" or "<a>"
|
|
180
|
+
const component = computed(() => {
|
|
181
|
+
const isDisabled = finalDisabled.value
|
|
182
|
+
|
|
183
|
+
// Disabled links should render as buttons for accessibility
|
|
184
|
+
if (isDisabled && (props.to || props.href)) {
|
|
185
|
+
return {
|
|
186
|
+
is: 'button',
|
|
187
|
+
props: {
|
|
188
|
+
type: 'button',
|
|
189
|
+
disabled: true,
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (props.to) {
|
|
195
|
+
return {
|
|
196
|
+
is: 'router-link',
|
|
197
|
+
props: {
|
|
198
|
+
to: props.to,
|
|
199
|
+
},
|
|
200
|
+
}
|
|
201
|
+
} else if (props.href) {
|
|
202
|
+
return {
|
|
203
|
+
is: 'a',
|
|
204
|
+
props: {
|
|
205
|
+
href: props.href,
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
return {
|
|
210
|
+
is: 'button',
|
|
211
|
+
props: {
|
|
212
|
+
type: props.type,
|
|
213
|
+
disabled: isDisabled,
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
// Check if component is a link (to apply inline-block) - only when not disabled
|
|
220
|
+
const isLink = computed(() => !finalDisabled.value && (!!props.href || !!props.to))
|
|
221
|
+
|
|
222
|
+
// Icon size classes
|
|
223
|
+
const iconSizeClasses = computed(() => ({
|
|
224
|
+
'size-3': props.size === 'sm',
|
|
225
|
+
'size-4': props.size === 'md',
|
|
226
|
+
'size-5': props.size === 'lg',
|
|
227
|
+
}))
|
|
228
|
+
|
|
229
|
+
// Label value
|
|
230
|
+
const labelFinal = computed(() => {
|
|
231
|
+
// Try to get label from slot or prop
|
|
232
|
+
const explicitLabel = ((defaultSlot.value && typeof defaultSlot.value[0].children === 'string' && defaultSlot.value[0].children) || props.label)?.trim()
|
|
233
|
+
if (explicitLabel) return explicitLabel
|
|
234
|
+
|
|
235
|
+
// Fallback: generate label from icon for icon-only buttons
|
|
236
|
+
if (isSquare.value && props.icon && typeof props.icon === 'string') {
|
|
237
|
+
// Extract readable name from icon class (e.g. "i-ls-settings" -> "settings")
|
|
238
|
+
const iconName = props.icon.replace(/^i-ls-/, '').replace(/-/g, ' ')
|
|
239
|
+
return iconName ? `${iconName} icon` : 'icon'
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return undefined
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
// Handle click
|
|
246
|
+
const instance = getCurrentInstance()
|
|
247
|
+
function onClick (event: Event) {
|
|
248
|
+
if (finalDisabled.value) {
|
|
249
|
+
event.preventDefault()
|
|
250
|
+
} else {
|
|
251
|
+
instance?.emit('click', event)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Style: Dynamic button classes
|
|
256
|
+
const buttonClasses = computed(() => [
|
|
257
|
+
{
|
|
258
|
+
'size-8': isSquare.value && props.size === 'sm',
|
|
259
|
+
'size-10': isSquare.value && props.size === 'md',
|
|
260
|
+
'size-12': isSquare.value && props.size === 'lg',
|
|
261
|
+
},
|
|
262
|
+
{ 'grid place-items-center': isSquare.value },
|
|
263
|
+
{
|
|
264
|
+
'h-8 text-action-button-sm': props.size === 'sm',
|
|
265
|
+
'h-10 text-action-button-md': props.size === 'md',
|
|
266
|
+
'h-12 text-action-button-lg': props.size === 'lg',
|
|
267
|
+
},
|
|
268
|
+
props.size === 'sm' ? 'px-2.5' : props.size === 'lg' ? 'px-4' : 'px-3',
|
|
269
|
+
// Links should be inline-flex to prevent full width while maintaining flex centering
|
|
270
|
+
{ 'inline-flex': isLink.value },
|
|
271
|
+
])
|
|
272
|
+
|
|
273
|
+
// Style: variant × color visual language — shared with `UiDropdownTrigger`
|
|
274
|
+
// via `useButtonStyles` so both stay pixel-identical.
|
|
275
|
+
const {
|
|
276
|
+
bgClass,
|
|
277
|
+
textClass,
|
|
278
|
+
borderClasses,
|
|
279
|
+
overlayClasses,
|
|
280
|
+
} = useButtonStyles({
|
|
281
|
+
variant: () => props.variant,
|
|
282
|
+
color: () => props.color,
|
|
283
|
+
disabled: finalDisabled,
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
const bgClasses = bgClass
|
|
287
|
+
const textClasses = computed(() => textClass.value ? [textClass.value] : [])
|
|
288
|
+
|
|
289
|
+
// Style: Focus ring color
|
|
290
|
+
const focusRingClasses = 'group-focus-visible:ring-2 group-focus-visible:ring-inset group-focus-visible:ring-focus-ring'
|
|
291
|
+
|
|
292
|
+
// Validation: warn if no label or icon provided
|
|
293
|
+
watch(() => !props.label && !props.icon && !props.iconRight && !defaultSlot.value, (isEmpty) => {
|
|
294
|
+
if (isEmpty) {
|
|
295
|
+
console.warn('UiButton: You must provide a label or an icon to the button')
|
|
296
|
+
}
|
|
297
|
+
}, { immediate: true })
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
component,
|
|
301
|
+
defaultSlot,
|
|
302
|
+
iconSlot,
|
|
303
|
+
hasLabel,
|
|
304
|
+
isLink,
|
|
305
|
+
iconSizeClasses,
|
|
306
|
+
buttonClasses,
|
|
307
|
+
bgClasses,
|
|
308
|
+
focusRingClasses,
|
|
309
|
+
textClasses,
|
|
310
|
+
borderClasses,
|
|
311
|
+
overlayClasses,
|
|
312
|
+
isSquare,
|
|
313
|
+
finalDisabled,
|
|
314
|
+
labelFinal,
|
|
315
|
+
onClick,
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
}
|
|
319
|
+
</script>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ToggleGroupRoot } from 'reka-ui'
|
|
3
|
+
import type { AcceptableValue } from 'reka-ui'
|
|
4
|
+
import { useDebounceFn, useResizeObserver } from '@vueuse/core'
|
|
5
|
+
import { computed, nextTick, onMounted, provide, ref, watch } from 'vue'
|
|
6
|
+
import type { ButtonGroupColor, ButtonGroupSize } from './types'
|
|
7
|
+
import {
|
|
8
|
+
BUTTON_GROUP_COLOR_KEY,
|
|
9
|
+
BUTTON_GROUP_REGISTER_KEY,
|
|
10
|
+
BUTTON_GROUP_SIZE_KEY,
|
|
11
|
+
} from './types'
|
|
12
|
+
|
|
13
|
+
interface UiButtonGroupProps {
|
|
14
|
+
modelValue?: string
|
|
15
|
+
defaultValue?: string
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
size?: ButtonGroupSize
|
|
18
|
+
color?: ButtonGroupColor
|
|
19
|
+
name?: string
|
|
20
|
+
orientation?: 'horizontal' | 'vertical'
|
|
21
|
+
/**
|
|
22
|
+
* When false (default), clicking the selected item is a no-op — matches
|
|
23
|
+
* radio-group semantics where exactly one option is always selected.
|
|
24
|
+
* Set to true to allow clearing the selection by clicking the active item.
|
|
25
|
+
*/
|
|
26
|
+
allowDeselect?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<UiButtonGroupProps>(), {
|
|
30
|
+
size: 'md',
|
|
31
|
+
color: 'neutral',
|
|
32
|
+
orientation: 'horizontal',
|
|
33
|
+
disabled: false,
|
|
34
|
+
allowDeselect: false,
|
|
35
|
+
modelValue: undefined,
|
|
36
|
+
defaultValue: undefined,
|
|
37
|
+
name: undefined,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits<{
|
|
41
|
+
'update:modelValue': [value: string | undefined]
|
|
42
|
+
}>()
|
|
43
|
+
|
|
44
|
+
provide(BUTTON_GROUP_SIZE_KEY, computed(() => props.size))
|
|
45
|
+
provide(BUTTON_GROUP_COLOR_KEY, computed(() => props.color))
|
|
46
|
+
|
|
47
|
+
// --- Sliding indicator -----------------------------------------------------
|
|
48
|
+
// Each item registers its DOM node on mount. When the selected value or
|
|
49
|
+
// layout changes, we measure the active item and reposition a single absolute
|
|
50
|
+
// <div> whose transform + width + height transition smoothly.
|
|
51
|
+
|
|
52
|
+
const itemEls = new Map<string, HTMLElement>()
|
|
53
|
+
const rootRef = ref<InstanceType<typeof ToggleGroupRoot> | null>(null)
|
|
54
|
+
|
|
55
|
+
// Shadowed selection state — mirrors modelValue when controlled, falls back
|
|
56
|
+
// to defaultValue/emitted updates when uncontrolled, so the indicator works
|
|
57
|
+
// either way. Undefined is forwarded too, so external form resets that clear
|
|
58
|
+
// v-model correctly hide the indicator.
|
|
59
|
+
const selectedValue = ref<string | undefined>(props.modelValue ?? props.defaultValue)
|
|
60
|
+
watch(() => props.modelValue, (v) => {
|
|
61
|
+
selectedValue.value = v
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const indicatorStyle = ref<Record<string, string>>({
|
|
65
|
+
transform: 'translate(0px, 0px)',
|
|
66
|
+
width: '0px',
|
|
67
|
+
height: '0px',
|
|
68
|
+
})
|
|
69
|
+
const indicatorVisible = ref(false)
|
|
70
|
+
|
|
71
|
+
function getRootEl (): HTMLElement | null {
|
|
72
|
+
const el = (rootRef.value as unknown as { $el?: unknown })?.$el
|
|
73
|
+
return el instanceof HTMLElement ? el : null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function updateIndicator () {
|
|
77
|
+
const rootEl = getRootEl()
|
|
78
|
+
if (!rootEl) return
|
|
79
|
+
|
|
80
|
+
const activeEl = selectedValue.value ? itemEls.get(selectedValue.value) : null
|
|
81
|
+
if (!activeEl) {
|
|
82
|
+
indicatorVisible.value = false
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const rootRect = rootEl.getBoundingClientRect()
|
|
87
|
+
const itemRect = activeEl.getBoundingClientRect()
|
|
88
|
+
indicatorStyle.value = {
|
|
89
|
+
transform: `translate(${itemRect.left - rootRect.left}px, ${itemRect.top - rootRect.top}px)`,
|
|
90
|
+
width: `${itemRect.width}px`,
|
|
91
|
+
height: `${itemRect.height}px`,
|
|
92
|
+
}
|
|
93
|
+
indicatorVisible.value = true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const debouncedUpdate = useDebounceFn(updateIndicator, 100)
|
|
97
|
+
|
|
98
|
+
provide(BUTTON_GROUP_REGISTER_KEY, {
|
|
99
|
+
register (value, el) {
|
|
100
|
+
itemEls.set(value, el)
|
|
101
|
+
updateIndicator()
|
|
102
|
+
},
|
|
103
|
+
unregister (value) {
|
|
104
|
+
itemEls.delete(value)
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
watch([selectedValue, () => props.orientation, () => props.size], async () => {
|
|
109
|
+
await nextTick()
|
|
110
|
+
updateIndicator()
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
onMounted(async () => {
|
|
114
|
+
await nextTick()
|
|
115
|
+
updateIndicator()
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const resizeTarget = computed(() => getRootEl())
|
|
119
|
+
useResizeObserver(resizeTarget, debouncedUpdate)
|
|
120
|
+
|
|
121
|
+
// --- Classes ---------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
const sizeClasses = computed(() => {
|
|
124
|
+
switch (props.size) {
|
|
125
|
+
case 'sm': return 'h-8 p-0.5 gap-0.5'
|
|
126
|
+
case 'lg': return 'h-12 p-1 gap-1'
|
|
127
|
+
case 'md':
|
|
128
|
+
default: return 'h-10 p-0.5 gap-1'
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const RAIL_BG: Record<ButtonGroupColor, string> = {
|
|
133
|
+
'neutral': 'bg-actions-neutral-idle-alpha-light',
|
|
134
|
+
'neutral-invert': 'bg-actions-neutral-invert-idle-alpha-light',
|
|
135
|
+
'primary': 'bg-actions-primary-idle-alpha-light',
|
|
136
|
+
'success': 'bg-actions-success-idle-alpha-light',
|
|
137
|
+
'warning': 'bg-actions-warning-idle-alpha-light',
|
|
138
|
+
'error': 'bg-actions-danger-idle-alpha-light',
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const INDICATOR_BG: Record<ButtonGroupColor, string> = {
|
|
142
|
+
'neutral': 'bg-actions-neutral-idle',
|
|
143
|
+
'neutral-invert': 'bg-actions-neutral-invert-idle',
|
|
144
|
+
'primary': 'bg-actions-primary-idle',
|
|
145
|
+
'success': 'bg-actions-success-idle',
|
|
146
|
+
'warning': 'bg-actions-warning-idle',
|
|
147
|
+
'error': 'bg-actions-danger-idle',
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const INDICATOR_RADIUS: Record<ButtonGroupSize, string> = {
|
|
151
|
+
sm: 'rounded-md',
|
|
152
|
+
md: 'rounded-lg',
|
|
153
|
+
lg: 'rounded-lg',
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const railBgClass = computed(() => RAIL_BG[props.color])
|
|
157
|
+
const indicatorBgClass = computed(() => INDICATOR_BG[props.color])
|
|
158
|
+
const indicatorRadiusClass = computed(() => INDICATOR_RADIUS[props.size])
|
|
159
|
+
|
|
160
|
+
function handleUpdate (value: AcceptableValue | AcceptableValue[]) {
|
|
161
|
+
const next = Array.isArray(value) ? value[0] : value
|
|
162
|
+
const resolved = typeof next === 'string' ? next : undefined
|
|
163
|
+
|
|
164
|
+
// Reka-ui's single-select emits `undefined` when the user clicks the already
|
|
165
|
+
// selected item. Suppress that unless the consumer opts into deselection —
|
|
166
|
+
// driving ToggleGroupRoot from `selectedValue` means the visible state
|
|
167
|
+
// reverts cleanly on the next render.
|
|
168
|
+
if (resolved === undefined && !props.allowDeselect) return
|
|
169
|
+
|
|
170
|
+
selectedValue.value = resolved
|
|
171
|
+
emit('update:modelValue', resolved)
|
|
172
|
+
}
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<template>
|
|
176
|
+
<ToggleGroupRoot
|
|
177
|
+
ref="rootRef"
|
|
178
|
+
:model-value="selectedValue"
|
|
179
|
+
:disabled="disabled"
|
|
180
|
+
:orientation="orientation"
|
|
181
|
+
:name="name"
|
|
182
|
+
:roving-focus="true"
|
|
183
|
+
type="single"
|
|
184
|
+
class="relative inline-flex w-full items-stretch rounded-lg"
|
|
185
|
+
:class="[sizeClasses, railBgClass, { 'flex-col h-auto': orientation === 'vertical' }]"
|
|
186
|
+
@update:model-value="handleUpdate"
|
|
187
|
+
>
|
|
188
|
+
<div
|
|
189
|
+
v-show="indicatorVisible"
|
|
190
|
+
data-testid="button-group-indicator"
|
|
191
|
+
aria-hidden="true"
|
|
192
|
+
class="absolute top-0 left-0 pointer-events-none transition-[transform,width,height] duration-200 ease-out will-change-transform"
|
|
193
|
+
:class="[indicatorBgClass, indicatorRadiusClass]"
|
|
194
|
+
:style="indicatorStyle"
|
|
195
|
+
/>
|
|
196
|
+
<slot />
|
|
197
|
+
</ToggleGroupRoot>
|
|
198
|
+
</template>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ToggleGroupItem } from 'reka-ui'
|
|
3
|
+
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
4
|
+
import type { ButtonGroupColor } from './types'
|
|
5
|
+
import {
|
|
6
|
+
BUTTON_GROUP_COLOR_KEY,
|
|
7
|
+
BUTTON_GROUP_REGISTER_KEY,
|
|
8
|
+
BUTTON_GROUP_SIZE_KEY,
|
|
9
|
+
} from './types'
|
|
10
|
+
|
|
11
|
+
interface UiButtonGroupItemProps {
|
|
12
|
+
value: string
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
ariaLabel?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<UiButtonGroupItemProps>(), {
|
|
18
|
+
disabled: false,
|
|
19
|
+
ariaLabel: undefined,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const size = inject(BUTTON_GROUP_SIZE_KEY, computed(() => 'md' as const))
|
|
23
|
+
const color = inject(BUTTON_GROUP_COLOR_KEY, computed<ButtonGroupColor>(() => 'neutral'))
|
|
24
|
+
const registry = inject(BUTTON_GROUP_REGISTER_KEY, null)
|
|
25
|
+
|
|
26
|
+
const itemRef = ref<InstanceType<typeof ToggleGroupItem> | null>(null)
|
|
27
|
+
|
|
28
|
+
function resolveEl (): HTMLElement | null {
|
|
29
|
+
const el = (itemRef.value as unknown as { $el?: unknown })?.$el
|
|
30
|
+
return el instanceof HTMLElement ? el : null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
const el = resolveEl()
|
|
35
|
+
if (el && registry) registry.register(props.value, el)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Re-register under the new key if the `value` prop changes dynamically
|
|
39
|
+
// (e.g. iterating over a reactive list), so the indicator keeps tracking
|
|
40
|
+
// this item instead of looking for a stale key.
|
|
41
|
+
watch(() => props.value, (next, prev) => {
|
|
42
|
+
if (next === prev || !registry) return
|
|
43
|
+
registry.unregister(prev)
|
|
44
|
+
const el = resolveEl()
|
|
45
|
+
if (el) registry.register(next, el)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
onBeforeUnmount(() => {
|
|
49
|
+
registry?.unregister(props.value)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Vertical padding is sized so the item content box matches the rail's inner height
|
|
53
|
+
// (rail height − rail padding) in horizontal mode, and drives height in vertical mode.
|
|
54
|
+
const sizeClasses = computed(() => {
|
|
55
|
+
switch (size.value) {
|
|
56
|
+
case 'sm': return 'px-2.5 py-1.5 gap-1 rounded-md text-action-button-sm'
|
|
57
|
+
case 'lg': return 'px-6 py-2.5 gap-2 rounded-lg text-action-button-lg'
|
|
58
|
+
case 'md':
|
|
59
|
+
default: return 'px-4 py-2.5 gap-1.5 rounded-lg text-action-button-md'
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// Per-color state classes. The selected fill is drawn by the parent's sliding
|
|
64
|
+
// indicator <div>, so items only set text color per state. Hover bg/text apply
|
|
65
|
+
// only to unselected items (data-[state=off]) so the hover tint never stacks
|
|
66
|
+
// on top of the indicator.
|
|
67
|
+
const COLOR_CLASSES: Record<ButtonGroupColor, string> = {
|
|
68
|
+
'neutral': [
|
|
69
|
+
'text-actions-neutral-idle-alpha-strong',
|
|
70
|
+
'data-[state=off]:hover:bg-actions-neutral-hover-overlay',
|
|
71
|
+
'data-[state=off]:hover:text-actions-neutral-idle',
|
|
72
|
+
'data-[state=on]:text-actions-neutral-invert-idle',
|
|
73
|
+
].join(' '),
|
|
74
|
+
'neutral-invert': [
|
|
75
|
+
'text-actions-neutral-invert-idle-alpha-strong',
|
|
76
|
+
'data-[state=off]:hover:bg-actions-neutral-invert-hover-overlay',
|
|
77
|
+
'data-[state=off]:hover:text-actions-neutral-invert-idle',
|
|
78
|
+
'data-[state=on]:text-actions-neutral-idle',
|
|
79
|
+
].join(' '),
|
|
80
|
+
'primary': [
|
|
81
|
+
'text-actions-primary-idle-alpha-strong',
|
|
82
|
+
'data-[state=off]:hover:bg-actions-primary-hover-overlay',
|
|
83
|
+
'data-[state=off]:hover:text-actions-primary-idle',
|
|
84
|
+
'data-[state=on]:text-actions-neutral-invert-idle',
|
|
85
|
+
].join(' '),
|
|
86
|
+
'success': [
|
|
87
|
+
'text-actions-success-idle-alpha-strong',
|
|
88
|
+
'data-[state=off]:hover:bg-actions-success-hover-overlay',
|
|
89
|
+
'data-[state=off]:hover:text-actions-success-idle',
|
|
90
|
+
'data-[state=on]:text-actions-neutral-invert-idle',
|
|
91
|
+
].join(' '),
|
|
92
|
+
'warning': [
|
|
93
|
+
'text-actions-warning-idle-alpha-strong',
|
|
94
|
+
'data-[state=off]:hover:bg-actions-warning-hover-overlay',
|
|
95
|
+
'data-[state=off]:hover:text-actions-warning-idle',
|
|
96
|
+
'data-[state=on]:text-actions-neutral-invert-idle',
|
|
97
|
+
].join(' '),
|
|
98
|
+
'error': [
|
|
99
|
+
'text-actions-danger-idle-alpha-strong',
|
|
100
|
+
'data-[state=off]:hover:bg-actions-danger-hover-overlay',
|
|
101
|
+
'data-[state=off]:hover:text-actions-danger-idle',
|
|
102
|
+
'data-[state=on]:text-actions-neutral-invert-idle',
|
|
103
|
+
].join(' '),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const colorClasses = computed(() => COLOR_CLASSES[color.value])
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<ToggleGroupItem
|
|
111
|
+
ref="itemRef"
|
|
112
|
+
:value="value"
|
|
113
|
+
:disabled="disabled"
|
|
114
|
+
:aria-label="ariaLabel"
|
|
115
|
+
class="relative z-10 flex-1 inline-flex items-center justify-center transition-colors cursor-pointer outline-none
|
|
116
|
+
focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-ring
|
|
117
|
+
data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed
|
|
118
|
+
data-[state=off]:data-[disabled]:hover:bg-transparent"
|
|
119
|
+
:class="[sizeClasses, colorClasses]"
|
|
120
|
+
>
|
|
121
|
+
<slot />
|
|
122
|
+
</ToggleGroupItem>
|
|
123
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type ButtonGroupSize = 'sm' | 'md' | 'lg'
|
|
4
|
+
export type ButtonGroupColor =
|
|
5
|
+
| 'neutral'
|
|
6
|
+
| 'neutral-invert'
|
|
7
|
+
| 'primary'
|
|
8
|
+
| 'success'
|
|
9
|
+
| 'warning'
|
|
10
|
+
| 'error'
|
|
11
|
+
|
|
12
|
+
export interface ButtonGroupRegister {
|
|
13
|
+
register(value: string, el: HTMLElement): void
|
|
14
|
+
unregister(value: string): void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const BUTTON_GROUP_SIZE_KEY: InjectionKey<ComputedRef<ButtonGroupSize>> =
|
|
18
|
+
Symbol('ui-button-group-size')
|
|
19
|
+
|
|
20
|
+
export const BUTTON_GROUP_COLOR_KEY: InjectionKey<ComputedRef<ButtonGroupColor>> =
|
|
21
|
+
Symbol('ui-button-group-color')
|
|
22
|
+
|
|
23
|
+
export const BUTTON_GROUP_REGISTER_KEY: InjectionKey<ButtonGroupRegister> =
|
|
24
|
+
Symbol('ui-button-group-register')
|