@cloudbase/weda-ui 0.2.6 → 0.2.10

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 (158) hide show
  1. package/package.json +3 -4
  2. package/src/configs/components/container.json +2 -1
  3. package/src/configs/components/form/input.json +6 -0
  4. package/src/configs/components/form/richText.json +2 -1
  5. package/src/configs/components/form/uploader.json +4 -5
  6. package/src/configs/components/image.json +2 -1
  7. package/src/configs/components/link.json +2 -1
  8. package/src/configs/components/richtextview.json +2 -1
  9. package/src/configs/components/scrollVeiw.json +2 -1
  10. package/src/configs/components/swiper.json +2 -1
  11. package/src/configs/components/tabs.json +31 -86
  12. package/src/configs/components/text.json +2 -1
  13. package/src/configs/index.js +4 -7
  14. package/src/mp/components/form/input/index.js +5 -1
  15. package/src/mp/components/form/input/index.wxml +2 -1
  16. package/src/mp/components/form/select/index.js +2 -2
  17. package/src/mp/components/form/textarea/index.wxml +1 -0
  18. package/src/mp/components/form/uploader/index.js +48 -14
  19. package/src/mp/components/form/uploader/index.wxml +9 -2
  20. package/src/mp/components/image/index.js +57 -8
  21. package/src/mp/components/image/index.json +4 -1
  22. package/src/mp/components/image/index.wxml +4 -2
  23. package/src/mp/components/image/index.wxss +14 -0
  24. package/src/mp/components/richText/index.wxml +1 -1
  25. package/src/mp/components/tabs/index.js +14 -1
  26. package/src/mp/utils/deepEqual.js +42 -0
  27. package/src/web/components/form/enumSelect/MultipleSelect.jsx +94 -0
  28. package/src/web/components/form/enumSelect/NormalSelect.jsx +105 -0
  29. package/src/web/components/form/enumSelect/SelectContainer.jsx +43 -0
  30. package/src/web/components/form/enumSelect/hooks/index.js +49 -0
  31. package/src/web/components/form/enumSelect/index.jsx +9 -0
  32. package/src/web/components/form/enumSelect/props/defaultProps.js +39 -0
  33. package/src/web/components/form/enumSelect/props/propsTypes.js +50 -0
  34. package/src/web/components/form/input/index.jsx +14 -10
  35. package/src/web/components/form/radio/index.jsx +1 -1
  36. package/src/web/components/form/select/h5.jsx +1 -1
  37. package/src/web/components/form/select/region/{cities.json → cities.js} +2 -2
  38. package/src/web/components/form/select/region/index.js +3 -3
  39. package/src/web/components/form/select/region/{provinces.json → provinces.js} +2 -2
  40. package/src/web/components/form/select/region/{regions.json → regions.js} +2 -2
  41. package/src/web/components/form/switch/index.jsx +1 -0
  42. package/src/web/components/form/uploader/index.css +15 -0
  43. package/src/web/components/form/uploader/index.jsx +2 -2
  44. package/src/web/components/form/uploader/uploader.h5.jsx +237 -0
  45. package/src/web/components/form/uploader/{uploaderPc.jsx → uploader.pc.jsx} +69 -59
  46. package/src/web/components/image/image.jsx +79 -5
  47. package/src/web/components/image/index.css +17 -0
  48. package/src/web/components/image/index.jsx +1 -0
  49. package/src/web/components/index.js +1 -1
  50. package/src/web/components/link/test/__snapshots__/storybook.test.js.snap +754 -0
  51. package/src/web/components/modal/index.jsx +3 -2
  52. package/src/web/components/richTextView/index.css +0 -10
  53. package/src/web/components/richTextView/index.jsx +1 -12
  54. package/src/web/components/tabs/index.jsx +3 -3
  55. package/src/web/components/tabs/{tabsH5.jsx → tabs.h5.jsx} +9 -47
  56. package/src/web/components/tabs/{tabsPc.jsx → tabs.pc.jsx} +13 -47
  57. package/src/web/components/uploaderView/index.jsx +1 -1
  58. package/src/web/utils/tcb.js +8 -0
  59. package/CHANGELOG.md +0 -240
  60. package/src/.DS_Store +0 -0
  61. package/src/configs/components/markdown.json +0 -17
  62. package/src/mp/.gitignore +0 -10
  63. package/src/mp/components/markdown/index.js +0 -27
  64. package/src/mp/components/markdown/index.json +0 -6
  65. package/src/mp/components/markdown/index.wxml +0 -1
  66. package/src/mp/components/markdown/towxml/audio-player/Audio.js +0 -99
  67. package/src/mp/components/markdown/towxml/audio-player/audio-player.js +0 -102
  68. package/src/mp/components/markdown/towxml/audio-player/audio-player.json +0 -5
  69. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxml +0 -14
  70. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxss +0 -175
  71. package/src/mp/components/markdown/towxml/audio-player/loading.svg +0 -1
  72. package/src/mp/components/markdown/towxml/config.js +0 -285
  73. package/src/mp/components/markdown/towxml/decode.js +0 -26
  74. package/src/mp/components/markdown/towxml/decode.json +0 -12
  75. package/src/mp/components/markdown/towxml/decode.wxml +0 -1
  76. package/src/mp/components/markdown/towxml/decode.wxss +0 -0
  77. package/src/mp/components/markdown/towxml/img/img.js +0 -98
  78. package/src/mp/components/markdown/towxml/img/img.json +0 -3
  79. package/src/mp/components/markdown/towxml/img/img.wxml +0 -1
  80. package/src/mp/components/markdown/towxml/img/img.wxss +0 -0
  81. package/src/mp/components/markdown/towxml/index.js +0 -19
  82. package/src/mp/components/markdown/towxml/latex/latex.js +0 -53
  83. package/src/mp/components/markdown/towxml/latex/latex.json +0 -5
  84. package/src/mp/components/markdown/towxml/latex/latex.wxml +0 -1
  85. package/src/mp/components/markdown/towxml/latex/latex.wxss +0 -0
  86. package/src/mp/components/markdown/towxml/parse/highlight/highlight.js +0 -729
  87. package/src/mp/components/markdown/towxml/parse/highlight/index.js +0 -7
  88. package/src/mp/components/markdown/towxml/parse/highlight/languages/bash.js +0 -91
  89. package/src/mp/components/markdown/towxml/parse/highlight/languages/c-like.js +0 -244
  90. package/src/mp/components/markdown/towxml/parse/highlight/languages/c.js +0 -20
  91. package/src/mp/components/markdown/towxml/parse/highlight/languages/css.js +0 -138
  92. package/src/mp/components/markdown/towxml/parse/highlight/languages/dart.js +0 -135
  93. package/src/mp/components/markdown/towxml/parse/highlight/languages/go.js +0 -57
  94. package/src/mp/components/markdown/towxml/parse/highlight/languages/htmlbars.js +0 -79
  95. package/src/mp/components/markdown/towxml/parse/highlight/languages/java.js +0 -126
  96. package/src/mp/components/markdown/towxml/parse/highlight/languages/javascript.js +0 -263
  97. package/src/mp/components/markdown/towxml/parse/highlight/languages/json.js +0 -51
  98. package/src/mp/components/markdown/towxml/parse/highlight/languages/less.js +0 -177
  99. package/src/mp/components/markdown/towxml/parse/highlight/languages/nginx.js +0 -103
  100. package/src/mp/components/markdown/towxml/parse/highlight/languages/php.js +0 -152
  101. package/src/mp/components/markdown/towxml/parse/highlight/languages/python-repl.js +0 -27
  102. package/src/mp/components/markdown/towxml/parse/highlight/languages/python.js +0 -146
  103. package/src/mp/components/markdown/towxml/parse/highlight/languages/scss.js +0 -137
  104. package/src/mp/components/markdown/towxml/parse/highlight/languages/shell.js +0 -23
  105. package/src/mp/components/markdown/towxml/parse/highlight/languages/typescript.js +0 -198
  106. package/src/mp/components/markdown/towxml/parse/highlight/languages/xml.js +0 -143
  107. package/src/mp/components/markdown/towxml/parse/highlight/style/github.wxss +0 -99
  108. package/src/mp/components/markdown/towxml/parse/highlight/style/monokai.wxss +0 -70
  109. package/src/mp/components/markdown/towxml/parse/index.js +0 -106
  110. package/src/mp/components/markdown/towxml/parse/markdown/index.js +0 -53
  111. package/src/mp/components/markdown/towxml/parse/markdown/markdown.js +0 -5834
  112. package/src/mp/components/markdown/towxml/parse/markdown/plugins/emoji.js +0 -1773
  113. package/src/mp/components/markdown/towxml/parse/markdown/plugins/ins.js +0 -120
  114. package/src/mp/components/markdown/towxml/parse/markdown/plugins/latex.js +0 -193
  115. package/src/mp/components/markdown/towxml/parse/markdown/plugins/mark.js +0 -120
  116. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sub.js +0 -95
  117. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sup.js +0 -95
  118. package/src/mp/components/markdown/towxml/parse/markdown/plugins/todo.js +0 -220
  119. package/src/mp/components/markdown/towxml/parse/markdown/plugins/yuml.js +0 -18
  120. package/src/mp/components/markdown/towxml/parse/parse2/Parser.js +0 -263
  121. package/src/mp/components/markdown/towxml/parse/parse2/Tokenizer.js +0 -507
  122. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/index.js +0 -104
  123. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/node.js +0 -169
  124. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode.js +0 -54
  125. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode_codepoint.js +0 -19
  126. package/src/mp/components/markdown/towxml/parse/parse2/entities/encode.js +0 -54
  127. package/src/mp/components/markdown/towxml/parse/parse2/entities/index.js +0 -30
  128. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/decode.js +0 -31
  129. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/entities.js +0 -2128
  130. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/legacy.js +0 -109
  131. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/xml.js +0 -2
  132. package/src/mp/components/markdown/towxml/parse/parse2/index.js +0 -8
  133. package/src/mp/components/markdown/towxml/style/main.wxss +0 -378
  134. package/src/mp/components/markdown/towxml/style/theme/dark.wxss +0 -73
  135. package/src/mp/components/markdown/towxml/style/theme/light.wxss +0 -63
  136. package/src/mp/components/markdown/towxml/table/table.js +0 -11
  137. package/src/mp/components/markdown/towxml/table/table.json +0 -6
  138. package/src/mp/components/markdown/towxml/table/table.wxml +0 -24
  139. package/src/mp/components/markdown/towxml/table/table.wxss +0 -0
  140. package/src/mp/components/markdown/towxml/todogroup/todogroup.js +0 -19
  141. package/src/mp/components/markdown/towxml/todogroup/todogroup.json +0 -6
  142. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxml +0 -13
  143. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxss +0 -3
  144. package/src/mp/components/markdown/towxml/towxml.js +0 -17
  145. package/src/mp/components/markdown/towxml/towxml.json +0 -6
  146. package/src/mp/components/markdown/towxml/towxml.wxml +0 -5
  147. package/src/mp/components/markdown/towxml/towxml.wxss +0 -8
  148. package/src/mp/components/markdown/towxml/yuml/yuml.js +0 -51
  149. package/src/mp/components/markdown/towxml/yuml/yuml.json +0 -5
  150. package/src/mp/components/markdown/towxml/yuml/yuml.wxml +0 -5
  151. package/src/mp/components/markdown/towxml/yuml/yuml.wxss +0 -0
  152. package/src/web/.DS_Store +0 -0
  153. package/src/web/components/form/uploader/uploaderH5.jsx +0 -208
  154. package/src/web/components/markdown/index.jsx +0 -40
  155. package/src/web/wedatheme/.git +0 -1
  156. package/src/web/wedatheme/.gitignore +0 -5
  157. package/src/web/wedatheme/.npmrc +0 -1
  158. package/src/web/wedatheme/package-lock.json +0 -14335
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "0.2.6",
3
+ "version": "0.2.10",
4
4
  "main": "./src/index.js",
