@nocobase/client 2.0.30 → 2.0.32

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.
@@ -17,6 +17,13 @@ import { DetailsGridModel } from './DetailsGridModel';
17
17
  * @param idx Form.List 的索引
18
18
  */
19
19
  export declare function getValueWithIndex(record: any, fieldPath: string, idx?: string[]): any;
20
+ export declare function getDetailsItemValue(options: {
21
+ record: any;
22
+ currentObject?: any;
23
+ fieldPath: string;
24
+ prefixFieldPath?: string;
25
+ idx?: string[];
26
+ }): any;
20
27
  export declare class DetailsItemModel extends DisplayItemModel<{
21
28
  parent: DetailsGridModel;
22
29
  subModels: {
package/es/index.mjs CHANGED
@@ -80,7 +80,7 @@ import { ErrorBoundary } from "react-error-boundary";
80
80
  import * as reactI18next from "react-i18next";
81
81
  import { useTranslation, initReactI18next, Trans, I18nextProvider } from "react-i18next";
82
82
  import * as nocobaseSDK from "@nocobase/sdk";
83
- import { APIClient as APIClient$1, getSubAppName } from "@nocobase/sdk";
83
+ import { APIClient as APIClient$1, hasHeaderValue, getSubAppName } from "@nocobase/sdk";
84
84
  import get$1 from "lodash/get";
85
85
  import merge$1 from "lodash/merge";
86
86
  import set$1 from "lodash/set";
@@ -3777,6 +3777,9 @@ const bp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3777
3777
  get getDefaultOperator() {
3778
3778
  return getDefaultOperator;
3779
3779
  },
3780
+ get getDetailsItemValue() {
3781
+ return getDetailsItemValue;
3782
+ },
3780
3783
  get getDisplayNumber() {
3781
3784
  return getDisplayNumber;
3782
3785
  },
@@ -5280,7 +5283,7 @@ class APIClient extends APIClient$1 {
5280
5283
  o.headers["X-With-ACL-Meta"] = !0;
5281
5284
  const n = this.getHeaders();
5282
5285
  return Object.keys(n).forEach((r) => {
5283
- o.headers[r] = o.headers[r] || n[r];
5286
+ hasHeaderValue(o.headers, r) || (o.headers[r] = n[r]);
5284
5287
  }), o;
5285
5288
  }), super.interceptors(), this.useNotificationMiddleware(), this.axios.interceptors.response.use(
5286
5289
  (o) => o,
@@ -9964,7 +9967,7 @@ function addAppVersion(e, t) {
9964
9967
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
9965
9968
  }), e;
9966
9969
  }
9967
- const name = "@nocobase/client", version = "2.0.30", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9970
+ const name = "@nocobase/client", version = "2.0.32", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9968
9971
  "@ahooksjs/use-url-state": "3.5.1",
9969
9972
  "@ant-design/cssinjs": "^1.11.1",
9970
9973
  "@ant-design/icons": "^5.6.1",
@@ -9987,10 +9990,10 @@ const name = "@nocobase/client", version = "2.0.30", license = "Apache-2.0", mai
9987
9990
  "@formily/reactive-react": "^2.2.27",
9988
9991
  "@formily/shared": "^2.2.27",
9989
9992
  "@formily/validator": "^2.2.27",
9990
- "@nocobase/evaluators": "2.0.30",
9991
- "@nocobase/flow-engine": "2.0.30",
9992
- "@nocobase/sdk": "2.0.30",
9993
- "@nocobase/utils": "2.0.30",
9993
+ "@nocobase/evaluators": "2.0.32",
9994
+ "@nocobase/flow-engine": "2.0.32",
9995
+ "@nocobase/sdk": "2.0.32",
9996
+ "@nocobase/utils": "2.0.32",
9994
9997
  "@tanstack/react-table": "^8.21.3",
9995
9998
  "@types/tabulator-tables": "^6.2.6",
9996
9999
  "acorn-jsx": "^5.3.2",
@@ -30630,7 +30633,7 @@ const useStyles$a = genStyleHook("nb-markdown", (e, { isDarkTheme: t }) => {
30630
30633
  }, t ? i : r)
