@douyinfe/semi-ui 2.17.0-alpha.1 → 2.17.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/_base/_story/a11y.jsx +2 -2
- package/avatar/__test__/avatar.test.js +3 -3
- package/avatar/interface.ts +1 -1
- package/cascader/_story/cascader.stories.js +91 -1
- package/cascader/index.tsx +35 -26
- package/checkbox/checkbox.tsx +4 -1
- package/collapse/__test__/collapse.test.js +22 -2
- package/collapse/_story/accordion.stories.js +2 -2
- package/collapse/item.tsx +20 -6
- package/collapsible/_story/collapsible.stories.js +6 -6
- package/configProvider/_story/RTLDirection/RTLForm.jsx +1 -1
- package/datePicker/__test__/datePicker.test.js +5 -5
- package/datePicker/_story/datePicker.stories.js +138 -22
- package/datePicker/datePicker.tsx +42 -7
- package/datePicker/monthsGrid.tsx +22 -10
- package/datePicker/quickControl.tsx +62 -16
- package/datePicker/yearAndMonth.tsx +31 -5
- package/dist/css/semi.css +328 -47
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +36811 -36304
- 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/empty/index.tsx +3 -3
- package/lib/cjs/avatar/interface.d.ts +1 -1
- package/lib/cjs/cascader/index.js +36 -25
- package/lib/cjs/checkbox/checkbox.js +4 -1
- package/lib/cjs/collapse/item.d.ts +8 -0
- package/lib/cjs/collapse/item.js +19 -8
- package/lib/cjs/datePicker/datePicker.d.ts +3 -0
- package/lib/cjs/datePicker/datePicker.js +56 -9
- package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
- package/lib/cjs/datePicker/monthsGrid.js +14 -3
- package/lib/cjs/datePicker/quickControl.d.ts +6 -0
- package/lib/cjs/datePicker/quickControl.js +61 -14
- package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/cjs/datePicker/yearAndMonth.js +15 -3
- package/lib/cjs/empty/index.js +1 -1
- package/lib/cjs/popover/index.d.ts +3 -0
- package/lib/cjs/popover/index.js +4 -2
- package/lib/cjs/select/index.d.ts +6 -1
- package/lib/cjs/select/index.js +130 -72
- package/lib/cjs/select/option.js +4 -2
- package/lib/cjs/tag/index.js +6 -4
- package/lib/cjs/tag/interface.d.ts +1 -0
- package/lib/cjs/tagInput/index.d.ts +13 -1
- package/lib/cjs/tagInput/index.js +217 -91
- package/lib/cjs/timePicker/TimePicker.js +1 -1
- package/lib/cjs/tooltip/index.d.ts +4 -0
- package/lib/cjs/tooltip/index.js +5 -3
- package/lib/cjs/typography/base.js +3 -15
- package/lib/cjs/typography/text.js +1 -11
- package/lib/es/avatar/interface.d.ts +1 -1
- package/lib/es/cascader/index.js +40 -29
- package/lib/es/checkbox/checkbox.js +4 -1
- package/lib/es/collapse/item.d.ts +8 -0
- package/lib/es/collapse/item.js +19 -8
- package/lib/es/datePicker/datePicker.d.ts +3 -0
- package/lib/es/datePicker/datePicker.js +56 -9
- package/lib/es/datePicker/monthsGrid.d.ts +3 -0
- package/lib/es/datePicker/monthsGrid.js +14 -3
- package/lib/es/datePicker/quickControl.d.ts +6 -0
- package/lib/es/datePicker/quickControl.js +61 -15
- package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/es/datePicker/yearAndMonth.js +14 -3
- package/lib/es/empty/index.js +1 -1
- package/lib/es/popover/index.d.ts +3 -0
- package/lib/es/popover/index.js +4 -2
- package/lib/es/select/index.d.ts +6 -1
- package/lib/es/select/index.js +129 -71
- package/lib/es/select/option.js +4 -2
- package/lib/es/tag/index.js +6 -4
- package/lib/es/tag/interface.d.ts +1 -0
- package/lib/es/tagInput/index.d.ts +13 -1
- package/lib/es/tagInput/index.js +217 -93
- package/lib/es/timePicker/TimePicker.js +1 -1
- package/lib/es/tooltip/index.d.ts +4 -0
- package/lib/es/tooltip/index.js +5 -3
- package/lib/es/typography/base.js +3 -15
- package/lib/es/typography/text.js +1 -10
- package/package.json +7 -7
- package/popover/index.tsx +4 -1
- package/select/__test__/select.test.js +5 -3
- package/select/_story/select.stories.js +1 -1
- package/select/_story/select.stories.tsx +2 -2
- package/select/index.tsx +65 -30
- package/select/option.tsx +2 -0
- package/table/_story/Perf/Render/complex.jsx +1 -1
- package/table/_story/Perf/Render/resizableSelection.jsx +1 -1
- package/tag/index.tsx +3 -2
- package/tag/interface.ts +1 -0
- package/tagInput/_story/tagInput.stories.js +20 -2
- package/tagInput/index.tsx +126 -26
- package/timePicker/TimePicker.tsx +1 -1
- package/tooltip/index.tsx +5 -2
- package/typography/_story/typography.stories.js +3 -15
- package/typography/base.tsx +4 -9
- package/typography/text.tsx +1 -9
- package/upload/__test__/upload.test.js +9 -9
- package/upload/_story/upload.stories.js +5 -5
package/empty/index.tsx
CHANGED
|
@@ -79,17 +79,17 @@ export default class Empty extends BaseComponent<EmptyProps, EmptyState> {
|
|
|
79
79
|
const { className, image, description, style, title, imageStyle, children, layout, darkModeImage } = this.props;
|
|
80
80
|
|
|
81
81
|
const alt = typeof description === 'string' ? description : 'empty';
|
|
82
|
-
const imgSrc = this.state.mode && darkModeImage ? darkModeImage : image;
|
|
82
|
+
const imgSrc = ((this.state.mode === 'dark') && darkModeImage) ? darkModeImage : image;
|
|
83
83
|
let imageNode = null;
|
|
84
84
|
if (typeof imgSrc === 'string') {
|
|
85
|
-
imageNode = <img alt={alt} src={imgSrc}
|
|
85
|
+
imageNode = <img alt={alt} src={imgSrc}/>;
|
|
86
86
|
} else if (imgSrc && 'id' in (imgSrc as any)) {
|
|
87
87
|
imageNode = (
|
|
88
88
|
<svg
|
|
89
89
|
// className={iconCls}
|
|
90
90
|
aria-hidden="true"
|
|
91
91
|
>
|
|
92
|
-
<use xlinkHref={`#${(imgSrc as any).id}`}
|
|
92
|
+
<use xlinkHref={`#${(imgSrc as any).id}`}/>
|
|
93
93
|
</svg>
|
|
94
94
|
);
|
|
95
95
|
} else {
|
|
@@ -19,7 +19,7 @@ export interface AvatarProps extends BaseProps {
|
|
|
19
19
|
imgAttr?: React.ImgHTMLAttributes<HTMLImageElement>;
|
|
20
20
|
}
|
|
21
21
|
export declare type AvatarGroupShape = 'circle' | 'square';
|
|
22
|
-
export declare type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
|
|
22
|
+
export declare type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'default' | 'medium' | 'large' | 'extra-large';
|
|
23
23
|
export declare type AvatarGroupOverlapFrom = 'start' | 'end';
|
|
24
24
|
export interface AvatarGroupProps {
|
|
25
25
|
children?: React.ReactNode;
|
|
@@ -801,6 +801,33 @@ class Cascader extends _baseComponent.default {
|
|
|
801
801
|
return firstInProps || treeDataHasChange;
|
|
802
802
|
};
|
|
803
803
|
|
|
804
|
+
const getRealKeys = (realValue, keyEntities) => {
|
|
805
|
+
// normallizedValue is used to save the value in two-dimensional array format
|
|
806
|
+
let normallizedValue = [];
|
|
807
|
+
|
|
808
|
+
if ((0, _isArray.default)(realValue)) {
|
|
809
|
+
normallizedValue = (0, _isArray.default)(realValue[0]) ? realValue : [realValue];
|
|
810
|
+
} else {
|
|
811
|
+
if (realValue !== undefined) {
|
|
812
|
+
normallizedValue = [[realValue]];
|
|
813
|
+
}
|
|
814
|
+
} // formatValuePath is used to save value of valuePath
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
const formatValuePath = [];
|
|
818
|
+
(0, _forEach.default)(normallizedValue).call(normallizedValue, valueItem => {
|
|
819
|
+
const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
|
|
820
|
+
formatValuePath.push(formatItem);
|
|
821
|
+
}); // formatKeys is used to save key of value
|
|
822
|
+
|
|
823
|
+
const formatKeys = [];
|
|
824
|
+
(0, _forEach.default)(formatValuePath).call(formatValuePath, v => {
|
|
825
|
+
const formatKeyItem = (0, _util.findKeysForValues)(v, keyEntities);
|
|
826
|
+
!(0, _isEmpty2.default)(formatKeyItem) && formatKeys.push(formatKeyItem);
|
|
827
|
+
});
|
|
828
|
+
return formatKeys;
|
|
829
|
+
};
|
|
830
|
+
|
|
804
831
|
const needUpdateTreeData = needUpdate('treeData') || needUpdateData();
|
|
805
832
|
const needUpdateValue = needUpdate('value') || (0, _isEmpty2.default)(prevProps) && defaultValue;
|
|
806
833
|
|
|
@@ -817,31 +844,15 @@ class Cascader extends _baseComponent.default {
|
|
|
817
844
|
let realKeys = prevState.checkedKeys; // when data was updated
|
|
818
845
|
|
|
819
846
|
if (needUpdateValue) {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
} // formatValuePath is used to save value of valuePath
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
const formatValuePath = [];
|
|
834
|
-
(0, _forEach.default)(normallizedValue).call(normallizedValue, valueItem => {
|
|
835
|
-
const formatItem = onChangeWithObject ? (0, _map.default)(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
|
|
836
|
-
formatValuePath.push(formatItem);
|
|
837
|
-
}); // formatKeys is used to save key of value
|
|
838
|
-
|
|
839
|
-
const formatKeys = [];
|
|
840
|
-
(0, _forEach.default)(formatValuePath).call(formatValuePath, v => {
|
|
841
|
-
const formatKeyItem = (0, _util.findKeysForValues)(v, keyEntities);
|
|
842
|
-
!(0, _isEmpty2.default)(formatKeyItem) && formatKeys.push(formatKeyItem);
|
|
843
|
-
});
|
|
844
|
-
realKeys = formatKeys;
|
|
847
|
+
const realValue = needUpdate('value') ? value : defaultValue;
|
|
848
|
+
realKeys = getRealKeys(realValue, keyEntities);
|
|
849
|
+
} else {
|
|
850
|
+
// needUpdateValue is false
|
|
851
|
+
// if treeData is updated & Cascader is controlled, realKeys should be recalculated
|
|
852
|
+
if (needUpdateTreeData && 'value' in props) {
|
|
853
|
+
const realValue = value;
|
|
854
|
+
realKeys = getRealKeys(realValue, keyEntities);
|
|
855
|
+
}
|
|
845
856
|
}
|
|
846
857
|
|
|
847
858
|
if ((0, _isSet2.default)(realKeys)) {
|
|
@@ -123,7 +123,10 @@ class Checkbox extends _baseComponent.default {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
isInGroup() {
|
|
126
|
-
|
|
126
|
+
// Why do we need to determine whether there is a value in props?
|
|
127
|
+
// If there is no value in the props of the checkbox in the context of the checkboxGroup,
|
|
128
|
+
// it will be considered not to belong to the checkboxGroup。
|
|
129
|
+
return Boolean(this.context && this.context.checkboxGroup && 'value' in this.props);
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
focus() {
|
|
@@ -9,6 +9,8 @@ export interface CollapsePanelProps {
|
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
reCalcKey?: number | string;
|
|
11
11
|
style?: CSSProperties;
|
|
12
|
+
showArrow?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
14
16
|
static contextType: React.Context<CollapseContextType>;
|
|
@@ -18,6 +20,12 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
18
20
|
header: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
19
21
|
className: PropTypes.Requireable<string>;
|
|
20
22
|
reCalcKey: PropTypes.Requireable<string | number>;
|
|
23
|
+
showArrow: PropTypes.Requireable<boolean>;
|
|
24
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
25
|
+
};
|
|
26
|
+
static defaultProps: {
|
|
27
|
+
showArrow: boolean;
|
|
28
|
+
disabled: boolean;
|
|
21
29
|
};
|
|
22
30
|
private ariaID;
|
|
23
31
|
context: CollapseContextType;
|
package/lib/cjs/collapse/item.js
CHANGED
|
@@ -60,6 +60,7 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
60
60
|
renderHeader(active) {
|
|
61
61
|
let expandIconEnable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
62
62
|
const {
|
|
63
|
+
showArrow,
|
|
63
64
|
header,
|
|
64
65
|
extra
|
|
65
66
|
} = this.props;
|
|
@@ -89,12 +90,12 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
89
90
|
const iconPosLeft = expandIconPosition === 'left';
|
|
90
91
|
|
|
91
92
|
if (typeof header === 'string') {
|
|
92
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconPosLeft ? icon : null, /*#__PURE__*/_react.default.createElement("span", null, header), /*#__PURE__*/_react.default.createElement("span", {
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showArrow && (iconPosLeft ? icon : null), /*#__PURE__*/_react.default.createElement("span", null, header), /*#__PURE__*/_react.default.createElement("span", {
|
|
93
94
|
className: "".concat(_constants.cssClasses.PREFIX, "-header-right")
|
|
94
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, extra), iconPosLeft ? null : icon));
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, extra), showArrow && (iconPosLeft ? null : icon)));
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconPosLeft ? icon : null, header, iconPosLeft ? null : icon);
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showArrow && (iconPosLeft ? icon : null), header, showArrow && (iconPosLeft ? null : icon));
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
render() {
|
|
@@ -105,9 +106,11 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
105
106
|
itemKey,
|
|
106
107
|
reCalcKey,
|
|
107
108
|
header,
|
|
108
|
-
extra
|
|
109
|
+
extra,
|
|
110
|
+
showArrow,
|
|
111
|
+
disabled
|
|
109
112
|
} = _a,
|
|
110
|
-
restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey", "header", "extra"]);
|
|
113
|
+
restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey", "header", "extra", "showArrow", "disabled"]);
|
|
111
114
|
|
|
112
115
|
const {
|
|
113
116
|
keepDOM,
|
|
@@ -122,6 +125,7 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
122
125
|
});
|
|
123
126
|
const headerCls = (0, _classnames.default)({
|
|
124
127
|
["".concat(_constants.cssClasses.PREFIX, "-header")]: true,
|
|
128
|
+
["".concat(_constants.cssClasses.PREFIX, "-header-disabled")]: disabled,
|
|
125
129
|
["".concat(_constants.cssClasses.PREFIX, "-header-iconLeft")]: expandIconPosition === 'left'
|
|
126
130
|
});
|
|
127
131
|
const contentCls = (0, _classnames.default)({
|
|
@@ -133,10 +137,11 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
133
137
|
role: "button",
|
|
134
138
|
tabIndex: 0,
|
|
135
139
|
className: headerCls,
|
|
140
|
+
"aria-disabled": disabled,
|
|
136
141
|
"aria-expanded": active ? 'true' : 'false',
|
|
137
142
|
"aria-owns": this.ariaID,
|
|
138
|
-
onClick: e => onClick(itemKey, e)
|
|
139
|
-
}, this.renderHeader(active, children !== undefined)), children && /*#__PURE__*/_react.default.createElement(_collapsible.default, {
|
|
143
|
+
onClick: e => !disabled && onClick(itemKey, e)
|
|
144
|
+
}, this.renderHeader(active, children !== undefined && !disabled)), children && /*#__PURE__*/_react.default.createElement(_collapsible.default, {
|
|
140
145
|
isOpen: active,
|
|
141
146
|
keepDOM: keepDOM,
|
|
142
147
|
motion: motion,
|
|
@@ -159,5 +164,11 @@ CollapsePanel.propTypes = {
|
|
|
159
164
|
extra: _propTypes.default.node,
|
|
160
165
|
header: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
161
166
|
className: _propTypes.default.string,
|
|
162
|
-
reCalcKey: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
167
|
+
reCalcKey: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
168
|
+
showArrow: _propTypes.default.bool,
|
|
169
|
+
disabled: _propTypes.default.bool
|
|
170
|
+
};
|
|
171
|
+
CollapsePanel.defaultProps = {
|
|
172
|
+
showArrow: true,
|
|
173
|
+
disabled: false
|
|
163
174
|
};
|
|
@@ -56,6 +56,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
56
56
|
max: PropTypes.Requireable<number>;
|
|
57
57
|
placeholder: PropTypes.Requireable<string | any[]>;
|
|
58
58
|
presets: PropTypes.Requireable<any[]>;
|
|
59
|
+
presetPosition: PropTypes.Requireable<"top" | "left" | "right" | "bottom">;
|
|
59
60
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
61
|
onChangeWithDateFirst: PropTypes.Requireable<boolean>;
|
|
61
62
|
weekStartsOn: PropTypes.Requireable<number>;
|
|
@@ -111,6 +112,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
111
112
|
stopPropagation: boolean;
|
|
112
113
|
motion: boolean;
|
|
113
114
|
prefixCls: "semi-datepicker";
|
|
115
|
+
presetPosition: string;
|
|
114
116
|
zIndex: number;
|
|
115
117
|
type: string;
|
|
116
118
|
size: string;
|
|
@@ -172,6 +174,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
172
174
|
disabledDisposeTime: MonthsGridProps['disabledTime'];
|
|
173
175
|
renderMonthGrid(locale: Locale['DatePicker'], localeCode: string, dateFnsLocale: Locale['dateFnsLocale']): JSX.Element;
|
|
174
176
|
renderQuickControls(): JSX.Element;
|
|
177
|
+
renderDateInput(): JSX.Element;
|
|
175
178
|
handleOpenPanel: () => void;
|
|
176
179
|
handleInputChange: DatePickerFoundation['handleInputChange'];
|
|
177
180
|
handleInsetInputChange: (options: InsetInputChangeProps) => void;
|
|
@@ -190,7 +190,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
190
190
|
type,
|
|
191
191
|
format,
|
|
192
192
|
rangeSeparator,
|
|
193
|
-
defaultPickerValue
|
|
193
|
+
defaultPickerValue,
|
|
194
|
+
presetPosition
|
|
194
195
|
} = this.props;
|
|
195
196
|
const {
|
|
196
197
|
insetInputValue,
|
|
@@ -222,9 +223,7 @@ class DatePicker extends _baseComponent.default {
|
|
|
222
223
|
}, topSlot && /*#__PURE__*/_react.default.createElement("div", {
|
|
223
224
|
className: "".concat(_constants.cssClasses.PREFIX, "-topSlot"),
|
|
224
225
|
"x-semi-prop": "topSlot"
|
|
225
|
-
}, topSlot),
|
|
226
|
-
insetInput: true
|
|
227
|
-
})), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/_react.default.createElement("div", {
|
|
226
|
+
}, topSlot), presetPosition === "top" && this.renderQuickControls(), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), presetPosition === "bottom" && this.renderQuickControls(), bottomSlot && /*#__PURE__*/_react.default.createElement("div", {
|
|
228
227
|
className: "".concat(_constants.cssClasses.PREFIX, "-bottomSlot"),
|
|
229
228
|
"x-semi-prop": "bottomSlot"
|
|
230
229
|
}, bottomSlot), this.renderFooter(locale, localeCode));
|
|
@@ -232,7 +231,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
232
231
|
|
|
233
232
|
this.renderYearMonthPanel = (locale, localeCode) => {
|
|
234
233
|
const {
|
|
235
|
-
density
|
|
234
|
+
density,
|
|
235
|
+
presetPosition
|
|
236
236
|
} = this.props;
|
|
237
237
|
const date = this.state.value[0];
|
|
238
238
|
let year = 0;
|
|
@@ -252,7 +252,10 @@ class DatePicker extends _baseComponent.default {
|
|
|
252
252
|
onSelect: this.handleYMSelectedChange,
|
|
253
253
|
currentYear: year,
|
|
254
254
|
currentMonth: month,
|
|
255
|
-
density: density
|
|
255
|
+
density: density,
|
|
256
|
+
presetPosition: presetPosition,
|
|
257
|
+
renderQuickControls: this.renderQuickControls(),
|
|
258
|
+
renderDateInput: this.renderDateInput()
|
|
256
259
|
});
|
|
257
260
|
};
|
|
258
261
|
|
|
@@ -592,7 +595,8 @@ class DatePicker extends _baseComponent.default {
|
|
|
592
595
|
onPanelChange,
|
|
593
596
|
timeZone,
|
|
594
597
|
triggerRender,
|
|
595
|
-
insetInput
|
|
598
|
+
insetInput,
|
|
599
|
+
presetPosition
|
|
596
600
|
} = this.props;
|
|
597
601
|
const {
|
|
598
602
|
cachedSelectedValue,
|
|
@@ -634,22 +638,63 @@ class DatePicker extends _baseComponent.default {
|
|
|
634
638
|
timeZone: timeZone,
|
|
635
639
|
focusRecordsRef: this.focusRecordsRef,
|
|
636
640
|
triggerRender: triggerRender,
|
|
637
|
-
insetInput: insetInput
|
|
641
|
+
insetInput: insetInput,
|
|
642
|
+
presetPosition: presetPosition,
|
|
643
|
+
renderQuickControls: this.renderQuickControls(),
|
|
644
|
+
renderDateInput: this.renderDateInput()
|
|
638
645
|
});
|
|
639
646
|
}
|
|
640
647
|
|
|
641
648
|
renderQuickControls() {
|
|
642
649
|
const {
|
|
643
650
|
presets,
|
|
644
|
-
type
|
|
651
|
+
type,
|
|
652
|
+
presetPosition,
|
|
653
|
+
insetInput
|
|
645
654
|
} = this.props;
|
|
646
655
|
return /*#__PURE__*/_react.default.createElement(_quickControl.default, {
|
|
647
656
|
type: type,
|
|
648
657
|
presets: presets,
|
|
658
|
+
insetInput: insetInput,
|
|
659
|
+
presetPosition: presetPosition,
|
|
649
660
|
onPresetClick: (item, e) => this.foundation.handlePresetClick(item, e)
|
|
650
661
|
});
|
|
651
662
|
}
|
|
652
663
|
|
|
664
|
+
renderDateInput() {
|
|
665
|
+
const {
|
|
666
|
+
insetInput,
|
|
667
|
+
dateFnsLocale,
|
|
668
|
+
density,
|
|
669
|
+
type,
|
|
670
|
+
format,
|
|
671
|
+
rangeSeparator,
|
|
672
|
+
defaultPickerValue
|
|
673
|
+
} = this.props;
|
|
674
|
+
const {
|
|
675
|
+
insetInputValue,
|
|
676
|
+
value
|
|
677
|
+
} = this.state;
|
|
678
|
+
const insetInputProps = {
|
|
679
|
+
dateFnsLocale,
|
|
680
|
+
format,
|
|
681
|
+
insetInputValue,
|
|
682
|
+
rangeSeparator,
|
|
683
|
+
type,
|
|
684
|
+
value: value,
|
|
685
|
+
handleInsetDateFocus: this.handleInsetDateFocus,
|
|
686
|
+
handleInsetTimeFocus: this.handleInsetTimeFocus,
|
|
687
|
+
onInsetInputChange: this.handleInsetInputChange,
|
|
688
|
+
rangeInputStartRef: this.rangeInputStartRef,
|
|
689
|
+
rangeInputEndRef: this.rangeInputEndRef,
|
|
690
|
+
density,
|
|
691
|
+
defaultPickerValue
|
|
692
|
+
};
|
|
693
|
+
return insetInput ? /*#__PURE__*/_react.default.createElement(_dateInput.default, (0, _assign.default)({}, insetInputProps, {
|
|
694
|
+
insetInput: true
|
|
695
|
+
})) : null;
|
|
696
|
+
}
|
|
697
|
+
|
|
653
698
|
renderInner(extraProps) {
|
|
654
699
|
var _context3, _context4;
|
|
655
700
|
|
|
@@ -791,6 +836,7 @@ DatePicker.propTypes = {
|
|
|
791
836
|
max: _propTypes.default.number,
|
|
792
837
|
placeholder: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
|
|
793
838
|
presets: _propTypes.default.array,
|
|
839
|
+
presetPosition: _propTypes.default.oneOf(_constants.strings.PRESET_POSITION_SET),
|
|
794
840
|
onChange: _propTypes.default.func,
|
|
795
841
|
onChangeWithDateFirst: _propTypes.default.bool,
|
|
796
842
|
weekStartsOn: _propTypes.default.number,
|
|
@@ -848,6 +894,7 @@ DatePicker.defaultProps = {
|
|
|
848
894
|
stopPropagation: true,
|
|
849
895
|
motion: true,
|
|
850
896
|
prefixCls: _constants.cssClasses.PREFIX,
|
|
897
|
+
presetPosition: 'bottom',
|
|
851
898
|
// position: 'bottomLeft',
|
|
852
899
|
zIndex: _constants2.numbers.DEFAULT_Z_INDEX,
|
|
853
900
|
type: 'date',
|
|
@@ -50,6 +50,9 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
50
50
|
onPanelChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
51
51
|
focusRecordsRef: PropTypes.Requireable<object>;
|
|
52
52
|
triggerRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
|
+
presetPosition: PropTypes.Requireable<"top" | "left" | "right" | "bottom">;
|
|
54
|
+
renderQuickControls: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
55
|
+
renderDateInput: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
53
56
|
};
|
|
54
57
|
static defaultProps: {
|
|
55
58
|
type: string;
|
|
@@ -647,7 +647,10 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
647
647
|
} = this.state;
|
|
648
648
|
const {
|
|
649
649
|
type,
|
|
650
|
-
insetInput
|
|
650
|
+
insetInput,
|
|
651
|
+
presetPosition,
|
|
652
|
+
renderQuickControls,
|
|
653
|
+
renderDateInput
|
|
651
654
|
} = this.props;
|
|
652
655
|
const monthGridCls = (0, _classnames.default)({
|
|
653
656
|
["".concat(prefixCls, "-month-grid")]: true
|
|
@@ -666,12 +669,17 @@ class MonthsGrid extends _baseComponent.default {
|
|
|
666
669
|
|
|
667
670
|
const yearOpenType = this.getYAMOpenType();
|
|
668
671
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
672
|
+
style: {
|
|
673
|
+
display: 'flex'
|
|
674
|
+
}
|
|
675
|
+
}, presetPosition === "left" && renderQuickControls, /*#__PURE__*/_react.default.createElement("div", null, renderDateInput, /*#__PURE__*/_react.default.createElement("div", {
|
|
669
676
|
className: monthGridCls,
|
|
670
677
|
"x-type": type,
|
|
671
678
|
"x-panel-yearandmonth-open-type": yearOpenType,
|
|
672
679
|
"x-insetinput": insetInput ? "true" : "false",
|
|
680
|
+
"x-preset-position": renderQuickControls === null ? 'null' : presetPosition,
|
|
673
681
|
ref: current => this.cacheRefCurrent('monthGrid', current)
|
|
674
|
-
}, content);
|
|
682
|
+
}, content)), presetPosition === "right" && renderQuickControls);
|
|
675
683
|
}
|
|
676
684
|
|
|
677
685
|
}
|
|
@@ -713,7 +721,10 @@ MonthsGrid.propTypes = {
|
|
|
713
721
|
// Callback function for panel date switching
|
|
714
722
|
onPanelChange: _propTypes.default.func,
|
|
715
723
|
focusRecordsRef: _propTypes.default.object,
|
|
716
|
-
triggerRender: _propTypes.default.func
|
|
724
|
+
triggerRender: _propTypes.default.func,
|
|
725
|
+
presetPosition: _propTypes.default.oneOf(_constants.strings.PRESET_POSITION_SET),
|
|
726
|
+
renderQuickControls: _propTypes.default.node,
|
|
727
|
+
renderDateInput: _propTypes.default.node
|
|
717
728
|
};
|
|
718
729
|
MonthsGrid.defaultProps = {
|
|
719
730
|
type: 'date',
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { strings } from '@douyinfe/semi-foundation/lib/cjs/datePicker/constants';
|
|
3
4
|
import { noop } from '@douyinfe/semi-foundation/lib/cjs/utils/function';
|
|
4
5
|
import { PresetsType, PresetType } from '@douyinfe/semi-foundation/lib/cjs/datePicker/foundation';
|
|
5
6
|
export interface QuickControlProps {
|
|
6
7
|
presets: PresetsType;
|
|
8
|
+
presetPosition: typeof strings.PRESET_POSITION_SET[number];
|
|
7
9
|
onPresetClick: (preset: PresetType, e: React.MouseEvent) => void;
|
|
8
10
|
type: string;
|
|
11
|
+
insetInput: boolean;
|
|
9
12
|
}
|
|
10
13
|
declare class QuickControl extends PureComponent<QuickControlProps> {
|
|
11
14
|
static propTypes: {
|
|
12
15
|
presets: PropTypes.Requireable<any[]>;
|
|
16
|
+
presetPosition: PropTypes.Requireable<"top" | "left" | "right" | "bottom">;
|
|
13
17
|
onPresetClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
18
|
type: PropTypes.Requireable<string>;
|
|
19
|
+
insetInput: PropTypes.Requireable<boolean>;
|
|
15
20
|
};
|
|
16
21
|
static defaultProps: {
|
|
17
22
|
presets: PresetsType;
|
|
23
|
+
presetPosition: string;
|
|
18
24
|
onPresetClick: typeof noop;
|
|
19
25
|
};
|
|
20
26
|
render(): JSX.Element;
|
|
@@ -28,6 +28,8 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/datePicker/constants
|
|
|
28
28
|
|
|
29
29
|
var _index = _interopRequireDefault(require("../button/index"));
|
|
30
30
|
|
|
31
|
+
var _index2 = _interopRequireDefault(require("../typography/index"));
|
|
32
|
+
|
|
31
33
|
var _function = require("@douyinfe/semi-foundation/lib/cjs/utils/function");
|
|
32
34
|
|
|
33
35
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -36,51 +38,96 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
38
|
|
|
37
39
|
/* eslint-disable jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events */
|
|
38
40
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
41
|
+
const {
|
|
42
|
+
Text
|
|
43
|
+
} = _index2.default;
|
|
39
44
|
|
|
40
45
|
class QuickControl extends _react.PureComponent {
|
|
41
46
|
render() {
|
|
42
|
-
var _context;
|
|
47
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12;
|
|
43
48
|
|
|
44
49
|
const {
|
|
45
50
|
presets,
|
|
46
51
|
onPresetClick,
|
|
47
|
-
type
|
|
52
|
+
type,
|
|
53
|
+
presetPosition,
|
|
54
|
+
insetInput
|
|
48
55
|
} = this.props;
|
|
56
|
+
const isTypeRange = type === 'dateRange' || type === 'dateTimeRange';
|
|
57
|
+
const isPanelTopAndBottom = presetPosition === 'top' || presetPosition === 'bottom';
|
|
58
|
+
const isMonth = type === 'month';
|
|
59
|
+
const isTopAndBottomRange = isPanelTopAndBottom && isTypeRange;
|
|
60
|
+
const isTopAndBottomMonth = isPanelTopAndBottom && isMonth;
|
|
49
61
|
const wrapperCls = (0, _classnames.default)("".concat(prefixCls, "-quick-control"), {
|
|
50
|
-
[(0, _concat.default)(_context = "".concat(prefixCls, "-quick-control-")).call(_context, type)]: type
|
|
62
|
+
[(0, _concat.default)(_context = "".concat(prefixCls, "-quick-control-")).call(_context, type)]: type,
|
|
63
|
+
[(0, _concat.default)(_context2 = "".concat(prefixCls, "-quick-control-")).call(_context2, presetPosition)]: true
|
|
64
|
+
});
|
|
65
|
+
const headerCls = (0, _classnames.default)({
|
|
66
|
+
["".concat(prefixCls, "-quick-control-header")]: true
|
|
67
|
+
});
|
|
68
|
+
const contentWrapperCls = (0, _classnames.default)({
|
|
69
|
+
[(0, _concat.default)(_context3 = "".concat(prefixCls, "-quick-control-")).call(_context3, presetPosition, "-content-wrapper")]: true
|
|
70
|
+
});
|
|
71
|
+
const contentCls = (0, _classnames.default)({
|
|
72
|
+
[(0, _concat.default)(_context4 = "".concat(prefixCls, "-quick-control-")).call(_context4, presetPosition, "-content")]: !isTopAndBottomRange && !isTopAndBottomMonth,
|
|
73
|
+
[(0, _concat.default)(_context5 = "".concat(prefixCls, "-quick-control-")).call(_context5, presetPosition, "-range-content")]: isTopAndBottomRange,
|
|
74
|
+
[(0, _concat.default)(_context6 = "".concat(prefixCls, "-quick-control-")).call(_context6, presetPosition, "-month-content")]: isTopAndBottomMonth
|
|
75
|
+
});
|
|
76
|
+
const itemCls = (0, _classnames.default)({
|
|
77
|
+
[(0, _concat.default)(_context7 = "".concat(prefixCls, "-quick-control-")).call(_context7, presetPosition, "-content-item")]: !isTopAndBottomRange && !isTopAndBottomMonth,
|
|
78
|
+
[(0, _concat.default)(_context8 = "".concat(prefixCls, "-quick-control-")).call(_context8, presetPosition, "-range-content-item")]: isTopAndBottomRange,
|
|
79
|
+
[(0, _concat.default)(_context9 = "".concat(prefixCls, "-quick-control-")).call(_context9, presetPosition, "-month-content-item")]: isTopAndBottomMonth
|
|
80
|
+
});
|
|
81
|
+
const ellipsisCls = (0, _classnames.default)({
|
|
82
|
+
[(0, _concat.default)(_context10 = "".concat(prefixCls, "-quick-control-")).call(_context10, presetPosition, "-content-item-ellipsis")]: !isTopAndBottomRange && !isTopAndBottomMonth,
|
|
83
|
+
[(0, _concat.default)(_context11 = "".concat(prefixCls, "-quick-control-")).call(_context11, presetPosition, "-range-content-item-ellipsis")]: isTopAndBottomRange,
|
|
84
|
+
[(0, _concat.default)(_context12 = "".concat(prefixCls, "-quick-control-")).call(_context12, presetPosition, "-month-content-item-ellipsis")]: isTopAndBottomMonth
|
|
51
85
|
});
|
|
52
|
-
const itemCls = (0, _classnames.default)("".concat(prefixCls, "-quick-control-item"));
|
|
53
86
|
|
|
54
87
|
if (!presets.length) {
|
|
55
88
|
return null;
|
|
56
89
|
}
|
|
57
90
|
|
|
58
91
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
-
className: wrapperCls
|
|
92
|
+
className: wrapperCls,
|
|
93
|
+
"x-insetinput": insetInput ? "true" : "false"
|
|
94
|
+
}, !isPanelTopAndBottom && /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: headerCls
|
|
96
|
+
}, "\u5FEB\u6377\u9009\u62E9"), /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
className: contentWrapperCls
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
className: contentCls
|
|
60
100
|
}, (0, _map.default)(presets).call(presets, (item, index) => {
|
|
61
101
|
const _item = typeof item === 'function' ? item() : item;
|
|
62
102
|
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
64
|
-
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
104
|
+
size: "small",
|
|
105
|
+
type: "primary",
|
|
65
106
|
onClick: e => onPresetClick(_item, e),
|
|
66
107
|
key: index
|
|
67
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
className: itemCls
|
|
110
|
+
}, /*#__PURE__*/_react.default.createElement(Text, {
|
|
111
|
+
ellipsis: {
|
|
112
|
+
showTooltip: true
|
|
113
|
+
},
|
|
114
|
+
className: ellipsisCls
|
|
115
|
+
}, _item.text)));
|
|
116
|
+
}))));
|
|
73
117
|
}
|
|
74
118
|
|
|
75
119
|
}
|
|
76
120
|
|
|
77
121
|
QuickControl.propTypes = {
|
|
78
122
|
presets: _propTypes.default.array,
|
|
123
|
+
presetPosition: _propTypes.default.oneOf(_constants.strings.PRESET_POSITION_SET),
|
|
79
124
|
onPresetClick: _propTypes.default.func,
|
|
80
|
-
type: _propTypes.default.string
|
|
125
|
+
type: _propTypes.default.string,
|
|
126
|
+
insetInput: _propTypes.default.bool
|
|
81
127
|
};
|
|
82
128
|
QuickControl.defaultProps = {
|
|
83
129
|
presets: [],
|
|
130
|
+
presetPosition: 'bottom',
|
|
84
131
|
onPresetClick: _function.noop
|
|
85
132
|
};
|
|
86
133
|
var _default = QuickControl;
|
|
@@ -20,6 +20,9 @@ declare class YearAndMonth extends BaseComponent<YearAndMonthProps, YearAndMonth
|
|
|
20
20
|
noBackBtn: PropTypes.Requireable<boolean>;
|
|
21
21
|
disabledDate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
22
|
density: PropTypes.Requireable<string>;
|
|
23
|
+
presetPosition: PropTypes.Requireable<"top" | "left" | "right" | "bottom">;
|
|
24
|
+
renderQuickControls: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
25
|
+
renderDateInput: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
23
26
|
};
|
|
24
27
|
static defaultProps: {
|
|
25
28
|
disabledDate: {
|
|
@@ -50,6 +50,8 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/base/constants");
|
|
|
50
50
|
|
|
51
51
|
var _dateFns = require("date-fns");
|
|
52
52
|
|
|
53
|
+
var _constants2 = require("@douyinfe/semi-foundation/lib/cjs/datePicker/constants");
|
|
54
|
+
|
|
53
55
|
/* eslint-disable max-len */
|
|
54
56
|
const prefixCls = "".concat(_constants.BASE_CLASS_PREFIX, "-datepicker");
|
|
55
57
|
|
|
@@ -237,7 +239,10 @@ class YearAndMonth extends _baseComponent.default {
|
|
|
237
239
|
const {
|
|
238
240
|
locale,
|
|
239
241
|
noBackBtn,
|
|
240
|
-
density
|
|
242
|
+
density,
|
|
243
|
+
presetPosition,
|
|
244
|
+
renderQuickControls,
|
|
245
|
+
renderDateInput
|
|
241
246
|
} = this.props;
|
|
242
247
|
const prefix = "".concat(prefixCls, "-yearmonth-header"); // i18n
|
|
243
248
|
|
|
@@ -254,7 +259,11 @@ class YearAndMonth extends _baseComponent.default {
|
|
|
254
259
|
}),
|
|
255
260
|
size: buttonSize,
|
|
256
261
|
onClick: this.backToMain
|
|
257
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, selectDateText))), /*#__PURE__*/_react.default.createElement(
|
|
262
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, selectDateText))), presetPosition ? /*#__PURE__*/_react.default.createElement("div", {
|
|
263
|
+
style: {
|
|
264
|
+
display: 'flex'
|
|
265
|
+
}
|
|
266
|
+
}, presetPosition === "left" && renderQuickControls, /*#__PURE__*/_react.default.createElement("div", null, renderDateInput, /*#__PURE__*/_react.default.createElement(_index.default, null, this.renderColYear(), this.renderColMonth())), presetPosition === "right" && renderQuickControls) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderDateInput, /*#__PURE__*/_react.default.createElement(_index.default, null, this.renderColYear(), this.renderColMonth())));
|
|
258
267
|
}
|
|
259
268
|
|
|
260
269
|
}
|
|
@@ -269,7 +278,10 @@ YearAndMonth.propTypes = {
|
|
|
269
278
|
yearCycled: _propTypes.default.bool,
|
|
270
279
|
noBackBtn: _propTypes.default.bool,
|
|
271
280
|
disabledDate: _propTypes.default.func,
|
|
272
|
-
density: _propTypes.default.string
|
|
281
|
+
density: _propTypes.default.string,
|
|
282
|
+
presetPosition: _propTypes.default.oneOf(_constants2.strings.PRESET_POSITION_SET),
|
|
283
|
+
renderQuickControls: _propTypes.default.node,
|
|
284
|
+
renderDateInput: _propTypes.default.node
|
|
273
285
|
};
|
|
274
286
|
YearAndMonth.defaultProps = {
|
|
275
287
|
disabledDate: _stubFalse2.default,
|
package/lib/cjs/empty/index.js
CHANGED
|
@@ -88,7 +88,7 @@ class Empty extends _baseComponent.default {
|
|
|
88
88
|
darkModeImage
|
|
89
89
|
} = this.props;
|
|
90
90
|
const alt = typeof description === 'string' ? description : 'empty';
|
|
91
|
-
const imgSrc = this.state.mode && darkModeImage ? darkModeImage : image;
|
|
91
|
+
const imgSrc = this.state.mode === 'dark' && darkModeImage ? darkModeImage : image;
|
|
92
92
|
let imageNode = null;
|
|
93
93
|
|
|
94
94
|
if (typeof imgSrc === 'string') {
|