@ztocwst/rc-pro-materials 0.2.3 → 0.2.5

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.
@@ -1,18 +1,39 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["children"],
4
- _excluded2 = ["authBtns", "singleWarehouseConfig", "singleFactoryConfig"];
4
+ _excluded2 = ["authBtns", "singleWarehouseConfig", "singleFactoryConfig", "asyncSelect", "form", "ossConfig", "print", "tableOptions", "tplOptions"];
5
5
  import * as React from 'react';
6
6
  import { RcConfigProvider } from '@ztocwst/rc-pro';
7
- import { processRequestConfig } from "../../utils/props/common";
7
+ import { processEmptyObject, processRequestConfig } from "../../utils/props/common";
8
8
  var ZConfigProvider = function ZConfigProvider(_ref) {
9
+ var _singleWarehouseConfi, _singleFactoryConfig$, _asyncSelect$fieldNam, _asyncSelect$pager, _form$footer, _print$printer, _tableOptions$paginat, _tableOptions$sortNam;
9
10
  var children = _ref.children,
10
11
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
11
12
  var _rest$authBtns = rest.authBtns,
12
13
  authBtns = _rest$authBtns === void 0 ? [] : _rest$authBtns,
13
14
  singleWarehouseConfig = rest.singleWarehouseConfig,
14
15
  singleFactoryConfig = rest.singleFactoryConfig,
16
+ asyncSelect = rest.asyncSelect,
17
+ form = rest.form,
18
+ ossConfig = rest.ossConfig,
19
+ print = rest.print,
20
+ tableOptions = rest.tableOptions,
21
+ tplOptions = rest.tplOptions,
15
22
  restProps = _objectWithoutPropertiesLoose(rest, _excluded2);
23
+
24
+ /**
25
+ *
26
+ * 过滤空对象,如果对象中的值都是undefined,整个对象赋值 undefined
27
+ * asyncSelect 中的 fieldNames、pager 对象
28
+ * form 中的 footer对象
29
+ * ossConfig 对象
30
+ * print 中的 printer
31
+ * tableOptions 中的 pagination、sortNames
32
+ * tplOptions 对象
33
+ * singleWarehouseConfig 中 defaultConfig
34
+ * singleFactoryConfig 中 defaultConfig
35
+ */
36
+
16
37
  var props = _extends({
17
38
  authBtns: authBtns === null || authBtns === void 0 ? void 0 : authBtns.map(function (e) {
18
39
  return _extends({}, e, {
@@ -21,10 +42,30 @@ var ZConfigProvider = function ZConfigProvider(_ref) {
21
42
  }),
22
43
  singleWarehouseConfig: _extends({}, singleWarehouseConfig, singleWarehouseConfig !== null && singleWarehouseConfig !== void 0 && singleWarehouseConfig.requestConfig ? {
23
44
  requestConfig: processRequestConfig(singleWarehouseConfig === null || singleWarehouseConfig === void 0 ? void 0 : singleWarehouseConfig.requestConfig)
24
- } : {}),
45
+ } : {}, {
46
+ defaultConfig: processEmptyObject((_singleWarehouseConfi = singleWarehouseConfig === null || singleWarehouseConfig === void 0 ? void 0 : singleWarehouseConfig.defaultConfig) !== null && _singleWarehouseConfi !== void 0 ? _singleWarehouseConfi : {})
47
+ }),
25
48
  singleFactoryConfig: _extends({}, singleFactoryConfig, singleFactoryConfig !== null && singleFactoryConfig !== void 0 && singleFactoryConfig.requestConfig ? {
26
49
  requestConfig: processRequestConfig(singleFactoryConfig === null || singleFactoryConfig === void 0 ? void 0 : singleFactoryConfig.requestConfig)
27
- } : {})
50
+ } : {}, {
51
+ defaultConfig: processEmptyObject((_singleFactoryConfig$ = singleFactoryConfig === null || singleFactoryConfig === void 0 ? void 0 : singleFactoryConfig.defaultConfig) !== null && _singleFactoryConfig$ !== void 0 ? _singleFactoryConfig$ : {})
52
+ }),
53
+ asyncSelect: _extends({}, asyncSelect, {
54
+ fieldNames: processEmptyObject((_asyncSelect$fieldNam = asyncSelect === null || asyncSelect === void 0 ? void 0 : asyncSelect.fieldNames) !== null && _asyncSelect$fieldNam !== void 0 ? _asyncSelect$fieldNam : {}),
55
+ pager: processEmptyObject((_asyncSelect$pager = asyncSelect === null || asyncSelect === void 0 ? void 0 : asyncSelect.pager) !== null && _asyncSelect$pager !== void 0 ? _asyncSelect$pager : {})
56
+ }),
57
+ form: _extends({}, form, {
58
+ footer: processEmptyObject((_form$footer = form === null || form === void 0 ? void 0 : form.footer) !== null && _form$footer !== void 0 ? _form$footer : {})
59
+ }),
60
+ ossConfig: processEmptyObject(ossConfig !== null && ossConfig !== void 0 ? ossConfig : {}),
61
+ print: _extends({}, print, {
62
+ printer: processEmptyObject((_print$printer = print === null || print === void 0 ? void 0 : print.printer) !== null && _print$printer !== void 0 ? _print$printer : {})
63
+ }),
64
+ tableOptions: _extends({}, tableOptions, {
65
+ pagination: processEmptyObject((_tableOptions$paginat = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.pagination) !== null && _tableOptions$paginat !== void 0 ? _tableOptions$paginat : {}),
66
+ sortNames: processEmptyObject((_tableOptions$sortNam = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.sortNames) !== null && _tableOptions$sortNam !== void 0 ? _tableOptions$sortNam : {})
67
+ }),
68
+ tplOptions: processEmptyObject(tplOptions !== null && tplOptions !== void 0 ? tplOptions : {})
28
69
  }, restProps);
