3h1-ui 3.0.0-next.242 → 3.0.0-next.244

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.
Files changed (3) hide show
  1. package/es/index.js +44 -28
  2. package/lib/index.js +44 -28
  3. package/package.json +3 -3
package/es/index.js CHANGED
@@ -12614,20 +12614,37 @@ function useFormEvents({
12614
12614
  return;
12615
12615
  }
12616
12616
  const schema = [];
12617
- unref(getSchema).forEach((val) => {
12618
- let _val;
12619
- updateData.forEach((item) => {
12620
- if (val.field === item.field) {
12621
- _val = item;
12617
+ function processSchemas(schemas, context = {}) {
12618
+ return schemas.map((schemaItem) => {
12619
+ const matched = updateData.find(
12620
+ (item) => item.field === schemaItem.field
12621
+ );
12622
+ const merged = matched ? deepMerge$2(schemaItem, matched) : { ...schemaItem };
12623
+ let originalProps = merged.componentProps;
12624
+ if (typeof originalProps === "function" && merged.component === "Group") {
12625
+ const resultProps = originalProps(context);
12626
+ if (Array.isArray(resultProps == null ? void 0 : resultProps.schemas)) {
12627
+ processSchemas(resultProps.schemas, context);
12628
+ merged.componentProps = (ctx) => {
12629
+ const finalProps = originalProps(ctx);
12630
+ return {
12631
+ ...finalProps,
12632
+ schemas: processSchemas(finalProps.schemas || [], ctx)
12633
+ };
12634
+ };
12635
+ }
12636
+ }
12637
+ if (typeof originalProps === "object" && merged.component === "Group" && Array.isArray(originalProps == null ? void 0 : originalProps.schemas)) {
12638
+ merged.componentProps = {
12639
+ ...originalProps,
12640
+ schemas: processSchemas(originalProps.schemas, context)
12641
+ };
12622
12642
  }
12643
+ return merged;
12623
12644
  });
12624
- if (_val !== void 0 && val.field === _val.field) {
12625
- const newSchema = deepMerge$2(val, _val);
12626
- schema.push(newSchema);
12627
- } else {
12628
- schema.push(val);
12629
- }
12630
- });
12645
+ }
12646
+ const rawSchemas = unref(getSchema);
12647
+ schema.push(...processSchemas(rawSchemas));
12631
12648
  _setDefaultValue(schema);
12632
12649
  schemaRef.value = uniqBy(schema, "field");
12633
12650
  }
@@ -25866,28 +25883,27 @@ const ShyForm = /* @__PURE__ */ defineComponent({
25866
25883
  for (const key2 in val) {
25867
25884
  let handleSchemas = function(schemas = []) {
25868
25885
  schemas.forEach((item) => {
25869
- var _a2, _b;
25870
- const isComponentProps = item.field === key2 && item.componentProps;
25871
- if (isComponentProps && !isFunction$5(item.componentProps) && ((_a2 = item.componentProps) == null ? void 0 : _a2.onModelChange)) {
25872
- item.componentProps.onModelChange(val[key2]);
25873
- } else if (isComponentProps && isFunction$5(item.componentProps)) {
25874
- const modelProps = item.componentProps({
25875
- schema: item,
25876
- formModel,
25877
- formActionType,
25878
- tableAction: props2.tableAction
25879
- });
25880
- if (modelProps.onModelChange) {
25881
- modelProps.onModelChange(val[key2]);
25882
- }
25886
+ const isTargetField = item.field === key2;
25887
+ context.schema = item;
25888
+ const rawComponentProps = item.componentProps;
25889
+ const resolvedProps = isFunction$5(rawComponentProps) ? rawComponentProps(context) : rawComponentProps;
25890
+ if (isTargetField && (resolvedProps == null ? void 0 : resolvedProps.onModelChange)) {
25891
+ resolvedProps.onModelChange(val[key2]);
25883
25892
  }
25884
- if (item.component === "Group" && ((_b = item.componentProps) == null ? void 0 : _b.schemas)) {
25885
- handleSchemas(item.componentProps.schemas);
25893
+ if (item.component === "Group" && resolvedProps && Array.isArray(resolvedProps.schemas)) {
25894
+ handleSchemas(resolvedProps.schemas);
25886
25895
  }
25887
25896
  });
25888
25897
  };
25889
25898
  if (isEqual(toRaw(val[key2]), toRaw(tempFormModel[key2])))
25890
25899
  continue;
25900
+ const context = {
25901
+ schema: {},
25902
+ // 每次赋值
25903
+ formModel,
25904
+ formActionType,
25905
+ tableAction: props2.tableAction
25906
+ };
25891
25907
  handleSchemas(unref(getProps).schemas);
25892
25908
  }
25893
25909
  Object.assign(tempFormModel, cloneDeep(formModel));
package/lib/index.js CHANGED
@@ -12638,20 +12638,37 @@ function useFormEvents({
12638
12638
  return;
12639
12639
  }
12640
12640
  const schema = [];
12641
- vue.unref(getSchema).forEach((val) => {
12642
- let _val;
12643
- updateData.forEach((item) => {
12644
- if (val.field === item.field) {
12645
- _val = item;
12641
+ function processSchemas(schemas, context = {}) {
12642
+ return schemas.map((schemaItem) => {
12643
+ const matched = updateData.find(
12644
+ (item) => item.field === schemaItem.field
12645
+ );
12646
+ const merged = matched ? utils$1.deepMerge(schemaItem, matched) : { ...schemaItem };
12647
+ let originalProps = merged.componentProps;
12648
+ if (typeof originalProps === "function" && merged.component === "Group") {
12649
+ const resultProps = originalProps(context);
12650
+ if (Array.isArray(resultProps == null ? void 0 : resultProps.schemas)) {
12651
+ processSchemas(resultProps.schemas, context);
12652
+ merged.componentProps = (ctx) => {
12653
+ const finalProps = originalProps(ctx);
12654
+ return {
12655
+ ...finalProps,
12656
+ schemas: processSchemas(finalProps.schemas || [], ctx)
12657
+ };
12658
+ };
12659
+ }
12660
+ }
12661
+ if (typeof originalProps === "object" && merged.component === "Group" && Array.isArray(originalProps == null ? void 0 : originalProps.schemas)) {
12662
+ merged.componentProps = {
12663
+ ...originalProps,
12664
+ schemas: processSchemas(originalProps.schemas, context)
12665
+ };
12646
12666
  }
12667
+ return merged;
12647
12668
  });
12648
- if (_val !== void 0 && val.field === _val.field) {
12649
- const newSchema = utils$1.deepMerge(val, _val);
12650
- schema.push(newSchema);
12651
- } else {
12652
- schema.push(val);
12653
- }
12654
- });
12669
+ }
12670
+ const rawSchemas = vue.unref(getSchema);
12671
+ schema.push(...processSchemas(rawSchemas));
12655
12672
  _setDefaultValue(schema);
12656
12673
  schemaRef.value = uniqBy(schema, "field");
12657
12674
  }
@@ -25890,28 +25907,27 @@ const ShyForm = /* @__PURE__ */ vue.defineComponent({
25890
25907
  for (const key2 in val) {
25891
25908
  let handleSchemas = function(schemas = []) {
25892
25909
  schemas.forEach((item) => {
25893
- var _a2, _b;
25894
- const isComponentProps = item.field === key2 && item.componentProps;
25895
- if (isComponentProps && !isFunction$5(item.componentProps) && ((_a2 = item.componentProps) == null ? void 0 : _a2.onModelChange)) {
25896
- item.componentProps.onModelChange(val[key2]);
25897
- } else if (isComponentProps && isFunction$5(item.componentProps)) {
25898
- const modelProps = item.componentProps({
25899
- schema: item,
25900
- formModel,
25901
- formActionType,
25902
- tableAction: props2.tableAction
25903
- });
25904
- if (modelProps.onModelChange) {
25905
- modelProps.onModelChange(val[key2]);
25906
- }
25910
+ const isTargetField = item.field === key2;
25911
+ context.schema = item;
25912
+ const rawComponentProps = item.componentProps;
25913
+ const resolvedProps = isFunction$5(rawComponentProps) ? rawComponentProps(context) : rawComponentProps;
25914
+ if (isTargetField && (resolvedProps == null ? void 0 : resolvedProps.onModelChange)) {
25915
+ resolvedProps.onModelChange(val[key2]);
25907
25916
  }
25908
- if (item.component === "Group" && ((_b = item.componentProps) == null ? void 0 : _b.schemas)) {
25909
- handleSchemas(item.componentProps.schemas);
25917
+ if (item.component === "Group" && resolvedProps && Array.isArray(resolvedProps.schemas)) {
25918
+ handleSchemas(resolvedProps.schemas);
25910
25919
  }
25911
25920
  });
25912
25921
  };
25913
25922
  if (isEqual(vue.toRaw(val[key2]), vue.toRaw(tempFormModel[key2])))
25914
25923
  continue;
25924
+ const context = {
25925
+ schema: {},
25926
+ // 每次赋值
25927
+ formModel,
25928
+ formActionType,
25929
+ tableAction: props2.tableAction
25930
+ };
25915
25931
  handleSchemas(vue.unref(getProps).schemas);
25916
25932
  }
25917
25933
  Object.assign(tempFormModel, cloneDeep(formModel));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3h1-ui",
3
- "version": "3.0.0-next.242",
3
+ "version": "3.0.0-next.244",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -29,9 +29,9 @@
29
29
  "vue-json-pretty": "^2.2.3",
30
30
  "vxe-table": "4.3.6",
31
31
  "xe-utils": "^3.5.7",
32
+ "@shy-plugins/utils": "1.0.0-next.1",
32
33
  "@shy-plugins/use": "1.0.1-next.5",
33
- "@shy-plugins/tinymce": "^1.0.6",
34
- "@shy-plugins/utils": "1.0.0-next.1"
34
+ "@shy-plugins/tinymce": "^1.0.6"
35
35
  },
36
36
  "types": "es/ui/index.d.ts",
37
37
  "devDependencies": {