@indielayer/ui 2.0.0 → 2.1.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/docs/App.vue +19 -4
- package/docs/assets/css/tailwind.css +7 -1
- package/docs/components/Cookies.vue +3 -1
- package/docs/components/common/CodePreview.vue +1 -1
- package/docs/components/common/DocsCopyPage.vue +200 -0
- package/docs/components/common/DocumentPage.vue +76 -23
- package/docs/components/toolbar/ToolbarColorToggle.vue +29 -18
- package/docs/components/toolbar/ToolbarSearch.vue +4 -4
- package/docs/composables/useDocMeta.ts +63 -4
- package/docs/icons.ts +3 -0
- package/docs/main.ts +25 -26
- package/docs/pages/component/accordion/index.vue +2 -2
- package/docs/pages/component/alert/index.vue +2 -2
- package/docs/pages/component/avatar/index.vue +4 -4
- package/docs/pages/component/badge/index.vue +2 -2
- package/docs/pages/component/breadcrumbs/index.vue +2 -2
- package/docs/pages/component/button/button-group.vue +3 -3
- package/docs/pages/component/button/index.vue +14 -7
- package/docs/pages/component/button/tooltip.vue +10 -0
- package/docs/pages/component/card/index.vue +2 -2
- package/docs/pages/component/carousel/index.vue +2 -2
- package/docs/pages/component/checkbox/index.vue +5 -5
- package/docs/pages/component/container/index.vue +2 -2
- package/docs/pages/component/datepicker/index.vue +2 -2
- package/docs/pages/component/divider/index.vue +4 -4
- package/docs/pages/component/drawer/index.vue +2 -2
- package/docs/pages/component/empty/index.vue +3 -3
- package/docs/pages/component/form/index.vue +2 -2
- package/docs/pages/component/formGroup/index.vue +2 -2
- package/docs/pages/component/infiniteLoader/index.vue +3 -3
- package/docs/pages/component/input/index.vue +5 -5
- package/docs/pages/component/inputGroup/index.vue +3 -3
- package/docs/pages/component/inputGroup/validation.vue +6 -1
- package/docs/pages/component/link/index.vue +2 -2
- package/docs/pages/component/loader/index.vue +2 -2
- package/docs/pages/component/menu/index.vue +2 -2
- package/docs/pages/component/modal/index.vue +3 -3
- package/docs/pages/component/notifications/index.vue +2 -2
- package/docs/pages/component/pagination/index.vue +2 -2
- package/docs/pages/component/popover/index.vue +2 -2
- package/docs/pages/component/popover/usage.vue +14 -0
- package/docs/pages/component/progress/index.vue +3 -3
- package/docs/pages/component/qrCode/index.vue +2 -2
- package/docs/pages/component/radio/index.vue +3 -3
- package/docs/pages/component/scroll/index.vue +3 -3
- package/docs/pages/component/select/index.vue +5 -5
- package/docs/pages/component/skeleton/index.vue +2 -2
- package/docs/pages/component/slider/index.vue +2 -2
- package/docs/pages/component/spacer/index.vue +2 -2
- package/docs/pages/component/spinner/index.vue +3 -3
- package/docs/pages/component/table/index.vue +4 -4
- package/docs/pages/component/tabs/index.vue +2 -2
- package/docs/pages/component/tabs/usage.vue +26 -0
- package/docs/pages/component/tag/index.vue +2 -2
- package/docs/pages/component/textarea/index.vue +4 -4
- package/docs/pages/component/toggle/index.vue +4 -4
- package/docs/pages/component/upload/index.vue +2 -2
- package/docs/pages/component/upload/usage.vue +1 -0
- package/docs/pages/component/virtualGrid/index.vue +2 -2
- package/docs/pages/component/virtualList/index.vue +3 -3
- package/docs/pages/icons.vue +2 -2
- package/docs/router/index.ts +39 -44
- package/docs/search/components.json +1 -1
- package/docs/search/index.json +1 -1
- package/lib/common/buttonGroupRadius.d.ts +3 -0
- package/lib/common/buttonGroupRadius.js +6 -0
- package/lib/common/props.d.ts +1 -1
- package/lib/common/props.js +10 -9
- package/lib/components/accordion/Accordion.vue.d.ts +42 -9
- package/lib/components/accordion/Accordion.vue_vue_type_script_setup_true_lang.js +18 -6
- package/lib/components/accordion/AccordionItem.vue.d.ts +33 -6
- package/lib/components/accordion/AccordionItem.vue_vue_type_script_setup_true_lang.js +31 -6
- package/lib/components/alert/Alert.vue.d.ts +27 -6
- package/lib/components/alert/Alert.vue_vue_type_script_setup_true_lang.js +20 -6
- package/lib/components/avatar/Avatar.vue.d.ts +45 -9
- package/lib/components/avatar/Avatar.vue_vue_type_script_setup_true_lang.js +17 -6
- package/lib/components/badge/Badge.vue.d.ts +54 -9
- package/lib/components/badge/Badge.vue_vue_type_script_setup_true_lang.js +26 -9
- package/lib/components/breadcrumbs/Breadcrumbs.vue.d.ts +30 -6
- package/lib/components/breadcrumbs/Breadcrumbs.vue_vue_type_script_setup_true_lang.js +13 -5
- package/lib/components/button/Button.js +2 -2
- package/lib/components/button/Button.vue.d.ts +138 -28
- package/lib/components/button/Button.vue_vue_type_script_setup_true_lang.js +192 -70
- package/lib/components/button/ButtonGroup.js +4 -5
- package/lib/components/button/ButtonGroup.vue.d.ts +54 -10
- package/lib/components/button/ButtonGroup.vue_vue_type_script_setup_true_lang.js +30 -19
- package/lib/components/button/theme/Button.base.theme.js +6 -5
- package/lib/components/button/theme/Button.carbon.theme.js +6 -5
- package/lib/components/card/Card.vue.d.ts +3 -0
- package/lib/components/card/Card.vue_vue_type_script_setup_true_lang.js +4 -2
- package/lib/components/carousel/Carousel.vue.d.ts +21 -3
- package/lib/components/carousel/Carousel.vue_vue_type_script_setup_true_lang.js +23 -5
- package/lib/components/carousel/CarouselSlide.js +2 -2
- package/lib/components/carousel/CarouselSlide.vue.d.ts +3 -0
- package/lib/components/carousel/CarouselSlide.vue_vue_type_script_setup_true_lang.js +3 -1
- package/lib/components/carousel/{CarouselSlide.vue_vue_type_style_index_0_scoped_e90d2127_lang.module.js → CarouselSlide.vue_vue_type_style_index_0_scoped_4f559831_lang.module.js} +1 -1
- package/lib/components/checkbox/Checkbox.vue.d.ts +198 -45
- package/lib/components/checkbox/Checkbox.vue_vue_type_script_setup_true_lang.js +20 -3
- package/lib/components/container/Container.vue.d.ts +6 -0
- package/lib/components/container/Container.vue_vue_type_script_setup_true_lang.js +5 -2
- package/lib/components/datepicker/Datepicker.vue.d.ts +462 -36
- package/lib/components/datepicker/Datepicker.vue_vue_type_script_setup_true_lang.js +294 -153
- package/lib/components/divider/Divider.vue.d.ts +12 -3
- package/lib/components/divider/Divider.vue_vue_type_script_setup_true_lang.js +6 -2
- package/lib/components/drawer/Drawer.vue.d.ts +39 -6
- package/lib/components/drawer/Drawer.vue_vue_type_script_setup_true_lang.js +30 -7
- package/lib/components/empty/Empty.vue.d.ts +30 -6
- package/lib/components/empty/Empty.vue_vue_type_script_setup_true_lang.js +17 -4
- package/lib/components/form/Form.vue.d.ts +48 -9
- package/lib/components/form/Form.vue_vue_type_script_setup_true_lang.js +34 -7
- package/lib/components/formGroup/FormGroup.vue.d.ts +171 -39
- package/lib/components/formGroup/FormGroup.vue_vue_type_script_setup_true_lang.js +15 -9
- package/lib/components/icon/Icon.vue.d.ts +9 -0
- package/lib/components/icon/Icon.vue_vue_type_script_setup_true_lang.js +6 -3
- package/lib/components/image/Image.vue.d.ts +12 -3
- package/lib/components/image/Image.vue_vue_type_script_setup_true_lang.js +5 -1
- package/lib/components/index.js +18 -18
- package/lib/components/input/Input.vue.d.ts +291 -66
- package/lib/components/input/Input.vue_vue_type_script_setup_true_lang.js +53 -15
- package/lib/components/inputFooter/InputFooter.vue.d.ts +48 -12
- package/lib/components/inputFooter/InputFooter.vue_vue_type_script_setup_true_lang.js +18 -5
- package/lib/components/inputGroup/InputGroup.vue.d.ts +171 -39
- package/lib/components/inputGroup/InputGroup.vue_vue_type_script_setup_true_lang.js +6 -1
- package/lib/components/label/Label.vue.d.ts +78 -18
- package/lib/components/label/Label.vue_vue_type_script_setup_true_lang.js +28 -8
- package/lib/components/link/Link.js +2 -2
- package/lib/components/link/Link.vue.d.ts +18 -3
- package/lib/components/link/Link.vue_vue_type_script_setup_true_lang.js +10 -5
- package/lib/components/loader/Loader.vue.d.ts +30 -6
- package/lib/components/loader/Loader.vue_vue_type_script_setup_true_lang.js +11 -3
- package/lib/components/menu/Menu.vue.d.ts +51 -9
- package/lib/components/menu/Menu.vue_vue_type_script_setup_true_lang.js +24 -8
- package/lib/components/menu/MenuItem.js +2 -2
- package/lib/components/menu/MenuItem.vue.d.ts +198 -45
- package/lib/components/menu/MenuItem.vue_vue_type_script_setup_true_lang.js +84 -23
- package/lib/components/menu/{MenuItem.vue_vue_type_style_index_0_scoped_2a6b7341_lang.module.js → MenuItem.vue_vue_type_style_index_0_scoped_5aebaff3_lang.module.js} +1 -1
- package/lib/components/modal/Modal.vue.d.ts +177 -39
- package/lib/components/modal/Modal.vue_vue_type_script_setup_true_lang.js +104 -23
- package/lib/components/notifications/Notifications.vue.d.ts +24 -0
- package/lib/components/notifications/Notifications.vue_vue_type_script_setup_true_lang.js +39 -12
- package/lib/components/pagination/Pagination.vue.d.ts +12 -0
- package/lib/components/pagination/Pagination.vue_vue_type_script_setup_true_lang.js +8 -4
- package/lib/components/pagination/PaginationItem.vue.d.ts +18 -3
- package/lib/components/pagination/PaginationItem.vue_vue_type_script_setup_true_lang.js +8 -3
- package/lib/components/popover/Popover.vue.d.ts +204 -45
- package/lib/components/popover/Popover.vue_vue_type_script_setup_true_lang.js +157 -66
- package/lib/components/popover/PopoverContainer.vue.d.ts +3 -0
- package/lib/components/popover/PopoverContainer.vue_vue_type_script_setup_true_lang.js +3 -1
- package/lib/components/popover/PopoverContentBoundary.js +5 -0
- package/lib/components/popover/PopoverContentBoundary.vue.d.ts +9 -0
- package/lib/components/popover/PopoverContentBoundary.vue_vue_type_script_setup_true_lang.js +18 -0
- package/lib/components/popover/theme/PopoverContainer.base.theme.js +1 -1
- package/lib/components/progress/Progress.vue.d.ts +9 -0
- package/lib/components/progress/Progress.vue_vue_type_script_setup_true_lang.js +7 -4
- package/lib/components/qrCode/QrCode.vue.d.ts +24 -3
- package/lib/components/qrCode/QrCode.vue_vue_type_script_setup_true_lang.js +13 -5
- package/lib/components/radio/Radio.vue.d.ts +186 -42
- package/lib/components/radio/Radio.vue_vue_type_script_setup_true_lang.js +10 -2
- package/lib/components/radioButton/RadioButton.vue.d.ts +186 -42
- package/lib/components/radioButton/RadioButton.vue_vue_type_script_setup_true_lang.js +9 -1
- package/lib/components/scroll/Scroll.vue.d.ts +3 -0
- package/lib/components/scroll/Scroll.vue_vue_type_script_setup_true_lang.js +9 -4
- package/lib/components/select/Select.vue.d.ts +633 -144
- package/lib/components/select/Select.vue_vue_type_script_setup_true_lang.js +224 -189
- package/lib/components/skeleton/Skeleton.vue.d.ts +6 -0
- package/lib/components/skeleton/Skeleton.vue_vue_type_script_setup_true_lang.js +5 -2
- package/lib/components/slider/Slider.js +1 -1
- package/lib/components/slider/Slider.vue.d.ts +180 -39
- package/lib/components/slider/Slider.vue_vue_type_script_setup_true_lang.js +14 -3
- package/lib/components/spinner/Spinner.vue.d.ts +6 -0
- package/lib/components/spinner/Spinner.vue_vue_type_script_setup_true_lang.js +3 -1
- package/lib/components/stepper/Stepper.vue.d.ts +120 -24
- package/lib/components/stepper/Stepper.vue_vue_type_script_setup_true_lang.js +63 -15
- package/lib/components/tab/Tab.vue.d.ts +112 -31
- package/lib/components/tab/Tab.vue_vue_type_script_setup_true_lang.js +166 -95
- package/lib/components/tab/TabGroup.vue.d.ts +47 -12
- package/lib/components/tab/TabGroup.vue_vue_type_script_setup_true_lang.js +93 -49
- package/lib/components/tab/theme/Tab.base.theme.js +6 -6
- package/lib/components/tab/theme/Tab.carbon.theme.js +6 -6
- package/lib/components/tab/theme/TabGroup.base.theme.js +7 -7
- package/lib/components/tab/theme/TabGroup.carbon.theme.js +3 -3
- package/lib/components/table/Table.vue.d.ts +45 -9
- package/lib/components/table/Table.vue_vue_type_script_setup_true_lang.js +82 -27
- package/lib/components/table/TableCell.vue.d.ts +54 -12
- package/lib/components/table/TableCell.vue_vue_type_script_setup_true_lang.js +23 -8
- package/lib/components/table/TableHead.vue_vue_type_script_setup_true_lang.js +2 -1
- package/lib/components/table/TableHeader.vue.d.ts +18 -3
- package/lib/components/table/TableHeader.vue_vue_type_script_setup_true_lang.js +10 -4
- package/lib/components/table/TableRow.vue.d.ts +15 -3
- package/lib/components/table/TableRow.vue_vue_type_script_setup_true_lang.js +10 -5
- package/lib/components/tag/Tag.vue.d.ts +33 -6
- package/lib/components/tag/Tag.vue_vue_type_script_setup_true_lang.js +21 -7
- package/lib/components/textarea/Textarea.vue.d.ts +237 -54
- package/lib/components/textarea/Textarea.vue_vue_type_script_setup_true_lang.js +38 -13
- package/lib/components/themeProvider/ThemeProvider.vue.d.ts +10 -4
- package/lib/components/themeProvider/ThemeProvider.vue_vue_type_script_setup_true_lang.js +6 -1
- package/lib/components/toggle/Toggle.vue.d.ts +174 -39
- package/lib/components/toggle/Toggle.vue_vue_type_script_setup_true_lang.js +5 -1
- package/lib/components/tooltip/ToggleTip.vue.d.ts +24 -6
- package/lib/components/tooltip/ToggleTip.vue_vue_type_script_setup_true_lang.js +9 -2
- package/lib/components/tooltip/Tooltip.vue.d.ts +30 -6
- package/lib/components/tooltip/Tooltip.vue_vue_type_script_setup_true_lang.js +16 -4
- package/lib/components/upload/Upload.vue.d.ts +249 -57
- package/lib/components/upload/Upload.vue_vue_type_script_setup_true_lang.js +156 -125
- package/lib/components/upload/fileAccept.d.ts +6 -0
- package/lib/components/upload/fileAccept.js +17 -0
- package/lib/composables/useColors.d.ts +1 -0
- package/lib/composables/useColors.js +2 -1
- package/lib/composables/useCommon.d.ts +1 -0
- package/lib/composables/useCommon.js +2 -1
- package/lib/composables/useFocusTrap.js +1 -1
- package/lib/composables/useInputtable.d.ts +45 -10
- package/lib/composables/useInputtable.js +56 -14
- package/lib/composables/useInteractive.d.ts +13 -3
- package/lib/composables/useInteractive.js +14 -4
- package/lib/index.js +12 -12
- package/lib/index.umd.js +9 -10
- package/lib/themes/base/styles.d.ts +1 -1
- package/lib/themes/base/styles.js +1 -1
- package/lib/themes/carbon/styles.d.ts +1 -1
- package/lib/themes/carbon/styles.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue.d.ts +27 -16
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue_vue_type_script_setup_true_lang.js +25 -5
- package/lib/virtual/components/virtualGrid/VirtualGrid.vue.d.ts +108 -86
- package/lib/virtual/components/virtualGrid/VirtualGrid.vue_vue_type_script_setup_true_lang.js +91 -21
- package/lib/virtual/components/virtualList/VirtualList.vue.d.ts +62 -48
- package/lib/virtual/components/virtualList/VirtualList.vue_vue_type_script_setup_true_lang.js +64 -13
- package/lib/virtual/components/virtualList/useDynamicRowHeight.js +4 -3
- package/package.json +5 -3
- package/src/common/buttonGroupRadius.ts +16 -0
- package/src/common/props.ts +10 -9
- package/src/components/accordion/Accordion.vue +20 -4
- package/src/components/accordion/AccordionItem.vue +28 -3
- package/src/components/alert/Alert.vue +22 -6
- package/src/components/avatar/Avatar.vue +20 -5
- package/src/components/badge/Badge.vue +24 -5
- package/src/components/breadcrumbs/Breadcrumbs.vue +15 -5
- package/src/components/button/Button.vue +140 -5
- package/src/components/button/ButtonGroup.vue +41 -25
- package/src/components/button/__tests__/ Button.spec.ts +41 -0
- package/src/components/button/__tests__/ ButtonGroup.spec.ts +32 -0
- package/src/components/button/theme/Button.base.theme.ts +4 -1
- package/src/components/button/theme/Button.carbon.theme.ts +5 -4
- package/src/components/card/Card.vue +10 -2
- package/src/components/carousel/Carousel.vue +22 -2
- package/src/components/carousel/CarouselSlide.vue +6 -0
- package/src/components/checkbox/Checkbox.vue +22 -3
- package/src/components/container/Container.vue +10 -1
- package/src/components/datepicker/Datepicker.vue +466 -101
- package/src/components/datepicker/__tests__/Datepicker.spec.ts +31 -0
- package/src/components/divider/Divider.vue +9 -3
- package/src/components/drawer/Drawer.vue +27 -2
- package/src/components/empty/Empty.vue +18 -3
- package/src/components/form/Form.vue +32 -3
- package/src/components/formGroup/FormGroup.vue +12 -0
- package/src/components/icon/Icon.vue +4 -1
- package/src/components/image/Image.vue +8 -2
- package/src/components/input/Input.vue +54 -12
- package/src/components/inputFooter/InputFooter.vue +21 -6
- package/src/components/inputGroup/InputGroup.vue +12 -1
- package/src/components/label/Label.vue +31 -7
- package/src/components/link/Link.vue +16 -5
- package/src/components/loader/Loader.vue +10 -2
- package/src/components/menu/Menu.vue +23 -5
- package/src/components/menu/MenuItem.vue +78 -17
- package/src/components/modal/Modal.vue +90 -15
- package/src/components/notifications/Notifications.vue +23 -0
- package/src/components/notifications/__tests__/Notifications.spec.ts +44 -4
- package/src/components/pagination/Pagination.vue +9 -1
- package/src/components/pagination/PaginationItem.vue +11 -2
- package/src/components/popover/Popover.vue +113 -18
- package/src/components/popover/PopoverContainer.vue +9 -1
- package/src/components/popover/PopoverContentBoundary.vue +32 -0
- package/src/components/popover/__tests__/Popover.spec.ts +51 -0
- package/src/components/popover/theme/PopoverContainer.base.theme.ts +1 -1
- package/src/components/progress/Progress.vue +8 -3
- package/src/components/qrCode/QrCode.vue +9 -1
- package/src/components/radio/Radio.vue +16 -2
- package/src/components/radioButton/RadioButton.vue +15 -1
- package/src/components/scroll/Scroll.vue +15 -4
- package/src/components/select/Select.vue +53 -16
- package/src/components/skeleton/Skeleton.vue +3 -0
- package/src/components/slider/Slider.vue +15 -0
- package/src/components/spinner/Spinner.vue +2 -0
- package/src/components/stepper/Stepper.vue +57 -9
- package/src/components/tab/Tab.vue +153 -63
- package/src/components/tab/TabGroup.vue +110 -26
- package/src/components/tab/__tests__/Tab.spec.ts +53 -0
- package/src/components/tab/__tests__/TabGroup.spec.ts +113 -0
- package/src/components/tab/theme/Tab.base.theme.ts +24 -2
- package/src/components/tab/theme/Tab.carbon.theme.ts +30 -7
- package/src/components/tab/theme/TabGroup.base.theme.ts +12 -9
- package/src/components/tab/theme/TabGroup.carbon.theme.ts +6 -2
- package/src/components/table/Table.vue +76 -19
- package/src/components/table/TableCell.vue +25 -6
- package/src/components/table/TableHead.vue +9 -2
- package/src/components/table/TableHeader.vue +16 -3
- package/src/components/table/TableRow.vue +17 -5
- package/src/components/tag/Tag.vue +22 -6
- package/src/components/textarea/Textarea.vue +40 -11
- package/src/components/themeProvider/ThemeProvider.vue +22 -7
- package/src/components/toggle/Toggle.vue +9 -1
- package/src/components/tooltip/ToggleTip.vue +12 -3
- package/src/components/tooltip/Tooltip.vue +19 -3
- package/src/components/upload/Upload.vue +46 -16
- package/src/components/upload/__tests__/fileAccept.spec.ts +39 -0
- package/src/components/upload/fileAccept.ts +29 -0
- package/src/composables/useColors.ts +1 -0
- package/src/composables/useCommon.ts +1 -0
- package/src/composables/useFocusTrap.ts +3 -1
- package/src/composables/useInputtable.ts +66 -10
- package/src/composables/useInteractive.ts +13 -3
- package/src/themes/base/styles.ts +2 -3
- package/src/themes/carbon/styles.ts +2 -3
- package/src/version.ts +1 -1
- package/src/virtual/components/infiniteLoader/InfiniteLoader.vue +33 -1
- package/src/virtual/components/virtualGrid/VirtualGrid.vue +104 -10
- package/src/virtual/components/virtualList/VirtualList.vue +73 -8
- package/src/virtual/components/virtualList/useDynamicRowHeight.ts +9 -2
- package/volar.d.ts +3 -0
- package/docs/layouts/simple.vue +0 -5
- package/lib/components/button/ButtonGroup.vue_vue_type_style_index_0_lang.module.js +0 -7
- /package/lib/components/button/{Button.vue_vue_type_style_index_0_scoped_4402fde2_lang.module.js → Button.vue_vue_type_style_index_0_scoped_486cb9c0_lang.module.js} +0 -0
- /package/lib/components/link/{Link.vue_vue_type_style_index_0_scoped_8e0e4d08_lang.module.js → Link.vue_vue_type_style_index_0_scoped_3ee61e03_lang.module.js} +0 -0
|
@@ -3,19 +3,50 @@ import { optionalBooleanProp } from '../../common/props'
|
|
|
3
3
|
|
|
4
4
|
const tabProps = {
|
|
5
5
|
...useCommon.props(),
|
|
6
|
+
size: {
|
|
7
|
+
type: String as PropType<Size>,
|
|
8
|
+
validator: (value: string) => useCommon.validators().size.includes(value),
|
|
9
|
+
description: 'Tab size. Falls back to the parent tab group size when omitted.',
|
|
10
|
+
},
|
|
6
11
|
value: {
|
|
7
12
|
type: [String, Number],
|
|
13
|
+
description: 'Value used to select this tab in the group.',
|
|
8
14
|
},
|
|
9
15
|
tag: {
|
|
10
16
|
type: String,
|
|
11
17
|
default: 'button',
|
|
18
|
+
description: 'Root element tag when not using `to`.',
|
|
19
|
+
},
|
|
20
|
+
to: {
|
|
21
|
+
type: [String, Object],
|
|
22
|
+
description: 'Vue Router location; renders as a link when set.',
|
|
23
|
+
},
|
|
24
|
+
label: {
|
|
25
|
+
type: String,
|
|
26
|
+
description: 'Visible label. Defaults to `value` when omitted.',
|
|
27
|
+
},
|
|
28
|
+
icon: {
|
|
29
|
+
type: String,
|
|
30
|
+
description: 'Icon name shown before the label.',
|
|
12
31
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
tooltip: {
|
|
33
|
+
type: String,
|
|
34
|
+
description: 'Tooltip text. Prefer the tooltip slot for custom content.',
|
|
35
|
+
},
|
|
36
|
+
tooltipPosition: {
|
|
37
|
+
type: String as PropType<TooltipPosition>,
|
|
38
|
+
default: 'top',
|
|
39
|
+
description: 'Tooltip placement relative to the tab.',
|
|
40
|
+
},
|
|
41
|
+
disabled: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
description: 'Prevents selecting this tab.',
|
|
44
|
+
},
|
|
45
|
+
exact: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
description: 'Requires exact route match when using `to`.',
|
|
48
|
+
},
|
|
49
|
+
removable: optionalBooleanProp('Shows a remove control that emits `remove`.'),
|
|
19
50
|
}
|
|
20
51
|
|
|
21
52
|
export type TabProps = ExtractPublicPropTypes<typeof tabProps>
|
|
@@ -23,6 +54,7 @@ export type TabProps = ExtractPublicPropTypes<typeof tabProps>
|
|
|
23
54
|
type InternalClasses = 'wrapper' | 'content' | 'label' | 'icon' | 'tabpanel'
|
|
24
55
|
type InternalExtraData = {
|
|
25
56
|
selected: boolean;
|
|
57
|
+
showLabel: boolean;
|
|
26
58
|
} & Pick<TabGroupInjection, 'state'>['state']
|
|
27
59
|
export interface TabTheme extends ThemeComponent<TabProps, InternalClasses, InternalExtraData> {}
|
|
28
60
|
|
|
@@ -31,11 +63,21 @@ export default {
|
|
|
31
63
|
validators: {
|
|
32
64
|
...useCommon.validators(),
|
|
33
65
|
},
|
|
66
|
+
docs: {
|
|
67
|
+
slots: {
|
|
68
|
+
default: 'Tab panel content shown when this tab is selected.',
|
|
69
|
+
tab: 'Custom tab trigger content. Slot props: label, value, size, icon.',
|
|
70
|
+
tooltip: 'Custom tooltip content; overrides the `tooltip` prop.',
|
|
71
|
+
},
|
|
72
|
+
emits: {
|
|
73
|
+
remove: 'Emitted when the remove control is clicked.',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
34
76
|
}
|
|
35
77
|
</script>
|
|
36
78
|
|
|
37
79
|
<script setup lang="ts">
|
|
38
|
-
import { inject, reactive, computed, ref, onMounted, type ExtractPublicPropTypes } from 'vue'
|
|
80
|
+
import { inject, reactive, computed, ref, onMounted, onBeforeUnmount, type ExtractPublicPropTypes, type PropType } from 'vue'
|
|
39
81
|
import { useMutationObserver } from '@vueuse/core'
|
|
40
82
|
import { injectTabGroupKey } from '../../composables/keys'
|
|
41
83
|
import { useCommon, type Size } from '../../composables/useCommon'
|
|
@@ -44,22 +86,40 @@ import { useResolvedComponentProps } from '../../composables/resolveComponentDef
|
|
|
44
86
|
|
|
45
87
|
import XIcon from '../icon/Icon.vue'
|
|
46
88
|
import XLink from '../link/Link.vue'
|
|
89
|
+
import XTooltip from '../tooltip/Tooltip.vue'
|
|
47
90
|
|
|
48
91
|
import { closeIcon } from '../../common/icons'
|
|
49
92
|
|
|
93
|
+
import type { TooltipPosition } from '../tooltip/Tooltip.vue'
|
|
50
94
|
import type { TabGroupInjection, TabGroupVariant } from './TabGroup.vue'
|
|
51
95
|
|
|
52
96
|
const props = defineProps(tabProps)
|
|
53
97
|
const resolvedProps = useResolvedComponentProps('Tab', props)
|
|
54
98
|
|
|
55
99
|
const computedValue = computed(() => (elRef.value as typeof XLink)?.$el?.href || props.value)
|
|
100
|
+
const showLabel = computed(() => {
|
|
101
|
+
if (props.icon && (props.label === undefined || props.label === '')) return false
|
|
102
|
+
|
|
103
|
+
return true
|
|
104
|
+
})
|
|
56
105
|
const computedLabel = computed(() => props.label || props.value)
|
|
106
|
+
const ariaLabel = computed(() => {
|
|
107
|
+
if (showLabel.value) return undefined
|
|
108
|
+
|
|
109
|
+
if (props.tooltip) return props.tooltip
|
|
110
|
+
if (props.label) return props.label
|
|
111
|
+
if (computedValue.value !== undefined && computedValue.value !== null) return String(computedValue.value)
|
|
112
|
+
|
|
113
|
+
return undefined
|
|
114
|
+
})
|
|
57
115
|
const teleportTo = ref<HTMLElement | null>(null)
|
|
58
116
|
const elRef = ref<HTMLElement | typeof XLink | null>(null)
|
|
59
117
|
|
|
60
118
|
const tabs = inject(injectTabGroupKey, {
|
|
61
119
|
tabsContentRef: ref(null),
|
|
62
120
|
activateTab: () => {},
|
|
121
|
+
registerTab: () => {},
|
|
122
|
+
unregisterTab: () => {},
|
|
63
123
|
state: reactive({
|
|
64
124
|
active: undefined,
|
|
65
125
|
variant: 'line' as TabGroupVariant,
|
|
@@ -72,11 +132,13 @@ const tabs = inject(injectTabGroupKey, {
|
|
|
72
132
|
})
|
|
73
133
|
|
|
74
134
|
const computedExact = computed(() => tabs.state.exact || props.exact)
|
|
75
|
-
const computedSize = computed(() => props.size
|
|
135
|
+
const computedSize = computed(() => props.size ?? tabs.state.size ?? 'md')
|
|
76
136
|
|
|
77
137
|
onMounted(() => {
|
|
78
138
|
teleportTo.value = tabs.tabsContentRef.value
|
|
79
139
|
|
|
140
|
+
if (typeof computedValue.value !== 'undefined') tabs.registerTab(computedValue.value)
|
|
141
|
+
|
|
80
142
|
if (props.to && elRef.value) {
|
|
81
143
|
check()
|
|
82
144
|
useMutationObserver((elRef.value as typeof XLink).$el, check, {
|
|
@@ -86,6 +148,10 @@ onMounted(() => {
|
|
|
86
148
|
}
|
|
87
149
|
})
|
|
88
150
|
|
|
151
|
+
onBeforeUnmount(() => {
|
|
152
|
+
if (typeof computedValue.value !== 'undefined') tabs.unregisterTab(computedValue.value)
|
|
153
|
+
})
|
|
154
|
+
|
|
89
155
|
function check() {
|
|
90
156
|
if (elRef.value && (elRef.value as typeof XLink).$el && (props.to)) {
|
|
91
157
|
const active = (elRef.value as typeof XLink).$el.classList.contains(computedExact.value ? 'router-link-exact-active' : 'router-link-active')
|
|
@@ -111,74 +177,98 @@ function onClickTab(e: MouseEvent) {
|
|
|
111
177
|
|
|
112
178
|
defineEmits(['remove'])
|
|
113
179
|
|
|
114
|
-
const
|
|
180
|
+
const isBlockLike = computed(() => tabs.state.variant === 'block' || tabs.state.variant === 'compact')
|
|
181
|
+
|
|
182
|
+
const themeProps = computed(() => ({
|
|
115
183
|
...props,
|
|
116
184
|
size: computedSize.value,
|
|
117
185
|
exact: computedExact.value,
|
|
118
|
-
})
|
|
186
|
+
}))
|
|
187
|
+
|
|
188
|
+
const { styles, classes, className } = useTheme('Tab', {}, themeProps, {
|
|
119
189
|
...tabs.state,
|
|
120
190
|
selected,
|
|
191
|
+
showLabel,
|
|
121
192
|
})
|
|
122
193
|
</script>
|
|
123
194
|
|
|
124
195
|
<template>
|
|
125
|
-
<
|
|
126
|
-
:
|
|
127
|
-
ref="elRef"
|
|
128
|
-
:type="tag === 'button' ? 'button' : undefined"
|
|
196
|
+
<x-tooltip
|
|
197
|
+
:position="tooltipPosition"
|
|
129
198
|
:data-value="computedValue"
|
|
130
|
-
:to="to"
|
|
131
|
-
:color="selected ? color : undefined"
|
|
132
|
-
:style="[
|
|
133
|
-
styles,
|
|
134
|
-
to && selected && tabs.state.variant === 'block'
|
|
135
|
-
? '--x-link-text: var(--x-tab-group-text); --x-link-text-hover: var(--x-tab-group-text);'
|
|
136
|
-
: ''
|
|
137
|
-
]"
|
|
138
199
|
:class="[
|
|
139
|
-
className,
|
|
140
|
-
classes.wrapper,
|
|
141
200
|
'shrink-0',
|
|
142
|
-
{
|
|
143
|
-
'flex-1': tabs.state.grow,
|
|
144
|
-
'text-[color:var(--x-tab-group-text)] dark:text-[color:var(--x-tab-group-dark-text)]': selected,
|
|
145
|
-
'cursor-pointer': !disabled,
|
|
146
|
-
'cursor-not-allowed': disabled,
|
|
147
|
-
'cursor-not-allowed text-secondary-500': disabled && !selected,
|
|
148
|
-
},
|
|
201
|
+
{ 'flex-1': tabs.state.grow },
|
|
149
202
|
]"
|
|
150
|
-
:aria-disabled="disabled ? 'true' : undefined"
|
|
151
|
-
:aria-selected="selected ? 'true' : 'false'"
|
|
152
|
-
@click="onClickTab"
|
|
153
203
|
>
|
|
154
|
-
<
|
|
155
|
-
name="
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
204
|
+
<template v-if="$slots.tooltip || tooltip" #tooltip>
|
|
205
|
+
<slot name="tooltip">
|
|
206
|
+
{{ tooltip }}
|
|
207
|
+
</slot>
|
|
208
|
+
</template>
|
|
209
|
+
<component
|
|
210
|
+
:is="to ? XLink : tag"
|
|
211
|
+
ref="elRef"
|
|
212
|
+
:type="tag === 'button' ? 'button' : undefined"
|
|
213
|
+
:to="to"
|
|
214
|
+
:color="selected ? color : undefined"
|
|
215
|
+
:style="[
|
|
216
|
+
styles,
|
|
217
|
+
to && selected && isBlockLike
|
|
218
|
+
? '--x-link-text: var(--x-tab-group-text); --x-link-text-hover: var(--x-tab-group-text);'
|
|
219
|
+
: ''
|
|
220
|
+
]"
|
|
221
|
+
:class="[
|
|
222
|
+
className,
|
|
223
|
+
classes.wrapper,
|
|
224
|
+
'flex items-center justify-center',
|
|
225
|
+
{
|
|
226
|
+
'w-full': tabs.state.grow,
|
|
227
|
+
'text-[color:var(--x-tab-group-text)] dark:text-[color:var(--x-tab-group-dark-text)]': selected,
|
|
228
|
+
'cursor-pointer': !disabled,
|
|
229
|
+
'cursor-not-allowed': disabled,
|
|
230
|
+
'cursor-not-allowed text-secondary-500': disabled && !selected,
|
|
231
|
+
},
|
|
232
|
+
]"
|
|
233
|
+
:aria-label="ariaLabel"
|
|
234
|
+
:aria-disabled="disabled ? 'true' : undefined"
|
|
235
|
+
:aria-selected="selected ? 'true' : 'false'"
|
|
236
|
+
@click="onClickTab"
|
|
160
237
|
>
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
<div :class="classes.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
238
|
+
<slot
|
|
239
|
+
name="tab"
|
|
240
|
+
:label="label"
|
|
241
|
+
:value="value"
|
|
242
|
+
:size="computedSize"
|
|
243
|
+
:icon="icon"
|
|
244
|
+
>
|
|
245
|
+
<div :class="classes.content">
|
|
246
|
+
<x-icon
|
|
247
|
+
v-if="icon"
|
|
248
|
+
:icon="icon"
|
|
249
|
+
:size="computedSize"
|
|
250
|
+
:class="classes.icon"
|
|
251
|
+
/>
|
|
252
|
+
<div
|
|
253
|
+
v-if="showLabel"
|
|
254
|
+
:class="classes.label"
|
|
255
|
+
>
|
|
256
|
+
{{ computedLabel }}
|
|
257
|
+
</div>
|
|
258
|
+
<x-icon
|
|
259
|
+
v-if="resolvedProps.removable"
|
|
260
|
+
size="sm"
|
|
261
|
+
:icon="closeIcon"
|
|
262
|
+
class="ml-2 cursor-pointer hover:text-secondary-700 dark:hover:text-secondary-500 transition-colors duration-150"
|
|
263
|
+
@click="(e: Event) => $emit('remove', e)"
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
</slot>
|
|
267
|
+
<teleport v-if="selected && teleportTo" :to="teleportTo">
|
|
268
|
+
<div v-if="$slots.default" role="tabpanel" :class="classes.tabpanel">
|
|
269
|
+
<slot></slot>
|
|
270
|
+
</div>
|
|
271
|
+
</teleport>
|
|
272
|
+
</component>
|
|
273
|
+
</x-tooltip>
|
|
184
274
|
</template>
|
|
@@ -3,33 +3,44 @@ import { optionalBooleanProp } from '../../common/props'
|
|
|
3
3
|
|
|
4
4
|
const validators = {
|
|
5
5
|
...useCommon.validators(),
|
|
6
|
-
variant: ['line', 'block'] as const,
|
|
6
|
+
variant: ['line', 'block', 'compact'] as const,
|
|
7
7
|
align: ['left', 'center', 'right'] as const,
|
|
8
8
|
}
|
|
9
9
|
const tabGroupProps = {
|
|
10
10
|
...useCommon.props(),
|
|
11
11
|
...useColors.props('primary'),
|
|
12
|
-
modelValue:
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: [String, Number],
|
|
14
|
+
description: 'Active tab value (v-model).',
|
|
15
|
+
},
|
|
13
16
|
variant: {
|
|
14
|
-
type: String as PropType<'line' | 'block'>,
|
|
17
|
+
type: String as PropType<'line' | 'block' | 'compact'>,
|
|
15
18
|
default: 'line',
|
|
19
|
+
description: 'Visual style of the tab list (line, block, or compact).',
|
|
16
20
|
},
|
|
17
21
|
align: {
|
|
18
22
|
type: String as PropType<'left' | 'center' | 'right'>,
|
|
19
23
|
default: 'left',
|
|
24
|
+
description: 'Horizontal alignment of tabs in the list.',
|
|
25
|
+
},
|
|
26
|
+
ghost: optionalBooleanProp('Subtle styling with less background emphasis.'),
|
|
27
|
+
grow: optionalBooleanProp('Stretches tabs to fill the list width.'),
|
|
28
|
+
exact: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
description: 'Default exact route matching for linked tabs.',
|
|
20
31
|
},
|
|
21
|
-
ghost: optionalBooleanProp(),
|
|
22
|
-
grow: optionalBooleanProp(),
|
|
23
|
-
exact: Boolean,
|
|
24
32
|
fullWidth: {
|
|
25
33
|
type: Boolean,
|
|
26
34
|
default: true,
|
|
35
|
+
description: 'Stretches the tab list to the container width.',
|
|
27
36
|
},
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export type TabGroupInjection = {
|
|
31
40
|
tabsContentRef: Ref<HTMLElement | null>;
|
|
32
|
-
activateTab: (tab: string | number) => void;
|
|
41
|
+
activateTab: (tab: string | number | null) => void;
|
|
42
|
+
registerTab: (tab: string | number) => void;
|
|
43
|
+
unregisterTab: (tab: string | number) => void;
|
|
33
44
|
state: {
|
|
34
45
|
active: string | number | undefined;
|
|
35
46
|
variant: TabGroupVariant;
|
|
@@ -50,6 +61,14 @@ export interface TabGroupTheme extends ThemeComponent<TabGroupProps, InternalCla
|
|
|
50
61
|
export default {
|
|
51
62
|
name: 'XTabGroup',
|
|
52
63
|
validators,
|
|
64
|
+
docs: {
|
|
65
|
+
slots: {
|
|
66
|
+
default: 'Tab triggers (typically x-tab children).',
|
|
67
|
+
},
|
|
68
|
+
emits: {
|
|
69
|
+
'update:modelValue': 'Emitted when the active tab changes (v-model).',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
53
72
|
}
|
|
54
73
|
</script>
|
|
55
74
|
|
|
@@ -91,38 +110,100 @@ const state = reactive({
|
|
|
91
110
|
color: computed(() => props.color),
|
|
92
111
|
})
|
|
93
112
|
|
|
113
|
+
const showTracker = ref(true)
|
|
114
|
+
const registeredTabs: (string | number)[] = []
|
|
115
|
+
|
|
94
116
|
function activateTab(tab: string | number | null) {
|
|
95
117
|
active.value = tab
|
|
96
118
|
emit('update:modelValue', tab)
|
|
97
119
|
}
|
|
98
120
|
|
|
121
|
+
function registerTab(tab: string | number) {
|
|
122
|
+
if (!registeredTabs.includes(tab)) registeredTabs.push(tab)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function unregisterTab(tab: string | number) {
|
|
126
|
+
const index = registeredTabs.indexOf(tab)
|
|
127
|
+
|
|
128
|
+
if (index === -1) return
|
|
129
|
+
|
|
130
|
+
registeredTabs.splice(index, 1)
|
|
131
|
+
|
|
132
|
+
if (active.value !== tab) return
|
|
133
|
+
|
|
134
|
+
const fallback = registeredTabs[Math.min(index, registeredTabs.length - 1)]
|
|
135
|
+
|
|
136
|
+
if (typeof fallback !== 'undefined') {
|
|
137
|
+
activateTab(fallback)
|
|
138
|
+
} else {
|
|
139
|
+
activateTab(null)
|
|
140
|
+
showTracker.value = false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
99
144
|
provide(injectTabGroupKey, {
|
|
100
145
|
tabsContentRef,
|
|
101
146
|
activateTab,
|
|
147
|
+
registerTab,
|
|
148
|
+
unregisterTab,
|
|
102
149
|
state,
|
|
103
150
|
})
|
|
104
151
|
|
|
105
152
|
const updateTracker = useThrottleFn(async (value: string | number | undefined) => {
|
|
106
|
-
if (typeof value === 'undefined')
|
|
153
|
+
if (typeof value === 'undefined' || value === null) {
|
|
154
|
+
showTracker.value = false
|
|
155
|
+
|
|
156
|
+
return
|
|
157
|
+
}
|
|
107
158
|
|
|
108
159
|
await nextTick()
|
|
109
160
|
|
|
110
161
|
const tabEl = tabsRef.value?.querySelector(`[data-value="${value}"]`) as HTMLElement
|
|
111
162
|
|
|
112
|
-
if (!tabEl || !trackerRef.value)
|
|
163
|
+
if (!tabEl || !trackerRef.value) {
|
|
164
|
+
showTracker.value = false
|
|
113
165
|
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
showTracker.value = true
|
|
114
170
|
trackerRef.value.style.left = `${tabEl.offsetLeft}px`
|
|
115
171
|
trackerRef.value.style.width = `${tabEl.offsetWidth}px`
|
|
116
172
|
|
|
117
|
-
if (!tabsRef.value || !scrollRef.value) return
|
|
173
|
+
if (!tabsRef.value || !scrollRef.value?.scrollEl) return
|
|
118
174
|
|
|
119
|
-
|
|
120
|
-
|
|
175
|
+
const scrollEl = scrollRef.value.scrollEl
|
|
176
|
+
// Measure overflow from the in-flow tabs list only (tracker is absolute and clipped).
|
|
177
|
+
const maxScroll = Math.max(0, tabsRef.value.scrollWidth - scrollEl.clientWidth)
|
|
178
|
+
const viewLeft = scrollEl.scrollLeft
|
|
179
|
+
const viewRight = viewLeft + scrollEl.clientWidth
|
|
180
|
+
const tabLeft = tabEl.offsetLeft
|
|
181
|
+
const tabRight = tabLeft + tabEl.offsetWidth
|
|
182
|
+
const tabFullyVisible = tabLeft >= viewLeft && tabRight <= viewRight
|
|
121
183
|
|
|
122
|
-
if (
|
|
123
|
-
|
|
184
|
+
if (maxScroll <= 0) {
|
|
185
|
+
if (scrollEl.scrollLeft !== 0) scrollEl.scrollTo({ left: 0 })
|
|
186
|
+
scrollEl.dispatchEvent(new CustomEvent('scroll'))
|
|
124
187
|
|
|
125
|
-
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (tabFullyVisible) {
|
|
192
|
+
scrollEl.dispatchEvent(new CustomEvent('scroll'))
|
|
193
|
+
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let nextLeft = viewLeft
|
|
198
|
+
|
|
199
|
+
if (tabLeft < viewLeft) nextLeft = tabLeft
|
|
200
|
+
else if (tabRight > viewRight) nextLeft = tabRight - scrollEl.clientWidth
|
|
201
|
+
|
|
202
|
+
nextLeft = Math.max(0, Math.min(nextLeft, maxScroll))
|
|
203
|
+
|
|
204
|
+
if (nextLeft !== viewLeft) scrollEl.scrollTo({ left: nextLeft, behavior: 'smooth' })
|
|
205
|
+
else scrollEl.dispatchEvent(new CustomEvent('scroll'))
|
|
206
|
+
}, 100, true)
|
|
126
207
|
|
|
127
208
|
function check() {
|
|
128
209
|
if (!tabsRef.value?.querySelector('.router-link-active')) {
|
|
@@ -170,18 +251,21 @@ const { styles, classes, className } = useTheme('TabGroup', {}, props)
|
|
|
170
251
|
mousewheel
|
|
171
252
|
:class="classes.scroller"
|
|
172
253
|
>
|
|
173
|
-
<div
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
254
|
+
<div class="relative overflow-x-clip">
|
|
255
|
+
<div
|
|
256
|
+
ref="tabsRef"
|
|
257
|
+
class="relative"
|
|
258
|
+
:class="classes.list"
|
|
259
|
+
>
|
|
260
|
+
<slot></slot>
|
|
261
|
+
</div>
|
|
262
|
+
<div
|
|
263
|
+
v-show="showTracker"
|
|
264
|
+
ref="trackerRef"
|
|
265
|
+
class="pointer-events-none"
|
|
266
|
+
:class="classes.tracker"
|
|
267
|
+
></div>
|
|
179
268
|
</div>
|
|
180
|
-
<div
|
|
181
|
-
v-show="showTracker"
|
|
182
|
-
ref="trackerRef"
|
|
183
|
-
:class="classes.tracker"
|
|
184
|
-
></div>
|
|
185
269
|
</x-scroll>
|
|
186
270
|
</div>
|
|
187
271
|
<div ref="tabsContentRef"></div>
|
|
@@ -8,4 +8,57 @@ describe('Tab', () => {
|
|
|
8
8
|
|
|
9
9
|
expect(wrapper.vm).toBeTruthy()
|
|
10
10
|
})
|
|
11
|
+
|
|
12
|
+
it('falls back label to value when icon is absent', () => {
|
|
13
|
+
const wrapper = mount(Tab, {
|
|
14
|
+
props: { value: 'grid' },
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
expect(wrapper.text()).toContain('grid')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('omits label when icon is set without label', () => {
|
|
21
|
+
const wrapper = mount(Tab, {
|
|
22
|
+
props: { value: 'grid', icon: 'grid' },
|
|
23
|
+
global: {
|
|
24
|
+
stubs: { XIcon: true },
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
expect(wrapper.text()).not.toContain('grid')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('renders label when icon and label are both set', () => {
|
|
32
|
+
const wrapper = mount(Tab, {
|
|
33
|
+
props: { value: 'grid', icon: 'grid', label: 'Grid' },
|
|
34
|
+
global: {
|
|
35
|
+
stubs: { XIcon: true },
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(wrapper.text()).toContain('Grid')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('passes tooltip to the tooltip wrapper', () => {
|
|
43
|
+
const wrapper = mount(Tab, {
|
|
44
|
+
props: { value: 'grid', icon: 'grid', tooltip: 'Grid view' },
|
|
45
|
+
global: {
|
|
46
|
+
stubs: {
|
|
47
|
+
XIcon: true,
|
|
48
|
+
XTooltip: {
|
|
49
|
+
props: ['position'],
|
|
50
|
+
template: `
|
|
51
|
+
<div class="tooltip-stub">
|
|
52
|
+
<slot />
|
|
53
|
+
<div class="tooltip-content"><slot name="tooltip" /></div>
|
|
54
|
+
</div>
|
|
55
|
+
`,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
expect(wrapper.find('.tooltip-content').text()).toBe('Grid view')
|
|
62
|
+
expect(wrapper.find('[aria-label="Grid view"]').exists()).toBe(true)
|
|
63
|
+
})
|
|
11
64
|
})
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { defineComponent, h, nextTick } from 'vue'
|
|
2
3
|
import { mount } from '@vue/test-utils'
|
|
3
4
|
import TabGroup from '../TabGroup.vue'
|
|
5
|
+
import Tab from '../Tab.vue'
|
|
4
6
|
|
|
5
7
|
describe('TabGroup', () => {
|
|
6
8
|
it('renders without errors', () => {
|
|
@@ -8,4 +10,115 @@ describe('TabGroup', () => {
|
|
|
8
10
|
|
|
9
11
|
expect(wrapper.vm).toBeTruthy()
|
|
10
12
|
})
|
|
13
|
+
|
|
14
|
+
it('supports compact variant with text labels', async () => {
|
|
15
|
+
const wrapper = mount(TabGroup, {
|
|
16
|
+
props: {
|
|
17
|
+
variant: 'compact',
|
|
18
|
+
modelValue: 'unique',
|
|
19
|
+
},
|
|
20
|
+
slots: {
|
|
21
|
+
default: () => [
|
|
22
|
+
h(Tab, { value: 'unique', label: 'Unique' }),
|
|
23
|
+
h(Tab, { value: 'total', label: 'Total' }),
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
global: {
|
|
27
|
+
stubs: {
|
|
28
|
+
XScroll: {
|
|
29
|
+
template: '<div><slot /></div>',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
await nextTick()
|
|
36
|
+
|
|
37
|
+
expect(wrapper.text()).toContain('Unique')
|
|
38
|
+
expect(wrapper.text()).toContain('Total')
|
|
39
|
+
expect(wrapper.find('[data-value="unique"] [aria-selected="true"]').exists()).toBe(true)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('hides label for icon-only compact tabs', async () => {
|
|
43
|
+
const Host = defineComponent({
|
|
44
|
+
components: { TabGroup, Tab },
|
|
45
|
+
data: () => ({ view: 'grid' }),
|
|
46
|
+
template: `
|
|
47
|
+
<TabGroup v-model="view" variant="compact">
|
|
48
|
+
<Tab value="grid" icon="grid" tooltip="Grid view" />
|
|
49
|
+
<Tab value="list" icon="list" tooltip="List view" />
|
|
50
|
+
</TabGroup>
|
|
51
|
+
`,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const wrapper = mount(Host, {
|
|
55
|
+
global: {
|
|
56
|
+
stubs: {
|
|
57
|
+
XScroll: {
|
|
58
|
+
template: '<div><slot /></div>',
|
|
59
|
+
},
|
|
60
|
+
XIcon: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
await nextTick()
|
|
66
|
+
|
|
67
|
+
expect(wrapper.find('[data-value="grid"] [aria-label="Grid view"]').exists()).toBe(true)
|
|
68
|
+
expect(wrapper.find('[data-value="list"] [aria-label="List view"]').exists()).toBe(true)
|
|
69
|
+
expect(wrapper.text()).not.toContain('grid')
|
|
70
|
+
expect(wrapper.text()).not.toContain('list')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('passes size down to Tab icons', async () => {
|
|
74
|
+
const wrapper = mount(TabGroup, {
|
|
75
|
+
props: {
|
|
76
|
+
modelValue: 'a',
|
|
77
|
+
size: 'lg',
|
|
78
|
+
},
|
|
79
|
+
slots: {
|
|
80
|
+
default: () => h(Tab, { value: 'a', label: 'Tab A', icon: 'smile' }),
|
|
81
|
+
},
|
|
82
|
+
global: {
|
|
83
|
+
stubs: {
|
|
84
|
+
XScroll: { template: '<div><slot /></div>' },
|
|
85
|
+
XTooltip: { template: '<div><slot /></div>' },
|
|
86
|
+
XIcon: {
|
|
87
|
+
props: ['icon', 'size'],
|
|
88
|
+
template: '<i class="icon-stub" :data-size="size" />',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
await nextTick()
|
|
95
|
+
|
|
96
|
+
expect(wrapper.find('.icon-stub').attributes('data-size')).toBe('lg')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('lets Tab size override TabGroup size', async () => {
|
|
100
|
+
const wrapper = mount(TabGroup, {
|
|
101
|
+
props: {
|
|
102
|
+
modelValue: 'a',
|
|
103
|
+
size: 'lg',
|
|
104
|
+
},
|
|
105
|
+
slots: {
|
|
106
|
+
default: () => h(Tab, { value: 'a', label: 'Tab A', icon: 'smile', size: 'sm' }),
|
|
107
|
+
},
|
|
108
|
+
global: {
|
|
109
|
+
stubs: {
|
|
110
|
+
XScroll: { template: '<div><slot /></div>' },
|
|
111
|
+
XTooltip: { template: '<div><slot /></div>' },
|
|
112
|
+
XIcon: {
|
|
113
|
+
props: ['icon', 'size'],
|
|
114
|
+
template: '<i class="icon-stub" :data-size="size" />',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
await nextTick()
|
|
121
|
+
|
|
122
|
+
expect(wrapper.find('.icon-stub').attributes('data-size')).toBe('sm')
|
|
123
|
+
})
|
|
11
124
|
})
|