29
70
  console.log(props, 'configProvider');
30
71
  return /*#__PURE__*/React.createElement(RcConfigProvider, props, children);
@@ -1 +1,7 @@
1
1
  export declare const processRequestConfig: (props: any) => any;
2
+ /**
3
+ * 根据对象是否为空判断返回值
4
+ * @param obj
5
+ * @returns undefined | obj
6
+ */
7
+ export declare const processEmptyObject: (obj?: any) => any;
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["singleWarehouse"];
4
+ import _ from 'lodash';
4
5
  export var processRequestConfig = function processRequestConfig(props) {
5
6
  var _props$headers;
6
7
  var singleWarehouse = props.singleWarehouse,
@@ -10,4 +11,20 @@ export var processRequestConfig = function processRequestConfig(props) {
10
11
  singleWarehouse: true
11
12
  } : {})
12
13
  } : {});
14
+ };
15
+
16
+ /**
17
+ * 根据对象是否为空判断返回值
18
+ * @param obj
19
+ * @returns undefined | obj
20
+ */
21
+ export var processEmptyObject = function processEmptyObject(obj) {
22
+ if (obj === void 0) {
23
+ obj = {};
24
+ }
25
+ // 判断对象是否为空
26
+ var empty = _ === null || _ === void 0 ? void 0 : _.isEmpty(_ === null || _ === void 0 ? void 0 : _.pickBy(obj, function (value) {
27
+ return value !== null && value !== undefined;
28
+ }));
29
+ return empty ? undefined : obj;
13
30
  };
@@ -169,9 +169,9 @@ export var processFormProps = function processFormProps(props) {
169
169
  width: labelColWidth
170
170
  })
171
171
  })
