@douyinfe/semi-ui 2.9.0 → 2.9.1
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/badge/_story/badge.stories.js +34 -2
- package/dist/css/semi.css +1 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +159 -260
- 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/form/hoc/withField.tsx +8 -5
- package/lib/cjs/form/hoc/withField.js +6 -4
- package/lib/cjs/scrollList/scrollItem.js +1 -1
- package/lib/cjs/toast/toast.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +1 -1
- package/lib/es/form/hoc/withField.js +6 -4
- package/lib/es/scrollList/scrollItem.js +1 -1
- package/lib/es/toast/toast.d.ts +1 -1
- package/lib/es/tooltip/index.js +1 -1
- package/package.json +9 -9
- package/scrollList/scrollItem.tsx +1 -1
- package/timePicker/TimePicker.tsx +1 -1
- package/timePicker/_story/timepicker.stories.js +20 -1
- package/tooltip/index.tsx +1 -1
package/form/hoc/withField.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { Col } from '../../grid';
|
|
|
15
15
|
import { CallOpts, WithFieldOption } from '@douyinfe/semi-foundation/form/interface';
|
|
16
16
|
import { CommonFieldProps, CommonexcludeType } from '../interface';
|
|
17
17
|
import { Subtract } from 'utility-types';
|
|
18
|
+
import { noop } from "lodash";
|
|
18
19
|
|
|
19
20
|
const prefix = cssClasses.PREFIX;
|
|
20
21
|
|
|
@@ -121,6 +122,7 @@ function withField<
|
|
|
121
122
|
const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
|
|
122
123
|
|
|
123
124
|
const rulesRef = useRef(rules);
|
|
125
|
+
const validateRef = useRef(validate);
|
|
124
126
|
|
|
125
127
|
// notNotify is true means that the onChange of the Form does not need to be triggered
|
|
126
128
|
// notUpdate is true means that this operation does not need to trigger the forceUpdate
|
|
@@ -221,7 +223,7 @@ function withField<
|
|
|
221
223
|
let maybePromisedErrors;
|
|
222
224
|
// let errorThrowSync;
|
|
223
225
|
try {
|
|
224
|
-
maybePromisedErrors =
|
|
226
|
+
maybePromisedErrors = validateRef.current(val, values);
|
|
225
227
|
} catch (err) {
|
|
226
228
|
// error throw by syncValidate
|
|
227
229
|
maybePromisedErrors = err;
|
|
@@ -258,7 +260,7 @@ function withField<
|
|
|
258
260
|
if (transform) {
|
|
259
261
|
finalVal = transform(val);
|
|
260
262
|
}
|
|
261
|
-
if (
|
|
263
|
+
if (validateRef.current) {
|
|
262
264
|
return _validate(finalVal, updater.getValue(), callOpts);
|
|
263
265
|
} else if (latestRules) {
|
|
264
266
|
return _validateInternal(finalVal, callOpts);
|
|
@@ -357,7 +359,8 @@ function withField<
|
|
|
357
359
|
// avoid hooks capture value, fixed issue 346
|
|
358
360
|
useLayoutEffect(() => {
|
|
359
361
|
rulesRef.current = rules;
|
|
360
|
-
|
|
362
|
+
validateRef.current = validate;
|
|
363
|
+
}, [rules, validate]);
|
|
361
364
|
|
|
362
365
|
// exec validate once when trigger inlcude 'mount'
|
|
363
366
|
useLayoutEffect(() => {
|
|
@@ -442,11 +445,11 @@ function withField<
|
|
|
442
445
|
if (helpText) {
|
|
443
446
|
newProps['aria-describedby'] = extraText ? `${helpTextId} ${extraTextId}` : helpTextId;
|
|
444
447
|
}
|
|
445
|
-
|
|
448
|
+
|
|
446
449
|
if (extraText) {
|
|
447
450
|
newProps['aria-describedby'] = helpText ? `${helpTextId} ${extraTextId}` : extraTextId;
|
|
448
451
|
}
|
|
449
|
-
|
|
452
|
+
|
|
450
453
|
if (status === 'error') {
|
|
451
454
|
newProps['aria-errormessage'] = errorMessageId;
|
|
452
455
|
newProps['aria-invalid'] = true;
|
|
@@ -147,7 +147,8 @@ function withField(Component, opts) {
|
|
|
147
147
|
const [cursor, setCursor, getCursor] = (0, _index.useStateWithGetter)(0);
|
|
148
148
|
const [status, setStatus] = (0, _react.useState)(validateStatus); // use props.validateStatus to init
|
|
149
149
|
|
|
150
|
-
const rulesRef = (0, _react.useRef)(rules);
|
|
150
|
+
const rulesRef = (0, _react.useRef)(rules);
|
|
151
|
+
const validateRef = (0, _react.useRef)(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
|
|
151
152
|
// notUpdate is true means that this operation does not need to trigger the forceUpdate
|
|
152
153
|
|
|
153
154
|
const updateTouched = (isTouched, callOpts) => {
|
|
@@ -246,7 +247,7 @@ function withField(Component, opts) {
|
|
|
246
247
|
let maybePromisedErrors; // let errorThrowSync;
|
|
247
248
|
|
|
248
249
|
try {
|
|
249
|
-
maybePromisedErrors =
|
|
250
|
+
maybePromisedErrors = validateRef.current(val, values);
|
|
250
251
|
} catch (err) {
|
|
251
252
|
// error throw by syncValidate
|
|
252
253
|
maybePromisedErrors = err;
|
|
@@ -286,7 +287,7 @@ function withField(Component, opts) {
|
|
|
286
287
|
finalVal = transform(val);
|
|
287
288
|
}
|
|
288
289
|
|
|
289
|
-
if (
|
|
290
|
+
if (validateRef.current) {
|
|
290
291
|
return _validate(finalVal, updater.getValue(), callOpts);
|
|
291
292
|
} else if (latestRules) {
|
|
292
293
|
return _validateInternal(finalVal, callOpts);
|
|
@@ -395,7 +396,8 @@ function withField(Component, opts) {
|
|
|
395
396
|
|
|
396
397
|
(0, _react.useLayoutEffect)(() => {
|
|
397
398
|
rulesRef.current = rules;
|
|
398
|
-
|
|
399
|
+
validateRef.current = validate;
|
|
400
|
+
}, [rules, validate]); // exec validate once when trigger inlcude 'mount'
|
|
399
401
|
|
|
400
402
|
(0, _react.useLayoutEffect)(() => {
|
|
401
403
|
if (validateOnMount) {
|
|
@@ -201,7 +201,7 @@ class ScrollItem extends _baseComponent.default {
|
|
|
201
201
|
} = this;
|
|
202
202
|
const wrapperHeight = wrapper.offsetHeight;
|
|
203
203
|
const itemHeight = this.getItmHeight(node);
|
|
204
|
-
const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
|
|
204
|
+
const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
|
|
205
205
|
this.scrollToPos(targetTop, duration);
|
|
206
206
|
};
|
|
207
207
|
|
package/lib/cjs/toast/toast.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
41
41
|
close(e: React.MouseEvent): void;
|
|
42
42
|
clearCloseTimer: () => void;
|
|
43
43
|
startCloseTimer: () => void;
|
|
44
|
-
renderIcon(): true | React.
|
|
44
|
+
renderIcon(): string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment;
|
|
45
45
|
render(): JSX.Element;
|
|
46
46
|
}
|
|
47
47
|
export default Toast;
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -258,7 +258,7 @@ class Tooltip extends _baseComponent.default {
|
|
|
258
258
|
}, portalEventSet, {
|
|
259
259
|
"x-placement": placement,
|
|
260
260
|
style: (0, _assign.default)({
|
|
261
|
-
visibility: motion ?
|
|
261
|
+
visibility: motion ? 'hidden' : 'visible'
|
|
262
262
|
}, style)
|
|
263
263
|
}), contentNode, icon);
|
|
264
264
|
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
@@ -112,7 +112,8 @@ function withField(Component, opts) {
|
|
|
112
112
|
const [cursor, setCursor, getCursor] = useStateWithGetter(0);
|
|
113
113
|
const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
|
|
114
114
|
|
|
115
|
-
const rulesRef = useRef(rules);
|
|
115
|
+
const rulesRef = useRef(rules);
|
|
116
|
+
const validateRef = useRef(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
|
|
116
117
|
// notUpdate is true means that this operation does not need to trigger the forceUpdate
|
|
117
118
|
|
|
118
119
|
const updateTouched = (isTouched, callOpts) => {
|
|
@@ -213,7 +214,7 @@ function withField(Component, opts) {
|
|
|
213
214
|
let maybePromisedErrors; // let errorThrowSync;
|
|
214
215
|
|
|
215
216
|
try {
|
|
216
|
-
maybePromisedErrors =
|
|
217
|
+
maybePromisedErrors = validateRef.current(val, values);
|
|
217
218
|
} catch (err) {
|
|
218
219
|
// error throw by syncValidate
|
|
219
220
|
maybePromisedErrors = err;
|
|
@@ -253,7 +254,7 @@ function withField(Component, opts) {
|
|
|
253
254
|
finalVal = transform(val);
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
if (
|
|
257
|
+
if (validateRef.current) {
|
|
257
258
|
return _validate(finalVal, updater.getValue(), callOpts);
|
|
258
259
|
} else if (latestRules) {
|
|
259
260
|
return _validateInternal(finalVal, callOpts);
|
|
@@ -362,7 +363,8 @@ function withField(Component, opts) {
|
|
|
362
363
|
|
|
363
364
|
useLayoutEffect(() => {
|
|
364
365
|
rulesRef.current = rules;
|
|
365
|
-
|
|
366
|
+
validateRef.current = validate;
|
|
367
|
+
}, [rules, validate]); // exec validate once when trigger inlcude 'mount'
|
|
366
368
|
|
|
367
369
|
useLayoutEffect(() => {
|
|
368
370
|
if (validateOnMount) {
|
|
@@ -176,7 +176,7 @@ export default class ScrollItem extends BaseComponent {
|
|
|
176
176
|
} = this;
|
|
177
177
|
const wrapperHeight = wrapper.offsetHeight;
|
|
178
178
|
const itemHeight = this.getItmHeight(node);
|
|
179
|
-
const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
|
|
179
|
+
const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
|
|
180
180
|
this.scrollToPos(targetTop, duration);
|
|
181
181
|
};
|
|
182
182
|
|
package/lib/es/toast/toast.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
41
41
|
close(e: React.MouseEvent): void;
|
|
42
42
|
clearCloseTimer: () => void;
|
|
43
43
|
startCloseTimer: () => void;
|
|
44
|
-
renderIcon(): true | React.
|
|
44
|
+
renderIcon(): string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment;
|
|
45
45
|
render(): JSX.Element;
|
|
46
46
|
}
|
|
47
47
|
export default Toast;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -212,7 +212,7 @@ export default class Tooltip extends BaseComponent {
|
|
|
212
212
|
}, portalEventSet, {
|
|
213
213
|
"x-placement": placement,
|
|
214
214
|
style: _Object$assign({
|
|
215
|
-
visibility: motion ?
|
|
215
|
+
visibility: motion ? 'hidden' : 'visible'
|
|
216
216
|
}, style)
|
|
217
217
|
}), contentNode, icon);
|
|
218
218
|
return /*#__PURE__*/React.createElement(Portal, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.9.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.9.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.9.
|
|
20
|
-
"@douyinfe/semi-icons": "2.9.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.9.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.9.
|
|
17
|
+
"@douyinfe/semi-animation": "2.9.1",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.9.1",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.9.1",
|
|
20
|
+
"@douyinfe/semi-icons": "2.9.1",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.9.1",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.9.1",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "9593ab23b59b5a18305627ac402cfd4527072f9c",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.9.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.9.1",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
|
@@ -329,7 +329,7 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
|
|
|
329
329
|
const { wrapper } = this;
|
|
330
330
|
const wrapperHeight = wrapper.offsetHeight;
|
|
331
331
|
const itemHeight = this.getItmHeight(node);
|
|
332
|
-
const targetTop =
|
|
332
|
+
const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2 ) - (wrapperHeight - itemHeight) / 2;
|
|
333
333
|
|
|
334
334
|
this.scrollToPos(targetTop, duration);
|
|
335
335
|
};
|
|
@@ -475,7 +475,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
475
475
|
|
|
476
476
|
const panelPrefix = classNames({
|
|
477
477
|
[`${prefixCls}-panel`]: true,
|
|
478
|
-
[`${prefixCls}-panel-${
|
|
478
|
+
[`${prefixCls}-panel-${size}`]: size,
|
|
479
479
|
});
|
|
480
480
|
|
|
481
481
|
const inputProps = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component, useState } from 'react';
|
|
2
2
|
import TimePickerPanel from '../index';
|
|
3
|
-
import { TimePicker as BasicTimePicker, Button } from '../../index';
|
|
3
|
+
import { TimePicker as BasicTimePicker, Button, Form } from '../../index';
|
|
4
4
|
import { strings } from '@douyinfe/semi-foundation/timePicker/constants';
|
|
5
5
|
import { get } from 'lodash';
|
|
6
6
|
|
|
@@ -44,6 +44,12 @@ const init = () => {
|
|
|
44
44
|
init();
|
|
45
45
|
|
|
46
46
|
export const TimePickerPanelDefault = () => {
|
|
47
|
+
const initValues = {
|
|
48
|
+
testRange: [
|
|
49
|
+
new Date("2022-04-17T15:00:00"),
|
|
50
|
+
new Date("2022-04-17T18:00:00"),
|
|
51
|
+
],
|
|
52
|
+
};
|
|
47
53
|
return (
|
|
48
54
|
<div>
|
|
49
55
|
<TimePicker panelHeader={'Time Select'} onChange={val => console.log(val)} />
|
|
@@ -53,6 +59,19 @@ export const TimePickerPanelDefault = () => {
|
|
|
53
59
|
defaultOpen={true}
|
|
54
60
|
scrollItemProps={{ cycled: false }}
|
|
55
61
|
/>
|
|
62
|
+
<TimePicker use12Hours defaultValue={"上午 10:32:33"}/>
|
|
63
|
+
<br/><br/>
|
|
64
|
+
<TimePicker type="timeRange" use12Hours format="a h:mm" defaultValue={["下午 08:11", "上午 11:21"]} />
|
|
65
|
+
<Form initValues={initValues}>
|
|
66
|
+
<pre>{JSON.stringify(initValues)}</pre>
|
|
67
|
+
<Form.TimePicker
|
|
68
|
+
use12Hours
|
|
69
|
+
field="testRange"
|
|
70
|
+
label="Time Range"
|
|
71
|
+
type="timeRange"
|
|
72
|
+
format="a hh:mm"
|
|
73
|
+
/>
|
|
74
|
+
</Form>
|
|
56
75
|
</div>
|
|
57
76
|
);
|
|
58
77
|
};
|
package/tooltip/index.tsx
CHANGED
|
@@ -581,7 +581,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
581
581
|
}
|
|
582
582
|
</TooltipTransition>
|
|
583
583
|
) : (
|
|
584
|
-
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ?
|
|
584
|
+
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ? 'hidden' : 'visible', ...style }}>
|
|
585
585
|
{contentNode}
|
|
586
586
|
{icon}
|
|
587
587
|
</div>
|