@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
package/README.md CHANGED
@@ -1,37 +1,28 @@
1
1
  # @ecolovo/uniapp-components
2
2
 
3
- Ecolovo UniApp 组件库
3
+ UniApp **Vue3** 组件库。
4
4
 
5
+ 本项目是为基于 `cli` 脚手架创建的项目开发的,未在 HBuilderX 项目中实践,请自行验证是否可以正常使用。
5
6
 
6
- ## Installation
7
+ ## 安装
7
8
 
8
9
  使用 npm / yarn 安装
9
10
 
10
11
  ```bash
11
- npm install @ecolovo/uniapp-components
12
+ npm install @ecolovo/uniapp-components
12
13
  ```
13
14
 
14
15
  同时需要使用 `uni-pages-hot-modules` 用来动态配置
15
16
 
16
17
  ```bash
17
- npm install uni-pages-hot-modules --save-dev
18
+ npm install uni-pages-hot-modules --save-dev
18
19
  ```
19
20
 
20
- ## Usage
21
+ ## 组件库的配置
21
22
 
22
- ### 1. 配置 `vue.config.js` 文件
23
+ 使用前,请按照以下步骤进行一些必要的配置。
23
24
 
24
- ```javascript
25
- // vue.config.js
26
-
27
- module.exports = {
28
- // configs...
29
- transpileDependencies: ['@ecolovo/uniapp-components'],
30
- // other configs...
31
- }
32
- ```
33
-
34
- ### 2. 在 `src/main.js` 文件中初始化组件库
25
+ ### 1. 在 `src/main.js` 文件中初始化组件库
35
26
 
36
27
  ```javascript
37
28
  // src/main.js
@@ -39,13 +30,13 @@ module.exports = {
39
30
  import init from '@ecolovo/uniapp-components/init';
40
31
 
41
32
  init({
42
- // 配置组件前缀
43
- // 在使用时加上前缀,如 button 组件,使用 <ui-button>
44
- componentPrefix: 'ui',
33
+ // 配置组件前缀
34
+ // 在使用时加上前缀,如 button 组件,使用 <ui-button>
35
+ componentPrefix: 'ui',
45
36
  });
46
37
  ```
47
38
 
48
- ### 3. 配置 `src/pages.js` 文件,
39
+ ### 2. 配置 `src/pages.js` 文件,
49
40
 
50
41
  ```javascript
51
42
  // src/pages.js
@@ -55,44 +46,55 @@ const { hot } = require('uni-pages-hot-modules');
55
46
  const componentEasyCom = require('@ecolovo/uniapp-components/easyCom');
56
47
 
57
48
  module.exports = hot((pagesJson) => {
58
- const pagesConfig = require('./pagesDef');
59
-
60
- return mergeWith(
61
- // pages.json 中的配置
62
- pagesJson,
63
- pagesConfig,
64
- componentEasyCom('ui'), // 填入和步骤 2 中同样的前缀
65
- function (objValue, srcValue) {
66
- if (Array.isArray(objValue)) {
67
- return objValue.concat(srcValue);
68
- }
69
- }
70
- );
49
+ const pagesConfig = require('./pagesDef');
50
+
51
+ return mergeWith(
52
+ // pages.json 中的配置
53
+ pagesJson,
54
+ pagesConfig,
55
+ componentEasyCom('ui'), // 填入和步骤 2 中同样的前缀
56
+ function (objValue, srcValue) {
57
+ if (Array.isArray(objValue)) {
58
+ return objValue.concat(srcValue);
59
+ }
60
+ }
61
+ );
71
62
  });
72
63
  ```
73
64
 
74
- ### 4. 配置样式
65
+ ### 3. 配置样式
75
66
 
76
67
  #### 全局样式
77
68
 
78
- ```html
69
+ ```vue
79
70
  <!-- App.vue -->
80
71
 
81
72
  <style lang="scss">
73
+ // 引入组件库全局样式
82
74
  @use '@ecolovo/uniapp-components/styles/global';
83
75
  </style>
84
76
  ```
85
77
 
86
- #### 自定义组件配置
78
+ #### 自定义样式
87
79
 
88
- ```css
80
+ ```scss
89
81
  /* src/styles/prepend.scss */
90
82
 
83
+ // 修改全局组件前缀与主题等全局样式
91
84
  @forward '@ecolovo/uniapp-components/styles/var/theme' with (
92
- $component-prefix: 'ui', // 推荐修改为与组件前缀一致
93
- $themes: (
94
- primary: #d92e20,
95
- )
85
+ $component-prefix: 'ui',
86
+ // 推荐修改为与组件前缀一致
87
+ $themes:
88
+ (
89
+ primary: #d92e20,
90
+ )
91
+ );
92
+
93
+ // 修改组件默认样式
94
+ @forward '@ecolovo/uniapp-components/styles/var/component' with (
95
+ $badge: (
96
+ background: #d92e20,
97
+ )
96
98
  );
97
99
 
98
100
  @forward '@ecolovo/uniapp-components/styles';
@@ -104,14 +106,44 @@ module.exports = hot((pagesJson) => {
104
106
  const sass = require('sass');
105
107
 
106
108
  module.exports = {
107
- // configs...
108
- css: {
109
- loaderOptions: {
110
- scss: {
111
- prependData: '@use "@/styles/prepend" as *;'
112
- },
113
- },
114
- },
115
- // other configs...
109
+ // configs...
110
+ css: {
111
+ loaderOptions: {
112
+ scss: {
113
+ prependData: '@use "@/styles/prepend" as *;',
114
+ },
115
+ },
116
+ },
117
+ // other configs...
116
118
  };
117
119
  ```
