@cloudbase/weda-ui 0.2.7 → 0.2.11

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/package.json +2 -4
  2. package/src/configs/components/container.json +2 -1
  3. package/src/configs/components/form/richText.json +2 -1
  4. package/src/configs/components/form/uploader.json +4 -4
  5. package/src/configs/components/image.json +2 -1
  6. package/src/configs/components/link.json +2 -1
  7. package/src/configs/components/richtextview.json +2 -1
  8. package/src/configs/components/scrollVeiw.json +2 -1
  9. package/src/configs/components/swiper.json +2 -1
  10. package/src/configs/components/tabs.json +2 -1
  11. package/src/configs/components/text.json +2 -1
  12. package/src/configs/index.js +4 -7
  13. package/src/mp/components/form/uploader/index.js +15 -8
  14. package/src/mp/components/form/uploader/index.wxml +1 -1
  15. package/src/web/components/form/enumSelect/MultipleSelect.jsx +89 -0
  16. package/src/web/components/form/enumSelect/NormalSelect.jsx +101 -0
  17. package/src/web/components/form/enumSelect/SelectContainer.jsx +43 -0
  18. package/src/web/components/form/enumSelect/index.jsx +9 -0
  19. package/src/web/components/form/enumSelect/props/defaultProps.js +39 -0
  20. package/src/web/components/form/enumSelect/props/propsTypes.js +50 -0
  21. package/src/web/components/form/select/region/{cities.json → cities.js} +2 -2
  22. package/src/web/components/form/select/region/index.js +3 -3
  23. package/src/web/components/form/select/region/{provinces.json → provinces.js} +2 -2
  24. package/src/web/components/form/select/region/{regions.json → regions.js} +2 -2
  25. package/src/web/components/form/switch/index.jsx +1 -0
  26. package/src/web/components/form/uploader/uploader.h5.jsx +42 -16
  27. package/src/web/components/form/uploader/uploader.pc.jsx +1 -1
  28. package/src/web/components/image/image.jsx +0 -1
  29. package/src/web/components/index.js +1 -1
  30. package/src/web/components/link/test/__snapshots__/storybook.test.js.snap +754 -0
  31. package/src/web/components/modal/index.jsx +3 -2
  32. package/CHANGELOG.md +0 -240
  33. package/src/.DS_Store +0 -0
  34. package/src/configs/components/markdown.json +0 -17
  35. package/src/mp/.gitignore +0 -10
  36. package/src/mp/components/markdown/index.js +0 -27
  37. package/src/mp/components/markdown/index.json +0 -6
  38. package/src/mp/components/markdown/index.wxml +0 -1
  39. package/src/mp/components/markdown/towxml/audio-player/Audio.js +0 -99
  40. package/src/mp/components/markdown/towxml/audio-player/audio-player.js +0 -102
  41. package/src/mp/components/markdown/towxml/audio-player/audio-player.json +0 -5
  42. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxml +0 -14
  43. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxss +0 -175
  44. package/src/mp/components/markdown/towxml/audio-player/loading.svg +0 -1
  45. package/src/mp/components/markdown/towxml/config.js +0 -285
  46. package/src/mp/components/markdown/towxml/decode.js +0 -26
  47. package/src/mp/components/markdown/towxml/decode.json +0 -12
  48. package/src/mp/components/markdown/towxml/decode.wxml +0 -1
  49. package/src/mp/components/markdown/towxml/decode.wxss +0 -0
  50. package/src/mp/components/markdown/towxml/img/img.js +0 -98
  51. package/src/mp/components/markdown/towxml/img/img.json +0 -3
  52. package/src/mp/components/markdown/towxml/img/img.wxml +0 -1
  53. package/src/mp/components/markdown/towxml/img/img.wxss +0 -0
  54. package/src/mp/components/markdown/towxml/index.js +0 -19
  55. package/src/mp/components/markdown/towxml/latex/latex.js +0 -53
  56. package/src/mp/components/markdown/towxml/latex/latex.json +0 -5
  57. package/src/mp/components/markdown/towxml/latex/latex.wxml +0 -1
  58. package/src/mp/components/markdown/towxml/latex/latex.wxss +0 -0
  59. package/src/mp/components/markdown/towxml/parse/highlight/highlight.js +0 -729
  60. package/src/mp/components/markdown/towxml/parse/highlight/index.js +0 -7
  61. package/src/mp/components/markdown/towxml/parse/highlight/languages/bash.js +0 -91
  62. package/src/mp/components/markdown/towxml/parse/highlight/languages/c-like.js +0 -244
  63. package/src/mp/components/markdown/towxml/parse/highlight/languages/c.js +0 -20
  64. package/src/mp/components/markdown/towxml/parse/highlight/languages/css.js +0 -138
  65. package/src/mp/components/markdown/towxml/parse/highlight/languages/dart.js +0 -135
  66. package/src/mp/components/markdown/towxml/parse/highlight/languages/go.js +0 -57
  67. package/src/mp/components/markdown/towxml/parse/highlight/languages/htmlbars.js +0 -79
  68. package/src/mp/components/markdown/towxml/parse/highlight/languages/java.js +0 -126
  69. package/src/mp/components/markdown/towxml/parse/highlight/languages/javascript.js +0 -263
  70. package/src/mp/components/markdown/towxml/parse/highlight/languages/json.js +0 -51
  71. package/src/mp/components/markdown/towxml/parse/highlight/languages/less.js +0 -177
  72. package/src/mp/components/markdown/towxml/parse/highlight/languages/nginx.js +0 -103
  73. package/src/mp/components/markdown/towxml/parse/highlight/languages/php.js +0 -152
  74. package/src/mp/components/markdown/towxml/parse/highlight/languages/python-repl.js +0 -27
  75. package/src/mp/components/markdown/towxml/parse/highlight/languages/python.js +0 -146
  76. package/src/mp/components/markdown/towxml/parse/highlight/languages/scss.js +0 -137
  77. package/src/mp/components/markdown/towxml/parse/highlight/languages/shell.js +0 -23
  78. package/src/mp/components/markdown/towxml/parse/highlight/languages/typescript.js +0 -198
  79. package/src/mp/components/markdown/towxml/parse/highlight/languages/xml.js +0 -143
  80. package/src/mp/components/markdown/towxml/parse/highlight/style/github.wxss +0 -99
  81. package/src/mp/components/markdown/towxml/parse/highlight/style/monokai.wxss +0 -70
  82. package/src/mp/components/markdown/towxml/parse/index.js +0 -106
  83. package/src/mp/components/markdown/towxml/parse/markdown/index.js +0 -53
  84. package/src/mp/components/markdown/towxml/parse/markdown/markdown.js +0 -5834
  85. package/src/mp/components/markdown/towxml/parse/markdown/plugins/emoji.js +0 -1773
  86. package/src/mp/components/markdown/towxml/parse/markdown/plugins/ins.js +0 -120
  87. package/src/mp/components/markdown/towxml/parse/markdown/plugins/latex.js +0 -193
  88. package/src/mp/components/markdown/towxml/parse/markdown/plugins/mark.js +0 -120
  89. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sub.js +0 -95
  90. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sup.js +0 -95
  91. package/src/mp/components/markdown/towxml/parse/markdown/plugins/todo.js +0 -220
  92. package/src/mp/components/markdown/towxml/parse/markdown/plugins/yuml.js +0 -18
  93. package/src/mp/components/markdown/towxml/parse/parse2/Parser.js +0 -263
  94. package/src/mp/components/markdown/towxml/parse/parse2/Tokenizer.js +0 -507
  95. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/index.js +0 -104
  96. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/node.js +0 -169
  97. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode.js +0 -54
  98. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode_codepoint.js +0 -19
  99. package/src/mp/components/markdown/towxml/parse/parse2/entities/encode.js +0 -54
  100. package/src/mp/components/markdown/towxml/parse/parse2/entities/index.js +0 -30
  101. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/decode.js +0 -31
  102. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/entities.js +0 -2128
  103. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/legacy.js +0 -109
  104. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/xml.js +0 -2
  105. package/src/mp/components/markdown/towxml/parse/parse2/index.js +0 -8
  106. package/src/mp/components/markdown/towxml/style/main.wxss +0 -378
  107. package/src/mp/components/markdown/towxml/style/theme/dark.wxss +0 -73
  108. package/src/mp/components/markdown/towxml/style/theme/light.wxss +0 -63
  109. package/src/mp/components/markdown/towxml/table/table.js +0 -11
  110. package/src/mp/components/markdown/towxml/table/table.json +0 -6
  111. package/src/mp/components/markdown/towxml/table/table.wxml +0 -24
  112. package/src/mp/components/markdown/towxml/table/table.wxss +0 -0
  113. package/src/mp/components/markdown/towxml/todogroup/todogroup.js +0 -19
  114. package/src/mp/components/markdown/towxml/todogroup/todogroup.json +0 -6
  115. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxml +0 -13
  116. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxss +0 -3
  117. package/src/mp/components/markdown/towxml/towxml.js +0 -17
  118. package/src/mp/components/markdown/towxml/towxml.json +0 -6
  119. package/src/mp/components/markdown/towxml/towxml.wxml +0 -5
  120. package/src/mp/components/markdown/towxml/towxml.wxss +0 -8
  121. package/src/mp/components/markdown/towxml/yuml/yuml.js +0 -51
  122. package/src/mp/components/markdown/towxml/yuml/yuml.json +0 -5
  123. package/src/mp/components/markdown/towxml/yuml/yuml.wxml +0 -5
  124. package/src/mp/components/markdown/towxml/yuml/yuml.wxss +0 -0
  125. package/src/web/.DS_Store +0 -0
  126. package/src/web/components/markdown/index.jsx +0 -40
  127. package/src/web/wedatheme/.git +0 -1
  128. package/src/web/wedatheme/.gitignore +0 -5
  129. package/src/web/wedatheme/.npmrc +0 -1
  130. package/src/web/wedatheme/package-lock.json +0 -14335
