@movk/nuxt 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/movk-ui.css +3 -0
- package/README.md +74 -79
- package/dist/module.d.mts +57 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +120 -126
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -30
- package/dist/runtime/components/AutoForm.vue +114 -125
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -30
- package/dist/runtime/components/ColorChooser.d.vue.ts +21 -22
- package/dist/runtime/components/ColorChooser.vue +304 -27
- package/dist/runtime/components/ColorChooser.vue.d.ts +21 -22
- package/dist/runtime/components/DataTable.d.vue.ts +57 -0
- package/dist/runtime/components/DataTable.vue +584 -0
- package/dist/runtime/components/DataTable.vue.d.ts +57 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +20 -33
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +20 -33
- package/dist/runtime/components/MessageBox.d.vue.ts +36 -0
- package/dist/runtime/components/MessageBox.vue +113 -0
- package/dist/runtime/components/MessageBox.vue.d.ts +36 -0
- package/dist/runtime/components/PillGroup.d.vue.ts +33 -0
- package/dist/runtime/components/PillGroup.vue +291 -0
- package/dist/runtime/components/PillGroup.vue.d.ts +33 -0
- package/dist/runtime/components/Popconfirm.d.vue.ts +30 -0
- package/dist/runtime/components/Popconfirm.vue +143 -0
- package/dist/runtime/components/Popconfirm.vue.d.ts +30 -0
- package/dist/runtime/components/SearchForm.d.vue.ts +21 -149
- package/dist/runtime/components/SearchForm.vue +211 -153
- package/dist/runtime/components/SearchForm.vue.d.ts +21 -149
- package/dist/runtime/components/SlideVerify.d.vue.ts +31 -70
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +31 -70
- package/dist/runtime/components/StarRating.d.vue.ts +38 -87
- package/dist/runtime/components/StarRating.vue +118 -74
- package/dist/runtime/components/StarRating.vue.d.ts +38 -87
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +11 -15
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +22 -9
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +11 -15
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -13
- package/dist/runtime/components/input/WithCharacterLimit.vue +23 -11
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -13
- package/dist/runtime/components/input/WithClear.d.vue.ts +13 -11
- package/dist/runtime/components/input/WithClear.vue +27 -8
- package/dist/runtime/components/input/WithClear.vue.d.ts +13 -11
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -13
- package/dist/runtime/components/input/WithCopy.vue +25 -8
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -13
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +13 -16
- package/dist/runtime/components/input/WithFloatingLabel.vue +35 -27
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +13 -16
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +24 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +27 -12
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +9 -4
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +9 -4
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +10 -5
- package/dist/runtime/composables/useApiFetch.js +20 -2
- package/dist/runtime/composables/useAutoForm.d.ts +4 -4
- package/dist/runtime/composables/useAutoForm.js +23 -9
- package/dist/runtime/composables/useClientApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useDateFormatter.d.ts +16 -3
- package/dist/runtime/composables/useDateFormatter.js +89 -30
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +26 -27
- package/dist/runtime/composables/useDownloadWithProgress.js +142 -40
- package/dist/runtime/composables/useLazyApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +26 -16
- package/dist/runtime/composables/useTheme.js +98 -71
- package/dist/runtime/composables/useUploadWithProgress.d.ts +23 -29
- package/dist/runtime/composables/useUploadWithProgress.js +78 -67
- package/dist/runtime/domains/api/auth.d.ts +2 -0
- package/dist/runtime/domains/api/auth.js +31 -0
- package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
- package/dist/runtime/domains/api/endpoint-config.js +17 -0
- package/dist/runtime/domains/api/errors.d.ts +2 -0
- package/dist/runtime/domains/api/errors.js +10 -0
- package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
- package/dist/runtime/domains/api/fetch-key.js +23 -0
- package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
- package/dist/runtime/domains/api/interceptors/error.js +49 -0
- package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
- package/dist/runtime/domains/api/interceptors/request.js +46 -0
- package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
- package/dist/runtime/domains/api/interceptors/response.js +27 -0
- package/dist/runtime/domains/api/response.d.ts +4 -0
- package/dist/runtime/domains/api/response.js +14 -0
- package/dist/runtime/domains/api/toast.d.ts +15 -0
- package/dist/runtime/domains/api/toast.js +46 -0
- package/dist/runtime/domains/api/transfer.d.ts +69 -0
- package/dist/runtime/domains/api/transfer.js +81 -0
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
- package/dist/runtime/domains/auto-form/actions.js +4 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +25 -29
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererChildren.vue → domains/auto-form/components/Children.vue} +18 -18
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererLayout.vue → domains/auto-form/components/Layout.vue} +24 -25
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererNested.vue → domains/auto-form/components/Nested.vue} +17 -21
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/{auto-form → domains/auto-form}/controls.js +27 -24
- package/dist/runtime/{auto-form/field-utils.d.ts → domains/auto-form/fields.d.ts} +3 -1
- package/dist/runtime/{auto-form/field-utils.js → domains/auto-form/fields.js} +18 -2
- package/dist/runtime/{auto-form → domains/auto-form}/metadata.js +1 -1
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{auto-form → domains/auto-form}/provider.js +6 -3
- package/dist/runtime/{auto-form/reactive-utils.d.ts → domains/auto-form/reactive.d.ts} +5 -5
- package/dist/runtime/{auto-form/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/{auto-form/schema-introspector.d.ts → domains/auto-form/schema.d.ts} +2 -2
- package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +1 -1
- package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
- package/dist/runtime/domains/data-table/columns/constants.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +164 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
- package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
- package/dist/runtime/domains/data-table/columns/style.js +67 -0
- package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
- package/dist/runtime/domains/data-table/columns/utils.js +16 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
- package/dist/runtime/domains/data-table/indent.d.ts +8 -0
- package/dist/runtime/domains/data-table/indent.js +19 -0
- package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
- package/dist/runtime/domains/data-table/tree-selection.js +76 -0
- package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/plugins/api.factory.js +17 -117
- package/dist/runtime/plugins/theme.js +49 -27
- package/dist/runtime/types/api/config.d.ts +127 -0
- package/dist/runtime/types/api/fetch.d.ts +50 -0
- package/dist/runtime/types/api/index.d.ts +5 -0
- package/dist/runtime/types/api/module.d.ts +94 -0
- package/dist/runtime/types/api/response.d.ts +62 -0
- package/dist/runtime/types/api/response.js +0 -0
- package/dist/runtime/types/api/transfer.d.ts +32 -0
- package/dist/runtime/types/api/transfer.js +0 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/auto-form/base.d.ts +26 -0
- package/dist/runtime/types/auto-form/base.js +0 -0
- package/dist/runtime/types/auto-form/component.d.ts +28 -0
- package/dist/runtime/types/auto-form/component.js +0 -0
- package/dist/runtime/types/auto-form/controls.d.ts +45 -0
- package/dist/runtime/types/auto-form/controls.js +0 -0
- package/dist/runtime/types/auto-form/fields.d.ts +68 -0
- package/dist/runtime/types/auto-form/fields.js +0 -0
- package/dist/runtime/types/auto-form/index.d.ts +7 -0
- package/dist/runtime/types/auto-form/index.js +0 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
- package/dist/runtime/types/auto-form/search-form.js +0 -0
- package/dist/runtime/types/auto-form/slots.d.ts +85 -0
- package/dist/runtime/types/auto-form/slots.js +0 -0
- package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
- package/dist/runtime/types/auto-form/zod-factory.js +0 -0
- package/dist/runtime/types/components/color-chooser.d.ts +109 -0
- package/dist/runtime/types/components/color-chooser.js +0 -0
- package/dist/runtime/types/components/date-picker.d.ts +41 -0
- package/dist/runtime/types/components/date-picker.js +0 -0
- package/dist/runtime/types/components/index.d.ts +8 -0
- package/dist/runtime/types/components/index.js +0 -0
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
- package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
- package/dist/runtime/types/components/input/index.d.ts +6 -0
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/message-box.d.ts +69 -0
- package/dist/runtime/types/components/message-box.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +103 -0
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +74 -0
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +54 -0
- package/dist/runtime/types/components/slide-verify.js +0 -0
- package/dist/runtime/types/components/star-rating.d.ts +55 -0
- package/dist/runtime/types/components/star-rating.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +236 -0
- package/dist/runtime/types/data-table/columns.js +6 -0
- package/dist/runtime/types/data-table/component.d.ts +190 -0
- package/dist/runtime/types/data-table/component.js +0 -0
- package/dist/runtime/types/data-table/contexts.d.ts +44 -0
- package/dist/runtime/types/data-table/contexts.js +0 -0
- package/dist/runtime/types/data-table/index.d.ts +6 -0
- package/dist/runtime/types/data-table/index.js +1 -0
- package/dist/runtime/types/data-table/pagination.d.ts +87 -0
- package/dist/runtime/types/data-table/pagination.js +0 -0
- package/dist/runtime/types/index.d.ts +6 -5
- package/dist/runtime/types/index.js +5 -5
- package/dist/runtime/types/shared.d.ts +5 -0
- package/dist/runtime/types/shared.js +0 -0
- package/dist/runtime/types/zod.d.ts +11 -10
- package/dist/runtime/utils/extend-theme.d.ts +19 -0
- package/dist/runtime/utils/extend-theme.js +44 -0
- package/dist/runtime/utils/form-control.d.ts +33 -0
- package/dist/runtime/utils/form-control.js +54 -0
- package/dist/runtime/utils/meta.d.ts +2 -5
- package/dist/runtime/utils/meta.js +1 -3
- package/dist/runtime/utils/theme-defaults.d.ts +27 -0
- package/dist/runtime/utils/theme-defaults.js +28 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
- package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
- package/dist/runtime/vue/plugins/theme.d.ts +6 -0
- package/dist/runtime/vue/plugins/theme.js +14 -0
- package/dist/runtime/vue/stubs/base.d.ts +2 -0
- package/dist/runtime/vue/stubs/base.js +2 -0
- package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
- package/dist/runtime/vue/stubs/inertia.js +2 -0
- package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
- package/dist/runtime/vue/stubs/movk-extra.js +2 -0
- package/dist/runtime/vue/stubs/none.d.ts +2 -0
- package/dist/runtime/vue/stubs/none.js +2 -0
- package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
- package/dist/runtime/vue/stubs/vue-router.js +2 -0
- package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
- package/dist/types.d.mts +2 -6
- package/dist/unplugin.d.mts +28 -0
- package/dist/unplugin.mjs +292 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.mjs +20 -0
- package/package.json +75 -36
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/auto-form/controls.d.ts +0 -221
- package/dist/runtime/auto-form/provider.d.ts +0 -27
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -26
- package/dist/runtime/constants/api-defaults.d.ts +0 -9
- package/dist/runtime/constants/api-defaults.js +0 -32
- package/dist/runtime/constants/grid-cols.d.ts +0 -7
- package/dist/runtime/constants/grid-cols.js +0 -44
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -349
- package/dist/runtime/types/auto-form.d.ts +0 -259
- package/dist/runtime/types/module.d.ts +0 -96
- package/dist/runtime/types/theme.d.ts +0 -2
- package/dist/runtime/utils/api-utils.d.ts +0 -58
- package/dist/runtime/utils/api-utils.js +0 -98
- /package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -0
- /package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -0
- /package/dist/runtime/{auto-form → domains/auto-form}/metadata.d.ts +0 -0
- /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
- /package/dist/runtime/types/{api.js → api/config.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{module.js → api/index.js} +0 -0
- /package/dist/runtime/types/{theme.js → api/module.js} +0 -0
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
import 'node:url';
|
|
2
|
+
import { kebabCase } from 'scule';
|
|
3
|
+
import { addTypeTemplate, addTemplate, getLayerDirectories } from '@nuxt/kit';
|
|
4
|
+
|
|
5
|
+
const popconfirm = () => ({
|
|
6
|
+
slots: {
|
|
7
|
+
content: "px-4 py-3 flex flex-col gap-2",
|
|
8
|
+
arrow: "",
|
|
9
|
+
header: "flex flex-col gap-1.5",
|
|
10
|
+
title: "flex gap-2 items-center text-sm text-highlighted font-semibold",
|
|
11
|
+
description: "text-muted text-xs",
|
|
12
|
+
body: "",
|
|
13
|
+
footer: "mt-1 flex items-center justify-end gap-1.5",
|
|
14
|
+
icon: "size-4 shrink-0"
|
|
15
|
+
},
|
|
16
|
+
variants: {
|
|
17
|
+
type: {
|
|
18
|
+
primary: { icon: "text-primary" },
|
|
19
|
+
info: { icon: "text-info" },
|
|
20
|
+
success: { icon: "text-success" },
|
|
21
|
+
warning: { icon: "text-warning" },
|
|
22
|
+
error: { icon: "text-error" },
|
|
23
|
+
neutral: { icon: "text-muted" }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const colorChooser = () => ({
|
|
29
|
+
slots: {
|
|
30
|
+
body: "p-2 flex flex-col gap-2 min-w-[14rem]",
|
|
31
|
+
header: "flex items-center justify-between gap-2",
|
|
32
|
+
section: "flex flex-col gap-1.5",
|
|
33
|
+
swatches: "grid grid-cols-8 gap-1",
|
|
34
|
+
swatch: "rounded ring-1 ring-default cursor-pointer transition hover:scale-110 hover:ring-2 hover:ring-primary aria-selected:ring-2 aria-selected:ring-primary",
|
|
35
|
+
actions: "mt-1 flex items-center justify-between gap-1.5 border-t border-default pt-2",
|
|
36
|
+
actionsValue: "text-xs text-muted tabular-nums truncate",
|
|
37
|
+
actionsButtons: "flex items-center gap-1",
|
|
38
|
+
triggerChipWrapper: "",
|
|
39
|
+
triggerChip: "rounded-full ring-1 ring-default shrink-0 transition",
|
|
40
|
+
triggerLabel: "tabular-nums truncate",
|
|
41
|
+
triggerIcon: "text-muted shrink-0"
|
|
42
|
+
},
|
|
43
|
+
variants: {
|
|
44
|
+
size: {
|
|
45
|
+
xs: { triggerChip: "size-2.5", swatch: "size-4", triggerIcon: "size-3" },
|
|
46
|
+
sm: { triggerChip: "size-3", swatch: "size-4", triggerIcon: "size-3.5" },
|
|
47
|
+
md: { triggerChip: "size-3.5", swatch: "size-5", triggerIcon: "size-4" },
|
|
48
|
+
lg: { triggerChip: "size-4", swatch: "size-5", triggerIcon: "size-4" },
|
|
49
|
+
xl: { triggerChip: "size-5", swatch: "size-6", triggerIcon: "size-5" }
|
|
50
|
+
},
|
|
51
|
+
trigger: {
|
|
52
|
+
button: {},
|
|
53
|
+
chip: {},
|
|
54
|
+
input: {}
|
|
55
|
+
},
|
|
56
|
+
disabled: {
|
|
57
|
+
true: { body: "opacity-60 pointer-events-none" }
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
size: "md",
|
|
62
|
+
trigger: "button"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const datePicker = () => ({
|
|
67
|
+
slots: {
|
|
68
|
+
wrapper: "flex",
|
|
69
|
+
presets: "flex flex-col gap-1 p-2 border-r border-default min-w-[120px]",
|
|
70
|
+
presetButton: "justify-start",
|
|
71
|
+
calendar: "p-2",
|
|
72
|
+
clearIcon: "cursor-pointer opacity-60 hover:opacity-100 transition-opacity"
|
|
73
|
+
},
|
|
74
|
+
variants: {
|
|
75
|
+
withPresets: {
|
|
76
|
+
true: {},
|
|
77
|
+
false: { wrapper: "block" }
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
withPresets: false
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const dataTablePagination = () => ({
|
|
86
|
+
slots: {
|
|
87
|
+
root: "flex flex-col gap-3 px-2 py-3 md:flex-row md:items-center md:justify-between",
|
|
88
|
+
summary: "flex flex-wrap items-center gap-2 text-sm text-muted",
|
|
89
|
+
summaryText: "",
|
|
90
|
+
selectedCount: "text-toned",
|
|
91
|
+
actions: "flex flex-wrap items-center gap-3",
|
|
92
|
+
pageSizeSelect: "w-28",
|
|
93
|
+
pagination: ""
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const asPhoneNumberInput = () => ({
|
|
98
|
+
slots: {
|
|
99
|
+
base: "",
|
|
100
|
+
leading: "",
|
|
101
|
+
dialCode: ""
|
|
102
|
+
},
|
|
103
|
+
variants: {
|
|
104
|
+
dialCode: {
|
|
105
|
+
true: {
|
|
106
|
+
base: "ps-(--dial-code-length)",
|
|
107
|
+
leading: "pointer-events-none text-muted"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const withClear = () => ({
|
|
114
|
+
slots: {
|
|
115
|
+
trailing: "pe-1"
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const withCopy = () => ({
|
|
120
|
+
slots: {
|
|
121
|
+
trailing: "pe-1"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const withFloatingLabel = () => ({
|
|
126
|
+
slots: {
|
|
127
|
+
base: "peer",
|
|
128
|
+
trailing: "pe-1",
|
|
129
|
+
label: [
|
|
130
|
+
"pointer-events-none absolute -top-2.5 px-1.5 transition-all",
|
|
131
|
+
"text-highlighted text-xs font-medium",
|
|
132
|
+
"peer-focus:-top-2.5 peer-focus:text-highlighted peer-focus:text-xs peer-focus:font-medium",
|
|
133
|
+
"peer-placeholder-shown:text-dimmed peer-placeholder-shown:font-normal",
|
|
134
|
+
"peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-focus:translate-y-0"
|
|
135
|
+
].join(" "),
|
|
136
|
+
labelText: "inline-flex bg-default px-1"
|
|
137
|
+
},
|
|
138
|
+
variants: {
|
|
139
|
+
size: {
|
|
140
|
+
xs: { label: "peer-placeholder-shown:text-xs" },
|
|
141
|
+
sm: { label: "peer-placeholder-shown:text-xs" },
|
|
142
|
+
md: { label: "peer-placeholder-shown:text-sm" },
|
|
143
|
+
lg: { label: "peer-placeholder-shown:text-sm" },
|
|
144
|
+
xl: { label: "peer-placeholder-shown:text-base" }
|
|
145
|
+
},
|
|
146
|
+
hasLeading: {
|
|
147
|
+
true: {},
|
|
148
|
+
false: { label: "left-0" }
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
compoundVariants: [
|
|
152
|
+
{ size: "xs", hasLeading: true, class: { label: "left-5" } },
|
|
153
|
+
{ size: "sm", hasLeading: true, class: { label: "left-6" } },
|
|
154
|
+
{ size: "md", hasLeading: true, class: { label: "left-7" } },
|
|
155
|
+
{ size: "lg", hasLeading: true, class: { label: "left-8" } },
|
|
156
|
+
{ size: "xl", hasLeading: true, class: { label: "left-9" } }
|
|
157
|
+
],
|
|
158
|
+
defaultVariants: {
|
|
159
|
+
size: "md",
|
|
160
|
+
hasLeading: false
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const withPasswordToggle = () => ({
|
|
165
|
+
slots: {
|
|
166
|
+
trailing: "pe-1"
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const withCharacterLimit = () => ({
|
|
171
|
+
slots: {
|
|
172
|
+
trailing: "pointer-events-none",
|
|
173
|
+
counter: "text-xs text-muted tabular-nums"
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const messageBox = () => ({
|
|
178
|
+
slots: {
|
|
179
|
+
title: "flex gap-2 items-center",
|
|
180
|
+
footer: "justify-end",
|
|
181
|
+
icon: "size-5 shrink-0"
|
|
182
|
+
},
|
|
183
|
+
variants: {
|
|
184
|
+
type: {
|
|
185
|
+
primary: { icon: "text-primary" },
|
|
186
|
+
info: { icon: "text-info" },
|
|
187
|
+
success: { icon: "text-success" },
|
|
188
|
+
warning: { icon: "text-warning" },
|
|
189
|
+
error: { icon: "text-error" },
|
|
190
|
+
neutral: { icon: "text-muted" }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const ROW_SEP = "[[data-slot=tr]+[data-slot=tr]>&]";
|
|
196
|
+
const PINNED = "data-[pinned]";
|
|
197
|
+
const PINNED_L = "data-[pinned=left]";
|
|
198
|
+
const NOT_LAST_NOT_PIN = "not-last:not-data-[pinned=left]:not-data-[pinned=right]";
|
|
199
|
+
const GROUP_HEADER = "[[data-slot=tr]:has([colspan])>&]";
|
|
200
|
+
const BW = "var(--m-dt-border-width,1px)";
|
|
201
|
+
const BC = "var(--m-dt-border-color,var(--ui-border))";
|
|
202
|
+
const BS = "var(--m-dt-border-style,solid)";
|
|
203
|
+
const dataTable = () => ({
|
|
204
|
+
slots: {
|
|
205
|
+
wrapper: "flex flex-col min-h-0 relative",
|
|
206
|
+
base: "border-separate border-spacing-0",
|
|
207
|
+
tbody: "divide-y-0",
|
|
208
|
+
th: [
|
|
209
|
+
`${PINNED}:sticky`,
|
|
210
|
+
`${PINNED}:[--m-dt-pin-shadow:0_0_0_0_transparent]`,
|
|
211
|
+
`${PINNED}:shadow-[var(--m-dt-pin-shadow)]`
|
|
212
|
+
].join(" "),
|
|
213
|
+
td: [
|
|
214
|
+
"empty:p-0",
|
|
215
|
+
`${ROW_SEP}:border-t`,
|
|
216
|
+
`${ROW_SEP}:border-default`,
|
|
217
|
+
`${PINNED}:sticky`,
|
|
218
|
+
`${PINNED}:[--m-dt-pin-shadow:0_0_0_0_transparent]`,
|
|
219
|
+
`${PINNED}:shadow-[var(--m-dt-pin-shadow)]`,
|
|
220
|
+
"[[data-selected=true]>&[data-pinned]]:bg-[color:color-mix(in_oklab,var(--ui-bg-elevated)_50%,transparent)]"
|
|
221
|
+
].join(" ")
|
|
222
|
+
},
|
|
223
|
+
variants: {
|
|
224
|
+
fitContent: {
|
|
225
|
+
true: {
|
|
226
|
+
base: "w-fit min-w-0"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
bordered: {
|
|
230
|
+
true: {
|
|
231
|
+
root: [
|
|
232
|
+
`border-[length:${BW}]`,
|
|
233
|
+
`border-[color:${BC}]`,
|
|
234
|
+
`[border-style:${BS}]`,
|
|
235
|
+
"rounded-[var(--ui-radius)]"
|
|
236
|
+
].join(" "),
|
|
237
|
+
th: [
|
|
238
|
+
`${NOT_LAST_NOT_PIN}:border-r-[length:${BW}]`,
|
|
239
|
+
`${NOT_LAST_NOT_PIN}:border-r-[color:${BC}]`,
|
|
240
|
+
`${NOT_LAST_NOT_PIN}:[border-right-style:${BS}]`,
|
|
241
|
+
`${PINNED_L}:shadow-[inset_-1px_0_0_${BC},var(--m-dt-pin-shadow)]`,
|
|
242
|
+
`${GROUP_HEADER}:border-b-[length:${BW}]`,
|
|
243
|
+
`${GROUP_HEADER}:border-b-[color:${BC}]`,
|
|
244
|
+
`${GROUP_HEADER}:[border-bottom-style:${BS}]`
|
|
245
|
+
].join(" "),
|
|
246
|
+
td: [
|
|
247
|
+
`${ROW_SEP}:border-t-[length:${BW}]`,
|
|
248
|
+
`${ROW_SEP}:border-t-[color:${BC}]`,
|
|
249
|
+
`${ROW_SEP}:[border-top-style:${BS}]`,
|
|
250
|
+
`${NOT_LAST_NOT_PIN}:border-r-[length:${BW}]`,
|
|
251
|
+
`${NOT_LAST_NOT_PIN}:border-r-[color:${BC}]`,
|
|
252
|
+
`${NOT_LAST_NOT_PIN}:[border-right-style:${BS}]`,
|
|
253
|
+
`${PINNED_L}:shadow-[inset_-1px_0_0_${BC},var(--m-dt-pin-shadow)]`
|
|
254
|
+
].join(" ")
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
striped: {
|
|
258
|
+
true: {
|
|
259
|
+
td: "[[data-slot=tr]:nth-child(even)>&[data-pinned]]:bg-[color:color-mix(in_oklab,var(--ui-bg-accented)_10%,transparent)]"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
tree: {
|
|
263
|
+
true: {
|
|
264
|
+
tr: "has-[>[data-slot=td]:only-child:empty]:hidden"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
resizing: {
|
|
268
|
+
true: {
|
|
269
|
+
base: "cursor-col-resize! select-none! [&_*]:cursor-col-resize! [&_*]:select-none!"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const themePicker = () => ({
|
|
276
|
+
slots: {
|
|
277
|
+
content: "w-72 px-6 py-4 flex flex-col gap-4 overflow-y-auto max-h-[calc(100vh-5rem)]"
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const slideVerify = () => ({
|
|
282
|
+
slots: {
|
|
283
|
+
root: "w-full relative flex items-center select-none overflow-hidden rounded-md border transition-colors duration-300",
|
|
284
|
+
track: "absolute inset-0",
|
|
285
|
+
fill: "absolute inset-y-0 left-0 bg-primary/20 opacity-60",
|
|
286
|
+
text: "absolute inset-0 flex items-center justify-center font-medium pointer-events-none",
|
|
287
|
+
slider: "relative z-10 flex shrink-0 touch-none items-center justify-center rounded-md shadow-sm transition-colors",
|
|
288
|
+
icon: "shrink-0"
|
|
289
|
+
},
|
|
290
|
+
variants: {
|
|
291
|
+
size: {
|
|
292
|
+
xs: { root: "p-1", text: "text-xs", slider: "px-2 py-1", icon: "size-4" },
|
|
293
|
+
sm: { root: "p-1.5", text: "text-xs", slider: "px-2.5 py-1.5", icon: "size-4" },
|
|
294
|
+
md: { root: "p-1.5", text: "text-sm", slider: "px-2.5 py-1.5", icon: "size-5" },
|
|
295
|
+
lg: { root: "p-2", text: "text-sm", slider: "px-3 py-2", icon: "size-5" },
|
|
296
|
+
xl: { root: "p-2", text: "text-base", slider: "px-3 py-2", icon: "size-6" }
|
|
297
|
+
},
|
|
298
|
+
disabled: {
|
|
299
|
+
true: { root: "opacity-50 cursor-not-allowed" }
|
|
300
|
+
},
|
|
301
|
+
verified: {
|
|
302
|
+
true: {
|
|
303
|
+
root: "bg-success border-transparent",
|
|
304
|
+
slider: "bg-white/90",
|
|
305
|
+
icon: "text-success"
|
|
306
|
+
},
|
|
307
|
+
false: {
|
|
308
|
+
root: "bg-elevated border-default",
|
|
309
|
+
slider: "bg-default cursor-grab active:cursor-grabbing ring-1 ring-default",
|
|
310
|
+
icon: "text-primary"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
fieldGroup: {
|
|
314
|
+
horizontal: {
|
|
315
|
+
root: "not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]"
|
|
316
|
+
},
|
|
317
|
+
vertical: {
|
|
318
|
+
root: "not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
defaultVariants: {
|
|
323
|
+
size: "md"
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const searchForm = () => ({
|
|
328
|
+
slots: {
|
|
329
|
+
root: "group/search",
|
|
330
|
+
form: "space-y-4",
|
|
331
|
+
visible: "relative",
|
|
332
|
+
grid: "grid gap-4 [grid-template-columns:repeat(var(--m-search-cols,1),minmax(0,1fr))] sm:[grid-template-columns:repeat(var(--m-search-cols-sm,var(--m-search-cols)),minmax(0,1fr))] md:[grid-template-columns:repeat(var(--m-search-cols-md,var(--m-search-cols-sm,var(--m-search-cols))),minmax(0,1fr))] lg:[grid-template-columns:repeat(var(--m-search-cols-lg,var(--m-search-cols-md,var(--m-search-cols-sm,var(--m-search-cols)))),minmax(0,1fr))] xl:[grid-template-columns:repeat(var(--m-search-cols-xl,var(--m-search-cols-lg,var(--m-search-cols-md,var(--m-search-cols-sm,var(--m-search-cols))))),minmax(0,1fr))]",
|
|
333
|
+
header: "",
|
|
334
|
+
footer: "",
|
|
335
|
+
actions: "flex items-end gap-2 justify-end",
|
|
336
|
+
toggleWrapper: "flex justify-center pt-2",
|
|
337
|
+
toggle: "group opacity-75 hover:opacity-100 active:opacity-90 transition-all duration-200",
|
|
338
|
+
toggleIcon: "size-3.5 transition-all duration-200 opacity-80 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100",
|
|
339
|
+
collapsed: "mt-4"
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const autoForm = () => ({
|
|
344
|
+
slots: {
|
|
345
|
+
root: "",
|
|
346
|
+
base: "space-y-4",
|
|
347
|
+
collapsible: "space-y-4",
|
|
348
|
+
header: "",
|
|
349
|
+
footer: "",
|
|
350
|
+
actions: ""
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
const starRating = () => ({
|
|
355
|
+
slots: {
|
|
356
|
+
root: "inline-flex items-center gap-1",
|
|
357
|
+
stars: "flex items-center gap-0.5",
|
|
358
|
+
star: "transition-all duration-150"
|
|
359
|
+
},
|
|
360
|
+
variants: {
|
|
361
|
+
interactive: {
|
|
362
|
+
true: { star: "cursor-pointer hover:scale-110" }
|
|
363
|
+
},
|
|
364
|
+
disabled: {
|
|
365
|
+
true: { star: "cursor-not-allowed opacity-50" }
|
|
366
|
+
},
|
|
367
|
+
readonly: {
|
|
368
|
+
true: { star: "cursor-default" }
|
|
369
|
+
},
|
|
370
|
+
fieldGroup: {
|
|
371
|
+
horizontal: {
|
|
372
|
+
root: "rounded-md bg-default ring ring-inset ring-accented px-1 not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]"
|
|
373
|
+
},
|
|
374
|
+
vertical: {
|
|
375
|
+
root: "rounded-md bg-default ring ring-inset ring-accented px-1 not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const pillGroup = () => ({
|
|
382
|
+
slots: {
|
|
383
|
+
root: "flex items-center gap-2",
|
|
384
|
+
list: "relative flex group rounded-lg gap-1",
|
|
385
|
+
item: "inline-flex items-center gap-1.5",
|
|
386
|
+
leading: "inline-flex items-center shrink-0",
|
|
387
|
+
leadingIcon: "shrink-0",
|
|
388
|
+
trailing: "inline-flex items-center shrink-0",
|
|
389
|
+
trailingIcon: "shrink-0",
|
|
390
|
+
itemWrapper: "flex flex-col items-start min-w-0 gap-0.5",
|
|
391
|
+
itemLabel: "truncate",
|
|
392
|
+
itemDescription: "truncate text-xs"
|
|
393
|
+
},
|
|
394
|
+
variants: {
|
|
395
|
+
orientation: {
|
|
396
|
+
horizontal: { root: "flex-col", list: "w-full" },
|
|
397
|
+
vertical: { list: "flex-col" }
|
|
398
|
+
},
|
|
399
|
+
fieldGroup: {
|
|
400
|
+
horizontal: {
|
|
401
|
+
root: "rounded-md overflow-hidden not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-within:z-[1]",
|
|
402
|
+
list: "rounded-md"
|
|
403
|
+
},
|
|
404
|
+
vertical: {
|
|
405
|
+
root: "rounded-md overflow-hidden not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-within:z-[1]",
|
|
406
|
+
list: "rounded-md"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const theme = {
|
|
413
|
+
__proto__: null,
|
|
414
|
+
asPhoneNumberInput: asPhoneNumberInput,
|
|
415
|
+
autoForm: autoForm,
|
|
416
|
+
colorChooser: colorChooser,
|
|
417
|
+
dataTable: dataTable,
|
|
418
|
+
dataTablePagination: dataTablePagination,
|
|
419
|
+
datePicker: datePicker,
|
|
420
|
+
messageBox: messageBox,
|
|
421
|
+
pillGroup: pillGroup,
|
|
422
|
+
popconfirm: popconfirm,
|
|
423
|
+
searchForm: searchForm,
|
|
424
|
+
slideVerify: slideVerify,
|
|
425
|
+
starRating: starRating,
|
|
426
|
+
themePicker: themePicker,
|
|
427
|
+
withCharacterLimit: withCharacterLimit,
|
|
428
|
+
withClear: withClear,
|
|
429
|
+
withCopy: withCopy,
|
|
430
|
+
withFloatingLabel: withFloatingLabel,
|
|
431
|
+
withPasswordToggle: withPasswordToggle
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
function prefixClasses(classString, prefix) {
|
|
435
|
+
if (!prefix || !classString) {
|
|
436
|
+
return classString;
|
|
437
|
+
}
|
|
438
|
+
return classString.split(" ").filter(Boolean).map((cls) => `${prefix}:${cls}`).join(" ");
|
|
439
|
+
}
|
|
440
|
+
function isSizeValue(value) {
|
|
441
|
+
return /^(?:[23]x[sl]|xs|sm|md|lg|xl)$/.test(value.trim());
|
|
442
|
+
}
|
|
443
|
+
function applyPrefixToObject(obj, prefix, context = []) {
|
|
444
|
+
if (!obj || !prefix) {
|
|
445
|
+
return obj;
|
|
446
|
+
}
|
|
447
|
+
const currentKey = context[context.length - 1];
|
|
448
|
+
const compoundVariantsIndex = context.indexOf("compoundVariants");
|
|
449
|
+
const isInCompoundVariant = compoundVariantsIndex !== -1 && !context.slice(compoundVariantsIndex).includes("class");
|
|
450
|
+
const isInDefaultVariants = context.includes("defaultVariants");
|
|
451
|
+
const isComponentSizeValue = typeof obj === "string" && typeof currentKey === "string" && currentKey.endsWith("Size") && isSizeValue(obj);
|
|
452
|
+
if (typeof obj === "string" && (isInCompoundVariant || isInDefaultVariants || isComponentSizeValue)) {
|
|
453
|
+
return obj;
|
|
454
|
+
}
|
|
455
|
+
if (typeof obj === "string") {
|
|
456
|
+
return prefixClasses(obj, prefix);
|
|
457
|
+
}
|
|
458
|
+
if (Array.isArray(obj)) {
|
|
459
|
+
return obj.map((item, index) => applyPrefixToObject(item, prefix, [...context, String(index)]));
|
|
460
|
+
}
|
|
461
|
+
if (typeof obj === "object") {
|
|
462
|
+
const result = {};
|
|
463
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
464
|
+
result[key] = applyPrefixToObject(value, prefix, [...context, key]);
|
|
465
|
+
}
|
|
466
|
+
return result;
|
|
467
|
+
}
|
|
468
|
+
return obj;
|
|
469
|
+
}
|
|
470
|
+
function applyDefaultVariants(result, defaultVariants) {
|
|
471
|
+
if (!result || !defaultVariants) {
|
|
472
|
+
return result;
|
|
473
|
+
}
|
|
474
|
+
if (defaultVariants.color && result.defaultVariants?.color && result.defaultVariants.color === "primary") {
|
|
475
|
+
result.defaultVariants.color = defaultVariants.color;
|
|
476
|
+
}
|
|
477
|
+
if (defaultVariants.size && result.defaultVariants?.size && result.defaultVariants.size === "md") {
|
|
478
|
+
result.defaultVariants.size = defaultVariants.size;
|
|
479
|
+
}
|
|
480
|
+
return result;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getTemplates(options, nuxt) {
|
|
484
|
+
const templates = [];
|
|
485
|
+
function writeThemeTemplate(theme2, path) {
|
|
486
|
+
for (const component in theme2) {
|
|
487
|
+
templates.push({
|
|
488
|
+
filename: `movk-ui/${""}${kebabCase(component)}.ts`,
|
|
489
|
+
write: true,
|
|
490
|
+
getContents: async () => {
|
|
491
|
+
const template = theme2[component];
|
|
492
|
+
let result = typeof template === "function" ? template(options) : template;
|
|
493
|
+
result = applyDefaultVariants(result, options.theme?.defaultVariants);
|
|
494
|
+
result = applyPrefixToObject(result, options.theme?.prefix);
|
|
495
|
+
const variants = Object.entries(result.variants || {}).filter(([_, values]) => {
|
|
496
|
+
const keys = Object.keys(values);
|
|
497
|
+
return keys.some((key) => key !== "true" && key !== "false");
|
|
498
|
+
}).map(([key]) => key);
|
|
499
|
+
let json = JSON.stringify(result, null, 2);
|
|
500
|
+
for (const variant of variants) {
|
|
501
|
+
json = json.replace(new RegExp(`("${variant}": "[^"]+")`, "g"), `$1 as typeof ${variant}[number]`);
|
|
502
|
+
json = json.replace(new RegExp(`("${variant}": \\[\\s*)((?:"[^"]+",?\\s*)+)(\\])`, "g"), (_, before, match, after) => {
|
|
503
|
+
const replaced = match.replace(/("[^"]+")/g, `$1 as typeof ${variant}[number]`);
|
|
504
|
+
return `${before}${replaced}${after}`;
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function generateVariantDeclarations(variants2) {
|
|
508
|
+
return variants2.filter((variant) => json.includes(`as typeof ${variant}`)).map((variant) => {
|
|
509
|
+
const keys = Object.keys(result.variants[variant]);
|
|
510
|
+
return `const ${variant} = ${JSON.stringify(keys, null, 2)} as const`;
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
return [
|
|
514
|
+
...generateVariantDeclarations(variants),
|
|
515
|
+
`export default ${json}`
|
|
516
|
+
].join("\n\n");
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
writeThemeTemplate(theme);
|
|
522
|
+
async function generateSources() {
|
|
523
|
+
if (!nuxt) {
|
|
524
|
+
return '@source "./movk-ui";';
|
|
525
|
+
}
|
|
526
|
+
const sources = [];
|
|
527
|
+
const layers = getLayerDirectories(nuxt).map((layer) => layer.app);
|
|
528
|
+
for (const layer of layers) {
|
|
529
|
+
sources.push(`@source "${layer}**/*";`);
|
|
530
|
+
}
|
|
531
|
+
sources.push('@source "./movk-ui";');
|
|
532
|
+
return sources.join("\n");
|
|
533
|
+
}
|
|
534
|
+
templates.push({
|
|
535
|
+
filename: "movk-ui.css",
|
|
536
|
+
write: true,
|
|
537
|
+
getContents: async () => {
|
|
538
|
+
const sources = await generateSources();
|
|
539
|
+
const inlineSafelist = '@source inline("{,sm:,md:,lg:,xl:}grid-cols-{1,2,3,4,5,6,7,8,9,10,11,12}");';
|
|
540
|
+
return `${sources}
|
|
541
|
+
${inlineSafelist}`;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
templates.push({
|
|
545
|
+
filename: "movk-ui/index.ts",
|
|
546
|
+
write: true,
|
|
547
|
+
getContents: () => [
|
|
548
|
+
...Object.keys(theme).map((component) => `export { default as ${component} } from './${kebabCase(component)}'`)
|
|
549
|
+
].join("\n")
|
|
550
|
+
});
|
|
551
|
+
templates.push({
|
|
552
|
+
filename: "types/movk-ui.d.ts",
|
|
553
|
+
getContents: () => {
|
|
554
|
+
return `import * as movkUi from '#build/movk-ui'
|
|
555
|
+
import type { TVConfig, Direction } from '@nuxt/ui'
|
|
556
|
+
import type { defaultConfig } from 'tailwind-variants'
|
|
557
|
+
import type { MovkApiPublicConfig, ApiInstance, ModuleOptions } from '@movk/nuxt'
|
|
558
|
+
import type { HookResult } from '@nuxt/schema'
|
|
559
|
+
import type { FetchContext } from 'ofetch'
|
|
560
|
+
|
|
561
|
+
type Radius = 0 | 0.125 | 0.25 | 0.375 | 0.5
|
|
562
|
+
type FontFamily = 'Alibaba PuHuiTi' | 'Public Sans' | 'DM Sans' | 'Geist' | 'Inter' | 'Poppins' | 'Outfit' | 'Raleway'
|
|
563
|
+
type Icons = 'lucide' | 'phosphor' | 'tabler'
|
|
564
|
+
|
|
565
|
+
interface PickerFontEntry {
|
|
566
|
+
name: string
|
|
567
|
+
href?: string
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
type AppConfigUI = {
|
|
571
|
+
dir?: Direction,
|
|
572
|
+
radius?: Radius | (number & {})
|
|
573
|
+
blackAsPrimary?: boolean
|
|
574
|
+
font?: FontFamily | (string & {})
|
|
575
|
+
icons?: Icons | (string & {})
|
|
576
|
+
prefix?: string
|
|
577
|
+
tv?: typeof defaultConfig
|
|
578
|
+
picker?: {
|
|
579
|
+
fonts?: PickerFontEntry[]
|
|
580
|
+
radiuses?: number[]
|
|
581
|
+
neutralColors?: string[]
|
|
582
|
+
}
|
|
583
|
+
} & TVConfig<typeof movkUi>
|
|
584
|
+
|
|
585
|
+
declare module 'nuxt/app' {
|
|
586
|
+
interface NuxtApp {
|
|
587
|
+
$api: ApiInstance
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
interface RuntimeNuxtHooks {
|
|
591
|
+
'movk:api:request': (context: FetchContext) => HookResult
|
|
592
|
+
'movk:api:response': (context: FetchContext) => HookResult
|
|
593
|
+
'movk:api:error': (context: FetchContext) => HookResult
|
|
594
|
+
'movk:api:unauthorized': (context: FetchContext, result: { handled: boolean }) => HookResult
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
declare module 'nuxt/schema' {
|
|
599
|
+
interface NuxtOptions {
|
|
600
|
+
['movk']: ModuleOptions
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
interface AppConfig {
|
|
604
|
+
/**
|
|
605
|
+
* Movk UI theme configuration
|
|
606
|
+
* @see https://nuxt.mhaibaraai.cn/docs/getting-started/theme
|
|
607
|
+
*/
|
|
608
|
+
movk?: AppConfigUI
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
interface PublicRuntimeConfig {
|
|
612
|
+
movkApi: MovkApiPublicConfig
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
interface RuntimeConfig {
|
|
616
|
+
movkApi: { endpoints?: Record<string, { headers?: Record<string, string> }> }
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
declare module '@nuxt/schema' {
|
|
621
|
+
interface NuxtOptions {
|
|
622
|
+
['movk']: ModuleOptions
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
interface AppConfigInput {
|
|
626
|
+
/**
|
|
627
|
+
* Movk UI theme configuration
|
|
628
|
+
* @see https://nuxt.mhaibaraai.cn/docs/getting-started/theme
|
|
629
|
+
*/
|
|
630
|
+
movk?: AppConfigUI
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export {}
|
|
635
|
+
`;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
templates.push({
|
|
639
|
+
filename: "types/movk-api-endpoints.d.ts",
|
|
640
|
+
getContents: () => {
|
|
641
|
+
const endpoints = options.api?.endpoints;
|
|
642
|
+
const keys = endpoints && Object.keys(endpoints).length > 0 ? Object.keys(endpoints) : ["default"];
|
|
643
|
+
const entries = keys.map((key) => ` ${JSON.stringify(key)}: true`).join("\n");
|
|
644
|
+
return `declare module '@movk/nuxt' {
|
|
645
|
+
interface MovkApiEndpoints {
|
|
646
|
+
${entries}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export {}
|
|
651
|
+
`;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return templates;
|
|
655
|
+
}
|
|
656
|
+
async function addTemplates(options, nuxt) {
|
|
657
|
+
const templates = getTemplates(options, nuxt);
|
|
658
|
+
for (const template of templates) {
|
|
659
|
+
if (template.filename.endsWith(".d.ts")) {
|
|
660
|
+
addTypeTemplate(template);
|
|
661
|
+
} else {
|
|
662
|
+
addTemplate(template);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export { addTemplates as a, getTemplates as g };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
-
|
|
3
|
-
import type { default as Module } from './module.mjs'
|
|
4
|
-
|
|
5
|
-
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
-
|
|
7
1
|
export { default } from './module.mjs'
|
|
8
2
|
|
|
3
|
+
export { type ModuleOptions } from './module.mjs'
|
|
4
|
+
|
|
9
5
|
export * from '../dist/runtime/types/index.js'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as unplugin from 'unplugin';
|
|
2
|
+
import { NuxtUIOptions } from '@nuxt/ui/unplugin';
|
|
3
|
+
import { ModuleOptions } from './module.mjs';
|
|
4
|
+
import '@nuxt/schema';
|
|
5
|
+
import '../dist/runtime/types/api/module.js';
|
|
6
|
+
import '@nuxt/ui';
|
|
7
|
+
import '../dist/runtime/types/index.js';
|
|
8
|
+
|
|
9
|
+
interface MovkUIOptions extends Pick<ModuleOptions, 'prefix' | 'theme'> {
|
|
10
|
+
/** 站点信息,注入 app.config.movkSite;name 作为主题 localStorage key 前缀 */
|
|
11
|
+
site?: {
|
|
12
|
+
url?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Nuxt UI 配置项
|
|
18
|
+
* @see https://ui.nuxt.com/docs/getting-started/installation/vue#options
|
|
19
|
+
*/
|
|
20
|
+
ui?: Partial<NuxtUIOptions>;
|
|
21
|
+
}
|
|
22
|
+
declare const runtimeDir: string;
|
|
23
|
+
/** movk 组件层从 `#components` 具名导入的 @nuxt/ui 组件(去 U 前缀映射到 @nuxt/ui/components/<Name>.vue) */
|
|
24
|
+
declare const UI_COMPONENTS: readonly ["UAccordion", "UButton", "UBadge", "UCheckbox", "UCollapsible", "UForm", "UDropdownMenu", "UIcon", "UInput", "UModal", "UPagination", "USelect", "UPopover", "UCalendar", "UColorPicker", "UTable", "UFormField", "UTooltip", "UInputNumber", "USwitch", "UTextarea", "USlider", "UPinInput", "UInputTags", "UFileUpload", "USelectMenu", "UInputMenu", "UCheckboxGroup", "URadioGroup", "UInputDate", "UInputTime", "UListbox"];
|
|
25
|
+
declare const MovkPlugin: unplugin.UnpluginInstance<MovkUIOptions | undefined, boolean>;
|
|
26
|
+
|
|
27
|
+
export { MovkPlugin, UI_COMPONENTS, runtimeDir };
|
|
28
|
+
export type { MovkUIOptions };
|