@neatui/nuxt 1.6.9 → 1.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/nuxt",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  <button ui-btn="@a s case :border"><i class="icon icon-dropdown"></i></button>
5
5
  </slot>
6
6
  </div>
7
- <Teleport v-if="$slots.tips" to="#ifollow">
7
+ <Teleport v-if="teleportReady && $slots.tips" to="#ifollow">
8
8
  <div
9
9
  ref="tip"
10
10
  :class="`${tipClass}${mobile ? ' fekit-follow-mobile' : ''}`"
@@ -37,15 +37,6 @@
37
37
 
38
38
  const emits = defineEmits(['update:modelValue', 'onhide', 'onshow']);
39
39
 
40
- if (import.meta.client) {
41
- const area = document.querySelector('#ifollow');
42
- if (!area) {
43
- const el = document.createElement('div');
44
- el.id = 'ifollow';
45
- document.body.appendChild(el);
46
- }
47
- }
48
-
49
40
  // 类型
50
41
  interface Props {
51
42
  modelValue?: string | number;
@@ -83,6 +74,7 @@
83
74
  const dom: any = ref(null);
84
75
  const tip: any = ref(null);
85
76
  const box: any = ref(null);
77
+ const teleportReady = ref(false);
86
78
  const state = reactive({
87
79
  view: 0,
88
80
  show: 0,
@@ -173,7 +165,18 @@
173
165
  }
174
166
  };
175
167
 
168
+ const ensureTeleportTarget = () => {
169
+ let area = document.querySelector('#ifollow');
170
+ if (!area) {
171
+ area = document.createElement('div');
172
+ area.id = 'ifollow';
173
+ document.body.appendChild(area);
174
+ }
175
+ teleportReady.value = true;
176
+ };
177
+
176
178
  onMounted(() => {
179
+ ensureTeleportTarget();
177
180
  document.addEventListener('click', cancel, true);
178
181
  // 添加触摸事件监听器以防止页面滚动
179
182
  document.addEventListener('touchstart', preventTouchScroll, { passive: false });
@@ -17,7 +17,7 @@
17
17
  <input
18
18
  :title="props.modelValue"
19
19
  :value="props.modelValue"
20
- :type="type"
20
+ :type="inputType"
21
21
  :placeholder="placeholder"
22
22
  :disabled="disabled"
23
23
  :readonly="readonly"
@@ -30,6 +30,12 @@
30
30
  </slot>
31
31
  <div ui-form-suffix="">
32
32
  <i ui-form-clean="" v-if="clearable && props.modelValue && !readonly && !disabled" @click.stop="clear"></i>
33
+ <div
34
+ class="o-ls"
35
+ v-if="type === 'password' && cipher"
36
+ :ui-form-cipher="cipherVisible ? '1' : ''"
37
+ @click.stop="toggleCipher"
38
+ ></div>
33
39
  <slot name="suffix"></slot>
34
40
  <template v-for="(item, idx) in suffix" :key="idx">
35
41
  <div v-if="isObject(item)" v-bind="item.attrs" v-on="event(item, props.modelValue)">
@@ -43,7 +49,7 @@
43
49
  </template>
44
50
 
45
51
  <script setup lang="ts">
46
- import { reactive, watch } from 'vue';
52
+ import { computed, reactive, ref, watch } from 'vue';
47
53
  import { isObject, isFunction } from '@fekit/utils';
48
54
 
49
55
  const emits = defineEmits(['update:modelValue', 'click', 'blur', 'focus', 'change', 'input', 'clear']);
@@ -65,6 +71,7 @@
65
71
  * disabled 是否禁用
66
72
  * readonly 是否只读
67
73
  * clearable 是否显示清除按钮
74
+ * cipher 密码框是否显示明密文切换
68
75
  * rules 校验规则
69
76
  * verify 是否显示校验
70
77
  * prefix 前缀内容
@@ -89,6 +96,7 @@
89
96
  disabled?: boolean;
90
97
  readonly?: boolean;
91
98
  clearable?: boolean;
99
+ cipher?: boolean;
92
100
  verify?: boolean;
93
101
  prefix?: Array<any>;
94
102
  suffix?: Array<any>;
@@ -110,6 +118,7 @@
110
118
  disabled: false,
111
119
  readonly: false,
112
120
  clearable: true,
121
+ cipher: true,
113
122
  verify: false,
114
123
  prefix: () => [],
115
124
  suffix: () => [],
@@ -124,6 +133,14 @@
124
133
  // 错误
125
134
  error: {},
126
135
  });
136
+ const cipherVisible = ref(false);
137
+
138
+ const inputType = computed(() => {
139
+ if (props.type === 'password') {
140
+ return cipherVisible.value ? 'text' : 'password';
141
+ }
142
+ return props.type;
143
+ });
127
144
  // 外部传入交互标识,主要用于外部没有输入但点击了提交,或表单提交成功后重置状态
128
145
  watch(
129
146
  () => props.interacted,
@@ -199,6 +216,11 @@
199
216
  emits('update:modelValue', null);
200
217
  emits('clear');
201
218
  }
219
+
220
+ const toggleCipher = () => {
221
+ if (props.disabled || props.readonly) return;
222
+ cipherVisible.value = !cipherVisible.value;
223
+ };
202
224
  // 输入
203
225
  const input = (e: any) => {
204
226
  // 用户交互