5
5
  "module": "./src/index",
6
6
  "miniprogram": "mpdist",
@@ -36,6 +36,7 @@
36
36
  "description": "腾讯云微搭低代码组件库模板",
37
37
  "dependencies": {
38
38
  "@cloudbase/ui-react": "^1.0.4",
39
+ "@use-gesture/react": "^10.1.4",
39
40
  "braft-editor": "^2.3.9",
40
41
  "braft-utils": "^3.0.12",
41
42
  "dayjs": "^1.10.6",
@@ -44,10 +45,8 @@
44
45
  "object.fromentries": "^2.0.4",
45
46
  "prop-types": "^15.7.2",
46
47
  "react-easy-swipe": "^0.0.21",
47
- "react-markdown": "^5.0.3",
48
- "react-syntax-highlighter": "^15.4.3",
49
48
  "react-use": "^15.3.4",
50
- "tea-component": "^2.6.22",
49
+ "tea-component": "^2.7.3",
51
50
  "uuid": "8.3.2",
52
51
  "weui": "^2.4.4",
53
52
  "weui.js": "1.2.2"
@@ -41,6 +41,7 @@
41
41
  "title": "普通容器",
42
42
  "category": "布局容器",
43
43
  "description": "通用块状容器",
44
- "componentOrder": 1000
44
+ "componentOrder": 1000,
45
+ "icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/Container.svg"
45
46
  }
