@nocobase/client 1.9.39 → 1.9.41

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.
package/es/index.mjs CHANGED
@@ -53,7 +53,7 @@ import { css, cx } from "@emotion/css";
53
53
  export * from "@emotion/css";
54
54
  import jsxRuntime, { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
55
55
  import * as formilyReact from "@formily/react";
56
- import { Observer, SchemaOptionsContext, SchemaComponentsContext, ExpressionScope, Schema, connect, mapProps, useField, useExpressionScope, useFieldSchema, SchemaExpressionScopeContext, observer as observer$1, FormContext, FormProvider as FormProvider$1, useForm, mapReadPretty, FieldContext, ObjectField, ArrayField, RecursionField, SchemaContext, VoidField, Field, createSchemaField } from "@formily/react";
56
+ import { Observer, SchemaOptionsContext, SchemaComponentsContext, ExpressionScope, Schema, connect, mapProps, useField, useExpressionScope, useFieldSchema, SchemaExpressionScopeContext, observer as observer$1, FormContext, FormProvider as FormProvider$1, useForm, mapReadPretty, FieldContext, ObjectField, ArrayField, RecursionField, SchemaContext, VoidField, Field, createSchemaField, useFormEffects } from "@formily/react";
57
57
  import * as ahooks from "ahooks";
58
58
  import { useSetState, useRequest as useRequest$1, useBoolean, useUpdate, useMemoizedFn, useDeepCompareEffect, useEventListener, useLocalStorageState, useCreation, useDebounce } from "ahooks";
59
59
  import * as antd from "antd";
@@ -97,7 +97,7 @@ import { matchRoutes } from "react-router";
97
97
  import omit$1 from "lodash/omit";
98
98
  import qs from "qs";
99
99
  import * as formilyCore from "@formily/core";
100
- import { createForm, onFormValuesChange, onFieldValueChange, onFieldChange, isArrayField, onFormInputChange, onFieldInit, onFieldInputValueChange, onFormSubmitSuccess, registerValidateFormats, registerValidateRules as registerValidateRules$1 } from "@formily/core";
100
+ import { createForm, onFormValuesChange, onFieldValueChange, onFieldChange, isArrayField, onFormInputChange, onFieldInit, onFieldInputValueChange, onFormReset, onFormSubmitSuccess, registerValidateFormats, registerValidateRules as registerValidateRules$1 } from "@formily/core";
101
101
  import dayjs from "dayjs";
102
102
  import flat, { unflatten } from "flat";
103
103
  import * as nocobaseEvaluators from "@nocobase/evaluators/client";
@@ -2785,6 +2785,9 @@ const bp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2785
2785
  get VariablePopupRecordProvider() {
2786
2786
  return VariablePopupRecordProvider;
2787
2787
  },
2788
+ get VariableScope() {
2789
+ return VariableScope;
2790
+ },
2788
2791
  get VariableScopeProvider() {
2789
2792
  return VariableScopeProvider;
2790
2793
  },
@@ -8855,7 +8858,7 @@ function addAppVersion(e, t) {
8855
8858
  addAppVersion((o = e.properties) == null ? void 0 : o[n], t);
8856
8859
  }), e;
8857
8860
  }
8858
- const name = "@nocobase/client", version = "1.9.39", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8861
+ const name = "@nocobase/client", version = "1.9.41", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8859
8862
  "@ahooksjs/use-url-state": "3.5.1",
8860
8863
  "@ant-design/cssinjs": "^1.11.1",
8861
8864
  "@ant-design/icons": "^5.6.1",
@@ -8876,9 +8879,9 @@ const name = "@nocobase/client", version = "1.9.39", license = "AGPL-3.0", main
8876
8879
  "@formily/reactive-react": "^2.2.27",
8877
8880
  "@formily/shared": "^2.2.27",
8878
8881
  "@formily/validator": "^2.2.27",
8879
- "@nocobase/evaluators": "1.9.39",
8880
- "@nocobase/sdk": "1.9.39",
8881
- "@nocobase/utils": "1.9.39",
8882
+ "@nocobase/evaluators": "1.9.41",
8883
+ "@nocobase/sdk": "1.9.41",
8884
+ "@nocobase/utils": "1.9.41",
8882
8885
  ahooks: "^3.7.2",
8883
8886
  antd: "5.24.2",
