@veltra/desktop 1.2.27 → 1.2.28

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 (31) hide show
  1. package/dist/components/action/action-group.vue.d.ts +3 -3
  2. package/dist/components/action/action.vue.d.ts +2 -2
  3. package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
  4. package/dist/components/batch-edit/batch-edit.vue.d.ts +2 -2
  5. package/dist/components/cascade/cascade.vue.d.ts +4 -4
  6. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  7. package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
  8. package/dist/components/date-picker/date-picker.vue.d.ts +3 -3
  9. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +3 -3
  10. package/dist/components/empty/empty.vue.d.ts +1 -1
  11. package/dist/components/grid-input/grid-input.js +18 -12
  12. package/dist/components/grid-input/grid-input.js.map +1 -1
  13. package/dist/components/grid-input/grid-input.vue.d.ts +1 -1
  14. package/dist/components/input/input.vue.d.ts +4 -4
  15. package/dist/components/multi-select/multi-select.vue.d.ts +2 -2
  16. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +4 -4
  17. package/dist/components/number/number.vue.d.ts +1 -1
  18. package/dist/components/number-input/number-input.vue.d.ts +4 -4
  19. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  20. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  21. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  22. package/dist/components/select/select.vue.d.ts +2 -2
  23. package/dist/components/steps/steps.vue.d.ts +2 -2
  24. package/dist/components/textarea/textarea.vue.d.ts +4 -4
  25. package/dist/components/tip/tip.vue.d.ts +1 -1
  26. package/dist/components/tree-select/tree-select.vue.d.ts +4 -4
  27. package/dist/components/watermark/watermark.vue.d.ts +1 -1
  28. package/dist/types/grid-input.d.ts +12 -5
  29. package/package.json +6 -6
  30. package/src/components/grid-input/grid-input.vue +21 -17
  31. package/src/types/grid-input.ts +12 -5
@@ -6,11 +6,11 @@ type __VLS_Slots = {
6
6
  default?: () => VNode[];
7
7
  };
8
8
  declare const __VLS_base: import("vue").DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
9
- text: boolean;
10
- size: "small" | "default" | "large";
11
9
  type: import("@veltra/utils").ColorType;
12
- max: number;
10
+ size: "small" | "default" | "large";
13
11
  circle: boolean;
12
+ max: number;
13
+ text: boolean;
14
14
  loading: boolean;
