@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
package/configs/index.js CHANGED
@@ -1,42 +1,40 @@
1
+ import defaultIconfonts from '../resources/iconfont/uniapp_ui_icon/iconfont.json';
1
2
  /** 组件前缀 */
2
3
  let componentPrefix = 'app';
3
4
  /** 首页路径 */
4
5
  let homePath = '/pages/index/index';
5
-
6
6
  /**
7
7
  * 设置组件前缀
8
- * @param {string} prefix 组件前缀
8
+ * @param prefix 组件前缀
9
9
  */
10
- function setComponentPrefix(prefix) {
10
+ function setComponentPrefix(prefix = 'app') {
11
+ if (!prefix) throw new Error('组件前缀不能为空');
11
12
  componentPrefix = prefix;
12
13
  }
13
-
14
14
  /**
15
15
  * 设置首页路径
16
- * @param {string} path 首页路径
16
+ * @param path 首页路径
17
17
  */
18
- function setHomePath(path) {
18
+ function setHomePath(path = '/pages/index/index') {
19
+ if (!path) throw new Error('app 首页不能为空');
19
20
  homePath = path;
20
21
  }
21
-
22
22
  /** iconfont 图标 map */
23
23
  const iconMap = new Map();
24
-
25
24
  /**
26
25
  * 添加单个图标
27
- * @param {string} fontFamily 字体文件名
28
- * @param {string} prefix 图标前缀
29
- * @param {string} name 图标名称
26
+ * @param fontFamily 字体文件名
27
+ * @param prefix 图标前缀
28
+ * @param name 图标名称
30
29
  */
31
30
  function addIconToMap(fontFamily, prefix, name) {
32
31
  if (iconMap.has(name)) {
33
32
  // eslint-disable-next-line no-console
34
- console.error(
33
+ console.warn(
35
34
  `图标库 "${fontFamily}" 中的图标 "${name}" 在图标库 "${
36
35
  iconMap.get(name).fontFamily
37
- }" 中已存在,这个图标将被忽略`
36
+ }" 中已存在,新的图标将会覆盖已存在的同名图标`
38
37
  );
39
- return;
40
38
  }
41
39
  iconMap.set(name, {
42
40
  fontFamily,
@@ -44,14 +42,9 @@ function addIconToMap(fontFamily, prefix, name) {
44
42
  name,
45
43
  });
46
44
  }
47
-
48
45
  /**
49
46
  * 添加一组图标,传入 iconfont.json 文件内容
50
- * @param {object} iconJson iconfont.json 文件内容
51
- * @param {string} iconJson.font_family
52
- * @param {string} iconJson.css_prefix_text
53
- * @param {object[]} iconJson.glyphs
54
- * @param {string} iconJson.glyphs.font_class
47
+ * @param iconJson iconfont.json 文件内容
55
48
  */
56
49
  function addIcons(iconJson) {
57
50
  const fontFamily = iconJson.font_family;
@@ -61,8 +54,6 @@ function addIcons(iconJson) {
61
54
  addIconToMap(fontFamily, prefix, glyph.font_class);
62
55
  });
63
56
  }
64
-
65
57
  // 添加内部图标库
66
- addIcons(require('../resources/iconfont/uniapp_ui_icon/iconfont.json'));
67
-
58
+ addIcons(defaultIconfonts);
68
59
  export { componentPrefix, homePath, setComponentPrefix, setHomePath, iconMap, addIcons };
@@ -0,0 +1,82 @@
1
+ import defaultIconfonts from '../resources/iconfont/uniapp_ui_icon/iconfont.json';
2
+
3
+ /** 组件前缀 */
4
+ let componentPrefix = 'app';
5
+ /** 首页路径 */
6
+ let homePath = '/pages/index/index';
7
+
8
+ /**
9
+ * 设置组件前缀
10
+ * @param prefix 组件前缀
11
+ */
12
+ function setComponentPrefix(prefix: string = 'app') {
13
+ if (!prefix) throw new Error('组件前缀不能为空');
14
+ componentPrefix = prefix;
15
+ }
16
+
17
+ /**
18
+ * 设置首页路径
19
+ * @param path 首页路径
20
+ */
21
+ function setHomePath(path: string = '/pages/index/index') {
22
+ if (!path) throw new Error('app 首页不能为空');
23
+ homePath = path;
24
+ }
25
+
26
+ interface IconInfo {
27
+ /** 字体文件名 */
28
+ fontFamily: string;
29
+ /** 图标前缀 */
30
+ prefix: string;
31
+ /** 图标名称 */
32
+ name: string;
33
+ }
34
+
35
+ /** iconfont 图标 map */
36
+ const iconMap: Map<string, IconInfo> = new Map();
37
+
38
+ /**
39
+ * 添加单个图标
40
+ * @param fontFamily 字体文件名
41
+ * @param prefix 图标前缀
42
+ * @param name 图标名称
43
+ */
44
+ function addIconToMap(fontFamily: string, prefix: string, name: string) {
45
+ if (iconMap.has(name)) {
46
+ // eslint-disable-next-line no-console
47
+ console.warn(
48
+ `图标库 "${fontFamily}" 中的图标 "${name}" 在图标库 "${
49
+ iconMap.get(name)!.fontFamily
50
+ }" 中已存在,新的图标将会覆盖已存在的同名图标`
51
+ );
52
+ }
53
+ iconMap.set(name, {
54
+ fontFamily,
55
+ prefix,
56
+ name,
57
+ });
58
+ }
59
+
60
+ export interface IconFontJson {
61
+ font_family: string;
62
+ css_prefix_text: string;
63
+ glyphs: { font_class: string }[];
64
+ }
65
+
66
+ /**
67
+ * 添加一组图标,传入 iconfont.json 文件内容
68
+ * @param iconJson iconfont.json 文件内容
69
+ */
70
+ function addIcons(iconJson: IconFontJson) {
71
+ const fontFamily = iconJson.font_family;
72
+ const prefix = iconJson.css_prefix_text;
73
+ const glyphs = iconJson.glyphs;
74
+ glyphs.forEach((glyph) => {
75
+ addIconToMap(fontFamily, prefix, glyph.font_class);
76
+ });
77
+ }
78
+
79
+ // 添加内部图标库
80
+ addIcons(defaultIconfonts);
81
+
82
+ export { componentPrefix, homePath, setComponentPrefix, setHomePath, iconMap, addIcons };
package/easyCom.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare function componentEasyCom(componentPrefix?: string): {
2
+ easycom: {
3
+ autoscan: boolean;
4
+ custom: {
5
+ [x: string]: string;
6
+ };
7
+ };
8
+ };
9
+ export default componentEasyCom;
package/easyCom.js CHANGED
@@ -26,6 +26,5 @@ function componentEasyCom(componentPrefix = 'app') {
26
26
  },
27
27
  };
28
28
  }