46
47
  }
@@ -115,6 +115,12 @@
115
115
  }
116
116
  ],
117
117
  "x-platforms": ["PCWEB"]
118
+ },
119
+ "clearable": {
120
+ "type": "boolean",
121
+ "default": true,
122
+ "title": "是否显示清空按钮",
123
+ "x-platforms": ["MOBILEWEB", "MP"]
118
124
  }
119
125
  }
120
126
  },
@@ -113,7 +113,8 @@
113
113
  "meta": {
114
114
  "title": "富文本",
115
115
  "description": "富文本编辑器",
116
- "category": "表单"
116
+ "category": "表单",
117
+ "icon": "//main.qcloudimg.com/raw/adc8cd1b6eb93c0f890ca2322e509a6b/RichText.svg"
117
118
  },
118
119
  "events": [
119
120
  {
@@ -8,7 +8,7 @@
8
8
  "default": ["image/*"],
9
9
  "x-category": "基础属性",
10
10
  "x-index": 6,
11
- "x-platforms": ["PCWEB"],
11
+ "x-platforms": ["WEB"],
12
12
  "items": {
13
13
  "type": "string",
14
14
  "enum": [
@@ -66,8 +66,7 @@
66
66
  "default": 10,
67
67
  "title": "单张大小(M)",
68
68
  "x-category": "基础属性",
69
- "x-index": 5,
70
- "x-platforms": ["PCWEB"]
69
+ "x-index": 5
71
70
  },
72
71
  "maxUploadCount": {
73
72
  "type": "number",
@@ -106,7 +105,6 @@
106
105
  },
107
106
  "single": {
108
107
  "type": "boolean",
109
- "default": false,
110
108
  "title": "是否返回单张图片",
111
109
  "x-category": "基础属性"
112
110
  },
@@ -137,6 +135,7 @@
137
135
  "meta": {
138
136
  "title": "上传图片",
139
137
  "description": "上传图片组件",
140
- "category": "表单"
138
+ "category": "表单",
139
+ "icon": "//main.qcloudimg.com/raw/f781e6bc48efa1cf926fc768fceeab5e/Uploader.svg"
141
140
  }
142
141
  }
@@ -145,6 +145,7 @@
145
145
  "meta": {
146
146
  "title": "图片",
147
147
  "description": "图片组件",
148
- "category": "多媒体"
148
+ "category": "多媒体",
149
+ "icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/Image.svg"
149
150
  }
150
151
  }
@@ -53,7 +53,8 @@
53
53
  "title": "链接",
54
54
  "description": "",
55
55
  "category": "文本",
56
- "componentOrder": 10
56
+ "componentOrder": 10,
57
+ "icon": "//main.qcloudimg.com/raw/eb8a45dc259eb4925d89ac88be1ecdd9/Link.svg"
57
58
  },
