@nocobase/client 1.4.15 → 1.4.17

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
@@ -4295,7 +4295,7 @@ function addAppVersion(e, t) {
4295
4295
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
4296
4296
  }), e;
4297
4297
  }
4298
- const name = "@nocobase/client", version$1 = "1.4.15", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
4298
+ const name = "@nocobase/client", version$1 = "1.4.17", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
4299
4299
  "@ahooksjs/use-url-state": "3.5.1",
4300
4300
  "@ant-design/cssinjs": "^1.11.1",
4301
4301
  "@ant-design/icons": "^5.1.4",
@@ -4317,9 +4317,9 @@ const name = "@nocobase/client", version$1 = "1.4.15", license = "AGPL-3.0", mai
4317
4317
  "@formily/reactive-react": "^2.2.27",
4318
4318
  "@formily/shared": "^2.2.27",
4319
4319
  "@formily/validator": "^2.2.27",
4320
- "@nocobase/evaluators": "1.4.15",
4321
- "@nocobase/sdk": "1.4.15",
4322
- "@nocobase/utils": "1.4.15",
4320
+ "@nocobase/evaluators": "1.4.17",
4321
+ "@nocobase/sdk": "1.4.17",
4322
+ "@nocobase/utils": "1.4.17",
4323
4323
  ahooks: "^3.7.2",
4324
4324
  antd: "5.12.8",
4325
4325
  "antd-style": "3.7.1",
@@ -4349,7 +4349,7 @@ const name = "@nocobase/client", version$1 = "1.4.15", license = "AGPL-3.0", mai
4349
4349
  "react-i18next": "^11.15.1",
4350
4350
  "react-iframe": "~1.8.5",
4351
4351
  "react-image-lightbox": "^5.1.4",
4352
- "react-intersection-observer": "9.13.0",
4352
+ "react-intersection-observer": "9.14.0",
4353
4353
  "react-js-cron": "^3.1.0",
4354
4354
  "react-quill": "^2.0.0",
4355
4355
  "react-router-dom": "^6.11.2",
@@ -9529,8 +9529,8 @@ const SearchFields = ({ value: e, onChange: t, name: o }) => {
9529
9529
  }, [e]), useEffect(() => {
9530
9530
  var h;
9531
9531
  const p = () => {
9532
- var g, f, C;
9533
- ((g = document.activeElement) == null ? void 0 : g.id) !== a.current.input.id && getPrefixAndCompare((f = document.activeElement) == null ? void 0 : f.id, a.current.input.id) && ((C = a.current) == null || C.focus());
9532
+ var g, f;
9533
+ a.current && ((g = document.activeElement) == null ? void 0 : g.id) !== a.current.input.id && getPrefixAndCompare((f = document.activeElement) == null ? void 0 : f.id, a.current.input.id) && a.current.focus();
9534
9534
  }, m = new IntersectionObserver((g) => {
9535
9535
  g.some((f) => f.isIntersecting) && p();
9536
9536
  });
@@ -9564,46 +9564,45 @@ const SearchFields = ({ value: e, onChange: t, name: o }) => {
9564
9564
  ),
9565
9565
  /* @__PURE__ */ jsx(Divider$1, { style: { margin: 0 } })
9566
9566
  ] });