172
- }, settingOpt ? {
172
+ }, typeof settingOpt === 'string' && settingOpt !== null && settingOpt !== void 0 && settingOpt.trim() ? {
173
173
  settingOpt: {
174
- key: "form_setting_" + Math.random()
174
+ key: "" + (settingOpt === null || settingOpt === void 0 ? void 0 : settingOpt.trim())
175
175
  }
176
176
  } : {}, {
177
177
  defaultColsNumber: defaultColsNumber,
@@ -9,17 +9,38 @@ var React = _interopRequireWildcard(require("react"));
9
9
  var _rcPro = require("@ztocwst/rc-pro");
10
10
  var _common = require("../../utils/props/common");
11
11
  var _excluded = ["children"],
12
- _excluded2 = ["authBtns", "singleWarehouseConfig", "singleFactoryConfig"];
12
+ _excluded2 = ["authBtns", "singleWarehouseConfig", "singleFactoryConfig", "asyncSelect", "form", "ossConfig", "print", "tableOptions", "tplOptions"];
13
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
  var ZConfigProvider = function ZConfigProvider(_ref) {
16
+ var _singleWarehouseConfi, _singleFactoryConfig$, _asyncSelect$fieldNam, _asyncSelect$pager, _form$footer, _print$printer, _tableOptions$paginat, _tableOptions$sortNam;
16
17
  var children = _ref.children,
17
18
  rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
18
19
  var _rest$authBtns = rest.authBtns,
19
20
  authBtns = _rest$authBtns === void 0 ? [] : _rest$authBtns,
20
21
  singleWarehouseConfig = rest.singleWarehouseConfig,
21
22
  singleFactoryConfig = rest.singleFactoryConfig,
23
+ asyncSelect = rest.asyncSelect,
24
+ form = rest.form,
25
+ ossConfig = rest.ossConfig,
26
+ print = rest.print,
27
+ tableOptions = rest.tableOptions,
28
+ tplOptions = rest.tplOptions,
22
29
  restProps = (0, _objectWithoutPropertiesLoose2["default"])(rest, _excluded2);
30
+
31
+ /**
32
+ *
33
+ * 过滤空对象,如果对象中的值都是undefined,整个对象赋值 undefined
34
+ * asyncSelect 中的 fieldNames、pager 对象
35
+ * form 中的 footer对象
36
+ * ossConfig 对象
37
+ * print 中的 printer
38
+ * tableOptions 中的 pagination、sortNames
39
+ * tplOptions 对象
40
+ * singleWarehouseConfig 中 defaultConfig
41
+ * singleFactoryConfig 中 defaultConfig
42
+ */
43
+
23
44
  var props = (0, _extends2["default"])({
24
45
  authBtns: authBtns === null || authBtns === void 0 ? void 0 : authBtns.map(function (e) {
25
46
  return (0, _extends2["default"])({}, e, {
@@ -28,10 +49,30 @@ var ZConfigProvider = function ZConfigProvider(_ref) {
28
49
  }),
29
50
  singleWarehouseConfig: (0, _extends2["default"])({}, singleWarehouseConfig, singleWarehouseConfig !== null && singleWarehouseConfig !== void 0 && singleWarehouseConfig.requestConfig ? {
30
51
  requestConfig: (0, _common.processRequestConfig)(singleWarehouseConfig === null || singleWarehouseConfig === void 0 ? void 0 : singleWarehouseConfig.requestConfig)
31
- } : {}),
52
+ } : {}, {
53
+ defaultConfig: (0, _common.processEmptyObject)((_singleWarehouseConfi = singleWarehouseConfig === null || singleWarehouseConfig === void 0 ? void 0 : singleWarehouseConfig.defaultConfig) !== null && _singleWarehouseConfi !== void 0 ? _singleWarehouseConfi : {})
54
+ }),
32
55
  singleFactoryConfig: (0, _extends2["default"])({}, singleFactoryConfig, singleFactoryConfig !== null && singleFactoryConfig !== void 0 && singleFactoryConfig.requestConfig ? {
33
56
  requestConfig: (0, _common.processRequestConfig)(singleFactoryConfig === null || singleFactoryConfig === void 0 ? void 0 : singleFactoryConfig.requestConfig)
34
- } : {})
57
+ } : {}, {
58
+ defaultConfig: (0, _common.processEmptyObject)((_singleFactoryConfig$ = singleFactoryConfig === null || singleFactoryConfig === void 0 ? void 0 : singleFactoryConfig.defaultConfig) !== null && _singleFactoryConfig$ !== void 0 ? _singleFactoryConfig$ : {})
59
+ }),
60
+ asyncSelect: (0, _extends2["default"])({}, asyncSelect, {
61
+ fieldNames: (0, _common.processEmptyObject)((_asyncSelect$fieldNam = asyncSelect === null || asyncSelect === void 0 ? void 0 : asyncSelect.fieldNames) !== null && _asyncSelect$fieldNam !== void 0 ? _asyncSelect$fieldNam : {}),
62
+ pager: (0, _common.processEmptyObject)((_asyncSelect$pager = asyncSelect === null || asyncSelect === void 0 ? void 0 : asyncSelect.pager) !== null && _asyncSelect$pager !== void 0 ? _asyncSelect$pager : {})
63
+ }),
64
+ form: (0, _extends2["default"])({}, form, {
65
+ footer: (0, _common.processEmptyObject)((_form$footer = form === null || form === void 0 ? void 0 : form.footer) !== null && _form$footer !== void 0 ? _form$footer : {})
66
+ }),
67
+ ossConfig: (0, _common.processEmptyObject)(ossConfig !== null && ossConfig !== void 0 ? ossConfig : {}),
68
+ print: (0, _extends2["default"])({}, print, {
69
+ printer: (0, _common.processEmptyObject)((_print$printer = print === null || print === void 0 ? void 0 : print.printer) !== null && _print$printer !== void 0 ? _print$printer : {})
70
+ }),
71
+ tableOptions: (0, _extends2["default"])({}, tableOptions, {
72
+ pagination: (0, _common.processEmptyObject)((_tableOptions$paginat = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.pagination) !== null && _tableOptions$paginat !== void 0 ? _tableOptions$paginat : {}),
73
+ sortNames: (0, _common.processEmptyObject)((_tableOptions$sortNam = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.sortNames) !== null && _tableOptions$sortNam !== void 0 ? _tableOptions$sortNam : {})
74
+ }),
75
+ tplOptions: (0, _common.processEmptyObject)(tplOptions !== null && tplOptions !== void 0 ? tplOptions : {})
35
76
  }, restProps);
36
77
  console.log(props, 'configProvider');
37
78
  return /*#__PURE__*/React.createElement(_rcPro.RcConfigProvider, props, children);
@@ -1 +1,7 @@
1
1
  export declare const processRequestConfig: (props: any) => any;
2
+ /**
3
+ * 根据对象是否为空判断返回值
4
+ * @param obj
5
+ * @returns undefined | obj
6
+ */
7
+ export declare const processEmptyObject: (obj?: any) => any;
@@ -2,9 +2,10 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
- exports.processRequestConfig = void 0;
5
+ exports.processRequestConfig = exports.processEmptyObject = void 0;
6
6
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
7
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
8
+ var _lodash = _interopRequireDefault(require("lodash"));
8
9
  var _excluded = ["singleWarehouse"];
9
10
  var processRequestConfig = function processRequestConfig(props) {
10
11
  var _props$headers;
@@ -16,4 +17,21 @@ var processRequestConfig = function processRequestConfig(props) {
16
17
  } : {})
17
18
  } : {});
