bitz-react-admin-ui 1.7.7 → 1.7.8

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,4 +1,4 @@
1
- var p = { exports: {} };
1
+ var s = { exports: {} };
2
2
  export {
3
- p as __module
3
+ s as __module
4
4
  };
@@ -1,4 +1,4 @@
1
- var s = { exports: {} };
1
+ var p = { exports: {} };
2
2
  export {
3
- s as __module
3
+ p as __module
4
4
  };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export type ToolEnum = 'export' | 'refresh' | 'size' | 'fullscreen' | 'colConfig';
3
+ /** 根据从左到右方向排序,不在数组中则不显示 */
3
4
  export interface TableComponentContextProps {
4
5
  toolbar?: ToolEnum[];
5
6
  }
@@ -14,6 +14,16 @@ export interface BitzTableComponentToken extends TableComponentToken {
14
14
  radioCheckboxBorderColor?: string;
15
15
  /** 展开按钮border颜色 */
16
16
  expandIconBorderColor?: string;
17
+ /** xl */
18
+ xlFontSize?: number;
19
+ /** lg */
20
+ lgFontSize?: number;
21
+ /** md */
22
+ mdFontSize?: number;
23
+ /** sm */
24
+ smFontSize?: number;
25
+ /** xs */
26
+ xsFontSize?: number;
17
27
  /** list背景颜色 移动端 */
18
28
  mobileListBgColor?: string;
19
29
  /** listItem背景颜色 移动端 */
@@ -21,12 +21,22 @@ export type ColumnStateType = {
21
21
  /** 仅在 persistenceType=online 有效 用于获取网络数据 */
22
22
  onlineGet?: (key: string) => Promise<Record<string, ColumnsConfigProps> | null | undefined>;
23
23
  };
24
+ export type SizeStateType = {
25
+ persistenceType?: 'localStorage' | 'sessionStorage' | 'online';
26
+ persistenceKey?: string;
27
+ defaultValue?: DensitySize;
28
+ value?: DensitySize;
29
+ onChange?: (val: DensitySize) => void;
30
+ onlineChange?: (key: string, sizeState: DensitySize) => void;
31
+ onlineGet?: (key: string) => Promise<DensitySize | null | undefined>;
32
+ };
24
33
  export type UseContainerProps<T = any> = {
25
34
  columnsStateMap?: Record<string, ColumnsConfigProps>;
26
35
  onColumnsStateChange?: (map: Record<string, ColumnsConfigProps>) => void;
27
36
  size?: DensitySize;
28
37
  defaultSize?: DensitySize;
29
38
  onSizeChange?: (size: DensitySize) => void;
39
+ sizeState?: SizeStateType;
30
40
  columns?: BitzTableColumnsType<T>;
31
41
  columnsState?: ColumnStateType;
32
42
  /** 仅在 persistenceType=online 有效 用于数据修改后数据上报 */
@@ -45,6 +55,7 @@ declare function useContainer(props?: UseContainerProps): {
45
55
  setColumnsMap: (updater: Record<string, ColumnsConfigProps> | ((origin: Record<string, ColumnsConfigProps>) => Record<string, ColumnsConfigProps>), ignoreDestroy?: boolean | undefined) => void;
46
56
  setTableSize: (updater: DensitySize | ((origin: DensitySize) => DensitySize), ignoreDestroy?: boolean | undefined) => void;
47
57
  tableSize: DensitySize;
58
+ onlineSizeChange: ((key: string, sizeState: DensitySize) => void) | undefined;
48
59
  columns: BitzTableColumnsType<any> | undefined;
49
60
  clearPersistenceStorage: () => void;
50
61
  defaultColumnKeyMap: Record<string, any>;
@@ -60,6 +71,7 @@ declare const TableContext: import("react").Context<{
60
71
  setColumnsMap: (updater: Record<string, ColumnsConfigProps> | ((origin: Record<string, ColumnsConfigProps>) => Record<string, ColumnsConfigProps>), ignoreDestroy?: boolean | undefined) => void;
61
72
  setTableSize: (updater: DensitySize | ((origin: DensitySize) => DensitySize), ignoreDestroy?: boolean | undefined) => void;
62
73
  tableSize: DensitySize;
74
+ onlineSizeChange: ((key: string, sizeState: DensitySize) => void) | undefined;
63
75
  columns: BitzTableColumnsType<any> | undefined;
64
76
  clearPersistenceStorage: () => void;
65
77
  defaultColumnKeyMap: Record<string, any>;
@@ -1,110 +1,160 @@
1
- import { j as R } from "../../../node_modules/.store/react@18.2.0/node_modules/react/jsx-runtime.mjs";
2
- import j from "../../../hooks/useMergedState.mjs";
3
- import { createContext as k, useRef as J, useMemo as U, useEffect as N, useCallback as q } from "react";
4
- import { genColumnKey as A } from "./utils/index.mjs";
5
- import { getUuid as B } from "../../../utils/uuid.mjs";
6
- import d from "../../../node_modules/.store/lodash-es@4.17.21/node_modules/lodash-es/merge.mjs";
7
- function D(e = {}) {
8
- var K, g, V, T, M, v, O, b, x;
9
- const f = J(B()), y = J([]), { defaultSize: I = "lg" } = e, [P, E] = j(
10
- () => e.size ?? I,
1
+ import { j as B } from "../../../node_modules/.store/react@18.2.0/node_modules/react/jsx-runtime.mjs";
2
+ import k from "../../../hooks/useMergedState.mjs";
3
+ import { createContext as D, useRef as U, useEffect as K, useMemo as F, useCallback as H } from "react";
4
+ import { genColumnKey as L } from "./utils/index.mjs";
5
+ import { getUuid as Q } from "../../../utils/uuid.mjs";
6
+ import S from "../../../node_modules/.store/lodash-es@4.17.21/node_modules/lodash-es/merge.mjs";
7
+ function W(e = {}) {
8
+ var g, T, O, v, J, M, N, b, x, I, j, P, E, R;
9
+ const d = U(Q()), h = U([]), { defaultSize: q = "lg" } = e, [V, A] = k(
10
+ () => {
11
+ var c, i, m, l, s;
12
+ const { persistenceType: t, persistenceKey: u, onlineGet: a } = e.sizeState || {};
13
+ if (u && t && typeof window < "u")
14
+ if (t !== "online") {
15
+ const n = window[t];
16
+ try {
17
+ const f = n == null ? void 0 : n.getItem(u);
18
+ if (f)
19
+ return (c = e == null ? void 0 : e.sizeState) != null && c.defaultValue ? S(
20
+ JSON.parse(f),
21
+ (i = e == null ? void 0 : e.sizeState) == null ? void 0 : i.defaultValue
22
+ ) : JSON.parse(f);
23
+ } catch (f) {
24
+ console.warn(f);
25
+ }
26
+ } else
27
+ try {
28
+ (m = a == null ? void 0 : a(u)) == null || m.then((n) => {
29
+ var f, r;
30
+ if (n)
31
+ return (f = e == null ? void 0 : e.sizeState) != null && f.defaultValue ? S(n, (r = e == null ? void 0 : e.sizeState) == null ? void 0 : r.defaultValue) : n;
32
+ });
33
+ } catch (n) {
34
+ console.warn(n);
35
+ }
36
+ return e.size || ((l = e.sizeState) == null ? void 0 : l.value) || ((s = e.sizeState) == null ? void 0 : s.defaultValue) || q;
37
+ },
11
38
  {
12
- value: e.size,
13
- onChange: e.onSizeChange
39
+ value: ((g = e.sizeState) == null ? void 0 : g.value) || e.size,
40
+ onChange: ((T = e.sizeState) == null ? void 0 : T.onChange) || e.onSizeChange
41
+ }
42
+ );
43
+ K(() => {
44
+ var a, c;
45
+ if (!((a = e.sizeState) != null && a.persistenceKey) || !((c = e.sizeState) != null && c.persistenceType) || typeof window > "u")
46
+ return;
47
+ const {
48
+ persistenceType: t,
49
+ persistenceKey: u
50
+ // onlineChange
51
+ } = e.sizeState;
52
+ if (t !== "online") {
53
+ const i = window[t];
54
+ try {
55
+ i == null || i.setItem(u, JSON.stringify(y));
56
+ } catch (m) {
57
+ console.warn(m), C();
58
+ }
14
59
  }
15
- ), r = U(() => {
16
- var u, n;
60
+ }, [
61
+ (O = e.sizeState) == null ? void 0 : O.persistenceKey,
62
+ V,
63
+ (v = e.sizeState) == null ? void 0 : v.persistenceType
64
+ ]);
65
+ const o = F(() => {
66
+ var u, a;
17
67
  if ((u = e == null ? void 0 : e.columnsState) != null && u.defaultValue)
18
68
  return e.columnsState.defaultValue;
19
69
  const t = {};
20
- return (n = e.columns) == null || n.forEach(({ key: i, dataIndex: m, fixed: o, disable: a }, l) => {
21
- const c = A(i ?? m, l);
22
- c && (t[c] = {
70
+ return (a = e.columns) == null || a.forEach(({ key: c, dataIndex: i, fixed: m, disable: l }, s) => {
71
+ const n = L(c ?? i, s);
72
+ n && (t[n] = {
23
73
  show: !0,
24
- fixed: o,
25
- disable: a
74
+ fixed: m,
75
+ disable: l
26
76
  });
27
77
  }), t;
28
- }, [e.columns]), [w, S] = j(
78
+ }, [e.columns]), [y, w] = k(
29
79
  () => {
30
- var i, m, o, a, l;
31
- const { persistenceType: t, persistenceKey: u, onlineGet: n } = e.columnsState || {};
80
+ var c, i, m, l, s;
81
+ const { persistenceType: t, persistenceKey: u, onlineGet: a } = e.columnsState || {};
32
82
  if (u && t && typeof window < "u")
33
83
  if (t !== "online") {
34
- const c = window[t];
84
+ const n = window[t];
35
85
  try {
36
- const s = c == null ? void 0 : c.getItem(u);
37
- if (s)
38
- return (i = e == null ? void 0 : e.columnsState) != null && i.defaultValue ? d(
39
- JSON.parse(s),
40
- (m = e == null ? void 0 : e.columnsState) == null ? void 0 : m.defaultValue
41
- ) : JSON.parse(s);
42
- } catch (s) {
43
- console.warn(s);
86
+ const f = n == null ? void 0 : n.getItem(u);
87
+ if (f)
88
+ return (c = e == null ? void 0 : e.columnsState) != null && c.defaultValue ? S(
89
+ JSON.parse(f),
90
+ (i = e == null ? void 0 : e.columnsState) == null ? void 0 : i.defaultValue
91
+ ) : JSON.parse(f);
92
+ } catch (f) {
93
+ console.warn(f);
44
94
  }
45
95
  } else
46
96
  try {
47
- (o = n == null ? void 0 : n(u)) == null || o.then((c) => {
48
- var s, z;
49
- if (c)
50
- return (s = e == null ? void 0 : e.columnsState) != null && s.defaultValue ? d(c, (z = e == null ? void 0 : e.columnsState) == null ? void 0 : z.defaultValue) : c;
97
+ (m = a == null ? void 0 : a(u)) == null || m.then((n) => {
98
+ var f, r;
99
+ if (n)
100
+ return (f = e == null ? void 0 : e.columnsState) != null && f.defaultValue ? S(n, (r = e == null ? void 0 : e.columnsState) == null ? void 0 : r.defaultValue) : n;
51
101
  });
52
- } catch (c) {
53
- console.warn(c);
102
+ } catch (n) {
103
+ console.warn(n);
54
104
  }
55
- return e.columnsStateMap || ((a = e.columnsState) == null ? void 0 : a.value) || ((l = e.columnsState) == null ? void 0 : l.defaultValue) || r;
105
+ return e.columnsStateMap || ((l = e.columnsState) == null ? void 0 : l.value) || ((s = e.columnsState) == null ? void 0 : s.defaultValue) || o;
56
106
  },
57
107
  {
58
- value: ((K = e.columnsState) == null ? void 0 : K.value) || e.columnsStateMap,
59
- onChange: ((g = e.columnsState) == null ? void 0 : g.onChange) || e.onColumnsStateChange
108
+ value: ((J = e.columnsState) == null ? void 0 : J.value) || e.columnsStateMap,
109
+ onChange: ((M = e.columnsState) == null ? void 0 : M.onChange) || e.onColumnsStateChange
60
110
  }
61
111
  );
62
- N(() => {
63
- var i, m, o;
64
- const { persistenceType: t, persistenceKey: u, onlineGet: n } = e.columnsState || {};
112
+ K(() => {
113
+ var c, i, m;
114
+ const { persistenceType: t, persistenceKey: u, onlineGet: a } = e.columnsState || {};
65
115
  if (u && t && typeof window < "u")
66
116
  if (t !== "online") {
67
- const a = window[t];
117
+ const l = window[t];
68
118
  try {
69
- const l = a == null ? void 0 : a.getItem(u);
70
- l ? (i = e == null ? void 0 : e.columnsState) != null && i.defaultValue ? S(
71
- d(
72
- JSON.parse(l),
73
- (m = e == null ? void 0 : e.columnsState) == null ? void 0 : m.defaultValue
119
+ const s = l == null ? void 0 : l.getItem(u);
120
+ s ? (c = e == null ? void 0 : e.columnsState) != null && c.defaultValue ? w(
121
+ S(
122
+ JSON.parse(s),
123
+ (i = e == null ? void 0 : e.columnsState) == null ? void 0 : i.defaultValue
74
124
  )
75
- ) : S(JSON.parse(l)) : S(r);
76
- } catch (l) {
77
- console.warn(l);
125
+ ) : w(JSON.parse(s)) : w(o);
126
+ } catch (s) {
127
+ console.warn(s);
78
128
  }
79
129
  } else
80
130
  try {
81
- (o = n == null ? void 0 : n(u)) == null || o.then((a) => {
82
- var l, c;
83
- if (a)
84
- return (l = e == null ? void 0 : e.columnsState) != null && l.defaultValue ? d(a, (c = e == null ? void 0 : e.columnsState) == null ? void 0 : c.defaultValue) : a;
131
+ (m = a == null ? void 0 : a(u)) == null || m.then((l) => {
132
+ var s, n;
133
+ if (l)
134
+ return (s = e == null ? void 0 : e.columnsState) != null && s.defaultValue ? S(l, (n = e == null ? void 0 : e.columnsState) == null ? void 0 : n.defaultValue) : l;
85
135
  });
86
- } catch (a) {
87
- console.warn(a);
136
+ } catch (l) {
137
+ console.warn(l);
88
138
  }
89
139
  }, [
90
- (V = e.columnsState) == null ? void 0 : V.persistenceKey,
91
- (T = e.columnsState) == null ? void 0 : T.persistenceType,
92
- r
140
+ (N = e.columnsState) == null ? void 0 : N.persistenceKey,
141
+ (b = e.columnsState) == null ? void 0 : b.persistenceType,
142
+ o
93
143
  ]);
94
- const h = q(() => {
144
+ const C = H(() => {
95
145
  const { persistenceType: t, persistenceKey: u } = e.columnsState || {};
96
146
  if (!u || !t || typeof window > "u")
97
147
  return;
98
- const n = window[t];
148
+ const a = window[t];
99
149
  try {
100
- n == null || n.removeItem(u);
101
- } catch (i) {
102
- console.warn(i);
150
+ a == null || a.removeItem(u);
151
+ } catch (c) {
152
+ console.warn(c);
103
153
  }
104
154
  }, [e.columnsState]);
105
- N(() => {
106
- var n, i;
107
- if (!((n = e.columnsState) != null && n.persistenceKey) || !((i = e.columnsState) != null && i.persistenceType) || typeof window > "u")
155
+ K(() => {
156
+ var a, c;
157
+ if (!((a = e.columnsState) != null && a.persistenceKey) || !((c = e.columnsState) != null && c.persistenceType) || typeof window > "u")
108
158
  return;
109
159
  const {
110
160
  persistenceType: t,
@@ -112,46 +162,47 @@ function D(e = {}) {
112
162
  // onlineChange
113
163
  } = e.columnsState;
114
164
  if (t !== "online") {
115
- const m = window[t];
165
+ const i = window[t];
116
166
  try {
117
- m == null || m.setItem(u, JSON.stringify(w));
118
- } catch (o) {
119
- console.warn(o), h();
167
+ i == null || i.setItem(u, JSON.stringify(y));
168
+ } catch (m) {
169
+ console.warn(m), C();
120
170
  }
121
171
  }
122
172
  }, [
123
- (M = e.columnsState) == null ? void 0 : M.persistenceKey,
124
- w,
125
- (v = e.columnsState) == null ? void 0 : v.persistenceType
173
+ (x = e.columnsState) == null ? void 0 : x.persistenceKey,
174
+ y,
175
+ (I = e.columnsState) == null ? void 0 : I.persistenceType
126
176
  ]);
127
- const C = {
128
- uuid: f.current,
129
- persistenceType: (O = e.columnsState) == null ? void 0 : O.persistenceType,
130
- persistenceKey: (b = e.columnsState) == null ? void 0 : b.persistenceKey,
131
- onlineChange: (x = e.columnsState) == null ? void 0 : x.onlineChange,
132
- sortKeyColumns: y.current,
177
+ const z = {
178
+ uuid: d.current,
179
+ persistenceType: (j = e.columnsState) == null ? void 0 : j.persistenceType,
180
+ persistenceKey: (P = e.columnsState) == null ? void 0 : P.persistenceKey,
181
+ onlineChange: (E = e.columnsState) == null ? void 0 : E.onlineChange,
182
+ sortKeyColumns: h.current,
133
183
  setSortKeyColumns: (t) => {
134
- y.current = t;
184
+ h.current = t;
135
185
  },
136
- columnsMap: w,
137
- setColumnsMap: S,
138
- setTableSize: E,
139
- tableSize: P,
186
+ columnsMap: y,
187
+ setColumnsMap: w,
188
+ setTableSize: A,
189
+ tableSize: V,
190
+ onlineSizeChange: (R = e.sizeState) == null ? void 0 : R.onlineChange,
140
191
  columns: e.columns,
141
- clearPersistenceStorage: h,
142
- defaultColumnKeyMap: r
192
+ clearPersistenceStorage: C,
193
+ defaultColumnKeyMap: o
143
194
  };
144
- return Object.defineProperty(C, "sortKeyColumns", {
145
- get: () => y.current
146
- }), Object.defineProperty(C, "uuid", {
147
- get: () => f.current
148
- }), C;
195
+ return Object.defineProperty(z, "sortKeyColumns", {
196
+ get: () => h.current
197
+ }), Object.defineProperty(z, "uuid", {
198
+ get: () => d.current
199
+ }), z;
149
200
  }
150
- const F = k({}), Z = (e) => {
151
- const f = D(e.initValue);
152
- return /* @__PURE__ */ R.jsx(F.Provider, { value: f, children: e.children });
201
+ const X = D({}), ee = (e) => {
202
+ const d = W(e.initValue);
203
+ return /* @__PURE__ */ B.jsx(X.Provider, { value: d, children: e.children });
153
204
  };
154
205
  export {
155
- F as TableContext,
156
- Z as default
206
+ X as TableContext,
207
+ ee as default
157
208
  };