@neatui/vue 2.10.0 → 2.12.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 (50) hide show
  1. package/package.json +1 -1
  2. package/src/components/basic/LayerView/Layer.vue +0 -16
  3. package/src/components/display/Calendar.vue +14 -14
  4. package/src/components/display/CalendarReg.vue +14 -14
  5. package/src/components/display/Tree.vue +6 -6
  6. package/src/components/form/Cascader.vue +20 -20
  7. package/src/components/form/DatePicker.vue +8 -9
  8. package/src/components/form/DateRangePicker@v3.vue +5 -5
  9. package/src/components/form/DateRangeView@v3.vue +9 -9
  10. package/src/components/form/DateView.vue +14 -14
  11. package/src/components/form/DateView@v2.vue +14 -14
  12. package/src/components/form/DateView@v3.vue +17 -15
  13. package/src/components/form/Input@v3.vue +2 -2
  14. package/src/components/form/MoreSelect@v3.vue +27 -8
  15. package/src/components/form/MoreSelectList.vue +1 -1
  16. package/src/components/form/MoreSelectPanel@v3.vue +4 -4
  17. package/src/components/form/MoreSelectPicker.vue +1 -1
  18. package/src/components/form/MoreSelectTags.vue +1 -1
  19. package/src/components/form/PageMoreSelect.vue +15 -15
  20. package/src/components/form/PageSelect.vue +17 -17
  21. package/src/components/form/SearchMoreSelect.vue +1 -1
  22. package/src/components/form/SearchSelect@v3.vue +4 -4
  23. package/src/components/form/Select@v3.vue +13 -10
  24. package/src/components/form/SelectList.vue +8 -8
  25. package/src/components/form/SelectPicker.vue +7 -7
  26. package/src/components/form/SelectTags.vue +7 -7
  27. package/src/components/form/SelectTree/SelectTree@v1.vue +6 -6
  28. package/src/components/form/Switch.vue +38 -103
  29. package/src/components/form/Textarea@v2.vue +275 -0
  30. package/src/components/form/TimeView.vue +14 -14
  31. package/src/components/form/Upload.vue +52 -9
  32. package/src/components/form/date.ts +321 -0
  33. package/src/components/form/index.ts +2 -2
  34. package/src/components/form/number.ts +3 -0
  35. package/src/components/form/type.ts +224 -0
  36. package/src/components/loader/FormLoader/FormLoader@v2.vue +20 -20
  37. package/src/components/loader/FormLoader/FormLoader@v3.vue.backup +372 -291
  38. package/src/components/loader/FormLoader/FormRender@v3.vue.backup +4 -0
  39. package/src/components/loader/FormLoader/NodeLoader.vue +85 -0
  40. package/src/components/loader/FormLoader@v1/FormLoader.vue +1 -1
  41. package/src/components/loader/FormLoader@v1/FormRender.vue +49 -24
  42. package/src/components/loader/LayerLoader/LayerLoader.vue +1 -1
  43. package/src/components/loader/LimitLoader/LimitLoader@v3.vue +1 -1
  44. package/src/components/loader/MoveLoader/MoveLoader.vue +8 -8
  45. package/src/components/loader/TableLoader/TableLoader.vue +14 -9
  46. package/src/components/loader/TableLoader/TableRender.vue +100 -70
  47. package/src/components/loader/index.ts +1 -1
  48. package/src/components/tools/Pagination@a.vue +1 -1
  49. package/tsconfig.json +1 -1
  50. package/src/components/loader/FormLoader/index.ts +0 -2
@@ -1,12 +1,15 @@
1
1
  <template>
2
- <div :ui-form="`@a type:select sz:${sz}`" :ui-form-open="state.show ? 'show' : ''">
2
+ <div :ui-form="`@a type:select${sz ? 'sz:' + sz : ''}`" :ui-form-open="state.show ? 'show' : ''">
3
3
  <IFollowView ref="ifollow" tipBoxClass="ny-sm nx-no" tipBoxStyle="min-width: 100%" @onshow="onshow" @onhide="onhide">
4
4
  <Input
5
5
  v-bind="{ placeholder, rules, theme, sz, co, block, ready, type, tips, disabled, readonly: true, clearable: false, verify, prefix, suffix, interacted }"
6
6
  v-model="state.selectd.label"
7
7
  :interacted="interacted"
8
8
  >
9
- <template #suffix><i ui-form-select=""></i></template>
9
+ <template #suffix>
10
+ <i v-if="clearable && modelValue && !readonly && !disabled" ui-form-clean="" @click.stop="remove"></i>
11
+ <i ui-form-select=""></i>
12
+ </template>
10
13
  </Input>
11
14
  <template #tips v-if="!readonly && !disabled">
