@teamix/pro 1.1.32 → 1.1.33
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 +832 -418
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.js +13 -8
- package/es/form/Components/ProField/index.d.ts +4 -0
- package/es/form/ProForm/index.js +2 -2
- package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
- package/es/form/ProForm/useFormDisplayValues.js +65 -0
- package/es/form/SchemaForm/adapterType.js +2 -1
- package/es/form/SchemaForm/initializeProField.js +1 -0
- package/es/form/SchemaForm/initializeReactions.js +82 -6
- package/es/form/index.d.ts +3 -3
- package/es/form/index.js +3 -3
- package/es/form/typing.d.ts +2 -2
- package/es/form/utils.d.ts +31 -8
- package/es/form/utils.js +27 -44
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/table/components/Filter/index.js +6 -2
- package/es/table/typing.d.ts +8 -4
- package/es/table/utils/columnRender.js +38 -11
- package/lib/actions/index.js +12 -7
- package/lib/form/Components/ProField/index.d.ts +4 -0
- package/lib/form/ProForm/index.js +1 -1
- package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
- package/lib/form/ProForm/useFormDisplayValues.js +74 -0
- package/lib/form/SchemaForm/adapterType.js +2 -1
- package/lib/form/SchemaForm/initializeProField.js +1 -0
- package/lib/form/SchemaForm/initializeReactions.js +87 -7
- package/lib/form/index.d.ts +3 -3
- package/lib/form/index.js +15 -8
- package/lib/form/typing.d.ts +2 -2
- package/lib/form/utils.d.ts +31 -8
- package/lib/form/utils.js +28 -54
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/Filter/index.js +6 -2
- package/lib/table/typing.d.ts +8 -4
- package/lib/table/utils/columnRender.js +38 -11
- package/package.json +1 -1
package/es/actions/index.js
CHANGED
@@ -33,7 +33,7 @@ import React from 'react';
|
|
33
33
|
import cls from 'classnames';
|
34
34
|
import { Button, MenuButton, Menu, Divider } from '@alicloudfe/components';
|
35
35
|
import Icon from '@teamix/icon';
|
36
|
-
import { getTargetValue } from '@teamix/utils';
|
36
|
+
import { getTargetValue, getMessage } from '@teamix/utils';
|
37
37
|
import { useLinkAction } from './link';
|
38
38
|
import { useRequestAction } from './request';
|
39
39
|
import { useDialogAction } from './dialog';
|
@@ -121,16 +121,18 @@ export var useAction = function useAction(config, context) {
|
|
121
121
|
}, registedAction.defaultConfig), others), context);
|
122
122
|
};
|
123
123
|
|
124
|
-
var buttonContent = function buttonContent(content, iconType, iconSize) {
|
124
|
+
var buttonContent = function buttonContent(content, iconType, iconSize, context) {
|
125
|
+
var renderedContent = typeof content === 'function' ? content(context) : content;
|
126
|
+
|
125
127
|
if (!iconType) {
|
126
|
-
return
|
128
|
+
return renderedContent;
|
127
129
|
}
|
128
130
|
|
129
131
|
return [/*#__PURE__*/React.createElement(Icon, {
|
130
132
|
type: iconType,
|
131
133
|
size: iconSize,
|
132
134
|
key: "teamix-button-icon"
|
133
|
-
}),
|
135
|
+
}), renderedContent];
|
134
136
|
};
|
135
137
|
|
136
138
|
export var ActionButton = function ActionButton(props) {
|
@@ -154,7 +156,7 @@ export var ActionButton = function ActionButton(props) {
|
|
154
156
|
}) : _objectSpread(_objectSpread({}, actionProps), others);
|
155
157
|
return /*#__PURE__*/React.createElement(Button, _objectSpread({
|
156
158
|
type: type
|
157
|
-
}, buttonProps), buttonContent(children, icon, iconSize));
|
159
|
+
}, buttonProps), buttonContent(children, icon, iconSize, context));
|
158
160
|
};
|
159
161
|
|
160
162
|
function renderMenuButtonItem(item, key, context) {
|
@@ -173,7 +175,7 @@ function renderMenuButtonItem(item, key, context) {
|
|
173
175
|
}) : _objectSpread({}, menuItemProps);
|
174
176
|
return /*#__PURE__*/React.createElement(MenuButton.Item, _objectSpread({
|
175
177
|
key: key
|
176
|
-
}, buttonProps), buttonContent(item.children, item.icon));
|
178
|
+
}, buttonProps), buttonContent(item.children, item.icon, undefined, context));
|
177
179
|
}
|
178
180
|
|
179
181
|
function renderCommonActionButtonMenuItem(action, key, context) {
|
@@ -209,8 +211,11 @@ export var ActionMenuButton = function ActionMenuButton(props) {
|
|
209
211
|
mode: 'popup',
|
210
212
|
triggerType: 'hover'
|
211
213
|
},
|
214
|
+
popupProps: {
|
215
|
+
shouldUpdatePosition: true
|
216
|
+
},
|
212
217
|
type: type,
|
213
|
-
label: buttonContent(label || children, icon, iconSize)
|
218
|
+
label: buttonContent(label || children, icon, iconSize, context)
|
214
219
|
}, others), actions.map(function (action, i) {
|
215
220
|
return renderCommonActionButtonMenuItem(action, i, context);
|
216
221
|
}));
|
@@ -255,7 +260,7 @@ function renderCommonActionButton(button, context, isTypeText) {
|
|
255
260
|
function getDefaultMoreButton(type, moreText) {
|
256
261
|
if (type === 'button') {
|
257
262
|
return {
|
258
|
-
label: moreText || '
|
263
|
+
label: moreText || getMessage('more')
|
259
264
|
};
|
260
265
|
}
|
261
266
|
|
@@ -143,6 +143,10 @@ declare const _default: React.ForwardRefExoticComponent<(Partial<import("@teamix
|
|
143
143
|
type: "tagFilter";
|
144
144
|
} & {
|
145
145
|
children?: React.ReactNode;
|
146
|
+
}> | Partial<import("@teamix/pro-field/lib/components/FieldTagFilter").IProFieldMultipleTagFilter & {
|
147
|
+
type: "multipleTagPicker";
|
148
|
+
} & {
|
149
|
+
children?: React.ReactNode;
|
146
150
|
}> | Partial<import("@teamix/pro-field/lib/components/FieldMenuSelect").IProFieldMenuSelect & {
|
147
151
|
type: "menuSelect";
|
148
152
|
} & {
|
package/es/form/ProForm/index.js
CHANGED
@@ -18,7 +18,7 @@ import { Form, FormLayout } from '@teamix/formily';
|
|
18
18
|
import TeamixIcon from '@teamix/icon';
|
19
19
|
import { usePrefixCls } from '@teamix/utils';
|
20
20
|
import SchemaForm from '../SchemaForm';
|
21
|
-
import { mergeArrayValue
|
21
|
+
import { mergeArrayValue } from '../utils';
|
22
22
|
import useAutoSubmit from './useAutoSubmit';
|
23
23
|
import useInitialRequest from './useInitialRequest';
|
24
24
|
import './index.scss';
|
@@ -71,7 +71,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
71
71
|
form.addEffects('onChange', function () {
|
72
72
|
onFormValuesChange(function (form) {
|
73
73
|
if (onChange) {
|
74
|
-
onChange(toJS(form.values)
|
74
|
+
onChange(toJS(form.values));
|
75
75
|
}
|
76
76
|
});
|
77
77
|
});
|
@@ -0,0 +1,65 @@
|
|
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 { useForm } from '@formily/react';
|
14
|
+
import { isArr, isPlainObj, getValueByValue } from '@teamix/utils';
|
15
|
+
/**
|
16
|
+
* 获取表单值的可显示值
|
17
|
+
* @returns 如果某字段有dataSource,则返回value对应label
|
18
|
+
*/
|
19
|
+
|
20
|
+
var useFormDisplayValues = function useFormDisplayValues() {
|
21
|
+
var form = useForm();
|
22
|
+
var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
|
23
|
+
|
24
|
+
var getDisplayValues = function getDisplayValues(values) {
|
25
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
26
|
+
var displayValues;
|
27
|
+
|
28
|
+
if (isPlainObj(values)) {
|
29
|
+
displayValues = {};
|
30
|
+
Object.entries(values).forEach(function (_ref) {
|
31
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
32
|
+
key = _ref2[0],
|
33
|
+
value = _ref2[1];
|
34
|
+
|
35
|
+
var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
|
36
|
+
displayValues[key] = getDisplayValues(value, path);
|
37
|
+
});
|
38
|
+
} else if (isArr(values)) {
|
39
|
+
displayValues = [];
|
40
|
+
values.map(function (value, index) {
|
41
|
+
var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
|
42
|
+
displayValues[index] = getDisplayValues(value, path);
|
43
|
+
});
|
44
|
+
} else {
|
45
|
+
// 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
|
46
|
+
var address = form.indexes[prefix];
|
47
|
+
var field = form.query(address).take();
|
48
|
+
displayValues = getValueByValue(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
|
49
|
+
}
|
50
|
+
|
51
|
+
return displayValues;
|
52
|
+
}; // 测试样例
|
53
|
+
// const example = {
|
54
|
+
// a: [
|
55
|
+
// [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
|
56
|
+
// { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
|
57
|
+
// ],
|
58
|
+
// };
|
59
|
+
// console.log(getDisplayValues(example));
|
60
|
+
|
61
|
+
|
62
|
+
return getDisplayValues(values);
|
63
|
+
};
|
64
|
+
|
65
|
+
export default useFormDisplayValues;
|
@@ -1,13 +1,89 @@
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
2
|
+
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
4
|
+
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
+
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
8
|
+
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
10
|
+
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
12
|
+
|
13
|
+
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
14
|
+
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
16
|
+
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
18
|
+
|
19
|
+
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."); }
|
20
|
+
|
21
|
+
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); }
|
22
|
+
|
23
|
+
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; }
|
24
|
+
|
25
|
+
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; }
|
26
|
+
|
27
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
28
|
+
|
29
|
+
import { isPlainObj, getValueByValue } from '@teamix/utils';
|
1
30
|
import { mergeArrayValue } from '../utils';
|
31
|
+
import schemaNameMap from '../schemaNameMap';
|
2
32
|
|
3
|
-
var
|
4
|
-
if (
|
5
|
-
|
6
|
-
|
7
|
-
|
33
|
+
var mapSchemaName = function mapSchemaName(schema) {
|
34
|
+
if (isPlainObj(schema)) {
|
35
|
+
var newSchema = {};
|
36
|
+
Object.entries(schema).forEach(function (_ref) {
|
37
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
38
|
+
key = _ref2[0],
|
39
|
+
value = _ref2[1];
|
40
|
+
|
41
|
+
var _key$split = key.split('.'),
|
42
|
+
_key$split2 = _toArray(_key$split),
|
43
|
+
firstKey = _key$split2[0],
|
44
|
+
otherKey = _key$split2.slice(1);
|
45
|
+
|
46
|
+
var newFirstKey = getValueByValue(schemaNameMap, firstKey, {
|
47
|
+
inputKey: 'proForm',
|
48
|
+
outputKey: 'formily'
|
49
|
+
}) || firstKey;
|
50
|
+
var newKey = [newFirstKey].concat(_toConsumableArray(otherKey)).join('.');
|
51
|
+
newSchema[newKey] = value;
|
52
|
+
});
|
53
|
+
return newSchema;
|
8
54
|
}
|
9
55
|
|
10
|
-
return
|
56
|
+
return schema;
|
57
|
+
};
|
58
|
+
|
59
|
+
var initializeReactions = function initializeReactions(reactions, innerReactions) {
|
60
|
+
var temp = innerReactions; // 合并reactions
|
61
|
+
|
62
|
+
if (reactions) {
|
63
|
+
temp = mergeArrayValue(innerReactions, reactions);
|
64
|
+
} // schema名称映射,由ProFormSchema映射为formilySchema
|
65
|
+
|
66
|
+
|
67
|
+
temp = temp.map(function (item) {
|
68
|
+
var _item$fulfill, _item$otherwise;
|
69
|
+
|
70
|
+
var fulfillSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$fulfill = item.fulfill) === null || _item$fulfill === void 0 ? void 0 : _item$fulfill.schema);
|
71
|
+
var otherwiseSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$otherwise = item.otherwise) === null || _item$otherwise === void 0 ? void 0 : _item$otherwise.schema);
|
72
|
+
|
73
|
+
if (fulfillSchema || otherwiseSchema) {
|
74
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
75
|
+
fulfill: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.fulfill), {}, {
|
76
|
+
schema: fulfillSchema
|
77
|
+
}),
|
78
|
+
otherwise: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.otherwise), {}, {
|
79
|
+
schema: otherwiseSchema
|
80
|
+
})
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
return item;
|
85
|
+
});
|
86
|
+
return temp;
|
11
87
|
};
|
12
88
|
|
13
89
|
export default initializeReactions;
|
package/es/form/index.d.ts
CHANGED
@@ -13,10 +13,10 @@ export * as formilyTeamix from '@teamix/formily';
|
|
13
13
|
* 导出常用formily内容,需谨慎限制
|
14
14
|
*/
|
15
15
|
import { createForm, registerValidateRules as registerRules, registerValidateFormats as registerFormats, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
16
|
-
import { FormConsumer } from '@formily/react';
|
16
|
+
import { FormConsumer, useForm } from '@formily/react';
|
17
17
|
import { FormDialog, FormDrawer, FormStep, FormTab, FormCollapse } from '@teamix/formily';
|
18
|
-
import
|
19
|
-
export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage,
|
18
|
+
import useFormDisplayValues from './ProForm/useFormDisplayValues';
|
19
|
+
export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, useForm, useFormDisplayValues, };
|
20
20
|
/**
|
21
21
|
* 导出 Filter 组件
|
22
22
|
*/
|
package/es/form/index.js
CHANGED
@@ -19,10 +19,10 @@ export { _formilyTeamix as formilyTeamix };
|
|
19
19
|
*/
|
20
20
|
|
21
21
|
import { createForm, registerValidateRules as registerRules, registerValidateFormats as registerFormats, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
22
|
-
import { FormConsumer } from '@formily/react';
|
22
|
+
import { FormConsumer, useForm } from '@formily/react';
|
23
23
|
import { FormDialog, FormDrawer, FormStep, FormTab, FormCollapse } from '@teamix/formily';
|
24
|
-
import
|
25
|
-
export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage,
|
24
|
+
import useFormDisplayValues from './ProForm/useFormDisplayValues';
|
25
|
+
export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, useForm, useFormDisplayValues };
|
26
26
|
/**
|
27
27
|
* 导出 Filter 组件
|
28
28
|
*/
|
package/es/form/typing.d.ts
CHANGED
@@ -6,7 +6,7 @@ export interface anyObject {
|
|
6
6
|
[propName: string]: any;
|
7
7
|
}
|
8
8
|
declare type FieldDisplayTypes = 'none' | 'hidden' | 'visible';
|
9
|
-
export declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker' | 'Percent' | 'Money' | 'Select' | 'MultipleSelect' | 'TreeSelect' | 'Cascader' | 'MultipleCascader' | 'ArbitraryCascader' | 'Radio' | 'Checkbox' | 'Switch' | 'DatePicker' | 'TimePicker' | 'DateTimePicker' | 'WeekPicker' | 'MonthPicker' | 'YearPicker' | 'QuarterPicker' | 'DateRangePicker' | 'TimeRangePicker' | 'DateTimeRangePicker' | 'WeekRangePicker' | 'MonthRangePicker' | 'YearRangePicker' | 'QuarterRangePicker' | 'Transfer' | 'Upload' | 'ColorPicker' | 'ColorRadio' | 'IconPicker' | 'JsonInput' | 'TagPicker' | 'Range' | 'Search';
|
9
|
+
export declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker' | 'Percent' | 'Money' | 'Select' | 'MultipleSelect' | 'TreeSelect' | 'Cascader' | 'MultipleCascader' | 'ArbitraryCascader' | 'Radio' | 'Checkbox' | 'Switch' | 'DatePicker' | 'TimePicker' | 'DateTimePicker' | 'WeekPicker' | 'MonthPicker' | 'YearPicker' | 'QuarterPicker' | 'DateRangePicker' | 'TimeRangePicker' | 'DateTimeRangePicker' | 'WeekRangePicker' | 'MonthRangePicker' | 'YearRangePicker' | 'QuarterRangePicker' | 'Transfer' | 'Upload' | 'ColorPicker' | 'ColorRadio' | 'IconPicker' | 'JsonInput' | 'TagPicker' | 'MultipleTagPicker' | 'Range' | 'Search';
|
10
10
|
export declare type IButtonComponent = 'Submit' | 'Reset';
|
11
11
|
export declare type IComboComponent = 'ArrayCards' | 'ArrayCards.Addition' | 'ArrayCards.Remove' | 'ArrayCards.MoveUp' | 'ArrayCards.MoveDown' | 'ArrayCards.Index' | 'ArrayCollapse' | 'ArrayCollapse.CollapsePanel' | 'ArrayCollapse.Addition' | 'ArrayCollapse.Remove' | 'ArrayCollapse.MoveUp' | 'ArrayCollapse.MoveDown' | 'ArrayCollapse.Index' | 'ArrayTable' | 'ArrayTable.Column' | 'ArrayTable.SortHandle' | 'ArrayTable.Addition' | 'ArrayTable.Remove' | 'ArrayTable.MoveDown' | 'ArrayTable.MoveUp' | 'ArrayTable.Index' | 'ArrayItems' | 'ArrayItems.Item' | 'ArrayItems.SortHandle' | 'ArrayItems.Addition' | 'ArrayItems.Remove' | 'ArrayItems.MoveDown' | 'ArrayItems.MoveUp' | 'ArrayItems.Index' | 'Editable' | 'Editable.Popover' | 'Editable.Dialog' | 'Editable.Drawer';
|
12
12
|
export declare type ILayoutComponent = 'FormFlex' | 'FormGrid' | 'FormGroup' | 'FormGroup.GroupPanel' | 'Search' | 'Search.SearchPanel' | 'FormTab' | 'FormTab.TabPane' | 'FormStep' | 'FormStep.StepPane' | 'FormCollapse' | 'FormCollapse.CollapsePanel' | 'FormButtonGroup' | 'FormDialog' | 'FormDrawer' | 'FormDialog.Footer' | 'FormDrawer.Footer';
|
@@ -57,7 +57,7 @@ export interface IFormProps extends IFormLayoutProps {
|
|
57
57
|
initialValues?: anyObject;
|
58
58
|
initialRequest?: CommonRequestConfig;
|
59
59
|
previewTextPlaceholder?: ReactNode;
|
60
|
-
onChange?: (values: any, displayValues
|
60
|
+
onChange?: (values: any, displayValues?: any) => any;
|
61
61
|
onSubmit?: ((values: any) => any) | CommonRequestConfig;
|
62
62
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
63
63
|
}
|
package/es/form/utils.d.ts
CHANGED
@@ -1,14 +1,37 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* 映射字段size,主要是default转medium
|
3
|
+
* @param props component的props
|
4
|
+
* @param field 当前字段实例
|
5
|
+
* @returns 映射后的字段属性
|
6
|
+
*/
|
7
|
+
declare const mapSize: (props: any, field: any) => any;
|
8
|
+
/**
|
9
|
+
* 映射字段state
|
10
|
+
* @param props component的props
|
11
|
+
* @param field 当前字段实例
|
12
|
+
* @returns 映射后的字段属性
|
13
|
+
*/
|
14
|
+
declare const mapStatus: (props: any, field: any) => any;
|
15
|
+
/**
|
16
|
+
* 为未配置name的字段添加随机字段名称
|
17
|
+
* @param prefix 随机字段名称前缀,默认为name
|
18
|
+
* @returns 随机字段名称
|
19
|
+
*/
|
2
20
|
interface IGetRandomName {
|
3
21
|
(prefix?: string): string;
|
4
22
|
}
|
5
|
-
declare const mapSize: (props: any, field: any) => any;
|
6
|
-
declare const mapStatus: (props: any, field: any) => any;
|
7
23
|
declare const getRandomName: IGetRandomName;
|
24
|
+
/**
|
25
|
+
* 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
|
26
|
+
* @param obj
|
27
|
+
* @returns
|
28
|
+
*/
|
8
29
|
declare const mapSchemaName: (obj: any) => any;
|
30
|
+
/**
|
31
|
+
* 合并数组或非数组,不移除无效值
|
32
|
+
* @param arr 数组
|
33
|
+
* @param v 数组或其他
|
34
|
+
* @returns 合并数组或合并其他值
|
35
|
+
*/
|
9
36
|
declare const mergeArrayValue: (arr: any[], v?: any) => any[];
|
10
|
-
|
11
|
-
(form: any, values: any, prefix?: string): any;
|
12
|
-
}
|
13
|
-
declare const getDisplayValues: IGetDisplayValues;
|
14
|
-
export { getRandomName, getValueByValue, getDisplayValues, mapSize, mapStatus, mergeArrayValue, mapSchemaName, };
|
37
|
+
export { getRandomName, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
|
package/es/form/utils.js
CHANGED
@@ -27,6 +27,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
27
27
|
import { useFormLayout, useFormShallowLayout } from '@teamix/formily';
|
28
28
|
import { isArr, isObj, getValueByValue } from '@teamix/utils';
|
29
29
|
import schemaNameMap from './schemaNameMap';
|
30
|
+
/**
|
31
|
+
* 映射字段size,主要是default转medium
|
32
|
+
* @param props component的props
|
33
|
+
* @param field 当前字段实例
|
34
|
+
* @returns 映射后的字段属性
|
35
|
+
*/
|
30
36
|
|
31
37
|
var mapSize = function mapSize(props, field) {
|
32
38
|
var layout = _objectSpread(_objectSpread({}, useFormShallowLayout()), useFormLayout());
|
@@ -39,6 +45,13 @@ var mapSize = function mapSize(props, field) {
|
|
39
45
|
size: props.size || takeSize()
|
40
46
|
});
|
41
47
|
};
|
48
|
+
/**
|
49
|
+
* 映射字段state
|
50
|
+
* @param props component的props
|
51
|
+
* @param field 当前字段实例
|
52
|
+
* @returns 映射后的字段属性
|
53
|
+
*/
|
54
|
+
|
42
55
|
|
43
56
|
var mapStatus = function mapStatus(props, field) {
|
44
57
|
var takeStatus = function takeStatus() {
|
@@ -66,7 +79,12 @@ var mapStatus = function mapStatus(props, field) {
|
|
66
79
|
var getRandomName = function getRandomName() {
|
67
80
|
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name';
|
68
81
|
return "".concat(prefix, "_").concat(Math.floor(Math.random() * Math.pow(10, 18)));
|
69
|
-
};
|
82
|
+
};
|
83
|
+
/**
|
84
|
+
* 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
|
85
|
+
* @param obj
|
86
|
+
* @returns
|
87
|
+
*/
|
70
88
|
|
71
89
|
|
72
90
|
var mapSchemaName = function mapSchemaName(obj) {
|
@@ -97,6 +115,13 @@ var mapSchemaName = function mapSchemaName(obj) {
|
|
97
115
|
});
|
98
116
|
return temp;
|
99
117
|
};
|
118
|
+
/**
|
119
|
+
* 合并数组或非数组,不移除无效值
|
120
|
+
* @param arr 数组
|
121
|
+
* @param v 数组或其他
|
122
|
+
* @returns 合并数组或合并其他值
|
123
|
+
*/
|
124
|
+
|
100
125
|
|
101
126
|
var mergeArrayValue = function mergeArrayValue(arr, v) {
|
102
127
|
if (isArr(v)) {
|
@@ -104,48 +129,6 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
|
|
104
129
|
}
|
105
130
|
|
106
131
|
return [].concat(_toConsumableArray(arr), [v]);
|
107
|
-
}; // 获取form的displayValues
|
108
|
-
|
109
|
-
|
110
|
-
var getDisplayValues = function getDisplayValues(form, values) {
|
111
|
-
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
112
|
-
var displayValues = {}; // 在form实例中,通过name获取该field的值在dataSource对应的label
|
113
|
-
|
114
|
-
var getLabelByKey = function getLabelByKey(name, value) {
|
115
|
-
var address = form.indexes[name] || '';
|
116
|
-
var field = form.query(address).take() || {};
|
117
|
-
var dataSource = field.dataSource;
|
118
|
-
return getValueByValue(dataSource, value);
|
119
|
-
};
|
120
|
-
|
121
|
-
Object.entries(values).forEach(function (_ref3) {
|
122
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
123
|
-
key = _ref4[0],
|
124
|
-
value = _ref4[1];
|
125
|
-
|
126
|
-
var label;
|
127
|
-
|
128
|
-
if (isArr(value)) {
|
129
|
-
value.map(function (v, i) {
|
130
|
-
if (isObj(v)) {
|
131
|
-
// 值是对象数组
|
132
|
-
label = getDisplayValues(form, v, "".concat(prefix).concat(key, ".").concat(i, "."));
|
133
|
-
} else if (isArr(v)) {
|
134
|
-
// 值是多重数组
|
135
|
-
console.warn('Multiple array, Please dingding qilou.zhl.');
|
136
|
-
} else if (v !== undefined && v !== null) {
|
137
|
-
label = getLabelByKey("".concat(prefix).concat(key, ".").concat(i), value);
|
138
|
-
}
|
139
|
-
});
|
140
|
-
} else if (isObj(value)) {
|
141
|
-
label = getDisplayValues(form, value, "".concat(key, "."));
|
142
|
-
} else {
|
143
|
-
label = getLabelByKey("".concat(prefix).concat(key), value);
|
144
|
-
}
|
145
|
-
|
146
|
-
displayValues[key] = label;
|
147
|
-
});
|
148
|
-
return displayValues;
|
149
132
|
};
|
150
133
|
|
151
|
-
export { getRandomName,
|
134
|
+
export { getRandomName, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
|
package/es/index.d.ts
CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
|
|
21
21
|
export * from './page-header';
|
22
22
|
export * from './skeleton';
|
23
23
|
export * from './table';
|
24
|
-
declare const version = "1.1.
|
24
|
+
declare const version = "1.1.32";
|
25
25
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -25,6 +25,6 @@ export * from './page-container';
|
|
25
25
|
export * from './page-header';
|
26
26
|
export * from './skeleton';
|
27
27
|
export * from './table';
|
28
|
-
var version = '1.1.
|
28
|
+
var version = '1.1.32';
|
29
29
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
30
30
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils };
|
@@ -86,9 +86,11 @@ var Filter = function Filter(props) {
|
|
86
86
|
|
87
87
|
var renderSingle = function renderSingle() {
|
88
88
|
return filters === null || filters === void 0 ? void 0 : filters.map(function (_ref3) {
|
89
|
+
var _value$toString;
|
90
|
+
|
89
91
|
var label = _ref3.label,
|
90
92
|
value = _ref3.value;
|
91
|
-
var valueStr = value.toString();
|
93
|
+
var valueStr = (_value$toString = value === null || value === void 0 ? void 0 : value.toString()) !== null && _value$toString !== void 0 ? _value$toString : '';
|
92
94
|
return /*#__PURE__*/React.createElement(RadioItem, {
|
93
95
|
id: valueStr,
|
94
96
|
checked: selected.includes(valueStr),
|
@@ -103,9 +105,11 @@ var Filter = function Filter(props) {
|
|
103
105
|
|
104
106
|
var renderMultiple = function renderMultiple() {
|
105
107
|
return filters === null || filters === void 0 ? void 0 : filters.map(function (_ref4) {
|
108
|
+
var _value$toString2;
|
109
|
+
|
106
110
|
var label = _ref4.label,
|
107
111
|
value = _ref4.value;
|
108
|
-
var valueStr = value.toString();
|
112
|
+
var valueStr = (_value$toString2 = value === null || value === void 0 ? void 0 : value.toString()) !== null && _value$toString2 !== void 0 ? _value$toString2 : '';
|
109
113
|
return /*#__PURE__*/React.createElement(CheckboxItem, {
|
110
114
|
key: valueStr,
|
111
115
|
checked: selected.includes(valueStr),
|
package/es/table/typing.d.ts
CHANGED
@@ -11,8 +11,10 @@ import { Method } from 'axios';
|
|
11
11
|
import React from 'react';
|
12
12
|
import type { Form as FormType } from '@formily/core';
|
13
13
|
declare type IFieldRenderProps = keyof IProFieldFormatterProps;
|
14
|
+
/** 列record函数 */
|
15
|
+
declare type ProTableCellFunProp = (value: any, index: number, record: any) => any;
|
14
16
|
declare type ITableCellRender = {
|
15
|
-
[key in IFieldRenderProps]?: IProFieldFormatterProps[key] |
|
17
|
+
[key in IFieldRenderProps]?: IProFieldFormatterProps[key] | ProTableCellFunProp;
|
16
18
|
} | ((...other: any) => React.ReactNode);
|
17
19
|
declare type TDataService = {
|
18
20
|
/** 翻页器总数 */
|
@@ -31,14 +33,14 @@ export declare type ProColumnProps = {
|
|
31
33
|
tooltipIcon?: React.ReactNode;
|
32
34
|
/** 对应 ProField 里面的 type */
|
33
35
|
valueType?: IProFieldType;
|
34
|
-
/**
|
36
|
+
/** 【列配置】是否默认隐藏列 */
|
35
37
|
columnFilters?: boolean;
|
36
|
-
/**
|
38
|
+
/** 【列配置】是否禁用隐藏列 */
|
37
39
|
columnFiltersDisabled?: boolean;
|
38
40
|
/** 渲染单元格内容字段 */
|
39
41
|
render?: ITableCellRender;
|
40
42
|
/** 枚举值 */
|
41
|
-
dataSource?: IProFieldOptionItem[];
|
43
|
+
dataSource?: IProFieldOptionItem[] | ProTableCellFunProp;
|
42
44
|
/** 表头的过滤菜单项,当值为 true 时,自动使用 dataSource 生成 */
|
43
45
|
filters?: boolean | ProTableColumnsFilterItemProps[];
|
44
46
|
/** 表头的过滤菜单项过滤方式 single 单选 multiple 多选 */
|
@@ -49,6 +51,8 @@ export declare type ProColumnProps = {
|
|
49
51
|
actionSchema?: ActionGroupProps;
|
50
52
|
/** 指定列对应的字段,支持`a.b`形式的快速取值 和 数组取值 */
|
51
53
|
dataIndex?: string | string[];
|
54
|
+
/** 指定 valueType 为日期时间格式时,可以格式化日期时间 */
|
55
|
+
format?: string;
|
52
56
|
} & Omit<ColumnProps, 'filters' | 'dataIndex' | 'filtersMode'>;
|
53
57
|
export declare type ProTableProps = {
|
54
58
|
/** ProColums 定义,取代 Table 的 columns */
|