@openli1115/lowcode-edit-pro-table 1.0.96 → 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) {
@@ -345,6 +346,34 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
345
346
  var raw = Array.isArray(dataSource) ? dataSource : Array.isArray(options) ? options : [];
346
347
  return mapToFusionCascaderTree(raw);
347
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]);
348
377
  var handleChange = function handleChange(newValue, _data, extra) {
349
378
  var next = cascaderChangeToPath(newValue, extra);
350
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) {
@@ -350,6 +351,34 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
350
351
  var raw = Array.isArray(dataSource) ? dataSource : Array.isArray(options) ? options : [];
351
352
  return mapToFusionCascaderTree(raw);
352
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]);
353
382
  var handleChange = function handleChange(newValue, _data, extra) {
354
383
  var next = cascaderChangeToPath(newValue, extra);
355
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.96';
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.96';
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.96",
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.96/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.96/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.97/build/index.html"
110
110
  }