@nocobase/client 2.0.3 → 2.0.6

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
@@ -9957,7 +9957,7 @@ function addAppVersion(e, t) {
9957
9957
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
9958
9958
  }), e;
9959
9959
  }
9960
- const name = "@nocobase/client", version = "2.0.3", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9960
+ const name = "@nocobase/client", version = "2.0.6", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9961
9961
  "@ahooksjs/use-url-state": "3.5.1",
9962
9962
  "@ant-design/cssinjs": "^1.11.1",
9963
9963
  "@ant-design/icons": "^5.6.1",
@@ -9980,10 +9980,10 @@ const name = "@nocobase/client", version = "2.0.3", license = "Apache-2.0", main
9980
9980
  "@formily/reactive-react": "^2.2.27",
9981
9981
  "@formily/shared": "^2.2.27",
9982
9982
  "@formily/validator": "^2.2.27",
9983
- "@nocobase/evaluators": "2.0.3",
9984
- "@nocobase/flow-engine": "2.0.3",
9985
- "@nocobase/sdk": "2.0.3",
9986
- "@nocobase/utils": "2.0.3",
9983
+ "@nocobase/evaluators": "2.0.6",
9984
+ "@nocobase/flow-engine": "2.0.6",
9985
+ "@nocobase/sdk": "2.0.6",
9986
+ "@nocobase/utils": "2.0.6",
9987
9987
  "@tanstack/react-table": "^8.21.3",
9988
9988
  "@types/tabulator-tables": "^6.2.6",
9989
9989
  "acorn-jsx": "^5.3.2",
@@ -26292,6 +26292,17 @@ const components$5 = { TreeSelect: TreeSelect$1 }, toItems$2 = (e, { t, compile:
26292
26292
  children: e.children
26293
26293
  }
26294
26294
  );
26295
+ }, MOBILE_MENU_CLOSE_DELAY_MS = 220, runAfterMobileMenuClosed = ({
26296
+ isMobile: e,
26297
+ closeMobileMenu: t,
26298
+ callback: o,
26299
+ delayMs: n = MOBILE_MENU_CLOSE_DELAY_MS
26300
+ }) => {
26301
+ if (!e) {
26302
+ o();
26303
+ return;
26304
+ }
26305
+ t(), window.setTimeout(o, n);
26295
26306
  }, UserCenterButton = () => {
26296
26307
  const { token: e } = useToken();
26297
26308
  return /* @__PURE__ */ jsx(
@@ -26467,7 +26478,10 @@ const LayoutContent = () => {
26467
26478
  /* @__PURE__ */ jsx(MenuSchemaToolbar, { container: t }),
26468
26479
  /* @__PURE__ */ jsx("div", { ref: e })
26469
26480
  ] });
