@teamix/pro 1.4.14 → 1.4.15
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/pro.css +1 -1
- package/dist/pro.js +211 -64
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/form/ProForm/index.js +14 -32
- package/es/form/ProForm/useAutoLayout.d.ts +9 -0
- package/es/form/ProForm/useAutoLayout.js +114 -0
- package/es/form/typing.d.ts +4 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/nocode/index.scss +2 -2
- package/es/nocode/pages/playground.js +1 -1
- package/es/nocode/pages/renderer.js +1 -1
- package/es/nocode/playground.js +1 -1
- package/es/table/components/Layout/index.js +8 -4
- package/es/table/components/QuickAction/index.js +1 -1
- package/es/table/index.js +31 -9
- package/lib/form/ProForm/index.js +13 -31
- package/lib/form/ProForm/useAutoLayout.d.ts +9 -0
- package/lib/form/ProForm/useAutoLayout.js +124 -0
- package/lib/form/typing.d.ts +4 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/nocode/index.scss +2 -2
- package/lib/nocode/pages/playground.js +1 -1
- package/lib/nocode/pages/renderer.js +1 -1
- package/lib/nocode/playground.js +1 -1
- package/lib/table/components/Layout/index.js +8 -4
- package/lib/table/components/QuickAction/index.js +1 -1
- package/lib/table/index.js +30 -8
- package/package.json +1 -1
package/es/form/ProForm/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "
|
1
|
+
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst", "schema", "children"];
|
2
2
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
|
@@ -10,8 +10,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
10
10
|
|
11
11
|
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; }
|
12
12
|
|
13
|
-
import React, { memo, useEffect, useMemo } from 'react';
|
14
|
-
import { usePrefixCls, cls, getLanguage, getGlobalConfig
|
13
|
+
import React, { memo, useEffect, useMemo, useRef } from 'react';
|
14
|
+
import { usePrefixCls, cls, getLanguage, getGlobalConfig } from '@teamix/utils';
|
15
15
|
import { createForm, onFieldValueChange, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
16
16
|
import { toJS } from '@formily/reactive';
|
17
17
|
import { Form, Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
|
@@ -22,8 +22,8 @@ import FormGroup from '../Components/FormGroup';
|
|
22
22
|
import LightFilter from '../Components/LightFilter';
|
23
23
|
import Text from '../Components/Text/index';
|
24
24
|
import SchemaForm from '../SchemaForm';
|
25
|
-
import { mergeArrayValue } from '../utils';
|
26
25
|
import useAutoSubmit from './useAutoSubmit';
|
26
|
+
import useAutoLayout from './useAutoLayout';
|
27
27
|
import useInitialRequest from './useInitialRequest';
|
28
28
|
import validateLocale from '../locales/validate';
|
29
29
|
import './index.scss';
|
@@ -63,12 +63,6 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
63
63
|
scope = _ref.scope,
|
64
64
|
context = _ref.context,
|
65
65
|
components = _ref.components,
|
66
|
-
layout = _ref.layout,
|
67
|
-
labelAlign = _ref.labelAlign,
|
68
|
-
wrapperAlign = _ref.wrapperAlign,
|
69
|
-
labelCol = _ref.labelCol,
|
70
|
-
wrapperCol = _ref.wrapperCol,
|
71
|
-
breakpoints = _ref.breakpoints,
|
72
66
|
onChange = _ref.onChange,
|
73
67
|
onChangeType = _ref.onChangeType,
|
74
68
|
onSubmit = _ref.onSubmit,
|
@@ -80,7 +74,8 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
80
74
|
children = _ref.children,
|
81
75
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
82
76
|
|
83
|
-
// 获取全局配置
|
77
|
+
var formRef = useRef(); // 获取全局配置
|
78
|
+
|
84
79
|
var _ref2 = getGlobalConfig('ProForm') || {},
|
85
80
|
globalComponents = _ref2.components,
|
86
81
|
globalScope = _ref2.scope;
|
@@ -98,25 +93,10 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
98
93
|
|
99
94
|
var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), ProFieldComponents);
|
100
95
|
|
101
|
-
var onAutoSubmit = useAutoSubmit(onSubmit, context);
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
breakpoints: [480],
|
106
|
-
layout: mergeArrayValue(['vertical'], layout),
|
107
|
-
labelAlign: mergeArrayValue(['left'], labelAlign),
|
108
|
-
wrapperAlign: mergeArrayValue(['left'], wrapperAlign),
|
109
|
-
labelCol: mergeArrayValue([24], labelCol),
|
110
|
-
wrapperCol: mergeArrayValue([24], wrapperCol)
|
111
|
-
} : {
|
112
|
-
breakpoints: isBool(breakpoints) ? undefined : breakpoints,
|
113
|
-
layout: layout,
|
114
|
-
labelAlign: labelAlign,
|
115
|
-
wrapperAlign: wrapperAlign,
|
116
|
-
labelCol: labelCol,
|
117
|
-
wrapperCol: wrapperCol
|
118
|
-
};
|
119
|
-
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
96
|
+
var onAutoSubmit = useAutoSubmit(onSubmit, context);
|
97
|
+
var autoTeamixLayout = useAutoLayout(_objectSpread(_objectSpread({}, otherProps), {}, {
|
98
|
+
schema: schema
|
99
|
+
}), formRef);
|
120
100
|
useMemo(function () {
|
121
101
|
// 配置表单默认值
|
122
102
|
if (initialValues) {
|
@@ -157,7 +137,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
157
137
|
}, []);
|
158
138
|
return /*#__PURE__*/React.createElement(Form, _objectSpread(_objectSpread(_objectSpread({
|
159
139
|
className: cls(prefixCls(), className)
|
160
|
-
}, otherProps),
|
140
|
+
}, otherProps), autoTeamixLayout), {}, {
|
161
141
|
form: form,
|
162
142
|
onAutoSubmit: onAutoSubmit,
|
163
143
|
onAutoSubmitFailed: onSubmitFailed
|
@@ -165,7 +145,9 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
165
145
|
schema: schema,
|
166
146
|
scope: mergedScope,
|
167
147
|
components: mergedComponents
|
168
|
-
}) : null,
|
148
|
+
}) : null, /*#__PURE__*/React.createElement("div", {
|
149
|
+
ref: formRef
|
150
|
+
}), children);
|
169
151
|
});
|
170
152
|
ProForm.defaultProps = {
|
171
153
|
colon: false,
|
@@ -0,0 +1,9 @@
|
|
1
|
+
declare const useAutoLayout: ({ breakpoints: outBreakpoints, layout, labelAlign, wrapperAlign, labelCol: outLabelCol, wrapperCol: outWrapperCol, autoLayout, schema, }: any, formRef: any) => {
|
2
|
+
breakpoints: any;
|
3
|
+
layout: any;
|
4
|
+
labelAlign: any;
|
5
|
+
wrapperAlign: any;
|
6
|
+
labelCol: any;
|
7
|
+
wrapperCol: any;
|
8
|
+
};
|
9
|
+
export default useAutoLayout;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
|
+
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
8
|
+
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
+
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
+
|
13
|
+
import { useEffect, useMemo, useState } from 'react';
|
14
|
+
import { isPlainObj, isBool, autoWidthBySpace, getWidthByCharacterMap, isStr } from '@teamix/utils';
|
15
|
+
import { mergeArrayValue } from '../utils';
|
16
|
+
|
17
|
+
var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
18
|
+
var outBreakpoints = _ref.breakpoints,
|
19
|
+
layout = _ref.layout,
|
20
|
+
labelAlign = _ref.labelAlign,
|
21
|
+
wrapperAlign = _ref.wrapperAlign,
|
22
|
+
outLabelCol = _ref.labelCol,
|
23
|
+
outWrapperCol = _ref.wrapperCol,
|
24
|
+
autoLayout = _ref.autoLayout,
|
25
|
+
schema = _ref.schema;
|
26
|
+
|
27
|
+
var _ref2 = isPlainObj(autoLayout) ? autoLayout : {
|
28
|
+
autoLabel: autoLayout
|
29
|
+
},
|
30
|
+
autoLabel = _ref2.autoLabel;
|
31
|
+
|
32
|
+
var breakpoints = useMemo(function () {
|
33
|
+
return autoLabel ? false : breakpoints;
|
34
|
+
}, []); // 当前断点不支持Col更新
|
35
|
+
|
36
|
+
var _useState = useState({
|
37
|
+
labelCol: outLabelCol,
|
38
|
+
wrapperCol: outWrapperCol
|
39
|
+
}),
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
41
|
+
autoCol = _useState2[0],
|
42
|
+
setAutoCol = _useState2[1];
|
43
|
+
|
44
|
+
var labelCol = autoCol.labelCol,
|
45
|
+
wrapperCol = autoCol.wrapperCol;
|
46
|
+
useEffect(function () {
|
47
|
+
/**
|
48
|
+
* autolayout
|
49
|
+
*/
|
50
|
+
if (autoLabel) {
|
51
|
+
var formWidth = formRef.current.getBoundingClientRect().width; // 表单宽度
|
52
|
+
|
53
|
+
var labelArray = schema.map(function (item) {
|
54
|
+
var text = item.title;
|
55
|
+
|
56
|
+
if (isStr(text)) {
|
57
|
+
var _item$decoratorProps;
|
58
|
+
|
59
|
+
if (item.required) {
|
60
|
+
text += '一'; // 必填 + 12
|
61
|
+
}
|
62
|
+
|
63
|
+
if ((_item$decoratorProps = item.decoratorProps) === null || _item$decoratorProps === void 0 ? void 0 : _item$decoratorProps.tooltip) {
|
64
|
+
text += '一'; // 提示 + 18
|
65
|
+
}
|
66
|
+
|
67
|
+
return text;
|
68
|
+
}
|
69
|
+
|
70
|
+
return '';
|
71
|
+
}); // 标题内容集合
|
72
|
+
|
73
|
+
var labelWidthArray = getWidthByCharacterMap(labelArray); // 标题宽度集合
|
74
|
+
|
75
|
+
var _autoWidthBySpace = autoWidthBySpace(labelWidthArray),
|
76
|
+
expectedWidth = _autoWidthBySpace.expectedWidth,
|
77
|
+
consoleArray = _autoWidthBySpace.consoleArray; // 智能计算预期宽度
|
78
|
+
|
79
|
+
|
80
|
+
var expectedCol = Math.ceil(expectedWidth / formWidth * 24); // 预期宽度转换为 Col 值
|
81
|
+
|
82
|
+
setAutoCol({
|
83
|
+
labelCol: expectedCol,
|
84
|
+
wrapperCol: wrapperCol
|
85
|
+
});
|
86
|
+
} else {
|
87
|
+
setAutoCol({
|
88
|
+
labelCol: outLabelCol,
|
89
|
+
wrapperCol: outWrapperCol
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}, [outLabelCol, outWrapperCol]); // Layout配置By断点(配置断点后,目前不支持 Col 更新)
|
93
|
+
|
94
|
+
var autoTeamixLayout = useMemo(function () {
|
95
|
+
return breakpoints === true ? {
|
96
|
+
breakpoints: [480],
|
97
|
+
layout: mergeArrayValue(['vertical'], layout),
|
98
|
+
labelAlign: mergeArrayValue(['left'], labelAlign),
|
99
|
+
wrapperAlign: mergeArrayValue(['left'], wrapperAlign),
|
100
|
+
labelCol: mergeArrayValue([24], labelCol),
|
101
|
+
wrapperCol: mergeArrayValue([24], wrapperCol)
|
102
|
+
} : {
|
103
|
+
breakpoints: isBool(breakpoints) ? undefined : breakpoints,
|
104
|
+
layout: layout,
|
105
|
+
labelAlign: labelAlign,
|
106
|
+
wrapperAlign: wrapperAlign,
|
107
|
+
labelCol: labelCol,
|
108
|
+
wrapperCol: wrapperCol
|
109
|
+
};
|
110
|
+
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
111
|
+
return autoTeamixLayout;
|
112
|
+
};
|
113
|
+
|
114
|
+
export default useAutoLayout;
|
package/es/form/typing.d.ts
CHANGED
@@ -59,6 +59,9 @@ export interface ProFormSchemaItem {
|
|
59
59
|
data?: AnyObject;
|
60
60
|
}
|
61
61
|
export declare type ProFormSchema = ProFormSchemaItem[];
|
62
|
+
interface AutoLayout {
|
63
|
+
autoLabel?: boolean;
|
64
|
+
}
|
62
65
|
export interface ProFormProps extends Omit<IFormLayoutProps, 'breakpoints'> {
|
63
66
|
form?: FormType | false;
|
64
67
|
schema?: ProFormSchema;
|
@@ -78,6 +81,7 @@ export interface ProFormProps extends Omit<IFormLayoutProps, 'breakpoints'> {
|
|
78
81
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
79
82
|
onInitialComplete?: (form: FormType) => void;
|
80
83
|
breakpoints?: number[] | boolean;
|
84
|
+
autoLayout?: AutoLayout | boolean;
|
81
85
|
}
|
82
86
|
export interface FilterProps extends ProFormProps {
|
83
87
|
form: FormType;
|
package/es/index.d.ts
CHANGED
@@ -28,5 +28,5 @@ export * from './table';
|
|
28
28
|
export * from './sidebar';
|
29
29
|
export * from './utils';
|
30
30
|
export * from './timeline';
|
31
|
-
declare const version = "1.4.
|
31
|
+
declare const version = "1.4.15";
|
32
32
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -36,6 +36,6 @@ export * from './table';
|
|
36
36
|
export * from './sidebar';
|
37
37
|
export * from './utils';
|
38
38
|
export * from './timeline';
|
39
|
-
var version = '1.4.
|
39
|
+
var version = '1.4.15';
|
40
40
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
41
41
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, hooks, nocode, templates, utils };
|
package/es/nocode/index.scss
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
.teamix-nocode {
|
1
|
+
.teamix-pro-nocode {
|
2
2
|
&-empty {
|
3
3
|
display: flex;
|
4
4
|
flex-direction: column;
|
@@ -75,7 +75,7 @@
|
|
75
75
|
right: 20px;
|
76
76
|
bottom: 20px;
|
77
77
|
|
78
|
-
|
78
|
+
& > i {
|
79
79
|
cursor: pointer;
|
80
80
|
color: var(--color-text1-8, #848484);
|
81
81
|
background-color: rgba(0, 0, 0, 0.06);
|
@@ -26,7 +26,7 @@ import { useAction } from '../../actions';
|
|
26
26
|
import { initConfigurator } from '../configurators';
|
27
27
|
import { ComponentConfiguratorMap } from '../configurators/map';
|
28
28
|
import { PlayGroundLayout } from '../playground';
|
29
|
-
var cls = usePrefixCls('teamix-nocode');
|
29
|
+
var cls = usePrefixCls('teamix-pro-nocode');
|
30
30
|
export var PagePlayground = function PagePlayground(props) {
|
31
31
|
var _useState = useState(undefined),
|
32
32
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -40,7 +40,7 @@ import PageHeader from '../../page-header';
|
|
40
40
|
import { ProSkeletonRaw } from '../../skeleton';
|
41
41
|
import { usePrefixCls } from '@teamix/utils';
|
42
42
|
import { PageMap } from '.';
|
43
|
-
var cls = usePrefixCls('teamix-nocode');
|
43
|
+
var cls = usePrefixCls('teamix-pro-nocode');
|
44
44
|
|
45
45
|
var Loading = function Loading(props) {
|
46
46
|
return /*#__PURE__*/React.createElement(PageContainer, _objectSpread({
|
package/es/nocode/playground.js
CHANGED
@@ -20,7 +20,7 @@ import React, { useMemo } from 'react';
|
|
20
20
|
import { usePrefixCls } from '@teamix/utils';
|
21
21
|
import { useDebounceFn } from '@teamix/hooks';
|
22
22
|
import { initConfigurator } from './configurators';
|
23
|
-
var cls = usePrefixCls('teamix-nocode-playground');
|
23
|
+
var cls = usePrefixCls('teamix-pro-nocode-playground');
|
24
24
|
export var PlayGroundLayout = function PlayGroundLayout(props) {
|
25
25
|
return /*#__PURE__*/React.createElement("div", {
|
26
26
|
className: cls()
|
@@ -122,14 +122,18 @@ var Layout = function Layout(props) {
|
|
122
122
|
}
|
123
123
|
} else if (mainAction) {
|
124
124
|
// 没传 dataFilter 但是传了 mainAction
|
125
|
-
return /*#__PURE__*/React.createElement(QueryFilterLayout, {
|
125
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(QueryFilterLayout, {
|
126
126
|
addonBefore: renderMainAction(),
|
127
127
|
addonAfter: renderAddonAfter()
|
128
|
-
})
|
128
|
+
}), afterDataFilter && /*#__PURE__*/React.createElement("div", {
|
129
|
+
className: "mb8 ".concat(cls('after-data-filter-wrapper'))
|
130
|
+
}, afterDataFilter));
|
129
131
|
} else {
|
130
|
-
return /*#__PURE__*/React.createElement(QueryFilterLayout, {
|
132
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(QueryFilterLayout, {
|
131
133
|
addonAfter: renderAddonAfter()
|
132
|
-
})
|
134
|
+
}), ' ', afterDataFilter && /*#__PURE__*/React.createElement("div", {
|
135
|
+
className: "mb8 ".concat(cls('after-data-filter-wrapper'))
|
136
|
+
}, afterDataFilter));
|
133
137
|
}
|
134
138
|
}; // 区域组合渲染
|
135
139
|
|
@@ -15,7 +15,7 @@ var QuickAction = function QuickAction(props) {
|
|
15
15
|
actionRef = props.actionRef,
|
16
16
|
rowSelection = props.rowSelection; // 如果传对象的话,默认为主要文字类型的 ProActionButton
|
17
17
|
|
18
|
-
if (_typeof(quickAction) === 'object') {
|
18
|
+
if (_typeof(quickAction) === 'object' && (quickAction === null || quickAction === void 0 ? void 0 : quickAction.config)) {
|
19
19
|
// 默认 context
|
20
20
|
var defaultContext = {
|
21
21
|
action: actionRef.current,
|
package/es/table/index.js
CHANGED
@@ -32,7 +32,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
32
32
|
|
33
33
|
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; }
|
34
34
|
|
35
|
-
import React, { useState, useEffect, useRef } from 'react';
|
35
|
+
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
36
36
|
import { Table, Checkbox } from '@alicloudfe/components';
|
37
37
|
import Pagination from './components/Pagination';
|
38
38
|
import genProColumnToColumn from './utils/genProColumnToColumn';
|
@@ -316,7 +316,11 @@ var ProTable = function ProTable(props) {
|
|
316
316
|
}, []); // 获取header高度,用作全屏吸底吸底高度计算以及固定body高度计算(滚动条在底部)
|
317
317
|
|
318
318
|
var getHeaderHeight = function getHeaderHeight(isFullscreen, offset) {
|
319
|
-
var _tableDom$getElements, _tableDom$getElements2;
|
319
|
+
var _tableDom$getElements, _tableDom$getElements2, _document$querySelect, _document$querySelect2, _document$querySelect3;
|
320
|
+
|
321
|
+
if (!fixedTableBody) {
|
322
|
+
return;
|
323
|
+
}
|
320
324
|
|
321
325
|
var tableDom = tableRef.current;
|
322
326
|
var headerDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements = tableDom.getElementsByClassName('teamix-pro-table-layout')) === null || _tableDom$getElements === void 0 ? void 0 : _tableDom$getElements[0];
|
@@ -326,8 +330,9 @@ var ProTable = function ProTable(props) {
|
|
326
330
|
var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName(basePrefix('table-header-inner'))) === null || _tableDom$getElements2 === void 0 ? void 0 : _tableDom$getElements2[0];
|
327
331
|
var pageContainerDom = document.querySelector('.teamix-pro-page-container-header');
|
328
332
|
var teamixNavDom = document.querySelector('.teamix-nav-console');
|
329
|
-
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer');
|
330
|
-
|
333
|
+
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer'); // 这边不能直接取 next-table-body
|
334
|
+
|
335
|
+
var tableBodyDom = (_document$querySelect = document.querySelector('.teamix-pro-table')) === null || _document$querySelect === void 0 ? void 0 : (_document$querySelect2 = _document$querySelect.getElementsByTagName('table')) === null || _document$querySelect2 === void 0 ? void 0 : (_document$querySelect3 = _document$querySelect2[1]) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.parentNode;
|
331
336
|
var headerFixedTopSectionDom = document.querySelector('.teamix-pro-page-container-fixed-top');
|
332
337
|
setTimeout(function () {
|
333
338
|
var _headerDom$offsetHeig, _tableHeaderDom$offse;
|
@@ -345,9 +350,8 @@ var ProTable = function ProTable(props) {
|
|
345
350
|
var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0; // 1 为预留值,js无法取出精确高度,会被四舍五入
|
346
351
|
|
347
352
|
var offsetHeaderHeight = headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0) + 1;
|
348
|
-
var clientTableBodyHeight = document.body.clientHeight - offsetHeaderHeight;
|
349
353
|
|
350
|
-
if (tableBodyDom.clientHeight <
|
354
|
+
if (tableBodyDom.clientHeight < tableBodyDom.scrollHeight) {
|
351
355
|
setFooterSuctionState(true);
|
352
356
|
} else {
|
353
357
|
setFooterSuctionState(false);
|
@@ -405,6 +409,10 @@ var ProTable = function ProTable(props) {
|
|
405
409
|
|
406
410
|
|
407
411
|
var getFooterSuctionState = function getFooterSuctionState() {
|
412
|
+
if (!footerSuction) {
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
|
408
416
|
var containerDom = document.querySelector('.teamix-pro-page-container-scroll-container');
|
409
417
|
|
410
418
|
if (containerDom) {
|
@@ -803,7 +811,7 @@ var ProTable = function ProTable(props) {
|
|
803
811
|
if (Number.isInteger(time) && time >= 1000) {
|
804
812
|
autoRefreshTimerRef.current = setTimeout(function () {
|
805
813
|
// 自动刷新不显示 loading
|
806
|
-
_request(
|
814
|
+
_request(requestData, true);
|
807
815
|
}, Number(time));
|
808
816
|
}
|
809
817
|
});
|
@@ -1039,8 +1047,22 @@ var ProTable = function ProTable(props) {
|
|
1039
1047
|
className: cls('footer-right-wrapper')
|
1040
1048
|
}, showSkeleton ? /*#__PURE__*/React.createElement(Skeleton.Footer.Pagination, null) : footer));
|
1041
1049
|
}
|
1042
|
-
};
|
1050
|
+
}; // 判断是否需要吸底
|
1043
1051
|
|
1052
|
+
|
1053
|
+
var fixFooterState = useMemo(function () {
|
1054
|
+
if (fullscreenState) {
|
1055
|
+
return true;
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
if (fixedTableBody || footerSuction) {
|
1059
|
+
if (footerSuctionState) {
|
1060
|
+
return true;
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
return false;
|
1065
|
+
}, [fullscreenState, fixedTableBody, footerSuction, footerSuctionState]);
|
1044
1066
|
return /*#__PURE__*/React.createElement(FullScreen, {
|
1045
1067
|
visible: fullscreenState,
|
1046
1068
|
actionRef: actionRef
|
@@ -1052,7 +1074,7 @@ var ProTable = function ProTable(props) {
|
|
1052
1074
|
|
1053
1075
|
}),
|
1054
1076
|
ref: tableRef
|
1055
|
-
}, renderTable(isFullScreen),
|
1077
|
+
}, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
|
1056
1078
|
});
|
1057
1079
|
};
|
1058
1080
|
|
@@ -31,17 +31,17 @@ var _index = _interopRequireDefault(require("../Components/Text/index"));
|
|
31
31
|
|
32
32
|
var _SchemaForm = _interopRequireDefault(require("../SchemaForm"));
|
33
33
|
|
34
|
-
var _utils2 = require("../utils");
|
35
|
-
|
36
34
|
var _useAutoSubmit = _interopRequireDefault(require("./useAutoSubmit"));
|
37
35
|
|
36
|
+
var _useAutoLayout = _interopRequireDefault(require("./useAutoLayout"));
|
37
|
+
|
38
38
|
var _useInitialRequest = _interopRequireDefault(require("./useInitialRequest"));
|
39
39
|
|
40
40
|
var _validate = _interopRequireDefault(require("../locales/validate"));
|
41
41
|
|
42
42
|
require("./index.scss");
|
43
43
|
|
44
|
-
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "
|
44
|
+
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst", "schema", "children"];
|
45
45
|
|
46
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
47
47
|
|
@@ -95,12 +95,6 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
95
95
|
scope = _ref.scope,
|
96
96
|
context = _ref.context,
|
97
97
|
components = _ref.components,
|
98
|
-
layout = _ref.layout,
|
99
|
-
labelAlign = _ref.labelAlign,
|
100
|
-
wrapperAlign = _ref.wrapperAlign,
|
101
|
-
labelCol = _ref.labelCol,
|
102
|
-
wrapperCol = _ref.wrapperCol,
|
103
|
-
breakpoints = _ref.breakpoints,
|
104
98
|
onChange = _ref.onChange,
|
105
99
|
onChangeType = _ref.onChangeType,
|
106
100
|
onSubmit = _ref.onSubmit,
|
@@ -112,7 +106,8 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
112
106
|
children = _ref.children,
|
113
107
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
114
108
|
|
115
|
-
// 获取全局配置
|
109
|
+
var formRef = (0, _react.useRef)(); // 获取全局配置
|
110
|
+
|
116
111
|
var _ref2 = (0, _utils.getGlobalConfig)('ProForm') || {},
|
117
112
|
globalComponents = _ref2.components,
|
118
113
|
globalScope = _ref2.scope;
|
@@ -130,25 +125,10 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
130
125
|
|
131
126
|
var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), _ProField.default);
|
132
127
|
|
133
|
-
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context);
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
breakpoints: [480],
|
138
|
-
layout: (0, _utils2.mergeArrayValue)(['vertical'], layout),
|
139
|
-
labelAlign: (0, _utils2.mergeArrayValue)(['left'], labelAlign),
|
140
|
-
wrapperAlign: (0, _utils2.mergeArrayValue)(['left'], wrapperAlign),
|
141
|
-
labelCol: (0, _utils2.mergeArrayValue)([24], labelCol),
|
142
|
-
wrapperCol: (0, _utils2.mergeArrayValue)([24], wrapperCol)
|
143
|
-
} : {
|
144
|
-
breakpoints: (0, _utils.isBool)(breakpoints) ? undefined : breakpoints,
|
145
|
-
layout: layout,
|
146
|
-
labelAlign: labelAlign,
|
147
|
-
wrapperAlign: wrapperAlign,
|
148
|
-
labelCol: labelCol,
|
149
|
-
wrapperCol: wrapperCol
|
150
|
-
};
|
151
|
-
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
128
|
+
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context);
|
129
|
+
var autoTeamixLayout = (0, _useAutoLayout.default)(_objectSpread(_objectSpread({}, otherProps), {}, {
|
130
|
+
schema: schema
|
131
|
+
}), formRef);
|
152
132
|
(0, _react.useMemo)(function () {
|
153
133
|
// 配置表单默认值
|
154
134
|
if (initialValues) {
|
@@ -189,7 +169,7 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
189
169
|
}, []);
|
190
170
|
return /*#__PURE__*/_react.default.createElement(_formily.Form, _objectSpread(_objectSpread(_objectSpread({
|
191
171
|
className: (0, _utils.cls)(prefixCls(), className)
|
192
|
-
}, otherProps),
|
172
|
+
}, otherProps), autoTeamixLayout), {}, {
|
193
173
|
form: form,
|
194
174
|
onAutoSubmit: onAutoSubmit,
|
195
175
|
onAutoSubmitFailed: onSubmitFailed
|
@@ -197,7 +177,9 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
197
177
|
schema: schema,
|
198
178
|
scope: mergedScope,
|
199
179
|
components: mergedComponents
|
200
|
-
}) : null,
|
180
|
+
}) : null, /*#__PURE__*/_react.default.createElement("div", {
|
181
|
+
ref: formRef
|
182
|
+
}), children);
|
201
183
|
});
|
202
184
|
ProForm.defaultProps = {
|
203
185
|
colon: false,
|
@@ -0,0 +1,9 @@
|
|
1
|
+
declare const useAutoLayout: ({ breakpoints: outBreakpoints, layout, labelAlign, wrapperAlign, labelCol: outLabelCol, wrapperCol: outWrapperCol, autoLayout, schema, }: any, formRef: any) => {
|
2
|
+
breakpoints: any;
|
3
|
+
layout: any;
|
4
|
+
labelAlign: any;
|
5
|
+
wrapperAlign: any;
|
6
|
+
labelCol: any;
|
7
|
+
wrapperCol: any;
|
8
|
+
};
|
9
|
+
export default useAutoLayout;
|