@openli1115/lowcode-edit-pro-table 1.0.60 → 1.0.61

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,11 +1,37 @@
1
1
  import _CascaderSelect from "@alifd/next/es/cascader-select";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
4
- var _excluded = ["screen_structure", "screen_structure_field", "screen_inner_id", "range_inner_table", "dataSource", "disableEdit", "readOnly", "disabled", "value", "onChange", "defaultValue"];
3
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
6
  import { resolveProScreenBinding } from "../utils";
6
7
  import { useProBoundValue } from "../../context/useProBoundValue";
7
8
  import { FORM_EMPTY_ARRAY } from "../../context/useComponentContext";
8
- var createElement = window.React.createElement;
9
+ var _window$React = window.React,
10
+ createElement = _window$React.createElement,
11
+ useCallback = _window$React.useCallback;
12
+
13
+ /**
14
+ * 按路径在树形 dataSource 上逐级匹配,取出每一层的 label(2 级、3 级…任意多级,长度由 pathValues 决定)。
15
+ */
16
+ function resolvePathLabels(dataSource, pathValues) {
17
+ var labels = [];
18
+ if (!Array.isArray(dataSource) || pathValues.length === 0) return labels;
19
+ var level = dataSource;
20
+ var _loop = function _loop() {
21
+ var pv = _step.value;
22
+ var node = level.find(function (n) {
23
+ return String(n === null || n === void 0 ? void 0 : n.value) === String(pv);
24
+ });
25
+ if (!node) return 1; // break
26
+ labels.push(node.label != null ? String(node.label) : String(pv));
27
+ var next = node.children;
28
+ level = Array.isArray(next) ? next : [];
29
+ };
30
+ for (var _iterator = _createForOfIteratorHelperLoose(pathValues), _step; !(_step = _iterator()).done;) {
31
+ if (_loop()) break;
32
+ }
33
+ return labels;
34
+ }
9
35
  function normalizeCascaderPath(v) {
10
36
  if (Array.isArray(v)) {
11
37
  return v.filter(function (x) {
@@ -38,7 +64,14 @@ function normalizeCascaderPath(v) {
38
64
  */
39
65
  function cascaderChangeToPath(newValue, extra) {
40
66
  if (newValue == null) return [];
41
- if (Array.isArray(newValue)) return newValue.slice();
67
+ /** 多选或已是完整路径数组时直接规范化(多级路径长度不限) */
68
+ if (Array.isArray(newValue)) {
69
+ return newValue.map(function (x) {
70
+ return x == null ? '' : String(x);
71
+ }).filter(function (x) {
72
+ return x !== '';
73
+ });
74
+ }
42
75
  var nodes = extra === null || extra === void 0 ? void 0 : extra.selectedPath;
43
76
  if (Array.isArray(nodes) && nodes.length > 0) {
44
77
  return nodes.map(function (n) {
@@ -63,8 +96,7 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
63
96
  disabledProp = props.disabled,
64
97
  _schemaValue = props.value,
65
98
  schemaOnChange = props.onChange,
66
- defaultValue = props.defaultValue,
67
- restProps = _objectWithoutPropertiesLoose(props, _excluded);
99
+ defaultValue = props.defaultValue;
68
100
  var _resolveProScreenBind = resolveProScreenBinding({
69
101
  screen_structure: screen_structure,
70
102
  screen_structure_field: screen_structure_field,
@@ -83,6 +115,22 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
83
115
  schemaOnChange === null || schemaOnChange === void 0 ? void 0 : schemaOnChange(next, structureName, structureField);
84
116
  };
85
117
  var displayValue = normalizeCascaderPath(value);
118
+
119
+ /**
120
+ * Fusion 单选 getSingleData 对数组 value 只会用 value[0] 查节点,输入框文案不完整。
121
+ * 表单存全路径 [省,市,区,...] 任意多级时,用 dataSource 拼「一级 / 二级 / …」。
122
+ */
123
+ var schemaDisplayRender = props.displayRender;
124
+ var pathDisplayRender = useCallback(function (labels, data) {
125
+ var fullLabels = resolvePathLabels(dataSource, normalizeCascaderPath(value));
126
+ if (fullLabels.length > 0) {
127
+ return fullLabels.join(' / ');
128
+ }
129
+ if (typeof schemaDisplayRender === 'function') {
130
+ return schemaDisplayRender(labels, data);
131
+ }
132
+ return (labels && labels.length ? labels.join(' / ') : '') || ((data === null || data === void 0 ? void 0 : data.label) != null ? String(data.label) : '');
133
+ }, [dataSource, value, schemaDisplayRender]);
86
134
  return /*#__PURE__*/React.createElement("span", {
87
135
  className: "field-wrapper " + (disableEdit ? 'disable-edit' : 'enable-edit')
88
136
  }, /*#__PURE__*/React.createElement(_CascaderSelect, _extends({}, props, {
@@ -90,7 +138,8 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
90
138
  disabled: disabledProp,
91
139
  dataSource: dataSource,
92
140
  value: displayValue,
93
- onChange: handleChange
141
+ onChange: handleChange,
142
+ displayRender: pathDisplayRender
94
143
  })));
95
144
  };
96
145
  export default ProCascaderSelect;
@@ -5,12 +5,38 @@ exports.__esModule = true;
5
5
  exports["default"] = void 0;
6
6
  var _cascaderSelect = _interopRequireDefault(require("@alifd/next/lib/cascader-select"));
7
7
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
8
  var _utils = require("../utils");
10
9
  var _useProBoundValue2 = require("../../context/useProBoundValue");
11
10
  var _useComponentContext = require("../../context/useComponentContext");
12
- var _excluded = ["screen_structure", "screen_structure_field", "screen_inner_id", "range_inner_table", "dataSource", "disableEdit", "readOnly", "disabled", "value", "onChange", "defaultValue"];
13
- var createElement = window.React.createElement;
11
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ var _window$React = window.React,
15
+ createElement = _window$React.createElement,
16
+ useCallback = _window$React.useCallback;
17
+
18
+ /**
19
+ * 按路径在树形 dataSource 上逐级匹配,取出每一层的 label(2 级、3 级…任意多级,长度由 pathValues 决定)。
20
+ */
21
+ function resolvePathLabels(dataSource, pathValues) {
22
+ var labels = [];
23
+ if (!Array.isArray(dataSource) || pathValues.length === 0) return labels;
24
+ var level = dataSource;
25
+ var _loop = function _loop() {
26
+ var pv = _step.value;
27
+ var node = level.find(function (n) {
28
+ return String(n === null || n === void 0 ? void 0 : n.value) === String(pv);
29
+ });
30
+ if (!node) return 1; // break
31
+ labels.push(node.label != null ? String(node.label) : String(pv));
32
+ var next = node.children;
33
+ level = Array.isArray(next) ? next : [];
34
+ };
35
+ for (var _iterator = _createForOfIteratorHelperLoose(pathValues), _step; !(_step = _iterator()).done;) {
36
+ if (_loop()) break;
37
+ }
38
+ return labels;
39
+ }
14
40
  function normalizeCascaderPath(v) {
15
41
  if (Array.isArray(v)) {
16
42
  return v.filter(function (x) {
@@ -43,7 +69,14 @@ function normalizeCascaderPath(v) {
43
69
  */
44
70
  function cascaderChangeToPath(newValue, extra) {
45
71
  if (newValue == null) return [];
46
- if (Array.isArray(newValue)) return newValue.slice();
72
+ /** 多选或已是完整路径数组时直接规范化(多级路径长度不限) */
73
+ if (Array.isArray(newValue)) {
74
+ return newValue.map(function (x) {
75
+ return x == null ? '' : String(x);
76
+ }).filter(function (x) {
77
+ return x !== '';
78
+ });
79
+ }
47
80
  var nodes = extra === null || extra === void 0 ? void 0 : extra.selectedPath;
48
81
  if (Array.isArray(nodes) && nodes.length > 0) {
49
82
  return nodes.map(function (n) {
@@ -68,8 +101,7 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
68
101
  disabledProp = props.disabled,
69
102
  _schemaValue = props.value,
70
103
  schemaOnChange = props.onChange,
71
- defaultValue = props.defaultValue,
72
- restProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
104
+ defaultValue = props.defaultValue;
73
105
  var _resolveProScreenBind = (0, _utils.resolveProScreenBinding)({
74
106
  screen_structure: screen_structure,
75
107
  screen_structure_field: screen_structure_field,
@@ -88,6 +120,22 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
88
120
  schemaOnChange === null || schemaOnChange === void 0 ? void 0 : schemaOnChange(next, structureName, structureField);
89
121
  };
90
122
  var displayValue = normalizeCascaderPath(value);
123
+
124
+ /**
125
+ * Fusion 单选 getSingleData 对数组 value 只会用 value[0] 查节点,输入框文案不完整。
126
+ * 表单存全路径 [省,市,区,...] 任意多级时,用 dataSource 拼「一级 / 二级 / …」。
127
+ */
128
+ var schemaDisplayRender = props.displayRender;
129
+ var pathDisplayRender = useCallback(function (labels, data) {
130
+ var fullLabels = resolvePathLabels(dataSource, normalizeCascaderPath(value));
131
+ if (fullLabels.length > 0) {
132
+ return fullLabels.join(' / ');
133
+ }
134
+ if (typeof schemaDisplayRender === 'function') {
135
+ return schemaDisplayRender(labels, data);
136
+ }
137
+ return (labels && labels.length ? labels.join(' / ') : '') || ((data === null || data === void 0 ? void 0 : data.label) != null ? String(data.label) : '');
138
+ }, [dataSource, value, schemaDisplayRender]);
91
139
  return /*#__PURE__*/React.createElement("span", {
92
140
  className: "field-wrapper " + (disableEdit ? 'disable-edit' : 'enable-edit')
93
141
  }, /*#__PURE__*/React.createElement(_cascaderSelect["default"], (0, _extends2["default"])({}, props, {
@@ -95,7 +143,8 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
95
143
  disabled: disabledProp,
96
144
  dataSource: dataSource,
97
145
  value: displayValue,
98
- onChange: handleChange
146
+ onChange: handleChange,
147
+ displayRender: pathDisplayRender
99
148
  })));
100
149
  };
101
150
  var _default = exports["default"] = ProCascaderSelect;
@@ -101,7 +101,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
101
101
  packageName = '@openli1115/lowcode-edit-pro-table';
102
102
  }
103
103
  if (version === void 0) {
104
- version = '1.0.60';
104
+ version = '1.0.61';
105
105
  }
106
106
  if (basicLibraryVersion === void 0) {
107
107
  basicLibraryVersion = {
@@ -106,7 +106,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
106
106
  packageName = '@openli1115/lowcode-edit-pro-table';
107
107
  }
108
108
  if (version === void 0) {
109
- version = '1.0.60';
109
+ version = '1.0.61';
110
110
  }
111
111
  if (basicLibraryVersion === void 0) {
112
112
  basicLibraryVersion = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openli1115/lowcode-edit-pro-table",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "@openli1115/lowcode-edit-pro-table",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -101,10 +101,10 @@
101
101
  },
102
102
  "componentConfig": {
103
103
  "isComponentLibrary": true,
104
- "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.60/build/lowcode/assets-prod.json"
104
+ "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.61/build/lowcode/assets-prod.json"
105
105
  },
106
106
  "lcMeta": {
107
107
  "type": "component"
108
108
  },
109
- "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.60/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.61/build/index.html"
110
110
  }