8884
8887
  "antd-mobile": "^5.41.1",
@@ -11655,47 +11658,38 @@ ResourceActionContext.displayName = "ResourceActionContext";
11655
11658
  const ResourceContext = createContext(null);
11656
11659
  ResourceContext.displayName = "ResourceContext";
11657
11660
  const CollectionResourceActionProvider = (e) => {
11658
- var g, f, C, b;
11661
+ var v, I, F;
11659
11662
  const { collection: t, request: n, uid: o, dragSort: r } = e, a = useAPIClient(), i = useRecord(), l = n == null ? void 0 : n.action, c = {};
11660
11663
  l === "get" && (c.filterByTk = i[t.targetKey || t.filterTargetKey || "id"]);
11661
- const u = ((g = n == null ? void 0 : n.params) == null ? void 0 : g.appends) || [], d = useRequest(
11664
+ const y = (n == null ? void 0 : n.params) || {}, { appends: u, disableDefaultAppends: d } = y, p = W(y, ["appends", "disableDefaultAppends"]), m = ((I = (v = t == null ? void 0 : t.fields) == null ? void 0 : v.filter) == null ? void 0 : I.call(v, (w) => w.target).map((w) => w.name)) || [], h = d ? u || [] : [...m, ...u || []], g = h.length > 0, f = useRequest(
11662
11665
  P(x({}, n), {
11663
- params: P(x(x({}, c), n == null ? void 0 : n.params), {
11664
- appends: [
11665
- ...((C = (f = t == null ? void 0 : t.fields) == null ? void 0 : f.filter) == null ? void 0 : C.call(f, (S) => S.target).map((S) => S.name)) || [],
11666
- ...u
11667
- ],
11668
- sort: r ? [t.sortable === !0 ? "sort" : t.sortable] : (b = n == null ? void 0 : n.params) == null ? void 0 : b.sort
11666
+ params: P(x(x(x({}, c), p), g ? { appends: h } : {}), {
11667
+ sort: r ? [t.sortable === !0 ? "sort" : t.sortable] : (F = n == null ? void 0 : n.params) == null ? void 0 : F.sort
11669
11668
  })
11670
11669
  }),
11671
11670
  { uid: o }
11672
- ), p = a.resource(n.resource), m = useMemo(
11673
- () => P(x({}, d), { defaultRequest: n, dragSort: r }),
11674
- [r, n, d]
11675
- ), h = useMemo(() => ({ type: "collection", resource: p, collection: t }), [t, p]);
11676
- return /* @__PURE__ */ jsx(ResourceContext.Provider, { value: h, children: /* @__PURE__ */ jsx(ResourceActionContext.Provider, { value: m, children: /* @__PURE__ */ jsx(CollectionProvider_deprecated, { collection: t, children: e.children }) }) });
11671
+ ), C = a.resource(n.resource), b = useMemo(
11672
+ () => P(x({}, f), { defaultRequest: n, dragSort: r }),
11673
+ [r, n, f]
11674
+ ), S = useMemo(() => ({ type: "collection", resource: C, collection: t }), [t, C]);
11675
+ return /* @__PURE__ */ jsx(ResourceContext.Provider, { value: S, children: /* @__PURE__ */ jsx(ResourceActionContext.Provider, { value: b, children: /* @__PURE__ */ jsx(CollectionProvider_deprecated, { collection: t, children: e.children }) }) });
11677
11676
  }, AssociationResourceActionProvider = (e) => {
11678
- var g, f, C;
11679
- const { collection: t, association: n, request: o, uid: r, dragSort: a } = e, i = useAPIClient(), c = useRecord()[n.sourceKey], u = ((g = o == null ? void 0 : o.params) == null ? void 0 : g.appends) || [], d = useRequest(
11677
+ var v, I;
11678
+ const { collection: t, association: n, request: o, uid: r, dragSort: a } = e, i = useAPIClient(), c = useRecord()[n.sourceKey], y = (o == null ? void 0 : o.params) || {}, { appends: u, disableDefaultAppends: d } = y, p = W(y, ["appends", "disableDefaultAppends"]), m = ((I = (v = t == null ? void 0 : t.fields) == null ? void 0 : v.filter) == null ? void 0 : I.call(v, (F) => F.target).map((F) => F.name)) || [], h = d ? u || [] : [...m, ...u || []], g = h.length > 0, f = useRequest(
11680
11679
  P(x({
11681
11680
  resourceOf: c
11682
11681
  }, o), {
11683
- params: P(x({}, o == null ? void 0 : o.params), {
11684
- appends: [
11685
- ...((C = (f = t == null ? void 0 : t.fields) == null ? void 0 : f.filter) == null ? void 0 : C.call(f, (b) => b.target).map((b) => b.name)) || [],
11686
- ...u
11687
- ]
11688
- })
11682
+ params: x(x({}, p), g ? { appends: h } : {})
11689
11683
  }),
11690
11684
  { uid: r }
11691
- ), p = i.resource(o.resource, c), m = useMemo(
11692
- () => ({ type: "association", resource: p, association: n, collection: t }),
11693
- [n, t, p]
11694
- ), h = useMemo(
11695
- () => P(x({}, d), { defaultRequest: o, dragSort: a }),
11696
- [a, o, d]
11685
+ ), C = i.resource(o.resource, c), b = useMemo(
11686
+ () => ({ type: "association", resource: C, association: n, collection: t }),
11687
+ [n, t, C]
11688
+ ), S = useMemo(
11689
+ () => P(x({}, f), { defaultRequest: o, dragSort: a }),
11690
+ [a, o, f]
11697
11691
  );
11698
- return /* @__PURE__ */ jsx(ResourceContext.Provider, { value: m, children: /* @__PURE__ */ jsx(ResourceActionContext.Provider, { value: h, children: /* @__PURE__ */ jsx(CollectionProvider_deprecated, { collection: t, children: e.children }) }) });
11692
+ return /* @__PURE__ */ jsx(ResourceContext.Provider, { value: b, children: /* @__PURE__ */ jsx(ResourceActionContext.Provider, { value: S, children: /* @__PURE__ */ jsx(CollectionProvider_deprecated, { collection: t, children: e.children }) }) });
11699
11693
  }, ResourceActionProvider = (e) => {
11700
11694
  var r;
11701
11695
  let { collection: t, request: n } = e;
@@ -45261,7 +45255,7 @@ const InternalFileManager = (e) => {
45261
45255
  var C, b;
45262
45256
  (C = a.values) != null && C[i.name] || (n && n.values.select_array && !((b = a.values) != null && b[i.name]) ? (n.setValuesIn("select_array", void 0), setTimeout(() => {
45263
45257
  n.setValuesIn("select_array", [{}]);
45264
- })) : n.reset());
45258
+ })) : n.setValuesIn(i.name, null));
45265
45259
  }, [(f = a.values) == null ? void 0 : f[i.name]]);
