@nocobase/client 1.9.0-beta.11 → 1.9.0-beta.13

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.11", 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-beta.13", 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.11", 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.11",
8875
- "@nocobase/sdk": "1.9.0-beta.11",
8876
- "@nocobase/utils": "1.9.0-beta.11",
8874
+ "@nocobase/evaluators": "1.9.0-beta.13",
8875
+ "@nocobase/sdk": "1.9.0-beta.13",
8876
+ "@nocobase/utils": "1.9.0-beta.13",
8877
8877
  ahooks: "^3.7.2",
8878
8878
  antd: "5.24.2",
8879
8879
  "antd-style": "3.7.1",
@@ -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,
@@ -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);
@@ -43189,7 +43189,7 @@ const className1 = css`
43189
43189
  onClick: () => q(void 0, null, function* () {
43190
43190
  const I = yield FormDialog(
43191
43191
  o("Add tab"),
43192
- () => /* @__PURE__ */ jsx(SchemaComponentOptions, { scope: p.scope, components: x({}, p.components), children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
43192
+ () => /* @__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
43193
  SchemaComponent,
43194
43194
  {
43195
43195
  schema: {
@@ -43208,7 +43208,7 @@ const className1 = css`
43208
43208
  }
43209
43209
  }
43210
43210
  }
43211
- ) }) }),
43211
+ ) }) }) }),
43212
43212
  m
43213
43213
  ).open({
43214
43214
  initialValues: {}
@@ -44034,9 +44034,18 @@ function validate(e, t) {
44034
44034
  function useBeforeUpload(e) {
44035
44035
  const { t } = useTranslation();
44036
44036
  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;
44037
+ (n, o) => {
44038
+ var i, l;
44039
+ let r = n;
44040
+ if (!n.type) {
44041
+ const c = (l = (i = n.name) == null ? void 0 : i.match(/\.[^.]+$/)) == null ? void 0 : l[0];
44042
+ c && (r = new File([n], n.name, {
44043
+ type: mime.getType(c) || "application/octet-stream",
44044
+ lastModified: n.lastModified
44045
+ }));
44046
+ }
44047
+ const a = validate(r, e);
44048
+ return a ? (r.status = "error", r.response = t(a)) : r.status === "error" && (delete r.status, delete r.response), a ? !1 : r;
44040
44049
  },
44041
44050
  [e]
44042
44051
  );
@@ -44151,38 +44160,56 @@ attachmentFileTypes.add({
44151
44160
  return e.preview ? e.preview : e.url ? e.url : e.originFileObj ? URL.createObjectURL(e.originFileObj) : null;
44152
44161
  },
44153
44162
  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}`);
44163
+ var p, m, h, g;
44164
+ const [o, r] = useState(0), a = useRef(!1), i = () => document.querySelector(".ril-image-current"), l = useCallback((f, C) => {
44165
+ if (!f)
44166
+ return;
44167
+ const b = f.style.transform || "", y = `${b.replace(/rotate\([^)]*\)/g, "").trim()} rotate(${(C % 360 + 360) % 360}deg)`.trim();
44168
+ b !== y && (a.current = !0, f.style.transform = y, f.style.transformOrigin = "center center", setTimeout(() => {
44169
+ a.current = !1;
44170
+ }, 0));
44171
+ }, []), c = useCallback(
44172
+ (f) => {
44173
+ f.preventDefault();
44174
+ const C = t[e];
44175
+ saveAs(C.url, `${C.title}${C.extname}`);
44160
44176
  },
44161
44177
  [e, t]
44162
- ), i = useCallback(() => {
44163
- r((m) => (m - 90) % 360);
44164
- }, []), l = useCallback(() => {
44165
- r((m) => (m + 90) % 360);
44178
+ ), u = useCallback(() => {
44179
+ r((f) => (f - 90) % 360);
44180
+ }, []), d = useCallback(() => {
44181
+ r((f) => (f + 90) % 360);
44166
44182
  }, []);
44167
44183
  return useEffect(() => {
44168
- const m = document.querySelector(".ril-image-current");
44169
- if (!m)
44184
+ l(i(), o);
44185
+ }, [o, l]), useEffect(() => {
44186
+ const f = i();
44187
+ if (!f)
44170
44188
  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: [
44189
+ l(f, o);
44190
+ const C = new MutationObserver((b) => {
44191
+ a.current || b.some((S) => S.attributeName === "style") && l(f, o);
44192
+ });
44193
+ return C.observe(f, { attributes: !0, attributeFilter: ["style"] }), () => C.disconnect();
44194
+ }, [l, o, e]), /* @__PURE__ */ jsxs(Fragment$1, { children: [
44175
44195
  /* @__PURE__ */ jsx(LightBoxGlobalStyle, {}),
44176
44196
  /* @__PURE__ */ jsx(
44177
44197
  LightBox,
44178
44198
  {
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,
44199
+ mainSrc: (p = t[e]) == null ? void 0 : p.url,
44200
+ nextSrc: (m = t[(e + 1) % t.length]) == null ? void 0 : m.url,
44201
+ prevSrc: (h = t[(e + t.length - 1) % t.length]) == null ? void 0 : h.url,
44182
44202
  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,
44203
+ onMovePrevRequest: () => {
44204
+ r(0), n((e + t.length - 1) % t.length);
44205
+ },
44206
+ onMoveNextRequest: () => {
44207
+ r(0), n((e + 1) % t.length);
44208
+ },
44209
+ onAfterOpen: () => {
44210
+ l(i(), o);
44211
+ },
44212
+ imageTitle: (g = t[e]) == null ? void 0 : g.title,
44186
44213
  toolbarButtons: [
44187
44214
  /* @__PURE__ */ jsx(
44188
44215
  "button",
@@ -44192,7 +44219,7 @@ attachmentFileTypes.add({
44192
44219
  title: "Download",
44193
44220
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44194
44221
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44195
- onClick: a,
44222
+ onClick: c,
44196
44223
  children: /* @__PURE__ */ jsx(DownloadOutlined, {})
44197
44224
  },
44198
44225
  "preview-img"
@@ -44203,7 +44230,7 @@ attachmentFileTypes.add({
44203
44230
  type: "button",
44204
44231
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44205
44232
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44206
- onClick: i,
44233
+ onClick: u,
44207
44234
  children: /* @__PURE__ */ jsx(UndoOutlined, {})
44208
44235
  },
44209
44236
  "rotate-left"
@@ -44214,7 +44241,7 @@ attachmentFileTypes.add({
44214
44241
  type: "button",
44215
44242
  className: "ril-zoom-in ril__toolbarItemChild ril__builtinButton",
44216
44243
  style: { fontSize: 22, background: "none", lineHeight: 1 },
44217
- onClick: l,
44244
+ onClick: d,
44218
44245
  children: /* @__PURE__ */ jsx(RedoOutlined, {})
44219
44246
  },
44220
44247
  "rotate-right"
@@ -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) => any;