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

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.
@@ -202,7 +202,7 @@ function cascaderChangeToPath(newValue, extra) {
202
202
  * 与 ProInput 一致写入扁平路径 `structure.field`;读取时兼容接口把字段挂在 `structure.data.field`
203
203
  * 或多包一层对象的情况(与 previewUtils normalizeType3 一致)。
204
204
  */
205
- function useCascaderBoundValue(fieldPath, structureName, structureField, unboundInit) {
205
+ function useCascaderBoundValue(fieldPath, structureName, structureField, unboundInit, rangeInnerTable) {
206
206
  var FormCtx = getFormContext();
207
207
  var formContext = useContext(FormCtx);
208
208
  var _useState = useState(function () {
@@ -213,35 +213,46 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
213
213
  var bound = Boolean(fieldPath);
214
214
  var nestedFieldPath = structureName && structureField ? structureName + ".data." + structureField : '';
215
215
  var dataBagPath = structureName ? structureName + ".data" : '';
216
+ /** 范围内表:接口与预览回填多在 structure.data.field(如 ts_city.data.low),须优先对该路径读写 */
217
+ var primaryStoragePath = rangeInnerTable && nestedFieldPath ? nestedFieldPath : fieldPath;
216
218
  var ctxValue = useMemo(function () {
217
219
  if (!bound || !(formContext !== null && formContext !== void 0 && formContext.initialized)) return FORM_EMPTY_ARRAY;
218
220
  var values = formContext.values;
219
- if (fieldPath && has(values, fieldPath)) {
220
- var v = get(values, fieldPath);
221
+ var tryRead = function tryRead(p) {
222
+ if (!p || !has(values, p)) return FORM_EMPTY_ARRAY;
223
+ var v = get(values, p);
221
224
  if (v !== undefined && v !== null) return v;
222
- }
223
- if (nestedFieldPath && has(values, nestedFieldPath)) {
224
- var _v = get(values, nestedFieldPath);
225
- if (_v !== undefined && _v !== null) return _v;
225
+ return FORM_EMPTY_ARRAY;
226
+ };
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;
226
237
  }
227
238
  if (structureField && dataBagPath && has(values, dataBagPath)) {
228
239
  var bag = get(values, dataBagPath);
229
240
  if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
230
- var _v2 = bag[structureField];
231
- if (_v2 !== undefined && _v2 !== null) return _v2;
241
+ var v = bag[structureField];
242
+ if (v !== undefined && v !== null) return v;
232
243
  }
233
244
  }
234
245
  return FORM_EMPTY_ARRAY;
235
- }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, formContext]);
246
+ }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, formContext]);
236
247
  var value = bound ? ctxValue : localValue;
