@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
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
+
import React, { ReactNode, Children, ReactChild, ReactFragment, ReactPortal } from 'react';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import BaseComponent from "../_base/baseComponent";
|
|
6
|
+
import { CarouselProps } from './interface';
|
|
7
|
+
import { cssClasses, numbers, strings } from '@douyinfe/semi-foundation/carousel/constants';
|
|
8
|
+
import CarouselFoundation, { CarouselAdapter } from '@douyinfe/semi-foundation/carousel/foundation';
|
|
9
|
+
import CarouselIndicator from './CarouselIndicator';
|
|
10
|
+
import CarouselArrow from './CarouselArrow';
|
|
11
|
+
import '@douyinfe/semi-foundation/carousel/carousel.scss';
|
|
12
|
+
import { debounce } from 'lodash';
|
|
13
|
+
import isNullOrUndefined from '@douyinfe/semi-foundation/utils/isNullOrUndefined';
|
|
14
|
+
|
|
15
|
+
export interface CarouselState {
|
|
16
|
+
activeIndex: number;
|
|
17
|
+
children: (ReactChild | ReactFragment | ReactPortal)[];
|
|
18
|
+
preIndex: number;
|
|
19
|
+
isReverse: boolean;
|
|
20
|
+
isInit: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class Carousel extends BaseComponent<CarouselProps, CarouselState> {
|
|
24
|
+
static propTypes = {
|
|
25
|
+
activeIndex: PropTypes.number,
|
|
26
|
+
animation:PropTypes.oneOf(strings.ANIMATION_MAP),
|
|
27
|
+
arrowProps: PropTypes.object,
|
|
28
|
+
autoPlay: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
29
|
+
className: PropTypes.string,
|
|
30
|
+
defaultActiveIndex: PropTypes.number,
|
|
31
|
+
indicatorPosition: PropTypes.oneOf(strings.POSITION_MAP),
|
|
32
|
+
indicatorSize: PropTypes.oneOf(strings.SIZE),
|
|
33
|
+
indicatorType: PropTypes.oneOf(strings.TYPE_MAP),
|
|
34
|
+
theme: PropTypes.oneOf(strings.THEME_MAP),
|
|
35
|
+
onChange: PropTypes.func,
|
|
36
|
+
arrowType: PropTypes.oneOf(strings.ARROW_MAP),
|
|
37
|
+
showArrow: PropTypes.bool,
|
|
38
|
+
showIndicator: PropTypes.bool,
|
|
39
|
+
slideDirection: PropTypes.oneOf(strings.DIRECTION),
|
|
40
|
+
speed: PropTypes.number,
|
|
41
|
+
style: PropTypes.object,
|
|
42
|
+
trigger: PropTypes.oneOf(strings.TRIGGER)
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
static defaultProps: CarouselProps = {
|
|
46
|
+
children: [],
|
|
47
|
+
animation: 'slide',
|
|
48
|
+
autoPlay: true,
|
|
49
|
+
arrowType: 'always',
|
|
50
|
+
defaultActiveIndex: numbers.DEFAULT_ACTIVE_INDEX,
|
|
51
|
+
indicatorPosition: 'center',
|
|
52
|
+
indicatorSize: 'small',
|
|
53
|
+
indicatorType: 'dot',
|
|
54
|
+
theme: 'light',
|
|
55
|
+
onChange: () => undefined,
|
|
56
|
+
showArrow: true,
|
|
57
|
+
showIndicator: true,
|
|
58
|
+
slideDirection: 'left',
|
|
59
|
+
speed: numbers.DEFAULT_SPEED,
|
|
60
|
+
trigger: 'click'
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
foundation: CarouselFoundation;
|
|
64
|
+
|
|
65
|
+
constructor(props: CarouselProps) {
|
|
66
|
+
super(props);
|
|
67
|
+
|
|
68
|
+
this.foundation = new CarouselFoundation(this.adapter);
|
|
69
|
+
const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
|
|
70
|
+
|
|
71
|
+
this.state = {
|
|
72
|
+
activeIndex: defaultActiveIndex,
|
|
73
|
+
children: this.getChildren(),
|
|
74
|
+
preIndex: defaultActiveIndex,
|
|
75
|
+
isReverse: false,
|
|
76
|
+
isInit: true
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get adapter(): CarouselAdapter<CarouselProps, CarouselState> {
|
|
81
|
+
return {
|
|
82
|
+
...super.adapter,
|
|
83
|
+
notifyChange: (activeIndex: number, preIndex: number): void => {
|
|
84
|
+
this.props.onChange(activeIndex, preIndex);
|
|
85
|
+
},
|
|
86
|
+
setNewActiveIndex: (activeIndex: number): void => {
|
|
87
|
+
this.setState({ activeIndex });
|
|
88
|
+
},
|
|
89
|
+
setPreActiveIndex: (preIndex: number): void => {
|
|
90
|
+
this.setState({ preIndex });
|
|
91
|
+
},
|
|
92
|
+
setIsReverse: (isReverse: boolean): void => {
|
|
93
|
+
this.setState({ isReverse });
|
|
94
|
+
},
|
|
95
|
+
setIsInit: (isInit: boolean): void => {
|
|
96
|
+
this.setState({ isInit });
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static getDerivedStateFromProps(props: CarouselProps, state: CarouselState): Partial<CarouselState> {
|
|
102
|
+
const states: Partial<CarouselState> = {};
|
|
103
|
+
if (!isNullOrUndefined(props.activeIndex) && props.activeIndex !== state.activeIndex) {
|
|
104
|
+
states.activeIndex = props.activeIndex;
|
|
105
|
+
}
|
|
106
|
+
return states;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
componentDidMount(): void {
|
|
110
|
+
this.handleAutoPlay();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
componentWillUnmount(): void {
|
|
114
|
+
this.foundation.destroy();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
play = (): void => {
|
|
118
|
+
return this.foundation.handleAutoPlay();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
stop = (): void => {
|
|
122
|
+
return this.foundation.stop();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
goTo = ( targetIndex: number): void => {
|
|
126
|
+
return this.foundation.goTo(targetIndex);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
prev = (): void => {
|
|
130
|
+
return this.foundation.prev();
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
next = (): void => {
|
|
134
|
+
return this.foundation.next();
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
handleAutoPlay = (): void => {
|
|
138
|
+
if (!this.foundation.getIsControledComponent()){
|
|
139
|
+
this.foundation.handleAutoPlay();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handleMouseEnter = (): void => {
|
|
144
|
+
const { autoPlay } = this.props;
|
|
145
|
+
if (typeof autoPlay !== 'object' || autoPlay.hoverToPause){
|
|
146
|
+
this.foundation.stop();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
handleMouseLeave = (): void => {
|
|
151
|
+
const { autoPlay } = this.props;
|
|
152
|
+
if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControledComponent()){
|
|
153
|
+
this.foundation.handleAutoPlay();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
onIndicatorChange = (activeIndex: number): void => {
|
|
158
|
+
return this.foundation.onIndicatorChange(activeIndex);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
getChildren = (): (ReactChild | ReactFragment | ReactPortal)[] => {
|
|
162
|
+
const { children: originChildren } = this.props;
|
|
163
|
+
return Children.toArray(originChildren).filter(child=>{
|
|
164
|
+
return React.isValidElement(child);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
getValidIndex = (activeIndex: number): number => {
|
|
169
|
+
return this.foundation.getValidIndex(activeIndex);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
renderChildren = () => {
|
|
174
|
+
const { speed, animation } = this.props;
|
|
175
|
+
const { activeIndex, children, preIndex, isInit } = this.state;
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<>
|
|
179
|
+
{children.map((child: any, index: number) => {
|
|
180
|
+
const isCurrent = index === activeIndex;
|
|
181
|
+
const isPrev = index === this.getValidIndex(activeIndex - 1);
|
|
182
|
+
const isNext = index === this.getValidIndex(activeIndex + 1);
|
|
183
|
+
|
|
184
|
+
const animateStyle = {
|
|
185
|
+
transitionTimingFunction: 'ease',
|
|
186
|
+
transitionDuration: `${speed}ms`,
|
|
187
|
+
animationTimingFunction: 'ease',
|
|
188
|
+
animationDuration: `${speed}ms`,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return React.cloneElement(child, {
|
|
192
|
+
style: {
|
|
193
|
+
...child.props.style,
|
|
194
|
+
...animateStyle,
|
|
195
|
+
},
|
|
196
|
+
className: cls(child.props.className, {
|
|
197
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-prev`]: isPrev,
|
|
198
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-next`]: isNext,
|
|
199
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-current`]: isCurrent,
|
|
200
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item`]: true,
|
|
201
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-active`]: isCurrent,
|
|
202
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-slide-in`]:animation === 'slide' && !isInit && isCurrent,
|
|
203
|
+
[`${cssClasses.CAROUSEL_CONTENT}-item-slide-out`]:animation === 'slide' && !isInit && index === preIndex,
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
})}
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
renderIndicator = () => {
|
|
212
|
+
const { children, activeIndex } = this.state;
|
|
213
|
+
const { showIndicator, indicatorType, theme, indicatorPosition, indicatorSize, trigger } = this.props;
|
|
214
|
+
|
|
215
|
+
const carouselIndicatorCls = cls({
|
|
216
|
+
[cssClasses.CAROUSEL_INDICATOR]: true
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
if (showIndicator && children.length > 1){
|
|
220
|
+
return (
|
|
221
|
+
<div className={carouselIndicatorCls}>
|
|
222
|
+
<CarouselIndicator
|
|
223
|
+
type={indicatorType}
|
|
224
|
+
total={children.length}
|
|
225
|
+
activeIndex={activeIndex}
|
|
226
|
+
position={indicatorPosition}
|
|
227
|
+
trigger={trigger}
|
|
228
|
+
size={indicatorSize}
|
|
229
|
+
theme={theme}
|
|
230
|
+
onIndicatorChange={this.onIndicatorChange}
|
|
231
|
+
/>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
renderArrow = () => {
|
|
239
|
+
const { children } = this.state;
|
|
240
|
+
const { showArrow, arrowType, theme, arrowProps } = this.props;
|
|
241
|
+
|
|
242
|
+
if (showArrow && children.length > 1){
|
|
243
|
+
return (
|
|
244
|
+
<CarouselArrow
|
|
245
|
+
type={arrowType}
|
|
246
|
+
theme={theme}
|
|
247
|
+
prev={this.prev}
|
|
248
|
+
next={this.next}
|
|
249
|
+
arrowProps={arrowProps}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
render(): ReactNode {
|
|
258
|
+
const { animation, className, style, slideDirection } = this.props;
|
|
259
|
+
const { isReverse } = this.state;
|
|
260
|
+
|
|
261
|
+
const carouselWrapperCls = cls(className, {
|
|
262
|
+
[cssClasses.CAROUSEL]: true
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
<div
|
|
267
|
+
// role='listbox'
|
|
268
|
+
// tabIndex={0}
|
|
269
|
+
className={carouselWrapperCls}
|
|
270
|
+
style={style}
|
|
271
|
+
onMouseEnter={debounce(this.handleMouseEnter, 400)}
|
|
272
|
+
onMouseLeave={debounce(this.handleMouseLeave, 400)}
|
|
273
|
+
// onMouseEnter={this.handleMouseEnter}
|
|
274
|
+
// onMouseLeave={this.handleMouseLeave}
|
|
275
|
+
// onKeyDown={e => this.foundation.handleKeyDown(e)}
|
|
276
|
+
>
|
|
277
|
+
<div
|
|
278
|
+
className={cls([`${cssClasses.CAROUSEL_CONTENT}-${animation}`], {
|
|
279
|
+
[`${cssClasses.CAROUSEL_CONTENT}`]: true,
|
|
280
|
+
[`${cssClasses.CAROUSEL_CONTENT}-reverse`]: slideDirection === 'left' ? isReverse : !isReverse,
|
|
281
|
+
})}
|
|
282
|
+
>
|
|
283
|
+
{this.renderChildren()}
|
|
284
|
+
</div>
|
|
285
|
+
{this.renderIndicator()}
|
|
286
|
+
{this.renderArrow()}
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export default Carousel;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { strings } from '@douyinfe/semi-foundation/carousel/constants';
|
|
3
|
+
|
|
4
|
+
export interface CarouselMethod {
|
|
5
|
+
next?: () => void;
|
|
6
|
+
prev?: () => void;
|
|
7
|
+
goTo?: (tagetIndex: number) => void;
|
|
8
|
+
play?: () => void;
|
|
9
|
+
stop?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CarouselProps {
|
|
13
|
+
activeIndex?: number;
|
|
14
|
+
animation?: typeof strings.ANIMATION_MAP[number];
|
|
15
|
+
arrowProps?: ArrowProps;
|
|
16
|
+
autoPlay?: boolean | {interval?: number, hoverToPause?: boolean};
|
|
17
|
+
arrowType?: typeof strings.ARROW_MAP[number];
|
|
18
|
+
children?: ReactNode | Array<ReactNode>;
|
|
19
|
+
className?: string;
|
|
20
|
+
defaultActiveIndex?: number;
|
|
21
|
+
indicatorPosition?: typeof strings.POSITION_MAP[number];
|
|
22
|
+
indicatorSize?: typeof strings.SIZE[number];
|
|
23
|
+
theme?: typeof strings.THEME_MAP[number];
|
|
24
|
+
indicatorType?: typeof strings.TYPE_MAP[number];
|
|
25
|
+
onChange?: (index: number, preIndex: number) => void;
|
|
26
|
+
showArrow?: boolean;
|
|
27
|
+
showIndicator?: boolean;
|
|
28
|
+
slideDirection?: typeof strings.DIRECTION[number];
|
|
29
|
+
speed?: number;
|
|
30
|
+
style?: React.CSSProperties;
|
|
31
|
+
trigger?: typeof strings.TRIGGER[number];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CarouselIndicatorProps {
|
|
35
|
+
activeIndex?: number;
|
|
36
|
+
className?: string;
|
|
37
|
+
defaultActiveIndex?: number;
|
|
38
|
+
position?: typeof strings.POSITION_MAP[number];
|
|
39
|
+
size?: typeof strings.SIZE[number];
|
|
40
|
+
total?:number;
|
|
41
|
+
theme?: typeof strings.THEME_MAP[number];
|
|
42
|
+
type?: typeof strings.TYPE_MAP[number];
|
|
43
|
+
onIndicatorChange?: (activeIndex: number) => void;
|
|
44
|
+
style?: React.CSSProperties;
|
|
45
|
+
trigger?: typeof strings.TRIGGER[number];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CarouselArrowProps {
|
|
49
|
+
type?: typeof strings.ARROW_MAP[number];
|
|
50
|
+
theme?: typeof strings.THEME_MAP[number];
|
|
51
|
+
prev?: () => void;
|
|
52
|
+
next?: () => void;
|
|
53
|
+
arrowProps?: ArrowProps;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ArrowButton {
|
|
57
|
+
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
58
|
+
children?: React.ReactNode;
|
|
59
|
+
}
|
|
60
|
+
export interface ArrowProps {
|
|
61
|
+
leftArrow?: ArrowButton;
|
|
62
|
+
rightArrow?: ArrowButton;
|
|
63
|
+
}
|
package/cascader/index.tsx
CHANGED
|
@@ -508,8 +508,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
508
508
|
this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
|
|
509
509
|
}}
|
|
510
510
|
>
|
|
511
|
-
{
|
|
512
|
-
{displayProp === 'value' && keyEntities[nodeKey].data.value}
|
|
511
|
+
{keyEntities[nodeKey].data[displayProp]}
|
|
513
512
|
</Tag>
|
|
514
513
|
);
|
|
515
514
|
}
|
package/checkbox/checkbox.tsx
CHANGED
|
@@ -29,13 +29,9 @@ export interface CheckboxProps extends BaseCheckboxProps {
|
|
|
29
29
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
30
30
|
role?: React.HTMLAttributes<HTMLSpanElement>['role']; // a11y: wrapper role
|
|
31
31
|
tabIndex?: number; // a11y: wrapper tabIndex
|
|
32
|
-
addonId?: string;
|
|
33
|
-
extraId?: string;
|
|
34
32
|
}
|
|
35
33
|
interface CheckboxState {
|
|
36
34
|
checked: boolean;
|
|
37
|
-
addonId?: string;
|
|
38
|
-
extraId?: string;
|
|
39
35
|
}
|
|
40
36
|
class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
41
37
|
static contextType = Context;
|
|
@@ -93,13 +89,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
93
89
|
notifyGroupChange: cbContent => {
|
|
94
90
|
this.context.checkboxGroup.onChange(cbContent);
|
|
95
91
|
},
|
|
96
|
-
getGroupDisabled: () => (this.context && this.context.checkboxGroup.disabled)
|
|
97
|
-
setAddonId: () => {
|
|
98
|
-
this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
|
|
99
|
-
},
|
|
100
|
-
setExtraId: () => {
|
|
101
|
-
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
102
|
-
}
|
|
92
|
+
getGroupDisabled: () => (this.context && this.context.checkboxGroup.disabled)
|
|
103
93
|
};
|
|
104
94
|
}
|
|
105
95
|
|
|
@@ -113,11 +103,11 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
113
103
|
|
|
114
104
|
this.state = {
|
|
115
105
|
checked: props.checked || props.defaultChecked || checked,
|
|
116
|
-
addonId: props.addonId,
|
|
117
|
-
extraId: props.extraId,
|
|
118
106
|
};
|
|
119
107
|
|
|
120
108
|
this.checkboxEntity = null;
|
|
109
|
+
this.addonId = getUuidShort({ prefix: 'addon' });
|
|
110
|
+
this.extraId = getUuidShort({ prefix: 'extra' });
|
|
121
111
|
this.foundation = new CheckboxFoundation(this.adapter);
|
|
122
112
|
}
|
|
123
113
|
|
|
@@ -163,7 +153,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
163
153
|
tabIndex,
|
|
164
154
|
id
|
|
165
155
|
} = this.props;
|
|
166
|
-
const { checked
|
|
156
|
+
const { checked } = this.state;
|
|
167
157
|
const props: Record<string, any> = {
|
|
168
158
|
checked,
|
|
169
159
|
disabled,
|
|
@@ -206,8 +196,8 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
206
196
|
|
|
207
197
|
const renderContent = () => (
|
|
208
198
|
<>
|
|
209
|
-
{children ? <span id={addonId} className={`${prefix}-addon`}>{children}</span> : null}
|
|
210
|
-
{extra ? <div id={extraId} className={extraCls}>{extra}</div> : null}
|
|
199
|
+
{children ? <span id={this.addonId} className={`${prefix}-addon`}>{children}</span> : null}
|
|
200
|
+
{extra ? <div id={this.extraId} className={extraCls}>{extra}</div> : null}
|
|
211
201
|
</>
|
|
212
202
|
);
|
|
213
203
|
return (
|
|
@@ -228,8 +218,8 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
228
218
|
<CheckboxInner
|
|
229
219
|
{...this.props}
|
|
230
220
|
{...props}
|
|
231
|
-
addonId={children && addonId}
|
|
232
|
-
extraId={extra && extraId}
|
|
221
|
+
addonId={children && this.addonId}
|
|
222
|
+
extraId={extra && this.extraId}
|
|
233
223
|
name={name}
|
|
234
224
|
isPureCardType={props.isPureCardType}
|
|
235
225
|
ref={ref => {
|
|
@@ -10,7 +10,7 @@ import { format as formatFn, addMonths, isSameDay } from 'date-fns';
|
|
|
10
10
|
|
|
11
11
|
import MonthsGridFoundation, { MonthInfo, MonthsGridAdapter, MonthsGridDateAdapter, MonthsGridFoundationProps, MonthsGridFoundationState, MonthsGridRangeAdapter, PanelType } from '@douyinfe/semi-foundation/datePicker/monthsGridFoundation';
|
|
12
12
|
import { strings, numbers, cssClasses } from '@douyinfe/semi-foundation/datePicker/constants';
|
|
13
|
-
import {
|
|
13
|
+
import { compatibleParse } from '@douyinfe/semi-foundation/datePicker/_utils/parser';
|
|
14
14
|
import { noop, stubFalse } from 'lodash';
|
|
15
15
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
16
16
|
import Navigation from './navigation';
|
|
@@ -476,8 +476,8 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
476
476
|
rangeStart &&
|
|
477
477
|
rangeEnd &&
|
|
478
478
|
isSameDay(
|
|
479
|
-
(startDate =
|
|
480
|
-
(endDate =
|
|
479
|
+
(startDate = compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale)),
|
|
480
|
+
(endDate = compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale))
|
|
481
481
|
)
|
|
482
482
|
) {
|
|
483
483
|
if (panelType === strings.PANEL_TYPE_RIGHT) {
|
|
@@ -550,10 +550,10 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
550
550
|
|
|
551
551
|
if (panelType === strings.PANEL_TYPE_LEFT) {
|
|
552
552
|
panelDetail = monthLeft;
|
|
553
|
-
dateText = rangeStart ? formatFn(
|
|
553
|
+
dateText = rangeStart ? formatFn(compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
554
554
|
} else {
|
|
555
555
|
panelDetail = monthRight;
|
|
556
|
-
dateText = rangeEnd ? formatFn(
|
|
556
|
+
dateText = rangeEnd ? formatFn(compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
const { isTimePickerOpen, showDate } = panelDetail;
|
|
@@ -561,7 +561,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
561
561
|
|
|
562
562
|
const timeText = showDate ? formatFn(showDate, formatTimePicker) : '';
|
|
563
563
|
|
|
564
|
-
const
|
|
564
|
+
const showSwitchIcon = ['default'].includes(density);
|
|
565
565
|
|
|
566
566
|
const switchCls = classnames(`${prefixCls}-switch`);
|
|
567
567
|
const dateCls = classnames({
|
|
@@ -583,7 +583,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
583
583
|
className={dateCls}
|
|
584
584
|
onClick={e => this.foundation.showDatePanel(panelType)}
|
|
585
585
|
>
|
|
586
|
-
{
|
|
586
|
+
{showSwitchIcon && <IconCalendar aria-hidden />}
|
|
587
587
|
<span className={textCls}>{dateText || monthText}</span>
|
|
588
588
|
</div>
|
|
589
589
|
<div
|
|
@@ -592,7 +592,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
592
592
|
className={timeCls}
|
|
593
593
|
onClick={e => this.foundation.showTimePicker(panelType, true)}
|
|
594
594
|
>
|
|
595
|
-
{
|
|
595
|
+
{showSwitchIcon && <IconClock aria-hidden />}
|
|
596
596
|
<span className={textCls}>{timeText}</span>
|
|
597
597
|
</div>
|
|
598
598
|
</div>
|