9567
- }, useMenuSearch$1 = (e) => {
9568
- var p;
9569
- const { children: t, showType: o, hideSearch: n, name: r } = e, i = ((p = t == null ? void 0 : t.concat) == null ? void 0 : p.call(t)) || [], [a, l] = useState(null), c = useCompile(), u = useMemo(() => {
9570
- if (!a || a === "")
9571
- return i;
9572
- const m = a.toLocaleLowerCase();
9573
- return i.filter((h) => (h.title || h.label) && String(c(h.title || h.label)).toLocaleLowerCase().includes(m));
9574
- }, [a, i]), d = useMemo(() => {
9575
- const m = [];
9576
- try {
9577
- !n && (i.length > 10 || a) && m.push(x({
9578
- key: `search-${uid()}`,
9579
- Component: () => /* @__PURE__ */ jsx(SearchFields, { name: r, value: a, onChange: (h) => l(h) }),
9580
- onClick({ domEvent: h }) {
9581
- h.stopPropagation();
9582
- }
9583
- }, o ? { isMenuType: !0 } : {})), u.length > 0 ? u.forEach((h) => {
9584
- if (["subMenu", "itemGroup"].includes(h.type)) {
9585
- const g = h.children ? (
9586
- // eslint-disable-next-line react-hooks/rules-of-hooks
9587
- useMenuSearch$1({
9588
- children: h.children,
9589
- showType: o,
9590
- hideSearch: n,
9591
- name: h.name
9592
- })
9593
- ) : [];
9594
- m.push(F(x({}, h), { children: g }));
9567
+ };
9568
+ let currentName = null;
9569
+ const useMenuSearch$1 = (e) => {
9570
+ const { children: t, showType: o, hideSearch: n, name: r } = e, i = useCompile(), [a, l] = useState(null), c = (p, m) => {
9571
+ if (!a || a === "" || currentName && currentName !== m)
9572
+ return p;
9573
+ const h = a.toLocaleLowerCase();
9574
+ return p.filter((g) => (g.title || g.label) && String(i(g.title || g.label)).toLocaleLowerCase().includes(h));
9575
+ }, u = (p, m, h = /* @__PURE__ */ new Set()) => {
9576
+ var f;
9577
+ const g = [];
9578
+ return !n && (p.length > 10 || a) && !["subMenu", "itemGroup"].includes((f = p[0]) == null ? void 0 : f.type) && g.push(x({
9579
+ key: `search-${uid()}`,
9580
+ Component: () => /* @__PURE__ */ jsx(
9581
+ SearchFields,
9582
+ {
9583
+ name: m,
9584
+ value: !currentName || currentName === m ? a : "",
9585
+ onChange: (C) => {
9586
+ currentName = m, l(C);
9587
+ }
9588
+ }
9589
+ ),
9590
+ onClick({ domEvent: C }) {
9591
+ C.stopPropagation();
9592
+ }
9593
+ }, o ? { isMenuType: !0 } : {})), p.forEach((C) => {
9594
+ if (!h.has(C))
9595
+ if (h.add(C), ["subMenu", "itemGroup"].includes(C.type)) {
9596
+ const S = !currentName || currentName === C.name ? c(C.children.concat(), C.name) : C.children, b = u(S, C.name, h);
9597
+ g.push(F(x({}, C), { children: b }));
9595
9598
  } else
9596
- m.push(h);
9597
- }) : m.push(x({
9598
- key: "empty",
9599
- style: { height: 150 },
9600
- Component: () => /* @__PURE__ */ jsx("div", { onClick: (h) => h.stopPropagation(), children: /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }) })
9601
- }, o ? { isMenuType: !0 } : {}));
9602
- } catch (h) {
9603
- m.push(...u);
9604
- }
9605
- return m;
9606
- }, [n, u, a, o]);
9599
+ g.push(C);
9600
+ }), p.length === 0 && g.push(x({
9601
+ key: "empty",
9602
+ style: { height: 150 },
9603
+ Component: () => /* @__PURE__ */ jsx("div", { onClick: (C) => C.stopPropagation(), children: /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }) })
9604
+ }, o ? { isMenuType: !0 } : {})), g;
9605
+ }, d = u(c((t == null ? void 0 : t.concat()) || [], r), r);
9607
9606
  return t ? d : void 0;
