@teamix/pro 1.1.32 → 1.1.36

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.
Files changed (87) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1183 -637
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/dialog-form.d.ts +8 -1
  6. package/es/actions/dialog-form.js +32 -15
  7. package/es/actions/dialog-info.d.ts +9 -0
  8. package/es/actions/dialog-info.js +23 -0
  9. package/es/actions/dialog.d.ts +2 -0
  10. package/es/actions/dialog.js +11 -4
  11. package/es/actions/drawer-info.d.ts +6 -0
  12. package/es/actions/drawer-info.js +7 -0
  13. package/es/actions/index.d.ts +11 -5
  14. package/es/actions/index.js +40 -19
  15. package/es/actions/index.scss +8 -0
  16. package/es/actions/link.js +2 -12
  17. package/es/form/Components/ProField/index.d.ts +4 -0
  18. package/es/form/ProForm/index.js +2 -2
  19. package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
  20. package/es/form/ProForm/useFormDisplayValues.js +65 -0
  21. package/es/form/SchemaForm/adapterType.js +2 -1
  22. package/es/form/SchemaForm/initializeProField.js +1 -0
  23. package/es/form/SchemaForm/initializeReactions.js +82 -6
  24. package/es/form/SchemaForm/reactions.js +4 -2
  25. package/es/form/index.d.ts +3 -3
  26. package/es/form/index.js +3 -3
  27. package/es/form/typing.d.ts +2 -2
  28. package/es/form/utils.d.ts +31 -8
  29. package/es/form/utils.js +27 -44
  30. package/es/index.d.ts +1 -1
  31. package/es/index.js +1 -1
  32. package/es/info/components/InfoValueItem/index.js +108 -26
  33. package/es/info/components/baseInfo/index.d.ts +3 -1
  34. package/es/info/components/baseInfo/index.js +6 -33
  35. package/es/info/components/headerInfo/index.d.ts +3 -1
  36. package/es/info/components/headerInfo/index.js +8 -39
  37. package/es/info/components/tableInfo/index.js +4 -21
  38. package/es/info/index.js +47 -25
  39. package/es/info/index.scss +0 -4
  40. package/es/info/typing.d.ts +14 -5
  41. package/es/page-header/index.js +1 -1
  42. package/es/table/components/Filter/index.js +6 -2
  43. package/es/table/index.js +3 -1
  44. package/es/table/typing.d.ts +8 -4
  45. package/es/table/utils/columnRender.js +38 -11
  46. package/lib/actions/dialog-form.d.ts +8 -1
  47. package/lib/actions/dialog-form.js +32 -15
  48. package/lib/actions/dialog-info.d.ts +9 -0
  49. package/lib/actions/dialog-info.js +37 -0
  50. package/lib/actions/dialog.d.ts +2 -0
  51. package/lib/actions/dialog.js +11 -4
  52. package/lib/actions/drawer-info.d.ts +6 -0
  53. package/lib/actions/drawer-info.js +18 -0
  54. package/lib/actions/index.d.ts +11 -5
  55. package/lib/actions/index.js +41 -18
  56. package/lib/actions/index.scss +8 -0
  57. package/lib/actions/link.js +2 -12
  58. package/lib/form/Components/ProField/index.d.ts +4 -0
  59. package/lib/form/ProForm/index.js +1 -1
  60. package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
  61. package/lib/form/ProForm/useFormDisplayValues.js +74 -0
  62. package/lib/form/SchemaForm/adapterType.js +2 -1
  63. package/lib/form/SchemaForm/initializeProField.js +1 -0
  64. package/lib/form/SchemaForm/initializeReactions.js +87 -7
  65. package/lib/form/SchemaForm/reactions.js +4 -2
  66. package/lib/form/index.d.ts +3 -3
  67. package/lib/form/index.js +15 -8
  68. package/lib/form/typing.d.ts +2 -2
  69. package/lib/form/utils.d.ts +31 -8
  70. package/lib/form/utils.js +28 -54
  71. package/lib/index.d.ts +1 -1
  72. package/lib/index.js +1 -1
  73. package/lib/info/components/InfoValueItem/index.js +107 -25
  74. package/lib/info/components/baseInfo/index.d.ts +3 -1
  75. package/lib/info/components/baseInfo/index.js +5 -40
  76. package/lib/info/components/headerInfo/index.d.ts +3 -1
  77. package/lib/info/components/headerInfo/index.js +7 -46
  78. package/lib/info/components/tableInfo/index.js +4 -22
  79. package/lib/info/index.js +49 -25
  80. package/lib/info/index.scss +0 -4
  81. package/lib/info/typing.d.ts +14 -5
  82. package/lib/page-header/index.js +1 -1
  83. package/lib/table/components/Filter/index.js +6 -2
  84. package/lib/table/index.js +3 -1
  85. package/lib/table/typing.d.ts +8 -4
  86. package/lib/table/utils/columnRender.js +38 -11
  87. package/package.json +1 -1
