@teamix/pro 1.1.29 → 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.
Files changed (77) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1329 -892
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/dialog-form.js +3 -1
  6. package/es/actions/dialog.d.ts +0 -2
  7. package/es/actions/dialog.js +16 -23
  8. package/es/actions/index.js +13 -8
  9. package/es/actions/link.d.ts +2 -8
  10. package/es/actions/link.js +2 -22
  11. package/es/actions/request.d.ts +1 -1
  12. package/es/actions/request.js +6 -3
  13. package/es/form/Components/FormGroup/index.scss +1 -1
  14. package/es/form/Components/ProField/index.d.ts +4 -0
  15. package/es/form/Components/Query/index.scss +1 -6
  16. package/es/form/Components/Text/index.scss +4 -2
  17. package/es/form/ProForm/index.js +3 -16
  18. package/es/form/ProForm/index.scss +4 -11
  19. package/es/form/ProForm/useAutoSubmit.js +3 -1
  20. package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
  21. package/es/form/ProForm/useFormDisplayValues.js +65 -0
  22. package/es/form/SchemaForm/adapterType.js +2 -1
  23. package/es/form/SchemaForm/index.js +5 -15
  24. package/es/form/SchemaForm/initializeProField.js +1 -0
  25. package/es/form/SchemaForm/initializeReactions.d.ts +2 -0
  26. package/es/form/SchemaForm/initializeReactions.js +89 -0
  27. package/es/form/SchemaForm/reactions.js +10 -2
  28. package/es/form/global.scss +12 -0
  29. package/es/form/index.d.ts +3 -3
  30. package/es/form/index.js +3 -3
  31. package/es/form/typing.d.ts +2 -2
  32. package/es/form/utils.d.ts +31 -8
  33. package/es/form/utils.js +27 -44
  34. package/es/index.d.ts +1 -1
  35. package/es/index.js +1 -1
  36. package/es/info/components/ProInfoItem/index.js +4 -2
  37. package/es/table/components/Filter/index.js +6 -2
  38. package/es/table/index.js +15 -3
  39. package/es/table/typing.d.ts +8 -4
  40. package/es/table/utils/columnRender.js +38 -11
  41. package/lib/actions/dialog-form.js +4 -1
  42. package/lib/actions/dialog.d.ts +0 -2
  43. package/lib/actions/dialog.js +15 -23
  44. package/lib/actions/index.js +12 -7
  45. package/lib/actions/link.d.ts +2 -8
  46. package/lib/actions/link.js +2 -25
  47. package/lib/actions/request.d.ts +1 -1
  48. package/lib/actions/request.js +7 -3
  49. package/lib/form/Components/FormGroup/index.scss +1 -1
  50. package/lib/form/Components/ProField/index.d.ts +4 -0
  51. package/lib/form/Components/Query/index.scss +1 -6
  52. package/lib/form/Components/Text/index.scss +4 -2
  53. package/lib/form/ProForm/index.js +2 -15
  54. package/lib/form/ProForm/index.scss +4 -11
  55. package/lib/form/ProForm/useAutoSubmit.js +4 -1
  56. package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
  57. package/lib/form/ProForm/useFormDisplayValues.js +74 -0
  58. package/lib/form/SchemaForm/adapterType.js +2 -1
  59. package/lib/form/SchemaForm/index.js +5 -14
  60. package/lib/form/SchemaForm/initializeProField.js +1 -0
  61. package/lib/form/SchemaForm/initializeReactions.d.ts +2 -0
  62. package/lib/form/SchemaForm/initializeReactions.js +101 -0
  63. package/lib/form/SchemaForm/reactions.js +10 -2
  64. package/lib/form/global.scss +12 -0
  65. package/lib/form/index.d.ts +3 -3
  66. package/lib/form/index.js +15 -8
  67. package/lib/form/typing.d.ts +2 -2
  68. package/lib/form/utils.d.ts +31 -8
  69. package/lib/form/utils.js +28 -54
  70. package/lib/index.d.ts +1 -1
  71. package/lib/index.js +1 -1
  72. package/lib/info/components/ProInfoItem/index.js +3 -1
  73. package/lib/table/components/Filter/index.js +6 -2
  74. package/lib/table/index.js +15 -3
  75. package/lib/table/typing.d.ts +8 -4
  76. package/lib/table/utils/columnRender.js +38 -11
  77. package/package.json +4 -4