9608
9607
  }, SchemaInitializerItemGroup = ({
9609
9608
  children: e,
@@ -11756,15 +11755,17 @@ const InternalTableBlockProvider = (e) => {
11756
11755
  return { params: o, parseVariableLoading: n };
11757
11756
  }, TableBlockProvider = withDynamicSchemaProps((e) => {
11758
11757
  const t = e.resource || e.association, o = useFieldSchema(), { getCollection: n, getCollectionField: r } = useCollectionManager_deprecated(e.dataSource), i = n(e.collection, e.dataSource), { treeTable: a, pagingMode: l } = (o == null ? void 0 : o["x-decorator-props"]) || {}, { params: c, parseVariableLoading: u } = useTableBlockParamsCompat(e);
11759
- let d = "children";
11758
+ let d = "__nochildren__";
11760
11759
  if (a)
11761
- if (t != null && t.includes(".")) {
11760
+ if (d = "children", t != null && t.includes(".")) {
11762
11761
  const m = r(t);
11763
11762
  m != null && m.treeChildren && (d = m.name), c.tree = !0;
11764
11763
  } else {
11765
11764
  const m = i == null ? void 0 : i.fields.find((h) => h.treeChildren);
11766
11765
  m && (d = m.name), c.tree = !0;
11767
11766
  }
11767
+ else
11768
+ d = "__nochildren__";
11768
11769
  const p = useMemo(() => createForm(), [a]);
11769
11770
  return u ? null : /* @__PURE__ */ jsx(SchemaComponentOptions, { scope: { treeTable: a }, children: /* @__PURE__ */ jsx(FormContext.Provider, { value: p, children: /* @__PURE__ */ jsx(BlockProvider, F(x({ name: e.name || "table" }, e), { params: c, runWhenParamsChanged: !0, children: /* @__PURE__ */ jsx(InternalTableBlockProvider, F(x({}, e), { childrenColumnName: d, params: c })) })) }) });
11770
11771
  }), useTableBlockContext = () => useContext(TableBlockContext), ActionContext = createContext({});
@@ -14487,7 +14488,7 @@ const useFormItemInitializerFields = (e) => {
14487
14488
  });
14488
14489
  }, useAssociatedFormItemInitializerFields = (e) => {
14489
14490
  var m;
14490
- const { name: t, fields: o } = useCollection_deprecated(), { getInterface: n, getCollectionFields: r, getCollection: i } = useCollectionManager_deprecated(), a = useForm(), { t: l } = useTranslation(), { readPretty: c = a.readPretty, block: u = "Form" } = e || {}, d = u === "Form" ? ["m2o"] : ["o2o", "oho", "obo", "m2o"];
14491
+ const { name: t, fields: o } = useCollection_deprecated(), { getInterface: n, getCollectionFields: r, getCollection: i } = useCollectionManager_deprecated(), a = useForm(), { t: l } = useTranslation(), { readPretty: c = a.readPretty, block: u = "Form" } = e || {}, d = u === "Form" ? ["m2o", "obo", "oho"] : ["o2o", "oho", "obo", "m2o"];
14491
14492
  return (m = o == null ? void 0 : o.filter((h) => d.includes(h.interface))) == null ? void 0 : m.map((h) => getGroupItemForForm({
14492
14493
  getCollectionFields: r,
14493
14494
  field: h,
@@ -19582,7 +19583,9 @@ const findOption$1 = (e = [], t) => {
19582
19583
  return new Promise((h) => {
19583
19584
  setTimeout(() => {
19584
19585
  const g = getChildren(
19585
- a(p).filter((f) => ["hasOne", "hasMany", "belongsTo", "belongsToMany"].includes(f.type)),
19586
+ a(p).filter((f) => ["hasOne", "hasMany", "belongsTo", "belongsToMany", "belongsToArray"].includes(
19587
+ f.type
19588
+ )),
19586
19589
  {
19587
19590
  schema: e,
19588
19591
  depth: d.depth + 1,
@@ -22511,7 +22514,7 @@ const getActionContext = (e) => {
22511
22514
  k != null && k.target && (u = p(
22512
22515
  `${k.target}.${((L = (N = n["x-component-props"]) == null ? void 0 : N.fieldNames) == null ? void 0 : L.label) || "id"}`
22513
22516
  ));
22514
- const D = (k == null ? void 0 : k.interface) === "m2o" && findParentFieldSchema(n), B = D && p(D == null ? void 0 : D["x-collection-field"]), z = useTableBlockContext(), O = (k == null ? void 0 : k.interface) === "m2m" || (B == null ? void 0 : B.type) === "hasMany" && (k == null ? void 0 : k.interface) === "m2o", j = useCallback(
22517
+ const D = (k == null ? void 0 : k.interface) === "m2o" && findParentFieldSchema(n), B = D && p(D == null ? void 0 : D["x-collection-field"]), z = useTableBlockContext(), O = (k == null ? void 0 : k.interface) === "m2m" || (k == null ? void 0 : k.interface) === "mbm" || (B == null ? void 0 : B.type) === "hasMany" && (k == null ? void 0 : k.interface) === "m2o", j = useCallback(
22515
22518
  (q) => {
22516
22519
  const V = q.find((G) => G.value === "$nForm"), U = m(w);
22517
22520
  return !(U != null && U.length) && V && (V.children = formatVariableScop(y())), q;
@@ -37229,7 +37232,7 @@ const InternalNesterCss = css`
37229
37232
  ] });
37230
37233
  },
37231
37234
  { displayName: "InternalPicker" }
37232
- ), toValue$3 = (e, t) => e == null ? t : e;
37235
+ ), toValue$4 = (e, t) => e == null ? t : e;
37233
37236
  function isObject(e) {
37234
37237
  return typeof e == "object" && e !== null;
37235
37238
  }
@@ -37254,7 +37257,7 @@ const RenderRecord = React.memo(
37254
37257
  const [f, C] = useState(!0), [S, b] = useState([]);
37255
37258
  return useEffect(() => {
37256
37259
  const y = toArr$3(h).map((v, I, w) => {
37257
- const k = v == null ? void 0 : v[(e == null ? void 0 : e.label) || "label"], A = t ? transformNestedData(v).map((O) => O == null ? void 0 : O[(e == null ? void 0 : e.label) || "label"]).join(" / ") : isObject(k) ? JSON.stringify(k) : k, D = toValue$3(o(A), "N/A"), B = n(
37260
+ const k = v == null ? void 0 : v[(e == null ? void 0 : e.label) || "label"], A = t ? transformNestedData(v).map((O) => O == null ? void 0 : O[(e == null ? void 0 : e.label) || "label"]).join(" / ") : isObject(k) ? JSON.stringify(k) : k, D = toValue$4(o(A), "N/A"), B = n(
37258
37261
  (v == null ? void 0 : v.__collection) || (r == null ? void 0 : r.target),
37259
37262
  (e == null ? void 0 : e.label) || "label"
37260
37263
  ), z = getLabelFormatValue$1(o(B), D, !0);
@@ -37964,10 +37967,10 @@ const CreateRecordAction$1 = forwardRef(InternalCreateRecordAction), initializer
37964
37967
  ) }, "add") });
37965
37968
  },
37966
37969
  { displayName: "ToManyNester" }
37967
- ), toValue$2 = (e, t) => e == null ? t : e, ButtonTabList = (e) => {
37970
+ ), toValue$3 = (e, t) => e == null ? t : e, ButtonTabList = (e) => {
37968
37971
  const t = useFieldSchema(), { enableLink: o, tagColorField: n } = t["x-component-props"], r = useFieldNames$1({ fieldNames: e.fieldNames }), i = useInsertSchema("Viewer"), { options: a } = useAssociationFieldContext(), l = useCompile(), { designable: c } = useDesignable(), u = useLabelUiSchema$1(a, (r == null ? void 0 : r.label) || "label"), { snapshot: d } = useActionContext(), p = useRef(), { getCollection: m } = useCollectionManager_deprecated(), h = m(a == null ? void 0 : a.target), g = (h == null ? void 0 : h.template) === "tree", { openPopup: f } = usePopupUtils(), C = useCollectionRecordData();
37969
37972
  return /* @__PURE__ */ jsx(Fragment, { children: toArr$3(e.value).map((b, y, v) => {
37970
- const I = b == null ? void 0 : b[(r == null ? void 0 : r.label) || "label"], w = g ? transformNestedData(b).map((D) => D == null ? void 0 : D[(r == null ? void 0 : r.label) || "label"]).join(" / ") : isObject(I) ? JSON.stringify(I) : I, k = toValue$2(l(w), "N/A"), A = getTabFormatValue(l(u), k, b[n]);
37973
+ const I = b == null ? void 0 : b[(r == null ? void 0 : r.label) || "label"], w = g ? transformNestedData(b).map((D) => D == null ? void 0 : D[(r == null ? void 0 : r.label) || "label"]).join(" / ") : isObject(I) ? JSON.stringify(I) : I, k = toValue$3(l(w), "N/A"), A = getTabFormatValue(l(u), k, b[n]);
37971
37974
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
37972
37975
  /* @__PURE__ */ jsx("span", { children: d ? A : o !== !1 ? /* @__PURE__ */ jsx(
37973
37976
  "a",
@@ -38103,7 +38106,7 @@ const useColumnsDeepMemoized = (e) => {
38103
38106
  return spliceArrayState(n, {
38104
38107
  startIndex: w,
38105
38108
  deleteCount: k
38106
- }), n.value.splice(w, k), n.setInitialValue(n.value), n.onInput(n.value);
38109
+ }), n.value.splice(w, k), n.setInitialValue([...n.value]), n.onInput(n.value);
38107
38110
  }),
38108
38111
  children: /* @__PURE__ */ jsx(CloseOutlined, { style: { cursor: "pointer", color: "gray" } })
38109
38112
  }
@@ -42493,22 +42496,22 @@ const useStyles$3 = createStyles(({ token: e }) => ({
42493
42496
  ] });
42494
42497
  },
42495
42498
  mapReadPretty((e) => e.value ? /* @__PURE__ */ jsx("div", { children: "********" }) : /* @__PURE__ */ jsx("div", {}))
42496
- ), isNumberLike = (e) => isNum$1(e) || /^-?\d+(\.\d+)?$/.test(e), toValue$1 = (e, t) => isNumberLike(e) ? math.round(t(e), 9) : null, Percent = connect(
42499
+ ), isNumberLike = (e) => isNum$1(e) || /^-?\d+(\.\d+)?$/.test(e), toValue$2 = (e, t) => isNumberLike(e) ? math.round(t(e), 9) : null, Percent = connect(
42497
42500
  (e) => {
42498
- const { value: t, onChange: o } = e, n = useMemo(() => toValue$1(t, (r) => r * 100), [t]);
42501
+ const { value: t, onChange: o } = e, n = useMemo(() => toValue$2(t, (r) => r * 100), [t]);
42499
42502
  return /* @__PURE__ */ jsx(
42500
42503
  InputNumber$1,
42501
42504
  F(x({}, e), {
42502
42505
  addonAfter: "%",
42503
42506
  value: n,
42504
42507
  onChange: (r) => {
42505
- o && o(toValue$1(r, (i) => i / 100));
42508
+ o && o(toValue$2(r, (i) => i / 100));
42506
42509
  }
42507
42510
  })
42508
42511
  );
42509
42512
  },
42510
42513
  mapReadPretty((e) => {
42511
- const t = useMemo(() => toValue$1(e.value, (o) => o * 100), [e.value]);
42514
+ const t = useMemo(() => toValue$2(e.value, (o) => o * 100), [e.value]);
42512
42515
  return /* @__PURE__ */ jsx(ReadPretty$2, F(x({}, e), { value: t }));
42513
42516
  })
42514
42517
  ), Preview = connect((e) => {
@@ -42770,14 +42773,14 @@ const useTableSelectorProps = () => {
42770
42773
  function isShowFilePicker(e) {
42771
42774
  return (e == null ? void 0 : e["x-component"]) === "Preview";
42772
42775
  }
42773
- const toValue = (e, t) => e == null ? t : e, ReadPrettyRecordPicker = observer$1(
42776
+ const toValue$1 = (e, t) => e == null ? t : e, ReadPrettyRecordPicker = observer$1(
42774
42777
  (e) => {
42775
42778
  var v, I;
42776
42779
  const { ellipsis: t } = e, o = useFieldSchema(), n = useRecord(), r = useCollectionManager(), i = useFieldNames(e), [a, l] = useState(!1), c = useCollection(), u = (c == null ? void 0 : c.getField(o.name)) || (r == null ? void 0 : r.getCollectionField(o == null ? void 0 : o["x-collection-field"])), [d, p] = useState({}), m = useCompile(), h = useLabelUiSchema(u, (i == null ? void 0 : i.label) || "label"), { snapshot: g } = useActionContext(), f = ((v = o["x-component-props"]) == null ? void 0 : v.mode) === "tags", C = useRef();
42777
42780
  if (isShowFilePicker(h))
42778
42781
  return u ? /* @__PURE__ */ jsx(Preview, x({}, e)) : null;
42779
42782
  const S = () => toArr$3(e.value).map((w, k, A) => {
42780
- const D = toValue(m(w == null ? void 0 : w[(i == null ? void 0 : i.label) || "label"]), "N/A"), B = getLabelFormatValue(h, D, !0);
42783
+ const D = toValue$1(m(w == null ? void 0 : w[(i == null ? void 0 : i.label) || "label"]), "N/A"), B = getLabelFormatValue(h, D, !0);
42781
42784
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
42782
42785
  /* @__PURE__ */ jsx("span", { className: "test-record-picker-read-pretty-item", children: g || f ? B : /* @__PURE__ */ jsx(
42783
42786
  "a",
@@ -44826,15 +44829,20 @@ const ReadPretty = observer$1(
44826
44829
  })
44827
44830
  ),
44828
44831
  mapReadPretty(ReadPretty)
44829
- ), UnixTimestamp = connect(
44832
+ ), toValue = (e, t) => e ? convertTimestampToDate(e, t) : null;
44833
+ function convertTimestampToDate(e, t = "second") {
44834
+ const o = t === "second" ? e * 1e3 : e, n = new Date(o);
44835
+ return isNaN(n.getTime()) ? "Invalid timestamp" : n.toUTCString();
44836
+ }
44837
+ const UnixTimestamp = connect(
44830
44838
  (e) => {
44831
- const { value: t, onChange: o } = e;
44839
+ const { value: t, onChange: o, accuracy: n } = e, r = useMemo(() => typeof t == "number" ? toValue(t, n) : t, [t]);
44832
44840
  return /* @__PURE__ */ jsx(
44833
44841
  DatePicker,
44834
44842
  F(x({}, e), {
44835
- value: t,
44836
- onChange: (n) => {
44837
- o && o(n);
44843
+ value: r,
44844
+ onChange: (i) => {
44845
+ o && o(i);
44838
44846
  }
44839
44847
  })
44840
44848
  );
@@ -10,6 +10,7 @@ import React from 'react';
10
10
  interface UnixTimestampProps {
11
11
  value?: any;
12
12
  onChange?: (value: number) => void;
13
+ accuracy?: 'millisecond' | 'second';
13
14
  }
14
15
  export declare const UnixTimestamp: React.ForwardRefExoticComponent<Partial<UnixTimestampProps> & React.RefAttributes<unknown>>;
15
16
  export {};