@nocobase/client 1.2.10-alpha → 1.2.12-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.
@@ -113,6 +113,7 @@ export declare class Collection {
113
113
  get isThrough(): boolean;
114
114
  get autoCreate(): boolean;
115
115
  get resource(): string;
116
+ setOption(key: string, value: any): this;
116
117
  getOptions(): CollectionOptions;
117
118
  getOption<K extends keyof CollectionOptions>(key: K): CollectionOptions[K];
118
119
  /**
package/es/index.mjs CHANGED
@@ -3801,6 +3801,9 @@ class Collection {
3801
3801
  get resource() {
3802
3802
  return this.options.resource;
3803
3803
  }
3804
+ setOption(t, o) {
3805
+ return this.options[t] = o, this;
3806
+ }
3804
3807
  getOptions() {
3805
3808
  return this.options;
3806
3809
  }
@@ -3926,7 +3929,7 @@ function addAppVersion(e, t) {
3926
3929
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
3927
3930
  }), e;
3928
3931
  }
3929
- const name = "@nocobase/client", version$1 = "1.2.10-alpha", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
3932
+ const name = "@nocobase/client", version$1 = "1.2.12-alpha", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
3930
3933
  "@ahooksjs/use-url-state": "3.5.1",
3931
3934
  "@ant-design/cssinjs": "^1.11.1",
3932
3935
  "@ant-design/icons": "^5.1.4",
@@ -3947,9 +3950,9 @@ const name = "@nocobase/client", version$1 = "1.2.10-alpha", license = "AGPL-3.0
3947
3950
  "@formily/reactive-react": "^2.2.27",
3948
3951
  "@formily/shared": "^2.2.27",
3949
3952
  "@formily/validator": "^2.2.27",
3950
- "@nocobase/evaluators": "1.2.10-alpha",
3951
- "@nocobase/sdk": "1.2.10-alpha",
3952
- "@nocobase/utils": "1.2.10-alpha",
3953
+ "@nocobase/evaluators": "1.2.12-alpha",
3954
+ "@nocobase/sdk": "1.2.12-alpha",
3955
+ "@nocobase/utils": "1.2.12-alpha",
3953
3956
  ahooks: "^3.7.2",
3954
3957
  antd: "^5.12.8",
3955
3958
  "antd-style": "3.4.5",
@@ -10626,22 +10629,28 @@ function useServiceOptions$1(e) {
10626
10629
  const T = yield u(mergeFilter([F || ((D = o == null ? void 0 : o.params) == null ? void 0 : D.filter)]));
10627
10630
  m(T);
10628
10631
  }), k = _.debounce(I, DEBOUNCE_WAIT);
10629
- return I(), reaction(() => flatten(F, {
10630
- breakOn({ key: D }) {
10631
- return D.startsWith("$") && D !== "$and" && D !== "$or";
10632
- },
10633
- transformValue(D) {
10634
- if (!isVariable(D))
10635
- return D;
10636
- const $ = getVariableName(D), q = d($);
10637
- return getValuesByPath(
10638
- {
10639
- [$]: (q == null ? void 0 : q.ctx) || {}
10640
- },
10641
- getPath(D)
10642
- );
10632
+ return I(), reaction(
10633
+ () => flatten(F, {
10634
+ breakOn({ key: D }) {
10635
+ return D.startsWith("$") && D !== "$and" && D !== "$or";
10636
+ },
10637
+ transformValue(D) {
10638
+ if (!isVariable(D))
10639
+ return D;
10640
+ const $ = getVariableName(D), q = d($);
10641
+ return getValuesByPath(
10642
+ {
10643
+ [$]: (q == null ? void 0 : q.ctx) || {}
10644
+ },
10645
+ getPath(D)
10646
+ );
10647
+ }
10648
+ }),
10649
+ k,
10650
+ {
10651
+ equals: _.isEqual
10643
10652
  }
10644
- }), k);
10653
+ );
10645
10654
  }, [
10646
10655
  (b = (S = (C = i.componentProps) == null ? void 0 : C.service) == null ? void 0 : S.params) == null ? void 0 : b.filter,
10647
10656
  r,
@@ -10971,23 +10980,29 @@ function useParsedFilter({ filterOption: e }) {
10971
10980
  });
10972
10981
  l();
10973
10982
  const c = _.debounce(l, DEBOUNCE_WAIT);
10974
- reaction(() => flatten(e, {
10975
- breakOn({ key: d }) {
10976
- return d.startsWith("$") && d !== "$and" && d !== "$or";
10977
- },
10978
- transformValue(d) {
10979
- if (!isVariable(d))
10980
- return d;
10981
- const p = getVariableName(d), m = o(p);
10982
- return getValuesByPath(
10983
- {
10984
- [p]: (m == null ? void 0 : m.ctx) || {}
10985
- },
10986
- getPath(d)
10987
- );
10983
+ reaction(
10984
+ () => flatten(e, {
10985
+ breakOn({ key: d }) {
10986
+ return d.startsWith("$") && d !== "$and" && d !== "$or";
10987
+ },
10988
+ transformValue(d) {
10989
+ if (!isVariable(d))
10990
+ return d;
10991
+ const p = getVariableName(d), m = o(p);
10992
+ return getValuesByPath(
10993
+ {
10994
+ [p]: (m == null ? void 0 : m.ctx) || {}
10995
+ },
10996
+ getPath(d)
10997
+ );
10998
+ }
10999
+ }),
11000
+ c,
11001
+ {
11002
+ equals: _.isEqual
10988
11003
  }
10989
- }), c);
10990
- }, [JSON.stringify(e), i]), {
11004
+ );
11005
+ }, [JSON.stringify(e)]), {
10991
11006
  /** 数据范围的筛选参数 */
10992
11007
  filter: n,
10993
11008
  /** 表示是否正在解析筛选参数中的变量 */
@@ -11355,59 +11370,46 @@ const ColDivider = (e) => {
11355
11370
  InitializerComponent: l,
11356
11371
  showDivider: o
11357
11372
  }), [i, a, l, o]);
