@wangcheng051/plugin-kit 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,787 @@
1
+ import o, { useState as T, useEffect as V, useRef as L, useMemo as F, useCallback as R } from "react";
2
+ import { Typography as Ce, Tooltip as de, Tag as be, Popover as fe, Checkbox as Ee, Button as ee, Input as me, Spin as Se, Pagination as we } from "antd";
3
+ import * as W from "@ant-design/icons";
4
+ import { useSelector as ge } from "react-redux";
5
+ import { AgGridReact as _e } from "ag-grid-react";
6
+ function te(e) {
7
+ return e == null || e === "" || typeof e == "number" && Number.isNaN(e) ? !0 : Array.isArray(e) ? e.length === 0 : !1;
8
+ }
9
+ function Ne(e, n, t) {
10
+ if (!e || !n) return t;
11
+ const r = String(n).split(".");
12
+ let i = e;
13
+ for (let s = 0; s < r.length; s += 1) {
14
+ if (i == null) return t;
15
+ i = i[r[s]];
16
+ }
17
+ return i === void 0 ? t : i;
18
+ }
19
+ function oe(e, n = 0) {
20
+ if (te(e)) return "-";
21
+ const t = Number(e);
22
+ return Number.isNaN(t) ? "-" : t.toLocaleString("zh-CN", {
23
+ minimumFractionDigits: n,
24
+ maximumFractionDigits: n
25
+ });
26
+ }
27
+ function Re(e, n = {}) {
28
+ const { digits: t = 2, symbol: r = "¥", showSymbol: i = !0, showZeroZero: s = !1 } = n;
29
+ if (te(e)) return "-";
30
+ const m = Number(e);
31
+ if (Number.isNaN(m)) return "-";
32
+ const E = oe(Math.abs(m), t), x = i ? r : "";
33
+ return m < 0 ? `-${x}${E}` : `${x}${E}`;
34
+ }
35
+ function Te(e, n = 2) {
36
+ if (te(e)) return "-";
37
+ const t = Number(e);
38
+ return Number.isNaN(t) ? "-" : `${oe(t * 100, n)}%`;
39
+ }
40
+ function lt(e, n) {
41
+ const t = {};
42
+ return (e || []).forEach((r) => {
43
+ const i = typeof n == "function" ? n(r) : Ne(r, n);
44
+ t[i] || (t[i] = []), t[i].push(r);
45
+ }), t;
46
+ }
47
+ function it(e) {
48
+ const n = {};
49
+ return Object.keys(e || {}).forEach((t) => {
50
+ te(e[t]) || (n[t] = e[t]);
51
+ }), n;
52
+ }
53
+ function at(e, n = 300) {
54
+ let t = null;
55
+ return function(...i) {
56
+ t && clearTimeout(t), t = setTimeout(() => {
57
+ t = null, e.apply(this, i);
58
+ }, n);
59
+ };
60
+ }
61
+ function ut(...e) {
62
+ return e.filter(Boolean).join(" ");
63
+ }
64
+ function xe(e = [], n = "value") {
65
+ return new Map(
66
+ (e || []).map((t) => [(t == null ? void 0 : t[n]) ?? (t == null ? void 0 : t.id), t])
67
+ );
68
+ }
69
+ function O(e, n = /* @__PURE__ */ new WeakMap()) {
70
+ if (e === null || typeof e != "object") return e;
71
+ if (n.has(e)) return n.get(e);
72
+ if (Array.isArray(e)) {
73
+ const r = [];
74
+ return n.set(e, r), e.forEach((i, s) => {
75
+ r[s] = O(i, n);
76
+ }), r;
77
+ }
78
+ if (e instanceof Date) return new Date(e.getTime());
79
+ if (e instanceof RegExp) return new RegExp(e.source, e.flags);
80
+ const t = {};
81
+ return n.set(e, t), Object.keys(e).forEach((r) => {
82
+ t[r] = O(e[r], n);
83
+ }), t;
84
+ }
85
+ const { Text: q } = Ce;
86
+ function dt({ value: e }) {
87
+ return e == null || e === "" ? /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-") : /* @__PURE__ */ o.createElement("span", null, String(e));
88
+ }
89
+ function ft({ value: e, digits: n = 2, showSymbol: t = !0 }) {
90
+ if (e == null || e === "")
91
+ return /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-");
92
+ const r = Number(e);
93
+ return Number.isNaN(r) ? /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-") : /* @__PURE__ */ o.createElement("span", { style: { color: r < 0 ? "#ff4d4f" : void 0 } }, Re(r, { digits: n, showSymbol: t }));
94
+ }
95
+ function mt({ value: e, digits: n = 0, percent: t = !1 }) {
96
+ if (e == null || e === "")
97
+ return /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-");
98
+ const r = Number(e);
99
+ return Number.isNaN(r) ? /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-") : /* @__PURE__ */ o.createElement("span", null, t ? Te(r, n) : oe(r, n));
100
+ }
101
+ function gt({ value: e, color: n, options: t }) {
102
+ if (e == null || e === "")
103
+ return /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-");
104
+ let r = n, i = e;
105
+ if (t && t.length) {
106
+ const s = t.find((m) => String(m.value) === String(e));
107
+ s && (i = s.label, r = r ?? s.color);
108
+ }
109
+ return /* @__PURE__ */ o.createElement(be, { color: r || "default" }, i);
110
+ }
111
+ function ht({ value: e, length: n = 30 }) {
112
+ if (e == null || e === "")
113
+ return /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-");
114
+ const t = String(e);
115
+ return t.length <= n ? /* @__PURE__ */ o.createElement("span", null, t) : /* @__PURE__ */ o.createElement(de, { title: t }, /* @__PURE__ */ o.createElement(q, { ellipsis: !0, style: { maxWidth: 240 } }, t));
116
+ }
117
+ function pt({ value: e, onClick: n }) {
118
+ return e == null || e === "" ? /* @__PURE__ */ o.createElement(q, { type: "secondary" }, "-") : /* @__PURE__ */ o.createElement("a", { onClick: () => n && n(e) }, String(e));
119
+ }
120
+ function yt({ value: e, actions: n = [] }) {
121
+ return /* @__PURE__ */ o.createElement("span", null, n.map((t) => /* @__PURE__ */ o.createElement(
122
+ "a",
123
+ {
124
+ key: t.key,
125
+ style: { marginRight: 8 },
126
+ onClick: () => t.onClick && t.onClick(t)
127
+ },
128
+ t.text
129
+ )));
130
+ }
131
+ const vt = {
132
+ token: {
133
+ colorPrimary: "#1677ff",
134
+ colorSuccess: "#52c41a",
135
+ colorWarning: "#faad14",
136
+ colorError: "#ff4d4f",
137
+ colorInfo: "#1677ff",
138
+ borderRadius: 6,
139
+ fontSize: 14,
140
+ controlHeight: 32,
141
+ wireframe: !1
142
+ },
143
+ components: {
144
+ Table: {
145
+ headerBg: "#fafafa",
146
+ headerColor: "#262626",
147
+ rowHoverBg: "#f5f5f5",
148
+ borderColor: "#f0f0f0"
149
+ },
150
+ Layout: {
151
+ headerBg: "#ffffff",
152
+ headerHeight: 56,
153
+ bodyBg: "#f0f2f5"
154
+ },
155
+ Card: {
156
+ headerBg: "transparent"
157
+ },
158
+ Menu: {
159
+ itemBorderRadius: 6
160
+ }
161
+ }
162
+ }, Ct = {
163
+ success: { color: "success", text: "成功" },
164
+ warning: { color: "warning", text: "警告" },
165
+ error: { color: "error", text: "异常" },
166
+ processing: { color: "processing", text: "处理中" },
167
+ info: { color: "processing", text: "进行中" },
168
+ default: { color: "default", text: "未知" }
169
+ }, bt = {
170
+ 1: "success",
171
+ 0: "default",
172
+ true: "success",
173
+ false: "default"
174
+ }, Me = ["alpine", "balham", "material", "quartz", "classic"], ue = "alpine";
175
+ function Et(e = ue, n) {
176
+ return [`ag-theme-${Me.includes(e) ? e : ue}`, n].filter(Boolean).join(" ");
177
+ }
178
+ const St = {
179
+ compact: 28,
180
+ normal: 36,
181
+ relaxed: 48
182
+ }, he = W.default && typeof W.default == "object" ? W.default : W, ke = W.SearchOutlined || he.SearchOutlined, Ae = W.SettingOutlined || he.SettingOutlined, De = "_poper_cidv4_2", Be = "_antTable_cidv4_6", Le = "_detailTable_cidv4_10", He = "_opts_cidv4_10", Ie = "_commonDetail_cidv4_18", ze = "_title_cidv4_18", Pe = "_searchAndAdd_cidv4_25", Oe = "_addIcons_cidv4_25", qe = "_noteTitle_cidv4_31", Ke = "_customHead_cidv4_40", $e = "_sortNames_cidv4_43", Ue = "_customSort_cidv4_48", Ge = "_customUnSort_cidv4_53", Fe = "_active_cidv4_56", We = "_inactive_cidv4_59", Je = "_popoverContext_cidv4_63", Ze = "_contextRender_cidv4_68", Qe = "_contextRenderFooter_cidv4_71", _ = {
183
+ poper: De,
184
+ antTable: Be,
185
+ detailTable: Le,
186
+ opts: He,
187
+ commonDetail: Ie,
188
+ title: ze,
189
+ searchAndAdd: Pe,
190
+ addIcons: Oe,
191
+ noteTitle: qe,
192
+ customHead: Ke,
193
+ sortNames: $e,
194
+ customSort: Ue,
195
+ customUnSort: Ge,
196
+ active: Fe,
197
+ inactive: We,
198
+ popoverContext: Je,
199
+ contextRender: Ze,
200
+ contextRenderFooter: Qe
201
+ }, Ye = ({ onChange: e = () => {
202
+ }, columRef: n }) => {
203
+ const { language: t } = ge((a) => a.controller), [r, i] = T(!1), [s, m] = T(
204
+ O(n.current)
205
+ );
206
+ V(() => {
207
+ const a = n == null ? void 0 : n.current;
208
+ !a || !a.length || r || m(O(a));
209
+ }, [n == null ? void 0 : n.current, r]);
210
+ const E = () => {
211
+ e({
212
+ column: s,
213
+ optType: "mergeColum"
214
+ }), i(!1);
215
+ }, x = (a) => {
216
+ s[a].visible = !s[a].visible, m([...s]);
217
+ }, M = () => {
218
+ m(O(n.current));
219
+ };
220
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
221
+ fe,
222
+ {
223
+ placement: "bottomLeft",
224
+ trigger: "click",
225
+ className: _.poper,
226
+ open: !!r,
227
+ onOpenChange: (a) => {
228
+ i(a);
229
+ },
230
+ content: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
231
+ "div",
232
+ {
233
+ style: {
234
+ padding: "10px 10px",
235
+ maxHeight: "300px",
236
+ overflowY: "auto",
237
+ position: "relative",
238
+ minWidth: 178
239
+ }
240
+ },
241
+ /* @__PURE__ */ React.createElement(
242
+ "div",
243
+ {
244
+ style: {
245
+ borderBottom: "1px solid rgba(0, 0, 0, 0.06)",
246
+ paddingBottom: "10px"
247
+ }
248
+ },
249
+ t ? "Custom List" : "自定义列表"
250
+ ),
251
+ s.map((a, S) => /* @__PURE__ */ React.createElement(
252
+ "div",
253
+ {
254
+ style: {
255
+ height: "32px",
256
+ display: "flex",
257
+ alignItems: "center"
258
+ },
259
+ key: a + S
260
+ },
261
+ /* @__PURE__ */ React.createElement(
262
+ Ee,
263
+ {
264
+ color: "primary",
265
+ checked: a.visible,
266
+ disabled: a.disabled,
267
+ onChange: (H) => x(S)
268
+ }
269
+ ),
270
+ /* @__PURE__ */ React.createElement(
271
+ "span",
272
+ {
273
+ style: {
274
+ position: "relative",
275
+ top: "2px",
276
+ marginLeft: "8px"
277
+ }
278
+ },
279
+ (t ? a.enDisplay : a.cnDisplay) || a.field
280
+ )
281
+ ))
282
+ ), /* @__PURE__ */ React.createElement(
283
+ "div",
284
+ {
285
+ style: {
286
+ minWidth: 120,
287
+ display: "flex",
288
+ justifyContent: "space-between",
289
+ alignItems: "center",
290
+ paddingTop: 5,
291
+ paddingBottom: 5,
292
+ boxShadow: " 0 -1px 2px 0 rgba(0, 0, 0, 0.05)"
293
+ }
294
+ },
295
+ /* @__PURE__ */ React.createElement(ee, { onClick: E, type: "primary" }, t ? "Save" : "保存"),
296
+ /* @__PURE__ */ React.createElement(ee, { onClick: () => i(!1) }, t ? "Cancel" : "取消")
297
+ ))
298
+ },
299
+ /* @__PURE__ */ React.createElement(Ae, { onClick: () => M() })
300
+ ));
301
+ }, ce = {
302
+ fill: "currentColor",
303
+ viewBox: "0 0 1024 1024",
304
+ version: "1.1",
305
+ xmlns: "http://www.w3.org/2000/svg",
306
+ width: "16",
307
+ height: "16"
308
+ }, Xe = (e) => /* @__PURE__ */ o.createElement("svg", { ...ce, ...e, t: "1688438905306", "p-id": "2388" }, /* @__PURE__ */ o.createElement(
309
+ "path",
310
+ {
311
+ d: "M804.571 621.714a36.206 36.206 0 0 1-10.861 25.71l-256 256c-6.84 6.839-16.019 10.862-25.71 10.862s-18.87-3.987-25.71-10.862l-256-256a36.425 36.425 0 0 1-10.861-25.71c0-20.004 16.566-36.571 36.571-36.571h512c20.005 0 36.571 16.567 36.571 36.571z",
312
+ "p-id": "2389"
313
+ }
314
+ )), je = (e) => /* @__PURE__ */ o.createElement("svg", { ...ce, ...e, t: "1688438923470", "p-id": "2523" }, /* @__PURE__ */ o.createElement(
315
+ "path",
316
+ {
317
+ d: "M804.571 402.286c0 20.004-16.566 36.571-36.571 36.571H256c-20.005 0-36.571-16.567-36.571-36.571a36.206 36.206 0 0 1 10.861-25.71l256-256c6.84-6.839 16.019-10.862 25.71-10.862s18.87 3.987 25.71 10.862l256 256a36.425 36.425 0 0 1 10.861 25.71z",
318
+ "p-id": "2524"
319
+ }
320
+ )), Ve = (e) => /* @__PURE__ */ o.createElement("svg", { ...ce, ...e, t: "1688438886160", "p-id": "2253" }, /* @__PURE__ */ o.createElement(
321
+ "path",
322
+ {
323
+ d: "M804.571 621.714a36.206 36.206 0 0 1-10.861 25.71l-256 256c-6.84 6.839-16.019 10.862-25.71 10.862s-18.87-3.987-25.71-10.862l-256-256a36.425 36.425 0 0 1-10.861-25.71c0-20.004 16.566-36.571 36.571-36.571h512c20.005 0 36.571 16.567 36.571 36.571z m0-219.428c0 20.004-16.566 36.571-36.571 36.571H256c-20.005 0-36.571-16.567-36.571-36.571a36.206 36.206 0 0 1 10.861-25.71l256-256c6.84-6.839 16.019-10.862 25.71-10.862s18.87 3.987 25.71 10.862l256 256a36.425 36.425 0 0 1 10.861 25.71z",
324
+ "p-id": "2254"
325
+ }
326
+ )), et = (e) => {
327
+ const [n, t] = T("inactive"), [r, i] = T("inactive"), [s, m] = T("inactive"), E = L(null), [x, M] = T(!1), [a, S] = T(null), H = () => {
328
+ e.showColumnMenu(E.current);
329
+ };
330
+ V(() => {
331
+ var g;
332
+ const c = Array.isArray(e.filterKey) ? e.filterKey : [];
333
+ S(((g = xe(c, "field").get(e.field)) == null ? void 0 : g.value) ?? null);
334
+ }, [e.filterKey, e.field]);
335
+ const b = () => {
336
+ const c = e.column.getSort();
337
+ console.log(c, "sort"), t(c === "asc" ? "active" : "inactive"), i(c === "desc" ? "active" : "inactive"), m(c ? "inactive" : "active");
338
+ }, w = (c, g) => {
339
+ e.setSort(c, g.shiftKey);
340
+ };
341
+ V(() => {
342
+ const c = e.column;
343
+ if (!(!c || typeof c.addEventListener != "function"))
344
+ return c.addEventListener("sortChanged", b), b(), () => {
345
+ c.removeEventListener("sortChanged", b);
346
+ };
347
+ }, [e.column]), e.enableFilterButton && `${e.menuIcon}`;
348
+ let K = null;
349
+ e.enableSorting && (K = /* @__PURE__ */ o.createElement("div", { className: _.sortNames }, /* @__PURE__ */ o.createElement("div", { onClick: (c) => w("", c), onTouchEnd: (c) => w("", c), className: `${_.customSort} ${_[n]}` }, /* @__PURE__ */ o.createElement(je, null)), /* @__PURE__ */ o.createElement("div", { onClick: (c) => w("asc", c), onTouchEnd: (c) => w("desc", c), className: `${_.customSort} ${_[r]}` }, /* @__PURE__ */ o.createElement(Xe, null)), /* @__PURE__ */ o.createElement(
350
+ "div",
351
+ {
352
+ onClick: (c) => w("desc", c),
353
+ onTouchEnd: (c) => w("", c),
354
+ className: `${_.customSort} ${_.customUnSort} ${_[s]}`
355
+ },
356
+ /* @__PURE__ */ o.createElement(Ve, null)
357
+ )));
358
+ const U = {
359
+ width: "100%"
360
+ }, J = F(() => {
361
+ var g, p;
362
+ let c = ((g = e.filterSearchRender[e.field]) == null ? void 0 : g.render) || me;
363
+ return /* @__PURE__ */ o.createElement(
364
+ c,
365
+ {
366
+ ...((p = e.filterSearchRender[e.field]) == null ? void 0 : p.tPropty) || {},
367
+ value: a,
368
+ onChange: (d) => {
369
+ S(d.target ? d.target.value : d);
370
+ },
371
+ style: U
372
+ }
373
+ );
374
+ }, [e.field, a]);
375
+ let $ = null;
376
+ return e.search && ($ = /* @__PURE__ */ o.createElement("div", null, /* @__PURE__ */ o.createElement(
377
+ fe,
378
+ {
379
+ arrow: !1,
380
+ open: x,
381
+ trigger: "click",
382
+ overlayClassName: _.popoverContext,
383
+ onOpenChange: (c) => M(c),
384
+ placement: "bottom",
385
+ content: /* @__PURE__ */ o.createElement("div", { className: _.contextRender }, J, /* @__PURE__ */ o.createElement("div", { className: _.contextRenderFooter }, /* @__PURE__ */ o.createElement(
386
+ ee,
387
+ {
388
+ type: "primary",
389
+ onClick: () => {
390
+ const c = e.filterKey.filter((p) => p.field != e.field);
391
+ a != null && a.length && c.push({
392
+ field: e.field,
393
+ value: a
394
+ });
395
+ const g = c != null && c.length ? c : [];
396
+ e.onSearch(g), e.setfilterKey(g), M(!1);
397
+ }
398
+ },
399
+ e.language ? "Search" : "搜索"
400
+ ), /* @__PURE__ */ o.createElement(
401
+ ee,
402
+ {
403
+ style: { marginLeft: 10 },
404
+ onClick: () => {
405
+ const c = e.filterKey.filter((p) => p.field != e.field), g = c != null && c.length ? c : [];
406
+ M(!1), e.setfilterKey(g), S(null), e.onSearch(g);
407
+ }
408
+ },
409
+ e.language ? "Reset" : "重置"
410
+ )))
411
+ },
412
+ /* @__PURE__ */ o.createElement(ke, { style: { color: a ? "#1890ff" : "rgba(0, 0, 0, 0.25)", marginLeft: 10, cursor: "pointer" } })
413
+ ))), /* @__PURE__ */ o.createElement("div", { className: _.customHead }, /* @__PURE__ */ o.createElement("div", { className: "customHeaderLabel" }, e.displayName), K, $);
414
+ }, tt = ({
415
+ columnDefs: e = [],
416
+ loading: n,
417
+ customBottomTotal: t = !1,
418
+ onChange: r = () => {
419
+ },
420
+ tableRef: i,
421
+ tableData: s,
422
+ pagination: m = !1,
423
+ reset: E = {},
424
+ customColumn: x = [],
425
+ filterSearchRender: M = {},
426
+ setfilterKey: a,
427
+ filterKey: S
428
+ }) => {
429
+ const H = F(() => ({ width: "100%", height: "100%", position: "relative" }), []), b = F(() => ({ height: "100%", width: "100%" }), []), w = ge((l) => l.controller.language), K = F(() => {
430
+ const l = m && typeof m == "object" ? m.total : void 0;
431
+ return typeof l == "number" && !Number.isNaN(l) ? l : Array.isArray(s) ? s.length : 0;
432
+ }, [m, s]), U = F(() => {
433
+ let l = {};
434
+ return e.map((u, k) => {
435
+ if (k == 0)
436
+ l[u.field] = "Total", l.fromData = "total";
437
+ else {
438
+ let B = u.lockPosition ? "" : 0;
439
+ s.map((I) => {
440
+ let Q = u.field != u.key && u.key ? u.key : u.field, Y = ["jobCurrency", "industries", "jobSalaryRange"];
441
+ !isNaN(Number(I[Q])) && !Y.includes(u.field) && (B += Number(I[Q]));
442
+ }), l[u.field] = typeof B == "number" && B > 0 ? B : "--";
443
+ }
444
+ }), [l];
445
+ }, [s, e]), J = {
446
+ visible: !0,
447
+ sortable: !0,
448
+ active: !1,
449
+ unSortIcon: !0,
450
+ minWidth: 200,
451
+ comparator: (l, u, k, B, I) => 0,
452
+ headerComponent: et
453
+ // suppressMovable: !isDrag,
454
+ }, $ = F(() => ({
455
+ width: 170,
456
+ lockPinned: !0
457
+ }), []), c = R((l) => {
458
+ i && (i.current = l);
459
+ }, []), g = (l) => {
460
+ var I;
461
+ const { isNotTip: u, render: k } = l.colDef || {}, B = ((I = l.data) == null ? void 0 : I.fromData) === "total";
462
+ return k && !B ? k(l) : /* @__PURE__ */ o.createElement(de, { title: u ? "" : l.value || "", arrow: !0, placement: "top" }, typeof l.value == "number" || l.value ? l.value : "--");
463
+ }, p = R((l) => {
464
+ var k;
465
+ const u = ((k = l.api.getState().sort) == null ? void 0 : k.sortModel) ?? [];
466
+ r({
467
+ sort: u[0] ?? null,
468
+ optType: "sort"
469
+ });
470
+ }, [r]), d = (l) => {
471
+ r({
472
+ column: l.api.getColumnDefs().filter((u) => u.field).map((u) => ({
473
+ ...u,
474
+ pinned: void 0,
475
+ field: u.field,
476
+ hide: u.hide,
477
+ visible: u.visible
478
+ }))
479
+ });
480
+ }, Z = (l, u) => {
481
+ r({
482
+ optType: "mergeColum",
483
+ pagination: {
484
+ page: l,
485
+ size: u
486
+ }
487
+ });
488
+ };
489
+ return /* @__PURE__ */ o.createElement("div", { style: H }, n ? /* @__PURE__ */ o.createElement("div", { className: "loadingContent" }, /* @__PURE__ */ o.createElement(Se, null)) : null, /* @__PURE__ */ o.createElement("div", { style: b, className: "ag-theme-alpine AgGridReact" }, /* @__PURE__ */ o.createElement(
490
+ _e,
491
+ {
492
+ rowData: s,
493
+ pinnedBottomRowData: t ? U : [],
494
+ defaultColDef: $,
495
+ suppressRowTransform: !0,
496
+ onSortChanged: p,
497
+ onDragStopped: d,
498
+ suppressDragLeaveHidesColumns: !0,
499
+ suppressMovableColumns: !1,
500
+ ...E,
501
+ columnDefs: [...e.map((l) => ({
502
+ ...J,
503
+ ...l,
504
+ headerName: w ? l.enDisplay : l.cnDisplay,
505
+ // apn写法
506
+ // cellRenderer:"getCellParams",
507
+ // crm写法
508
+ cellRenderer: g,
509
+ headerComponentParams: {
510
+ onSearch: (u) => {
511
+ console.log(u, "搜索"), r({
512
+ filter: u || {}
513
+ });
514
+ },
515
+ setfilterKey: a,
516
+ filterKey: S,
517
+ language: w,
518
+ filterSearchRender: M,
519
+ ...l
520
+ }
521
+ })), ...x],
522
+ icons: {
523
+ sortAscending: `<span style="font-size: inherit;color: rgb(24, 144, 255);vertical-align:-webkit-baseline-middle">
524
+ <svg t="1688438905306" fill="currentColor" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2388" width="16" height="16"><path d="M804.571 621.714a36.206 36.206 0 0 1-10.861 25.71l-256 256c-6.84 6.839-16.019 10.862-25.71 10.862s-18.87-3.987-25.71-10.862l-256-256a36.425 36.425 0 0 1-10.861-25.71c0-20.004 16.566-36.571 36.571-36.571h512c20.005 0 36.571 16.567 36.571 36.571z" p-id="2389"></path></svg>
525
+ </span>`,
526
+ sortDescending: `<span style="font-size: inherit;color:rgb(24, 144, 255);vertical-align:-webkit-baseline-middle">
527
+ <svg t="1688438923470" fill="currentColor" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2523" width="16" height="16"><path d="M804.571 402.286c0 20.004-16.566 36.571-36.571 36.571H256c-20.005 0-36.571-16.567-36.571-36.571a36.206 36.206 0 0 1 10.861-25.71l256-256c6.84-6.839 16.019-10.862 25.71-10.862s18.87 3.987 25.71 10.862l256 256a36.425 36.425 0 0 1 10.861 25.71z" p-id="2524"></path></svg>
528
+ </span>`,
529
+ sortUnSort: `<span style="font-size: inherit;color: rgb(153, 153, 153);vertical-align:-webkit-baseline-middle">
530
+ <svg t="1688438886160" fill="currentColor" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2253" width="16" height="16"><path d="M804.571 621.714a36.206 36.206 0 0 1-10.861 25.71l-256 256c-6.84 6.839-16.019 10.862-25.71 10.862s-18.87-3.987-25.71-10.862l-256-256a36.425 36.425 0 0 1-10.861-25.71c0-20.004 16.566-36.571 36.571-36.571h512c20.005 0 36.571 16.567 36.571 36.571z m0-219.428c0 20.004-16.566 36.571-36.571 36.571H256c-20.005 0-36.571-16.567-36.571-36.571a36.206 36.206 0 0 1 10.861-25.71l256-256c6.84-6.839 16.019-10.862 25.71-10.862s18.87 3.987 25.71 10.862l256 256a36.425 36.425 0 0 1 10.861 25.71z" p-id="2254"></path></svg>
531
+ </span>`
532
+ },
533
+ onGridReady: c
534
+ }
535
+ )), m ? /* @__PURE__ */ o.createElement(we, { total: K, onChange: Z, ...m }) : null);
536
+ }, wt = (e = {}, n = {}) => {
537
+ var ie;
538
+ const {
539
+ sessionKey: t,
540
+ renderKey: r,
541
+ setParamsList: i,
542
+ configKey: s,
543
+ tableUrl: m,
544
+ tableRequest: E,
545
+ getColConfigRequest: x,
546
+ saveColConfigRequest: M
547
+ } = { ...n, ...e }, a = typeof window < "u" && !!window.sessionStorage, S = R(
548
+ (f) => {
549
+ if (a)
550
+ try {
551
+ window.sessionStorage.setItem(t, JSON.stringify(f));
552
+ } catch (y) {
553
+ console.warn("[useTableModule] sessionStorage 写入失败:", y);
554
+ }
555
+ },
556
+ [t, a]
557
+ ), H = R(() => {
558
+ if (!a) return null;
559
+ try {
560
+ const f = window.sessionStorage.getItem(t);
561
+ return f ? JSON.parse(f) : null;
562
+ } catch (f) {
563
+ return console.warn("[useTableModule] sessionStorage 读取失败:", f), null;
564
+ }
565
+ }, [t, a]), b = L([]), [w, K] = T([]), [U, J] = T([]), [$, c] = T(void 0), [g, p] = T(!0), d = L(H() || {}), [Z, l] = T(((ie = H()) == null ? void 0 : ie.filter) || []), u = L(0), k = L(E);
566
+ k.current = E;
567
+ const B = L(m);
568
+ B.current = m;
569
+ const I = L(i);
570
+ I.current = i;
571
+ const Q = L(r);
572
+ Q.current = r;
573
+ const Y = L(x);
574
+ Y.current = x;
575
+ const se = L(M);
576
+ se.current = M;
577
+ const X = R(() => {
578
+ const { sort: f } = d.current, y = b.current.map((v) => ({
579
+ ...v,
580
+ sort: f && f.colId == v.field ? f.sort : void 0
581
+ }));
582
+ K(O(y));
583
+ }, []), ne = R(() => {
584
+ const f = se.current;
585
+ if (!f) {
586
+ console.warn("[useTableModule] 未注入 saveColConfigRequest,跳过列配置保存");
587
+ return;
588
+ }
589
+ const y = {
590
+ subcategory: s,
591
+ userConfig: {
592
+ pageConfig: {
593
+ pageSize: d.current.size ? d.current.size : null
594
+ },
595
+ columnConfig: b.current
596
+ }
597
+ }, v = f(y);
598
+ v && typeof v.catch == "function" && v.catch((A) => console.error("[useTableModule] 列配置保存失败:", A));
599
+ }, [s]), z = R(() => {
600
+ const f = k.current;
601
+ if (!f) {
602
+ console.warn("[useTableModule] 未注入 tableRequest,跳过列表加载"), p(!1);
603
+ return;
604
+ }
605
+ u.current += 1;
606
+ const y = u.current, v = I.current, A = v ? v(d.current) : d.current;
607
+ return p(!0), f(A, B.current).then(
608
+ (P) => {
609
+ if (y !== u.current) return;
610
+ const C = P == null ? void 0 : P.response, N = Array.isArray(C) ? C : (C == null ? void 0 : C.data) || [], D = Array.isArray(C) || C == null ? void 0 : C.total;
611
+ typeof D == "number" && !Number.isNaN(D) && c(D);
612
+ const re = N.map((h) => ({
613
+ ...h,
614
+ ...h._source || {}
615
+ }));
616
+ J(re), p(!1);
617
+ },
618
+ (P) => {
619
+ y === u.current && (console.error("[useTableModule] 列表加载失败:", P), p(!1));
620
+ }
621
+ );
622
+ }, []), j = R(
623
+ (f) => {
624
+ const { column: y, optType: v, sort: A, pagination: P, filter: C } = f;
625
+ let N = [];
626
+ if (y) {
627
+ const D = new Map(y.map((h) => [h.field, h]));
628
+ N = b.current.map((h) => {
629
+ const G = D.get(h.field);
630
+ if (!G) return { ...h };
631
+ const ae = G.visible !== void 0 ? G.visible : !G.hide;
632
+ return { ...h, hide: !ae, visible: ae };
633
+ });
634
+ const re = new Set(b.current.map((h) => h.field));
635
+ y.forEach((h) => {
636
+ if (!re.has(h.field)) {
637
+ const G = h.visible !== void 0 ? h.visible : !h.hide;
638
+ N.push({ ...h, hide: !G, visible: G });
639
+ }
640
+ }), b.current = N, ne();
641
+ }
642
+ v == "mergeColum" && K(O(N != null && N.length ? N : b.current)), v == "sort" && (d.current = {
643
+ ...d.current,
644
+ sort: A
645
+ }, S(d.current), X(), z()), P && (d.current = {
646
+ ...d.current,
647
+ ...P
648
+ }, S(d.current), z()), C && (d.current = {
649
+ ...d.current,
650
+ filter: C
651
+ }, d.current.page && d.current.page > 1 && (d.current.page = 1), S(d.current), z());
652
+ },
653
+ [S, ne, X, z]
654
+ ), le = R(() => {
655
+ const f = Y.current;
656
+ if (!f) {
657
+ console.warn("[useTableModule] 未注入 getColConfigRequest,跳过列配置加载"), p(!1);
658
+ return;
659
+ }
660
+ const { sort: y } = d.current, v = Q.current;
661
+ f(s).then(
662
+ ({ response: A }) => {
663
+ var N;
664
+ const C = (((N = A == null ? void 0 : A.userConfig) == null ? void 0 : N.columnConfig) || []).map((D) => ({
665
+ ...D,
666
+ hide: !D.visible,
667
+ visible: D.visible,
668
+ sort: y && y.colId == D.field ? y.sort : void 0,
669
+ render: v ? v[D.field] : void 0
670
+ }));
671
+ K(O(C)), b.current = O(C), z();
672
+ },
673
+ (A) => {
674
+ console.error("[useTableModule] 列配置加载失败:", A), p(!1);
675
+ }
676
+ );
677
+ }, [s, z]), pe = R(() => {
678
+ const f = H() || {};
679
+ d.current = f, l(f.filter || []), X(), z();
680
+ }, [H, X, z]);
681
+ V(() => {
682
+ s && le();
683
+ }, [s]);
684
+ const ye = R(
685
+ (f = {}) => /* @__PURE__ */ React.createElement(Ye, { columRef: b, onChange: j, ...f }),
686
+ [j]
687
+ ), ve = R(
688
+ (f = {}) => /* @__PURE__ */ React.createElement(
689
+ tt,
690
+ {
691
+ filterKey: Z,
692
+ setfilterKey: l,
693
+ loading: g,
694
+ columnDefs: w,
695
+ pagination: {
696
+ current: d.current.page,
697
+ pageSize: d.current.size,
698
+ total: $
699
+ },
700
+ onChange: j,
701
+ tableData: U,
702
+ ...f
703
+ }
704
+ ),
705
+ [Z, g, w, U, $, j]
706
+ );
707
+ return {
708
+ SettingTableRender: ye,
709
+ TableListRender: ve,
710
+ // 需要单独回调的就抛出去,特殊场景多个列表使用,平常用url回调一次
711
+ getTableData: z,
712
+ //获取列表数据
713
+ getColConfig: le,
714
+ //获取配置接口
715
+ saveColConfig: ne,
716
+ //保存配置接口
717
+ resetSesstion: pe,
718
+ tableData: U,
719
+ setloading: p,
720
+ // 原实现漏掉了 loading / columnDefs / paramsCurrent / total,
721
+ // 使用方无法感知加载态与分页总数,这里补齐。
722
+ loading: g,
723
+ columnDefs: w,
724
+ paramsCurrent: d,
725
+ total: $,
726
+ filterKey: Z
727
+ };
728
+ }, nt = {
729
+ width: "100%"
730
+ }, _t = ({ dataIndex: e, language: n, onChange: t, value: r, ...i }) => {
731
+ const s = F(() => /* @__PURE__ */ React.createElement(
732
+ me,
733
+ {
734
+ value: r != null && r.length ? r : null,
735
+ style: nt,
736
+ ...i,
737
+ onChange: (m) => {
738
+ t(m.target.value);
739
+ }
740
+ }
741
+ ), [e, r]);
742
+ return /* @__PURE__ */ React.createElement(
743
+ "div",
744
+ {
745
+ style: {
746
+ marginBottom: 8
747
+ }
748
+ },
749
+ s
750
+ );
751
+ };
752
+ export {
753
+ Me as AG_GRID_THEMES,
754
+ yt as ActionCell,
755
+ et as CustomHeader,
756
+ ue as DEFAULT_AG_GRID_THEME,
757
+ bt as DICT_COLOR_MAP,
758
+ ht as EllipsisCell,
759
+ pt as LinkCell,
760
+ xe as MayList,
761
+ ft as MoneyCell,
762
+ mt as NumberCell,
763
+ _t as OtherSlot,
764
+ St as ROW_HEIGHT_PRESETS,
765
+ Ct as STATUS_PRESETS,
766
+ Ye as SettingTable,
767
+ Xe as SortAscending,
768
+ je as SortDescending,
769
+ Ve as SortUnSort,
770
+ tt as TableList,
771
+ gt as TagCell,
772
+ dt as TextCell,
773
+ Et as agGridClass,
774
+ vt as crmTheme,
775
+ ut as cx,
776
+ at as debounce,
777
+ O as deepClone,
778
+ Re as formatMoney,
779
+ oe as formatNumber,
780
+ Te as formatPercent,
781
+ Ne as get,
782
+ lt as groupBy,
783
+ te as isEmpty,
784
+ it as omitEmpty,
785
+ wt as useTableModule
786
+ };
787
+ //# sourceMappingURL=index.js.map