@dtjoy/dt-design 1.0.3 → 1.0.4
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/esm/formList/index.d.ts +77 -0
- package/esm/formList/index.js +141 -0
- package/esm/formList/style/index.d.ts +2 -0
- package/esm/formList/style/index.js +2 -0
- package/esm/formList/style/index.less +45 -0
- package/esm/index.d.ts +4 -2
- package/esm/index.js +5 -46
- package/esm/splitter/Splitter.js +8 -19
- package/esm/splitter/hooks/sizeUtil.js +20 -4
- package/esm/splitter/hooks/useSizes.js +2 -2
- package/esm/splitter/interface.d.ts +1 -0
- package/lib/formList/index.d.ts +77 -0
- package/lib/formList/index.js +128 -0
- package/lib/formList/style/index.d.ts +2 -0
- package/lib/formList/style/index.js +4 -0
- package/lib/formList/style/index.less +45 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.js +23 -4
- package/lib/splitter/Splitter.js +5 -19
- package/lib/splitter/hooks/sizeUtil.js +12 -0
- package/lib/splitter/hooks/useSizes.js +2 -2
- package/lib/splitter/interface.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { type FormListFieldData, type TableProps } from 'antd';
|
|
3
|
+
import type { FormItemProps, FormListProps, RuleObject, RuleRender } from 'antd/lib/form';
|
|
4
|
+
import type { ColumnType as TableColumnType } from 'antd/lib/table';
|
|
5
|
+
import './style';
|
|
6
|
+
declare type NotNullRowSelection = NonNullable<TableProps<any>['rowSelection']>;
|
|
7
|
+
/**
|
|
8
|
+
* Override NamePath parameters type
|
|
9
|
+
*/
|
|
10
|
+
declare type OverrideParameters = (string | number)[];
|
|
11
|
+
declare type RcFormInstance = Parameters<RuleRender>[0];
|
|
12
|
+
declare type RawPanelRender = NonNullable<TableProps<any>['footer']>;
|
|
13
|
+
/**
|
|
14
|
+
* Override PanelRender type
|
|
15
|
+
*/
|
|
16
|
+
declare type PanelRenderFunc = (...args: Parameters<FormListProps['children']>) => ReturnType<RawPanelRender>;
|
|
17
|
+
/**
|
|
18
|
+
* Form.Table 组件类型
|
|
19
|
+
*/
|
|
20
|
+
export interface IFormTableProps
|
|
21
|
+
/**
|
|
22
|
+
* Support all FormListProps except children for which is re-defined in this component
|
|
23
|
+
* and prefixCls for which is not expected to be supported
|
|
24
|
+
*/
|
|
25
|
+
extends Pick<FormListProps, 'name' | 'rules' | 'initialValue'>,
|
|
26
|
+
/**
|
|
27
|
+
* Support all TableProps except
|
|
28
|
+
* - re-define columns and re-defined rowSelection
|
|
29
|
+
* - and pagination which is expect to be not supported in Form.Table
|
|
30
|
+
* - and className which is renamed to tableClassName
|
|
31
|
+
* - and rowKey, dataSource for which are defined and not allowed to be modified
|
|
32
|
+
* - and footer, title, summary for which are re-defined to pass form's operation
|
|
33
|
+
*/
|
|
34
|
+
Omit<TableProps<any>, 'columns' | 'rowSelection' | 'pagination' | 'className' | 'rowKey' | 'dataSource' | 'footer' | 'title' | 'summary'> {
|
|
35
|
+
/**
|
|
36
|
+
* 表格列的配置描述
|
|
37
|
+
*/
|
|
38
|
+
columns?: ColumnType[] | ((...args: Parameters<FormListProps['children']>) => ColumnType[]);
|
|
39
|
+
/**
|
|
40
|
+
* Table 的 className
|
|
41
|
+
*/
|
|
42
|
+
tableClassName?: TableProps<any>['className'];
|
|
43
|
+
/**
|
|
44
|
+
* 表格行是否可选择
|
|
45
|
+
*/
|
|
46
|
+
rowSelection?: Omit<NotNullRowSelection, 'getCheckboxProps'> & {
|
|
47
|
+
getCheckboxProps?: (field: FormListFieldData) => ReturnType<NonNullable<NotNullRowSelection['getCheckboxProps']>>;
|
|
48
|
+
};
|
|
49
|
+
title?: PanelRenderFunc;
|
|
50
|
+
footer?: PanelRenderFunc;
|
|
51
|
+
summary?: PanelRenderFunc;
|
|
52
|
+
}
|
|
53
|
+
export interface ColumnType
|
|
54
|
+
/**
|
|
55
|
+
* Support all FormItemProps, and re-defined `rules` and `dependencies`
|
|
56
|
+
*/
|
|
57
|
+
extends Omit<FormItemProps, 'rules' | 'dependencies' | 'prefixCls' | 'children'>,
|
|
58
|
+
/**
|
|
59
|
+
* Support all TableColumnType, and re-defined `render`
|
|
60
|
+
*/
|
|
61
|
+
Omit<TableColumnType<FormListFieldData>, 'render'> {
|
|
62
|
+
/**
|
|
63
|
+
* 设置依赖字段, 支持通过回调函数获取当前字段名
|
|
64
|
+
*/
|
|
65
|
+
dependencies?: ((namePath: OverrideParameters) => FormItemProps['dependencies']) | FormItemProps['dependencies'];
|
|
66
|
+
/**
|
|
67
|
+
* 校验规则,设置字段的校验逻辑,支持通过回调函数获取当前字段名
|
|
68
|
+
*/
|
|
69
|
+
rules?: (RuleObject | ((form: RcFormInstance, namePath: OverrideParameters) => RuleObject))[];
|
|
70
|
+
/**
|
|
71
|
+
* 渲染函数
|
|
72
|
+
* @param formInstance 只有在设置了 `dependencies` 的情况下才有该参数
|
|
73
|
+
*/
|
|
74
|
+
render?: (fieldData: FormListFieldData, namePath: OverrideParameters, formInstance?: RcFormInstance) => ReactNode;
|
|
75
|
+
}
|
|
76
|
+
export default function InternalTable({ name, rules, initialValue, ...tableProps }: IFormTableProps): React.JSX.Element;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var _excluded = ["name", "rules", "initialValue"],
|
|
2
|
+
_excluded2 = ["tableClassName", "columns", "title", "footer", "summary"],
|
|
3
|
+
_excluded3 = ["noStyle", "style", "className", "id", "hasFeedback", "validateStatus", "required", "hidden", "initialValue", "messageVariables", "tooltip", "dependencies", "rules", "validateFirst", "validateTrigger", "valuePropName", "render"];
|
|
4
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
+
import React, { useMemo } from 'react';
|
|
14
|
+
import { Utils } from '@dtinsight/dt-utils';
|
|
15
|
+
import { Form, Table } from 'antd';
|
|
16
|
+
import { globalConfig } from 'antd/es/config-provider';
|
|
17
|
+
import classnames from 'classnames';
|
|
18
|
+
import "./style";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Override NamePath parameters type
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Override PanelRender type
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Form.Table 组件类型
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export default function InternalTable(_ref) {
|
|
33
|
+
var name = _ref.name,
|
|
34
|
+
rules = _ref.rules,
|
|
35
|
+
initialValue = _ref.initialValue,
|
|
36
|
+
tableProps = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
var tableClassName = tableProps.tableClassName,
|
|
38
|
+
rawColumns = tableProps.columns,
|
|
39
|
+
title = tableProps.title,
|
|
40
|
+
footer = tableProps.footer,
|
|
41
|
+
summary = tableProps.summary,
|
|
42
|
+
restProps = _objectWithoutProperties(tableProps, _excluded2);
|
|
43
|
+
var prefixCls = globalConfig().getPrefixCls('form-list');
|
|
44
|
+
var formInstance = Form.useFormInstance();
|
|
45
|
+
var convertRawToTableCol = function convertRawToTableCol(raw) {
|
|
46
|
+
if (!(raw !== null && raw !== void 0 && raw.length)) return [];
|
|
47
|
+
return raw.map(function (_ref2) {
|
|
48
|
+
var noStyle = _ref2.noStyle,
|
|
49
|
+
style = _ref2.style,
|
|
50
|
+
className = _ref2.className,
|
|
51
|
+
id = _ref2.id,
|
|
52
|
+
hasFeedback = _ref2.hasFeedback,
|
|
53
|
+
validateStatus = _ref2.validateStatus,
|
|
54
|
+
required = _ref2.required,
|
|
55
|
+
hidden = _ref2.hidden,
|
|
56
|
+
initialValue = _ref2.initialValue,
|
|
57
|
+
messageVariables = _ref2.messageVariables,
|
|
58
|
+
tooltip = _ref2.tooltip,
|
|
59
|
+
dependencies = _ref2.dependencies,
|
|
60
|
+
rawRules = _ref2.rules,
|
|
61
|
+
validateFirst = _ref2.validateFirst,
|
|
62
|
+
validateTrigger = _ref2.validateTrigger,
|
|
63
|
+
valuePropName = _ref2.valuePropName,
|
|
64
|
+
_render = _ref2.render,
|
|
65
|
+
cols = _objectWithoutProperties(_ref2, _excluded3);
|
|
66
|
+
var formItemProps = {
|
|
67
|
+
noStyle: noStyle,
|
|
68
|
+
style: style,
|
|
69
|
+
className: className,
|
|
70
|
+
id: id,
|
|
71
|
+
hasFeedback: hasFeedback,
|
|
72
|
+
validateStatus: validateStatus,
|
|
73
|
+
required: required,
|
|
74
|
+
hidden: hidden,
|
|
75
|
+
initialValue: initialValue,
|
|
76
|
+
messageVariables: messageVariables,
|
|
77
|
+
validateFirst: validateFirst,
|
|
78
|
+
validateTrigger: validateTrigger,
|
|
79
|
+
tooltip: tooltip,
|
|
80
|
+
valuePropName: valuePropName
|
|
81
|
+
};
|
|
82
|
+
var isRequired = required || (rawRules === null || rawRules === void 0 ? void 0 : rawRules.some(function (rule) {
|
|
83
|
+
return _typeof(rule) === 'object' && rule.required;
|
|
84
|
+
}));
|
|
85
|
+
return _objectSpread(_objectSpread({}, cols), {}, {
|
|
86
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, isRequired && /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
className: "dtc-form__table__column--required"
|
|
88
|
+
}), cols.title),
|
|
89
|
+
render: function render(_, fieldData) {
|
|
90
|
+
var currentNamePath = [fieldData.name, cols.dataIndex].filter(Utils.checkExist).flat();
|
|
91
|
+
var rules = rawRules === null || rawRules === void 0 ? void 0 : rawRules.map(function (rule) {
|
|
92
|
+
return typeof rule === 'function' ? function (form) {
|
|
93
|
+
return rule(form, currentNamePath);
|
|
94
|
+
} : rule;
|
|
95
|
+
});
|
|
96
|
+
if (dependencies) {
|
|
97
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
98
|
+
noStyle: true,
|
|
99
|
+
dependencies: typeof dependencies === 'function' ? dependencies(currentNamePath) : dependencies
|
|
100
|
+
}, function (formInstance) {
|
|
101
|
+
return /*#__PURE__*/React.createElement(Form.Item, _extends({
|
|
102
|
+
name: currentNamePath,
|
|
103
|
+
rules: rules
|
|
104
|
+
}, formItemProps), _render === null || _render === void 0 ? void 0 : _render(fieldData, currentNamePath, formInstance));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React.createElement(Form.Item, _extends({
|
|
108
|
+
name: currentNamePath,
|
|
109
|
+
rules: rules
|
|
110
|
+
}, formItemProps), _render === null || _render === void 0 ? void 0 : _render(fieldData, currentNamePath, formInstance));
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
var columns = useMemo(function () {
|
|
116
|
+
if (typeof rawColumns === 'function') return rawColumns;
|
|
117
|
+
return convertRawToTableCol(rawColumns);
|
|
118
|
+
}, [rawColumns]);
|
|
119
|
+
return /*#__PURE__*/React.createElement(Form.List, {
|
|
120
|
+
name: name,
|
|
121
|
+
rules: rules,
|
|
122
|
+
initialValue: initialValue
|
|
123
|
+
}, function (fields, ope, meta) {
|
|
124
|
+
return /*#__PURE__*/React.createElement(Table, _extends({
|
|
125
|
+
className: classnames(prefixCls, tableClassName),
|
|
126
|
+
rowKey: "key",
|
|
127
|
+
dataSource: fields,
|
|
128
|
+
pagination: false,
|
|
129
|
+
columns: typeof columns === 'function' ? convertRawToTableCol(columns(fields, ope, meta)) : columns,
|
|
130
|
+
footer: footer ? function () {
|
|
131
|
+
return footer(fields, ope, meta);
|
|
132
|
+
} : undefined,
|
|
133
|
+
title: title ? function () {
|
|
134
|
+
return title(fields, ope, meta);
|
|
135
|
+
} : undefined,
|
|
136
|
+
summary: summary ? function () {
|
|
137
|
+
return summary(fields, ope, meta);
|
|
138
|
+
} : undefined
|
|
139
|
+
}, restProps));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
|
|
3
|
+
@form-list-prefix-cls: ~'@{ant-prefix}-form-list';
|
|
4
|
+
|
|
5
|
+
.@{form-list-prefix-cls} {
|
|
6
|
+
height: 100%;
|
|
7
|
+
|
|
8
|
+
&__column {
|
|
9
|
+
&--required {
|
|
10
|
+
&::before {
|
|
11
|
+
content: "*";
|
|
12
|
+
display: inline-block;
|
|
13
|
+
margin-inline-end: 4px;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
color: @error-color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
vertical-align: -0.1em;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ant-table,
|
|
24
|
+
.ant-table-container {
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ant-form-item {
|
|
29
|
+
margin-bottom: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
table colgroup > col.ant-table-selection-col {
|
|
33
|
+
width: 48px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ant-table-thead > tr > th.ant-table-selection-column {
|
|
37
|
+
padding: 0 16px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ant-table-tbody > tr > td.ant-table-selection-column {
|
|
41
|
+
padding: 0 16px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
package/esm/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { default as BlockHeader } from './blockHeader';
|
|
2
2
|
export type { ButtonProps } from './button';
|
|
3
3
|
export { default as Button } from './button';
|
|
4
|
+
export { default as Collapsible } from './collapsible';
|
|
5
|
+
export { default as CollapsibleActionItems } from './collapsibleActionItems';
|
|
4
6
|
export { default as Flex } from './flex';
|
|
5
7
|
export type { FlexProps } from './flex/interface';
|
|
6
|
-
export { default as
|
|
8
|
+
export { default as FormList } from './formList';
|
|
9
|
+
export * from './formList';
|
|
7
10
|
export { default as OverflowList } from './overflowList';
|
|
8
11
|
export { default as Resize } from './resize';
|
|
9
12
|
export { default as Splitter } from './splitter';
|
|
10
13
|
export * from './splitter';
|
|
11
|
-
export { default as Collapsible } from './collapsible';
|
|
12
14
|
export { default as StatusTag } from './statusTag';
|
package/esm/index.js
CHANGED
|
@@ -1,53 +1,12 @@
|
|
|
1
1
|
export { default as BlockHeader } from "./blockHeader";
|
|
2
2
|
export { default as Button } from "./button";
|
|
3
|
-
export { default as
|
|
4
|
-
// export { default as Catalogue } from './catalogue';
|
|
5
|
-
// export { default as Chat } from './chat';
|
|
3
|
+
export { default as Collapsible } from "./collapsible";
|
|
6
4
|
export { default as CollapsibleActionItems } from "./collapsibleActionItems";
|
|
5
|
+
export { default as Flex } from "./flex";
|
|
6
|
+
export { default as FormList } from "./formList";
|
|
7
|
+
export * from "./formList";
|
|
7
8
|
export { default as OverflowList } from "./overflowList";
|
|
8
|
-
// export { default as ConfigProvider } from './configProvider';
|
|
9
|
-
// export { default as ContentLayout } from './contentLayout';
|
|
10
|
-
// export { default as ContextMenu } from './contextMenu';
|
|
11
|
-
// export { default as Copy } from './copy';
|
|
12
|
-
// export { default as Descriptions } from './descriptions';
|
|
13
|
-
// export { default as Drawer } from './drawer';
|
|
14
|
-
// export { default as Dropdown } from './dropdown';
|
|
15
|
-
// export { default as EllipsisText } from './ellipsisText';
|
|
16
|
-
// export { default as Empty } from './empty';
|
|
17
|
-
// export { default as ErrorBoundary } from './errorBoundary';
|
|
18
|
-
// export { default as LoadError } from './errorBoundary/loadError';
|
|
19
|
-
// export { default as FilterRules } from './filterRules';
|
|
20
|
-
// export { default as Flex } from './flex';
|
|
21
|
-
// export type { FlexProps } from './flex/interface';
|
|
22
|
-
// export { default as Float } from './float';
|
|
23
|
-
// export { default as Form } from './form';
|
|
24
|
-
// export { default as Fullscreen } from './fullscreen';
|
|
25
|
-
// export { default as GlobalLoading } from './globalLoading';
|
|
26
|
-
// export { default as Image } from './image';
|
|
27
|
-
// export { default as Input } from './input';
|
|
28
|
-
// export { default as KeyEventListener } from './keyEventListener';
|
|
29
|
-
// export { default as enUS } from './locale/en-US';
|
|
30
|
-
// export { default as useLocale } from './locale/useLocale';
|
|
31
|
-
// export { default as zhCN } from './locale/zh-CN';
|
|
32
|
-
// export { default as MarkdownRender } from './markdownRender';
|
|
33
|
-
// export { default as Modal } from './modal/modal';
|
|
34
|
-
// export { default as NotFound } from './notFound';
|
|
35
|
-
// export { default as ProgressBar } from './progressBar';
|
|
36
|
-
// export { default as ProgressLine } from './progressLine';
|
|
37
9
|
export { default as Resize } from "./resize";
|
|
38
10
|
export { default as Splitter } from "./splitter";
|
|
39
11
|
export * from "./splitter";
|
|
40
|
-
|
|
41
|
-
export { default as Collapsible } from "./collapsible";
|
|
42
|
-
export { default as StatusTag } from "./statusTag";
|
|
43
|
-
// export { default as Table } from './table';
|
|
44
|
-
// export { default as TinyTag } from './tinyTag';
|
|
45
|
-
// export { default as useCookieListener } from './useCookieListener';
|
|
46
|
-
// export { default as useDebounce } from './useDebounce';
|
|
47
|
-
// export { default as useIntersectionObserver } from './useIntersectionObserver';
|
|
48
|
-
// export { default as useList } from './useList';
|
|
49
|
-
// export { default as useMeasure } from './useMeasure';
|
|
50
|
-
// export { default as useMergeOption } from './useMergeOption';
|
|
51
|
-
// export { default as useModal } from './useModal';
|
|
52
|
-
// export { default as useTyping } from './useTyping';
|
|
53
|
-
// export { default as useWindowSwitchListener } from './useWindowSwitchListener';
|
|
12
|
+
export { default as StatusTag } from "./statusTag";
|
package/esm/splitter/Splitter.js
CHANGED
|
@@ -40,16 +40,10 @@ var Splitter = function Splitter(props) {
|
|
|
40
40
|
getPrefixCls = _useContext.getPrefixCls,
|
|
41
41
|
direction = _useContext.direction;
|
|
42
42
|
var prefixCls = getPrefixCls('splitter', customizePrefixCls);
|
|
43
|
-
|
|
44
|
-
// ======================== Direct ========================
|
|
45
43
|
var isVertical = layout === 'vertical';
|
|
46
44
|
var isRTL = direction === 'rtl';
|
|
47
45
|
var reverse = !isVertical && isRTL;
|
|
48
|
-
|
|
49
|
-
// ====================== Items Data ======================
|
|
50
46
|
var items = useItems(children);
|
|
51
|
-
|
|
52
|
-
// >>> Warning 适配 v4
|
|
53
47
|
if (process.env.NODE_ENV !== 'production') {
|
|
54
48
|
var existSize = false;
|
|
55
49
|
var existUndefinedSize = false;
|
|
@@ -64,8 +58,6 @@ var Splitter = function Splitter(props) {
|
|
|
64
58
|
warning(false, 'When part of `Splitter.Panel` has `size`, `onResize` is required or change `size` to `defaultSize`.');
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
|
-
|
|
68
|
-
// ====================== Container =======================
|
|
69
61
|
var _useState = useState(),
|
|
70
62
|
_useState2 = _slicedToArray(_useState, 2),
|
|
71
63
|
containerSize = _useState2[0],
|
|
@@ -79,8 +71,6 @@ var Splitter = function Splitter(props) {
|
|
|
79
71
|
}
|
|
80
72
|
setContainerSize(containerSize);
|
|
81
73
|
};
|
|
82
|
-
|
|
83
|
-
// ========================= Size =========================
|
|
84
74
|
var _useSizes = useSizes(items, containerSize),
|
|
85
75
|
_useSizes2 = _slicedToArray(_useSizes, 6),
|
|
86
76
|
panelSizes = _useSizes2[0],
|
|
@@ -89,8 +79,6 @@ var Splitter = function Splitter(props) {
|
|
|
89
79
|
itemPtgMinSizes = _useSizes2[3],
|
|
90
80
|
itemPtgMaxSizes = _useSizes2[4],
|
|
91
81
|
updateSizes = _useSizes2[5];
|
|
92
|
-
|
|
93
|
-
// ====================== Resizable =======================
|
|
94
82
|
var resizableInfos = useResizable(items, itemPxSizes, isRTL);
|
|
95
83
|
var _useResize = useResize(items, resizableInfos, itemPtgSizes, containerSize, updateSizes, isRTL),
|
|
96
84
|
_useResize2 = _slicedToArray(_useResize, 5),
|
|
@@ -99,8 +87,6 @@ var Splitter = function Splitter(props) {
|
|
|
99
87
|
onOffsetEnd = _useResize2[2],
|
|
100
88
|
onCollapse = _useResize2[3],
|
|
101
89
|
movingIndex = _useResize2[4];
|
|
102
|
-
|
|
103
|
-
// ======================== Events ========================
|
|
104
90
|
var onInternalResizeStart = useEvent(function (index) {
|
|
105
91
|
onOffsetStart(index);
|
|
106
92
|
onResizeStart === null || onResizeStart === void 0 || onResizeStart(itemPxSizes);
|
|
@@ -120,23 +106,27 @@ var Splitter = function Splitter(props) {
|
|
|
120
106
|
}
|
|
121
107
|
});
|
|
122
108
|
var onInternalCollapse = useEvent(function (index, type) {
|
|
109
|
+
var _props$onCollapse;
|
|
123
110
|
var nextSizes = onCollapse(index, type);
|
|
124
111
|
onResize === null || onResize === void 0 || onResize(nextSizes);
|
|
125
112
|
onResizeEnd === null || onResizeEnd === void 0 || onResizeEnd(nextSizes);
|
|
113
|
+
var collapsed = nextSizes.map(function (size) {
|
|
114
|
+
return Math.abs(size) < Number.EPSILON;
|
|
115
|
+
});
|
|
116
|
+
(_props$onCollapse = props.onCollapse) === null || _props$onCollapse === void 0 || _props$onCollapse.call(props, collapsed, nextSizes);
|
|
126
117
|
});
|
|
127
118
|
var containerClassName = classNames(prefixCls, className, "".concat(prefixCls, "-").concat(layout), _defineProperty({}, "".concat(prefixCls, "-rtl"), isRTL), rootClassName);
|
|
128
|
-
|
|
129
|
-
// ======================== Render ========================
|
|
130
119
|
var maskCls = "".concat(prefixCls, "-mask");
|
|
131
120
|
var stackSizes = React.useMemo(function () {
|
|
132
121
|
var mergedSizes = [];
|
|
133
122
|
var stack = 0;
|
|
134
|
-
|
|
123
|
+
var len = items.length;
|
|
124
|
+
for (var i = 0; i < len; i += 1) {
|
|
135
125
|
stack += itemPtgSizes[i];
|
|
136
126
|
mergedSizes.push(stack);
|
|
137
127
|
}
|
|
138
128
|
return mergedSizes;
|
|
139
|
-
}, [itemPtgSizes]);
|
|
129
|
+
}, [itemPtgSizes, items.length]);
|
|
140
130
|
var mergedStyle = _objectSpread({}, style);
|
|
141
131
|
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
142
132
|
onResize: onContainerResize
|
|
@@ -144,7 +134,6 @@ var Splitter = function Splitter(props) {
|
|
|
144
134
|
style: mergedStyle,
|
|
145
135
|
className: containerClassName
|
|
146
136
|
}, items.map(function (item, idx) {
|
|
147
|
-
// Panel
|
|
148
137
|
var panel = /*#__PURE__*/React.createElement(InternalPanel, _extends({}, item, {
|
|
149
138
|
prefixCls: prefixCls,
|
|
150
139
|
size: panelSizes[idx]
|
|
@@ -16,10 +16,26 @@ export function autoPtgSizes(ptgSizes, minPtgSizes, maxPtgSizes) {
|
|
|
16
16
|
});
|
|
17
17
|
var restPtg = 1 - currentTotalPtg;
|
|
18
18
|
var undefinedCount = undefinedIndexes.length;
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
// If all sizes are defined but don't sum to 1, scale them.
|
|
21
|
+
if (ptgSizes.length && !undefinedIndexes.length && currentTotalPtg !== 1) {
|
|
22
|
+
// Handle the case when all sizes are 0
|
|
23
|
+
if (currentTotalPtg === 0) {
|
|
24
|
+
var avg = 1 / ptgSizes.length;
|
|
25
|
+
return ptgSizes.map(function () {
|
|
26
|
+
return avg;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
var scale = 1 / currentTotalPtg;
|
|
30
|
+
// We know `size` is a number here because undefinedIndexes is empty.
|
|
31
|
+
return ptgSizes.map(function (size) {
|
|
32
|
+
return size * scale;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (restPtg < 0) {
|
|
36
|
+
var _scale = 1 / currentTotalPtg;
|
|
21
37
|
return ptgSizes.map(function (size) {
|
|
22
|
-
return size === undefined ? 0 : size *
|
|
38
|
+
return size === undefined ? 0 : size * _scale;
|
|
23
39
|
});
|
|
24
40
|
}
|
|
25
41
|
var sumMin = 0;
|
|
@@ -36,9 +52,9 @@ export function autoPtgSizes(ptgSizes, minPtgSizes, maxPtgSizes) {
|
|
|
36
52
|
limitMax = Math.min(limitMax, max);
|
|
37
53
|
}
|
|
38
54
|
if (sumMin > 1 && sumMax < 1) {
|
|
39
|
-
var
|
|
55
|
+
var _avg = 1 / undefinedCount;
|
|
40
56
|
return ptgSizes.map(function (size) {
|
|
41
|
-
return size === undefined ?
|
|
57
|
+
return size === undefined ? _avg : size;
|
|
42
58
|
});
|
|
43
59
|
}
|
|
44
60
|
var restAvg = restPtg / undefinedCount;
|
|
@@ -69,12 +69,12 @@ export default function useSizes(items, containerSize) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return autoPtgSizes(ptgList, postPercentMinSizes, postPercentMaxSizes);
|
|
72
|
-
}, [sizes, mergedContainerSize, postPercentMinSizes, postPercentMaxSizes]);
|
|
72
|
+
}, [itemsCount, sizes, mergedContainerSize, postPercentMinSizes, postPercentMaxSizes]);
|
|
73
73
|
var postPxSizes = React.useMemo(function () {
|
|
74
74
|
return postPercentSizes.map(ptg2px);
|
|
75
75
|
}, [postPercentSizes, mergedContainerSize]);
|
|
76
76
|
var panelSizes = React.useMemo(function () {
|
|
77
77
|
return containerSize ? postPxSizes : sizes;
|
|
78
|
-
}, [postPxSizes, containerSize]);
|
|
78
|
+
}, [postPxSizes, sizes, containerSize]);
|
|
79
79
|
return [panelSizes, postPxSizes, postPercentSizes, postPercentMinSizes, postPercentMaxSizes, setInnerSizes];
|
|
80
80
|
}
|
|
@@ -9,6 +9,7 @@ export interface SplitterProps {
|
|
|
9
9
|
onResizeStart?: (sizes: number[]) => void;
|
|
10
10
|
onResize?: (sizes: number[]) => void;
|
|
11
11
|
onResizeEnd?: (sizes: number[]) => void;
|
|
12
|
+
onCollapse?: (collapsed: boolean[], sizes: number[]) => void;
|
|
12
13
|
lazy?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export interface PanelProps {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { type FormListFieldData, type TableProps } from 'antd';
|
|
3
|
+
import type { FormItemProps, FormListProps, RuleObject, RuleRender } from 'antd/lib/form';
|
|
4
|
+
import type { ColumnType as TableColumnType } from 'antd/lib/table';
|
|
5
|
+
import './style';
|
|
6
|
+
declare type NotNullRowSelection = NonNullable<TableProps<any>['rowSelection']>;
|
|
7
|
+
/**
|
|
8
|
+
* Override NamePath parameters type
|
|
9
|
+
*/
|
|
10
|
+
declare type OverrideParameters = (string | number)[];
|
|
11
|
+
declare type RcFormInstance = Parameters<RuleRender>[0];
|
|
12
|
+
declare type RawPanelRender = NonNullable<TableProps<any>['footer']>;
|
|
13
|
+
/**
|
|
14
|
+
* Override PanelRender type
|
|
15
|
+
*/
|
|
16
|
+
declare type PanelRenderFunc = (...args: Parameters<FormListProps['children']>) => ReturnType<RawPanelRender>;
|
|
17
|
+
/**
|
|
18
|
+
* Form.Table 组件类型
|
|
19
|
+
*/
|
|
20
|
+
export interface IFormTableProps
|
|
21
|
+
/**
|
|
22
|
+
* Support all FormListProps except children for which is re-defined in this component
|
|
23
|
+
* and prefixCls for which is not expected to be supported
|
|
24
|
+
*/
|
|
25
|
+
extends Pick<FormListProps, 'name' | 'rules' | 'initialValue'>,
|
|
26
|
+
/**
|
|
27
|
+
* Support all TableProps except
|
|
28
|
+
* - re-define columns and re-defined rowSelection
|
|
29
|
+
* - and pagination which is expect to be not supported in Form.Table
|
|
30
|
+
* - and className which is renamed to tableClassName
|
|
31
|
+
* - and rowKey, dataSource for which are defined and not allowed to be modified
|
|
32
|
+
* - and footer, title, summary for which are re-defined to pass form's operation
|
|
33
|
+
*/
|
|
34
|
+
Omit<TableProps<any>, 'columns' | 'rowSelection' | 'pagination' | 'className' | 'rowKey' | 'dataSource' | 'footer' | 'title' | 'summary'> {
|
|
35
|
+
/**
|
|
36
|
+
* 表格列的配置描述
|
|
37
|
+
*/
|
|
38
|
+
columns?: ColumnType[] | ((...args: Parameters<FormListProps['children']>) => ColumnType[]);
|
|
39
|
+
/**
|
|
40
|
+
* Table 的 className
|
|
41
|
+
*/
|
|
42
|
+
tableClassName?: TableProps<any>['className'];
|
|
43
|
+
/**
|
|
44
|
+
* 表格行是否可选择
|
|
45
|
+
*/
|
|
46
|
+
rowSelection?: Omit<NotNullRowSelection, 'getCheckboxProps'> & {
|
|
47
|
+
getCheckboxProps?: (field: FormListFieldData) => ReturnType<NonNullable<NotNullRowSelection['getCheckboxProps']>>;
|
|
48
|
+
};
|
|
49
|
+
title?: PanelRenderFunc;
|
|
50
|
+
footer?: PanelRenderFunc;
|
|
51
|
+
summary?: PanelRenderFunc;
|
|
52
|
+
}
|
|
53
|
+
export interface ColumnType
|
|
54
|
+
/**
|
|
55
|
+
* Support all FormItemProps, and re-defined `rules` and `dependencies`
|
|
56
|
+
*/
|
|
57
|
+
extends Omit<FormItemProps, 'rules' | 'dependencies' | 'prefixCls' | 'children'>,
|
|
58
|
+
/**
|
|
59
|
+
* Support all TableColumnType, and re-defined `render`
|
|
60
|
+
*/
|
|
61
|
+
Omit<TableColumnType<FormListFieldData>, 'render'> {
|
|
62
|
+
/**
|
|
63
|
+
* 设置依赖字段, 支持通过回调函数获取当前字段名
|
|
64
|
+
*/
|
|
65
|
+
dependencies?: ((namePath: OverrideParameters) => FormItemProps['dependencies']) | FormItemProps['dependencies'];
|
|
66
|
+
/**
|
|
67
|
+
* 校验规则,设置字段的校验逻辑,支持通过回调函数获取当前字段名
|
|
68
|
+
*/
|
|
69
|
+
rules?: (RuleObject | ((form: RcFormInstance, namePath: OverrideParameters) => RuleObject))[];
|
|
70
|
+
/**
|
|
71
|
+
* 渲染函数
|
|
72
|
+
* @param formInstance 只有在设置了 `dependencies` 的情况下才有该参数
|
|
73
|
+
*/
|
|
74
|
+
render?: (fieldData: FormListFieldData, namePath: OverrideParameters, formInstance?: RcFormInstance) => ReactNode;
|
|
75
|
+
}
|
|
76
|
+
export default function InternalTable({ name, rules, initialValue, ...tableProps }: IFormTableProps): React.JSX.Element;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = InternalTable;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _dtUtils = require("@dtinsight/dt-utils");
|
|
9
|
+
var _antd = require("antd");
|
|
10
|
+
var _configProvider = require("antd/es/config-provider");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
require("./style");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
/**
|
|
18
|
+
* Override NamePath parameters type
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Override PanelRender type
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Form.Table 组件类型
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
function InternalTable({
|
|
30
|
+
name,
|
|
31
|
+
rules,
|
|
32
|
+
initialValue,
|
|
33
|
+
...tableProps
|
|
34
|
+
}) {
|
|
35
|
+
const {
|
|
36
|
+
tableClassName,
|
|
37
|
+
columns: rawColumns,
|
|
38
|
+
// override title, footer, summary
|
|
39
|
+
title,
|
|
40
|
+
footer,
|
|
41
|
+
summary,
|
|
42
|
+
...restProps
|
|
43
|
+
} = tableProps;
|
|
44
|
+
const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('form-list');
|
|
45
|
+
const formInstance = _antd.Form.useFormInstance();
|
|
46
|
+
const convertRawToTableCol = raw => {
|
|
47
|
+
if (!raw?.length) return [];
|
|
48
|
+
return raw.map(({
|
|
49
|
+
noStyle,
|
|
50
|
+
style,
|
|
51
|
+
className,
|
|
52
|
+
id,
|
|
53
|
+
hasFeedback,
|
|
54
|
+
validateStatus,
|
|
55
|
+
required,
|
|
56
|
+
hidden,
|
|
57
|
+
initialValue,
|
|
58
|
+
messageVariables,
|
|
59
|
+
tooltip,
|
|
60
|
+
dependencies,
|
|
61
|
+
rules: rawRules,
|
|
62
|
+
validateFirst,
|
|
63
|
+
validateTrigger,
|
|
64
|
+
valuePropName,
|
|
65
|
+
render,
|
|
66
|
+
...cols
|
|
67
|
+
}) => {
|
|
68
|
+
const formItemProps = {
|
|
69
|
+
noStyle,
|
|
70
|
+
style,
|
|
71
|
+
className,
|
|
72
|
+
id,
|
|
73
|
+
hasFeedback,
|
|
74
|
+
validateStatus,
|
|
75
|
+
required,
|
|
76
|
+
hidden,
|
|
77
|
+
initialValue,
|
|
78
|
+
messageVariables,
|
|
79
|
+
validateFirst,
|
|
80
|
+
validateTrigger,
|
|
81
|
+
tooltip,
|
|
82
|
+
valuePropName
|
|
83
|
+
};
|
|
84
|
+
const isRequired = required || rawRules?.some(rule => typeof rule === 'object' && rule.required);
|
|
85
|
+
return {
|
|
86
|
+
...cols,
|
|
87
|
+
title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isRequired && /*#__PURE__*/_react.default.createElement("span", {
|
|
88
|
+
className: "dtc-form__table__column--required"
|
|
89
|
+
}), cols.title),
|
|
90
|
+
render(_, fieldData) {
|
|
91
|
+
const currentNamePath = [fieldData.name, cols.dataIndex].filter(_dtUtils.Utils.checkExist).flat();
|
|
92
|
+
const rules = rawRules?.map(rule => typeof rule === 'function' ? form => rule(form, currentNamePath) : rule);
|
|
93
|
+
if (dependencies) {
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
95
|
+
noStyle: true,
|
|
96
|
+
dependencies: typeof dependencies === 'function' ? dependencies(currentNamePath) : dependencies
|
|
97
|
+
}, formInstance => /*#__PURE__*/_react.default.createElement(_antd.Form.Item, _extends({
|
|
98
|
+
name: currentNamePath,
|
|
99
|
+
rules: rules
|
|
100
|
+
}, formItemProps), render?.(fieldData, currentNamePath, formInstance)));
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, _extends({
|
|
103
|
+
name: currentNamePath,
|
|
104
|
+
rules: rules
|
|
105
|
+
}, formItemProps), render?.(fieldData, currentNamePath, formInstance));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const columns = (0, _react.useMemo)(() => {
|
|
111
|
+
if (typeof rawColumns === 'function') return rawColumns;
|
|
112
|
+
return convertRawToTableCol(rawColumns);
|
|
113
|
+
}, [rawColumns]);
|
|
114
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Form.List, {
|
|
115
|
+
name: name,
|
|
116
|
+
rules: rules,
|
|
117
|
+
initialValue: initialValue
|
|
118
|
+
}, (fields, ope, meta) => /*#__PURE__*/_react.default.createElement(_antd.Table, _extends({
|
|
119
|
+
className: (0, _classnames.default)(prefixCls, tableClassName),
|
|
120
|
+
rowKey: "key",
|
|
121
|
+
dataSource: fields,
|
|
122
|
+
pagination: false,
|
|
123
|
+
columns: typeof columns === 'function' ? convertRawToTableCol(columns(fields, ope, meta)) : columns,
|
|
124
|
+
footer: footer ? () => footer(fields, ope, meta) : undefined,
|
|
125
|
+
title: title ? () => title(fields, ope, meta) : undefined,
|
|
126
|
+
summary: summary ? () => summary(fields, ope, meta) : undefined
|
|
127
|
+
}, restProps)));
|
|
128
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
|
|
3
|
+
@form-list-prefix-cls: ~'@{ant-prefix}-form-list';
|
|
4
|
+
|
|
5
|
+
.@{form-list-prefix-cls} {
|
|
6
|
+
height: 100%;
|
|
7
|
+
|
|
8
|
+
&__column {
|
|
9
|
+
&--required {
|
|
10
|
+
&::before {
|
|
11
|
+
content: "*";
|
|
12
|
+
display: inline-block;
|
|
13
|
+
margin-inline-end: 4px;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
color: @error-color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
vertical-align: -0.1em;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ant-table,
|
|
24
|
+
.ant-table-container {
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ant-form-item {
|
|
29
|
+
margin-bottom: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
table colgroup > col.ant-table-selection-col {
|
|
33
|
+
width: 48px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ant-table-thead > tr > th.ant-table-selection-column {
|
|
37
|
+
padding: 0 16px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ant-table-tbody > tr > td.ant-table-selection-column {
|
|
41
|
+
padding: 0 16px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { default as BlockHeader } from './blockHeader';
|
|
2
2
|
export type { ButtonProps } from './button';
|
|
3
3
|
export { default as Button } from './button';
|
|
4
|
+
export { default as Collapsible } from './collapsible';
|
|
5
|
+
export { default as CollapsibleActionItems } from './collapsibleActionItems';
|
|
4
6
|
export { default as Flex } from './flex';
|
|
5
7
|
export type { FlexProps } from './flex/interface';
|
|
6
|
-
export { default as
|
|
8
|
+
export { default as FormList } from './formList';
|
|
9
|
+
export * from './formList';
|
|
7
10
|
export { default as OverflowList } from './overflowList';
|
|
8
11
|
export { default as Resize } from './resize';
|
|
9
12
|
export { default as Splitter } from './splitter';
|
|
10
13
|
export * from './splitter';
|
|
11
|
-
export { default as Collapsible } from './collapsible';
|
|
12
14
|
export { default as StatusTag } from './statusTag';
|
package/lib/index.js
CHANGED
|
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
BlockHeader: true,
|
|
8
8
|
Button: true,
|
|
9
|
-
|
|
9
|
+
Collapsible: true,
|
|
10
10
|
CollapsibleActionItems: true,
|
|
11
|
+
Flex: true,
|
|
12
|
+
FormList: true,
|
|
11
13
|
OverflowList: true,
|
|
12
14
|
Resize: true,
|
|
13
15
|
Splitter: true,
|
|
14
|
-
Collapsible: true,
|
|
15
16
|
StatusTag: true
|
|
16
17
|
};
|
|
17
18
|
Object.defineProperty(exports, "BlockHeader", {
|
|
@@ -44,6 +45,12 @@ Object.defineProperty(exports, "Flex", {
|
|
|
44
45
|
return _flex.default;
|
|
45
46
|
}
|
|
46
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "FormList", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _formList.default;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
47
54
|
Object.defineProperty(exports, "OverflowList", {
|
|
48
55
|
enumerable: true,
|
|
49
56
|
get: function () {
|
|
@@ -70,8 +77,21 @@ Object.defineProperty(exports, "StatusTag", {
|
|
|
70
77
|
});
|
|
71
78
|
var _blockHeader = _interopRequireDefault(require("./blockHeader"));
|
|
72
79
|
var _button = _interopRequireDefault(require("./button"));
|
|
73
|
-
var
|
|
80
|
+
var _collapsible = _interopRequireDefault(require("./collapsible"));
|
|
74
81
|
var _collapsibleActionItems = _interopRequireDefault(require("./collapsibleActionItems"));
|
|
82
|
+
var _flex = _interopRequireDefault(require("./flex"));
|
|
83
|
+
var _formList = _interopRequireWildcard(require("./formList"));
|
|
84
|
+
Object.keys(_formList).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
87
|
+
if (key in exports && exports[key] === _formList[key]) return;
|
|
88
|
+
Object.defineProperty(exports, key, {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return _formList[key];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
75
95
|
var _overflowList = _interopRequireDefault(require("./overflowList"));
|
|
76
96
|
var _resize = _interopRequireDefault(require("./resize"));
|
|
77
97
|
var _splitter = _interopRequireWildcard(require("./splitter"));
|
|
@@ -86,7 +106,6 @@ Object.keys(_splitter).forEach(function (key) {
|
|
|
86
106
|
}
|
|
87
107
|
});
|
|
88
108
|
});
|
|
89
|
-
var _collapsible = _interopRequireDefault(require("./collapsible"));
|
|
90
109
|
var _statusTag = _interopRequireDefault(require("./statusTag"));
|
|
91
110
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
92
111
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
package/lib/splitter/Splitter.js
CHANGED
|
@@ -39,16 +39,10 @@ const Splitter = props => {
|
|
|
39
39
|
direction
|
|
40
40
|
} = (0, _react.useContext)(_configProvider.ConfigContext);
|
|
41
41
|
const prefixCls = getPrefixCls('splitter', customizePrefixCls);
|
|
42
|
-
|
|
43
|
-
// ======================== Direct ========================
|
|
44
42
|
const isVertical = layout === 'vertical';
|
|
45
43
|
const isRTL = direction === 'rtl';
|
|
46
44
|
const reverse = !isVertical && isRTL;
|
|
47
|
-
|
|
48
|
-
// ====================== Items Data ======================
|
|
49
45
|
const items = (0, _useItems.default)(children);
|
|
50
|
-
|
|
51
|
-
// >>> Warning 适配 v4
|
|
52
46
|
if (process.env.NODE_ENV !== 'production') {
|
|
53
47
|
let existSize = false;
|
|
54
48
|
let existUndefinedSize = false;
|
|
@@ -63,8 +57,6 @@ const Splitter = props => {
|
|
|
63
57
|
(0, _warning.default)(false, 'When part of `Splitter.Panel` has `size`, `onResize` is required or change `size` to `defaultSize`.');
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
|
|
67
|
-
// ====================== Container =======================
|
|
68
60
|
const [containerSize, setContainerSize] = (0, _react.useState)();
|
|
69
61
|
const onContainerResize = size => {
|
|
70
62
|
const {
|
|
@@ -77,15 +69,9 @@ const Splitter = props => {
|
|
|
77
69
|
}
|
|
78
70
|
setContainerSize(containerSize);
|
|
79
71
|
};
|
|
80
|
-
|
|
81
|
-
// ========================= Size =========================
|
|
82
72
|
const [panelSizes, itemPxSizes, itemPtgSizes, itemPtgMinSizes, itemPtgMaxSizes, updateSizes] = (0, _useSizes.default)(items, containerSize);
|
|
83
|
-
|
|
84
|
-
// ====================== Resizable =======================
|
|
85
73
|
const resizableInfos = (0, _useResizable.default)(items, itemPxSizes, isRTL);
|
|
86
74
|
const [onOffsetStart, onOffsetUpdate, onOffsetEnd, onCollapse, movingIndex] = (0, _useResize.default)(items, resizableInfos, itemPtgSizes, containerSize, updateSizes, isRTL);
|
|
87
|
-
|
|
88
|
-
// ======================== Events ========================
|
|
89
75
|
const onInternalResizeStart = (0, _useEvent.default)(index => {
|
|
90
76
|
onOffsetStart(index);
|
|
91
77
|
onResizeStart?.(itemPxSizes);
|
|
@@ -108,22 +94,23 @@ const Splitter = props => {
|
|
|
108
94
|
const nextSizes = onCollapse(index, type);
|
|
109
95
|
onResize?.(nextSizes);
|
|
110
96
|
onResizeEnd?.(nextSizes);
|
|
97
|
+
const collapsed = nextSizes.map(size => Math.abs(size) < Number.EPSILON);
|
|
98
|
+
props.onCollapse?.(collapsed, nextSizes);
|
|
111
99
|
});
|
|
112
100
|
const containerClassName = (0, _classnames.default)(prefixCls, className, `${prefixCls}-${layout}`, {
|
|
113
101
|
[`${prefixCls}-rtl`]: isRTL
|
|
114
102
|
}, rootClassName);
|
|
115
|
-
|
|
116
|
-
// ======================== Render ========================
|
|
117
103
|
const maskCls = `${prefixCls}-mask`;
|
|
118
104
|
const stackSizes = _react.default.useMemo(() => {
|
|
119
105
|
const mergedSizes = [];
|
|
120
106
|
let stack = 0;
|
|
121
|
-
|
|
107
|
+
const len = items.length;
|
|
108
|
+
for (let i = 0; i < len; i += 1) {
|
|
122
109
|
stack += itemPtgSizes[i];
|
|
123
110
|
mergedSizes.push(stack);
|
|
124
111
|
}
|
|
125
112
|
return mergedSizes;
|
|
126
|
-
}, [itemPtgSizes]);
|
|
113
|
+
}, [itemPtgSizes, items.length]);
|
|
127
114
|
const mergedStyle = {
|
|
128
115
|
...style
|
|
129
116
|
};
|
|
@@ -133,7 +120,6 @@ const Splitter = props => {
|
|
|
133
120
|
style: mergedStyle,
|
|
134
121
|
className: containerClassName
|
|
135
122
|
}, items.map((item, idx) => {
|
|
136
|
-
// Panel
|
|
137
123
|
const panel = /*#__PURE__*/_react.default.createElement(_Panel.InternalPanel, _extends({}, item, {
|
|
138
124
|
prefixCls: prefixCls,
|
|
139
125
|
size: panelSizes[idx]
|
|
@@ -16,6 +16,18 @@ function autoPtgSizes(ptgSizes, minPtgSizes, maxPtgSizes) {
|
|
|
16
16
|
});
|
|
17
17
|
const restPtg = 1 - currentTotalPtg;
|
|
18
18
|
const undefinedCount = undefinedIndexes.length;
|
|
19
|
+
|
|
20
|
+
// If all sizes are defined but don't sum to 1, scale them.
|
|
21
|
+
if (ptgSizes.length && !undefinedIndexes.length && currentTotalPtg !== 1) {
|
|
22
|
+
// Handle the case when all sizes are 0
|
|
23
|
+
if (currentTotalPtg === 0) {
|
|
24
|
+
const avg = 1 / ptgSizes.length;
|
|
25
|
+
return ptgSizes.map(() => avg);
|
|
26
|
+
}
|
|
27
|
+
const scale = 1 / currentTotalPtg;
|
|
28
|
+
// We know `size` is a number here because undefinedIndexes is empty.
|
|
29
|
+
return ptgSizes.map(size => size * scale);
|
|
30
|
+
}
|
|
19
31
|
if (restPtg < 0) {
|
|
20
32
|
const scale = 1 / currentTotalPtg;
|
|
21
33
|
return ptgSizes.map(size => size === undefined ? 0 : size * scale);
|
|
@@ -55,8 +55,8 @@ function useSizes(items, containerSize) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
return (0, _sizeUtil.autoPtgSizes)(ptgList, postPercentMinSizes, postPercentMaxSizes);
|
|
58
|
-
}, [sizes, mergedContainerSize, postPercentMinSizes, postPercentMaxSizes]);
|
|
58
|
+
}, [itemsCount, sizes, mergedContainerSize, postPercentMinSizes, postPercentMaxSizes]);
|
|
59
59
|
const postPxSizes = _react.default.useMemo(() => postPercentSizes.map(ptg2px), [postPercentSizes, mergedContainerSize]);
|
|
60
|
-
const panelSizes = _react.default.useMemo(() => containerSize ? postPxSizes : sizes, [postPxSizes, containerSize]);
|
|
60
|
+
const panelSizes = _react.default.useMemo(() => containerSize ? postPxSizes : sizes, [postPxSizes, sizes, containerSize]);
|
|
61
61
|
return [panelSizes, postPxSizes, postPercentSizes, postPercentMinSizes, postPercentMaxSizes, setInnerSizes];
|
|
62
62
|
}
|
|
@@ -9,6 +9,7 @@ export interface SplitterProps {
|
|
|
9
9
|
onResizeStart?: (sizes: number[]) => void;
|
|
10
10
|
onResize?: (sizes: number[]) => void;
|
|
11
11
|
onResizeEnd?: (sizes: number[]) => void;
|
|
12
|
+
onCollapse?: (collapsed: boolean[], sizes: number[]) => void;
|
|
12
13
|
lazy?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export interface PanelProps {
|