11358
- return /* @__PURE__ */ jsx(FilterBlockProvider, { children: /* @__PURE__ */ jsx(GridContext.Provider, { value: x, children: /* @__PURE__ */ jsx(
11359
- "div",
11360
- {
11361
- className: cls(
11362
- "nb-grid-container"
11363
- // css`
11364
- // & {
11365
- // margin-bottom: ${designable ? 0 : -token.marginLG}px;
11366
- // }
11367
- // `,
11368
- ),
11369
- children: /* @__PURE__ */ jsx("div", { className: cls(`nb-grid ${p.container}`), style: { position: "relative" }, ref: n, children: /* @__PURE__ */ jsxs("div", { className: "nb-grid-warp", children: [
11370
- /* @__PURE__ */ jsxs(DndWrapper, { dndContext: e.dndContext, children: [
11371
- o ? /* @__PURE__ */ jsx(
11372
- RowDivider,
11373
- {
11374
- rows: u,
11375
- first: !0,
11376
- id: `${c}_0`,
11377
- data: {
11378
- breakRemoveOn: breakRemoveOnGrid,
11379
- wrapSchema: wrapRowSchema,
11380
- insertAdjacent: "afterBegin",
11381
- schema: i
11382
- }
11373
+ return /* @__PURE__ */ jsx(FilterBlockProvider, { children: /* @__PURE__ */ jsx(GridContext.Provider, { value: x, children: /* @__PURE__ */ jsx("div", { className: cls("nb-grid-container"), children: /* @__PURE__ */ jsx("div", { className: cls(`nb-grid ${p.container}`), style: { position: "relative" }, ref: n, children: /* @__PURE__ */ jsxs("div", { className: "nb-grid-warp", children: [
11374
+ /* @__PURE__ */ jsxs(DndWrapper, { dndContext: e.dndContext, children: [
11375
+ o ? /* @__PURE__ */ jsx(
11376
+ RowDivider,
11377
+ {
11378
+ rows: u,
11379
+ first: !0,
11380
+ id: `${c}_0`,
11381
+ data: {
11382
+ breakRemoveOn: breakRemoveOnGrid,
11383
+ wrapSchema: wrapRowSchema,
11384
+ insertAdjacent: "afterBegin",
11385
+ schema: i
11386
+ }
11387
+ }
11388
+ ) : null,
11389
+ u.map((f, C) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
11390
+ h ? /* @__PURE__ */ jsx(SchemaComponent, { name: f.name, schema: f, distributed: !0 }) : /* @__PURE__ */ jsx(MemorizedRecursionField, { name: f.name, schema: f }),
11391
+ o ? /* @__PURE__ */ jsx(
11392
+ RowDivider,
11393
+ {
11394
+ rows: u,
11395
+ index: C,
11396
+ id: `${c}_${C + 1}`,
11397
+ data: {
11398
+ breakRemoveOn: breakRemoveOnGrid,
11399
+ wrapSchema: wrapRowSchema,
11400
+ insertAdjacent: "afterEnd",
11401
+ schema: f
11383
11402
  }
11384
- ) : null,
11385
- u.map((f, C) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
11386
- h ? /* @__PURE__ */ jsx(SchemaComponent, { name: f.name, schema: f, distributed: !0 }) : /* @__PURE__ */ jsx(MemorizedRecursionField, { name: f.name, schema: f }),
11387
- o ? /* @__PURE__ */ jsx(
11388
- RowDivider,
11389
- {
11390
- rows: u,
11391
- index: C,
11392
- id: `${c}_${C + 1}`,
11393
- data: {
11394
- breakRemoveOn: breakRemoveOnGrid,
11395
- wrapSchema: wrapRowSchema,
11396
- insertAdjacent: "afterEnd",
11397
- schema: f
11398
- }
11399
- }
11400
- ) : null
11401
- ] }, C))
11402
- ] }),
11403
- a({
11404
- style: {
11405
- marginBottom: m.marginLG
11406
11403
  }
11407
- })
11408
- ] }) })
11409
- }
11410
- ) }) });
11404
+ ) : null
11405
+ ] }, C))
11406
+ ] }),
11407
+ a({
11408
+ style: {
11409
+ marginBottom: m.marginLG
11410
+ }
11411
+ })
11412
+ ] }) }) }) }) });
11411
11413
  },
