@movk/nuxt 1.2.0 → 1.3.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/movk-ui.css +3 -0
- package/README.md +74 -79
- package/dist/module.d.mts +57 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +120 -126
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -30
- package/dist/runtime/components/AutoForm.vue +114 -125
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -30
- package/dist/runtime/components/ColorChooser.d.vue.ts +21 -22
- package/dist/runtime/components/ColorChooser.vue +304 -27
- package/dist/runtime/components/ColorChooser.vue.d.ts +21 -22
- package/dist/runtime/components/DataTable.d.vue.ts +57 -0
- package/dist/runtime/components/DataTable.vue +584 -0
- package/dist/runtime/components/DataTable.vue.d.ts +57 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +20 -33
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +20 -33
- package/dist/runtime/components/MessageBox.d.vue.ts +36 -0
- package/dist/runtime/components/MessageBox.vue +113 -0
- package/dist/runtime/components/MessageBox.vue.d.ts +36 -0
- package/dist/runtime/components/PillGroup.d.vue.ts +33 -0
- package/dist/runtime/components/PillGroup.vue +291 -0
- package/dist/runtime/components/PillGroup.vue.d.ts +33 -0
- package/dist/runtime/components/Popconfirm.d.vue.ts +30 -0
- package/dist/runtime/components/Popconfirm.vue +143 -0
- package/dist/runtime/components/Popconfirm.vue.d.ts +30 -0
- package/dist/runtime/components/SearchForm.d.vue.ts +21 -149
- package/dist/runtime/components/SearchForm.vue +211 -153
- package/dist/runtime/components/SearchForm.vue.d.ts +21 -149
- package/dist/runtime/components/SlideVerify.d.vue.ts +31 -70
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +31 -70
- package/dist/runtime/components/StarRating.d.vue.ts +38 -87
- package/dist/runtime/components/StarRating.vue +118 -74
- package/dist/runtime/components/StarRating.vue.d.ts +38 -87
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +11 -15
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +22 -9
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +11 -15
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -13
- package/dist/runtime/components/input/WithCharacterLimit.vue +23 -11
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -13
- package/dist/runtime/components/input/WithClear.d.vue.ts +13 -11
- package/dist/runtime/components/input/WithClear.vue +27 -8
- package/dist/runtime/components/input/WithClear.vue.d.ts +13 -11
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -13
- package/dist/runtime/components/input/WithCopy.vue +25 -8
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -13
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +13 -16
- package/dist/runtime/components/input/WithFloatingLabel.vue +35 -27
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +13 -16
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +24 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +27 -12
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +9 -4
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +9 -4
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +10 -5
- package/dist/runtime/composables/useApiFetch.js +20 -2
- package/dist/runtime/composables/useAutoForm.d.ts +4 -4
- package/dist/runtime/composables/useAutoForm.js +23 -9
- package/dist/runtime/composables/useClientApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useDateFormatter.d.ts +16 -3
- package/dist/runtime/composables/useDateFormatter.js +89 -30
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +26 -27
- package/dist/runtime/composables/useDownloadWithProgress.js +142 -40
- package/dist/runtime/composables/useLazyApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +26 -16
- package/dist/runtime/composables/useTheme.js +98 -71
- package/dist/runtime/composables/useUploadWithProgress.d.ts +23 -29
- package/dist/runtime/composables/useUploadWithProgress.js +78 -67
- package/dist/runtime/domains/api/auth.d.ts +2 -0
- package/dist/runtime/domains/api/auth.js +31 -0
- package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
- package/dist/runtime/domains/api/endpoint-config.js +17 -0
- package/dist/runtime/domains/api/errors.d.ts +2 -0
- package/dist/runtime/domains/api/errors.js +10 -0
- package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
- package/dist/runtime/domains/api/fetch-key.js +23 -0
- package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
- package/dist/runtime/domains/api/interceptors/error.js +49 -0
- package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
- package/dist/runtime/domains/api/interceptors/request.js +46 -0
- package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
- package/dist/runtime/domains/api/interceptors/response.js +27 -0
- package/dist/runtime/domains/api/response.d.ts +4 -0
- package/dist/runtime/domains/api/response.js +14 -0
- package/dist/runtime/domains/api/toast.d.ts +15 -0
- package/dist/runtime/domains/api/toast.js +46 -0
- package/dist/runtime/domains/api/transfer.d.ts +69 -0
- package/dist/runtime/domains/api/transfer.js +81 -0
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
- package/dist/runtime/domains/auto-form/actions.js +4 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +25 -29
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererChildren.vue → domains/auto-form/components/Children.vue} +18 -18
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererLayout.vue → domains/auto-form/components/Layout.vue} +24 -25
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererNested.vue → domains/auto-form/components/Nested.vue} +17 -21
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/{auto-form → domains/auto-form}/controls.js +27 -24
- package/dist/runtime/{auto-form/field-utils.d.ts → domains/auto-form/fields.d.ts} +3 -1
- package/dist/runtime/{auto-form/field-utils.js → domains/auto-form/fields.js} +18 -2
- package/dist/runtime/{auto-form → domains/auto-form}/metadata.js +1 -1
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{auto-form → domains/auto-form}/provider.js +6 -3
- package/dist/runtime/{auto-form/reactive-utils.d.ts → domains/auto-form/reactive.d.ts} +5 -5
- package/dist/runtime/{auto-form/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/{auto-form/schema-introspector.d.ts → domains/auto-form/schema.d.ts} +2 -2
- package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +1 -1
- package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
- package/dist/runtime/domains/data-table/columns/constants.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +164 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
- package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
- package/dist/runtime/domains/data-table/columns/style.js +67 -0
- package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
- package/dist/runtime/domains/data-table/columns/utils.js +16 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
- package/dist/runtime/domains/data-table/indent.d.ts +8 -0
- package/dist/runtime/domains/data-table/indent.js +19 -0
- package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
- package/dist/runtime/domains/data-table/tree-selection.js +76 -0
- package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/plugins/api.factory.js +17 -117
- package/dist/runtime/plugins/theme.js +49 -27
- package/dist/runtime/types/api/config.d.ts +127 -0
- package/dist/runtime/types/api/fetch.d.ts +50 -0
- package/dist/runtime/types/api/index.d.ts +5 -0
- package/dist/runtime/types/api/module.d.ts +94 -0
- package/dist/runtime/types/api/response.d.ts +62 -0
- package/dist/runtime/types/api/response.js +0 -0
- package/dist/runtime/types/api/transfer.d.ts +32 -0
- package/dist/runtime/types/api/transfer.js +0 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/auto-form/base.d.ts +26 -0
- package/dist/runtime/types/auto-form/base.js +0 -0
- package/dist/runtime/types/auto-form/component.d.ts +28 -0
- package/dist/runtime/types/auto-form/component.js +0 -0
- package/dist/runtime/types/auto-form/controls.d.ts +45 -0
- package/dist/runtime/types/auto-form/controls.js +0 -0
- package/dist/runtime/types/auto-form/fields.d.ts +68 -0
- package/dist/runtime/types/auto-form/fields.js +0 -0
- package/dist/runtime/types/auto-form/index.d.ts +7 -0
- package/dist/runtime/types/auto-form/index.js +0 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
- package/dist/runtime/types/auto-form/search-form.js +0 -0
- package/dist/runtime/types/auto-form/slots.d.ts +85 -0
- package/dist/runtime/types/auto-form/slots.js +0 -0
- package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
- package/dist/runtime/types/auto-form/zod-factory.js +0 -0
- package/dist/runtime/types/components/color-chooser.d.ts +109 -0
- package/dist/runtime/types/components/color-chooser.js +0 -0
- package/dist/runtime/types/components/date-picker.d.ts +41 -0
- package/dist/runtime/types/components/date-picker.js +0 -0
- package/dist/runtime/types/components/index.d.ts +8 -0
- package/dist/runtime/types/components/index.js +0 -0
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
- package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
- package/dist/runtime/types/components/input/index.d.ts +6 -0
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/message-box.d.ts +69 -0
- package/dist/runtime/types/components/message-box.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +103 -0
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +74 -0
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +54 -0
- package/dist/runtime/types/components/slide-verify.js +0 -0
- package/dist/runtime/types/components/star-rating.d.ts +55 -0
- package/dist/runtime/types/components/star-rating.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +236 -0
- package/dist/runtime/types/data-table/columns.js +6 -0
- package/dist/runtime/types/data-table/component.d.ts +190 -0
- package/dist/runtime/types/data-table/component.js +0 -0
- package/dist/runtime/types/data-table/contexts.d.ts +44 -0
- package/dist/runtime/types/data-table/contexts.js +0 -0
- package/dist/runtime/types/data-table/index.d.ts +6 -0
- package/dist/runtime/types/data-table/index.js +1 -0
- package/dist/runtime/types/data-table/pagination.d.ts +87 -0
- package/dist/runtime/types/data-table/pagination.js +0 -0
- package/dist/runtime/types/index.d.ts +6 -5
- package/dist/runtime/types/index.js +5 -5
- package/dist/runtime/types/shared.d.ts +5 -0
- package/dist/runtime/types/shared.js +0 -0
- package/dist/runtime/types/zod.d.ts +11 -10
- package/dist/runtime/utils/extend-theme.d.ts +19 -0
- package/dist/runtime/utils/extend-theme.js +44 -0
- package/dist/runtime/utils/form-control.d.ts +33 -0
- package/dist/runtime/utils/form-control.js +54 -0
- package/dist/runtime/utils/meta.d.ts +2 -5
- package/dist/runtime/utils/meta.js +1 -3
- package/dist/runtime/utils/theme-defaults.d.ts +27 -0
- package/dist/runtime/utils/theme-defaults.js +28 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
- package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
- package/dist/runtime/vue/plugins/theme.d.ts +6 -0
- package/dist/runtime/vue/plugins/theme.js +14 -0
- package/dist/runtime/vue/stubs/base.d.ts +2 -0
- package/dist/runtime/vue/stubs/base.js +2 -0
- package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
- package/dist/runtime/vue/stubs/inertia.js +2 -0
- package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
- package/dist/runtime/vue/stubs/movk-extra.js +2 -0
- package/dist/runtime/vue/stubs/none.d.ts +2 -0
- package/dist/runtime/vue/stubs/none.js +2 -0
- package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
- package/dist/runtime/vue/stubs/vue-router.js +2 -0
- package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
- package/dist/types.d.mts +2 -6
- package/dist/unplugin.d.mts +28 -0
- package/dist/unplugin.mjs +292 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.mjs +20 -0
- package/package.json +75 -36
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/auto-form/controls.d.ts +0 -221
- package/dist/runtime/auto-form/provider.d.ts +0 -27
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -26
- package/dist/runtime/constants/api-defaults.d.ts +0 -9
- package/dist/runtime/constants/api-defaults.js +0 -32
- package/dist/runtime/constants/grid-cols.d.ts +0 -7
- package/dist/runtime/constants/grid-cols.js +0 -44
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -349
- package/dist/runtime/types/auto-form.d.ts +0 -259
- package/dist/runtime/types/module.d.ts +0 -96
- package/dist/runtime/types/theme.d.ts +0 -2
- package/dist/runtime/utils/api-utils.d.ts +0 -58
- package/dist/runtime/utils/api-utils.js +0 -98
- /package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -0
- /package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -0
- /package/dist/runtime/{auto-form → domains/auto-form}/metadata.d.ts +0 -0
- /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
- /package/dist/runtime/types/{api.js → api/config.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{module.js → api/index.js} +0 -0
- /package/dist/runtime/types/{theme.js → api/module.js} +0 -0
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { getPaginationRowModel } from "@tanstack/vue-table";
|
|
3
|
+
import { UTable } from "#components";
|
|
4
|
+
import { useAppConfig } from "#imports";
|
|
5
|
+
import { computed, onMounted, ref, useAttrs, useTemplateRef, watch } from "vue";
|
|
6
|
+
import { useExtendedTv } from "../utils/extend-theme";
|
|
7
|
+
import { resolveColumns } from "../domains/data-table/columns/resolve-columns";
|
|
8
|
+
import { resolveCallbackValue } from "../domains/data-table/columns/utils";
|
|
9
|
+
import { computeTreeRowSelection } from "../domains/data-table/tree-selection";
|
|
10
|
+
import { resolveMaxIndentPx } from "../domains/data-table/indent";
|
|
11
|
+
import { Tree, useInfiniteScrollBinding, separate } from "@movk/core";
|
|
12
|
+
import theme from "#build/movk-ui/data-table";
|
|
13
|
+
import tableTheme from "#build/ui/table";
|
|
14
|
+
import DataTablePagination from "../domains/data-table/components/Pagination.vue";
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
rowKey: { type: [String, Object], required: false },
|
|
17
|
+
columns: { type: Array, required: false },
|
|
18
|
+
loading: { type: Boolean, required: false },
|
|
19
|
+
stripe: { type: Boolean, required: false },
|
|
20
|
+
bordered: { type: [Boolean, Object], required: false },
|
|
21
|
+
fitContent: { type: Boolean, required: false },
|
|
22
|
+
emptyCell: { type: [Boolean, String, Function], required: false, default: "-" },
|
|
23
|
+
pinable: { type: [Boolean, Function], required: false },
|
|
24
|
+
pinButtonProps: { type: [Object, Function], required: false },
|
|
25
|
+
sortable: { type: [Boolean, Function], required: false },
|
|
26
|
+
sortButtonProps: { type: [Object, Function], required: false },
|
|
27
|
+
actionButtonProps: { type: [Object, Function], required: false },
|
|
28
|
+
actionsMaxInline: { type: Number, required: false },
|
|
29
|
+
actionsOverflowTrigger: { type: [Object, Function], required: false },
|
|
30
|
+
resizable: { type: [Boolean, Function], required: false },
|
|
31
|
+
columnResizeMode: { type: String, required: false, default: "onChange" },
|
|
32
|
+
density: { type: String, required: false },
|
|
33
|
+
meta: { type: Object, required: false },
|
|
34
|
+
rowClass: { type: [String, Function], required: false },
|
|
35
|
+
rowStyle: { type: [String, Object, Function], required: false },
|
|
36
|
+
tooltip: { type: [Boolean, Number, Function], required: false },
|
|
37
|
+
tooltipProps: { type: null, required: false },
|
|
38
|
+
truncate: { type: [Boolean, Number, Function], required: false, default: true },
|
|
39
|
+
sortingOptions: { type: Object, required: false },
|
|
40
|
+
columnSizingOptions: { type: Object, required: false },
|
|
41
|
+
columnPinningOptions: { type: Object, required: false },
|
|
42
|
+
rowSelectionOptions: { type: Object, required: false },
|
|
43
|
+
childrenKey: { type: [String, Object], required: false },
|
|
44
|
+
indentSize: { type: [Number, String, Function], required: false, default: "1rem" },
|
|
45
|
+
expandedOptions: { type: Object, required: false },
|
|
46
|
+
expandOnRowClick: { type: Boolean, required: false },
|
|
47
|
+
selectOnRowClick: { type: Boolean, required: false },
|
|
48
|
+
columnVisibilityKeys: { type: Array, required: false },
|
|
49
|
+
columnVisibilityExcludeKeys: { type: Array, required: false },
|
|
50
|
+
rowSelectionKeys: { type: Array, required: false },
|
|
51
|
+
expandedKeys: { type: Array, required: false },
|
|
52
|
+
onSelect: { type: Function, required: false },
|
|
53
|
+
onHover: { type: Function, required: false },
|
|
54
|
+
onRowContextmenu: { type: [Function, Array], required: false },
|
|
55
|
+
paginationOptions: { type: Object, required: false },
|
|
56
|
+
sticky: { type: [Boolean, String], required: false, default: true },
|
|
57
|
+
paginationUi: { type: Object, required: false },
|
|
58
|
+
loadMore: { type: Function, required: false },
|
|
59
|
+
canLoadMore: { type: Boolean, required: false },
|
|
60
|
+
loadMoreDistance: { type: Number, required: false },
|
|
61
|
+
class: { type: null, required: false },
|
|
62
|
+
ui: { type: Object, required: false }
|
|
63
|
+
});
|
|
64
|
+
const paginationState = defineModel("pagination", { type: Object });
|
|
65
|
+
const columnVisibilityState = defineModel("columnVisibility", { type: Object });
|
|
66
|
+
const columnPinningState = defineModel("columnPinning", { type: Object });
|
|
67
|
+
const columnSizingState = defineModel("columnSizing", { type: Object });
|
|
68
|
+
const rowSelectionState = defineModel("rowSelection", { type: Object });
|
|
69
|
+
const rowPinningState = defineModel("rowPinning", { type: Object, ...{ default: () => ({ top: [], bottom: [] }) } });
|
|
70
|
+
const sortingState = defineModel("sorting", { type: Array, ...{ default: () => [] } });
|
|
71
|
+
const expandedState = defineModel("expanded", { type: [Boolean, Object] });
|
|
72
|
+
const columnVisibilityKeysState = defineModel("columnVisibilityKeys", { type: Array });
|
|
73
|
+
const columnVisibilityExcludeKeysState = defineModel("columnVisibilityExcludeKeys", { type: Array });
|
|
74
|
+
const rowSelectionKeysState = defineModel("rowSelectionKeys", { type: Array });
|
|
75
|
+
const expandedKeysState = defineModel("expandedKeys", { type: Array });
|
|
76
|
+
defineSlots();
|
|
77
|
+
const resolved = computed(() => resolveColumns(props.columns || [], props));
|
|
78
|
+
function hasEntries(v) {
|
|
79
|
+
return typeof v === "object" && v !== null && Object.keys(v).length > 0;
|
|
80
|
+
}
|
|
81
|
+
function keysToVisibility(keys, allColumnIds) {
|
|
82
|
+
const set = new Set(keys);
|
|
83
|
+
const state = {};
|
|
84
|
+
for (const id of allColumnIds) state[id] = set.has(id);
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
function visibilityToKeys(state, allColumnIds) {
|
|
88
|
+
return allColumnIds.filter((id) => state[id] !== false);
|
|
89
|
+
}
|
|
90
|
+
function keysToVisibilityExclude(excludeKeys, allColumnIds) {
|
|
91
|
+
const set = new Set(excludeKeys);
|
|
92
|
+
const state = {};
|
|
93
|
+
for (const id of allColumnIds) state[id] = !set.has(id);
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
96
|
+
function visibilityToExcludeKeys(state, allColumnIds) {
|
|
97
|
+
return allColumnIds.filter((id) => state[id] === false);
|
|
98
|
+
}
|
|
99
|
+
function keysToRowSelection(keys) {
|
|
100
|
+
const state = {};
|
|
101
|
+
for (const key of keys) state[key] = true;
|
|
102
|
+
return state;
|
|
103
|
+
}
|
|
104
|
+
function rowSelectionToKeys(state) {
|
|
105
|
+
return Object.entries(state).filter(([, s]) => s).map(([k]) => k);
|
|
106
|
+
}
|
|
107
|
+
function keysToExpanded(keys) {
|
|
108
|
+
const state = {};
|
|
109
|
+
for (const key of keys) state[key] = true;
|
|
110
|
+
return state;
|
|
111
|
+
}
|
|
112
|
+
function expandedToKeys(state) {
|
|
113
|
+
if (state === true) return [];
|
|
114
|
+
return Object.entries(state).filter(([, e]) => e).map(([k]) => k);
|
|
115
|
+
}
|
|
116
|
+
function areSameKeys(a, b) {
|
|
117
|
+
if (a.length !== b.length) return false;
|
|
118
|
+
const set = new Set(a.map(String));
|
|
119
|
+
for (const key of b) if (!set.has(String(key))) return false;
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
function useEffectiveModel(model, getDefault, syncBack) {
|
|
123
|
+
const effective = computed({
|
|
124
|
+
get: () => model.value !== void 0 ? model.value : getDefault(),
|
|
125
|
+
set: (value) => {
|
|
126
|
+
model.value = value;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (syncBack !== void 0) {
|
|
130
|
+
onMounted(() => {
|
|
131
|
+
if (model.value !== void 0) return;
|
|
132
|
+
const defaults = getDefault();
|
|
133
|
+
if (syncBack(defaults)) model.value = defaults;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return effective;
|
|
137
|
+
}
|
|
138
|
+
function useSyncKeys(keys, record, toRecord, toKeys) {
|
|
139
|
+
let updating = false;
|
|
140
|
+
watch(keys, (next) => {
|
|
141
|
+
if (updating) return;
|
|
142
|
+
const current = record.value !== void 0 ? toKeys(record.value) : [];
|
|
143
|
+
if (areSameKeys(current, next ?? [])) return;
|
|
144
|
+
updating = true;
|
|
145
|
+
record.value = toRecord(next ?? []);
|
|
146
|
+
updating = false;
|
|
147
|
+
}, { deep: true });
|
|
148
|
+
watch(record, (next) => {
|
|
149
|
+
if (updating) return;
|
|
150
|
+
if (next === void 0) return;
|
|
151
|
+
const derived = toKeys(next);
|
|
152
|
+
if (areSameKeys(derived, keys.value ?? [])) return;
|
|
153
|
+
updating = true;
|
|
154
|
+
keys.value = derived;
|
|
155
|
+
updating = false;
|
|
156
|
+
}, { deep: true });
|
|
157
|
+
}
|
|
158
|
+
const effectiveVisibility = useEffectiveModel(
|
|
159
|
+
columnVisibilityState,
|
|
160
|
+
() => {
|
|
161
|
+
if (columnVisibilityKeysState.value !== void 0) {
|
|
162
|
+
return keysToVisibility(columnVisibilityKeysState.value, resolved.value.allColumnIds);
|
|
163
|
+
}
|
|
164
|
+
if (columnVisibilityExcludeKeysState.value !== void 0) {
|
|
165
|
+
return keysToVisibilityExclude(columnVisibilityExcludeKeysState.value, resolved.value.allColumnIds);
|
|
166
|
+
}
|
|
167
|
+
return { ...resolved.value.initialVisibility };
|
|
168
|
+
},
|
|
169
|
+
hasEntries
|
|
170
|
+
);
|
|
171
|
+
const effectivePinning = useEffectiveModel(
|
|
172
|
+
columnPinningState,
|
|
173
|
+
() => ({
|
|
174
|
+
left: [...resolved.value.initialPinning.left ?? []],
|
|
175
|
+
right: [...resolved.value.initialPinning.right ?? []]
|
|
176
|
+
}),
|
|
177
|
+
(v) => (v.left?.length ?? 0) + (v.right?.length ?? 0) > 0
|
|
178
|
+
);
|
|
179
|
+
const effectiveSizing = useEffectiveModel(
|
|
180
|
+
columnSizingState,
|
|
181
|
+
() => ({ ...resolved.value.initialSizing }),
|
|
182
|
+
hasEntries
|
|
183
|
+
);
|
|
184
|
+
const effectiveRowSelection = useEffectiveModel(
|
|
185
|
+
rowSelectionState,
|
|
186
|
+
() => rowSelectionKeysState.value !== void 0 ? keysToRowSelection(rowSelectionKeysState.value) : {},
|
|
187
|
+
hasEntries
|
|
188
|
+
);
|
|
189
|
+
const effectiveExpanded = useEffectiveModel(
|
|
190
|
+
expandedState,
|
|
191
|
+
() => expandedKeysState.value !== void 0 ? keysToExpanded(expandedKeysState.value) : {},
|
|
192
|
+
hasEntries
|
|
193
|
+
);
|
|
194
|
+
useSyncKeys(
|
|
195
|
+
columnVisibilityKeysState,
|
|
196
|
+
columnVisibilityState,
|
|
197
|
+
(keys) => keysToVisibility(keys, resolved.value.allColumnIds),
|
|
198
|
+
(state) => visibilityToKeys(state, resolved.value.allColumnIds)
|
|
199
|
+
);
|
|
200
|
+
useSyncKeys(
|
|
201
|
+
columnVisibilityExcludeKeysState,
|
|
202
|
+
columnVisibilityState,
|
|
203
|
+
(keys) => keysToVisibilityExclude(keys, resolved.value.allColumnIds),
|
|
204
|
+
(state) => visibilityToExcludeKeys(state, resolved.value.allColumnIds)
|
|
205
|
+
);
|
|
206
|
+
useSyncKeys(
|
|
207
|
+
rowSelectionKeysState,
|
|
208
|
+
rowSelectionState,
|
|
209
|
+
keysToRowSelection,
|
|
210
|
+
rowSelectionToKeys
|
|
211
|
+
);
|
|
212
|
+
useSyncKeys(
|
|
213
|
+
expandedKeysState,
|
|
214
|
+
expandedState,
|
|
215
|
+
keysToExpanded,
|
|
216
|
+
expandedToKeys
|
|
217
|
+
);
|
|
218
|
+
defineOptions({ inheritAttrs: false });
|
|
219
|
+
const attrs = useAttrs();
|
|
220
|
+
const appConfig = useAppConfig();
|
|
221
|
+
const tableRef = useTemplateRef("tableRef");
|
|
222
|
+
const internalLoading = ref(false);
|
|
223
|
+
async function invokeLoadMore() {
|
|
224
|
+
if (!props.loadMore) return;
|
|
225
|
+
const ret = props.loadMore();
|
|
226
|
+
if (ret && typeof ret.then === "function") {
|
|
227
|
+
internalLoading.value = true;
|
|
228
|
+
try {
|
|
229
|
+
await ret;
|
|
230
|
+
} finally {
|
|
231
|
+
internalLoading.value = false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
useInfiniteScrollBinding(
|
|
236
|
+
() => tableRef.value?.$el ?? null,
|
|
237
|
+
{
|
|
238
|
+
distance: () => props.loadMoreDistance ?? 100,
|
|
239
|
+
canLoadMore: () => !!props.loadMore && props.canLoadMore !== false && !internalLoading.value,
|
|
240
|
+
onLoadMore: invokeLoadMore
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
function scrollToTop(options = { top: 0, behavior: "smooth" }) {
|
|
244
|
+
tableRef.value?.$el?.scrollTo({ top: 0, ...options });
|
|
245
|
+
}
|
|
246
|
+
const tableApi = computed(() => tableRef.value?.tableApi ?? null);
|
|
247
|
+
const isColumnResizing = computed(() => Boolean(tableApi.value?.getState().columnSizingInfo.isResizingColumn));
|
|
248
|
+
const isTreeMode = computed(() => Boolean(props.childrenKey));
|
|
249
|
+
const treeMaxDepth = computed(() => {
|
|
250
|
+
if (!isTreeMode.value || !props.childrenKey) return 0;
|
|
251
|
+
const data = attrs.data ?? [];
|
|
252
|
+
if (data.length === 0) return 0;
|
|
253
|
+
return Tree.getStats(data, { children: props.childrenKey }).depth - 1;
|
|
254
|
+
});
|
|
255
|
+
const EXPAND_DEFAULT_SIZE = 60;
|
|
256
|
+
const EXPAND_BUTTON_SLOT = 60;
|
|
257
|
+
const expandColumnSize = computed(() => {
|
|
258
|
+
if (!isTreeMode.value || !resolved.value.hasExpandColumn) return null;
|
|
259
|
+
const maxButtonDepth = Math.max(0, treeMaxDepth.value - 1);
|
|
260
|
+
if (maxButtonDepth === 0) return null;
|
|
261
|
+
const indentPx = resolveMaxIndentPx(props.indentSize, maxButtonDepth);
|
|
262
|
+
return Math.max(EXPAND_DEFAULT_SIZE, EXPAND_BUTTON_SLOT + indentPx * 2);
|
|
263
|
+
});
|
|
264
|
+
let autoExpandSize = null;
|
|
265
|
+
watch(expandColumnSize, (target) => {
|
|
266
|
+
if (target == null) return;
|
|
267
|
+
const state = effectiveSizing.value;
|
|
268
|
+
const current = state.__expand;
|
|
269
|
+
const canOverride = current == null || current === EXPAND_DEFAULT_SIZE || current === autoExpandSize;
|
|
270
|
+
if (!canOverride || current === target) return;
|
|
271
|
+
effectiveSizing.value = { ...state, __expand: target };
|
|
272
|
+
autoExpandSize = target;
|
|
273
|
+
}, { immediate: true });
|
|
274
|
+
const isManualPagination = computed(() => props.paginationOptions?.manualPagination === true);
|
|
275
|
+
const hasPaginationIntent = computed(
|
|
276
|
+
() => !props.loadMore && (props.paginationOptions !== void 0 || paginationState.value !== void 0 || (props.paginationUi?.pageSizes?.length ?? 0) > 0 || props.paginationUi?.show === true)
|
|
277
|
+
);
|
|
278
|
+
const tableMeta = computed(() => ({
|
|
279
|
+
...(props.stripe || props.rowClass || props.meta?.class?.tr) && {
|
|
280
|
+
class: {
|
|
281
|
+
tr: (row) => [
|
|
282
|
+
props.rowClass && resolveCallbackValue(props.rowClass, row.original),
|
|
283
|
+
props.meta?.class?.tr && resolveCallbackValue(props.meta.class.tr, row)
|
|
284
|
+
].filter(Boolean).join(" ")
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
...(props.rowStyle || props.meta?.style?.tr) && {
|
|
288
|
+
style: {
|
|
289
|
+
tr: props.rowStyle && props.meta?.style?.tr ? (row) => {
|
|
290
|
+
const a = resolveCallbackValue(props.rowStyle, row.original);
|
|
291
|
+
const b = resolveCallbackValue(props.meta.style.tr, row);
|
|
292
|
+
return typeof a === "object" && typeof b === "object" ? { ...a, ...b } : b;
|
|
293
|
+
} : props.rowStyle ? (row) => resolveCallbackValue(props.rowStyle, row.original) : props.meta.style.tr
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}));
|
|
297
|
+
const borderedStyle = computed(() => {
|
|
298
|
+
if (!props.bordered || typeof props.bordered === "boolean") return void 0;
|
|
299
|
+
return {
|
|
300
|
+
"--m-dt-border-color": props.bordered.color,
|
|
301
|
+
"--m-dt-border-width": props.bordered.width,
|
|
302
|
+
"--m-dt-border-style": props.bordered.style
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
const { baseUi, extraUi } = useExtendedTv(
|
|
306
|
+
tableTheme,
|
|
307
|
+
theme,
|
|
308
|
+
() => appConfig.movk?.dataTable,
|
|
309
|
+
() => ({
|
|
310
|
+
ui: {
|
|
311
|
+
...props.ui,
|
|
312
|
+
wrapper: [props.ui?.wrapper, props.class]
|
|
313
|
+
},
|
|
314
|
+
variants: {
|
|
315
|
+
fitContent: !!props.fitContent,
|
|
316
|
+
bordered: !!props.bordered,
|
|
317
|
+
striped: !!props.stripe,
|
|
318
|
+
tree: isTreeMode.value,
|
|
319
|
+
resizing: isColumnResizing.value
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
const uTableProps = computed(() => {
|
|
324
|
+
const hasRowClickBehavior = props.expandOnRowClick || props.selectOnRowClick || !!props.onSelect;
|
|
325
|
+
return {
|
|
326
|
+
...props.rowKey && {
|
|
327
|
+
getRowId: ((row) => String(row[props.rowKey]))
|
|
328
|
+
},
|
|
329
|
+
...props.childrenKey && {
|
|
330
|
+
getSubRows: (row) => {
|
|
331
|
+
const children = row[props.childrenKey];
|
|
332
|
+
return Array.isArray(children) && children.length > 0 ? children : void 0;
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
...attrs,
|
|
336
|
+
sticky: props.sticky,
|
|
337
|
+
loading: Boolean(props.loading) || internalLoading.value,
|
|
338
|
+
columns: resolved.value.columnDefs,
|
|
339
|
+
meta: tableMeta.value,
|
|
340
|
+
ui: baseUi.value,
|
|
341
|
+
columnSizingOptions: {
|
|
342
|
+
enableColumnResizing: !!props.resizable || resolved.value.hasColumnResizing,
|
|
343
|
+
...props.columnResizeMode && { columnResizeMode: props.columnResizeMode },
|
|
344
|
+
...props.columnSizingOptions
|
|
345
|
+
},
|
|
346
|
+
sortingOptions: {
|
|
347
|
+
enableSorting: !!props.sortable || resolved.value.hasColumnSort,
|
|
348
|
+
...props.sortingOptions
|
|
349
|
+
},
|
|
350
|
+
columnPinningOptions: {
|
|
351
|
+
enableColumnPinning: !!props.pinable || resolved.value.hasColumnPinning,
|
|
352
|
+
...props.columnPinningOptions
|
|
353
|
+
},
|
|
354
|
+
rowSelectionOptions: resolved.value.selectionMode ? {
|
|
355
|
+
...resolved.value.selectionMode === "single" && { enableMultiRowSelection: false },
|
|
356
|
+
...resolved.value.subRowSelection === false && { enableSubRowSelection: false },
|
|
357
|
+
...props.rowSelectionOptions
|
|
358
|
+
} : {
|
|
359
|
+
...resolved.value.subRowSelection === false && { enableSubRowSelection: false },
|
|
360
|
+
...props.rowSelectionOptions
|
|
361
|
+
},
|
|
362
|
+
expandedOptions: {
|
|
363
|
+
...resolved.value.hasExpandColumn && { enableExpanding: true },
|
|
364
|
+
...props.expandedOptions
|
|
365
|
+
},
|
|
366
|
+
// pageCount / rowCount 由 MDataTable 自管,不灌进 TanStack,避免 setPageIndex 的 clamp 副作用
|
|
367
|
+
paginationOptions: {
|
|
368
|
+
...hasPaginationIntent.value && !isManualPagination.value && {
|
|
369
|
+
getPaginationRowModel: getPaginationRowModel()
|
|
370
|
+
},
|
|
371
|
+
...separate(props.paginationOptions ?? {}, ["pageCount", "rowCount"]).omitted
|
|
372
|
+
},
|
|
373
|
+
...hasRowClickBehavior && {
|
|
374
|
+
onSelect: (e, row) => {
|
|
375
|
+
if (props.expandOnRowClick) {
|
|
376
|
+
const canToggle = isTreeMode.value ? row.getCanExpand() : true;
|
|
377
|
+
if (canToggle) row.toggleExpanded();
|
|
378
|
+
}
|
|
379
|
+
if (props.selectOnRowClick) row.toggleSelected();
|
|
380
|
+
props.onSelect?.(e, row);
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
...props.onHover && { onHover: props.onHover },
|
|
384
|
+
...props.onRowContextmenu && { onContextmenu: props.onRowContextmenu }
|
|
385
|
+
};
|
|
386
|
+
});
|
|
387
|
+
const selectedCount = computed(() => {
|
|
388
|
+
if (rowSelectionKeysState.value !== void 0) return rowSelectionKeysState.value.length;
|
|
389
|
+
return Object.keys(rowSelectionState.value ?? {}).length;
|
|
390
|
+
});
|
|
391
|
+
const paginationView = computed(() => {
|
|
392
|
+
const api = tableApi.value;
|
|
393
|
+
if (!api || !hasPaginationIntent.value) return null;
|
|
394
|
+
const manual = isManualPagination.value;
|
|
395
|
+
const explicitRowCount = props.paginationOptions?.rowCount;
|
|
396
|
+
const explicitPageCount = props.paginationOptions?.pageCount;
|
|
397
|
+
const rowCountKnown = !manual || explicitRowCount !== void 0;
|
|
398
|
+
const pagination = api.getState().pagination;
|
|
399
|
+
const pageIndex = pagination?.pageIndex ?? 0;
|
|
400
|
+
const pageSize = pagination?.pageSize ?? 10;
|
|
401
|
+
const currentPageRowCount = api.getRowModel().rows.length;
|
|
402
|
+
const fallbackManualPageCount = explicitRowCount !== void 0 ? Math.ceil(Math.max(0, explicitRowCount) / pageSize) : api.getPageCount();
|
|
403
|
+
const pageCount = manual ? Math.max(0, explicitPageCount ?? fallbackManualPageCount) : api.getPageCount();
|
|
404
|
+
const rowCount = rowCountKnown ? manual ? Math.max(0, explicitRowCount) : api.getRowCount() : 0;
|
|
405
|
+
const referenceCount = rowCountKnown ? rowCount : pageCount * pageSize;
|
|
406
|
+
const from = referenceCount > 0 && currentPageRowCount > 0 ? pageIndex * pageSize + 1 : 0;
|
|
407
|
+
const to = referenceCount > 0 && currentPageRowCount > 0 ? Math.min(referenceCount, from + currentPageRowCount - 1) : 0;
|
|
408
|
+
const show = props.paginationUi?.show ?? (pageCount > 1 || (props.paginationUi?.pageSizes?.length ?? 0) > 1);
|
|
409
|
+
const setPage = (value) => {
|
|
410
|
+
const nextPage = Math.floor(Number(value));
|
|
411
|
+
if (!Number.isFinite(nextPage) || nextPage < 1) return;
|
|
412
|
+
const maxPage = Math.max(1, pageCount);
|
|
413
|
+
const nextIndex = Math.min(maxPage, nextPage) - 1;
|
|
414
|
+
api.setPagination((prev) => ({ ...prev, pageIndex: nextIndex }));
|
|
415
|
+
};
|
|
416
|
+
const setPageSize = (value) => {
|
|
417
|
+
if (value === "" || value == null) return;
|
|
418
|
+
const nextPageSize = Math.floor(Number(value));
|
|
419
|
+
if (!Number.isFinite(nextPageSize) || nextPageSize <= 0) return;
|
|
420
|
+
api.setPagination((prev) => ({ ...prev, pageSize: nextPageSize }));
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
tableApi: api,
|
|
424
|
+
pagination: { pageIndex, pageSize },
|
|
425
|
+
page: pageIndex + 1,
|
|
426
|
+
rowCount,
|
|
427
|
+
rowCountKnown,
|
|
428
|
+
pageCount,
|
|
429
|
+
currentPageRowCount,
|
|
430
|
+
from,
|
|
431
|
+
to,
|
|
432
|
+
show,
|
|
433
|
+
setPage,
|
|
434
|
+
setPageSize
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
const paginationRendererProps = computed(() => {
|
|
438
|
+
const v = paginationView.value;
|
|
439
|
+
if (!v) return null;
|
|
440
|
+
return {
|
|
441
|
+
tableApi: v.tableApi,
|
|
442
|
+
pagination: v.pagination,
|
|
443
|
+
page: v.page,
|
|
444
|
+
rowCount: v.rowCount,
|
|
445
|
+
rowCountKnown: v.rowCountKnown,
|
|
446
|
+
pageCount: v.pageCount,
|
|
447
|
+
from: v.from,
|
|
448
|
+
to: v.to,
|
|
449
|
+
setPage: v.setPage,
|
|
450
|
+
setPageSize: v.setPageSize,
|
|
451
|
+
selectedCount: selectedCount.value
|
|
452
|
+
};
|
|
453
|
+
});
|
|
454
|
+
const showPagination = computed(() => paginationView.value?.show ?? false);
|
|
455
|
+
const treeSelection = computed(() => {
|
|
456
|
+
const data = attrs.data ?? [];
|
|
457
|
+
const keys = rowSelectionKeysState.value ?? Object.keys(effectiveRowSelection.value).filter((k) => effectiveRowSelection.value[k]);
|
|
458
|
+
return computeTreeRowSelection(data, keys, {
|
|
459
|
+
rowKey: props.rowKey,
|
|
460
|
+
childrenKey: props.childrenKey,
|
|
461
|
+
strategy: resolved.value.selectionStrategy
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
function clearSelection() {
|
|
465
|
+
rowSelectionState.value = {};
|
|
466
|
+
if (rowSelectionKeysState.value !== void 0) rowSelectionKeysState.value = [];
|
|
467
|
+
}
|
|
468
|
+
function expandToDepth(depth) {
|
|
469
|
+
const api = tableApi.value;
|
|
470
|
+
if (!api) return;
|
|
471
|
+
const next = {};
|
|
472
|
+
for (const row of api.getPrePaginationRowModel().flatRows) {
|
|
473
|
+
if (row.getCanExpand() && row.depth < depth) next[row.id] = true;
|
|
474
|
+
}
|
|
475
|
+
effectiveExpanded.value = next;
|
|
476
|
+
}
|
|
477
|
+
function collapseAll() {
|
|
478
|
+
effectiveExpanded.value = {};
|
|
479
|
+
}
|
|
480
|
+
const tableResetKey = computed(() => {
|
|
481
|
+
const flags = [
|
|
482
|
+
!!props.resizable,
|
|
483
|
+
!!props.sortable,
|
|
484
|
+
!!props.pinable,
|
|
485
|
+
resolved.value.hasColumnPinning,
|
|
486
|
+
resolved.value.hasColumnResizing,
|
|
487
|
+
resolved.value.hasColumnSort,
|
|
488
|
+
isManualPagination.value,
|
|
489
|
+
resolved.value.selectionMode === "single",
|
|
490
|
+
resolved.value.subRowSelection === false
|
|
491
|
+
].reduce((mask, enabled, index) => mask | (enabled ? 1 : 0) << index, 0);
|
|
492
|
+
return `${props.columnResizeMode === "onEnd" ? "e" : "c"}${flags.toString(36)}`;
|
|
493
|
+
});
|
|
494
|
+
defineExpose({
|
|
495
|
+
get tableRef() {
|
|
496
|
+
return tableRef.value?.tableRef ?? null;
|
|
497
|
+
},
|
|
498
|
+
get tableApi() {
|
|
499
|
+
return tableApi.value;
|
|
500
|
+
},
|
|
501
|
+
get el() {
|
|
502
|
+
return tableRef.value?.$el ?? null;
|
|
503
|
+
},
|
|
504
|
+
scrollToTop,
|
|
505
|
+
clearSelection,
|
|
506
|
+
expandToDepth,
|
|
507
|
+
collapseAll,
|
|
508
|
+
get treeSelection() {
|
|
509
|
+
return treeSelection.value;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
</script>
|
|
513
|
+
|
|
514
|
+
<template>
|
|
515
|
+
<div :class="extraUi.wrapper" data-slot="wrapper">
|
|
516
|
+
<UTable
|
|
517
|
+
:key="tableResetKey"
|
|
518
|
+
ref="tableRef"
|
|
519
|
+
v-model:pagination="paginationState"
|
|
520
|
+
v-model:column-visibility="effectiveVisibility"
|
|
521
|
+
v-model:column-pinning="effectivePinning"
|
|
522
|
+
v-model:column-sizing="effectiveSizing"
|
|
523
|
+
v-model:row-selection="effectiveRowSelection"
|
|
524
|
+
v-model:row-pinning="rowPinningState"
|
|
525
|
+
v-model:sorting="sortingState"
|
|
526
|
+
v-model:expanded="effectiveExpanded"
|
|
527
|
+
data-slot="table"
|
|
528
|
+
:style="borderedStyle"
|
|
529
|
+
v-bind="uTableProps"
|
|
530
|
+
>
|
|
531
|
+
<template v-if="$slots.expanded" #expanded="{ row }">
|
|
532
|
+
<slot name="expanded" :row="row" />
|
|
533
|
+
</template>
|
|
534
|
+
|
|
535
|
+
<template v-if="$slots.empty" #empty>
|
|
536
|
+
<slot name="empty" />
|
|
537
|
+
</template>
|
|
538
|
+
|
|
539
|
+
<template v-if="$slots.loading" #loading>
|
|
540
|
+
<slot name="loading" />
|
|
541
|
+
</template>
|
|
542
|
+
|
|
543
|
+
<template v-if="$slots.caption" #caption>
|
|
544
|
+
<slot name="caption" />
|
|
545
|
+
</template>
|
|
546
|
+
|
|
547
|
+
<template v-if="$slots['body-top']" #body-top>
|
|
548
|
+
<slot name="body-top" />
|
|
549
|
+
</template>
|
|
550
|
+
|
|
551
|
+
<template v-if="$slots['body-bottom']" #body-bottom>
|
|
552
|
+
<slot name="body-bottom" />
|
|
553
|
+
</template>
|
|
554
|
+
</UTable>
|
|
555
|
+
|
|
556
|
+
<template v-if="showPagination && paginationView && paginationRendererProps">
|
|
557
|
+
<slot
|
|
558
|
+
v-if="$slots.pagination"
|
|
559
|
+
name="pagination"
|
|
560
|
+
v-bind="{ ...paginationView, selectedCount }"
|
|
561
|
+
/>
|
|
562
|
+
|
|
563
|
+
<DataTablePagination
|
|
564
|
+
v-else
|
|
565
|
+
v-bind="paginationRendererProps"
|
|
566
|
+
:ui-config="props.paginationUi"
|
|
567
|
+
>
|
|
568
|
+
<template
|
|
569
|
+
v-if="$slots['pagination-summary']"
|
|
570
|
+
#summary="slotProps"
|
|
571
|
+
>
|
|
572
|
+
<slot name="pagination-summary" v-bind="slotProps" />
|
|
573
|
+
</template>
|
|
574
|
+
|
|
575
|
+
<template
|
|
576
|
+
v-if="$slots['pagination-actions']"
|
|
577
|
+
#actions="slotProps"
|
|
578
|
+
>
|
|
579
|
+
<slot name="pagination-actions" v-bind="slotProps" />
|
|
580
|
+
</template>
|
|
581
|
+
</DataTablePagination>
|
|
582
|
+
</template>
|
|
583
|
+
</div>
|
|
584
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ColumnPinningState, ColumnSizingState, ExpandedState, PaginationState, RowPinningState, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
|
|
2
|
+
import type { TableData } from '@nuxt/ui';
|
|
3
|
+
import type { DataTableExposed, DataTableProps, DataTableSlots } from '../types/data-table/component';
|
|
4
|
+
import type { DataTablePaginationUi } from '../types/data-table/pagination';
|
|
5
|
+
declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
6
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(DataTableProps<T> & {
|
|
7
|
+
ui?: {
|
|
8
|
+
[x: string]: import("tailwind-variants").ClassValue;
|
|
9
|
+
};
|
|
10
|
+
paginationUi?: DataTablePaginationUi & {
|
|
11
|
+
ui?: {
|
|
12
|
+
[x: string]: import("tailwind-variants").ClassValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} & {
|
|
16
|
+
pagination?: PaginationState;
|
|
17
|
+
columnVisibility?: VisibilityState;
|
|
18
|
+
columnPinning?: ColumnPinningState;
|
|
19
|
+
columnSizing?: ColumnSizingState;
|
|
20
|
+
rowSelection?: RowSelectionState;
|
|
21
|
+
rowPinning?: RowPinningState;
|
|
22
|
+
sorting?: SortingState;
|
|
23
|
+
expanded?: ExpandedState;
|
|
24
|
+
columnVisibilityKeys?: string[];
|
|
25
|
+
columnVisibilityExcludeKeys?: string[];
|
|
26
|
+
rowSelectionKeys?: string[];
|
|
27
|
+
expandedKeys?: string[];
|
|
28
|
+
}) & {
|
|
29
|
+
"onUpdate:pagination"?: ((value: PaginationState | undefined) => any) | undefined;
|
|
30
|
+
"onUpdate:columnVisibility"?: ((value: VisibilityState | undefined) => any) | undefined;
|
|
31
|
+
"onUpdate:columnPinning"?: ((value: ColumnPinningState | undefined) => any) | undefined;
|
|
32
|
+
"onUpdate:columnSizing"?: ((value: ColumnSizingState | undefined) => any) | undefined;
|
|
33
|
+
"onUpdate:rowSelection"?: ((value: RowSelectionState | undefined) => any) | undefined;
|
|
34
|
+
"onUpdate:rowPinning"?: ((value: RowPinningState) => any) | undefined;
|
|
35
|
+
"onUpdate:sorting"?: ((value: SortingState) => any) | undefined;
|
|
36
|
+
"onUpdate:expanded"?: ((value: ExpandedState | undefined) => any) | undefined;
|
|
37
|
+
"onUpdate:columnVisibilityKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
38
|
+
"onUpdate:columnVisibilityExcludeKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
39
|
+
"onUpdate:rowSelectionKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
40
|
+
"onUpdate:expandedKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
41
|
+
}> & (typeof globalThis extends {
|
|
42
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
43
|
+
} ? P : {});
|
|
44
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<DataTableExposed<T>>) => void;
|
|
45
|
+
attrs: any;
|
|
46
|
+
slots: DataTableSlots<T>;
|
|
47
|
+
emit: ((event: "update:pagination", value: PaginationState | undefined) => void) & ((event: "update:columnVisibility", value: VisibilityState | undefined) => void) & ((event: "update:columnPinning", value: ColumnPinningState | undefined) => void) & ((event: "update:columnSizing", value: ColumnSizingState | undefined) => void) & ((event: "update:rowSelection", value: RowSelectionState | undefined) => void) & ((event: "update:rowPinning", value: RowPinningState) => void) & ((event: "update:sorting", value: SortingState) => void) & ((event: "update:expanded", value: ExpandedState | undefined) => void) & ((event: "update:columnVisibilityKeys", value: string[] | undefined) => void) & ((event: "update:columnVisibilityExcludeKeys", value: string[] | undefined) => void) & ((event: "update:rowSelectionKeys", value: string[] | undefined) => void) & ((event: "update:expandedKeys", value: string[] | undefined) => void);
|
|
48
|
+
}>) => import("vue").VNode & {
|
|
49
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
50
|
+
};
|
|
51
|
+
declare const _default: typeof __VLS_export;
|
|
52
|
+
export default _default;
|
|
53
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
54
|
+
[K in keyof T]: T[K];
|
|
55
|
+
} : {
|
|
56
|
+
[K in keyof T as K]: T[K];
|
|
57
|
+
}) & {};
|