@object-ui/plugin-grid 2.0.0 → 3.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 +42 -6
- package/CHANGELOG.md +22 -0
- package/dist/index.js +960 -641
- package/dist/index.umd.cjs +3 -3
- package/dist/packages/plugin-grid/src/InlineEditing.d.ts +28 -0
- package/dist/packages/plugin-grid/src/ObjectGrid.EdgeCases.stories.d.ts +25 -0
- package/dist/packages/plugin-grid/src/ObjectGrid.stories.d.ts +33 -0
- package/dist/packages/plugin-grid/src/__tests__/InlineEditing.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/__tests__/accessibility.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/__tests__/performance-benchmark.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/__tests__/view-states.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/index.d.ts +5 -0
- package/dist/packages/plugin-grid/src/useGroupedData.d.ts +30 -0
- package/dist/packages/plugin-grid/src/useRowColor.d.ts +8 -0
- package/package.json +11 -10
- package/src/InlineEditing.tsx +235 -0
- package/src/ObjectGrid.EdgeCases.stories.tsx +147 -0
- package/src/ObjectGrid.stories.tsx +139 -0
- package/src/ObjectGrid.tsx +148 -16
- package/src/__tests__/InlineEditing.test.tsx +360 -0
- package/src/__tests__/accessibility.test.tsx +254 -0
- package/src/__tests__/performance-benchmark.test.tsx +182 -0
- package/src/__tests__/view-states.test.tsx +203 -0
- package/src/index.tsx +5 -0
- package/src/useGroupedData.ts +122 -0
- package/src/useRowColor.ts +74 -0
package/dist/index.js
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
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(
|
|
1
|
+
import * as me from "react";
|
|
2
|
+
import Pe, { useRef as pe, useState as D, useCallback as $, useEffect as re, createContext as Be, useMemo as Se } from "react";
|
|
3
|
+
import { ComponentRegistry as Fe } from "@object-ui/core";
|
|
4
|
+
import { useDataScope as He, useNavigationOverlay as Je, useAction as Xe, SchemaRenderer as Ce, useSchemaContext as Ze } from "@object-ui/react";
|
|
5
|
+
import { getCellRenderer as Oe } from "@object-ui/fields";
|
|
6
|
+
import { DropdownMenu as Qe, DropdownMenuTrigger as et, Button as tt, DropdownMenuContent as nt, DropdownMenuItem as Ne, NavigationOverlay as ve, cn as fe } from "@object-ui/components";
|
|
7
|
+
import { MoreVertical as st, Edit as rt, Trash2 as it, ChevronRight as ot, ChevronDown as lt, Check as at, X as ct } from "lucide-react";
|
|
8
|
+
import { flushSync as ut } from "react-dom";
|
|
9
|
+
var he = { exports: {} }, ue = {};
|
|
10
|
+
var _e;
|
|
11
|
+
function dt() {
|
|
12
|
+
if (_e) return ue;
|
|
13
|
+
_e = 1;
|
|
14
|
+
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), c = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
|
+
function e(n, s, i) {
|
|
16
16
|
var o = null;
|
|
17
|
-
if (i !== void 0 && (o = "" + i),
|
|
17
|
+
if (i !== void 0 && (o = "" + i), s.key !== void 0 && (o = "" + s.key), "key" in s) {
|
|
18
18
|
i = {};
|
|
19
|
-
for (var l in
|
|
20
|
-
l !== "key" && (i[l] =
|
|
21
|
-
} else i =
|
|
22
|
-
return
|
|
23
|
-
$$typeof:
|
|
24
|
-
type:
|
|
19
|
+
for (var l in s)
|
|
20
|
+
l !== "key" && (i[l] = s[l]);
|
|
21
|
+
} else i = s;
|
|
22
|
+
return s = i.ref, {
|
|
23
|
+
$$typeof: t,
|
|
24
|
+
type: n,
|
|
25
25
|
key: o,
|
|
26
|
-
ref:
|
|
26
|
+
ref: s !== void 0 ? s : null,
|
|
27
27
|
props: i
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return ue.Fragment = c, ue.jsx = e, ue.jsxs = e, ue;
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
function
|
|
35
|
-
return
|
|
36
|
-
function
|
|
32
|
+
var de = {};
|
|
33
|
+
var Re;
|
|
34
|
+
function ft() {
|
|
35
|
+
return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
|
+
function t(r) {
|
|
37
37
|
if (r == null) return null;
|
|
38
38
|
if (typeof r == "function")
|
|
39
|
-
return r.$$typeof ===
|
|
39
|
+
return r.$$typeof === Z ? null : r.displayName || r.name || null;
|
|
40
40
|
if (typeof r == "string") return r;
|
|
41
41
|
switch (r) {
|
|
42
|
-
case
|
|
42
|
+
case S:
|
|
43
43
|
return "Fragment";
|
|
44
|
-
case
|
|
44
|
+
case _:
|
|
45
45
|
return "Profiler";
|
|
46
|
-
case
|
|
46
|
+
case R:
|
|
47
47
|
return "StrictMode";
|
|
48
|
-
case
|
|
48
|
+
case k:
|
|
49
49
|
return "Suspense";
|
|
50
|
-
case
|
|
50
|
+
case L:
|
|
51
51
|
return "SuspenseList";
|
|
52
|
-
case
|
|
52
|
+
case X:
|
|
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 x:
|
|
60
60
|
return "Portal";
|
|
61
|
-
case
|
|
61
|
+
case A:
|
|
62
62
|
return r.displayName || "Context";
|
|
63
|
-
case
|
|
63
|
+
case F:
|
|
64
64
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
|
-
case
|
|
65
|
+
case K:
|
|
66
66
|
var h = r.render;
|
|
67
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 :
|
|
70
|
-
case
|
|
68
|
+
case ge:
|
|
69
|
+
return h = r.displayName || null, h !== null ? h : t(r.type) || "Memo";
|
|
70
|
+
case J:
|
|
71
71
|
h = r._payload, r = r._init;
|
|
72
72
|
try {
|
|
73
|
-
return
|
|
73
|
+
return t(r(h));
|
|
74
74
|
} catch {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function c(r) {
|
|
80
80
|
return "" + r;
|
|
81
81
|
}
|
|
82
82
|
function e(r) {
|
|
83
83
|
try {
|
|
84
|
-
|
|
84
|
+
c(r);
|
|
85
85
|
var h = !1;
|
|
86
86
|
} catch {
|
|
87
87
|
h = !0;
|
|
88
88
|
}
|
|
89
89
|
if (h) {
|
|
90
90
|
h = console;
|
|
91
|
-
var
|
|
92
|
-
return
|
|
91
|
+
var j = h.error, C = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
92
|
+
return j.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
|
-
|
|
96
|
-
),
|
|
95
|
+
C
|
|
96
|
+
), c(r);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
if (r ===
|
|
101
|
-
if (typeof r == "object" && r !== null && r.$$typeof ===
|
|
99
|
+
function n(r) {
|
|
100
|
+
if (r === S) return "<>";
|
|
101
|
+
if (typeof r == "object" && r !== null && r.$$typeof === J)
|
|
102
102
|
return "<...>";
|
|
103
103
|
try {
|
|
104
|
-
var h =
|
|
104
|
+
var h = t(r);
|
|
105
105
|
return h ? "<" + h + ">" : "<...>";
|
|
106
106
|
} catch {
|
|
107
107
|
return "<...>";
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
var r =
|
|
110
|
+
function s() {
|
|
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 (
|
|
118
|
+
if (z.call(r, "key")) {
|
|
119
119
|
var h = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
120
|
if (h && h.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
122
|
return r.key !== void 0;
|
|
123
123
|
}
|
|
124
124
|
function l(r, h) {
|
|
125
|
-
function
|
|
126
|
-
|
|
125
|
+
function j() {
|
|
126
|
+
W || (W = !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
|
-
|
|
132
|
-
get:
|
|
131
|
+
j.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
132
|
+
get: j,
|
|
133
133
|
configurable: !0
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var r =
|
|
138
|
-
return
|
|
136
|
+
function g() {
|
|
137
|
+
var r = t(this.type);
|
|
138
|
+
return V[r] || (V[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 m(r, h, j, C, ee, te) {
|
|
143
|
+
var O = j.ref;
|
|
144
144
|
return r = {
|
|
145
|
-
$$typeof:
|
|
145
|
+
$$typeof: y,
|
|
146
146
|
type: r,
|
|
147
147
|
key: h,
|
|
148
|
-
props:
|
|
149
|
-
_owner:
|
|
150
|
-
}, (
|
|
148
|
+
props: j,
|
|
149
|
+
_owner: C
|
|
150
|
+
}, (O !== void 0 ? O : null) !== null ? Object.defineProperty(r, "ref", {
|
|
151
151
|
enumerable: !1,
|
|
152
|
-
get:
|
|
152
|
+
get: g
|
|
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,503 +164,679 @@ function Le() {
|
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
166
166
|
writable: !0,
|
|
167
|
-
value:
|
|
167
|
+
value: ee
|
|
168
168
|
}), Object.defineProperty(r, "_debugTask", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
171
171
|
writable: !0,
|
|
172
|
-
value:
|
|
172
|
+
value: te
|
|
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 f(r, h, j, C, ee, te) {
|
|
176
|
+
var O = h.children;
|
|
177
|
+
if (O !== void 0)
|
|
178
|
+
if (C)
|
|
179
|
+
if (U(O)) {
|
|
180
|
+
for (C = 0; C < O.length; C++)
|
|
181
|
+
v(O[C]);
|
|
182
|
+
Object.freeze && Object.freeze(O);
|
|
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 v(O);
|
|
188
|
+
if (z.call(h, "key")) {
|
|
189
|
+
O = t(r);
|
|
190
|
+
var G = Object.keys(h).filter(function(q) {
|
|
191
|
+
return q !== "key";
|
|
192
192
|
});
|
|
193
|
-
|
|
193
|
+
C = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", ie[O + C] || (G = 0 < G.length ? "{" + G.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
|
+
C,
|
|
201
|
+
O,
|
|
202
|
+
G,
|
|
203
|
+
O
|
|
204
|
+
), ie[O + C] = !0);
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
for (var
|
|
209
|
-
|
|
210
|
-
} else
|
|
211
|
-
return
|
|
212
|
-
|
|
206
|
+
if (O = null, j !== void 0 && (e(j), O = "" + j), o(h) && (e(h.key), O = "" + h.key), "key" in h) {
|
|
207
|
+
j = {};
|
|
208
|
+
for (var ne in h)
|
|
209
|
+
ne !== "key" && (j[ne] = h[ne]);
|
|
210
|
+
} else j = h;
|
|
211
|
+
return O && l(
|
|
212
|
+
j,
|
|
213
213
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
214
|
-
),
|
|
214
|
+
), m(
|
|
215
215
|
r,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
O,
|
|
217
|
+
j,
|
|
218
|
+
s(),
|
|
219
|
+
ee,
|
|
220
|
+
te
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
223
|
+
function v(r) {
|
|
224
|
+
u(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === J && (r._payload.status === "fulfilled" ? u(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
225
225
|
}
|
|
226
|
-
function
|
|
227
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
226
|
+
function u(r) {
|
|
227
|
+
return typeof r == "object" && r !== null && r.$$typeof === y;
|
|
228
228
|
}
|
|
229
|
-
var
|
|
229
|
+
var d = Pe, y = /* @__PURE__ */ Symbol.for("react.transitional.element"), x = /* @__PURE__ */ Symbol.for("react.portal"), S = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), _ = /* @__PURE__ */ Symbol.for("react.profiler"), F = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), L = /* @__PURE__ */ Symbol.for("react.suspense_list"), ge = /* @__PURE__ */ Symbol.for("react.memo"), J = /* @__PURE__ */ Symbol.for("react.lazy"), X = /* @__PURE__ */ Symbol.for("react.activity"), Z = /* @__PURE__ */ Symbol.for("react.client.reference"), Q = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, U = Array.isArray, P = console.createTask ? console.createTask : function() {
|
|
230
230
|
return null;
|
|
231
231
|
};
|
|
232
|
-
|
|
232
|
+
d = {
|
|
233
233
|
react_stack_bottom_frame: function(r) {
|
|
234
234
|
return r();
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
var
|
|
238
|
-
|
|
237
|
+
var W, V = {}, H = d.react_stack_bottom_frame.bind(
|
|
238
|
+
d,
|
|
239
239
|
i
|
|
240
|
-
)(),
|
|
241
|
-
|
|
242
|
-
var
|
|
243
|
-
return
|
|
240
|
+
)(), Y = P(n(i)), ie = {};
|
|
241
|
+
de.Fragment = S, de.jsx = function(r, h, j) {
|
|
242
|
+
var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
|
|
243
|
+
return f(
|
|
244
244
|
r,
|
|
245
245
|
h,
|
|
246
|
-
|
|
246
|
+
j,
|
|
247
247
|
!1,
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
C ? Error("react-stack-top-frame") : H,
|
|
249
|
+
C ? P(n(r)) : Y
|
|
250
250
|
);
|
|
251
|
-
},
|
|
252
|
-
var
|
|
253
|
-
return
|
|
251
|
+
}, de.jsxs = function(r, h, j) {
|
|
252
|
+
var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return f(
|
|
254
254
|
r,
|
|
255
255
|
h,
|
|
256
|
-
|
|
256
|
+
j,
|
|
257
257
|
!0,
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
C ? Error("react-stack-top-frame") : H,
|
|
259
|
+
C ? P(n(r)) : Y
|
|
260
260
|
);
|
|
261
261
|
};
|
|
262
|
-
})()),
|
|
262
|
+
})()), de;
|
|
263
|
+
}
|
|
264
|
+
var ke;
|
|
265
|
+
function ht() {
|
|
266
|
+
return ke || (ke = 1, process.env.NODE_ENV === "production" ? he.exports = dt() : he.exports = ft()), he.exports;
|
|
267
|
+
}
|
|
268
|
+
var a = ht();
|
|
269
|
+
function mt(t) {
|
|
270
|
+
const { onRefresh: c, threshold: e = 80, enabled: n = !0 } = t, s = pe(null), [i, o] = D(!1), [l, g] = D(0), m = pe(0), f = $((d) => {
|
|
271
|
+
if (!n || i)
|
|
272
|
+
return;
|
|
273
|
+
const y = s.current;
|
|
274
|
+
y && y.scrollTop === 0 && (m.current = d.touches[0].clientY);
|
|
275
|
+
}, [n, i]), v = $((d) => {
|
|
276
|
+
if (!n || i || !m.current)
|
|
277
|
+
return;
|
|
278
|
+
const x = d.touches[0].clientY - m.current;
|
|
279
|
+
x > 0 && g(Math.min(x, e * 1.5));
|
|
280
|
+
}, [n, i, e]), u = $(async () => {
|
|
281
|
+
if (!(!n || i)) {
|
|
282
|
+
if (l >= e) {
|
|
283
|
+
o(!0);
|
|
284
|
+
try {
|
|
285
|
+
await c();
|
|
286
|
+
} finally {
|
|
287
|
+
o(!1);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
g(0), m.current = 0;
|
|
291
|
+
}
|
|
292
|
+
}, [n, i, l, e, c]);
|
|
293
|
+
return re(() => {
|
|
294
|
+
const d = s.current;
|
|
295
|
+
if (!(!d || !n))
|
|
296
|
+
return d.addEventListener("touchstart", f, { passive: !0 }), d.addEventListener("touchmove", v, { passive: !0 }), d.addEventListener("touchend", u, { passive: !0 }), () => {
|
|
297
|
+
d.removeEventListener("touchstart", f), d.removeEventListener("touchmove", v), d.removeEventListener("touchend", u);
|
|
298
|
+
};
|
|
299
|
+
}, [f, v, u, n]), { ref: s, isRefreshing: i, pullDistance: l };
|
|
300
|
+
}
|
|
301
|
+
const pt = Be(null);
|
|
302
|
+
pt.displayName = "MobileContext";
|
|
303
|
+
const gt = {
|
|
304
|
+
red: "bg-red-100",
|
|
305
|
+
green: "bg-green-100",
|
|
306
|
+
blue: "bg-blue-100",
|
|
307
|
+
yellow: "bg-yellow-100",
|
|
308
|
+
orange: "bg-orange-100",
|
|
309
|
+
purple: "bg-purple-100",
|
|
310
|
+
pink: "bg-pink-100",
|
|
311
|
+
gray: "bg-gray-100",
|
|
312
|
+
grey: "bg-gray-100",
|
|
313
|
+
indigo: "bg-indigo-100",
|
|
314
|
+
teal: "bg-teal-100",
|
|
315
|
+
cyan: "bg-cyan-100",
|
|
316
|
+
amber: "bg-amber-100",
|
|
317
|
+
lime: "bg-lime-100",
|
|
318
|
+
emerald: "bg-emerald-100",
|
|
319
|
+
rose: "bg-rose-100",
|
|
320
|
+
sky: "bg-sky-100",
|
|
321
|
+
violet: "bg-violet-100",
|
|
322
|
+
fuchsia: "bg-fuchsia-100",
|
|
323
|
+
slate: "bg-slate-100",
|
|
324
|
+
zinc: "bg-zinc-100",
|
|
325
|
+
stone: "bg-stone-100",
|
|
326
|
+
neutral: "bg-neutral-100"
|
|
327
|
+
};
|
|
328
|
+
function bt(t) {
|
|
329
|
+
if (t.startsWith("bg-")) return t;
|
|
330
|
+
const c = t.toLowerCase().trim();
|
|
331
|
+
return gt[c];
|
|
332
|
+
}
|
|
333
|
+
function xt(t) {
|
|
334
|
+
return $(
|
|
335
|
+
(c) => {
|
|
336
|
+
if (!t?.field || !t.colors) return;
|
|
337
|
+
const e = String(c[t.field] ?? ""), n = t.colors[e];
|
|
338
|
+
if (n)
|
|
339
|
+
return bt(n);
|
|
340
|
+
},
|
|
341
|
+
[t?.field, t?.colors]
|
|
342
|
+
);
|
|
263
343
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return pe || (pe = 1, process.env.NODE_ENV === "production" ? oe.exports = We() : oe.exports = Le()), oe.exports;
|
|
344
|
+
function vt(t, c) {
|
|
345
|
+
return c.map((e) => String(t[e.field] ?? "")).join(" / ");
|
|
267
346
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
347
|
+
function yt(t, c) {
|
|
348
|
+
return c.map((e) => {
|
|
349
|
+
const n = t[e.field];
|
|
350
|
+
return n != null && n !== "" ? String(n) : "(empty)";
|
|
351
|
+
}).join(" / ");
|
|
352
|
+
}
|
|
353
|
+
function Et(t, c, e) {
|
|
354
|
+
const n = t.localeCompare(c, void 0, { numeric: !0, sensitivity: "base" });
|
|
355
|
+
return e === "desc" ? -n : n;
|
|
356
|
+
}
|
|
357
|
+
function wt(t, c) {
|
|
358
|
+
const e = t?.fields, n = !!(e && e.length > 0), [s, i] = D({}), o = Se(() => e ? e.some((m) => m.collapsed) : !1, [e]), l = Se(() => {
|
|
359
|
+
if (!n || !e) return [];
|
|
360
|
+
const m = /* @__PURE__ */ new Map(), f = [];
|
|
361
|
+
for (const u of c) {
|
|
362
|
+
const d = vt(u, e);
|
|
363
|
+
m.has(d) || (m.set(d, { label: yt(u, e), rows: [] }), f.push(d)), m.get(d).rows.push(u);
|
|
364
|
+
}
|
|
365
|
+
const v = e[0]?.order ?? "asc";
|
|
366
|
+
return f.sort((u, d) => Et(u, d, v)), f.map((u) => {
|
|
367
|
+
const d = m.get(u), y = u in s ? s[u] : o;
|
|
368
|
+
return { key: u, label: d.label, rows: d.rows, collapsed: y };
|
|
369
|
+
});
|
|
370
|
+
}, [c, e, n, s, o]), g = $((m) => {
|
|
371
|
+
i((f) => ({
|
|
372
|
+
...f,
|
|
373
|
+
[m]: f[m] !== void 0 ? !f[m] : !o
|
|
374
|
+
}));
|
|
375
|
+
}, [o]);
|
|
376
|
+
return { groups: l, isGrouped: n, toggleGroup: g };
|
|
377
|
+
}
|
|
378
|
+
function jt(t) {
|
|
379
|
+
return t.data ? Array.isArray(t.data) ? {
|
|
271
380
|
provider: "value",
|
|
272
|
-
items:
|
|
273
|
-
} :
|
|
381
|
+
items: t.data
|
|
382
|
+
} : t.data : t.staticData ? {
|
|
274
383
|
provider: "value",
|
|
275
|
-
items:
|
|
276
|
-
} :
|
|
384
|
+
items: t.staticData
|
|
385
|
+
} : t.objectName ? {
|
|
277
386
|
provider: "object",
|
|
278
|
-
object:
|
|
387
|
+
object: t.objectName
|
|
279
388
|
} : null;
|
|
280
389
|
}
|
|
281
|
-
function
|
|
282
|
-
if (!(!
|
|
283
|
-
return typeof
|
|
390
|
+
function Te(t) {
|
|
391
|
+
if (!(!t || t.length === 0))
|
|
392
|
+
return typeof t[0] == "object" && t[0] !== null, t;
|
|
284
393
|
}
|
|
285
|
-
const
|
|
286
|
-
schema:
|
|
287
|
-
dataSource:
|
|
394
|
+
const St = ({
|
|
395
|
+
schema: t,
|
|
396
|
+
dataSource: c,
|
|
288
397
|
onEdit: e,
|
|
289
|
-
onDelete:
|
|
290
|
-
onRowSelect:
|
|
398
|
+
onDelete: n,
|
|
399
|
+
onRowSelect: s,
|
|
291
400
|
onRowClick: i,
|
|
292
401
|
onCellChange: o,
|
|
293
402
|
onRowSave: l,
|
|
294
|
-
onBatchSave:
|
|
295
|
-
...
|
|
403
|
+
onBatchSave: g,
|
|
404
|
+
...m
|
|
296
405
|
}) => {
|
|
297
|
-
const [
|
|
406
|
+
const [f, v] = D([]), [u, d] = D(!0), [y, x] = D(null), [S, R] = D(null), [_, F] = D(!1), [A, K] = D(0), k = $(async () => {
|
|
407
|
+
K((b) => b + 1);
|
|
408
|
+
}, []), { ref: L, isRefreshing: ge, pullDistance: J } = mt({
|
|
409
|
+
onRefresh: k,
|
|
410
|
+
enabled: !!c && !!t.objectName
|
|
411
|
+
});
|
|
412
|
+
re(() => {
|
|
413
|
+
const b = () => F(window.innerWidth < 480);
|
|
414
|
+
return b(), window.addEventListener("resize", b), () => window.removeEventListener("resize", b);
|
|
415
|
+
}, []);
|
|
416
|
+
const X = m.data, Z = He(t.bind), Q = jt(t), z = Pe.useMemo(() => X && Array.isArray(X) ? {
|
|
298
417
|
provider: "value",
|
|
299
|
-
items:
|
|
300
|
-
} :
|
|
418
|
+
items: X
|
|
419
|
+
} : Z && Array.isArray(Z) ? {
|
|
301
420
|
provider: "value",
|
|
302
|
-
items:
|
|
303
|
-
} :
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
return JSON.stringify(
|
|
308
|
-
}),
|
|
309
|
-
}, [
|
|
310
|
-
if (
|
|
311
|
-
let
|
|
421
|
+
items: Z
|
|
422
|
+
} : Q, [JSON.stringify(Q), Z, X]), U = z?.provider === "value", P = z?.provider === "object" && z && "object" in z ? z.object : t.objectName, W = t.fields, V = t.columns, H = t.filter, Y = t.sort, ie = t.pagination, r = t.pageSize;
|
|
423
|
+
re(() => {
|
|
424
|
+
U && z?.provider === "value" && (v((b) => {
|
|
425
|
+
const E = z.items;
|
|
426
|
+
return JSON.stringify(b) !== JSON.stringify(E) ? E : b;
|
|
427
|
+
}), d(!1));
|
|
428
|
+
}, [U, z]), re(() => {
|
|
429
|
+
if (U) return;
|
|
430
|
+
let b = !1;
|
|
312
431
|
return (async () => {
|
|
313
|
-
|
|
432
|
+
d(!0), x(null);
|
|
314
433
|
try {
|
|
315
|
-
let
|
|
316
|
-
if ((
|
|
317
|
-
|
|
318
|
-
else if (
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
|
|
322
|
-
} else throw
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
434
|
+
let M = null;
|
|
435
|
+
if ((Te(V) || W) && P)
|
|
436
|
+
M = { name: P, fields: {} };
|
|
437
|
+
else if (P && c) {
|
|
438
|
+
const p = await c.getObjectSchema(P);
|
|
439
|
+
if (b) return;
|
|
440
|
+
M = p;
|
|
441
|
+
} else throw P ? new Error("DataSource required") : new Error("Object name required for data fetching");
|
|
442
|
+
if (b || R(M), c && P) {
|
|
443
|
+
const I = {
|
|
325
444
|
$select: (() => {
|
|
326
|
-
if (
|
|
327
|
-
if (
|
|
328
|
-
return
|
|
445
|
+
if (W) return W;
|
|
446
|
+
if (V && Array.isArray(V))
|
|
447
|
+
return V.map((T) => typeof T == "string" ? T : T.field);
|
|
329
448
|
})(),
|
|
330
|
-
$top:
|
|
449
|
+
$top: ie?.pageSize || r || 50
|
|
331
450
|
};
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
335
|
-
|
|
451
|
+
H && Array.isArray(H) ? I.$filter = H : t.defaultFilters && (I.$filter = t.defaultFilters), Y ? typeof Y == "string" ? I.$orderby = Y : Array.isArray(Y) && (I.$orderby = Y.map((T) => `${T.field} ${T.order}`).join(", ")) : t.defaultSort && (I.$orderby = `${t.defaultSort.field} ${t.defaultSort.order}`);
|
|
452
|
+
const oe = await c.find(P, I);
|
|
453
|
+
if (b) return;
|
|
454
|
+
v(oe.data || []);
|
|
336
455
|
}
|
|
337
|
-
} catch (
|
|
338
|
-
|
|
456
|
+
} catch (M) {
|
|
457
|
+
b || x(M);
|
|
339
458
|
} finally {
|
|
340
|
-
|
|
459
|
+
b || d(!1);
|
|
341
460
|
}
|
|
342
461
|
})(), () => {
|
|
343
|
-
|
|
462
|
+
b = !0;
|
|
344
463
|
};
|
|
345
|
-
}, [
|
|
346
|
-
const
|
|
347
|
-
navigation:
|
|
348
|
-
objectName:
|
|
349
|
-
onNavigate:
|
|
464
|
+
}, [P, W, V, H, Y, ie, r, c, U, z, A]);
|
|
465
|
+
const h = Je({
|
|
466
|
+
navigation: t.navigation,
|
|
467
|
+
objectName: t.objectName,
|
|
468
|
+
onNavigate: t.onNavigate,
|
|
350
469
|
onRowClick: i
|
|
351
|
-
}), { execute:
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
354
|
-
if (
|
|
355
|
-
const w =
|
|
470
|
+
}), { execute: j } = Xe(), C = xt(t.rowColor), { groups: ee, isGrouped: te, toggleGroup: O } = wt(t.grouping, f), G = $(() => {
|
|
471
|
+
const b = Te(V);
|
|
472
|
+
if (b) {
|
|
473
|
+
if (b.length > 0 && typeof b[0] == "object" && b[0] !== null) {
|
|
474
|
+
const w = b[0];
|
|
356
475
|
if ("accessorKey" in w)
|
|
357
|
-
return
|
|
476
|
+
return b;
|
|
358
477
|
if ("field" in w)
|
|
359
|
-
return
|
|
360
|
-
const
|
|
361
|
-
let
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
return /* @__PURE__ */
|
|
478
|
+
return b.filter((p) => p?.field && typeof p.field == "string" && !p.hidden).map((p, I) => {
|
|
479
|
+
const oe = p.label || p.field.charAt(0).toUpperCase() + p.field.slice(1).replace(/_/g, " ");
|
|
480
|
+
let T;
|
|
481
|
+
const B = p.type ? Oe(p.type) : null;
|
|
482
|
+
p.link && p.action ? T = (N, le) => {
|
|
483
|
+
const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
|
|
484
|
+
return /* @__PURE__ */ a.jsx(
|
|
366
485
|
"button",
|
|
367
486
|
{
|
|
368
487
|
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: (
|
|
371
|
-
|
|
488
|
+
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
489
|
+
onClick: (ce) => {
|
|
490
|
+
ce.stopPropagation(), h.handleClick(le);
|
|
372
491
|
},
|
|
373
|
-
children:
|
|
492
|
+
children: ae
|
|
374
493
|
}
|
|
375
494
|
);
|
|
376
|
-
} :
|
|
377
|
-
const
|
|
378
|
-
return /* @__PURE__ */
|
|
495
|
+
} : p.link ? T = (N, le) => {
|
|
496
|
+
const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
|
|
497
|
+
return /* @__PURE__ */ a.jsx(
|
|
379
498
|
"button",
|
|
380
499
|
{
|
|
381
500
|
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: (
|
|
384
|
-
|
|
501
|
+
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
502
|
+
onClick: (ce) => {
|
|
503
|
+
ce.stopPropagation(), h.handleClick(le);
|
|
385
504
|
},
|
|
386
|
-
children:
|
|
505
|
+
children: ae
|
|
387
506
|
}
|
|
388
507
|
);
|
|
389
|
-
} :
|
|
390
|
-
const
|
|
391
|
-
return /* @__PURE__ */
|
|
508
|
+
} : p.action ? T = (N, le) => {
|
|
509
|
+
const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
|
|
510
|
+
return /* @__PURE__ */ a.jsx(
|
|
392
511
|
"button",
|
|
393
512
|
{
|
|
394
513
|
type: "button",
|
|
395
514
|
className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
396
|
-
onClick: (
|
|
397
|
-
|
|
398
|
-
type:
|
|
399
|
-
params: { record:
|
|
515
|
+
onClick: (ce) => {
|
|
516
|
+
ce.stopPropagation(), j({
|
|
517
|
+
type: p.action,
|
|
518
|
+
params: { record: le, field: p.field, value: N }
|
|
400
519
|
});
|
|
401
520
|
},
|
|
402
|
-
children:
|
|
521
|
+
children: ae
|
|
403
522
|
}
|
|
404
523
|
);
|
|
405
|
-
} :
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
...
|
|
412
|
-
...
|
|
413
|
-
|
|
524
|
+
} : B ? T = (N) => /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : T = (N) => N != null && N !== "" ? /* @__PURE__ */ a.jsx("span", { children: String(N) }) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
|
|
525
|
+
const Ue = ["number", "currency", "percent"], je = p.align || (p.type && Ue.includes(p.type) ? "right" : void 0), qe = I === 0 || p.essential === !0;
|
|
526
|
+
return {
|
|
527
|
+
header: oe,
|
|
528
|
+
accessorKey: p.field,
|
|
529
|
+
...!qe && { className: "hidden sm:table-cell" },
|
|
530
|
+
...p.width && { width: p.width },
|
|
531
|
+
...je && { align: je },
|
|
532
|
+
sortable: p.sortable !== !1,
|
|
533
|
+
...p.resizable !== void 0 && { resizable: p.resizable },
|
|
534
|
+
...p.wrap !== void 0 && { wrap: p.wrap },
|
|
535
|
+
...T && { cell: T }
|
|
414
536
|
};
|
|
415
537
|
});
|
|
416
538
|
}
|
|
417
|
-
return
|
|
418
|
-
header:
|
|
539
|
+
return b.filter((w) => typeof w == "string" && w.trim().length > 0).map((w) => ({
|
|
540
|
+
header: S?.fields?.[w]?.label || w.charAt(0).toUpperCase() + w.slice(1).replace(/_/g, " "),
|
|
419
541
|
accessorKey: w
|
|
420
542
|
}));
|
|
421
543
|
}
|
|
422
|
-
if (
|
|
423
|
-
const w =
|
|
544
|
+
if (U) {
|
|
545
|
+
const w = z?.provider === "value" ? z.items : [];
|
|
424
546
|
if (w.length > 0)
|
|
425
|
-
return (
|
|
426
|
-
header:
|
|
427
|
-
accessorKey:
|
|
547
|
+
return (W || Object.keys(w[0])).map((I) => ({
|
|
548
|
+
header: I.charAt(0).toUpperCase() + I.slice(1).replace(/_/g, " "),
|
|
549
|
+
accessorKey: I
|
|
428
550
|
}));
|
|
429
551
|
}
|
|
430
|
-
if (!
|
|
431
|
-
const
|
|
432
|
-
return (
|
|
433
|
-
const
|
|
434
|
-
if (!
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
header:
|
|
552
|
+
if (!S) return [];
|
|
553
|
+
const E = [];
|
|
554
|
+
return (W || Object.keys(S.fields || {})).forEach((w) => {
|
|
555
|
+
const p = S.fields?.[w];
|
|
556
|
+
if (!p || p.permissions && p.permissions.read === !1) return;
|
|
557
|
+
const I = Oe(p.type), oe = ["number", "currency", "percent"];
|
|
558
|
+
E.push({
|
|
559
|
+
header: p.label || w,
|
|
438
560
|
accessorKey: w,
|
|
439
|
-
|
|
440
|
-
|
|
561
|
+
...oe.includes(p.type) && { align: "right" },
|
|
562
|
+
cell: (T) => /* @__PURE__ */ a.jsx(I, { value: T, field: p }),
|
|
563
|
+
sortable: p.sortable !== !1
|
|
441
564
|
});
|
|
442
|
-
}),
|
|
443
|
-
}, [
|
|
444
|
-
if (
|
|
445
|
-
return /* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */
|
|
447
|
-
/* @__PURE__ */
|
|
565
|
+
}), E;
|
|
566
|
+
}, [S, W, V, z, U, h.handleClick, j]);
|
|
567
|
+
if (y)
|
|
568
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
569
|
+
/* @__PURE__ */ a.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
|
|
570
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-red-600 text-sm mt-1", children: y.message })
|
|
448
571
|
] });
|
|
449
|
-
if (
|
|
450
|
-
return /* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
572
|
+
if (u && f.length === 0)
|
|
573
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "p-4 sm:p-8 text-center", children: [
|
|
574
|
+
/* @__PURE__ */ a.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
575
|
+
/* @__PURE__ */ a.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading grid..." })
|
|
453
576
|
] });
|
|
454
|
-
const
|
|
455
|
-
...
|
|
577
|
+
const ne = G(), q = "operations" in t ? t.operations : void 0, ye = q && (q.update || q.delete), We = ye ? [
|
|
578
|
+
...ne,
|
|
456
579
|
{
|
|
457
580
|
header: "Actions",
|
|
458
581
|
accessorKey: "_actions",
|
|
459
|
-
cell: (
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
462
|
-
/* @__PURE__ */
|
|
582
|
+
cell: (b, E) => /* @__PURE__ */ a.jsxs(Qe, { children: [
|
|
583
|
+
/* @__PURE__ */ a.jsx(et, { asChild: !0, children: /* @__PURE__ */ a.jsxs(tt, { variant: "ghost", size: "icon", className: "h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0", children: [
|
|
584
|
+
/* @__PURE__ */ a.jsx(st, { className: "h-4 w-4" }),
|
|
585
|
+
/* @__PURE__ */ a.jsx("span", { className: "sr-only", children: "Open menu" })
|
|
463
586
|
] }) }),
|
|
464
|
-
/* @__PURE__ */
|
|
465
|
-
|
|
466
|
-
/* @__PURE__ */
|
|
587
|
+
/* @__PURE__ */ a.jsxs(nt, { align: "end", children: [
|
|
588
|
+
q?.update && e && /* @__PURE__ */ a.jsxs(Ne, { onClick: () => e(E), children: [
|
|
589
|
+
/* @__PURE__ */ a.jsx(rt, { className: "mr-2 h-4 w-4" }),
|
|
467
590
|
"Edit"
|
|
468
591
|
] }),
|
|
469
|
-
|
|
470
|
-
/* @__PURE__ */
|
|
592
|
+
q?.delete && n && /* @__PURE__ */ a.jsxs(Ne, { onClick: () => n(E), children: [
|
|
593
|
+
/* @__PURE__ */ a.jsx(it, { className: "mr-2 h-4 w-4" }),
|
|
471
594
|
"Delete"
|
|
472
595
|
] })
|
|
473
596
|
] })
|
|
474
597
|
] }),
|
|
475
598
|
sortable: !1
|
|
476
599
|
}
|
|
477
|
-
] :
|
|
478
|
-
let
|
|
479
|
-
|
|
480
|
-
const
|
|
600
|
+
] : ne;
|
|
601
|
+
let be = !1;
|
|
602
|
+
t.selection?.type ? be = t.selection.type === "none" ? !1 : t.selection.type : t.selectable !== void 0 && (be = t.selectable);
|
|
603
|
+
const Ve = t.pagination !== void 0 ? !0 : t.showPagination !== void 0 ? t.showPagination : !0, Ye = t.pagination?.pageSize || t.pageSize || 10, Ge = t.searchableFields !== void 0 ? t.searchableFields.length > 0 : t.showSearch !== void 0 ? t.showSearch : !0, Ee = {
|
|
481
604
|
type: "data-table",
|
|
482
|
-
caption:
|
|
483
|
-
columns:
|
|
484
|
-
data:
|
|
485
|
-
pagination:
|
|
486
|
-
pageSize:
|
|
487
|
-
searchable:
|
|
488
|
-
selectable:
|
|
605
|
+
caption: t.label || t.title,
|
|
606
|
+
columns: We,
|
|
607
|
+
data: f,
|
|
608
|
+
pagination: Ve,
|
|
609
|
+
pageSize: Ye,
|
|
610
|
+
searchable: Ge,
|
|
611
|
+
selectable: be,
|
|
489
612
|
sortable: !0,
|
|
490
|
-
exportable:
|
|
491
|
-
rowActions:
|
|
492
|
-
resizableColumns:
|
|
493
|
-
reorderableColumns:
|
|
494
|
-
editable:
|
|
495
|
-
className:
|
|
496
|
-
|
|
497
|
-
|
|
613
|
+
exportable: q?.export,
|
|
614
|
+
rowActions: ye,
|
|
615
|
+
resizableColumns: t.resizable ?? t.resizableColumns ?? !0,
|
|
616
|
+
reorderableColumns: t.reorderableColumns ?? !1,
|
|
617
|
+
editable: t.editable ?? !1,
|
|
618
|
+
className: t.className,
|
|
619
|
+
cellClassName: "px-2 py-1.5 sm:px-3 sm:py-2 md:px-4 md:py-2.5",
|
|
620
|
+
rowClassName: t.rowColor ? (b, E) => C(b) : void 0,
|
|
621
|
+
onSelectionChange: s,
|
|
622
|
+
onRowClick: h.handleClick,
|
|
498
623
|
onCellChange: o,
|
|
499
624
|
onRowSave: l,
|
|
500
|
-
onBatchSave:
|
|
501
|
-
},
|
|
502
|
-
|
|
503
|
-
|
|
625
|
+
onBatchSave: g
|
|
626
|
+
}, Ke = (b) => ({
|
|
627
|
+
...Ee,
|
|
628
|
+
caption: void 0,
|
|
629
|
+
data: b,
|
|
630
|
+
pagination: !1,
|
|
631
|
+
searchable: !1
|
|
632
|
+
}), xe = t.label ? `${t.label} Detail` : t.objectName ? `${t.objectName.charAt(0).toUpperCase() + t.objectName.slice(1)} Detail` : "Record Detail";
|
|
633
|
+
if (_ && f.length > 0 && !te) {
|
|
634
|
+
const b = G().filter((E) => E.accessorKey !== "_actions");
|
|
635
|
+
return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
636
|
+
/* @__PURE__ */ a.jsx("div", { className: "space-y-2 p-2", children: f.map((E, M) => /* @__PURE__ */ a.jsx(
|
|
637
|
+
"div",
|
|
638
|
+
{
|
|
639
|
+
className: "border rounded-lg p-3 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
|
|
640
|
+
onClick: () => h.handleClick(E),
|
|
641
|
+
children: b.slice(0, 4).map((w) => /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center py-1", children: [
|
|
642
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-xs text-muted-foreground", children: w.header }),
|
|
643
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-sm font-medium truncate ml-2 text-right", children: w.cell ? w.cell(E[w.accessorKey], E) : String(E[w.accessorKey] ?? "—") })
|
|
644
|
+
] }, w.accessorKey))
|
|
645
|
+
},
|
|
646
|
+
E.id || E._id || M
|
|
647
|
+
)) }),
|
|
648
|
+
h.isOverlay && /* @__PURE__ */ a.jsx(ve, { ...h, title: xe, children: (E) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(E).map(([M, w]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
|
|
649
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: M.replace(/_/g, " ") }),
|
|
650
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(w ?? "—") })
|
|
651
|
+
] }, M)) }) })
|
|
652
|
+
] });
|
|
653
|
+
}
|
|
654
|
+
const we = te ? /* @__PURE__ */ a.jsx("div", { className: "space-y-2", children: ee.map((b) => /* @__PURE__ */ a.jsxs("div", { className: "border rounded-md", children: [
|
|
655
|
+
/* @__PURE__ */ a.jsxs(
|
|
656
|
+
"button",
|
|
657
|
+
{
|
|
658
|
+
type: "button",
|
|
659
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors",
|
|
660
|
+
onClick: () => O(b.key),
|
|
661
|
+
children: [
|
|
662
|
+
b.collapsed ? /* @__PURE__ */ a.jsx(ot, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ a.jsx(lt, { className: "h-4 w-4 shrink-0" }),
|
|
663
|
+
/* @__PURE__ */ a.jsx("span", { children: b.label }),
|
|
664
|
+
/* @__PURE__ */ a.jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: b.rows.length })
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
),
|
|
668
|
+
!b.collapsed && /* @__PURE__ */ a.jsx(Ce, { schema: Ke(b.rows) })
|
|
669
|
+
] }, b.key)) }) : /* @__PURE__ */ a.jsx(Ce, { schema: Ee });
|
|
670
|
+
return h.isOverlay && h.mode === "split" ? /* @__PURE__ */ a.jsx(
|
|
671
|
+
ve,
|
|
504
672
|
{
|
|
505
|
-
...
|
|
506
|
-
title:
|
|
507
|
-
mainContent:
|
|
508
|
-
children: (
|
|
509
|
-
/* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
] },
|
|
673
|
+
...h,
|
|
674
|
+
title: xe,
|
|
675
|
+
mainContent: we,
|
|
676
|
+
children: (b) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(b).map(([E, M]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
|
|
677
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: E.replace(/_/g, " ") }),
|
|
678
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(M ?? "—") })
|
|
679
|
+
] }, E)) })
|
|
512
680
|
}
|
|
513
|
-
) : /* @__PURE__ */
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
|
|
516
|
-
|
|
681
|
+
) : /* @__PURE__ */ a.jsxs("div", { ref: L, className: "relative h-full", children: [
|
|
682
|
+
J > 0 && /* @__PURE__ */ a.jsx(
|
|
683
|
+
"div",
|
|
684
|
+
{
|
|
685
|
+
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
686
|
+
style: { height: J },
|
|
687
|
+
children: ge ? "Refreshing…" : "Pull to refresh"
|
|
688
|
+
}
|
|
689
|
+
),
|
|
690
|
+
we,
|
|
691
|
+
h.isOverlay && /* @__PURE__ */ a.jsx(
|
|
692
|
+
ve,
|
|
517
693
|
{
|
|
518
|
-
...
|
|
519
|
-
title:
|
|
520
|
-
children: (
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
] },
|
|
694
|
+
...h,
|
|
695
|
+
title: xe,
|
|
696
|
+
children: (b) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(b).map(([E, M]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
|
|
697
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: E.replace(/_/g, " ") }),
|
|
698
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(M ?? "—") })
|
|
699
|
+
] }, E)) })
|
|
524
700
|
}
|
|
525
701
|
)
|
|
526
702
|
] });
|
|
527
703
|
};
|
|
528
|
-
function
|
|
529
|
-
let
|
|
704
|
+
function se(t, c, e) {
|
|
705
|
+
let n = e.initialDeps ?? [], s, i = !0;
|
|
530
706
|
function o() {
|
|
531
|
-
var l,
|
|
532
|
-
let
|
|
533
|
-
e.key && ((l = e.debug) != null && l.call(e)) && (
|
|
534
|
-
const
|
|
535
|
-
if (!(
|
|
536
|
-
return
|
|
537
|
-
|
|
538
|
-
let
|
|
539
|
-
if (e.key && ((
|
|
540
|
-
const
|
|
541
|
-
for (
|
|
542
|
-
|
|
543
|
-
return
|
|
707
|
+
var l, g, m;
|
|
708
|
+
let f;
|
|
709
|
+
e.key && ((l = e.debug) != null && l.call(e)) && (f = Date.now());
|
|
710
|
+
const v = t();
|
|
711
|
+
if (!(v.length !== n.length || v.some((y, x) => n[x] !== y)))
|
|
712
|
+
return s;
|
|
713
|
+
n = v;
|
|
714
|
+
let d;
|
|
715
|
+
if (e.key && ((g = e.debug) != null && g.call(e)) && (d = Date.now()), s = c(...v), e.key && ((m = e.debug) != null && m.call(e))) {
|
|
716
|
+
const y = Math.round((Date.now() - f) * 100) / 100, x = Math.round((Date.now() - d) * 100) / 100, S = x / 16, R = (_, F) => {
|
|
717
|
+
for (_ = String(_); _.length < F; )
|
|
718
|
+
_ = " " + _;
|
|
719
|
+
return _;
|
|
544
720
|
};
|
|
545
721
|
console.info(
|
|
546
|
-
`%c⏱ ${
|
|
722
|
+
`%c⏱ ${R(x, 5)} /${R(y, 5)} ms`,
|
|
547
723
|
`
|
|
548
724
|
font-size: .6rem;
|
|
549
725
|
font-weight: bold;
|
|
550
726
|
color: hsl(${Math.max(
|
|
551
727
|
0,
|
|
552
|
-
Math.min(120 - 120 *
|
|
728
|
+
Math.min(120 - 120 * S, 120)
|
|
553
729
|
)}deg 100% 31%);`,
|
|
554
730
|
e?.key
|
|
555
731
|
);
|
|
556
732
|
}
|
|
557
|
-
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(
|
|
733
|
+
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(s), i = !1, s;
|
|
558
734
|
}
|
|
559
735
|
return o.updateDeps = (l) => {
|
|
560
|
-
|
|
736
|
+
n = l;
|
|
561
737
|
}, o;
|
|
562
738
|
}
|
|
563
|
-
function
|
|
564
|
-
if (
|
|
739
|
+
function Ae(t, c) {
|
|
740
|
+
if (t === void 0)
|
|
565
741
|
throw new Error("Unexpected undefined");
|
|
566
|
-
return
|
|
742
|
+
return t;
|
|
567
743
|
}
|
|
568
|
-
const
|
|
569
|
-
let
|
|
570
|
-
return function(...
|
|
571
|
-
|
|
744
|
+
const Ct = (t, c) => Math.abs(t - c) < 1.01, Ot = (t, c, e) => {
|
|
745
|
+
let n;
|
|
746
|
+
return function(...s) {
|
|
747
|
+
t.clearTimeout(n), n = t.setTimeout(() => c.apply(this, s), e);
|
|
572
748
|
};
|
|
573
|
-
},
|
|
574
|
-
const { offsetWidth:
|
|
575
|
-
return { width:
|
|
576
|
-
},
|
|
577
|
-
const
|
|
578
|
-
for (let
|
|
579
|
-
|
|
580
|
-
return
|
|
581
|
-
},
|
|
582
|
-
const e =
|
|
749
|
+
}, ze = (t) => {
|
|
750
|
+
const { offsetWidth: c, offsetHeight: e } = t;
|
|
751
|
+
return { width: c, height: e };
|
|
752
|
+
}, Nt = (t) => t, _t = (t) => {
|
|
753
|
+
const c = Math.max(t.startIndex - t.overscan, 0), e = Math.min(t.endIndex + t.overscan, t.count - 1), n = [];
|
|
754
|
+
for (let s = c; s <= e; s++)
|
|
755
|
+
n.push(s);
|
|
756
|
+
return n;
|
|
757
|
+
}, Rt = (t, c) => {
|
|
758
|
+
const e = t.scrollElement;
|
|
583
759
|
if (!e)
|
|
584
760
|
return;
|
|
585
|
-
const
|
|
586
|
-
if (!
|
|
761
|
+
const n = t.targetWindow;
|
|
762
|
+
if (!n)
|
|
587
763
|
return;
|
|
588
|
-
const
|
|
589
|
-
const { width: l, height:
|
|
590
|
-
|
|
764
|
+
const s = (o) => {
|
|
765
|
+
const { width: l, height: g } = o;
|
|
766
|
+
c({ width: Math.round(l), height: Math.round(g) });
|
|
591
767
|
};
|
|
592
|
-
if (
|
|
768
|
+
if (s(ze(e)), !n.ResizeObserver)
|
|
593
769
|
return () => {
|
|
594
770
|
};
|
|
595
|
-
const i = new
|
|
771
|
+
const i = new n.ResizeObserver((o) => {
|
|
596
772
|
const l = () => {
|
|
597
|
-
const
|
|
598
|
-
if (
|
|
599
|
-
const
|
|
600
|
-
if (
|
|
601
|
-
|
|
773
|
+
const g = o[0];
|
|
774
|
+
if (g?.borderBoxSize) {
|
|
775
|
+
const m = g.borderBoxSize[0];
|
|
776
|
+
if (m) {
|
|
777
|
+
s({ width: m.inlineSize, height: m.blockSize });
|
|
602
778
|
return;
|
|
603
779
|
}
|
|
604
780
|
}
|
|
605
|
-
|
|
781
|
+
s(ze(e));
|
|
606
782
|
};
|
|
607
|
-
|
|
783
|
+
t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
|
|
608
784
|
});
|
|
609
785
|
return i.observe(e, { box: "border-box" }), () => {
|
|
610
786
|
i.unobserve(e);
|
|
611
787
|
};
|
|
612
|
-
},
|
|
788
|
+
}, Me = {
|
|
613
789
|
passive: !0
|
|
614
|
-
},
|
|
615
|
-
const e =
|
|
790
|
+
}, Ie = typeof window > "u" ? !0 : "onscrollend" in window, kt = (t, c) => {
|
|
791
|
+
const e = t.scrollElement;
|
|
616
792
|
if (!e)
|
|
617
793
|
return;
|
|
618
|
-
const
|
|
619
|
-
if (!
|
|
794
|
+
const n = t.targetWindow;
|
|
795
|
+
if (!n)
|
|
620
796
|
return;
|
|
621
|
-
let
|
|
622
|
-
const i =
|
|
623
|
-
} :
|
|
624
|
-
|
|
797
|
+
let s = 0;
|
|
798
|
+
const i = t.options.useScrollendEvent && Ie ? () => {
|
|
799
|
+
} : Ot(
|
|
800
|
+
n,
|
|
625
801
|
() => {
|
|
626
|
-
|
|
802
|
+
c(s, !1);
|
|
627
803
|
},
|
|
628
|
-
|
|
629
|
-
), o = (
|
|
630
|
-
const { horizontal:
|
|
631
|
-
|
|
632
|
-
}, l = o(!0),
|
|
633
|
-
e.addEventListener("scroll", l,
|
|
634
|
-
const
|
|
635
|
-
return
|
|
636
|
-
e.removeEventListener("scroll", l),
|
|
804
|
+
t.options.isScrollingResetDelay
|
|
805
|
+
), o = (f) => () => {
|
|
806
|
+
const { horizontal: v, isRtl: u } = t.options;
|
|
807
|
+
s = v ? e.scrollLeft * (u && -1 || 1) : e.scrollTop, i(), c(s, f);
|
|
808
|
+
}, l = o(!0), g = o(!1);
|
|
809
|
+
e.addEventListener("scroll", l, Me);
|
|
810
|
+
const m = t.options.useScrollendEvent && Ie;
|
|
811
|
+
return m && e.addEventListener("scrollend", g, Me), () => {
|
|
812
|
+
e.removeEventListener("scroll", l), m && e.removeEventListener("scrollend", g);
|
|
637
813
|
};
|
|
638
|
-
},
|
|
639
|
-
if (
|
|
640
|
-
const
|
|
641
|
-
if (
|
|
814
|
+
}, Tt = (t, c, e) => {
|
|
815
|
+
if (c?.borderBoxSize) {
|
|
816
|
+
const n = c.borderBoxSize[0];
|
|
817
|
+
if (n)
|
|
642
818
|
return Math.round(
|
|
643
|
-
|
|
819
|
+
n[e.options.horizontal ? "inlineSize" : "blockSize"]
|
|
644
820
|
);
|
|
645
821
|
}
|
|
646
|
-
return
|
|
647
|
-
},
|
|
648
|
-
adjustments:
|
|
822
|
+
return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
823
|
+
}, At = (t, {
|
|
824
|
+
adjustments: c = 0,
|
|
649
825
|
behavior: e
|
|
650
|
-
},
|
|
651
|
-
var
|
|
652
|
-
const o =
|
|
653
|
-
(i = (
|
|
654
|
-
[
|
|
826
|
+
}, n) => {
|
|
827
|
+
var s, i;
|
|
828
|
+
const o = t + c;
|
|
829
|
+
(i = (s = n.scrollElement) == null ? void 0 : s.scrollTo) == null || i.call(s, {
|
|
830
|
+
[n.options.horizontal ? "left" : "top"]: o,
|
|
655
831
|
behavior: e
|
|
656
832
|
});
|
|
657
833
|
};
|
|
658
|
-
class
|
|
659
|
-
constructor(
|
|
834
|
+
class zt {
|
|
835
|
+
constructor(c) {
|
|
660
836
|
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
837
|
let e = null;
|
|
662
|
-
const
|
|
663
|
-
|
|
838
|
+
const n = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
|
|
839
|
+
s.forEach((i) => {
|
|
664
840
|
const o = () => {
|
|
665
841
|
this._measureElement(i.target, i);
|
|
666
842
|
};
|
|
@@ -669,21 +845,21 @@ class Qe {
|
|
|
669
845
|
}));
|
|
670
846
|
return {
|
|
671
847
|
disconnect: () => {
|
|
672
|
-
var
|
|
673
|
-
(
|
|
848
|
+
var s;
|
|
849
|
+
(s = n()) == null || s.disconnect(), e = null;
|
|
674
850
|
},
|
|
675
|
-
observe: (
|
|
851
|
+
observe: (s) => {
|
|
676
852
|
var i;
|
|
677
|
-
return (i =
|
|
853
|
+
return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
|
|
678
854
|
},
|
|
679
|
-
unobserve: (
|
|
855
|
+
unobserve: (s) => {
|
|
680
856
|
var i;
|
|
681
|
-
return (i =
|
|
857
|
+
return (i = n()) == null ? void 0 : i.unobserve(s);
|
|
682
858
|
}
|
|
683
859
|
};
|
|
684
860
|
})(), this.range = null, this.setOptions = (e) => {
|
|
685
|
-
Object.entries(e).forEach(([
|
|
686
|
-
typeof
|
|
861
|
+
Object.entries(e).forEach(([n, s]) => {
|
|
862
|
+
typeof s > "u" && delete e[n];
|
|
687
863
|
}), this.options = {
|
|
688
864
|
debug: !1,
|
|
689
865
|
initialOffset: 0,
|
|
@@ -693,11 +869,11 @@ class Qe {
|
|
|
693
869
|
scrollPaddingStart: 0,
|
|
694
870
|
scrollPaddingEnd: 0,
|
|
695
871
|
horizontal: !1,
|
|
696
|
-
getItemKey:
|
|
697
|
-
rangeExtractor:
|
|
872
|
+
getItemKey: Nt,
|
|
873
|
+
rangeExtractor: _t,
|
|
698
874
|
onChange: () => {
|
|
699
875
|
},
|
|
700
|
-
measureElement:
|
|
876
|
+
measureElement: Tt,
|
|
701
877
|
initialRect: { width: 0, height: 0 },
|
|
702
878
|
scrollMargin: 0,
|
|
703
879
|
gap: 0,
|
|
@@ -712,9 +888,9 @@ class Qe {
|
|
|
712
888
|
...e
|
|
713
889
|
};
|
|
714
890
|
}, this.notify = (e) => {
|
|
715
|
-
var
|
|
716
|
-
(
|
|
717
|
-
}, this.maybeNotify =
|
|
891
|
+
var n, s;
|
|
892
|
+
(s = (n = this.options).onChange) == null || s.call(n, this, e);
|
|
893
|
+
}, this.maybeNotify = se(
|
|
718
894
|
() => (this.calculateRange(), [
|
|
719
895
|
this.isScrolling,
|
|
720
896
|
this.range ? this.range.startIndex : null,
|
|
@@ -738,41 +914,41 @@ class Qe {
|
|
|
738
914
|
this.cleanup();
|
|
739
915
|
}, this._willUpdate = () => {
|
|
740
916
|
var e;
|
|
741
|
-
const
|
|
742
|
-
if (this.scrollElement !==
|
|
743
|
-
if (this.cleanup(), !
|
|
917
|
+
const n = this.options.enabled ? this.options.getScrollElement() : null;
|
|
918
|
+
if (this.scrollElement !== n) {
|
|
919
|
+
if (this.cleanup(), !n) {
|
|
744
920
|
this.maybeNotify();
|
|
745
921
|
return;
|
|
746
922
|
}
|
|
747
|
-
this.scrollElement =
|
|
748
|
-
this.observer.observe(
|
|
923
|
+
this.scrollElement = n, 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((s) => {
|
|
924
|
+
this.observer.observe(s);
|
|
749
925
|
}), this.unsubs.push(
|
|
750
|
-
this.options.observeElementRect(this, (
|
|
751
|
-
this.scrollRect =
|
|
926
|
+
this.options.observeElementRect(this, (s) => {
|
|
927
|
+
this.scrollRect = s, this.maybeNotify();
|
|
752
928
|
})
|
|
753
929
|
), this.unsubs.push(
|
|
754
|
-
this.options.observeElementOffset(this, (
|
|
755
|
-
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() <
|
|
930
|
+
this.options.observeElementOffset(this, (s, i) => {
|
|
931
|
+
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < s ? "forward" : "backward" : null, this.scrollOffset = s, this.isScrolling = i, this.maybeNotify();
|
|
756
932
|
})
|
|
757
933
|
), this._scrollToOffset(this.getScrollOffset(), {
|
|
758
934
|
adjustments: void 0,
|
|
759
935
|
behavior: void 0
|
|
760
936
|
});
|
|
761
937
|
}
|
|
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,
|
|
763
|
-
const
|
|
764
|
-
for (let o =
|
|
938
|
+
}, 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, n) => {
|
|
939
|
+
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
940
|
+
for (let o = n - 1; o >= 0; o--) {
|
|
765
941
|
const l = e[o];
|
|
766
|
-
if (
|
|
942
|
+
if (s.has(l.lane))
|
|
767
943
|
continue;
|
|
768
|
-
const
|
|
944
|
+
const g = i.get(
|
|
769
945
|
l.lane
|
|
770
946
|
);
|
|
771
|
-
if (
|
|
947
|
+
if (g == null || l.end > g.end ? i.set(l.lane, l) : l.end < g.end && s.set(l.lane, !0), s.size === this.options.lanes)
|
|
772
948
|
break;
|
|
773
949
|
}
|
|
774
950
|
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 =
|
|
951
|
+
}, this.getMeasurementOptions = se(
|
|
776
952
|
() => [
|
|
777
953
|
this.options.count,
|
|
778
954
|
this.options.paddingStart,
|
|
@@ -781,10 +957,10 @@ class Qe {
|
|
|
781
957
|
this.options.enabled,
|
|
782
958
|
this.options.lanes
|
|
783
959
|
],
|
|
784
|
-
(e,
|
|
960
|
+
(e, n, s, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
|
|
785
961
|
count: e,
|
|
786
|
-
paddingStart:
|
|
787
|
-
scrollMargin:
|
|
962
|
+
paddingStart: n,
|
|
963
|
+
scrollMargin: s,
|
|
788
964
|
getItemKey: i,
|
|
789
965
|
enabled: o,
|
|
790
966
|
lanes: l
|
|
@@ -792,142 +968,142 @@ class Qe {
|
|
|
792
968
|
{
|
|
793
969
|
key: !1
|
|
794
970
|
}
|
|
795
|
-
), this.getMeasurements =
|
|
971
|
+
), this.getMeasurements = se(
|
|
796
972
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
797
|
-
({ count: e, paddingStart:
|
|
973
|
+
({ count: e, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: o, lanes: l }, g) => {
|
|
798
974
|
if (!o)
|
|
799
975
|
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
800
976
|
if (this.laneAssignments.size > e)
|
|
801
|
-
for (const
|
|
802
|
-
|
|
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((
|
|
804
|
-
this.itemSizeCache.set(
|
|
977
|
+
for (const u of this.laneAssignments.keys())
|
|
978
|
+
u >= e && this.laneAssignments.delete(u);
|
|
979
|
+
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((u) => {
|
|
980
|
+
this.itemSizeCache.set(u.key, u.size);
|
|
805
981
|
}));
|
|
806
|
-
const
|
|
982
|
+
const m = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
807
983
|
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
|
|
808
|
-
const
|
|
984
|
+
const f = this.measurementsCache.slice(0, m), v = new Array(l).fill(
|
|
809
985
|
void 0
|
|
810
986
|
);
|
|
811
|
-
for (let
|
|
812
|
-
const
|
|
813
|
-
|
|
987
|
+
for (let u = 0; u < m; u++) {
|
|
988
|
+
const d = f[u];
|
|
989
|
+
d && (v[d.lane] = u);
|
|
814
990
|
}
|
|
815
|
-
for (let
|
|
816
|
-
const
|
|
817
|
-
let
|
|
818
|
-
if (
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
|
|
991
|
+
for (let u = m; u < e; u++) {
|
|
992
|
+
const d = i(u), y = this.laneAssignments.get(u);
|
|
993
|
+
let x, S;
|
|
994
|
+
if (y !== void 0 && this.options.lanes > 1) {
|
|
995
|
+
x = y;
|
|
996
|
+
const A = v[x], K = A !== void 0 ? f[A] : void 0;
|
|
997
|
+
S = K ? K.end + this.options.gap : n + s;
|
|
822
998
|
} else {
|
|
823
|
-
const
|
|
824
|
-
|
|
999
|
+
const A = this.options.lanes === 1 ? f[u - 1] : this.getFurthestMeasurement(f, u);
|
|
1000
|
+
S = A ? A.end + this.options.gap : n + s, x = A ? A.lane : u % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(u, x);
|
|
825
1001
|
}
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
index:
|
|
829
|
-
start:
|
|
830
|
-
size:
|
|
831
|
-
end:
|
|
832
|
-
key:
|
|
833
|
-
lane:
|
|
834
|
-
},
|
|
1002
|
+
const R = g.get(d), _ = typeof R == "number" ? R : this.options.estimateSize(u), F = S + _;
|
|
1003
|
+
f[u] = {
|
|
1004
|
+
index: u,
|
|
1005
|
+
start: S,
|
|
1006
|
+
size: _,
|
|
1007
|
+
end: F,
|
|
1008
|
+
key: d,
|
|
1009
|
+
lane: x
|
|
1010
|
+
}, v[x] = u;
|
|
835
1011
|
}
|
|
836
|
-
return this.measurementsCache =
|
|
1012
|
+
return this.measurementsCache = f, f;
|
|
837
1013
|
},
|
|
838
1014
|
{
|
|
839
1015
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
840
1016
|
debug: () => this.options.debug
|
|
841
1017
|
}
|
|
842
|
-
), this.calculateRange =
|
|
1018
|
+
), this.calculateRange = se(
|
|
843
1019
|
() => [
|
|
844
1020
|
this.getMeasurements(),
|
|
845
1021
|
this.getSize(),
|
|
846
1022
|
this.getScrollOffset(),
|
|
847
1023
|
this.options.lanes
|
|
848
1024
|
],
|
|
849
|
-
(e,
|
|
1025
|
+
(e, n, s, i) => this.range = e.length > 0 && n > 0 ? Mt({
|
|
850
1026
|
measurements: e,
|
|
851
|
-
outerSize:
|
|
852
|
-
scrollOffset:
|
|
1027
|
+
outerSize: n,
|
|
1028
|
+
scrollOffset: s,
|
|
853
1029
|
lanes: i
|
|
854
1030
|
}) : null,
|
|
855
1031
|
{
|
|
856
1032
|
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
857
1033
|
debug: () => this.options.debug
|
|
858
1034
|
}
|
|
859
|
-
), this.getVirtualIndexes =
|
|
1035
|
+
), this.getVirtualIndexes = se(
|
|
860
1036
|
() => {
|
|
861
|
-
let e = null,
|
|
862
|
-
const
|
|
863
|
-
return
|
|
1037
|
+
let e = null, n = null;
|
|
1038
|
+
const s = this.calculateRange();
|
|
1039
|
+
return s && (e = s.startIndex, n = s.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, n]), [
|
|
864
1040
|
this.options.rangeExtractor,
|
|
865
1041
|
this.options.overscan,
|
|
866
1042
|
this.options.count,
|
|
867
1043
|
e,
|
|
868
|
-
|
|
1044
|
+
n
|
|
869
1045
|
];
|
|
870
1046
|
},
|
|
871
|
-
(e,
|
|
1047
|
+
(e, n, s, i, o) => i === null || o === null ? [] : e({
|
|
872
1048
|
startIndex: i,
|
|
873
1049
|
endIndex: o,
|
|
874
|
-
overscan:
|
|
875
|
-
count:
|
|
1050
|
+
overscan: n,
|
|
1051
|
+
count: s
|
|
876
1052
|
}),
|
|
877
1053
|
{
|
|
878
1054
|
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
879
1055
|
debug: () => this.options.debug
|
|
880
1056
|
}
|
|
881
1057
|
), this.indexFromElement = (e) => {
|
|
882
|
-
const
|
|
883
|
-
return
|
|
884
|
-
`Missing attribute name '${
|
|
1058
|
+
const n = this.options.indexAttribute, s = e.getAttribute(n);
|
|
1059
|
+
return s ? parseInt(s, 10) : (console.warn(
|
|
1060
|
+
`Missing attribute name '${n}={index}' on measured element.`
|
|
885
1061
|
), -1);
|
|
886
|
-
}, this._measureElement = (e,
|
|
887
|
-
const
|
|
1062
|
+
}, this._measureElement = (e, n) => {
|
|
1063
|
+
const s = this.indexFromElement(e), i = this.measurementsCache[s];
|
|
888
1064
|
if (!i)
|
|
889
1065
|
return;
|
|
890
1066
|
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(
|
|
892
|
-
}, this.resizeItem = (e,
|
|
893
|
-
const
|
|
894
|
-
if (!
|
|
1067
|
+
l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(s, this.options.measureElement(e, n, this));
|
|
1068
|
+
}, this.resizeItem = (e, n) => {
|
|
1069
|
+
const s = this.measurementsCache[e];
|
|
1070
|
+
if (!s)
|
|
895
1071
|
return;
|
|
896
|
-
const i = this.itemSizeCache.get(
|
|
897
|
-
o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(
|
|
1072
|
+
const i = this.itemSizeCache.get(s.key) ?? s.size, o = n - i;
|
|
1073
|
+
o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(s, o, this) : s.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
|
|
898
1074
|
adjustments: this.scrollAdjustments += o,
|
|
899
1075
|
behavior: void 0
|
|
900
|
-
})), this.pendingMeasuredCacheIndexes.push(
|
|
1076
|
+
})), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
|
|
901
1077
|
}, this.measureElement = (e) => {
|
|
902
1078
|
if (!e) {
|
|
903
|
-
this.elementsCache.forEach((
|
|
904
|
-
|
|
1079
|
+
this.elementsCache.forEach((n, s) => {
|
|
1080
|
+
n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
|
|
905
1081
|
});
|
|
906
1082
|
return;
|
|
907
1083
|
}
|
|
908
1084
|
this._measureElement(e, void 0);
|
|
909
|
-
}, this.getVirtualItems =
|
|
1085
|
+
}, this.getVirtualItems = se(
|
|
910
1086
|
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
911
|
-
(e,
|
|
912
|
-
const
|
|
1087
|
+
(e, n) => {
|
|
1088
|
+
const s = [];
|
|
913
1089
|
for (let i = 0, o = e.length; i < o; i++) {
|
|
914
|
-
const l = e[i],
|
|
915
|
-
|
|
1090
|
+
const l = e[i], g = n[l];
|
|
1091
|
+
s.push(g);
|
|
916
1092
|
}
|
|
917
|
-
return
|
|
1093
|
+
return s;
|
|
918
1094
|
},
|
|
919
1095
|
{
|
|
920
1096
|
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
921
1097
|
debug: () => this.options.debug
|
|
922
1098
|
}
|
|
923
1099
|
), this.getVirtualItemForOffset = (e) => {
|
|
924
|
-
const
|
|
925
|
-
if (
|
|
926
|
-
return
|
|
927
|
-
|
|
1100
|
+
const n = this.getMeasurements();
|
|
1101
|
+
if (n.length !== 0)
|
|
1102
|
+
return Ae(
|
|
1103
|
+
n[Le(
|
|
928
1104
|
0,
|
|
929
|
-
|
|
930
|
-
(
|
|
1105
|
+
n.length - 1,
|
|
1106
|
+
(s) => Ae(n[s]).start,
|
|
931
1107
|
e
|
|
932
1108
|
)]
|
|
933
1109
|
);
|
|
@@ -939,280 +1115,420 @@ class Qe {
|
|
|
939
1115
|
const e = this.scrollElement.document.documentElement;
|
|
940
1116
|
return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
|
|
941
1117
|
}
|
|
942
|
-
}, this.getOffsetForAlignment = (e,
|
|
1118
|
+
}, this.getOffsetForAlignment = (e, n, s = 0) => {
|
|
943
1119
|
if (!this.scrollElement) return 0;
|
|
944
1120
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
945
|
-
|
|
1121
|
+
n === "auto" && (n = e >= o + i ? "end" : "start"), n === "center" ? e += (s - i) / 2 : n === "end" && (e -= i);
|
|
946
1122
|
const l = this.getMaxScrollOffset();
|
|
947
1123
|
return Math.max(Math.min(l, e), 0);
|
|
948
|
-
}, this.getOffsetForIndex = (e,
|
|
1124
|
+
}, this.getOffsetForIndex = (e, n = "auto") => {
|
|
949
1125
|
e = Math.max(0, Math.min(e, this.options.count - 1));
|
|
950
|
-
const
|
|
951
|
-
if (!
|
|
1126
|
+
const s = this.measurementsCache[e];
|
|
1127
|
+
if (!s)
|
|
952
1128
|
return;
|
|
953
1129
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
954
|
-
if (
|
|
955
|
-
if (
|
|
956
|
-
|
|
957
|
-
else if (
|
|
958
|
-
|
|
1130
|
+
if (n === "auto")
|
|
1131
|
+
if (s.end >= o + i - this.options.scrollPaddingEnd)
|
|
1132
|
+
n = "end";
|
|
1133
|
+
else if (s.start <= o + this.options.scrollPaddingStart)
|
|
1134
|
+
n = "start";
|
|
959
1135
|
else
|
|
960
|
-
return [o,
|
|
961
|
-
if (
|
|
962
|
-
return [this.getMaxScrollOffset(),
|
|
963
|
-
const l =
|
|
1136
|
+
return [o, n];
|
|
1137
|
+
if (n === "end" && e === this.options.count - 1)
|
|
1138
|
+
return [this.getMaxScrollOffset(), n];
|
|
1139
|
+
const l = n === "end" ? s.end + this.options.scrollPaddingEnd : s.start - this.options.scrollPaddingStart;
|
|
964
1140
|
return [
|
|
965
|
-
this.getOffsetForAlignment(l,
|
|
966
|
-
|
|
1141
|
+
this.getOffsetForAlignment(l, n, s.size),
|
|
1142
|
+
n
|
|
967
1143
|
];
|
|
968
|
-
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align:
|
|
969
|
-
|
|
1144
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: n = "start", behavior: s } = {}) => {
|
|
1145
|
+
s === "smooth" && this.isDynamicMode() && console.warn(
|
|
970
1146
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
971
|
-
), this._scrollToOffset(this.getOffsetForAlignment(e,
|
|
1147
|
+
), this._scrollToOffset(this.getOffsetForAlignment(e, n), {
|
|
972
1148
|
adjustments: void 0,
|
|
973
|
-
behavior:
|
|
1149
|
+
behavior: s
|
|
974
1150
|
});
|
|
975
|
-
}, this.scrollToIndex = (e, { align:
|
|
976
|
-
|
|
1151
|
+
}, this.scrollToIndex = (e, { align: n = "auto", behavior: s } = {}) => {
|
|
1152
|
+
s === "smooth" && this.isDynamicMode() && console.warn(
|
|
977
1153
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
978
1154
|
), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
|
|
979
1155
|
let i = 0;
|
|
980
|
-
const o = 10, l = (
|
|
1156
|
+
const o = 10, l = (m) => {
|
|
981
1157
|
if (!this.targetWindow) return;
|
|
982
|
-
const
|
|
983
|
-
if (!
|
|
1158
|
+
const f = this.getOffsetForIndex(e, m);
|
|
1159
|
+
if (!f) {
|
|
984
1160
|
console.warn("Failed to get offset for index:", e);
|
|
985
1161
|
return;
|
|
986
1162
|
}
|
|
987
|
-
const [
|
|
988
|
-
this._scrollToOffset(
|
|
989
|
-
const
|
|
1163
|
+
const [v, u] = f;
|
|
1164
|
+
this._scrollToOffset(v, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
|
|
1165
|
+
const d = () => {
|
|
990
1166
|
if (this.currentScrollToIndex !== e) return;
|
|
991
|
-
const
|
|
992
|
-
if (!
|
|
1167
|
+
const y = this.getScrollOffset(), x = this.getOffsetForIndex(e, u);
|
|
1168
|
+
if (!x) {
|
|
993
1169
|
console.warn("Failed to get offset for index:", e);
|
|
994
1170
|
return;
|
|
995
1171
|
}
|
|
996
|
-
|
|
1172
|
+
Ct(x[0], y) || g(u);
|
|
997
1173
|
};
|
|
998
|
-
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(
|
|
1174
|
+
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(d) : d();
|
|
999
1175
|
});
|
|
1000
|
-
},
|
|
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(
|
|
1176
|
+
}, g = (m) => {
|
|
1177
|
+
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(m))) : console.warn(
|
|
1002
1178
|
`Failed to scroll to index ${e} after ${o} attempts.`
|
|
1003
1179
|
));
|
|
1004
1180
|
};
|
|
1005
|
-
l(
|
|
1006
|
-
}, this.scrollBy = (e, { behavior:
|
|
1007
|
-
|
|
1181
|
+
l(n);
|
|
1182
|
+
}, this.scrollBy = (e, { behavior: n } = {}) => {
|
|
1183
|
+
n === "smooth" && this.isDynamicMode() && console.warn(
|
|
1008
1184
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
1009
1185
|
), this._scrollToOffset(this.getScrollOffset() + e, {
|
|
1010
1186
|
adjustments: void 0,
|
|
1011
|
-
behavior:
|
|
1187
|
+
behavior: n
|
|
1012
1188
|
});
|
|
1013
1189
|
}, this.getTotalSize = () => {
|
|
1014
1190
|
var e;
|
|
1015
|
-
const
|
|
1016
|
-
let
|
|
1017
|
-
if (
|
|
1018
|
-
|
|
1191
|
+
const n = this.getMeasurements();
|
|
1192
|
+
let s;
|
|
1193
|
+
if (n.length === 0)
|
|
1194
|
+
s = this.options.paddingStart;
|
|
1019
1195
|
else if (this.options.lanes === 1)
|
|
1020
|
-
|
|
1196
|
+
s = ((e = n[n.length - 1]) == null ? void 0 : e.end) ?? 0;
|
|
1021
1197
|
else {
|
|
1022
1198
|
const i = Array(this.options.lanes).fill(null);
|
|
1023
|
-
let o =
|
|
1199
|
+
let o = n.length - 1;
|
|
1024
1200
|
for (; o >= 0 && i.some((l) => l === null); ) {
|
|
1025
|
-
const l =
|
|
1201
|
+
const l = n[o];
|
|
1026
1202
|
i[l.lane] === null && (i[l.lane] = l.end), o--;
|
|
1027
1203
|
}
|
|
1028
|
-
|
|
1204
|
+
s = Math.max(...i.filter((l) => l !== null));
|
|
1029
1205
|
}
|
|
1030
1206
|
return Math.max(
|
|
1031
|
-
|
|
1207
|
+
s - this.options.scrollMargin + this.options.paddingEnd,
|
|
1032
1208
|
0
|
|
1033
1209
|
);
|
|
1034
1210
|
}, this._scrollToOffset = (e, {
|
|
1035
|
-
adjustments:
|
|
1036
|
-
behavior:
|
|
1211
|
+
adjustments: n,
|
|
1212
|
+
behavior: s
|
|
1037
1213
|
}) => {
|
|
1038
|
-
this.options.scrollToFn(e, { behavior:
|
|
1214
|
+
this.options.scrollToFn(e, { behavior: s, adjustments: n }, this);
|
|
1039
1215
|
}, this.measure = () => {
|
|
1040
1216
|
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
1041
|
-
}, this.setOptions(
|
|
1217
|
+
}, this.setOptions(c);
|
|
1042
1218
|
}
|
|
1043
1219
|
}
|
|
1044
|
-
const
|
|
1045
|
-
for (;
|
|
1046
|
-
const
|
|
1047
|
-
if (i <
|
|
1048
|
-
|
|
1049
|
-
else if (i >
|
|
1050
|
-
|
|
1220
|
+
const Le = (t, c, e, n) => {
|
|
1221
|
+
for (; t <= c; ) {
|
|
1222
|
+
const s = (t + c) / 2 | 0, i = e(s);
|
|
1223
|
+
if (i < n)
|
|
1224
|
+
t = s + 1;
|
|
1225
|
+
else if (i > n)
|
|
1226
|
+
c = s - 1;
|
|
1051
1227
|
else
|
|
1052
|
-
return
|
|
1228
|
+
return s;
|
|
1053
1229
|
}
|
|
1054
|
-
return
|
|
1230
|
+
return t > 0 ? t - 1 : 0;
|
|
1055
1231
|
};
|
|
1056
|
-
function
|
|
1057
|
-
measurements:
|
|
1058
|
-
outerSize:
|
|
1232
|
+
function Mt({
|
|
1233
|
+
measurements: t,
|
|
1234
|
+
outerSize: c,
|
|
1059
1235
|
scrollOffset: e,
|
|
1060
|
-
lanes:
|
|
1236
|
+
lanes: n
|
|
1061
1237
|
}) {
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1238
|
+
const s = t.length - 1, i = (g) => t[g].start;
|
|
1239
|
+
if (t.length <= n)
|
|
1064
1240
|
return {
|
|
1065
1241
|
startIndex: 0,
|
|
1066
|
-
endIndex:
|
|
1242
|
+
endIndex: s
|
|
1067
1243
|
};
|
|
1068
|
-
let o =
|
|
1244
|
+
let o = Le(
|
|
1069
1245
|
0,
|
|
1070
|
-
|
|
1246
|
+
s,
|
|
1071
1247
|
i,
|
|
1072
1248
|
e
|
|
1073
1249
|
), l = o;
|
|
1074
|
-
if (
|
|
1075
|
-
for (; l <
|
|
1250
|
+
if (n === 1)
|
|
1251
|
+
for (; l < s && t[l].end < e + c; )
|
|
1076
1252
|
l++;
|
|
1077
|
-
else if (
|
|
1078
|
-
const
|
|
1079
|
-
for (; l <
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1253
|
+
else if (n > 1) {
|
|
1254
|
+
const g = Array(n).fill(0);
|
|
1255
|
+
for (; l < s && g.some((f) => f < e + c); ) {
|
|
1256
|
+
const f = t[l];
|
|
1257
|
+
g[f.lane] = f.end, l++;
|
|
1082
1258
|
}
|
|
1083
|
-
const
|
|
1084
|
-
for (; o >= 0 &&
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1259
|
+
const m = Array(n).fill(e + c);
|
|
1260
|
+
for (; o >= 0 && m.some((f) => f >= e); ) {
|
|
1261
|
+
const f = t[o];
|
|
1262
|
+
m[f.lane] = f.start, o--;
|
|
1087
1263
|
}
|
|
1088
|
-
o = Math.max(0, o - o %
|
|
1264
|
+
o = Math.max(0, o - o % n), l = Math.min(s, l + (n - 1 - l % n));
|
|
1089
1265
|
}
|
|
1090
1266
|
return { startIndex: o, endIndex: l };
|
|
1091
1267
|
}
|
|
1092
|
-
const
|
|
1093
|
-
function
|
|
1094
|
-
useFlushSync:
|
|
1095
|
-
...
|
|
1268
|
+
const De = typeof document < "u" ? me.useLayoutEffect : me.useEffect;
|
|
1269
|
+
function It({
|
|
1270
|
+
useFlushSync: t = !0,
|
|
1271
|
+
...c
|
|
1096
1272
|
}) {
|
|
1097
|
-
const e =
|
|
1098
|
-
...
|
|
1273
|
+
const e = me.useReducer(() => ({}), {})[1], n = {
|
|
1274
|
+
...c,
|
|
1099
1275
|
onChange: (i, o) => {
|
|
1100
1276
|
var l;
|
|
1101
|
-
|
|
1277
|
+
t && o ? ut(e) : e(), (l = c.onChange) == null || l.call(c, i, o);
|
|
1102
1278
|
}
|
|
1103
|
-
}, [
|
|
1104
|
-
() => new
|
|
1279
|
+
}, [s] = me.useState(
|
|
1280
|
+
() => new zt(n)
|
|
1105
1281
|
);
|
|
1106
|
-
return
|
|
1282
|
+
return s.setOptions(n), De(() => s._didMount(), []), De(() => s._willUpdate()), s;
|
|
1107
1283
|
}
|
|
1108
|
-
function
|
|
1109
|
-
return
|
|
1110
|
-
observeElementRect:
|
|
1111
|
-
observeElementOffset:
|
|
1112
|
-
scrollToFn:
|
|
1113
|
-
...
|
|
1284
|
+
function Dt(t) {
|
|
1285
|
+
return It({
|
|
1286
|
+
observeElementRect: Rt,
|
|
1287
|
+
observeElementOffset: kt,
|
|
1288
|
+
scrollToFn: At,
|
|
1289
|
+
...t
|
|
1114
1290
|
});
|
|
1115
1291
|
}
|
|
1116
|
-
const
|
|
1117
|
-
data:
|
|
1118
|
-
columns:
|
|
1292
|
+
const Gt = ({
|
|
1293
|
+
data: t,
|
|
1294
|
+
columns: c,
|
|
1119
1295
|
rowHeight: e = 40,
|
|
1120
|
-
height:
|
|
1121
|
-
className:
|
|
1296
|
+
height: n = 600,
|
|
1297
|
+
className: s = "",
|
|
1122
1298
|
headerClassName: i = "",
|
|
1123
1299
|
rowClassName: o,
|
|
1124
1300
|
onRowClick: l,
|
|
1125
|
-
overscan:
|
|
1301
|
+
overscan: g = 5
|
|
1126
1302
|
}) => {
|
|
1127
|
-
const
|
|
1128
|
-
count:
|
|
1129
|
-
getScrollElement: () =>
|
|
1303
|
+
const m = pe(null), f = Dt({
|
|
1304
|
+
count: t.length,
|
|
1305
|
+
getScrollElement: () => m.current,
|
|
1130
1306
|
estimateSize: () => e,
|
|
1131
|
-
overscan:
|
|
1132
|
-
}),
|
|
1133
|
-
return /* @__PURE__ */
|
|
1134
|
-
/* @__PURE__ */
|
|
1307
|
+
overscan: g
|
|
1308
|
+
}), v = f.getVirtualItems();
|
|
1309
|
+
return /* @__PURE__ */ a.jsxs("div", { className: s, children: [
|
|
1310
|
+
/* @__PURE__ */ a.jsx(
|
|
1135
1311
|
"div",
|
|
1136
1312
|
{
|
|
1137
1313
|
className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
|
|
1138
1314
|
style: {
|
|
1139
|
-
gridTemplateColumns:
|
|
1315
|
+
gridTemplateColumns: c.map((u) => u.width || "1fr").join(" ")
|
|
1140
1316
|
},
|
|
1141
|
-
children:
|
|
1317
|
+
children: c.map((u, d) => /* @__PURE__ */ a.jsx(
|
|
1142
1318
|
"div",
|
|
1143
1319
|
{
|
|
1144
|
-
className: `px-4 py-2 font-semibold text-sm ${
|
|
1145
|
-
children:
|
|
1320
|
+
className: `px-4 py-2 font-semibold text-sm ${u.align === "center" ? "text-center" : u.align === "right" ? "text-right" : "text-left"}`,
|
|
1321
|
+
children: u.header
|
|
1146
1322
|
},
|
|
1147
|
-
|
|
1323
|
+
d
|
|
1148
1324
|
))
|
|
1149
1325
|
}
|
|
1150
1326
|
),
|
|
1151
|
-
/* @__PURE__ */
|
|
1327
|
+
/* @__PURE__ */ a.jsx(
|
|
1152
1328
|
"div",
|
|
1153
1329
|
{
|
|
1154
|
-
ref:
|
|
1330
|
+
ref: m,
|
|
1155
1331
|
className: "overflow-auto",
|
|
1156
1332
|
style: {
|
|
1157
|
-
height: typeof
|
|
1333
|
+
height: typeof n == "number" ? `${n}px` : n,
|
|
1158
1334
|
contain: "strict"
|
|
1159
1335
|
},
|
|
1160
|
-
children: /* @__PURE__ */
|
|
1336
|
+
children: /* @__PURE__ */ a.jsx(
|
|
1161
1337
|
"div",
|
|
1162
1338
|
{
|
|
1163
1339
|
style: {
|
|
1164
|
-
height: `${
|
|
1340
|
+
height: `${f.getTotalSize()}px`,
|
|
1165
1341
|
width: "100%",
|
|
1166
1342
|
position: "relative"
|
|
1167
1343
|
},
|
|
1168
|
-
children:
|
|
1169
|
-
const
|
|
1170
|
-
return /* @__PURE__ */
|
|
1344
|
+
children: v.map((u) => {
|
|
1345
|
+
const d = t[u.index], y = typeof o == "function" ? o(d, u.index) : o || "";
|
|
1346
|
+
return /* @__PURE__ */ a.jsx(
|
|
1171
1347
|
"div",
|
|
1172
1348
|
{
|
|
1173
|
-
className: `grid border-b hover:bg-muted/50 cursor-pointer ${
|
|
1349
|
+
className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
|
|
1174
1350
|
style: {
|
|
1175
1351
|
position: "absolute",
|
|
1176
1352
|
top: 0,
|
|
1177
1353
|
left: 0,
|
|
1178
1354
|
width: "100%",
|
|
1179
|
-
height: `${
|
|
1180
|
-
transform: `translateY(${
|
|
1181
|
-
gridTemplateColumns:
|
|
1355
|
+
height: `${u.size}px`,
|
|
1356
|
+
transform: `translateY(${u.start}px)`,
|
|
1357
|
+
gridTemplateColumns: c.map((x) => x.width || "1fr").join(" ")
|
|
1182
1358
|
},
|
|
1183
|
-
onClick: () => l?.(
|
|
1184
|
-
children:
|
|
1185
|
-
const
|
|
1186
|
-
return /* @__PURE__ */
|
|
1359
|
+
onClick: () => l?.(d, u.index),
|
|
1360
|
+
children: c.map((x, S) => {
|
|
1361
|
+
const R = d[x.accessorKey], _ = x.cell ? x.cell(R, d) : R;
|
|
1362
|
+
return /* @__PURE__ */ a.jsx(
|
|
1187
1363
|
"div",
|
|
1188
1364
|
{
|
|
1189
|
-
className: `px-4 py-2 text-sm flex items-center ${
|
|
1190
|
-
children:
|
|
1365
|
+
className: `px-4 py-2 text-sm flex items-center ${x.align === "center" ? "text-center justify-center" : x.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
|
|
1366
|
+
children: _
|
|
1191
1367
|
},
|
|
1192
|
-
|
|
1368
|
+
S
|
|
1193
1369
|
);
|
|
1194
1370
|
})
|
|
1195
1371
|
},
|
|
1196
|
-
|
|
1372
|
+
u.key
|
|
1197
1373
|
);
|
|
1198
1374
|
})
|
|
1199
1375
|
}
|
|
1200
1376
|
)
|
|
1201
1377
|
}
|
|
1202
1378
|
),
|
|
1203
|
-
/* @__PURE__ */
|
|
1379
|
+
/* @__PURE__ */ a.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
|
|
1204
1380
|
"Showing ",
|
|
1205
|
-
|
|
1381
|
+
v.length,
|
|
1206
1382
|
" of ",
|
|
1207
|
-
|
|
1383
|
+
t.length,
|
|
1208
1384
|
" rows (virtual scrolling enabled)"
|
|
1209
1385
|
] })
|
|
1210
1386
|
] });
|
|
1211
|
-
}, Oe = ({ schema: n, ...a }) => {
|
|
1212
|
-
const { dataSource: e } = Ne() || {};
|
|
1213
|
-
return /* @__PURE__ */ u.jsx(Ue, { schema: n, dataSource: e, ...a });
|
|
1214
1387
|
};
|
|
1215
|
-
|
|
1388
|
+
function Kt({
|
|
1389
|
+
value: t,
|
|
1390
|
+
onSave: c,
|
|
1391
|
+
onCancel: e,
|
|
1392
|
+
validate: n,
|
|
1393
|
+
type: s = "text",
|
|
1394
|
+
placeholder: i,
|
|
1395
|
+
editing: o = !1,
|
|
1396
|
+
className: l,
|
|
1397
|
+
disabled: g = !1
|
|
1398
|
+
}) {
|
|
1399
|
+
const [m, f] = D(o), [v, u] = D(String(t ?? "")), [d, y] = D(), [x, S] = D(!1), R = pe(null);
|
|
1400
|
+
re(() => {
|
|
1401
|
+
m || u(String(t ?? ""));
|
|
1402
|
+
}, [t, m]), re(() => {
|
|
1403
|
+
m && R.current && (R.current.focus(), R.current.select());
|
|
1404
|
+
}, [m]);
|
|
1405
|
+
const _ = $(() => {
|
|
1406
|
+
g || (f(!0), u(String(t ?? "")), y(void 0));
|
|
1407
|
+
}, [g, t]), F = $(() => {
|
|
1408
|
+
f(!1), u(String(t ?? "")), y(void 0), e?.();
|
|
1409
|
+
}, [t, e]), A = $(async () => {
|
|
1410
|
+
if (n) {
|
|
1411
|
+
const L = n(v);
|
|
1412
|
+
if (L) {
|
|
1413
|
+
y(L);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
const k = s === "number" ? Number(v) : v;
|
|
1418
|
+
S(!0);
|
|
1419
|
+
try {
|
|
1420
|
+
const L = await c(k);
|
|
1421
|
+
if (typeof L == "string") {
|
|
1422
|
+
y(L), S(!1);
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
f(!1), y(void 0);
|
|
1426
|
+
} catch (L) {
|
|
1427
|
+
y(L?.message || "Save failed");
|
|
1428
|
+
} finally {
|
|
1429
|
+
S(!1);
|
|
1430
|
+
}
|
|
1431
|
+
}, [v, n, s, c]), K = $(
|
|
1432
|
+
(k) => {
|
|
1433
|
+
k.key === "Enter" ? (k.preventDefault(), A()) : k.key === "Escape" && (k.preventDefault(), F());
|
|
1434
|
+
},
|
|
1435
|
+
[A, F]
|
|
1436
|
+
);
|
|
1437
|
+
return m ? /* @__PURE__ */ a.jsxs(
|
|
1438
|
+
"div",
|
|
1439
|
+
{
|
|
1440
|
+
"data-slot": "inline-editing",
|
|
1441
|
+
className: fe("relative flex items-center gap-1", l),
|
|
1442
|
+
children: [
|
|
1443
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex-1 relative", children: [
|
|
1444
|
+
/* @__PURE__ */ a.jsx(
|
|
1445
|
+
"input",
|
|
1446
|
+
{
|
|
1447
|
+
ref: R,
|
|
1448
|
+
"data-slot": "inline-editing-input",
|
|
1449
|
+
type: s,
|
|
1450
|
+
value: v,
|
|
1451
|
+
onChange: (k) => {
|
|
1452
|
+
u(k.target.value), d && y(void 0);
|
|
1453
|
+
},
|
|
1454
|
+
onKeyDown: K,
|
|
1455
|
+
placeholder: i,
|
|
1456
|
+
disabled: x,
|
|
1457
|
+
"aria-invalid": !!d,
|
|
1458
|
+
"aria-describedby": d ? "inline-editing-error" : void 0,
|
|
1459
|
+
className: fe(
|
|
1460
|
+
"w-full rounded border px-2 py-1 text-sm outline-none transition-colors",
|
|
1461
|
+
"focus:ring-2 focus:ring-ring focus:border-input",
|
|
1462
|
+
d ? "border-destructive focus:ring-destructive/30" : "border-input",
|
|
1463
|
+
x && "opacity-50"
|
|
1464
|
+
)
|
|
1465
|
+
}
|
|
1466
|
+
),
|
|
1467
|
+
d && /* @__PURE__ */ a.jsx(
|
|
1468
|
+
"p",
|
|
1469
|
+
{
|
|
1470
|
+
id: "inline-editing-error",
|
|
1471
|
+
"data-slot": "inline-editing-error",
|
|
1472
|
+
className: "absolute left-0 top-full mt-0.5 text-xs text-destructive",
|
|
1473
|
+
role: "alert",
|
|
1474
|
+
children: d
|
|
1475
|
+
}
|
|
1476
|
+
)
|
|
1477
|
+
] }),
|
|
1478
|
+
/* @__PURE__ */ a.jsx(
|
|
1479
|
+
"button",
|
|
1480
|
+
{
|
|
1481
|
+
"data-slot": "inline-editing-save",
|
|
1482
|
+
type: "button",
|
|
1483
|
+
onClick: A,
|
|
1484
|
+
disabled: x,
|
|
1485
|
+
"aria-label": "Save",
|
|
1486
|
+
className: fe(
|
|
1487
|
+
"inline-flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/10 transition-colors",
|
|
1488
|
+
x && "opacity-50 cursor-not-allowed"
|
|
1489
|
+
),
|
|
1490
|
+
children: /* @__PURE__ */ a.jsx(at, { className: "h-3.5 w-3.5" })
|
|
1491
|
+
}
|
|
1492
|
+
),
|
|
1493
|
+
/* @__PURE__ */ a.jsx(
|
|
1494
|
+
"button",
|
|
1495
|
+
{
|
|
1496
|
+
"data-slot": "inline-editing-cancel",
|
|
1497
|
+
type: "button",
|
|
1498
|
+
onClick: F,
|
|
1499
|
+
disabled: x,
|
|
1500
|
+
"aria-label": "Cancel",
|
|
1501
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",
|
|
1502
|
+
children: /* @__PURE__ */ a.jsx(ct, { className: "h-3.5 w-3.5" })
|
|
1503
|
+
}
|
|
1504
|
+
)
|
|
1505
|
+
]
|
|
1506
|
+
}
|
|
1507
|
+
) : /* @__PURE__ */ a.jsx(
|
|
1508
|
+
"div",
|
|
1509
|
+
{
|
|
1510
|
+
"data-slot": "inline-editing",
|
|
1511
|
+
className: fe(
|
|
1512
|
+
"group relative cursor-pointer rounded px-2 py-1 hover:bg-muted/50 transition-colors min-h-[1.75rem] flex items-center",
|
|
1513
|
+
g && "cursor-default opacity-60",
|
|
1514
|
+
l
|
|
1515
|
+
),
|
|
1516
|
+
onClick: _,
|
|
1517
|
+
role: "button",
|
|
1518
|
+
tabIndex: g ? -1 : 0,
|
|
1519
|
+
onKeyDown: (k) => {
|
|
1520
|
+
(k.key === "Enter" || k.key === " ") && (k.preventDefault(), _());
|
|
1521
|
+
},
|
|
1522
|
+
"aria-label": `Edit value: ${String(t ?? "")}`,
|
|
1523
|
+
children: /* @__PURE__ */ a.jsx("span", { "data-slot": "inline-editing-display", className: "truncate text-sm", children: t != null && String(t) !== "" ? String(t) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground italic", children: i || "Click to edit" }) })
|
|
1524
|
+
}
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
const $e = ({ schema: t, ...c }) => {
|
|
1528
|
+
const { dataSource: e } = Ze() || {};
|
|
1529
|
+
return /* @__PURE__ */ a.jsx(St, { schema: t, dataSource: e, ...c });
|
|
1530
|
+
};
|
|
1531
|
+
Fe.register("object-grid", $e, {
|
|
1216
1532
|
namespace: "plugin-grid",
|
|
1217
1533
|
label: "Object Grid",
|
|
1218
1534
|
category: "plugin",
|
|
@@ -1222,7 +1538,7 @@ we.register("object-grid", Oe, {
|
|
|
1222
1538
|
{ name: "filters", type: "array", label: "Filters" }
|
|
1223
1539
|
]
|
|
1224
1540
|
});
|
|
1225
|
-
|
|
1541
|
+
Fe.register("grid", $e, {
|
|
1226
1542
|
namespace: "view",
|
|
1227
1543
|
label: "Data Grid",
|
|
1228
1544
|
category: "view",
|
|
@@ -1233,7 +1549,10 @@ we.register("grid", Oe, {
|
|
|
1233
1549
|
]
|
|
1234
1550
|
});
|
|
1235
1551
|
export {
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1552
|
+
Kt as InlineEditing,
|
|
1553
|
+
St as ObjectGrid,
|
|
1554
|
+
$e as ObjectGridRenderer,
|
|
1555
|
+
Gt as VirtualGrid,
|
|
1556
|
+
wt as useGroupedData,
|
|
1557
|
+
xt as useRowColor
|
|
1239
1558
|
};
|