@douyinfe/semi-ui 2.17.0-alpha.1 → 2.17.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/_base/_story/a11y.jsx +2 -2
- package/avatar/__test__/avatar.test.js +3 -3
- package/avatar/interface.ts +1 -1
- package/cascader/_story/cascader.stories.js +91 -1
- package/cascader/index.tsx +35 -26
- package/checkbox/checkbox.tsx +4 -1
- package/collapse/__test__/collapse.test.js +22 -2
- package/collapse/_story/accordion.stories.js +2 -2
- package/collapse/item.tsx +20 -6
- package/collapsible/_story/collapsible.stories.js +6 -6
- package/configProvider/_story/RTLDirection/RTLForm.jsx +1 -1
- package/datePicker/__test__/datePicker.test.js +5 -5
- package/datePicker/_story/datePicker.stories.js +138 -22
- package/datePicker/datePicker.tsx +42 -7
- package/datePicker/monthsGrid.tsx +22 -10
- package/datePicker/quickControl.tsx +62 -16
- package/datePicker/yearAndMonth.tsx +31 -5
- package/dist/css/semi.css +328 -47
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +36811 -36304
- 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/empty/index.tsx +3 -3
- package/lib/cjs/avatar/interface.d.ts +1 -1
- package/lib/cjs/cascader/index.js +36 -25
- package/lib/cjs/checkbox/checkbox.js +4 -1
- package/lib/cjs/collapse/item.d.ts +8 -0
- package/lib/cjs/collapse/item.js +19 -8
- package/lib/cjs/datePicker/datePicker.d.ts +3 -0
- package/lib/cjs/datePicker/datePicker.js +56 -9
- package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
- package/lib/cjs/datePicker/monthsGrid.js +14 -3
- package/lib/cjs/datePicker/quickControl.d.ts +6 -0
- package/lib/cjs/datePicker/quickControl.js +61 -14
- package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/cjs/datePicker/yearAndMonth.js +15 -3
- package/lib/cjs/empty/index.js +1 -1
- package/lib/cjs/popover/index.d.ts +3 -0
- package/lib/cjs/popover/index.js +4 -2
- package/lib/cjs/select/index.d.ts +6 -1
- package/lib/cjs/select/index.js +130 -72
- package/lib/cjs/select/option.js +4 -2
- package/lib/cjs/tag/index.js +6 -4
- package/lib/cjs/tag/interface.d.ts +1 -0
- package/lib/cjs/tagInput/index.d.ts +13 -1
- package/lib/cjs/tagInput/index.js +217 -91
- package/lib/cjs/timePicker/TimePicker.js +1 -1
- package/lib/cjs/tooltip/index.d.ts +4 -0
- package/lib/cjs/tooltip/index.js +5 -3
- package/lib/cjs/typography/base.js +3 -15
- package/lib/cjs/typography/text.js +1 -11
- package/lib/es/avatar/interface.d.ts +1 -1
- package/lib/es/cascader/index.js +40 -29
- package/lib/es/checkbox/checkbox.js +4 -1
- package/lib/es/collapse/item.d.ts +8 -0
- package/lib/es/collapse/item.js +19 -8
- package/lib/es/datePicker/datePicker.d.ts +3 -0
- package/lib/es/datePicker/datePicker.js +56 -9
- package/lib/es/datePicker/monthsGrid.d.ts +3 -0
- package/lib/es/datePicker/monthsGrid.js +14 -3
- package/lib/es/datePicker/quickControl.d.ts +6 -0
- package/lib/es/datePicker/quickControl.js +61 -15
- package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/es/datePicker/yearAndMonth.js +14 -3
- package/lib/es/empty/index.js +1 -1
- package/lib/es/popover/index.d.ts +3 -0
- package/lib/es/popover/index.js +4 -2
- package/lib/es/select/index.d.ts +6 -1
- package/lib/es/select/index.js +129 -71
- package/lib/es/select/option.js +4 -2
- package/lib/es/tag/index.js +6 -4
- package/lib/es/tag/interface.d.ts +1 -0
- package/lib/es/tagInput/index.d.ts +13 -1
- package/lib/es/tagInput/index.js +217 -93
- package/lib/es/timePicker/TimePicker.js +1 -1
- package/lib/es/tooltip/index.d.ts +4 -0
- package/lib/es/tooltip/index.js +5 -3
- package/lib/es/typography/base.js +3 -15
- package/lib/es/typography/text.js +1 -10
- package/package.json +7 -7
- package/popover/index.tsx +4 -1
- package/select/__test__/select.test.js +5 -3
- package/select/_story/select.stories.js +1 -1
- package/select/_story/select.stories.tsx +2 -2
- package/select/index.tsx +65 -30
- package/select/option.tsx +2 -0
- package/table/_story/Perf/Render/complex.jsx +1 -1
- package/table/_story/Perf/Render/resizableSelection.jsx +1 -1
- package/tag/index.tsx +3 -2
- package/tag/interface.ts +1 -0
- package/tagInput/_story/tagInput.stories.js +20 -2
- package/tagInput/index.tsx +126 -26
- package/timePicker/TimePicker.tsx +1 -1
- package/tooltip/index.tsx +5 -2
- package/typography/_story/typography.stories.js +3 -15
- package/typography/base.tsx +4 -9
- package/typography/text.tsx +1 -9
- package/upload/__test__/upload.test.js +9 -9
- package/upload/_story/upload.stories.js +5 -5
package/tagInput/index.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from 'lodash';
|
|
12
12
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/tagInput/constants';
|
|
13
13
|
import '@douyinfe/semi-foundation/tagInput/tagInput.scss';
|
|
14
|
-
import TagInputFoundation, { TagInputAdapter } from '@douyinfe/semi-foundation/tagInput/foundation';
|
|
14
|
+
import TagInputFoundation, { TagInputAdapter, OnSortEndProps } from '@douyinfe/semi-foundation/tagInput/foundation';
|
|
15
15
|
import { ArrayElement } from '../_base/base';
|
|
16
16
|
import { isSemiIcon } from '../_utils';
|
|
17
17
|
import BaseComponent from '../_base/baseComponent';
|
|
@@ -19,12 +19,27 @@ import Tag from '../tag';
|
|
|
19
19
|
import Input from '../input';
|
|
20
20
|
import Popover, { PopoverProps } from '../popover';
|
|
21
21
|
import Paragraph from '../typography/paragraph';
|
|
22
|
-
import { IconClear } from '@douyinfe/semi-icons';
|
|
22
|
+
import { IconClear, IconHandle } from '@douyinfe/semi-icons';
|
|
23
|
+
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
|
23
24
|
|
|
24
25
|
export type Size = ArrayElement<typeof strings.SIZE_SET>;
|
|
25
26
|
export type RestTagsPopoverProps = PopoverProps;
|
|
26
27
|
type ValidateStatus = "default" | "error" | "warning";
|
|
27
28
|
|
|
29
|
+
const SortableItem = SortableElement(props => props.item);
|
|
30
|
+
|
|
31
|
+
const SortableList = SortableContainer(
|
|
32
|
+
({ items }) => {
|
|
33
|
+
return (
|
|
34
|
+
<div style={{ display: 'flex', flexFlow: 'row wrap', }}>
|
|
35
|
+
{items.map((item, index) => (
|
|
36
|
+
// @ts-ignore skip SortableItem type check
|
|
37
|
+
<SortableItem key={item.key} index={index} item={item.item}></SortableItem>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
28
43
|
export interface TagInputProps {
|
|
29
44
|
className?: string;
|
|
30
45
|
defaultValue?: string[];
|
|
@@ -38,6 +53,8 @@ export interface TagInputProps {
|
|
|
38
53
|
showContentTooltip?: boolean;
|
|
39
54
|
allowDuplicates?: boolean;
|
|
40
55
|
addOnBlur?: boolean;
|
|
56
|
+
draggable?: boolean;
|
|
57
|
+
expandRestTagsOnClick?: boolean;
|
|
41
58
|
onAdd?: (addedValue: string[]) => void;
|
|
42
59
|
onBlur?: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
43
60
|
onChange?: (value: string[]) => void;
|
|
@@ -69,6 +86,7 @@ export interface TagInputState {
|
|
|
69
86
|
inputValue?: string;
|
|
70
87
|
focusing?: boolean;
|
|
71
88
|
hovering?: boolean;
|
|
89
|
+
active?: boolean;
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
const prefixCls = cssClasses.PREFIX;
|
|
@@ -93,6 +111,8 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
93
111
|
separator: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
94
112
|
showClear: PropTypes.bool,
|
|
95
113
|
addOnBlur: PropTypes.bool,
|
|
114
|
+
draggable: PropTypes.bool,
|
|
115
|
+
expandRestTagsOnClick: PropTypes.bool,
|
|
96
116
|
autoFocus: PropTypes.bool,
|
|
97
117
|
renderTagItem: PropTypes.func,
|
|
98
118
|
onBlur: PropTypes.func,
|
|
@@ -118,6 +138,8 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
118
138
|
allowDuplicates: true,
|
|
119
139
|
showRestTagsPopover: true,
|
|
120
140
|
autoFocus: false,
|
|
141
|
+
draggable: false,
|
|
142
|
+
expandRestTagsOnClick: true,
|
|
121
143
|
showContentTooltip: true,
|
|
122
144
|
separator: ',',
|
|
123
145
|
size: 'default' as const,
|
|
@@ -134,7 +156,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
134
156
|
};
|
|
135
157
|
|
|
136
158
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
159
|
+
tagInputRef: React.RefObject<HTMLDivElement>;
|
|
137
160
|
foundation: TagInputFoundation;
|
|
161
|
+
clickOutsideHandler: any;
|
|
138
162
|
|
|
139
163
|
constructor(props: TagInputProps) {
|
|
140
164
|
super(props);
|
|
@@ -143,9 +167,12 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
143
167
|
tagsArray: props.defaultValue || [],
|
|
144
168
|
inputValue: '',
|
|
145
169
|
focusing: false,
|
|
146
|
-
hovering: false
|
|
170
|
+
hovering: false,
|
|
171
|
+
active: false,
|
|
147
172
|
};
|
|
148
173
|
this.inputRef = React.createRef();
|
|
174
|
+
this.tagInputRef = React.createRef();
|
|
175
|
+
this.clickOutsideHandler = null;
|
|
149
176
|
}
|
|
150
177
|
|
|
151
178
|
static getDerivedStateFromProps(nextProps: TagInputProps, prevState: TagInputState) {
|
|
@@ -190,6 +217,12 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
190
217
|
setHovering: (hovering: boolean) => {
|
|
191
218
|
this.setState({ hovering });
|
|
192
219
|
},
|
|
220
|
+
setActive: (active: boolean) => {
|
|
221
|
+
this.setState({ active });
|
|
222
|
+
},
|
|
223
|
+
getClickOutsideHandler: () => {
|
|
224
|
+
return this.clickOutsideHandler;
|
|
225
|
+
},
|
|
193
226
|
notifyBlur: (e: React.MouseEvent<HTMLInputElement>) => {
|
|
194
227
|
this.props.onBlur(e);
|
|
195
228
|
},
|
|
@@ -211,6 +244,21 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
211
244
|
notifyKeyDown: e => {
|
|
212
245
|
this.props.onKeyDown(e);
|
|
213
246
|
},
|
|
247
|
+
registerClickOutsideHandler: cb => {
|
|
248
|
+
const clickOutsideHandler = (e: Event) => {
|
|
249
|
+
const tagInputDom = this.tagInputRef && this.tagInputRef.current;
|
|
250
|
+
const target = e.target as Element;
|
|
251
|
+
if (tagInputDom && !tagInputDom.contains(target)) {
|
|
252
|
+
cb(e);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
this.clickOutsideHandler = clickOutsideHandler;
|
|
256
|
+
document.addEventListener('click', clickOutsideHandler, false);
|
|
257
|
+
},
|
|
258
|
+
unregisterClickOutsideHandler: () => {
|
|
259
|
+
document.removeEventListener('click', this.clickOutsideHandler, false);
|
|
260
|
+
this.clickOutsideHandler = null;
|
|
261
|
+
},
|
|
214
262
|
};
|
|
215
263
|
}
|
|
216
264
|
|
|
@@ -218,7 +266,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
218
266
|
const { disabled, autoFocus, preventScroll } = this.props;
|
|
219
267
|
if (!disabled && autoFocus) {
|
|
220
268
|
this.inputRef.current.focus({ preventScroll });
|
|
269
|
+
this.foundation.handleClick();
|
|
221
270
|
}
|
|
271
|
+
this.foundation.init();
|
|
222
272
|
}
|
|
223
273
|
|
|
224
274
|
handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -254,6 +304,10 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
254
304
|
this.foundation.handleInputMouseLeave();
|
|
255
305
|
};
|
|
256
306
|
|
|
307
|
+
handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
308
|
+
this.foundation.handleClick(e);
|
|
309
|
+
};
|
|
310
|
+
|
|
257
311
|
handleInputMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
258
312
|
this.foundation.handleInputMouseEnter();
|
|
259
313
|
};
|
|
@@ -338,34 +392,37 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
338
392
|
);
|
|
339
393
|
}
|
|
340
394
|
|
|
341
|
-
|
|
395
|
+
getAllTags = () => {
|
|
342
396
|
const {
|
|
343
397
|
size,
|
|
344
398
|
disabled,
|
|
345
399
|
renderTagItem,
|
|
346
|
-
maxTagCount,
|
|
347
400
|
showContentTooltip,
|
|
348
|
-
|
|
349
|
-
restTagsPopoverProps = {},
|
|
401
|
+
draggable,
|
|
350
402
|
} = this.props;
|
|
351
|
-
const { tagsArray } = this.state;
|
|
403
|
+
const { tagsArray, active } = this.state;
|
|
404
|
+
const showIconHandler = active && draggable;
|
|
352
405
|
const tagCls = cls(`${prefixCls}-wrapper-tag`, {
|
|
353
406
|
[`${prefixCls}-wrapper-tag-size-${size}`]: size,
|
|
407
|
+
[`${prefixCls}-wrapper-tag-icon`]: showIconHandler,
|
|
354
408
|
});
|
|
355
409
|
const typoCls = cls(`${prefixCls}-wrapper-typo`, {
|
|
356
|
-
[`${prefixCls}-wrapper-typo-disabled`]: disabled
|
|
410
|
+
[`${prefixCls}-wrapper-typo-disabled`]: disabled,
|
|
357
411
|
});
|
|
358
|
-
const
|
|
359
|
-
[`${prefixCls}-
|
|
412
|
+
const itemWrapperCls = cls({
|
|
413
|
+
[`${prefixCls}-drag-item`]: showIconHandler,
|
|
414
|
+
[`${prefixCls}-wrapper-tag-icon`]: showIconHandler,
|
|
360
415
|
});
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
let item = null;
|
|
416
|
+
const DragHandle = SortableHandle(() => <IconHandle className={`${prefixCls}-drag-handler`}></IconHandle>);
|
|
417
|
+
return tagsArray.map((value, index) => {
|
|
418
|
+
const elementKey = showIconHandler ? value : `${index}${value}`;
|
|
365
419
|
if (isFunction(renderTagItem)) {
|
|
366
|
-
|
|
420
|
+
return showIconHandler? (<div className={itemWrapperCls} key={elementKey}>
|
|
421
|
+
<DragHandle />
|
|
422
|
+
{renderTagItem(value, index)}
|
|
423
|
+
</div>) : renderTagItem(value, index);
|
|
367
424
|
} else {
|
|
368
|
-
|
|
425
|
+
return (
|
|
369
426
|
<Tag
|
|
370
427
|
className={tagCls}
|
|
371
428
|
color="white"
|
|
@@ -375,10 +432,11 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
375
432
|
!disabled && this.handleTagClose(index);
|
|
376
433
|
}}
|
|
377
434
|
closable={!disabled}
|
|
378
|
-
key={
|
|
435
|
+
key={elementKey}
|
|
379
436
|
visible
|
|
380
437
|
aria-label={`${!disabled ? 'Closable ' : ''}Tag: ${value}`}
|
|
381
438
|
>
|
|
439
|
+
{showIconHandler && <DragHandle />}
|
|
382
440
|
<Paragraph
|
|
383
441
|
className={typoCls}
|
|
384
442
|
ellipsis={{ showTooltip: showContentTooltip, rows: 1 }}
|
|
@@ -388,17 +446,47 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
388
446
|
</Tag>
|
|
389
447
|
);
|
|
390
448
|
}
|
|
391
|
-
if (maxTagCount && index >= maxTagCount) {
|
|
392
|
-
restTags.push(item);
|
|
393
|
-
} else {
|
|
394
|
-
tags.push(item);
|
|
395
|
-
}
|
|
396
449
|
});
|
|
450
|
+
}
|
|
397
451
|
|
|
452
|
+
onSortEnd = (callbackProps: OnSortEndProps) => {
|
|
453
|
+
this.foundation.handleSortEnd(callbackProps);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
renderTags() {
|
|
457
|
+
const {
|
|
458
|
+
disabled,
|
|
459
|
+
maxTagCount,
|
|
460
|
+
showRestTagsPopover,
|
|
461
|
+
restTagsPopoverProps = {},
|
|
462
|
+
draggable,
|
|
463
|
+
expandRestTagsOnClick,
|
|
464
|
+
} = this.props;
|
|
465
|
+
const { tagsArray, active } = this.state;
|
|
466
|
+
const restTagsCls = cls(`${prefixCls}-wrapper-n`, {
|
|
467
|
+
[`${prefixCls}-wrapper-n-disabled`]: disabled,
|
|
468
|
+
});
|
|
469
|
+
const allTags = this.getAllTags();
|
|
470
|
+
let restTags: Array<React.ReactNode> = [];
|
|
471
|
+
let tags: Array<React.ReactNode> = [...allTags];
|
|
472
|
+
if (( !active || !expandRestTagsOnClick) && maxTagCount && maxTagCount < allTags.length){
|
|
473
|
+
tags = allTags.slice(0, maxTagCount);
|
|
474
|
+
restTags = allTags.slice(maxTagCount);
|
|
475
|
+
}
|
|
476
|
+
|
|
398
477
|
const restTagsContent = (
|
|
399
478
|
<span className={restTagsCls}>+{tagsArray.length - maxTagCount}</span>
|
|
400
479
|
);
|
|
401
480
|
|
|
481
|
+
const sortableListItems = allTags.map((item, index) => ({
|
|
482
|
+
item: item,
|
|
483
|
+
key: tagsArray[index],
|
|
484
|
+
}));
|
|
485
|
+
|
|
486
|
+
if (active && draggable && sortableListItems.length > 0) {
|
|
487
|
+
// @ts-ignore skip SortableItem type check
|
|
488
|
+
return <SortableList useDragHandle items={sortableListItems} onSortEnd={this.onSortEnd} axis={"xy"} />;
|
|
489
|
+
}
|
|
402
490
|
return (
|
|
403
491
|
<>
|
|
404
492
|
{tags}
|
|
@@ -426,11 +514,17 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
426
514
|
|
|
427
515
|
blur() {
|
|
428
516
|
this.inputRef.current.blur();
|
|
517
|
+
// unregister clickOutside event
|
|
518
|
+
this.foundation.clickOutsideCallBack();
|
|
429
519
|
}
|
|
430
520
|
|
|
431
521
|
focus() {
|
|
432
|
-
const { preventScroll } = this.props;
|
|
522
|
+
const { preventScroll, disabled } = this.props;
|
|
433
523
|
this.inputRef.current.focus({ preventScroll });
|
|
524
|
+
if (!disabled) {
|
|
525
|
+
// register clickOutside event
|
|
526
|
+
this.foundation.handleClick();
|
|
527
|
+
}
|
|
434
528
|
}
|
|
435
529
|
|
|
436
530
|
render() {
|
|
@@ -447,11 +541,12 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
447
541
|
focusing,
|
|
448
542
|
hovering,
|
|
449
543
|
tagsArray,
|
|
450
|
-
inputValue
|
|
544
|
+
inputValue,
|
|
545
|
+
active,
|
|
451
546
|
} = this.state;
|
|
452
547
|
|
|
453
548
|
const tagInputCls = cls(prefixCls, className, {
|
|
454
|
-
[`${prefixCls}-focus`]: focusing,
|
|
549
|
+
[`${prefixCls}-focus`]: focusing || active,
|
|
455
550
|
[`${prefixCls}-disabled`]: disabled,
|
|
456
551
|
[`${prefixCls}-hover`]: hovering && !disabled,
|
|
457
552
|
[`${prefixCls}-error`]: validateStatus === 'error',
|
|
@@ -463,7 +558,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
463
558
|
const wrapperCls = cls(`${prefixCls}-wrapper`);
|
|
464
559
|
|
|
465
560
|
return (
|
|
561
|
+
// eslint-disable-next-line
|
|
466
562
|
<div
|
|
563
|
+
ref={this.tagInputRef}
|
|
467
564
|
style={style}
|
|
468
565
|
className={tagInputCls}
|
|
469
566
|
aria-disabled={disabled}
|
|
@@ -475,6 +572,9 @@ class TagInput extends BaseComponent<TagInputProps, TagInputState> {
|
|
|
475
572
|
onMouseLeave={e => {
|
|
476
573
|
this.handleInputMouseLeave(e);
|
|
477
574
|
}}
|
|
575
|
+
onClick={e => {
|
|
576
|
+
this.handleClick(e);
|
|
577
|
+
}}
|
|
478
578
|
>
|
|
479
579
|
{this.renderPrefix()}
|
|
480
580
|
<div className={wrapperCls}>
|
|
@@ -248,7 +248,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
248
248
|
this.timePickerRef.current.contains(e.target as Node);
|
|
249
249
|
if (!isInTimepicker && !isInPanel) {
|
|
250
250
|
const clickedOutside = true;
|
|
251
|
-
this.foundation.
|
|
251
|
+
this.foundation.handlePanelClose(clickedOutside, e);
|
|
252
252
|
}
|
|
253
253
|
};
|
|
254
254
|
document.addEventListener('mousedown', this.clickOutSideHandler);
|
package/tooltip/index.tsx
CHANGED
|
@@ -75,8 +75,10 @@ export interface TooltipProps extends BaseProps {
|
|
|
75
75
|
guardFocus?: boolean;
|
|
76
76
|
returnFocusOnClose?: boolean;
|
|
77
77
|
onEscKeyDown?: (e: React.KeyboardEvent) => void;
|
|
78
|
+
disableArrowKeyDown?: boolean;
|
|
78
79
|
wrapperId?: string;
|
|
79
80
|
preventScroll?: boolean;
|
|
81
|
+
disableFocusListener?: boolean;
|
|
80
82
|
}
|
|
81
83
|
interface TooltipState {
|
|
82
84
|
visible: boolean;
|
|
@@ -162,6 +164,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
162
164
|
guardFocus: false,
|
|
163
165
|
returnFocusOnClose: false,
|
|
164
166
|
onEscKeyDown: noop,
|
|
167
|
+
disableFocusListener: false,
|
|
168
|
+
disableArrowKeyDown: false,
|
|
165
169
|
};
|
|
166
170
|
|
|
167
171
|
eventManager: Event;
|
|
@@ -716,8 +720,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
716
720
|
ref.current = node;
|
|
717
721
|
}
|
|
718
722
|
},
|
|
719
|
-
tabIndex: 0
|
|
720
|
-
'data-popupid': id
|
|
723
|
+
tabIndex: (children as React.ReactElement).props.tabIndex || 0 // a11y keyboard, in some condition select's tabindex need to -1 or 0
|
|
721
724
|
});
|
|
722
725
|
|
|
723
726
|
// If you do not add a layer of div, in order to bind the events and className in the tooltip, you need to cloneElement children, but this time it may overwrite the children's original ref reference
|
|
@@ -3,7 +3,7 @@ import withPropsCombinations from 'react-storybook-addon-props-combinations';
|
|
|
3
3
|
|
|
4
4
|
import Icon from '../../icons';
|
|
5
5
|
import Typography from '../index';
|
|
6
|
-
import { IconLink, IconTick
|
|
6
|
+
import { IconLink, IconTick } from '@douyinfe/semi-icons';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Typography'
|
|
@@ -51,22 +51,10 @@ export const _Text = () => (
|
|
|
51
51
|
<br />
|
|
52
52
|
<Text link={{ href: 'https://semi.design/' }}>打开网站</Text>
|
|
53
53
|
<br />
|
|
54
|
-
{/* 用户未通过icon API设置icon,而是通过children传入,则需要手动处理内容的对齐 */}
|
|
55
54
|
<Text link>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
网页链接
|
|
59
|
-
</span>
|
|
55
|
+
<IconLink />
|
|
56
|
+
网页链接
|
|
60
57
|
</Text>
|
|
61
|
-
<br />
|
|
62
|
-
<Text link icon={<IconLink />} underline>带下划线的网页链接</Text>
|
|
63
|
-
<br />
|
|
64
|
-
<Text icon={<IconLink />} underline>带下划线的内容</Text>
|
|
65
|
-
<br />
|
|
66
|
-
<Text icon={<IconPlusCircle />} style={{ color: 'purple'}}>添加条件</Text>
|
|
67
|
-
<br />
|
|
68
|
-
<Text icon={<IconPlusCircle />} style={{ color: 'purple'}} size={'small'}>添加条件</Text>
|
|
69
|
-
<br />
|
|
70
58
|
</div>
|
|
71
59
|
);
|
|
72
60
|
|
package/typography/base.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Component
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
@@ -54,15 +54,15 @@ const prefixCls = cssClasses.PREFIX;
|
|
|
54
54
|
const ELLIPSIS_STR = '...';
|
|
55
55
|
|
|
56
56
|
const wrapperDecorations = (props: BaseTypographyProps, content: React.ReactNode) => {
|
|
57
|
-
const { mark, code, underline, strong, link, disabled
|
|
57
|
+
const { mark, code, underline, strong, link, disabled } = props;
|
|
58
58
|
let wrapped = content;
|
|
59
59
|
const wrap = (isNeeded: boolean | LinkType, tag: string) => {
|
|
60
|
-
let wrapProps =
|
|
60
|
+
let wrapProps = {};
|
|
61
61
|
if (!isNeeded) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
if (typeof isNeeded === 'object') {
|
|
65
|
-
wrapProps = { ...isNeeded }
|
|
65
|
+
wrapProps = { ...isNeeded };
|
|
66
66
|
}
|
|
67
67
|
wrapped = React.createElement(tag, wrapProps, wrapped);
|
|
68
68
|
};
|
|
@@ -72,11 +72,6 @@ const wrapperDecorations = (props: BaseTypographyProps, content: React.ReactNode
|
|
|
72
72
|
wrap(strong, 'strong');
|
|
73
73
|
wrap(props.delete, 'del');
|
|
74
74
|
wrap(link, disabled ? 'span' : 'a');
|
|
75
|
-
// When the content is not wrapped, and there is more than one element in the content (one of which is an icon),
|
|
76
|
-
// use span to wrap the content, so that the content in the span is vertically aligned
|
|
77
|
-
if (wrapped === content && icon) {
|
|
78
|
-
wrap(true, 'span');
|
|
79
|
-
}
|
|
80
75
|
return wrapped;
|
|
81
76
|
};
|
|
82
77
|
|
package/typography/text.tsx
CHANGED
|
@@ -4,13 +4,9 @@ import { strings } from '@douyinfe/semi-foundation/typography/constants';
|
|
|
4
4
|
import Base from './base';
|
|
5
5
|
import { Ellipsis, TypographyBaseSize, TypographyBaseType, OmitTypographyProps } from './interface';
|
|
6
6
|
import { CopyableConfig, LinkType } from './title';
|
|
7
|
-
import cls from 'classnames';
|
|
8
|
-
import { cssClasses } from '@douyinfe/semi-foundation/typography/constants';
|
|
9
7
|
|
|
10
8
|
type OmitTextProps = OmitTypographyProps;
|
|
11
9
|
|
|
12
|
-
const prefixCls = cssClasses.PREFIX;
|
|
13
|
-
|
|
14
10
|
export interface TextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, OmitTextProps> {
|
|
15
11
|
children?: React.ReactNode;
|
|
16
12
|
className?: string;
|
|
@@ -67,10 +63,6 @@ export default class Text extends PureComponent<TextProps> {
|
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
render() {
|
|
70
|
-
|
|
71
|
-
[`${prefixCls}-text`]: true,
|
|
72
|
-
[`${prefixCls}-text-icon`]: this.props.icon,
|
|
73
|
-
});
|
|
74
|
-
return <Base component={'span'} {...this.props} className={className} />;
|
|
66
|
+
return <Base component={'span'} {...this.props} />;
|
|
75
67
|
}
|
|
76
68
|
}
|
|
@@ -45,7 +45,7 @@ const defaultFileList = [
|
|
|
45
45
|
status: 'success',
|
|
46
46
|
size: '130KB',
|
|
47
47
|
preview: true,
|
|
48
|
-
url: 'https://
|
|
48
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
uid: '2',
|
|
@@ -53,7 +53,7 @@ const defaultFileList = [
|
|
|
53
53
|
status: 'uploadFail',
|
|
54
54
|
size: '222KB',
|
|
55
55
|
preview: false,
|
|
56
|
-
url: 'https://
|
|
56
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
57
57
|
},
|
|
58
58
|
];
|
|
59
59
|
|
|
@@ -448,7 +448,7 @@ describe('Upload', () => {
|
|
|
448
448
|
size: '222KB',
|
|
449
449
|
preview: true,
|
|
450
450
|
fileInstance,
|
|
451
|
-
url: 'https://
|
|
451
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
452
452
|
};
|
|
453
453
|
const props = {
|
|
454
454
|
fileList: [file],
|
|
@@ -502,7 +502,7 @@ describe('Upload', () => {
|
|
|
502
502
|
size: '222KB',
|
|
503
503
|
preview: true,
|
|
504
504
|
fileInstance,
|
|
505
|
-
url: 'https://
|
|
505
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
506
506
|
};
|
|
507
507
|
let props = {
|
|
508
508
|
defaultFileList: [file],
|
|
@@ -535,7 +535,7 @@ describe('Upload', () => {
|
|
|
535
535
|
status: 'error',
|
|
536
536
|
size: '222KB',
|
|
537
537
|
preview: true,
|
|
538
|
-
url: 'https://
|
|
538
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
539
539
|
},
|
|
540
540
|
],
|
|
541
541
|
};
|
|
@@ -756,7 +756,7 @@ describe('Upload', () => {
|
|
|
756
756
|
status: 'success',
|
|
757
757
|
size: '130KB',
|
|
758
758
|
preview: true,
|
|
759
|
-
url: 'https://
|
|
759
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
760
760
|
},
|
|
761
761
|
],
|
|
762
762
|
showReplace: true,
|
|
@@ -786,7 +786,7 @@ describe('Upload', () => {
|
|
|
786
786
|
status: 'success',
|
|
787
787
|
size: '130KB',
|
|
788
788
|
preview: true,
|
|
789
|
-
url: 'https://
|
|
789
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
790
790
|
},
|
|
791
791
|
],
|
|
792
792
|
};
|
|
@@ -839,7 +839,7 @@ describe('Upload', () => {
|
|
|
839
839
|
status: 'success',
|
|
840
840
|
size: '130KB',
|
|
841
841
|
preview: true,
|
|
842
|
-
url: 'https://
|
|
842
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
843
843
|
},
|
|
844
844
|
],
|
|
845
845
|
};
|
|
@@ -933,7 +933,7 @@ describe('Upload', () => {
|
|
|
933
933
|
name: 'jiafang1.jpeg',
|
|
934
934
|
status: 'success',
|
|
935
935
|
size: '130kb',
|
|
936
|
-
url: 'https://
|
|
936
|
+
url: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
937
937
|
},
|
|
938
938
|
],
|
|
939
939
|
showPicInfo: true,
|
|
@@ -258,7 +258,7 @@ const defaultFileList = [
|
|
|
258
258
|
status: 'success',
|
|
259
259
|
size: '130kb',
|
|
260
260
|
url:
|
|
261
|
-
'https://
|
|
261
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
264
|
uid: '2',
|
|
@@ -266,7 +266,7 @@ const defaultFileList = [
|
|
|
266
266
|
status: 'uploadFail',
|
|
267
267
|
size: '222kb',
|
|
268
268
|
url:
|
|
269
|
-
'https://
|
|
269
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
270
270
|
},
|
|
271
271
|
{
|
|
272
272
|
uid: '3',
|
|
@@ -275,7 +275,7 @@ const defaultFileList = [
|
|
|
275
275
|
percent: 50,
|
|
276
276
|
size: '222kb',
|
|
277
277
|
url:
|
|
278
|
-
'https://
|
|
278
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
279
279
|
},
|
|
280
280
|
{
|
|
281
281
|
uid: '4',
|
|
@@ -284,7 +284,7 @@ const defaultFileList = [
|
|
|
284
284
|
validateMessage: '文件过大',
|
|
285
285
|
size: '222kb',
|
|
286
286
|
url:
|
|
287
|
-
'https://
|
|
287
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
uid: '5',
|
|
@@ -293,7 +293,7 @@ const defaultFileList = [
|
|
|
293
293
|
validateMessage: '校验中',
|
|
294
294
|
size: '222kb',
|
|
295
295
|
url:
|
|
296
|
-
'https://
|
|
296
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg',
|
|
297
297
|
},
|
|
298
298
|
];
|
|
299
299
|
|