@douyinfe/semi-ui 2.31.2-alpha.0 → 2.32.0-beta.0
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/dist/css/semi.css +40 -11
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +693 -379
- 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/lib/cjs/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/cascader/index.d.ts +1 -0
- package/lib/cjs/cascader/index.js +10 -1
- package/lib/cjs/datePicker/dateInput.d.ts +5 -1
- package/lib/cjs/datePicker/dateInput.js +16 -9
- package/lib/cjs/datePicker/datePicker.d.ts +33 -5
- package/lib/cjs/datePicker/datePicker.js +104 -23
- package/lib/cjs/datePicker/index.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.js +11 -3
- package/lib/cjs/datePicker/yearAndMonth.d.ts +10 -6
- package/lib/cjs/datePicker/yearAndMonth.js +84 -30
- package/lib/cjs/form/baseForm.d.ts +3 -3
- package/lib/cjs/form/field.d.ts +2 -2
- package/lib/cjs/input/index.d.ts +1 -1
- package/lib/cjs/input/inputGroup.d.ts +1 -1
- package/lib/cjs/locale/interface.d.ts +1 -0
- package/lib/cjs/locale/source/ar.js +2 -1
- package/lib/cjs/locale/source/de.js +2 -1
- package/lib/cjs/locale/source/en_GB.js +2 -1
- package/lib/cjs/locale/source/en_US.js +2 -1
- package/lib/cjs/locale/source/es.js +2 -1
- package/lib/cjs/locale/source/fr.js +2 -1
- package/lib/cjs/locale/source/id_ID.js +2 -1
- package/lib/cjs/locale/source/it.js +2 -1
- package/lib/cjs/locale/source/ja_JP.js +2 -1
- package/lib/cjs/locale/source/ko_KR.js +2 -1
- package/lib/cjs/locale/source/ms_MY.js +2 -1
- package/lib/cjs/locale/source/nl_NL.js +2 -1
- package/lib/cjs/locale/source/pl_PL.js +2 -1
- package/lib/cjs/locale/source/pt_BR.js +2 -1
- package/lib/cjs/locale/source/ro.d.ts +1 -0
- package/lib/cjs/locale/source/ro.js +2 -1
- package/lib/cjs/locale/source/ru_RU.js +2 -1
- package/lib/cjs/locale/source/sv_SE.js +2 -1
- package/lib/cjs/locale/source/th_TH.js +2 -1
- package/lib/cjs/locale/source/tr_TR.js +2 -1
- package/lib/cjs/locale/source/vi_VN.js +2 -1
- package/lib/cjs/locale/source/zh_CN.js +2 -1
- package/lib/cjs/locale/source/zh_TW.js +2 -1
- package/lib/cjs/modal/confirm.d.ts +8 -8
- package/lib/cjs/navigation/Item.js +4 -2
- package/lib/cjs/navigation/nav-context.d.ts +2 -0
- package/lib/cjs/rating/index.d.ts +1 -1
- package/lib/cjs/rating/item.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +18 -1
- package/lib/cjs/select/index.js +4 -1
- package/lib/cjs/sideSheet/SideSheetContent.d.ts +3 -1
- package/lib/cjs/sideSheet/SideSheetContent.js +3 -2
- package/lib/cjs/sideSheet/index.js +6 -3
- package/lib/cjs/space/index.js +5 -2
- package/lib/cjs/switch/index.d.ts +1 -1
- package/lib/cjs/switch/index.js +1 -1
- package/lib/cjs/table/Table.d.ts +2 -2
- package/lib/cjs/table/index.d.ts +1 -1
- package/lib/cjs/tagInput/index.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +1 -1
- package/lib/cjs/treeSelect/index.d.ts +1 -0
- package/lib/cjs/treeSelect/index.js +7 -3
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +10 -1
- package/lib/es/datePicker/dateInput.d.ts +5 -1
- package/lib/es/datePicker/dateInput.js +16 -9
- package/lib/es/datePicker/datePicker.d.ts +33 -5
- package/lib/es/datePicker/datePicker.js +109 -23
- package/lib/es/datePicker/index.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.js +11 -3
- package/lib/es/datePicker/yearAndMonth.d.ts +10 -6
- package/lib/es/datePicker/yearAndMonth.js +83 -29
- package/lib/es/form/baseForm.d.ts +3 -3
- package/lib/es/form/field.d.ts +2 -2
- package/lib/es/input/index.d.ts +1 -1
- package/lib/es/input/inputGroup.d.ts +1 -1
- package/lib/es/locale/interface.d.ts +1 -0
- package/lib/es/locale/source/ar.js +2 -1
- package/lib/es/locale/source/de.js +2 -1
- package/lib/es/locale/source/en_GB.js +2 -1
- package/lib/es/locale/source/en_US.js +2 -1
- package/lib/es/locale/source/es.js +2 -1
- package/lib/es/locale/source/fr.js +2 -1
- package/lib/es/locale/source/id_ID.js +2 -1
- package/lib/es/locale/source/it.js +2 -1
- package/lib/es/locale/source/ja_JP.js +2 -1
- package/lib/es/locale/source/ko_KR.js +2 -1
- package/lib/es/locale/source/ms_MY.js +2 -1
- package/lib/es/locale/source/nl_NL.js +2 -1
- package/lib/es/locale/source/pl_PL.js +2 -1
- package/lib/es/locale/source/pt_BR.js +2 -1
- package/lib/es/locale/source/ro.d.ts +1 -0
- package/lib/es/locale/source/ro.js +2 -1
- package/lib/es/locale/source/ru_RU.js +2 -1
- package/lib/es/locale/source/sv_SE.js +2 -1
- package/lib/es/locale/source/th_TH.js +2 -1
- package/lib/es/locale/source/tr_TR.js +2 -1
- package/lib/es/locale/source/vi_VN.js +2 -1
- package/lib/es/locale/source/zh_CN.js +2 -1
- package/lib/es/locale/source/zh_TW.js +2 -1
- package/lib/es/modal/confirm.d.ts +8 -8
- package/lib/es/navigation/Item.js +4 -2
- package/lib/es/navigation/nav-context.d.ts +2 -0
- package/lib/es/rating/index.d.ts +1 -1
- package/lib/es/rating/item.d.ts +1 -1
- package/lib/es/select/index.d.ts +18 -1
- package/lib/es/select/index.js +4 -1
- package/lib/es/sideSheet/SideSheetContent.d.ts +3 -1
- package/lib/es/sideSheet/SideSheetContent.js +3 -2
- package/lib/es/sideSheet/index.js +6 -3
- package/lib/es/space/index.js +4 -2
- package/lib/es/switch/index.d.ts +1 -1
- package/lib/es/switch/index.js +1 -1
- package/lib/es/table/Table.d.ts +2 -2
- package/lib/es/table/index.d.ts +1 -1
- package/lib/es/tagInput/index.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +1 -1
- package/lib/es/treeSelect/index.d.ts +1 -0
- package/lib/es/treeSelect/index.js +7 -3
- package/lib/es/typography/title.d.ts +1 -1
- package/package.json +8 -8
|
@@ -28,10 +28,21 @@ export interface DatePickerProps extends DatePickerFoundationProps {
|
|
|
28
28
|
renderDate?: (dayNumber?: number, fullDate?: string) => React.ReactNode;
|
|
29
29
|
renderFullDate?: (dayNumber?: number, fullDate?: string, dayStatus?: DayStatusType) => React.ReactNode;
|
|
30
30
|
triggerRender?: (props: DatePickerProps) => React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* There are multiple input boxes when selecting a range, and the input boxes will be out of focus multiple times.
|
|
33
|
+
*
|
|
34
|
+
* Use `onOpenChange` or `onClickOutSide` instead
|
|
35
|
+
*/
|
|
31
36
|
onBlur?: React.MouseEventHandler<HTMLInputElement>;
|
|
32
37
|
onClear?: React.MouseEventHandler<HTMLDivElement>;
|
|
38
|
+
/**
|
|
39
|
+
* There are multiple input boxes when selecting a range, and the input boxes will be focused multiple times.
|
|
40
|
+
*
|
|
41
|
+
* Use `onOpenChange` or `triggerRender` instead
|
|
42
|
+
*/
|
|
33
43
|
onFocus?: (e: React.MouseEvent, rangeType: RangeType) => void;
|
|
34
44
|
onPresetClick?: (item: PresetType, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
45
|
+
onClickOutSide?: () => void;
|
|
35
46
|
locale?: Locale['DatePicker'];
|
|
36
47
|
dateFnsLocale?: Locale['dateFnsLocale'];
|
|
37
48
|
yearAndMonthOpts?: ScrollItemProps<any>;
|
|
@@ -46,8 +57,8 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
46
57
|
'aria-invalid': PropTypes.Requireable<boolean>;
|
|
47
58
|
'aria-labelledby': PropTypes.Requireable<string>;
|
|
48
59
|
'aria-required': PropTypes.Requireable<boolean>;
|
|
49
|
-
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
50
|
-
size: PropTypes.Requireable<"
|
|
60
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "monthRange" | "dateTimeRange">;
|
|
61
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
51
62
|
clearIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
52
63
|
density: PropTypes.Requireable<"default" | "compact">;
|
|
53
64
|
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
@@ -113,6 +124,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
113
124
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
114
125
|
preventScroll: PropTypes.Requireable<boolean>;
|
|
115
126
|
yearAndMonthOpts: PropTypes.Requireable<object>;
|
|
127
|
+
onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
116
128
|
};
|
|
117
129
|
static defaultProps: {
|
|
118
130
|
onChangeWithDateFirst: boolean;
|
|
@@ -155,12 +167,14 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
155
167
|
syncSwitchMonth: boolean;
|
|
156
168
|
rangeSeparator: " ~ ";
|
|
157
169
|
insetInput: boolean;
|
|
170
|
+
onClickOutSide: (...args: any[]) => void;
|
|
158
171
|
};
|
|
159
172
|
triggerElRef: React.MutableRefObject<HTMLElement>;
|
|
160
173
|
panelRef: React.RefObject<HTMLDivElement>;
|
|
161
174
|
monthGrid: React.RefObject<MonthsGrid>;
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
inputRef: DateInputProps['inputRef'];
|
|
176
|
+
rangeInputStartRef: DateInputProps['rangeInputStartRef'];
|
|
177
|
+
rangeInputEndRef: DateInputProps['rangeInputEndRef'];
|
|
164
178
|
focusRecordsRef: React.RefObject<{
|
|
165
179
|
rangeStart: boolean;
|
|
166
180
|
rangeEnd: boolean;
|
|
@@ -175,6 +189,20 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
175
189
|
componentDidUpdate(prevProps: DatePickerProps): void;
|
|
176
190
|
componentDidMount(): void;
|
|
177
191
|
componentWillUnmount(): void;
|
|
192
|
+
open(): void;
|
|
193
|
+
close(): void;
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* When selecting a range, the default focus is on the start input box, passing in `rangeEnd` can focus on the end input box
|
|
197
|
+
*
|
|
198
|
+
* When `insetInput` is `true`, due to trigger disabled, the cursor will focus on the input box of the popup layer panel
|
|
199
|
+
*
|
|
200
|
+
* 范围选择时,默认聚焦在开始输入框,传入 `rangeEnd` 可以聚焦在结束输入框
|
|
201
|
+
*
|
|
202
|
+
* `insetInput` 打开时,由于 trigger 禁用,会把焦点放在弹出面板的输入框上
|
|
203
|
+
*/
|
|
204
|
+
focus(focusType?: Exclude<RangeType, false>): void;
|
|
205
|
+
blur(): void;
|
|
178
206
|
setTriggerRef: (node: HTMLDivElement) => HTMLDivElement;
|
|
179
207
|
handleSelectedChange: MonthsGridProps['onChange'];
|
|
180
208
|
handleYMSelectedChange: YearAndMonthProps['onSelect'];
|
|
@@ -199,7 +227,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
199
227
|
handleInsetDateFocus: (e: React.FocusEvent, rangeType: 'rangeStart' | 'rangeEnd') => void;
|
|
200
228
|
handleInsetTimeFocus: () => void;
|
|
201
229
|
handlePanelVisibleChange: (visible: boolean) => void;
|
|
202
|
-
renderInner(
|
|
230
|
+
renderInner(): JSX.Element;
|
|
203
231
|
handleConfirm: (e: React.MouseEvent) => void;
|
|
204
232
|
handleCancel: (e: React.MouseEvent) => void;
|
|
205
233
|
renderFooter: (locale: Locale['DatePicker'], localeCode: string) => JSX.Element;
|
|
@@ -143,7 +143,8 @@ export default class DatePicker extends BaseComponent {
|
|
|
143
143
|
density,
|
|
144
144
|
topSlot,
|
|
145
145
|
bottomSlot,
|
|
146
|
-
presetPosition
|
|
146
|
+
presetPosition,
|
|
147
|
+
type
|
|
147
148
|
} = this.props;
|
|
148
149
|
const wrapCls = classnames(cssClasses.PREFIX, {
|
|
149
150
|
[cssClasses.PANEL_YAM]: this.adapter.typeIsYearOrMonth(),
|
|
@@ -152,11 +153,12 @@ export default class DatePicker extends BaseComponent {
|
|
|
152
153
|
return /*#__PURE__*/React.createElement("div", {
|
|
153
154
|
ref: this.panelRef,
|
|
154
155
|
className: wrapCls,
|
|
155
|
-
style: dropdownStyle
|
|
156
|
+
style: dropdownStyle,
|
|
157
|
+
"x-type": type
|
|
156
158
|
}, topSlot && /*#__PURE__*/React.createElement("div", {
|
|
157
159
|
className: `${cssClasses.PREFIX}-topSlot`,
|
|
158
160
|
"x-semi-prop": "topSlot"
|
|
159
|
-
}, topSlot), presetPosition === "top" && this.renderQuickControls(), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), presetPosition === "bottom" && this.renderQuickControls(), bottomSlot && /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
}, topSlot), presetPosition === "top" && type !== 'monthRange' && this.renderQuickControls(), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), presetPosition === "bottom" && type !== 'monthRange' && this.renderQuickControls(), bottomSlot && /*#__PURE__*/React.createElement("div", {
|
|
160
162
|
className: `${cssClasses.PREFIX}-bottomSlot`,
|
|
161
163
|
"x-semi-prop": "bottomSlot"
|
|
162
164
|
}, bottomSlot), this.renderFooter(locale, localeCode));
|
|
@@ -166,15 +168,31 @@ export default class DatePicker extends BaseComponent {
|
|
|
166
168
|
const {
|
|
167
169
|
density,
|
|
168
170
|
presetPosition,
|
|
169
|
-
yearAndMonthOpts
|
|
171
|
+
yearAndMonthOpts,
|
|
172
|
+
type
|
|
170
173
|
} = this.props;
|
|
171
174
|
const date = this.state.value[0];
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
const year = {
|
|
176
|
+
left: 0,
|
|
177
|
+
right: 0
|
|
178
|
+
};
|
|
179
|
+
const month = {
|
|
180
|
+
left: 0,
|
|
181
|
+
right: 0
|
|
182
|
+
};
|
|
174
183
|
|
|
175
184
|
if (_isDate(date)) {
|
|
176
|
-
year = date.getFullYear();
|
|
177
|
-
month = date.getMonth() + 1;
|
|
185
|
+
year.left = date.getFullYear();
|
|
186
|
+
month.left = date.getMonth() + 1;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (type === 'monthRange') {
|
|
190
|
+
const dateRight = this.state.value[1];
|
|
191
|
+
|
|
192
|
+
if (_isDate(dateRight)) {
|
|
193
|
+
year.right = dateRight.getFullYear();
|
|
194
|
+
month.right = dateRight.getMonth() + 1;
|
|
195
|
+
}
|
|
178
196
|
}
|
|
179
197
|
|
|
180
198
|
return /*#__PURE__*/React.createElement(YearAndMonth, {
|
|
@@ -190,6 +208,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
190
208
|
presetPosition: presetPosition,
|
|
191
209
|
renderQuickControls: this.renderQuickControls(),
|
|
192
210
|
renderDateInput: this.renderDateInput(),
|
|
211
|
+
type: type,
|
|
193
212
|
yearAndMonthOpts: yearAndMonthOpts
|
|
194
213
|
});
|
|
195
214
|
};
|
|
@@ -249,6 +268,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
249
268
|
this.triggerElRef = /*#__PURE__*/React.createRef();
|
|
250
269
|
this.panelRef = /*#__PURE__*/React.createRef();
|
|
251
270
|
this.monthGrid = /*#__PURE__*/React.createRef();
|
|
271
|
+
this.inputRef = /*#__PURE__*/React.createRef();
|
|
252
272
|
this.rangeInputStartRef = /*#__PURE__*/React.createRef();
|
|
253
273
|
this.rangeInputEndRef = /*#__PURE__*/React.createRef();
|
|
254
274
|
this.focusRecordsRef = /*#__PURE__*/React.createRef(); // @ts-ignore ignore readonly
|
|
@@ -264,10 +284,10 @@ export default class DatePicker extends BaseComponent {
|
|
|
264
284
|
var _this2 = this;
|
|
265
285
|
|
|
266
286
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
267
|
-
togglePanel: panelShow => {
|
|
287
|
+
togglePanel: (panelShow, cb) => {
|
|
268
288
|
this.setState({
|
|
269
289
|
panelShow
|
|
270
|
-
});
|
|
290
|
+
}, cb);
|
|
271
291
|
|
|
272
292
|
if (!panelShow) {
|
|
273
293
|
this.focusRecordsRef.current.rangeEnd = false;
|
|
@@ -281,17 +301,20 @@ export default class DatePicker extends BaseComponent {
|
|
|
281
301
|
}
|
|
282
302
|
|
|
283
303
|
this.clickOutSideHandler = e => {
|
|
284
|
-
if (this.adapter.needConfirm()) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
304
|
const triggerEl = this.triggerElRef && this.triggerElRef.current;
|
|
289
305
|
const panelEl = this.panelRef && this.panelRef.current;
|
|
290
306
|
const isInTrigger = triggerEl && triggerEl.contains(e.target);
|
|
291
307
|
const isInPanel = panelEl && panelEl.contains(e.target);
|
|
308
|
+
const clickOutSide = !isInTrigger && !isInPanel && this._mounted;
|
|
292
309
|
|
|
293
|
-
if (
|
|
294
|
-
this.
|
|
310
|
+
if (this.adapter.needConfirm()) {
|
|
311
|
+
clickOutSide && this.props.onClickOutSide();
|
|
312
|
+
return;
|
|
313
|
+
} else {
|
|
314
|
+
if (clickOutSide) {
|
|
315
|
+
this.props.onClickOutSide();
|
|
316
|
+
this.foundation.closePanel(e);
|
|
317
|
+
}
|
|
295
318
|
}
|
|
296
319
|
};
|
|
297
320
|
|
|
@@ -358,7 +381,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
358
381
|
}
|
|
359
382
|
},
|
|
360
383
|
needConfirm: () => ['dateTime', 'dateTimeRange'].includes(this.props.type) && this.props.needConfirm === true,
|
|
361
|
-
typeIsYearOrMonth: () => ['month', 'year'].includes(this.props.type),
|
|
384
|
+
typeIsYearOrMonth: () => ['month', 'year', 'monthRange'].includes(this.props.type),
|
|
362
385
|
setRangeInputFocus: rangeInputFocus => {
|
|
363
386
|
const {
|
|
364
387
|
preventScroll
|
|
@@ -460,6 +483,39 @@ export default class DatePicker extends BaseComponent {
|
|
|
460
483
|
break;
|
|
461
484
|
}
|
|
462
485
|
},
|
|
486
|
+
setInputFocus: () => {
|
|
487
|
+
const {
|
|
488
|
+
preventScroll
|
|
489
|
+
} = this.props;
|
|
490
|
+
|
|
491
|
+
const inputNode = _get(this, 'inputRef.current');
|
|
492
|
+
|
|
493
|
+
inputNode && inputNode.focus({
|
|
494
|
+
preventScroll
|
|
495
|
+
});
|
|
496
|
+
},
|
|
497
|
+
setInputBlur: () => {
|
|
498
|
+
const inputNode = _get(this, 'inputRef.current');
|
|
499
|
+
|
|
500
|
+
inputNode && inputNode.blur();
|
|
501
|
+
},
|
|
502
|
+
setRangeInputBlur: () => {
|
|
503
|
+
const {
|
|
504
|
+
rangeInputFocus
|
|
505
|
+
} = this.state;
|
|
506
|
+
|
|
507
|
+
if (rangeInputFocus === 'rangeStart') {
|
|
508
|
+
const inputStartNode = _get(this, 'rangeInputStartRef.current');
|
|
509
|
+
|
|
510
|
+
inputStartNode && inputStartNode.blur();
|
|
511
|
+
} else if (rangeInputFocus === 'rangeEnd') {
|
|
512
|
+
const inputEndNode = _get(this, 'rangeInputEndRef.current');
|
|
513
|
+
|
|
514
|
+
inputEndNode && inputEndNode.blur();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
this.adapter.setRangeInputFocus(false);
|
|
518
|
+
},
|
|
463
519
|
setTriggerDisabled: disabled => {
|
|
464
520
|
this.setState({
|
|
465
521
|
triggerDisabled: disabled
|
|
@@ -502,6 +558,33 @@ export default class DatePicker extends BaseComponent {
|
|
|
502
558
|
super.componentWillUnmount();
|
|
503
559
|
}
|
|
504
560
|
|
|
561
|
+
open() {
|
|
562
|
+
this.foundation.open();
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
close() {
|
|
566
|
+
this.foundation.close();
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
*
|
|
570
|
+
* When selecting a range, the default focus is on the start input box, passing in `rangeEnd` can focus on the end input box
|
|
571
|
+
*
|
|
572
|
+
* When `insetInput` is `true`, due to trigger disabled, the cursor will focus on the input box of the popup layer panel
|
|
573
|
+
*
|
|
574
|
+
* 范围选择时,默认聚焦在开始输入框,传入 `rangeEnd` 可以聚焦在结束输入框
|
|
575
|
+
*
|
|
576
|
+
* `insetInput` 打开时,由于 trigger 禁用,会把焦点放在弹出面板的输入框上
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
focus(focusType) {
|
|
581
|
+
this.foundation.focus(focusType);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
blur() {
|
|
585
|
+
this.foundation.blur();
|
|
586
|
+
}
|
|
587
|
+
|
|
505
588
|
renderMonthGrid(locale, localeCode, dateFnsLocale) {
|
|
506
589
|
const {
|
|
507
590
|
type,
|
|
@@ -623,7 +706,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
623
706
|
})) : null;
|
|
624
707
|
}
|
|
625
708
|
|
|
626
|
-
renderInner(
|
|
709
|
+
renderInner() {
|
|
627
710
|
const {
|
|
628
711
|
clearIcon,
|
|
629
712
|
type,
|
|
@@ -665,7 +748,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
665
748
|
const phText = placeholder || locale.placeholder[type]; // i18n
|
|
666
749
|
// These values should be passed to triggerRender, do not delete any key if it is not necessary
|
|
667
750
|
|
|
668
|
-
const props =
|
|
751
|
+
const props = {
|
|
669
752
|
placeholder: phText,
|
|
670
753
|
clearIcon,
|
|
671
754
|
disabled: inputDisabled,
|
|
@@ -699,8 +782,9 @@ export default class DatePicker extends BaseComponent {
|
|
|
699
782
|
onRangeClear: this.handleRangeInputClear,
|
|
700
783
|
onRangeEndTabPress: this.handleRangeEndTabPress,
|
|
701
784
|
rangeInputStartRef: insetInput ? null : this.rangeInputStartRef,
|
|
702
|
-
rangeInputEndRef: insetInput ? null : this.rangeInputEndRef
|
|
703
|
-
|
|
785
|
+
rangeInputEndRef: insetInput ? null : this.rangeInputEndRef,
|
|
786
|
+
inputRef: this.inputRef
|
|
787
|
+
};
|
|
704
788
|
return /*#__PURE__*/React.createElement("div", {
|
|
705
789
|
// tooltip will mount a11y props to children
|
|
706
790
|
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
@@ -815,7 +899,8 @@ DatePicker.propTypes = {
|
|
|
815
899
|
onPanelChange: PropTypes.func,
|
|
816
900
|
rangeSeparator: PropTypes.string,
|
|
817
901
|
preventScroll: PropTypes.bool,
|
|
818
|
-
yearAndMonthOpts: PropTypes.object
|
|
902
|
+
yearAndMonthOpts: PropTypes.object,
|
|
903
|
+
onClickOutSide: PropTypes.func
|
|
819
904
|
};
|
|
820
905
|
DatePicker.defaultProps = {
|
|
821
906
|
onChangeWithDateFirst: true,
|
|
@@ -852,5 +937,6 @@ DatePicker.defaultProps = {
|
|
|
852
937
|
autoSwitchDate: true,
|
|
853
938
|
syncSwitchMonth: false,
|
|
854
939
|
rangeSeparator: strings.DEFAULT_SEPARATOR_RANGE,
|
|
855
|
-
insetInput: false
|
|
940
|
+
insetInput: false,
|
|
941
|
+
onClickOutSide: _noop
|
|
856
942
|
};
|
|
@@ -8,5 +8,6 @@ export type { MonthsGridProps } from './monthsGrid';
|
|
|
8
8
|
export type { QuickControlProps } from './quickControl';
|
|
9
9
|
export type { YearAndMonthProps } from './yearAndMonth';
|
|
10
10
|
export type { InsetInputProps } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
11
|
+
export type { DatePicker as BaseDatePicker };
|
|
11
12
|
declare const _default: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<DatePicker>>;
|
|
12
13
|
export default _default;
|
|
@@ -19,7 +19,7 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
|
19
19
|
export declare type MonthsGridState = MonthsGridFoundationState;
|
|
20
20
|
export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
|
|
21
21
|
static propTypes: {
|
|
22
|
-
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
22
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "monthRange" | "dateTimeRange">;
|
|
23
23
|
defaultValue: PropTypes.Requireable<any[]>;
|
|
24
24
|
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
25
25
|
multiple: PropTypes.Requireable<boolean>;
|
|
@@ -482,9 +482,17 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
482
482
|
ref: current => this.cacheRefCurrent(`yam-${panelType}`, current),
|
|
483
483
|
locale: locale,
|
|
484
484
|
localeCode: localeCode,
|
|
485
|
-
currentYear
|
|
486
|
-
currentMonth
|
|
487
|
-
|
|
485
|
+
// currentYear={y}
|
|
486
|
+
// currentMonth={m}
|
|
487
|
+
currentYear: {
|
|
488
|
+
left: y,
|
|
489
|
+
right: 0
|
|
490
|
+
},
|
|
491
|
+
currentMonth: {
|
|
492
|
+
left: m,
|
|
493
|
+
right: 0
|
|
494
|
+
},
|
|
495
|
+
onSelect: item => this.foundation.toYearMonth(panelType, new Date(item.currentYear.left, item.currentMonth.left - 1)),
|
|
488
496
|
onBackToMain: () => {
|
|
489
497
|
this.foundation.showDatePanel(panelType);
|
|
490
498
|
const wrapCurrent = this.adapter.getCache(`wrap-${panelType}`);
|
|
@@ -4,14 +4,15 @@ import YearAndMonthFoundation, { MonthScrollItem, YearAndMonthAdapter, YearAndMo
|
|
|
4
4
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
5
5
|
import ScrollItem from '../scrollList/scrollItem';
|
|
6
6
|
import { Locale } from '../locale/interface';
|
|
7
|
+
import { PanelType } from '@douyinfe/semi-foundation/lib/es/datePicker/monthsGridFoundation';
|
|
7
8
|
export interface YearAndMonthProps extends YearAndMonthFoundationProps, BaseProps {
|
|
8
9
|
locale?: Locale['DatePicker'];
|
|
9
10
|
}
|
|
10
11
|
export declare type YearAndMonthState = YearAndMonthFoundationState;
|
|
11
12
|
declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonthState> {
|
|
12
13
|
static propTypes: {
|
|
13
|
-
currentYear: PropTypes.Requireable<
|
|
14
|
-
currentMonth: PropTypes.Requireable<
|
|
14
|
+
currentYear: PropTypes.Requireable<object>;
|
|
15
|
+
currentMonth: PropTypes.Requireable<object>;
|
|
15
16
|
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
17
|
locale: PropTypes.Requireable<object>;
|
|
17
18
|
localeCode: PropTypes.Requireable<string>;
|
|
@@ -23,6 +24,7 @@ declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonth
|
|
|
23
24
|
presetPosition: PropTypes.Requireable<"left" | "top" | "right" | "bottom">;
|
|
24
25
|
renderQuickControls: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
25
26
|
renderDateInput: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
27
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "monthRange" | "dateTimeRange">;
|
|
26
28
|
};
|
|
27
29
|
static defaultProps: {
|
|
28
30
|
disabledDate: {
|
|
@@ -33,6 +35,7 @@ declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonth
|
|
|
33
35
|
yearCycled: boolean;
|
|
34
36
|
noBackBtn: boolean;
|
|
35
37
|
onSelect: (...args: any[]) => void;
|
|
38
|
+
type: string;
|
|
36
39
|
};
|
|
37
40
|
foundation: YearAndMonthFoundation;
|
|
38
41
|
yearRef: React.RefObject<ScrollItem<YearScrollItem>>;
|
|
@@ -40,12 +43,13 @@ declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonth
|
|
|
40
43
|
constructor(props: YearAndMonthProps);
|
|
41
44
|
get adapter(): YearAndMonthAdapter;
|
|
42
45
|
static getDerivedStateFromProps(props: YearAndMonthProps, state: YearAndMonthState): Partial<YearAndMonthFoundationState>;
|
|
43
|
-
renderColYear(): JSX.Element;
|
|
44
|
-
selectYear: (item: YearScrollItem) => void;
|
|
45
|
-
selectMonth: (item: MonthScrollItem) => void;
|
|
46
|
+
renderColYear(panelType: PanelType): JSX.Element;
|
|
47
|
+
selectYear: (item: YearScrollItem, panelType?: PanelType) => void;
|
|
48
|
+
selectMonth: (item: MonthScrollItem, panelType?: PanelType) => void;
|
|
46
49
|
reselect: () => void;
|
|
47
|
-
renderColMonth(): JSX.Element;
|
|
50
|
+
renderColMonth(panelType: PanelType): JSX.Element;
|
|
48
51
|
backToMain: React.MouseEventHandler<HTMLButtonElement>;
|
|
52
|
+
renderPanel(panelType: PanelType): JSX.Element;
|
|
49
53
|
render(): JSX.Element;
|
|
50
54
|
}
|
|
51
55
|
export default YearAndMonth;
|