@openli1115/lowcode-edit-pro-table 1.0.92 → 1.0.94

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.
@@ -14,6 +14,14 @@ var _window$React = window.React,
14
14
  useMemo = _window$React.useMemo,
15
15
  useContext = _window$React.useContext,
16
16
  useState = _window$React.useState;
17
+
18
+ /** 与预览 previewFlowDebug 一致:window.__PREVIEW_FLOW_LOG__ === false 时静音 */
19
+ function previewFlowCascader(tag, detail) {
20
+ if (typeof window !== 'undefined' && window.__PREVIEW_FLOW_LOG__ === false) {
21
+ return;
22
+ }
23
+ console.log('[PreviewFlow][Cascader]', tag, detail);
24
+ }
17
25
  function toStr(v) {
18
26
  if (v == null) return '';
19
27
  return String(v);
@@ -198,6 +206,45 @@ function cascaderChangeToPath(newValue, extra) {
198
206
  return [String(newValue)];
199
207
  }
200
208
 
209
+ /**
210
+ * 范围内表回填形状:
211
+ * - customType 4:`structure.data` 为 `[{ low, high, sign, option, ... }]` → 取 `data[0].field`
212
+ * - 对象型:`structure.data` 为 `{ low: ... }` → 取 `data.field`
213
+ * - 扁平:`structure.field`(与 previewUtils expandInnerTableRangeEcho 一致)
214
+ */
215
+ function readRangeInnerEchoValue(values, structureName, structureField, flatPath) {
216
+ var dataBagPath = structureName ? structureName + ".data" : '';
217
+ var pathsTryFirst = [structureName && structureField ? structureName + ".data[0]." + structureField : '', structureName && structureField ? structureName + ".data." + structureField : '', flatPath].filter(Boolean);
218
+ for (var _iterator4 = _createForOfIteratorHelperLoose(pathsTryFirst), _step4; !(_step4 = _iterator4()).done;) {
219
+ var p = _step4.value;
220
+ var _v2 = get(values, p);
221
+ if (_v2 !== undefined && _v2 !== null) return _v2;
222
+ }
223
+ if (structureField && dataBagPath) {
224
+ var bag = get(values, dataBagPath);
225
+ if (Array.isArray(bag) && bag[0] && typeof bag[0] === 'object' && structureField in bag[0]) {
226
+ var v = bag[0][structureField];
227
+ if (v !== undefined && v !== null) return v;
228
+ }
229
+ if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
230
+ var _v = bag[structureField];
231
+ if (_v !== undefined && _v !== null) return _v;
232
+ }
233
+ }
234
+ return FORM_EMPTY_ARRAY;
235
+ }
236
+ function resolveRangeInnerWritePath(values, structureName, structureField, flatPath) {
237
+ if (!structureName || !structureField) return flatPath;
238
+ var dataBag = get(values, structureName + ".data");
239
+ if (Array.isArray(dataBag)) {
240
+ return structureName + ".data[0]." + structureField;
241
+ }
242
+ if (dataBag && typeof dataBag === 'object' && !Array.isArray(dataBag)) {
243
+ return structureName + ".data." + structureField;
244
+ }
245
+ return flatPath;
246
+ }
247
+
201
248
  /**
202
249
  * 与 ProInput 一致写入扁平路径 `structure.field`;读取时兼容接口把字段挂在 `structure.data.field`
203
250
  * 或多包一层对象的情况(与 previewUtils normalizeType3 一致)。
@@ -213,8 +260,6 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
213
260
  var bound = Boolean(fieldPath);
214
261
  var nestedFieldPath = structureName && structureField ? structureName + ".data." + structureField : '';
215
262
  var dataBagPath = structureName ? structureName + ".data" : '';
216
- /** 范围内表:接口与预览回填多在 structure.data.field(如 ts_city.data.low),须优先对该路径读写 */
217
- var primaryStoragePath = rangeInnerTable && nestedFieldPath ? nestedFieldPath : fieldPath;
218
263
  var ctxValue = useMemo(function () {
219
264
  if (!bound || !(formContext !== null && formContext !== void 0 && formContext.initialized)) return FORM_EMPTY_ARRAY;
220
265
  var values = formContext.values;
@@ -224,17 +269,14 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
224
269
  if (v !== undefined && v !== null) return v;
225
270
  return FORM_EMPTY_ARRAY;
226
271
  };
227
- if (rangeInnerTable) {
228
- var fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : FORM_EMPTY_ARRAY;
229
- if (fromNested !== FORM_EMPTY_ARRAY) return fromNested;
230
- var fromFlat = fieldPath ? tryRead(fieldPath) : FORM_EMPTY_ARRAY;
231
- if (fromFlat !== FORM_EMPTY_ARRAY) return fromFlat;
232
- } else {
233
- var _fromFlat = fieldPath ? tryRead(fieldPath) : FORM_EMPTY_ARRAY;
234
- if (_fromFlat !== FORM_EMPTY_ARRAY) return _fromFlat;
235
- var _fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : FORM_EMPTY_ARRAY;
236
- if (_fromNested !== FORM_EMPTY_ARRAY) return _fromNested;
272
+ if (rangeInnerTable && structureName && structureField) {
273
+ var fromRange = readRangeInnerEchoValue(values, structureName, structureField, fieldPath);
274
+ if (fromRange !== FORM_EMPTY_ARRAY) return fromRange;
237
275
  }
276
+ var fromFlat = fieldPath ? tryRead(fieldPath) : FORM_EMPTY_ARRAY;
277
+ if (fromFlat !== FORM_EMPTY_ARRAY) return fromFlat;
278
+ var fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : FORM_EMPTY_ARRAY;
279
+ if (fromNested !== FORM_EMPTY_ARRAY) return fromNested;
238
280
  if (structureField && dataBagPath && has(values, dataBagPath)) {
239
281
  var bag = get(values, dataBagPath);
240
282
  if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
@@ -243,16 +285,18 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
243
285
  }
244
286
  }
245
287
  return FORM_EMPTY_ARRAY;
246
- }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, formContext]);
288
+ }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, structureName, formContext]);
247
289
  var value = bound ? ctxValue : localValue;