29
-
30
29
  // 导出 easycom 配置
31
- module.exports = componentEasyCom;
30
+ export default componentEasyCom;
package/easyCom.ts ADDED
@@ -0,0 +1,31 @@
1
+ function componentEasyCom(componentPrefix = 'app') {
2
+ return {
3
+ easycom: {
4
+ autoscan: true,
5
+ custom: {
6
+ [`^${componentPrefix}-date-picker-view`]:
7
+ '@ecolovo/uniapp-components/components/date-picker/date-picker-view.vue',
8
+ [`^${componentPrefix}-dialog-content`]:
9
+ '@ecolovo/uniapp-components/components/dialog/dialog-content.vue',
10
+ [`^${componentPrefix}-loading-animation(.*)`]:
11
+ '@ecolovo/uniapp-components/components/loading/animations/loading-animation$1.vue',
12
+ [`^${componentPrefix}-page-(.*)`]: '@ecolovo/uniapp-components/components/page/page-$1.vue',
13
+ [`^${componentPrefix}-password-input`]:
14
+ '@ecolovo/uniapp-components/components/input/password-input.vue',
15
+ [`^${componentPrefix}-picker-popup`]: '@ecolovo/uniapp-components/components/picker/picker-popup.vue',
16
+ [`^${componentPrefix}-popover-content`]:
17
+ '@ecolovo/uniapp-components/components/popover/popover-content.vue',
18
+ [`^${componentPrefix}-popover-mask`]: '@ecolovo/uniapp-components/components/popover/popover-mask.vue',
19
+ [`^${componentPrefix}-popup-content`]: '@ecolovo/uniapp-components/components/popup/popup-content.vue',
20
+ [`^${componentPrefix}-media-uploader`]:
21
+ '@ecolovo/uniapp-components/components/uploader/media-uploader.vue',
22
+ [`^${componentPrefix}-file-uploader`]:
23
+ '@ecolovo/uniapp-components/components/uploader/file-uploader.vue',
24
+ [`^${componentPrefix}-(.*)`]: '@ecolovo/uniapp-components/components/$1/$1.vue',
25
+ },
26
+ },
27
+ };
28
+ }
29
+
30
+ // 导出 easycom 配置
31
+ export default componentEasyCom;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { default as init } from './init';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as init } from './init';
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default as init } from './init';
package/init.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { IconFontJson } from './configs';
2
-
1
+ import type { IconFontJson } from './configs';
3
2
  /** 组件库初始化配置 */
