@veltra/desktop 1.1.22 → 1.1.23

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 (40) hide show
  1. package/dist/components/action/action-group.vue.d.ts +1 -1
  2. package/dist/components/action/action.vue.d.ts +1 -1
  3. package/dist/components/auto-complete/auto-complete.vue.d.ts +1 -1
  4. package/dist/components/cascade/cascade.vue.d.ts +1 -1
  5. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  6. package/dist/components/checkbox-group/checkbox-group.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 +1 -1
  9. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +1 -1
  10. package/dist/components/drawer/drawer.vue.d.ts +2 -2
  11. package/dist/components/empty/empty.vue.d.ts +1 -1
  12. package/dist/components/file-viewer/file-viewer.vue.d.ts +1 -1
  13. package/dist/components/input/input.vue.d.ts +1 -1
  14. package/dist/components/input/style2.css +5 -2
  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 +2 -2
  17. package/dist/components/number-input/number-input.vue.d.ts +1 -1
  18. package/dist/components/number-range-input/number-range-input.vue.d.ts +2 -2
  19. package/dist/components/password-input/password-input.js +30 -13
  20. package/dist/components/password-input/password-input.js.map +1 -1
  21. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  22. package/dist/components/password-input/style2.css +21 -0
  23. package/dist/components/pop-confirm/pop-confirm.vue.d.ts +1 -1
  24. package/dist/components/progress-nodes/progress-nodes.vue.d.ts +2 -2
  25. package/dist/components/radio-group/radio-group.vue.d.ts +1 -1
  26. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  27. package/dist/components/select/select.vue.d.ts +1 -1
  28. package/dist/components/tabs/tabs-horizontal.vue.d.ts +4 -4
  29. package/dist/components/tabs/tabs-vertical.vue.d.ts +4 -4
  30. package/dist/components/tabs/tabs.vue.d.ts +4 -4
  31. package/dist/components/textarea/style2.css +7 -4
  32. package/dist/components/textarea/textarea.vue.d.ts +1 -1
  33. package/dist/components/tip/tip.vue.d.ts +1 -1
  34. package/dist/components/tree-select/tree-select.vue.d.ts +2 -2
  35. package/package.json +6 -6
  36. package/src/components/input/style.scss +3 -6
  37. package/src/components/password-input/__test__/password-input.test.ts +90 -0
  38. package/src/components/password-input/password-input.vue +28 -13
  39. package/src/components/password-input/style.scss +22 -1
  40. package/src/components/textarea/style.scss +3 -2
@@ -8,9 +8,9 @@ type __VLS_Slots = {
8
8
  default?: () => VNode[];
9
9
  };
10
10
  declare const __VLS_base: _$vue.DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
11
- size: "small" | "default" | "large";
12
11
  type: _$_veltra_utils0.ColorType;
13
12
  text: boolean;
13
+ size: "small" | "default" | "large";
14
14
  circle: boolean;
15
15
  max: number;
16
16
  loading: boolean;