237
248
  var commit = useCallback(function (next) {
238
249
  if (bound) {
239
250
  if (!(formContext !== null && formContext !== void 0 && formContext.setFieldValue)) return;
240
- formContext.setFieldValue(fieldPath, next);
251
+ formContext.setFieldValue(primaryStoragePath || fieldPath, next);
241
252
  } else {
242
253
  setLocalValue(next);
243
254
  }
244
- }, [bound, fieldPath, formContext]);
255
+ }, [bound, fieldPath, primaryStoragePath, formContext]);
245
256
  return {
246
257
  value: value,
247
258
  commit: commit
@@ -270,8 +281,9 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
270
281
  structureName = _resolveProScreenBind.structureName,
271
282
  structureField = _resolveProScreenBind.structureField,
272
283
  fieldPath = _resolveProScreenBind.fieldPath;
284
+ var rangeInnerTable = Boolean(range_inner_table && String(range_inner_table).trim());
273
285
  var unboundInit = defaultValue != null && Array.isArray(defaultValue) ? defaultValue.slice() : FORM_EMPTY_ARRAY;
274
- var _useCascaderBoundValu = useCascaderBoundValue(fieldPath, structureName || '', structureField || '', unboundInit),
286
+ var _useCascaderBoundValu = useCascaderBoundValue(fieldPath, structureName || '', structureField || '', unboundInit, rangeInnerTable),
275
287
  value = _useCascaderBoundValu.value,
276
288
  commit = _useCascaderBoundValu.commit;
277
289
  // 优先 dataSource,兼容部分 schema 透传为 options;并转为 Fusion 可索引的树形
@@ -207,7 +207,7 @@ function cascaderChangeToPath(newValue, extra) {
207
207
  * 与 ProInput 一致写入扁平路径 `structure.field`;读取时兼容接口把字段挂在 `structure.data.field`
208
208
  * 或多包一层对象的情况(与 previewUtils normalizeType3 一致)。
209
209
  */
210
- function useCascaderBoundValue(fieldPath, structureName, structureField, unboundInit) {
210
+ function useCascaderBoundValue(fieldPath, structureName, structureField, unboundInit, rangeInnerTable) {
211
211
  var FormCtx = (0, _FormProvider.getFormContext)();
212
212
  var formContext = useContext(FormCtx);
213
213
  var _useState = useState(function () {
@@ -218,35 +218,46 @@ function useCascaderBoundValue(fieldPath, structureName, structureField, unbound
218
218
  var bound = Boolean(fieldPath);
219
219
  var nestedFieldPath = structureName && structureField ? structureName + ".data." + structureField : '';
220
220
  var dataBagPath = structureName ? structureName + ".data" : '';
221
+ /** 范围内表:接口与预览回填多在 structure.data.field(如 ts_city.data.low),须优先对该路径读写 */
222
+ var primaryStoragePath = rangeInnerTable && nestedFieldPath ? nestedFieldPath : fieldPath;
221
223
  var ctxValue = useMemo(function () {
222
224
  if (!bound || !(formContext !== null && formContext !== void 0 && formContext.initialized)) return _useComponentContext.FORM_EMPTY_ARRAY;
223
225
  var values = formContext.values;
224
- if (fieldPath && (0, _lodash.has)(values, fieldPath)) {
225
- var v = (0, _lodash.get)(values, fieldPath);
226
+ var tryRead = function tryRead(p) {
227
+ if (!p || !(0, _lodash.has)(values, p)) return _useComponentContext.FORM_EMPTY_ARRAY;
228
+ var v = (0, _lodash.get)(values, p);
226
229
  if (v !== undefined && v !== null) return v;
227
- }
228
- if (nestedFieldPath && (0, _lodash.has)(values, nestedFieldPath)) {
229
- var _v = (0, _lodash.get)(values, nestedFieldPath);
230
- if (_v !== undefined && _v !== null) return _v;
230
+ return _useComponentContext.FORM_EMPTY_ARRAY;
231
+ };
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;
231
242
  }
232
243
  if (structureField && dataBagPath && (0, _lodash.has)(values, dataBagPath)) {
233
244
  var bag = (0, _lodash.get)(values, dataBagPath);
234
245
  if (bag && typeof bag === 'object' && !Array.isArray(bag) && structureField in bag) {
235
- var _v2 = bag[structureField];
236
- if (_v2 !== undefined && _v2 !== null) return _v2;
246
+ var v = bag[structureField];
247
+ if (v !== undefined && v !== null) return v;
237
248
  }
238
249
  }
239
250
  return _useComponentContext.FORM_EMPTY_ARRAY;
240
- }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, formContext]);
251
+ }, [bound, fieldPath, nestedFieldPath, dataBagPath, structureField, rangeInnerTable, formContext]);
241
252
  var value = bound ? ctxValue : localValue;
242
253
  var commit = useCallback(function (next) {
243
254
  if (bound) {
244
255
  if (!(formContext !== null && formContext !== void 0 && formContext.setFieldValue)) return;
245
- formContext.setFieldValue(fieldPath, next);
256
+ formContext.setFieldValue(primaryStoragePath || fieldPath, next);
246
257
  } else {
247
258
  setLocalValue(next);
248
259
  }
249
- }, [bound, fieldPath, formContext]);
260
+ }, [bound, fieldPath, primaryStoragePath, formContext]);
250
261
  return {
251
262
  value: value,
252
263
  commit: commit
@@ -275,8 +286,9 @@ var ProCascaderSelect = function ProCascaderSelect(props) {
275
286
  structureName = _resolveProScreenBind.structureName,
276
287
  structureField = _resolveProScreenBind.structureField,
277
288
  fieldPath = _resolveProScreenBind.fieldPath;
289
+ var rangeInnerTable = Boolean(range_inner_table && String(range_inner_table).trim());
278
290
  var unboundInit = defaultValue != null && Array.isArray(defaultValue) ? defaultValue.slice() : _useComponentContext.FORM_EMPTY_ARRAY;
279
- var _useCascaderBoundValu = useCascaderBoundValue(fieldPath, structureName || '', structureField || '', unboundInit),
291
+ var _useCascaderBoundValu = useCascaderBoundValue(fieldPath, structureName || '', structureField || '', unboundInit, rangeInnerTable),
280
292
  value = _useCascaderBoundValu.value,
281
293
  commit = _useCascaderBoundValu.commit;
282
294
  // 优先 dataSource,兼容部分 schema 透传为 options;并转为 Fusion 可索引的树形
@@ -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.91';
104
+ version = '1.0.92';
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.91';
109
+ version = '1.0.92';
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.91",
3
+ "version": "1.0.92",
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.91/build/lowcode/assets-prod.json"
104
+ "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.92/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.91/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.92/build/index.html"
110
110
  }