@douyinfe/semi-ui 2.5.1 → 2.7.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/button/__test__/button.test.js +7 -0
- package/button/buttonGroup.tsx +5 -2
- package/calendar/monthCalendar.tsx +14 -13
- package/cascader/__test__/cascader.test.js +159 -81
- package/cascader/_story/cascader.stories.js +36 -23
- package/cascader/index.tsx +47 -8
- package/cascader/item.tsx +25 -5
- package/datePicker/_story/v2/InsetInput.jsx +104 -0
- package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
- package/datePicker/_story/v2/index.js +2 -0
- package/datePicker/dateInput.tsx +102 -13
- package/datePicker/datePicker.tsx +95 -16
- package/datePicker/index.tsx +15 -0
- package/datePicker/insetInput.tsx +76 -0
- package/datePicker/month.tsx +14 -7
- package/datePicker/monthsGrid.tsx +31 -12
- package/datePicker/navigation.tsx +8 -4
- package/datePicker/quickControl.tsx +1 -0
- package/datePicker/yearAndMonth.tsx +1 -1
- package/dist/css/semi.css +120 -8
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1100 -193
- 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/hoc/withField.tsx +1 -1
- package/input/_story/input.stories.js +13 -0
- package/lib/cjs/_base/base.css +5 -5
- package/lib/cjs/button/buttonGroup.d.ts +1 -0
- package/lib/cjs/button/buttonGroup.js +6 -2
- package/lib/cjs/calendar/monthCalendar.js +21 -5
- package/lib/cjs/cascader/index.d.ts +10 -2
- package/lib/cjs/cascader/index.js +52 -10
- package/lib/cjs/cascader/item.d.ts +6 -2
- package/lib/cjs/cascader/item.js +33 -4
- package/lib/cjs/datePicker/dateInput.d.ts +9 -4
- package/lib/cjs/datePicker/dateInput.js +107 -13
- package/lib/cjs/datePicker/datePicker.d.ts +7 -2
- package/lib/cjs/datePicker/datePicker.js +138 -30
- package/lib/cjs/datePicker/index.js +24 -2
- package/lib/cjs/datePicker/insetInput.d.ts +21 -0
- package/lib/cjs/datePicker/insetInput.js +80 -0
- package/lib/cjs/datePicker/month.d.ts +1 -0
- package/lib/cjs/datePicker/month.js +18 -2
- package/lib/cjs/datePicker/monthsGrid.js +35 -11
- package/lib/cjs/datePicker/navigation.js +8 -0
- package/lib/cjs/datePicker/quickControl.js +1 -0
- package/lib/cjs/datePicker/yearAndMonth.js +1 -0
- package/lib/cjs/form/hoc/withField.js +1 -1
- package/lib/cjs/navigation/Item.d.ts +2 -2
- package/lib/cjs/navigation/Item.js +8 -6
- package/lib/cjs/navigation/SubNav.js +2 -2
- package/lib/cjs/scrollList/scrollItem.d.ts +2 -1
- package/lib/cjs/scrollList/scrollItem.js +13 -3
- package/lib/cjs/table/Body/index.d.ts +2 -0
- package/lib/cjs/table/Body/index.js +13 -4
- package/lib/cjs/tree/index.js +5 -3
- package/lib/cjs/tree/interface.d.ts +1 -0
- package/lib/cjs/tree/nodeList.js +2 -1
- package/lib/cjs/treeSelect/index.js +7 -3
- package/lib/es/_base/base.css +5 -5
- package/lib/es/button/buttonGroup.d.ts +1 -0
- package/lib/es/button/buttonGroup.js +5 -2
- package/lib/es/calendar/monthCalendar.js +22 -5
- package/lib/es/cascader/index.d.ts +10 -2
- package/lib/es/cascader/index.js +49 -7
- package/lib/es/cascader/item.d.ts +6 -2
- package/lib/es/cascader/item.js +31 -4
- package/lib/es/datePicker/dateInput.d.ts +9 -4
- package/lib/es/datePicker/dateInput.js +106 -13
- package/lib/es/datePicker/datePicker.d.ts +7 -2
- package/lib/es/datePicker/datePicker.js +139 -30
- package/lib/es/datePicker/index.js +20 -0
- package/lib/es/datePicker/insetInput.d.ts +21 -0
- package/lib/es/datePicker/insetInput.js +65 -0
- package/lib/es/datePicker/month.d.ts +1 -0
- package/lib/es/datePicker/month.js +18 -2
- package/lib/es/datePicker/monthsGrid.js +35 -11
- package/lib/es/datePicker/navigation.js +8 -0
- package/lib/es/datePicker/quickControl.js +2 -0
- package/lib/es/datePicker/yearAndMonth.js +1 -0
- package/lib/es/form/hoc/withField.js +1 -1
- package/lib/es/navigation/Item.d.ts +2 -2
- package/lib/es/navigation/Item.js +8 -6
- package/lib/es/navigation/SubNav.js +2 -2
- package/lib/es/scrollList/scrollItem.d.ts +2 -1
- package/lib/es/scrollList/scrollItem.js +13 -3
- package/lib/es/table/Body/index.d.ts +2 -0
- package/lib/es/table/Body/index.js +13 -4
- package/lib/es/tree/index.js +5 -3
- package/lib/es/tree/interface.d.ts +1 -0
- package/lib/es/tree/nodeList.js +2 -1
- package/lib/es/treeSelect/index.js +7 -3
- package/navigation/Item.tsx +15 -12
- package/navigation/SubNav.tsx +4 -4
- package/package.json +9 -9
- package/scrollList/_story/ScrollList/index.js +3 -0
- package/scrollList/_story/WheelList/index.js +3 -0
- package/scrollList/scrollItem.tsx +30 -9
- package/table/Body/index.tsx +15 -4
- package/table/__test__/table.test.js +18 -0
- package/table/_story/v2/FixedExpandedRow/index.jsx +95 -0
- package/table/_story/v2/index.js +2 -1
- package/tree/__test__/tree.test.js +87 -2
- package/tree/_story/tree.stories.js +65 -5
- package/tree/index.tsx +4 -2
- package/tree/interface.ts +1 -0
- package/tree/nodeList.tsx +2 -2
- package/treeSelect/__test__/treeSelect.test.js +28 -0
- package/treeSelect/_story/treeSelect.stories.js +55 -2
- package/treeSelect/index.tsx +11 -3
|
@@ -36,11 +36,13 @@ var _function = require("@douyinfe/semi-foundation/lib/cjs/utils/function");
|
|
|
36
36
|
|
|
37
37
|
var _isNullOrUndefined = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/isNullOrUndefined"));
|
|
38
38
|
|
|
39
|
+
var _semiIcons = require("@douyinfe/semi-icons");
|
|
40
|
+
|
|
39
41
|
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
40
42
|
|
|
41
43
|
var _index = _interopRequireDefault(require("../input/index"));
|
|
42
44
|
|
|
43
|
-
var
|
|
45
|
+
var _insetInput = require("./insetInput");
|
|
44
46
|
|
|
45
47
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
46
48
|
var t = {};
|
|
@@ -52,6 +54,10 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
52
54
|
}
|
|
53
55
|
return t;
|
|
54
56
|
};
|
|
57
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
58
|
+
|
|
59
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
60
|
+
|
|
55
61
|
/* eslint-disable max-lines-per-function */
|
|
56
62
|
|
|
57
63
|
/* eslint-disable no-unused-vars */
|
|
@@ -94,6 +100,10 @@ class DateInput extends _baseComponent.default {
|
|
|
94
100
|
this.handleRangeInputFocus(e, 'rangeStart');
|
|
95
101
|
};
|
|
96
102
|
|
|
103
|
+
this.handleInsetInputChange = options => {
|
|
104
|
+
this.foundation.handleInsetInputChange(options);
|
|
105
|
+
};
|
|
106
|
+
|
|
97
107
|
this.getRangeInputValue = (rangeStart, rangeEnd) => {
|
|
98
108
|
var _context, _context2;
|
|
99
109
|
|
|
@@ -140,7 +150,8 @@ class DateInput extends _baseComponent.default {
|
|
|
140
150
|
},
|
|
141
151
|
notifyTabPress: function () {
|
|
142
152
|
return _this.props.onRangeEndTabPress(...arguments);
|
|
143
|
-
}
|
|
153
|
+
},
|
|
154
|
+
notifyInsetInputChange: options => this.props.onInsetInputChange(options)
|
|
144
155
|
});
|
|
145
156
|
}
|
|
146
157
|
|
|
@@ -195,9 +206,14 @@ class DateInput extends _baseComponent.default {
|
|
|
195
206
|
} = this.props;
|
|
196
207
|
const allowClear = (rangeStart || rangeEnd) && showClear;
|
|
197
208
|
return allowClear && !disabled ? /*#__PURE__*/_react.default.createElement("div", {
|
|
209
|
+
role: "button",
|
|
210
|
+
tabIndex: 0,
|
|
211
|
+
"aria-label": "Clear range input value",
|
|
198
212
|
className: "".concat(prefixCls, "-range-input-clearbtn"),
|
|
199
213
|
onMouseDown: e => !disabled && this.handleRangeInputClear(e)
|
|
200
|
-
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClear,
|
|
214
|
+
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClear, {
|
|
215
|
+
"aria-hidden": true
|
|
216
|
+
})) : null;
|
|
201
217
|
}
|
|
202
218
|
|
|
203
219
|
renderRangeSuffix(suffix) {
|
|
@@ -240,11 +256,11 @@ class DateInput extends _baseComponent.default {
|
|
|
240
256
|
const rangePlaceholder = (0, _isArray.default)(placeholder) ? placeholder : [placeholder, placeholder];
|
|
241
257
|
const [rangeStartPlaceholder, rangeEndPlaceholder] = rangePlaceholder;
|
|
242
258
|
const inputLeftWrapperCls = (0, _classnames.default)("".concat(prefixCls, "-range-input-wrapper-start"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
243
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart',
|
|
259
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart' && !disabled,
|
|
244
260
|
["".concat(prefixCls, "-range-input-wrapper-start-with-prefix")]: this.props.prefix || this.props.insetLabel
|
|
245
261
|
});
|
|
246
262
|
const inputRightWrapperCls = (0, _classnames.default)("".concat(prefixCls, "-range-input-wrapper-end"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
247
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd'
|
|
263
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd' && !disabled
|
|
248
264
|
});
|
|
249
265
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderRangePrefix(), /*#__PURE__*/_react.default.createElement("div", {
|
|
250
266
|
onClick: e => !disabled && this.handleRangeInputFocus(e, 'rangeStart'),
|
|
@@ -283,7 +299,70 @@ class DateInput extends _baseComponent.default {
|
|
|
283
299
|
})), this.renderRangeClearBtn(rangeStart, rangeEnd), this.renderRangeSuffix(suffix));
|
|
284
300
|
}
|
|
285
301
|
|
|
286
|
-
|
|
302
|
+
renderInputInset() {
|
|
303
|
+
const {
|
|
304
|
+
type,
|
|
305
|
+
handleInsetDateFocus,
|
|
306
|
+
handleInsetTimeFocus,
|
|
307
|
+
value,
|
|
308
|
+
insetInputValue,
|
|
309
|
+
prefixCls,
|
|
310
|
+
rangeInputStartRef,
|
|
311
|
+
rangeInputEndRef,
|
|
312
|
+
density
|
|
313
|
+
} = this.props;
|
|
314
|
+
|
|
315
|
+
const _isRangeType = (0, _includes.default)(type).call(type, 'Range');
|
|
316
|
+
|
|
317
|
+
const newInsetInputValue = this.foundation.getInsetInputValue({
|
|
318
|
+
value,
|
|
319
|
+
insetInputValue
|
|
320
|
+
});
|
|
321
|
+
const {
|
|
322
|
+
datePlaceholder,
|
|
323
|
+
timePlaceholder
|
|
324
|
+
} = this.foundation.getInsetInputPlaceholder();
|
|
325
|
+
const insetInputWrapperCls = "".concat(prefixCls, "-inset-input-wrapper");
|
|
326
|
+
const separatorCls = "".concat(prefixCls, "-inset-input-separator");
|
|
327
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
328
|
+
className: insetInputWrapperCls,
|
|
329
|
+
"x-type": type
|
|
330
|
+
}, /*#__PURE__*/_react.default.createElement(_insetInput.InsetDateInput, {
|
|
331
|
+
forwardRef: rangeInputStartRef,
|
|
332
|
+
insetInputValue: newInsetInputValue,
|
|
333
|
+
placeholder: datePlaceholder,
|
|
334
|
+
valuePath: 'monthLeft.dateInput',
|
|
335
|
+
onChange: this.handleInsetInputChange,
|
|
336
|
+
onFocus: e => handleInsetDateFocus(e, 'rangeStart')
|
|
337
|
+
}), /*#__PURE__*/_react.default.createElement(_insetInput.InsetTimeInput, {
|
|
338
|
+
disabled: !newInsetInputValue.monthLeft.dateInput,
|
|
339
|
+
insetInputValue: newInsetInputValue,
|
|
340
|
+
placeholder: timePlaceholder,
|
|
341
|
+
type: type,
|
|
342
|
+
valuePath: 'monthLeft.timeInput',
|
|
343
|
+
onChange: this.handleInsetInputChange,
|
|
344
|
+
onFocus: handleInsetTimeFocus
|
|
345
|
+
}), _isRangeType && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
346
|
+
className: separatorCls
|
|
347
|
+
}, density === 'compact' ? null : '-'), /*#__PURE__*/_react.default.createElement(_insetInput.InsetDateInput, {
|
|
348
|
+
forwardRef: rangeInputEndRef,
|
|
349
|
+
insetInputValue: newInsetInputValue,
|
|
350
|
+
placeholder: datePlaceholder,
|
|
351
|
+
valuePath: 'monthRight.dateInput',
|
|
352
|
+
onChange: this.handleInsetInputChange,
|
|
353
|
+
onFocus: e => handleInsetDateFocus(e, 'rangeEnd')
|
|
354
|
+
}), /*#__PURE__*/_react.default.createElement(_insetInput.InsetTimeInput, {
|
|
355
|
+
disabled: !newInsetInputValue.monthRight.dateInput,
|
|
356
|
+
insetInputValue: newInsetInputValue,
|
|
357
|
+
placeholder: timePlaceholder,
|
|
358
|
+
type: type,
|
|
359
|
+
valuePath: 'monthRight.timeInput',
|
|
360
|
+
onChange: this.handleInsetInputChange,
|
|
361
|
+
onFocus: handleInsetTimeFocus
|
|
362
|
+
})));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
renderTriggerInput() {
|
|
287
366
|
const _a = this.props,
|
|
288
367
|
{
|
|
289
368
|
placeholder,
|
|
@@ -298,6 +377,8 @@ class DateInput extends _baseComponent.default {
|
|
|
298
377
|
validateStatus,
|
|
299
378
|
block,
|
|
300
379
|
prefixCls,
|
|
380
|
+
multiple,
|
|
381
|
+
// Whether to allow multiple values for email and file types
|
|
301
382
|
dateFnsLocale,
|
|
302
383
|
// No need to pass to input
|
|
303
384
|
onBlur,
|
|
@@ -313,13 +394,19 @@ class DateInput extends _baseComponent.default {
|
|
|
313
394
|
onRangeBlur,
|
|
314
395
|
onRangeEndTabPress,
|
|
315
396
|
rangeInputFocus,
|
|
316
|
-
rangeSeparator
|
|
397
|
+
rangeSeparator,
|
|
398
|
+
insetInput,
|
|
399
|
+
insetInputValue
|
|
317
400
|
} = _a,
|
|
318
|
-
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator"]);
|
|
401
|
+
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "multiple", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator", "insetInput", "insetInputValue"]);
|
|
319
402
|
|
|
320
|
-
const dateIcon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar,
|
|
403
|
+
const dateIcon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar, {
|
|
404
|
+
"aria-hidden": true
|
|
405
|
+
});
|
|
321
406
|
|
|
322
|
-
const dateTimeIcon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendarClock,
|
|
407
|
+
const dateTimeIcon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendarClock, {
|
|
408
|
+
"aria-hidden": true
|
|
409
|
+
});
|
|
323
410
|
|
|
324
411
|
const suffix = (0, _includes.default)(type).call(type, 'Time') ? dateTimeIcon : dateIcon;
|
|
325
412
|
let text = '';
|
|
@@ -362,6 +449,13 @@ class DateInput extends _baseComponent.default {
|
|
|
362
449
|
}));
|
|
363
450
|
}
|
|
364
451
|
|
|
452
|
+
render() {
|
|
453
|
+
const {
|
|
454
|
+
insetInput
|
|
455
|
+
} = this.props;
|
|
456
|
+
return insetInput ? this.renderInputInset() : this.renderTriggerInput();
|
|
457
|
+
}
|
|
458
|
+
|
|
365
459
|
}
|
|
366
460
|
|
|
367
461
|
exports.default = DateInput;
|
|
@@ -375,7 +469,6 @@ DateInput.propTypes = {
|
|
|
375
469
|
value: _propTypes.default.array,
|
|
376
470
|
disabled: _propTypes.default.bool,
|
|
377
471
|
type: _propTypes.default.oneOf(_constants.strings.TYPE_SET),
|
|
378
|
-
multiple: _propTypes.default.bool,
|
|
379
472
|
showClear: _propTypes.default.bool,
|
|
380
473
|
format: _propTypes.default.string,
|
|
381
474
|
inputStyle: _propTypes.default.object,
|
|
@@ -389,7 +482,9 @@ DateInput.propTypes = {
|
|
|
389
482
|
rangeInputFocus: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
390
483
|
rangeInputStartRef: _propTypes.default.object,
|
|
391
484
|
rangeInputEndRef: _propTypes.default.object,
|
|
392
|
-
rangeSeparator: _propTypes.default.string
|
|
485
|
+
rangeSeparator: _propTypes.default.string,
|
|
486
|
+
insetInput: _propTypes.default.bool,
|
|
487
|
+
insetInputValue: _propTypes.default.object
|
|
393
488
|
};
|
|
394
489
|
DateInput.defaultProps = {
|
|
395
490
|
showClear: true,
|
|
@@ -399,7 +494,6 @@ DateInput.defaultProps = {
|
|
|
399
494
|
onBlur: _function.noop,
|
|
400
495
|
onClear: _function.noop,
|
|
401
496
|
onFocus: _function.noop,
|
|
402
|
-
multiple: false,
|
|
403
497
|
type: 'date',
|
|
404
498
|
inputStyle: {},
|
|
405
499
|
inputReadOnly: false,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import DatePickerFoundation, { DatePickerAdapter, DatePickerFoundationProps, DatePickerFoundationState, DayStatusType, PresetType, Type } from '@douyinfe/semi-foundation/lib/cjs/datePicker/foundation';
|
|
3
|
+
import DatePickerFoundation, { DatePickerAdapter, DatePickerFoundationProps, DatePickerFoundationState, DayStatusType, PresetType, Type, RangeType } from '@douyinfe/semi-foundation/lib/cjs/datePicker/foundation';
|
|
4
4
|
import BaseComponent from '../_base/baseComponent';
|
|
5
5
|
import { DateInputProps } from './dateInput';
|
|
6
6
|
import MonthsGrid, { MonthsGridProps } from './monthsGrid';
|
|
7
7
|
import { YearAndMonthProps } from './yearAndMonth';
|
|
8
8
|
import '@douyinfe/semi-foundation/lib/cjs/datePicker/datePicker.css';
|
|
9
9
|
import { Locale } from '../locale/interface';
|
|
10
|
-
import { RangeType } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
|
|
11
10
|
import { TimePickerProps } from '../timePicker/TimePicker';
|
|
11
|
+
import { InsetInputChangeProps } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
|
|
12
12
|
export interface DatePickerProps extends DatePickerFoundationProps {
|
|
13
13
|
'aria-describedby'?: React.AriaAttributes['aria-describedby'];
|
|
14
14
|
'aria-errormessage'?: React.AriaAttributes['aria-errormessage'];
|
|
@@ -143,6 +143,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
143
143
|
autoSwitchDate: boolean;
|
|
144
144
|
syncSwitchMonth: boolean;
|
|
145
145
|
rangeSeparator: " ~ ";
|
|
146
|
+
insetInput: boolean;
|
|
146
147
|
};
|
|
147
148
|
triggerElRef: React.MutableRefObject<HTMLElement>;
|
|
148
149
|
panelRef: React.RefObject<HTMLDivElement>;
|
|
@@ -171,6 +172,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
171
172
|
renderQuickControls(): JSX.Element;
|
|
172
173
|
handleOpenPanel: () => void;
|
|
173
174
|
handleInputChange: DatePickerFoundation['handleInputChange'];
|
|
175
|
+
handleInsetInputChange: (options: InsetInputChangeProps) => void;
|
|
174
176
|
handleInputComplete: DatePickerFoundation['handleInputComplete'];
|
|
175
177
|
handleInputBlur: DateInputProps['onBlur'];
|
|
176
178
|
handleInputFocus: DatePickerFoundation['handleInputFocus'];
|
|
@@ -181,6 +183,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
181
183
|
handleRangeInputClear: DatePickerFoundation['handleRangeInputClear'];
|
|
182
184
|
handleRangeEndTabPress: DatePickerFoundation['handleRangeEndTabPress'];
|
|
183
185
|
isAnotherPanelHasOpened: (currentRangeInput: RangeType) => boolean;
|
|
186
|
+
handleInsetDateFocus: (e: React.FocusEvent, rangeType: 'rangeStart' | 'rangeEnd') => void;
|
|
187
|
+
handleInsetTimeFocus: () => void;
|
|
188
|
+
handlePanelVisibleChange: (visible: boolean) => void;
|
|
184
189
|
renderInner(extraProps?: Partial<DatePickerProps>): JSX.Element;
|
|
185
190
|
handleConfirm: (e: React.MouseEvent) => void;
|
|
186
191
|
handleCancel: (e: React.MouseEvent) => void;
|
|
@@ -20,6 +20,8 @@ var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-j
|
|
|
20
20
|
|
|
21
21
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
22
22
|
|
|
23
|
+
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
24
|
+
|
|
23
25
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
24
26
|
|
|
25
27
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
@@ -62,7 +64,13 @@ var _yearAndMonth = _interopRequireDefault(require("./yearAndMonth"));
|
|
|
62
64
|
|
|
63
65
|
require("@douyinfe/semi-foundation/lib/cjs/datePicker/datePicker.css");
|
|
64
66
|
|
|
67
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus */
|
|
68
|
+
|
|
65
69
|
/* eslint-disable max-len */
|
|
70
|
+
|
|
71
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
72
|
+
|
|
73
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
66
74
|
class DatePicker extends _baseComponent.default {
|
|
67
75
|
constructor(props) {
|
|
68
76
|
var _this;
|
|
@@ -100,6 +108,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
100
108
|
return _this.foundation.handleInputChange(...arguments);
|
|
101
109
|
};
|
|
102
110
|
|
|
111
|
+
this.handleInsetInputChange = options => this.foundation.handleInsetInputChange(options);
|
|
112
|
+
|
|
103
113
|
this.handleInputComplete = v => this.foundation.handleInputComplete(v);
|
|
104
114
|
|
|
105
115
|
this.handleInputBlur = e => this.foundation.handleInputBlur((0, _get2.default)(e, 'nativeEvent.target.value'), e);
|
|
@@ -128,6 +138,30 @@ class DatePicker extends _baseComponent.default {
|
|
|
128
138
|
}
|
|
129
139
|
};
|
|
130
140
|
|
|
141
|
+
this.handleInsetDateFocus = (e, rangeType) => {
|
|
142
|
+
const monthGridFoundation = (0, _get2.default)(this, 'monthGrid.current.foundation');
|
|
143
|
+
|
|
144
|
+
if (monthGridFoundation) {
|
|
145
|
+
monthGridFoundation.showDatePanel(_constants.strings.PANEL_TYPE_LEFT);
|
|
146
|
+
monthGridFoundation.showDatePanel(_constants.strings.PANEL_TYPE_RIGHT);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.handleInputFocus(e, rangeType);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
this.handleInsetTimeFocus = () => {
|
|
153
|
+
const monthGridFoundation = (0, _get2.default)(this, 'monthGrid.current.foundation');
|
|
154
|
+
|
|
155
|
+
if (monthGridFoundation) {
|
|
156
|
+
monthGridFoundation.showTimePicker(_constants.strings.PANEL_TYPE_LEFT);
|
|
157
|
+
monthGridFoundation.showTimePicker(_constants.strings.PANEL_TYPE_RIGHT);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
this.handlePanelVisibleChange = visible => {
|
|
162
|
+
this.foundation.handlePanelVisibleChange(visible);
|
|
163
|
+
};
|
|
164
|
+
|
|
131
165
|
this.handleConfirm = e => this.foundation.handleConfirm();
|
|
132
166
|
|
|
133
167
|
this.handleCancel = e => this.foundation.handleCancel();
|
|
@@ -151,19 +185,43 @@ class DatePicker extends _baseComponent.default {
|
|
|
151
185
|
dropdownStyle,
|
|
152
186
|
density,
|
|
153
187
|
topSlot,
|
|
154
|
-
bottomSlot
|
|
188
|
+
bottomSlot,
|
|
189
|
+
insetInput,
|
|
190
|
+
type,
|
|
191
|
+
format,
|
|
192
|
+
rangeSeparator
|
|
155
193
|
} = this.props;
|
|
194
|
+
const {
|
|
195
|
+
insetInputValue,
|
|
196
|
+
value
|
|
197
|
+
} = this.state;
|
|
156
198
|
const wrapCls = (0, _classnames.default)(_constants.cssClasses.PREFIX, {
|
|
157
199
|
[_constants.cssClasses.PANEL_YAM]: this.adapter.typeIsYearOrMonth(),
|
|
158
200
|
["".concat(_constants.cssClasses.PREFIX, "-compact")]: density === 'compact'
|
|
159
201
|
}, dropdownClassName);
|
|
202
|
+
const insetInputProps = {
|
|
203
|
+
dateFnsLocale,
|
|
204
|
+
format,
|
|
205
|
+
insetInputValue,
|
|
206
|
+
rangeSeparator,
|
|
207
|
+
type,
|
|
208
|
+
value: value,
|
|
209
|
+
handleInsetDateFocus: this.handleInsetDateFocus,
|
|
210
|
+
handleInsetTimeFocus: this.handleInsetTimeFocus,
|
|
211
|
+
onInsetInputChange: this.handleInsetInputChange,
|
|
212
|
+
rangeInputStartRef: this.rangeInputStartRef,
|
|
213
|
+
rangeInputEndRef: this.rangeInputEndRef,
|
|
214
|
+
density
|
|
215
|
+
};
|
|
160
216
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
161
217
|
ref: this.panelRef,
|
|
162
218
|
className: wrapCls,
|
|
163
219
|
style: dropdownStyle
|
|
164
220
|
}, topSlot && /*#__PURE__*/_react.default.createElement("div", {
|
|
165
221
|
className: "".concat(_constants.cssClasses.PREFIX, "-topSlot")
|
|
166
|
-
}, topSlot),
|
|
222
|
+
}, topSlot), insetInput && /*#__PURE__*/_react.default.createElement(_dateInput.default, (0, _assign.default)({}, insetInputProps, {
|
|
223
|
+
insetInput: true
|
|
224
|
+
})), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/_react.default.createElement("div", {
|
|
167
225
|
className: "".concat(_constants.cssClasses.PREFIX, "-bottomSlot")
|
|
168
226
|
}, bottomSlot), this.renderFooter(locale, localeCode));
|
|
169
227
|
};
|
|
@@ -227,7 +285,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
227
285
|
position: position,
|
|
228
286
|
visible: panelShow,
|
|
229
287
|
stopPropagation: stopPropagation,
|
|
230
|
-
spacing: spacing
|
|
288
|
+
spacing: spacing,
|
|
289
|
+
onVisibleChange: this.handlePanelVisibleChange
|
|
231
290
|
}, children);
|
|
232
291
|
};
|
|
233
292
|
|
|
@@ -240,7 +299,9 @@ class DatePicker extends _baseComponent.default {
|
|
|
240
299
|
prevTimeZone: null,
|
|
241
300
|
motionEnd: false,
|
|
242
301
|
rangeInputFocus: undefined,
|
|
243
|
-
autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen)
|
|
302
|
+
autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen),
|
|
303
|
+
insetInputValue: null,
|
|
304
|
+
triggerDisabled: undefined
|
|
244
305
|
};
|
|
245
306
|
this.adapter.setCache('cachedSelectedValue', null);
|
|
246
307
|
this.triggerElRef = /*#__PURE__*/_react.default.createRef();
|
|
@@ -343,6 +404,17 @@ class DatePicker extends _baseComponent.default {
|
|
|
343
404
|
inputValue
|
|
344
405
|
});
|
|
345
406
|
},
|
|
407
|
+
updateInsetInputValue: insetInputValue => {
|
|
408
|
+
const {
|
|
409
|
+
insetInput
|
|
410
|
+
} = this.props;
|
|
411
|
+
|
|
412
|
+
if (insetInput && !(0, _isEqual2.default)(insetInputValue, this.state.insetInputValue)) {
|
|
413
|
+
this.setState({
|
|
414
|
+
insetInputValue
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
},
|
|
346
418
|
needConfirm: () => {
|
|
347
419
|
var _context;
|
|
348
420
|
|
|
@@ -413,7 +485,36 @@ class DatePicker extends _baseComponent.default {
|
|
|
413
485
|
}
|
|
414
486
|
},
|
|
415
487
|
couldPanelClosed: () => this.focusRecordsRef.current.rangeStart && this.focusRecordsRef.current.rangeEnd,
|
|
416
|
-
isEventTarget: e => e && e.target === e.currentTarget
|
|
488
|
+
isEventTarget: e => e && e.target === e.currentTarget,
|
|
489
|
+
setInsetInputFocus: () => {
|
|
490
|
+
const {
|
|
491
|
+
rangeInputFocus
|
|
492
|
+
} = this.state;
|
|
493
|
+
|
|
494
|
+
switch (rangeInputFocus) {
|
|
495
|
+
case 'rangeEnd':
|
|
496
|
+
if (document.activeElement !== this.rangeInputEndRef.current) {
|
|
497
|
+
const inputEndNode = (0, _get2.default)(this, 'rangeInputEndRef.current');
|
|
498
|
+
inputEndNode && inputEndNode.focus();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
break;
|
|
502
|
+
|
|
503
|
+
case 'rangeStart':
|
|
504
|
+
default:
|
|
505
|
+
if (document.activeElement !== this.rangeInputStartRef.current) {
|
|
506
|
+
const inputStartNode = (0, _get2.default)(this, 'rangeInputStartRef.current');
|
|
507
|
+
inputStartNode && inputStartNode.focus();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
setTriggerDisabled: disabled => {
|
|
514
|
+
this.setState({
|
|
515
|
+
triggerDisabled: disabled
|
|
516
|
+
});
|
|
517
|
+
}
|
|
417
518
|
});
|
|
418
519
|
}
|
|
419
520
|
|
|
@@ -471,7 +572,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
471
572
|
syncSwitchMonth,
|
|
472
573
|
onPanelChange,
|
|
473
574
|
timeZone,
|
|
474
|
-
triggerRender
|
|
575
|
+
triggerRender,
|
|
576
|
+
insetInput
|
|
475
577
|
} = this.props;
|
|
476
578
|
const {
|
|
477
579
|
value,
|
|
@@ -519,7 +621,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
519
621
|
onPanelChange: onPanelChange,
|
|
520
622
|
timeZone: timeZone,
|
|
521
623
|
focusRecordsRef: this.focusRecordsRef,
|
|
522
|
-
triggerRender: triggerRender
|
|
624
|
+
triggerRender: triggerRender,
|
|
625
|
+
insetInput: insetInput
|
|
523
626
|
});
|
|
524
627
|
}
|
|
525
628
|
|
|
@@ -555,20 +658,23 @@ class DatePicker extends _baseComponent.default {
|
|
|
555
658
|
triggerRender,
|
|
556
659
|
size,
|
|
557
660
|
inputReadOnly,
|
|
558
|
-
rangeSeparator
|
|
661
|
+
rangeSeparator,
|
|
662
|
+
insetInput
|
|
559
663
|
} = this.props;
|
|
560
664
|
const {
|
|
561
665
|
value,
|
|
562
666
|
inputValue,
|
|
563
|
-
rangeInputFocus
|
|
667
|
+
rangeInputFocus,
|
|
668
|
+
triggerDisabled
|
|
564
669
|
} = this.state; // This class is not needed when triggerRender is function
|
|
565
670
|
|
|
566
671
|
const isRangeType = this.isRangeType(type, triggerRender);
|
|
672
|
+
const inputDisabled = disabled || insetInput && triggerDisabled;
|
|
567
673
|
const inputCls = (0, _classnames.default)("".concat(_constants.cssClasses.PREFIX, "-input"), {
|
|
568
674
|
["".concat(_constants.cssClasses.PREFIX, "-range-input")]: isRangeType,
|
|
569
675
|
[(0, _concat.default)(_context3 = "".concat(_constants.cssClasses.PREFIX, "-range-input-")).call(_context3, size)]: isRangeType && size,
|
|
570
|
-
["".concat(_constants.cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !
|
|
571
|
-
["".concat(_constants.cssClasses.PREFIX, "-range-input-disabled")]: isRangeType &&
|
|
676
|
+
["".concat(_constants.cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !inputDisabled,
|
|
677
|
+
["".concat(_constants.cssClasses.PREFIX, "-range-input-disabled")]: isRangeType && inputDisabled,
|
|
572
678
|
[(0, _concat.default)(_context4 = "".concat(_constants.cssClasses.PREFIX, "-range-input-")).call(_context4, validateStatus)]: isRangeType && validateStatus
|
|
573
679
|
});
|
|
574
680
|
const phText = placeholder || locale.placeholder[type]; // i18n
|
|
@@ -576,9 +682,9 @@ class DatePicker extends _baseComponent.default {
|
|
|
576
682
|
|
|
577
683
|
const props = (0, _assign.default)((0, _assign.default)({}, extraProps), {
|
|
578
684
|
placeholder: phText,
|
|
579
|
-
disabled,
|
|
685
|
+
disabled: inputDisabled,
|
|
580
686
|
inputValue,
|
|
581
|
-
value,
|
|
687
|
+
value: value,
|
|
582
688
|
onChange: this.handleInputChange,
|
|
583
689
|
onEnterPress: this.handleInputComplete,
|
|
584
690
|
// TODO: remove in next major version
|
|
@@ -591,7 +697,7 @@ class DatePicker extends _baseComponent.default {
|
|
|
591
697
|
format,
|
|
592
698
|
multiple,
|
|
593
699
|
validateStatus,
|
|
594
|
-
inputReadOnly,
|
|
700
|
+
inputReadOnly: inputReadOnly || insetInput,
|
|
595
701
|
// onClick: this.handleOpenPanel,
|
|
596
702
|
onBlur: this.handleInputBlur,
|
|
597
703
|
onFocus: this.handleInputFocus,
|
|
@@ -600,26 +706,27 @@ class DatePicker extends _baseComponent.default {
|
|
|
600
706
|
size,
|
|
601
707
|
autofocus: this.state.autofocus,
|
|
602
708
|
dateFnsLocale,
|
|
603
|
-
rangeInputStartRef: this.rangeInputStartRef,
|
|
604
|
-
rangeInputEndRef: this.rangeInputEndRef,
|
|
605
709
|
rangeInputFocus,
|
|
606
710
|
rangeSeparator,
|
|
607
711
|
onRangeBlur: this.handleRangeInputBlur,
|
|
608
712
|
onRangeClear: this.handleRangeInputClear,
|
|
609
|
-
onRangeEndTabPress: this.handleRangeEndTabPress
|
|
713
|
+
onRangeEndTabPress: this.handleRangeEndTabPress,
|
|
714
|
+
rangeInputStartRef: insetInput ? null : this.rangeInputStartRef,
|
|
715
|
+
rangeInputEndRef: insetInput ? null : this.rangeInputEndRef
|
|
610
716
|
});
|
|
611
|
-
return (
|
|
612
|
-
|
|
613
|
-
// eslint-disable-next-line jsx-a11y/
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
717
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
718
|
+
// tooltip will mount a11y props to children
|
|
719
|
+
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
720
|
+
role: "combobox",
|
|
721
|
+
"aria-label": (0, _isArray.default)(value) && value.length ? "Change date" : "Choose date",
|
|
722
|
+
"aria-disabled": disabled,
|
|
723
|
+
onClick: this.handleTriggerWrapperClick,
|
|
724
|
+
className: inputCls
|
|
725
|
+
}, typeof triggerRender === 'function' ? /*#__PURE__*/_react.default.createElement(_trigger.default, (0, _assign.default)({}, props, {
|
|
726
|
+
triggerRender: triggerRender,
|
|
727
|
+
componentName: "DatePicker",
|
|
728
|
+
componentProps: (0, _assign.default)({}, this.props)
|
|
729
|
+
})) : /*#__PURE__*/_react.default.createElement(_dateInput.default, (0, _assign.default)({}, props)));
|
|
623
730
|
}
|
|
624
731
|
|
|
625
732
|
render() {
|
|
@@ -754,5 +861,6 @@ DatePicker.defaultProps = {
|
|
|
754
861
|
spacing: _constants.numbers.SPACING,
|
|
755
862
|
autoSwitchDate: true,
|
|
756
863
|
syncSwitchMonth: false,
|
|
757
|
-
rangeSeparator: _constants.strings.DEFAULT_SEPARATOR_RANGE
|
|
864
|
+
rangeSeparator: _constants.strings.DEFAULT_SEPARATOR_RANGE,
|
|
865
|
+
insetInput: false
|
|
758
866
|
};
|
|
@@ -14,13 +14,17 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
14
14
|
|
|
15
15
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
16
16
|
|
|
17
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
|
+
|
|
17
19
|
var _react = _interopRequireDefault(require("react"));
|
|
18
20
|
|
|
19
21
|
var _object = require("@douyinfe/semi-foundation/lib/cjs/utils/object");
|
|
20
22
|
|
|
23
|
+
var _constants = require("@douyinfe/semi-foundation/lib/cjs/datePicker/constants");
|
|
24
|
+
|
|
21
25
|
var _datePicker = _interopRequireDefault(require("./datePicker"));
|
|
22
26
|
|
|
23
|
-
var
|
|
27
|
+
var _context2 = _interopRequireDefault(require("../configProvider/context"));
|
|
24
28
|
|
|
25
29
|
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
26
30
|
|
|
@@ -47,7 +51,25 @@ var _default = (0, _object.forwardStatics)( /*#__PURE__*/_react.default.forwardR
|
|
|
47
51
|
propsObj.rangeSeparator = " ".concat((0, _trim.default)(rangeSeparator).call(rangeSeparator), " ");
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
if (propsObj.insetInput) {
|
|
55
|
+
var _context;
|
|
56
|
+
|
|
57
|
+
if (!propsObj.position) {
|
|
58
|
+
propsObj.position = _constants.strings.POSITION_INLINE_INPUT;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* When insetInput is `true` and `position` includes `over`, use 1px `spacing` to solve the problem of border-radius leakage in the upper left corner
|
|
62
|
+
*
|
|
63
|
+
* @see https://user-images.githubusercontent.com/26477537/158817185-126a5f33-41f7-414a-8e36-8d1be2dda5cd.png
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if ((0, _includes.default)(_context = propsObj.position).call(_context, 'Over') && !propsObj.spacing) {
|
|
68
|
+
propsObj.spacing = _constants.numbers.SPACING_INSET_INPUT;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_context2.default.Consumer, null, _ref => {
|
|
51
73
|
let {
|
|
52
74
|
timeZone
|
|
53
75
|
} = _ref;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InsetInputValue, Type, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
|
|
2
|
+
import { InputProps } from '../input';
|
|
3
|
+
export interface InsetDateInputProps {
|
|
4
|
+
forwardRef: InputProps['forwardRef'];
|
|
5
|
+
insetInputValue: InsetInputValue;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
valuePath: string;
|
|
8
|
+
onChange: (options: InsetInputChangeFoundationProps) => void;
|
|
9
|
+
onFocus: InputProps['onFocus'];
|
|
10
|
+
}
|
|
11
|
+
export interface InsetTimeInputProps {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
insetInputValue: InsetInputValue;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
valuePath: string;
|
|
16
|
+
type: Type;
|
|
17
|
+
onChange: (options: InsetInputChangeFoundationProps) => void;
|
|
18
|
+
onFocus: InputProps['onFocus'];
|
|
19
|
+
}
|
|
20
|
+
export declare function InsetDateInput(props: InsetDateInputProps): JSX.Element;
|
|
21
|
+
export declare function InsetTimeInput(props: InsetTimeInputProps): JSX.Element;
|