@movk/nuxt 1.4.1 → 1.5.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.
Files changed (69) hide show
  1. package/README.en.md +308 -0
  2. package/README.md +4 -2
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +2 -2
  5. package/dist/runtime/components/AutoForm.d.vue.ts +1 -1
  6. package/dist/runtime/components/AutoForm.vue.d.ts +1 -1
  7. package/dist/runtime/components/ColorChooser.d.vue.ts +1 -1
  8. package/dist/runtime/components/ColorChooser.vue.d.ts +1 -1
  9. package/dist/runtime/components/DataTable.d.vue.ts +1 -1
  10. package/dist/runtime/components/DataTable.vue.d.ts +1 -1
  11. package/dist/runtime/components/DatePicker.d.vue.ts +1 -1
  12. package/dist/runtime/components/DatePicker.vue.d.ts +1 -1
  13. package/dist/runtime/components/PillGroup.d.vue.ts +1 -1
  14. package/dist/runtime/components/PillGroup.vue.d.ts +1 -1
  15. package/dist/runtime/components/Popconfirm.d.vue.ts +1 -1
  16. package/dist/runtime/components/Popconfirm.vue.d.ts +1 -1
  17. package/dist/runtime/components/SearchForm.d.vue.ts +1 -1
  18. package/dist/runtime/components/SearchForm.vue.d.ts +1 -1
  19. package/dist/runtime/components/Tree.d.vue.ts +1 -1
  20. package/dist/runtime/components/Tree.vue +4 -3
  21. package/dist/runtime/components/Tree.vue.d.ts +1 -1
  22. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +1 -1
  23. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +1 -1
  24. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +1 -1
  25. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +1 -1
  26. package/dist/runtime/components/input/WithClear.d.vue.ts +1 -1
  27. package/dist/runtime/components/input/WithClear.vue.d.ts +1 -1
  28. package/dist/runtime/components/input/WithCopy.d.vue.ts +1 -1
  29. package/dist/runtime/components/input/WithCopy.vue.d.ts +1 -1
  30. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +1 -1
  31. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +1 -1
  32. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +1 -1
  33. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +1 -1
  34. package/dist/runtime/composables/useApiFetch.d.ts +4 -1
  35. package/dist/runtime/composables/useApiFetch.js +14 -2
  36. package/dist/runtime/composables/useTheme.js +3 -3
  37. package/dist/runtime/domains/api/deep-to-value.d.ts +9 -0
  38. package/dist/runtime/domains/api/deep-to-value.js +11 -0
  39. package/dist/runtime/domains/api/interceptors/compose.d.ts +24 -0
  40. package/dist/runtime/domains/api/interceptors/compose.js +18 -0
  41. package/dist/runtime/domains/auto-form/controls.d.ts +11 -90
  42. package/dist/runtime/domains/auto-form/controls.js +0 -2
  43. package/dist/runtime/domains/data-table/columns/resize.d.ts +4 -0
  44. package/dist/runtime/domains/data-table/columns/resize.js +134 -0
  45. package/dist/runtime/domains/data-table/columns/resolve-data-column.js +3 -46
  46. package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +2 -1
  47. package/dist/runtime/domains/data-table/columns/style.d.ts +1 -0
  48. package/dist/runtime/domains/data-table/columns/style.js +22 -5
  49. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
  50. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
  51. package/dist/runtime/domains/theme/theme-icons.d.ts +9 -0
  52. package/dist/runtime/domains/theme/theme-icons.js +7 -0
  53. package/dist/runtime/domains/tree/components/TreeToolbar.vue +1 -1
  54. package/dist/runtime/plugins/api.factory.js +9 -3
  55. package/dist/runtime/plugins/theme.js +2 -2
  56. package/dist/runtime/types/auto-form/zod-factory.d.ts +20 -5
  57. package/dist/runtime/types/components/date-picker.d.ts +3 -0
  58. package/dist/runtime/types/components/index.d.ts +0 -1
  59. package/dist/runtime/types/components/tree.d.ts +1 -0
  60. package/dist/runtime/vue/plugins/theme.js +2 -2
  61. package/dist/shared/{nuxt.CXM2nhP4.mjs → nuxt.DJKBap-S.mjs} +0 -28
  62. package/dist/unplugin.mjs +1 -1
  63. package/dist/vite.mjs +1 -1
  64. package/package.json +13 -13
  65. package/dist/runtime/components/StarRating.d.vue.ts +0 -52
  66. package/dist/runtime/components/StarRating.vue +0 -238
  67. package/dist/runtime/components/StarRating.vue.d.ts +0 -52
  68. package/dist/runtime/types/components/star-rating.d.ts +0 -55
  69. package/dist/runtime/types/components/star-rating.js +0 -0
