@openli1115/lowcode-edit-pro-table 1.0.95 → 1.0.97

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.
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
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
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
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; }
6
- import { get } from 'lodash';
6
+ import { get, isEqual } from 'lodash';
7
7
  import { resolveProScreenBinding } from "../utils";
8
8
  import { getFormContext } from "../../context/FormProvider";
9
9
  import { FORM_EMPTY_ARRAY } from "../../context/useComponentContext";
@@ -13,7 +13,8 @@ var _window$React = window.React,
13
13
  useEffect = _window$React.useEffect,
14
14
  useMemo = _window$React.useMemo,
15
15
  useContext = _window$React.useContext,
16
- useState = _window$React.useState;
16
+ useState = _window$React.useState,
17
+ useRef = _window$React.useRef;
17
18
 
18
19
  /** 与预览 previewFlowDebug 一致:window.__PREVIEW_FLOW_LOG__ === false 时静音 */
19
20
  function previewFlowCascader(tag, detail) {
@@ -121,7 +122,11 @@ function isValidPathInTree(dataSource, pathValues) {
121
122
  return true;
122
123
  }
123
124
 
124
- /** 回填仅有叶子 id(如 city=2977)时,递归反查完整路径 [provinceId, cityId] */
125
+ /**
126
+ * 回填仅有叶子 id(与范围内表接口 `data[0].low` / 扁平 `st_xxx.low` 一致)时,
127
+ * 在 dataSource 树上 DFS:沿 children 向下找到 value===叶子的节点,返回从根到叶的 id 数组,
128
+ * 例如 ['2025','2026'] —— 最后一项即 low,前面各项为各级父节点(由树结构决定,非接口另返)。
129
+ */
125
130
  function findPathByNodeValue(dataSource, targetValue, parentPath) {
126
131
  if (parentPath === void 0) {
127
132
  parentPath = [];
@@ -140,6 +145,8 @@ function findPathByNodeValue(dataSource, targetValue, parentPath) {
140
145
  }
141
146
  return [];
142
147
  }
148
+
149
+ /** 把表单/接口里的值规范成 Fusion 用的路径数组;单叶子字符串会经 findPathByNodeValue 拼成 ['父','…','叶'] */
143
150
  function normalizeCascaderPath(v, dataSource) {
144
151
  var tryExpandByLeaf = function tryExpandByLeaf(leaf, fallback) {
145
152
  if (fallback === void 0) {
@@ -339,6 +346,34 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
339
346
  var raw = Array.isArray(dataSource) ? dataSource : Array.isArray(options) ? options : [];
340
347
  return mapToFusionCascaderTree(raw);
341
348
  }, [dataSource, options]);
349
+
350
+ /**
351
+ * 屏幕结构(customType 3)等:接口常回标量如 current_status: "2976";级联需要完整路径 ['父','子']。
352
+ * 在 dataSource(children 树)就绪后,用 normalizeCascaderPath 反查并写回表单,避免初始化只存叶子、展示依赖异步树。
353
+ * structureName / structureField 来自 schema,不硬编码。
354
+ */
355
+ var pathPersistAttemptsRef = useRef(new Set());
356
+ useEffect(function () {
357
+ pathPersistAttemptsRef.current.clear();
358
+ }, [fieldPath, cascaderOptions]);
359
+ useEffect(function () {
360
+ if (!fieldPath) return;
361
+ if (cascaderOptions.length === 0) return;
362
+ var expanded = normalizeCascaderPath(value, cascaderOptions);
363
+ if (!Array.isArray(expanded) || expanded.length === 0) return;
364
+ if (isEqual(value, expanded)) return;
365
+ var attemptKey = JSON.stringify(value) + "\u2192" + JSON.stringify(expanded);
366
+ if (pathPersistAttemptsRef.current.has(attemptKey)) return;
367
+ pathPersistAttemptsRef.current.add(attemptKey);
368
+ commit(expanded);
369
+ previewFlowCascader('persistScalarOrPartialToPath', {
370
+ fieldPath: fieldPath,
371
+ structureName: structureName,
372
+ structureField: structureField,
373
+ from: typeof value === 'object' ? JSON.stringify(value).slice(0, 160) : String(value).slice(0, 80),
374
+ expanded: expanded
375
+ });
376
+ }, [fieldPath, value, cascaderOptions, commit, structureName, structureField]);
342
377
  var handleChange = function handleChange(newValue, _data, extra) {
343
378
  var next = cascaderChangeToPath(newValue, extra);
344
379
  previewFlowCascader('onChange', {
@@ -18,7 +18,8 @@ var _window$React = window.React,
18
18
  useEffect = _window$React.useEffect,
19
19
  useMemo = _window$React.useMemo,
20
20
  useContext = _window$React.useContext,
21
- useState = _window$React.useState;
21
+ useState = _window$React.useState,
22
+ useRef = _window$React.useRef;
22
23
 
23
24
  /** 与预览 previewFlowDebug 一致:window.__PREVIEW_FLOW_LOG__ === false 时静音 */
24
25
  function previewFlowCascader(tag, detail) {
@@ -126,7 +127,11 @@ function isValidPathInTree(dataSource, pathValues) {
126
127
  return true;
127
128
  }
128
129
 
129
- /** 回填仅有叶子 id(如 city=2977)时,递归反查完整路径 [provinceId, cityId] */
130
+ /**
131
+ * 回填仅有叶子 id(与范围内表接口 `data[0].low` / 扁平 `st_xxx.low` 一致)时,
132
+ * 在 dataSource 树上 DFS:沿 children 向下找到 value===叶子的节点,返回从根到叶的 id 数组,
133
+ * 例如 ['2025','2026'] —— 最后一项即 low,前面各项为各级父节点(由树结构决定,非接口另返)。
134
+ */
130
135
  function findPathByNodeValue(dataSource, targetValue, parentPath) {
131
136
  if (parentPath === void 0) {
132
137
  parentPath = [];
@@ -145,6 +150,8 @@ function findPathByNodeValue(dataSource, targetValue, parentPath) {
145
150
  }
146
151
  return [];
147
152
  }
153
+
154
+ /** 把表单/接口里的值规范成 Fusion 用的路径数组;单叶子字符串会经 findPathByNodeValue 拼成 ['父','…','叶'] */
148
155
  function normalizeCascaderPath(v, dataSource) {
149
156
  var tryExpandByLeaf = function tryExpandByLeaf(leaf, fallback) {
150
157
  if (fallback === void 0) {
@@ -344,6 +351,34 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
344
351
  var raw = Array.isArray(dataSource) ? dataSource : Array.isArray(options) ? options : [];
345
352
  return mapToFusionCascaderTree(raw);
346
353
  }, [dataSource, options]);
354
+
355
+ /**
356
+ * 屏幕结构(customType 3)等:接口常回标量如 current_status: "2976";级联需要完整路径 ['父','子']。
357
+ * 在 dataSource(children 树)就绪后,用 normalizeCascaderPath 反查并写回表单,避免初始化只存叶子、展示依赖异步树。
358
+ * structureName / structureField 来自 schema,不硬编码。
359
+ */
360
+ var pathPersistAttemptsRef = useRef(new Set());
361
+ useEffect(function () {
362
+ pathPersistAttemptsRef.current.clear();
363
+ }, [fieldPath, cascaderOptions]);
364
+ useEffect(function () {
365
+ if (!fieldPath) return;
366
+ if (cascaderOptions.length === 0) return;
367
+ var expanded = normalizeCascaderPath(value, cascaderOptions);
368
+ if (!Array.isArray(expanded) || expanded.length === 0) return;
369
+ if ((0, _lodash.isEqual)(value, expanded)) return;
370
+ var attemptKey = JSON.stringify(value) + "\u2192" + JSON.stringify(expanded);
371
+ if (pathPersistAttemptsRef.current.has(attemptKey)) return;
372
+ pathPersistAttemptsRef.current.add(attemptKey);
373
+ commit(expanded);
374
+ previewFlowCascader('persistScalarOrPartialToPath', {
375
+ fieldPath: fieldPath,
376
+ structureName: structureName,
377
+ structureField: structureField,
378
+ from: typeof value === 'object' ? JSON.stringify(value).slice(0, 160) : String(value).slice(0, 80),
379
+ expanded: expanded
380
+ });
381
+ }, [fieldPath, value, cascaderOptions, commit, structureName, structureField]);
347
382
  var handleChange = function handleChange(newValue, _data, extra) {
348
383
  var next = cascaderChangeToPath(newValue, extra);
349
384
  previewFlowCascader('onChange', {
@@ -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.95';
104
+ version = '1.0.97';
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.95';
109
+ version = '1.0.97';
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.95",
3
+ "version": "1.0.97",
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.95/build/lowcode/assets-prod.json"
104
+ "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.97/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.95/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.97/build/index.html"
110
110
  }