@object-ui/plugin-grid 0.5.0 → 2.0.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/.turbo/turbo-build.log +14 -5
- package/CHANGELOG.md +15 -0
- package/README.md +97 -0
- package/dist/index.js +622 -531
- package/dist/index.umd.cjs +3 -3
- package/dist/packages/plugin-grid/src/ListColumnExtensions.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/ListColumnSchema.test.d.ts +1 -0
- package/dist/packages/plugin-grid/src/ObjectGrid.d.ts +7 -1
- package/dist/packages/plugin-grid/src/__tests__/VirtualGrid.test.d.ts +0 -0
- package/package.json +8 -8
- package/src/ListColumnExtensions.test.tsx +374 -0
- package/src/ListColumnSchema.test.ts +88 -0
- package/src/ObjectGrid.msw.test.tsx +24 -1
- package/src/ObjectGrid.tsx +273 -109
- package/src/__tests__/VirtualGrid.test.tsx +438 -0
- package/src/index.tsx +12 -2
package/dist/index.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import { ComponentRegistry as
|
|
4
|
-
import { useDataScope as
|
|
5
|
-
import { getCellRenderer as
|
|
6
|
-
import { DropdownMenu as
|
|
7
|
-
import { MoreVertical as
|
|
8
|
-
import { flushSync as
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
function e(s,
|
|
1
|
+
import * as le from "react";
|
|
2
|
+
import Se, { useState as ie, useEffect as ae, useCallback as Ce, useRef as _e } from "react";
|
|
3
|
+
import { ComponentRegistry as we } from "@object-ui/core";
|
|
4
|
+
import { useDataScope as Re, useNavigationOverlay as Ae, useAction as Te, SchemaRenderer as ce, useSchemaContext as Ne } from "@object-ui/react";
|
|
5
|
+
import { getCellRenderer as ue } from "@object-ui/fields";
|
|
6
|
+
import { DropdownMenu as ke, DropdownMenuTrigger as ze, Button as Me, DropdownMenuContent as Ie, DropdownMenuItem as de, NavigationOverlay as fe } from "@object-ui/components";
|
|
7
|
+
import { MoreVertical as De, Edit as Fe, Trash2 as Pe } from "lucide-react";
|
|
8
|
+
import { flushSync as $e } from "react-dom";
|
|
9
|
+
var oe = { exports: {} }, te = {};
|
|
10
|
+
var he;
|
|
11
|
+
function We() {
|
|
12
|
+
if (he) return te;
|
|
13
|
+
he = 1;
|
|
14
|
+
var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
|
+
function e(s, t, i) {
|
|
16
16
|
var o = null;
|
|
17
|
-
if (i !== void 0 && (o = "" + i),
|
|
17
|
+
if (i !== void 0 && (o = "" + i), t.key !== void 0 && (o = "" + t.key), "key" in t) {
|
|
18
18
|
i = {};
|
|
19
|
-
for (var l in
|
|
20
|
-
l !== "key" && (i[l] =
|
|
21
|
-
} else i =
|
|
22
|
-
return
|
|
23
|
-
$$typeof:
|
|
19
|
+
for (var l in t)
|
|
20
|
+
l !== "key" && (i[l] = t[l]);
|
|
21
|
+
} else i = t;
|
|
22
|
+
return t = i.ref, {
|
|
23
|
+
$$typeof: n,
|
|
24
24
|
type: s,
|
|
25
25
|
key: o,
|
|
26
|
-
ref:
|
|
26
|
+
ref: t !== void 0 ? t : null,
|
|
27
27
|
props: i
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return te.Fragment = a, te.jsx = e, te.jsxs = e, te;
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
function
|
|
35
|
-
return
|
|
36
|
-
function
|
|
32
|
+
var ne = {};
|
|
33
|
+
var me;
|
|
34
|
+
function Le() {
|
|
35
|
+
return me || (me = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
|
+
function n(r) {
|
|
37
37
|
if (r == null) return null;
|
|
38
38
|
if (typeof r == "function")
|
|
39
|
-
return r.$$typeof ===
|
|
39
|
+
return r.$$typeof === V ? null : r.displayName || r.name || null;
|
|
40
40
|
if (typeof r == "string") return r;
|
|
41
41
|
switch (r) {
|
|
42
|
-
case
|
|
42
|
+
case j:
|
|
43
43
|
return "Fragment";
|
|
44
|
-
case
|
|
44
|
+
case O:
|
|
45
45
|
return "Profiler";
|
|
46
|
-
case
|
|
46
|
+
case N:
|
|
47
47
|
return "StrictMode";
|
|
48
|
-
case
|
|
48
|
+
case L:
|
|
49
49
|
return "Suspense";
|
|
50
|
-
case
|
|
50
|
+
case F:
|
|
51
51
|
return "SuspenseList";
|
|
52
|
-
case
|
|
52
|
+
case U:
|
|
53
53
|
return "Activity";
|
|
54
54
|
}
|
|
55
55
|
if (typeof r == "object")
|
|
56
56
|
switch (typeof r.tag == "number" && console.error(
|
|
57
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
58
58
|
), r.$$typeof) {
|
|
59
|
-
case
|
|
59
|
+
case v:
|
|
60
60
|
return "Portal";
|
|
61
|
-
case
|
|
61
|
+
case k:
|
|
62
62
|
return r.displayName || "Context";
|
|
63
|
-
case
|
|
63
|
+
case D:
|
|
64
64
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
|
-
case
|
|
66
|
-
var
|
|
67
|
-
return r = r.displayName, r || (r =
|
|
68
|
-
case
|
|
69
|
-
return
|
|
70
|
-
case
|
|
71
|
-
|
|
65
|
+
case C:
|
|
66
|
+
var h = r.render;
|
|
67
|
+
return r = r.displayName, r || (r = h.displayName || h.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
68
|
+
case $:
|
|
69
|
+
return h = r.displayName || null, h !== null ? h : n(r.type) || "Memo";
|
|
70
|
+
case z:
|
|
71
|
+
h = r._payload, r = r._init;
|
|
72
72
|
try {
|
|
73
|
-
return
|
|
73
|
+
return n(r(h));
|
|
74
74
|
} catch {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -82,50 +82,50 @@ function Te() {
|
|
|
82
82
|
function e(r) {
|
|
83
83
|
try {
|
|
84
84
|
a(r);
|
|
85
|
-
var
|
|
85
|
+
var h = !1;
|
|
86
86
|
} catch {
|
|
87
|
-
|
|
87
|
+
h = !0;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
var x =
|
|
89
|
+
if (h) {
|
|
90
|
+
h = console;
|
|
91
|
+
var x = h.error, S = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
92
92
|
return x.call(
|
|
93
|
-
|
|
93
|
+
h,
|
|
94
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
95
|
-
|
|
95
|
+
S
|
|
96
96
|
), a(r);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
function s(r) {
|
|
100
|
-
if (r ===
|
|
101
|
-
if (typeof r == "object" && r !== null && r.$$typeof ===
|
|
100
|
+
if (r === j) return "<>";
|
|
101
|
+
if (typeof r == "object" && r !== null && r.$$typeof === z)
|
|
102
102
|
return "<...>";
|
|
103
103
|
try {
|
|
104
|
-
var
|
|
105
|
-
return
|
|
104
|
+
var h = n(r);
|
|
105
|
+
return h ? "<" + h + ">" : "<...>";
|
|
106
106
|
} catch {
|
|
107
107
|
return "<...>";
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
var r =
|
|
110
|
+
function t() {
|
|
111
|
+
var r = q.A;
|
|
112
112
|
return r === null ? null : r.getOwner();
|
|
113
113
|
}
|
|
114
114
|
function i() {
|
|
115
115
|
return Error("react-stack-top-frame");
|
|
116
116
|
}
|
|
117
117
|
function o(r) {
|
|
118
|
-
if (
|
|
119
|
-
var
|
|
120
|
-
if (
|
|
118
|
+
if (J.call(r, "key")) {
|
|
119
|
+
var h = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
|
+
if (h && h.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
122
|
return r.key !== void 0;
|
|
123
123
|
}
|
|
124
|
-
function l(r,
|
|
124
|
+
function l(r, h) {
|
|
125
125
|
function x() {
|
|
126
|
-
|
|
126
|
+
se || (se = !0, console.error(
|
|
127
127
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
128
|
-
|
|
128
|
+
h
|
|
129
129
|
));
|
|
130
130
|
}
|
|
131
131
|
x.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
@@ -133,23 +133,23 @@ function Te() {
|
|
|
133
133
|
configurable: !0
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var r =
|
|
138
|
-
return
|
|
136
|
+
function p() {
|
|
137
|
+
var r = n(this.type);
|
|
138
|
+
return K[r] || (K[r] = !0, console.error(
|
|
139
139
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
140
140
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
var
|
|
142
|
+
function g(r, h, x, S, Y, G) {
|
|
143
|
+
var f = x.ref;
|
|
144
144
|
return r = {
|
|
145
|
-
$$typeof:
|
|
145
|
+
$$typeof: _,
|
|
146
146
|
type: r,
|
|
147
|
-
key:
|
|
147
|
+
key: h,
|
|
148
148
|
props: x,
|
|
149
|
-
_owner:
|
|
150
|
-
}, (
|
|
149
|
+
_owner: S
|
|
150
|
+
}, (f !== void 0 ? f : null) !== null ? Object.defineProperty(r, "ref", {
|
|
151
151
|
enumerable: !1,
|
|
152
|
-
get:
|
|
152
|
+
get: p
|
|
153
153
|
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
154
154
|
configurable: !1,
|
|
155
155
|
enumerable: !1,
|
|
@@ -164,397 +164,478 @@ function Te() {
|
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
166
166
|
writable: !0,
|
|
167
|
-
value:
|
|
167
|
+
value: Y
|
|
168
168
|
}), Object.defineProperty(r, "_debugTask", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
171
171
|
writable: !0,
|
|
172
|
-
value:
|
|
172
|
+
value: G
|
|
173
173
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
var
|
|
177
|
-
if (
|
|
178
|
-
if (
|
|
179
|
-
if (
|
|
180
|
-
for (
|
|
181
|
-
|
|
182
|
-
Object.freeze && Object.freeze(
|
|
175
|
+
function m(r, h, x, S, Y, G) {
|
|
176
|
+
var f = h.children;
|
|
177
|
+
if (f !== void 0)
|
|
178
|
+
if (S)
|
|
179
|
+
if (M(f)) {
|
|
180
|
+
for (S = 0; S < f.length; S++)
|
|
181
|
+
E(f[S]);
|
|
182
|
+
Object.freeze && Object.freeze(f);
|
|
183
183
|
} else
|
|
184
184
|
console.error(
|
|
185
185
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
186
186
|
);
|
|
187
|
-
else
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
var
|
|
191
|
-
return
|
|
187
|
+
else E(f);
|
|
188
|
+
if (J.call(h, "key")) {
|
|
189
|
+
f = n(r);
|
|
190
|
+
var y = Object.keys(h).filter(function(w) {
|
|
191
|
+
return w !== "key";
|
|
192
192
|
});
|
|
193
|
-
|
|
193
|
+
S = 0 < y.length ? "{key: someKey, " + y.join(": ..., ") + ": ...}" : "{key: someKey}", re[f + S] || (y = 0 < y.length ? "{" + y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
194
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
195
195
|
let props = %s;
|
|
196
196
|
<%s {...props} />
|
|
197
197
|
React keys must be passed directly to JSX without using spread:
|
|
198
198
|
let props = %s;
|
|
199
199
|
<%s key={someKey} {...props} />`,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
),
|
|
200
|
+
S,
|
|
201
|
+
f,
|
|
202
|
+
y,
|
|
203
|
+
f
|
|
204
|
+
), re[f + S] = !0);
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (f = null, x !== void 0 && (e(x), f = "" + x), o(h) && (e(h.key), f = "" + h.key), "key" in h) {
|
|
207
207
|
x = {};
|
|
208
|
-
for (var
|
|
209
|
-
|
|
210
|
-
} else x =
|
|
211
|
-
return
|
|
208
|
+
for (var A in h)
|
|
209
|
+
A !== "key" && (x[A] = h[A]);
|
|
210
|
+
} else x = h;
|
|
211
|
+
return f && l(
|
|
212
212
|
x,
|
|
213
213
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
214
|
-
),
|
|
214
|
+
), g(
|
|
215
215
|
r,
|
|
216
|
-
|
|
216
|
+
f,
|
|
217
217
|
x,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
t(),
|
|
219
|
+
Y,
|
|
220
|
+
G
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
c(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof ===
|
|
223
|
+
function E(r) {
|
|
224
|
+
c(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === z && (r._payload.status === "fulfilled" ? c(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
225
225
|
}
|
|
226
226
|
function c(r) {
|
|
227
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
227
|
+
return typeof r == "object" && r !== null && r.$$typeof === _;
|
|
228
228
|
}
|
|
229
|
-
var
|
|
229
|
+
var b = Se, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), N = /* @__PURE__ */ Symbol.for("react.strict_mode"), O = /* @__PURE__ */ Symbol.for("react.profiler"), D = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), C = /* @__PURE__ */ Symbol.for("react.forward_ref"), L = /* @__PURE__ */ Symbol.for("react.suspense"), F = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), V = /* @__PURE__ */ Symbol.for("react.client.reference"), q = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, M = Array.isArray, B = console.createTask ? console.createTask : function() {
|
|
230
230
|
return null;
|
|
231
231
|
};
|
|
232
|
-
|
|
232
|
+
b = {
|
|
233
233
|
react_stack_bottom_frame: function(r) {
|
|
234
234
|
return r();
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
var
|
|
238
|
-
|
|
237
|
+
var se, K = {}, W = b.react_stack_bottom_frame.bind(
|
|
238
|
+
b,
|
|
239
239
|
i
|
|
240
|
-
)(),
|
|
241
|
-
|
|
242
|
-
var
|
|
243
|
-
return
|
|
240
|
+
)(), X = B(s(i)), re = {};
|
|
241
|
+
ne.Fragment = j, ne.jsx = function(r, h, x) {
|
|
242
|
+
var S = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
243
|
+
return m(
|
|
244
244
|
r,
|
|
245
|
-
|
|
245
|
+
h,
|
|
246
246
|
x,
|
|
247
247
|
!1,
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
S ? Error("react-stack-top-frame") : W,
|
|
249
|
+
S ? B(s(r)) : X
|
|
250
250
|
);
|
|
251
|
-
},
|
|
252
|
-
var
|
|
253
|
-
return
|
|
251
|
+
}, ne.jsxs = function(r, h, x) {
|
|
252
|
+
var S = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return m(
|
|
254
254
|
r,
|
|
255
|
-
|
|
255
|
+
h,
|
|
256
256
|
x,
|
|
257
257
|
!0,
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
S ? Error("react-stack-top-frame") : W,
|
|
259
|
+
S ? B(s(r)) : X
|
|
260
260
|
);
|
|
261
261
|
};
|
|
262
|
-
})()),
|
|
262
|
+
})()), ne;
|
|
263
263
|
}
|
|
264
|
-
var
|
|
265
|
-
function
|
|
266
|
-
return
|
|
264
|
+
var pe;
|
|
265
|
+
function Ve() {
|
|
266
|
+
return pe || (pe = 1, process.env.NODE_ENV === "production" ? oe.exports = We() : oe.exports = Le()), oe.exports;
|
|
267
267
|
}
|
|
268
|
-
var
|
|
269
|
-
function
|
|
270
|
-
return
|
|
268
|
+
var u = Ve();
|
|
269
|
+
function Ye(n) {
|
|
270
|
+
return n.data ? Array.isArray(n.data) ? {
|
|
271
271
|
provider: "value",
|
|
272
|
-
items:
|
|
273
|
-
} :
|
|
272
|
+
items: n.data
|
|
273
|
+
} : n.data : n.staticData ? {
|
|
274
274
|
provider: "value",
|
|
275
|
-
items:
|
|
276
|
-
} :
|
|
275
|
+
items: n.staticData
|
|
276
|
+
} : n.objectName ? {
|
|
277
277
|
provider: "object",
|
|
278
|
-
object:
|
|
278
|
+
object: n.objectName
|
|
279
279
|
} : null;
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
if (!(!
|
|
283
|
-
return typeof
|
|
281
|
+
function ge(n) {
|
|
282
|
+
if (!(!n || n.length === 0))
|
|
283
|
+
return typeof n[0] == "object" && n[0] !== null, n;
|
|
284
284
|
}
|
|
285
|
-
const
|
|
286
|
-
schema:
|
|
285
|
+
const Ue = ({
|
|
286
|
+
schema: n,
|
|
287
287
|
dataSource: a,
|
|
288
288
|
onEdit: e,
|
|
289
289
|
onDelete: s,
|
|
290
|
-
onRowSelect:
|
|
290
|
+
onRowSelect: t,
|
|
291
291
|
onRowClick: i,
|
|
292
|
-
|
|
292
|
+
onCellChange: o,
|
|
293
|
+
onRowSave: l,
|
|
294
|
+
onBatchSave: p,
|
|
295
|
+
...g
|
|
293
296
|
}) => {
|
|
294
|
-
const [
|
|
297
|
+
const [m, E] = ie([]), [c, b] = ie(!0), [_, v] = ie(null), [j, N] = ie(null), O = g.data, D = Re(n.bind), k = Ye(n), C = Se.useMemo(() => O && Array.isArray(O) ? {
|
|
295
298
|
provider: "value",
|
|
296
|
-
items:
|
|
297
|
-
} :
|
|
299
|
+
items: O
|
|
300
|
+
} : D && Array.isArray(D) ? {
|
|
298
301
|
provider: "value",
|
|
299
|
-
items:
|
|
300
|
-
} :
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
return JSON.stringify(
|
|
305
|
-
}),
|
|
306
|
-
}, [
|
|
307
|
-
|
|
302
|
+
items: D
|
|
303
|
+
} : k, [JSON.stringify(k), D, O]), L = C?.provider === "value", F = C?.provider === "object" && C && "object" in C ? C.object : n.objectName, $ = n.fields, z = n.columns, U = n.filter, V = n.sort, q = n.pagination, J = n.pageSize;
|
|
304
|
+
ae(() => {
|
|
305
|
+
L && C?.provider === "value" && (E((f) => {
|
|
306
|
+
const y = C.items;
|
|
307
|
+
return JSON.stringify(f) !== JSON.stringify(y) ? y : f;
|
|
308
|
+
}), b(!1));
|
|
309
|
+
}, [L, C]), ae(() => {
|
|
310
|
+
if (L) return;
|
|
311
|
+
let f = !1;
|
|
312
|
+
return (async () => {
|
|
313
|
+
b(!0), v(null);
|
|
308
314
|
try {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
let A = null;
|
|
316
|
+
if ((ge(z) || $) && F)
|
|
317
|
+
A = { name: F, fields: {} };
|
|
318
|
+
else if (F && a) {
|
|
319
|
+
const d = await a.getObjectSchema(F);
|
|
320
|
+
if (f) return;
|
|
321
|
+
A = d;
|
|
322
|
+
} else throw F ? new Error("DataSource required") : new Error("Object name required for data fetching");
|
|
323
|
+
if (f || N(A), a && F) {
|
|
324
|
+
const T = {
|
|
325
|
+
$select: (() => {
|
|
326
|
+
if ($) return $;
|
|
327
|
+
if (z && Array.isArray(z))
|
|
328
|
+
return z.map((R) => typeof R == "string" ? R : R.field);
|
|
329
|
+
})(),
|
|
330
|
+
$top: q?.pageSize || J || 50
|
|
331
|
+
};
|
|
332
|
+
U && Array.isArray(U) ? T.$filter = U : n.defaultFilters && (T.$filter = n.defaultFilters), V ? typeof V == "string" ? T.$orderby = V : Array.isArray(V) && (T.$orderby = V.map((R) => `${R.field} ${R.order}`).join(", ")) : n.defaultSort && (T.$orderby = `${n.defaultSort.field} ${n.defaultSort.order}`);
|
|
333
|
+
const P = await a.find(F, T);
|
|
334
|
+
if (f) return;
|
|
335
|
+
E(P.data || []);
|
|
336
|
+
}
|
|
337
|
+
} catch (A) {
|
|
338
|
+
f || v(A);
|
|
339
|
+
} finally {
|
|
340
|
+
f || b(!1);
|
|
318
341
|
}
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
})(), () => {
|
|
343
|
+
f = !0;
|
|
344
|
+
};
|
|
345
|
+
}, [F, $, z, U, V, q, J, a, L, C]);
|
|
346
|
+
const M = Ae({
|
|
347
|
+
navigation: n.navigation,
|
|
348
|
+
objectName: n.objectName,
|
|
349
|
+
onNavigate: n.onNavigate,
|
|
350
|
+
onRowClick: i
|
|
351
|
+
}), { execute: B } = Te(), se = Ce(() => {
|
|
352
|
+
const f = ge(z);
|
|
353
|
+
if (f) {
|
|
354
|
+
if (f.length > 0 && typeof f[0] == "object" && f[0] !== null) {
|
|
355
|
+
const w = f[0];
|
|
356
|
+
if ("accessorKey" in w)
|
|
357
|
+
return f;
|
|
358
|
+
if ("field" in w)
|
|
359
|
+
return f.filter((d) => d?.field && typeof d.field == "string" && !d.hidden).map((d) => {
|
|
360
|
+
const T = d.label || d.field.charAt(0).toUpperCase() + d.field.slice(1).replace(/_/g, " ");
|
|
361
|
+
let P;
|
|
362
|
+
const R = d.type ? ue(d.type) : null;
|
|
363
|
+
return d.link && d.action ? P = (I, Z) => {
|
|
364
|
+
const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
|
|
365
|
+
return /* @__PURE__ */ u.jsx(
|
|
366
|
+
"button",
|
|
367
|
+
{
|
|
368
|
+
type: "button",
|
|
369
|
+
className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
370
|
+
onClick: (ee) => {
|
|
371
|
+
ee.stopPropagation(), M.handleClick(Z);
|
|
372
|
+
},
|
|
373
|
+
children: Q
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
} : d.link ? P = (I, Z) => {
|
|
377
|
+
const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
|
|
378
|
+
return /* @__PURE__ */ u.jsx(
|
|
379
|
+
"button",
|
|
380
|
+
{
|
|
381
|
+
type: "button",
|
|
382
|
+
className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
383
|
+
onClick: (ee) => {
|
|
384
|
+
ee.stopPropagation(), M.handleClick(Z);
|
|
385
|
+
},
|
|
386
|
+
children: Q
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
} : d.action ? P = (I, Z) => {
|
|
390
|
+
const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
|
|
391
|
+
return /* @__PURE__ */ u.jsx(
|
|
392
|
+
"button",
|
|
393
|
+
{
|
|
394
|
+
type: "button",
|
|
395
|
+
className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
396
|
+
onClick: (ee) => {
|
|
397
|
+
ee.stopPropagation(), B({
|
|
398
|
+
type: d.action,
|
|
399
|
+
params: { record: Z, field: d.field, value: I }
|
|
400
|
+
});
|
|
401
|
+
},
|
|
402
|
+
children: Q
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
} : R && (P = (I) => /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } })), {
|
|
406
|
+
header: T,
|
|
407
|
+
accessorKey: d.field,
|
|
408
|
+
...d.width && { width: d.width },
|
|
409
|
+
...d.align && { align: d.align },
|
|
410
|
+
sortable: d.sortable !== !1,
|
|
411
|
+
...d.resizable !== void 0 && { resizable: d.resizable },
|
|
412
|
+
...d.wrap !== void 0 && { wrap: d.wrap },
|
|
413
|
+
...P && { cell: P }
|
|
414
|
+
};
|
|
415
|
+
});
|
|
337
416
|
}
|
|
338
|
-
return
|
|
339
|
-
header:
|
|
340
|
-
accessorKey:
|
|
417
|
+
return f.filter((w) => typeof w == "string" && w.trim().length > 0).map((w) => ({
|
|
418
|
+
header: j?.fields?.[w]?.label || w.charAt(0).toUpperCase() + w.slice(1).replace(/_/g, " "),
|
|
419
|
+
accessorKey: w
|
|
341
420
|
}));
|
|
342
421
|
}
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
return (
|
|
347
|
-
header:
|
|
348
|
-
accessorKey:
|
|
422
|
+
if (L) {
|
|
423
|
+
const w = C?.provider === "value" ? C.items : [];
|
|
424
|
+
if (w.length > 0)
|
|
425
|
+
return ($ || Object.keys(w[0])).map((T) => ({
|
|
426
|
+
header: T.charAt(0).toUpperCase() + T.slice(1).replace(/_/g, " "),
|
|
427
|
+
accessorKey: T
|
|
349
428
|
}));
|
|
350
429
|
}
|
|
351
|
-
if (!
|
|
352
|
-
const
|
|
353
|
-
return (
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
header:
|
|
359
|
-
accessorKey:
|
|
360
|
-
cell: (
|
|
361
|
-
sortable:
|
|
430
|
+
if (!j) return [];
|
|
431
|
+
const y = [];
|
|
432
|
+
return ($ || Object.keys(j.fields || {})).forEach((w) => {
|
|
433
|
+
const d = j.fields?.[w];
|
|
434
|
+
if (!d || d.permissions && d.permissions.read === !1) return;
|
|
435
|
+
const T = ue(d.type);
|
|
436
|
+
y.push({
|
|
437
|
+
header: d.label || w,
|
|
438
|
+
accessorKey: w,
|
|
439
|
+
cell: (P) => /* @__PURE__ */ u.jsx(T, { value: P, field: d }),
|
|
440
|
+
sortable: d.sortable !== !1
|
|
362
441
|
});
|
|
363
|
-
}),
|
|
364
|
-
}, [
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (!y)
|
|
370
|
-
throw new Error("Object name required for data fetching");
|
|
371
|
-
const R = {
|
|
372
|
-
$select: (() => {
|
|
373
|
-
if (t.fields) return t.fields;
|
|
374
|
-
if (t.columns && Array.isArray(t.columns))
|
|
375
|
-
return t.columns.map((h) => typeof h == "string" ? h : h.field);
|
|
376
|
-
})(),
|
|
377
|
-
$top: t.pagination?.pageSize || t.pageSize || 50
|
|
378
|
-
};
|
|
379
|
-
t.filter && Array.isArray(t.filter) ? R.$filter = t.filter : "defaultFilters" in t && t.defaultFilters && (R.$filter = t.defaultFilters), t.sort ? typeof t.sort == "string" ? R.$orderby = t.sort : Array.isArray(t.sort) && (R.$orderby = t.sort.map((h) => `${h.field} ${h.order}`).join(", ")) : "defaultSort" in t && t.defaultSort && (R.$orderby = `${t.defaultSort.field} ${t.defaultSort.order}`);
|
|
380
|
-
const E = await a.find(y, R);
|
|
381
|
-
f(E.data || []);
|
|
382
|
-
} catch (y) {
|
|
383
|
-
c(y);
|
|
384
|
-
} finally {
|
|
385
|
-
d(!1);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}, [t, a, j, p]);
|
|
389
|
-
if (Q(() => {
|
|
390
|
-
(m || j) && N();
|
|
391
|
-
}, [m, j, N]), S)
|
|
392
|
-
return /* @__PURE__ */ v.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
393
|
-
/* @__PURE__ */ v.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
|
|
394
|
-
/* @__PURE__ */ v.jsx("p", { className: "text-red-600 text-sm mt-1", children: S.message })
|
|
442
|
+
}), y;
|
|
443
|
+
}, [j, $, z, C, L, M.handleClick, B]);
|
|
444
|
+
if (_)
|
|
445
|
+
return /* @__PURE__ */ u.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
446
|
+
/* @__PURE__ */ u.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
|
|
447
|
+
/* @__PURE__ */ u.jsx("p", { className: "text-red-600 text-sm mt-1", children: _.message })
|
|
395
448
|
] });
|
|
396
|
-
if (
|
|
397
|
-
return /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */
|
|
449
|
+
if (c && m.length === 0)
|
|
450
|
+
return /* @__PURE__ */ u.jsxs("div", { className: "p-8 text-center", children: [
|
|
451
|
+
/* @__PURE__ */ u.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
452
|
+
/* @__PURE__ */ u.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading grid..." })
|
|
400
453
|
] });
|
|
401
|
-
const
|
|
402
|
-
...
|
|
454
|
+
const K = se(), W = "operations" in n ? n.operations : void 0, X = W && (W.update || W.delete), re = X ? [
|
|
455
|
+
...K,
|
|
403
456
|
{
|
|
404
457
|
header: "Actions",
|
|
405
458
|
accessorKey: "_actions",
|
|
406
|
-
cell: (
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */
|
|
459
|
+
cell: (f, y) => /* @__PURE__ */ u.jsxs(ke, { children: [
|
|
460
|
+
/* @__PURE__ */ u.jsx(ze, { asChild: !0, children: /* @__PURE__ */ u.jsxs(Me, { variant: "ghost", size: "icon", className: "h-8 w-8", children: [
|
|
461
|
+
/* @__PURE__ */ u.jsx(De, { className: "h-4 w-4" }),
|
|
462
|
+
/* @__PURE__ */ u.jsx("span", { className: "sr-only", children: "Open menu" })
|
|
410
463
|
] }) }),
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
|
|
413
|
-
/* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ u.jsxs(Ie, { align: "end", children: [
|
|
465
|
+
W?.update && e && /* @__PURE__ */ u.jsxs(de, { onClick: () => e(y), children: [
|
|
466
|
+
/* @__PURE__ */ u.jsx(Fe, { className: "mr-2 h-4 w-4" }),
|
|
414
467
|
"Edit"
|
|
415
468
|
] }),
|
|
416
|
-
|
|
417
|
-
/* @__PURE__ */
|
|
469
|
+
W?.delete && s && /* @__PURE__ */ u.jsxs(de, { onClick: () => s(y), children: [
|
|
470
|
+
/* @__PURE__ */ u.jsx(Pe, { className: "mr-2 h-4 w-4" }),
|
|
418
471
|
"Delete"
|
|
419
472
|
] })
|
|
420
473
|
] })
|
|
421
474
|
] }),
|
|
422
475
|
sortable: !1
|
|
423
476
|
}
|
|
424
|
-
] :
|
|
425
|
-
let
|
|
426
|
-
|
|
427
|
-
const
|
|
477
|
+
] : K;
|
|
478
|
+
let r = !1;
|
|
479
|
+
n.selection?.type ? r = n.selection.type === "none" ? !1 : n.selection.type : n.selectable !== void 0 && (r = n.selectable);
|
|
480
|
+
const h = n.pagination !== void 0 ? !0 : n.showPagination !== void 0 ? n.showPagination : !0, x = n.pagination?.pageSize || n.pageSize || 10, S = n.searchableFields !== void 0 ? n.searchableFields.length > 0 : n.showSearch !== void 0 ? n.showSearch : !0, Y = {
|
|
428
481
|
type: "data-table",
|
|
429
|
-
caption:
|
|
430
|
-
columns:
|
|
431
|
-
data:
|
|
432
|
-
pagination:
|
|
433
|
-
pageSize:
|
|
434
|
-
searchable:
|
|
435
|
-
selectable:
|
|
482
|
+
caption: n.label || n.title,
|
|
483
|
+
columns: re,
|
|
484
|
+
data: m,
|
|
485
|
+
pagination: h,
|
|
486
|
+
pageSize: x,
|
|
487
|
+
searchable: S,
|
|
488
|
+
selectable: r,
|
|
436
489
|
sortable: !0,
|
|
437
|
-
exportable:
|
|
438
|
-
rowActions:
|
|
439
|
-
resizableColumns:
|
|
440
|
-
reorderableColumns:
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
490
|
+
exportable: W?.export,
|
|
491
|
+
rowActions: X,
|
|
492
|
+
resizableColumns: n.resizable ?? n.resizableColumns ?? !0,
|
|
493
|
+
reorderableColumns: n.reorderableColumns ?? !1,
|
|
494
|
+
editable: n.editable ?? !1,
|
|
495
|
+
className: n.className,
|
|
496
|
+
onSelectionChange: t,
|
|
497
|
+
onRowClick: M.handleClick,
|
|
498
|
+
onCellChange: o,
|
|
499
|
+
onRowSave: l,
|
|
500
|
+
onBatchSave: p
|
|
501
|
+
}, G = n.label ? `${n.label} Detail` : n.objectName ? `${n.objectName.charAt(0).toUpperCase() + n.objectName.slice(1)} Detail` : "Record Detail";
|
|
502
|
+
return M.isOverlay && M.mode === "split" ? /* @__PURE__ */ u.jsx(
|
|
503
|
+
fe,
|
|
504
|
+
{
|
|
505
|
+
...M,
|
|
506
|
+
title: G,
|
|
507
|
+
mainContent: /* @__PURE__ */ u.jsx(ce, { schema: Y }),
|
|
508
|
+
children: (f) => /* @__PURE__ */ u.jsx("div", { className: "space-y-3", children: Object.entries(f).map(([y, A]) => /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col", children: [
|
|
509
|
+
/* @__PURE__ */ u.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: y.replace(/_/g, " ") }),
|
|
510
|
+
/* @__PURE__ */ u.jsx("span", { className: "text-sm", children: String(A ?? "—") })
|
|
511
|
+
] }, y)) })
|
|
512
|
+
}
|
|
513
|
+
) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
|
|
514
|
+
/* @__PURE__ */ u.jsx(ce, { schema: Y }),
|
|
515
|
+
M.isOverlay && /* @__PURE__ */ u.jsx(
|
|
516
|
+
fe,
|
|
517
|
+
{
|
|
518
|
+
...M,
|
|
519
|
+
title: G,
|
|
520
|
+
children: (f) => /* @__PURE__ */ u.jsx("div", { className: "space-y-3", children: Object.entries(f).map(([y, A]) => /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col", children: [
|
|
521
|
+
/* @__PURE__ */ u.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: y.replace(/_/g, " ") }),
|
|
522
|
+
/* @__PURE__ */ u.jsx("span", { className: "text-sm", children: String(A ?? "—") })
|
|
523
|
+
] }, y)) })
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
] });
|
|
446
527
|
};
|
|
447
|
-
function
|
|
448
|
-
let s = e.initialDeps ?? [],
|
|
528
|
+
function H(n, a, e) {
|
|
529
|
+
let s = e.initialDeps ?? [], t, i = !0;
|
|
449
530
|
function o() {
|
|
450
|
-
var l,
|
|
451
|
-
let d;
|
|
452
|
-
e.key && ((l = e.debug) != null && l.call(e)) && (d = Date.now());
|
|
453
|
-
const S = t();
|
|
454
|
-
if (!(S.length !== s.length || S.some((C, g) => s[g] !== C)))
|
|
455
|
-
return n;
|
|
456
|
-
s = S;
|
|
531
|
+
var l, p, g;
|
|
457
532
|
let m;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
533
|
+
e.key && ((l = e.debug) != null && l.call(e)) && (m = Date.now());
|
|
534
|
+
const E = n();
|
|
535
|
+
if (!(E.length !== s.length || E.some((_, v) => s[v] !== _)))
|
|
536
|
+
return t;
|
|
537
|
+
s = E;
|
|
538
|
+
let b;
|
|
539
|
+
if (e.key && ((p = e.debug) != null && p.call(e)) && (b = Date.now()), t = a(...E), e.key && ((g = e.debug) != null && g.call(e))) {
|
|
540
|
+
const _ = Math.round((Date.now() - m) * 100) / 100, v = Math.round((Date.now() - b) * 100) / 100, j = v / 16, N = (O, D) => {
|
|
541
|
+
for (O = String(O); O.length < D; )
|
|
542
|
+
O = " " + O;
|
|
543
|
+
return O;
|
|
463
544
|
};
|
|
464
545
|
console.info(
|
|
465
|
-
`%c⏱ ${
|
|
546
|
+
`%c⏱ ${N(v, 5)} /${N(_, 5)} ms`,
|
|
466
547
|
`
|
|
467
548
|
font-size: .6rem;
|
|
468
549
|
font-weight: bold;
|
|
469
550
|
color: hsl(${Math.max(
|
|
470
551
|
0,
|
|
471
|
-
Math.min(120 - 120 *
|
|
552
|
+
Math.min(120 - 120 * j, 120)
|
|
472
553
|
)}deg 100% 31%);`,
|
|
473
554
|
e?.key
|
|
474
555
|
);
|
|
475
556
|
}
|
|
476
|
-
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(
|
|
557
|
+
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(t), i = !1, t;
|
|
477
558
|
}
|
|
478
559
|
return o.updateDeps = (l) => {
|
|
479
560
|
s = l;
|
|
480
561
|
}, o;
|
|
481
562
|
}
|
|
482
|
-
function
|
|
483
|
-
if (
|
|
563
|
+
function be(n, a) {
|
|
564
|
+
if (n === void 0)
|
|
484
565
|
throw new Error("Unexpected undefined");
|
|
485
|
-
return
|
|
566
|
+
return n;
|
|
486
567
|
}
|
|
487
|
-
const
|
|
568
|
+
const qe = (n, a) => Math.abs(n - a) < 1.01, Be = (n, a, e) => {
|
|
488
569
|
let s;
|
|
489
|
-
return function(...
|
|
490
|
-
|
|
570
|
+
return function(...t) {
|
|
571
|
+
n.clearTimeout(s), s = n.setTimeout(() => a.apply(this, t), e);
|
|
491
572
|
};
|
|
492
|
-
},
|
|
493
|
-
const { offsetWidth: a, offsetHeight: e } =
|
|
573
|
+
}, ve = (n) => {
|
|
574
|
+
const { offsetWidth: a, offsetHeight: e } = n;
|
|
494
575
|
return { width: a, height: e };
|
|
495
|
-
},
|
|
496
|
-
const a = Math.max(
|
|
497
|
-
for (let
|
|
498
|
-
s.push(
|
|
576
|
+
}, Ge = (n) => n, He = (n) => {
|
|
577
|
+
const a = Math.max(n.startIndex - n.overscan, 0), e = Math.min(n.endIndex + n.overscan, n.count - 1), s = [];
|
|
578
|
+
for (let t = a; t <= e; t++)
|
|
579
|
+
s.push(t);
|
|
499
580
|
return s;
|
|
500
|
-
},
|
|
501
|
-
const e =
|
|
581
|
+
}, Je = (n, a) => {
|
|
582
|
+
const e = n.scrollElement;
|
|
502
583
|
if (!e)
|
|
503
584
|
return;
|
|
504
|
-
const s =
|
|
585
|
+
const s = n.targetWindow;
|
|
505
586
|
if (!s)
|
|
506
587
|
return;
|
|
507
|
-
const
|
|
508
|
-
const { width: l, height:
|
|
509
|
-
a({ width: Math.round(l), height: Math.round(
|
|
588
|
+
const t = (o) => {
|
|
589
|
+
const { width: l, height: p } = o;
|
|
590
|
+
a({ width: Math.round(l), height: Math.round(p) });
|
|
510
591
|
};
|
|
511
|
-
if (
|
|
592
|
+
if (t(ve(e)), !s.ResizeObserver)
|
|
512
593
|
return () => {
|
|
513
594
|
};
|
|
514
595
|
const i = new s.ResizeObserver((o) => {
|
|
515
596
|
const l = () => {
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
|
|
597
|
+
const p = o[0];
|
|
598
|
+
if (p?.borderBoxSize) {
|
|
599
|
+
const g = p.borderBoxSize[0];
|
|
600
|
+
if (g) {
|
|
601
|
+
t({ width: g.inlineSize, height: g.blockSize });
|
|
521
602
|
return;
|
|
522
603
|
}
|
|
523
604
|
}
|
|
524
|
-
|
|
605
|
+
t(ve(e));
|
|
525
606
|
};
|
|
526
|
-
|
|
607
|
+
n.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
|
|
527
608
|
});
|
|
528
609
|
return i.observe(e, { box: "border-box" }), () => {
|
|
529
610
|
i.unobserve(e);
|
|
530
611
|
};
|
|
531
|
-
},
|
|
612
|
+
}, xe = {
|
|
532
613
|
passive: !0
|
|
533
|
-
},
|
|
534
|
-
const e =
|
|
614
|
+
}, ye = typeof window > "u" ? !0 : "onscrollend" in window, Ke = (n, a) => {
|
|
615
|
+
const e = n.scrollElement;
|
|
535
616
|
if (!e)
|
|
536
617
|
return;
|
|
537
|
-
const s =
|
|
618
|
+
const s = n.targetWindow;
|
|
538
619
|
if (!s)
|
|
539
620
|
return;
|
|
540
|
-
let
|
|
541
|
-
const i =
|
|
542
|
-
} :
|
|
621
|
+
let t = 0;
|
|
622
|
+
const i = n.options.useScrollendEvent && ye ? () => {
|
|
623
|
+
} : Be(
|
|
543
624
|
s,
|
|
544
625
|
() => {
|
|
545
|
-
a(
|
|
626
|
+
a(t, !1);
|
|
546
627
|
},
|
|
547
|
-
|
|
548
|
-
), o = (
|
|
549
|
-
const { horizontal:
|
|
550
|
-
|
|
551
|
-
}, l = o(!0),
|
|
552
|
-
e.addEventListener("scroll", l,
|
|
553
|
-
const
|
|
554
|
-
return
|
|
555
|
-
e.removeEventListener("scroll", l),
|
|
628
|
+
n.options.isScrollingResetDelay
|
|
629
|
+
), o = (m) => () => {
|
|
630
|
+
const { horizontal: E, isRtl: c } = n.options;
|
|
631
|
+
t = E ? e.scrollLeft * (c && -1 || 1) : e.scrollTop, i(), a(t, m);
|
|
632
|
+
}, l = o(!0), p = o(!1);
|
|
633
|
+
e.addEventListener("scroll", l, xe);
|
|
634
|
+
const g = n.options.useScrollendEvent && ye;
|
|
635
|
+
return g && e.addEventListener("scrollend", p, xe), () => {
|
|
636
|
+
e.removeEventListener("scroll", l), g && e.removeEventListener("scrollend", p);
|
|
556
637
|
};
|
|
557
|
-
},
|
|
638
|
+
}, Xe = (n, a, e) => {
|
|
558
639
|
if (a?.borderBoxSize) {
|
|
559
640
|
const s = a.borderBoxSize[0];
|
|
560
641
|
if (s)
|
|
@@ -562,24 +643,24 @@ const Ne = (t, a) => Math.abs(t - a) < 1.01, Ie = (t, a, e) => {
|
|
|
562
643
|
s[e.options.horizontal ? "inlineSize" : "blockSize"]
|
|
563
644
|
);
|
|
564
645
|
}
|
|
565
|
-
return
|
|
566
|
-
},
|
|
646
|
+
return n[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
647
|
+
}, Ze = (n, {
|
|
567
648
|
adjustments: a = 0,
|
|
568
649
|
behavior: e
|
|
569
650
|
}, s) => {
|
|
570
|
-
var
|
|
571
|
-
const o =
|
|
572
|
-
(i = (
|
|
651
|
+
var t, i;
|
|
652
|
+
const o = n + a;
|
|
653
|
+
(i = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || i.call(t, {
|
|
573
654
|
[s.options.horizontal ? "left" : "top"]: o,
|
|
574
655
|
behavior: e
|
|
575
656
|
});
|
|
576
657
|
};
|
|
577
|
-
class
|
|
658
|
+
class Qe {
|
|
578
659
|
constructor(a) {
|
|
579
660
|
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
|
|
580
661
|
let e = null;
|
|
581
|
-
const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((
|
|
582
|
-
|
|
662
|
+
const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
|
|
663
|
+
t.forEach((i) => {
|
|
583
664
|
const o = () => {
|
|
584
665
|
this._measureElement(i.target, i);
|
|
585
666
|
};
|
|
@@ -588,21 +669,21 @@ class Ve {
|
|
|
588
669
|
}));
|
|
589
670
|
return {
|
|
590
671
|
disconnect: () => {
|
|
591
|
-
var
|
|
592
|
-
(
|
|
672
|
+
var t;
|
|
673
|
+
(t = s()) == null || t.disconnect(), e = null;
|
|
593
674
|
},
|
|
594
|
-
observe: (
|
|
675
|
+
observe: (t) => {
|
|
595
676
|
var i;
|
|
596
|
-
return (i = s()) == null ? void 0 : i.observe(
|
|
677
|
+
return (i = s()) == null ? void 0 : i.observe(t, { box: "border-box" });
|
|
597
678
|
},
|
|
598
|
-
unobserve: (
|
|
679
|
+
unobserve: (t) => {
|
|
599
680
|
var i;
|
|
600
|
-
return (i = s()) == null ? void 0 : i.unobserve(
|
|
681
|
+
return (i = s()) == null ? void 0 : i.unobserve(t);
|
|
601
682
|
}
|
|
602
683
|
};
|
|
603
684
|
})(), this.range = null, this.setOptions = (e) => {
|
|
604
|
-
Object.entries(e).forEach(([s,
|
|
605
|
-
typeof
|
|
685
|
+
Object.entries(e).forEach(([s, t]) => {
|
|
686
|
+
typeof t > "u" && delete e[s];
|
|
606
687
|
}), this.options = {
|
|
607
688
|
debug: !1,
|
|
608
689
|
initialOffset: 0,
|
|
@@ -612,11 +693,11 @@ class Ve {
|
|
|
612
693
|
scrollPaddingStart: 0,
|
|
613
694
|
scrollPaddingEnd: 0,
|
|
614
695
|
horizontal: !1,
|
|
615
|
-
getItemKey:
|
|
616
|
-
rangeExtractor:
|
|
696
|
+
getItemKey: Ge,
|
|
697
|
+
rangeExtractor: He,
|
|
617
698
|
onChange: () => {
|
|
618
699
|
},
|
|
619
|
-
measureElement:
|
|
700
|
+
measureElement: Xe,
|
|
620
701
|
initialRect: { width: 0, height: 0 },
|
|
621
702
|
scrollMargin: 0,
|
|
622
703
|
gap: 0,
|
|
@@ -631,9 +712,9 @@ class Ve {
|
|
|
631
712
|
...e
|
|
632
713
|
};
|
|
633
714
|
}, this.notify = (e) => {
|
|
634
|
-
var s,
|
|
635
|
-
(
|
|
636
|
-
}, this.maybeNotify =
|
|
715
|
+
var s, t;
|
|
716
|
+
(t = (s = this.options).onChange) == null || t.call(s, this, e);
|
|
717
|
+
}, this.maybeNotify = H(
|
|
637
718
|
() => (this.calculateRange(), [
|
|
638
719
|
this.isScrolling,
|
|
639
720
|
this.range ? this.range.startIndex : null,
|
|
@@ -663,15 +744,15 @@ class Ve {
|
|
|
663
744
|
this.maybeNotify();
|
|
664
745
|
return;
|
|
665
746
|
}
|
|
666
|
-
this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((
|
|
667
|
-
this.observer.observe(
|
|
747
|
+
this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((t) => {
|
|
748
|
+
this.observer.observe(t);
|
|
668
749
|
}), this.unsubs.push(
|
|
669
|
-
this.options.observeElementRect(this, (
|
|
670
|
-
this.scrollRect =
|
|
750
|
+
this.options.observeElementRect(this, (t) => {
|
|
751
|
+
this.scrollRect = t, this.maybeNotify();
|
|
671
752
|
})
|
|
672
753
|
), this.unsubs.push(
|
|
673
|
-
this.options.observeElementOffset(this, (
|
|
674
|
-
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() <
|
|
754
|
+
this.options.observeElementOffset(this, (t, i) => {
|
|
755
|
+
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = i, this.maybeNotify();
|
|
675
756
|
})
|
|
676
757
|
), this._scrollToOffset(this.getScrollOffset(), {
|
|
677
758
|
adjustments: void 0,
|
|
@@ -679,19 +760,19 @@ class Ve {
|
|
|
679
760
|
});
|
|
680
761
|
}
|
|
681
762
|
}, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, s) => {
|
|
682
|
-
const
|
|
763
|
+
const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
683
764
|
for (let o = s - 1; o >= 0; o--) {
|
|
684
765
|
const l = e[o];
|
|
685
|
-
if (
|
|
766
|
+
if (t.has(l.lane))
|
|
686
767
|
continue;
|
|
687
|
-
const
|
|
768
|
+
const p = i.get(
|
|
688
769
|
l.lane
|
|
689
770
|
);
|
|
690
|
-
if (
|
|
771
|
+
if (p == null || l.end > p.end ? i.set(l.lane, l) : l.end < p.end && t.set(l.lane, !0), t.size === this.options.lanes)
|
|
691
772
|
break;
|
|
692
773
|
}
|
|
693
774
|
return i.size === this.options.lanes ? Array.from(i.values()).sort((o, l) => o.end === l.end ? o.index - l.index : o.end - l.end)[0] : void 0;
|
|
694
|
-
}, this.getMeasurementOptions =
|
|
775
|
+
}, this.getMeasurementOptions = H(
|
|
695
776
|
() => [
|
|
696
777
|
this.options.count,
|
|
697
778
|
this.options.paddingStart,
|
|
@@ -700,10 +781,10 @@ class Ve {
|
|
|
700
781
|
this.options.enabled,
|
|
701
782
|
this.options.lanes
|
|
702
783
|
],
|
|
703
|
-
(e, s,
|
|
784
|
+
(e, s, t, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
|
|
704
785
|
count: e,
|
|
705
786
|
paddingStart: s,
|
|
706
|
-
scrollMargin:
|
|
787
|
+
scrollMargin: t,
|
|
707
788
|
getItemKey: i,
|
|
708
789
|
enabled: o,
|
|
709
790
|
lanes: l
|
|
@@ -711,9 +792,9 @@ class Ve {
|
|
|
711
792
|
{
|
|
712
793
|
key: !1
|
|
713
794
|
}
|
|
714
|
-
), this.getMeasurements =
|
|
795
|
+
), this.getMeasurements = H(
|
|
715
796
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
716
|
-
({ count: e, paddingStart: s, scrollMargin:
|
|
797
|
+
({ count: e, paddingStart: s, scrollMargin: t, getItemKey: i, enabled: o, lanes: l }, p) => {
|
|
717
798
|
if (!o)
|
|
718
799
|
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
719
800
|
if (this.laneAssignments.size > e)
|
|
@@ -722,64 +803,64 @@ class Ve {
|
|
|
722
803
|
this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
|
|
723
804
|
this.itemSizeCache.set(c.key, c.size);
|
|
724
805
|
}));
|
|
725
|
-
const
|
|
806
|
+
const g = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
726
807
|
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
|
|
727
|
-
const
|
|
808
|
+
const m = this.measurementsCache.slice(0, g), E = new Array(l).fill(
|
|
728
809
|
void 0
|
|
729
810
|
);
|
|
730
|
-
for (let c = 0; c <
|
|
731
|
-
const
|
|
732
|
-
|
|
811
|
+
for (let c = 0; c < g; c++) {
|
|
812
|
+
const b = m[c];
|
|
813
|
+
b && (E[b.lane] = c);
|
|
733
814
|
}
|
|
734
|
-
for (let c =
|
|
735
|
-
const
|
|
736
|
-
let
|
|
737
|
-
if (
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
|
|
815
|
+
for (let c = g; c < e; c++) {
|
|
816
|
+
const b = i(c), _ = this.laneAssignments.get(c);
|
|
817
|
+
let v, j;
|
|
818
|
+
if (_ !== void 0 && this.options.lanes > 1) {
|
|
819
|
+
v = _;
|
|
820
|
+
const k = E[v], C = k !== void 0 ? m[k] : void 0;
|
|
821
|
+
j = C ? C.end + this.options.gap : s + t;
|
|
741
822
|
} else {
|
|
742
|
-
const
|
|
743
|
-
|
|
823
|
+
const k = this.options.lanes === 1 ? m[c - 1] : this.getFurthestMeasurement(m, c);
|
|
824
|
+
j = k ? k.end + this.options.gap : s + t, v = k ? k.lane : c % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(c, v);
|
|
744
825
|
}
|
|
745
|
-
const
|
|
746
|
-
|
|
826
|
+
const N = p.get(b), O = typeof N == "number" ? N : this.options.estimateSize(c), D = j + O;
|
|
827
|
+
m[c] = {
|
|
747
828
|
index: c,
|
|
748
|
-
start:
|
|
749
|
-
size:
|
|
750
|
-
end:
|
|
751
|
-
key:
|
|
752
|
-
lane:
|
|
753
|
-
},
|
|
829
|
+
start: j,
|
|
830
|
+
size: O,
|
|
831
|
+
end: D,
|
|
832
|
+
key: b,
|
|
833
|
+
lane: v
|
|
834
|
+
}, E[v] = c;
|
|
754
835
|
}
|
|
755
|
-
return this.measurementsCache =
|
|
836
|
+
return this.measurementsCache = m, m;
|
|
756
837
|
},
|
|
757
838
|
{
|
|
758
839
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
759
840
|
debug: () => this.options.debug
|
|
760
841
|
}
|
|
761
|
-
), this.calculateRange =
|
|
842
|
+
), this.calculateRange = H(
|
|
762
843
|
() => [
|
|
763
844
|
this.getMeasurements(),
|
|
764
845
|
this.getSize(),
|
|
765
846
|
this.getScrollOffset(),
|
|
766
847
|
this.options.lanes
|
|
767
848
|
],
|
|
768
|
-
(e, s,
|
|
849
|
+
(e, s, t, i) => this.range = e.length > 0 && s > 0 ? et({
|
|
769
850
|
measurements: e,
|
|
770
851
|
outerSize: s,
|
|
771
|
-
scrollOffset:
|
|
852
|
+
scrollOffset: t,
|
|
772
853
|
lanes: i
|
|
773
854
|
}) : null,
|
|
774
855
|
{
|
|
775
856
|
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
776
857
|
debug: () => this.options.debug
|
|
777
858
|
}
|
|
778
|
-
), this.getVirtualIndexes =
|
|
859
|
+
), this.getVirtualIndexes = H(
|
|
779
860
|
() => {
|
|
780
861
|
let e = null, s = null;
|
|
781
|
-
const
|
|
782
|
-
return
|
|
862
|
+
const t = this.calculateRange();
|
|
863
|
+
return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
|
|
783
864
|
this.options.rangeExtractor,
|
|
784
865
|
this.options.overscan,
|
|
785
866
|
this.options.count,
|
|
@@ -787,53 +868,53 @@ class Ve {
|
|
|
787
868
|
s
|
|
788
869
|
];
|
|
789
870
|
},
|
|
790
|
-
(e, s,
|
|
871
|
+
(e, s, t, i, o) => i === null || o === null ? [] : e({
|
|
791
872
|
startIndex: i,
|
|
792
873
|
endIndex: o,
|
|
793
874
|
overscan: s,
|
|
794
|
-
count:
|
|
875
|
+
count: t
|
|
795
876
|
}),
|
|
796
877
|
{
|
|
797
878
|
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
798
879
|
debug: () => this.options.debug
|
|
799
880
|
}
|
|
800
881
|
), this.indexFromElement = (e) => {
|
|
801
|
-
const s = this.options.indexAttribute,
|
|
802
|
-
return
|
|
882
|
+
const s = this.options.indexAttribute, t = e.getAttribute(s);
|
|
883
|
+
return t ? parseInt(t, 10) : (console.warn(
|
|
803
884
|
`Missing attribute name '${s}={index}' on measured element.`
|
|
804
885
|
), -1);
|
|
805
886
|
}, this._measureElement = (e, s) => {
|
|
806
|
-
const
|
|
887
|
+
const t = this.indexFromElement(e), i = this.measurementsCache[t];
|
|
807
888
|
if (!i)
|
|
808
889
|
return;
|
|
809
890
|
const o = i.key, l = this.elementsCache.get(o);
|
|
810
|
-
l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(
|
|
891
|
+
l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
|
|
811
892
|
}, this.resizeItem = (e, s) => {
|
|
812
|
-
const
|
|
813
|
-
if (!
|
|
893
|
+
const t = this.measurementsCache[e];
|
|
894
|
+
if (!t)
|
|
814
895
|
return;
|
|
815
|
-
const i = this.itemSizeCache.get(
|
|
816
|
-
o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(
|
|
896
|
+
const i = this.itemSizeCache.get(t.key) ?? t.size, o = s - i;
|
|
897
|
+
o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, o, this) : t.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
|
|
817
898
|
adjustments: this.scrollAdjustments += o,
|
|
818
899
|
behavior: void 0
|
|
819
|
-
})), this.pendingMeasuredCacheIndexes.push(
|
|
900
|
+
})), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
|
|
820
901
|
}, this.measureElement = (e) => {
|
|
821
902
|
if (!e) {
|
|
822
|
-
this.elementsCache.forEach((s,
|
|
823
|
-
s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(
|
|
903
|
+
this.elementsCache.forEach((s, t) => {
|
|
904
|
+
s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
|
|
824
905
|
});
|
|
825
906
|
return;
|
|
826
907
|
}
|
|
827
908
|
this._measureElement(e, void 0);
|
|
828
|
-
}, this.getVirtualItems =
|
|
909
|
+
}, this.getVirtualItems = H(
|
|
829
910
|
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
830
911
|
(e, s) => {
|
|
831
|
-
const
|
|
912
|
+
const t = [];
|
|
832
913
|
for (let i = 0, o = e.length; i < o; i++) {
|
|
833
|
-
const l = e[i],
|
|
834
|
-
|
|
914
|
+
const l = e[i], p = s[l];
|
|
915
|
+
t.push(p);
|
|
835
916
|
}
|
|
836
|
-
return
|
|
917
|
+
return t;
|
|
837
918
|
},
|
|
838
919
|
{
|
|
839
920
|
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
@@ -842,11 +923,11 @@ class Ve {
|
|
|
842
923
|
), this.getVirtualItemForOffset = (e) => {
|
|
843
924
|
const s = this.getMeasurements();
|
|
844
925
|
if (s.length !== 0)
|
|
845
|
-
return
|
|
846
|
-
s[
|
|
926
|
+
return be(
|
|
927
|
+
s[je(
|
|
847
928
|
0,
|
|
848
929
|
s.length - 1,
|
|
849
|
-
(
|
|
930
|
+
(t) => be(s[t]).start,
|
|
850
931
|
e
|
|
851
932
|
)]
|
|
852
933
|
);
|
|
@@ -858,66 +939,66 @@ class Ve {
|
|
|
858
939
|
const e = this.scrollElement.document.documentElement;
|
|
859
940
|
return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
|
|
860
941
|
}
|
|
861
|
-
}, this.getOffsetForAlignment = (e, s,
|
|
942
|
+
}, this.getOffsetForAlignment = (e, s, t = 0) => {
|
|
862
943
|
if (!this.scrollElement) return 0;
|
|
863
944
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
864
|
-
s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (
|
|
945
|
+
s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (t - i) / 2 : s === "end" && (e -= i);
|
|
865
946
|
const l = this.getMaxScrollOffset();
|
|
866
947
|
return Math.max(Math.min(l, e), 0);
|
|
867
948
|
}, this.getOffsetForIndex = (e, s = "auto") => {
|
|
868
949
|
e = Math.max(0, Math.min(e, this.options.count - 1));
|
|
869
|
-
const
|
|
870
|
-
if (!
|
|
950
|
+
const t = this.measurementsCache[e];
|
|
951
|
+
if (!t)
|
|
871
952
|
return;
|
|
872
953
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
873
954
|
if (s === "auto")
|
|
874
|
-
if (
|
|
955
|
+
if (t.end >= o + i - this.options.scrollPaddingEnd)
|
|
875
956
|
s = "end";
|
|
876
|
-
else if (
|
|
957
|
+
else if (t.start <= o + this.options.scrollPaddingStart)
|
|
877
958
|
s = "start";
|
|
878
959
|
else
|
|
879
960
|
return [o, s];
|
|
880
961
|
if (s === "end" && e === this.options.count - 1)
|
|
881
962
|
return [this.getMaxScrollOffset(), s];
|
|
882
|
-
const l = s === "end" ?
|
|
963
|
+
const l = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
|
|
883
964
|
return [
|
|
884
|
-
this.getOffsetForAlignment(l, s,
|
|
965
|
+
this.getOffsetForAlignment(l, s, t.size),
|
|
885
966
|
s
|
|
886
967
|
];
|
|
887
|
-
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior:
|
|
888
|
-
|
|
968
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
|
|
969
|
+
t === "smooth" && this.isDynamicMode() && console.warn(
|
|
889
970
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
890
971
|
), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
|
|
891
972
|
adjustments: void 0,
|
|
892
|
-
behavior:
|
|
973
|
+
behavior: t
|
|
893
974
|
});
|
|
894
|
-
}, this.scrollToIndex = (e, { align: s = "auto", behavior:
|
|
895
|
-
|
|
975
|
+
}, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
|
|
976
|
+
t === "smooth" && this.isDynamicMode() && console.warn(
|
|
896
977
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
897
978
|
), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
|
|
898
979
|
let i = 0;
|
|
899
|
-
const o = 10, l = (
|
|
980
|
+
const o = 10, l = (g) => {
|
|
900
981
|
if (!this.targetWindow) return;
|
|
901
|
-
const
|
|
902
|
-
if (!
|
|
982
|
+
const m = this.getOffsetForIndex(e, g);
|
|
983
|
+
if (!m) {
|
|
903
984
|
console.warn("Failed to get offset for index:", e);
|
|
904
985
|
return;
|
|
905
986
|
}
|
|
906
|
-
const [
|
|
907
|
-
this._scrollToOffset(
|
|
908
|
-
const
|
|
987
|
+
const [E, c] = m;
|
|
988
|
+
this._scrollToOffset(E, { adjustments: void 0, behavior: t }), this.targetWindow.requestAnimationFrame(() => {
|
|
989
|
+
const b = () => {
|
|
909
990
|
if (this.currentScrollToIndex !== e) return;
|
|
910
|
-
const
|
|
911
|
-
if (!
|
|
991
|
+
const _ = this.getScrollOffset(), v = this.getOffsetForIndex(e, c);
|
|
992
|
+
if (!v) {
|
|
912
993
|
console.warn("Failed to get offset for index:", e);
|
|
913
994
|
return;
|
|
914
995
|
}
|
|
915
|
-
|
|
996
|
+
qe(v[0], _) || p(c);
|
|
916
997
|
};
|
|
917
|
-
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(
|
|
998
|
+
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(b) : b();
|
|
918
999
|
});
|
|
919
|
-
},
|
|
920
|
-
this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => l(
|
|
1000
|
+
}, p = (g) => {
|
|
1001
|
+
this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => l(g))) : console.warn(
|
|
921
1002
|
`Failed to scroll to index ${e} after ${o} attempts.`
|
|
922
1003
|
));
|
|
923
1004
|
};
|
|
@@ -932,11 +1013,11 @@ class Ve {
|
|
|
932
1013
|
}, this.getTotalSize = () => {
|
|
933
1014
|
var e;
|
|
934
1015
|
const s = this.getMeasurements();
|
|
935
|
-
let
|
|
1016
|
+
let t;
|
|
936
1017
|
if (s.length === 0)
|
|
937
|
-
|
|
1018
|
+
t = this.options.paddingStart;
|
|
938
1019
|
else if (this.options.lanes === 1)
|
|
939
|
-
|
|
1020
|
+
t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
|
|
940
1021
|
else {
|
|
941
1022
|
const i = Array(this.options.lanes).fill(null);
|
|
942
1023
|
let o = s.length - 1;
|
|
@@ -944,152 +1025,152 @@ class Ve {
|
|
|
944
1025
|
const l = s[o];
|
|
945
1026
|
i[l.lane] === null && (i[l.lane] = l.end), o--;
|
|
946
1027
|
}
|
|
947
|
-
|
|
1028
|
+
t = Math.max(...i.filter((l) => l !== null));
|
|
948
1029
|
}
|
|
949
1030
|
return Math.max(
|
|
950
|
-
|
|
1031
|
+
t - this.options.scrollMargin + this.options.paddingEnd,
|
|
951
1032
|
0
|
|
952
1033
|
);
|
|
953
1034
|
}, this._scrollToOffset = (e, {
|
|
954
1035
|
adjustments: s,
|
|
955
|
-
behavior:
|
|
1036
|
+
behavior: t
|
|
956
1037
|
}) => {
|
|
957
|
-
this.options.scrollToFn(e, { behavior:
|
|
1038
|
+
this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
|
|
958
1039
|
}, this.measure = () => {
|
|
959
1040
|
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
960
1041
|
}, this.setOptions(a);
|
|
961
1042
|
}
|
|
962
1043
|
}
|
|
963
|
-
const
|
|
964
|
-
for (;
|
|
965
|
-
const
|
|
1044
|
+
const je = (n, a, e, s) => {
|
|
1045
|
+
for (; n <= a; ) {
|
|
1046
|
+
const t = (n + a) / 2 | 0, i = e(t);
|
|
966
1047
|
if (i < s)
|
|
967
|
-
|
|
1048
|
+
n = t + 1;
|
|
968
1049
|
else if (i > s)
|
|
969
|
-
a =
|
|
1050
|
+
a = t - 1;
|
|
970
1051
|
else
|
|
971
|
-
return
|
|
1052
|
+
return t;
|
|
972
1053
|
}
|
|
973
|
-
return
|
|
1054
|
+
return n > 0 ? n - 1 : 0;
|
|
974
1055
|
};
|
|
975
|
-
function
|
|
976
|
-
measurements:
|
|
1056
|
+
function et({
|
|
1057
|
+
measurements: n,
|
|
977
1058
|
outerSize: a,
|
|
978
1059
|
scrollOffset: e,
|
|
979
1060
|
lanes: s
|
|
980
1061
|
}) {
|
|
981
|
-
const
|
|
982
|
-
if (
|
|
1062
|
+
const t = n.length - 1, i = (p) => n[p].start;
|
|
1063
|
+
if (n.length <= s)
|
|
983
1064
|
return {
|
|
984
1065
|
startIndex: 0,
|
|
985
|
-
endIndex:
|
|
1066
|
+
endIndex: t
|
|
986
1067
|
};
|
|
987
|
-
let o =
|
|
1068
|
+
let o = je(
|
|
988
1069
|
0,
|
|
989
|
-
|
|
1070
|
+
t,
|
|
990
1071
|
i,
|
|
991
1072
|
e
|
|
992
1073
|
), l = o;
|
|
993
1074
|
if (s === 1)
|
|
994
|
-
for (; l <
|
|
1075
|
+
for (; l < t && n[l].end < e + a; )
|
|
995
1076
|
l++;
|
|
996
1077
|
else if (s > 1) {
|
|
997
|
-
const
|
|
998
|
-
for (; l <
|
|
999
|
-
const
|
|
1000
|
-
|
|
1078
|
+
const p = Array(s).fill(0);
|
|
1079
|
+
for (; l < t && p.some((m) => m < e + a); ) {
|
|
1080
|
+
const m = n[l];
|
|
1081
|
+
p[m.lane] = m.end, l++;
|
|
1001
1082
|
}
|
|
1002
|
-
const
|
|
1003
|
-
for (; o >= 0 &&
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1083
|
+
const g = Array(s).fill(e + a);
|
|
1084
|
+
for (; o >= 0 && g.some((m) => m >= e); ) {
|
|
1085
|
+
const m = n[o];
|
|
1086
|
+
g[m.lane] = m.start, o--;
|
|
1006
1087
|
}
|
|
1007
|
-
o = Math.max(0, o - o % s), l = Math.min(
|
|
1088
|
+
o = Math.max(0, o - o % s), l = Math.min(t, l + (s - 1 - l % s));
|
|
1008
1089
|
}
|
|
1009
1090
|
return { startIndex: o, endIndex: l };
|
|
1010
1091
|
}
|
|
1011
|
-
const
|
|
1012
|
-
function
|
|
1013
|
-
useFlushSync:
|
|
1092
|
+
const Ee = typeof document < "u" ? le.useLayoutEffect : le.useEffect;
|
|
1093
|
+
function tt({
|
|
1094
|
+
useFlushSync: n = !0,
|
|
1014
1095
|
...a
|
|
1015
1096
|
}) {
|
|
1016
|
-
const e =
|
|
1097
|
+
const e = le.useReducer(() => ({}), {})[1], s = {
|
|
1017
1098
|
...a,
|
|
1018
1099
|
onChange: (i, o) => {
|
|
1019
1100
|
var l;
|
|
1020
|
-
|
|
1101
|
+
n && o ? $e(e) : e(), (l = a.onChange) == null || l.call(a, i, o);
|
|
1021
1102
|
}
|
|
1022
|
-
}, [
|
|
1023
|
-
() => new
|
|
1103
|
+
}, [t] = le.useState(
|
|
1104
|
+
() => new Qe(s)
|
|
1024
1105
|
);
|
|
1025
|
-
return
|
|
1106
|
+
return t.setOptions(s), Ee(() => t._didMount(), []), Ee(() => t._willUpdate()), t;
|
|
1026
1107
|
}
|
|
1027
|
-
function
|
|
1028
|
-
return
|
|
1029
|
-
observeElementRect:
|
|
1030
|
-
observeElementOffset:
|
|
1031
|
-
scrollToFn:
|
|
1032
|
-
...
|
|
1108
|
+
function nt(n) {
|
|
1109
|
+
return tt({
|
|
1110
|
+
observeElementRect: Je,
|
|
1111
|
+
observeElementOffset: Ke,
|
|
1112
|
+
scrollToFn: Ze,
|
|
1113
|
+
...n
|
|
1033
1114
|
});
|
|
1034
1115
|
}
|
|
1035
|
-
const
|
|
1036
|
-
data:
|
|
1116
|
+
const ut = ({
|
|
1117
|
+
data: n,
|
|
1037
1118
|
columns: a,
|
|
1038
1119
|
rowHeight: e = 40,
|
|
1039
1120
|
height: s = 600,
|
|
1040
|
-
className:
|
|
1121
|
+
className: t = "",
|
|
1041
1122
|
headerClassName: i = "",
|
|
1042
1123
|
rowClassName: o,
|
|
1043
1124
|
onRowClick: l,
|
|
1044
|
-
overscan:
|
|
1125
|
+
overscan: p = 5
|
|
1045
1126
|
}) => {
|
|
1046
|
-
const
|
|
1047
|
-
count:
|
|
1048
|
-
getScrollElement: () =>
|
|
1127
|
+
const g = _e(null), m = nt({
|
|
1128
|
+
count: n.length,
|
|
1129
|
+
getScrollElement: () => g.current,
|
|
1049
1130
|
estimateSize: () => e,
|
|
1050
|
-
overscan:
|
|
1051
|
-
}),
|
|
1052
|
-
return /* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */
|
|
1131
|
+
overscan: p
|
|
1132
|
+
}), E = m.getVirtualItems();
|
|
1133
|
+
return /* @__PURE__ */ u.jsxs("div", { className: t, children: [
|
|
1134
|
+
/* @__PURE__ */ u.jsx(
|
|
1054
1135
|
"div",
|
|
1055
1136
|
{
|
|
1056
1137
|
className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
|
|
1057
1138
|
style: {
|
|
1058
1139
|
gridTemplateColumns: a.map((c) => c.width || "1fr").join(" ")
|
|
1059
1140
|
},
|
|
1060
|
-
children: a.map((c,
|
|
1141
|
+
children: a.map((c, b) => /* @__PURE__ */ u.jsx(
|
|
1061
1142
|
"div",
|
|
1062
1143
|
{
|
|
1063
1144
|
className: `px-4 py-2 font-semibold text-sm ${c.align === "center" ? "text-center" : c.align === "right" ? "text-right" : "text-left"}`,
|
|
1064
1145
|
children: c.header
|
|
1065
1146
|
},
|
|
1066
|
-
|
|
1147
|
+
b
|
|
1067
1148
|
))
|
|
1068
1149
|
}
|
|
1069
1150
|
),
|
|
1070
|
-
/* @__PURE__ */
|
|
1151
|
+
/* @__PURE__ */ u.jsx(
|
|
1071
1152
|
"div",
|
|
1072
1153
|
{
|
|
1073
|
-
ref:
|
|
1154
|
+
ref: g,
|
|
1074
1155
|
className: "overflow-auto",
|
|
1075
1156
|
style: {
|
|
1076
1157
|
height: typeof s == "number" ? `${s}px` : s,
|
|
1077
1158
|
contain: "strict"
|
|
1078
1159
|
},
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1160
|
+
children: /* @__PURE__ */ u.jsx(
|
|
1080
1161
|
"div",
|
|
1081
1162
|
{
|
|
1082
1163
|
style: {
|
|
1083
|
-
height: `${
|
|
1164
|
+
height: `${m.getTotalSize()}px`,
|
|
1084
1165
|
width: "100%",
|
|
1085
1166
|
position: "relative"
|
|
1086
1167
|
},
|
|
1087
|
-
children:
|
|
1088
|
-
const
|
|
1089
|
-
return /* @__PURE__ */
|
|
1168
|
+
children: E.map((c) => {
|
|
1169
|
+
const b = n[c.index], _ = typeof o == "function" ? o(b, c.index) : o || "";
|
|
1170
|
+
return /* @__PURE__ */ u.jsx(
|
|
1090
1171
|
"div",
|
|
1091
1172
|
{
|
|
1092
|
-
className: `grid border-b hover:bg-muted/50 cursor-pointer ${
|
|
1173
|
+
className: `grid border-b hover:bg-muted/50 cursor-pointer ${_}`,
|
|
1093
1174
|
style: {
|
|
1094
1175
|
position: "absolute",
|
|
1095
1176
|
top: 0,
|
|
@@ -1097,18 +1178,18 @@ const Qe = ({
|
|
|
1097
1178
|
width: "100%",
|
|
1098
1179
|
height: `${c.size}px`,
|
|
1099
1180
|
transform: `translateY(${c.start}px)`,
|
|
1100
|
-
gridTemplateColumns: a.map((
|
|
1181
|
+
gridTemplateColumns: a.map((v) => v.width || "1fr").join(" ")
|
|
1101
1182
|
},
|
|
1102
|
-
onClick: () => l?.(
|
|
1103
|
-
children: a.map((
|
|
1104
|
-
const
|
|
1105
|
-
return /* @__PURE__ */
|
|
1183
|
+
onClick: () => l?.(b, c.index),
|
|
1184
|
+
children: a.map((v, j) => {
|
|
1185
|
+
const N = b[v.accessorKey], O = v.cell ? v.cell(N, b) : N;
|
|
1186
|
+
return /* @__PURE__ */ u.jsx(
|
|
1106
1187
|
"div",
|
|
1107
1188
|
{
|
|
1108
|
-
className: `px-4 py-2 text-sm flex items-center ${
|
|
1109
|
-
children:
|
|
1189
|
+
className: `px-4 py-2 text-sm flex items-center ${v.align === "center" ? "text-center justify-center" : v.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
|
|
1190
|
+
children: O
|
|
1110
1191
|
},
|
|
1111
|
-
|
|
1192
|
+
j
|
|
1112
1193
|
);
|
|
1113
1194
|
})
|
|
1114
1195
|
},
|
|
@@ -1119,30 +1200,40 @@ const Qe = ({
|
|
|
1119
1200
|
)
|
|
1120
1201
|
}
|
|
1121
1202
|
),
|
|
1122
|
-
/* @__PURE__ */
|
|
1203
|
+
/* @__PURE__ */ u.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
|
|
1123
1204
|
"Showing ",
|
|
1124
|
-
|
|
1205
|
+
E.length,
|
|
1125
1206
|
" of ",
|
|
1126
|
-
|
|
1207
|
+
n.length,
|
|
1127
1208
|
" rows (virtual scrolling enabled)"
|
|
1128
1209
|
] })
|
|
1129
1210
|
] });
|
|
1130
|
-
},
|
|
1131
|
-
const { dataSource: e } =
|
|
1132
|
-
return /* @__PURE__ */
|
|
1211
|
+
}, Oe = ({ schema: n, ...a }) => {
|
|
1212
|
+
const { dataSource: e } = Ne() || {};
|
|
1213
|
+
return /* @__PURE__ */ u.jsx(Ue, { schema: n, dataSource: e, ...a });
|
|
1133
1214
|
};
|
|
1134
|
-
|
|
1215
|
+
we.register("object-grid", Oe, {
|
|
1135
1216
|
namespace: "plugin-grid",
|
|
1136
1217
|
label: "Object Grid",
|
|
1137
|
-
category: "plugin"
|
|
1218
|
+
category: "plugin",
|
|
1219
|
+
inputs: [
|
|
1220
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1221
|
+
{ name: "columns", type: "array", label: "Columns" },
|
|
1222
|
+
{ name: "filters", type: "array", label: "Filters" }
|
|
1223
|
+
]
|
|
1138
1224
|
});
|
|
1139
|
-
|
|
1225
|
+
we.register("grid", Oe, {
|
|
1140
1226
|
namespace: "view",
|
|
1141
1227
|
label: "Data Grid",
|
|
1142
|
-
category: "view"
|
|
1228
|
+
category: "view",
|
|
1229
|
+
inputs: [
|
|
1230
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1231
|
+
{ name: "columns", type: "array", label: "Columns" },
|
|
1232
|
+
{ name: "filters", type: "array", label: "Filters" }
|
|
1233
|
+
]
|
|
1143
1234
|
});
|
|
1144
1235
|
export {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1236
|
+
Ue as ObjectGrid,
|
|
1237
|
+
Oe as ObjectGridRenderer,
|
|
1238
|
+
ut as VirtualGrid
|
|
1148
1239
|
};
|