@alepha/ui 0.12.0 → 0.12.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/README.md +2 -30
- package/dist/admin/AdminFiles-BM6_7_5A.cjs +4 -0
- package/dist/admin/AdminFiles-BaCIMeNt.js +4 -0
- package/dist/admin/AdminFiles-CllAxb1B.js +117 -0
- package/dist/admin/AdminFiles-CllAxb1B.js.map +1 -0
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs +122 -0
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs.map +1 -0
- package/dist/admin/AdminJobs-BXkFtlVo.js +125 -0
- package/dist/admin/AdminJobs-BXkFtlVo.js.map +1 -0
- package/dist/admin/AdminJobs-C428qrNQ.cjs +130 -0
- package/dist/admin/AdminJobs-C428qrNQ.cjs.map +1 -0
- package/dist/admin/AdminJobs-DCPPaJ4i.cjs +4 -0
- package/dist/admin/AdminJobs-yC6DarGO.js +4 -0
- package/dist/admin/AdminLayout-Bqo4cd33.cjs +4 -0
- package/dist/admin/AdminLayout-CQpxfko6.js +4 -0
- package/dist/admin/AdminLayout-CiLlywAQ.cjs +93 -0
- package/dist/admin/AdminLayout-CiLlywAQ.cjs.map +1 -0
- package/dist/admin/AdminLayout-CtkVYk-u.js +88 -0
- package/dist/admin/AdminLayout-CtkVYk-u.js.map +1 -0
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs +44 -0
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs.map +1 -0
- package/dist/admin/AdminNotifications-DaMu1AQ4.js +4 -0
- package/dist/admin/AdminNotifications-DnnulNNV.js +40 -0
- package/dist/admin/AdminNotifications-DnnulNNV.js.map +1 -0
- package/dist/admin/AdminNotifications-ihgbKVCx.cjs +4 -0
- package/dist/admin/AdminParameters-B3hvpLpu.js +40 -0
- package/dist/admin/AdminParameters-B3hvpLpu.js.map +1 -0
- package/dist/admin/AdminParameters-U4lU1rUF.cjs +4 -0
- package/dist/admin/AdminParameters-gdf7036N.cjs +44 -0
- package/dist/admin/AdminParameters-gdf7036N.cjs.map +1 -0
- package/dist/admin/AdminParameters-prMcCgxf.js +4 -0
- package/dist/admin/AdminSessions-BF_P4lHs.cjs +128 -0
- package/dist/admin/AdminSessions-BF_P4lHs.cjs.map +1 -0
- package/dist/admin/AdminSessions-CATIU61I.cjs +4 -0
- package/dist/admin/AdminSessions-DqOXOpYR.js +4 -0
- package/dist/admin/AdminSessions-Pjdz-iZx.js +123 -0
- package/dist/admin/AdminSessions-Pjdz-iZx.js.map +1 -0
- package/dist/admin/AdminUsers-BgTL-zSY.js +4 -0
- package/dist/admin/AdminUsers-C1HsrRxn.js +104 -0
- package/dist/admin/AdminUsers-C1HsrRxn.js.map +1 -0
- package/dist/admin/AdminUsers-HqvxwNGZ.cjs +4 -0
- package/dist/admin/AdminUsers-M2uEQbp5.cjs +109 -0
- package/dist/admin/AdminUsers-M2uEQbp5.cjs.map +1 -0
- package/dist/admin/AdminVerifications-BVssbtfU.cjs +44 -0
- package/dist/admin/AdminVerifications-BVssbtfU.cjs.map +1 -0
- package/dist/admin/AdminVerifications-Df6DRgNo.js +4 -0
- package/dist/admin/AdminVerifications-DxAtcYUR.cjs +4 -0
- package/dist/admin/AdminVerifications-VMpm30mS.js +40 -0
- package/dist/admin/AdminVerifications-VMpm30mS.js.map +1 -0
- package/dist/admin/core-CzO6aavT.js +2507 -0
- package/dist/admin/core-CzO6aavT.js.map +1 -0
- package/dist/{index.cjs → admin/core-aFtK4l9I.cjs} +287 -204
- package/dist/admin/core-aFtK4l9I.cjs.map +1 -0
- package/dist/admin/index.cjs +87 -0
- package/dist/admin/index.cjs.map +1 -0
- package/dist/admin/index.d.cts +1739 -0
- package/dist/admin/index.d.ts +1745 -0
- package/dist/admin/index.js +78 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/auth/IconGoogle-B17BTQyD.cjs +69 -0
- package/dist/auth/IconGoogle-B17BTQyD.cjs.map +1 -0
- package/dist/auth/IconGoogle-Bfmuv9Rv.js +58 -0
- package/dist/auth/IconGoogle-Bfmuv9Rv.js.map +1 -0
- package/dist/auth/Login-BTBmbnWl.cjs +181 -0
- package/dist/auth/Login-BTBmbnWl.cjs.map +1 -0
- package/dist/auth/Login-BcQOtG3v.js +5 -0
- package/dist/auth/Login-Btmd70Um.cjs +5 -0
- package/dist/auth/Login-JeXFsUf5.js +176 -0
- package/dist/auth/Login-JeXFsUf5.js.map +1 -0
- package/dist/auth/Register-CPQnvXCZ.js +318 -0
- package/dist/auth/Register-CPQnvXCZ.js.map +1 -0
- package/dist/auth/Register-CbesZal3.cjs +5 -0
- package/dist/auth/Register-DpI_JdyO.js +5 -0
- package/dist/auth/Register-HP3rP71B.cjs +323 -0
- package/dist/auth/Register-HP3rP71B.cjs.map +1 -0
- package/dist/auth/ResetPassword-B-tkzV7g.cjs +248 -0
- package/dist/auth/ResetPassword-B-tkzV7g.cjs.map +1 -0
- package/dist/auth/ResetPassword-BlK3xEpU.js +4 -0
- package/dist/auth/ResetPassword-BzUjGG_-.js +243 -0
- package/dist/auth/ResetPassword-BzUjGG_-.js.map +1 -0
- package/dist/auth/ResetPassword-W3xjOnWy.cjs +4 -0
- package/dist/auth/chunk-DhGyd7sr.js +28 -0
- package/dist/auth/core-D1MHij1j.js +1795 -0
- package/dist/auth/core-D1MHij1j.js.map +1 -0
- package/dist/auth/core-rDZ9d92K.cjs +1824 -0
- package/dist/auth/core-rDZ9d92K.cjs.map +1 -0
- package/dist/auth/index.cjs +211 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +6265 -0
- package/dist/auth/index.d.ts +6274 -0
- package/dist/auth/index.js +206 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/core/index.cjs +2620 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +2737 -0
- package/dist/core/index.d.ts +2743 -0
- package/dist/{index.js → core/index.js} +298 -126
- package/dist/core/index.js.map +1 -0
- package/package.json +32 -14
- package/src/admin/AdminRouter.ts +58 -0
- package/src/admin/components/AdminFiles.tsx +117 -0
- package/src/admin/components/AdminJobs.tsx +158 -0
- package/src/admin/components/AdminLayout.tsx +114 -0
- package/src/admin/components/AdminNotifications.tsx +20 -0
- package/src/admin/components/AdminParameters.tsx +24 -0
- package/src/admin/components/AdminSessions.tsx +159 -0
- package/src/admin/components/AdminUsers.tsx +137 -0
- package/src/admin/components/AdminVerifications.tsx +25 -0
- package/src/admin/index.ts +29 -0
- package/src/auth/AuthI18n.ts +118 -0
- package/src/auth/AuthRouter.ts +53 -0
- package/src/auth/components/Login.tsx +193 -0
- package/src/auth/components/Register.tsx +421 -0
- package/src/auth/components/ResetPassword.tsx +259 -0
- package/src/auth/components/buttons/UserButton.tsx +118 -0
- package/src/auth/components/icons/IconGithub.tsx +21 -0
- package/src/auth/components/icons/IconGoogle.tsx +30 -0
- package/src/auth/index.ts +27 -0
- package/src/{RootRouter.ts → core/RootRouter.ts} +2 -1
- package/src/{components → core/components}/buttons/ActionButton.tsx +49 -6
- package/src/core/components/buttons/ClipboardButton.tsx +56 -0
- package/src/{components → core/components}/buttons/DarkModeButton.tsx +7 -8
- package/src/{components → core/components}/buttons/LanguageButton.tsx +2 -2
- package/src/{components → core/components}/buttons/OmnibarButton.tsx +1 -1
- package/src/{components → core/components}/dialogs/AlertDialog.tsx +1 -1
- package/src/{components → core/components}/dialogs/ConfirmDialog.tsx +1 -1
- package/src/{components → core/components}/dialogs/PromptDialog.tsx +1 -1
- package/src/{components → core/components}/form/Control.tsx +1 -0
- package/src/{components → core/components}/layout/AdminShell.tsx +38 -7
- package/src/{components → core/components}/layout/AlephaMantineProvider.tsx +12 -8
- package/src/{components → core/components}/layout/AppBar.tsx +1 -1
- package/src/{components → core/components}/layout/Omnibar.tsx +1 -1
- package/src/{components → core/components}/layout/Sidebar.tsx +29 -26
- package/src/{components → core/components}/table/DataTable.tsx +1 -1
- package/src/{constants → core/constants}/ui.ts +9 -0
- package/src/{index.ts → core/index.ts} +3 -0
- package/src/{services → core/services}/DialogService.tsx +3 -3
- package/src/{services → core/services}/ToastService.tsx +3 -1
- package/src/{utils → core/utils}/extractSchemaFields.ts +2 -8
- package/src/{utils → core/utils}/icons.tsx +5 -15
- package/src/{utils → core/utils}/parseInput.ts +34 -26
- package/dist/AlephaMantineProvider-CGpgWDt8.cjs +0 -3
- package/dist/AlephaMantineProvider-D8cHYAge.js +0 -152
- package/dist/AlephaMantineProvider-D8cHYAge.js.map +0 -1
- package/dist/AlephaMantineProvider-DuvZFAuk.cjs +0 -175
- package/dist/AlephaMantineProvider-DuvZFAuk.cjs.map +0 -1
- package/dist/AlephaMantineProvider-twBqV4IO.js +0 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -821
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -821
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- /package/src/{components → core/components}/buttons/BurgerButton.tsx +0 -0
- /package/src/{components → core/components}/buttons/ToggleSidebarButton.tsx +0 -0
- /package/src/{components → core/components}/data/JsonViewer.tsx +0 -0
- /package/src/{components → core/components}/form/ControlDate.tsx +0 -0
- /package/src/{components → core/components}/form/ControlNumber.tsx +0 -0
- /package/src/{components → core/components}/form/ControlQueryBuilder.tsx +0 -0
- /package/src/{components → core/components}/form/ControlSelect.tsx +0 -0
- /package/src/{components → core/components}/form/TypeForm.tsx +0 -0
- /package/src/{hooks → core/hooks}/useDialog.ts +0 -0
- /package/src/{hooks → core/hooks}/useToast.ts +0 -0
- /package/src/{utils → core/utils}/string.ts +0 -0
|
@@ -4,15 +4,22 @@ import {
|
|
|
4
4
|
type FlexProps,
|
|
5
5
|
type MantineBreakpoint,
|
|
6
6
|
Text,
|
|
7
|
-
ThemeIcon,
|
|
8
7
|
} from "@mantine/core";
|
|
9
8
|
import {
|
|
10
9
|
IconChevronDown,
|
|
11
10
|
IconChevronRight,
|
|
12
11
|
IconSquareRounded,
|
|
13
12
|
} from "@tabler/icons-react";
|
|
14
|
-
import {
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
type ComponentType,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
useCallback,
|
|
17
|
+
useState,
|
|
18
|
+
} from "react";
|
|
19
|
+
import ActionButton, {
|
|
20
|
+
type ActionProps,
|
|
21
|
+
renderIcon,
|
|
22
|
+
} from "../buttons/ActionButton.tsx";
|
|
16
23
|
import OmnibarButton from "../buttons/OmnibarButton.tsx";
|
|
17
24
|
|
|
18
25
|
export interface SidebarProps {
|
|
@@ -25,6 +32,9 @@ export interface SidebarProps {
|
|
|
25
32
|
flexProps?: Partial<FlexProps>;
|
|
26
33
|
collapsed?: boolean;
|
|
27
34
|
gap?: MantineBreakpoint;
|
|
35
|
+
hide?: {
|
|
36
|
+
paths?: string[];
|
|
37
|
+
};
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
export const Sidebar = (props: SidebarProps) => {
|
|
@@ -56,10 +66,8 @@ export const Sidebar = (props: SidebarProps) => {
|
|
|
56
66
|
if (item.type === "section") {
|
|
57
67
|
if (props.collapsed) return;
|
|
58
68
|
return (
|
|
59
|
-
<Flex mt={"md"} mb={"xs"} align={"center"} gap={"xs"}>
|
|
60
|
-
|
|
61
|
-
{item.icon}
|
|
62
|
-
</ThemeIcon>
|
|
69
|
+
<Flex key={key} mt={"md"} mb={"xs"} align={"center"} gap={"xs"}>
|
|
70
|
+
{renderIcon(item.icon)}
|
|
63
71
|
<Text
|
|
64
72
|
key={key}
|
|
65
73
|
size={"xs"}
|
|
@@ -108,8 +116,8 @@ export const Sidebar = (props: SidebarProps) => {
|
|
|
108
116
|
(router.concretePages.map((page) => ({
|
|
109
117
|
label: page.label ?? page.name,
|
|
110
118
|
description: page.description,
|
|
111
|
-
icon: page.icon,
|
|
112
|
-
href: page.
|
|
119
|
+
icon: renderIcon(page.icon),
|
|
120
|
+
href: router.path(page.name),
|
|
113
121
|
})) as SidebarMenuItem[]);
|
|
114
122
|
|
|
115
123
|
return (
|
|
@@ -211,25 +219,19 @@ export const SidebarItem = (props: SidebarItemProps) => {
|
|
|
211
219
|
justify="space-between"
|
|
212
220
|
href={props.item.href}
|
|
213
221
|
target={props.item.target}
|
|
214
|
-
variant={"subtle"}
|
|
215
222
|
size={
|
|
216
223
|
props.item.theme?.size ??
|
|
217
224
|
props.theme.button?.size ??
|
|
218
225
|
(level === 0 ? "sm" : "xs")
|
|
219
226
|
}
|
|
227
|
+
color={"var(--alepha-text)"}
|
|
228
|
+
variant={"subtle"}
|
|
220
229
|
variantActive={"default"}
|
|
221
230
|
radius={props.item.theme?.radius ?? props.theme.button?.radius ?? "md"}
|
|
222
231
|
onClick={handleItemClick}
|
|
223
232
|
leftSection={
|
|
224
233
|
<Flex w={"100%"} align="center" gap={"sm"}>
|
|
225
|
-
{item.icon
|
|
226
|
-
<ThemeIcon
|
|
227
|
-
size={level === 0 ? "sm" : "xs"}
|
|
228
|
-
variant={"transparent"}
|
|
229
|
-
>
|
|
230
|
-
{item.icon}
|
|
231
|
-
</ThemeIcon>
|
|
232
|
-
)}
|
|
234
|
+
{renderIcon(item.icon)}
|
|
233
235
|
<Flex direction={"column"}>
|
|
234
236
|
<Flex>{item.label}</Flex>
|
|
235
237
|
{item.description && (
|
|
@@ -328,30 +330,31 @@ const SidebarCollapsedItem = (props: SidebarItemProps) => {
|
|
|
328
330
|
|
|
329
331
|
return (
|
|
330
332
|
<ActionButton
|
|
331
|
-
variant={"subtle"}
|
|
332
333
|
size={
|
|
333
334
|
props.item.theme?.size ??
|
|
334
335
|
props.theme.button?.size ??
|
|
335
336
|
(level === 0 ? "sm" : "xs")
|
|
336
337
|
}
|
|
338
|
+
color={"var(--alepha-text)"}
|
|
339
|
+
variant={"subtle"}
|
|
337
340
|
variantActive={"default"}
|
|
338
341
|
radius={props.item.theme?.radius ?? props.theme.button?.radius ?? "md"}
|
|
339
342
|
onClick={handleItemClick}
|
|
340
|
-
icon={item.icon ?? <IconSquareRounded />}
|
|
341
|
-
href={props.item.href}
|
|
343
|
+
icon={renderIcon(item.icon) ?? <IconSquareRounded />}
|
|
344
|
+
href={props.item.href as any}
|
|
342
345
|
target={props.item.target}
|
|
343
346
|
menu={
|
|
344
347
|
item.children
|
|
345
|
-
? {
|
|
348
|
+
? ({
|
|
346
349
|
position: "right",
|
|
347
350
|
on: "hover",
|
|
348
351
|
items: item.children.map((child) => ({
|
|
349
352
|
label: child.label,
|
|
350
353
|
href: child.href,
|
|
351
|
-
icon: child.icon,
|
|
354
|
+
icon: renderIcon(child.icon),
|
|
352
355
|
children: child.children,
|
|
353
356
|
})),
|
|
354
|
-
}
|
|
357
|
+
} as any)
|
|
355
358
|
: undefined
|
|
356
359
|
}
|
|
357
360
|
{...props.item.actionProps}
|
|
@@ -392,13 +395,13 @@ export interface SidebarSearch extends SidebarAbstractItem {
|
|
|
392
395
|
export interface SidebarSection extends SidebarAbstractItem {
|
|
393
396
|
type: "section";
|
|
394
397
|
label: string;
|
|
395
|
-
icon?: ReactNode;
|
|
398
|
+
icon?: ReactNode | ComponentType;
|
|
396
399
|
}
|
|
397
400
|
|
|
398
401
|
export interface SidebarMenuItem extends SidebarAbstractItem {
|
|
399
402
|
label: string | ReactNode;
|
|
400
403
|
description?: string;
|
|
401
|
-
icon?: ReactNode;
|
|
404
|
+
icon?: ReactNode | ComponentType;
|
|
402
405
|
href?: string;
|
|
403
406
|
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
404
407
|
activeStartsWith?: boolean; // Use startWith matching for active state
|
|
@@ -22,7 +22,10 @@ export type {
|
|
|
22
22
|
} from "./components/buttons/ActionButton.tsx";
|
|
23
23
|
export { default as ActionButton } from "./components/buttons/ActionButton.tsx";
|
|
24
24
|
export { default as BurgerButton } from "./components/buttons/BurgerButton.tsx";
|
|
25
|
+
export type { ClipboardButtonProps } from "./components/buttons/ClipboardButton.tsx";
|
|
26
|
+
export { default as ClipboardButton } from "./components/buttons/ClipboardButton.tsx";
|
|
25
27
|
export { default as DarkModeButton } from "./components/buttons/DarkModeButton.tsx";
|
|
28
|
+
export { default as LanguageButton } from "./components/buttons/LanguageButton.tsx";
|
|
26
29
|
export { default as OmnibarButton } from "./components/buttons/OmnibarButton.tsx";
|
|
27
30
|
export { default as JsonViewer } from "./components/data/JsonViewer.tsx";
|
|
28
31
|
export { default as AlertDialog } from "./components/dialogs/AlertDialog.tsx";
|
|
@@ -2,9 +2,9 @@ import { Flex, type ModalProps } from "@mantine/core";
|
|
|
2
2
|
import { modals } from "@mantine/modals";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
import JsonViewer from "../components/data/JsonViewer.tsx";
|
|
5
|
-
import AlertDialog from "../components/dialogs/AlertDialog";
|
|
6
|
-
import ConfirmDialog from "../components/dialogs/ConfirmDialog";
|
|
7
|
-
import PromptDialog from "../components/dialogs/PromptDialog";
|
|
5
|
+
import AlertDialog from "../components/dialogs/AlertDialog.tsx";
|
|
6
|
+
import ConfirmDialog from "../components/dialogs/ConfirmDialog.tsx";
|
|
7
|
+
import PromptDialog from "../components/dialogs/PromptDialog.tsx";
|
|
8
8
|
import { ui } from "../constants/ui.ts";
|
|
9
9
|
|
|
10
10
|
// Base interfaces
|
|
@@ -117,8 +117,8 @@ export function getOperatorsForField(field: SchemaField): string[] {
|
|
|
117
117
|
switch (field.type) {
|
|
118
118
|
case "string":
|
|
119
119
|
case "text":
|
|
120
|
-
// String fields: equality
|
|
121
|
-
return [...allOperators, "
|
|
120
|
+
// String fields: equality and null checks (wildcards supported in = operator)
|
|
121
|
+
return [...allOperators, "null"];
|
|
122
122
|
|
|
123
123
|
case "number":
|
|
124
124
|
case "integer":
|
|
@@ -152,12 +152,6 @@ export const OPERATOR_INFO: Record<
|
|
|
152
152
|
gte: { symbol: ">=", label: "greater or equal", example: "age>=18" },
|
|
153
153
|
lt: { symbol: "<", label: "less than", example: "age<65" },
|
|
154
154
|
lte: { symbol: "<=", label: "less or equal", example: "age<=65" },
|
|
155
|
-
like: { symbol: "~", label: "like (case-sensitive)", example: "name~John" },
|
|
156
|
-
ilike: {
|
|
157
|
-
symbol: "~*",
|
|
158
|
-
label: "like (case-insensitive)",
|
|
159
|
-
example: "name~*john",
|
|
160
|
-
},
|
|
161
155
|
null: { symbol: "=null", label: "is null", example: "deletedAt=null" },
|
|
162
156
|
notNull: {
|
|
163
157
|
symbol: "!=null",
|
|
@@ -15,20 +15,10 @@ import {
|
|
|
15
15
|
IconSelector,
|
|
16
16
|
IconToggleLeft,
|
|
17
17
|
} from "@tabler/icons-react";
|
|
18
|
-
import type {
|
|
18
|
+
import type { ReactElement } from "react";
|
|
19
|
+
import { ui } from "../constants/ui.ts";
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
* Icon size presets following Mantine's size conventions
|
|
22
|
-
*/
|
|
23
|
-
export const ICON_SIZES = {
|
|
24
|
-
xs: 12,
|
|
25
|
-
sm: 16,
|
|
26
|
-
md: 20,
|
|
27
|
-
lg: 24,
|
|
28
|
-
xl: 28,
|
|
29
|
-
} as const;
|
|
30
|
-
|
|
31
|
-
export type IconSize = keyof typeof ICON_SIZES;
|
|
21
|
+
export type IconSize = keyof typeof ui.sizes.icon;
|
|
32
22
|
|
|
33
23
|
/**
|
|
34
24
|
* Get the default icon for an input based on its type, format, or name.
|
|
@@ -40,9 +30,9 @@ export const getDefaultIcon = (params: {
|
|
|
40
30
|
isEnum?: boolean;
|
|
41
31
|
isArray?: boolean;
|
|
42
32
|
size?: IconSize;
|
|
43
|
-
}):
|
|
33
|
+
}): ReactElement => {
|
|
44
34
|
const { type, format, name, isEnum, isArray, size = "sm" } = params;
|
|
45
|
-
const iconSize =
|
|
35
|
+
const iconSize = ui.sizes.icon[size];
|
|
46
36
|
|
|
47
37
|
// Format-based icons (highest priority)
|
|
48
38
|
if (format) {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { InputField } from "@alepha/react/form";
|
|
2
2
|
import { type TObject, TypeBoxError } from "alepha";
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
createElement,
|
|
5
|
+
isValidElement,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from "react";
|
|
4
9
|
import type { ControlProps } from "../components/form/Control.tsx";
|
|
10
|
+
import { ui } from "../constants/ui.ts";
|
|
5
11
|
import { getDefaultIcon } from "./icons.tsx";
|
|
6
12
|
import { prettyName } from "./string.ts";
|
|
7
13
|
|
|
@@ -32,29 +38,31 @@ export const parseInput = (
|
|
|
32
38
|
: undefined;
|
|
33
39
|
|
|
34
40
|
// Auto-generate icon if not provided
|
|
35
|
-
const icon =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
const icon = !props.icon
|
|
42
|
+
? getDefaultIcon({
|
|
43
|
+
type:
|
|
44
|
+
props.input.schema && "type" in props.input.schema
|
|
45
|
+
? String(props.input.schema.type)
|
|
46
|
+
: undefined,
|
|
47
|
+
format:
|
|
48
|
+
props.input.schema &&
|
|
49
|
+
"format" in props.input.schema &&
|
|
50
|
+
typeof props.input.schema.format === "string"
|
|
51
|
+
? props.input.schema.format
|
|
52
|
+
: undefined,
|
|
53
|
+
name: props.input.props.name,
|
|
54
|
+
isEnum:
|
|
55
|
+
props.input.schema &&
|
|
56
|
+
"enum" in props.input.schema &&
|
|
57
|
+
Boolean(props.input.schema.enum),
|
|
58
|
+
isArray:
|
|
59
|
+
props.input.schema &&
|
|
60
|
+
"type" in props.input.schema &&
|
|
61
|
+
props.input.schema.type === "array",
|
|
62
|
+
})
|
|
63
|
+
: isValidElement(props.icon)
|
|
64
|
+
? props.icon
|
|
65
|
+
: createElement(props.icon, { size: ui.sizes.icon.md });
|
|
58
66
|
|
|
59
67
|
const format =
|
|
60
68
|
props.input.schema &&
|
|
@@ -100,12 +108,12 @@ export interface GenericControlProps {
|
|
|
100
108
|
input: InputField;
|
|
101
109
|
title?: string;
|
|
102
110
|
description?: string;
|
|
103
|
-
icon?: ReactNode;
|
|
111
|
+
icon?: ReactElement | ((props: { size: number }) => ReactNode);
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
export interface ControlInput {
|
|
107
115
|
id?: string;
|
|
108
|
-
icon:
|
|
116
|
+
icon: ReactElement;
|
|
109
117
|
format?: string;
|
|
110
118
|
schema: TObject & { $control?: ControlProps };
|
|
111
119
|
inputProps: InputProps;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { NestedView, useEvents, useInject, useRouter } from "@alepha/react";
|
|
2
|
-
import { ColorSchemeScript, MantineProvider } from "@mantine/core";
|
|
3
|
-
import { ModalsProvider } from "@mantine/modals";
|
|
4
|
-
import { IconAlertTriangle, IconCheck, IconInfoCircle, IconSearch, IconX } from "@tabler/icons-react";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { Notifications, notifications } from "@mantine/notifications";
|
|
8
|
-
import { Spotlight } from "@mantine/spotlight";
|
|
9
|
-
import { NavigationProgress, nprogress } from "@mantine/nprogress";
|
|
10
|
-
|
|
11
|
-
//#region src/services/ToastService.tsx
|
|
12
|
-
var ToastService = class {
|
|
13
|
-
raw = notifications;
|
|
14
|
-
options = { default: {
|
|
15
|
-
autoClose: 5e3,
|
|
16
|
-
withCloseButton: true,
|
|
17
|
-
position: "top-center"
|
|
18
|
-
} };
|
|
19
|
-
show(options) {
|
|
20
|
-
notifications.show({
|
|
21
|
-
...this.options.default,
|
|
22
|
-
...options
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
info(options) {
|
|
26
|
-
if (typeof options === "string") options = { message: options };
|
|
27
|
-
this.show({
|
|
28
|
-
color: "blue",
|
|
29
|
-
icon: /* @__PURE__ */ jsx(IconInfoCircle, { size: 20 }),
|
|
30
|
-
title: "Info",
|
|
31
|
-
message: "Information notification",
|
|
32
|
-
...options
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
success(options) {
|
|
36
|
-
if (typeof options === "string") options = { message: options };
|
|
37
|
-
this.show({
|
|
38
|
-
color: "green",
|
|
39
|
-
icon: /* @__PURE__ */ jsx(IconCheck, { size: 16 }),
|
|
40
|
-
title: "Success",
|
|
41
|
-
message: "Operation completed successfully",
|
|
42
|
-
...options
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
warning(options) {
|
|
46
|
-
if (typeof options === "string") options = { message: options };
|
|
47
|
-
this.show({
|
|
48
|
-
color: "yellow",
|
|
49
|
-
icon: /* @__PURE__ */ jsx(IconAlertTriangle, { size: 20 }),
|
|
50
|
-
title: "Warning",
|
|
51
|
-
message: "Please review this warning",
|
|
52
|
-
...options
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
danger(options) {
|
|
56
|
-
if (typeof options === "string") options = { message: options };
|
|
57
|
-
this.show({
|
|
58
|
-
color: "red",
|
|
59
|
-
icon: /* @__PURE__ */ jsx(IconX, { size: 20 }),
|
|
60
|
-
title: "Error",
|
|
61
|
-
message: "An error occurred",
|
|
62
|
-
...options
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/hooks/useToast.ts
|
|
69
|
-
/**
|
|
70
|
-
* Use this hook to access the Toast Service for showing notifications.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```tsx
|
|
74
|
-
* const toast = useToast();
|
|
75
|
-
* toast.success({ message: "Operation completed successfully!" });
|
|
76
|
-
* toast.error({ title: "Error", message: "Something went wrong" });
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
const useToast = () => {
|
|
80
|
-
return useInject(ToastService);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/components/layout/Omnibar.tsx
|
|
85
|
-
const Omnibar = (props) => {
|
|
86
|
-
const shortcut = props.shortcut ?? "mod+K";
|
|
87
|
-
const searchPlaceholder = props.searchPlaceholder ?? "Search...";
|
|
88
|
-
const nothingFound = props.nothingFound ?? "Nothing found...";
|
|
89
|
-
const router = useRouter();
|
|
90
|
-
return /* @__PURE__ */ jsx(Spotlight, {
|
|
91
|
-
actions: useMemo(() => router.concretePages.map((page) => ({
|
|
92
|
-
id: page.name,
|
|
93
|
-
label: page.label ?? page.name,
|
|
94
|
-
description: page.description,
|
|
95
|
-
onClick: () => router.go(page.path ?? page.name),
|
|
96
|
-
leftSection: page.icon
|
|
97
|
-
})), []),
|
|
98
|
-
shortcut,
|
|
99
|
-
limit: 10,
|
|
100
|
-
searchProps: {
|
|
101
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 20 }),
|
|
102
|
-
placeholder: searchPlaceholder
|
|
103
|
-
},
|
|
104
|
-
nothingFound
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
var Omnibar_default = Omnibar;
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/components/layout/AlephaMantineProvider.tsx
|
|
111
|
-
const AlephaMantineProvider = (props) => {
|
|
112
|
-
const toast = useToast();
|
|
113
|
-
useEvents({
|
|
114
|
-
"react:transition:begin": () => {
|
|
115
|
-
nprogress.start();
|
|
116
|
-
},
|
|
117
|
-
"react:transition:end": () => {
|
|
118
|
-
nprogress.complete();
|
|
119
|
-
},
|
|
120
|
-
"react:action:error": () => {
|
|
121
|
-
toast.danger("An error occurred while processing your action.");
|
|
122
|
-
}
|
|
123
|
-
}, []);
|
|
124
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ColorSchemeScript, {
|
|
125
|
-
defaultColorScheme: props.mantine?.defaultColorScheme,
|
|
126
|
-
...props.colorSchemeScript
|
|
127
|
-
}), /* @__PURE__ */ jsxs(MantineProvider, {
|
|
128
|
-
...props.mantine,
|
|
129
|
-
theme: {
|
|
130
|
-
primaryColor: "gray",
|
|
131
|
-
primaryShade: {
|
|
132
|
-
light: 9,
|
|
133
|
-
dark: 8
|
|
134
|
-
},
|
|
135
|
-
cursorType: "pointer",
|
|
136
|
-
...props.mantine?.theme
|
|
137
|
-
},
|
|
138
|
-
children: [
|
|
139
|
-
/* @__PURE__ */ jsx(Notifications, { ...props.notifications }),
|
|
140
|
-
/* @__PURE__ */ jsx(NavigationProgress, { ...props.navigationProgress }),
|
|
141
|
-
/* @__PURE__ */ jsxs(ModalsProvider, {
|
|
142
|
-
...props.modals,
|
|
143
|
-
children: [/* @__PURE__ */ jsx(Omnibar_default, { ...props.omnibar }), props.children ?? /* @__PURE__ */ jsx(NestedView, {})]
|
|
144
|
-
})
|
|
145
|
-
]
|
|
146
|
-
})] });
|
|
147
|
-
};
|
|
148
|
-
var AlephaMantineProvider_default = AlephaMantineProvider;
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
export { ToastService as i, Omnibar_default as n, useToast as r, AlephaMantineProvider_default as t };
|
|
152
|
-
//# sourceMappingURL=AlephaMantineProvider-D8cHYAge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AlephaMantineProvider-D8cHYAge.js","names":["Omnibar"],"sources":["../src/services/ToastService.tsx","../src/hooks/useToast.ts","../src/components/layout/Omnibar.tsx","../src/components/layout/AlephaMantineProvider.tsx"],"sourcesContent":["import type { NotificationData } from \"@mantine/notifications\";\nimport { notifications } from \"@mantine/notifications\";\nimport {\n IconAlertTriangle,\n IconCheck,\n IconInfoCircle,\n IconX,\n} from \"@tabler/icons-react\";\n\nexport interface ToastServiceOptions {\n default?: Partial<NotificationData>;\n}\n\nexport class ToastService {\n protected readonly raw = notifications;\n\n public readonly options: ToastServiceOptions = {\n default: {\n autoClose: 5000,\n withCloseButton: true,\n position: \"top-center\",\n },\n };\n\n public show(options: NotificationData) {\n notifications.show({\n ...this.options.default,\n ...options,\n });\n }\n\n public info(options: Partial<NotificationData> | string) {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.show({\n color: \"blue\",\n icon: <IconInfoCircle size={20} />,\n title: \"Info\",\n message: \"Information notification\",\n ...options,\n });\n }\n\n public success(options: Partial<NotificationData> | string) {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.show({\n color: \"green\",\n icon: <IconCheck size={16} />,\n title: \"Success\",\n message: \"Operation completed successfully\",\n ...options,\n });\n }\n\n public warning(options: Partial<NotificationData> | string) {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.show({\n color: \"yellow\",\n icon: <IconAlertTriangle size={20} />,\n title: \"Warning\",\n message: \"Please review this warning\",\n ...options,\n });\n }\n\n public danger(options: Partial<NotificationData> | string) {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.show({\n color: \"red\",\n icon: <IconX size={20} />,\n title: \"Error\",\n message: \"An error occurred\",\n ...options,\n });\n }\n}\n","import { useInject } from \"@alepha/react\";\nimport { ToastService } from \"../services/ToastService.tsx\";\n\n/**\n * Use this hook to access the Toast Service for showing notifications.\n *\n * @example\n * ```tsx\n * const toast = useToast();\n * toast.success({ message: \"Operation completed successfully!\" });\n * toast.error({ title: \"Error\", message: \"Something went wrong\" });\n * ```\n */\nexport const useToast = (): ToastService => {\n return useInject(ToastService);\n};\n","import { useRouter } from \"@alepha/react\";\nimport { Spotlight, type SpotlightActionData } from \"@mantine/spotlight\";\nimport { IconSearch } from \"@tabler/icons-react\";\nimport { type ReactNode, useMemo } from \"react\";\n\nexport interface OmnibarProps {\n shortcut?: string | string[];\n searchPlaceholder?: string;\n nothingFound?: ReactNode;\n}\n\nconst Omnibar = (props: OmnibarProps) => {\n const shortcut = props.shortcut ?? \"mod+K\";\n const searchPlaceholder = props.searchPlaceholder ?? \"Search...\";\n const nothingFound = props.nothingFound ?? \"Nothing found...\";\n const router = useRouter();\n const actions: SpotlightActionData[] = useMemo(\n () =>\n router.concretePages.map((page) => ({\n id: page.name,\n label: page.label ?? page.name,\n description: page.description,\n onClick: () => router.go(page.path ?? page.name),\n leftSection: page.icon,\n })),\n [],\n );\n\n return (\n <Spotlight\n actions={actions}\n shortcut={shortcut}\n limit={10}\n searchProps={{\n leftSection: <IconSearch size={20} />,\n placeholder: searchPlaceholder,\n }}\n nothingFound={nothingFound}\n />\n );\n};\n\nexport default Omnibar;\n","import { NestedView, useEvents } from \"@alepha/react\";\nimport type {\n ColorSchemeScriptProps,\n MantineProviderProps,\n} from \"@mantine/core\";\nimport { ColorSchemeScript, MantineProvider } from \"@mantine/core\";\nimport { ModalsProvider, type ModalsProviderProps } from \"@mantine/modals\";\nimport { Notifications, type NotificationsProps } from \"@mantine/notifications\";\nimport type { NavigationProgressProps } from \"@mantine/nprogress\";\nimport { NavigationProgress, nprogress } from \"@mantine/nprogress\";\nimport type { ReactNode } from \"react\";\nimport { useToast } from \"../../hooks/useToast.ts\";\nimport Omnibar, { type OmnibarProps } from \"./Omnibar.tsx\";\n\nexport interface AlephaMantineProviderProps {\n children?: ReactNode;\n mantine?: MantineProviderProps;\n colorSchemeScript?: ColorSchemeScriptProps;\n navigationProgress?: NavigationProgressProps;\n notifications?: NotificationsProps;\n modals?: ModalsProviderProps;\n omnibar?: OmnibarProps;\n}\n\nconst AlephaMantineProvider = (props: AlephaMantineProviderProps) => {\n const toast = useToast();\n\n useEvents(\n {\n \"react:transition:begin\": () => {\n nprogress.start();\n },\n \"react:transition:end\": () => {\n nprogress.complete();\n },\n \"react:action:error\": () => {\n toast.danger(\"An error occurred while processing your action.\");\n },\n },\n [],\n );\n\n return (\n <>\n <ColorSchemeScript\n defaultColorScheme={props.mantine?.defaultColorScheme}\n {...props.colorSchemeScript}\n />\n <MantineProvider\n {...props.mantine}\n theme={{\n primaryColor: \"gray\",\n primaryShade: {\n light: 9,\n dark: 8,\n },\n cursorType: \"pointer\",\n ...props.mantine?.theme,\n }}\n >\n <Notifications {...props.notifications} />\n <NavigationProgress {...props.navigationProgress} />\n <ModalsProvider {...props.modals}>\n <Omnibar {...props.omnibar} />\n {props.children ?? <NestedView />}\n </ModalsProvider>\n </MantineProvider>\n </>\n );\n};\n\nexport default AlephaMantineProvider;\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,eAAb,MAA0B;CACxB,AAAmB,MAAM;CAEzB,AAAgB,UAA+B,EAC7C,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,UAAU;EACX,EACF;CAED,AAAO,KAAK,SAA2B;AACrC,gBAAc,KAAK;GACjB,GAAG,KAAK,QAAQ;GAChB,GAAG;GACJ,CAAC;;CAGJ,AAAO,KAAK,SAA6C;AACvD,MAAI,OAAO,YAAY,SACrB,WAAU,EAAE,SAAS,SAAS;AAEhC,OAAK,KAAK;GACR,OAAO;GACP,MAAM,oBAAC,kBAAe,MAAM,KAAM;GAClC,OAAO;GACP,SAAS;GACT,GAAG;GACJ,CAAC;;CAGJ,AAAO,QAAQ,SAA6C;AAC1D,MAAI,OAAO,YAAY,SACrB,WAAU,EAAE,SAAS,SAAS;AAEhC,OAAK,KAAK;GACR,OAAO;GACP,MAAM,oBAAC,aAAU,MAAM,KAAM;GAC7B,OAAO;GACP,SAAS;GACT,GAAG;GACJ,CAAC;;CAGJ,AAAO,QAAQ,SAA6C;AAC1D,MAAI,OAAO,YAAY,SACrB,WAAU,EAAE,SAAS,SAAS;AAEhC,OAAK,KAAK;GACR,OAAO;GACP,MAAM,oBAAC,qBAAkB,MAAM,KAAM;GACrC,OAAO;GACP,SAAS;GACT,GAAG;GACJ,CAAC;;CAGJ,AAAO,OAAO,SAA6C;AACzD,MAAI,OAAO,YAAY,SACrB,WAAU,EAAE,SAAS,SAAS;AAEhC,OAAK,KAAK;GACR,OAAO;GACP,MAAM,oBAAC,SAAM,MAAM,KAAM;GACzB,OAAO;GACP,SAAS;GACT,GAAG;GACJ,CAAC;;;;;;;;;;;;;;;;ACnEN,MAAa,iBAA+B;AAC1C,QAAO,UAAU,aAAa;;;;;ACHhC,MAAM,WAAW,UAAwB;CACvC,MAAM,WAAW,MAAM,YAAY;CACnC,MAAM,oBAAoB,MAAM,qBAAqB;CACrD,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,SAAS,WAAW;AAa1B,QACE,oBAAC;EACC,SAdmC,cAEnC,OAAO,cAAc,KAAK,UAAU;GAClC,IAAI,KAAK;GACT,OAAO,KAAK,SAAS,KAAK;GAC1B,aAAa,KAAK;GAClB,eAAe,OAAO,GAAG,KAAK,QAAQ,KAAK,KAAK;GAChD,aAAa,KAAK;GACnB,EAAE,EACL,EAAE,CACH;EAKa;EACV,OAAO;EACP,aAAa;GACX,aAAa,oBAAC,cAAW,MAAM,KAAM;GACrC,aAAa;GACd;EACa;GACd;;AAIN,sBAAe;;;;AClBf,MAAM,yBAAyB,UAAsC;CACnE,MAAM,QAAQ,UAAU;AAExB,WACE;EACE,gCAAgC;AAC9B,aAAU,OAAO;;EAEnB,8BAA8B;AAC5B,aAAU,UAAU;;EAEtB,4BAA4B;AAC1B,SAAM,OAAO,kDAAkD;;EAElE,EACD,EAAE,CACH;AAED,QACE,4CACE,oBAAC;EACC,oBAAoB,MAAM,SAAS;EACnC,GAAI,MAAM;GACV,EACF,qBAAC;EACC,GAAI,MAAM;EACV,OAAO;GACL,cAAc;GACd,cAAc;IACZ,OAAO;IACP,MAAM;IACP;GACD,YAAY;GACZ,GAAG,MAAM,SAAS;GACnB;;GAED,oBAAC,iBAAc,GAAI,MAAM,gBAAiB;GAC1C,oBAAC,sBAAmB,GAAI,MAAM,qBAAsB;GACpD,qBAAC;IAAe,GAAI,MAAM;eACxB,oBAACA,mBAAQ,GAAI,MAAM,UAAW,EAC7B,MAAM,YAAY,oBAAC,eAAa;KAClB;;GACD,IACjB;;AAIP,oCAAe"}
|