bitz-react-admin-ui 1.9.3 → 1.9.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.
@@ -1,15 +1,18 @@
1
1
  /// <reference types="react" />
2
+ import { DensitySize } from '../BitzTable/Store';
2
3
  export type ToolEnum = 'export' | 'refresh' | 'size' | 'fullscreen' | 'colConfig';
3
4
  /** 控制table的全局行为 */
4
5
  export interface TableComponentContextProps {
5
- /** 根据从左到右方向排序,不在数组中则不显示 */
6
- toolbar?: ToolEnum[];
7
6
  /** 是否显示外边框和列边框 */
8
7
  bordered?: boolean;
8
+ /** 默认size */
9
+ defaultSize?: DensitySize;
9
10
  /** 是否开启斑马纹,填充偶数行背景色 */
10
11
  fillEvenRow?: boolean;
11
12
  /** 是否开启rowHover样式 */
12
13
  rowHoverable?: boolean;
14
+ /** 根据从左到右方向排序,不在数组中则不显示 */
15
+ toolbar?: ToolEnum[];
13
16
  }
14
17
  export interface BitzConfigProviderContextProps {
15
18
  Table?: TableComponentContextProps;
@@ -50,6 +50,7 @@ declare function useContainer(props: UseContainerProps): {
50
50
  columnsMap: Record<string, ColumnsConfigProps>;
51
51
  setColumnsMap: (updater: Record<string, ColumnsConfigProps> | ((origin: Record<string, ColumnsConfigProps>) => Record<string, ColumnsConfigProps>), ignoreDestroy?: boolean | undefined) => void;
52
52
  setTableSize: (updater: DensitySize | ((origin: DensitySize) => DensitySize), ignoreDestroy?: boolean | undefined) => void;
53
+ defaultTableSize: "xl" | "lg" | "md" | "sm" | "xs";
53
54
  tableSize: DensitySize;
54
55
  sizeStorageType: "online" | "localStorage" | "sessionStorage" | undefined;
55
56
  sizeStorageKey: any;
@@ -68,6 +69,7 @@ declare const TableContext: import("react").Context<{
68
69
  columnsMap: Record<string, ColumnsConfigProps>;
69
70
  setColumnsMap: (updater: Record<string, ColumnsConfigProps> | ((origin: Record<string, ColumnsConfigProps>) => Record<string, ColumnsConfigProps>), ignoreDestroy?: boolean | undefined) => void;
70
71
  setTableSize: (updater: DensitySize | ((origin: DensitySize) => DensitySize), ignoreDestroy?: boolean | undefined) => void;
72
+ defaultTableSize: "xl" | "lg" | "md" | "sm" | "xs";
71
73
  tableSize: DensitySize;
72
74
  sizeStorageType: "online" | "localStorage" | "sessionStorage" | undefined;
73
75
  sizeStorageKey: any;
@@ -1,209 +1,211 @@
1
1
  import { j as A } from "../../../node_modules/.store/react@18.2.0/node_modules/react/jsx-runtime.mjs";
2
- import U from "../../../hooks/useMergedState.mjs";
3
- import { createContext as B, useRef as q, useEffect as r, useMemo as D, useCallback as F } from "react";
4
- import { genColumnKey as H } from "./utils/index.mjs";
5
- import { getUuid as L } from "../../../utils/uuid.mjs";
2
+ import G from "../../../hooks/useMergedState.mjs";
3
+ import { createContext as F, useRef as U, useContext as H, useEffect as m, useMemo as L, useCallback as Q } from "react";
4
+ import { genColumnKey as W } from "./utils/index.mjs";
5
+ import { getUuid as X } from "../../../utils/uuid.mjs";
6
+ import { BitzConfigContext as Y } from "../../BitzConfigProvider/context.mjs";
6
7
  import d from "../../../node_modules/.store/lodash-es@4.17.21/node_modules/lodash-es/merge.mjs";
7
- function Q(e) {
8
- var T, V, v, O, J, M, N, b, j, x, I, P, E, k, R, G;
9
- const f = q(L()), w = q([]), { defaultSize: h = "lg" } = e, [g, C] = U(
8
+ function Z(e) {
9
+ var T, V, v, O, b, x, J, M, N, j, I, P, E, k, R, B, D;
10
+ const r = U(X()), w = U([]), q = (T = H(Y).Table) == null ? void 0 : T.defaultSize, z = e.defaultSize ?? q ?? "lg", [h, g] = G(
10
11
  () => {
11
- var n, a, i, l;
12
- const { persistenceType: t, persistenceKey: c, onlineGet: u } = e.sizeState || {};
13
- if (c && t && typeof window < "u" && t !== "online") {
12
+ var n, c, a, l;
13
+ const { persistenceType: t, persistenceKey: i, onlineGet: u } = e.sizeState || {};
14
+ if (i && t && typeof window < "u" && t !== "online") {
14
15
  const o = window[t];
15
16
  try {
16
- const s = o == null ? void 0 : o.getItem(c);
17
+ const s = o == null ? void 0 : o.getItem(i);
17
18
  if (s)
18
19
  return (n = e == null ? void 0 : e.sizeState) != null && n.defaultValue ? d(
19
20
  JSON.parse(s),
20
- (a = e == null ? void 0 : e.sizeState) == null ? void 0 : a.defaultValue
21
+ (c = e == null ? void 0 : e.sizeState) == null ? void 0 : c.defaultValue
21
22
  ) : JSON.parse(s);
22
23
  } catch (s) {
23
24
  console.warn(s);
24
25
  }
25
26
  }
26
- return e.size || ((i = e.sizeState) == null ? void 0 : i.value) || ((l = e.sizeState) == null ? void 0 : l.defaultValue) || h;
27
+ return e.size || ((a = e.sizeState) == null ? void 0 : a.value) || ((l = e.sizeState) == null ? void 0 : l.defaultValue) || z;
27
28
  },
28
29
  {
29
- value: ((T = e.sizeState) == null ? void 0 : T.value) || e.size,
30
- onChange: ((V = e.sizeState) == null ? void 0 : V.onChange) || e.onSizeChange
30
+ value: ((V = e.sizeState) == null ? void 0 : V.value) || e.size,
31
+ onChange: ((v = e.sizeState) == null ? void 0 : v.onChange) || e.onSizeChange
31
32
  }
32
33
  );
33
- r(() => {
34
+ m(() => {
34
35
  var u, n;
35
36
  if (!((u = e.sizeState) != null && u.persistenceKey) || !((n = e.sizeState) != null && n.persistenceType) || typeof window > "u")
36
37
  return;
37
38
  const {
38
39
  persistenceType: t,
39
- persistenceKey: c
40
+ persistenceKey: i
40
41
  // onlineChange
41
42
  } = e.sizeState;
42
43
  if (t !== "online") {
43
- const a = window[t];
44
+ const c = window[t];
44
45
  try {
45
- a == null || a.setItem(c, JSON.stringify(y));
46
- } catch (i) {
47
- console.warn(i), z();
46
+ c == null || c.setItem(i, JSON.stringify(y));
47
+ } catch (a) {
48
+ console.warn(a), K();
48
49
  }
49
50
  }
50
51
  }, [
51
- (v = e.sizeState) == null ? void 0 : v.persistenceKey,
52
- g,
53
- (O = e.sizeState) == null ? void 0 : O.persistenceType
54
- ]), r(() => {
55
- var t, c, u;
56
- if ((t = e.sizeState) != null && t.persistenceKey && ((c = e.sizeState) == null ? void 0 : c.persistenceType) === "online") {
57
- const { onlineGet: n, persistenceKey: a } = e.sizeState;
52
+ (O = e.sizeState) == null ? void 0 : O.persistenceKey,
53
+ h,
54
+ (b = e.sizeState) == null ? void 0 : b.persistenceType
55
+ ]), m(() => {
56
+ var t, i, u;
57
+ if ((t = e.sizeState) != null && t.persistenceKey && ((i = e.sizeState) == null ? void 0 : i.persistenceType) === "online") {
58
+ const { onlineGet: n, persistenceKey: c } = e.sizeState;
58
59
  try {
59
- (u = n == null ? void 0 : n(a)) == null || u.then((i) => {
60
+ (u = n == null ? void 0 : n(c)) == null || u.then((a) => {
60
61
  var l;
61
- C(i ?? ((l = e == null ? void 0 : e.sizeState) == null ? void 0 : l.value) ?? h);
62
+ g(a ?? ((l = e == null ? void 0 : e.sizeState) == null ? void 0 : l.value) ?? z);
62
63
  });
63
- } catch (i) {
64
- console.warn(i);
64
+ } catch (a) {
65
+ console.warn(a);
65
66
  }
66
67
  }
67
68
  }, []);
68
- const S = D(() => {
69
- var c, u;
70
- if ((c = e == null ? void 0 : e.columnsState) != null && c.defaultValue)
69
+ const S = L(() => {
70
+ var i, u;
71
+ if ((i = e == null ? void 0 : e.columnsState) != null && i.defaultValue)
71
72
  return e.columnsState.defaultValue;
72
73
  const t = {};
73
- return (u = e.columns) == null || u.forEach(({ key: n, dataIndex: a, fixed: i, disable: l }, o) => {
74
- const s = H(n ?? a, o);
74
+ return (u = e.columns) == null || u.forEach(({ key: n, dataIndex: c, fixed: a, disable: l }, o) => {
75
+ const s = W(n ?? c, o);
75
76
  s && (t[s] = {
76
77
  show: !0,
77
- fixed: i,
78
+ fixed: a,
78
79
  disable: l
79
80
  });
80
81
  }), t;
81
- }, [e.columns]), [y, m] = U(
82
+ }, [e.columns]), [y, f] = G(
82
83
  () => {
83
- var n, a, i, l;
84
- const { persistenceType: t, persistenceKey: c, onlineGet: u } = e.columnsState || {};
85
- if (c && t && typeof window < "u" && t !== "online") {
84
+ var n, c, a, l;
85
+ const { persistenceType: t, persistenceKey: i, onlineGet: u } = e.columnsState || {};
86
+ if (i && t && typeof window < "u" && t !== "online") {
86
87
  const o = window[t];
87
88
  try {
88
- const s = o == null ? void 0 : o.getItem(c);
89
+ const s = o == null ? void 0 : o.getItem(i);
89
90
  if (s)
90
91
  return (n = e == null ? void 0 : e.columnsState) != null && n.defaultValue ? d(
91
92
  JSON.parse(s),
92
- (a = e == null ? void 0 : e.columnsState) == null ? void 0 : a.defaultValue
93
+ (c = e == null ? void 0 : e.columnsState) == null ? void 0 : c.defaultValue
93
94
  ) : JSON.parse(s);
94
95
  } catch (s) {
95
96
  console.warn(s);
96
97
  }
97
98
  }
98
- return e.columnsStateMap || ((i = e.columnsState) == null ? void 0 : i.value) || ((l = e.columnsState) == null ? void 0 : l.defaultValue) || S;
99
+ return e.columnsStateMap || ((a = e.columnsState) == null ? void 0 : a.value) || ((l = e.columnsState) == null ? void 0 : l.defaultValue) || S;
99
100
  },
100
101
  {
101
- value: ((J = e.columnsState) == null ? void 0 : J.value) || e.columnsStateMap,
102
- onChange: ((M = e.columnsState) == null ? void 0 : M.onChange) || e.onColumnsStateChange
102
+ value: ((x = e.columnsState) == null ? void 0 : x.value) || e.columnsStateMap,
103
+ onChange: ((J = e.columnsState) == null ? void 0 : J.onChange) || e.onColumnsStateChange
103
104
  }
104
105
  );
105
- r(() => {
106
- var n, a;
107
- const { persistenceType: t, persistenceKey: c, onlineGet: u } = e.columnsState || {};
108
- if (c && t && typeof window < "u" && t !== "online") {
109
- const i = window[t];
106
+ m(() => {
107
+ var n, c;
108
+ const { persistenceType: t, persistenceKey: i, onlineGet: u } = e.columnsState || {};
109
+ if (i && t && typeof window < "u" && t !== "online") {
110
+ const a = window[t];
110
111
  try {
111
- const l = i == null ? void 0 : i.getItem(c);
112
- l ? (n = e == null ? void 0 : e.columnsState) != null && n.defaultValue ? m(
112
+ const l = a == null ? void 0 : a.getItem(i);
113
+ l ? (n = e == null ? void 0 : e.columnsState) != null && n.defaultValue ? f(
113
114
  d(
114
115
  JSON.parse(l),
115
- (a = e == null ? void 0 : e.columnsState) == null ? void 0 : a.defaultValue
116
+ (c = e == null ? void 0 : e.columnsState) == null ? void 0 : c.defaultValue
116
117
  )
117
- ) : m(JSON.parse(l)) : m(S);
118
+ ) : f(JSON.parse(l)) : f(S);
118
119
  } catch (l) {
119
120
  console.warn(l);
120
121
  }
121
122
  }
122
123
  }, [
123
- (N = e.columnsState) == null ? void 0 : N.persistenceKey,
124
- (b = e.columnsState) == null ? void 0 : b.persistenceType,
124
+ (M = e.columnsState) == null ? void 0 : M.persistenceKey,
125
+ (N = e.columnsState) == null ? void 0 : N.persistenceType,
125
126
  S
126
127
  ]);
127
- const z = F(() => {
128
- const { persistenceType: t, persistenceKey: c } = e.columnsState || {};
129
- if (!c || !t || typeof window > "u")
128
+ const K = Q(() => {
129
+ const { persistenceType: t, persistenceKey: i } = e.columnsState || {};
130
+ if (!i || !t || typeof window > "u")
130
131
  return;
131
132
  const u = window[t];
132
133
  try {
133
- u == null || u.removeItem(c);
134
+ u == null || u.removeItem(i);
134
135
  } catch (n) {
135
136
  console.warn(n);
136
137
  }
137
138
  }, [e.columnsState]);
138
- r(() => {
139
+ m(() => {
139
140
  var u, n;
140
141
  if (!((u = e.columnsState) != null && u.persistenceKey) || !((n = e.columnsState) != null && n.persistenceType) || typeof window > "u")
141
142
  return;
142
143
  const {
143
144
  persistenceType: t,
144
- persistenceKey: c
145
+ persistenceKey: i
145
146
  // onlineChange
146
147
  } = e.columnsState;
147
148
  if (t !== "online") {
148
- const a = window[t];
149
+ const c = window[t];
149
150
  try {
150
- a == null || a.setItem(c, JSON.stringify(y));
151
- } catch (i) {
152
- console.warn(i), z();
151
+ c == null || c.setItem(i, JSON.stringify(y));
152
+ } catch (a) {
153
+ console.warn(a), K();
153
154
  }
154
155
  }
155
156
  }, [
156
157
  (j = e.columnsState) == null ? void 0 : j.persistenceKey,
157
158
  y,
158
- (x = e.columnsState) == null ? void 0 : x.persistenceType
159
- ]), r(() => {
160
- var t, c, u;
161
- if ((t = e.columnsState) != null && t.persistenceKey && ((c = e.columnsState) == null ? void 0 : c.persistenceType) === "online") {
162
- const { onlineGet: n, persistenceKey: a } = e.columnsState;
159
+ (I = e.columnsState) == null ? void 0 : I.persistenceType
160
+ ]), m(() => {
161
+ var t, i, u;
162
+ if ((t = e.columnsState) != null && t.persistenceKey && ((i = e.columnsState) == null ? void 0 : i.persistenceType) === "online") {
163
+ const { onlineGet: n, persistenceKey: c } = e.columnsState;
163
164
  try {
164
- (u = n == null ? void 0 : n(a)) == null || u.then((i) => {
165
+ (u = n == null ? void 0 : n(c)) == null || u.then((a) => {
165
166
  var o, s;
166
- const l = d(i, (o = e == null ? void 0 : e.columnsState) == null ? void 0 : o.value);
167
- m(
167
+ const l = d(a, (o = e == null ? void 0 : e.columnsState) == null ? void 0 : o.value);
168
+ f(
168
169
  (s = Object.keys(l ?? {})) != null && s.length ? l ?? {} : S
169
170
  );
170
171
  });
171
- } catch (i) {
172
- console.warn(i);
172
+ } catch (a) {
173
+ console.warn(a);
173
174
  }
174
175
  }
175
176
  }, []);
176
- const K = {
177
- uuid: f.current,
178
- persistenceType: (I = e.columnsState) == null ? void 0 : I.persistenceType,
179
- persistenceKey: (P = e.columnsState) == null ? void 0 : P.persistenceKey,
180
- onlineChange: (E = e.columnsState) == null ? void 0 : E.onlineChange,
177
+ const C = {
178
+ uuid: r.current,
179
+ persistenceType: (P = e.columnsState) == null ? void 0 : P.persistenceType,
180
+ persistenceKey: (E = e.columnsState) == null ? void 0 : E.persistenceKey,
181
+ onlineChange: (k = e.columnsState) == null ? void 0 : k.onlineChange,
181
182
  sortKeyColumns: w.current,
182
183
  setSortKeyColumns: (t) => {
183
184
  w.current = t;
184
185
  },
185
186
  columnsMap: y,
186
- setColumnsMap: m,
187
- setTableSize: C,
188
- tableSize: g,
189
- sizeStorageType: (k = e.sizeState) == null ? void 0 : k.persistenceType,
190
- sizeStorageKey: (R = e.sizeState) == null ? void 0 : R.persistenceKey,
191
- onlineSizeChange: (G = e.sizeState) == null ? void 0 : G.onlineChange,
187
+ setColumnsMap: f,
188
+ setTableSize: g,
189
+ defaultTableSize: z,
190
+ tableSize: h,
191
+ sizeStorageType: (R = e.sizeState) == null ? void 0 : R.persistenceType,
192
+ sizeStorageKey: (B = e.sizeState) == null ? void 0 : B.persistenceKey,
193
+ onlineSizeChange: (D = e.sizeState) == null ? void 0 : D.onlineChange,
192
194
  columns: e.columns,
193
- clearPersistenceStorage: z,
195
+ clearPersistenceStorage: K,
194
196
  defaultColumnKeyMap: S
195
197
  };
196
- return Object.defineProperty(K, "sortKeyColumns", {
198
+ return Object.defineProperty(C, "sortKeyColumns", {
197
199
  get: () => w.current
198
- }), Object.defineProperty(K, "uuid", {
199
- get: () => f.current
200
- }), K;
200
+ }), Object.defineProperty(C, "uuid", {
201
+ get: () => r.current
202
+ }), C;
201
203
  }
202
- const W = B({}), ee = (e) => {
203
- const f = Q(e.initValue);
204
- return /* @__PURE__ */ A.jsx(W.Provider, { value: f, children: e.children });
204
+ const _ = F({}), ce = (e) => {
205
+ const r = Z(e.initValue);
206
+ return /* @__PURE__ */ A.jsx(_.Provider, { value: r, children: e.children });
205
207
  };
206
208
  export {
207
- W as TableContext,
208
- ee as default
209
+ _ as TableContext,
210
+ ce as default
209
211
  };
@@ -1,5 +1,7 @@
1
1
  import { Key } from 'react';
2
2
  import { ColumnsConfigProps } from '../../';
3
+ /** 删掉不应该显示的 */
4
+ export declare const loopFilter: (column: any[], columnsMap: any) => any[];
3
5
  /**
4
6
  * 根据 key 和 dataIndex 生成唯一 id
5
7
  *
@@ -1,14 +1,21 @@
1
- const s = (r, e) => r ? Array.isArray(r) ? r.join("-") : r.toString() : `${e}`, y = (r) => (e, i) => {
2
- var x, f, g, u;
3
- const { fixed: t, index: c } = e, { fixed: n, index: h } = i;
4
- if (t === "left" && n !== "left" || n === "right" && t !== "right")
1
+ const h = (n, e) => n.map((r) => {
2
+ const o = g((r == null ? void 0 : r.key) || (r == null ? void 0 : r.dataIndex), r.index), d = e[o];
3
+ return d && d.show === !1 ? !1 : r.children ? {
4
+ ...r,
5
+ children: h(r.children, e)
6
+ } : r;
7
+ }).filter(Boolean), g = (n, e) => n ? Array.isArray(n) ? n.join("-") : n.toString() : `${e}`, y = (n) => (e, r) => {
8
+ var x, l, c, s;
9
+ const { fixed: o, index: d } = e, { fixed: t, index: u } = r;
10
+ if (o === "left" && t !== "left" || t === "right" && o !== "right")
5
11
  return -2;
6
- if (n === "left" && t !== "left" || t === "right" && n !== "right")
12
+ if (t === "left" && o !== "left" || o === "right" && t !== "right")
7
13
  return 2;
8
- const d = e.key || `${c}`, o = i.key || `${h}`;
9
- return (x = r[d]) != null && x.order || (f = r[o]) != null && f.order ? (((g = r[d]) == null ? void 0 : g.order) || 0) - (((u = r[o]) == null ? void 0 : u.order) || 0) : (e.index || 0) - (i.index || 0);
14
+ const f = e.key || `${d}`, i = r.key || `${u}`;
15
+ return (x = n[f]) != null && x.order || (l = n[i]) != null && l.order ? (((c = n[f]) == null ? void 0 : c.order) || 0) - (((s = n[i]) == null ? void 0 : s.order) || 0) : (e.index || 0) - (r.index || 0);
10
16
  };
11
17
  export {
12
18
  y as columnSort,
13
- s as genColumnKey
19
+ g as genColumnKey,
20
+ h as loopFilter
14
21
  };
@@ -60,7 +60,7 @@ export interface BitzTableProps<RecordType = any> extends Omit<TableProps<Record
60
60
  */
61
61
  skeletonRender?: () => ReactNode;
62
62
  /**
63
- * table布局size,默认为宽松(lg)
63
+ * table布局size
64
64
  */
65
65
  size?: DensitySize;
66
66
  /**