@@ -15,9 +15,9 @@ declare const __VLS_base: _$vue.DefineComponent<ActionProps, {}, {}, {}, {}, _$v
15
15
  }, string, _$vue.PublicProps, Readonly<ActionProps> & Readonly<{
16
16
  onRun?: (() => any) | undefined;
17
17
  }>, {
18
- size: _$_veltra_utils0.ComponentSize;
19
18
  type: ButtonType;
20
19
  text: boolean;
20
+ size: _$_veltra_utils0.ComponentSize;
21
21
  circle: boolean;
22
22
  loading: boolean;
23
23
  inDropdown: boolean;
@@ -25,9 +25,9 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
25
25
  onSelect?: ((value: string) => any) | undefined;
26
26
  }>, {
27
27
  disabled: boolean;
28
- readonly: boolean;
29
28
  placeholder: string;
30
29
  clearable: boolean;
30
+ readonly: boolean;
31
31
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
32
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
33
33
  declare const _default: typeof __VLS_export;
@@ -12,7 +12,6 @@ declare const __VLS_export: _$vue.DefineComponent<CascadeProps, {}, {}, {}, {},
12
12
  onChange?: ((...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any) | undefined;
13
13
  }>, {
14
14
  disabled: boolean;
15
- readonly: boolean;
16
15
  labelKey: string;
17
16
  valueKey: string;
18
17
  childrenKey: string;
@@ -20,6 +19,7 @@ declare const __VLS_export: _$vue.DefineComponent<CascadeProps, {}, {}, {}, {},
20
19
  placeholder: string;
21
20
  clearable: boolean;
22
21
  filterable: boolean;
22
+ readonly: boolean;
23
23
  visibilityLimit: number;
24
24
  separator: string;
25
25
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
@@ -21,8 +21,8 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
21
21
  onChange?: ((checked: boolean) => any) | undefined;
22
22
  }>, {
23
23
  disabled: boolean;
24
- readonly: boolean;
25
24
  type: _$_veltra_utils0.ColorType;
25
+ readonly: boolean;
26
26
  round: boolean;
27
27
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
28
28
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -15,9 +15,9 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
15
15
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
16
16
  }>, {
17
17
  disabled: boolean;
18
- readonly: boolean;
19
18
  labelKey: string;
20
19
  valueKey: string;
20
+ readonly: boolean;
21
21
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
22
22
  declare const _default: typeof __VLS_export;
23
23
  //#endregion
@@ -11,8 +11,8 @@ declare const __VLS_export: _$vue.DefineComponent<DatePanelProps, {}, {}, {}, {}
11
11
  "onSelect:range-date"?: ((rangeDate?: [_$_cat_kit_core0.Dater, _$_cat_kit_core0.Dater] | undefined) => any) | undefined;
12
12
  "onSelect:date"?: ((date: _$_cat_kit_core0.Dater) => any) | undefined;
13
13
  }>, {
14
- size: _$_veltra_utils0.ComponentSize;
15
14
  type: "date" | "month" | "year";
15
+ size: _$_veltra_utils0.ComponentSize;
16
16
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: typeof __VLS_export;
18
18
  //#endregion
@@ -8,10 +8,10 @@ declare const __VLS_export: _$vue.DefineComponent<DatePickerProps, {}, {}, {}, {
8
8
  "onUpdate:modelValue"?: ((value?: string | number | Date | undefined) => any) | undefined;
9
9
  }>, {
10
10
  disabled: boolean;
11
- readonly: boolean;
12
11
  type: "date" | "month" | "year";
13
12
  placeholder: string;
14
13
  clearable: boolean;
14
+ readonly: boolean;
15
15
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
16
16
  declare const _default: typeof __VLS_export;
17
17
  //#endregion
@@ -8,10 +8,10 @@ declare const __VLS_export: _$vue.DefineComponent<DateRangePickerProps, {}, {},
8
8
  "onUpdate:modelValue"?: ((value?: [string, string] | undefined) => any) | undefined;
9
9
  }>, {
10
10
  disabled: boolean;
11
- readonly: boolean;
12
11
  type: "date" | "month" | "year";
13
12
  placeholder: [string, string];
14
13
  clearable: boolean;
14
+ readonly: boolean;
15
15
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
16
16
  declare const _default: typeof __VLS_export;
17
17
  //#endregion
@@ -14,12 +14,12 @@ type __VLS_Slots = {} & {
14
14
  declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
15
15
  "update:modelValue": (value: boolean) => any;
16
16
  } & {
17
- "update:modelValue": (value: boolean) => any;
18
17
  close: () => any;
18
+ "update:modelValue": (value: boolean) => any;
19
19
  closed: () => any;
20
20
  }, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
- "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
22
21
  onClose?: (() => any) | undefined;
22
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
23
23
  onClosed?: (() => any) | undefined;
24
24
  }>, {
25
25
  direction: DrawerDirection;
@@ -3,8 +3,8 @@ import * as _$vue from "vue";
3
3
 
4
4
  //#region src/components/empty/empty.vue.d.ts
5
5
  declare const __VLS_export: _$vue.DefineComponent<EmptyProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<EmptyProps> & Readonly<{}>, {
6
- size: number;
7
6
  text: string;
7
+ size: number;
8
8
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
9
9
  declare const _default: typeof __VLS_export;
10
10
  //#endregion
@@ -28,8 +28,8 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, _FileViewer
28
28
  }) => any) | undefined;
29
29
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
30
30
  }>, {
31
- modelValue: string;
32
31
  open: boolean;
32
+ modelValue: string;
33
33
  sidebarWidth: string | number | false;
34
34
  sheetMaxRows: number;
35
35
  downloadable: boolean;
@@ -35,9 +35,9 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, _InputExposed
35
35
  "onNative:input"?: ((ev: Event) => any) | undefined;
36
36
  }>, {
37
37
  disabled: boolean;
38
- readonly: boolean;
39
38
  placeholder: string;
40
39
  clearable: boolean;
40
+ readonly: boolean;
41
41
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
42
42
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
43
43
  declare const _default: typeof __VLS_export;
@@ -35,6 +35,7 @@
35
35
  height: var(--u-form-component-height-small);
36
36
  border-radius: var(--u-radius-small);
37
37
  padding: 0 calc(var(--u-gap-small) / 2);
38
+ font-size: var(--u-font-size-main-small);
38
39
  }
39
40
  .u-input--small .u-input__native {
40
41
  height: var(--u-form-component-height-small);
@@ -44,6 +45,7 @@
44
45
  height: var(--u-form-component-height-default);
45
46
  border-radius: var(--u-radius-default);
46
47
  padding: 0 calc(var(--u-gap-default) / 2);
48
+ font-size: var(--u-font-size-main-default);
47
49
  }
48
50
  .u-input--default .u-input__native {
49
51
  height: var(--u-form-component-height-default);
@@ -53,6 +55,7 @@
53
55
  height: var(--u-form-component-height-large);
54
56
  border-radius: var(--u-radius-large);
55
57
  padding: 0 calc(var(--u-gap-large) / 2);
58
+ font-size: var(--u-font-size-main-large);
56
59
  }
57
60
  .u-input--large .u-input__native {
58
61
  height: var(--u-form-component-height-large);
@@ -68,7 +71,7 @@
68
71
  width: 100%;
69
72
  flex-grow: 1;
70
73
  color: var(--u-text-color-main);
71
- font-size: 1em;
74
+ font-size: inherit;
72
75
  padding: 0;
73
76
  font-family: var(--u-font-family);
74
77
  }
@@ -80,7 +83,7 @@
80
83
  color: var(--u-text-color-placeholder);
81
84
  }