@@ -0,0 +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';
30
+ import { mergeArrayValue } from '../utils';
31
+ import schemaNameMap from '../schemaNameMap';
32
+
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;
54
+ }
55
+
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;
87
+ };
88
+
89
+ export default initializeReactions;
@@ -43,10 +43,18 @@ var useAsyncDataSource = function useAsyncDataSource(services, onComplete) {
43
43
  loading: true
44
44
  });
45
45
  return services(field).then(function (res) {
46
- field.setState({
46
+ var _res$map;
47
+
48
+ var isValueInDataSource = res === null || res === void 0 ? void 0 : (_res$map = res.map(function (v) {
49
+ return v.value;
50
+ })) === null || _res$map === void 0 ? void 0 : _res$map.includes(field.value);
51
+ var clearValue = isValueInDataSource ? {} : {
52
+ value: undefined
53
+ };
54
+ field.setState(_objectSpread({
47
55
  dataSource: res,
48
56
  loading: false
49
- });
57
+ }, clearValue));
50
58
  return onComplete && onComplete(res, field);
51
59
  }).catch(function () {
52
60
  field.setState({
@@ -0,0 +1,12 @@
1
+ @import '~@alicloudfe/components/lib/common-var.scss';
2
+
3
+ $form-item-cls: #{$css-prefix}formily-item;
4
+ $teamix-pro-form: teamix-pro-form;
5
+
6
+ $inset-font-weight-medium: calc(
7
+ var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
8
+ );
9
+
10
+ $noborder-font-weight-medium: calc(
11
+ var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
12
+ );
@@ -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.28";
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';
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 };
@@ -1,6 +1,6 @@
1
1
  import { Grid } from '@alicloudfe/components';
2
2
  import { BaseSkeleton } from '../../..';
3
- import { baseClass, LabelIconTip } from '@teamix/utils';
3
+ import { baseClass, Ellipsis, LabelIconTip } from '@teamix/utils';
4
4
  import React from 'react';
5
5
  import './index.scss';
6
6
  var cls = baseClass('teamix-pro-field-info-form-item');
@@ -24,11 +24,13 @@ var ProInfoItem = function ProInfoItem(prop) {
24
24
  }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
25
25
  span: labelCol === null || labelCol === void 0 ? void 0 : labelCol.span,
26
26
  className: cls('label')
27
+ }, /*#__PURE__*/React.createElement(Ellipsis, {
28
+ tooltip: label
27
29
  }, /*#__PURE__*/React.createElement(LabelIconTip, {
28
30
  label: label,
29
31
  tooltip: tooltip,
30
32
  icon: tooltipIcon
31
- })), /*#__PURE__*/React.createElement(Col, {
33
+ }))), /*#__PURE__*/React.createElement(Col, {
32
34
  span: wrapperCol === null || wrapperCol === void 0 ? void 0 : wrapperCol.span,
33
35
  className: cls('value')
34
36
  }, loading && /*#__PURE__*/React.createElement("div", {
@@ -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/index.js CHANGED
@@ -595,11 +595,22 @@ var ProTable = function ProTable(props) {
595
595
  var defaultContext = {
596
596
  action: actionRef.current,
597
597
  rowSelection: rowSelection
598
- };
598
+ }; // 未选择的时候所有 button 默认 disabled
599
+
600
+ var targetActions = footerAction.actions.map(function (action) {
601
+ return _objectSpread(_objectSpread({}, action), {}, {
602
+ disabled: action.disabled || selectedCount === 0
603
+ });
604
+ });
605
+
606
+ var targetFooterActions = _objectSpread(_objectSpread({}, footerAction), {}, {
607
+ actions: targetActions
608
+ });
609
+
599
610
  return /*#__PURE__*/React.createElement("div", {
600
611
  className: cls('footer-action')
601
- }, /*#__PURE__*/React.createElement(ActionGroup, _objectSpread(_objectSpread({}, footerAction), {}, {
602
- context: _objectSpread(_objectSpread({}, defaultContext), footerAction.context)
612
+ }, /*#__PURE__*/React.createElement(ActionGroup, _objectSpread(_objectSpread({}, targetFooterActions), {}, {
613
+ context: _objectSpread(_objectSpread({}, defaultContext), targetFooterActions === null || targetFooterActions === void 0 ? void 0 : targetFooterActions.context)
603
614
  })));
604
615
  } else return footerAction;
605
616
  };
@@ -614,6 +625,7 @@ var ProTable = function ProTable(props) {
614
625
 
615
626
  function onChangePaginationSize(currentPageSize) {
616
627
  setPageSize(currentPageSize);
628
+ setCurrentPage(1);
617
629
 
618
630
  _request(_defineProperty({}, targetPageSizeKey, currentPageSize));
619
631
  }
@@ -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] | ((...props: any) => void);
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 */
@@ -57,7 +57,8 @@ export var renderCell = function renderCell(value, item, index, record, actionRe
57
57
  valueType = _item$valueType === void 0 ? 'text' : _item$valueType,
58
58
  render = item.render,
59
59
  actionSchema = item.actionSchema,
60
- dataIndex = item.dataIndex; // 如果没传 dataIndex,返回 null
60
+ dataIndex = item.dataIndex,
61
+ format = item.format; // 如果没传 dataIndex,返回 null
61
62
 
62
63
  if (!dataIndex) {
63
64
  value = null;
@@ -72,7 +73,8 @@ export var renderCell = function renderCell(value, item, index, record, actionRe
72
73
  });
73
74
  }
74
75
 
75
- var newRender = null; // 如果 render 直接传函数
76
+ var newRender = null;
77
+ var newDataSource = null; // 如果 render 直接传函数
76
78
 
77
79
  if (typeof render === 'function') {
78
80
  newRender = function newRender() {
@@ -96,6 +98,29 @@ export var renderCell = function renderCell(value, item, index, record, actionRe
96
98
  }, actionSchema), {}, {
97
99
  context: _objectSpread(_objectSpread({}, defaultContext), actionSchema.context)
98
100
  }));
101
+ } // dataSource可传函数
102
+
103
+
104
+ if (typeof item.dataSource === 'function') {
105
+ var _item$dataSource;
106
+
107
+ newDataSource = (_item$dataSource = item.dataSource) === null || _item$dataSource === void 0 ? void 0 : _item$dataSource.call(item, value, index, record);
108
+ } else {
109
+ var _item$dataSource2;
110
+
111
+ newDataSource = ((_item$dataSource2 = item.dataSource) !== null && _item$dataSource2 !== void 0 ? _item$dataSource2 : []).map(function (item) {
112
+ return Object.fromEntries(Object.entries(item).map(function (_ref) {
113
+ var _ref2 = _slicedToArray(_ref, 2),
114
+ k = _ref2[0],
115
+ v = _ref2[1];
116
+
117
+ return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
118
+ record: record,
119
+ value: value,
120
+ index: index
121
+ }))];
122
+ }));
123
+ });
99
124
  } // 渲染 ProField
