@douyinfe/semi-ui 2.52.3 → 2.53.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/dist/umd/semi-ui.js +804 -273
- 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/lib/cjs/_utils/index.d.ts +2 -0
- package/lib/cjs/_utils/index.js +77 -0
- package/lib/cjs/_utils/semi-global.d.ts +46 -0
- package/lib/cjs/_utils/semi-global.js +13 -0
- package/lib/cjs/autoComplete/index.d.ts +2 -25
- package/lib/cjs/autoComplete/index.js +4 -2
- package/lib/cjs/avatar/index.d.ts +2 -10
- package/lib/cjs/avatar/index.js +4 -2
- package/lib/cjs/backtop/index.d.ts +2 -5
- package/lib/cjs/backtop/index.js +4 -2
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +3 -1
- package/lib/cjs/button/index.js +3 -0
- package/lib/cjs/carousel/index.d.ts +2 -2
- package/lib/cjs/cascader/index.d.ts +2 -31
- package/lib/cjs/cascader/index.js +3 -2
- package/lib/cjs/collapse/index.d.ts +2 -7
- package/lib/cjs/collapse/index.js +4 -2
- package/lib/cjs/collapsible/index.d.ts +3 -9
- package/lib/cjs/collapsible/index.js +4 -2
- package/lib/cjs/configProvider/index.d.ts +2 -1
- package/lib/cjs/configProvider/index.js +5 -2
- package/lib/cjs/datePicker/datePicker.d.ts +2 -44
- package/lib/cjs/datePicker/datePicker.js +4 -2
- package/lib/cjs/dropdown/index.d.ts +2 -12
- package/lib/cjs/dropdown/index.js +4 -2
- package/lib/cjs/form/arrayField.js +3 -3
- package/lib/cjs/modal/Modal.d.ts +2 -20
- package/lib/cjs/modal/Modal.js +3 -2
- package/lib/cjs/modal/confirm.d.ts +14 -14
- package/lib/cjs/navigation/index.d.ts +2 -15
- package/lib/cjs/navigation/index.js +4 -2
- package/lib/cjs/notification/notice.d.ts +2 -12
- package/lib/cjs/notification/notice.js +3 -2
- package/lib/cjs/overflowList/index.d.ts +2 -9
- package/lib/cjs/overflowList/index.js +3 -2
- package/lib/cjs/popconfirm/index.d.ts +2 -15
- package/lib/cjs/popconfirm/index.js +4 -2
- package/lib/cjs/popover/index.d.ts +2 -23
- package/lib/cjs/popover/index.js +4 -2
- package/lib/cjs/resizeObserver/index.d.ts +14 -1
- package/lib/cjs/resizeObserver/index.js +66 -31
- package/lib/cjs/select/index.d.ts +1 -0
- package/lib/cjs/select/index.js +3 -2
- package/lib/cjs/sideSheet/index.d.ts +1 -0
- package/lib/cjs/sideSheet/index.js +20 -18
- package/lib/cjs/tabs/index.d.ts +1 -0
- package/lib/cjs/tabs/index.js +4 -2
- package/lib/cjs/tagInput/index.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -34
- package/lib/cjs/timePicker/index.js +3 -1
- package/lib/cjs/toast/toast.d.ts +2 -11
- package/lib/cjs/toast/toast.js +3 -2
- package/lib/cjs/tooltip/index.d.ts +2 -32
- package/lib/cjs/tooltip/index.js +3 -2
- package/lib/cjs/typography/base.d.ts +7 -4
- package/lib/cjs/typography/base.js +127 -64
- package/lib/cjs/typography/numeral.d.ts +1 -1
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/_utils/index.d.ts +2 -0
- package/lib/es/_utils/index.js +75 -0
- package/lib/es/_utils/semi-global.d.ts +46 -0
- package/lib/es/_utils/semi-global.js +6 -0
- package/lib/es/autoComplete/index.d.ts +2 -25
- package/lib/es/autoComplete/index.js +4 -2
- package/lib/es/avatar/index.d.ts +2 -10
- package/lib/es/avatar/index.js +4 -2
- package/lib/es/backtop/index.d.ts +2 -5
- package/lib/es/backtop/index.js +4 -2
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +3 -1
- package/lib/es/button/index.js +3 -0
- package/lib/es/carousel/index.d.ts +2 -2
- package/lib/es/cascader/index.d.ts +2 -31
- package/lib/es/cascader/index.js +4 -3
- package/lib/es/collapse/index.d.ts +2 -7
- package/lib/es/collapse/index.js +4 -2
- package/lib/es/collapsible/index.d.ts +3 -9
- package/lib/es/collapsible/index.js +4 -2
- package/lib/es/configProvider/index.d.ts +2 -1
- package/lib/es/configProvider/index.js +5 -2
- package/lib/es/datePicker/datePicker.d.ts +2 -44
- package/lib/es/datePicker/datePicker.js +4 -2
- package/lib/es/dropdown/index.d.ts +2 -12
- package/lib/es/dropdown/index.js +4 -2
- package/lib/es/form/arrayField.js +3 -3
- package/lib/es/modal/Modal.d.ts +2 -20
- package/lib/es/modal/Modal.js +4 -3
- package/lib/es/modal/confirm.d.ts +14 -14
- package/lib/es/navigation/index.d.ts +2 -15
- package/lib/es/navigation/index.js +4 -2
- package/lib/es/notification/notice.d.ts +2 -12
- package/lib/es/notification/notice.js +4 -3
- package/lib/es/overflowList/index.d.ts +2 -9
- package/lib/es/overflowList/index.js +4 -3
- package/lib/es/popconfirm/index.d.ts +2 -15
- package/lib/es/popconfirm/index.js +4 -2
- package/lib/es/popover/index.d.ts +2 -23
- package/lib/es/popover/index.js +4 -2
- package/lib/es/resizeObserver/index.d.ts +14 -1
- package/lib/es/resizeObserver/index.js +64 -30
- package/lib/es/select/index.d.ts +1 -0
- package/lib/es/select/index.js +4 -3
- package/lib/es/sideSheet/index.d.ts +1 -0
- package/lib/es/sideSheet/index.js +21 -19
- package/lib/es/tabs/index.d.ts +1 -0
- package/lib/es/tabs/index.js +4 -2
- package/lib/es/tagInput/index.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -34
- package/lib/es/timePicker/index.js +3 -1
- package/lib/es/toast/toast.d.ts +2 -11
- package/lib/es/toast/toast.js +4 -3
- package/lib/es/tooltip/index.d.ts +2 -32
- package/lib/es/tooltip/index.js +4 -3
- package/lib/es/typography/base.d.ts +7 -4
- package/lib/es/typography/base.js +128 -65
- package/lib/es/typography/numeral.d.ts +1 -1
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/package.json +9 -8
|
@@ -23,10 +23,37 @@ var _warning = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs
|
|
|
23
23
|
var _isEnterPress = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/isEnterPress"));
|
|
24
24
|
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
25
25
|
var _utils = require("../_utils");
|
|
26
|
-
var _resizeObserver =
|
|
26
|
+
var _resizeObserver = _interopRequireWildcard(require("../resizeObserver"));
|
|
27
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) {
|
|
32
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
33
|
+
resolve(value);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
+
function fulfilled(value) {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.next(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function rejected(value) {
|
|
45
|
+
try {
|
|
46
|
+
step(generator["throw"](value));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function step(result) {
|
|
52
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
53
|
+
}
|
|
54
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
55
|
+
});
|
|
56
|
+
};
|
|
30
57
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
31
58
|
var t = {};
|
|
32
59
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -68,12 +95,18 @@ const wrapperDecorations = (props, content) => {
|
|
|
68
95
|
class Base extends _react.Component {
|
|
69
96
|
constructor(props) {
|
|
70
97
|
super(props);
|
|
71
|
-
this.
|
|
98
|
+
this.observerTakingEffect = false;
|
|
99
|
+
this.onResize = entries => __awaiter(this, void 0, void 0, function* () {
|
|
72
100
|
if (this.rafId) {
|
|
73
101
|
window.cancelAnimationFrame(this.rafId);
|
|
74
102
|
}
|
|
75
|
-
|
|
76
|
-
|
|
103
|
+
return new Promise(resolve => {
|
|
104
|
+
this.rafId = window.requestAnimationFrame(() => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
yield this.getEllipsisState();
|
|
106
|
+
resolve();
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
77
110
|
// if it needs to use js overflowed:
|
|
78
111
|
// 1. text is expandable 2. expandText need to be shown 3. has extra operation 4. text need to ellipse from mid
|
|
79
112
|
this.canUseCSSEllipsis = () => {
|
|
@@ -143,6 +176,80 @@ class Base extends _react.Component {
|
|
|
143
176
|
}
|
|
144
177
|
return defaultOpts;
|
|
145
178
|
};
|
|
179
|
+
this.onHover = () => {
|
|
180
|
+
const canUseCSSEllipsis = this.canUseCSSEllipsis();
|
|
181
|
+
if (canUseCSSEllipsis) {
|
|
182
|
+
const {
|
|
183
|
+
rows,
|
|
184
|
+
suffix,
|
|
185
|
+
pos
|
|
186
|
+
} = this.getEllipsisOpt();
|
|
187
|
+
const updateOverflow = this.shouldTruncated(rows);
|
|
188
|
+
// isOverflowed needs to be updated to show tooltip when using css ellipsis
|
|
189
|
+
this.setState({
|
|
190
|
+
isOverflowed: updateOverflow,
|
|
191
|
+
isTruncated: false
|
|
192
|
+
});
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
this.getEllipsisState = () => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const {
|
|
198
|
+
rows,
|
|
199
|
+
suffix,
|
|
200
|
+
pos
|
|
201
|
+
} = this.getEllipsisOpt();
|
|
202
|
+
const {
|
|
203
|
+
children
|
|
204
|
+
} = this.props;
|
|
205
|
+
// wait until element mounted
|
|
206
|
+
if (!this.wrapperRef || !this.wrapperRef.current) {
|
|
207
|
+
yield this.onResize();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const {
|
|
211
|
+
expanded
|
|
212
|
+
} = this.state;
|
|
213
|
+
const canUseCSSEllipsis = this.canUseCSSEllipsis();
|
|
214
|
+
if (canUseCSSEllipsis) {
|
|
215
|
+
// const updateOverflow = this.shouldTruncated(rows);
|
|
216
|
+
// // isOverflowed needs to be updated to show tooltip when using css ellipsis
|
|
217
|
+
// this.setState({
|
|
218
|
+
// isOverflowed: updateOverflow,
|
|
219
|
+
// isTruncated: false
|
|
220
|
+
// });
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// If children is null, css/js truncated flag isTruncate is false
|
|
224
|
+
if ((0, _isNull2.default)(children)) {
|
|
225
|
+
return new Promise(resolve => {
|
|
226
|
+
this.setState({
|
|
227
|
+
isTruncated: false,
|
|
228
|
+
isOverflowed: false
|
|
229
|
+
}, resolve);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// Currently only text truncation is supported, if there is non-text,
|
|
233
|
+
// both css truncation and js truncation should throw a warning
|
|
234
|
+
(0, _warning.default)('children' in this.props && typeof children !== 'string', "[Semi Typography] Only children with pure text could be used with ellipsis at this moment.");
|
|
235
|
+
if (!rows || rows < 0 || expanded) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const extraNode = {
|
|
239
|
+
expand: this.expandRef.current,
|
|
240
|
+
copy: this.copyRef && this.copyRef.current
|
|
241
|
+
};
|
|
242
|
+
const content = (0, _util.default)(this.wrapperRef.current, rows,
|
|
243
|
+
// Perform type conversion on children to prevent component crash due to non-string type of children
|
|
244
|
+
String(children), extraNode, ELLIPSIS_STR, suffix, pos);
|
|
245
|
+
return new Promise(resolve => {
|
|
246
|
+
this.setState({
|
|
247
|
+
isOverflowed: false,
|
|
248
|
+
ellipsisContent: content,
|
|
249
|
+
isTruncated: children !== content
|
|
250
|
+
}, resolve);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
146
253
|
/**
|
|
147
254
|
* Triggered when the fold button is clicked to save the latest expanded state
|
|
148
255
|
* @param {Event} e
|
|
@@ -309,9 +416,13 @@ class Base extends _react.Component {
|
|
|
309
416
|
ellipsisContent
|
|
310
417
|
} = this.state;
|
|
311
418
|
if (expanded || !isTruncated) {
|
|
312
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
419
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
420
|
+
onMouseEnter: this.onHover
|
|
421
|
+
}, children, suffix && suffix.length ? suffix : null);
|
|
313
422
|
}
|
|
314
|
-
return /*#__PURE__*/_react.default.createElement("span",
|
|
423
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
424
|
+
onMouseEnter: this.onHover
|
|
425
|
+
}, ellipsisContent, suffix);
|
|
315
426
|
};
|
|
316
427
|
this.state = {
|
|
317
428
|
editable: false,
|
|
@@ -331,7 +442,8 @@ class Base extends _react.Component {
|
|
|
331
442
|
}
|
|
332
443
|
componentDidMount() {
|
|
333
444
|
if (this.props.ellipsis) {
|
|
334
|
-
|
|
445
|
+
// runAfterTicks: make sure start observer on the next tick
|
|
446
|
+
this.onResize().then(() => (0, _utils.runAfterTicks)(() => this.observerTakingEffect = true, 1));
|
|
335
447
|
}
|
|
336
448
|
}
|
|
337
449
|
static getDerivedStateFromProps(props, prevState) {
|
|
@@ -363,61 +475,6 @@ class Base extends _react.Component {
|
|
|
363
475
|
window.cancelAnimationFrame(this.rafId);
|
|
364
476
|
}
|
|
365
477
|
}
|
|
366
|
-
getEllipsisState() {
|
|
367
|
-
const {
|
|
368
|
-
rows,
|
|
369
|
-
suffix,
|
|
370
|
-
pos
|
|
371
|
-
} = this.getEllipsisOpt();
|
|
372
|
-
const {
|
|
373
|
-
children
|
|
374
|
-
} = this.props;
|
|
375
|
-
// wait until element mounted
|
|
376
|
-
if (!this.wrapperRef || !this.wrapperRef.current) {
|
|
377
|
-
this.onResize();
|
|
378
|
-
return false;
|
|
379
|
-
}
|
|
380
|
-
const {
|
|
381
|
-
expanded
|
|
382
|
-
} = this.state;
|
|
383
|
-
const canUseCSSEllipsis = this.canUseCSSEllipsis();
|
|
384
|
-
// If children is null, css/js truncated flag isTruncate is false
|
|
385
|
-
if ((0, _isNull2.default)(children)) {
|
|
386
|
-
this.setState({
|
|
387
|
-
isTruncated: false,
|
|
388
|
-
isOverflowed: false
|
|
389
|
-
});
|
|
390
|
-
return undefined;
|
|
391
|
-
}
|
|
392
|
-
// Currently only text truncation is supported, if there is non-text,
|
|
393
|
-
// both css truncation and js truncation should throw a warning
|
|
394
|
-
(0, _warning.default)('children' in this.props && typeof children !== 'string', "[Semi Typography] Only children with pure text could be used with ellipsis at this moment.");
|
|
395
|
-
if (!rows || rows < 0 || expanded) {
|
|
396
|
-
return undefined;
|
|
397
|
-
}
|
|
398
|
-
if (canUseCSSEllipsis) {
|
|
399
|
-
const updateOverflow = this.shouldTruncated(rows);
|
|
400
|
-
// isOverflowed needs to be updated to show tooltip when using css ellipsis
|
|
401
|
-
this.setState({
|
|
402
|
-
isOverflowed: updateOverflow,
|
|
403
|
-
isTruncated: false
|
|
404
|
-
});
|
|
405
|
-
return undefined;
|
|
406
|
-
}
|
|
407
|
-
const extraNode = {
|
|
408
|
-
expand: this.expandRef.current,
|
|
409
|
-
copy: this.copyRef && this.copyRef.current
|
|
410
|
-
};
|
|
411
|
-
const content = (0, _util.default)(this.wrapperRef.current, rows,
|
|
412
|
-
// Perform type conversion on children to prevent component crash due to non-string type of children
|
|
413
|
-
String(children), extraNode, ELLIPSIS_STR, suffix, pos);
|
|
414
|
-
this.setState({
|
|
415
|
-
isOverflowed: false,
|
|
416
|
-
ellipsisContent: content,
|
|
417
|
-
isTruncated: children !== content
|
|
418
|
-
});
|
|
419
|
-
return undefined;
|
|
420
|
-
}
|
|
421
478
|
renderOperations() {
|
|
422
479
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderExpandable(), this.renderCopy());
|
|
423
480
|
}
|
|
@@ -559,6 +616,7 @@ class Base extends _react.Component {
|
|
|
559
616
|
}
|
|
560
617
|
}
|
|
561
618
|
render() {
|
|
619
|
+
var _this = this;
|
|
562
620
|
const content = /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
563
621
|
componentName: "Typography"
|
|
564
622
|
}, locale => {
|
|
@@ -568,8 +626,13 @@ class Base extends _react.Component {
|
|
|
568
626
|
});
|
|
569
627
|
if (this.props.ellipsis) {
|
|
570
628
|
return /*#__PURE__*/_react.default.createElement(_resizeObserver.default, {
|
|
571
|
-
onResize:
|
|
572
|
-
|
|
629
|
+
onResize: function () {
|
|
630
|
+
if (_this.observerTakingEffect) {
|
|
631
|
+
_this.onResize(...arguments);
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
observeParent: true,
|
|
635
|
+
observerProperty: _resizeObserver.ObserverProperty.Width
|
|
573
636
|
}, content);
|
|
574
637
|
}
|
|
575
638
|
return content;
|
|
@@ -38,7 +38,7 @@ export default class Numeral extends PureComponent<NumeralProps> {
|
|
|
38
38
|
underline: PropTypes.Requireable<boolean>;
|
|
39
39
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
40
40
|
strong: PropTypes.Requireable<boolean>;
|
|
41
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
41
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
|
|
42
42
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
43
43
|
style: PropTypes.Requireable<object>;
|
|
44
44
|
className: PropTypes.Requireable<string>;
|
|
@@ -50,7 +50,7 @@ export default class Paragraph extends PureComponent<ParagraphProps> {
|
|
|
50
50
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
51
51
|
underline: PropTypes.Requireable<boolean>;
|
|
52
52
|
strong: PropTypes.Requireable<boolean>;
|
|
53
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
53
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
|
|
54
54
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
55
55
|
spacing: PropTypes.Requireable<"normal" | "extended">;
|
|
56
56
|
style: PropTypes.Requireable<object>;
|
|
@@ -53,7 +53,7 @@ export default class Text extends PureComponent<TextProps> {
|
|
|
53
53
|
underline: PropTypes.Requireable<boolean>;
|
|
54
54
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
55
55
|
strong: PropTypes.Requireable<boolean>;
|
|
56
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
56
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
|
|
57
57
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
58
58
|
style: PropTypes.Requireable<object>;
|
|
59
59
|
className: PropTypes.Requireable<string>;
|
|
@@ -59,7 +59,7 @@ export default class Title extends PureComponent<TitleProps> {
|
|
|
59
59
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
60
60
|
underline: PropTypes.Requireable<boolean>;
|
|
61
61
|
strong: PropTypes.Requireable<boolean>;
|
|
62
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
62
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
|
|
63
63
|
heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
|
|
64
64
|
style: PropTypes.Requireable<object>;
|
|
65
65
|
className: PropTypes.Requireable<string>;
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -69,4 +69,6 @@ export declare const isSemiIcon: (icon: any) => boolean;
|
|
|
69
69
|
export declare function getActiveElement(): HTMLElement | null;
|
|
70
70
|
export declare function isNodeContainsFocus(node: HTMLElement): boolean;
|
|
71
71
|
export declare function getFocusableElements(node: HTMLElement): HTMLElement[];
|
|
72
|
+
export declare function runAfterTicks(func: (...args: any) => any, numberOfTicks: number): Promise<void>;
|
|
72
73
|
export declare function getScrollbarWidth(): number;
|
|
74
|
+
export declare function getDefaultPropsFromGlobalConfig(componentName: string, semiDefaultProps?: any): any;
|
package/lib/es/_utils/index.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
import _get from "lodash/get";
|
|
2
2
|
import _set from "lodash/set";
|
|
3
3
|
import _cloneDeepWith from "lodash/cloneDeepWith";
|
|
4
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) {
|
|
6
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
7
|
+
resolve(value);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.next(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function rejected(value) {
|
|
19
|
+
try {
|
|
20
|
+
step(generator["throw"](value));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
reject(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function step(result) {
|
|
26
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
+
}
|
|
28
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
+
});
|
|
30
|
+
};
|
|
4
31
|
import React from 'react';
|
|
5
32
|
import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
|
|
6
33
|
import { findAll } from '@douyinfe/semi-foundation/lib/es/utils/getHighlight';
|
|
7
34
|
import { isHTMLElement } from '@douyinfe/semi-foundation/lib/es/utils/dom';
|
|
35
|
+
import semiGlobal from "./semi-global";
|
|
8
36
|
/**
|
|
9
37
|
* stop propagation
|
|
10
38
|
*
|
|
@@ -154,9 +182,56 @@ export function getFocusableElements(node) {
|
|
|
154
182
|
const focusableElements = Array.from(node.querySelectorAll(focusableSelectorsStr));
|
|
155
183
|
return focusableElements;
|
|
156
184
|
}
|
|
185
|
+
export function runAfterTicks(func, numberOfTicks) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
if (numberOfTicks === 0) {
|
|
188
|
+
yield func();
|
|
189
|
+
return;
|
|
190
|
+
} else {
|
|
191
|
+
yield new Promise(resolve => {
|
|
192
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
yield runAfterTicks(func, numberOfTicks - 1);
|
|
194
|
+
resolve();
|
|
195
|
+
}), 0);
|
|
196
|
+
});
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
157
201
|
export function getScrollbarWidth() {
|
|
158
202
|
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
159
203
|
return window.innerWidth - document.documentElement.clientWidth;
|
|
160
204
|
}
|
|
161
205
|
return 0;
|
|
206
|
+
}
|
|
207
|
+
export function getDefaultPropsFromGlobalConfig(componentName) {
|
|
208
|
+
let semiDefaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
209
|
+
const getFromGlobalConfig = () => {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
return ((_b = (_a = semiGlobal === null || semiGlobal === void 0 ? void 0 : semiGlobal.config) === null || _a === void 0 ? void 0 : _a.overrideDefaultProps) === null || _b === void 0 ? void 0 : _b[componentName]) || {};
|
|
212
|
+
};
|
|
213
|
+
return new Proxy(Object.assign({}, semiDefaultProps), {
|
|
214
|
+
get(target, key, receiver) {
|
|
215
|
+
const defaultPropsFromGlobal = getFromGlobalConfig();
|
|
216
|
+
if (key in defaultPropsFromGlobal) {
|
|
217
|
+
return defaultPropsFromGlobal[key];
|
|
218
|
+
}
|
|
219
|
+
return Reflect.get(target, key, receiver);
|
|
220
|
+
},
|
|
221
|
+
set(target, key, value, receiver) {
|
|
222
|
+
return Reflect.set(target, key, value, receiver);
|
|
223
|
+
},
|
|
224
|
+
ownKeys() {
|
|
225
|
+
const defaultPropsFromGlobal = getFromGlobalConfig();
|
|
226
|
+
return Array.from(new Set([...Reflect.ownKeys(semiDefaultProps), ...Object.keys(defaultPropsFromGlobal)]));
|
|
227
|
+
},
|
|
228
|
+
getOwnPropertyDescriptor(target, key) {
|
|
229
|
+
const defaultPropsFromGlobal = getFromGlobalConfig();
|
|
230
|
+
if (key in defaultPropsFromGlobal) {
|
|
231
|
+
return Reflect.getOwnPropertyDescriptor(defaultPropsFromGlobal, key);
|
|
232
|
+
} else {
|
|
233
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
162
237
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AutoCompleteProps } from "../autoComplete";
|
|
2
|
+
import type { AvatarProps } from "../avatar";
|
|
3
|
+
import type { CascaderProps } from "../cascader";
|
|
4
|
+
import type { CollapseReactProps } from "../collapse";
|
|
5
|
+
import type { CollapsibleProps } from "../collapsible";
|
|
6
|
+
import type { DatePickerProps } from "../datePicker";
|
|
7
|
+
import type { DropdownProps } from "../dropdown";
|
|
8
|
+
import type { ModalReactProps } from "../modal";
|
|
9
|
+
import type { NavProps } from "../navigation";
|
|
10
|
+
import type { NoticeReactProps } from "../notification";
|
|
11
|
+
import type { OverflowListProps } from "../overflowList";
|
|
12
|
+
import type { PopconfirmProps } from "../popconfirm";
|
|
13
|
+
import type { PopoverProps } from "../popover";
|
|
14
|
+
import type { SelectProps } from "../select";
|
|
15
|
+
import type { SideSheetReactProps } from "../sideSheet";
|
|
16
|
+
import type { TabsProps } from "../tabs";
|
|
17
|
+
import type { TimePickerProps } from "../timePicker";
|
|
18
|
+
import type { ToastReactProps } from "../toast";
|
|
19
|
+
import type { TooltipProps } from "../tooltip";
|
|
20
|
+
declare class SemiGlobal {
|
|
21
|
+
config: {
|
|
22
|
+
overrideDefaultProps?: {
|
|
23
|
+
"AutoComplete"?: Partial<AutoCompleteProps<any>>;
|
|
24
|
+
"Avatar"?: Partial<AvatarProps>;
|
|
25
|
+
Cascader?: Partial<CascaderProps>;
|
|
26
|
+
Collapse?: Partial<CollapseReactProps>;
|
|
27
|
+
Collapsible?: Partial<CollapsibleProps>;
|
|
28
|
+
DatePicker?: Partial<DatePickerProps>;
|
|
29
|
+
Dropdown?: Partial<DropdownProps>;
|
|
30
|
+
Modal?: Partial<ModalReactProps>;
|
|
31
|
+
Navigation?: Partial<NavProps>;
|
|
32
|
+
Notification?: Partial<NoticeReactProps>;
|
|
33
|
+
OverflowList?: Partial<OverflowListProps>;
|
|
34
|
+
Popconfirm?: Partial<PopconfirmProps>;
|
|
35
|
+
Popover?: Partial<PopoverProps>;
|
|
36
|
+
Select?: Partial<SelectProps>;
|
|
37
|
+
SideSheet?: Partial<SideSheetReactProps>;
|
|
38
|
+
Tabs?: Partial<TabsProps>;
|
|
39
|
+
TimePicker?: Partial<TimePickerProps>;
|
|
40
|
+
Toast?: Partial<ToastReactProps>;
|
|
41
|
+
Tooltip?: Partial<TooltipProps>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
declare const _default: SemiGlobal;
|
|
46
|
+
export default _default;
|
|
@@ -139,31 +139,8 @@ declare class AutoComplete<T extends AutoCompleteItems> extends BaseComponent<Au
|
|
|
139
139
|
zIndex: PropTypes.Requireable<number>;
|
|
140
140
|
};
|
|
141
141
|
static Option: typeof Option;
|
|
142
|
-
static
|
|
143
|
-
|
|
144
|
-
motion: boolean;
|
|
145
|
-
zIndex: number;
|
|
146
|
-
position: "bottomLeft";
|
|
147
|
-
data: [];
|
|
148
|
-
showClear: boolean;
|
|
149
|
-
size: "default";
|
|
150
|
-
onFocus: (...args: any[]) => void;
|
|
151
|
-
onSearch: (...args: any[]) => void;
|
|
152
|
-
onClear: (...args: any[]) => void;
|
|
153
|
-
onBlur: (...args: any[]) => void;
|
|
154
|
-
onSelect: (...args: any[]) => void;
|
|
155
|
-
onChange: (...args: any[]) => void;
|
|
156
|
-
onSelectWithObject: boolean;
|
|
157
|
-
onDropdownVisibleChange: (...args: any[]) => void;
|
|
158
|
-
defaultActiveFirstOption: boolean;
|
|
159
|
-
dropdownMatchSelectWidth: boolean;
|
|
160
|
-
loading: boolean;
|
|
161
|
-
maxHeight: number;
|
|
162
|
-
validateStatus: "default";
|
|
163
|
-
autoFocus: boolean;
|
|
164
|
-
emptyContent: null;
|
|
165
|
-
onKeyDown: (...args: any[]) => void;
|
|
166
|
-
};
|
|
142
|
+
static __SemiComponentName__: string;
|
|
143
|
+
static defaultProps: any;
|
|
167
144
|
triggerRef: React.RefObject<HTMLDivElement> | null;
|
|
168
145
|
optionsRef: React.RefObject<HTMLDivElement> | null;
|
|
169
146
|
private clickOutsideHandler;
|
|
@@ -15,6 +15,7 @@ import Option from './option';
|
|
|
15
15
|
import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
|
|
16
16
|
import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
|
|
17
17
|
import ReactDOM from 'react-dom';
|
|
18
|
+
import { getDefaultPropsFromGlobalConfig } from "../_utils";
|
|
18
19
|
const prefixCls = cssClasses.PREFIX;
|
|
19
20
|
const sizeSet = strings.SIZE;
|
|
20
21
|
const positionSet = strings.POSITION;
|
|
@@ -385,7 +386,8 @@ AutoComplete.propTypes = {
|
|
|
385
386
|
zIndex: PropTypes.number
|
|
386
387
|
};
|
|
387
388
|
AutoComplete.Option = Option;
|
|
388
|
-
AutoComplete.
|
|
389
|
+
AutoComplete.__SemiComponentName__ = "AutoComplete";
|
|
390
|
+
AutoComplete.defaultProps = getDefaultPropsFromGlobalConfig(AutoComplete.__SemiComponentName__, {
|
|
389
391
|
stopPropagation: true,
|
|
390
392
|
motion: true,
|
|
391
393
|
zIndex: popoverNumbers.DEFAULT_Z_INDEX,
|
|
@@ -411,6 +413,6 @@ AutoComplete.defaultProps = {
|
|
|
411
413
|
onKeyDown: _noop
|
|
412
414
|
// onPressEnter: () => undefined,
|
|
413
415
|
// defaultOpen: false,
|
|
414
|
-
};
|
|
416
|
+
});
|
|
415
417
|
|
|
416
418
|
export default AutoComplete;
|
package/lib/es/avatar/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import AvatarFoundation, { AvatarAdapter } from '@douyinfe/semi-foundation/lib/es/avatar/foundation';
|
|
4
4
|
import '@douyinfe/semi-foundation/lib/es/avatar/avatar.css';
|
|
5
|
-
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
6
5
|
import BaseComponent from '../_base/baseComponent';
|
|
7
6
|
import { AvatarProps } from './interface';
|
|
8
7
|
export * from './interface';
|
|
@@ -13,15 +12,8 @@ export interface AvatarState {
|
|
|
13
12
|
scale: number;
|
|
14
13
|
}
|
|
15
14
|
export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
16
|
-
static
|
|
17
|
-
|
|
18
|
-
color: string;
|
|
19
|
-
shape: string;
|
|
20
|
-
gap: number;
|
|
21
|
-
onClick: typeof noop;
|
|
22
|
-
onMouseEnter: typeof noop;
|
|
23
|
-
onMouseLeave: typeof noop;
|
|
24
|
-
};
|
|
15
|
+
static __SemiComponentName__: string;
|
|
16
|
+
static defaultProps: any;
|
|
25
17
|
static elementType: string;
|
|
26
18
|
static propTypes: {
|
|
27
19
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
package/lib/es/avatar/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import '@douyinfe/semi-foundation/lib/es/avatar/avatar.css';
|
|
|
15
15
|
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
16
16
|
import BaseComponent from '../_base/baseComponent';
|
|
17
17
|
import { handlePrevent } from '@douyinfe/semi-foundation/lib/es/utils/a11y';
|
|
18
|
+
import { getDefaultPropsFromGlobalConfig } from "../_utils";
|
|
18
19
|
import TopSlotSvg from "./TopSlotSvg";
|
|
19
20
|
const sizeSet = strings.SIZE;
|
|
20
21
|
const shapeSet = strings.SHAPE;
|
|
@@ -345,7 +346,8 @@ export default class Avatar extends BaseComponent {
|
|
|
345
346
|
}
|
|
346
347
|
}
|
|
347
348
|
}
|
|
348
|
-
Avatar.
|
|
349
|
+
Avatar.__SemiComponentName__ = "Avatar";
|
|
350
|
+
Avatar.defaultProps = getDefaultPropsFromGlobalConfig(Avatar.__SemiComponentName__, {
|
|
349
351
|
size: 'medium',
|
|
350
352
|
color: 'grey',
|
|
351
353
|
shape: 'circle',
|
|
@@ -353,7 +355,7 @@ Avatar.defaultProps = {
|
|
|
353
355
|
onClick: noop,
|
|
354
356
|
onMouseEnter: noop,
|
|
355
357
|
onMouseLeave: noop
|
|
356
|
-
};
|
|
358
|
+
});
|
|
357
359
|
Avatar.propTypes = {
|
|
358
360
|
children: PropTypes.node,
|
|
359
361
|
color: PropTypes.oneOf(colorSet),
|
|
@@ -16,11 +16,8 @@ export interface BackTopState {
|
|
|
16
16
|
visible?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export default class BackTop extends BaseComponent<BackTopProps, BackTopState> {
|
|
19
|
-
static
|
|
20
|
-
|
|
21
|
-
target: () => Window & typeof globalThis;
|
|
22
|
-
duration: number;
|
|
23
|
-
};
|
|
19
|
+
static __SemiComponentName__: string;
|
|
20
|
+
static defaultProps: any;
|
|
24
21
|
static propTypes: {
|
|
25
22
|
target: PropTypes.Requireable<(...args: any[]) => any>;
|
|
26
23
|
visibilityHeight: PropTypes.Requireable<number>;
|
package/lib/es/backtop/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import BackTopFoundation from '@douyinfe/semi-foundation/lib/es/backtop/foundati
|
|
|
15
15
|
import '@douyinfe/semi-foundation/lib/es/backtop/backtop.css';
|
|
16
16
|
import IconButton from '../iconButton';
|
|
17
17
|
import { IconChevronUp } from '@douyinfe/semi-icons';
|
|
18
|
+
import { getDefaultPropsFromGlobalConfig } from "../_utils";
|
|
18
19
|
const prefixCls = cssClasses.PREFIX;
|
|
19
20
|
const getDefaultTarget = () => window;
|
|
20
21
|
export default class BackTop extends BaseComponent {
|
|
@@ -90,11 +91,12 @@ export default class BackTop extends BaseComponent {
|
|
|
90
91
|
return content;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
BackTop.
|
|
94
|
+
BackTop.__SemiComponentName__ = "BackTop";
|
|
95
|
+
BackTop.defaultProps = getDefaultPropsFromGlobalConfig(BackTop.__SemiComponentName__, {
|
|
94
96
|
visibilityHeight: 400,
|
|
95
97
|
target: getDefaultTarget,
|
|
96
98
|
duration: 450
|
|
97
|
-
};
|
|
99
|
+
});
|
|
98
100
|
BackTop.propTypes = {
|
|
99
101
|
target: PropTypes.func,
|
|
100
102
|
visibilityHeight: PropTypes.number,
|
|
@@ -48,7 +48,7 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
48
48
|
prefixCls: PropTypes.Requireable<string>;
|
|
49
49
|
style: PropTypes.Requireable<object>;
|
|
50
50
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
51
|
-
type: PropTypes.Requireable<"warning" | "primary" | "
|
|
51
|
+
type: PropTypes.Requireable<"warning" | "primary" | "secondary" | "danger" | "tertiary">;
|
|
52
52
|
block: PropTypes.Requireable<boolean>;
|
|
53
53
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
package/lib/es/button/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type { SplitButtonGroupProps } from './splitButtonGroup';
|
|
|
7
7
|
export interface ButtonProps extends IconButtonProps {
|
|
8
8
|
}
|
|
9
9
|
declare class Button extends React.PureComponent<ButtonProps> {
|
|
10
|
+
static __SemiComponentName__: string;
|
|
10
11
|
static propTypes: {
|
|
11
12
|
iconStyle: import("prop-types").Requireable<object>;
|
|
12
13
|
style: import("prop-types").Requireable<object>;
|
|
@@ -23,7 +24,7 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
23
24
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
25
|
disabled: import("prop-types").Requireable<boolean>;
|
|
25
26
|
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
-
type: import("prop-types").Requireable<"warning" | "primary" | "
|
|
27
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "secondary" | "danger" | "tertiary">;
|
|
27
28
|
block: import("prop-types").Requireable<boolean>;
|
|
28
29
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
29
30
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
@@ -33,6 +34,7 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
33
34
|
};
|
|
34
35
|
static elementType: string;
|
|
35
36
|
constructor(props?: ButtonProps);
|
|
37
|
+
static defaultProps: any;
|
|
36
38
|
render(): JSX.Element;
|
|
37
39
|
}
|
|
38
40
|
export default Button;
|
package/lib/es/button/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import BaseButton from './Button';
|
|
3
3
|
import IconButton from '../iconButton';
|
|
4
|
+
import { getDefaultPropsFromGlobalConfig } from "../_utils";
|
|
4
5
|
class Button extends React.PureComponent {
|
|
5
6
|
constructor() {
|
|
6
7
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -18,6 +19,8 @@ class Button extends React.PureComponent {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
Button.__SemiComponentName__ = "Button";
|
|
21
23
|
Button.propTypes = Object.assign(Object.assign({}, BaseButton.propTypes), IconButton.propTypes);
|
|
24
|
+
Button.defaultProps = getDefaultPropsFromGlobalConfig(Button.__SemiComponentName__);
|
|
22
25
|
Button.elementType = 'Button';
|
|
23
26
|
export default Button;
|