45266
45260
  const g = {
45267
45261
  type: "object",
@@ -45328,6 +45322,9 @@ const InternalFileManager = (e) => {
45328
45322
  schema: P(x({}, i), {
45329
45323
  default: u,
45330
45324
  title: "",
45325
+ "x-decorator-props": {
45326
+ feedbackLayout: "none"
45327
+ },
45331
45328
  "x-component": AssociationCascadeSelect,
45332
45329
  "x-component-props": x({}, e)
45333
45330
  })
@@ -46314,51 +46311,52 @@ function FinallyButton(h) {
46314
46311
  form: p,
46315
46312
  designable: m
46316
46313
  } = g;
46317
- var v, I, F, w, T, D;
46318
- const { getCollection: b } = useCollectionManager_deprecated(), S = useACLActionParamsContext(), y = useMemo(() => {
46319
- var M;
46320
- const B = m && (((M = d == null ? void 0 : d.data) == null ? void 0 : M.hidden) || !S);
46314
+ var I, F, w, T, D, B, N, M;
46315
+ const { getCollection: b } = useCollectionManager_deprecated(), S = useACLActionParamsContext(), y = (p == null ? void 0 : p.disabled) || ((I = d == null ? void 0 : d.data) == null ? void 0 : I.disabled) || ((F = d == null ? void 0 : d.componentProps) == null ? void 0 : F.disabled) || (r == null ? void 0 : r.disabled), v = useMemo(() => {
46316
+ var O;
46317
+ const j = m && (((O = d == null ? void 0 : d.data) == null ? void 0 : O.hidden) || !S);
46321
46318
  return {
46322
- opacity: a !== "link" && B ? 0.1 : 1
46319
+ opacity: a !== "link" && j ? 0.1 : 1
46323
46320
  };
46324
- }, [m, (v = d == null ? void 0 : d.data) == null ? void 0 : v.hidden, S, a]);
46321
+ }, [m, (w = d == null ? void 0 : d.data) == null ? void 0 : w.hidden, S, a]);
46325
46322
  return (e == null ? void 0 : e.length) > 0 ? t ? /* @__PURE__ */ jsx(
46326
46323
  Button,
46327
46324
  {
46328
46325
  "aria-label": r["aria-label"],
46329
46326
  type: a,
46330
- disabled: d.disabled,
46327
+ disabled: y,
46331
46328
  danger: r.danger,
46332
46329
  icon: u,
46333
- onClick: (B) => {
46334
- const N = getLinkageCollection(t, p, d), M = e.find((R) => R.name === N) ? N : c.name, j = b(M);
46335
- l == null || l(j);
46330
+ onClick: (j) => {
46331
+ const R = getLinkageCollection(t, p, d), O = e.find((A) => A.name === R) ? R : c.name, $ = b(O);
46332
+ l == null || l($);
46336
46333
  },
46337
46334
  style: x({
46338
- display: !m && ((I = d == null ? void 0 : d.data) == null ? void 0 : I.hidden) && "none",
46339
- opacity: m && ((F = d == null ? void 0 : d.data) == null ? void 0 : F.hidden) && 0.1
46340
- }, y),
46335
+ display: !m && ((T = d == null ? void 0 : d.data) == null ? void 0 : T.hidden) && "none",
46336
+ opacity: m && ((D = d == null ? void 0 : d.data) == null ? void 0 : D.hidden) && 0.1
46337
+ }, v),
46341
46338
  children: r.children
46342
46339
  }
46343
46340
  ) : n === void 0 || n ? /* @__PURE__ */ jsxs(
46344
46341
  Dropdown.Button,
46345
46342
  {
46346
46343
  "aria-label": r["aria-label"],
46344
+ disabled: y,
46347
46345
  danger: r.danger,
46348
46346
  type: a,
46349
46347
  icon: /* @__PURE__ */ jsx(DownOutlined, {}),
46350
- style: x(x({}, r == null ? void 0 : r.style), y),
46351
- buttonsRender: ([B, N]) => [
46352
- React.cloneElement(B, {
46348
+ style: x(x({}, r == null ? void 0 : r.style), v),
46349
+ buttonsRender: ([j, R]) => [
46350
+ React.cloneElement(j, {
46353
46351
  style: r == null ? void 0 : r.style
46354
46352
  }),
46355
- React.cloneElement(N, {
46353
+ React.cloneElement(R, {
46356
46354
  loading: !1,
46357
46355
  style: P(x({}, r == null ? void 0 : r.style), { justifyContent: "center" })
46358
46356
  })
46359
46357
  ],
46360
46358
  menu: i,
46361
- onClick: (B) => {
46359
+ onClick: (j) => {
46362
46360
  l == null || l(c);
46363
46361
  },
46364
46362
  children: [
@@ -46366,14 +46364,15 @@ function FinallyButton(h) {
46366
46364
  r.children
46367
46365
  ]
46368
46366
  }
46369
- ) : /* @__PURE__ */ jsx(Dropdown, { menu: i, children: /* @__PURE__ */ jsxs(
46367
+ ) : /* @__PURE__ */ jsx(Dropdown, { menu: i, disabled: y, children: /* @__PURE__ */ jsxs(
46370
46368
  Button,
46371
46369
  {
46372
46370
  "aria-label": r["aria-label"],
46371
+ disabled: y,
46373
46372
  icon: u,
46374
46373
  type: a,
46375
46374
  danger: r.danger,
46376
- style: x(x({}, r == null ? void 0 : r.style), y),
46375
+ style: x(x({}, r == null ? void 0 : r.style), v),
46377
46376
  children: [
46378
46377
  r.children,
46379
46378
  " ",
@@ -46385,17 +46384,17 @@ function FinallyButton(h) {
46385
46384
  P(x({}, r), {
46386
46385
  "aria-label": r["aria-label"],
46387
46386
  type: a,
46388
- disabled: d.disabled,
46387
+ disabled: y,
46389
46388
  danger: r.danger,
46390
46389
  icon: u,
46391
- onClick: (B) => {
46390
+ onClick: (j) => {
46392
46391
  l == null || l(c);
46393
46392
  },
46394
46393
  style: x(P(x({}, r == null ? void 0 : r.style), {
46395
- display: !m && ((w = d == null ? void 0 : d.data) != null && w.hidden) ? "none" : "inline-block",
46396
- opacity: m && ((T = d == null ? void 0 : d.data) == null ? void 0 : T.hidden) && 0.1
46397
- }), y),
46398
- children: o ? (D = r == null ? void 0 : r.children) == null ? void 0 : D[1] : r == null ? void 0 : r.children
46394
+ display: !m && ((B = d == null ? void 0 : d.data) != null && B.hidden) ? "none" : "inline-block",
46395
+ opacity: m && ((N = d == null ? void 0 : d.data) == null ? void 0 : N.hidden) && 0.1
46396
+ }), v),
46397
+ children: o ? (M = r == null ? void 0 : r.children) == null ? void 0 : M[1] : r == null ? void 0 : r.children
46399
46398
  })
46400
46399
  );
46401
46400
  }
@@ -50397,19 +50396,26 @@ const NanoIDInput = Object.assign(
50397
50396
  connect(
50398
50397
  Input$3,
50399
50398
  mapProps((e, t) => {
50400
- const { size: n, customAlphabet: o } = useCollectionField() || { size: 21 }, { t: r } = useTranslation(), a = useForm(), { isInFilterFormBlock: i } = useFlag();
50401
- function l(c) {
50402
- if ((c == null ? void 0 : c.length) !== n)
50403
- return r("Field value size is") + ` ${n || 21}`;
50404
- for (let u = 0; u < c.length; u++)
50405
- if ((o == null ? void 0 : o.indexOf(c[u])) === -1)
50406
- return r("Field value do not meet the requirements");
50399
+ const { size: n, customAlphabet: o, autoFill: r } = useCollectionField() || { size: 21 }, { t: a } = useTranslation(), i = useForm(), { isInFilterFormBlock: l } = useFlag();
50400
+ function c(u) {
50401
+ if ((u == null ? void 0 : u.length) !== n)
50402
+ return a("Field value size is") + ` ${n || 21}`;
50403
+ for (let d = 0; d < u.length; d++)
50404
+ if ((o == null ? void 0 : o.indexOf(u[d])) === -1)
50405
+ return a("Field value do not meet the requirements");
50407
50406
  }
50408
50407
  return useEffect(() => {
50409
- !t.initialValue && o && !i && t.setInitialValue(customAlphabet(o, n)()), a.setFieldState(t.props.name, (c) => {
50410
- c.validator = l;
50408
+ !t.initialValue && o && !l && t.setInitialValue(customAlphabet(o, n)()), i.setFieldState(t.props.name, (u) => {
50409
+ u.validator = c;
50410
+ });
50411
+ }, [l]), useFormEffects(() => {
50412
+ onFormReset(() => {
50413
+ if (!o || l || r === !1)
50414
+ return;
50415
+ const u = customAlphabet(o, n)();
50416
+ t.setInitialValue(u), t.setValue(u);
50411
50417
  });
50412
- }, [i]), P(x({}, e), {
50418
+ }), P(x({}, e), {
50413
50419
  suffix: /* @__PURE__ */ jsx("span", { children: t != null && t.loading || t != null && t.validating ? /* @__PURE__ */ jsx(LoadingOutlined, {}) : e.suffix })
50414
50420
  });
50415
50421
  }),
@@ -70497,6 +70503,7 @@ export {
70497
70503
  Variable,
70498
70504
  VariableInput,
70499
70505
  VariablePopupRecordProvider,
70506
+ VariableScope,
70500
70507
  VariableScopeProvider,
70501
70508
  VariablesContext,
70502
70509
  VariablesProvider$1 as VariablesProvider,
@@ -16,4 +16,4 @@ export * from './utils/isVariable';
16
16
  export * from './utils/transformVariableValue';
17
17
  export * from './constants';
18
18
  export type { VariablesContextType } from './types';
19
- export { useVariableScopeInfo } from './VariableScope';
19
+ export { VariableScope, useVariableScopeInfo } from './VariableScope';