@object-ui/plugin-view 0.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +184 -6
- package/CHANGELOG.md +16 -0
- package/README.md +58 -0
- package/dist/index.js +1168 -349
- package/dist/index.umd.cjs +2 -2
- package/dist/plugin-view/src/FilterUI.d.ts +16 -0
- package/dist/plugin-view/src/ObjectView.d.ts +85 -5
- package/dist/plugin-view/src/SortUI.d.ts +16 -0
- package/dist/plugin-view/src/ViewSwitcher.d.ts +16 -0
- package/dist/plugin-view/src/__tests__/FilterUI.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/ObjectView.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/SortUI.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/registration.test.d.ts +8 -0
- package/dist/plugin-view/src/index.d.ts +7 -1
- package/package.json +8 -7
- package/src/FilterUI.tsx +317 -0
- package/src/ObjectView.tsx +668 -148
- package/src/SortUI.tsx +210 -0
- package/src/ViewSwitcher.tsx +311 -0
- package/src/__tests__/FilterUI.test.tsx +544 -0
- package/src/__tests__/ObjectView.test.tsx +375 -0
- package/src/__tests__/SortUI.test.tsx +380 -0
- package/src/__tests__/registration.test.tsx +32 -0
- package/src/index.tsx +147 -5
- package/vitest.config.ts +12 -0
- package/vitest.setup.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,363 +1,777 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import * as T from "react";
|
|
2
|
+
import Ue, { useState as B, useMemo as W, useEffect as Re, useCallback as z, useContext as mt } from "react";
|
|
3
|
+
import { ComponentRegistry as te } from "@object-ui/core";
|
|
4
|
+
import { ObjectGrid as bt } from "@object-ui/plugin-grid";
|
|
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 G, Tabs as Ye, TabsList as Be, TabsTrigger as We, Drawer as qe, DrawerContent as Ge, DrawerHeader as Ke, DrawerTitle as He, DrawerDescription as Je, 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 Ft } from "@object-ui/components";
|
|
7
|
+
import { Map as Vt, Activity as Et, Calendar as _t, LayoutGrid as Tt, Grid as Rt, FileText as kt, List as At, icons as Ot, Plus as Dt, SlidersHorizontal as Ae, X as Pt, ArrowUp as $t, ArrowDown as It } from "lucide-react";
|
|
8
|
+
import { SchemaRenderer as Oe } from "@object-ui/react";
|
|
9
|
+
var pe = { exports: {} }, se = {};
|
|
10
|
+
var De;
|
|
11
|
+
function Lt() {
|
|
12
|
+
if (De) return se;
|
|
13
|
+
De = 1;
|
|
14
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
|
+
function f(c, p, m) {
|
|
16
|
+
var S = null;
|
|
17
|
+
if (m !== void 0 && (S = "" + m), p.key !== void 0 && (S = "" + p.key), "key" in p) {
|
|
18
|
+
m = {};
|
|
19
|
+
for (var b in p)
|
|
20
|
+
b !== "key" && (m[b] = p[b]);
|
|
21
|
+
} else m = p;
|
|
22
|
+
return p = m.ref, {
|
|
23
|
+
$$typeof: e,
|
|
24
|
+
type: c,
|
|
25
|
+
key: S,
|
|
26
|
+
ref: p !== void 0 ? p : null,
|
|
27
|
+
props: m
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
return
|
|
30
|
+
return se.Fragment = l, se.jsx = f, se.jsxs = f, se;
|
|
29
31
|
}
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
function r
|
|
35
|
-
if (
|
|
36
|
-
if (typeof
|
|
37
|
-
return
|
|
38
|
-
if (typeof
|
|
39
|
-
switch (
|
|
32
|
+
var oe = {};
|
|
33
|
+
var Pe;
|
|
34
|
+
function zt() {
|
|
35
|
+
return Pe || (Pe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
|
+
function e(r) {
|
|
37
|
+
if (r == null) return null;
|
|
38
|
+
if (typeof r == "function")
|
|
39
|
+
return r.$$typeof === Se ? null : r.displayName || r.name || null;
|
|
40
|
+
if (typeof r == "string") return r;
|
|
41
|
+
switch (r) {
|
|
40
42
|
case _:
|
|
41
43
|
return "Fragment";
|
|
42
|
-
case
|
|
44
|
+
case o:
|
|
43
45
|
return "Profiler";
|
|
44
|
-
case
|
|
46
|
+
case R:
|
|
45
47
|
return "StrictMode";
|
|
46
|
-
case
|
|
48
|
+
case ge:
|
|
47
49
|
return "Suspense";
|
|
48
|
-
case
|
|
50
|
+
case de:
|
|
49
51
|
return "SuspenseList";
|
|
50
|
-
case
|
|
52
|
+
case U:
|
|
51
53
|
return "Activity";
|
|
52
54
|
}
|
|
53
|
-
if (typeof
|
|
54
|
-
switch (typeof
|
|
55
|
+
if (typeof r == "object")
|
|
56
|
+
switch (typeof r.tag == "number" && console.error(
|
|
55
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
56
|
-
),
|
|
57
|
-
case
|
|
58
|
+
), r.$$typeof) {
|
|
59
|
+
case s:
|
|
58
60
|
return "Portal";
|
|
59
|
-
case
|
|
60
|
-
return
|
|
61
|
-
case
|
|
62
|
-
return (
|
|
61
|
+
case P:
|
|
62
|
+
return r.displayName || "Context";
|
|
63
|
+
case g:
|
|
64
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
65
|
+
case X:
|
|
66
|
+
var u = r.render;
|
|
67
|
+
return r = r.displayName, r || (r = u.displayName || u.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
63
68
|
case $:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return t = e.displayName || null, t !== null ? t : r(e.type) || "Memo";
|
|
68
|
-
case h:
|
|
69
|
-
t = e._payload, e = e._init;
|
|
69
|
+
return u = r.displayName || null, u !== null ? u : e(r.type) || "Memo";
|
|
70
|
+
case ue:
|
|
71
|
+
u = r._payload, r = r._init;
|
|
70
72
|
try {
|
|
71
|
-
return r(
|
|
73
|
+
return e(r(u));
|
|
72
74
|
} catch {
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
return null;
|
|
76
78
|
}
|
|
77
|
-
function
|
|
78
|
-
return "" +
|
|
79
|
+
function l(r) {
|
|
80
|
+
return "" + r;
|
|
79
81
|
}
|
|
80
|
-
function
|
|
82
|
+
function f(r) {
|
|
81
83
|
try {
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
+
l(r);
|
|
85
|
+
var u = !1;
|
|
84
86
|
} catch {
|
|
85
|
-
|
|
87
|
+
u = !0;
|
|
86
88
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
return
|
|
91
|
-
|
|
89
|
+
if (u) {
|
|
90
|
+
u = console;
|
|
91
|
+
var w = u.error, y = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
92
|
+
return w.call(
|
|
93
|
+
u,
|
|
92
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
93
|
-
|
|
94
|
-
),
|
|
95
|
+
y
|
|
96
|
+
), l(r);
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
|
-
function
|
|
98
|
-
if (
|
|
99
|
-
if (typeof
|
|
99
|
+
function c(r) {
|
|
100
|
+
if (r === _) return "<>";
|
|
101
|
+
if (typeof r == "object" && r !== null && r.$$typeof === ue)
|
|
100
102
|
return "<...>";
|
|
101
103
|
try {
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
+
var u = e(r);
|
|
105
|
+
return u ? "<" + u + ">" : "<...>";
|
|
104
106
|
} catch {
|
|
105
107
|
return "<...>";
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
return
|
|
110
|
+
function p() {
|
|
111
|
+
var r = I.A;
|
|
112
|
+
return r === null ? null : r.getOwner();
|
|
111
113
|
}
|
|
112
|
-
function
|
|
114
|
+
function m() {
|
|
113
115
|
return Error("react-stack-top-frame");
|
|
114
116
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
var
|
|
118
|
-
if (
|
|
117
|
+
function S(r) {
|
|
118
|
+
if (Z.call(r, "key")) {
|
|
119
|
+
var u = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
120
|
+
if (u && u.isReactWarning) return !1;
|
|
119
121
|
}
|
|
120
|
-
return
|
|
122
|
+
return r.key !== void 0;
|
|
121
123
|
}
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
|
|
124
|
+
function b(r, u) {
|
|
125
|
+
function w() {
|
|
126
|
+
F || (F = !0, console.error(
|
|
125
127
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
126
|
-
|
|
128
|
+
u
|
|
127
129
|
));
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
get:
|
|
131
|
+
w.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
132
|
+
get: w,
|
|
131
133
|
configurable: !0
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
|
-
function
|
|
135
|
-
var
|
|
136
|
-
return
|
|
136
|
+
function V() {
|
|
137
|
+
var r = e(this.type);
|
|
138
|
+
return D[r] || (D[r] = !0, console.error(
|
|
137
139
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
138
|
-
)),
|
|
139
|
-
}
|
|
140
|
-
function
|
|
141
|
-
var
|
|
142
|
-
return
|
|
143
|
-
$$typeof:
|
|
144
|
-
type:
|
|
145
|
-
key:
|
|
146
|
-
props:
|
|
147
|
-
_owner:
|
|
148
|
-
}, (
|
|
140
|
+
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
141
|
+
}
|
|
142
|
+
function N(r, u, w, y, Q, ee) {
|
|
143
|
+
var E = w.ref;
|
|
144
|
+
return r = {
|
|
145
|
+
$$typeof: C,
|
|
146
|
+
type: r,
|
|
147
|
+
key: u,
|
|
148
|
+
props: w,
|
|
149
|
+
_owner: y
|
|
150
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(r, "ref", {
|
|
149
151
|
enumerable: !1,
|
|
150
|
-
get:
|
|
151
|
-
}) : Object.defineProperty(
|
|
152
|
+
get: V
|
|
153
|
+
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
152
154
|
configurable: !1,
|
|
153
155
|
enumerable: !1,
|
|
154
156
|
writable: !0,
|
|
155
157
|
value: 0
|
|
156
|
-
}), Object.defineProperty(
|
|
158
|
+
}), Object.defineProperty(r, "_debugInfo", {
|
|
157
159
|
configurable: !1,
|
|
158
160
|
enumerable: !1,
|
|
159
161
|
writable: !0,
|
|
160
162
|
value: null
|
|
161
|
-
}), Object.defineProperty(
|
|
163
|
+
}), Object.defineProperty(r, "_debugStack", {
|
|
162
164
|
configurable: !1,
|
|
163
165
|
enumerable: !1,
|
|
164
166
|
writable: !0,
|
|
165
|
-
value:
|
|
166
|
-
}), Object.defineProperty(
|
|
167
|
+
value: Q
|
|
168
|
+
}), Object.defineProperty(r, "_debugTask", {
|
|
167
169
|
configurable: !1,
|
|
168
170
|
enumerable: !1,
|
|
169
171
|
writable: !0,
|
|
170
|
-
value:
|
|
171
|
-
}), Object.freeze && (Object.freeze(
|
|
172
|
-
}
|
|
173
|
-
function j(
|
|
174
|
-
var
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
177
|
-
if (
|
|
178
|
-
for (
|
|
179
|
-
|
|
180
|
-
Object.freeze && Object.freeze(
|
|
172
|
+
value: ee
|
|
173
|
+
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
174
|
+
}
|
|
175
|
+
function j(r, u, w, y, Q, ee) {
|
|
176
|
+
var E = u.children;
|
|
177
|
+
if (E !== void 0)
|
|
178
|
+
if (y)
|
|
179
|
+
if (K(E)) {
|
|
180
|
+
for (y = 0; y < E.length; y++)
|
|
181
|
+
i(E[y]);
|
|
182
|
+
Object.freeze && Object.freeze(E);
|
|
181
183
|
} else
|
|
182
184
|
console.error(
|
|
183
185
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
184
186
|
);
|
|
185
|
-
else
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
return
|
|
187
|
+
else i(E);
|
|
188
|
+
if (Z.call(u, "key")) {
|
|
189
|
+
E = e(r);
|
|
190
|
+
var q = Object.keys(u).filter(function(xe) {
|
|
191
|
+
return xe !== "key";
|
|
190
192
|
});
|
|
191
|
-
|
|
193
|
+
y = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", x[E + y] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
192
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
193
195
|
let props = %s;
|
|
194
196
|
<%s {...props} />
|
|
195
197
|
React keys must be passed directly to JSX without using spread:
|
|
196
198
|
let props = %s;
|
|
197
199
|
<%s key={someKey} {...props} />`,
|
|
198
|
-
|
|
199
|
-
s,
|
|
200
|
+
y,
|
|
200
201
|
E,
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
q,
|
|
203
|
+
E
|
|
204
|
+
), x[E + y] = !0);
|
|
203
205
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
for (var
|
|
207
|
-
|
|
208
|
-
} else
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
typeof
|
|
212
|
-
),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
206
|
+
if (E = null, w !== void 0 && (f(w), E = "" + w), S(u) && (f(u.key), E = "" + u.key), "key" in u) {
|
|
207
|
+
w = {};
|
|
208
|
+
for (var ae in u)
|
|
209
|
+
ae !== "key" && (w[ae] = u[ae]);
|
|
210
|
+
} else w = u;
|
|
211
|
+
return E && b(
|
|
212
|
+
w,
|
|
213
|
+
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
214
|
+
), N(
|
|
215
|
+
r,
|
|
216
|
+
E,
|
|
217
|
+
w,
|
|
218
|
+
p(),
|
|
219
|
+
Q,
|
|
220
|
+
ee
|
|
219
221
|
);
|
|
220
222
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
+
function i(r) {
|
|
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));
|
|
223
225
|
}
|
|
224
|
-
function
|
|
225
|
-
return typeof
|
|
226
|
+
function h(r) {
|
|
227
|
+
return typeof r == "object" && r !== null && r.$$typeof === C;
|
|
226
228
|
}
|
|
227
|
-
var
|
|
229
|
+
var v = Ue, C = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.portal"), _ = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), o = /* @__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"), $ = /* @__PURE__ */ Symbol.for("react.memo"), ue = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), Se = /* @__PURE__ */ Symbol.for("react.client.reference"), I = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, K = Array.isArray, ne = console.createTask ? console.createTask : function() {
|
|
228
230
|
return null;
|
|
229
231
|
};
|
|
230
|
-
|
|
231
|
-
react_stack_bottom_frame: function(
|
|
232
|
-
return
|
|
232
|
+
v = {
|
|
233
|
+
react_stack_bottom_frame: function(r) {
|
|
234
|
+
return r();
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
)(),
|
|
239
|
-
|
|
240
|
-
var
|
|
237
|
+
var F, D = {}, le = v.react_stack_bottom_frame.bind(
|
|
238
|
+
v,
|
|
239
|
+
m
|
|
240
|
+
)(), fe = ne(c(m)), x = {};
|
|
241
|
+
oe.Fragment = _, oe.jsx = function(r, u, w) {
|
|
242
|
+
var y = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
241
243
|
return j(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
r,
|
|
245
|
+
u,
|
|
246
|
+
w,
|
|
245
247
|
!1,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
y ? Error("react-stack-top-frame") : le,
|
|
249
|
+
y ? ne(c(r)) : fe
|
|
248
250
|
);
|
|
249
|
-
},
|
|
250
|
-
var
|
|
251
|
+
}, oe.jsxs = function(r, u, w) {
|
|
252
|
+
var y = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
251
253
|
return j(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
r,
|
|
255
|
+
u,
|
|
256
|
+
w,
|
|
255
257
|
!0,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
y ? Error("react-stack-top-frame") : le,
|
|
259
|
+
y ? ne(c(r)) : fe
|
|
258
260
|
);
|
|
259
261
|
};
|
|
260
|
-
})()),
|
|
262
|
+
})()), oe;
|
|
261
263
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
264
|
-
return
|
|
264
|
+
var $e;
|
|
265
|
+
function Mt() {
|
|
266
|
+
return $e || ($e = 1, process.env.NODE_ENV === "production" ? pe.exports = Lt() : pe.exports = zt()), pe.exports;
|
|
265
267
|
}
|
|
266
|
-
var
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
var t = Mt();
|
|
269
|
+
function Xe(e) {
|
|
270
|
+
var l, f, c = "";
|
|
271
|
+
if (typeof e == "string" || typeof e == "number") c += e;
|
|
272
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
273
|
+
var p = e.length;
|
|
274
|
+
for (l = 0; l < p; l++) e[l] && (f = Xe(e[l])) && (c && (c += " "), c += f);
|
|
275
|
+
} else for (f in e) e[f] && (c && (c += " "), c += f);
|
|
276
|
+
return c;
|
|
277
|
+
}
|
|
278
|
+
function Ut() {
|
|
279
|
+
for (var e, l, f = 0, c = "", p = arguments.length; f < p; f++) (e = arguments[f]) && (l = Xe(e)) && (c && (c += " "), c += l);
|
|
280
|
+
return c;
|
|
281
|
+
}
|
|
282
|
+
const Ie = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, Le = Ut, re = (e, l) => (f) => {
|
|
283
|
+
var c;
|
|
284
|
+
if (l?.variants == null) return Le(e, f?.class, f?.className);
|
|
285
|
+
const { variants: p, defaultVariants: m } = l, S = Object.keys(p).map((N) => {
|
|
286
|
+
const j = f?.[N], i = m?.[N];
|
|
287
|
+
if (j === null) return null;
|
|
288
|
+
const h = Ie(j) || Ie(i);
|
|
289
|
+
return p[N][h];
|
|
290
|
+
}), b = f && Object.entries(f).reduce((N, j) => {
|
|
291
|
+
let [i, h] = j;
|
|
292
|
+
return h === void 0 || (N[i] = h), N;
|
|
293
|
+
}, {}), V = l == null || (c = l.compoundVariants) === null || c === void 0 ? void 0 : c.reduce((N, j) => {
|
|
294
|
+
let { class: i, className: h, ...v } = j;
|
|
295
|
+
return Object.entries(v).every((C) => {
|
|
296
|
+
let [s, _] = C;
|
|
297
|
+
return Array.isArray(_) ? _.includes({
|
|
298
|
+
...m,
|
|
299
|
+
...b
|
|
300
|
+
}[s]) : {
|
|
301
|
+
...m,
|
|
302
|
+
...b
|
|
303
|
+
}[s] === _;
|
|
304
|
+
}) ? [
|
|
305
|
+
...N,
|
|
306
|
+
i,
|
|
307
|
+
h
|
|
308
|
+
] : N;
|
|
309
|
+
}, []);
|
|
310
|
+
return Le(e, S, V, f?.class, f?.className);
|
|
311
|
+
}, Yt = {
|
|
312
|
+
list: "List",
|
|
313
|
+
detail: "Detail",
|
|
314
|
+
grid: "Grid",
|
|
315
|
+
kanban: "Kanban",
|
|
316
|
+
calendar: "Calendar",
|
|
317
|
+
timeline: "Timeline",
|
|
318
|
+
map: "Map"
|
|
319
|
+
}, Bt = {
|
|
320
|
+
list: At,
|
|
321
|
+
detail: kt,
|
|
322
|
+
grid: Rt,
|
|
323
|
+
kanban: Tt,
|
|
324
|
+
calendar: _t,
|
|
325
|
+
timeline: Et,
|
|
326
|
+
map: Vt
|
|
327
|
+
}, Wt = re("flex gap-4", {
|
|
328
|
+
variants: {
|
|
329
|
+
position: {
|
|
330
|
+
top: "flex-col",
|
|
331
|
+
bottom: "flex-col-reverse",
|
|
332
|
+
left: "flex-row",
|
|
333
|
+
right: "flex-row-reverse"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
defaultVariants: {
|
|
337
|
+
position: "top"
|
|
338
|
+
}
|
|
339
|
+
}), qt = re("w-full", {
|
|
340
|
+
variants: {
|
|
341
|
+
orientation: {
|
|
342
|
+
horizontal: "w-full",
|
|
343
|
+
vertical: "w-48"
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
defaultVariants: {
|
|
347
|
+
orientation: "horizontal"
|
|
348
|
+
}
|
|
349
|
+
}), Gt = re("flex gap-2", {
|
|
350
|
+
variants: {
|
|
351
|
+
orientation: {
|
|
352
|
+
horizontal: "flex-row flex-wrap",
|
|
353
|
+
vertical: "flex-col"
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
defaultVariants: {
|
|
357
|
+
orientation: "horizontal"
|
|
358
|
+
}
|
|
359
|
+
}), Kt = re("", {
|
|
360
|
+
variants: {
|
|
361
|
+
orientation: {
|
|
362
|
+
horizontal: "",
|
|
363
|
+
vertical: "flex h-auto flex-col items-stretch"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
defaultVariants: {
|
|
367
|
+
orientation: "horizontal"
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
function Ht(e) {
|
|
371
|
+
return e.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("");
|
|
372
|
+
}
|
|
373
|
+
const Jt = {
|
|
374
|
+
Home: "House"
|
|
375
|
+
};
|
|
376
|
+
function Xt(e) {
|
|
377
|
+
if (!e) return null;
|
|
378
|
+
const l = Ht(e), f = Jt[l] || l;
|
|
379
|
+
return Ot[f] || null;
|
|
380
|
+
}
|
|
381
|
+
function je(e) {
|
|
382
|
+
return e.label ? e.label : Yt[e.type] || e.type;
|
|
383
|
+
}
|
|
384
|
+
function ze(e) {
|
|
385
|
+
return e.icon ? Xt(e.icon) : Bt[e.type] || null;
|
|
386
|
+
}
|
|
387
|
+
function Zt(e) {
|
|
388
|
+
return e.activeView ? e.activeView : e.defaultView ? e.defaultView : e.views?.[0]?.type;
|
|
389
|
+
}
|
|
390
|
+
const Ze = ({
|
|
391
|
+
schema: e,
|
|
392
|
+
className: l,
|
|
393
|
+
onViewChange: f,
|
|
394
|
+
...c
|
|
271
395
|
}) => {
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
396
|
+
const p = T.useMemo(() => e.storageKey ? e.storageKey : `view-switcher${e.id ? `-${e.id}` : ""}`, [e.id, e.storageKey]), [m, S] = T.useState(() => Zt(e));
|
|
397
|
+
T.useEffect(() => {
|
|
398
|
+
if (e.activeView) {
|
|
399
|
+
S(e.activeView);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (e.persistPreference)
|
|
275
403
|
try {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
404
|
+
const o = localStorage.getItem(p);
|
|
405
|
+
if (o) {
|
|
406
|
+
const g = e.views.find((P) => P.type === o)?.type;
|
|
407
|
+
g && S(g);
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
280
410
|
}
|
|
411
|
+
}, [e.activeView, e.persistPreference, e.views, p]), T.useEffect(() => {
|
|
412
|
+
if (!(!e.persistPreference || !m || e.activeView))
|
|
413
|
+
try {
|
|
414
|
+
localStorage.setItem(p, m);
|
|
415
|
+
} catch {
|
|
416
|
+
}
|
|
417
|
+
}, [m, e.activeView, e.persistPreference, p]);
|
|
418
|
+
const b = T.useCallback((o) => {
|
|
419
|
+
f?.(o), e.onViewChange && typeof window < "u" && window.dispatchEvent(
|
|
420
|
+
new CustomEvent(e.onViewChange, {
|
|
421
|
+
detail: { view: o }
|
|
422
|
+
})
|
|
423
|
+
);
|
|
424
|
+
}, [f, e.onViewChange]), V = T.useCallback((o) => {
|
|
425
|
+
S(o), b(o);
|
|
426
|
+
}, [b]), N = m || e.views?.[0]?.type, j = N || "", i = e.views.find((o) => o.type === N) || e.views?.[0], h = e.variant || "tabs", v = e.position || "top", C = v === "left" || v === "right", s = C ? "vertical" : "horizontal", _ = /* @__PURE__ */ t.jsxs("div", { className: A(qt({ orientation: s })), children: [
|
|
427
|
+
h === "dropdown" && /* @__PURE__ */ t.jsxs(be, { value: j, onValueChange: (o) => V(o), children: [
|
|
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((o, g) => /* @__PURE__ */ t.jsx(ce, { value: o.type, children: je(o) }, `${o.type}-${g}`)) })
|
|
430
|
+
] }),
|
|
431
|
+
h === "buttons" && /* @__PURE__ */ t.jsx("div", { className: A(Gt({ orientation: s })), children: e.views.map((o, g) => {
|
|
432
|
+
const P = o.type === N, X = ze(o);
|
|
433
|
+
return /* @__PURE__ */ t.jsxs(
|
|
434
|
+
G,
|
|
435
|
+
{
|
|
436
|
+
type: "button",
|
|
437
|
+
size: "sm",
|
|
438
|
+
variant: P ? "secondary" : "ghost",
|
|
439
|
+
className: A("justify-start gap-2", C ? "w-full" : ""),
|
|
440
|
+
onClick: () => V(o.type),
|
|
441
|
+
children: [
|
|
442
|
+
X ? /* @__PURE__ */ t.jsx(X, { className: "h-4 w-4" }) : null,
|
|
443
|
+
/* @__PURE__ */ t.jsx("span", { children: je(o) })
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
`${o.type}-${g}`
|
|
447
|
+
);
|
|
448
|
+
}) }),
|
|
449
|
+
h === "tabs" && /* @__PURE__ */ t.jsx(Ye, { value: j, onValueChange: (o) => V(o), children: /* @__PURE__ */ t.jsx(Be, { className: A(Kt({ orientation: s })), children: e.views.map((o, g) => {
|
|
450
|
+
const P = ze(o);
|
|
451
|
+
return /* @__PURE__ */ t.jsxs(
|
|
452
|
+
We,
|
|
453
|
+
{
|
|
454
|
+
value: o.type,
|
|
455
|
+
className: A("gap-2", C ? "justify-start" : ""),
|
|
456
|
+
children: [
|
|
457
|
+
P ? /* @__PURE__ */ t.jsx(P, { className: "h-4 w-4" }) : null,
|
|
458
|
+
/* @__PURE__ */ t.jsx("span", { children: je(o) })
|
|
459
|
+
]
|
|
460
|
+
},
|
|
461
|
+
`${o.type}-${g}`
|
|
462
|
+
);
|
|
463
|
+
}) }) })
|
|
464
|
+
] }), R = i?.schema ? Array.isArray(i.schema) ? /* @__PURE__ */ t.jsx("div", { className: "space-y-4", children: i.schema.map((o, g) => /* @__PURE__ */ t.jsx(Oe, { schema: o, ...c }, `${i.type}-${g}`)) }) : /* @__PURE__ */ t.jsx(Oe, { schema: i.schema, ...c }) : null;
|
|
465
|
+
return /* @__PURE__ */ t.jsxs(
|
|
466
|
+
"div",
|
|
467
|
+
{
|
|
468
|
+
className: A(
|
|
469
|
+
Wt({ position: v }),
|
|
470
|
+
l
|
|
471
|
+
),
|
|
472
|
+
children: [
|
|
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: R })
|
|
475
|
+
]
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
};
|
|
479
|
+
let me = null;
|
|
480
|
+
try {
|
|
481
|
+
me = require("@object-ui/react").SchemaRenderer || null;
|
|
482
|
+
} catch {
|
|
483
|
+
}
|
|
484
|
+
const Qt = ({
|
|
485
|
+
schema: e,
|
|
486
|
+
dataSource: l,
|
|
487
|
+
className: f,
|
|
488
|
+
views: c,
|
|
489
|
+
activeViewId: p,
|
|
490
|
+
onViewChange: m,
|
|
491
|
+
onRowClick: S,
|
|
492
|
+
onEdit: b,
|
|
493
|
+
renderListView: V,
|
|
494
|
+
toolbarAddon: N
|
|
495
|
+
}) => {
|
|
496
|
+
const [j, i] = B(null), [h, v] = B(!1), [C, s] = B("create"), [_, R] = B(null), [o, g] = B(0), [P, X] = B([]), [ge, de] = B(!1), [$, ue] = B({}), [U, Se] = B([]), I = e.listViews, Z = I != null && Object.keys(I).length > 0, [K, ne] = B(() => e.defaultListView && I?.[e.defaultListView] ? e.defaultListView : I && Object.keys(I)[0] || ""), F = W(() => !Z || !K ? null : I[K] || null, [Z, K, I]), D = W(() => c && c.length > 0 ? c : null, [c]), le = D != null && D.length > 0, fe = p || D?.[0]?.id, x = D?.find((n) => n.id === fe) || D?.[0], r = W(() => F?.type ? F.type : x?.type ? x.type : e.defaultViewType || "grid", [F, x, e.defaultViewType]), u = e.navigation;
|
|
497
|
+
Re(() => {
|
|
498
|
+
let n = !0;
|
|
499
|
+
const d = async () => {
|
|
500
|
+
try {
|
|
501
|
+
const a = await l.getObjectSchema(e.objectName);
|
|
502
|
+
n && i(a);
|
|
503
|
+
} catch (a) {
|
|
504
|
+
console.error("Failed to fetch object schema:", a);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
return e.objectName && l && d(), () => {
|
|
508
|
+
n = !1;
|
|
509
|
+
};
|
|
510
|
+
}, [e.objectName, l]), Re(() => {
|
|
511
|
+
let n = !0;
|
|
512
|
+
return (async () => {
|
|
513
|
+
if (!(r === "grid" && !V) && !(!l || !e.objectName)) {
|
|
514
|
+
de(!0);
|
|
515
|
+
try {
|
|
516
|
+
const a = F?.filter || x?.filter || e.table?.defaultFilters || [], M = Object.entries($).filter(([, L]) => L !== void 0 && L !== "" && L !== null).map(([L, J]) => [L, "=", J]);
|
|
517
|
+
let O = [];
|
|
518
|
+
a.length > 0 && M.length > 0 ? O = ["and", ...a, ...M] : M.length === 1 ? O = M[0] : M.length > 1 ? O = ["and", ...M] : O = a;
|
|
519
|
+
const H = U.length > 0 ? U.map((L) => ({ field: L.field, order: L.direction })) : F?.sort || x?.sort || e.table?.defaultSort || void 0, k = await l.find(e.objectName, {
|
|
520
|
+
$filter: O.length > 0 ? O : void 0,
|
|
521
|
+
$orderby: H,
|
|
522
|
+
$top: 100
|
|
523
|
+
});
|
|
524
|
+
let Y = [];
|
|
525
|
+
Array.isArray(k) ? Y = k : k && typeof k == "object" && (Array.isArray(k.data) ? Y = k.data : Array.isArray(k.value) && (Y = k.value)), n && X(Y);
|
|
526
|
+
} catch (a) {
|
|
527
|
+
console.error("ObjectView data fetch error:", a);
|
|
528
|
+
} finally {
|
|
529
|
+
n && de(!1);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
})(), () => {
|
|
533
|
+
n = !1;
|
|
281
534
|
};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const p = r.layout || "drawer", w = r.operations || r.table?.operations || {
|
|
535
|
+
}, [e.objectName, l, r, $, U, o, F, x, V]);
|
|
536
|
+
const w = e.layout || "drawer", y = e.operations || e.table?.operations || {
|
|
285
537
|
create: !0,
|
|
286
538
|
read: !0,
|
|
287
539
|
update: !0,
|
|
288
540
|
delete: !0
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
}, [
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
|
|
541
|
+
}, Q = z(() => {
|
|
542
|
+
w === "page" && e.onNavigate ? e.onNavigate("new", "edit") : (s("create"), R(null), v(!0));
|
|
543
|
+
}, [w, e]), ee = z((n) => {
|
|
544
|
+
if (b) {
|
|
545
|
+
b(n);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (w === "page" && e.onNavigate) {
|
|
549
|
+
const d = n._id || n.id;
|
|
550
|
+
e.onNavigate(d, "edit");
|
|
295
551
|
} else
|
|
296
|
-
|
|
297
|
-
}, [
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
|
|
552
|
+
s("edit"), R(n), v(!0);
|
|
553
|
+
}, [w, e, b]), E = z((n) => {
|
|
554
|
+
if (w === "page" && e.onNavigate) {
|
|
555
|
+
const d = n._id || n.id;
|
|
556
|
+
e.onNavigate(d, "view");
|
|
301
557
|
} else
|
|
302
|
-
|
|
303
|
-
}, [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
558
|
+
s("view"), R(n), v(!0);
|
|
559
|
+
}, [w, e]), q = z((n) => {
|
|
560
|
+
if (S) {
|
|
561
|
+
S(n);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (u) {
|
|
565
|
+
if (u.mode === "none" || u.preventNavigation)
|
|
566
|
+
return;
|
|
567
|
+
if (u.mode === "new_window" || u.openNewTab) {
|
|
568
|
+
const d = n._id || n.id, a = `/${e.objectName}/${d}`;
|
|
569
|
+
window.open(a, "_blank");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (u.mode === "drawer") {
|
|
573
|
+
s("view"), R(n), v(!0);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (u.mode === "modal") {
|
|
577
|
+
s("view"), R(n), v(!0);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (u.mode === "page") {
|
|
581
|
+
const d = n._id || n.id;
|
|
582
|
+
e.onNavigate && e.onNavigate(d, "view");
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
y.read !== !1 && E(n);
|
|
587
|
+
}, [S, u, y.read, E, e]), ae = z((n) => {
|
|
588
|
+
g((d) => d + 1);
|
|
589
|
+
}, []), xe = z((n) => {
|
|
590
|
+
g((d) => d + 1);
|
|
591
|
+
}, []), tt = z(() => {
|
|
592
|
+
v(!1), R(null), g((n) => n + 1);
|
|
593
|
+
}, []), rt = z(() => {
|
|
594
|
+
v(!1), R(null);
|
|
595
|
+
}, []);
|
|
596
|
+
z(() => {
|
|
597
|
+
g((n) => n + 1);
|
|
598
|
+
}, []);
|
|
599
|
+
const Fe = W(() => !le || !D || D.length <= 1 ? null : {
|
|
600
|
+
type: "view-switcher",
|
|
601
|
+
variant: "tabs",
|
|
602
|
+
position: "top",
|
|
603
|
+
persistPreference: !0,
|
|
604
|
+
storageKey: `view-pref-${e.objectName}`,
|
|
605
|
+
defaultView: x?.type || "grid",
|
|
606
|
+
activeView: x?.type || "grid",
|
|
607
|
+
views: D.map((n) => {
|
|
608
|
+
const d = {
|
|
609
|
+
kanban: "kanban",
|
|
610
|
+
calendar: "calendar",
|
|
611
|
+
map: "map",
|
|
612
|
+
gallery: "layout-grid",
|
|
613
|
+
timeline: "activity",
|
|
614
|
+
gantt: "gantt-chart",
|
|
615
|
+
grid: "table",
|
|
616
|
+
list: "list",
|
|
617
|
+
detail: "file-text"
|
|
618
|
+
};
|
|
619
|
+
return {
|
|
620
|
+
type: n.type,
|
|
621
|
+
label: n.label,
|
|
622
|
+
icon: d[n.type] || "table"
|
|
623
|
+
};
|
|
624
|
+
})
|
|
625
|
+
}, [le, D, x, e.objectName]), nt = z((n) => {
|
|
626
|
+
if (!D) return;
|
|
627
|
+
const d = D.find((a) => a.type === n);
|
|
628
|
+
d && m && m(d.id);
|
|
629
|
+
}, [D, m]), lt = z((n) => {
|
|
630
|
+
ne(n);
|
|
631
|
+
}, []);
|
|
632
|
+
W(() => {
|
|
633
|
+
if (e.showFilters === !1) return null;
|
|
634
|
+
const n = e.filterableFields, d = j?.fields || {}, M = (n ? n.map((O) => [O, d[O] || { label: O }]) : Object.entries(d).filter(([, O]) => !O.hidden).slice(0, 8)).map(([O, H]) => {
|
|
635
|
+
const k = H.type || "text";
|
|
636
|
+
let Y = "text", L;
|
|
637
|
+
return k === "number" || k === "currency" || k === "percent" ? Y = "number" : k === "boolean" || k === "toggle" ? Y = "boolean" : k === "date" || k === "datetime" ? Y = "date" : (k === "select" || H.options) && (Y = "select", L = (H.options || []).map(
|
|
638
|
+
(J) => typeof J == "string" ? { label: J, value: J } : { label: J.label, value: J.value }
|
|
639
|
+
)), {
|
|
640
|
+
field: O,
|
|
641
|
+
label: H.label || O,
|
|
642
|
+
type: Y,
|
|
643
|
+
placeholder: `Filter ${H.label || O}...`,
|
|
644
|
+
...L ? { options: L } : {}
|
|
645
|
+
};
|
|
646
|
+
});
|
|
647
|
+
return M.length === 0 ? null : {
|
|
648
|
+
type: "filter-ui",
|
|
649
|
+
layout: "popover",
|
|
650
|
+
showClear: !0,
|
|
651
|
+
showApply: !0,
|
|
652
|
+
filters: M,
|
|
653
|
+
values: $
|
|
654
|
+
};
|
|
655
|
+
}, [e.showFilters, e.filterableFields, j, $]), W(() => {
|
|
656
|
+
const n = j?.fields || {}, d = Object.entries(n).filter(([, a]) => !a.hidden).slice(0, 10).map(([a, M]) => ({ field: a, label: M.label || a }));
|
|
657
|
+
return d.length === 0 ? null : {
|
|
658
|
+
type: "sort-ui",
|
|
659
|
+
variant: "dropdown",
|
|
660
|
+
multiple: !1,
|
|
661
|
+
fields: d,
|
|
662
|
+
sort: U
|
|
663
|
+
};
|
|
664
|
+
}, [j, U]);
|
|
665
|
+
const at = z((n) => {
|
|
666
|
+
const d = {
|
|
667
|
+
objectName: e.objectName,
|
|
668
|
+
fields: F?.columns || x?.columns || e.table?.fields,
|
|
669
|
+
className: "h-full w-full",
|
|
670
|
+
showSearch: !1
|
|
671
|
+
}, a = F?.options || x || {};
|
|
672
|
+
switch (n) {
|
|
673
|
+
case "kanban":
|
|
674
|
+
return {
|
|
675
|
+
type: "object-kanban",
|
|
676
|
+
...d,
|
|
677
|
+
groupBy: a.kanban?.groupField || a.groupBy || a.groupField || "status",
|
|
678
|
+
groupField: a.kanban?.groupField || a.groupField || "status",
|
|
679
|
+
titleField: a.kanban?.titleField || a.titleField || "name",
|
|
680
|
+
cardFields: d.fields || [],
|
|
681
|
+
...a.kanban || {}
|
|
682
|
+
};
|
|
683
|
+
case "calendar":
|
|
684
|
+
return {
|
|
685
|
+
type: "object-calendar",
|
|
686
|
+
...d,
|
|
687
|
+
startDateField: a.calendar?.startDateField || a.startDateField || "start_date",
|
|
688
|
+
endDateField: a.calendar?.endDateField || a.endDateField || "end_date",
|
|
689
|
+
titleField: a.calendar?.titleField || a.titleField || "name",
|
|
690
|
+
...a.calendar || {}
|
|
691
|
+
};
|
|
692
|
+
case "gallery":
|
|
693
|
+
return {
|
|
694
|
+
type: "object-gallery",
|
|
695
|
+
...d,
|
|
696
|
+
imageField: a.gallery?.imageField || a.imageField,
|
|
697
|
+
titleField: a.gallery?.titleField || a.titleField || "name",
|
|
698
|
+
subtitleField: a.gallery?.subtitleField || a.subtitleField,
|
|
699
|
+
...a.gallery || {}
|
|
700
|
+
};
|
|
701
|
+
case "timeline":
|
|
702
|
+
return {
|
|
703
|
+
type: "object-timeline",
|
|
704
|
+
...d,
|
|
705
|
+
dateField: a.timeline?.dateField || a.dateField || "created_at",
|
|
706
|
+
titleField: a.timeline?.titleField || a.titleField || "name",
|
|
707
|
+
...a.timeline || {}
|
|
708
|
+
};
|
|
709
|
+
case "gantt":
|
|
710
|
+
return {
|
|
711
|
+
type: "object-gantt",
|
|
712
|
+
...d,
|
|
713
|
+
startDateField: a.gantt?.startDateField || a.startDateField || "start_date",
|
|
714
|
+
endDateField: a.gantt?.endDateField || a.endDateField || "end_date",
|
|
715
|
+
progressField: a.gantt?.progressField || a.progressField || "progress",
|
|
716
|
+
dependenciesField: a.gantt?.dependenciesField || a.dependenciesField || "dependencies",
|
|
717
|
+
...a.gantt || {}
|
|
718
|
+
};
|
|
719
|
+
case "map":
|
|
720
|
+
return {
|
|
721
|
+
type: "object-map",
|
|
722
|
+
...d,
|
|
723
|
+
locationField: a.map?.locationField || a.locationField || "location",
|
|
724
|
+
...a.map || {}
|
|
725
|
+
};
|
|
726
|
+
default:
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
}, [e.objectName, e.table?.fields, F, x]), it = W(() => ({
|
|
316
730
|
type: "object-grid",
|
|
317
|
-
objectName:
|
|
318
|
-
title:
|
|
319
|
-
description:
|
|
320
|
-
fields:
|
|
321
|
-
columns:
|
|
731
|
+
objectName: e.objectName,
|
|
732
|
+
title: e.table?.title,
|
|
733
|
+
description: e.table?.description,
|
|
734
|
+
fields: F?.columns || x?.columns || e.table?.fields,
|
|
735
|
+
columns: F?.columns || x?.columns || e.table?.columns,
|
|
322
736
|
operations: {
|
|
323
|
-
...
|
|
737
|
+
...y,
|
|
324
738
|
create: !1
|
|
325
739
|
// Create is handled by the view's create button
|
|
326
740
|
},
|
|
327
|
-
defaultFilters:
|
|
328
|
-
defaultSort:
|
|
329
|
-
pageSize:
|
|
330
|
-
selectable:
|
|
331
|
-
className:
|
|
332
|
-
},
|
|
333
|
-
const n =
|
|
741
|
+
defaultFilters: F?.filter || x?.filter || e.table?.defaultFilters,
|
|
742
|
+
defaultSort: F?.sort || x?.sort || e.table?.defaultSort,
|
|
743
|
+
pageSize: e.table?.pageSize,
|
|
744
|
+
selectable: e.table?.selectable,
|
|
745
|
+
className: e.table?.className
|
|
746
|
+
}), [e, y, F, x]), Ve = () => {
|
|
747
|
+
const n = _ ? _._id || _.id : void 0;
|
|
334
748
|
return {
|
|
335
749
|
type: "object-form",
|
|
336
|
-
objectName:
|
|
337
|
-
mode:
|
|
750
|
+
objectName: e.objectName,
|
|
751
|
+
mode: C,
|
|
338
752
|
recordId: n,
|
|
339
|
-
title:
|
|
340
|
-
description:
|
|
341
|
-
fields:
|
|
342
|
-
customFields:
|
|
343
|
-
groups:
|
|
344
|
-
layout:
|
|
345
|
-
columns:
|
|
346
|
-
showSubmit:
|
|
347
|
-
submitText:
|
|
348
|
-
showCancel:
|
|
349
|
-
cancelText:
|
|
350
|
-
showReset:
|
|
351
|
-
initialValues:
|
|
352
|
-
readOnly:
|
|
353
|
-
className:
|
|
354
|
-
onSuccess:
|
|
355
|
-
onCancel:
|
|
753
|
+
title: e.form?.title,
|
|
754
|
+
description: e.form?.description,
|
|
755
|
+
fields: e.form?.fields,
|
|
756
|
+
customFields: e.form?.customFields,
|
|
757
|
+
groups: e.form?.groups,
|
|
758
|
+
layout: e.form?.layout,
|
|
759
|
+
columns: e.form?.columns,
|
|
760
|
+
showSubmit: e.form?.showSubmit,
|
|
761
|
+
submitText: e.form?.submitText,
|
|
762
|
+
showCancel: e.form?.showCancel,
|
|
763
|
+
cancelText: e.form?.cancelText,
|
|
764
|
+
showReset: e.form?.showReset,
|
|
765
|
+
initialValues: e.form?.initialValues,
|
|
766
|
+
readOnly: e.form?.readOnly || C === "view",
|
|
767
|
+
className: e.form?.className,
|
|
768
|
+
onSuccess: tt,
|
|
769
|
+
onCancel: rt
|
|
356
770
|
};
|
|
357
|
-
},
|
|
358
|
-
if (
|
|
359
|
-
const n =
|
|
360
|
-
switch (
|
|
771
|
+
}, Ee = () => {
|
|
772
|
+
if (e.form?.title) return e.form.title;
|
|
773
|
+
const n = j?.label || e.objectName;
|
|
774
|
+
switch (C) {
|
|
361
775
|
case "create":
|
|
362
776
|
return `Create ${n}`;
|
|
363
777
|
case "edit":
|
|
@@ -367,128 +781,533 @@ const ye = ({
|
|
|
367
781
|
default:
|
|
368
782
|
return n;
|
|
369
783
|
}
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
784
|
+
}, _e = W(() => {
|
|
785
|
+
const n = u?.width;
|
|
786
|
+
return n ? typeof n == "number" ? `max-w-[${n}px]` : `max-w-[${n}]` : "";
|
|
787
|
+
}, [u]), 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
|
+
/* @__PURE__ */ t.jsxs(Ke, { children: [
|
|
789
|
+
/* @__PURE__ */ t.jsx(He, { children: Ee() }),
|
|
790
|
+
e.form?.description && /* @__PURE__ */ t.jsx(Je, { children: e.form.description })
|
|
374
791
|
] }),
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
) })
|
|
382
|
-
] }) }), Y = () => /* @__PURE__ */ o.jsx(pe, { open: f, onOpenChange: d, children: /* @__PURE__ */ o.jsxs(be, { className: "max-w-2xl max-h-[90vh] overflow-y-auto", children: [
|
|
383
|
-
/* @__PURE__ */ o.jsxs(ve, { children: [
|
|
384
|
-
/* @__PURE__ */ o.jsx(we, { children: I() }),
|
|
385
|
-
r.form?.description && /* @__PURE__ */ o.jsx(xe, { children: r.form.description })
|
|
792
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-1 overflow-y-auto px-4 pb-4", children: /* @__PURE__ */ t.jsx(ke, { schema: Ve(), dataSource: l }) })
|
|
793
|
+
] }) }), 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
|
+
/* @__PURE__ */ t.jsxs(yt, { children: [
|
|
795
|
+
/* @__PURE__ */ t.jsx(gt, { children: Ee() }),
|
|
796
|
+
e.form?.description && /* @__PURE__ */ t.jsx(xt, { children: e.form.description })
|
|
386
797
|
] }),
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
|
|
798
|
+
/* @__PURE__ */ t.jsx(ke, { schema: Ve(), dataSource: l })
|
|
799
|
+
] }) }), ct = W(() => Object.keys($).some(
|
|
800
|
+
(d) => $[d] !== void 0 && $[d] !== "" && $[d] !== null
|
|
801
|
+
) ? Object.entries($).filter(([, d]) => d !== void 0 && d !== "" && d !== null).map(([d, a]) => ({ field: d, operator: "equals", value: a })) : F?.filter || x?.filter || e.table?.defaultFilters, [$, F, x, e.table?.defaultFilters]), dt = W(() => U.length > 0 ? U : F?.sort || x?.sort || e.table?.defaultSort, [U, F, x, e.table?.defaultSort]), ut = () => {
|
|
802
|
+
const n = `${e.objectName}-${K || x?.id || "default"}-${r}-${o}`;
|
|
803
|
+
if (V)
|
|
804
|
+
return V({
|
|
805
|
+
schema: {
|
|
806
|
+
type: "list-view",
|
|
807
|
+
objectName: e.objectName,
|
|
808
|
+
viewType: r,
|
|
809
|
+
fields: F?.columns || x?.columns || e.table?.fields,
|
|
810
|
+
filters: ct,
|
|
811
|
+
sort: dt,
|
|
812
|
+
options: F?.options || x
|
|
813
|
+
},
|
|
814
|
+
dataSource: l,
|
|
815
|
+
onEdit: ee,
|
|
816
|
+
onRowClick: q,
|
|
817
|
+
className: "h-full"
|
|
818
|
+
});
|
|
819
|
+
if (r !== "grid") {
|
|
820
|
+
const d = at(r);
|
|
821
|
+
if (d && me)
|
|
822
|
+
return /* @__PURE__ */ t.jsx(
|
|
823
|
+
me,
|
|
824
|
+
{
|
|
825
|
+
schema: d,
|
|
826
|
+
dataSource: l,
|
|
827
|
+
data: P,
|
|
828
|
+
loading: ge
|
|
829
|
+
},
|
|
830
|
+
n
|
|
831
|
+
);
|
|
832
|
+
if (!me)
|
|
833
|
+
return /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center h-40 text-muted-foreground", children: /* @__PURE__ */ t.jsxs("p", { children: [
|
|
834
|
+
"SchemaRenderer not available. Install @object-ui/react to render ",
|
|
835
|
+
r,
|
|
836
|
+
" views."
|
|
837
|
+
] }) });
|
|
838
|
+
}
|
|
839
|
+
return /* @__PURE__ */ t.jsx(
|
|
840
|
+
bt,
|
|
389
841
|
{
|
|
390
|
-
schema:
|
|
391
|
-
dataSource:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
842
|
+
schema: it,
|
|
843
|
+
dataSource: l,
|
|
844
|
+
onRowClick: q,
|
|
845
|
+
onEdit: y.update !== !1 ? ee : void 0,
|
|
846
|
+
onDelete: y.delete !== !1 ? ae : void 0,
|
|
847
|
+
onBulkDelete: y.delete !== !1 ? xe : void 0
|
|
848
|
+
},
|
|
849
|
+
n
|
|
850
|
+
);
|
|
851
|
+
}, ft = () => {
|
|
852
|
+
if (!Z) return null;
|
|
853
|
+
const n = Object.entries(I);
|
|
854
|
+
return n.length <= 1 ? null : /* @__PURE__ */ t.jsx(Ye, { value: K, onValueChange: lt, className: "w-full", children: /* @__PURE__ */ t.jsx(Be, { className: "w-auto", children: n.map(([d, a]) => /* @__PURE__ */ t.jsx(We, { value: d, className: "text-sm", children: a.label || d }, d)) }) });
|
|
855
|
+
}, pt = () => {
|
|
856
|
+
const n = e.showCreate !== !1 && y.create !== !1, d = e.showViewSwitcher === !0, a = ft();
|
|
857
|
+
return !a && !d && !n && !N ? null : /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
858
|
+
a,
|
|
859
|
+
(d || n || N) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
860
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex items-center gap-2", children: d && Fe && /* @__PURE__ */ t.jsx(
|
|
861
|
+
Ze,
|
|
862
|
+
{
|
|
863
|
+
schema: Fe,
|
|
864
|
+
onViewChange: nt,
|
|
865
|
+
className: "overflow-x-auto"
|
|
866
|
+
}
|
|
867
|
+
) }),
|
|
868
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
869
|
+
N,
|
|
870
|
+
n && /* @__PURE__ */ t.jsxs(G, { size: "sm", onClick: Q, children: [
|
|
871
|
+
/* @__PURE__ */ t.jsx(Dt, { className: "h-4 w-4" }),
|
|
872
|
+
"Create"
|
|
873
|
+
] })
|
|
874
|
+
] })
|
|
875
|
+
] })
|
|
876
|
+
] });
|
|
877
|
+
}, Te = u?.mode === "modal" ? "modal" : u?.mode === "drawer" ? "drawer" : w;
|
|
878
|
+
return /* @__PURE__ */ t.jsxs("div", { className: A("flex flex-col h-full", f), children: [
|
|
879
|
+
(e.title || e.description) && /* @__PURE__ */ t.jsxs("div", { className: "mb-4 shrink-0", children: [
|
|
880
|
+
e.title && /* @__PURE__ */ t.jsx("h2", { className: "text-2xl font-bold tracking-tight", children: e.title }),
|
|
881
|
+
e.description && /* @__PURE__ */ t.jsx("p", { className: "text-muted-foreground mt-1", children: e.description })
|
|
882
|
+
] }),
|
|
883
|
+
/* @__PURE__ */ t.jsx("div", { className: "mb-4 shrink-0", children: pt() }),
|
|
884
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-1 min-h-0", children: ut() }),
|
|
885
|
+
Te === "drawer" && st(),
|
|
886
|
+
Te === "modal" && ot()
|
|
887
|
+
] });
|
|
888
|
+
}, he = re("flex", {
|
|
889
|
+
variants: {
|
|
890
|
+
layout: {
|
|
891
|
+
inline: "flex-col space-y-4",
|
|
892
|
+
popover: "items-center",
|
|
893
|
+
drawer: "items-center"
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
defaultVariants: {
|
|
897
|
+
layout: "inline"
|
|
898
|
+
}
|
|
899
|
+
}), er = (e) => e == null || e === "" ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.values(e).every((l) => l == null || l === "") : !1, tr = (e) => Array.isArray(e) ? { start: e[0] || "", end: e[1] || "" } : e && typeof e == "object" ? { start: e.start || "", end: e.end || "" } : { start: "", end: "" }, rr = ({
|
|
900
|
+
schema: e,
|
|
901
|
+
className: l,
|
|
902
|
+
onChange: f
|
|
903
|
+
}) => {
|
|
904
|
+
const [c, p] = T.useState(e.values || {}), [m, S] = T.useState(!1);
|
|
905
|
+
T.useEffect(() => {
|
|
906
|
+
e.values && p(e.values);
|
|
907
|
+
}, [e.values]);
|
|
908
|
+
const b = T.useCallback((s) => {
|
|
909
|
+
f?.(s), e.onChange && typeof window < "u" && window.dispatchEvent(
|
|
910
|
+
new CustomEvent(e.onChange, {
|
|
911
|
+
detail: { values: s }
|
|
912
|
+
})
|
|
913
|
+
);
|
|
914
|
+
}, [f, e.onChange]), V = T.useCallback((s, _) => {
|
|
915
|
+
const R = { ...c, [s]: _ };
|
|
916
|
+
p(R), e.showApply || b(R);
|
|
917
|
+
}, [b, e.showApply, c]), N = T.useCallback(() => {
|
|
918
|
+
const s = {};
|
|
919
|
+
if (p(s), e.showApply) {
|
|
920
|
+
b(s);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
b(s);
|
|
924
|
+
}, [b, e.showApply]), j = T.useCallback(() => {
|
|
925
|
+
b(c), S(!1);
|
|
926
|
+
}, [b, c]), i = T.useMemo(() => Object.values(c).filter((s) => !er(s)).length, [c]), h = (s) => {
|
|
927
|
+
const _ = s.label || s.field, R = s.placeholder || `Filter by ${_}`;
|
|
928
|
+
switch (s.type) {
|
|
929
|
+
case "number":
|
|
930
|
+
return /* @__PURE__ */ t.jsx(
|
|
931
|
+
ie,
|
|
932
|
+
{
|
|
933
|
+
type: "number",
|
|
934
|
+
value: c[s.field] ?? "",
|
|
935
|
+
placeholder: R,
|
|
936
|
+
onChange: (o) => {
|
|
937
|
+
const g = o.target.value, P = g === "" ? "" : Number(g);
|
|
938
|
+
V(s.field, P);
|
|
408
939
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
940
|
+
}
|
|
941
|
+
);
|
|
942
|
+
case "select":
|
|
943
|
+
return /* @__PURE__ */ t.jsxs(
|
|
944
|
+
be,
|
|
945
|
+
{
|
|
946
|
+
value: c[s.field] !== void 0 ? String(c[s.field]) : "",
|
|
947
|
+
onValueChange: (o) => {
|
|
948
|
+
const g = s.options?.find((P) => String(P.value) === o);
|
|
949
|
+
V(s.field, g ? g.value : o);
|
|
950
|
+
},
|
|
951
|
+
children: [
|
|
952
|
+
/* @__PURE__ */ t.jsx(we, { children: /* @__PURE__ */ t.jsx(ve, { placeholder: R }) }),
|
|
953
|
+
/* @__PURE__ */ t.jsx(ye, { children: s.options?.map((o) => /* @__PURE__ */ t.jsx(ce, { value: String(o.value), children: o.label }, String(o.value))) })
|
|
954
|
+
]
|
|
955
|
+
}
|
|
956
|
+
);
|
|
957
|
+
case "date":
|
|
958
|
+
return /* @__PURE__ */ t.jsx(
|
|
959
|
+
ie,
|
|
960
|
+
{
|
|
961
|
+
type: "date",
|
|
962
|
+
value: c[s.field] ?? "",
|
|
963
|
+
onChange: (o) => V(s.field, o.target.value)
|
|
964
|
+
}
|
|
965
|
+
);
|
|
966
|
+
case "date-range": {
|
|
967
|
+
const o = tr(c[s.field]);
|
|
968
|
+
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
969
|
+
/* @__PURE__ */ t.jsx(
|
|
970
|
+
ie,
|
|
414
971
|
{
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
"Filters",
|
|
421
|
-
R && /* @__PURE__ */ o.jsx(_e, { className: "h-3 w-3 ml-1" })
|
|
422
|
-
]
|
|
972
|
+
type: "date",
|
|
973
|
+
value: o.start ?? "",
|
|
974
|
+
onChange: (g) => {
|
|
975
|
+
V(s.field, { ...o, start: g.target.value });
|
|
976
|
+
}
|
|
423
977
|
}
|
|
424
978
|
),
|
|
425
|
-
|
|
426
|
-
|
|
979
|
+
/* @__PURE__ */ t.jsx(
|
|
980
|
+
ie,
|
|
427
981
|
{
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
982
|
+
type: "date",
|
|
983
|
+
value: o.end ?? "",
|
|
984
|
+
onChange: (g) => {
|
|
985
|
+
V(s.field, { ...o, end: g.target.value });
|
|
986
|
+
}
|
|
432
987
|
}
|
|
433
|
-
)
|
|
434
|
-
|
|
435
|
-
|
|
988
|
+
)
|
|
989
|
+
] });
|
|
990
|
+
}
|
|
991
|
+
case "boolean":
|
|
992
|
+
return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
993
|
+
/* @__PURE__ */ t.jsx(
|
|
994
|
+
St,
|
|
436
995
|
{
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
children: [
|
|
440
|
-
/* @__PURE__ */ o.jsx(Ee, { className: "h-4 w-4" }),
|
|
441
|
-
"Create"
|
|
442
|
-
]
|
|
996
|
+
checked: !!c[s.field],
|
|
997
|
+
onCheckedChange: (o) => V(s.field, !!o)
|
|
443
998
|
}
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
999
|
+
),
|
|
1000
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-sm text-muted-foreground", children: "Enabled" })
|
|
1001
|
+
] });
|
|
1002
|
+
default:
|
|
1003
|
+
return /* @__PURE__ */ t.jsx(
|
|
1004
|
+
ie,
|
|
1005
|
+
{
|
|
1006
|
+
value: c[s.field] ?? "",
|
|
1007
|
+
placeholder: R,
|
|
1008
|
+
onChange: (o) => V(s.field, o.target.value)
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
}, 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((s) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
|
|
1014
|
+
/* @__PURE__ */ t.jsx(jt, { className: "text-xs text-muted-foreground", children: s.label || s.field }),
|
|
1015
|
+
h(s)
|
|
1016
|
+
] }, s.field)) }),
|
|
1017
|
+
(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(G, { type: "button", variant: "ghost", size: "sm", onClick: N, children: "Clear" }),
|
|
1019
|
+
e.showApply && /* @__PURE__ */ t.jsx(G, { type: "button", size: "sm", onClick: j, children: "Apply" })
|
|
1020
|
+
] })
|
|
1021
|
+
] }), C = e.layout || "inline";
|
|
1022
|
+
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(G, { type: "button", variant: i > 0 ? "secondary" : "outline", size: "sm", className: "gap-2", children: [
|
|
1024
|
+
/* @__PURE__ */ t.jsx(Ae, { className: "h-4 w-4" }),
|
|
1025
|
+
"Filters",
|
|
1026
|
+
i > 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: i })
|
|
1027
|
+
] }) }),
|
|
1028
|
+
/* @__PURE__ */ t.jsx(Ct, { align: "start", className: "w-[520px] p-4", children: v })
|
|
1029
|
+
] }) }) : C === "drawer" ? /* @__PURE__ */ t.jsxs("div", { className: A(he({ layout: C }), l), children: [
|
|
1030
|
+
/* @__PURE__ */ t.jsxs(G, { type: "button", variant: i > 0 ? "secondary" : "outline", size: "sm", className: "gap-2", onClick: () => S(!0), children: [
|
|
1031
|
+
/* @__PURE__ */ t.jsx(Ae, { className: "h-4 w-4" }),
|
|
1032
|
+
"Filters",
|
|
1033
|
+
i > 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: i })
|
|
454
1034
|
] }),
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1035
|
+
/* @__PURE__ */ t.jsx(qe, { open: m, onOpenChange: S, children: /* @__PURE__ */ t.jsxs(Ge, { children: [
|
|
1036
|
+
/* @__PURE__ */ t.jsxs(Ke, { children: [
|
|
1037
|
+
/* @__PURE__ */ t.jsx(He, { children: "Filters" }),
|
|
1038
|
+
/* @__PURE__ */ t.jsx(Je, { children: "Refine the data with advanced filters." })
|
|
1039
|
+
] }),
|
|
1040
|
+
/* @__PURE__ */ t.jsx("div", { className: "px-4 pb-6", children: v })
|
|
1041
|
+
] }) })
|
|
1042
|
+
] }) : /* @__PURE__ */ t.jsxs("div", { className: A(he({ layout: C }), l), children: [
|
|
1043
|
+
v,
|
|
1044
|
+
!e.showApply && e.showClear && /* @__PURE__ */ t.jsxs(G, { type: "button", variant: "ghost", size: "sm", className: "gap-2", onClick: N, children: [
|
|
1045
|
+
/* @__PURE__ */ t.jsx(Pt, { className: "h-3.5 w-3.5" }),
|
|
1046
|
+
"Clear filters"
|
|
1047
|
+
] })
|
|
1048
|
+
] });
|
|
1049
|
+
}, Ne = re("", {
|
|
1050
|
+
variants: {
|
|
1051
|
+
variant: {
|
|
1052
|
+
buttons: "flex flex-wrap gap-2",
|
|
1053
|
+
dropdown: "flex flex-wrap items-center gap-3",
|
|
1054
|
+
builder: "space-y-3"
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
defaultVariants: {
|
|
1058
|
+
variant: "dropdown"
|
|
1059
|
+
}
|
|
1060
|
+
}), Ce = (e) => e ? e.map((l) => ({
|
|
1061
|
+
field: l.field,
|
|
1062
|
+
direction: l.direction
|
|
1063
|
+
})) : [], Me = (e) => e.map((l) => ({
|
|
1064
|
+
id: `${l.field}-${l.direction}`,
|
|
1065
|
+
field: l.field,
|
|
1066
|
+
order: l.direction
|
|
1067
|
+
})), nr = (e) => e.filter((l) => l.field).map((l) => ({
|
|
1068
|
+
field: l.field,
|
|
1069
|
+
direction: l.order
|
|
1070
|
+
})), lr = ({
|
|
1071
|
+
schema: e,
|
|
1072
|
+
className: l,
|
|
1073
|
+
onChange: f
|
|
1074
|
+
}) => {
|
|
1075
|
+
const [c, p] = T.useState(() => Ce(e.sort)), [m, S] = T.useState(() => Me(Ce(e.sort)));
|
|
1076
|
+
T.useEffect(() => {
|
|
1077
|
+
const i = Ce(e.sort);
|
|
1078
|
+
p(i), S(Me(i));
|
|
1079
|
+
}, [e.sort]);
|
|
1080
|
+
const b = T.useCallback((i) => {
|
|
1081
|
+
p(i), f?.(i), e.onChange && typeof window < "u" && window.dispatchEvent(
|
|
1082
|
+
new CustomEvent(e.onChange, {
|
|
1083
|
+
detail: { sort: i }
|
|
1084
|
+
})
|
|
1085
|
+
);
|
|
1086
|
+
}, [f, e.onChange]), V = T.useCallback((i) => {
|
|
1087
|
+
const h = c.find((s) => s.field === i), v = !!e.multiple;
|
|
1088
|
+
if (!h) {
|
|
1089
|
+
const s = v ? [...c, { field: i, direction: "asc" }] : [{ field: i, direction: "asc" }];
|
|
1090
|
+
b(s);
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (h.direction === "asc") {
|
|
1094
|
+
const s = c.map(
|
|
1095
|
+
(_) => _.field === i ? { ..._, direction: "desc" } : _
|
|
1096
|
+
);
|
|
1097
|
+
b(s);
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
const C = c.filter((s) => s.field !== i);
|
|
1101
|
+
b(C);
|
|
1102
|
+
}, [b, e.multiple, c]);
|
|
1103
|
+
if ((e.variant || "dropdown") === "buttons")
|
|
1104
|
+
return /* @__PURE__ */ t.jsx("div", { className: A(Ne({ variant: "buttons" }), l), children: e.fields.map((i) => {
|
|
1105
|
+
const h = c.find((C) => C.field === i.field), v = h?.direction === "asc" ? $t : It;
|
|
1106
|
+
return /* @__PURE__ */ t.jsxs(
|
|
1107
|
+
G,
|
|
1108
|
+
{
|
|
1109
|
+
type: "button",
|
|
1110
|
+
variant: h ? "secondary" : "outline",
|
|
1111
|
+
size: "sm",
|
|
1112
|
+
onClick: () => V(i.field),
|
|
1113
|
+
className: "gap-2",
|
|
1114
|
+
children: [
|
|
1115
|
+
/* @__PURE__ */ t.jsx("span", { children: i.label || i.field }),
|
|
1116
|
+
h && /* @__PURE__ */ t.jsx(v, { className: "h-3.5 w-3.5" })
|
|
1117
|
+
]
|
|
1118
|
+
},
|
|
1119
|
+
i.field
|
|
1120
|
+
);
|
|
1121
|
+
}) });
|
|
1122
|
+
if (e.multiple)
|
|
1123
|
+
return /* @__PURE__ */ t.jsx("div", { className: A(Ne({ variant: "builder" }), l), children: /* @__PURE__ */ t.jsx(
|
|
1124
|
+
Ft,
|
|
458
1125
|
{
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1126
|
+
fields: e.fields.map((i) => ({ value: i.field, label: i.label || i.field })),
|
|
1127
|
+
value: m,
|
|
1128
|
+
onChange: (i) => {
|
|
1129
|
+
S(i), b(nr(i));
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
) });
|
|
1133
|
+
const j = c[0];
|
|
1134
|
+
return /* @__PURE__ */ t.jsxs("div", { className: A(Ne({ variant: "dropdown" }), l), children: [
|
|
1135
|
+
/* @__PURE__ */ t.jsxs(
|
|
1136
|
+
be,
|
|
1137
|
+
{
|
|
1138
|
+
value: j?.field || "",
|
|
1139
|
+
onValueChange: (i) => {
|
|
1140
|
+
if (!i) {
|
|
1141
|
+
b([]);
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
b([{ field: i, direction: j?.direction || "asc" }]);
|
|
1145
|
+
},
|
|
1146
|
+
children: [
|
|
1147
|
+
/* @__PURE__ */ t.jsx(we, { className: "w-56", children: /* @__PURE__ */ t.jsx(ve, { placeholder: "Select field" }) }),
|
|
1148
|
+
/* @__PURE__ */ t.jsx(ye, { children: e.fields.map((i) => /* @__PURE__ */ t.jsx(ce, { value: i.field, children: i.label || i.field }, i.field)) })
|
|
1149
|
+
]
|
|
1150
|
+
}
|
|
467
1151
|
),
|
|
468
|
-
|
|
469
|
-
|
|
1152
|
+
/* @__PURE__ */ t.jsxs(
|
|
1153
|
+
be,
|
|
1154
|
+
{
|
|
1155
|
+
value: j?.direction || "asc",
|
|
1156
|
+
onValueChange: (i) => {
|
|
1157
|
+
j?.field && b([{ field: j.field, direction: i }]);
|
|
1158
|
+
},
|
|
1159
|
+
children: [
|
|
1160
|
+
/* @__PURE__ */ t.jsx(we, { className: "w-36", children: /* @__PURE__ */ t.jsx(ve, {}) }),
|
|
1161
|
+
/* @__PURE__ */ t.jsxs(ye, { children: [
|
|
1162
|
+
/* @__PURE__ */ t.jsx(ce, { value: "asc", children: "Ascending" }),
|
|
1163
|
+
/* @__PURE__ */ t.jsx(ce, { value: "desc", children: "Descending" })
|
|
1164
|
+
] })
|
|
1165
|
+
]
|
|
1166
|
+
}
|
|
1167
|
+
)
|
|
470
1168
|
] });
|
|
471
|
-
},
|
|
472
|
-
|
|
473
|
-
|
|
1169
|
+
}, ar = Ue.createContext(null);
|
|
1170
|
+
let Qe = ar;
|
|
1171
|
+
try {
|
|
1172
|
+
const e = require("@object-ui/react");
|
|
1173
|
+
e.SchemaRendererContext && (Qe = e.SchemaRendererContext);
|
|
1174
|
+
} catch {
|
|
1175
|
+
}
|
|
1176
|
+
const et = ({ schema: e }) => {
|
|
1177
|
+
const f = mt(Qe)?.dataSource ?? null;
|
|
1178
|
+
return /* @__PURE__ */ t.jsx(Qt, { schema: e, dataSource: f });
|
|
1179
|
+
};
|
|
1180
|
+
te.register("object-view", et, {
|
|
1181
|
+
namespace: "plugin-view",
|
|
1182
|
+
label: "Object View",
|
|
1183
|
+
category: "view",
|
|
1184
|
+
icon: "LayoutDashboard",
|
|
1185
|
+
inputs: [
|
|
1186
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1187
|
+
{ name: "title", type: "string", label: "Title" },
|
|
1188
|
+
{ name: "description", type: "string", label: "Description" },
|
|
1189
|
+
{ name: "layout", type: "enum", label: "Form Layout", enum: ["drawer", "modal", "page"] },
|
|
1190
|
+
{ name: "defaultViewType", type: "enum", label: "Default View Type", enum: ["grid", "kanban", "gallery", "calendar", "timeline", "gantt", "map"] },
|
|
1191
|
+
{ name: "defaultListView", type: "string", label: "Default Named View" },
|
|
1192
|
+
{ name: "showSearch", type: "boolean", label: "Show Search" },
|
|
1193
|
+
{ name: "showFilters", type: "boolean", label: "Show Filters" },
|
|
1194
|
+
{ name: "showCreate", type: "boolean", label: "Show Create Button" },
|
|
1195
|
+
{ name: "showRefresh", type: "boolean", label: "Show Refresh Button" },
|
|
1196
|
+
{ name: "showViewSwitcher", type: "boolean", label: "Show View Switcher" },
|
|
1197
|
+
{ name: "listViews", type: "object", label: "Named List Views" },
|
|
1198
|
+
{ name: "navigation", type: "object", label: "Navigation Config" },
|
|
1199
|
+
{ name: "searchableFields", type: "array", label: "Searchable Fields" },
|
|
1200
|
+
{ name: "filterableFields", type: "array", label: "Filterable Fields" }
|
|
1201
|
+
],
|
|
1202
|
+
defaultProps: {
|
|
1203
|
+
layout: "drawer",
|
|
1204
|
+
defaultViewType: "grid",
|
|
1205
|
+
showSearch: !0,
|
|
1206
|
+
showFilters: !0,
|
|
1207
|
+
showCreate: !0,
|
|
1208
|
+
showRefresh: !0,
|
|
1209
|
+
showViewSwitcher: !0
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
te.register("view", et, {
|
|
1213
|
+
namespace: "plugin-view",
|
|
1214
|
+
label: "View",
|
|
1215
|
+
category: "view"
|
|
1216
|
+
});
|
|
1217
|
+
te.register("view-switcher", Ze, {
|
|
1218
|
+
namespace: "view",
|
|
1219
|
+
label: "View Switcher",
|
|
1220
|
+
category: "view",
|
|
1221
|
+
icon: "LayoutGrid",
|
|
1222
|
+
inputs: [
|
|
1223
|
+
{ name: "views", type: "array", label: "Views", required: !0 },
|
|
1224
|
+
{ name: "defaultView", type: "string", label: "Default View" },
|
|
1225
|
+
{ name: "activeView", type: "string", label: "Active View" },
|
|
1226
|
+
{ name: "variant", type: "enum", label: "Variant", enum: ["tabs", "buttons", "dropdown"] },
|
|
1227
|
+
{ name: "position", type: "enum", label: "Position", enum: ["top", "bottom", "left", "right"] },
|
|
1228
|
+
{ name: "persistPreference", type: "boolean", label: "Persist Preference" },
|
|
1229
|
+
{ name: "storageKey", type: "string", label: "Storage Key" },
|
|
1230
|
+
{ name: "onViewChange", type: "string", label: "On View Change Event" }
|
|
1231
|
+
],
|
|
1232
|
+
defaultProps: {
|
|
1233
|
+
variant: "tabs",
|
|
1234
|
+
position: "top",
|
|
1235
|
+
defaultView: "grid",
|
|
1236
|
+
views: [
|
|
1237
|
+
{ type: "grid", label: "Grid", schema: { type: "text", content: "Grid view" } },
|
|
1238
|
+
{ type: "list", label: "List", schema: { type: "text", content: "List view" } }
|
|
1239
|
+
]
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
te.register("filter-ui", rr, {
|
|
1243
|
+
namespace: "view",
|
|
1244
|
+
label: "Filter UI",
|
|
1245
|
+
category: "view",
|
|
1246
|
+
icon: "SlidersHorizontal",
|
|
1247
|
+
inputs: [
|
|
1248
|
+
{ name: "filters", type: "array", label: "Filters", required: !0 },
|
|
1249
|
+
{ name: "values", type: "object", label: "Values" },
|
|
1250
|
+
{ name: "onChange", type: "string", label: "On Change Event" },
|
|
1251
|
+
{ name: "showClear", type: "boolean", label: "Show Clear Button" },
|
|
1252
|
+
{ name: "showApply", type: "boolean", label: "Show Apply Button" },
|
|
1253
|
+
{ name: "layout", type: "enum", label: "Layout", enum: ["inline", "popover", "drawer"] }
|
|
1254
|
+
],
|
|
1255
|
+
defaultProps: {
|
|
1256
|
+
layout: "inline",
|
|
1257
|
+
showApply: !1,
|
|
1258
|
+
showClear: !0,
|
|
1259
|
+
filters: [
|
|
1260
|
+
{ field: "name", label: "Name", type: "text", placeholder: "Search name" },
|
|
1261
|
+
{ field: "status", label: "Status", type: "select", options: [
|
|
1262
|
+
{ label: "Open", value: "open" },
|
|
1263
|
+
{ label: "Closed", value: "closed" }
|
|
1264
|
+
] },
|
|
1265
|
+
{ field: "created_at", label: "Created", type: "date" }
|
|
1266
|
+
]
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
te.register("sort-ui", lr, {
|
|
1270
|
+
namespace: "view",
|
|
1271
|
+
label: "Sort UI",
|
|
1272
|
+
category: "view",
|
|
1273
|
+
icon: "ArrowUpDown",
|
|
1274
|
+
inputs: [
|
|
1275
|
+
{ name: "fields", type: "array", label: "Fields", required: !0 },
|
|
1276
|
+
{ name: "sort", type: "array", label: "Sort" },
|
|
1277
|
+
{ name: "onChange", type: "string", label: "On Change Event" },
|
|
1278
|
+
{ name: "multiple", type: "boolean", label: "Allow Multiple" },
|
|
1279
|
+
{ name: "variant", type: "enum", label: "Variant", enum: ["dropdown", "buttons"] }
|
|
1280
|
+
],
|
|
1281
|
+
defaultProps: {
|
|
1282
|
+
variant: "dropdown",
|
|
1283
|
+
multiple: !0,
|
|
1284
|
+
fields: [
|
|
1285
|
+
{ field: "name", label: "Name" },
|
|
1286
|
+
{ field: "created_at", label: "Created At" }
|
|
1287
|
+
],
|
|
1288
|
+
sort: [{ field: "name", direction: "asc" }]
|
|
1289
|
+
}
|
|
474
1290
|
});
|
|
475
|
-
const
|
|
476
|
-
const
|
|
477
|
-
return /* @__PURE__ */
|
|
1291
|
+
const ir = ({ schema: e, className: l, children: f, dataSource: c, ...p }) => {
|
|
1292
|
+
const m = e.props?.columns ? { display: "grid", gridTemplateColumns: `repeat(${e.props.columns}, 1fr)`, gap: "1rem" } : void 0;
|
|
1293
|
+
return /* @__PURE__ */ t.jsx(
|
|
478
1294
|
"div",
|
|
479
1295
|
{
|
|
480
|
-
className:
|
|
481
|
-
style:
|
|
482
|
-
...
|
|
483
|
-
children:
|
|
1296
|
+
className: l,
|
|
1297
|
+
style: m,
|
|
1298
|
+
...p,
|
|
1299
|
+
children: f
|
|
484
1300
|
}
|
|
485
1301
|
);
|
|
486
1302
|
};
|
|
487
|
-
|
|
1303
|
+
te.register("view:simple", ir, {
|
|
488
1304
|
namespace: "plugin-view",
|
|
489
1305
|
label: "Simple View",
|
|
490
1306
|
category: "view"
|
|
491
1307
|
});
|
|
492
1308
|
export {
|
|
493
|
-
|
|
1309
|
+
rr as FilterUI,
|
|
1310
|
+
Qt as ObjectView,
|
|
1311
|
+
lr as SortUI,
|
|
1312
|
+
Ze as ViewSwitcher
|
|
494
1313
|
};
|