58
59
  "events": [
59
60
  {
@@ -16,6 +16,7 @@
16
16
  "title": "富文本展示",
17
17
  "description": "富文本展示",
18
18
  "category": "文本",
19
- "componentOrder": 0
19
+ "componentOrder": 0,
20
+ "icon": "//main.qcloudimg.com/raw/9c42d779f51105715a032d139344c508/RichTextView.svg"
20
21
  }
21
22
  }
@@ -209,7 +209,8 @@
209
209
  "title": "滚动容器",
210
210
  "description": "滚动容器",
211
211
  "category": "布局容器",
212
- "componentOrder": 80
212
+ "componentOrder": 80,
213
+ "icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/ScrollView.svg"
213
214
  },
214
215
  "isContainer": true,
215
216
  "mpOrigin": "scroll-view"
@@ -70,7 +70,8 @@
70
70
  "title": "轮播",
71
71
  "description": "轮播图组件",
72
72
  "category": "展示",
73
- "componentOrder": 80
73
+ "componentOrder": 80,
74
+ "icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/Swiper.svg"
74
75
  },
75
76
  "isContainer": true,
76
77
  "mpOrigin": "swiper"
@@ -3,7 +3,10 @@
3
3
  "data": {
4
4
  "properties": {
5
5
  "tabs": {
6
- "title": "选项卡数据",
6
+ "title": "选项卡标签",
7
+ "x-props": {
8
+ "data-hidebind": true
9
+ },
7
10
  "x-index":1,
8
11
  "type": "array",
9
12
  "maxLength": 20,
@@ -21,98 +24,39 @@
21
24
  "items": {
22
25
  "type": "object",
23
26
  "properties": {
24
- "name": {
25
- "title": "序号",
26
- "type": "string",
27
- "default": "name"
28
- },
29
27
  "title": {
30
28
  "title": "标题",
31
29
  "type": "string",
32
30
  "default": "标题"
33
31
  }
34
32
  }
35
- }
36
- },
37
- "panel1": {
38
- "title": "面板1",
39
- "type": "slot"
40
- },
41
- "panel2": {
42
- "title": "面板2",
43
- "type": "slot"
44
- },
45
- "panel3": {
46
- "title": "面板3",
47
- "type": "slot"
48
- },
49
- "panel4": {
50
- "title": "面板4",
51
- "type": "slot"
52
- },
53
- "panel5": {
54
- "title": "面板5",
55
- "type": "slot"
56
- },
57
- "panel6": {
58
- "title": "面板6",
59
- "type": "slot"
60
- },
61
- "panel7": {
62
- "title": "面板7",
63
- "type": "slot"
64
- },
65
- "panel8": {
66
- "title": "面板8",
67
- "type": "slot"
68
- },
69
- "panel9": {
70
- "title": "面板9",
71
- "type": "slot"
72
- },
73
- "panel10": {
74
- "title": "面板10",
75
- "type": "slot"
76
- },
77
- "panel11": {
78
- "title": "面板11",
79
- "type": "slot"
80
- },
81
- "panel12": {
82
- "title": "面板12",
83
- "type": "slot"
84
- },
85
- "panel13": {
86
- "title": "面板13",
87
- "type": "slot"
88
- },
89
- "panel14": {
90
- "title": "面板14",
91
- "type": "slot"
92
- },
93
- "panel15": {
94
- "title": "面板15",
95
- "type": "slot"
96
- },
97
- "panel16": {
98
- "title": "面板16",
99
- "type": "slot"
100
- },
101
- "panel17": {
102
- "title": "面板17",
103
- "type": "slot"
104
- },
105
- "panel18": {
106
- "title": "面板18",
107
- "type": "slot"
33
+ },
34
+ "x-linkages": [
35
+ {
36
+ "target": "selectedIndex",
37
+ "type": "value:schema",
38
+ "schema": {
39
+ "x-component-props": {
40
+ "options": "{{ $value.map((title, index) => ({label: '选项' + (index + 1), value: index}) ) }}"
41
+ }
42
+ }
43
+ }
44
+ ]
108
45
  },
109
- "panel19": {
110
- "title": "面板19",
111
- "type": "slot"
46
+ "selectedIndex": {
47
+ "title": "选中标签",
48
+ "type": "number",
49
+ "default": 0,
50
+ "x-category": "基础属性",
51
+ "x-component": "select"
112
52
  },
113
- "panel20": {
114
- "title": "面板20",
115
- "type": "slot"
53
+ "panel": {
54
+ "title": "面板1",
55
+ "type": "slot",
56
+ "x-auto-num": {
57
+ "from": 1,
58
+ "to": "{{ $form.values.tabs.length }}"
59
+ }
116
60
  }
117
61
  }
118
62
  },
@@ -126,6 +70,7 @@
126
70
  "name": "Tabs",
127
71
  "title": "选项卡",
128
72
  "description": "选项卡组件",
129
- "category": "展示"
73
+ "category": "展示",
74
+ "icon": "//qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_files/static/comp/icons/Tabs.svg"
130
75
  }
