@object-ui/plugin-grid 0.5.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 +51 -6
- package/CHANGELOG.md +37 -0
- package/README.md +97 -0
- package/dist/index.js +994 -584
- package/dist/index.umd.cjs +3 -3
- package/dist/packages/plugin-grid/src/InlineEditing.d.ts +28 -0
- package/dist/packages/plugin-grid/src/ListColumnExtensions.test.d.ts +0 -0
- package/dist/packages/plugin-grid/src/ListColumnSchema.test.d.ts +1 -0
- package/dist/packages/plugin-grid/src/ObjectGrid.EdgeCases.stories.d.ts +25 -0
- package/dist/packages/plugin-grid/src/ObjectGrid.d.ts +7 -1
- 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__/VirtualGrid.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/ListColumnExtensions.test.tsx +374 -0
- package/src/ListColumnSchema.test.ts +88 -0
- package/src/ObjectGrid.EdgeCases.stories.tsx +147 -0
- package/src/ObjectGrid.msw.test.tsx +24 -1
- package/src/ObjectGrid.stories.tsx +139 -0
- package/src/ObjectGrid.tsx +409 -113
- package/src/__tests__/InlineEditing.test.tsx +360 -0
- package/src/__tests__/VirtualGrid.test.tsx +438 -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 +17 -2
- 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 t = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
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
|
|
19
|
+
for (var l in s)
|
|
20
|
+
l !== "key" && (i[l] = s[l]);
|
|
21
|
+
} else i = s;
|
|
22
|
+
return s = i.ref, {
|
|
23
23
|
$$typeof: t,
|
|
24
|
-
type:
|
|
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
|
|
32
|
+
var de = {};
|
|
33
|
+
var Re;
|
|
34
|
+
function ft() {
|
|
35
|
+
return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
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 j:
|
|
64
|
-
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
|
-
case N:
|
|
66
|
-
var u = r.render;
|
|
67
|
-
return r = r.displayName, r || (r = u.displayName || u.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
68
|
-
case Y:
|
|
69
|
-
return u = r.displayName || null, u !== null ? u : t(r.type) || "Memo";
|
|
70
63
|
case F:
|
|
71
|
-
|
|
64
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
|
+
case K:
|
|
66
|
+
var h = r.render;
|
|
67
|
+
return r = r.displayName, r || (r = h.displayName || h.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
68
|
+
case ge:
|
|
69
|
+
return h = r.displayName || null, h !== null ? h : t(r.type) || "Memo";
|
|
70
|
+
case J:
|
|
71
|
+
h = r._payload, r = r._init;
|
|
72
72
|
try {
|
|
73
|
-
return t(r(
|
|
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
|
-
|
|
85
|
-
var
|
|
84
|
+
c(r);
|
|
85
|
+
var h = !1;
|
|
86
86
|
} catch {
|
|
87
|
-
|
|
87
|
+
h = !0;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
var
|
|
92
|
-
return
|
|
93
|
-
|
|
89
|
+
if (h) {
|
|
90
|
+
h = console;
|
|
91
|
+
var j = h.error, C = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
92
|
+
return j.call(
|
|
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
|
|
105
|
-
return
|
|
104
|
+
var h = t(r);
|
|
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 (
|
|
119
|
-
var
|
|
120
|
-
if (
|
|
118
|
+
if (z.call(r, "key")) {
|
|
119
|
+
var h = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
|
+
if (h && h.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
122
|
return r.key !== void 0;
|
|
123
123
|
}
|
|
124
|
-
function l(r,
|
|
125
|
-
function
|
|
126
|
-
|
|
124
|
+
function l(r, h) {
|
|
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
|
|
136
|
+
function g() {
|
|
137
137
|
var r = t(this.type);
|
|
138
|
-
return
|
|
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 O =
|
|
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
|
-
key:
|
|
148
|
-
props:
|
|
149
|
-
_owner:
|
|
147
|
+
key: h,
|
|
148
|
+
props: j,
|
|
149
|
+
_owner: C
|
|
150
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,109 +164,218 @@ function Te() {
|
|
|
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 O =
|
|
175
|
+
function f(r, h, j, C, ee, te) {
|
|
176
|
+
var O = h.children;
|
|
177
177
|
if (O !== void 0)
|
|
178
|
-
if (
|
|
179
|
-
if (
|
|
180
|
-
for (
|
|
181
|
-
|
|
178
|
+
if (C)
|
|
179
|
+
if (U(O)) {
|
|
180
|
+
for (C = 0; C < O.length; C++)
|
|
181
|
+
v(O[C]);
|
|
182
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 (
|
|
187
|
+
else v(O);
|
|
188
|
+
if (z.call(h, "key")) {
|
|
189
189
|
O = t(r);
|
|
190
|
-
var
|
|
191
|
-
return
|
|
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
|
-
|
|
200
|
+
C,
|
|
201
201
|
O,
|
|
202
|
-
|
|
202
|
+
G,
|
|
203
203
|
O
|
|
204
|
-
),
|
|
204
|
+
), ie[O + C] = !0);
|
|
205
205
|
}
|
|
206
|
-
if (O = null,
|
|
207
|
-
|
|
208
|
-
for (var
|
|
209
|
-
|
|
210
|
-
} else
|
|
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
211
|
return O && l(
|
|
212
|
-
|
|
212
|
+
j,
|
|
213
213
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
214
|
-
),
|
|
214
|
+
), m(
|
|
215
215
|
r,
|
|
216
216
|
O,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
246
|
-
|
|
245
|
+
h,
|
|
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
|
-
|
|
256
|
-
|
|
255
|
+
h,
|
|
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 };
|
|
263
300
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
);
|
|
343
|
+
}
|
|
344
|
+
function vt(t, c) {
|
|
345
|
+
return c.map((e) => String(t[e.field] ?? "")).join(" / ");
|
|
346
|
+
}
|
|
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(" / ");
|
|
267
352
|
}
|
|
268
|
-
|
|
269
|
-
|
|
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) {
|
|
270
379
|
return t.data ? Array.isArray(t.data) ? {
|
|
271
380
|
provider: "value",
|
|
272
381
|
items: t.data
|
|
@@ -278,308 +387,456 @@ function ze(t) {
|
|
|
278
387
|
object: t.objectName
|
|
279
388
|
} : null;
|
|
280
389
|
}
|
|
281
|
-
function
|
|
390
|
+
function Te(t) {
|
|
282
391
|
if (!(!t || t.length === 0))
|
|
283
392
|
return typeof t[0] == "object" && t[0] !== null, t;
|
|
284
393
|
}
|
|
285
|
-
const
|
|
394
|
+
const St = ({
|
|
286
395
|
schema: t,
|
|
287
|
-
dataSource:
|
|
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,
|
|
402
|
+
onRowSave: l,
|
|
403
|
+
onBatchSave: g,
|
|
404
|
+
...m
|
|
293
405
|
}) => {
|
|
294
|
-
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) ? {
|
|
295
417
|
provider: "value",
|
|
296
|
-
items:
|
|
297
|
-
} :
|
|
418
|
+
items: X
|
|
419
|
+
} : Z && Array.isArray(Z) ? {
|
|
298
420
|
provider: "value",
|
|
299
|
-
items:
|
|
300
|
-
} :
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
return JSON.stringify(
|
|
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;
|
|
305
427
|
}), d(!1));
|
|
306
|
-
}, [
|
|
307
|
-
|
|
428
|
+
}, [U, z]), re(() => {
|
|
429
|
+
if (U) return;
|
|
430
|
+
let b = !1;
|
|
431
|
+
return (async () => {
|
|
432
|
+
d(!0), x(null);
|
|
308
433
|
try {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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 = {
|
|
444
|
+
$select: (() => {
|
|
445
|
+
if (W) return W;
|
|
446
|
+
if (V && Array.isArray(V))
|
|
447
|
+
return V.map((T) => typeof T == "string" ? T : T.field);
|
|
448
|
+
})(),
|
|
449
|
+
$top: ie?.pageSize || r || 50
|
|
450
|
+
};
|
|
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 || []);
|
|
455
|
+
}
|
|
456
|
+
} catch (M) {
|
|
457
|
+
b || x(M);
|
|
458
|
+
} finally {
|
|
459
|
+
b || d(!1);
|
|
318
460
|
}
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
461
|
+
})(), () => {
|
|
462
|
+
b = !0;
|
|
463
|
+
};
|
|
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,
|
|
469
|
+
onRowClick: i
|
|
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];
|
|
475
|
+
if ("accessorKey" in w)
|
|
476
|
+
return b;
|
|
477
|
+
if ("field" in w)
|
|
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(
|
|
485
|
+
"button",
|
|
486
|
+
{
|
|
487
|
+
type: "button",
|
|
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);
|
|
491
|
+
},
|
|
492
|
+
children: ae
|
|
493
|
+
}
|
|
494
|
+
);
|
|
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(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
type: "button",
|
|
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);
|
|
504
|
+
},
|
|
505
|
+
children: ae
|
|
506
|
+
}
|
|
507
|
+
);
|
|
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(
|
|
511
|
+
"button",
|
|
512
|
+
{
|
|
513
|
+
type: "button",
|
|
514
|
+
className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
515
|
+
onClick: (ce) => {
|
|
516
|
+
ce.stopPropagation(), j({
|
|
517
|
+
type: p.action,
|
|
518
|
+
params: { record: le, field: p.field, value: N }
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
children: ae
|
|
522
|
+
}
|
|
523
|
+
);
|
|
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 }
|
|
536
|
+
};
|
|
537
|
+
});
|
|
337
538
|
}
|
|
338
|
-
return
|
|
339
|
-
header:
|
|
340
|
-
accessorKey:
|
|
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, " "),
|
|
541
|
+
accessorKey: w
|
|
341
542
|
}));
|
|
342
543
|
}
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
return (
|
|
347
|
-
header:
|
|
348
|
-
accessorKey:
|
|
544
|
+
if (U) {
|
|
545
|
+
const w = z?.provider === "value" ? z.items : [];
|
|
546
|
+
if (w.length > 0)
|
|
547
|
+
return (W || Object.keys(w[0])).map((I) => ({
|
|
548
|
+
header: I.charAt(0).toUpperCase() + I.slice(1).replace(/_/g, " "),
|
|
549
|
+
accessorKey: I
|
|
349
550
|
}));
|
|
350
551
|
}
|
|
351
|
-
if (!
|
|
352
|
-
const
|
|
353
|
-
return (
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
header:
|
|
359
|
-
accessorKey:
|
|
360
|
-
|
|
361
|
-
|
|
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,
|
|
560
|
+
accessorKey: w,
|
|
561
|
+
...oe.includes(p.type) && { align: "right" },
|
|
562
|
+
cell: (T) => /* @__PURE__ */ a.jsx(I, { value: T, field: p }),
|
|
563
|
+
sortable: p.sortable !== !1
|
|
362
564
|
});
|
|
363
|
-
}),
|
|
364
|
-
}, [
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (!y)
|
|
370
|
-
throw new Error("Object name required for data fetching");
|
|
371
|
-
const R = {
|
|
372
|
-
$select: (() => {
|
|
373
|
-
if (t.fields) return t.fields;
|
|
374
|
-
if (t.columns && Array.isArray(t.columns))
|
|
375
|
-
return t.columns.map((h) => typeof h == "string" ? h : h.field);
|
|
376
|
-
})(),
|
|
377
|
-
$top: t.pagination?.pageSize || t.pageSize || 50
|
|
378
|
-
};
|
|
379
|
-
t.filter && Array.isArray(t.filter) ? R.$filter = t.filter : "defaultFilters" in t && t.defaultFilters && (R.$filter = t.defaultFilters), t.sort ? typeof t.sort == "string" ? R.$orderby = t.sort : Array.isArray(t.sort) && (R.$orderby = t.sort.map((h) => `${h.field} ${h.order}`).join(", ")) : "defaultSort" in t && t.defaultSort && (R.$orderby = `${t.defaultSort.field} ${t.defaultSort.order}`);
|
|
380
|
-
const E = await a.find(y, R);
|
|
381
|
-
f(E.data || []);
|
|
382
|
-
} catch (y) {
|
|
383
|
-
c(y);
|
|
384
|
-
} finally {
|
|
385
|
-
d(!1);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}, [t, a, j, p]);
|
|
389
|
-
if (Q(() => {
|
|
390
|
-
(m || j) && N();
|
|
391
|
-
}, [m, j, N]), S)
|
|
392
|
-
return /* @__PURE__ */ v.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
393
|
-
/* @__PURE__ */ v.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
|
|
394
|
-
/* @__PURE__ */ v.jsx("p", { className: "text-red-600 text-sm mt-1", children: S.message })
|
|
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 })
|
|
395
571
|
] });
|
|
396
|
-
if (
|
|
397
|
-
return /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
/* @__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..." })
|
|
400
576
|
] });
|
|
401
|
-
const
|
|
402
|
-
...
|
|
577
|
+
const ne = G(), q = "operations" in t ? t.operations : void 0, ye = q && (q.update || q.delete), We = ye ? [
|
|
578
|
+
...ne,
|
|
403
579
|
{
|
|
404
580
|
header: "Actions",
|
|
405
581
|
accessorKey: "_actions",
|
|
406
|
-
cell: (
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
/* @__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" })
|
|
410
586
|
] }) }),
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
|
|
413
|
-
/* @__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" }),
|
|
414
590
|
"Edit"
|
|
415
591
|
] }),
|
|
416
|
-
|
|
417
|
-
/* @__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" }),
|
|
418
594
|
"Delete"
|
|
419
595
|
] })
|
|
420
596
|
] })
|
|
421
597
|
] }),
|
|
422
598
|
sortable: !1
|
|
423
599
|
}
|
|
424
|
-
] :
|
|
425
|
-
let
|
|
426
|
-
t.selection?.type ?
|
|
427
|
-
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 = {
|
|
428
604
|
type: "data-table",
|
|
429
605
|
caption: t.label || t.title,
|
|
430
|
-
columns:
|
|
431
|
-
data:
|
|
432
|
-
pagination:
|
|
433
|
-
pageSize:
|
|
434
|
-
searchable:
|
|
435
|
-
selectable:
|
|
606
|
+
columns: We,
|
|
607
|
+
data: f,
|
|
608
|
+
pagination: Ve,
|
|
609
|
+
pageSize: Ye,
|
|
610
|
+
searchable: Ge,
|
|
611
|
+
selectable: be,
|
|
436
612
|
sortable: !0,
|
|
437
|
-
exportable:
|
|
438
|
-
rowActions:
|
|
613
|
+
exportable: q?.export,
|
|
614
|
+
rowActions: ye,
|
|
439
615
|
resizableColumns: t.resizable ?? t.resizableColumns ?? !0,
|
|
440
616
|
reorderableColumns: t.reorderableColumns ?? !1,
|
|
617
|
+
editable: t.editable ?? !1,
|
|
441
618
|
className: t.className,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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,
|
|
623
|
+
onCellChange: o,
|
|
624
|
+
onRowSave: l,
|
|
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,
|
|
672
|
+
{
|
|
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)) })
|
|
680
|
+
}
|
|
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,
|
|
693
|
+
{
|
|
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)) })
|
|
700
|
+
}
|
|
701
|
+
)
|
|
702
|
+
] });
|
|
446
703
|
};
|
|
447
|
-
function
|
|
448
|
-
let
|
|
704
|
+
function se(t, c, e) {
|
|
705
|
+
let n = e.initialDeps ?? [], s, i = !0;
|
|
449
706
|
function o() {
|
|
450
|
-
var l,
|
|
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;
|
|
451
714
|
let d;
|
|
452
|
-
e.key && ((
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
let m;
|
|
458
|
-
if (e.key && ((f = e.debug) != null && f.call(e)) && (m = Date.now()), n = a(...S), e.key && ((b = e.debug) != null && b.call(e))) {
|
|
459
|
-
const C = Math.round((Date.now() - d) * 100) / 100, g = Math.round((Date.now() - m) * 100) / 100, _ = g / 16, T = (p, j) => {
|
|
460
|
-
for (p = String(p); p.length < j; )
|
|
461
|
-
p = " " + p;
|
|
462
|
-
return p;
|
|
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 _;
|
|
463
720
|
};
|
|
464
721
|
console.info(
|
|
465
|
-
`%c⏱ ${
|
|
722
|
+
`%c⏱ ${R(x, 5)} /${R(y, 5)} ms`,
|
|
466
723
|
`
|
|
467
724
|
font-size: .6rem;
|
|
468
725
|
font-weight: bold;
|
|
469
726
|
color: hsl(${Math.max(
|
|
470
727
|
0,
|
|
471
|
-
Math.min(120 - 120 *
|
|
728
|
+
Math.min(120 - 120 * S, 120)
|
|
472
729
|
)}deg 100% 31%);`,
|
|
473
730
|
e?.key
|
|
474
731
|
);
|
|
475
732
|
}
|
|
476
|
-
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(
|
|
733
|
+
return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(s), i = !1, s;
|
|
477
734
|
}
|
|
478
735
|
return o.updateDeps = (l) => {
|
|
479
|
-
|
|
736
|
+
n = l;
|
|
480
737
|
}, o;
|
|
481
738
|
}
|
|
482
|
-
function
|
|
739
|
+
function Ae(t, c) {
|
|
483
740
|
if (t === void 0)
|
|
484
741
|
throw new Error("Unexpected undefined");
|
|
485
742
|
return t;
|
|
486
743
|
}
|
|
487
|
-
const
|
|
488
|
-
let
|
|
489
|
-
return function(...
|
|
490
|
-
t.clearTimeout(
|
|
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);
|
|
491
748
|
};
|
|
492
|
-
},
|
|
493
|
-
const { offsetWidth:
|
|
494
|
-
return { width:
|
|
495
|
-
},
|
|
496
|
-
const
|
|
497
|
-
for (let
|
|
498
|
-
|
|
499
|
-
return
|
|
500
|
-
},
|
|
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) => {
|
|
501
758
|
const e = t.scrollElement;
|
|
502
759
|
if (!e)
|
|
503
760
|
return;
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
761
|
+
const n = t.targetWindow;
|
|
762
|
+
if (!n)
|
|
506
763
|
return;
|
|
507
|
-
const
|
|
508
|
-
const { width: l, height:
|
|
509
|
-
|
|
764
|
+
const s = (o) => {
|
|
765
|
+
const { width: l, height: g } = o;
|
|
766
|
+
c({ width: Math.round(l), height: Math.round(g) });
|
|
510
767
|
};
|
|
511
|
-
if (
|
|
768
|
+
if (s(ze(e)), !n.ResizeObserver)
|
|
512
769
|
return () => {
|
|
513
770
|
};
|
|
514
|
-
const i = new
|
|
771
|
+
const i = new n.ResizeObserver((o) => {
|
|
515
772
|
const l = () => {
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
|
|
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 });
|
|
521
778
|
return;
|
|
522
779
|
}
|
|
523
780
|
}
|
|
524
|
-
|
|
781
|
+
s(ze(e));
|
|
525
782
|
};
|
|
526
783
|
t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
|
|
527
784
|
});
|
|
528
785
|
return i.observe(e, { box: "border-box" }), () => {
|
|
529
786
|
i.unobserve(e);
|
|
530
787
|
};
|
|
531
|
-
},
|
|
788
|
+
}, Me = {
|
|
532
789
|
passive: !0
|
|
533
|
-
},
|
|
790
|
+
}, Ie = typeof window > "u" ? !0 : "onscrollend" in window, kt = (t, c) => {
|
|
534
791
|
const e = t.scrollElement;
|
|
535
792
|
if (!e)
|
|
536
793
|
return;
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
794
|
+
const n = t.targetWindow;
|
|
795
|
+
if (!n)
|
|
539
796
|
return;
|
|
540
|
-
let
|
|
541
|
-
const i = t.options.useScrollendEvent &&
|
|
542
|
-
} :
|
|
543
|
-
|
|
797
|
+
let s = 0;
|
|
798
|
+
const i = t.options.useScrollendEvent && Ie ? () => {
|
|
799
|
+
} : Ot(
|
|
800
|
+
n,
|
|
544
801
|
() => {
|
|
545
|
-
|
|
802
|
+
c(s, !1);
|
|
546
803
|
},
|
|
547
804
|
t.options.isScrollingResetDelay
|
|
548
|
-
), o = (
|
|
549
|
-
const { horizontal:
|
|
550
|
-
|
|
551
|
-
}, l = o(!0),
|
|
552
|
-
e.addEventListener("scroll", l,
|
|
553
|
-
const
|
|
554
|
-
return
|
|
555
|
-
e.removeEventListener("scroll", l),
|
|
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);
|
|
556
813
|
};
|
|
557
|
-
},
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
814
|
+
}, Tt = (t, c, e) => {
|
|
815
|
+
if (c?.borderBoxSize) {
|
|
816
|
+
const n = c.borderBoxSize[0];
|
|
817
|
+
if (n)
|
|
561
818
|
return Math.round(
|
|
562
|
-
|
|
819
|
+
n[e.options.horizontal ? "inlineSize" : "blockSize"]
|
|
563
820
|
);
|
|
564
821
|
}
|
|
565
822
|
return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
566
|
-
},
|
|
567
|
-
adjustments:
|
|
823
|
+
}, At = (t, {
|
|
824
|
+
adjustments: c = 0,
|
|
568
825
|
behavior: e
|
|
569
|
-
},
|
|
570
|
-
var
|
|
571
|
-
const o = t +
|
|
572
|
-
(i = (
|
|
573
|
-
[
|
|
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,
|
|
574
831
|
behavior: e
|
|
575
832
|
});
|
|
576
833
|
};
|
|
577
|
-
class
|
|
578
|
-
constructor(
|
|
834
|
+
class zt {
|
|
835
|
+
constructor(c) {
|
|
579
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__ */ (() => {
|
|
580
837
|
let e = null;
|
|
581
|
-
const
|
|
582
|
-
|
|
838
|
+
const n = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
|
|
839
|
+
s.forEach((i) => {
|
|
583
840
|
const o = () => {
|
|
584
841
|
this._measureElement(i.target, i);
|
|
585
842
|
};
|
|
@@ -588,21 +845,21 @@ class Ve {
|
|
|
588
845
|
}));
|
|
589
846
|
return {
|
|
590
847
|
disconnect: () => {
|
|
591
|
-
var
|
|
592
|
-
(
|
|
848
|
+
var s;
|
|
849
|
+
(s = n()) == null || s.disconnect(), e = null;
|
|
593
850
|
},
|
|
594
|
-
observe: (
|
|
851
|
+
observe: (s) => {
|
|
595
852
|
var i;
|
|
596
|
-
return (i =
|
|
853
|
+
return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
|
|
597
854
|
},
|
|
598
|
-
unobserve: (
|
|
855
|
+
unobserve: (s) => {
|
|
599
856
|
var i;
|
|
600
|
-
return (i =
|
|
857
|
+
return (i = n()) == null ? void 0 : i.unobserve(s);
|
|
601
858
|
}
|
|
602
859
|
};
|
|
603
860
|
})(), this.range = null, this.setOptions = (e) => {
|
|
604
|
-
Object.entries(e).forEach(([
|
|
605
|
-
typeof
|
|
861
|
+
Object.entries(e).forEach(([n, s]) => {
|
|
862
|
+
typeof s > "u" && delete e[n];
|
|
606
863
|
}), this.options = {
|
|
607
864
|
debug: !1,
|
|
608
865
|
initialOffset: 0,
|
|
@@ -612,11 +869,11 @@ class Ve {
|
|
|
612
869
|
scrollPaddingStart: 0,
|
|
613
870
|
scrollPaddingEnd: 0,
|
|
614
871
|
horizontal: !1,
|
|
615
|
-
getItemKey:
|
|
616
|
-
rangeExtractor:
|
|
872
|
+
getItemKey: Nt,
|
|
873
|
+
rangeExtractor: _t,
|
|
617
874
|
onChange: () => {
|
|
618
875
|
},
|
|
619
|
-
measureElement:
|
|
876
|
+
measureElement: Tt,
|
|
620
877
|
initialRect: { width: 0, height: 0 },
|
|
621
878
|
scrollMargin: 0,
|
|
622
879
|
gap: 0,
|
|
@@ -631,9 +888,9 @@ class Ve {
|
|
|
631
888
|
...e
|
|
632
889
|
};
|
|
633
890
|
}, this.notify = (e) => {
|
|
634
|
-
var
|
|
635
|
-
(
|
|
636
|
-
}, this.maybeNotify =
|
|
891
|
+
var n, s;
|
|
892
|
+
(s = (n = this.options).onChange) == null || s.call(n, this, e);
|
|
893
|
+
}, this.maybeNotify = se(
|
|
637
894
|
() => (this.calculateRange(), [
|
|
638
895
|
this.isScrolling,
|
|
639
896
|
this.range ? this.range.startIndex : null,
|
|
@@ -657,41 +914,41 @@ class Ve {
|
|
|
657
914
|
this.cleanup();
|
|
658
915
|
}, this._willUpdate = () => {
|
|
659
916
|
var e;
|
|
660
|
-
const
|
|
661
|
-
if (this.scrollElement !==
|
|
662
|
-
if (this.cleanup(), !
|
|
917
|
+
const n = this.options.enabled ? this.options.getScrollElement() : null;
|
|
918
|
+
if (this.scrollElement !== n) {
|
|
919
|
+
if (this.cleanup(), !n) {
|
|
663
920
|
this.maybeNotify();
|
|
664
921
|
return;
|
|
665
922
|
}
|
|
666
|
-
this.scrollElement =
|
|
667
|
-
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);
|
|
668
925
|
}), this.unsubs.push(
|
|
669
|
-
this.options.observeElementRect(this, (
|
|
670
|
-
this.scrollRect =
|
|
926
|
+
this.options.observeElementRect(this, (s) => {
|
|
927
|
+
this.scrollRect = s, this.maybeNotify();
|
|
671
928
|
})
|
|
672
929
|
), this.unsubs.push(
|
|
673
|
-
this.options.observeElementOffset(this, (
|
|
674
|
-
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();
|
|
675
932
|
})
|
|
676
933
|
), this._scrollToOffset(this.getScrollOffset(), {
|
|
677
934
|
adjustments: void 0,
|
|
678
935
|
behavior: void 0
|
|
679
936
|
});
|
|
680
937
|
}
|
|
681
|
-
}, 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,
|
|
682
|
-
const
|
|
683
|
-
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--) {
|
|
684
941
|
const l = e[o];
|
|
685
|
-
if (
|
|
942
|
+
if (s.has(l.lane))
|
|
686
943
|
continue;
|
|
687
|
-
const
|
|
944
|
+
const g = i.get(
|
|
688
945
|
l.lane
|
|
689
946
|
);
|
|
690
|
-
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)
|
|
691
948
|
break;
|
|
692
949
|
}
|
|
693
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;
|
|
694
|
-
}, this.getMeasurementOptions =
|
|
951
|
+
}, this.getMeasurementOptions = se(
|
|
695
952
|
() => [
|
|
696
953
|
this.options.count,
|
|
697
954
|
this.options.paddingStart,
|
|
@@ -700,10 +957,10 @@ class Ve {
|
|
|
700
957
|
this.options.enabled,
|
|
701
958
|
this.options.lanes
|
|
702
959
|
],
|
|
703
|
-
(e,
|
|
960
|
+
(e, n, s, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
|
|
704
961
|
count: e,
|
|
705
|
-
paddingStart:
|
|
706
|
-
scrollMargin:
|
|
962
|
+
paddingStart: n,
|
|
963
|
+
scrollMargin: s,
|
|
707
964
|
getItemKey: i,
|
|
708
965
|
enabled: o,
|
|
709
966
|
lanes: l
|
|
@@ -711,142 +968,142 @@ class Ve {
|
|
|
711
968
|
{
|
|
712
969
|
key: !1
|
|
713
970
|
}
|
|
714
|
-
), this.getMeasurements =
|
|
971
|
+
), this.getMeasurements = se(
|
|
715
972
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
716
|
-
({ count: e, paddingStart:
|
|
973
|
+
({ count: e, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: o, lanes: l }, g) => {
|
|
717
974
|
if (!o)
|
|
718
975
|
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
719
976
|
if (this.laneAssignments.size > e)
|
|
720
|
-
for (const
|
|
721
|
-
|
|
722
|
-
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((
|
|
723
|
-
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);
|
|
724
981
|
}));
|
|
725
|
-
const
|
|
982
|
+
const m = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
726
983
|
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
|
|
727
|
-
const
|
|
984
|
+
const f = this.measurementsCache.slice(0, m), v = new Array(l).fill(
|
|
728
985
|
void 0
|
|
729
986
|
);
|
|
730
|
-
for (let
|
|
731
|
-
const
|
|
732
|
-
|
|
987
|
+
for (let u = 0; u < m; u++) {
|
|
988
|
+
const d = f[u];
|
|
989
|
+
d && (v[d.lane] = u);
|
|
733
990
|
}
|
|
734
|
-
for (let
|
|
735
|
-
const
|
|
736
|
-
let
|
|
737
|
-
if (
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
|
|
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;
|
|
741
998
|
} else {
|
|
742
|
-
const
|
|
743
|
-
|
|
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);
|
|
744
1001
|
}
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
index:
|
|
748
|
-
start:
|
|
749
|
-
size:
|
|
750
|
-
end:
|
|
751
|
-
key:
|
|
752
|
-
lane:
|
|
753
|
-
},
|
|
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;
|
|
754
1011
|
}
|
|
755
|
-
return this.measurementsCache =
|
|
1012
|
+
return this.measurementsCache = f, f;
|
|
756
1013
|
},
|
|
757
1014
|
{
|
|
758
1015
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
759
1016
|
debug: () => this.options.debug
|
|
760
1017
|
}
|
|
761
|
-
), this.calculateRange =
|
|
1018
|
+
), this.calculateRange = se(
|
|
762
1019
|
() => [
|
|
763
1020
|
this.getMeasurements(),
|
|
764
1021
|
this.getSize(),
|
|
765
1022
|
this.getScrollOffset(),
|
|
766
1023
|
this.options.lanes
|
|
767
1024
|
],
|
|
768
|
-
(e,
|
|
1025
|
+
(e, n, s, i) => this.range = e.length > 0 && n > 0 ? Mt({
|
|
769
1026
|
measurements: e,
|
|
770
|
-
outerSize:
|
|
771
|
-
scrollOffset:
|
|
1027
|
+
outerSize: n,
|
|
1028
|
+
scrollOffset: s,
|
|
772
1029
|
lanes: i
|
|
773
1030
|
}) : null,
|
|
774
1031
|
{
|
|
775
1032
|
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
776
1033
|
debug: () => this.options.debug
|
|
777
1034
|
}
|
|
778
|
-
), this.getVirtualIndexes =
|
|
1035
|
+
), this.getVirtualIndexes = se(
|
|
779
1036
|
() => {
|
|
780
|
-
let e = null,
|
|
781
|
-
const
|
|
782
|
-
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]), [
|
|
783
1040
|
this.options.rangeExtractor,
|
|
784
1041
|
this.options.overscan,
|
|
785
1042
|
this.options.count,
|
|
786
1043
|
e,
|
|
787
|
-
|
|
1044
|
+
n
|
|
788
1045
|
];
|
|
789
1046
|
},
|
|
790
|
-
(e,
|
|
1047
|
+
(e, n, s, i, o) => i === null || o === null ? [] : e({
|
|
791
1048
|
startIndex: i,
|
|
792
1049
|
endIndex: o,
|
|
793
|
-
overscan:
|
|
794
|
-
count:
|
|
1050
|
+
overscan: n,
|
|
1051
|
+
count: s
|
|
795
1052
|
}),
|
|
796
1053
|
{
|
|
797
1054
|
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
798
1055
|
debug: () => this.options.debug
|
|
799
1056
|
}
|
|
800
1057
|
), this.indexFromElement = (e) => {
|
|
801
|
-
const
|
|
802
|
-
return
|
|
803
|
-
`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.`
|
|
804
1061
|
), -1);
|
|
805
|
-
}, this._measureElement = (e,
|
|
806
|
-
const
|
|
1062
|
+
}, this._measureElement = (e, n) => {
|
|
1063
|
+
const s = this.indexFromElement(e), i = this.measurementsCache[s];
|
|
807
1064
|
if (!i)
|
|
808
1065
|
return;
|
|
809
1066
|
const o = i.key, l = this.elementsCache.get(o);
|
|
810
|
-
l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(
|
|
811
|
-
}, this.resizeItem = (e,
|
|
812
|
-
const
|
|
813
|
-
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)
|
|
814
1071
|
return;
|
|
815
|
-
const i = this.itemSizeCache.get(
|
|
816
|
-
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(), {
|
|
817
1074
|
adjustments: this.scrollAdjustments += o,
|
|
818
1075
|
behavior: void 0
|
|
819
|
-
})), this.pendingMeasuredCacheIndexes.push(
|
|
1076
|
+
})), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
|
|
820
1077
|
}, this.measureElement = (e) => {
|
|
821
1078
|
if (!e) {
|
|
822
|
-
this.elementsCache.forEach((
|
|
823
|
-
|
|
1079
|
+
this.elementsCache.forEach((n, s) => {
|
|
1080
|
+
n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
|
|
824
1081
|
});
|
|
825
1082
|
return;
|
|
826
1083
|
}
|
|
827
1084
|
this._measureElement(e, void 0);
|
|
828
|
-
}, this.getVirtualItems =
|
|
1085
|
+
}, this.getVirtualItems = se(
|
|
829
1086
|
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
830
|
-
(e,
|
|
831
|
-
const
|
|
1087
|
+
(e, n) => {
|
|
1088
|
+
const s = [];
|
|
832
1089
|
for (let i = 0, o = e.length; i < o; i++) {
|
|
833
|
-
const l = e[i],
|
|
834
|
-
|
|
1090
|
+
const l = e[i], g = n[l];
|
|
1091
|
+
s.push(g);
|
|
835
1092
|
}
|
|
836
|
-
return
|
|
1093
|
+
return s;
|
|
837
1094
|
},
|
|
838
1095
|
{
|
|
839
1096
|
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
840
1097
|
debug: () => this.options.debug
|
|
841
1098
|
}
|
|
842
1099
|
), this.getVirtualItemForOffset = (e) => {
|
|
843
|
-
const
|
|
844
|
-
if (
|
|
845
|
-
return
|
|
846
|
-
|
|
1100
|
+
const n = this.getMeasurements();
|
|
1101
|
+
if (n.length !== 0)
|
|
1102
|
+
return Ae(
|
|
1103
|
+
n[Le(
|
|
847
1104
|
0,
|
|
848
|
-
|
|
849
|
-
(
|
|
1105
|
+
n.length - 1,
|
|
1106
|
+
(s) => Ae(n[s]).start,
|
|
850
1107
|
e
|
|
851
1108
|
)]
|
|
852
1109
|
);
|
|
@@ -858,291 +1115,444 @@ class Ve {
|
|
|
858
1115
|
const e = this.scrollElement.document.documentElement;
|
|
859
1116
|
return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
|
|
860
1117
|
}
|
|
861
|
-
}, this.getOffsetForAlignment = (e,
|
|
1118
|
+
}, this.getOffsetForAlignment = (e, n, s = 0) => {
|
|
862
1119
|
if (!this.scrollElement) return 0;
|
|
863
1120
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
864
|
-
|
|
1121
|
+
n === "auto" && (n = e >= o + i ? "end" : "start"), n === "center" ? e += (s - i) / 2 : n === "end" && (e -= i);
|
|
865
1122
|
const l = this.getMaxScrollOffset();
|
|
866
1123
|
return Math.max(Math.min(l, e), 0);
|
|
867
|
-
}, this.getOffsetForIndex = (e,
|
|
1124
|
+
}, this.getOffsetForIndex = (e, n = "auto") => {
|
|
868
1125
|
e = Math.max(0, Math.min(e, this.options.count - 1));
|
|
869
|
-
const
|
|
870
|
-
if (!
|
|
1126
|
+
const s = this.measurementsCache[e];
|
|
1127
|
+
if (!s)
|
|
871
1128
|
return;
|
|
872
1129
|
const i = this.getSize(), o = this.getScrollOffset();
|
|
873
|
-
if (
|
|
874
|
-
if (
|
|
875
|
-
|
|
876
|
-
else if (
|
|
877
|
-
|
|
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";
|
|
878
1135
|
else
|
|
879
|
-
return [o,
|
|
880
|
-
if (
|
|
881
|
-
return [this.getMaxScrollOffset(),
|
|
882
|
-
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;
|
|
883
1140
|
return [
|
|
884
|
-
this.getOffsetForAlignment(l,
|
|
885
|
-
|
|
1141
|
+
this.getOffsetForAlignment(l, n, s.size),
|
|
1142
|
+
n
|
|
886
1143
|
];
|
|
887
|
-
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align:
|
|
888
|
-
|
|
1144
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: n = "start", behavior: s } = {}) => {
|
|
1145
|
+
s === "smooth" && this.isDynamicMode() && console.warn(
|
|
889
1146
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
890
|
-
), this._scrollToOffset(this.getOffsetForAlignment(e,
|
|
1147
|
+
), this._scrollToOffset(this.getOffsetForAlignment(e, n), {
|
|
891
1148
|
adjustments: void 0,
|
|
892
|
-
behavior:
|
|
1149
|
+
behavior: s
|
|
893
1150
|
});
|
|
894
|
-
}, this.scrollToIndex = (e, { align:
|
|
895
|
-
|
|
1151
|
+
}, this.scrollToIndex = (e, { align: n = "auto", behavior: s } = {}) => {
|
|
1152
|
+
s === "smooth" && this.isDynamicMode() && console.warn(
|
|
896
1153
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
897
1154
|
), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
|
|
898
1155
|
let i = 0;
|
|
899
|
-
const o = 10, l = (
|
|
1156
|
+
const o = 10, l = (m) => {
|
|
900
1157
|
if (!this.targetWindow) return;
|
|
901
|
-
const
|
|
902
|
-
if (!
|
|
1158
|
+
const f = this.getOffsetForIndex(e, m);
|
|
1159
|
+
if (!f) {
|
|
903
1160
|
console.warn("Failed to get offset for index:", e);
|
|
904
1161
|
return;
|
|
905
1162
|
}
|
|
906
|
-
const [
|
|
907
|
-
this._scrollToOffset(
|
|
908
|
-
const
|
|
1163
|
+
const [v, u] = f;
|
|
1164
|
+
this._scrollToOffset(v, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
|
|
1165
|
+
const d = () => {
|
|
909
1166
|
if (this.currentScrollToIndex !== e) return;
|
|
910
|
-
const
|
|
911
|
-
if (!
|
|
1167
|
+
const y = this.getScrollOffset(), x = this.getOffsetForIndex(e, u);
|
|
1168
|
+
if (!x) {
|
|
912
1169
|
console.warn("Failed to get offset for index:", e);
|
|
913
1170
|
return;
|
|
914
1171
|
}
|
|
915
|
-
|
|
1172
|
+
Ct(x[0], y) || g(u);
|
|
916
1173
|
};
|
|
917
|
-
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(
|
|
1174
|
+
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(d) : d();
|
|
918
1175
|
});
|
|
919
|
-
},
|
|
920
|
-
this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => l(
|
|
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(
|
|
921
1178
|
`Failed to scroll to index ${e} after ${o} attempts.`
|
|
922
1179
|
));
|
|
923
1180
|
};
|
|
924
|
-
l(
|
|
925
|
-
}, this.scrollBy = (e, { behavior:
|
|
926
|
-
|
|
1181
|
+
l(n);
|
|
1182
|
+
}, this.scrollBy = (e, { behavior: n } = {}) => {
|
|
1183
|
+
n === "smooth" && this.isDynamicMode() && console.warn(
|
|
927
1184
|
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
928
1185
|
), this._scrollToOffset(this.getScrollOffset() + e, {
|
|
929
1186
|
adjustments: void 0,
|
|
930
|
-
behavior:
|
|
1187
|
+
behavior: n
|
|
931
1188
|
});
|
|
932
1189
|
}, this.getTotalSize = () => {
|
|
933
1190
|
var e;
|
|
934
|
-
const
|
|
935
|
-
let
|
|
936
|
-
if (
|
|
937
|
-
|
|
1191
|
+
const n = this.getMeasurements();
|
|
1192
|
+
let s;
|
|
1193
|
+
if (n.length === 0)
|
|
1194
|
+
s = this.options.paddingStart;
|
|
938
1195
|
else if (this.options.lanes === 1)
|
|
939
|
-
|
|
1196
|
+
s = ((e = n[n.length - 1]) == null ? void 0 : e.end) ?? 0;
|
|
940
1197
|
else {
|
|
941
1198
|
const i = Array(this.options.lanes).fill(null);
|
|
942
|
-
let o =
|
|
1199
|
+
let o = n.length - 1;
|
|
943
1200
|
for (; o >= 0 && i.some((l) => l === null); ) {
|
|
944
|
-
const l =
|
|
1201
|
+
const l = n[o];
|
|
945
1202
|
i[l.lane] === null && (i[l.lane] = l.end), o--;
|
|
946
1203
|
}
|
|
947
|
-
|
|
1204
|
+
s = Math.max(...i.filter((l) => l !== null));
|
|
948
1205
|
}
|
|
949
1206
|
return Math.max(
|
|
950
|
-
|
|
1207
|
+
s - this.options.scrollMargin + this.options.paddingEnd,
|
|
951
1208
|
0
|
|
952
1209
|
);
|
|
953
1210
|
}, this._scrollToOffset = (e, {
|
|
954
|
-
adjustments:
|
|
955
|
-
behavior:
|
|
1211
|
+
adjustments: n,
|
|
1212
|
+
behavior: s
|
|
956
1213
|
}) => {
|
|
957
|
-
this.options.scrollToFn(e, { behavior:
|
|
1214
|
+
this.options.scrollToFn(e, { behavior: s, adjustments: n }, this);
|
|
958
1215
|
}, this.measure = () => {
|
|
959
1216
|
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
960
|
-
}, this.setOptions(
|
|
1217
|
+
}, this.setOptions(c);
|
|
961
1218
|
}
|
|
962
1219
|
}
|
|
963
|
-
const
|
|
964
|
-
for (; t <=
|
|
965
|
-
const
|
|
966
|
-
if (i <
|
|
967
|
-
t =
|
|
968
|
-
else if (i >
|
|
969
|
-
|
|
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;
|
|
970
1227
|
else
|
|
971
|
-
return
|
|
1228
|
+
return s;
|
|
972
1229
|
}
|
|
973
1230
|
return t > 0 ? t - 1 : 0;
|
|
974
1231
|
};
|
|
975
|
-
function
|
|
1232
|
+
function Mt({
|
|
976
1233
|
measurements: t,
|
|
977
|
-
outerSize:
|
|
1234
|
+
outerSize: c,
|
|
978
1235
|
scrollOffset: e,
|
|
979
|
-
lanes:
|
|
1236
|
+
lanes: n
|
|
980
1237
|
}) {
|
|
981
|
-
const
|
|
982
|
-
if (t.length <=
|
|
1238
|
+
const s = t.length - 1, i = (g) => t[g].start;
|
|
1239
|
+
if (t.length <= n)
|
|
983
1240
|
return {
|
|
984
1241
|
startIndex: 0,
|
|
985
|
-
endIndex:
|
|
1242
|
+
endIndex: s
|
|
986
1243
|
};
|
|
987
|
-
let o =
|
|
1244
|
+
let o = Le(
|
|
988
1245
|
0,
|
|
989
|
-
|
|
1246
|
+
s,
|
|
990
1247
|
i,
|
|
991
1248
|
e
|
|
992
1249
|
), l = o;
|
|
993
|
-
if (
|
|
994
|
-
for (; l <
|
|
1250
|
+
if (n === 1)
|
|
1251
|
+
for (; l < s && t[l].end < e + c; )
|
|
995
1252
|
l++;
|
|
996
|
-
else if (
|
|
997
|
-
const
|
|
998
|
-
for (; l <
|
|
999
|
-
const
|
|
1000
|
-
f
|
|
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++;
|
|
1001
1258
|
}
|
|
1002
|
-
const
|
|
1003
|
-
for (; o >= 0 &&
|
|
1004
|
-
const
|
|
1005
|
-
|
|
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--;
|
|
1006
1263
|
}
|
|
1007
|
-
o = Math.max(0, o - o %
|
|
1264
|
+
o = Math.max(0, o - o % n), l = Math.min(s, l + (n - 1 - l % n));
|
|
1008
1265
|
}
|
|
1009
1266
|
return { startIndex: o, endIndex: l };
|
|
1010
1267
|
}
|
|
1011
|
-
const
|
|
1012
|
-
function
|
|
1268
|
+
const De = typeof document < "u" ? me.useLayoutEffect : me.useEffect;
|
|
1269
|
+
function It({
|
|
1013
1270
|
useFlushSync: t = !0,
|
|
1014
|
-
...
|
|
1271
|
+
...c
|
|
1015
1272
|
}) {
|
|
1016
|
-
const e =
|
|
1017
|
-
...
|
|
1273
|
+
const e = me.useReducer(() => ({}), {})[1], n = {
|
|
1274
|
+
...c,
|
|
1018
1275
|
onChange: (i, o) => {
|
|
1019
1276
|
var l;
|
|
1020
|
-
t && o ?
|
|
1277
|
+
t && o ? ut(e) : e(), (l = c.onChange) == null || l.call(c, i, o);
|
|
1021
1278
|
}
|
|
1022
|
-
}, [
|
|
1023
|
-
() => new
|
|
1279
|
+
}, [s] = me.useState(
|
|
1280
|
+
() => new zt(n)
|
|
1024
1281
|
);
|
|
1025
|
-
return
|
|
1282
|
+
return s.setOptions(n), De(() => s._didMount(), []), De(() => s._willUpdate()), s;
|
|
1026
1283
|
}
|
|
1027
|
-
function
|
|
1028
|
-
return
|
|
1029
|
-
observeElementRect:
|
|
1030
|
-
observeElementOffset:
|
|
1031
|
-
scrollToFn:
|
|
1284
|
+
function Dt(t) {
|
|
1285
|
+
return It({
|
|
1286
|
+
observeElementRect: Rt,
|
|
1287
|
+
observeElementOffset: kt,
|
|
1288
|
+
scrollToFn: At,
|
|
1032
1289
|
...t
|
|
1033
1290
|
});
|
|
1034
1291
|
}
|
|
1035
|
-
const
|
|
1292
|
+
const Gt = ({
|
|
1036
1293
|
data: t,
|
|
1037
|
-
columns:
|
|
1294
|
+
columns: c,
|
|
1038
1295
|
rowHeight: e = 40,
|
|
1039
|
-
height:
|
|
1040
|
-
className:
|
|
1296
|
+
height: n = 600,
|
|
1297
|
+
className: s = "",
|
|
1041
1298
|
headerClassName: i = "",
|
|
1042
1299
|
rowClassName: o,
|
|
1043
1300
|
onRowClick: l,
|
|
1044
|
-
overscan:
|
|
1301
|
+
overscan: g = 5
|
|
1045
1302
|
}) => {
|
|
1046
|
-
const
|
|
1303
|
+
const m = pe(null), f = Dt({
|
|
1047
1304
|
count: t.length,
|
|
1048
|
-
getScrollElement: () =>
|
|
1305
|
+
getScrollElement: () => m.current,
|
|
1049
1306
|
estimateSize: () => e,
|
|
1050
|
-
overscan:
|
|
1051
|
-
}),
|
|
1052
|
-
return /* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */
|
|
1307
|
+
overscan: g
|
|
1308
|
+
}), v = f.getVirtualItems();
|
|
1309
|
+
return /* @__PURE__ */ a.jsxs("div", { className: s, children: [
|
|
1310
|
+
/* @__PURE__ */ a.jsx(
|
|
1054
1311
|
"div",
|
|
1055
1312
|
{
|
|
1056
1313
|
className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
|
|
1057
1314
|
style: {
|
|
1058
|
-
gridTemplateColumns:
|
|
1315
|
+
gridTemplateColumns: c.map((u) => u.width || "1fr").join(" ")
|
|
1059
1316
|
},
|
|
1060
|
-
children:
|
|
1317
|
+
children: c.map((u, d) => /* @__PURE__ */ a.jsx(
|
|
1061
1318
|
"div",
|
|
1062
1319
|
{
|
|
1063
|
-
className: `px-4 py-2 font-semibold text-sm ${
|
|
1064
|
-
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
|
|
1065
1322
|
},
|
|
1066
|
-
|
|
1323
|
+
d
|
|
1067
1324
|
))
|
|
1068
1325
|
}
|
|
1069
1326
|
),
|
|
1070
|
-
/* @__PURE__ */
|
|
1327
|
+
/* @__PURE__ */ a.jsx(
|
|
1071
1328
|
"div",
|
|
1072
1329
|
{
|
|
1073
|
-
ref:
|
|
1330
|
+
ref: m,
|
|
1074
1331
|
className: "overflow-auto",
|
|
1075
1332
|
style: {
|
|
1076
|
-
height: typeof
|
|
1333
|
+
height: typeof n == "number" ? `${n}px` : n,
|
|
1077
1334
|
contain: "strict"
|
|
1078
1335
|
},
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1336
|
+
children: /* @__PURE__ */ a.jsx(
|
|
1080
1337
|
"div",
|
|
1081
1338
|
{
|
|
1082
1339
|
style: {
|
|
1083
|
-
height: `${
|
|
1340
|
+
height: `${f.getTotalSize()}px`,
|
|
1084
1341
|
width: "100%",
|
|
1085
1342
|
position: "relative"
|
|
1086
1343
|
},
|
|
1087
|
-
children:
|
|
1088
|
-
const
|
|
1089
|
-
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(
|
|
1090
1347
|
"div",
|
|
1091
1348
|
{
|
|
1092
|
-
className: `grid border-b hover:bg-muted/50 cursor-pointer ${
|
|
1349
|
+
className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
|
|
1093
1350
|
style: {
|
|
1094
1351
|
position: "absolute",
|
|
1095
1352
|
top: 0,
|
|
1096
1353
|
left: 0,
|
|
1097
1354
|
width: "100%",
|
|
1098
|
-
height: `${
|
|
1099
|
-
transform: `translateY(${
|
|
1100
|
-
gridTemplateColumns:
|
|
1355
|
+
height: `${u.size}px`,
|
|
1356
|
+
transform: `translateY(${u.start}px)`,
|
|
1357
|
+
gridTemplateColumns: c.map((x) => x.width || "1fr").join(" ")
|
|
1101
1358
|
},
|
|
1102
|
-
onClick: () => l?.(
|
|
1103
|
-
children:
|
|
1104
|
-
const
|
|
1105
|
-
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(
|
|
1106
1363
|
"div",
|
|
1107
1364
|
{
|
|
1108
|
-
className: `px-4 py-2 text-sm flex items-center ${
|
|
1109
|
-
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: _
|
|
1110
1367
|
},
|
|
1111
|
-
|
|
1368
|
+
S
|
|
1112
1369
|
);
|
|
1113
1370
|
})
|
|
1114
1371
|
},
|
|
1115
|
-
|
|
1372
|
+
u.key
|
|
1116
1373
|
);
|
|
1117
1374
|
})
|
|
1118
1375
|
}
|
|
1119
1376
|
)
|
|
1120
1377
|
}
|
|
1121
1378
|
),
|
|
1122
|
-
/* @__PURE__ */
|
|
1379
|
+
/* @__PURE__ */ a.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
|
|
1123
1380
|
"Showing ",
|
|
1124
|
-
|
|
1381
|
+
v.length,
|
|
1125
1382
|
" of ",
|
|
1126
1383
|
t.length,
|
|
1127
1384
|
" rows (virtual scrolling enabled)"
|
|
1128
1385
|
] })
|
|
1129
1386
|
] });
|
|
1130
|
-
}, me = ({ schema: t, ...a }) => {
|
|
1131
|
-
const { dataSource: e } = Ee() || {};
|
|
1132
|
-
return /* @__PURE__ */ v.jsx(ke, { schema: t, dataSource: e, ...a });
|
|
1133
1387
|
};
|
|
1134
|
-
|
|
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, {
|
|
1135
1532
|
namespace: "plugin-grid",
|
|
1136
1533
|
label: "Object Grid",
|
|
1137
|
-
category: "plugin"
|
|
1534
|
+
category: "plugin",
|
|
1535
|
+
inputs: [
|
|
1536
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1537
|
+
{ name: "columns", type: "array", label: "Columns" },
|
|
1538
|
+
{ name: "filters", type: "array", label: "Filters" }
|
|
1539
|
+
]
|
|
1138
1540
|
});
|
|
1139
|
-
|
|
1541
|
+
Fe.register("grid", $e, {
|
|
1140
1542
|
namespace: "view",
|
|
1141
1543
|
label: "Data Grid",
|
|
1142
|
-
category: "view"
|
|
1544
|
+
category: "view",
|
|
1545
|
+
inputs: [
|
|
1546
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1547
|
+
{ name: "columns", type: "array", label: "Columns" },
|
|
1548
|
+
{ name: "filters", type: "array", label: "Filters" }
|
|
1549
|
+
]
|
|
1143
1550
|
});
|
|
1144
1551
|
export {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1552
|
+
Kt as InlineEditing,
|
|
1553
|
+
St as ObjectGrid,
|
|
1554
|
+
$e as ObjectGridRenderer,
|
|
1555
|
+
Gt as VirtualGrid,
|
|
1556
|
+
wt as useGroupedData,
|
|
1557
|
+
xt as useRowColor
|
|
1148
1558
|
};
|