30631
30634
  };
30632
30635
  }), parseMarkdown$1 = _.memoize((e) => L(void 0, null, function* () {
30633
- return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
30636
+ return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
30634
30637
  }));
30635
30638
  function useParseMarkdown$1(e) {
30636
30639
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -72043,7 +72046,7 @@ BlockGridModel.registerFlow({
72043
72046
  }
72044
72047
  });
72045
72048
  const parseMarkdown = _.memoize((e) => L(void 0, null, function* () {
72046
- return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
72049
+ return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
72047
72050
  }));
72048
72051
  function useParseMarkdown(e) {
72049
72052
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -79468,6 +79471,18 @@ function getValueWithIndex(e, t, o) {
79468
79471
  }
79469
79472
  return get(e, r);
79470
79473
  }
79474
+ function getDetailsItemValue(e) {
79475
+ const { record: t, currentObject: o, fieldPath: n, prefixFieldPath: r, idx: i } = e, a = getValueWithIndex(t, n, i);
79476
+ if (a !== void 0 || o == null)
79477
+ return a;
79478
+ if (r && n === r)
79479
+ return o;
79480
+ const l = r && n.startsWith(`${r}.`) ? n.slice(r.length + 1) : n;
79481
+ return l ? get(o, l) : o;
79482
+ }
79483
+ function normalizeDetailsAssociationValue(e, t) {
79484
+ return !isToManyAssociationField(e) || Array.isArray(t) ? t : t && typeof t == "object" && Array.isArray(t.rows) ? t.rows : t == null ? [] : [t];
79485
+ }
79471
79486
  class DetailsItemModel extends DisplayItemModel {
79472
79487
  static defineChildren(t) {
79473
79488
  const o = t.collection;
@@ -79513,29 +79528,38 @@ class DetailsItemModel extends DisplayItemModel {
79513
79528
  });
79514
79529
  }
79515
79530
  renderItem() {
79516
- const t = this.subModels.field, o = this.context.fieldIndex, n = this.context.record, r = this.context.currentObject, i = this.context.item, a = this.context.getPropertyOptions("item"), l = o != null ? (() => {
79517
- const d = t.createFork({}, `${o}`);
79518
- d.context.defineProperty("fieldIndex", {
79531
+ const t = this.subModels.field, o = this.context.fieldIndex, n = this.context.record, r = this.context.currentObject, i = this.context.item, a = this.context.getPropertyOptions("item"), l = this.context.prefixFieldPath, c = o != null ? (() => {
79532
+ const p = t.createFork({}, `${o}`);
79533
+ p.context.defineProperty("fieldIndex", {
79519
79534
  get: () => o
79520
- }), d.context.defineProperty("record", {
79535
+ }), p.context.defineProperty("record", {
79521
79536
  get: () => n,
79522
79537
  cache: !1
79523
- }), d.context.defineProperty("currentObject", {
79538
+ }), p.context.defineProperty("currentObject", {
79524
79539
  get: () => r,
79525
79540
  cache: !1
79526
79541
  });
79527
- const h = a || {}, { value: p } = h, m = ee(h, ["value"]);
79528
- return d.context.defineProperty("item", A(x({}, m), {
79542
+ const g = a || {}, { value: m } = g, h = ee(g, ["value"]);
79543
+ return p.context.defineProperty("item", A(x({}, h), {
79529
79544
  get: () => i,
79530
79545
  cache: !1
79531
- })), this.context.pattern && d.context.defineProperty("pattern", {
79546
+ })), this.context.pattern && p.context.defineProperty("pattern", {
79532
79547
  get: () => this.context.pattern
79533
- }), d;
79534
- })() : t, c = this.context.pattern ? A(x(x({}, this.context.blockModel.props), this.props), {
79548
+ }), p;
79549
+ })() : t, u = this.context.pattern ? A(x(x({}, this.context.blockModel.props), this.props), {
79535
79550
  pattern: this.context.pattern,
79536
79551
  disabled: this.context.pattern === "readPretty"
79537
- }) : x(x({}, this.context.blockModel.props), this.props), u = getValueWithIndex(n, this.fieldPath, o);
79538
- return /* @__PURE__ */ jsx(FormItem$2, A(x({}, c), { value: u, children: /* @__PURE__ */ jsx(FieldModelRenderer, { model: l }) }));
79552
+ }) : x(x({}, this.context.blockModel.props), this.props), d = normalizeDetailsAssociationValue(
79553
+ this.collectionField,
79554
+ getDetailsItemValue({
79555
+ record: n,
79556
+ currentObject: r,
79557
+ fieldPath: this.fieldPath,
79558
+ prefixFieldPath: l,
79559
+ idx: o
79560
+ })
79561
+ );
79562
+ return /* @__PURE__ */ jsx(FormItem$2, A(x({}, u), { value: d, children: /* @__PURE__ */ jsx(FieldModelRenderer, { model: c }) }));
79539
79563
  }
79540
79564
  }
79541
79565
  DetailsItemModel.define({
@@ -83703,7 +83727,12 @@ const CustomWidth = ({ setOpen: e, t, handleChange: o, defaultValue: n }) => {
83703
83727
  ] })
83704
83728
  }
