@douyinfe/semi-ui 2.41.3 → 2.42.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/semi.css +27 -7
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1245 -1496
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/button/splitButtonGroup.d.ts +2 -0
- package/lib/cjs/button/splitButtonGroup.js +14 -0
- package/lib/cjs/collapse/item.d.ts +2 -1
- package/lib/cjs/collapse/item.js +4 -1
- package/lib/cjs/form/baseForm.d.ts +12 -10
- package/lib/cjs/form/baseForm.js +17 -13
- package/lib/cjs/form/hoc/withField.js +13 -11
- package/lib/cjs/form/interface.d.ts +5 -3
- package/lib/cjs/inputNumber/index.js +1 -1
- package/lib/cjs/modal/confirm.d.ts +1 -1
- package/lib/cjs/table/ResizableHeaderCell.d.ts +2 -0
- package/lib/cjs/table/ResizableHeaderCell.js +6 -4
- package/lib/cjs/table/TableHeader.d.ts +2 -2
- package/lib/cjs/table/TableHeaderRow.d.ts +2 -1
- package/lib/cjs/table/TableHeaderRow.js +3 -0
- package/lib/cjs/table/interface.d.ts +2 -1
- package/lib/cjs/toast/index.d.ts +18 -0
- package/lib/cjs/toast/index.js +49 -4
- package/lib/cjs/toast/toast.d.ts +11 -0
- package/lib/cjs/toast/toast.js +22 -2
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +2 -1
- package/lib/cjs/tree/treeNode.js +1 -2
- package/lib/cjs/typography/base.js +1 -3
- package/lib/cjs/upload/fileCard.d.ts +13 -2
- package/lib/cjs/upload/fileCard.js +52 -11
- package/lib/cjs/upload/index.d.ts +4 -0
- package/lib/cjs/upload/index.js +16 -4
- package/lib/es/button/splitButtonGroup.d.ts +2 -0
- package/lib/es/button/splitButtonGroup.js +14 -0
- package/lib/es/collapse/item.d.ts +2 -1
- package/lib/es/collapse/item.js +4 -1
- package/lib/es/form/baseForm.d.ts +12 -10
- package/lib/es/form/baseForm.js +17 -13
- package/lib/es/form/hoc/withField.js +14 -12
- package/lib/es/form/interface.d.ts +5 -3
- package/lib/es/inputNumber/index.js +1 -1
- package/lib/es/modal/confirm.d.ts +1 -1
- package/lib/es/table/ResizableHeaderCell.d.ts +2 -0
- package/lib/es/table/ResizableHeaderCell.js +6 -4
- package/lib/es/table/TableHeader.d.ts +2 -2
- package/lib/es/table/TableHeaderRow.d.ts +2 -1
- package/lib/es/table/TableHeaderRow.js +3 -0
- package/lib/es/table/interface.d.ts +2 -1
- package/lib/es/toast/index.d.ts +18 -0
- package/lib/es/toast/index.js +49 -4
- package/lib/es/toast/toast.d.ts +11 -0
- package/lib/es/toast/toast.js +22 -2
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tooltip/index.js +2 -1
- package/lib/es/tree/treeNode.js +1 -2
- package/lib/es/typography/base.js +1 -3
- package/lib/es/upload/fileCard.d.ts +13 -2
- package/lib/es/upload/fileCard.js +52 -9
- package/lib/es/upload/index.d.ts +4 -0
- package/lib/es/upload/index.js +16 -4
- package/package.json +2 -2
|
@@ -6,10 +6,12 @@ export interface SplitButtonGroupProps extends BaseProps {
|
|
|
6
6
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
7
7
|
}
|
|
8
8
|
export default class SplitButtonGroup extends BaseComponent<SplitButtonGroupProps> {
|
|
9
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
9
10
|
static propTypes: {
|
|
10
11
|
style: PropTypes.Requireable<object>;
|
|
11
12
|
className: PropTypes.Requireable<string>;
|
|
12
13
|
'aria-label': PropTypes.Requireable<string>;
|
|
13
14
|
};
|
|
15
|
+
componentDidMount(): void;
|
|
14
16
|
render(): JSX.Element;
|
|
15
17
|
}
|
|
@@ -13,6 +13,19 @@ var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
15
15
|
class SplitButtonGroup extends _baseComponent.default {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.containerRef = /*#__PURE__*/_react.default.createRef();
|
|
19
|
+
}
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
if (this.containerRef.current) {
|
|
22
|
+
const buttons = this.containerRef.current.querySelectorAll('button');
|
|
23
|
+
const firstButton = buttons[0];
|
|
24
|
+
const lastButton = buttons[buttons.length - 1];
|
|
25
|
+
firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.add(`${prefixCls}-first`);
|
|
26
|
+
lastButton === null || lastButton === void 0 ? void 0 : lastButton.classList.add(`${prefixCls}-last`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
render() {
|
|
17
30
|
const {
|
|
18
31
|
children,
|
|
@@ -21,6 +34,7 @@ class SplitButtonGroup extends _baseComponent.default {
|
|
|
21
34
|
} = this.props;
|
|
22
35
|
const cls = (0, _classnames.default)(`${prefixCls}-split`, className);
|
|
23
36
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
+
ref: this.containerRef,
|
|
24
38
|
className: cls,
|
|
25
39
|
style: style,
|
|
26
40
|
role: "group",
|
|
@@ -15,6 +15,7 @@ export interface CollapsePanelProps {
|
|
|
15
15
|
export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
16
16
|
static contextType: React.Context<CollapseContextType>;
|
|
17
17
|
headerExpandIconTriggerRef: React.RefObject<HTMLElement>;
|
|
18
|
+
private ariaID;
|
|
18
19
|
static propTypes: {
|
|
19
20
|
itemKey: PropTypes.Requireable<string>;
|
|
20
21
|
extra: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -28,8 +29,8 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
28
29
|
showArrow: boolean;
|
|
29
30
|
disabled: boolean;
|
|
30
31
|
};
|
|
31
|
-
private ariaID;
|
|
32
32
|
context: CollapseContextType;
|
|
33
|
+
componentDidMount(): void;
|
|
33
34
|
renderHeader(active: boolean, expandIconEnable?: boolean): JSX.Element;
|
|
34
35
|
handleClick: (itemKey: string, e: React.MouseEvent) => void;
|
|
35
36
|
render(): JSX.Element;
|
package/lib/cjs/collapse/item.js
CHANGED
|
@@ -27,7 +27,7 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
this.headerExpandIconTriggerRef = /*#__PURE__*/_react.default.createRef();
|
|
30
|
-
this.ariaID =
|
|
30
|
+
this.ariaID = "";
|
|
31
31
|
this.handleClick = (itemKey, e) => {
|
|
32
32
|
var _a;
|
|
33
33
|
// Judge user click Icon or Header
|
|
@@ -37,6 +37,9 @@ class CollapsePanel extends _react.PureComponent {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
+
componentDidMount() {
|
|
41
|
+
this.ariaID = (0, _uuid.getUuidShort)({});
|
|
42
|
+
}
|
|
40
43
|
renderHeader(active) {
|
|
41
44
|
let expandIconEnable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
42
45
|
const {
|
|
@@ -19,25 +19,27 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
|
|
|
19
19
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
20
|
onReset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
21
|
onValueChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
autoScrollToError: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
23
|
+
allowEmpty: PropTypes.Requireable<boolean>;
|
|
24
|
+
className: PropTypes.Requireable<string>;
|
|
24
25
|
component: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
25
|
-
|
|
26
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
27
|
+
extraTextPosition: PropTypes.Requireable<string>;
|
|
28
|
+
getFormApi: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
+
initValues: PropTypes.Requireable<object>;
|
|
26
30
|
validateFields: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
style: PropTypes.Requireable<object>;
|
|
28
|
-
className: PropTypes.Requireable<string>;
|
|
29
31
|
layout: PropTypes.Requireable<string>;
|
|
30
32
|
labelPosition: PropTypes.Requireable<string>;
|
|
31
33
|
labelWidth: PropTypes.Requireable<NonNullable<string | number>>;
|
|
32
34
|
labelAlign: PropTypes.Requireable<string>;
|
|
33
35
|
labelCol: PropTypes.Requireable<object>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
autoScrollToError: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
37
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
36
|
+
render: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
+
style: PropTypes.Requireable<object>;
|
|
38
38
|
showValidateIcon: PropTypes.Requireable<boolean>;
|
|
39
|
-
|
|
39
|
+
stopValidateWithError: PropTypes.Requireable<boolean>;
|
|
40
40
|
id: PropTypes.Requireable<string>;
|
|
41
|
+
wrapperCol: PropTypes.Requireable<object>;
|
|
42
|
+
trigger: PropTypes.Requireable<NonNullable<string | string[]>>;
|
|
41
43
|
};
|
|
42
44
|
static defaultProps: {
|
|
43
45
|
onChange: (...args: any[]) => void;
|
package/lib/cjs/form/baseForm.js
CHANGED
|
@@ -171,10 +171,12 @@ class Form extends _baseComponent.default {
|
|
|
171
171
|
allowEmpty,
|
|
172
172
|
autoScrollToError,
|
|
173
173
|
showValidateIcon,
|
|
174
|
+
stopValidateWithError,
|
|
174
175
|
extraTextPosition,
|
|
175
|
-
id
|
|
176
|
+
id,
|
|
177
|
+
trigger
|
|
176
178
|
} = _a,
|
|
177
|
-
rest = __rest(_a, ["children", "getFormApi", "onChange", "onSubmit", "onSubmitFail", "onValueChange", "component", "render", "validateFields", "initValues", "layout", "style", "className", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "allowEmpty", "autoScrollToError", "showValidateIcon", "extraTextPosition", "id"]);
|
|
179
|
+
rest = __rest(_a, ["children", "getFormApi", "onChange", "onSubmit", "onSubmitFail", "onValueChange", "component", "render", "validateFields", "initValues", "layout", "style", "className", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "allowEmpty", "autoScrollToError", "showValidateIcon", "stopValidateWithError", "extraTextPosition", "id", "trigger"]);
|
|
178
180
|
const formCls = (0, _classnames.default)(prefix, className, {
|
|
179
181
|
[prefix + '-vertical']: layout === 'vertical',
|
|
180
182
|
[prefix + '-horizontal']: layout === 'horizontal'
|
|
@@ -207,25 +209,27 @@ Form.propTypes = {
|
|
|
207
209
|
onReset: _propTypes.default.func,
|
|
208
210
|
// Triggered when the value of the form is updated, only when the value of the subfield changes. The entry parameter is formState.values
|
|
209
211
|
onValueChange: _propTypes.default.func,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
autoScrollToError: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
|
|
213
|
+
allowEmpty: _propTypes.default.bool,
|
|
214
|
+
className: _propTypes.default.string,
|
|
212
215
|
component: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
213
|
-
|
|
216
|
+
disabled: _propTypes.default.bool,
|
|
217
|
+
extraTextPosition: _propTypes.default.oneOf(_constants.strings.EXTRA_POS),
|
|
218
|
+
getFormApi: _propTypes.default.func,
|
|
219
|
+
initValues: _propTypes.default.object,
|
|
214
220
|
validateFields: _propTypes.default.func,
|
|
215
|
-
style: _propTypes.default.object,
|
|
216
|
-
className: _propTypes.default.string,
|
|
217
221
|
layout: _propTypes.default.oneOf(_constants.strings.LAYOUT),
|
|
218
222
|
labelPosition: _propTypes.default.oneOf(_constants.strings.LABEL_POS),
|
|
219
223
|
labelWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
220
224
|
labelAlign: _propTypes.default.oneOf(_constants.strings.LABEL_ALIGN),
|
|
221
225
|
labelCol: _propTypes.default.object,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
autoScrollToError: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
|
|
225
|
-
disabled: _propTypes.default.bool,
|
|
226
|
+
render: _propTypes.default.func,
|
|
227
|
+
style: _propTypes.default.object,
|
|
226
228
|
showValidateIcon: _propTypes.default.bool,
|
|
227
|
-
|
|
228
|
-
id: _propTypes.default.string
|
|
229
|
+
stopValidateWithError: _propTypes.default.bool,
|
|
230
|
+
id: _propTypes.default.string,
|
|
231
|
+
wrapperCol: _propTypes.default.object,
|
|
232
|
+
trigger: _propTypes.default.oneOfType([_propTypes.default.oneOf(['blur', 'change', 'custom', 'mount']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['blur', 'change', 'custom', 'mount']))])
|
|
229
233
|
};
|
|
230
234
|
Form.defaultProps = {
|
|
231
235
|
onChange: _noop2.default,
|
|
@@ -88,6 +88,15 @@ function withField(Component, opts) {
|
|
|
88
88
|
(0, _warning.default)(true, '[Semi Form]: Field Component must be use inside the Form, please check your dom declaration');
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
+
let formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'labelCol', 'wrapperCol', 'disabled', 'showValidateIcon', 'extraTextPosition', 'stopValidateWithError', 'trigger']);
|
|
92
|
+
let mergeLabelPos = labelPosition || formProps.labelPosition;
|
|
93
|
+
let mergeLabelWidth = labelWidth || formProps.labelWidth;
|
|
94
|
+
let mergeLabelAlign = labelAlign || formProps.labelAlign;
|
|
95
|
+
let mergeLabelCol = labelCol || formProps.labelCol;
|
|
96
|
+
let mergeWrapperCol = wrapperCol || formProps.wrapperCol;
|
|
97
|
+
let mergeExtraPos = extraTextPosition || formProps.extraTextPosition || 'bottom';
|
|
98
|
+
let mergeStopValidateWithError = (0, _utils.transformDefaultBooleanAPI)(stopValidateWithError, formProps.stopValidateWithError, false);
|
|
99
|
+
let mergeTrigger = (0, _utils.transformTrigger)(trigger, formProps.trigger);
|
|
91
100
|
// To prevent user forgetting to pass the field, use undefined as the key, and updater.getValue will get the wrong value.
|
|
92
101
|
let initValueInFormOpts = typeof field !== 'undefined' ? updater.getValue(field) : undefined; // Get the init value of form from formP rops.init Values Get the initial value set in the initValues of Form
|
|
93
102
|
let initVal = typeof initValue !== 'undefined' ? initValue : initValueInFormOpts;
|
|
@@ -101,7 +110,7 @@ function withField(Component, opts) {
|
|
|
101
110
|
} catch (err) {}
|
|
102
111
|
// FIXME typeof initVal
|
|
103
112
|
const [value, setValue, getVal] = (0, _index.useStateWithGetter)(typeof initVal !== undefined ? initVal : null);
|
|
104
|
-
const validateOnMount =
|
|
113
|
+
const validateOnMount = mergeTrigger.includes('mount');
|
|
105
114
|
allowEmpty = allowEmpty || updater.getFormProps().allowEmpty;
|
|
106
115
|
// Error information: Array, String, undefined
|
|
107
116
|
const [error, setError, getError] = (0, _index.useStateWithGetter)();
|
|
@@ -160,7 +169,7 @@ function withField(Component, opts) {
|
|
|
160
169
|
};
|
|
161
170
|
const rootPromise = new Promise((resolve, reject) => {
|
|
162
171
|
validator.validate(model, {
|
|
163
|
-
first:
|
|
172
|
+
first: mergeStopValidateWithError
|
|
164
173
|
}, (errors, fields) => {}).then(res => {
|
|
165
174
|
if (validatePromise.current !== rootPromise) {
|
|
166
175
|
return;
|
|
@@ -308,7 +317,7 @@ function withField(Component, opts) {
|
|
|
308
317
|
});
|
|
309
318
|
updateValue(val);
|
|
310
319
|
// only validate when trigger includes change
|
|
311
|
-
if (
|
|
320
|
+
if (mergeTrigger.includes('change')) {
|
|
312
321
|
fieldValidate(val);
|
|
313
322
|
}
|
|
314
323
|
};
|
|
@@ -319,7 +328,7 @@ function withField(Component, opts) {
|
|
|
319
328
|
if (!touched) {
|
|
320
329
|
updateTouched(true);
|
|
321
330
|
}
|
|
322
|
-
if (
|
|
331
|
+
if (mergeTrigger.includes('blur')) {
|
|
323
332
|
let val = getVal();
|
|
324
333
|
fieldValidate(val);
|
|
325
334
|
}
|
|
@@ -379,13 +388,6 @@ function withField(Component, opts) {
|
|
|
379
388
|
};
|
|
380
389
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
381
390
|
}, [field]);
|
|
382
|
-
let formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'labelCol', 'wrapperCol', 'disabled', 'showValidateIcon', 'extraTextPosition']);
|
|
383
|
-
let mergeLabelPos = labelPosition || formProps.labelPosition;
|
|
384
|
-
let mergeLabelWidth = labelWidth || formProps.labelWidth;
|
|
385
|
-
let mergeLabelAlign = labelAlign || formProps.labelAlign;
|
|
386
|
-
let mergeLabelCol = labelCol || formProps.labelCol;
|
|
387
|
-
let mergeWrapperCol = wrapperCol || formProps.wrapperCol;
|
|
388
|
-
let mergeExtraPos = extraTextPosition || formProps.extraTextPosition || 'bottom';
|
|
389
391
|
// id attribute to improve a11y
|
|
390
392
|
const a11yId = id ? id : field;
|
|
391
393
|
const labelId = `${a11yId}-label`;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Subtract } from 'utility-types';
|
|
3
3
|
import type { RuleItem } from 'async-validator';
|
|
4
4
|
import type { Options as ScrollIntoViewOptions } from 'scroll-into-view-if-needed';
|
|
5
|
-
import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
|
|
5
|
+
import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors, FieldValidateTriggerType } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
|
|
6
6
|
import type { SelectProps } from '../select/index';
|
|
7
7
|
import Option from '../select/option';
|
|
8
8
|
import OptGroup from '../select/optionGroup';
|
|
@@ -88,6 +88,7 @@ export interface BaseFormProps<Values extends Record<string, any> = any> extends
|
|
|
88
88
|
onReset?: () => void;
|
|
89
89
|
onValueChange?: (values: Values, changedValue: Partial<Values>) => void;
|
|
90
90
|
onChange?: (formState: FormState<Values>) => void;
|
|
91
|
+
allowEmpty?: boolean;
|
|
91
92
|
validateFields?: (values: Values) => string | Partial<AllErrors<Values>>;
|
|
92
93
|
/** Use this if you want to populate the form with initial values. */
|
|
93
94
|
initValues?: Values;
|
|
@@ -96,18 +97,19 @@ export interface BaseFormProps<Values extends Record<string, any> = any> extends
|
|
|
96
97
|
getFormApi?: (formApi: FormApi<Values>) => void;
|
|
97
98
|
style?: React.CSSProperties;
|
|
98
99
|
className?: string;
|
|
100
|
+
extraTextPosition?: 'middle' | 'bottom';
|
|
99
101
|
layout?: 'horizontal' | 'vertical';
|
|
100
102
|
labelPosition?: 'top' | 'left' | 'inset';
|
|
101
103
|
labelWidth?: number | string;
|
|
102
104
|
labelAlign?: 'left' | 'right';
|
|
103
105
|
labelCol?: Record<string, any>;
|
|
104
106
|
wrapperCol?: Record<string, any>;
|
|
105
|
-
allowEmpty?: boolean;
|
|
106
107
|
render?: (internalProps: FormFCChild) => React.ReactNode;
|
|
107
108
|
component?: React.FC<any> | React.ComponentClass<any>;
|
|
108
109
|
children?: React.ReactNode | ((internalProps: FormFCChild) => React.ReactNode);
|
|
109
110
|
autoScrollToError?: boolean | ScrollIntoViewOptions;
|
|
110
111
|
disabled?: boolean;
|
|
111
112
|
showValidateIcon?: boolean;
|
|
112
|
-
|
|
113
|
+
stopValidateWithError?: boolean;
|
|
114
|
+
trigger?: FieldValidateTriggerType;
|
|
113
115
|
}
|
|
@@ -259,7 +259,7 @@ class InputNumber extends _baseComponent.default {
|
|
|
259
259
|
} else {
|
|
260
260
|
let valueStr = value;
|
|
261
261
|
if (typeof value === 'number') {
|
|
262
|
-
valueStr =
|
|
262
|
+
valueStr = this.foundation.doFormat(value);
|
|
263
263
|
}
|
|
264
264
|
const parsedNum = this.foundation.doParse(valueStr, false, true, true);
|
|
265
265
|
const toNum = typeof value === 'number' ? value : this.foundation.doParse(valueStr, false, false, false);
|
|
@@ -382,6 +382,7 @@ export declare function withError(props: ModalReactProps): {
|
|
|
382
382
|
formMethod?: string;
|
|
383
383
|
formNoValidate?: boolean;
|
|
384
384
|
formTarget?: string;
|
|
385
|
+
contextMenu?: string;
|
|
385
386
|
dir?: string;
|
|
386
387
|
draggable?: boolean | "true" | "false";
|
|
387
388
|
lang?: string;
|
|
@@ -395,7 +396,6 @@ export declare function withError(props: ModalReactProps): {
|
|
|
395
396
|
'aria-haspopup'?: boolean | "dialog" | "menu" | "grid" | "listbox" | "tree" | "true" | "false";
|
|
396
397
|
'aria-controls'?: string;
|
|
397
398
|
'aria-describedby'?: string;
|
|
398
|
-
contextMenu?: string;
|
|
399
399
|
placeholder?: string;
|
|
400
400
|
spellCheck?: boolean | "true" | "false";
|
|
401
401
|
radioGroup?: string;
|
|
@@ -5,6 +5,8 @@ export interface ResizableHeaderCellProps {
|
|
|
5
5
|
onResizeStart?: ResizeFn;
|
|
6
6
|
onResizeStop?: ResizeFn;
|
|
7
7
|
width?: number | string;
|
|
8
|
+
/** For compatibility with previous versions, the default value is true. If you don't want to resize, set it to false */
|
|
9
|
+
resize?: boolean;
|
|
8
10
|
}
|
|
9
11
|
declare class ResizableHeaderCell extends React.PureComponent<ResizableHeaderCellProps> {
|
|
10
12
|
render(): JSX.Element;
|
|
@@ -22,10 +22,11 @@ class ResizableHeaderCell extends _react.default.PureComponent {
|
|
|
22
22
|
onResize,
|
|
23
23
|
onResizeStart,
|
|
24
24
|
onResizeStop,
|
|
25
|
-
width
|
|
25
|
+
width,
|
|
26
|
+
resize
|
|
26
27
|
} = _a,
|
|
27
|
-
restProps = __rest(_a, ["onResize", "onResizeStart", "onResizeStop", "width"]);
|
|
28
|
-
if (typeof width !== 'number') {
|
|
28
|
+
restProps = __rest(_a, ["onResize", "onResizeStart", "onResizeStop", "width", "resize"]);
|
|
29
|
+
if (typeof width !== 'number' || resize === false) {
|
|
29
30
|
return /*#__PURE__*/_react.default.createElement("th", Object.assign({}, restProps));
|
|
30
31
|
}
|
|
31
32
|
let {
|
|
@@ -43,7 +44,8 @@ class ResizableHeaderCell extends _react.default.PureComponent {
|
|
|
43
44
|
onResizeStop: onResizeStop,
|
|
44
45
|
draggableOpts: {
|
|
45
46
|
enableUserSelectHack: false
|
|
46
|
-
}
|
|
47
|
+
},
|
|
48
|
+
axis: 'x'
|
|
47
49
|
}, /*#__PURE__*/_react.default.createElement("th", Object.assign({}, restProps), children));
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { BaseProps } from '../_base/baseComponent';
|
|
3
|
-
import { Fixed, TableComponents, OnHeaderRow } from './interface';
|
|
3
|
+
import { Fixed, TableComponents, OnHeaderRow, ColumnProps } from './interface';
|
|
4
4
|
export interface TableHeaderProps extends BaseProps {
|
|
5
5
|
columns?: any[];
|
|
6
6
|
components?: TableComponents;
|
|
@@ -15,7 +15,7 @@ export interface TableHeaderCell {
|
|
|
15
15
|
key: string | number;
|
|
16
16
|
className: string;
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
column:
|
|
18
|
+
column: ColumnProps;
|
|
19
19
|
colStart: number;
|
|
20
20
|
level: number;
|
|
21
21
|
parents: any[];
|
|
@@ -3,9 +3,10 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import BaseComponent from '../_base/baseComponent';
|
|
4
4
|
import { TableContextProps } from './table-context';
|
|
5
5
|
import { TableComponents, OnHeaderRow, Fixed } from './interface';
|
|
6
|
+
import type { TableHeaderCell } from './TableHeader';
|
|
6
7
|
export interface TableHeaderRowProps {
|
|
7
8
|
components?: TableComponents;
|
|
8
|
-
row?:
|
|
9
|
+
row?: TableHeaderCell[];
|
|
9
10
|
prefixCls?: string;
|
|
10
11
|
onHeaderRow?: OnHeaderRow<any>;
|
|
11
12
|
index?: number;
|
|
@@ -138,6 +138,9 @@ class TableHeaderRow extends _baseComponent.default {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
Object.assign(cellProps, {
|
|
142
|
+
resize: column.resize
|
|
143
|
+
});
|
|
141
144
|
const props = (0, _omit2.default)(Object.assign(Object.assign({}, cellProps), customProps), ['colStart', 'colEnd', 'hasSubColumns', 'parents', 'level']);
|
|
142
145
|
const {
|
|
143
146
|
rowSpan,
|
|
@@ -90,6 +90,7 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
90
90
|
onFilterDropdownVisibleChange?: OnFilterDropdownVisibleChange;
|
|
91
91
|
onHeaderCell?: OnHeaderCell<RecordType>;
|
|
92
92
|
ellipsis?: BaseEllipsis;
|
|
93
|
+
resize?: boolean;
|
|
93
94
|
}
|
|
94
95
|
export type Align = BaseAlign;
|
|
95
96
|
export type SortOrder = BaseSortOrder;
|
|
@@ -103,7 +104,7 @@ export type Fixed = BaseFixed;
|
|
|
103
104
|
export type OnCell<RecordType> = (record?: RecordType, rowIndex?: number) => OnCellReturnObject;
|
|
104
105
|
export type OnFilter<RecordType> = (filteredValue?: any, record?: RecordType) => boolean;
|
|
105
106
|
export type OnFilterDropdownVisibleChange = (visible?: boolean) => void;
|
|
106
|
-
export type OnHeaderCell<RecordType> = (record?: RecordType, columnIndex?: number) => OnHeaderCellReturnObject;
|
|
107
|
+
export type OnHeaderCell<RecordType> = (record?: RecordType, columnIndex?: number, index?: number) => OnHeaderCellReturnObject;
|
|
107
108
|
export type ColumnRender<RecordType> = (text: any, record: RecordType, index: number, options?: RenderOptions) => ColumnRenderReturnType;
|
|
108
109
|
export type RenderFilterDropdownItem = (itemInfo?: FilterDropdownItem) => ReactNode;
|
|
109
110
|
export type Sorter<RecordType> = BaseSorter<RecordType>;
|
package/lib/cjs/toast/index.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export interface ToastReactProps extends ToastProps {
|
|
|
13
13
|
export type { ConfigProps, ToastListProps, ToastListState, ToastState };
|
|
14
14
|
declare const createBaseToast: () => {
|
|
15
15
|
new (props: ToastListProps): {
|
|
16
|
+
stack: boolean;
|
|
17
|
+
innerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
16
18
|
readonly adapter: ToastListAdapter;
|
|
19
|
+
handleMouseEnter: (e: React.MouseEvent) => void;
|
|
20
|
+
handleMouseLeave: (e: React.MouseEvent) => void;
|
|
17
21
|
has(id: string): any;
|
|
18
22
|
add(opts: ToastInstance): any;
|
|
19
23
|
update(id: string, opts: ToastInstance): any;
|
|
@@ -47,7 +51,11 @@ declare const createBaseToast: () => {
|
|
|
47
51
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<ToastListProps>, nextState: Readonly<ToastListState>, nextContext: any): void;
|
|
48
52
|
};
|
|
49
53
|
ref: {
|
|
54
|
+
stack: boolean;
|
|
55
|
+
innerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
50
56
|
readonly adapter: ToastListAdapter;
|
|
57
|
+
handleMouseEnter: (e: React.MouseEvent) => void;
|
|
58
|
+
handleMouseLeave: (e: React.MouseEvent) => void;
|
|
51
59
|
has(id: string): any;
|
|
52
60
|
add(opts: ToastInstance): any;
|
|
53
61
|
update(id: string, opts: ToastInstance): any;
|
|
@@ -90,6 +98,7 @@ declare const createBaseToast: () => {
|
|
|
90
98
|
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
91
99
|
icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
92
100
|
direction: PropTypes.Requireable<string>;
|
|
101
|
+
stack: PropTypes.Requireable<boolean>;
|
|
93
102
|
};
|
|
94
103
|
defaultProps: {};
|
|
95
104
|
wrapperId: null | string;
|
|
@@ -109,7 +118,11 @@ export declare class ToastFactory {
|
|
|
109
118
|
}
|
|
110
119
|
declare const _default: {
|
|
111
120
|
new (props: ToastListProps): {
|
|
121
|
+
stack: boolean;
|
|
122
|
+
innerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
112
123
|
readonly adapter: ToastListAdapter;
|
|
124
|
+
handleMouseEnter: (e: React.MouseEvent<Element, MouseEvent>) => void;
|
|
125
|
+
handleMouseLeave: (e: React.MouseEvent<Element, MouseEvent>) => void;
|
|
113
126
|
has(id: string): any;
|
|
114
127
|
add(opts: ToastInstance): any;
|
|
115
128
|
update(id: string, opts: ToastInstance): any;
|
|
@@ -143,7 +156,11 @@ declare const _default: {
|
|
|
143
156
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<ToastListProps>, nextState: Readonly<ToastListState>, nextContext: any): void;
|
|
144
157
|
};
|
|
145
158
|
ref: {
|
|
159
|
+
stack: boolean;
|
|
160
|
+
innerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
146
161
|
readonly adapter: ToastListAdapter;
|
|
162
|
+
handleMouseEnter: (e: React.MouseEvent<Element, MouseEvent>) => void;
|
|
163
|
+
handleMouseLeave: (e: React.MouseEvent<Element, MouseEvent>) => void;
|
|
147
164
|
has(id: string): any;
|
|
148
165
|
add(opts: ToastInstance): any;
|
|
149
166
|
update(id: string, opts: ToastInstance): any;
|
|
@@ -186,6 +203,7 @@ declare const _default: {
|
|
|
186
203
|
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
187
204
|
icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
188
205
|
direction: PropTypes.Requireable<string>;
|
|
206
|
+
stack: PropTypes.Requireable<boolean>;
|
|
189
207
|
};
|
|
190
208
|
defaultProps: {};
|
|
191
209
|
wrapperId: string;
|
package/lib/cjs/toast/index.js
CHANGED
|
@@ -22,10 +22,27 @@ const createBaseToast = () => {
|
|
|
22
22
|
return _a = class ToastList extends _baseComponent.default {
|
|
23
23
|
constructor(props) {
|
|
24
24
|
super(props);
|
|
25
|
+
this.stack = false;
|
|
26
|
+
this.innerWrapperRef = /*#__PURE__*/_react.default.createRef();
|
|
27
|
+
this.handleMouseEnter = e => {
|
|
28
|
+
if (this.stack) {
|
|
29
|
+
this.foundation.handleMouseInSideChange(true);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this.handleMouseLeave = e => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (this.stack) {
|
|
35
|
+
const height = (_a = this.foundation.getInputWrapperRect()) === null || _a === void 0 ? void 0 : _a.height;
|
|
36
|
+
if (height) {
|
|
37
|
+
this.foundation.handleMouseInSideChange(false);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
25
41
|
this.state = {
|
|
26
42
|
list: [],
|
|
27
43
|
removedItems: [],
|
|
28
|
-
updatedItems: []
|
|
44
|
+
updatedItems: [],
|
|
45
|
+
mouseInSide: false
|
|
29
46
|
};
|
|
30
47
|
this.foundation = new _toastListFoundation.default(this.adapter);
|
|
31
48
|
}
|
|
@@ -37,6 +54,15 @@ const createBaseToast = () => {
|
|
|
37
54
|
removedItems,
|
|
38
55
|
updatedItems
|
|
39
56
|
});
|
|
57
|
+
},
|
|
58
|
+
handleMouseInSideChange: mouseInSide => {
|
|
59
|
+
this.setState({
|
|
60
|
+
mouseInSide
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
getInputWrapperRect: () => {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = this.innerWrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
40
66
|
}
|
|
41
67
|
});
|
|
42
68
|
}
|
|
@@ -71,6 +97,7 @@ const createBaseToast = () => {
|
|
|
71
97
|
ToastList.ref.add(Object.assign(Object.assign({}, opts), {
|
|
72
98
|
id
|
|
73
99
|
}));
|
|
100
|
+
ToastList.ref.stack = Boolean(opts.stack);
|
|
74
101
|
});
|
|
75
102
|
} else {
|
|
76
103
|
const node = document.querySelector(`#${this.wrapperId}`);
|
|
@@ -79,6 +106,9 @@ const createBaseToast = () => {
|
|
|
79
106
|
node.style[pos] = typeof opts[pos] === 'number' ? `${opts[pos]}px` : opts[pos];
|
|
80
107
|
}
|
|
81
108
|
});
|
|
109
|
+
if (Boolean(opts.stack) !== ToastList.ref.stack) {
|
|
110
|
+
ToastList.ref.stack = Boolean(opts.stack);
|
|
111
|
+
}
|
|
82
112
|
if (ToastList.ref.has(id)) {
|
|
83
113
|
ToastList.ref.update(id, Object.assign(Object.assign({}, opts), {
|
|
84
114
|
id
|
|
@@ -204,7 +234,15 @@ const createBaseToast = () => {
|
|
|
204
234
|
toast.foundation.restartCloseTimer();
|
|
205
235
|
}
|
|
206
236
|
};
|
|
207
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
237
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
238
|
+
className: (0, _classnames.default)({
|
|
239
|
+
[`${_constants.cssClasses.PREFIX}-innerWrapper`]: true,
|
|
240
|
+
[`${_constants.cssClasses.PREFIX}-innerWrapper-hover`]: this.state.mouseInSide
|
|
241
|
+
}),
|
|
242
|
+
ref: this.innerWrapperRef,
|
|
243
|
+
onMouseEnter: this.handleMouseEnter,
|
|
244
|
+
onMouseLeave: this.handleMouseLeave
|
|
245
|
+
}, list.map((item, index) => {
|
|
208
246
|
const isRemoved = removedItems.find(removedItem => removedItem.id === item.id) !== undefined;
|
|
209
247
|
return /*#__PURE__*/_react.default.createElement(_cssAnimation.default, {
|
|
210
248
|
key: item.id,
|
|
@@ -218,6 +256,12 @@ const createBaseToast = () => {
|
|
|
218
256
|
isAnimating
|
|
219
257
|
} = _ref2;
|
|
220
258
|
return isRemoved && !isAnimating ? null : /*#__PURE__*/_react.default.createElement(_toast.default, Object.assign({}, item, {
|
|
259
|
+
stack: this.stack,
|
|
260
|
+
stackExpanded: this.state.mouseInSide,
|
|
261
|
+
positionInList: {
|
|
262
|
+
length: list.length,
|
|
263
|
+
index
|
|
264
|
+
},
|
|
221
265
|
className: (0, _classnames.default)({
|
|
222
266
|
[item.className]: Boolean(item.className),
|
|
223
267
|
[animationClassName]: true
|
|
@@ -228,7 +272,7 @@ const createBaseToast = () => {
|
|
|
228
272
|
ref: refFn
|
|
229
273
|
}));
|
|
230
274
|
});
|
|
231
|
-
}));
|
|
275
|
+
})));
|
|
232
276
|
}
|
|
233
277
|
}, _a.defaultOpts = {
|
|
234
278
|
motion: true,
|
|
@@ -239,7 +283,8 @@ const createBaseToast = () => {
|
|
|
239
283
|
duration: _propTypes.default.number,
|
|
240
284
|
onClose: _propTypes.default.func,
|
|
241
285
|
icon: _propTypes.default.node,
|
|
242
|
-
direction: _propTypes.default.oneOf(_constants.strings.directions)
|
|
286
|
+
direction: _propTypes.default.oneOf(_constants.strings.directions),
|
|
287
|
+
stack: _propTypes.default.bool
|
|
243
288
|
}, _a.defaultProps = {}, _a;
|
|
244
289
|
};
|
|
245
290
|
class ToastFactory {
|
package/lib/cjs/toast/toast.d.ts
CHANGED
|
@@ -7,10 +7,17 @@ export interface ToastReactProps extends ToastProps {
|
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
icon?: React.ReactNode;
|
|
9
9
|
content: React.ReactNode;
|
|
10
|
+
stack?: boolean;
|
|
11
|
+
stackExpanded?: boolean;
|
|
10
12
|
onAnimationEnd?: (e: React.AnimationEvent) => void;
|
|
11
13
|
onAnimationStart?: (e: React.AnimationEvent) => void;
|
|
14
|
+
positionInList?: {
|
|
15
|
+
index: number;
|
|
16
|
+
length: number;
|
|
17
|
+
};
|
|
12
18
|
}
|
|
13
19
|
declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
20
|
+
toastEle: React.RefObject<HTMLDivElement>;
|
|
14
21
|
static contextType: React.Context<ContextValue>;
|
|
15
22
|
static propTypes: {
|
|
16
23
|
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -23,6 +30,8 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
23
30
|
style: PropTypes.Requireable<object>;
|
|
24
31
|
className: PropTypes.Requireable<string>;
|
|
25
32
|
showClose: PropTypes.Requireable<boolean>;
|
|
33
|
+
stack: PropTypes.Requireable<boolean>;
|
|
34
|
+
stackExpanded: PropTypes.Requireable<boolean>;
|
|
26
35
|
icon: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
27
36
|
direction: PropTypes.Requireable<string>;
|
|
28
37
|
};
|
|
@@ -33,6 +42,8 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
|
|
|
33
42
|
duration: number;
|
|
34
43
|
textMaxWidth: number;
|
|
35
44
|
showClose: boolean;
|
|
45
|
+
stack: boolean;
|
|
46
|
+
stackExpanded: boolean;
|
|
36
47
|
theme: string;
|
|
37
48
|
};
|
|
38
49
|
constructor(props: ToastReactProps);
|