82
85
  .u-input__prefix, .u-input__suffix {
83
- font-size: 14px;
86
+ font-size: inherit;
84
87
  color: var(--u-text-color-main);
85
88
  flex-shrink: 0;
86
89
  min-width: 20px;
@@ -28,13 +28,13 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
28
28
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
29
29
  onChange?: ((options: Record<string, any>[]) => any) | undefined;
30
30
  }>, {
31
+ minWidth: string;
31
32
  disabled: boolean;
32
- readonly: boolean;
33
33
  labelKey: string;
34
34
  valueKey: string;
35
35
  placeholder: string;
36
36
  clearable: boolean;
37
- minWidth: string;
37
+ readonly: boolean;
38
38
  visibilityLimit: number;
39
39
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
40
40
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -22,15 +22,15 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
22
22
  onClear?: (() => any) | undefined;
23
23
  onChange?: ((checked: Record<string, any>[]) => any) | undefined;
24
24
  }>, {
25
+ minWidth: string;
25
26
  disabled: boolean;
26
- readonly: boolean;
27
27
  expandAll: boolean;
28
28
  labelKey: string;
29
29
  valueKey: string;
30
30
  placeholder: string;
31
31
  clearable: boolean;
32
32
  filterable: boolean;
33
- minWidth: string;
33
+ readonly: boolean;
34
34
  visibilityLimit: number;
35
35
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
36
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -23,9 +23,9 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
23
23
  onChange?: ((value?: number | undefined) => any) | undefined;
24
24
  }>, {
25
25
  disabled: boolean;
26
- readonly: boolean;
27
26
  placeholder: string;
28
27
  clearable: boolean;
28
+ readonly: boolean;
29
29
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
30
30
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
31
31
  declare const _default: typeof __VLS_export;
@@ -25,11 +25,11 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
25
25
  "onUpdate:end"?: ((value: number | undefined) => any) | undefined;
26
26
  }>, {
27
27
  disabled: boolean;
28
- readonly: boolean;
29
28
  clearable: boolean;
30
- separator: string;
29
+ readonly: boolean;
31
30
  startPlaceholder: string;
32
31
  endPlaceholder: string;
32
+ separator: string;
33
33
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
34
34
  declare const _default: typeof __VLS_export;
35
35
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import _sfc_main$1 from "../icon/icon.js";
2
2
  import input_default from "../input/input.js";
3
- import { Transition, computed, createBlock, createSlots, createVNode, defineComponent, mergeModels, mergeProps, nextTick, normalizeClass, openBlock, renderSlot, shallowRef, unref, useModel, useSlots, withCtx } from "vue";
3
+ import { computed, createBlock, createCommentVNode, createElementVNode, createSlots, createVNode, defineComponent, mergeModels, mergeProps, nextTick, normalizeClass, openBlock, ref, renderSlot, shallowRef, unref, useModel, useSlots, withCtx, withModifiers } from "vue";
4
4
  import { useFormFallbackProps } from "@veltra/compositions";
5
5
  import { bem, injectFormContext } from "@veltra/utils";
6
- import { Hide, View } from "@veltra/icons/normal";
6
+ import { Close, Hide, View } from "@veltra/icons/normal";
7
7
  import { o } from "@cat-kit/core";
8
8
  //#region src/components/password-input/password-input.vue
9
9
  const passwordChar = "●";
@@ -50,7 +50,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
50
50
  });
