@cloudbase/weda-ui 0.2.5 → 0.2.8

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 (150) hide show
  1. package/package.json +4 -4
  2. package/src/.DS_Store +0 -0
  3. package/src/configs/components/container.json +2 -1
  4. package/src/configs/components/form/input.json +6 -0
  5. package/src/configs/components/form/richText.json +2 -1
  6. package/src/configs/components/form/uploader.json +10 -5
  7. package/src/configs/components/image.json +2 -1
  8. package/src/configs/components/link.json +2 -1
  9. package/src/configs/components/richtextview.json +2 -1
  10. package/src/configs/components/scrollVeiw.json +2 -1
  11. package/src/configs/components/swiper.json +2 -1
  12. package/src/configs/components/tabs.json +31 -86
  13. package/src/configs/components/text.json +2 -1
  14. package/src/configs/index.js +3 -5
  15. package/src/index.js +2 -3
  16. package/src/mp/components/form/input/index.js +5 -1
  17. package/src/mp/components/form/input/index.wxml +2 -1
  18. package/src/mp/components/form/select/index.js +2 -2
  19. package/src/mp/components/form/textarea/index.wxml +1 -0
  20. package/src/mp/components/form/uploader/index.js +50 -13
  21. package/src/mp/components/form/uploader/index.wxml +11 -1
  22. package/src/mp/components/image/index.js +57 -8
  23. package/src/mp/components/image/index.json +4 -1
  24. package/src/mp/components/image/index.wxml +4 -2
  25. package/src/mp/components/image/index.wxss +15 -0
  26. package/src/mp/components/richText/index.wxml +3 -1
  27. package/src/mp/components/tabs/index.js +22 -6
  28. package/src/mp/utils/deepEqual.js +42 -0
  29. package/src/web/actions/index.js +2 -4
  30. package/src/web/components/form/checkbox/index.jsx +8 -10
  31. package/src/web/components/form/formcell/index.jsx +1 -1
  32. package/src/web/components/form/input/index.jsx +16 -18
  33. package/src/web/components/form/radio/index.jsx +7 -7
  34. package/src/web/components/form/select/h5.jsx +1 -1
  35. package/src/web/components/form/select/region/{cities.json → cities.js} +2 -2
  36. package/src/web/components/form/select/region/index.js +3 -3
  37. package/src/web/components/form/select/region/{provinces.json → provinces.js} +2 -2
  38. package/src/web/components/form/select/region/{regions.json → regions.js} +2 -2
  39. package/src/web/components/form/switch/index.jsx +4 -9
  40. package/src/web/components/form/textarea/index.jsx +4 -12
  41. package/src/web/components/form/uploader/index.css +15 -0
  42. package/src/web/components/form/uploader/index.jsx +2 -2
  43. package/src/web/components/form/uploader/uploader.h5.jsx +237 -0
  44. package/src/web/components/form/uploader/{uploaderPc.jsx → uploader.pc.jsx} +76 -58
  45. package/src/web/components/image/image.jsx +79 -5
  46. package/src/web/components/image/index.css +18 -0
  47. package/src/web/components/image/index.jsx +1 -0
  48. package/src/web/components/index.js +26 -58
  49. package/src/web/components/richTextView/index.css +0 -10
  50. package/src/web/components/richTextView/index.jsx +1 -12
  51. package/src/web/components/tabs/{index.js → index.jsx} +3 -3
  52. package/src/web/components/tabs/{tabsH5.js → tabs.h5.jsx} +9 -47
  53. package/src/web/components/tabs/{tabsPc.js → tabs.pc.jsx} +13 -47
  54. package/src/web/components/uploaderView/index.jsx +1 -1
  55. package/src/web/index.js +2 -3
  56. package/src/web/utils/isObjectEqual.js +10 -1
  57. package/src/web/utils/useSyncValue.js +14 -0
  58. package/src/web/weda-ui.css +8 -0
  59. package/src/configs/components/markdown.json +0 -17
  60. package/src/mp/components/markdown/index.js +0 -27
  61. package/src/mp/components/markdown/index.json +0 -6
  62. package/src/mp/components/markdown/index.wxml +0 -1
  63. package/src/mp/components/markdown/towxml/audio-player/Audio.js +0 -99
  64. package/src/mp/components/markdown/towxml/audio-player/audio-player.js +0 -102
  65. package/src/mp/components/markdown/towxml/audio-player/audio-player.json +0 -5
  66. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxml +0 -14
  67. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxss +0 -175
  68. package/src/mp/components/markdown/towxml/audio-player/loading.svg +0 -1
  69. package/src/mp/components/markdown/towxml/config.js +0 -285
  70. package/src/mp/components/markdown/towxml/decode.js +0 -26
  71. package/src/mp/components/markdown/towxml/decode.json +0 -12
  72. package/src/mp/components/markdown/towxml/decode.wxml +0 -1
  73. package/src/mp/components/markdown/towxml/decode.wxss +0 -0
  74. package/src/mp/components/markdown/towxml/img/img.js +0 -98
  75. package/src/mp/components/markdown/towxml/img/img.json +0 -3
  76. package/src/mp/components/markdown/towxml/img/img.wxml +0 -1
  77. package/src/mp/components/markdown/towxml/img/img.wxss +0 -0
  78. package/src/mp/components/markdown/towxml/index.js +0 -19
  79. package/src/mp/components/markdown/towxml/latex/latex.js +0 -53
  80. package/src/mp/components/markdown/towxml/latex/latex.json +0 -5
  81. package/src/mp/components/markdown/towxml/latex/latex.wxml +0 -1
  82. package/src/mp/components/markdown/towxml/latex/latex.wxss +0 -0
  83. package/src/mp/components/markdown/towxml/parse/highlight/highlight.js +0 -729
  84. package/src/mp/components/markdown/towxml/parse/highlight/index.js +0 -7
  85. package/src/mp/components/markdown/towxml/parse/highlight/languages/bash.js +0 -91
  86. package/src/mp/components/markdown/towxml/parse/highlight/languages/c-like.js +0 -244
  87. package/src/mp/components/markdown/towxml/parse/highlight/languages/c.js +0 -20
  88. package/src/mp/components/markdown/towxml/parse/highlight/languages/css.js +0 -138
  89. package/src/mp/components/markdown/towxml/parse/highlight/languages/dart.js +0 -135
  90. package/src/mp/components/markdown/towxml/parse/highlight/languages/go.js +0 -57
  91. package/src/mp/components/markdown/towxml/parse/highlight/languages/htmlbars.js +0 -79
  92. package/src/mp/components/markdown/towxml/parse/highlight/languages/java.js +0 -126
  93. package/src/mp/components/markdown/towxml/parse/highlight/languages/javascript.js +0 -263
  94. package/src/mp/components/markdown/towxml/parse/highlight/languages/json.js +0 -51
  95. package/src/mp/components/markdown/towxml/parse/highlight/languages/less.js +0 -177
  96. package/src/mp/components/markdown/towxml/parse/highlight/languages/nginx.js +0 -103
  97. package/src/mp/components/markdown/towxml/parse/highlight/languages/php.js +0 -152
  98. package/src/mp/components/markdown/towxml/parse/highlight/languages/python-repl.js +0 -27
  99. package/src/mp/components/markdown/towxml/parse/highlight/languages/python.js +0 -146
  100. package/src/mp/components/markdown/towxml/parse/highlight/languages/scss.js +0 -137
  101. package/src/mp/components/markdown/towxml/parse/highlight/languages/shell.js +0 -23
  102. package/src/mp/components/markdown/towxml/parse/highlight/languages/typescript.js +0 -198
  103. package/src/mp/components/markdown/towxml/parse/highlight/languages/xml.js +0 -143
  104. package/src/mp/components/markdown/towxml/parse/highlight/style/github.wxss +0 -99
  105. package/src/mp/components/markdown/towxml/parse/highlight/style/monokai.wxss +0 -70
  106. package/src/mp/components/markdown/towxml/parse/index.js +0 -106
  107. package/src/mp/components/markdown/towxml/parse/markdown/index.js +0 -53
  108. package/src/mp/components/markdown/towxml/parse/markdown/markdown.js +0 -5834
  109. package/src/mp/components/markdown/towxml/parse/markdown/plugins/emoji.js +0 -1773
  110. package/src/mp/components/markdown/towxml/parse/markdown/plugins/ins.js +0 -120
  111. package/src/mp/components/markdown/towxml/parse/markdown/plugins/latex.js +0 -193
  112. package/src/mp/components/markdown/towxml/parse/markdown/plugins/mark.js +0 -120
  113. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sub.js +0 -95
  114. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sup.js +0 -95
  115. package/src/mp/components/markdown/towxml/parse/markdown/plugins/todo.js +0 -220
  116. package/src/mp/components/markdown/towxml/parse/markdown/plugins/yuml.js +0 -18
  117. package/src/mp/components/markdown/towxml/parse/parse2/Parser.js +0 -263
  118. package/src/mp/components/markdown/towxml/parse/parse2/Tokenizer.js +0 -507
  119. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/index.js +0 -104
  120. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/node.js +0 -169
  121. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode.js +0 -54
  122. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode_codepoint.js +0 -19
  123. package/src/mp/components/markdown/towxml/parse/parse2/entities/encode.js +0 -54
  124. package/src/mp/components/markdown/towxml/parse/parse2/entities/index.js +0 -30
  125. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/decode.js +0 -31
  126. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/entities.js +0 -2128
  127. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/legacy.js +0 -109
  128. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/xml.js +0 -2
  129. package/src/mp/components/markdown/towxml/parse/parse2/index.js +0 -8
  130. package/src/mp/components/markdown/towxml/style/main.wxss +0 -378
  131. package/src/mp/components/markdown/towxml/style/theme/dark.wxss +0 -73
  132. package/src/mp/components/markdown/towxml/style/theme/light.wxss +0 -63
  133. package/src/mp/components/markdown/towxml/table/table.js +0 -11
  134. package/src/mp/components/markdown/towxml/table/table.json +0 -6
  135. package/src/mp/components/markdown/towxml/table/table.wxml +0 -24
  136. package/src/mp/components/markdown/towxml/table/table.wxss +0 -0
  137. package/src/mp/components/markdown/towxml/todogroup/todogroup.js +0 -19
  138. package/src/mp/components/markdown/towxml/todogroup/todogroup.json +0 -6
  139. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxml +0 -13
  140. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxss +0 -3
  141. package/src/mp/components/markdown/towxml/towxml.js +0 -17
  142. package/src/mp/components/markdown/towxml/towxml.json +0 -6
  143. package/src/mp/components/markdown/towxml/towxml.wxml +0 -5
  144. package/src/mp/components/markdown/towxml/towxml.wxss +0 -8
  145. package/src/mp/components/markdown/towxml/yuml/yuml.js +0 -51
  146. package/src/mp/components/markdown/towxml/yuml/yuml.json +0 -5
  147. package/src/mp/components/markdown/towxml/yuml/yuml.wxml +0 -5
  148. package/src/mp/components/markdown/towxml/yuml/yuml.wxss +0 -0
  149. package/src/web/components/form/uploader/uploaderH5.jsx +0 -192
  150. package/src/web/components/markdown/index.jsx +0 -40
