@ecolovo/uniapp-components 1.0.10 → 2.0.1

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 (130) hide show
  1. package/README.md +202 -66
  2. package/components/aspect/aspect.vue +24 -15
  3. package/components/badge/badge.scss +20 -0
  4. package/components/badge/badge.vue +49 -40
  5. package/components/button/button.scss +15 -0
  6. package/components/button/button.vue +121 -177
  7. package/components/checkbox/checkbox.scss +10 -0
  8. package/components/checkbox/checkbox.vue +118 -146
  9. package/components/checkbox-group/checkbox-group.vue +79 -85
  10. package/components/checkbox-group2/checkbox-group2.vue +111 -107
  11. package/components/checkbox-group2/checkbox2.vue +104 -0
  12. package/components/data-list/data-list.scss +9 -0
  13. package/components/data-list/data-list.vue +70 -79
  14. package/components/date-picker/date-picker-view.vue +125 -124
  15. package/components/date-picker/date-picker.vue +145 -146
  16. package/components/dialog/dialog-content.vue +39 -47
  17. package/components/dialog/dialog.scss +11 -0
  18. package/components/dialog/dialog.vue +125 -138
  19. package/components/dropdown/dropdown.scss +11 -0
  20. package/components/dropdown/dropdown.vue +55 -97
  21. package/components/empty/empty.scss +14 -0
  22. package/components/empty/empty.vue +42 -41
  23. package/components/flex/flex.vue +45 -54
  24. package/components/form/form.vue +29 -24
  25. package/components/form-item/form-item.scss +11 -0
  26. package/components/form-item/form-item.vue +43 -40
  27. package/components/icon/icon.vue +70 -85
  28. package/components/image/image.vue +35 -38
  29. package/components/input/input.vue +65 -79
  30. package/components/input/password-input.vue +34 -42
  31. package/components/list-page/list-page.vue +73 -99
  32. package/components/load-more/load-more.scss +12 -0
  33. package/components/load-more/load-more.vue +29 -29
  34. package/components/loading/animations/loading-animation1.vue +8 -8
  35. package/components/loading/animations/loading-animation2.vue +8 -9
  36. package/components/loading/animations/loading-animation3.vue +11 -11
  37. package/components/loading/animations/loading-animation4.vue +8 -8
  38. package/components/loading/loading.vue +19 -20
  39. package/components/message-box/message-box.vue +59 -41
  40. package/components/number-dialog/number-dialog.scss +9 -0
  41. package/components/number-dialog/number-dialog.vue +209 -204
  42. package/components/number-input/number-input.scss +9 -0
  43. package/components/number-input/number-input.vue +233 -232
  44. package/components/numpad/numpad.scss +9 -0
  45. package/components/numpad/numpad.vue +133 -150
  46. package/components/page/page-body.scss +15 -0
  47. package/components/page/page-body.vue +137 -119
  48. package/components/page/page-footer.scss +13 -0
  49. package/components/page/page-footer.vue +31 -33
  50. package/components/page/page-header.scss +17 -0
  51. package/components/page/page-header.vue +89 -94
  52. package/components/page/page.scss +9 -0
  53. package/components/page/page.vue +105 -81
  54. package/components/picker/picker-popup.vue +218 -209
  55. package/components/picker/picker.vue +99 -104
  56. package/components/popover/popover-content.vue +54 -63
  57. package/components/popover/popover-mask.vue +63 -63
  58. package/components/popover/popover.scss +28 -0
  59. package/components/popover/popover.vue +49 -47
  60. package/components/popup/popup-content.vue +49 -53
  61. package/components/popup/popup.scss +11 -0
  62. package/components/popup/popup.vue +117 -132
  63. package/components/price/price.scss +20 -0
  64. package/components/price/price.vue +31 -42
  65. package/components/search/search.scss +12 -0
  66. package/components/search/search.vue +93 -117
  67. package/components/searching/searching.vue +33 -40
  68. package/components/selector/selector.vue +43 -48
  69. package/components/switch/switch.scss +12 -0
  70. package/components/switch/switch.vue +99 -96
  71. package/components/tab/tab.scss +19 -0
  72. package/components/tab/tab.vue +151 -145
  73. package/components/textarea/textarea.vue +104 -101
  74. package/composable/component-name.d.ts +2 -0
  75. package/composable/component-name.js +8 -0
  76. package/composable/component-name.ts +10 -0
  77. package/configs/index.d.ts +25 -10
  78. package/configs/index.js +14 -23
  79. package/configs/index.ts +82 -0
  80. package/easyCom.d.ts +9 -0
  81. package/easyCom.js +1 -2
  82. package/easyCom.ts +31 -0
  83. package/index.d.ts +1 -0
  84. package/index.js +1 -0
  85. package/index.ts +1 -0
  86. package/init.d.ts +4 -7
  87. package/init.js +5 -4
  88. package/init.ts +34 -0
  89. package/package.json +14 -4
  90. package/styles/utils/css-var.scss +12 -15
  91. package/styles/utils/ellipsis.scss +0 -7
  92. package/styles/utils/z-index.scss +1 -1
  93. package/styles/var/component.scss +21 -245
  94. package/utils/date.d.ts +47 -0
  95. package/utils/date.js +23 -43
  96. package/utils/date.ts +153 -0
  97. package/utils/freezeDeep.d.ts +1 -0
  98. package/utils/freezeDeep.js +4 -14
  99. package/utils/freezeDeep.ts +9 -0
  100. package/utils/price.d.ts +24 -0
  101. package/utils/price.js +14 -8
  102. package/utils/price.ts +57 -0
  103. package/utils/round.d.ts +2 -0
  104. package/utils/round.js +2 -14
  105. package/utils/round.ts +11 -0
  106. package/utils/windowInfo.d.ts +24 -0
  107. package/utils/windowInfo.js +8 -36
  108. package/utils/windowInfo.ts +50 -0
  109. package/components/checkbox-group2/checkbox.vue +0 -109
  110. package/components/datetime-picker/datetime-picker-view.vue +0 -209
  111. package/components/datetime-picker/datetime-picker.vue +0 -235
  112. package/components/form/mixin.js +0 -13
  113. package/components/list-page/list-page.js +0 -10
  114. package/components/table/table.vue +0 -112
  115. package/components/time-picker/time-picker-view.vue +0 -127
  116. package/components/time-picker/time-picker.vue +0 -140
  117. package/components/uploader/download.js +0 -81
  118. package/components/uploader/file-uploader.vue +0 -52
  119. package/components/uploader/files.js +0 -225
  120. package/components/uploader/media-uploader.vue +0 -189
  121. package/components/uploader/mixin.js +0 -171
  122. package/components/uploader/uni.js +0 -38
  123. package/components/uploader/upload-button.vue +0 -29
  124. package/components/uploader/uploader copy.vue +0 -547
  125. package/components/uploader/uploader.vue +0 -117
  126. package/mixins/componentName.js +0 -32
  127. package/mixins/listPage.js +0 -1
  128. package/mixins/windowInfo.js +0 -1
  129. package/utils/fileSize.js +0 -39
  130. package/utils/floor.js +0 -20
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view
3
- :class="[componentClassNames, { [$style['NumberDialog--disabled']]: disabled }]"
3
+ :class="[...classNames, $style['NumberDialog'], { [$style['NumberDialog--disabled']]: disabled }]"
4
4
  @click.stop.prevent="doNothing"