131
76
  }
@@ -41,6 +41,7 @@
41
41
  "title": "文本",
42
42
  "description": "文本内容",
43
43
  "category": "文本",
44
- "componentOrder": 100
44
+ "componentOrder": 100,
45
+ "icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/Text.svg"
45
46
  }
46
47
  }
@@ -1,7 +1,6 @@
1
- import Button from './components/button';
2
- import Markdown from './components/markdown';
3
- import Text from './components/text';
4
- import Container from './components/container';
1
+ import Button from './components/button.json';
2
+ import Text from './components/text.json';
3
+ import Container from './components/container.json';
5
4
  import Image from './components/image.json';
6
5
  import Link from './components/link.json';
7
6
  // import Picker from './components/picker/picker.json';
@@ -32,7 +31,6 @@ import showModal from './actions/showModal';
32
31
 
33
32
  export const components = {
34
33
  Button,
35
- Markdown,
36
34
  Text,
37
35
  Container,
38
36
  Image,
@@ -59,8 +57,7 @@ export const components = {
59
57
  RichTextView,
60
58
  Link,
61
59
  Drawer,
62
- Tabs
63
-
60
+ Tabs,
64
61
  };
65
62
 
66
63
  export const actions = {
@@ -55,6 +55,10 @@ Component({
55
55
  type: Boolean,
56
56
  value: false,
57
57
  },
58
+ clearable: {
59
+ type: Boolean,
60
+ value: true
61
+ }
58
62
  },
59
63
  data: {
60
64
  isFlex: true,
@@ -70,7 +74,7 @@ Component({
70
74
  },
71
75
  },
72
76
  observers: {
73
- defaultValue: function (defaultValue) {
77
+ 'defaultValue': function (defaultValue) {
74
78
  this.setData({ value: defaultValue });
75
79
  },
76
80
  },
@@ -21,8 +21,9 @@
21
21
  bindfocus="handleFocus"
22
22
  bindblur="handleBlur"
23
23
  bindconfirm="handleConfirm"
24
+ maxlength="{{maxLength}}"
24
25
  />
25
- <view class="weui-btn_reset weui-btn_icon weui-btn_input-clear" bindtap="handleClear">
26
+ <view wx:if="{{clearable}}" class="weui-btn_reset weui-btn_icon weui-btn_input-clear" bindtap="handleClear">
26
27
  <i class="weui-icon-clear" />
27
28
  </view>
28
29
  </view>
@@ -265,7 +265,7 @@ Component({
265
265
  const regexp = time.match(/^(\d{2}):(\d{2})$/);
266
266
  if (regexp && regexp[1] < 24 && regexp[2] < 60) {
267
267
  return dayjs().hour(regexp[1]).minute(regexp[2]);
268
- } else if (typeof time === 'string' && /^[0-9]*$/.test(time)) {
268
+ } else if (typeof time === 'string' && /^-?[0-9]*$/.test(time)) {
269
269
  const timeSnap = Number(time);
270
270
  let day;
271
271
  try {
@@ -281,7 +281,7 @@ Component({
281
281
  }
282
282
  },
283
283
  converDate2Dayjs(date) {
284
- if (typeof date === 'string' && /^[0-9]*$/.test(date)) {
284
+ if (typeof date === 'string' && /^-?[0-9]*$/.test(date)) {
285
285
  return dayjs(Number(date));
286
286
  }
287
287
  return dayjs(date);
@@ -14,6 +14,7 @@
14
14
  placeholder-class="weui-input__placeholder"
15
15
  bindinput="handleChange"
16
16
  value="{{value}}"
17
+ maxlength="{{maxLength}}"
17
18
  ></textarea>
18
19
  <view wx:if="{{counterVisible}}" class="weui-textarea-counter"><span>{{!!value ? value.length : 0}}</span>/{{maxLength}}</view>
19
20
  </view>
@@ -1,4 +1,5 @@
1
1
  import { getCloudInstance } from '../../../utils/tcb';
2
+ import deepEqual from '../../../utils/deepEqual';
2
3
 
3
4
  Component({
4
5
  options: {
@@ -7,7 +8,8 @@ Component({
7
8
  lifetimes: {
8
9
  attached() {
9
10
  this.setData({
10
- urls: this.properties.defaultValue
11
+ urls: this.properties.defaultValue,
12
+ files: this.properties.defaultValue.map(url => ({url}))
11
13
  });
12
14
  }
13
15
  },
@@ -31,12 +33,21 @@ Component({
31
33
  defaultValue: {
32
34
  type: Array,
33
35
  value: []
36
+ },
37
+ single: {
38
+ type: Boolean,
39
+ value: false
40
+ },
41
+ maxSize: {
42
+ type: Number,
43
+ value: 10
34
44
  }
35
45
  },
36
46
  data: {
47
+ maxCount: 0,
37
48
  files: [],
38
49
  urls: [],
39
- uploadFile: async (files) => {
50
+ uploadFile: async function (files) {
40
51
  // 文件上传的函数,返回一个promise
41
52
  const uploadPath = 'weda-uploader';
42
53
 
@@ -51,8 +62,11 @@ Component({
51
62
  return { fileID: uploadRes.fileID };
52
63
  });
53
64
  const uploadFileList = await Promise.all(uploadPromise);
54
- const urls = uploadFileList.map((file) => file.fileID);
55
- return { urls, tempUrls: files.tempFilePaths };
65
+ const cloudUrls = uploadFileList.map((file) => file.fileID);
66
+ // 这里返回的东西会在uploadSuccess回调函数中获取到
67
+ // https://github.com/wechat-miniprogram/weui-miniprogram/blob/a3630575910302e3b94e69fcef266d2b509de650/src/components/uploader/uploader.ts#L149
68
+ // 写死的从返回值的 .urls 获取展示用的url来用。一定要将tempFilePaths透传下去,否则会重新加载然后出现闪白
69
+ return { urls: files.tempFilePaths, cloudUrls };
56
70
  }
57
71
  },
58
72
  methods: {
@@ -61,7 +75,7 @@ Component({
61
75
  this.triggerEvent('error', e.detail);
62
76
  },
63
77
  uploadSuccess: async function (e) {
64
- const urls = e.detail.urls; // uploadFile 获取返回值
78
+ const urls = e.detail.cloudUrls; // uploadFile 获取返回值
65
79
  // 小程序自带tempURL 不需要调用 tcb.getTempFileURL 获取
66
80
  this.triggerEvent(
67
81
  'success',
@@ -70,22 +84,42 @@ Component({
70
84
  }
71
85
  );
72
86
  this.setData({
73
- files: this.data.files.concat(e.detail.tempUrls.map(url => ({url}))),
87
+ files: this.data.files.concat(e.detail.urls.map(url => ({url}))),
74
88
  urls: [...this.data.urls, ...urls]
75
89
  });
76
90
 
77
91
  },
92
+ onDelete: function(e) {
93
+ this.setData({
94
+ files: this.data.files.filter((v, index) => e.detail.index !== index),
95
+ urls: this.data.urls.filter((v, index) => e.detail.index !== index)
96
+ });
97
+ }
78
98
  },
79
99
  observers: {
80
- 'defaultValue': function(value) {
81
- // change value
82
- if(!value || value.length === 0) {
83
- this.setData({files: []});
84
- this.setData({urls: []});
85
- }
100
+ // 'defaultValue': function(value) {
101
+ // if(!deepEqual(value, this.data.urls)) {
102
+ // if(!Array.isArray(value)) {
103
+ // value = [value].filter(v => v.length > 0);
104
+ // }
105
+ // this.setData({
106
+ // files: value.map(f => ({url: f})),
107
+ // urls: value
108
+ // });
109
+ // }
110
+ // },
111
+ 'maxUploadCount, single': function(maxUploadCount, single) {
112
+ const maxCount = single ? 1 : maxUploadCount;
113
+ this.setData({
114
+ maxCount
115
+ });
86
116
  },
87
117
  'urls': function (urls) {
88
- this.triggerEvent('change', {value: urls});
118
+ let value = urls;
119
+ if(this.properties.single) {
120
+ value = urls[0] ?? '';
121
+ }
122
+ this.triggerEvent('change', {value});
89
123
  }
90
124
  }
91
- });
125
+ });
@@ -1,8 +1,15 @@
1
1
  <mp-cells>
2
2
  <mp-cell>
3
- <mp-uploader files="{{files}}" showDelete="{{false}}" ext-class="{{layout}}" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uploadFile}}" maxCount="{{maxUploadCount}}" title="{{title}}" tips="{{tips}}"></mp-uploader>
3
+ <mp-uploader max-size="{{maxSize * 1024 * 1024}}" files="{{files}}" showDelete="{{true}}" ext-class="{{layout}}" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uploadFile}}" maxCount="{{maxCount}}" title="{{title}}" tips="{{tips}}" binddelete="onDelete"></mp-uploader>
4
4
  </mp-cell>
5
5
  </mp-cells>
6
6
  <!-- uploader delete 实际代码接受 showDelete
7
7
  https://developers.weixin.qq.com/community/develop/doc/000a4e7b9cc158c110aa3961056400
8
- -->
8
+ -->
9
+
10
+ <!-- bind开头的是事件handler,wxml模版中不能带 `{{}}`
11
+ ```
12
+ <mp-uploader files="{{files}}" showDelete="{{true}}" ext-class="{{layout}}" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uploadFile}}" maxCount="{{maxUploadCount}}" title="{{title}}" tips="{{tips}}" binddelete="onDelete"></mp-uploader>
13
+ ```
14
+ upload 是函数带{{}}, bindtelete直接传函数名字符串
15
+ -->
@@ -1,5 +1,3 @@
1
- import handleEvents from '../../utils/handleEvents';
2
-
3
1
  Component({
4
2
  options: {
5
3
  virtualHost: true,
@@ -48,17 +46,55 @@ Component({
48
46
  }
49
47
  },
50
48
  methods: {
51
- ...handleEvents([
52
- { name: 'load', title: '加载成功' },
53
- { name: 'error', title: '加载失败' },
54
- ]),
49
+ load: function(e) {
50
+ this.triggerEvent('error', e.detail);
51
+ this.setData({
52
+ realHeight: e.detail.height,
53
+ realWidth: e.detail.width
54
+ });
55
+ },
56
+ error: function(e) {
57
+ this.setData({
58
+ isError: true,
59
+ clsx: this.properties.className + 'weda-image-error'
60
+ });
61
+ this.triggerEvent('error', e.detail);
62
+ },
55
63
  onImgTap: function() {
56
- if(this.properties.imgPreview) {
64
+ if(this.properties.imgPreview && !this.data.isError) {
65
+ // 计算图片预览展示高度
66
+ const {windowWidth, windowHeight} = wx.getSystemInfoSync();
67
+ const showHeight = windowWidth / (this.data.realWidth / this.data.realHeight);
68
+ const offsetHeight = windowHeight / 2 - (showHeight / 2);
57
69
  this.setData({
58
- showImg: true
70
+ showImg: true,
71
+ zoom: 1,
72
+ previewTranslateY: 0,
73
+ previewTranslateX: 0,
74
+ showHeight,
75
+ offsetHeight
59
76
  });
60
77
  }
61
78
  },
79
+ onPinch: function(ev) {
80
+ let zoom = ev.detail.zoom;
81
+ // zoom = this.data.zoom * zoom;
82
+ if(zoom > 5) {
83
+ zoom = 5;
84
+ }
85
+ if(zoom < 0.6) {
86
+ zoom = 0.6;
87
+ }
88
+ this.setData({
89
+ zoom
90
+ });
91
+ },
92
+ onPressMove: function(ev) {
93
+ this.setData({
94
+ previewTranslateX: this.data.previewTranslateX + ev.detail.deltaX,
95
+ previewTranslateY: this.data.previewTranslateY + ev.detail.deltaY
96
+ });
97
+ },
62
98
  onMaskClick: function() {
63
99
  if(this.properties.maskClosable) {
64
100
  this.setData({
@@ -76,8 +112,21 @@ Component({
76
112
  showImg: false,
77
113
  realSrc: '',
78
114
  imgMode: 'scaleToFill',
115
+ clsx: '',
116
+ isError: false,
117
+ zoom: 1,
118
+ previewTranslateX: 0,
119
+ previewTranslateY: 0,
120
+ realHeight: 0,
121
+ realWidth: 0
79
122
  },
80
123
  observers: {
124
+ className: function() {
125
+ const className = this.properties.className;
126
+ this.setData({
127
+ clsx: className
128
+ });
129
+ },
81
130
  src: function () {
82
131
  const { src = '' } = this.properties;
83
132
  let { app } = getApp();
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "component": true,
3
- "styleIsolation": "shared"
3
+ "styleIsolation": "shared",
4
+ "usingComponents": {
5
+ "gesture": "miniprogram-gesture/gesture"
6
+ }
4
7
  }
@@ -1,6 +1,6 @@
1
1
  <image
2
2
  style="{{style}}"
3
- class="weda-ui weda-image {{className}}"
3
+ class="weda-ui weda-image {{clsx}}"
4
4
  src="{{realSrc}}"
5
5
  alt="{{alt}}"
6
6
  mode="{{imgMode}}"
@@ -14,5 +14,7 @@
14
14
  <view bindtap="onCloseClick" class="weda-img-modal-close-btn">
15
15
  <icon type="clear" size="23" color="white"></icon>
16
16
  </view>
17
- <view class="weda-img-preview" style="background-image: url('{{realSrc}}');"></view>
17
+ <gesture bindpinch="onPinch" catchtap="onTapImgPreview" bindpressMove="onPressMove">
18
+ <view class="weda-img-preview" style="margin-top:{{offsetHeight}}px;width: 100%;height:{{showHeight}}px;background-image: url('{{realSrc}}');transform: scale({{zoom}}) translateX({{previewTranslateX}}px) translateY({{previewTranslateY}}px);"></view>
19
+ </gesture>
18
20
  </view>
@@ -30,3 +30,17 @@
30
30
  display: inline-block;
31
31
  z-index: 99;
32
32
  }
33
+
34
+ .weda-image-error {
35
+ position: relative;
36
+ }
37
+
38
+ .weda-image-error::before {
39
+ content: '';
40
+ background: #f5f5f5 url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMjUuMzIgMTYuMzU5N0MyNi4wNzY0IDE2LjM1OTcgMjYuODI1NCAxNi41MDg3IDI3LjUyNDMgMTYuNzk4MUMyOC4yMjMxIDE3LjA4NzYgMjguODU4MSAxNy41MTE5IDI5LjM5MjkgMTguMDQ2OEMyOS45Mjc4IDE4LjU4MTYgMzAuMzUyMSAxOS4yMTY2IDMwLjY0MTYgMTkuOTE1NEMzMC45MzEgMjAuNjE0MyAzMS4wOCAyMS4zNjMzIDMxLjA4IDIyLjExOTdDMzEuMDggMjIuODc2MSAzMC45MzEgMjMuNjI1MSAzMC42NDE2IDI0LjMyMzlDMzAuMzUyMSAyNS4wMjI4IDI5LjkyNzggMjUuNjU3OCAyOS4zOTI5IDI2LjE5MjZDMjguODU4MSAyNi43Mjc1IDI4LjIyMzEgMjcuMTUxOCAyNy41MjQzIDI3LjQ0MTJDMjYuODI1NCAyNy43MzA3IDI2LjA3NjQgMjcuODc5NyAyNS4zMiAyNy44Nzk3QzIzLjc5MjQgMjcuODc5NyAyMi4zMjczIDI3LjI3MjggMjEuMjQ3MSAyNi4xOTI2QzIwLjE2NjkgMjUuMTEyNCAxOS41NiAyMy42NDczIDE5LjU2IDIyLjExOTdDMTkuNTYgMjAuNTkyIDIwLjE2NjkgMTkuMTI3IDIxLjI0NzEgMTguMDQ2OEMyMi4zMjczIDE2Ljk2NjUgMjMuNzkyNCAxNi4zNTk3IDI1LjMyIDE2LjM1OTdaTTI4IDMuNTU5NjlWMTQuODc2OEMyNy4xNzc3IDE0LjU4NjYgMjYuMTkyIDE0LjQzODggMjUuMzIgMTQuNDM5N0MyNC4wMzEgMTQuNDM5NyAyMi44MTU3IDE0Ljc1NzEgMjEuNzQ4OCAxNS4zMTg0TDIwLjc5NTIgMTMuMTU5N0wxNi4wMjU5IDIwLjAyNzVMOC40NDU3NiAxNi40NDFMMy41NiAyMy4zOTk3SDE3Ljc0NjJDMTcuOTg2NyAyNC44MjkgMTguNjI4MiAyNi4xNjA2IDE5LjU5NTggMjcuMjM5N0gxVjMuNTU5NjlIMjhaTTI1Ljk2IDI0LjAzOTdIMjQuNjhWMjUuMzE5N0gyNS45NlYyNC4wMzk3Wk0yNS45NiAxOC45MTk3SDI0LjY4VjIzLjM5OTdIMjUuOTZWMTguOTE5N1pNNi4xMiAxMC41OTk3QzYuMTIgMTEuOTk4MSA3LjE5OTA0IDEzLjEwODUgOC42MDc2OCAxMy4xNTg0QzEwLjAyMDggMTMuMjA3NyAxMS4yNCAxMi4wNDggMTEuMjQgMTAuNTk5N0MxMS4yNCA5LjI0NjA5IDEwLjA2NDMgOC4wODU3NyA4Ljc1MjMyIDguMDQwOTdDNy4yOTU2OCA3Ljk5MTY5IDYuMTIgOS4xNTEzNyA2LjEyIDEwLjU5OTdaIiBmaWxsPSIjQkNDNEQwIj48L3BhdGg+Cjwvc3ZnPgo=') no-repeat center / 50% 50%;
41
+ position: absolute;
42
+ left: 0;
43
+ top: 0;
44
+ width: 100%;
45
+ height: 100%;
46
+ }