@wangcheng051/plugin-kit 0.0.0-stage → 0.1.0

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,802 @@
1
+ import r, { useState as T, useEffect as V, useRef as B, 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 o = String(n).split(".");
12
+ let i = e;
13
+ for (let s = 0; s < o.length; s += 1) {
14
+ if (i == null) return t;
15
+ i = i[o[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: o = "¥", 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 ? o : "";
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((o) => {
43
+ const i = typeof n == "function" ? n(o) : Ne(o, n);
44
+ t[i] || (t[i] = []), t[i].push(o);
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 P(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 o = [];
74
+ return n.set(e, o), e.forEach((i, s) => {
75
+ o[s] = P(i, n);
76
+ }), o;
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((o) => {
82
+ t[o] = P(e[o], n);
83
+ }), t;
84
+ }
85
+ const { Text: O } = Ce;
86
+ function dt({ value: e }) {
87
+ return e == null || e === "" ? /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-") : /* @__PURE__ */ r.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__ */ r.createElement(O, { type: "secondary" }, "-");
92
+ const o = Number(e);
93
+ return Number.isNaN(o) ? /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-") : /* @__PURE__ */ r.createElement("span", { style: { color: o < 0 ? "#ff4d4f" : void 0 } }, Re(o, { digits: n, showSymbol: t }));
94
+ }
95
+ function mt({ value: e, digits: n = 0, percent: t = !1 }) {
96
+ if (e == null || e === "")
97
+ return /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-");
98
+ const o = Number(e);
99
+ return Number.isNaN(o) ? /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-") : /* @__PURE__ */ r.createElement("span", null, t ? Te(o, n) : oe(o, n));
100
+ }
101
+ function gt({ value: e, color: n, options: t }) {
102
+ if (e == null || e === "")
103
+ return /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-");
104
+ let o = n, i = e;
105
+ if (t && t.length) {
106
+ const s = t.find((m) => String(m.value) === String(e));
107
+ s && (i = s.label, o = o ?? s.color);
108
+ }
109
+ return /* @__PURE__ */ r.createElement(be, { color: o || "default" }, i);
110
+ }
111
+ function ht({ value: e, length: n = 30 }) {
112
+ if (e == null || e === "")
113
+ return /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-");
114
+ const t = String(e);
115
+ return t.length <= n ? /* @__PURE__ */ r.createElement("span", null, t) : /* @__PURE__ */ r.createElement(de, { title: t }, /* @__PURE__ */ r.createElement(O, { ellipsis: !0, style: { maxWidth: 240 } }, t));
116
+ }
117
+ function pt({ value: e, onClick: n }) {
118
+ return e == null || e === "" ? /* @__PURE__ */ r.createElement(O, { type: "secondary" }, "-") : /* @__PURE__ */ r.createElement("a", { onClick: () => n && n(e) }, String(e));
119
+ }
120
+ function yt({ value: e, actions: n = [] }) {
121
+ return /* @__PURE__ */ r.createElement("span", null, n.map((t) => /* @__PURE__ */ r.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((u) => u.controller), [o, i] = T(!1), [s, m] = T(
204
+ P(n.current)
205
+ );
206
+ V(() => {
207
+ const u = n == null ? void 0 : n.current;
208
+ !u || !u.length || o || m(P(u));
209
+ }, [n == null ? void 0 : n.current, o]);
210
+ const E = () => {
211
+ e({
212
+ column: s,
213
+ optType: "mergeColum"
214
+ }), i(!1);
215
+ }, x = (u) => {
216
+ s[u].visible = !s[u].visible, m([...s]);
217
+ }, M = () => {
218
+ m(P(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: !!o,
227
+ onOpenChange: (u) => {
228
+ i(u);
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((u, S) => /* @__PURE__ */ React.createElement(
252
+ "div",
253
+ {
254
+ style: {
255
+ height: "32px",
256
+ display: "flex",
257
+ alignItems: "center"
258
+ },
259
+ key: u + S
260
+ },
261
+ /* @__PURE__ */ React.createElement(
262
+ Ee,
263
+ {
264
+ color: "primary",
265
+ checked: u.visible,
266
+ disabled: u.disabled,
267
+ onChange: (L) => 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 ? u.enDisplay : u.cnDisplay) || u.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__ */ r.createElement("svg", { ...ce, ...e, t: "1688438905306", "p-id": "2388" }, /* @__PURE__ */ r.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__ */ r.createElement("svg", { ...ce, ...e, t: "1688438923470", "p-id": "2523" }, /* @__PURE__ */ r.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__ */ r.createElement("svg", { ...ce, ...e, t: "1688438886160", "p-id": "2253" }, /* @__PURE__ */ r.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"), [o, i] = T("inactive"), [s, m] = T("inactive"), E = B(null), [x, M] = T(!1), [u, S] = T(null), L = () => {
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
+ 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 q = null;
349
+ e.enableSorting && (q = /* @__PURE__ */ r.createElement("div", { className: _.sortNames }, /* @__PURE__ */ r.createElement(
350
+ "div",
351
+ {
352
+ onClick: (c) => w("asc", c),
353
+ onTouchEnd: (c) => w("asc", c),
354
+ className: `${_.customSort} ${_[n]}`
355
+ },
356
+ /* @__PURE__ */ r.createElement(Xe, null)
357
+ ), /* @__PURE__ */ r.createElement(
358
+ "div",
359
+ {
360
+ onClick: (c) => w("desc", c),
361
+ onTouchEnd: (c) => w("desc", c),
362
+ className: `${_.customSort} ${_[o]}`
363
+ },
364
+ /* @__PURE__ */ r.createElement(je, null)
365
+ ), /* @__PURE__ */ r.createElement(
366
+ "div",
367
+ {
368
+ onClick: (c) => w("", c),
369
+ onTouchEnd: (c) => w("", c),
370
+ className: `${_.customSort} ${_.customUnSort} ${_[s]}`
371
+ },
372
+ /* @__PURE__ */ r.createElement(Ve, null)
373
+ )));
374
+ const U = {
375
+ width: "100%"
376
+ }, J = F(() => {
377
+ var g, p;
378
+ let c = ((g = e.filterSearchRender[e.field]) == null ? void 0 : g.render) || me;
379
+ return /* @__PURE__ */ r.createElement(
380
+ c,
381
+ {
382
+ ...((p = e.filterSearchRender[e.field]) == null ? void 0 : p.tPropty) || {},
383
+ value: u,
384
+ onChange: (d) => {
385
+ S(d.target ? d.target.value : d);
386
+ },
387
+ style: U
388
+ }
389
+ );
390
+ }, [e.field, u]);
391
+ let K = null;
392
+ return e.search && (K = /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(
393
+ fe,
394
+ {
395
+ arrow: !1,
396
+ open: x,
397
+ trigger: "click",
398
+ overlayClassName: _.popoverContext,
399
+ onOpenChange: (c) => M(c),
400
+ placement: "bottom",
401
+ content: /* @__PURE__ */ r.createElement("div", { className: _.contextRender }, J, /* @__PURE__ */ r.createElement("div", { className: _.contextRenderFooter }, /* @__PURE__ */ r.createElement(
402
+ ee,
403
+ {
404
+ type: "primary",
405
+ onClick: () => {
406
+ const c = e.filterKey.filter((p) => p.field != e.field);
407
+ u != null && u.length && c.push({
408
+ field: e.field,
409
+ value: u
410
+ });
411
+ const g = c != null && c.length ? c : [];
412
+ e.onSearch(g), e.setfilterKey(g), M(!1);
413
+ }
414
+ },
415
+ e.language ? "Search" : "搜索"
416
+ ), /* @__PURE__ */ r.createElement(
417
+ ee,
418
+ {
419
+ style: { marginLeft: 10 },
420
+ onClick: () => {
421
+ const c = e.filterKey.filter((p) => p.field != e.field), g = c != null && c.length ? c : [];
422
+ M(!1), e.setfilterKey(g), S(null), e.onSearch(g);
423
+ }
424
+ },
425
+ e.language ? "Reset" : "重置"
426
+ )))
427
+ },
428
+ /* @__PURE__ */ r.createElement(ke, { style: { color: u ? "#1890ff" : "rgba(0, 0, 0, 0.25)", marginLeft: 10, cursor: "pointer" } })
429
+ ))), /* @__PURE__ */ r.createElement("div", { className: _.customHead }, /* @__PURE__ */ r.createElement("div", { className: "customHeaderLabel" }, e.displayName), q, K);
430
+ }, tt = ({
431
+ columnDefs: e = [],
432
+ loading: n,
433
+ customBottomTotal: t = !1,
434
+ onChange: o = () => {
435
+ },
436
+ tableRef: i,
437
+ tableData: s,
438
+ pagination: m = !1,
439
+ reset: E = {},
440
+ customColumn: x = [],
441
+ filterSearchRender: M = {},
442
+ setfilterKey: u,
443
+ filterKey: S
444
+ }) => {
445
+ const L = F(() => ({ width: "100%", height: "100%", position: "relative" }), []), b = F(() => ({ height: "100%", width: "100%" }), []), w = ge((l) => l.controller.language), q = F(() => {
446
+ const l = m && typeof m == "object" ? m.total : void 0;
447
+ return typeof l == "number" && !Number.isNaN(l) ? l : Array.isArray(s) ? s.length : 0;
448
+ }, [m, s]), U = F(() => {
449
+ let l = {};
450
+ return e.map((a, $) => {
451
+ if ($ == 0)
452
+ l[a.field] = "Total", l.fromData = "total";
453
+ else {
454
+ let D = a.lockPosition ? "" : 0;
455
+ s.map((H) => {
456
+ let Q = a.field != a.key && a.key ? a.key : a.field, Y = ["jobCurrency", "industries", "jobSalaryRange"];
457
+ !isNaN(Number(H[Q])) && !Y.includes(a.field) && (D += Number(H[Q]));
458
+ }), l[a.field] = typeof D == "number" && D > 0 ? D : "--";
459
+ }
460
+ }), [l];
461
+ }, [s, e]), J = {
462
+ visible: !0,
463
+ sortable: !0,
464
+ active: !1,
465
+ unSortIcon: !0,
466
+ minWidth: 200,
467
+ comparator: (l, a, $, D, H) => 0,
468
+ headerComponent: et
469
+ // suppressMovable: !isDrag,
470
+ }, K = F(() => ({
471
+ width: 170,
472
+ lockPinned: !0
473
+ }), []), c = R((l) => {
474
+ i && (i.current = l);
475
+ }, []), g = (l) => {
476
+ var H;
477
+ const { isNotTip: a, render: $ } = l.colDef || {}, D = ((H = l.data) == null ? void 0 : H.fromData) === "total";
478
+ return $ && !D ? $(l) : /* @__PURE__ */ r.createElement(de, { title: a ? "" : l.value || "", arrow: !0, placement: "top" }, typeof l.value == "number" || l.value ? l.value : "--");
479
+ }, p = R((l) => {
480
+ const { sortModel: a } = l.api.getState().sort || {};
481
+ console.log(a, "sortModel"), o({
482
+ sort: a ? a[0] : null,
483
+ optType: "sort"
484
+ });
485
+ }, []), d = (l) => {
486
+ o({
487
+ column: l.api.getColumnDefs().filter((a) => a.field).map((a) => ({
488
+ ...a,
489
+ pinned: void 0,
490
+ field: a.field,
491
+ hide: a.hide,
492
+ visible: a.visible
493
+ }))
494
+ });
495
+ }, Z = (l, a) => {
496
+ o({
497
+ optType: "mergeColum",
498
+ pagination: {
499
+ page: l,
500
+ size: a
501
+ }
502
+ });
503
+ };
504
+ return /* @__PURE__ */ r.createElement("div", { style: L }, n ? /* @__PURE__ */ r.createElement("div", { className: "loadingContent" }, /* @__PURE__ */ r.createElement(Se, null)) : null, /* @__PURE__ */ r.createElement("div", { style: b, className: "ag-theme-alpine AgGridReact" }, /* @__PURE__ */ r.createElement(
505
+ _e,
506
+ {
507
+ rowData: s,
508
+ pinnedBottomRowData: t ? U : [],
509
+ defaultColDef: K,
510
+ suppressRowTransform: !0,
511
+ onSortChanged: p,
512
+ onDragStopped: d,
513
+ suppressDragLeaveHidesColumns: !0,
514
+ suppressMovableColumns: !1,
515
+ ...E,
516
+ columnDefs: [...e.map((l) => ({
517
+ ...J,
518
+ ...l,
519
+ headerName: w ? l.enDisplay : l.cnDisplay,
520
+ // apn写法
521
+ // cellRenderer:"getCellParams",
522
+ // crm写法
523
+ cellRenderer: g,
524
+ headerComponentParams: {
525
+ onSearch: (a) => {
526
+ console.log(a, "搜索"), o({
527
+ filter: a || {}
528
+ });
529
+ },
530
+ setfilterKey: u,
531
+ filterKey: S,
532
+ language: w,
533
+ filterSearchRender: M,
534
+ ...l
535
+ }
536
+ })), ...x],
537
+ icons: {
538
+ sortAscending: `<span style="font-size: inherit;color: rgb(24, 144, 255);vertical-align:-webkit-baseline-middle">
539
+ <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>
540
+ </span>`,
541
+ sortDescending: `<span style="font-size: inherit;color:rgb(24, 144, 255);vertical-align:-webkit-baseline-middle">
542
+ <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>
543
+ </span>`,
544
+ sortUnSort: `<span style="font-size: inherit;color: rgb(153, 153, 153);vertical-align:-webkit-baseline-middle">
545
+ <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>
546
+ </span>`
547
+ },
548
+ onGridReady: c
549
+ }
550
+ )), m ? /* @__PURE__ */ r.createElement(we, { total: q, onChange: Z, ...m }) : null);
551
+ }, wt = (e = {}, n = {}) => {
552
+ var ie;
553
+ const {
554
+ sessionKey: t,
555
+ renderKey: o,
556
+ setParamsList: i,
557
+ configKey: s,
558
+ tableUrl: m,
559
+ tableRequest: E,
560
+ getColConfigRequest: x,
561
+ saveColConfigRequest: M
562
+ } = { ...n, ...e }, u = typeof window < "u" && !!window.sessionStorage, S = R(
563
+ (f) => {
564
+ if (u)
565
+ try {
566
+ window.sessionStorage.setItem(t, JSON.stringify(f));
567
+ } catch (y) {
568
+ console.warn("[useTableModule] sessionStorage 写入失败:", y);
569
+ }
570
+ },
571
+ [t, u]
572
+ ), L = R(() => {
573
+ if (!u) return null;
574
+ try {
575
+ const f = window.sessionStorage.getItem(t);
576
+ return f ? JSON.parse(f) : null;
577
+ } catch (f) {
578
+ return console.warn("[useTableModule] sessionStorage 读取失败:", f), null;
579
+ }
580
+ }, [t, u]), b = B([]), [w, q] = T([]), [U, J] = T([]), [K, c] = T(void 0), [g, p] = T(!0), d = B(L() || {}), [Z, l] = T(((ie = L()) == null ? void 0 : ie.filter) || []), a = B(0), $ = B(E);
581
+ $.current = E;
582
+ const D = B(m);
583
+ D.current = m;
584
+ const H = B(i);
585
+ H.current = i;
586
+ const Q = B(o);
587
+ Q.current = o;
588
+ const Y = B(x);
589
+ Y.current = x;
590
+ const se = B(M);
591
+ se.current = M;
592
+ const X = R(() => {
593
+ const { sort: f } = d.current, y = b.current.map((v) => ({
594
+ ...v,
595
+ sort: f && f.colId == v.field ? f.sort : void 0
596
+ }));
597
+ q(P(y));
598
+ }, []), ne = R(() => {
599
+ const f = se.current;
600
+ if (!f) {
601
+ console.warn("[useTableModule] 未注入 saveColConfigRequest,跳过列配置保存");
602
+ return;
603
+ }
604
+ const y = {
605
+ subcategory: s,
606
+ userConfig: {
607
+ pageConfig: {
608
+ pageSize: d.current.size ? d.current.size : null
609
+ },
610
+ columnConfig: b.current
611
+ }
612
+ }, v = f(y);
613
+ v && typeof v.catch == "function" && v.catch((k) => console.error("[useTableModule] 列配置保存失败:", k));
614
+ }, [s]), I = R(() => {
615
+ const f = $.current;
616
+ if (!f) {
617
+ console.warn("[useTableModule] 未注入 tableRequest,跳过列表加载"), p(!1);
618
+ return;
619
+ }
620
+ a.current += 1;
621
+ const y = a.current, v = H.current, k = v ? v(d.current) : d.current;
622
+ return p(!0), f(k, D.current).then(
623
+ (z) => {
624
+ if (y !== a.current) return;
625
+ const C = z == null ? void 0 : z.response, N = Array.isArray(C) ? C : (C == null ? void 0 : C.data) || [], A = Array.isArray(C) || C == null ? void 0 : C.total;
626
+ typeof A == "number" && !Number.isNaN(A) && c(A);
627
+ const re = N.map((h) => ({
628
+ ...h,
629
+ ...h._source || {}
630
+ }));
631
+ J(re), p(!1);
632
+ },
633
+ (z) => {
634
+ y === a.current && (console.error("[useTableModule] 列表加载失败:", z), p(!1));
635
+ }
636
+ );
637
+ }, []), j = R(
638
+ (f) => {
639
+ const { column: y, optType: v, sort: k, pagination: z, filter: C } = f;
640
+ let N = [];
641
+ if (y) {
642
+ const A = new Map(y.map((h) => [h.field, h]));
643
+ N = b.current.map((h) => {
644
+ const G = A.get(h.field);
645
+ if (!G) return { ...h };
646
+ const ae = G.visible !== void 0 ? G.visible : !G.hide;
647
+ return { ...h, hide: !ae, visible: ae };
648
+ });
649
+ const re = new Set(b.current.map((h) => h.field));
650
+ y.forEach((h) => {
651
+ if (!re.has(h.field)) {
652
+ const G = h.visible !== void 0 ? h.visible : !h.hide;
653
+ N.push({ ...h, hide: !G, visible: G });
654
+ }
655
+ }), b.current = N, ne();
656
+ }
657
+ v == "mergeColum" && q(P(N != null && N.length ? N : b.current)), v == "sort" && (d.current = {
658
+ ...d.current,
659
+ sort: k
660
+ }, S(d.current), X(), I()), z && (d.current = {
661
+ ...d.current,
662
+ ...z
663
+ }, S(d.current), I()), C && (d.current = {
664
+ ...d.current,
665
+ filter: C
666
+ }, d.current.page && d.current.page > 1 && (d.current.page = 1), S(d.current), I());
667
+ },
668
+ [S, ne, X, I]
669
+ ), le = R(() => {
670
+ const f = Y.current;
671
+ if (!f) {
672
+ console.warn("[useTableModule] 未注入 getColConfigRequest,跳过列配置加载"), p(!1);
673
+ return;
674
+ }
675
+ const { sort: y } = d.current, v = Q.current;
676
+ f(s).then(
677
+ ({ response: k }) => {
678
+ var N;
679
+ const C = (((N = k == null ? void 0 : k.userConfig) == null ? void 0 : N.columnConfig) || []).map((A) => ({
680
+ ...A,
681
+ hide: !A.visible,
682
+ visible: A.visible,
683
+ sort: y && y.colId == A.field ? y.sort : void 0,
684
+ render: v ? v[A.field] : void 0
685
+ }));
686
+ q(P(C)), b.current = P(C), I();
687
+ },
688
+ (k) => {
689
+ console.error("[useTableModule] 列配置加载失败:", k), p(!1);
690
+ }
691
+ );
692
+ }, [s, I]), pe = R(() => {
693
+ const f = L() || {};
694
+ d.current = f, l(f.filter || []), X(), I();
695
+ }, [L, X, I]);
696
+ V(() => {
697
+ s && le();
698
+ }, [s]);
699
+ const ye = R(
700
+ (f = {}) => /* @__PURE__ */ React.createElement(Ye, { columRef: b, onChange: j, ...f }),
701
+ [j]
702
+ ), ve = R(
703
+ (f = {}) => /* @__PURE__ */ React.createElement(
704
+ tt,
705
+ {
706
+ filterKey: Z,
707
+ setfilterKey: l,
708
+ loading: g,
709
+ columnDefs: w,
710
+ pagination: {
711
+ current: d.current.page,
712
+ pageSize: d.current.size,
713
+ total: K
714
+ },
715
+ onChange: j,
716
+ tableData: U,
717
+ ...f
718
+ }
719
+ ),
720
+ [Z, g, w, U, K, j]
721
+ );
722
+ return {
723
+ SettingTableRender: ye,
724
+ TableListRender: ve,
725
+ // 需要单独回调的就抛出去,特殊场景多个列表使用,平常用url回调一次
726
+ getTableData: I,
727
+ //获取列表数据
728
+ getColConfig: le,
729
+ //获取配置接口
730
+ saveColConfig: ne,
731
+ //保存配置接口
732
+ resetSesstion: pe,
733
+ tableData: U,
734
+ setloading: p,
735
+ // 原实现漏掉了 loading / columnDefs / paramsCurrent / total,
736
+ // 使用方无法感知加载态与分页总数,这里补齐。
737
+ loading: g,
738
+ columnDefs: w,
739
+ paramsCurrent: d,
740
+ total: K,
741
+ filterKey: Z
742
+ };
743
+ }, nt = {
744
+ width: "100%"
745
+ }, _t = ({ dataIndex: e, language: n, onChange: t, value: o, ...i }) => {
746
+ const s = F(() => /* @__PURE__ */ React.createElement(
747
+ me,
748
+ {
749
+ value: o != null && o.length ? o : null,
750
+ style: nt,
751
+ ...i,
752
+ onChange: (m) => {
753
+ t(m.target.value);
754
+ }
755
+ }
756
+ ), [e, o]);
757
+ return /* @__PURE__ */ React.createElement(
758
+ "div",
759
+ {
760
+ style: {
761
+ marginBottom: 8
762
+ }
763
+ },
764
+ s
765
+ );
766
+ };
767
+ export {
768
+ Me as AG_GRID_THEMES,
769
+ yt as ActionCell,
770
+ et as CustomHeader,
771
+ ue as DEFAULT_AG_GRID_THEME,
772
+ bt as DICT_COLOR_MAP,
773
+ ht as EllipsisCell,
774
+ pt as LinkCell,
775
+ xe as MayList,
776
+ ft as MoneyCell,
777
+ mt as NumberCell,
778
+ _t as OtherSlot,
779
+ St as ROW_HEIGHT_PRESETS,
780
+ Ct as STATUS_PRESETS,
781
+ Ye as SettingTable,
782
+ Xe as SortAscending,
783
+ je as SortDescending,
784
+ Ve as SortUnSort,
785
+ tt as TableList,
786
+ gt as TagCell,
787
+ dt as TextCell,
788
+ Et as agGridClass,
789
+ vt as crmTheme,
790
+ ut as cx,
791
+ at as debounce,
792
+ P as deepClone,
793
+ Re as formatMoney,
794
+ oe as formatNumber,
795
+ Te as formatPercent,
796
+ Ne as get,
797
+ lt as groupBy,
798
+ te as isEmpty,
799
+ it as omitEmpty,
800
+ wt as useTableModule
801
+ };
802
+ //# sourceMappingURL=index.js.map