11412
11414
  { displayName: "Grid" }
11413
11415
  );
@@ -13103,7 +13105,10 @@ const useParseDefaultValue = () => {
13103
13105
  const F = { [S]: (b == null ? void 0 : b.ctx) || {} }, I = getPath(t.default), k = getValuesByPath(F, I);
13104
13106
  return k === void 0 ? Math.random() : k;
13105
13107
  },
13106
- () => C({ forceUpdate: !0 })
13108
+ () => C({ forceUpdate: !0 }),
13109
+ {
13110
+ equals: _.isEqual
13111
+ }
13107
13112
  )) : console.error(`useParseDefaultValue: can not find variable ${S}`);
13108
13113
  } else
13109
13114
  e.value == null && (c || u) && e.setValue(t.default);
@@ -28862,22 +28867,22 @@ const useFieldComponentOptions = () => {
28862
28867
  if (!(!(i != null && i.heightMode) || l === HeightMode.DEFAULT))
28863
28868
  return l === HeightMode.FULL_HEIGHT ? window.innerHeight - a : c;
28864
28869
  }, useTableSize = () => {
28865
- const [e, t] = useState(), [o, n] = useState(), r = useRef(null), i = useTableHeight(), a = useCallback(
28870
+ const [e, t] = useState(), o = useRef(null), n = useTableHeight(), r = useCallback(
28866
28871
  debounce(() => {
28867
- var d;
28868
- if (!r.current)
28872
+ var c;
28873
+ if (!o.current)
28869
28874
  return;
28870
- const c = r.current.getBoundingClientRect();
28871
- (d = r.current.querySelector(".ant-table")) != null && d.getBoundingClientRect() && (n(c.width), t(i));
28875
+ const a = o.current.getBoundingClientRect();
28876
+ (c = o.current.querySelector(".ant-table")) != null && c.getBoundingClientRect() && t(a.width);
28872
28877
  }, 100),
28873
- [i]
28874
- ), l = useCallback(
28875
- (c) => {
28876
- r.current = c && c.children ? c.children[0] : null, a();
28878
+ [n]
28879
+ ), i = useCallback(
28880
+ (a) => {
28881
+ o.current = a && a.children ? a.children[0] : null, r();
28877
28882
  },
28878
- [a]
28883
+ [r]
28879
28884
  );
28880
- return useEventListener("resize", a), { height: e, width: o, tableSizeRefCallback: l };
28885
+ return useEventListener("resize", r), { height: n, width: e, tableSizeRefCallback: i };
28881
28886
  }, hasActionContainerInParentChain = (e) => e ? e["x-component"] === "Action.Container" ? !0 : hasActionContainerInParentChain(e.parent) : null, useFieldModeOptions = (e) => {
28882
28887
  var x;
28883
28888
  const { t } = useTranslation(), { getCollectionJoinField: o, getCollection: n } = useCollectionManager_deprecated(), r = useFieldSchema(), i = (e == null ? void 0 : e.fieldSchema) || r, a = useField(), l = useForm(), c = (i == null ? void 0 : i["x-read-pretty"]) || a.readPretty || l.readPretty, u = e == null ? void 0 : e.fieldSchema, { getField: d } = useCollection_deprecated(), p = (e == null ? void 0 : e.collectionField) || d(i.name) || o(i["x-collection-field"]), { label: m } = ((x = i["x-component-props"]) == null ? void 0 : x.fieldNames) || {};
@@ -29786,7 +29791,7 @@ const useFormBlockHeight = () => {
29786
29791
  return [A, w, M].map((E) => JSON.stringify(E)).join(",");
29787
29792
  },
29788
29793
  getSubscriber(x, S, m, r, i),
29789
- { fireImmediately: !0 }
29794
+ { fireImmediately: !0, equals: _.isEqual }
29790
29795
  )
29791
29796
  );
29792
29797
  });
