@ecolovo/uniapp-components 1.0.9 → 2.0.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 (117) hide show
  1. package/README.md +83 -51
  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 +125 -181
  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 -81
  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.ts +10 -0
  75. package/configs/index.ts +82 -0
  76. package/{easyCom.js → easyCom.ts} +1 -1
  77. package/index.ts +1 -0
  78. package/init.ts +34 -0
  79. package/package.json +12 -4
  80. package/styles/utils/css-var.scss +12 -15
  81. package/styles/utils/ellipsis.scss +0 -7
  82. package/styles/utils/z-index.scss +1 -1
  83. package/styles/var/component.scss +21 -245
  84. package/utils/{date.js → date.ts} +44 -42
  85. package/utils/freezeDeep.ts +9 -0
  86. package/utils/price.ts +57 -0
  87. package/utils/round.ts +11 -0
  88. package/utils/{windowInfo.js → windowInfo.ts} +12 -35
  89. package/components/checkbox-group2/checkbox.vue +0 -109
  90. package/components/datetime-picker/datetime-picker-view.vue +0 -209
  91. package/components/datetime-picker/datetime-picker.vue +0 -235
  92. package/components/form/mixin.js +0 -13
  93. package/components/list-page/list-page.js +0 -10
  94. package/components/table/table.vue +0 -112
  95. package/components/time-picker/time-picker-view.vue +0 -127
  96. package/components/time-picker/time-picker.vue +0 -140
  97. package/components/uploader/download.js +0 -81
  98. package/components/uploader/file-uploader.vue +0 -52
  99. package/components/uploader/files.js +0 -225
  100. package/components/uploader/media-uploader.vue +0 -179
  101. package/components/uploader/mixin.js +0 -171
  102. package/components/uploader/uni.js +0 -38
  103. package/components/uploader/upload-button.vue +0 -29
  104. package/components/uploader/uploader copy.vue +0 -547
  105. package/components/uploader/uploader.vue +0 -117
  106. package/configs/index.d.ts +0 -22
  107. package/configs/index.js +0 -68
  108. package/init.d.ts +0 -19
  109. package/init.js +0 -20
  110. package/mixins/componentName.js +0 -32
  111. package/mixins/listPage.js +0 -1
  112. package/mixins/windowInfo.js +0 -1
  113. package/utils/fileSize.js +0 -39
  114. package/utils/floor.js +0 -20
  115. package/utils/freezeDeep.js +0 -19
  116. package/utils/price.js +0 -32
  117. package/utils/round.js +0 -22
@@ -1,99 +1,97 @@
1
1
  <template>
2
- <view :class="componentClassNames">
2
+ <view :class="[...classNames, $style['CheckboxGroup']]">
3
3
  <slot></slot>
4
4
  </view>
5
5
  </template>
6
6
 
7
- <script>
8
- import componentName from '../../mixins/componentName';
7
+ <script lang="ts" setup>
8
+ import { computed, provide, ref, watch } from 'vue';
9
+ import useClassNames from '../../composable/component-name';
9
10
 