@@ -1,13 +0,0 @@
1
- <checkbox-group wx:if="{{data.tag === 'todogroup'}}" class="{{data.attr.class}}" bindchange="_change">
2
- <block wx:if="{{data.child}}" wx:for="{{data.child}}" wx:for-item="item" wx:key="i">
3
- <label wx:if="{{item.tag}}" class="{{item.attr.class}}">
4
- <block wx:if="{{item.child}}" wx:for="{{item.child}}" wx:for-item="item" wx:key="i">
5
- <!--解析选择框-->
6
- <checkbox wx:if="{{item.tag === 'checkbox'}}" class="{{item.attr.class}}" value="{{item.attr.value}}" data-_e="{{item}}" checked="{{item.attr.checked}}" disabled="{{item.attr.disabled}}"/>
7
-
8
- <!--解析文字-->
9
- <decode wx:if="{{item.child}}" nodes="{{item}}"/>
10
- </block>
11
- </label>
12
- </block>
13
- </checkbox-group>
@@ -1,3 +0,0 @@
1
- .h2w__todolist {
2
- display:block;
3
- }
@@ -1,17 +0,0 @@
1
- Component({
2
- options: {
3
- styleIsolation: 'shared',
4
- },
5
- properties: {
6
- nodes: {
7
- type: Object,
8
- value: {},
9
- },
10
- className: {
11
- type: String,
12
- },
13
- },
14
- data: {
15
- someData: {},
16
- },
17
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "decode": "./decode"
5
- }
6
- }
@@ -1,5 +0,0 @@
1
- <view class="h2w h2w-{{nodes.theme}} {{className}}">
2
- <view class="h2w__main">
3
- <decode nodes="{{nodes}}"/>
4
- </view>
5
- </view>
@@ -1,8 +0,0 @@
1
- /**基础风格样式**/
2
- @import './style/main.wxss';
3
-
4
- /**主题配色(浅色样式)**/
5
- @import './style/theme/light.wxss';
6
-
7
- /**主题配色(深色样式)**/
8
- @import './style/theme/dark.wxss';
@@ -1,51 +0,0 @@
1
- const config = require('../config');
2
- Component({
3
- options: {
4
- styleIsolation: 'shared',
5
- },
6
- properties: {
7
- data: {
8
- type: Object,
9
- value: {},
10
- },
11
- },
12
- data: {
13
- attr: {
14
- src: '',
15
- class: '',
16
- },
17
- size: {
18
- w: 0,
19
- h: 0,
20
- },
21
- },
22
- lifetimes: {
23
- attached() {
24
- const _ts = this;
25
- const dataAttr = this.data.data.attr;
26
-
27
- // 设置公式图片
28
- _ts.setData({
29
- attr: {
30
- src: `${config.yuml.api}=${dataAttr.value}&theme=${global._theme}`,
31
- class: `${dataAttr.class}`,
32
- },
33
- });
34
- },
35
- },
36
- methods: {
37
- load(e) {
38
- const _ts = this;
39
- // 公式图片加载完成则根据其图片大小、类型计算其显示的合适大小
40
- const scale = 20;
41
- const w = e.detail.width / scale;
42
- const h = e.detail.height / scale;
43
- _ts.setData({
44
- size: {
45
- w,
46
- h,
47
- },
48
- });
49
- },
50
- },
51
- });
@@ -1,5 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- }
5
- }
@@ -1,5 +0,0 @@
1
- <view class="h2w__yumlBox">
2
- <view style="width:{{size.w}}em;" class="h2w__yumlView">
3
- <image class="{{attr.class}}" src="{{attr.src}}" style="width:{{size.w}}em; height:{{size.h}}em;" lazy-load="true" mode="aspectFill" bindload="load"></image>
4
- </view>
5
- </view>
File without changes
@@ -1,192 +0,0 @@
1
- import * as PropTypes from 'prop-types';
2
- import * as React from 'react';
3
- import weui from '../../../utils/weui';
4
- import classNames from '../../../utils/classnames';
5
- import { getCloudInstance } from '../../../utils/tcb';
6
- import { useGetSet } from 'react-use';
7
-
8
- const uploadPath = 'weda-uploader';
9
- /**
10
- * H5端
11
- */
12
- export function UploaderH5({
13
- title,
14
- maxUploadCount,
15
- className,
16
- id,
17
- events,
18
- layout,
19
- value,
20
- single = false,
21
- onChange,
22
- style,
23
- }) {
24
- const cls = classNames({
25
- 'weda-ui': true,
26
- 'weui-cells': true,
27
- 'weui-cells_form': true,
28
- [className]: className,
29
- });
30
-
31
- const [fileIDList, setfileIDList] = React.useState([]);
32
- React.useEffect(() => {
33
- if(value === undefined) {
34
- const root = document.getElementById(id);
35
- if(root) {
36
- root.querySelector('#uploaderFiles').innerHTML = '';
37
- value = [];
38
- }
39
- }
40
- }, [value]);
41
- React.useEffect(() => {
42
- let initialValue = []
43
- .concat(value ?? [])
44
- .filter((d) => typeof d === 'string' && d !== '');
45
- if (single) {
46
- maxUploadCount = 1;
47
- initialValue = initialValue[0] ? [initialValue[0]] : [];
48
- }
49
- setfileIDList(initialValue);
50
- }, [value, maxUploadCount, single]);
51
-
52
- const [uploadCount, setUploadConut] = useGetSet(0);
53
- React.useEffect(() => {
54
- events.change && events.change({ value: fileIDList });
55
- if (single) {
56
- const file = fileIDList[0] || '';
57
- file && onChange && onChange(file);
58
- } else {
59
- onChange && onChange(fileIDList);
60
- }
61
- }, [fileIDList]);
62
- React.useEffect(() => {
63
- const opts = {
64
- url: 'http://localhost:8081',
65
- auto: true,
66
- type: 'file',
67
- fileVal: 'fileVal',
68
- compress: {
69
- width: 1600,
70
- height: 1600,
71
- quality: 0.8,
72
- },
73
- onBeforeQueued: function (files) {
74
- // `this` 是轮询到的文件, `files` 是所有文件
75
-
76
- if (
77
- ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'].indexOf(
78
- this.type
79
- ) < 0
80
- ) {
81
- weui.alert('请上传图片');
82
- return false; // 阻止文件添加
83
- }
84
- if (this.size > 10 * 1024 * 1024) {
85
- weui.alert('请上传不超过10M的图片');
86
- return false;
87
- }
88
-
89
- if (files.length > maxUploadCount) {
90
- // 防止一下子选择过多文件
91
- weui.alert(`最多只能上传${maxUploadCount}张图片,请重新选择`);
92
- return false;
93
- }
94
- if (uploadCount() + 1 > maxUploadCount) {
95
- weui.alert(`最多只能上传${maxUploadCount}张图片`);
96
- return false;
97
- }
98
-
99
- setUploadConut(c => c + 1);
100
-
101
- },
102
- onQueued: function () {
103
-
104
- const file = this;
105
- getCloudInstance().then(async (tcb) => {
106
- try {
107
- const fileType = file.type.split('/')?.[1];
108
- const cloudPath = `${uploadPath}/uploader-${Date.now()}.${fileType}`;
109
- const { fileID } = await tcb.uploadFile({
110
- cloudPath,
111
- filePath: file,
112
- });
113
- fileID && setfileIDList((list) => [...list, fileID]);
114
- fileID && events.success && events.success({ value: fileID, file });
115
- const r = opts.onSuccess(file, );
116
- if(!r) {
117
-
118
- const $el = document.querySelector(`#${id}`);
119
- const $file = $el.querySelector(`[data-id="${file.id}"]`);
120
- $file.classList.remove('weui-uploader__file_status');
121
- $file.querySelector('.weui-uploader__file-content').remove();
122
- }
123
- } catch (err) {
124
- opts.onError(err);
125
- }
126
- });
127
- },
128
- onBeforeSend: function () {
129
- // $.extend(data, { test: 1 }); // 可以扩展此对象来控制上传参数
130
- // $.extend(headers, { Origin: 'http://127.0.0.1' }); // 可以扩展此对象来控制上传头部
131
-
132
- return false; // 阻止文件上传
133
- },
134
- onProgress: function () {
135
- // console.log(this, percent);
136
- // return true; // 阻止默认行为,不使用默认的进度显示
137
- },
138
- onSuccess: function (ret) {
139
- events.success && events.success(ret);
140
- return false;
141
- },
142
- onError: function (err) {
143
- events.error && events.error(err);
144
- return false;
145
- },
146
- };
147
- weui.uploader(`#${id}`, opts);
148
- }, []);
149
-
150
- return (
151
- <div className={cls} id={id} style={style}>
152
- <div className="weui-cell">
153
- <div className="weui-cell__bd">
154
- <div className={classNames("weui-uploader", layout)}>
155
- <div className={classNames("weui-uploader__hd", layout)}>
156
- <p className="weui-uploader__title">{title}</p>
157
- <div className="weui-uploader__info">
158
- <span id="uploadCount">{uploadCount()}</span>
159
- {`/${maxUploadCount}`}
160
- </div>
161
- </div>
162
- <div className="weui-uploader__bd">
163
- <ul className="weui-uploader__files" id="uploaderFiles"></ul>
164
- <div className="weui-uploader__input-box">
165
- <input
166
- id="uploaderInput"
167
- className="weui-uploader__input"
168
- type="file"
169
- accept="image/*"
170
- multiple=""
171
- />
172
- </div>
173
- </div>
174
- </div>
175
- </div>
176
- </div>
177
- </div>
178
- );
179
- }
180
-
181
- UploaderH5.propTypes = {
182
- id: PropTypes.string,
183
- title: PropTypes.string,
184
- className: PropTypes.string, // 传入类
185
- maxUploadCount: PropTypes.number, // 【上传图片最大数量】
186
- events: PropTypes.objectOf(PropTypes.func), // 事件
187
- style: PropTypes.object,
188
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
189
- value: PropTypes.oneOfType([PropTypes.array, PropTypes.string]), // 初始值,该参数需配合 formily 使用
190
- single: PropTypes.bool, // 单张上传还是多张上传,对应 onChange 参数为字符串还是字符串数组,value 在处理过程统一转为字符串数组
191
- onChange: PropTypes.objectOf(PropTypes.func), // 值变化,该参数需配合 formily 使用
192
- };
@@ -1,40 +0,0 @@
1
- /* eslint-disable react/display-name */
2
- /* eslint-disable react/prop-types */
3
- import * as React from 'react';
4
- import RawMarkdown from 'react-markdown';
5
- import { Prism } from 'react-syntax-highlighter';
6
-
7
- import * as PropTypes from 'prop-types';
8
- import classNames from '../../utils/classnames';
9
-
10
- const renderers = {
11
- code: ({ language, value = '' }) => (
12
- <Prism language={language}>{value}</Prism>
13
- ),
14
- };
15
-
16
- export default function Markdown({ source = '', className = '', ...props }) {
17
- const { contenteditable, onInput, onBlur, style, id } = props;
18
- return (
19
- <div
20
- className={classNames({
21
- 'weda-ui': true,
22
- [className]: className,
23
- })}
24
- id={id}
25
- style={style}
26
- contentEditable={contenteditable}
27
- onInput={onInput}
28
- onBlur={onBlur}
29
- >
30
- <RawMarkdown source={source} renderers={renderers} />
31
- </div>
32
- );
33
- }
34
-
35
- Markdown.propTypes = {
36
- /**
37
- * markdown 文本内容
38
- */
39
- source: PropTypes.string,
40
- };