@@ -32430,7 +32435,7 @@ const InternalNesterCss = css`
32430
32435
  const e = useField(), t = useFieldSchema(), o = useInsertSchema("Nester"), { options: n } = useAssociationFieldContext(), r = (l = (a = t["x-decorator-props"]) == null ? void 0 : a.showTitle) != null ? l : !0, { actionName: i } = useACLActionParamsContext();
32431
32436
  return useEffect(() => {
32432
32437
  o(schema$1.Nester);
32433
- }, []), /* @__PURE__ */ jsx(CollectionProvider_deprecated, { name: n.target, children: /* @__PURE__ */ jsx(ACLCollectionProvider, { actionPath: `${n.target}:${i}`, children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
32438
+ }, []), /* @__PURE__ */ jsx(CollectionProvider_deprecated, { name: n.target, children: /* @__PURE__ */ jsx(ACLCollectionProvider, { actionPath: `${n.target}:${i || "view"}`, children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
32434
32439
  "div",
32435
32440
  {
32436
32441
  className: cx(
@@ -35678,40 +35683,71 @@ const InternalGridCardBlockProvider = (e) => {
35678
35683
  GridCard.Item = GridCardItem;
35679
35684
  GridCard.Designer = GridCardDesigner;
35680
35685
  GridCard.Decorator = GridCardBlockProvider;
35686
+ const { Search } = Input$3, useStyle = (e) => createStyles(({ css: t }) => ({
35687
+ popoverContent: t`
35688
+ width: 26em;
35689
+ ${!e && "max-"}height: 20em;
35690
+ overflow-y: auto;
35691
+ `
35692
+ }))();
35681
35693
  function IconField(e) {
35682
- const t = useFormLayout(), { value: o, onChange: n, disabled: r } = e, [i, a] = useState(!1), { t: l } = useTranslation();
35694
+ const { fontSizeXL: t } = theme.useToken().token, o = [...icons.keys()], n = useFormLayout(), { value: r, onChange: i, disabled: a, iconSize: l = t, searchable: c = !0 } = e, [u, d] = useState(!1), [p, m] = useState(o), { t: h } = useTranslation(), { styles: x } = useStyle(c), f = debounce((C) => {
35695
+ var b;
35696
+ const S = (b = C == null ? void 0 : C.trim()) != null ? b : "";
35697
+ m(
35698
+ S.length ? o.filter((y) => y.split(" ").some((F) => F.includes(S))) : o
35699
+ );
35700
+ }, 250);
35683
35701
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Space$1.Compact, { children: [
35684
35702
  /* @__PURE__ */ jsx(
35685
35703
  StablePopover,
35686
35704
  {
35687
35705
  placement: "bottom",
35688
- open: i,
35689
- onOpenChange: (c) => {
35690
- r || a(c);
35706
+ open: u,
35707
+ onOpenChange: (C) => {
35708
+ a || d(C);
35691
35709
  },
35692
- content: /* @__PURE__ */ jsx("div", { style: { width: "26em", maxHeight: "20em", overflowY: "auto" }, children: [...icons.keys()].map((c) => /* @__PURE__ */ jsx(
35710
+ content: /* @__PURE__ */ jsx("div", { className: x.popoverContent, children: p.length === 0 ? /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }) : p.map((C) => /* @__PURE__ */ jsx(
35693
35711
  "span",
35694
35712
  {
35695
- style: { fontSize: 18, marginRight: 10, cursor: "pointer" },
35713
+ title: C.replace(/outlined|filled|twotone$/i, ""),
35714
+ style: { fontSize: l, marginRight: 10, cursor: "pointer" },
35696
35715
  onClick: () => {
35697
- n(c), a(!1);
35716
+ i(C), d(!1);
35698
35717
  },
35699
- children: /* @__PURE__ */ jsx(Icon, { type: c })
35718
+ children: /* @__PURE__ */ jsx(Icon, { type: C })
35700
35719
  },
35701
- c
35720
+ C
35702
35721
  )) }),
35703
- title: l("Icon"),
35722
+ title: /* @__PURE__ */ jsxs("div", { children: [
35723
+ /* @__PURE__ */ jsx("div", { children: h("Icon") }),
35724
+ c && /* @__PURE__ */ jsx(
35725
+ Search,
35726
+ {
35727
+ style: { marginTop: 8 },
35728
+ role: "search",
35729
+ name: "icon-search",
35730
+ placeholder: h("Search"),
35731
+ allowClear: !0,
35732
+ onSearch: f,
35733
+ onChange: (C) => {
35734
+ var S;
35735
+ return f((S = C.target) == null ? void 0 : S.value);
35736
+ }
35737
+ }
35738
+ )
35739
+ ] }),
35704
35740
  trigger: "click",
35705
- children: /* @__PURE__ */ jsx(Button, { size: t.size, disabled: r, children: hasIcon(o) ? /* @__PURE__ */ jsx(Icon, { type: o }) : l("Select icon") })
35741
+ children: /* @__PURE__ */ jsx(Button, { size: n.size, disabled: a, children: hasIcon(r) ? /* @__PURE__ */ jsx(Icon, { type: r }) : h("Select icon") })
35706
35742
  }
35707
35743
  ),
35708
- o && !r && /* @__PURE__ */ jsx(
35744
+ r && !a && /* @__PURE__ */ jsx(
35709
35745
  Button,
35710
35746
  {
35711
- size: t.size,
35747
+ size: n.size,
35712
35748
  icon: /* @__PURE__ */ jsx(CloseOutlined, {}),
35713
- onClick: (c) => {
35714
- n(null);
35749
+ onClick: (C) => {
35750
+ i(null);
35715
35751
  }
35716
35752
  }
35717
35753
  )
@@ -36119,19 +36155,18 @@ const InternalListBlockProvider = (e) => {
36119
36155
  d,
36120
36156
  p,
36121
36157
  css`