83705
83729
  );
83706
- }, Ze = class Ze extends DisplayItemModel {
83730
+ };
83731
+ function getSavedAssociationTitleField(e) {
83732
+ var t, o, n;
83733
+ return ((o = (t = e.getStepParams) == null ? void 0 : t.call(e, "tableColumnSettings", "fieldNames")) == null ? void 0 : o.label) || ((n = e.props) == null ? void 0 : n.titleField);
83734
+ }
83735
+ const Ze = class Ze extends DisplayItemModel {
83707
83736
  afterAddAsSubModel() {
83708
83737
  return L(this, null, function* () {
83709
83738
  yield Ne(Ze.prototype, this, "afterAddAsSubModel").call(this), yield this.dispatchEvent("beforeRender");
@@ -83865,8 +83894,12 @@ TableColumnModel.registerFlow({
83865
83894
  init: {
83866
83895
  handler(e, t) {
83867
83896
  return L(this, null, function* () {
83897
+ var i, a, l, c;
83868
83898
  const o = e.model.context.collectionField;
83869
- o && (e.model.setProps("title", o.title), e.model.setProps("dataIndex", o.name), yield e.model.applySubModelsBeforeRenderFlows("field"), e.model.setProps(x({}, o.getComponentProps())));
83899
+ if (!o)
83900
+ return;
83901
+ const n = getSavedAssociationTitleField(e.model), r = o.isAssociationField() && n ? x(x({}, o.getComponentProps()), (c = (l = (a = (i = o.targetCollection) == null ? void 0 : i.getField) == null ? void 0 : a.call(i, n)) == null ? void 0 : l.getComponentProps) == null ? void 0 : c.call(l)) : o.getComponentProps();
83902
+ e.model.setProps("title", o.title), e.model.setProps("dataIndex", o.name), yield e.model.applySubModelsBeforeRenderFlows("field"), e.model.setProps(x({}, r));
83870
83903
  });
83871
83904
  }
83872
83905
  },
@@ -84019,7 +84052,7 @@ TableColumnModel.registerFlow({
84019
84052
  defaultParams: (e) => {
84020
84053
  const t = e.model.context.collectionField.targetCollectionTitleFieldName;
84021
84054
  return {
84022
- label: e.model.props.titleField || t
84055
+ label: getSavedAssociationTitleField(e.model) || t
84023
84056
  };
84024
84057
  },
84025
84058
  handler(e, t) {
@@ -84122,16 +84155,20 @@ const LargeFieldEdit = observer((a) => {
84122
84155
  )
84123
84156
  }
84124
84157
  );
84125
- }), handleModelName = (e) => ["RadioGroupFieldModel", "CheckboxGroupFieldModel"].includes(e) ? "SelectFieldModel" : e, MemoFieldRenderer = React.memo(FieldModelRenderer, (e, t) => e.value === t.value && e.model === t.model), FieldModelRendererOptimize = React.memo((e) => {
84158
+ }), handleModelName = (e) => ["RadioGroupFieldModel", "CheckboxGroupFieldModel"].includes(e) ? "SelectFieldModel" : e, MemoFieldRenderer = React.memo(FieldModelRenderer, (e, t) => e.value === t.value && e.model === t.model);
84159
+ function shouldCommitImmediately(e) {
84160
+ return Array.isArray(e) ? !0 : e && typeof e == "object" ? !("target" in e) : !1;
84161
+ }
84162
+ const FieldModelRendererOptimize = React.memo((e) => {
84126
84163
  const c = e, { model: t, onChange: o, value: n } = c, r = ee(c, ["model", "onChange", "value"]), i = React.useRef(e == null ? void 0 : e.value);
84127
84164
  useEffect(() => {
84128
84165
  i.current = n;
84129
84166
  }, [n]);
84130
84167
  const a = React.useCallback(
84131
84168
  (u) => {
84132
- i.current = u;
84169
+ i.current = u, shouldCommitImmediately(u) && (o == null || o(u));
84133
84170
  },
84134
- [t]
84171
+ [o]
84135
84172
  ), l = React.useCallback(() => {
84136
84173
  o == null || o(i.current);
84137
84174
  }, [o]);
@@ -95792,6 +95829,7 @@ const models = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
95792
95829
  formatNumber,
95793
95830
  getAllDataModels,
95794
95831
  getDefaultOperator,
95832
+ getDetailsItemValue,
95795
95833
  getDisplayNumber,
95796
95834
  getValueWithIndex,
95797
95835
  injectRecordPickerPopupContext,
@@ -95954,9 +95992,9 @@ const openView = defineAction({
95954
95992
  const se = typeof (o == null ? void 0 : o[ne]) != "undefined", re = a.includes(ne);
95955
95993
  return se && !re ? o[ne] : typeof (t == null ? void 0 : t[ne]) != "undefined" ? t[ne] : se ? o[ne] : i == null ? void 0 : i[ne];
95956
95994
  }, c = (() => {
95957
- var se;
95995
+ var se, re;
95958
95996
  const ne = l("filterByTk");
95959
- return Array.isArray((se = e.collection) == null ? void 0 : se.filterTargetKey) && e.collection.filterTargetKey.length === 1 && ne != null && typeof ne != "object" ? { [e.collection.filterTargetKey[0]]: ne } : ne;
95997
+ return ((se = e.collection) == null ? void 0 : se.template) === "sql" && Array.isArray((re = e.collection) == null ? void 0 : re.filterTargetKey) && e.collection.filterTargetKey.length === 1 && ne != null && typeof ne != "object" ? { [e.collection.filterTargetKey[0]]: ne } : ne;
95960
95998
  })(), u = l("sourceId"), d = typeof (o == null ? void 0 : o.dataSourceKey) != "undefined" ? o.dataSourceKey : t == null ? void 0 : t.dataSourceKey, p = typeof (o == null ? void 0 : o.collectionName) != "undefined" ? o.collectionName : t == null ? void 0 : t.collectionName, m = typeof (o == null ? void 0 : o.associationName) != "undefined" ? o.associationName : t == null ? void 0 : t.associationName, h = typeof o.tabUid != "undefined" ? o.tabUid : t.tabUid, g = (z = e.inputArgs) != null && z.isMobileLayout ? "embed" : ((U = e.inputArgs) == null ? void 0 : U.mode) || t.mode || "drawer";
95961
95999
  let f = typeof o.navigation != "undefined" ? o.navigation : t.navigation;
95962
96000
  if ((n || r) && (f = !1), f !== !1 && e.isNavigationEnabled !== !1 && !e.inputArgs.navigation && (K = e.view) != null && K.navigation) {
@@ -108669,6 +108707,7 @@ export {
108669
108707
  getDatePickerLabels,
108670
108708
  getDateRanges,
108671
108709
  getDefaultOperator,
108710
+ getDetailsItemValue,
108672
108711
  getDisplayNumber,
108673
108712
  getFieldDefaultValue,
108674
108713
  getFlowPageMenuSchema,