5
5
  >
6
6
  <view
@@ -14,16 +14,18 @@
14
14
  <icon-cpn
15
15
  icon="step-minus"
16
16
  tap-size="60rpx"
17
- @touchstart.native="handleStepLongTouchStart($event, -step, disabledDecrease)"
18
- @touchend.native="handleStepLongTouchEnd(-step)"
19
- @touchcancel.native="handleStepLongTouchEnd(-step)"
17
+ @touchstart="handleStepLongTouchStart($event, -step, disabledDecrease)"
18
+ @touchend="handleStepLongTouchEnd(-step)"
19
+ @touchcancel="handleStepLongTouchEnd(-step)"
20
20
  />
21
21
  </view>
22
22
  <view
23
23
  :class="[$style['NumberDialog--input'], { [$style['NumberDialog--readonly']]: isReadonly }]"
24
24
  @click="showPad"
25
25
  >
26
- <text v-if="isReadonly || value === 0 || value" :class="$style['NumberDialog--value']">{{ value }}</text>
26
+ <text v-if="isReadonly || modelValue === 0 || modelValue" :class="$style['NumberDialog--value']">{{
27
+ modelValue
28
+ }}</text>
27
29
  <text v-else :class="$style['NumberDialog--placeholder']">{{ placeholder }}</text>