248
290
  var commit = useCallback(function (next) {
249
291
  if (bound) {
250
292
  if (!(formContext !== null && formContext !== void 0 && formContext.setFieldValue)) return;
251
- formContext.setFieldValue(primaryStoragePath || fieldPath, next);
293
+ var vals = formContext.values || {};
294
+ var path = rangeInnerTable && structureName && structureField ? resolveRangeInnerWritePath(vals, structureName, structureField, fieldPath) : fieldPath;
295
+ formContext.setFieldValue(path, next);
252
296
  } else {
253
297
  setLocalValue(next);
254
298
  }
255
- }, [bound, fieldPath, primaryStoragePath, formContext]);
299
+ }, [bound, fieldPath, formContext, rangeInnerTable, structureName, structureField]);
256
300
  return {
257
301
  value: value,
258
302
  commit: commit
@@ -293,11 +337,11 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
293
337
  }, [dataSource, options]);
294
338
  var handleChange = function handleChange(newValue, _data, extra) {
295
339
  var next = cascaderChangeToPath(newValue, extra);
296
- console.log('[ProCascaderSelect] onChange', {
340
+ previewFlowCascader('onChange', {
297
341
  fieldPath: fieldPath,
298
342
  rawValue: newValue,
299
- selectedPath: extra === null || extra === void 0 ? void 0 : extra.selectedPath,
300
- normalizedPath: next
343
+ normalizedPath: next,
344
+ selectedPathLen: Array.isArray(extra === null || extra === void 0 ? void 0 : extra.selectedPath) ? extra.selectedPath.length : 0
301
345
  });
302
346
  commit(next);
303
347
  schemaOnChange === null || schemaOnChange === void 0 ? void 0 : schemaOnChange(next, structureName, structureField);
@@ -349,30 +393,21 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
349
393
  useEffect(function () {
350
394
  var leaf = displayValue.length > 0 ? displayValue[displayValue.length - 1] : '';
351
395
  var resolvedPathFromLeaf = leaf ? findPathByNodeValue(cascaderOptions, toStr(leaf)) : [];
352
- console.log('[ProCascaderSelect] echo-id-and-path', {
353
- fieldPath: fieldPath,
354
- incomingLeafId: incomingLeafId,
355
- packedPathFromLeaf: packedPathFromLeaf
356
- });
357
- console.log('[ProCascaderSelect] render-debug', {
396
+ previewFlowCascader('echo', {
358
397
  fieldPath: fieldPath,
359
398
  structureName: structureName,
360
399
  structureField: structureField,
361
- rawBoundValue: value,
400
+ rangeInnerTable: rangeInnerTable,
401
+ incomingLeafId: incomingLeafId,
402
+ packedPathFromLeafLen: packedPathFromLeaf.length,
403
+ rawBoundValuePreview: typeof value === 'object' ? JSON.stringify(value).slice(0, 120) : String(value).slice(0, 80),
362
404
  normalizedDisplayPath: displayValue,
363
- fusionValue: valueForFusion,
405
+ fusionValuePreview: typeof valueForFusion === 'object' ? JSON.stringify(valueForFusion).slice(0, 80) : String(valueForFusion).slice(0, 80),
364
406
  isMultiple: isMultiple,
365
407
  optionsCount: cascaderOptions.length,
366
- resolvedPathFromLeaf: resolvedPathFromLeaf,
367
- optionsPreview: cascaderOptions.slice(0, 3).map(function (n) {
368
- return {
369
- value: getNodeValue(n),
370
- label: getNodeLabel(n),
371
- childrenCount: getNodeChildren(n).length
372
- };
373
- })
408
+ resolvedPathFromLeafLen: resolvedPathFromLeaf.length
374
409
  });
375
- }, [fieldPath, structureName, structureField, value, displayValue, valueForFusion, isMultiple, cascaderOptions]);
410
+ }, [fieldPath, structureName, structureField, rangeInnerTable, incomingLeafId, packedPathFromLeaf, value, displayValue, valueForFusion, isMultiple, cascaderOptions]);
376
411
 
377
412
  /** dataSource 未就绪或异步时,仍用自定义文案兜底 */
378
413
  var schemaDisplayRender = props.displayRender;
@@ -19,6 +19,14 @@ var _window$React = window.React,
19
19
  useMemo = _window$React.useMemo,
20
20
  useContext = _window$React.useContext,
21
21
  useState = _window$React.useState;
22
+
23
+ /** 与预览 previewFlowDebug 一致:window.__PREVIEW_FLOW_LOG__ === false 时静音 */
24
+ function previewFlowCascader(tag, detail) {
25
+ if (typeof window !== 'undefined' && window.__PREVIEW_FLOW_LOG__ === false) {
26
+ return;
27
+ }
28
+ console.log('[PreviewFlow][Cascader]', tag, detail);
29
+ }
22
30
  function toStr(v) {
23
31
  if (v == null) return '';
24
32
  return String(v);
@@ -203,6 +211,45 @@ function cascaderChangeToPath(newValue, extra) {
203
211
  return [String(newValue)];
204
212
  }
205
213
 
214
+ /**
215
+ * 范围内表回填形状:
216
+ * - customType 4:`structure.data` 为 `[{ low, high, sign, option, ... }]` → 取 `data[0].field`
217
+ * - 对象型:`structure.data` 为 `{ low: ... }` → 取 `data.field`
218
+ * - 扁平:`structure.field`(与 previewUtils expandInnerTableRangeEcho 一致)
219
+ */
220
+ function readRangeInnerEchoValue(values, structureName, structureField, flatPath) {
221
+ var dataBagPath = structureName ? structureName + ".data" : '';
222
+ var pathsTryFirst = [structureName && structureField ? structureName + ".data[0]." + structureField : '', structureName && structureField ? structureName + ".data." + structureField : '', flatPath].filter(Boolean);
223
+ for (var _iterator4 = _createForOfIteratorHelperLoose(pathsTryFirst), _step4; !(_step4 = _iterator4()).done;) {
224
+ var p = _step4.value;
225
+ var _v2 = (0, _lodash.get)(values, p);
226
+ if (_v2 !== undefined && _v2 !== null) return _v2;
227
+ }
228
+ if (structureField && dataBagPath) {
229
+ var bag = (0, _lodash.get)(values, dataBagPath);
230
+ if (Array.isArray(bag) && bag[0] && typeof bag[0] === 'object' && structureField in bag[0]) {
231
+ var v = bag[0][structureField];
232
+ if (v !== undefined && v !== null) return v;
233
+ }
234
+ if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
235
+ var _v = bag[structureField];
236
+ if (_v !== undefined && _v !== null) return _v;
237
+ }
238
+ }
239
+ return _useComponentContext.FORM_EMPTY_ARRAY;
240
+ }
241
+ function resolveRangeInnerWritePath(values, structureName, structureField, flatPath) {
242
+ if (!structureName || !structureField) return flatPath;
243
+ var dataBag = (0, _lodash.get)(values, structureName + ".data");
244
+ if (Array.isArray(dataBag)) {
245
+ return structureName + ".data[0]." + structureField;
246
+ }
247
+ if (dataBag && typeof dataBag === 'object' && !Array.isArray(dataBag)) {
248
+ return structureName + ".data." + structureField;
249
+ }
250
+ return flatPath;
251
+ }
252
+
206
253
  /**
207
254
  * 与 ProInput 一致写入扁平路径 `structure.field`;读取时兼容接口把字段挂在 `structure.data.field`
208
255
  * 或多包一层对象的情况(与 previewUtils normalizeType3 一致)。
@@ -218,8 +265,6 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
218
265
  var bound = Boolean(fieldPath);
219
266
  var nestedFieldPath = structureName && structureField ? structureName + ".data." + structureField : '';
220
267
  var dataBagPath = structureName ? structureName + ".data" : '';
221
- /** 范围内表:接口与预览回填多在 structure.data.field(如 ts_city.data.low),须优先对该路径读写 */
222
- var primaryStoragePath = rangeInnerTable && nestedFieldPath ? nestedFieldPath : fieldPath;
223
268
  var ctxValue = useMemo(function () {
224
269
  if (!bound || !(formContext !== null && formContext !== void 0 && formContext.initialized)) return _useComponentContext.FORM_EMPTY_ARRAY;
225
270
  var values = formContext.values;
@@ -229,17 +274,14 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
229
274
  if (v !== undefined && v !== null) return v;
230
275
  return _useComponentContext.FORM_EMPTY_ARRAY;
231
276
  };
232
- if (rangeInnerTable) {
233
- var fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
234
- if (fromNested !== _useComponentContext.FORM_EMPTY_ARRAY) return fromNested;
235
- var fromFlat = fieldPath ? tryRead(fieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
236
- if (fromFlat !== _useComponentContext.FORM_EMPTY_ARRAY) return fromFlat;
237
- } else {
238
- var _fromFlat = fieldPath ? tryRead(fieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
239
- if (_fromFlat !== _useComponentContext.FORM_EMPTY_ARRAY) return _fromFlat;
240
- var _fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
241
- if (_fromNested !== _useComponentContext.FORM_EMPTY_ARRAY) return _fromNested;
277
+ if (rangeInnerTable && structureName && structureField) {
278
+ var fromRange = readRangeInnerEchoValue(values, structureName, structureField, fieldPath);
279
+ if (fromRange !== _useComponentContext.FORM_EMPTY_ARRAY) return fromRange;
242
280
  }
281
+ var fromFlat = fieldPath ? tryRead(fieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
282
+ if (fromFlat !== _useComponentContext.FORM_EMPTY_ARRAY) return fromFlat;
283
+ var fromNested = nestedFieldPath ? tryRead(nestedFieldPath) : _useComponentContext.FORM_EMPTY_ARRAY;
284
+ if (fromNested !== _useComponentContext.FORM_EMPTY_ARRAY) return fromNested;
243
285
  if (structureField && dataBagPath && (0, _lodash.has)(values, dataBagPath)) {
244
286
  var bag = (0, _lodash.get)(values, dataBagPath);
245
287
  if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
@@ -248,16 +290,18 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
248
290
  }
249
291
  }
250
292
  return _useComponentContext.FORM_EMPTY_ARRAY;
251
- }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, formContext]);
293
+ }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, structureName, formContext]);
252
294
  var value = bound ? ctxValue : localValue;
253
295
  var commit = useCallback(function (next) {
254
296
  if (bound) {
255
297
  if (!(formContext !== null && formContext !== void 0 && formContext.setFieldValue)) return;
256
- formContext.setFieldValue(primaryStoragePath || fieldPath, next);
298
+ var vals = formContext.values || {};
299
+ var path = rangeInnerTable && structureName && structureField ? resolveRangeInnerWritePath(vals, structureName, structureField, fieldPath) : fieldPath;
300
+ formContext.setFieldValue(path, next);
257
301
  } else {
258
302
  setLocalValue(next);
259
303
  }
260
- }, [bound, fieldPath, primaryStoragePath, formContext]);
304
+ }, [bound, fieldPath, formContext, rangeInnerTable, structureName, structureField]);
261
305
  return {
262
306
  value: value,
263
307
  commit: commit
@@ -298,11 +342,11 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
298
342
  }, [dataSource, options]);
