@movk/nuxt 1.4.2 → 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 (51) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -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.d.ts +1 -1
  21. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +1 -1
  22. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +1 -1
  23. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +1 -1
  24. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +1 -1
  25. package/dist/runtime/components/input/WithClear.d.vue.ts +1 -1
  26. package/dist/runtime/components/input/WithClear.vue.d.ts +1 -1
  27. package/dist/runtime/components/input/WithCopy.d.vue.ts +1 -1
  28. package/dist/runtime/components/input/WithCopy.vue.d.ts +1 -1
  29. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +1 -1
  30. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +1 -1
  31. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +1 -1
  32. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +1 -1
  33. package/dist/runtime/composables/useTheme.js +3 -3
  34. package/dist/runtime/domains/auto-form/controls.d.ts +9 -89
  35. package/dist/runtime/domains/auto-form/controls.js +0 -2
  36. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
  37. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
  38. package/dist/runtime/domains/theme/theme-icons.d.ts +9 -0
  39. package/dist/runtime/domains/theme/theme-icons.js +7 -0
  40. package/dist/runtime/plugins/theme.js +2 -2
  41. package/dist/runtime/types/components/index.d.ts +0 -1
  42. package/dist/runtime/vue/plugins/theme.js +2 -2
  43. package/dist/shared/{nuxt.CXM2nhP4.mjs → nuxt.DJKBap-S.mjs} +0 -28
  44. package/dist/unplugin.mjs +1 -1
  45. package/dist/vite.mjs +1 -1
  46. package/package.json +11 -11
  47. package/dist/runtime/components/StarRating.d.vue.ts +0 -52
  48. package/dist/runtime/components/StarRating.vue +0 -238
  49. package/dist/runtime/components/StarRating.vue.d.ts +0 -52
  50. package/dist/runtime/types/components/star-rating.d.ts +0 -55
  51. package/dist/runtime/types/components/star-rating.js +0 -0
