@object-ui/plugin-grid 0.3.1 → 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 +30 -0
- package/CHANGELOG.md +15 -0
- package/README.md +97 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1117 -303
- package/dist/index.umd.cjs +5 -2
- 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/{plugin-grid → packages/plugin-grid}/src/ObjectGrid.d.ts +7 -1
- package/dist/packages/plugin-grid/src/ObjectGrid.msw.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/VirtualGrid.d.ts +35 -0
- package/dist/packages/plugin-grid/src/VirtualGrid.test.d.ts +8 -0
- package/dist/packages/plugin-grid/src/__tests__/VirtualGrid.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/index.d.ts +10 -0
- package/dist/packages/plugin-grid/src/index.test.d.ts +1 -0
- package/package.json +11 -8
- package/src/ListColumnExtensions.test.tsx +374 -0
- package/src/ListColumnSchema.test.ts +88 -0
- package/src/ObjectGrid.msw.test.tsx +130 -0
- package/src/ObjectGrid.tsx +341 -117
- package/src/VirtualGrid.test.tsx +23 -0
- package/src/VirtualGrid.tsx +183 -0
- package/src/__tests__/VirtualGrid.test.tsx +438 -0
- package/src/index.test.tsx +29 -0
- package/src/index.tsx +33 -5
- package/vite.config.ts +18 -0
- package/vitest.config.ts +13 -0
- package/vitest.setup.ts +1 -0
- package/dist/plugin-grid/src/index.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,425 +1,1239 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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";
|
|
4
5
|
import { getCellRenderer as ue } from "@object-ui/fields";
|
|
5
|
-
import { DropdownMenu as
|
|
6
|
-
import { MoreVertical as
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
var o = null;
|
|
17
|
+
if (i !== void 0 && (o = "" + i), t.key !== void 0 && (o = "" + t.key), "key" in t) {
|
|
18
|
+
i = {};
|
|
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
|
+
type: s,
|
|
25
|
+
key: o,
|
|
26
|
+
ref: t !== void 0 ? t : null,
|
|
27
|
+
props: i
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
return
|
|
30
|
+
return te.Fragment = a, te.jsx = e, te.jsxs = e, te;
|
|
29
31
|
}
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
function r
|
|
35
|
-
if (
|
|
36
|
-
if (typeof
|
|
37
|
-
return
|
|
38
|
-
if (typeof
|
|
39
|
-
switch (
|
|
40
|
-
case
|
|
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
|
+
if (r == null) return null;
|
|
38
|
+
if (typeof r == "function")
|
|
39
|
+
return r.$$typeof === V ? null : r.displayName || r.name || null;
|
|
40
|
+
if (typeof r == "string") return r;
|
|
41
|
+
switch (r) {
|
|
42
|
+
case j:
|
|
41
43
|
return "Fragment";
|
|
42
|
-
case
|
|
44
|
+
case O:
|
|
43
45
|
return "Profiler";
|
|
44
|
-
case
|
|
46
|
+
case N:
|
|
45
47
|
return "StrictMode";
|
|
46
|
-
case
|
|
48
|
+
case L:
|
|
47
49
|
return "Suspense";
|
|
48
|
-
case
|
|
50
|
+
case F:
|
|
49
51
|
return "SuspenseList";
|
|
50
|
-
case
|
|
52
|
+
case U:
|
|
51
53
|
return "Activity";
|
|
52
54
|
}
|
|
53
|
-
if (typeof
|
|
54
|
-
switch (typeof
|
|
55
|
+
if (typeof r == "object")
|
|
56
|
+
switch (typeof r.tag == "number" && console.error(
|
|
55
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
56
|
-
),
|
|
57
|
-
case
|
|
58
|
+
), r.$$typeof) {
|
|
59
|
+
case v:
|
|
58
60
|
return "Portal";
|
|
59
|
-
case
|
|
60
|
-
return
|
|
61
|
+
case k:
|
|
62
|
+
return r.displayName || "Context";
|
|
61
63
|
case D:
|
|
62
|
-
return (
|
|
63
|
-
case
|
|
64
|
-
var
|
|
65
|
-
return
|
|
66
|
-
case
|
|
67
|
-
return
|
|
68
|
-
case
|
|
69
|
-
|
|
64
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
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;
|
|
70
72
|
try {
|
|
71
|
-
return r(
|
|
73
|
+
return n(r(h));
|
|
72
74
|
} catch {
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
return null;
|
|
76
78
|
}
|
|
77
|
-
function
|
|
78
|
-
return "" +
|
|
79
|
+
function a(r) {
|
|
80
|
+
return "" + r;
|
|
79
81
|
}
|
|
80
|
-
function
|
|
82
|
+
function e(r) {
|
|
81
83
|
try {
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
+
a(r);
|
|
85
|
+
var h = !1;
|
|
84
86
|
} catch {
|
|
85
|
-
|
|
87
|
+
h = !0;
|
|
86
88
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
return
|
|
91
|
-
|
|
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
|
+
return x.call(
|
|
93
|
+
h,
|
|
92
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
93
|
-
|
|
94
|
-
),
|
|
95
|
+
S
|
|
96
|
+
), a(r);
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
|
-
function
|
|
98
|
-
if (
|
|
99
|
-
if (typeof
|
|
99
|
+
function s(r) {
|
|
100
|
+
if (r === j) return "<>";
|
|
101
|
+
if (typeof r == "object" && r !== null && r.$$typeof === z)
|
|
100
102
|
return "<...>";
|
|
101
103
|
try {
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
+
var h = n(r);
|
|
105
|
+
return h ? "<" + h + ">" : "<...>";
|
|
104
106
|
} catch {
|
|
105
107
|
return "<...>";
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
return
|
|
110
|
+
function t() {
|
|
111
|
+
var r = q.A;
|
|
112
|
+
return r === null ? null : r.getOwner();
|
|
111
113
|
}
|
|
112
|
-
function
|
|
114
|
+
function i() {
|
|
113
115
|
return Error("react-stack-top-frame");
|
|
114
116
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
var
|
|
118
|
-
if (
|
|
117
|
+
function o(r) {
|
|
118
|
+
if (J.call(r, "key")) {
|
|
119
|
+
var h = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
|
+
if (h && h.isReactWarning) return !1;
|
|
119
121
|
}
|
|
120
|
-
return
|
|
122
|
+
return r.key !== void 0;
|
|
121
123
|
}
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
|
|
124
|
+
function l(r, h) {
|
|
125
|
+
function x() {
|
|
126
|
+
se || (se = !0, console.error(
|
|
125
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)",
|
|
126
|
-
|
|
128
|
+
h
|
|
127
129
|
));
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
get:
|
|
131
|
+
x.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
132
|
+
get: x,
|
|
131
133
|
configurable: !0
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
|
-
function
|
|
135
|
-
var
|
|
136
|
-
return
|
|
136
|
+
function p() {
|
|
137
|
+
var r = n(this.type);
|
|
138
|
+
return K[r] || (K[r] = !0, console.error(
|
|
137
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."
|
|
138
|
-
)),
|
|
140
|
+
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
139
141
|
}
|
|
140
|
-
function
|
|
141
|
-
var
|
|
142
|
-
return
|
|
143
|
-
$$typeof:
|
|
144
|
-
type:
|
|
145
|
-
key:
|
|
146
|
-
props:
|
|
147
|
-
_owner:
|
|
148
|
-
}, (
|
|
142
|
+
function g(r, h, x, S, Y, G) {
|
|
143
|
+
var f = x.ref;
|
|
144
|
+
return r = {
|
|
145
|
+
$$typeof: _,
|
|
146
|
+
type: r,
|
|
147
|
+
key: h,
|
|
148
|
+
props: x,
|
|
149
|
+
_owner: S
|
|
150
|
+
}, (f !== void 0 ? f : null) !== null ? Object.defineProperty(r, "ref", {
|
|
149
151
|
enumerable: !1,
|
|
150
|
-
get:
|
|
151
|
-
}) : Object.defineProperty(
|
|
152
|
+
get: p
|
|
153
|
+
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
152
154
|
configurable: !1,
|
|
153
155
|
enumerable: !1,
|
|
154
156
|
writable: !0,
|
|
155
157
|
value: 0
|
|
156
|
-
}), Object.defineProperty(
|
|
158
|
+
}), Object.defineProperty(r, "_debugInfo", {
|
|
157
159
|
configurable: !1,
|
|
158
160
|
enumerable: !1,
|
|
159
161
|
writable: !0,
|
|
160
162
|
value: null
|
|
161
|
-
}), Object.defineProperty(
|
|
163
|
+
}), Object.defineProperty(r, "_debugStack", {
|
|
162
164
|
configurable: !1,
|
|
163
165
|
enumerable: !1,
|
|
164
166
|
writable: !0,
|
|
165
167
|
value: Y
|
|
166
|
-
}), Object.defineProperty(
|
|
168
|
+
}), Object.defineProperty(r, "_debugTask", {
|
|
167
169
|
configurable: !1,
|
|
168
170
|
enumerable: !1,
|
|
169
171
|
writable: !0,
|
|
170
|
-
value:
|
|
171
|
-
}), Object.freeze && (Object.freeze(
|
|
172
|
+
value: G
|
|
173
|
+
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
172
174
|
}
|
|
173
|
-
function
|
|
174
|
-
var
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
177
|
-
if (
|
|
178
|
-
for (
|
|
179
|
-
|
|
180
|
-
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);
|
|
181
183
|
} else
|
|
182
184
|
console.error(
|
|
183
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."
|
|
184
186
|
);
|
|
185
|
-
else
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
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";
|
|
190
192
|
});
|
|
191
|
-
|
|
193
|
+
S = 0 < y.length ? "{key: someKey, " + y.join(": ..., ") + ": ...}" : "{key: someKey}", re[f + S] || (y = 0 < y.length ? "{" + y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
192
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
193
195
|
let props = %s;
|
|
194
196
|
<%s {...props} />
|
|
195
197
|
React keys must be passed directly to JSX without using spread:
|
|
196
198
|
let props = %s;
|
|
197
199
|
<%s key={someKey} {...props} />`,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
),
|
|
200
|
+
S,
|
|
201
|
+
f,
|
|
202
|
+
y,
|
|
203
|
+
f
|
|
204
|
+
), re[f + S] = !0);
|
|
203
205
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
for (var
|
|
207
|
-
|
|
208
|
-
} else
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
typeof
|
|
212
|
-
),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
if (f = null, x !== void 0 && (e(x), f = "" + x), o(h) && (e(h.key), f = "" + h.key), "key" in h) {
|
|
207
|
+
x = {};
|
|
208
|
+
for (var A in h)
|
|
209
|
+
A !== "key" && (x[A] = h[A]);
|
|
210
|
+
} else x = h;
|
|
211
|
+
return f && l(
|
|
212
|
+
x,
|
|
213
|
+
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
214
|
+
), g(
|
|
215
|
+
r,
|
|
216
|
+
f,
|
|
217
|
+
x,
|
|
218
|
+
t(),
|
|
217
219
|
Y,
|
|
218
|
-
|
|
220
|
+
G
|
|
219
221
|
);
|
|
220
222
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
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));
|
|
223
225
|
}
|
|
224
|
-
function
|
|
225
|
-
return typeof
|
|
226
|
+
function c(r) {
|
|
227
|
+
return typeof r == "object" && r !== null && r.$$typeof === _;
|
|
226
228
|
}
|
|
227
|
-
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() {
|
|
228
230
|
return null;
|
|
229
231
|
};
|
|
230
|
-
|
|
231
|
-
react_stack_bottom_frame: function(
|
|
232
|
-
return
|
|
232
|
+
b = {
|
|
233
|
+
react_stack_bottom_frame: function(r) {
|
|
234
|
+
return r();
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
)(),
|
|
239
|
-
|
|
240
|
-
var
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
var se, K = {}, W = b.react_stack_bottom_frame.bind(
|
|
238
|
+
b,
|
|
239
|
+
i
|
|
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
|
+
r,
|
|
245
|
+
h,
|
|
246
|
+
x,
|
|
245
247
|
!1,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
S ? Error("react-stack-top-frame") : W,
|
|
249
|
+
S ? B(s(r)) : X
|
|
248
250
|
);
|
|
249
|
-
},
|
|
250
|
-
var
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
}, ne.jsxs = function(r, h, x) {
|
|
252
|
+
var S = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return m(
|
|
254
|
+
r,
|
|
255
|
+
h,
|
|
256
|
+
x,
|
|
255
257
|
!0,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
S ? Error("react-stack-top-frame") : W,
|
|
259
|
+
S ? B(s(r)) : X
|
|
258
260
|
);
|
|
259
261
|
};
|
|
260
|
-
})()),
|
|
262
|
+
})()), ne;
|
|
261
263
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
264
|
-
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;
|
|
265
267
|
}
|
|
266
|
-
var
|
|
267
|
-
function
|
|
268
|
-
return
|
|
268
|
+
var u = Ve();
|
|
269
|
+
function Ye(n) {
|
|
270
|
+
return n.data ? Array.isArray(n.data) ? {
|
|
271
|
+
provider: "value",
|
|
272
|
+
items: n.data
|
|
273
|
+
} : n.data : n.staticData ? {
|
|
269
274
|
provider: "value",
|
|
270
|
-
items:
|
|
271
|
-
} :
|
|
275
|
+
items: n.staticData
|
|
276
|
+
} : n.objectName ? {
|
|
272
277
|
provider: "object",
|
|
273
|
-
object:
|
|
278
|
+
object: n.objectName
|
|
274
279
|
} : null;
|
|
275
280
|
}
|
|
276
|
-
function
|
|
277
|
-
if (!(!
|
|
278
|
-
return typeof
|
|
281
|
+
function ge(n) {
|
|
282
|
+
if (!(!n || n.length === 0))
|
|
283
|
+
return typeof n[0] == "object" && n[0] !== null, n;
|
|
279
284
|
}
|
|
280
|
-
const
|
|
281
|
-
schema:
|
|
282
|
-
dataSource:
|
|
283
|
-
onEdit:
|
|
284
|
-
onDelete:
|
|
285
|
-
onRowSelect:
|
|
285
|
+
const Ue = ({
|
|
286
|
+
schema: n,
|
|
287
|
+
dataSource: a,
|
|
288
|
+
onEdit: e,
|
|
289
|
+
onDelete: s,
|
|
290
|
+
onRowSelect: t,
|
|
291
|
+
onRowClick: i,
|
|
292
|
+
onCellChange: o,
|
|
293
|
+
onRowSave: l,
|
|
294
|
+
onBatchSave: p,
|
|
295
|
+
...g
|
|
286
296
|
}) => {
|
|
287
|
-
const [
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
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) ? {
|
|
298
|
+
provider: "value",
|
|
299
|
+
items: O
|
|
300
|
+
} : D && Array.isArray(D) ? {
|
|
301
|
+
provider: "value",
|
|
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);
|
|
292
314
|
try {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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);
|
|
341
|
+
}
|
|
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
|
+
});
|
|
302
416
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const M = Z(() => {
|
|
307
|
-
const c = ne(r.columns);
|
|
308
|
-
if (c)
|
|
309
|
-
return c.length > 0 && typeof c[0] == "object" && c[0] !== null ? c.filter((n) => n?.field && typeof n.field == "string").map((n) => ({
|
|
310
|
-
header: n.label || n.field.charAt(0).toUpperCase() + n.field.slice(1).replace(/_/g, " "),
|
|
311
|
-
accessorKey: n.field,
|
|
312
|
-
...n.width && { width: n.width },
|
|
313
|
-
...n.align && { align: n.align },
|
|
314
|
-
sortable: n.sortable !== !1
|
|
315
|
-
})) : c.filter((n) => typeof n == "string" && n.trim().length > 0).map((n) => ({
|
|
316
|
-
header: n.charAt(0).toUpperCase() + n.slice(1).replace(/_/g, " "),
|
|
317
|
-
accessorKey: n
|
|
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
|
|
318
420
|
}));
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
421
|
+
}
|
|
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
|
|
325
428
|
}));
|
|
326
429
|
}
|
|
327
|
-
if (!
|
|
328
|
-
const
|
|
329
|
-
return (
|
|
330
|
-
const
|
|
331
|
-
if (!
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
header:
|
|
335
|
-
accessorKey:
|
|
336
|
-
cell: (
|
|
337
|
-
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
|
|
338
441
|
});
|
|
339
|
-
}),
|
|
340
|
-
}, [
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (!c)
|
|
346
|
-
throw new Error("Object name required for data fetching");
|
|
347
|
-
const f = {
|
|
348
|
-
$select: (() => {
|
|
349
|
-
if (r.fields) return r.fields;
|
|
350
|
-
if (r.columns && Array.isArray(r.columns))
|
|
351
|
-
return r.columns.map((u) => typeof u == "string" ? u : u.field);
|
|
352
|
-
})(),
|
|
353
|
-
$top: r.pagination?.pageSize || r.pageSize || 50
|
|
354
|
-
};
|
|
355
|
-
r.filter && Array.isArray(r.filter) ? f.$filter = r.filter : "defaultFilters" in r && r.defaultFilters && (f.$filter = r.defaultFilters), r.sort ? typeof r.sort == "string" ? f.$orderby = r.sort : Array.isArray(r.sort) && (f.$orderby = r.sort.map((u) => `${u.field} ${u.order}`).join(", ")) : "defaultSort" in r && r.defaultSort && (f.$orderby = `${r.defaultSort.field} ${r.defaultSort.order}`);
|
|
356
|
-
const n = await g.find(c, f);
|
|
357
|
-
y(n.data || []);
|
|
358
|
-
} catch (c) {
|
|
359
|
-
A(c);
|
|
360
|
-
} finally {
|
|
361
|
-
S(!1);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}, [r, g, d, s]);
|
|
365
|
-
if (J(() => {
|
|
366
|
-
(m || d) && w();
|
|
367
|
-
}, [m, d, w]), P)
|
|
368
|
-
return /* @__PURE__ */ l.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
369
|
-
/* @__PURE__ */ l.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
|
|
370
|
-
/* @__PURE__ */ l.jsx("p", { className: "text-red-600 text-sm mt-1", children: P.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 })
|
|
371
448
|
] });
|
|
372
|
-
if (
|
|
373
|
-
return /* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__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..." })
|
|
376
453
|
] });
|
|
377
|
-
const
|
|
378
|
-
|
|
454
|
+
const K = se(), W = "operations" in n ? n.operations : void 0, X = W && (W.update || W.delete), re = X ? [
|
|
455
|
+
...K,
|
|
379
456
|
{
|
|
380
457
|
header: "Actions",
|
|
381
458
|
accessorKey: "_actions",
|
|
382
|
-
cell: (
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
/* @__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" })
|
|
386
463
|
] }) }),
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
|
|
389
|
-
/* @__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" }),
|
|
390
467
|
"Edit"
|
|
391
468
|
] }),
|
|
392
|
-
|
|
393
|
-
/* @__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" }),
|
|
394
471
|
"Delete"
|
|
395
472
|
] })
|
|
396
473
|
] })
|
|
397
474
|
] }),
|
|
398
475
|
sortable: !1
|
|
399
476
|
}
|
|
400
|
-
] :
|
|
401
|
-
let
|
|
402
|
-
|
|
403
|
-
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 = {
|
|
404
481
|
type: "data-table",
|
|
405
|
-
caption:
|
|
406
|
-
columns:
|
|
407
|
-
data:
|
|
408
|
-
pagination:
|
|
409
|
-
pageSize:
|
|
410
|
-
searchable:
|
|
411
|
-
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,
|
|
412
489
|
sortable: !0,
|
|
413
|
-
exportable:
|
|
414
|
-
rowActions:
|
|
415
|
-
resizableColumns:
|
|
416
|
-
|
|
417
|
-
|
|
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
|
+
] });
|
|
527
|
+
};
|
|
528
|
+
function H(n, a, e) {
|
|
529
|
+
let s = e.initialDeps ?? [], t, i = !0;
|
|
530
|
+
function o() {
|
|
531
|
+
var l, p, g;
|
|
532
|
+
let m;
|
|
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;
|
|
544
|
+
};
|
|
545
|
+
console.info(
|
|
546
|
+
`%c⏱ ${N(v, 5)} /${N(_, 5)} ms`,
|
|
547
|
+
`
|
|
548
|
+
font-size: .6rem;
|
|
549
|
+
font-weight: bold;
|
|
550
|
+
color: hsl(${Math.max(
|
|
551
|
+
0,
|
|
552
|
+
Math.min(120 - 120 * j, 120)
|
|
553
|
+
)}deg 100% 31%);`,
|
|
554
|
+
e?.key
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(t), i = !1, t;
|
|
558
|
+
}
|
|
559
|
+
return o.updateDeps = (l) => {
|
|
560
|
+
s = l;
|
|
561
|
+
}, o;
|
|
562
|
+
}
|
|
563
|
+
function be(n, a) {
|
|
564
|
+
if (n === void 0)
|
|
565
|
+
throw new Error("Unexpected undefined");
|
|
566
|
+
return n;
|
|
567
|
+
}
|
|
568
|
+
const qe = (n, a) => Math.abs(n - a) < 1.01, Be = (n, a, e) => {
|
|
569
|
+
let s;
|
|
570
|
+
return function(...t) {
|
|
571
|
+
n.clearTimeout(s), s = n.setTimeout(() => a.apply(this, t), e);
|
|
572
|
+
};
|
|
573
|
+
}, ve = (n) => {
|
|
574
|
+
const { offsetWidth: a, offsetHeight: e } = n;
|
|
575
|
+
return { width: a, height: e };
|
|
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);
|
|
580
|
+
return s;
|
|
581
|
+
}, Je = (n, a) => {
|
|
582
|
+
const e = n.scrollElement;
|
|
583
|
+
if (!e)
|
|
584
|
+
return;
|
|
585
|
+
const s = n.targetWindow;
|
|
586
|
+
if (!s)
|
|
587
|
+
return;
|
|
588
|
+
const t = (o) => {
|
|
589
|
+
const { width: l, height: p } = o;
|
|
590
|
+
a({ width: Math.round(l), height: Math.round(p) });
|
|
591
|
+
};
|
|
592
|
+
if (t(ve(e)), !s.ResizeObserver)
|
|
593
|
+
return () => {
|
|
594
|
+
};
|
|
595
|
+
const i = new s.ResizeObserver((o) => {
|
|
596
|
+
const l = () => {
|
|
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 });
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
t(ve(e));
|
|
606
|
+
};
|
|
607
|
+
n.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
|
|
608
|
+
});
|
|
609
|
+
return i.observe(e, { box: "border-box" }), () => {
|
|
610
|
+
i.unobserve(e);
|
|
611
|
+
};
|
|
612
|
+
}, xe = {
|
|
613
|
+
passive: !0
|
|
614
|
+
}, ye = typeof window > "u" ? !0 : "onscrollend" in window, Ke = (n, a) => {
|
|
615
|
+
const e = n.scrollElement;
|
|
616
|
+
if (!e)
|
|
617
|
+
return;
|
|
618
|
+
const s = n.targetWindow;
|
|
619
|
+
if (!s)
|
|
620
|
+
return;
|
|
621
|
+
let t = 0;
|
|
622
|
+
const i = n.options.useScrollendEvent && ye ? () => {
|
|
623
|
+
} : Be(
|
|
624
|
+
s,
|
|
625
|
+
() => {
|
|
626
|
+
a(t, !1);
|
|
627
|
+
},
|
|
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);
|
|
418
637
|
};
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
638
|
+
}, Xe = (n, a, e) => {
|
|
639
|
+
if (a?.borderBoxSize) {
|
|
640
|
+
const s = a.borderBoxSize[0];
|
|
641
|
+
if (s)
|
|
642
|
+
return Math.round(
|
|
643
|
+
s[e.options.horizontal ? "inlineSize" : "blockSize"]
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
return n[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
647
|
+
}, Ze = (n, {
|
|
648
|
+
adjustments: a = 0,
|
|
649
|
+
behavior: e
|
|
650
|
+
}, s) => {
|
|
651
|
+
var t, i;
|
|
652
|
+
const o = n + a;
|
|
653
|
+
(i = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || i.call(t, {
|
|
654
|
+
[s.options.horizontal ? "left" : "top"]: o,
|
|
655
|
+
behavior: e
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
class Qe {
|
|
659
|
+
constructor(a) {
|
|
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__ */ (() => {
|
|
661
|
+
let e = null;
|
|
662
|
+
const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
|
|
663
|
+
t.forEach((i) => {
|
|
664
|
+
const o = () => {
|
|
665
|
+
this._measureElement(i.target, i);
|
|
666
|
+
};
|
|
667
|
+
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
|
|
668
|
+
});
|
|
669
|
+
}));
|
|
670
|
+
return {
|
|
671
|
+
disconnect: () => {
|
|
672
|
+
var t;
|
|
673
|
+
(t = s()) == null || t.disconnect(), e = null;
|
|
674
|
+
},
|
|
675
|
+
observe: (t) => {
|
|
676
|
+
var i;
|
|
677
|
+
return (i = s()) == null ? void 0 : i.observe(t, { box: "border-box" });
|
|
678
|
+
},
|
|
679
|
+
unobserve: (t) => {
|
|
680
|
+
var i;
|
|
681
|
+
return (i = s()) == null ? void 0 : i.unobserve(t);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
})(), this.range = null, this.setOptions = (e) => {
|
|
685
|
+
Object.entries(e).forEach(([s, t]) => {
|
|
686
|
+
typeof t > "u" && delete e[s];
|
|
687
|
+
}), this.options = {
|
|
688
|
+
debug: !1,
|
|
689
|
+
initialOffset: 0,
|
|
690
|
+
overscan: 1,
|
|
691
|
+
paddingStart: 0,
|
|
692
|
+
paddingEnd: 0,
|
|
693
|
+
scrollPaddingStart: 0,
|
|
694
|
+
scrollPaddingEnd: 0,
|
|
695
|
+
horizontal: !1,
|
|
696
|
+
getItemKey: Ge,
|
|
697
|
+
rangeExtractor: He,
|
|
698
|
+
onChange: () => {
|
|
699
|
+
},
|
|
700
|
+
measureElement: Xe,
|
|
701
|
+
initialRect: { width: 0, height: 0 },
|
|
702
|
+
scrollMargin: 0,
|
|
703
|
+
gap: 0,
|
|
704
|
+
indexAttribute: "data-index",
|
|
705
|
+
initialMeasurementsCache: [],
|
|
706
|
+
lanes: 1,
|
|
707
|
+
isScrollingResetDelay: 150,
|
|
708
|
+
enabled: !0,
|
|
709
|
+
isRtl: !1,
|
|
710
|
+
useScrollendEvent: !1,
|
|
711
|
+
useAnimationFrameWithResizeObserver: !1,
|
|
712
|
+
...e
|
|
713
|
+
};
|
|
714
|
+
}, this.notify = (e) => {
|
|
715
|
+
var s, t;
|
|
716
|
+
(t = (s = this.options).onChange) == null || t.call(s, this, e);
|
|
717
|
+
}, this.maybeNotify = H(
|
|
718
|
+
() => (this.calculateRange(), [
|
|
719
|
+
this.isScrolling,
|
|
720
|
+
this.range ? this.range.startIndex : null,
|
|
721
|
+
this.range ? this.range.endIndex : null
|
|
722
|
+
]),
|
|
723
|
+
(e) => {
|
|
724
|
+
this.notify(e);
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
|
728
|
+
debug: () => this.options.debug,
|
|
729
|
+
initialDeps: [
|
|
730
|
+
this.isScrolling,
|
|
731
|
+
this.range ? this.range.startIndex : null,
|
|
732
|
+
this.range ? this.range.endIndex : null
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
), this.cleanup = () => {
|
|
736
|
+
this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
|
737
|
+
}, this._didMount = () => () => {
|
|
738
|
+
this.cleanup();
|
|
739
|
+
}, this._willUpdate = () => {
|
|
740
|
+
var e;
|
|
741
|
+
const s = this.options.enabled ? this.options.getScrollElement() : null;
|
|
742
|
+
if (this.scrollElement !== s) {
|
|
743
|
+
if (this.cleanup(), !s) {
|
|
744
|
+
this.maybeNotify();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
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);
|
|
749
|
+
}), this.unsubs.push(
|
|
750
|
+
this.options.observeElementRect(this, (t) => {
|
|
751
|
+
this.scrollRect = t, this.maybeNotify();
|
|
752
|
+
})
|
|
753
|
+
), this.unsubs.push(
|
|
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();
|
|
756
|
+
})
|
|
757
|
+
), this._scrollToOffset(this.getScrollOffset(), {
|
|
758
|
+
adjustments: void 0,
|
|
759
|
+
behavior: void 0
|
|
760
|
+
});
|
|
761
|
+
}
|
|
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) => {
|
|
763
|
+
const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
764
|
+
for (let o = s - 1; o >= 0; o--) {
|
|
765
|
+
const l = e[o];
|
|
766
|
+
if (t.has(l.lane))
|
|
767
|
+
continue;
|
|
768
|
+
const p = i.get(
|
|
769
|
+
l.lane
|
|
770
|
+
);
|
|
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)
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
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;
|
|
775
|
+
}, this.getMeasurementOptions = H(
|
|
776
|
+
() => [
|
|
777
|
+
this.options.count,
|
|
778
|
+
this.options.paddingStart,
|
|
779
|
+
this.options.scrollMargin,
|
|
780
|
+
this.options.getItemKey,
|
|
781
|
+
this.options.enabled,
|
|
782
|
+
this.options.lanes
|
|
783
|
+
],
|
|
784
|
+
(e, s, t, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
|
|
785
|
+
count: e,
|
|
786
|
+
paddingStart: s,
|
|
787
|
+
scrollMargin: t,
|
|
788
|
+
getItemKey: i,
|
|
789
|
+
enabled: o,
|
|
790
|
+
lanes: l
|
|
791
|
+
}),
|
|
792
|
+
{
|
|
793
|
+
key: !1
|
|
794
|
+
}
|
|
795
|
+
), this.getMeasurements = H(
|
|
796
|
+
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
797
|
+
({ count: e, paddingStart: s, scrollMargin: t, getItemKey: i, enabled: o, lanes: l }, p) => {
|
|
798
|
+
if (!o)
|
|
799
|
+
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
800
|
+
if (this.laneAssignments.size > e)
|
|
801
|
+
for (const c of this.laneAssignments.keys())
|
|
802
|
+
c >= e && this.laneAssignments.delete(c);
|
|
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) => {
|
|
804
|
+
this.itemSizeCache.set(c.key, c.size);
|
|
805
|
+
}));
|
|
806
|
+
const g = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
807
|
+
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
|
|
808
|
+
const m = this.measurementsCache.slice(0, g), E = new Array(l).fill(
|
|
809
|
+
void 0
|
|
810
|
+
);
|
|
811
|
+
for (let c = 0; c < g; c++) {
|
|
812
|
+
const b = m[c];
|
|
813
|
+
b && (E[b.lane] = c);
|
|
814
|
+
}
|
|
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;
|
|
822
|
+
} else {
|
|
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);
|
|
825
|
+
}
|
|
826
|
+
const N = p.get(b), O = typeof N == "number" ? N : this.options.estimateSize(c), D = j + O;
|
|
827
|
+
m[c] = {
|
|
828
|
+
index: c,
|
|
829
|
+
start: j,
|
|
830
|
+
size: O,
|
|
831
|
+
end: D,
|
|
832
|
+
key: b,
|
|
833
|
+
lane: v
|
|
834
|
+
}, E[v] = c;
|
|
835
|
+
}
|
|
836
|
+
return this.measurementsCache = m, m;
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
840
|
+
debug: () => this.options.debug
|
|
841
|
+
}
|
|
842
|
+
), this.calculateRange = H(
|
|
843
|
+
() => [
|
|
844
|
+
this.getMeasurements(),
|
|
845
|
+
this.getSize(),
|
|
846
|
+
this.getScrollOffset(),
|
|
847
|
+
this.options.lanes
|
|
848
|
+
],
|
|
849
|
+
(e, s, t, i) => this.range = e.length > 0 && s > 0 ? et({
|
|
850
|
+
measurements: e,
|
|
851
|
+
outerSize: s,
|
|
852
|
+
scrollOffset: t,
|
|
853
|
+
lanes: i
|
|
854
|
+
}) : null,
|
|
855
|
+
{
|
|
856
|
+
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
857
|
+
debug: () => this.options.debug
|
|
858
|
+
}
|
|
859
|
+
), this.getVirtualIndexes = H(
|
|
860
|
+
() => {
|
|
861
|
+
let e = null, s = null;
|
|
862
|
+
const t = this.calculateRange();
|
|
863
|
+
return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
|
|
864
|
+
this.options.rangeExtractor,
|
|
865
|
+
this.options.overscan,
|
|
866
|
+
this.options.count,
|
|
867
|
+
e,
|
|
868
|
+
s
|
|
869
|
+
];
|
|
870
|
+
},
|
|
871
|
+
(e, s, t, i, o) => i === null || o === null ? [] : e({
|
|
872
|
+
startIndex: i,
|
|
873
|
+
endIndex: o,
|
|
874
|
+
overscan: s,
|
|
875
|
+
count: t
|
|
876
|
+
}),
|
|
877
|
+
{
|
|
878
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
879
|
+
debug: () => this.options.debug
|
|
880
|
+
}
|
|
881
|
+
), this.indexFromElement = (e) => {
|
|
882
|
+
const s = this.options.indexAttribute, t = e.getAttribute(s);
|
|
883
|
+
return t ? parseInt(t, 10) : (console.warn(
|
|
884
|
+
`Missing attribute name '${s}={index}' on measured element.`
|
|
885
|
+
), -1);
|
|
886
|
+
}, this._measureElement = (e, s) => {
|
|
887
|
+
const t = this.indexFromElement(e), i = this.measurementsCache[t];
|
|
888
|
+
if (!i)
|
|
889
|
+
return;
|
|
890
|
+
const o = i.key, l = this.elementsCache.get(o);
|
|
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));
|
|
892
|
+
}, this.resizeItem = (e, s) => {
|
|
893
|
+
const t = this.measurementsCache[e];
|
|
894
|
+
if (!t)
|
|
895
|
+
return;
|
|
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(), {
|
|
898
|
+
adjustments: this.scrollAdjustments += o,
|
|
899
|
+
behavior: void 0
|
|
900
|
+
})), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
|
|
901
|
+
}, this.measureElement = (e) => {
|
|
902
|
+
if (!e) {
|
|
903
|
+
this.elementsCache.forEach((s, t) => {
|
|
904
|
+
s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
|
|
905
|
+
});
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
this._measureElement(e, void 0);
|
|
909
|
+
}, this.getVirtualItems = H(
|
|
910
|
+
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
911
|
+
(e, s) => {
|
|
912
|
+
const t = [];
|
|
913
|
+
for (let i = 0, o = e.length; i < o; i++) {
|
|
914
|
+
const l = e[i], p = s[l];
|
|
915
|
+
t.push(p);
|
|
916
|
+
}
|
|
917
|
+
return t;
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
921
|
+
debug: () => this.options.debug
|
|
922
|
+
}
|
|
923
|
+
), this.getVirtualItemForOffset = (e) => {
|
|
924
|
+
const s = this.getMeasurements();
|
|
925
|
+
if (s.length !== 0)
|
|
926
|
+
return be(
|
|
927
|
+
s[je(
|
|
928
|
+
0,
|
|
929
|
+
s.length - 1,
|
|
930
|
+
(t) => be(s[t]).start,
|
|
931
|
+
e
|
|
932
|
+
)]
|
|
933
|
+
);
|
|
934
|
+
}, this.getMaxScrollOffset = () => {
|
|
935
|
+
if (!this.scrollElement) return 0;
|
|
936
|
+
if ("scrollHeight" in this.scrollElement)
|
|
937
|
+
return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
938
|
+
{
|
|
939
|
+
const e = this.scrollElement.document.documentElement;
|
|
940
|
+
return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
|
|
941
|
+
}
|
|
942
|
+
}, this.getOffsetForAlignment = (e, s, t = 0) => {
|
|
943
|
+
if (!this.scrollElement) return 0;
|
|
944
|
+
const i = this.getSize(), o = this.getScrollOffset();
|
|
945
|
+
s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (t - i) / 2 : s === "end" && (e -= i);
|
|
946
|
+
const l = this.getMaxScrollOffset();
|
|
947
|
+
return Math.max(Math.min(l, e), 0);
|
|
948
|
+
}, this.getOffsetForIndex = (e, s = "auto") => {
|
|
949
|
+
e = Math.max(0, Math.min(e, this.options.count - 1));
|
|
950
|
+
const t = this.measurementsCache[e];
|
|
951
|
+
if (!t)
|
|
952
|
+
return;
|
|
953
|
+
const i = this.getSize(), o = this.getScrollOffset();
|
|
954
|
+
if (s === "auto")
|
|
955
|
+
if (t.end >= o + i - this.options.scrollPaddingEnd)
|
|
956
|
+
s = "end";
|
|
957
|
+
else if (t.start <= o + this.options.scrollPaddingStart)
|
|
958
|
+
s = "start";
|
|
959
|
+
else
|
|
960
|
+
return [o, s];
|
|
961
|
+
if (s === "end" && e === this.options.count - 1)
|
|
962
|
+
return [this.getMaxScrollOffset(), s];
|
|
963
|
+
const l = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
|
|
964
|
+
return [
|
|
965
|
+
this.getOffsetForAlignment(l, s, t.size),
|
|
966
|
+
s
|
|
967
|
+
];
|
|
968
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
|
|
969
|
+
t === "smooth" && this.isDynamicMode() && console.warn(
|
|
970
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
971
|
+
), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
|
|
972
|
+
adjustments: void 0,
|
|
973
|
+
behavior: t
|
|
974
|
+
});
|
|
975
|
+
}, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
|
|
976
|
+
t === "smooth" && this.isDynamicMode() && console.warn(
|
|
977
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
978
|
+
), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
|
|
979
|
+
let i = 0;
|
|
980
|
+
const o = 10, l = (g) => {
|
|
981
|
+
if (!this.targetWindow) return;
|
|
982
|
+
const m = this.getOffsetForIndex(e, g);
|
|
983
|
+
if (!m) {
|
|
984
|
+
console.warn("Failed to get offset for index:", e);
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
const [E, c] = m;
|
|
988
|
+
this._scrollToOffset(E, { adjustments: void 0, behavior: t }), this.targetWindow.requestAnimationFrame(() => {
|
|
989
|
+
const b = () => {
|
|
990
|
+
if (this.currentScrollToIndex !== e) return;
|
|
991
|
+
const _ = this.getScrollOffset(), v = this.getOffsetForIndex(e, c);
|
|
992
|
+
if (!v) {
|
|
993
|
+
console.warn("Failed to get offset for index:", e);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
qe(v[0], _) || p(c);
|
|
997
|
+
};
|
|
998
|
+
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(b) : b();
|
|
999
|
+
});
|
|
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(
|
|
1002
|
+
`Failed to scroll to index ${e} after ${o} attempts.`
|
|
1003
|
+
));
|
|
1004
|
+
};
|
|
1005
|
+
l(s);
|
|
1006
|
+
}, this.scrollBy = (e, { behavior: s } = {}) => {
|
|
1007
|
+
s === "smooth" && this.isDynamicMode() && console.warn(
|
|
1008
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
1009
|
+
), this._scrollToOffset(this.getScrollOffset() + e, {
|
|
1010
|
+
adjustments: void 0,
|
|
1011
|
+
behavior: s
|
|
1012
|
+
});
|
|
1013
|
+
}, this.getTotalSize = () => {
|
|
1014
|
+
var e;
|
|
1015
|
+
const s = this.getMeasurements();
|
|
1016
|
+
let t;
|
|
1017
|
+
if (s.length === 0)
|
|
1018
|
+
t = this.options.paddingStart;
|
|
1019
|
+
else if (this.options.lanes === 1)
|
|
1020
|
+
t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
|
|
1021
|
+
else {
|
|
1022
|
+
const i = Array(this.options.lanes).fill(null);
|
|
1023
|
+
let o = s.length - 1;
|
|
1024
|
+
for (; o >= 0 && i.some((l) => l === null); ) {
|
|
1025
|
+
const l = s[o];
|
|
1026
|
+
i[l.lane] === null && (i[l.lane] = l.end), o--;
|
|
1027
|
+
}
|
|
1028
|
+
t = Math.max(...i.filter((l) => l !== null));
|
|
1029
|
+
}
|
|
1030
|
+
return Math.max(
|
|
1031
|
+
t - this.options.scrollMargin + this.options.paddingEnd,
|
|
1032
|
+
0
|
|
1033
|
+
);
|
|
1034
|
+
}, this._scrollToOffset = (e, {
|
|
1035
|
+
adjustments: s,
|
|
1036
|
+
behavior: t
|
|
1037
|
+
}) => {
|
|
1038
|
+
this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
|
|
1039
|
+
}, this.measure = () => {
|
|
1040
|
+
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
1041
|
+
}, this.setOptions(a);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
const je = (n, a, e, s) => {
|
|
1045
|
+
for (; n <= a; ) {
|
|
1046
|
+
const t = (n + a) / 2 | 0, i = e(t);
|
|
1047
|
+
if (i < s)
|
|
1048
|
+
n = t + 1;
|
|
1049
|
+
else if (i > s)
|
|
1050
|
+
a = t - 1;
|
|
1051
|
+
else
|
|
1052
|
+
return t;
|
|
1053
|
+
}
|
|
1054
|
+
return n > 0 ? n - 1 : 0;
|
|
1055
|
+
};
|
|
1056
|
+
function et({
|
|
1057
|
+
measurements: n,
|
|
1058
|
+
outerSize: a,
|
|
1059
|
+
scrollOffset: e,
|
|
1060
|
+
lanes: s
|
|
1061
|
+
}) {
|
|
1062
|
+
const t = n.length - 1, i = (p) => n[p].start;
|
|
1063
|
+
if (n.length <= s)
|
|
1064
|
+
return {
|
|
1065
|
+
startIndex: 0,
|
|
1066
|
+
endIndex: t
|
|
1067
|
+
};
|
|
1068
|
+
let o = je(
|
|
1069
|
+
0,
|
|
1070
|
+
t,
|
|
1071
|
+
i,
|
|
1072
|
+
e
|
|
1073
|
+
), l = o;
|
|
1074
|
+
if (s === 1)
|
|
1075
|
+
for (; l < t && n[l].end < e + a; )
|
|
1076
|
+
l++;
|
|
1077
|
+
else if (s > 1) {
|
|
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++;
|
|
1082
|
+
}
|
|
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--;
|
|
1087
|
+
}
|
|
1088
|
+
o = Math.max(0, o - o % s), l = Math.min(t, l + (s - 1 - l % s));
|
|
1089
|
+
}
|
|
1090
|
+
return { startIndex: o, endIndex: l };
|
|
1091
|
+
}
|
|
1092
|
+
const Ee = typeof document < "u" ? le.useLayoutEffect : le.useEffect;
|
|
1093
|
+
function tt({
|
|
1094
|
+
useFlushSync: n = !0,
|
|
1095
|
+
...a
|
|
1096
|
+
}) {
|
|
1097
|
+
const e = le.useReducer(() => ({}), {})[1], s = {
|
|
1098
|
+
...a,
|
|
1099
|
+
onChange: (i, o) => {
|
|
1100
|
+
var l;
|
|
1101
|
+
n && o ? $e(e) : e(), (l = a.onChange) == null || l.call(a, i, o);
|
|
1102
|
+
}
|
|
1103
|
+
}, [t] = le.useState(
|
|
1104
|
+
() => new Qe(s)
|
|
1105
|
+
);
|
|
1106
|
+
return t.setOptions(s), Ee(() => t._didMount(), []), Ee(() => t._willUpdate()), t;
|
|
1107
|
+
}
|
|
1108
|
+
function nt(n) {
|
|
1109
|
+
return tt({
|
|
1110
|
+
observeElementRect: Je,
|
|
1111
|
+
observeElementOffset: Ke,
|
|
1112
|
+
scrollToFn: Ze,
|
|
1113
|
+
...n
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
const ut = ({
|
|
1117
|
+
data: n,
|
|
1118
|
+
columns: a,
|
|
1119
|
+
rowHeight: e = 40,
|
|
1120
|
+
height: s = 600,
|
|
1121
|
+
className: t = "",
|
|
1122
|
+
headerClassName: i = "",
|
|
1123
|
+
rowClassName: o,
|
|
1124
|
+
onRowClick: l,
|
|
1125
|
+
overscan: p = 5
|
|
1126
|
+
}) => {
|
|
1127
|
+
const g = _e(null), m = nt({
|
|
1128
|
+
count: n.length,
|
|
1129
|
+
getScrollElement: () => g.current,
|
|
1130
|
+
estimateSize: () => e,
|
|
1131
|
+
overscan: p
|
|
1132
|
+
}), E = m.getVirtualItems();
|
|
1133
|
+
return /* @__PURE__ */ u.jsxs("div", { className: t, children: [
|
|
1134
|
+
/* @__PURE__ */ u.jsx(
|
|
1135
|
+
"div",
|
|
1136
|
+
{
|
|
1137
|
+
className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
|
|
1138
|
+
style: {
|
|
1139
|
+
gridTemplateColumns: a.map((c) => c.width || "1fr").join(" ")
|
|
1140
|
+
},
|
|
1141
|
+
children: a.map((c, b) => /* @__PURE__ */ u.jsx(
|
|
1142
|
+
"div",
|
|
1143
|
+
{
|
|
1144
|
+
className: `px-4 py-2 font-semibold text-sm ${c.align === "center" ? "text-center" : c.align === "right" ? "text-right" : "text-left"}`,
|
|
1145
|
+
children: c.header
|
|
1146
|
+
},
|
|
1147
|
+
b
|
|
1148
|
+
))
|
|
1149
|
+
}
|
|
1150
|
+
),
|
|
1151
|
+
/* @__PURE__ */ u.jsx(
|
|
1152
|
+
"div",
|
|
1153
|
+
{
|
|
1154
|
+
ref: g,
|
|
1155
|
+
className: "overflow-auto",
|
|
1156
|
+
style: {
|
|
1157
|
+
height: typeof s == "number" ? `${s}px` : s,
|
|
1158
|
+
contain: "strict"
|
|
1159
|
+
},
|
|
1160
|
+
children: /* @__PURE__ */ u.jsx(
|
|
1161
|
+
"div",
|
|
1162
|
+
{
|
|
1163
|
+
style: {
|
|
1164
|
+
height: `${m.getTotalSize()}px`,
|
|
1165
|
+
width: "100%",
|
|
1166
|
+
position: "relative"
|
|
1167
|
+
},
|
|
1168
|
+
children: E.map((c) => {
|
|
1169
|
+
const b = n[c.index], _ = typeof o == "function" ? o(b, c.index) : o || "";
|
|
1170
|
+
return /* @__PURE__ */ u.jsx(
|
|
1171
|
+
"div",
|
|
1172
|
+
{
|
|
1173
|
+
className: `grid border-b hover:bg-muted/50 cursor-pointer ${_}`,
|
|
1174
|
+
style: {
|
|
1175
|
+
position: "absolute",
|
|
1176
|
+
top: 0,
|
|
1177
|
+
left: 0,
|
|
1178
|
+
width: "100%",
|
|
1179
|
+
height: `${c.size}px`,
|
|
1180
|
+
transform: `translateY(${c.start}px)`,
|
|
1181
|
+
gridTemplateColumns: a.map((v) => v.width || "1fr").join(" ")
|
|
1182
|
+
},
|
|
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(
|
|
1187
|
+
"div",
|
|
1188
|
+
{
|
|
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
|
|
1191
|
+
},
|
|
1192
|
+
j
|
|
1193
|
+
);
|
|
1194
|
+
})
|
|
1195
|
+
},
|
|
1196
|
+
c.key
|
|
1197
|
+
);
|
|
1198
|
+
})
|
|
1199
|
+
}
|
|
1200
|
+
)
|
|
1201
|
+
}
|
|
1202
|
+
),
|
|
1203
|
+
/* @__PURE__ */ u.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
|
|
1204
|
+
"Showing ",
|
|
1205
|
+
E.length,
|
|
1206
|
+
" of ",
|
|
1207
|
+
n.length,
|
|
1208
|
+
" rows (virtual scrolling enabled)"
|
|
1209
|
+
] })
|
|
1210
|
+
] });
|
|
1211
|
+
}, Oe = ({ schema: n, ...a }) => {
|
|
1212
|
+
const { dataSource: e } = Ne() || {};
|
|
1213
|
+
return /* @__PURE__ */ u.jsx(Ue, { schema: n, dataSource: e, ...a });
|
|
1214
|
+
};
|
|
1215
|
+
we.register("object-grid", Oe, {
|
|
1216
|
+
namespace: "plugin-grid",
|
|
1217
|
+
label: "Object Grid",
|
|
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
|
+
]
|
|
1224
|
+
});
|
|
1225
|
+
we.register("grid", Oe, {
|
|
1226
|
+
namespace: "view",
|
|
1227
|
+
label: "Data Grid",
|
|
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
|
+
]
|
|
1234
|
+
});
|
|
423
1235
|
export {
|
|
424
|
-
|
|
1236
|
+
Ue as ObjectGrid,
|
|
1237
|
+
Oe as ObjectGridRenderer,
|
|
1238
|
+
ut as VirtualGrid
|
|
425
1239
|
};
|