26470
- }, menuItemStyle = { display: "flex", alignItems: "center", justifyContent: "space-between" }, GroupItem = (e) => {
26481
+ }, menuItemStyle = { display: "flex", alignItems: "center", justifyContent: "space-between" }, MobileMenuControlContext = React.createContext({
26482
+ closeMobileMenu: () => {
26483
+ }
26484
+ }), GroupItem = (e) => {
26471
26485
  var i, a, l, c;
26472
26486
  const { item: t } = e, { designable: o } = useDesignable(), n = useEvaluatedExpression((a = (i = t._route.options) == null ? void 0 : i.badge) == null ? void 0 : a.count), r = { __route__: t._route };
26473
26487
  return /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: /* @__PURE__ */ jsxs(SortableItem$1, { id: t._route.id, schema: r, "aria-label": t.name, style: menuItemStyle, children: [
@@ -26486,59 +26500,76 @@ const LayoutContent = () => {
26486
26500
  const { inHeader: t } = useContext(HeaderContext);
26487
26501
  return /* @__PURE__ */ jsx(RouteContext.Consumer, { children: (o) => o.collapsed && !e.hidden && !t ? /* @__PURE__ */ jsx(Tooltip, { title: e.title, placement: "right", children: /* @__PURE__ */ jsx(Badge, A(x({}, e.badgeProps), { style: { transform: "none", maxWidth: "10em" }, dot: !1, children: e.children })) }) : e.children });
26488
26502
  }, MenuItem = (e) => {
26489
- var m, h, g, f, y, b, S, C, F;
26490
- const { item: t } = e, { parseURLAndParams: o } = useParseURLAndParams(), n = useRef(null), r = useLocation(), i = useEvaluatedExpression((h = (m = t._route.options) == null ? void 0 : m.badge) == null ? void 0 : h.count), a = useNavigateNoUpdate(), l = useRouterBasename();
26503
+ var g, f, y, b, S, C, F, P, v, k, I;
26504
+ const { item: t } = e, { parseURLAndParams: o } = useParseURLAndParams(), n = useRef(null), r = useLocation(), i = useEvaluatedExpression((f = (g = t._route.options) == null ? void 0 : g.badge) == null ? void 0 : f.count), a = useNavigateNoUpdate(), l = useRouterBasename(), { closeMobileMenu: c } = useContext(MobileMenuControlContext), u = t.redirect || t.path, d = A(x({}, (y = t._route.options) == null ? void 0 : y.badge), { count: i });
26491
26505
  useEffect(() => {
26492
26506
  n.current && (n.current.parentElement.parentElement.style.order = 999, n.current.parentElement.parentElement.style.paddingLeft = 0, n.current.parentElement.parentElement.style.padding = 0);
26493
26507
  }, []);
26494
- const c = useCallback(
26495
- (P) => V(void 0, null, function* () {
26496
- var D, E, $;
26497
- const v = (D = t._route.options) == null ? void 0 : D.href, k = (E = t._route.options) == null ? void 0 : E.params, I = ($ = t._route.options) == null ? void 0 : $.openInNewWindow;
26498
- P.preventDefault(), P.stopPropagation();
26508
+ const p = useCallback(
26509
+ (D) => V(void 0, null, function* () {
26510
+ var T, w, B, N, j, O;
26511
+ const E = (T = t._route.options) == null ? void 0 : T.href, $ = (w = t._route.options) == null ? void 0 : w.params, M = (B = t._route.options) == null ? void 0 : B.openInNewWindow;
26512
+ D.preventDefault(), D.stopPropagation();
26499
26513
  try {
26500
- const M = yield o(v, k || []);
26501
- I !== !1 ? window.open(M, "_blank") : navigateWithinSelf(v, a, window.location.origin + l);
26502
- } catch (M) {
26503
- console.error(M), window.open(v, "_blank");
26514
+ const q = yield o(E, $ || []);
26515
+ M !== !1 ? ((N = e.options) != null && N.isMobile && c(), window.open(q, "_blank")) : runAfterMobileMenuClosed({
26516
+ isMobile: !!((j = e.options) != null && j.isMobile),
26517
+ closeMobileMenu: c,
26518
+ callback: () => {
26519
+ navigateWithinSelf(E, a, window.location.origin + l);
26520
+ }
26521
+ });
26522
+ } catch (q) {
26523
+ console.error(q), (O = e.options) != null && O.isMobile && c(), window.open(E, "_blank");
26504
26524
  }
26505
26525
  }),
26506
- [o, t]
26526
+ [o, t, (b = e.options) == null ? void 0 : b.isMobile, c, a, l]
26527
+ ), m = useCallback(
26528
+ (D) => {
26529
+ var E, $;
26530
+ if (D.preventDefault(), D.stopPropagation(), !((E = e.options) != null && E.isMobile)) {
26531
+ a(u);
26532
+ return;
26533
+ }
26534
+ runAfterMobileMenuClosed({
26535
+ isMobile: !!(($ = e.options) != null && $.isMobile),
26536
+ closeMobileMenu: c,
26537
+ callback: () => {
26538
+ a(u);
26539
+ }
26540
+ });
26541
+ },
26542
+ [(S = e.options) == null ? void 0 : S.isMobile, c, a, u]
26507
26543
  );
26508
26544
  if (t._hidden)
26509
26545
  return null;
26510
- const u = { __route__: t._route };
26511
- if (t.key === "x-designer-button")
26512
- return /* @__PURE__ */ jsx("div", { ref: n, children: /* @__PURE__ */ jsx(ResetThemeTokenAndKeepAlgorithm, { children: /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: e.children }) }) }) });
26513
- if (((g = t._route) == null ? void 0 : g.type) === NocoBaseDesktopRouteType.link)
26514
- return /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: /* @__PURE__ */ jsxs(SortableItem$1, { id: t._route.id, schema: u, style: menuItemStyle, children: [
26515
- /* @__PURE__ */ jsx("div", { onClick: c, children: /* @__PURE__ */ jsx(Link$1, { to: r.pathname, "aria-label": t.name, children: e.children }) }),
26516
- /* @__PURE__ */ jsx(MenuSchemaToolbar, {}),
26517
- i != null && /* @__PURE__ */ jsx(
26518
- Badge,
26519
- A(x({}, (f = t._route.options) == null ? void 0 : f.badge), {
26520
- count: i,
26521
- style: { marginLeft: 4, color: (b = (y = t._route.options) == null ? void 0 : y.badge) == null ? void 0 : b.textColor, maxWidth: "10em" },
26522
- dot: !1
26523
- })
26524
- )
26525
- ] }) }) });
26526
- const d = t.redirect || t.path, p = A(x({}, (S = t._route.options) == null ? void 0 : S.badge), { count: i });
26527
- return /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: /* @__PURE__ */ jsxs(SortableItem$1, { id: t._route.id, schema: u, style: menuItemStyle, children: [
26546
+ const h = { __route__: t._route };
26547
+ return t.key === "x-designer-button" ? /* @__PURE__ */ jsx("div", { ref: n, children: /* @__PURE__ */ jsx(ResetThemeTokenAndKeepAlgorithm, { children: /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: e.children }) }) }) }) : ((C = t._route) == null ? void 0 : C.type) === NocoBaseDesktopRouteType.link ? /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: /* @__PURE__ */ jsxs(SortableItem$1, { id: t._route.id, schema: h, style: menuItemStyle, children: [
26548
+ /* @__PURE__ */ jsx("div", { onClick: p, children: /* @__PURE__ */ jsx(Link$1, { to: r.pathname, "aria-label": t.name, children: e.children }) }),
26549
+ /* @__PURE__ */ jsx(MenuSchemaToolbar, {}),
26550
+ i != null && /* @__PURE__ */ jsx(
26551
+ Badge,
26552
+ A(x({}, (F = t._route.options) == null ? void 0 : F.badge), {
26553
+ count: i,
26554
+ style: { marginLeft: 4, color: (v = (P = t._route.options) == null ? void 0 : P.badge) == null ? void 0 : v.textColor, maxWidth: "10em" },
26555
+ dot: !1
26556
+ })
26557
+ )
26558
+ ] }) }) }) : /* @__PURE__ */ jsx(ParentRouteContext.Provider, { value: t._parentRoute, children: /* @__PURE__ */ jsx(NocoBaseRouteContext.Provider, { value: t._route, children: /* @__PURE__ */ jsxs(SortableItem$1, { id: t._route.id, schema: h, style: menuItemStyle, children: [
26528
26559
  /* @__PURE__ */ jsx(
26529
26560
  WithTooltip,
26530
26561
  {
26531
26562
  title: t.name,
26532
26563
  hidden: t._route.type === NocoBaseDesktopRouteType.group || t._depth > 0,
26533
- badgeProps: p,
26534
- children: /* @__PURE__ */ jsx(Link$1, { to: d, "aria-label": t.name, children: e.children })
26564
+ badgeProps: d,
26565
+ children: /* @__PURE__ */ jsx(Link$1, { to: u, "aria-label": t.name, onClick: m, children: e.children })
26535
26566
  }
26536
26567
  ),
26537
26568
  /* @__PURE__ */ jsx(MenuSchemaToolbar, {}),
26538
26569
  i != null && /* @__PURE__ */ jsx(
26539
26570
  Badge,
26540
- A(x({}, p), {
26541
- style: { marginLeft: 4, color: (F = (C = t._route.options) == null ? void 0 : C.badge) == null ? void 0 : F.textColor, maxWidth: "10em" },
26571
+ A(x({}, d), {
26572
+ style: { marginLeft: 4, color: (I = (k = t._route.options) == null ? void 0 : k.badge) == null ? void 0 : I.textColor, maxWidth: "10em" },
26542
26573
  dot: !1
26543
26574
  })
26544
26575
  )
@@ -26657,10 +26688,10 @@ const LayoutContent = () => {
26657
26688
  return /* @__PURE__ */ jsx(t, {});
26658
26689
  }, InternalAdminLayout = (e) => {
26659
26690
  const { allAccessRoutes: t } = useAllAccessDesktopRoutes(), { designable: o } = useDesignable(), n = useLocation(), { onDragEnd: r } = useMenuDragEnd(), { token: i } = useToken(), { isMobileLayout: a } = useMobileLayout(), [l, c] = useState(a), u = useRef(!1), { t: d } = useMenuTranslation(), p = a ? !1 : o, { styles: m } = useHeaderStyle(), { Component: h } = useApplications(), g = useMemo(() => {
26660
- const v = convertRoutesToLayout(t, { designable: p, isMobile: a, t: d });
26691
+ const k = convertRoutesToLayout(t, { designable: p, isMobile: a, t: d });
26661
26692
  return {
26662
26693
  path: "/",
26663
- children: Array.isArray(v) ? v : []
26694
+ children: Array.isArray(k) ? k : []
26664
26695
  };
26665
26696
  }, [t, p, a, d]), f = useMemo(() => ({
26666
26697
  header: {
@@ -26697,17 +26728,19 @@ const LayoutContent = () => {
26697
26728
  }),
26698
26729
  algorithm: b ? [theme.compactAlgorithm, theme.darkAlgorithm] : theme.compactAlgorithm
26699
26730
  // Set mobile mode to always use compact algorithm
26700
- }), [y, b]), C = useCallback((v) => {
26701
- u.current || c(v);
26731
+ }), [y, b]), C = useCallback((k) => {
26732
+ u.current || c(k);
26702
26733
  }, []), F = useCallback(() => {
26703
26734
  u.current = !0, setTimeout(() => {
26704
26735
  u.current = !1;
26705
26736
  });
26706
26737
  }, []), P = useMemo(() => ({
26707
26738
  overflowedIndicatorPopupClassName: m.headerPopup
26708
- }), [m.headerPopup]);
26739
+ }), [m.headerPopup]), v = useCallback(() => {
26740
+ a && c(!0);
26741
+ }, [a]);
26709
26742
  return /* @__PURE__ */ jsxs("div", { style: rootStyle, children: [
26710
- /* @__PURE__ */ jsx("div", { id: "nocobase-app-container", style: appContainerStyle, children: /* @__PURE__ */ jsx(DndContext, { onDragEnd: r, children: /* @__PURE__ */ jsx(
26743
+ /* @__PURE__ */ jsx("div", { id: "nocobase-app-container", style: appContainerStyle, children: /* @__PURE__ */ jsx(MobileMenuControlContext.Provider, { value: { closeMobileMenu: v }, children: /* @__PURE__ */ jsx(DndContext, { onDragEnd: r, children: /* @__PURE__ */ jsx(
26711
26744
  ProLayout,
26712
26745
  A(x({}, e), {
26713
26746
  contentStyle: contentStyle$1,
@@ -26736,15 +26769,15 @@ const LayoutContent = () => {
26736
26769
  autoClose: !1
26737
26770
  },
26738
26771
  menuProps: P,
26739
- children: /* @__PURE__ */ jsx(RouteContext.Consumer, { children: (v) => {
26740
- const { isMobile: k } = v;
26741
- return /* @__PURE__ */ jsx(SetIsMobileLayout, { isMobile: k, children: /* @__PURE__ */ jsxs(ConfigProvider, { theme: k ? S : y, children: [
26772
+ children: /* @__PURE__ */ jsx(RouteContext.Consumer, { children: (k) => {
26773
+ const { isMobile: I } = k;
26774
+ return /* @__PURE__ */ jsx(SetIsMobileLayout, { isMobile: I, children: /* @__PURE__ */ jsxs(ConfigProvider, { theme: I ? S : y, children: [
26742
26775
  /* @__PURE__ */ jsx(GlobalStyle, {}),
26743
26776
  /* @__PURE__ */ jsx(LayoutContent, {})
26744
26777
  ] }) });
26745
26778
  } })
26746
26779
  })
26747
- ) }) }),
26780
+ ) }) }) }),
26748
26781
  /* @__PURE__ */ jsx("div", { id: "nocobase-embed-container", style: embedContainerStyle })
26749
26782
  ] });
26750
26783
  };
@@ -30527,7 +30560,7 @@ const useStyles$a = genStyleHook("nb-markdown", (e, { isDarkTheme: t }) => {
30527
30560
  }, t ? i : r)
30528
30561
  };
30529
30562
  }), parseMarkdown$1 = _.memoize((e) => V(void 0, null, function* () {
30530
- return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
30563
+ return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
30531
30564
  }));
30532
30565
  function useParseMarkdown$1(e) {
30533
30566
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -71748,7 +71781,7 @@ BlockGridModel.registerFlow({
71748
71781
  }
71749
71782
  });
71750
71783
  const parseMarkdown = _.memoize((e) => V(void 0, null, function* () {
71751
- return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
71784
+ return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
71752
71785
  }));
71753
71786
  function useParseMarkdown(e) {
71754
71787
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -78047,7 +78080,26 @@ function clearLegacyDefaultValuesFromFormModel(e) {
78047
78080
  const GRID_DELEGATED_STEP_KEYS = {
78048
78081
  formModelSettings: /* @__PURE__ */ new Set(["layout", "assignRules"]),
78049
78082
  eventSettings: /* @__PURE__ */ new Set(["linkageRules"])
78050
- };
78083
+ }, FLOW_KEEP_MOBILE_HORIZONTAL_CLASS = "nb-flow-keep-mobile-horizontal", flowKeepMobileHorizontalClassName = css`
78084
+ &.${FLOW_KEEP_MOBILE_HORIZONTAL_CLASS} {
78085
+ @media (max-width: 575px) {
78086
+ .ant-form-item {
78087
+ flex-wrap: nowrap !important;
78088
+ }
78089
+
78090
+ .ant-form-item .ant-form-item-label {
78091
+ flex: 0 0 auto !important;
78092
+ max-width: none !important;
78093
+ }
78094
+
78095
+ .ant-form-item .ant-form-item-control {
78096
+ flex: 1 1 0 !important;
78097
+ max-width: none !important;
78098
+ min-width: 0;
78099
+ }
78100
+ }
78101
+ }
78102
+ `;
78051
78103
  function isGridDelegatedStep(e, t) {
78052
78104
  var o;
78053
78105
  return !!((o = GRID_DELEGATED_STEP_KEYS[e]) != null && o.has(t));
@@ -78296,29 +78348,35 @@ function FormComponent(i) {
78296
78348
  "layoutProps",
78297
78349
  "initialValues"
78298
78350
  ]);
78299
- var l, c, u;
78351
+ var u, d, p, m;
78352
+ const l = !!((u = e == null ? void 0 : e.context) != null && u.isMobileLayout && (o == null ? void 0 : o.layout) === "horizontal"), c = [
78353
+ r.className,
78354
+ l ? FLOW_KEEP_MOBILE_HORIZONTAL_CLASS : "",
78355
+ l ? flowKeepMobileHorizontalClassName : ""
78356
+ ].filter(Boolean).join(" ");
78300
78357
  return /* @__PURE__ */ jsx(
78301
78358
  Form$2,
78302
78359
  A(x(A(x({
78303
78360
  form: e.form,
78304
- initialValues: ((u = (c = (l = e.context) == null ? void 0 : l.view) == null ? void 0 : c.inputArgs) == null ? void 0 : u.formData) || e.context.record || n
78361
+ initialValues: ((m = (p = (d = e.context) == null ? void 0 : d.view) == null ? void 0 : p.inputArgs) == null ? void 0 : m.formData) || e.context.record || n
78305
78362
  }, omit(o, "labelWidth")), {
78306
78363
  labelCol: { style: { width: o == null ? void 0 : o.labelWidth } },
78307
- onFieldsChange: (d) => {
78308
- const p = e.formValueRuntime;
78309
- p && p.handleFormFieldsChange(d);
78364
+ onFieldsChange: (h) => {
78365
+ const g = e.formValueRuntime;
78366
+ g && g.handleFormFieldsChange(h);
78310
78367
  },
78311
- onValuesChange: (d, p) => {
78312
- var h;
78313
- (h = e.markUserModifiedFields) == null || h.call(e, d);
78314
- const m = e.formValueRuntime;
78315
- if (m) {
78316
- m.handleFormValuesChange(d, p);
78368
+ onValuesChange: (h, g) => {
78369
+ var y;
78370
+ (y = e.markUserModifiedFields) == null || y.call(e, h);
78371
+ const f = e.formValueRuntime;
78372
+ if (f) {
78373
+ f.handleFormValuesChange(h, g);
78317
78374
  return;
78318
78375
  }
78319
- e.dispatchEvent("formValuesChange", { changedValues: d, allValues: p }, { debounce: !0 }), e.emitter.emit("formValuesChange", { changedValues: d, allValues: p });
78376
+ e.dispatchEvent("formValuesChange", { changedValues: h, allValues: g }, { debounce: !0 }), e.emitter.emit("formValuesChange", { changedValues: h, allValues: g });
78320
78377
  }
78321
78378
  }), r), {
78379
+ className: c || void 0,
78322
78380
  children: t
78323
78381
  })
78324
78382
  );
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const MOBILE_MENU_CLOSE_DELAY_MS = 220;
10
+ export declare const runAfterMobileMenuClosed: ({ isMobile, closeMobileMenu, callback, delayMs, }: {
11
+ isMobile: boolean;
12
+ closeMobileMenu: () => void;
13
+ callback: () => void;
14
+ delayMs?: number;
15
+ }) => void;