@douyinfe/semi-ui 2.10.0-alpha.0 → 2.10.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/banner/_story/banner.stories.js +62 -1
- package/banner/index.tsx +5 -5
- package/button/buttonGroup.tsx +2 -2
- package/carousel/CarouselArrow.tsx +62 -0
- package/carousel/CarouselIndicator.tsx +83 -0
- package/carousel/__test__/carousel.test.js +159 -0
- package/carousel/_story/carousel.stories.js +486 -0
- package/carousel/index.tsx +292 -0
- package/carousel/interface.ts +63 -0
- package/cascader/index.tsx +1 -2
- package/checkbox/checkbox.tsx +8 -18
- package/datePicker/monthsGrid.tsx +8 -8
- package/dist/css/semi.css +343 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +23525 -22602
- 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/baseForm.tsx +10 -1
- package/form/hoc/withField.tsx +25 -10
- package/index.ts +2 -0
- package/inputNumber/__test__/inputNumber.test.js +40 -3
- package/inputNumber/_story/inputNumber.stories.js +56 -1
- package/inputNumber/index.tsx +22 -14
- package/lib/cjs/_portal/index.d.ts +1 -1
- package/lib/cjs/banner/index.js +11 -5
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
- package/lib/cjs/carousel/CarouselArrow.js +88 -0
- package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/cjs/carousel/CarouselIndicator.js +145 -0
- package/lib/cjs/carousel/index.d.ts +58 -0
- package/lib/cjs/carousel/index.js +343 -0
- package/lib/cjs/carousel/interface.d.ts +61 -0
- package/lib/cjs/carousel/interface.js +7 -0
- package/lib/cjs/cascader/index.js +1 -1
- package/lib/cjs/checkbox/checkbox.d.ts +0 -4
- package/lib/cjs/checkbox/checkbox.js +13 -25
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/insetInput.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.js +6 -6
- package/lib/cjs/dropdown/dropdownMenu.d.ts +1 -0
- package/lib/cjs/form/baseForm.d.ts +2 -1
- package/lib/cjs/form/baseForm.js +10 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +14 -5
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/inputNumber/index.d.ts +2 -6
- package/lib/cjs/inputNumber/index.js +27 -11
- package/lib/cjs/modal/useModal/index.d.ts +1 -0
- package/lib/cjs/notification/useNotification/index.d.ts +1 -0
- package/lib/cjs/radio/radio.d.ts +1 -5
- package/lib/cjs/radio/radio.js +12 -26
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/scrollList/scrollItem.js +1 -1
- package/lib/cjs/switch/index.d.ts +3 -0
- package/lib/cjs/switch/index.js +26 -6
- package/lib/cjs/timePicker/Combobox.d.ts +1 -0
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/toast/useToast/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +11 -13
- package/lib/cjs/transfer/index.js +5 -5
- package/lib/cjs/treeSelect/index.js +1 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/es/_portal/index.d.ts +1 -1
- package/lib/es/banner/index.js +11 -5
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/carousel/CarouselArrow.d.ts +8 -0
- package/lib/es/carousel/CarouselArrow.js +70 -0
- package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/es/carousel/CarouselIndicator.js +125 -0
- package/lib/es/carousel/index.d.ts +58 -0
- package/lib/es/carousel/index.js +309 -0
- package/lib/es/carousel/interface.d.ts +61 -0
- package/lib/es/carousel/interface.js +1 -0
- package/lib/es/cascader/index.js +1 -1
- package/lib/es/checkbox/checkbox.d.ts +0 -4
- package/lib/es/checkbox/checkbox.js +13 -25
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/insetInput.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.js +7 -7
- package/lib/es/dropdown/dropdownMenu.d.ts +1 -0
- package/lib/es/form/baseForm.d.ts +2 -1
- package/lib/es/form/baseForm.js +10 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +14 -5
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/inputNumber/index.d.ts +2 -6
- package/lib/es/inputNumber/index.js +26 -11
- package/lib/es/modal/useModal/index.d.ts +1 -0
- package/lib/es/notification/useNotification/index.d.ts +1 -0
- package/lib/es/radio/radio.d.ts +1 -5
- package/lib/es/radio/radio.js +12 -26
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/scrollList/scrollItem.js +1 -1
- package/lib/es/switch/index.d.ts +3 -0
- package/lib/es/switch/index.js +26 -6
- package/lib/es/timePicker/Combobox.d.ts +1 -0
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/toast/useToast/index.d.ts +1 -0
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tooltip/index.js +11 -13
- package/lib/es/transfer/index.js +1 -1
- package/lib/es/treeSelect/index.js +1 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +1 -1
- package/package.json +9 -9
- package/popover/_story/popover.stories.js +38 -2
- package/radio/radio.tsx +7 -17
- package/scrollList/scrollItem.tsx +1 -1
- package/switch/index.tsx +20 -3
- package/tagInput/__test__/tagInput.test.js +11 -11
- package/timePicker/TimePicker.tsx +1 -1
- package/timePicker/_story/timepicker.stories.js +20 -1
- package/tooltip/index.tsx +11 -8
- package/transfer/index.tsx +1 -1
- package/treeSelect/index.tsx +1 -1
package/form/baseForm.tsx
CHANGED
|
@@ -122,7 +122,7 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
122
122
|
constructor(props: BaseFormProps) {
|
|
123
123
|
super(props);
|
|
124
124
|
this.state = {
|
|
125
|
-
formId:
|
|
125
|
+
formId: '',
|
|
126
126
|
};
|
|
127
127
|
warning(
|
|
128
128
|
Boolean(props.component && props.render),
|
|
@@ -145,6 +145,10 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
componentDidMount() {
|
|
149
|
+
this.foundation.init();
|
|
150
|
+
}
|
|
151
|
+
|
|
148
152
|
componentWillUnmount() {
|
|
149
153
|
this.foundation.destroy();
|
|
150
154
|
this.foundation = null;
|
|
@@ -173,6 +177,11 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
173
177
|
notifyReset: () => {
|
|
174
178
|
this.props.onReset();
|
|
175
179
|
},
|
|
180
|
+
initFormId: () => {
|
|
181
|
+
this.setState({
|
|
182
|
+
formId: getUuidv4()
|
|
183
|
+
});
|
|
184
|
+
},
|
|
176
185
|
getInitValues: () => this.props.initValues,
|
|
177
186
|
getFormProps: (keys: undefined | string | Array<string>) => {
|
|
178
187
|
if (typeof keys === 'undefined') {
|
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(() => {
|
|
@@ -376,12 +379,24 @@ function withField<
|
|
|
376
379
|
return () => {};
|
|
377
380
|
}
|
|
378
381
|
// log('register: ' + field);
|
|
379
|
-
|
|
382
|
+
|
|
383
|
+
// field value may change after field component mounted, we use ref value here to get changed value
|
|
384
|
+
const refValue = getVal();
|
|
385
|
+
updater.register(
|
|
380
386
|
field,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
{
|
|
388
|
+
value: refValue,
|
|
389
|
+
error,
|
|
390
|
+
touched,
|
|
391
|
+
status,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
field,
|
|
395
|
+
fieldApi,
|
|
396
|
+
keepState,
|
|
397
|
+
allowEmpty: allowEmpty || allowEmptyString,
|
|
398
|
+
}
|
|
399
|
+
);
|
|
385
400
|
// return unRegister cb
|
|
386
401
|
return () => {
|
|
387
402
|
updater.unRegister(field);
|
|
@@ -442,11 +457,11 @@ function withField<
|
|
|
442
457
|
if (helpText) {
|
|
443
458
|
newProps['aria-describedby'] = extraText ? `${helpTextId} ${extraTextId}` : helpTextId;
|
|
444
459
|
}
|
|
445
|
-
|
|
460
|
+
|
|
446
461
|
if (extraText) {
|
|
447
462
|
newProps['aria-describedby'] = helpText ? `${helpTextId} ${extraTextId}` : extraTextId;
|
|
448
463
|
}
|
|
449
|
-
|
|
464
|
+
|
|
450
465
|
if (status === 'error') {
|
|
451
466
|
newProps['aria-errormessage'] = errorMessageId;
|
|
452
467
|
newProps['aria-invalid'] = true;
|
package/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as ButtonGroup } from './button/buttonGroup';
|
|
|
12
12
|
export { default as Calendar } from './calendar';
|
|
13
13
|
export { default as Card } from './card';
|
|
14
14
|
export { default as CardGroup } from './card/cardGroup';
|
|
15
|
+
export { default as Carousel } from './carousel';
|
|
15
16
|
export { default as Cascader } from './cascader';
|
|
16
17
|
export { default as Checkbox } from './checkbox';
|
|
17
18
|
export { default as CheckboxGroup } from './checkbox/checkboxGroup';
|
|
@@ -79,6 +80,7 @@ export { default as Upload } from './upload';
|
|
|
79
80
|
export { default as Typography } from './typography';
|
|
80
81
|
export { default as Transfer } from './transfer';
|
|
81
82
|
|
|
83
|
+
|
|
82
84
|
export { default as LocaleProvider } from './locale/localeProvider';
|
|
83
85
|
|
|
84
86
|
/** Form */
|
|
@@ -6,7 +6,7 @@ import keyCode from '@douyinfe/semi-foundation/utils/keyCode';
|
|
|
6
6
|
import * as _ from 'lodash';
|
|
7
7
|
import { BASE_CLASS_PREFIX } from '../../../semi-foundation/base/constants';
|
|
8
8
|
import { numbers } from '@douyinfe/semi-foundation/inputNumber/constants';
|
|
9
|
-
import { Form, withField } from '../../index';
|
|
9
|
+
import { Form, withField, useFormApi } from '../../index';
|
|
10
10
|
|
|
11
11
|
const log = (...args) => console.log(...args);
|
|
12
12
|
const times = (n = 0, fn) => {
|
|
@@ -182,8 +182,9 @@ describe(`InputNumber`, () => {
|
|
|
182
182
|
const inputElem = inputNumber.find('input');
|
|
183
183
|
|
|
184
184
|
inputElem.simulate('change', event);
|
|
185
|
-
expect(onChange.
|
|
186
|
-
expect(onChange.
|
|
185
|
+
expect(onChange.calledTwice).toBe(true);
|
|
186
|
+
expect(onChange.getCall(1).args[0]).toEqual(Number(newValue.toFixed(precision)));
|
|
187
|
+
// expect(onChange.calledWithMatch(Number(newValue.toFixed(precision)))).toBe(true);
|
|
187
188
|
expect(inputElem.instance().value).toBe(formatter(newValue));
|
|
188
189
|
|
|
189
190
|
inputElem.simulate('blur');
|
|
@@ -395,4 +396,40 @@ describe(`InputNumber`, () => {
|
|
|
395
396
|
expect(onUpClick.called).toBe(false);
|
|
396
397
|
expect(onDownClick.called).toBe(false);
|
|
397
398
|
});
|
|
399
|
+
|
|
400
|
+
it('fix controlled min value didMount', () => {
|
|
401
|
+
const spyChange = sinon.spy();
|
|
402
|
+
const inputNumber = mount(
|
|
403
|
+
<InputNumber min={1} value={0} onChange={spyChange} />
|
|
404
|
+
);
|
|
405
|
+
expect(spyChange.calledOnce).toBe(true);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('fix controlled min value didUpdate', () => {
|
|
409
|
+
const spyChange = sinon.spy();
|
|
410
|
+
const value = undefined;
|
|
411
|
+
const inputNumber = mount(
|
|
412
|
+
<InputNumber min={1} value={value} onChange={spyChange} />
|
|
413
|
+
);
|
|
414
|
+
inputNumber.setProps({ value: 0 });
|
|
415
|
+
expect(spyChange.calledTwice).toBe(true);
|
|
416
|
+
expect(spyChange.getCall(0).args[0]).toEqual('');
|
|
417
|
+
expect(spyChange.getCall(1).args[0]).toEqual(1);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('fix controlled min value form field', () => {
|
|
421
|
+
const spyChange = sinon.spy();
|
|
422
|
+
let formApi = null;
|
|
423
|
+
let getFormApi = api => {
|
|
424
|
+
formApi = api;
|
|
425
|
+
};
|
|
426
|
+
const inputNumber = mount(
|
|
427
|
+
<Form initValues={{ minControlled: 0 }} getFormApi={getFormApi}>
|
|
428
|
+
<Form.InputNumber field="minControlled" min={1} onChange={spyChange} />
|
|
429
|
+
</Form>
|
|
430
|
+
);
|
|
431
|
+
expect(spyChange.calledOnce).toBe(true);
|
|
432
|
+
expect(spyChange.getCall(0).args[0]).toEqual(1);
|
|
433
|
+
expect(formApi.getValue('minControlled')).toBe(1);
|
|
434
|
+
});
|
|
398
435
|
});
|
|
@@ -4,6 +4,7 @@ import './inputNumber.scss';
|
|
|
4
4
|
import InputNumber from '../index';
|
|
5
5
|
import Button from '../../button/index';
|
|
6
6
|
import { withField, Form } from '../../index';
|
|
7
|
+
import { useFormApi } from '../../form';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: 'InputNumber',
|
|
@@ -656,4 +657,58 @@ export const FixPrecision = () => {
|
|
|
656
657
|
<InputNumber keepFocus onBlur={() => console.log('blur')} onChange={v => setValue2(v)} value={value2} style={{ width: 190 }} precision={2} />
|
|
657
658
|
</div>
|
|
658
659
|
);
|
|
659
|
-
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* 受控传超出 min value 的值,需要触发 onChange
|
|
664
|
+
* 不然在 Form 中使用可能会导致 Form State 与 InputNumber 展示的值不同问题
|
|
665
|
+
*/
|
|
666
|
+
export const FixMinValue = () => {
|
|
667
|
+
const [value, setValue] = useState();
|
|
668
|
+
const formRef = useFormApi();
|
|
669
|
+
return (
|
|
670
|
+
<div style={{ width: 280 }}>
|
|
671
|
+
<Button onClick={() => setValue(0)}>min=1, setValue=0</Button>
|
|
672
|
+
<InputNumber
|
|
673
|
+
min={1}
|
|
674
|
+
value={value}
|
|
675
|
+
onChange={(v, e) => {
|
|
676
|
+
console.log('inputNumber1 change', `'${v}'`, e);
|
|
677
|
+
setValue(v);
|
|
678
|
+
}}
|
|
679
|
+
/>
|
|
680
|
+
<InputNumber
|
|
681
|
+
min={1}
|
|
682
|
+
value={0}
|
|
683
|
+
onChange={(v, e) => {
|
|
684
|
+
console.log('inputNumber2 change', v, e);
|
|
685
|
+
}}
|
|
686
|
+
/>
|
|
687
|
+
<Form initValues={{ minControlled: 0 }}>
|
|
688
|
+
<Form.InputNumber
|
|
689
|
+
field='minControlled'
|
|
690
|
+
min={1}
|
|
691
|
+
onChange={(v, e) => {
|
|
692
|
+
console.log('form inputNumber change', v, e);
|
|
693
|
+
}}
|
|
694
|
+
/>
|
|
695
|
+
</Form>
|
|
696
|
+
<Button onClick={() => formRef.current.setValue('minControlled', 0) }>set form value</Button>
|
|
697
|
+
<Button onClick={() => { console.log('form value', JSON.stringify(formRef.current.getValues()))}}>get form values</Button>
|
|
698
|
+
</div>
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
FixMinValue.storyName = 'fix min value';
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* fix InputNumber precision 删除后,输入非法字符显示 0.00
|
|
705
|
+
* https://github.com/DouyinFE/semi-design/issues/786
|
|
706
|
+
*/
|
|
707
|
+
export const FixPrecision786 = () => {
|
|
708
|
+
return (
|
|
709
|
+
<div data-cy="fix-precision-786">
|
|
710
|
+
<InputNumber defaultValue={10.00} precision={2} />
|
|
711
|
+
</div>
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
FixPrecision786.storyName = 'fix precision 删除后输入非法值会显示 0.00';
|
package/inputNumber/index.tsx
CHANGED
|
@@ -10,13 +10,13 @@ import Input, { InputProps } from '../input';
|
|
|
10
10
|
import { forwardStatics } from '@douyinfe/semi-foundation/utils/object';
|
|
11
11
|
import isNullOrUndefined from '@douyinfe/semi-foundation/utils/isNullOrUndefined';
|
|
12
12
|
import isBothNaN from '@douyinfe/semi-foundation/utils/isBothNaN';
|
|
13
|
-
import InputNumberFoundation, { InputNumberAdapter } from '@douyinfe/semi-foundation/inputNumber/foundation';
|
|
13
|
+
import InputNumberFoundation, { BaseInputNumberState, InputNumberAdapter } from '@douyinfe/semi-foundation/inputNumber/foundation';
|
|
14
14
|
import BaseComponent from '../_base/baseComponent';
|
|
15
15
|
import { cssClasses, numbers, strings } from '@douyinfe/semi-foundation/inputNumber/constants';
|
|
16
16
|
import { IconChevronUp, IconChevronDown } from '@douyinfe/semi-icons';
|
|
17
17
|
|
|
18
18
|
import '@douyinfe/semi-foundation/inputNumber/inputNumber.scss';
|
|
19
|
-
import { isNaN, noop } from 'lodash';
|
|
19
|
+
import { isNaN, isString, noop } from 'lodash';
|
|
20
20
|
import { ArrayElement } from '../_base/base';
|
|
21
21
|
|
|
22
22
|
export interface InputNumberProps extends InputProps {
|
|
@@ -54,12 +54,7 @@ export interface InputNumberProps extends InputProps {
|
|
|
54
54
|
onUpClick?: (value: string, e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export interface InputNumberState {
|
|
58
|
-
value?: number | string;
|
|
59
|
-
number?: number | null; // Current parsed numbers
|
|
60
|
-
focusing?: boolean;
|
|
61
|
-
hovering?: boolean;
|
|
62
|
-
}
|
|
57
|
+
export interface InputNumberState extends BaseInputNumberState {}
|
|
63
58
|
|
|
64
59
|
class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
65
60
|
static propTypes = {
|
|
@@ -222,6 +217,9 @@ class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
|
222
217
|
},
|
|
223
218
|
setClickUpOrDown: value => {
|
|
224
219
|
this.clickUpOrDown = value;
|
|
220
|
+
},
|
|
221
|
+
updateStates: (states, callback) => {
|
|
222
|
+
this.setState(states, callback);
|
|
225
223
|
}
|
|
226
224
|
};
|
|
227
225
|
}
|
|
@@ -250,13 +248,15 @@ class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
|
250
248
|
componentDidUpdate(prevProps: InputNumberProps) {
|
|
251
249
|
const { value } = this.props;
|
|
252
250
|
const { focusing } = this.state;
|
|
251
|
+
let newValue;
|
|
253
252
|
/**
|
|
254
253
|
* To determine whether the front and back are equal
|
|
255
254
|
* NaN need to check whether both are NaN
|
|
256
255
|
*/
|
|
257
256
|
if (value !== prevProps.value && !isBothNaN(value, prevProps.value)) {
|
|
258
257
|
if (isNullOrUndefined(value) || value === '') {
|
|
259
|
-
|
|
258
|
+
newValue = '';
|
|
259
|
+
this.foundation.updateStates({ value: newValue, number: null });
|
|
260
260
|
} else {
|
|
261
261
|
let valueStr = value;
|
|
262
262
|
if (typeof value === 'number') {
|
|
@@ -306,22 +306,30 @@ class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
|
306
306
|
*/
|
|
307
307
|
if (this.clickUpOrDown) {
|
|
308
308
|
obj.value = this.foundation.doFormat(valueStr, true);
|
|
309
|
+
newValue = obj.value;
|
|
309
310
|
}
|
|
310
|
-
this.
|
|
311
|
+
this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
|
|
311
312
|
} else if (!isNaN(toNum)) {
|
|
312
313
|
// Update input content when controlled input is illegal and not NaN
|
|
313
|
-
|
|
314
|
+
newValue = this.foundation.doFormat(toNum, false);
|
|
315
|
+
this.foundation.updateStates({ value: newValue });
|
|
314
316
|
} else {
|
|
315
317
|
// Update input content when controlled input NaN
|
|
316
|
-
|
|
318
|
+
newValue = this.foundation.doFormat(valueStr, false);
|
|
319
|
+
this.foundation.updateStates({ value: newValue });
|
|
317
320
|
}
|
|
318
321
|
} else if (this.foundation.isValidNumber(parsedNum)) {
|
|
319
|
-
|
|
322
|
+
newValue = this.foundation.doFormat(parsedNum);
|
|
323
|
+
this.foundation.updateStates({ number: parsedNum, value: newValue });
|
|
320
324
|
} else {
|
|
321
325
|
// Invalid digital analog blurring effect instead of controlled failure
|
|
322
|
-
|
|
326
|
+
newValue = '';
|
|
327
|
+
this.foundation.updateStates({ number: null, value: newValue });
|
|
323
328
|
}
|
|
324
329
|
}
|
|
330
|
+
if (isString(newValue) && newValue !== String(this.props.value)) {
|
|
331
|
+
this.foundation.notifyChange(newValue, null);
|
|
332
|
+
}
|
|
325
333
|
}
|
|
326
334
|
|
|
327
335
|
if (!this.clickUpOrDown) {
|
|
@@ -33,6 +33,6 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
|
33
33
|
componentWillUnmount(): void;
|
|
34
34
|
addStyle: (style?: {}) => void;
|
|
35
35
|
addClass: (prefixCls: string, ...classNames: string[]) => void;
|
|
36
|
-
render():
|
|
36
|
+
render(): React.ReactPortal;
|
|
37
37
|
}
|
|
38
38
|
export default Portal;
|
package/lib/cjs/banner/index.js
CHANGED
|
@@ -92,7 +92,9 @@ class Banner extends _baseComponent.default {
|
|
|
92
92
|
const closer = /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
93
93
|
className: "".concat(prefixCls, "-close"),
|
|
94
94
|
onClick: this.remove,
|
|
95
|
-
icon: closeIcon || /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose,
|
|
95
|
+
icon: closeIcon || /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, {
|
|
96
|
+
"aria-hidden": true
|
|
97
|
+
}),
|
|
96
98
|
theme: "borderless",
|
|
97
99
|
size: "small",
|
|
98
100
|
type: "tertiary",
|
|
@@ -109,16 +111,20 @@ class Banner extends _baseComponent.default {
|
|
|
109
111
|
} = this.props;
|
|
110
112
|
const iconMap = {
|
|
111
113
|
warning: /*#__PURE__*/_react.default.createElement(_semiIcons.IconAlertTriangle, {
|
|
112
|
-
size: "large"
|
|
114
|
+
size: "large",
|
|
115
|
+
"aria-label": 'warning'
|
|
113
116
|
}),
|
|
114
117
|
success: /*#__PURE__*/_react.default.createElement(_semiIcons.IconTickCircle, {
|
|
115
|
-
size: "large"
|
|
118
|
+
size: "large",
|
|
119
|
+
"aria-label": 'success'
|
|
116
120
|
}),
|
|
117
121
|
info: /*#__PURE__*/_react.default.createElement(_semiIcons.IconInfoCircle, {
|
|
118
|
-
size: "large"
|
|
122
|
+
size: "large",
|
|
123
|
+
"aria-label": 'info'
|
|
119
124
|
}),
|
|
120
125
|
danger: /*#__PURE__*/_react.default.createElement(_semiIcons.IconAlertCircle, {
|
|
121
|
-
size: "large"
|
|
126
|
+
size: "large",
|
|
127
|
+
"aria-label": 'danger'
|
|
122
128
|
})
|
|
123
129
|
};
|
|
124
130
|
let iconType = iconMap[type];
|
|
@@ -10,7 +10,7 @@ export interface ButtonGroupProps extends BaseProps {
|
|
|
10
10
|
size?: Size;
|
|
11
11
|
theme?: Theme;
|
|
12
12
|
className?: string;
|
|
13
|
-
children?: React.
|
|
13
|
+
children?: React.ReactNode;
|
|
14
14
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
15
15
|
}
|
|
16
16
|
export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { CarouselArrowProps } from "./interface";
|
|
3
|
+
declare class CarouselArrow extends React.PureComponent<CarouselArrowProps> {
|
|
4
|
+
renderLeftIcon: () => any;
|
|
5
|
+
renderRightIcon: () => any;
|
|
6
|
+
render(): ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export default CarouselArrow;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
|
|
13
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
14
|
+
|
|
15
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
16
|
+
|
|
17
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
18
|
+
|
|
19
|
+
var _react = _interopRequireDefault(require("react"));
|
|
20
|
+
|
|
21
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
22
|
+
|
|
23
|
+
var _constants = require("@douyinfe/semi-foundation/lib/cjs/carousel/constants");
|
|
24
|
+
|
|
25
|
+
var _semiIcons = require("@douyinfe/semi-icons");
|
|
26
|
+
|
|
27
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
28
|
+
|
|
29
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
30
|
+
class CarouselArrow extends _react.default.PureComponent {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
|
|
34
|
+
this.renderLeftIcon = () => {
|
|
35
|
+
return (0, _get2.default)(this.props, 'arrowProps.leftArrow.children', /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronLeft, {
|
|
36
|
+
"aria-label": "Previous index",
|
|
37
|
+
size: "inherit"
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
this.renderRightIcon = () => {
|
|
42
|
+
return (0, _get2.default)(this.props, 'arrowProps.rightArrow.children', /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronRight, {
|
|
43
|
+
"aria-label": "Next index",
|
|
44
|
+
size: "inherit"
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
render() {
|
|
50
|
+
var _context, _context2, _context3;
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
type,
|
|
54
|
+
theme,
|
|
55
|
+
prev,
|
|
56
|
+
next
|
|
57
|
+
} = this.props;
|
|
58
|
+
const classNames = (0, _classnames.default)({
|
|
59
|
+
[_constants.cssClasses.CAROUSEL_ARROW]: true,
|
|
60
|
+
[(0, _concat.default)(_context = "".concat(_constants.cssClasses.CAROUSEL_ARROW, "-")).call(_context, theme)]: theme,
|
|
61
|
+
["".concat(_constants.cssClasses.CAROUSEL_ARROW, "-hover")]: type === 'hover'
|
|
62
|
+
});
|
|
63
|
+
const leftClassNames = (0, _classnames.default)({
|
|
64
|
+
["".concat(_constants.cssClasses.CAROUSEL_ARROW, "-prev")]: true,
|
|
65
|
+
[(0, _concat.default)(_context2 = "".concat(_constants.cssClasses.CAROUSEL_ARROW, "-")).call(_context2, theme)]: theme
|
|
66
|
+
});
|
|
67
|
+
const rightClassNames = (0, _classnames.default)({
|
|
68
|
+
["".concat(_constants.cssClasses.CAROUSEL_ARROW, "-next")]: true,
|
|
69
|
+
[(0, _concat.default)(_context3 = "".concat(_constants.cssClasses.CAROUSEL_ARROW, "-")).call(_context3, theme)]: theme
|
|
70
|
+
});
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
className: classNames
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
|
|
74
|
+
// role='button'
|
|
75
|
+
className: leftClassNames,
|
|
76
|
+
onClick: prev
|
|
77
|
+
}, (0, _get2.default)(this.props, 'arrowProps.leftArrow.props')), this.renderLeftIcon()), /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
|
|
78
|
+
// role='button'
|
|
79
|
+
// tabIndex={0}
|
|
80
|
+
className: rightClassNames,
|
|
81
|
+
onClick: next
|
|
82
|
+
}, (0, _get2.default)(this.props, 'arrowProps.rightArrow.props')), this.renderRightIcon()));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var _default = CarouselArrow;
|
|
88
|
+
exports.default = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CarouselIndicatorProps } from "./interface";
|
|
4
|
+
declare class CarouselIndicator extends React.PureComponent<CarouselIndicatorProps> {
|
|
5
|
+
static propTypes: {
|
|
6
|
+
activeKey: PropTypes.Requireable<number>;
|
|
7
|
+
className: PropTypes.Requireable<string>;
|
|
8
|
+
position: PropTypes.Requireable<"left" | "right" | "center">;
|
|
9
|
+
size: PropTypes.Requireable<"small" | "medium">;
|
|
10
|
+
style: PropTypes.Requireable<object>;
|
|
11
|
+
theme: PropTypes.Requireable<"primary" | "dark" | "light">;
|
|
12
|
+
total: PropTypes.Requireable<number>;
|
|
13
|
+
onIndicatorChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
type: PropTypes.Requireable<"line" | "dot" | "columnar">;
|
|
15
|
+
trigger: PropTypes.Requireable<"hover" | "click">;
|
|
16
|
+
};
|
|
17
|
+
onIndicatorChange: (activeIndex: number) => void;
|
|
18
|
+
handleIndicatorClick: (activeIndex: number) => void;
|
|
19
|
+
handleIndicatorHover: (activeIndex: number) => void;
|
|
20
|
+
renderIndicatorContent(): ReactNode;
|
|
21
|
+
render(): ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export default CarouselIndicator;
|