@object-ui/plugin-grid 3.1.1 → 3.1.3
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 +5 -5
- package/CHANGELOG.md +22 -0
- package/dist/index.js +815 -774
- package/dist/index.umd.cjs +8 -8
- package/package.json +10 -10
- package/src/ListColumnExtensions.test.tsx +6 -6
- package/src/ObjectGrid.msw.test.tsx +3 -3
- package/src/ObjectGrid.stories.tsx +7 -7
- package/src/__tests__/accessorKey-inference.test.tsx +2 -2
- package/src/__tests__/airtable-style.test.tsx +8 -8
- package/src/__tests__/column-features.test.tsx +5 -5
- package/src/__tests__/grid-export.test.tsx +3 -3
- package/src/__tests__/mobile-card-view.test.tsx +6 -6
- package/src/__tests__/objectdef-enrichment.test.tsx +6 -6
- package/src/__tests__/row-bulk-actions.test.tsx +4 -4
- package/src/__tests__/row-height.test.tsx +2 -2
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import * as He from "react";
|
|
2
|
-
import
|
|
2
|
+
import ze, { useRef as xe, useState as I, useCallback as M, useEffect as me, createContext as fs, useMemo as ye } from "react";
|
|
3
3
|
import { evaluatePlainCondition as ms, buildExpandFields as hs, ComponentRegistry as rt } from "@object-ui/core";
|
|
4
|
-
import { useSafeFieldLabel as ps, useDataScope as gs, useNavigationOverlay as xs, useAction as bs, SchemaRenderer as jt, useObjectTranslation as
|
|
5
|
-
import { getCellRenderer as Ee, humanizeLabel as Ue, formatCompactCurrency as
|
|
6
|
-
import { DropdownMenu as Ns, DropdownMenuTrigger as Cs, Button as le, DropdownMenuContent as Ss, DropdownMenuItem as Ze, Badge as Te, NavigationOverlay as et, Popover as Es, PopoverTrigger as Rs, PopoverContent as ks, Dialog as _s, DialogContent as Os, DialogHeader as Ts, DialogTitle as As, DialogDescription as Ms, cn as ue, Progress as Ds, DialogFooter as
|
|
4
|
+
import { useSafeFieldLabel as ps, useDataScope as gs, useNavigationOverlay as xs, useAction as bs, SchemaRenderer as jt, useObjectTranslation as vs, useSchemaContext as Lt } from "@object-ui/react";
|
|
5
|
+
import { getCellRenderer as Ee, humanizeLabel as Ue, formatCompactCurrency as ys, formatDate as Qe, formatPercent as js, formatCurrency as ws } from "@object-ui/fields";
|
|
6
|
+
import { DropdownMenu as Ns, DropdownMenuTrigger as Cs, Button as le, DropdownMenuContent as Ss, DropdownMenuItem as Ze, Badge as Te, NavigationOverlay as et, Popover as Es, PopoverTrigger as Rs, PopoverContent as ks, Dialog as _s, DialogContent as Os, DialogHeader as Ts, DialogTitle as As, DialogDescription as Ms, cn as ue, Progress as Ds, DialogFooter as Is, Table as Pt, TableHeader as $t, TableRow as Ye, TableHead as Le, TableBody as Vt, TableCell as Pe, Select as Fs, SelectTrigger as zs, SelectValue as Ls, SelectContent as Ps, SelectItem as wt } from "@object-ui/components";
|
|
7
7
|
import { ChevronRight as $s, ChevronDown as Vs, MoreVertical as Ks, Edit as Ws, Trash2 as qs, AlignJustify as Nt, Rows2 as Bs, Rows3 as Us, Rows4 as Gs, Download as Ct, Type as tt, Tag as Hs, User as Ys, CheckSquare as Js, Clock as Xs, Calendar as Qs, Hash as st, FileSpreadsheet as Zs, ArrowRight as St, CheckCircle2 as en, X as it, ArrowLeft as tn, Upload as sn, AlertCircle as Kt, Check as Wt, FunctionSquare as nn, GripVertical as rn } from "lucide-react";
|
|
8
8
|
import { flushSync as on } from "react-dom";
|
|
9
|
-
var Ge = { exports: {} },
|
|
9
|
+
var Ge = { exports: {} }, Ie = {};
|
|
10
10
|
var Et;
|
|
11
11
|
function ln() {
|
|
12
|
-
if (Et) return
|
|
12
|
+
if (Et) return Ie;
|
|
13
13
|
Et = 1;
|
|
14
|
-
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
14
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
15
|
function t(n, r, i) {
|
|
16
16
|
var a = null;
|
|
17
17
|
if (i !== void 0 && (a = "" + i), r.key !== void 0 && (a = "" + r.key), "key" in r) {
|
|
18
18
|
i = {};
|
|
19
|
-
for (var
|
|
20
|
-
|
|
19
|
+
for (var o in r)
|
|
20
|
+
o !== "key" && (i[o] = r[o]);
|
|
21
21
|
} else i = r;
|
|
22
22
|
return r = i.ref, {
|
|
23
23
|
$$typeof: e,
|
|
@@ -27,18 +27,18 @@ function ln() {
|
|
|
27
27
|
props: i
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return Ie.Fragment = l, Ie.jsx = t, Ie.jsxs = t, Ie;
|
|
31
31
|
}
|
|
32
|
-
var
|
|
32
|
+
var Fe = {};
|
|
33
33
|
var Rt;
|
|
34
34
|
function an() {
|
|
35
35
|
return Rt || (Rt = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
|
-
function e(
|
|
37
|
-
if (
|
|
38
|
-
if (typeof
|
|
39
|
-
return
|
|
40
|
-
if (typeof
|
|
41
|
-
switch (
|
|
36
|
+
function e(d) {
|
|
37
|
+
if (d == null) return null;
|
|
38
|
+
if (typeof d == "function")
|
|
39
|
+
return d.$$typeof === ae ? null : d.displayName || d.name || null;
|
|
40
|
+
if (typeof d == "string") return d;
|
|
41
|
+
switch (d) {
|
|
42
42
|
case k:
|
|
43
43
|
return "Fragment";
|
|
44
44
|
case D:
|
|
@@ -52,145 +52,145 @@ function an() {
|
|
|
52
52
|
case Re:
|
|
53
53
|
return "Activity";
|
|
54
54
|
}
|
|
55
|
-
if (typeof
|
|
56
|
-
switch (typeof
|
|
55
|
+
if (typeof d == "object")
|
|
56
|
+
switch (typeof d.tag == "number" && console.error(
|
|
57
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
58
|
-
),
|
|
59
|
-
case
|
|
58
|
+
), d.$$typeof) {
|
|
59
|
+
case j:
|
|
60
60
|
return "Portal";
|
|
61
61
|
case G:
|
|
62
|
-
return
|
|
63
|
-
case
|
|
64
|
-
return (
|
|
62
|
+
return d.displayName || "Context";
|
|
63
|
+
case F:
|
|
64
|
+
return (d._context.displayName || "Context") + ".Consumer";
|
|
65
65
|
case W:
|
|
66
|
-
var _ =
|
|
67
|
-
return
|
|
66
|
+
var _ = d.render;
|
|
67
|
+
return d = d.displayName, d || (d = _.displayName || _.name || "", d = d !== "" ? "ForwardRef(" + d + ")" : "ForwardRef"), d;
|
|
68
68
|
case Ae:
|
|
69
|
-
return _ =
|
|
69
|
+
return _ = d.displayName || null, _ !== null ? _ : e(d.type) || "Memo";
|
|
70
70
|
case je:
|
|
71
|
-
_ =
|
|
71
|
+
_ = d._payload, d = d._init;
|
|
72
72
|
try {
|
|
73
|
-
return e(
|
|
73
|
+
return e(d(_));
|
|
74
74
|
} catch {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return "" +
|
|
79
|
+
function l(d) {
|
|
80
|
+
return "" + d;
|
|
81
81
|
}
|
|
82
|
-
function t(
|
|
82
|
+
function t(d) {
|
|
83
83
|
try {
|
|
84
|
-
|
|
84
|
+
l(d);
|
|
85
85
|
var _ = !1;
|
|
86
86
|
} catch {
|
|
87
87
|
_ = !0;
|
|
88
88
|
}
|
|
89
89
|
if (_) {
|
|
90
90
|
_ = console;
|
|
91
|
-
var $ = _.error, B = typeof Symbol == "function" && Symbol.toStringTag &&
|
|
91
|
+
var $ = _.error, B = typeof Symbol == "function" && Symbol.toStringTag && d[Symbol.toStringTag] || d.constructor.name || "Object";
|
|
92
92
|
return $.call(
|
|
93
93
|
_,
|
|
94
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
95
95
|
B
|
|
96
|
-
),
|
|
96
|
+
), l(d);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function n(
|
|
100
|
-
if (
|
|
101
|
-
if (typeof
|
|
99
|
+
function n(d) {
|
|
100
|
+
if (d === k) return "<>";
|
|
101
|
+
if (typeof d == "object" && d !== null && d.$$typeof === je)
|
|
102
102
|
return "<...>";
|
|
103
103
|
try {
|
|
104
|
-
var _ = e(
|
|
104
|
+
var _ = e(d);
|
|
105
105
|
return _ ? "<" + _ + ">" : "<...>";
|
|
106
106
|
} catch {
|
|
107
107
|
return "<...>";
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function r() {
|
|
111
|
-
var
|
|
112
|
-
return
|
|
111
|
+
var d = pe.A;
|
|
112
|
+
return d === null ? null : d.getOwner();
|
|
113
113
|
}
|
|
114
114
|
function i() {
|
|
115
115
|
return Error("react-stack-top-frame");
|
|
116
116
|
}
|
|
117
|
-
function a(
|
|
118
|
-
if (
|
|
119
|
-
var _ = Object.getOwnPropertyDescriptor(
|
|
117
|
+
function a(d) {
|
|
118
|
+
if (P.call(d, "key")) {
|
|
119
|
+
var _ = Object.getOwnPropertyDescriptor(d, "key").get;
|
|
120
120
|
if (_ && _.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
|
-
return
|
|
122
|
+
return d.key !== void 0;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function o(d, _) {
|
|
125
125
|
function $() {
|
|
126
126
|
ie || (ie = !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
|
_
|
|
129
129
|
));
|
|
130
130
|
}
|
|
131
|
-
$.isReactWarning = !0, Object.defineProperty(
|
|
131
|
+
$.isReactWarning = !0, Object.defineProperty(d, "key", {
|
|
132
132
|
get: $,
|
|
133
133
|
configurable: !0
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var
|
|
138
|
-
return we[
|
|
136
|
+
function m() {
|
|
137
|
+
var d = e(this.type);
|
|
138
|
+
return we[d] || (we[d] = !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
|
+
)), d = this.props.ref, d !== void 0 ? d : null;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
var
|
|
144
|
-
return
|
|
145
|
-
$$typeof:
|
|
146
|
-
type:
|
|
142
|
+
function h(d, _, $, B, Ne, X) {
|
|
143
|
+
var z = $.ref;
|
|
144
|
+
return d = {
|
|
145
|
+
$$typeof: y,
|
|
146
|
+
type: d,
|
|
147
147
|
key: _,
|
|
148
148
|
props: $,
|
|
149
149
|
_owner: B
|
|
150
|
-
}, (
|
|
150
|
+
}, (z !== void 0 ? z : null) !== null ? Object.defineProperty(d, "ref", {
|
|
151
151
|
enumerable: !1,
|
|
152
|
-
get:
|
|
153
|
-
}) : Object.defineProperty(
|
|
152
|
+
get: m
|
|
153
|
+
}) : Object.defineProperty(d, "ref", { enumerable: !1, value: null }), d._store = {}, Object.defineProperty(d._store, "validated", {
|
|
154
154
|
configurable: !1,
|
|
155
155
|
enumerable: !1,
|
|
156
156
|
writable: !0,
|
|
157
157
|
value: 0
|
|
158
|
-
}), Object.defineProperty(
|
|
158
|
+
}), Object.defineProperty(d, "_debugInfo", {
|
|
159
159
|
configurable: !1,
|
|
160
160
|
enumerable: !1,
|
|
161
161
|
writable: !0,
|
|
162
162
|
value: null
|
|
163
|
-
}), Object.defineProperty(
|
|
163
|
+
}), Object.defineProperty(d, "_debugStack", {
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
166
166
|
writable: !0,
|
|
167
167
|
value: Ne
|
|
168
|
-
}), Object.defineProperty(
|
|
168
|
+
}), Object.defineProperty(d, "_debugTask", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
171
171
|
writable: !0,
|
|
172
172
|
value: X
|
|
173
|
-
}), Object.freeze && (Object.freeze(
|
|
173
|
+
}), Object.freeze && (Object.freeze(d.props), Object.freeze(d)), d;
|
|
174
174
|
}
|
|
175
|
-
function d
|
|
176
|
-
var
|
|
177
|
-
if (
|
|
175
|
+
function u(d, _, $, B, Ne, X) {
|
|
176
|
+
var z = _.children;
|
|
177
|
+
if (z !== void 0)
|
|
178
178
|
if (B)
|
|
179
|
-
if (J(
|
|
180
|
-
for (B = 0; B <
|
|
181
|
-
|
|
182
|
-
Object.freeze && Object.freeze(
|
|
179
|
+
if (J(z)) {
|
|
180
|
+
for (B = 0; B < z.length; B++)
|
|
181
|
+
f(z[B]);
|
|
182
|
+
Object.freeze && Object.freeze(z);
|
|
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
|
-
|
|
187
|
+
else f(z);
|
|
188
|
+
if (P.call(_, "key")) {
|
|
189
|
+
z = e(d);
|
|
190
190
|
var Y = Object.keys(_).filter(function(he) {
|
|
191
191
|
return he !== "key";
|
|
192
192
|
});
|
|
193
|
-
B = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ge[
|
|
193
|
+
B = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ge[z + B] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
194
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
195
195
|
let props = %s;
|
|
196
196
|
<%s {...props} />
|
|
@@ -198,68 +198,68 @@ React keys must be passed directly to JSX without using spread:
|
|
|
198
198
|
let props = %s;
|
|
199
199
|
<%s key={someKey} {...props} />`,
|
|
200
200
|
B,
|
|
201
|
-
|
|
201
|
+
z,
|
|
202
202
|
Y,
|
|
203
|
-
|
|
204
|
-
), ge[
|
|
203
|
+
z
|
|
204
|
+
), ge[z + B] = !0);
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (z = null, $ !== void 0 && (t($), z = "" + $), a(_) && (t(_.key), z = "" + _.key), "key" in _) {
|
|
207
207
|
$ = {};
|
|
208
208
|
for (var ce in _)
|
|
209
209
|
ce !== "key" && ($[ce] = _[ce]);
|
|
210
210
|
} else $ = _;
|
|
211
|
-
return
|
|
211
|
+
return z && o(
|
|
212
212
|
$,
|
|
213
|
-
typeof
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
typeof d == "function" ? d.displayName || d.name || "Unknown" : d
|
|
214
|
+
), h(
|
|
215
|
+
d,
|
|
216
|
+
z,
|
|
217
217
|
$,
|
|
218
218
|
r(),
|
|
219
219
|
Ne,
|
|
220
220
|
X
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
p(
|
|
223
|
+
function f(d) {
|
|
224
|
+
p(d) ? d._store && (d._store.validated = 1) : typeof d == "object" && d !== null && d.$$typeof === je && (d._payload.status === "fulfilled" ? p(d._payload.value) && d._payload.value._store && (d._payload.value._store.validated = 1) : d._store && (d._store.validated = 1));
|
|
225
225
|
}
|
|
226
|
-
function p(
|
|
227
|
-
return typeof
|
|
226
|
+
function p(d) {
|
|
227
|
+
return typeof d == "object" && d !== null && d.$$typeof === y;
|
|
228
228
|
}
|
|
229
|
-
var x =
|
|
229
|
+
var x = ze, y = /* @__PURE__ */ Symbol.for("react.transitional.element"), j = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), D = /* @__PURE__ */ Symbol.for("react.profiler"), F = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), W = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), Ae = /* @__PURE__ */ Symbol.for("react.memo"), je = /* @__PURE__ */ Symbol.for("react.lazy"), Re = /* @__PURE__ */ Symbol.for("react.activity"), ae = /* @__PURE__ */ Symbol.for("react.client.reference"), pe = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, J = Array.isArray, fe = console.createTask ? console.createTask : function() {
|
|
230
230
|
return null;
|
|
231
231
|
};
|
|
232
232
|
x = {
|
|
233
|
-
react_stack_bottom_frame: function(
|
|
234
|
-
return
|
|
233
|
+
react_stack_bottom_frame: function(d) {
|
|
234
|
+
return d();
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
var ie, we = {}, ee = x.react_stack_bottom_frame.bind(
|
|
238
238
|
x,
|
|
239
239
|
i
|
|
240
240
|
)(), be = fe(n(i)), ge = {};
|
|
241
|
-
|
|
241
|
+
Fe.Fragment = k, Fe.jsx = function(d, _, $) {
|
|
242
242
|
var B = 1e4 > pe.recentlyCreatedOwnerStacks++;
|
|
243
|
-
return
|
|
244
|
-
|
|
243
|
+
return u(
|
|
244
|
+
d,
|
|
245
245
|
_,
|
|
246
246
|
$,
|
|
247
247
|
!1,
|
|
248
248
|
B ? Error("react-stack-top-frame") : ee,
|
|
249
|
-
B ? fe(n(
|
|
249
|
+
B ? fe(n(d)) : be
|
|
250
250
|
);
|
|
251
|
-
},
|
|
251
|
+
}, Fe.jsxs = function(d, _, $) {
|
|
252
252
|
var B = 1e4 > pe.recentlyCreatedOwnerStacks++;
|
|
253
|
-
return
|
|
254
|
-
|
|
253
|
+
return u(
|
|
254
|
+
d,
|
|
255
255
|
_,
|
|
256
256
|
$,
|
|
257
257
|
!0,
|
|
258
258
|
B ? Error("react-stack-top-frame") : ee,
|
|
259
|
-
B ? fe(n(
|
|
259
|
+
B ? fe(n(d)) : be
|
|
260
260
|
);
|
|
261
261
|
};
|
|
262
|
-
})()),
|
|
262
|
+
})()), Fe;
|
|
263
263
|
}
|
|
264
264
|
var kt;
|
|
265
265
|
function cn() {
|
|
@@ -267,36 +267,36 @@ function cn() {
|
|
|
267
267
|
}
|
|
268
268
|
var s = cn();
|
|
269
269
|
function dn(e) {
|
|
270
|
-
const { onRefresh:
|
|
270
|
+
const { onRefresh: l, threshold: t = 80, enabled: n = !0 } = e, r = xe(null), [i, a] = I(!1), [o, m] = I(0), h = xe(0), u = M((x) => {
|
|
271
271
|
if (!n || i)
|
|
272
272
|
return;
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
}, [n, i]),
|
|
276
|
-
if (!n || i || !
|
|
273
|
+
const y = r.current;
|
|
274
|
+
y && y.scrollTop === 0 && (h.current = x.touches[0].clientY);
|
|
275
|
+
}, [n, i]), f = M((x) => {
|
|
276
|
+
if (!n || i || !h.current)
|
|
277
277
|
return;
|
|
278
|
-
const
|
|
279
|
-
|
|
278
|
+
const j = x.touches[0].clientY - h.current;
|
|
279
|
+
j > 0 && m(Math.min(j, t * 1.5));
|
|
280
280
|
}, [n, i, t]), p = M(async () => {
|
|
281
281
|
if (!n || i)
|
|
282
282
|
return;
|
|
283
|
-
const x =
|
|
284
|
-
if (
|
|
283
|
+
const x = o;
|
|
284
|
+
if (m(0), h.current = 0, x >= t) {
|
|
285
285
|
a(!0);
|
|
286
286
|
try {
|
|
287
|
-
await
|
|
287
|
+
await l();
|
|
288
288
|
} finally {
|
|
289
289
|
a(!1);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
}, [n, i,
|
|
292
|
+
}, [n, i, o, t, l]);
|
|
293
293
|
return me(() => {
|
|
294
294
|
const x = r.current;
|
|
295
295
|
if (!(!x || !n))
|
|
296
|
-
return x.addEventListener("touchstart",
|
|
297
|
-
x.removeEventListener("touchstart",
|
|
296
|
+
return x.addEventListener("touchstart", u, { passive: !0 }), x.addEventListener("touchmove", f, { passive: !0 }), x.addEventListener("touchend", p, { passive: !0 }), () => {
|
|
297
|
+
x.removeEventListener("touchstart", u), x.removeEventListener("touchmove", f), x.removeEventListener("touchend", p);
|
|
298
298
|
};
|
|
299
|
-
}, [
|
|
299
|
+
}, [u, f, p, n]), { ref: r, isRefreshing: i, pullDistance: o };
|
|
300
300
|
}
|
|
301
301
|
const un = fs(null);
|
|
302
302
|
un.displayName = "MobileContext";
|
|
@@ -327,31 +327,31 @@ const fn = {
|
|
|
327
327
|
};
|
|
328
328
|
function mn(e) {
|
|
329
329
|
if (e.startsWith("bg-")) return e;
|
|
330
|
-
const
|
|
331
|
-
return fn[
|
|
330
|
+
const l = e.toLowerCase().trim();
|
|
331
|
+
return fn[l];
|
|
332
332
|
}
|
|
333
333
|
function hn(e) {
|
|
334
334
|
return M(
|
|
335
|
-
(
|
|
335
|
+
(l) => {
|
|
336
336
|
if (!e?.field || !e.colors) return;
|
|
337
|
-
const t = String(
|
|
337
|
+
const t = String(l[e.field] ?? ""), n = e.colors[t];
|
|
338
338
|
if (n)
|
|
339
339
|
return mn(n);
|
|
340
340
|
},
|
|
341
341
|
[e?.field, e?.colors]
|
|
342
342
|
);
|
|
343
343
|
}
|
|
344
|
-
function pn(e,
|
|
345
|
-
return
|
|
344
|
+
function pn(e, l) {
|
|
345
|
+
return l.map((t) => String(e[t.field] ?? "")).join(" / ");
|
|
346
346
|
}
|
|
347
|
-
function gn(e,
|
|
348
|
-
return
|
|
347
|
+
function gn(e, l) {
|
|
348
|
+
return l.map((t) => {
|
|
349
349
|
const n = e[t.field];
|
|
350
350
|
return n != null && n !== "" ? String(n) : "(empty)";
|
|
351
351
|
}).join(" / ");
|
|
352
352
|
}
|
|
353
|
-
function xn(e,
|
|
354
|
-
return
|
|
353
|
+
function xn(e, l) {
|
|
354
|
+
return l.map(({ field: t, type: n }) => {
|
|
355
355
|
const r = e.map((a) => Number(a[t])).filter((a) => Number.isFinite(a));
|
|
356
356
|
let i;
|
|
357
357
|
switch (n) {
|
|
@@ -359,10 +359,10 @@ function xn(e, o) {
|
|
|
359
359
|
i = r.length;
|
|
360
360
|
break;
|
|
361
361
|
case "sum":
|
|
362
|
-
i = r.reduce((a,
|
|
362
|
+
i = r.reduce((a, o) => a + o, 0);
|
|
363
363
|
break;
|
|
364
364
|
case "avg":
|
|
365
|
-
i = r.length > 0 ? r.reduce((a,
|
|
365
|
+
i = r.length > 0 ? r.reduce((a, o) => a + o, 0) / r.length : 0;
|
|
366
366
|
break;
|
|
367
367
|
case "min":
|
|
368
368
|
i = r.length > 0 ? Math.min(...r) : 0;
|
|
@@ -376,34 +376,34 @@ function xn(e, o) {
|
|
|
376
376
|
return { field: t, type: n, value: i };
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
function bn(e,
|
|
380
|
-
const n = e.localeCompare(
|
|
379
|
+
function bn(e, l, t) {
|
|
380
|
+
const n = e.localeCompare(l, void 0, { numeric: !0, sensitivity: "base" });
|
|
381
381
|
return t === "desc" ? -n : n;
|
|
382
382
|
}
|
|
383
|
-
function
|
|
384
|
-
const n = e?.fields, r = !!(n && n.length > 0), [i, a] =
|
|
383
|
+
function vn(e, l, t) {
|
|
384
|
+
const n = e?.fields, r = !!(n && n.length > 0), [i, a] = I({}), o = ye(() => n ? n.some((u) => u.collapsed) : !1, [n]), m = ye(() => {
|
|
385
385
|
if (!r || !n) return [];
|
|
386
|
-
const
|
|
387
|
-
for (const x of
|
|
388
|
-
const
|
|
389
|
-
|
|
386
|
+
const u = /* @__PURE__ */ new Map(), f = [];
|
|
387
|
+
for (const x of l) {
|
|
388
|
+
const y = pn(x, n);
|
|
389
|
+
u.has(y) || (u.set(y, { label: gn(x, n), rows: [] }), f.push(y)), u.get(y).rows.push(x);
|
|
390
390
|
}
|
|
391
391
|
const p = n[0]?.order ?? "asc";
|
|
392
|
-
return
|
|
393
|
-
const
|
|
394
|
-
return { key: x, label:
|
|
392
|
+
return f.sort((x, y) => bn(x, y, p)), f.map((x) => {
|
|
393
|
+
const y = u.get(x), j = x in i ? i[x] : o, k = t && t.length > 0 ? xn(y.rows, t) : [];
|
|
394
|
+
return { key: x, label: y.label, rows: y.rows, collapsed: j, aggregations: k };
|
|
395
395
|
});
|
|
396
|
-
}, [
|
|
397
|
-
a((
|
|
398
|
-
...
|
|
399
|
-
[
|
|
396
|
+
}, [l, n, r, i, o, t]), h = M((u) => {
|
|
397
|
+
a((f) => ({
|
|
398
|
+
...f,
|
|
399
|
+
[u]: f[u] !== void 0 ? !f[u] : !o
|
|
400
400
|
}));
|
|
401
|
-
}, [
|
|
402
|
-
return { groups:
|
|
401
|
+
}, [o]);
|
|
402
|
+
return { groups: m, isGrouped: r, toggleGroup: h };
|
|
403
403
|
}
|
|
404
|
-
const
|
|
404
|
+
const yn = ({
|
|
405
405
|
groupKey: e,
|
|
406
|
-
label:
|
|
406
|
+
label: l,
|
|
407
407
|
count: t,
|
|
408
408
|
collapsed: n,
|
|
409
409
|
aggregations: r,
|
|
@@ -419,12 +419,12 @@ const vn = ({
|
|
|
419
419
|
"aria-expanded": !n,
|
|
420
420
|
children: [
|
|
421
421
|
n ? /* @__PURE__ */ s.jsx($s, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ s.jsx(Vs, { className: "h-4 w-4 shrink-0" }),
|
|
422
|
-
/* @__PURE__ */ s.jsx("span", { className: "group-label", children:
|
|
423
|
-
r && r.length > 0 && /* @__PURE__ */ s.jsx("span", { className: "ml-2 text-xs text-muted-foreground group-aggregations", children: r.map((
|
|
424
|
-
|
|
422
|
+
/* @__PURE__ */ s.jsx("span", { className: "group-label", children: l }),
|
|
423
|
+
r && r.length > 0 && /* @__PURE__ */ s.jsx("span", { className: "ml-2 text-xs text-muted-foreground group-aggregations", children: r.map((o) => /* @__PURE__ */ s.jsxs("span", { className: "mr-2", children: [
|
|
424
|
+
o.type,
|
|
425
425
|
": ",
|
|
426
|
-
Number.isInteger(
|
|
427
|
-
] }, `${
|
|
426
|
+
Number.isInteger(o.value) ? o.value : o.value.toFixed(2)
|
|
427
|
+
] }, `${o.field}-${o.type}`)) }),
|
|
428
428
|
/* @__PURE__ */ s.jsxs("span", { className: "ml-auto text-xs text-muted-foreground group-count", children: [
|
|
429
429
|
"(",
|
|
430
430
|
t,
|
|
@@ -438,72 +438,72 @@ const vn = ({
|
|
|
438
438
|
function jn(e) {
|
|
439
439
|
return typeof e == "string" ? { type: e } : e;
|
|
440
440
|
}
|
|
441
|
-
function wn(e,
|
|
442
|
-
if (
|
|
441
|
+
function wn(e, l) {
|
|
442
|
+
if (l.length === 0) return null;
|
|
443
443
|
switch (e) {
|
|
444
444
|
case "count":
|
|
445
|
-
return
|
|
445
|
+
return l.length;
|
|
446
446
|
case "sum":
|
|
447
|
-
return
|
|
447
|
+
return l.reduce((t, n) => t + n, 0);
|
|
448
448
|
case "avg":
|
|
449
|
-
return
|
|
449
|
+
return l.reduce((t, n) => t + n, 0) / l.length;
|
|
450
450
|
case "min":
|
|
451
|
-
return Math.min(...
|
|
451
|
+
return Math.min(...l);
|
|
452
452
|
case "max":
|
|
453
|
-
return Math.max(...
|
|
453
|
+
return Math.max(...l);
|
|
454
454
|
default:
|
|
455
455
|
return null;
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
function Nn(e,
|
|
459
|
-
if (
|
|
458
|
+
function Nn(e, l) {
|
|
459
|
+
if (l === null) return "";
|
|
460
460
|
const n = {
|
|
461
461
|
count: "Count",
|
|
462
462
|
sum: "Sum",
|
|
463
463
|
avg: "Avg",
|
|
464
464
|
min: "Min",
|
|
465
465
|
max: "Max"
|
|
466
|
-
}[e] || e, r = e === "avg" ?
|
|
466
|
+
}[e] || e, r = e === "avg" ? l.toLocaleString(void 0, { maximumFractionDigits: 2 }) : l.toLocaleString();
|
|
467
467
|
return `${n}: ${r}`;
|
|
468
468
|
}
|
|
469
|
-
function Cn(e,
|
|
470
|
-
return
|
|
469
|
+
function Cn(e, l) {
|
|
470
|
+
return ye(() => {
|
|
471
471
|
const t = /* @__PURE__ */ new Map();
|
|
472
|
-
if (!e || e.length === 0 ||
|
|
472
|
+
if (!e || e.length === 0 || l.length === 0)
|
|
473
473
|
return { summaries: t, hasSummary: !1 };
|
|
474
474
|
for (const n of e) {
|
|
475
475
|
if (!n.summary) continue;
|
|
476
476
|
const r = jn(n.summary), i = r.field || n.field, a = [];
|
|
477
|
-
for (const
|
|
478
|
-
const
|
|
479
|
-
if (
|
|
480
|
-
a.push(
|
|
481
|
-
else if (
|
|
482
|
-
const
|
|
483
|
-
isNaN(
|
|
477
|
+
for (const m of l) {
|
|
478
|
+
const h = m[i];
|
|
479
|
+
if (h != null && typeof h == "number" && !isNaN(h))
|
|
480
|
+
a.push(h);
|
|
481
|
+
else if (h != null && typeof h == "string") {
|
|
482
|
+
const u = parseFloat(h);
|
|
483
|
+
isNaN(u) || a.push(u);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
let
|
|
486
|
+
let o;
|
|
487
487
|
if (r.type === "count") {
|
|
488
|
-
const
|
|
489
|
-
|
|
488
|
+
const m = l.filter((h) => h[i] != null && h[i] !== "").length;
|
|
489
|
+
o = m > 0 ? m : null;
|
|
490
490
|
} else
|
|
491
|
-
|
|
491
|
+
o = wn(r.type, a);
|
|
492
492
|
t.set(n.field, {
|
|
493
493
|
field: n.field,
|
|
494
|
-
value:
|
|
495
|
-
label: Nn(r.type,
|
|
494
|
+
value: o,
|
|
495
|
+
label: Nn(r.type, o)
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
return { summaries: t, hasSummary: t.size > 0 };
|
|
499
|
-
}, [e,
|
|
499
|
+
}, [e, l]);
|
|
500
500
|
}
|
|
501
501
|
function ot(e) {
|
|
502
|
-
return e.replace(/_/g, " ").replace(/\b\w/g, (
|
|
502
|
+
return e.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
503
503
|
}
|
|
504
504
|
const Sn = ({
|
|
505
505
|
row: e,
|
|
506
|
-
rowActions:
|
|
506
|
+
rowActions: l,
|
|
507
507
|
canEdit: t,
|
|
508
508
|
canDelete: n,
|
|
509
509
|
onEdit: r,
|
|
@@ -532,22 +532,22 @@ const Sn = ({
|
|
|
532
532
|
/* @__PURE__ */ s.jsx(qs, { className: "mr-2 h-4 w-4" }),
|
|
533
533
|
"Delete"
|
|
534
534
|
] }),
|
|
535
|
-
|
|
535
|
+
l?.map((o) => /* @__PURE__ */ s.jsx(
|
|
536
536
|
Ze,
|
|
537
537
|
{
|
|
538
|
-
onClick: () => a?.(
|
|
539
|
-
"data-testid": `row-action-${
|
|
540
|
-
children: ot(
|
|
538
|
+
onClick: () => a?.(o, e),
|
|
539
|
+
"data-testid": `row-action-${o}`,
|
|
540
|
+
children: ot(o)
|
|
541
541
|
},
|
|
542
|
-
|
|
542
|
+
o
|
|
543
543
|
))
|
|
544
544
|
] })
|
|
545
545
|
] }), _t = ({
|
|
546
546
|
selectedRows: e,
|
|
547
|
-
actions:
|
|
547
|
+
actions: l,
|
|
548
548
|
onAction: t,
|
|
549
549
|
onClearSelection: n
|
|
550
|
-
}) => !
|
|
550
|
+
}) => !l || l.length === 0 || e.length === 0 ? null : /* @__PURE__ */ s.jsxs(
|
|
551
551
|
"div",
|
|
552
552
|
{
|
|
553
553
|
className: "border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0",
|
|
@@ -557,7 +557,7 @@ const Sn = ({
|
|
|
557
557
|
e.length,
|
|
558
558
|
" selected"
|
|
559
559
|
] }),
|
|
560
|
-
/* @__PURE__ */ s.jsx("div", { className: "flex items-center gap-1 ml-2", children:
|
|
560
|
+
/* @__PURE__ */ s.jsx("div", { className: "flex items-center gap-1 ml-2", children: l.map((r) => /* @__PURE__ */ s.jsx(
|
|
561
561
|
le,
|
|
562
562
|
{
|
|
563
563
|
variant: "outline",
|
|
@@ -595,7 +595,7 @@ const Sn = ({
|
|
|
595
595
|
};
|
|
596
596
|
function En() {
|
|
597
597
|
try {
|
|
598
|
-
const e =
|
|
598
|
+
const e = vs();
|
|
599
599
|
return e.t("grid.actions") === "grid.actions" ? {
|
|
600
600
|
t: (t, n) => {
|
|
601
601
|
let r = Ot[t] || t;
|
|
@@ -607,10 +607,10 @@ function En() {
|
|
|
607
607
|
} : { t: e.t };
|
|
608
608
|
} catch {
|
|
609
609
|
return {
|
|
610
|
-
t: (e,
|
|
610
|
+
t: (e, l) => {
|
|
611
611
|
let t = Ot[e] || e;
|
|
612
|
-
if (
|
|
613
|
-
for (const [n, r] of Object.entries(
|
|
612
|
+
if (l)
|
|
613
|
+
for (const [n, r] of Object.entries(l))
|
|
614
614
|
t = t.replace(`{{${n}}}`, String(r));
|
|
615
615
|
return t;
|
|
616
616
|
}
|
|
@@ -639,18 +639,18 @@ function nt(e) {
|
|
|
639
639
|
}
|
|
640
640
|
const _n = ({
|
|
641
641
|
schema: e,
|
|
642
|
-
dataSource:
|
|
642
|
+
dataSource: l,
|
|
643
643
|
onEdit: t,
|
|
644
644
|
onDelete: n,
|
|
645
645
|
onRowSelect: r,
|
|
646
646
|
onRowClick: i,
|
|
647
647
|
onCellChange: a,
|
|
648
|
-
onRowSave:
|
|
649
|
-
onBatchSave:
|
|
650
|
-
onAddRecord:
|
|
651
|
-
...
|
|
648
|
+
onRowSave: o,
|
|
649
|
+
onBatchSave: m,
|
|
650
|
+
onAddRecord: h,
|
|
651
|
+
...u
|
|
652
652
|
}) => {
|
|
653
|
-
const [
|
|
653
|
+
const [f, p] = I([]), [x, y] = I(!0), [j, k] = I(null), { t: T } = En(), { fieldLabel: D } = ps(), [F, G] = I(null), [W, H] = I(!1), [re, Ae] = I(0), [je, Re] = I(!1), [ae, pe] = I(e.rowHeight ?? "compact"), [P, J] = I([]), fe = ze.useMemo(() => e.id ? `grid-columns-${e.objectName}-${e.id}` : `grid-columns-${e.objectName}`, [e.objectName, e.id]), [ie, we] = I(() => {
|
|
654
654
|
try {
|
|
655
655
|
const c = localStorage.getItem(fe);
|
|
656
656
|
return c ? JSON.parse(c) : {};
|
|
@@ -666,32 +666,32 @@ const _n = ({
|
|
|
666
666
|
}
|
|
667
667
|
}, [fe]), be = M(async () => {
|
|
668
668
|
Ae((c) => c + 1);
|
|
669
|
-
}, []), { ref: ge, isRefreshing:
|
|
669
|
+
}, []), { ref: ge, isRefreshing: d, pullDistance: _ } = dn({
|
|
670
670
|
onRefresh: be,
|
|
671
|
-
enabled: !!
|
|
671
|
+
enabled: !!l && !!e.objectName
|
|
672
672
|
});
|
|
673
673
|
me(() => {
|
|
674
674
|
const c = () => H(window.innerWidth < 480);
|
|
675
675
|
return c(), window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
|
|
676
676
|
}, []);
|
|
677
|
-
const $ =
|
|
677
|
+
const $ = u.data, B = gs(e.bind), Ne = kn(e), X = ze.useMemo(() => $ && Array.isArray($) ? {
|
|
678
678
|
provider: "value",
|
|
679
679
|
items: $
|
|
680
680
|
} : B && Array.isArray(B) ? {
|
|
681
681
|
provider: "value",
|
|
682
682
|
items: B
|
|
683
|
-
} : Ne, [JSON.stringify(Ne), B, $]),
|
|
683
|
+
} : Ne, [JSON.stringify(Ne), B, $]), z = X?.provider === "value", Y = X?.provider === "object" && X && "object" in X ? X.object : e.objectName, ce = e.fields, he = e.columns, $e = e.filter, ke = e.sort, lt = e.pagination, at = e.pageSize;
|
|
684
684
|
me(() => {
|
|
685
|
-
|
|
685
|
+
z && X?.provider === "value" && (p((c) => {
|
|
686
686
|
const O = X.items;
|
|
687
687
|
return JSON.stringify(c) !== JSON.stringify(O) ? O : c;
|
|
688
|
-
}),
|
|
689
|
-
}, [
|
|
690
|
-
if (!
|
|
688
|
+
}), y(!1));
|
|
689
|
+
}, [z, X]), me(() => {
|
|
690
|
+
if (!z || !Y || !l) return;
|
|
691
691
|
let c = !1;
|
|
692
692
|
return (async () => {
|
|
693
693
|
try {
|
|
694
|
-
const S = await
|
|
694
|
+
const S = await l.getObjectSchema(Y);
|
|
695
695
|
c || G(S);
|
|
696
696
|
} catch (S) {
|
|
697
697
|
console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${Y}):`, S);
|
|
@@ -699,23 +699,23 @@ const _n = ({
|
|
|
699
699
|
})(), () => {
|
|
700
700
|
c = !0;
|
|
701
701
|
};
|
|
702
|
-
}, [
|
|
703
|
-
if (
|
|
702
|
+
}, [z, Y, l]), me(() => {
|
|
703
|
+
if (z) return;
|
|
704
704
|
let c = !1;
|
|
705
705
|
return (async () => {
|
|
706
|
-
|
|
706
|
+
y(!0), k(null);
|
|
707
707
|
try {
|
|
708
708
|
let S = null;
|
|
709
709
|
const U = nt(he) || ce;
|
|
710
|
-
if (Y &&
|
|
711
|
-
const Q = await
|
|
710
|
+
if (Y && l) {
|
|
711
|
+
const Q = await l.getObjectSchema(Y);
|
|
712
712
|
if (c) return;
|
|
713
713
|
S = Q;
|
|
714
714
|
} else if (U && Y)
|
|
715
715
|
S = { name: Y, fields: {} };
|
|
716
716
|
else throw Y ? new Error("DataSource required") : new Error("Object name required for data fetching");
|
|
717
|
-
if (c || G(S),
|
|
718
|
-
const
|
|
717
|
+
if (c || G(S), l && Y) {
|
|
718
|
+
const v = {
|
|
719
719
|
$select: (() => {
|
|
720
720
|
if (ce) return ce;
|
|
721
721
|
if (he && Array.isArray(he))
|
|
@@ -723,22 +723,22 @@ const _n = ({
|
|
|
723
723
|
})(),
|
|
724
724
|
$top: lt?.pageSize || at || 50
|
|
725
725
|
};
|
|
726
|
-
$e && Array.isArray($e) ?
|
|
726
|
+
$e && Array.isArray($e) ? v.$filter = $e : e.defaultFilters && (v.$filter = e.defaultFilters), ke ? typeof ke == "string" ? v.$orderby = ke : Array.isArray(ke) && (v.$orderby = ke.map((w) => `${w.field} ${w.order}`).join(", ")) : e.defaultSort && (v.$orderby = `${e.defaultSort.field} ${e.defaultSort.order}`);
|
|
727
727
|
const g = hs(S?.fields, he ?? ce);
|
|
728
|
-
g.length > 0 && (
|
|
729
|
-
const N = await
|
|
728
|
+
g.length > 0 && (v.$expand = g);
|
|
729
|
+
const N = await l.find(Y, v);
|
|
730
730
|
if (c) return;
|
|
731
731
|
p(N.data || []);
|
|
732
732
|
}
|
|
733
733
|
} catch (S) {
|
|
734
734
|
c || k(S);
|
|
735
735
|
} finally {
|
|
736
|
-
c ||
|
|
736
|
+
c || y(!1);
|
|
737
737
|
}
|
|
738
738
|
})(), () => {
|
|
739
739
|
c = !0;
|
|
740
740
|
};
|
|
741
|
-
}, [Y, ce, he, $e, ke, lt, at,
|
|
741
|
+
}, [Y, ce, he, $e, ke, lt, at, l, z, X, re]);
|
|
742
742
|
const te = xs({
|
|
743
743
|
navigation: e.navigation,
|
|
744
744
|
objectName: e.objectName,
|
|
@@ -753,39 +753,39 @@ const _n = ({
|
|
|
753
753
|
if (Q)
|
|
754
754
|
U = ms(Q, c);
|
|
755
755
|
else if ("field" in S && "operator" in S && S.field && S.operator) {
|
|
756
|
-
const
|
|
757
|
-
switch (
|
|
756
|
+
const v = S, g = c[v.field];
|
|
757
|
+
switch (v.operator) {
|
|
758
758
|
case "equals":
|
|
759
|
-
U = g ===
|
|
759
|
+
U = g === v.value;
|
|
760
760
|
break;
|
|
761
761
|
case "not_equals":
|
|
762
|
-
U = g !==
|
|
762
|
+
U = g !== v.value;
|
|
763
763
|
break;
|
|
764
764
|
case "contains":
|
|
765
|
-
U = typeof g == "string" && typeof
|
|
765
|
+
U = typeof g == "string" && typeof v.value == "string" && g.includes(v.value);
|
|
766
766
|
break;
|
|
767
767
|
case "greater_than":
|
|
768
|
-
U = typeof g == "number" && typeof
|
|
768
|
+
U = typeof g == "number" && typeof v.value == "number" && g > v.value;
|
|
769
769
|
break;
|
|
770
770
|
case "less_than":
|
|
771
|
-
U = typeof g == "number" && typeof
|
|
771
|
+
U = typeof g == "number" && typeof v.value == "number" && g < v.value;
|
|
772
772
|
break;
|
|
773
773
|
case "in":
|
|
774
|
-
U = Array.isArray(
|
|
774
|
+
U = Array.isArray(v.value) && v.value.includes(g);
|
|
775
775
|
break;
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
if (U) {
|
|
779
|
-
const
|
|
780
|
-
return "style" in S && S.style && Object.assign(
|
|
779
|
+
const v = {};
|
|
780
|
+
return "style" in S && S.style && Object.assign(v, S.style), "backgroundColor" in S && S.backgroundColor && (v.backgroundColor = S.backgroundColor), "textColor" in S && S.textColor && (v.color = S.textColor), "borderColor" in S && S.borderColor && (v.borderColor = S.borderColor), v;
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
}, [e.conditionalFormatting]), { groups: Yt, isGrouped: ct, toggleGroup: Jt } =
|
|
783
|
+
}, [e.conditionalFormatting]), { groups: Yt, isGrouped: ct, toggleGroup: Jt } = vn(e.grouping, f), Xt = ze.useMemo(() => {
|
|
784
784
|
const c = nt(e.columns);
|
|
785
785
|
if (c && c.length > 0 && typeof c[0] == "object")
|
|
786
786
|
return c;
|
|
787
|
-
}, [e.columns]), { summaries: dt, hasSummary: Qt } = Cn(Xt,
|
|
788
|
-
const c = (
|
|
787
|
+
}, [e.columns]), { summaries: dt, hasSummary: Qt } = Cn(Xt, f), Ve = M(() => {
|
|
788
|
+
const c = (v) => v ? {
|
|
789
789
|
text: /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }),
|
|
790
790
|
number: /* @__PURE__ */ s.jsx(st, { className: "h-3.5 w-3.5" }),
|
|
791
791
|
currency: /* @__PURE__ */ s.jsx(st, { className: "h-3.5 w-3.5" }),
|
|
@@ -795,34 +795,34 @@ const _n = ({
|
|
|
795
795
|
boolean: /* @__PURE__ */ s.jsx(Js, { className: "h-3.5 w-3.5" }),
|
|
796
796
|
user: /* @__PURE__ */ s.jsx(Ys, { className: "h-3.5 w-3.5" }),
|
|
797
797
|
select: /* @__PURE__ */ s.jsx(Hs, { className: "h-3.5 w-3.5" })
|
|
798
|
-
}[
|
|
799
|
-
if (
|
|
800
|
-
const g =
|
|
798
|
+
}[v] || /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }), O = (v) => {
|
|
799
|
+
if (v.type) return v.type;
|
|
800
|
+
const g = v.field.toLowerCase();
|
|
801
801
|
if (["completed", "is_completed", "done", "active", "enabled", "archived"].some((E) => g === E || g === `is_${E}`))
|
|
802
802
|
return "boolean";
|
|
803
803
|
if (["created_time", "modified_time", "updated_time", "created_at", "updated_at", "modified_at", "last_login", "logged_at"].some((E) => g === E || g.endsWith(`_${E}`)))
|
|
804
804
|
return "datetime";
|
|
805
805
|
if (["date", "due", "created", "updated", "deadline", "start", "end", "expires"].some((E) => g.includes(E))) {
|
|
806
|
-
if (
|
|
807
|
-
const E =
|
|
806
|
+
if (f.length > 0) {
|
|
807
|
+
const E = f.find((L) => L[v.field] != null)?.[v.field];
|
|
808
808
|
if (typeof E == "string" && !isNaN(Date.parse(E)))
|
|
809
809
|
return "date";
|
|
810
810
|
}
|
|
811
811
|
return "date";
|
|
812
812
|
}
|
|
813
|
-
if (["probability", "percent", "percentage", "completion", "progress", "rate"].some((E) => g.includes(E)) &&
|
|
813
|
+
if (["probability", "percent", "percentage", "completion", "progress", "rate"].some((E) => g.includes(E)) && f.length > 0 && typeof f.find((L) => L[v.field] != null)?.[v.field] == "number")
|
|
814
814
|
return "percent";
|
|
815
|
-
if (["status", "priority", "category", "stage", "type", "severity", "level"].some((E) => g.includes(E)) &&
|
|
816
|
-
const E = new Set(
|
|
815
|
+
if (["status", "priority", "category", "stage", "type", "severity", "level"].some((E) => g.includes(E)) && f.length > 0) {
|
|
816
|
+
const E = new Set(f.map((L) => L[v.field]).filter(Boolean));
|
|
817
817
|
if (E.size > 0 && E.size <= 10)
|
|
818
818
|
return "select";
|
|
819
819
|
}
|
|
820
820
|
if (["assignee", "owner", "author", "reporter", "creator", "user"].some((E) => g.includes(E)))
|
|
821
821
|
return "user";
|
|
822
|
-
if (["amount", "price", "total", "revenue", "cost", "budget", "salary"].some((E) => g.includes(E)) &&
|
|
822
|
+
if (["amount", "price", "total", "revenue", "cost", "budget", "salary"].some((E) => g.includes(E)) && f.length > 0 && typeof f.find((L) => L[v.field] != null)?.[v.field] == "number")
|
|
823
823
|
return "currency";
|
|
824
|
-
if (
|
|
825
|
-
const E =
|
|
824
|
+
if (f.length > 0) {
|
|
825
|
+
const E = f.find((L) => L[v.field] != null)?.[v.field];
|
|
826
826
|
if (typeof E == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(E))
|
|
827
827
|
return "datetime";
|
|
828
828
|
}
|
|
@@ -830,15 +830,15 @@ const _n = ({
|
|
|
830
830
|
}, S = nt(he);
|
|
831
831
|
if (S) {
|
|
832
832
|
if (S.length > 0 && typeof S[0] == "object" && S[0] !== null) {
|
|
833
|
-
const
|
|
834
|
-
if ("accessorKey" in
|
|
833
|
+
const v = S[0];
|
|
834
|
+
if ("accessorKey" in v)
|
|
835
835
|
return S.map((g) => {
|
|
836
836
|
if (g.cell) return g;
|
|
837
837
|
const N = { field: g.accessorKey, label: g.header, type: g.type }, w = O(N);
|
|
838
838
|
if (!w) return g;
|
|
839
839
|
const A = Ee(w), C = { name: g.accessorKey, type: w };
|
|
840
840
|
if (w === "select") {
|
|
841
|
-
const b = Array.from(new Set(
|
|
841
|
+
const b = Array.from(new Set(f.map((R) => R[g.accessorKey]).filter(Boolean)));
|
|
842
842
|
C.options = b.map((R) => ({ value: R, label: Ue(String(R)) }));
|
|
843
843
|
}
|
|
844
844
|
return {
|
|
@@ -847,25 +847,25 @@ const _n = ({
|
|
|
847
847
|
cell: (b) => /* @__PURE__ */ s.jsx(A, { value: b, field: C })
|
|
848
848
|
};
|
|
849
849
|
});
|
|
850
|
-
if ("field" in
|
|
850
|
+
if ("field" in v)
|
|
851
851
|
return S.filter((g) => g?.field && typeof g.field == "string" && !g.hidden).map((g, N) => {
|
|
852
852
|
const w = Rn(g.label) || g.field.charAt(0).toUpperCase() + g.field.slice(1).replace(/_/g, " "), A = e.objectName ? D(e.objectName, g.field, w) : w;
|
|
853
853
|
let C;
|
|
854
|
-
const b =
|
|
854
|
+
const b = F?.fields?.[g.field], R = g.type || b?.type || O({ field: g.field }) || null, V = R ? Ee(R) : null, E = { name: g.field, type: R || "text" };
|
|
855
855
|
if (b && (b.label && (E.label = b.label), b.currency && (E.currency = b.currency), b.precision !== void 0 && (E.precision = b.precision), b.format && (E.format = b.format), b.options && (E.options = b.options)), R === "select" && !E.options) {
|
|
856
|
-
const q = Array.from(new Set(
|
|
856
|
+
const q = Array.from(new Set(f.map((oe) => oe[g.field]).filter(Boolean)));
|
|
857
857
|
E.options = q.map((oe) => ({ value: oe, label: Ue(String(oe)) }));
|
|
858
858
|
}
|
|
859
859
|
g.options && (E.options = g.options);
|
|
860
|
-
const
|
|
861
|
-
g.link && g.action ||
|
|
860
|
+
const L = N === 0 && !g.link && !g.action, Z = g.link || L;
|
|
861
|
+
g.link && g.action || L && g.action ? C = (q, oe) => {
|
|
862
862
|
const Se = V ? /* @__PURE__ */ s.jsx(V, { value: q, field: E }) : q != null && q !== "" ? String(q) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "—" });
|
|
863
863
|
return /* @__PURE__ */ s.jsx(
|
|
864
864
|
"button",
|
|
865
865
|
{
|
|
866
866
|
type: "button",
|
|
867
867
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
868
|
-
"data-testid":
|
|
868
|
+
"data-testid": L ? "primary-field-link" : "link-cell",
|
|
869
869
|
onClick: (_e) => {
|
|
870
870
|
_e.stopPropagation(), te.handleClick(oe);
|
|
871
871
|
},
|
|
@@ -879,7 +879,7 @@ const _n = ({
|
|
|
879
879
|
{
|
|
880
880
|
type: "button",
|
|
881
881
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
882
|
-
"data-testid":
|
|
882
|
+
"data-testid": L ? "primary-field-link" : "link-cell",
|
|
883
883
|
onClick: (_e) => {
|
|
884
884
|
_e.stopPropagation(), te.handleClick(oe);
|
|
885
885
|
},
|
|
@@ -913,14 +913,14 @@ const _n = ({
|
|
|
913
913
|
] });
|
|
914
914
|
};
|
|
915
915
|
}
|
|
916
|
-
const se = ["number", "currency", "percent"], ne = R || g.type,
|
|
916
|
+
const se = ["number", "currency", "percent"], ne = R || g.type, ve = g.align || (ne && se.includes(ne) ? "right" : void 0), K = N === 0 || g.essential === !0;
|
|
917
917
|
return {
|
|
918
918
|
header: A,
|
|
919
919
|
accessorKey: g.field,
|
|
920
920
|
headerIcon: c(R),
|
|
921
921
|
...!K && { className: "hidden sm:table-cell" },
|
|
922
922
|
...g.width && { width: g.width },
|
|
923
|
-
...
|
|
923
|
+
...ve && { align: ve },
|
|
924
924
|
sortable: g.sortable !== !1,
|
|
925
925
|
...g.resizable !== void 0 && { resizable: g.resizable },
|
|
926
926
|
...g.wrap !== void 0 && { wrap: g.wrap },
|
|
@@ -929,16 +929,16 @@ const _n = ({
|
|
|
929
929
|
};
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
|
-
return S.filter((
|
|
933
|
-
const N =
|
|
932
|
+
return S.filter((v) => typeof v == "string" && v.trim().length > 0).map((v, g) => {
|
|
933
|
+
const N = F?.fields?.[v], A = N?.label || v.charAt(0).toUpperCase() + v.slice(1).replace(/_/g, " "), C = e.objectName ? D(e.objectName, v, A) : A, b = N?.type || O({ field: v }) || null, R = b ? Ee(b) : null, V = { name: v, type: b || "text" };
|
|
934
934
|
if (N && (N.label && (V.label = N.label), N.currency && (V.currency = N.currency), N.precision !== void 0 && (V.precision = N.precision), N.format && (V.format = N.format), N.options && (V.options = N.options)), b === "select" && !V.options) {
|
|
935
|
-
const se = Array.from(new Set(
|
|
935
|
+
const se = Array.from(new Set(f.map((ne) => ne[v]).filter(Boolean)));
|
|
936
936
|
V.options = se.map((ne) => ({ value: ne, label: Ue(String(ne)) }));
|
|
937
937
|
}
|
|
938
|
-
const
|
|
938
|
+
const L = b && ["number", "currency", "percent"].includes(b) ? "right" : void 0, Z = g === 0;
|
|
939
939
|
let de;
|
|
940
940
|
return Z && R ? de = (se, ne) => {
|
|
941
|
-
const
|
|
941
|
+
const ve = /* @__PURE__ */ s.jsx(R, { value: se, field: V });
|
|
942
942
|
return /* @__PURE__ */ s.jsx(
|
|
943
943
|
"button",
|
|
944
944
|
{
|
|
@@ -948,7 +948,7 @@ const _n = ({
|
|
|
948
948
|
onClick: (K) => {
|
|
949
949
|
K.stopPropagation(), te.handleClick(ne);
|
|
950
950
|
},
|
|
951
|
-
children:
|
|
951
|
+
children: ve
|
|
952
952
|
}
|
|
953
953
|
);
|
|
954
954
|
} : Z ? de = (se, ne) => /* @__PURE__ */ s.jsx(
|
|
@@ -957,29 +957,29 @@ const _n = ({
|
|
|
957
957
|
type: "button",
|
|
958
958
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
959
959
|
"data-testid": "primary-field-link",
|
|
960
|
-
onClick: (
|
|
961
|
-
|
|
960
|
+
onClick: (ve) => {
|
|
961
|
+
ve.stopPropagation(), te.handleClick(ne);
|
|
962
962
|
},
|
|
963
963
|
children: se != null && se !== "" ? String(se) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "—" })
|
|
964
964
|
}
|
|
965
965
|
) : R && (de = (se) => /* @__PURE__ */ s.jsx(R, { value: se, field: V })), {
|
|
966
966
|
header: C,
|
|
967
|
-
accessorKey:
|
|
967
|
+
accessorKey: v,
|
|
968
968
|
...b && { headerIcon: c(b) },
|
|
969
|
-
...
|
|
969
|
+
...L && { align: L },
|
|
970
970
|
...de && { cell: de },
|
|
971
971
|
sortable: N?.sortable !== !1
|
|
972
972
|
};
|
|
973
973
|
});
|
|
974
974
|
}
|
|
975
|
-
if (
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
return (ce || Object.keys(
|
|
979
|
-
const w =
|
|
975
|
+
if (z) {
|
|
976
|
+
const v = X?.provider === "value" ? X.items : [];
|
|
977
|
+
if (v.length > 0)
|
|
978
|
+
return (ce || Object.keys(v[0])).map((N) => {
|
|
979
|
+
const w = F?.fields?.[N], A = w?.type || O({ field: N }) || null, C = A ? Ee(A) : null, b = w?.label || N.charAt(0).toUpperCase() + N.slice(1).replace(/_/g, " "), R = { name: N, type: A || "text" };
|
|
980
980
|
if (w && (w.label && (R.label = w.label), w.currency && (R.currency = w.currency), w.precision !== void 0 && (R.precision = w.precision), w.format && (R.format = w.format), w.options && (R.options = w.options)), A === "select" && !R.options) {
|
|
981
|
-
const
|
|
982
|
-
R.options =
|
|
981
|
+
const L = Array.from(new Set(f.map((Z) => Z[N]).filter(Boolean)));
|
|
982
|
+
R.options = L.map((Z) => ({ value: Z, label: Ue(String(Z)) }));
|
|
983
983
|
}
|
|
984
984
|
const E = A && ["number", "currency", "percent"].includes(A) ? "right" : void 0;
|
|
985
985
|
return {
|
|
@@ -987,27 +987,27 @@ const _n = ({
|
|
|
987
987
|
accessorKey: N,
|
|
988
988
|
...A && { headerIcon: c(A) },
|
|
989
989
|
...E && { align: E },
|
|
990
|
-
...C && { cell: (
|
|
990
|
+
...C && { cell: (L) => /* @__PURE__ */ s.jsx(C, { value: L, field: R }) },
|
|
991
991
|
sortable: w?.sortable !== !1
|
|
992
992
|
};
|
|
993
993
|
});
|
|
994
994
|
}
|
|
995
|
-
if (!
|
|
995
|
+
if (!F) return [];
|
|
996
996
|
const U = [];
|
|
997
|
-
return (ce || Object.keys(
|
|
998
|
-
const g =
|
|
997
|
+
return (ce || Object.keys(F.fields || {})).forEach((v) => {
|
|
998
|
+
const g = F.fields?.[v];
|
|
999
999
|
if (!g || g.permissions && g.permissions.read === !1) return;
|
|
1000
1000
|
const N = Ee(g.type), w = ["number", "currency", "percent"];
|
|
1001
1001
|
U.push({
|
|
1002
|
-
header: e.objectName ? D(e.objectName,
|
|
1003
|
-
accessorKey:
|
|
1002
|
+
header: e.objectName ? D(e.objectName, v, g.label || v) : g.label || v,
|
|
1003
|
+
accessorKey: v,
|
|
1004
1004
|
...w.includes(g.type) && { align: "right" },
|
|
1005
1005
|
cell: (A) => /* @__PURE__ */ s.jsx(N, { value: A, field: g }),
|
|
1006
1006
|
sortable: g.sortable !== !1
|
|
1007
1007
|
});
|
|
1008
1008
|
}), U;
|
|
1009
|
-
}, [
|
|
1010
|
-
const O = e.exportOptions, S = O?.maxRecords || 0, U = O?.includeHeaders !== !1, Q = O?.fileNamePrefix || e.objectName || "export",
|
|
1009
|
+
}, [F, ce, he, X, z, te.handleClick, Me, f, D, e.objectName]), Zt = M((c) => {
|
|
1010
|
+
const O = e.exportOptions, S = O?.maxRecords || 0, U = O?.includeHeaders !== !1, Q = O?.fileNamePrefix || e.objectName || "export", v = S > 0 ? f.slice(0, S) : f, g = (w, A) => {
|
|
1011
1011
|
const C = URL.createObjectURL(w), b = document.createElement("a");
|
|
1012
1012
|
b.href = C, b.download = A, b.click(), URL.revokeObjectURL(C);
|
|
1013
1013
|
}, N = (w) => {
|
|
@@ -1017,19 +1017,19 @@ const _n = ({
|
|
|
1017
1017
|
};
|
|
1018
1018
|
if (c === "csv") {
|
|
1019
1019
|
const w = Ve().filter((R) => R.accessorKey !== "_actions"), A = w.map((R) => R.accessorKey), C = w.map((R) => R.header), b = [];
|
|
1020
|
-
U && b.push(C.join(",")),
|
|
1020
|
+
U && b.push(C.join(",")), v.forEach((R) => {
|
|
1021
1021
|
b.push(A.map((V) => N(R[V])).join(","));
|
|
1022
1022
|
}), g(new Blob([b.join(`
|
|
1023
1023
|
`)], { type: "text/csv;charset=utf-8;" }), `${Q}.csv`);
|
|
1024
|
-
} else c === "json" && g(new Blob([JSON.stringify(
|
|
1024
|
+
} else c === "json" && g(new Blob([JSON.stringify(v, null, 2)], { type: "application/json" }), `${Q}.json`);
|
|
1025
1025
|
Re(!1);
|
|
1026
|
-
}, [
|
|
1027
|
-
if (
|
|
1026
|
+
}, [f, e.exportOptions, e.objectName, Ve]);
|
|
1027
|
+
if (j)
|
|
1028
1028
|
return /* @__PURE__ */ s.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
1029
1029
|
/* @__PURE__ */ s.jsx("h3", { className: "text-red-800 font-semibold", children: T("grid.errorLoading") }),
|
|
1030
|
-
/* @__PURE__ */ s.jsx("p", { className: "text-red-600 text-sm mt-1", children:
|
|
1030
|
+
/* @__PURE__ */ s.jsx("p", { className: "text-red-600 text-sm mt-1", children: j.message })
|
|
1031
1031
|
] });
|
|
1032
|
-
if (x &&
|
|
1032
|
+
if (x && f.length === 0)
|
|
1033
1033
|
return W ? /* @__PURE__ */ s.jsx("div", { className: "space-y-2 p-2", children: [1, 2, 3].map((c) => /* @__PURE__ */ s.jsxs("div", { className: "border rounded-lg p-3 bg-card animate-pulse", children: [
|
|
1034
1034
|
/* @__PURE__ */ s.jsx("div", { className: "h-5 bg-muted rounded w-3/4 mb-3" }),
|
|
1035
1035
|
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
@@ -1086,7 +1086,7 @@ const _n = ({
|
|
|
1086
1086
|
type: "data-table",
|
|
1087
1087
|
caption: e.label || e.title,
|
|
1088
1088
|
columns: pt,
|
|
1089
|
-
data:
|
|
1089
|
+
data: f,
|
|
1090
1090
|
pagination: rs,
|
|
1091
1091
|
pageSize: is,
|
|
1092
1092
|
searchable: os,
|
|
@@ -1102,7 +1102,7 @@ const _n = ({
|
|
|
1102
1102
|
cellClassName: ae === "compact" ? "px-3 py-1 text-[13px] leading-tight" : ae === "short" ? "px-3 py-1 text-[13px] leading-normal" : ae === "tall" ? "px-3 py-2.5 text-sm" : ae === "extra_tall" ? "px-3 py-3.5 text-sm leading-relaxed" : "px-3 py-1.5 text-[13px] leading-normal",
|
|
1103
1103
|
showRowNumbers: !0,
|
|
1104
1104
|
showAddRow: !!Ce?.create,
|
|
1105
|
-
onAddRecord:
|
|
1105
|
+
onAddRecord: h,
|
|
1106
1106
|
rowClassName: e.rowColor ? (c, O) => Gt(c) : void 0,
|
|
1107
1107
|
rowStyle: e.conditionalFormatting?.length ? (c, O) => Ht(c) : void 0,
|
|
1108
1108
|
frozenColumns: ss,
|
|
@@ -1111,8 +1111,8 @@ const _n = ({
|
|
|
1111
1111
|
},
|
|
1112
1112
|
onRowClick: te.handleClick,
|
|
1113
1113
|
onCellChange: a,
|
|
1114
|
-
onRowSave:
|
|
1115
|
-
onBatchSave:
|
|
1114
|
+
onRowSave: o,
|
|
1115
|
+
onBatchSave: m,
|
|
1116
1116
|
onColumnResize: (c, O) => {
|
|
1117
1117
|
ee({
|
|
1118
1118
|
...ie,
|
|
@@ -1132,10 +1132,10 @@ const _n = ({
|
|
|
1132
1132
|
pagination: !1,
|
|
1133
1133
|
searchable: !1
|
|
1134
1134
|
}), Xe = e.label ? `${e.label} Detail` : e.objectName ? `${e.objectName.charAt(0).toUpperCase() + e.objectName.slice(1)} Detail` : "Record Detail";
|
|
1135
|
-
if (W &&
|
|
1135
|
+
if (W && f.length > 0 && !ct) {
|
|
1136
1136
|
const c = Ve().filter((C) => C.accessorKey !== "_actions"), O = /* @__PURE__ */ new Map();
|
|
1137
1137
|
c.forEach((C) => O.set(C.accessorKey, C));
|
|
1138
|
-
const S = c[0], U = ["amount", "price", "total", "revenue", "cost", "value", "budget", "salary"], Q = ["stage", "status", "priority", "category", "severity", "level"],
|
|
1138
|
+
const S = c[0], U = ["amount", "price", "total", "revenue", "cost", "value", "budget", "salary"], Q = ["stage", "status", "priority", "category", "severity", "level"], v = ["date", "due", "created", "updated", "deadline", "start", "end", "expires"], g = ["probability", "percent", "rate", "ratio", "confidence", "score"], N = (C) => {
|
|
1139
1139
|
const b = (C || "").toLowerCase();
|
|
1140
1140
|
return b.includes("won") || b.includes("completed") || b.includes("done") || b.includes("active") ? "bg-green-100 text-green-800 border-green-300" : b.includes("lost") || b.includes("cancelled") || b.includes("rejected") || b.includes("closed lost") ? "bg-red-100 text-red-800 border-red-300" : b.includes("negotiation") || b.includes("review") || b.includes("in progress") ? "bg-yellow-100 text-yellow-800 border-yellow-300" : b.includes("proposal") || b.includes("pending") ? "bg-blue-100 text-blue-800 border-blue-300" : b.includes("qualification") || b.includes("qualified") ? "bg-indigo-100 text-indigo-800 border-indigo-300" : b.includes("prospecting") || b.includes("new") || b.includes("open") ? "bg-purple-100 text-purple-800 border-purple-300" : "bg-muted text-muted-foreground border-border";
|
|
1141
1141
|
}, w = (C) => {
|
|
@@ -1143,25 +1143,25 @@ const _n = ({
|
|
|
1143
1143
|
return b.includes("won") || b.includes("completed") || b.includes("done") || b.includes("active") ? "border-l-green-500" : b.includes("lost") || b.includes("cancelled") || b.includes("rejected") ? "border-l-red-500" : b.includes("negotiation") || b.includes("review") || b.includes("in progress") ? "border-l-yellow-500" : b.includes("proposal") || b.includes("pending") ? "border-l-blue-500" : b.includes("qualification") || b.includes("qualified") ? "border-l-indigo-500" : b.includes("prospecting") || b.includes("new") || b.includes("open") ? "border-l-purple-500" : "border-l-gray-300";
|
|
1144
1144
|
}, A = (C) => {
|
|
1145
1145
|
const b = C.toLowerCase();
|
|
1146
|
-
return U.some((R) => b.includes(R)) ? "amount" : Q.some((R) => b.includes(R)) ? "stage" :
|
|
1146
|
+
return U.some((R) => b.includes(R)) ? "amount" : Q.some((R) => b.includes(R)) ? "stage" : v.some((R) => b.includes(R)) ? "date" : g.some((R) => b.includes(R)) ? "percent" : "other";
|
|
1147
1147
|
};
|
|
1148
1148
|
return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
|
|
1149
|
-
/* @__PURE__ */ s.jsx("div", { className: "space-y-2 p-2", children:
|
|
1150
|
-
const R = c.slice(1, 5), V = R.find((K) => A(K.accessorKey) === "amount"), E = R.find((K) => A(K.accessorKey) === "stage"),
|
|
1151
|
-
(K) => K !== V && K !== E && !
|
|
1152
|
-
), se = E ? String(C[E.accessorKey] ?? "") : "", ne = se ? w(se) : "",
|
|
1149
|
+
/* @__PURE__ */ s.jsx("div", { className: "space-y-2 p-2", children: f.map((C, b) => {
|
|
1150
|
+
const R = c.slice(1, 5), V = R.find((K) => A(K.accessorKey) === "amount"), E = R.find((K) => A(K.accessorKey) === "stage"), L = R.filter((K) => A(K.accessorKey) === "date"), Z = R.filter((K) => A(K.accessorKey) === "percent"), de = R.filter(
|
|
1151
|
+
(K) => K !== V && K !== E && !L.includes(K) && !Z.includes(K)
|
|
1152
|
+
), se = E ? String(C[E.accessorKey] ?? "") : "", ne = se ? w(se) : "", ve = [
|
|
1153
1153
|
"border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
|
|
1154
1154
|
ne ? `border-l-[3px] ${ne}` : ""
|
|
1155
1155
|
].filter(Boolean).join(" ");
|
|
1156
1156
|
return /* @__PURE__ */ s.jsxs(
|
|
1157
1157
|
"div",
|
|
1158
1158
|
{
|
|
1159
|
-
className:
|
|
1159
|
+
className: ve,
|
|
1160
1160
|
onClick: () => te.handleClick(C),
|
|
1161
1161
|
children: [
|
|
1162
1162
|
S && /* @__PURE__ */ s.jsx("div", { className: "font-semibold text-sm truncate mb-1", children: C[S.accessorKey] ?? "—" }),
|
|
1163
1163
|
(V || E) && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between gap-2 mb-1", children: [
|
|
1164
|
-
V && /* @__PURE__ */ s.jsx("span", { className: "text-sm tabular-nums font-medium", children: typeof C[V.accessorKey] == "number" ?
|
|
1164
|
+
V && /* @__PURE__ */ s.jsx("span", { className: "text-sm tabular-nums font-medium", children: typeof C[V.accessorKey] == "number" ? ys(C[V.accessorKey]) : C[V.accessorKey] ?? "—" }),
|
|
1165
1165
|
E && C[E.accessorKey] && /* @__PURE__ */ s.jsx(
|
|
1166
1166
|
Te,
|
|
1167
1167
|
{
|
|
@@ -1171,11 +1171,11 @@ const _n = ({
|
|
|
1171
1171
|
}
|
|
1172
1172
|
)
|
|
1173
1173
|
] }),
|
|
1174
|
-
(
|
|
1175
|
-
|
|
1174
|
+
(L.length > 0 || Z.length > 0) && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between py-0.5 text-xs text-muted-foreground", children: [
|
|
1175
|
+
L[0] && /* @__PURE__ */ s.jsx("span", { className: "tabular-nums", children: C[L[0].accessorKey] ? Qe(C[L[0].accessorKey], "short") : "—" }),
|
|
1176
1176
|
Z[0] && C[Z[0].accessorKey] != null && /* @__PURE__ */ s.jsx("span", { className: "tabular-nums", children: js(Number(C[Z[0].accessorKey])) })
|
|
1177
1177
|
] }),
|
|
1178
|
-
|
|
1178
|
+
L.slice(1).map((K) => /* @__PURE__ */ s.jsxs("div", { className: "flex justify-between items-center py-0.5", children: [
|
|
1179
1179
|
/* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground", children: K.header }),
|
|
1180
1180
|
/* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground tabular-nums", children: C[K.accessorKey] ? Qe(C[K.accessorKey], "short") : "—" })
|
|
1181
1181
|
] }, K.accessorKey)),
|
|
@@ -1242,11 +1242,11 @@ const _n = ({
|
|
|
1242
1242
|
c
|
|
1243
1243
|
)) }) })
|
|
1244
1244
|
] })
|
|
1245
|
-
] }) : null,
|
|
1246
|
-
const O = ["_id", "id", "created_at", "updated_at", "created_by", "updated_by"], S = Object.entries(c), U = S.filter(([N]) => !O.includes(N)), Q = S.filter(([N]) => O.includes(N) && N !== "_id" && N !== "id"),
|
|
1245
|
+
] }) : null, vt = (c) => {
|
|
1246
|
+
const O = ["_id", "id", "created_at", "updated_at", "created_by", "updated_by"], S = Object.entries(c), U = S.filter(([N]) => !O.includes(N)), Q = S.filter(([N]) => O.includes(N) && N !== "_id" && N !== "id"), v = (N) => N.charAt(0).toUpperCase() + N.slice(1).replace(/_/g, " "), g = (N, w) => {
|
|
1247
1247
|
if (w == null || w === "")
|
|
1248
1248
|
return /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-sm italic", children: "Empty" });
|
|
1249
|
-
const A =
|
|
1249
|
+
const A = F?.fields?.[N];
|
|
1250
1250
|
if (A?.type) {
|
|
1251
1251
|
const b = Ee(A.type);
|
|
1252
1252
|
if (b)
|
|
@@ -1256,13 +1256,13 @@ const _n = ({
|
|
|
1256
1256
|
};
|
|
1257
1257
|
return /* @__PURE__ */ s.jsxs("div", { className: "space-y-4", "data-testid": "record-detail-panel", children: [
|
|
1258
1258
|
/* @__PURE__ */ s.jsx("div", { className: "rounded-lg border bg-card", children: /* @__PURE__ */ s.jsx("div", { className: "divide-y", children: U.map(([N, w]) => /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3", children: [
|
|
1259
|
-
/* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0", children:
|
|
1259
|
+
/* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0", children: v(N) }),
|
|
1260
1260
|
/* @__PURE__ */ s.jsx("div", { className: "flex-1 min-w-0", children: g(N, w) })
|
|
1261
1261
|
] }, N)) }) }),
|
|
1262
1262
|
Q.length > 0 && /* @__PURE__ */ s.jsxs("div", { className: "rounded-lg border bg-muted/30", children: [
|
|
1263
1263
|
/* @__PURE__ */ s.jsx("div", { className: "px-4 py-2 border-b", children: /* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "System" }) }),
|
|
1264
1264
|
/* @__PURE__ */ s.jsx("div", { className: "divide-y divide-border/50", children: Q.map(([N, w]) => /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-4 px-4 py-2", children: [
|
|
1265
|
-
/* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground w-1/3 text-right shrink-0", children:
|
|
1265
|
+
/* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground w-1/3 text-right shrink-0", children: v(N) }),
|
|
1266
1266
|
/* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground flex-1 min-w-0 break-words", children: String(w ?? "") })
|
|
1267
1267
|
] }, N)) })
|
|
1268
1268
|
] })
|
|
@@ -1274,8 +1274,8 @@ const _n = ({
|
|
|
1274
1274
|
": ",
|
|
1275
1275
|
O.label
|
|
1276
1276
|
] }, c.accessorKey);
|
|
1277
|
-
}) }) }) : null,
|
|
1278
|
-
|
|
1277
|
+
}) }) }) : null, yt = ct ? /* @__PURE__ */ s.jsx("div", { className: "space-y-2", children: Yt.map((c) => /* @__PURE__ */ s.jsx(
|
|
1278
|
+
yn,
|
|
1279
1279
|
{
|
|
1280
1280
|
groupKey: c.key,
|
|
1281
1281
|
label: c.label,
|
|
@@ -1297,18 +1297,18 @@ const _n = ({
|
|
|
1297
1297
|
title: Xe,
|
|
1298
1298
|
mainContent: /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
|
|
1299
1299
|
bt,
|
|
1300
|
-
|
|
1300
|
+
yt,
|
|
1301
1301
|
/* @__PURE__ */ s.jsx(
|
|
1302
1302
|
_t,
|
|
1303
1303
|
{
|
|
1304
|
-
selectedRows:
|
|
1304
|
+
selectedRows: P,
|
|
1305
1305
|
actions: We ?? [],
|
|
1306
1306
|
onAction: (c, O) => Me({ type: c, params: { records: O } }),
|
|
1307
1307
|
onClearSelection: () => J([])
|
|
1308
1308
|
}
|
|
1309
1309
|
)
|
|
1310
1310
|
] }),
|
|
1311
|
-
children: (c) =>
|
|
1311
|
+
children: (c) => vt(c)
|
|
1312
1312
|
}
|
|
1313
1313
|
) : /* @__PURE__ */ s.jsxs("div", { ref: ge, className: "relative h-full", children: [
|
|
1314
1314
|
_ > 0 && /* @__PURE__ */ s.jsx(
|
|
@@ -1316,15 +1316,15 @@ const _n = ({
|
|
|
1316
1316
|
{
|
|
1317
1317
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1318
1318
|
style: { height: _ },
|
|
1319
|
-
children: T(
|
|
1319
|
+
children: T(d ? "grid.refreshing" : "grid.pullToRefresh")
|
|
1320
1320
|
}
|
|
1321
1321
|
),
|
|
1322
1322
|
bt,
|
|
1323
|
-
|
|
1323
|
+
yt,
|
|
1324
1324
|
/* @__PURE__ */ s.jsx(
|
|
1325
1325
|
_t,
|
|
1326
1326
|
{
|
|
1327
|
-
selectedRows:
|
|
1327
|
+
selectedRows: P,
|
|
1328
1328
|
actions: We ?? [],
|
|
1329
1329
|
onAction: (c, O) => Me({ type: c, params: { records: O } }),
|
|
1330
1330
|
onClearSelection: () => J([])
|
|
@@ -1335,30 +1335,30 @@ const _n = ({
|
|
|
1335
1335
|
{
|
|
1336
1336
|
...te,
|
|
1337
1337
|
title: Xe,
|
|
1338
|
-
children: (c) =>
|
|
1338
|
+
children: (c) => vt(c)
|
|
1339
1339
|
}
|
|
1340
1340
|
)
|
|
1341
1341
|
] });
|
|
1342
1342
|
};
|
|
1343
|
-
function Oe(e,
|
|
1343
|
+
function Oe(e, l, t) {
|
|
1344
1344
|
let n = t.initialDeps ?? [], r, i = !0;
|
|
1345
1345
|
function a() {
|
|
1346
|
-
var
|
|
1347
|
-
let
|
|
1348
|
-
t.key && ((
|
|
1349
|
-
const
|
|
1350
|
-
if (!(
|
|
1346
|
+
var o, m, h;
|
|
1347
|
+
let u;
|
|
1348
|
+
t.key && ((o = t.debug) != null && o.call(t)) && (u = Date.now());
|
|
1349
|
+
const f = e();
|
|
1350
|
+
if (!(f.length !== n.length || f.some((y, j) => n[j] !== y)))
|
|
1351
1351
|
return r;
|
|
1352
|
-
n =
|
|
1352
|
+
n = f;
|
|
1353
1353
|
let x;
|
|
1354
|
-
if (t.key && ((
|
|
1355
|
-
const
|
|
1356
|
-
for (D = String(D); D.length <
|
|
1354
|
+
if (t.key && ((m = t.debug) != null && m.call(t)) && (x = Date.now()), r = l(...f), t.key && ((h = t.debug) != null && h.call(t))) {
|
|
1355
|
+
const y = Math.round((Date.now() - u) * 100) / 100, j = Math.round((Date.now() - x) * 100) / 100, k = j / 16, T = (D, F) => {
|
|
1356
|
+
for (D = String(D); D.length < F; )
|
|
1357
1357
|
D = " " + D;
|
|
1358
1358
|
return D;
|
|
1359
1359
|
};
|
|
1360
1360
|
console.info(
|
|
1361
|
-
`%c⏱ ${T(
|
|
1361
|
+
`%c⏱ ${T(j, 5)} /${T(y, 5)} ms`,
|
|
1362
1362
|
`
|
|
1363
1363
|
font-size: .6rem;
|
|
1364
1364
|
font-weight: bold;
|
|
@@ -1371,29 +1371,29 @@ function Oe(e, o, t) {
|
|
|
1371
1371
|
}
|
|
1372
1372
|
return t?.onChange && !(i && t.skipInitialOnChange) && t.onChange(r), i = !1, r;
|
|
1373
1373
|
}
|
|
1374
|
-
return a.updateDeps = (
|
|
1375
|
-
n =
|
|
1374
|
+
return a.updateDeps = (o) => {
|
|
1375
|
+
n = o;
|
|
1376
1376
|
}, a;
|
|
1377
1377
|
}
|
|
1378
|
-
function Tt(e,
|
|
1378
|
+
function Tt(e, l) {
|
|
1379
1379
|
if (e === void 0)
|
|
1380
1380
|
throw new Error("Unexpected undefined");
|
|
1381
1381
|
return e;
|
|
1382
1382
|
}
|
|
1383
|
-
const On = (e,
|
|
1383
|
+
const On = (e, l) => Math.abs(e - l) < 1.01, Tn = (e, l, t) => {
|
|
1384
1384
|
let n;
|
|
1385
1385
|
return function(...r) {
|
|
1386
|
-
e.clearTimeout(n), n = e.setTimeout(() =>
|
|
1386
|
+
e.clearTimeout(n), n = e.setTimeout(() => l.apply(this, r), t);
|
|
1387
1387
|
};
|
|
1388
1388
|
}, At = (e) => {
|
|
1389
|
-
const { offsetWidth:
|
|
1390
|
-
return { width:
|
|
1389
|
+
const { offsetWidth: l, offsetHeight: t } = e;
|
|
1390
|
+
return { width: l, height: t };
|
|
1391
1391
|
}, An = (e) => e, Mn = (e) => {
|
|
1392
|
-
const
|
|
1393
|
-
for (let r =
|
|
1392
|
+
const l = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
|
|
1393
|
+
for (let r = l; r <= t; r++)
|
|
1394
1394
|
n.push(r);
|
|
1395
1395
|
return n;
|
|
1396
|
-
}, Dn = (e,
|
|
1396
|
+
}, Dn = (e, l) => {
|
|
1397
1397
|
const t = e.scrollElement;
|
|
1398
1398
|
if (!t)
|
|
1399
1399
|
return;
|
|
@@ -1401,32 +1401,32 @@ const On = (e, o) => Math.abs(e - o) < 1.01, Tn = (e, o, t) => {
|
|
|
1401
1401
|
if (!n)
|
|
1402
1402
|
return;
|
|
1403
1403
|
const r = (a) => {
|
|
1404
|
-
const { width:
|
|
1405
|
-
|
|
1404
|
+
const { width: o, height: m } = a;
|
|
1405
|
+
l({ width: Math.round(o), height: Math.round(m) });
|
|
1406
1406
|
};
|
|
1407
1407
|
if (r(At(t)), !n.ResizeObserver)
|
|
1408
1408
|
return () => {
|
|
1409
1409
|
};
|
|
1410
1410
|
const i = new n.ResizeObserver((a) => {
|
|
1411
|
-
const
|
|
1412
|
-
const
|
|
1413
|
-
if (
|
|
1414
|
-
const
|
|
1415
|
-
if (
|
|
1416
|
-
r({ width:
|
|
1411
|
+
const o = () => {
|
|
1412
|
+
const m = a[0];
|
|
1413
|
+
if (m?.borderBoxSize) {
|
|
1414
|
+
const h = m.borderBoxSize[0];
|
|
1415
|
+
if (h) {
|
|
1416
|
+
r({ width: h.inlineSize, height: h.blockSize });
|
|
1417
1417
|
return;
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
1420
|
r(At(t));
|
|
1421
1421
|
};
|
|
1422
|
-
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(
|
|
1422
|
+
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
|
|
1423
1423
|
});
|
|
1424
1424
|
return i.observe(t, { box: "border-box" }), () => {
|
|
1425
1425
|
i.unobserve(t);
|
|
1426
1426
|
};
|
|
1427
1427
|
}, Mt = {
|
|
1428
1428
|
passive: !0
|
|
1429
|
-
}, Dt = typeof window > "u" ? !0 : "onscrollend" in window,
|
|
1429
|
+
}, Dt = typeof window > "u" ? !0 : "onscrollend" in window, In = (e, l) => {
|
|
1430
1430
|
const t = e.scrollElement;
|
|
1431
1431
|
if (!t)
|
|
1432
1432
|
return;
|
|
@@ -1438,41 +1438,44 @@ const On = (e, o) => Math.abs(e - o) < 1.01, Tn = (e, o, t) => {
|
|
|
1438
1438
|
} : Tn(
|
|
1439
1439
|
n,
|
|
1440
1440
|
() => {
|
|
1441
|
-
|
|
1441
|
+
l(r, !1);
|
|
1442
1442
|
},
|
|
1443
1443
|
e.options.isScrollingResetDelay
|
|
1444
|
-
), a = (
|
|
1445
|
-
const { horizontal:
|
|
1446
|
-
r =
|
|
1447
|
-
},
|
|
1448
|
-
t.addEventListener("scroll",
|
|
1449
|
-
const
|
|
1450
|
-
return
|
|
1451
|
-
t.removeEventListener("scroll",
|
|
1444
|
+
), a = (u) => () => {
|
|
1445
|
+
const { horizontal: f, isRtl: p } = e.options;
|
|
1446
|
+
r = f ? t.scrollLeft * (p && -1 || 1) : t.scrollTop, i(), l(r, u);
|
|
1447
|
+
}, o = a(!0), m = a(!1);
|
|
1448
|
+
t.addEventListener("scroll", o, Mt);
|
|
1449
|
+
const h = e.options.useScrollendEvent && Dt;
|
|
1450
|
+
return h && t.addEventListener("scrollend", m, Mt), () => {
|
|
1451
|
+
t.removeEventListener("scroll", o), h && t.removeEventListener("scrollend", m);
|
|
1452
1452
|
};
|
|
1453
|
-
},
|
|
1454
|
-
if (
|
|
1455
|
-
const n =
|
|
1453
|
+
}, Fn = (e, l, t) => {
|
|
1454
|
+
if (l?.borderBoxSize) {
|
|
1455
|
+
const n = l.borderBoxSize[0];
|
|
1456
1456
|
if (n)
|
|
1457
1457
|
return Math.round(
|
|
1458
1458
|
n[t.options.horizontal ? "inlineSize" : "blockSize"]
|
|
1459
1459
|
);
|
|
1460
1460
|
}
|
|
1461
1461
|
return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
1462
|
-
},
|
|
1463
|
-
adjustments:
|
|
1462
|
+
}, zn = (e, {
|
|
1463
|
+
adjustments: l = 0,
|
|
1464
1464
|
behavior: t
|
|
1465
1465
|
}, n) => {
|
|
1466
1466
|
var r, i;
|
|
1467
|
-
const a = e +
|
|
1467
|
+
const a = e + l;
|
|
1468
1468
|
(i = (r = n.scrollElement) == null ? void 0 : r.scrollTo) == null || i.call(r, {
|
|
1469
1469
|
[n.options.horizontal ? "left" : "top"]: a,
|
|
1470
1470
|
behavior: t
|
|
1471
1471
|
});
|
|
1472
1472
|
};
|
|
1473
|
-
class
|
|
1474
|
-
constructor(
|
|
1475
|
-
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.
|
|
1473
|
+
class Ln {
|
|
1474
|
+
constructor(l) {
|
|
1475
|
+
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = 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.now = () => {
|
|
1476
|
+
var t, n, r;
|
|
1477
|
+
return ((r = (n = (t = this.targetWindow) == null ? void 0 : t.performance) == null ? void 0 : n.now) == null ? void 0 : r.call(n)) ?? Date.now();
|
|
1478
|
+
}, this.observer = /* @__PURE__ */ (() => {
|
|
1476
1479
|
let t = null;
|
|
1477
1480
|
const n = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((r) => {
|
|
1478
1481
|
r.forEach((i) => {
|
|
@@ -1512,7 +1515,7 @@ class Pn {
|
|
|
1512
1515
|
rangeExtractor: Mn,
|
|
1513
1516
|
onChange: () => {
|
|
1514
1517
|
},
|
|
1515
|
-
measureElement:
|
|
1518
|
+
measureElement: Fn,
|
|
1516
1519
|
initialRect: { width: 0, height: 0 },
|
|
1517
1520
|
scrollMargin: 0,
|
|
1518
1521
|
gap: 0,
|
|
@@ -1548,7 +1551,7 @@ class Pn {
|
|
|
1548
1551
|
]
|
|
1549
1552
|
}
|
|
1550
1553
|
), this.cleanup = () => {
|
|
1551
|
-
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
|
1554
|
+
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.scrollElement = null, this.targetWindow = null;
|
|
1552
1555
|
}, this._didMount = () => () => {
|
|
1553
1556
|
this.cleanup();
|
|
1554
1557
|
}, this._willUpdate = () => {
|
|
@@ -1567,26 +1570,26 @@ class Pn {
|
|
|
1567
1570
|
})
|
|
1568
1571
|
), this.unsubs.push(
|
|
1569
1572
|
this.options.observeElementOffset(this, (r, i) => {
|
|
1570
|
-
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < r ? "forward" : "backward" : null, this.scrollOffset = r, this.isScrolling = i, this.maybeNotify();
|
|
1573
|
+
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < r ? "forward" : "backward" : null, this.scrollOffset = r, this.isScrolling = i, this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
|
|
1571
1574
|
})
|
|
1572
1575
|
), this._scrollToOffset(this.getScrollOffset(), {
|
|
1573
1576
|
adjustments: void 0,
|
|
1574
1577
|
behavior: void 0
|
|
1575
1578
|
});
|
|
1576
1579
|
}
|
|
1577
|
-
}, 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 = (t, n) => {
|
|
1580
|
+
}, this.rafId = null, 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 = (t, n) => {
|
|
1578
1581
|
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
1579
1582
|
for (let a = n - 1; a >= 0; a--) {
|
|
1580
|
-
const
|
|
1581
|
-
if (r.has(
|
|
1583
|
+
const o = t[a];
|
|
1584
|
+
if (r.has(o.lane))
|
|
1582
1585
|
continue;
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1586
|
+
const m = i.get(
|
|
1587
|
+
o.lane
|
|
1585
1588
|
);
|
|
1586
|
-
if (
|
|
1589
|
+
if (m == null || o.end > m.end ? i.set(o.lane, o) : o.end < m.end && r.set(o.lane, !0), r.size === this.options.lanes)
|
|
1587
1590
|
break;
|
|
1588
1591
|
}
|
|
1589
|
-
return i.size === this.options.lanes ? Array.from(i.values()).sort((a,
|
|
1592
|
+
return i.size === this.options.lanes ? Array.from(i.values()).sort((a, o) => a.end === o.end ? a.index - o.index : a.end - o.end)[0] : void 0;
|
|
1590
1593
|
}, this.getMeasurementOptions = Oe(
|
|
1591
1594
|
() => [
|
|
1592
1595
|
this.options.count,
|
|
@@ -1596,20 +1599,20 @@ class Pn {
|
|
|
1596
1599
|
this.options.enabled,
|
|
1597
1600
|
this.options.lanes
|
|
1598
1601
|
],
|
|
1599
|
-
(t, n, r, i, a,
|
|
1602
|
+
(t, n, r, i, a, o) => (this.prevLanes !== void 0 && this.prevLanes !== o && (this.lanesChangedFlag = !0), this.prevLanes = o, this.pendingMeasuredCacheIndexes = [], {
|
|
1600
1603
|
count: t,
|
|
1601
1604
|
paddingStart: n,
|
|
1602
1605
|
scrollMargin: r,
|
|
1603
1606
|
getItemKey: i,
|
|
1604
1607
|
enabled: a,
|
|
1605
|
-
lanes:
|
|
1608
|
+
lanes: o
|
|
1606
1609
|
}),
|
|
1607
1610
|
{
|
|
1608
1611
|
key: !1
|
|
1609
1612
|
}
|
|
1610
1613
|
), this.getMeasurements = Oe(
|
|
1611
1614
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
1612
|
-
({ count: t, paddingStart: n, scrollMargin: r, getItemKey: i, enabled: a, lanes:
|
|
1615
|
+
({ count: t, paddingStart: n, scrollMargin: r, getItemKey: i, enabled: a, lanes: o }, m) => {
|
|
1613
1616
|
if (!a)
|
|
1614
1617
|
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
1615
1618
|
if (this.laneAssignments.size > t)
|
|
@@ -1618,37 +1621,37 @@ class Pn {
|
|
|
1618
1621
|
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((p) => {
|
|
1619
1622
|
this.itemSizeCache.set(p.key, p.size);
|
|
1620
1623
|
}));
|
|
1621
|
-
const
|
|
1624
|
+
const h = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
1622
1625
|
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1);
|
|
1623
|
-
const
|
|
1626
|
+
const u = this.measurementsCache.slice(0, h), f = new Array(o).fill(
|
|
1624
1627
|
void 0
|
|
1625
1628
|
);
|
|
1626
|
-
for (let p = 0; p <
|
|
1627
|
-
const x =
|
|
1628
|
-
x && (
|
|
1629
|
+
for (let p = 0; p < h; p++) {
|
|
1630
|
+
const x = u[p];
|
|
1631
|
+
x && (f[x.lane] = p);
|
|
1629
1632
|
}
|
|
1630
|
-
for (let p =
|
|
1631
|
-
const x = i(p),
|
|
1632
|
-
let
|
|
1633
|
-
if (
|
|
1634
|
-
|
|
1635
|
-
const G =
|
|
1633
|
+
for (let p = h; p < t; p++) {
|
|
1634
|
+
const x = i(p), y = this.laneAssignments.get(p);
|
|
1635
|
+
let j, k;
|
|
1636
|
+
if (y !== void 0 && this.options.lanes > 1) {
|
|
1637
|
+
j = y;
|
|
1638
|
+
const G = f[j], W = G !== void 0 ? u[G] : void 0;
|
|
1636
1639
|
k = W ? W.end + this.options.gap : n + r;
|
|
1637
1640
|
} else {
|
|
1638
|
-
const G = this.options.lanes === 1 ?
|
|
1639
|
-
k = G ? G.end + this.options.gap : n + r,
|
|
1641
|
+
const G = this.options.lanes === 1 ? u[p - 1] : this.getFurthestMeasurement(u, p);
|
|
1642
|
+
k = G ? G.end + this.options.gap : n + r, j = G ? G.lane : p % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(p, j);
|
|
1640
1643
|
}
|
|
1641
|
-
const T =
|
|
1642
|
-
|
|
1644
|
+
const T = m.get(x), D = typeof T == "number" ? T : this.options.estimateSize(p), F = k + D;
|
|
1645
|
+
u[p] = {
|
|
1643
1646
|
index: p,
|
|
1644
1647
|
start: k,
|
|
1645
1648
|
size: D,
|
|
1646
|
-
end:
|
|
1649
|
+
end: F,
|
|
1647
1650
|
key: x,
|
|
1648
|
-
lane:
|
|
1649
|
-
},
|
|
1651
|
+
lane: j
|
|
1652
|
+
}, f[j] = p;
|
|
1650
1653
|
}
|
|
1651
|
-
return this.measurementsCache =
|
|
1654
|
+
return this.measurementsCache = u, u;
|
|
1652
1655
|
},
|
|
1653
1656
|
{
|
|
1654
1657
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
@@ -1661,7 +1664,7 @@ class Pn {
|
|
|
1661
1664
|
this.getScrollOffset(),
|
|
1662
1665
|
this.options.lanes
|
|
1663
1666
|
],
|
|
1664
|
-
(t, n, r, i) => this.range = t.length > 0 && n > 0 ?
|
|
1667
|
+
(t, n, r, i) => this.range = t.length > 0 && n > 0 ? Pn({
|
|
1665
1668
|
measurements: t,
|
|
1666
1669
|
outerSize: n,
|
|
1667
1670
|
scrollOffset: r,
|
|
@@ -1698,21 +1701,42 @@ class Pn {
|
|
|
1698
1701
|
return r ? parseInt(r, 10) : (console.warn(
|
|
1699
1702
|
`Missing attribute name '${n}={index}' on measured element.`
|
|
1700
1703
|
), -1);
|
|
1704
|
+
}, this.shouldMeasureDuringScroll = (t) => {
|
|
1705
|
+
var n;
|
|
1706
|
+
if (!this.scrollState || this.scrollState.behavior !== "smooth")
|
|
1707
|
+
return !0;
|
|
1708
|
+
const r = this.scrollState.index ?? ((n = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : n.index);
|
|
1709
|
+
if (r !== void 0 && this.range) {
|
|
1710
|
+
const i = Math.max(
|
|
1711
|
+
this.options.overscan,
|
|
1712
|
+
Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
|
|
1713
|
+
), a = Math.max(0, r - i), o = Math.min(
|
|
1714
|
+
this.options.count - 1,
|
|
1715
|
+
r + i
|
|
1716
|
+
);
|
|
1717
|
+
return t >= a && t <= o;
|
|
1718
|
+
}
|
|
1719
|
+
return !0;
|
|
1701
1720
|
}, this._measureElement = (t, n) => {
|
|
1721
|
+
if (!t.isConnected) {
|
|
1722
|
+
this.observer.unobserve(t);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1702
1725
|
const r = this.indexFromElement(t), i = this.measurementsCache[r];
|
|
1703
1726
|
if (!i)
|
|
1704
1727
|
return;
|
|
1705
|
-
const a = i.key,
|
|
1706
|
-
|
|
1728
|
+
const a = i.key, o = this.elementsCache.get(a);
|
|
1729
|
+
o !== t && (o && this.observer.unobserve(o), this.observer.observe(t), this.elementsCache.set(a, t)), this.shouldMeasureDuringScroll(r) && this.resizeItem(r, this.options.measureElement(t, n, this));
|
|
1707
1730
|
}, this.resizeItem = (t, n) => {
|
|
1708
|
-
|
|
1709
|
-
|
|
1731
|
+
var r;
|
|
1732
|
+
const i = this.measurementsCache[t];
|
|
1733
|
+
if (!i)
|
|
1710
1734
|
return;
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
adjustments: this.scrollAdjustments +=
|
|
1735
|
+
const a = this.itemSizeCache.get(i.key) ?? i.size, o = n - a;
|
|
1736
|
+
o !== 0 && (((r = this.scrollState) == null ? void 0 : r.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(i, o, this) : i.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
|
|
1737
|
+
adjustments: this.scrollAdjustments += o,
|
|
1714
1738
|
behavior: void 0
|
|
1715
|
-
})), this.pendingMeasuredCacheIndexes.push(
|
|
1739
|
+
})), this.pendingMeasuredCacheIndexes.push(i.index), this.itemSizeCache = new Map(this.itemSizeCache.set(i.key, n)), this.notify(!1));
|
|
1716
1740
|
}, this.measureElement = (t) => {
|
|
1717
1741
|
if (!t) {
|
|
1718
1742
|
this.elementsCache.forEach((n, r) => {
|
|
@@ -1726,8 +1750,8 @@ class Pn {
|
|
|
1726
1750
|
(t, n) => {
|
|
1727
1751
|
const r = [];
|
|
1728
1752
|
for (let i = 0, a = t.length; i < a; i++) {
|
|
1729
|
-
const
|
|
1730
|
-
r.push(
|
|
1753
|
+
const o = t[i], m = n[o];
|
|
1754
|
+
r.push(m);
|
|
1731
1755
|
}
|
|
1732
1756
|
return r;
|
|
1733
1757
|
},
|
|
@@ -1758,74 +1782,63 @@ class Pn {
|
|
|
1758
1782
|
if (!this.scrollElement) return 0;
|
|
1759
1783
|
const i = this.getSize(), a = this.getScrollOffset();
|
|
1760
1784
|
n === "auto" && (n = t >= a + i ? "end" : "start"), n === "center" ? t += (r - i) / 2 : n === "end" && (t -= i);
|
|
1761
|
-
const
|
|
1762
|
-
return Math.max(Math.min(
|
|
1785
|
+
const o = this.getMaxScrollOffset();
|
|
1786
|
+
return Math.max(Math.min(o, t), 0);
|
|
1763
1787
|
}, this.getOffsetForIndex = (t, n = "auto") => {
|
|
1764
1788
|
t = Math.max(0, Math.min(t, this.options.count - 1));
|
|
1765
|
-
const r = this.measurementsCache[t];
|
|
1766
|
-
if (!
|
|
1767
|
-
return;
|
|
1768
|
-
const i = this.getSize(), a = this.getScrollOffset();
|
|
1789
|
+
const r = this.getSize(), i = this.getScrollOffset(), a = this.measurementsCache[t];
|
|
1790
|
+
if (!a) return;
|
|
1769
1791
|
if (n === "auto")
|
|
1770
|
-
if (
|
|
1792
|
+
if (a.end >= i + r - this.options.scrollPaddingEnd)
|
|
1771
1793
|
n = "end";
|
|
1772
|
-
else if (
|
|
1794
|
+
else if (a.start <= i + this.options.scrollPaddingStart)
|
|
1773
1795
|
n = "start";
|
|
1774
1796
|
else
|
|
1775
|
-
return [
|
|
1797
|
+
return [i, n];
|
|
1776
1798
|
if (n === "end" && t === this.options.count - 1)
|
|
1777
1799
|
return [this.getMaxScrollOffset(), n];
|
|
1778
|
-
const
|
|
1800
|
+
const o = n === "end" ? a.end + this.options.scrollPaddingEnd : a.start - this.options.scrollPaddingStart;
|
|
1779
1801
|
return [
|
|
1780
|
-
this.getOffsetForAlignment(
|
|
1802
|
+
this.getOffsetForAlignment(o, n, a.size),
|
|
1781
1803
|
n
|
|
1782
1804
|
];
|
|
1783
|
-
}, this.
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
behavior: r
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
};
|
|
1821
|
-
l(n);
|
|
1822
|
-
}, this.scrollBy = (t, { behavior: n } = {}) => {
|
|
1823
|
-
n === "smooth" && this.isDynamicMode() && console.warn(
|
|
1824
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
1825
|
-
), this._scrollToOffset(this.getScrollOffset() + t, {
|
|
1826
|
-
adjustments: void 0,
|
|
1827
|
-
behavior: n
|
|
1828
|
-
});
|
|
1805
|
+
}, this.scrollToOffset = (t, { align: n = "start", behavior: r = "auto" } = {}) => {
|
|
1806
|
+
const i = this.getOffsetForAlignment(t, n), a = this.now();
|
|
1807
|
+
this.scrollState = {
|
|
1808
|
+
index: null,
|
|
1809
|
+
align: n,
|
|
1810
|
+
behavior: r,
|
|
1811
|
+
startedAt: a,
|
|
1812
|
+
lastTargetOffset: i,
|
|
1813
|
+
stableFrames: 0
|
|
1814
|
+
}, this._scrollToOffset(i, { adjustments: void 0, behavior: r }), this.scheduleScrollReconcile();
|
|
1815
|
+
}, this.scrollToIndex = (t, {
|
|
1816
|
+
align: n = "auto",
|
|
1817
|
+
behavior: r = "auto"
|
|
1818
|
+
} = {}) => {
|
|
1819
|
+
t = Math.max(0, Math.min(t, this.options.count - 1));
|
|
1820
|
+
const i = this.getOffsetForIndex(t, n);
|
|
1821
|
+
if (!i)
|
|
1822
|
+
return;
|
|
1823
|
+
const [a, o] = i, m = this.now();
|
|
1824
|
+
this.scrollState = {
|
|
1825
|
+
index: t,
|
|
1826
|
+
align: o,
|
|
1827
|
+
behavior: r,
|
|
1828
|
+
startedAt: m,
|
|
1829
|
+
lastTargetOffset: a,
|
|
1830
|
+
stableFrames: 0
|
|
1831
|
+
}, this._scrollToOffset(a, { adjustments: void 0, behavior: r }), this.scheduleScrollReconcile();
|
|
1832
|
+
}, this.scrollBy = (t, { behavior: n = "auto" } = {}) => {
|
|
1833
|
+
const r = this.getScrollOffset() + t, i = this.now();
|
|
1834
|
+
this.scrollState = {
|
|
1835
|
+
index: null,
|
|
1836
|
+
align: "start",
|
|
1837
|
+
behavior: n,
|
|
1838
|
+
startedAt: i,
|
|
1839
|
+
lastTargetOffset: r,
|
|
1840
|
+
stableFrames: 0
|
|
1841
|
+
}, this._scrollToOffset(r, { adjustments: void 0, behavior: n }), this.scheduleScrollReconcile();
|
|
1829
1842
|
}, this.getTotalSize = () => {
|
|
1830
1843
|
var t;
|
|
1831
1844
|
const n = this.getMeasurements();
|
|
@@ -1837,11 +1850,11 @@ class Pn {
|
|
|
1837
1850
|
else {
|
|
1838
1851
|
const i = Array(this.options.lanes).fill(null);
|
|
1839
1852
|
let a = n.length - 1;
|
|
1840
|
-
for (; a >= 0 && i.some((
|
|
1841
|
-
const
|
|
1842
|
-
i[
|
|
1853
|
+
for (; a >= 0 && i.some((o) => o === null); ) {
|
|
1854
|
+
const o = n[a];
|
|
1855
|
+
i[o.lane] === null && (i[o.lane] = o.end), a--;
|
|
1843
1856
|
}
|
|
1844
|
-
r = Math.max(...i.filter((
|
|
1857
|
+
r = Math.max(...i.filter((o) => o !== null));
|
|
1845
1858
|
}
|
|
1846
1859
|
return Math.max(
|
|
1847
1860
|
r - this.options.scrollMargin + this.options.paddingEnd,
|
|
@@ -1854,28 +1867,56 @@ class Pn {
|
|
|
1854
1867
|
this.options.scrollToFn(t, { behavior: r, adjustments: n }, this);
|
|
1855
1868
|
}, this.measure = () => {
|
|
1856
1869
|
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
1857
|
-
}, this.setOptions(
|
|
1870
|
+
}, this.setOptions(l);
|
|
1871
|
+
}
|
|
1872
|
+
scheduleScrollReconcile() {
|
|
1873
|
+
if (!this.targetWindow) {
|
|
1874
|
+
this.scrollState = null;
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
this.rafId == null && (this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
1878
|
+
this.rafId = null, this.reconcileScroll();
|
|
1879
|
+
}));
|
|
1880
|
+
}
|
|
1881
|
+
reconcileScroll() {
|
|
1882
|
+
if (!this.scrollState || !this.scrollElement) return;
|
|
1883
|
+
if (this.now() - this.scrollState.startedAt > 5e3) {
|
|
1884
|
+
this.scrollState = null;
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1887
|
+
const n = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0, r = n ? n[0] : this.scrollState.lastTargetOffset, i = 1, a = r !== this.scrollState.lastTargetOffset;
|
|
1888
|
+
if (!a && On(r, this.getScrollOffset())) {
|
|
1889
|
+
if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= i) {
|
|
1890
|
+
this.scrollState = null;
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
} else
|
|
1894
|
+
this.scrollState.stableFrames = 0, a && (this.scrollState.lastTargetOffset = r, this.scrollState.behavior = "auto", this._scrollToOffset(r, {
|
|
1895
|
+
adjustments: void 0,
|
|
1896
|
+
behavior: "auto"
|
|
1897
|
+
}));
|
|
1898
|
+
this.scheduleScrollReconcile();
|
|
1858
1899
|
}
|
|
1859
1900
|
}
|
|
1860
|
-
const qt = (e,
|
|
1861
|
-
for (; e <=
|
|
1862
|
-
const r = (e +
|
|
1901
|
+
const qt = (e, l, t, n) => {
|
|
1902
|
+
for (; e <= l; ) {
|
|
1903
|
+
const r = (e + l) / 2 | 0, i = t(r);
|
|
1863
1904
|
if (i < n)
|
|
1864
1905
|
e = r + 1;
|
|
1865
1906
|
else if (i > n)
|
|
1866
|
-
|
|
1907
|
+
l = r - 1;
|
|
1867
1908
|
else
|
|
1868
1909
|
return r;
|
|
1869
1910
|
}
|
|
1870
1911
|
return e > 0 ? e - 1 : 0;
|
|
1871
1912
|
};
|
|
1872
|
-
function
|
|
1913
|
+
function Pn({
|
|
1873
1914
|
measurements: e,
|
|
1874
|
-
outerSize:
|
|
1915
|
+
outerSize: l,
|
|
1875
1916
|
scrollOffset: t,
|
|
1876
1917
|
lanes: n
|
|
1877
1918
|
}) {
|
|
1878
|
-
const r = e.length - 1, i = (
|
|
1919
|
+
const r = e.length - 1, i = (m) => e[m].start;
|
|
1879
1920
|
if (e.length <= n)
|
|
1880
1921
|
return {
|
|
1881
1922
|
startIndex: 0,
|
|
@@ -1886,75 +1927,75 @@ function Ln({
|
|
|
1886
1927
|
r,
|
|
1887
1928
|
i,
|
|
1888
1929
|
t
|
|
1889
|
-
),
|
|
1930
|
+
), o = a;
|
|
1890
1931
|
if (n === 1)
|
|
1891
|
-
for (;
|
|
1892
|
-
|
|
1932
|
+
for (; o < r && e[o].end < t + l; )
|
|
1933
|
+
o++;
|
|
1893
1934
|
else if (n > 1) {
|
|
1894
|
-
const
|
|
1895
|
-
for (;
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1935
|
+
const m = Array(n).fill(0);
|
|
1936
|
+
for (; o < r && m.some((u) => u < t + l); ) {
|
|
1937
|
+
const u = e[o];
|
|
1938
|
+
m[u.lane] = u.end, o++;
|
|
1898
1939
|
}
|
|
1899
|
-
const
|
|
1900
|
-
for (; a >= 0 &&
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1940
|
+
const h = Array(n).fill(t + l);
|
|
1941
|
+
for (; a >= 0 && h.some((u) => u >= t); ) {
|
|
1942
|
+
const u = e[a];
|
|
1943
|
+
h[u.lane] = u.start, a--;
|
|
1903
1944
|
}
|
|
1904
|
-
a = Math.max(0, a - a % n),
|
|
1945
|
+
a = Math.max(0, a - a % n), o = Math.min(r, o + (n - 1 - o % n));
|
|
1905
1946
|
}
|
|
1906
|
-
return { startIndex: a, endIndex:
|
|
1947
|
+
return { startIndex: a, endIndex: o };
|
|
1907
1948
|
}
|
|
1908
|
-
const
|
|
1949
|
+
const It = typeof document < "u" ? He.useLayoutEffect : He.useEffect;
|
|
1909
1950
|
function $n({
|
|
1910
1951
|
useFlushSync: e = !0,
|
|
1911
|
-
...
|
|
1952
|
+
...l
|
|
1912
1953
|
}) {
|
|
1913
1954
|
const t = He.useReducer(() => ({}), {})[1], n = {
|
|
1914
|
-
...
|
|
1955
|
+
...l,
|
|
1915
1956
|
onChange: (i, a) => {
|
|
1916
|
-
var
|
|
1917
|
-
e && a ? on(t) : t(), (
|
|
1957
|
+
var o;
|
|
1958
|
+
e && a ? on(t) : t(), (o = l.onChange) == null || o.call(l, i, a);
|
|
1918
1959
|
}
|
|
1919
1960
|
}, [r] = He.useState(
|
|
1920
|
-
() => new
|
|
1961
|
+
() => new Ln(n)
|
|
1921
1962
|
);
|
|
1922
|
-
return r.setOptions(n),
|
|
1963
|
+
return r.setOptions(n), It(() => r._didMount(), []), It(() => r._willUpdate()), r;
|
|
1923
1964
|
}
|
|
1924
1965
|
function Vn(e) {
|
|
1925
1966
|
return $n({
|
|
1926
1967
|
observeElementRect: Dn,
|
|
1927
|
-
observeElementOffset:
|
|
1928
|
-
scrollToFn:
|
|
1968
|
+
observeElementOffset: In,
|
|
1969
|
+
scrollToFn: zn,
|
|
1929
1970
|
...e
|
|
1930
1971
|
});
|
|
1931
1972
|
}
|
|
1932
1973
|
const dr = ({
|
|
1933
1974
|
data: e,
|
|
1934
|
-
columns:
|
|
1975
|
+
columns: l,
|
|
1935
1976
|
rowHeight: t = 40,
|
|
1936
1977
|
height: n = 600,
|
|
1937
1978
|
className: r = "",
|
|
1938
1979
|
headerClassName: i = "",
|
|
1939
1980
|
rowClassName: a,
|
|
1940
|
-
onRowClick:
|
|
1941
|
-
overscan:
|
|
1981
|
+
onRowClick: o,
|
|
1982
|
+
overscan: m = 5
|
|
1942
1983
|
}) => {
|
|
1943
|
-
const
|
|
1984
|
+
const h = xe(null), u = Vn({
|
|
1944
1985
|
count: e.length,
|
|
1945
|
-
getScrollElement: () =>
|
|
1986
|
+
getScrollElement: () => h.current,
|
|
1946
1987
|
estimateSize: () => t,
|
|
1947
|
-
overscan:
|
|
1948
|
-
}),
|
|
1988
|
+
overscan: m
|
|
1989
|
+
}), f = u.getVirtualItems();
|
|
1949
1990
|
return /* @__PURE__ */ s.jsxs("div", { className: r, children: [
|
|
1950
1991
|
/* @__PURE__ */ s.jsx(
|
|
1951
1992
|
"div",
|
|
1952
1993
|
{
|
|
1953
1994
|
className: `grid border-b sticky top-0 bg-muted/30 z-10 ${i}`,
|
|
1954
1995
|
style: {
|
|
1955
|
-
gridTemplateColumns:
|
|
1996
|
+
gridTemplateColumns: l.map((p) => p.width || "1fr").join(" ")
|
|
1956
1997
|
},
|
|
1957
|
-
children:
|
|
1998
|
+
children: l.map((p, x) => /* @__PURE__ */ s.jsx(
|
|
1958
1999
|
"div",
|
|
1959
2000
|
{
|
|
1960
2001
|
className: `px-4 py-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70 ${p.align === "center" ? "text-center" : p.align === "right" ? "text-right" : "text-left"}`,
|
|
@@ -1967,7 +2008,7 @@ const dr = ({
|
|
|
1967
2008
|
/* @__PURE__ */ s.jsx(
|
|
1968
2009
|
"div",
|
|
1969
2010
|
{
|
|
1970
|
-
ref:
|
|
2011
|
+
ref: h,
|
|
1971
2012
|
className: "overflow-auto",
|
|
1972
2013
|
style: {
|
|
1973
2014
|
height: typeof n == "number" ? `${n}px` : n,
|
|
@@ -1977,16 +2018,16 @@ const dr = ({
|
|
|
1977
2018
|
"div",
|
|
1978
2019
|
{
|
|
1979
2020
|
style: {
|
|
1980
|
-
height: `${
|
|
2021
|
+
height: `${u.getTotalSize()}px`,
|
|
1981
2022
|
width: "100%",
|
|
1982
2023
|
position: "relative"
|
|
1983
2024
|
},
|
|
1984
|
-
children:
|
|
1985
|
-
const x = e[p.index],
|
|
2025
|
+
children: f.map((p) => {
|
|
2026
|
+
const x = e[p.index], y = typeof a == "function" ? a(x, p.index) : a || "";
|
|
1986
2027
|
return /* @__PURE__ */ s.jsx(
|
|
1987
2028
|
"div",
|
|
1988
2029
|
{
|
|
1989
|
-
className: `grid border-b hover:bg-muted/50 cursor-pointer ${
|
|
2030
|
+
className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
|
|
1990
2031
|
style: {
|
|
1991
2032
|
position: "absolute",
|
|
1992
2033
|
top: 0,
|
|
@@ -1994,15 +2035,15 @@ const dr = ({
|
|
|
1994
2035
|
width: "100%",
|
|
1995
2036
|
height: `${p.size}px`,
|
|
1996
2037
|
transform: `translateY(${p.start}px)`,
|
|
1997
|
-
gridTemplateColumns:
|
|
2038
|
+
gridTemplateColumns: l.map((j) => j.width || "1fr").join(" ")
|
|
1998
2039
|
},
|
|
1999
|
-
onClick: () =>
|
|
2000
|
-
children:
|
|
2001
|
-
const T = x[
|
|
2040
|
+
onClick: () => o?.(x, p.index),
|
|
2041
|
+
children: l.map((j, k) => {
|
|
2042
|
+
const T = x[j.accessorKey], D = j.cell ? j.cell(T, x) : T;
|
|
2002
2043
|
return /* @__PURE__ */ s.jsx(
|
|
2003
2044
|
"div",
|
|
2004
2045
|
{
|
|
2005
|
-
className: `px-4 py-2 text-sm flex items-center ${
|
|
2046
|
+
className: `px-4 py-2 text-sm flex items-center ${j.align === "center" ? "text-center justify-center" : j.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
|
|
2006
2047
|
children: D
|
|
2007
2048
|
},
|
|
2008
2049
|
k
|
|
@@ -2018,7 +2059,7 @@ const dr = ({
|
|
|
2018
2059
|
),
|
|
2019
2060
|
/* @__PURE__ */ s.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
|
|
2020
2061
|
"Showing ",
|
|
2021
|
-
|
|
2062
|
+
f.length,
|
|
2022
2063
|
" of ",
|
|
2023
2064
|
e.length,
|
|
2024
2065
|
" rows (virtual scrolling enabled)"
|
|
@@ -2026,19 +2067,19 @@ const dr = ({
|
|
|
2026
2067
|
] });
|
|
2027
2068
|
}, Kn = 10;
|
|
2028
2069
|
function Wn(e) {
|
|
2029
|
-
const
|
|
2070
|
+
const l = [];
|
|
2030
2071
|
let t = [], n = "", r = !1;
|
|
2031
2072
|
for (let i = 0; i < e.length; i++) {
|
|
2032
|
-
const a = e[i],
|
|
2033
|
-
r ? a === '"' &&
|
|
2034
|
-
` || a === "\r" &&
|
|
2035
|
-
` ? (t.push(n.trim()), t.some((
|
|
2073
|
+
const a = e[i], o = e[i + 1];
|
|
2074
|
+
r ? a === '"' && o === '"' ? (n += '"', i++) : a === '"' ? r = !1 : n += a : a === '"' ? r = !0 : a === "," ? (t.push(n.trim()), n = "") : a === `
|
|
2075
|
+
` || a === "\r" && o === `
|
|
2076
|
+
` ? (t.push(n.trim()), t.some((m) => m !== "") && l.push(t), t = [], n = "", a === "\r" && i++) : n += a;
|
|
2036
2077
|
}
|
|
2037
|
-
return t.push(n.trim()), t.some((i) => i !== "") &&
|
|
2078
|
+
return t.push(n.trim()), t.some((i) => i !== "") && l.push(t), l;
|
|
2038
2079
|
}
|
|
2039
|
-
function Bt(e,
|
|
2080
|
+
function Bt(e, l) {
|
|
2040
2081
|
if (!e) return !0;
|
|
2041
|
-
switch (
|
|
2082
|
+
switch (l) {
|
|
2042
2083
|
case "number":
|
|
2043
2084
|
case "currency":
|
|
2044
2085
|
case "percent":
|
|
@@ -2052,19 +2093,19 @@ function Bt(e, o) {
|
|
|
2052
2093
|
return !0;
|
|
2053
2094
|
}
|
|
2054
2095
|
}
|
|
2055
|
-
function qn(e,
|
|
2096
|
+
function qn(e, l) {
|
|
2056
2097
|
const t = {};
|
|
2057
2098
|
return e.forEach((n, r) => {
|
|
2058
|
-
const i = n.toLowerCase().replace(/[_\s-]/g, ""), a =
|
|
2059
|
-
const
|
|
2060
|
-
return
|
|
2099
|
+
const i = n.toLowerCase().replace(/[_\s-]/g, ""), a = l.find((o) => {
|
|
2100
|
+
const m = o.name.toLowerCase().replace(/[_\s-]/g, ""), h = o.label.toLowerCase().replace(/[_\s-]/g, "");
|
|
2101
|
+
return m === i || h === i;
|
|
2061
2102
|
});
|
|
2062
2103
|
a && (t[r] = a.name);
|
|
2063
2104
|
}), t;
|
|
2064
2105
|
}
|
|
2065
|
-
function Bn(e,
|
|
2106
|
+
function Bn(e, l, t) {
|
|
2066
2107
|
const n = [], r = {};
|
|
2067
|
-
for (const i of
|
|
2108
|
+
for (const i of l) {
|
|
2068
2109
|
const a = e[i.csvIdx] ?? "";
|
|
2069
2110
|
if (i.field.required && !a) {
|
|
2070
2111
|
n.push({ row: t, field: i.field.name, message: "Required field is empty" });
|
|
@@ -2079,20 +2120,20 @@ function Bn(e, o, t) {
|
|
|
2079
2120
|
return { record: r, errors: n };
|
|
2080
2121
|
}
|
|
2081
2122
|
const Un = ({ onFileLoaded: e }) => {
|
|
2082
|
-
const [
|
|
2123
|
+
const [l, t] = I(!1), [n, r] = I(null), i = M((a) => {
|
|
2083
2124
|
if (r(null), !a.name.endsWith(".csv")) {
|
|
2084
2125
|
r("Only CSV files are supported.");
|
|
2085
2126
|
return;
|
|
2086
2127
|
}
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
const
|
|
2090
|
-
if (
|
|
2128
|
+
const o = new FileReader();
|
|
2129
|
+
o.onload = (m) => {
|
|
2130
|
+
const h = Wn(m.target?.result);
|
|
2131
|
+
if (h.length < 2) {
|
|
2091
2132
|
r("File must contain a header row and at least one data row.");
|
|
2092
2133
|
return;
|
|
2093
2134
|
}
|
|
2094
|
-
e(
|
|
2095
|
-
},
|
|
2135
|
+
e(h[0], h.slice(1));
|
|
2136
|
+
}, o.readAsText(a);
|
|
2096
2137
|
}, [e]);
|
|
2097
2138
|
return /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col items-center gap-4 py-6", children: [
|
|
2098
2139
|
/* @__PURE__ */ s.jsxs(
|
|
@@ -2100,7 +2141,7 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2100
2141
|
{
|
|
2101
2142
|
className: ue(
|
|
2102
2143
|
"flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors",
|
|
2103
|
-
|
|
2144
|
+
l ? "border-primary bg-primary/5" : "border-muted-foreground/25"
|
|
2104
2145
|
),
|
|
2105
2146
|
onDragOver: (a) => {
|
|
2106
2147
|
a.preventDefault(), t(!0);
|
|
@@ -2108,16 +2149,16 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2108
2149
|
onDragLeave: () => t(!1),
|
|
2109
2150
|
onDrop: (a) => {
|
|
2110
2151
|
a.preventDefault(), t(!1);
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2152
|
+
const o = a.dataTransfer.files[0];
|
|
2153
|
+
o && i(o);
|
|
2113
2154
|
},
|
|
2114
2155
|
children: [
|
|
2115
2156
|
/* @__PURE__ */ s.jsx(sn, { className: "h-10 w-10 text-muted-foreground" }),
|
|
2116
2157
|
/* @__PURE__ */ s.jsx("p", { className: "text-sm text-muted-foreground", children: "Drag & drop a CSV file here, or click to browse" }),
|
|
2117
2158
|
/* @__PURE__ */ s.jsxs("label", { children: [
|
|
2118
2159
|
/* @__PURE__ */ s.jsx("input", { type: "file", accept: ".csv", className: "hidden", onChange: (a) => {
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2160
|
+
const o = a.target.files?.[0];
|
|
2161
|
+
o && i(o);
|
|
2121
2162
|
} }),
|
|
2122
2163
|
/* @__PURE__ */ s.jsx(le, { variant: "outline", size: "sm", asChild: !0, children: /* @__PURE__ */ s.jsx("span", { children: "Browse Files" }) })
|
|
2123
2164
|
] })
|
|
@@ -2130,123 +2171,123 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2130
2171
|
n
|
|
2131
2172
|
] })
|
|
2132
2173
|
] });
|
|
2133
|
-
}, Gn = ({ headers: e, fields:
|
|
2134
|
-
const r =
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2174
|
+
}, Gn = ({ headers: e, fields: l, mapping: t, onMappingChange: n }) => {
|
|
2175
|
+
const r = ye(() => new Set(Object.values(t)), [t]), i = M((a, o) => {
|
|
2176
|
+
const m = { ...t };
|
|
2177
|
+
o === "__skip__" ? delete m[a] : m[a] = o, n(m);
|
|
2137
2178
|
}, [t, n]);
|
|
2138
|
-
return /* @__PURE__ */ s.jsx("div", { className: "max-h-[360px] overflow-auto", children: /* @__PURE__ */ s.jsxs(
|
|
2179
|
+
return /* @__PURE__ */ s.jsx("div", { className: "max-h-[360px] overflow-auto", children: /* @__PURE__ */ s.jsxs(Pt, { children: [
|
|
2139
2180
|
/* @__PURE__ */ s.jsx($t, { children: /* @__PURE__ */ s.jsxs(Ye, { children: [
|
|
2140
|
-
/* @__PURE__ */ s.jsx(
|
|
2141
|
-
/* @__PURE__ */ s.jsx(
|
|
2142
|
-
/* @__PURE__ */ s.jsx(
|
|
2181
|
+
/* @__PURE__ */ s.jsx(Le, { children: "CSV Column" }),
|
|
2182
|
+
/* @__PURE__ */ s.jsx(Le, { children: "Maps To" }),
|
|
2183
|
+
/* @__PURE__ */ s.jsx(Le, { className: "w-24 text-center", children: "Status" })
|
|
2143
2184
|
] }) }),
|
|
2144
|
-
/* @__PURE__ */ s.jsx(Vt, { children: e.map((a,
|
|
2145
|
-
/* @__PURE__ */ s.jsx(
|
|
2146
|
-
/* @__PURE__ */ s.jsx(
|
|
2147
|
-
/* @__PURE__ */ s.jsx(
|
|
2148
|
-
/* @__PURE__ */ s.jsxs(
|
|
2185
|
+
/* @__PURE__ */ s.jsx(Vt, { children: e.map((a, o) => /* @__PURE__ */ s.jsxs(Ye, { children: [
|
|
2186
|
+
/* @__PURE__ */ s.jsx(Pe, { className: "font-medium", children: a }),
|
|
2187
|
+
/* @__PURE__ */ s.jsx(Pe, { children: /* @__PURE__ */ s.jsxs(Fs, { value: t[o] ?? "__skip__", onValueChange: (m) => i(o, m), children: [
|
|
2188
|
+
/* @__PURE__ */ s.jsx(zs, { className: "h-8 w-56", children: /* @__PURE__ */ s.jsx(Ls, { placeholder: "Skip column" }) }),
|
|
2189
|
+
/* @__PURE__ */ s.jsxs(Ps, { children: [
|
|
2149
2190
|
/* @__PURE__ */ s.jsx(wt, { value: "__skip__", children: "— Skip —" }),
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
] },
|
|
2191
|
+
l.map((m) => /* @__PURE__ */ s.jsxs(wt, { value: m.name, disabled: r.has(m.name) && t[o] !== m.name, children: [
|
|
2192
|
+
m.label,
|
|
2193
|
+
m.required ? " *" : ""
|
|
2194
|
+
] }, m.name))
|
|
2154
2195
|
] })
|
|
2155
2196
|
] }) }),
|
|
2156
|
-
/* @__PURE__ */ s.jsx(
|
|
2157
|
-
] },
|
|
2197
|
+
/* @__PURE__ */ s.jsx(Pe, { className: "text-center", children: t[o] ? /* @__PURE__ */ s.jsx(Te, { variant: "default", className: "text-xs", children: "Mapped" }) : /* @__PURE__ */ s.jsx(Te, { variant: "secondary", className: "text-xs", children: "Skipped" }) })
|
|
2198
|
+
] }, o)) })
|
|
2158
2199
|
] }) });
|
|
2159
|
-
}, Hn = ({ headers: e, rows:
|
|
2160
|
-
const r =
|
|
2161
|
-
csvIdx: Number(
|
|
2162
|
-
header: e[Number(
|
|
2163
|
-
field: n.find((
|
|
2164
|
-
})), [t, e, n]), i =
|
|
2165
|
-
const
|
|
2166
|
-
for (const
|
|
2167
|
-
const p =
|
|
2168
|
-
|
|
2200
|
+
}, Hn = ({ headers: e, rows: l, mapping: t, fields: n }) => {
|
|
2201
|
+
const r = ye(() => Object.entries(t).map(([m, h]) => ({
|
|
2202
|
+
csvIdx: Number(m),
|
|
2203
|
+
header: e[Number(m)],
|
|
2204
|
+
field: n.find((u) => u.name === h)
|
|
2205
|
+
})), [t, e, n]), i = l.slice(0, Kn), a = ye(() => i.map((m, h) => {
|
|
2206
|
+
const u = {};
|
|
2207
|
+
for (const f of r) {
|
|
2208
|
+
const p = m[f.csvIdx] ?? "";
|
|
2209
|
+
f.field.required && !p ? u[f.csvIdx] = "Required" : p && !Bt(p, f.field.type) && (u[f.csvIdx] = `Invalid ${f.field.type}`);
|
|
2169
2210
|
}
|
|
2170
|
-
return
|
|
2171
|
-
}), [i, r]),
|
|
2211
|
+
return u;
|
|
2212
|
+
}), [i, r]), o = a.filter((m) => Object.keys(m).length > 0).length;
|
|
2172
2213
|
return /* @__PURE__ */ s.jsxs("div", { className: "max-h-[360px] overflow-auto", children: [
|
|
2173
|
-
|
|
2214
|
+
o > 0 && /* @__PURE__ */ s.jsxs("p", { className: "mb-2 flex items-center gap-1 text-xs text-destructive", children: [
|
|
2174
2215
|
/* @__PURE__ */ s.jsx(Kt, { className: "h-3.5 w-3.5" }),
|
|
2175
2216
|
" ",
|
|
2176
|
-
|
|
2217
|
+
o,
|
|
2177
2218
|
" row(s) with errors in preview"
|
|
2178
2219
|
] }),
|
|
2179
|
-
/* @__PURE__ */ s.jsxs(
|
|
2220
|
+
/* @__PURE__ */ s.jsxs(Pt, { children: [
|
|
2180
2221
|
/* @__PURE__ */ s.jsx($t, { children: /* @__PURE__ */ s.jsxs(Ye, { children: [
|
|
2181
|
-
/* @__PURE__ */ s.jsx(
|
|
2182
|
-
r.map((
|
|
2222
|
+
/* @__PURE__ */ s.jsx(Le, { className: "w-12", children: "#" }),
|
|
2223
|
+
r.map((m) => /* @__PURE__ */ s.jsx(Le, { children: m.field.label }, m.csvIdx))
|
|
2183
2224
|
] }) }),
|
|
2184
|
-
/* @__PURE__ */ s.jsx(Vt, { children: i.map((
|
|
2185
|
-
const
|
|
2186
|
-
return /* @__PURE__ */ s.jsxs(Ye, { className: ue(
|
|
2187
|
-
/* @__PURE__ */ s.jsx(
|
|
2225
|
+
/* @__PURE__ */ s.jsx(Vt, { children: i.map((m, h) => {
|
|
2226
|
+
const u = a[h], f = Object.keys(u).length > 0;
|
|
2227
|
+
return /* @__PURE__ */ s.jsxs(Ye, { className: ue(f && "bg-destructive/5"), children: [
|
|
2228
|
+
/* @__PURE__ */ s.jsx(Pe, { className: "text-xs text-muted-foreground", children: h + 1 }),
|
|
2188
2229
|
r.map((p) => {
|
|
2189
|
-
const x =
|
|
2190
|
-
return /* @__PURE__ */ s.jsx(
|
|
2230
|
+
const x = m[p.csvIdx] ?? "", y = u[p.csvIdx];
|
|
2231
|
+
return /* @__PURE__ */ s.jsx(Pe, { className: ue(y && "text-destructive"), title: y, children: x || /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50", children: "—" }) }, p.csvIdx);
|
|
2191
2232
|
})
|
|
2192
|
-
] },
|
|
2233
|
+
] }, h);
|
|
2193
2234
|
}) })
|
|
2194
2235
|
] }),
|
|
2195
2236
|
/* @__PURE__ */ s.jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: [
|
|
2196
2237
|
"Showing ",
|
|
2197
2238
|
i.length,
|
|
2198
2239
|
" of ",
|
|
2199
|
-
|
|
2240
|
+
l.length,
|
|
2200
2241
|
" rows"
|
|
2201
2242
|
] })
|
|
2202
2243
|
] });
|
|
2203
2244
|
}, Yn = ({
|
|
2204
2245
|
objectName: e,
|
|
2205
|
-
objectLabel:
|
|
2246
|
+
objectLabel: l,
|
|
2206
2247
|
fields: t,
|
|
2207
2248
|
dataSource: n,
|
|
2208
2249
|
onComplete: r,
|
|
2209
2250
|
onCancel: i,
|
|
2210
2251
|
open: a,
|
|
2211
|
-
onOpenChange:
|
|
2212
|
-
onErrorMode:
|
|
2252
|
+
onOpenChange: o,
|
|
2253
|
+
onErrorMode: m = "skip"
|
|
2213
2254
|
}) => {
|
|
2214
|
-
const [
|
|
2215
|
-
const
|
|
2216
|
-
return t.filter((J) => J.required && !
|
|
2217
|
-
}, [t,
|
|
2218
|
-
p(
|
|
2255
|
+
const [h, u] = I("upload"), [f, p] = I([]), [x, y] = I([]), [j, k] = I({}), [T, D] = I(!1), [F, G] = I(0), [W, H] = I(null), re = l ?? e, Ae = ye(() => {
|
|
2256
|
+
const P = new Set(Object.values(j));
|
|
2257
|
+
return t.filter((J) => J.required && !P.has(J.name));
|
|
2258
|
+
}, [t, j]), je = M((P, J) => {
|
|
2259
|
+
p(P), y(J), k(qn(P, t)), u("mapping");
|
|
2219
2260
|
}, [t]), Re = M(async () => {
|
|
2220
2261
|
D(!0), G(0);
|
|
2221
|
-
const
|
|
2262
|
+
const P = [];
|
|
2222
2263
|
let J = 0, fe = 0;
|
|
2223
|
-
const ie = Object.entries(
|
|
2264
|
+
const ie = Object.entries(j).map(([ee, be]) => ({
|
|
2224
2265
|
csvIdx: Number(ee),
|
|
2225
2266
|
field: t.find((ge) => ge.name === be)
|
|
2226
2267
|
}));
|
|
2227
2268
|
for (let ee = 0; ee < x.length; ee++) {
|
|
2228
2269
|
const { record: be, errors: ge } = Bn(x[ee], ie, ee + 1);
|
|
2229
2270
|
if (ge.length > 0) {
|
|
2230
|
-
if (fe++,
|
|
2271
|
+
if (fe++, P.push(...ge), m === "stop") break;
|
|
2231
2272
|
} else
|
|
2232
2273
|
try {
|
|
2233
2274
|
n?.create && await n.create(e, be), J++;
|
|
2234
|
-
} catch (
|
|
2275
|
+
} catch (d) {
|
|
2235
2276
|
fe++;
|
|
2236
|
-
const _ =
|
|
2237
|
-
if (
|
|
2277
|
+
const _ = d instanceof Error ? d.message : "Failed to create record";
|
|
2278
|
+
if (P.push({ row: ee + 1, field: "", message: _ }), m === "stop") break;
|
|
2238
2279
|
}
|
|
2239
2280
|
G(Math.round((ee + 1) / x.length * 100));
|
|
2240
2281
|
}
|
|
2241
|
-
const we = { totalRows: x.length, importedRows: J, skippedRows: fe, errors:
|
|
2282
|
+
const we = { totalRows: x.length, importedRows: J, skippedRows: fe, errors: P };
|
|
2242
2283
|
H(we), D(!1), r?.(we);
|
|
2243
|
-
}, [x,
|
|
2244
|
-
|
|
2284
|
+
}, [x, j, t, n, e, r, m]), ae = M(() => {
|
|
2285
|
+
u("upload"), p([]), y([]), k({}), G(0), H(null);
|
|
2245
2286
|
}, []), pe = M(() => {
|
|
2246
|
-
ae(),
|
|
2247
|
-
}, [ae,
|
|
2248
|
-
return /* @__PURE__ */ s.jsx(_s, { open: a, onOpenChange: (
|
|
2249
|
-
|
|
2287
|
+
ae(), o?.(!1), i?.();
|
|
2288
|
+
}, [ae, o, i]);
|
|
2289
|
+
return /* @__PURE__ */ s.jsx(_s, { open: a, onOpenChange: (P) => {
|
|
2290
|
+
P ? o?.(P) : pe();
|
|
2250
2291
|
}, children: /* @__PURE__ */ s.jsxs(Os, { className: "sm:max-w-2xl", children: [
|
|
2251
2292
|
/* @__PURE__ */ s.jsxs(Ts, { children: [
|
|
2252
2293
|
/* @__PURE__ */ s.jsxs(As, { className: "flex items-center gap-2", children: [
|
|
@@ -2255,19 +2296,19 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2255
2296
|
re
|
|
2256
2297
|
] }),
|
|
2257
2298
|
/* @__PURE__ */ s.jsxs(Ms, { children: [
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2299
|
+
h === "upload" && "Upload a CSV file to get started.",
|
|
2300
|
+
h === "mapping" && "Map CSV columns to object fields.",
|
|
2301
|
+
h === "preview" && "Review data before importing."
|
|
2261
2302
|
] })
|
|
2262
2303
|
] }),
|
|
2263
|
-
/* @__PURE__ */ s.jsx("div", { className: "flex items-center justify-center gap-2 text-xs text-muted-foreground", children: ["upload", "mapping", "preview"].map((
|
|
2304
|
+
/* @__PURE__ */ s.jsx("div", { className: "flex items-center justify-center gap-2 text-xs text-muted-foreground", children: ["upload", "mapping", "preview"].map((P, J) => /* @__PURE__ */ s.jsxs(ze.Fragment, { children: [
|
|
2264
2305
|
J > 0 && /* @__PURE__ */ s.jsx(St, { className: "h-3 w-3" }),
|
|
2265
|
-
/* @__PURE__ */ s.jsxs("span", { className: ue("rounded-full px-3 py-1",
|
|
2306
|
+
/* @__PURE__ */ s.jsxs("span", { className: ue("rounded-full px-3 py-1", h === P ? "bg-primary text-primary-foreground" : "bg-muted"), children: [
|
|
2266
2307
|
J + 1,
|
|
2267
2308
|
". ",
|
|
2268
|
-
|
|
2309
|
+
P === "upload" ? "Upload" : P === "mapping" ? "Mapping" : "Preview"
|
|
2269
2310
|
] })
|
|
2270
|
-
] },
|
|
2311
|
+
] }, P)) }),
|
|
2271
2312
|
W ? /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col items-center gap-3 py-4", children: [
|
|
2272
2313
|
/* @__PURE__ */ s.jsx(en, { className: "h-10 w-10 text-green-500" }),
|
|
2273
2314
|
/* @__PURE__ */ s.jsx("p", { className: "text-lg font-semibold", children: "Import Complete" }),
|
|
@@ -2282,12 +2323,12 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2282
2323
|
] })
|
|
2283
2324
|
] }),
|
|
2284
2325
|
W.errors.length > 0 && /* @__PURE__ */ s.jsxs("div", { className: "max-h-32 w-full overflow-auto rounded border p-2 text-xs", children: [
|
|
2285
|
-
W.errors.slice(0, 10).map((
|
|
2326
|
+
W.errors.slice(0, 10).map((P, J) => /* @__PURE__ */ s.jsxs("p", { className: "text-destructive", children: [
|
|
2286
2327
|
"Row ",
|
|
2287
|
-
|
|
2288
|
-
|
|
2328
|
+
P.row,
|
|
2329
|
+
P.field ? ` (${P.field})` : "",
|
|
2289
2330
|
": ",
|
|
2290
|
-
|
|
2331
|
+
P.message
|
|
2291
2332
|
] }, J)),
|
|
2292
2333
|
W.errors.length > 10 && /* @__PURE__ */ s.jsxs("p", { className: "text-muted-foreground", children: [
|
|
2293
2334
|
"…and ",
|
|
@@ -2296,89 +2337,89 @@ const Un = ({ onFileLoaded: e }) => {
|
|
|
2296
2337
|
] })
|
|
2297
2338
|
] })
|
|
2298
2339
|
] }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2340
|
+
h === "upload" && /* @__PURE__ */ s.jsx(Un, { onFileLoaded: je }),
|
|
2341
|
+
h === "mapping" && /* @__PURE__ */ s.jsx(Gn, { headers: f, fields: t, mapping: j, onMappingChange: k }),
|
|
2342
|
+
h === "preview" && /* @__PURE__ */ s.jsx(Hn, { headers: f, rows: x, mapping: j, fields: t }),
|
|
2302
2343
|
T && /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
2303
|
-
/* @__PURE__ */ s.jsx(Ds, { value:
|
|
2344
|
+
/* @__PURE__ */ s.jsx(Ds, { value: F, className: "h-2" }),
|
|
2304
2345
|
/* @__PURE__ */ s.jsxs("p", { className: "text-center text-xs text-muted-foreground", children: [
|
|
2305
2346
|
"Importing… ",
|
|
2306
|
-
|
|
2347
|
+
F,
|
|
2307
2348
|
"%"
|
|
2308
2349
|
] })
|
|
2309
2350
|
] })
|
|
2310
2351
|
] }),
|
|
2311
|
-
/* @__PURE__ */ s.jsx(
|
|
2352
|
+
/* @__PURE__ */ s.jsx(Is, { className: "gap-2 sm:gap-0", children: W ? /* @__PURE__ */ s.jsx(le, { onClick: pe, children: "Close" }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
|
|
2312
2353
|
/* @__PURE__ */ s.jsxs(le, { variant: "ghost", onClick: pe, disabled: T, children: [
|
|
2313
2354
|
/* @__PURE__ */ s.jsx(it, { className: "mr-1 h-4 w-4" }),
|
|
2314
2355
|
" Cancel"
|
|
2315
2356
|
] }),
|
|
2316
|
-
(
|
|
2357
|
+
(h === "mapping" || h === "preview") && /* @__PURE__ */ s.jsxs(le, { variant: "outline", onClick: () => u(h === "mapping" ? "upload" : "mapping"), disabled: T, children: [
|
|
2317
2358
|
/* @__PURE__ */ s.jsx(tn, { className: "mr-1 h-4 w-4" }),
|
|
2318
2359
|
" Back"
|
|
2319
2360
|
] }),
|
|
2320
|
-
|
|
2361
|
+
h === "mapping" && /* @__PURE__ */ s.jsxs(le, { onClick: () => u("preview"), disabled: Object.keys(j).length === 0 || Ae.length > 0, children: [
|
|
2321
2362
|
"Next ",
|
|
2322
2363
|
/* @__PURE__ */ s.jsx(St, { className: "ml-1 h-4 w-4" })
|
|
2323
2364
|
] }),
|
|
2324
|
-
|
|
2365
|
+
h === "preview" && /* @__PURE__ */ s.jsx(le, { onClick: Re, disabled: T, children: T ? "Importing…" : `Import ${x.length} Rows` })
|
|
2325
2366
|
] }) })
|
|
2326
2367
|
] }) });
|
|
2327
2368
|
};
|
|
2328
2369
|
function ur({
|
|
2329
2370
|
value: e,
|
|
2330
|
-
onSave:
|
|
2371
|
+
onSave: l,
|
|
2331
2372
|
onCancel: t,
|
|
2332
2373
|
validate: n,
|
|
2333
2374
|
type: r = "text",
|
|
2334
2375
|
placeholder: i,
|
|
2335
2376
|
editing: a = !1,
|
|
2336
|
-
className:
|
|
2337
|
-
disabled:
|
|
2377
|
+
className: o,
|
|
2378
|
+
disabled: m = !1
|
|
2338
2379
|
}) {
|
|
2339
|
-
const [
|
|
2380
|
+
const [h, u] = I(a), [f, p] = I(String(e ?? "")), [x, y] = I(), [j, k] = I(!1), T = xe(null);
|
|
2340
2381
|
me(() => {
|
|
2341
|
-
|
|
2342
|
-
}, [e,
|
|
2343
|
-
|
|
2344
|
-
}, [
|
|
2382
|
+
h || p(String(e ?? ""));
|
|
2383
|
+
}, [e, h]), me(() => {
|
|
2384
|
+
h && T.current && (T.current.focus(), T.current.select());
|
|
2385
|
+
}, [h]);
|
|
2345
2386
|
const D = M(() => {
|
|
2346
|
-
|
|
2347
|
-
}, [
|
|
2348
|
-
|
|
2387
|
+
m || (u(!0), p(String(e ?? "")), y(void 0));
|
|
2388
|
+
}, [m, e]), F = M(() => {
|
|
2389
|
+
u(!1), p(String(e ?? "")), y(void 0), t?.();
|
|
2349
2390
|
}, [e, t]), G = M(async () => {
|
|
2350
2391
|
if (n) {
|
|
2351
|
-
const re = n(
|
|
2392
|
+
const re = n(f);
|
|
2352
2393
|
if (re) {
|
|
2353
|
-
|
|
2394
|
+
y(re);
|
|
2354
2395
|
return;
|
|
2355
2396
|
}
|
|
2356
2397
|
}
|
|
2357
|
-
const H = r === "number" ? Number(
|
|
2398
|
+
const H = r === "number" ? Number(f) : f;
|
|
2358
2399
|
k(!0);
|
|
2359
2400
|
try {
|
|
2360
|
-
const re = await
|
|
2401
|
+
const re = await l(H);
|
|
2361
2402
|
if (typeof re == "string") {
|
|
2362
|
-
|
|
2403
|
+
y(re), k(!1);
|
|
2363
2404
|
return;
|
|
2364
2405
|
}
|
|
2365
|
-
|
|
2406
|
+
u(!1), y(void 0);
|
|
2366
2407
|
} catch (re) {
|
|
2367
|
-
|
|
2408
|
+
y(re?.message || "Save failed");
|
|
2368
2409
|
} finally {
|
|
2369
2410
|
k(!1);
|
|
2370
2411
|
}
|
|
2371
|
-
}, [
|
|
2412
|
+
}, [f, n, r, l]), W = M(
|
|
2372
2413
|
(H) => {
|
|
2373
|
-
H.key === "Enter" ? (H.preventDefault(), G()) : H.key === "Escape" && (H.preventDefault(),
|
|
2414
|
+
H.key === "Enter" ? (H.preventDefault(), G()) : H.key === "Escape" && (H.preventDefault(), F());
|
|
2374
2415
|
},
|
|
2375
|
-
[G,
|
|
2416
|
+
[G, F]
|
|
2376
2417
|
);
|
|
2377
|
-
return
|
|
2418
|
+
return h ? /* @__PURE__ */ s.jsxs(
|
|
2378
2419
|
"div",
|
|
2379
2420
|
{
|
|
2380
2421
|
"data-slot": "inline-editing",
|
|
2381
|
-
className: ue("relative flex items-center gap-1",
|
|
2422
|
+
className: ue("relative flex items-center gap-1", o),
|
|
2382
2423
|
children: [
|
|
2383
2424
|
/* @__PURE__ */ s.jsxs("div", { className: "flex-1 relative", children: [
|
|
2384
2425
|
/* @__PURE__ */ s.jsx(
|
|
@@ -2387,20 +2428,20 @@ function ur({
|
|
|
2387
2428
|
ref: T,
|
|
2388
2429
|
"data-slot": "inline-editing-input",
|
|
2389
2430
|
type: r,
|
|
2390
|
-
value:
|
|
2431
|
+
value: f,
|
|
2391
2432
|
onChange: (H) => {
|
|
2392
|
-
p(H.target.value), x &&
|
|
2433
|
+
p(H.target.value), x && y(void 0);
|
|
2393
2434
|
},
|
|
2394
2435
|
onKeyDown: W,
|
|
2395
2436
|
placeholder: i,
|
|
2396
|
-
disabled:
|
|
2437
|
+
disabled: j,
|
|
2397
2438
|
"aria-invalid": !!x,
|
|
2398
2439
|
"aria-describedby": x ? "inline-editing-error" : void 0,
|
|
2399
2440
|
className: ue(
|
|
2400
2441
|
"w-full rounded border px-2 py-1 text-sm outline-none transition-colors",
|
|
2401
2442
|
"focus:ring-2 focus:ring-ring focus:border-input",
|
|
2402
2443
|
x ? "border-destructive focus:ring-destructive/30" : "border-input",
|
|
2403
|
-
|
|
2444
|
+
j && "opacity-50"
|
|
2404
2445
|
)
|
|
2405
2446
|
}
|
|
2406
2447
|
),
|
|
@@ -2421,11 +2462,11 @@ function ur({
|
|
|
2421
2462
|
"data-slot": "inline-editing-save",
|
|
2422
2463
|
type: "button",
|
|
2423
2464
|
onClick: G,
|
|
2424
|
-
disabled:
|
|
2465
|
+
disabled: j,
|
|
2425
2466
|
"aria-label": "Save",
|
|
2426
2467
|
className: ue(
|
|
2427
2468
|
"inline-flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/10 transition-colors",
|
|
2428
|
-
|
|
2469
|
+
j && "opacity-50 cursor-not-allowed"
|
|
2429
2470
|
),
|
|
2430
2471
|
children: /* @__PURE__ */ s.jsx(Wt, { className: "h-3.5 w-3.5" })
|
|
2431
2472
|
}
|
|
@@ -2435,8 +2476,8 @@ function ur({
|
|
|
2435
2476
|
{
|
|
2436
2477
|
"data-slot": "inline-editing-cancel",
|
|
2437
2478
|
type: "button",
|
|
2438
|
-
onClick:
|
|
2439
|
-
disabled:
|
|
2479
|
+
onClick: F,
|
|
2480
|
+
disabled: j,
|
|
2440
2481
|
"aria-label": "Cancel",
|
|
2441
2482
|
className: "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",
|
|
2442
2483
|
children: /* @__PURE__ */ s.jsx(it, { className: "h-3.5 w-3.5" })
|
|
@@ -2450,12 +2491,12 @@ function ur({
|
|
|
2450
2491
|
"data-slot": "inline-editing",
|
|
2451
2492
|
className: ue(
|
|
2452
2493
|
"group relative cursor-pointer rounded px-2 py-1 hover:bg-muted/50 transition-colors min-h-[1.75rem] flex items-center",
|
|
2453
|
-
|
|
2454
|
-
|
|
2494
|
+
m && "cursor-default opacity-60",
|
|
2495
|
+
o
|
|
2455
2496
|
),
|
|
2456
2497
|
onClick: D,
|
|
2457
2498
|
role: "button",
|
|
2458
|
-
tabIndex:
|
|
2499
|
+
tabIndex: m ? -1 : 0,
|
|
2459
2500
|
onKeyDown: (H) => {
|
|
2460
2501
|
(H.key === "Enter" || H.key === " ") && (H.preventDefault(), D());
|
|
2461
2502
|
},
|
|
@@ -2464,7 +2505,7 @@ function ur({
|
|
|
2464
2505
|
}
|
|
2465
2506
|
);
|
|
2466
2507
|
}
|
|
2467
|
-
function
|
|
2508
|
+
function Ft(e) {
|
|
2468
2509
|
return {
|
|
2469
2510
|
startRow: Math.min(e.startRow, e.endRow),
|
|
2470
2511
|
startCol: Math.min(e.startCol, e.endCol),
|
|
@@ -2474,162 +2515,162 @@ function zt(e) {
|
|
|
2474
2515
|
}
|
|
2475
2516
|
function fr({
|
|
2476
2517
|
data: e,
|
|
2477
|
-
columns:
|
|
2518
|
+
columns: l,
|
|
2478
2519
|
onPaste: t,
|
|
2479
2520
|
enabled: n = !0
|
|
2480
2521
|
}) {
|
|
2481
|
-
const [r, i] =
|
|
2522
|
+
const [r, i] = I(null), a = M(() => {
|
|
2482
2523
|
if (!n || !r) return;
|
|
2483
|
-
const { startRow:
|
|
2484
|
-
for (let
|
|
2485
|
-
const k = e[
|
|
2524
|
+
const { startRow: h, startCol: u, endRow: f, endCol: p } = Ft(r), x = [];
|
|
2525
|
+
for (let j = h; j <= f; j++) {
|
|
2526
|
+
const k = e[j];
|
|
2486
2527
|
if (!k) continue;
|
|
2487
2528
|
const T = [];
|
|
2488
|
-
for (let D =
|
|
2489
|
-
const
|
|
2490
|
-
T.push(
|
|
2529
|
+
for (let D = u; D <= p; D++) {
|
|
2530
|
+
const F = l[D];
|
|
2531
|
+
T.push(F ? String(k[F] ?? "") : "");
|
|
2491
2532
|
}
|
|
2492
2533
|
x.push(T.join(" "));
|
|
2493
2534
|
}
|
|
2494
|
-
const
|
|
2535
|
+
const y = x.join(`
|
|
2495
2536
|
`);
|
|
2496
|
-
navigator.clipboard.writeText(
|
|
2497
|
-
}, [n, r, e,
|
|
2537
|
+
navigator.clipboard.writeText(y);
|
|
2538
|
+
}, [n, r, e, l]), o = M(() => {
|
|
2498
2539
|
if (!n || !r || !t) return;
|
|
2499
|
-
const { startRow:
|
|
2500
|
-
navigator.clipboard.readText().then((
|
|
2501
|
-
const p = [], x =
|
|
2540
|
+
const { startRow: h, startCol: u } = Ft(r);
|
|
2541
|
+
navigator.clipboard.readText().then((f) => {
|
|
2542
|
+
const p = [], x = f.split(`
|
|
2502
2543
|
`);
|
|
2503
|
-
for (let
|
|
2504
|
-
const
|
|
2505
|
-
for (let k = 0; k <
|
|
2506
|
-
const T =
|
|
2507
|
-
|
|
2544
|
+
for (let y = 0; y < x.length; y++) {
|
|
2545
|
+
const j = x[y].split(" ");
|
|
2546
|
+
for (let k = 0; k < j.length; k++) {
|
|
2547
|
+
const T = h + y, D = u + k, F = l[D];
|
|
2548
|
+
F && T < e.length && p.push({ rowIndex: T, field: F, value: j[k] });
|
|
2508
2549
|
}
|
|
2509
2550
|
}
|
|
2510
2551
|
p.length > 0 && t(p);
|
|
2511
2552
|
});
|
|
2512
|
-
}, [n, r,
|
|
2513
|
-
(
|
|
2553
|
+
}, [n, r, l, e.length, t]), m = M(
|
|
2554
|
+
(h) => {
|
|
2514
2555
|
if (!n) return;
|
|
2515
|
-
const
|
|
2516
|
-
|
|
2556
|
+
const u = h.metaKey || h.ctrlKey;
|
|
2557
|
+
u && h.key === "c" ? (h.preventDefault(), a()) : u && h.key === "v" && (h.preventDefault(), o());
|
|
2517
2558
|
},
|
|
2518
|
-
[n, a,
|
|
2559
|
+
[n, a, o]
|
|
2519
2560
|
);
|
|
2520
2561
|
return me(() => {
|
|
2521
2562
|
n || i(null);
|
|
2522
|
-
}, [n]), { selectedRange: r, setSelectedRange: i, onCopy: a, onPaste:
|
|
2563
|
+
}, [n]), { selectedRange: r, setSelectedRange: i, onCopy: a, onPaste: o, onKeyDown: m };
|
|
2523
2564
|
}
|
|
2524
2565
|
const Jn = [
|
|
2525
2566
|
{ position: 0, className: "bg-green-100" },
|
|
2526
2567
|
{ position: 0.5, className: "bg-yellow-100" },
|
|
2527
2568
|
{ position: 1, className: "bg-red-100" }
|
|
2528
2569
|
];
|
|
2529
|
-
function Xn(e,
|
|
2570
|
+
function Xn(e, l) {
|
|
2530
2571
|
let t = 1 / 0, n = -1 / 0;
|
|
2531
2572
|
for (const r of e) {
|
|
2532
|
-
const i = Number(r[
|
|
2573
|
+
const i = Number(r[l]);
|
|
2533
2574
|
Number.isFinite(i) && (i < t && (t = i), i > n && (n = i));
|
|
2534
2575
|
}
|
|
2535
2576
|
return Number.isFinite(t) ? [t, n] : [0, 0];
|
|
2536
2577
|
}
|
|
2537
|
-
function Qn(e,
|
|
2538
|
-
if (
|
|
2539
|
-
if (
|
|
2540
|
-
let t =
|
|
2541
|
-
for (let r = 1; r <
|
|
2542
|
-
const i = Math.abs(e -
|
|
2543
|
-
i < n && (t =
|
|
2578
|
+
function Qn(e, l) {
|
|
2579
|
+
if (l.length === 0) return "";
|
|
2580
|
+
if (l.length === 1) return l[0].className;
|
|
2581
|
+
let t = l[0], n = Math.abs(e - t.position);
|
|
2582
|
+
for (let r = 1; r < l.length; r++) {
|
|
2583
|
+
const i = Math.abs(e - l[r].position);
|
|
2584
|
+
i < n && (t = l[r], n = i);
|
|
2544
2585
|
}
|
|
2545
2586
|
return t.className;
|
|
2546
2587
|
}
|
|
2547
2588
|
function mr(e) {
|
|
2548
|
-
const { field:
|
|
2589
|
+
const { field: l, data: t, min: n, max: r, stops: i = Jn } = e, [a, o] = ye(() => Xn(t, l), [t, l]), m = n ?? a, h = r ?? o;
|
|
2549
2590
|
return M(
|
|
2550
|
-
(
|
|
2551
|
-
const
|
|
2552
|
-
if (!Number.isFinite(
|
|
2553
|
-
if (
|
|
2554
|
-
const p = Math.max(0, Math.min(1, (
|
|
2591
|
+
(u) => {
|
|
2592
|
+
const f = Number(u[l]);
|
|
2593
|
+
if (!Number.isFinite(f)) return;
|
|
2594
|
+
if (h === m) return i.length > 0 ? i[0].className : void 0;
|
|
2595
|
+
const p = Math.max(0, Math.min(1, (f - m) / (h - m)));
|
|
2555
2596
|
return Qn(p, i);
|
|
2556
2597
|
},
|
|
2557
|
-
[
|
|
2598
|
+
[l, m, h, i]
|
|
2558
2599
|
);
|
|
2559
2600
|
}
|
|
2560
|
-
const
|
|
2601
|
+
const zt = "text/x-group-key";
|
|
2561
2602
|
function hr({ groupKeys: e }) {
|
|
2562
|
-
const [
|
|
2603
|
+
const [l, t] = I(e), [n, r] = I(null);
|
|
2563
2604
|
me(() => {
|
|
2564
|
-
t((
|
|
2565
|
-
const
|
|
2566
|
-
if (
|
|
2567
|
-
return
|
|
2568
|
-
const x =
|
|
2569
|
-
return [...x, ...
|
|
2605
|
+
t((u) => {
|
|
2606
|
+
const f = new Set(u), p = new Set(e);
|
|
2607
|
+
if (u.length === e.length && u.every((j, k) => j === e[k]))
|
|
2608
|
+
return u;
|
|
2609
|
+
const x = u.filter((j) => p.has(j)), y = e.filter((j) => !f.has(j));
|
|
2610
|
+
return [...x, ...y];
|
|
2570
2611
|
});
|
|
2571
2612
|
}, [e]);
|
|
2572
|
-
const i = M((
|
|
2613
|
+
const i = M((u, f) => {
|
|
2573
2614
|
t((p) => {
|
|
2574
|
-
if (
|
|
2575
|
-
const x = [...p], [
|
|
2576
|
-
return x.splice(
|
|
2615
|
+
if (u < 0 || u >= p.length || f < 0 || f >= p.length || u === f) return p;
|
|
2616
|
+
const x = [...p], [y] = x.splice(u, 1);
|
|
2617
|
+
return x.splice(f, 0, y), x;
|
|
2577
2618
|
});
|
|
2578
|
-
}, []), a = M((
|
|
2579
|
-
|
|
2580
|
-
}, []),
|
|
2581
|
-
|
|
2582
|
-
}, []),
|
|
2583
|
-
(
|
|
2584
|
-
|
|
2585
|
-
const p =
|
|
2586
|
-
!p || p ===
|
|
2587
|
-
const
|
|
2588
|
-
if (
|
|
2589
|
-
const k = [...x], [T] = k.splice(
|
|
2590
|
-
return k.splice(
|
|
2619
|
+
}, []), a = M((u, f) => {
|
|
2620
|
+
u.dataTransfer.effectAllowed = "move", u.dataTransfer.setData(zt, f), r(f);
|
|
2621
|
+
}, []), o = M((u) => {
|
|
2622
|
+
u.preventDefault(), u.dataTransfer.dropEffect = "move";
|
|
2623
|
+
}, []), m = M(
|
|
2624
|
+
(u, f) => {
|
|
2625
|
+
u.preventDefault();
|
|
2626
|
+
const p = u.dataTransfer.getData(zt);
|
|
2627
|
+
!p || p === f || t((x) => {
|
|
2628
|
+
const y = x.indexOf(p), j = x.indexOf(f);
|
|
2629
|
+
if (y === -1 || j === -1) return x;
|
|
2630
|
+
const k = [...x], [T] = k.splice(y, 1);
|
|
2631
|
+
return k.splice(j, 0, T), k;
|
|
2591
2632
|
});
|
|
2592
2633
|
},
|
|
2593
2634
|
[]
|
|
2594
|
-
),
|
|
2635
|
+
), h = M(() => {
|
|
2595
2636
|
r(null);
|
|
2596
2637
|
}, []);
|
|
2597
2638
|
return {
|
|
2598
|
-
groupOrder:
|
|
2639
|
+
groupOrder: l,
|
|
2599
2640
|
moveGroup: i,
|
|
2600
2641
|
onDragStart: a,
|
|
2601
|
-
onDragOver:
|
|
2602
|
-
onDrop:
|
|
2603
|
-
onDragEnd:
|
|
2642
|
+
onDragOver: o,
|
|
2643
|
+
onDrop: m,
|
|
2644
|
+
onDragEnd: h,
|
|
2604
2645
|
draggingKey: n
|
|
2605
2646
|
};
|
|
2606
2647
|
}
|
|
2607
2648
|
function pr({
|
|
2608
2649
|
value: e,
|
|
2609
|
-
onChange:
|
|
2650
|
+
onChange: l,
|
|
2610
2651
|
onConfirm: t,
|
|
2611
2652
|
onCancel: n,
|
|
2612
2653
|
activeCell: r,
|
|
2613
2654
|
disabled: i = !1,
|
|
2614
2655
|
className: a
|
|
2615
2656
|
}) {
|
|
2616
|
-
const [
|
|
2657
|
+
const [o, m] = I(!1), [h, u] = I(e), f = xe(null);
|
|
2617
2658
|
me(() => {
|
|
2618
|
-
|
|
2619
|
-
}, [e,
|
|
2620
|
-
|
|
2621
|
-
}, [
|
|
2659
|
+
o || u(e);
|
|
2660
|
+
}, [e, o]), me(() => {
|
|
2661
|
+
o && f.current && (f.current.focus(), f.current.select());
|
|
2662
|
+
}, [o]);
|
|
2622
2663
|
const p = M(() => {
|
|
2623
|
-
i || (
|
|
2664
|
+
i || (m(!0), u(e));
|
|
2624
2665
|
}, [i, e]), x = M(() => {
|
|
2625
|
-
|
|
2626
|
-
}, [
|
|
2627
|
-
|
|
2628
|
-
}, [e, n]),
|
|
2666
|
+
m(!1), l?.(h), t?.(h);
|
|
2667
|
+
}, [h, l, t]), y = M(() => {
|
|
2668
|
+
m(!1), u(e), n?.();
|
|
2669
|
+
}, [e, n]), j = M(
|
|
2629
2670
|
(k) => {
|
|
2630
|
-
k.key === "Enter" ? (k.preventDefault(), x()) : k.key === "Escape" && (k.preventDefault(),
|
|
2671
|
+
k.key === "Enter" ? (k.preventDefault(), x()) : k.key === "Escape" && (k.preventDefault(), y());
|
|
2631
2672
|
},
|
|
2632
|
-
[x,
|
|
2673
|
+
[x, y]
|
|
2633
2674
|
);
|
|
2634
2675
|
return /* @__PURE__ */ s.jsxs(
|
|
2635
2676
|
"div",
|
|
@@ -2644,22 +2685,22 @@ function pr({
|
|
|
2644
2685
|
/* @__PURE__ */ s.jsx(
|
|
2645
2686
|
"input",
|
|
2646
2687
|
{
|
|
2647
|
-
ref:
|
|
2688
|
+
ref: f,
|
|
2648
2689
|
type: "text",
|
|
2649
|
-
value:
|
|
2650
|
-
readOnly: !
|
|
2690
|
+
value: o ? h : e,
|
|
2691
|
+
readOnly: !o,
|
|
2651
2692
|
disabled: i,
|
|
2652
2693
|
onClick: p,
|
|
2653
|
-
onChange: (k) =>
|
|
2654
|
-
onKeyDown:
|
|
2694
|
+
onChange: (k) => u(k.target.value),
|
|
2695
|
+
onKeyDown: j,
|
|
2655
2696
|
className: ue(
|
|
2656
2697
|
"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",
|
|
2657
|
-
|
|
2698
|
+
o && "rounded ring-1 ring-ring px-1",
|
|
2658
2699
|
i && "cursor-not-allowed opacity-50"
|
|
2659
2700
|
)
|
|
2660
2701
|
}
|
|
2661
2702
|
),
|
|
2662
|
-
|
|
2703
|
+
o && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2663
2704
|
/* @__PURE__ */ s.jsx(
|
|
2664
2705
|
"button",
|
|
2665
2706
|
{
|
|
@@ -2674,7 +2715,7 @@ function pr({
|
|
|
2674
2715
|
"button",
|
|
2675
2716
|
{
|
|
2676
2717
|
type: "button",
|
|
2677
|
-
onClick:
|
|
2718
|
+
onClick: y,
|
|
2678
2719
|
className: "rounded p-0.5 text-red-600 hover:bg-red-100",
|
|
2679
2720
|
"aria-label": "Cancel",
|
|
2680
2721
|
children: /* @__PURE__ */ s.jsx(it, { className: "h-4 w-4" })
|
|
@@ -2687,32 +2728,32 @@ function pr({
|
|
|
2687
2728
|
}
|
|
2688
2729
|
function gr({
|
|
2689
2730
|
frozenWidth: e,
|
|
2690
|
-
onResize:
|
|
2731
|
+
onResize: l,
|
|
2691
2732
|
minFrozenWidth: t = 100,
|
|
2692
2733
|
minScrollableWidth: n = 200,
|
|
2693
2734
|
left: r,
|
|
2694
2735
|
right: i,
|
|
2695
2736
|
className: a
|
|
2696
2737
|
}) {
|
|
2697
|
-
const
|
|
2698
|
-
(
|
|
2699
|
-
|
|
2738
|
+
const o = xe(null), [m, h] = I(e), u = xe(!1), f = xe(0), p = xe(0), x = l ? e : m, y = M(
|
|
2739
|
+
(j) => {
|
|
2740
|
+
j.preventDefault(), u.current = !0, f.current = j.clientX, p.current = x;
|
|
2700
2741
|
const k = (D) => {
|
|
2701
|
-
if (!
|
|
2702
|
-
const
|
|
2742
|
+
if (!u.current || !o.current) return;
|
|
2743
|
+
const F = o.current.offsetWidth, G = D.clientX - f.current;
|
|
2703
2744
|
let W = p.current + G;
|
|
2704
|
-
W = Math.max(W, t), W = Math.min(W,
|
|
2745
|
+
W = Math.max(W, t), W = Math.min(W, F - n), l ? l(W) : h(W);
|
|
2705
2746
|
}, T = () => {
|
|
2706
|
-
|
|
2747
|
+
u.current = !1, document.removeEventListener("pointermove", k), document.removeEventListener("pointerup", T);
|
|
2707
2748
|
};
|
|
2708
2749
|
document.addEventListener("pointermove", k), document.addEventListener("pointerup", T);
|
|
2709
2750
|
},
|
|
2710
|
-
[x, t, n,
|
|
2751
|
+
[x, t, n, l]
|
|
2711
2752
|
);
|
|
2712
2753
|
return /* @__PURE__ */ s.jsxs(
|
|
2713
2754
|
"div",
|
|
2714
2755
|
{
|
|
2715
|
-
ref:
|
|
2756
|
+
ref: o,
|
|
2716
2757
|
className: ue("flex h-full w-full overflow-hidden", a),
|
|
2717
2758
|
children: [
|
|
2718
2759
|
/* @__PURE__ */ s.jsx(
|
|
@@ -2728,7 +2769,7 @@ function gr({
|
|
|
2728
2769
|
{
|
|
2729
2770
|
role: "separator",
|
|
2730
2771
|
"aria-orientation": "vertical",
|
|
2731
|
-
onPointerDown:
|
|
2772
|
+
onPointerDown: y,
|
|
2732
2773
|
className: ue(
|
|
2733
2774
|
"flex w-2 cursor-col-resize items-center justify-center",
|
|
2734
2775
|
"border-x border-border bg-muted/50 hover:bg-muted",
|
|
@@ -2742,9 +2783,9 @@ function gr({
|
|
|
2742
2783
|
}
|
|
2743
2784
|
);
|
|
2744
2785
|
}
|
|
2745
|
-
const Ut = ({ schema: e, ...
|
|
2746
|
-
const { dataSource: t } =
|
|
2747
|
-
return /* @__PURE__ */ s.jsx(_n, { schema: e, dataSource: t, ...
|
|
2786
|
+
const Ut = ({ schema: e, ...l }) => {
|
|
2787
|
+
const { dataSource: t } = Lt() || {};
|
|
2788
|
+
return /* @__PURE__ */ s.jsx(_n, { schema: e, dataSource: t, ...l });
|
|
2748
2789
|
};
|
|
2749
2790
|
rt.register("object-grid", Ut, {
|
|
2750
2791
|
namespace: "plugin-grid",
|
|
@@ -2766,8 +2807,8 @@ rt.register("grid", Ut, {
|
|
|
2766
2807
|
{ name: "filters", type: "array", label: "Filters" }
|
|
2767
2808
|
]
|
|
2768
2809
|
});
|
|
2769
|
-
const Zn = ({ schema: e, ...
|
|
2770
|
-
const { dataSource: t } =
|
|
2810
|
+
const Zn = ({ schema: e, ...l }) => {
|
|
2811
|
+
const { dataSource: t } = Lt() || {};
|
|
2771
2812
|
return /* @__PURE__ */ s.jsx(
|
|
2772
2813
|
Yn,
|
|
2773
2814
|
{
|
|
@@ -2775,7 +2816,7 @@ const Zn = ({ schema: e, ...o }) => {
|
|
|
2775
2816
|
objectLabel: e.objectLabel,
|
|
2776
2817
|
fields: e.fields ?? [],
|
|
2777
2818
|
dataSource: t,
|
|
2778
|
-
...
|
|
2819
|
+
...l
|
|
2779
2820
|
}
|
|
2780
2821
|
);
|
|
2781
2822
|
};
|
|
@@ -2791,7 +2832,7 @@ rt.register("import-wizard", Zn, {
|
|
|
2791
2832
|
export {
|
|
2792
2833
|
_t as BulkActionBar,
|
|
2793
2834
|
pr as FormulaBar,
|
|
2794
|
-
|
|
2835
|
+
yn as GroupRow,
|
|
2795
2836
|
Yn as ImportWizard,
|
|
2796
2837
|
ur as InlineEditing,
|
|
2797
2838
|
_n as ObjectGrid,
|
|
@@ -2804,6 +2845,6 @@ export {
|
|
|
2804
2845
|
Cn as useColumnSummary,
|
|
2805
2846
|
mr as useGradientColor,
|
|
2806
2847
|
hr as useGroupReorder,
|
|
2807
|
-
|
|
2848
|
+
vn as useGroupedData,
|
|
2808
2849
|
hn as useRowColor
|
|
2809
2850
|
};
|