@@ -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 initializeReactions = function initializeReactions(reactions, innerReactions) {
4
- if (reactions && innerReactions.length) {
5
- return mergeArrayValue(innerReactions, reactions);
6
- } else if (innerReactions.length) {
7
- return innerReactions;
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 reactions;
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;
@@ -8,6 +8,8 @@ import { isFn, doCommonRequest } from '@teamix/utils'; // 配置请求
8
8
 
9
9
  var useRequest = function useRequest(requestConfig) {
10
10
  return function (field) {
11
+ var _field$form;
12
+
11
13
  var beforeRequest = requestConfig.beforeRequest,
12
14
  onSuccess = requestConfig.onSuccess;
13
15
  var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field) : {};
@@ -21,8 +23,8 @@ var useRequest = function useRequest(requestConfig) {
21
23
  } : onSuccess
22
24
  }), {
23
25
  $self: field,
24
- $form: field.form,
25
- $values: field.form.values
26
+ $form: field === null || field === void 0 ? void 0 : field.form,
27
+ $values: field === null || field === void 0 ? void 0 : (_field$form = field.form) === null || _field$form === void 0 ? void 0 : _field$form.values
26
28
  });
27
29
  };
28
30
  }; // 配置校验
@@ -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 { getDisplayValues } from './utils';
19
- export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, getDisplayValues, };
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 { getDisplayValues } from './utils';
25
- export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, getDisplayValues };
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
  */
@@ -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: any) => any;
60
+ onChange?: (values: any, displayValues?: any) => any;
61
61
  onSubmit?: ((values: any) => any) | CommonRequestConfig;
62
62
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
63
63
  }
@@ -1,14 +1,37 @@
1
- import { getValueByValue } from '@teamix/utils';
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
- interface IGetDisplayValues {
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
- }; // 将ProForm的key映射为formily的key,然后筛除掉无效的keyvalue
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, getValueByValue, getDisplayValues, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
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.31";
24
+ declare const version = "1.1.35";
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.31';
28
+ var version = '1.1.35';
29
29
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
30
30
  ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils };
@@ -1,4 +1,18 @@
1
- var _excluded = ["type", "value", "render", "infoItem", "record", "actionRef"];
1
+ var _excluded = ["type", "value", "render", "infoItem", "record", "actionRef", "dataSource"];
2
+
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+
5
+ 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."); }
6
+
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ 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; }
12
+
13
+ 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; }
14
+
15
+ 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; }
2
16
 
3
17
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
18
 
@@ -12,19 +26,13 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
12
26
 
13
27
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
28
 
15
- 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; }
16
-
17
- 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; }
18
-
19
- 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; }
20
-
21
29
  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; }
22
30
 
23
31
  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; }
24
32
 
25
33
  import TeamixIcon from '@teamix/icon';
26
34
  import ProField from '../../../field';
27
- import { baseClass, request } from '@teamix/utils';
35
+ import { baseClass, getTargetValue, request } from '@teamix/utils';
28
36
  import PopConfirm from '@teamix/pop-confirm';
29
37
  import React, { useMemo, useState } from 'react';
30
38
  import './index.scss';
