@aleph-alpha/ui-library 1.8.0 → 1.10.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 +14 -0
- package/dist/mcp/cli.js +21588 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/scripts/generate-component-meta.js +236 -0
- package/dist/mcp/server.js +21456 -0
- package/dist/system/index-CkH7HQaa.js +7 -0
- package/dist/system/index-CuHwEAQ_.js +7 -0
- package/dist/system/index.d.ts +1269 -540
- package/dist/system/lib.js +9001 -7237
- package/mcp/components-meta.json +1172 -0
- package/package.json +15 -5
- package/src/@types/shims-vue.d.ts +5 -0
- package/src/__tests__/placeholder.test.ts +7 -0
- package/src/compositions/UiCompositionPlaceholder/UiCompositionPlaceholder.vue +9 -0
- package/src/compositions/UiCompositionPlaceholder/index.ts +1 -0
- package/src/compositions/UiCompositionPlaceholder/types.ts +8 -0
- package/src/compositions/UiDataTable/UiDataTable.mock.ts +104 -0
- package/src/compositions/UiDataTable/UiDataTable.stories.ts +1575 -0
- package/src/compositions/UiDataTable/UiDataTable.vue +129 -0
- package/src/compositions/UiDataTable/UiDataTableColumnHeader.vue +97 -0
- package/src/compositions/UiDataTable/UiDataTablePagination.vue +147 -0
- package/src/compositions/UiDataTable/UiDataTableToolbar.vue +85 -0
- package/src/compositions/UiDataTable/__tests__/UiDataTable.test.ts +372 -0
- package/src/compositions/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +217 -0
- package/src/compositions/UiDataTable/__tests__/UiDataTablePagination.test.ts +274 -0
- package/src/compositions/UiDataTable/__tests__/UiDataTableToolbar.test.ts +198 -0
- package/src/compositions/UiDataTable/constants.ts +77 -0
- package/src/compositions/UiDataTable/index.ts +6 -0
- package/src/compositions/UiDataTable/types.ts +39 -0
- package/src/compositions/UiDatePicker/UiDatePicker.stories.ts +976 -0
- package/src/compositions/UiDatePicker/UiDatePicker.vue +193 -0
- package/src/compositions/UiDatePicker/__tests__/UiDatePicker.test.ts +325 -0
- package/src/compositions/UiDatePicker/index.ts +14 -0
- package/src/compositions/UiDatePicker/types.ts +220 -0
- package/src/compositions/index.ts +8 -0
- package/src/foundations/UiPlaceholder/UiPlaceholder.vue +9 -0
- package/src/foundations/UiPlaceholder/index.ts +1 -0
- package/src/foundations/UiPlaceholder/types.ts +8 -0
- package/src/foundations/index.ts +6 -0
- package/src/index.ts +27 -0
- package/src/lib/utils.ts +6 -0
- package/src/primitives/UiAccordion/UiAccordion.stories.ts +476 -0
- package/src/primitives/UiAccordion/UiAccordion.vue +31 -0
- package/src/primitives/UiAccordion/UiAccordionContent.vue +16 -0
- package/src/primitives/UiAccordion/UiAccordionItem.vue +16 -0
- package/src/primitives/UiAccordion/UiAccordionTrigger.vue +23 -0
- package/src/primitives/UiAccordion/__tests__/UiAccordion.test.ts +198 -0
- package/src/primitives/UiAccordion/index.ts +6 -0
- package/src/primitives/UiAccordion/types.ts +95 -0
- package/src/primitives/UiAlert/UiAlert.stories.ts +199 -0
- package/src/primitives/UiAlert/UiAlert.vue +27 -0
- package/src/primitives/UiAlert/UiAlertDescription.vue +13 -0
- package/src/primitives/UiAlert/UiAlertTitle.vue +13 -0
- package/src/primitives/UiAlert/__tests__/UiAlert.test.ts +20 -0
- package/src/primitives/UiAlert/constants.ts +3 -0
- package/src/primitives/UiAlert/index.ts +5 -0
- package/src/primitives/UiAlert/types.ts +14 -0
- package/src/primitives/UiAlertDialog/UiAlertDialog.stories.ts +186 -0
- package/src/primitives/UiAlertDialog/UiAlertDialog.vue +18 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogAction.vue +16 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogCancel.vue +16 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogContent.vue +26 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogDescription.vue +16 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogFooter.vue +13 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogHeader.vue +16 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogTitle.vue +16 -0
- package/src/primitives/UiAlertDialog/UiAlertDialogTrigger.vue +17 -0
- package/src/primitives/UiAlertDialog/__tests__/UiAlertDialog.test.ts +184 -0
- package/src/primitives/UiAlertDialog/index.ts +9 -0
- package/src/primitives/UiAlertDialog/types.ts +83 -0
- package/src/primitives/UiAvatar/UiAvatar.stories.ts +194 -0
- package/src/primitives/UiAvatar/UiAvatar.vue +13 -0
- package/src/primitives/UiAvatar/UiAvatarFallback.vue +13 -0
- package/src/primitives/UiAvatar/UiAvatarImage.vue +14 -0
- package/src/primitives/UiAvatar/__tests__/UiAvatar.test.ts +36 -0
- package/src/primitives/UiAvatar/index.ts +3 -0
- package/src/primitives/UiAvatar/types.ts +17 -0
- package/src/primitives/UiBadge/UiBadge.stories.ts +373 -0
- package/src/primitives/UiBadge/UiBadge.vue +21 -0
- package/src/primitives/UiBadge/__tests__/UiBadge.test.ts +44 -0
- package/src/primitives/UiBadge/constants.ts +3 -0
- package/src/primitives/UiBadge/index.ts +2 -0
- package/src/primitives/UiBadge/types.ts +48 -0
- package/src/primitives/UiButton/UiButton.stories.ts +537 -0
- package/src/primitives/UiButton/UiButton.vue +72 -0
- package/src/primitives/UiButton/__tests__/UiButton.test.ts +133 -0
- package/src/primitives/UiButton/index.ts +2 -0
- package/src/primitives/UiButton/types.ts +87 -0
- package/src/primitives/UiCalendar/UiCalendar.stories.ts +797 -0
- package/src/primitives/UiCalendar/UiCalendar.vue +67 -0
- package/src/primitives/UiCalendar/__tests__/UiCalendar.test.ts +45 -0
- package/src/primitives/UiCalendar/index.ts +15 -0
- package/src/primitives/UiCalendar/types.ts +236 -0
- package/src/primitives/UiCard/UiCard.stories.ts +197 -0
- package/src/primitives/UiCard/UiCard.vue +13 -0
- package/src/primitives/UiCard/UiCardAction.vue +13 -0
- package/src/primitives/UiCard/UiCardContent.vue +13 -0
- package/src/primitives/UiCard/UiCardDescription.vue +13 -0
- package/src/primitives/UiCard/UiCardFooter.vue +13 -0
- package/src/primitives/UiCard/UiCardHeader.vue +13 -0
- package/src/primitives/UiCard/UiCardTitle.vue +13 -0
- package/src/primitives/UiCard/__tests__/UiCard.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardAction.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardContent.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardDescription.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardFooter.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardHeader.test.ts +19 -0
- package/src/primitives/UiCard/__tests__/UiCardTitle.test.ts +19 -0
- package/src/primitives/UiCard/index.ts +7 -0
- package/src/primitives/UiCard/types.ts +10 -0
- package/src/primitives/UiCheckbox/UiCheckbox.stories.ts +231 -0
- package/src/primitives/UiCheckbox/UiCheckbox.vue +19 -0
- package/src/primitives/UiCheckbox/__tests__/UiCheckbox.test.ts +29 -0
- package/src/primitives/UiCheckbox/index.ts +2 -0
- package/src/primitives/UiCheckbox/types.ts +30 -0
- package/src/primitives/UiDrawer/UiDrawer.stories.ts +602 -0
- package/src/primitives/UiDrawer/UiDrawer.vue +19 -0
- package/src/primitives/UiDrawer/UiDrawerClose.vue +16 -0
- package/src/primitives/UiDrawer/UiDrawerContent.vue +29 -0
- package/src/primitives/UiDrawer/UiDrawerDescription.vue +16 -0
- package/src/primitives/UiDrawer/UiDrawerFooter.vue +16 -0
- package/src/primitives/UiDrawer/UiDrawerHeader.vue +16 -0
- package/src/primitives/UiDrawer/UiDrawerTitle.vue +16 -0
- package/src/primitives/UiDrawer/UiDrawerTrigger.vue +16 -0
- package/src/primitives/UiDrawer/__tests__/UiDrawer.test.ts +229 -0
- package/src/primitives/UiDrawer/index.ts +8 -0
- package/src/primitives/UiDrawer/types.ts +96 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenu.stories.ts +760 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenu.vue +25 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuCheckboxItem.vue +29 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuContent.vue +27 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuGroup.vue +13 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuItem.vue +26 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuLabel.vue +18 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuRadioGroup.vue +20 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuRadioItem.vue +26 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuSeparator.vue +11 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuShortcut.vue +13 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuSub.vue +26 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuSubContent.vue +23 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +24 -0
- package/src/primitives/UiDropdownMenu/UiDropdownMenuTrigger.vue +24 -0
- package/src/primitives/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +557 -0
- package/src/primitives/UiDropdownMenu/index.ts +16 -0
- package/src/primitives/UiDropdownMenu/types.ts +219 -0
- package/src/primitives/UiField/UiField.stories.ts +1496 -0
- package/src/primitives/UiField/UiField.vue +18 -0
- package/src/primitives/UiField/UiFieldContent.vue +13 -0
- package/src/primitives/UiField/UiFieldDescription.vue +13 -0
- package/src/primitives/UiField/UiFieldError.vue +20 -0
- package/src/primitives/UiField/UiFieldGroup.vue +13 -0
- package/src/primitives/UiField/UiFieldLabel.vue +16 -0
- package/src/primitives/UiField/UiFieldLegend.vue +13 -0
- package/src/primitives/UiField/UiFieldSeparator.vue +13 -0
- package/src/primitives/UiField/UiFieldSet.vue +13 -0
- package/src/primitives/UiField/UiFieldTitle.vue +13 -0
- package/src/primitives/UiField/__tests__/UiFieldError.test.ts +35 -0
- package/src/primitives/UiField/index.ts +10 -0
- package/src/primitives/UiField/types.ts +47 -0
- package/src/primitives/UiIcon/UiIcon.stories.ts +95 -0
- package/src/primitives/UiIcon/UiIcon.vue +14 -0
- package/src/primitives/UiIcon/__tests__/UiIcon.test.ts +24 -0
- package/src/primitives/UiIcon/index.ts +1 -0
- package/src/primitives/UiIcon/types.ts +23 -0
- package/src/primitives/UiIconButton/UiIconButton.stories.ts +446 -0
- package/src/primitives/UiIconButton/UiIconButton.vue +63 -0
- package/src/primitives/UiIconButton/__tests__/UiIconButton.test.ts +102 -0
- package/src/primitives/UiIconButton/index.ts +2 -0
- package/src/primitives/UiIconButton/types.ts +67 -0
- package/src/primitives/UiInput/UiInput.stories.ts +193 -0
- package/src/primitives/UiInput/UiInput.vue +19 -0
- package/src/primitives/UiInput/__tests__/UiInput.test.ts +38 -0
- package/src/primitives/UiInput/index.ts +2 -0
- package/src/primitives/UiInput/types.ts +31 -0
- package/src/primitives/UiPopover/UiPopover.stories.ts +394 -0
- package/src/primitives/UiPopover/UiPopover.vue +17 -0
- package/src/primitives/UiPopover/UiPopoverContent.vue +27 -0
- package/src/primitives/UiPopover/UiPopoverTrigger.vue +16 -0
- package/src/primitives/UiPopover/__tests__/UiPopover.test.ts +87 -0
- package/src/primitives/UiPopover/index.ts +5 -0
- package/src/primitives/UiPopover/types.ts +86 -0
- package/src/primitives/UiProgress/UiProgress.stories.ts +92 -0
- package/src/primitives/UiProgress/UiProgress.vue +25 -0
- package/src/primitives/UiProgress/__tests__/UiProgress.test.ts +46 -0
- package/src/primitives/UiProgress/index.ts +2 -0
- package/src/primitives/UiProgress/types.ts +16 -0
- package/src/primitives/UiRadioGroup/UiRadioGroup.stories.ts +291 -0
- package/src/primitives/UiRadioGroup/UiRadioGroup.vue +43 -0
- package/src/primitives/UiRadioGroup/UiRadioGroupItem.vue +18 -0
- package/src/primitives/UiRadioGroup/__tests__/UiRadioGroup.test.ts +404 -0
- package/src/primitives/UiRadioGroup/index.ts +4 -0
- package/src/primitives/UiRadioGroup/types.ts +66 -0
- package/src/primitives/UiRangeCalendar/UiRangeCalendar.stories.ts +609 -0
- package/src/primitives/UiRangeCalendar/UiRangeCalendar.vue +50 -0
- package/src/primitives/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +35 -0
- package/src/primitives/UiRangeCalendar/index.ts +13 -0
- package/src/primitives/UiRangeCalendar/types.ts +184 -0
- package/src/primitives/UiSelect/UiSelect.stories.ts +425 -0
- package/src/primitives/UiSelect/UiSelect.vue +47 -0
- package/src/primitives/UiSelect/UiSelectContent.vue +30 -0
- package/src/primitives/UiSelect/UiSelectGroup.vue +13 -0
- package/src/primitives/UiSelect/UiSelectItem.vue +19 -0
- package/src/primitives/UiSelect/UiSelectLabel.vue +13 -0
- package/src/primitives/UiSelect/UiSelectSeparator.vue +11 -0
- package/src/primitives/UiSelect/UiSelectTrigger.vue +30 -0
- package/src/primitives/UiSelect/UiSelectValue.vue +18 -0
- package/src/primitives/UiSelect/__tests__/UiSelect.test.ts +211 -0
- package/src/primitives/UiSelect/__tests__/UiSelectContent.test.ts +30 -0
- package/src/primitives/UiSelect/__tests__/UiSelectGroup.test.ts +85 -0
- package/src/primitives/UiSelect/__tests__/UiSelectItem.test.ts +79 -0
- package/src/primitives/UiSelect/__tests__/UiSelectLabel.test.ts +83 -0
- package/src/primitives/UiSelect/__tests__/UiSelectSeparator.test.ts +82 -0
- package/src/primitives/UiSelect/__tests__/UiSelectTrigger.test.ts +54 -0
- package/src/primitives/UiSelect/__tests__/UiSelectValue.test.ts +39 -0
- package/src/primitives/UiSelect/index.ts +10 -0
- package/src/primitives/UiSelect/types.ts +93 -0
- package/src/primitives/UiSlider/UiSlider.stories.ts +226 -0
- package/src/primitives/UiSlider/UiSlider.vue +44 -0
- package/src/primitives/UiSlider/__tests__/UiSlider.test.ts +76 -0
- package/src/primitives/UiSlider/index.ts +1 -0
- package/src/primitives/UiSlider/types.ts +101 -0
- package/src/primitives/UiSpinner/UiSpinner.stories.ts +143 -0
- package/src/primitives/UiSpinner/UiSpinner.vue +16 -0
- package/src/primitives/UiSpinner/__tests__/UiSpinner.test.ts +19 -0
- package/src/primitives/UiSpinner/index.ts +2 -0
- package/src/primitives/UiSpinner/types.ts +16 -0
- package/src/primitives/UiSwitch/UiSwitch.stories.ts +120 -0
- package/src/primitives/UiSwitch/UiSwitch.vue +21 -0
- package/src/primitives/UiSwitch/__tests__/UiSwitch.test.ts +47 -0
- package/src/primitives/UiSwitch/index.ts +2 -0
- package/src/primitives/UiSwitch/types.ts +25 -0
- package/src/primitives/UiTable/UiTable.stories.ts +505 -0
- package/src/primitives/UiTable/UiTable.vue +13 -0
- package/src/primitives/UiTable/UiTableBody.vue +13 -0
- package/src/primitives/UiTable/UiTableCaption.vue +13 -0
- package/src/primitives/UiTable/UiTableCell.vue +16 -0
- package/src/primitives/UiTable/UiTableEmpty.vue +18 -0
- package/src/primitives/UiTable/UiTableFooter.vue +13 -0
- package/src/primitives/UiTable/UiTableHead.vue +18 -0
- package/src/primitives/UiTable/UiTableHeader.vue +13 -0
- package/src/primitives/UiTable/UiTableRow.vue +18 -0
- package/src/primitives/UiTable/__tests__/UiTable.test.ts +19 -0
- package/src/primitives/UiTable/__tests__/UiTableBody.test.ts +19 -0
- package/src/primitives/UiTable/__tests__/UiTableCaption.test.ts +19 -0
- package/src/primitives/UiTable/__tests__/UiTableCell.test.ts +26 -0
- package/src/primitives/UiTable/__tests__/UiTableEmpty.test.ts +32 -0
- package/src/primitives/UiTable/__tests__/UiTableFooter.test.ts +19 -0
- package/src/primitives/UiTable/__tests__/UiTableHead.test.ts +43 -0
- package/src/primitives/UiTable/__tests__/UiTableHeader.test.ts +19 -0
- package/src/primitives/UiTable/__tests__/UiTableRow.test.ts +32 -0
- package/src/primitives/UiTable/index.ts +16 -0
- package/src/primitives/UiTable/types.ts +68 -0
- package/src/primitives/UiTabs/UiTabs.stories.ts +456 -0
- package/src/primitives/UiTabs/UiTabs.vue +31 -0
- package/src/primitives/UiTabs/UiTabsContent.vue +16 -0
- package/src/primitives/UiTabs/UiTabsList.vue +16 -0
- package/src/primitives/UiTabs/UiTabsTrigger.vue +16 -0
- package/src/primitives/UiTabs/__tests__/UiTabs.test.ts +122 -0
- package/src/primitives/UiTabs/index.ts +6 -0
- package/src/primitives/UiTabs/types.ts +68 -0
- package/src/primitives/UiTextarea/UiTextarea.stories.ts +107 -0
- package/src/primitives/UiTextarea/UiTextarea.vue +19 -0
- package/src/primitives/UiTextarea/__tests__/UiTextarea.test.ts +40 -0
- package/src/primitives/UiTextarea/index.ts +2 -0
- package/src/primitives/UiTextarea/types.ts +30 -0
- package/src/primitives/UiTooltip/UiTooltip.stories.ts +550 -0
- package/src/primitives/UiTooltip/UiTooltip.vue +42 -0
- package/src/primitives/UiTooltip/__tests__/UiTooltip.test.ts +78 -0
- package/src/primitives/UiTooltip/index.ts +2 -0
- package/src/primitives/UiTooltip/types.ts +53 -0
- package/src/primitives/index.ts +33 -0
- package/src/primitives/shadcn/accordion/Accordion.vue +15 -0
- package/src/primitives/shadcn/accordion/AccordionContent.vue +23 -0
- package/src/primitives/shadcn/accordion/AccordionItem.vue +24 -0
- package/src/primitives/shadcn/accordion/AccordionTrigger.vue +35 -0
- package/src/primitives/shadcn/accordion/index.ts +4 -0
- package/src/primitives/shadcn/alert/Alert.vue +17 -0
- package/src/primitives/shadcn/alert/AlertDescription.vue +22 -0
- package/src/primitives/shadcn/alert/AlertTitle.vue +17 -0
- package/src/primitives/shadcn/alert/index.ts +24 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialog.vue +15 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogAction.vue +18 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogCancel.vue +21 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogContent.vue +44 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogDescription.vue +21 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogFooter.vue +17 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogHeader.vue +17 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogTitle.vue +21 -0
- package/src/primitives/shadcn/alert-dialog/AlertDialogTrigger.vue +12 -0
- package/src/primitives/shadcn/alert-dialog/index.ts +9 -0
- package/src/primitives/shadcn/avatar/Avatar.vue +18 -0
- package/src/primitives/shadcn/avatar/AvatarFallback.vue +21 -0
- package/src/primitives/shadcn/avatar/AvatarImage.vue +12 -0
- package/src/primitives/shadcn/avatar/index.ts +3 -0
- package/src/primitives/shadcn/badge/Badge.vue +28 -0
- package/src/primitives/shadcn/badge/index.ts +24 -0
- package/src/primitives/shadcn/button/Button.vue +29 -0
- package/src/primitives/shadcn/button/index.ts +36 -0
- package/src/primitives/shadcn/calendar/Calendar.vue +206 -0
- package/src/primitives/shadcn/calendar/CalendarCell.vue +28 -0
- package/src/primitives/shadcn/calendar/CalendarCellTrigger.vue +44 -0
- package/src/primitives/shadcn/calendar/CalendarGrid.vue +23 -0
- package/src/primitives/shadcn/calendar/CalendarGridBody.vue +12 -0
- package/src/primitives/shadcn/calendar/CalendarGridHead.vue +13 -0
- package/src/primitives/shadcn/calendar/CalendarGridRow.vue +23 -0
- package/src/primitives/shadcn/calendar/CalendarHeadCell.vue +23 -0
- package/src/primitives/shadcn/calendar/CalendarHeader.vue +23 -0
- package/src/primitives/shadcn/calendar/CalendarHeading.vue +30 -0
- package/src/primitives/shadcn/calendar/CalendarNextButton.vue +33 -0
- package/src/primitives/shadcn/calendar/CalendarPrevButton.vue +33 -0
- package/src/primitives/shadcn/calendar/index.ts +14 -0
- package/src/primitives/shadcn/card/Card.vue +22 -0
- package/src/primitives/shadcn/card/CardAction.vue +17 -0
- package/src/primitives/shadcn/card/CardContent.vue +14 -0
- package/src/primitives/shadcn/card/CardDescription.vue +14 -0
- package/src/primitives/shadcn/card/CardFooter.vue +14 -0
- package/src/primitives/shadcn/card/CardHeader.vue +22 -0
- package/src/primitives/shadcn/card/CardTitle.vue +14 -0
- package/src/primitives/shadcn/card/index.ts +7 -0
- package/src/primitives/shadcn/checkbox/Checkbox.vue +38 -0
- package/src/primitives/shadcn/checkbox/index.ts +1 -0
- package/src/primitives/shadcn/drawer/Drawer.vue +15 -0
- package/src/primitives/shadcn/drawer/DrawerClose.vue +12 -0
- package/src/primitives/shadcn/drawer/DrawerContent.vue +52 -0
- package/src/primitives/shadcn/drawer/DrawerDescription.vue +20 -0
- package/src/primitives/shadcn/drawer/DrawerFooter.vue +17 -0
- package/src/primitives/shadcn/drawer/DrawerHeader.vue +17 -0
- package/src/primitives/shadcn/drawer/DrawerTitle.vue +20 -0
- package/src/primitives/shadcn/drawer/DrawerTrigger.vue +12 -0
- package/src/primitives/shadcn/drawer/index.ts +8 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenu.vue +15 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuCheckboxItem.vue +41 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuContent.vue +40 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuItem.vue +41 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuLabel.vue +25 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuRadioGroup.vue +15 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuRadioItem.vue +38 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuSeparator.vue +23 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuShortcut.vue +17 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuSub.vue +15 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuSubContent.vue +29 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
- package/src/primitives/shadcn/dropdown-menu/DropdownMenuTrigger.vue +14 -0
- package/src/primitives/shadcn/dropdown-menu/index.ts +16 -0
- package/src/primitives/shadcn/field/Field.vue +22 -0
- package/src/primitives/shadcn/field/FieldContent.vue +17 -0
- package/src/primitives/shadcn/field/FieldDescription.vue +24 -0
- package/src/primitives/shadcn/field/FieldError.vue +69 -0
- package/src/primitives/shadcn/field/FieldGroup.vue +22 -0
- package/src/primitives/shadcn/field/FieldLabel.vue +28 -0
- package/src/primitives/shadcn/field/FieldLegend.vue +26 -0
- package/src/primitives/shadcn/field/FieldSeparator.vue +28 -0
- package/src/primitives/shadcn/field/FieldSet.vue +23 -0
- package/src/primitives/shadcn/field/FieldTitle.vue +22 -0
- package/src/primitives/shadcn/field/index.ts +39 -0
- package/src/primitives/shadcn/icon/Icon.vue +38 -0
- package/src/primitives/shadcn/icon/index.ts +1 -0
- package/src/primitives/shadcn/index.ts +3 -0
- package/src/primitives/shadcn/input/Input.vue +35 -0
- package/src/primitives/shadcn/input/index.ts +1 -0
- package/src/primitives/shadcn/label/Label.vue +28 -0
- package/src/primitives/shadcn/label/index.ts +1 -0
- package/src/primitives/shadcn/native-select/NativeSelect.vue +56 -0
- package/src/primitives/shadcn/native-select/NativeSelectOptGroup.vue +18 -0
- package/src/primitives/shadcn/native-select/NativeSelectOption.vue +18 -0
- package/src/primitives/shadcn/native-select/index.ts +3 -0
- package/src/primitives/shadcn/popover/Popover.vue +19 -0
- package/src/primitives/shadcn/popover/PopoverContent.vue +41 -0
- package/src/primitives/shadcn/popover/PopoverTrigger.vue +11 -0
- package/src/primitives/shadcn/popover/index.ts +4 -0
- package/src/primitives/shadcn/progress/Progress.vue +30 -0
- package/src/primitives/shadcn/progress/index.ts +1 -0
- package/src/primitives/shadcn/radio-group/RadioGroup.vue +25 -0
- package/src/primitives/shadcn/radio-group/RadioGroupItem.vue +38 -0
- package/src/primitives/shadcn/radio-group/index.ts +2 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendar.vue +73 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarCell.vue +28 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarCellTrigger.vue +46 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarGrid.vue +23 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarGridBody.vue +12 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarGridHead.vue +12 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarGridRow.vue +23 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarHeadCell.vue +23 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarHeader.vue +23 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarHeading.vue +30 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarNextButton.vue +34 -0
- package/src/primitives/shadcn/range-calendar/RangeCalendarPrevButton.vue +34 -0
- package/src/primitives/shadcn/range-calendar/index.ts +12 -0
- package/src/primitives/shadcn/select/Select.vue +15 -0
- package/src/primitives/shadcn/select/SelectContent.vue +55 -0
- package/src/primitives/shadcn/select/SelectGroup.vue +12 -0
- package/src/primitives/shadcn/select/SelectItem.vue +39 -0
- package/src/primitives/shadcn/select/SelectItemText.vue +12 -0
- package/src/primitives/shadcn/select/SelectLabel.vue +17 -0
- package/src/primitives/shadcn/select/SelectScrollDownButton.vue +26 -0
- package/src/primitives/shadcn/select/SelectScrollUpButton.vue +26 -0
- package/src/primitives/shadcn/select/SelectSeparator.vue +19 -0
- package/src/primitives/shadcn/select/SelectTrigger.vue +37 -0
- package/src/primitives/shadcn/select/SelectValue.vue +12 -0
- package/src/primitives/shadcn/select/index.ts +11 -0
- package/src/primitives/shadcn/separator/Separator.vue +27 -0
- package/src/primitives/shadcn/separator/index.ts +1 -0
- package/src/primitives/shadcn/slider/Slider.vue +45 -0
- package/src/primitives/shadcn/slider/index.ts +1 -0
- package/src/primitives/shadcn/spinner/Spinner.vue +18 -0
- package/src/primitives/shadcn/spinner/index.ts +1 -0
- package/src/primitives/shadcn/switch/Switch.vue +40 -0
- package/src/primitives/shadcn/switch/index.ts +1 -0
- package/src/primitives/shadcn/table/Table.vue +16 -0
- package/src/primitives/shadcn/table/TableBody.vue +14 -0
- package/src/primitives/shadcn/table/TableCaption.vue +14 -0
- package/src/primitives/shadcn/table/TableCell.vue +26 -0
- package/src/primitives/shadcn/table/TableEmpty.vue +29 -0
- package/src/primitives/shadcn/table/TableFooter.vue +17 -0
- package/src/primitives/shadcn/table/TableHead.vue +28 -0
- package/src/primitives/shadcn/table/TableHeader.vue +14 -0
- package/src/primitives/shadcn/table/TableRow.vue +21 -0
- package/src/primitives/shadcn/table/index.ts +9 -0
- package/src/primitives/shadcn/table/utils.ts +8 -0
- package/src/primitives/shadcn/tabs/Tabs.vue +24 -0
- package/src/primitives/shadcn/tabs/TabsContent.vue +21 -0
- package/src/primitives/shadcn/tabs/TabsList.vue +26 -0
- package/src/primitives/shadcn/tabs/TabsTrigger.vue +28 -0
- package/src/primitives/shadcn/tabs/index.ts +4 -0
- package/src/primitives/shadcn/textarea/Textarea.vue +33 -0
- package/src/primitives/shadcn/textarea/index.ts +1 -0
- package/src/primitives/shadcn/tooltip/Tooltip.vue +15 -0
- package/src/primitives/shadcn/tooltip/TooltipContent.vue +40 -0
- package/src/primitives/shadcn/tooltip/TooltipProvider.vue +12 -0
- package/src/primitives/shadcn/tooltip/TooltipTrigger.vue +12 -0
- package/src/primitives/shadcn/tooltip/index.ts +4 -0
- package/src/styles/global.css +1 -0
- package/src/templates/UiTemplatePlaceholder/UiTemplatePlaceholder.vue +9 -0
- package/src/templates/UiTemplatePlaceholder/index.ts +1 -0
- package/src/templates/UiTemplatePlaceholder/types.ts +8 -0
- package/src/templates/index.ts +6 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { defineComponent, markRaw } from 'vue';
|
|
4
|
+
import UiBadge from '../UiBadge.vue';
|
|
5
|
+
|
|
6
|
+
// Mock icon component for testing startIcon and endIcon props
|
|
7
|
+
// Using markRaw to prevent Vue from making it reactive
|
|
8
|
+
const MockIcon = (testId: string) =>
|
|
9
|
+
markRaw(
|
|
10
|
+
defineComponent({
|
|
11
|
+
name: 'MockIcon',
|
|
12
|
+
template: `<svg data-testid="${testId}" />`,
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
describe('UiBadge', () => {
|
|
17
|
+
describe('Icons', () => {
|
|
18
|
+
test('renders start icon', () => {
|
|
19
|
+
const iconTestId = 'start-icon';
|
|
20
|
+
|
|
21
|
+
const { getByTestId } = render(UiBadge, {
|
|
22
|
+
props: {
|
|
23
|
+
startIcon: MockIcon(iconTestId),
|
|
24
|
+
},
|
|
25
|
+
slots: { default: 'Badge' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(getByTestId(iconTestId)).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('renders end icon', () => {
|
|
32
|
+
const iconTestId = 'end-icon';
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(UiBadge, {
|
|
35
|
+
props: {
|
|
36
|
+
endIcon: MockIcon(iconTestId),
|
|
37
|
+
},
|
|
38
|
+
slots: { default: 'Badge' },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(getByTestId(iconTestId)).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Variant Types for the UiBadge primitive component
|
|
5
|
+
*/
|
|
6
|
+
export type UiBadgeVariants = 'default' | 'secondary' | 'outline' | 'destructive';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A small label for status, counts, or categories. Use for tags,
|
|
10
|
+
* notifications counts, status indicators, or labels.
|
|
11
|
+
*
|
|
12
|
+
* @category Feedback
|
|
13
|
+
* @useCases status label, notification count, tag, category, version
|
|
14
|
+
* @keywords badge, label, tag, status, count, chip, pill
|
|
15
|
+
* @related UiButton
|
|
16
|
+
*/
|
|
17
|
+
export interface UiBadgeProps {
|
|
18
|
+
/**
|
|
19
|
+
* Variant types for the badge
|
|
20
|
+
* @default default
|
|
21
|
+
*/
|
|
22
|
+
variant?: UiBadgeVariants;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether to render as a child (Slot) instead of a wrapper element.
|
|
26
|
+
* Useful for tooltips or wrapping other components.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
asChild?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Icon component to display before the badge text.
|
|
33
|
+
* @example
|
|
34
|
+
* ```vue
|
|
35
|
+
* <UiBadge :startIcon="InfoIcon">Info</UiBadge>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
startIcon?: Component;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Icon component to display after the badge text.
|
|
42
|
+
* @example
|
|
43
|
+
* ```vue
|
|
44
|
+
* <UiBadge :endIcon="CloseIcon">Dismissible</UiBadge>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
endIcon?: Component;
|
|
48
|
+
}
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import UiButton from './UiButton.vue';
|
|
3
|
+
import { UiIcon } from '../UiIcon';
|
|
4
|
+
|
|
5
|
+
const ChevronLeftIcon = {
|
|
6
|
+
components: { UiIcon },
|
|
7
|
+
template: '<UiIcon icon="i-material-symbols-chevron-left" class="size-4" />',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const ChevronRightIcon = {
|
|
11
|
+
components: { UiIcon },
|
|
12
|
+
template: '<UiIcon icon="i-material-symbols-chevron-right" class="size-4" />',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const MailIcon = {
|
|
16
|
+
components: { UiIcon },
|
|
17
|
+
template: '<UiIcon icon="i-material-symbols-mail" class="size-4" />',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const meta: Meta<typeof UiButton> = {
|
|
21
|
+
title: 'Primitives/UiButton',
|
|
22
|
+
component: UiButton,
|
|
23
|
+
tags: ['autodocs'],
|
|
24
|
+
argTypes: {
|
|
25
|
+
variant: {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'],
|
|
28
|
+
description: 'The visual style of the button',
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
control: 'select',
|
|
32
|
+
options: ['default', 'xs', 'sm', 'lg'],
|
|
33
|
+
description: 'The size of the button',
|
|
34
|
+
},
|
|
35
|
+
disabled: {
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
description: 'Disables the button',
|
|
38
|
+
},
|
|
39
|
+
loading: {
|
|
40
|
+
control: 'boolean',
|
|
41
|
+
description: 'Shows a loading state and prevents interaction',
|
|
42
|
+
},
|
|
43
|
+
startIcon: {
|
|
44
|
+
control: false,
|
|
45
|
+
description: 'Icon component to display before the button text',
|
|
46
|
+
},
|
|
47
|
+
endIcon: {
|
|
48
|
+
control: false,
|
|
49
|
+
description: 'Icon component to display after the button text',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
args: {
|
|
53
|
+
variant: 'default',
|
|
54
|
+
size: 'default',
|
|
55
|
+
disabled: false,
|
|
56
|
+
loading: false,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default meta;
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof UiButton>;
|
|
63
|
+
|
|
64
|
+
const defaultTemplateSource = `<script setup lang="ts">
|
|
65
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<UiButton>Default</UiButton>
|
|
70
|
+
</template>`;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Default button variant.
|
|
74
|
+
*/
|
|
75
|
+
export const Default: Story = {
|
|
76
|
+
render: (args) => ({
|
|
77
|
+
components: { UiButton },
|
|
78
|
+
setup() {
|
|
79
|
+
return { args };
|
|
80
|
+
},
|
|
81
|
+
template: `<UiButton :variant="args.variant" :size="args.size" :disabled="args.disabled" :loading="args.loading">Default</UiButton>`,
|
|
82
|
+
}),
|
|
83
|
+
parameters: {
|
|
84
|
+
docs: {
|
|
85
|
+
source: {
|
|
86
|
+
code: defaultTemplateSource,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const outlineTemplateSource = `<script setup lang="ts">
|
|
93
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<UiButton variant="outline">Outline</UiButton>
|
|
98
|
+
</template>`;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Outline button variant.
|
|
102
|
+
*/
|
|
103
|
+
export const Outline: Story = {
|
|
104
|
+
render: () => ({
|
|
105
|
+
components: { UiButton },
|
|
106
|
+
template: `<UiButton variant="outline">Outline</UiButton>`,
|
|
107
|
+
}),
|
|
108
|
+
parameters: {
|
|
109
|
+
docs: {
|
|
110
|
+
source: {
|
|
111
|
+
code: outlineTemplateSource,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const secondaryTemplateSource = `<script setup lang="ts">
|
|
118
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<template>
|
|
122
|
+
<UiButton variant="secondary">Secondary</UiButton>
|
|
123
|
+
</template>`;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Secondary button variant.
|
|
127
|
+
*/
|
|
128
|
+
export const Secondary: Story = {
|
|
129
|
+
render: () => ({
|
|
130
|
+
components: { UiButton },
|
|
131
|
+
template: `<UiButton variant="secondary">Secondary</UiButton>`,
|
|
132
|
+
}),
|
|
133
|
+
parameters: {
|
|
134
|
+
docs: {
|
|
135
|
+
source: {
|
|
136
|
+
code: secondaryTemplateSource,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const ghostTemplateSource = `<script setup lang="ts">
|
|
143
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<template>
|
|
147
|
+
<UiButton variant="ghost">Ghost</UiButton>
|
|
148
|
+
</template>`;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Ghost button variant.
|
|
152
|
+
*/
|
|
153
|
+
export const Ghost: Story = {
|
|
154
|
+
render: () => ({
|
|
155
|
+
components: { UiButton },
|
|
156
|
+
template: `<UiButton variant="ghost">Ghost</UiButton>`,
|
|
157
|
+
}),
|
|
158
|
+
parameters: {
|
|
159
|
+
docs: {
|
|
160
|
+
source: {
|
|
161
|
+
code: ghostTemplateSource,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const destructiveTemplateSource = `<script setup lang="ts">
|
|
168
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<template>
|
|
172
|
+
<UiButton variant="destructive">Destructive</UiButton>
|
|
173
|
+
</template>`;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Destructive button variant.
|
|
177
|
+
*/
|
|
178
|
+
export const Destructive: Story = {
|
|
179
|
+
render: () => ({
|
|
180
|
+
components: { UiButton },
|
|
181
|
+
template: `<UiButton variant="destructive">Destructive</UiButton>`,
|
|
182
|
+
}),
|
|
183
|
+
parameters: {
|
|
184
|
+
docs: {
|
|
185
|
+
source: {
|
|
186
|
+
code: destructiveTemplateSource,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const linkTemplateSource = `<script setup lang="ts">
|
|
193
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<template>
|
|
197
|
+
<UiButton variant="link">Link</UiButton>
|
|
198
|
+
</template>`;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Link button variant.
|
|
202
|
+
*/
|
|
203
|
+
export const Link: Story = {
|
|
204
|
+
render: () => ({
|
|
205
|
+
components: { UiButton },
|
|
206
|
+
template: `<UiButton variant="link">Link</UiButton>`,
|
|
207
|
+
}),
|
|
208
|
+
parameters: {
|
|
209
|
+
docs: {
|
|
210
|
+
source: {
|
|
211
|
+
code: linkTemplateSource,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const sizesTemplateSource = `<script setup lang="ts">
|
|
218
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<template>
|
|
222
|
+
<div class="flex items-center gap-4">
|
|
223
|
+
<UiButton size="xs" variant="outline">Extra Small</UiButton>
|
|
224
|
+
<UiButton size="sm" variant="outline">Small</UiButton>
|
|
225
|
+
<UiButton variant="outline">Default</UiButton>
|
|
226
|
+
<UiButton size="lg" variant="outline">Large</UiButton>
|
|
227
|
+
</div>
|
|
228
|
+
</template>`;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Button sizes.
|
|
232
|
+
*/
|
|
233
|
+
export const Sizes: Story = {
|
|
234
|
+
render: () => ({
|
|
235
|
+
components: { UiButton },
|
|
236
|
+
template: `
|
|
237
|
+
<div class="flex items-center gap-4">
|
|
238
|
+
<UiButton size="xs" variant="outline">Extra Small</UiButton>
|
|
239
|
+
<UiButton size="sm" variant="outline">Small</UiButton>
|
|
240
|
+
<UiButton variant="outline">Default</UiButton>
|
|
241
|
+
<UiButton size="lg" variant="outline">Large</UiButton>
|
|
242
|
+
</div>
|
|
243
|
+
`,
|
|
244
|
+
}),
|
|
245
|
+
parameters: {
|
|
246
|
+
docs: {
|
|
247
|
+
source: {
|
|
248
|
+
code: sizesTemplateSource,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const withStartIconTemplateSource = `<script setup lang="ts">
|
|
255
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
256
|
+
|
|
257
|
+
const ChevronLeftIcon = {
|
|
258
|
+
components: { UiIcon },
|
|
259
|
+
template: '<UiIcon icon="i-material-symbols-chevron-left" class="size-4" />',
|
|
260
|
+
}
|
|
261
|
+
</script>
|
|
262
|
+
|
|
263
|
+
<template>
|
|
264
|
+
<UiButton :start-icon="ChevronLeftIcon">Back</UiButton>
|
|
265
|
+
</template>`;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Use the `startIcon` prop to add an icon before the button text.
|
|
269
|
+
*/
|
|
270
|
+
export const WithStartIcon: Story = {
|
|
271
|
+
render: () => ({
|
|
272
|
+
components: { UiButton },
|
|
273
|
+
setup() {
|
|
274
|
+
return { ChevronLeftIcon };
|
|
275
|
+
},
|
|
276
|
+
template: `<UiButton :start-icon="ChevronLeftIcon">Back</UiButton>`,
|
|
277
|
+
}),
|
|
278
|
+
parameters: {
|
|
279
|
+
docs: {
|
|
280
|
+
source: {
|
|
281
|
+
code: withStartIconTemplateSource,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const withEndIconTemplateSource = `<script setup lang="ts">
|
|
288
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
289
|
+
|
|
290
|
+
const ChevronRightIcon = {
|
|
291
|
+
components: { UiIcon },
|
|
292
|
+
template: '<UiIcon icon="i-material-symbols-chevron-right" class="size-4" />',
|
|
293
|
+
}
|
|
294
|
+
</script>
|
|
295
|
+
|
|
296
|
+
<template>
|
|
297
|
+
<UiButton :end-icon="ChevronRightIcon">Next</UiButton>
|
|
298
|
+
</template>`;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Use the `endIcon` prop to add an icon after the button text.
|
|
302
|
+
*/
|
|
303
|
+
export const WithEndIcon: Story = {
|
|
304
|
+
render: () => ({
|
|
305
|
+
components: { UiButton },
|
|
306
|
+
setup() {
|
|
307
|
+
return { ChevronRightIcon };
|
|
308
|
+
},
|
|
309
|
+
template: `<UiButton :end-icon="ChevronRightIcon">Next</UiButton>`,
|
|
310
|
+
}),
|
|
311
|
+
parameters: {
|
|
312
|
+
docs: {
|
|
313
|
+
source: {
|
|
314
|
+
code: withEndIconTemplateSource,
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const withBothIconsTemplateSource = `<script setup lang="ts">
|
|
321
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
322
|
+
|
|
323
|
+
const MailIcon = {
|
|
324
|
+
components: { UiIcon },
|
|
325
|
+
template: '<UiIcon icon="i-material-symbols-mail" class="size-4" />',
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const ChevronRightIcon = {
|
|
329
|
+
components: { UiIcon },
|
|
330
|
+
template: '<UiIcon icon="i-material-symbols-chevron-right" class="size-4" />',
|
|
331
|
+
}
|
|
332
|
+
</script>
|
|
333
|
+
|
|
334
|
+
<template>
|
|
335
|
+
<UiButton :start-icon="MailIcon" :end-icon="ChevronRightIcon">
|
|
336
|
+
Login with Email
|
|
337
|
+
</UiButton>
|
|
338
|
+
</template>`;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* You can use both `startIcon` and `endIcon` together.
|
|
342
|
+
*/
|
|
343
|
+
export const WithBothIcons: Story = {
|
|
344
|
+
render: () => ({
|
|
345
|
+
components: { UiButton },
|
|
346
|
+
setup() {
|
|
347
|
+
return { MailIcon, ChevronRightIcon };
|
|
348
|
+
},
|
|
349
|
+
template: `<UiButton :start-icon="MailIcon" :end-icon="ChevronRightIcon">Login with Email</UiButton>`,
|
|
350
|
+
}),
|
|
351
|
+
parameters: {
|
|
352
|
+
docs: {
|
|
353
|
+
source: {
|
|
354
|
+
code: withBothIconsTemplateSource,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const loadingTemplateSource = `<script setup lang="ts">
|
|
361
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
362
|
+
|
|
363
|
+
const MailIcon = {
|
|
364
|
+
components: { UiIcon },
|
|
365
|
+
template: '<UiIcon icon="i-material-symbols-mail" class="size-4" />',
|
|
366
|
+
}
|
|
367
|
+
</script>
|
|
368
|
+
|
|
369
|
+
<template>
|
|
370
|
+
<UiButton :loading="true" :start-icon="MailIcon">Please wait</UiButton>
|
|
371
|
+
</template>`;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* When loading is true, the spinner replaces the startIcon automatically.
|
|
375
|
+
*/
|
|
376
|
+
export const Loading: Story = {
|
|
377
|
+
render: () => ({
|
|
378
|
+
components: { UiButton },
|
|
379
|
+
setup() {
|
|
380
|
+
return { MailIcon };
|
|
381
|
+
},
|
|
382
|
+
template: `<UiButton :loading="true" :start-icon="MailIcon">Please wait</UiButton>`,
|
|
383
|
+
}),
|
|
384
|
+
parameters: {
|
|
385
|
+
docs: {
|
|
386
|
+
source: {
|
|
387
|
+
code: loadingTemplateSource,
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const loadingWithBothIconsTemplateSource = `<script setup lang="ts">
|
|
394
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
395
|
+
|
|
396
|
+
const MailIcon = {
|
|
397
|
+
components: { UiIcon },
|
|
398
|
+
template: '<UiIcon icon="i-material-symbols-mail" class="size-4" />',
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const ChevronRightIcon = {
|
|
402
|
+
components: { UiIcon },
|
|
403
|
+
template: '<UiIcon icon="i-material-symbols-chevron-right" class="size-4" />',
|
|
404
|
+
}
|
|
405
|
+
</script>
|
|
406
|
+
|
|
407
|
+
<template>
|
|
408
|
+
<UiButton :loading="true" :start-icon="MailIcon" :end-icon="ChevronRightIcon">
|
|
409
|
+
Saving changes
|
|
410
|
+
</UiButton>
|
|
411
|
+
</template>`;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* When a button has both start and end icons, the loading spinner replaces
|
|
415
|
+
* the startIcon while the endIcon stays visible.
|
|
416
|
+
*/
|
|
417
|
+
export const LoadingWithBothIcons: Story = {
|
|
418
|
+
render: () => ({
|
|
419
|
+
components: { UiButton },
|
|
420
|
+
setup() {
|
|
421
|
+
return { MailIcon, ChevronRightIcon };
|
|
422
|
+
},
|
|
423
|
+
template: `<UiButton :loading="true" :start-icon="MailIcon" :end-icon="ChevronRightIcon">Saving changes</UiButton>`,
|
|
424
|
+
}),
|
|
425
|
+
parameters: {
|
|
426
|
+
docs: {
|
|
427
|
+
source: {
|
|
428
|
+
code: loadingWithBothIconsTemplateSource,
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const withIconSlotTemplateSource = `<script setup lang="ts">
|
|
435
|
+
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
436
|
+
</script>
|
|
437
|
+
|
|
438
|
+
<template>
|
|
439
|
+
<UiButton variant="outline" size="sm">
|
|
440
|
+
<UiIcon icon="i-material-symbols-call-split" class="size-4" />
|
|
441
|
+
New Branch
|
|
442
|
+
</UiButton>
|
|
443
|
+
</template>`;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* For maximum flexibility, you can use slots to render custom icon content.
|
|
447
|
+
*/
|
|
448
|
+
export const WithIconSlot: Story = {
|
|
449
|
+
render: () => ({
|
|
450
|
+
components: { UiButton, UiIcon },
|
|
451
|
+
template: `
|
|
452
|
+
<UiButton variant="outline" size="sm">
|
|
453
|
+
<UiIcon icon="i-material-symbols-call-split" class="size-4" />
|
|
454
|
+
New Branch
|
|
455
|
+
</UiButton>
|
|
456
|
+
`,
|
|
457
|
+
}),
|
|
458
|
+
parameters: {
|
|
459
|
+
docs: {
|
|
460
|
+
source: {
|
|
461
|
+
code: withIconSlotTemplateSource,
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const asChildTemplateSource = `<script setup lang="ts">
|
|
468
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
469
|
+
</script>
|
|
470
|
+
|
|
471
|
+
<template>
|
|
472
|
+
<UiButton as-child>
|
|
473
|
+
<a href="/login">Login</a>
|
|
474
|
+
</UiButton>
|
|
475
|
+
</template>`;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Use `as-child` to make another component look like a button.
|
|
479
|
+
*/
|
|
480
|
+
export const AsChild: Story = {
|
|
481
|
+
render: () => ({
|
|
482
|
+
components: { UiButton },
|
|
483
|
+
template: `
|
|
484
|
+
<UiButton as-child>
|
|
485
|
+
<a href="/login">Login</a>
|
|
486
|
+
</UiButton>
|
|
487
|
+
`,
|
|
488
|
+
}),
|
|
489
|
+
parameters: {
|
|
490
|
+
docs: {
|
|
491
|
+
source: {
|
|
492
|
+
code: asChildTemplateSource,
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const allVariantsTemplateSource = `<script setup lang="ts">
|
|
499
|
+
import { UiButton } from '@aleph-alpha/ui-library'
|
|
500
|
+
</script>
|
|
501
|
+
|
|
502
|
+
<template>
|
|
503
|
+
<div class="flex flex-wrap gap-2">
|
|
504
|
+
<UiButton>Default</UiButton>
|
|
505
|
+
<UiButton variant="secondary">Secondary</UiButton>
|
|
506
|
+
<UiButton variant="destructive">Destructive</UiButton>
|
|
507
|
+
<UiButton variant="outline">Outline</UiButton>
|
|
508
|
+
<UiButton variant="ghost">Ghost</UiButton>
|
|
509
|
+
<UiButton variant="link">Link</UiButton>
|
|
510
|
+
</div>
|
|
511
|
+
</template>`;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* All button variants side by side.
|
|
515
|
+
*/
|
|
516
|
+
export const AllVariants: Story = {
|
|
517
|
+
render: () => ({
|
|
518
|
+
components: { UiButton },
|
|
519
|
+
template: `
|
|
520
|
+
<div class="flex flex-wrap gap-2">
|
|
521
|
+
<UiButton>Default</UiButton>
|
|
522
|
+
<UiButton variant="secondary">Secondary</UiButton>
|
|
523
|
+
<UiButton variant="destructive">Destructive</UiButton>
|
|
524
|
+
<UiButton variant="outline">Outline</UiButton>
|
|
525
|
+
<UiButton variant="ghost">Ghost</UiButton>
|
|
526
|
+
<UiButton variant="link">Link</UiButton>
|
|
527
|
+
</div>
|
|
528
|
+
`,
|
|
529
|
+
}),
|
|
530
|
+
parameters: {
|
|
531
|
+
docs: {
|
|
532
|
+
source: {
|
|
533
|
+
code: allVariantsTemplateSource,
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Button as ShadcnButton } from '@/primitives/shadcn/button';
|
|
3
|
+
import { UiSpinner } from '@/primitives/UiSpinner';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
import type { UiButtonProps, UiButtonVariant } from './types';
|
|
6
|
+
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: 'UiButton',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<UiButtonProps>(), {
|
|
12
|
+
variant: 'default',
|
|
13
|
+
size: 'default',
|
|
14
|
+
asChild: false,
|
|
15
|
+
type: 'button',
|
|
16
|
+
disabled: false,
|
|
17
|
+
loading: false,
|
|
18
|
+
ariaLabel: undefined,
|
|
19
|
+
startIcon: undefined,
|
|
20
|
+
endIcon: undefined,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const variantMap: Record<
|
|
24
|
+
UiButtonVariant,
|
|
25
|
+
'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link'
|
|
26
|
+
> = {
|
|
27
|
+
default: 'default',
|
|
28
|
+
destructive: 'destructive',
|
|
29
|
+
outline: 'outline',
|
|
30
|
+
secondary: 'secondary',
|
|
31
|
+
ghost: 'ghost',
|
|
32
|
+
link: 'link',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const sizeMap: Record<'default' | 'xs' | 'sm' | 'lg', 'default' | 'xs' | 'sm' | 'lg'> = {
|
|
36
|
+
default: 'default',
|
|
37
|
+
xs: 'xs',
|
|
38
|
+
sm: 'sm',
|
|
39
|
+
lg: 'lg',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isDisabled = computed(() => props.disabled || props.loading);
|
|
43
|
+
|
|
44
|
+
function handleClick(e: MouseEvent) {
|
|
45
|
+
if (isDisabled.value) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<ShadcnButton
|
|
54
|
+
:variant="variantMap[props.variant]"
|
|
55
|
+
:size="sizeMap[props.size]"
|
|
56
|
+
:aria-label="props.ariaLabel"
|
|
57
|
+
:as-child="props.asChild"
|
|
58
|
+
:type="props.type"
|
|
59
|
+
:disabled="isDisabled"
|
|
60
|
+
:aria-busy="props.loading ? 'true' : undefined"
|
|
61
|
+
@click="handleClick"
|
|
62
|
+
>
|
|
63
|
+
<UiSpinner v-if="props.loading && !props.asChild" class="mr-2" aria-label="Loading" />
|
|
64
|
+
<component
|
|
65
|
+
:is="props.startIcon"
|
|
66
|
+
v-else-if="props.startIcon && !props.asChild"
|
|
67
|
+
class="mr-2 size-4"
|
|
68
|
+
/>
|
|
69
|
+
<slot />
|
|
70
|
+
<component :is="props.endIcon" v-if="props.endIcon && !props.asChild" class="ml-2 size-4" />
|
|
71
|
+
</ShadcnButton>
|
|
72
|
+
</template>
|