28
30
  </view>
29
31
  <view
@@ -37,13 +39,13 @@
37
39
  <icon-cpn
38
40
  icon="step-plus"
39
41
  tap-size="60rpx"
40
- @touchstart.native="handleStepLongTouchStart($event, step, disabledIncrease)"
41
- @touchend.native="handleStepLongTouchEnd(step)"
42
- @touchcancel.native="handleStepLongTouchEnd(step)"
42
+ @touchstart="handleStepLongTouchStart($event, step, disabledIncrease)"
43
+ @touchend="handleStepLongTouchEnd(step)"
44
+ @touchcancel="handleStepLongTouchEnd(step)"
43
45
  />
44
46
  </view>
45
47
 
46
- <popover-mask-cpn v-if="isShowPad" ref="mask" v-model="isShowPad">
48
+ <popover-mask-cpn v-if="isShowPad" ref="maskRef" v-model="isShowPad">
47
49
  <dialog-content-cpn
48
50
  title="请输入数字"
49
51
  center-title
@@ -64,9 +66,9 @@
64
66
  </view>
65
67
  </template>
66
68
 
67
- <script>
68
- import componentName from '../../mixins/componentName';
69
- import { isFormReadonly } from '../form/mixin';
69
+ <script lang="ts" setup>
70
+ import { computed, inject, ref, watch } from 'vue';
71
+ import useClassNames from '../../composable/component-name';
70
72
  import { round } from '../../utils/round';
71
73
  import DialogContentCpn from '../dialog/dialog-content.vue';
72
74
  import IconCpn from '../icon/icon.vue';
@@ -74,210 +76,213 @@ import NumpadCpn from '../numpad/numpad.vue';
74
76
  import PopoverContentCpn from '../popover/popover-content.vue';
75
77
  import PopoverMaskCpn from '../popover/popover-mask.vue';
76
78
 
