@pnt-team/pnt-component-frontend 0.0.130 → 0.0.133
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/lib/cjs/components/PntSecureBox/index.js +6 -2
- package/lib/cjs/components/PntTable/index.d.ts +14 -0
- package/lib/cjs/components/PntTable/index.js +359 -0
- package/lib/cjs/components/PntTable/index.scss +315 -0
- package/lib/cjs/components/PntTable/types.d.ts +225 -0
- package/lib/cjs/components/PntTable/types.js +17 -0
- package/lib/cjs/components/PntTable/useTableCore.d.ts +38 -0
- package/lib/cjs/components/PntTable/useTableCore.js +491 -0
- package/lib/cjs/hooks/useHighSecurity.js +11 -5
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +3 -0
- package/lib/esm/components/PntSecureBox/index.js +11 -2
- package/lib/esm/components/PntTable/index.d.ts +14 -0
- package/lib/esm/components/PntTable/index.js +404 -0
- package/lib/esm/components/PntTable/index.scss +315 -0
- package/lib/esm/components/PntTable/types.d.ts +225 -0
- package/lib/esm/components/PntTable/types.js +1 -0
- package/lib/esm/components/PntTable/useTableCore.d.ts +38 -0
- package/lib/esm/components/PntTable/useTableCore.js +479 -0
- package/lib/esm/hooks/useHighSecurity.js +14 -4
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +1 -1
- package/lib/umd/pnt-component-frontend.min.css +1 -1
- package/lib/umd/pnt-component-frontend.min.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/PntTable/useTableCore.ts
|
|
20
|
+
var useTableCore_exports = {};
|
|
21
|
+
__export(useTableCore_exports, {
|
|
22
|
+
clampPage: () => clampPage,
|
|
23
|
+
cycleSort: () => cycleSort,
|
|
24
|
+
useTableCore: () => useTableCore,
|
|
25
|
+
validateColumnConflicts: () => validateColumnConflicts,
|
|
26
|
+
validateJumpPage: () => validateJumpPage
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(useTableCore_exports);
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var RequestManager = class {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.requestIdCounter = 0;
|
|
33
|
+
this.abortController = null;
|
|
34
|
+
}
|
|
35
|
+
nextId() {
|
|
36
|
+
if (this.abortController) {
|
|
37
|
+
try {
|
|
38
|
+
this.abortController.abort();
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this.abortController = new AbortController();
|
|
43
|
+
return ++this.requestIdCounter;
|
|
44
|
+
}
|
|
45
|
+
isLatest(id) {
|
|
46
|
+
return id === this.requestIdCounter;
|
|
47
|
+
}
|
|
48
|
+
abortCurrent() {
|
|
49
|
+
if (this.abortController) {
|
|
50
|
+
try {
|
|
51
|
+
this.abortController.abort();
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
this.abortController = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function cycleSort(currentField, currentDir, targetField) {
|
|
59
|
+
if (currentField !== targetField) {
|
|
60
|
+
return { field: targetField, direction: "asc" };
|
|
61
|
+
}
|
|
62
|
+
if (currentDir === void 0 || currentDir === null)
|
|
63
|
+
return { field: targetField, direction: "asc" };
|
|
64
|
+
if (currentDir === "asc")
|
|
65
|
+
return { field: targetField, direction: "desc" };
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function clampPage(page, total, pageSize) {
|
|
69
|
+
const maxPage = Math.max(1, Math.ceil(total / pageSize));
|
|
70
|
+
if (page < 1)
|
|
71
|
+
return 1;
|
|
72
|
+
if (page > maxPage)
|
|
73
|
+
return maxPage;
|
|
74
|
+
return page;
|
|
75
|
+
}
|
|
76
|
+
function validateJumpPage(page, total, pageSize) {
|
|
77
|
+
const maxPage = Math.max(1, Math.ceil(total / pageSize));
|
|
78
|
+
if (!Number.isInteger(page) || page < 1 || page > maxPage) {
|
|
79
|
+
return `请输入 1–${maxPage} 的整数页码`;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function validateColumnConflicts(columns) {
|
|
84
|
+
const errors = [];
|
|
85
|
+
columns.forEach((col) => {
|
|
86
|
+
if (col.sort && col.headerFilter) {
|
|
87
|
+
errors.push(
|
|
88
|
+
`[PntTable] 列 "${col.key}" 同时配置了 sort 和 headerFilter,违反 TBL-01.03 互斥规则。 如需该字段同时排序+筛选,表头保留 sort,筛选移至 externalFilter(独立查询区)。`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return errors;
|
|
93
|
+
}
|
|
94
|
+
function useTableCore(props) {
|
|
95
|
+
const {
|
|
96
|
+
tableId,
|
|
97
|
+
rowKey,
|
|
98
|
+
columns,
|
|
99
|
+
dataMode,
|
|
100
|
+
fetcher,
|
|
101
|
+
data: clientData,
|
|
102
|
+
total: clientTotal,
|
|
103
|
+
initialPage = 1,
|
|
104
|
+
pageSize: initialPageSize = 10,
|
|
105
|
+
businessId,
|
|
106
|
+
env,
|
|
107
|
+
timezone,
|
|
108
|
+
onQueryChange,
|
|
109
|
+
onSelectionChange,
|
|
110
|
+
selectable = false,
|
|
111
|
+
currentPageOnly = true
|
|
112
|
+
} = props;
|
|
113
|
+
const reqMgrRef = (0, import_react.useRef)(new RequestManager());
|
|
114
|
+
const [requestId, setRequestId] = (0, import_react.useState)(0);
|
|
115
|
+
const [state, setState] = (0, import_react.useState)(() => {
|
|
116
|
+
var _a;
|
|
117
|
+
return {
|
|
118
|
+
data: dataMode === "client" ? clientData != null ? clientData : [] : [],
|
|
119
|
+
total: dataMode === "client" ? (_a = clientTotal != null ? clientTotal : clientData == null ? void 0 : clientData.length) != null ? _a : 0 : 0,
|
|
120
|
+
status: dataMode === "client" ? "normal" : "loading",
|
|
121
|
+
error: null,
|
|
122
|
+
sort: null,
|
|
123
|
+
appliedFilters: {},
|
|
124
|
+
page: initialPage,
|
|
125
|
+
pageSize: initialPageSize,
|
|
126
|
+
selection: /* @__PURE__ */ new Set()
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
const setStatePartial = (0, import_react.useCallback)((patch) => {
|
|
130
|
+
setState((prev) => ({ ...prev, ...patch }));
|
|
131
|
+
}, []);
|
|
132
|
+
const triggerFetch = (0, import_react.useCallback)(
|
|
133
|
+
async (trigger, snapshot) => {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
if (dataMode !== "server" || !fetcher)
|
|
136
|
+
return;
|
|
137
|
+
const thisReqId = reqMgrRef.current.nextId();
|
|
138
|
+
const query = {
|
|
139
|
+
query: {},
|
|
140
|
+
// 独立查询区(组件不维护,由业务项目维护并透传)
|
|
141
|
+
filters: snapshot.appliedFilters,
|
|
142
|
+
sort: snapshot.sort,
|
|
143
|
+
page: snapshot.page,
|
|
144
|
+
pageSize: snapshot.pageSize,
|
|
145
|
+
businessId,
|
|
146
|
+
env,
|
|
147
|
+
timezone
|
|
148
|
+
};
|
|
149
|
+
onQueryChange == null ? void 0 : onQueryChange(query, { tableId, trigger, requestId: thisReqId });
|
|
150
|
+
setStatePartial({
|
|
151
|
+
status: snapshot.page > 1 || requestId > 0 ? "refreshing" : "loading"
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
const res = await fetcher(query);
|
|
155
|
+
if (!reqMgrRef.current.isLatest(thisReqId))
|
|
156
|
+
return;
|
|
157
|
+
if (res.noPermission) {
|
|
158
|
+
setStatePartial({
|
|
159
|
+
status: "no-permission",
|
|
160
|
+
error: null,
|
|
161
|
+
data: [],
|
|
162
|
+
total: 0
|
|
163
|
+
});
|
|
164
|
+
setRequestId(thisReqId);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (res.code !== void 0 && res.code !== 0) {
|
|
168
|
+
setStatePartial({ status: "error", error: res.msg || "加载失败" });
|
|
169
|
+
setRequestId(thisReqId);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const rows = (_a = res.rows) != null ? _a : [];
|
|
173
|
+
setStatePartial({
|
|
174
|
+
data: rows,
|
|
175
|
+
total: (_b = res.total) != null ? _b : rows.length,
|
|
176
|
+
status: rows.length === 0 ? Object.values(snapshot.appliedFilters).some(
|
|
177
|
+
(v) => v !== void 0 && v !== null && v !== ""
|
|
178
|
+
) ? "empty-with-filter" : "empty" : "normal",
|
|
179
|
+
error: null
|
|
180
|
+
});
|
|
181
|
+
setRequestId(thisReqId);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
if (!reqMgrRef.current.isLatest(thisReqId))
|
|
184
|
+
return;
|
|
185
|
+
if ((err == null ? void 0 : err.name) === "AbortError")
|
|
186
|
+
return;
|
|
187
|
+
setStatePartial({ status: "error", error: (err == null ? void 0 : err.message) || "加载失败" });
|
|
188
|
+
setRequestId(thisReqId);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
[
|
|
192
|
+
dataMode,
|
|
193
|
+
fetcher,
|
|
194
|
+
tableId,
|
|
195
|
+
businessId,
|
|
196
|
+
env,
|
|
197
|
+
timezone,
|
|
198
|
+
onQueryChange,
|
|
199
|
+
requestId,
|
|
200
|
+
setStatePartial
|
|
201
|
+
]
|
|
202
|
+
);
|
|
203
|
+
(0, import_react.useEffect)(() => {
|
|
204
|
+
if (dataMode === "server" && fetcher) {
|
|
205
|
+
const page = initialPage;
|
|
206
|
+
const pageSize = state.pageSize;
|
|
207
|
+
setStatePartial({ page, pageSize });
|
|
208
|
+
triggerFetch("initial", {
|
|
209
|
+
sort: null,
|
|
210
|
+
appliedFilters: {},
|
|
211
|
+
page,
|
|
212
|
+
pageSize
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}, [tableId, dataMode]);
|
|
216
|
+
const toggleSort = (0, import_react.useCallback)(
|
|
217
|
+
(field) => {
|
|
218
|
+
if (dataMode !== "server")
|
|
219
|
+
return;
|
|
220
|
+
const col = columns.find((c) => c.key === field);
|
|
221
|
+
if (!col || col.sort === false)
|
|
222
|
+
return;
|
|
223
|
+
setState((prev) => {
|
|
224
|
+
var _a, _b, _c, _d;
|
|
225
|
+
const newSort = cycleSort(
|
|
226
|
+
(_b = (_a = prev.sort) == null ? void 0 : _a.field) != null ? _b : null,
|
|
227
|
+
(_c = prev.sort) == null ? void 0 : _c.direction,
|
|
228
|
+
field
|
|
229
|
+
);
|
|
230
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
231
|
+
const clearedPage = ((_d = prev.sort) == null ? void 0 : _d.field) !== field ? prev.page : prev.page;
|
|
232
|
+
const newPage = newSort ? 1 : clearedPage;
|
|
233
|
+
const next = {
|
|
234
|
+
...prev,
|
|
235
|
+
sort: newSort,
|
|
236
|
+
page: newPage,
|
|
237
|
+
selection: clearedSelection
|
|
238
|
+
};
|
|
239
|
+
if (newSort) {
|
|
240
|
+
triggerFetch("sort", {
|
|
241
|
+
sort: newSort,
|
|
242
|
+
appliedFilters: next.appliedFilters,
|
|
243
|
+
page: newPage,
|
|
244
|
+
pageSize: next.pageSize
|
|
245
|
+
});
|
|
246
|
+
} else if (prev.sort) {
|
|
247
|
+
triggerFetch("sort", {
|
|
248
|
+
sort: null,
|
|
249
|
+
appliedFilters: next.appliedFilters,
|
|
250
|
+
page: newPage,
|
|
251
|
+
pageSize: next.pageSize
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return next;
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
[dataMode, columns, triggerFetch, currentPageOnly]
|
|
258
|
+
);
|
|
259
|
+
const applyFilters = (0, import_react.useCallback)(
|
|
260
|
+
(filters) => {
|
|
261
|
+
const normalized = {};
|
|
262
|
+
Object.entries(filters).forEach(([k, v]) => {
|
|
263
|
+
if (Array.isArray(v) && v.length === 0)
|
|
264
|
+
return;
|
|
265
|
+
if (v === void 0 || v === null || v === "")
|
|
266
|
+
return;
|
|
267
|
+
normalized[k] = v;
|
|
268
|
+
});
|
|
269
|
+
setState((prev) => {
|
|
270
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
271
|
+
const next = {
|
|
272
|
+
...prev,
|
|
273
|
+
appliedFilters: normalized,
|
|
274
|
+
page: 1,
|
|
275
|
+
// 筛选变更回 1 页(TBL-04.05)
|
|
276
|
+
selection: clearedSelection
|
|
277
|
+
};
|
|
278
|
+
triggerFetch("filter", {
|
|
279
|
+
sort: next.sort,
|
|
280
|
+
appliedFilters: normalized,
|
|
281
|
+
page: 1,
|
|
282
|
+
pageSize: next.pageSize
|
|
283
|
+
});
|
|
284
|
+
return next;
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
[triggerFetch, currentPageOnly]
|
|
288
|
+
);
|
|
289
|
+
const resetFilters = (0, import_react.useCallback)(() => {
|
|
290
|
+
setState((prev) => {
|
|
291
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
292
|
+
const next = {
|
|
293
|
+
...prev,
|
|
294
|
+
appliedFilters: {},
|
|
295
|
+
page: 1,
|
|
296
|
+
selection: clearedSelection
|
|
297
|
+
};
|
|
298
|
+
triggerFetch("reset", {
|
|
299
|
+
sort: next.sort,
|
|
300
|
+
appliedFilters: {},
|
|
301
|
+
page: 1,
|
|
302
|
+
pageSize: next.pageSize
|
|
303
|
+
});
|
|
304
|
+
return next;
|
|
305
|
+
});
|
|
306
|
+
}, [triggerFetch, currentPageOnly]);
|
|
307
|
+
const setPage = (0, import_react.useCallback)(
|
|
308
|
+
(page) => {
|
|
309
|
+
if (dataMode !== "server")
|
|
310
|
+
return;
|
|
311
|
+
setState((prev) => {
|
|
312
|
+
const validated = clampPage(page, prev.total, prev.pageSize);
|
|
313
|
+
if (validated === prev.page)
|
|
314
|
+
return prev;
|
|
315
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
316
|
+
const next = { ...prev, page: validated, selection: clearedSelection };
|
|
317
|
+
triggerFetch("pagination", {
|
|
318
|
+
sort: next.sort,
|
|
319
|
+
appliedFilters: next.appliedFilters,
|
|
320
|
+
page: validated,
|
|
321
|
+
pageSize: next.pageSize
|
|
322
|
+
});
|
|
323
|
+
return next;
|
|
324
|
+
});
|
|
325
|
+
},
|
|
326
|
+
[dataMode, triggerFetch, currentPageOnly]
|
|
327
|
+
);
|
|
328
|
+
const setPageSize = (0, import_react.useCallback)(
|
|
329
|
+
(size) => {
|
|
330
|
+
if (dataMode !== "server")
|
|
331
|
+
return;
|
|
332
|
+
setState((prev) => {
|
|
333
|
+
if (size === prev.pageSize)
|
|
334
|
+
return prev;
|
|
335
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
336
|
+
const next = {
|
|
337
|
+
...prev,
|
|
338
|
+
pageSize: size,
|
|
339
|
+
page: 1,
|
|
340
|
+
selection: clearedSelection
|
|
341
|
+
};
|
|
342
|
+
triggerFetch("page-size", {
|
|
343
|
+
sort: next.sort,
|
|
344
|
+
appliedFilters: next.appliedFilters,
|
|
345
|
+
page: 1,
|
|
346
|
+
pageSize: size
|
|
347
|
+
});
|
|
348
|
+
return next;
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
[dataMode, triggerFetch, currentPageOnly]
|
|
352
|
+
);
|
|
353
|
+
const toggleRow = (0, import_react.useCallback)(
|
|
354
|
+
(key, selected) => {
|
|
355
|
+
if (!selectable)
|
|
356
|
+
return;
|
|
357
|
+
setState((prev) => {
|
|
358
|
+
const next = new Set(prev.selection);
|
|
359
|
+
if (selected)
|
|
360
|
+
next.add(key);
|
|
361
|
+
else
|
|
362
|
+
next.delete(key);
|
|
363
|
+
const selArr = Array.from(next);
|
|
364
|
+
onSelectionChange == null ? void 0 : onSelectionChange(selArr, {
|
|
365
|
+
tableId,
|
|
366
|
+
pageKeys: prev.data.map((r) => String(r[rowKey])),
|
|
367
|
+
disabledKeys: [],
|
|
368
|
+
trigger: "select"
|
|
369
|
+
});
|
|
370
|
+
return { ...prev, selection: next };
|
|
371
|
+
});
|
|
372
|
+
},
|
|
373
|
+
[selectable, onSelectionChange, tableId, rowKey]
|
|
374
|
+
);
|
|
375
|
+
const selectAllOnPage = (0, import_react.useCallback)(
|
|
376
|
+
(rowKeys, disabledKeys) => {
|
|
377
|
+
if (!selectable)
|
|
378
|
+
return;
|
|
379
|
+
const selectableKeys = rowKeys.filter((k) => !disabledKeys.includes(k));
|
|
380
|
+
setState((prev) => {
|
|
381
|
+
const allSelected = selectableKeys.every((k) => prev.selection.has(k));
|
|
382
|
+
const next = new Set(prev.selection);
|
|
383
|
+
if (allSelected) {
|
|
384
|
+
selectableKeys.forEach((k) => next.delete(k));
|
|
385
|
+
} else {
|
|
386
|
+
selectableKeys.forEach((k) => next.add(k));
|
|
387
|
+
}
|
|
388
|
+
const selArr = Array.from(next);
|
|
389
|
+
onSelectionChange == null ? void 0 : onSelectionChange(selArr, {
|
|
390
|
+
tableId,
|
|
391
|
+
pageKeys: rowKeys,
|
|
392
|
+
disabledKeys,
|
|
393
|
+
trigger: allSelected ? "select-all" : "select-all"
|
|
394
|
+
});
|
|
395
|
+
return { ...prev, selection: next };
|
|
396
|
+
});
|
|
397
|
+
},
|
|
398
|
+
[selectable, onSelectionChange, tableId]
|
|
399
|
+
);
|
|
400
|
+
const clearSelection = (0, import_react.useCallback)(() => {
|
|
401
|
+
setState((prev) => ({ ...prev, selection: /* @__PURE__ */ new Set() }));
|
|
402
|
+
onSelectionChange == null ? void 0 : onSelectionChange([], {
|
|
403
|
+
tableId,
|
|
404
|
+
pageKeys: [],
|
|
405
|
+
disabledKeys: [],
|
|
406
|
+
trigger: "reset"
|
|
407
|
+
});
|
|
408
|
+
}, [onSelectionChange, tableId]);
|
|
409
|
+
const isAllSelectedOnPage = (0, import_react.useCallback)(
|
|
410
|
+
(rowKeys, disabledKeys) => {
|
|
411
|
+
const selectableKeys = rowKeys.filter((k) => !disabledKeys.includes(k));
|
|
412
|
+
if (selectableKeys.length === 0)
|
|
413
|
+
return false;
|
|
414
|
+
return selectableKeys.every((k) => state.selection.has(k));
|
|
415
|
+
},
|
|
416
|
+
[state.selection]
|
|
417
|
+
);
|
|
418
|
+
const isIndeterminateOnPage = (0, import_react.useCallback)(
|
|
419
|
+
(rowKeys, disabledKeys) => {
|
|
420
|
+
const selectableKeys = rowKeys.filter((k) => !disabledKeys.includes(k));
|
|
421
|
+
if (selectableKeys.length === 0)
|
|
422
|
+
return false;
|
|
423
|
+
const selectedCount = selectableKeys.filter(
|
|
424
|
+
(k) => state.selection.has(k)
|
|
425
|
+
).length;
|
|
426
|
+
return selectedCount > 0 && selectedCount < selectableKeys.length;
|
|
427
|
+
},
|
|
428
|
+
[state.selection]
|
|
429
|
+
);
|
|
430
|
+
const refresh = (0, import_react.useCallback)(() => {
|
|
431
|
+
setState((prev) => {
|
|
432
|
+
const clearedSelection = currentPageOnly ? /* @__PURE__ */ new Set() : prev.selection;
|
|
433
|
+
const next = { ...prev, selection: clearedSelection };
|
|
434
|
+
triggerFetch("reset", {
|
|
435
|
+
sort: next.sort,
|
|
436
|
+
appliedFilters: next.appliedFilters,
|
|
437
|
+
page: next.page,
|
|
438
|
+
pageSize: next.pageSize
|
|
439
|
+
});
|
|
440
|
+
return next;
|
|
441
|
+
});
|
|
442
|
+
}, [triggerFetch, currentPageOnly]);
|
|
443
|
+
return (0, import_react.useMemo)(
|
|
444
|
+
() => ({
|
|
445
|
+
data: state.data,
|
|
446
|
+
total: state.total,
|
|
447
|
+
status: state.status,
|
|
448
|
+
error: state.error,
|
|
449
|
+
sort: state.sort,
|
|
450
|
+
appliedFilters: state.appliedFilters,
|
|
451
|
+
page: state.page,
|
|
452
|
+
pageSize: state.pageSize,
|
|
453
|
+
selection: Array.from(state.selection),
|
|
454
|
+
requestId,
|
|
455
|
+
toggleSort,
|
|
456
|
+
applyFilters,
|
|
457
|
+
resetFilters,
|
|
458
|
+
setPage,
|
|
459
|
+
setPageSize,
|
|
460
|
+
toggleRow,
|
|
461
|
+
selectAllOnPage,
|
|
462
|
+
clearSelection,
|
|
463
|
+
refresh,
|
|
464
|
+
isAllSelectedOnPage,
|
|
465
|
+
isIndeterminateOnPage
|
|
466
|
+
}),
|
|
467
|
+
[
|
|
468
|
+
state,
|
|
469
|
+
requestId,
|
|
470
|
+
toggleSort,
|
|
471
|
+
applyFilters,
|
|
472
|
+
resetFilters,
|
|
473
|
+
setPage,
|
|
474
|
+
setPageSize,
|
|
475
|
+
toggleRow,
|
|
476
|
+
selectAllOnPage,
|
|
477
|
+
clearSelection,
|
|
478
|
+
refresh,
|
|
479
|
+
isAllSelectedOnPage,
|
|
480
|
+
isIndeterminateOnPage
|
|
481
|
+
]
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
485
|
+
0 && (module.exports = {
|
|
486
|
+
clampPage,
|
|
487
|
+
cycleSort,
|
|
488
|
+
useTableCore,
|
|
489
|
+
validateColumnConflicts,
|
|
490
|
+
validateJumpPage
|
|
491
|
+
});
|
|
@@ -151,9 +151,11 @@ var useHighSecurity = (options) => {
|
|
|
151
151
|
const scope = (_a = paramScope != null ? paramScope : optionsScope) != null ? _a : "business";
|
|
152
152
|
const url = scope === "platform" ? merged.decryptPlatUrl || "/v3/business/game_info/plat-high-security-decrypt?audience=/laas-pnt" : merged.decryptUrl || "/v3/business/game_info/high-security-decrypt?audience=/laas-pnt";
|
|
153
153
|
const requestKey = `${gid}:${eid}:${missing.map((item) => `${item.key}${item.value}`).join("")}`;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
if (!forceRefresh) {
|
|
155
|
+
const existing = inflightRequests.get(requestKey);
|
|
156
|
+
if (existing)
|
|
157
|
+
return existing;
|
|
158
|
+
}
|
|
157
159
|
const promise = (async () => {
|
|
158
160
|
var _a2, _b;
|
|
159
161
|
try {
|
|
@@ -203,13 +205,17 @@ var useHighSecurity = (options) => {
|
|
|
203
205
|
error
|
|
204
206
|
);
|
|
205
207
|
} finally {
|
|
206
|
-
|
|
208
|
+
if (!forceRefresh) {
|
|
209
|
+
inflightRequests.delete(requestKey);
|
|
210
|
+
}
|
|
207
211
|
}
|
|
208
212
|
return result.filter(
|
|
209
213
|
(item) => item !== void 0
|
|
210
214
|
);
|
|
211
215
|
})();
|
|
212
|
-
|
|
216
|
+
if (!forceRefresh) {
|
|
217
|
+
inflightRequests.set(requestKey, promise);
|
|
218
|
+
}
|
|
213
219
|
return promise;
|
|
214
220
|
},
|
|
215
221
|
[http, snapshot, globalHighSecurity, optionsScope]
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { PntProvider, usePntConfig, type PntConfig, type PntHighSecurityConfig, type PntHttpLike, type PntRegionQueryConfig, type commonEesType, } from './config';
|
|
2
2
|
export { default as PntImage } from './components/PntImage';
|
|
3
|
+
export { default as PntTable } from './components/PntTable';
|
|
4
|
+
export type { PntSortDirection, PntSortInfo, PntTableColumn, PntTableDataMode, PntTableFetcher, PntTableFilterConfig as PntTableFilterConfigItem, PntTableProps, PntTableQuery, PntTableQueryMeta, PntTableQueryTrigger, PntTableRef, PntTableResponse, PntTableSelectConfig, PntTableSelectionMeta, PntTableStatus, PntTableTheme, } from './components/PntTable/types';
|
|
3
5
|
export { default as PntBusinessSelect } from './components/PntBusinessSelect';
|
|
4
6
|
export { default as PntRegionSelect, normalizeRegionCode, } from './components/PntRegionSelect';
|
|
5
7
|
export { DEFAULT_TEXTS, EN_TEXTS, getTextsByLocale, } from './components/PntRegionSelect/types';
|
package/lib/cjs/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
PntProvider: () => import_config.PntProvider,
|
|
38
38
|
PntRegionSelect: () => import_PntRegionSelect.default,
|
|
39
39
|
PntSecureBox: () => import_PntSecureBox.default,
|
|
40
|
+
PntTable: () => import_PntTable.default,
|
|
40
41
|
businessGameInfoHighSecurityDecrypt: () => import_api.businessGameInfoHighSecurityDecrypt,
|
|
41
42
|
businessRegionQuery: () => import_api.businessRegionQuery,
|
|
42
43
|
businessSelectList: () => import_api.businessSelectList,
|
|
@@ -49,6 +50,7 @@ __export(src_exports, {
|
|
|
49
50
|
module.exports = __toCommonJS(src_exports);
|
|
50
51
|
var import_config = require("./config");
|
|
51
52
|
var import_PntImage = __toESM(require("./components/PntImage"));
|
|
53
|
+
var import_PntTable = __toESM(require("./components/PntTable"));
|
|
52
54
|
var import_PntBusinessSelect = __toESM(require("./components/PntBusinessSelect"));
|
|
53
55
|
var import_PntRegionSelect = __toESM(require("./components/PntRegionSelect"));
|
|
54
56
|
var import_types = require("./components/PntRegionSelect/types");
|
|
@@ -67,6 +69,7 @@ var import_PntGeneralLayout = __toESM(require("./components/PntGeneralLayout"));
|
|
|
67
69
|
PntProvider,
|
|
68
70
|
PntRegionSelect,
|
|
69
71
|
PntSecureBox,
|
|
72
|
+
PntTable,
|
|
70
73
|
businessGameInfoHighSecurityDecrypt,
|
|
71
74
|
businessRegionQuery,
|
|
72
75
|
businessSelectList,
|
|
@@ -92,8 +92,17 @@ const PntSecureBox = prop => {
|
|
|
92
92
|
|
|
93
93
|
// securityData 变化时回调,把整个对象抛给消费方
|
|
94
94
|
useEffect(() => {
|
|
95
|
-
onSecurityDataChange
|
|
96
|
-
|
|
95
|
+
if (!onSecurityDataChange) return;
|
|
96
|
+
// 0.0.130 起 storeKey 含密文指纹(dataKey#tail16),内部缓存键不再是纯 dataKey;
|
|
97
|
+
// 按本 prop 文档契约(key 为字段名),这里把自身条目以原始 dataKey 补一份别名,
|
|
98
|
+
// 保证消费方 securityData[dataKey] 能取到明文(同 dataKey 多密文时以后解锁的为准)
|
|
99
|
+
const ownValue = securityData[storeKey];
|
|
100
|
+
const payload = ownValue !== undefined && securityData[dataKey] !== ownValue ? {
|
|
101
|
+
...securityData,
|
|
102
|
+
[dataKey]: ownValue
|
|
103
|
+
} : securityData;
|
|
104
|
+
onSecurityDataChange(payload);
|
|
105
|
+
}, [securityData, onSecurityDataChange, storeKey, dataKey]);
|
|
97
106
|
const handleView = () => {
|
|
98
107
|
if (isSecurity) {
|
|
99
108
|
requestSecurityData({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PntTable — 统一表格组件
|
|
3
|
+
*
|
|
4
|
+
* 封装 tdesign-react Table,落地产品规范 12 章 47 条规则:
|
|
5
|
+
* 排序三态循环、筛选草稿/生效分离、多选三态+翻页清空、分页越界校验、
|
|
6
|
+
* 请求顺序控制、7 种状态管理、蓝紫双主题、同字段 sort+headerFilter 互斥。
|
|
7
|
+
*
|
|
8
|
+
* 零业务侵入:业务项目通过 fetcher 注入数据源,不依赖组件库内部 API。
|
|
9
|
+
*/
|
|
10
|
+
/// <reference types="react" />
|
|
11
|
+
import './index.scss';
|
|
12
|
+
import type { PntTableProps, PntTableRef } from './types';
|
|
13
|
+
export declare const PntTable: import("react").ForwardRefExoticComponent<PntTableProps & import("react").RefAttributes<PntTableRef>>;
|
|
14
|
+
export default PntTable;
|