@nocobase/client 1.9.0-beta.9 → 1.9.0

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.
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import { Form } from '@formily/core';
9
10
  import { ChangeEvent } from 'react';
10
11
  import { NavigateFunction } from 'react-router-dom';
11
12
  import { CollectionOptions } from '../../collection-manager';
@@ -26,7 +27,7 @@ export declare function getFormValues({ filterByTk, field, form, fieldNames, get
26
27
  resource: any;
27
28
  actionFields: any[];
28
29
  }): any;
29
- export declare function useCollectValuesToSubmit(): () => Promise<any>;
30
+ export declare function useCollectValuesToSubmit(f?: Form): () => Promise<any>;
30
31
  export declare const useCreateActionProps: () => {
31
32
  onClick(): Promise<void>;
32
33
  };
package/es/index.mjs CHANGED
@@ -8850,7 +8850,7 @@ function addAppVersion(e, t) {
8850
8850
  addAppVersion((o = e.properties) == null ? void 0 : o[n], t);
8851
8851
  }), e;
8852
8852
  }
8853
- const name = "@nocobase/client", version = "1.9.0-beta.9", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8853
+ const name = "@nocobase/client", version = "1.9.0", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
8854
8854
  "@ahooksjs/use-url-state": "3.5.1",
8855
8855
  "@ant-design/cssinjs": "^1.11.1",
8856
8856
  "@ant-design/icons": "^5.6.1",
@@ -8871,9 +8871,9 @@ const name = "@nocobase/client", version = "1.9.0-beta.9", license = "AGPL-3.0",
8871
8871
  "@formily/reactive-react": "^2.2.27",
8872
8872
  "@formily/shared": "^2.2.27",
8873
8873
  "@formily/validator": "^2.2.27",
8874
- "@nocobase/evaluators": "1.9.0-beta.9",
8875
- "@nocobase/sdk": "1.9.0-beta.9",
8876
- "@nocobase/utils": "1.9.0-beta.9",
8874
+ "@nocobase/evaluators": "1.9.0",
8875
+ "@nocobase/sdk": "1.9.0",
8876
+ "@nocobase/utils": "1.9.0",
8877
8877
  ahooks: "^3.7.2",
8878
8878
  antd: "5.24.2",
8879
8879
  "antd-style": "3.7.1",
@@ -22368,7 +22368,7 @@ const SchemaSettingsModalItem = (e) => {
22368
22368
  );