77
- const MIN = 0;
78
- const MAX = 9999;
79
-
80
- export default {
81
- name: 'NumberDialog',
79
+ defineOptions({
82
80
  options: {
83
81
  virtualHost: true,
84
82
  styleIsolation: 'shared',
85
83
  },
86
- components: { DialogContentCpn, IconCpn, NumpadCpn, PopoverContentCpn, PopoverMaskCpn },
87
- mixins: [componentName, isFormReadonly],
88
- props: {
89
- /** 绑定值 */
90
- value: {
91
- type: [Number, String],
92
- default: '',
93
- },
94
- /** 是否禁用 */
95
- disabled: {
96
- type: Boolean,
97
- default: false,
98
- },
99
- /** 是否可编辑,为 true 时点击中间数字会弹出键盘 */
100
- editable: {
101
- type: Boolean,
102
- default: true,
103
- },
104
- /** 是否只读 */
105
- readonly: {
106
- type: Boolean,
107
- default: false,
108
- },
109
- /** 占位提示文本 */
110
- placeholder: {
111
- type: String,
112
- default: '请输入',
113
- },
114
- /** 小数的精度 */
115
- precision: {
116
- type: Number,
117
- default: 0,
118
- },
119
- /** 步进器的步长 */
120
- step: {
121
- type: Number,
122
- default: 1,
123
- },
124
- /** 最大值 */
125
- max: {
126
- type: Number,
127
- default: MAX,
128
- },
129
- /** 最小值 */
130
- min: {
131
- type: Number,
132
- default: MIN,
133
- },
134
- },
135
- data() {
136
- return {
137
- /** 编辑值 */
138
- editValue: '',
139
- /** 是否显示数字键盘 */
140
- isShowPad: false,
141
- };
142
- },
143
- computed: {
144
- /** 是否只读 */
145
- isReadonly() {
146
- return this.readonly || this.isFormReadonly;
147
- },
148
- /** 是否禁用减 */
149
- disabledDecrease() {
150
- if (this.disabled) return true;
151
- if (!isNaN(this.value) && +this.value <= Number(this.min)) return true;
152
- return false;
153
- },
154
- /** 是否禁用增 */
155
- disabledIncrease() {
156
- if (this.disabled) return true;
157
- if (!isNaN(this.value) && +this.value >= Number(this.max)) return true;
158
- return false;
159
- },
160
- },
161
- watch: {
162
- value: {
163
- handler(n) {
164
- this.editValue = n + '';
165
- },
166
- immediate: true,
167
- },
168
- },
169
- methods: {
170
- doNothing() {},
171
- /** 长按步进按钮开始处理 */
172
- handleStepLongTouchStart(event, step, disabled) {
173
- if (disabled) return;
174
- if (event.touches && event.touches.length > 1) return;
175
-
176
- this._lastValue = this.value;
177
- this._touchingStep = step;
178
- let interval = 400;
179
- let times = 0;
180
-
181
- const longTouch = () => {
182
- if (!this.handleOneStep(step * (times >= 30 ? 4 : times >= 12 ? 2 : 1))) return;
183
-
184
- this._touchTimer = setTimeout(longTouch, interval);
185
- interval = Math.max(100, interval - 50);
186
- times++;
187
- };
188
- longTouch();
189
- },
190
- /** 长按步进按钮结束处理 */
191
- handleStepLongTouchEnd(step) {
192
- if (this._touchingStep !== step) return;
193
- if (this._touchTimer) {
194
- clearTimeout(this._touchTimer);
195
- this._touchTimer = null;
196
- }
197
- this._touchingStep = null;
198
- this.confirmValue(this.editValue + '', true);
199
- },
200
- /** 单次步进处理 */
201
- handleOneStep(step) {
202
- if ((step > 0 && this.disabledIncrease) || (step < 0 && this.disabledDecrease)) {
203
- return false;
204
- }
205
- let nextValue = round(+this.value + step, this.precision);
206
-
207
- this.updateStepValue(nextValue + '');
208
- return true;
209
- },
210
- /** 每次步进处理 */
211
- updateStepValue(value) {
212
- value = this.validateValue(value, true);
213
- this.$emit('input', value);
214
- this.editValue = value;
215
- },
216
- /** 校验数据
217
- * @param {string} value 输入值
218
- * @param {boolean} isStepButton 是否为步进按钮触发
219
- */
220
- validateValue(value, isStepButton = false) {
221
- let nextValue;
222
- if (isNaN(value)) {
223
- // 输入不合法,取消此次输入
224
- nextValue = isStepButton ? 0 : this._lastValue;
225
- this.$emit('error', '请输入正确的数值');
226
- } else if (value === '') {
227
- // 输入空值
228
- nextValue = isStepButton ? 0 : '';
229
- this.$emit('error', '请输入数值');
230
- } else if (+value < this.min) {
231
- // 超过最小输入值
232
- nextValue = this.min;
233
- this.$emit('error', `数值不能小于 ${this.min}`);
234
- } else if (+value > this.max) {
235
- // 超过最大输入值
236
- nextValue = this.max;
237
- this.$emit('error', `数值不能大于 ${this.max}`);
238
- } else {
239
- nextValue = round(+value, this.precision);
240
- }
241
- return nextValue;
242
- },
243
- /** 确认数据
244
- * @param {string} value
245
- */
246
- confirmValue(value, isStepButton = false) {
247
- value = this.validateValue(value, isStepButton);
248
- this.editValue = value + '';
249
-
250
- this.$emit('input', value);
251
- this.$emit('change', { value, lastValue: this._lastValue });
252
- },
253
- /** 显示数字键盘弹框 */
254
- showPad() {
255
- if (this.isReadonly || this.disabled || !this.editable) return;
256
-
257
- this.editValue = this.value + '';
258
- this.isShowPad = true;
259
- },
260
- /** 关闭数字键盘弹框 */
261
- closePad() {
262
- this.$refs.mask.close();
263
- },
264
- /** 点击弹框确认按钮 */
265
- onConfirm() {
266
- this.confirmValue(this.editValue);
267
- this.closePad();
268
- },
84
+ });
85
+
86
+ const classNames = useClassNames('number-dialog');
87
+
88
+ const MIN = 0;
89
+ const MAX = 9999;
90
+
91
+ type _Props = {
92
+ /** 绑定值 */
93
+ modelValue?: string | number;
94
+ /** 是否禁用 */
95
+ disabled?: boolean;
96
+ /** 是否可编辑,为 true 时点击中间数字会弹出键盘 */
97
+ editable?: boolean;
98
+ /** 是否只读 */
99
+ readonly?: boolean;
100
+ /** 占位提示文本 */
101
+ placeholder?: string;
102
+ /** 小数的精度 */
103
+ precision?: number;
104
+ /** 步进器的步长 */
105
+ step?: number;
106
+ /** 最大值 */
107
+ max?: number;
108
+ /** 最小值 */
109
+ min?: number;
110
+ };
111
+
112
+ const props = withDefaults(defineProps<_Props>(), {
113
+ modelValue: '',
114
+ disabled: false,
115
+ editable: true,
116
+ readonly: false,
117
+ placeholder: '请输入',
118
+ precision: 0,
119
+ step: 1,
120
+ max: MAX,
121
+ min: MIN,
122
+ });
123
+
124
+ const emit = defineEmits<{
125
+ (e: 'update:modelValue', val: string | number): void;
126
+ (e: 'change', payload: { value: string | number; lastValue: string | number }): void;
127
+ (e: 'error', msg: string): void;
128
+ }>();
129
+
130
+ /** 表单是否只读 */
131
+ const isFormReadonly = inject(
132
+ 'ecolovo/form/readonly',
133
+ computed(() => false)
134
+ );
135
+
136
+ /** 编辑值 */
137
+ const editValue = ref<string | number>('');
138
+ /** 是否显示数字键盘 */
139
+ const isShowPad = ref(false);
140
+
141
+ const maskRef = ref<InstanceType<typeof PopoverMaskCpn>>();
142
+
143
+ /** 是否只读 */
144
+ const isReadonly = computed(() => props.readonly || isFormReadonly.value);
145
+
146
+ /** 是否禁用减 */
147
+ const disabledDecrease = computed(() => {
148
+ if (props.disabled) return true;
149
+ const val = Number(props.modelValue);
150
+ if (!Number.isNaN(val) && val <= Number(props.min)) return true;
151
+ return false;
152
+ });
153
+
154
+ /** 是否禁用增 */
155
+ const disabledIncrease = computed(() => {
156
+ if (props.disabled) return true;
157
+ const val = Number(props.modelValue);
158
+ if (!Number.isNaN(val) && val >= Number(props.max)) return true;
159
+ return false;
160
+ });
161
+
162
+ watch(
163
+ () => props.modelValue,
164
+ (n) => {
165
+ editValue.value = (n ?? '') + '';
269
166
  },
167
+ { immediate: true }
168
+ );
169
+
170
+ let _lastValue: string | number = '';
171
+ let _touchingStep: number | null = null;
172
+ let _touchTimer: ReturnType<typeof setTimeout> | null = null;
173
+
174
+ const doNothing = () => {};
175
+
176
+ /** 长按步进按钮开始处理 */
177
+ const handleStepLongTouchStart = (event: TouchEvent, step: number, disabled: boolean) => {
178
+ if (disabled) return;
179
+ if (event.touches.length > 1) return;
180
+
181
+ _lastValue = props.modelValue;
182
+ _touchingStep = step;
183
+ let interval = 400;
184
+ let times = 0;
185
+
186
+ const longTouch = () => {
187
+ if (!handleOneStep(step * (times >= 30 ? 4 : times >= 12 ? 2 : 1))) return;
188
+
189
+ _touchTimer = setTimeout(longTouch, interval);
190
+ interval = Math.max(100, interval - 50);
191
+ times++;
192
+ };
193
+ longTouch();
194
+ };
195
+
196
+ /** 长按步进按钮结束处理 */
197
+ const handleStepLongTouchEnd = (step: number) => {
198
+ if (_touchingStep !== step) return;
199
+ if (_touchTimer) {
200
+ clearTimeout(_touchTimer);
201
+ _touchTimer = null;
202
+ }
203
+ _touchingStep = null;
204
+ confirmValue(editValue.value + '', true);
205
+ };
206
+
207
+ /** 单次步进处理 */
208
+ const handleOneStep = (step: number) => {
209
+ if ((step > 0 && disabledIncrease.value) || (step < 0 && disabledDecrease.value)) {
210
+ return false;
211
+ }
212
+ const nextValue = round(+props.modelValue + step, props.precision);
213
+
214
+ updateStepValue(nextValue + '');
215
+ return true;
216
+ };
217
+
218
+ /** 每次步进处理 */
219
+ const updateStepValue = (value: string) => {
220
+ const nextValue = validateValue(value, true);
221
+ emit('update:modelValue', nextValue);
222
+ editValue.value = nextValue + '';
223
+ };
224
+
225
+ /** 校验数据 */
226
+ const validateValue = (value: string, isStepButton = false) => {
227
+ let nextValue: string | number;
228
+ if (isNaN(+value)) {
229
+ // 输入不合法,取消此次输入
230
+ nextValue = isStepButton ? 0 : _lastValue;
231
+ emit('error', '请输入正确的数值');
232
+ } else if (value === '') {
233
+ // 输入空值
234
+ nextValue = isStepButton ? 0 : '';
235
+ emit('error', '请输入数值');
236
+ } else if (+value < props.min) {
237
+ // 超过最小输入值
238
+ nextValue = props.min;
239
+ emit('error', `数值不能小于 ${props.min}`);
240
+ } else if (+value > props.max) {
241
+ // 超过最大输入值
242
+ nextValue = props.max;
243
+ emit('error', `数值不能大于 ${props.max}`);
244
+ } else {
245
+ nextValue = round(+value, props.precision);
246
+ }
247
+ return nextValue;
248
+ };
249
+
250
+ /** 确认数据 */
251
+ const confirmValue = (value: string, isStepButton = false) => {
252
+ const nextValue = validateValue(value, isStepButton);
253
+ editValue.value = nextValue + '';
254
+
255
+ emit('update:modelValue', nextValue);
256
+ emit('change', { value, lastValue: _lastValue });
257
+ };
258
+
259
+ /** 显示数字键盘弹框 */
260
+ const showPad = () => {
261
+ if (isReadonly.value || props.disabled || !props.editable) return;
262
+
263
+ editValue.value = (props.modelValue ?? '') + '';
264
+ isShowPad.value = true;
265
+ };
266
+
267
+ /** 关闭数字键盘弹框 */
268
+ const closePad = () => {
269
+ maskRef.value?.close();
270
+ };
271
+
272
+ /** 点击弹框确认按钮 */
273
+ const onConfirm = () => {
274
+ confirmValue(editValue.value as string);
275
+ closePad();
270
276
  };
271
277
  </script>
272
278
 
273
279
  <style lang="scss" module>
274
- @use '../../styles/index' as *;
280
+ @use '../../styles/utils' as *;
281
+ @use './number-dialog' as *;
275
282
 
276
283
  // 定义外部变量
277
- $component-name: 'number-dialog';
278
- $component-vars: $number-dialog;
279
284
  %external-vars {
280
- @include UTILS__DEFINE_COMPONENT_VARS();
285
+ @include UTILS__DEFINE_COMPONENT_VARS($number-dialog, 'number-dialog');
281
286
  }
282
287
 
283
288
  .NumberDialog {
@@ -0,0 +1,9 @@
1
+ @use 'sass:map';
2
+
3
+ // 可配置的变量
4
+ $number-input: () !default;
5
+ $number-input-default: (
6
+ font-size: inherit,
7
+ text-align: center,
8
+ );
9
+ $number-input: map.merge($number-input-default, $number-input);