12
15
  <div v-if="search" class="ny-sm nx-sl">
@@ -16,7 +19,7 @@
16
19
  </template>
17
20
  </Input>
18
21
  </div>
19
- <ul v-if="props.options?.length" ui-scroll=":y s" class="nx-sm lh-sl" style="min-width: 100%; max-height: 16em">
22
+ <ul v-if="state.filter?.length" ui-scroll=":y s" class="nx-sm lh-sl" style="min-width: 100%; max-height: 16em">
20
23
  <template v-for="(item, idx) of state.filter" :key="idx">
21
24
  <li v-if="item.disabled" class="ux-hover nx-sm ny-ss r-ss o-ms nowrap" :class="item.value === state.selectd?.value ? 'co-main' : ''">
22
25
  <del>{{ item.label || item }}</del>
@@ -47,7 +50,7 @@
47
50
 
48
51
  <script setup lang="ts">
49
52
  import { reactive, ref, computed } from 'vue';
50
- import { Input } from '../form';
53
+ import { Input } from '.';
51
54
  import { IFollowView } from '../basic';
52
55
  const ifollow: any = ref(null);
53
56
 
@@ -119,7 +122,7 @@
119
122
  const props: any = withDefaults(defineProps<Props>(), {
120
123
  modelValue: '',
121
124
  options: () => [],
122
- tools: true,
125
+ tools: false,
123
126
  spare: '当前没有可选项',
124
127
  search: false,
125
128
  pagination: false,
@@ -139,14 +142,14 @@
139
142
  minlength: null,
140
143
  disabled: false,
141
144
  readonly: false,
142
- clearable: false,
145
+ clearable: true,
143
146
  verify: false,
144
147
  prefix: () => [],
145
148
  suffix: () => [],
146
- interacted: false
149
+ interacted: false,
147
150
  });
148
151
 
149
- const change = ({ value = '' }: any = {}) => {
152
+ const change = ({ value = null }: any = {}) => {
150
153
  emits('update:modelValue', value);
151
154
  emits('change', value);
152
155
  };
@@ -165,7 +168,7 @@
165
168
  } else {
166
169
  return props.options;
167
170
  }
168
- })
171
+ }),
169
172
  });
170
173
  // 选择
171
174
  const select = (item: any = {}) => {
@@ -195,7 +198,7 @@
195
198
  select,
196
199
  remove,
197
200
  change,
198
- cancel
201
+ cancel,
199
202
  });
200
203
  </script>
201
204
  . .
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <ul v-if="props.options?.length" class="my-sm-sub lh-ss">
3
3
  <li
4
- class="hover:bg-main-ss n-sl r-ss b-solid b-xs"
5
- :class="`${item.value === mv ? 'bk-main-ml bg-main-ss' : 'bk-case'}`"
4
+ class="hover:bg-main-o-ss n-sl r-ss b-solid b-xs"
5
+ :class="`${item.value === mv ? 'bk-main-o-ml bg-main-o-ss' : 'bk-case'}`"
6
6
  v-for="(item, idx) of props.options"
7
7
  :key="idx"
8
8
  @click="mv = item.value === mv ? '' : item.value"
@@ -27,16 +27,16 @@
27
27
  placeholder: { type: String, default: '' },
28
28
  options: {
29
29
  type: Array as () => any[],
30
- default: () => []
30
+ default: () => [],
31
31
  },
32
32
  modelValue: {
33
33
  type: [String, Number],
34
- default: ''
34
+ default: '',
35
35
  },
36
36
  rules: {
37
37
  type: Array,
38
- default: () => []
39
- }
38
+ default: () => [],
39
+ },
40
40
  });
41
41
 
42
42
  // eslint-disable-next-line vue/no-dupe-keys
@@ -47,12 +47,12 @@
47
47
  () => props.modelValue,
48
48
  (value: any) => {
49
49
  mv.value = value;
50
- }
50
+ },
51
51
  );
52
52
  watch(
53
53
  () => mv.value,
54
54
  (value: any) => {
55
55
  emits('update:modelValue', value);
56
- }
56
+ },
57
57
  );
58
58
  </script>
@@ -29,7 +29,7 @@
29
29
 
30
30
  <script setup lang="ts">
31
31
  import { reactive, ref, computed } from 'vue';
32
- import { Input } from '../form';
32
+ import { Input } from '.';
33
33
  import { IPickerView, IScrollView } from '../basic';
34
34
  import { watch } from 'vue';
35
35
  const ipicker: any = ref(null);
@@ -43,16 +43,16 @@
43
43
  placeholder: { type: String, default: '' },
44
44
  options: {
45
45
  type: Array as () => any[],
46
- default: () => []
46
+ default: () => [],
47
47
  },