120
+
121
+ ### 4. 全局可用的 css 变量
122
+
123
+ 以下变量的访问必须为 `<ui-page>` 的内部元素。
124
+
125
+ ```scss
126
+ // 顶部安全区高度
127
+ --safe-area-top: 30px;
128
+
129
+ // 底部安全区高度
130
+ --safe-area-bottom: 30px;
131
+
132
+ // 页面头部上边缘相较于顶部的距离,原则上等于 `--safe-area-top`
133
+ --page-header-top: 30px;
134
+
135
+ // 页面头部高度
136
+ --page-header-height: 44px;
137
+
138
+ // 页面头部下边缘相较于顶部的距离,原则上等于 `--page-header-top` + `--page-header-height`
139
+ --page-header-bottom: 74px;
140
+
141
+ // 小程序胶囊按钮宽度(实际为胶囊按钮最左侧到页面右边的距离)
142
+ --menu-button-width: calc(100vw - 280px);
143
+ ```
144
+
145
+ > 上述变量后的值仅供参考,以实际值为准
146
+
147
+ ## 使用
148
+
149
+ 请阅读 [**使用文档**](./docs/index.md) 。
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <view :class="componentClassNames">
3
- <view :class="$style['Aspect--content-wrapper']" :style="{ paddingTop: 100 * ratio + '%' }">
2
+ <view :class="[...classNames, $style['Aspect']]">
3
+ <view :class="$style['Aspect--content-wrapper']" :style="inlineStyle">
4
4
  <view :class="$style['Aspect--content']" @click="$emit('click')">
5
5
  <slot></slot>
6
6
  </view>
@@ -8,24 +8,33 @@
8
8
  </view>
9
9
  </template>
10
10
 
11
- <script>
12
- import componentName from '../../mixins/componentName';
11
+ <script lang="ts" setup>
12
+ import { computed } from 'vue';
13
+ import useClassNames from '../../composable/component-name';
13
14
 
