@alepha/ui 0.11.7 → 0.11.10

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.
@@ -0,0 +1,3 @@
1
+ const require_AlephaMantineProvider = require('./AlephaMantineProvider-DlOEv9f0.cjs');
2
+
3
+ exports.default = require_AlephaMantineProvider.AlephaMantineProvider_default;
@@ -0,0 +1,173 @@
1
+ let __alepha_react = require("@alepha/react");
2
+ let __mantine_core = require("@mantine/core");
3
+ let __mantine_modals = require("@mantine/modals");
4
+ let __tabler_icons_react = require("@tabler/icons-react");
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let __mantine_notifications = require("@mantine/notifications");
8
+ let __mantine_spotlight = require("@mantine/spotlight");
9
+ let __mantine_nprogress = require("@mantine/nprogress");
10
+
11
+ //#region src/services/ToastService.tsx
12
+ var ToastService = class {
13
+ raw = __mantine_notifications.notifications;
14
+ options = { default: {
15
+ autoClose: 5e3,
16
+ withCloseButton: true,
17
+ position: "top-center"
18
+ } };
19
+ show(options) {
20
+ __mantine_notifications.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__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.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__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.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__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.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__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.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
+ * const toast = useToast();
74
+ * toast.success({ message: "Operation completed successfully!" });
75
+ * toast.error({ title: "Error", message: "Something went wrong" });
76
+ */
77
+ const useToast = () => {
78
+ return (0, __alepha_react.useInject)(ToastService);
79
+ };
80
+
81
+ //#endregion
82
+ //#region src/components/layout/Omnibar.tsx
83
+ const Omnibar = (props) => {
84
+ const shortcut = props.shortcut ?? "mod+K";
85
+ const searchPlaceholder = props.searchPlaceholder ?? "Search...";
86
+ const nothingFound = props.nothingFound ?? "Nothing found...";
87
+ const router = (0, __alepha_react.useRouter)();
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_spotlight.Spotlight, {
89
+ actions: (0, react.useMemo)(() => router.concretePages.map((page) => ({
90
+ id: page.name,
91
+ label: page.label ?? page.name,
92
+ description: page.description,
93
+ onClick: () => router.go(page.path ?? page.name),
94
+ leftSection: page.icon
95
+ })), []),
96
+ shortcut,
97
+ limit: 10,
98
+ searchProps: {
99
+ leftSection: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tabler_icons_react.IconSearch, { size: 20 }),
100
+ placeholder: searchPlaceholder
101
+ },
102
+ nothingFound
103
+ });
104
+ };
105
+ var Omnibar_default = Omnibar;
106
+
107
+ //#endregion
108
+ //#region src/components/layout/AlephaMantineProvider.tsx
109
+ const AlephaMantineProvider = (props) => {
110
+ const toast = useToast();
111
+ (0, __alepha_react.useEvents)({
112
+ "react:transition:begin": () => {
113
+ __mantine_nprogress.nprogress.start();
114
+ },
115
+ "react:transition:end": () => {
116
+ __mantine_nprogress.nprogress.complete();
117
+ },
118
+ "react:action:error": () => {
119
+ toast.danger("An error occurred while processing your action.");
120
+ }
121
+ }, []);
122
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_core.ColorSchemeScript, {
123
+ defaultColorScheme: props.mantine?.defaultColorScheme,
124
+ ...props.colorSchemeScript
125
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_core.MantineProvider, {
126
+ ...props.mantine,
127
+ theme: {
128
+ primaryColor: "gray",
129
+ primaryShade: {
130
+ light: 9,
131
+ dark: 8
132
+ },
133
+ cursorType: "pointer",
134
+ ...props.mantine?.theme
135
+ },
136
+ children: [
137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_notifications.Notifications, { ...props.notifications }),
138
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__mantine_nprogress.NavigationProgress, { ...props.navigationProgress }),
139
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__mantine_modals.ModalsProvider, {
140
+ ...props.modals,
141
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Omnibar_default, { ...props.omnibar }), props.children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alepha_react.NestedView, {})]
142
+ })
143
+ ]
144
+ })] });
145
+ };
146
+ var AlephaMantineProvider_default = AlephaMantineProvider;
147
+
148
+ //#endregion
149
+ Object.defineProperty(exports, 'AlephaMantineProvider_default', {
150
+ enumerable: true,
151
+ get: function () {
152
+ return AlephaMantineProvider_default;
153
+ }
154
+ });
155
+ Object.defineProperty(exports, 'Omnibar_default', {
156
+ enumerable: true,
157
+ get: function () {
158
+ return Omnibar_default;
159
+ }
160
+ });
161
+ Object.defineProperty(exports, 'ToastService', {
162
+ enumerable: true,
163
+ get: function () {
164
+ return ToastService;
165
+ }
166
+ });
167
+ Object.defineProperty(exports, 'useToast', {
168
+ enumerable: true,
169
+ get: function () {
170
+ return useToast;
171
+ }
172
+ });
173
+ //# sourceMappingURL=AlephaMantineProvider-DlOEv9f0.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlephaMantineProvider-DlOEv9f0.cjs","names":["notifications","IconInfoCircle","IconCheck","IconAlertTriangle","IconX","Spotlight","IconSearch","ColorSchemeScript","MantineProvider","Notifications","NavigationProgress","ModalsProvider","Omnibar","NestedView"],"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 * const toast = useToast();\n * toast.success({ message: \"Operation completed successfully!\" });\n * toast.error({ title: \"Error\", message: \"Something went wrong\" });\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,MAAMA;CAEzB,AAAgB,UAA+B,EAC7C,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,UAAU;EACX,EACF;CAED,AAAO,KAAK,SAA2B;AACrC,wCAAc,KAAK;GACjB,GAAG,KAAK,QAAQ;GAChB,GAAG;GACJ,CAAC;;CAGJ,AAAO,KAAK,SAA6C;AACvD,MAAI,OAAO,YAAY,SACrB,WAAU,EAAE,SAAS,SAAS;AAEhC,OAAK,K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