@luminix/mui-cms 0.0.1-beta.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/.eslintrc.cjs +18 -0
- package/README.md +30 -0
- package/bundle/mui-cms.bundle.iife.js +196 -0
- package/bundle/style.css +1 -0
- package/bundle/vite.svg +1 -0
- package/dist/mui-cms.js +3163 -0
- package/dist/vite.svg +1 -0
- package/package.json +46 -0
- package/tsconfig.json +25 -0
- package/tsconfig.node.json +11 -0
- package/types/components/Breadcrumbs.d.ts +3 -0
- package/types/components/DesktopPageTitle.d.ts +2 -0
- package/types/components/Layout/AppBar/MenuButton.d.ts +3 -0
- package/types/components/Layout/AppBar.d.ts +4 -0
- package/types/components/Layout/BackButton.d.ts +4 -0
- package/types/components/Layout/Drawer.d.ts +4 -0
- package/types/components/Layout/SearchBar.d.ts +4 -0
- package/types/components/Link.d.ts +7 -0
- package/types/components/LuminixCms.d.ts +4 -0
- package/types/components/ModelIndex/Filter/Content.d.ts +3 -0
- package/types/components/ModelIndex/Filter/Row.d.ts +4 -0
- package/types/components/ModelIndex/Filter/ValueInput/AsyncAutocomplete.d.ts +3 -0
- package/types/components/ModelIndex/Filter/ValueInput/DatePicker.d.ts +4 -0
- package/types/components/ModelIndex/Filter/ValueInput/Switch.d.ts +3 -0
- package/types/components/ModelIndex/Filter/ValueInput/TextField.d.ts +4 -0
- package/types/components/ModelIndex/Filter/ValueInput.d.ts +3 -0
- package/types/components/ModelIndex/Filter/useRow.d.ts +19 -0
- package/types/components/ModelIndex/Filter.d.ts +3 -0
- package/types/components/ModelIndex/InstanceActions.d.ts +5 -0
- package/types/components/ModelIndex/MassActions.d.ts +4 -0
- package/types/components/ModelIndex/Pagination.d.ts +4 -0
- package/types/components/ModelIndex/PaginationDetails.d.ts +3 -0
- package/types/components/ModelIndex/PerPageSwitch.d.ts +3 -0
- package/types/components/ModelIndex/Sort.d.ts +3 -0
- package/types/components/ModelIndex/StaticActions.d.ts +4 -0
- package/types/components/ModelIndex/Table/ShrinkedCell.d.ts +4 -0
- package/types/components/ModelIndex/Table/TableBody/Skeleton.d.ts +3 -0
- package/types/components/ModelIndex/Table/TableBody/TableRow.d.ts +4 -0
- package/types/components/ModelIndex/Table/TableBody.d.ts +4 -0
- package/types/components/ModelIndex/Table/TableFooter.d.ts +4 -0
- package/types/components/ModelIndex/Table/TableHead.d.ts +4 -0
- package/types/components/ModelIndex/Table/TableToolbar.d.ts +3 -0
- package/types/components/ModelIndex/Table.d.ts +4 -0
- package/types/components/ModelIndex/Tabs.d.ts +3 -0
- package/types/components/RecursiveList.d.ts +4 -0
- package/types/components/RecursiveMenu.d.ts +4 -0
- package/types/contexts/DialogContext.d.ts +4 -0
- package/types/contexts/LayoutContext.d.ts +4 -0
- package/types/contexts/ModelContext.d.ts +4 -0
- package/types/contexts/ModelFilterContext.d.ts +4 -0
- package/types/contexts/ModelFilterRowContext.d.ts +4 -0
- package/types/contexts/NotificationContext.d.ts +4 -0
- package/types/contexts/TableContext.d.ts +4 -0
- package/types/dist.d.ts +3 -0
- package/types/facades/Cms.d.ts +31 -0
- package/types/facades/Filter.d.ts +24 -0
- package/types/hooks/useActionEvent.d.ts +2 -0
- package/types/hooks/useBackButton.d.ts +6 -0
- package/types/hooks/useCurrentModel.d.ts +1 -0
- package/types/hooks/useDialog.d.ts +1 -0
- package/types/hooks/useDisplaceNotifications.d.ts +1 -0
- package/types/hooks/useHandleError.d.ts +1 -0
- package/types/hooks/useHasBackButton.d.ts +6 -0
- package/types/hooks/useHasSearch.d.ts +7 -0
- package/types/hooks/useIsDesktopMode.d.ts +7 -0
- package/types/hooks/useKeyChord.d.ts +1 -0
- package/types/hooks/useKeyPress.d.ts +1 -0
- package/types/hooks/useLayoutConfig.d.ts +8 -0
- package/types/hooks/useMenu.d.ts +12 -0
- package/types/hooks/useNotifications.d.ts +1 -0
- package/types/hooks/useNotify.d.ts +1 -0
- package/types/hooks/useOptimistic.d.ts +32 -0
- package/types/hooks/usePageTitle.d.ts +7 -0
- package/types/hooks/useSearch.d.ts +6 -0
- package/types/hooks/useSelection.d.ts +10 -0
- package/types/hooks/useSetPageTitle.d.ts +8 -0
- package/types/hooks/useTable.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/main.d.ts +0 -0
- package/types/plugins/CmsPlugin.d.ts +18 -0
- package/types/plugins/i18NextPlugin.d.ts +19 -0
- package/types/providers/DialogProvider.d.ts +4 -0
- package/types/providers/LayoutProvider.d.ts +5 -0
- package/types/providers/ModelProvider.d.ts +3 -0
- package/types/providers/NotificationProvider.d.ts +4 -0
- package/types/providers/TableProvider.d.ts +4 -0
- package/types/routes.d.ts +3 -0
- package/types/support/ModelIndex/Filter/inputs.d.ts +4 -0
- package/types/support/ModelIndex/Filter/searchParams.d.ts +18 -0
- package/types/support/ModelIndex/relation.d.ts +4 -0
- package/types/support/array.d.ts +9 -0
- package/types/support/date.d.ts +1 -0
- package/types/support/error.d.ts +2 -0
- package/types/support/handlers.d.ts +9 -0
- package/types/support/misc.d.ts +16 -0
- package/types/support/searchParams.d.ts +1 -0
- package/types/types/Config.d.ts +13 -0
- package/types/types/Contexts.d.ts +72 -0
- package/types/types/Dialog.d.ts +9 -0
- package/types/types/Filter.d.ts +20 -0
- package/types/types/Menu.d.ts +11 -0
- package/types/types/Notifications.d.ts +13 -0
- package/types/types/Plugin.d.ts +8 -0
- package/types/types/PropTypes.d.ts +100 -0
- package/types/types/Reducers.d.ts +4 -0
- package/types/types/Table.d.ts +41 -0
- package/types/types/Tabs.d.ts +4 -0
- package/types/views/Dashboard.d.ts +3 -0
- package/types/views/Error.d.ts +4 -0
- package/types/views/Layout/Layout.d.ts +4 -0
- package/types/views/ModelIndex.d.ts +3 -0
- package/types/views/ModelItem.d.ts +4 -0
package/dist/mui-cms.js
ADDED
|
@@ -0,0 +1,3163 @@
|
|
|
1
|
+
var xt = Object.defineProperty;
|
|
2
|
+
var wt = (e, t, n) => t in e ? xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ce = (e, t, n) => wt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as r, jsxs as m, Fragment as F } from "react/jsx-runtime";
|
|
5
|
+
import f from "lodash";
|
|
6
|
+
import { Reducible as Xe, model as te, config as H, collect as O, app as A, Plugin as Je } from "@luminix/core";
|
|
7
|
+
import { Outlet as St, useParams as kt, useNavigate as Ae, useSearchParams as q, Link as ae, Form as At } from "react-router-dom";
|
|
8
|
+
import { useCollection as _e, PaginationProvider as Ct, usePagination as ne, ModelForm as vt, useApplyReducers as Ce, LuminixProvider as Dt } from "@luminix/react";
|
|
9
|
+
import { useMediaQuery as le, Dialog as ve, DialogTitle as et, DialogContent as tt, DialogContentText as Tt, DialogActions as nt, Button as E, Snackbar as Ft, Alert as It, IconButton as R, AlertTitle as Pt, Box as N, Unstable_Grid2 as Y, Fab as Mt, SpeedDial as Bt, SpeedDialIcon as Et, SpeedDialAction as Lt, ButtonGroup as Ot, Popper as Rt, Grow as Nt, Paper as De, ClickAwayListener as jt, MenuList as qt, MenuItem as Z, AppBar as rt, Toolbar as Wt, Typography as j, Avatar as Ut, Drawer as at, Divider as oe, Autocomplete as Vt, TextField as re, CircularProgress as Yt, Switch as zt, Stack as B, FormControl as xe, InputLabel as we, Select as se, Badge as Te, Popover as Kt, Link as Se, Collapse as ot, TableCell as z, RadioGroup as We, FormControlLabel as ue, Radio as de, TableContainer as $t, Table as Ht, TableHead as Zt, TableRow as J, Checkbox as Fe, TableSortLabel as Gt, Skeleton as Ue, TableBody as Qt, TableFooter as Xt, Tabs as Jt, Tab as Ve, Breadcrumbs as _t, List as en, ListItem as tn, ListItemButton as nn, ListItemIcon as st, ListItemText as lt, Menu as it, CssBaseline as rn } from "@mui/material";
|
|
10
|
+
import p, { useContext as ct, useMemo as an } from "react";
|
|
11
|
+
import { useTranslation as I, initReactI18next as on } from "react-i18next";
|
|
12
|
+
import { Close as ut, ArrowDropDown as sn, ChevronLeft as Ie, ChevronRight as Pe, HighlightOffOutlined as Ye, FilterList as ln, Menu as cn, LastPage as un, FirstPage as dn, Search as ze, SwapVert as pn, ArrowUpward as hn, ArrowDownward as mn, MoreVert as dt, ExpandLess as fn, ExpandMore as gn, PeopleOutlined as bn, CategoryOutlined as yn, DashboardOutlined as xn, Add as wn } from "@mui/icons-material";
|
|
13
|
+
import { useTheme as Me, styled as U, createTheme as Sn, ThemeProvider as kn } from "@mui/material/styles";
|
|
14
|
+
import { isAxiosError as An } from "axios";
|
|
15
|
+
import Ke from "react-dom";
|
|
16
|
+
import W from "i18next";
|
|
17
|
+
class Cn {
|
|
18
|
+
constructor() {
|
|
19
|
+
}
|
|
20
|
+
getComponents() {
|
|
21
|
+
return this.componentMap({});
|
|
22
|
+
}
|
|
23
|
+
getComponent(t) {
|
|
24
|
+
return this.getComponents()[t];
|
|
25
|
+
}
|
|
26
|
+
getRoutes() {
|
|
27
|
+
return this.cmsRoutes([], this.getComponents(), te().make());
|
|
28
|
+
}
|
|
29
|
+
getMenuItems() {
|
|
30
|
+
return this.menuItems([], te().make());
|
|
31
|
+
}
|
|
32
|
+
getModelFormProps(t) {
|
|
33
|
+
return this.wireModelFormProps({}, t);
|
|
34
|
+
}
|
|
35
|
+
getMassActions(t, n) {
|
|
36
|
+
return this[`mass${f.upperFirst(f.camelCase(t.getSchemaName()))}Actions`](
|
|
37
|
+
this.massActions([], t, n),
|
|
38
|
+
t,
|
|
39
|
+
n
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
getInstanceActions(t, n) {
|
|
43
|
+
return this[`instance${f.upperFirst(f.camelCase(t.getSchemaName()))}Actions`](
|
|
44
|
+
this.instanceActions([], t, n),
|
|
45
|
+
t,
|
|
46
|
+
n
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
getStaticActions(t, n) {
|
|
50
|
+
return this[`static${f.upperFirst(f.camelCase(t.getSchemaName()))}Actions`](
|
|
51
|
+
this.staticActions([], t, n),
|
|
52
|
+
t,
|
|
53
|
+
n
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const vn = Xe(Cn), ee = (e) => !(f.isUndefined(e) || f.isNull(e) || f.isEmpty(e));
|
|
58
|
+
class Dn {
|
|
59
|
+
getInputType(t) {
|
|
60
|
+
switch (t) {
|
|
61
|
+
case "int":
|
|
62
|
+
case "float":
|
|
63
|
+
case "number":
|
|
64
|
+
return "number";
|
|
65
|
+
case "date":
|
|
66
|
+
return "date";
|
|
67
|
+
case "datetime":
|
|
68
|
+
case "timestamp":
|
|
69
|
+
return "datetime-local";
|
|
70
|
+
case "autocomplete":
|
|
71
|
+
return "autocomplete";
|
|
72
|
+
case "bool":
|
|
73
|
+
case "boolean":
|
|
74
|
+
return "boolean";
|
|
75
|
+
default:
|
|
76
|
+
return "text";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
getOperators() {
|
|
80
|
+
return H("luminix.admin.filter.operators");
|
|
81
|
+
}
|
|
82
|
+
getMatchingOperators(t) {
|
|
83
|
+
return this.getOperators().filter((n) => !t.is_relation && ["relation"].includes(n) || ["number", "date"].includes(this.getInputType(t.type)) && ["like", "notLike"].includes(n) ? !1 : n).map((n) => {
|
|
84
|
+
let a = n;
|
|
85
|
+
switch (n) {
|
|
86
|
+
case "equals":
|
|
87
|
+
a = "==";
|
|
88
|
+
break;
|
|
89
|
+
case "notEquals":
|
|
90
|
+
a = "!=";
|
|
91
|
+
break;
|
|
92
|
+
case "greaterThan":
|
|
93
|
+
a = ">";
|
|
94
|
+
break;
|
|
95
|
+
case "greaterThanOrEquals":
|
|
96
|
+
a = ">=";
|
|
97
|
+
break;
|
|
98
|
+
case "lessThan":
|
|
99
|
+
a = "<";
|
|
100
|
+
break;
|
|
101
|
+
case "lessThanOrEquals":
|
|
102
|
+
a = "<=";
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
key: n,
|
|
107
|
+
label: a
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
getFilterableColumns(t) {
|
|
112
|
+
const { attributes: n = [], relations: a = {} } = t.getSchema();
|
|
113
|
+
return [
|
|
114
|
+
...n.filter((s) => !s.hidden).map((s) => {
|
|
115
|
+
let o = s.phpType ?? "string";
|
|
116
|
+
return !f.isNull(s.cast) && !f.isEmpty(s.cast) && (o = s.cast), {
|
|
117
|
+
key: s.name,
|
|
118
|
+
label: f.upperFirst(s.name).replaceAll("_", " "),
|
|
119
|
+
type: o,
|
|
120
|
+
is_relation: !1
|
|
121
|
+
};
|
|
122
|
+
}),
|
|
123
|
+
// TODO: review typing of 'acc'
|
|
124
|
+
...Object.entries(a ?? {}).reduce((s, [o]) => [
|
|
125
|
+
...s,
|
|
126
|
+
{
|
|
127
|
+
key: o,
|
|
128
|
+
label: f.upperFirst(o).replaceAll("_", " "),
|
|
129
|
+
type: "autocomplete",
|
|
130
|
+
is_relation: !0
|
|
131
|
+
}
|
|
132
|
+
], [])
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
checkIfCanApplyFilters(t) {
|
|
136
|
+
return !!(t.length === 0 || t.map((a) => {
|
|
137
|
+
if (!ee(a.key) || !ee(a.operator))
|
|
138
|
+
return !0;
|
|
139
|
+
if (["boolean"].includes(this.getInputType(a.type))) {
|
|
140
|
+
if (f.isUndefined(a.value) || f.isNull(a.value))
|
|
141
|
+
return !0;
|
|
142
|
+
} else if (!ee(a.value))
|
|
143
|
+
return !0;
|
|
144
|
+
return !!(Array.isArray(a.value) && ["between", "notBetween"].includes(a.operator) && (!ee(a.value[0]) || !ee(a.value[1])));
|
|
145
|
+
}).includes(!0));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const Tn = Xe(Dn), Fn = {
|
|
149
|
+
open: !1,
|
|
150
|
+
setOpen: () => {
|
|
151
|
+
},
|
|
152
|
+
layout: {},
|
|
153
|
+
isBreakpointUp: !1,
|
|
154
|
+
currentPage: "",
|
|
155
|
+
setCurrentPage: () => {
|
|
156
|
+
},
|
|
157
|
+
showSearch: !1,
|
|
158
|
+
setShowSearch: () => {
|
|
159
|
+
},
|
|
160
|
+
showBackButton: !1,
|
|
161
|
+
setShowBackButton: () => {
|
|
162
|
+
}
|
|
163
|
+
}, V = p.createContext(Fn), pe = document.title, In = ({ children: e }) => {
|
|
164
|
+
const [t, n] = p.useState(!1), [a, s] = p.useState(""), [o, l] = p.useState(!1), [i, c] = p.useState(!1), u = H("luminix.cms.layout", {}), d = le((g) => g.breakpoints.up((u == null ? void 0 : u.breakpoint) || "md")), h = {
|
|
165
|
+
open: t,
|
|
166
|
+
setOpen: n,
|
|
167
|
+
layout: u,
|
|
168
|
+
isBreakpointUp: d,
|
|
169
|
+
currentPage: a,
|
|
170
|
+
setCurrentPage: s,
|
|
171
|
+
showSearch: o,
|
|
172
|
+
setShowSearch: l,
|
|
173
|
+
showBackButton: i,
|
|
174
|
+
setShowBackButton: c
|
|
175
|
+
};
|
|
176
|
+
return p.useEffect(() => (document.title = a ? `${a} | ${H("app.name", pe)}` : H("app.name", pe), () => {
|
|
177
|
+
document.title = pe;
|
|
178
|
+
}), [a]), /* @__PURE__ */ r(V.Provider, { value: h, children: e });
|
|
179
|
+
}, pt = p.createContext({
|
|
180
|
+
Model: null
|
|
181
|
+
}), he = ({ Model: e, children: t }) => /* @__PURE__ */ r(pt.Provider, { value: { Model: e }, children: t }), ht = p.createContext({
|
|
182
|
+
isOpen: !1,
|
|
183
|
+
dialog: () => Promise.reject(new Error("Trying to access DialogContext outside of DialogProvider")),
|
|
184
|
+
dismissDialog: () => {
|
|
185
|
+
},
|
|
186
|
+
current: void 0
|
|
187
|
+
});
|
|
188
|
+
function Pn(e) {
|
|
189
|
+
const [t, n] = p.useState(e);
|
|
190
|
+
return p.useEffect(() => {
|
|
191
|
+
e && n(e);
|
|
192
|
+
}, [e]), e || t;
|
|
193
|
+
}
|
|
194
|
+
function Mn({ children: e, ...t }) {
|
|
195
|
+
const [{ current: n, resolve: a }, s] = p.useState({}), o = Pn(n), l = p.useCallback((d) => new Promise((h) => {
|
|
196
|
+
s({
|
|
197
|
+
current: typeof d == "string" ? { message: d } : d,
|
|
198
|
+
resolve: h
|
|
199
|
+
});
|
|
200
|
+
}), []), { t: i } = I(), c = () => {
|
|
201
|
+
a && a(!1), s({});
|
|
202
|
+
}, u = () => {
|
|
203
|
+
a && a(!0), s({});
|
|
204
|
+
};
|
|
205
|
+
return /* @__PURE__ */ m(ht.Provider, { value: {
|
|
206
|
+
isOpen: !!n,
|
|
207
|
+
current: n,
|
|
208
|
+
dialog: l,
|
|
209
|
+
dismissDialog: c
|
|
210
|
+
}, children: [
|
|
211
|
+
e,
|
|
212
|
+
/* @__PURE__ */ m(
|
|
213
|
+
ve,
|
|
214
|
+
{
|
|
215
|
+
open: !!n,
|
|
216
|
+
"aria-labelledby": "alert-dialog-title",
|
|
217
|
+
"aria-describedby": "alert-dialog-description",
|
|
218
|
+
...(n == null ? void 0 : n.dismissable) ?? !0 ? { onClose: c } : {},
|
|
219
|
+
...t,
|
|
220
|
+
children: [
|
|
221
|
+
(o == null ? void 0 : o.title) && /* @__PURE__ */ r(et, { id: "alert-dialog-title", children: o.title }),
|
|
222
|
+
/* @__PURE__ */ r(tt, { children: /* @__PURE__ */ r(Tt, { id: "alert-dialog-description", children: o == null ? void 0 : o.message }) }),
|
|
223
|
+
/* @__PURE__ */ m(nt, { children: [
|
|
224
|
+
(o == null ? void 0 : o.type) === "confirm" && /* @__PURE__ */ m(F, { children: [
|
|
225
|
+
/* @__PURE__ */ r(E, { onClick: c, children: (o == null ? void 0 : o.cancelText) ?? i("No") }),
|
|
226
|
+
/* @__PURE__ */ r(E, { onClick: u, autoFocus: !0, children: (o == null ? void 0 : o.confirmText) ?? i("Yes") })
|
|
227
|
+
] }),
|
|
228
|
+
((o == null ? void 0 : o.type) ?? "alert") === "alert" && /* @__PURE__ */ r(E, { onClick: c, autoFocus: !0, children: (o == null ? void 0 : o.confirmText) ?? i("Ok") })
|
|
229
|
+
] })
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
] });
|
|
234
|
+
}
|
|
235
|
+
function v() {
|
|
236
|
+
const { isBreakpointUp: e } = ct(V);
|
|
237
|
+
return e;
|
|
238
|
+
}
|
|
239
|
+
const Be = p.createContext({
|
|
240
|
+
isOpen: !1,
|
|
241
|
+
notify: () => {
|
|
242
|
+
},
|
|
243
|
+
dismissNotification: () => {
|
|
244
|
+
},
|
|
245
|
+
notifications: [],
|
|
246
|
+
current: void 0,
|
|
247
|
+
displacement: "8px",
|
|
248
|
+
setDisplacement: () => {
|
|
249
|
+
}
|
|
250
|
+
}), ke = O([]), Bn = (e) => {
|
|
251
|
+
ke.push(
|
|
252
|
+
typeof e == "string" ? { message: e } : e
|
|
253
|
+
);
|
|
254
|
+
}, En = ({
|
|
255
|
+
children: e,
|
|
256
|
+
autoHideDuration: t = 6e3,
|
|
257
|
+
variant: n,
|
|
258
|
+
anchorOrigin: a,
|
|
259
|
+
sx: s,
|
|
260
|
+
...o
|
|
261
|
+
}) => {
|
|
262
|
+
const l = _e(ke), i = v(), u = Me().spacing(i ? 3 : 1), [d, h] = p.useState(), [g, y] = p.useState(u), { vertical: k = "bottom" } = a || {}, b = (x, S) => {
|
|
263
|
+
S !== "clickaway" && h(void 0);
|
|
264
|
+
};
|
|
265
|
+
return p.useEffect(() => {
|
|
266
|
+
if (!d && l.isNotEmpty()) {
|
|
267
|
+
const x = setTimeout(() => {
|
|
268
|
+
h(ke.pull(0) ?? void 0);
|
|
269
|
+
}, 100);
|
|
270
|
+
return () => clearTimeout(x);
|
|
271
|
+
}
|
|
272
|
+
}, [d, l]), /* @__PURE__ */ m(Be.Provider, { value: {
|
|
273
|
+
isOpen: !!d,
|
|
274
|
+
notify: Bn,
|
|
275
|
+
dismissNotification: b,
|
|
276
|
+
notifications: l.all(),
|
|
277
|
+
current: d,
|
|
278
|
+
displacement: g,
|
|
279
|
+
setDisplacement: y
|
|
280
|
+
}, children: [
|
|
281
|
+
e,
|
|
282
|
+
/* @__PURE__ */ r(
|
|
283
|
+
Ft,
|
|
284
|
+
{
|
|
285
|
+
open: !!d,
|
|
286
|
+
autoHideDuration: t,
|
|
287
|
+
anchorOrigin: a,
|
|
288
|
+
onClose: b,
|
|
289
|
+
sx: {
|
|
290
|
+
...s,
|
|
291
|
+
[k]: `${g} !important`
|
|
292
|
+
},
|
|
293
|
+
...o,
|
|
294
|
+
children: d && /* @__PURE__ */ m(
|
|
295
|
+
It,
|
|
296
|
+
{
|
|
297
|
+
onClose: b,
|
|
298
|
+
severity: d.severity,
|
|
299
|
+
variant: n,
|
|
300
|
+
sx: { width: "100%" },
|
|
301
|
+
action: d.actions && [
|
|
302
|
+
...d.actions.map(({ label: x, callback: S }, w) => /* @__PURE__ */ r(
|
|
303
|
+
E,
|
|
304
|
+
{
|
|
305
|
+
color: "inherit",
|
|
306
|
+
size: "small",
|
|
307
|
+
onClick: S,
|
|
308
|
+
children: x
|
|
309
|
+
},
|
|
310
|
+
w
|
|
311
|
+
)),
|
|
312
|
+
/* @__PURE__ */ r(R, { "aria-label": "close", color: "inherit", size: "small", onClick: b, children: /* @__PURE__ */ r(ut, {}) }, "close")
|
|
313
|
+
],
|
|
314
|
+
children: [
|
|
315
|
+
d.title && /* @__PURE__ */ r(Pt, { children: d.title }),
|
|
316
|
+
d.message
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
] });
|
|
323
|
+
}, Ln = ({ children: e }) => {
|
|
324
|
+
const t = le("(prefers-color-scheme: dark)");
|
|
325
|
+
return /* @__PURE__ */ r(
|
|
326
|
+
En,
|
|
327
|
+
{
|
|
328
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
329
|
+
variant: t ? "standard" : "filled",
|
|
330
|
+
children: /* @__PURE__ */ r(Mn, { children: /* @__PURE__ */ r(In, { children: e }) })
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
}, On = (e, { Layout: t, Dashboard: n, ModelIndex: a, ModelItem: s, Error: o }, l) => [
|
|
334
|
+
{
|
|
335
|
+
element: /* @__PURE__ */ r(Ln, { children: /* @__PURE__ */ r(t, { children: /* @__PURE__ */ r(St, {}) }) }),
|
|
336
|
+
errorElement: /* @__PURE__ */ r(o, {}),
|
|
337
|
+
children: [
|
|
338
|
+
{
|
|
339
|
+
path: "/",
|
|
340
|
+
name: "luminix.cms.dashboard",
|
|
341
|
+
element: /* @__PURE__ */ r(n, {})
|
|
342
|
+
},
|
|
343
|
+
...Object.entries(l).flatMap(([i, c]) => [
|
|
344
|
+
{
|
|
345
|
+
path: "/" + f.kebabCase(c.plural()),
|
|
346
|
+
name: `luminix.cms.${i}.index`,
|
|
347
|
+
element: /* @__PURE__ */ r(he, { Model: c, children: /* @__PURE__ */ r(Ct, { factory: c.query, children: /* @__PURE__ */ r(a, {}) }) })
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
path: "/" + f.kebabCase(c.plural()) + "/create",
|
|
351
|
+
name: `luminix.cms.${i}.item`,
|
|
352
|
+
element: /* @__PURE__ */ r(he, { Model: c, children: /* @__PURE__ */ r(s, { create: !0 }) })
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
path: "/" + f.kebabCase(c.plural()) + "/:id",
|
|
356
|
+
name: `luminix.cms.${i}.item`,
|
|
357
|
+
element: /* @__PURE__ */ r(he, { Model: c, children: /* @__PURE__ */ r(s, {}) })
|
|
358
|
+
}
|
|
359
|
+
])
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
];
|
|
363
|
+
function Ee(e) {
|
|
364
|
+
const { setCurrentPage: t } = p.useContext(V);
|
|
365
|
+
p.useEffect(() => (t(e), () => {
|
|
366
|
+
t("");
|
|
367
|
+
}), [e, t]);
|
|
368
|
+
}
|
|
369
|
+
const Rn = () => {
|
|
370
|
+
const { t: e } = I();
|
|
371
|
+
return Ee(e("Dashboard")), /* @__PURE__ */ r(F, { children: "Dashboard" });
|
|
372
|
+
}, Nn = ({ error: e }) => /* @__PURE__ */ m("div", { children: [
|
|
373
|
+
/* @__PURE__ */ r("h1", { children: "Ops..." }),
|
|
374
|
+
/* @__PURE__ */ r("p", { children: "Something went wrong" }),
|
|
375
|
+
A().hasDebugModeEnabled() && e && /* @__PURE__ */ r(F, { children: /* @__PURE__ */ m("pre", { style: { whiteSpace: "pre-wrap" }, children: [
|
|
376
|
+
e.message,
|
|
377
|
+
/* @__PURE__ */ r("br", {}),
|
|
378
|
+
e.stack
|
|
379
|
+
] }) })
|
|
380
|
+
] });
|
|
381
|
+
function L(e, t) {
|
|
382
|
+
const { layout: n } = ct(V);
|
|
383
|
+
return an(() => f.get(n, e, t), [n, e, t]);
|
|
384
|
+
}
|
|
385
|
+
const jn = U("div")(({ theme: e }) => ({
|
|
386
|
+
padding: e.spacing(0, 1),
|
|
387
|
+
// necessary for content to be below app bar
|
|
388
|
+
...e.mixins.toolbar
|
|
389
|
+
})), qn = ({ children: e, slotProps: t, ...n }) => {
|
|
390
|
+
const {
|
|
391
|
+
DesktopPageTitle: a,
|
|
392
|
+
["Layout.AppBar"]: s,
|
|
393
|
+
["Layout.Drawer"]: o
|
|
394
|
+
} = A("cms").getComponents(), l = L("appBar.height"), {
|
|
395
|
+
AppBar: i,
|
|
396
|
+
Drawer: c,
|
|
397
|
+
main: u
|
|
398
|
+
} = t || {};
|
|
399
|
+
return /* @__PURE__ */ m(N, { sx: { display: "flex" }, ...n, children: [
|
|
400
|
+
/* @__PURE__ */ r(
|
|
401
|
+
s,
|
|
402
|
+
{
|
|
403
|
+
position: "fixed",
|
|
404
|
+
...i
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ r(o, { ...c }),
|
|
408
|
+
/* @__PURE__ */ m(
|
|
409
|
+
N,
|
|
410
|
+
{
|
|
411
|
+
component: "main",
|
|
412
|
+
sx: {
|
|
413
|
+
flexGrow: 1
|
|
414
|
+
// p: { xs: 1, sm: 2, md: 3 },
|
|
415
|
+
},
|
|
416
|
+
...u,
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ r(jn, { style: { height: l } }),
|
|
419
|
+
/* @__PURE__ */ r(a, {}),
|
|
420
|
+
/* @__PURE__ */ r(N, { sx: { p: { xs: 1, sm: 2, md: 3 } }, children: e })
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
)
|
|
424
|
+
] });
|
|
425
|
+
};
|
|
426
|
+
function Wn() {
|
|
427
|
+
const { setShowSearch: e } = p.useContext(V);
|
|
428
|
+
p.useEffect(() => (e(!0), () => {
|
|
429
|
+
e(!1);
|
|
430
|
+
}), [e]);
|
|
431
|
+
}
|
|
432
|
+
function K() {
|
|
433
|
+
const { Model: e } = p.useContext(pt);
|
|
434
|
+
return e;
|
|
435
|
+
}
|
|
436
|
+
const Un = () => {
|
|
437
|
+
const e = K(), {
|
|
438
|
+
data: t,
|
|
439
|
+
error: n,
|
|
440
|
+
loading: a
|
|
441
|
+
} = ne();
|
|
442
|
+
Ee(e.plural()), Wn();
|
|
443
|
+
const s = v(), {
|
|
444
|
+
Breadcrumbs: o,
|
|
445
|
+
["ModelIndex.Pagination"]: l,
|
|
446
|
+
["ModelIndex.StaticActions"]: i,
|
|
447
|
+
["ModelIndex.Table"]: c,
|
|
448
|
+
["ModelIndex.Table.TableBody"]: u,
|
|
449
|
+
["ModelIndex.Table.TableHead"]: d,
|
|
450
|
+
["ModelIndex.Table.TableFooter"]: h,
|
|
451
|
+
["ModelIndex.Table.TableToolbar"]: g,
|
|
452
|
+
["ModelIndex.Table.TableBody.TableRow"]: y,
|
|
453
|
+
["ModelIndex.Tabs"]: k
|
|
454
|
+
} = A("cms").getComponents();
|
|
455
|
+
return /* @__PURE__ */ m(Y, { container: !0, spacing: 2, children: [
|
|
456
|
+
/* @__PURE__ */ m(
|
|
457
|
+
Y,
|
|
458
|
+
{
|
|
459
|
+
xs: 12,
|
|
460
|
+
display: "flex",
|
|
461
|
+
flexDirection: "row",
|
|
462
|
+
justifyContent: "space-between",
|
|
463
|
+
children: [
|
|
464
|
+
/* @__PURE__ */ r(
|
|
465
|
+
o,
|
|
466
|
+
{
|
|
467
|
+
parts: [
|
|
468
|
+
{ name: e.plural() }
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
),
|
|
472
|
+
/* @__PURE__ */ r(i, { variant: s ? "default" : "fab" })
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
!s && /* @__PURE__ */ r(Y, { display: "flex", justifyContent: "center", xs: 12, children: /* @__PURE__ */ r(l, { variant: "compact" }) }),
|
|
477
|
+
/* @__PURE__ */ r(Y, { xs: 12, sx: { pb: 0 }, children: /* @__PURE__ */ r(k, {}) }),
|
|
478
|
+
/* @__PURE__ */ r(Y, { xs: 12, sx: { pt: 0 }, children: /* @__PURE__ */ m(
|
|
479
|
+
c,
|
|
480
|
+
{
|
|
481
|
+
items: t,
|
|
482
|
+
loading: a,
|
|
483
|
+
error: n,
|
|
484
|
+
children: [
|
|
485
|
+
/* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(g, {}) }),
|
|
486
|
+
/* @__PURE__ */ r(u, { children: (b) => /* @__PURE__ */ r(y, { item: b }, b.getKey()) }),
|
|
487
|
+
/* @__PURE__ */ r(h, {})
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
) })
|
|
491
|
+
] });
|
|
492
|
+
};
|
|
493
|
+
function Vn() {
|
|
494
|
+
const { setShowBackButton: e } = p.useContext(V);
|
|
495
|
+
p.useEffect(() => (e(!0), () => {
|
|
496
|
+
e(!1);
|
|
497
|
+
}), [e]);
|
|
498
|
+
}
|
|
499
|
+
function Q(e) {
|
|
500
|
+
return (t) => {
|
|
501
|
+
var n;
|
|
502
|
+
if (!(t instanceof Error))
|
|
503
|
+
throw t;
|
|
504
|
+
e({
|
|
505
|
+
message: An(t) ? ((n = t.response) == null ? void 0 : n.data.message) ?? t.message : t.message,
|
|
506
|
+
severity: "error"
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function Le() {
|
|
511
|
+
return p.useContext(Be).notify;
|
|
512
|
+
}
|
|
513
|
+
function Yn() {
|
|
514
|
+
const e = Le();
|
|
515
|
+
return p.useCallback((t) => {
|
|
516
|
+
Q(e)(t);
|
|
517
|
+
}, [e]);
|
|
518
|
+
}
|
|
519
|
+
const zn = ({ create: e = !1 }) => {
|
|
520
|
+
const [t, n] = p.useState(), { id: a } = kt(), { t: s } = I(), o = Le(), l = Ae(), i = K(), c = L("breakpoint", "md");
|
|
521
|
+
Ee(
|
|
522
|
+
t != null && t.exists ? s("Edit :model “:label“", { model: i.singular(), label: (t == null ? void 0 : t.getLabel()) || "..." }) : s("Create :model", { model: i.singular() })
|
|
523
|
+
), Vn();
|
|
524
|
+
const u = A("cms").getComponent("Breadcrumbs");
|
|
525
|
+
p.useEffect(() => {
|
|
526
|
+
e ? n(new i()) : i.find(a).then((y) => n(y ?? void 0));
|
|
527
|
+
}, [a, i, e]);
|
|
528
|
+
const d = p.useCallback(() => {
|
|
529
|
+
o(s(":model saved successfully", { model: i.singular() })), t != null && t.wasRecentlyCreated && l(`/${f.kebabCase(i.plural())}/${t.getKey()}`);
|
|
530
|
+
}, [o, l, i, t, s]), h = Yn(), g = p.useMemo(() => A("cms").getModelFormProps(t), [t]);
|
|
531
|
+
return t ? /* @__PURE__ */ m(Y, { container: !0, children: [
|
|
532
|
+
/* @__PURE__ */ r(Y, { xs: 12, children: /* @__PURE__ */ r(
|
|
533
|
+
u,
|
|
534
|
+
{
|
|
535
|
+
parts: [
|
|
536
|
+
{ name: i.plural(), href: "/" + f.kebabCase(i.plural()) },
|
|
537
|
+
{ name: t.exists ? t.getLabel() : s("New") }
|
|
538
|
+
]
|
|
539
|
+
}
|
|
540
|
+
) }),
|
|
541
|
+
/* @__PURE__ */ r(
|
|
542
|
+
Y,
|
|
543
|
+
{
|
|
544
|
+
xs: 12,
|
|
545
|
+
[c]: 6,
|
|
546
|
+
children: /* @__PURE__ */ r(
|
|
547
|
+
vt,
|
|
548
|
+
{
|
|
549
|
+
submitText: "Save",
|
|
550
|
+
...g,
|
|
551
|
+
item: t,
|
|
552
|
+
onSuccess: d,
|
|
553
|
+
onError: h
|
|
554
|
+
}
|
|
555
|
+
)
|
|
556
|
+
}
|
|
557
|
+
)
|
|
558
|
+
] }) : null;
|
|
559
|
+
};
|
|
560
|
+
function Kn(e) {
|
|
561
|
+
const {
|
|
562
|
+
setDisplacement: t
|
|
563
|
+
} = p.useContext(Be), n = Me(), a = v(), s = n.spacing(a ? 3 : 1), o = e === !1 ? s : n.spacing(e);
|
|
564
|
+
p.useEffect(() => (t(o), () => {
|
|
565
|
+
t(s);
|
|
566
|
+
}), [o, s]);
|
|
567
|
+
}
|
|
568
|
+
function $n() {
|
|
569
|
+
return p.useContext(ht).dialog;
|
|
570
|
+
}
|
|
571
|
+
function Oe() {
|
|
572
|
+
const e = Ae(), t = Le(), n = $n(), { t: a } = I(), { refresh: s } = ne();
|
|
573
|
+
return { navigate: e, notify: t, dialog: n, t: a, refresh: s };
|
|
574
|
+
}
|
|
575
|
+
const Hn = U(Mt)(({ theme: e }) => ({
|
|
576
|
+
position: "fixed",
|
|
577
|
+
bottom: e.spacing(2),
|
|
578
|
+
right: e.spacing(2)
|
|
579
|
+
})), Zn = U(Bt)(({ theme: e }) => ({
|
|
580
|
+
position: "fixed",
|
|
581
|
+
bottom: e.spacing(2),
|
|
582
|
+
right: e.spacing(2)
|
|
583
|
+
})), Gn = ({ variant: e = "default" }) => {
|
|
584
|
+
const t = K(), n = v(), [a] = q(), s = a.get("tab") ?? "all", [o, l] = p.useState(!1), i = p.useRef(null), [c, u] = p.useState(0), d = Oe(), h = p.useMemo(() => A("cms").getStaticActions(t, s), [t, s]);
|
|
585
|
+
if (Kn(
|
|
586
|
+
e === "fab" && h.length > 0 ? n ? 12 : 10 : !1
|
|
587
|
+
), h.length === 0)
|
|
588
|
+
return null;
|
|
589
|
+
const g = (b, x) => {
|
|
590
|
+
u(x), l(!1);
|
|
591
|
+
}, y = () => {
|
|
592
|
+
l((b) => !b);
|
|
593
|
+
}, k = (b) => {
|
|
594
|
+
i.current && i.current.contains(b.target) || l(!1);
|
|
595
|
+
};
|
|
596
|
+
return e === "fab" ? h.length === 1 ? Ke.createPortal(
|
|
597
|
+
/* @__PURE__ */ r(
|
|
598
|
+
Hn,
|
|
599
|
+
{
|
|
600
|
+
color: "primary",
|
|
601
|
+
onClick: () => h[0].callback(d),
|
|
602
|
+
children: h[0].icon || h[0].label.charAt(0).toUpperCase()
|
|
603
|
+
}
|
|
604
|
+
),
|
|
605
|
+
document.body
|
|
606
|
+
) : Ke.createPortal(
|
|
607
|
+
/* @__PURE__ */ r(
|
|
608
|
+
Zn,
|
|
609
|
+
{
|
|
610
|
+
ariaLabel: `actions for ${t.singular()}`,
|
|
611
|
+
icon: /* @__PURE__ */ r(Et, {}),
|
|
612
|
+
color: "primary",
|
|
613
|
+
onClose: () => l(!1),
|
|
614
|
+
onOpen: () => l(!0),
|
|
615
|
+
open: o,
|
|
616
|
+
children: h.map((b) => /* @__PURE__ */ r(
|
|
617
|
+
Lt,
|
|
618
|
+
{
|
|
619
|
+
icon: b.icon || b.label.charAt(0).toUpperCase(),
|
|
620
|
+
tooltipTitle: b.label,
|
|
621
|
+
onClick: () => b.callback(d)
|
|
622
|
+
},
|
|
623
|
+
b.label
|
|
624
|
+
))
|
|
625
|
+
}
|
|
626
|
+
),
|
|
627
|
+
document.body
|
|
628
|
+
) : /* @__PURE__ */ m(F, { children: [
|
|
629
|
+
/* @__PURE__ */ m(
|
|
630
|
+
Ot,
|
|
631
|
+
{
|
|
632
|
+
variant: "contained",
|
|
633
|
+
ref: i,
|
|
634
|
+
"aria-label": h[c].label,
|
|
635
|
+
children: [
|
|
636
|
+
/* @__PURE__ */ r(E, { onClick: () => h[c].callback(d), children: h[c].label }),
|
|
637
|
+
h.length > 1 && /* @__PURE__ */ r(
|
|
638
|
+
E,
|
|
639
|
+
{
|
|
640
|
+
variant: "contained",
|
|
641
|
+
size: "small",
|
|
642
|
+
"aria-controls": o ? "split-button-menu" : void 0,
|
|
643
|
+
"aria-expanded": o ? "true" : void 0,
|
|
644
|
+
"aria-label": `select ${t.singular()} actions`,
|
|
645
|
+
"aria-haspopup": "menu",
|
|
646
|
+
onClick: y,
|
|
647
|
+
children: /* @__PURE__ */ r(sn, {})
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
]
|
|
651
|
+
}
|
|
652
|
+
),
|
|
653
|
+
/* @__PURE__ */ r(
|
|
654
|
+
Rt,
|
|
655
|
+
{
|
|
656
|
+
open: o,
|
|
657
|
+
anchorEl: i.current,
|
|
658
|
+
role: void 0,
|
|
659
|
+
transition: !0,
|
|
660
|
+
children: ({ TransitionProps: b, placement: x }) => /* @__PURE__ */ r(
|
|
661
|
+
Nt,
|
|
662
|
+
{
|
|
663
|
+
...b,
|
|
664
|
+
style: {
|
|
665
|
+
transformOrigin: x === "bottom" ? "center top" : "center bottom"
|
|
666
|
+
},
|
|
667
|
+
children: /* @__PURE__ */ r(De, { children: /* @__PURE__ */ r(jt, { onClickAway: k, children: /* @__PURE__ */ r(qt, { id: "split-button-menu", children: h.map((S, w) => /* @__PURE__ */ r(
|
|
668
|
+
Z,
|
|
669
|
+
{
|
|
670
|
+
selected: w === c,
|
|
671
|
+
onClick: (C) => g(C, w),
|
|
672
|
+
children: S.label
|
|
673
|
+
},
|
|
674
|
+
S.label
|
|
675
|
+
)) }) }) })
|
|
676
|
+
}
|
|
677
|
+
)
|
|
678
|
+
}
|
|
679
|
+
)
|
|
680
|
+
] });
|
|
681
|
+
};
|
|
682
|
+
function Re() {
|
|
683
|
+
const { open: e, setOpen: t } = p.useContext(V);
|
|
684
|
+
return {
|
|
685
|
+
open: e,
|
|
686
|
+
handleDrawerOpen: () => {
|
|
687
|
+
t(!0);
|
|
688
|
+
},
|
|
689
|
+
handleDrawerClose: () => {
|
|
690
|
+
t(!1);
|
|
691
|
+
},
|
|
692
|
+
toggle: () => {
|
|
693
|
+
t((o) => !o);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function mt() {
|
|
698
|
+
const { currentPage: e } = p.useContext(V);
|
|
699
|
+
return e;
|
|
700
|
+
}
|
|
701
|
+
function Qn() {
|
|
702
|
+
const { showSearch: e } = p.useContext(V);
|
|
703
|
+
return e;
|
|
704
|
+
}
|
|
705
|
+
const Xn = "data:image/png;base64,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", Jn = "data:image/png;base64,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";
|
|
706
|
+
function ft() {
|
|
707
|
+
const { showBackButton: e } = p.useContext(V);
|
|
708
|
+
return e;
|
|
709
|
+
}
|
|
710
|
+
const _n = U(
|
|
711
|
+
rt,
|
|
712
|
+
{ shouldForwardProp: (e) => !["open", "drawerWidth", "height"].includes(String(e)) }
|
|
713
|
+
)(({ theme: e, open: t, drawerWidth: n, height: a }) => ({
|
|
714
|
+
zIndex: e.zIndex.drawer + 1,
|
|
715
|
+
transition: e.transitions.create(["width", "margin"], {
|
|
716
|
+
easing: e.transitions.easing.sharp,
|
|
717
|
+
duration: e.transitions.duration.leavingScreen
|
|
718
|
+
}),
|
|
719
|
+
height: a,
|
|
720
|
+
...t && {
|
|
721
|
+
marginLeft: n,
|
|
722
|
+
width: `calc(100% - ${n}px)`,
|
|
723
|
+
transition: e.transitions.create(["width", "margin"], {
|
|
724
|
+
easing: e.transitions.easing.sharp,
|
|
725
|
+
duration: e.transitions.duration.enteringScreen
|
|
726
|
+
})
|
|
727
|
+
}
|
|
728
|
+
})), er = U(
|
|
729
|
+
rt,
|
|
730
|
+
{ shouldForwardProp: (e) => !["open", "drawerWidth", "height"].includes(String(e)) }
|
|
731
|
+
)(({ height: e }) => ({ height: e })), tr = ({ slots: e = {}, ...t }) => {
|
|
732
|
+
const n = v(), a = le("(prefers-color-scheme: dark)"), s = n ? _n : er, {
|
|
733
|
+
["Layout.AppBar.MenuButton"]: o,
|
|
734
|
+
["Layout.SearchBar"]: l,
|
|
735
|
+
["Layout.BackButton"]: i
|
|
736
|
+
} = A("cms").getComponents(), { open: c } = Re(), u = Qn(), d = ft(), h = L("appBar.height"), g = L("drawer.width", 280), {
|
|
737
|
+
start: y = null,
|
|
738
|
+
//: title = config('app.name', document.title),
|
|
739
|
+
end: k = null
|
|
740
|
+
} = e, b = mt();
|
|
741
|
+
return /* @__PURE__ */ r(
|
|
742
|
+
s,
|
|
743
|
+
{
|
|
744
|
+
open: c,
|
|
745
|
+
height: h,
|
|
746
|
+
drawerWidth: g,
|
|
747
|
+
...t,
|
|
748
|
+
children: /* @__PURE__ */ m(Wt, { children: [
|
|
749
|
+
(n && !c || !n && !d) && /* @__PURE__ */ r(o, {}),
|
|
750
|
+
!n && d && /* @__PURE__ */ r(i, {}),
|
|
751
|
+
n ? null : y,
|
|
752
|
+
/* @__PURE__ */ r(
|
|
753
|
+
j,
|
|
754
|
+
{
|
|
755
|
+
width: "100%",
|
|
756
|
+
variant: "h6",
|
|
757
|
+
noWrap: !0,
|
|
758
|
+
component: "div",
|
|
759
|
+
children: !n && b || H("app.name", document.title)
|
|
760
|
+
}
|
|
761
|
+
),
|
|
762
|
+
/* @__PURE__ */ r(N, { sx: { flexGrow: 1 } }),
|
|
763
|
+
/* @__PURE__ */ m(
|
|
764
|
+
N,
|
|
765
|
+
{
|
|
766
|
+
display: "flex",
|
|
767
|
+
alignItems: "center",
|
|
768
|
+
children: [
|
|
769
|
+
u && /* @__PURE__ */ r(l, {}),
|
|
770
|
+
k || /* @__PURE__ */ r(
|
|
771
|
+
Ut,
|
|
772
|
+
{
|
|
773
|
+
src: a ? Xn : Jn,
|
|
774
|
+
alt: "Luminix",
|
|
775
|
+
variant: "square",
|
|
776
|
+
sx: {
|
|
777
|
+
width: 40,
|
|
778
|
+
height: 40,
|
|
779
|
+
marginLeft: u ? 2 : 0
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
]
|
|
784
|
+
}
|
|
785
|
+
)
|
|
786
|
+
] })
|
|
787
|
+
}
|
|
788
|
+
);
|
|
789
|
+
};
|
|
790
|
+
function nr(e) {
|
|
791
|
+
return /* @__PURE__ */ r(
|
|
792
|
+
R,
|
|
793
|
+
{
|
|
794
|
+
component: ae,
|
|
795
|
+
to: -1,
|
|
796
|
+
edge: "start",
|
|
797
|
+
color: "inherit",
|
|
798
|
+
"aria-label": "back",
|
|
799
|
+
...e,
|
|
800
|
+
children: /* @__PURE__ */ r(Ie, {})
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
const $e = (e, t) => ({
|
|
805
|
+
width: t,
|
|
806
|
+
transition: e.transitions.create("width", {
|
|
807
|
+
easing: e.transitions.easing.sharp,
|
|
808
|
+
duration: e.transitions.duration.enteringScreen
|
|
809
|
+
}),
|
|
810
|
+
overflowX: "hidden"
|
|
811
|
+
}), He = (e) => ({
|
|
812
|
+
transition: e.transitions.create("width", {
|
|
813
|
+
easing: e.transitions.easing.sharp,
|
|
814
|
+
duration: e.transitions.duration.leavingScreen
|
|
815
|
+
}),
|
|
816
|
+
overflowX: "hidden",
|
|
817
|
+
width: `calc(${e.spacing(9)} + 1px)`,
|
|
818
|
+
[e.breakpoints.up("sm")]: { width: `calc(${e.spacing(10)} + 1px)` }
|
|
819
|
+
}), rr = U(
|
|
820
|
+
at,
|
|
821
|
+
{ shouldForwardProp: (e) => !["open", "width"].includes(String(e)) }
|
|
822
|
+
)(({ theme: e, open: t, width: n }) => ({
|
|
823
|
+
flexShrink: 0,
|
|
824
|
+
whiteSpace: "nowrap",
|
|
825
|
+
boxSizing: "border-box",
|
|
826
|
+
...t && {
|
|
827
|
+
...$e(e, n),
|
|
828
|
+
"& .MuiDrawer-paper": $e(e, n)
|
|
829
|
+
},
|
|
830
|
+
...!t && {
|
|
831
|
+
...He(e),
|
|
832
|
+
"& .MuiDrawer-paper": He(e)
|
|
833
|
+
}
|
|
834
|
+
})), ar = U(
|
|
835
|
+
at,
|
|
836
|
+
{ shouldForwardProp: (e) => e !== "width" }
|
|
837
|
+
)(() => ({})), or = U("div")(({ theme: e }) => ({
|
|
838
|
+
display: "flex",
|
|
839
|
+
alignItems: "center",
|
|
840
|
+
justifyContent: "space-between",
|
|
841
|
+
padding: e.spacing(0, 1),
|
|
842
|
+
// necessary for content to be below app bar
|
|
843
|
+
...e.mixins.toolbar
|
|
844
|
+
})), sr = (e) => {
|
|
845
|
+
const t = Me(), n = v(), { open: a, handleDrawerClose: s } = Re(), o = n ? rr : ar, l = L("drawer.width", 280), i = L("appBar.height"), c = A("cms").getComponent("RecursiveList"), u = A("cms").getMenuItems();
|
|
846
|
+
return /* @__PURE__ */ m(
|
|
847
|
+
o,
|
|
848
|
+
{
|
|
849
|
+
variant: n ? "permanent" : "temporary",
|
|
850
|
+
open: a,
|
|
851
|
+
width: l,
|
|
852
|
+
onClose: s,
|
|
853
|
+
PaperProps: { sx: { width: l } },
|
|
854
|
+
sx: {
|
|
855
|
+
display: "flex",
|
|
856
|
+
direction: "flex-column",
|
|
857
|
+
flexWrap: "nowrap",
|
|
858
|
+
height: "100%"
|
|
859
|
+
},
|
|
860
|
+
...e,
|
|
861
|
+
children: [
|
|
862
|
+
/* @__PURE__ */ r(or, { style: { height: i }, children: /* @__PURE__ */ r(R, { onClick: s, children: t.direction === "ltr" ? /* @__PURE__ */ r(Ie, {}) : /* @__PURE__ */ r(Pe, {}) }) }),
|
|
863
|
+
/* @__PURE__ */ r(oe, {}),
|
|
864
|
+
/* @__PURE__ */ r(N, { sx: { flexGrow: 1, overflowY: "auto", overflowX: "hidden" }, children: /* @__PURE__ */ r(
|
|
865
|
+
c,
|
|
866
|
+
{
|
|
867
|
+
collapsed: !a && n,
|
|
868
|
+
items: u,
|
|
869
|
+
onClick: () => !n && s()
|
|
870
|
+
}
|
|
871
|
+
) })
|
|
872
|
+
]
|
|
873
|
+
}
|
|
874
|
+
);
|
|
875
|
+
}, lr = () => {
|
|
876
|
+
const e = mt(), t = L("breakpoint", "md"), n = ft(), {
|
|
877
|
+
["Layout.BackButton"]: a
|
|
878
|
+
} = A("cms").getComponents();
|
|
879
|
+
return /* @__PURE__ */ m(
|
|
880
|
+
De,
|
|
881
|
+
{
|
|
882
|
+
sx: {
|
|
883
|
+
display: { xs: "none", [t]: "flex" },
|
|
884
|
+
boxShadow: (s) => s.shadows[3],
|
|
885
|
+
py: 2,
|
|
886
|
+
px: 3,
|
|
887
|
+
borderRadius: 0,
|
|
888
|
+
alignItems: "center"
|
|
889
|
+
},
|
|
890
|
+
children: [
|
|
891
|
+
n && /* @__PURE__ */ r(a, {}),
|
|
892
|
+
/* @__PURE__ */ r(j, { variant: "h5", noWrap: !0, children: e })
|
|
893
|
+
]
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
}, Ne = p.createContext({
|
|
897
|
+
Model: null,
|
|
898
|
+
anchorEl: null,
|
|
899
|
+
setAnchorEl: () => {
|
|
900
|
+
},
|
|
901
|
+
columnsFilter: [],
|
|
902
|
+
setColumnsFilter: () => {
|
|
903
|
+
},
|
|
904
|
+
searchParams: new URLSearchParams(),
|
|
905
|
+
setSearchParams: () => {
|
|
906
|
+
},
|
|
907
|
+
clearSearchParams: () => {
|
|
908
|
+
},
|
|
909
|
+
clearFilters: () => {
|
|
910
|
+
}
|
|
911
|
+
}), _ = p.createContext({
|
|
912
|
+
key: "",
|
|
913
|
+
type: "",
|
|
914
|
+
operator: "",
|
|
915
|
+
value: "",
|
|
916
|
+
isRelation: !1,
|
|
917
|
+
//
|
|
918
|
+
setKey: () => {
|
|
919
|
+
},
|
|
920
|
+
setType: () => {
|
|
921
|
+
},
|
|
922
|
+
setOperator: () => {
|
|
923
|
+
},
|
|
924
|
+
setValue: () => {
|
|
925
|
+
},
|
|
926
|
+
setIsRelation: () => {
|
|
927
|
+
}
|
|
928
|
+
}), ir = (e) => {
|
|
929
|
+
if (!Array.isArray(e))
|
|
930
|
+
return e;
|
|
931
|
+
let t;
|
|
932
|
+
return f.isEmpty(e) ? t = "" : t = e[0], t;
|
|
933
|
+
}, cr = (e) => {
|
|
934
|
+
if (Array.isArray(e))
|
|
935
|
+
return e;
|
|
936
|
+
let t;
|
|
937
|
+
return f.isEmpty(e) ? t = [] : t = [e, ""], t;
|
|
938
|
+
}, ur = async (e, t, n) => {
|
|
939
|
+
const a = e.getSchema().relations[t], s = te().make(a.model), o = s.getSchema().primaryKey, l = [];
|
|
940
|
+
for (const i of n) {
|
|
941
|
+
const { data: c } = await s.where(o, i).get();
|
|
942
|
+
l.push(c.first());
|
|
943
|
+
}
|
|
944
|
+
return l;
|
|
945
|
+
};
|
|
946
|
+
function dr(e, t) {
|
|
947
|
+
const n = A("filter"), { Model: a, setColumnsFilter: s } = p.useContext(Ne), [o, l] = p.useState(t.key), [i, c] = p.useState(t.operator), [u, d] = p.useState(t.type), [h, g] = p.useState(t.value), [y, k] = p.useState(t.is_relation), b = p.useMemo(() => n.getFilterableColumns(a), [a]), x = (C) => () => {
|
|
948
|
+
s((T) => T.filter((D, M) => M !== C));
|
|
949
|
+
}, S = async (C) => {
|
|
950
|
+
const T = C.target.value, D = b.find(($) => $.key === T), M = (D == null ? void 0 : D.type) ?? "text";
|
|
951
|
+
if (o !== T) {
|
|
952
|
+
const $ = (D == null ? void 0 : D.is_relation) ?? !1;
|
|
953
|
+
$ ? (c("relation"), g([])) : y && c("equals"), k($);
|
|
954
|
+
}
|
|
955
|
+
M !== u && (["boolean"].includes(n.getInputType(M)) && c("equals"), g(() => {
|
|
956
|
+
if (["between", "notBetween"].includes(i))
|
|
957
|
+
return [];
|
|
958
|
+
switch (n.getInputType(M)) {
|
|
959
|
+
case "number":
|
|
960
|
+
return 0;
|
|
961
|
+
case "boolean":
|
|
962
|
+
return 0;
|
|
963
|
+
default:
|
|
964
|
+
return "";
|
|
965
|
+
}
|
|
966
|
+
})), l(T), d(M);
|
|
967
|
+
}, w = async (C) => {
|
|
968
|
+
const T = C.target.value;
|
|
969
|
+
i !== T && g((D) => {
|
|
970
|
+
switch (T) {
|
|
971
|
+
case "between":
|
|
972
|
+
case "notBetween":
|
|
973
|
+
return cr(D);
|
|
974
|
+
case "null":
|
|
975
|
+
case "notNull":
|
|
976
|
+
return "1";
|
|
977
|
+
default:
|
|
978
|
+
return ir(D);
|
|
979
|
+
}
|
|
980
|
+
}), c(T);
|
|
981
|
+
};
|
|
982
|
+
return p.useEffect(() => {
|
|
983
|
+
s((C) => C.map((D, M) => e === M ? {
|
|
984
|
+
...D,
|
|
985
|
+
key: o,
|
|
986
|
+
operator: i,
|
|
987
|
+
type: u,
|
|
988
|
+
value: h,
|
|
989
|
+
is_relation: y
|
|
990
|
+
} : D));
|
|
991
|
+
}, [o, i, u, h, y]), {
|
|
992
|
+
columns: b,
|
|
993
|
+
key: o,
|
|
994
|
+
setKey: l,
|
|
995
|
+
operator: i,
|
|
996
|
+
setOperator: c,
|
|
997
|
+
type: u,
|
|
998
|
+
setType: d,
|
|
999
|
+
value: h,
|
|
1000
|
+
setValue: g,
|
|
1001
|
+
isRelation: y,
|
|
1002
|
+
setIsRelation: k,
|
|
1003
|
+
handleKey: S,
|
|
1004
|
+
handleOperator: w,
|
|
1005
|
+
handleRemoveColumn: x
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
const Ze = async (e, t, n) => {
|
|
1009
|
+
const a = e.getSchema().relations[t].model, { data: s } = await te().make(a).get(), o = s.all().filter((u) => !n.find((d) => d.getKey() === u.getKey())), l = o.length, i = n.length;
|
|
1010
|
+
console.log({
|
|
1011
|
+
newOptionsLength: l,
|
|
1012
|
+
loadedLength: i
|
|
1013
|
+
});
|
|
1014
|
+
const c = 15;
|
|
1015
|
+
return l + i > c ? O([...n, ...o.slice(0, c - i)]) : O([...n, ...o]);
|
|
1016
|
+
}, pr = async (e, t, n = "", a) => {
|
|
1017
|
+
const s = e.getSchema().relations[t], o = te().make(s.model), l = o.getSchema().primaryKey, { data: i } = await o.searchBy(n).get();
|
|
1018
|
+
return O([...a, ...i]).unique(l);
|
|
1019
|
+
}, hr = () => {
|
|
1020
|
+
const e = v(), t = K(), {
|
|
1021
|
+
key: n,
|
|
1022
|
+
value: a,
|
|
1023
|
+
setValue: s
|
|
1024
|
+
} = p.useContext(_), [o, l] = p.useState(!1), [i, c] = p.useState(""), [u, d] = p.useState(O([])), [h, g] = p.useState([]), y = p.useMemo(
|
|
1025
|
+
() => o && u.count() === 0,
|
|
1026
|
+
[o, u]
|
|
1027
|
+
), k = async (b, x) => {
|
|
1028
|
+
c(x), f.isEmpty(x) || d(await pr(t, n, x, O(h)));
|
|
1029
|
+
};
|
|
1030
|
+
return p.useEffect(() => {
|
|
1031
|
+
a.length > 0 && (async () => g(await ur(t, n, a)))();
|
|
1032
|
+
}, []), p.useEffect(() => {
|
|
1033
|
+
let b = !0;
|
|
1034
|
+
if (y)
|
|
1035
|
+
return (async () => b && d(await Ze(t, n, h)))(), () => {
|
|
1036
|
+
b = !1;
|
|
1037
|
+
};
|
|
1038
|
+
}, [y]), p.useEffect(() => {
|
|
1039
|
+
s(h.map((b) => b.getKey())), f.isEmpty(i) ? (async () => d(await Ze(t, n, h)))() : d(O([]));
|
|
1040
|
+
}, [h]), /* @__PURE__ */ r(
|
|
1041
|
+
Vt,
|
|
1042
|
+
{
|
|
1043
|
+
sx: { width: e ? 377 : "100%" },
|
|
1044
|
+
open: o,
|
|
1045
|
+
onOpen: () => {
|
|
1046
|
+
l(!0);
|
|
1047
|
+
},
|
|
1048
|
+
onClose: () => {
|
|
1049
|
+
l(!1);
|
|
1050
|
+
},
|
|
1051
|
+
value: h,
|
|
1052
|
+
onChange: (b, x) => {
|
|
1053
|
+
g(x);
|
|
1054
|
+
},
|
|
1055
|
+
inputValue: i,
|
|
1056
|
+
onInputChange: k,
|
|
1057
|
+
options: u.all() || [],
|
|
1058
|
+
getOptionLabel: (b) => b.getLabel(),
|
|
1059
|
+
isOptionEqualToValue: (b, x) => b.getKey() === x.getKey(),
|
|
1060
|
+
filterOptions: (b) => b,
|
|
1061
|
+
renderInput: (b) => /* @__PURE__ */ r(
|
|
1062
|
+
mr,
|
|
1063
|
+
{
|
|
1064
|
+
params: b,
|
|
1065
|
+
loading: y
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1068
|
+
size: "small",
|
|
1069
|
+
loading: y,
|
|
1070
|
+
disableCloseOnSelect: !0,
|
|
1071
|
+
autoHighlight: !0,
|
|
1072
|
+
multiple: !0
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
}, mr = ({ params: e, loading: t }) => {
|
|
1076
|
+
const { t: n } = I();
|
|
1077
|
+
return /* @__PURE__ */ r(
|
|
1078
|
+
re,
|
|
1079
|
+
{
|
|
1080
|
+
...e,
|
|
1081
|
+
label: n("Value"),
|
|
1082
|
+
InputProps: {
|
|
1083
|
+
...e.InputProps,
|
|
1084
|
+
endAdornment: /* @__PURE__ */ m(p.Fragment, { children: [
|
|
1085
|
+
t ? /* @__PURE__ */ r(Yt, { color: "inherit", size: 20 }) : null,
|
|
1086
|
+
e.InputProps.endAdornment
|
|
1087
|
+
] })
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
);
|
|
1091
|
+
}, me = ({ index: e = null }) => {
|
|
1092
|
+
const { t } = I(), n = v(), a = A("filter"), {
|
|
1093
|
+
type: s,
|
|
1094
|
+
value: o,
|
|
1095
|
+
setValue: l
|
|
1096
|
+
} = p.useContext(_), c = a.getInputType(s) === "datetime-local" ? 230 : 167.5, u = e !== null ? `${t("Date")} ${e + 1}` : `${t("Date")}`, d = p.useMemo(
|
|
1097
|
+
() => e !== null ? o[e] : o,
|
|
1098
|
+
[o]
|
|
1099
|
+
), h = (g) => {
|
|
1100
|
+
l(typeof e == "number" ? (y) => {
|
|
1101
|
+
const k = y;
|
|
1102
|
+
return k[e] = g.target.value, [...k];
|
|
1103
|
+
} : g.target.value);
|
|
1104
|
+
};
|
|
1105
|
+
return /* @__PURE__ */ r(
|
|
1106
|
+
re,
|
|
1107
|
+
{
|
|
1108
|
+
type: a.getInputType(s),
|
|
1109
|
+
label: u,
|
|
1110
|
+
value: d || /* @__PURE__ */ new Date(),
|
|
1111
|
+
onChange: h,
|
|
1112
|
+
size: "small",
|
|
1113
|
+
sx: { width: n ? c : "100%" }
|
|
1114
|
+
}
|
|
1115
|
+
);
|
|
1116
|
+
}, fr = () => {
|
|
1117
|
+
const e = v(), { value: t, setValue: n } = p.useContext(_);
|
|
1118
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
1119
|
+
/* @__PURE__ */ r(
|
|
1120
|
+
zt,
|
|
1121
|
+
{
|
|
1122
|
+
checked: t,
|
|
1123
|
+
onChange: (s) => {
|
|
1124
|
+
const o = s.target.checked;
|
|
1125
|
+
n(o ? 1 : 0);
|
|
1126
|
+
},
|
|
1127
|
+
inputProps: { "aria-label": "filter-controlled" },
|
|
1128
|
+
size: "small"
|
|
1129
|
+
}
|
|
1130
|
+
),
|
|
1131
|
+
e && /* @__PURE__ */ r(N, { width: 325 })
|
|
1132
|
+
] });
|
|
1133
|
+
}, fe = ({ index: e = null }) => {
|
|
1134
|
+
const { t } = I(), n = v(), a = A("filter"), {
|
|
1135
|
+
type: s,
|
|
1136
|
+
value: o,
|
|
1137
|
+
setValue: l
|
|
1138
|
+
} = p.useContext(_), i = e !== null ? `${t("Value")} ${e + 1}` : `${t("Value")}`, c = p.useMemo(
|
|
1139
|
+
() => e !== null ? o[e] : o,
|
|
1140
|
+
[o]
|
|
1141
|
+
), u = (d) => {
|
|
1142
|
+
l(typeof e == "number" ? (h) => {
|
|
1143
|
+
const g = h;
|
|
1144
|
+
return g[e] = d.target.value, [...g];
|
|
1145
|
+
} : d.target.value);
|
|
1146
|
+
};
|
|
1147
|
+
return /* @__PURE__ */ r(
|
|
1148
|
+
re,
|
|
1149
|
+
{
|
|
1150
|
+
type: a.getInputType(s),
|
|
1151
|
+
label: i,
|
|
1152
|
+
value: c || "",
|
|
1153
|
+
onChange: u,
|
|
1154
|
+
sx: { width: n ? 167.5 : "100%" },
|
|
1155
|
+
size: "small"
|
|
1156
|
+
}
|
|
1157
|
+
);
|
|
1158
|
+
}, ge = () => {
|
|
1159
|
+
const e = v(), t = A("filter"), { type: n, operator: a } = p.useContext(_), s = p.useMemo(
|
|
1160
|
+
() => ["between", "notBetween"].includes(a),
|
|
1161
|
+
[a]
|
|
1162
|
+
);
|
|
1163
|
+
if (["null", "notNull"].includes(a))
|
|
1164
|
+
return e ? /* @__PURE__ */ r(N, { width: 230 }) : null;
|
|
1165
|
+
if (s)
|
|
1166
|
+
switch (t.getInputType(n)) {
|
|
1167
|
+
case "date":
|
|
1168
|
+
case "datetime-local":
|
|
1169
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
1170
|
+
/* @__PURE__ */ r(me, { index: 0 }),
|
|
1171
|
+
/* @__PURE__ */ r(me, { index: 1 })
|
|
1172
|
+
] });
|
|
1173
|
+
default:
|
|
1174
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
1175
|
+
/* @__PURE__ */ r(fe, { index: 0 }),
|
|
1176
|
+
/* @__PURE__ */ r(fe, { index: 1 })
|
|
1177
|
+
] });
|
|
1178
|
+
}
|
|
1179
|
+
switch (t.getInputType(n)) {
|
|
1180
|
+
case "date":
|
|
1181
|
+
case "datetime-local":
|
|
1182
|
+
return /* @__PURE__ */ r(me, {});
|
|
1183
|
+
case "autocomplete":
|
|
1184
|
+
return /* @__PURE__ */ r(hr, {});
|
|
1185
|
+
case "boolean":
|
|
1186
|
+
return /* @__PURE__ */ r(fr, {});
|
|
1187
|
+
default:
|
|
1188
|
+
return /* @__PURE__ */ r(fe, {});
|
|
1189
|
+
}
|
|
1190
|
+
}, gr = ({ index: e, column: t }) => {
|
|
1191
|
+
const { t: n } = I(), a = v(), s = L("breakpoint", "md"), o = A("filter"), l = p.useMemo(() => o.getMatchingOperators(t), [t]), {
|
|
1192
|
+
columns: i,
|
|
1193
|
+
key: c,
|
|
1194
|
+
setKey: u,
|
|
1195
|
+
operator: d,
|
|
1196
|
+
setOperator: h,
|
|
1197
|
+
type: g,
|
|
1198
|
+
setType: y,
|
|
1199
|
+
value: k,
|
|
1200
|
+
setValue: b,
|
|
1201
|
+
isRelation: x,
|
|
1202
|
+
setIsRelation: S,
|
|
1203
|
+
handleKey: w,
|
|
1204
|
+
handleOperator: C,
|
|
1205
|
+
handleRemoveColumn: T
|
|
1206
|
+
} = dr(e, t), D = ["boolean"].includes(o.getInputType(g));
|
|
1207
|
+
return /* @__PURE__ */ r(
|
|
1208
|
+
_.Provider,
|
|
1209
|
+
{
|
|
1210
|
+
value: {
|
|
1211
|
+
key: c,
|
|
1212
|
+
setKey: u,
|
|
1213
|
+
type: g,
|
|
1214
|
+
setType: y,
|
|
1215
|
+
operator: d,
|
|
1216
|
+
setOperator: h,
|
|
1217
|
+
value: k,
|
|
1218
|
+
setValue: b,
|
|
1219
|
+
isRelation: x,
|
|
1220
|
+
setIsRelation: S
|
|
1221
|
+
},
|
|
1222
|
+
children: /* @__PURE__ */ m(
|
|
1223
|
+
Y,
|
|
1224
|
+
{
|
|
1225
|
+
container: !0,
|
|
1226
|
+
display: "flex",
|
|
1227
|
+
flexDirection: {
|
|
1228
|
+
xs: "column",
|
|
1229
|
+
[s]: "row"
|
|
1230
|
+
},
|
|
1231
|
+
flexWrap: {
|
|
1232
|
+
xs: "wrap",
|
|
1233
|
+
[s]: "nowrap"
|
|
1234
|
+
},
|
|
1235
|
+
alignItems: "center",
|
|
1236
|
+
justifyContent: "space-between",
|
|
1237
|
+
gap: 0.5,
|
|
1238
|
+
children: [
|
|
1239
|
+
/* @__PURE__ */ m(
|
|
1240
|
+
B,
|
|
1241
|
+
{
|
|
1242
|
+
display: "flex",
|
|
1243
|
+
flexDirection: {
|
|
1244
|
+
xs: "column",
|
|
1245
|
+
[s]: "row"
|
|
1246
|
+
},
|
|
1247
|
+
alignItems: "center",
|
|
1248
|
+
width: "100%",
|
|
1249
|
+
my: 1,
|
|
1250
|
+
gap: 1.5,
|
|
1251
|
+
children: [
|
|
1252
|
+
/* @__PURE__ */ m(
|
|
1253
|
+
B,
|
|
1254
|
+
{
|
|
1255
|
+
direction: "row",
|
|
1256
|
+
alignItems: "center",
|
|
1257
|
+
...!a && { width: "100%" },
|
|
1258
|
+
gap: 1,
|
|
1259
|
+
children: [
|
|
1260
|
+
/* @__PURE__ */ m(xe, { sx: {
|
|
1261
|
+
width: a ? 165 : `calc(100% - ${D ? 88 : 44}px)`
|
|
1262
|
+
}, children: [
|
|
1263
|
+
/* @__PURE__ */ r(
|
|
1264
|
+
we,
|
|
1265
|
+
{
|
|
1266
|
+
id: "filter-column-select-label",
|
|
1267
|
+
size: "small",
|
|
1268
|
+
children: n("Column")
|
|
1269
|
+
}
|
|
1270
|
+
),
|
|
1271
|
+
/* @__PURE__ */ r(
|
|
1272
|
+
se,
|
|
1273
|
+
{
|
|
1274
|
+
labelId: "filter-column-select-label",
|
|
1275
|
+
id: "filter-column-select",
|
|
1276
|
+
value: c,
|
|
1277
|
+
onChange: w,
|
|
1278
|
+
size: "small",
|
|
1279
|
+
children: i.map(({ key: M, label: $ }) => /* @__PURE__ */ r(
|
|
1280
|
+
Z,
|
|
1281
|
+
{
|
|
1282
|
+
value: M,
|
|
1283
|
+
children: $
|
|
1284
|
+
},
|
|
1285
|
+
`column_${M}_option`
|
|
1286
|
+
))
|
|
1287
|
+
}
|
|
1288
|
+
)
|
|
1289
|
+
] }),
|
|
1290
|
+
!a && /* @__PURE__ */ m(
|
|
1291
|
+
B,
|
|
1292
|
+
{
|
|
1293
|
+
direction: "row",
|
|
1294
|
+
alignItems: "center",
|
|
1295
|
+
children: [
|
|
1296
|
+
D && /* @__PURE__ */ r(ge, {}),
|
|
1297
|
+
/* @__PURE__ */ r(
|
|
1298
|
+
R,
|
|
1299
|
+
{
|
|
1300
|
+
color: "error",
|
|
1301
|
+
onClick: T(e),
|
|
1302
|
+
children: /* @__PURE__ */ r(Ye, {})
|
|
1303
|
+
}
|
|
1304
|
+
)
|
|
1305
|
+
]
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
]
|
|
1309
|
+
}
|
|
1310
|
+
),
|
|
1311
|
+
!x && !D && /* @__PURE__ */ m(xe, { sx: {
|
|
1312
|
+
width: a ? 135 : "100%"
|
|
1313
|
+
}, children: [
|
|
1314
|
+
/* @__PURE__ */ r(
|
|
1315
|
+
we,
|
|
1316
|
+
{
|
|
1317
|
+
id: "filter-operator-select-label",
|
|
1318
|
+
size: "small",
|
|
1319
|
+
children: n("Operator")
|
|
1320
|
+
}
|
|
1321
|
+
),
|
|
1322
|
+
/* @__PURE__ */ r(
|
|
1323
|
+
se,
|
|
1324
|
+
{
|
|
1325
|
+
labelId: "filter-operator-select-label",
|
|
1326
|
+
id: "filter-operator-select",
|
|
1327
|
+
value: d,
|
|
1328
|
+
onChange: C,
|
|
1329
|
+
size: "small",
|
|
1330
|
+
children: l.map(({ key: M, label: $ }) => /* @__PURE__ */ r(
|
|
1331
|
+
Z,
|
|
1332
|
+
{
|
|
1333
|
+
value: M,
|
|
1334
|
+
children: n($)
|
|
1335
|
+
},
|
|
1336
|
+
`operator_${M}_option`
|
|
1337
|
+
))
|
|
1338
|
+
}
|
|
1339
|
+
)
|
|
1340
|
+
] }),
|
|
1341
|
+
a ? /* @__PURE__ */ r(ge, {}) : !D && /* @__PURE__ */ r(ge, {})
|
|
1342
|
+
]
|
|
1343
|
+
},
|
|
1344
|
+
`filter_${c}_${e}`
|
|
1345
|
+
),
|
|
1346
|
+
a && /* @__PURE__ */ r(
|
|
1347
|
+
R,
|
|
1348
|
+
{
|
|
1349
|
+
color: "error",
|
|
1350
|
+
onClick: T(e),
|
|
1351
|
+
children: /* @__PURE__ */ r(Ye, {})
|
|
1352
|
+
}
|
|
1353
|
+
)
|
|
1354
|
+
]
|
|
1355
|
+
}
|
|
1356
|
+
)
|
|
1357
|
+
}
|
|
1358
|
+
);
|
|
1359
|
+
}, gt = (e) => {
|
|
1360
|
+
const t = {};
|
|
1361
|
+
for (const [n, a] of e.entries())
|
|
1362
|
+
f.set(t, n, a);
|
|
1363
|
+
return t;
|
|
1364
|
+
}, Ge = (e) => {
|
|
1365
|
+
const t = e instanceof Date ? e : new Date(e), n = `${t.getFullYear()}`, a = `${f.padStart(`${t.getMonth() + 1}`, 2, "0")}`, s = `${f.padStart(`${t.getDate()}`, 2, "0")}`, o = `${f.padStart(`${t.getHours()}`, 2, "0")}`, l = `${f.padStart(`${t.getMinutes()}`, 2, "0")}`;
|
|
1366
|
+
return `${n}-${a}-${s}T${o}:${l}`;
|
|
1367
|
+
}, br = (e, t) => {
|
|
1368
|
+
const n = A("filter"), a = gt(t), s = Object.keys(a).reduce((l, i) => (["where"].includes(i) && (l[i] = a[i]), l), {}), o = [];
|
|
1369
|
+
return Object.entries(s).forEach(([, l]) => {
|
|
1370
|
+
Object.entries(l).forEach(([i, c]) => {
|
|
1371
|
+
e.filter((u) => {
|
|
1372
|
+
const d = (() => {
|
|
1373
|
+
const g = f.camelCase(i.split(f.camelCase(u.key))[1]);
|
|
1374
|
+
return f.isEmpty(g) ? "equals" : g;
|
|
1375
|
+
})();
|
|
1376
|
+
if (!n.getOperators().includes(d))
|
|
1377
|
+
return !1;
|
|
1378
|
+
const h = f.snakeCase(i.split(f.upperFirst(d))[0]);
|
|
1379
|
+
return u.key === h;
|
|
1380
|
+
}).forEach((u) => {
|
|
1381
|
+
let d = f.camelCase(i.split(f.camelCase(u.key))[1]);
|
|
1382
|
+
(f.isUndefined(d) || f.isNull(d) || f.isEmpty(d)) && (d = "equals");
|
|
1383
|
+
let h = c;
|
|
1384
|
+
switch (n.getInputType(u.type)) {
|
|
1385
|
+
case "text": {
|
|
1386
|
+
Array.isArray(c) && (h = c.join(","));
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
case "datetime-local": {
|
|
1390
|
+
Array.isArray(c) ? h = c.map((g) => Ge(g)) : h = Ge(c);
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
case "boolean": {
|
|
1394
|
+
h = f.toNumber(c);
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
o.push({
|
|
1399
|
+
key: u.key,
|
|
1400
|
+
operator: d,
|
|
1401
|
+
type: u.type,
|
|
1402
|
+
value: h,
|
|
1403
|
+
is_relation: u.is_relation
|
|
1404
|
+
});
|
|
1405
|
+
});
|
|
1406
|
+
});
|
|
1407
|
+
}), o;
|
|
1408
|
+
}, yr = (e) => {
|
|
1409
|
+
const t = A("filter"), n = new URLSearchParams();
|
|
1410
|
+
return e.forEach((a) => {
|
|
1411
|
+
const { key: s, operator: o, value: l, type: i } = a;
|
|
1412
|
+
let c = f.upperFirst(o);
|
|
1413
|
+
if (["equals"].includes(c.toLowerCase()) && (c = ""), Array.isArray(l))
|
|
1414
|
+
l.forEach((u, d) => {
|
|
1415
|
+
let h = u;
|
|
1416
|
+
switch (t.getInputType(i)) {
|
|
1417
|
+
case "datetime-local": {
|
|
1418
|
+
h = new Date(u).toISOString();
|
|
1419
|
+
break;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
n.set(`where[${f.camelCase(s)}${c}][${d}]`, h);
|
|
1423
|
+
});
|
|
1424
|
+
else {
|
|
1425
|
+
let u = l;
|
|
1426
|
+
switch (t.getInputType(i)) {
|
|
1427
|
+
case "datetime-local": {
|
|
1428
|
+
u = new Date(l).toISOString();
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
n.set(`where[${f.camelCase(s)}${c}]`, u);
|
|
1433
|
+
}
|
|
1434
|
+
}), n;
|
|
1435
|
+
}, Qe = () => {
|
|
1436
|
+
const { t: e } = I(), t = v(), n = L("breakpoint", "md"), a = A("filter"), {
|
|
1437
|
+
columnsFilter: s,
|
|
1438
|
+
setColumnsFilter: o,
|
|
1439
|
+
setSearchParams: l,
|
|
1440
|
+
clearSearchParams: i,
|
|
1441
|
+
clearFilters: c
|
|
1442
|
+
} = p.useContext(Ne), u = () => {
|
|
1443
|
+
o((h) => [
|
|
1444
|
+
...h,
|
|
1445
|
+
{
|
|
1446
|
+
key: "",
|
|
1447
|
+
operator: "equals",
|
|
1448
|
+
type: "text",
|
|
1449
|
+
value: "",
|
|
1450
|
+
is_relation: !1
|
|
1451
|
+
}
|
|
1452
|
+
]);
|
|
1453
|
+
}, d = () => {
|
|
1454
|
+
i();
|
|
1455
|
+
const h = yr(s);
|
|
1456
|
+
l(h, { replace: !0 });
|
|
1457
|
+
};
|
|
1458
|
+
return /* @__PURE__ */ m(
|
|
1459
|
+
N,
|
|
1460
|
+
{
|
|
1461
|
+
sx: { minWidth: { [n]: 567.5 } },
|
|
1462
|
+
p: 2,
|
|
1463
|
+
children: [
|
|
1464
|
+
/* @__PURE__ */ r(B, { children: s.map((h, g) => /* @__PURE__ */ m(F, { children: [
|
|
1465
|
+
/* @__PURE__ */ r(
|
|
1466
|
+
gr,
|
|
1467
|
+
{
|
|
1468
|
+
index: g,
|
|
1469
|
+
column: h
|
|
1470
|
+
},
|
|
1471
|
+
`row_${h.key}`
|
|
1472
|
+
),
|
|
1473
|
+
!t && /* @__PURE__ */ r(oe, { sx: {
|
|
1474
|
+
mt: 1.25,
|
|
1475
|
+
mb: 1.5
|
|
1476
|
+
} })
|
|
1477
|
+
] })) }),
|
|
1478
|
+
/* @__PURE__ */ r(B, { mt: 0.75, children: /* @__PURE__ */ r(
|
|
1479
|
+
E,
|
|
1480
|
+
{
|
|
1481
|
+
variant: "outlined",
|
|
1482
|
+
onClick: u,
|
|
1483
|
+
fullWidth: !0,
|
|
1484
|
+
children: `+ ${e("Add Column")}`
|
|
1485
|
+
}
|
|
1486
|
+
) }),
|
|
1487
|
+
/* @__PURE__ */ m(
|
|
1488
|
+
B,
|
|
1489
|
+
{
|
|
1490
|
+
direction: "row",
|
|
1491
|
+
justifyContent: "space-between",
|
|
1492
|
+
mt: 2,
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ r(E, { onClick: c, children: e("Clear") }),
|
|
1495
|
+
/* @__PURE__ */ r(
|
|
1496
|
+
E,
|
|
1497
|
+
{
|
|
1498
|
+
variant: "contained",
|
|
1499
|
+
onClick: d,
|
|
1500
|
+
disabled: a.checkIfCanApplyFilters(s),
|
|
1501
|
+
children: e("Apply")
|
|
1502
|
+
}
|
|
1503
|
+
)
|
|
1504
|
+
]
|
|
1505
|
+
}
|
|
1506
|
+
)
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
}, xr = () => {
|
|
1511
|
+
const e = A("filter"), t = v(), n = K(), [a, s] = q(), o = p.useMemo(() => "where" in gt(a), [a]), [l, i] = p.useState(null), [c, u] = p.useState([]), d = !!l, h = p.useMemo(() => e.getFilterableColumns(n), [n]), g = (x) => {
|
|
1512
|
+
i(x.currentTarget);
|
|
1513
|
+
}, y = () => {
|
|
1514
|
+
i(null), setTimeout(() => {
|
|
1515
|
+
u([]);
|
|
1516
|
+
}, 300);
|
|
1517
|
+
}, k = () => {
|
|
1518
|
+
s((x) => {
|
|
1519
|
+
const S = new URLSearchParams(x);
|
|
1520
|
+
for (const [w] of x.entries())
|
|
1521
|
+
w.startsWith("where[") && S.delete(w);
|
|
1522
|
+
return S;
|
|
1523
|
+
});
|
|
1524
|
+
}, b = () => {
|
|
1525
|
+
k(), setTimeout(() => {
|
|
1526
|
+
u([]);
|
|
1527
|
+
}, 300);
|
|
1528
|
+
};
|
|
1529
|
+
return p.useEffect(() => {
|
|
1530
|
+
const x = br(h, a);
|
|
1531
|
+
u(x);
|
|
1532
|
+
}, [h, a, l]), /* @__PURE__ */ m(
|
|
1533
|
+
Ne.Provider,
|
|
1534
|
+
{
|
|
1535
|
+
value: {
|
|
1536
|
+
Model: n,
|
|
1537
|
+
anchorEl: l,
|
|
1538
|
+
setAnchorEl: i,
|
|
1539
|
+
columnsFilter: c,
|
|
1540
|
+
setColumnsFilter: u,
|
|
1541
|
+
searchParams: a,
|
|
1542
|
+
setSearchParams: s,
|
|
1543
|
+
clearSearchParams: k,
|
|
1544
|
+
clearFilters: b
|
|
1545
|
+
},
|
|
1546
|
+
children: [
|
|
1547
|
+
/* @__PURE__ */ r(
|
|
1548
|
+
R,
|
|
1549
|
+
{
|
|
1550
|
+
"aria-describedby": "model-filter-popover-button",
|
|
1551
|
+
"aria-label": "filter",
|
|
1552
|
+
onClick: g,
|
|
1553
|
+
children: /* @__PURE__ */ r(
|
|
1554
|
+
Te,
|
|
1555
|
+
{
|
|
1556
|
+
color: "secondary",
|
|
1557
|
+
variant: "dot",
|
|
1558
|
+
invisible: !o,
|
|
1559
|
+
children: /* @__PURE__ */ r(ln, {})
|
|
1560
|
+
}
|
|
1561
|
+
)
|
|
1562
|
+
}
|
|
1563
|
+
),
|
|
1564
|
+
t ? /* @__PURE__ */ r(
|
|
1565
|
+
Kt,
|
|
1566
|
+
{
|
|
1567
|
+
id: "model-filter-popover",
|
|
1568
|
+
open: d,
|
|
1569
|
+
anchorEl: l,
|
|
1570
|
+
onClose: y,
|
|
1571
|
+
anchorOrigin: {
|
|
1572
|
+
vertical: "bottom",
|
|
1573
|
+
horizontal: "left"
|
|
1574
|
+
},
|
|
1575
|
+
children: /* @__PURE__ */ r(Qe, {})
|
|
1576
|
+
}
|
|
1577
|
+
) : /* @__PURE__ */ r(
|
|
1578
|
+
ve,
|
|
1579
|
+
{
|
|
1580
|
+
open: d,
|
|
1581
|
+
onClose: y,
|
|
1582
|
+
fullWidth: !0,
|
|
1583
|
+
children: /* @__PURE__ */ r(Qe, {})
|
|
1584
|
+
}
|
|
1585
|
+
)
|
|
1586
|
+
]
|
|
1587
|
+
}
|
|
1588
|
+
);
|
|
1589
|
+
}, je = p.createContext({
|
|
1590
|
+
columns: [],
|
|
1591
|
+
columnCount: 0,
|
|
1592
|
+
selected: O([]),
|
|
1593
|
+
massActions: [],
|
|
1594
|
+
items: O([]),
|
|
1595
|
+
error: new Error("Trying to access TableContext outside of TableProvider"),
|
|
1596
|
+
Model: null
|
|
1597
|
+
});
|
|
1598
|
+
function qe() {
|
|
1599
|
+
const {
|
|
1600
|
+
selected: e,
|
|
1601
|
+
items: t
|
|
1602
|
+
} = p.useContext(je), n = _e(e), a = () => {
|
|
1603
|
+
e.splice(0, e.count());
|
|
1604
|
+
}, s = (u) => {
|
|
1605
|
+
const d = e.search(u);
|
|
1606
|
+
if (d !== !1) {
|
|
1607
|
+
e.pull(d);
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
e.push(u);
|
|
1611
|
+
}, o = () => {
|
|
1612
|
+
if (t) {
|
|
1613
|
+
if (e.count() === t.count()) {
|
|
1614
|
+
a();
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
e.splice(0, e.count(), ...t);
|
|
1618
|
+
}
|
|
1619
|
+
}, l = (u) => n.contains(u), i = t ? n.count() > 0 && n.count() < t.count() : !1, c = t && t.count() ? n.count() === t.count() : !1;
|
|
1620
|
+
return {
|
|
1621
|
+
selected: n,
|
|
1622
|
+
indeterminate: i,
|
|
1623
|
+
allSelected: c,
|
|
1624
|
+
isSelected: l,
|
|
1625
|
+
handleClearSelected: a,
|
|
1626
|
+
handleSelectToggle: s,
|
|
1627
|
+
handleSelectToggleAll: o
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
function G() {
|
|
1631
|
+
return p.useContext(je);
|
|
1632
|
+
}
|
|
1633
|
+
function wr(e) {
|
|
1634
|
+
const [t, n] = p.useState(""), { selected: a } = qe(), { t: s } = I(), o = Oe(), { massActions: l } = G(), i = (u) => {
|
|
1635
|
+
n(u.target.value);
|
|
1636
|
+
};
|
|
1637
|
+
if (p.useEffect(() => {
|
|
1638
|
+
a.isEmpty() && n("");
|
|
1639
|
+
}, [a]), l.length === 0)
|
|
1640
|
+
return null;
|
|
1641
|
+
const c = a.isEmpty() ? s("Select items to apply") : s("Select action");
|
|
1642
|
+
return /* @__PURE__ */ m(
|
|
1643
|
+
B,
|
|
1644
|
+
{
|
|
1645
|
+
direction: "row",
|
|
1646
|
+
alignItems: "center",
|
|
1647
|
+
...e,
|
|
1648
|
+
children: [
|
|
1649
|
+
/* @__PURE__ */ m(
|
|
1650
|
+
xe,
|
|
1651
|
+
{
|
|
1652
|
+
sx: { m: 1, minWidth: 200 },
|
|
1653
|
+
size: "small",
|
|
1654
|
+
children: [
|
|
1655
|
+
/* @__PURE__ */ r(we, { id: "mass-actions-select-label", children: c }),
|
|
1656
|
+
/* @__PURE__ */ m(
|
|
1657
|
+
se,
|
|
1658
|
+
{
|
|
1659
|
+
labelId: "mass-actions-select-label",
|
|
1660
|
+
id: "mass-actions-select",
|
|
1661
|
+
value: t,
|
|
1662
|
+
label: c,
|
|
1663
|
+
onChange: i,
|
|
1664
|
+
disabled: a.isEmpty(),
|
|
1665
|
+
children: [
|
|
1666
|
+
/* @__PURE__ */ r(Z, { value: "", children: /* @__PURE__ */ r("em", { children: s("None") }) }),
|
|
1667
|
+
l.map((u) => /* @__PURE__ */ r(
|
|
1668
|
+
Z,
|
|
1669
|
+
{
|
|
1670
|
+
value: u.key,
|
|
1671
|
+
children: u.label
|
|
1672
|
+
},
|
|
1673
|
+
u.key
|
|
1674
|
+
))
|
|
1675
|
+
]
|
|
1676
|
+
}
|
|
1677
|
+
)
|
|
1678
|
+
]
|
|
1679
|
+
}
|
|
1680
|
+
),
|
|
1681
|
+
/* @__PURE__ */ r(
|
|
1682
|
+
E,
|
|
1683
|
+
{
|
|
1684
|
+
size: "small",
|
|
1685
|
+
disabled: a.isEmpty() || !t,
|
|
1686
|
+
onClick: () => {
|
|
1687
|
+
var u;
|
|
1688
|
+
(u = l.find((d) => d.key === t)) == null || u.callback({
|
|
1689
|
+
selected: a,
|
|
1690
|
+
...o
|
|
1691
|
+
});
|
|
1692
|
+
},
|
|
1693
|
+
children: s("Apply")
|
|
1694
|
+
}
|
|
1695
|
+
)
|
|
1696
|
+
]
|
|
1697
|
+
}
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
const Sr = () => {
|
|
1701
|
+
const { handleDrawerOpen: e } = Re();
|
|
1702
|
+
return /* @__PURE__ */ r(
|
|
1703
|
+
R,
|
|
1704
|
+
{
|
|
1705
|
+
color: "inherit",
|
|
1706
|
+
"aria-label": "open drawer",
|
|
1707
|
+
edge: "start",
|
|
1708
|
+
onClick: e,
|
|
1709
|
+
sx: { mr: { md: 2 } },
|
|
1710
|
+
children: /* @__PURE__ */ r(cn, {})
|
|
1711
|
+
}
|
|
1712
|
+
);
|
|
1713
|
+
}, ie = p.forwardRef(({ to: e, children: t, ...n }, a) => /* @__PURE__ */ r(
|
|
1714
|
+
Se,
|
|
1715
|
+
{
|
|
1716
|
+
component: ae,
|
|
1717
|
+
to: e,
|
|
1718
|
+
ref: a,
|
|
1719
|
+
sx: { textDecoration: "none" },
|
|
1720
|
+
...n,
|
|
1721
|
+
children: t
|
|
1722
|
+
}
|
|
1723
|
+
));
|
|
1724
|
+
ie.displayName = "Link";
|
|
1725
|
+
const kr = ({ label: e }) => isNaN(e) || isNaN(parseFloat(e)) ? /* @__PURE__ */ r(F, { children: {
|
|
1726
|
+
"« Previous": /* @__PURE__ */ r(Ie, {}),
|
|
1727
|
+
"Next »": /* @__PURE__ */ r(Pe, {}),
|
|
1728
|
+
"Last »": /* @__PURE__ */ r(un, {}),
|
|
1729
|
+
"« First": /* @__PURE__ */ r(dn, {})
|
|
1730
|
+
}[e] || e }) : /* @__PURE__ */ r(F, { children: e }), Ar = ({ variant: e = "default", ...t }) => {
|
|
1731
|
+
const n = e === "default", [a, s] = q(), [o, l] = p.useState(a.get("page") || "1"), {
|
|
1732
|
+
links: i,
|
|
1733
|
+
meta: {
|
|
1734
|
+
current_page: c = 1,
|
|
1735
|
+
links: u = [],
|
|
1736
|
+
last_page: d = 1
|
|
1737
|
+
} = {}
|
|
1738
|
+
} = ne(), {
|
|
1739
|
+
first: h,
|
|
1740
|
+
prev: g,
|
|
1741
|
+
next: y,
|
|
1742
|
+
last: k
|
|
1743
|
+
} = i || {}, b = (S) => {
|
|
1744
|
+
S.preventDefault(), s((w) => (w.set("page", o || "1"), w));
|
|
1745
|
+
}, x = [
|
|
1746
|
+
{ url: c > 1 ? h : null, label: "« First", active: !1 },
|
|
1747
|
+
{ url: g, label: "« Previous", active: !1 },
|
|
1748
|
+
{
|
|
1749
|
+
element: /* @__PURE__ */ r(
|
|
1750
|
+
At,
|
|
1751
|
+
{
|
|
1752
|
+
onSubmit: b,
|
|
1753
|
+
preventScrollReset: !0,
|
|
1754
|
+
children: /* @__PURE__ */ r(
|
|
1755
|
+
re,
|
|
1756
|
+
{
|
|
1757
|
+
size: "small",
|
|
1758
|
+
type: "number",
|
|
1759
|
+
variant: "standard",
|
|
1760
|
+
sx: {
|
|
1761
|
+
width: 56,
|
|
1762
|
+
"& input": {
|
|
1763
|
+
textAlign: "center",
|
|
1764
|
+
"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button": {
|
|
1765
|
+
WebkitAppearance: "none",
|
|
1766
|
+
margin: 0
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
},
|
|
1770
|
+
value: o,
|
|
1771
|
+
error: Number(o) > d,
|
|
1772
|
+
helperText: Number(o) > d ? `Max ${d}` : void 0,
|
|
1773
|
+
onChange: (S) => {
|
|
1774
|
+
!Number.isNaN(Number(S.target.value)) && Number(S.target.value) > 0 && l(S.target.value), S.target.value === "" && l("");
|
|
1775
|
+
},
|
|
1776
|
+
onBlur: (S) => {
|
|
1777
|
+
s((w) => (w.set("page", S.target.value || "1"), w), { replace: !0 });
|
|
1778
|
+
},
|
|
1779
|
+
disabled: d === 1,
|
|
1780
|
+
"aria-label": "Page number"
|
|
1781
|
+
}
|
|
1782
|
+
)
|
|
1783
|
+
},
|
|
1784
|
+
"page"
|
|
1785
|
+
)
|
|
1786
|
+
},
|
|
1787
|
+
{ url: y, label: "Next »", active: !1 },
|
|
1788
|
+
{ url: c < d ? k : null, label: "Last »", active: !1 }
|
|
1789
|
+
];
|
|
1790
|
+
return p.useEffect(() => {
|
|
1791
|
+
c && l(String(c));
|
|
1792
|
+
}, [c]), /* @__PURE__ */ r(
|
|
1793
|
+
B,
|
|
1794
|
+
{
|
|
1795
|
+
spacing: 1,
|
|
1796
|
+
direction: "row",
|
|
1797
|
+
justifyContent: "center",
|
|
1798
|
+
alignItems: "center",
|
|
1799
|
+
...t,
|
|
1800
|
+
children: (n ? u : x).map((S, w) => S.element || /* @__PURE__ */ r(
|
|
1801
|
+
E,
|
|
1802
|
+
{
|
|
1803
|
+
variant: S.active ? "contained" : "text",
|
|
1804
|
+
color: "primary",
|
|
1805
|
+
size: "small",
|
|
1806
|
+
sx: {
|
|
1807
|
+
minWidth: "unset",
|
|
1808
|
+
width: 32,
|
|
1809
|
+
height: 32,
|
|
1810
|
+
borderRadius: "50%"
|
|
1811
|
+
},
|
|
1812
|
+
disabled: !S.url,
|
|
1813
|
+
component: ie,
|
|
1814
|
+
to: S.url,
|
|
1815
|
+
children: /* @__PURE__ */ r(kr, { label: S.label })
|
|
1816
|
+
},
|
|
1817
|
+
w
|
|
1818
|
+
))
|
|
1819
|
+
}
|
|
1820
|
+
);
|
|
1821
|
+
}, Cr = () => {
|
|
1822
|
+
const { t: e } = I(), {
|
|
1823
|
+
meta: {
|
|
1824
|
+
total: t = 0,
|
|
1825
|
+
from: n = 0,
|
|
1826
|
+
to: a = 0
|
|
1827
|
+
} = {}
|
|
1828
|
+
} = ne();
|
|
1829
|
+
return /* @__PURE__ */ r(j, { variant: "caption", noWrap: !0, children: e(":from–:to of :total", {
|
|
1830
|
+
from: n,
|
|
1831
|
+
to: a,
|
|
1832
|
+
total: t
|
|
1833
|
+
}) });
|
|
1834
|
+
}, vr = () => {
|
|
1835
|
+
const { t: e } = I(), {
|
|
1836
|
+
meta: {
|
|
1837
|
+
per_page: t = 15
|
|
1838
|
+
} = {}
|
|
1839
|
+
} = ne(), [, n] = q(), a = (o) => {
|
|
1840
|
+
n((l) => {
|
|
1841
|
+
const i = new URLSearchParams(l);
|
|
1842
|
+
return i.set("per_page", o.target.value.toString()), i;
|
|
1843
|
+
});
|
|
1844
|
+
}, s = Ce(
|
|
1845
|
+
A("cms"),
|
|
1846
|
+
"perPageOptions",
|
|
1847
|
+
[15, 30, 75, 150]
|
|
1848
|
+
);
|
|
1849
|
+
return /* @__PURE__ */ m(
|
|
1850
|
+
B,
|
|
1851
|
+
{
|
|
1852
|
+
direction: "row",
|
|
1853
|
+
alignItems: "center",
|
|
1854
|
+
gap: 1,
|
|
1855
|
+
children: [
|
|
1856
|
+
/* @__PURE__ */ m(j, { variant: "caption", children: [
|
|
1857
|
+
e("Rows per page"),
|
|
1858
|
+
":"
|
|
1859
|
+
] }),
|
|
1860
|
+
/* @__PURE__ */ r(
|
|
1861
|
+
se,
|
|
1862
|
+
{
|
|
1863
|
+
value: t,
|
|
1864
|
+
onChange: a,
|
|
1865
|
+
size: "small",
|
|
1866
|
+
variant: "standard",
|
|
1867
|
+
sx: {
|
|
1868
|
+
fontSize: (o) => o.typography.caption.fontSize,
|
|
1869
|
+
"& .MuiSelect-select": {
|
|
1870
|
+
py: 0.5
|
|
1871
|
+
}
|
|
1872
|
+
},
|
|
1873
|
+
children: s.map((o) => /* @__PURE__ */ r(
|
|
1874
|
+
Z,
|
|
1875
|
+
{
|
|
1876
|
+
value: o,
|
|
1877
|
+
sx: {
|
|
1878
|
+
fontSize: (l) => l.typography.caption.fontSize,
|
|
1879
|
+
minHeight: "unset",
|
|
1880
|
+
lineHeight: 1,
|
|
1881
|
+
py: 1.5
|
|
1882
|
+
},
|
|
1883
|
+
children: o
|
|
1884
|
+
},
|
|
1885
|
+
o
|
|
1886
|
+
))
|
|
1887
|
+
}
|
|
1888
|
+
)
|
|
1889
|
+
]
|
|
1890
|
+
}
|
|
1891
|
+
);
|
|
1892
|
+
};
|
|
1893
|
+
function Dr(e, t) {
|
|
1894
|
+
const [n, a] = p.useState(!1);
|
|
1895
|
+
return p.useEffect(() => {
|
|
1896
|
+
const s = /* @__PURE__ */ new Set(), o = (i) => {
|
|
1897
|
+
s.add(i.key), e.every((c) => s.has(c)) && (a(!0), t && t());
|
|
1898
|
+
}, l = (i) => {
|
|
1899
|
+
s.delete(i.key), e.every((c) => !s.has(c)) && a(!1);
|
|
1900
|
+
};
|
|
1901
|
+
return window.addEventListener("keydown", o), window.addEventListener("keyup", l), () => {
|
|
1902
|
+
window.removeEventListener("keydown", o), window.removeEventListener("keyup", l);
|
|
1903
|
+
};
|
|
1904
|
+
}, [e, t]), n;
|
|
1905
|
+
}
|
|
1906
|
+
const Tr = U(re)(({ theme: e }) => ({
|
|
1907
|
+
"& .MuiInputBase-root": {
|
|
1908
|
+
backgroundColor: e.palette.background.paper
|
|
1909
|
+
}
|
|
1910
|
+
// transition: 'width 250ms ease-in-out',
|
|
1911
|
+
})), Fr = f.throttle((e, t) => {
|
|
1912
|
+
t((n) => {
|
|
1913
|
+
const a = new URLSearchParams(n);
|
|
1914
|
+
return e ? a.set("q", e) : a.delete("q"), a;
|
|
1915
|
+
});
|
|
1916
|
+
}, 500), Ir = () => {
|
|
1917
|
+
const [e, t] = q(), n = e.get("q") || "", [a, s] = p.useState(n), [o, l] = p.useState(!1), i = p.useRef(null), { t: c } = I();
|
|
1918
|
+
p.useEffect(() => {
|
|
1919
|
+
s(n);
|
|
1920
|
+
}, [n]);
|
|
1921
|
+
const u = (g) => {
|
|
1922
|
+
s(g.target.value), Fr(g.target.value, t);
|
|
1923
|
+
}, d = v();
|
|
1924
|
+
Dr(["Control", "/"], () => {
|
|
1925
|
+
i.current.focus();
|
|
1926
|
+
});
|
|
1927
|
+
const h = d ? 300 : "calc(100vw - 58px)";
|
|
1928
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
1929
|
+
!d && !o && /* @__PURE__ */ r(R, { color: "inherit", onClick: () => l(!0), children: /* @__PURE__ */ r(
|
|
1930
|
+
Te,
|
|
1931
|
+
{
|
|
1932
|
+
variant: "dot",
|
|
1933
|
+
color: "secondary",
|
|
1934
|
+
invisible: !n,
|
|
1935
|
+
anchorOrigin: {
|
|
1936
|
+
vertical: "bottom",
|
|
1937
|
+
horizontal: "left"
|
|
1938
|
+
},
|
|
1939
|
+
children: /* @__PURE__ */ r(ze, {})
|
|
1940
|
+
}
|
|
1941
|
+
) }),
|
|
1942
|
+
/* @__PURE__ */ r(
|
|
1943
|
+
ot,
|
|
1944
|
+
{
|
|
1945
|
+
orientation: "horizontal",
|
|
1946
|
+
in: d || o,
|
|
1947
|
+
addEndListener: () => {
|
|
1948
|
+
var g;
|
|
1949
|
+
!d && o && ((g = i.current) == null || g.focus());
|
|
1950
|
+
},
|
|
1951
|
+
unmountOnExit: !1,
|
|
1952
|
+
children: /* @__PURE__ */ r(
|
|
1953
|
+
Tr,
|
|
1954
|
+
{
|
|
1955
|
+
placeholder: d ? `(Ctrl + /) ${c("Search...")}` : `${c("Search...")}`,
|
|
1956
|
+
value: a,
|
|
1957
|
+
InputProps: {
|
|
1958
|
+
endAdornment: /* @__PURE__ */ r(ze, {})
|
|
1959
|
+
},
|
|
1960
|
+
inputProps: {
|
|
1961
|
+
ref: i
|
|
1962
|
+
},
|
|
1963
|
+
onChange: u,
|
|
1964
|
+
onBlur: () => l(!1),
|
|
1965
|
+
sx: { width: h },
|
|
1966
|
+
size: "small"
|
|
1967
|
+
}
|
|
1968
|
+
)
|
|
1969
|
+
}
|
|
1970
|
+
)
|
|
1971
|
+
] });
|
|
1972
|
+
}, Pr = ({ children: e, ...t }) => /* @__PURE__ */ r(
|
|
1973
|
+
z,
|
|
1974
|
+
{
|
|
1975
|
+
sx: { width: "1px" },
|
|
1976
|
+
padding: "checkbox",
|
|
1977
|
+
...t,
|
|
1978
|
+
children: e
|
|
1979
|
+
}
|
|
1980
|
+
), Mr = () => {
|
|
1981
|
+
const { t: e } = I(), [t, n] = q(), {
|
|
1982
|
+
columns: a,
|
|
1983
|
+
Model: s
|
|
1984
|
+
} = G(), o = t.get("order_by") || "", [l = "", i = ""] = o.split(":"), [c, u] = p.useState(l), [d, h] = p.useState(i), [g, y] = p.useState(!1), k = () => {
|
|
1985
|
+
y(!0);
|
|
1986
|
+
}, b = () => {
|
|
1987
|
+
y(!1), u(l), h(i);
|
|
1988
|
+
}, x = () => {
|
|
1989
|
+
if (!c || !d) {
|
|
1990
|
+
y(!1);
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
n((w) => {
|
|
1994
|
+
const C = new URLSearchParams(w);
|
|
1995
|
+
return C.set("order_by", `${c}:${d}`), C;
|
|
1996
|
+
}), y(!1);
|
|
1997
|
+
}, S = () => {
|
|
1998
|
+
n((w) => {
|
|
1999
|
+
const C = new URLSearchParams(w);
|
|
2000
|
+
return C.delete("order_by"), C;
|
|
2001
|
+
}), y(!1), u(""), h("");
|
|
2002
|
+
};
|
|
2003
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
2004
|
+
/* @__PURE__ */ r(R, { onClick: k, children: /* @__PURE__ */ r(
|
|
2005
|
+
Te,
|
|
2006
|
+
{
|
|
2007
|
+
color: "secondary",
|
|
2008
|
+
variant: "dot",
|
|
2009
|
+
invisible: !l,
|
|
2010
|
+
children: /* @__PURE__ */ r(pn, {})
|
|
2011
|
+
}
|
|
2012
|
+
) }),
|
|
2013
|
+
/* @__PURE__ */ m(ve, { open: g, onClose: b, fullWidth: !0, children: [
|
|
2014
|
+
/* @__PURE__ */ m(et, { children: [
|
|
2015
|
+
e("Sort :model", { model: s.plural() }),
|
|
2016
|
+
/* @__PURE__ */ r(
|
|
2017
|
+
R,
|
|
2018
|
+
{
|
|
2019
|
+
onClick: b,
|
|
2020
|
+
sx: { position: "absolute", right: 8, top: 8 },
|
|
2021
|
+
children: /* @__PURE__ */ r(ut, {})
|
|
2022
|
+
}
|
|
2023
|
+
)
|
|
2024
|
+
] }),
|
|
2025
|
+
/* @__PURE__ */ m(tt, { dividers: !0, children: [
|
|
2026
|
+
/* @__PURE__ */ m(
|
|
2027
|
+
We,
|
|
2028
|
+
{
|
|
2029
|
+
value: c,
|
|
2030
|
+
onChange: (w) => {
|
|
2031
|
+
u(w.target.value), d || h("asc");
|
|
2032
|
+
},
|
|
2033
|
+
children: [
|
|
2034
|
+
/* @__PURE__ */ r(j, { variant: "caption", children: e("Column") }),
|
|
2035
|
+
/* @__PURE__ */ r(oe, {}),
|
|
2036
|
+
O(a).whereStrict("sortable", "!=", !1).map(({ key: w, label: C }) => /* @__PURE__ */ r(
|
|
2037
|
+
ue,
|
|
2038
|
+
{
|
|
2039
|
+
value: w,
|
|
2040
|
+
control: /* @__PURE__ */ r(de, {}),
|
|
2041
|
+
label: C
|
|
2042
|
+
},
|
|
2043
|
+
w
|
|
2044
|
+
))
|
|
2045
|
+
]
|
|
2046
|
+
}
|
|
2047
|
+
),
|
|
2048
|
+
/* @__PURE__ */ r(j, { variant: "caption", children: e("Direction") }),
|
|
2049
|
+
/* @__PURE__ */ r(oe, {}),
|
|
2050
|
+
/* @__PURE__ */ m(
|
|
2051
|
+
We,
|
|
2052
|
+
{
|
|
2053
|
+
value: d,
|
|
2054
|
+
onChange: (w) => h(w.target.value),
|
|
2055
|
+
children: [
|
|
2056
|
+
/* @__PURE__ */ r(
|
|
2057
|
+
ue,
|
|
2058
|
+
{
|
|
2059
|
+
value: "asc",
|
|
2060
|
+
control: /* @__PURE__ */ r(de, {}),
|
|
2061
|
+
label: /* @__PURE__ */ m(F, { children: [
|
|
2062
|
+
e("Ascending"),
|
|
2063
|
+
/* @__PURE__ */ r(hn, {})
|
|
2064
|
+
] })
|
|
2065
|
+
}
|
|
2066
|
+
),
|
|
2067
|
+
/* @__PURE__ */ r(
|
|
2068
|
+
ue,
|
|
2069
|
+
{
|
|
2070
|
+
value: "desc",
|
|
2071
|
+
control: /* @__PURE__ */ r(de, {}),
|
|
2072
|
+
label: /* @__PURE__ */ m(F, { children: [
|
|
2073
|
+
e("Descending"),
|
|
2074
|
+
/* @__PURE__ */ r(mn, {})
|
|
2075
|
+
] })
|
|
2076
|
+
}
|
|
2077
|
+
)
|
|
2078
|
+
]
|
|
2079
|
+
}
|
|
2080
|
+
)
|
|
2081
|
+
] }),
|
|
2082
|
+
/* @__PURE__ */ m(nt, { children: [
|
|
2083
|
+
/* @__PURE__ */ r(E, { onClick: S, sx: { mr: "auto" }, children: e("Clear") }),
|
|
2084
|
+
/* @__PURE__ */ r(E, { onClick: x, variant: "contained", children: e("Apply") })
|
|
2085
|
+
] })
|
|
2086
|
+
] })
|
|
2087
|
+
] });
|
|
2088
|
+
}, Br = ({ items: e, loading: t, children: n, error: a }) => {
|
|
2089
|
+
const s = K(), o = p.useMemo(() => O([]), [s, e]), [l] = q(), i = l.get("tab") ?? "all", c = p.useMemo(() => [
|
|
2090
|
+
{
|
|
2091
|
+
key: s.getSchema().labeledBy,
|
|
2092
|
+
label: f.upperFirst(f.camelCase(s.getSchema().labeledBy))
|
|
2093
|
+
}
|
|
2094
|
+
], [s]), u = v(), d = p.useMemo(() => A("cms").getMassActions(s, i), [s, i]), h = Ce(
|
|
2095
|
+
A("cms"),
|
|
2096
|
+
`model${f.upperFirst(f.camelCase(s.getSchemaName()))}Columns`,
|
|
2097
|
+
c
|
|
2098
|
+
), y = (u ? h.length : 1) + (d.length > 0 ? 2 : 1), k = {
|
|
2099
|
+
columns: h,
|
|
2100
|
+
columnCount: y,
|
|
2101
|
+
massActions: d,
|
|
2102
|
+
items: e,
|
|
2103
|
+
loading: t,
|
|
2104
|
+
selected: o,
|
|
2105
|
+
error: a,
|
|
2106
|
+
Model: s
|
|
2107
|
+
};
|
|
2108
|
+
return /* @__PURE__ */ r(je.Provider, { value: k, children: n });
|
|
2109
|
+
}, Er = ({
|
|
2110
|
+
items: e,
|
|
2111
|
+
loading: t,
|
|
2112
|
+
error: n,
|
|
2113
|
+
children: a,
|
|
2114
|
+
...s
|
|
2115
|
+
}) => /* @__PURE__ */ r(
|
|
2116
|
+
Br,
|
|
2117
|
+
{
|
|
2118
|
+
items: e,
|
|
2119
|
+
loading: t,
|
|
2120
|
+
error: n,
|
|
2121
|
+
children: /* @__PURE__ */ r($t, { component: De, children: /* @__PURE__ */ r(Ht, { ...s, children: a }) })
|
|
2122
|
+
}
|
|
2123
|
+
), Lr = ({ children: e, ...t }) => {
|
|
2124
|
+
const {
|
|
2125
|
+
massActions: n,
|
|
2126
|
+
columns: a,
|
|
2127
|
+
items: s
|
|
2128
|
+
} = G(), o = v(), [l, i] = q(), {
|
|
2129
|
+
indeterminate: c,
|
|
2130
|
+
allSelected: u,
|
|
2131
|
+
handleSelectToggleAll: d
|
|
2132
|
+
} = qe(), {
|
|
2133
|
+
["ModelIndex.Table.ShrinkedCell"]: h
|
|
2134
|
+
} = A("cms").getComponents(), g = l.get("order_by") || "", [y, k] = g.split(":"), b = (x) => () => {
|
|
2135
|
+
i(y === x ? (S) => {
|
|
2136
|
+
const w = new URLSearchParams(S);
|
|
2137
|
+
return k ? k === "desc" ? (w.delete("order_by"), w) : (w.set("order_by", `${x}:desc`), w) : (w.set("order_by", `${x}:asc`), w);
|
|
2138
|
+
} : (S) => {
|
|
2139
|
+
const w = new URLSearchParams(S);
|
|
2140
|
+
return w.set("order_by", `${x}:asc`), w;
|
|
2141
|
+
});
|
|
2142
|
+
};
|
|
2143
|
+
return /* @__PURE__ */ m(Zt, { ...t, children: [
|
|
2144
|
+
e,
|
|
2145
|
+
o && /* @__PURE__ */ m(J, { children: [
|
|
2146
|
+
n.length > 0 && /* @__PURE__ */ r(h, { children: /* @__PURE__ */ r(
|
|
2147
|
+
Fe,
|
|
2148
|
+
{
|
|
2149
|
+
indeterminate: c,
|
|
2150
|
+
checked: u,
|
|
2151
|
+
onChange: d,
|
|
2152
|
+
disabled: s && s.count() === 0
|
|
2153
|
+
}
|
|
2154
|
+
) }),
|
|
2155
|
+
a.map(({ key: x, label: S, sortable: w = !0, ...C }) => /* @__PURE__ */ r(
|
|
2156
|
+
z,
|
|
2157
|
+
{
|
|
2158
|
+
sortDirection: w && y === x && k || !1,
|
|
2159
|
+
...C,
|
|
2160
|
+
children: /* @__PURE__ */ m(
|
|
2161
|
+
Gt,
|
|
2162
|
+
{
|
|
2163
|
+
active: w && y === x,
|
|
2164
|
+
direction: k,
|
|
2165
|
+
onClick: b(x),
|
|
2166
|
+
children: [
|
|
2167
|
+
S,
|
|
2168
|
+
w && y === x ? /* @__PURE__ */ r(N, { component: "span", sx: { visibility: "hidden", display: "none" }, children: k === "desc" ? "sorted descending" : "sorted ascending" }) : null
|
|
2169
|
+
]
|
|
2170
|
+
}
|
|
2171
|
+
)
|
|
2172
|
+
},
|
|
2173
|
+
x
|
|
2174
|
+
)),
|
|
2175
|
+
/* @__PURE__ */ r(h, {})
|
|
2176
|
+
] })
|
|
2177
|
+
] });
|
|
2178
|
+
}, Or = () => {
|
|
2179
|
+
const {
|
|
2180
|
+
massActions: e,
|
|
2181
|
+
columns: t
|
|
2182
|
+
} = G(), n = v(), {
|
|
2183
|
+
["ModelIndex.Table.ShrinkedCell"]: a
|
|
2184
|
+
} = A("cms").getComponents(), [s] = q(), o = parseInt(s.get("per_page") || "15");
|
|
2185
|
+
return /* @__PURE__ */ r(F, { children: Array.from({ length: o }).map((l, i) => /* @__PURE__ */ m(J, { children: [
|
|
2186
|
+
e.length > 0 && /* @__PURE__ */ r(a, { children: /* @__PURE__ */ r(Fe, {}) }),
|
|
2187
|
+
n && t.map(({ key: c, label: u, sortable: d, ...h }, g) => /* @__PURE__ */ r(z, { ...h, children: /* @__PURE__ */ r(
|
|
2188
|
+
Ue,
|
|
2189
|
+
{
|
|
2190
|
+
variant: "text",
|
|
2191
|
+
height: 24
|
|
2192
|
+
}
|
|
2193
|
+
) }, g)),
|
|
2194
|
+
!n && /* @__PURE__ */ r(z, { sx: { px: 0 }, children: Array.from({ length: t.length }).map((c, u) => /* @__PURE__ */ r(
|
|
2195
|
+
Ue,
|
|
2196
|
+
{
|
|
2197
|
+
variant: "text",
|
|
2198
|
+
width: "100%",
|
|
2199
|
+
height: 24
|
|
2200
|
+
},
|
|
2201
|
+
u
|
|
2202
|
+
)) }),
|
|
2203
|
+
/* @__PURE__ */ r(a, { children: /* @__PURE__ */ r(R, { children: /* @__PURE__ */ r(dt, {}) }) })
|
|
2204
|
+
] }, i)) });
|
|
2205
|
+
}, Rr = ({ children: e, ...t }) => {
|
|
2206
|
+
const n = K(), { t: a } = I(), {
|
|
2207
|
+
items: s,
|
|
2208
|
+
loading: o,
|
|
2209
|
+
columnCount: l
|
|
2210
|
+
} = G(), {
|
|
2211
|
+
["ModelIndex.StaticActions"]: i
|
|
2212
|
+
} = A("cms").getComponents(), c = p.isValidElement(e) ? e : (s || O([])).map(e);
|
|
2213
|
+
return /* @__PURE__ */ m(Qt, { ...t, children: [
|
|
2214
|
+
o && /* @__PURE__ */ r(Or, {}),
|
|
2215
|
+
c,
|
|
2216
|
+
s && !s.count() && /* @__PURE__ */ r(J, { children: /* @__PURE__ */ m(z, { colSpan: l, sx: { textAlign: "center", py: 10 }, children: [
|
|
2217
|
+
/* @__PURE__ */ r(j, { children: a("No :model found", {
|
|
2218
|
+
model: n.plural().toLocaleLowerCase()
|
|
2219
|
+
}) }),
|
|
2220
|
+
/* @__PURE__ */ r("br", {}),
|
|
2221
|
+
/* @__PURE__ */ r(i, {})
|
|
2222
|
+
] }) })
|
|
2223
|
+
] });
|
|
2224
|
+
}, X = U(j)(() => ({
|
|
2225
|
+
whiteSpace: "nowrap",
|
|
2226
|
+
overflow: "hidden",
|
|
2227
|
+
textOverflow: "ellipsis",
|
|
2228
|
+
"& label": {
|
|
2229
|
+
fontWeight: "bold"
|
|
2230
|
+
}
|
|
2231
|
+
})), Nr = ({ content: e }) => ["string", "number"].includes(typeof e) ? /* @__PURE__ */ r(X, { children: e }) : e instanceof Date ? /* @__PURE__ */ r(X, { children: e.toLocaleString(H("app.locale", "en")) }) : typeof e == "object" && !p.isValidElement(e) ? /* @__PURE__ */ r(X, { children: JSON.stringify(e) }) : /* @__PURE__ */ r(p.Fragment, { children: e }), jr = ({ label: e, content: t }) => ["string", "number"].includes(typeof t) ? /* @__PURE__ */ m(X, { children: [
|
|
2232
|
+
/* @__PURE__ */ m("label", { children: [
|
|
2233
|
+
e,
|
|
2234
|
+
":"
|
|
2235
|
+
] }),
|
|
2236
|
+
" ",
|
|
2237
|
+
t
|
|
2238
|
+
] }) : t instanceof Date ? /* @__PURE__ */ m(X, { children: [
|
|
2239
|
+
/* @__PURE__ */ m("label", { children: [
|
|
2240
|
+
e,
|
|
2241
|
+
":"
|
|
2242
|
+
] }),
|
|
2243
|
+
t.toLocaleString(H("app.locale", "en"))
|
|
2244
|
+
] }) : typeof t == "object" && !p.isValidElement(t) ? /* @__PURE__ */ m(X, { children: [
|
|
2245
|
+
/* @__PURE__ */ m("label", { children: [
|
|
2246
|
+
e,
|
|
2247
|
+
":"
|
|
2248
|
+
] }),
|
|
2249
|
+
" ",
|
|
2250
|
+
JSON.stringify(t)
|
|
2251
|
+
] }) : /* @__PURE__ */ m(p.Fragment, { children: [
|
|
2252
|
+
/* @__PURE__ */ r(j, { sx: { display: "inline" }, children: /* @__PURE__ */ m("b", { children: [
|
|
2253
|
+
e,
|
|
2254
|
+
":"
|
|
2255
|
+
] }) }),
|
|
2256
|
+
" ",
|
|
2257
|
+
t
|
|
2258
|
+
] }), qr = ({ item: e, ...t }) => {
|
|
2259
|
+
const n = v(), a = Ae(), s = K(), { massActions: o, columns: l } = G(), i = p.useMemo(() => l.map((g) => ({
|
|
2260
|
+
...g,
|
|
2261
|
+
content: A("cms")[`model${e.constructor.name}Get${f.upperFirst(f.camelCase(g.key))}Content`](e.getAttribute(g.key), e)
|
|
2262
|
+
})), [l, e]), {
|
|
2263
|
+
["ModelIndex.Table.ShrinkedCell"]: c,
|
|
2264
|
+
["ModelIndex.InstanceActions"]: u
|
|
2265
|
+
} = A("cms").getComponents(), {
|
|
2266
|
+
isSelected: d,
|
|
2267
|
+
handleSelectToggle: h
|
|
2268
|
+
} = qe();
|
|
2269
|
+
return /* @__PURE__ */ m(
|
|
2270
|
+
J,
|
|
2271
|
+
{
|
|
2272
|
+
...t,
|
|
2273
|
+
sx: { cursor: e.deletedAt ? "default" : "pointer" },
|
|
2274
|
+
selected: d(e),
|
|
2275
|
+
hover: !e.deletedAt,
|
|
2276
|
+
children: [
|
|
2277
|
+
o.length > 0 && /* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(
|
|
2278
|
+
Fe,
|
|
2279
|
+
{
|
|
2280
|
+
checked: d(e),
|
|
2281
|
+
onChange: () => h(e)
|
|
2282
|
+
}
|
|
2283
|
+
) }),
|
|
2284
|
+
n && i.map(({ key: g, label: y, sortable: k, content: b, ...x }) => /* @__PURE__ */ r(
|
|
2285
|
+
z,
|
|
2286
|
+
{
|
|
2287
|
+
...x,
|
|
2288
|
+
onClick: () => {
|
|
2289
|
+
e.deletedAt || a(`/${f.kebabCase(s.plural())}/${e.getKey()}`);
|
|
2290
|
+
},
|
|
2291
|
+
children: /* @__PURE__ */ r(
|
|
2292
|
+
Nr,
|
|
2293
|
+
{
|
|
2294
|
+
label: y,
|
|
2295
|
+
content: b
|
|
2296
|
+
}
|
|
2297
|
+
)
|
|
2298
|
+
},
|
|
2299
|
+
g
|
|
2300
|
+
)),
|
|
2301
|
+
!n && /* @__PURE__ */ r(
|
|
2302
|
+
z,
|
|
2303
|
+
{
|
|
2304
|
+
sx: { maxWidth: 0, px: 0 },
|
|
2305
|
+
onClick: () => {
|
|
2306
|
+
e.deletedAt || a(`/${f.kebabCase(s.plural())}/${e.getKey()}`);
|
|
2307
|
+
},
|
|
2308
|
+
children: i.map(({ key: g, ...y }) => /* @__PURE__ */ r(jr, { ...y }, g))
|
|
2309
|
+
}
|
|
2310
|
+
),
|
|
2311
|
+
/* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(u, { item: e }) })
|
|
2312
|
+
]
|
|
2313
|
+
}
|
|
2314
|
+
);
|
|
2315
|
+
}, Wr = ({ children: e, ...t }) => {
|
|
2316
|
+
const {
|
|
2317
|
+
columnCount: n
|
|
2318
|
+
} = G(), a = v(), s = L("breakpoint", "md"), {
|
|
2319
|
+
["ModelIndex.Pagination"]: o,
|
|
2320
|
+
["ModelIndex.PaginationDetails"]: l,
|
|
2321
|
+
["ModelIndex.PerPageSwitch"]: i
|
|
2322
|
+
} = A("cms").getComponents();
|
|
2323
|
+
return /* @__PURE__ */ m(Xt, { ...t, children: [
|
|
2324
|
+
/* @__PURE__ */ r(J, { children: /* @__PURE__ */ r(z, { colSpan: n, children: /* @__PURE__ */ m(
|
|
2325
|
+
B,
|
|
2326
|
+
{
|
|
2327
|
+
direction: a ? "row" : "column-reverse",
|
|
2328
|
+
alignItems: "center",
|
|
2329
|
+
justifyContent: "space-between",
|
|
2330
|
+
gap: 3,
|
|
2331
|
+
children: [
|
|
2332
|
+
/* @__PURE__ */ m(
|
|
2333
|
+
B,
|
|
2334
|
+
{
|
|
2335
|
+
direction: a ? "row" : "column-reverse",
|
|
2336
|
+
alignItems: a ? "center" : "flex-start",
|
|
2337
|
+
justifyContent: "flex-start",
|
|
2338
|
+
width: { xs: "100%", [s]: "auto" },
|
|
2339
|
+
gap: a ? 2 : 0,
|
|
2340
|
+
children: [
|
|
2341
|
+
/* @__PURE__ */ r(i, {}),
|
|
2342
|
+
/* @__PURE__ */ r(l, {})
|
|
2343
|
+
]
|
|
2344
|
+
}
|
|
2345
|
+
),
|
|
2346
|
+
/* @__PURE__ */ r(
|
|
2347
|
+
o,
|
|
2348
|
+
{
|
|
2349
|
+
variant: a ? "default" : "compact",
|
|
2350
|
+
justifyContent: { xs: "center", [s]: "flex-end" }
|
|
2351
|
+
}
|
|
2352
|
+
)
|
|
2353
|
+
]
|
|
2354
|
+
}
|
|
2355
|
+
) }) }),
|
|
2356
|
+
e
|
|
2357
|
+
] });
|
|
2358
|
+
}, Ur = () => {
|
|
2359
|
+
const {
|
|
2360
|
+
columnCount: e
|
|
2361
|
+
} = G(), {
|
|
2362
|
+
["ModelIndex.Filter"]: t,
|
|
2363
|
+
["ModelIndex.MassActions"]: n,
|
|
2364
|
+
["ModelIndex.Sort"]: a,
|
|
2365
|
+
["ModelIndex.Pagination"]: s
|
|
2366
|
+
// ['ModelIndex.PaginationDetails']: PaginationDetails,
|
|
2367
|
+
} = A("cms").getComponents(), o = v(), l = L("breakpoint", "md");
|
|
2368
|
+
return /* @__PURE__ */ r(J, { children: /* @__PURE__ */ r(z, { colSpan: e, sx: { p: 1 }, children: /* @__PURE__ */ m(
|
|
2369
|
+
B,
|
|
2370
|
+
{
|
|
2371
|
+
direction: { xs: "column", [l]: "row" },
|
|
2372
|
+
justifyContent: "space-between",
|
|
2373
|
+
spacing: 1,
|
|
2374
|
+
children: [
|
|
2375
|
+
/* @__PURE__ */ m(
|
|
2376
|
+
B,
|
|
2377
|
+
{
|
|
2378
|
+
direction: "row",
|
|
2379
|
+
alignItems: "center",
|
|
2380
|
+
width: { [l]: "100%" },
|
|
2381
|
+
children: [
|
|
2382
|
+
/* @__PURE__ */ r(t, {}),
|
|
2383
|
+
!o && /* @__PURE__ */ r(a, {})
|
|
2384
|
+
]
|
|
2385
|
+
}
|
|
2386
|
+
),
|
|
2387
|
+
o && /* @__PURE__ */ r(
|
|
2388
|
+
B,
|
|
2389
|
+
{
|
|
2390
|
+
direction: "row",
|
|
2391
|
+
alignItems: "center",
|
|
2392
|
+
justifyContent: { xs: "center", [l]: "flex-end" },
|
|
2393
|
+
rowGap: 2,
|
|
2394
|
+
children: /* @__PURE__ */ r(
|
|
2395
|
+
s,
|
|
2396
|
+
{
|
|
2397
|
+
variant: "compact",
|
|
2398
|
+
justifyContent: "end"
|
|
2399
|
+
}
|
|
2400
|
+
)
|
|
2401
|
+
}
|
|
2402
|
+
),
|
|
2403
|
+
/* @__PURE__ */ r(n, {})
|
|
2404
|
+
]
|
|
2405
|
+
}
|
|
2406
|
+
) }) });
|
|
2407
|
+
};
|
|
2408
|
+
function Vr() {
|
|
2409
|
+
const e = K(), { t } = I(), [n, a] = q(), s = n.get("tab") || "all", o = (c, u) => {
|
|
2410
|
+
a(() => {
|
|
2411
|
+
const d = new URLSearchParams();
|
|
2412
|
+
return u !== "all" && d.set("tab", u), d;
|
|
2413
|
+
});
|
|
2414
|
+
}, l = p.useMemo(() => e.getSchema().softDeletes ? [{ label: t("Trashed"), value: "trashed" }] : [], [e]), i = Ce(
|
|
2415
|
+
A("cms"),
|
|
2416
|
+
`model${f.upperFirst(f.camelCase(e.getSchemaName()))}Tabs`,
|
|
2417
|
+
l
|
|
2418
|
+
);
|
|
2419
|
+
return i.length === 0 ? null : /* @__PURE__ */ r(N, { sx: { maxWidth: { xs: 320, sm: 480 }, bgcolor: "background.paper" }, children: /* @__PURE__ */ m(
|
|
2420
|
+
Jt,
|
|
2421
|
+
{
|
|
2422
|
+
value: s,
|
|
2423
|
+
onChange: o,
|
|
2424
|
+
variant: "scrollable",
|
|
2425
|
+
scrollButtons: "auto",
|
|
2426
|
+
"aria-label": `tabs for ${e.singular()}`,
|
|
2427
|
+
allowScrollButtonsMobile: !0,
|
|
2428
|
+
children: [
|
|
2429
|
+
/* @__PURE__ */ r(
|
|
2430
|
+
Ve,
|
|
2431
|
+
{
|
|
2432
|
+
label: t("All"),
|
|
2433
|
+
value: "all"
|
|
2434
|
+
}
|
|
2435
|
+
),
|
|
2436
|
+
i.map((c) => /* @__PURE__ */ r(
|
|
2437
|
+
Ve,
|
|
2438
|
+
{
|
|
2439
|
+
label: c.label,
|
|
2440
|
+
value: c.value
|
|
2441
|
+
},
|
|
2442
|
+
c.value
|
|
2443
|
+
))
|
|
2444
|
+
]
|
|
2445
|
+
}
|
|
2446
|
+
) });
|
|
2447
|
+
}
|
|
2448
|
+
function Yr(e) {
|
|
2449
|
+
const {
|
|
2450
|
+
parts: t,
|
|
2451
|
+
...n
|
|
2452
|
+
} = e;
|
|
2453
|
+
return /* @__PURE__ */ m(
|
|
2454
|
+
_t,
|
|
2455
|
+
{
|
|
2456
|
+
"aria-label": "breadcrumb",
|
|
2457
|
+
...n,
|
|
2458
|
+
children: [
|
|
2459
|
+
/* @__PURE__ */ r(
|
|
2460
|
+
Se,
|
|
2461
|
+
{
|
|
2462
|
+
underline: "hover",
|
|
2463
|
+
color: "inherit",
|
|
2464
|
+
to: "/",
|
|
2465
|
+
component: ae,
|
|
2466
|
+
children: H("app.name", "Laravel")
|
|
2467
|
+
}
|
|
2468
|
+
),
|
|
2469
|
+
t == null ? void 0 : t.map(({ name: a, href: s }, o) => s ? /* @__PURE__ */ r(
|
|
2470
|
+
Se,
|
|
2471
|
+
{
|
|
2472
|
+
underline: "hover",
|
|
2473
|
+
color: "inherit",
|
|
2474
|
+
to: s,
|
|
2475
|
+
component: ae,
|
|
2476
|
+
children: a
|
|
2477
|
+
},
|
|
2478
|
+
o
|
|
2479
|
+
) : /* @__PURE__ */ r(
|
|
2480
|
+
j,
|
|
2481
|
+
{
|
|
2482
|
+
color: "text.primary",
|
|
2483
|
+
children: a
|
|
2484
|
+
},
|
|
2485
|
+
o
|
|
2486
|
+
))
|
|
2487
|
+
]
|
|
2488
|
+
}
|
|
2489
|
+
);
|
|
2490
|
+
}
|
|
2491
|
+
const bt = ({
|
|
2492
|
+
collapsed: e = !1,
|
|
2493
|
+
items: t,
|
|
2494
|
+
onClick: n,
|
|
2495
|
+
...a
|
|
2496
|
+
}) => {
|
|
2497
|
+
const [s, o] = p.useState(null), [l, i] = p.useState(null), [c, u] = p.useState({}), d = L("drawer.width", 280), h = A("cms").getComponent("RecursiveMenu");
|
|
2498
|
+
return /* @__PURE__ */ m(en, { ...a, children: [
|
|
2499
|
+
t.map((g) => {
|
|
2500
|
+
const {
|
|
2501
|
+
text: y,
|
|
2502
|
+
icon: k,
|
|
2503
|
+
element: b = null,
|
|
2504
|
+
key: x,
|
|
2505
|
+
children: S,
|
|
2506
|
+
to: w,
|
|
2507
|
+
onClick: C
|
|
2508
|
+
} = g;
|
|
2509
|
+
return b || /* @__PURE__ */ m(
|
|
2510
|
+
tn,
|
|
2511
|
+
{
|
|
2512
|
+
disablePadding: !0,
|
|
2513
|
+
sx: { display: "block" },
|
|
2514
|
+
children: [
|
|
2515
|
+
/* @__PURE__ */ m(
|
|
2516
|
+
nn,
|
|
2517
|
+
{
|
|
2518
|
+
sx: {
|
|
2519
|
+
minHeight: 48,
|
|
2520
|
+
justifyContent: e ? "center" : "initial",
|
|
2521
|
+
px: 2.5
|
|
2522
|
+
},
|
|
2523
|
+
onClick: (T) => {
|
|
2524
|
+
if (C && C(T), S) {
|
|
2525
|
+
if (e) {
|
|
2526
|
+
i(() => (o(T.currentTarget), S));
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
u({
|
|
2530
|
+
...c,
|
|
2531
|
+
[x]: !c[x]
|
|
2532
|
+
});
|
|
2533
|
+
return;
|
|
2534
|
+
}
|
|
2535
|
+
n && n(T);
|
|
2536
|
+
},
|
|
2537
|
+
...w ? { to: w, component: ie } : {},
|
|
2538
|
+
children: [
|
|
2539
|
+
/* @__PURE__ */ m(
|
|
2540
|
+
st,
|
|
2541
|
+
{
|
|
2542
|
+
sx: {
|
|
2543
|
+
minWidth: 0,
|
|
2544
|
+
mr: e ? "unset" : 3,
|
|
2545
|
+
justifyContent: "center",
|
|
2546
|
+
flexDirection: "column",
|
|
2547
|
+
alignItems: "center",
|
|
2548
|
+
color: "inherit"
|
|
2549
|
+
},
|
|
2550
|
+
children: [
|
|
2551
|
+
k,
|
|
2552
|
+
e && /* @__PURE__ */ r(
|
|
2553
|
+
j,
|
|
2554
|
+
{
|
|
2555
|
+
fontSize: 10,
|
|
2556
|
+
sx: { mt: 0.5 },
|
|
2557
|
+
children: y
|
|
2558
|
+
}
|
|
2559
|
+
)
|
|
2560
|
+
]
|
|
2561
|
+
}
|
|
2562
|
+
),
|
|
2563
|
+
!e && /* @__PURE__ */ r(lt, { primary: y }),
|
|
2564
|
+
!e && S && (c[x] ? /* @__PURE__ */ r(fn, {}) : /* @__PURE__ */ r(gn, {}))
|
|
2565
|
+
]
|
|
2566
|
+
}
|
|
2567
|
+
),
|
|
2568
|
+
S && !e && /* @__PURE__ */ r(
|
|
2569
|
+
ot,
|
|
2570
|
+
{
|
|
2571
|
+
in: c[x],
|
|
2572
|
+
timeout: "auto",
|
|
2573
|
+
unmountOnExit: !0,
|
|
2574
|
+
children: /* @__PURE__ */ r(
|
|
2575
|
+
bt,
|
|
2576
|
+
{
|
|
2577
|
+
items: S,
|
|
2578
|
+
onClick: n,
|
|
2579
|
+
collapsed: e,
|
|
2580
|
+
sx: { pl: e ? 0 : 2, pb: 0 }
|
|
2581
|
+
}
|
|
2582
|
+
)
|
|
2583
|
+
}
|
|
2584
|
+
)
|
|
2585
|
+
]
|
|
2586
|
+
},
|
|
2587
|
+
x
|
|
2588
|
+
);
|
|
2589
|
+
}),
|
|
2590
|
+
e && /* @__PURE__ */ r(
|
|
2591
|
+
h,
|
|
2592
|
+
{
|
|
2593
|
+
items: l || [],
|
|
2594
|
+
onClick: n,
|
|
2595
|
+
collapsed: !1,
|
|
2596
|
+
sx: { pl: e ? 0 : 2, pb: 0 },
|
|
2597
|
+
anchorEl: s,
|
|
2598
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
2599
|
+
onClose: () => {
|
|
2600
|
+
o(null), i(null);
|
|
2601
|
+
},
|
|
2602
|
+
open: !!s,
|
|
2603
|
+
slotProps: { paper: { sx: { minWidth: d } } }
|
|
2604
|
+
}
|
|
2605
|
+
)
|
|
2606
|
+
] });
|
|
2607
|
+
}, yt = ({
|
|
2608
|
+
collapsed: e = !1,
|
|
2609
|
+
items: t,
|
|
2610
|
+
onClick: n,
|
|
2611
|
+
...a
|
|
2612
|
+
}) => {
|
|
2613
|
+
const [s, o] = p.useState({}), l = L("drawer.width", 280);
|
|
2614
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
2615
|
+
/* @__PURE__ */ r(it, { ...a, children: t.map((i) => {
|
|
2616
|
+
const {
|
|
2617
|
+
text: c,
|
|
2618
|
+
icon: u,
|
|
2619
|
+
element: d = null,
|
|
2620
|
+
key: h,
|
|
2621
|
+
children: g,
|
|
2622
|
+
onClick: y,
|
|
2623
|
+
to: k
|
|
2624
|
+
} = i;
|
|
2625
|
+
return d || /* @__PURE__ */ m(
|
|
2626
|
+
Z,
|
|
2627
|
+
{
|
|
2628
|
+
onClick: (b) => {
|
|
2629
|
+
if (y && y(b), g) {
|
|
2630
|
+
o({
|
|
2631
|
+
...s,
|
|
2632
|
+
[h]: s[h] ? null : b.currentTarget
|
|
2633
|
+
});
|
|
2634
|
+
return;
|
|
2635
|
+
}
|
|
2636
|
+
n && n(b);
|
|
2637
|
+
},
|
|
2638
|
+
...k ? {
|
|
2639
|
+
component: ie,
|
|
2640
|
+
to: k
|
|
2641
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2642
|
+
} : {},
|
|
2643
|
+
children: [
|
|
2644
|
+
u && /* @__PURE__ */ r(
|
|
2645
|
+
st,
|
|
2646
|
+
{
|
|
2647
|
+
sx: {
|
|
2648
|
+
minWidth: 0,
|
|
2649
|
+
mr: e ? "auto" : 3,
|
|
2650
|
+
justifyContent: "center",
|
|
2651
|
+
color: "inherit"
|
|
2652
|
+
},
|
|
2653
|
+
children: u
|
|
2654
|
+
}
|
|
2655
|
+
),
|
|
2656
|
+
/* @__PURE__ */ r(lt, { sx: { opacity: e ? 0 : 1 }, children: c }),
|
|
2657
|
+
!e && g && /* @__PURE__ */ r(Pe, {})
|
|
2658
|
+
]
|
|
2659
|
+
},
|
|
2660
|
+
h
|
|
2661
|
+
);
|
|
2662
|
+
}) }),
|
|
2663
|
+
t.map((i) => {
|
|
2664
|
+
const { key: c, children: u } = i;
|
|
2665
|
+
return u ? /* @__PURE__ */ r(
|
|
2666
|
+
yt,
|
|
2667
|
+
{
|
|
2668
|
+
items: u,
|
|
2669
|
+
onClick: n,
|
|
2670
|
+
collapsed: e,
|
|
2671
|
+
sx: { pl: e ? 0 : 2, pb: 0 },
|
|
2672
|
+
open: !!s[c],
|
|
2673
|
+
anchorEl: s[c],
|
|
2674
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
2675
|
+
onClose: () => o({ ...s, [c]: null }),
|
|
2676
|
+
slotProps: { paper: { sx: { minWidth: l } } }
|
|
2677
|
+
},
|
|
2678
|
+
c
|
|
2679
|
+
) : null;
|
|
2680
|
+
})
|
|
2681
|
+
] });
|
|
2682
|
+
}, be = {
|
|
2683
|
+
delete: (e) => async ({ selected: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2684
|
+
const l = e.getSchema().softDeletes ? "send to trash" : "delete permanently", i = e.getSchema().softDeletes ? "sent to trash" : "deleted";
|
|
2685
|
+
if (await a({
|
|
2686
|
+
title: e.getSchema().softDeletes ? o("Confirm send to trash") : o("Confirm delete permanently"),
|
|
2687
|
+
message: o(`Are you sure you want to ${l} :count :model?`, {
|
|
2688
|
+
count: t.count(),
|
|
2689
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2690
|
+
}),
|
|
2691
|
+
type: "confirm"
|
|
2692
|
+
}))
|
|
2693
|
+
try {
|
|
2694
|
+
await e.delete(t.pluck(e.getSchema().primaryKey).all()), n(o(`Successfully ${i} :count :model`, {
|
|
2695
|
+
count: t.count(),
|
|
2696
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2697
|
+
})), s();
|
|
2698
|
+
} catch (u) {
|
|
2699
|
+
Q(n)(u);
|
|
2700
|
+
}
|
|
2701
|
+
},
|
|
2702
|
+
restore: (e) => async ({ selected: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2703
|
+
if (await a({
|
|
2704
|
+
title: o("Confirm restore"),
|
|
2705
|
+
message: o("Are you sure you want to restore :count :model?", {
|
|
2706
|
+
count: t.count(),
|
|
2707
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2708
|
+
}),
|
|
2709
|
+
type: "confirm"
|
|
2710
|
+
}))
|
|
2711
|
+
try {
|
|
2712
|
+
await e.restore(t.pluck(e.getSchema().primaryKey).all()), n(o("Successfully restored :count :model", {
|
|
2713
|
+
count: t.count(),
|
|
2714
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2715
|
+
})), s();
|
|
2716
|
+
} catch (i) {
|
|
2717
|
+
Q(n)(i);
|
|
2718
|
+
}
|
|
2719
|
+
},
|
|
2720
|
+
forceDelete: (e) => async ({ selected: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2721
|
+
if (await a({
|
|
2722
|
+
title: o("Confirm permanent deletion"),
|
|
2723
|
+
message: o("Are you sure you want to delete permanently :count :model?", {
|
|
2724
|
+
count: t.count(),
|
|
2725
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2726
|
+
}),
|
|
2727
|
+
type: "confirm"
|
|
2728
|
+
}))
|
|
2729
|
+
try {
|
|
2730
|
+
await e.forceDelete(t.pluck(e.getSchema().primaryKey).all()), n(o("Successfully deleted :count :model", {
|
|
2731
|
+
count: t.count(),
|
|
2732
|
+
model: f.lowerFirst(t.count() === 1 ? e.singular() : e.plural())
|
|
2733
|
+
})), s();
|
|
2734
|
+
} catch (i) {
|
|
2735
|
+
Q(n)(i);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
}, ye = {
|
|
2739
|
+
delete: (e) => async ({ item: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2740
|
+
const l = e.getSchema().softDeletes ? "send :model “:label” to trash" : "delete :model “:label” permanently", i = e.getSchema().softDeletes ? "sent :model “:label” to trash" : "deleted :model “:label”";
|
|
2741
|
+
if (await a({
|
|
2742
|
+
title: e.getSchema().softDeletes ? o("Confirm send to trash") : o("Confirm permanent deletion"),
|
|
2743
|
+
message: o(`Are you sure you want to ${l}?`, {
|
|
2744
|
+
model: f.lowerFirst(e.singular()),
|
|
2745
|
+
label: t.getLabel()
|
|
2746
|
+
}),
|
|
2747
|
+
type: "confirm"
|
|
2748
|
+
}))
|
|
2749
|
+
try {
|
|
2750
|
+
await t.delete(), n(o(`Successfully ${i}`, {
|
|
2751
|
+
model: e.singular(),
|
|
2752
|
+
label: t.getLabel()
|
|
2753
|
+
})), s();
|
|
2754
|
+
} catch (u) {
|
|
2755
|
+
Q(n)(u);
|
|
2756
|
+
}
|
|
2757
|
+
},
|
|
2758
|
+
restore: (e) => async ({ item: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2759
|
+
if (await a({
|
|
2760
|
+
title: o("Confirm restore"),
|
|
2761
|
+
message: o("Are you sure you want to restore :model “:label”?", {
|
|
2762
|
+
model: f.lowerFirst(e.singular()),
|
|
2763
|
+
label: t.getLabel()
|
|
2764
|
+
}),
|
|
2765
|
+
type: "confirm"
|
|
2766
|
+
}))
|
|
2767
|
+
try {
|
|
2768
|
+
await t.restore(), n(o("Successfully restored :model “:label”", {
|
|
2769
|
+
model: e.singular(),
|
|
2770
|
+
label: t.getLabel()
|
|
2771
|
+
})), s();
|
|
2772
|
+
} catch (i) {
|
|
2773
|
+
Q(n)(i);
|
|
2774
|
+
}
|
|
2775
|
+
},
|
|
2776
|
+
forceDelete: (e) => async ({ item: t, notify: n, dialog: a, refresh: s, t: o }) => {
|
|
2777
|
+
if (await a({
|
|
2778
|
+
title: o("Confirm permanent deletion"),
|
|
2779
|
+
message: o("Are you sure you want to delete :model “:label” permanently?", {
|
|
2780
|
+
model: f.lowerFirst(e.singular()),
|
|
2781
|
+
label: t.getLabel()
|
|
2782
|
+
}),
|
|
2783
|
+
type: "confirm"
|
|
2784
|
+
}))
|
|
2785
|
+
try {
|
|
2786
|
+
await t.forceDelete(), n(o("Successfully deleted :model “:label”", {
|
|
2787
|
+
model: e.singular(),
|
|
2788
|
+
label: t.getLabel()
|
|
2789
|
+
})), s();
|
|
2790
|
+
} catch (i) {
|
|
2791
|
+
Q(n)(i);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}, zr = {
|
|
2795
|
+
create: (e) => ({ navigate: t }) => {
|
|
2796
|
+
t(`/${f.kebabCase(e.plural())}/create`);
|
|
2797
|
+
}
|
|
2798
|
+
}, Kr = ({ item: e }) => {
|
|
2799
|
+
const t = Oe(), [n] = q(), a = n.get("tab") ?? "all", s = p.useMemo(() => A("cms").getInstanceActions(e.constructor, a), [e, a]), [o, l] = p.useState(null), i = !!o, c = (d) => {
|
|
2800
|
+
l(d.currentTarget);
|
|
2801
|
+
}, u = () => {
|
|
2802
|
+
l(null);
|
|
2803
|
+
};
|
|
2804
|
+
return /* @__PURE__ */ m(F, { children: [
|
|
2805
|
+
/* @__PURE__ */ r(
|
|
2806
|
+
R,
|
|
2807
|
+
{
|
|
2808
|
+
"aria-describedby": "model-item-actions",
|
|
2809
|
+
"aria-label": "filter",
|
|
2810
|
+
onClick: c,
|
|
2811
|
+
children: /* @__PURE__ */ r(dt, {})
|
|
2812
|
+
}
|
|
2813
|
+
),
|
|
2814
|
+
/* @__PURE__ */ r(
|
|
2815
|
+
it,
|
|
2816
|
+
{
|
|
2817
|
+
id: "model-item-actions",
|
|
2818
|
+
anchorEl: o,
|
|
2819
|
+
open: i,
|
|
2820
|
+
onClose: u,
|
|
2821
|
+
MenuListProps: {
|
|
2822
|
+
"aria-labelledby": "model-item-action"
|
|
2823
|
+
},
|
|
2824
|
+
children: s.map((d) => /* @__PURE__ */ m(
|
|
2825
|
+
Z,
|
|
2826
|
+
{
|
|
2827
|
+
onClick: () => {
|
|
2828
|
+
d.callback({
|
|
2829
|
+
item: e,
|
|
2830
|
+
...t
|
|
2831
|
+
}), u();
|
|
2832
|
+
},
|
|
2833
|
+
sx: { px: 1, gap: 0.75 },
|
|
2834
|
+
children: [
|
|
2835
|
+
d.icon,
|
|
2836
|
+
d.label
|
|
2837
|
+
]
|
|
2838
|
+
},
|
|
2839
|
+
d.label
|
|
2840
|
+
))
|
|
2841
|
+
}
|
|
2842
|
+
)
|
|
2843
|
+
] });
|
|
2844
|
+
};
|
|
2845
|
+
let P;
|
|
2846
|
+
class $r extends Je {
|
|
2847
|
+
constructor(n = {}) {
|
|
2848
|
+
super();
|
|
2849
|
+
ce(this, "name", "Luminix CMS Plugin");
|
|
2850
|
+
this.options = n;
|
|
2851
|
+
}
|
|
2852
|
+
register(n) {
|
|
2853
|
+
P = n, P.bind("cms", new vn()), P.bind("filter", new Tn()), P.once("booting", () => {
|
|
2854
|
+
this.bootModels();
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
boot() {
|
|
2858
|
+
this.bootComponents(), this.bootRoutes(), this.bootMenu(), this.bootMassActions(), this.bootInstanceActions(), this.bootStaticActions(), (this.options.applyUserDefaults ?? !0) && this.bootDefaultUserModifiers();
|
|
2859
|
+
}
|
|
2860
|
+
bootModels() {
|
|
2861
|
+
P.make("model").reducer(
|
|
2862
|
+
"model",
|
|
2863
|
+
(n, a) => class extends n {
|
|
2864
|
+
static icon() {
|
|
2865
|
+
return a === "user" ? /* @__PURE__ */ r(bn, {}) : /* @__PURE__ */ r(yn, {});
|
|
2866
|
+
}
|
|
2867
|
+
},
|
|
2868
|
+
0
|
|
2869
|
+
);
|
|
2870
|
+
}
|
|
2871
|
+
bootRoutes() {
|
|
2872
|
+
P.make("cms").reducer("cmsRoutes", On, 0), P.make("route").reducer("routerOptions", (n) => ({
|
|
2873
|
+
...n,
|
|
2874
|
+
basename: P.make("config").get("luminix.admin.url", "/admin")
|
|
2875
|
+
}));
|
|
2876
|
+
}
|
|
2877
|
+
bootComponents() {
|
|
2878
|
+
P.make("cms").reducer("componentMap", () => ({
|
|
2879
|
+
Layout: qn,
|
|
2880
|
+
Dashboard: Rn,
|
|
2881
|
+
ModelIndex: Un,
|
|
2882
|
+
ModelItem: zn,
|
|
2883
|
+
Error: Nn,
|
|
2884
|
+
DesktopPageTitle: lr,
|
|
2885
|
+
RecursiveList: bt,
|
|
2886
|
+
RecursiveMenu: yt,
|
|
2887
|
+
Breadcrumbs: Yr,
|
|
2888
|
+
"Layout.AppBar": tr,
|
|
2889
|
+
"Layout.Drawer": sr,
|
|
2890
|
+
"Layout.AppBar.MenuButton": Sr,
|
|
2891
|
+
"Layout.SearchBar": Ir,
|
|
2892
|
+
"Layout.BackButton": nr,
|
|
2893
|
+
"ModelIndex.Filter": xr,
|
|
2894
|
+
"ModelIndex.InstanceActions": Kr,
|
|
2895
|
+
"ModelIndex.MassActions": wr,
|
|
2896
|
+
"ModelIndex.Pagination": Ar,
|
|
2897
|
+
"ModelIndex.PaginationDetails": Cr,
|
|
2898
|
+
"ModelIndex.PerPageSwitch": vr,
|
|
2899
|
+
"ModelIndex.Sort": Mr,
|
|
2900
|
+
"ModelIndex.StaticActions": Gn,
|
|
2901
|
+
"ModelIndex.Table": Er,
|
|
2902
|
+
"ModelIndex.Table.TableHead": Lr,
|
|
2903
|
+
"ModelIndex.Table.TableBody": Rr,
|
|
2904
|
+
"ModelIndex.Table.TableFooter": Wr,
|
|
2905
|
+
"ModelIndex.Table.TableToolbar": Ur,
|
|
2906
|
+
"ModelIndex.Table.TableBody.TableRow": qr,
|
|
2907
|
+
"ModelIndex.Table.ShrinkedCell": Pr,
|
|
2908
|
+
"ModelIndex.Tabs": Vr
|
|
2909
|
+
}), 0);
|
|
2910
|
+
}
|
|
2911
|
+
bootMenu() {
|
|
2912
|
+
P.make("cms").reducer("menuItems", (n, a) => [
|
|
2913
|
+
...n,
|
|
2914
|
+
{
|
|
2915
|
+
key: "dashboard",
|
|
2916
|
+
text: "Dashboard",
|
|
2917
|
+
to: "/",
|
|
2918
|
+
icon: /* @__PURE__ */ r(xn, {})
|
|
2919
|
+
},
|
|
2920
|
+
...Object.entries(a).sort(([s], [o]) => s.localeCompare(o)).map(([s, o]) => ({
|
|
2921
|
+
key: s,
|
|
2922
|
+
text: o.plural(),
|
|
2923
|
+
// TODO: use route(`luminix.cms.${model}.index`) instead
|
|
2924
|
+
to: "/" + f.kebabCase(o.plural()),
|
|
2925
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2926
|
+
icon: o.icon()
|
|
2927
|
+
}))
|
|
2928
|
+
], 0);
|
|
2929
|
+
}
|
|
2930
|
+
bootDefaultUserModifiers() {
|
|
2931
|
+
P.make("cms").reducer("modelUserColumns", () => [
|
|
2932
|
+
{
|
|
2933
|
+
key: "name",
|
|
2934
|
+
label: "Name",
|
|
2935
|
+
scope: "row",
|
|
2936
|
+
component: "th"
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
key: "email",
|
|
2940
|
+
label: "Email",
|
|
2941
|
+
align: "right",
|
|
2942
|
+
size: "small"
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
key: "created_at",
|
|
2946
|
+
label: "Created At",
|
|
2947
|
+
align: "right",
|
|
2948
|
+
size: "small"
|
|
2949
|
+
}
|
|
2950
|
+
], 1), P.make("cms").reducer("wireModelFormProps", (n, a) => (a == null ? void 0 : a.getType()) === "user" ? {
|
|
2951
|
+
...n,
|
|
2952
|
+
confirmed: "password"
|
|
2953
|
+
} : n);
|
|
2954
|
+
}
|
|
2955
|
+
bootMassActions() {
|
|
2956
|
+
P.make("cms").reducer("massActions", (n, a, s) => {
|
|
2957
|
+
const o = [], { softDeletes: l } = a.getSchema();
|
|
2958
|
+
return s !== "trashed" ? o.push({
|
|
2959
|
+
key: "delete",
|
|
2960
|
+
label: l ? "Send to trash" : "Delete permanently",
|
|
2961
|
+
callback: be.delete(a)
|
|
2962
|
+
}) : (o.push({
|
|
2963
|
+
key: "restore",
|
|
2964
|
+
label: "Restore",
|
|
2965
|
+
callback: be.restore(a)
|
|
2966
|
+
}), o.push({
|
|
2967
|
+
key: "forceDelete",
|
|
2968
|
+
label: "Delete permanently",
|
|
2969
|
+
callback: be.forceDelete(a)
|
|
2970
|
+
})), [
|
|
2971
|
+
...n,
|
|
2972
|
+
...o
|
|
2973
|
+
];
|
|
2974
|
+
}, 0);
|
|
2975
|
+
}
|
|
2976
|
+
bootInstanceActions() {
|
|
2977
|
+
P.make("cms").reducer("instanceActions", (n, a, s) => {
|
|
2978
|
+
const o = [], { softDeletes: l } = a.getSchema();
|
|
2979
|
+
return s !== "trashed" ? o.push({
|
|
2980
|
+
label: l ? "Send to trash" : "Delete permanently",
|
|
2981
|
+
callback: ye.delete(a)
|
|
2982
|
+
}) : (o.push({
|
|
2983
|
+
label: "Restore",
|
|
2984
|
+
callback: ye.restore(a)
|
|
2985
|
+
}), o.push({
|
|
2986
|
+
label: "Delete permanently",
|
|
2987
|
+
callback: ye.forceDelete(a)
|
|
2988
|
+
})), [
|
|
2989
|
+
...n,
|
|
2990
|
+
...o
|
|
2991
|
+
];
|
|
2992
|
+
}, 0);
|
|
2993
|
+
}
|
|
2994
|
+
bootStaticActions() {
|
|
2995
|
+
P.make("cms").reducer("staticActions", (n, a, s) => s === "trashed" ? n : [
|
|
2996
|
+
...n,
|
|
2997
|
+
{
|
|
2998
|
+
key: "create",
|
|
2999
|
+
label: `Create ${a.singular()}`,
|
|
3000
|
+
callback: zr.create(a),
|
|
3001
|
+
icon: /* @__PURE__ */ r(wn, {})
|
|
3002
|
+
}
|
|
3003
|
+
], 0);
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
class Hr extends Je {
|
|
3007
|
+
constructor(n) {
|
|
3008
|
+
super();
|
|
3009
|
+
ce(this, "name", "Luminix CMS i18Next Plugin");
|
|
3010
|
+
this.options = n;
|
|
3011
|
+
}
|
|
3012
|
+
register(n) {
|
|
3013
|
+
n.once("booting", () => {
|
|
3014
|
+
this.initI18Next(n.make("config")), this.translateModelNames(n.make("model"));
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
boot({ cms: n, model: a, forms: s }) {
|
|
3018
|
+
this.translateModelColumns(a, n), this.translateMenuEntries(n), this.translateInstanceActions(n), this.translateMassActions(n), this.translateFormLabels(s), this.translateStaticActions(n);
|
|
3019
|
+
}
|
|
3020
|
+
initI18Next(n) {
|
|
3021
|
+
W.use(on).init({
|
|
3022
|
+
lng: n.get("app.locale", "en"),
|
|
3023
|
+
fallbackLng: n.get("app.fallback_locale", "en"),
|
|
3024
|
+
resources: {
|
|
3025
|
+
[n.get("app.locale", "en")]: {
|
|
3026
|
+
translation: n.get("trans", {})
|
|
3027
|
+
}
|
|
3028
|
+
},
|
|
3029
|
+
...this.options,
|
|
3030
|
+
interpolation: {
|
|
3031
|
+
prefix: ":",
|
|
3032
|
+
suffix: "",
|
|
3033
|
+
prefixEscaped: ":\\b",
|
|
3034
|
+
// start with : and follow by word boundary
|
|
3035
|
+
suffixEscaped: "(?:\\b)",
|
|
3036
|
+
// match with word boundary as suffix but don't capture it
|
|
3037
|
+
...this.options.interpolation
|
|
3038
|
+
},
|
|
3039
|
+
debug: n.get("app.debug", !1)
|
|
3040
|
+
});
|
|
3041
|
+
}
|
|
3042
|
+
translateModelNames(n) {
|
|
3043
|
+
n.reducer(
|
|
3044
|
+
"model",
|
|
3045
|
+
(a) => class extends a {
|
|
3046
|
+
static singular() {
|
|
3047
|
+
return W.t(a.singular());
|
|
3048
|
+
}
|
|
3049
|
+
static plural() {
|
|
3050
|
+
return W.t(a.plural());
|
|
3051
|
+
}
|
|
3052
|
+
},
|
|
3053
|
+
0
|
|
3054
|
+
);
|
|
3055
|
+
}
|
|
3056
|
+
translateModelColumns(n, a) {
|
|
3057
|
+
for (const s of Object.keys(n.make()))
|
|
3058
|
+
a.reducer(
|
|
3059
|
+
`model${f.upperFirst(f.camelCase(s))}Columns`,
|
|
3060
|
+
(o) => o.map((l) => ({
|
|
3061
|
+
...l,
|
|
3062
|
+
label: W.t(l.label)
|
|
3063
|
+
})),
|
|
3064
|
+
99
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
translateMenuEntries(n) {
|
|
3068
|
+
n.reducer(
|
|
3069
|
+
"menuItems",
|
|
3070
|
+
(a) => {
|
|
3071
|
+
const s = a.find((o) => o.key === "dashboard");
|
|
3072
|
+
return s && (s.text = W.t(s.text)), a;
|
|
3073
|
+
},
|
|
3074
|
+
5
|
|
3075
|
+
);
|
|
3076
|
+
}
|
|
3077
|
+
translateMassActions(n) {
|
|
3078
|
+
n.reducer(
|
|
3079
|
+
"massActions",
|
|
3080
|
+
(a) => a.map((s) => ({
|
|
3081
|
+
...s,
|
|
3082
|
+
label: W.t(s.label)
|
|
3083
|
+
})),
|
|
3084
|
+
99
|
|
3085
|
+
);
|
|
3086
|
+
}
|
|
3087
|
+
translateInstanceActions(n) {
|
|
3088
|
+
n.reducer(
|
|
3089
|
+
"instanceActions",
|
|
3090
|
+
(a) => a.map((s) => ({
|
|
3091
|
+
...s,
|
|
3092
|
+
label: W.t(s.label)
|
|
3093
|
+
})),
|
|
3094
|
+
99
|
|
3095
|
+
);
|
|
3096
|
+
}
|
|
3097
|
+
translateStaticActions(n) {
|
|
3098
|
+
n.reducer(
|
|
3099
|
+
"staticActions",
|
|
3100
|
+
(a, s) => {
|
|
3101
|
+
const o = a.find(({ key: l }) => l === "create");
|
|
3102
|
+
return o && (o.label = W.t("Create :model", {
|
|
3103
|
+
model: s.singular()
|
|
3104
|
+
})), a;
|
|
3105
|
+
}
|
|
3106
|
+
);
|
|
3107
|
+
}
|
|
3108
|
+
translateFormLabels(n) {
|
|
3109
|
+
n.reducer(
|
|
3110
|
+
"getDefaultInputProps",
|
|
3111
|
+
(a) => (Array.isArray(a) ? a.map((s) => {
|
|
3112
|
+
s.label && (s.label = W.t(s.label));
|
|
3113
|
+
}) : a.label && (a.label = W.t(a.label)), a),
|
|
3114
|
+
99
|
|
3115
|
+
);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
const Zr = {
|
|
3119
|
+
palette: {
|
|
3120
|
+
primary: {
|
|
3121
|
+
main: "#1d9798"
|
|
3122
|
+
},
|
|
3123
|
+
secondary: {
|
|
3124
|
+
main: "#fa510c"
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
}, ca = ({
|
|
3128
|
+
theme: e = Zr,
|
|
3129
|
+
plugins: t,
|
|
3130
|
+
i18nOptions: n = {}
|
|
3131
|
+
}) => {
|
|
3132
|
+
const a = le("(prefers-color-scheme: dark)"), s = p.useMemo(() => Sn({
|
|
3133
|
+
...e,
|
|
3134
|
+
palette: {
|
|
3135
|
+
...e.palette,
|
|
3136
|
+
mode: a ? "dark" : "light"
|
|
3137
|
+
}
|
|
3138
|
+
}), [e, a]);
|
|
3139
|
+
return /* @__PURE__ */ m(kn, { theme: s, children: [
|
|
3140
|
+
/* @__PURE__ */ r(rn, {}),
|
|
3141
|
+
/* @__PURE__ */ r(
|
|
3142
|
+
Dt,
|
|
3143
|
+
{
|
|
3144
|
+
routes: (o) => o.make("cms").getRoutes(),
|
|
3145
|
+
plugins: [
|
|
3146
|
+
new $r(),
|
|
3147
|
+
new Hr(n),
|
|
3148
|
+
...t || []
|
|
3149
|
+
],
|
|
3150
|
+
config: {
|
|
3151
|
+
app: {
|
|
3152
|
+
debug: !0,
|
|
3153
|
+
url: "http://localhost"
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
)
|
|
3158
|
+
] });
|
|
3159
|
+
};
|
|
3160
|
+
export {
|
|
3161
|
+
$r as CmsPlugin,
|
|
3162
|
+
ca as LuminixCms
|
|
3163
|
+
};
|