14
- export default {
15
- name: 'Aspect',
15
+ defineOptions({
16
16
  options: {
17
- virtualHost: true,
18
17
  styleIsolation: 'shared',
18
+ virtualHost: true,
19
19
  },
20
- mixins: [componentName],
21
- props: {
22
- /** 高与宽的比例,默认为 1,即宽高相等,2 表示高为宽的 2 倍 */
23
- ratio: {
24
- type: [String, Number],
25
- default: 1,
26
- },
27
- },
20
+ });
21
+
22
+ const classNames = useClassNames('aspect');
23
+
24
+ type _Props = {
25
+ /** 图标名 */
26
+ ratio?: string | number;
28
27
  };
28
+
29
+ const props = withDefaults(defineProps<_Props>(), {
30
+ ratio: 1,
31
+ });
32
+
33
+ defineEmits<{
34
+ (event: 'click'): void;
35
+ }>();
36
+
37
+ const inlineStyle = computed(() => `padding-top: ${100 * Number(props.ratio)}%;`);
29
38
  </script>
30
39
 
31
40
  <style lang="css" module>
@@ -0,0 +1,20 @@
1
+ @use 'sass:map';
2
+ @use '../../styles/utils' as *;
3
+
4
+ $badge: () !default;
5
+ // 可配置的变量
6
+ $badge-default: (
7
+ // 徽章相对于挂载元素右上角的偏移量
8
+ translate: 40% -40%,
9
+ // 文字字号
10
+ font-size: UTILS__GLOBAL_VAR(font-size, small),
11
+ // 文字颜色
12
+ color: #fff,
13
+ // 背景色
14
+ background: #ff0000,
15
+ // 边框样式
16
+ border: none,
17
+ // 徽章高度
18
+ height: calc(#{UTILS__LOCAL_VAR(font-size)} + 12rpx)
19
+ );
20
+ $badge: map.merge($badge-default, $badge);
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view :class="componentClassNames">
2
+ <view :class="[...classNames, $style['Badge']]">
3
3
  <slot></slot>
4
4
  <template v-if="$slots['badge'] || $slots['badge-value']">
5
5
  <slot name="badge">
@@ -15,48 +15,57 @@
15
15
  </view>
16
16
  </template>
17
17
 
18
- <script>
19
- import componentName from '../../mixins/componentName';
18
+ <script lang="ts" setup>
19
+ import { computed } from 'vue';
20
+ import useClassNames from '../../composable/component-name';
20
21
 
21
- export default {
22
- name: 'Badge',
22
+ defineOptions({
23
23
  options: {
24
- virtualHost: true,
25
24
  styleIsolation: 'shared',
25
+ virtualHost: true,
26
26
  },
27
- mixins: [componentName],
28
- props: {
29
- /** 显示在右上角的内容 */
30
- value: {
31
- type: [String, Number],
32
- default: 0,
33
- },
34
- /** 最大显示值,超出时会在后面添加一个“+” */
35
- max: {
36
- type: Number,
37
- default: 99,
38
- },
39
- },
40
- computed: {
41
- /** 显示值 */
42
- showValue() {
43
- const numberValue = Number(this.value);
44
- return numberValue && numberValue > 0 ? (numberValue > this.max ? `${this.max}+` : numberValue) : '';
45
- },
46
- },
27
+ });
28
+
29
+ const classNames = useClassNames('badge');
30
+
31
+ type _Props = {
32
+ /** 显示在右上角的内容 */
33
+ value?: string | number;
34
+ /** 最大显示值,超出时会在后面添加一个“+” */
35
+ max?: number;
47
36
  };
37
+
38
+ const props = withDefaults(defineProps<_Props>(), {
39
+ value: 0,
40
+ max: 99,
41
+ });
42
+
43
+ defineEmits<{
44
+ (event: 'click'): void;
45
+ }>();
46
+
47
+ const showValue = computed(() => {
48
+ const numberValue = Number(props.value);
49
+ return numberValue && numberValue > 0 ? (numberValue > props.max ? `${props.max}+` : numberValue) : '';
50
+ });
48
51
  </script>
49
52
 
50
53
  <style lang="scss" module>
51
- @use '../../styles/index' as *;
54
+ @use '../../styles/utils' as *;
55
+ @use './badge' as *;
52
56
 
53
57
  // 定义外部变量
54
- $component-name: 'badge';
55
- $component-vars: $badge;
56
58
  %external-vars {
57
- @include UTILS__DEFINE_COMPONENT_VARS();
59
+ @include UTILS__DEFINE_COMPONENT_VARS($badge, 'badge');
58
60
  }
59
61
 
62
+ $__translate: UTILS__LOCAL_VAR(translate);
63
+ $__font-size: UTILS__LOCAL_VAR(font-size);
64
+ $__height: UTILS__LOCAL_VAR(height);
65
+ $__border: UTILS__LOCAL_VAR(border);
66
+ $__color: UTILS__LOCAL_VAR(color);
67
+ $__background: UTILS__LOCAL_VAR(background);
68
+
60
69
  .Badge {
61
70
  @extend %external-vars;
62
71
 
@@ -65,7 +74,7 @@ $component-vars: $badge;
65
74
  width: fit-content;
66
75
 
67
76
  .Badge--box {
68
- --padding-x: calc(#{UTILS__LOCAL_VAR(font-size)} / 2);
77
+ --padding-x: calc(#{$__font-size} / 2);
69
78
 
70
79
  position: absolute;
71
80
  top: 0;
@@ -74,15 +83,15 @@ $component-vars: $badge;
74
83
  padding: 0 var(--padding-x);
75
84
  box-sizing: content-box;
76
85
  text-align: center;
77
- min-width: calc(#{UTILS__LOCAL_VAR(height)} - 2 * var(--padding-x));
78
- height: UTILS__LOCAL_VAR(height);
79
- line-height: UTILS__LOCAL_VAR(height);
80
- font-size: UTILS__LOCAL_VAR(font-size);
81
- border: UTILS__LOCAL_VAR(border);
82
- border-radius: UTILS__LOCAL_VAR(height);
83
- translate: UTILS__LOCAL_VAR(translate);
84
- color: UTILS__LOCAL_VAR(color);
85
- background: UTILS__LOCAL_VAR(background);
86
+ min-width: calc(#{$__height} - 2 * var(--padding-x));
87
+ height: $__height;
88
+ line-height: $__height;
89
+ font-size: $__font-size;
90
+ border: $__border;
91
+ border-radius: $__height;
92
+ translate: $__translate;
93
+ color: $__color;
94
+ background: $__background;
86
95
  }
87
96
  }
88
97
  </style>
@@ -0,0 +1,15 @@
1
+ @use 'sass:map';
2
+
3
+ // 可配置的变量
4
+ $button: () !default;
5
+ $button-default: (
6
+ // 按钮主题颜色,默认取值组件 props 中的 type
7
+ theme: var(--theme-from-prop),
8
+ // 按钮文本颜色
9
+ text-color: #fff,
10
+ // 按钮激活态遮罩颜色
11
+ active-mask: #ffffff,
12
+ // plain 按钮的边框宽度
13
+ border-width: 3rpx
14
+ );
15
+ $button: map.merge($button-default, $button);