@nuxt/ui 3.0.1 → 3.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/.nuxt/ui/accordion.ts +25 -4
- package/.nuxt/ui/alert.ts +52 -31
- package/.nuxt/ui/avatar-group.ts +24 -3
- package/.nuxt/ui/avatar.ts +26 -5
- package/.nuxt/ui/badge.ts +56 -35
- package/.nuxt/ui/breadcrumb.ts +28 -7
- package/.nuxt/ui/button-group.ts +23 -2
- package/.nuxt/ui/button.ts +66 -45
- package/.nuxt/ui/calendar.ts +39 -18
- package/.nuxt/ui/card.ts +28 -7
- package/.nuxt/ui/carousel.ts +29 -8
- package/.nuxt/ui/checkbox-group.ts +82 -0
- package/.nuxt/ui/checkbox.ts +163 -29
- package/.nuxt/ui/chip.ts +31 -10
- package/.nuxt/ui/collapsible.ts +23 -2
- package/.nuxt/ui/color-picker.ts +26 -5
- package/.nuxt/ui/command-palette.ts +37 -16
- package/.nuxt/ui/container.ts +24 -3
- package/.nuxt/ui/context-menu.ts +56 -35
- package/.nuxt/ui/drawer.ts +33 -12
- package/.nuxt/ui/dropdown-menu.ts +57 -36
- package/.nuxt/ui/form-field.ts +29 -8
- package/.nuxt/ui/form.ts +23 -2
- package/.nuxt/ui/index.ts +1 -0
- package/.nuxt/ui/input-menu.ts +65 -44
- package/.nuxt/ui/input-number.ts +43 -22
- package/.nuxt/ui/input.ts +46 -25
- package/.nuxt/ui/kbd.ts +27 -6
- package/.nuxt/ui/link.ts +26 -5
- package/.nuxt/ui/modal.ts +28 -7
- package/.nuxt/ui/navigation-menu.ts +103 -84
- package/.nuxt/ui/pagination.ts +23 -2
- package/.nuxt/ui/pin-input.ts +43 -22
- package/.nuxt/ui/popover.ts +25 -4
- package/.nuxt/ui/progress.ts +40 -19
- package/.nuxt/ui/radio-group.ts +273 -37
- package/.nuxt/ui/select-menu.ts +59 -35
- package/.nuxt/ui/select.ts +55 -34
- package/.nuxt/ui/separator.ts +31 -10
- package/.nuxt/ui/skeleton.ts +24 -3
- package/.nuxt/ui/slideover.ts +27 -6
- package/.nuxt/ui/slider.ts +39 -18
- package/.nuxt/ui/stepper.ts +41 -20
- package/.nuxt/ui/switch.ts +44 -23
- package/.nuxt/ui/table.ts +38 -17
- package/.nuxt/ui/tabs.ts +55 -34
- package/.nuxt/ui/textarea.ts +63 -37
- package/.nuxt/ui/toast.ts +47 -26
- package/.nuxt/ui/toaster.ts +23 -2
- package/.nuxt/ui/tooltip.ts +25 -4
- package/.nuxt/ui/tree.ts +41 -20
- package/.nuxt/ui.css +56 -12
- package/README.md +11 -0
- package/cli/templates.mjs +18 -17
- package/dist/module.d.mts +2 -1
- package/dist/module.json +5 -5
- package/dist/module.mjs +11 -7
- package/dist/runtime/components/Accordion.vue +36 -92
- package/dist/runtime/components/Accordion.vue.d.ts +91 -0
- package/dist/runtime/components/Alert.vue +37 -100
- package/dist/runtime/components/Alert.vue.d.ts +96 -0
- package/dist/runtime/components/App.vue +28 -34
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +47 -78
- package/dist/runtime/components/Avatar.vue.d.ts +60 -0
- package/dist/runtime/components/AvatarGroup.vue +40 -77
- package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
- package/dist/runtime/components/Badge.vue +33 -62
- package/dist/runtime/components/Badge.vue.d.ts +62 -0
- package/dist/runtime/components/Breadcrumb.vue +36 -88
- package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
- package/dist/runtime/components/Button.vue +96 -105
- package/dist/runtime/components/Button.vue.d.ts +73 -0
- package/dist/runtime/components/ButtonGroup.vue +20 -46
- package/dist/runtime/components/ButtonGroup.vue.d.ts +55 -0
- package/dist/runtime/components/Calendar.vue +73 -127
- package/dist/runtime/components/Calendar.vue.d.ts +107 -0
- package/dist/runtime/components/Card.vue +18 -40
- package/dist/runtime/components/Card.vue.d.ts +38 -0
- package/dist/runtime/components/Carousel.vue +112 -230
- package/dist/runtime/components/Carousel.vue.d.ts +120 -0
- package/dist/runtime/components/Checkbox.vue +52 -93
- package/dist/runtime/components/Checkbox.vue.d.ts +76 -0
- package/dist/runtime/components/CheckboxGroup.vue +121 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +75 -0
- package/dist/runtime/components/Chip.vue +26 -69
- package/dist/runtime/components/Chip.vue.d.ts +71 -0
- package/dist/runtime/components/Collapsible.vue +22 -41
- package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
- package/dist/runtime/components/ColorPicker.vue +111 -197
- package/dist/runtime/components/ColorPicker.vue.d.ts +63 -0
- package/dist/runtime/components/CommandPalette.vue +94 -234
- package/dist/runtime/components/CommandPalette.vue.d.ts +173 -0
- package/dist/runtime/components/Container.vue +15 -28
- package/dist/runtime/components/Container.vue.d.ts +27 -0
- package/dist/runtime/components/ContextMenu.vue +32 -119
- package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
- package/dist/runtime/components/ContextMenuContent.vue +71 -72
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
- package/dist/runtime/components/Drawer.vue +49 -87
- package/dist/runtime/components/Drawer.vue.d.ts +88 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -129
- package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
- package/dist/runtime/components/DropdownMenuContent.vue +76 -79
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
- package/dist/runtime/components/Form.vue +135 -219
- package/dist/runtime/components/Form.vue.d.ts +66 -0
- package/dist/runtime/components/FormField.vue +36 -77
- package/dist/runtime/components/FormField.vue.d.ts +70 -0
- package/dist/runtime/components/Icon.vue +12 -19
- package/dist/runtime/components/Icon.vue.d.ts +17 -0
- package/dist/runtime/components/Input.vue +82 -140
- package/dist/runtime/components/Input.vue.d.ts +91 -0
- package/dist/runtime/components/InputMenu.vue +193 -302
- package/dist/runtime/components/InputMenu.vue.d.ts +312 -0
- package/dist/runtime/components/InputNumber.vue +71 -133
- package/dist/runtime/components/InputNumber.vue.d.ts +193 -0
- package/dist/runtime/components/Kbd.vue +20 -46
- package/dist/runtime/components/Kbd.vue.d.ts +55 -0
- package/dist/runtime/components/Link.vue +98 -173
- package/dist/runtime/components/Link.vue.d.ts +124 -0
- package/dist/runtime/components/LinkBase.vue +33 -41
- package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
- package/dist/runtime/components/Modal.vue +53 -116
- package/dist/runtime/components/Modal.vue.d.ts +109 -0
- package/dist/runtime/components/NavigationMenu.vue +78 -186
- package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
- package/dist/runtime/components/OverlayProvider.vue +14 -18
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +46 -140
- package/dist/runtime/components/Pagination.vue.d.ts +143 -0
- package/dist/runtime/components/PinInput.vue +61 -78
- package/dist/runtime/components/PinInput.vue.d.ts +68 -0
- package/dist/runtime/components/Popover.vue +47 -84
- package/dist/runtime/components/Popover.vue.d.ts +80 -0
- package/dist/runtime/components/Progress.vue +70 -131
- package/dist/runtime/components/Progress.vue.d.ts +97 -0
- package/dist/runtime/components/RadioGroup.vue +75 -126
- package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
- package/dist/runtime/components/Select.vue +115 -202
- package/dist/runtime/components/Select.vue.d.ts +139 -0
- package/dist/runtime/components/SelectMenu.vue +167 -281
- package/dist/runtime/components/SelectMenu.vue.d.ts +184 -0
- package/dist/runtime/components/Separator.vue +29 -71
- package/dist/runtime/components/Separator.vue.d.ts +75 -0
- package/dist/runtime/components/Skeleton.vue +21 -23
- package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
- package/dist/runtime/components/Slideover.vue +53 -120
- package/dist/runtime/components/Slideover.vue.d.ts +111 -0
- package/dist/runtime/components/Slider.vue +46 -84
- package/dist/runtime/components/Slider.vue.d.ts +71 -0
- package/dist/runtime/components/Stepper.vue +44 -113
- package/dist/runtime/components/Stepper.vue.d.ts +89 -0
- package/dist/runtime/components/Switch.vue +45 -93
- package/dist/runtime/components/Switch.vue.d.ts +73 -0
- package/dist/runtime/components/Table.vue +165 -264
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +40 -105
- package/dist/runtime/components/Tabs.vue.d.ts +104 -0
- package/dist/runtime/components/Textarea.vue +113 -158
- package/dist/runtime/components/Textarea.vue.d.ts +95 -0
- package/dist/runtime/components/Toast.vue +49 -110
- package/dist/runtime/components/Toast.vue.d.ts +95 -0
- package/dist/runtime/components/Toaster.vue +70 -107
- package/dist/runtime/components/Toaster.vue.d.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +38 -65
- package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
- package/dist/runtime/components/Tree.vue +57 -150
- package/dist/runtime/components/Tree.vue.d.ts +128 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +0 -1
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormField.d.ts +2 -2
- package/dist/runtime/composables/useFormField.js +1 -1
- package/dist/runtime/composables/useOverlay.d.ts +16 -8
- package/dist/runtime/composables/useOverlay.js +14 -6
- package/dist/runtime/composables/usePortal.d.ts +6 -0
- package/dist/runtime/composables/usePortal.js +17 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/inertia/components/Link.vue +146 -0
- package/dist/runtime/inertia/components/Link.vue.d.ts +92 -0
- package/dist/runtime/inertia/stubs.d.ts +43 -0
- package/dist/runtime/inertia/stubs.js +82 -0
- package/dist/runtime/locale/bg.d.ts +3 -0
- package/dist/runtime/locale/bg.js +54 -0
- package/dist/runtime/locale/hy.d.ts +3 -0
- package/dist/runtime/locale/hy.js +54 -0
- package/dist/runtime/locale/index.d.ts +6 -1
- package/dist/runtime/locale/index.js +6 -1
- package/dist/runtime/locale/kk.d.ts +3 -0
- package/dist/runtime/locale/kk.js +54 -0
- package/dist/runtime/locale/tj.d.ts +3 -0
- package/dist/runtime/locale/tj.js +54 -0
- package/dist/runtime/locale/ug_cn.d.ts +3 -0
- package/dist/runtime/locale/ug_cn.js +55 -0
- package/dist/runtime/types/form.d.ts +5 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/utils.d.ts +70 -10
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/link.d.ts +4 -27
- package/dist/runtime/utils/link.js +32 -1
- package/dist/runtime/utils/tv.js +2 -2
- package/dist/runtime/vue/components/Icon.vue +7 -8
- package/dist/runtime/vue/components/Icon.vue.d.ts +14 -0
- package/dist/runtime/vue/components/Link.vue +118 -199
- package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
- package/dist/runtime/vue/stubs.d.ts +5 -0
- package/dist/runtime/vue/stubs.js +11 -2
- package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
- package/dist/types.d.mts +5 -1
- package/dist/unplugin.d.mts +6 -1
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.mjs +1 -1
- package/package.json +122 -64
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -44
- package/dist/module.d.ts +0 -44
- package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
- package/dist/types.d.ts +0 -1
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -61
- package/dist/unplugin.d.ts +0 -61
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -1,314 +1,197 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Ref } from 'vue'
|
|
4
|
-
import type { VariantProps } from 'tailwind-variants'
|
|
5
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
6
|
-
import type { RowData } from '@tanstack/table-core'
|
|
7
|
-
import type {
|
|
8
|
-
CellContext,
|
|
9
|
-
ColumnDef,
|
|
10
|
-
ColumnFiltersOptions,
|
|
11
|
-
ColumnFiltersState,
|
|
12
|
-
ColumnOrderState,
|
|
13
|
-
ColumnPinningOptions,
|
|
14
|
-
ColumnPinningState,
|
|
15
|
-
ColumnSizingInfoState,
|
|
16
|
-
ColumnSizingOptions,
|
|
17
|
-
ColumnSizingState,
|
|
18
|
-
CoreOptions,
|
|
19
|
-
ExpandedOptions,
|
|
20
|
-
ExpandedState,
|
|
21
|
-
FacetedOptions,
|
|
22
|
-
GlobalFilterOptions,
|
|
23
|
-
GroupingOptions,
|
|
24
|
-
GroupingState,
|
|
25
|
-
HeaderContext,
|
|
26
|
-
PaginationOptions,
|
|
27
|
-
PaginationState,
|
|
28
|
-
Row,
|
|
29
|
-
RowPinningOptions,
|
|
30
|
-
RowPinningState,
|
|
31
|
-
RowSelectionOptions,
|
|
32
|
-
RowSelectionState,
|
|
33
|
-
SortingOptions,
|
|
34
|
-
SortingState,
|
|
35
|
-
Updater,
|
|
36
|
-
VisibilityOptions,
|
|
37
|
-
VisibilityState
|
|
38
|
-
} from '@tanstack/vue-table'
|
|
39
|
-
import _appConfig from '#build/app.config'
|
|
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
|
-
}
|
|
52
|
-
|
|
53
|
-
const appConfigTable = _appConfig as AppConfig & { ui: { table: Partial<typeof theme> } }
|
|
54
|
-
|
|
55
|
-
const table = tv({ extend: tv(theme), ...(appConfigTable.ui?.table || {}) })
|
|
56
|
-
|
|
57
|
-
type TableVariants = VariantProps<typeof table>
|
|
58
|
-
|
|
59
|
-
export type TableRow<T> = Row<T>
|
|
60
|
-
export type TableData = RowData
|
|
61
|
-
export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D>
|
|
62
|
-
|
|
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']
|
|
67
|
-
}
|
|
68
|
-
|
|
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
|
|
75
|
-
data?: T[]
|
|
76
|
-
columns?: TableColumn<T>[]
|
|
77
|
-
caption?: string
|
|
78
|
-
/**
|
|
79
|
-
* Whether the table should have a sticky header.
|
|
80
|
-
* @defaultValue false
|
|
81
|
-
*/
|
|
82
|
-
sticky?: boolean
|
|
83
|
-
/** Whether the table should be in loading state. */
|
|
84
|
-
loading?: boolean
|
|
85
|
-
/**
|
|
86
|
-
* @defaultValue 'primary'
|
|
87
|
-
*/
|
|
88
|
-
loadingColor?: TableVariants['loadingColor']
|
|
89
|
-
/**
|
|
90
|
-
* @defaultValue 'carousel'
|
|
91
|
-
*/
|
|
92
|
-
loadingAnimation?: TableVariants['loadingAnimation']
|
|
93
|
-
/**
|
|
94
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#table-options)
|
|
95
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
96
|
-
*/
|
|
97
|
-
globalFilterOptions?: Omit<GlobalFilterOptions<T>, 'onGlobalFilterChange'>
|
|
98
|
-
/**
|
|
99
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#table-options)
|
|
100
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
101
|
-
*/
|
|
102
|
-
columnFiltersOptions?: Omit<ColumnFiltersOptions<T>, 'getFilteredRowModel' | 'onColumnFiltersChange'>
|
|
103
|
-
/**
|
|
104
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-pinning#table-options)
|
|
105
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-pinning)
|
|
106
|
-
*/
|
|
107
|
-
columnPinningOptions?: Omit<ColumnPinningOptions, 'onColumnPinningChange'>
|
|
108
|
-
/**
|
|
109
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#table-options)
|
|
110
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
111
|
-
*/
|
|
112
|
-
columnSizingOptions?: Omit<ColumnSizingOptions, 'onColumnSizingChange' | 'onColumnSizingInfoChange'>
|
|
113
|
-
/**
|
|
114
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#table-options)
|
|
115
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
116
|
-
*/
|
|
117
|
-
visibilityOptions?: Omit<VisibilityOptions, 'onColumnVisibilityChange'>
|
|
118
|
-
/**
|
|
119
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#table-options)
|
|
120
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
|
|
121
|
-
*/
|
|
122
|
-
sortingOptions?: Omit<SortingOptions<T>, 'getSortedRowModel' | 'onSortingChange'>
|
|
123
|
-
/**
|
|
124
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#table-options)
|
|
125
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
|
|
126
|
-
*/
|
|
127
|
-
groupingOptions?: Omit<GroupingOptions, 'onGroupingChange'>
|
|
128
|
-
/**
|
|
129
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#table-options)
|
|
130
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
131
|
-
*/
|
|
132
|
-
expandedOptions?: Omit<ExpandedOptions<T>, 'getExpandedRowModel' | 'onExpandedChange'>
|
|
133
|
-
/**
|
|
134
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#table-options)
|
|
135
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
|
|
136
|
-
*/
|
|
137
|
-
rowSelectionOptions?: Omit<RowSelectionOptions<T>, 'onRowSelectionChange'>
|
|
138
|
-
/**
|
|
139
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#table-options)
|
|
140
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
|
|
141
|
-
*/
|
|
142
|
-
rowPinningOptions?: Omit<RowPinningOptions<T>, 'onRowPinningChange'>
|
|
143
|
-
/**
|
|
144
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#table-options)
|
|
145
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
|
|
146
|
-
*/
|
|
147
|
-
paginationOptions?: Omit<PaginationOptions, 'onPaginationChange'>
|
|
148
|
-
/**
|
|
149
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#table-options)
|
|
150
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
|
|
151
|
-
*/
|
|
152
|
-
facetedOptions?: FacetedOptions<T>
|
|
153
|
-
onSelect?: (row: TableRow<T>, e?: Event) => void
|
|
154
|
-
class?: any
|
|
155
|
-
ui?: Partial<typeof table.slots>
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
type DynamicHeaderSlots<T, K = keyof T> = Record<string, (props: HeaderContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-header`, (props: HeaderContext<T, unknown>) => any>
|
|
159
|
-
type DynamicCellSlots<T, K = keyof T> = Record<string, (props: CellContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-cell`, (props: CellContext<T, unknown>) => any>
|
|
160
|
-
|
|
161
|
-
export type TableSlots<T> = {
|
|
162
|
-
expanded: (props: { row: Row<T> }) => any
|
|
163
|
-
empty: (props?: {}) => any
|
|
164
|
-
loading: (props?: {}) => any
|
|
165
|
-
caption: (props?: {}) => any
|
|
166
|
-
} & DynamicHeaderSlots<T> & DynamicCellSlots<T>
|
|
167
|
-
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/table";
|
|
168
3
|
</script>
|
|
169
4
|
|
|
170
|
-
<script setup
|
|
171
|
-
import { computed } from
|
|
172
|
-
import { Primitive } from
|
|
173
|
-
import { upperFirst } from
|
|
174
|
-
import { FlexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getExpandedRowModel, useVueTable } from
|
|
175
|
-
import { reactiveOmit } from
|
|
176
|
-
import {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed, ref, watch } from "vue";
|
|
7
|
+
import { Primitive } from "reka-ui";
|
|
8
|
+
import { upperFirst } from "scule";
|
|
9
|
+
import { FlexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getExpandedRowModel, useVueTable } from "@tanstack/vue-table";
|
|
10
|
+
import { reactiveOmit } from "@vueuse/core";
|
|
11
|
+
import { useAppConfig } from "#imports";
|
|
12
|
+
import { useLocale } from "../composables/useLocale";
|
|
13
|
+
import { tv } from "../utils/tv";
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
as: { type: null, required: false },
|
|
16
|
+
data: { type: Array, required: false },
|
|
17
|
+
columns: { type: Array, required: false },
|
|
18
|
+
caption: { type: String, required: false },
|
|
19
|
+
meta: { type: Object, required: false },
|
|
20
|
+
empty: { type: String, required: false },
|
|
21
|
+
sticky: { type: Boolean, required: false },
|
|
22
|
+
loading: { type: Boolean, required: false },
|
|
23
|
+
loadingColor: { type: null, required: false },
|
|
24
|
+
loadingAnimation: { type: null, required: false },
|
|
25
|
+
watchOptions: { type: Object, required: false, default: () => ({
|
|
26
|
+
deep: true
|
|
27
|
+
}) },
|
|
28
|
+
globalFilterOptions: { type: Object, required: false },
|
|
29
|
+
columnFiltersOptions: { type: Object, required: false },
|
|
30
|
+
columnPinningOptions: { type: Object, required: false },
|
|
31
|
+
columnSizingOptions: { type: Object, required: false },
|
|
32
|
+
visibilityOptions: { type: Object, required: false },
|
|
33
|
+
sortingOptions: { type: Object, required: false },
|
|
34
|
+
groupingOptions: { type: Object, required: false },
|
|
35
|
+
expandedOptions: { type: Object, required: false },
|
|
36
|
+
rowSelectionOptions: { type: Object, required: false },
|
|
37
|
+
rowPinningOptions: { type: Object, required: false },
|
|
38
|
+
paginationOptions: { type: Object, required: false },
|
|
39
|
+
facetedOptions: { type: Object, required: false },
|
|
40
|
+
onSelect: { type: Function, required: false },
|
|
41
|
+
class: { type: null, required: false },
|
|
42
|
+
ui: { type: null, required: false },
|
|
43
|
+
state: { type: Object, required: false },
|
|
44
|
+
onStateChange: { type: Function, required: false },
|
|
45
|
+
renderFallbackValue: { type: null, required: false },
|
|
46
|
+
_features: { type: Array, required: false },
|
|
47
|
+
autoResetAll: { type: Boolean, required: false },
|
|
48
|
+
debugAll: { type: Boolean, required: false },
|
|
49
|
+
debugCells: { type: Boolean, required: false },
|
|
50
|
+
debugColumns: { type: Boolean, required: false },
|
|
51
|
+
debugHeaders: { type: Boolean, required: false },
|
|
52
|
+
debugRows: { type: Boolean, required: false },
|
|
53
|
+
debugTable: { type: Boolean, required: false },
|
|
54
|
+
defaultColumn: { type: Object, required: false },
|
|
55
|
+
getRowId: { type: Function, required: false },
|
|
56
|
+
getSubRows: { type: Function, required: false },
|
|
57
|
+
initialState: { type: Object, required: false },
|
|
58
|
+
mergeOptions: { type: Function, required: false }
|
|
59
|
+
});
|
|
60
|
+
const slots = defineSlots();
|
|
61
|
+
const { t } = useLocale();
|
|
62
|
+
const appConfig = useAppConfig();
|
|
63
|
+
const data = ref(props.data ?? []);
|
|
64
|
+
const columns = computed(() => props.columns ?? Object.keys(data.value[0] ?? {}).map((accessorKey) => ({ accessorKey, header: upperFirst(accessorKey) })));
|
|
65
|
+
const meta = computed(() => props.meta ?? {});
|
|
66
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.table || {} })({
|
|
187
67
|
sticky: props.sticky,
|
|
188
68
|
loading: props.loading,
|
|
189
69
|
loadingColor: props.loadingColor,
|
|
190
70
|
loadingAnimation: props.loadingAnimation
|
|
191
|
-
}))
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
71
|
+
}));
|
|
72
|
+
const globalFilterState = defineModel("globalFilter", { type: String, ...{ default: void 0 } });
|
|
73
|
+
const columnFiltersState = defineModel("columnFilters", { type: Array, ...{ default: [] } });
|
|
74
|
+
const columnOrderState = defineModel("columnOrder", { type: Array, ...{ default: [] } });
|
|
75
|
+
const columnVisibilityState = defineModel("columnVisibility", { type: Object, ...{ default: {} } });
|
|
76
|
+
const columnPinningState = defineModel("columnPinning", { type: Object, ...{ default: {} } });
|
|
77
|
+
const columnSizingState = defineModel("columnSizing", { type: Object, ...{ default: {} } });
|
|
78
|
+
const columnSizingInfoState = defineModel("columnSizingInfo", { type: Object, ...{ default: {} } });
|
|
79
|
+
const rowSelectionState = defineModel("rowSelection", { type: Object, ...{ default: {} } });
|
|
80
|
+
const rowPinningState = defineModel("rowPinning", { type: Object, ...{ default: {} } });
|
|
81
|
+
const sortingState = defineModel("sorting", { type: Array, ...{ default: [] } });
|
|
82
|
+
const groupingState = defineModel("grouping", { type: Array, ...{ default: [] } });
|
|
83
|
+
const expandedState = defineModel("expanded", { type: [Boolean, Object], ...{ default: {} } });
|
|
84
|
+
const paginationState = defineModel("pagination", { type: Object, ...{ default: {} } });
|
|
85
|
+
const tableRef = ref();
|
|
207
86
|
const tableApi = useVueTable({
|
|
208
|
-
...reactiveOmit(props,
|
|
87
|
+
...reactiveOmit(props, "as", "data", "columns", "caption", "sticky", "loading", "loadingColor", "loadingAnimation", "class", "ui"),
|
|
209
88
|
data,
|
|
210
89
|
columns: columns.value,
|
|
90
|
+
meta: meta.value,
|
|
211
91
|
getCoreRowModel: getCoreRowModel(),
|
|
212
|
-
...
|
|
213
|
-
onGlobalFilterChange: updaterOrValue => valueUpdater(updaterOrValue, globalFilterState),
|
|
214
|
-
...
|
|
92
|
+
...props.globalFilterOptions || {},
|
|
93
|
+
onGlobalFilterChange: (updaterOrValue) => valueUpdater(updaterOrValue, globalFilterState),
|
|
94
|
+
...props.columnFiltersOptions || {},
|
|
215
95
|
getFilteredRowModel: getFilteredRowModel(),
|
|
216
|
-
onColumnFiltersChange: updaterOrValue => valueUpdater(updaterOrValue, columnFiltersState),
|
|
217
|
-
onColumnOrderChange: updaterOrValue => valueUpdater(updaterOrValue, columnOrderState),
|
|
218
|
-
...
|
|
219
|
-
onColumnVisibilityChange: updaterOrValue => valueUpdater(updaterOrValue, columnVisibilityState),
|
|
220
|
-
...
|
|
221
|
-
onColumnPinningChange: updaterOrValue => valueUpdater(updaterOrValue, columnPinningState),
|
|
222
|
-
...
|
|
223
|
-
onColumnSizingChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingState),
|
|
224
|
-
onColumnSizingInfoChange: updaterOrValue => valueUpdater(updaterOrValue, columnSizingInfoState),
|
|
225
|
-
...
|
|
226
|
-
onRowSelectionChange: updaterOrValue => valueUpdater(updaterOrValue, rowSelectionState),
|
|
227
|
-
...
|
|
228
|
-
onRowPinningChange: updaterOrValue => valueUpdater(updaterOrValue, rowPinningState),
|
|
229
|
-
...
|
|
96
|
+
onColumnFiltersChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnFiltersState),
|
|
97
|
+
onColumnOrderChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnOrderState),
|
|
98
|
+
...props.visibilityOptions || {},
|
|
99
|
+
onColumnVisibilityChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnVisibilityState),
|
|
100
|
+
...props.columnPinningOptions || {},
|
|
101
|
+
onColumnPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnPinningState),
|
|
102
|
+
...props.columnSizingOptions || {},
|
|
103
|
+
onColumnSizingChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingState),
|
|
104
|
+
onColumnSizingInfoChange: (updaterOrValue) => valueUpdater(updaterOrValue, columnSizingInfoState),
|
|
105
|
+
...props.rowSelectionOptions || {},
|
|
106
|
+
onRowSelectionChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowSelectionState),
|
|
107
|
+
...props.rowPinningOptions || {},
|
|
108
|
+
onRowPinningChange: (updaterOrValue) => valueUpdater(updaterOrValue, rowPinningState),
|
|
109
|
+
...props.sortingOptions || {},
|
|
230
110
|
getSortedRowModel: getSortedRowModel(),
|
|
231
|
-
onSortingChange: updaterOrValue => valueUpdater(updaterOrValue, sortingState),
|
|
232
|
-
...
|
|
233
|
-
onGroupingChange: updaterOrValue => valueUpdater(updaterOrValue, groupingState),
|
|
234
|
-
...
|
|
111
|
+
onSortingChange: (updaterOrValue) => valueUpdater(updaterOrValue, sortingState),
|
|
112
|
+
...props.groupingOptions || {},
|
|
113
|
+
onGroupingChange: (updaterOrValue) => valueUpdater(updaterOrValue, groupingState),
|
|
114
|
+
...props.expandedOptions || {},
|
|
235
115
|
getExpandedRowModel: getExpandedRowModel(),
|
|
236
|
-
onExpandedChange: updaterOrValue => valueUpdater(updaterOrValue, expandedState),
|
|
237
|
-
...
|
|
238
|
-
onPaginationChange: updaterOrValue => valueUpdater(updaterOrValue, paginationState),
|
|
239
|
-
...
|
|
116
|
+
onExpandedChange: (updaterOrValue) => valueUpdater(updaterOrValue, expandedState),
|
|
117
|
+
...props.paginationOptions || {},
|
|
118
|
+
onPaginationChange: (updaterOrValue) => valueUpdater(updaterOrValue, paginationState),
|
|
119
|
+
...props.facetedOptions || {},
|
|
240
120
|
state: {
|
|
241
121
|
get globalFilter() {
|
|
242
|
-
return globalFilterState.value
|
|
122
|
+
return globalFilterState.value;
|
|
243
123
|
},
|
|
244
124
|
get columnFilters() {
|
|
245
|
-
return columnFiltersState.value
|
|
125
|
+
return columnFiltersState.value;
|
|
246
126
|
},
|
|
247
127
|
get columnOrder() {
|
|
248
|
-
return columnOrderState.value
|
|
128
|
+
return columnOrderState.value;
|
|
249
129
|
},
|
|
250
130
|
get columnVisibility() {
|
|
251
|
-
return columnVisibilityState.value
|
|
131
|
+
return columnVisibilityState.value;
|
|
252
132
|
},
|
|
253
133
|
get columnPinning() {
|
|
254
|
-
return columnPinningState.value
|
|
134
|
+
return columnPinningState.value;
|
|
255
135
|
},
|
|
256
136
|
get expanded() {
|
|
257
|
-
return expandedState.value
|
|
137
|
+
return expandedState.value;
|
|
258
138
|
},
|
|
259
139
|
get rowSelection() {
|
|
260
|
-
return rowSelectionState.value
|
|
140
|
+
return rowSelectionState.value;
|
|
261
141
|
},
|
|
262
142
|
get sorting() {
|
|
263
|
-
return sortingState.value
|
|
143
|
+
return sortingState.value;
|
|
264
144
|
},
|
|
265
145
|
get grouping() {
|
|
266
|
-
return groupingState.value
|
|
146
|
+
return groupingState.value;
|
|
267
147
|
},
|
|
268
148
|
get rowPinning() {
|
|
269
|
-
return rowPinningState.value
|
|
149
|
+
return rowPinningState.value;
|
|
270
150
|
},
|
|
271
151
|
get columnSizing() {
|
|
272
|
-
return columnSizingState.value
|
|
152
|
+
return columnSizingState.value;
|
|
273
153
|
},
|
|
274
154
|
get columnSizingInfo() {
|
|
275
|
-
return columnSizingInfoState.value
|
|
155
|
+
return columnSizingInfoState.value;
|
|
276
156
|
},
|
|
277
157
|
get pagination() {
|
|
278
|
-
return paginationState.value
|
|
158
|
+
return paginationState.value;
|
|
279
159
|
}
|
|
280
160
|
}
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue
|
|
161
|
+
});
|
|
162
|
+
function valueUpdater(updaterOrValue, ref2) {
|
|
163
|
+
ref2.value = typeof updaterOrValue === "function" ? updaterOrValue(ref2.value) : updaterOrValue;
|
|
285
164
|
}
|
|
286
|
-
|
|
287
|
-
function handleRowSelect(row: TableRow<T>, e: Event) {
|
|
165
|
+
function handleRowSelect(row, e) {
|
|
288
166
|
if (!props.onSelect) {
|
|
289
|
-
return
|
|
167
|
+
return;
|
|
290
168
|
}
|
|
291
|
-
const target = e.target
|
|
292
|
-
const isInteractive = target.closest(
|
|
169
|
+
const target = e.target;
|
|
170
|
+
const isInteractive = target.closest("button") || target.closest("a");
|
|
293
171
|
if (isInteractive) {
|
|
294
|
-
return
|
|
172
|
+
return;
|
|
295
173
|
}
|
|
296
|
-
|
|
297
|
-
e.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
props.onSelect(row, e)
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
e.stopPropagation();
|
|
176
|
+
props.onSelect(row, e);
|
|
301
177
|
}
|
|
302
|
-
|
|
178
|
+
watch(
|
|
179
|
+
() => props.data,
|
|
180
|
+
() => {
|
|
181
|
+
data.value = props.data ? [...props.data] : [];
|
|
182
|
+
},
|
|
183
|
+
props.watchOptions
|
|
184
|
+
);
|
|
303
185
|
defineExpose({
|
|
186
|
+
tableRef,
|
|
304
187
|
tableApi
|
|
305
|
-
})
|
|
188
|
+
});
|
|
306
189
|
</script>
|
|
307
190
|
|
|
308
191
|
<template>
|
|
309
192
|
<Primitive :as="as" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
310
|
-
<table :class="ui.base({ class: [props.ui?.base] })">
|
|
311
|
-
<caption v-if="caption" :class="ui.caption({ class: [props.ui?.caption] })">
|
|
193
|
+
<table ref="tableRef" :class="ui.base({ class: [props.ui?.base] })">
|
|
194
|
+
<caption v-if="caption || !!slots.caption" :class="ui.caption({ class: [props.ui?.caption] })">
|
|
312
195
|
<slot name="caption">
|
|
313
196
|
{{ caption }}
|
|
314
197
|
</slot>
|
|
@@ -320,7 +203,14 @@ defineExpose({
|
|
|
320
203
|
v-for="header in headerGroup.headers"
|
|
321
204
|
:key="header.id"
|
|
322
205
|
:data-pinned="header.column.getIsPinned()"
|
|
323
|
-
:
|
|
206
|
+
:colspan="header.colSpan > 1 ? header.colSpan : void 0"
|
|
207
|
+
:class="ui.th({
|
|
208
|
+
class: [
|
|
209
|
+
props.ui?.th,
|
|
210
|
+
typeof header.column.columnDef.meta?.class?.th === 'function' ? header.column.columnDef.meta.class.th(header) : header.column.columnDef.meta?.class?.th
|
|
211
|
+
],
|
|
212
|
+
pinned: !!header.column.getIsPinned()
|
|
213
|
+
})"
|
|
324
214
|
>
|
|
325
215
|
<slot :name="`${header.id}-header`" v-bind="header.getContext()">
|
|
326
216
|
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.header" :props="header.getContext()" />
|
|
@@ -336,16 +226,27 @@ defineExpose({
|
|
|
336
226
|
:data-selected="row.getIsSelected()"
|
|
337
227
|
:data-selectable="!!props.onSelect"
|
|
338
228
|
:data-expanded="row.getIsExpanded()"
|
|
339
|
-
:role="props.onSelect ? 'button' :
|
|
340
|
-
:tabindex="props.onSelect ? 0 :
|
|
341
|
-
:class="ui.tr({
|
|
229
|
+
:role="props.onSelect ? 'button' : void 0"
|
|
230
|
+
:tabindex="props.onSelect ? 0 : void 0"
|
|
231
|
+
:class="ui.tr({
|
|
232
|
+
class: [
|
|
233
|
+
props.ui?.tr,
|
|
234
|
+
typeof tableApi.options.meta?.class?.tr === 'function' ? tableApi.options.meta.class.tr(row) : tableApi.options.meta?.class?.tr
|
|
235
|
+
]
|
|
236
|
+
})"
|
|
342
237
|
@click="handleRowSelect(row, $event)"
|
|
343
238
|
>
|
|
344
239
|
<td
|
|
345
240
|
v-for="cell in row.getVisibleCells()"
|
|
346
241
|
:key="cell.id"
|
|
347
242
|
:data-pinned="cell.column.getIsPinned()"
|
|
348
|
-
:class="ui.td({
|
|
243
|
+
:class="ui.td({
|
|
244
|
+
class: [
|
|
245
|
+
props.ui?.td,
|
|
246
|
+
typeof cell.column.columnDef.meta?.class?.td === 'function' ? cell.column.columnDef.meta.class.td(cell) : cell.column.columnDef.meta?.class?.td
|
|
247
|
+
],
|
|
248
|
+
pinned: !!cell.column.getIsPinned()
|
|
249
|
+
})"
|
|
349
250
|
>
|
|
350
251
|
<slot :name="`${cell.column.id}-cell`" v-bind="cell.getContext()">
|
|
351
252
|
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
|
@@ -369,7 +270,7 @@ defineExpose({
|
|
|
369
270
|
<tr v-else>
|
|
370
271
|
<td :colspan="columns?.length" :class="ui.empty({ class: props.ui?.empty })">
|
|
371
272
|
<slot name="empty">
|
|
372
|
-
{{ t('table.noData') }}
|
|
273
|
+
{{ empty || t('table.noData') }}
|
|
373
274
|
</slot>
|
|
374
275
|
</td>
|
|
375
276
|
</tr>
|