51
51
  const inputProps = computed(() => {
52
52
  return o(props).pick([
53
- "clearable",
54
53
  "disabled",
55
54
  "placeholder",
56
55
  "size"
@@ -58,6 +57,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
58
57
  });
59
58
  const cls = bem("password-input");
60
59
  const model = useModel(__props, "modelValue");
60
+ const hovered = ref(false);
61
+ const handleMouseEnter = () => {
62
+ hovered.value = true;
63
+ };
64
+ const handleMouseLeave = () => {
65
+ hovered.value = false;
66
+ };
67
+ const showClear = computed(() => {
68
+ return props.clearable && !disabled.value && !!model.value && hovered.value;
69
+ });
61
70
  const handleUpdatePwd = (e) => {
62
71
  const target = e.target;
63
72
  const val = target.value;
@@ -101,20 +110,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
101
110
  size: unref(size),
102
111
  readonly: unref(readonly),
103
112
  disabled: unref(disabled),
113
+ clearable: false,
104
114
  "onNative:input": handleUpdatePwd,
105
115
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => !$event && handleClear()),
106
- "onSuffix:click": toggleVisible
116
+ onMouseenter: handleMouseEnter,
117
+ onMouseleave: handleMouseLeave
107
118
  }), createSlots({
108
- suffix: withCtx(() => [createVNode(Transition, { name: "fade" }, {
109
- default: withCtx(() => [createVNode(unref(_sfc_main$1), {
110
- class: normalizeClass(unref(cls).e("visibility-toggle")),
111
- size: 18
112
- }, {
113
- default: withCtx(() => [pwdVisible.value ? (openBlock(), createBlock(unref(Hide), { key: 0 })) : (openBlock(), createBlock(unref(View), { key: 1 }))]),
114
- _: 1
115
- }, 8, ["class"])]),
119
+ suffix: withCtx(() => [createElementVNode("span", { class: normalizeClass(unref(cls).e("suffix")) }, [showClear.value ? (openBlock(), createBlock(unref(_sfc_main$1), {
120
+ key: 0,
121
+ class: normalizeClass(unref(cls).e("clear")),
122
+ title: "清除",
123
+ onClick: withModifiers(handleClear, ["stop"])
124
+ }, {
125
+ default: withCtx(() => [createVNode(unref(Close))]),
126
+ _: 1
127
+ }, 8, ["class"])) : createCommentVNode("v-if", true), createVNode(unref(_sfc_main$1), {
128
+ class: normalizeClass(unref(cls).e("visibility-toggle")),
129
+ size: 18,
130
+ onClick: withModifiers(toggleVisible, ["stop"])
131
+ }, {
132
+ default: withCtx(() => [pwdVisible.value ? (openBlock(), createBlock(unref(Hide), { key: 0 })) : (openBlock(), createBlock(unref(View), { key: 1 }))]),
116
133
  _: 1
117
- })]),
134
+ }, 8, ["class"])], 2)]),
118
135
  _: 2
119
136
  }, [slots.prefix ? {
120
137
  name: "prefix",
@@ -1 +1 @@
1
- {"version":3,"file":"password-input.js","names":[],"sources":["../../../src/components/password-input/password-input.vue"],"sourcesContent":["<template>\n <u-input\n :class=\"cls.b\"\n :model-value=\"passwordText\"\n v-bind=\"inputProps\"\n :size=\"size\"\n :readonly=\"readonly\"\n :disabled=\"disabled\"\n @native:input=\"handleUpdatePwd\"\n @update:model-value=\"!$event && handleClear()\"\n @suffix:click=\"toggleVisible\"\n >\n <template #suffix>\n <Transition name=\"fade\">\n <UIcon :class=\"cls.e('visibility-toggle')\" :size=\"18\">\n <Hide v-if=\"pwdVisible\" />\n <View v-else />\n </UIcon>\n </Transition>\n </template>\n\n <template #prefix v-if=\"slots.prefix\">\n <slot name=\"prefix\" />\n </template>\n </u-input>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { Hide, View } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, nextTick, shallowRef } from 'vue'\n\nimport type { PasswordInputProps } from '../../types'\nimport { UIcon } from '../icon'\nimport { UInput } from '../input'\n\ndefineOptions({\n name: 'PasswordInput'\n})\n\nconst props = withDefaults(defineProps<PasswordInputProps>(), {\n clearable: false,\n disabled: undefined,\n readonly: undefined\n})\n\nconst slots = defineSlots<{\n prefix?: () => any\n}>()\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default',\n disabled: false,\n readonly: false\n})\n\nconst inputProps = computed(() => {\n return o(props).pick(['clearable', 'disabled', 'placeholder', 'size'])\n})\n\nconst cls = bem('password-input')\n\nconst model = defineModel<string>()\n\nconst passwordChar = '●'\n\nconst handleUpdatePwd = (e: Event): void => {\n const target = e.target as HTMLInputElement\n const val = target.value\n if (!val) {\n model.value = val\n return\n }\n\n // 字符从无到有\n if (!model.value) {\n model.value = val\n return\n }\n\n const pointIndex = target.selectionStart!\n let inputChar = pointIndex === 0 ? '' : val[pointIndex - 1]!\n if (inputChar === passwordChar) inputChar = ''\n\n // 光标右侧字符数量(当前字符长度减去光标位置)\n const rightLen = val.length - pointIndex\n // 光标左侧字符数量 (当光标前的字符是刚刚输入的,则为这个字符前的所有的字符,否则为光标前的所有赐福)\n const leftLen = inputChar === '' ? pointIndex : pointIndex - 1\n\n const leftVal = model.value.slice(0, leftLen)\n const rightVal = rightLen === 0 ? '' : model.value.slice(-rightLen)\n\n model.value = leftVal + inputChar + rightVal\n\n nextTick(() => {\n target.selectionStart = pointIndex\n target.selectionEnd = pointIndex\n })\n}\n\nconst handleClear = (): void => {\n model.value = ''\n}\n\nconst pwdVisible = shallowRef(false)\n\nconst passwordText = computed<string | undefined>(() => {\n if (pwdVisible.value) return model.value\n return model.value ? passwordChar.repeat(model.value.length) : ''\n})\n\nconst toggleVisible = () => {\n pwdVisible.value = !pwdVisible.value\n}\n</script>\n"],"mappings":";;;;;;;;AAqEA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA1BrB,MAAM,QAAQ;EAMd,MAAM,QAAQ,UAAA;EAId,MAAM,EAAE,cAAc,mBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,EAAC,EAAG,MAAK,EAAG;GAClF,MAAM;GACN,UAAU;GACV,UAAU;GACX,CAAA;EAED,MAAM,aAAa,eAAe;GAChC,OAAO,EAAE,MAAK,CAAE,KAAK;IAAC;IAAa;IAAY;IAAe;IAAO,CAAA;IACtE;EAED,MAAM,MAAM,IAAI,iBAAgB;EAEhC,MAAM,QAAQ,SAAmB,SAAA,aAAC;EAIlC,MAAM,mBAAmB,MAAmB;GAC1C,MAAM,SAAS,EAAE;GACjB,MAAM,MAAM,OAAO;GACnB,IAAI,CAAC,KAAK;IACR,MAAM,QAAQ;IACd;;GAIF,IAAI,CAAC,MAAM,OAAO;IAChB,MAAM,QAAQ;IACd;;GAGF,MAAM,aAAa,OAAO;GAC1B,IAAI,YAAY,eAAe,IAAI,KAAK,IAAI,aAAa;GACzD,IAAI,cAAc,cAAc,YAAY;GAG5C,MAAM,WAAW,IAAI,SAAS;GAE9B,MAAM,UAAU,cAAc,KAAK,aAAa,aAAa;GAE7D,MAAM,UAAU,MAAM,MAAM,MAAM,GAAG,QAAO;GAC5C,MAAM,WAAW,aAAa,IAAI,KAAK,MAAM,MAAM,MAAM,CAAC,SAAQ;GAElE,MAAM,QAAQ,UAAU,YAAY;GAEpC,eAAe;IACb,OAAO,iBAAiB;IACxB,OAAO,eAAe;KACvB;;EAGH,MAAM,oBAA0B;GAC9B,MAAM,QAAQ;;EAGhB,MAAM,aAAa,WAAW,MAAK;EAEnC,MAAM,eAAe,eAAmC;GACtD,IAAI,WAAW,OAAO,OAAO,MAAM;GACnC,OAAO,MAAM,QAAQ,aAAa,OAAO,MAAM,MAAM,OAAM,GAAI;IAChE;EAED,MAAM,sBAAsB;GAC1B,WAAW,QAAQ,CAAC,WAAW;;;uBApH/B,YAuBU,MAAA,cAAA,EAvBV,WAuBU;IAtBP,OAAO,MAAA,IAAA,CAAI;IACX,eAAa,aAAA;MACN,WAAA,OAAU;IACjB,MAAM,MAAA,KAAA;IACN,UAAU,MAAA,SAAA;IACV,UAAU,MAAA,SAAA;IACV,kBAAc;IACd,uBAAkB,OAAA,OAAA,OAAA,MAAA,WAAA,CAAG,UAAU,aAAW;IAC1C,kBAAc;;IAEJ,QAAM,cAMF,CALb,YAKa,YAAA,EALD,MAAK,QAAM,EAAA;4BAIb,CAHR,YAGQ,MAAA,YAAA,EAAA;MAHA,OAAK,eAAE,MAAA,IAAA,CAAI,EAAC,oBAAA,CAAA;MAAwB,MAAM;;6BACtB,CAAd,WAAA,SAAA,WAAA,EAAZ,YAA0B,MAAA,KAAA,EAAA,EAAA,KAAA,GAAA,CAAA,KAAA,WAAA,EAC1B,YAAe,MAAA,KAAA,EAAA,EAAA,KAAA,GAAA,CAAA,EAAA,CAAA;;;;;;OAKG,MAAM,SAAA;UAAnB;sBACa,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"password-input.js","names":[],"sources":["../../../src/components/password-input/password-input.vue"],"sourcesContent":["<template>\n <u-input\n :class=\"cls.b\"\n :model-value=\"passwordText\"\n v-bind=\"inputProps\"\n :size=\"size\"\n :readonly=\"readonly\"\n :disabled=\"disabled\"\n :clearable=\"false\"\n @native:input=\"handleUpdatePwd\"\n @update:model-value=\"!$event && handleClear()\"\n @mouseenter=\"handleMouseEnter\"\n @mouseleave=\"handleMouseLeave\"\n >\n <template #suffix>\n <span :class=\"cls.e('suffix')\">\n <UIcon v-if=\"showClear\" :class=\"cls.e('clear')\" title=\"清除\" @click.stop=\"handleClear\">\n <Close />\n </UIcon>\n <UIcon :class=\"cls.e('visibility-toggle')\" :size=\"18\" @click.stop=\"toggleVisible\">\n <Hide v-if=\"pwdVisible\" />\n <View v-else />\n </UIcon>\n </span>\n </template>\n\n <template #prefix v-if=\"slots.prefix\">\n <slot name=\"prefix\" />\n </template>\n </u-input>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { Close, Hide, View } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, nextTick, ref, shallowRef } from 'vue'\n\nimport type { PasswordInputProps } from '../../types'\nimport { UIcon } from '../icon'\nimport { UInput } from '../input'\n\ndefineOptions({ name: 'PasswordInput' })\n\nconst props = withDefaults(defineProps<PasswordInputProps>(), {\n clearable: false,\n disabled: undefined,\n readonly: undefined\n})\n\nconst slots = defineSlots<{ prefix?: () => any }>()\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default',\n disabled: false,\n readonly: false\n})\n\nconst inputProps = computed(() => {\n return o(props).pick(['disabled', 'placeholder', 'size'])\n})\n\nconst cls = bem('password-input')\n\nconst model = defineModel<string>()\n\nconst hovered = ref(false)\n\nconst handleMouseEnter = (): void => {\n hovered.value = true\n}\n\nconst handleMouseLeave = (): void => {\n hovered.value = false\n}\n\nconst showClear = computed(() => {\n return props.clearable && !disabled.value && !!model.value && hovered.value\n})\n\nconst passwordChar = '●'\n\nconst handleUpdatePwd = (e: Event): void => {\n const target = e.target as HTMLInputElement\n const val = target.value\n if (!val) {\n model.value = val\n return\n }\n\n // 字符从无到有\n if (!model.value) {\n model.value = val\n return\n }\n\n const pointIndex = target.selectionStart!\n let inputChar = pointIndex === 0 ? '' : val[pointIndex - 1]!\n if (inputChar === passwordChar) inputChar = ''\n\n // 光标右侧字符数量(当前字符长度减去光标位置)\n const rightLen = val.length - pointIndex\n // 光标左侧字符数量 (当光标前的字符是刚刚输入的,则为这个字符前的所有的字符,否则为光标前的所有赐福)\n const leftLen = inputChar === '' ? pointIndex : pointIndex - 1\n\n const leftVal = model.value.slice(0, leftLen)\n const rightVal = rightLen === 0 ? '' : model.value.slice(-rightLen)\n\n model.value = leftVal + inputChar + rightVal\n\n nextTick(() => {\n target.selectionStart = pointIndex\n target.selectionEnd = pointIndex\n })\n}\n\nconst handleClear = (): void => {\n model.value = ''\n}\n\nconst pwdVisible = shallowRef(false)\n\nconst passwordText = computed<string | undefined>(() => {\n if (pwdVisible.value) return model.value\n return model.value ? passwordChar.repeat(model.value.length) : ''\n})\n\nconst toggleVisible = () => {\n pwdVisible.value = !pwdVisible.value\n}\n</script>\n"],"mappings":"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"}
@@ -16,8 +16,8 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
16
16
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
17
17
  }>, {
18
18
  disabled: boolean;
19
- readonly: boolean;
20
19
  clearable: boolean;
20
+ readonly: boolean;
21
21
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
22
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
23
  declare const _default: typeof __VLS_export;
@@ -15,3 +15,24 @@
15
15
  * --u-height-small: 24px;
16
16
  */
17
17
  /** 暗色:data-theme 与系统偏好,与 UITheme.injectBuiltInThemes 选择器策略一致 */
18
+ .u-password-input__suffix {
19
+ display: inline-flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ height: 100%;
23
+ gap: 2px;
24
+ }
25
+ .u-password-input__clear {
26
+ cursor: pointer;
27
+ flex-shrink: 0;
28
+ width: 20px;
29
+ border-radius: var(--u-radius-default);
30
+ transition: color 0.25s;
31
+ }
32
+ .u-password-input__clear:hover {
33
+ color: var(--u-color-primary);
34
+ }
35
+ .u-password-input__visibility-toggle {
36
+ cursor: pointer;
37
+ flex-shrink: 0;
38
+ }
@@ -14,8 +14,8 @@ declare const __VLS_base: _$vue.DefineComponent<PopConfirmProps, {}, {}, {}, {},
14
14
  onConfirm?: (() => any) | undefined;
15
15
  onCancel?: (() => any) | undefined;
16
16
  }>, {
17
- direction: TipDirection;
18
17
  trigger: "hover" | "click";
18
+ direction: TipDirection;
19
19
  icon: _$vue.Component;
20
20
  iconColor: string;
21
21
  confirmText: string;
@@ -16,11 +16,11 @@ type __VLS_Slots = {} & {
16
16
  default?: (props: typeof __VLS_3) => any;
17
17
  };
18
18
  declare const __VLS_base: _$vue.DefineComponent<ProgressNodesProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {} & {
19
- "update:modelValue": (value: string | number) => any;
20
19
  click: (node: Record<string, any>, index: number) => any;
20
+ "update:modelValue": (value: string | number) => any;
21
21
  }, string, _$vue.PublicProps, Readonly<ProgressNodesProps> & Readonly<{
22
- "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
23
22
  onClick?: ((node: Record<string, any>, index: number) => any) | undefined;
23
+ "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
24
24
  }>, {
25
25
  labelKey: string;
26
26
  valueKey: string;
@@ -17,9 +17,9 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
17
17
  onChange?: ((item: Record<string, any>) => any) | undefined;
18
18
  }>, {
19
19
  disabled: boolean;
20
- readonly: boolean;
21
20
  labelKey: string;
22
21
  valueKey: string;
22
+ readonly: boolean;
23
23
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: typeof __VLS_export;
25
25
  //#endregion
@@ -13,8 +13,8 @@ declare const __VLS_export: _$vue.DefineComponent<RichTextEditorProps & {
13
13
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
14
14
  }>, {
15
15
  disabled: boolean;
16
- readonly: boolean;
17
16
  placeholder: string;
17
+ readonly: boolean;
18
18
  format: RichTextFormat;
19
19
  toolbar: ToolbarItem[];
20
20
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
@@ -27,11 +27,11 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
27
27
  "onUpdate:label"?: ((label?: string | undefined) => any) | undefined;
28
28
  }>, {
29
29
  disabled: boolean;
30
- readonly: boolean;
31
30
  labelKey: string;
32
31
  valueKey: string;
33
32
  placeholder: string;
34
33
  clearable: boolean;
34
+ readonly: boolean;
35
35
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
36
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
37
37
  declare const _default: typeof __VLS_export;
@@ -15,13 +15,13 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
15
15
  declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
16
16
  "update:modelValue": (value: string | undefined) => any;
17
17
  } & {
18
- "update:modelValue": (value: string) => any;
19
- click: (item: TabItem, index: number) => any;
20
18
  close: (item: TabItem, index: number) => any;
19
+ click: (item: TabItem, index: number) => any;
20
+ "update:modelValue": (value: string) => any;
21
21
  }, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
23
- onClick?: ((item: TabItem, index: number) => any) | undefined;
24
22
  onClose?: ((item: TabItem, index: number) => any) | undefined;
23
+ onClick?: ((item: TabItem, index: number) => any) | undefined;
24
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
25
25
  }>, {
26
26
  closable: boolean;
27
27
  rounded: boolean;
@@ -14,13 +14,13 @@ type __VLS_Slots = {} & { [K in NonNullable<typeof __VLS_2>]?: (props: typeof __
14
14
  declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
15
15
  "update:modelValue": (value: string | undefined) => any;
16
16
  } & {
17
- "update:modelValue": (value: string) => any;
18
- click: (item: TabItem, index: number) => any;
19
17
  close: (item: TabItem, index: number) => any;
18
+ click: (item: TabItem, index: number) => any;
19
+ "update:modelValue": (value: string) => any;
20
20
  }, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
22
- onClick?: ((item: TabItem, index: number) => any) | undefined;
23
21
  onClose?: ((item: TabItem, index: number) => any) | undefined;
22
+ onClick?: ((item: TabItem, index: number) => any) | undefined;
23
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
24
24
  }>, {
25
25
  closable: boolean;
26
26
  rounded: boolean;
@@ -10,13 +10,13 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
10
  declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
11
11
  "update:modelValue": (value: string | undefined) => any;
12
12
  } & {
13
- "update:modelValue": (value: string) => any;
14
- click: (item: TabItem, index: number) => any;
15
13
  close: (item: TabItem, index: number) => any;
14
+ click: (item: TabItem, index: number) => any;
15
+ "update:modelValue": (value: string) => any;
16
16
  }, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
17
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
18
- onClick?: ((item: TabItem, index: number) => any) | undefined;
19
17
  onClose?: ((item: TabItem, index: number) => any) | undefined;
18
+ onClick?: ((item: TabItem, index: number) => any) | undefined;
19
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
20
20
  }>, {
21
21
  closable: boolean;
22
22
  rounded: boolean;
@@ -29,6 +29,7 @@
29
29
  }
30
30
  .u-textarea--small {
31
31
  border-radius: var(--u-radius-small);
32
+ font-size: var(--u-font-size-main-small);
32
33
  }
33
34
  .u-textarea--small .u-textarea__native {
34
35
  padding: calc(var(--u-gap-small) / 2);
@@ -36,10 +37,11 @@
36
37
  padding-right: 20px;
37
38
  }
38
39
  .u-textarea--small .u-textarea__clear {
39
- font-size: var(--u-font-size-main-small);
40
+ font-size: inherit;
40
41
  }
41
42
  .u-textarea--default {
42
43
  border-radius: var(--u-radius-default);
44
+ font-size: var(--u-font-size-main-default);
43
45
  }
44
46
  .u-textarea--default .u-textarea__native {
45
47
  padding: calc(var(--u-gap-default) / 2);
@@ -47,10 +49,11 @@
47
49
  padding-right: 20px;
48
50
  }
49
51
  .u-textarea--default .u-textarea__clear {
50
- font-size: var(--u-font-size-main-default);
52
+ font-size: inherit;
51
53
  }
52
54
  .u-textarea--large {
53
55
  border-radius: var(--u-radius-large);
56
+ font-size: var(--u-font-size-main-large);
54
57
  }
55
58
  .u-textarea--large .u-textarea__native {
56
59
  padding: calc(var(--u-gap-large) / 2);
@@ -58,7 +61,7 @@
58
61
  padding-right: 20px;
59
62
  }
60
63
  .u-textarea--large .u-textarea__clear {
61
- font-size: var(--u-font-size-main-large);
64
+ font-size: inherit;
62
65
  }
63
66
  .u-textarea__native {
64
67
  color: var(--u-text-color-main);
@@ -66,7 +69,7 @@
66
69
  border: none;
67
70
  background-color: transparent;
68
71
  font-family: var(--u-font-family);
69
- font-size: 1em;
72
+ font-size: inherit;
70
73
  width: 100%;
71
74
  display: block;
72
75
  padding: 0;
@@ -23,9 +23,9 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
23
23
  onBlur?: (() => any) | undefined;
24
24
  }>, {
25
25
  disabled: boolean;
26
- readonly: boolean;
27
26
  placeholder: string;
28
27
  clearable: boolean;
28
+ readonly: boolean;
29
29
  resize: boolean;
30
30
  autosize: boolean;
31
31
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
@@ -11,10 +11,10 @@ declare const __VLS_base: _$vue.DefineComponent<TipProps, {}, {}, {}, {}, _$vue.
11
11
  }, string, _$vue.PublicProps, Readonly<TipProps> & Readonly<{
12
12
  "onUpdate:visible"?: ((value: boolean) => any) | undefined;
13
13
  }>, {
14
- direction: TipDirection;
15
14
  trigger: "hover" | "click";
16
15
  contentTag: string;
17
16
  visible: boolean;
17
+ direction: TipDirection;
18
18
  content: string;
19
19
  alignment: TipAlign;
20
20
  }, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
@@ -24,15 +24,15 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
24
24
  onChange?: ((value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any) | undefined;
25
25
  "onUpdate:text"?: ((text?: string | undefined) => any) | undefined;
26
26
  }>, {
27
+ minWidth: string;
27
28
  disabled: boolean;
28
- readonly: boolean;
29
29
  expandAll: boolean;
30
30
  labelKey: string;
31
31
  valueKey: string;
32
32
  placeholder: string;
33
33
  clearable: boolean;
34
34
  filterable: boolean;
35
- minWidth: string;
35
+ readonly: boolean;
36
36
  }, {}, {}, {}, string, _$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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -68,11 +68,11 @@
68
68
  "@cat-kit/core": ">=1.1.5",
69
69
  "@cat-kit/excel": ">=1.0.0",
70
70
  "@cat-kit/fe": "^1.1.5",
71
- "@veltra/compositions": "1.1.22",
72
- "@veltra/directives": "1.1.22",
73
- "@veltra/icons": "1.1.22",
74
- "@veltra/styles": "1.1.22",
75
- "@veltra/utils": "1.1.22",
71
+ "@veltra/compositions": "1.1.23",
72
+ "@veltra/directives": "1.1.23",
73
+ "@veltra/icons": "1.1.23",
74
+ "@veltra/styles": "1.1.23",
75
+ "@veltra/utils": "1.1.23",
76
76
  "vue": ">=3.5.0"
77
77
  }
78
78
  }
