react-toolkits 0.8.36 → 0.8.37

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 0.8.37
4
+
5
+ ### Patch Changes
6
+
7
+ - cbffc19: feat: add isGlobal context
8
+
3
9
  ## 0.8.36
4
10
 
5
11
  ### Patch Changes
@@ -64,7 +70,7 @@
64
70
 
65
71
  ### Patch Changes
66
72
 
67
- - 7046d58: fix: missing isGlobalNS config in useTokenValidation hook
73
+ - 7046d58: fix: missing isGlobal config in useTokenValidation hook
68
74
 
69
75
  ## 0.8.25
70
76
 
@@ -322,7 +328,7 @@
322
328
 
323
329
  ### Patch Changes
324
330
 
325
- - 46ca83c: fix: missing app-id while isGlobalNS is true
331
+ - 46ca83c: fix: missing app-id while isGlobal is true
326
332
 
327
333
  ## 0.4.1
328
334
 
@@ -576,13 +582,13 @@
576
582
 
577
583
  ### Patch Changes
578
584
 
579
- - ec2fb3c: feat: set isGlobalNS to true
585
+ - ec2fb3c: feat: set isGlobal to true
580
586
 
581
587
  ## 0.3.11
582
588
 
583
589
  ### Patch Changes
584
590
 
585
- - b9b1ce0: feat: remove isGlobalNS prop
591
+ - b9b1ce0: feat: remove isGlobal prop
586
592
 
587
593
  ## 0.3.10
588
594
 
@@ -710,7 +716,7 @@
710
716
 
711
717
  ### Patch Changes
712
718
 
713
- - fceb92e: fix: missing isGlobalNS prop in ContextProvider
719
+ - fceb92e: fix: missing isGlobal prop in ContextProvider
714
720
 
715
721
  ## 0.2.19
716
722
 
@@ -4189,7 +4189,7 @@ function af(e = !1) {
4189
4189
  body: {
4190
4190
  permissions: ["100001"]
4191
4191
  },
4192
- isGlobalNS: !0
4192
+ isGlobal: !0
4193
4193
  }),