4
3
  interface InitOptions {
5
4
  /** 组件前缀 */
@@ -9,11 +8,9 @@ interface InitOptions {
9
8
  /** iconfont 图标 json 文件 */
10
9
  iconfont?: IconFontJson | IconFontJson[];
11
10
  }
12
-
13
11
  /**
14
- * 初始化组件库
15
- * @param {InitOptions} options 组件库初始化配置
12
+ * 组件库初始化方法,在使用组件库前调用
13
+ * @param options 组件库初始化配置
16
14
  */
17
- declare const init: (options: InitOptions) => void;
18
-
15
+ declare function init(options?: InitOptions): void;
19
16
  export default init;
package/init.js CHANGED
@@ -1,6 +1,8 @@
1
- const { setComponentPrefix, setHomePath, addIcons } = require('./configs');
2
-
3
- /** 组件库初始化方法,在 main.js 中调用 */
1
+ import { setComponentPrefix, setHomePath, addIcons } from './configs';
2
+ /**
3
+ * 组件库初始化方法,在使用组件库前调用
4
+ * @param options 组件库初始化配置
5
+ */
4
6
  function init(options = {}) {
5
7
  if (options.componentPrefix) {
6
8
  setComponentPrefix(options.componentPrefix);
@@ -16,5 +18,4 @@ function init(options = {}) {
16
18
  }
17
19
  }
18
20
  }
19
-
20
21
  export default init;
package/init.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { setComponentPrefix, setHomePath, addIcons } from './configs';
2
+ import type { IconFontJson } from './configs';
3
+
4
+ /** 组件库初始化配置 */
5
+ interface InitOptions {
6
+ /** 组件前缀 */
7
+ componentPrefix?: string;
8
+ /** 首页路径 */
9
+ homePath?: string;
10
+ /** iconfont 图标 json 文件 */
11
+ iconfont?: IconFontJson | IconFontJson[];
12
+ }
13
+
14
+ /**
15
+ * 组件库初始化方法,在使用组件库前调用
16
+ * @param options 组件库初始化配置
17
+ */
18
+ function init(options: InitOptions = {}) {
19
+ if (options.componentPrefix) {
20
+ setComponentPrefix(options.componentPrefix);
21
+ }
22
+ if (options.homePath) {
23
+ setHomePath(options.homePath);
24
+ }
25
+ if (options.iconfont) {
26
+ if (Array.isArray(options.iconfont)) {
27
+ options.iconfont.forEach(addIcons);
28
+ } else {
29
+ addIcons(options.iconfont);
30
+ }
31
+ }
32
+ }
33
+
34
+ export default init;
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@ecolovo/uniapp-components",
3
- "version": "1.0.10",
4
- "description": "Ecolovo UniApp 组件库",
3
+ "version": "2.0.1",
4
+ "description": "Ecolovo UniApp Vue3 组件库",
5
5
  "scripts": {
6
- "lint": "eslint . --fix"
6
+ "lint": "eslint",
7
+ "lint:fix": "eslint --fix",
8
+ "build": "tsc"
7
9
  },
8
10
  "keywords": [
9
11
  "uniapp",
@@ -12,18 +14,26 @@
12
14
  "author": "Yang",
13
15
  "license": "ISC",
14
16
  "dependencies": {
17
+ "@ecolovo/utils": "^1.0.7",
15
18
  "case-anything": "3.1.2",
16
- "lodash-es": "4.17.21"
19
+ "lodash-es": "4.17.21",
20
+ "vue": "^3.4.21"
17
21
  },
18
22
  "devDependencies": {
19
23
  "@dcloudio/types": "^3.4.30",
20
24
  "@eslint/js": "^10.0.1",
25
+ "@types/lodash-es": "^4.17.12",
26
+ "@vue/eslint-config-prettier": "^10.2.0",
27
+ "@vue/eslint-config-typescript": "^14.8.0",
28
+ "@vue/tsconfig": "^0.1.3",
21
29
  "eslint": "^10.0.3",
22
30
  "eslint-config-prettier": "^10.1.8",
23
31
  "eslint-plugin-prettier": "^5.5.5",
24
32
  "eslint-plugin-vue": "^10.8.0",
25
33
  "globals": "^17.4.0",
34
+ "miniprogram-api-typings": "^5.2.1",
26
35
  "prettier": "^2.8.8",
36
+ "typescript": "^4.9.4",
27
37
  "vue-eslint-parser": "^10.4.0"
28
38
  }
29
39
  }
@@ -4,11 +4,8 @@
4
4
  @use 'sass:string';
5
5
  @use '../var/theme' as *;
6
6
 
7
- $component-name: null !default;
8
- $component-vars: null !default;
9
-
10
7
  // 返回组件外部变量名
11
- @function UTILS__VAR_NAME($name, $component: $component-name) {
8
+ @function UTILS__VAR_NAME($name, $component) {
12
9
  @return string.unquote('--#{$component-prefix}-#{$component}--#{$name}');
13
10
  }
14
11
 
@@ -25,7 +22,7 @@ $component-vars: null !default;
25
22
  }
26
23
 
27
24
  // 返回组件外部变量值
28
- @function UTILS__VAR($name, $component: $component-name, $default: null) {
25
+ @function UTILS__VAR($name, $component, $default: null) {
29
26
  @if $default != null {
30
27
  @return var(UTILS__VAR_NAME($name, $component), $default);
31
28
  }
@@ -43,17 +40,17 @@ $component-vars: null !default;
43
40
  }
44
41
 
45
42
  // 定义组件变量
46
- @mixin UTILS__DEFINE_COMPONENT_VARS() {
47
- @if not $component-name {
48
- @error "请在调用 UTILS__DEFINE_COMPONENT_VARS 之前设置 $component-name";
43
+ @mixin UTILS__DEFINE_COMPONENT_VARS($vars, $name) {
44
+ @if not $name {
45
+ @error "请传入 $name";
49
46
  }
50
47
 
51
- @if (not $component-vars) or (meta.type-of($component-vars) != 'map') {
52
- @error "请在调用 UTILS__DEFINE_COMPONENT_VARS 之前设置 $component-vars";
48
+ @if (not $vars) or (meta.type-of($vars) != 'map') {
49
+ @error "请传入 $vars";
53
50
  }
54
51
 
55
- @each $key, $value in $component-vars {
56
- @include __DO_NOT_USE__define-component-var($key, $value);
52
+ @each $key, $value in $vars {
53
+ @include __DO_NOT_USE__define-component-var($name, $key, $value);
57
54
  }
58
55
  }
59
56
 
@@ -65,12 +62,12 @@ $component-vars: null !default;
65
62
  }
66
63
 
67
64
  // 定义单个组件变量,不要直接调用
68
- @mixin __DO_NOT_USE__define-component-var($name, $value) {
65
+ @mixin __DO_NOT_USE__define-component-var($component, $name, $value) {
69
66
  @if not $component-prefix {
70
67
  @error "请在调用 __DO_NOT_USE__define-component-var 之前设置 component-prefix";
71
68
  }
72
69
 
73
- $var-prefix: '#{$component-prefix}-#{$component-name}';
70
+ $var-prefix: '#{$component-prefix}-#{$component}';
74
71
 
75
72
  $default: false;
76
73
 
@@ -78,7 +75,7 @@ $component-vars: null !default;
78
75
  $default: true;
79
76
  }
80
77
 
81
- $var-name: UTILS__VAR_NAME($name);
78
+ $var-name: UTILS__VAR_NAME($name, $component);
82
79
  $local-name: __DO_NOT_USE__local-var-name($name);
83
80
 
84
81
  @if $default {
@@ -1,10 +1,3 @@
1
- // 单行
2
- .ellipsis {
3
- overflow-x: hidden;
4
- text-overflow: ellipsis;
5
- white-space: nowrap;
6
- }
7
-
8
1
  @mixin UTILS__ELLIPSIS($line: 1) {
9
2
  @if $line < 1 {
10
3
  @error "$line 必须为非 0 正整数";
@@ -5,6 +5,6 @@
5
5
  @use '../var/theme' as *;
6
6
  @use './css-var' as *;
7
7
 
8
- @function UTILS__z-index($key: $component-name) {
8
+ @function UTILS__z-index($key) {
9
9
  @return map.get($z-index-maps, $key);
10
10
  }