100
125
 
101
126
 
@@ -103,7 +128,8 @@ export var renderCell = function renderCell(value, item, index, record, actionRe
103
128
  type: valueType || 'text',
104
129
  value: value,
105
130
  render: newRender,
106
- dataSource: item.dataSource
131
+ dataSource: newDataSource,
132
+ format: format
107
133
  });
108
134
  };
109
135
  /**
@@ -121,10 +147,10 @@ var processRenderFunction = function processRenderFunction() {
121
147
  var index = arguments.length > 2 ? arguments[2] : undefined;
122
148
  var record = arguments.length > 3 ? arguments[3] : undefined;
123
149
  var external = ['linkOnClick', 'link', 'value'];
124
- return Object.fromEntries(Object.entries(render).map(function (_ref) {
125
- var _ref2 = _slicedToArray(_ref, 2),
126
- k = _ref2[0],
127
- v = _ref2[1];
150
+ return Object.fromEntries(Object.entries(render).map(function (_ref3) {
151
+ var _ref4 = _slicedToArray(_ref3, 2),
152
+ k = _ref4[0],
153
+ v = _ref4[1];
128
154
 
129
155
  if (typeof v === 'function') {
130
156
  var _v;
@@ -159,10 +185,11 @@ var processBuriedPoint = function processBuriedPoint() {
159
185
  var value = arguments.length > 2 ? arguments[2] : undefined;
160
186
  var index = arguments.length > 3 ? arguments[3] : undefined;
161
187
  return Object.fromEntries([// 默认 ellipsis、descriptionEllipsis 为 true
162
- ['ellipsis', true], ['descriptionEllipsis', true]].concat(_toConsumableArray(Object.entries(render).map(function (_ref3) {
163
- var _ref4 = _slicedToArray(_ref3, 2),
164
- k = _ref4[0],
165
- v = _ref4[1];
188
+ // emptyText 默认为 '-'
189
+ ['ellipsis', true], ['descriptionEllipsis', true], ['emptyText', '-']].concat(_toConsumableArray(Object.entries(render).map(function (_ref5) {
190
+ var _ref6 = _slicedToArray(_ref5, 2),
191
+ k = _ref6[0],
192
+ v = _ref6[1];
166
193
 
167
194
  return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
168
195
  record: record,
@@ -10,6 +10,8 @@ exports.useDialogFormAction = useDialogFormAction;
10
10
 
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
 
13
+ var _reactRouterDom = require("react-router-dom");
14
+
13
15
  var _components = require("@alicloudfe/components");
14
16
 
15
17
  var _form = _interopRequireWildcard(require("../form"));
@@ -100,12 +102,13 @@ var DialogForm = function DialogForm(props) {
100
102
  loading = _useState2[0],
101
103
  setLoading = _useState2[1];
102
104
 
105
+ var history = (0, _reactRouterDom.useHistory)();
103
106
  (0, _react.useEffect)(function () {
104
107
  formRef.current = form;
105
108
 
106
109
  if (initialRequest) {
107
110
  setLoading(true);
108
- (0, _request.doRequest)(initialRequest, context).then(function (res) {
111
+ (0, _request.doRequest)(initialRequest, context, history).then(function (res) {
109
112
  form.setValues(res);
110
113
  setLoading(false);
111
114
  }).catch(function () {
@@ -1,14 +1,12 @@
1
1
  import React from 'react';
2
2
  import { QuickShowConfig } from '@alicloudfe/components/types/dialog';
3
3
  import { quickShowDrawerProps } from '@alicloudfe/components/types/drawer';
4
- import { LinkBase } from './link';
5
4
  import { RequestAction } from './request';
6
5
  export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShowConfig, 'onError' | 'type'>, Omit<quickShowDrawerProps, 'trigger' | 'animation' | 'height' | 'locale' | 'onOk' | 'onCancel' | 'onError'> {
7
6
  url?: string;
8
7
  dialogType?: 'dialog' | 'drawer';
9
8
  dialogQuickShowType?: 'alert' | 'confirm';
10
9
  messageType?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
11
- link?: LinkBase;
12
10
  }
13
11
  export declare function useDialogAction(action: DialogAction, context?: any): {
14
12
  [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;