@@ -1,3 +1,9 @@
1
+ export type ThemeIconSet = keyof typeof themeIcons;
2
+ /**
3
+ * 按图标集覆盖当前图标表,图标集未收录的键回退当前值。
4
+ * 整体替换会丢失 @nuxt/ui 新增而图标集尚未跟进的键(如 4.10 的 star),故此处合并。
5
+ */
6
+ export declare function resolveThemeIcons(set: string, current: Record<string, string>): Record<string, string>;
1
7
  export declare const themeIcons: {
2
8
  lucide: {
3
9
  arrowDown: string;
@@ -37,6 +43,7 @@ export declare const themeIcons: {
37
43
  reload: string;
38
44
  search: string;
39
45
  stop: string;
46
+ star: string;
40
47
  success: string;
41
48
  system: string;
42
49
  tip: string;
@@ -81,6 +88,7 @@ export declare const themeIcons: {
81
88
  reload: string;
82
89
  search: string;
83
90
  stop: string;
91
+ star: string;
84
92
  success: string;
85
93
  system: string;
86
94
  tip: string;
@@ -125,6 +133,7 @@ export declare const themeIcons: {
125
133
  reload: string;
126
134
  search: string;
127
135
  stop: string;
136
+ star: string;
128
137
  success: string;
129
138
  system: string;
130
139
  tip: string;
@@ -1,3 +1,7 @@
1
+ export function resolveThemeIcons(set, current) {
2
+ const icons = themeIcons[set];
3
+ return icons ? { ...current, ...icons } : current;
4
+ }
1
5
  export const themeIcons = {
2
6
  lucide: {
3
7
  arrowDown: "i-lucide-arrow-down",
@@ -37,6 +41,7 @@ export const themeIcons = {
37
41
  reload: "i-lucide-rotate-ccw",
38
42
  search: "i-lucide-search",
39
43
  stop: "i-lucide-square",
44
+ star: "i-lucide-star",
40
45
  success: "i-lucide-circle-check",
41
46
  system: "i-lucide-monitor",
42
47
  tip: "i-lucide-lightbulb",
@@ -81,6 +86,7 @@ export const themeIcons = {
81
86
  reload: "i-ph-arrow-counter-clockwise",
82
87
  search: "i-ph-magnifying-glass",
83
88
  stop: "i-ph-square",
89
+ star: "i-ph-star",
84
90
  success: "i-ph-check-circle",
85
91
  system: "i-ph-monitor",
86
92
  tip: "i-ph-lightbulb",
@@ -125,6 +131,7 @@ export const themeIcons = {
125
131
  reload: "i-tabler-reload",
126
132
  search: "i-tabler-search",
127
133
  stop: "i-tabler-player-stop",
134
+ star: "i-tabler-star",
128
135
  success: "i-tabler-square-rounded-check",
129
136
  system: "i-tabler-device-desktop",
130
137
  tip: "i-tabler-bulb",
@@ -1,6 +1,6 @@
1
1
  import { kebabCase } from "@movk/core";
2
2
  import { defineNuxtPlugin, useAppConfig, useHead, useSiteConfig } from "#imports";
3
- import { themeIcons } from "../domains/theme/theme-icons.js";
3
+ import { resolveThemeIcons } from "../domains/theme/theme-icons.js";
4
4
  export default defineNuxtPlugin({
5
5
  enforce: "post",
6
6
  setup() {
@@ -13,7 +13,7 @@ export default defineNuxtPlugin({
13
13
  const neutral = localStorage.getItem(`${name}-ui-neutral`);
14
14
  if (neutral) appConfig.ui.colors.neutral = neutral;
15
15
  const icons = localStorage.getItem(`${name}-ui-icons`);
16
- if (icons) appConfig.ui.icons = themeIcons[icons];
16
+ if (icons) appConfig.ui.icons = resolveThemeIcons(icons, appConfig.ui.icons);
17
17
  }
18
18
  if (import.meta.server) {
19
19
  const pickerFonts = appConfig.movk?.picker?.fonts ?? [];
@@ -4,6 +4,5 @@ export type { MessageBoxEmits, MessageBoxProps, MessageBoxSlots } from './messag
4
4
  export type { MTreeItem, TreeEmits, TreeExposed, TreeFilter, TreeItem, TreeLoadChildren, TreeProps, TreeSelectionResult, TreeSelectionStrategy, TreeSelectionSummary, TreeSlots } from './tree';
5
5
  export type { PopconfirmEmits, PopconfirmProps, PopconfirmSlots } from './popconfirm';
6
6
  export type { SlideVerifyEmits, SlideVerifyProps, SlideVerifySlots } from './slide-verify';
7
- export type { StarRatingEmits, StarRatingProps } from './star-rating';
8
7
  export type { PillGroupEmits, PillGroupProps, PillGroupSlots, PillItem, PillGroupValue, PillSelectPayload } from './pill-group';
9
8
  export type { AsPhoneNumberInputProps, WithCharacterLimitProps, WithClearEmits, WithClearProps, WithCopyEmits, WithCopyProps, WithFloatingLabelEmits, WithFloatingLabelProps, WithPasswordToggleProps } from './input';
@@ -1,6 +1,6 @@
1
1
  import { defineNuxtPlugin, useAppConfig, useSiteConfig } from "#imports";
2
2
  import { kebabCase } from "@movk/core";
3
- import { themeIcons } from "../../domains/theme/theme-icons.js";
3
+ import { resolveThemeIcons } from "../../domains/theme/theme-icons.js";
4
4
  export default defineNuxtPlugin(() => {
5
5
  const appConfig = useAppConfig();
6
6
  const site = useSiteConfig();
@@ -10,5 +10,5 @@ export default defineNuxtPlugin(() => {
10
10
  const neutral = localStorage.getItem(`${name}-ui-neutral`);
11
11
  if (neutral) appConfig.ui.colors.neutral = neutral;
12
12
  const icons = localStorage.getItem(`${name}-ui-icons`);
13
- if (icons) appConfig.ui.icons = themeIcons[icons];
13
+ if (icons) appConfig.ui.icons = resolveThemeIcons(icons, appConfig.ui.icons);
14
14
  });
@@ -372,33 +372,6 @@ const autoForm = () => ({
372
372
  }
373
373
  });
374
374
 
375
- const starRating = () => ({
376
- slots: {
377
- root: "inline-flex items-center gap-1",
378
- stars: "flex items-center gap-0.5",
379
- star: "transition-all duration-150"
380
- },
381
- variants: {
382
- interactive: {
383
- true: { star: "cursor-pointer hover:scale-110" }
384
- },
385
- disabled: {
386
- true: { star: "cursor-not-allowed opacity-50" }
387
- },
388
- readonly: {
389
- true: { star: "cursor-default" }
390
- },
391
- fieldGroup: {
392
- horizontal: {
393
- root: "rounded-md bg-default ring ring-inset ring-accented px-1 not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]"
394
- },
395
- vertical: {
396
- root: "rounded-md bg-default ring ring-inset ring-accented px-1 not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"
397
- }
398
- }
399
- }
400
- });
401
-
402
375
  const pillGroup = () => ({
403
376
  slots: {
404
377
  root: "flex items-center gap-2",
@@ -457,7 +430,6 @@ const theme = {
457
430
  popconfirm: popconfirm,
458
431
  searchForm: searchForm,
459
432
  slideVerify: slideVerify,
460
- starRating: starRating,
461
433
  themePicker: themePicker,
462
434
  tree: tree,
463
435
  withCharacterLimit: withCharacterLimit,
package/dist/unplugin.mjs CHANGED
@@ -8,7 +8,7 @@ import MagicString from 'magic-string';
8
8
  import { resolvePathSync } from 'mlly';
9
9
  import fs from 'node:fs';
10
10
  import path from 'node:path';
11
- import { U as UI_COMPONENTS, g as getTemplates } from './shared/nuxt.CXM2nhP4.mjs';
11
+ import { U as UI_COMPONENTS, g as getTemplates } from './shared/nuxt.DJKBap-S.mjs';
12
12
  import { kebabCase } from 'scule';
13
13
  import { getDefaultConfig } from '../dist/runtime/utils/theme-defaults.js';
14
14
  import { getPackageJsonMetadata } from '../dist/runtime/utils/meta.js';
package/dist/vite.mjs CHANGED
@@ -9,7 +9,7 @@ import 'magic-string';
9
9
  import 'mlly';
10
10
  import 'node:fs';
11
11
  import 'node:path';
12
- import './shared/nuxt.CXM2nhP4.mjs';
12
+ import './shared/nuxt.DJKBap-S.mjs';
13
13
  import 'scule';
14
14
  import '@nuxt/kit';
15
15
  import '../dist/runtime/utils/theme-defaults.js';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@movk/nuxt",
3
3
  "type": "module",
4
- "version": "1.4.2",
5
- "packageManager": "pnpm@11.9.0",
4
+ "version": "1.5.0",
5
+ "packageManager": "pnpm@11.13.1",
6
6
  "description": "An engineering suite built on Nuxt UI: schema-driven AutoForm (Zod v4), a full-featured DataTable, standalone UI components and composables. Get the full capabilities — including API integration with auth & progress — in Nuxt 4, and use its UI, forms, tables and theming in plain Vue + Vite via the Vite plugin.",
7
7
  "author": "YiXuan <mhaibaraai@gmail.com>",
8
8
  "license": "MIT",
@@ -124,13 +124,13 @@
124
124
  "test:vue": "vitest --project vue"
125
125
  },
126
126
  "dependencies": {
127
- "@iconify-json/lucide": "^1.2.114",
127
+ "@iconify-json/lucide": "^1.2.117",
128
128
  "@iconify-json/ph": "^1.2.2",
129
129
  "@iconify-json/tabler": "^1.2.35",
130
130
  "@internationalized/date": "^3.12.2",
131
131
  "@movk/core": "^1.3.1",
132
132
  "@nuxt/image": "^2.0.0",
133
- "@nuxt/ui": "^4.9.0",
133
+ "@nuxt/ui": "^4.10.0",
134
134
  "@tanstack/vue-table": "^8.21.3",
135
135
  "@vueuse/core": "^14.3.0",
136
136
  "@vueuse/nuxt": "^14.3.0",
@@ -142,13 +142,13 @@
142
142
  "nuxt-auth-utils": "^0.5.29",
143
143
  "nuxt-site-config": "^4.1.1",
144
144
  "pathe": "^2.0.3",
145
- "reka-ui": "2.9.10",
145
+ "reka-ui": "2.10.1",
146
146
  "scule": "^1.3.0",
147
147
  "tailwind-variants": "^3.2.2",
148
- "tailwindcss": "^4.3.1",
148
+ "tailwindcss": "^4.3.2",
149
149
  "tinyglobby": "^0.2.17",
150
150
  "unifont": "^0.7.4",
151
- "unplugin": "^3.2.0",
151
+ "unplugin": "^3.3.0",
152
152
  "zod": "^4.4.3"
153
153
  },
154
154
  "devDependencies": {
@@ -157,16 +157,16 @@
157
157
  "@nuxt/module-builder": "^1.0.2",
158
158
  "@nuxt/schema": "^4.4.8",
159
159
  "@release-it/conventional-changelog": "^11.0.1",
160
- "eslint": "^10.5.0",
160
+ "eslint": "^10.7.0",
161
161
  "happy-dom": "^20.10.6",
162
162
  "nuxt": "^4.4.8",
163
- "release-it": "^20.2.0",
163
+ "release-it": "^20.2.1",
164
164
  "typescript": "^6.0.3",
165
165
  "unbuild": "^3.6.1",
166
166
  "unplugin-auto-import": "^21.0.0",
167
167
  "unplugin-vue-components": "^32.1.0",
168
- "vitest": "^4.1.9",
168
+ "vitest": "^4.1.10",
169
169
  "vue": "^3.5.39",
170
- "vue-tsc": "^3.3.5"
170
+ "vue-tsc": "^3.3.7"
171
171
  }
172
172
  }
@@ -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
- hover: (value: number | null) => any;
33
- "update:modelValue": (value: number) => any;
34
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
35
- onChange?: ((value: number) => any) | undefined;
36
- onHover?: ((value: number | null) => any) | undefined;
37
- "onUpdate:modelValue"?: ((value: number) => 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,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
- hover: (value: number | null) => any;
33
- "update:modelValue": (value: number) => any;
34
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
35
- onChange?: ((value: number) => any) | undefined;
36
- onHover?: ((value: number | null) => any) | undefined;
37
- "onUpdate:modelValue"?: ((value: number) => 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