@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,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,11 @@
|
|
|
1
|
+
import type { CellContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableActionsColumn } from '../../../types/data-table';
|
|
3
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
4
|
+
interface DataTableRendererActionsCellProps {
|
|
5
|
+
col: DataTableActionsColumn<unknown>;
|
|
6
|
+
cellCtx: CellContext<unknown, unknown>;
|
|
7
|
+
options: DataTableProps<any>;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<DataTableRendererActionsCellProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DataTableRendererActionsCellProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import { isFunction } from "@movk/core";
|
|
4
|
+
import { resolveCallbackValue } from "../columns/utils";
|
|
5
|
+
import { useMessageBox } from "../../../composables/useMessageBox";
|
|
6
|
+
import { UButton, UDropdownMenu } from "#components";
|
|
7
|
+
import DataTableActionConfirm from "./ActionConfirm.vue";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
col: { type: Object, required: true },
|
|
10
|
+
cellCtx: { type: Object, required: true },
|
|
11
|
+
options: { type: Object, required: true }
|
|
12
|
+
});
|
|
13
|
+
const { confirm } = useMessageBox();
|
|
14
|
+
function buildActionCtx(action) {
|
|
15
|
+
return {
|
|
16
|
+
cellContext: props.cellCtx,
|
|
17
|
+
row: props.cellCtx.row.original,
|
|
18
|
+
index: props.cellCtx.row.index,
|
|
19
|
+
action
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function renderInline(action, idx) {
|
|
23
|
+
const actionCtx = buildActionCtx(action);
|
|
24
|
+
return h(DataTableActionConfirm, {
|
|
25
|
+
key: action.key ?? `${idx}`,
|
|
26
|
+
action,
|
|
27
|
+
ctx: actionCtx,
|
|
28
|
+
globalButtonProps: props.options.actionButtonProps
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function renderOverflow(actions) {
|
|
32
|
+
const groups = [];
|
|
33
|
+
let currentGroup = [];
|
|
34
|
+
for (const action of actions) {
|
|
35
|
+
if (action.divider && currentGroup.length > 0) {
|
|
36
|
+
groups.push(currentGroup);
|
|
37
|
+
currentGroup = [];
|
|
38
|
+
}
|
|
39
|
+
const actionCtx = buildActionCtx(action);
|
|
40
|
+
const resolved = resolveCallbackValue(action.buttonProps ?? {}, actionCtx);
|
|
41
|
+
const isDisabled = resolveCallbackValue(action.disabled ?? false, actionCtx);
|
|
42
|
+
currentGroup.push({
|
|
43
|
+
label: resolved.label ?? "",
|
|
44
|
+
icon: resolved.icon,
|
|
45
|
+
color: resolved.color,
|
|
46
|
+
disabled: isDisabled,
|
|
47
|
+
onSelect: async (e) => {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
if (action.confirm) {
|
|
50
|
+
const ok = await confirm(resolveCallbackValue(action.confirmProps ?? {}, actionCtx));
|
|
51
|
+
if (!ok) return;
|
|
52
|
+
}
|
|
53
|
+
await action.onClick(actionCtx);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
58
|
+
const triggerProps = {
|
|
59
|
+
variant: "ghost",
|
|
60
|
+
size: "xs",
|
|
61
|
+
color: "neutral",
|
|
62
|
+
icon: "i-lucide-ellipsis",
|
|
63
|
+
...resolveCallbackValue(props.options.actionsOverflowTrigger ?? {}, props.cellCtx),
|
|
64
|
+
...resolveCallbackValue(props.col.overflowTrigger ?? {}, props.cellCtx)
|
|
65
|
+
};
|
|
66
|
+
const dropdownProps = resolveCallbackValue(props.col.dropdownProps ?? {}, props.cellCtx);
|
|
67
|
+
return h(UDropdownMenu, { ...dropdownProps, items: groups }, {
|
|
68
|
+
default: () => h(UButton, { ...triggerProps, onClick: (e) => e.stopPropagation() })
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function render() {
|
|
72
|
+
const actionList = isFunction(props.col.actions) ? props.col.actions(props.cellCtx) : props.col.actions;
|
|
73
|
+
const visible = actionList.filter(
|
|
74
|
+
(a) => resolveCallbackValue(a.visibility ?? true, buildActionCtx(a))
|
|
75
|
+
);
|
|
76
|
+
if (visible.length === 0) return null;
|
|
77
|
+
const maxInline = props.col.maxInline ?? props.options.actionsMaxInline ?? 3;
|
|
78
|
+
const shouldOverflow = visible.length > maxInline;
|
|
79
|
+
const inline = shouldOverflow ? visible.slice(0, maxInline - 1) : visible;
|
|
80
|
+
const overflow = shouldOverflow ? visible.slice(maxInline - 1) : [];
|
|
81
|
+
const wrapperClass = isFunction(props.col.wrapperClass) ? props.col.wrapperClass(props.cellCtx) : props.col.wrapperClass ?? "flex items-center gap-1";
|
|
82
|
+
return h("div", { class: wrapperClass }, [
|
|
83
|
+
...inline.map((action, idx) => renderInline(action, idx)),
|
|
84
|
+
overflow.length > 0 ? renderOverflow(overflow) : null
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<render />
|
|
91
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CellContext } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableActionsColumn } from '../../../types/data-table';
|
|
3
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
4
|
+
interface DataTableRendererActionsCellProps {
|
|
5
|
+
col: DataTableActionsColumn<unknown>;
|
|
6
|
+
cellCtx: CellContext<unknown, unknown>;
|
|
7
|
+
options: DataTableProps<any>;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<DataTableRendererActionsCellProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DataTableRendererActionsCellProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DataTableRendererCellTooltipProps {
|
|
2
|
+
/** 单元格显示文本,溢出时作为 Tooltip 内容 */
|
|
3
|
+
text: string;
|
|
4
|
+
/** true = 单行截断,number = 多行截断行数(-webkit-line-clamp) */
|
|
5
|
+
lines?: boolean | number;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<DataTableRendererCellTooltipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DataTableRendererCellTooltipProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { UTooltip } from "#components";
|
|
3
|
+
import { computed, useAttrs, useTemplateRef } from "vue";
|
|
4
|
+
import { useOverflowDetection } from "@movk/core";
|
|
5
|
+
defineOptions({ inheritAttrs: false });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
text: { type: String, required: true },
|
|
8
|
+
lines: { type: [Boolean, Number], required: false }
|
|
9
|
+
});
|
|
10
|
+
const attrs = useAttrs();
|
|
11
|
+
const cellRef = useTemplateRef("cellRef");
|
|
12
|
+
const { overflowed } = useOverflowDetection(cellRef);
|
|
13
|
+
const isMultiline = computed(() => typeof props.lines === "number" && props.lines > 1);
|
|
14
|
+
const multilineStyle = computed(
|
|
15
|
+
() => isMultiline.value ? {
|
|
16
|
+
"-webkit-line-clamp": props.lines,
|
|
17
|
+
"display": "-webkit-box",
|
|
18
|
+
"-webkit-box-orient": "vertical",
|
|
19
|
+
"overflow": "hidden",
|
|
20
|
+
"white-space": "normal",
|
|
21
|
+
"word-break": "break-all"
|
|
22
|
+
} : void 0
|
|
23
|
+
);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<UTooltip
|
|
28
|
+
:disabled="!overflowed"
|
|
29
|
+
:text="text"
|
|
30
|
+
v-bind="attrs"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
ref="cellRef"
|
|
34
|
+
:class="isMultiline ? 'overflow-hidden' : 'truncate'"
|
|
35
|
+
:style="multilineStyle"
|
|
36
|
+
>
|
|
37
|
+
{{ text }}
|
|
38
|
+
</div>
|
|
39
|
+
</UTooltip>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DataTableRendererCellTooltipProps {
|
|
2
|
+
/** 单元格显示文本,溢出时作为 Tooltip 内容 */
|
|
3
|
+
text: string;
|
|
4
|
+
/** true = 单行截断,number = 多行截断行数(-webkit-line-clamp) */
|
|
5
|
+
lines?: boolean | number;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<DataTableRendererCellTooltipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DataTableRendererCellTooltipProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TableData } from '@nuxt/ui';
|
|
2
|
+
import type { DataTablePaginationProps, DataTablePaginationSlots, DataTablePaginationUi } from '../../../types/data-table/pagination';
|
|
3
|
+
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<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
|
+
uiConfig?: DataTablePaginationUi & {
|
|
6
|
+
ui?: {
|
|
7
|
+
[x: string]: import("tailwind-variants").ClassValue;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}> & (typeof globalThis extends {
|
|
11
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
12
|
+
} ? P : {});
|
|
13
|
+
expose: (exposed: {}) => void;
|
|
14
|
+
attrs: any;
|
|
15
|
+
slots: DataTablePaginationSlots<T>;
|
|
16
|
+
emit: {};
|
|
17
|
+
}>) => import("vue").VNode & {
|
|
18
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: typeof __VLS_export;
|
|
21
|
+
export default _default;
|
|
22
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
23
|
+
[K in keyof T]: T[K];
|
|
24
|
+
} : {
|
|
25
|
+
[K in keyof T as K]: T[K];
|
|
26
|
+
}) & {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { UPagination, USelect } from "#components";
|
|
3
|
+
import { useAppConfig } from "#imports";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
import { tv } from "@nuxt/ui/utils/tv";
|
|
6
|
+
import theme from "#build/movk-ui/data-table-pagination";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
tableApi: { type: Object, required: true },
|
|
9
|
+
pagination: { type: Object, required: true },
|
|
10
|
+
page: { type: Number, required: true },
|
|
11
|
+
rowCount: { type: Number, required: true },
|
|
12
|
+
rowCountKnown: { type: Boolean, required: true },
|
|
13
|
+
pageCount: { type: Number, required: true },
|
|
14
|
+
from: { type: Number, required: true },
|
|
15
|
+
to: { type: Number, required: true },
|
|
16
|
+
selectedCount: { type: Number, required: true },
|
|
17
|
+
setPage: { type: Function, required: true },
|
|
18
|
+
setPageSize: { type: Function, required: true },
|
|
19
|
+
uiConfig: { type: Object, required: false }
|
|
20
|
+
});
|
|
21
|
+
defineSlots();
|
|
22
|
+
const appConfig = useAppConfig();
|
|
23
|
+
const uiCls = computed(
|
|
24
|
+
() => tv({ extend: tv(theme), ...appConfig.movk?.dataTablePagination || {} })()
|
|
25
|
+
);
|
|
26
|
+
const cfg = computed(() => ({
|
|
27
|
+
pageSizes: props.uiConfig?.pageSizes ?? [],
|
|
28
|
+
showSelectedCount: props.uiConfig?.showSelectedCount ?? true,
|
|
29
|
+
showRowRange: props.uiConfig?.showRowRange ?? true,
|
|
30
|
+
paginationProps: props.uiConfig?.paginationProps,
|
|
31
|
+
pageSizeSelectProps: props.uiConfig?.pageSizeSelectProps,
|
|
32
|
+
ui: props.uiConfig?.ui
|
|
33
|
+
}));
|
|
34
|
+
const text = computed(() => ({
|
|
35
|
+
total: props.uiConfig?.text?.total ?? "\u5171",
|
|
36
|
+
item: props.uiConfig?.text?.item ?? "\u6761",
|
|
37
|
+
range: props.uiConfig?.text?.range ?? "\u663E\u793A",
|
|
38
|
+
selected: props.uiConfig?.text?.selected ?? "\u5DF2\u9009",
|
|
39
|
+
page: props.uiConfig?.text?.page ?? "\u9875"
|
|
40
|
+
}));
|
|
41
|
+
const pageSizeOptions = computed(
|
|
42
|
+
() => cfg.value.pageSizes.map((size) => ({
|
|
43
|
+
label: `${size} ${text.value.item}/\u9875`,
|
|
44
|
+
value: size
|
|
45
|
+
}))
|
|
46
|
+
);
|
|
47
|
+
const showPageSizeSelect = computed(() => cfg.value.pageSizes.length > 1);
|
|
48
|
+
const pageSizeSelectAttrs = computed(() => ({
|
|
49
|
+
...cfg.value.pageSizeSelectProps,
|
|
50
|
+
class: uiCls.value.pageSizeSelect({ class: cfg.value.pageSizeSelectProps?.class })
|
|
51
|
+
}));
|
|
52
|
+
const paginationAttrs = computed(() => ({
|
|
53
|
+
...cfg.value.paginationProps,
|
|
54
|
+
class: uiCls.value.pagination({ class: cfg.value.paginationProps?.class })
|
|
55
|
+
}));
|
|
56
|
+
const summaryText = computed(() => {
|
|
57
|
+
if (!props.rowCountKnown) {
|
|
58
|
+
if (props.from === 0) return `${text.value.range} 0`;
|
|
59
|
+
return `${text.value.range} ${props.from}-${props.to}\uFF0C\u7B2C ${props.page} / ${props.pageCount} ${text.value.page}`;
|
|
60
|
+
}
|
|
61
|
+
if (!cfg.value.showRowRange || props.rowCount === 0) {
|
|
62
|
+
return `${text.value.total} ${props.rowCount} ${text.value.item}`;
|
|
63
|
+
}
|
|
64
|
+
return `${text.value.range} ${props.from}-${props.to}\uFF0C${text.value.total} ${props.rowCount} ${text.value.item}`;
|
|
65
|
+
});
|
|
66
|
+
const selectedText = computed(
|
|
67
|
+
() => `${text.value.selected} ${props.selectedCount} ${text.value.item}`
|
|
68
|
+
);
|
|
69
|
+
const summarySlotProps = computed(() => ({
|
|
70
|
+
summaryText: summaryText.value,
|
|
71
|
+
selectedText: selectedText.value,
|
|
72
|
+
selectedCount: props.selectedCount,
|
|
73
|
+
rowCount: props.rowCount,
|
|
74
|
+
rowCountKnown: props.rowCountKnown,
|
|
75
|
+
from: props.from,
|
|
76
|
+
to: props.to,
|
|
77
|
+
page: props.page,
|
|
78
|
+
pageCount: props.pageCount,
|
|
79
|
+
showSelectedCount: cfg.value.showSelectedCount
|
|
80
|
+
}));
|
|
81
|
+
const actionsSlotProps = computed(() => ({
|
|
82
|
+
tableApi: props.tableApi,
|
|
83
|
+
page: props.page,
|
|
84
|
+
pageCount: props.pageCount,
|
|
85
|
+
pageSize: props.pagination.pageSize,
|
|
86
|
+
rowCount: props.rowCount,
|
|
87
|
+
pageSizes: cfg.value.pageSizes,
|
|
88
|
+
pageSizeOptions: pageSizeOptions.value,
|
|
89
|
+
showPageSizeSelect: showPageSizeSelect.value,
|
|
90
|
+
setPage: props.setPage,
|
|
91
|
+
setPageSize: props.setPageSize
|
|
92
|
+
}));
|
|
93
|
+
const setPage = (value) => props.setPage(value);
|
|
94
|
+
const setPageSize = (value) => props.setPageSize(value);
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<template>
|
|
98
|
+
<div :class="uiCls.root({ class: cfg.ui?.root })" data-slot="root">
|
|
99
|
+
<div :class="uiCls.summary({ class: cfg.ui?.summary })" data-slot="summary">
|
|
100
|
+
<slot name="summary" v-bind="summarySlotProps">
|
|
101
|
+
<span :class="uiCls.summaryText({ class: cfg.ui?.summaryText })">{{ summaryText }}</span>
|
|
102
|
+
<span
|
|
103
|
+
v-if="cfg.showSelectedCount && selectedCount > 0"
|
|
104
|
+
:class="uiCls.selectedCount({ class: cfg.ui?.selectedCount })"
|
|
105
|
+
>
|
|
106
|
+
{{ selectedText }}
|
|
107
|
+
</span>
|
|
108
|
+
</slot>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div :class="uiCls.actions({ class: cfg.ui?.actions })" data-slot="actions">
|
|
112
|
+
<slot name="actions" v-bind="actionsSlotProps">
|
|
113
|
+
<USelect
|
|
114
|
+
v-if="showPageSizeSelect"
|
|
115
|
+
:model-value="pagination.pageSize"
|
|
116
|
+
:items="pageSizeOptions"
|
|
117
|
+
v-bind="pageSizeSelectAttrs"
|
|
118
|
+
@update:model-value="setPageSize"
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<UPagination
|
|
122
|
+
:page="page"
|
|
123
|
+
:total="pageCount * pagination.pageSize"
|
|
124
|
+
:items-per-page="pagination.pageSize"
|
|
125
|
+
v-bind="paginationAttrs"
|
|
126
|
+
data-slot="pagination"
|
|
127
|
+
@update:page="setPage"
|
|
128
|
+
/>
|
|
129
|
+
</slot>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TableData } from '@nuxt/ui';
|
|
2
|
+
import type { DataTablePaginationProps, DataTablePaginationSlots, DataTablePaginationUi } from '../../../types/data-table/pagination';
|
|
3
|
+
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<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
|
+
uiConfig?: DataTablePaginationUi & {
|
|
6
|
+
ui?: {
|
|
7
|
+
[x: string]: import("tailwind-variants").ClassValue;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}> & (typeof globalThis extends {
|
|
11
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
12
|
+
} ? P : {});
|
|
13
|
+
expose: (exposed: {}) => void;
|
|
14
|
+
attrs: any;
|
|
15
|
+
slots: DataTablePaginationSlots<T>;
|
|
16
|
+
emit: {};
|
|
17
|
+
}>) => import("vue").VNode & {
|
|
18
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: typeof __VLS_export;
|
|
21
|
+
export default _default;
|
|
22
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
23
|
+
[K in keyof T]: T[K];
|
|
24
|
+
} : {
|
|
25
|
+
[K in keyof T as K]: T[K];
|
|
26
|
+
}) & {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataTableProps } from '../../types/data-table';
|
|
2
|
+
/**
|
|
3
|
+
* 计算给定 `indentSize` 在 `[0, maxButtonDepth]` 范围内的最大缩进像素
|
|
4
|
+
*
|
|
5
|
+
* - `number` / `string`:等差缩进 `depth * step`,取 `maxButtonDepth * step`
|
|
6
|
+
* - `function`:对每个 depth 评估并取最大值;评估失败回退 0
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveMaxIndentPx<T>(size: DataTableProps<T>['indentSize'], maxButtonDepth: number): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { lengthToPx } from "@movk/core";
|
|
2
|
+
export function resolveMaxIndentPx(size, maxButtonDepth) {
|
|
3
|
+
if (maxButtonDepth <= 0) return 0;
|
|
4
|
+
if (typeof size === "number") return size * maxButtonDepth;
|
|
5
|
+
if (typeof size === "string") return lengthToPx(size) * maxButtonDepth;
|
|
6
|
+
if (typeof size === "function") {
|
|
7
|
+
let max = 0;
|
|
8
|
+
for (let d = 1; d <= maxButtonDepth; d++) {
|
|
9
|
+
try {
|
|
10
|
+
const ret = size({ row: { depth: d } });
|
|
11
|
+
const px = typeof ret === "number" ? ret : typeof ret === "string" ? lengthToPx(ret) : 0;
|
|
12
|
+
if (px > max) max = px;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return max;
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DataTableTreeSelectionStrategy } from '../../types/data-table';
|
|
2
|
+
import type { TreeSelectionResult } from '../../types/data-table/columns';
|
|
3
|
+
interface ComputeOptions {
|
|
4
|
+
rowKey?: string;
|
|
5
|
+
childrenKey?: string;
|
|
6
|
+
strategy?: DataTableTreeSelectionStrategy;
|
|
7
|
+
}
|
|
8
|
+
export declare function computeTreeRowSelection<T>(rows: T[], keys: readonly (string | number)[], options?: ComputeOptions): TreeSelectionResult<T>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export function computeTreeRowSelection(rows, keys, options = {}) {
|
|
2
|
+
const rowKey = options.rowKey ?? "id";
|
|
3
|
+
const childrenKey = options.childrenKey;
|
|
4
|
+
const strategy = options.strategy ?? "cascade";
|
|
5
|
+
const keySet = new Set(keys.map(String));
|
|
6
|
+
const selected = [];
|
|
7
|
+
const leaves = [];
|
|
8
|
+
const parents = [];
|
|
9
|
+
const halfSelected = [];
|
|
10
|
+
const strictlyChecked = [];
|
|
11
|
+
const readKey = (row, key) => row[key];
|
|
12
|
+
if (!childrenKey) {
|
|
13
|
+
for (const row of rows) {
|
|
14
|
+
if (keySet.has(String(readKey(row, rowKey)))) {
|
|
15
|
+
selected.push(row);
|
|
16
|
+
leaves.push(row);
|
|
17
|
+
strictlyChecked.push(row);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return { selected, leaves, parents, halfSelected, strictlyChecked };
|
|
21
|
+
}
|
|
22
|
+
const build = (items, parent) => {
|
|
23
|
+
const list = [];
|
|
24
|
+
for (const row of items) {
|
|
25
|
+
const id = String(readKey(row, rowKey));
|
|
26
|
+
const selfSelected = keySet.has(id);
|
|
27
|
+
const node = {
|
|
28
|
+
row,
|
|
29
|
+
id,
|
|
30
|
+
parent,
|
|
31
|
+
children: [],
|
|
32
|
+
selfSelected,
|
|
33
|
+
leafTotal: 0,
|
|
34
|
+
leafSelected: 0
|
|
35
|
+
};
|
|
36
|
+
const childArr = readKey(row, childrenKey);
|
|
37
|
+
if (Array.isArray(childArr) && childArr.length > 0) {
|
|
38
|
+
node.children = build(childArr, node);
|
|
39
|
+
for (const c of node.children) {
|
|
40
|
+
node.leafTotal += c.leafTotal;
|
|
41
|
+
node.leafSelected += c.leafSelected;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
node.leafTotal = 1;
|
|
45
|
+
node.leafSelected = selfSelected ? 1 : 0;
|
|
46
|
+
}
|
|
47
|
+
list.push(node);
|
|
48
|
+
}
|
|
49
|
+
return list;
|
|
50
|
+
};
|
|
51
|
+
const roots = build(rows, null);
|
|
52
|
+
const visit = (node) => {
|
|
53
|
+
const isLeaf = node.children.length === 0;
|
|
54
|
+
if (node.selfSelected) {
|
|
55
|
+
selected.push(node.row);
|
|
56
|
+
if (isLeaf) leaves.push(node.row);
|
|
57
|
+
if (strategy === "cascade") {
|
|
58
|
+
if (!node.parent || !node.parent.selfSelected) {
|
|
59
|
+
strictlyChecked.push(node.row);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
strictlyChecked.push(node.row);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!isLeaf) {
|
|
66
|
+
if (node.leafTotal > 0 && node.leafSelected === node.leafTotal) {
|
|
67
|
+
parents.push(node.row);
|
|
68
|
+
} else if (node.leafSelected > 0) {
|
|
69
|
+
halfSelected.push(node.row);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const child of node.children) visit(child);
|
|
73
|
+
};
|
|
74
|
+
for (const root of roots) visit(root);
|
|
75
|
+
return { selected, leaves, parents, halfSelected, strictlyChecked };
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss" theme(static);@import "@nuxt/ui";@import "#build/movk-ui.css";@source "./components";@theme static{--font-sans:"Alibaba PuHuiTi",sans-serif}@layer base{[role=button]:not(:disabled),button:not(:disabled){cursor:pointer}}
|