@douyinfe/semi-ui 2.14.0-alpha.0 → 2.14.0-beta.2
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/autoComplete/_story/CustomTrigger/index.jsx +1 -1
- package/avatar/_story/avatar.stories.js +62 -5
- package/avatar/avatarGroup.tsx +16 -4
- package/avatar/index.tsx +88 -17
- package/backtop/index.tsx +11 -7
- package/badge/index.tsx +1 -1
- package/banner/index.tsx +5 -5
- package/breadcrumb/index.tsx +5 -3
- package/button/Button.tsx +10 -8
- package/calendar/_story/calendar.stories.js +125 -1
- package/card/index.tsx +43 -41
- package/carousel/CarouselArrow.tsx +2 -0
- package/carousel/index.tsx +1 -0
- package/cascader/_story/cascader.stories.js +21 -0
- package/cascader/index.tsx +103 -122
- package/cascader/item.tsx +1 -1
- package/checkbox/checkbox.tsx +13 -2
- package/collapsible/index.tsx +8 -1
- package/datePicker/dateInput.tsx +1 -0
- package/datePicker/datePicker.tsx +13 -5
- package/dist/css/semi.css +73 -35
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +957 -545
- 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/divider/index.tsx +8 -4
- package/dropdown/index.tsx +1 -1
- package/empty/index.tsx +13 -5
- package/form/_story/form.stories.tsx +9 -2
- package/form/field.tsx +1 -1
- package/form/hoc/withField.tsx +1 -1
- package/form/label.tsx +1 -1
- package/grid/col.tsx +1 -1
- package/grid/row.tsx +1 -1
- package/gulpfile.js +5 -5
- package/iconButton/index.tsx +2 -1
- package/input/_story/input.stories.js +32 -3
- package/input/index.tsx +45 -23
- package/input/inputGroup.tsx +3 -1
- package/input/textarea.tsx +2 -14
- package/lib/cjs/_base/base.css +36 -14
- package/lib/cjs/avatar/avatarGroup.d.ts +1 -1
- package/lib/cjs/avatar/avatarGroup.js +36 -9
- package/lib/cjs/avatar/index.d.ts +5 -0
- package/lib/cjs/avatar/index.js +121 -41
- package/lib/cjs/backtop/index.js +2 -1
- package/lib/cjs/badge/index.js +2 -1
- package/lib/cjs/banner/index.js +9 -4
- package/lib/cjs/breadcrumb/index.js +4 -3
- package/lib/cjs/button/Button.js +13 -3
- package/lib/cjs/card/index.js +10 -5
- package/lib/cjs/carousel/CarouselArrow.js +6 -2
- package/lib/cjs/carousel/index.js +2 -1
- package/lib/cjs/cascader/index.js +15 -8
- package/lib/cjs/cascader/item.js +2 -1
- package/lib/cjs/checkbox/checkbox.js +6 -2
- package/lib/cjs/collapsible/index.js +2 -1
- package/lib/cjs/datePicker/dateInput.js +2 -1
- package/lib/cjs/datePicker/datePicker.js +4 -2
- package/lib/cjs/divider/index.js +2 -1
- package/lib/cjs/dropdown/index.js +2 -1
- package/lib/cjs/empty/index.js +8 -4
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/field.js +2 -2
- package/lib/cjs/form/hoc/withField.js +2 -1
- package/lib/cjs/form/label.js +2 -1
- package/lib/cjs/grid/col.js +2 -1
- package/lib/cjs/grid/row.js +2 -1
- package/lib/cjs/iconButton/index.js +3 -1
- package/lib/cjs/input/index.d.ts +0 -1
- package/lib/cjs/input/index.js +41 -36
- package/lib/cjs/input/inputGroup.js +2 -3
- package/lib/cjs/input/textarea.js +8 -15
- package/lib/cjs/list/index.js +6 -3
- package/lib/cjs/modal/ConfirmModal.js +2 -1
- package/lib/cjs/modal/Modal.js +6 -2
- package/lib/cjs/modal/ModalContent.js +13 -6
- package/lib/cjs/notification/notice.js +6 -3
- package/lib/cjs/pagination/index.js +4 -2
- package/lib/cjs/popconfirm/index.js +6 -3
- package/lib/cjs/radio/radio.d.ts +4 -0
- package/lib/cjs/radio/radio.js +32 -9
- package/lib/cjs/radio/radioInner.d.ts +6 -0
- package/lib/cjs/radio/radioInner.js +13 -4
- package/lib/cjs/rating/item.js +2 -1
- package/lib/cjs/scrollList/index.js +6 -3
- package/lib/cjs/select/index.js +10 -4
- package/lib/cjs/select/option.js +2 -1
- package/lib/cjs/sideSheet/SideSheetContent.js +6 -3
- package/lib/cjs/skeleton/index.js +3 -1
- package/lib/cjs/space/index.js +2 -1
- package/lib/cjs/spin/index.js +7 -3
- package/lib/cjs/switch/index.js +6 -4
- package/lib/cjs/table/ColumnFilter.js +2 -2
- package/lib/cjs/table/ColumnSelection.js +2 -2
- package/lib/cjs/table/Table.js +6 -3
- package/lib/cjs/tabs/TabBar.js +2 -1
- package/lib/cjs/tabs/TabPane.js +5 -2
- package/lib/cjs/tagInput/index.js +33 -22
- package/lib/cjs/timePicker/Combobox.js +3 -1
- package/lib/cjs/timePicker/TimePicker.js +2 -0
- package/lib/cjs/toast/toast.js +6 -3
- package/lib/cjs/tooltip/index.js +6 -1
- package/lib/cjs/transfer/index.js +6 -5
- package/lib/cjs/tree/treeNode.js +4 -3
- package/lib/cjs/treeSelect/index.js +10 -3
- package/lib/cjs/typography/base.js +2 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/cjs/upload/index.js +13 -6
- package/lib/es/_base/base.css +36 -14
- package/lib/es/avatar/avatarGroup.d.ts +1 -1
- package/lib/es/avatar/avatarGroup.js +37 -9
- package/lib/es/avatar/index.d.ts +5 -0
- package/lib/es/avatar/index.js +119 -38
- package/lib/es/backtop/index.js +2 -1
- package/lib/es/badge/index.js +2 -1
- package/lib/es/banner/index.js +9 -4
- package/lib/es/breadcrumb/index.js +4 -3
- package/lib/es/button/Button.js +11 -3
- package/lib/es/card/index.js +10 -5
- package/lib/es/carousel/CarouselArrow.js +6 -2
- package/lib/es/carousel/index.js +2 -1
- package/lib/es/cascader/index.js +15 -8
- package/lib/es/cascader/item.js +2 -1
- package/lib/es/checkbox/checkbox.js +6 -2
- package/lib/es/collapsible/index.js +2 -1
- package/lib/es/datePicker/dateInput.js +2 -1
- package/lib/es/datePicker/datePicker.js +4 -2
- package/lib/es/divider/index.js +2 -1
- package/lib/es/dropdown/index.js +2 -1
- package/lib/es/empty/index.js +8 -4
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/field.js +1 -1
- package/lib/es/form/hoc/withField.js +2 -1
- package/lib/es/form/label.js +2 -1
- package/lib/es/grid/col.js +2 -1
- package/lib/es/grid/row.js +2 -1
- package/lib/es/iconButton/index.js +3 -1
- package/lib/es/input/index.d.ts +0 -1
- package/lib/es/input/index.js +41 -36
- package/lib/es/input/inputGroup.js +2 -3
- package/lib/es/input/textarea.js +8 -15
- package/lib/es/list/index.js +6 -3
- package/lib/es/modal/ConfirmModal.js +2 -1
- package/lib/es/modal/Modal.js +6 -2
- package/lib/es/modal/ModalContent.js +13 -6
- package/lib/es/notification/notice.js +6 -3
- package/lib/es/pagination/index.js +4 -2
- package/lib/es/popconfirm/index.js +6 -3
- package/lib/es/radio/radio.d.ts +4 -0
- package/lib/es/radio/radio.js +32 -9
- package/lib/es/radio/radioInner.d.ts +6 -0
- package/lib/es/radio/radioInner.js +13 -4
- package/lib/es/rating/item.js +2 -1
- package/lib/es/scrollList/index.js +6 -3
- package/lib/es/select/index.js +10 -4
- package/lib/es/select/option.js +2 -1
- package/lib/es/sideSheet/SideSheetContent.js +6 -3
- package/lib/es/skeleton/index.js +3 -1
- package/lib/es/space/index.js +2 -1
- package/lib/es/spin/index.js +7 -3
- package/lib/es/switch/index.js +6 -4
- package/lib/es/table/ColumnFilter.js +1 -1
- package/lib/es/table/ColumnSelection.js +1 -1
- package/lib/es/table/Table.js +6 -3
- package/lib/es/tabs/TabBar.js +2 -1
- package/lib/es/tabs/TabPane.js +5 -2
- package/lib/es/tagInput/index.js +31 -22
- package/lib/es/timePicker/Combobox.js +3 -1
- package/lib/es/timePicker/TimePicker.js +2 -0
- package/lib/es/toast/toast.js +6 -3
- package/lib/es/tooltip/index.js +6 -1
- package/lib/es/transfer/index.js +3 -2
- package/lib/es/tree/treeNode.js +3 -2
- package/lib/es/treeSelect/index.js +10 -3
- package/lib/es/typography/base.js +2 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +1 -1
- package/lib/es/upload/index.js +13 -6
- package/list/index.tsx +16 -4
- package/modal/ConfirmModal.tsx +1 -1
- package/modal/Modal.tsx +2 -0
- package/modal/ModalContent.tsx +27 -14
- package/notification/notice.tsx +16 -4
- package/package.json +8 -8
- package/pagination/index.tsx +16 -2
- package/popconfirm/index.tsx +11 -3
- package/radio/_story/radio.stories.js +9 -6
- package/radio/radio.tsx +37 -7
- package/radio/radioInner.tsx +11 -2
- package/rating/item.tsx +1 -1
- package/scrollList/index.tsx +19 -3
- package/select/index.tsx +13 -4
- package/select/option.tsx +5 -1
- package/sideSheet/SideSheetContent.tsx +3 -3
- package/skeleton/index.tsx +1 -1
- package/space/index.tsx +1 -1
- package/spin/index.tsx +15 -9
- package/switch/index.tsx +9 -14
- package/table/ColumnFilter.tsx +1 -1
- package/table/ColumnSelection.tsx +1 -1
- package/table/Table.tsx +5 -3
- package/table/_story/v2/FixedOnHeaderRow/index.jsx +3 -0
- package/tabs/TabBar.tsx +1 -1
- package/tabs/TabPane.tsx +9 -4
- package/tabs/_story/tabs.stories.js +36 -0
- package/tag/_story/tag.stories.js +1 -1
- package/tagInput/index.tsx +32 -15
- package/timePicker/Combobox.tsx +6 -1
- package/timePicker/TimePicker.tsx +1 -0
- package/toast/toast.tsx +3 -3
- package/tooltip/index.tsx +4 -1
- package/transfer/index.tsx +2 -1
- package/tree/treeNode.tsx +2 -2
- package/treeSelect/_story/treeSelect.stories.js +161 -2
- package/treeSelect/index.tsx +17 -3
- package/typography/base.tsx +1 -1
- package/upload/_story/upload.stories.js +152 -0
- package/upload/index.tsx +107 -38
package/tagInput/index.tsx
CHANGED
|
@@ -238,6 +238,7 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
238
238
|
this.foundation.handleClearBtn(e);
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
+
/* istanbul ignore next */
|
|
241
242
|
handleClearEnterPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
242
243
|
this.foundation.handleClearEnterPress(e);
|
|
243
244
|
};
|
|
@@ -298,8 +299,17 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
298
299
|
// eslint-disable-next-line max-len
|
|
299
300
|
[`${prefixCls}-prefix-icon`]: isSemiIcon(labelNode),
|
|
300
301
|
});
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
return (
|
|
303
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
|
|
304
|
+
<div
|
|
305
|
+
className={prefixWrapperCls}
|
|
306
|
+
onMouseDown={this.handlePreventMouseDown}
|
|
307
|
+
onClick={this.handleClickPrefixOrSuffix}
|
|
308
|
+
id={insetLabelId} x-semi-prop="prefix"
|
|
309
|
+
>
|
|
310
|
+
{labelNode}
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
303
313
|
}
|
|
304
314
|
|
|
305
315
|
renderSuffix() {
|
|
@@ -312,8 +322,17 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
312
322
|
// eslint-disable-next-line max-len
|
|
313
323
|
[`${prefixCls}-suffix-icon`]: isSemiIcon(suffix),
|
|
314
324
|
});
|
|
315
|
-
|
|
316
|
-
|
|
325
|
+
return (
|
|
326
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
327
|
+
<div
|
|
328
|
+
className={suffixWrapperCls}
|
|
329
|
+
onMouseDown={this.handlePreventMouseDown}
|
|
330
|
+
onClick={this.handleClickPrefixOrSuffix}
|
|
331
|
+
x-semi-prop="suffix"
|
|
332
|
+
>
|
|
333
|
+
{suffix}
|
|
334
|
+
</div>
|
|
335
|
+
);
|
|
317
336
|
}
|
|
318
337
|
|
|
319
338
|
renderTags() {
|
|
@@ -333,7 +352,7 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
333
352
|
const typoCls = cls(`${prefixCls}-wrapper-typo`, {
|
|
334
353
|
[`${prefixCls}-wrapper-typo-disabled`]: disabled
|
|
335
354
|
});
|
|
336
|
-
const
|
|
355
|
+
const restTagsCls = cls(`${prefixCls}-wrapper-n`, {
|
|
337
356
|
[`${prefixCls}-wrapper-n-disabled`]: disabled
|
|
338
357
|
});
|
|
339
358
|
const restTags: Array<React.ReactNode> = [];
|
|
@@ -372,13 +391,18 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
372
391
|
tags.push(item);
|
|
373
392
|
}
|
|
374
393
|
});
|
|
394
|
+
|
|
395
|
+
const restTagsContent = (
|
|
396
|
+
<span className={restTagsCls}>+{tagsArray.length - maxTagCount}</span>
|
|
397
|
+
);
|
|
398
|
+
|
|
375
399
|
return (
|
|
376
400
|
<>
|
|
377
401
|
{tags}
|
|
378
402
|
{
|
|
379
403
|
restTags.length > 0 &&
|
|
380
404
|
(
|
|
381
|
-
showRestTagsPopover
|
|
405
|
+
showRestTagsPopover ?
|
|
382
406
|
(
|
|
383
407
|
<Popover
|
|
384
408
|
content={restTags}
|
|
@@ -388,16 +412,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
388
412
|
autoAdjustOverflow
|
|
389
413
|
{...restTagsPopoverProps}
|
|
390
414
|
>
|
|
391
|
-
|
|
392
|
-
+{tagsArray.length - maxTagCount}
|
|
393
|
-
</span>
|
|
415
|
+
{restTagsContent}
|
|
394
416
|
</Popover>
|
|
395
|
-
) :
|
|
396
|
-
(
|
|
397
|
-
<span className={spanNotWithPopoverCls}>
|
|
398
|
-
{`+${tagsArray.length - maxTagCount}`}
|
|
399
|
-
</span>
|
|
400
|
-
)
|
|
417
|
+
) : restTagsContent
|
|
401
418
|
)
|
|
402
419
|
}
|
|
403
420
|
</>
|
package/timePicker/Combobox.tsx
CHANGED
|
@@ -317,7 +317,12 @@ class Combobox extends BaseComponent<ComboboxProps, ComboboxState> {
|
|
|
317
317
|
return (
|
|
318
318
|
<LocaleConsumer componentName="TimePicker">
|
|
319
319
|
{(locale: Locale['TimePicker'], localeCode: Locale['code']) => (
|
|
320
|
-
<ScrollList
|
|
320
|
+
<ScrollList
|
|
321
|
+
header={panelHeader}
|
|
322
|
+
footer={panelFooter}
|
|
323
|
+
x-semi-header-alias="panelHeader"
|
|
324
|
+
x-semi-footer-alias="panelFooter"
|
|
325
|
+
>
|
|
321
326
|
{this.renderAMPMSelect(locale, localeCode)}
|
|
322
327
|
{this.renderHourSelect(value.getHours(), locale)}
|
|
323
328
|
{this.renderMinuteSelect(value.getMinutes(), locale)}
|
|
@@ -413,6 +413,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
413
413
|
// this.picker.blur();
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
/* istanbul ignore next */
|
|
416
417
|
handlePanelVisibleChange = (visible: boolean) => this.foundation.handleVisibleChange(visible);
|
|
417
418
|
|
|
418
419
|
openPanel = () => {
|
package/toast/toast.tsx
CHANGED
|
@@ -120,7 +120,7 @@ class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
120
120
|
const btnSize = 'small';
|
|
121
121
|
return (
|
|
122
122
|
<div
|
|
123
|
-
role=
|
|
123
|
+
role="alert"
|
|
124
124
|
aria-label={`${type ? type : 'default'} type`}
|
|
125
125
|
className={toastCls}
|
|
126
126
|
style={style}
|
|
@@ -129,7 +129,7 @@ class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
129
129
|
>
|
|
130
130
|
<div className={`${prefixCls}-content`}>
|
|
131
131
|
{this.renderIcon()}
|
|
132
|
-
<span className={`${prefixCls}-content-text`} style={textStyle}>
|
|
132
|
+
<span className={`${prefixCls}-content-text`} style={textStyle} x-semi-prop="content">
|
|
133
133
|
{content}
|
|
134
134
|
</span>
|
|
135
135
|
{showClose && (
|
|
@@ -137,7 +137,7 @@ class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
137
137
|
<Button
|
|
138
138
|
onClick={e => this.close(e)}
|
|
139
139
|
type="tertiary"
|
|
140
|
-
icon={<IconClose />}
|
|
140
|
+
icon={<IconClose x-semi-prop="icon" />}
|
|
141
141
|
theme={btnTheme}
|
|
142
142
|
size={btnSize}
|
|
143
143
|
/>
|
package/tooltip/index.tsx
CHANGED
|
@@ -664,7 +664,10 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
children = cloneElement(children as React.ReactElement, { style: childrenStyle });
|
|
667
|
-
|
|
667
|
+
if (trigger !== 'custom') {
|
|
668
|
+
// no need to wrap span when trigger is custom, cause it don't need bind event
|
|
669
|
+
children = this.wrapSpan(children);
|
|
670
|
+
}
|
|
668
671
|
this.isWrapped = true;
|
|
669
672
|
} else if (!isValidElement(children)) {
|
|
670
673
|
children = this.wrapSpan(children);
|
package/transfer/index.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import '@douyinfe/semi-foundation/transfer/transfer.scss';
|
|
|
10
10
|
import BaseComponent from '../_base/baseComponent';
|
|
11
11
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
12
12
|
import { Locale } from '../locale/interface';
|
|
13
|
-
import Checkbox from '../checkbox';
|
|
13
|
+
import { Checkbox } from '../checkbox/index';
|
|
14
14
|
import Input, { InputProps } from '../input/index';
|
|
15
15
|
import Spin from '../spin';
|
|
16
16
|
import Button from '../button';
|
|
@@ -353,6 +353,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
|
|
|
353
353
|
checked={checked}
|
|
354
354
|
role="listitem"
|
|
355
355
|
onChange={() => this.onSelectOrRemove(item)}
|
|
356
|
+
x-semi-children-alias={`dataSource[${index}].label`}
|
|
356
357
|
>
|
|
357
358
|
{item.label}
|
|
358
359
|
</Checkbox>
|
package/tree/treeNode.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { cssClasses } from '@douyinfe/semi-foundation/tree/constants';
|
|
|
5
5
|
import isEnterPress from '@douyinfe/semi-foundation/utils/isEnterPress';
|
|
6
6
|
import { debounce, isFunction, isString, get, isEmpty } from 'lodash';
|
|
7
7
|
import { IconTreeTriangleDown, IconFile, IconFolder, IconFolderOpen } from '@douyinfe/semi-icons';
|
|
8
|
-
import Checkbox from '../checkbox';
|
|
8
|
+
import { Checkbox } from '../checkbox';
|
|
9
9
|
import TreeContext, { TreeContextValue } from './treeContext';
|
|
10
10
|
import Spin from '../spin';
|
|
11
11
|
import { TreeNodeProps, TreeNodeState } from './interface';
|
|
@@ -269,7 +269,7 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
269
269
|
});
|
|
270
270
|
return (
|
|
271
271
|
<ul className={wrapperCls}>
|
|
272
|
-
<li className={`${prefixcls}-label ${prefixcls}-label-empty`}>
|
|
272
|
+
<li className={`${prefixcls}-label ${prefixcls}-label-empty`} x-semi-prop="emptyContent">
|
|
273
273
|
{emptyContent}
|
|
274
274
|
</li>
|
|
275
275
|
</ul>
|
|
@@ -1343,7 +1343,7 @@ export const CheckRelationDemo = () => {
|
|
|
1343
1343
|
defaultValue='China'
|
|
1344
1344
|
/>
|
|
1345
1345
|
<br /><br />
|
|
1346
|
-
<div
|
|
1346
|
+
<div>多选 + checkRelation='unRelated' + defaultValue 为 China + 开启搜索 + searchBox in trigger + showClear</div>
|
|
1347
1347
|
<TreeSelect
|
|
1348
1348
|
dropdownStyle={dropdownStyle}
|
|
1349
1349
|
treeData={treeData}
|
|
@@ -1354,6 +1354,19 @@ export const CheckRelationDemo = () => {
|
|
|
1354
1354
|
defaultExpandAll
|
|
1355
1355
|
style={style}
|
|
1356
1356
|
searchPosition='trigger'
|
|
1357
|
+
defaultValue={['China', 'Japan']}
|
|
1358
|
+
/>
|
|
1359
|
+
<br /><br />
|
|
1360
|
+
<div>单选 + checkRelation='unRelated' + defaultValue 为 China + 开启搜索 + searchBox in trigger + showClear</div>
|
|
1361
|
+
<TreeSelect
|
|
1362
|
+
dropdownStyle={dropdownStyle}
|
|
1363
|
+
treeData={treeData}
|
|
1364
|
+
filterTreeNode
|
|
1365
|
+
showClear
|
|
1366
|
+
checkRelation='unRelated'
|
|
1367
|
+
defaultExpandAll
|
|
1368
|
+
style={style}
|
|
1369
|
+
searchPosition='trigger'
|
|
1357
1370
|
defaultValue='China'
|
|
1358
1371
|
/>
|
|
1359
1372
|
<br /><br />
|
|
@@ -1459,4 +1472,150 @@ export const SearchableAndExpandedKeys = () => {
|
|
|
1459
1472
|
/>
|
|
1460
1473
|
</>
|
|
1461
1474
|
)
|
|
1462
|
-
}
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
export const loadData = () => {
|
|
1478
|
+
const initialData = [
|
|
1479
|
+
{
|
|
1480
|
+
label: 'Expand to load',
|
|
1481
|
+
value: '0',
|
|
1482
|
+
key: '0',
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
label: 'Expand to load',
|
|
1486
|
+
value: '1',
|
|
1487
|
+
key: '1',
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
label: 'Leaf Node',
|
|
1491
|
+
value: '2',
|
|
1492
|
+
key: '2',
|
|
1493
|
+
isLeaf: true,
|
|
1494
|
+
},
|
|
1495
|
+
];
|
|
1496
|
+
const [treeData, setTreeData] = useState(initialData);
|
|
1497
|
+
const [loadedKeys, setLoadedKeys] = useState(['2']);
|
|
1498
|
+
|
|
1499
|
+
function updateTreeData(list, key, children) {
|
|
1500
|
+
return list.map(node => {
|
|
1501
|
+
if (node.key === key) {
|
|
1502
|
+
return { ...node, children };
|
|
1503
|
+
}
|
|
1504
|
+
if (node.children) {
|
|
1505
|
+
return { ...node, children: updateTreeData(node.children, key, children) };
|
|
1506
|
+
}
|
|
1507
|
+
return node;
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
function onLoadData({ key, children }) {
|
|
1512
|
+
return new Promise(resolve => {
|
|
1513
|
+
if (children) {
|
|
1514
|
+
resolve();
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
setTimeout(() => {
|
|
1518
|
+
setTreeData(origin =>
|
|
1519
|
+
updateTreeData(origin, key, [
|
|
1520
|
+
{
|
|
1521
|
+
label: 'Child Node',
|
|
1522
|
+
key: `${key}-0`,
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
label: 'Child Node',
|
|
1526
|
+
key: `${key}-1`,
|
|
1527
|
+
},
|
|
1528
|
+
]),
|
|
1529
|
+
);
|
|
1530
|
+
resolve();
|
|
1531
|
+
}, 1000);
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
return (
|
|
1535
|
+
<TreeSelect
|
|
1536
|
+
loadData={onLoadData}
|
|
1537
|
+
filterTreeNode
|
|
1538
|
+
treeData={treeData}
|
|
1539
|
+
style={{ width: 300 }}
|
|
1540
|
+
placeholder="请选择"
|
|
1541
|
+
/>
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
export const loadDataAndLoadedkeys = () => {
|
|
1547
|
+
const initialData = [
|
|
1548
|
+
{
|
|
1549
|
+
label: 'Expand to load',
|
|
1550
|
+
value: '0',
|
|
1551
|
+
key: '0',
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
label: 'Expand to load',
|
|
1555
|
+
value: '1',
|
|
1556
|
+
key: '1',
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
label: 'Leaf Node',
|
|
1560
|
+
value: '2',
|
|
1561
|
+
key: '2',
|
|
1562
|
+
isLeaf: true,
|
|
1563
|
+
},
|
|
1564
|
+
];
|
|
1565
|
+
const [treeData, setTreeData] = useState(initialData);
|
|
1566
|
+
const [loadedKeys, setLoadedKeys] = useState(['2']);
|
|
1567
|
+
|
|
1568
|
+
function updateTreeData(list, key, children) {
|
|
1569
|
+
return list.map(node => {
|
|
1570
|
+
if (node.key === key) {
|
|
1571
|
+
return { ...node, children };
|
|
1572
|
+
}
|
|
1573
|
+
if (node.children) {
|
|
1574
|
+
return { ...node, children: updateTreeData(node.children, key, children) };
|
|
1575
|
+
}
|
|
1576
|
+
return node;
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
function updateLoadedKeys(key) {
|
|
1581
|
+
if(!loadedKeys.includes(key)){
|
|
1582
|
+
setLoadedKeys([...loadedKeys, key]);
|
|
1583
|
+
console.log('[...loadedKeys, key]', [...loadedKeys, key]);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
function onLoadData({ key, children }) {
|
|
1588
|
+
return new Promise(resolve => {
|
|
1589
|
+
if (children) {
|
|
1590
|
+
resolve();
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
setTimeout(() => {
|
|
1594
|
+
setTreeData(origin =>
|
|
1595
|
+
updateTreeData(origin, key, [
|
|
1596
|
+
{
|
|
1597
|
+
label: 'Child Node',
|
|
1598
|
+
key: `${key}-0`,
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
label: 'Child Node',
|
|
1602
|
+
key: `${key}-1`,
|
|
1603
|
+
},
|
|
1604
|
+
]),
|
|
1605
|
+
);
|
|
1606
|
+
// updateLoadedKeys(key);
|
|
1607
|
+
resolve();
|
|
1608
|
+
}, 1000);
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
return (
|
|
1612
|
+
<TreeSelect
|
|
1613
|
+
loadData={onLoadData}
|
|
1614
|
+
filterTreeNode
|
|
1615
|
+
// loadedKeys={loadedKeys}
|
|
1616
|
+
treeData={treeData}
|
|
1617
|
+
style={{ width: 300 }}
|
|
1618
|
+
placeholder="请选择"
|
|
1619
|
+
/>
|
|
1620
|
+
);
|
|
1621
|
+
}
|
package/treeSelect/index.tsx
CHANGED
|
@@ -646,7 +646,11 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
646
646
|
[`${prefixcls}-suffix-text`]: suffix && isString(suffix),
|
|
647
647
|
[`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
|
|
648
648
|
});
|
|
649
|
-
return
|
|
649
|
+
return (
|
|
650
|
+
<div className={suffixWrapperCls} x-semi-prop="suffix">
|
|
651
|
+
{suffix}
|
|
652
|
+
</div>
|
|
653
|
+
);
|
|
650
654
|
};
|
|
651
655
|
|
|
652
656
|
renderPrefix = () => {
|
|
@@ -660,7 +664,11 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
660
664
|
[`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
|
|
661
665
|
});
|
|
662
666
|
|
|
663
|
-
return
|
|
667
|
+
return (
|
|
668
|
+
<div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
|
|
669
|
+
{labelNode}
|
|
670
|
+
</div>
|
|
671
|
+
);
|
|
664
672
|
};
|
|
665
673
|
|
|
666
674
|
renderContent = () => {
|
|
@@ -683,6 +691,7 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
683
691
|
this.foundation.handleClick(e);
|
|
684
692
|
};
|
|
685
693
|
|
|
694
|
+
/* istanbul ignore next */
|
|
686
695
|
handleSelectionEnterPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
687
696
|
this.foundation.handleSelectionEnterPress(e);
|
|
688
697
|
};
|
|
@@ -840,6 +849,7 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
840
849
|
this.foundation.handleClear(e);
|
|
841
850
|
};
|
|
842
851
|
|
|
852
|
+
/* istanbul ignore next */
|
|
843
853
|
handleClearEnterPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
844
854
|
e && e.stopPropagation();
|
|
845
855
|
this.foundation.handleClearEnterPress(e);
|
|
@@ -867,7 +877,11 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
867
877
|
if (showClearBtn) {
|
|
868
878
|
return null;
|
|
869
879
|
}
|
|
870
|
-
return arrowIcon ?
|
|
880
|
+
return arrowIcon ? (
|
|
881
|
+
<div className={cls(`${prefixcls}-arrow`)} x-semi-prop="arrowIcon">
|
|
882
|
+
{arrowIcon}
|
|
883
|
+
</div>
|
|
884
|
+
) : null;
|
|
871
885
|
};
|
|
872
886
|
|
|
873
887
|
renderClearBtn = () => {
|
package/typography/base.tsx
CHANGED
|
@@ -526,7 +526,7 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
|
|
|
526
526
|
}
|
|
527
527
|
const iconSize: Size = size === 'small' ? 'small' : 'default';
|
|
528
528
|
return (
|
|
529
|
-
<span className={`${prefixCls}-icon`}>
|
|
529
|
+
<span className={`${prefixCls}-icon`} x-semi-prop="icon">
|
|
530
530
|
{isSemiIcon(icon) ? React.cloneElement((icon as React.ReactElement), { size: iconSize }) : icon}
|
|
531
531
|
</span>
|
|
532
532
|
);
|
|
@@ -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
|
+
};
|