@nocobase/client 1.0.1-alpha.3 → 1.2.0-alpha

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.d.ts CHANGED
@@ -54,6 +54,7 @@ export * from './testUtils';
54
54
  export * from './user';
55
55
  export * from './variables';
56
56
  export { withDynamicSchemaProps } from './hoc/withDynamicSchemaProps';
57
+ export { SchemaSettingsActionLinkItem } from './modules/actions/link/customizeLinkActionSettings';
57
58
  export * from './modules/blocks/BlockSchemaToolbar';
58
59
  export * from './modules/blocks/data-blocks/form';
59
60
  export * from './modules/blocks/data-blocks/table';
package/es/index.mjs CHANGED
@@ -1938,6 +1938,9 @@ const bp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1938
1938
  get SchemaSettings() {
1939
1939
  return SchemaSettings;
1940
1940
  },
1941
+ get SchemaSettingsActionLinkItem() {
1942
+ return SchemaSettingsActionLinkItem;
1943
+ },
1941
1944
  get SchemaSettingsActionModalItem() {
1942
1945
  return SchemaSettingsActionModalItem;
1943
1946
  },
@@ -3899,7 +3902,7 @@ function addAppVersion(e, t) {
3899
3902
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
3900
3903
  }), e;
3901
3904
  }
3902
- const name = "@nocobase/client", version$1 = "1.0.1-alpha.3", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
3905
+ const name = "@nocobase/client", version$1 = "1.2.0-alpha", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
3903
3906
  "@ahooksjs/use-url-state": "3.5.1",
3904
3907
  "@ant-design/cssinjs": "^1.11.1",
3905
3908
  "@ant-design/icons": "^5.1.4",
@@ -3920,9 +3923,9 @@ const name = "@nocobase/client", version$1 = "1.0.1-alpha.3", license = "AGPL-3.
3920
3923
  "@formily/reactive-react": "^2.2.27",
3921
3924
  "@formily/shared": "^2.2.27",
3922
3925
  "@formily/validator": "^2.2.27",
3923
- "@nocobase/evaluators": "1.0.1-alpha.3",
3924
- "@nocobase/sdk": "1.0.1-alpha.3",
3925
- "@nocobase/utils": "1.0.1-alpha.3",
3926
+ "@nocobase/evaluators": "1.2.0-alpha",
3927
+ "@nocobase/sdk": "1.2.0-alpha",
3928
+ "@nocobase/utils": "1.2.0-alpha",
3926
3929
  ahooks: "^3.7.2",
3927
3930
  antd: "^5.12.8",
3928
3931
  "antd-style": "3.4.5",
@@ -17992,7 +17995,7 @@ const DynamicComponent$1 = (e) => {
17992
17995
  });
17993
17996
  },
17994
17997
  [r, i, n]
