@mijalowcode/materials 1.2.0 → 1.2.2
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/DesensitizationDisplay-XCB4GDPW.js +3 -0
- package/dist/{DesensitizationDisplay-CBKBVL2V.js.map → DesensitizationDisplay-XCB4GDPW.js.map} +1 -1
- package/dist/DrawerWrapper-MPT3IWYD.css +104 -0
- package/dist/DrawerWrapper-MPT3IWYD.css.map +1 -0
- package/dist/DrawerWrapper-MQOCGF7M.js +3 -0
- package/dist/{DrawerWrapper-S4DWP4YO.js.map → DrawerWrapper-MQOCGF7M.js.map} +1 -1
- package/dist/{ProTableWrapper-ATFZXHWT.js → ProTableWrapper-3MACKNZ5.js} +3 -3
- package/dist/{ProTableWrapper-ATFZXHWT.js.map → ProTableWrapper-3MACKNZ5.js.map} +1 -1
- package/dist/{chunk-C7UZWG4J.js → chunk-3FN6LEP3.js} +356 -186
- package/dist/chunk-3FN6LEP3.js.map +1 -0
- package/dist/{chunk-YIFEQ2KZ.js → chunk-DL6YUG5R.js} +36 -13
- package/dist/chunk-DL6YUG5R.js.map +1 -0
- package/dist/{chunk-HSEAHONQ.js → chunk-ICDNHCBG.js} +95 -4
- package/dist/chunk-ICDNHCBG.js.map +1 -0
- package/dist/{chunk-BVDSN573.js → chunk-PJFDO4E6.js} +18 -7
- package/dist/chunk-PJFDO4E6.js.map +1 -0
- package/dist/{chunk-RWMCWXH3.js → chunk-RY7OLIUM.js} +6 -6
- package/dist/{chunk-RWMCWXH3.js.map → chunk-RY7OLIUM.js.map} +1 -1
- package/dist/index.css +99 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/meta-AKNOVCWP.js +3 -0
- package/dist/{meta-BYJ4YSP5.js.map → meta-AKNOVCWP.js.map} +1 -1
- package/dist/runtime.css +99 -10
- package/dist/runtime.css.map +1 -1
- package/dist/runtime.js +1 -1
- package/package.json +4 -4
- package/dist/DesensitizationDisplay-CBKBVL2V.js +0 -3
- package/dist/DesensitizationDisplay-X2JJGJ3P.css +0 -15
- package/dist/DesensitizationDisplay-X2JJGJ3P.css.map +0 -1
- package/dist/DrawerWrapper-S4DWP4YO.js +0 -3
- package/dist/chunk-BVDSN573.js.map +0 -1
- package/dist/chunk-C7UZWG4J.js.map +0 -1
- package/dist/chunk-HSEAHONQ.js.map +0 -1
- package/dist/chunk-YIFEQ2KZ.js.map +0 -1
- package/dist/meta-BYJ4YSP5.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSlotRuntime } from './chunk-ERTSEXI5.js';
|
|
2
2
|
import { useEventEmitter } from './chunk-CTF6CVK3.js';
|
|
3
|
-
import { useRef, useState, useEffect, useMemo, useCallback } from 'react';
|
|
3
|
+
import { memo, useRef, useState, useEffect, useMemo, useCallback } from 'react';
|
|
4
4
|
import { ProTable } from '@ant-design/pro-components';
|
|
5
5
|
import * as AntdIcons from '@ant-design/icons';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -26,108 +26,8 @@ function hasTableRequestBinding(eventMap) {
|
|
|
26
26
|
}
|
|
27
27
|
return Array.isArray(current.actions) && current.actions.length > 0;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return window.__LC_DEBUG_ENABLED__ === true;
|
|
32
|
-
}
|
|
33
|
-
function recordProTableDiagnostic(name, detail) {
|
|
34
|
-
if (typeof window === "undefined" || !isRuntimeDebugEnabled()) return;
|
|
35
|
-
if (!window.__LC_PERF_COUNTS__) {
|
|
36
|
-
window.__LC_PERF_COUNTS__ = {};
|
|
37
|
-
}
|
|
38
|
-
const eventName = String(name || "").trim();
|
|
39
|
-
if (!eventName) return;
|
|
40
|
-
const nextCount = Number(window.__LC_PERF_COUNTS__[eventName] || 0) + 1;
|
|
41
|
-
window.__LC_PERF_COUNTS__[eventName] = nextCount;
|
|
42
|
-
console.info("[LC PERF]", {
|
|
43
|
-
name: eventName,
|
|
44
|
-
count: nextCount,
|
|
45
|
-
detail
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function resolveProTableQueryActionName(text) {
|
|
49
|
-
const normalized = String(text || "").replace(/\s+/g, "");
|
|
50
|
-
if (normalized === "\u67E5\u8BE2") return "query";
|
|
51
|
-
if (normalized === "\u91CD\u7F6E") return "reset";
|
|
52
|
-
return void 0;
|
|
53
|
-
}
|
|
54
|
-
function buildProTableQueryDelayDetail(capturedAt, triggeredAt) {
|
|
55
|
-
return {
|
|
56
|
-
delayMs: Math.round(triggeredAt - capturedAt)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function getDiagnosticValueType(value) {
|
|
60
|
-
if (Array.isArray(value)) return `array(${value.length})`;
|
|
61
|
-
if (value === null) return "null";
|
|
62
|
-
return typeof value;
|
|
63
|
-
}
|
|
64
|
-
function buildProTableRequestParamsSummary(params) {
|
|
65
|
-
const keys = Object.keys(params || {});
|
|
66
|
-
return {
|
|
67
|
-
keys,
|
|
68
|
-
fieldTypes: keys.reduce((acc, key) => {
|
|
69
|
-
acc[key] = getDiagnosticValueType(params[key]);
|
|
70
|
-
return acc;
|
|
71
|
-
}, {})
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function shouldRecordProTableLongTask(duration) {
|
|
75
|
-
return Number(duration || 0) >= 50;
|
|
76
|
-
}
|
|
77
|
-
function getEventTargetButton(target) {
|
|
78
|
-
if (!target || typeof Element === "undefined") return null;
|
|
79
|
-
if (!(target instanceof Element)) return null;
|
|
80
|
-
return target.closest("button");
|
|
81
|
-
}
|
|
82
|
-
function getNowTime() {
|
|
83
|
-
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
84
|
-
}
|
|
85
|
-
function buildTableRequestSortPayload(sort) {
|
|
86
|
-
const [sortField, sortOrder] = Object.entries(sort).find(([, value]) => {
|
|
87
|
-
return value === "ascend" || value === "descend";
|
|
88
|
-
}) || [void 0, void 0];
|
|
89
|
-
if (!sortField || typeof sortOrder !== "string") return {};
|
|
90
|
-
return {
|
|
91
|
-
sortField,
|
|
92
|
-
sortMode: sortOrder === "ascend" ? "ASC" : "DESC"
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function isBindValue(value) {
|
|
96
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && typeof value.__bind === "object";
|
|
97
|
-
}
|
|
98
|
-
function renderFieldPropsPrefixSuffix(fieldProps) {
|
|
99
|
-
if (!fieldProps) return void 0;
|
|
100
|
-
const result = { ...fieldProps };
|
|
101
|
-
if (fieldProps.prefixType === "icon" && fieldProps.prefixIcon) {
|
|
102
|
-
const icons = AntdIcons;
|
|
103
|
-
const IconComponent = icons[fieldProps.prefixIcon];
|
|
104
|
-
result.prefix = IconComponent ? /* @__PURE__ */ jsx(IconComponent, {}) : void 0;
|
|
105
|
-
} else if (fieldProps.prefixText) {
|
|
106
|
-
result.prefix = fieldProps.prefixText;
|
|
107
|
-
}
|
|
108
|
-
if (fieldProps.suffixType === "icon" && fieldProps.suffixIcon) {
|
|
109
|
-
const icons = AntdIcons;
|
|
110
|
-
const IconComponent = icons[fieldProps.suffixIcon];
|
|
111
|
-
result.suffix = IconComponent ? /* @__PURE__ */ jsx(IconComponent, {}) : void 0;
|
|
112
|
-
} else if (fieldProps.suffixText) {
|
|
113
|
-
result.suffix = fieldProps.suffixText;
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
function resolveColumnValueEnum(col) {
|
|
118
|
-
if (isBindValue(col.valueEnum)) {
|
|
119
|
-
return col.valueEnum.__bind.fallback;
|
|
120
|
-
}
|
|
121
|
-
return col.valueEnum;
|
|
122
|
-
}
|
|
123
|
-
function resolveColumnSlotAreaNames(col) {
|
|
124
|
-
const areaNames = [];
|
|
125
|
-
const columnId = String(col.columnId || "").trim();
|
|
126
|
-
if (columnId) {
|
|
127
|
-
areaNames.push(`columnId:${columnId}`);
|
|
128
|
-
}
|
|
129
|
-
return areaNames;
|
|
130
|
-
}
|
|
29
|
+
|
|
30
|
+
// src/antdPro/ProTable/storage-search.ts
|
|
131
31
|
function isPlainObject(value) {
|
|
132
32
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
133
33
|
}
|
|
@@ -170,6 +70,8 @@ function buildProTableFormConfig(searchInitialValues) {
|
|
|
170
70
|
initialValues: searchInitialValues
|
|
171
71
|
};
|
|
172
72
|
}
|
|
73
|
+
|
|
74
|
+
// src/antdPro/ProTable/slot-cell.tsx
|
|
173
75
|
function buildProTableSlotRuntimeContext(runtimeContext, slotRuntimeContext) {
|
|
174
76
|
const baseData = isPlainObject(runtimeContext?.data) ? runtimeContext.data : {};
|
|
175
77
|
const slotData = isPlainObject(slotRuntimeContext.data) ? slotRuntimeContext.data : {};
|
|
@@ -182,6 +84,104 @@ function buildProTableSlotRuntimeContext(runtimeContext, slotRuntimeContext) {
|
|
|
182
84
|
}
|
|
183
85
|
};
|
|
184
86
|
}
|
|
87
|
+
var ProTableSlotCell = memo(
|
|
88
|
+
function ProTableSlotCell2({
|
|
89
|
+
areaNames,
|
|
90
|
+
column,
|
|
91
|
+
getAreaNodes,
|
|
92
|
+
index,
|
|
93
|
+
record,
|
|
94
|
+
runtimeContext,
|
|
95
|
+
value,
|
|
96
|
+
valueEnum
|
|
97
|
+
}) {
|
|
98
|
+
const enumRecord = valueEnum;
|
|
99
|
+
const enumMatch = enumRecord && value !== void 0 && value !== null ? enumRecord[String(value)] : void 0;
|
|
100
|
+
const slotPayload = {
|
|
101
|
+
record,
|
|
102
|
+
index,
|
|
103
|
+
column,
|
|
104
|
+
value,
|
|
105
|
+
valueEnum,
|
|
106
|
+
valueEnumItem: enumMatch,
|
|
107
|
+
enumText: enumMatch?.text,
|
|
108
|
+
enumStatus: enumMatch?.status
|
|
109
|
+
};
|
|
110
|
+
const slotNodes = areaNames.reduce(
|
|
111
|
+
(matchedNodes, areaName) => {
|
|
112
|
+
if (matchedNodes !== void 0) {
|
|
113
|
+
return matchedNodes;
|
|
114
|
+
}
|
|
115
|
+
const slotRuntimeContext = buildProTableSlotRuntimeContext(
|
|
116
|
+
runtimeContext,
|
|
117
|
+
{
|
|
118
|
+
scope: "table.cell",
|
|
119
|
+
area: areaName,
|
|
120
|
+
container: {
|
|
121
|
+
type: "table",
|
|
122
|
+
area: areaName,
|
|
123
|
+
index,
|
|
124
|
+
column,
|
|
125
|
+
record
|
|
126
|
+
},
|
|
127
|
+
data: {
|
|
128
|
+
...slotPayload,
|
|
129
|
+
rawValue: value,
|
|
130
|
+
displayValue: enumMatch?.text !== void 0 && enumMatch?.text !== null ? enumMatch.text : value,
|
|
131
|
+
status: enumMatch?.status
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
return getAreaNodes?.(areaName, {
|
|
136
|
+
...slotPayload,
|
|
137
|
+
runtimeContext: slotRuntimeContext
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
void 0
|
|
141
|
+
);
|
|
142
|
+
if (slotNodes !== void 0) {
|
|
143
|
+
return slotNodes.length === 1 ? slotNodes[0] : slotNodes;
|
|
144
|
+
}
|
|
145
|
+
return String(record[column.dataIndex] ?? "");
|
|
146
|
+
},
|
|
147
|
+
(prev, next) => prev.areaNames === next.areaNames && prev.column === next.column && prev.getAreaNodes === next.getAreaNodes && prev.index === next.index && prev.record === next.record && prev.runtimeContext === next.runtimeContext && prev.value === next.value && prev.valueEnum === next.valueEnum
|
|
148
|
+
);
|
|
149
|
+
function isBindValue(value) {
|
|
150
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && typeof value.__bind === "object";
|
|
151
|
+
}
|
|
152
|
+
function renderFieldPropsPrefixSuffix(fieldProps) {
|
|
153
|
+
if (!fieldProps) return void 0;
|
|
154
|
+
const result = { ...fieldProps };
|
|
155
|
+
if (fieldProps.prefixType === "icon" && fieldProps.prefixIcon) {
|
|
156
|
+
const icons = AntdIcons;
|
|
157
|
+
const IconComponent = icons[fieldProps.prefixIcon];
|
|
158
|
+
result.prefix = IconComponent ? /* @__PURE__ */ jsx(IconComponent, {}) : void 0;
|
|
159
|
+
} else if (fieldProps.prefixText) {
|
|
160
|
+
result.prefix = fieldProps.prefixText;
|
|
161
|
+
}
|
|
162
|
+
if (fieldProps.suffixType === "icon" && fieldProps.suffixIcon) {
|
|
163
|
+
const icons = AntdIcons;
|
|
164
|
+
const IconComponent = icons[fieldProps.suffixIcon];
|
|
165
|
+
result.suffix = IconComponent ? /* @__PURE__ */ jsx(IconComponent, {}) : void 0;
|
|
166
|
+
} else if (fieldProps.suffixText) {
|
|
167
|
+
result.suffix = fieldProps.suffixText;
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function resolveColumnValueEnum(col) {
|
|
172
|
+
if (isBindValue(col.valueEnum)) {
|
|
173
|
+
return col.valueEnum.__bind.fallback;
|
|
174
|
+
}
|
|
175
|
+
return col.valueEnum;
|
|
176
|
+
}
|
|
177
|
+
function resolveColumnSlotAreaNames(col) {
|
|
178
|
+
const areaNames = [];
|
|
179
|
+
const columnId = String(col.columnId || "").trim();
|
|
180
|
+
if (columnId) {
|
|
181
|
+
areaNames.push(`columnId:${columnId}`);
|
|
182
|
+
}
|
|
183
|
+
return areaNames;
|
|
184
|
+
}
|
|
185
185
|
function convertColumns(columns = [], getAreaNodes, areaMap = {}, hasExternalRenderSlot = false, runtimeContext) {
|
|
186
186
|
return columns.map((col) => {
|
|
187
187
|
const extendedCol = col;
|
|
@@ -213,57 +213,246 @@ function convertColumns(columns = [], getAreaNodes, areaMap = {}, hasExternalRen
|
|
|
213
213
|
proColumn.render = (_, record, index) => {
|
|
214
214
|
const rawValue = record[col.dataIndex];
|
|
215
215
|
const valueEnum = resolveColumnValueEnum(col);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
(matchedNodes, areaName) => {
|
|
229
|
-
if (matchedNodes !== void 0) {
|
|
230
|
-
return matchedNodes;
|
|
231
|
-
}
|
|
232
|
-
const slotRuntimeContext = buildProTableSlotRuntimeContext(
|
|
233
|
-
runtimeContext,
|
|
234
|
-
{
|
|
235
|
-
scope: "table.cell",
|
|
236
|
-
area: areaName,
|
|
237
|
-
container: {
|
|
238
|
-
type: "table",
|
|
239
|
-
area: areaName,
|
|
240
|
-
index,
|
|
241
|
-
column: col,
|
|
242
|
-
record
|
|
243
|
-
},
|
|
244
|
-
data: {
|
|
245
|
-
...slotPayload,
|
|
246
|
-
rawValue,
|
|
247
|
-
displayValue: enumMatch?.text !== void 0 && enumMatch?.text !== null ? enumMatch.text : rawValue,
|
|
248
|
-
status: enumMatch?.status
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
);
|
|
252
|
-
return getAreaNodes?.(areaName, {
|
|
253
|
-
...slotPayload,
|
|
254
|
-
runtimeContext: slotRuntimeContext
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
void 0
|
|
216
|
+
return /* @__PURE__ */ jsx(
|
|
217
|
+
ProTableSlotCell,
|
|
218
|
+
{
|
|
219
|
+
areaNames,
|
|
220
|
+
column: col,
|
|
221
|
+
getAreaNodes,
|
|
222
|
+
index,
|
|
223
|
+
record,
|
|
224
|
+
runtimeContext,
|
|
225
|
+
value: rawValue,
|
|
226
|
+
valueEnum
|
|
227
|
+
}
|
|
258
228
|
);
|
|
259
|
-
if (slotNodes !== void 0) {
|
|
260
|
-
return slotNodes.length === 1 ? slotNodes[0] : slotNodes;
|
|
261
|
-
}
|
|
262
|
-
return String(record[col.dataIndex] ?? "");
|
|
263
229
|
};
|
|
264
230
|
return proColumn;
|
|
265
231
|
});
|
|
266
232
|
}
|
|
233
|
+
var SEARCH_RESIZE_SETTLE_DELAY = 120;
|
|
234
|
+
function getInitialProTableAutoHeightMetrics() {
|
|
235
|
+
return {
|
|
236
|
+
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 900,
|
|
237
|
+
searchAreaHeight: 0
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function buildProTableAutoHeightMetricsUpdate(current, next) {
|
|
241
|
+
if (current.viewportHeight === next.viewportHeight && current.searchAreaHeight === next.searchAreaHeight) {
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
return next;
|
|
245
|
+
}
|
|
246
|
+
function resolveResizeObserverHeight(entry) {
|
|
247
|
+
const height = entry?.contentRect.height;
|
|
248
|
+
return typeof height === "number" ? Math.ceil(height) : void 0;
|
|
249
|
+
}
|
|
250
|
+
function resolveProTableAutoHeightCommitDelay(source) {
|
|
251
|
+
return source === "search-resize" ? SEARCH_RESIZE_SETTLE_DELAY : 0;
|
|
252
|
+
}
|
|
253
|
+
function useProTableAutoHeight({
|
|
254
|
+
autoHeight,
|
|
255
|
+
getSearchNode,
|
|
256
|
+
searchEnabled
|
|
257
|
+
}) {
|
|
258
|
+
const [metrics, setMetrics] = useState(
|
|
259
|
+
getInitialProTableAutoHeightMetrics
|
|
260
|
+
);
|
|
261
|
+
const metricsRef = useRef(metrics);
|
|
262
|
+
const frameRef = useRef();
|
|
263
|
+
const settleTimerRef = useRef();
|
|
264
|
+
const pendingSearchAreaHeightRef = useRef();
|
|
265
|
+
const readSearchAreaHeight = useCallback(() => {
|
|
266
|
+
const searchNode = getSearchNode();
|
|
267
|
+
return searchNode ? Math.ceil(searchNode.getBoundingClientRect().height) : 0;
|
|
268
|
+
}, [getSearchNode]);
|
|
269
|
+
const commitMetrics = useCallback((next) => {
|
|
270
|
+
const update = buildProTableAutoHeightMetricsUpdate(
|
|
271
|
+
metricsRef.current,
|
|
272
|
+
next
|
|
273
|
+
);
|
|
274
|
+
if (!update) return;
|
|
275
|
+
metricsRef.current = update;
|
|
276
|
+
setMetrics(update);
|
|
277
|
+
}, []);
|
|
278
|
+
const flushMetrics = useCallback(() => {
|
|
279
|
+
frameRef.current = void 0;
|
|
280
|
+
const pendingSearchAreaHeight = pendingSearchAreaHeightRef.current;
|
|
281
|
+
pendingSearchAreaHeightRef.current = void 0;
|
|
282
|
+
commitMetrics({
|
|
283
|
+
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 900,
|
|
284
|
+
searchAreaHeight: typeof pendingSearchAreaHeight === "number" ? pendingSearchAreaHeight : readSearchAreaHeight()
|
|
285
|
+
});
|
|
286
|
+
}, [commitMetrics, readSearchAreaHeight]);
|
|
287
|
+
const scheduleMetricsFrame = useCallback(() => {
|
|
288
|
+
if (typeof window === "undefined" || typeof window.requestAnimationFrame !== "function") {
|
|
289
|
+
flushMetrics();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (frameRef.current !== void 0) return;
|
|
293
|
+
frameRef.current = window.requestAnimationFrame(flushMetrics);
|
|
294
|
+
}, [flushMetrics]);
|
|
295
|
+
const scheduleMetricsUpdate = useCallback(
|
|
296
|
+
(source, observedSearchAreaHeight) => {
|
|
297
|
+
if (typeof observedSearchAreaHeight === "number") {
|
|
298
|
+
pendingSearchAreaHeightRef.current = Math.ceil(observedSearchAreaHeight);
|
|
299
|
+
}
|
|
300
|
+
if (typeof window === "undefined") {
|
|
301
|
+
scheduleMetricsFrame();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const delay = resolveProTableAutoHeightCommitDelay(source);
|
|
305
|
+
if (delay <= 0) {
|
|
306
|
+
if (settleTimerRef.current !== void 0) {
|
|
307
|
+
window.clearTimeout(settleTimerRef.current);
|
|
308
|
+
settleTimerRef.current = void 0;
|
|
309
|
+
}
|
|
310
|
+
scheduleMetricsFrame();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (settleTimerRef.current !== void 0) {
|
|
314
|
+
window.clearTimeout(settleTimerRef.current);
|
|
315
|
+
}
|
|
316
|
+
settleTimerRef.current = window.setTimeout(() => {
|
|
317
|
+
settleTimerRef.current = void 0;
|
|
318
|
+
scheduleMetricsFrame();
|
|
319
|
+
}, delay);
|
|
320
|
+
},
|
|
321
|
+
[scheduleMetricsFrame]
|
|
322
|
+
);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (typeof window === "undefined") return;
|
|
325
|
+
const clearScheduledMetrics = () => {
|
|
326
|
+
if (frameRef.current !== void 0 && typeof window.cancelAnimationFrame === "function") {
|
|
327
|
+
window.cancelAnimationFrame(frameRef.current);
|
|
328
|
+
}
|
|
329
|
+
if (settleTimerRef.current !== void 0) {
|
|
330
|
+
window.clearTimeout(settleTimerRef.current);
|
|
331
|
+
}
|
|
332
|
+
frameRef.current = void 0;
|
|
333
|
+
settleTimerRef.current = void 0;
|
|
334
|
+
pendingSearchAreaHeightRef.current = void 0;
|
|
335
|
+
};
|
|
336
|
+
if (!autoHeight) {
|
|
337
|
+
clearScheduledMetrics();
|
|
338
|
+
commitMetrics({
|
|
339
|
+
viewportHeight: window.innerHeight,
|
|
340
|
+
searchAreaHeight: 0
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
scheduleMetricsUpdate("initial");
|
|
345
|
+
const searchNode = getSearchNode();
|
|
346
|
+
const resizeObserver = searchNode && typeof ResizeObserver !== "undefined" ? new ResizeObserver((entries) => {
|
|
347
|
+
scheduleMetricsUpdate(
|
|
348
|
+
"search-resize",
|
|
349
|
+
resolveResizeObserverHeight(entries[0])
|
|
350
|
+
);
|
|
351
|
+
}) : null;
|
|
352
|
+
if (resizeObserver && searchNode) {
|
|
353
|
+
resizeObserver.observe(searchNode);
|
|
354
|
+
}
|
|
355
|
+
const handleWindowResize = () => {
|
|
356
|
+
scheduleMetricsUpdate("window-resize");
|
|
357
|
+
};
|
|
358
|
+
window.addEventListener("resize", handleWindowResize);
|
|
359
|
+
return () => {
|
|
360
|
+
clearScheduledMetrics();
|
|
361
|
+
if (resizeObserver) resizeObserver.disconnect();
|
|
362
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
363
|
+
};
|
|
364
|
+
}, [
|
|
365
|
+
autoHeight,
|
|
366
|
+
searchEnabled,
|
|
367
|
+
getSearchNode,
|
|
368
|
+
commitMetrics,
|
|
369
|
+
scheduleMetricsUpdate
|
|
370
|
+
]);
|
|
371
|
+
return metrics;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/antdPro/ProTable/query-diagnostics.ts
|
|
375
|
+
function isRuntimeDebugEnabled() {
|
|
376
|
+
if (typeof window === "undefined") return false;
|
|
377
|
+
return window.__LC_DEBUG_ENABLED__ === true;
|
|
378
|
+
}
|
|
379
|
+
function recordProTableDiagnostic(name, detail) {
|
|
380
|
+
if (typeof window === "undefined" || !isRuntimeDebugEnabled()) return;
|
|
381
|
+
if (!window.__LC_PERF_COUNTS__) {
|
|
382
|
+
window.__LC_PERF_COUNTS__ = {};
|
|
383
|
+
}
|
|
384
|
+
const eventName = String(name || "").trim();
|
|
385
|
+
if (!eventName) return;
|
|
386
|
+
const nextCount = Number(window.__LC_PERF_COUNTS__[eventName] || 0) + 1;
|
|
387
|
+
window.__LC_PERF_COUNTS__[eventName] = nextCount;
|
|
388
|
+
console.info("[LC PERF]", {
|
|
389
|
+
name: eventName,
|
|
390
|
+
count: nextCount,
|
|
391
|
+
detail
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function resolveProTableQueryActionName(text) {
|
|
395
|
+
const normalized = String(text || "").replace(/\s+/g, "");
|
|
396
|
+
if (normalized === "\u67E5\u8BE2") return "query";
|
|
397
|
+
if (normalized === "\u91CD\u7F6E") return "reset";
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
function buildProTableQueryDelayDetail(capturedAt, triggeredAt) {
|
|
401
|
+
return {
|
|
402
|
+
delayMs: Math.round(triggeredAt - capturedAt)
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function getDiagnosticValueType(value) {
|
|
406
|
+
if (Array.isArray(value)) return `array(${value.length})`;
|
|
407
|
+
if (value === null) return "null";
|
|
408
|
+
return typeof value;
|
|
409
|
+
}
|
|
410
|
+
function buildProTableRequestParamsSummary(params) {
|
|
411
|
+
const keys = Object.keys(params || {});
|
|
412
|
+
return {
|
|
413
|
+
keys,
|
|
414
|
+
fieldTypes: keys.reduce((acc, key) => {
|
|
415
|
+
acc[key] = getDiagnosticValueType(params[key]);
|
|
416
|
+
return acc;
|
|
417
|
+
}, {})
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function shouldRecordProTableLongTask(duration) {
|
|
421
|
+
return Number(duration || 0) >= 50;
|
|
422
|
+
}
|
|
423
|
+
function getNowTime() {
|
|
424
|
+
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
425
|
+
}
|
|
426
|
+
function yieldProTableRequestPaint() {
|
|
427
|
+
return new Promise((resolve) => {
|
|
428
|
+
if (typeof window === "undefined") {
|
|
429
|
+
resolve();
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (typeof window.requestAnimationFrame !== "function") {
|
|
433
|
+
window.setTimeout(resolve, 0);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
window.requestAnimationFrame(() => {
|
|
437
|
+
window.setTimeout(resolve, 0);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function getEventTargetButton(target) {
|
|
442
|
+
if (!target || typeof Element === "undefined") return null;
|
|
443
|
+
if (!(target instanceof Element)) return null;
|
|
444
|
+
return target.closest("button");
|
|
445
|
+
}
|
|
446
|
+
function buildTableRequestSortPayload(sort) {
|
|
447
|
+
const [sortField, sortOrder] = Object.entries(sort).find(([, value]) => {
|
|
448
|
+
return value === "ascend" || value === "descend";
|
|
449
|
+
}) || [void 0, void 0];
|
|
450
|
+
if (!sortField || typeof sortOrder !== "string") return {};
|
|
451
|
+
return {
|
|
452
|
+
sortField,
|
|
453
|
+
sortMode: sortOrder === "ascend" ? "ASC" : "DESC"
|
|
454
|
+
};
|
|
455
|
+
}
|
|
267
456
|
function ProTableWrapper({
|
|
268
457
|
columns = [],
|
|
269
458
|
dataSource = [],
|
|
@@ -304,10 +493,6 @@ function ProTableWrapper({
|
|
|
304
493
|
const lastQueryActionRef = useRef(null);
|
|
305
494
|
const lastFormSubmitRef = useRef(null);
|
|
306
495
|
const longTaskObserverRef = useRef(null);
|
|
307
|
-
const [searchAreaHeight, setSearchAreaHeight] = useState(0);
|
|
308
|
-
const [viewportHeight, setViewportHeight] = useState(
|
|
309
|
-
typeof window !== "undefined" ? window.innerHeight : 900
|
|
310
|
-
);
|
|
311
496
|
const [tablePageSize, setTablePageSize] = useState(pageSize);
|
|
312
497
|
const emitEvent = useEventEmitter(onEvent);
|
|
313
498
|
const emitEventRef = useRef(emitEvent);
|
|
@@ -360,41 +545,22 @@ function ProTableWrapper({
|
|
|
360
545
|
".ant-pro-table-search"
|
|
361
546
|
);
|
|
362
547
|
}, []);
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}, [getSearchNode]);
|
|
369
|
-
useEffect(() => {
|
|
370
|
-
if (!autoHeight) {
|
|
371
|
-
setSearchAreaHeight(0);
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
updateAutoHeightMetrics();
|
|
375
|
-
const searchNode = getSearchNode();
|
|
376
|
-
const resizeObserver = searchNode && typeof ResizeObserver !== "undefined" ? new ResizeObserver(updateAutoHeightMetrics) : null;
|
|
377
|
-
if (resizeObserver && searchNode) {
|
|
378
|
-
resizeObserver.observe(searchNode);
|
|
379
|
-
}
|
|
380
|
-
window.addEventListener("resize", updateAutoHeightMetrics);
|
|
381
|
-
return () => {
|
|
382
|
-
if (resizeObserver) resizeObserver.disconnect();
|
|
383
|
-
window.removeEventListener("resize", updateAutoHeightMetrics);
|
|
384
|
-
};
|
|
385
|
-
}, [autoHeight, search, getSearchNode, updateAutoHeightMetrics]);
|
|
548
|
+
const autoHeightMetrics = useProTableAutoHeight({
|
|
549
|
+
autoHeight,
|
|
550
|
+
getSearchNode,
|
|
551
|
+
searchEnabled: search
|
|
552
|
+
});
|
|
386
553
|
const finalScrollY = useMemo(() => {
|
|
387
554
|
if (!autoHeight) return scrollY;
|
|
388
555
|
const headerOffset = 47;
|
|
389
556
|
const paginationOffset = paginationEnabled ? 40 : 0;
|
|
390
557
|
const toolbarOffset = toolbarNodes && toolbarNodes.length > 0 ? 64 : 0;
|
|
391
|
-
const dynamic = viewportHeight - searchAreaHeight - autoHeightOffset - headerOffset - paginationOffset - toolbarOffset;
|
|
558
|
+
const dynamic = autoHeightMetrics.viewportHeight - autoHeightMetrics.searchAreaHeight - autoHeightOffset - headerOffset - paginationOffset - toolbarOffset;
|
|
392
559
|
return Math.max(autoHeightMinY, dynamic);
|
|
393
560
|
}, [
|
|
394
561
|
autoHeight,
|
|
395
562
|
scrollY,
|
|
396
|
-
|
|
397
|
-
searchAreaHeight,
|
|
563
|
+
autoHeightMetrics,
|
|
398
564
|
autoHeightOffset,
|
|
399
565
|
autoHeightMinY,
|
|
400
566
|
paginationEnabled,
|
|
@@ -429,11 +595,15 @@ function ProTableWrapper({
|
|
|
429
595
|
)
|
|
430
596
|
} : void 0
|
|
431
597
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
598
|
+
await yieldProTableRequestPaint();
|
|
599
|
+
const result = await emitEventRef.current(
|
|
600
|
+
"table.request",
|
|
601
|
+
{
|
|
602
|
+
...params,
|
|
603
|
+
...buildTableRequestSortPayload(sort),
|
|
604
|
+
...filter
|
|
605
|
+
}
|
|
606
|
+
);
|
|
437
607
|
const finalResult = result || {
|
|
438
608
|
data: [],
|
|
439
609
|
success: true,
|
|
@@ -707,5 +877,5 @@ function ProTableWrapper({
|
|
|
707
877
|
var ProTableWrapper_default = ProTableWrapper;
|
|
708
878
|
|
|
709
879
|
export { ProTableWrapper_default, buildProTableFormConfig, buildProTableQueryDelayDetail, buildProTableRequestParamsSummary, buildProTableSlotRuntimeContext, buildSearchInitialValuesFromStorageValue, resolveProTableQueryActionName, shouldRecordProTableLongTask, unwrapSearchStorageValue };
|
|
710
|
-
//# sourceMappingURL=chunk-
|
|
711
|
-
//# sourceMappingURL=chunk-
|
|
880
|
+
//# sourceMappingURL=chunk-3FN6LEP3.js.map
|
|
881
|
+
//# sourceMappingURL=chunk-3FN6LEP3.js.map
|