@douyinfe/semi-ui 2.13.0-beta.0 → 2.13.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.
- package/cascader/index.tsx +4 -2
- package/dist/css/semi.css +22 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +28 -80
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/gulpfile.js +5 -5
- package/lib/cjs/_base/base.css +22 -0
- package/lib/cjs/cascader/index.js +4 -2
- package/lib/cjs/tagInput/index.js +8 -7
- package/lib/es/_base/base.css +22 -0
- package/lib/es/cascader/index.js +4 -2
- package/lib/es/tagInput/index.js +6 -7
- package/package.json +8 -8
- package/table/_story/v2/FixedOnHeaderRow/index.jsx +3 -0
- package/tabs/_story/tabs.stories.js +36 -0
- package/tag/_story/tag.stories.js +1 -1
- package/tagInput/index.tsx +9 -11
- package/upload/_story/upload.stories.js +152 -0
package/gulpfile.js
CHANGED
|
@@ -73,14 +73,14 @@ gulp.task('compileScss', function compileScss() {
|
|
|
73
73
|
}
|
|
74
74
|
))
|
|
75
75
|
.pipe(sass({
|
|
76
|
-
importer: (url, prev) => {
|
|
76
|
+
importer: (url, prev, done) => {
|
|
77
77
|
const rootPath = path.join(__dirname, '../../');
|
|
78
78
|
let realUrl = url;
|
|
79
79
|
if (/~@douyinfe\/semi-foundation/.test(url)) {
|
|
80
80
|
const semiUIPath = path.join(rootPath, 'packages/semi-foundation');
|
|
81
81
|
realUrl = url.replace(/~@douyinfe\/semi-foundation/, semiUIPath);
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
done({ file:realUrl });
|
|
84
84
|
},
|
|
85
85
|
charset: false
|
|
86
86
|
}).on('error', sass.logError))
|
|
@@ -104,11 +104,11 @@ gulp.task('moveScssForCJS', function moveScssForCJS() {
|
|
|
104
104
|
return moveScss(false);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
gulp.task('compileLib',
|
|
107
|
+
gulp.task('compileLib',
|
|
108
108
|
gulp.series(
|
|
109
109
|
[
|
|
110
|
-
'cleanLib',
|
|
111
|
-
'compileScss',
|
|
110
|
+
'cleanLib',
|
|
111
|
+
'compileScss',
|
|
112
112
|
gulp.parallel('moveScssForESM', 'moveScssForCJS'),
|
|
113
113
|
gulp.parallel('compileTSXForESM', 'compileTSXForCJS')
|
|
114
114
|
]
|
package/lib/cjs/_base/base.css
CHANGED
|
@@ -507,4 +507,26 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
507
507
|
--semi-border-radius-large: 12px;
|
|
508
508
|
--semi-border-radius-circle: 50%;
|
|
509
509
|
--semi-border-radius-full: 9999px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.semi-light-scrollbar::-webkit-scrollbar, .semi-light-scrollbar *::-webkit-scrollbar {
|
|
513
|
+
width: 8px;
|
|
514
|
+
height: 8px;
|
|
515
|
+
}
|
|
516
|
+
.semi-light-scrollbar::-webkit-scrollbar-track, .semi-light-scrollbar *::-webkit-scrollbar-track {
|
|
517
|
+
background: rgba(0, 0, 0, 0);
|
|
518
|
+
}
|
|
519
|
+
.semi-light-scrollbar::-webkit-scrollbar-corner, .semi-light-scrollbar *::-webkit-scrollbar-corner {
|
|
520
|
+
background-color: rgba(0, 0, 0, 0);
|
|
521
|
+
}
|
|
522
|
+
.semi-light-scrollbar::-webkit-scrollbar-thumb, .semi-light-scrollbar *::-webkit-scrollbar-thumb {
|
|
523
|
+
border-radius: 6px;
|
|
524
|
+
background: transparent;
|
|
525
|
+
transition: all 1s;
|
|
526
|
+
}
|
|
527
|
+
.semi-light-scrollbar:hover::-webkit-scrollbar-thumb, .semi-light-scrollbar *:hover::-webkit-scrollbar-thumb {
|
|
528
|
+
background: var(--semi-color-fill-2);
|
|
529
|
+
}
|
|
530
|
+
.semi-light-scrollbar::-webkit-scrollbar-thumb:hover, .semi-light-scrollbar *::-webkit-scrollbar-thumb:hover {
|
|
531
|
+
background: var(--semi-color-fill-1);
|
|
510
532
|
}
|
|
@@ -800,13 +800,15 @@ class Cascader extends _baseComponent.default {
|
|
|
800
800
|
if ((0, _isArray.default)(realValue)) {
|
|
801
801
|
normallizedValue = (0, _isArray.default)(realValue[0]) ? realValue : [realValue];
|
|
802
802
|
} else {
|
|
803
|
-
|
|
803
|
+
if (realValue !== undefined) {
|
|
804
|
+
normallizedValue = [[realValue]];
|
|
805
|
+
}
|
|
804
806
|
} // formatValuePath is used to save value of valuePath
|
|
805
807
|
|
|
806
808
|
|
|
807
809
|
const formatValuePath = [];
|
|
808
810
|
(0, _forEach.default)(normallizedValue).call(normallizedValue, valueItem => {
|
|
809
|
-
const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i.value) : valueItem;
|
|
811
|
+
const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
|
|
810
812
|
formatValuePath.push(formatItem);
|
|
811
813
|
}); // formatKeys is used to save key of value
|
|
812
814
|
|
|
@@ -306,7 +306,7 @@ class TagInput extends _baseComponent.default {
|
|
|
306
306
|
const typoCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-typo"), {
|
|
307
307
|
["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
|
|
308
308
|
});
|
|
309
|
-
const
|
|
309
|
+
const restTagsCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-n"), {
|
|
310
310
|
["".concat(prefixCls, "-wrapper-n-disabled")]: disabled
|
|
311
311
|
});
|
|
312
312
|
const restTags = [];
|
|
@@ -346,17 +346,18 @@ class TagInput extends _baseComponent.default {
|
|
|
346
346
|
tags.push(item);
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
|
-
|
|
349
|
+
|
|
350
|
+
const restTagsContent = /*#__PURE__*/_react.default.createElement("span", {
|
|
351
|
+
className: restTagsCls
|
|
352
|
+
}, "+", tagsArray.length - maxTagCount);
|
|
353
|
+
|
|
354
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tags, restTags.length > 0 && (showRestTagsPopover ? /*#__PURE__*/_react.default.createElement(_popover.default, (0, _assign.default)({
|
|
350
355
|
content: restTags,
|
|
351
356
|
showArrow: true,
|
|
352
357
|
trigger: "hover",
|
|
353
358
|
position: "top",
|
|
354
359
|
autoAdjustOverflow: true
|
|
355
|
-
}, restTagsPopoverProps),
|
|
356
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-wrapper-n"))
|
|
357
|
-
}, "+", tagsArray.length - maxTagCount)) : /*#__PURE__*/_react.default.createElement("span", {
|
|
358
|
-
className: spanNotWithPopoverCls
|
|
359
|
-
}, "+".concat(tagsArray.length - maxTagCount))));
|
|
360
|
+
}, restTagsPopoverProps), restTagsContent) : restTagsContent));
|
|
360
361
|
}
|
|
361
362
|
|
|
362
363
|
blur() {
|
package/lib/es/_base/base.css
CHANGED
|
@@ -507,4 +507,26 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
507
507
|
--semi-border-radius-large: 12px;
|
|
508
508
|
--semi-border-radius-circle: 50%;
|
|
509
509
|
--semi-border-radius-full: 9999px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.semi-light-scrollbar::-webkit-scrollbar, .semi-light-scrollbar *::-webkit-scrollbar {
|
|
513
|
+
width: 8px;
|
|
514
|
+
height: 8px;
|
|
515
|
+
}
|
|
516
|
+
.semi-light-scrollbar::-webkit-scrollbar-track, .semi-light-scrollbar *::-webkit-scrollbar-track {
|
|
517
|
+
background: rgba(0, 0, 0, 0);
|
|
518
|
+
}
|
|
519
|
+
.semi-light-scrollbar::-webkit-scrollbar-corner, .semi-light-scrollbar *::-webkit-scrollbar-corner {
|
|
520
|
+
background-color: rgba(0, 0, 0, 0);
|
|
521
|
+
}
|
|
522
|
+
.semi-light-scrollbar::-webkit-scrollbar-thumb, .semi-light-scrollbar *::-webkit-scrollbar-thumb {
|
|
523
|
+
border-radius: 6px;
|
|
524
|
+
background: transparent;
|
|
525
|
+
transition: all 1s;
|
|
526
|
+
}
|
|
527
|
+
.semi-light-scrollbar:hover::-webkit-scrollbar-thumb, .semi-light-scrollbar *:hover::-webkit-scrollbar-thumb {
|
|
528
|
+
background: var(--semi-color-fill-2);
|
|
529
|
+
}
|
|
530
|
+
.semi-light-scrollbar::-webkit-scrollbar-thumb:hover, .semi-light-scrollbar *::-webkit-scrollbar-thumb:hover {
|
|
531
|
+
background: var(--semi-color-fill-1);
|
|
510
532
|
}
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -741,14 +741,16 @@ class Cascader extends BaseComponent {
|
|
|
741
741
|
if (_Array$isArray(realValue)) {
|
|
742
742
|
normallizedValue = _Array$isArray(realValue[0]) ? realValue : [realValue];
|
|
743
743
|
} else {
|
|
744
|
-
|
|
744
|
+
if (realValue !== undefined) {
|
|
745
|
+
normallizedValue = [[realValue]];
|
|
746
|
+
}
|
|
745
747
|
} // formatValuePath is used to save value of valuePath
|
|
746
748
|
|
|
747
749
|
|
|
748
750
|
const formatValuePath = [];
|
|
749
751
|
|
|
750
752
|
_forEachInstanceProperty(normallizedValue).call(normallizedValue, valueItem => {
|
|
751
|
-
const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i.value) : valueItem;
|
|
753
|
+
const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
|
|
752
754
|
formatValuePath.push(formatItem);
|
|
753
755
|
}); // formatKeys is used to save key of value
|
|
754
756
|
|
package/lib/es/tagInput/index.js
CHANGED
|
@@ -272,7 +272,7 @@ class TagInput extends BaseComponent {
|
|
|
272
272
|
const typoCls = cls("".concat(prefixCls, "-wrapper-typo"), {
|
|
273
273
|
["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
|
|
274
274
|
});
|
|
275
|
-
const
|
|
275
|
+
const restTagsCls = cls("".concat(prefixCls, "-wrapper-n"), {
|
|
276
276
|
["".concat(prefixCls, "-wrapper-n-disabled")]: disabled
|
|
277
277
|
});
|
|
278
278
|
const restTags = [];
|
|
@@ -314,17 +314,16 @@ class TagInput extends BaseComponent {
|
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
-
|
|
317
|
+
const restTagsContent = /*#__PURE__*/React.createElement("span", {
|
|
318
|
+
className: restTagsCls
|
|
319
|
+
}, "+", tagsArray.length - maxTagCount);
|
|
320
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, tags, restTags.length > 0 && (showRestTagsPopover ? /*#__PURE__*/React.createElement(Popover, _Object$assign({
|
|
318
321
|
content: restTags,
|
|
319
322
|
showArrow: true,
|
|
320
323
|
trigger: "hover",
|
|
321
324
|
position: "top",
|
|
322
325
|
autoAdjustOverflow: true
|
|
323
|
-
}, restTagsPopoverProps),
|
|
324
|
-
className: cls("".concat(prefixCls, "-wrapper-n"))
|
|
325
|
-
}, "+", tagsArray.length - maxTagCount)) : /*#__PURE__*/React.createElement("span", {
|
|
326
|
-
className: spanNotWithPopoverCls
|
|
327
|
-
}, "+".concat(tagsArray.length - maxTagCount))));
|
|
326
|
+
}, restTagsPopoverProps), restTagsContent) : restTagsContent));
|
|
328
327
|
}
|
|
329
328
|
|
|
330
329
|
blur() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.13.0
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
17
|
"@douyinfe/semi-animation": "2.12.0",
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.13.0
|
|
19
|
-
"@douyinfe/semi-foundation": "2.13.0
|
|
20
|
-
"@douyinfe/semi-icons": "2.13.0
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.13.0
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.13.0
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.13.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.13.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.13.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.13.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.13.0",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "27671f7d0a04e5569c6bf16c0c6ea6c547a77016",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.13.0
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.13.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
|
@@ -867,3 +867,39 @@ export const TabListChange = () => <TabListChangeDemo />;
|
|
|
867
867
|
TabListChange.story = {
|
|
868
868
|
name: 'tablist change',
|
|
869
869
|
};
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
class TabClosableDemo extends React.Component {
|
|
873
|
+
constructor(props){
|
|
874
|
+
super(props);
|
|
875
|
+
this.state = {
|
|
876
|
+
tabList: [
|
|
877
|
+
{tab: '文档', itemKey:'1', text:'文档', closable:true},
|
|
878
|
+
{tab: '快速起步', itemKey:'2', text:'快速起步', closable:true},
|
|
879
|
+
{tab: '帮助', itemKey:'3', text:'帮助'},
|
|
880
|
+
]
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
close(key){
|
|
884
|
+
const newTabList = [...this.state.tabList];
|
|
885
|
+
const closeIndex = newTabList.findIndex(t=>t.itemKey===key);
|
|
886
|
+
newTabList.splice(closeIndex, 1);
|
|
887
|
+
this.setState({tabList:newTabList});
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
render() {
|
|
891
|
+
return (
|
|
892
|
+
<Tabs type="card" defaultActiveKey="1" onTabClose={this.close.bind(this)}>
|
|
893
|
+
{
|
|
894
|
+
this.state.tabList.map(t=><TabPane closable={t.closable} tab={t.tab} itemKey={t.itemKey} key={t.itemKey}>{t.text}</TabPane>)
|
|
895
|
+
}
|
|
896
|
+
</Tabs>
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
export const TabClosable = () => <TabClosableDemo />;
|
|
902
|
+
|
|
903
|
+
TabClosable.story = {
|
|
904
|
+
name: 'tab closable',
|
|
905
|
+
};
|
|
@@ -155,7 +155,7 @@ export const TagAvatar = () => {
|
|
|
155
155
|
'https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg';
|
|
156
156
|
return (
|
|
157
157
|
<div style={{ margin: 10 }}>
|
|
158
|
-
<Tag avatarSrc={avatarSrc} avatarShape={'square'}>
|
|
158
|
+
<Tag avatarSrc={avatarSrc} avatarShape={'square'} onClick={()=>{console.log('如果能重来,我要做李白')}}>
|
|
159
159
|
李白
|
|
160
160
|
</Tag>
|
|
161
161
|
<br />
|
package/tagInput/index.tsx
CHANGED
|
@@ -333,7 +333,7 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
333
333
|
const typoCls = cls(`${prefixCls}-wrapper-typo`, {
|
|
334
334
|
[`${prefixCls}-wrapper-typo-disabled`]: disabled
|
|
335
335
|
});
|
|
336
|
-
const
|
|
336
|
+
const restTagsCls = cls(`${prefixCls}-wrapper-n`, {
|
|
337
337
|
[`${prefixCls}-wrapper-n-disabled`]: disabled
|
|
338
338
|
});
|
|
339
339
|
const restTags: Array<React.ReactNode> = [];
|
|
@@ -372,13 +372,18 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
372
372
|
tags.push(item);
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
|
+
|
|
376
|
+
const restTagsContent = (
|
|
377
|
+
<span className={restTagsCls}>+{tagsArray.length - maxTagCount}</span>
|
|
378
|
+
);
|
|
379
|
+
|
|
375
380
|
return (
|
|
376
381
|
<>
|
|
377
382
|
{tags}
|
|
378
383
|
{
|
|
379
384
|
restTags.length > 0 &&
|
|
380
385
|
(
|
|
381
|
-
showRestTagsPopover
|
|
386
|
+
showRestTagsPopover ?
|
|
382
387
|
(
|
|
383
388
|
<Popover
|
|
384
389
|
content={restTags}
|
|
@@ -388,16 +393,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
388
393
|
autoAdjustOverflow
|
|
389
394
|
{...restTagsPopoverProps}
|
|
390
395
|
>
|
|
391
|
-
|
|
392
|
-
+{tagsArray.length - maxTagCount}
|
|
393
|
-
</span>
|
|
396
|
+
{restTagsContent}
|
|
394
397
|
</Popover>
|
|
395
|
-
) :
|
|
396
|
-
(
|
|
397
|
-
<span className={spanNotWithPopoverCls}>
|
|
398
|
-
{`+${tagsArray.length - maxTagCount}`}
|
|
399
|
-
</span>
|
|
400
|
-
)
|
|
398
|
+
) : restTagsContent
|
|
401
399
|
)
|
|
402
400
|
}
|
|
403
401
|
</>
|
|
@@ -957,3 +957,155 @@ export const CustomListOperation = () => {
|
|
|
957
957
|
CustomListOperation.story = {
|
|
958
958
|
name: 'custom list operation',
|
|
959
959
|
}
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
export const TestReplaceFunc = () => (
|
|
963
|
+
<>
|
|
964
|
+
<Upload
|
|
965
|
+
{...commonProps}
|
|
966
|
+
action={action}
|
|
967
|
+
accept=".md,image/*,video/*"
|
|
968
|
+
maxSize={mb1}
|
|
969
|
+
minSize={0}
|
|
970
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
971
|
+
>
|
|
972
|
+
<Button icon={<IconUpload />} theme="light">
|
|
973
|
+
点击上传(最小0kB,最大1MB)
|
|
974
|
+
</Button>
|
|
975
|
+
</Upload>
|
|
976
|
+
<Upload
|
|
977
|
+
{...commonProps}
|
|
978
|
+
action={action}
|
|
979
|
+
accept="image/*"
|
|
980
|
+
maxSize={mb1}
|
|
981
|
+
minSize={0}
|
|
982
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
983
|
+
>
|
|
984
|
+
<Button icon={<IconUpload />} theme="light">
|
|
985
|
+
只接受image点击上传(最小0kB,最大1MB)
|
|
986
|
+
</Button>
|
|
987
|
+
</Upload>
|
|
988
|
+
<Upload
|
|
989
|
+
{...commonProps}
|
|
990
|
+
action={action}
|
|
991
|
+
accept=".md,image/*,video/*"
|
|
992
|
+
maxSize={mb1}
|
|
993
|
+
minSize={kb2}
|
|
994
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
995
|
+
>
|
|
996
|
+
<Button icon={<IconUpload />} theme="light">
|
|
997
|
+
点击上传(最小200kB,最大1MB)
|
|
998
|
+
</Button>
|
|
999
|
+
</Upload>
|
|
1000
|
+
</>
|
|
1001
|
+
);
|
|
1002
|
+
|
|
1003
|
+
TestReplaceFunc.story = {
|
|
1004
|
+
name: 'test replace func',
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
class InsertUpload extends React.Component {
|
|
1009
|
+
constructor() {
|
|
1010
|
+
super();
|
|
1011
|
+
this.onFileChange = this.onFileChange.bind(this);
|
|
1012
|
+
this.insert1 = this.insert1.bind(this);
|
|
1013
|
+
this.insert2 = this.insert2.bind(this);
|
|
1014
|
+
this.insert3 = this.insert3.bind(this);
|
|
1015
|
+
this.uploadRef1 = React.createRef();
|
|
1016
|
+
this.uploadRef2 = React.createRef();
|
|
1017
|
+
this.uploadRef3 = React.createRef();
|
|
1018
|
+
this.file = null;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
onFileChange(file) {
|
|
1022
|
+
delete file[0].uid;
|
|
1023
|
+
this.file = file;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
insert1() {
|
|
1027
|
+
// test file number limit
|
|
1028
|
+
this.uploadRef1.current.insert(this.file, 0);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
insert2() {
|
|
1032
|
+
this.uploadRef2.current.insert(this.file, 0);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
insert3() {
|
|
1036
|
+
// test size limit
|
|
1037
|
+
this.uploadRef3.current.insert(this.file, 0);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
render() {
|
|
1041
|
+
let action = 'https://run.mocky.io/v3/d6ac5c9e-4d39-4309-a747-7ed3b5694859';
|
|
1042
|
+
return (
|
|
1043
|
+
<div>
|
|
1044
|
+
<Upload
|
|
1045
|
+
action={action}
|
|
1046
|
+
ref={this.uploadRef1}
|
|
1047
|
+
accept=".md,image/*,video/*"
|
|
1048
|
+
onSuccess={(...v) => console.log(...v)}
|
|
1049
|
+
onError={(...v) => console.log(...v)}
|
|
1050
|
+
onFileChange={this.onFileChange}
|
|
1051
|
+
maxSize={mb1}
|
|
1052
|
+
minSize={0}
|
|
1053
|
+
limit={1}
|
|
1054
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
1055
|
+
>
|
|
1056
|
+
<Button icon={<IconPlus />} theme="light" style={{ marginRight: 8 }}>
|
|
1057
|
+
选择文件 limit 1
|
|
1058
|
+
</Button>
|
|
1059
|
+
</Upload>
|
|
1060
|
+
<Upload
|
|
1061
|
+
action={action}
|
|
1062
|
+
ref={this.uploadRef2}
|
|
1063
|
+
accept=".md,image/*,video/*"
|
|
1064
|
+
onSuccess={(...v) => console.log(...v)}
|
|
1065
|
+
onError={(...v) => console.log(...v)}
|
|
1066
|
+
onFileChange={this.onFileChange}
|
|
1067
|
+
maxSize={mb1}
|
|
1068
|
+
minSize={0}
|
|
1069
|
+
limit={2}
|
|
1070
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
1071
|
+
>
|
|
1072
|
+
<Button icon={<IconPlus />} theme="light" style={{ marginRight: 8 }}>
|
|
1073
|
+
选择文件 limit 2
|
|
1074
|
+
</Button>
|
|
1075
|
+
</Upload>
|
|
1076
|
+
<Upload
|
|
1077
|
+
{...commonProps}
|
|
1078
|
+
action={action}
|
|
1079
|
+
ref={this.uploadRef3}
|
|
1080
|
+
accept=".md,image/*,video/*"
|
|
1081
|
+
onSuccess={(...v) => console.log(...v)}
|
|
1082
|
+
onError={(...v) => console.log(...v)}
|
|
1083
|
+
onFileChange={this.onFileChange}
|
|
1084
|
+
maxSize={mb1}
|
|
1085
|
+
minSize={kb2}
|
|
1086
|
+
limit={1}
|
|
1087
|
+
transformFile={(fileInstance)=>{return fileInstance;}}
|
|
1088
|
+
>
|
|
1089
|
+
<Button icon={<IconPlus />} theme="light" style={{ marginRight: 8 }}>
|
|
1090
|
+
选择文件 size 限制
|
|
1091
|
+
</Button>
|
|
1092
|
+
</Upload>
|
|
1093
|
+
<Button icon={<IconUpload />} theme="light" onClick={this.insert1}>
|
|
1094
|
+
插入首项上传1
|
|
1095
|
+
</Button>
|
|
1096
|
+
<Button icon={<IconUpload />} theme="light" onClick={this.insert2}>
|
|
1097
|
+
插入首项上传2
|
|
1098
|
+
</Button>
|
|
1099
|
+
<Button icon={<IconUpload />} theme="light" onClick={this.insert3}>
|
|
1100
|
+
插入首项上传3
|
|
1101
|
+
</Button>
|
|
1102
|
+
</div>
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
export const Insert = () => <InsertUpload></InsertUpload>;
|
|
1108
|
+
|
|
1109
|
+
Insert.story = {
|
|
1110
|
+
name: 'insert',
|
|
1111
|
+
};
|