17995
- ), C = useMemo(() => ({ minWidth: 460, marginRight: 15 }), []), S = useMemo(() => p(d, {
17998
+ ), C = useMemo(() => ({ minWidth: 460 }), []), S = useMemo(() => p(d, {
17996
17999
  value: t == null ? void 0 : t.value
17997
18000
  }), [p, t == null ? void 0 : t.value, d]), b = {
17998
18001
  // 常量
@@ -18030,7 +18033,7 @@ const DynamicComponent$1 = (e) => {
18030
18033
  value: i,
18031
18034
  style: { width: 150 },
18032
18035
  onChange: (y) => {
18033
- console.log(y), a(y), n({
18036
+ a(y), n({
18034
18037
  mode: y
18035
18038
  });
18036
18039
  },
@@ -20615,7 +20618,7 @@ const createSubmitActionSettings = new SchemaSettings({
20615
20618
  e.data = e.data || {}, e.display = "visible", e.disabled = !1, e.data.hidden = !1, e.componentProps.disabled = !1;
20616
20619
  }, MenuGroup = (e) => e.children;
20617
20620
  function ButtonEditor$1(e) {
20618
- var a, l, c;
20621
+ var a, l, c, u;
20619
20622
  const t = useField(), o = useFieldSchema(), { dn: n } = useDesignable(), { t: r } = useTranslation(), i = (e == null ? void 0 : e.isLink) || o["x-component"] === "Action.Link";
20620
20623
  return /* @__PURE__ */ jsx(
20621
20624
  SchemaSettingsModalItem,
@@ -20642,25 +20645,33 @@ function ButtonEditor$1(e) {
20642
20645
  "x-visible": !i
20643
20646
  // description: `原字段标题:${collectionField?.uiSchema?.title}`,
20644
20647
  },
20648
+ iconColor: {
20649
+ title: r("Color"),
20650
+ required: !0,
20651
+ default: ((l = o == null ? void 0 : o["x-component-props"]) == null ? void 0 : l.iconColor) || "#1677FF",
20652
+ "x-hidden": !e.hasIconColor,
20653
+ "x-component": "ColorPicker",
20654
+ "x-decorator": "FormItem"
20655
+ },
20645
20656
  type: {
20646
20657
  "x-decorator": "FormItem",
20647
20658
  "x-component": "Radio.Group",
20648
20659
  title: r("Button background color"),
20649
- default: (l = o == null ? void 0 : o["x-component-props"]) != null && l.danger ? "danger" : ((c = o == null ? void 0 : o["x-component-props"]) == null ? void 0 : c.type) === "primary" ? "primary" : "default",
20660
+ default: (c = o == null ? void 0 : o["x-component-props"]) != null && c.danger ? "danger" : ((u = o == null ? void 0 : o["x-component-props"]) == null ? void 0 : u.type) === "primary" ? "primary" : "default",
20650
20661
  enum: [
20651
20662
  { value: "default", label: '{{t("Default")}}' },
20652
20663
  { value: "primary", label: '{{t("Highlight")}}' },
20653
20664
  { value: "danger", label: '{{t("Danger red")}}' }
20654
20665
  ],
20655
- "x-visible": !i
20666
+ "x-visible": !e.hasIconColor && !i
20656
20667
  }
20657
20668
  }
20658
20669
  },
20659
- onSubmit: ({ title: u, icon: d, type: p }) => {
20660
- o.title = u, t.title = u, t.componentProps.icon = d, t.componentProps.danger = p === "danger", t.componentProps.type = p || t.componentProps.type, o["x-component-props"] = o["x-component-props"] || {}, o["x-component-props"].icon = d, o["x-component-props"].danger = p === "danger", o["x-component-props"].type = p || t.componentProps.type, n.emit("patch", {
20670
+ onSubmit: ({ title: d, icon: p, type: m, iconColor: h }) => {
20671
+ o.title = d, t.title = d, t.componentProps.iconColor = h, t.componentProps.icon = p, t.componentProps.danger = m === "danger", t.componentProps.type = m || t.componentProps.type, o["x-component-props"] = o["x-component-props"] || {}, o["x-component-props"].iconColor = h, o["x-component-props"].icon = p, o["x-component-props"].danger = m === "danger", o["x-component-props"].type = m || t.componentProps.type, n.emit("patch", {
20661
20672
  schema: {
20662
20673
  "x-uid": o["x-uid"],
20663
- title: u,
20674
+ title: d,
20664
20675
  "x-component-props": g({}, o["x-component-props"])
20665
20676
  }
20666
20677
  }), n.refresh();
@@ -22053,13 +22064,13 @@ const useGetFilterOptions = () => {
22053
22064
  }), d;
22054
22065
  };
22055
22066
  return a(e, 1);
22056
- }, isEmpty = (e) => Array.isArray(e) && e.length === 0 || e && Object.keys(e).length === 0 && Object.getPrototypeOf(e) === Object.prototype, removeNullCondition = (e) => {
22057
- const t = flat(e || {}), o = {};
22058
- for (const n in t) {
22059
- const r = t[n];
22060
- r != null && !isEmpty(r) && (o[n] = r);
22067
+ }, isEmpty = (e) => Array.isArray(e) && e.length === 0 || e && Object.keys(e).length === 0 && Object.getPrototypeOf(e) === Object.prototype, removeNullCondition = (e, t = flat) => {
22068
+ const o = t(e || {}), n = {};
22069
+ for (const r in o) {
22070
+ const i = o[r];
22071
+ i != null && !isEmpty(i) && (n[r] = i);
22061
22072
  }
22062
- return flat.unflatten(o);
22073
+ return t.unflatten(n);
22063
22074
  }, useFilterActionProps$1 = () => {
22064
22075
  const { name: e } = useCollection_deprecated(), t = useFilterOptions(e), { service: o, props: n } = useBlockRequestContext();
22065
22076
  return useFilterFieldProps({ options: t, service: o, params: n == null ? void 0 : n.params });
@@ -23483,45 +23494,47 @@ const useCreateActionProps = () => {
23483
23494
  e = e.parent;
23484
23495
  }
23485
23496
  }, useDoFilter = () => {
23486
- const e = useForm(), { getDataBlocks: t } = useFilterBlock(), { getCollectionJoinField: o } = useCollectionManager_deprecated(), { getOperators: n } = useOperators(), r = useFieldSchema(), { name: i } = useCollection(), { targets: a = [], uid: l } = useMemo(() => findFilterTargets(r), [r]), c = useCallback(
23487
- (...d) => V(void 0, [...d], function* ({ doNothingWhenFilterIsEmpty: u = !1 } = {}) {
23497
+ const e = useForm(), { getDataBlocks: t } = useFilterBlock(), { getCollectionJoinField: o } = useCollectionManager_deprecated(), { getOperators: n } = useOperators(), r = useFieldSchema(), { name: i } = useCollection(), { targets: a = [], uid: l } = useMemo(() => findFilterTargets(r), [r]), c = useCallback(() => removeNullCondition(transformToFilter(e.values, n(), o, i)), [e.values, o, n, i]), u = useCallback(
23498
+ (...p) => V(void 0, [...p], function* ({ doNothingWhenFilterIsEmpty: d = !1 } = {}) {
23488
23499
  try {
23489
23500
  yield Promise.all(
23490
- t().map((p) => V(void 0, null, function* () {
23491
- var C, S, b;
23492
- if (!a.find((y) => y.uid === p.uid))
23501
+ t().map((m) => V(void 0, null, function* () {
23502
+ var S, b, y;
23503
+ if (!a.find((v) => v.uid === m.uid))
23493
23504
  return;
23494
- const h = ((C = p.service.params) == null ? void 0 : C[0]) || {}, x = ((b = (S = p.service.params) == null ? void 0 : S[1]) == null ? void 0 : b.filters) || {};
23495
- x[l] = removeNullCondition(
23496
- transformToFilter(e.values, n(), o, i)
23497
- );
23498
- const f = mergeFilter([
23499
- ...Object.values(x).map((y) => removeNullCondition(y)),
23500
- p.defaultFilter
23505
+ const x = ((S = m.service.params) == null ? void 0 : S[0]) || {}, f = ((y = (b = m.service.params) == null ? void 0 : b[1]) == null ? void 0 : y.filters) || {};
23506
+ f[l] = c();
23507
+ const C = mergeFilter([
23508
+ ...Object.values(f).map((v) => removeNullCondition(v)),
23509
+ m.defaultFilter
23501
23510
  ]);
23502
- if (!(u && _.isEmpty(f)))
23503
- return p.dataLoadingMode === "manual" && _.isEmpty(f) ? p.clearData() : p.doFilter(
23504
- F(g({}, h), {
23511
+ if (!(d && _.isEmpty(f[l])))
23512
+ return m.dataLoadingMode === "manual" && _.isEmpty(f[l]) ? m.clearData() : m.doFilter(
23513
+ F(g({}, x), {
23505
23514
  page: 1,
23506
- filter: f
23515
+ filter: C
23507
23516
  }),
23508
- { filters: x }
23517
+ { filters: f }
23509
23518
  );
23510
23519
  }))
23511
23520
  );
23512
- } catch (p) {
23513
- console.error(p);
23521
+ } catch (m) {
23522
+ console.error(m);
23514
23523
  }
23515
23524
  }),
23516
- [e.values, o, t, n, i, a, l]
23525
+ [t, c, a, l]
23517
23526
  );
23518
23527
  return useEffect(() => {
23519
- c({ doNothingWhenFilterIsEmpty: !0 });
23528
+ u({ doNothingWhenFilterIsEmpty: !0 });
23520
23529
  }, [t().length]), {
23521
23530
  /**
23522
23531
  * 用于执行筛选表单的筛选操作
23523
23532
  */
23524
- doFilter: c
23533
+ doFilter: u,
23534
+ /**
23535
+ * 根据当前表单的值获取 filter
23536
+ */
23537
+ getFilterFromCurrentForm: c
23525
23538
  };
23526
23539
  }, useFilterBlockActionProps = () => {
23527
23540
  const { doFilter: e } = useDoFilter(), t = useField();
@@ -23532,36 +23545,21 @@ const useCreateActionProps = () => {
23532
23545
  });
23533
23546
  }
23534
23547
  };
23548
+ }, useDoReset = () => {
23549
+ const e = useForm(), t = useFieldSchema(), { getDataBlocks: o } = useFilterBlock(), { targets: n, uid: r } = findFilterTargets(t), { doFilter: i, getFilterFromCurrentForm: a } = useDoFilter();
23550
+ return {
23551
+ doReset: () => V(void 0, null, function* () {
23552
+ if (yield e.reset(), _.isEmpty(a()))
23553
+ return doReset({ getDataBlocks: o, targets: n, uid: r });
23554
+ yield i();
23555
+ })
23556
+ };
23535
23557
  }, useResetBlockActionProps = () => {
23536
- const e = useForm(), t = useField(), o = useFieldSchema(), { getDataBlocks: n } = useFilterBlock();
23537
- return t.data = t.data || {}, {
23558
+ const e = useField(), { doReset: t } = useDoReset();
23559
+ return e.data = e.data || {}, {
23538
23560
  onClick() {
23539
23561
  return V(this, null, function* () {
23540
- const { targets: i, uid: a } = findFilterTargets(o);
23541
- e.reset(), t.data.loading = !0;
23542
- try {
23543
- yield Promise.all(
23544
- n().map((l) => V(this, null, function* () {
23545
- var m, h, x;
23546
- if (!i.find((f) => f.uid === l.uid))
23547
- return;
23548
- if (l.dataLoadingMode === "manual")
23549
- return l.clearData();
23550
- const u = ((m = l.service.params) == null ? void 0 : m[0]) || {}, d = ((x = (h = l.service.params) == null ? void 0 : h[1]) == null ? void 0 : x.filters) || {};
23551
- delete d[a];
23552
- const p = mergeFilter([...Object.values(d), l.defaultFilter]);
23553
- return l.doFilter(
23554
- F(g({}, u), {
23555
- page: 1,
23556
- filter: p
23557
- }),
23558
- { filters: d }
23559
- );
23560
- }))
23561
- ), t.data.loading = !1;
23562
- } catch (l) {
23563
- t.data.loading = !1;
23564
- }
23562
+ e.data.loading = !0, yield t(), e.data.loading = !1;
23565
23563
  });
23566
23564
  }
23567
23565
  };
@@ -24008,6 +24006,37 @@ const useCreateActionProps = () => {
24008
24006
  labelKey: f
24009
24007
  };
24010
24008
  };
24009
+ function doReset(n) {
24010
+ return V(this, arguments, function* ({
24011
+ getDataBlocks: e,
24012
+ targets: t,
24013
+ uid: o
24014
+ }) {
24015
+ try {
24016
+ yield Promise.all(
24017
+ e().map((r) => V(this, null, function* () {
24018
+ var u, d, p;
24019
+ if (!t.find((m) => m.uid === r.uid))
24020
+ return;
24021
+ if (r.dataLoadingMode === "manual")
24022
+ return r.clearData();
24023
+ const a = ((u = r.service.params) == null ? void 0 : u[0]) || {}, l = ((p = (d = r.service.params) == null ? void 0 : d[1]) == null ? void 0 : p.filters) || {};
24024
+ delete l[o];
24025
+ const c = mergeFilter([...Object.values(l), r.defaultFilter]);
24026
+ return r.doFilter(
24027
+ F(g({}, a), {
24028
+ page: 1,
24029
+ filter: c
24030
+ }),
24031
+ { filters: l }
24032
+ );
24033
+ }))
24034
+ );
24035
+ } catch (r) {
24036
+ console.error(r);
24037
+ }
24038
+ });
24039
+ }
24011
24040
  function getAssociationPath(e) {
24012
24041
  const t = e.lastIndexOf(".");
24013
24042
  return t !== -1 ? e.substring(0, t) : e;
@@ -33550,7 +33579,7 @@ const useTableColumns$1 = (e) => {
33550
33579
  const { setVisible: y } = useActionContext(), { selectedRows: v, setSelectedRows: I } = useContext(RecordPickerContext);
33551
33580
  return {
33552
33581
  onClick() {
33553
- v.map((A) => o.value.push(markRecordAsNew(g({}, A)))), o.onInput(o.value), I([]), y(!1);
33582
+ v.map((A) => o.value.push(A)), o.onInput(o.value), I([]), y(!1);
33554
33583
  }
33555
33584
  };
33556
33585
  }, b = () => {
@@ -56738,6 +56767,7 @@ export {
56738
56767
  SchemaSettingItemContext,
56739
56768
  SchemaSettingOpenModeSchemaItems,
56740
56769
  SchemaSettings,
56770
+ SchemaSettingsActionLinkItem,
56741
56771
  SchemaSettingsActionModalItem,
56742
56772
  SchemaSettingsBlockHeightItem,
56743
56773
  SchemaSettingsBlockTitleItem,
@@ -10,7 +10,7 @@ export declare const useGetFilterOptions: () => (collectionName: any, dataSource
10
10
  export declare const useFilterOptions: (collectionName: string) => any[];
11
11
  export declare const useGetFilterFieldOptions: () => (fields: any) => any[];
12
12
  export declare const useFilterFieldOptions: (fields: any) => any[];
13
- export declare const removeNullCondition: (filter: any) => any;
13
+ export declare const removeNullCondition: (filter: any, customFlat?: any) => any;
14
14
  export declare const useFilterActionProps: () => {
15
15
  options: any;
16
16
  onSubmit(values: any): any;