48
48
  modelValue: {
49
49
  type: [String, Number],
50
- default: ''
50
+ default: '',
51
51
  },
52
52
  rules: {
53
53
  type: Array,
54
- default: () => []
55
- }
54
+ default: () => [],
55
+ },
56
56
  });
57
57
  // 内部数据
58
58
  const mv: any = ref(props.modelValue);
@@ -61,7 +61,7 @@
61
61
  (v: any) => {
62
62
  mv.value = v;
63
63
  },
64
- { deep: true, immediate: true }
64
+ { deep: true, immediate: true },
65
65
  );
66
66
  const state = reactive({
67
67
  view: 0,
@@ -74,7 +74,7 @@
74
74
  }
75
75
  }
76
76
  return _value;
77
- })
77
+ }),
78
78
  });
79
79
  // 更新
80
80
  const change = ({ value = null }: any = {}) => {
@@ -2,7 +2,7 @@
2
2
  <div v-if="props.options?.length" class="mr-sm-sub mb-sm-sub">
3
3
  <span
4
4
  class="lh-ss ny-sm nx-ms r-xl dib"
5
- :class="`${mv == item.value ? 'bg-main-sm co-main' : 'bg-weak'}`"
5
+ :class="`${mv == item.value ? 'bg-main-o-sm co-main' : 'bg-weak'}`"
6
6
  v-for="(item, idx) of props.options"
7
7
  :key="idx"
8
8
  @click="mv = item.value === mv ? '' : item.value"
@@ -24,16 +24,16 @@
24
24
  placeholder: { type: String, default: '' },
25
25
  options: {
26
26
  type: Array as () => any[],
27
- default: () => []
27
+ default: () => [],
28
28
  },
29
29
  modelValue: {
30
30
  type: [String, Number],
31
- default: ''
31
+ default: '',
32
32
  },
33
33
  rules: {
34
34
  type: Array,
35
- default: () => []
36
- }
35
+ default: () => [],
36
+ },
37
37
  });
38
38
  // 内部数据
39
39
  const mv: any = ref(props.modelValue);
@@ -41,12 +41,12 @@
41
41
  () => props.modelValue,
42
42
  (value: any) => {
43
43
  mv.value = value;
44
- }
44
+ },
45
45
  );
46
46
  watch(
47
47
  () => mv.value,
48
48
  (value: any) => {
49
49
  emits('update:modelValue', value);
50
- }
50
+ },
51
51
  );
52
52
  </script>
@@ -40,7 +40,7 @@
40
40
 
41
41
  <script setup lang="ts">
42
42
  import { reactive, ref, computed, watch } from 'vue';
43
- import { Input } from '../../form';
43
+ import { Input } from '..';
44
44
  import { IFollowView } from '../../basic';
45
45
  import { TreeView } from '../../display';
46
46
  import { findByJson, filterJson } from '@fekit/utils';
@@ -144,7 +144,7 @@
144
144
  verify: false,
145
145
  prefix: () => [],
146
146
  suffix: () => [],
147
- interacted: false
147
+ interacted: false,
148
148
  });
149
149
 
150
150
  const state: any = reactive({
@@ -158,7 +158,7 @@
158
158
  return (props.chain ? _item.chain : _item.label) || '';
159
159
  }),
160
160
  filter: [],
161
- value: ''
161
+ value: '',
162
162
  });
163
163
  watch(
164
164
  () => state.value,
@@ -167,7 +167,7 @@
167
167
  change(value);
168
168
  }
169
169
  },
170
- { deep: true }
170
+ { deep: true },
171
171
  );
172
172
  watch(
173
173
  [() => state.search, () => props.options],
@@ -178,7 +178,7 @@
178
178
  state.filter = props.options;
179
179
  }
180
180
  },
181
- { deep: true, immediate: true }
181
+ { deep: true, immediate: true },
182
182
  );
183
183
 
184
184
  const change = (value: any = '') => {
@@ -221,7 +221,7 @@
221
221
  select,
222
222
  remove,
223
223
  change,
224
- cancel
224
+ cancel,
225
225
  });
226
226
  </script>
227
227
  .. ..
@@ -1,12 +1,14 @@
1
1
  <template>
2
- <label ui-form="@a type:switch" class="lh-ls">
3
- <input type="checkbox" name="form2" :checked="value ? true : false" />
4
- <slot>&nbsp;</slot>
2
+ <label ui-form="@a type:switch">
3
+ <input type="checkbox" v-model="internalValue" :disabled="disabled" />
4
+ <slot>
5
+ <span>{{ text }}</span>
6
+ </slot>
5
7
  </label>
6
8
  </template>
7
9
 
8
10
  <script setup lang="ts">
