@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
|
@@ -51,11 +51,15 @@ class Checkbox extends _baseComponent.default {
|
|
|
51
51
|
|
|
52
52
|
const checked = false;
|
|
53
53
|
this.state = {
|
|
54
|
-
checked: props.checked || props.defaultChecked || checked
|
|
55
|
-
addonId: props.addonId,
|
|
56
|
-
extraId: props.extraId
|
|
54
|
+
checked: props.checked || props.defaultChecked || checked
|
|
57
55
|
};
|
|
58
56
|
this.checkboxEntity = null;
|
|
57
|
+
this.addonId = (0, _uuid.getUuidShort)({
|
|
58
|
+
prefix: 'addon'
|
|
59
|
+
});
|
|
60
|
+
this.extraId = (0, _uuid.getUuidShort)({
|
|
61
|
+
prefix: 'extra'
|
|
62
|
+
});
|
|
59
63
|
this.foundation = new _checkboxFoundation.default(this.adapter);
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -77,21 +81,7 @@ class Checkbox extends _baseComponent.default {
|
|
|
77
81
|
notifyGroupChange: cbContent => {
|
|
78
82
|
this.context.checkboxGroup.onChange(cbContent);
|
|
79
83
|
},
|
|
80
|
-
getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
|
|
81
|
-
setAddonId: () => {
|
|
82
|
-
this.setState({
|
|
83
|
-
addonId: (0, _uuid.getUuidShort)({
|
|
84
|
-
prefix: 'addon'
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
setExtraId: () => {
|
|
89
|
-
this.setState({
|
|
90
|
-
extraId: (0, _uuid.getUuidShort)({
|
|
91
|
-
prefix: 'extra'
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
}
|
|
84
|
+
getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
|
|
95
85
|
});
|
|
96
86
|
}
|
|
97
87
|
|
|
@@ -134,9 +124,7 @@ class Checkbox extends _baseComponent.default {
|
|
|
134
124
|
id
|
|
135
125
|
} = this.props;
|
|
136
126
|
const {
|
|
137
|
-
checked
|
|
138
|
-
addonId,
|
|
139
|
-
extraId
|
|
127
|
+
checked
|
|
140
128
|
} = this.state;
|
|
141
129
|
const props = {
|
|
142
130
|
checked,
|
|
@@ -183,10 +171,10 @@ class Checkbox extends _baseComponent.default {
|
|
|
183
171
|
const name = inGroup && this.context.checkboxGroup.name;
|
|
184
172
|
|
|
185
173
|
const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
|
|
186
|
-
id: addonId,
|
|
174
|
+
id: this.addonId,
|
|
187
175
|
className: "".concat(prefix, "-addon")
|
|
188
176
|
}, children) : null, extra ? /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
-
id: extraId,
|
|
177
|
+
id: this.extraId,
|
|
190
178
|
className: extraCls
|
|
191
179
|
}, extra) : null);
|
|
192
180
|
|
|
@@ -206,8 +194,8 @@ class Checkbox extends _baseComponent.default {
|
|
|
206
194
|
onKeyPress: this.handleEnterPress,
|
|
207
195
|
"aria-labelledby": this.props['aria-labelledby']
|
|
208
196
|
}, /*#__PURE__*/_react.default.createElement(_checkboxInner.default, (0, _assign.default)({}, this.props, props, {
|
|
209
|
-
addonId: children && addonId,
|
|
210
|
-
extraId: extra && extraId,
|
|
197
|
+
addonId: children && this.addonId,
|
|
198
|
+
extraId: extra && this.extraId,
|
|
211
199
|
name: name,
|
|
212
200
|
isPureCardType: props.isPureCardType,
|
|
213
201
|
ref: ref => {
|
|
@@ -26,7 +26,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
26
26
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
27
|
value: PropTypes.Requireable<any[]>;
|
|
28
28
|
disabled: PropTypes.Requireable<boolean>;
|
|
29
|
-
type: PropTypes.Requireable<"
|
|
29
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
30
30
|
showClear: PropTypes.Requireable<boolean>;
|
|
31
31
|
format: PropTypes.Requireable<string>;
|
|
32
32
|
inputStyle: PropTypes.Requireable<object>;
|
|
@@ -41,7 +41,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
41
41
|
'aria-invalid': PropTypes.Requireable<boolean>;
|
|
42
42
|
'aria-labelledby': PropTypes.Requireable<string>;
|
|
43
43
|
'aria-required': PropTypes.Requireable<boolean>;
|
|
44
|
-
type: PropTypes.Requireable<"
|
|
44
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
45
45
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
46
46
|
density: PropTypes.Requireable<"default" | "compact">;
|
|
47
47
|
defaultValue: PropTypes.Requireable<string | number | object>;
|
|
@@ -17,7 +17,7 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
|
17
17
|
export declare type MonthsGridState = MonthsGridFoundationState;
|
|
18
18
|
export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
|
|
19
19
|
static propTypes: {
|
|
20
|
-
type: PropTypes.Requireable<"
|
|
20
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
21
21
|
defaultValue: PropTypes.Requireable<string | number | object>;
|
|
22
22
|
defaultPickerValue: PropTypes.Requireable<string | number | object>;
|
|
23
23
|
multiple: PropTypes.Requireable<boolean>;
|
|
@@ -505,7 +505,7 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
505
505
|
const dateFormat = this.foundation.getValidDateFormat();
|
|
506
506
|
let startDate, endDate;
|
|
507
507
|
|
|
508
|
-
if (type === 'dateTimeRange' && rangeStart && rangeEnd && (0, _dateFns.isSameDay)(startDate = (0, _parser.
|
|
508
|
+
if (type === 'dateTimeRange' && rangeStart && rangeEnd && (0, _dateFns.isSameDay)(startDate = (0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = (0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
|
|
509
509
|
if (panelType === _constants.strings.PANEL_TYPE_RIGHT) {
|
|
510
510
|
rangeStart && (restProps.startDate = startDate);
|
|
511
511
|
} else {
|
|
@@ -591,10 +591,10 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
591
591
|
|
|
592
592
|
if (panelType === _constants.strings.PANEL_TYPE_LEFT) {
|
|
593
593
|
panelDetail = monthLeft;
|
|
594
|
-
dateText = rangeStart ? (0, _dateFns.format)((0, _parser.
|
|
594
|
+
dateText = rangeStart ? (0, _dateFns.format)((0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
595
595
|
} else {
|
|
596
596
|
panelDetail = monthRight;
|
|
597
|
-
dateText = rangeEnd ? (0, _dateFns.format)((0, _parser.
|
|
597
|
+
dateText = rangeEnd ? (0, _dateFns.format)((0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
const {
|
|
@@ -603,7 +603,7 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
603
603
|
} = panelDetail;
|
|
604
604
|
const monthText = showDate ? (0, _dateFns.format)(showDate, FORMAT_SWITCH_DATE) : '';
|
|
605
605
|
const timeText = showDate ? (0, _dateFns.format)(showDate, formatTimePicker) : '';
|
|
606
|
-
const
|
|
606
|
+
const showSwitchIcon = (0, _includes.default)(_context3 = ['default']).call(_context3, density);
|
|
607
607
|
const switchCls = (0, _classnames.default)("".concat(prefixCls, "-switch"));
|
|
608
608
|
const dateCls = (0, _classnames.default)({
|
|
609
609
|
["".concat(prefixCls, "-switch-date")]: true,
|
|
@@ -623,7 +623,7 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
623
623
|
"aria-label": "Switch to date panel",
|
|
624
624
|
className: dateCls,
|
|
625
625
|
onClick: e => this.foundation.showDatePanel(panelType)
|
|
626
|
-
},
|
|
626
|
+
}, showSwitchIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar, {
|
|
627
627
|
"aria-hidden": true
|
|
628
628
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
629
629
|
className: textCls
|
|
@@ -632,7 +632,7 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
632
632
|
"aria-label": "Switch to time panel",
|
|
633
633
|
className: timeCls,
|
|
634
634
|
onClick: e => this.foundation.showTimePicker(panelType, true)
|
|
635
|
-
},
|
|
635
|
+
}, showSwitchIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconClock, {
|
|
636
636
|
"aria-hidden": true
|
|
637
637
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
638
638
|
className: textCls
|
|
@@ -125,7 +125,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
125
125
|
onBlur?: (e: React.FocusEvent<Element, Element>) => void;
|
|
126
126
|
onListScroll?: (e: React.UIEvent<HTMLDivElement, UIEvent>) => void;
|
|
127
127
|
children?: React.ReactNode;
|
|
128
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
128
|
+
} & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
129
129
|
static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
130
130
|
static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
131
131
|
static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
|
|
@@ -147,6 +147,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
147
147
|
static Section: typeof Section;
|
|
148
148
|
formApi: FormApi;
|
|
149
149
|
constructor(props: BaseFormProps);
|
|
150
|
+
componentDidMount(): void;
|
|
150
151
|
componentWillUnmount(): void;
|
|
151
152
|
get adapter(): BaseFormAdapter<BaseFormProps, BaseFormState>;
|
|
152
153
|
get content(): React.ReactNode;
|
package/lib/cjs/form/baseForm.js
CHANGED
|
@@ -85,7 +85,7 @@ class Form extends _baseComponent.default {
|
|
|
85
85
|
|
|
86
86
|
super(props);
|
|
87
87
|
this.state = {
|
|
88
|
-
formId:
|
|
88
|
+
formId: ''
|
|
89
89
|
};
|
|
90
90
|
(0, _warning.default)(Boolean(props.component && props.render), '[Semi Form] You should not use <Form component> and <Form render> in ths same time; <Form render> will be ignored');
|
|
91
91
|
(0, _warning.default)(props.component && props.children && !(0, _reactUtils.isEmptyChildren)(props.children), '[Semi Form] You should not use <Form component> and <Form>{children}</Form> in ths same time; <Form>{children}</Form> will be ignored');
|
|
@@ -100,6 +100,10 @@ class Form extends _baseComponent.default {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
componentDidMount() {
|
|
104
|
+
this.foundation.init();
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
componentWillUnmount() {
|
|
104
108
|
this.foundation.destroy();
|
|
105
109
|
this.foundation = null;
|
|
@@ -127,6 +131,11 @@ class Form extends _baseComponent.default {
|
|
|
127
131
|
notifyReset: () => {
|
|
128
132
|
this.props.onReset();
|
|
129
133
|
},
|
|
134
|
+
initFormId: () => {
|
|
135
|
+
this.setState({
|
|
136
|
+
formId: (0, _uuid.getUuidv4)()
|
|
137
|
+
});
|
|
138
|
+
},
|
|
130
139
|
getInitValues: () => this.props.initValues,
|
|
131
140
|
getFormProps: keys => {
|
|
132
141
|
if (typeof keys === 'undefined') {
|
package/lib/cjs/form/field.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
73
73
|
onBlur?: (e: import("react").FocusEvent<Element, Element>) => void;
|
|
74
74
|
onListScroll?: (e: import("react").UIEvent<HTMLDivElement, UIEvent>) => void;
|
|
75
75
|
children?: import("react").ReactNode;
|
|
76
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
76
|
+
} & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
77
77
|
declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
78
78
|
declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
79
79
|
declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
@@ -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) {
|
|
@@ -411,9 +413,16 @@ function withField(Component, opts) {
|
|
|
411
413
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
412
414
|
return () => {};
|
|
413
415
|
} // log('register: ' + field);
|
|
416
|
+
// field value may change after field component mounted, we use ref value here to get changed value
|
|
414
417
|
|
|
415
418
|
|
|
416
|
-
|
|
419
|
+
const refValue = getVal();
|
|
420
|
+
updater.register(field, {
|
|
421
|
+
value: refValue,
|
|
422
|
+
error,
|
|
423
|
+
touched,
|
|
424
|
+
status
|
|
425
|
+
}, {
|
|
417
426
|
field,
|
|
418
427
|
fieldApi,
|
|
419
428
|
keepState,
|
package/lib/cjs/index.d.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';
|
package/lib/cjs/index.js
CHANGED
|
@@ -110,6 +110,13 @@ _Object$defineProperty(exports, "CardGroup", {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
_Object$defineProperty(exports, "Carousel", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return _carousel.default;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
113
120
|
_Object$defineProperty(exports, "Cascader", {
|
|
114
121
|
enumerable: true,
|
|
115
122
|
get: function () {
|
|
@@ -656,6 +663,8 @@ var _card = _interopRequireDefault(require("./card"));
|
|
|
656
663
|
|
|
657
664
|
var _cardGroup = _interopRequireDefault(require("./card/cardGroup"));
|
|
658
665
|
|
|
666
|
+
var _carousel = _interopRequireDefault(require("./carousel"));
|
|
667
|
+
|
|
659
668
|
var _cascader = _interopRequireDefault(require("./cascader"));
|
|
660
669
|
|
|
661
670
|
var _checkbox = _interopRequireDefault(require("./checkbox"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { InputProps } from '../input';
|
|
4
|
-
import InputNumberFoundation, { InputNumberAdapter } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/foundation';
|
|
4
|
+
import InputNumberFoundation, { BaseInputNumberState, InputNumberAdapter } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/foundation';
|
|
5
5
|
import BaseComponent from '../_base/baseComponent';
|
|
6
6
|
import { strings } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/constants';
|
|
7
7
|
import '@douyinfe/semi-foundation/lib/cjs/inputNumber/inputNumber.css';
|
|
@@ -40,11 +40,7 @@ export interface InputNumberProps extends InputProps {
|
|
|
40
40
|
onNumberChange?: (value: number, e?: React.ChangeEvent) => void;
|
|
41
41
|
onUpClick?: (value: string, e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
42
42
|
}
|
|
43
|
-
export interface InputNumberState {
|
|
44
|
-
value?: number | string;
|
|
45
|
-
number?: number | null;
|
|
46
|
-
focusing?: boolean;
|
|
47
|
-
hovering?: boolean;
|
|
43
|
+
export interface InputNumberState extends BaseInputNumberState {
|
|
48
44
|
}
|
|
49
45
|
declare class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
50
46
|
static propTypes: {
|
|
@@ -24,6 +24,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
24
24
|
|
|
25
25
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
26
26
|
|
|
27
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
28
|
+
|
|
27
29
|
var _isNaN2 = _interopRequireDefault(require("lodash/isNaN"));
|
|
28
30
|
|
|
29
31
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -300,6 +302,9 @@ class InputNumber extends _baseComponent.default {
|
|
|
300
302
|
},
|
|
301
303
|
setClickUpOrDown: value => {
|
|
302
304
|
this.clickUpOrDown = value;
|
|
305
|
+
},
|
|
306
|
+
updateStates: (states, callback) => {
|
|
307
|
+
this.setState(states, callback);
|
|
303
308
|
}
|
|
304
309
|
});
|
|
305
310
|
}
|
|
@@ -311,6 +316,7 @@ class InputNumber extends _baseComponent.default {
|
|
|
311
316
|
const {
|
|
312
317
|
focusing
|
|
313
318
|
} = this.state;
|
|
319
|
+
let newValue;
|
|
314
320
|
/**
|
|
315
321
|
* To determine whether the front and back are equal
|
|
316
322
|
* NaN need to check whether both are NaN
|
|
@@ -318,8 +324,9 @@ class InputNumber extends _baseComponent.default {
|
|
|
318
324
|
|
|
319
325
|
if (value !== prevProps.value && !(0, _isBothNaN.default)(value, prevProps.value)) {
|
|
320
326
|
if ((0, _isNullOrUndefined.default)(value) || value === '') {
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
newValue = '';
|
|
328
|
+
this.foundation.updateStates({
|
|
329
|
+
value: newValue,
|
|
323
330
|
number: null
|
|
324
331
|
});
|
|
325
332
|
} else {
|
|
@@ -375,33 +382,42 @@ class InputNumber extends _baseComponent.default {
|
|
|
375
382
|
|
|
376
383
|
if (this.clickUpOrDown) {
|
|
377
384
|
obj.value = this.foundation.doFormat(valueStr, true);
|
|
385
|
+
newValue = obj.value;
|
|
378
386
|
}
|
|
379
387
|
|
|
380
|
-
this.
|
|
388
|
+
this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
|
|
381
389
|
} else if (!(0, _isNaN2.default)(toNum)) {
|
|
382
390
|
// Update input content when controlled input is illegal and not NaN
|
|
383
|
-
this.
|
|
384
|
-
|
|
391
|
+
newValue = this.foundation.doFormat(toNum, false);
|
|
392
|
+
this.foundation.updateStates({
|
|
393
|
+
value: newValue
|
|
385
394
|
});
|
|
386
395
|
} else {
|
|
387
396
|
// Update input content when controlled input NaN
|
|
388
|
-
this.
|
|
389
|
-
|
|
397
|
+
newValue = this.foundation.doFormat(valueStr, false);
|
|
398
|
+
this.foundation.updateStates({
|
|
399
|
+
value: newValue
|
|
390
400
|
});
|
|
391
401
|
}
|
|
392
402
|
} else if (this.foundation.isValidNumber(parsedNum)) {
|
|
393
|
-
this.
|
|
403
|
+
newValue = this.foundation.doFormat(parsedNum);
|
|
404
|
+
this.foundation.updateStates({
|
|
394
405
|
number: parsedNum,
|
|
395
|
-
value:
|
|
406
|
+
value: newValue
|
|
396
407
|
});
|
|
397
408
|
} else {
|
|
398
409
|
// Invalid digital analog blurring effect instead of controlled failure
|
|
399
|
-
|
|
410
|
+
newValue = '';
|
|
411
|
+
this.foundation.updateStates({
|
|
400
412
|
number: null,
|
|
401
|
-
value:
|
|
413
|
+
value: newValue
|
|
402
414
|
});
|
|
403
415
|
}
|
|
404
416
|
}
|
|
417
|
+
|
|
418
|
+
if ((0, _isString2.default)(newValue) && newValue !== String(this.props.value)) {
|
|
419
|
+
this.foundation.notifyChange(newValue, null);
|
|
420
|
+
}
|
|
405
421
|
}
|
|
406
422
|
|
|
407
423
|
if (!this.clickUpOrDown) {
|
package/lib/cjs/radio/radio.d.ts
CHANGED
|
@@ -29,13 +29,9 @@ export declare type RadioProps = {
|
|
|
29
29
|
addonClassName?: string;
|
|
30
30
|
type?: RadioType;
|
|
31
31
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
32
|
-
addonId?: string;
|
|
33
|
-
extraId?: string;
|
|
34
32
|
};
|
|
35
33
|
export interface RadioState {
|
|
36
34
|
hover?: boolean;
|
|
37
|
-
addonId?: string;
|
|
38
|
-
extraId?: string;
|
|
39
35
|
}
|
|
40
36
|
export { RadioChangeEvent };
|
|
41
37
|
declare class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
@@ -75,7 +71,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
75
71
|
prefixCls?: string;
|
|
76
72
|
name?: string;
|
|
77
73
|
onChange?: (e: RadioChangeEvent) => void;
|
|
78
|
-
buttonSize?: "small" | "
|
|
74
|
+
buttonSize?: "small" | "middle" | "large";
|
|
79
75
|
isCardRadio?: boolean;
|
|
80
76
|
isPureCardRadio?: boolean;
|
|
81
77
|
};
|
package/lib/cjs/radio/radio.js
CHANGED
|
@@ -67,12 +67,16 @@ class Radio extends _baseComponent.default {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
this.state = {
|
|
70
|
-
hover: false
|
|
71
|
-
addonId: props.addonId,
|
|
72
|
-
extraId: props.extraId
|
|
70
|
+
hover: false
|
|
73
71
|
};
|
|
74
72
|
this.foundation = new _radioFoundation.default(this.adapter);
|
|
75
73
|
this.radioEntity = null;
|
|
74
|
+
this.addonId = (0, _uuid.getUuidShort)({
|
|
75
|
+
prefix: 'addon'
|
|
76
|
+
});
|
|
77
|
+
this.extraId = (0, _uuid.getUuidShort)({
|
|
78
|
+
prefix: 'extra'
|
|
79
|
+
});
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
get adapter() {
|
|
@@ -81,20 +85,6 @@ class Radio extends _baseComponent.default {
|
|
|
81
85
|
this.setState({
|
|
82
86
|
hover
|
|
83
87
|
});
|
|
84
|
-
},
|
|
85
|
-
setAddonId: () => {
|
|
86
|
-
this.setState({
|
|
87
|
-
addonId: (0, _uuid.getUuidShort)({
|
|
88
|
-
prefix: 'addon'
|
|
89
|
-
})
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
setExtraId: () => {
|
|
93
|
-
this.setState({
|
|
94
|
-
extraId: (0, _uuid.getUuidShort)({
|
|
95
|
-
prefix: 'extra'
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
88
|
}
|
|
99
89
|
});
|
|
100
90
|
}
|
|
@@ -131,11 +121,7 @@ class Radio extends _baseComponent.default {
|
|
|
131
121
|
value: propValue
|
|
132
122
|
} = this.props;
|
|
133
123
|
let realChecked, isDisabled, realMode, isButtonRadioGroup, isCardRadioGroup, isPureCardRadioGroup, isButtonRadioComponent, buttonSize, realPrefixCls;
|
|
134
|
-
const
|
|
135
|
-
hover: isHover,
|
|
136
|
-
addonId,
|
|
137
|
-
extraId
|
|
138
|
-
} = this.state;
|
|
124
|
+
const isHover = this.state.hover;
|
|
139
125
|
let props = {};
|
|
140
126
|
|
|
141
127
|
if (this.isInGroup()) {
|
|
@@ -188,10 +174,10 @@ class Radio extends _baseComponent.default {
|
|
|
188
174
|
const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
|
|
189
175
|
className: addonCls,
|
|
190
176
|
style: addonStyle,
|
|
191
|
-
id: addonId
|
|
177
|
+
id: this.addonId
|
|
192
178
|
}, children) : null, extra && !isButtonRadio ? /*#__PURE__*/_react.default.createElement("div", {
|
|
193
179
|
className: "".concat(prefix, "-extra"),
|
|
194
|
-
id: extraId
|
|
180
|
+
id: this.extraId
|
|
195
181
|
}, extra) : null);
|
|
196
182
|
|
|
197
183
|
return /*#__PURE__*/_react.default.createElement("label", {
|
|
@@ -208,8 +194,8 @@ class Radio extends _baseComponent.default {
|
|
|
208
194
|
ref: ref => {
|
|
209
195
|
this.radioEntity = ref;
|
|
210
196
|
},
|
|
211
|
-
addonId: children && addonId,
|
|
212
|
-
extraId: extra && extraId
|
|
197
|
+
addonId: children && this.addonId,
|
|
198
|
+
extraId: extra && this.extraId
|
|
213
199
|
})), isCardRadioGroup ? /*#__PURE__*/_react.default.createElement("div", {
|
|
214
200
|
className: "".concat(prefix, "-isCardRadioGroup_content")
|
|
215
201
|
}, renderContent()) : renderContent());
|
|
@@ -48,7 +48,7 @@ declare class RadioGroup extends BaseComponent<RadioGroupProps, RadioGroupState>
|
|
|
48
48
|
disabled: PropTypes.Requireable<boolean>;
|
|
49
49
|
name: PropTypes.Requireable<string>;
|
|
50
50
|
options: PropTypes.Requireable<any[]>;
|
|
51
|
-
buttonSize: PropTypes.Requireable<"small" | "
|
|
51
|
+
buttonSize: PropTypes.Requireable<"small" | "middle" | "large">;
|
|
52
52
|
type: PropTypes.Requireable<"default" | "button" | "card" | "pureCard">;
|
|
53
53
|
value: PropTypes.Requireable<any>;
|
|
54
54
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -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
|
|
|
@@ -26,6 +26,7 @@ export interface SwitchProps {
|
|
|
26
26
|
export interface SwitchState {
|
|
27
27
|
nativeControlChecked: boolean;
|
|
28
28
|
nativeControlDisabled: boolean;
|
|
29
|
+
focusVisible: boolean;
|
|
29
30
|
}
|
|
30
31
|
declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
31
32
|
static propTypes: {
|
|
@@ -55,6 +56,8 @@ declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
55
56
|
componentDidUpdate(prevProps: SwitchProps): void;
|
|
56
57
|
componentWillUnmount(): void;
|
|
57
58
|
get adapter(): SwitchAdapter<SwitchProps, SwitchState>;
|
|
59
|
+
handleFocusVisible: (event: React.FocusEvent) => void;
|
|
60
|
+
handleBlur: (event: React.FocusEvent) => void;
|
|
58
61
|
render(): JSX.Element;
|
|
59
62
|
}
|
|
60
63
|
export default Switch;
|