22369
22369
  }, SchemaSettingsLinkageRules = function(t) {
22370
22370
  var w;
22371
- const { collectionName: n, readPretty: o, Component: r, afterSubmit: a, title: i, returnScope: l } = t, c = useFieldSchema(), { form: u } = useFormBlockContext(), { dn: d } = useDesignable(), { t: p } = useTranslation(), { getTemplateById: m } = useSchemaTemplateManager(), h = useVariables$1(), g = useLocalVariables$1(), f = useRecord(), { type: C } = useFormBlockType(), b = (w = t == null ? void 0 : t.category) != null ? w : LinkageRuleCategory.default, S = (t == null ? void 0 : t.type) || (c != null && c["x-action"] || ["Action", "Action.Link"].includes(c["x-component"]) ? "button" : "field"), y = findGridSchema(c) || c, v = useLinkageCollectionFilterOptions(n), I = useLinkageCollectionFieldOptions(n, o), F = {
22371
+ const { collectionName: n, readPretty: o, Component: r, afterSubmit: a, title: i, returnScope: l } = t, c = useFieldSchema(), { form: u } = useFormBlockContext(), { dn: d } = useDesignable(), { t: p } = useTranslation(), { getTemplateById: m } = useSchemaTemplateManager(), h = useVariables$1(), g = useLocalVariables$1(), f = useRecord(), { type: C } = useFormBlockType(), b = (w = t == null ? void 0 : t.category) != null ? w : LinkageRuleCategory.default, S = (t == null ? void 0 : t.type) || (c != null && c["x-action"] || ["Action", "Action.Link", "WorkbenchAction"].includes(c["x-component"]) ? "button" : "field"), y = findGridSchema(c) || c, v = useLinkageCollectionFilterOptions(n), I = useLinkageCollectionFieldOptions(n, o), F = {
22372
22372
  [LinkageRuleCategory.default]: p("Linkage rules"),
22373
22373
  [LinkageRuleCategory.style]: p("Style")
22374
22374
  }, R = LinkageRuleDataKeyMap[b], T = useCallback(() => (y == null ? void 0 : y[R]) || (c == null ? void 0 : c[R]) || [], [y, c, R]), D = i || F[b] || p("Linkage rules"), B = useFlag(), N = useMemo(
@@ -29456,46 +29456,46 @@ function getFormValues({
29456
29456
  }
29457
29457
  return getFilteredFormValues(n);
29458
29458
  }
29459
- function useCollectValuesToSubmit() {
29460
- const e = useForm(), t = useFilterByTk(), { field: n, resource: o } = useBlockRequestContext(), { fields: r, getField: a, getTreeParentField: i, name: l } = useCollection_deprecated(), c = r.map((f) => f.name), { fieldSchema: u } = useActionContext(), { getActiveFieldsName: d } = useFormActiveFields() || {}, p = useVariables$1(), m = useLocalVariables$1({ currentForm: e }), h = useFieldSchema(), g = useTreeParentRecord();
29459
+ function useCollectValuesToSubmit(e) {
29460
+ const t = useForm(), n = e != null ? e : t, o = useFilterByTk(), { field: r, resource: a } = useBlockRequestContext(), { fields: i, getField: l, getTreeParentField: c, name: u } = useCollection_deprecated(), d = i.map((b) => b.name), { fieldSchema: p } = useActionContext(), { getActiveFieldsName: m } = useFormActiveFields() || {}, h = useVariables$1(), g = useLocalVariables$1({ currentForm: n }), f = useFieldSchema(), C = useTreeParentRecord();
29461
29461
  return useCallback(() => q(this, null, function* () {
29462
- var I, F, R, T;
29463
- const { assignedValues: f = {}, overwriteValues: C } = (I = h == null ? void 0 : h["x-action-settings"]) != null ? I : {}, b = getFormValues({
29464
- filterByTk: t,
29465
- field: n,
29466
- form: e,
29467
- fieldNames: c,
29468
- getField: a,
29469
- resource: o,
29470
- actionFields: (d == null ? void 0 : d("form")) || []
29471
- }), S = {}, y = Object.keys(f).map((D) => q(this, null, function* () {
29472
- const B = f[D], N = a(D);
29473
- if (isVariable$1(B)) {
29474
- const { value: M } = (yield p == null ? void 0 : p.parseVariable(B, m)) || {};
29475
- S[D] = transformVariableValue(M, { targetCollectionField: N });
29462
+ var R, T, D, B;
29463
+ const { assignedValues: b = {}, overwriteValues: S } = (R = f == null ? void 0 : f["x-action-settings"]) != null ? R : {}, y = getFormValues({
29464
+ filterByTk: o,
29465
+ field: r,
29466
+ form: n,
29467
+ fieldNames: d,
29468
+ getField: l,
29469
+ resource: a,
29470
+ actionFields: (m == null ? void 0 : m("form")) || []
29471
+ }), v = {}, I = Object.keys(b).map((N) => q(this, null, function* () {
29472
+ const M = b[N], j = l(N);
29473
+ if (isVariable$1(M)) {
29474
+ const { value: w } = (yield h == null ? void 0 : h.parseVariable(M, g)) || {};
29475
+ v[N] = transformVariableValue(w, { targetCollectionField: j });
29476
29476
  } else
29477
- B !== "" && (S[D] = B);
29477
+ M !== "" && (v[N] = M);
29478
29478
  }));
29479
- if (yield Promise.all(y), (F = u == null ? void 0 : u["x-component-props"]) == null ? void 0 : F.addChild) {
29480
- const D = i();
29481
- b[(R = D == null ? void 0 : D.name) != null ? R : "parent"] = g, b[(T = D == null ? void 0 : D.foreignKey) != null ? T : "parentId"] = g == null ? void 0 : g.id;
29479
+ if (yield Promise.all(I), (T = p == null ? void 0 : p["x-component-props"]) == null ? void 0 : T.addChild) {
29480
+ const N = c();
29481
+ y[(D = N == null ? void 0 : N.name) != null ? D : "parent"] = C, y[(B = N == null ? void 0 : N.foreignKey) != null ? B : "parentId"] = C == null ? void 0 : C.id;
29482
29482
  }
29483
- return x(x(x({}, b), C), S);
29483
+ return x(x(x({}, y), S), v);
29484
29484
  }), [
29485
- h,
29486
- n,
29487
- c,
29488
- u,
29489
- t,
29490
- e,
29485
+ f,
29486
+ r,
29491
29487
  d,
29492
- a,
29493
- i,
29488
+ p,
29489
+ o,
29490
+ n,
29494
29491
  m,
29495
29492
  l,
29496
- o,
29493
+ c,
29497
29494
  g,
29498
- p
29495
+ u,
29496
+ a,
29497
+ C,
29498
+ h
29499
29499
  ]);
29500
29500
  }
29501
29501
  const useCreateActionProps = () => {
@@ -31089,7 +31089,7 @@ const DragHandler = (e) => {
31089
31089
  open: i,
31090
31090
  onDropdownVisibleChange: l
31091
31091
  }, e), {
31092
- allowClear: !0,
31092
+ allowClear: !1,
31093
31093
  style: {
31094
31094
  width: "100%",
31095
31095
  minWidth: 100,
@@ -31215,7 +31215,7 @@ const DragHandler = (e) => {
31215
31215
  };
31216
31216
  }, BlockItem = withDynamicSchemaProps(
31217
31217
  (e) => {
31218
- const { className: t, children: n, style: o } = useProps(e), { componentCls: r, hashId: a } = useStyles$9(), i = useFieldSchema(), { render: l } = useSchemaToolbarRender(i), { getAriaLabel: c } = useGetAriaLabelOfBlockItem(e.name), u = useMemo(() => c(), [c]), d = useCollection(), p = i["x-decorator"] === "FormItem" && i["x-block-linkage-rules"], m = /* @__PURE__ */ jsxs(
31218
+ const { className: t, children: n, style: o } = useProps(e), { componentCls: r, hashId: a } = useStyles$9(), i = useFieldSchema(), { render: l } = useSchemaToolbarRender(i), { getAriaLabel: c } = useGetAriaLabelOfBlockItem(e.name), u = useMemo(() => c(), [c]), d = useCollection(), p = i["x-decorator"] === "FormItem" && i["x-block-linkage-rules"], m = i["x-component"] === "Iframe" && i["x-block-linkage-rules"], h = /* @__PURE__ */ jsxs(
31219
31219
  SortableItem,
31220
31220
  {
31221
31221
  role: "button",
@@ -31228,7 +31228,7 @@ const DragHandler = (e) => {
31228
31228
  ]
31229
31229
  }
31230
31230
  );
31231
- return d && !p ? m : /* @__PURE__ */ jsx(BlockLinkageRuleProvider, { children: m });
31231
+ return d && !p && !m ? h : /* @__PURE__ */ jsx(BlockLinkageRuleProvider, { children: h });
31232
31232
  },
31233
31233
  { displayName: "BlockItem" }
31234
31234
  ), TestDesigner = () => {
@@ -31909,7 +31909,7 @@ const useParseDefaultValue = () => {
31909
31909
  const j = transformVariableValue(B, {
31910
31910
  targetCollectionField: D
31911
31911
  });
31912
- j == null || j === "" ? e.mounted && (e.setInitialValue(void 0), e.setValue(void 0)) : p() ? h === 0 && m(j) : e.setInitialValue(j), e.loading = !1;
31912
+ j == null || j === "" ? e.mounted && (e.setInitialValue(void 0), e.setValue(void 0)) : p() ? h === 0 && m(j) : (e.setInitialValue(j), e.setValue(j)), e.loading = !1;
31913
31913
  } else
31914
31914
  !/\{\{.+\}\}/g.test(t.default) && e.setInitialValue && e.setInitialValue(t.default);
31915
31915
  }), v = _.debounce(y, DEBOUNCE_WAIT);
@@ -31955,6 +31955,9 @@ const formItemWrapCss = css`
31955
31955
  display: inline;
31956
31956
  }
31957
31957
  }
31958
+ .ant-formily-item-label label {
31959
+ word-break: normal;
31960
+ }
31958
31961
  `, formItemLabelCss = css`
31959
31962
  .ant-card-body {
31960
31963
  padding: 0px !important;
@@ -43189,7 +43192,7 @@ const className1 = css`
43189
43192
  onClick: () => q(void 0, null, function* () {
43190
43193
  const I = yield FormDialog(
43191
43194
  o("Add tab"),
43192
- () => /* @__PURE__ */ jsx(SchemaComponentOptions, { scope: p.scope, components: x({}, p.components), children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
43195
+ () => /* @__PURE__ */ jsx(SchemaComponentOptions, { scope: p.scope, components: x({}, p.components), children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(zIndexContext.Provider, { value: ICON_POPUP_Z_INDEX, children: /* @__PURE__ */ jsx(
43193
43196
  SchemaComponent,
43194
43197
  {
43195
43198
  schema: {
@@ -43208,7 +43211,7 @@ const className1 = css`
43208
43211
  }
43209
43212
  }
43210
43213
  }
43211
- ) }) }),
43214
+ ) }) }) }),
43212
43215
  m
43213
43216
  ).open({
43214
43217
  initialValues: {}
@@ -44034,9 +44037,18 @@ function validate(e, t) {
44034
44037
  function useBeforeUpload(e) {
44035
44038
  const { t } = useTranslation();
44036
44039
  return useCallback(
44037
- (n) => {
44038
- const o = validate(n, e);
44039
- return o ? (n.status = "error", n.response = t(o)) : n.status === "error" && (delete n.status, delete n.response), !o;
44040
+ (n, o) => {
44041
+ var i, l;
44042
+ let r = n;
44043
+ if (!n.type) {
44044
+ const c = (l = (i = n.name) == null ? void 0 : i.match(/\.[^.]+$/)) == null ? void 0 : l[0];
44045
+ c && (r = new File([n], n.name, {
44046
+ type: mime.getType(c) || "application/octet-stream",
44047
+ lastModified: n.lastModified
44048
+ }));
44049
+ }
44050
+ const a = validate(r, e);
44051
+ return a ? (n.status = "error", n.response = t(a)) : n.status === "error" && (delete r.status, delete r.response), a ? !1 : Promise.resolve(r);
44040
44052
  },
44041
44053
  [e]
44042
44054
  );
@@ -44151,38 +44163,56 @@ attachmentFileTypes.add({
44151
44163
  return e.preview ? e.preview : e.url ? e.url : e.originFileObj ? URL.createObjectURL(e.originFileObj) : null;
44152
44164
  },
44153
44165
  Previewer({ index: e, list: t, onSwitchIndex: n }) {
44154
- var c, u, d, p;
44155
- const [o, r] = useState(0), a = useCallback(
44156
- (m) => {
44157
- m.preventDefault();
44158
- const h = t[e];
44159
- saveAs(h.url, `${h.title}${h.extname}`);
44166
+ var p, m, h, g;
44167
+ const [o, r] = useState(0), a = useRef(!1), i = () => document.querySelector(".ril-image-current"), l = useCallback((f, C) => {
44168
+ if (!f)
44169
+ return;
44170
+ const b = f.style.transform || "", y = `${b.replace(/rotate\([^)]*\)/g, "").trim()} rotate(${(C % 360 + 360) % 360}deg)`.trim();
44171
+ b !== y && (a.current = !0, f.style.transform = y, f.style.transformOrigin = "center center", setTimeout(() => {
44172
+ a.current = !1;
44173
+ }, 0));
44174
+ }, []), c = useCallback(
44175
+ (f) => {
44176
+ f.preventDefault();
44177
+ const C = t[e];
44178
+ saveAs(C.url, `${C.title}${C.extname}`);
44160
44179
  },
44161
44180
  [e, t]
44162
- ), i = useCallback(() => {
44163
- r((m) => (m - 90) % 360);
44164
- }, []), l = useCallback(() => {
44165
- r((m) => (m + 90) % 360);
44181
+ ), u = useCallback(() => {
44182
+ r((f) => (f - 90) % 360);
44183
+ }, []), d = useCallback(() => {
44184
+ r((f) => (f + 90) % 360);
44166
44185
  }, []);
44167
44186
  return useEffect(() => {
44168
- const m = document.querySelector(".ril-image-current");
44169
- if (!m)
44187
+ l(i(), o);
44188
+ }, [o, l]), useEffect(() => {
44189
+ const f = i();
44190
+ if (!f)
44170
44191
  return;
44171
- let { transform: h } = m.style || {};
44172
- const g = `rotate(${o}deg)`;
44173
- (h == null ? void 0 : h.match(/rotate\(-?(\d+)deg\)/)) ? h = h.replace(/rotate\(-?(\d+)deg\)/, g) : h = `${h} ${g}`, m.style.transform = h;
44174
- }, [o]), /* @__PURE__ */ jsxs(Fragment$1, { children: [
44192
+ l(f, o);
44193
+ const C = new MutationObserver((b) => {
44194
+ a.current || b.some((S) => S.attributeName === "style") && l(f, o);
44195
+ });
44196
+ return C.observe(f, { attributes: !0, attributeFilter: ["style"] }), () => C.disconnect();
44197
+ }, [l, o, e]), /* @__PURE__ */ jsxs(Fragment$1, { children: [
44175
44198
  /* @__PURE__ */ jsx(LightBoxGlobalStyle, {}),
44176
44199
  /* @__PURE__ */ jsx(
44177
44200
  LightBox,
44178
44201
  {
44179
- mainSrc: (c = t[e]) == null ? void 0 : c.url,
44180
- nextSrc: (u = t[(e + 1) % t.length]) == null ? void 0 : u.url,
44181
- prevSrc: (d = t[(e + t.length - 1) % t.length]) == null ? void 0 : d.url,
44202
+ mainSrc: (p = t[e]) == null ? void 0 : p.url,
44203
+ nextSrc: (m = t[(e + 1) % t.length]) == null ? void 0 : m.url,
44204
+ prevSrc: (h = t[(e + t.length - 1) % t.length]) == null ? void 0 : h.url,
44182
44205
  onCloseRequest: () => n(null),
44183
- onMovePrevRequest: () => n((e + t.length - 1) % t.length),
44184
- onMoveNextRequest: () => n((e + 1) % t.length),
44185
- imageTitle: (p = t[e]) == null ? void 0 : p.title,
44206
+ onMovePrevRequest: () => {
44207
+ r(0), n((e + t.length - 1) % t.length);
44208
+ },
44209
+ onMoveNextRequest: () => {
44210
+ r(0), n((e + 1) % t.length);
44211
+ },
44212
+ onAfterOpen: () => {
44213
+ l(i(), o);
44214
+ },
44215
+ imageTitle: (g = t[e]) == null ? void 0 : g.title,
44186
44216
  toolbarButtons: [
44187
44217
  /* @__PURE__ */ jsx(
44188
44218
  "button",
@@ -44192,7 +44222,7 @@ attachmentFileTypes.add({
44192
44222
  title: "Download",
44193
44223
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44194
44224
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44195
- onClick: a,
44225
+ onClick: c,
44196
44226
  children: /* @__PURE__ */ jsx(DownloadOutlined, {})
44197
44227
  },
44198
44228
  "preview-img"
@@ -44203,7 +44233,7 @@ attachmentFileTypes.add({
44203
44233
  type: "button",
44204
44234
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44205
44235
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44206
- onClick: i,
44236
+ onClick: u,
44207
44237
  children: /* @__PURE__ */ jsx(UndoOutlined, {})
44208
44238
  },
44209
44239
  "rotate-left"
@@ -44214,7 +44244,7 @@ attachmentFileTypes.add({
44214
44244
  type: "button",
44215
44245
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44216
44246
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44217
- onClick: l,
44247
+ onClick: d,
44218
44248
  children: /* @__PURE__ */ jsx(RedoOutlined, {})
44219
44249
  },
44220
44250
  "rotate-right"
@@ -45933,7 +45963,7 @@ const AssignedFieldInner = (e) => {
45933
45963
  targetFieldSchema: l
45934
45964
  }
45935
45965
  ) });
45936
- }, AssignedField = (e) => (useFormBlockContext(), useBlockContext(), /* @__PURE__ */ jsx(AssignedFieldInner, x({}, e)));
45966
+ }, AssignedField = withDynamicSchemaProps(AssignedFieldInner);
45937
45967
  function useAclCheck(e) {
45938
45968
  return useAclCheckFn()(e);
45939
45969
  }
@@ -87,4 +87,4 @@ export declare function toValueItem(data: any): any;
87
87
  export declare const toItem: (file: any) => any;
88
88
  export declare const toFileList: (fileList: any) => any[];
89
89
  export declare function validate(file: any, rules: Record<string, any>): string;
90
- export declare function useBeforeUpload(rules: any): (file: any) => boolean;
90
+ export declare function useBeforeUpload(rules: any): (file: any, fileList: any) => false | Promise<any>;
@@ -17,5 +17,5 @@ export declare enum AssignedFieldValueType {
17
17
  DynamicValue = "dynamicValue"
18
18
  }
19
19
  export declare const AssignedFieldInner: (props: AssignedFieldProps) => React.JSX.Element;
20
- export declare const AssignedField: (props: any) => React.JSX.Element;
20
+ export declare const AssignedField: React.FunctionComponent<AssignedFieldProps>;
21
21
  export {};