@douyinfe/semi-ui 2.14.0-alpha.0 → 2.14.0-beta.2
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/autoComplete/_story/CustomTrigger/index.jsx +1 -1
- package/avatar/_story/avatar.stories.js +62 -5
- package/avatar/avatarGroup.tsx +16 -4
- package/avatar/index.tsx +88 -17
- package/backtop/index.tsx +11 -7
- package/badge/index.tsx +1 -1
- package/banner/index.tsx +5 -5
- package/breadcrumb/index.tsx +5 -3
- package/button/Button.tsx +10 -8
- package/calendar/_story/calendar.stories.js +125 -1
- package/card/index.tsx +43 -41
- package/carousel/CarouselArrow.tsx +2 -0
- package/carousel/index.tsx +1 -0
- package/cascader/_story/cascader.stories.js +21 -0
- package/cascader/index.tsx +103 -122
- package/cascader/item.tsx +1 -1
- package/checkbox/checkbox.tsx +13 -2
- package/collapsible/index.tsx +8 -1
- package/datePicker/dateInput.tsx +1 -0
- package/datePicker/datePicker.tsx +13 -5
- package/dist/css/semi.css +73 -35
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +957 -545
- 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/divider/index.tsx +8 -4
- package/dropdown/index.tsx +1 -1
- package/empty/index.tsx +13 -5
- package/form/_story/form.stories.tsx +9 -2
- package/form/field.tsx +1 -1
- package/form/hoc/withField.tsx +1 -1
- package/form/label.tsx +1 -1
- package/grid/col.tsx +1 -1
- package/grid/row.tsx +1 -1
- package/gulpfile.js +5 -5
- package/iconButton/index.tsx +2 -1
- package/input/_story/input.stories.js +32 -3
- package/input/index.tsx +45 -23
- package/input/inputGroup.tsx +3 -1
- package/input/textarea.tsx +2 -14
- package/lib/cjs/_base/base.css +36 -14
- package/lib/cjs/avatar/avatarGroup.d.ts +1 -1
- package/lib/cjs/avatar/avatarGroup.js +36 -9
- package/lib/cjs/avatar/index.d.ts +5 -0
- package/lib/cjs/avatar/index.js +121 -41
- package/lib/cjs/backtop/index.js +2 -1
- package/lib/cjs/badge/index.js +2 -1
- package/lib/cjs/banner/index.js +9 -4
- package/lib/cjs/breadcrumb/index.js +4 -3
- package/lib/cjs/button/Button.js +13 -3
- package/lib/cjs/card/index.js +10 -5
- package/lib/cjs/carousel/CarouselArrow.js +6 -2
- package/lib/cjs/carousel/index.js +2 -1
- package/lib/cjs/cascader/index.js +15 -8
- package/lib/cjs/cascader/item.js +2 -1
- package/lib/cjs/checkbox/checkbox.js +6 -2
- package/lib/cjs/collapsible/index.js +2 -1
- package/lib/cjs/datePicker/dateInput.js +2 -1
- package/lib/cjs/datePicker/datePicker.js +4 -2
- package/lib/cjs/divider/index.js +2 -1
- package/lib/cjs/dropdown/index.js +2 -1
- package/lib/cjs/empty/index.js +8 -4
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/field.js +2 -2
- package/lib/cjs/form/hoc/withField.js +2 -1
- package/lib/cjs/form/label.js +2 -1
- package/lib/cjs/grid/col.js +2 -1
- package/lib/cjs/grid/row.js +2 -1
- package/lib/cjs/iconButton/index.js +3 -1
- package/lib/cjs/input/index.d.ts +0 -1
- package/lib/cjs/input/index.js +41 -36
- package/lib/cjs/input/inputGroup.js +2 -3
- package/lib/cjs/input/textarea.js +8 -15
- package/lib/cjs/list/index.js +6 -3
- package/lib/cjs/modal/ConfirmModal.js +2 -1
- package/lib/cjs/modal/Modal.js +6 -2
- package/lib/cjs/modal/ModalContent.js +13 -6
- package/lib/cjs/notification/notice.js +6 -3
- package/lib/cjs/pagination/index.js +4 -2
- package/lib/cjs/popconfirm/index.js +6 -3
- package/lib/cjs/radio/radio.d.ts +4 -0
- package/lib/cjs/radio/radio.js +32 -9
- package/lib/cjs/radio/radioInner.d.ts +6 -0
- package/lib/cjs/radio/radioInner.js +13 -4
- package/lib/cjs/rating/item.js +2 -1
- package/lib/cjs/scrollList/index.js +6 -3
- package/lib/cjs/select/index.js +10 -4
- package/lib/cjs/select/option.js +2 -1
- package/lib/cjs/sideSheet/SideSheetContent.js +6 -3
- package/lib/cjs/skeleton/index.js +3 -1
- package/lib/cjs/space/index.js +2 -1
- package/lib/cjs/spin/index.js +7 -3
- package/lib/cjs/switch/index.js +6 -4
- package/lib/cjs/table/ColumnFilter.js +2 -2
- package/lib/cjs/table/ColumnSelection.js +2 -2
- package/lib/cjs/table/Table.js +6 -3
- package/lib/cjs/tabs/TabBar.js +2 -1
- package/lib/cjs/tabs/TabPane.js +5 -2
- package/lib/cjs/tagInput/index.js +33 -22
- package/lib/cjs/timePicker/Combobox.js +3 -1
- package/lib/cjs/timePicker/TimePicker.js +2 -0
- package/lib/cjs/toast/toast.js +6 -3
- package/lib/cjs/tooltip/index.js +6 -1
- package/lib/cjs/transfer/index.js +6 -5
- package/lib/cjs/tree/treeNode.js +4 -3
- package/lib/cjs/treeSelect/index.js +10 -3
- package/lib/cjs/typography/base.js +2 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/cjs/upload/index.js +13 -6
- package/lib/es/_base/base.css +36 -14
- package/lib/es/avatar/avatarGroup.d.ts +1 -1
- package/lib/es/avatar/avatarGroup.js +37 -9
- package/lib/es/avatar/index.d.ts +5 -0
- package/lib/es/avatar/index.js +119 -38
- package/lib/es/backtop/index.js +2 -1
- package/lib/es/badge/index.js +2 -1
- package/lib/es/banner/index.js +9 -4
- package/lib/es/breadcrumb/index.js +4 -3
- package/lib/es/button/Button.js +11 -3
- package/lib/es/card/index.js +10 -5
- package/lib/es/carousel/CarouselArrow.js +6 -2
- package/lib/es/carousel/index.js +2 -1
- package/lib/es/cascader/index.js +15 -8
- package/lib/es/cascader/item.js +2 -1
- package/lib/es/checkbox/checkbox.js +6 -2
- package/lib/es/collapsible/index.js +2 -1
- package/lib/es/datePicker/dateInput.js +2 -1
- package/lib/es/datePicker/datePicker.js +4 -2
- package/lib/es/divider/index.js +2 -1
- package/lib/es/dropdown/index.js +2 -1
- package/lib/es/empty/index.js +8 -4
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/field.js +1 -1
- package/lib/es/form/hoc/withField.js +2 -1
- package/lib/es/form/label.js +2 -1
- package/lib/es/grid/col.js +2 -1
- package/lib/es/grid/row.js +2 -1
- package/lib/es/iconButton/index.js +3 -1
- package/lib/es/input/index.d.ts +0 -1
- package/lib/es/input/index.js +41 -36
- package/lib/es/input/inputGroup.js +2 -3
- package/lib/es/input/textarea.js +8 -15
- package/lib/es/list/index.js +6 -3
- package/lib/es/modal/ConfirmModal.js +2 -1
- package/lib/es/modal/Modal.js +6 -2
- package/lib/es/modal/ModalContent.js +13 -6
- package/lib/es/notification/notice.js +6 -3
- package/lib/es/pagination/index.js +4 -2
- package/lib/es/popconfirm/index.js +6 -3
- package/lib/es/radio/radio.d.ts +4 -0
- package/lib/es/radio/radio.js +32 -9
- package/lib/es/radio/radioInner.d.ts +6 -0
- package/lib/es/radio/radioInner.js +13 -4
- package/lib/es/rating/item.js +2 -1
- package/lib/es/scrollList/index.js +6 -3
- package/lib/es/select/index.js +10 -4
- package/lib/es/select/option.js +2 -1
- package/lib/es/sideSheet/SideSheetContent.js +6 -3
- package/lib/es/skeleton/index.js +3 -1
- package/lib/es/space/index.js +2 -1
- package/lib/es/spin/index.js +7 -3
- package/lib/es/switch/index.js +6 -4
- package/lib/es/table/ColumnFilter.js +1 -1
- package/lib/es/table/ColumnSelection.js +1 -1
- package/lib/es/table/Table.js +6 -3
- package/lib/es/tabs/TabBar.js +2 -1
- package/lib/es/tabs/TabPane.js +5 -2
- package/lib/es/tagInput/index.js +31 -22
- package/lib/es/timePicker/Combobox.js +3 -1
- package/lib/es/timePicker/TimePicker.js +2 -0
- package/lib/es/toast/toast.js +6 -3
- package/lib/es/tooltip/index.js +6 -1
- package/lib/es/transfer/index.js +3 -2
- package/lib/es/tree/treeNode.js +3 -2
- package/lib/es/treeSelect/index.js +10 -3
- package/lib/es/typography/base.js +2 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +1 -1
- package/lib/es/upload/index.js +13 -6
- package/list/index.tsx +16 -4
- package/modal/ConfirmModal.tsx +1 -1
- package/modal/Modal.tsx +2 -0
- package/modal/ModalContent.tsx +27 -14
- package/notification/notice.tsx +16 -4
- package/package.json +8 -8
- package/pagination/index.tsx +16 -2
- package/popconfirm/index.tsx +11 -3
- package/radio/_story/radio.stories.js +9 -6
- package/radio/radio.tsx +37 -7
- package/radio/radioInner.tsx +11 -2
- package/rating/item.tsx +1 -1
- package/scrollList/index.tsx +19 -3
- package/select/index.tsx +13 -4
- package/select/option.tsx +5 -1
- package/sideSheet/SideSheetContent.tsx +3 -3
- package/skeleton/index.tsx +1 -1
- package/space/index.tsx +1 -1
- package/spin/index.tsx +15 -9
- package/switch/index.tsx +9 -14
- package/table/ColumnFilter.tsx +1 -1
- package/table/ColumnSelection.tsx +1 -1
- package/table/Table.tsx +5 -3
- package/table/_story/v2/FixedOnHeaderRow/index.jsx +3 -0
- package/tabs/TabBar.tsx +1 -1
- package/tabs/TabPane.tsx +9 -4
- package/tabs/_story/tabs.stories.js +36 -0
- package/tag/_story/tag.stories.js +1 -1
- package/tagInput/index.tsx +32 -15
- package/timePicker/Combobox.tsx +6 -1
- package/timePicker/TimePicker.tsx +1 -0
- package/toast/toast.tsx +3 -3
- package/tooltip/index.tsx +4 -1
- package/transfer/index.tsx +2 -1
- package/tree/treeNode.tsx +2 -2
- package/treeSelect/_story/treeSelect.stories.js +161 -2
- package/treeSelect/index.tsx +17 -3
- package/typography/base.tsx +1 -1
- package/upload/_story/upload.stories.js +152 -0
- package/upload/index.tsx +107 -38
package/card/index.tsx
CHANGED
|
@@ -55,7 +55,6 @@ export interface CardProps {
|
|
|
55
55
|
'aria-label'?: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
class Card extends PureComponent<CardProps> {
|
|
60
59
|
static Meta = Meta;
|
|
61
60
|
|
|
@@ -106,37 +105,33 @@ class Card extends PureComponent<CardProps> {
|
|
|
106
105
|
if (header || headerExtraContent || title) {
|
|
107
106
|
return (
|
|
108
107
|
<div style={headerStyle} className={headerCls}>
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
</div>
|
|
138
|
-
)
|
|
139
|
-
}
|
|
108
|
+
{header || ( // Priority of header over title and headerExtraContent
|
|
109
|
+
<div className={headerWrapperCls}>
|
|
110
|
+
{headerExtraContent && (
|
|
111
|
+
<div
|
|
112
|
+
className={`${prefixcls}-header-wrapper-extra`}
|
|
113
|
+
x-semi-prop="headerExtraContent"
|
|
114
|
+
>
|
|
115
|
+
{headerExtraContent}
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
{title && (
|
|
119
|
+
<div className={titleCls}>
|
|
120
|
+
{isString(title) ? (
|
|
121
|
+
<Typography.Title
|
|
122
|
+
heading={6}
|
|
123
|
+
ellipsis={{ showTooltip: true, rows: 1 }}
|
|
124
|
+
x-semi-prop="title"
|
|
125
|
+
>
|
|
126
|
+
{title}
|
|
127
|
+
</Typography.Title>
|
|
128
|
+
) : (
|
|
129
|
+
title
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
140
135
|
</div>
|
|
141
136
|
);
|
|
142
137
|
}
|
|
@@ -149,16 +144,17 @@ class Card extends PureComponent<CardProps> {
|
|
|
149
144
|
} = this.props;
|
|
150
145
|
const coverCls = cls(`${prefixcls}-cover`);
|
|
151
146
|
|
|
152
|
-
return
|
|
147
|
+
return (
|
|
148
|
+
cover && (
|
|
149
|
+
<div className={coverCls} x-semi-prop="cover">
|
|
150
|
+
{cover}
|
|
151
|
+
</div>
|
|
152
|
+
)
|
|
153
|
+
);
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
renderBody = (): ReactNode => {
|
|
156
|
-
const {
|
|
157
|
-
bodyStyle,
|
|
158
|
-
children,
|
|
159
|
-
actions,
|
|
160
|
-
loading
|
|
161
|
-
} = this.props;
|
|
157
|
+
const { bodyStyle, children, actions, loading } = this.props;
|
|
162
158
|
const bodyCls = cls(`${prefixcls}-body`);
|
|
163
159
|
const actionsCls = cls(`${prefixcls}-body-actions`);
|
|
164
160
|
const actionsItemCls = cls(`${prefixcls}-body-actions-item`);
|
|
@@ -182,7 +178,7 @@ class Card extends PureComponent<CardProps> {
|
|
|
182
178
|
<div className={actionsCls}>
|
|
183
179
|
<Space spacing={12}>
|
|
184
180
|
{actions.map((item, idx) => (
|
|
185
|
-
<div key={idx} className={actionsItemCls}>{item}</div>
|
|
181
|
+
<div key={idx} className={actionsItemCls} x-semi-prop={`actions.${idx}`}>{item}</div>
|
|
186
182
|
))}
|
|
187
183
|
</Space>
|
|
188
184
|
</div>
|
|
@@ -202,7 +198,13 @@ class Card extends PureComponent<CardProps> {
|
|
|
202
198
|
[`${prefixcls}-footer-bordered`]: footerLine
|
|
203
199
|
});
|
|
204
200
|
|
|
205
|
-
return
|
|
201
|
+
return (
|
|
202
|
+
footer && (
|
|
203
|
+
<div style={footerStyle} className={footerCls} x-semi-prop="footer">
|
|
204
|
+
{footer}
|
|
205
|
+
</div>
|
|
206
|
+
)
|
|
207
|
+
);
|
|
206
208
|
};
|
|
207
209
|
|
|
208
210
|
render(): ReactNode {
|
|
@@ -41,6 +41,7 @@ class CarouselArrow extends React.PureComponent<CarouselArrowProps> {
|
|
|
41
41
|
className={leftClassNames}
|
|
42
42
|
onClick={prev}
|
|
43
43
|
{...get(this.props, 'arrowProps.leftArrow.props')}
|
|
44
|
+
x-semi-prop="arrowProps.leftArrow.children"
|
|
44
45
|
>
|
|
45
46
|
{this.renderLeftIcon()}
|
|
46
47
|
</div>
|
|
@@ -50,6 +51,7 @@ class CarouselArrow extends React.PureComponent<CarouselArrowProps> {
|
|
|
50
51
|
className={rightClassNames}
|
|
51
52
|
onClick={next}
|
|
52
53
|
{...get(this.props, 'arrowProps.rightArrow.props')}
|
|
54
|
+
x-semi-prop="arrowProps.rightArrow.children"
|
|
53
55
|
>
|
|
54
56
|
{this.renderRightIcon()}
|
|
55
57
|
</div>
|
package/carousel/index.tsx
CHANGED
|
@@ -279,6 +279,7 @@ class Carousel extends BaseComponent<CarouselProps, CarouselState> {
|
|
|
279
279
|
[`${cssClasses.CAROUSEL_CONTENT}`]: true,
|
|
280
280
|
[`${cssClasses.CAROUSEL_CONTENT}-reverse`]: slideDirection === 'left' ? isReverse : !isReverse,
|
|
281
281
|
})}
|
|
282
|
+
x-semi-prop="children"
|
|
282
283
|
>
|
|
283
284
|
{this.renderChildren()}
|
|
284
285
|
</div>
|
|
@@ -1276,6 +1276,27 @@ export const OnChangeWithObject = () => (
|
|
|
1276
1276
|
</>
|
|
1277
1277
|
);
|
|
1278
1278
|
|
|
1279
|
+
export const undefinedValueWhileMutipleAndOnChangeWithObject = () => {
|
|
1280
|
+
const [value, setValue] = useState(undefined);
|
|
1281
|
+
|
|
1282
|
+
return (
|
|
1283
|
+
<>
|
|
1284
|
+
<div>多选 + onChangeWithObject + value 为 undefined</div>
|
|
1285
|
+
<Cascader
|
|
1286
|
+
multiple
|
|
1287
|
+
onChangeWithObject
|
|
1288
|
+
style={{ width: 300 }}
|
|
1289
|
+
treeData={treeData2}
|
|
1290
|
+
placeholder="请选择所在地区"
|
|
1291
|
+
value={value}
|
|
1292
|
+
onChange={(v)=>{
|
|
1293
|
+
setValue(v);
|
|
1294
|
+
}}
|
|
1295
|
+
/>
|
|
1296
|
+
</>
|
|
1297
|
+
)
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1279
1300
|
export const LeafOnly = () => {
|
|
1280
1301
|
const [value, setValue] = useState([])
|
|
1281
1302
|
return (
|
package/cascader/index.tsx
CHANGED
|
@@ -122,7 +122,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
122
122
|
PropTypes.shape({
|
|
123
123
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
124
124
|
label: PropTypes.any,
|
|
125
|
-
})
|
|
125
|
+
})
|
|
126
126
|
),
|
|
127
127
|
treeNodeFilterProp: PropTypes.string,
|
|
128
128
|
suffix: PropTypes.node,
|
|
@@ -199,7 +199,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
199
199
|
onDropdownVisibleChange: noop,
|
|
200
200
|
onListScroll: noop,
|
|
201
201
|
enableLeafClick: false,
|
|
202
|
-
'aria-label': 'Cascader'
|
|
202
|
+
'aria-label': 'Cascader',
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
options: any;
|
|
@@ -247,7 +247,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
247
247
|
/* Keys of loading item */
|
|
248
248
|
loadingKeys: new Set(),
|
|
249
249
|
/* Mark whether this rendering has triggered asynchronous loading of data */
|
|
250
|
-
loading: false
|
|
250
|
+
loading: false,
|
|
251
251
|
};
|
|
252
252
|
this.options = {};
|
|
253
253
|
this.isEmpty = false;
|
|
@@ -274,10 +274,9 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
274
274
|
}
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
|
-
const cascaderAdapter: Pick<
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
| 'rePositionDropdown'
|
|
277
|
+
const cascaderAdapter: Pick<
|
|
278
|
+
CascaderAdapter,
|
|
279
|
+
'registerClickOutsideHandler' | 'unregisterClickOutsideHandler' | 'rePositionDropdown'
|
|
281
280
|
> = {
|
|
282
281
|
registerClickOutsideHandler: cb => {
|
|
283
282
|
const clickOutsideHandler = (e: Event) => {
|
|
@@ -368,17 +367,10 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
368
367
|
}
|
|
369
368
|
|
|
370
369
|
static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState) {
|
|
371
|
-
const {
|
|
372
|
-
multiple,
|
|
373
|
-
value,
|
|
374
|
-
defaultValue,
|
|
375
|
-
onChangeWithObject,
|
|
376
|
-
leafOnly,
|
|
377
|
-
autoMergeValue,
|
|
378
|
-
} = props;
|
|
370
|
+
const { multiple, value, defaultValue, onChangeWithObject, leafOnly, autoMergeValue } = props;
|
|
379
371
|
const { prevProps } = prevState;
|
|
380
372
|
let keyEntities = prevState.keyEntities || {};
|
|
381
|
-
const newState: Partial<CascaderState> = {
|
|
373
|
+
const newState: Partial<CascaderState> = {};
|
|
382
374
|
const needUpdate = (name: string) => {
|
|
383
375
|
const firstInProps = isEmpty(prevProps) && name in props;
|
|
384
376
|
const nameHasChange = prevProps && !isEqual(prevProps[name], props[name]);
|
|
@@ -408,17 +400,19 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
408
400
|
const realValue = needUpdate('value') ? value : defaultValue;
|
|
409
401
|
// eslint-disable-next-line max-depth
|
|
410
402
|
if (Array.isArray(realValue)) {
|
|
411
|
-
normallizedValue = Array.isArray(realValue[0])
|
|
412
|
-
realValue as SimpleValueType[][]
|
|
413
|
-
[realValue] as SimpleValueType[][];
|
|
403
|
+
normallizedValue = Array.isArray(realValue[0])
|
|
404
|
+
? (realValue as SimpleValueType[][])
|
|
405
|
+
: ([realValue] as SimpleValueType[][]);
|
|
414
406
|
} else {
|
|
415
|
-
|
|
407
|
+
if (realValue !== undefined) {
|
|
408
|
+
normallizedValue = [[realValue]];
|
|
409
|
+
}
|
|
416
410
|
}
|
|
417
411
|
// formatValuePath is used to save value of valuePath
|
|
418
412
|
const formatValuePath: (string | number)[][] = [];
|
|
419
413
|
normallizedValue.forEach((valueItem: SimpleValueType[]) => {
|
|
420
414
|
const formatItem: (string | number)[] = onChangeWithObject ?
|
|
421
|
-
(valueItem as CascaderData[]).map(i => i
|
|
415
|
+
(valueItem as CascaderData[]).map(i => i?.value) :
|
|
422
416
|
valueItem as (string | number)[];
|
|
423
417
|
formatValuePath.push(formatItem);
|
|
424
418
|
});
|
|
@@ -480,12 +474,9 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
480
474
|
renderTagItem = (value: string | Array<string>, idx: number, type: string) => {
|
|
481
475
|
const { keyEntities, disabledKeys } = this.state;
|
|
482
476
|
const { size, disabled, displayProp, displayRender, disableStrictly } = this.props;
|
|
483
|
-
const nodeKey = type === strings.IS_VALUE ?
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const isDsiabled = disabled ||
|
|
487
|
-
keyEntities[nodeKey].data.disabled ||
|
|
488
|
-
(disableStrictly && disabledKeys.has(nodeKey));
|
|
477
|
+
const nodeKey = type === strings.IS_VALUE ? findKeysForValues(value, keyEntities)[0] : value;
|
|
478
|
+
const isDsiabled =
|
|
479
|
+
disabled || keyEntities[nodeKey].data.disabled || (disableStrictly && disabledKeys.has(nodeKey));
|
|
489
480
|
if (!isEmpty(keyEntities) && !isEmpty(keyEntities[nodeKey])) {
|
|
490
481
|
const tagCls = cls(`${prefixcls}-selection-tag`, {
|
|
491
482
|
[`${prefixcls}-selection-tag-disabled`]: isDsiabled,
|
|
@@ -493,7 +484,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
493
484
|
// custom render tags
|
|
494
485
|
if (isFunction(displayRender)) {
|
|
495
486
|
return displayRender(keyEntities[nodeKey], idx);
|
|
496
|
-
|
|
487
|
+
// default render tags
|
|
497
488
|
} else {
|
|
498
489
|
return (
|
|
499
490
|
<Tag
|
|
@@ -517,25 +508,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
517
508
|
};
|
|
518
509
|
|
|
519
510
|
renderTagInput() {
|
|
520
|
-
const {
|
|
521
|
-
|
|
522
|
-
disabled,
|
|
523
|
-
placeholder,
|
|
524
|
-
maxTagCount,
|
|
525
|
-
showRestTagsPopover,
|
|
526
|
-
restTagsPopoverProps,
|
|
527
|
-
} = this.props;
|
|
528
|
-
const {
|
|
529
|
-
inputValue,
|
|
530
|
-
checkedKeys,
|
|
531
|
-
keyEntities,
|
|
532
|
-
resolvedCheckedKeys
|
|
533
|
-
} = this.state;
|
|
511
|
+
const { size, disabled, placeholder, maxTagCount, showRestTagsPopover, restTagsPopoverProps } = this.props;
|
|
512
|
+
const { inputValue, checkedKeys, keyEntities, resolvedCheckedKeys } = this.state;
|
|
534
513
|
const tagInputcls = cls(`${prefixcls}-tagInput-wrapper`);
|
|
535
514
|
const tagValue: Array<Array<string>> = [];
|
|
536
|
-
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
537
|
-
? checkedKeys
|
|
538
|
-
: resolvedCheckedKeys;
|
|
515
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
539
516
|
[...realKeys].forEach(checkedKey => {
|
|
540
517
|
if (!isEmpty(keyEntities[checkedKey])) {
|
|
541
518
|
tagValue.push(keyEntities[checkedKey].valuePath);
|
|
@@ -548,7 +525,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
548
525
|
disabled={disabled}
|
|
549
526
|
size={size}
|
|
550
527
|
// TODO Modify logic, not modify type
|
|
551
|
-
value={tagValue as unknown as string[]}
|
|
528
|
+
value={(tagValue as unknown) as string[]}
|
|
552
529
|
showRestTagsPopover={showRestTagsPopover}
|
|
553
530
|
restTagsPopoverProps={restTagsPopoverProps}
|
|
554
531
|
maxTagCount={maxTagCount}
|
|
@@ -556,7 +533,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
556
533
|
inputValue={inputValue}
|
|
557
534
|
onInputChange={this.handleInputChange}
|
|
558
535
|
// TODO Modify logic, not modify type
|
|
559
|
-
onRemove={v => this.handleTagRemove(null, v as unknown as (string | number)[])}
|
|
536
|
+
onRemove={v => this.handleTagRemove(null, (v as unknown) as (string | number)[])}
|
|
560
537
|
placeholder={placeholder}
|
|
561
538
|
/>
|
|
562
539
|
);
|
|
@@ -578,11 +555,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
578
555
|
});
|
|
579
556
|
return (
|
|
580
557
|
<div className={wrappercls}>
|
|
581
|
-
<Input
|
|
582
|
-
ref={this.inputRef as any}
|
|
583
|
-
size={size}
|
|
584
|
-
{...inputProps}
|
|
585
|
-
/>
|
|
558
|
+
<Input ref={this.inputRef as any} size={size} {...inputProps} />
|
|
586
559
|
</div>
|
|
587
560
|
);
|
|
588
561
|
}
|
|
@@ -612,7 +585,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
612
585
|
checkedKeys,
|
|
613
586
|
halfCheckedKeys,
|
|
614
587
|
loadedKeys,
|
|
615
|
-
loadingKeys
|
|
588
|
+
loadingKeys,
|
|
616
589
|
} = this.state;
|
|
617
590
|
const {
|
|
618
591
|
filterTreeNode,
|
|
@@ -624,7 +597,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
624
597
|
topSlot,
|
|
625
598
|
bottomSlot,
|
|
626
599
|
showNext,
|
|
627
|
-
multiple
|
|
600
|
+
multiple,
|
|
628
601
|
} = this.props;
|
|
629
602
|
const searchable = Boolean(filterTreeNode) && isSearching;
|
|
630
603
|
const popoverCls = cls(dropdownClassName, `${prefixcls}-popover`);
|
|
@@ -661,37 +634,29 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
661
634
|
renderPlusN = (hiddenTag: Array<ReactNode>) => {
|
|
662
635
|
const { disabled, showRestTagsPopover, restTagsPopoverProps } = this.props;
|
|
663
636
|
const plusNCls = cls(`${prefixcls}-selection-n`, {
|
|
664
|
-
[`${prefixcls}-selection-n-disabled`]: disabled
|
|
637
|
+
[`${prefixcls}-selection-n-disabled`]: disabled,
|
|
665
638
|
});
|
|
666
|
-
const renderPlusNChildren =
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
{...restTagsPopoverProps}
|
|
681
|
-
>
|
|
682
|
-
{renderPlusNChildren}
|
|
683
|
-
</Popover>
|
|
684
|
-
) :
|
|
685
|
-
renderPlusNChildren
|
|
639
|
+
const renderPlusNChildren = <span className={plusNCls}>+{hiddenTag.length}</span>;
|
|
640
|
+
return showRestTagsPopover && !disabled ? (
|
|
641
|
+
<Popover
|
|
642
|
+
content={hiddenTag}
|
|
643
|
+
showArrow
|
|
644
|
+
trigger="hover"
|
|
645
|
+
position="top"
|
|
646
|
+
autoAdjustOverflow
|
|
647
|
+
{...restTagsPopoverProps}
|
|
648
|
+
>
|
|
649
|
+
{renderPlusNChildren}
|
|
650
|
+
</Popover>
|
|
651
|
+
) : (
|
|
652
|
+
renderPlusNChildren
|
|
686
653
|
);
|
|
687
654
|
};
|
|
688
655
|
|
|
689
656
|
renderMultipleTags = () => {
|
|
690
657
|
const { autoMergeValue, maxTagCount } = this.props;
|
|
691
658
|
const { checkedKeys, resolvedCheckedKeys } = this.state;
|
|
692
|
-
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
693
|
-
? checkedKeys
|
|
694
|
-
: resolvedCheckedKeys;
|
|
659
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
695
660
|
const displayTag: Array<ReactNode> = [];
|
|
696
661
|
const hiddenTag: Array<ReactNode> = [];
|
|
697
662
|
[...realKeys].forEach((checkedKey, idx) => {
|
|
@@ -720,19 +685,22 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
720
685
|
if (displayRender && typeof displayRender === 'function') {
|
|
721
686
|
displayText = displayRender(displayPath);
|
|
722
687
|
} else {
|
|
723
|
-
displayText = displayPath.map((path: ReactNode, index: number)=>(
|
|
688
|
+
displayText = displayPath.map((path: ReactNode, index: number) => (
|
|
724
689
|
<Fragment key={`${path}-${index}`}>
|
|
725
|
-
{
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
690
|
+
{index < displayPath.length - 1 ? (
|
|
691
|
+
<>
|
|
692
|
+
{path}
|
|
693
|
+
{separator}
|
|
694
|
+
</>
|
|
695
|
+
) : (
|
|
696
|
+
path
|
|
697
|
+
)}
|
|
730
698
|
</Fragment>
|
|
731
699
|
));
|
|
732
700
|
}
|
|
733
701
|
}
|
|
734
702
|
return displayText;
|
|
735
|
-
}
|
|
703
|
+
};
|
|
736
704
|
|
|
737
705
|
renderSelectContent = () => {
|
|
738
706
|
const { placeholder, filterTreeNode, multiple } = this.props;
|
|
@@ -763,7 +731,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
763
731
|
[`${prefixcls}-suffix-text`]: suffix && isString(suffix),
|
|
764
732
|
[`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
|
|
765
733
|
});
|
|
766
|
-
return
|
|
734
|
+
return (
|
|
735
|
+
<div className={suffixWrapperCls} x-semi-prop="suffix">
|
|
736
|
+
{suffix}
|
|
737
|
+
</div>
|
|
738
|
+
);
|
|
767
739
|
};
|
|
768
740
|
|
|
769
741
|
renderPrefix = () => {
|
|
@@ -778,7 +750,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
778
750
|
[`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
|
|
779
751
|
});
|
|
780
752
|
|
|
781
|
-
return
|
|
753
|
+
return (
|
|
754
|
+
<div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
|
|
755
|
+
{labelNode}
|
|
756
|
+
</div>
|
|
757
|
+
);
|
|
782
758
|
};
|
|
783
759
|
|
|
784
760
|
renderCustomTrigger = () => {
|
|
@@ -825,6 +801,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
825
801
|
/**
|
|
826
802
|
* A11y: simulate clear button click
|
|
827
803
|
*/
|
|
804
|
+
/* istanbul ignore next */
|
|
828
805
|
handleClearEnterPress = (e: KeyboardEvent) => {
|
|
829
806
|
e && e.stopPropagation();
|
|
830
807
|
this.foundation.handleClearEnterPress(e);
|
|
@@ -847,7 +824,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
847
824
|
className={clearCls}
|
|
848
825
|
onClick={this.handleClear}
|
|
849
826
|
onKeyPress={this.handleClearEnterPress}
|
|
850
|
-
role=
|
|
827
|
+
role="button"
|
|
851
828
|
tabIndex={0}
|
|
852
829
|
>
|
|
853
830
|
<IconClear />
|
|
@@ -863,7 +840,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
863
840
|
if (showClearBtn) {
|
|
864
841
|
return null;
|
|
865
842
|
}
|
|
866
|
-
return arrowIcon ?
|
|
843
|
+
return arrowIcon ? (
|
|
844
|
+
<div className={cls(`${prefixcls}-arrow`)} x-semi-prop="arrowIcon">
|
|
845
|
+
{arrowIcon}
|
|
846
|
+
</div>
|
|
847
|
+
) : null;
|
|
867
848
|
};
|
|
868
849
|
|
|
869
850
|
renderSelection = () => {
|
|
@@ -885,40 +866,40 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
885
866
|
const { isOpen, isFocus, isInput, checkedKeys } = this.state;
|
|
886
867
|
const filterable = Boolean(filterTreeNode);
|
|
887
868
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
888
|
-
const classNames = useCustomTrigger
|
|
889
|
-
cls(className)
|
|
890
|
-
cls(prefixcls, className, {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
const mouseEvent = showClear
|
|
903
|
-
{
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
{};
|
|
869
|
+
const classNames = useCustomTrigger
|
|
870
|
+
? cls(className)
|
|
871
|
+
: cls(prefixcls, className, {
|
|
872
|
+
[`${prefixcls}-focus`]: isFocus || (isOpen && !isInput),
|
|
873
|
+
[`${prefixcls}-disabled`]: disabled,
|
|
874
|
+
[`${prefixcls}-single`]: true,
|
|
875
|
+
[`${prefixcls}-filterable`]: filterable,
|
|
876
|
+
[`${prefixcls}-error`]: validateStatus === 'error',
|
|
877
|
+
[`${prefixcls}-warning`]: validateStatus === 'warning',
|
|
878
|
+
[`${prefixcls}-small`]: size === 'small',
|
|
879
|
+
[`${prefixcls}-large`]: size === 'large',
|
|
880
|
+
[`${prefixcls}-with-prefix`]: prefix || insetLabel,
|
|
881
|
+
[`${prefixcls}-with-suffix`]: suffix,
|
|
882
|
+
});
|
|
883
|
+
const mouseEvent = showClear
|
|
884
|
+
? {
|
|
885
|
+
onMouseEnter: () => this.handleMouseOver(),
|
|
886
|
+
onMouseLeave: () => this.handleMouseLeave(),
|
|
887
|
+
}
|
|
888
|
+
: {};
|
|
908
889
|
const sectionCls = cls(`${prefixcls}-selection`, {
|
|
909
890
|
[`${prefixcls}-selection-multiple`]: multiple && !isEmpty(checkedKeys),
|
|
910
891
|
});
|
|
911
|
-
const inner = useCustomTrigger
|
|
912
|
-
this.renderCustomTrigger()
|
|
913
|
-
[
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
892
|
+
const inner = useCustomTrigger
|
|
893
|
+
? this.renderCustomTrigger()
|
|
894
|
+
: [
|
|
895
|
+
<Fragment key={'prefix'}>{prefix || insetLabel ? this.renderPrefix() : null}</Fragment>,
|
|
896
|
+
<Fragment key={'selection'}>
|
|
897
|
+
<div className={sectionCls}>{this.renderSelectContent()}</div>
|
|
898
|
+
</Fragment>,
|
|
899
|
+
<Fragment key={'clearbtn'}>{this.renderClearBtn()}</Fragment>,
|
|
900
|
+
<Fragment key={'suffix'}>{suffix ? this.renderSuffix() : null}</Fragment>,
|
|
901
|
+
<Fragment key={'arrow'}>{this.renderArrow()}</Fragment>,
|
|
902
|
+
];
|
|
922
903
|
/**
|
|
923
904
|
* Reasons for disabling the a11y eslint rule:
|
|
924
905
|
* The following attributes(aria-controls,aria-expanded) will be automatically added by Tooltip, no need to declare here
|
|
@@ -934,12 +915,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
934
915
|
aria-errormessage={this.props['aria-errormessage']}
|
|
935
916
|
aria-label={this.props['aria-label']}
|
|
936
917
|
aria-labelledby={this.props['aria-labelledby']}
|
|
937
|
-
aria-describedby={this.props[
|
|
918
|
+
aria-describedby={this.props['aria-describedby']}
|
|
938
919
|
aria-required={this.props['aria-required']}
|
|
939
920
|
id={id}
|
|
940
921
|
{...mouseEvent}
|
|
941
922
|
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
942
|
-
role=
|
|
923
|
+
role="combobox"
|
|
943
924
|
tabIndex={0}
|
|
944
925
|
>
|
|
945
926
|
{inner}
|
package/cascader/item.tsx
CHANGED
|
@@ -291,7 +291,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
291
291
|
<LocaleConsumer componentName="Cascader">
|
|
292
292
|
{(locale: Locale['Cascader']) => (
|
|
293
293
|
<ul className={`${prefixcls} ${prefixcls}-empty`} key={'empty-list'}>
|
|
294
|
-
<span className={`${prefixcls}-label`}>
|
|
294
|
+
<span className={`${prefixcls}-label`} x-semi-prop="emptyContent">
|
|
295
295
|
{emptyContent || locale.emptyText}
|
|
296
296
|
</span>
|
|
297
297
|
</ul>
|
package/checkbox/checkbox.tsx
CHANGED
|
@@ -220,10 +220,21 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
220
220
|
[`${prefix}-cardType_extra_noChildren`]: props.isCardType && !children,
|
|
221
221
|
});
|
|
222
222
|
|
|
223
|
+
const name = inGroup && this.context.checkboxGroup.name;
|
|
224
|
+
const xSemiPropChildren = this.props['x-semi-children-alias'] || 'children';
|
|
225
|
+
|
|
223
226
|
const renderContent = () => (
|
|
224
227
|
<>
|
|
225
|
-
{children ?
|
|
226
|
-
|
|
228
|
+
{children ? (
|
|
229
|
+
<span id={addonId} className={`${prefix}-addon`} x-semi-prop={xSemiPropChildren}>
|
|
230
|
+
{children}
|
|
231
|
+
</span>
|
|
232
|
+
) : null}
|
|
233
|
+
{extra ? (
|
|
234
|
+
<div id={extraId} className={extraCls} x-semi-prop="extra">
|
|
235
|
+
{extra}
|
|
236
|
+
</div>
|
|
237
|
+
) : null}
|
|
227
238
|
</>
|
|
228
239
|
);
|
|
229
240
|
return (
|
package/collapsible/index.tsx
CHANGED
|
@@ -92,7 +92,14 @@ const Collapsible = (props: CollapsibleProps) => {
|
|
|
92
92
|
const wrapperCls = cls(`${cssClasses.PREFIX}-wrapper`, className);
|
|
93
93
|
return (
|
|
94
94
|
<div style={wrapperstyle} className={wrapperCls} ref={ref}>
|
|
95
|
-
<div
|
|
95
|
+
<div
|
|
96
|
+
ref={setHeight}
|
|
97
|
+
style={{ overflow: 'hidden' }}
|
|
98
|
+
id={id}
|
|
99
|
+
x-semi-prop="children"
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</div>
|
|
96
103
|
</div>
|
|
97
104
|
);
|
|
98
105
|
};
|
package/datePicker/dateInput.tsx
CHANGED
|
@@ -172,6 +172,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
172
172
|
<div
|
|
173
173
|
className={`${prefixCls}-range-input-prefix`}
|
|
174
174
|
onClick={e => !disabled && !rangeInputFocus && this.handleRangeStartFocus(e)}
|
|
175
|
+
x-semi-prop="prefix,insetLabel"
|
|
175
176
|
>
|
|
176
177
|
{labelNode}
|
|
177
178
|
</div>
|