@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
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
2
|
+
import { useAttrs } from "vue";
|
|
3
3
|
import { UInput, UButton } from "#components";
|
|
4
4
|
import { isEmpty } from "@movk/core";
|
|
5
|
+
import { useAppConfig } from "#imports";
|
|
6
|
+
import theme from "#build/movk-ui/with-floating-label";
|
|
7
|
+
import inputTheme from "#build/ui/input";
|
|
8
|
+
import { useExtendedTv } from "../../utils/extend-theme";
|
|
9
|
+
import { useFormFieldBridge, useForwardedProps } from "../../utils/form-control";
|
|
5
10
|
const props = defineProps({
|
|
6
11
|
label: { type: String, required: false },
|
|
7
|
-
|
|
8
|
-
clearButtonProps: { type: Object, required: false }
|
|
12
|
+
size: { type: null, required: false },
|
|
13
|
+
clearButtonProps: { type: Object, required: false },
|
|
14
|
+
ui: { type: Object, required: false }
|
|
9
15
|
});
|
|
10
|
-
const
|
|
16
|
+
const emits = defineEmits(["update:modelValue", "blur", "change", "clear"]);
|
|
11
17
|
const slots = defineSlots();
|
|
12
18
|
defineOptions({ inheritAttrs: false });
|
|
13
19
|
const attrs = useAttrs();
|
|
20
|
+
const appConfig = useAppConfig();
|
|
14
21
|
const modelValue = defineModel({ type: null });
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
const inputProps = useForwardedProps(props, ["ui", "label", "clearButtonProps", "placeholder", "defaultValue", "modelModifiers"]);
|
|
23
|
+
const { size: effectiveSize, emitFormChange, emitFormInput } = useFormFieldBridge(props);
|
|
24
|
+
const { baseUi, extraUi } = useExtendedTv(
|
|
25
|
+
inputTheme,
|
|
26
|
+
theme,
|
|
27
|
+
() => appConfig.movk?.withFloatingLabel,
|
|
28
|
+
() => ({
|
|
29
|
+
ui: props.ui,
|
|
30
|
+
variants: {
|
|
31
|
+
size: effectiveSize.value,
|
|
32
|
+
hasLeading: !!(attrs["leading-icon"] || attrs.avatar || attrs.leadingIcon || attrs.icon || slots.leading)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
);
|
|
27
36
|
function handleClear() {
|
|
28
37
|
modelValue.value = void 0;
|
|
29
|
-
|
|
38
|
+
emitFormInput();
|
|
39
|
+
emitFormChange();
|
|
40
|
+
emits("clear");
|
|
30
41
|
}
|
|
31
42
|
</script>
|
|
32
43
|
|
|
@@ -34,21 +45,18 @@ function handleClear() {
|
|
|
34
45
|
<UInput
|
|
35
46
|
v-model="modelValue"
|
|
36
47
|
:placeholder="props.placeholder ?? ''"
|
|
37
|
-
:ui="
|
|
38
|
-
v-bind="
|
|
39
|
-
@blur="
|
|
40
|
-
@change="
|
|
48
|
+
:ui="baseUi"
|
|
49
|
+
v-bind="{ ...inputProps, ...attrs }"
|
|
50
|
+
@blur="emits('blur', $event)"
|
|
51
|
+
@change="emits('change', $event)"
|
|
41
52
|
>
|
|
42
53
|
<template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
|
|
43
54
|
<slot :name="slotName" v-bind="slotProps ?? {}" />
|
|
44
55
|
</template>
|
|
45
56
|
|
|
46
57
|
<template v-if="props.label" #default>
|
|
47
|
-
<label
|
|
48
|
-
class="
|
|
49
|
-
:class="[labelLeftClass, props.labelClass]"
|
|
50
|
-
>
|
|
51
|
-
<span class="inline-flex bg-default px-1">{{ props.label }}</span>
|
|
58
|
+
<label :class="extraUi.label">
|
|
59
|
+
<span :class="extraUi.labelText">{{ props.label }}</span>
|
|
52
60
|
</label>
|
|
53
61
|
</template>
|
|
54
62
|
|
|
@@ -56,7 +64,7 @@ function handleClear() {
|
|
|
56
64
|
<UButton
|
|
57
65
|
color="neutral"
|
|
58
66
|
variant="link"
|
|
59
|
-
size="
|
|
67
|
+
:size="effectiveSize"
|
|
60
68
|
icon="i-lucide-circle-x"
|
|
61
69
|
aria-label="Clear input"
|
|
62
70
|
v-bind="props.clearButtonProps"
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** 浮动标签的自定义样式类 */
|
|
8
|
-
labelClass?: ClassNameValue;
|
|
9
|
-
/** 清除按钮的自定义属性 */
|
|
10
|
-
clearButtonProps?: ButtonProps;
|
|
11
|
-
}
|
|
12
|
-
export type WithFloatingLabelEmits<T extends InputValue = InputValue> = InputEmits<T> & {
|
|
13
|
-
clear: [];
|
|
14
|
-
};
|
|
1
|
+
import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
|
|
2
|
+
import type { OmitByKey } from '@movk/core';
|
|
3
|
+
import theme from '#build/movk-ui/with-floating-label';
|
|
4
|
+
import inputTheme from '#build/ui/input';
|
|
5
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
6
|
+
import type { WithFloatingLabelProps } from '../../types/components/input/with-floating-label';
|
|
15
7
|
declare const __VLS_export: <T extends InputValue>(__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<{
|
|
16
8
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithFloatingLabelProps<T> & {
|
|
9
|
+
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withFloatingLabel">["slots"];
|
|
10
|
+
} & {
|
|
17
11
|
modelValue?: T;
|
|
18
12
|
}) & {
|
|
19
|
-
|
|
13
|
+
onClear?: (() => any) | undefined;
|
|
14
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
15
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
16
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
20
17
|
}> & (typeof globalThis extends {
|
|
21
18
|
__VLS_PROPS_FALLBACK: infer P;
|
|
22
19
|
} ? P : {});
|
|
23
20
|
expose: (exposed: {}) => void;
|
|
24
21
|
attrs: any;
|
|
25
22
|
slots: OmitByKey<InputSlots, "default" | "trailing">;
|
|
26
|
-
emit:
|
|
23
|
+
emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
27
24
|
}>) => import("vue").VNode & {
|
|
28
25
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
29
26
|
};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
+
import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
|
|
1
2
|
import type { OmitByKey } from '@movk/core';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
import theme from '#build/movk-ui/with-password-toggle';
|
|
4
|
+
import inputTheme from '#build/ui/input';
|
|
5
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
6
|
+
import type { WithPasswordToggleProps } from '../../types/components/input/with-password-toggle';
|
|
7
7
|
declare const __VLS_export: <T extends InputValue>(__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<{
|
|
8
8
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
|
|
9
|
+
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
|
|
10
|
+
} & {
|
|
9
11
|
modelValue?: T;
|
|
10
12
|
}) & {
|
|
11
|
-
|
|
13
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
14
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
15
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
12
16
|
}> & (typeof globalThis extends {
|
|
13
17
|
__VLS_PROPS_FALLBACK: infer P;
|
|
14
18
|
} ? P : {});
|
|
15
19
|
expose: (exposed: {}) => void;
|
|
16
20
|
attrs: any;
|
|
17
21
|
slots: OmitByKey<InputSlots, "trailing">;
|
|
18
|
-
emit:
|
|
22
|
+
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
19
23
|
}>) => import("vue").VNode & {
|
|
20
24
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
21
25
|
};
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { useAttrs } from "vue";
|
|
2
3
|
import { UInput, UButton } from "#components";
|
|
3
4
|
import { useToggle } from "@vueuse/core";
|
|
5
|
+
import { useAppConfig } from "#imports";
|
|
6
|
+
import theme from "#build/movk-ui/with-password-toggle";
|
|
7
|
+
import inputTheme from "#build/ui/input";
|
|
8
|
+
import { useExtendedTv } from "../../utils/extend-theme";
|
|
9
|
+
import { useFormFieldBridge, useForwardedProps } from "../../utils/form-control";
|
|
4
10
|
const props = defineProps({
|
|
5
|
-
buttonProps: { type: Object, required: false }
|
|
11
|
+
buttonProps: { type: Object, required: false },
|
|
12
|
+
ui: { type: Object, required: false }
|
|
6
13
|
});
|
|
7
|
-
const
|
|
14
|
+
const emits = defineEmits(["update:modelValue", "blur", "change"]);
|
|
8
15
|
const slots = defineSlots();
|
|
9
16
|
defineOptions({ inheritAttrs: false });
|
|
17
|
+
const attrs = useAttrs();
|
|
18
|
+
const appConfig = useAppConfig();
|
|
10
19
|
const modelValue = defineModel({ type: null });
|
|
20
|
+
const inputProps = useForwardedProps(props, ["ui", "buttonProps", "defaultValue", "modelModifiers"]);
|
|
21
|
+
const { size: buttonSize } = useFormFieldBridge(props);
|
|
22
|
+
const { baseUi } = useExtendedTv(
|
|
23
|
+
inputTheme,
|
|
24
|
+
theme,
|
|
25
|
+
() => appConfig.movk?.withPasswordToggle,
|
|
26
|
+
() => ({ ui: props.ui })
|
|
27
|
+
);
|
|
11
28
|
const [value, toggle] = useToggle(false);
|
|
12
29
|
</script>
|
|
13
30
|
|
|
@@ -15,10 +32,10 @@ const [value, toggle] = useToggle(false);
|
|
|
15
32
|
<UInput
|
|
16
33
|
v-model="modelValue"
|
|
17
34
|
:type="value ? 'text' : 'password'"
|
|
18
|
-
:ui="
|
|
19
|
-
v-bind="
|
|
20
|
-
@blur="
|
|
21
|
-
@change="
|
|
35
|
+
:ui="baseUi"
|
|
36
|
+
v-bind="{ ...inputProps, ...attrs }"
|
|
37
|
+
@blur="emits('blur', $event)"
|
|
38
|
+
@change="emits('change', $event)"
|
|
22
39
|
>
|
|
23
40
|
<template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
|
|
24
41
|
<slot :name="slotName" v-bind="slotProps ?? {}" />
|
|
@@ -28,7 +45,7 @@ const [value, toggle] = useToggle(false);
|
|
|
28
45
|
<UButton
|
|
29
46
|
color="neutral"
|
|
30
47
|
variant="link"
|
|
31
|
-
size="
|
|
48
|
+
:size="buttonSize"
|
|
32
49
|
:icon="value ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
|
33
50
|
:aria-label="value ? 'Hide password' : 'Show password'"
|
|
34
51
|
:aria-pressed="value"
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
+
import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
|
|
1
2
|
import type { OmitByKey } from '@movk/core';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
import theme from '#build/movk-ui/with-password-toggle';
|
|
4
|
+
import inputTheme from '#build/ui/input';
|
|
5
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
6
|
+
import type { WithPasswordToggleProps } from '../../types/components/input/with-password-toggle';
|
|
7
7
|
declare const __VLS_export: <T extends InputValue>(__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<{
|
|
8
8
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
|
|
9
|
+
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
|
|
10
|
+
} & {
|
|
9
11
|
modelValue?: T;
|
|
10
12
|
}) & {
|
|
11
|
-
|
|
13
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
14
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
15
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
12
16
|
}> & (typeof globalThis extends {
|
|
13
17
|
__VLS_PROPS_FALLBACK: infer P;
|
|
14
18
|
} ? P : {});
|
|
15
19
|
expose: (exposed: {}) => void;
|
|
16
20
|
attrs: any;
|
|
17
21
|
slots: OmitByKey<InputSlots, "trailing">;
|
|
18
|
-
emit:
|
|
22
|
+
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
19
23
|
}>) => import("vue").VNode & {
|
|
20
24
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
21
25
|
};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ComponentConfig } from '@nuxt/ui';
|
|
2
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
3
|
+
import theme from '#build/movk-ui/theme-picker';
|
|
4
|
+
import popoverTheme from '#build/ui/popover';
|
|
5
|
+
interface ThemePickerProps {
|
|
6
|
+
ui?: ComponentConfig<typeof popoverTheme & typeof theme, AppConfig, 'themePicker'>['slots'];
|
|
7
|
+
}
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<ThemePickerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
9
|
declare const _default: typeof __VLS_export;
|
|
3
10
|
export default _default;
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useColorMode } from "#imports";
|
|
2
|
+
import { useAppConfig, useColorMode } from "#imports";
|
|
3
3
|
import { useClipboard } from "@vueuse/core";
|
|
4
4
|
import { ref } from "vue";
|
|
5
|
-
import { useTheme } from "../../composables";
|
|
5
|
+
import { useTheme } from "../../composables/useTheme";
|
|
6
6
|
import ThemePickerButton from "./ThemePickerButton.vue";
|
|
7
|
+
import theme from "#build/movk-ui/theme-picker";
|
|
8
|
+
import popoverTheme from "#build/ui/popover";
|
|
9
|
+
import { useExtendedTv } from "../../utils/extend-theme";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
ui: { type: Object, required: false }
|
|
12
|
+
});
|
|
13
|
+
const appConfig = useAppConfig();
|
|
7
14
|
const colorMode = useColorMode();
|
|
15
|
+
const { extendUi } = useExtendedTv(
|
|
16
|
+
popoverTheme,
|
|
17
|
+
theme,
|
|
18
|
+
() => appConfig.movk?.themePicker,
|
|
19
|
+
() => ({ ui: props.ui })
|
|
20
|
+
);
|
|
8
21
|
const open = ref(false);
|
|
9
22
|
const { copy: copyCSS, copied: copiedCSS } = useClipboard();
|
|
10
|
-
const { copy:
|
|
23
|
+
const { copy: copyConfig, copied: copiedConfig } = useClipboard();
|
|
11
24
|
const {
|
|
12
25
|
neutralColors,
|
|
13
26
|
neutral,
|
|
14
27
|
primaryColors,
|
|
15
28
|
primary,
|
|
16
29
|
blackAsPrimary,
|
|
30
|
+
setBlackAsPrimary,
|
|
17
31
|
radiuses,
|
|
18
32
|
radius,
|
|
19
33
|
fonts,
|
|
@@ -23,15 +37,16 @@ const {
|
|
|
23
37
|
modes,
|
|
24
38
|
mode,
|
|
25
39
|
hasCSSChanges,
|
|
26
|
-
|
|
40
|
+
hasConfigChanges,
|
|
41
|
+
configLabel,
|
|
27
42
|
exportCSS,
|
|
28
|
-
|
|
43
|
+
exportConfig,
|
|
29
44
|
resetTheme
|
|
30
45
|
} = useTheme();
|
|
31
46
|
</script>
|
|
32
47
|
|
|
33
48
|
<template>
|
|
34
|
-
<UPopover v-model:open="open" :ui="
|
|
49
|
+
<UPopover v-model:open="open" :ui="extendUi">
|
|
35
50
|
<template #default>
|
|
36
51
|
<UButton
|
|
37
52
|
icon="i-lucide-swatch-book"
|
|
@@ -63,7 +78,7 @@ const {
|
|
|
63
78
|
<ThemePickerButton
|
|
64
79
|
label="Black"
|
|
65
80
|
:selected="blackAsPrimary"
|
|
66
|
-
@click="
|
|
81
|
+
@click="setBlackAsPrimary(true)"
|
|
67
82
|
>
|
|
68
83
|
<template #leading>
|
|
69
84
|
<span class="inline-block size-2 rounded-full bg-black dark:bg-white" />
|
|
@@ -217,7 +232,7 @@ const {
|
|
|
217
232
|
</div>
|
|
218
233
|
</fieldset>
|
|
219
234
|
|
|
220
|
-
<fieldset v-if="hasCSSChanges ||
|
|
235
|
+
<fieldset v-if="hasCSSChanges || hasConfigChanges">
|
|
221
236
|
<legend class="text-[11px] leading-none font-semibold mb-2 select-none">
|
|
222
237
|
Export
|
|
223
238
|
</legend>
|
|
@@ -234,14 +249,14 @@ const {
|
|
|
234
249
|
@click="copyCSS(exportCSS())"
|
|
235
250
|
/>
|
|
236
251
|
<UButton
|
|
237
|
-
v-if="
|
|
252
|
+
v-if="hasConfigChanges"
|
|
238
253
|
color="neutral"
|
|
239
254
|
variant="soft"
|
|
240
255
|
size="sm"
|
|
241
|
-
label="
|
|
242
|
-
:icon="
|
|
256
|
+
:label="configLabel"
|
|
257
|
+
:icon="copiedConfig ? 'i-lucide-copy-check' : 'i-lucide-copy'"
|
|
243
258
|
class="flex-1 text-[11px]"
|
|
244
|
-
@click="
|
|
259
|
+
@click="copyConfig(exportConfig())"
|
|
245
260
|
/>
|
|
246
261
|
<UTooltip text="Reset theme">
|
|
247
262
|
<UButton
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ComponentConfig } from '@nuxt/ui';
|
|
2
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
3
|
+
import theme from '#build/movk-ui/theme-picker';
|
|
4
|
+
import popoverTheme from '#build/ui/popover';
|
|
5
|
+
interface ThemePickerProps {
|
|
6
|
+
ui?: ComponentConfig<typeof popoverTheme & typeof theme, AppConfig, 'themePicker'>['slots'];
|
|
7
|
+
}
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<ThemePickerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
9
|
declare const _default: typeof __VLS_export;
|
|
3
10
|
export default _default;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
interface ThemePickerButtonProps {
|
|
2
|
+
label: string;
|
|
3
|
+
icon?: string;
|
|
4
|
+
chip?: string;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ThemePickerButtonSlots {
|
|
2
8
|
leading: () => any;
|
|
3
|
-
}
|
|
4
|
-
declare const __VLS_base: any;
|
|
5
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
}
|
|
6
10
|
declare const _default: typeof __VLS_export;
|
|
7
11
|
export default _default;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ThemePickerButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerButtonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ThemePickerButtonSlots>;
|
|
8
13
|
type __VLS_WithSlots<T, S> = T & {
|
|
9
14
|
new (): {
|
|
10
15
|
$slots: S;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
interface ThemePickerButtonProps {
|
|
2
|
+
label: string;
|
|
3
|
+
icon?: string;
|
|
4
|
+
chip?: string;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ThemePickerButtonSlots {
|
|
2
8
|
leading: () => any;
|
|
3
|
-
}
|
|
4
|
-
declare const __VLS_base: any;
|
|
5
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
}
|
|
6
10
|
declare const _default: typeof __VLS_export;
|
|
7
11
|
export default _default;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ThemePickerButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerButtonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ThemePickerButtonSlots>;
|
|
8
13
|
type __VLS_WithSlots<T, S> = T & {
|
|
9
14
|
new (): {
|
|
10
15
|
$slots: S;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from './useApiFetch
|
|
2
|
-
export * from './useLazyApiFetch
|
|
3
|
-
export * from './useClientApiFetch
|
|
4
|
-
export * from './useDownloadWithProgress
|
|
5
|
-
export * from './useUploadWithProgress
|
|
6
|
-
export * from './useAutoForm
|
|
7
|
-
export * from './useTheme
|
|
8
|
-
export * from './useDateFormatter
|
|
1
|
+
export * from './useApiFetch';
|
|
2
|
+
export * from './useLazyApiFetch';
|
|
3
|
+
export * from './useClientApiFetch';
|
|
4
|
+
export * from './useDownloadWithProgress';
|
|
5
|
+
export * from './useUploadWithProgress';
|
|
6
|
+
export * from './useAutoForm';
|
|
7
|
+
export * from './useTheme';
|
|
8
|
+
export * from './useDateFormatter';
|
|
9
|
+
export * from './useMessageBox';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
+
import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
|
|
2
3
|
/**
|
|
3
4
|
* API Fetch 组合式函数
|
|
4
5
|
*
|
|
5
6
|
* 基于 Nuxt useFetch 的薄封装,自动注入 $api 实例。
|
|
6
7
|
* 所有核心能力(认证、业务检查、数据解包、Toast)由 $api interceptors 统一处理。
|
|
7
8
|
*
|
|
8
|
-
* @typeParam T -
|
|
9
|
+
* @typeParam T - 业务数据类型(默认已由 $api 自动解包;skipUnwrap 时为原始响应类型)
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```ts
|
|
@@ -31,15 +32,19 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
|
|
|
31
32
|
* toast: { successMessage: '加载成功' }
|
|
32
33
|
* })
|
|
33
34
|
*
|
|
34
|
-
* //
|
|
35
|
-
* const { data } = await useApiFetch('/
|
|
35
|
+
* // 跳过业务状态码校验(仍按 dataKey 解包,适合 code 字段缺失的场景)
|
|
36
|
+
* const { data } = await useApiFetch('/legacy', { skipBusinessCheck: true })
|
|
37
|
+
*
|
|
38
|
+
* // 跳过解包,拿原始响应(与 skipBusinessCheck 正交)
|
|
39
|
+
* const { data } = await useApiFetch<ApiResponse>('/external', { skipUnwrap: true })
|
|
36
40
|
*
|
|
37
41
|
* // 用户自定义 hooks(通过 useFetch 原生选项透传)
|
|
38
42
|
* const { data } = await useApiFetch('/users', {
|
|
39
43
|
* onResponse({ response }) {
|
|
44
|
+
* // response._data 已是解包后的业务数据(除非传入 skipUnwrap: true)
|
|
40
45
|
* console.log('自定义处理:', response._data)
|
|
41
46
|
* }
|
|
42
47
|
* })
|
|
43
48
|
* ```
|
|
44
49
|
*/
|
|
45
|
-
export declare function useApiFetch<T = unknown, DataT = T>(url:
|
|
50
|
+
export declare function useApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import { useNuxtApp, useFetch } from "#app";
|
|
3
|
+
import { buildApiFetchKey } from "../domains/api/fetch-key.js";
|
|
2
4
|
export function useApiFetch(url, options = {}) {
|
|
3
5
|
const { $api } = useNuxtApp();
|
|
4
6
|
const {
|
|
5
7
|
endpoint,
|
|
6
8
|
toast,
|
|
7
9
|
skipBusinessCheck,
|
|
10
|
+
skipUnwrap,
|
|
8
11
|
...fetchOptions
|
|
9
12
|
} = options;
|
|
10
13
|
const apiInstance = endpoint ? $api.use(endpoint) : $api;
|
|
14
|
+
const fetchKey = computed(() => {
|
|
15
|
+
const userKey = toValue(fetchOptions.key);
|
|
16
|
+
if (userKey) return userKey;
|
|
17
|
+
return buildApiFetchKey({
|
|
18
|
+
endpoint,
|
|
19
|
+
skipUnwrap,
|
|
20
|
+
skipBusinessCheck,
|
|
21
|
+
toast,
|
|
22
|
+
method: toValue(fetchOptions.method),
|
|
23
|
+
url: typeof url === "function" ? url() : url,
|
|
24
|
+
query: toValue(fetchOptions.query),
|
|
25
|
+
body: toValue(fetchOptions.body)
|
|
26
|
+
});
|
|
27
|
+
});
|
|
11
28
|
return useFetch(url, {
|
|
12
29
|
...fetchOptions,
|
|
30
|
+
key: fetchKey,
|
|
13
31
|
$fetch: apiInstance,
|
|
14
|
-
context: { toast, skipBusinessCheck }
|
|
32
|
+
context: { toast, skipBusinessCheck, skipUnwrap }
|
|
15
33
|
});
|
|
16
34
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { AutoFormControls, TypedZodFactory } from '../types/auto-form
|
|
2
|
-
import { getAutoFormMetadata } from '../auto-form/metadata
|
|
3
|
-
import { DEFAULT_CONTROLS, defineControl } from '../auto-form/controls
|
|
4
|
-
export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
|
|
1
|
+
import type { AutoFormControls, TypedZodFactory } from '../types/auto-form';
|
|
2
|
+
import { getAutoFormMetadata } from '../domains/auto-form/metadata';
|
|
3
|
+
import { DEFAULT_CONTROLS, defineControl } from '../domains/auto-form/controls';
|
|
5
4
|
type UseAutoFormReturn<TControls extends AutoFormControls> = {
|
|
6
5
|
defineControl: typeof defineControl;
|
|
7
6
|
afz: TypedZodFactory<TControls>;
|
|
@@ -15,3 +14,4 @@ type UseAutoFormReturn<TControls extends AutoFormControls> = {
|
|
|
15
14
|
*/
|
|
16
15
|
export declare function useAutoForm(): UseAutoFormReturn<typeof DEFAULT_CONTROLS>;
|
|
17
16
|
export declare function useAutoForm<const TControls extends AutoFormControls>(controls: TControls): UseAutoFormReturn<typeof DEFAULT_CONTROLS & TControls>;
|
|
17
|
+
export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { isObject } from "@movk/core";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { extractEnumValuesFromItems } from "../auto-form/field-utils.js";
|
|
3
|
+
import { applyMeta, extractErrorAndMeta, getAutoFormMetadata } from "../domains/auto-form/metadata.js";
|
|
4
|
+
import { DEFAULT_CONTROLS, defineControl } from "../domains/auto-form/controls.js";
|
|
5
|
+
import { extractEnumValuesFromItems } from "../domains/auto-form/fields.js";
|
|
7
6
|
import { useDateFormatter } from "./useDateFormatter.js";
|
|
7
|
+
import { AUTOFORM_META } from "../domains/auto-form/constants.js";
|
|
8
8
|
function createBasicFactory(zodFactory) {
|
|
9
9
|
return (controlMeta) => {
|
|
10
10
|
const [error, meta] = extractErrorAndMeta(controlMeta);
|
|
@@ -12,19 +12,33 @@ function createBasicFactory(zodFactory) {
|
|
|
12
12
|
return applyMeta(schema, meta || {});
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
const DEFAULT_VALUE_FORMAT = "date-value";
|
|
16
|
+
const VALUE_FORMATS = ["date-value", "iso", "timestamp", "unix", "date"];
|
|
17
|
+
function isValueFormat(value) {
|
|
18
|
+
return typeof value === "string" && VALUE_FORMATS.includes(value);
|
|
19
|
+
}
|
|
20
|
+
function resolveStaticValueFormat(meta) {
|
|
21
|
+
if (!isObject(meta)) return DEFAULT_VALUE_FORMAT;
|
|
22
|
+
const controlProps = meta.controlProps;
|
|
23
|
+
if (!isObject(controlProps)) return DEFAULT_VALUE_FORMAT;
|
|
24
|
+
const valueFormat = controlProps.valueFormat;
|
|
25
|
+
return isValueFormat(valueFormat) ? valueFormat : DEFAULT_VALUE_FORMAT;
|
|
26
|
+
}
|
|
15
27
|
function createCalendarDateFactory(type = "calendarDate") {
|
|
16
|
-
const {
|
|
28
|
+
const { fromFormat, isDateRange } = useDateFormatter();
|
|
17
29
|
return (controlMeta) => {
|
|
18
30
|
const [error, meta] = extractErrorAndMeta(controlMeta);
|
|
31
|
+
const valueFormat = resolveStaticValueFormat(meta);
|
|
32
|
+
const isValidDateValue = (value) => fromFormat(value, valueFormat) !== null;
|
|
19
33
|
const schema = z.custom().refine(
|
|
20
34
|
(val) => {
|
|
21
|
-
if (
|
|
35
|
+
if (isValidDateValue(val)) return true;
|
|
22
36
|
if (isDateRange(val)) {
|
|
23
37
|
const range = val;
|
|
24
|
-
return
|
|
38
|
+
return isValidDateValue(range.start) && isValidDateValue(range.end);
|
|
25
39
|
}
|
|
26
40
|
if (Array.isArray(val)) {
|
|
27
|
-
return val.length > 0 && val.every(
|
|
41
|
+
return val.length > 0 && val.every(isValidDateValue);
|
|
28
42
|
}
|
|
29
43
|
return false;
|
|
30
44
|
},
|
|
@@ -88,7 +102,6 @@ function createEnumFactory() {
|
|
|
88
102
|
return applyOverwrite(z.enum(enumValues), overwrite);
|
|
89
103
|
};
|
|
90
104
|
}
|
|
91
|
-
export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
|
|
92
105
|
export function useAutoForm(controls) {
|
|
93
106
|
function createZodFactory() {
|
|
94
107
|
return {
|
|
@@ -124,3 +137,4 @@ export function useAutoForm(controls) {
|
|
|
124
137
|
getAutoFormMetadata
|
|
125
138
|
};
|
|
126
139
|
}
|
|
140
|
+
export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
+
import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
|
|
2
3
|
/**
|
|
3
4
|
* 仅客户端执行的 useApiFetch
|
|
4
5
|
*
|
|
@@ -20,4 +21,4 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
|
|
|
20
21
|
* })
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
23
|
-
export declare function useClientApiFetch<T = unknown, DataT = T>(url:
|
|
24
|
+
export declare function useClientApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
|