@@ -28,15 +28,12 @@ $root-name: input;
28
28
  height: fn.use-var(form-component-height, $size);
29
29
  border-radius: fn.use-var(radius, $size);
30
30
  padding: 0 calc(fn.use-var(gap, $size) / 2);
31
+ font-size: fn.use-var(font-size-main, $size);
31
32
 
32
33
  @include m.bem($root-name, native) {
33
34
  height: fn.use-var(form-component-height, $size);
34
35
  line-height: fn.use-var(form-component-height, $size);
35
36
  }
36
-
37
- // @include m.bem($root-name, clear) {
38
- // font-size: fn.use-var(font-size-main, $size);
39
- // }
40
37
  }
41
38
 
42
39
  @include m.is(focus) {
@@ -51,7 +48,7 @@ $root-name: input;
51
48
  width: 100%;
52
49
  flex-grow: 1;
53
50
  color: fn.use-var(text-color, main);
54
- font-size: 1em;
51
+ font-size: inherit;
55
52
  padding: 0;
56
53
  font-family: fn.use-var(font-family);
57
54
 
@@ -66,7 +63,7 @@ $root-name: input;
66
63
  }
67
64
 
68
65
  @include m.e(prefix, suffix) {
69
- font-size: 14px;
66
+ font-size: inherit;
70
67
  color: fn.use-var(text-color, main);
71
68
  flex-shrink: 0;
72
69
  min-width: 20px;
@@ -0,0 +1,90 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { createApp, h, nextTick, ref } from 'vue'
3
+
4
+ import UPasswordInput from '../password-input.vue'
5
+
6
+ function mountPasswordInput(props: Record<string, unknown>) {
7
+ const host = document.createElement('div')
8
+ document.body.appendChild(host)
9
+
10
+ const model = ref(props.modelValue as string | undefined)
11
+ const app = createApp({
12
+ render() {
13
+ return h(UPasswordInput, {
14
+ ...props,
15
+ modelValue: model.value,
16
+ 'onUpdate:modelValue': (value: string | undefined) => {
17
+ model.value = value
18
+ }
19
+ })
20
+ }
21
+ })
22
+
23
+ app.mount(host)
24
+
25
+ return {
26
+ host,
27
+ model,
28
+ unmount() {
29
+ app.unmount()
30
+ host.remove()
31
+ }
32
+ }
33
+ }
34
+
35
+ describe('PasswordInput', () => {
36
+ it('keeps visibility toggle while clear control is shown on hover', async () => {
37
+ const { host, unmount } = mountPasswordInput({ modelValue: 'secret', clearable: true })
38
+
39
+ try {
40
+ expect(host.querySelector('.u-password-input__visibility-toggle')).not.toBeNull()
41
+
42
+ host.querySelector('.u-password-input')?.dispatchEvent(new MouseEvent('mouseenter'))
43
+ await nextTick()
44
+
45
+ expect(host.querySelector('.u-password-input__clear')).not.toBeNull()
46
+ expect(host.querySelector('.u-password-input__visibility-toggle')).not.toBeNull()
47
+ } finally {
48
+ unmount()
49
+ }
50
+ })
51
+
52
+ it('toggles password visibility when clearable', async () => {
53
+ const { host, unmount } = mountPasswordInput({ modelValue: 'secret', clearable: true })
54
+
55
+ try {
56
+ const native = host.querySelector('.u-input__native') as HTMLInputElement
57
+ expect(native.value).toBe('●●●●●●')
58
+
59
+ host
60
+ .querySelector('.u-password-input__visibility-toggle')
61
+ ?.dispatchEvent(new MouseEvent('click', { bubbles: true }))
62
+ await nextTick()
63
+
64
+ expect(native.value).toBe('secret')
65
+ } finally {
66
+ unmount()
67
+ }
68
+ })
69
+
70
+ it('toggles password visibility when clear control is visible on hover', async () => {
71
+ const { host, unmount } = mountPasswordInput({ modelValue: 'secret', clearable: true })
72
+
73
+ try {
74
+ const native = host.querySelector('.u-input__native') as HTMLInputElement
75
+ host.querySelector('.u-password-input')?.dispatchEvent(new MouseEvent('mouseenter'))
76
+ await nextTick()
77
+
78
+ expect(host.querySelector('.u-password-input__clear')).not.toBeNull()
79
+
80
+ host
81
+ .querySelector('.u-password-input__visibility-toggle')
82
+ ?.dispatchEvent(new MouseEvent('click', { bubbles: true }))
83
+ await nextTick()
84
+
85
+ expect(native.value).toBe('secret')
86
+ } finally {
87
+ unmount()
88
+ }
89
+ })
90
+ })
@@ -6,17 +6,22 @@
6
6
  :size="size"
7
7
  :readonly="readonly"
8
8
  :disabled="disabled"
9
+ :clearable="false"
9
10
  @native:input="handleUpdatePwd"
10
11
  @update:model-value="!$event && handleClear()"
11
- @suffix:click="toggleVisible"
12
+ @mouseenter="handleMouseEnter"
13
+ @mouseleave="handleMouseLeave"
12
14
  >
13
15
  <template #suffix>
14
- <Transition name="fade">
15
- <UIcon :class="cls.e('visibility-toggle')" :size="18">
16
+ <span :class="cls.e('suffix')">
17
+ <UIcon v-if="showClear" :class="cls.e('clear')" title="清除" @click.stop="handleClear">
18
+ <Close />
19
+ </UIcon>
20
+ <UIcon :class="cls.e('visibility-toggle')" :size="18" @click.stop="toggleVisible">
16
21
  <Hide v-if="pwdVisible" />
17
22
  <View v-else />
18
23
  </UIcon>
19
- </Transition>
24
+ </span>
20
25
  </template>
21
26
 
22
27
  <template #prefix v-if="slots.prefix">
@@ -28,18 +33,16 @@
28
33
  <script lang="ts" setup>
29
34
  import { o } from '@cat-kit/core'
30
35
  import { useFormFallbackProps } from '@veltra/compositions'
31
- import { Hide, View } from '@veltra/icons/normal'
36
+ import { Close, Hide, View } from '@veltra/icons/normal'
32
37
  import { bem } from '@veltra/utils'
33
38
  import { injectFormContext } from '@veltra/utils'
34
- import { computed, nextTick, shallowRef } from 'vue'
39
+ import { computed, nextTick, ref, shallowRef } from 'vue'
35
40
 
36
41
  import type { PasswordInputProps } from '../../types'
37
42
  import { UIcon } from '../icon'
38
43
  import { UInput } from '../input'
39
44
 
40
- defineOptions({
41
- name: 'PasswordInput'
42
- })
45
+ defineOptions({ name: 'PasswordInput' })
43
46
 
44
47
  const props = withDefaults(defineProps<PasswordInputProps>(), {
45
48
  clearable: false,
@@ -47,9 +50,7 @@ const props = withDefaults(defineProps<PasswordInputProps>(), {
47
50
  readonly: undefined
48
51
  })
49
52
 
50
- const slots = defineSlots<{
51
- prefix?: () => any
52
- }>()
53
+ const slots = defineSlots<{ prefix?: () => any }>()
53
54
 
54
55
  const { formProps } = injectFormContext()
55
56
 
@@ -60,13 +61,27 @@ const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, prop
60
61
  })
61
62
 
62
63
  const inputProps = computed(() => {
63
- return o(props).pick(['clearable', 'disabled', 'placeholder', 'size'])
64
+ return o(props).pick(['disabled', 'placeholder', 'size'])
64
65
  })
65
66
 
66
67
  const cls = bem('password-input')
67
68
 
68
69
  const model = defineModel<string>()
69
70
 
71
+ const hovered = ref(false)
72
+
73
+ const handleMouseEnter = (): void => {
74
+ hovered.value = true
75
+ }
76
+
77
+ const handleMouseLeave = (): void => {
78
+ hovered.value = false
79
+ }
80
+
81
+ const showClear = computed(() => {
82
+ return props.clearable && !disabled.value && !!model.value && hovered.value
83
+ })
84
+
70
85
  const passwordChar = '●'
71
86
 
72
87
  const handleUpdatePwd = (e: Event): void => {
@@ -5,7 +5,28 @@
5
5
  $root-name: password-input;
6
6
 
7
7
  @include m.b($root-name) {
8
+ @include m.e(suffix) {
9
+ display: inline-flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ height: 100%;
13
+ gap: 2px;
14
+ }
15
+
16
+ @include m.e(clear) {
17
+ cursor: pointer;
18
+ flex-shrink: 0;
19
+ width: 20px;
20
+ border-radius: fn.use-var(radius, default);
21
+ transition: color 0.25s;
22
+
23
+ &:hover {
24
+ color: fn.use-var(color, primary);
25
+ }
26
+ }
27
+
8
28
  @include m.e(visibility-toggle) {
9
- // cursor: pointer;
29
+ cursor: pointer;
30
+ flex-shrink: 0;
10
31
  }
11
32
  }
@@ -23,6 +23,7 @@ $root-name: textarea;
23
23
 
24
24
  @include m.size using ($size) {
25
25
  border-radius: fn.use-var(radius, $size);
26
+ font-size: fn.use-var(font-size-main, $size);
26
27
 
27
28
  @include m.bem($root-name, native) {
28
29
  padding: calc(fn.use-var(gap, $size) / 2);
@@ -31,7 +32,7 @@ $root-name: textarea;
31
32
  }
32
33
 
33
34
  @include m.bem($root-name, clear) {
34
- font-size: fn.use-var(font-size-main, $size);
35
+ font-size: inherit;
35
36
  }
36
37
  }
37
38
 
@@ -41,7 +42,7 @@ $root-name: textarea;
41
42
  border: none;
42
43
  background-color: transparent;
43
44
  font-family: fn.use-var(font-family);
44
- font-size: 1em;
45
+ font-size: inherit;
45
46
  width: 100%;
46
47
  display: block;
47
48
  padding: 0;