@douyinfe/semi-ui 2.6.0-beta.0 → 2.7.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/button/index.tsx +1 -1
- package/cascader/__test__/cascader.test.js +159 -81
- package/cascader/_story/cascader.stories.js +36 -23
- package/cascader/index.tsx +26 -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 +95 -9
- package/datePicker/datePicker.tsx +89 -15
- package/datePicker/index.tsx +15 -0
- package/datePicker/insetInput.tsx +76 -0
- package/datePicker/monthsGrid.tsx +14 -7
- package/dist/css/semi.css +105 -2
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +949 -163
- 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/hooks/useFormApi.tsx +3 -2
- package/input/_story/input.stories.js +13 -0
- package/lib/cjs/button/Button.d.ts +4 -4
- package/lib/cjs/button/buttonGroup.d.ts +3 -2
- package/lib/cjs/button/buttonGroup.js +6 -2
- package/lib/cjs/button/index.d.ts +5 -6
- package/lib/cjs/cascader/index.d.ts +1 -0
- package/lib/cjs/cascader/index.js +38 -9
- package/lib/cjs/datePicker/dateInput.d.ts +9 -2
- package/lib/cjs/datePicker/dateInput.js +92 -9
- package/lib/cjs/datePicker/datePicker.d.ts +7 -2
- package/lib/cjs/datePicker/datePicker.js +123 -18
- 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/monthsGrid.js +19 -7
- package/lib/cjs/form/hooks/useFormApi.d.ts +2 -1
- package/lib/cjs/iconButton/index.d.ts +2 -2
- 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/radio/radioGroup.js +6 -0
- package/lib/cjs/select/index.js +5 -2
- package/lib/cjs/table/Body/index.d.ts +2 -0
- package/lib/cjs/table/Body/index.js +13 -4
- package/lib/cjs/tag/group.d.ts +2 -0
- package/lib/cjs/tag/group.js +4 -2
- package/lib/cjs/tooltip/index.js +6 -2
- package/lib/cjs/tree/index.js +5 -3
- package/lib/cjs/tree/interface.d.ts +1 -0
- package/lib/cjs/tree/nodeList.js +3 -1
- package/lib/cjs/treeSelect/index.js +11 -3
- package/lib/es/button/Button.d.ts +4 -4
- package/lib/es/button/buttonGroup.d.ts +3 -2
- package/lib/es/button/buttonGroup.js +5 -2
- package/lib/es/button/index.d.ts +5 -6
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +35 -6
- package/lib/es/datePicker/dateInput.d.ts +9 -2
- package/lib/es/datePicker/dateInput.js +91 -9
- package/lib/es/datePicker/datePicker.d.ts +7 -2
- package/lib/es/datePicker/datePicker.js +124 -18
- 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/monthsGrid.js +19 -7
- package/lib/es/form/hooks/useFormApi.d.ts +2 -1
- package/lib/es/iconButton/index.d.ts +2 -2
- 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/radio/radioGroup.js +6 -0
- package/lib/es/select/index.js +5 -2
- package/lib/es/table/Body/index.d.ts +2 -0
- package/lib/es/table/Body/index.js +13 -4
- package/lib/es/tag/group.d.ts +2 -0
- package/lib/es/tag/group.js +4 -2
- package/lib/es/tooltip/index.js +6 -2
- package/lib/es/tree/index.js +5 -3
- package/lib/es/tree/interface.d.ts +1 -0
- package/lib/es/tree/nodeList.js +3 -1
- package/lib/es/treeSelect/index.js +11 -3
- package/navigation/Item.tsx +15 -12
- package/navigation/SubNav.tsx +4 -4
- package/package.json +9 -9
- package/radio/__test__/radioGroup.test.jsx +9 -1
- package/radio/_story/radio.stories.js +22 -1
- package/radio/radioGroup.tsx +9 -0
- package/select/_story/select.stories.js +73 -2
- package/select/index.tsx +5 -3
- 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/tag/group.tsx +5 -3
- package/tooltip/_story/tooltip.stories.js +702 -625
- package/tooltip/index.tsx +2 -2
- 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 +3 -2
- package/treeSelect/__test__/treeSelect.test.js +28 -0
- package/treeSelect/_story/treeSelect.stories.js +55 -2
- package/treeSelect/index.tsx +14 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { BaseFormApi } from '@douyinfe/semi-foundation/form/interface';
|
|
1
2
|
import React, { useContext } from 'react';
|
|
2
3
|
import { FormApiContext } from '../context';
|
|
3
4
|
|
|
4
|
-
export default function useFormApi() {
|
|
5
|
-
return useContext(FormApiContext);
|
|
5
|
+
export default function useFormApi<T extends Record<string, any> = any>() {
|
|
6
|
+
return useContext<BaseFormApi<T>>(FormApiContext);
|
|
6
7
|
}
|
|
@@ -884,4 +884,17 @@ export const ClearButton = () => {
|
|
|
884
884
|
|
|
885
885
|
ClearButton.story = {
|
|
886
886
|
name: 'clear button',
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
export const InputFocus = () => {
|
|
890
|
+
const ref = React.useRef();
|
|
891
|
+
const handleClick = () => {
|
|
892
|
+
ref.current.focus();
|
|
893
|
+
};
|
|
894
|
+
return (
|
|
895
|
+
<>
|
|
896
|
+
<Button onClick={handleClick}>focus input</Button>
|
|
897
|
+
<Input ref={ref} onChange={() => console.log('ref', ref) } onFocus={() => console.log('focus')} />
|
|
898
|
+
</>
|
|
899
|
+
);
|
|
887
900
|
};
|
|
@@ -46,15 +46,15 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
46
46
|
disabled: PropTypes.Requireable<boolean>;
|
|
47
47
|
prefixCls: PropTypes.Requireable<string>;
|
|
48
48
|
style: PropTypes.Requireable<object>;
|
|
49
|
-
size: PropTypes.Requireable<
|
|
50
|
-
type: PropTypes.Requireable<
|
|
49
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
50
|
+
type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
51
51
|
block: PropTypes.Requireable<boolean>;
|
|
52
52
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
53
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
circle: PropTypes.Requireable<boolean>;
|
|
55
55
|
loading: PropTypes.Requireable<boolean>;
|
|
56
|
-
htmlType: PropTypes.Requireable<
|
|
57
|
-
theme: PropTypes.Requireable<
|
|
56
|
+
htmlType: PropTypes.Requireable<"button" | "reset" | "submit">;
|
|
57
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
58
58
|
className: PropTypes.Requireable<string>;
|
|
59
59
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
60
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -9,6 +9,7 @@ export interface ButtonGroupProps extends BaseProps {
|
|
|
9
9
|
type?: Type;
|
|
10
10
|
size?: Size;
|
|
11
11
|
theme?: Theme;
|
|
12
|
+
className?: string;
|
|
12
13
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
13
14
|
}
|
|
14
15
|
export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
@@ -16,8 +17,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
|
16
17
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
17
18
|
disabled: PropTypes.Requireable<boolean>;
|
|
18
19
|
type: PropTypes.Requireable<string>;
|
|
19
|
-
size: PropTypes.Requireable<
|
|
20
|
-
theme: PropTypes.Requireable<
|
|
20
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
21
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
21
22
|
'aria-label': PropTypes.Requireable<string>;
|
|
22
23
|
};
|
|
23
24
|
static defaultProps: {
|
|
@@ -30,6 +30,8 @@ var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
|
30
30
|
|
|
31
31
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
32
32
|
|
|
33
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
34
|
+
|
|
33
35
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/button/constants");
|
|
34
36
|
|
|
35
37
|
require("@douyinfe/semi-foundation/lib/cjs/button/button.css");
|
|
@@ -60,11 +62,13 @@ class ButtonGroup extends _baseComponent.default {
|
|
|
60
62
|
disabled,
|
|
61
63
|
size,
|
|
62
64
|
type,
|
|
65
|
+
className,
|
|
63
66
|
'aria-label': ariaLabel
|
|
64
67
|
} = _a,
|
|
65
|
-
rest = __rest(_a, ["children", "disabled", "size", "type", 'aria-label']);
|
|
68
|
+
rest = __rest(_a, ["children", "disabled", "size", "type", "className", 'aria-label']);
|
|
66
69
|
|
|
67
70
|
let inner;
|
|
71
|
+
const cls = (0, _classnames.default)("".concat(prefixCls, "-group"), className);
|
|
68
72
|
|
|
69
73
|
if (children) {
|
|
70
74
|
var _context;
|
|
@@ -79,7 +83,7 @@ class ButtonGroup extends _baseComponent.default {
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
82
|
-
className:
|
|
86
|
+
className: cls,
|
|
83
87
|
role: "group",
|
|
84
88
|
"aria-label": ariaLabel
|
|
85
89
|
}, inner);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ButtonProps as BaseButtonProps } from './Button';
|
|
3
2
|
import { IconButtonProps } from '../iconButton';
|
|
4
3
|
export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
|
|
5
4
|
export { HorizontalPaddingType } from '../iconButton';
|
|
6
5
|
export { ButtonGroupProps } from './buttonGroup';
|
|
7
6
|
export { SplitButtonGroupProps } from './splitButtonGroup';
|
|
8
|
-
export interface ButtonProps extends IconButtonProps
|
|
7
|
+
export interface ButtonProps extends IconButtonProps {
|
|
9
8
|
}
|
|
10
9
|
declare class Button extends React.PureComponent<ButtonProps> {
|
|
11
10
|
static propTypes: {
|
|
@@ -18,18 +17,18 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
18
17
|
noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
|
|
19
18
|
children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
|
|
20
19
|
theme: import("prop-types").Requireable<string>;
|
|
21
|
-
iconPosition: import("prop-types").Requireable<
|
|
20
|
+
iconPosition: import("prop-types").Requireable<"left" | "right">;
|
|
22
21
|
className: import("prop-types").Requireable<string>;
|
|
23
22
|
onMouseEnter: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
23
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
24
|
disabled: import("prop-types").Requireable<boolean>;
|
|
26
|
-
size: import("prop-types").Requireable<
|
|
27
|
-
type: import("prop-types").Requireable<
|
|
25
|
+
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
28
27
|
block: import("prop-types").Requireable<boolean>;
|
|
29
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
30
29
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
31
30
|
circle: import("prop-types").Requireable<boolean>;
|
|
32
|
-
htmlType: import("prop-types").Requireable<
|
|
31
|
+
htmlType: import("prop-types").Requireable<"button" | "reset" | "submit">;
|
|
33
32
|
'aria-label': import("prop-types").Requireable<string>;
|
|
34
33
|
};
|
|
35
34
|
constructor(props?: {});
|
|
@@ -187,6 +187,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
187
187
|
renderContent: () => JSX.Element;
|
|
188
188
|
renderPlusN: (hiddenTag: Array<ReactNode>) => JSX.Element;
|
|
189
189
|
renderMultipleTags: () => JSX.Element;
|
|
190
|
+
renderDisplayText: () => ReactNode;
|
|
190
191
|
renderSelectContent: () => JSX.Element;
|
|
191
192
|
renderSuffix: () => JSX.Element;
|
|
192
193
|
renderPrefix: () => JSX.Element;
|
|
@@ -20,14 +20,14 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
20
20
|
|
|
21
21
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
22
22
|
|
|
23
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
24
|
+
|
|
23
25
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
24
26
|
|
|
25
27
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
26
28
|
|
|
27
29
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
28
30
|
|
|
29
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
30
|
-
|
|
31
31
|
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
32
32
|
|
|
33
33
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
@@ -66,7 +66,7 @@ var _util = require("@douyinfe/semi-foundation/lib/cjs/cascader/util");
|
|
|
66
66
|
|
|
67
67
|
var _treeUtil = require("@douyinfe/semi-foundation/lib/cjs/tree/treeUtil");
|
|
68
68
|
|
|
69
|
-
var
|
|
69
|
+
var _context5 = _interopRequireDefault(require("../configProvider/context"));
|
|
70
70
|
|
|
71
71
|
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
72
72
|
|
|
@@ -267,6 +267,36 @@ class Cascader extends _baseComponent.default {
|
|
|
267
267
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, displayTag, !(0, _isEmpty2.default)(hiddenTag) && this.renderPlusN(hiddenTag));
|
|
268
268
|
};
|
|
269
269
|
|
|
270
|
+
this.renderDisplayText = () => {
|
|
271
|
+
const {
|
|
272
|
+
displayProp,
|
|
273
|
+
separator,
|
|
274
|
+
displayRender
|
|
275
|
+
} = this.props;
|
|
276
|
+
const {
|
|
277
|
+
selectedKeys
|
|
278
|
+
} = this.state;
|
|
279
|
+
let displayText = '';
|
|
280
|
+
|
|
281
|
+
if (selectedKeys.size) {
|
|
282
|
+
const displayPath = this.foundation.getItemPropPath([...selectedKeys][0], displayProp);
|
|
283
|
+
|
|
284
|
+
if (displayRender && typeof displayRender === 'function') {
|
|
285
|
+
displayText = displayRender(displayPath);
|
|
286
|
+
} else {
|
|
287
|
+
displayText = (0, _map.default)(displayPath).call(displayPath, (path, index) => {
|
|
288
|
+
var _context3;
|
|
289
|
+
|
|
290
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
291
|
+
key: (0, _concat.default)(_context3 = "".concat(path, "-")).call(_context3, index)
|
|
292
|
+
}, index < displayPath.length - 1 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, path, separator) : path);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return displayText;
|
|
298
|
+
};
|
|
299
|
+
|
|
270
300
|
this.renderSelectContent = () => {
|
|
271
301
|
const {
|
|
272
302
|
placeholder,
|
|
@@ -274,7 +304,6 @@ class Cascader extends _baseComponent.default {
|
|
|
274
304
|
multiple
|
|
275
305
|
} = this.props;
|
|
276
306
|
const {
|
|
277
|
-
selectedKeys,
|
|
278
307
|
checkedKeys
|
|
279
308
|
} = this.state;
|
|
280
309
|
const searchable = Boolean(filterTreeNode);
|
|
@@ -289,9 +318,9 @@ class Cascader extends _baseComponent.default {
|
|
|
289
318
|
|
|
290
319
|
return this.renderMultipleTags();
|
|
291
320
|
} else {
|
|
292
|
-
const displayText =
|
|
321
|
+
const displayText = this.renderDisplayText();
|
|
293
322
|
const spanCls = (0, _classnames.default)({
|
|
294
|
-
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
323
|
+
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
295
324
|
});
|
|
296
325
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
297
326
|
className: spanCls
|
|
@@ -835,7 +864,7 @@ class Cascader extends _baseComponent.default {
|
|
|
835
864
|
}
|
|
836
865
|
|
|
837
866
|
renderTagInput() {
|
|
838
|
-
var
|
|
867
|
+
var _context4;
|
|
839
868
|
|
|
840
869
|
const {
|
|
841
870
|
size,
|
|
@@ -854,7 +883,7 @@ class Cascader extends _baseComponent.default {
|
|
|
854
883
|
const tagInputcls = (0, _classnames.default)("".concat(prefixcls, "-tagInput-wrapper"));
|
|
855
884
|
const tagValue = [];
|
|
856
885
|
const realKeys = this.mergeType === _constants.strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
857
|
-
(0, _forEach.default)(
|
|
886
|
+
(0, _forEach.default)(_context4 = [...realKeys]).call(_context4, checkedKey => {
|
|
858
887
|
if (!(0, _isEmpty2.default)(keyEntities[checkedKey])) {
|
|
859
888
|
tagValue.push(keyEntities[checkedKey].valuePath);
|
|
860
889
|
}
|
|
@@ -945,7 +974,7 @@ class Cascader extends _baseComponent.default {
|
|
|
945
974
|
|
|
946
975
|
}
|
|
947
976
|
|
|
948
|
-
Cascader.contextType =
|
|
977
|
+
Cascader.contextType = _context5.default;
|
|
949
978
|
Cascader.propTypes = {
|
|
950
979
|
'aria-labelledby': _propTypes.default.string,
|
|
951
980
|
'aria-invalid': _propTypes.default.bool,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
|
|
3
|
+
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType, InsetInputChangeProps, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
|
|
4
4
|
import { noop } from '@douyinfe/semi-foundation/lib/cjs/utils/function';
|
|
5
|
-
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
6
5
|
import { ValueType } from '@douyinfe/semi-foundation/lib/cjs/datePicker/foundation';
|
|
6
|
+
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
7
7
|
export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
8
8
|
insetLabel?: React.ReactNode;
|
|
9
9
|
prefix?: React.ReactNode;
|
|
@@ -13,6 +13,8 @@ export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
|
13
13
|
onBlur?: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
14
14
|
onFocus?: (e: React.MouseEvent<HTMLInputElement>, rangeType?: RangeType) => void;
|
|
15
15
|
onClear?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
|
+
onInsetInputChange?: (options: InsetInputChangeProps) => void;
|
|
17
|
+
value?: Date[];
|
|
16
18
|
}
|
|
17
19
|
export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
18
20
|
static propTypes: {
|
|
@@ -39,6 +41,8 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
39
41
|
rangeInputStartRef: PropTypes.Requireable<object>;
|
|
40
42
|
rangeInputEndRef: PropTypes.Requireable<object>;
|
|
41
43
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
44
|
+
insetInput: PropTypes.Requireable<boolean>;
|
|
45
|
+
insetInputValue: PropTypes.Requireable<object>;
|
|
42
46
|
};
|
|
43
47
|
static defaultProps: {
|
|
44
48
|
showClear: boolean;
|
|
@@ -69,11 +73,14 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
69
73
|
handleRangeInputEndKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
70
74
|
handleRangeInputFocus: (e: React.MouseEvent<HTMLElement>, rangeType: RangeType) => void;
|
|
71
75
|
handleRangeStartFocus: React.MouseEventHandler<HTMLElement>;
|
|
76
|
+
handleInsetInputChange: (options: InsetInputChangeFoundationProps) => void;
|
|
72
77
|
getRangeInputValue: (rangeStart: string, rangeEnd: string) => string;
|
|
73
78
|
renderRangePrefix(): JSX.Element;
|
|
74
79
|
renderRangeSeparator(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
75
80
|
renderRangeClearBtn(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
76
81
|
renderRangeSuffix(suffix: React.ReactNode): JSX.Element;
|
|
77
82
|
renderRangeInput(rangeProps: DateInputProps): JSX.Element;
|
|
83
|
+
renderInputInset(): JSX.Element;
|
|
84
|
+
renderTriggerInput(): JSX.Element;
|
|
78
85
|
render(): JSX.Element;
|
|
79
86
|
}
|
|
@@ -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,7 +54,9 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
52
54
|
}
|
|
53
55
|
return t;
|
|
54
56
|
};
|
|
55
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events
|
|
57
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
58
|
+
|
|
59
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
56
60
|
|
|
57
61
|
/* eslint-disable max-lines-per-function */
|
|
58
62
|
|
|
@@ -96,6 +100,10 @@ class DateInput extends _baseComponent.default {
|
|
|
96
100
|
this.handleRangeInputFocus(e, 'rangeStart');
|
|
97
101
|
};
|
|
98
102
|
|
|
103
|
+
this.handleInsetInputChange = options => {
|
|
104
|
+
this.foundation.handleInsetInputChange(options);
|
|
105
|
+
};
|
|
106
|
+
|
|
99
107
|
this.getRangeInputValue = (rangeStart, rangeEnd) => {
|
|
100
108
|
var _context, _context2;
|
|
101
109
|
|
|
@@ -142,7 +150,8 @@ class DateInput extends _baseComponent.default {
|
|
|
142
150
|
},
|
|
143
151
|
notifyTabPress: function () {
|
|
144
152
|
return _this.props.onRangeEndTabPress(...arguments);
|
|
145
|
-
}
|
|
153
|
+
},
|
|
154
|
+
notifyInsetInputChange: options => this.props.onInsetInputChange(options)
|
|
146
155
|
});
|
|
147
156
|
}
|
|
148
157
|
|
|
@@ -247,11 +256,11 @@ class DateInput extends _baseComponent.default {
|
|
|
247
256
|
const rangePlaceholder = (0, _isArray.default)(placeholder) ? placeholder : [placeholder, placeholder];
|
|
248
257
|
const [rangeStartPlaceholder, rangeEndPlaceholder] = rangePlaceholder;
|
|
249
258
|
const inputLeftWrapperCls = (0, _classnames.default)("".concat(prefixCls, "-range-input-wrapper-start"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
250
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart',
|
|
259
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart' && !disabled,
|
|
251
260
|
["".concat(prefixCls, "-range-input-wrapper-start-with-prefix")]: this.props.prefix || this.props.insetLabel
|
|
252
261
|
});
|
|
253
262
|
const inputRightWrapperCls = (0, _classnames.default)("".concat(prefixCls, "-range-input-wrapper-end"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
254
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd'
|
|
263
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd' && !disabled
|
|
255
264
|
});
|
|
256
265
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderRangePrefix(), /*#__PURE__*/_react.default.createElement("div", {
|
|
257
266
|
onClick: e => !disabled && this.handleRangeInputFocus(e, 'rangeStart'),
|
|
@@ -290,7 +299,70 @@ class DateInput extends _baseComponent.default {
|
|
|
290
299
|
})), this.renderRangeClearBtn(rangeStart, rangeEnd), this.renderRangeSuffix(suffix));
|
|
291
300
|
}
|
|
292
301
|
|
|
293
|
-
|
|
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() {
|
|
294
366
|
const _a = this.props,
|
|
295
367
|
{
|
|
296
368
|
placeholder,
|
|
@@ -322,9 +394,11 @@ class DateInput extends _baseComponent.default {
|
|
|
322
394
|
onRangeBlur,
|
|
323
395
|
onRangeEndTabPress,
|
|
324
396
|
rangeInputFocus,
|
|
325
|
-
rangeSeparator
|
|
397
|
+
rangeSeparator,
|
|
398
|
+
insetInput,
|
|
399
|
+
insetInputValue
|
|
326
400
|
} = _a,
|
|
327
|
-
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"]);
|
|
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"]);
|
|
328
402
|
|
|
329
403
|
const dateIcon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar, {
|
|
330
404
|
"aria-hidden": true
|
|
@@ -375,6 +449,13 @@ class DateInput extends _baseComponent.default {
|
|
|
375
449
|
}));
|
|
376
450
|
}
|
|
377
451
|
|
|
452
|
+
render() {
|
|
453
|
+
const {
|
|
454
|
+
insetInput
|
|
455
|
+
} = this.props;
|
|
456
|
+
return insetInput ? this.renderInputInset() : this.renderTriggerInput();
|
|
457
|
+
}
|
|
458
|
+
|
|
378
459
|
}
|
|
379
460
|
|
|
380
461
|
exports.default = DateInput;
|
|
@@ -401,7 +482,9 @@ DateInput.propTypes = {
|
|
|
401
482
|
rangeInputFocus: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
402
483
|
rangeInputStartRef: _propTypes.default.object,
|
|
403
484
|
rangeInputEndRef: _propTypes.default.object,
|
|
404
|
-
rangeSeparator: _propTypes.default.string
|
|
485
|
+
rangeSeparator: _propTypes.default.string,
|
|
486
|
+
insetInput: _propTypes.default.bool,
|
|
487
|
+
insetInputValue: _propTypes.default.object
|
|
405
488
|
};
|
|
406
489
|
DateInput.defaultProps = {
|
|
407
490
|
showClear: true,
|
|
@@ -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;
|