4194
4194
  {
4195
4195
  suspense: !0,
@@ -4207,7 +4207,7 @@ class Va extends Error {
4207
4207
  }
4208
4208
  async function ct(e, t) {
4209
4209
  var g;
4210
- let { body: r, params: n, headers: a, responseType: s = "json", isGlobalNS: c, ...o } = t ?? {};
4210
+ let { body: r, params: n, headers: a, responseType: s = "json", isGlobal: c, ...o } = t ?? {};
4211
4211
  const l = yt.parseUrl(e), f = Object.assign({}, l.query, n), p = {
4212
4212
  skipNull: !0,
4213
4213
  skipEmptyString: !0,
@@ -4216,14 +4216,13 @@ async function ct(e, t) {
4216
4216
  }, u = yt.stringify(f, p);
4217
4217
  e = u ? `${l.url}?${u}` : e, a = new Headers(a);
4218
4218
  const A = (g = Ot == null ? void 0 : Ot.getState()) == null ? void 0 : g.token;
4219
- if (A && a.set("Authorization", `Bearer ${A}`), Br.getState().usePermissionApiV2) {
4220
- if (c)
4219
+ if (A && a.set("Authorization", `Bearer ${A}`), Br.getState().usePermissionApiV2)
4220
+ if (c || Br.getState().isGlobal)
4221
4221
  a.set("App-ID", "global");
4222
- else if (!Br.getState().hideGameSelect) {
4222
+ else {
4223
4223
  const _ = On.getState().game;
4224
4224
  _ && a.set("App-ID", _.id);
4225
4225
  }
4226
- }
4227
4226
  s === "blob" ? a.append("Accept", "application/octet-stream") : a.append("Accept", "application/json");
4228
4227
  const h = !!(r && typeof r == "object" && !(r instanceof FormData));
4229
4228
  h && a.set("Content-Type", "application/json");
@@ -4279,7 +4278,7 @@ const Hl = {
4279
4278
  e({ isLoading: r });
4280
4279
  },
4281
4280
  refreshGames() {
4282
- ct("/api/usystem/game/all", { isGlobalNS: !0 }).then((r) => {
4281
+ ct("/api/usystem/game/all", { isGlobal: !0 }).then((r) => {
4283
4282
  t().setGames(r.data), t().setIsLoading(!1);
4284
4283
  });
4285
4284
  }
@@ -4290,7 +4289,7 @@ const Hl = {
4290
4289
  partialize: (e) => ({ game: e.game }),
4291
4290
  onRehydrateStorage: () => (console.log("Game store hydration starts"), (e, t) => {
4292
4291
  e && !t && setTimeout(() => {
4293
- ct("/api/usystem/game/all", { isGlobalNS: !0 }).then((r) => {
4292
+ ct("/api/usystem/game/all", { isGlobal: !0 }).then((r) => {
4294
4293
  e.setGames(r.data), e.setIsLoading(!1);
4295
4294
  });
4296
4295
  }, 800);
@@ -4523,7 +4522,7 @@ function Tn(e, t, r) {
4523
4522
  body: {
4524
4523
  permissions: e
4525
4524
  },
4526
- isGlobalNS: t
4525
+ isGlobal: t
4527
4526
  }).then((l) => {
4528
4527
  var f;
4529
4528
  return (f = l.data) != null && f.has_all ? e.reduce(
@@ -4562,7 +4561,7 @@ const ru = (e) => {
4562
4561
  action: r,
4563
4562
  extras: n,
4564
4563
  headers: a,
4565
- isGlobalNS: s,
4564
+ isGlobal: s,
4566
4565
  getRowKey: c,
4567
4566
  getDataSource: o,
4568
4567
  hasMore: l,
@@ -4583,7 +4582,7 @@ const ru = (e) => {
4583
4582
  T,
4584
4583
  (v) => ct(v, {
4585
4584
  headers: typeof a == "function" ? a(h) : a,
4586
- isGlobalNS: s
4585
+ isGlobal: s
4587
4586
  }).then((E) => E.data),
4588
4587
  {
4589
4588
  shouldRetryOnError: !1,
@@ -4834,7 +4833,7 @@ const su = Cc, cu = (e) => {
4834
4833
  ] });
4835
4834
  }, gu = Au, yu = (e) => {
4836
4835
  var f;
4837
- const { children: t, code: r, showLoading: n, isGlobalNS: a, ...s } = e, { data: c, isLoading: o } = Tn(Array.isArray(r) ? r : [r], a), l = we();
4836
+ const { children: t, code: r, showLoading: n, isGlobal: a, ...s } = e, { data: c, isLoading: o } = Tn(Array.isArray(r) ? r : [r], a), l = we();
4838
4837
  return o ? /* @__PURE__ */ d.jsx(ze, { loading: n, disabled: !n, ...s, children: t }) : (f = Object.values(c ?? {})) != null && f.some(Boolean) ? /* @__PURE__ */ d.jsx(ze, { ...s, children: t }) : /* @__PURE__ */ d.jsx(Zc, { defaultOpen: !1, title: l("global.noEntitlement"), children: /* @__PURE__ */ d.jsx(ze, { disabled: !0, ...s, children: t }) });
4839
4838
  }, of = yu, mu = (e) => {
4840
4839
  const { code: t, children: r } = e, { accessible: n, isValidating: a } = Rn(t), s = we();
@@ -4896,7 +4895,7 @@ const bu = (e, t) => {
4896
4895
  action: r,
4897
4896
  code: n,
4898
4897
  headers: a,
4899
- isGlobalNS: s,
4898
+ isGlobal: s,
4900
4899
  onePage: c,
4901
4900
  method: o = "GET",
4902
4901
  body: l,
@@ -4926,7 +4925,7 @@ const bu = (e, t) => {
4926
4925
  method: o,
4927
4926
  headers: typeof a == "function" ? a({ page: ae, size: ue, arg: pe }) : a,
4928
4927
  body: typeof l == "function" ? l({ page: ae, size: ue, arg: pe }) : l,
4929
- isGlobalNS: s
4928
+ isGlobal: s
4930
4929
  });
4931
4930
  return {
4932
4931
  dataSource: b(fe.data),
@@ -5512,7 +5511,7 @@ const Mu = /* @__PURE__ */ ln(Du), { Option: Ha } = sn, { Paragraph: Ya } = cn,
5512
5511
  }, zu = Lu, Uu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5513
5512
  __proto__: null,
5514
5513
  default: zu
5515
- }, Symbol.toStringTag, { value: "Module" })), ku = ot(() => import("./index-7xuXLgqA.chunk.js")), $u = ot(() => import("./index-0bU-UwlE.chunk.js")), Vu = ot(() => import("./index-9G4AkNbR.chunk.js")), Wu = () => /* @__PURE__ */ d.jsxs(ts, { children: [
5514
+ }, Symbol.toStringTag, { value: "Module" })), ku = ot(() => import("./index-rOwKhYYf.chunk.js")), $u = ot(() => import("./index-0kLlKKs0.chunk.js")), Vu = ot(() => import("./index-bubqP5K4.chunk.js")), Wu = () => /* @__PURE__ */ d.jsxs(ts, { children: [
5516
5515
  /* @__PURE__ */ d.jsx(He, { index: !0, element: /* @__PURE__ */ d.jsx(Ir, { to: "user" }) }),
5517
5516
  /* @__PURE__ */ d.jsx(He, { path: "user", element: /* @__PURE__ */ d.jsx(ku, {}) }),
5518
5517
  /* @__PURE__ */ d.jsx(He, { path: "role", element: /* @__PURE__ */ d.jsx($u, {}) }),
@@ -1,6 +1,6 @@
1
- import { a as S, j as e, d as $ } from "./index-WjQ2L06b.chunk.js";
1
+ import { a as S, j as e, d as $ } from "./index--xP5ZRwk.chunk.js";
2
2
  import { Collapse as D, Checkbox as k, Row as G, Col as _, Skeleton as T, Typography as A, Divider as w, Card as K, Space as M, Select as E, Button as N, Empty as O } from "antd";
3
- import { h as R, i as B } from "./index-EcHXdtfc.chunk.js";
3
+ import { h as R, i as B } from "./index-j7kGPvUz.chunk.js";
4
4
  import { useState as P, useCallback as F, useEffect as b } from "react";
5
5
  const q = (x) => {
6
6
  const { permissions: l, readonly: t, expand: d, value: a, onChange: r } = x, [m, p] = P([]), [g, u] = P({}), [c, f] = P(a ?? []), C = S(), h = F((s) => {
@@ -1,47 +1,47 @@
1
- import { A as T, _ as U, c as N, d as P, u as y, a as b, j as e, P as j, r as _, H as z, Q as $, b as S } from "./index-WjQ2L06b.chunk.js";
2
- import { App as f, Space as F, Card as G, Form as g, Input as L } from "antd";
3
- import { p as A } from "./immer-BLf7GM7E.chunk.js";
4
- import { Link as B } from "react-router-dom";
5
- import { P as k } from "./index-PdAloIXt.chunk.js";
6
- import { d as E, e as q, f as D } from "./index-EcHXdtfc.chunk.js";
7
- import * as v from "react";
1
+ import { A as T, _ as U, c as P, d as _, u as y, a as b, j as e, P as j, r as z, H as $, Q as F, b as L } from "./index--xP5ZRwk.chunk.js";
2
+ import { App as f, Space as G, Card as B, Form as g, Input as A } from "antd";
3
+ import { p as k } from "./immer-BLf7GM7E.chunk.js";
4
+ import { Link as E } from "react-router-dom";
5
+ import { P as v } from "./index-0LeTY9YL.chunk.js";
6
+ import { d as q, e as D, f as N } from "./index-j7kGPvUz.chunk.js";
7
+ import * as I from "react";
8
8
  import "react-dom";
9
9
  var Q = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M892 772h-80v-80c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v80h-80c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h80v80c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-80h80c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM373.5 498.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.8-1.7-203.2 89.2-203.2 200 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.8-1.1 6.4-4.8 5.9-8.8zM824 472c0-109.4-87.9-198.3-196.9-200C516.3 270.3 424 361.2 424 472c0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C357 742.6 326 814.8 324 891.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5C505.8 695.7 563 672 624 672c110.4 0 200-89.5 200-200zm-109.5 90.5C690.3 586.7 658.2 600 624 600s-66.3-13.3-90.5-37.5a127.26 127.26 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4-.1 34.2-13.4 66.3-37.6 90.5z" } }] }, name: "usergroup-add", theme: "outlined" };
10
10
  const H = Q;
11
- var I = function(r, a) {
12
- return /* @__PURE__ */ v.createElement(T, U({}, r, {
11
+ var M = function(r, a) {
12
+ return /* @__PURE__ */ I.createElement(T, U({}, r, {
13
13
  ref: a,
14
14
  icon: H
15
15
  }));
16
16
  };
17
- process.env.NODE_ENV !== "production" && (I.displayName = "UsergroupAddOutlined");
18
- const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = () => {
19
- const { message: c } = f.useApp(), { setPayload: r } = y(), a = q(), n = b(), l = async (o) => {
17
+ process.env.NODE_ENV !== "production" && (M.displayName = "UsergroupAddOutlined");
18
+ const K = /* @__PURE__ */ I.forwardRef(M), h = "/api/usystem/role/list", J = () => {
19
+ const { message: c } = f.useApp(), { setPayload: r } = y(), a = D(), n = b(), l = async (o) => {
20
20
  await a.trigger({
21
21
  name: `role_${o.name}`,
22
22
  permissions: o.permissions
23
23
  }), r(h, { page: 1 }), c.success(n("RoleList.createSuccessfully"));
24
24
  };
25
- return S({
25
+ return L({
26
26
  title: n("RoleList.createTitle"),
27
27
  width: "50vw",
28
28
  formProps: {
29
29
  layout: "vertical"
30
30
  },
31
31
  content: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
32
- /* @__PURE__ */ e.jsx(g.Item, { label: n("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(L, { addonBefore: "role_" }) }),
33
- /* @__PURE__ */ e.jsx(g.Item, { name: "permissions", children: /* @__PURE__ */ e.jsx(k, {}) })
32
+ /* @__PURE__ */ e.jsx(g.Item, { label: n("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(A, { addonBefore: "role_" }) }),
33
+ /* @__PURE__ */ e.jsx(g.Item, { name: "permissions", children: /* @__PURE__ */ e.jsx(v, {}) })
34
34
  ] }),
35
35
  onConfirm: l
36
36
  });
37
37
  }, W = () => {
38
- const { message: c } = f.useApp(), { mutate: r } = y(), a = D(), n = b();
39
- return S({
38
+ const { message: c } = f.useApp(), { mutate: r } = y(), a = N(), n = b();
39
+ return L({
40
40
  title: n("RoleList.updateTitle"),
41
41
  width: "50vw",
42
42
  content: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
43
- /* @__PURE__ */ e.jsx(g.Item, { label: n("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(L, { readOnly: !0, addonBefore: "role_" }) }),
44
- /* @__PURE__ */ e.jsx(g.Item, { name: "permissions", children: /* @__PURE__ */ e.jsx(k, {}) })
43
+ /* @__PURE__ */ e.jsx(g.Item, { label: n("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(A, { readOnly: !0, addonBefore: "role_" }) }),
44
+ /* @__PURE__ */ e.jsx(g.Item, { name: "permissions", children: /* @__PURE__ */ e.jsx(v, {}) })
45
45
  ] }),
46
46
  onConfirm: async (l, o) => {
47
47
  await a.trigger({
@@ -50,7 +50,7 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
50
50
  permissions: l.permissions
51
51
  }), r(
52
52
  h,
53
- (x) => A(x, (m) => {
53
+ (x) => k(x, (m) => {
54
54
  var p;
55
55
  const u = (p = m == null ? void 0 : m.dataSource) == null ? void 0 : p.find((t) => t.id === (o == null ? void 0 : o.id));
56
56
  u && (u.permissions = l.permissions);
@@ -60,12 +60,12 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
60
60
  }
61
61
  });
62
62
  }, oe = () => {
63
- const { accessible: c } = N("200005", !0), { modal: r, message: a } = f.useApp(), { usePermissionApiV2: n } = P(), l = E(), { mutate: o } = y(), { show: x, modal: m } = J(), { show: u, modal: p } = W(), t = b(), M = [
63
+ const { accessible: c } = P("200005", !0), { modal: r, message: a } = f.useApp(), { usePermissionApiV2: n } = _(), l = q(), { mutate: o } = y(), { show: x, modal: m } = J(), { show: u, modal: p } = W(), t = b(), S = [
64
64
  {
65
65
  title: t("global.name"),
66
66
  key: "name",
67
67
  render(s) {
68
- return c ? /* @__PURE__ */ e.jsx(B, { to: `${s.name}`, relative: "path", children: s.name }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: s.name });
68
+ return c ? /* @__PURE__ */ e.jsx(E, { to: `${s.name}`, relative: "path", children: s.name }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: s.name });
69
69
  }
70
70
  },
71
71
  {
@@ -82,18 +82,18 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
82
82
  title: t("global.operation"),
83
83
  width: 150,
84
84
  align: "center",
85
- render: (s) => /* @__PURE__ */ e.jsxs(F, { size: "small", children: [
85
+ render: (s) => /* @__PURE__ */ e.jsxs(G, { size: "small", children: [
86
86
  /* @__PURE__ */ e.jsx(
87
87
  j,
88
88
  {
89
- isGlobalNS: !0,
89
+ isGlobal: !0,
90
90
  code: "200003",
91
91
  size: "small",
92
92
  type: "link",
93
93
  onClick: async () => {
94
- const { data: i } = await _(
94
+ const { data: i } = await z(
95
95
  `/api/usystem/role/info${n ? "V2" : ""}?name=${s.name}`,
96
- { isGlobalNS: !0 }
96
+ { isGlobal: !0 }
97
97
  );
98
98
  u({
99
99
  initialValues: {
@@ -111,7 +111,7 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
111
111
  /* @__PURE__ */ e.jsx(
112
112
  j,
113
113
  {
114
- isGlobalNS: !0,
114
+ isGlobal: !0,
115
115
  danger: !0,
116
116
  code: "200004",
117
117
  size: "small",
@@ -119,12 +119,12 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
119
119
  onClick: () => {
120
120
  r.confirm({
121
121
  title: t("RoleList.deleteTitle"),
122
- content: /* @__PURE__ */ e.jsx(z, { texts: [s.name], children: t("RoleList.deleteContent", { role: s.name }) }),
122
+ content: /* @__PURE__ */ e.jsx($, { texts: [s.name], children: t("RoleList.deleteContent", { role: s.name }) }),
123
123
  async onOk() {
124
124
  await l.trigger({
125
125
  id: s.id,
126
126
  name: s.name
127
- }), o(h, (i) => A(i, (d) => {
127
+ }), o(h, (i) => k(i, (d) => {
128
128
  var R, C;
129
129
  const w = (R = d == null ? void 0 : d.dataSource) == null ? void 0 : R.findIndex((O) => O.id === s.id);
130
130
  w && ((C = d == null ? void 0 : d.dataSource) == null || C.splice(w, 1));
@@ -140,13 +140,13 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
140
140
  ];
141
141
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
142
142
  /* @__PURE__ */ e.jsx(
143
- G,
143
+ B,
144
144
  {
145
145
  title: t("global.role"),
146
146
  extra: /* @__PURE__ */ e.jsx(
147
147
  j,
148
148
  {
149
- isGlobalNS: !0,
149
+ isGlobal: !0,
150
150
  type: "primary",
151
151
  code: "200002",
152
152
  icon: /* @__PURE__ */ e.jsx(K, {}),
@@ -157,11 +157,11 @@ const K = /* @__PURE__ */ v.forwardRef(I), h = "/api/usystem/role/list", J = ()
157
157
  }
158
158
  ),
159
159
  children: /* @__PURE__ */ e.jsx(
160
- $,
160
+ F,
161
161
  {
162
- isGlobalNS: !0,
162
+ isGlobal: !0,
163
163
  rowKey: "name",
164
- columns: M,
164
+ columns: S,
165
165
  code: "200001",
166
166
  action: h,
167
167
  getTotal: (s) => s.Total,
@@ -1,8 +1,8 @@
1
- import { a as t, j as i } from "./index-WjQ2L06b.chunk.js";
1
+ import { a as t, j as i } from "./index--xP5ZRwk.chunk.js";
2
2
  import { Breadcrumb as m, Card as n, Skeleton as a, Descriptions as l } from "antd";
3
3
  import { useParams as c, Link as x } from "react-router-dom";
4
- import { P as j } from "./index-PdAloIXt.chunk.js";
5
- import { g as p } from "./index-EcHXdtfc.chunk.js";
4
+ import { P as j } from "./index-0LeTY9YL.chunk.js";
5
+ import { g as p } from "./index-j7kGPvUz.chunk.js";
6
6
  import "react";
7
7
  import "react-dom";
8
8
  const k = () => {
@@ -1,13 +1,13 @@
1
- import { I as O, w as W, e as h, f as x, s as z, m as w, g as V, U as R, h as U, d as G, r as n, c as K } from "./index-WjQ2L06b.chunk.js";
2
- import L, { useRef as o, useCallback as N, useState as $ } from "react";
3
- const P = O ? (e) => {
1
+ import { I as W, w as x, e as h, f as z, s as K, m as G, g as P, U as R, h as v, d as S, r as n, c as L } from "./index--xP5ZRwk.chunk.js";
2
+ import N, { useRef as o, useCallback as M, useState as $ } from "react";
3
+ const U = W ? (e) => {
4
4
  e();
5
- } : L.startTransition, j = (e) => {
5
+ } : N.startTransition, j = (e) => {
6
6
  const [, t] = $({}), r = o(!1), i = o(e), d = o({
7
7
  data: !1,
8
8
  error: !1,
9
9
  isValidating: !1
10
- }), m = N((c) => {
10
+ }), m = M((c) => {
11
11
  let a = !1;
12
12
  const g = i.current;
13
13
  for (const p in c) {
@@ -16,7 +16,7 @@ const P = O ? (e) => {
16
16
  }
17
17
  a && !r.current && t({});
18
18
  }, []);
19
- return U(() => (r.current = !1, () => {
19
+ return v(() => (r.current = !1, () => {
20
20
  r.current = !0;
21
21
  })), [
22
22
  i,
@@ -24,108 +24,108 @@ const P = O ? (e) => {
24
24
  m
25
25
  ];
26
26
  }, q = () => (e, t, r = {}) => {
27
- const { mutate: i } = x(), d = o(e), m = o(t), c = o(r), a = o(0), [g, p, s] = j({
27
+ const { mutate: i } = z(), d = o(e), m = o(t), c = o(r), a = o(0), [g, p, s] = j({
28
28
  data: R,
29
29
  error: R,
30
30
  isMutating: !1
31
- }), S = g.current, v = N(
32
- async (T, k) => {
33
- const [y, I] = z(d.current);
31
+ }), b = g.current, D = M(
32
+ async (k, I) => {
33
+ const [y, O] = K(d.current);
34
34
  if (!m.current)
35
35
  throw new Error("Can’t trigger the mutation: missing fetcher.");
36
36
  if (!y)
37
37
  throw new Error("Can’t trigger the mutation: missing key.");
38
- const l = w(w({
38
+ const l = G(G({
39
39
  populateCache: !1,
40
40
  throwOnError: !0
41
- }, c.current), k), b = V();
42
- a.current = b, s({
41
+ }, c.current), I), w = P();
42
+ a.current = w, s({
43
43
  isMutating: !0
44
44
  });
45
45
  try {
46
46
  const u = await i(
47
47
  y,
48
- m.current(I, {
49
- arg: T
48
+ m.current(O, {
49
+ arg: k
50
50
  }),
51
51
  // We must throw the error here so we can catch and update the states.
52
- w(l, {
52
+ G(l, {
53
53
  throwOnError: !0
54
54
  })
55
55
  );
56
- if (a.current <= b) {
57
- var M, C;
58
- P(() => s({
56
+ if (a.current <= w) {
57
+ var C, E;
58
+ U(() => s({
59
59
  data: u,
60
60
  isMutating: !1,
61
61
  error: void 0
62
- })), (M = (C = l).onSuccess) == null || M.call(C, u, y, l);
62
+ })), (C = (E = l).onSuccess) == null || C.call(E, u, y, l);
63
63
  }
64
64
  return u;
65
65
  } catch (u) {
66
- if (a.current <= b) {
67
- var E, A;
68
- if (P(() => s({
66
+ if (a.current <= w) {
67
+ var A, V;
68
+ if (U(() => s({
69
69
  error: u,
70
70
  isMutating: !1
71
- })), (E = (A = l).onError) == null || E.call(A, u, y, l), l.throwOnError)
71
+ })), (A = (V = l).onError) == null || A.call(V, u, y, l), l.throwOnError)
72
72
  throw u;
73
73
  }
74
74
  }
75
75
  },
76
76
  // eslint-disable-next-line react-hooks/exhaustive-deps
77
77
  []
78
- ), D = N(() => {
79
- a.current = V(), s({
78
+ ), T = M(() => {
79
+ a.current = P(), s({
80
80
  data: R,
81
81
  error: R,
82
82
  isMutating: !1
83
83
  });
84
84
  }, []);
85
- return U(() => {
85
+ return v(() => {
86
86
  d.current = e, m.current = t, c.current = r;
87
87
  }), {
88
- trigger: v,
89
- reset: D,
88
+ trigger: D,
89
+ reset: T,
90
90
  get data() {
91
- return p.data = !0, S.data;
91
+ return p.data = !0, b.data;
92
92
  },
93
93
  get error() {
94
- return p.error = !0, S.error;
94
+ return p.error = !0, b.error;
95
95
  },
96
96
  get isMutating() {
97
- return p.isMutating = !0, S.isMutating;
97
+ return p.isMutating = !0, b.isMutating;
98
98
  }
99
99
  };
100
- }, f = W(h, q);
100
+ }, f = x(h, q);
101
101
  function B() {
102
102
  return h(
103
103
  "/api/usystem/user/allPermssions",
104
- (e) => n(e, { isGlobalNS: !0 }).then((t) => t.data)
104
+ (e) => n(e, { isGlobal: !0 }).then((t) => t.data)
105
105
  );
106
106
  }
107
107
  function H() {
108
108
  return h(
109
109
  "/api/usystem/user/allPermissionsV2",
110
- (e) => n(e, { isGlobalNS: !0 }).then((t) => t.data)
110
+ (e) => n(e, { isGlobal: !0 }).then((t) => t.data)
111
111
  );
112
112
  }
113
113
  function J() {
114
- const { accessible: e } = K("200005", !0);
114
+ const { accessible: e } = L("200005", !0);
115
115
  return h(
116
116
  e ? "/api/usystem/role/all" : null,
117
- (t) => n(t, { isGlobalNS: !0 }).then((r) => r.data)
117
+ (t) => n(t, { isGlobal: !0 }).then((r) => r.data)
118
118
  );
119
119
  }
120
120
  function Q(e) {
121
- const { usePermissionApiV2: t } = G();
121
+ const { usePermissionApiV2: t } = S();
122
122
  return h(
123
123
  `/api/usystem/role/${t ? "infoV2" : "info"}?name=${e}`,
124
- (r) => n(r, { isGlobalNS: !0 }).then((i) => i.data)
124
+ (r) => n(r, { isGlobal: !0 }).then((i) => i.data)
125
125
  );
126
126
  }
127
127
  function X() {
128
- const { usePermissionApiV2: e } = G();
128
+ const { usePermissionApiV2: e } = S();
129
129
  return f(
130
130
  e ? "/api/usystem/role/createV2" : "/api/usystem/role/create",
131
131
  (t, {
@@ -133,12 +133,12 @@ function X() {
133
133
  }) => n(t, {
134
134
  method: "post",
135
135
  body: r,
136
- isGlobalNS: !0
136
+ isGlobal: !0
137
137
  })
138
138
  );
139
139
  }
140
140
  function Z() {
141
- const { usePermissionApiV2: e } = G();
141
+ const { usePermissionApiV2: e } = S();
142
142
  return f(
143
143
  e ? "/api/usystem/role/updateV2" : "/api/usystem/role/update",
144
144
  (t, {
@@ -146,7 +146,7 @@ function Z() {
146
146
  }) => n(t, {
147
147
  method: "post",
148
148
  body: r,
149
- isGlobalNS: !0
149
+ isGlobal: !0
150
150
  })
151
151
  );
152
152
  }
@@ -158,7 +158,7 @@ function _() {
158
158
  }) => n(e, {
159
159
  method: "post",
160
160
  body: t,
161
- isGlobalNS: !0
161
+ isGlobal: !0
162
162
  })
163
163
  );
164
164
  }
@@ -170,7 +170,7 @@ function ee() {
170
170
  }) => n(e, {
171
171
  method: "post",
172
172
  body: t,
173
- isGlobalNS: !0
173
+ isGlobal: !0
174
174
  })
175
175
  );
176
176
  }
@@ -182,7 +182,7 @@ function te() {
182
182
  }) => n(e, {
183
183
  method: "post",
184
184
  body: t,
185
- isGlobalNS: !0
185
+ isGlobal: !0
186
186
  })
187
187
  );
188
188
  }
@@ -194,7 +194,7 @@ function re() {
194
194
  }) => n(e, {
195
195
  method: "post",
196
196
  body: t,
197
- isGlobalNS: !0
197
+ isGlobal: !0
198
198
  })
199
199
  );
200
200
  }
@@ -1,14 +1,14 @@
1
- import { A as T, _ as N, u as j, a as b, j as e, P as h, H as R, Q as z, b as w } from "./index-WjQ2L06b.chunk.js";
2
- import { App as U, Row as F, Col as P, Tag as A, Space as E, Card as G, Form as x, Input as L, Select as y } from "antd";
1
+ import { A as T, _ as R, u as j, a as b, j as e, P as h, H as z, Q as F, b as L } from "./index--xP5ZRwk.chunk.js";
2
+ import { App as U, Row as P, Col as E, Tag as w, Space as G, Card as D, Form as x, Input as S, Select as y } from "antd";
3
3
  import { p as I } from "./immer-BLf7GM7E.chunk.js";
4
- import { Link as D } from "react-router-dom";
5
- import { u as Q, a as _, b as k, c as $ } from "./index-EcHXdtfc.chunk.js";
4
+ import { Link as N } from "react-router-dom";
5
+ import { u as Q, a as _, b as k, c as $ } from "./index-j7kGPvUz.chunk.js";
6
6
  import * as M from "react";
7
7
  import "react-dom";
8
8
  var q = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M678.3 642.4c24.2-13 51.9-20.4 81.4-20.4h.1c3 0 4.4-3.6 2.2-5.6a371.67 371.67 0 00-103.7-65.8c-.4-.2-.8-.3-1.2-.5C719.2 505 759.6 431.7 759.6 349c0-137-110.8-248-247.5-248S264.7 212 264.7 349c0 82.7 40.4 156 102.6 201.1-.4.2-.8.3-1.2.5-44.7 18.9-84.8 46-119.3 80.6a373.42 373.42 0 00-80.4 119.5A373.6 373.6 0 00137 888.8a8 8 0 008 8.2h59.9c4.3 0 7.9-3.5 8-7.8 2-77.2 32.9-149.5 87.6-204.3C357 628.2 432.2 597 512.2 597c56.7 0 111.1 15.7 158 45.1a8.1 8.1 0 008.1.3zM512.2 521c-45.8 0-88.9-17.9-121.4-50.4A171.2 171.2 0 01340.5 349c0-45.9 17.9-89.1 50.3-121.6S466.3 177 512.2 177s88.9 17.9 121.4 50.4A171.2 171.2 0 01683.9 349c0 45.9-17.9 89.1-50.3 121.6C601.1 503.1 558 521 512.2 521zM880 759h-84v-84c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v84h-84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h84v84c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-84h84c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z" } }] }, name: "user-add", theme: "outlined" };
9
9
  const B = q;
10
10
  var O = function(i, n) {
11
- return /* @__PURE__ */ M.createElement(T, N({}, i, {
11
+ return /* @__PURE__ */ M.createElement(T, R({}, i, {
12
12
  ref: n,
13
13
  icon: B
14
14
  }));
@@ -17,13 +17,13 @@ process.env.NODE_ENV !== "production" && (O.displayName = "UserAddOutlined");
17
17
  const H = /* @__PURE__ */ M.forwardRef(O), { Option: K } = y, g = "/api/usystem/user/list";
18
18
  function J() {
19
19
  const { message: d } = U.useApp(), i = _(), { data: n, isLoading: u } = k(), { setPayload: m } = j(), o = b();
20
- return w({
20
+ return L({
21
21
  title: o("UserList.createTitle"),
22
22
  formProps: {
23
23
  labelCol: { flex: "80px" }
24
24
  },
25
25
  content: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
26
- /* @__PURE__ */ e.jsx(x.Item, { label: o("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(L, {}) }),
26
+ /* @__PURE__ */ e.jsx(x.Item, { label: o("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(S, {}) }),
27
27
  /* @__PURE__ */ e.jsx(x.Item, { label: o("global.role"), name: "roles", children: /* @__PURE__ */ e.jsx(y, { allowClear: !0, mode: "multiple", loading: u, children: (n ?? []).map((t) => /* @__PURE__ */ e.jsx(K, { value: t.name, children: t.name }, t.id)) }) })
28
28
  ] }),
29
29
  async onConfirm(t) {
@@ -33,13 +33,13 @@ function J() {
33
33
  }
34
34
  function W() {
35
35
  const { message: d } = U.useApp(), i = $(), { data: n, isLoading: u } = k(), { mutate: m } = j(), o = b();
36
- return w({
36
+ return L({
37
37
  title: o("UserList.updateTitle"),
38
38
  formProps: {
39
39
  labelCol: { flex: "80px" }
40
40
  },
41
41
  content: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
42
- /* @__PURE__ */ e.jsx(x.Item, { label: o("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(L, { readOnly: !0 }) }),
42
+ /* @__PURE__ */ e.jsx(x.Item, { label: o("global.name"), name: "name", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(S, { readOnly: !0 }) }),
43
43
  /* @__PURE__ */ e.jsx(x.Item, { label: o("global.role"), name: "roles", children: /* @__PURE__ */ e.jsx(
44
44
  y,
45
45
  {
@@ -86,7 +86,7 @@ const te = () => {
86
86
  key: "roles",
87
87
  width: "40%",
88
88
  render(s) {
89
- return /* @__PURE__ */ e.jsx(F, { gutter: [4, 4], children: (s || []).map((l) => /* @__PURE__ */ e.jsx(P, { children: l === "root" ? /* @__PURE__ */ e.jsx(A, { color: "#f50", children: l }) : /* @__PURE__ */ e.jsx(A, { color: "#ff5a00", children: /* @__PURE__ */ e.jsx(D, { to: `/permission/role/${l}`, children: l }) }) }, l)) });
89
+ return /* @__PURE__ */ e.jsx(P, { gutter: [4, 4], children: (s || []).map((l) => /* @__PURE__ */ e.jsx(E, { children: l === "root" ? /* @__PURE__ */ e.jsx(w, { color: "#f50", children: l }) : /* @__PURE__ */ e.jsx(w, { color: "#ff5a00", children: /* @__PURE__ */ e.jsx(N, { to: `/permission/role/${l}`, children: l }) }) }, l)) });
90
90
  }
91
91
  },
92
92
  {
@@ -98,11 +98,11 @@ const te = () => {
98
98
  title: a("global.operation"),
99
99
  width: 150,
100
100
  align: "center",
101
- render: (s) => /* @__PURE__ */ e.jsxs(E, { children: [
101
+ render: (s) => /* @__PURE__ */ e.jsxs(G, { children: [
102
102
  /* @__PURE__ */ e.jsx(
103
103
  h,
104
104
  {
105
- isGlobalNS: !0,
105
+ isGlobal: !0,
106
106
  size: "small",
107
107
  type: "link",
108
108
  code: "100003",
@@ -123,7 +123,7 @@ const te = () => {
123
123
  /* @__PURE__ */ e.jsx(
124
124
  h,
125
125
  {
126
- isGlobalNS: !0,
126
+ isGlobal: !0,
127
127
  danger: !0,
128
128
  size: "small",
129
129
  code: "100004",
@@ -131,15 +131,15 @@ const te = () => {
131
131
  onClick: () => {
132
132
  d.confirm({
133
133
  title: a("UserList.deleteTitle"),
134
- content: /* @__PURE__ */ e.jsx(R, { texts: [s.name], children: a("UserList.deleteContent", { user: s.name }) }),
134
+ content: /* @__PURE__ */ e.jsx(z, { texts: [s.name], children: a("UserList.deleteContent", { user: s.name }) }),
135
135
  async onOk() {
136
136
  await n.trigger({
137
137
  id: s.id,
138
138
  name: s.name
139
139
  }), u(g, (l) => I(l, (r) => {
140
- var C, S;
140
+ var C, A;
141
141
  const f = (C = r == null ? void 0 : r.dataSource) == null ? void 0 : C.findIndex((v) => v.id === s.id);
142
- f && ((S = r == null ? void 0 : r.dataSource) == null || S.splice(f, 1));
142
+ f && ((A = r == null ? void 0 : r.dataSource) == null || A.splice(f, 1));
143
143
  })), i.success(a("UserList.deleteSuccessfully"));
144
144
  }
145
145
  });
@@ -152,13 +152,13 @@ const te = () => {
152
152
  ];
153
153
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
154
154
  /* @__PURE__ */ e.jsx(
155
- G,
155
+ D,
156
156
  {
157
157
  title: a("global.user"),
158
158
  extra: /* @__PURE__ */ e.jsx(
159
159
  h,
160
160
  {
161
- isGlobalNS: !0,
161
+ isGlobal: !0,
162
162
  type: "primary",
163
163
  icon: /* @__PURE__ */ e.jsx(H, {}),
164
164
  code: "100002",
@@ -169,9 +169,9 @@ const te = () => {
169
169
  }
170
170
  ),
171
171
  children: /* @__PURE__ */ e.jsx(
172
- z,
172
+ F,
173
173
  {
174
- isGlobalNS: !0,
174
+ isGlobal: !0,
175
175
  code: "100001",
176
176
  action: g,
177
177
  rowKey: "id",
package/lib/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export declare interface ContextState {
44
44
  key: Key;
45
45
  children: ReactNode;
46
46
  }[];
47
+ isGlobal?: boolean;
47
48
  }
48
49
 
49
50
  export declare const contextStore: StoreApi<ContextState>;
@@ -112,7 +113,7 @@ export declare interface InfiniteListProps<Item, Values, Response> extends Pick<
112
113
  renderForm?: (form: FormInstance<Values>) => ReactNode;
113
114
  transformArg: (values: Values | undefined, rowKey?: string) => Record<any, any>;
114
115
  hasMore?: (data: Response[] | undefined) => boolean;
115
- isGlobalNS?: boolean;
116
+ isGlobal?: boolean;
116
117
  extras?: InfiniteListExtra<Values>[];
117
118
  }
118
119
 
@@ -252,7 +253,7 @@ export declare const PermissionButton: FC<PropsWithChildren<PermissionButtonProp
252
253
  export declare interface PermissionButtonProps extends Omit<ButtonProps, 'disabled'> {
253
254
  code: string | string[];
254
255
  showLoading?: boolean;
255
- isGlobalNS?: boolean;
256
+ isGlobal?: boolean;
256
257
  }
257
258
 
258
259
  export declare const PermissionGuard: FC<PropsWithChildren<PermissionGuardProps>>;
@@ -287,7 +288,7 @@ declare interface QueryListPayload<Arg = any> {
287
288
 
288
289
  export declare interface QueryListProps<Item = any, Values = any, Response = any, Arg extends Values = Values> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'> {
289
290
  code?: string;
290
- isGlobalNS?: boolean;
291
+ isGlobal?: boolean;
291
292
  action: string;
292
293
  method?: string;
293
294
  refreshInterval?: number;
@@ -337,7 +338,7 @@ declare interface RequestOptions extends Omit<RequestInit, 'body'> {
337
338
  body?: Record<string | number, any> | FormData | null;
338
339
  params?: Record<string | number, any> | URLSearchParams | null;
339
340
  responseType?: 'json' | 'blob';
340
- isGlobalNS?: boolean;
341
+ isGlobal?: boolean;
341
342
  }
342
343
 
343
344
  declare type RequestResponse<T> = Pick<Response, 'headers' | 'status' | 'statusText' | 'url'> & {
@@ -406,13 +407,13 @@ declare interface UseModalProps extends Omit<ModalProps, 'open' | 'confirmLoadin
406
407
 
407
408
  export declare const useModalStore: UseBoundStore<StoreApi<ModalState>>;
408
409
 
409
- export declare function usePermission(code: string | undefined, isGlobalNS?: boolean, config?: SWRConfiguration): {
410
+ export declare function usePermission(code: string | undefined, isGlobal?: boolean, config?: SWRConfiguration): {
410
411
  accessible: boolean;
411
412
  isValidating: boolean;
412
413
  isLoading: boolean;
413
414
  };
414
415
 
415
- export declare function usePermissions(codes: string[], isGlobalNS?: boolean, config?: SWRConfiguration): {
416
+ export declare function usePermissions(codes: string[], isGlobal?: boolean, config?: SWRConfiguration): {
416
417
  data: Record<string, boolean> | undefined;
417
418
  isValidating: boolean;
418
419
  isLoading: boolean;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as r, D as u, F as n, G as m, H as d, i as l, L as p, N as L, k as S, O as g, l as y, P, n as x, Q as c, o as F, R as G, p as M, S as T, q as h, t as k, v as q, r as Q, b as R, x as v, y as B, z as C, c as N, B as f, u as w, E as D, J as E, d as H, a as I, K as O, M as W } from "./index-WjQ2L06b.chunk.js";
1
+ import { C as r, D as u, F as n, G as m, H as d, i as l, L as p, N as L, k as S, O as g, l as y, P, n as x, Q as c, o as F, R as G, p as M, S as T, q as h, t as k, v as q, r as Q, b as R, x as v, y as B, z as C, c as N, B as f, u as w, E as D, J as E, d as H, a as I, K as O, M as W } from "./index--xP5ZRwk.chunk.js";
2
2
  import "react";
3
3
  import "antd";
4
4
  import "react-dom";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-toolkits",
3
- "version": "0.8.36",
3
+ "version": "0.8.37",
4
4
  "packageManager": "^pnpm@8.7.5",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -70,8 +70,8 @@
70
70
  "vite": "^5.0.10",
71
71
  "vite-plugin-dts": "^3.6.4",
72
72
  "@flow97/eslint-config-mono": "0.0.4",
73
- "tsconfig": "0.0.5",
74
- "tailwind-config": "0.1.1"
73
+ "tailwind-config": "0.1.1",
74
+ "tsconfig": "0.0.5"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "antd": "^5.12.2",