@nuxt/ui 3.0.0-alpha.8 → 3.0.0-beta.1
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/.nuxt/ui/accordion.ts +2 -2
- package/.nuxt/ui/alert.ts +122 -95
- package/.nuxt/ui/avatar-group.ts +14 -2
- package/.nuxt/ui/avatar.ts +16 -4
- package/.nuxt/ui/badge.ts +139 -93
- package/.nuxt/ui/breadcrumb.ts +5 -5
- package/.nuxt/ui/button-group.ts +13 -0
- package/.nuxt/ui/button.ts +167 -136
- package/.nuxt/ui/calendar.ts +103 -0
- package/.nuxt/ui/card.ts +27 -1
- package/.nuxt/ui/carousel.ts +9 -7
- package/.nuxt/ui/checkbox.ts +45 -27
- package/.nuxt/ui/chip.ts +44 -15
- package/.nuxt/ui/color-picker.ts +47 -0
- package/.nuxt/ui/command-palette.ts +28 -18
- package/.nuxt/ui/container.ts +1 -1
- package/.nuxt/ui/context-menu.ts +64 -46
- package/.nuxt/ui/drawer.ts +83 -15
- package/.nuxt/ui/dropdown-menu.ts +65 -47
- package/.nuxt/ui/form-field.ts +15 -7
- package/.nuxt/ui/index.ts +7 -1
- package/.nuxt/ui/input-menu.ts +150 -116
- package/.nuxt/ui/input-number.ts +235 -0
- package/.nuxt/ui/input.ts +111 -76
- package/.nuxt/ui/kbd.ts +18 -6
- package/.nuxt/ui/link.ts +3 -3
- package/.nuxt/ui/modal.ts +8 -7
- package/.nuxt/ui/navigation-menu.ts +244 -131
- package/.nuxt/ui/pin-input.ts +171 -0
- package/.nuxt/ui/popover.ts +2 -2
- package/.nuxt/ui/progress.ts +111 -72
- package/.nuxt/ui/radio-group.ts +45 -22
- package/.nuxt/ui/select-menu.ts +127 -96
- package/.nuxt/ui/select.ts +120 -84
- package/.nuxt/ui/separator.ts +60 -31
- package/.nuxt/ui/skeleton.ts +1 -1
- package/.nuxt/ui/slideover.ts +17 -9
- package/.nuxt/ui/slider.ts +61 -38
- package/.nuxt/ui/stepper.ts +202 -0
- package/.nuxt/ui/switch.ts +40 -22
- package/.nuxt/ui/table.ts +49 -31
- package/.nuxt/ui/tabs.ts +101 -73
- package/.nuxt/ui/textarea.ts +111 -76
- package/.nuxt/ui/toast.ts +53 -33
- package/.nuxt/ui/toaster.ts +31 -15
- package/.nuxt/ui/tooltip.ts +2 -2
- package/.nuxt/ui/tree.ts +154 -0
- package/.nuxt/ui.css +92 -0
- package/README.md +69 -18
- package/cli/commands/{init.mjs → make/component.mjs} +16 -4
- package/cli/commands/make/index.mjs +14 -0
- package/cli/commands/make/locale.mjs +64 -0
- package/cli/index.mjs +2 -2
- package/cli/package.json +2 -2
- package/cli/templates.mjs +62 -12
- package/cli/utils.mjs +14 -0
- package/dist/module.cjs +9 -170
- package/dist/module.d.cts +5 -15
- package/dist/module.d.mts +5 -15
- package/dist/module.d.ts +5 -15
- package/dist/module.json +2 -2
- package/dist/module.mjs +12 -167
- package/dist/runtime/components/Accordion.vue +8 -39
- package/dist/runtime/components/Alert.vue +25 -21
- package/dist/runtime/components/App.vue +15 -15
- package/dist/runtime/components/Avatar.vue +33 -21
- package/dist/runtime/components/AvatarGroup.vue +5 -7
- package/dist/runtime/components/Badge.vue +10 -8
- package/dist/runtime/components/Breadcrumb.vue +13 -34
- package/dist/runtime/components/Button.vue +5 -8
- package/dist/runtime/components/ButtonGroup.vue +5 -7
- package/dist/runtime/components/Calendar.vue +194 -0
- package/dist/runtime/components/Card.vue +10 -9
- package/dist/runtime/components/Carousel.vue +26 -17
- package/dist/runtime/components/Checkbox.vue +32 -38
- package/dist/runtime/components/Chip.vue +6 -8
- package/dist/runtime/components/Collapsible.vue +10 -11
- package/dist/runtime/components/ColorPicker.vue +297 -0
- package/dist/runtime/components/CommandPalette.vue +114 -98
- package/dist/runtime/components/Container.vue +4 -7
- package/dist/runtime/components/ContextMenu.vue +16 -69
- package/dist/runtime/components/ContextMenuContent.vue +14 -10
- package/dist/runtime/components/Drawer.vue +23 -12
- package/dist/runtime/components/DropdownMenu.vue +18 -59
- package/dist/runtime/components/DropdownMenuContent.vue +14 -10
- package/dist/runtime/components/Form.vue +78 -49
- package/dist/runtime/components/FormField.vue +28 -15
- package/dist/runtime/components/Icon.vue +1 -1
- package/dist/runtime/components/Input.vue +15 -7
- package/dist/runtime/components/InputMenu.vue +133 -66
- package/dist/runtime/components/InputNumber.vue +197 -0
- package/dist/runtime/components/Kbd.vue +5 -6
- package/dist/runtime/components/Link.vue +24 -13
- package/dist/runtime/components/LinkBase.vue +1 -1
- package/dist/runtime/components/Modal.vue +56 -34
- package/dist/runtime/components/NavigationMenu.vue +129 -112
- package/dist/runtime/components/OverlayProvider.vue +28 -0
- package/dist/runtime/components/Pagination.vue +18 -14
- package/dist/runtime/components/PinInput.vue +95 -0
- package/dist/runtime/components/Popover.vue +28 -14
- package/dist/runtime/components/Progress.vue +28 -12
- package/dist/runtime/components/RadioGroup.vue +9 -12
- package/dist/runtime/components/Select.vue +61 -35
- package/dist/runtime/components/SelectMenu.vue +201 -130
- package/dist/runtime/components/Separator.vue +6 -5
- package/dist/runtime/components/Skeleton.vue +4 -7
- package/dist/runtime/components/Slideover.vue +56 -33
- package/dist/runtime/components/Slider.vue +8 -7
- package/dist/runtime/components/Stepper.vue +170 -0
- package/dist/runtime/components/Switch.vue +19 -23
- package/dist/runtime/components/Table.vue +157 -32
- package/dist/runtime/components/Tabs.vue +12 -31
- package/dist/runtime/components/Textarea.vue +18 -9
- package/dist/runtime/components/Toast.vue +39 -25
- package/dist/runtime/components/Toaster.vue +31 -24
- package/dist/runtime/components/Tooltip.vue +9 -12
- package/dist/runtime/components/Tree.vue +196 -0
- package/dist/runtime/composables/defineLocale.d.ts +9 -0
- package/dist/runtime/composables/defineLocale.js +4 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +2 -2
- package/dist/runtime/composables/useFormField.d.ts +11 -4
- package/dist/runtime/composables/useFormField.js +19 -9
- package/dist/runtime/composables/useLocale.d.ts +4 -0
- package/dist/runtime/composables/useLocale.js +10 -0
- package/dist/runtime/composables/useOverlay.d.ts +30 -0
- package/dist/runtime/composables/useOverlay.js +70 -0
- package/dist/runtime/composables/useToast.d.ts +4 -3
- package/dist/runtime/composables/useToast.js +20 -6
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/keyframes.css +1 -1
- package/dist/runtime/locale/ar.d.ts +2 -0
- package/dist/runtime/locale/ar.js +55 -0
- package/dist/runtime/locale/az.d.ts +2 -0
- package/dist/runtime/locale/az.js +54 -0
- package/dist/runtime/locale/bn.d.ts +2 -0
- package/dist/runtime/locale/bn.js +54 -0
- package/dist/runtime/locale/cs.d.ts +2 -0
- package/dist/runtime/locale/cs.js +54 -0
- package/dist/runtime/locale/da.d.ts +2 -0
- package/dist/runtime/locale/da.js +54 -0
- package/dist/runtime/locale/de.d.ts +2 -0
- package/dist/runtime/locale/de.js +54 -0
- package/dist/runtime/locale/el.d.ts +2 -0
- package/dist/runtime/locale/el.js +54 -0
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +54 -0
- package/dist/runtime/locale/es.d.ts +2 -0
- package/dist/runtime/locale/es.js +54 -0
- package/dist/runtime/locale/et.d.ts +2 -0
- package/dist/runtime/locale/et.js +54 -0
- package/dist/runtime/locale/fa_ir.d.ts +2 -0
- package/dist/runtime/locale/fa_ir.js +55 -0
- package/dist/runtime/locale/fi.d.ts +2 -0
- package/dist/runtime/locale/fi.js +54 -0
- package/dist/runtime/locale/fr.d.ts +2 -0
- package/dist/runtime/locale/fr.js +54 -0
- package/dist/runtime/locale/he.d.ts +2 -0
- package/dist/runtime/locale/he.js +53 -0
- package/dist/runtime/locale/hi.d.ts +2 -0
- package/dist/runtime/locale/hi.js +54 -0
- package/dist/runtime/locale/hu.d.ts +2 -0
- package/dist/runtime/locale/hu.js +54 -0
- package/dist/runtime/locale/id.d.ts +2 -0
- package/dist/runtime/locale/id.js +54 -0
- package/dist/runtime/locale/index.d.ts +34 -0
- package/dist/runtime/locale/index.js +34 -0
- package/dist/runtime/locale/it.d.ts +2 -0
- package/dist/runtime/locale/it.js +54 -0
- package/dist/runtime/locale/ja.d.ts +2 -0
- package/dist/runtime/locale/ja.js +54 -0
- package/dist/runtime/locale/km.d.ts +2 -0
- package/dist/runtime/locale/km.js +54 -0
- package/dist/runtime/locale/ko.d.ts +2 -0
- package/dist/runtime/locale/ko.js +54 -0
- package/dist/runtime/locale/nb_no.d.ts +2 -0
- package/dist/runtime/locale/nb_no.js +54 -0
- package/dist/runtime/locale/nl.d.ts +2 -0
- package/dist/runtime/locale/nl.js +54 -0
- package/dist/runtime/locale/pl.d.ts +2 -0
- package/dist/runtime/locale/pl.js +54 -0
- package/dist/runtime/locale/pt.d.ts +2 -0
- package/dist/runtime/locale/pt.js +54 -0
- package/dist/runtime/locale/pt_br.d.ts +2 -0
- package/dist/runtime/locale/pt_br.js +54 -0
- package/dist/runtime/locale/ru.d.ts +2 -0
- package/dist/runtime/locale/ru.js +54 -0
- package/dist/runtime/locale/sk.d.ts +2 -0
- package/dist/runtime/locale/sk.js +54 -0
- package/dist/runtime/locale/sv.d.ts +2 -0
- package/dist/runtime/locale/sv.js +54 -0
- package/dist/runtime/locale/th.d.ts +2 -0
- package/dist/runtime/locale/th.js +54 -0
- package/dist/runtime/locale/tr.d.ts +2 -0
- package/dist/runtime/locale/tr.js +54 -0
- package/dist/runtime/locale/uk.d.ts +2 -0
- package/dist/runtime/locale/uk.js +54 -0
- package/dist/runtime/locale/vi.d.ts +2 -0
- package/dist/runtime/locale/vi.js +54 -0
- package/dist/runtime/locale/zh_cn.d.ts +2 -0
- package/dist/runtime/locale/zh_cn.js +54 -0
- package/dist/runtime/locale/zh_tw.d.ts +2 -0
- package/dist/runtime/locale/zh_tw.js +54 -0
- package/dist/runtime/plugins/colors.js +8 -5
- package/dist/runtime/types/form.d.ts +29 -15
- package/dist/runtime/types/form.js +2 -2
- package/dist/runtime/types/index.d.ts +8 -0
- package/dist/runtime/types/index.js +8 -0
- package/dist/runtime/types/locale.d.ts +56 -0
- package/dist/runtime/types/locale.js +0 -0
- package/dist/runtime/types/utils.d.ts +7 -3
- package/dist/runtime/utils/form.d.ts +5 -9
- package/dist/runtime/utils/form.js +113 -50
- package/dist/runtime/utils/index.d.ts +1 -1
- package/dist/runtime/utils/index.js +15 -2
- package/dist/runtime/utils/link.d.ts +1 -1
- package/dist/runtime/utils/locale.d.ts +15 -0
- package/dist/runtime/utils/locale.js +25 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/components/Icon.vue +2 -2
- package/dist/runtime/vue/components/Link.vue +87 -23
- package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
- package/dist/runtime/vue/composables/useAppConfig.js +2 -0
- package/dist/runtime/vue/plugins/head.d.ts +1 -1
- package/dist/runtime/vue/plugins/head.js +3 -3
- package/dist/runtime/vue/stubs.d.ts +19 -0
- package/dist/runtime/vue/stubs.js +37 -0
- package/dist/shared/{ui.BufKhDiD.mjs → ui.DSPu6Y8j.mjs} +1071 -409
- package/dist/shared/{ui.BU7wzH0D.cjs → ui.DfK2RX6G.cjs} +1074 -409
- package/dist/unplugin.cjs +62 -26
- package/dist/unplugin.d.cts +17 -3
- package/dist/unplugin.d.mts +17 -3
- package/dist/unplugin.d.ts +17 -3
- package/dist/unplugin.mjs +61 -25
- package/dist/vite.cjs +3 -2
- package/dist/vite.d.cts +2 -0
- package/dist/vite.d.mts +2 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.mjs +3 -2
- package/package.json +110 -67
- package/dist/chunks/component-meta.cjs +0 -73264
- package/dist/chunks/component-meta.mjs +0 -73262
- package/dist/client/devtools/200.html +0 -1
- package/dist/client/devtools/404.html +0 -1
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKK58UfivUw4aw-SK92LTmKP0.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKy58UfivUw-9uYm8d48E4.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu0-K6z9mXg-VNw7NHvqnp.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu6-K6z9mXgjU0-EkYdMs3MAX.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-7DW3w-R7n06NbhGy.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDG3w-leGNfkTmsj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDW3w-ciElMF03ku.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JCm3w-sB722Uoa0f.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JDW3w-PBDI1JDjwV.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8gCm3w-0q1hqVn09O.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9XCm3w-ByvzuLy2fa.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9uCm3w-5TKCIs6EEw.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat_XDW3w-r2swRDGfn2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAC5thTQ-ldB60l5U8r.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpthTQ-wbFKGFDrgo.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpxhTQ-LLUBv5jskj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwARZthTQ-F71RdTRbNg.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwA_JxhTQ-6nh65gZkc0.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAfJthTQ-aMoWEJLmTt.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAkJxhTQ-WMBvmLOgKm.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAop1hTQ-utGC2hnWq2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhTQ-YpyTieVa5B.woff +0 -0
- package/dist/client/devtools/_nuxt/Bj9hdafK.js +0 -1
- package/dist/client/devtools/_nuxt/DM3_wAgz.js +0 -62
- package/dist/client/devtools/_nuxt/builds/latest.json +0 -1
- package/dist/client/devtools/_nuxt/builds/meta/e6b425f7-b919-4014-915b-0ea07c316790.json +0 -1
- package/dist/client/devtools/_nuxt/entry.DaJP-ZMB.css +0 -24
- package/dist/client/devtools/_nuxt/error-404.B0Nmv3fV.css +0 -1
- package/dist/client/devtools/_nuxt/error-500.C8fgTxVz.css +0 -1
- package/dist/client/devtools/_nuxt/hKiujHsR.js +0 -1
- package/dist/client/devtools/favicon.svg +0 -1
- package/dist/client/devtools/index.html +0 -1
- package/dist/devtools/runtime/DevtoolsRenderer.vue +0 -53
- package/dist/devtools/runtime/examples/AvatarGroupExample.vue +0 -7
- package/dist/devtools/runtime/examples/ButtonGroupExample.vue +0 -8
- package/dist/devtools/runtime/examples/CardExample.vue +0 -13
- package/dist/devtools/runtime/examples/CarouselExample.vue +0 -13
- package/dist/devtools/runtime/examples/ChipExample.vue +0 -5
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +0 -8
- package/dist/devtools/runtime/examples/CommandPaletteExample.vue +0 -29
- package/dist/devtools/runtime/examples/ContainerExample.vue +0 -5
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +0 -5
- package/dist/devtools/runtime/examples/DrawerExample.vue +0 -8
- package/dist/devtools/runtime/examples/DropdownMenuExample.vue +0 -5
- package/dist/devtools/runtime/examples/FormExample.vue +0 -30
- package/dist/devtools/runtime/examples/FormFieldExample.vue +0 -5
- package/dist/devtools/runtime/examples/LinkExample.vue +0 -5
- package/dist/devtools/runtime/examples/ModalExample.vue +0 -8
- package/dist/devtools/runtime/examples/PopoverExample.vue +0 -8
- package/dist/devtools/runtime/examples/SkeletonExample.vue +0 -3
- package/dist/devtools/runtime/examples/SlideoverExample.vue +0 -8
- package/dist/devtools/runtime/examples/ToasterExample.vue +0 -11
- package/dist/devtools/runtime/examples/TooltipExample.vue +0 -5
- package/dist/runtime/components/ModalProvider.vue +0 -12
- package/dist/runtime/components/SlideoverProvider.vue +0 -12
- package/dist/runtime/composables/extendDevtoolsMeta.d.ts +0 -7
- package/dist/runtime/composables/extendDevtoolsMeta.js +0 -2
- package/dist/runtime/composables/useModal.d.ts +0 -17
- package/dist/runtime/composables/useModal.js +0 -46
- package/dist/runtime/composables/useSlideover.d.ts +0 -17
- package/dist/runtime/composables/useSlideover.js +0 -46
- package/dist/runtime/plugins/modal.d.ts +0 -2
- package/dist/runtime/plugins/modal.js +0 -10
- package/dist/runtime/plugins/slideover.d.ts +0 -2
- package/dist/runtime/plugins/slideover.js +0 -10
|
@@ -1,46 +1,80 @@
|
|
|
1
1
|
<!-- eslint-disable vue/block-tag-newline -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import type { Ref } from 'vue'
|
|
4
|
-
import {
|
|
4
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
5
5
|
import type { AppConfig } from '@nuxt/schema'
|
|
6
|
+
import type { RowData } from '@tanstack/table-core'
|
|
6
7
|
import type {
|
|
7
|
-
|
|
8
|
+
CellContext,
|
|
8
9
|
ColumnDef,
|
|
10
|
+
ColumnFiltersOptions,
|
|
9
11
|
ColumnFiltersState,
|
|
12
|
+
ColumnOrderState,
|
|
13
|
+
ColumnPinningOptions,
|
|
10
14
|
ColumnPinningState,
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
ColumnSizingInfoState,
|
|
16
|
+
ColumnSizingOptions,
|
|
17
|
+
ColumnSizingState,
|
|
18
|
+
CoreOptions,
|
|
19
|
+
ExpandedOptions,
|
|
13
20
|
ExpandedState,
|
|
14
|
-
|
|
21
|
+
FacetedOptions,
|
|
15
22
|
GlobalFilterOptions,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
GroupingOptions,
|
|
24
|
+
GroupingState,
|
|
25
|
+
HeaderContext,
|
|
26
|
+
PaginationOptions,
|
|
27
|
+
PaginationState,
|
|
28
|
+
Row,
|
|
29
|
+
RowPinningOptions,
|
|
30
|
+
RowPinningState,
|
|
21
31
|
RowSelectionOptions,
|
|
32
|
+
RowSelectionState,
|
|
33
|
+
SortingOptions,
|
|
34
|
+
SortingState,
|
|
22
35
|
Updater,
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
VisibilityOptions,
|
|
37
|
+
VisibilityState
|
|
25
38
|
} from '@tanstack/vue-table'
|
|
26
39
|
import _appConfig from '#build/app.config'
|
|
27
40
|
import theme from '#build/ui/table'
|
|
41
|
+
import { tv } from '../utils/tv'
|
|
42
|
+
|
|
43
|
+
declare module '@tanstack/table-core' {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
46
|
+
class?: {
|
|
47
|
+
th?: string
|
|
48
|
+
td?: string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
28
52
|
|
|
29
|
-
const
|
|
53
|
+
const appConfigTable = _appConfig as AppConfig & { ui: { table: Partial<typeof theme> } }
|
|
30
54
|
|
|
31
|
-
const table = tv({ extend: tv(theme), ...(
|
|
55
|
+
const table = tv({ extend: tv(theme), ...(appConfigTable.ui?.table || {}) })
|
|
32
56
|
|
|
33
57
|
type TableVariants = VariantProps<typeof table>
|
|
34
58
|
|
|
35
|
-
export type
|
|
59
|
+
export type TableRow<T> = Row<T>
|
|
60
|
+
export type TableData = RowData
|
|
61
|
+
export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D>
|
|
36
62
|
|
|
37
|
-
export interface TableData {
|
|
38
|
-
[
|
|
63
|
+
export interface TableOptions<T extends TableData> extends Omit<CoreOptions<T>, 'data' | 'columns' | 'getCoreRowModel' | 'state' | 'onStateChange' | 'renderFallbackValue'> {
|
|
64
|
+
state?: CoreOptions<T>['state']
|
|
65
|
+
onStateChange?: CoreOptions<T>['onStateChange']
|
|
66
|
+
renderFallbackValue?: CoreOptions<T>['renderFallbackValue']
|
|
39
67
|
}
|
|
40
68
|
|
|
41
|
-
export interface TableProps<T> {
|
|
69
|
+
export interface TableProps<T extends TableData> extends TableOptions<T> {
|
|
70
|
+
/**
|
|
71
|
+
* The element or component this component should render as.
|
|
72
|
+
* @defaultValue 'div'
|
|
73
|
+
*/
|
|
74
|
+
as?: any
|
|
42
75
|
data?: T[]
|
|
43
76
|
columns?: TableColumn<T>[]
|
|
77
|
+
caption?: string
|
|
44
78
|
/**
|
|
45
79
|
* Whether the table should have a sticky header.
|
|
46
80
|
* @defaultValue false
|
|
@@ -65,6 +99,11 @@ export interface TableProps<T> {
|
|
|
65
99
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-pinning)
|
|
66
100
|
*/
|
|
67
101
|
columnPinningOptions?: Omit<ColumnPinningOptions, 'onColumnPinningChange'>
|
|
102
|
+
/**
|
|
103
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#table-options)
|
|
104
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
105
|
+
*/
|
|
106
|
+
columnSizingOptions?: Omit<ColumnSizingOptions, 'onColumnSizingChange' | 'onColumnSizingInfoChange'>
|
|
68
107
|
/**
|
|
69
108
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#table-options)
|
|
70
109
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
@@ -75,6 +114,11 @@ export interface TableProps<T> {
|
|
|
75
114
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
|
|
76
115
|
*/
|
|
77
116
|
sortingOptions?: Omit<SortingOptions<T>, 'getSortedRowModel' | 'onSortingChange'>
|
|
117
|
+
/**
|
|
118
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#table-options)
|
|
119
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
|
|
120
|
+
*/
|
|
121
|
+
groupingOptions?: Omit<GroupingOptions, 'onGroupingChange'>
|
|
78
122
|
/**
|
|
79
123
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#table-options)
|
|
80
124
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
@@ -85,6 +129,22 @@ export interface TableProps<T> {
|
|
|
85
129
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
|
|
86
130
|
*/
|
|
87
131
|
rowSelectionOptions?: Omit<RowSelectionOptions<T>, 'onRowSelectionChange'>
|
|
132
|
+
/**
|
|
133
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#table-options)
|
|
134
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
|
|
135
|
+
*/
|
|
136
|
+
rowPinningOptions?: Omit<RowPinningOptions<T>, 'onRowPinningChange'>
|
|
137
|
+
/**
|
|
138
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#table-options)
|
|
139
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
|
|
140
|
+
*/
|
|
141
|
+
paginationOptions?: Omit<PaginationOptions, 'onPaginationChange'>
|
|
142
|
+
/**
|
|
143
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#table-options)
|
|
144
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
|
|
145
|
+
*/
|
|
146
|
+
facetedOptions?: FacetedOptions<T>
|
|
147
|
+
onSelect?: (row: TableRow<T>, e?: Event) => void
|
|
88
148
|
class?: any
|
|
89
149
|
ui?: Partial<typeof table.slots>
|
|
90
150
|
}
|
|
@@ -95,25 +155,24 @@ type DynamicCellSlots<T, K = keyof T> = Record<string, (props: CellContext<T, un
|
|
|
95
155
|
export type TableSlots<T> = {
|
|
96
156
|
expanded: (props: { row: Row<T> }) => any
|
|
97
157
|
empty: (props?: {}) => any
|
|
158
|
+
caption: (props?: {}) => any
|
|
98
159
|
} & DynamicHeaderSlots<T> & DynamicCellSlots<T>
|
|
99
160
|
|
|
100
161
|
</script>
|
|
101
162
|
|
|
102
163
|
<script setup lang="ts" generic="T extends TableData">
|
|
103
164
|
import { computed } from 'vue'
|
|
104
|
-
import {
|
|
105
|
-
FlexRender,
|
|
106
|
-
getCoreRowModel,
|
|
107
|
-
getFilteredRowModel,
|
|
108
|
-
getSortedRowModel,
|
|
109
|
-
getExpandedRowModel,
|
|
110
|
-
useVueTable
|
|
111
|
-
} from '@tanstack/vue-table'
|
|
165
|
+
import { Primitive } from 'reka-ui'
|
|
112
166
|
import { upperFirst } from 'scule'
|
|
167
|
+
import { FlexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getExpandedRowModel, useVueTable } from '@tanstack/vue-table'
|
|
168
|
+
import { reactiveOmit } from '@vueuse/core'
|
|
169
|
+
import { useLocale } from '../composables/useLocale'
|
|
113
170
|
|
|
114
171
|
const props = defineProps<TableProps<T>>()
|
|
115
172
|
defineSlots<TableSlots<T>>()
|
|
116
173
|
|
|
174
|
+
const { t } = useLocale()
|
|
175
|
+
|
|
117
176
|
const data = computed(() => props.data ?? [])
|
|
118
177
|
const columns = computed<TableColumn<T>[]>(() => props.columns ?? Object.keys(data.value[0] ?? {}).map((accessorKey: string) => ({ accessorKey, header: upperFirst(accessorKey) })))
|
|
119
178
|
|
|
@@ -126,13 +185,20 @@ const ui = computed(() => table({
|
|
|
126
185
|
|
|
127
186
|
const globalFilterState = defineModel<string>('globalFilter', { default: undefined })
|
|
128
187
|
const columnFiltersState = defineModel<ColumnFiltersState>('columnFilters', { default: [] })
|
|
188
|
+
const columnOrderState = defineModel<ColumnOrderState>('columnOrder', { default: [] })
|
|
129
189
|
const columnVisibilityState = defineModel<VisibilityState>('columnVisibility', { default: {} })
|
|
130
190
|
const columnPinningState = defineModel<ColumnPinningState>('columnPinning', { default: {} })
|
|
191
|
+
const columnSizingState = defineModel<ColumnSizingState>('columnSizing', { default: {} })
|
|
192
|
+
const columnSizingInfoState = defineModel<ColumnSizingInfoState>('columnSizingInfo', { default: {} })
|
|
131
193
|
const rowSelectionState = defineModel<RowSelectionState>('rowSelection', { default: {} })
|
|
194
|
+
const rowPinningState = defineModel<RowPinningState>('rowPinning', { default: {} })
|
|
132
195
|
const sortingState = defineModel<SortingState>('sorting', { default: [] })
|
|
196
|
+
const groupingState = defineModel<GroupingState>('grouping', { default: [] })
|
|
133
197
|
const expandedState = defineModel<ExpandedState>('expanded', { default: {} })
|
|
198
|
+
const paginationState = defineModel<PaginationState>('pagination', { default: {} })
|
|
134
199
|
|
|
135
200
|
const tableApi = useVueTable({
|
|
201
|
+
...reactiveOmit(props, 'as', 'data', 'columns', 'caption', 'sticky', 'loading', 'loadingColor', 'loadingAnimation', 'class', 'ui'),
|
|
136
202
|
data,
|
|
137
203
|
columns: columns.value,
|
|
138
204
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -141,18 +207,29 @@ const tableApi = useVueTable({
|
|
|
141
207
|
...(props.columnFiltersOptions || {}),
|
|
142
208
|
getFilteredRowModel: getFilteredRowModel(),
|
|
143
209
|
onColumnFiltersChange: updaterOrValue => valueUpdater(updaterOrValue, columnFiltersState),
|
|
210
|
+
onColumnOrderChange: updaterOrValue => valueUpdater(updaterOrValue, columnOrderState),
|
|
144
211
|
...(props.visibilityOptions || {}),
|
|
145
212
|
onColumnVisibilityChange: updaterOrValue => valueUpdater(updaterOrValue, columnVisibilityState),
|
|
146
213
|
...(props.columnPinningOptions || {}),
|
|
147
214
|
onColumnPinningChange: updaterOrValue => valueUpdater(updaterOrValue, columnPinningState),
|
|
215
|
+
...(props.columnSizingOptions || {}),
|
|
216
|
+
onColumnSizingChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingState),
|
|
217
|
+
onColumnSizingInfoChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingInfoState),
|
|
148
218
|
...(props.rowSelectionOptions || {}),
|
|
149
219
|
onRowSelectionChange: updaterOrValue => valueUpdater(updaterOrValue, rowSelectionState),
|
|
220
|
+
...(props.rowPinningOptions || {}),
|
|
221
|
+
onRowPinningChange: updaterOrValue => valueUpdater(updaterOrValue, rowPinningState),
|
|
150
222
|
...(props.sortingOptions || {}),
|
|
151
223
|
getSortedRowModel: getSortedRowModel(),
|
|
152
224
|
onSortingChange: updaterOrValue => valueUpdater(updaterOrValue, sortingState),
|
|
225
|
+
...(props.groupingOptions || {}),
|
|
226
|
+
onGroupingChange: updaterOrValue => valueUpdater(updaterOrValue, groupingState),
|
|
153
227
|
...(props.expandedOptions || {}),
|
|
154
228
|
getExpandedRowModel: getExpandedRowModel(),
|
|
155
229
|
onExpandedChange: updaterOrValue => valueUpdater(updaterOrValue, expandedState),
|
|
230
|
+
...(props.paginationOptions || {}),
|
|
231
|
+
onPaginationChange: updaterOrValue => valueUpdater(updaterOrValue, paginationState),
|
|
232
|
+
...(props.facetedOptions || {}),
|
|
156
233
|
state: {
|
|
157
234
|
get globalFilter() {
|
|
158
235
|
return globalFilterState.value
|
|
@@ -160,6 +237,9 @@ const tableApi = useVueTable({
|
|
|
160
237
|
get columnFilters() {
|
|
161
238
|
return columnFiltersState.value
|
|
162
239
|
},
|
|
240
|
+
get columnOrder() {
|
|
241
|
+
return columnOrderState.value
|
|
242
|
+
},
|
|
163
243
|
get columnVisibility() {
|
|
164
244
|
return columnVisibilityState.value
|
|
165
245
|
},
|
|
@@ -174,6 +254,21 @@ const tableApi = useVueTable({
|
|
|
174
254
|
},
|
|
175
255
|
get sorting() {
|
|
176
256
|
return sortingState.value
|
|
257
|
+
},
|
|
258
|
+
get grouping() {
|
|
259
|
+
return groupingState.value
|
|
260
|
+
},
|
|
261
|
+
get rowPinning() {
|
|
262
|
+
return rowPinningState.value
|
|
263
|
+
},
|
|
264
|
+
get columnSizing() {
|
|
265
|
+
return columnSizingState.value
|
|
266
|
+
},
|
|
267
|
+
get columnSizingInfo() {
|
|
268
|
+
return columnSizingInfoState.value
|
|
269
|
+
},
|
|
270
|
+
get pagination() {
|
|
271
|
+
return paginationState.value
|
|
177
272
|
}
|
|
178
273
|
}
|
|
179
274
|
})
|
|
@@ -182,21 +277,43 @@ function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
|
|
|
182
277
|
ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue
|
|
183
278
|
}
|
|
184
279
|
|
|
280
|
+
function handleRowSelect(row: TableRow<T>, e: Event) {
|
|
281
|
+
if (!props.onSelect) {
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
const target = e.target as HTMLElement
|
|
285
|
+
const isInteractive = target.closest('button')
|
|
286
|
+
if (isInteractive) {
|
|
287
|
+
return
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
e.preventDefault()
|
|
291
|
+
e.stopPropagation()
|
|
292
|
+
|
|
293
|
+
props.onSelect(row, e)
|
|
294
|
+
}
|
|
295
|
+
|
|
185
296
|
defineExpose({
|
|
186
297
|
tableApi
|
|
187
298
|
})
|
|
188
299
|
</script>
|
|
189
300
|
|
|
190
301
|
<template>
|
|
191
|
-
<
|
|
302
|
+
<Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
192
303
|
<table :class="ui.base({ class: [props.ui?.base] })">
|
|
304
|
+
<caption v-if="caption" :class="ui.caption({ class: [props.ui?.caption] })">
|
|
305
|
+
<slot name="caption">
|
|
306
|
+
{{ caption }}
|
|
307
|
+
</slot>
|
|
308
|
+
</caption>
|
|
309
|
+
|
|
193
310
|
<thead :class="ui.thead({ class: [props.ui?.thead] })">
|
|
194
311
|
<tr v-for="headerGroup in tableApi.getHeaderGroups()" :key="headerGroup.id" :class="ui.tr({ class: [props.ui?.tr] })">
|
|
195
312
|
<th
|
|
196
313
|
v-for="header in headerGroup.headers"
|
|
197
314
|
:key="header.id"
|
|
198
315
|
:data-pinned="header.column.getIsPinned()"
|
|
199
|
-
:class="ui.th({ class: [props.ui?.th], pinned: !!header.column.getIsPinned() })"
|
|
316
|
+
:class="ui.th({ class: [props.ui?.th, header.column.columnDef.meta?.class?.th], pinned: !!header.column.getIsPinned() })"
|
|
200
317
|
>
|
|
201
318
|
<slot :name="`${header.id}-header`" v-bind="header.getContext()">
|
|
202
319
|
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.header" :props="header.getContext()" />
|
|
@@ -208,12 +325,20 @@ defineExpose({
|
|
|
208
325
|
<tbody :class="ui.tbody({ class: [props.ui?.tbody] })">
|
|
209
326
|
<template v-if="tableApi.getRowModel().rows?.length">
|
|
210
327
|
<template v-for="row in tableApi.getRowModel().rows" :key="row.id">
|
|
211
|
-
<tr
|
|
328
|
+
<tr
|
|
329
|
+
:data-selected="row.getIsSelected()"
|
|
330
|
+
:data-selectable="!!props.onSelect"
|
|
331
|
+
:data-expanded="row.getIsExpanded()"
|
|
332
|
+
:role="props.onSelect ? 'button' : undefined"
|
|
333
|
+
:tabindex="props.onSelect ? 0 : undefined"
|
|
334
|
+
:class="ui.tr({ class: [props.ui?.tr] })"
|
|
335
|
+
@click="handleRowSelect(row, $event)"
|
|
336
|
+
>
|
|
212
337
|
<td
|
|
213
338
|
v-for="cell in row.getVisibleCells()"
|
|
214
339
|
:key="cell.id"
|
|
215
340
|
:data-pinned="cell.column.getIsPinned()"
|
|
216
|
-
:class="ui.td({ class: [props.ui?.td], pinned: !!cell.column.getIsPinned() })"
|
|
341
|
+
:class="ui.td({ class: [props.ui?.td, cell.column.columnDef.meta?.class?.td], pinned: !!cell.column.getIsPinned() })"
|
|
217
342
|
>
|
|
218
343
|
<slot :name="`${cell.column.id}-cell`" v-bind="cell.getContext()">
|
|
219
344
|
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
|
@@ -231,11 +356,11 @@ defineExpose({
|
|
|
231
356
|
<tr v-else :class="ui.tr({ class: [props.ui?.tr] })">
|
|
232
357
|
<td :colspan="columns?.length" :class="ui.empty({ class: props.ui?.empty })">
|
|
233
358
|
<slot name="empty">
|
|
234
|
-
|
|
359
|
+
{{ t('table.noData') }}
|
|
235
360
|
</slot>
|
|
236
361
|
</td>
|
|
237
362
|
</tr>
|
|
238
363
|
</tbody>
|
|
239
364
|
</table>
|
|
240
|
-
</
|
|
365
|
+
</Primitive>
|
|
241
366
|
</template>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import type { TabsRootProps, TabsRootEmits
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { TabsRootProps, TabsRootEmits } from 'reka-ui'
|
|
4
4
|
import type { AppConfig } from '@nuxt/schema'
|
|
5
5
|
import _appConfig from '#build/app.config'
|
|
6
6
|
import theme from '#build/ui/tabs'
|
|
7
|
-
import {
|
|
7
|
+
import { tv } from '../utils/tv'
|
|
8
8
|
import type { AvatarProps } from '../types'
|
|
9
9
|
import type { DynamicSlots, PartialString } from '../types/utils'
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const appConfigTabs = _appConfig as AppConfig & { ui: { tabs: Partial<typeof theme> } }
|
|
12
12
|
|
|
13
|
-
const tabs = tv({ extend: tv(theme), ...(
|
|
13
|
+
const tabs = tv({ extend: tv(theme), ...(appConfigTabs.ui?.tabs || {}) })
|
|
14
14
|
|
|
15
15
|
export interface TabsItem {
|
|
16
16
|
label?: string
|
|
@@ -25,7 +25,7 @@ export interface TabsItem {
|
|
|
25
25
|
|
|
26
26
|
type TabsVariants = VariantProps<typeof tabs>
|
|
27
27
|
|
|
28
|
-
export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode'> {
|
|
28
|
+
export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
29
29
|
/**
|
|
30
30
|
* The element or component this component should render as.
|
|
31
31
|
* @defaultValue 'div'
|
|
@@ -44,7 +44,7 @@ export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defa
|
|
|
44
44
|
* The content of the tabs, can be disabled to prevent rendering the content.
|
|
45
45
|
* @defaultValue true
|
|
46
46
|
*/
|
|
47
|
-
content?: boolean
|
|
47
|
+
content?: boolean
|
|
48
48
|
/**
|
|
49
49
|
* The key used to get the label from the item.
|
|
50
50
|
* @defaultValue 'label'
|
|
@@ -64,30 +64,11 @@ export type TabsSlots<T extends { slot?: string }> = {
|
|
|
64
64
|
trailing: SlotProps<T>
|
|
65
65
|
content: SlotProps<T>
|
|
66
66
|
} & DynamicSlots<T, SlotProps<T>>
|
|
67
|
-
|
|
68
|
-
extendDevtoolsMeta({
|
|
69
|
-
defaultProps: {
|
|
70
|
-
items: [{
|
|
71
|
-
label: 'Tab1',
|
|
72
|
-
avatar: { src: 'https://avatars.githubusercontent.com/u/739984?v=4' },
|
|
73
|
-
content: 'This is the content shown for Tab1'
|
|
74
|
-
}, {
|
|
75
|
-
label: 'Tab2',
|
|
76
|
-
icon: 'i-lucide-user',
|
|
77
|
-
content: 'And, this is the content for Tab2'
|
|
78
|
-
}, {
|
|
79
|
-
label: 'Tab3',
|
|
80
|
-
icon: 'i-lucide-bell',
|
|
81
|
-
content: 'Finally, this is the content for Tab3'
|
|
82
|
-
}]
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
67
|
</script>
|
|
86
68
|
|
|
87
69
|
<script setup lang="ts" generic="T extends TabsItem">
|
|
88
|
-
import { computed
|
|
89
|
-
import {
|
|
90
|
-
import { TabsRoot, TabsList, TabsIndicator, TabsTrigger, TabsContent, useForwardPropsEmits } from 'radix-vue'
|
|
70
|
+
import { computed } from 'vue'
|
|
71
|
+
import { TabsRoot, TabsList, TabsIndicator, TabsTrigger, TabsContent, useForwardPropsEmits } from 'reka-ui'
|
|
91
72
|
import { reactivePick } from '@vueuse/core'
|
|
92
73
|
import { get } from '../utils'
|
|
93
74
|
import UIcon from './Icon.vue'
|
|
@@ -97,13 +78,13 @@ const props = withDefaults(defineProps<TabsProps<T>>(), {
|
|
|
97
78
|
content: true,
|
|
98
79
|
defaultValue: '0',
|
|
99
80
|
orientation: 'horizontal',
|
|
81
|
+
unmountOnHide: true,
|
|
100
82
|
labelKey: 'label'
|
|
101
83
|
})
|
|
102
84
|
const emits = defineEmits<TabsEmits>()
|
|
103
85
|
const slots = defineSlots<TabsSlots<T>>()
|
|
104
86
|
|
|
105
|
-
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultValue', 'orientation', 'activationMode', '
|
|
106
|
-
const contentProps = toRef(() => defu(props.content || {}, { forceMount: true }) as TabsContentProps)
|
|
87
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emits)
|
|
107
88
|
|
|
108
89
|
const ui = computed(() => tabs({
|
|
109
90
|
color: props.color,
|
|
@@ -133,7 +114,7 @@ const ui = computed(() => tabs({
|
|
|
133
114
|
</TabsList>
|
|
134
115
|
|
|
135
116
|
<template v-if="!!content">
|
|
136
|
-
<TabsContent v-for="(item, index) of items" :key="index"
|
|
117
|
+
<TabsContent v-for="(item, index) of items" :key="index" :value="item.value || String(index)" :class="ui.content({ class: props.ui?.content })">
|
|
137
118
|
<slot :name="item.slot || 'content'" :item="item" :index="index">
|
|
138
119
|
{{ item.content }}
|
|
139
120
|
</slot>
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
3
|
import type { AppConfig } from '@nuxt/schema'
|
|
4
4
|
import _appConfig from '#build/app.config'
|
|
5
5
|
import theme from '#build/ui/textarea'
|
|
6
|
+
import { tv } from '../utils/tv'
|
|
7
|
+
import type { PartialString } from '../types/utils'
|
|
6
8
|
|
|
7
|
-
const
|
|
9
|
+
const appConfigTextarea = _appConfig as AppConfig & { ui: { textarea: Partial<typeof theme> } }
|
|
8
10
|
|
|
9
|
-
const textarea = tv({ extend: tv(theme), ...(
|
|
11
|
+
const textarea = tv({ extend: tv(theme), ...(appConfigTextarea.ui?.textarea || {}) })
|
|
10
12
|
|
|
11
13
|
type TextareaVariants = VariantProps<typeof textarea>
|
|
12
14
|
|
|
13
15
|
export interface TextareaProps {
|
|
16
|
+
/**
|
|
17
|
+
* The element or component this component should render as.
|
|
18
|
+
* @defaultValue 'div'
|
|
19
|
+
*/
|
|
20
|
+
as?: any
|
|
14
21
|
id?: string
|
|
15
22
|
name?: string
|
|
16
23
|
/** The placeholder text when the textarea is empty. */
|
|
@@ -28,7 +35,7 @@ export interface TextareaProps {
|
|
|
28
35
|
autoresize?: boolean
|
|
29
36
|
/** Highlight the ring color like a focus state. */
|
|
30
37
|
highlight?: boolean
|
|
31
|
-
ui?:
|
|
38
|
+
ui?: PartialString<typeof textarea.slots>
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
export interface TextareaEmits {
|
|
@@ -44,6 +51,7 @@ export interface TextareaSlots {
|
|
|
44
51
|
|
|
45
52
|
<script setup lang="ts">
|
|
46
53
|
import { ref, computed, onMounted, nextTick, watch } from 'vue'
|
|
54
|
+
import { Primitive } from 'reka-ui'
|
|
47
55
|
import { useFormField } from '../composables/useFormField'
|
|
48
56
|
import { looseToNumber } from '../utils'
|
|
49
57
|
|
|
@@ -59,7 +67,7 @@ const emits = defineEmits<TextareaEmits>()
|
|
|
59
67
|
|
|
60
68
|
const [modelValue, modelModifiers] = defineModel<string | number>()
|
|
61
69
|
|
|
62
|
-
const { emitFormBlur, emitFormInput, emitFormChange, size, color, id, name, highlight, disabled } = useFormField<TextareaProps>(props)
|
|
70
|
+
const { emitFormFocus, emitFormBlur, emitFormInput, emitFormChange, size, color, id, name, highlight, disabled, ariaAttrs } = useFormField<TextareaProps>(props, { deferInputValidation: true })
|
|
63
71
|
|
|
64
72
|
const ui = computed(() => textarea({
|
|
65
73
|
color: color.value,
|
|
@@ -151,7 +159,7 @@ function autoResize() {
|
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
watch(
|
|
162
|
+
watch(modelValue, () => {
|
|
155
163
|
nextTick(autoResize)
|
|
156
164
|
})
|
|
157
165
|
|
|
@@ -167,7 +175,7 @@ onMounted(() => {
|
|
|
167
175
|
</script>
|
|
168
176
|
|
|
169
177
|
<template>
|
|
170
|
-
<
|
|
178
|
+
<Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
171
179
|
<textarea
|
|
172
180
|
:id="id"
|
|
173
181
|
ref="textareaRef"
|
|
@@ -178,12 +186,13 @@ onMounted(() => {
|
|
|
178
186
|
:class="ui.base({ class: props.ui?.base })"
|
|
179
187
|
:disabled="disabled"
|
|
180
188
|
:required="required"
|
|
181
|
-
v-bind="
|
|
189
|
+
v-bind="{ ...$attrs, ...ariaAttrs }"
|
|
182
190
|
@input="onInput"
|
|
183
191
|
@blur="onBlur"
|
|
184
192
|
@change="onChange"
|
|
193
|
+
@focus="emitFormFocus"
|
|
185
194
|
/>
|
|
186
195
|
|
|
187
196
|
<slot />
|
|
188
|
-
</
|
|
197
|
+
</Primitive>
|
|
189
198
|
</template>
|