@@ -42,6 +50,7 @@ var InfoValueItem = function InfoValueItem(props) {
42
50
  infoItem = props.infoItem,
43
51
  record = props.record,
44
52
  actionRef = props.actionRef,
53
+ dataSource = props.dataSource,
45
54
  others = _objectWithoutProperties(props, _excluded);
46
55
 
47
56
  var dataIndex = infoItem.dataIndex,
@@ -55,28 +64,41 @@ var InfoValueItem = function InfoValueItem(props) {
55
64
  _infoItem$successMess = infoItem.successMessage,
56
65
  successMessage = _infoItem$successMess === void 0 ? 'success' : _infoItem$successMess,
57
66
  actions = infoItem.actions,
58
- extra = infoItem.extra; // 由info接管field中的value。重新实现
59
- // let fieldRender = render;
60
- // let newValue = value;
61
- // if (render && typeof render !== 'function') {
62
- // const { value, ...others } = render;
63
- // fieldRender = others;
64
- // if (value) {
65
- // newValue = getTargetValue(`${value}`, { ...record, record });
66
- // console.log("newValue", newValue);
67
- // }
68
- // }
69
- // 获取render
67
+ extra = infoItem.extra; // 获取处理过的 render
70
68
 
71
69
  var getRender = function getRender() {
70
+ var _processRenderFunctio;
71
+
72
72
  if (typeof render === 'function') {
73
73
  return render;
74
74
  }
75
75
 
76
- return _objectSpread({
77
- ellipsis: true,
78
- emptyText: '-'
79
- }, render);
76
+ var newRender = processBuriedPoint((_processRenderFunctio = processRenderFunction(render !== null && render !== void 0 ? render : {}, value, record)) !== null && _processRenderFunctio !== void 0 ? _processRenderFunctio : {}, value, record);
77
+ return newRender;
78
+ }; // 获取处理过的 dataSource
79
+
80
+
81
+ var getDataSource = function getDataSource() {
82
+ var newDataSource = null;
83
+
84
+ if (typeof dataSource === 'function') {
85
+ newDataSource = dataSource === null || dataSource === void 0 ? void 0 : dataSource(value, record);
86
+ } else {
87
+ newDataSource = (dataSource !== null && dataSource !== void 0 ? dataSource : []).map(function (item) {
88
+ return Object.fromEntries(Object.entries(item).map(function (_ref) {
89
+ var _ref2 = _slicedToArray(_ref, 2),
90
+ k = _ref2[0],
91
+ v = _ref2[1];
92
+
93
+ return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
94
+ record: record,
95
+ value: value
96
+ }))];
97
+ }));
98
+ });
99
+ }
100
+
101
+ return newDataSource;
80
102
  }; // 浮层的显隐状态
81
103
 
82
104
 
@@ -115,6 +137,64 @@ var InfoValueItem = function InfoValueItem(props) {
115
137
 
116
138
  return /*#__PURE__*/React.createElement(React.Fragment, null);
117
139
  };
140
+ /**
141
+ * 处理 render 配置项是函数的情况
142
+ * @param render ProFieldRender
143
+ * @param value table cell value
144
+ * @param record table cell record
145
+ * @returns
146
+ */
147
+
148
+
149
+ var processRenderFunction = function processRenderFunction(render, value, record) {
150
+ var external = ['linkOnClick', 'link', 'value'];
151
+ return Object.fromEntries(Object.entries(render).map(function (_ref3) {
152
+ var _ref4 = _slicedToArray(_ref3, 2),
153
+ k = _ref4[0],
154
+ v = _ref4[1];
155
+
156
+ if (typeof v === 'function') {
157
+ var _v;
158
+
159
+ if (external.includes(k)) {
160
+ return [k, function () {
161
+ for (var _len = arguments.length, others = new Array(_len), _key = 0; _key < _len; _key++) {
162
+ others[_key] = arguments[_key];
163
+ }
164
+
165
+ return v === null || v === void 0 ? void 0 : v.apply(void 0, [value, record].concat(others));
166
+ }];
167
+ }
168
+
169
+ return [k, (_v = v === null || v === void 0 ? void 0 : v(value, record)) !== null && _v !== void 0 ? _v : ''];
170
+ }
171
+
172
+ return [k, v];
173
+ }));
174
+ };
175
+ /**
176
+ * 处理 render 数据,取出 {{xxx}} 匹配值
177
+ * @param render ProFieldRender
178
+ * @param record table cell record
179
+ * @returns
180
+ */
181
+
182
+
183
+ var processBuriedPoint = function processBuriedPoint(render, value, record) {
184
+ return Object.fromEntries([// 默认 ellipsis、descriptionEllipsis 为 true
185
+ // emptyText 默认为 '-'
186
+ ['ellipsis', true], ['descriptionEllipsis', true], ['emptyText', '-']].concat(_toConsumableArray(Object.entries(render).map(function (_ref5) {
187
+ var _ref6 = _slicedToArray(_ref5, 2),
188
+ k = _ref6[0],
189
+ v = _ref6[1];
190
+
191
+ return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
192
+ record: record,
193
+ value: value
194
+ }))];
195
+ }))));
196
+ }; // 重写编辑逻辑替代field原有逻辑
197
+
118
198
 
