@movk/nuxt 1.8.3 → 2.0.0-beta.1
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/README.en.md +16 -6
- package/README.md +16 -6
- package/dist/module.d.mts +6 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -22
- package/dist/runtime/components/AutoForm.d.vue.ts +15 -1
- package/dist/runtime/components/AutoForm.vue +48 -50
- package/dist/runtime/components/AutoForm.vue.d.ts +15 -1
- package/dist/runtime/components/DataTable.d.vue.ts +4 -2
- package/dist/runtime/components/DataTable.vue +166 -174
- package/dist/runtime/components/DataTable.vue.d.ts +4 -2
- package/dist/runtime/components/DatePicker.d.vue.ts +6 -5
- package/dist/runtime/components/DatePicker.vue +96 -43
- package/dist/runtime/components/DatePicker.vue.d.ts +6 -5
- package/dist/runtime/components/MessageBox.d.vue.ts +1 -5
- package/dist/runtime/components/MessageBox.vue +9 -7
- package/dist/runtime/components/MessageBox.vue.d.ts +1 -5
- package/dist/runtime/components/SearchForm.d.vue.ts +12 -4
- package/dist/runtime/components/SearchForm.vue +130 -120
- package/dist/runtime/components/SearchForm.vue.d.ts +12 -4
- package/dist/runtime/components/Tree.d.vue.ts +3 -1
- package/dist/runtime/components/Tree.vue +102 -140
- package/dist/runtime/components/Tree.vue.d.ts +3 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +5 -3
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +15 -6
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +7 -7
- package/dist/runtime/composables/useApiFetch.js +5 -23
- package/dist/runtime/composables/useAutoForm.js +2 -2
- package/dist/runtime/composables/useClientApiFetch.d.ts +5 -5
- package/dist/runtime/composables/useDateFormatter.d.ts +32 -34
- package/dist/runtime/composables/useDateFormatter.js +75 -232
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +11 -8
- package/dist/runtime/composables/useDownloadWithProgress.js +49 -132
- package/dist/runtime/composables/useMessageBox.js +3 -2
- package/dist/runtime/composables/useMovkLocale.d.ts +16 -0
- package/dist/runtime/composables/useMovkLocale.js +20 -0
- package/dist/runtime/composables/useTheme.js +8 -18
- package/dist/runtime/composables/useUploadWithProgress.d.ts +9 -6
- package/dist/runtime/composables/useUploadWithProgress.js +50 -84
- package/dist/runtime/domains/ai/chat-transport.js +1 -0
- package/dist/runtime/domains/api/adapters/xhr.d.ts +17 -0
- package/dist/runtime/domains/api/adapters/xhr.js +55 -0
- package/dist/runtime/domains/api/auth.d.ts +4 -1
- package/dist/runtime/domains/api/auth.js +6 -7
- package/dist/runtime/domains/api/client.d.ts +13 -0
- package/dist/runtime/domains/api/client.js +35 -0
- package/dist/runtime/domains/api/download.d.ts +10 -0
- package/dist/runtime/domains/api/download.js +28 -0
- package/dist/runtime/domains/api/errors.d.ts +20 -2
- package/dist/runtime/domains/api/errors.js +61 -8
- package/dist/runtime/domains/api/fetch-key.d.ts +2 -2
- package/dist/runtime/domains/api/fetch-key.js +4 -4
- package/dist/runtime/domains/api/interceptors/request.d.ts +2 -6
- package/dist/runtime/domains/api/interceptors/request.js +3 -2
- package/dist/runtime/domains/api/interceptors/response.d.ts +8 -14
- package/dist/runtime/domains/api/interceptors/response.js +34 -25
- package/dist/runtime/domains/api/report.d.ts +25 -0
- package/dist/runtime/domains/api/report.js +51 -0
- package/dist/runtime/domains/api/response.d.ts +29 -4
- package/dist/runtime/domains/api/response.js +27 -6
- package/dist/runtime/domains/api/session.d.ts +1 -1
- package/dist/runtime/domains/api/session.js +1 -1
- package/dist/runtime/domains/api/stream.d.ts +2 -1
- package/dist/runtime/domains/api/stream.js +2 -1
- package/dist/runtime/domains/api/toast.d.ts +6 -3
- package/dist/runtime/domains/api/toast.js +7 -7
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -1
- package/dist/runtime/domains/auto-form/actions.js +6 -4
- package/dist/runtime/domains/auto-form/array-ops.d.ts +3 -0
- package/dist/runtime/domains/auto-form/array-ops.js +9 -0
- package/dist/runtime/domains/auto-form/async-items.d.ts +10 -0
- package/dist/runtime/domains/auto-form/async-items.js +42 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Array.vue +81 -73
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Children.vue +0 -5
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.vue +9 -2
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.vue +3 -6
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.vue +5 -9
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/controls.d.ts +5 -572
- package/dist/runtime/domains/auto-form/controls.js +7 -20
- package/dist/runtime/domains/auto-form/fields.d.ts +21 -4
- package/dist/runtime/domains/auto-form/fields.js +52 -40
- package/dist/runtime/domains/auto-form/provider.d.ts +15 -6
- package/dist/runtime/domains/auto-form/provider.js +24 -10
- package/dist/runtime/domains/auto-form/schema.d.ts +9 -4
- package/dist/runtime/domains/auto-form/schema.js +91 -50
- package/dist/runtime/domains/auto-form/search-query.d.ts +10 -0
- package/dist/runtime/domains/auto-form/search-query.js +57 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.d.ts +62 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.js +108 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.d.ts +11 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.js +64 -0
- package/dist/runtime/domains/data-table/columns/constants.d.ts +2 -0
- package/dist/runtime/domains/data-table/columns/constants.js +1 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +2 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +3 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +7 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +10 -5
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +14 -8
- package/dist/runtime/domains/data-table/components/ColumnSettings.d.vue.ts +20 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue +63 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue.d.ts +20 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +2 -8
- package/dist/runtime/domains/data-table/components/Pagination.vue +34 -36
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +2 -8
- package/dist/runtime/domains/data-table/export.d.ts +23 -0
- package/dist/runtime/domains/data-table/export.js +43 -0
- package/dist/runtime/domains/data-table/load-more.d.ts +8 -0
- package/dist/runtime/domains/data-table/load-more.js +14 -0
- package/dist/runtime/domains/data-table/pagination.d.ts +29 -0
- package/dist/runtime/domains/data-table/pagination.js +42 -0
- package/dist/runtime/domains/data-table/persist.d.ts +12 -0
- package/dist/runtime/domains/data-table/persist.js +41 -0
- package/dist/runtime/domains/data-table/state/keys.d.ts +11 -0
- package/dist/runtime/domains/data-table/state/keys.js +44 -0
- package/dist/runtime/domains/data-table/state/models.d.ts +5 -0
- package/dist/runtime/domains/data-table/state/models.js +38 -0
- package/dist/runtime/domains/data-table/tree-layout.d.ts +13 -0
- package/dist/runtime/domains/data-table/tree-layout.js +30 -0
- package/dist/runtime/domains/theme/theme-color.d.ts +3 -0
- package/dist/runtime/domains/theme/theme-color.js +16 -0
- package/dist/runtime/domains/theme/theme-fouc.d.ts +5 -0
- package/dist/runtime/domains/theme/theme-fouc.js +43 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +7 -5
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +6 -4
- package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +7 -5
- package/dist/runtime/domains/tree/tree-disabled.d.ts +5 -0
- package/dist/runtime/domains/tree/tree-disabled.js +15 -0
- package/dist/runtime/domains/tree/tree-lazy.d.ts +8 -0
- package/dist/runtime/domains/tree/tree-lazy.js +19 -1
- package/dist/runtime/domains/tree/tree-search.d.ts +3 -1
- package/dist/runtime/domains/tree/tree-search.js +4 -0
- package/dist/runtime/domains/tree/useTreeLazy.d.ts +22 -0
- package/dist/runtime/domains/tree/useTreeLazy.js +57 -0
- package/dist/runtime/domains/tree/useTreeSearch.d.ts +27 -0
- package/dist/runtime/domains/tree/useTreeSearch.js +59 -0
- package/dist/runtime/domains/tree/useTreeSelection.d.ts +31 -0
- package/dist/runtime/domains/tree/useTreeSelection.js +89 -0
- package/dist/runtime/domains/zod/apply.d.ts +23 -0
- package/dist/runtime/domains/zod/apply.js +26 -0
- package/dist/runtime/domains/zod/error-map.d.ts +13 -0
- package/dist/runtime/domains/zod/error-map.js +19 -0
- package/dist/runtime/domains/zod/locale-map.d.ts +5 -0
- package/dist/runtime/domains/zod/locale-map.js +17 -0
- package/dist/runtime/domains/zod/sync.d.ts +12 -0
- package/dist/runtime/domains/zod/sync.js +30 -0
- package/dist/runtime/locale/en.d.ts +74 -0
- package/dist/runtime/locale/en.js +73 -0
- package/dist/runtime/locale/index.d.ts +8 -0
- package/dist/runtime/locale/index.js +15 -0
- package/dist/runtime/locale/zh_cn.d.ts +74 -0
- package/dist/runtime/locale/zh_cn.js +73 -0
- package/dist/runtime/plugins/api.factory.js +5 -22
- package/dist/runtime/plugins/theme.js +4 -42
- package/dist/runtime/plugins/zod.d.ts +2 -0
- package/dist/runtime/plugins/zod.js +16 -0
- package/dist/runtime/types/api/config.d.ts +12 -0
- package/dist/runtime/types/api/fetch.d.ts +3 -16
- package/dist/runtime/types/api/index.d.ts +1 -1
- package/dist/runtime/types/api/response.d.ts +33 -19
- package/dist/runtime/types/api/stream.d.ts +2 -3
- package/dist/runtime/types/api/transfer.d.ts +3 -7
- package/dist/runtime/types/auto-form/base.d.ts +9 -1
- package/dist/runtime/types/auto-form/component.d.ts +31 -3
- package/dist/runtime/types/auto-form/fields.d.ts +15 -1
- package/dist/runtime/types/auto-form/index.d.ts +3 -3
- package/dist/runtime/types/auto-form/search-form.d.ts +26 -12
- package/dist/runtime/types/auto-form/zod-factory.d.ts +2 -2
- package/dist/runtime/types/components/date-picker.d.ts +14 -3
- package/dist/runtime/types/components/index.d.ts +1 -6
- package/dist/runtime/types/components/message-box.d.ts +5 -18
- package/dist/runtime/types/components/tree.d.ts +17 -14
- package/dist/runtime/types/data-table/columns.d.ts +6 -14
- package/dist/runtime/types/data-table/component.d.ts +42 -1
- package/dist/runtime/types/data-table/index.d.ts +1 -1
- package/dist/runtime/types/data-table/pagination.d.ts +7 -8
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/locale.d.ts +82 -0
- package/dist/runtime/types/shared.d.ts +13 -0
- package/dist/runtime/types/zod-config.d.ts +38 -0
- package/dist/runtime/types/zod.d.ts +9 -1
- package/dist/runtime/utils/date/convert.d.ts +29 -0
- package/dist/runtime/utils/date/convert.js +93 -0
- package/dist/runtime/utils/date/guards.d.ts +10 -0
- package/dist/runtime/utils/date/guards.js +18 -0
- package/dist/runtime/utils/extend-theme.js +2 -1
- package/dist/runtime/utils/form-control.d.ts +0 -12
- package/dist/runtime/utils/form-control.js +3 -39
- package/dist/runtime/utils/interpolate.d.ts +2 -0
- package/dist/runtime/utils/interpolate.js +4 -0
- package/dist/runtime/utils/theme-defaults.d.ts +10 -0
- package/dist/runtime/utils/theme-defaults.js +9 -0
- package/dist/runtime/utils/tree-selection.d.ts +2 -15
- package/dist/runtime/utils/tv.d.ts +1 -1
- package/dist/runtime/vue/plugins/zod.d.ts +7 -0
- package/dist/runtime/vue/plugins/zod.js +12 -0
- package/dist/shared/{nuxt.DfVF6ZZv.mjs → nuxt.CbmfnBRt.mjs} +82 -236
- package/dist/unplugin.d.mts +3 -2
- package/dist/unplugin.mjs +22 -22
- package/dist/vite.d.mts +1 -0
- package/dist/vite.mjs +2 -1
- package/package.json +39 -34
- package/vue-plugin.d.ts +7 -1
- package/dist/runtime/components/ColorChooser.d.vue.ts +0 -36
- package/dist/runtime/components/ColorChooser.vue +0 -328
- package/dist/runtime/components/ColorChooser.vue.d.ts +0 -36
- package/dist/runtime/components/PillGroup.d.vue.ts +0 -33
- package/dist/runtime/components/PillGroup.vue +0 -291
- package/dist/runtime/components/PillGroup.vue.d.ts +0 -33
- package/dist/runtime/components/Popconfirm.d.vue.ts +0 -30
- package/dist/runtime/components/Popconfirm.vue +0 -143
- package/dist/runtime/components/Popconfirm.vue.d.ts +0 -30
- package/dist/runtime/components/SlideVerify.d.vue.ts +0 -41
- package/dist/runtime/components/SlideVerify.vue +0 -174
- package/dist/runtime/components/SlideVerify.vue.d.ts +0 -41
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +0 -32
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +0 -48
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.vue +0 -54
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithClear.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithClear.vue +0 -60
- package/dist/runtime/components/input/WithClear.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithCopy.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithCopy.vue +0 -66
- package/dist/runtime/components/input/WithCopy.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.vue +0 -75
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithPasswordToggle.vue +0 -61
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +0 -32
- package/dist/runtime/domains/api/interceptors/compose.d.ts +0 -24
- package/dist/runtime/domains/api/interceptors/compose.js +0 -18
- package/dist/runtime/domains/api/interceptors/error.d.ts +0 -13
- package/dist/runtime/domains/api/interceptors/error.js +0 -26
- package/dist/runtime/domains/api/interceptors/unauthorized.d.ts +0 -12
- package/dist/runtime/domains/api/interceptors/unauthorized.js +0 -34
- package/dist/runtime/domains/api/transfer.d.ts +0 -69
- package/dist/runtime/domains/api/transfer.js +0 -87
- package/dist/runtime/types/components/color-chooser.d.ts +0 -109
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +0 -17
- package/dist/runtime/types/components/input/index.d.ts +0 -6
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +0 -11
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +0 -10
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +0 -11
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +0 -12
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +0 -7
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +0 -103
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +0 -74
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +0 -54
- package/dist/runtime/types/components/slide-verify.js +0 -0
- /package/dist/runtime/types/{components/color-chooser.js → locale.js} +0 -0
- /package/dist/runtime/types/{components/input/as-phone-number-input.js → zod-config.js} +0 -0
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { useAttrs } from "vue";
|
|
3
|
-
import { UInput, UButton, UTooltip } from "#components";
|
|
4
|
-
import { useClipboard } from "@vueuse/core";
|
|
5
|
-
import { isEmpty } from "@movk/core";
|
|
6
|
-
import { useAppConfig } from "#imports";
|
|
7
|
-
import theme from "#build/movk-ui/with-copy";
|
|
8
|
-
import inputTheme from "#build/ui/input";
|
|
9
|
-
import { useExtendedTv } from "../../utils/extend-theme";
|
|
10
|
-
import { useFormFieldBridge, useForwardedProps } from "../../utils/form-control";
|
|
11
|
-
const props = defineProps({
|
|
12
|
-
buttonProps: { type: Object, required: false },
|
|
13
|
-
tooltipProps: { type: Object, required: false },
|
|
14
|
-
ui: { type: Object, required: false }
|
|
15
|
-
});
|
|
16
|
-
const emits = defineEmits(["update:modelValue", "blur", "change", "copy"]);
|
|
17
|
-
const slots = defineSlots();
|
|
18
|
-
defineOptions({ inheritAttrs: false });
|
|
19
|
-
const attrs = useAttrs();
|
|
20
|
-
const appConfig = useAppConfig();
|
|
21
|
-
const modelValue = defineModel({ type: null });
|
|
22
|
-
const inputProps = useForwardedProps(props, ["ui", "buttonProps", "tooltipProps", "defaultValue", "modelModifiers"]);
|
|
23
|
-
const { size: buttonSize } = useFormFieldBridge(props);
|
|
24
|
-
const { baseUi } = useExtendedTv(
|
|
25
|
-
inputTheme,
|
|
26
|
-
theme,
|
|
27
|
-
() => appConfig.movk?.withCopy,
|
|
28
|
-
() => ({ ui: props.ui })
|
|
29
|
-
);
|
|
30
|
-
const { copy, copied } = useClipboard();
|
|
31
|
-
function handleCopy() {
|
|
32
|
-
if (modelValue.value) {
|
|
33
|
-
const stringValue = String(modelValue.value);
|
|
34
|
-
copy(stringValue);
|
|
35
|
-
emits("copy", stringValue);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
<template>
|
|
41
|
-
<UInput
|
|
42
|
-
v-model="modelValue"
|
|
43
|
-
:ui="baseUi"
|
|
44
|
-
v-bind="{ ...inputProps, ...attrs }"
|
|
45
|
-
@blur="emits('blur', $event)"
|
|
46
|
-
@change="emits('change', $event)"
|
|
47
|
-
>
|
|
48
|
-
<template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
|
|
49
|
-
<slot :name="slotName" v-bind="slotProps ?? {}" />
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<template v-if="!isEmpty(modelValue)" #trailing>
|
|
53
|
-
<UTooltip text="Copy to clipboard" v-bind="props.tooltipProps">
|
|
54
|
-
<UButton
|
|
55
|
-
:color="copied ? 'success' : 'neutral'"
|
|
56
|
-
variant="link"
|
|
57
|
-
:size="buttonSize"
|
|
58
|
-
:icon="copied ? 'i-lucide-copy-check' : 'i-lucide-copy'"
|
|
59
|
-
aria-label="Copy to clipboard"
|
|
60
|
-
v-bind="props.buttonProps"
|
|
61
|
-
@click="handleCopy"
|
|
62
|
-
/>
|
|
63
|
-
</UTooltip>
|
|
64
|
-
</template>
|
|
65
|
-
</UInput>
|
|
66
|
-
</template>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ComponentConfig, InputSlots, InputValue } from '@nuxt/ui';
|
|
2
|
-
import type { OmitByKey } from '@movk/core';
|
|
3
|
-
import theme from '#build/movk-ui/with-copy';
|
|
4
|
-
import inputTheme from '#build/ui/input';
|
|
5
|
-
import type { WithCopyProps } from '../../types/components/input/with-copy';
|
|
6
|
-
import type { AppConfig } from 'nuxt/schema';
|
|
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithCopyProps<T> & {
|
|
9
|
-
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withCopy">["slots"];
|
|
10
|
-
} & {
|
|
11
|
-
modelValue?: T;
|
|
12
|
-
}) & {
|
|
13
|
-
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
14
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
15
|
-
onCopy?: ((value: string) => any) | undefined;
|
|
16
|
-
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
17
|
-
}> & (typeof globalThis extends {
|
|
18
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
19
|
-
} ? P : {});
|
|
20
|
-
expose: (exposed: {}) => void;
|
|
21
|
-
attrs: any;
|
|
22
|
-
slots: OmitByKey<InputSlots, "trailing">;
|
|
23
|
-
emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
24
|
-
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
|
-
};
|
|
27
|
-
declare const _default: typeof __VLS_export;
|
|
28
|
-
export default _default;
|
|
29
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
30
|
-
[K in keyof T]: T[K];
|
|
31
|
-
} : {
|
|
32
|
-
[K in keyof T as K]: T[K];
|
|
33
|
-
}) & {};
|
|
@@ -1,33 +0,0 @@
|
|
|
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';
|
|
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithFloatingLabelProps<T> & {
|
|
9
|
-
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withFloatingLabel">["slots"];
|
|
10
|
-
} & {
|
|
11
|
-
modelValue?: T;
|
|
12
|
-
}) & {
|
|
13
|
-
onClear?: (() => any) | undefined;
|
|
14
|
-
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
15
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
16
|
-
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
17
|
-
}> & (typeof globalThis extends {
|
|
18
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
19
|
-
} ? P : {});
|
|
20
|
-
expose: (exposed: {}) => void;
|
|
21
|
-
attrs: any;
|
|
22
|
-
slots: OmitByKey<InputSlots, "default" | "trailing">;
|
|
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);
|
|
24
|
-
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
|
-
};
|
|
27
|
-
declare const _default: typeof __VLS_export;
|
|
28
|
-
export default _default;
|
|
29
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
30
|
-
[K in keyof T]: T[K];
|
|
31
|
-
} : {
|
|
32
|
-
[K in keyof T as K]: T[K];
|
|
33
|
-
}) & {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { useAttrs } from "vue";
|
|
3
|
-
import { UInput, UButton } from "#components";
|
|
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";
|
|
10
|
-
const props = defineProps({
|
|
11
|
-
label: { type: String, required: false },
|
|
12
|
-
size: { type: null, required: false },
|
|
13
|
-
clearButtonProps: { type: Object, required: false },
|
|
14
|
-
ui: { type: Object, required: false }
|
|
15
|
-
});
|
|
16
|
-
const emits = defineEmits(["update:modelValue", "blur", "change", "clear"]);
|
|
17
|
-
const slots = defineSlots();
|
|
18
|
-
defineOptions({ inheritAttrs: false });
|
|
19
|
-
const attrs = useAttrs();
|
|
20
|
-
const appConfig = useAppConfig();
|
|
21
|
-
const modelValue = defineModel({ type: null });
|
|
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
|
-
);
|
|
36
|
-
function handleClear() {
|
|
37
|
-
modelValue.value = void 0;
|
|
38
|
-
emitFormInput();
|
|
39
|
-
emitFormChange();
|
|
40
|
-
emits("clear");
|
|
41
|
-
}
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<UInput
|
|
46
|
-
v-model="modelValue"
|
|
47
|
-
:placeholder="props.placeholder ?? ''"
|
|
48
|
-
:ui="baseUi"
|
|
49
|
-
v-bind="{ ...inputProps, ...attrs }"
|
|
50
|
-
@blur="emits('blur', $event)"
|
|
51
|
-
@change="emits('change', $event)"
|
|
52
|
-
>
|
|
53
|
-
<template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
|
|
54
|
-
<slot :name="slotName" v-bind="slotProps ?? {}" />
|
|
55
|
-
</template>
|
|
56
|
-
|
|
57
|
-
<template v-if="props.label" #default>
|
|
58
|
-
<label :class="extraUi.label">
|
|
59
|
-
<span :class="extraUi.labelText">{{ props.label }}</span>
|
|
60
|
-
</label>
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
|
-
<template v-if="!isEmpty(modelValue)" #trailing>
|
|
64
|
-
<UButton
|
|
65
|
-
color="neutral"
|
|
66
|
-
variant="link"
|
|
67
|
-
:size="effectiveSize"
|
|
68
|
-
icon="i-lucide-circle-x"
|
|
69
|
-
aria-label="Clear input"
|
|
70
|
-
v-bind="props.clearButtonProps"
|
|
71
|
-
@click="handleClear"
|
|
72
|
-
/>
|
|
73
|
-
</template>
|
|
74
|
-
</UInput>
|
|
75
|
-
</template>
|
|
@@ -1,33 +0,0 @@
|
|
|
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';
|
|
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithFloatingLabelProps<T> & {
|
|
9
|
-
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withFloatingLabel">["slots"];
|
|
10
|
-
} & {
|
|
11
|
-
modelValue?: T;
|
|
12
|
-
}) & {
|
|
13
|
-
onClear?: (() => any) | undefined;
|
|
14
|
-
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
15
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
16
|
-
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
17
|
-
}> & (typeof globalThis extends {
|
|
18
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
19
|
-
} ? P : {});
|
|
20
|
-
expose: (exposed: {}) => void;
|
|
21
|
-
attrs: any;
|
|
22
|
-
slots: OmitByKey<InputSlots, "default" | "trailing">;
|
|
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);
|
|
24
|
-
}>) => import("vue").VNode & {
|
|
25
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
26
|
-
};
|
|
27
|
-
declare const _default: typeof __VLS_export;
|
|
28
|
-
export default _default;
|
|
29
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
30
|
-
[K in keyof T]: T[K];
|
|
31
|
-
} : {
|
|
32
|
-
[K in keyof T as K]: T[K];
|
|
33
|
-
}) & {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
|
|
2
|
-
import type { OmitByKey } from '@movk/core';
|
|
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
|
-
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
|
|
9
|
-
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
|
|
10
|
-
} & {
|
|
11
|
-
modelValue?: T;
|
|
12
|
-
}) & {
|
|
13
|
-
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
14
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
15
|
-
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
16
|
-
}> & (typeof globalThis extends {
|
|
17
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
18
|
-
} ? P : {});
|
|
19
|
-
expose: (exposed: {}) => void;
|
|
20
|
-
attrs: any;
|
|
21
|
-
slots: OmitByKey<InputSlots, "trailing">;
|
|
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);
|
|
23
|
-
}>) => import("vue").VNode & {
|
|
24
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
25
|
-
};
|
|
26
|
-
declare const _default: typeof __VLS_export;
|
|
27
|
-
export default _default;
|
|
28
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
29
|
-
[K in keyof T]: T[K];
|
|
30
|
-
} : {
|
|
31
|
-
[K in keyof T as K]: T[K];
|
|
32
|
-
}) & {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { useAttrs } from "vue";
|
|
3
|
-
import { UInput, UButton } from "#components";
|
|
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";
|
|
10
|
-
const props = defineProps({
|
|
11
|
-
buttonProps: { type: Object, required: false },
|
|
12
|
-
ui: { type: Object, required: false }
|
|
13
|
-
});
|
|
14
|
-
const emits = defineEmits(["update:modelValue", "blur", "change"]);
|
|
15
|
-
const slots = defineSlots();
|
|
16
|
-
defineOptions({ inheritAttrs: false });
|
|
17
|
-
const attrs = useAttrs();
|
|
18
|
-
const appConfig = useAppConfig();
|
|
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
|
-
);
|
|
28
|
-
const [value, toggle] = useToggle(false);
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<template>
|
|
32
|
-
<UInput
|
|
33
|
-
v-model="modelValue"
|
|
34
|
-
:type="value ? 'text' : 'password'"
|
|
35
|
-
:ui="baseUi"
|
|
36
|
-
v-bind="{ ...inputProps, ...attrs }"
|
|
37
|
-
@blur="emits('blur', $event)"
|
|
38
|
-
@change="emits('change', $event)"
|
|
39
|
-
>
|
|
40
|
-
<template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
|
|
41
|
-
<slot :name="slotName" v-bind="slotProps ?? {}" />
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<template #trailing>
|
|
45
|
-
<UButton
|
|
46
|
-
color="neutral"
|
|
47
|
-
variant="link"
|
|
48
|
-
:size="buttonSize"
|
|
49
|
-
:icon="value ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
|
50
|
-
:aria-label="value ? 'Hide password' : 'Show password'"
|
|
51
|
-
:aria-pressed="value"
|
|
52
|
-
v-bind="props.buttonProps"
|
|
53
|
-
@click="toggle()"
|
|
54
|
-
/>
|
|
55
|
-
</template>
|
|
56
|
-
</UInput>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
|
-
<style>
|
|
60
|
-
::-ms-reveal{display:none}
|
|
61
|
-
</style>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
|
|
2
|
-
import type { OmitByKey } from '@movk/core';
|
|
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
|
-
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
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
|
|
9
|
-
ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
|
|
10
|
-
} & {
|
|
11
|
-
modelValue?: T;
|
|
12
|
-
}) & {
|
|
13
|
-
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
14
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
15
|
-
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
16
|
-
}> & (typeof globalThis extends {
|
|
17
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
18
|
-
} ? P : {});
|
|
19
|
-
expose: (exposed: {}) => void;
|
|
20
|
-
attrs: any;
|
|
21
|
-
slots: OmitByKey<InputSlots, "trailing">;
|
|
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);
|
|
23
|
-
}>) => import("vue").VNode & {
|
|
24
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
25
|
-
};
|
|
26
|
-
declare const _default: typeof __VLS_export;
|
|
27
|
-
export default _default;
|
|
28
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
29
|
-
[K in keyof T]: T[K];
|
|
30
|
-
} : {
|
|
31
|
-
[K in keyof T as K]: T[K];
|
|
32
|
-
}) & {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { $Fetch } from 'nitropack/types';
|
|
2
|
-
import type { FetchHook } from 'ofetch';
|
|
3
|
-
/**
|
|
4
|
-
* 单端点的 movk 内置拦截器集合
|
|
5
|
-
* @description 由 api.factory 在创建 $fetch 实例时挂到实例上,供 useApiFetch 在用户传入同名钩子时组合复用
|
|
6
|
-
*/
|
|
7
|
-
export interface MovkInterceptors {
|
|
8
|
-
onRequest: FetchHook;
|
|
9
|
-
onResponse: FetchHook;
|
|
10
|
-
onResponseError: FetchHook;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 把 movk 内置拦截器以非枚举符号挂到 $fetch 实例
|
|
14
|
-
* @description 符号键不进入 ApiInstance 公共类型,强转集中于此
|
|
15
|
-
*/
|
|
16
|
-
export declare function attachInterceptors(instance: $Fetch, interceptors: MovkInterceptors): void;
|
|
17
|
-
/** 读取实例上挂载的 movk 内置拦截器 */
|
|
18
|
-
export declare function getInterceptors(instance: $Fetch): MovkInterceptors | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* 组合 movk 内置钩子与用户钩子为数组(movk 先执行)
|
|
21
|
-
* @description 用户未传钩子时返回 undefined,让 ofetch 沿用实例 default(不覆盖);
|
|
22
|
-
* 用户传入时返回 `[movkHook, ...userHooks]`,使用户钩子拿到 movk 处理后的上下文
|
|
23
|
-
*/
|
|
24
|
-
export declare function composeHook<H>(movkHook: H, userHook: H | H[] | undefined): H[] | undefined;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const MOVK_INTERCEPTORS = Symbol("movk:interceptors");
|
|
2
|
-
export function attachInterceptors(instance, interceptors) {
|
|
3
|
-
Object.defineProperty(instance, MOVK_INTERCEPTORS, {
|
|
4
|
-
value: interceptors,
|
|
5
|
-
enumerable: false,
|
|
6
|
-
configurable: true
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
export function getInterceptors(instance) {
|
|
10
|
-
return instance[MOVK_INTERCEPTORS];
|
|
11
|
-
}
|
|
12
|
-
function toArray(value) {
|
|
13
|
-
return Array.isArray(value) ? value : [value];
|
|
14
|
-
}
|
|
15
|
-
export function composeHook(movkHook, userHook) {
|
|
16
|
-
if (userHook === void 0) return void 0;
|
|
17
|
-
return [movkHook, ...toArray(userHook)];
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FetchContext } from 'ofetch';
|
|
2
|
-
import type { MovkApiPublicConfig } from '../../../types/api';
|
|
3
|
-
import type { ResolvedEndpointConfig } from '../../../types/api/module';
|
|
4
|
-
import type { useNuxtApp } from '#imports';
|
|
5
|
-
type NuxtApp = ReturnType<typeof useNuxtApp>;
|
|
6
|
-
/**
|
|
7
|
-
* 构造 onResponseError 拦截器
|
|
8
|
-
*
|
|
9
|
-
* @description 401 优先派发 `movk:api:unauthorized` hook 让业务侧自定义处理;
|
|
10
|
-
* `result.handled === true` 时**跳过** `movk:api:error` 派发,避免全局错误上报双计 401。
|
|
11
|
-
*/
|
|
12
|
-
export declare function createOnResponseError(resolvedConfig: ResolvedEndpointConfig, publicConfig: MovkApiPublicConfig, nuxtApp: NuxtApp): (context: FetchContext) => Promise<void>;
|
|
13
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { showToast } from "../toast.js";
|
|
2
|
-
import { dispatchUnauthorized } from "./unauthorized.js";
|
|
3
|
-
function readApiContext(options) {
|
|
4
|
-
return options.context || {};
|
|
5
|
-
}
|
|
6
|
-
export function createOnResponseError(resolvedConfig, publicConfig, nuxtApp) {
|
|
7
|
-
const { auth: authConfig, toast: toastConfig, response: responseConfig } = resolvedConfig;
|
|
8
|
-
return async function onResponseError(context) {
|
|
9
|
-
const { response } = context;
|
|
10
|
-
if (!response) return;
|
|
11
|
-
const { toast } = readApiContext(context.options);
|
|
12
|
-
let unauthorizedHandled = false;
|
|
13
|
-
if (response.status === 401) {
|
|
14
|
-
unauthorizedHandled = await dispatchUnauthorized(context, authConfig, nuxtApp);
|
|
15
|
-
}
|
|
16
|
-
if (!unauthorizedHandled) {
|
|
17
|
-
await nuxtApp.callHook("movk:api:error", context);
|
|
18
|
-
}
|
|
19
|
-
const data = response._data;
|
|
20
|
-
const fallback = `\u8BF7\u6C42\u5931\u8D25 (${response.status})`;
|
|
21
|
-
showToast("error", data ?? fallback, toast, toastConfig, responseConfig, context.options.method);
|
|
22
|
-
if (publicConfig.debug) {
|
|
23
|
-
console.error("[@movk/nuxt] Error:", response.status, response._data);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { FetchContext } from 'ofetch';
|
|
2
|
-
import type { ApiAuthConfig, ApiResponse, ApiResponseConfig } from '../../../types/api';
|
|
3
|
-
import type { useNuxtApp } from '#imports';
|
|
4
|
-
type NuxtApp = ReturnType<typeof useNuxtApp>;
|
|
5
|
-
/** HTTP 状态码或业务码(按 codeKey 读取,兼容字符串)为 401 */
|
|
6
|
-
export declare function isUnauthorized(status: number | undefined, raw: ApiResponse | null | undefined, responseConfig?: Partial<ApiResponseConfig>): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* 派发 `movk:api:unauthorized`,业务未接管时执行默认的清理会话与重定向
|
|
9
|
-
* @returns 业务侧是否已接管(`result.handled`)
|
|
10
|
-
*/
|
|
11
|
-
export declare function dispatchUnauthorized(context: FetchContext, authConfig: ApiAuthConfig, nuxtApp: NuxtApp): Promise<boolean>;
|
|
12
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { navigateTo } from "#imports";
|
|
2
|
-
import { getUserSession } from "../session.js";
|
|
3
|
-
const UNAUTHORIZED_CODE = 401;
|
|
4
|
-
export function isUnauthorized(status, raw, responseConfig = {}) {
|
|
5
|
-
if (status === UNAUTHORIZED_CODE) return true;
|
|
6
|
-
const code = raw?.[responseConfig.codeKey || "code"];
|
|
7
|
-
return code !== void 0 && code !== null && Number(code) === UNAUTHORIZED_CODE;
|
|
8
|
-
}
|
|
9
|
-
async function handleUnauthorized(authConfig, nuxtApp) {
|
|
10
|
-
const unauthorizedConfig = authConfig.unauthorized;
|
|
11
|
-
if (!unauthorizedConfig) return;
|
|
12
|
-
if (unauthorizedConfig.clearSession) {
|
|
13
|
-
const userSession = getUserSession(nuxtApp);
|
|
14
|
-
if (userSession?.clear) {
|
|
15
|
-
try {
|
|
16
|
-
await userSession.clear();
|
|
17
|
-
await userSession.fetch?.();
|
|
18
|
-
} catch {
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (unauthorizedConfig.redirect) {
|
|
23
|
-
const loginPath = unauthorizedConfig.loginPath || "/login";
|
|
24
|
-
await nuxtApp.runWithContext(() => navigateTo(loginPath));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export async function dispatchUnauthorized(context, authConfig, nuxtApp) {
|
|
28
|
-
const result = { handled: false };
|
|
29
|
-
await nuxtApp.callHook("movk:api:unauthorized", context, result);
|
|
30
|
-
if (!result.handled) {
|
|
31
|
-
await handleUnauthorized(authConfig, nuxtApp);
|
|
32
|
-
}
|
|
33
|
-
return result.handled;
|
|
34
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { FetchContext, FetchOptions } from 'ofetch';
|
|
2
|
-
import type { ApiResponse, MovkApiPublicConfig, RequestToastOptions, TransferRequestOptions, TransferResult } from '../../types/api';
|
|
3
|
-
import type { ResolvedEndpointConfig } from '../../types/api/module';
|
|
4
|
-
import type { useNuxtApp } from '#imports';
|
|
5
|
-
type NuxtApp = ReturnType<typeof useNuxtApp>;
|
|
6
|
-
/**
|
|
7
|
-
* 预备传输上下文
|
|
8
|
-
*/
|
|
9
|
-
export interface PreparedTransfer {
|
|
10
|
-
fullUrl: string;
|
|
11
|
-
headers: Record<string, string>;
|
|
12
|
-
config: ResolvedEndpointConfig;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 解析端点 + 拼装 URL + 合并 headers(auth 在前、用户在后,用户优先)
|
|
16
|
-
*/
|
|
17
|
-
export declare function prepareTransfer(publicConfig: MovkApiPublicConfig, url: string, options: TransferRequestOptions): PreparedTransfer;
|
|
18
|
-
/**
|
|
19
|
-
* 解析下载文件名
|
|
20
|
-
* @description 优先级:override > content-disposition > URL pathname 末段 > 'download'
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveFilename(headers: Headers, url: string, override?: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* 安全解析 JSON 响应
|
|
25
|
-
* @description content-type 含 application/json 时尝试 JSON.parse;失败或非 JSON 返回 null
|
|
26
|
-
*/
|
|
27
|
-
export declare function tryParseJsonResponse(headers: Headers, text: string): ApiResponse | null;
|
|
28
|
-
/**
|
|
29
|
-
* 把 XHR 的 getAllResponseHeaders() 字符串解析为标准 Headers
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseXhrHeaders(raw: string): Headers;
|
|
32
|
-
/**
|
|
33
|
-
* finalizeTransfer 入参
|
|
34
|
-
*/
|
|
35
|
-
export interface FinalizeTransferContext<T> {
|
|
36
|
-
/** JSON 响应体;纯二进制成功时为 null */
|
|
37
|
-
raw: ApiResponse | null;
|
|
38
|
-
/** 无 JSON 时由调用方提供成功/失败判定与默认数据 */
|
|
39
|
-
fallback?: {
|
|
40
|
-
isSuccess: boolean;
|
|
41
|
-
data: T | null;
|
|
42
|
-
message?: string;
|
|
43
|
-
};
|
|
44
|
-
config: ResolvedEndpointConfig;
|
|
45
|
-
publicConfig: MovkApiPublicConfig;
|
|
46
|
-
/** 单次请求 toast 覆盖;false 整体禁用 */
|
|
47
|
-
requestToast: RequestToastOptions | false | undefined;
|
|
48
|
-
skipBusinessCheck?: boolean;
|
|
49
|
-
/** 合成的 FetchContext,用于派发 movk:api:* hook */
|
|
50
|
-
fetchContext: FetchContext;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 统一处理传输结果:业务校验 → 派发 hook → 触发 toast → 构造 TransferResult
|
|
54
|
-
*
|
|
55
|
-
* @description 本函数**不抛异常**,所有错误以 result.error 形式返回,由 composable 自行决定是否 throw。
|
|
56
|
-
* 中止场景应由调用方在调用本函数前短路,不要进入此函数。
|
|
57
|
-
*/
|
|
58
|
-
export declare function finalizeTransfer<T>(nuxtApp: NuxtApp, ctx: FinalizeTransferContext<T>): Promise<TransferResult<T>>;
|
|
59
|
-
/**
|
|
60
|
-
* 合成一个最小可用的 FetchContext,供 hook 订阅者使用
|
|
61
|
-
*
|
|
62
|
-
* @description 由于上传/下载基于 XHR / fetch,不经 ofetch;此处提供必要字段以与 $api 的 hook 契约对齐。
|
|
63
|
-
*/
|
|
64
|
-
export declare function buildFetchContext(request: string, options: FetchOptions, response?: {
|
|
65
|
-
status: number;
|
|
66
|
-
headers: Headers;
|
|
67
|
-
_data?: unknown;
|
|
68
|
-
}): FetchContext;
|
|
69
|
-
export {};
|