@movk/nuxt 1.1.2 → 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 +75 -104
- package/dist/module.d.mts +59 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +136 -56
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -31
- package/dist/runtime/components/AutoForm.vue +114 -148
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -31
- package/dist/runtime/components/ColorChooser.d.vue.ts +20 -17
- package/dist/runtime/components/ColorChooser.vue +305 -31
- package/dist/runtime/components/ColorChooser.vue.d.ts +20 -17
- 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 +15 -22
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +15 -22
- 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 +43 -0
- package/dist/runtime/components/SearchForm.vue +274 -0
- package/dist/runtime/components/SearchForm.vue.d.ts +43 -0
- package/dist/runtime/components/SlideVerify.d.vue.ts +13 -79
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +13 -79
- package/dist/runtime/components/StarRating.d.vue.ts +25 -82
- package/dist/runtime/components/StarRating.vue +128 -99
- package/dist/runtime/components/StarRating.vue.d.ts +25 -82
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +32 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +48 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +32 -0
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCharacterLimit.vue +27 -15
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithClear.d.vue.ts +11 -5
- package/dist/runtime/components/input/WithClear.vue +29 -10
- package/dist/runtime/components/input/WithClear.vue.d.ts +11 -5
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCopy.vue +28 -11
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +33 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue +75 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +33 -0
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +27 -10
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +13 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +37 -28
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +5 -6
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +5 -6
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +2 -1
- package/dist/runtime/composables/useApiFetch.d.ts +23 -15
- package/dist/runtime/composables/useApiFetch.js +21 -28
- package/dist/runtime/composables/useAutoForm.d.ts +14 -98
- package/dist/runtime/composables/useAutoForm.js +55 -161
- package/dist/runtime/composables/useClientApiFetch.d.ts +7 -7
- 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 +143 -42
- package/dist/runtime/composables/useLazyApiFetch.d.ts +19 -0
- package/dist/runtime/composables/useLazyApiFetch.js +4 -0
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +21 -8
- package/dist/runtime/composables/useTheme.js +109 -86
- package/dist/runtime/composables/useUploadWithProgress.d.ts +22 -28
- package/dist/runtime/composables/useUploadWithProgress.js +79 -68
- 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} +37 -48
- 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/domains/auto-form/components/Children.vue +50 -0
- 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/domains/auto-form/components/Layout.vue +89 -0
- 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/domains/auto-form/components/Nested.vue +47 -0
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -2
- package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -25
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/domains/auto-form/controls.js +73 -0
- package/dist/runtime/{utils/field-utils.d.ts → domains/auto-form/fields.d.ts} +7 -21
- package/dist/runtime/{utils/field-utils.js → domains/auto-form/fields.js} +19 -4
- package/dist/runtime/domains/auto-form/metadata.d.ts +22 -0
- package/dist/runtime/domains/auto-form/metadata.js +53 -0
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{internal/useAutoFormProvider.js → domains/auto-form/provider.js} +6 -3
- package/dist/runtime/domains/auto-form/reactive.d.ts +12 -0
- package/dist/runtime/{utils/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/domains/auto-form/schema.d.ts +7 -0
- package/dist/runtime/{utils/schema-introspector.js → domains/auto-form/schema.js} +12 -10
- 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 +28 -171
- package/dist/runtime/plugins/theme.js +72 -70
- 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/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 +19 -17
- 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 +4 -0
- package/dist/runtime/utils/meta.js +14 -0
- 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 +82 -42
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +0 -125
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +0 -105
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -20
- package/dist/runtime/composables/useApiAuth.d.ts +0 -47
- package/dist/runtime/composables/useApiAuth.js +0 -66
- package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
- package/dist/runtime/schemas/api.d.ts +0 -590
- package/dist/runtime/schemas/api.js +0 -228
- package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
- package/dist/runtime/server/api/_movk/session.post.js +0 -18
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -218
- package/dist/runtime/types/auth.d.ts +0 -34
- package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
- package/dist/runtime/types/auto-form.d.ts +0 -548
- package/dist/runtime/types/components.d.ts +0 -43
- package/dist/runtime/types/module.d.ts +0 -39
- package/dist/runtime/utils/api-utils.d.ts +0 -79
- package/dist/runtime/utils/api-utils.js +0 -127
- package/dist/runtime/utils/auto-form.d.ts +0 -3
- package/dist/runtime/utils/auto-form.js +0 -18
- package/dist/runtime/utils/reactive-utils.d.ts +0 -30
- package/dist/runtime/utils/schema-introspector.d.ts +0 -13
- /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-renderer.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/index.js} +0 -0
- /package/dist/runtime/types/{module.js → api/module.js} +0 -0
- /package/dist/runtime/types/{components.js → api/response.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isDataColumn, isGroupColumn } from "../../../types/data-table/index.js";
|
|
2
|
+
import { isString } from "@movk/core";
|
|
3
|
+
import { DENSITY_PRESETS } from "./constants.js";
|
|
4
|
+
import { resolveDataColumn } from "./resolve-data-column.js";
|
|
5
|
+
import { resolveGroupColumn } from "./resolve-group-column.js";
|
|
6
|
+
import {
|
|
7
|
+
resolveActionsColumn,
|
|
8
|
+
resolveExpandColumn,
|
|
9
|
+
resolveIndexColumn,
|
|
10
|
+
resolveRowPinningColumn,
|
|
11
|
+
resolveSelectionColumn
|
|
12
|
+
} from "./resolve-special-columns.js";
|
|
13
|
+
function resolveColumn(col, ctx, inheritedFixed) {
|
|
14
|
+
if (isGroupColumn(col)) return resolveGroupColumn(col, ctx, resolveColumn, inheritedFixed);
|
|
15
|
+
if (isDataColumn(col)) return resolveDataColumn(col, ctx, inheritedFixed);
|
|
16
|
+
if ("type" in col) {
|
|
17
|
+
switch (col.type) {
|
|
18
|
+
case "selection":
|
|
19
|
+
return resolveSelectionColumn(col, ctx);
|
|
20
|
+
case "index":
|
|
21
|
+
return resolveIndexColumn(col, ctx);
|
|
22
|
+
case "expand":
|
|
23
|
+
return resolveExpandColumn(col, ctx);
|
|
24
|
+
case "row-pinning":
|
|
25
|
+
return resolveRowPinningColumn(col, ctx);
|
|
26
|
+
case "actions":
|
|
27
|
+
return resolveActionsColumn(col, ctx);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return col;
|
|
31
|
+
}
|
|
32
|
+
export function resolveColumns(columns, options) {
|
|
33
|
+
let groupCounter = 0;
|
|
34
|
+
const ctx = {
|
|
35
|
+
options,
|
|
36
|
+
density: options.density ? isString(options.density) ? DENSITY_PRESETS[options.density] : options.density : null,
|
|
37
|
+
pinning: { left: [], right: [] },
|
|
38
|
+
visibility: {},
|
|
39
|
+
sizing: {},
|
|
40
|
+
flags: { hasPinning: false, hasResizing: false, hasSort: false, hasExpand: false },
|
|
41
|
+
nextGroupId: () => groupCounter++,
|
|
42
|
+
allColumnIds: []
|
|
43
|
+
};
|
|
44
|
+
const columnDefs = columns.map((col) => resolveColumn(col, ctx));
|
|
45
|
+
return {
|
|
46
|
+
columnDefs,
|
|
47
|
+
initialPinning: ctx.pinning,
|
|
48
|
+
initialVisibility: ctx.visibility,
|
|
49
|
+
initialSizing: ctx.sizing,
|
|
50
|
+
hasColumnPinning: ctx.flags.hasPinning,
|
|
51
|
+
hasColumnResizing: ctx.flags.hasResizing,
|
|
52
|
+
hasColumnSort: ctx.flags.hasSort,
|
|
53
|
+
hasExpandColumn: ctx.flags.hasExpand,
|
|
54
|
+
selectionMode: ctx.selectionMode,
|
|
55
|
+
selectionStrategy: ctx.selectionStrategy,
|
|
56
|
+
subRowSelection: ctx.subRowSelection,
|
|
57
|
+
allColumnIds: ctx.allColumnIds
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ColumnDef, HeaderContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { VNode } from 'vue';
|
|
3
|
+
import type { DataTableDataColumn } from '../../../types/data-table';
|
|
4
|
+
import type { ResolveContext } from './constants';
|
|
5
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
6
|
+
export declare function renderHeaderActions<T>(ctx: HeaderContext<T, unknown>, col: Pick<DataTableDataColumn<T>, 'pinButtonProps' | 'sortButtonProps'>, options: DataTableProps<T>, label: unknown, sortable: boolean, pinable: boolean, resizable: boolean): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function resolveDataColumn<T>(col: DataTableDataColumn<T>, ctx: ResolveContext<T>, inheritedFixed?: 'left' | 'right'): ColumnDef<T, unknown>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { h, isVNode } from "vue";
|
|
2
|
+
import { resolveCallbackValue, resolveColumnFlag, resolveTemplate } from "./utils.js";
|
|
3
|
+
import DataTableCellTooltip from "../components/CellTooltip.vue";
|
|
4
|
+
import { UButton } from "#components";
|
|
5
|
+
import { applyBaseState, buildClassMeta, makeColumnStyle, resolveAlignClass } from "./style.js";
|
|
6
|
+
function buildDataCellRenderer(col, options) {
|
|
7
|
+
const maybeTooltip = col.tooltip !== void 0 ? !!col.tooltip : !!options.tooltip;
|
|
8
|
+
const maybeTruncate = col.truncate !== void 0 ? !!col.truncate : !!options.truncate;
|
|
9
|
+
const needCustomCell = !!(col.cell || maybeTooltip || maybeTruncate || col.emptyCell !== void 0 || options.emptyCell !== false);
|
|
10
|
+
if (!needCustomCell) return void 0;
|
|
11
|
+
return (ctx) => {
|
|
12
|
+
const raw = ctx.getValue();
|
|
13
|
+
const emptyText = col.emptyCell !== void 0 ? col.emptyCell : options.emptyCell;
|
|
14
|
+
if ((raw == null || raw === "") && emptyText !== false) {
|
|
15
|
+
return emptyText != null ? resolveTemplate(emptyText, ctx) : null;
|
|
16
|
+
}
|
|
17
|
+
const formatted = col.cell ? resolveTemplate(col.cell, ctx) : String(raw ?? "");
|
|
18
|
+
if (isVNode(formatted)) return formatted;
|
|
19
|
+
const tooltipRaw = col.tooltip !== void 0 ? col.tooltip : options.tooltip;
|
|
20
|
+
const tooltipVal = resolveCallbackValue(tooltipRaw, ctx);
|
|
21
|
+
if (tooltipVal) {
|
|
22
|
+
return h(DataTableCellTooltip, {
|
|
23
|
+
text: String(formatted ?? ""),
|
|
24
|
+
lines: tooltipVal === true ? void 0 : tooltipVal,
|
|
25
|
+
...options.tooltipProps ?? {},
|
|
26
|
+
...col.tooltipProps ?? {}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const truncateRaw = col.truncate !== void 0 ? col.truncate : options.truncate;
|
|
30
|
+
const truncateVal = resolveCallbackValue(truncateRaw, ctx);
|
|
31
|
+
if (truncateVal) {
|
|
32
|
+
if (truncateVal === true) {
|
|
33
|
+
return h("div", { class: "truncate" }, String(formatted ?? ""));
|
|
34
|
+
}
|
|
35
|
+
return h("div", {
|
|
36
|
+
style: {
|
|
37
|
+
"-webkit-line-clamp": truncateVal,
|
|
38
|
+
"display": "-webkit-box",
|
|
39
|
+
"-webkit-box-orient": "vertical",
|
|
40
|
+
"overflow": "hidden",
|
|
41
|
+
"white-space": "normal",
|
|
42
|
+
"word-break": "break-all"
|
|
43
|
+
}
|
|
44
|
+
}, String(formatted ?? ""));
|
|
45
|
+
}
|
|
46
|
+
return formatted;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function buildSortAction(col, options) {
|
|
50
|
+
return {
|
|
51
|
+
id: "sort",
|
|
52
|
+
position: "trailing",
|
|
53
|
+
render: (ctx) => {
|
|
54
|
+
const isSorted = ctx.column.getIsSorted();
|
|
55
|
+
const sortCtx = { isSorted, headerContext: ctx };
|
|
56
|
+
const icon = isSorted === "asc" ? "i-lucide-arrow-up-narrow-wide" : isSorted === "desc" ? "i-lucide-arrow-down-wide-narrow" : "i-lucide-arrow-up-down";
|
|
57
|
+
return h(UButton, {
|
|
58
|
+
size: "xs",
|
|
59
|
+
variant: "ghost",
|
|
60
|
+
color: "neutral",
|
|
61
|
+
class: isSorted ? "opacity-100" : "opacity-60 group-hover:opacity-100",
|
|
62
|
+
icon,
|
|
63
|
+
onClick: ctx.column.getToggleSortingHandler(),
|
|
64
|
+
...resolveCallbackValue(options.sortButtonProps ?? {}, sortCtx),
|
|
65
|
+
...resolveCallbackValue(col.sortButtonProps ?? {}, sortCtx)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function buildPinAction(col, options) {
|
|
71
|
+
return {
|
|
72
|
+
id: "pin",
|
|
73
|
+
position: "leading",
|
|
74
|
+
render: (ctx) => {
|
|
75
|
+
const pinned = ctx.column.getIsPinned();
|
|
76
|
+
const pinCtx = { pinned, headerContext: ctx };
|
|
77
|
+
return h(UButton, {
|
|
78
|
+
"size": "xs",
|
|
79
|
+
"variant": "ghost",
|
|
80
|
+
"color": pinned ? "primary" : "neutral",
|
|
81
|
+
"class": pinned ? "opacity-100" : "opacity-60 group-hover:opacity-100",
|
|
82
|
+
"icon": pinned ? "i-lucide-pin-off" : "i-lucide-pin",
|
|
83
|
+
"aria-label": pinned ? "Cancel column pin" : "Pin column",
|
|
84
|
+
"onClick": (event) => {
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
if (pinned === "left") {
|
|
87
|
+
ctx.column.pin("right");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (pinned === "right") {
|
|
91
|
+
ctx.column.pin(false);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const th = event.target.closest("th");
|
|
95
|
+
if (th) {
|
|
96
|
+
const w = Math.ceil(th.getBoundingClientRect().width);
|
|
97
|
+
if (w > 0) ctx.table.setColumnSizing((prev) => ({ ...prev, [ctx.column.id]: w }));
|
|
98
|
+
}
|
|
99
|
+
ctx.column.pin("left");
|
|
100
|
+
},
|
|
101
|
+
...resolveCallbackValue(options.pinButtonProps ?? {}, pinCtx),
|
|
102
|
+
...resolveCallbackValue(col.pinButtonProps ?? {}, pinCtx)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export function renderHeaderActions(ctx, col, options, label, sortable, pinable, resizable) {
|
|
108
|
+
const actions = [];
|
|
109
|
+
if (pinable) actions.push(buildPinAction(col, options));
|
|
110
|
+
if (sortable) actions.push(buildSortAction(col, options));
|
|
111
|
+
const leading = actions.filter((a) => a.position === "leading").map((a) => a.render(ctx));
|
|
112
|
+
const trailing = actions.filter((a) => a.position === "trailing").map((a) => a.render(ctx));
|
|
113
|
+
const resizeHandle = resizable ? h("div", {
|
|
114
|
+
class: "absolute top-0 bottom-0 right-0 w-4 -mr-2 cursor-col-resize select-none touch-none flex items-center justify-center group/resize",
|
|
115
|
+
onMousedown: ctx.header.getResizeHandler(),
|
|
116
|
+
onTouchstart: ctx.header.getResizeHandler(),
|
|
117
|
+
onClick: (e) => e.stopPropagation()
|
|
118
|
+
}, [
|
|
119
|
+
h("div", {
|
|
120
|
+
class: [
|
|
121
|
+
"h-full transition-colors",
|
|
122
|
+
ctx.column.getIsResizing() ? "w-0.5 bg-primary" : "w-px opacity-50 group-hover:opacity-100 bg-(--ui-border-accented) group-hover/resize:w-0.5 group-hover/resize:bg-primary"
|
|
123
|
+
].join(" ")
|
|
124
|
+
})
|
|
125
|
+
]) : null;
|
|
126
|
+
const labelNode = isVNode(label) ? label : h("span", { class: "truncate" }, String(label ?? ""));
|
|
127
|
+
return h("div", { class: "flex items-center gap-1 relative group" }, [
|
|
128
|
+
...leading,
|
|
129
|
+
labelNode,
|
|
130
|
+
...trailing,
|
|
131
|
+
resizeHandle
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
export function resolveDataColumn(col, ctx, inheritedFixed) {
|
|
135
|
+
const { options, density } = ctx;
|
|
136
|
+
const id = col.accessorKey;
|
|
137
|
+
const effectiveSortable = resolveColumnFlag(col.sortable, options.sortable, col);
|
|
138
|
+
const effectivePinable = resolveColumnFlag(col.pinable, options.pinable, col);
|
|
139
|
+
const effectiveResizable = resolveColumnFlag(col.resizable, options.resizable, col);
|
|
140
|
+
ctx.flags.hasPinning ||= effectivePinable;
|
|
141
|
+
ctx.flags.hasResizing ||= effectiveResizable;
|
|
142
|
+
ctx.flags.hasSort ||= effectiveSortable;
|
|
143
|
+
const resolvedSize = applyBaseState(id, col.fixed ?? inheritedFixed, col.size, ctx);
|
|
144
|
+
if (col.visibility === false) ctx.visibility[id] = false;
|
|
145
|
+
ctx.allColumnIds.push(id);
|
|
146
|
+
const cellRenderer = buildDataCellRenderer(col, options);
|
|
147
|
+
const def = {
|
|
148
|
+
accessorKey: id,
|
|
149
|
+
header: effectiveSortable || effectivePinable || effectiveResizable ? (hctx) => renderHeaderActions(hctx, col, options, col.header ?? id, effectiveSortable, effectivePinable, effectiveResizable) : col.header ?? id,
|
|
150
|
+
...col.minSize != null && { minSize: col.minSize },
|
|
151
|
+
...col.maxSize != null && { maxSize: col.maxSize },
|
|
152
|
+
...resolvedSize != null && { size: resolvedSize },
|
|
153
|
+
enableSorting: effectiveSortable,
|
|
154
|
+
enablePinning: effectivePinable,
|
|
155
|
+
enableResizing: effectiveResizable,
|
|
156
|
+
...cellRenderer && { cell: cellRenderer },
|
|
157
|
+
meta: {
|
|
158
|
+
class: buildClassMeta(density, resolveAlignClass(col.align), effectiveResizable),
|
|
159
|
+
style: makeColumnStyle(col.align)
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
if (col._raw) Object.assign(def, col._raw);
|
|
163
|
+
return def;
|
|
164
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableColumn, DataTableGroupColumn } from '../../../types/data-table';
|
|
3
|
+
import type { ResolveContext } from './constants';
|
|
4
|
+
export declare function resolveGroupColumn<T>(col: DataTableGroupColumn<T>, ctx: ResolveContext<T>, resolveChild: (col: DataTableColumn<T>, ctx: ResolveContext<T>, inheritedFixed?: 'left' | 'right') => ColumnDef<T, unknown>, inheritedFixed?: 'left' | 'right'): ColumnDef<T, unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isString } from "@movk/core";
|
|
2
|
+
import { resolvePresetSize } from "./utils.js";
|
|
3
|
+
import { groupHeaderStyle, resolveAlignClass } from "./style.js";
|
|
4
|
+
export function resolveGroupColumn(col, ctx, resolveChild, inheritedFixed) {
|
|
5
|
+
const effectiveFixed = col.fixed ?? inheritedFixed;
|
|
6
|
+
const resolvedSize = col.size != null ? isString(col.size) ? resolvePresetSize(col.size) : col.size : void 0;
|
|
7
|
+
return {
|
|
8
|
+
id: `group-${ctx.nextGroupId()}-${col.header ?? "unnamed"}`,
|
|
9
|
+
header: col.header,
|
|
10
|
+
...resolvedSize != null && { size: resolvedSize },
|
|
11
|
+
...col.minSize != null && { minSize: col.minSize },
|
|
12
|
+
...col.maxSize != null && { maxSize: col.maxSize },
|
|
13
|
+
columns: col.children?.map((child) => resolveChild(child, ctx, effectiveFixed)),
|
|
14
|
+
meta: {
|
|
15
|
+
class: { th: resolveAlignClass(col.align) || void 0 },
|
|
16
|
+
style: { th: (header) => groupHeaderStyle(header, effectiveFixed) }
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableActionsColumn, DataTableExpandColumn, DataTableIndexColumn, DataTableRowPinningColumn, DataTableSelectionColumn } from '../../../types/data-table';
|
|
3
|
+
import type { ResolveContext } from './constants';
|
|
4
|
+
export declare function resolveSelectionColumn<T>(col: DataTableSelectionColumn<T>, ctx: ResolveContext<T>): ColumnDef<T, unknown>;
|
|
5
|
+
export declare function resolveIndexColumn<T>(col: DataTableIndexColumn<T>, ctx: ResolveContext<T>): ColumnDef<T, unknown>;
|
|
6
|
+
export declare function resolveExpandColumn<T>(col: DataTableExpandColumn<T>, ctx: ResolveContext<T>): ColumnDef<T, unknown>;
|
|
7
|
+
export declare function resolveRowPinningColumn<T>(col: DataTableRowPinningColumn<T>, ctx: ResolveContext<T>): ColumnDef<T, unknown>;
|
|
8
|
+
export declare function resolveActionsColumn<T>(col: DataTableActionsColumn<T>, ctx: ResolveContext<T>): ColumnDef<T, unknown>;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
import { isFunction } from "@movk/core";
|
|
3
|
+
import { SPECIAL_COLUMN_DEFAULTS } from "./constants.js";
|
|
4
|
+
import { resolveCallbackValue } from "./utils.js";
|
|
5
|
+
import DataTableActionsCell from "../components/ActionsCell.vue";
|
|
6
|
+
import { UButton, UCheckbox } from "#components";
|
|
7
|
+
import { applyBaseState, buildClassMeta, makeColumnStyle, resolveAlignClass } from "./style.js";
|
|
8
|
+
import { renderHeaderActions } from "./resolve-data-column.js";
|
|
9
|
+
function computeLeafAggregate(row) {
|
|
10
|
+
let total = 0;
|
|
11
|
+
let selected = 0;
|
|
12
|
+
const walk = (rows) => {
|
|
13
|
+
for (const r of rows) {
|
|
14
|
+
if (r.subRows.length === 0) {
|
|
15
|
+
total++;
|
|
16
|
+
if (r.getIsSelected()) selected++;
|
|
17
|
+
} else {
|
|
18
|
+
walk(r.subRows);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
walk(row.subRows);
|
|
23
|
+
if (total === 0) return { all: false, some: false };
|
|
24
|
+
return { all: selected === total, some: selected > 0 && selected < total };
|
|
25
|
+
}
|
|
26
|
+
function buildSpecialColumnDef(col, type, ctx, render) {
|
|
27
|
+
const defaults = SPECIAL_COLUMN_DEFAULTS[type];
|
|
28
|
+
const { options, density } = ctx;
|
|
29
|
+
const { id } = defaults;
|
|
30
|
+
const resolvedSize = applyBaseState(
|
|
31
|
+
id,
|
|
32
|
+
col.fixed ?? defaults.fixed,
|
|
33
|
+
col.size ?? defaults.size,
|
|
34
|
+
ctx
|
|
35
|
+
);
|
|
36
|
+
if (col.visibility === false) ctx.visibility[id] = false;
|
|
37
|
+
ctx.allColumnIds.push(id);
|
|
38
|
+
const effectivePinable = col.pinable ?? options.pinable === true;
|
|
39
|
+
const effectiveResizable = col.resizable ?? options.resizable === true;
|
|
40
|
+
ctx.flags.hasPinning ||= effectivePinable;
|
|
41
|
+
ctx.flags.hasResizing ||= effectiveResizable;
|
|
42
|
+
const effectiveAlign = col.align ?? defaults.align;
|
|
43
|
+
const alignClass = resolveAlignClass(effectiveAlign);
|
|
44
|
+
const resolvedHeader = effectivePinable || effectiveResizable ? (hctx) => {
|
|
45
|
+
const label = isFunction(render.header) ? render.header(hctx) : render.header ?? "";
|
|
46
|
+
return renderHeaderActions(hctx, col, options, label, false, effectivePinable, effectiveResizable);
|
|
47
|
+
} : render.header;
|
|
48
|
+
const classMeta = buildClassMeta(density, alignClass, effectiveResizable, defaults.tdClass);
|
|
49
|
+
const checkboxClass = type === "selection" ? {
|
|
50
|
+
td: [classMeta?.td, "[&:has([role=checkbox])]:px-0"].filter(Boolean).join(" "),
|
|
51
|
+
th: [classMeta?.th, "[&:has([role=checkbox])]:px-0"].filter(Boolean).join(" ")
|
|
52
|
+
} : classMeta;
|
|
53
|
+
const def = {
|
|
54
|
+
id,
|
|
55
|
+
header: resolvedHeader,
|
|
56
|
+
...resolvedSize != null && { size: resolvedSize },
|
|
57
|
+
...col.minSize != null && { minSize: col.minSize },
|
|
58
|
+
...col.maxSize != null && { maxSize: col.maxSize },
|
|
59
|
+
enableSorting: false,
|
|
60
|
+
enableResizing: effectiveResizable,
|
|
61
|
+
enablePinning: effectivePinable,
|
|
62
|
+
cell: render.cell,
|
|
63
|
+
meta: {
|
|
64
|
+
class: checkboxClass,
|
|
65
|
+
style: makeColumnStyle(effectiveAlign)
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
if (col._raw) Object.assign(def, col._raw);
|
|
69
|
+
return def;
|
|
70
|
+
}
|
|
71
|
+
export function resolveSelectionColumn(col, ctx) {
|
|
72
|
+
ctx.selectionMode = col.mode ?? "multiple";
|
|
73
|
+
const isTree = !!ctx.options.childrenKey;
|
|
74
|
+
const strategy = col.strategy ?? "cascade";
|
|
75
|
+
ctx.selectionStrategy = strategy;
|
|
76
|
+
if (isTree && (strategy !== "cascade" || ctx.selectionMode === "single")) ctx.subRowSelection = false;
|
|
77
|
+
const isLeafStrategy = isTree && strategy === "leaf";
|
|
78
|
+
return buildSpecialColumnDef(col, "selection", ctx, {
|
|
79
|
+
header: ctx.selectionMode === "multiple" ? (hctx) => {
|
|
80
|
+
const isIndeterminate = hctx.table.getIsSomePageRowsSelected();
|
|
81
|
+
const isAllSelected = hctx.table.getIsAllPageRowsSelected();
|
|
82
|
+
const cbCtx = {
|
|
83
|
+
scope: "header",
|
|
84
|
+
headerContext: hctx,
|
|
85
|
+
isAllSelected,
|
|
86
|
+
isIndeterminate
|
|
87
|
+
};
|
|
88
|
+
return h(UCheckbox, {
|
|
89
|
+
"aria-label": "Select all rows",
|
|
90
|
+
"class": "inline-flex",
|
|
91
|
+
"modelValue": isIndeterminate ? "indeterminate" : isAllSelected,
|
|
92
|
+
"onUpdate:modelValue": (value) => hctx.table.toggleAllPageRowsSelected(!!value),
|
|
93
|
+
...resolveCallbackValue(col.checkboxProps ?? {}, cbCtx)
|
|
94
|
+
});
|
|
95
|
+
} : col.header ?? SPECIAL_COLUMN_DEFAULTS.selection.header,
|
|
96
|
+
cell: (cellCtx) => {
|
|
97
|
+
if (isLeafStrategy && cellCtx.row.subRows.length > 0) {
|
|
98
|
+
const { all, some } = computeLeafAggregate(cellCtx.row);
|
|
99
|
+
const cbCtx2 = {
|
|
100
|
+
scope: "cell",
|
|
101
|
+
cellContext: cellCtx,
|
|
102
|
+
isSelected: all,
|
|
103
|
+
isIndeterminate: some,
|
|
104
|
+
isLeafAggregate: true
|
|
105
|
+
};
|
|
106
|
+
return h(UCheckbox, {
|
|
107
|
+
"aria-label": "Select parent row",
|
|
108
|
+
"class": "inline-flex",
|
|
109
|
+
"disabled": true,
|
|
110
|
+
"modelValue": all ? true : some ? "indeterminate" : false,
|
|
111
|
+
...resolveCallbackValue(col.checkboxProps ?? {}, cbCtx2)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const isCascadeParent = isTree && strategy === "cascade" && cellCtx.row.subRows.length > 0;
|
|
115
|
+
const isSelected = isCascadeParent ? cellCtx.row.getIsSelected() || cellCtx.row.getIsAllSubRowsSelected() : cellCtx.row.getIsSelected();
|
|
116
|
+
const isIndeterminate = isCascadeParent ? !isSelected && cellCtx.row.getIsSomeSelected() : cellCtx.row.getIsSomeSelected();
|
|
117
|
+
const cbCtx = {
|
|
118
|
+
scope: "cell",
|
|
119
|
+
cellContext: cellCtx,
|
|
120
|
+
isSelected,
|
|
121
|
+
isIndeterminate,
|
|
122
|
+
isLeafAggregate: false
|
|
123
|
+
};
|
|
124
|
+
return h(UCheckbox, {
|
|
125
|
+
"aria-label": "Select row",
|
|
126
|
+
"class": "inline-flex",
|
|
127
|
+
"modelValue": isSelected ? true : isIndeterminate ? "indeterminate" : false,
|
|
128
|
+
"onUpdate:modelValue": (value) => cellCtx.row.toggleSelected(!!value),
|
|
129
|
+
...resolveCallbackValue(col.checkboxProps ?? {}, cbCtx)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export function resolveIndexColumn(col, ctx) {
|
|
135
|
+
return buildSpecialColumnDef(col, "index", ctx, {
|
|
136
|
+
header: col.header ?? SPECIAL_COLUMN_DEFAULTS.index.header,
|
|
137
|
+
cell: (cellCtx) => cellCtx.row.index + 1
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export function resolveExpandColumn(col, ctx) {
|
|
141
|
+
ctx.flags.hasExpand = true;
|
|
142
|
+
const isTreeMode = ctx.options.childrenKey != null;
|
|
143
|
+
const showToggleAll = col.toggleAll !== false;
|
|
144
|
+
return buildSpecialColumnDef(col, "expand", ctx, {
|
|
145
|
+
header: showToggleAll ? (hctx) => {
|
|
146
|
+
const isAllExpanded = hctx.table.getIsAllRowsExpanded();
|
|
147
|
+
const isSomeExpanded = hctx.table.getIsSomeRowsExpanded();
|
|
148
|
+
const toggleCtx = {
|
|
149
|
+
headerContext: hctx,
|
|
150
|
+
isAllExpanded,
|
|
151
|
+
isSomeExpanded
|
|
152
|
+
};
|
|
153
|
+
return h(UButton, {
|
|
154
|
+
"variant": "outline",
|
|
155
|
+
"size": "xs",
|
|
156
|
+
"color": "neutral",
|
|
157
|
+
"aria-label": isAllExpanded ? "Collapse all rows" : "Expand all rows",
|
|
158
|
+
"icon": isAllExpanded ? "i-lucide-minus" : "i-lucide-plus",
|
|
159
|
+
"ui": {
|
|
160
|
+
base: "p-0.5 rounded-sm",
|
|
161
|
+
leadingIcon: "size-4"
|
|
162
|
+
},
|
|
163
|
+
"onClick": (event) => {
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
hctx.table.toggleAllRowsExpanded();
|
|
166
|
+
},
|
|
167
|
+
...resolveCallbackValue(col.toggleAllButtonProps ?? {}, toggleCtx)
|
|
168
|
+
});
|
|
169
|
+
} : void 0,
|
|
170
|
+
cell: (cellCtx) => {
|
|
171
|
+
if (isTreeMode && !cellCtx.row.getCanExpand()) return null;
|
|
172
|
+
const depth = cellCtx.row.depth;
|
|
173
|
+
const indentSize = ctx.options.indentSize ?? "1rem";
|
|
174
|
+
const marginLeft = isTreeMode ? isFunction(indentSize) ? indentSize(cellCtx) : typeof indentSize === "number" ? `${depth * indentSize}px` : depth > 0 ? `calc(${depth} * ${indentSize})` : "0px" : "0px";
|
|
175
|
+
const isExpanded = cellCtx.row.getIsExpanded();
|
|
176
|
+
const expandCtx = {
|
|
177
|
+
cellContext: cellCtx,
|
|
178
|
+
isExpanded,
|
|
179
|
+
depth,
|
|
180
|
+
canExpand: true
|
|
181
|
+
};
|
|
182
|
+
return h(UButton, {
|
|
183
|
+
variant: "outline",
|
|
184
|
+
size: "xs",
|
|
185
|
+
color: "neutral",
|
|
186
|
+
icon: isExpanded ? "i-lucide-minus" : "i-lucide-plus",
|
|
187
|
+
ui: {
|
|
188
|
+
base: "p-0.5 rounded-sm",
|
|
189
|
+
leadingIcon: "size-4"
|
|
190
|
+
},
|
|
191
|
+
style: { marginLeft },
|
|
192
|
+
onClick: (event) => {
|
|
193
|
+
event.stopPropagation();
|
|
194
|
+
cellCtx.row.toggleExpanded();
|
|
195
|
+
},
|
|
196
|
+
...resolveCallbackValue(col.buttonProps ?? {}, expandCtx)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export function resolveRowPinningColumn(col, ctx) {
|
|
202
|
+
return buildSpecialColumnDef(col, "row-pinning", ctx, {
|
|
203
|
+
header: col.header ?? SPECIAL_COLUMN_DEFAULTS["row-pinning"].header,
|
|
204
|
+
cell: (cellCtx) => {
|
|
205
|
+
const pinned = cellCtx.row.getIsPinned();
|
|
206
|
+
const position = col.position ?? "top";
|
|
207
|
+
const rpCtx = { cellContext: cellCtx, pinned, position };
|
|
208
|
+
return h(UButton, {
|
|
209
|
+
"variant": "ghost",
|
|
210
|
+
"size": "xs",
|
|
211
|
+
"color": pinned ? "primary" : "neutral",
|
|
212
|
+
"icon": "i-lucide-star",
|
|
213
|
+
"aria-label": pinned ? "Cancel row pin" : "Pin row",
|
|
214
|
+
"onClick": (event) => {
|
|
215
|
+
event.stopPropagation();
|
|
216
|
+
if (pinned) {
|
|
217
|
+
cellCtx.row.pin(false);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
cellCtx.row.pin(position);
|
|
221
|
+
},
|
|
222
|
+
...resolveCallbackValue(col.buttonProps ?? {}, rpCtx)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export function resolveActionsColumn(col, ctx) {
|
|
228
|
+
return buildSpecialColumnDef(col, "actions", ctx, {
|
|
229
|
+
header: col.header ?? SPECIAL_COLUMN_DEFAULTS.actions.header,
|
|
230
|
+
cell: (cellCtx) => h(DataTableActionsCell, { col, cellCtx, options: ctx.options })
|
|
231
|
+
});
|
|
232
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Cell, ColumnMeta, Header } from '@tanstack/vue-table';
|
|
2
|
+
import type { ResolveContext } from './constants';
|
|
3
|
+
export declare function resolveColumnSize<T>(ctx: Header<T, unknown> | Cell<T, unknown>): Record<string, string>;
|
|
4
|
+
export declare function makeColumnStyle<T>(align?: 'left' | 'center' | 'right'): {
|
|
5
|
+
th: (ctx: Header<T, unknown>) => Record<string, string>;
|
|
6
|
+
td: (ctx: Cell<T, unknown>) => Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare function applyBaseState(id: string, fixed: 'left' | 'right' | undefined, size: number | string | undefined, ctx: ResolveContext<unknown>): number | undefined;
|
|
9
|
+
export declare function resolveAlignClass(align?: 'left' | 'center' | 'right'): string;
|
|
10
|
+
export declare function buildClassMeta<T, V>(density: ColumnMeta<T, unknown>['class'] | null, align?: string, resizable?: boolean, tdClass?: string): ColumnMeta<T, V>['class'];
|
|
11
|
+
export declare function groupHeaderStyle<T>(header: Header<T, unknown>, fixed?: 'left' | 'right'): Record<string, string>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isString } from "@movk/core";
|
|
2
|
+
import { resolvePresetSize } from "./utils.js";
|
|
3
|
+
export function resolveColumnSize(ctx) {
|
|
4
|
+
const { columnDef } = ctx.column;
|
|
5
|
+
const table = ctx.getContext().table;
|
|
6
|
+
const isPinned = ctx.column.getIsPinned();
|
|
7
|
+
const hasMeasuredSize = isPinned && ctx.column.id in table.getState().columnSizing;
|
|
8
|
+
if (hasMeasuredSize || columnDef.size != table._getDefaultColumnDef().size || columnDef.enableResizing === true) {
|
|
9
|
+
const w = `${ctx.column.getSize()}px`;
|
|
10
|
+
return { width: w, minWidth: w, maxWidth: w };
|
|
11
|
+
}
|
|
12
|
+
const style = {};
|
|
13
|
+
if (columnDef.minSize != null) style.minWidth = `${columnDef.minSize}px`;
|
|
14
|
+
if (columnDef.maxSize != null) style.maxWidth = `${columnDef.maxSize}px`;
|
|
15
|
+
return style;
|
|
16
|
+
}
|
|
17
|
+
export function makeColumnStyle(align) {
|
|
18
|
+
const resolver = (ctx) => align ? { ...resolveColumnSize(ctx), textAlign: align } : resolveColumnSize(ctx);
|
|
19
|
+
return { th: resolver, td: resolver };
|
|
20
|
+
}
|
|
21
|
+
export function applyBaseState(id, fixed, size, ctx) {
|
|
22
|
+
if (fixed) {
|
|
23
|
+
ctx.pinning[fixed].push(id);
|
|
24
|
+
}
|
|
25
|
+
const resolvedSize = size != null ? isString(size) ? resolvePresetSize(size) : size : void 0;
|
|
26
|
+
if (resolvedSize != null) {
|
|
27
|
+
ctx.sizing[id] = resolvedSize;
|
|
28
|
+
}
|
|
29
|
+
return resolvedSize;
|
|
30
|
+
}
|
|
31
|
+
export function resolveAlignClass(align) {
|
|
32
|
+
switch (align) {
|
|
33
|
+
case "center":
|
|
34
|
+
return "text-center";
|
|
35
|
+
case "right":
|
|
36
|
+
return "text-right";
|
|
37
|
+
default:
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function buildClassMeta(density, align, resizable, tdClass) {
|
|
42
|
+
return {
|
|
43
|
+
td: [align, density?.td, tdClass].filter(Boolean).join(" ") || void 0,
|
|
44
|
+
th: [resizable ? "relative" : "", align, density?.th].filter(Boolean).join(" ") || void 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getFirstLeafHeader(header) {
|
|
48
|
+
return header.subHeaders.length ? getFirstLeafHeader(header.subHeaders[0]) : header;
|
|
49
|
+
}
|
|
50
|
+
function getLastLeafHeader(header) {
|
|
51
|
+
return header.subHeaders.length ? getLastLeafHeader(header.subHeaders[header.subHeaders.length - 1]) : header;
|
|
52
|
+
}
|
|
53
|
+
export function groupHeaderStyle(header, fixed) {
|
|
54
|
+
const w = `${header.getSize()}px`;
|
|
55
|
+
const style = { width: w, minWidth: w };
|
|
56
|
+
const pinned = fixed ?? header.column.getIsPinned();
|
|
57
|
+
if (pinned === "left") {
|
|
58
|
+
const first = getFirstLeafHeader(header);
|
|
59
|
+
style.position = "sticky";
|
|
60
|
+
style.left = `${first.column.getStart("left")}px`;
|
|
61
|
+
} else if (pinned === "right") {
|
|
62
|
+
const last = getLastLeafHeader(header);
|
|
63
|
+
style.position = "sticky";
|
|
64
|
+
style.right = `${last.column.getAfter("right")}px`;
|
|
65
|
+
}
|
|
66
|
+
return style;
|
|
67
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColumnDefTemplate } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableDataColumn, DataTableSizePreset } from '../../../types/data-table';
|
|
3
|
+
export declare function resolveCallbackValue<V, A>(valueOrFn: V | ((arg: A) => V), arg: A): V;
|
|
4
|
+
export declare function resolveColumnFlag<T>(colValue: boolean | undefined, globalValue: boolean | ((col: DataTableDataColumn<T>) => boolean) | undefined, col: DataTableDataColumn<T>, fallback?: boolean): boolean;
|
|
5
|
+
export declare function resolveTemplate<TProps extends object>(template: ColumnDefTemplate<TProps>, props: TProps): unknown;
|
|
6
|
+
export declare function resolvePresetSize(size: number | DataTableSizePreset): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isFunction, isString } from "@movk/core";
|
|
2
|
+
import { SIZE_PRESET_MAP } from "./constants.js";
|
|
3
|
+
export function resolveCallbackValue(valueOrFn, arg) {
|
|
4
|
+
return isFunction(valueOrFn) ? valueOrFn(arg) : valueOrFn;
|
|
5
|
+
}
|
|
6
|
+
export function resolveColumnFlag(colValue, globalValue, col, fallback = false) {
|
|
7
|
+
if (colValue !== void 0) return colValue;
|
|
8
|
+
if (typeof globalValue === "function") return globalValue(col);
|
|
9
|
+
return globalValue ?? fallback;
|
|
10
|
+
}
|
|
11
|
+
export function resolveTemplate(template, props) {
|
|
12
|
+
return isFunction(template) ? template(props) : template;
|
|
13
|
+
}
|
|
14
|
+
export function resolvePresetSize(size) {
|
|
15
|
+
return isString(size) ? SIZE_PRESET_MAP[size] : size;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ButtonProps } from '@nuxt/ui';
|
|
2
|
+
import type { DataTableAction, DataTableActionButtonContext, DataTableDynamic } from '../../../types/data-table';
|
|
3
|
+
interface DataTableRendererActionConfirmProps {
|
|
4
|
+
action: DataTableAction<unknown>;
|
|
5
|
+
ctx: DataTableActionButtonContext<unknown>;
|
|
6
|
+
globalButtonProps?: DataTableDynamic<ButtonProps, DataTableActionButtonContext<unknown>>;
|
|
7
|
+
}
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<DataTableRendererActionConfirmProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DataTableRendererActionConfirmProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { resolveCallbackValue } from "../columns/utils";
|
|
4
|
+
import { useMessageBox } from "../../../composables/useMessageBox";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
action: { type: Object, required: true },
|
|
7
|
+
ctx: { type: Object, required: true },
|
|
8
|
+
globalButtonProps: { type: [Object, Function], required: false }
|
|
9
|
+
});
|
|
10
|
+
const { confirm } = useMessageBox();
|
|
11
|
+
const loading = ref(false);
|
|
12
|
+
const resolvedButtonProps = computed(() => ({
|
|
13
|
+
variant: "ghost",
|
|
14
|
+
size: "xs",
|
|
15
|
+
color: "neutral",
|
|
16
|
+
...resolveCallbackValue(props.globalButtonProps ?? {}, props.ctx),
|
|
17
|
+
...resolveCallbackValue(props.action.buttonProps ?? {}, props.ctx)
|
|
18
|
+
}));
|
|
19
|
+
const disabled = computed(
|
|
20
|
+
() => loading.value || resolveCallbackValue(props.action.disabled ?? false, props.ctx)
|
|
21
|
+
);
|
|
22
|
+
async function handleClick(event) {
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
if (props.action.confirm) {
|
|
25
|
+
const ok = await confirm(resolveCallbackValue(props.action.confirmProps ?? {}, props.ctx));
|
|
26
|
+
if (!ok) return;
|
|
27
|
+
}
|
|
28
|
+
loading.value = true;
|
|
29
|
+
try {
|
|
30
|
+
await props.action.onClick(props.ctx);
|
|
31
|
+
} finally {
|
|
32
|
+
loading.value = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<UButton v-bind="resolvedButtonProps" :loading="loading" :disabled="disabled" @click="handleClick" />
|
|
39
|
+
</template>
|