@alepha/ui 0.13.0 → 0.13.1
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/dist/admin/{AdminFiles-CllAxb1B.js → AdminFiles-BjofP3OC.js} +11 -11
- package/dist/admin/AdminFiles-BjofP3OC.js.map +1 -0
- package/dist/admin/AdminFiles-DldZB7oo.js +3 -0
- package/dist/admin/AdminJobs-BOq6AZOW.js +3 -0
- package/dist/admin/{AdminJobs-BXkFtlVo.js → AdminJobs-CDnVxEv6.js} +11 -11
- package/dist/admin/AdminJobs-CDnVxEv6.js.map +1 -0
- package/dist/admin/AdminLayout-Bgx25J8m.js +3 -0
- package/dist/admin/{AdminLayout-CtkVYk-u.js → AdminLayout-CervL8LV.js} +6 -6
- package/dist/admin/AdminLayout-CervL8LV.js.map +1 -0
- package/dist/admin/AdminNotifications-BDQXt3-e.js +3 -0
- package/dist/admin/{AdminNotifications-DnnulNNV.js → AdminNotifications-DvI2989x.js} +6 -6
- package/dist/admin/AdminNotifications-DvI2989x.js.map +1 -0
- package/dist/admin/{AdminParameters-B3hvpLpu.js → AdminParameters-CWi7crdn.js} +6 -6
- package/dist/admin/AdminParameters-CWi7crdn.js.map +1 -0
- package/dist/admin/AdminParameters-DKRAVen3.js +3 -0
- package/dist/admin/{AdminSessions-Pjdz-iZx.js → AdminSessions-CmDVneE2.js} +11 -11
- package/dist/admin/AdminSessions-CmDVneE2.js.map +1 -0
- package/dist/admin/AdminSessions-Dkk_fzWK.js +3 -0
- package/dist/admin/{AdminUsers-C1HsrRxn.js → AdminUsers-88De5pev.js} +9 -9
- package/dist/admin/AdminUsers-88De5pev.js.map +1 -0
- package/dist/admin/AdminUsers-oyAXqZ5l.js +3 -0
- package/dist/admin/AdminVerifications-D93TKymL.js +3 -0
- package/dist/admin/{AdminVerifications-VMpm30mS.js → AdminVerifications-DBVEoqJe.js} +6 -6
- package/dist/admin/AdminVerifications-DBVEoqJe.js.map +1 -0
- package/dist/admin/index.d.ts +80 -80
- package/dist/admin/index.js +17 -17
- package/dist/auth/{IconGoogle-Bfmuv9Rv.js → IconGoogle-v_58os2T.js} +1 -1
- package/dist/auth/{IconGoogle-Bfmuv9Rv.js.map → IconGoogle-v_58os2T.js.map} +1 -1
- package/dist/auth/Login-BC2jTczq.js +4 -0
- package/dist/auth/{Login-JeXFsUf5.js → Login-OCrvjs9U.js} +12 -12
- package/dist/auth/Login-OCrvjs9U.js.map +1 -0
- package/dist/auth/Register-Dh0lsQmI.js +4 -0
- package/dist/auth/{Register-CPQnvXCZ.js → Register-Ei34GSba.js} +16 -16
- package/dist/auth/Register-Ei34GSba.js.map +1 -0
- package/dist/auth/ResetPassword-BnlAQAOE.js +3 -0
- package/dist/auth/{ResetPassword-BzUjGG_-.js → ResetPassword-tO0oMzfo.js} +12 -12
- package/dist/auth/ResetPassword-tO0oMzfo.js.map +1 -0
- package/dist/auth/index.d.ts +413 -830
- package/dist/auth/index.js +10 -10
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.d.ts +70 -70
- package/package.json +6 -9
- package/dist/admin/AdminFiles-BM6_7_5A.cjs +0 -4
- package/dist/admin/AdminFiles-BaCIMeNt.js +0 -4
- package/dist/admin/AdminFiles-CllAxb1B.js.map +0 -1
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs +0 -122
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs.map +0 -1
- package/dist/admin/AdminJobs-BXkFtlVo.js.map +0 -1
- package/dist/admin/AdminJobs-C428qrNQ.cjs +0 -130
- package/dist/admin/AdminJobs-C428qrNQ.cjs.map +0 -1
- package/dist/admin/AdminJobs-DCPPaJ4i.cjs +0 -4
- package/dist/admin/AdminJobs-yC6DarGO.js +0 -4
- package/dist/admin/AdminLayout-Bqo4cd33.cjs +0 -4
- package/dist/admin/AdminLayout-CQpxfko6.js +0 -4
- package/dist/admin/AdminLayout-CiLlywAQ.cjs +0 -93
- package/dist/admin/AdminLayout-CiLlywAQ.cjs.map +0 -1
- package/dist/admin/AdminLayout-CtkVYk-u.js.map +0 -1
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs +0 -44
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs.map +0 -1
- package/dist/admin/AdminNotifications-DaMu1AQ4.js +0 -4
- package/dist/admin/AdminNotifications-DnnulNNV.js.map +0 -1
- package/dist/admin/AdminNotifications-ihgbKVCx.cjs +0 -4
- package/dist/admin/AdminParameters-B3hvpLpu.js.map +0 -1
- package/dist/admin/AdminParameters-U4lU1rUF.cjs +0 -4
- package/dist/admin/AdminParameters-gdf7036N.cjs +0 -44
- package/dist/admin/AdminParameters-gdf7036N.cjs.map +0 -1
- package/dist/admin/AdminParameters-prMcCgxf.js +0 -4
- package/dist/admin/AdminSessions-BF_P4lHs.cjs +0 -128
- package/dist/admin/AdminSessions-BF_P4lHs.cjs.map +0 -1
- package/dist/admin/AdminSessions-CATIU61I.cjs +0 -4
- package/dist/admin/AdminSessions-DqOXOpYR.js +0 -4
- package/dist/admin/AdminSessions-Pjdz-iZx.js.map +0 -1
- package/dist/admin/AdminUsers-BgTL-zSY.js +0 -4
- package/dist/admin/AdminUsers-C1HsrRxn.js.map +0 -1
- package/dist/admin/AdminUsers-HqvxwNGZ.cjs +0 -4
- package/dist/admin/AdminUsers-M2uEQbp5.cjs +0 -109
- package/dist/admin/AdminUsers-M2uEQbp5.cjs.map +0 -1
- package/dist/admin/AdminVerifications-BVssbtfU.cjs +0 -44
- package/dist/admin/AdminVerifications-BVssbtfU.cjs.map +0 -1
- package/dist/admin/AdminVerifications-Df6DRgNo.js +0 -4
- package/dist/admin/AdminVerifications-DxAtcYUR.cjs +0 -4
- package/dist/admin/AdminVerifications-VMpm30mS.js.map +0 -1
- package/dist/admin/core-CzO6aavT.js +0 -2507
- package/dist/admin/core-CzO6aavT.js.map +0 -1
- package/dist/admin/core-aFtK4l9I.cjs +0 -2530
- package/dist/admin/core-aFtK4l9I.cjs.map +0 -1
- package/dist/admin/index.cjs +0 -87
- package/dist/admin/index.cjs.map +0 -1
- package/dist/admin/index.d.cts +0 -1739
- package/dist/auth/IconGoogle-B17BTQyD.cjs +0 -69
- package/dist/auth/IconGoogle-B17BTQyD.cjs.map +0 -1
- package/dist/auth/Login-BTBmbnWl.cjs +0 -181
- package/dist/auth/Login-BTBmbnWl.cjs.map +0 -1
- package/dist/auth/Login-BcQOtG3v.js +0 -5
- package/dist/auth/Login-Btmd70Um.cjs +0 -5
- package/dist/auth/Login-JeXFsUf5.js.map +0 -1
- package/dist/auth/Register-CPQnvXCZ.js.map +0 -1
- package/dist/auth/Register-CbesZal3.cjs +0 -5
- package/dist/auth/Register-DpI_JdyO.js +0 -5
- package/dist/auth/Register-HP3rP71B.cjs +0 -323
- package/dist/auth/Register-HP3rP71B.cjs.map +0 -1
- package/dist/auth/ResetPassword-B-tkzV7g.cjs +0 -248
- package/dist/auth/ResetPassword-B-tkzV7g.cjs.map +0 -1
- package/dist/auth/ResetPassword-BlK3xEpU.js +0 -4
- package/dist/auth/ResetPassword-BzUjGG_-.js.map +0 -1
- package/dist/auth/ResetPassword-W3xjOnWy.cjs +0 -4
- package/dist/auth/chunk-DhGyd7sr.js +0 -28
- package/dist/auth/core-D1MHij1j.js +0 -1795
- package/dist/auth/core-D1MHij1j.js.map +0 -1
- package/dist/auth/core-rDZ9d92K.cjs +0 -1824
- package/dist/auth/core-rDZ9d92K.cjs.map +0 -1
- package/dist/auth/index.cjs +0 -211
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.d.cts +0 -6265
- package/dist/core/index.cjs +0 -2620
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -2737
|
@@ -1,2530 +0,0 @@
|
|
|
1
|
-
let __alepha_react_form = require("@alepha/react/form");
|
|
2
|
-
let __alepha_react_head = require("@alepha/react/head");
|
|
3
|
-
let __alepha_react_i18n = require("@alepha/react/i18n");
|
|
4
|
-
let alepha = require("alepha");
|
|
5
|
-
let __alepha_react = require("@alepha/react");
|
|
6
|
-
let __mantine_core = require("@mantine/core");
|
|
7
|
-
let __mantine_modals = require("@mantine/modals");
|
|
8
|
-
let __mantine_notifications = require("@mantine/notifications");
|
|
9
|
-
let __mantine_nprogress = require("@mantine/nprogress");
|
|
10
|
-
let __tabler_icons_react = require("@tabler/icons-react");
|
|
11
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
-
let __mantine_spotlight = require("@mantine/spotlight");
|
|
13
|
-
let react = require("react");
|
|
14
|
-
let __mantine_dates = require("@mantine/dates");
|
|
15
|
-
let alepha_orm = require("alepha/orm");
|
|
16
|
-
let __mantine_hooks = require("@mantine/hooks");
|
|
17
|
-
let alepha_datetime = require("alepha/datetime");
|
|
18
|
-
|
|
19
|
-
//#region src/core/services/ToastService.tsx
|
|
20
|
-
var ToastService = class {
|
|
21
|
-
raw = __mantine_notifications.notifications;
|
|
22
|
-
options = { default: {
|
|
23
|
-
radius: "md",
|
|
24
|
-
withBorder: true,
|
|
25
|
-
withCloseButton: true,
|
|
26
|
-
autoClose: 5e3,
|
|
27
|
-
position: "top-center"
|
|
28
|
-
} };
|
|
29
|
-
show(options) {
|
|
30
|
-
__mantine_notifications.notifications.show({
|
|
31
|
-
...this.options.default,
|
|
32
|
-
...options
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
info(options) {
|
|
36
|
-
if (typeof options === "string") options = { message: options };
|
|
37
|
-
this.show({
|
|
38
|
-
color: "blue",
|
|
39
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconInfoCircle, { size: 20 }),
|
|
40
|
-
title: "Info",
|
|
41
|
-
message: "Information notification",
|
|
42
|
-
...options
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
success(options) {
|
|
46
|
-
if (typeof options === "string") options = { message: options };
|
|
47
|
-
this.show({
|
|
48
|
-
color: "green",
|
|
49
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCheck, { size: 16 }),
|
|
50
|
-
title: "Success",
|
|
51
|
-
message: "Operation completed successfully",
|
|
52
|
-
...options
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
warning(options) {
|
|
56
|
-
if (typeof options === "string") options = { message: options };
|
|
57
|
-
this.show({
|
|
58
|
-
color: "yellow",
|
|
59
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconAlertTriangle, { size: 20 }),
|
|
60
|
-
title: "Warning",
|
|
61
|
-
message: "Please review this warning",
|
|
62
|
-
...options
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
danger(options) {
|
|
66
|
-
if (typeof options === "string") options = { message: options };
|
|
67
|
-
this.show({
|
|
68
|
-
color: "red",
|
|
69
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconX, { size: 20 }),
|
|
70
|
-
title: "Error",
|
|
71
|
-
message: "An error occurred",
|
|
72
|
-
...options
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/core/hooks/useToast.ts
|
|
79
|
-
/**
|
|
80
|
-
* Use this hook to access the Toast Service for showing notifications.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```tsx
|
|
84
|
-
* const toast = useToast();
|
|
85
|
-
* toast.success({ message: "Operation completed successfully!" });
|
|
86
|
-
* toast.error({ title: "Error", message: "Something went wrong" });
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
const useToast = () => {
|
|
90
|
-
return (0, __alepha_react.useInject)(ToastService);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/core/components/layout/Omnibar.tsx
|
|
95
|
-
const Omnibar = (props) => {
|
|
96
|
-
const shortcut = props.shortcut ?? "mod+K";
|
|
97
|
-
const searchPlaceholder = props.searchPlaceholder ?? "Search...";
|
|
98
|
-
const nothingFound = props.nothingFound ?? "Nothing found...";
|
|
99
|
-
const router = (0, __alepha_react.useRouter)();
|
|
100
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_spotlight.Spotlight, {
|
|
101
|
-
actions: (0, react.useMemo)(() => router.concretePages.map((page) => ({
|
|
102
|
-
id: page.name,
|
|
103
|
-
label: page.label ?? page.name,
|
|
104
|
-
description: page.description,
|
|
105
|
-
onClick: () => router.go(page.name),
|
|
106
|
-
leftSection: page.icon
|
|
107
|
-
})), []),
|
|
108
|
-
shortcut,
|
|
109
|
-
limit: 10,
|
|
110
|
-
searchProps: {
|
|
111
|
-
leftSection: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSearch, { size: 20 }),
|
|
112
|
-
placeholder: searchPlaceholder
|
|
113
|
-
},
|
|
114
|
-
nothingFound
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
var Omnibar_default = Omnibar;
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/core/components/layout/AlephaMantineProvider.tsx
|
|
121
|
-
const AlephaMantineProvider = (props) => {
|
|
122
|
-
const toast = useToast();
|
|
123
|
-
(0, __alepha_react.useEvents)({
|
|
124
|
-
"react:transition:begin": () => {
|
|
125
|
-
__mantine_nprogress.nprogress.start();
|
|
126
|
-
},
|
|
127
|
-
"react:transition:end": () => {
|
|
128
|
-
__mantine_nprogress.nprogress.complete();
|
|
129
|
-
},
|
|
130
|
-
"react:action:error": ({ error }) => {
|
|
131
|
-
if (error instanceof __alepha_react_form.FormValidationError) return;
|
|
132
|
-
toast.danger({
|
|
133
|
-
title: error.name || "Error",
|
|
134
|
-
message: error.message ?? "An error occurred while processing your action."
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}, []);
|
|
138
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ColorSchemeScript, {
|
|
139
|
-
defaultColorScheme: props.mantine?.defaultColorScheme,
|
|
140
|
-
...props.colorSchemeScript
|
|
141
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.MantineProvider, {
|
|
142
|
-
...props.mantine,
|
|
143
|
-
theme: { ...props.mantine?.theme },
|
|
144
|
-
children: [
|
|
145
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_notifications.Notifications, { ...props.notifications }),
|
|
146
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_nprogress.NavigationProgress, { ...props.navigationProgress }),
|
|
147
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_modals.ModalsProvider, {
|
|
148
|
-
...props.modals,
|
|
149
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Omnibar_default, { ...props.omnibar }), props.children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alepha_react.NestedView, {})]
|
|
150
|
-
})
|
|
151
|
-
]
|
|
152
|
-
})] });
|
|
153
|
-
};
|
|
154
|
-
var AlephaMantineProvider_default = AlephaMantineProvider;
|
|
155
|
-
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/core/RootRouter.ts
|
|
158
|
-
var RootRouter = class {
|
|
159
|
-
root = (0, __alepha_react.$page)({
|
|
160
|
-
path: "/",
|
|
161
|
-
component: AlephaMantineProvider_default
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/core/components/data/JsonViewer.tsx
|
|
167
|
-
const getSizeConfig = (size = "sm") => {
|
|
168
|
-
const configs = {
|
|
169
|
-
xs: {
|
|
170
|
-
text: "xs",
|
|
171
|
-
icon: 12,
|
|
172
|
-
indent: 16,
|
|
173
|
-
gap: 2
|
|
174
|
-
},
|
|
175
|
-
sm: {
|
|
176
|
-
text: "sm",
|
|
177
|
-
icon: 14,
|
|
178
|
-
indent: 20,
|
|
179
|
-
gap: 4
|
|
180
|
-
},
|
|
181
|
-
md: {
|
|
182
|
-
text: "md",
|
|
183
|
-
icon: 16,
|
|
184
|
-
indent: 24,
|
|
185
|
-
gap: 6
|
|
186
|
-
},
|
|
187
|
-
lg: {
|
|
188
|
-
text: "lg",
|
|
189
|
-
icon: 18,
|
|
190
|
-
indent: 28,
|
|
191
|
-
gap: 8
|
|
192
|
-
},
|
|
193
|
-
xl: {
|
|
194
|
-
text: "xl",
|
|
195
|
-
icon: 20,
|
|
196
|
-
indent: 32,
|
|
197
|
-
gap: 10
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
return configs[size] || configs.sm;
|
|
201
|
-
};
|
|
202
|
-
const JsonNode = ({ name, value, depth, maxDepth, isLast = false, isArrayItem = false, size = "sm" }) => {
|
|
203
|
-
const [expanded, setExpanded] = (0, react.useState)(depth < 2);
|
|
204
|
-
const sizeConfig = getSizeConfig(size);
|
|
205
|
-
const getValueType = (val) => {
|
|
206
|
-
if (val === null) return "null";
|
|
207
|
-
if (val === void 0) return "undefined";
|
|
208
|
-
if (Array.isArray(val)) return "array";
|
|
209
|
-
return typeof val;
|
|
210
|
-
};
|
|
211
|
-
const valueType = getValueType(value);
|
|
212
|
-
const renderPrimitive = (val) => {
|
|
213
|
-
switch (getValueType(val)) {
|
|
214
|
-
case "string": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Text, {
|
|
215
|
-
component: "span",
|
|
216
|
-
c: "teal",
|
|
217
|
-
ff: "monospace",
|
|
218
|
-
size: sizeConfig.text,
|
|
219
|
-
style: { whiteSpace: "nowrap" },
|
|
220
|
-
children: [
|
|
221
|
-
"\"",
|
|
222
|
-
val,
|
|
223
|
-
"\""
|
|
224
|
-
]
|
|
225
|
-
});
|
|
226
|
-
case "number": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
227
|
-
component: "span",
|
|
228
|
-
c: "blue",
|
|
229
|
-
ff: "monospace",
|
|
230
|
-
size: sizeConfig.text,
|
|
231
|
-
style: { whiteSpace: "nowrap" },
|
|
232
|
-
children: val
|
|
233
|
-
});
|
|
234
|
-
case "boolean": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
235
|
-
component: "span",
|
|
236
|
-
c: "violet",
|
|
237
|
-
ff: "monospace",
|
|
238
|
-
size: sizeConfig.text,
|
|
239
|
-
style: { whiteSpace: "nowrap" },
|
|
240
|
-
children: String(val)
|
|
241
|
-
});
|
|
242
|
-
case "null": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
243
|
-
component: "span",
|
|
244
|
-
c: "dimmed",
|
|
245
|
-
ff: "monospace",
|
|
246
|
-
size: sizeConfig.text,
|
|
247
|
-
style: { whiteSpace: "nowrap" },
|
|
248
|
-
children: "null"
|
|
249
|
-
});
|
|
250
|
-
case "undefined": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
251
|
-
component: "span",
|
|
252
|
-
c: "dimmed",
|
|
253
|
-
ff: "monospace",
|
|
254
|
-
size: sizeConfig.text,
|
|
255
|
-
style: { whiteSpace: "nowrap" },
|
|
256
|
-
children: "undefined"
|
|
257
|
-
});
|
|
258
|
-
default: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
259
|
-
component: "span",
|
|
260
|
-
ff: "monospace",
|
|
261
|
-
size: sizeConfig.text,
|
|
262
|
-
style: { whiteSpace: "nowrap" },
|
|
263
|
-
children: String(val)
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
const renderKey = () => {
|
|
268
|
-
if (!name) return null;
|
|
269
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Text, {
|
|
270
|
-
component: "span",
|
|
271
|
-
c: "cyan",
|
|
272
|
-
ff: "monospace",
|
|
273
|
-
fw: 500,
|
|
274
|
-
size: sizeConfig.text,
|
|
275
|
-
children: [isArrayItem ? `[${name}]` : `"${name}"`, ":"]
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
if (valueType === "object" || valueType === "array") {
|
|
279
|
-
const isObject = valueType === "object";
|
|
280
|
-
const entries = isObject ? Object.entries(value) : value.map((v, i) => [i, v]);
|
|
281
|
-
const isEmpty = entries.length === 0;
|
|
282
|
-
const canExpand = depth < maxDepth && !isEmpty;
|
|
283
|
-
const preview = isObject ? "{...}" : "[...]";
|
|
284
|
-
const brackets = isObject ? ["{", "}"] : ["[", "]"];
|
|
285
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Box, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Box, {
|
|
286
|
-
style: {
|
|
287
|
-
display: "flex",
|
|
288
|
-
alignItems: "center",
|
|
289
|
-
gap: sizeConfig.gap,
|
|
290
|
-
minWidth: "max-content"
|
|
291
|
-
},
|
|
292
|
-
children: [
|
|
293
|
-
canExpand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ActionIcon, {
|
|
294
|
-
size: "xs",
|
|
295
|
-
variant: "transparent",
|
|
296
|
-
c: "dimmed",
|
|
297
|
-
onClick: () => setExpanded(!expanded),
|
|
298
|
-
style: {
|
|
299
|
-
cursor: "pointer",
|
|
300
|
-
flexShrink: 0
|
|
301
|
-
},
|
|
302
|
-
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconChevronDown, { size: sizeConfig.icon }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconChevronRight, { size: sizeConfig.icon })
|
|
303
|
-
}),
|
|
304
|
-
!canExpand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
305
|
-
w: sizeConfig.icon + 6,
|
|
306
|
-
style: { flexShrink: 0 }
|
|
307
|
-
}),
|
|
308
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
309
|
-
style: { flexShrink: 0 },
|
|
310
|
-
children: renderKey()
|
|
311
|
-
}),
|
|
312
|
-
" ",
|
|
313
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
314
|
-
component: "span",
|
|
315
|
-
c: "dimmed",
|
|
316
|
-
ff: "monospace",
|
|
317
|
-
size: sizeConfig.text,
|
|
318
|
-
style: { flexShrink: 0 },
|
|
319
|
-
children: brackets[0]
|
|
320
|
-
}),
|
|
321
|
-
!expanded && !isEmpty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
322
|
-
component: "span",
|
|
323
|
-
c: "dimmed",
|
|
324
|
-
ff: "monospace",
|
|
325
|
-
fs: "italic",
|
|
326
|
-
size: sizeConfig.text,
|
|
327
|
-
style: { flexShrink: 0 },
|
|
328
|
-
children: preview
|
|
329
|
-
}),
|
|
330
|
-
(isEmpty || !expanded) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
331
|
-
component: "span",
|
|
332
|
-
c: "dimmed",
|
|
333
|
-
ff: "monospace",
|
|
334
|
-
size: sizeConfig.text,
|
|
335
|
-
style: { flexShrink: 0 },
|
|
336
|
-
children: brackets[1]
|
|
337
|
-
}),
|
|
338
|
-
!isEmpty && !expanded && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Text, {
|
|
339
|
-
component: "span",
|
|
340
|
-
c: "dimmed",
|
|
341
|
-
size: sizeConfig.text,
|
|
342
|
-
style: { flexShrink: 0 },
|
|
343
|
-
children: [
|
|
344
|
-
entries.length,
|
|
345
|
-
" ",
|
|
346
|
-
entries.length === 1 ? "item" : "items"
|
|
347
|
-
]
|
|
348
|
-
})
|
|
349
|
-
]
|
|
350
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Collapse, {
|
|
351
|
-
in: expanded && canExpand,
|
|
352
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
353
|
-
pl: sizeConfig.indent,
|
|
354
|
-
style: {
|
|
355
|
-
borderLeft: "1px solid var(--mantine-color-default-border)",
|
|
356
|
-
marginLeft: Math.floor((sizeConfig.icon + 6) / 2)
|
|
357
|
-
},
|
|
358
|
-
children: entries.map(([key, val], index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonNode, {
|
|
359
|
-
name: String(key),
|
|
360
|
-
value: val,
|
|
361
|
-
depth: depth + 1,
|
|
362
|
-
maxDepth,
|
|
363
|
-
isLast: index === entries.length - 1,
|
|
364
|
-
isArrayItem: !isObject,
|
|
365
|
-
size
|
|
366
|
-
}, String(key)))
|
|
367
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Box, {
|
|
368
|
-
style: {
|
|
369
|
-
display: "flex",
|
|
370
|
-
minWidth: "max-content"
|
|
371
|
-
},
|
|
372
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
373
|
-
w: sizeConfig.icon + 6,
|
|
374
|
-
style: { flexShrink: 0 }
|
|
375
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
376
|
-
c: "dimmed",
|
|
377
|
-
ff: "monospace",
|
|
378
|
-
size: sizeConfig.text,
|
|
379
|
-
style: { flexShrink: 0 },
|
|
380
|
-
children: brackets[1]
|
|
381
|
-
})]
|
|
382
|
-
})]
|
|
383
|
-
})] });
|
|
384
|
-
}
|
|
385
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Box, {
|
|
386
|
-
style: {
|
|
387
|
-
display: "flex",
|
|
388
|
-
alignItems: "center",
|
|
389
|
-
gap: sizeConfig.gap,
|
|
390
|
-
minWidth: "max-content"
|
|
391
|
-
},
|
|
392
|
-
children: [
|
|
393
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
394
|
-
w: sizeConfig.icon + 6,
|
|
395
|
-
style: { flexShrink: 0 }
|
|
396
|
-
}),
|
|
397
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
398
|
-
style: { flexShrink: 0 },
|
|
399
|
-
children: renderKey()
|
|
400
|
-
}),
|
|
401
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
402
|
-
style: { flexShrink: 0 },
|
|
403
|
-
children: renderPrimitive(value)
|
|
404
|
-
}),
|
|
405
|
-
!isLast && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
406
|
-
component: "span",
|
|
407
|
-
c: "dimmed",
|
|
408
|
-
ff: "monospace",
|
|
409
|
-
size: sizeConfig.text,
|
|
410
|
-
style: { flexShrink: 0 },
|
|
411
|
-
children: ","
|
|
412
|
-
})
|
|
413
|
-
]
|
|
414
|
-
});
|
|
415
|
-
};
|
|
416
|
-
const JsonViewer = ({ data, defaultExpanded = true, maxDepth = 10, copyable = true, size = "sm" }) => {
|
|
417
|
-
const copyIconSize = getSizeConfig(size).icon + 2;
|
|
418
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Box, {
|
|
419
|
-
pos: "relative",
|
|
420
|
-
w: "100%",
|
|
421
|
-
children: [copyable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
422
|
-
pos: "absolute",
|
|
423
|
-
top: 0,
|
|
424
|
-
right: 0,
|
|
425
|
-
style: { zIndex: 1 },
|
|
426
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.CopyButton, {
|
|
427
|
-
value: JSON.stringify(data, null, 2),
|
|
428
|
-
children: ({ copied, copy }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Tooltip, {
|
|
429
|
-
label: copied ? "Copied" : "Copy JSON",
|
|
430
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ActionIcon, {
|
|
431
|
-
color: copied ? "teal" : "gray",
|
|
432
|
-
variant: "subtle",
|
|
433
|
-
onClick: copy,
|
|
434
|
-
size,
|
|
435
|
-
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCheck, { size: copyIconSize }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCopy, { size: copyIconSize })
|
|
436
|
-
})
|
|
437
|
-
})
|
|
438
|
-
})
|
|
439
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Box, {
|
|
440
|
-
pt: copyable ? 30 : 0,
|
|
441
|
-
style: { overflowX: "auto" },
|
|
442
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonNode, {
|
|
443
|
-
value: data,
|
|
444
|
-
depth: 0,
|
|
445
|
-
maxDepth,
|
|
446
|
-
size
|
|
447
|
-
})
|
|
448
|
-
})]
|
|
449
|
-
});
|
|
450
|
-
};
|
|
451
|
-
var JsonViewer_default = JsonViewer;
|
|
452
|
-
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/core/components/dialogs/AlertDialog.tsx
|
|
455
|
-
const AlertDialog = ({ options, onClose }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [options?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
456
|
-
mb: "md",
|
|
457
|
-
children: options.message
|
|
458
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Group, {
|
|
459
|
-
justify: "flex-end",
|
|
460
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
461
|
-
onClick: onClose,
|
|
462
|
-
children: options?.okLabel || "OK"
|
|
463
|
-
})
|
|
464
|
-
})] });
|
|
465
|
-
var AlertDialog_default = AlertDialog;
|
|
466
|
-
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region src/core/components/dialogs/ConfirmDialog.tsx
|
|
469
|
-
const ConfirmDialog = ({ options, onConfirm }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [options?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
470
|
-
mb: "md",
|
|
471
|
-
children: options.message
|
|
472
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
473
|
-
justify: "flex-end",
|
|
474
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
475
|
-
variant: "subtle",
|
|
476
|
-
onClick: () => onConfirm(false),
|
|
477
|
-
children: options?.cancelLabel || "Cancel"
|
|
478
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
479
|
-
color: options?.confirmColor || "blue",
|
|
480
|
-
onClick: () => onConfirm(true),
|
|
481
|
-
children: options?.confirmLabel || "Confirm"
|
|
482
|
-
})]
|
|
483
|
-
})] });
|
|
484
|
-
var ConfirmDialog_default = ConfirmDialog;
|
|
485
|
-
|
|
486
|
-
//#endregion
|
|
487
|
-
//#region src/core/components/dialogs/PromptDialog.tsx
|
|
488
|
-
const PromptDialog = ({ options, onSubmit }) => {
|
|
489
|
-
const [value, setValue] = (0, react.useState)(options?.defaultValue || "");
|
|
490
|
-
const inputRef = (0, react.useRef)(null);
|
|
491
|
-
(0, react.useEffect)(() => {
|
|
492
|
-
inputRef.current?.focus();
|
|
493
|
-
}, []);
|
|
494
|
-
const handleSubmit = () => {
|
|
495
|
-
if (!options?.required || value.trim()) onSubmit(value);
|
|
496
|
-
};
|
|
497
|
-
const handleKeyDown = (event) => {
|
|
498
|
-
if (event.key === "Enter") handleSubmit();
|
|
499
|
-
};
|
|
500
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
501
|
-
options?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
502
|
-
mb: "md",
|
|
503
|
-
children: options.message
|
|
504
|
-
}),
|
|
505
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.TextInput, {
|
|
506
|
-
ref: inputRef,
|
|
507
|
-
label: options?.label,
|
|
508
|
-
placeholder: options?.placeholder,
|
|
509
|
-
value,
|
|
510
|
-
onChange: (event) => setValue(event.currentTarget.value),
|
|
511
|
-
onKeyDown: handleKeyDown,
|
|
512
|
-
required: options?.required,
|
|
513
|
-
mb: "md"
|
|
514
|
-
}),
|
|
515
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
516
|
-
justify: "flex-end",
|
|
517
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
518
|
-
variant: "subtle",
|
|
519
|
-
onClick: () => onSubmit(null),
|
|
520
|
-
children: options?.cancelLabel || "Cancel"
|
|
521
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
522
|
-
onClick: handleSubmit,
|
|
523
|
-
disabled: options?.required && !value.trim(),
|
|
524
|
-
children: options?.submitLabel || "OK"
|
|
525
|
-
})]
|
|
526
|
-
})
|
|
527
|
-
] });
|
|
528
|
-
};
|
|
529
|
-
var PromptDialog_default = PromptDialog;
|
|
530
|
-
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region src/core/constants/ui.ts
|
|
533
|
-
const ui = {
|
|
534
|
-
colors: {
|
|
535
|
-
transparent: "transparent",
|
|
536
|
-
background: "var(--alepha-background)",
|
|
537
|
-
surface: "var(--alepha-surface)",
|
|
538
|
-
elevated: "var(--alepha-elevated)",
|
|
539
|
-
border: "var(--alepha-border)"
|
|
540
|
-
},
|
|
541
|
-
sizes: { icon: {
|
|
542
|
-
xs: 12,
|
|
543
|
-
sm: 16,
|
|
544
|
-
md: 20,
|
|
545
|
-
lg: 24,
|
|
546
|
-
xl: 32
|
|
547
|
-
} }
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
//#endregion
|
|
551
|
-
//#region src/core/services/DialogService.tsx
|
|
552
|
-
var DialogService = class {
|
|
553
|
-
options = { default: {
|
|
554
|
-
centered: true,
|
|
555
|
-
withCloseButton: true,
|
|
556
|
-
size: "md",
|
|
557
|
-
overlayProps: {
|
|
558
|
-
backgroundOpacity: .55,
|
|
559
|
-
blur: 3
|
|
560
|
-
},
|
|
561
|
-
transitionProps: {
|
|
562
|
-
transition: "pop",
|
|
563
|
-
duration: 200
|
|
564
|
-
}
|
|
565
|
-
} };
|
|
566
|
-
/**
|
|
567
|
-
* Show an alert dialog with a message
|
|
568
|
-
*/
|
|
569
|
-
alert(options) {
|
|
570
|
-
return new Promise((resolve) => {
|
|
571
|
-
const modalId = this.open({
|
|
572
|
-
...options,
|
|
573
|
-
title: options?.title || "Alert",
|
|
574
|
-
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AlertDialog_default, {
|
|
575
|
-
options,
|
|
576
|
-
onClose: () => {
|
|
577
|
-
this.close(modalId);
|
|
578
|
-
resolve();
|
|
579
|
-
}
|
|
580
|
-
})
|
|
581
|
-
});
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Show a confirmation dialog that returns a promise
|
|
586
|
-
*/
|
|
587
|
-
confirm(options) {
|
|
588
|
-
return new Promise((resolve) => {
|
|
589
|
-
const modalId = this.open({
|
|
590
|
-
...options,
|
|
591
|
-
title: options?.title || "Confirm",
|
|
592
|
-
closeOnClickOutside: false,
|
|
593
|
-
closeOnEscape: false,
|
|
594
|
-
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfirmDialog_default, {
|
|
595
|
-
options,
|
|
596
|
-
onConfirm: (confirmed) => {
|
|
597
|
-
this.close(modalId);
|
|
598
|
-
resolve(confirmed);
|
|
599
|
-
}
|
|
600
|
-
})
|
|
601
|
-
});
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Show a prompt dialog to get user input
|
|
606
|
-
*/
|
|
607
|
-
prompt(options) {
|
|
608
|
-
return new Promise((resolve) => {
|
|
609
|
-
const modalId = this.open({
|
|
610
|
-
...options,
|
|
611
|
-
title: options?.title || "Input",
|
|
612
|
-
closeOnClickOutside: false,
|
|
613
|
-
closeOnEscape: false,
|
|
614
|
-
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromptDialog_default, {
|
|
615
|
-
options,
|
|
616
|
-
onSubmit: (value) => {
|
|
617
|
-
this.close(modalId);
|
|
618
|
-
resolve(value);
|
|
619
|
-
}
|
|
620
|
-
})
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Open a custom dialog with provided content
|
|
626
|
-
*/
|
|
627
|
-
open(options) {
|
|
628
|
-
return __mantine_modals.modals.open({
|
|
629
|
-
...this.options.default,
|
|
630
|
-
...options,
|
|
631
|
-
children: options?.content || options?.message
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* Close the currently open dialog or a specific dialog by ID
|
|
636
|
-
*/
|
|
637
|
-
close(modalId) {
|
|
638
|
-
if (modalId) __mantine_modals.modals.close(modalId);
|
|
639
|
-
else __mantine_modals.modals.closeAll();
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Show a JSON editor/viewer dialog
|
|
643
|
-
*/
|
|
644
|
-
json(data, options) {
|
|
645
|
-
this.open({
|
|
646
|
-
size: "lg",
|
|
647
|
-
title: options?.title || "Json Viewer",
|
|
648
|
-
...options,
|
|
649
|
-
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
650
|
-
bdrs: "md",
|
|
651
|
-
w: "100%",
|
|
652
|
-
flex: 1,
|
|
653
|
-
p: "sm",
|
|
654
|
-
bg: ui.colors.surface,
|
|
655
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonViewer_default, {
|
|
656
|
-
size: "xs",
|
|
657
|
-
data
|
|
658
|
-
})
|
|
659
|
-
})
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
/**
|
|
663
|
-
* Show a form dialog for structured input
|
|
664
|
-
*/
|
|
665
|
-
form(options) {
|
|
666
|
-
return Promise.resolve(null);
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Show a loading/progress dialog with optional progress percentage
|
|
670
|
-
*/
|
|
671
|
-
loading(options) {}
|
|
672
|
-
/**
|
|
673
|
-
* Show an image viewer/gallery dialog
|
|
674
|
-
*/
|
|
675
|
-
image(src, options) {}
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
//#endregion
|
|
679
|
-
//#region src/core/components/buttons/ActionButton.tsx
|
|
680
|
-
const ActionMenuItem = (props) => {
|
|
681
|
-
const { item, index } = props;
|
|
682
|
-
const router = (0, __alepha_react.useRouter)();
|
|
683
|
-
const action = (0, __alepha_react.useAction)({ handler: async (e) => {
|
|
684
|
-
await item.onClick?.();
|
|
685
|
-
} }, [item.onClick]);
|
|
686
|
-
if (item.type === "divider") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Divider, {}, index);
|
|
687
|
-
if (item.type === "label") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Label, { children: item.label }, index);
|
|
688
|
-
if (item.children && item.children.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Menu, {
|
|
689
|
-
trigger: "hover",
|
|
690
|
-
position: "right-start",
|
|
691
|
-
offset: 2,
|
|
692
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Target, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Item, {
|
|
693
|
-
leftSection: item.icon,
|
|
694
|
-
rightSection: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconChevronRight, { size: 14 }),
|
|
695
|
-
children: item.label
|
|
696
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Dropdown, { children: item.children.map((child, childIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionMenuItem, {
|
|
697
|
-
item: child,
|
|
698
|
-
index: childIndex
|
|
699
|
-
}, childIndex)) })]
|
|
700
|
-
}, index);
|
|
701
|
-
const menuItemProps = {};
|
|
702
|
-
if (props.item.onClick) menuItemProps.onClick = action.run;
|
|
703
|
-
else if (props.item.href) Object.assign(menuItemProps, router.anchor(props.item.href));
|
|
704
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Item, {
|
|
705
|
-
leftSection: item.icon,
|
|
706
|
-
onClick: item.onClick,
|
|
707
|
-
color: item.color,
|
|
708
|
-
rightSection: item.active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ThemeIcon, {
|
|
709
|
-
size: "xs",
|
|
710
|
-
variant: "transparent",
|
|
711
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCheck, {})
|
|
712
|
-
}) : void 0,
|
|
713
|
-
...menuItemProps,
|
|
714
|
-
children: item.label
|
|
715
|
-
}, index);
|
|
716
|
-
};
|
|
717
|
-
const ActionButton = (_props) => {
|
|
718
|
-
const props = {
|
|
719
|
-
variant: "default",
|
|
720
|
-
..._props
|
|
721
|
-
};
|
|
722
|
-
const { tooltip, menu, icon, ...restProps } = props;
|
|
723
|
-
if (props.icon) {
|
|
724
|
-
const icon$1 = isComponentType(props.icon) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(props.icon, { size: ui.sizes.icon.md }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ThemeIcon, {
|
|
725
|
-
w: 24,
|
|
726
|
-
variant: "transparent",
|
|
727
|
-
size: "sm",
|
|
728
|
-
c: "var(--mantine-color-text)",
|
|
729
|
-
...props.themeIconProps,
|
|
730
|
-
children: props.icon
|
|
731
|
-
});
|
|
732
|
-
if (!props.children) {
|
|
733
|
-
restProps.children = react.Children.only(icon$1);
|
|
734
|
-
restProps.p ??= "xs";
|
|
735
|
-
} else restProps.leftSection = icon$1;
|
|
736
|
-
}
|
|
737
|
-
if (props.leftSection && !props.children) {
|
|
738
|
-
restProps.className ??= "mantine-Action-iconOnly";
|
|
739
|
-
restProps.p ??= "xs";
|
|
740
|
-
}
|
|
741
|
-
if (props.textVisibleFrom) {
|
|
742
|
-
const { children, textVisibleFrom, leftSection, ...rest } = restProps;
|
|
743
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
744
|
-
w: "100%",
|
|
745
|
-
visibleFrom: textVisibleFrom,
|
|
746
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton, {
|
|
747
|
-
flex: 1,
|
|
748
|
-
...rest,
|
|
749
|
-
leftSection,
|
|
750
|
-
tooltip,
|
|
751
|
-
menu,
|
|
752
|
-
children
|
|
753
|
-
})
|
|
754
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
755
|
-
w: "100%",
|
|
756
|
-
hiddenFrom: textVisibleFrom,
|
|
757
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton, {
|
|
758
|
-
px: "xs",
|
|
759
|
-
...rest,
|
|
760
|
-
tooltip,
|
|
761
|
-
menu,
|
|
762
|
-
children: leftSection
|
|
763
|
-
})
|
|
764
|
-
})] });
|
|
765
|
-
}
|
|
766
|
-
const renderAction = () => {
|
|
767
|
-
if ("href" in restProps && restProps.href) {
|
|
768
|
-
if (restProps.href.startsWith("http") || restProps.target) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionHrefButton, {
|
|
769
|
-
...restProps,
|
|
770
|
-
href: restProps.href,
|
|
771
|
-
children: restProps.children
|
|
772
|
-
});
|
|
773
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionNavigationButton, {
|
|
774
|
-
...restProps,
|
|
775
|
-
href: restProps.href,
|
|
776
|
-
children: restProps.children
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
delete restProps.classNameActive;
|
|
780
|
-
delete restProps.variantActive;
|
|
781
|
-
if ("action" in restProps && restProps.action) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionHookButton, {
|
|
782
|
-
...restProps,
|
|
783
|
-
action: restProps.action,
|
|
784
|
-
children: restProps.children
|
|
785
|
-
});
|
|
786
|
-
if ("onClick" in restProps && restProps.onClick) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionClickButton, {
|
|
787
|
-
...restProps,
|
|
788
|
-
onClick: restProps.onClick,
|
|
789
|
-
children: restProps.children
|
|
790
|
-
});
|
|
791
|
-
if ("form" in restProps && restProps.form) {
|
|
792
|
-
if (restProps.type === "reset") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionResetButton, {
|
|
793
|
-
...restProps,
|
|
794
|
-
form: restProps.form,
|
|
795
|
-
children: restProps.children
|
|
796
|
-
});
|
|
797
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionSubmitButton, {
|
|
798
|
-
...restProps,
|
|
799
|
-
form: restProps.form,
|
|
800
|
-
children: restProps.children
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
804
|
-
...restProps,
|
|
805
|
-
children: restProps.children
|
|
806
|
-
});
|
|
807
|
-
};
|
|
808
|
-
let actionElement = renderAction();
|
|
809
|
-
if (menu) actionElement = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Menu, {
|
|
810
|
-
position: menu.position || "bottom-start",
|
|
811
|
-
width: menu.width || 200,
|
|
812
|
-
shadow: menu.shadow || "md",
|
|
813
|
-
trigger: menu.on === "hover" ? "hover" : "click",
|
|
814
|
-
...menu.menuProps,
|
|
815
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Target, {
|
|
816
|
-
...menu.targetProps,
|
|
817
|
-
children: actionElement
|
|
818
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Menu.Dropdown, { children: menu.items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionMenuItem, {
|
|
819
|
-
item,
|
|
820
|
-
index
|
|
821
|
-
}, index)) })]
|
|
822
|
-
});
|
|
823
|
-
if (tooltip) {
|
|
824
|
-
const defaultTooltipProps = { openDelay: 1e3 };
|
|
825
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Tooltip, { ...typeof tooltip === "string" ? {
|
|
826
|
-
...defaultTooltipProps,
|
|
827
|
-
label: tooltip,
|
|
828
|
-
children: actionElement
|
|
829
|
-
} : {
|
|
830
|
-
...defaultTooltipProps,
|
|
831
|
-
...tooltip,
|
|
832
|
-
children: actionElement
|
|
833
|
-
} });
|
|
834
|
-
}
|
|
835
|
-
return actionElement;
|
|
836
|
-
};
|
|
837
|
-
var ActionButton_default = ActionButton;
|
|
838
|
-
/**
|
|
839
|
-
* Action button that submits a form with loading and disabled state handling.
|
|
840
|
-
*/
|
|
841
|
-
const ActionSubmitButton = (props) => {
|
|
842
|
-
const { form, ...buttonProps } = props;
|
|
843
|
-
const state = (0, __alepha_react_form.useFormState)(form);
|
|
844
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
845
|
-
...buttonProps,
|
|
846
|
-
loading: state.loading,
|
|
847
|
-
disabled: state.loading,
|
|
848
|
-
type: "submit",
|
|
849
|
-
children: props.children
|
|
850
|
-
});
|
|
851
|
-
};
|
|
852
|
-
const ActionResetButton = (props) => {
|
|
853
|
-
const { form, ...buttonProps } = props;
|
|
854
|
-
const state = (0, __alepha_react_form.useFormState)(form);
|
|
855
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
856
|
-
...buttonProps,
|
|
857
|
-
disabled: state.loading,
|
|
858
|
-
type: "reset",
|
|
859
|
-
children: props.children
|
|
860
|
-
});
|
|
861
|
-
};
|
|
862
|
-
/**
|
|
863
|
-
* Action button that integrates with useAction hook return value.
|
|
864
|
-
* Automatically handles loading state and executes the action on click.
|
|
865
|
-
*
|
|
866
|
-
* @example
|
|
867
|
-
* ```tsx
|
|
868
|
-
* const saveAction = useAction({
|
|
869
|
-
* handler: async (data) => {
|
|
870
|
-
* await api.save(data);
|
|
871
|
-
* }
|
|
872
|
-
* }, []);
|
|
873
|
-
*
|
|
874
|
-
* <ActionButton action={saveAction}>
|
|
875
|
-
* Save
|
|
876
|
-
* </ActionButton>
|
|
877
|
-
* ```
|
|
878
|
-
*/
|
|
879
|
-
const ActionHookButton = (props) => {
|
|
880
|
-
const { action, ...buttonProps } = props;
|
|
881
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
882
|
-
...buttonProps,
|
|
883
|
-
disabled: action.loading || props.disabled,
|
|
884
|
-
loading: action.loading,
|
|
885
|
-
onClick: () => action.run(),
|
|
886
|
-
children: props.children
|
|
887
|
-
});
|
|
888
|
-
};
|
|
889
|
-
/**
|
|
890
|
-
* Basic action button that handles click events with loading and error handling.
|
|
891
|
-
*
|
|
892
|
-
* @example
|
|
893
|
-
* ```tsx
|
|
894
|
-
* <ActionButton onClick={() => api.doSomething()}>
|
|
895
|
-
* Do Something
|
|
896
|
-
* </ActionButton>
|
|
897
|
-
* ```
|
|
898
|
-
*/
|
|
899
|
-
const ActionClickButton = (props) => {
|
|
900
|
-
const action = (0, __alepha_react.useAction)({ handler: async (e) => {
|
|
901
|
-
await props.onClick(e);
|
|
902
|
-
} }, [props.onClick]);
|
|
903
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
904
|
-
...props,
|
|
905
|
-
disabled: action.loading || props.disabled,
|
|
906
|
-
loading: action.loading,
|
|
907
|
-
onClick: action.run,
|
|
908
|
-
children: props.children
|
|
909
|
-
});
|
|
910
|
-
};
|
|
911
|
-
/**
|
|
912
|
-
* Action for navigation with active state support.
|
|
913
|
-
*/
|
|
914
|
-
const ActionNavigationButton = (props) => {
|
|
915
|
-
const { active: options, classNameActive, variantActive, routerGoOptions, ...buttonProps } = props;
|
|
916
|
-
const router = (0, __alepha_react.useRouter)();
|
|
917
|
-
const { isPending, isActive } = (0, __alepha_react.useActive)(options ? {
|
|
918
|
-
href: props.href,
|
|
919
|
-
...options
|
|
920
|
-
} : { href: props.href });
|
|
921
|
-
const anchorProps = router.anchor(props.href, routerGoOptions);
|
|
922
|
-
const className = buttonProps.className || "";
|
|
923
|
-
if (isActive && options !== false && classNameActive) buttonProps.className = `${className} ${classNameActive}`.trim();
|
|
924
|
-
if (props.anchorProps) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Anchor, {
|
|
925
|
-
component: "a",
|
|
926
|
-
...anchorProps,
|
|
927
|
-
...props.anchorProps,
|
|
928
|
-
children: props.children
|
|
929
|
-
});
|
|
930
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
931
|
-
component: "a",
|
|
932
|
-
loading: isPending,
|
|
933
|
-
...buttonProps,
|
|
934
|
-
...anchorProps,
|
|
935
|
-
variant: isActive && options !== false ? variantActive ?? "filled" : buttonProps.variant ?? "subtle",
|
|
936
|
-
children: props.children
|
|
937
|
-
});
|
|
938
|
-
};
|
|
939
|
-
const ActionHrefButton = (props) => {
|
|
940
|
-
const { active: options, classNameActive, variantActive, routerGoOptions, target, ...buttonProps } = props;
|
|
941
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Button, {
|
|
942
|
-
component: "a",
|
|
943
|
-
target,
|
|
944
|
-
...buttonProps,
|
|
945
|
-
children: props.children
|
|
946
|
-
});
|
|
947
|
-
};
|
|
948
|
-
function isComponentType(param) {
|
|
949
|
-
if ((0, react.isValidElement)(param)) return false;
|
|
950
|
-
return typeof param === "function" || typeof param === "object" && param !== null && "$$typeof" in param;
|
|
951
|
-
}
|
|
952
|
-
const renderIcon = (icon) => {
|
|
953
|
-
if (!icon) return null;
|
|
954
|
-
if ((0, react.isValidElement)(icon)) return icon;
|
|
955
|
-
if (isComponentType(icon)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(icon, { size: ui.sizes.icon.md });
|
|
956
|
-
return icon;
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
//#endregion
|
|
960
|
-
//#region src/core/components/buttons/BurgerButton.tsx
|
|
961
|
-
const BurgerButton = (props) => {
|
|
962
|
-
const [opened, setOpened] = (0, __alepha_react.useStore)("alepha.ui.sidebar.opened");
|
|
963
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Burger, {
|
|
964
|
-
opened,
|
|
965
|
-
onClick: () => setOpened(!opened),
|
|
966
|
-
hiddenFrom: "sm",
|
|
967
|
-
size: "sm",
|
|
968
|
-
...props
|
|
969
|
-
});
|
|
970
|
-
};
|
|
971
|
-
var BurgerButton_default = BurgerButton;
|
|
972
|
-
|
|
973
|
-
//#endregion
|
|
974
|
-
//#region src/core/components/buttons/DarkModeButton.tsx
|
|
975
|
-
const DarkModeButton = (props) => {
|
|
976
|
-
const { setColorScheme } = (0, __mantine_core.useMantineColorScheme)();
|
|
977
|
-
const computedColorScheme = (0, __mantine_core.useComputedColorScheme)("light");
|
|
978
|
-
const [colorScheme, setColorScheme2] = (0, react.useState)("default");
|
|
979
|
-
const mode = props.mode ?? "minimal";
|
|
980
|
-
(0, react.useEffect)(() => {
|
|
981
|
-
setColorScheme2(computedColorScheme);
|
|
982
|
-
}, [computedColorScheme]);
|
|
983
|
-
const toggleColorScheme = () => {
|
|
984
|
-
setColorScheme(computedColorScheme === "dark" ? "light" : "dark");
|
|
985
|
-
};
|
|
986
|
-
if (mode === "segmented") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.SegmentedControl, {
|
|
987
|
-
value: colorScheme,
|
|
988
|
-
onChange: (value) => setColorScheme(value),
|
|
989
|
-
data: [{
|
|
990
|
-
value: "light",
|
|
991
|
-
label: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
992
|
-
h: 20,
|
|
993
|
-
align: "center",
|
|
994
|
-
justify: "center",
|
|
995
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSun, { size: 16 })
|
|
996
|
-
})
|
|
997
|
-
}, {
|
|
998
|
-
value: "dark",
|
|
999
|
-
label: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
1000
|
-
h: 20,
|
|
1001
|
-
align: "center",
|
|
1002
|
-
justify: "center",
|
|
1003
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconMoon, { size: 16 })
|
|
1004
|
-
})
|
|
1005
|
-
}],
|
|
1006
|
-
w: props.fullWidth ? "100%" : void 0,
|
|
1007
|
-
...props.segmentedProps
|
|
1008
|
-
});
|
|
1009
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1010
|
-
onClick: toggleColorScheme,
|
|
1011
|
-
variant: props.variant ?? "default",
|
|
1012
|
-
size: props.size ?? "sm",
|
|
1013
|
-
"aria-label": "Toggle color scheme",
|
|
1014
|
-
px: "xs",
|
|
1015
|
-
c: colorScheme !== "default" ? void 0 : "transparent",
|
|
1016
|
-
fullWidth: props.fullWidth ?? false,
|
|
1017
|
-
icon: colorScheme === "dark" ? __tabler_icons_react.IconSun : colorScheme === "light" ? __tabler_icons_react.IconMoon : __tabler_icons_react.IconSun,
|
|
1018
|
-
...props.actionProps
|
|
1019
|
-
});
|
|
1020
|
-
};
|
|
1021
|
-
var DarkModeButton_default = DarkModeButton;
|
|
1022
|
-
|
|
1023
|
-
//#endregion
|
|
1024
|
-
//#region src/core/components/buttons/LanguageButton.tsx
|
|
1025
|
-
const LanguageButton = (props) => {
|
|
1026
|
-
const i18n = (0, __alepha_react_i18n.useI18n)();
|
|
1027
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1028
|
-
variant: "default",
|
|
1029
|
-
icon: __tabler_icons_react.IconLanguage,
|
|
1030
|
-
menu: { items: i18n.languages.map((lang) => ({
|
|
1031
|
-
label: i18n.tr(lang),
|
|
1032
|
-
onClick: () => i18n.setLang(lang),
|
|
1033
|
-
active: i18n.lang === lang
|
|
1034
|
-
})) },
|
|
1035
|
-
...props.actionProps
|
|
1036
|
-
});
|
|
1037
|
-
};
|
|
1038
|
-
var LanguageButton_default = LanguageButton;
|
|
1039
|
-
|
|
1040
|
-
//#endregion
|
|
1041
|
-
//#region src/core/components/buttons/OmnibarButton.tsx
|
|
1042
|
-
const OmnibarButton = (props) => {
|
|
1043
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1044
|
-
variant: "default",
|
|
1045
|
-
miw: 256,
|
|
1046
|
-
onClick: __mantine_spotlight.spotlight.open,
|
|
1047
|
-
justify: "space-between",
|
|
1048
|
-
rightSection: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Kbd, {
|
|
1049
|
-
size: "sm",
|
|
1050
|
-
children: "⌘+K"
|
|
1051
|
-
}),
|
|
1052
|
-
radius: "md",
|
|
1053
|
-
...props.actionProps,
|
|
1054
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1055
|
-
align: "center",
|
|
1056
|
-
gap: "xs",
|
|
1057
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSearch, {
|
|
1058
|
-
size: 16,
|
|
1059
|
-
color: "gray"
|
|
1060
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1061
|
-
size: "xs",
|
|
1062
|
-
c: "dimmed",
|
|
1063
|
-
children: "Search..."
|
|
1064
|
-
})]
|
|
1065
|
-
})
|
|
1066
|
-
});
|
|
1067
|
-
};
|
|
1068
|
-
var OmnibarButton_default = OmnibarButton;
|
|
1069
|
-
|
|
1070
|
-
//#endregion
|
|
1071
|
-
//#region src/core/utils/icons.tsx
|
|
1072
|
-
/**
|
|
1073
|
-
* Get the default icon for an input based on its type, format, or name.
|
|
1074
|
-
*/
|
|
1075
|
-
const getDefaultIcon = (params) => {
|
|
1076
|
-
const { type, format, name, isEnum, isArray, size = "sm" } = params;
|
|
1077
|
-
const iconSize = ui.sizes.icon[size];
|
|
1078
|
-
if (format) switch (format) {
|
|
1079
|
-
case "email": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconMail, { size: iconSize });
|
|
1080
|
-
case "url":
|
|
1081
|
-
case "uri": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconLink, { size: iconSize });
|
|
1082
|
-
case "tel":
|
|
1083
|
-
case "phone": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconPhone, { size: iconSize });
|
|
1084
|
-
case "date": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCalendar, { size: iconSize });
|
|
1085
|
-
case "date-time": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCalendar, { size: iconSize });
|
|
1086
|
-
case "time": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconClock, { size: iconSize });
|
|
1087
|
-
case "color": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconColorPicker, { size: iconSize });
|
|
1088
|
-
case "uuid": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconKey, { size: iconSize });
|
|
1089
|
-
}
|
|
1090
|
-
if (name) {
|
|
1091
|
-
const nameLower = name.toLowerCase();
|
|
1092
|
-
if (nameLower.includes("password") || nameLower.includes("secret")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconKey, { size: iconSize });
|
|
1093
|
-
if (nameLower.includes("email") || nameLower.includes("mail")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconMail, { size: iconSize });
|
|
1094
|
-
if (nameLower.includes("url") || nameLower.includes("link")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconLink, { size: iconSize });
|
|
1095
|
-
if (nameLower.includes("phone") || nameLower.includes("tel")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconPhone, { size: iconSize });
|
|
1096
|
-
if (nameLower.includes("color")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconPalette, { size: iconSize });
|
|
1097
|
-
if (nameLower.includes("file") || nameLower.includes("upload")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconFile, { size: iconSize });
|
|
1098
|
-
if (nameLower.includes("date")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconCalendar, { size: iconSize });
|
|
1099
|
-
if (nameLower.includes("time")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconClock, { size: iconSize });
|
|
1100
|
-
}
|
|
1101
|
-
if (isEnum || isArray) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSelector, { size: iconSize });
|
|
1102
|
-
if (type) switch (type) {
|
|
1103
|
-
case "boolean": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconToggleLeft, { size: iconSize });
|
|
1104
|
-
case "number":
|
|
1105
|
-
case "integer": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconHash, { size: iconSize });
|
|
1106
|
-
case "array": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconList, { size: iconSize });
|
|
1107
|
-
case "string": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconLetterCase, { size: iconSize });
|
|
1108
|
-
}
|
|
1109
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconAt, { size: iconSize });
|
|
1110
|
-
};
|
|
1111
|
-
|
|
1112
|
-
//#endregion
|
|
1113
|
-
//#region src/core/utils/string.ts
|
|
1114
|
-
/**
|
|
1115
|
-
* Capitalizes the first letter of a string.
|
|
1116
|
-
*
|
|
1117
|
-
* @example
|
|
1118
|
-
* capitalize("hello") // "Hello"
|
|
1119
|
-
*/
|
|
1120
|
-
const capitalize = (str) => {
|
|
1121
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1122
|
-
};
|
|
1123
|
-
/**
|
|
1124
|
-
* Converts a path or identifier string into a pretty display name.
|
|
1125
|
-
* Removes slashes and capitalizes the first letter.
|
|
1126
|
-
*
|
|
1127
|
-
* @example
|
|
1128
|
-
* prettyName("/userName") // "UserName"
|
|
1129
|
-
* prettyName("email") // "Email"
|
|
1130
|
-
*/
|
|
1131
|
-
const prettyName = (name) => {
|
|
1132
|
-
return capitalize(name.replaceAll("/", ""));
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
//#endregion
|
|
1136
|
-
//#region src/core/utils/parseInput.ts
|
|
1137
|
-
const parseInput = (props, form) => {
|
|
1138
|
-
const disabled = false;
|
|
1139
|
-
const id = props.input.props.id;
|
|
1140
|
-
const label = props.title ?? ("title" in props.input.schema && typeof props.input.schema.title === "string" ? props.input.schema.title : void 0) ?? prettyName(props.input.path);
|
|
1141
|
-
const description = props.description ?? ("description" in props.input.schema && typeof props.input.schema.description === "string" ? props.input.schema.description : void 0);
|
|
1142
|
-
const error = form.error && form.error instanceof alepha.TypeBoxError ? form.error.value.message : void 0;
|
|
1143
|
-
const icon = !props.icon ? getDefaultIcon({
|
|
1144
|
-
type: props.input.schema && "type" in props.input.schema ? String(props.input.schema.type) : void 0,
|
|
1145
|
-
format: props.input.schema && "format" in props.input.schema && typeof props.input.schema.format === "string" ? props.input.schema.format : void 0,
|
|
1146
|
-
name: props.input.props.name,
|
|
1147
|
-
isEnum: props.input.schema && "enum" in props.input.schema && Boolean(props.input.schema.enum),
|
|
1148
|
-
isArray: props.input.schema && "type" in props.input.schema && props.input.schema.type === "array"
|
|
1149
|
-
}) : (0, react.isValidElement)(props.icon) ? props.icon : (0, react.createElement)(props.icon, { size: ui.sizes.icon.md });
|
|
1150
|
-
const format = props.input.schema && "format" in props.input.schema && typeof props.input.schema.format === "string" ? props.input.schema.format : void 0;
|
|
1151
|
-
const required = props.input.required;
|
|
1152
|
-
const schema = props.input.schema;
|
|
1153
|
-
const inputProps = {
|
|
1154
|
-
label,
|
|
1155
|
-
description,
|
|
1156
|
-
error,
|
|
1157
|
-
required,
|
|
1158
|
-
disabled
|
|
1159
|
-
};
|
|
1160
|
-
if ("minLength" in schema && typeof schema.minLength === "number") inputProps.minLength = schema.minLength;
|
|
1161
|
-
if ("maxLength" in schema && typeof schema.maxLength === "number") inputProps.maxLength = schema.maxLength;
|
|
1162
|
-
if ("minimum" in schema && typeof schema.minimum === "number") inputProps.minimum = schema.minimum;
|
|
1163
|
-
if ("maximum" in schema && typeof schema.maximum === "number") inputProps.maximum = schema.maximum;
|
|
1164
|
-
return {
|
|
1165
|
-
id,
|
|
1166
|
-
icon,
|
|
1167
|
-
format,
|
|
1168
|
-
schema: props.input.schema,
|
|
1169
|
-
inputProps
|
|
1170
|
-
};
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
//#endregion
|
|
1174
|
-
//#region src/core/components/form/ControlDate.tsx
|
|
1175
|
-
/**
|
|
1176
|
-
* ControlDate component for handling date, datetime, and time inputs.
|
|
1177
|
-
*
|
|
1178
|
-
* Features:
|
|
1179
|
-
* - DateInput for date format
|
|
1180
|
-
* - DateTimePicker for date-time format
|
|
1181
|
-
* - TimeInput for time format
|
|
1182
|
-
*
|
|
1183
|
-
* Automatically detects date formats from schema and renders appropriate picker.
|
|
1184
|
-
*/
|
|
1185
|
-
const ControlDate = (props) => {
|
|
1186
|
-
const { inputProps, id, icon, format } = parseInput(props, (0, __alepha_react_form.useFormState)(props.input));
|
|
1187
|
-
if (!props.input?.props) return null;
|
|
1188
|
-
if (props.datetime || format === "date-time") {
|
|
1189
|
-
const dateTimePickerProps = typeof props.datetime === "object" ? props.datetime : {};
|
|
1190
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_dates.DateTimePicker, {
|
|
1191
|
-
...inputProps,
|
|
1192
|
-
id,
|
|
1193
|
-
leftSection: icon,
|
|
1194
|
-
defaultValue: props.input.props.defaultValue ? new Date(props.input.props.defaultValue) : void 0,
|
|
1195
|
-
onChange: (value) => {
|
|
1196
|
-
props.input.set(value ? new Date(value).toISOString() : void 0);
|
|
1197
|
-
},
|
|
1198
|
-
...dateTimePickerProps
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
if (props.date || format === "date") {
|
|
1202
|
-
const dateInputProps = typeof props.date === "object" ? props.date : {};
|
|
1203
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_dates.DateInput, {
|
|
1204
|
-
...inputProps,
|
|
1205
|
-
id,
|
|
1206
|
-
leftSection: icon,
|
|
1207
|
-
defaultValue: props.input.props.defaultValue ? new Date(props.input.props.defaultValue) : void 0,
|
|
1208
|
-
onChange: (value) => {
|
|
1209
|
-
props.input.set(value ? new Date(value).toISOString().slice(0, 10) : void 0);
|
|
1210
|
-
},
|
|
1211
|
-
...dateInputProps
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
if (props.time || format === "time") {
|
|
1215
|
-
const timeInputProps = typeof props.time === "object" ? props.time : {};
|
|
1216
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_dates.TimeInput, {
|
|
1217
|
-
...inputProps,
|
|
1218
|
-
id,
|
|
1219
|
-
leftSection: icon,
|
|
1220
|
-
defaultValue: props.input.props.defaultValue,
|
|
1221
|
-
onChange: (event) => {
|
|
1222
|
-
props.input.set(event.currentTarget.value);
|
|
1223
|
-
},
|
|
1224
|
-
...timeInputProps
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
return null;
|
|
1228
|
-
};
|
|
1229
|
-
var ControlDate_default = ControlDate;
|
|
1230
|
-
|
|
1231
|
-
//#endregion
|
|
1232
|
-
//#region src/core/components/form/ControlNumber.tsx
|
|
1233
|
-
/**
|
|
1234
|
-
*
|
|
1235
|
-
*/
|
|
1236
|
-
const ControlNumber = (props) => {
|
|
1237
|
-
const { inputProps, id, icon } = parseInput(props, (0, __alepha_react_form.useFormState)(props.input));
|
|
1238
|
-
const ref = (0, react.useRef)(null);
|
|
1239
|
-
const [value, setValue] = (0, react.useState)(props.input.props.defaultValue);
|
|
1240
|
-
(0, __alepha_react.useEvents)({ "form:reset": (event) => {
|
|
1241
|
-
if (event.id === props.input?.form.id && ref.current) setValue(props.input.props.defaultValue);
|
|
1242
|
-
} }, [props.input]);
|
|
1243
|
-
if (!props.input?.props) return null;
|
|
1244
|
-
const { type, ...inputPropsWithoutType } = props.input.props;
|
|
1245
|
-
if (props.sliderProps) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Input.Wrapper, {
|
|
1246
|
-
...inputProps,
|
|
1247
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1248
|
-
style: {
|
|
1249
|
-
height: 32,
|
|
1250
|
-
padding: 8
|
|
1251
|
-
},
|
|
1252
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Slider, {
|
|
1253
|
-
...inputProps,
|
|
1254
|
-
ref,
|
|
1255
|
-
id,
|
|
1256
|
-
...inputPropsWithoutType,
|
|
1257
|
-
...props.sliderProps,
|
|
1258
|
-
value,
|
|
1259
|
-
onChange: (val) => {
|
|
1260
|
-
setValue(val);
|
|
1261
|
-
props.input.set(val);
|
|
1262
|
-
}
|
|
1263
|
-
})
|
|
1264
|
-
})
|
|
1265
|
-
});
|
|
1266
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.NumberInput, {
|
|
1267
|
-
...inputProps,
|
|
1268
|
-
ref,
|
|
1269
|
-
id,
|
|
1270
|
-
leftSection: icon,
|
|
1271
|
-
...inputPropsWithoutType,
|
|
1272
|
-
...props.numberInputProps,
|
|
1273
|
-
value: value ?? "",
|
|
1274
|
-
onChange: (val) => {
|
|
1275
|
-
const newValue = val !== null ? Number(val) : void 0;
|
|
1276
|
-
setValue(newValue);
|
|
1277
|
-
props.input.set(newValue);
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
};
|
|
1281
|
-
var ControlNumber_default = ControlNumber;
|
|
1282
|
-
|
|
1283
|
-
//#endregion
|
|
1284
|
-
//#region src/core/utils/extractSchemaFields.ts
|
|
1285
|
-
/**
|
|
1286
|
-
* Extract field information from a TypeBox schema for query building.
|
|
1287
|
-
* Supports nested objects and provides field metadata for autocomplete.
|
|
1288
|
-
*/
|
|
1289
|
-
function extractSchemaFields(schema, prefix = "") {
|
|
1290
|
-
const fields = [];
|
|
1291
|
-
if (!schema || typeof schema !== "object") return fields;
|
|
1292
|
-
const properties = "properties" in schema ? schema.properties : schema;
|
|
1293
|
-
if (!properties || typeof properties !== "object") return fields;
|
|
1294
|
-
for (const [key, value] of Object.entries(properties)) {
|
|
1295
|
-
if (typeof value !== "object" || value === null) continue;
|
|
1296
|
-
const fieldSchema = value;
|
|
1297
|
-
const path = prefix ? `${prefix}.${key}` : key;
|
|
1298
|
-
const format = "format" in fieldSchema ? fieldSchema.format : void 0;
|
|
1299
|
-
let displayType = "type" in fieldSchema ? fieldSchema.type : "object";
|
|
1300
|
-
if (format === "date-time") displayType = "datetime";
|
|
1301
|
-
else if (format === "date") displayType = "date";
|
|
1302
|
-
else if (format === "time") displayType = "time";
|
|
1303
|
-
else if (format === "duration") displayType = "duration";
|
|
1304
|
-
const field = {
|
|
1305
|
-
name: key,
|
|
1306
|
-
path,
|
|
1307
|
-
type: displayType,
|
|
1308
|
-
format,
|
|
1309
|
-
description: "description" in fieldSchema ? fieldSchema.description : void 0
|
|
1310
|
-
};
|
|
1311
|
-
if ("enum" in fieldSchema && fieldSchema.enum) {
|
|
1312
|
-
field.enum = fieldSchema.enum;
|
|
1313
|
-
field.type = "enum";
|
|
1314
|
-
}
|
|
1315
|
-
if ("type" in fieldSchema && fieldSchema.type === "object" && "properties" in fieldSchema && typeof fieldSchema.properties === "object") field.nested = extractSchemaFields(fieldSchema.properties, path);
|
|
1316
|
-
fields.push(field);
|
|
1317
|
-
if (field.nested) fields.push(...field.nested);
|
|
1318
|
-
}
|
|
1319
|
-
return fields;
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Get operator symbol and description
|
|
1323
|
-
*/
|
|
1324
|
-
const OPERATOR_INFO = {
|
|
1325
|
-
eq: {
|
|
1326
|
-
symbol: "=",
|
|
1327
|
-
label: "equals",
|
|
1328
|
-
example: "name=John"
|
|
1329
|
-
},
|
|
1330
|
-
ne: {
|
|
1331
|
-
symbol: "!=",
|
|
1332
|
-
label: "not equals",
|
|
1333
|
-
example: "status!=archived"
|
|
1334
|
-
},
|
|
1335
|
-
gt: {
|
|
1336
|
-
symbol: ">",
|
|
1337
|
-
label: "greater than",
|
|
1338
|
-
example: "age>18"
|
|
1339
|
-
},
|
|
1340
|
-
gte: {
|
|
1341
|
-
symbol: ">=",
|
|
1342
|
-
label: "greater or equal",
|
|
1343
|
-
example: "age>=18"
|
|
1344
|
-
},
|
|
1345
|
-
lt: {
|
|
1346
|
-
symbol: "<",
|
|
1347
|
-
label: "less than",
|
|
1348
|
-
example: "age<65"
|
|
1349
|
-
},
|
|
1350
|
-
lte: {
|
|
1351
|
-
symbol: "<=",
|
|
1352
|
-
label: "less or equal",
|
|
1353
|
-
example: "age<=65"
|
|
1354
|
-
},
|
|
1355
|
-
null: {
|
|
1356
|
-
symbol: "=null",
|
|
1357
|
-
label: "is null",
|
|
1358
|
-
example: "deletedAt=null"
|
|
1359
|
-
},
|
|
1360
|
-
notNull: {
|
|
1361
|
-
symbol: "!=null",
|
|
1362
|
-
label: "is not null",
|
|
1363
|
-
example: "email!=null"
|
|
1364
|
-
},
|
|
1365
|
-
in: {
|
|
1366
|
-
symbol: "[...]",
|
|
1367
|
-
label: "in array",
|
|
1368
|
-
example: "status=[active,pending]"
|
|
1369
|
-
}
|
|
1370
|
-
};
|
|
1371
|
-
|
|
1372
|
-
//#endregion
|
|
1373
|
-
//#region src/core/components/form/ControlQueryBuilder.tsx
|
|
1374
|
-
/**
|
|
1375
|
-
* Query builder with text input and help popover.
|
|
1376
|
-
* Generates query strings for parseQueryString syntax.
|
|
1377
|
-
*/
|
|
1378
|
-
const ControlQueryBuilder = ({ schema, value = "", onChange, placeholder = "Enter query or click for assistance...", ...textInputProps }) => {
|
|
1379
|
-
const [helpOpened, setHelpOpened] = (0, react.useState)(false);
|
|
1380
|
-
const [textValue, setTextValue] = (0, react.useState)(value);
|
|
1381
|
-
const inputRef = (0, react.useRef)(null);
|
|
1382
|
-
const fields = schema ? extractSchemaFields(schema) : [];
|
|
1383
|
-
const [error, setError] = (0, react.useState)(null);
|
|
1384
|
-
const isValid = (value$1) => {
|
|
1385
|
-
try {
|
|
1386
|
-
(0, alepha_orm.parseQueryString)(value$1.trim());
|
|
1387
|
-
} catch (e) {
|
|
1388
|
-
setError(e.message);
|
|
1389
|
-
return false;
|
|
1390
|
-
}
|
|
1391
|
-
setError(null);
|
|
1392
|
-
return true;
|
|
1393
|
-
};
|
|
1394
|
-
const handleTextChange = (newValue) => {
|
|
1395
|
-
setTextValue(newValue);
|
|
1396
|
-
if (isValid(newValue)) onChange?.(newValue);
|
|
1397
|
-
};
|
|
1398
|
-
const handleClear = () => {
|
|
1399
|
-
setTextValue("");
|
|
1400
|
-
onChange?.("");
|
|
1401
|
-
isValid("");
|
|
1402
|
-
};
|
|
1403
|
-
const handleInsert = (text) => {
|
|
1404
|
-
const newValue = textValue ? `${textValue}${text} ` : `${text} `;
|
|
1405
|
-
setTextValue(newValue);
|
|
1406
|
-
if (isValid(newValue)) onChange?.(newValue);
|
|
1407
|
-
setTimeout(() => {
|
|
1408
|
-
inputRef.current?.focus();
|
|
1409
|
-
const length = inputRef.current?.value.length || 0;
|
|
1410
|
-
inputRef.current?.setSelectionRange(length, length);
|
|
1411
|
-
}, 0);
|
|
1412
|
-
};
|
|
1413
|
-
(0, __alepha_react.useEvents)({ "form:change": (event) => {
|
|
1414
|
-
if (event.id === inputRef.current?.form?.id) {
|
|
1415
|
-
if (event.path === textInputProps["data-path"]) setTextValue(event.value ?? "");
|
|
1416
|
-
}
|
|
1417
|
-
} }, []);
|
|
1418
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Popover, {
|
|
1419
|
-
width: 800,
|
|
1420
|
-
position: "bottom-start",
|
|
1421
|
-
shadow: "md",
|
|
1422
|
-
opened: helpOpened,
|
|
1423
|
-
onChange: setHelpOpened,
|
|
1424
|
-
closeOnClickOutside: true,
|
|
1425
|
-
closeOnEscape: true,
|
|
1426
|
-
transitionProps: {
|
|
1427
|
-
transition: "fade-up",
|
|
1428
|
-
duration: 200,
|
|
1429
|
-
timingFunction: "ease"
|
|
1430
|
-
},
|
|
1431
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Popover.Target, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.TextInput, {
|
|
1432
|
-
ref: inputRef,
|
|
1433
|
-
placeholder,
|
|
1434
|
-
value: textValue,
|
|
1435
|
-
onChange: (e) => handleTextChange(e.currentTarget.value),
|
|
1436
|
-
onFocus: () => setHelpOpened(true),
|
|
1437
|
-
leftSection: error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconInfoTriangle, { size: 16 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconFilter, { size: 16 }),
|
|
1438
|
-
rightSection: textValue && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ActionIcon, {
|
|
1439
|
-
size: "sm",
|
|
1440
|
-
variant: "subtle",
|
|
1441
|
-
color: "gray",
|
|
1442
|
-
onClick: handleClear,
|
|
1443
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconX, { size: 14 })
|
|
1444
|
-
}),
|
|
1445
|
-
...textInputProps
|
|
1446
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Popover.Dropdown, {
|
|
1447
|
-
bg: "transparent",
|
|
1448
|
-
p: "xs",
|
|
1449
|
-
bd: `1px solid ${ui.colors.border}`,
|
|
1450
|
-
style: { backdropFilter: "blur(20px)" },
|
|
1451
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QueryHelp, {
|
|
1452
|
-
fields,
|
|
1453
|
-
onInsert: handleInsert
|
|
1454
|
-
})
|
|
1455
|
-
})]
|
|
1456
|
-
});
|
|
1457
|
-
};
|
|
1458
|
-
function QueryHelp({ fields, onInsert }) {
|
|
1459
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
1460
|
-
gap: "md",
|
|
1461
|
-
align: "flex-start",
|
|
1462
|
-
wrap: "nowrap",
|
|
1463
|
-
bg: ui.colors.surface,
|
|
1464
|
-
p: "sm",
|
|
1465
|
-
bdrs: "sm",
|
|
1466
|
-
children: [
|
|
1467
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Stack, {
|
|
1468
|
-
gap: "md",
|
|
1469
|
-
style: { flex: 1 },
|
|
1470
|
-
children: [
|
|
1471
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Stack, {
|
|
1472
|
-
gap: "xs",
|
|
1473
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1474
|
-
size: "sm",
|
|
1475
|
-
fw: 600,
|
|
1476
|
-
children: "Operators"
|
|
1477
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Stack, {
|
|
1478
|
-
gap: 4,
|
|
1479
|
-
children: Object.entries(OPERATOR_INFO).map(([key, info]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
1480
|
-
gap: "xs",
|
|
1481
|
-
wrap: "nowrap",
|
|
1482
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1483
|
-
px: "xs",
|
|
1484
|
-
size: "xs",
|
|
1485
|
-
h: 24,
|
|
1486
|
-
variant: "default",
|
|
1487
|
-
justify: "center",
|
|
1488
|
-
miw: 48,
|
|
1489
|
-
onClick: () => onInsert(info.symbol),
|
|
1490
|
-
children: info.symbol
|
|
1491
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1492
|
-
size: "xs",
|
|
1493
|
-
c: "dimmed",
|
|
1494
|
-
style: { flex: 1 },
|
|
1495
|
-
children: info.label
|
|
1496
|
-
})]
|
|
1497
|
-
}, key))
|
|
1498
|
-
})]
|
|
1499
|
-
}),
|
|
1500
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Divider, {}),
|
|
1501
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Stack, {
|
|
1502
|
-
gap: "xs",
|
|
1503
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1504
|
-
size: "sm",
|
|
1505
|
-
fw: 600,
|
|
1506
|
-
children: "Logic"
|
|
1507
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Stack, {
|
|
1508
|
-
gap: 4,
|
|
1509
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
1510
|
-
gap: "xs",
|
|
1511
|
-
wrap: "nowrap",
|
|
1512
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1513
|
-
px: "xs",
|
|
1514
|
-
size: "xs",
|
|
1515
|
-
h: 24,
|
|
1516
|
-
variant: "default",
|
|
1517
|
-
justify: "center",
|
|
1518
|
-
miw: 48,
|
|
1519
|
-
onClick: () => onInsert("&"),
|
|
1520
|
-
children: "&"
|
|
1521
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1522
|
-
size: "xs",
|
|
1523
|
-
c: "dimmed",
|
|
1524
|
-
children: "AND"
|
|
1525
|
-
})]
|
|
1526
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Group, {
|
|
1527
|
-
gap: "xs",
|
|
1528
|
-
wrap: "nowrap",
|
|
1529
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1530
|
-
px: "xs",
|
|
1531
|
-
size: "xs",
|
|
1532
|
-
h: 24,
|
|
1533
|
-
variant: "default",
|
|
1534
|
-
justify: "center",
|
|
1535
|
-
miw: 48,
|
|
1536
|
-
onClick: () => onInsert("|"),
|
|
1537
|
-
children: "|"
|
|
1538
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1539
|
-
size: "xs",
|
|
1540
|
-
c: "dimmed",
|
|
1541
|
-
children: "OR"
|
|
1542
|
-
})]
|
|
1543
|
-
})]
|
|
1544
|
-
})]
|
|
1545
|
-
})
|
|
1546
|
-
]
|
|
1547
|
-
}),
|
|
1548
|
-
fields.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Divider, { orientation: "vertical" }),
|
|
1549
|
-
fields.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1550
|
-
direction: "column",
|
|
1551
|
-
gap: "xs",
|
|
1552
|
-
style: { flex: 2 },
|
|
1553
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1554
|
-
size: "sm",
|
|
1555
|
-
fw: 600,
|
|
1556
|
-
children: "Fields"
|
|
1557
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
1558
|
-
direction: "column",
|
|
1559
|
-
gap: 4,
|
|
1560
|
-
style: {
|
|
1561
|
-
maxHeight: 300,
|
|
1562
|
-
overflowY: "auto"
|
|
1563
|
-
},
|
|
1564
|
-
children: fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1565
|
-
gap: "xs",
|
|
1566
|
-
wrap: "nowrap",
|
|
1567
|
-
align: "flex-start",
|
|
1568
|
-
children: [
|
|
1569
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1570
|
-
px: "xs",
|
|
1571
|
-
size: "xs",
|
|
1572
|
-
h: 24,
|
|
1573
|
-
variant: "default",
|
|
1574
|
-
justify: "end",
|
|
1575
|
-
miw: 120,
|
|
1576
|
-
onClick: () => onInsert(field.path),
|
|
1577
|
-
children: field.path
|
|
1578
|
-
}),
|
|
1579
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1580
|
-
mt: 3,
|
|
1581
|
-
direction: "column",
|
|
1582
|
-
gap: 2,
|
|
1583
|
-
style: {
|
|
1584
|
-
flex: 1,
|
|
1585
|
-
minWidth: 0
|
|
1586
|
-
},
|
|
1587
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
1588
|
-
size: "xs",
|
|
1589
|
-
c: "dimmed",
|
|
1590
|
-
lineClamp: 1,
|
|
1591
|
-
children: field.description || field.type
|
|
1592
|
-
}), field.enum && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Group, {
|
|
1593
|
-
gap: 0,
|
|
1594
|
-
wrap: "wrap",
|
|
1595
|
-
children: field.enum.map((enumValue) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1596
|
-
px: "xs",
|
|
1597
|
-
size: "xs",
|
|
1598
|
-
h: 24,
|
|
1599
|
-
onClick: () => onInsert(enumValue),
|
|
1600
|
-
children: enumValue
|
|
1601
|
-
}, enumValue))
|
|
1602
|
-
})]
|
|
1603
|
-
}),
|
|
1604
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Badge, {
|
|
1605
|
-
size: "xs",
|
|
1606
|
-
variant: "light",
|
|
1607
|
-
style: { flexShrink: 0 },
|
|
1608
|
-
children: field.type
|
|
1609
|
-
})
|
|
1610
|
-
]
|
|
1611
|
-
}, field.path))
|
|
1612
|
-
})]
|
|
1613
|
-
})
|
|
1614
|
-
]
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
var ControlQueryBuilder_default = ControlQueryBuilder;
|
|
1618
|
-
|
|
1619
|
-
//#endregion
|
|
1620
|
-
//#region src/core/components/form/ControlSelect.tsx
|
|
1621
|
-
/**
|
|
1622
|
-
* ControlSelect component for handling Select, MultiSelect, and TagsInput.
|
|
1623
|
-
*
|
|
1624
|
-
* Features:
|
|
1625
|
-
* - Basic Select with enum support
|
|
1626
|
-
* - MultiSelect for array of enums
|
|
1627
|
-
* - TagsInput for array of strings (no enum)
|
|
1628
|
-
* - Future: Lazy loading
|
|
1629
|
-
* - Future: Searchable/filterable options
|
|
1630
|
-
* - Future: Custom option rendering
|
|
1631
|
-
*
|
|
1632
|
-
* Automatically detects enum values and array types from schema.
|
|
1633
|
-
*/
|
|
1634
|
-
const ControlSelect = (props) => {
|
|
1635
|
-
const { inputProps, id, icon } = parseInput(props, (0, __alepha_react_form.useFormState)(props.input));
|
|
1636
|
-
const isArray = props.input.schema && "type" in props.input.schema && props.input.schema.type === "array";
|
|
1637
|
-
let itemsEnum;
|
|
1638
|
-
if (isArray && "items" in props.input.schema && props.input.schema.items) {
|
|
1639
|
-
const items = props.input.schema.items;
|
|
1640
|
-
if ("enum" in items && Array.isArray(items.enum)) itemsEnum = items.enum;
|
|
1641
|
-
}
|
|
1642
|
-
const enumValues = props.input.schema && "enum" in props.input.schema && Array.isArray(props.input.schema.enum) ? props.input.schema.enum : [];
|
|
1643
|
-
const [data, setData] = (0, react.useState)([]);
|
|
1644
|
-
(0, react.useEffect)(() => {
|
|
1645
|
-
if (!props.input?.props) return;
|
|
1646
|
-
if (props.loader) props.loader().then(setData);
|
|
1647
|
-
else setData(enumValues);
|
|
1648
|
-
}, [props.input, props.loader]);
|
|
1649
|
-
if (!props.input?.props) return null;
|
|
1650
|
-
if (props.segmented) {
|
|
1651
|
-
const segmentedControlProps = typeof props.segmented === "object" ? props.segmented : {};
|
|
1652
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Input.Wrapper, {
|
|
1653
|
-
...inputProps,
|
|
1654
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.SegmentedControl, {
|
|
1655
|
-
disabled: inputProps.disabled,
|
|
1656
|
-
defaultValue: String(props.input.props.defaultValue),
|
|
1657
|
-
...segmentedControlProps,
|
|
1658
|
-
onChange: (value) => {
|
|
1659
|
-
props.input.set(value);
|
|
1660
|
-
},
|
|
1661
|
-
data: data.slice(0, 10)
|
|
1662
|
-
}) })
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
if (props.autocomplete) {
|
|
1666
|
-
const autocompleteProps = typeof props.autocomplete === "object" ? props.autocomplete : {};
|
|
1667
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Autocomplete, {
|
|
1668
|
-
...inputProps,
|
|
1669
|
-
id,
|
|
1670
|
-
leftSection: icon,
|
|
1671
|
-
data,
|
|
1672
|
-
...props.input.props,
|
|
1673
|
-
...autocompleteProps
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
if (isArray && !itemsEnum || props.tags) {
|
|
1677
|
-
const tagsInputProps = typeof props.tags === "object" ? props.tags : {};
|
|
1678
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.TagsInput, {
|
|
1679
|
-
...inputProps,
|
|
1680
|
-
id,
|
|
1681
|
-
leftSection: icon,
|
|
1682
|
-
defaultValue: Array.isArray(props.input.props.defaultValue) ? props.input.props.defaultValue : [],
|
|
1683
|
-
onChange: (value) => {
|
|
1684
|
-
props.input.set(value);
|
|
1685
|
-
},
|
|
1686
|
-
...tagsInputProps
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1689
|
-
if (isArray && itemsEnum || props.multi) {
|
|
1690
|
-
const data$1 = itemsEnum?.map((value) => ({
|
|
1691
|
-
value,
|
|
1692
|
-
label: value
|
|
1693
|
-
})) || [];
|
|
1694
|
-
const multiSelectProps = typeof props.multi === "object" ? props.multi : {};
|
|
1695
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.MultiSelect, {
|
|
1696
|
-
...inputProps,
|
|
1697
|
-
id,
|
|
1698
|
-
leftSection: icon,
|
|
1699
|
-
data: data$1,
|
|
1700
|
-
defaultValue: Array.isArray(props.input.props.defaultValue) ? props.input.props.defaultValue : [],
|
|
1701
|
-
onChange: (value) => {
|
|
1702
|
-
props.input.set(value);
|
|
1703
|
-
},
|
|
1704
|
-
...multiSelectProps
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
const selectProps = typeof props.select === "object" ? props.select : {};
|
|
1708
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Select, {
|
|
1709
|
-
...inputProps,
|
|
1710
|
-
id,
|
|
1711
|
-
leftSection: icon,
|
|
1712
|
-
data,
|
|
1713
|
-
...props.input.props,
|
|
1714
|
-
...selectProps
|
|
1715
|
-
});
|
|
1716
|
-
};
|
|
1717
|
-
var ControlSelect_default = ControlSelect;
|
|
1718
|
-
|
|
1719
|
-
//#endregion
|
|
1720
|
-
//#region src/core/components/form/Control.tsx
|
|
1721
|
-
/**
|
|
1722
|
-
* Generic form control that renders the appropriate input based on the schema and props.
|
|
1723
|
-
*
|
|
1724
|
-
* Supports:
|
|
1725
|
-
* - TextInput (with format detection: email, url, tel)
|
|
1726
|
-
* - Textarea
|
|
1727
|
-
* - NumberInput (for number/integer types)
|
|
1728
|
-
* - FileInput
|
|
1729
|
-
* - ColorInput (for color format)
|
|
1730
|
-
* - Select (for enum types)
|
|
1731
|
-
* - Autocomplete
|
|
1732
|
-
* - PasswordInput
|
|
1733
|
-
* - Switch (for boolean types)
|
|
1734
|
-
* - SegmentedControl (for enum types)
|
|
1735
|
-
* - DateInput (for date format)
|
|
1736
|
-
* - DateTimePicker (for date-time format)
|
|
1737
|
-
* - TimeInput (for time format)
|
|
1738
|
-
* - QueryBuilder (for building type-safe queries with autocomplete)
|
|
1739
|
-
* - Custom component
|
|
1740
|
-
*
|
|
1741
|
-
* Automatically handles labels, descriptions, error messages, required state, and default icons.
|
|
1742
|
-
*/
|
|
1743
|
-
const Control = (_props) => {
|
|
1744
|
-
const { inputProps, id, icon, format, schema } = parseInput(_props, (0, __alepha_react_form.useFormState)(_props.input, ["error"]));
|
|
1745
|
-
if (!_props.input?.props) return null;
|
|
1746
|
-
const props = {
|
|
1747
|
-
..._props,
|
|
1748
|
-
...schema.$control
|
|
1749
|
-
};
|
|
1750
|
-
if (props.query) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ControlQueryBuilder_default, {
|
|
1751
|
-
...props.input.props,
|
|
1752
|
-
...inputProps,
|
|
1753
|
-
schema: props.query,
|
|
1754
|
-
value: props.input.props.value,
|
|
1755
|
-
onChange: (value) => {
|
|
1756
|
-
props.input.set(value);
|
|
1757
|
-
}
|
|
1758
|
-
});
|
|
1759
|
-
if (props.custom) {
|
|
1760
|
-
const Custom = props.custom;
|
|
1761
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Input.Wrapper, {
|
|
1762
|
-
...inputProps,
|
|
1763
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
1764
|
-
flex: 1,
|
|
1765
|
-
mt: "calc(var(--mantine-spacing-xs) / 2)",
|
|
1766
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Custom, {
|
|
1767
|
-
defaultValue: props.input.props.defaultValue,
|
|
1768
|
-
onChange: (value) => {
|
|
1769
|
-
props.input.set(value);
|
|
1770
|
-
}
|
|
1771
|
-
})
|
|
1772
|
-
})
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
if (props.number || props.input.schema && "type" in props.input.schema && (props.input.schema.type === "number" || props.input.schema.type === "integer")) {
|
|
1776
|
-
const controlNumberProps = typeof props.number === "object" ? props.number : {};
|
|
1777
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ControlNumber_default, {
|
|
1778
|
-
input: props.input,
|
|
1779
|
-
title: props.title,
|
|
1780
|
-
description: props.description,
|
|
1781
|
-
icon,
|
|
1782
|
-
...controlNumberProps
|
|
1783
|
-
});
|
|
1784
|
-
}
|
|
1785
|
-
if (props.file) {
|
|
1786
|
-
const fileInputProps = typeof props.file === "object" ? props.file : {};
|
|
1787
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.FileInput, {
|
|
1788
|
-
...inputProps,
|
|
1789
|
-
id,
|
|
1790
|
-
leftSection: icon,
|
|
1791
|
-
onChange: (file) => {
|
|
1792
|
-
props.input.set(file);
|
|
1793
|
-
},
|
|
1794
|
-
...fileInputProps
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
if (props.color || format === "color") {
|
|
1798
|
-
const colorInputProps = typeof props.color === "object" ? props.color : {};
|
|
1799
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ColorInput, {
|
|
1800
|
-
...inputProps,
|
|
1801
|
-
id,
|
|
1802
|
-
leftSection: icon,
|
|
1803
|
-
...props.input.props,
|
|
1804
|
-
...colorInputProps
|
|
1805
|
-
});
|
|
1806
|
-
}
|
|
1807
|
-
const isEnum = props.input.schema && "enum" in props.input.schema && props.input.schema.enum;
|
|
1808
|
-
const isArray = props.input.schema && "type" in props.input.schema && props.input.schema.type === "array";
|
|
1809
|
-
if (isEnum || isArray || props.select) {
|
|
1810
|
-
const opts = typeof props.select === "object" ? props.select : {};
|
|
1811
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ControlSelect_default, {
|
|
1812
|
-
input: props.input,
|
|
1813
|
-
title: props.title,
|
|
1814
|
-
description: props.description,
|
|
1815
|
-
icon,
|
|
1816
|
-
...opts
|
|
1817
|
-
});
|
|
1818
|
-
}
|
|
1819
|
-
if (props.input.schema && "type" in props.input.schema && props.input.schema.type === "boolean" || props.switch) {
|
|
1820
|
-
const switchProps = typeof props.switch === "object" ? props.switch : {};
|
|
1821
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Switch, {
|
|
1822
|
-
...inputProps,
|
|
1823
|
-
id,
|
|
1824
|
-
color: "blue",
|
|
1825
|
-
defaultChecked: props.input.props.defaultValue,
|
|
1826
|
-
...props.input.props,
|
|
1827
|
-
...switchProps
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
if (props.password || props.input.props.name?.includes("password")) {
|
|
1831
|
-
const passwordInputProps = typeof props.password === "object" ? props.password : {};
|
|
1832
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.PasswordInput, {
|
|
1833
|
-
...inputProps,
|
|
1834
|
-
id,
|
|
1835
|
-
leftSection: icon,
|
|
1836
|
-
...props.input.props,
|
|
1837
|
-
...passwordInputProps
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
if (props.area) {
|
|
1841
|
-
const textAreaProps = typeof props.area === "object" ? props.area : {};
|
|
1842
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Textarea, {
|
|
1843
|
-
...inputProps,
|
|
1844
|
-
id,
|
|
1845
|
-
leftSection: icon,
|
|
1846
|
-
...props.input.props,
|
|
1847
|
-
...textAreaProps
|
|
1848
|
-
});
|
|
1849
|
-
}
|
|
1850
|
-
if (props.date || props.datetime || props.time || format === "date" || format === "date-time" || format === "time") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ControlDate_default, {
|
|
1851
|
-
input: props.input,
|
|
1852
|
-
title: props.title,
|
|
1853
|
-
description: props.description,
|
|
1854
|
-
icon,
|
|
1855
|
-
date: props.date,
|
|
1856
|
-
datetime: props.datetime,
|
|
1857
|
-
time: props.time
|
|
1858
|
-
});
|
|
1859
|
-
const textInputProps = typeof props.text === "object" ? props.text : {};
|
|
1860
|
-
const getInputType = () => {
|
|
1861
|
-
switch (format) {
|
|
1862
|
-
case "email": return "email";
|
|
1863
|
-
case "url":
|
|
1864
|
-
case "uri": return "url";
|
|
1865
|
-
case "tel":
|
|
1866
|
-
case "phone": return "tel";
|
|
1867
|
-
default: return;
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.TextInput, {
|
|
1871
|
-
...inputProps,
|
|
1872
|
-
id,
|
|
1873
|
-
leftSection: icon,
|
|
1874
|
-
type: getInputType(),
|
|
1875
|
-
...props.input.props,
|
|
1876
|
-
...textInputProps,
|
|
1877
|
-
inputWrapperOrder: [
|
|
1878
|
-
"label",
|
|
1879
|
-
"input",
|
|
1880
|
-
"description",
|
|
1881
|
-
"error"
|
|
1882
|
-
]
|
|
1883
|
-
});
|
|
1884
|
-
};
|
|
1885
|
-
var Control_default = Control;
|
|
1886
|
-
|
|
1887
|
-
//#endregion
|
|
1888
|
-
//#region src/core/components/form/TypeForm.tsx
|
|
1889
|
-
/**
|
|
1890
|
-
* TypeForm component that automatically renders all form inputs based on schema.
|
|
1891
|
-
* Uses the Control component to render individual fields and Mantine Grid for responsive layout.
|
|
1892
|
-
*
|
|
1893
|
-
* @example
|
|
1894
|
-
* ```tsx
|
|
1895
|
-
* import { t } from "alepha";
|
|
1896
|
-
* import { useForm } from "@alepha/react/form";
|
|
1897
|
-
* import { TypeForm } from "@alepha/ui";
|
|
1898
|
-
*
|
|
1899
|
-
* const form = useForm({
|
|
1900
|
-
* schema: t.object({
|
|
1901
|
-
* username: t.text(),
|
|
1902
|
-
* email: t.text(),
|
|
1903
|
-
* age: t.integer(),
|
|
1904
|
-
* subscribe: t.boolean(),
|
|
1905
|
-
* }),
|
|
1906
|
-
* handler: (values) => {
|
|
1907
|
-
* console.log(values);
|
|
1908
|
-
* },
|
|
1909
|
-
* });
|
|
1910
|
-
*
|
|
1911
|
-
* return <TypeForm form={form} columns={2} />;
|
|
1912
|
-
* ```
|
|
1913
|
-
*/
|
|
1914
|
-
const TypeForm = (props) => {
|
|
1915
|
-
const { form, columns = 3, children, controlProps, skipFormElement = false, skipSubmitButton = false, submitButtonProps } = props;
|
|
1916
|
-
const schema = props.schema || form.options.schema;
|
|
1917
|
-
if (!schema?.properties) return null;
|
|
1918
|
-
const supportedFields = Object.keys(schema.properties).filter((fieldName) => {
|
|
1919
|
-
const field = form.input[fieldName];
|
|
1920
|
-
if (!field || typeof field !== "object" || !("schema" in field)) return false;
|
|
1921
|
-
const schema$1 = field.schema;
|
|
1922
|
-
if ("type" in schema$1) {
|
|
1923
|
-
if (schema$1.type === "object") return false;
|
|
1924
|
-
}
|
|
1925
|
-
if ("properties" in schema$1 && schema$1.properties) return false;
|
|
1926
|
-
return true;
|
|
1927
|
-
});
|
|
1928
|
-
const colSpan = typeof columns === "number" ? {
|
|
1929
|
-
xs: 12,
|
|
1930
|
-
sm: 6,
|
|
1931
|
-
lg: 12 / columns
|
|
1932
|
-
} : {
|
|
1933
|
-
base: columns.base ? 12 / columns.base : void 0,
|
|
1934
|
-
xs: columns.xs ? 12 / columns.xs : 12,
|
|
1935
|
-
sm: columns.sm ? 12 / columns.sm : 6,
|
|
1936
|
-
md: columns.md ? 12 / columns.md : void 0,
|
|
1937
|
-
lg: columns.lg ? 12 / columns.lg : 4,
|
|
1938
|
-
xl: columns.xl ? 12 / columns.xl : void 0
|
|
1939
|
-
};
|
|
1940
|
-
const renderFields = () => {
|
|
1941
|
-
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(form.input) });
|
|
1942
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Grid, { children: supportedFields.map((fieldName) => {
|
|
1943
|
-
const field = form.input[fieldName];
|
|
1944
|
-
if (!field || typeof field !== "object" || !("schema" in field)) return null;
|
|
1945
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Grid.Col, {
|
|
1946
|
-
span: colSpan,
|
|
1947
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Control_default, {
|
|
1948
|
-
input: field,
|
|
1949
|
-
...controlProps
|
|
1950
|
-
})
|
|
1951
|
-
}, fieldName);
|
|
1952
|
-
}) });
|
|
1953
|
-
};
|
|
1954
|
-
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1955
|
-
direction: "column",
|
|
1956
|
-
gap: "sm",
|
|
1957
|
-
children: [renderFields(), !skipSubmitButton && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1958
|
-
gap: "sm",
|
|
1959
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1960
|
-
form,
|
|
1961
|
-
...submitButtonProps,
|
|
1962
|
-
children: submitButtonProps?.children ?? "Submit"
|
|
1963
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
1964
|
-
type: "reset",
|
|
1965
|
-
children: "Reset"
|
|
1966
|
-
})]
|
|
1967
|
-
})]
|
|
1968
|
-
});
|
|
1969
|
-
if (skipFormElement) return content;
|
|
1970
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
|
|
1971
|
-
...form.props,
|
|
1972
|
-
children: content
|
|
1973
|
-
});
|
|
1974
|
-
};
|
|
1975
|
-
var TypeForm_default = TypeForm;
|
|
1976
|
-
|
|
1977
|
-
//#endregion
|
|
1978
|
-
//#region src/core/components/layout/AppBar.tsx
|
|
1979
|
-
const AppBar = (props) => {
|
|
1980
|
-
const { items = [] } = props;
|
|
1981
|
-
const renderItem = (item, index) => {
|
|
1982
|
-
if ("type" in item) {
|
|
1983
|
-
if (item.type === "burger") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BurgerButton_default, {}, index);
|
|
1984
|
-
if (item.type === "dark") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DarkModeButton_default, { ...item.props }, index);
|
|
1985
|
-
if (item.type === "search") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OmnibarButton_default, { ...item.props }, index);
|
|
1986
|
-
if (item.type === "lang") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LanguageButton_default, { ...item.props }, index);
|
|
1987
|
-
if (item.type === "spacer") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { w: 16 }, index);
|
|
1988
|
-
if (item.type === "divider") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Divider, { orientation: "vertical" }, index);
|
|
1989
|
-
}
|
|
1990
|
-
if ("element" in item) return item.element;
|
|
1991
|
-
return null;
|
|
1992
|
-
};
|
|
1993
|
-
const leftItems = items.filter((item) => item.position === "left");
|
|
1994
|
-
const centerItems = items.filter((item) => item.position === "center");
|
|
1995
|
-
const rightItems = items.filter((item) => item.position === "right");
|
|
1996
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
1997
|
-
h: "100%",
|
|
1998
|
-
align: "center",
|
|
1999
|
-
px: "md",
|
|
2000
|
-
justify: "space-between",
|
|
2001
|
-
...props.flexProps,
|
|
2002
|
-
children: [
|
|
2003
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2004
|
-
flex: 1,
|
|
2005
|
-
children: leftItems.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2006
|
-
ml: index === 0 ? 0 : "md",
|
|
2007
|
-
align: "center",
|
|
2008
|
-
children: renderItem(item, index)
|
|
2009
|
-
}, index))
|
|
2010
|
-
}),
|
|
2011
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: centerItems.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2012
|
-
mx: "md",
|
|
2013
|
-
align: "center",
|
|
2014
|
-
children: renderItem(item, index)
|
|
2015
|
-
}, index)) }),
|
|
2016
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2017
|
-
flex: 1,
|
|
2018
|
-
align: "center",
|
|
2019
|
-
justify: "end",
|
|
2020
|
-
children: rightItems.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2021
|
-
ml: index === 0 ? 0 : "md",
|
|
2022
|
-
align: "center",
|
|
2023
|
-
children: renderItem(item, index)
|
|
2024
|
-
}, index))
|
|
2025
|
-
})
|
|
2026
|
-
]
|
|
2027
|
-
});
|
|
2028
|
-
};
|
|
2029
|
-
var AppBar_default = AppBar;
|
|
2030
|
-
|
|
2031
|
-
//#endregion
|
|
2032
|
-
//#region src/core/components/layout/Sidebar.tsx
|
|
2033
|
-
const Sidebar = (props) => {
|
|
2034
|
-
const router = (0, __alepha_react.useRouter)();
|
|
2035
|
-
const { top = [], bottom = [], onItemClick } = props;
|
|
2036
|
-
const renderNode = (item, key) => {
|
|
2037
|
-
if ("type" in item) {
|
|
2038
|
-
if (item.type === "spacer") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { h: 16 }, key);
|
|
2039
|
-
if (item.type === "divider") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2040
|
-
h: 1,
|
|
2041
|
-
bg: "var(--alepha-border)",
|
|
2042
|
-
my: "md",
|
|
2043
|
-
mx: "sm"
|
|
2044
|
-
}, key);
|
|
2045
|
-
if (item.type === "search") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OmnibarButton_default, { collapsed: props.collapsed }, key);
|
|
2046
|
-
if (item.type === "section") {
|
|
2047
|
-
if (props.collapsed) return;
|
|
2048
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2049
|
-
mt: "md",
|
|
2050
|
-
mb: "xs",
|
|
2051
|
-
align: "center",
|
|
2052
|
-
gap: "xs",
|
|
2053
|
-
children: [renderIcon(item.icon), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
2054
|
-
size: "xs",
|
|
2055
|
-
c: "dimmed",
|
|
2056
|
-
tt: "uppercase",
|
|
2057
|
-
fw: "bold",
|
|
2058
|
-
children: item.label
|
|
2059
|
-
}, key)]
|
|
2060
|
-
}, key);
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
if ("element" in item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: item.element }, key);
|
|
2064
|
-
if (props.collapsed) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarCollapsedItem, {
|
|
2065
|
-
item,
|
|
2066
|
-
level: 0,
|
|
2067
|
-
onItemClick,
|
|
2068
|
-
theme: props.theme ?? {}
|
|
2069
|
-
}, key);
|
|
2070
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarItem, {
|
|
2071
|
-
item,
|
|
2072
|
-
level: 0,
|
|
2073
|
-
onItemClick,
|
|
2074
|
-
theme: props.theme ?? {}
|
|
2075
|
-
}, key);
|
|
2076
|
-
};
|
|
2077
|
-
const padding = "md";
|
|
2078
|
-
const gap = props.gap;
|
|
2079
|
-
const menu = props.menu ?? router.concretePages.map((page) => ({
|
|
2080
|
-
label: page.label ?? page.name,
|
|
2081
|
-
description: page.description,
|
|
2082
|
-
icon: renderIcon(page.icon),
|
|
2083
|
-
href: router.path(page.name)
|
|
2084
|
-
}));
|
|
2085
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2086
|
-
flex: 1,
|
|
2087
|
-
py: padding,
|
|
2088
|
-
direction: "column",
|
|
2089
|
-
className: "overflow-auto",
|
|
2090
|
-
...props.flexProps,
|
|
2091
|
-
children: [
|
|
2092
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2093
|
-
gap,
|
|
2094
|
-
px: padding,
|
|
2095
|
-
direction: "column",
|
|
2096
|
-
children: [top.map((item, index) => renderNode(item, index)), menu.filter((it) => it.position === "top").map((item, index) => renderNode(item, index + top.length))]
|
|
2097
|
-
}),
|
|
2098
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2099
|
-
gap,
|
|
2100
|
-
px: padding,
|
|
2101
|
-
direction: "column",
|
|
2102
|
-
flex: 1,
|
|
2103
|
-
className: "overflow-auto",
|
|
2104
|
-
children: menu.filter((it) => !it.position).map((item, index) => renderNode(item, index))
|
|
2105
|
-
}),
|
|
2106
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2107
|
-
gap,
|
|
2108
|
-
px: padding,
|
|
2109
|
-
direction: "column",
|
|
2110
|
-
children: [bottom.map((item, index) => renderNode(item, index)), menu.filter((it) => it.position === "bottom").map((item, index) => renderNode(item, index + bottom.length))]
|
|
2111
|
-
})
|
|
2112
|
-
]
|
|
2113
|
-
});
|
|
2114
|
-
};
|
|
2115
|
-
const SidebarItem = (props) => {
|
|
2116
|
-
const { item, level } = props;
|
|
2117
|
-
const maxLevel = 2;
|
|
2118
|
-
const router = (0, __alepha_react.useRouter)();
|
|
2119
|
-
const isActive = (0, react.useCallback)((item$1) => {
|
|
2120
|
-
if (!item$1.children) return false;
|
|
2121
|
-
for (const child of item$1.children) {
|
|
2122
|
-
if (child.href) {
|
|
2123
|
-
if (router.isActive(child.href)) return true;
|
|
2124
|
-
}
|
|
2125
|
-
if (isActive(child)) return true;
|
|
2126
|
-
}
|
|
2127
|
-
return false;
|
|
2128
|
-
}, []);
|
|
2129
|
-
const [isOpen, setIsOpen] = (0, react.useState)(isActive(item));
|
|
2130
|
-
(0, __alepha_react.useEvents)({ "react:transition:end": () => {
|
|
2131
|
-
if (isActive(item)) setIsOpen(true);
|
|
2132
|
-
} }, []);
|
|
2133
|
-
if (level > maxLevel) return null;
|
|
2134
|
-
const handleItemClick = (e) => {
|
|
2135
|
-
if (!props.item.target) e.preventDefault();
|
|
2136
|
-
if (item.children && item.children.length > 0) setIsOpen(!isOpen);
|
|
2137
|
-
else {
|
|
2138
|
-
props.onItemClick?.(item);
|
|
2139
|
-
item.onClick?.();
|
|
2140
|
-
}
|
|
2141
|
-
};
|
|
2142
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2143
|
-
direction: "column",
|
|
2144
|
-
ps: level === 0 ? 0 : 32,
|
|
2145
|
-
pos: "relative",
|
|
2146
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
2147
|
-
w: "100%",
|
|
2148
|
-
justify: "space-between",
|
|
2149
|
-
href: props.item.href,
|
|
2150
|
-
target: props.item.target,
|
|
2151
|
-
size: props.item.theme?.size ?? props.theme.button?.size ?? (level === 0 ? "sm" : "xs"),
|
|
2152
|
-
color: "var(--alepha-text)",
|
|
2153
|
-
variant: "subtle",
|
|
2154
|
-
variantActive: "default",
|
|
2155
|
-
radius: props.item.theme?.radius ?? props.theme.button?.radius ?? "md",
|
|
2156
|
-
onClick: handleItemClick,
|
|
2157
|
-
leftSection: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2158
|
-
w: "100%",
|
|
2159
|
-
align: "center",
|
|
2160
|
-
gap: "sm",
|
|
2161
|
-
children: [renderIcon(item.icon), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2162
|
-
direction: "column",
|
|
2163
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: item.label }), item.description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Text, {
|
|
2164
|
-
size: "xs",
|
|
2165
|
-
c: "dimmed",
|
|
2166
|
-
children: item.description
|
|
2167
|
-
})]
|
|
2168
|
-
})]
|
|
2169
|
-
}),
|
|
2170
|
-
rightSection: item.children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: isOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconChevronDown, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconChevronRight, { size: 14 }) }) : props.item.rightSection,
|
|
2171
|
-
...props.item.actionProps
|
|
2172
|
-
}), item.children && isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2173
|
-
direction: "column",
|
|
2174
|
-
"data-parent-level": level,
|
|
2175
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { style: {
|
|
2176
|
-
position: "absolute",
|
|
2177
|
-
width: 1,
|
|
2178
|
-
background: "linear-gradient(to bottom, transparent, var(--alepha-border), transparent)",
|
|
2179
|
-
top: 48,
|
|
2180
|
-
left: 20 + 32 * level,
|
|
2181
|
-
bottom: 16
|
|
2182
|
-
} }), item.children.map((child, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarItem, {
|
|
2183
|
-
item: child,
|
|
2184
|
-
level: level + 1,
|
|
2185
|
-
onItemClick: props.onItemClick,
|
|
2186
|
-
theme: props.theme
|
|
2187
|
-
}, index))]
|
|
2188
|
-
})]
|
|
2189
|
-
});
|
|
2190
|
-
};
|
|
2191
|
-
const SidebarCollapsedItem = (props) => {
|
|
2192
|
-
const { item, level } = props;
|
|
2193
|
-
const router = (0, __alepha_react.useRouter)();
|
|
2194
|
-
const isActive = (0, react.useCallback)((item$1) => {
|
|
2195
|
-
if (!item$1.children) return false;
|
|
2196
|
-
for (const child of item$1.children) {
|
|
2197
|
-
if (child.href) {
|
|
2198
|
-
if (router.isActive(child.href)) return true;
|
|
2199
|
-
}
|
|
2200
|
-
if (isActive(child)) return true;
|
|
2201
|
-
}
|
|
2202
|
-
return false;
|
|
2203
|
-
}, []);
|
|
2204
|
-
const [isOpen, setIsOpen] = (0, react.useState)(isActive(item));
|
|
2205
|
-
const handleItemClick = (e) => {
|
|
2206
|
-
if (!props.item.target) e.preventDefault();
|
|
2207
|
-
if (item.children && item.children.length > 0) setIsOpen(!isOpen);
|
|
2208
|
-
else {
|
|
2209
|
-
props.onItemClick?.(item);
|
|
2210
|
-
item.onClick?.();
|
|
2211
|
-
}
|
|
2212
|
-
};
|
|
2213
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
2214
|
-
size: props.item.theme?.size ?? props.theme.button?.size ?? (level === 0 ? "sm" : "xs"),
|
|
2215
|
-
color: "var(--alepha-text)",
|
|
2216
|
-
variant: "subtle",
|
|
2217
|
-
variantActive: "default",
|
|
2218
|
-
radius: props.item.theme?.radius ?? props.theme.button?.radius ?? "md",
|
|
2219
|
-
onClick: handleItemClick,
|
|
2220
|
-
icon: renderIcon(item.icon) ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSquareRounded, {}),
|
|
2221
|
-
href: props.item.href,
|
|
2222
|
-
target: props.item.target,
|
|
2223
|
-
menu: item.children ? {
|
|
2224
|
-
position: "right",
|
|
2225
|
-
on: "hover",
|
|
2226
|
-
items: item.children.map((child) => ({
|
|
2227
|
-
label: child.label,
|
|
2228
|
-
href: child.href,
|
|
2229
|
-
icon: renderIcon(child.icon),
|
|
2230
|
-
children: child.children
|
|
2231
|
-
}))
|
|
2232
|
-
} : void 0,
|
|
2233
|
-
...props.item.actionProps
|
|
2234
|
-
});
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
|
-
//#endregion
|
|
2238
|
-
//#region src/core/components/layout/AdminShell.tsx
|
|
2239
|
-
const AdminShell = (props) => {
|
|
2240
|
-
const router = (0, __alepha_react.useRouter)();
|
|
2241
|
-
const [opened, setOpened] = (0, __alepha_react.useStore)("alepha.ui.sidebar.opened");
|
|
2242
|
-
const [collapsed] = (0, __alepha_react.useStore)("alepha.ui.sidebar.collapsed", props.sidebarProps?.collapsed);
|
|
2243
|
-
const shouldShowSidebar = () => {
|
|
2244
|
-
if (props.noSidebarWhen?.paths) {
|
|
2245
|
-
for (const path of props.noSidebarWhen.paths) if (router.isActive(path, { startWith: true })) return false;
|
|
2246
|
-
}
|
|
2247
|
-
return true;
|
|
2248
|
-
};
|
|
2249
|
-
const [showSidebar, setShowSidebar] = (0, react.useState)(shouldShowSidebar());
|
|
2250
|
-
(0, __alepha_react.useEvents)({
|
|
2251
|
-
"react:transition:end": () => {
|
|
2252
|
-
setShowSidebar(shouldShowSidebar());
|
|
2253
|
-
},
|
|
2254
|
-
"react:transition:begin": () => {
|
|
2255
|
-
setOpened(false);
|
|
2256
|
-
}
|
|
2257
|
-
}, []);
|
|
2258
|
-
const defaultAppBarItems = [{
|
|
2259
|
-
position: "left",
|
|
2260
|
-
type: "burger"
|
|
2261
|
-
}];
|
|
2262
|
-
const hasSidebar = showSidebar && props.sidebarProps !== void 0;
|
|
2263
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.AppShell, {
|
|
2264
|
-
padding: "md",
|
|
2265
|
-
header: hasSidebar || props.appBarProps || props.header ? { height: 60 } : void 0,
|
|
2266
|
-
navbar: hasSidebar ? {
|
|
2267
|
-
width: collapsed ? { base: 72 } : { base: 300 },
|
|
2268
|
-
breakpoint: "sm",
|
|
2269
|
-
collapsed: { mobile: !opened }
|
|
2270
|
-
} : void 0,
|
|
2271
|
-
footer: props.footer ? { height: 60 } : void 0,
|
|
2272
|
-
...props.appShellProps,
|
|
2273
|
-
children: [
|
|
2274
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.AppShell.Header, {
|
|
2275
|
-
bg: ui.colors.surface,
|
|
2276
|
-
...props.appShellHeaderProps,
|
|
2277
|
-
children: props.header ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppBar_default, {
|
|
2278
|
-
items: defaultAppBarItems,
|
|
2279
|
-
...props.appBarProps
|
|
2280
|
-
})
|
|
2281
|
-
}),
|
|
2282
|
-
hasSidebar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.AppShell.Navbar, {
|
|
2283
|
-
bg: ui.colors.surface,
|
|
2284
|
-
...props.appShellNavbarProps,
|
|
2285
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {
|
|
2286
|
-
collapsed,
|
|
2287
|
-
...props.sidebarProps ?? {}
|
|
2288
|
-
})
|
|
2289
|
-
}),
|
|
2290
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.AppShell.Main, {
|
|
2291
|
-
display: "flex",
|
|
2292
|
-
flex: 1,
|
|
2293
|
-
...props.appShellMainProps,
|
|
2294
|
-
children: props.children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alepha_react.NestedView, {})
|
|
2295
|
-
}),
|
|
2296
|
-
props.footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.AppShell.Footer, {
|
|
2297
|
-
bg: ui.colors.surface,
|
|
2298
|
-
...props.appShellFooterProps,
|
|
2299
|
-
children: props.footer
|
|
2300
|
-
})
|
|
2301
|
-
]
|
|
2302
|
-
});
|
|
2303
|
-
};
|
|
2304
|
-
var AdminShell_default = AdminShell;
|
|
2305
|
-
|
|
2306
|
-
//#endregion
|
|
2307
|
-
//#region src/core/components/table/DataTable.tsx
|
|
2308
|
-
const DataTable = (props) => {
|
|
2309
|
-
const [items, setItems] = (0, react.useState)(typeof props.items === "function" ? { content: [] } : props.items);
|
|
2310
|
-
const defaultSize = props.infinityScroll ? 100 : props.defaultSize || 10;
|
|
2311
|
-
const [page, setPage] = (0, react.useState)(1);
|
|
2312
|
-
const [size, setSize] = (0, react.useState)(String(defaultSize));
|
|
2313
|
-
const [currentPage, setCurrentPage] = (0, react.useState)(0);
|
|
2314
|
-
const alepha$1 = (0, __alepha_react.useInject)(alepha.Alepha);
|
|
2315
|
-
const form = (0, __alepha_react_form.useForm)({
|
|
2316
|
-
schema: alepha.t.object({
|
|
2317
|
-
...props.filters ? props.filters.properties : {},
|
|
2318
|
-
page: alepha.t.number({ default: 0 }),
|
|
2319
|
-
size: alepha.t.number({ default: defaultSize }),
|
|
2320
|
-
sort: alepha.t.optional(alepha.t.string())
|
|
2321
|
-
}),
|
|
2322
|
-
handler: async (values, args) => {
|
|
2323
|
-
if (typeof props.items === "function") {
|
|
2324
|
-
const response = await props.items(values, { items: items.content });
|
|
2325
|
-
if (props.infinityScroll && values.page > 0) setItems((prev) => ({
|
|
2326
|
-
...response,
|
|
2327
|
-
content: [...prev.content, ...response.content]
|
|
2328
|
-
}));
|
|
2329
|
-
else setItems(response);
|
|
2330
|
-
setCurrentPage(values.page);
|
|
2331
|
-
}
|
|
2332
|
-
},
|
|
2333
|
-
onReset: async () => {
|
|
2334
|
-
setPage(1);
|
|
2335
|
-
setSize("10");
|
|
2336
|
-
await form.submit();
|
|
2337
|
-
},
|
|
2338
|
-
onChange: async (key, value) => {
|
|
2339
|
-
if (key === "page") {
|
|
2340
|
-
setPage(value + 1);
|
|
2341
|
-
await form.submit();
|
|
2342
|
-
return;
|
|
2343
|
-
}
|
|
2344
|
-
if (key === "size") {
|
|
2345
|
-
setSize(String(value));
|
|
2346
|
-
form.input.page.set(0);
|
|
2347
|
-
return;
|
|
2348
|
-
}
|
|
2349
|
-
props.onFilterChange?.(key, value, form);
|
|
2350
|
-
}
|
|
2351
|
-
}, [items]);
|
|
2352
|
-
(0, __mantine_hooks.useDebouncedCallback)(() => form.submit(), { delay: 800 });
|
|
2353
|
-
const dt = (0, __alepha_react.useInject)(alepha_datetime.DateTimeProvider);
|
|
2354
|
-
(0, react.useEffect)(() => {
|
|
2355
|
-
if (props.submitOnInit) form.submit();
|
|
2356
|
-
if (props.submitEvery) {
|
|
2357
|
-
const it = dt.createInterval(() => {
|
|
2358
|
-
form.submit();
|
|
2359
|
-
}, props.submitEvery);
|
|
2360
|
-
return () => dt.clearInterval(it);
|
|
2361
|
-
}
|
|
2362
|
-
}, []);
|
|
2363
|
-
(0, react.useEffect)(() => {
|
|
2364
|
-
if (typeof props.items !== "function") setItems(props.items);
|
|
2365
|
-
}, [props.items]);
|
|
2366
|
-
(0, react.useEffect)(() => {
|
|
2367
|
-
if (!props.infinityScroll || typeof props.items !== "function") return;
|
|
2368
|
-
const handleScroll = () => {
|
|
2369
|
-
if (form.submitting) return;
|
|
2370
|
-
const scrollTop = window.scrollY;
|
|
2371
|
-
const windowHeight = window.innerHeight;
|
|
2372
|
-
const docHeight = document.documentElement.scrollHeight;
|
|
2373
|
-
if (scrollTop + windowHeight >= docHeight - 300) {
|
|
2374
|
-
const totalPages = items.page?.totalPages ?? 1;
|
|
2375
|
-
if (currentPage + 1 < totalPages) form.input.page.set(currentPage + 1);
|
|
2376
|
-
}
|
|
2377
|
-
};
|
|
2378
|
-
window.addEventListener("scroll", handleScroll);
|
|
2379
|
-
return () => window.removeEventListener("scroll", handleScroll);
|
|
2380
|
-
}, [
|
|
2381
|
-
props.infinityScroll,
|
|
2382
|
-
form.submitting,
|
|
2383
|
-
items.page?.totalPages,
|
|
2384
|
-
currentPage,
|
|
2385
|
-
form
|
|
2386
|
-
]);
|
|
2387
|
-
const head = Object.entries(props.columns).map(([key, col]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Th, {
|
|
2388
|
-
style: { ...col.fit ? {
|
|
2389
|
-
width: "1%",
|
|
2390
|
-
whiteSpace: "nowrap"
|
|
2391
|
-
} : {} },
|
|
2392
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton_default, {
|
|
2393
|
-
justify: "space-between",
|
|
2394
|
-
radius: 0,
|
|
2395
|
-
fullWidth: true,
|
|
2396
|
-
size: "xs",
|
|
2397
|
-
children: col.label
|
|
2398
|
-
})
|
|
2399
|
-
}, key));
|
|
2400
|
-
const rows = items.content.map((item, index) => {
|
|
2401
|
-
const trProps = props.tableTrProps ? props.tableTrProps(item) : {};
|
|
2402
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Tr, {
|
|
2403
|
-
...trProps,
|
|
2404
|
-
children: Object.entries(props.columns).map(([key, col]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Td, { children: col.value(item, {
|
|
2405
|
-
index,
|
|
2406
|
-
form,
|
|
2407
|
-
alepha: alepha$1
|
|
2408
|
-
}) }, key))
|
|
2409
|
-
}, JSON.stringify(item));
|
|
2410
|
-
});
|
|
2411
|
-
const schema = alepha.t.omit(form.options.schema, [
|
|
2412
|
-
"page",
|
|
2413
|
-
"size",
|
|
2414
|
-
"sort"
|
|
2415
|
-
]);
|
|
2416
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2417
|
-
direction: "column",
|
|
2418
|
-
gap: "sm",
|
|
2419
|
-
flex: 1,
|
|
2420
|
-
children: [
|
|
2421
|
-
props.filters ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypeForm_default, {
|
|
2422
|
-
...props.typeFormProps,
|
|
2423
|
-
form,
|
|
2424
|
-
schema
|
|
2425
|
-
}) : null,
|
|
2426
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, {
|
|
2427
|
-
className: "overflow-auto",
|
|
2428
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Table, {
|
|
2429
|
-
striped: true,
|
|
2430
|
-
withRowBorders: true,
|
|
2431
|
-
withColumnBorders: true,
|
|
2432
|
-
withTableBorder: true,
|
|
2433
|
-
stripedColor: "",
|
|
2434
|
-
...props.tableProps,
|
|
2435
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Thead, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Tr, { children: head }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Table.Tbody, { children: rows })]
|
|
2436
|
-
})
|
|
2437
|
-
}),
|
|
2438
|
-
!props.infinityScroll && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.Flex, {
|
|
2439
|
-
justify: "space-between",
|
|
2440
|
-
align: "center",
|
|
2441
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Pagination, {
|
|
2442
|
-
withEdges: true,
|
|
2443
|
-
total: items.page?.totalPages ?? 1,
|
|
2444
|
-
value: page,
|
|
2445
|
-
onChange: (value) => {
|
|
2446
|
-
form.input.page.set(value - 1);
|
|
2447
|
-
}
|
|
2448
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Flex, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.Select, {
|
|
2449
|
-
value: size,
|
|
2450
|
-
onChange: (value) => {
|
|
2451
|
-
form.input.size.set(Number(value));
|
|
2452
|
-
},
|
|
2453
|
-
data: [
|
|
2454
|
-
{
|
|
2455
|
-
value: "5",
|
|
2456
|
-
label: "5"
|
|
2457
|
-
},
|
|
2458
|
-
{
|
|
2459
|
-
value: "10",
|
|
2460
|
-
label: "10"
|
|
2461
|
-
},
|
|
2462
|
-
{
|
|
2463
|
-
value: "25",
|
|
2464
|
-
label: "25"
|
|
2465
|
-
},
|
|
2466
|
-
{
|
|
2467
|
-
value: "50",
|
|
2468
|
-
label: "50"
|
|
2469
|
-
},
|
|
2470
|
-
{
|
|
2471
|
-
value: "100",
|
|
2472
|
-
label: "100"
|
|
2473
|
-
}
|
|
2474
|
-
]
|
|
2475
|
-
}) })]
|
|
2476
|
-
})
|
|
2477
|
-
]
|
|
2478
|
-
});
|
|
2479
|
-
};
|
|
2480
|
-
var DataTable_default = DataTable;
|
|
2481
|
-
|
|
2482
|
-
//#endregion
|
|
2483
|
-
//#region src/core/index.ts
|
|
2484
|
-
/**
|
|
2485
|
-
* Mantine
|
|
2486
|
-
*
|
|
2487
|
-
* @module alepha.ui
|
|
2488
|
-
*/
|
|
2489
|
-
const AlephaUI = (0, alepha.$module)({
|
|
2490
|
-
name: "alepha.ui",
|
|
2491
|
-
services: [
|
|
2492
|
-
DialogService,
|
|
2493
|
-
ToastService,
|
|
2494
|
-
RootRouter
|
|
2495
|
-
],
|
|
2496
|
-
register: (alepha$1) => {
|
|
2497
|
-
alepha$1.with(__alepha_react_i18n.AlephaReactI18n);
|
|
2498
|
-
alepha$1.with(__alepha_react_head.AlephaReactHead);
|
|
2499
|
-
alepha$1.with(__alepha_react_form.AlephaReactForm);
|
|
2500
|
-
alepha$1.with(DialogService);
|
|
2501
|
-
alepha$1.with(ToastService);
|
|
2502
|
-
}
|
|
2503
|
-
});
|
|
2504
|
-
|
|
2505
|
-
//#endregion
|
|
2506
|
-
Object.defineProperty(exports, 'AdminShell_default', {
|
|
2507
|
-
enumerable: true,
|
|
2508
|
-
get: function () {
|
|
2509
|
-
return AdminShell_default;
|
|
2510
|
-
}
|
|
2511
|
-
});
|
|
2512
|
-
Object.defineProperty(exports, 'AlephaMantineProvider_default', {
|
|
2513
|
-
enumerable: true,
|
|
2514
|
-
get: function () {
|
|
2515
|
-
return AlephaMantineProvider_default;
|
|
2516
|
-
}
|
|
2517
|
-
});
|
|
2518
|
-
Object.defineProperty(exports, 'AlephaUI', {
|
|
2519
|
-
enumerable: true,
|
|
2520
|
-
get: function () {
|
|
2521
|
-
return AlephaUI;
|
|
2522
|
-
}
|
|
2523
|
-
});
|
|
2524
|
-
Object.defineProperty(exports, 'DataTable_default', {
|
|
2525
|
-
enumerable: true,
|
|
2526
|
-
get: function () {
|
|
2527
|
-
return DataTable_default;
|
|
2528
|
-
}
|
|
2529
|
-
});
|
|
2530
|
-
//# sourceMappingURL=core-aFtK4l9I.cjs.map
|