@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,309 @@
|
|
|
1
|
+
import _debounce from "lodash/debounce";
|
|
2
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
3
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
4
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
5
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
6
|
+
|
|
7
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
8
|
+
import React, { Children } from 'react';
|
|
9
|
+
import cls from 'classnames';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import BaseComponent from "../_base/baseComponent";
|
|
12
|
+
import { cssClasses, numbers, strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
|
|
13
|
+
import CarouselFoundation from '@douyinfe/semi-foundation/lib/es/carousel/foundation';
|
|
14
|
+
import CarouselIndicator from './CarouselIndicator';
|
|
15
|
+
import CarouselArrow from './CarouselArrow';
|
|
16
|
+
import '@douyinfe/semi-foundation/lib/es/carousel/carousel.css';
|
|
17
|
+
import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
|
|
18
|
+
|
|
19
|
+
class Carousel extends BaseComponent {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
22
|
+
|
|
23
|
+
this.play = () => {
|
|
24
|
+
return this.foundation.handleAutoPlay();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.stop = () => {
|
|
28
|
+
return this.foundation.stop();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
this.goTo = targetIndex => {
|
|
32
|
+
return this.foundation.goTo(targetIndex);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.prev = () => {
|
|
36
|
+
return this.foundation.prev();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.next = () => {
|
|
40
|
+
return this.foundation.next();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
this.handleAutoPlay = () => {
|
|
44
|
+
if (!this.foundation.getIsControledComponent()) {
|
|
45
|
+
this.foundation.handleAutoPlay();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
this.handleMouseEnter = () => {
|
|
50
|
+
const {
|
|
51
|
+
autoPlay
|
|
52
|
+
} = this.props;
|
|
53
|
+
|
|
54
|
+
if (typeof autoPlay !== 'object' || autoPlay.hoverToPause) {
|
|
55
|
+
this.foundation.stop();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.handleMouseLeave = () => {
|
|
60
|
+
const {
|
|
61
|
+
autoPlay
|
|
62
|
+
} = this.props;
|
|
63
|
+
|
|
64
|
+
if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControledComponent()) {
|
|
65
|
+
this.foundation.handleAutoPlay();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.onIndicatorChange = activeIndex => {
|
|
70
|
+
return this.foundation.onIndicatorChange(activeIndex);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
this.getChildren = () => {
|
|
74
|
+
var _context;
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
children: originChildren
|
|
78
|
+
} = this.props;
|
|
79
|
+
return _filterInstanceProperty(_context = Children.toArray(originChildren)).call(_context, child => {
|
|
80
|
+
return /*#__PURE__*/React.isValidElement(child);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
this.getValidIndex = activeIndex => {
|
|
85
|
+
return this.foundation.getValidIndex(activeIndex);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
this.renderChildren = () => {
|
|
89
|
+
const {
|
|
90
|
+
speed,
|
|
91
|
+
animation
|
|
92
|
+
} = this.props;
|
|
93
|
+
const {
|
|
94
|
+
activeIndex,
|
|
95
|
+
children,
|
|
96
|
+
preIndex,
|
|
97
|
+
isInit
|
|
98
|
+
} = this.state;
|
|
99
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, _mapInstanceProperty(children).call(children, (child, index) => {
|
|
100
|
+
const isCurrent = index === activeIndex;
|
|
101
|
+
const isPrev = index === this.getValidIndex(activeIndex - 1);
|
|
102
|
+
const isNext = index === this.getValidIndex(activeIndex + 1);
|
|
103
|
+
const animateStyle = {
|
|
104
|
+
transitionTimingFunction: 'ease',
|
|
105
|
+
transitionDuration: "".concat(speed, "ms"),
|
|
106
|
+
animationTimingFunction: 'ease',
|
|
107
|
+
animationDuration: "".concat(speed, "ms")
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
110
|
+
style: _Object$assign(_Object$assign({}, child.props.style), animateStyle),
|
|
111
|
+
className: cls(child.props.className, {
|
|
112
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-prev")]: isPrev,
|
|
113
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-next")]: isNext,
|
|
114
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-current")]: isCurrent,
|
|
115
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item")]: true,
|
|
116
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-active")]: isCurrent,
|
|
117
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-slide-in")]: animation === 'slide' && !isInit && isCurrent,
|
|
118
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-item-slide-out")]: animation === 'slide' && !isInit && index === preIndex
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
this.renderIndicator = () => {
|
|
125
|
+
const {
|
|
126
|
+
children,
|
|
127
|
+
activeIndex
|
|
128
|
+
} = this.state;
|
|
129
|
+
const {
|
|
130
|
+
showIndicator,
|
|
131
|
+
indicatorType,
|
|
132
|
+
theme,
|
|
133
|
+
indicatorPosition,
|
|
134
|
+
indicatorSize,
|
|
135
|
+
trigger
|
|
136
|
+
} = this.props;
|
|
137
|
+
const carouselIndicatorCls = cls({
|
|
138
|
+
[cssClasses.CAROUSEL_INDICATOR]: true
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (showIndicator && children.length > 1) {
|
|
142
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: carouselIndicatorCls
|
|
144
|
+
}, /*#__PURE__*/React.createElement(CarouselIndicator, {
|
|
145
|
+
type: indicatorType,
|
|
146
|
+
total: children.length,
|
|
147
|
+
activeIndex: activeIndex,
|
|
148
|
+
position: indicatorPosition,
|
|
149
|
+
trigger: trigger,
|
|
150
|
+
size: indicatorSize,
|
|
151
|
+
theme: theme,
|
|
152
|
+
onIndicatorChange: this.onIndicatorChange
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
this.renderArrow = () => {
|
|
160
|
+
const {
|
|
161
|
+
children
|
|
162
|
+
} = this.state;
|
|
163
|
+
const {
|
|
164
|
+
showArrow,
|
|
165
|
+
arrowType,
|
|
166
|
+
theme,
|
|
167
|
+
arrowProps
|
|
168
|
+
} = this.props;
|
|
169
|
+
|
|
170
|
+
if (showArrow && children.length > 1) {
|
|
171
|
+
return /*#__PURE__*/React.createElement(CarouselArrow, {
|
|
172
|
+
type: arrowType,
|
|
173
|
+
theme: theme,
|
|
174
|
+
prev: this.prev,
|
|
175
|
+
next: this.next,
|
|
176
|
+
arrowProps: arrowProps
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return null;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
this.foundation = new CarouselFoundation(this.adapter);
|
|
184
|
+
const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
|
|
185
|
+
this.state = {
|
|
186
|
+
activeIndex: defaultActiveIndex,
|
|
187
|
+
children: this.getChildren(),
|
|
188
|
+
preIndex: defaultActiveIndex,
|
|
189
|
+
isReverse: false,
|
|
190
|
+
isInit: true
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
get adapter() {
|
|
195
|
+
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
196
|
+
notifyChange: (activeIndex, preIndex) => {
|
|
197
|
+
this.props.onChange(activeIndex, preIndex);
|
|
198
|
+
},
|
|
199
|
+
setNewActiveIndex: activeIndex => {
|
|
200
|
+
this.setState({
|
|
201
|
+
activeIndex
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
setPreActiveIndex: preIndex => {
|
|
205
|
+
this.setState({
|
|
206
|
+
preIndex
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
setIsReverse: isReverse => {
|
|
210
|
+
this.setState({
|
|
211
|
+
isReverse
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
setIsInit: isInit => {
|
|
215
|
+
this.setState({
|
|
216
|
+
isInit
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static getDerivedStateFromProps(props, state) {
|
|
223
|
+
const states = {};
|
|
224
|
+
|
|
225
|
+
if (!isNullOrUndefined(props.activeIndex) && props.activeIndex !== state.activeIndex) {
|
|
226
|
+
states.activeIndex = props.activeIndex;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return states;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
componentDidMount() {
|
|
233
|
+
this.handleAutoPlay();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
componentWillUnmount() {
|
|
237
|
+
this.foundation.destroy();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
render() {
|
|
241
|
+
var _context2;
|
|
242
|
+
|
|
243
|
+
const {
|
|
244
|
+
animation,
|
|
245
|
+
className,
|
|
246
|
+
style,
|
|
247
|
+
slideDirection
|
|
248
|
+
} = this.props;
|
|
249
|
+
const {
|
|
250
|
+
isReverse
|
|
251
|
+
} = this.state;
|
|
252
|
+
const carouselWrapperCls = cls(className, {
|
|
253
|
+
[cssClasses.CAROUSEL]: true
|
|
254
|
+
});
|
|
255
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
256
|
+
// role='listbox'
|
|
257
|
+
// tabIndex={0}
|
|
258
|
+
className: carouselWrapperCls,
|
|
259
|
+
style: style,
|
|
260
|
+
onMouseEnter: _debounce(this.handleMouseEnter, 400),
|
|
261
|
+
onMouseLeave: _debounce(this.handleMouseLeave, 400)
|
|
262
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
263
|
+
className: cls([_concatInstanceProperty(_context2 = "".concat(cssClasses.CAROUSEL_CONTENT, "-")).call(_context2, animation)], {
|
|
264
|
+
["".concat(cssClasses.CAROUSEL_CONTENT)]: true,
|
|
265
|
+
["".concat(cssClasses.CAROUSEL_CONTENT, "-reverse")]: slideDirection === 'left' ? isReverse : !isReverse
|
|
266
|
+
})
|
|
267
|
+
}, this.renderChildren()), this.renderIndicator(), this.renderArrow());
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
Carousel.propTypes = {
|
|
273
|
+
activeIndex: PropTypes.number,
|
|
274
|
+
animation: PropTypes.oneOf(strings.ANIMATION_MAP),
|
|
275
|
+
arrowProps: PropTypes.object,
|
|
276
|
+
autoPlay: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
277
|
+
className: PropTypes.string,
|
|
278
|
+
defaultActiveIndex: PropTypes.number,
|
|
279
|
+
indicatorPosition: PropTypes.oneOf(strings.POSITION_MAP),
|
|
280
|
+
indicatorSize: PropTypes.oneOf(strings.SIZE),
|
|
281
|
+
indicatorType: PropTypes.oneOf(strings.TYPE_MAP),
|
|
282
|
+
theme: PropTypes.oneOf(strings.THEME_MAP),
|
|
283
|
+
onChange: PropTypes.func,
|
|
284
|
+
arrowType: PropTypes.oneOf(strings.ARROW_MAP),
|
|
285
|
+
showArrow: PropTypes.bool,
|
|
286
|
+
showIndicator: PropTypes.bool,
|
|
287
|
+
slideDirection: PropTypes.oneOf(strings.DIRECTION),
|
|
288
|
+
speed: PropTypes.number,
|
|
289
|
+
style: PropTypes.object,
|
|
290
|
+
trigger: PropTypes.oneOf(strings.TRIGGER)
|
|
291
|
+
};
|
|
292
|
+
Carousel.defaultProps = {
|
|
293
|
+
children: [],
|
|
294
|
+
animation: 'slide',
|
|
295
|
+
autoPlay: true,
|
|
296
|
+
arrowType: 'always',
|
|
297
|
+
defaultActiveIndex: numbers.DEFAULT_ACTIVE_INDEX,
|
|
298
|
+
indicatorPosition: 'center',
|
|
299
|
+
indicatorSize: 'small',
|
|
300
|
+
indicatorType: 'dot',
|
|
301
|
+
theme: 'light',
|
|
302
|
+
onChange: () => undefined,
|
|
303
|
+
showArrow: true,
|
|
304
|
+
showIndicator: true,
|
|
305
|
+
slideDirection: 'left',
|
|
306
|
+
speed: numbers.DEFAULT_SPEED,
|
|
307
|
+
trigger: 'click'
|
|
308
|
+
};
|
|
309
|
+
export default Carousel;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
|
|
3
|
+
export interface CarouselMethod {
|
|
4
|
+
next?: () => void;
|
|
5
|
+
prev?: () => void;
|
|
6
|
+
goTo?: (tagetIndex: number) => void;
|
|
7
|
+
play?: () => void;
|
|
8
|
+
stop?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface CarouselProps {
|
|
11
|
+
activeIndex?: number;
|
|
12
|
+
animation?: typeof strings.ANIMATION_MAP[number];
|
|
13
|
+
arrowProps?: ArrowProps;
|
|
14
|
+
autoPlay?: boolean | {
|
|
15
|
+
interval?: number;
|
|
16
|
+
hoverToPause?: boolean;
|
|
17
|
+
};
|
|
18
|
+
arrowType?: typeof strings.ARROW_MAP[number];
|
|
19
|
+
children?: ReactNode | Array<ReactNode>;
|
|
20
|
+
className?: string;
|
|
21
|
+
defaultActiveIndex?: number;
|
|
22
|
+
indicatorPosition?: typeof strings.POSITION_MAP[number];
|
|
23
|
+
indicatorSize?: typeof strings.SIZE[number];
|
|
24
|
+
theme?: typeof strings.THEME_MAP[number];
|
|
25
|
+
indicatorType?: typeof strings.TYPE_MAP[number];
|
|
26
|
+
onChange?: (index: number, preIndex: number) => void;
|
|
27
|
+
showArrow?: boolean;
|
|
28
|
+
showIndicator?: boolean;
|
|
29
|
+
slideDirection?: typeof strings.DIRECTION[number];
|
|
30
|
+
speed?: number;
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
trigger?: typeof strings.TRIGGER[number];
|
|
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
|
+
export interface CarouselArrowProps {
|
|
48
|
+
type?: typeof strings.ARROW_MAP[number];
|
|
49
|
+
theme?: typeof strings.THEME_MAP[number];
|
|
50
|
+
prev?: () => void;
|
|
51
|
+
next?: () => void;
|
|
52
|
+
arrowProps?: ArrowProps;
|
|
53
|
+
}
|
|
54
|
+
export interface ArrowButton {
|
|
55
|
+
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
56
|
+
children?: React.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
export interface ArrowProps {
|
|
59
|
+
leftArrow?: ArrowButton;
|
|
60
|
+
rightArrow?: ArrowButton;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -84,7 +84,7 @@ class Cascader extends BaseComponent {
|
|
|
84
84
|
e.preventDefault();
|
|
85
85
|
this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
|
|
86
86
|
}
|
|
87
|
-
},
|
|
87
|
+
}, keyEntities[nodeKey].data[displayProp]);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -22,13 +22,9 @@ export interface CheckboxProps extends BaseCheckboxProps {
|
|
|
22
22
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
23
23
|
role?: React.HTMLAttributes<HTMLSpanElement>['role'];
|
|
24
24
|
tabIndex?: number;
|
|
25
|
-
addonId?: string;
|
|
26
|
-
extraId?: string;
|
|
27
25
|
}
|
|
28
26
|
interface CheckboxState {
|
|
29
27
|
checked: boolean;
|
|
30
|
-
addonId?: string;
|
|
31
|
-
extraId?: string;
|
|
32
28
|
}
|
|
33
29
|
declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
34
30
|
static contextType: React.Context<CheckboxContextType>;
|
|
@@ -26,11 +26,15 @@ class Checkbox extends BaseComponent {
|
|
|
26
26
|
|
|
27
27
|
const checked = false;
|
|
28
28
|
this.state = {
|
|
29
|
-
checked: props.checked || props.defaultChecked || checked
|
|
30
|
-
addonId: props.addonId,
|
|
31
|
-
extraId: props.extraId
|
|
29
|
+
checked: props.checked || props.defaultChecked || checked
|
|
32
30
|
};
|
|
33
31
|
this.checkboxEntity = null;
|
|
32
|
+
this.addonId = getUuidShort({
|
|
33
|
+
prefix: 'addon'
|
|
34
|
+
});
|
|
35
|
+
this.extraId = getUuidShort({
|
|
36
|
+
prefix: 'extra'
|
|
37
|
+
});
|
|
34
38
|
this.foundation = new CheckboxFoundation(this.adapter);
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -52,21 +56,7 @@ class Checkbox extends BaseComponent {
|
|
|
52
56
|
notifyGroupChange: cbContent => {
|
|
53
57
|
this.context.checkboxGroup.onChange(cbContent);
|
|
54
58
|
},
|
|
55
|
-
getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
|
|
56
|
-
setAddonId: () => {
|
|
57
|
-
this.setState({
|
|
58
|
-
addonId: getUuidShort({
|
|
59
|
-
prefix: 'addon'
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
setExtraId: () => {
|
|
64
|
-
this.setState({
|
|
65
|
-
extraId: getUuidShort({
|
|
66
|
-
prefix: 'extra'
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
}
|
|
59
|
+
getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
|
|
70
60
|
});
|
|
71
61
|
}
|
|
72
62
|
|
|
@@ -109,9 +99,7 @@ class Checkbox extends BaseComponent {
|
|
|
109
99
|
id
|
|
110
100
|
} = this.props;
|
|
111
101
|
const {
|
|
112
|
-
checked
|
|
113
|
-
addonId,
|
|
114
|
-
extraId
|
|
102
|
+
checked
|
|
115
103
|
} = this.state;
|
|
116
104
|
const props = {
|
|
117
105
|
checked,
|
|
@@ -159,10 +147,10 @@ class Checkbox extends BaseComponent {
|
|
|
159
147
|
const name = inGroup && this.context.checkboxGroup.name;
|
|
160
148
|
|
|
161
149
|
const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
|
|
162
|
-
id: addonId,
|
|
150
|
+
id: this.addonId,
|
|
163
151
|
className: "".concat(prefix, "-addon")
|
|
164
152
|
}, children) : null, extra ? /*#__PURE__*/React.createElement("div", {
|
|
165
|
-
id: extraId,
|
|
153
|
+
id: this.extraId,
|
|
166
154
|
className: extraCls
|
|
167
155
|
}, extra) : null);
|
|
168
156
|
|
|
@@ -182,8 +170,8 @@ class Checkbox extends BaseComponent {
|
|
|
182
170
|
onKeyPress: this.handleEnterPress,
|
|
183
171
|
"aria-labelledby": this.props['aria-labelledby']
|
|
184
172
|
}, /*#__PURE__*/React.createElement(CheckboxInner, _Object$assign({}, this.props, props, {
|
|
185
|
-
addonId: children && addonId,
|
|
186
|
-
extraId: extra && extraId,
|
|
173
|
+
addonId: children && this.addonId,
|
|
174
|
+
extraId: extra && this.extraId,
|
|
187
175
|
name: name,
|
|
188
176
|
isPureCardType: props.isPureCardType,
|
|
189
177
|
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>;
|
|
@@ -21,7 +21,7 @@ import PropTypes from 'prop-types';
|
|
|
21
21
|
import { format as formatFn, isSameDay } from 'date-fns';
|
|
22
22
|
import MonthsGridFoundation from '@douyinfe/semi-foundation/lib/es/datePicker/monthsGridFoundation';
|
|
23
23
|
import { strings, numbers, cssClasses } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
|
|
24
|
-
import {
|
|
24
|
+
import { compatibleParse } from '@douyinfe/semi-foundation/lib/es/datePicker/_utils/parser';
|
|
25
25
|
import BaseComponent from '../_base/baseComponent';
|
|
26
26
|
import Navigation from './navigation';
|
|
27
27
|
import Month from './month';
|
|
@@ -474,7 +474,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
474
474
|
const dateFormat = this.foundation.getValidDateFormat();
|
|
475
475
|
let startDate, endDate;
|
|
476
476
|
|
|
477
|
-
if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate =
|
|
477
|
+
if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate = compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
|
|
478
478
|
if (panelType === strings.PANEL_TYPE_RIGHT) {
|
|
479
479
|
rangeStart && (restProps.startDate = startDate);
|
|
480
480
|
} else {
|
|
@@ -560,10 +560,10 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
560
560
|
|
|
561
561
|
if (panelType === strings.PANEL_TYPE_LEFT) {
|
|
562
562
|
panelDetail = monthLeft;
|
|
563
|
-
dateText = rangeStart ? formatFn(
|
|
563
|
+
dateText = rangeStart ? formatFn(compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
564
564
|
} else {
|
|
565
565
|
panelDetail = monthRight;
|
|
566
|
-
dateText = rangeEnd ? formatFn(
|
|
566
|
+
dateText = rangeEnd ? formatFn(compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
const {
|
|
@@ -573,7 +573,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
573
573
|
const monthText = showDate ? formatFn(showDate, FORMAT_SWITCH_DATE) : '';
|
|
574
574
|
const timeText = showDate ? formatFn(showDate, formatTimePicker) : '';
|
|
575
575
|
|
|
576
|
-
const
|
|
576
|
+
const showSwitchIcon = _includesInstanceProperty(_context3 = ['default']).call(_context3, density);
|
|
577
577
|
|
|
578
578
|
const switchCls = classnames("".concat(prefixCls, "-switch"));
|
|
579
579
|
const dateCls = classnames({
|
|
@@ -594,7 +594,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
594
594
|
"aria-label": "Switch to date panel",
|
|
595
595
|
className: dateCls,
|
|
596
596
|
onClick: e => this.foundation.showDatePanel(panelType)
|
|
597
|
-
},
|
|
597
|
+
}, showSwitchIcon && /*#__PURE__*/React.createElement(IconCalendar, {
|
|
598
598
|
"aria-hidden": true
|
|
599
599
|
}), /*#__PURE__*/React.createElement("span", {
|
|
600
600
|
className: textCls
|
|
@@ -603,7 +603,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
603
603
|
"aria-label": "Switch to time panel",
|
|
604
604
|
className: timeCls,
|
|
605
605
|
onClick: e => this.foundation.showTimePicker(panelType, true)
|
|
606
|
-
},
|
|
606
|
+
}, showSwitchIcon && /*#__PURE__*/React.createElement(IconClock, {
|
|
607
607
|
"aria-hidden": true
|
|
608
608
|
}), /*#__PURE__*/React.createElement("span", {
|
|
609
609
|
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/es/form/baseForm.js
CHANGED
|
@@ -47,7 +47,7 @@ class Form extends BaseComponent {
|
|
|
47
47
|
|
|
48
48
|
super(props);
|
|
49
49
|
this.state = {
|
|
50
|
-
formId:
|
|
50
|
+
formId: ''
|
|
51
51
|
};
|
|
52
52
|
warning(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');
|
|
53
53
|
warning(props.component && props.children && !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');
|
|
@@ -62,6 +62,10 @@ class Form extends BaseComponent {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
this.foundation.init();
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
componentWillUnmount() {
|
|
66
70
|
this.foundation.destroy();
|
|
67
71
|
this.foundation = null;
|
|
@@ -89,6 +93,11 @@ class Form extends BaseComponent {
|
|
|
89
93
|
notifyReset: () => {
|
|
90
94
|
this.props.onReset();
|
|
91
95
|
},
|
|
96
|
+
initFormId: () => {
|
|
97
|
+
this.setState({
|
|
98
|
+
formId: getUuidv4()
|
|
99
|
+
});
|
|
100
|
+
},
|
|
92
101
|
getInitValues: () => this.props.initValues,
|
|
93
102
|
getFormProps: keys => {
|
|
94
103
|
if (typeof keys === 'undefined') {
|
package/lib/es/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>;
|