36122
- .ant-spin-nested-loading {
36158
+ .nb-list-container {
36123
36159
  height: ${m ? m + "px" : "100%"};
36124
- overflow-y: ${m ? "auto" : "null"};
36125
- .ant-spin-container {
36126
- width: 100%;
36127
- overflow-x: clip;
36128
- padding-right: ${h.paddingSM + "px"};
36129
- }
36160
+ overflow-y: ${m ? "auto" : null};
36161
+ margin-left: -${h.marginLG}px;
36162
+ margin-right: -${h.marginLG}px;
36163
+ padding-left: ${h.marginLG}px;
36164
+ padding-right: ${h.marginLG}px;
36130
36165
  }
36131
36166
  `
36132
36167
  ),
36133
36168
  children: [
36134
- /* @__PURE__ */ jsx(
36169
+ /* @__PURE__ */ jsx("div", { className: "nb-list-container", children: /* @__PURE__ */ jsx(
36135
36170
  List$1,
36136
36171
  v(g({}, e), {
36137
36172
  pagination: !a || a.count <= a.pageSize ? !1 : {
@@ -36152,7 +36187,7 @@ const InternalListBlockProvider = (e) => {
36152
36187
  y
36153
36188
  )) : null
36154
36189
  })
36155
- ),
36190
+ ) }),
36156
36191
  /* @__PURE__ */ jsx(i, {})
36157
36192
  ]
36158
36193
  }
@@ -48409,9 +48444,9 @@ class ViewCollectionTemplate extends CollectionTemplate {
48409
48444
  }
48410
48445
  },
48411
48446
  filterTargetKey: {
48412
- title: '{{ t("Filter target key")}}',
48447
+ title: '{{ t("Record unique key")}}',
48413
48448
  type: "single",
48414
- description: '{{t( "Filter data based on the specific field, with the requirement that the field value must be unique.")}}',
48449
+ description: '{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',
48415
48450
  "x-decorator": "FormItem",
48416
48451
  "x-component": "Select",
48417
48452
  "x-reactions": ["{{useAsyncDataSource(loadFilterTargetKeys)}}"]
@@ -48486,9 +48521,9 @@ class SqlCollectionTemplate extends CollectionTemplate {
48486
48521
  }
48487
48522
  }, getConfigurableProperties("category")), {
48488
48523
  filterTargetKey: {
48489
- title: '{{ t("Filter target key")}}',
48524
+ title: '{{ t("Record unique key")}}',
48490
48525
  type: "single",
48491
- description: '{{t( "Filter data based on the specific field, with the requirement that the field value must be unique.")}}',
48526
+ description: '{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',
48492
48527
  "x-decorator": "FormItem",
48493
48528
  "x-component": "Select",
48494
48529
  "x-reactions": ["{{useAsyncDataSource(loadFilterTargetKeys)}}"]
@@ -12,6 +12,8 @@ export interface IconPickerProps {
12
12
  onChange?: (value: string) => void;
13
13
  disabled?: boolean;
14
14
  suffix?: React.ReactNode;
15
+ iconSize?: number;
16
+ searchable?: boolean;
15
17
  }
16
18
  export declare const IconPicker: React.ForwardRefExoticComponent<Partial<IconPickerProps> & React.RefAttributes<unknown>>;
17
19
  export default IconPicker;