10
- export default {
11
- name: 'CheckboxGroup',
11
+ defineOptions({
12
12
  options: {
13
- virtualHost: true,
14
13
  styleIsolation: 'shared',
14
+ virtualHost: true,
15
15
  },
16
- mixins: [componentName],
17
- provide() {
18
- return {
19
- checkboxGroupCheck: this.check,
20
- checkboxGroupProps: this.$props,
21
- checkboxGroupData: this.$data,
22
- };
23
- },
24
- props: {
25
- /** 值 */
26
- value: {
27
- type: [Number, String, Boolean, Array, null],
28
- default: null,
29
- },
30
- /** 类型 */
31
- radio: {
32
- type: Boolean,
33
- default: false,
34
- },
35
- /** 是否显示勾选图标 */
36
- icon: {
37
- type: Boolean,
38
- default: true,
39
- },
40
- /** 选中时的图标 */
41
- checkedIcon: {
42
- type: String,
43
- default: '',
44
- },
45
- /** 未选中时的图标 */
46
- uncheckedIcon: {
47
- type: String,
48
- default: '',
49
- },
50
- },
51
- data() {
52
- return {
53
- checkedValue: null,
54
- };
16
+ });
17
+
18
+ const classNames = useClassNames('checkbox-group');
19
+
20
+ type _Props = {
21
+ /** 绑定值 */
22
+ modelValue?: string | number | boolean | Array<unknown>;
23
+ /** 是否单选 */
24
+ radio?: boolean;
25
+ /** 是否显示勾选图标 */
26
+ icon?: boolean;
27
+ /** 选中时的图标 */
28
+ checkedIcon?: string;
29
+ /** 未选中时的图标 */
30
+ uncheckedIcon?: string;
31
+ };
32
+
33
+ const props = withDefaults(defineProps<_Props>(), {
34
+ modelValue: undefined,
35
+ radio: false,
36
+ icon: true,
37
+ checkedIcon: '',
38
+ uncheckedIcon: '',
39
+ });
40
+
41
+ const emit = defineEmits<{
42
+ (event: 'update:modelValue', value?: string | number | boolean | Array<unknown>): void;
43
+ (event: 'change', value?: string | number | boolean | Array<unknown>): void;
44
+ }>();
45
+
46
+ const checkedValue = ref<undefined | string | number | boolean | Array<unknown>>(undefined);
47
+
48
+ const currentValue = computed({
49
+ get: function () {
50
+ return props.modelValue === undefined ? checkedValue.value : props.modelValue;
55
51
  },
56
- computed: {
57
- currentValue: {
58
- get: function () {
59
- return this.value === null ? this.checkedValue : this.value;
60
- },
61
- set: function (val) {
62
- this.$emit('input', val);
63
- this.checkedValue = val;
64
- this.$emit('change', val);
65
- },
66
- },
52
+ set: function (val) {
53
+ if (checkedValue.value === val) return;
54
+ emit('update:modelValue', val);
55
+ checkedValue.value = val;
56
+ emit('change', val);
67
57
  },
68
- watch: {
69
- value: {
70
- handler: function (val) {
71
- this.checkedValue = val;
72
- },
73
- immediate: true,
74
- deep: true,
75
- },
58
+ });
59
+
60
+ watch(
61
+ () => props.modelValue,
62
+ (val) => {
63
+ if (checkedValue.value === val) return;
64
+ emit('update:modelValue', val);
65
+ checkedValue.value = val;
66
+ emit('change', val);
76
67
  },
77
- methods: {
78
- check(val) {
79
- if (this.radio) {
80
- this.currentValue = val;
81
- return;
82
- }
68
+ {
69
+ immediate: true,
70
+ deep: true,
71
+ }
72
+ );
83
73
 
84
- if (!Array.isArray(this.currentValue)) {
85
- this.currentValue = [val];
86
- return;
87
- }
74
+ const check = (val: string | number | boolean | Array<unknown>) => {
75
+ if (props.radio) {
76
+ currentValue.value = val;
77
+ return;
78
+ }
88
79
 
89
- if (this.currentValue.includes(val)) {
90
- this.currentValue = this.currentValue.filter((item) => item !== val);
91
- } else {
92
- this.currentValue.push(val);
93
- }
94
- },
95
- },
80
+ if (!Array.isArray(currentValue.value)) {
81
+ currentValue.value = [val];
82
+ return;
83
+ }
84
+
85
+ if (currentValue.value.includes(val)) {
86
+ currentValue.value = currentValue.value.filter((item) => item !== val);
87
+ } else {
88
+ currentValue.value = currentValue.value.concat(val);
89
+ }
96
90
  };
91
+
92
+ provide('ecolovo/checkboxGroup/props', props);
93
+ provide('ecolovo/checkboxGroup/checkedValue', checkedValue);
94
+ provide('ecolovo/checkboxGroup/check', check);
97
95
  </script>
98
96
 
99
97
  <style lang="scss" module>
@@ -1,9 +1,11 @@
1
1
  <template>
2
- <view :class="componentClassNames">
3
- <checkbox-cpn
2
+ <view :class="[...classNames, $style['CheckboxGroup2']]">
3
+ <checkbox2-cpn
4
4
  v-for="(item, index) in options"
5
5
  :key="index"
6
- :value="radio ? item.value === currentValue : currentValue && currentValue.includes(item.value)"
6
+ :value="
7
+ radio ? item.value === currentValue : Array.isArray(currentValue) && currentValue.includes(item.value)
8
+ "
7
9
  :icon="icon"
8
10
  :checked-icon="checkedIcon || (radio ? 'radio-checked' : 'checkbox-checked')"
9
11
  :unchecked-icon="uncheckedIcon || (radio ? 'radio-unchecked' : 'checkbox-unchecked')"
@@ -11,120 +13,122 @@
11
13
  @change="check(item.value)"
12
14
  >
13
15
  {{ item.label }}
14
- </checkbox-cpn>
16
+ </checkbox2-cpn>
15
17
  </view>
16
18
  </template>
17
19
 
18
- <script>
19
- import componentName from '../../mixins/componentName';
20
- import CheckboxCpn from './checkbox.vue';
20
+ <script lang="ts" setup>
21
+ import { computed, ref } from 'vue';
22
+ import useClassNames from '../../composable/component-name';
23
+ import Checkbox2Cpn from './checkbox2.vue';
21
24
 
22
- export default {
23
- name: 'CheckboxGroup2',
25
+ defineOptions({
24
26
  options: {
25
- virtualHost: true,
26
27
  styleIsolation: 'shared',
28
+ virtualHost: true,
27
29
  },
28
- components: { CheckboxCpn },
29
- mixins: [componentName],
30
- props: {
31
- /** 值 */
32
- value: {
33
- type: [Number, String, Boolean, Array, null],
34
- default: null,
35
- },
36
- /** 类型 */
37
- options: {
38
- type: Array,
39
- default: () => [],
40
- },
41
- /** 类型 */
42
- radio: {
43
- type: Boolean,
44
- default: true,
45
- },
46
- /** 是否显示勾选图标 */
47
- icon: {
48
- type: Boolean,
49
- default: true,
50
- },
51
- /** 选中时的图标 */
52
- checkedIcon: {
53
- type: String,
54
- default: '',
55
- },
56
- /** 未选中时的图标 */
57
- uncheckedIcon: {
58
- type: String,
59
- default: '',
60
- },
61
- },
62
- data() {
63
- return {
64
- checkedValue: null,
65
- };
66
- },
67
- computed: {
68
- currentValue: {
69
- get() {
70
- return this.value === null ? this.checkedValue : this.value;
71
- },
72
- set(val) {
73
- this.$emit('input', val);
74
- this.checkedValue = val;
75
- this.$emit('change', val);
76
- },
77
- },
78
- optionsValue() {
79
- return this.options.map((item) => item.value);
80
- },
30
+ });
31
+
32
+ const classNames = useClassNames('aspect');
33
+
34
+ type OptionValue = string | number | boolean;
35
+ interface _Option {
36
+ label: string;
37
+ value: OptionValue;
38
+ }
39
+
40
+ type _Props = {
41
+ /** 选项值 */
42
+ modelValue?: OptionValue | OptionValue[];
43
+ /** 选项 */
44
+ options?: _Option[];
45
+ /** 是否单选 */
46
+ radio?: boolean;
47
+ /** 是否显示勾选图标 */
48
+ icon?: boolean;
49
+ /** 选中时的图标 */
50
+ checkedIcon?: string;
51
+ /** 未选中时的图标 */
52
+ uncheckedIcon?: string;
53
+ };
54
+
55
+ const props = withDefaults(defineProps<_Props>(), {
56
+ modelValue: undefined,
57
+ options: () => [],
58
+ radio: false,
59
+ icon: true,
60
+ checkedIcon: undefined,
61
+ uncheckedIcon: undefined,
62
+ });
63
+
64
+ const emit = defineEmits<{
65
+ (event: 'update:modelValue', value?: OptionValue | OptionValue[]): void;
66
+ (event: 'change', value?: OptionValue | OptionValue[]): void;
67
+ }>();
68
+
69
+ const checkedValue = ref<OptionValue | OptionValue[]>();
70
+
71
+ const currentValue = computed<undefined | OptionValue | OptionValue[]>({
72
+ get() {
73
+ return props.modelValue === undefined ? checkedValue.value : props.modelValue;
81
74
  },
82
- methods: {
83
- check(val) {
84
- if (this.radio) {
85
- this.currentValue = val;
86
- return;
87
- }
88
-
89
- if (!Array.isArray(this.currentValue)) {
90
- this.currentValue = [val];
91
- return;
92
- }
93
-
94
- if (this.currentValue.includes(val)) {
95
- this.currentValue = this.currentValue.filter((item) => item !== val);
96
- } else {
97
- this.currentValue.push(val);
98
- }
99
- },
100
- /** 切换全选
101
- * @param {boolean | Array} isSelectedAll
102
- */
103
- toggle(isSelectedAll) {
104
- if (this.radio) return;
105
-
106
- if (typeof isSelectedAll === 'boolean') {
107
- if (isSelectedAll) {
108
- this.currentValue = this.optionsValue;
109
- } else {
110
- this.currentValue = [];
111
- }
112
- return;
113
- }
114
-
115
- if (Array.isArray(isSelectedAll)) {
116
- this.currentValue = isSelectedAll.filter((item) => this.optionsValue.includes(item));
117
- return;
118
- }
119
-
120
- if (Array.isArray(this.currentValue) && this.currentValue.length === this.options.length) {
121
- this.currentValue = [];
122
- } else {
123
- this.currentValue = this.optionsValue;
124
- }
125
- },
75
+ set(val) {
76
+ emit('update:modelValue', val);
77
+ checkedValue.value = val;
78
+ emit('change', val);
126
79
  },
80
+ });
81
+
82
+ const optionsValue = computed(() => {
83
+ return props.options.map((item) => item.value);
84
+ });
85
+
86
+ const check = (val: OptionValue) => {
87
+ if (props.radio) {
88
+ currentValue.value = val;
89
+ return;
90
+ }
91
+
92
+ if (!Array.isArray(currentValue.value)) {
93
+ currentValue.value = [val];
94
+ return;
95
+ }
96
+
97
+ if (currentValue.value.includes(val)) {
98
+ currentValue.value = currentValue.value.filter((item) => item !== val);
99
+ } else {
100
+ currentValue.value.push(val);
101
+ }
102
+ };
103
+
104
+ /** 切换全选
105
+ * @param {boolean | Array} isSelectedAll
106
+ */
107
+ const toggle = (isSelectedAll: boolean | OptionValue | OptionValue[]) => {
108
+ if (props.radio) return;
109
+
110
+ if (typeof isSelectedAll === 'boolean') {
111
+ if (isSelectedAll) {
112
+ currentValue.value = optionsValue.value;
113
+ } else {
114
+ currentValue.value = [];
115
+ }
116
+ return;
117
+ }
118
+
119
+ if (Array.isArray(isSelectedAll)) {
120
+ currentValue.value = isSelectedAll.filter((item) => optionsValue.value.includes(item));
121
+ return;
122
+ }
123
+
124
+ if (Array.isArray(currentValue.value) && currentValue.value.length === props.options.length) {
125
+ currentValue.value = [];
126
+ } else {
127
+ currentValue.value = optionsValue.value;
128
+ }
127
129
  };
130
+
131
+ defineExpose({ toggle });
128
132
  </script>
129
133
 
130
134
  <style lang="scss" module>
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <view :class="[...classNames, $style['Checkbox2']]" @click="toggle()">
3
+ <icon-cpn
4
+ v-if="icon"
5
+ :icon="currentValue ? checkedIcon || 'checkbox-checked' : uncheckedIcon || 'checkbox-unchecked'"
6
+ tap-size="50rpx"
7
+ :class="[$style['Checkbox2--icon'], { [$style['Checkbox2--checked']]: currentValue }]"
8
+ />
9
+ <view :class="$style['Checkbox2--text']">
10
+ <slot></slot>
11
+ </view>
12
+ </view>
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ import { computed, ref } from 'vue';
17
+ import useClassNames from '../../composable/component-name';
18
+ import IconCpn from '../icon/icon.vue';
19
+
20
+ defineOptions({
21
+ options: {
22
+ styleIsolation: 'shared',
23
+ virtualHost: true,
24
+ },
25
+ });
26
+
27
+ const classNames = useClassNames('aspect');
28
+
29
+ type _Props = {
30
+ /** 选项值 */
31
+ value?: boolean;
32
+ /** 是否显示勾选图标 */
33
+ icon?: boolean;
34
+ /** 选中时的图标 */
35
+ checkedIcon?: string;
36
+ /** 未选中时的图标 */
37
+ uncheckedIcon?: string;
38
+ };
39
+
40
+ const props = withDefaults(defineProps<_Props>(), {
41
+ value: undefined,
42
+ icon: true,
43
+ checkedIcon: undefined,
44
+ uncheckedIcon: undefined,
45
+ });
46
+
47
+ const emit = defineEmits<{
48
+ (event: 'update:modelValue', value: boolean): void;
49
+ (event: 'change', value: boolean): void;
50
+ }>();
51
+
52
+ const innerValue = ref(false);
53
+
54
+ const currentValue = computed({
55
+ get: function () {
56
+ return props.value === undefined ? innerValue.value : props.value;
57
+ },
58
+ set: function (val) {
59
+ emit('update:modelValue', val);
60
+ innerValue.value = val;
61
+ emit('change', val);
62
+ },
63
+ });
64
+
65
+ /** 切换选择 */
66
+ const toggle = (checked?: boolean) => {
67
+ if (checked === undefined || checked === null) {
68
+ currentValue.value = !currentValue.value;
69
+ return;
70
+ }
71
+
72
+ if (currentValue.value !== !!checked) {
73
+ currentValue.value = !!checked;
74
+ }
75
+ };
76
+ </script>
77
+
78
+ <style lang="scss" module>
79
+ @use '../../styles/utils' as *;
80
+ @use '../checkbox/checkbox' as *;
81
+
82
+ // 定义外部变量
83
+ %external-vars {
84
+ @include UTILS__DEFINE_COMPONENT_VARS($checkbox, 'checkbox');
85
+ }
86
+
87
+ .Checkbox2 {
88
+ @extend %external-vars;
89
+ display: flex;
90
+ align-items: center;
91
+
92
+ .Checkbox2--icon {
93
+ flex: none;
94
+ margin-right: 12rpx;
95
+ color: UTILS__LOCAL_VAR(unchecked-color);
96
+ }
97
+ .Checkbox2--checked {
98
+ color: UTILS__LOCAL_VAR(checked-color);
99
+ }
100
+ .Checkbox2--text {
101
+ flex: 0 1 auto;
102
+ }
103
+ }
104
+ </style>
@@ -0,0 +1,9 @@
1
+ @use 'sass:map';
2
+
3
+ // 可配置的变量
4
+ $data-list: () !default;
5
+ $data-list-default: (
6
+ // 触发加载更多的区域高度
7
+ observer-height: 100vh
8
+ );
9
+ $data-list: map.merge($data-list-default, $data-list);