@@ -6,6 +6,7 @@ import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
6
6
  import isObjectEqual from '../../../utils/isObjectEqual';
7
7
  import { useSyncValue } from '../../../utils/useSyncValue';
8
8
  import { isCloudFileID } from '../../../utils/platform';
9
+ import { IMAGE_TYPES } from './uploader.pc';
9
10
 
10
11
  const uploadPath = 'weda-uploader';
11
12
  /**
@@ -14,6 +15,8 @@ const uploadPath = 'weda-uploader';
14
15
  export function ImageUploaderH5({
15
16
  title,
16
17
  maxUploadCount,
18
+ maxSize = 10,
19
+ acceptTypes,
17
20
  className,
18
21
  id,
19
22
  events,
@@ -34,8 +37,17 @@ export function ImageUploaderH5({
34
37
  const [uploading, setUploading] = React.useState(false);
35
38
  //上传进度
36
39
  const [progress, setProgress] = React.useState(0);
37
- const [fileIDList, setfileIDList] = useSyncValue(defaultValue, isObjectEqual);
38
- const uploadCount = (fileIDList ?? []).length;
40
+ const [inputValue, setInputValue] = useSyncValue(defaultValue, isObjectEqual);
41
+ const fileIdList = React.useMemo(() => {
42
+ if( typeof inputValue === 'string') {
43
+ // single = true 传入的是字符串
44
+ return [inputValue].filter(i => i.length > 0); // 排除空串
45
+ }
46
+ if(Array.isArray(inputValue)) {
47
+ return inputValue;
48
+ }
49
+ return [];
50
+ }, [inputValue]);
39
51
 
40
52
  const finalMaxImgCount = React.useMemo(() => {
41
53
  if(single) return 1;
@@ -43,18 +55,22 @@ export function ImageUploaderH5({
43
55
  }, [single, maxUploadCount]);
44
56
 
45
57
  const deleteFile = (url) => {
46
- setfileIDList((list) => list.filter(f => f !== url));
58
+ if(single) {
59
+ setInputValue('');
60
+ return;
61
+ }
62
+ setInputValue((list) => list.filter(f => f !== url));
47
63
  };
48
64
  React.useEffect(() => {
49
65
  if (single) {
50
- const file = fileIDList[0] || '';
66
+ const file = fileIdList[0] || '';
51
67
  file && onChange && onChange(file);
52
68
  events.change && events.change({ value: file });
53
69
  } else {
54
- onChange && onChange(fileIDList);
55
- events.change && events.change({ value: fileIDList });
70
+ onChange && onChange(fileIdList);
71
+ events.change && events.change({ value: fileIdList });
56
72
  }
57
- }, [fileIDList]);
73
+ }, [fileIdList]);
58
74
  const onProgress = (progressEvent) => {
59
75
  let percentCompleted = 0;
60
76
  try {
@@ -77,7 +93,7 @@ export function ImageUploaderH5({
77
93
  onUploadProgress: onProgress,
78
94
 
79
95
  });
80
- fileID && setfileIDList((list) => [...list, fileID]);
96
+ fileID && setInputValue((list) => [...list, fileID]);
81
97
  fileID && events.success && events.success({ value: fileID, file });
82
98
  } catch (err) {
83
99
  events.error && events.error(err);
@@ -87,6 +103,13 @@ export function ImageUploaderH5({
87
103
  }
88
104
  });
89
105
  };
106
+
107
+ const accepts = React.useMemo(() => {
108
+ return acceptTypes.includes('image/*') || acceptTypes.length === 0
109
+ ? IMAGE_TYPES
110
+ : Array.from(new Set(acceptTypes));
111
+ }, [acceptTypes]);
112
+
90
113
  return (
91
114
  <div className={cls} id={id} style={style}>
92
115
  <div className="weui-cell">
@@ -95,13 +118,13 @@ export function ImageUploaderH5({
95
118
  <div className={classNames("weui-uploader__hd", layout)}>
96
119
  <p className="weui-uploader__title">{title}</p>
97
120
  <div className="weui-uploader__info">
98
- <span id="uploadCount">{uploadCount}</span>
121
+ <span id="uploadCount">{fileIdList.length}</span>
99
122
  {`/${finalMaxImgCount}`}
100
123
  </div>
101
124
  </div>
102
125
  <div className="weui-uploader__bd">
103
126
  <ul className="weui-uploader__files" id="uploaderFiles">
104
- {(fileIDList ?? []).map(f => <SingleImage key={f} src={f} deleteBySrc={deleteFile} />)}
127
+ {(fileIdList ?? []).map(f => <SingleImage key={f} src={f} deleteBySrc={deleteFile} />)}
105
128
  {uploading &&
106
129
  <li className="weui-uploader__file weui-uploader__file_status" >
107
130
  <div className="weui-uploader__file-content">
@@ -109,18 +132,18 @@ export function ImageUploaderH5({
109
132
  </div>
110
133
  </li>}
111
134
  </ul>
112
- {(fileIDList.length < maxUploadCount ||
113
- (single && fileIDList.length < 1)) && ( // single 模式时,仅当数组为空时显示
135
+ {(fileIdList.length < maxUploadCount ||
136
+ (single && fileIdList.length < 1)) && ( // single 模式时,仅当数组为空时显示
114
137
  <div className="weui-uploader__input-box">
115
138
  <input
116
139
  id="uploaderInput"
117
140
  className="weui-uploader__input"
118
141
  type="file"
119
- accept="image/*"
142
+ accept={accepts.join(',')}
120
143
  multiple
121
144
  onChange={e => {
122
145
  const files = [...e.target.files];
123
- if (files.some(f => f.size > 10 * 1024 * 1024)) {
146
+ if (files.some(f => f.size > maxSize * 1024 * 1024)) {
124
147
  weui.alert('请上传不超过10M的图片');
125
148
  return false;
126
149
  }
@@ -130,7 +153,7 @@ export function ImageUploaderH5({
130
153
  weui.alert(`最多只能上传${finalMaxImgCount}张图片,请重新选择`);
131
154
  return false;
132
155
  }
133
- if (uploadCount + files.length > finalMaxImgCount) {
156
+ if (fileIdList.length + files.length > finalMaxImgCount) {
134
157
  weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
135
158
  return false;
136
159
  }
@@ -195,12 +218,15 @@ function SingleImage({src, deleteBySrc}) {
195
218
  );
196
219
  }
197
220
  SingleImage.propTypes = {
198
- src: PropTypes.string
221
+ src: PropTypes.string,
222
+ deleteBySrc: PropTypes.func
199
223
  };
200
224
  ImageUploaderH5.propTypes = {
201
225
  id: PropTypes.string,
202
226
  title: PropTypes.string,
203
227
  className: PropTypes.string, // 传入类
228
+ maxSize: PropTypes.number,
229
+ acceptTypes: PropTypes.array,
204
230
  maxUploadCount: PropTypes.number, // 【上传图片最大数量】
205
231
  events: PropTypes.objectOf(PropTypes.func), // 事件
206
232
  style: PropTypes.object,
@@ -18,7 +18,7 @@ import * as PropTypes from 'prop-types';
18
18
  // 默认组件类前缀
19
19
  export const CLASS_PREFIX = 'weda-uploader-pc';
20
20
  // 默认图片类型
21
- const IMAGE_TYPES = [
21
+ export const IMAGE_TYPES = [
22
22
  'image/jpg',
23
23
  'image/png',
24
24
  'image/tif',
@@ -3,7 +3,6 @@ import * as PropTypes from 'prop-types';
3
3
  import { ConfigProvider, ImagePreview } from 'tea-component';
4
4
  import { usePlatform } from '../../utils/platform';
5
5
  import { useGesture } from '@use-gesture/react';
6
- import { off } from 'react-use/lib/util';
7
6
 
8
7
  ImageInner.propTypes = {
9
8
  objectFit: PropTypes.string,
@@ -1,7 +1,6 @@
1
1
  import '../wedatheme/style-package/index.css';
2
2
 
3
3
  export { default as Button } from './button';
4
- export { default as Markdown } from './markdown';
5
4
  export { default as Text } from './text';
6
5
  export { default as Container } from './container';
7
6
  export { default as Image } from './image';
@@ -29,6 +28,7 @@ export { default as Select } from './form/select';
29
28
  export { default as Uploader } from './form/uploader';
30
29
  export { default as Tips } from './form/tips';
31
30
  export { default as Tabs } from './tabs';
31
+ export { default as EnumSelect } from './form/enumSelect';
32
32
  // open
33
33
  // import Auth from './auth';
34
34