@object-ui/plugin-view 3.0.2 → 3.0.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 +11 -0
- package/dist/index.js +367 -347
- package/dist/index.umd.cjs +2 -2
- package/package.json +7 -7
- package/src/ObjectView.tsx +32 -16
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import Ue, { useState as
|
|
1
|
+
import * as R from "react";
|
|
2
|
+
import Ue, { useState as W, useMemo as q, useEffect as Re, useCallback as M, useContext as mt } from "react";
|
|
3
3
|
import { ComponentRegistry as te } from "@object-ui/core";
|
|
4
4
|
import { ObjectGrid as bt } from "@object-ui/plugin-grid";
|
|
5
5
|
import { ObjectForm as ke } from "@object-ui/plugin-form";
|
|
6
|
-
import { Select as be, SelectTrigger as we, SelectValue as ve, cn as A, SelectContent as ye, SelectItem as ce, Button as
|
|
7
|
-
import { Map as
|
|
8
|
-
import { SchemaRenderer as
|
|
6
|
+
import { Select as be, SelectTrigger as we, SelectValue as ve, cn as A, SelectContent as ye, SelectItem as ce, Button as K, Tabs as Ye, TabsList as Be, TabsTrigger as We, Drawer as qe, DrawerContent as Ge, DrawerHeader as Ke, DrawerTitle as Je, DrawerDescription as He, Dialog as wt, DialogContent as vt, DialogHeader as yt, DialogTitle as gt, DialogDescription as xt, Label as jt, Popover as ht, PopoverTrigger as Nt, PopoverContent as Ct, Input as ie, Checkbox as St, SortBuilder as Vt } from "@object-ui/components";
|
|
7
|
+
import { Map as Ft, Activity as Et, Calendar as _t, LayoutGrid as Tt, Grid as Rt, FileText as kt, List as Ot, icons as At, Plus as Dt, SlidersHorizontal as Oe, X as Pt, ArrowUp as $t, ArrowDown as It } from "lucide-react";
|
|
8
|
+
import { SchemaRenderer as Ae } from "@object-ui/react";
|
|
9
9
|
var pe = { exports: {} }, se = {};
|
|
10
10
|
var De;
|
|
11
11
|
function Lt() {
|
|
12
12
|
if (De) return se;
|
|
13
13
|
De = 1;
|
|
14
14
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
|
-
function f(
|
|
15
|
+
function f(o, p, m) {
|
|
16
16
|
var S = null;
|
|
17
17
|
if (m !== void 0 && (S = "" + m), p.key !== void 0 && (S = "" + p.key), "key" in p) {
|
|
18
18
|
m = {};
|
|
@@ -21,7 +21,7 @@ function Lt() {
|
|
|
21
21
|
} else m = p;
|
|
22
22
|
return p = m.ref, {
|
|
23
23
|
$$typeof: e,
|
|
24
|
-
type:
|
|
24
|
+
type: o,
|
|
25
25
|
key: S,
|
|
26
26
|
ref: p !== void 0 ? p : null,
|
|
27
27
|
props: m
|
|
@@ -41,9 +41,9 @@ function zt() {
|
|
|
41
41
|
switch (r) {
|
|
42
42
|
case _:
|
|
43
43
|
return "Fragment";
|
|
44
|
-
case
|
|
44
|
+
case s:
|
|
45
45
|
return "Profiler";
|
|
46
|
-
case
|
|
46
|
+
case k:
|
|
47
47
|
return "StrictMode";
|
|
48
48
|
case ge:
|
|
49
49
|
return "Suspense";
|
|
@@ -56,21 +56,21 @@ function zt() {
|
|
|
56
56
|
switch (typeof r.tag == "number" && console.error(
|
|
57
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
58
58
|
), r.$$typeof) {
|
|
59
|
-
case
|
|
59
|
+
case i:
|
|
60
60
|
return "Portal";
|
|
61
61
|
case P:
|
|
62
62
|
return r.displayName || "Context";
|
|
63
63
|
case g:
|
|
64
64
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
65
|
case X:
|
|
66
|
-
var
|
|
67
|
-
return r = r.displayName, r || (r =
|
|
68
|
-
case
|
|
69
|
-
return
|
|
66
|
+
var d = r.render;
|
|
67
|
+
return r = r.displayName, r || (r = d.displayName || d.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
68
|
+
case I:
|
|
69
|
+
return d = r.displayName || null, d !== null ? d : e(r.type) || "Memo";
|
|
70
70
|
case ue:
|
|
71
|
-
|
|
71
|
+
d = r._payload, r = r._init;
|
|
72
72
|
try {
|
|
73
|
-
return e(r(
|
|
73
|
+
return e(r(d));
|
|
74
74
|
} catch {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -82,33 +82,33 @@ function zt() {
|
|
|
82
82
|
function f(r) {
|
|
83
83
|
try {
|
|
84
84
|
l(r);
|
|
85
|
-
var
|
|
85
|
+
var d = !1;
|
|
86
86
|
} catch {
|
|
87
|
-
|
|
87
|
+
d = !0;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
var w =
|
|
89
|
+
if (d) {
|
|
90
|
+
d = console;
|
|
91
|
+
var w = d.error, y = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
92
92
|
return w.call(
|
|
93
|
-
|
|
93
|
+
d,
|
|
94
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
95
95
|
y
|
|
96
96
|
), l(r);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function o(r) {
|
|
100
100
|
if (r === _) return "<>";
|
|
101
101
|
if (typeof r == "object" && r !== null && r.$$typeof === ue)
|
|
102
102
|
return "<...>";
|
|
103
103
|
try {
|
|
104
|
-
var
|
|
105
|
-
return
|
|
104
|
+
var d = e(r);
|
|
105
|
+
return d ? "<" + d + ">" : "<...>";
|
|
106
106
|
} catch {
|
|
107
107
|
return "<...>";
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function p() {
|
|
111
|
-
var r =
|
|
111
|
+
var r = L.A;
|
|
112
112
|
return r === null ? null : r.getOwner();
|
|
113
113
|
}
|
|
114
114
|
function m() {
|
|
@@ -116,16 +116,16 @@ function zt() {
|
|
|
116
116
|
}
|
|
117
117
|
function S(r) {
|
|
118
118
|
if (Z.call(r, "key")) {
|
|
119
|
-
var
|
|
120
|
-
if (
|
|
119
|
+
var d = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
|
+
if (d && d.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
122
|
return r.key !== void 0;
|
|
123
123
|
}
|
|
124
|
-
function b(r,
|
|
124
|
+
function b(r, d) {
|
|
125
125
|
function w() {
|
|
126
|
-
|
|
126
|
+
V || (V = !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
|
+
d
|
|
129
129
|
));
|
|
130
130
|
}
|
|
131
131
|
w.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
@@ -133,23 +133,23 @@ function zt() {
|
|
|
133
133
|
configurable: !0
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function F() {
|
|
137
137
|
var r = e(this.type);
|
|
138
138
|
return D[r] || (D[r] = !0, console.error(
|
|
139
139
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
140
140
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
141
141
|
}
|
|
142
|
-
function N(r,
|
|
142
|
+
function N(r, d, w, y, Q, ee) {
|
|
143
143
|
var E = w.ref;
|
|
144
144
|
return r = {
|
|
145
145
|
$$typeof: C,
|
|
146
146
|
type: r,
|
|
147
|
-
key:
|
|
147
|
+
key: d,
|
|
148
148
|
props: w,
|
|
149
149
|
_owner: y
|
|
150
150
|
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(r, "ref", {
|
|
151
151
|
enumerable: !1,
|
|
152
|
-
get:
|
|
152
|
+
get: F
|
|
153
153
|
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
154
154
|
configurable: !1,
|
|
155
155
|
enumerable: !1,
|
|
@@ -172,25 +172,25 @@ function zt() {
|
|
|
172
172
|
value: ee
|
|
173
173
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
174
174
|
}
|
|
175
|
-
function j(r,
|
|
176
|
-
var E =
|
|
175
|
+
function j(r, d, w, y, Q, ee) {
|
|
176
|
+
var E = d.children;
|
|
177
177
|
if (E !== void 0)
|
|
178
178
|
if (y)
|
|
179
|
-
if (
|
|
179
|
+
if (J(E)) {
|
|
180
180
|
for (y = 0; y < E.length; y++)
|
|
181
|
-
|
|
181
|
+
a(E[y]);
|
|
182
182
|
Object.freeze && Object.freeze(E);
|
|
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 (Z.call(
|
|
187
|
+
else a(E);
|
|
188
|
+
if (Z.call(d, "key")) {
|
|
189
189
|
E = e(r);
|
|
190
|
-
var
|
|
190
|
+
var G = Object.keys(d).filter(function(xe) {
|
|
191
191
|
return xe !== "key";
|
|
192
192
|
});
|
|
193
|
-
y = 0 <
|
|
193
|
+
y = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", x[E + y] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
194
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
195
195
|
let props = %s;
|
|
196
196
|
<%s {...props} />
|
|
@@ -199,15 +199,15 @@ React keys must be passed directly to JSX without using spread:
|
|
|
199
199
|
<%s key={someKey} {...props} />`,
|
|
200
200
|
y,
|
|
201
201
|
E,
|
|
202
|
-
|
|
202
|
+
G,
|
|
203
203
|
E
|
|
204
204
|
), x[E + y] = !0);
|
|
205
205
|
}
|
|
206
|
-
if (E = null, w !== void 0 && (f(w), E = "" + w), S(
|
|
206
|
+
if (E = null, w !== void 0 && (f(w), E = "" + w), S(d) && (f(d.key), E = "" + d.key), "key" in d) {
|
|
207
207
|
w = {};
|
|
208
|
-
for (var ae in
|
|
209
|
-
ae !== "key" && (w[ae] =
|
|
210
|
-
} else w =
|
|
208
|
+
for (var ae in d)
|
|
209
|
+
ae !== "key" && (w[ae] = d[ae]);
|
|
210
|
+
} else w = d;
|
|
211
211
|
return E && b(
|
|
212
212
|
w,
|
|
213
213
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
@@ -220,13 +220,13 @@ React keys must be passed directly to JSX without using spread:
|
|
|
220
220
|
ee
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function a(r) {
|
|
224
224
|
h(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === ue && (r._payload.status === "fulfilled" ? h(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
225
225
|
}
|
|
226
226
|
function h(r) {
|
|
227
227
|
return typeof r == "object" && r !== null && r.$$typeof === C;
|
|
228
228
|
}
|
|
229
|
-
var v = Ue, C = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
229
|
+
var v = Ue, C = /* @__PURE__ */ Symbol.for("react.transitional.element"), i = /* @__PURE__ */ Symbol.for("react.portal"), _ = /* @__PURE__ */ Symbol.for("react.fragment"), k = /* @__PURE__ */ Symbol.for("react.strict_mode"), s = /* @__PURE__ */ Symbol.for("react.profiler"), g = /* @__PURE__ */ Symbol.for("react.consumer"), P = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), ge = /* @__PURE__ */ Symbol.for("react.suspense"), de = /* @__PURE__ */ Symbol.for("react.suspense_list"), I = /* @__PURE__ */ Symbol.for("react.memo"), ue = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), Se = /* @__PURE__ */ Symbol.for("react.client.reference"), L = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, J = Array.isArray, ne = console.createTask ? console.createTask : function() {
|
|
230
230
|
return null;
|
|
231
231
|
};
|
|
232
232
|
v = {
|
|
@@ -234,29 +234,29 @@ React keys must be passed directly to JSX without using spread:
|
|
|
234
234
|
return r();
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
var
|
|
237
|
+
var V, D = {}, le = v.react_stack_bottom_frame.bind(
|
|
238
238
|
v,
|
|
239
239
|
m
|
|
240
|
-
)(), fe = ne(
|
|
241
|
-
oe.Fragment = _, oe.jsx = function(r,
|
|
242
|
-
var y = 1e4 >
|
|
240
|
+
)(), fe = ne(o(m)), x = {};
|
|
241
|
+
oe.Fragment = _, oe.jsx = function(r, d, w) {
|
|
242
|
+
var y = 1e4 > L.recentlyCreatedOwnerStacks++;
|
|
243
243
|
return j(
|
|
244
244
|
r,
|
|
245
|
-
|
|
245
|
+
d,
|
|
246
246
|
w,
|
|
247
247
|
!1,
|
|
248
248
|
y ? Error("react-stack-top-frame") : le,
|
|
249
|
-
y ? ne(
|
|
249
|
+
y ? ne(o(r)) : fe
|
|
250
250
|
);
|
|
251
|
-
}, oe.jsxs = function(r,
|
|
252
|
-
var y = 1e4 >
|
|
251
|
+
}, oe.jsxs = function(r, d, w) {
|
|
252
|
+
var y = 1e4 > L.recentlyCreatedOwnerStacks++;
|
|
253
253
|
return j(
|
|
254
254
|
r,
|
|
255
|
-
|
|
255
|
+
d,
|
|
256
256
|
w,
|
|
257
257
|
!0,
|
|
258
258
|
y ? Error("react-stack-top-frame") : le,
|
|
259
|
-
y ? ne(
|
|
259
|
+
y ? ne(o(r)) : fe
|
|
260
260
|
);
|
|
261
261
|
};
|
|
262
262
|
})()), oe;
|
|
@@ -267,47 +267,47 @@ function Mt() {
|
|
|
267
267
|
}
|
|
268
268
|
var t = Mt();
|
|
269
269
|
function Xe(e) {
|
|
270
|
-
var l, f,
|
|
271
|
-
if (typeof e == "string" || typeof e == "number")
|
|
270
|
+
var l, f, o = "";
|
|
271
|
+
if (typeof e == "string" || typeof e == "number") o += e;
|
|
272
272
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
273
273
|
var p = e.length;
|
|
274
|
-
for (l = 0; l < p; l++) e[l] && (f = Xe(e[l])) && (
|
|
275
|
-
} else for (f in e) e[f] && (
|
|
276
|
-
return
|
|
274
|
+
for (l = 0; l < p; l++) e[l] && (f = Xe(e[l])) && (o && (o += " "), o += f);
|
|
275
|
+
} else for (f in e) e[f] && (o && (o += " "), o += f);
|
|
276
|
+
return o;
|
|
277
277
|
}
|
|
278
278
|
function Ut() {
|
|
279
|
-
for (var e, l, f = 0,
|
|
280
|
-
return
|
|
279
|
+
for (var e, l, f = 0, o = "", p = arguments.length; f < p; f++) (e = arguments[f]) && (l = Xe(e)) && (o && (o += " "), o += l);
|
|
280
|
+
return o;
|
|
281
281
|
}
|
|
282
282
|
const Ie = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, Le = Ut, re = (e, l) => (f) => {
|
|
283
|
-
var
|
|
283
|
+
var o;
|
|
284
284
|
if (l?.variants == null) return Le(e, f?.class, f?.className);
|
|
285
285
|
const { variants: p, defaultVariants: m } = l, S = Object.keys(p).map((N) => {
|
|
286
|
-
const j = f?.[N],
|
|
286
|
+
const j = f?.[N], a = m?.[N];
|
|
287
287
|
if (j === null) return null;
|
|
288
|
-
const h = Ie(j) || Ie(
|
|
288
|
+
const h = Ie(j) || Ie(a);
|
|
289
289
|
return p[N][h];
|
|
290
290
|
}), b = f && Object.entries(f).reduce((N, j) => {
|
|
291
|
-
let [
|
|
292
|
-
return h === void 0 || (N[
|
|
293
|
-
}, {}),
|
|
294
|
-
let { class:
|
|
291
|
+
let [a, h] = j;
|
|
292
|
+
return h === void 0 || (N[a] = h), N;
|
|
293
|
+
}, {}), F = l == null || (o = l.compoundVariants) === null || o === void 0 ? void 0 : o.reduce((N, j) => {
|
|
294
|
+
let { class: a, className: h, ...v } = j;
|
|
295
295
|
return Object.entries(v).every((C) => {
|
|
296
|
-
let [
|
|
296
|
+
let [i, _] = C;
|
|
297
297
|
return Array.isArray(_) ? _.includes({
|
|
298
298
|
...m,
|
|
299
299
|
...b
|
|
300
|
-
}[
|
|
300
|
+
}[i]) : {
|
|
301
301
|
...m,
|
|
302
302
|
...b
|
|
303
|
-
}[
|
|
303
|
+
}[i] === _;
|
|
304
304
|
}) ? [
|
|
305
305
|
...N,
|
|
306
|
-
|
|
306
|
+
a,
|
|
307
307
|
h
|
|
308
308
|
] : N;
|
|
309
309
|
}, []);
|
|
310
|
-
return Le(e, S,
|
|
310
|
+
return Le(e, S, F, f?.class, f?.className);
|
|
311
311
|
}, Yt = {
|
|
312
312
|
list: "List",
|
|
313
313
|
detail: "Detail",
|
|
@@ -317,13 +317,13 @@ const Ie = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, Le = Ut, r
|
|
|
317
317
|
timeline: "Timeline",
|
|
318
318
|
map: "Map"
|
|
319
319
|
}, Bt = {
|
|
320
|
-
list:
|
|
320
|
+
list: Ot,
|
|
321
321
|
detail: kt,
|
|
322
322
|
grid: Rt,
|
|
323
323
|
kanban: Tt,
|
|
324
324
|
calendar: _t,
|
|
325
325
|
timeline: Et,
|
|
326
|
-
map:
|
|
326
|
+
map: Ft
|
|
327
327
|
}, Wt = re("flex gap-4", {
|
|
328
328
|
variants: {
|
|
329
329
|
position: {
|
|
@@ -367,16 +367,16 @@ const Ie = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, Le = Ut, r
|
|
|
367
367
|
orientation: "horizontal"
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
|
-
function
|
|
370
|
+
function Jt(e) {
|
|
371
371
|
return e.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("");
|
|
372
372
|
}
|
|
373
|
-
const
|
|
373
|
+
const Ht = {
|
|
374
374
|
Home: "House"
|
|
375
375
|
};
|
|
376
376
|
function Xt(e) {
|
|
377
377
|
if (!e) return null;
|
|
378
|
-
const l =
|
|
379
|
-
return
|
|
378
|
+
const l = Jt(e), f = Ht[l] || l;
|
|
379
|
+
return At[f] || null;
|
|
380
380
|
}
|
|
381
381
|
function je(e) {
|
|
382
382
|
return e.label ? e.label : Yt[e.type] || e.type;
|
|
@@ -391,77 +391,77 @@ const Ze = ({
|
|
|
391
391
|
schema: e,
|
|
392
392
|
className: l,
|
|
393
393
|
onViewChange: f,
|
|
394
|
-
...
|
|
394
|
+
...o
|
|
395
395
|
}) => {
|
|
396
|
-
const p =
|
|
397
|
-
|
|
396
|
+
const p = R.useMemo(() => e.storageKey ? e.storageKey : `view-switcher${e.id ? `-${e.id}` : ""}`, [e.id, e.storageKey]), [m, S] = R.useState(() => Zt(e));
|
|
397
|
+
R.useEffect(() => {
|
|
398
398
|
if (e.activeView) {
|
|
399
399
|
S(e.activeView);
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
402
|
if (e.persistPreference)
|
|
403
403
|
try {
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const g = e.views.find((P) => P.type ===
|
|
404
|
+
const s = localStorage.getItem(p);
|
|
405
|
+
if (s) {
|
|
406
|
+
const g = e.views.find((P) => P.type === s)?.type;
|
|
407
407
|
g && S(g);
|
|
408
408
|
}
|
|
409
409
|
} catch {
|
|
410
410
|
}
|
|
411
|
-
}, [e.activeView, e.persistPreference, e.views, p]),
|
|
411
|
+
}, [e.activeView, e.persistPreference, e.views, p]), R.useEffect(() => {
|
|
412
412
|
if (!(!e.persistPreference || !m || e.activeView))
|
|
413
413
|
try {
|
|
414
414
|
localStorage.setItem(p, m);
|
|
415
415
|
} catch {
|
|
416
416
|
}
|
|
417
417
|
}, [m, e.activeView, e.persistPreference, p]);
|
|
418
|
-
const b =
|
|
419
|
-
f?.(
|
|
418
|
+
const b = R.useCallback((s) => {
|
|
419
|
+
f?.(s), e.onViewChange && typeof window < "u" && window.dispatchEvent(
|
|
420
420
|
new CustomEvent(e.onViewChange, {
|
|
421
|
-
detail: { view:
|
|
421
|
+
detail: { view: s }
|
|
422
422
|
})
|
|
423
423
|
);
|
|
424
|
-
}, [f, e.onViewChange]),
|
|
425
|
-
S(
|
|
426
|
-
}, [b]), N = m || e.views?.[0]?.type, j = N || "",
|
|
427
|
-
h === "dropdown" && /* @__PURE__ */ t.jsxs(be, { value: j, onValueChange: (
|
|
424
|
+
}, [f, e.onViewChange]), F = R.useCallback((s) => {
|
|
425
|
+
S(s), b(s);
|
|
426
|
+
}, [b]), N = m || e.views?.[0]?.type, j = N || "", a = e.views.find((s) => s.type === N) || e.views?.[0], h = e.variant || "tabs", v = e.position || "top", C = v === "left" || v === "right", i = C ? "vertical" : "horizontal", _ = /* @__PURE__ */ t.jsxs("div", { className: A(qt({ orientation: i })), children: [
|
|
427
|
+
h === "dropdown" && /* @__PURE__ */ t.jsxs(be, { value: j, onValueChange: (s) => F(s), children: [
|
|
428
428
|
/* @__PURE__ */ t.jsx(we, { className: A("w-full", C ? "h-10" : "h-9"), children: /* @__PURE__ */ t.jsx(ve, { placeholder: "Select view" }) }),
|
|
429
|
-
/* @__PURE__ */ t.jsx(ye, { children: e.views.map((
|
|
429
|
+
/* @__PURE__ */ t.jsx(ye, { children: e.views.map((s, g) => /* @__PURE__ */ t.jsx(ce, { value: s.type, children: je(s) }, `${s.type}-${g}`)) })
|
|
430
430
|
] }),
|
|
431
|
-
h === "buttons" && /* @__PURE__ */ t.jsx("div", { className: A(Gt({ orientation:
|
|
432
|
-
const P =
|
|
431
|
+
h === "buttons" && /* @__PURE__ */ t.jsx("div", { className: A(Gt({ orientation: i })), children: e.views.map((s, g) => {
|
|
432
|
+
const P = s.type === N, X = ze(s);
|
|
433
433
|
return /* @__PURE__ */ t.jsxs(
|
|
434
|
-
|
|
434
|
+
K,
|
|
435
435
|
{
|
|
436
436
|
type: "button",
|
|
437
437
|
size: "sm",
|
|
438
438
|
variant: P ? "secondary" : "ghost",
|
|
439
439
|
className: A("justify-start gap-2", C ? "w-full" : ""),
|
|
440
|
-
onClick: () =>
|
|
440
|
+
onClick: () => F(s.type),
|
|
441
441
|
children: [
|
|
442
442
|
X ? /* @__PURE__ */ t.jsx(X, { className: "h-4 w-4" }) : null,
|
|
443
|
-
/* @__PURE__ */ t.jsx("span", { children: je(
|
|
443
|
+
/* @__PURE__ */ t.jsx("span", { children: je(s) })
|
|
444
444
|
]
|
|
445
445
|
},
|
|
446
|
-
`${
|
|
446
|
+
`${s.type}-${g}`
|
|
447
447
|
);
|
|
448
448
|
}) }),
|
|
449
|
-
h === "tabs" && /* @__PURE__ */ t.jsx(Ye, { value: j, onValueChange: (
|
|
450
|
-
const P = ze(
|
|
449
|
+
h === "tabs" && /* @__PURE__ */ t.jsx(Ye, { value: j, onValueChange: (s) => F(s), children: /* @__PURE__ */ t.jsx(Be, { className: A(Kt({ orientation: i })), children: e.views.map((s, g) => {
|
|
450
|
+
const P = ze(s);
|
|
451
451
|
return /* @__PURE__ */ t.jsxs(
|
|
452
452
|
We,
|
|
453
453
|
{
|
|
454
|
-
value:
|
|
454
|
+
value: s.type,
|
|
455
455
|
className: A("gap-2", C ? "justify-start" : ""),
|
|
456
456
|
children: [
|
|
457
457
|
P ? /* @__PURE__ */ t.jsx(P, { className: "h-4 w-4" }) : null,
|
|
458
|
-
/* @__PURE__ */ t.jsx("span", { children: je(
|
|
458
|
+
/* @__PURE__ */ t.jsx("span", { children: je(s) })
|
|
459
459
|
]
|
|
460
460
|
},
|
|
461
|
-
`${
|
|
461
|
+
`${s.type}-${g}`
|
|
462
462
|
);
|
|
463
463
|
}) }) })
|
|
464
|
-
] }),
|
|
464
|
+
] }), k = a?.schema ? Array.isArray(a.schema) ? /* @__PURE__ */ t.jsx("div", { className: "space-y-4", children: a.schema.map((s, g) => /* @__PURE__ */ t.jsx(Ae, { schema: s, ...o }, `${a.type}-${g}`)) }) : /* @__PURE__ */ t.jsx(Ae, { schema: a.schema, ...o }) : null;
|
|
465
465
|
return /* @__PURE__ */ t.jsxs(
|
|
466
466
|
"div",
|
|
467
467
|
{
|
|
@@ -471,7 +471,7 @@ const Ze = ({
|
|
|
471
471
|
),
|
|
472
472
|
children: [
|
|
473
473
|
/* @__PURE__ */ t.jsx("div", { className: A("shrink-0", C ? "flex flex-col" : "flex"), children: _ }),
|
|
474
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1 min-w-0", children:
|
|
474
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-1 min-w-0", children: k })
|
|
475
475
|
]
|
|
476
476
|
}
|
|
477
477
|
);
|
|
@@ -485,46 +485,46 @@ const Qt = ({
|
|
|
485
485
|
schema: e,
|
|
486
486
|
dataSource: l,
|
|
487
487
|
className: f,
|
|
488
|
-
views:
|
|
488
|
+
views: o,
|
|
489
489
|
activeViewId: p,
|
|
490
490
|
onViewChange: m,
|
|
491
491
|
onRowClick: S,
|
|
492
492
|
onEdit: b,
|
|
493
|
-
renderListView:
|
|
493
|
+
renderListView: F,
|
|
494
494
|
toolbarAddon: N
|
|
495
495
|
}) => {
|
|
496
|
-
const [j,
|
|
496
|
+
const [j, a] = W(null), [h, v] = W(!1), [C, i] = W("create"), [_, k] = W(null), [s, g] = W(0), [P, X] = W([]), [ge, de] = W(!1), [I, ue] = W({}), [U, Se] = W([]), L = e.listViews, Z = L != null && Object.keys(L).length > 0, [J, ne] = W(() => e.defaultListView && L?.[e.defaultListView] ? e.defaultListView : L && Object.keys(L)[0] || ""), V = q(() => !Z || !J ? null : L[J] || null, [Z, J, L]), D = q(() => o && o.length > 0 ? o : null, [o]), le = D != null && D.length > 0, fe = p || D?.[0]?.id, x = D?.find((n) => n.id === fe) || D?.[0], r = q(() => V?.type ? V.type : x?.type ? x.type : e.defaultViewType || "grid", [V, x, e.defaultViewType]), d = e.navigation;
|
|
497
497
|
Re(() => {
|
|
498
498
|
let n = !0;
|
|
499
|
-
const
|
|
499
|
+
const c = async () => {
|
|
500
500
|
try {
|
|
501
|
-
const
|
|
502
|
-
n &&
|
|
503
|
-
} catch (
|
|
504
|
-
console.error("Failed to fetch object schema:",
|
|
501
|
+
const u = await l.getObjectSchema(e.objectName);
|
|
502
|
+
n && a(u);
|
|
503
|
+
} catch (u) {
|
|
504
|
+
console.error("Failed to fetch object schema:", u);
|
|
505
505
|
}
|
|
506
506
|
};
|
|
507
|
-
return e.objectName && l &&
|
|
507
|
+
return e.objectName && l && c(), () => {
|
|
508
508
|
n = !1;
|
|
509
509
|
};
|
|
510
510
|
}, [e.objectName, l]), Re(() => {
|
|
511
511
|
let n = !0;
|
|
512
512
|
return (async () => {
|
|
513
|
-
if (!(r === "grid" && !
|
|
513
|
+
if (!(r === "grid" && !F) && !(!l || !e.objectName)) {
|
|
514
514
|
de(!0);
|
|
515
515
|
try {
|
|
516
|
-
const
|
|
516
|
+
const u = V?.filter || x?.filter || e.table?.defaultFilters || [], $ = Object.entries(I).filter(([, z]) => z !== void 0 && z !== "" && z !== null).map(([z, H]) => [z, "=", H]);
|
|
517
517
|
let O = [];
|
|
518
|
-
|
|
519
|
-
const
|
|
518
|
+
u.length > 0 && $.length > 0 ? O = ["and", ...u, ...$] : $.length === 1 ? O = $[0] : $.length > 1 ? O = ["and", ...$] : O = u;
|
|
519
|
+
const Y = U.length > 0 ? U.map((z) => ({ field: z.field, order: z.direction })) : V?.sort || x?.sort || e.table?.defaultSort || void 0, T = await l.find(e.objectName, {
|
|
520
520
|
$filter: O.length > 0 ? O : void 0,
|
|
521
|
-
$orderby:
|
|
521
|
+
$orderby: Y,
|
|
522
522
|
$top: 100
|
|
523
523
|
});
|
|
524
|
-
let
|
|
525
|
-
Array.isArray(
|
|
526
|
-
} catch (
|
|
527
|
-
console.error("ObjectView data fetch error:",
|
|
524
|
+
let B = [];
|
|
525
|
+
Array.isArray(T) ? B = T : T && typeof T == "object" && (Array.isArray(T.data) ? B = T.data : Array.isArray(T.records) && (B = T.records)), n && X(B);
|
|
526
|
+
} catch (u) {
|
|
527
|
+
console.error("ObjectView data fetch error:", u);
|
|
528
528
|
} finally {
|
|
529
529
|
n && de(!1);
|
|
530
530
|
}
|
|
@@ -532,71 +532,71 @@ const Qt = ({
|
|
|
532
532
|
})(), () => {
|
|
533
533
|
n = !1;
|
|
534
534
|
};
|
|
535
|
-
}, [e.objectName, l, r,
|
|
535
|
+
}, [e.objectName, l, r, I, U, s, V, x, F]);
|
|
536
536
|
const w = e.layout || "drawer", y = e.operations || e.table?.operations || {
|
|
537
537
|
create: !0,
|
|
538
538
|
read: !0,
|
|
539
539
|
update: !0,
|
|
540
540
|
delete: !0
|
|
541
|
-
}, Q =
|
|
542
|
-
w === "page" && e.onNavigate ? e.onNavigate("new", "edit") : (
|
|
543
|
-
}, [w, e]), ee =
|
|
541
|
+
}, Q = M(() => {
|
|
542
|
+
w === "page" && e.onNavigate ? e.onNavigate("new", "edit") : (i("create"), k(null), v(!0));
|
|
543
|
+
}, [w, e]), ee = M((n) => {
|
|
544
544
|
if (b) {
|
|
545
545
|
b(n);
|
|
546
546
|
return;
|
|
547
547
|
}
|
|
548
548
|
if (w === "page" && e.onNavigate) {
|
|
549
|
-
const
|
|
550
|
-
e.onNavigate(
|
|
549
|
+
const c = n._id || n.id;
|
|
550
|
+
e.onNavigate(c, "edit");
|
|
551
551
|
} else
|
|
552
|
-
|
|
553
|
-
}, [w, e, b]), E =
|
|
552
|
+
i("edit"), k(n), v(!0);
|
|
553
|
+
}, [w, e, b]), E = M((n) => {
|
|
554
554
|
if (w === "page" && e.onNavigate) {
|
|
555
|
-
const
|
|
556
|
-
e.onNavigate(
|
|
555
|
+
const c = n._id || n.id;
|
|
556
|
+
e.onNavigate(c, "view");
|
|
557
557
|
} else
|
|
558
|
-
|
|
559
|
-
}, [w, e]),
|
|
558
|
+
i("view"), k(n), v(!0);
|
|
559
|
+
}, [w, e]), G = M((n) => {
|
|
560
560
|
if (S) {
|
|
561
561
|
S(n);
|
|
562
562
|
return;
|
|
563
563
|
}
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
564
|
+
if (d) {
|
|
565
|
+
if (d.mode === "none" || d.preventNavigation)
|
|
566
566
|
return;
|
|
567
|
-
if (
|
|
568
|
-
const
|
|
569
|
-
window.open(
|
|
567
|
+
if (d.mode === "new_window" || d.openNewTab) {
|
|
568
|
+
const c = n._id || n.id, u = `/${e.objectName}/${c}`;
|
|
569
|
+
window.open(u, "_blank");
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
|
-
if (
|
|
573
|
-
|
|
572
|
+
if (d.mode === "drawer") {
|
|
573
|
+
i("view"), k(n), v(!0);
|
|
574
574
|
return;
|
|
575
575
|
}
|
|
576
|
-
if (
|
|
577
|
-
|
|
576
|
+
if (d.mode === "modal") {
|
|
577
|
+
i("view"), k(n), v(!0);
|
|
578
578
|
return;
|
|
579
579
|
}
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
e.onNavigate && e.onNavigate(
|
|
580
|
+
if (d.mode === "page") {
|
|
581
|
+
const c = n._id || n.id;
|
|
582
|
+
e.onNavigate && e.onNavigate(c, "view");
|
|
583
583
|
return;
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
y.read !== !1 && E(n);
|
|
587
|
-
}, [S,
|
|
588
|
-
g((
|
|
589
|
-
}, []), xe =
|
|
590
|
-
g((
|
|
591
|
-
}, []), tt =
|
|
592
|
-
v(!1),
|
|
593
|
-
}, []), rt =
|
|
594
|
-
v(!1),
|
|
587
|
+
}, [S, d, y.read, E, e]), ae = M((n) => {
|
|
588
|
+
g((c) => c + 1);
|
|
589
|
+
}, []), xe = M((n) => {
|
|
590
|
+
g((c) => c + 1);
|
|
591
|
+
}, []), tt = M(() => {
|
|
592
|
+
v(!1), k(null), g((n) => n + 1);
|
|
593
|
+
}, []), rt = M(() => {
|
|
594
|
+
v(!1), k(null);
|
|
595
595
|
}, []);
|
|
596
|
-
|
|
596
|
+
M(() => {
|
|
597
597
|
g((n) => n + 1);
|
|
598
598
|
}, []);
|
|
599
|
-
const
|
|
599
|
+
const Ve = q(() => !le || !D || D.length <= 1 ? null : {
|
|
600
600
|
type: "view-switcher",
|
|
601
601
|
variant: "tabs",
|
|
602
602
|
position: "top",
|
|
@@ -605,7 +605,7 @@ const Qt = ({
|
|
|
605
605
|
defaultView: x?.type || "grid",
|
|
606
606
|
activeView: x?.type || "grid",
|
|
607
607
|
views: D.map((n) => {
|
|
608
|
-
const
|
|
608
|
+
const c = {
|
|
609
609
|
kanban: "kanban",
|
|
610
610
|
calendar: "calendar",
|
|
611
611
|
map: "map",
|
|
@@ -619,131 +619,151 @@ const Qt = ({
|
|
|
619
619
|
return {
|
|
620
620
|
type: n.type,
|
|
621
621
|
label: n.label,
|
|
622
|
-
icon:
|
|
622
|
+
icon: c[n.type] || "table"
|
|
623
623
|
};
|
|
624
624
|
})
|
|
625
|
-
}, [le, D, x, e.objectName]), nt =
|
|
625
|
+
}, [le, D, x, e.objectName]), nt = M((n) => {
|
|
626
626
|
if (!D) return;
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
}, [D, m]), lt =
|
|
627
|
+
const c = D.find((u) => u.type === n);
|
|
628
|
+
c && m && m(c.id);
|
|
629
|
+
}, [D, m]), lt = M((n) => {
|
|
630
630
|
ne(n);
|
|
631
631
|
}, []);
|
|
632
|
-
|
|
632
|
+
q(() => {
|
|
633
633
|
if (e.showFilters === !1) return null;
|
|
634
|
-
const n = e.filterableFields,
|
|
635
|
-
const
|
|
636
|
-
let
|
|
637
|
-
return
|
|
638
|
-
(
|
|
634
|
+
const n = e.filterableFields, c = j?.fields || {}, $ = (n ? n.map((O) => [O, c[O] || { label: O }]) : Object.entries(c).filter(([, O]) => !O.hidden).slice(0, 8)).map(([O, Y]) => {
|
|
635
|
+
const T = Y.type || "text";
|
|
636
|
+
let B = "text", z;
|
|
637
|
+
return T === "number" || T === "currency" || T === "percent" ? B = "number" : T === "boolean" || T === "toggle" ? B = "boolean" : T === "date" || T === "datetime" ? B = "date" : (T === "select" || Y.options) && (B = "select", z = (Y.options || []).map(
|
|
638
|
+
(H) => typeof H == "string" ? { label: H, value: H } : { label: H.label, value: H.value }
|
|
639
639
|
)), {
|
|
640
640
|
field: O,
|
|
641
|
-
label:
|
|
642
|
-
type:
|
|
643
|
-
placeholder: `Filter ${
|
|
644
|
-
...
|
|
641
|
+
label: Y.label || O,
|
|
642
|
+
type: B,
|
|
643
|
+
placeholder: `Filter ${Y.label || O}...`,
|
|
644
|
+
...z ? { options: z } : {}
|
|
645
645
|
};
|
|
646
646
|
});
|
|
647
|
-
return
|
|
647
|
+
return $.length === 0 ? null : {
|
|
648
648
|
type: "filter-ui",
|
|
649
649
|
layout: "popover",
|
|
650
650
|
showClear: !0,
|
|
651
651
|
showApply: !0,
|
|
652
|
-
filters:
|
|
653
|
-
values:
|
|
652
|
+
filters: $,
|
|
653
|
+
values: I
|
|
654
654
|
};
|
|
655
|
-
}, [e.showFilters, e.filterableFields, j,
|
|
656
|
-
const n = j?.fields || {},
|
|
657
|
-
return
|
|
655
|
+
}, [e.showFilters, e.filterableFields, j, I]), q(() => {
|
|
656
|
+
const n = j?.fields || {}, c = Object.entries(n).filter(([, u]) => !u.hidden).slice(0, 10).map(([u, $]) => ({ field: u, label: $.label || u }));
|
|
657
|
+
return c.length === 0 ? null : {
|
|
658
658
|
type: "sort-ui",
|
|
659
659
|
variant: "dropdown",
|
|
660
660
|
multiple: !1,
|
|
661
|
-
fields:
|
|
661
|
+
fields: c,
|
|
662
662
|
sort: U
|
|
663
663
|
};
|
|
664
664
|
}, [j, U]);
|
|
665
|
-
const at =
|
|
666
|
-
const
|
|
665
|
+
const at = M((n) => {
|
|
666
|
+
const c = {
|
|
667
667
|
objectName: e.objectName,
|
|
668
|
-
fields:
|
|
668
|
+
fields: V?.columns || x?.columns || e.table?.fields,
|
|
669
669
|
className: "h-full w-full",
|
|
670
670
|
showSearch: !1
|
|
671
|
-
},
|
|
671
|
+
}, u = V?.options || x || {};
|
|
672
|
+
if (process.env.NODE_ENV === "development") {
|
|
673
|
+
const $ = [
|
|
674
|
+
"startDateField",
|
|
675
|
+
"endDateField",
|
|
676
|
+
"dateField",
|
|
677
|
+
"groupBy",
|
|
678
|
+
"groupField",
|
|
679
|
+
"locationField",
|
|
680
|
+
"imageField",
|
|
681
|
+
"dependenciesField",
|
|
682
|
+
"progressField",
|
|
683
|
+
"titleField",
|
|
684
|
+
"subtitleField",
|
|
685
|
+
"latitudeField",
|
|
686
|
+
"longitudeField"
|
|
687
|
+
], O = u[n] || {}, Y = $.filter((T) => T in u && !(T in O));
|
|
688
|
+
Y.length > 0 && console.warn(
|
|
689
|
+
`[Spec Compliance] View options use flat properties ${JSON.stringify(Y)}. Move them under options.${n} per @objectstack/spec protocol.`
|
|
690
|
+
);
|
|
691
|
+
}
|
|
672
692
|
switch (n) {
|
|
673
693
|
case "kanban":
|
|
674
694
|
return {
|
|
675
695
|
type: "object-kanban",
|
|
676
|
-
...
|
|
677
|
-
groupBy:
|
|
678
|
-
groupField:
|
|
679
|
-
titleField:
|
|
680
|
-
cardFields:
|
|
681
|
-
...
|
|
696
|
+
...c,
|
|
697
|
+
groupBy: u.kanban?.groupField || "status",
|
|
698
|
+
groupField: u.kanban?.groupField || "status",
|
|
699
|
+
titleField: u.kanban?.titleField || "name",
|
|
700
|
+
cardFields: c.fields || [],
|
|
701
|
+
...u.kanban || {}
|
|
682
702
|
};
|
|
683
703
|
case "calendar":
|
|
684
704
|
return {
|
|
685
705
|
type: "object-calendar",
|
|
686
|
-
...
|
|
687
|
-
startDateField:
|
|
688
|
-
endDateField:
|
|
689
|
-
titleField:
|
|
690
|
-
...
|
|
706
|
+
...c,
|
|
707
|
+
startDateField: u.calendar?.startDateField || "start_date",
|
|
708
|
+
endDateField: u.calendar?.endDateField || "end_date",
|
|
709
|
+
titleField: u.calendar?.titleField || "name",
|
|
710
|
+
...u.calendar || {}
|
|
691
711
|
};
|
|
692
712
|
case "gallery":
|
|
693
713
|
return {
|
|
694
714
|
type: "object-gallery",
|
|
695
|
-
...
|
|
696
|
-
imageField:
|
|
697
|
-
titleField:
|
|
698
|
-
subtitleField:
|
|
699
|
-
...
|
|
715
|
+
...c,
|
|
716
|
+
imageField: u.gallery?.imageField,
|
|
717
|
+
titleField: u.gallery?.titleField || "name",
|
|
718
|
+
subtitleField: u.gallery?.subtitleField,
|
|
719
|
+
...u.gallery || {}
|
|
700
720
|
};
|
|
701
721
|
case "timeline":
|
|
702
722
|
return {
|
|
703
723
|
type: "object-timeline",
|
|
704
|
-
...
|
|
705
|
-
dateField:
|
|
706
|
-
titleField:
|
|
707
|
-
...
|
|
724
|
+
...c,
|
|
725
|
+
dateField: u.timeline?.dateField || "created_at",
|
|
726
|
+
titleField: u.timeline?.titleField || "name",
|
|
727
|
+
...u.timeline || {}
|
|
708
728
|
};
|
|
709
729
|
case "gantt":
|
|
710
730
|
return {
|
|
711
731
|
type: "object-gantt",
|
|
712
|
-
...
|
|
713
|
-
startDateField:
|
|
714
|
-
endDateField:
|
|
715
|
-
progressField:
|
|
716
|
-
dependenciesField:
|
|
717
|
-
...
|
|
732
|
+
...c,
|
|
733
|
+
startDateField: u.gantt?.startDateField || "start_date",
|
|
734
|
+
endDateField: u.gantt?.endDateField || "end_date",
|
|
735
|
+
progressField: u.gantt?.progressField || "progress",
|
|
736
|
+
dependenciesField: u.gantt?.dependenciesField || "dependencies",
|
|
737
|
+
...u.gantt || {}
|
|
718
738
|
};
|
|
719
739
|
case "map":
|
|
720
740
|
return {
|
|
721
741
|
type: "object-map",
|
|
722
|
-
...
|
|
723
|
-
locationField:
|
|
724
|
-
...
|
|
742
|
+
...c,
|
|
743
|
+
locationField: u.map?.locationField || "location",
|
|
744
|
+
...u.map || {}
|
|
725
745
|
};
|
|
726
746
|
default:
|
|
727
747
|
return null;
|
|
728
748
|
}
|
|
729
|
-
}, [e.objectName, e.table?.fields,
|
|
749
|
+
}, [e.objectName, e.table?.fields, V, x]), it = q(() => ({
|
|
730
750
|
type: "object-grid",
|
|
731
751
|
objectName: e.objectName,
|
|
732
752
|
title: e.table?.title,
|
|
733
753
|
description: e.table?.description,
|
|
734
|
-
fields:
|
|
735
|
-
columns:
|
|
754
|
+
fields: V?.columns || x?.columns || e.table?.fields,
|
|
755
|
+
columns: V?.columns || x?.columns || e.table?.columns,
|
|
736
756
|
operations: {
|
|
737
757
|
...y,
|
|
738
758
|
create: !1
|
|
739
759
|
// Create is handled by the view's create button
|
|
740
760
|
},
|
|
741
|
-
defaultFilters:
|
|
742
|
-
defaultSort:
|
|
761
|
+
defaultFilters: V?.filter || x?.filter || e.table?.defaultFilters,
|
|
762
|
+
defaultSort: V?.sort || x?.sort || e.table?.defaultSort,
|
|
743
763
|
pageSize: e.table?.pageSize,
|
|
744
764
|
selectable: e.table?.selectable,
|
|
745
765
|
className: e.table?.className
|
|
746
|
-
}), [e, y,
|
|
766
|
+
}), [e, y, V, x]), Fe = () => {
|
|
747
767
|
const n = _ ? _._id || _.id : void 0;
|
|
748
768
|
return {
|
|
749
769
|
type: "object-form",
|
|
@@ -781,48 +801,48 @@ const Qt = ({
|
|
|
781
801
|
default:
|
|
782
802
|
return n;
|
|
783
803
|
}
|
|
784
|
-
}, _e =
|
|
785
|
-
const n =
|
|
804
|
+
}, _e = q(() => {
|
|
805
|
+
const n = d?.width;
|
|
786
806
|
return n ? typeof n == "number" ? `max-w-[${n}px]` : `max-w-[${n}]` : "";
|
|
787
|
-
}, [
|
|
807
|
+
}, [d]), st = () => /* @__PURE__ */ t.jsx(qe, { open: h, onOpenChange: v, direction: "right", children: /* @__PURE__ */ t.jsxs(Ge, { className: A("w-full sm:max-w-2xl", _e), children: [
|
|
788
808
|
/* @__PURE__ */ t.jsxs(Ke, { children: [
|
|
789
|
-
/* @__PURE__ */ t.jsx(
|
|
790
|
-
e.form?.description && /* @__PURE__ */ t.jsx(
|
|
809
|
+
/* @__PURE__ */ t.jsx(Je, { children: Ee() }),
|
|
810
|
+
e.form?.description && /* @__PURE__ */ t.jsx(He, { children: e.form.description })
|
|
791
811
|
] }),
|
|
792
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1 overflow-y-auto px-4 pb-4", children: /* @__PURE__ */ t.jsx(ke, { schema:
|
|
812
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-1 overflow-y-auto px-4 pb-4", children: /* @__PURE__ */ t.jsx(ke, { schema: Fe(), dataSource: l }) })
|
|
793
813
|
] }) }), ot = () => /* @__PURE__ */ t.jsx(wt, { open: h, onOpenChange: v, children: /* @__PURE__ */ t.jsxs(vt, { className: A("max-w-2xl max-h-[90vh] overflow-y-auto", _e), children: [
|
|
794
814
|
/* @__PURE__ */ t.jsxs(yt, { children: [
|
|
795
815
|
/* @__PURE__ */ t.jsx(gt, { children: Ee() }),
|
|
796
816
|
e.form?.description && /* @__PURE__ */ t.jsx(xt, { children: e.form.description })
|
|
797
817
|
] }),
|
|
798
|
-
/* @__PURE__ */ t.jsx(ke, { schema:
|
|
799
|
-
] }) }), ct =
|
|
800
|
-
(
|
|
801
|
-
) ? Object.entries(
|
|
802
|
-
const n = `${e.objectName}-${
|
|
803
|
-
if (
|
|
804
|
-
return
|
|
818
|
+
/* @__PURE__ */ t.jsx(ke, { schema: Fe(), dataSource: l })
|
|
819
|
+
] }) }), ct = q(() => Object.keys(I).some(
|
|
820
|
+
(c) => I[c] !== void 0 && I[c] !== "" && I[c] !== null
|
|
821
|
+
) ? Object.entries(I).filter(([, c]) => c !== void 0 && c !== "" && c !== null).map(([c, u]) => ({ field: c, operator: "equals", value: u })) : V?.filter || x?.filter || e.table?.defaultFilters, [I, V, x, e.table?.defaultFilters]), dt = q(() => U.length > 0 ? U : V?.sort || x?.sort || e.table?.defaultSort, [U, V, x, e.table?.defaultSort]), ut = () => {
|
|
822
|
+
const n = `${e.objectName}-${J || x?.id || "default"}-${r}-${s}`;
|
|
823
|
+
if (F)
|
|
824
|
+
return F({
|
|
805
825
|
schema: {
|
|
806
826
|
type: "list-view",
|
|
807
827
|
objectName: e.objectName,
|
|
808
828
|
viewType: r,
|
|
809
|
-
fields:
|
|
829
|
+
fields: V?.columns || x?.columns || e.table?.fields,
|
|
810
830
|
filters: ct,
|
|
811
831
|
sort: dt,
|
|
812
|
-
options:
|
|
832
|
+
options: V?.options || x
|
|
813
833
|
},
|
|
814
834
|
dataSource: l,
|
|
815
835
|
onEdit: ee,
|
|
816
|
-
onRowClick:
|
|
836
|
+
onRowClick: G,
|
|
817
837
|
className: "h-full"
|
|
818
838
|
});
|
|
819
839
|
if (r !== "grid") {
|
|
820
|
-
const
|
|
821
|
-
if (
|
|
840
|
+
const c = at(r);
|
|
841
|
+
if (c && me)
|
|
822
842
|
return /* @__PURE__ */ t.jsx(
|
|
823
843
|
me,
|
|
824
844
|
{
|
|
825
|
-
schema:
|
|
845
|
+
schema: c,
|
|
826
846
|
dataSource: l,
|
|
827
847
|
data: P,
|
|
828
848
|
loading: ge
|
|
@@ -841,7 +861,7 @@ const Qt = ({
|
|
|
841
861
|
{
|
|
842
862
|
schema: it,
|
|
843
863
|
dataSource: l,
|
|
844
|
-
onRowClick:
|
|
864
|
+
onRowClick: G,
|
|
845
865
|
onEdit: y.update !== !1 ? ee : void 0,
|
|
846
866
|
onDelete: y.delete !== !1 ? ae : void 0,
|
|
847
867
|
onBulkDelete: y.delete !== !1 ? xe : void 0
|
|
@@ -850,31 +870,31 @@ const Qt = ({
|
|
|
850
870
|
);
|
|
851
871
|
}, ft = () => {
|
|
852
872
|
if (!Z) return null;
|
|
853
|
-
const n = Object.entries(
|
|
854
|
-
return n.length <= 1 ? null : /* @__PURE__ */ t.jsx(Ye, { value:
|
|
873
|
+
const n = Object.entries(L);
|
|
874
|
+
return n.length <= 1 ? null : /* @__PURE__ */ t.jsx(Ye, { value: J, onValueChange: lt, className: "w-full", children: /* @__PURE__ */ t.jsx(Be, { className: "w-auto", children: n.map(([c, u]) => /* @__PURE__ */ t.jsx(We, { value: c, className: "text-sm", children: u.label || c }, c)) }) });
|
|
855
875
|
}, pt = () => {
|
|
856
|
-
const n = e.showCreate !== !1 && y.create !== !1,
|
|
857
|
-
return !
|
|
858
|
-
|
|
859
|
-
(
|
|
860
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex items-center gap-2", children:
|
|
876
|
+
const n = e.showCreate !== !1 && y.create !== !1, c = e.showViewSwitcher === !0, u = ft();
|
|
877
|
+
return !u && !c && !n && !N ? null : /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
878
|
+
u,
|
|
879
|
+
(c || n || N) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
880
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex items-center gap-2", children: c && Ve && /* @__PURE__ */ t.jsx(
|
|
861
881
|
Ze,
|
|
862
882
|
{
|
|
863
|
-
schema:
|
|
883
|
+
schema: Ve,
|
|
864
884
|
onViewChange: nt,
|
|
865
885
|
className: "overflow-x-auto"
|
|
866
886
|
}
|
|
867
887
|
) }),
|
|
868
888
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
869
889
|
N,
|
|
870
|
-
n && /* @__PURE__ */ t.jsxs(
|
|
890
|
+
n && /* @__PURE__ */ t.jsxs(K, { size: "sm", onClick: Q, children: [
|
|
871
891
|
/* @__PURE__ */ t.jsx(Dt, { className: "h-4 w-4" }),
|
|
872
892
|
"Create"
|
|
873
893
|
] })
|
|
874
894
|
] })
|
|
875
895
|
] })
|
|
876
896
|
] });
|
|
877
|
-
}, Te =
|
|
897
|
+
}, Te = d?.mode === "modal" ? "modal" : d?.mode === "drawer" ? "drawer" : w;
|
|
878
898
|
return /* @__PURE__ */ t.jsxs("div", { className: A("flex flex-col h-full", f), children: [
|
|
879
899
|
(e.title || e.description) && /* @__PURE__ */ t.jsxs("div", { className: "mb-4 shrink-0", children: [
|
|
880
900
|
e.title && /* @__PURE__ */ t.jsx("h2", { className: "text-2xl font-bold tracking-tight", children: e.title }),
|
|
@@ -901,41 +921,41 @@ const Qt = ({
|
|
|
901
921
|
className: l,
|
|
902
922
|
onChange: f
|
|
903
923
|
}) => {
|
|
904
|
-
const [
|
|
905
|
-
|
|
924
|
+
const [o, p] = R.useState(e.values || {}), [m, S] = R.useState(!1);
|
|
925
|
+
R.useEffect(() => {
|
|
906
926
|
e.values && p(e.values);
|
|
907
927
|
}, [e.values]);
|
|
908
|
-
const b =
|
|
909
|
-
f?.(
|
|
928
|
+
const b = R.useCallback((i) => {
|
|
929
|
+
f?.(i), e.onChange && typeof window < "u" && window.dispatchEvent(
|
|
910
930
|
new CustomEvent(e.onChange, {
|
|
911
|
-
detail: { values:
|
|
931
|
+
detail: { values: i }
|
|
912
932
|
})
|
|
913
933
|
);
|
|
914
|
-
}, [f, e.onChange]),
|
|
915
|
-
const
|
|
916
|
-
p(
|
|
917
|
-
}, [b, e.showApply,
|
|
918
|
-
const
|
|
919
|
-
if (p(
|
|
920
|
-
b(
|
|
934
|
+
}, [f, e.onChange]), F = R.useCallback((i, _) => {
|
|
935
|
+
const k = { ...o, [i]: _ };
|
|
936
|
+
p(k), e.showApply || b(k);
|
|
937
|
+
}, [b, e.showApply, o]), N = R.useCallback(() => {
|
|
938
|
+
const i = {};
|
|
939
|
+
if (p(i), e.showApply) {
|
|
940
|
+
b(i);
|
|
921
941
|
return;
|
|
922
942
|
}
|
|
923
|
-
b(
|
|
924
|
-
}, [b, e.showApply]), j =
|
|
925
|
-
b(
|
|
926
|
-
}, [b,
|
|
927
|
-
const _ =
|
|
928
|
-
switch (
|
|
943
|
+
b(i);
|
|
944
|
+
}, [b, e.showApply]), j = R.useCallback(() => {
|
|
945
|
+
b(o), S(!1);
|
|
946
|
+
}, [b, o]), a = R.useMemo(() => Object.values(o).filter((i) => !er(i)).length, [o]), h = (i) => {
|
|
947
|
+
const _ = i.label || i.field, k = i.placeholder || `Filter by ${_}`;
|
|
948
|
+
switch (i.type) {
|
|
929
949
|
case "number":
|
|
930
950
|
return /* @__PURE__ */ t.jsx(
|
|
931
951
|
ie,
|
|
932
952
|
{
|
|
933
953
|
type: "number",
|
|
934
|
-
value:
|
|
935
|
-
placeholder:
|
|
936
|
-
onChange: (
|
|
937
|
-
const g =
|
|
938
|
-
|
|
954
|
+
value: o[i.field] ?? "",
|
|
955
|
+
placeholder: k,
|
|
956
|
+
onChange: (s) => {
|
|
957
|
+
const g = s.target.value, P = g === "" ? "" : Number(g);
|
|
958
|
+
F(i.field, P);
|
|
939
959
|
}
|
|
940
960
|
}
|
|
941
961
|
);
|
|
@@ -943,14 +963,14 @@ const Qt = ({
|
|
|
943
963
|
return /* @__PURE__ */ t.jsxs(
|
|
944
964
|
be,
|
|
945
965
|
{
|
|
946
|
-
value:
|
|
947
|
-
onValueChange: (
|
|
948
|
-
const g =
|
|
949
|
-
|
|
966
|
+
value: o[i.field] !== void 0 ? String(o[i.field]) : "",
|
|
967
|
+
onValueChange: (s) => {
|
|
968
|
+
const g = i.options?.find((P) => String(P.value) === s);
|
|
969
|
+
F(i.field, g ? g.value : s);
|
|
950
970
|
},
|
|
951
971
|
children: [
|
|
952
|
-
/* @__PURE__ */ t.jsx(we, { children: /* @__PURE__ */ t.jsx(ve, { placeholder:
|
|
953
|
-
/* @__PURE__ */ t.jsx(ye, { children:
|
|
972
|
+
/* @__PURE__ */ t.jsx(we, { children: /* @__PURE__ */ t.jsx(ve, { placeholder: k }) }),
|
|
973
|
+
/* @__PURE__ */ t.jsx(ye, { children: i.options?.map((s) => /* @__PURE__ */ t.jsx(ce, { value: String(s.value), children: s.label }, String(s.value))) })
|
|
954
974
|
]
|
|
955
975
|
}
|
|
956
976
|
);
|
|
@@ -959,20 +979,20 @@ const Qt = ({
|
|
|
959
979
|
ie,
|
|
960
980
|
{
|
|
961
981
|
type: "date",
|
|
962
|
-
value:
|
|
963
|
-
onChange: (
|
|
982
|
+
value: o[i.field] ?? "",
|
|
983
|
+
onChange: (s) => F(i.field, s.target.value)
|
|
964
984
|
}
|
|
965
985
|
);
|
|
966
986
|
case "date-range": {
|
|
967
|
-
const
|
|
987
|
+
const s = tr(o[i.field]);
|
|
968
988
|
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
969
989
|
/* @__PURE__ */ t.jsx(
|
|
970
990
|
ie,
|
|
971
991
|
{
|
|
972
992
|
type: "date",
|
|
973
|
-
value:
|
|
993
|
+
value: s.start ?? "",
|
|
974
994
|
onChange: (g) => {
|
|
975
|
-
|
|
995
|
+
F(i.field, { ...s, start: g.target.value });
|
|
976
996
|
}
|
|
977
997
|
}
|
|
978
998
|
),
|
|
@@ -980,9 +1000,9 @@ const Qt = ({
|
|
|
980
1000
|
ie,
|
|
981
1001
|
{
|
|
982
1002
|
type: "date",
|
|
983
|
-
value:
|
|
1003
|
+
value: s.end ?? "",
|
|
984
1004
|
onChange: (g) => {
|
|
985
|
-
|
|
1005
|
+
F(i.field, { ...s, end: g.target.value });
|
|
986
1006
|
}
|
|
987
1007
|
}
|
|
988
1008
|
)
|
|
@@ -993,8 +1013,8 @@ const Qt = ({
|
|
|
993
1013
|
/* @__PURE__ */ t.jsx(
|
|
994
1014
|
St,
|
|
995
1015
|
{
|
|
996
|
-
checked: !!
|
|
997
|
-
onCheckedChange: (
|
|
1016
|
+
checked: !!o[i.field],
|
|
1017
|
+
onCheckedChange: (s) => F(i.field, !!s)
|
|
998
1018
|
}
|
|
999
1019
|
),
|
|
1000
1020
|
/* @__PURE__ */ t.jsx("span", { className: "text-sm text-muted-foreground", children: "Enabled" })
|
|
@@ -1003,45 +1023,45 @@ const Qt = ({
|
|
|
1003
1023
|
return /* @__PURE__ */ t.jsx(
|
|
1004
1024
|
ie,
|
|
1005
1025
|
{
|
|
1006
|
-
value:
|
|
1007
|
-
placeholder:
|
|
1008
|
-
onChange: (
|
|
1026
|
+
value: o[i.field] ?? "",
|
|
1027
|
+
placeholder: k,
|
|
1028
|
+
onChange: (s) => F(i.field, s.target.value)
|
|
1009
1029
|
}
|
|
1010
1030
|
);
|
|
1011
1031
|
}
|
|
1012
1032
|
}, v = /* @__PURE__ */ t.jsxs("div", { className: "space-y-4", children: [
|
|
1013
|
-
/* @__PURE__ */ t.jsx("div", { className: "grid gap-4 sm:grid-cols-2", children: e.filters.map((
|
|
1014
|
-
/* @__PURE__ */ t.jsx(jt, { className: "text-xs text-muted-foreground", children:
|
|
1015
|
-
h(
|
|
1016
|
-
] },
|
|
1033
|
+
/* @__PURE__ */ t.jsx("div", { className: "grid gap-4 sm:grid-cols-2", children: e.filters.map((i) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
|
|
1034
|
+
/* @__PURE__ */ t.jsx(jt, { className: "text-xs text-muted-foreground", children: i.label || i.field }),
|
|
1035
|
+
h(i)
|
|
1036
|
+
] }, i.field)) }),
|
|
1017
1037
|
(e.showApply || e.showClear) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-end gap-2 border-t pt-3", children: [
|
|
1018
|
-
e.showClear && /* @__PURE__ */ t.jsx(
|
|
1019
|
-
e.showApply && /* @__PURE__ */ t.jsx(
|
|
1038
|
+
e.showClear && /* @__PURE__ */ t.jsx(K, { type: "button", variant: "ghost", size: "sm", onClick: N, children: "Clear" }),
|
|
1039
|
+
e.showApply && /* @__PURE__ */ t.jsx(K, { type: "button", size: "sm", onClick: j, children: "Apply" })
|
|
1020
1040
|
] })
|
|
1021
1041
|
] }), C = e.layout || "inline";
|
|
1022
1042
|
return C === "popover" ? /* @__PURE__ */ t.jsx("div", { className: A(he({ layout: C }), l), children: /* @__PURE__ */ t.jsxs(ht, { open: m, onOpenChange: S, children: [
|
|
1023
|
-
/* @__PURE__ */ t.jsx(Nt, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
|
|
1024
|
-
/* @__PURE__ */ t.jsx(
|
|
1043
|
+
/* @__PURE__ */ t.jsx(Nt, { asChild: !0, children: /* @__PURE__ */ t.jsxs(K, { type: "button", variant: a > 0 ? "secondary" : "outline", size: "sm", className: "gap-2", children: [
|
|
1044
|
+
/* @__PURE__ */ t.jsx(Oe, { className: "h-4 w-4" }),
|
|
1025
1045
|
"Filters",
|
|
1026
|
-
|
|
1046
|
+
a > 0 && /* @__PURE__ */ t.jsx("span", { className: "inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary", children: a })
|
|
1027
1047
|
] }) }),
|
|
1028
1048
|
/* @__PURE__ */ t.jsx(Ct, { align: "start", className: "w-[520px] p-4", children: v })
|
|
1029
1049
|
] }) }) : C === "drawer" ? /* @__PURE__ */ t.jsxs("div", { className: A(he({ layout: C }), l), children: [
|
|
1030
|
-
/* @__PURE__ */ t.jsxs(
|
|
1031
|
-
/* @__PURE__ */ t.jsx(
|
|
1050
|
+
/* @__PURE__ */ t.jsxs(K, { type: "button", variant: a > 0 ? "secondary" : "outline", size: "sm", className: "gap-2", onClick: () => S(!0), children: [
|
|
1051
|
+
/* @__PURE__ */ t.jsx(Oe, { className: "h-4 w-4" }),
|
|
1032
1052
|
"Filters",
|
|
1033
|
-
|
|
1053
|
+
a > 0 && /* @__PURE__ */ t.jsx("span", { className: "inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary", children: a })
|
|
1034
1054
|
] }),
|
|
1035
1055
|
/* @__PURE__ */ t.jsx(qe, { open: m, onOpenChange: S, children: /* @__PURE__ */ t.jsxs(Ge, { children: [
|
|
1036
1056
|
/* @__PURE__ */ t.jsxs(Ke, { children: [
|
|
1037
|
-
/* @__PURE__ */ t.jsx(
|
|
1038
|
-
/* @__PURE__ */ t.jsx(
|
|
1057
|
+
/* @__PURE__ */ t.jsx(Je, { children: "Filters" }),
|
|
1058
|
+
/* @__PURE__ */ t.jsx(He, { children: "Refine the data with advanced filters." })
|
|
1039
1059
|
] }),
|
|
1040
1060
|
/* @__PURE__ */ t.jsx("div", { className: "px-4 pb-6", children: v })
|
|
1041
1061
|
] }) })
|
|
1042
1062
|
] }) : /* @__PURE__ */ t.jsxs("div", { className: A(he({ layout: C }), l), children: [
|
|
1043
1063
|
v,
|
|
1044
|
-
!e.showApply && e.showClear && /* @__PURE__ */ t.jsxs(
|
|
1064
|
+
!e.showApply && e.showClear && /* @__PURE__ */ t.jsxs(K, { type: "button", variant: "ghost", size: "sm", className: "gap-2", onClick: N, children: [
|
|
1045
1065
|
/* @__PURE__ */ t.jsx(Pt, { className: "h-3.5 w-3.5" }),
|
|
1046
1066
|
"Clear filters"
|
|
1047
1067
|
] })
|
|
@@ -1072,80 +1092,80 @@ const Qt = ({
|
|
|
1072
1092
|
className: l,
|
|
1073
1093
|
onChange: f
|
|
1074
1094
|
}) => {
|
|
1075
|
-
const [
|
|
1076
|
-
|
|
1077
|
-
const
|
|
1078
|
-
p(
|
|
1095
|
+
const [o, p] = R.useState(() => Ce(e.sort)), [m, S] = R.useState(() => Me(Ce(e.sort)));
|
|
1096
|
+
R.useEffect(() => {
|
|
1097
|
+
const a = Ce(e.sort);
|
|
1098
|
+
p(a), S(Me(a));
|
|
1079
1099
|
}, [e.sort]);
|
|
1080
|
-
const b =
|
|
1081
|
-
p(
|
|
1100
|
+
const b = R.useCallback((a) => {
|
|
1101
|
+
p(a), f?.(a), e.onChange && typeof window < "u" && window.dispatchEvent(
|
|
1082
1102
|
new CustomEvent(e.onChange, {
|
|
1083
|
-
detail: { sort:
|
|
1103
|
+
detail: { sort: a }
|
|
1084
1104
|
})
|
|
1085
1105
|
);
|
|
1086
|
-
}, [f, e.onChange]),
|
|
1087
|
-
const h =
|
|
1106
|
+
}, [f, e.onChange]), F = R.useCallback((a) => {
|
|
1107
|
+
const h = o.find((i) => i.field === a), v = !!e.multiple;
|
|
1088
1108
|
if (!h) {
|
|
1089
|
-
const
|
|
1090
|
-
b(
|
|
1109
|
+
const i = v ? [...o, { field: a, direction: "asc" }] : [{ field: a, direction: "asc" }];
|
|
1110
|
+
b(i);
|
|
1091
1111
|
return;
|
|
1092
1112
|
}
|
|
1093
1113
|
if (h.direction === "asc") {
|
|
1094
|
-
const
|
|
1095
|
-
(_) => _.field ===
|
|
1114
|
+
const i = o.map(
|
|
1115
|
+
(_) => _.field === a ? { ..._, direction: "desc" } : _
|
|
1096
1116
|
);
|
|
1097
|
-
b(
|
|
1117
|
+
b(i);
|
|
1098
1118
|
return;
|
|
1099
1119
|
}
|
|
1100
|
-
const C =
|
|
1120
|
+
const C = o.filter((i) => i.field !== a);
|
|
1101
1121
|
b(C);
|
|
1102
|
-
}, [b, e.multiple,
|
|
1122
|
+
}, [b, e.multiple, o]);
|
|
1103
1123
|
if ((e.variant || "dropdown") === "buttons")
|
|
1104
|
-
return /* @__PURE__ */ t.jsx("div", { className: A(Ne({ variant: "buttons" }), l), children: e.fields.map((
|
|
1105
|
-
const h =
|
|
1124
|
+
return /* @__PURE__ */ t.jsx("div", { className: A(Ne({ variant: "buttons" }), l), children: e.fields.map((a) => {
|
|
1125
|
+
const h = o.find((C) => C.field === a.field), v = h?.direction === "asc" ? $t : It;
|
|
1106
1126
|
return /* @__PURE__ */ t.jsxs(
|
|
1107
|
-
|
|
1127
|
+
K,
|
|
1108
1128
|
{
|
|
1109
1129
|
type: "button",
|
|
1110
1130
|
variant: h ? "secondary" : "outline",
|
|
1111
1131
|
size: "sm",
|
|
1112
|
-
onClick: () =>
|
|
1132
|
+
onClick: () => F(a.field),
|
|
1113
1133
|
className: "gap-2",
|
|
1114
1134
|
children: [
|
|
1115
|
-
/* @__PURE__ */ t.jsx("span", { children:
|
|
1135
|
+
/* @__PURE__ */ t.jsx("span", { children: a.label || a.field }),
|
|
1116
1136
|
h && /* @__PURE__ */ t.jsx(v, { className: "h-3.5 w-3.5" })
|
|
1117
1137
|
]
|
|
1118
1138
|
},
|
|
1119
|
-
|
|
1139
|
+
a.field
|
|
1120
1140
|
);
|
|
1121
1141
|
}) });
|
|
1122
1142
|
if (e.multiple)
|
|
1123
1143
|
return /* @__PURE__ */ t.jsx("div", { className: A(Ne({ variant: "builder" }), l), children: /* @__PURE__ */ t.jsx(
|
|
1124
|
-
|
|
1144
|
+
Vt,
|
|
1125
1145
|
{
|
|
1126
|
-
fields: e.fields.map((
|
|
1146
|
+
fields: e.fields.map((a) => ({ value: a.field, label: a.label || a.field })),
|
|
1127
1147
|
value: m,
|
|
1128
|
-
onChange: (
|
|
1129
|
-
S(
|
|
1148
|
+
onChange: (a) => {
|
|
1149
|
+
S(a), b(nr(a));
|
|
1130
1150
|
}
|
|
1131
1151
|
}
|
|
1132
1152
|
) });
|
|
1133
|
-
const j =
|
|
1153
|
+
const j = o[0];
|
|
1134
1154
|
return /* @__PURE__ */ t.jsxs("div", { className: A(Ne({ variant: "dropdown" }), l), children: [
|
|
1135
1155
|
/* @__PURE__ */ t.jsxs(
|
|
1136
1156
|
be,
|
|
1137
1157
|
{
|
|
1138
1158
|
value: j?.field || "",
|
|
1139
|
-
onValueChange: (
|
|
1140
|
-
if (!
|
|
1159
|
+
onValueChange: (a) => {
|
|
1160
|
+
if (!a) {
|
|
1141
1161
|
b([]);
|
|
1142
1162
|
return;
|
|
1143
1163
|
}
|
|
1144
|
-
b([{ field:
|
|
1164
|
+
b([{ field: a, direction: j?.direction || "asc" }]);
|
|
1145
1165
|
},
|
|
1146
1166
|
children: [
|
|
1147
1167
|
/* @__PURE__ */ t.jsx(we, { className: "w-56", children: /* @__PURE__ */ t.jsx(ve, { placeholder: "Select field" }) }),
|
|
1148
|
-
/* @__PURE__ */ t.jsx(ye, { children: e.fields.map((
|
|
1168
|
+
/* @__PURE__ */ t.jsx(ye, { children: e.fields.map((a) => /* @__PURE__ */ t.jsx(ce, { value: a.field, children: a.label || a.field }, a.field)) })
|
|
1149
1169
|
]
|
|
1150
1170
|
}
|
|
1151
1171
|
),
|
|
@@ -1153,8 +1173,8 @@ const Qt = ({
|
|
|
1153
1173
|
be,
|
|
1154
1174
|
{
|
|
1155
1175
|
value: j?.direction || "asc",
|
|
1156
|
-
onValueChange: (
|
|
1157
|
-
j?.field && b([{ field: j.field, direction:
|
|
1176
|
+
onValueChange: (a) => {
|
|
1177
|
+
j?.field && b([{ field: j.field, direction: a }]);
|
|
1158
1178
|
},
|
|
1159
1179
|
children: [
|
|
1160
1180
|
/* @__PURE__ */ t.jsx(we, { className: "w-36", children: /* @__PURE__ */ t.jsx(ve, {}) }),
|
|
@@ -1288,7 +1308,7 @@ te.register("sort-ui", lr, {
|
|
|
1288
1308
|
sort: [{ field: "name", direction: "asc" }]
|
|
1289
1309
|
}
|
|
1290
1310
|
});
|
|
1291
|
-
const ir = ({ schema: e, className: l, children: f, dataSource:
|
|
1311
|
+
const ir = ({ schema: e, className: l, children: f, dataSource: o, ...p }) => {
|
|
1292
1312
|
const m = e.props?.columns ? { display: "grid", gridTemplateColumns: `repeat(${e.props.columns}, 1fr)`, gap: "1rem" } : void 0;
|
|
1293
1313
|
return /* @__PURE__ */ t.jsx(
|
|
1294
1314
|
"div",
|