@nocobase/client 1.7.0 → 1.7.1

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.
@@ -13,8 +13,6 @@ import { FC } from 'react';
13
13
  export declare const useTemplateBlockContext: () => {
14
14
  templateFinished?: boolean;
15
15
  onTemplateSuccess?: Function;
16
- isBlockTemplate?: () => boolean;
17
- setIsBlockTemplate?: (value: boolean) => void;
18
16
  };
19
17
  declare const TemplateBlockProvider: FC<{
20
18
  onTemplateLoaded?: () => void;
package/es/index.mjs CHANGED
@@ -6459,26 +6459,13 @@ const TreeRecordContext = createContext(null), TreeRecordProvider = ({ children:
6459
6459
  return e == null ? void 0 : e.parent;
6460
6460
  }, TemplateBlockContext = createContext({});
6461
6461
  TemplateBlockContext.displayName = "TemplateBlockContext";
6462
- const useTemplateBlockContext = () => useContext(TemplateBlockContext), _isBlockTemplate = (e, t = 1) => {
6463
- if (!e || t >= 3)
6464
- return !1;
6465
- const o = Object.keys(e.properties || {});
6466
- for (const n of o) {
6467
- const r = e.properties[n];
6468
- if (r["x-component"] === "BlockTemplate" || _isBlockTemplate(r, t + 1))
6469
- return !0;
6470
- }
6471
- return !1;
6472
- }, TemplateBlockProvider = ({ onTemplateLoaded: e, children: t }) => {
6473
- const o = useFieldSchema(), [n, r] = useState(!1), a = useCallback(() => {
6474
- r(!0), setTimeout(() => {
6462
+ const useTemplateBlockContext = () => useContext(TemplateBlockContext), TemplateBlockProvider = ({ onTemplateLoaded: e, children: t }) => {
6463
+ const [o, n] = useState(!1), r = useCallback(() => {
6464
+ n(!0), setTimeout(() => {
6475
6465
  e == null || e();
6476
6466
  });
6477
- }, [e]), i = useCallback(() => _isBlockTemplate(o) || o["x-component"] === "BlockTemplate", [o]), l = useMemo(
6478
- () => ({ templateFinished: n, onTemplateSuccess: a, isBlockTemplate: i }),
6479
- [a, n, i]
6480
- );
6481
- return /* @__PURE__ */ jsx(TemplateBlockContext.Provider, { value: l, children: t });
6467
+ }, [e]), a = useMemo(() => ({ templateFinished: o, onTemplateSuccess: r }), [r, o]);
6468
+ return /* @__PURE__ */ jsx(TemplateBlockContext.Provider, { value: a, children: t });
6482
6469
  }, FormActiveFieldsContext = createContext(null), FormActiveFieldsProvider = ({
6483
6470
  children: e,
6484
6471
  name: t,
@@ -8398,7 +8385,7 @@ function addAppVersion(e, t) {
8398
8385
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
8399
8386
  }), e;
8400
8387
  }
8401
- const name = "@nocobase/client", version = "1.7.0", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8388
+ const name = "@nocobase/client", version = "1.7.1", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8402
8389
  "@ahooksjs/use-url-state": "3.5.1",
8403
8390
  "@ant-design/cssinjs": "^1.11.1",
8404
8391
  "@ant-design/icons": "^5.6.1",
@@ -8419,9 +8406,9 @@ const name = "@nocobase/client", version = "1.7.0", license = "AGPL-3.0", main =
8419
8406
  "@formily/reactive-react": "^2.2.27",
8420
8407
  "@formily/shared": "^2.2.27",
8421
8408
  "@formily/validator": "^2.2.27",
8422
- "@nocobase/evaluators": "1.7.0",
8423
- "@nocobase/sdk": "1.7.0",
8424
- "@nocobase/utils": "1.7.0",
8409
+ "@nocobase/evaluators": "1.7.1",
8410
+ "@nocobase/sdk": "1.7.1",
8411
+ "@nocobase/utils": "1.7.1",
8425
8412
  ahooks: "^3.7.2",
8426
8413
  antd: "5.24.2",
8427
8414
  "antd-style": "3.7.1",
@@ -18049,7 +18036,7 @@ const InternalDetailsBlockProvider = (e) => {
18049
18036
  resource: i,
18050
18037
  formBlockRef: d
18051
18038
  }), [t, n, r, i, l]);
18052
- return n.loaded = !0, /* @__PURE__ */ jsx(CurrentRecordContextProvider, { recordData: u, collectionName: a == null ? void 0 : a.name, children: /* @__PURE__ */ jsx(DetailsBlockContext.Provider, { value: p, children: /* @__PURE__ */ jsx("div", { ref: d, children: /* @__PURE__ */ jsx(RecordProvider, { isNew: !1, record: u, parent: c == null ? void 0 : c.data, children: e.children }) }) }) });
18039
+ return l.loading && !n.loaded ? /* @__PURE__ */ jsx(Spin, {}) : (n.loaded = !0, /* @__PURE__ */ jsx(CurrentRecordContextProvider, { recordData: u, collectionName: a == null ? void 0 : a.name, children: /* @__PURE__ */ jsx(DetailsBlockContext.Provider, { value: p, children: /* @__PURE__ */ jsx("div", { ref: d, children: /* @__PURE__ */ jsx(RecordProvider, { isNew: !1, record: u, parent: c == null ? void 0 : c.data, children: e.children }) }) }) }));
18053
18040
  }, useCompatDetailsBlockParams = (e) => {
18054
18041
  const t = useFieldSchema();
18055
18042
  let o, n = !1;
@@ -28002,8 +27989,8 @@ BlockRequestLoadingContext.displayName = "BlockRequestLoadingContext";
28002
27989
  const BlockRequestDataContext = createContext(null);
28003
27990
  BlockRequestDataContext.displayName = "BlockRequestDataContext";
28004
27991
  function useRecordRequest(e) {
28005
- const t = useDataLoadingMode(), o = useDataBlockResource(), { action: n, params: r = {}, record: a, requestService: i, requestOptions: l, sourceId: c, association: u, parentRecord: d } = e, p = useAPIClient(), m = useDataBlockProps(), h = useDataSourceHeaders(m.dataSource), g = useSourceKey(u), [f, C] = useMemo(() => [JSON.stringify(r), JSON.stringify(a)], [r, a]), { isBlockTemplate: b, templateFinished: S } = useTemplateBlockContext(), y = (T) => {
28006
- var B;
27992
+ const t = useDataLoadingMode(), o = useDataBlockResource(), { action: n, params: r = {}, record: a, requestService: i, requestOptions: l, sourceId: c, association: u, parentRecord: d } = e, p = useAPIClient(), m = useDataBlockProps(), h = useDataSourceHeaders(m.dataSource), g = useSourceKey(u), [f, C] = useMemo(() => [JSON.stringify(r), JSON.stringify(a)], [r, a]), b = (v) => {
27993
+ var T;
28007
27994
  if (a)
28008
27995
  return Promise.resolve({ data: a });
28009
27996
  if (!n)
@@ -28012,19 +27999,19 @@ function useRecordRequest(e) {
28012
27999
  return console.warn(
28013
28000
  '[nocobase]: The "filterByTk" parameter is missing in the "DataBlockRequestProvider" component'
28014
28001
  );
28015
- const R = r.filterByTk === void 0 ? _.omit(r, "filterByTk") : r, D = x(x({}, R), T);
28016
- return (B = o[n]) == null ? void 0 : B.call(o, D).then((N) => N.data);
28017
- }, v = (...T) => b != null && b() && !S ? null : (i || y)(...T);
28018
- return useRequest((...T) => q(this, null, function* () {
28019
- const [R, D] = yield Promise.all([
28020
- v(...T),
28002
+ const F = r.filterByTk === void 0 ? _.omit(r, "filterByTk") : r, I = x(x({}, F), v);
28003
+ return (T = o[n]) == null ? void 0 : T.call(o, I).then((R) => R.data);
28004
+ };
28005
+ return useRequest((...v) => q(this, null, function* () {
28006
+ const [F, I] = yield Promise.all([
28007
+ (i || b)(...v),
28021
28008
  requestParentRecordData({ sourceId: c, association: u, parentRecord: d, api: p, headers: h, sourceKey: g })
28022
28009
  ]);
28023
- return R && (R.parentRecord = D == null ? void 0 : D.data), R;
28010
+ return F && (F.parentRecord = I == null ? void 0 : I.data), F;
28024
28011
  }), P(x({}, l), {
28025
28012
  manual: t === "manual",
28026
28013
  ready: !!n,
28027
- refreshDeps: [n, f, C, o, u, d, c, S]
28014
+ refreshDeps: [n, f, C, o, u, d, c]
28028
28015
  }));
28029
28016
  }
28030
28017
  function requestParentRecordData(i) {
@@ -40174,40 +40161,40 @@ const useFormBlockHeight = () => {
40174
40161
  o["x-linkage-rules"] && (t = o["x-linkage-rules"]);
40175
40162
  }), t;
40176
40163
  }, WithForm = (e) => {
40177
- var m, h;
40178
- const { form: t } = e, o = useFieldSchema(), { setFormValueChanged: n } = useActionContext(), r = useVariables$1(), a = useLocalVariables$1({ currentForm: t }), { templateFinished: i } = useTemplateBlockContext(), { loading: l, data: c } = useDataBlockRequest() || {}, u = useApp(), d = ((h = getLinkageRules(o) || ((m = o.parent) == null ? void 0 : m["x-linkage-rules"])) == null ? void 0 : h.filter((g) => !g.disabled)) || [], { confirmBeforeClose: p = !0 } = useDataBlockProps() || {};
40164
+ var p, m;
40165
+ const { form: t } = e, o = useFieldSchema(), { setFormValueChanged: n } = useActionContext(), r = useVariables$1(), a = useLocalVariables$1({ currentForm: t }), { templateFinished: i } = useTemplateBlockContext(), { loading: l } = useDataBlockRequest() || {}, c = useApp(), u = ((m = getLinkageRules(o) || ((p = o.parent) == null ? void 0 : p["x-linkage-rules"])) == null ? void 0 : m.filter((h) => !h.disabled)) || [], { confirmBeforeClose: d = !0 } = useDataBlockProps() || {};
40179
40166
  return useEffect(() => {
40180
- const g = uid();
40181
- return t.addEffects(g, () => {
40167
+ const h = uid();
40168
+ return t.addEffects(h, () => {
40182
40169
  onFormInputChange(() => {
40183
- n == null || n(p);
40170
+ n == null || n(d);
40184
40171
  });
40185
40172
  }), e.disabled && (t.disabled = e.disabled), () => {
40186
- t.removeEffects(g);
40173
+ t.removeEffects(h);
40187
40174
  };
40188
- }, [t, e.disabled, n, p]), useEffect(() => {
40189
- if (l || _.isEmpty(c == null ? void 0 : c.data))
40175
+ }, [t, e.disabled, n, d]), useEffect(() => {
40176
+ if (l)
40190
40177
  return;
40191
- const g = uid(), f = [];
40178
+ const h = uid(), g = [];
40192
40179
  return setTimeout(() => {
40193
- t.addEffects(g, () => {
40194
- forEachLinkageRule(d, (C, b) => {
40195
- var S;
40196
- if ((S = C.targetFields) != null && S.length) {
40197
- const y = C.targetFields.join(",");
40198
- onFieldInit(`*(${y})`, (v, F) => {
40199
- f.push(
40180
+ t.addEffects(h, () => {
40181
+ forEachLinkageRule(u, (f, C) => {
40182
+ var b;
40183
+ if ((b = f.targetFields) != null && b.length) {
40184
+ const S = f.targetFields.join(",");
40185
+ onFieldInit(`*(${S})`, (y, v) => {
40186
+ g.push(
40200
40187
  bindLinkageRulesToFiled(
40201
40188
  {
40202
- field: v,
40203
- linkageRules: d,
40204
- formValues: F.values,
40189
+ field: y,
40190
+ linkageRules: u,
40191
+ formValues: v.values,
40205
40192
  localVariables: a,
40206
- action: C,
40207
- rule: b,
40193
+ action: f,
40194
+ rule: C,
40208
40195
  variables: r
40209
40196
  },
40210
- u.jsonLogic
40197
+ c.jsonLogic
40211
40198
  )
40212
40199
  );
40213
40200
  });
@@ -40215,11 +40202,11 @@ const useFormBlockHeight = () => {
40215
40202
  });
40216
40203
  });
40217
40204
  }), () => {
40218
- t.removeEffects(g), f.forEach((C) => {
40219
- C();
40205
+ t.removeEffects(h), g.forEach((f) => {
40206
+ f();
40220
40207
  });
40221
40208
  };
40222
- }, [d, i, l]), o["x-decorator"] === "FormV2" ? /* @__PURE__ */ jsx(FormDecorator, x({}, e)) : /* @__PURE__ */ jsx(FormComponent, x({}, e));
40209
+ }, [u, i, l]), o["x-decorator"] === "FormV2" ? /* @__PURE__ */ jsx(FormDecorator, x({}, e)) : /* @__PURE__ */ jsx(FormComponent, x({}, e));
40223
40210
  }, WithoutForm = (e) => {
40224
40211
  const t = useFieldSchema(), { setFormValueChanged: o } = useActionContext(), { confirmBeforeClose: n = !0 } = useDataBlockProps() || {}, r = useMemo(
40225
40212
  () => createForm({
@@ -47082,10 +47069,10 @@ const CronSetInternal = (e) => {
47082
47069
  return /* @__PURE__ */ jsx(EllipsisWithTooltip, { ellipsis: !0, children: t && (l ? o(l) : /* @__PURE__ */ jsx(Cron.ReadPretty, x({}, e))) });
47083
47070
  }, CronSet = connect(CronSetInternal, mapReadPretty(ReadPretty$3)), Details = withDynamicSchemaProps(
47084
47071
  withSkeletonComponent((e) => {
47085
- const { data: t, loading: o } = useDataBlockRequest() || {}, n = useFieldSchema(), { isBlockTemplate: r, templateFinished: a } = useTemplateBlockContext();
47086
- return (r != null && r() ? !o && a && t && _.isEmpty(t.data) : _.isEmpty(t == null ? void 0 : t.data)) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
47072
+ const t = useDataBlockRequestData(), o = useFieldSchema();
47073
+ return _.isEmpty(t == null ? void 0 : t.data) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
47087
47074
  /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }),
47088
- /* @__PURE__ */ jsx(NocoBaseRecursionField, { schema: n.properties.pagination, name: "pagination" })
47075
+ /* @__PURE__ */ jsx(NocoBaseRecursionField, { schema: o.properties.pagination, name: "pagination" })
47089
47076
  ] }) : /* @__PURE__ */ jsx("div", { className: "nb-details", children: /* @__PURE__ */ jsx(FormWithDataTemplates, x({}, e)) });
47090
47077
  }),
47091
47078
  { displayName: "NocoBaseDetails" }