@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,5 +1,5 @@
1
1
  <template>
2
- <view :class="componentClassNames">
2
+ <view :class="[...classNames, $style['Searching']]">
3
3
  <image v-if="image" :src="image" :class="$style['Searching--image']" />
4
4
  <view v-else :class="$style['Searching--search-icon-animation']">
5
5
  <icon-cpn icon="search" :class="$style['Searching--search-icon']" />
@@ -10,52 +10,36 @@
10
10
  </view>
11
11
  </template>
12
12
 
13
- <script>
14
- import componentName from '../../mixins/componentName';
13
+ <script lang="ts" setup>
14
+ import useClassNames from '../../composable/component-name';
15
15
  import IconCpn from '../icon/icon.vue';
16
16
 
17
- export default {
18
- name: 'Searching',
17
+ defineOptions({
19
18
  options: {
20
19
  virtualHost: true,
21
20
  styleIsolation: 'shared',
22
21
  },
23
- components: { IconCpn },
24
- mixins: [componentName],
25
- props: {
26
- /** 图片 */
27
- image: {
28
- type: String,
29
- default: '',
30
- },
31
- /** 文本 */
32
- text: {
33
- type: String,
34
- default: '数据加载中',
35
- },
36
- },
22
+ });
23
+
24
+ const classNames = useClassNames('searching');
25
+
26
+ type _Props = {
27
+ /** 图片 */
28
+ image?: string;
29
+ /** 文本 */
30
+ text?: string;
37
31
  };
32
+
33
+ withDefaults(defineProps<_Props>(), {
34
+ image: '',
35
+ text: '数据加载中',
36
+ });
38
37
  </script>
39
38
 
40
39
  <style lang="scss" module>
41
40
  @use '../../styles/index' as *;
42
41
 
43
- // 自定义样式变量前缀,与组件名称一致
44
- $component-prefix: '#{$ec-component-prefix}-searching';
45
- // 自定义样式变量
46
- %external-vars {
47
- @include define-component-vars(
48
- $image-size: 300rpx,
49
- $image-width: var(--image-size),
50
- $image-height: var(--image-size),
51
- $space: get-value('size-m'),
52
- $color: get-value('color-info'),
53
- $font-size: get-value('size-font-m')
54
- );
55
- }
56
-
57
42
  .Searching {
58
- @extend %external-vars;
59
43
  display: flex;
60
44
  flex-direction: column;
61
45
  justify-content: center;
@@ -63,8 +47,8 @@ $component-prefix: '#{$ec-component-prefix}-searching';
63
47
  }
64
48
  .Searching--image {
65
49
  position: relative;
66
- width: var(--image-width);
67
- height: var(--image-height);
50
+ width: 300rpx;
51
+ height: 300rpx;
68
52
  }
69
53
  .Searching--search-icon-animation {
70
54
  width: 100rpx;
@@ -75,12 +59,21 @@ $component-prefix: '#{$ec-component-prefix}-searching';
75
59
  .Searching--search-icon {
76
60
  position: absolute;
77
61
  font-size: 60rpx;
78
- color: var(--color);
62
+ color: #999;
79
63
  animation: circle 1.5s linear infinite reverse;
80
64
  }
81
65
  .Searching--text {
82
- margin-top: var(--space);
83
- color: var(--color);
84
- font-size: var(--font-size);
66
+ margin-top: 20rpx;
67
+ color: #999;
68
+ font-size: 28rpx;
69
+ }
70
+
71
+ @keyframes circle {
72
+ 0% {
73
+ transform: rotate(0deg);
74
+ }
75
+ 100% {
76
+ transform: rotate(360deg);
77
+ }
85
78
  }
86
79
  </style>
@@ -1,11 +1,8 @@
1
1
  <template>
2
- <view :class="componentClassNames" @click="onClick">
3
- <text v-if="isReadonly || value" :class="$style['Selector--text']">
4
- <slot>
5
- {{ value || '' }}
6
- </slot>
2
+ <view :class="[...classNames, $style['Selector']]" @click="onClick">
3
+ <text v-if="isReadonly || modelValue" :class="$style['Selector--text']">
4
+ <slot>{{ modelValue || '' }}</slot>
7
5
  </text>
8
-
9
6
  <text v-else :class="[$style['Selector--text'], $style['Selector--placeholder']]">
10
7
  {{ placeholder }}
11
8
  </text>
@@ -13,54 +10,52 @@
13
10
  </view>
14
11
  </template>
15
12
 
16
- <script>
17
- import componentName from '../../mixins/componentName';
18
- import { isFormReadonly } from '../form/mixin';
13
+ <script lang="ts" setup>
14
+ import { computed, inject } from 'vue';
15
+ import useClassNames from '../../composable/component-name';
19
16
  import IconCpn from '../icon/icon.vue';
20
17
 
21
- export default {
22
- name: 'Selector',
18
+ defineOptions({
23
19
  options: {
24
20
  virtualHost: true,
25
21
  styleIsolation: 'shared',
26
22
  },
27
- components: { IconCpn },
28
- mixins: [componentName, isFormReadonly],
29
- props: {
30
- /** 绑定值 */
31
- value: {
32
- type: [String, null],
33
- default: '',
34
- },
35
- /** 是否禁用 */
36
- disabled: {
37
- type: Boolean,
38
- default: false,
39
- },
40
- /** 是否只读 */
41
- readonly: {
42
- type: Boolean,
43
- default: false,
44
- },
45
- /** 占位文本 */
46
- placeholder: {
47
- type: String,
48
- default: '请选择',
49
- },
50
- },
51
- computed: {
52
- isReadonly() {
53
- return this.readonly || this.isFormReadonly;
54
- },
55
- },
56
- methods: {
57
- onClick() {
58
- if (this.disabled || this.isReadonly) {
59
- return;
60
- }
61
- this.$emit('click');
62
- },
63
- },
23
+ });
24
+
25
+ const classNames = useClassNames('selector');
26
+
27
+ type _Props = {
28
+ /** 绑定值 */
29
+ modelValue?: string | null;
30
+ /** 是否禁用 */
31
+ disabled?: boolean;
32
+ /** 是否只读 */
33
+ readonly?: boolean;
34
+ /** 占位文本 */
35
+ placeholder?: string;
36
+ };
37
+
38
+ const props = withDefaults(defineProps<_Props>(), {
39
+ modelValue: '',
40
+ disabled: false,
41
+ readonly: false,
42
+ placeholder: '请选择',
43
+ });
44
+
45
+ const emit = defineEmits<{
46
+ (e: 'click'): void;
47
+ }>();
48
+
49
+ const isFormReadonly = inject(
50
+ 'ecolovo/form/readonly',
51
+ computed(() => false)
52
+ );
53
+
54
+ const isReadonly = computed(() => props.readonly || isFormReadonly.value);
55
+
56
+ const onClick = () => {
57
+ if (props.disabled || isReadonly.value) return;
58
+ emit('click');
64
59
  };
65
60
  </script>
66
61
 
@@ -0,0 +1,12 @@
1
+ @use 'sass:map';
2
+ @use '../../styles/utils' as *;
3
+
4
+ // 可配置的变量
5
+ $switch: () !default;
6
+ $switch-default: (
7
+ width: 92rpx,
8
+ height: 48rpx,
9
+ active-color: UTILS__GLOBAL_VAR(theme, primary),
10
+ indicator-size: 42rpx,
11
+ );
12
+ $switch: map.merge($switch-default, $switch);
@@ -1,10 +1,11 @@
1
1
  <template>
2
2
  <view
3
3
  :class="[
4
- componentClassNames,
4
+ ...classNames,
5
+ $style['Switch'],
5
6
  {
6
7
  [$style['Switch--disabled']]: disabled || loading,
7
- [$style['Switch--switch-on']]: value === valueOn,
8
+ [$style['Switch--switch-on']]: modelValue === valueOn,
8
9
  },
9
10
  ]"
10
11
  @click.stop="toggle"
@@ -15,115 +16,117 @@
15
16
  </view>
16
17
  </template>
17
18
 
18
- <script>
19
- import componentName from '../../mixins/componentName';
20
- import { isFormReadonly } from '../form/mixin';
19
+ <script lang="ts" setup>
20
+ import { computed, inject, ref } from 'vue';
21
+ import useClassNames from '../../composable/component-name';
21
22
  import IconCpn from '../icon/icon.vue';
22
23
 
23
- export default {
24
- name: 'Switch',
24
+ defineOptions({
25
25
  options: {
26
26
  virtualHost: true,
27
27
  styleIsolation: 'shared',
28
28
  },
29
- components: { IconCpn },
30
- mixins: [componentName, isFormReadonly],
31
- props: {
32
- /** 绑定值 */
33
- value: {
34
- type: [Boolean, Number, String],
35
- default: false,
36
- },
37
- /** 是否异步事件 */
38
- async: {
39
- type: Boolean,
40
- default: false,
41
- },
42
- /** 开启状态的值 */
43
- valueOn: {
44
- type: [Boolean, Number, String],
45
- default: true,
46
- },
47
- /** 关闭状态的值 */
48
- valueOff: {
49
- type: [Boolean, Number, String],
50
- default: false,
51
- },
52
- /** 是否禁用 */
53
- disabled: {
54
- type: Boolean,
55
- default: false,
56
- },
57
- /** 是否只读 */
58
- readonly: {
59
- type: Boolean,
60
- default: false,
61
- },
62
- },
63
- data() {
64
- return {
65
- /** 是否加载中状态 */
66
- loading: false,
67
- };
68
- },
69
- computed: {
70
- isReadonly() {
71
- return this.readonly || this.isFormReadonly;
72
- },
73
- /** 按钮是否可点击 */
74
- isNotClickable() {
75
- return this.disabled || this.isReadonly || this.loading;
76
- },
77
- },
78
- methods: {
79
- /** 开启或关闭 */
80
- toggle() {
81
- if (this.isNotClickable) return;
82
-
83
- if (!this.async) {
84
- this.$_toggle();
85
- return;
86
- }
29
+ });
30
+
31
+ const classNames = useClassNames('switch');
32
+
33
+ type _Props = {
34
+ /** 绑定值 */
35
+ modelValue?: boolean | number | string;
36
+ /** 是否异步事件 */
37
+ async?: boolean;
38
+ /** 开启状态的值 */
39
+ valueOn?: boolean | number | string;
40
+ /** 关闭状态的值 */
41
+ valueOff?: boolean | number | string;
42
+ /** 是否禁用 */
43
+ disabled?: boolean;
44
+ /** 是否只读 */
45
+ readonly?: boolean;
46
+ };
47
+
48
+ const props = withDefaults(defineProps<_Props>(), {
49
+ modelValue: false,
50
+ async: false,
51
+ valueOn: true,
52
+ valueOff: false,
53
+ disabled: false,
54
+ readonly: false,
55
+ });
56
+
57
+ const emit = defineEmits<{
58
+ (e: 'update:modelValue', val: boolean | number | string): void;
59
+ (
60
+ e: 'async',
61
+ payload: {
62
+ value: boolean | number | string;
63
+ resolve: (value: unknown) => void;
64
+ reject: (reason?: unknown) => void;
65
+ }
66
+ ): void;
67
+ }>();
68
+
69
+ /** 表单是否只读 */
70
+ const isFormReadonly = inject(
71
+ 'ecolovo/form/readonly',
72
+ computed(() => false)
73
+ );
87
74
 
88
- this.loading = true;
89
- const nextValue = this.value !== this.valueOn ? this.valueOn : this.valueOff;
90
- const { promise, resolve, reject } = Promise.withResolvers();
91
- promise
92
- .then((isOk = true) => {
93
- if (isOk === false) return;
94
- this.$_toggle();
95
- })
96
- .catch((err) => {
97
- if (process.env.NODE_ENV === 'development') {
98
- // eslint-disable-next-line no-console
99
- console.warn(`${this.componentClass} unresolved error:`, err);
100
- }
101
- })
102
- .finally(() => {
103
- this.loading = false;
104
- });
105
- this.$emit('async', { value: nextValue, resolve, reject });
106
- },
107
- /** 开启或关闭,组件内部调用 */
108
- $_toggle() {
109
- if (this.value !== this.valueOn) {
110
- this.$emit('input', this.valueOn);
111
- } else {
112
- this.$emit('input', this.valueOff);
75
+ /** 是否加载中状态 */
76
+ const loading = ref(false);
77
+
78
+ /** 是否只读 */
79
+ const isReadonly = computed(() => props.readonly || isFormReadonly.value);
80
+
81
+ /** 按钮是否可点击 */
82
+ const isNotClickable = computed(() => props.disabled || isReadonly.value || loading.value);
83
+
84
+ /** 开启或关闭 */
85
+ const toggle = () => {
86
+ if (isNotClickable.value) return;
87
+
88
+ if (!props.async) {
89
+ $_toggle();
90
+ return;
91
+ }
92
+
93
+ loading.value = true;
94
+ const nextValue = props.modelValue !== props.valueOn ? props.valueOn : props.valueOff;
95
+ const { promise, resolve, reject } = Promise.withResolvers();
96
+ promise
97
+ .then((isOk = true) => {
98
+ if (isOk === false) return;
99
+ $_toggle();
100
+ })
101
+ .catch((err) => {
102
+ if (import.meta.env.DEV) {
103
+ // eslint-disable-next-line no-console
104
+ console.warn(`${classNames[0]} unresolved error:`, err);
113
105
  }
114
- },
115
- },
106
+ })
107
+ .finally(() => {
108
+ loading.value = false;
109
+ });
110
+ emit('async', { value: nextValue, resolve, reject });
111
+ };
112
+
113
+ /** 开启或关闭,组件内部调用 */
114
+ const $_toggle = () => {
115
+ if (props.modelValue !== props.valueOn) {
116
+ emit('update:modelValue', props.valueOn);
117
+ } else {
118
+ emit('update:modelValue', props.valueOff);
119
+ }
116
120
  };
117
121
  </script>
118
122
 
119
123
  <style lang="scss" module>
120
- @use '../../styles/index' as *;
124
+ @use '../../styles/utils' as *;
125
+ @use './switch' as *;
121
126
 
122
127
  // 定义外部变量
123
- $component-name: 'switch';
124
- $component-vars: $switch;
125
128
  %external-vars {
126
- @include UTILS__DEFINE_COMPONENT_VARS();
129
+ @include UTILS__DEFINE_COMPONENT_VARS($switch, 'switch');
127
130
  }
128
131
 
129
132
  .Switch {
@@ -0,0 +1,19 @@
1
+ @use 'sass:map';
2
+ @use '../../styles/utils' as *;
3
+
4
+ // 可配置的变量
5
+ $tab: () !default;
6
+ $tab-default: (
7
+ height: 88rpx,
8
+ tab-padding: 0 10rpx,
9
+ tab-gaps: 0,
10
+ color: UTILS__GLOBAL_VAR(color, foreground),
11
+ font-size: UTILS__GLOBAL_VAR(font-size, large),
12
+ font-weight: 600,
13
+ background: #ffffff,
14
+ border-radius: 0,
15
+ active-color: UTILS__LOCAL_VAR(color),
16
+ indicator-color: UTILS__GLOBAL_VAR(theme, primary),
17
+ indicator-width: null,
18
+ );
19
+ $tab: map.merge($tab-default, $tab);