ding-react-admin 2.2.0 → 2.2.1

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/dist/index.js CHANGED
@@ -1342,52 +1342,59 @@ function zn({ title: e }) {
1342
1342
  }
1343
1343
  //#endregion
1344
1344
  //#region src/components/AppHub.tsx
1345
- function Bn({ apps: e, menuItems: t, onAppClick: n, onMenuClick: r, menuSearchPlaceholder: i = "Search menus across apps…", className: a, maxWidth: o = 960 }) {
1346
- let s = v(), { token: c } = G.useToken(), [u, f] = d(""), p = (e) => {
1345
+ function Bn({ apps: e, menuItems: t, onAppClick: n, onMenuClick: r, menuSearchPlaceholder: i = "Search menus across apps…", className: a, maxWidth: o = 960, loading: s = !1 }) {
1346
+ let c = v(), { token: u } = G.useToken(), [f, p] = d(""), m = (e) => {
1347
1347
  if (n) {
1348
1348
  n(e);
1349
1349
  return;
1350
1350
  }
1351
- s(e.path);
1352
- }, m = (e) => {
1351
+ c(e.path);
1352
+ }, h = (e) => {
1353
1353
  if (r) {
1354
1354
  r(e);
1355
1355
  return;
1356
1356
  }
1357
- s(e.path);
1358
- }, h = u.trim(), g = l(() => t && h ? bt(t, h) : [], [t, h]), _ = !!(t && h);
1357
+ c(e.path);
1358
+ }, g = f.trim(), _ = l(() => t && g ? bt(t, g) : [], [t, g]), y = !!(t && g);
1359
1359
  return /* @__PURE__ */ J("div", {
1360
1360
  className: a,
1361
1361
  style: {
1362
1362
  width: "100%",
1363
1363
  maxWidth: o,
1364
1364
  marginInline: "auto",
1365
- paddingInline: c.paddingMD
1365
+ paddingInline: u.paddingMD
1366
1366
  },
1367
- children: [t?.length ? /* @__PURE__ */ q("div", {
1367
+ children: [t?.length && !s ? /* @__PURE__ */ q("div", {
1368
1368
  style: {
1369
1369
  maxWidth: 480,
1370
1370
  margin: "0 auto 24px"
1371
1371
  },
1372
1372
  children: /* @__PURE__ */ q(it, {
1373
- value: u,
1374
- onChange: f,
1373
+ value: f,
1374
+ onChange: p,
1375
1375
  placeholder: i,
1376
1376
  variant: "app"
1377
1377
  })
1378
- }) : null, _ ? /* @__PURE__ */ q(te, {
1378
+ }) : null, s ? /* @__PURE__ */ q("div", {
1379
+ style: {
1380
+ display: "flex",
1381
+ justifyContent: "center",
1382
+ padding: u.paddingXL
1383
+ },
1384
+ children: /* @__PURE__ */ q(oe, { size: "large" })
1385
+ }) : y ? /* @__PURE__ */ q(te, {
1379
1386
  bordered: !0,
1380
- dataSource: g,
1387
+ dataSource: _,
1381
1388
  locale: { emptyText: "No menus match your search." },
1382
1389
  style: {
1383
- background: c.colorBgContainer,
1384
- borderRadius: c.borderRadiusLG
1390
+ background: u.colorBgContainer,
1391
+ borderRadius: u.borderRadiusLG
1385
1392
  },
1386
1393
  renderItem: (e) => {
1387
1394
  let t = e.Icon;
1388
1395
  return /* @__PURE__ */ q(te.Item, {
1389
1396
  style: { cursor: "pointer" },
1390
- onClick: () => m(e),
1397
+ onClick: () => h(e),
1391
1398
  children: /* @__PURE__ */ q(te.Item.Meta, {
1392
1399
  avatar: t ? /* @__PURE__ */ q("span", {
1393
1400
  style: {
@@ -1414,10 +1421,10 @@ function Bn({ apps: e, menuItems: t, onAppClick: n, onMenuClick: r, menuSearchPl
1414
1421
  style: { maxWidth: 200 },
1415
1422
  children: /* @__PURE__ */ q(T, {
1416
1423
  hoverable: !0,
1417
- onClick: () => p(e),
1424
+ onClick: () => m(e),
1418
1425
  styles: { body: {
1419
1426
  textAlign: "center",
1420
- padding: c.paddingLG
1427
+ padding: u.paddingLG
1421
1428
  } },
1422
1429
  children: /* @__PURE__ */ J(B, {
1423
1430
  orientation: "vertical",
@@ -10,6 +10,8 @@ export type AppHubProps = {
10
10
  className?: string;
11
11
  /** Max width of the centered hub content. Default `960`. */
12
12
  maxWidth?: number;
13
+ /** When true, shows a centered spinner instead of the app grid. */
14
+ loading?: boolean;
13
15
  };
14
- export declare function AppHub({ apps, menuItems, onAppClick, onMenuClick, menuSearchPlaceholder, className, maxWidth, }: AppHubProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function AppHub({ apps, menuItems, onAppClick, onMenuClick, menuSearchPlaceholder, className, maxWidth, loading, }: AppHubProps): import("react/jsx-runtime").JSX.Element;
15
17
  //# sourceMappingURL=AppHub.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppHub.d.ts","sourceRoot":"","sources":["../../../src/components/AppHub.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,EACX,qBAAmD,EACnD,SAAS,EACT,QAAc,GACf,EAAE,WAAW,2CA2Gb"}
1
+ {"version":3,"file":"AppHub.d.ts","sourceRoot":"","sources":["../../../src/components/AppHub.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,EACX,qBAAmD,EACnD,SAAS,EACT,QAAc,EACd,OAAe,GAChB,EAAE,WAAW,2CA+Gb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ding-react-admin",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Composable admin shell (Ant Design + React Router): quick-start AdminApp or build your own layout.",
@@ -1,4 +1,4 @@
1
- import { Card, Col, List, Row, Space, Typography, theme } from "antd";
1
+ import { Card, Col, List, Row, Space, Spin, Typography, theme } from "antd";
2
2
  import { useMemo, useState } from "react";
3
3
  import { useNavigate } from "react-router-dom";
4
4
  import {
@@ -19,6 +19,8 @@ export type AppHubProps = {
19
19
  className?: string;
20
20
  /** Max width of the centered hub content. Default `960`. */
21
21
  maxWidth?: number;
22
+ /** When true, shows a centered spinner instead of the app grid. */
23
+ loading?: boolean;
22
24
  };
23
25
 
24
26
  export function AppHub({
@@ -29,6 +31,7 @@ export function AppHub({
29
31
  menuSearchPlaceholder = "Search menus across apps…",
30
32
  className,
31
33
  maxWidth = 960,
34
+ loading = false,
32
35
  }: AppHubProps) {
33
36
  const navigate = useNavigate();
34
37
  const { token } = theme.useToken();
@@ -70,7 +73,7 @@ export function AppHub({
70
73
  paddingInline: token.paddingMD,
71
74
  }}
72
75
  >
73
- {menuItems?.length ? (
76
+ {menuItems?.length && !loading ? (
74
77
  <div style={{ maxWidth: 480, margin: "0 auto 24px" }}>
75
78
  <NavMenuSearch
76
79
  value={query}
@@ -81,7 +84,11 @@ export function AppHub({
81
84
  </div>
82
85
  ) : null}
83
86
 
84
- {isSearching ? (
87
+ {loading ? (
88
+ <div style={{ display: "flex", justifyContent: "center", padding: token.paddingXL }}>
89
+ <Spin size="large" />
90
+ </div>
91
+ ) : isSearching ? (
85
92
  <List
86
93
  bordered
87
94
  dataSource={menuResults}