119
199
  if (isEdit) {
120
200
  // 渲染表单
@@ -195,7 +275,8 @@ var InfoValueItem = function InfoValueItem(props) {
195
275
  }, /*#__PURE__*/React.createElement(ProField, _objectSpread({
196
276
  type: type,
197
277
  value: value,
198
- render: getRender()
278
+ render: getRender(),
279
+ dataSource: getDataSource()
199
280
  }, others)), /*#__PURE__*/React.createElement(PopConfirm, {
200
281
  visible: popConfirmVisible,
201
282
  content: renderContent(),
@@ -226,7 +307,8 @@ var InfoValueItem = function InfoValueItem(props) {
226
307
  }, /*#__PURE__*/React.createElement(ProField, _objectSpread({
227
308
  type: type,
228
309
  value: value,
229
- render: getRender()
310
+ render: getRender(),
311
+ dataSource: getDataSource()
230
312
  }, others)), renderAction(), extra && extra);
231
313
  };
232
314
 
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { ProInfoBaseProps, ProInfoTransparentBase } from '../../typing';
3
3
  import './index.scss';
4
4
  import { IUseInfoRequestResult } from '../../utils/useInfoRequest';
5
- declare type ProBaseInfoProps = ProInfoBaseProps & IUseInfoRequestResult & ProInfoTransparentBase;
5
+ declare type ProBaseInfoProps = ProInfoBaseProps & IUseInfoRequestResult & ProInfoTransparentBase & {
6
+ size?: any;
7
+ };
6
8
  declare const ProBaseInfo: React.FC<ProBaseInfoProps>;
7
9
  export default ProBaseInfo;
@@ -1,44 +1,24 @@
1
- var _excluded = ["header", "columns", "dataSource", "loading", "result", "actionRef", "className", "layout"];
2
-
3
- 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; }
4
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- 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; }
10
-
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
-
13
1
  import { Grid } from '@alicloudfe/components';
14
- import { ProCard } from '../../../';
15
- import React, { useContext, useRef } from 'react';
2
+ import React from 'react';
16
3
  import ProInfoItem from '../ProInfoItem';
17
4
  import './index.scss';
18
- import { useSize } from '@teamix/hooks';
19
5
  import { getLayout } from '../../utils/utils';
20
6
  import defaultLayoutMap from '../../utils/layout';
21
7
  import InfoValueItem from '../InfoValueItem';
22
- import { getDataIndexValue, ProInfoGroupContext } from '../../utils';
8
+ import { getDataIndexValue } from '../../utils';
23
9
  var Row = Grid.Row,
24
10
  Col = Grid.Col;
25
11
 
26
12
  var ProBaseInfo = function ProBaseInfo(props) {
27
13
  var _size$width;
28
14
 
29
- var header = props.header,
30
- columns = props.columns,
15
+ var columns = props.columns,
31
16
  dataSource = props.dataSource,
32
17
  loading = props.loading,
33
18
  result = props.result,
34
19
  actionRef = props.actionRef,
35
- className = props.className,
36
20
  layout = props.layout,
37
- others = _objectWithoutProperties(props, _excluded);
38
-
39
- var context = useContext(ProInfoGroupContext);
40
- var ref = useRef();
41
- var size = context.visible ? context.size : useSize(ref);
21
+ size = props.size;
42
22
  var defaultLayout = defaultLayoutMap[getLayout((_size$width = size === null || size === void 0 ? void 0 : size.width) !== null && _size$width !== void 0 ? _size$width : 0)]; // 获取列的布局参数
43
23
 
44
24
  var getFormItemLayout = function getFormItemLayout() {
@@ -81,17 +61,10 @@ var ProBaseInfo = function ProBaseInfo(props) {
81
61
  });
82
62
  };
83
63
 
84
- return /*#__PURE__*/React.createElement("div", _objectSpread({
85
- ref: ref,
86
- className: "teamix-pro-info ".concat(className !== null && className !== void 0 ? className : '')
87
- }, others), (size === null || size === void 0 ? void 0 : size.width) && /*#__PURE__*/React.createElement(ProCard, _objectSpread({
88
- compacted: true,
89
- hoveredShadow: false,
90
- bordered: false
91
- }, header), /*#__PURE__*/React.createElement(Row, {
64
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (size === null || size === void 0 ? void 0 : size.width) && /*#__PURE__*/React.createElement(Row, {
92
65
  wrap: true,
93
66
  className: "teamix-pro-info-content-row"
94
- }, renderContent())));
67
+ }, renderContent()));
95
68
  };
96
69
 
97
70
  export default ProBaseInfo;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { IProHeaderInfo, ProInfoTransparentBase } from '../../typing';
3
3
  import { IUseInfoRequestResult } from '../../utils/useInfoRequest';
4
4
  import './index.scss';
5
- declare type ProHeaderInfoProps = IProHeaderInfo & IUseInfoRequestResult & ProInfoTransparentBase;
5
+ declare type ProHeaderInfoProps = IProHeaderInfo & IUseInfoRequestResult & ProInfoTransparentBase & {
6
+ size?: any;
7
+ };
6
8
  declare const ProHeaderInfo: React.FC<ProHeaderInfoProps>;
7
9
  export default ProHeaderInfo;