@@ -1,238 +0,0 @@
1
- <script setup>
2
- import { UButton, UBadge } from "#components";
3
- import { computed, ref } from "vue";
4
- import { FieldGroupReset } from "@nuxt/ui/composables/useFieldGroup";
5
- import { useAppConfig } from "#imports";
6
- import theme from "#build/movk-ui/star-rating";
7
- import { useExtendedTv } from "../utils/extend-theme";
8
- import { useFieldControl } from "../utils/form-control";
9
- const props = defineProps({
10
- id: { type: String, required: false },
11
- name: { type: String, required: false },
12
- max: { type: Number, required: false, default: 5 },
13
- disabled: { type: Boolean, required: false },
14
- highlight: { type: Boolean, required: false },
15
- readonly: { type: Boolean, required: false },
16
- showBadge: { type: Boolean, required: false, default: true },
17
- buttonProps: { type: Object, required: false },
18
- emptyIcon: { type: null, required: false, default: "i-lucide-star" },
19
- filledIcon: { type: null, required: false, default: "i-lucide-star" },
20
- halfIcon: { type: null, required: false, default: "i-lucide-star-half" },
21
- color: { type: null, required: false },
22
- size: { type: null, required: false },
23
- allowHalf: { type: Boolean, required: false },
24
- clearable: { type: Boolean, required: false },
25
- class: { type: null, required: false },
26
- ui: { type: Object, required: false }
27
- });
28
- const modelValue = defineModel({ type: Number, ...{ default: 0 } });
29
- const emits = defineEmits(["change", "hover"]);
30
- defineOptions({ inheritAttrs: false });
31
- const {
32
- id,
33
- name,
34
- size: effectiveSize,
35
- color: effectiveColor,
36
- disabled: effectiveDisabled,
37
- fieldGroupOrientation,
38
- ariaAttrs,
39
- emitFormBlur,
40
- emitFormChange,
41
- emitFormFocus,
42
- emitFormInput
43
- } = useFieldControl(props);
44
- const hoveredStar = ref(null);
45
- const focusedIndex = ref(0);
46
- const isInteractive = computed(() => !effectiveDisabled.value && !props.readonly);
47
- const appConfig = useAppConfig();
48
- const { extendUi } = useExtendedTv(
49
- { slots: {} },
50
- theme,
51
- () => appConfig.movk?.starRating,
52
- () => ({
53
- ui: {
54
- ...props.ui,
55
- root: [props.ui?.root, props.class]
56
- },
57
- variants: {
58
- interactive: isInteractive.value,
59
- disabled: effectiveDisabled.value,
60
- readonly: props.readonly && !effectiveDisabled.value,
61
- fieldGroup: fieldGroupOrientation.value
62
- }
63
- })
64
- );
65
- function emitFormValueChange() {
66
- emitFormInput();
67
- emitFormChange();
68
- }
69
- function calculateHalfStarValue(index, event) {
70
- if (!props.allowHalf) return index + 1;
71
- const target = event.currentTarget;
72
- const rect = target.getBoundingClientRect();
73
- const posX = event.clientX - rect.left;
74
- const halfWidth = rect.width / 2;
75
- return posX < halfWidth ? index + 0.5 : index + 1;
76
- }
77
- function updateValue(newValue) {
78
- const finalValue = props.clearable && newValue === modelValue.value ? 0 : newValue;
79
- modelValue.value = finalValue;
80
- emits("change", finalValue);
81
- emitFormValueChange();
82
- }
83
- function handleClick(index, event) {
84
- if (!isInteractive.value || !event) return;
85
- const newValue = calculateHalfStarValue(index, event);
86
- updateValue(newValue);
87
- }
88
- function handleMouseEnter(index, event) {
89
- if (!isInteractive.value || !event) return;
90
- const hoverValue = calculateHalfStarValue(index, event);
91
- hoveredStar.value = hoverValue - 1;
92
- emits("hover", hoverValue);
93
- }
94
- function handleMouseMove(index, event) {
95
- if (!isInteractive.value || !props.allowHalf) return;
96
- const hoverValue = calculateHalfStarValue(index, event);
97
- const currentHover = hoveredStar.value !== null ? hoveredStar.value + 1 : null;
98
- if (currentHover !== hoverValue) {
99
- hoveredStar.value = hoverValue - 1;
100
- emits("hover", hoverValue);
101
- }
102
- }
103
- function handleMouseLeave() {
104
- if (!isInteractive.value) return;
105
- hoveredStar.value = null;
106
- emits("hover", null);
107
- }
108
- function handleKeyDown(event) {
109
- if (!isInteractive.value) return;
110
- const step = props.allowHalf ? 0.5 : 1;
111
- switch (event.key) {
112
- case "ArrowRight":
113
- case "ArrowUp":
114
- event.preventDefault();
115
- if (modelValue.value < props.max) {
116
- updateValue(Math.min(modelValue.value + step, props.max));
117
- focusedIndex.value = Math.min(Math.floor(modelValue.value + step), props.max - 1);
118
- }
119
- break;
120
- case "ArrowLeft":
121
- case "ArrowDown":
122
- event.preventDefault();
123
- if (modelValue.value > 0) {
124
- updateValue(Math.max(modelValue.value - step, 0));
125
- focusedIndex.value = Math.max(Math.floor(modelValue.value - step) - 1, 0);
126
- }
127
- break;
128
- case "Home":
129
- event.preventDefault();
130
- updateValue(step);
131
- focusedIndex.value = 0;
132
- break;
133
- case "End":
134
- event.preventDefault();
135
- updateValue(props.max);
136
- focusedIndex.value = props.max - 1;
137
- break;
138
- case "Backspace":
139
- case "Delete":
140
- if (props.clearable) {
141
- event.preventDefault();
142
- updateValue(0);
143
- focusedIndex.value = 0;
144
- }
145
- break;
146
- default:
147
- if (event.key >= "0" && event.key <= "9") {
148
- const numValue = Number.parseInt(event.key);
149
- if (numValue <= props.max) {
150
- event.preventDefault();
151
- updateValue(numValue);
152
- focusedIndex.value = Math.max(numValue - 1, 0);
153
- }
154
- }
155
- }
156
- }
157
- function getStarState(index) {
158
- const displayValue = hoveredStar.value !== null ? hoveredStar.value + 1 : modelValue.value;
159
- if (index < Math.floor(displayValue)) {
160
- return "full";
161
- }
162
- if (props.allowHalf && index === Math.floor(displayValue) && displayValue % 1 !== 0) {
163
- return "half";
164
- }
165
- return "empty";
166
- }
167
- function getStarIcon(index) {
168
- const state = getStarState(index);
169
- if (state === "full") return props.filledIcon;
170
- if (state === "half") return props.halfIcon;
171
- return props.emptyIcon;
172
- }
173
- function getStarColor(index) {
174
- const state = getStarState(index);
175
- return state !== "empty" ? effectiveColor.value : "neutral";
176
- }
177
- const badgeLabel = computed(() => `${modelValue.value}/${props.max}`);
178
- </script>
179
-
180
- <template>
181
- <div
182
- :id="id"
183
- :name="name"
184
- :class="extendUi.root"
185
- role="slider"
186
- :aria-label="`\u8BC4\u5206 ${modelValue} / ${props.max}`"
187
- :aria-valuenow="modelValue"
188
- :aria-valuemin="0"
189
- :aria-valuemax="props.max"
190
- :aria-disabled="effectiveDisabled"
191
- :aria-readonly="props.readonly"
192
- :tabindex="isInteractive ? 0 : -1"
193
- v-bind="ariaAttrs"
194
- @blur="emitFormBlur"
195
- @focus="emitFormFocus"
196
- @keydown="handleKeyDown"
197
- >
198
- <FieldGroupReset>
199
- <slot name="prefix" :value="modelValue" :max="props.max" />
200
- <div :class="extendUi.stars">
201
- <UButton
202
- v-for="index in props.max"
203
- :key="index"
204
- :icon="getStarIcon(index - 1)"
205
- :color="getStarColor(index - 1)"
206
- variant="ghost"
207
- :size="effectiveSize"
208
- :disabled="effectiveDisabled"
209
- :aria-label="`${index} \u661F`"
210
- :tabindex="-1"
211
- v-bind="buttonProps"
212
- :class="extendUi.star"
213
- @click="handleClick(index - 1, $event)"
214
- @mouseenter="handleMouseEnter(index - 1, $event)"
215
- @mousemove="handleMouseMove(index - 1, $event)"
216
- @mouseleave="handleMouseLeave"
217
- />
218
- </div>
219
-
220
- <slot
221
- name="badge"
222
- :value="modelValue"
223
- :max="props.max"
224
- :label="badgeLabel"
225
- >
226
- <UBadge
227
- v-if="showBadge && modelValue > 0"
228
- :label="badgeLabel"
229
- color="primary"
230
- variant="subtle"
231
- :size="effectiveSize"
232
- />
233
- </slot>
234
-
235
- <slot name="suffix" :value="modelValue" :max="props.max" />
236
- </FieldGroupReset>
237
- </div>
238
- </template>
@@ -1,52 +0,0 @@
1
- import type { ComponentConfig } from '@nuxt/ui';
2
- import theme from '#build/movk-ui/star-rating';
3
- import type { AppConfig } from 'nuxt/schema';
4
- import type { StarRatingProps } from '../types/components/star-rating';
5
- type __VLS_Props = StarRatingProps & {
6
- ui?: ComponentConfig<typeof theme, AppConfig, 'starRating'>['slots'];
7
- };
8
- type __VLS_ModelProps = {
9
- modelValue?: number;
10
- };
11
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
- declare var __VLS_7: {
13
- value: number;
14
- max: number;
15
- }, __VLS_19: {
16
- value: number;
17
- max: number;
18
- label: string;
19
- }, __VLS_26: {
20
- value: number;
21
- max: number;
22
- };
23
- type __VLS_Slots = {} & {
24
- prefix?: (props: typeof __VLS_7) => any;
25
- } & {
26
- badge?: (props: typeof __VLS_19) => any;
27
- } & {
28
- suffix?: (props: typeof __VLS_26) => any;
29
- };
30
- declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
31
- change: (value: number) => any;
32
- "update:modelValue": (value: number) => any;
33
- hover: (value: number | null) => any;
34
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
35
- onChange?: ((value: number) => any) | undefined;
36
- "onUpdate:modelValue"?: ((value: number) => any) | undefined;
37
- onHover?: ((value: number | null) => any) | undefined;
38
- }>, {
39
- max: number;
40
- showBadge: boolean;
41
- emptyIcon: import("@nuxt/ui").IconProps["name"];
42
- filledIcon: import("@nuxt/ui").IconProps["name"];
43
- halfIcon: import("@nuxt/ui").IconProps["name"];
44
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
46
- declare const _default: typeof __VLS_export;
47
- export default _default;
48
- type __VLS_WithSlots<T, S> = T & {
49
- new (): {
50
- $slots: S;
51
- };
52
- };
@@ -1,55 +0,0 @@
1
- import type { ButtonProps, IconProps } from '@nuxt/ui';
2
- import type { ClassNameValue } from '../shared';
3
- export interface StarRatingProps {
4
- id?: string;
5
- name?: string;
6
- /**
7
- * 最大星级数
8
- * @defaultValue 5
9
- */
10
- max?: number;
11
- /** 是否禁用 */
12
- disabled?: boolean;
13
- /** Highlight the ring color like a focus state. */
14
- highlight?: boolean;
15
- /** 是否只读 */
16
- readonly?: boolean;
17
- /**
18
- * 是否显示评分徽章
19
- * @defaultValue true
20
- */
21
- showBadge?: boolean;
22
- buttonProps?: ButtonProps;
23
- /**
24
- * 未选中星星的图标
25
- * @IconifyIcon
26
- * @defaultValue 'i-lucide-star'
27
- */
28
- emptyIcon?: IconProps['name'];
29
- /**
30
- * 选中星星的图标
31
- * @IconifyIcon
32
- * @defaultValue 'i-lucide-star'
33
- */
34
- filledIcon?: IconProps['name'];
35
- /**
36
- * 半星图标
37
- * @IconifyIcon
38
- * @defaultValue 'i-lucide-star-half'
39
- */
40
- halfIcon?: IconProps['name'];
41
- /** 选中星星的颜色 */
42
- color?: ButtonProps['color'];
43
- /** 星星大小 @defaultValue 'md' */
44
- size?: ButtonProps['size'];
45
- /** 是否允许半星 */
46
- allowHalf?: boolean;
47
- /** 是否允许清除评分 */
48
- clearable?: boolean;
49
- class?: ClassNameValue;
50
- ui?: Record<string, ClassNameValue>;
51
- }
52
- export interface StarRatingEmits {
53
- change: [value: number];
54
- hover: [value: number | null];
55
- }
File without changes