15
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
16
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -12,10 +12,10 @@ declare const __VLS_base: import("vue").DefineComponent<ActionProps, {}, {}, {},
12
12
  }, string, import("vue").PublicProps, Readonly<ActionProps> & Readonly<{
13
13
  onRun?: (() => any) | undefined;
14
14
  }>, {
15
- text: boolean;
16
- size: import("@veltra/utils").ComponentSize;
17
15
  type: ButtonType;
16
+ size: import("@veltra/utils").ComponentSize;
18
17
  circle: boolean;
18
+ text: boolean;
19
19
  loading: boolean;
20
20
  inDropdown: boolean;
21
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -22,10 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Auto
22
22
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
23
23
  onSelect?: ((value: string) => any) | undefined;
24
24
  }>, {
25
- placeholder: string;
26
- clearable: boolean;
27
25
  disabled: boolean;
28
26
  readonly: boolean;
27
+ placeholder: string;
28
+ clearable: boolean;
29
29
  allowCustom: boolean;
30
30
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
31
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -6,20 +6,20 @@ declare const __VLS_base: import("vue").DefineComponent<BatchEditProps, {}, {},
6
6
  "update:selected": (value: Record<string, any> | undefined) => any;
7
7
  "update:checked": (value: Record<string, any>[]) => any;
8
8
  "update:current": (row?: TableRow | undefined) => any;
9
- "update:data": (value: Record<string, any>[]) => any;
10
9
  "update:rows": (rows: TableRow[]) => any;
11
10
  "update:forest": (rows?: import("@cat-kit/core").Forest<Record<string, unknown>, any> | undefined) => any;
12
11
  "cell-click": (row: TableRow, column: TableColumn, ev: MouseEvent) => any;
13
12
  "row-click": (row: TableRow, ev: MouseEvent) => any;
13
+ "update:data": (value: Record<string, any>[]) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<BatchEditProps> & Readonly<{
15
15
  "onUpdate:selected"?: ((value: Record<string, any> | undefined) => any) | undefined;
16
16
  "onUpdate:checked"?: ((value: Record<string, any>[]) => any) | undefined;
17
17
  "onUpdate:current"?: ((row?: TableRow | undefined) => any) | undefined;
18
- "onUpdate:data"?: ((value: Record<string, any>[]) => any) | undefined;
19
18
  "onUpdate:rows"?: ((rows: TableRow[]) => any) | undefined;
20
19
  "onUpdate:forest"?: ((rows?: import("@cat-kit/core").Forest<Record<string, unknown>, any> | undefined) => any) | undefined;
21
20
  "onCell-click"?: ((row: TableRow, column: TableColumn, ev: MouseEvent) => any) | undefined;
22
21
  "onRow-click"?: ((row: TableRow, ev: MouseEvent) => any) | undefined;
22
+ "onUpdate:data"?: ((value: Record<string, any>[]) => any) | undefined;
23
23
  }>, {
24
24
  cols: string | [string, string];
25
25
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -2,24 +2,24 @@ import { CascadeProps } from "../../types/cascade.js";
2
2
  //#region src/components/cascade/cascade.vue.d.ts
3
3
  declare const __VLS_export: import("vue").DefineComponent<CascadeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
4
4
  "update:modelValue": (value?: string | string[] | undefined) => any;
5
- clear: () => any;
6
5
  change: (...args: [item?: Record<string, any> | undefined] | [items: Record<string, any>[]]) => any;
6
+ clear: () => any;
7
7
  "update:label": (label?: string | string[] | undefined) => any;
8
8
  }, string, import("vue").PublicProps, Readonly<CascadeProps> & Readonly<{
9
9
  "onUpdate:modelValue"?: ((value?: string | string[] | undefined) => any) | undefined;
10
- onClear?: (() => any) | undefined;
11
10
  onChange?: ((...args: [item?: Record<string, any> | undefined] | [items: Record<string, any>[]]) => any) | undefined;
11
+ onClear?: (() => any) | undefined;
12
12
  "onUpdate:label"?: ((label?: string | string[] | undefined) => any) | undefined;
13
13
  }>, {
14
14
  labelKey: string;
15
15
  valueKey: string;
16
16
  childrenKey: string;
17
17
  data: Record<string, any>[];
18
+ disabled: boolean;
19
+ readonly: boolean;
18
20
  placeholder: string;
19
21
  clearable: boolean;
20
22
  filterable: boolean;
21
- disabled: boolean;
22
- readonly: boolean;
23
23
  visibilityLimit: number;
24
24
  separator: string;
25
25
  showFullPath: boolean;
@@ -17,9 +17,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
17
17
  "onUpdate:modelValue"?: ((checked: boolean) => any) | undefined;
18
18
  onChange?: ((checked: boolean) => any) | undefined;
19
19
  }>, {
20
+ type: import("@veltra/utils").ColorType;
20
21
  disabled: boolean;
21
22
  readonly: boolean;
22
- type: import("@veltra/utils").ColorType;
23
23
  round: boolean;
24
24
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
25
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -7,8 +7,8 @@ declare const __VLS_export: import("vue").DefineComponent<DatePanelProps, {}, {}
7
7
  "onSelect:range-date"?: ((rangeDate?: [import("@cat-kit/core").Dater, import("@cat-kit/core").Dater] | undefined) => any) | undefined;
8
8
  "onSelect:date"?: ((date: import("@cat-kit/core").Dater) => any) | undefined;
9
9
  }>, {
10
- size: import("@veltra/utils").ComponentSize;
11
10
  type: "date" | "month" | "year";
11
+ size: import("@veltra/utils").ComponentSize;
12
12
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
13
  declare const _default: typeof __VLS_export;
14
14
  //#endregion
@@ -5,11 +5,11 @@ declare const __VLS_export: import("vue").DefineComponent<DatePickerProps, {}, {
5
5
  }, string, import("vue").PublicProps, Readonly<DatePickerProps> & Readonly<{
6
6
  "onUpdate:modelValue"?: ((value?: string | number | Date | undefined) => any) | undefined;
7
7
  }>, {
8
- placeholder: string;
9
- clearable: boolean;
8
+ type: "date" | "month" | "year";
10
9
  disabled: boolean;
11
10
  readonly: boolean;
12
- type: "date" | "month" | "year";
11
+ placeholder: string;
12
+ clearable: boolean;
13
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
14
  declare const _default: typeof __VLS_export;
15
15
  //#endregion
@@ -5,11 +5,11 @@ declare const __VLS_export: import("vue").DefineComponent<DateRangePickerProps,
5
5
  }, string, import("vue").PublicProps, Readonly<DateRangePickerProps> & Readonly<{
6
6
  "onUpdate:modelValue"?: ((value?: [string, string] | undefined) => any) | undefined;
7
7
  }>, {
8
- placeholder: [string, string];
9
- clearable: boolean;
8
+ type: "date" | "month" | "year";
10
9
  disabled: boolean;
11
10
  readonly: boolean;
12
- type: "date" | "month" | "year";
11
+ placeholder: [string, string];
12
+ clearable: boolean;
13
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
14
  declare const _default: typeof __VLS_export;
15
15
  //#endregion
@@ -1,8 +1,8 @@
1
1
  import { EmptyProps } from "../../types/empty.js";
2
2
  //#region src/components/empty/empty.vue.d.ts
3
3
  declare const __VLS_export: import("vue").DefineComponent<EmptyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EmptyProps> & Readonly<{}>, {
4
- text: string;
5
4
  size: number;
5
+ text: string;
6
6
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  //#endregion
@@ -25,11 +25,16 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
25
25
  const props = __props;
26
26
  const { size } = useFallbackProps([props], { size: "default" });
27
27
  const cls = bem("grid-input");
28
- const _numberReg = computed(() => props.zero ? /^[0-9]$/ : /^[1-9]$/);
28
+ const numberReg = computed(() => props.zero ? /^[0-9]$/ : /^[1-9]$/);
29
29
  const valueArray = ref([]);
30
30
  const position = ref(-1);
31
31
  const blur = ref(false);
32
32
  const instance = getCurrentInstance();
33
+ const emitValue = () => {
34
+ const value = valueArray.value.join(props.separator);
35
+ emit("input", value);
36
+ emit("update:modelValue", value);
37
+ };
33
38
  const focus = async (index) => {
34
39
  if (index === void 0) {
35
40
  focus(position.value);
@@ -42,38 +47,39 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
42
47
  };
43
48
  const changeValue = (value, index) => {
44
49
  if (position.value === props.length) return;
45
- if (valueArray.value[index]) valueArray.value.splice(index, 1, value);
50
+ if (index < valueArray.value.length) valueArray.value.splice(index, 1, value);
46
51
  else if (index === valueArray.value.length) valueArray.value.push(value);
47
52
  else return;
48
53
  position.value++;
49
54
  focus();
50
- emit("input", valueArray.value.filter((v) => v).join(props.separator));
55
+ emitValue();
51
56
  };
52
57
  const baseOperation = {
53
- Backspace: (value, index) => {
54
- if (value) valueArray.value.splice(index, 1);
58
+ Backspace: (_value, index) => {
59
+ if (index < valueArray.value.length) valueArray.value.splice(index, 1);
55
60
  else if (index - 1 >= 0) valueArray.value.splice(index - 1, 1);
56
61
  if (index !== 0) focus(index - 1);
57
- emit("input", valueArray.value.filter((v) => v).join(props.separator));
62
+ emitValue();
58
63
  },
59
- ArrowLeft: (value, index) => {
64
+ ArrowLeft: (_value, index) => {
60
65
  if (index === 0) return;
61
66
  focus(index - 1);
62
67
  },
63
- ArrowRight: (value, index) => {
68
+ ArrowRight: (_value, index) => {
64
69
  if (index === valueArray.value.length) return;
65
70
  focus(index + 1);
66
71
  }
67
72
  };
68
73
  const onKeydown = (e, value, index) => {
69
- if (_numberReg.value.test(e.key)) {
74
+ if (numberReg.value.test(e.key)) {
70
75
  changeValue(e.key, index);
71
76
  return;
72
77
  }
73
- baseOperation[e.key](value, index);
78
+ baseOperation[e.key]?.(value, index);
74
79
  };
75
80
  const clear = () => {
76
- while (valueArray.value.length) valueArray.value.pop();
81
+ valueArray.value = [];
82
+ position.value = -1;
77
83
  };
78
84
  __expose({ clear });
79
85
  return (_ctx, _cache) => {
@@ -87,7 +93,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
87
93
  ref_for: true,
88
94
  ref: "items",
89
95
  class: normalizeClass([unref(cls).e("item"), unref(bem).is("focus", index === position.value && !blur.value)])
90
- }, [valueArray.value[index] ? (openBlock(), createElementBlock("span", {
96
+ }, [index < valueArray.value.length ? (openBlock(), createElementBlock("span", {
91
97
  key: 0,
92
98
  class: normalizeClass(unref(cls).em("item", "text"))
93
99
  }, toDisplayString(valueArray.value[index]), 3)) : index === position.value ? (openBlock(), createElementBlock("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"grid-input.js","names":[],"sources":["../../../src/components/grid-input/grid-input.vue"],"sourcesContent":["<template>\n <ul :class=\"[cls.b, cls.m(size)]\">\n <li\n v-for=\"(_, index) in length\"\n :key=\"index\"\n tabindex=\"0\"\n @keydown=\"onKeydown($event, valueArray[index]!, index)\"\n @focus=\"focus(index)\"\n @blur=\"index === position && (blur = true)\"\n ref=\"items\"\n :class=\"[cls.e('item'), bem.is('focus', index === position && !blur)]\"\n >\n <span :class=\"cls.em('item', 'text')\" v-if=\"valueArray[index]\">\n {{ valueArray[index] }}\n </span>\n\n <span :class=\"cls.em('item', 'cursor')\" v-else-if=\"index === position\"></span>\n </li>\n </ul>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { computed, ref, getCurrentInstance } from 'vue'\n\nimport type { GridInputProps, GridInputEmits, GridInputExposed } from '../../types'\n\ndefineOptions({ name: 'UGridInput' })\n\nconst emit = defineEmits<GridInputEmits>()\n\nconst props = withDefaults(defineProps<GridInputProps>(), {\n length: 6,\n zero: false,\n separator: '-'\n})\n\nconst { size } = useFallbackProps([props], { size: 'default' })\n\nconst cls = bem('grid-input')\n\nconst _numberReg = computed(() => (props.zero ? /^[0-9]$/ : /^[1-9]$/))\n\nconst valueArray = ref<string[]>([])\n\nconst position = ref<number>(-1)\n\nconst blur = ref<boolean>(false)\n\nconst instance = getCurrentInstance()\n\nconst focus = async (index?: number) => {\n if (index === undefined) {\n focus(position.value)\n return\n }\n if (index !== 0 && index > valueArray.value.length) {\n index = valueArray.value.length\n }\n position.value = index\n const items = (instance?.refs as { items?: unknown })?.items as any\n let dom = items?.[index]\n dom?.focus()\n blur.value = false\n}\n\nconst changeValue = (value: string, index: number) => {\n if (position.value === props.length) return\n const currentValue = valueArray.value[index]\n\n if (currentValue) {\n valueArray.value.splice(index, 1, value)\n } else if (index === valueArray.value.length) {\n valueArray.value.push(value)\n } else {\n return\n }\n position.value++\n focus()\n\n emit('input', valueArray.value.filter((v) => v).join(props.separator))\n}\n\nconst baseOperation = {\n Backspace: (value: string, index: number) => {\n if (value) {\n valueArray.value.splice(index, 1)\n } else if (index - 1 >= 0) {\n valueArray.value.splice(index - 1, 1)\n }\n if (index !== 0) {\n focus(index - 1)\n }\n emit('input', valueArray.value.filter((v) => v).join(props.separator))\n },\n ArrowLeft: (value: string, index: number) => {\n if (index === 0) return\n focus(index - 1)\n },\n ArrowRight: (value: string, index: number) => {\n if (index === valueArray.value.length) return\n focus(index + 1)\n }\n}\n\nconst onKeydown = (e: any, value: string, index: number) => {\n if (_numberReg.value.test(e.key)) {\n changeValue(e.key, index)\n return\n }\n baseOperation[e.key](value, index)\n}\n\nconst clear = () => {\n while (valueArray.value.length) {\n valueArray.value.pop()\n }\n}\n\ndefineExpose<GridInputExposed>({ clear })\n</script>\n"],"mappings":";;;;;;;;;;;;;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KAAvE,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,GAAE,QAAA,QAAA,CAAA"}
1
+ {"version":3,"file":"grid-input.js","names":[],"sources":["../../../src/components/grid-input/grid-input.vue"],"sourcesContent":["<template>\n <ul :class=\"[cls.b, cls.m(size)]\">\n <li\n v-for=\"(_, index) in length\"\n :key=\"index\"\n tabindex=\"0\"\n @keydown=\"onKeydown($event, valueArray[index]!, index)\"\n @focus=\"focus(index)\"\n @blur=\"index === position && (blur = true)\"\n ref=\"items\"\n :class=\"[cls.e('item'), bem.is('focus', index === position && !blur)]\"\n >\n <span :class=\"cls.em('item', 'text')\" v-if=\"index < valueArray.length\">\n {{ valueArray[index] }}\n </span>\n\n <span :class=\"cls.em('item', 'cursor')\" v-else-if=\"index === position\"></span>\n </li>\n </ul>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { computed, ref, getCurrentInstance } from 'vue'\n\nimport type { GridInputProps, GridInputEmits, GridInputExposed } from '../../types'\n\ndefineOptions({ name: 'UGridInput' })\n\nconst emit = defineEmits<GridInputEmits>()\n\nconst props = withDefaults(defineProps<GridInputProps>(), {\n length: 6,\n zero: false,\n separator: '-'\n})\n\nconst { size } = useFallbackProps([props], { size: 'default' })\n\nconst cls = bem('grid-input')\n\nconst numberReg = computed(() => (props.zero ? /^[0-9]$/ : /^[1-9]$/))\n\nconst valueArray = ref<string[]>([])\n\nconst position = ref<number>(-1)\n\nconst blur = ref<boolean>(false)\n\nconst instance = getCurrentInstance()\n\nconst emitValue = () => {\n const value = valueArray.value.join(props.separator)\n emit('input', value)\n emit('update:modelValue', value)\n}\n\nconst focus = async (index?: number) => {\n if (index === undefined) {\n focus(position.value)\n return\n }\n if (index !== 0 && index > valueArray.value.length) {\n index = valueArray.value.length\n }\n position.value = index\n const items = (instance?.refs as { items?: unknown })?.items as any\n let dom = items?.[index]\n dom?.focus()\n blur.value = false\n}\n\nconst changeValue = (value: string, index: number) => {\n if (position.value === props.length) return\n\n if (index < valueArray.value.length) {\n valueArray.value.splice(index, 1, value)\n } else if (index === valueArray.value.length) {\n valueArray.value.push(value)\n } else {\n return\n }\n position.value++\n focus()\n\n emitValue()\n}\n\nconst baseOperation: Record<string, (value: string, index: number) => void> = {\n Backspace: (_value: string, index: number) => {\n if (index < valueArray.value.length) {\n valueArray.value.splice(index, 1)\n } else if (index - 1 >= 0) {\n valueArray.value.splice(index - 1, 1)\n }\n if (index !== 0) {\n focus(index - 1)\n }\n emitValue()\n },\n ArrowLeft: (_value: string, index: number) => {\n if (index === 0) return\n focus(index - 1)\n },\n ArrowRight: (_value: string, index: number) => {\n if (index === valueArray.value.length) return\n focus(index + 1)\n }\n}\n\nconst onKeydown = (e: KeyboardEvent, value: string, index: number) => {\n if (numberReg.value.test(e.key)) {\n changeValue(e.key, index)\n return\n }\n baseOperation[e.key]?.(value, index)\n}\n\nconst clear = () => {\n valueArray.value = []\n position.value = -1\n}\n\ndefineExpose<GridInputExposed>({ clear })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA8BA,MAAM,OAAO;EAEb,MAAM,QAAQ;EAMd,MAAM,EAAE,SAAS,iBAAiB,CAAC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;EAE9D,MAAM,MAAM,IAAI,YAAY;EAE5B,MAAM,YAAY,eAAgB,MAAM,OAAO,YAAY,SAAU;EAErE,MAAM,aAAa,IAAc,CAAC,CAAC;EAEnC,MAAM,WAAW,IAAY,EAAE;EAE/B,MAAM,OAAO,IAAa,KAAK;EAE/B,MAAM,WAAW,mBAAmB;EAEpC,MAAM,kBAAkB;GACtB,MAAM,QAAQ,WAAW,MAAM,KAAK,MAAM,SAAS;GACnD,KAAK,SAAS,KAAK;GACnB,KAAK,qBAAqB,KAAK;EACjC;EAEA,MAAM,QAAQ,OAAO,UAAmB;GACtC,IAAI,UAAU,KAAA,GAAW;IACvB,MAAM,SAAS,KAAK;IACpB;GACF;GACA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C,EAAE,MAAA,IAAA,CAAI,CAAA,CAAA,EAAA,GAAA,EAAA,UAAA,IAAA,GAC5B,mBAeK,UAAA,MAAA,WAdkB,QAAA,SAAb,GAAG,UAAK;wBADlB,mBAeK,MAAA;KAbF,KAAK;KACN,UAAS;KACR,YAAO,WAAE,UAAU,QAAQ,WAAA,MAAW,QAAS,KAAK;KACpD,UAAK,WAAE,MAAM,KAAK;KAClB,SAAI,WAAE,UAAU,SAAA,UAAa,KAAA,QAAI;;KAClC,KAAI;KACH,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,GAAU,MAAA,GAAA,CAAG,CAAC,GAAE,SAAU,UAAU,SAAA,SAAQ,CAAK,KAAA,KAAI,CAAA,CAAA;QAEvB,QAAQ,WAAA,MAAW,UAAA,UAAA,GAA/D,mBAEO,QAAA;;KAFA,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,GAAE,QAAA,MAAA,CAAA;uBACf,WAAA,MAAW,MAAK,GAAA,CAAA,KAG8B,UAAU,SAAA,SAAA,UAAA,GAA7D,mBAA8E,QAAA;;KAAvE,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,GAAE,QAAA,QAAA,CAAA"}
@@ -9,7 +9,7 @@ declare const __VLS_export: import("vue").DefineComponent<GridInputProps, import
9
9
  }>, {
10
10
  length: number;
11
11
  separator: string;
12
- zero: false;
12
+ zero: boolean;
13
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
14
  declare const _default: typeof __VLS_export;
15
15
  //#endregion
@@ -15,27 +15,27 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Inpu
15
15
  "update:modelValue": (value: string | undefined) => any;
16
16
  } & {
17
17
  "update:modelValue": (value: string) => any;
18
- clear: () => any;
19
18
  change: (value: string) => any;
20
19
  "suffix:click": (value?: string | undefined) => any;
21
20
  "prefix:click": (value?: string | undefined) => any;
22
21
  focus: (value?: string | undefined) => any;
22
+ clear: () => any;
23
23
  blur: (value?: string | undefined) => any;
24
24
  "native:input": (ev: Event) => any;
25
25
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
26
26
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
27
- onClear?: (() => any) | undefined;
28
27
  onChange?: ((value: string) => any) | undefined;
29
28
  "onSuffix:click"?: ((value?: string | undefined) => any) | undefined;
30
29
  "onPrefix:click"?: ((value?: string | undefined) => any) | undefined;
31
30
  onFocus?: ((value?: string | undefined) => any) | undefined;
31
+ onClear?: (() => any) | undefined;
32
32
  onBlur?: ((value?: string | undefined) => any) | undefined;
33
33
  "onNative:input"?: ((ev: Event) => any) | undefined;
34
34
  }>, {
35
- placeholder: string;
36
- clearable: boolean;
37
35
  disabled: boolean;
38
36
  readonly: boolean;
37
+ placeholder: string;
38
+ clearable: boolean;
39
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
40
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
41
41
  declare const _default: typeof __VLS_export;
@@ -28,11 +28,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
28
28
  }>, {
29
29
  labelKey: string;
30
30
  valueKey: string;
31
+ disabled: boolean;
32
+ readonly: boolean;
31
33
  placeholder: string;
32
34
  clearable: boolean;
33
35
  minWidth: string;
34
- disabled: boolean;
35
- readonly: boolean;
36
36
  visibilityLimit: number;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -14,22 +14,22 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
14
14
  "update:modelValue": (value: (string | number)[]) => any;
15
15
  } & {
16
16
  "update:modelValue": (value: any[]) => any;
17
- clear: () => any;
18
17
  change: (checked: Record<string, any>[]) => any;
18
+ clear: () => any;
19
19
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
20
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
21
- onClear?: (() => any) | undefined;
22
21
  onChange?: ((checked: Record<string, any>[]) => any) | undefined;
22
+ onClear?: (() => any) | undefined;
23
23
  }>, {
24
24
  expandAll: boolean;
25
25
  labelKey: string;
26
26
  valueKey: string;
27
+ disabled: boolean;
28
+ readonly: boolean;
27
29
  placeholder: string;
28
30
  clearable: boolean;
29
31
  filterable: boolean;
30
32
  minWidth: string;
31
- disabled: boolean;
32
- readonly: boolean;
33
33
  visibilityLimit: number;
34
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,8 +1,8 @@
1
1
  import { NumberProps } from "../../types/number.js";
2
2
  //#region src/components/number/number.vue.d.ts
3
3
  declare const __VLS_export: import("vue").DefineComponent<NumberProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NumberProps> & Readonly<{}>, {
4
- format: "currency" | "percent" | "decimal";
5
4
  duration: number;
5
+ format: "currency" | "percent" | "decimal";
6
6
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  //#endregion
@@ -13,17 +13,17 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
13
13
  "update:modelValue": (value: number | undefined) => any;
14
14
  } & {
15
15
  "update:modelValue": (value?: number | undefined) => any;
16
- clear: () => any;
17
16
  change: (value?: number | undefined) => any;
17
+ clear: () => any;
18
18
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
19
19
  "onUpdate:modelValue"?: ((value?: number | undefined) => any) | undefined;
20
- onClear?: (() => any) | undefined;
21
20
  onChange?: ((value?: number | undefined) => any) | undefined;
21
+ onClear?: (() => any) | undefined;
22
22
  }>, {
23
- placeholder: string;
24
- clearable: boolean;
25
23
  disabled: boolean;
26
24
  readonly: boolean;
25
+ placeholder: string;
26
+ clearable: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
29
  declare const _default: typeof __VLS_export;
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
22
22
  "onUpdate:start"?: ((value: number | undefined) => any) | undefined;
23
23
  "onUpdate:end"?: ((value: number | undefined) => any) | undefined;
24
24
  }>, {
25
- clearable: boolean;
26
25
  disabled: boolean;
27
26
  readonly: boolean;
27
+ clearable: boolean;
28
28
  startPlaceholder: string;
29
29
  endPlaceholder: string;
30
30
  separator: string;
@@ -13,9 +13,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
13
13
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
14
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
15
15
  }>, {
16
- clearable: boolean;
17
16
  disabled: boolean;
18
17
  readonly: boolean;
18
+ clearable: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
21
  declare const _default: typeof __VLS_export;
@@ -10,9 +10,9 @@ declare const __VLS_export: import("vue").DefineComponent<RichTextEditorProps &
10
10
  }> & Readonly<{
11
11
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
12
12
  }>, {
13
- placeholder: string;
14
13
  disabled: boolean;
15
14
  readonly: boolean;
15
+ placeholder: string;
16
16
  format: RichTextFormat;
17
17
  toolbar: ToolbarItem[];
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -26,10 +26,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
26
26
  }>, {
27
27
  labelKey: string;
28
28
  valueKey: string;
29
- placeholder: string;
30
- clearable: boolean;
31
29
  disabled: boolean;
32
30
  readonly: boolean;
31
+ placeholder: string;
32
+ clearable: boolean;
33
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
35
35
  declare const _default: typeof __VLS_export;
@@ -6,11 +6,11 @@ type __VLS_Slots = {
6
6
  tip?: (scope: StepsSlotScope) => any;
7
7
  };
8
8
  declare const __VLS_base: import("vue").DefineComponent<StepsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
- "update:current": (value?: string | number | undefined) => any;
10
9
  "item-click": (item: Record<string, any>, index: number) => any;
10
+ "update:current": (value?: string | number | undefined) => any;
11
11
  }, string, import("vue").PublicProps, Readonly<StepsProps> & Readonly<{
12
- "onUpdate:current"?: ((value?: string | number | undefined) => any) | undefined;
13
12
  "onItem-click"?: ((item: Record<string, any>, index: number) => any) | undefined;
13
+ "onUpdate:current"?: ((value?: string | number | undefined) => any) | undefined;
14
14
  }>, {
15
15
  labelKey: string;
16
16
  direction: "horizontal" | "vertical";
@@ -9,21 +9,21 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
9
9
  "update:modelValue": (value: string | undefined) => any;
10
10
  } & {
11
11
  "update:modelValue": (value: string) => any;
12
- clear: () => any;
13
12
  change: (value: string) => any;
14
13
  focus: () => any;
14
+ clear: () => any;
15
15
  blur: () => any;
16
16
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
17
17
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
18
- onClear?: (() => any) | undefined;
19
18
  onChange?: ((value: string) => any) | undefined;
20
19
  onFocus?: (() => any) | undefined;
20
+ onClear?: (() => any) | undefined;
21
21
  onBlur?: (() => any) | undefined;
22
22
  }>, {
23
- placeholder: string;
24
- clearable: boolean;
25
23
  disabled: boolean;
26
24
  readonly: boolean;
25
+ placeholder: string;
26
+ clearable: boolean;
27
27
  resize: boolean;
28
28
  autosize: boolean;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -13,8 +13,8 @@ declare const __VLS_base: import("vue").DefineComponent<TipProps, {}, {}, {}, {}
13
13
  contentTag: string;
14
14
  visible: boolean;
15
15
  direction: TipDirection;
16
- content: string;
17
16
  alignment: TipAlign;
17
+ content: string;
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
20
  declare const _default: typeof __VLS_export;
@@ -15,24 +15,24 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
15
15
  "update:modelValue": (value: string | number | undefined) => any;
16
16
  } & {
17
17
  "update:modelValue": (value?: string | number | undefined) => any;
18
- clear: () => any;
19
18
  change: (selectedData?: Record<string, any> | undefined) => any;
19
+ clear: () => any;
20
20
  "update:text": (text?: string | undefined) => any;
21
21
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
22
  "onUpdate:modelValue"?: ((value?: string | number | undefined) => any) | undefined;
23
- onClear?: (() => any) | undefined;
24
23
  onChange?: ((selectedData?: Record<string, any> | undefined) => any) | undefined;
24
+ onClear?: (() => any) | undefined;
25
25
  "onUpdate:text"?: ((text?: string | undefined) => any) | undefined;
26
26
  }>, {
27
27
  expandAll: boolean;
28
28
  labelKey: string;
29
29
  valueKey: string;
30
+ disabled: boolean;
31
+ readonly: boolean;
30
32
  placeholder: string;
31
33
  clearable: boolean;
32
34
  filterable: boolean;
33
35
  minWidth: string;
34
- disabled: boolean;
35
- readonly: boolean;
36
36
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
37
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
38
38
  declare const _default: typeof __VLS_export;
@@ -5,8 +5,8 @@ type __VLS_Slots = {} & {
5
5
  default?: (props: typeof __VLS_7) => any;
6
6
  };
7
7
  declare const __VLS_base: import("vue").DefineComponent<WatermarkProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<WatermarkProps> & Readonly<{}>, {
8
- route: number;
9
8
  fontSize: number;
9
+ route: number;
10
10
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
11
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
12
12
  declare const _default: typeof __VLS_export;
@@ -1,23 +1,30 @@
1
1
  import { DeconstructValue } from "@veltra/utils";
2
2
 
3
3
  //#region src/types/grid-input.d.ts
4
- /** 密码输入框组件组件属性 */
4
+ /** 网格输入框组件属性 */
5
5
  interface GridInputProps {
6
6
  modelValue?: string;
7
+ /** 格子数量 */
7
8
  length?: number;
8
- zero?: false;
9
+ /**
10
+ * 是否允许输入 0
11
+ * @description 验证码场景通常开启;组织编码结构等场景关闭(如 3-3-2)
12
+ * @default false
13
+ */
14
+ zero?: boolean;
15
+ /** 格子之间的分隔符 */
9
16
  separator?: string;
10
17
  }
11
- /** 密码输入框组件组件定义的事件 */
18
+ /** 网格输入框组件定义的事件 */
12
19
  interface GridInputEmits {
13
20
  (e: 'update:modelValue', value: string): void;
14
21
  (e: 'input', value: string): void;
15
22
  }
16
- /** 密码输入框组件组件暴露的属性和方法(组件内部使用) */
23
+ /** 网格输入框组件暴露的属性和方法(组件内部使用) */
17
24
  interface _GridInputExposed {
18
25
  clear: () => void;
19
26
  }
20
- /** 密码输入框组件组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
27
+ /** 网格输入框组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
21
28
  type GridInputExposed = DeconstructValue<_GridInputExposed>;
22
29
  //#endregion
23
30
  export { GridInputEmits, GridInputExposed, GridInputProps, _GridInputExposed };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -57,11 +57,11 @@
57
57
  "@cat-kit/core": ">=1.1.8",
58
58
  "@cat-kit/excel": ">=1.0.0",
59
59
  "@cat-kit/fe": "^1.1.8",
60
- "@veltra/compositions": "1.2.27",
61
- "@veltra/directives": "1.2.27",
62
- "@veltra/icons": "1.2.27",
63
- "@veltra/styles": "1.2.27",
64
- "@veltra/utils": "1.2.27",
60
+ "@veltra/compositions": "1.2.28",
61
+ "@veltra/directives": "1.2.28",
62
+ "@veltra/icons": "1.2.28",
63
+ "@veltra/styles": "1.2.28",
64
+ "@veltra/utils": "1.2.28",
65
65
  "vue": ">=3.5.39"
66
66
  },
67
67
  "devDependencies": {
@@ -10,7 +10,7 @@
10
10
  ref="items"
11
11
  :class="[cls.e('item'), bem.is('focus', index === position && !blur)]"
12
12
  >
13
- <span :class="cls.em('item', 'text')" v-if="valueArray[index]">
13
+ <span :class="cls.em('item', 'text')" v-if="index < valueArray.length">
14
14
  {{ valueArray[index] }}
15
15
  </span>
16
16
 
@@ -40,7 +40,7 @@ const { size } = useFallbackProps([props], { size: 'default' })
40
40
 
41
41
  const cls = bem('grid-input')
42
42
 
43
- const _numberReg = computed(() => (props.zero ? /^[0-9]$/ : /^[1-9]$/))
43
+ const numberReg = computed(() => (props.zero ? /^[0-9]$/ : /^[1-9]$/))
44
44
 
45
45
  const valueArray = ref<string[]>([])
46
46
 
@@ -50,6 +50,12 @@ const blur = ref<boolean>(false)
50
50
 
51
51
  const instance = getCurrentInstance()
52
52
 
53
+ const emitValue = () => {
54
+ const value = valueArray.value.join(props.separator)
55
+ emit('input', value)
56
+ emit('update:modelValue', value)
57
+ }
58
+
53
59
  const focus = async (index?: number) => {
54
60
  if (index === undefined) {
55
61
  focus(position.value)
@@ -67,9 +73,8 @@ const focus = async (index?: number) => {
67
73
 
68
74
  const changeValue = (value: string, index: number) => {
69
75
  if (position.value === props.length) return
70
- const currentValue = valueArray.value[index]
71
76
 
72
- if (currentValue) {
77
+ if (index < valueArray.value.length) {
73
78
  valueArray.value.splice(index, 1, value)
74
79
  } else if (index === valueArray.value.length) {
75
80
  valueArray.value.push(value)
@@ -79,12 +84,12 @@ const changeValue = (value: string, index: number) => {
79
84
  position.value++
80
85
  focus()
81
86
 
82
- emit('input', valueArray.value.filter((v) => v).join(props.separator))
87
+ emitValue()
83
88
  }
84
89
 
85
- const baseOperation = {
86
- Backspace: (value: string, index: number) => {
87
- if (value) {
90
+ const baseOperation: Record<string, (value: string, index: number) => void> = {
91
+ Backspace: (_value: string, index: number) => {
92
+ if (index < valueArray.value.length) {
88
93
  valueArray.value.splice(index, 1)
89
94
  } else if (index - 1 >= 0) {
90
95
  valueArray.value.splice(index - 1, 1)
@@ -92,30 +97,29 @@ const baseOperation = {
92
97
  if (index !== 0) {
93
98
  focus(index - 1)
94
99
  }
95
- emit('input', valueArray.value.filter((v) => v).join(props.separator))
100
+ emitValue()
96
101
  },
97
- ArrowLeft: (value: string, index: number) => {
102
+ ArrowLeft: (_value: string, index: number) => {
98
103
  if (index === 0) return
99
104
  focus(index - 1)
100
105
  },
101
- ArrowRight: (value: string, index: number) => {
106
+ ArrowRight: (_value: string, index: number) => {
102
107
  if (index === valueArray.value.length) return
103
108
  focus(index + 1)
104
109
  }
105
110
  }
106
111
 
107
- const onKeydown = (e: any, value: string, index: number) => {
108
- if (_numberReg.value.test(e.key)) {
112
+ const onKeydown = (e: KeyboardEvent, value: string, index: number) => {
113
+ if (numberReg.value.test(e.key)) {
109
114
  changeValue(e.key, index)
110
115
  return
111
116
  }
112
- baseOperation[e.key](value, index)
117
+ baseOperation[e.key]?.(value, index)
113
118
  }
114
119
 
115
120
  const clear = () => {
116
- while (valueArray.value.length) {
117
- valueArray.value.pop()
118
- }
121
+ valueArray.value = []
122
+ position.value = -1
119
123
  }
120
124
 
121
125
  defineExpose<GridInputExposed>({ clear })
@@ -1,23 +1,30 @@
1
1
  import type { DeconstructValue } from '@veltra/utils'
2
2
 
3
- /** 密码输入框组件组件属性 */
3
+ /** 网格输入框组件属性 */
4
4
  export interface GridInputProps {
5
5
  modelValue?: string
6
+ /** 格子数量 */
6
7
  length?: number
7
- zero?: false
8
+ /**
9
+ * 是否允许输入 0
10
+ * @description 验证码场景通常开启;组织编码结构等场景关闭(如 3-3-2)
11
+ * @default false
12
+ */
13
+ zero?: boolean
14
+ /** 格子之间的分隔符 */
8
15
  separator?: string
9
16
  }
10
17
 
11
- /** 密码输入框组件组件定义的事件 */
18
+ /** 网格输入框组件定义的事件 */
12
19
  export interface GridInputEmits {
13
20
  (e: 'update:modelValue', value: string): void
14
21
  (e: 'input', value: string): void
15
22
  }
16
23
 
17
- /** 密码输入框组件组件暴露的属性和方法(组件内部使用) */
24
+ /** 网格输入框组件暴露的属性和方法(组件内部使用) */
18
25
  export interface _GridInputExposed {
19
26
  clear: () => void
20
27
  }
21
28
 
22
- /** 密码输入框组件组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
29
+ /** 网格输入框组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
23
30
  export type GridInputExposed = DeconstructValue<_GridInputExposed>