18
19
  };
19
- exports.processRequestConfig = processRequestConfig;
20
+
21
+ /**
22
+ * 根据对象是否为空判断返回值
23
+ * @param obj
24
+ * @returns undefined | obj
25
+ */
26
+ exports.processRequestConfig = processRequestConfig;
27
+ var processEmptyObject = function processEmptyObject(obj) {
28
+ if (obj === void 0) {
29
+ obj = {};
30
+ }
31
+ // 判断对象是否为空
32
+ var empty = _lodash["default"] === null || _lodash["default"] === void 0 ? void 0 : _lodash["default"].isEmpty(_lodash["default"] === null || _lodash["default"] === void 0 ? void 0 : _lodash["default"].pickBy(obj, function (value) {
33
+ return value !== null && value !== undefined;
34
+ }));
35
+ return empty ? undefined : obj;
36
+ };
37
+ exports.processEmptyObject = processEmptyObject;
@@ -173,9 +173,9 @@ var processFormProps = function processFormProps(props) {
173
173
  width: labelColWidth
174
174
  })
175
175
  })
176
- }, settingOpt ? {
176
+ }, typeof settingOpt === 'string' && settingOpt !== null && settingOpt !== void 0 && settingOpt.trim() ? {
177
177
  settingOpt: {
178
- key: "form_setting_" + Math.random()
178
+ key: "" + (settingOpt === null || settingOpt === void 0 ? void 0 : settingOpt.trim())
179
179
  }
180
180
  } : {}, {
181
181
  defaultColsNumber: defaultColsNumber,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztocwst/rc-pro-materials",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "@ztocwst/rc-pro-materials",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -86,9 +86,9 @@
86
86
  },
87
87
  "componentConfig": {
88
88
  "isComponentLibrary": true,
89
- "materialSchema": "https://npm.onmicrosoft.cn/@ztocwst/rc-pro-materials@0.2.3/build/lowcode/assets-prod.json"
89
+ "materialSchema": "https://npm.onmicrosoft.cn/@ztocwst/rc-pro-materials@0.2.5/build/lowcode/assets-prod.json"
90
90
  },
91
- "homepage": "https://unpkg.com/@ztocwst/rc-pro-materials@0.2.3/build/index.html",
91
+ "homepage": "https://unpkg.com/@ztocwst/rc-pro-materials@0.2.5/build/index.html",
92
92
  "publishConfig": {
93
93
  "registry": "https://registry.npmjs.org/",
94
94
  "access": "public"