299
343
  var handleChange = function handleChange(newValue, _data, extra) {
300
344
  var next = cascaderChangeToPath(newValue, extra);
301
- console.log('[ProCascaderSelect] onChange', {
345
+ previewFlowCascader('onChange', {
302
346
  fieldPath: fieldPath,
303
347
  rawValue: newValue,
304
- selectedPath: extra === null || extra === void 0 ? void 0 : extra.selectedPath,
305
- normalizedPath: next
348
+ normalizedPath: next,
349
+ selectedPathLen: Array.isArray(extra === null || extra === void 0 ? void 0 : extra.selectedPath) ? extra.selectedPath.length : 0
306
350
  });
307
351
  commit(next);
308
352
  schemaOnChange === null || schemaOnChange === void 0 ? void 0 : schemaOnChange(next, structureName, structureField);
@@ -354,30 +398,21 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
354
398
  useEffect(function () {
355
399
  var leaf = displayValue.length > 0 ? displayValue[displayValue.length - 1] : '';
356
400
  var resolvedPathFromLeaf = leaf ? findPathByNodeValue(cascaderOptions, toStr(leaf)) : [];
357
- console.log('[ProCascaderSelect] echo-id-and-path', {
358
- fieldPath: fieldPath,
359
- incomingLeafId: incomingLeafId,
360
- packedPathFromLeaf: packedPathFromLeaf
361
- });
362
- console.log('[ProCascaderSelect] render-debug', {
401
+ previewFlowCascader('echo', {
363
402
  fieldPath: fieldPath,
364
403
  structureName: structureName,
365
404
  structureField: structureField,
366
- rawBoundValue: value,
405
+ rangeInnerTable: rangeInnerTable,
406
+ incomingLeafId: incomingLeafId,
407
+ packedPathFromLeafLen: packedPathFromLeaf.length,
408
+ rawBoundValuePreview: typeof value === 'object' ? JSON.stringify(value).slice(0, 120) : String(value).slice(0, 80),
367
409
  normalizedDisplayPath: displayValue,
368
- fusionValue: valueForFusion,
410
+ fusionValuePreview: typeof valueForFusion === 'object' ? JSON.stringify(valueForFusion).slice(0, 80) : String(valueForFusion).slice(0, 80),
369
411
  isMultiple: isMultiple,
370
412
  optionsCount: cascaderOptions.length,
371
- resolvedPathFromLeaf: resolvedPathFromLeaf,
372
- optionsPreview: cascaderOptions.slice(0, 3).map(function (n) {
373
- return {
374
- value: getNodeValue(n),
375
- label: getNodeLabel(n),
376
- childrenCount: getNodeChildren(n).length
377
- };
378
- })
413
+ resolvedPathFromLeafLen: resolvedPathFromLeaf.length
379
414
  });
380
- }, [fieldPath, structureName, structureField, value, displayValue, valueForFusion, isMultiple, cascaderOptions]);
415
+ }, [fieldPath, structureName, structureField, rangeInnerTable, incomingLeafId, packedPathFromLeaf, value, displayValue, valueForFusion, isMultiple, cascaderOptions]);
381
416
 
382
417
  /** dataSource 未就绪或异步时,仍用自定义文案兜底 */
383
418
  var schemaDisplayRender = props.displayRender;
@@ -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.92';
104
+ version = '1.0.94';
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.92';
109
+ version = '1.0.94';
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.92",
3
+ "version": "1.0.94",
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.92/build/lowcode/assets-prod.json"
104
+ "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.94/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.92/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.94/build/index.html"
110
110
  }