9
- import { ref, watch, computed, onMounted, PropType } from 'vue';
11
+ import { ref, watch, PropType } from 'vue';
10
12
 
11
13
  const props = defineProps({
12
14
  theme: { type: String, default: '@a' },
@@ -15,121 +17,54 @@
15
17
  block: { type: Boolean, default: true },
16
18
  // 值
17
19
  modelValue: {
18
- type: [Number, Boolean],
19
- default: false
20
+ type: [Number, Boolean, String],
21
+ default: false,
20
22
  },
21
- // 类型
22
- type: {
23
+ text: {
23
24
  type: String,
24
- default: 'text'
25
- },
26
- // 提示文案
27
- tips: {
28
- type: String,
29
- default: ''
30
- },
31
- // 内容占位
32
- placeholder: {
33
- type: String,
34
- default: ''
35
- },
36
- // 最大长度
37
- maxlength: {
38
- type: Number,
39
- default: null
40
- },
41
- // 最小长度
42
- minlength: {
43
- type: Number,
44
- default: null
25
+ default: '',
45
26
  },
46
27
  // 是否禁用
47
28
  disabled: {
48
29
  type: Boolean,
49
- default: false
50
- },
51
- // 是否中读
52
- readonly: {
53
- type: Boolean,
54
- default: false
55
- },
56
- // 是否显示清除按钮
57
- clearable: {
58
- type: Boolean,
59
- default: true
30
+ default: false,
60
31
  },
61
- // 校验规则
62
- rules: {
63
- type: Array,
64
- default: () => []
65
- },
66
- // 是否是示校验图标
67
- verify: {
68
- type: Boolean,
69
- default: false
70
- },
71
- prefix: {
32
+ map: {
72
33
  type: Array as PropType<any[]>,
73
- default: () => []
34
+ default: () => [false, true],
74
35
  },
75
- suffix: {
76
- type: Array as PropType<any[]>,
77
- default: () => []
78
- }
79
36
  });
80
37
 
81
- const ready: any = ref(0);
82
- const state: any = computed(() => {
83
- if (ready.value) {
84
- // 提示文案
85
- let tips = '';
86
- // 错误类型
87
- let type = '';
88
- // 验证结果
89
- let verify = '';
90
- if (props.modelValue) {
91
- // 有值
92
- const res: any = props.rules?.some((rule: any) => {
93
- const yes = rule.validator && !rule.validator(props.modelValue);
94
- tips = rule.msg;
95
- type = rule.type;
96
- return yes;
97
- });
98
- verify = res ? 'no' : 'ok';
99
- } else {
100
- // 无值
101
- const res: any = props.rules?.some((rule: any) => {
102
- tips = rule.msg;
103
- type = rule.type;
104
- return rule.required;
105
- });
106
- verify = res ? 'no' : '';
107
- }
108
- if (verify !== 'no' && props.tips) {
109
- tips = props.tips;
110
- }
111
- // 是否显示提示
112
- const ontips = verify === 'no' && tips ? 'show' : '';
113
- // 状态颜色
114
- const co = verify === 'no' ? 'co:' + type : props.co ? 'co:' + props.co : '';
115
- return { tips, ontips, verify, co };
116
- } else {
117
- return {};
118
- }
119
- });
38
+ const emit = defineEmits(['update:modelValue']);
120
39
 
121
- const value = ref(props.modelValue);
122
- // 监听异步数据
40
+ // 内部值(始终是布尔值)
41
+ const internalValue = ref(false);
42
+
43
+ // 计算内部值
44
+ const getInternalValue = (externalValue: any) => {
45
+ const index = props.map.indexOf(externalValue);
46
+ return index === 0 ? true : index === 1 ? false : Boolean(externalValue);
47
+ };
48
+
49
+ // 计算外部值
50
+ const getExternalValue = (internalValue: boolean) => {
51
+ return internalValue ? props.map[0] : props.map[1];
52
+ };
53
+
54
+ // 初始化内部值
55
+ internalValue.value = getInternalValue(props.modelValue);
56
+
57
+ // 监听外部值变化
123
58
  watch(
124
59
  () => props.modelValue,
125
60
  (newValue) => {
126
- value.value = newValue;
127
- }
61
+ internalValue.value = getInternalValue(newValue);
62
+ },
128
63
  );
129
64
 
130
- onMounted(() => {
131
- setTimeout(() => {
132
- ready.value = 1;
133
- }, 300);
65
+ // 监听内部值变化,向父组件发送映射后的值
66
+ watch(internalValue, (newValue) => {
67
+ const externalValue = getExternalValue(newValue);
68
+ emit('update:modelValue', externalValue);
134
69
  });
135
70
  </script>