remoraid 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # License
2
+
3
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,412 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __toESM = (mod, isNodeMode, target) => {
9
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
10
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
+ for (let key of __getOwnPropNames(mod))
12
+ if (!__hasOwnProp.call(to, key))
13
+ __defProp(to, key, {
14
+ get: () => mod[key],
15
+ enumerable: true
16
+ });
17
+ return to;
18
+ };
19
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
20
+ var __toCommonJS = (from) => {
21
+ var entry = __moduleCache.get(from), desc;
22
+ if (entry)
23
+ return entry;
24
+ entry = __defProp({}, "__esModule", { value: true });
25
+ if (from && typeof from === "object" || typeof from === "function")
26
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
+ get: () => from[key],
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ }));
30
+ __moduleCache.set(from, entry);
31
+ return entry;
32
+ };
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true,
38
+ configurable: true,
39
+ set: (newValue) => all[name] = () => newValue
40
+ });
41
+ };
42
+
43
+ // src/index.ts
44
+ var exports_src = {};
45
+ __export(exports_src, {
46
+ useUserExperience: () => useUserExperience,
47
+ useUpdateUserExperience: () => useUpdateUserExperience,
48
+ defaultNavbarSettings: () => defaultNavbarSettings,
49
+ UserExperienceProvider: () => UserExperienceProvider,
50
+ AppShell: () => AppShell
51
+ });
52
+ module.exports = __toCommonJS(exports_src);
53
+
54
+ // src/components/AppShell/NavbarMinimal/index.tsx
55
+ var import_core2 = require("@mantine/core");
56
+ var import_icons_react = require("@tabler/icons-react");
57
+ var import_link = __toESM(require("next/link"));
58
+ var import_navigation = require("next/navigation");
59
+ var import_react = require("react");
60
+
61
+ // src/lib/utils.ts
62
+ var import_core = require("@mantine/core");
63
+ var co = (condition, value, fallback) => condition(value) ? value : fallback;
64
+ var isMantinePrimaryShade = (primaryShade) => {
65
+ if (isNaN(Number(primaryShade))) {
66
+ return true;
67
+ }
68
+ return false;
69
+ };
70
+ var getCustomStyles = (theme, colorScheme) => {
71
+ return {
72
+ transparentBackground: colorScheme === "dark" ? import_core.rgba(theme.colors.dark[8], 0.8) : import_core.rgba(theme.white, 0.8),
73
+ iconSize: "1.125em",
74
+ primaryColor: theme.colors[theme.primaryColor][isMantinePrimaryShade(theme.primaryShade) ? theme.primaryShade[colorScheme === "auto" ? "light" : colorScheme] : theme.primaryShade],
75
+ spacingPx: {
76
+ xs: Number(co((v) => !Number.isNaN(v), Number(import_core.px(theme.spacing.xs)), 0)),
77
+ sm: Number(co((v) => !Number.isNaN(v), Number(import_core.px(theme.spacing.sm)), 0)),
78
+ md: Number(co((v) => !Number.isNaN(v), Number(import_core.px(theme.spacing.md)), 0)),
79
+ lg: Number(co((v) => !Number.isNaN(v), Number(import_core.px(theme.spacing.lg)), 0)),
80
+ xl: Number(co((v) => !Number.isNaN(v), Number(import_core.px(theme.spacing.xl)), 0))
81
+ }
82
+ };
83
+ };
84
+
85
+ // src/components/AppShell/NavbarMinimal/index.tsx
86
+ var jsx_dev_runtime = require("react/jsx-dev-runtime");
87
+ function NavbarLink({
88
+ icon: Icon2,
89
+ label,
90
+ active,
91
+ onClick,
92
+ href,
93
+ indicator,
94
+ settings
95
+ }) {
96
+ const [isHoveringRoleIndicator, setIsHoveringRoleIndicator] = import_react.useState(false);
97
+ const iconProps = {
98
+ size: settings.iconSize,
99
+ stroke: 1.5
100
+ };
101
+ if (!href) {
102
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Tooltip, {
103
+ label,
104
+ position: "right",
105
+ transitionProps: { duration: 0 },
106
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.UnstyledButton, {
107
+ onClick,
108
+ className: "remoraid-navbar-minimal-link",
109
+ "data-active": active || undefined,
110
+ w: settings.linkSize,
111
+ h: settings.linkSize,
112
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Icon2, {
113
+ ...iconProps
114
+ }, undefined, false, undefined, this)
115
+ }, undefined, false, undefined, this)
116
+ }, undefined, false, undefined, this);
117
+ }
118
+ const button = /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.UnstyledButton, {
119
+ onClick,
120
+ className: "remoraid-navbar-minimal-link",
121
+ "data-active": active || undefined,
122
+ w: settings.linkSize,
123
+ h: settings.linkSize,
124
+ component: import_link.default,
125
+ href,
126
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Icon2, {
127
+ ...iconProps
128
+ }, undefined, false, undefined, this)
129
+ }, undefined, false, undefined, this);
130
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Tooltip, {
131
+ label,
132
+ position: "right",
133
+ transitionProps: { duration: 0 },
134
+ children: indicator === undefined ? button : /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Indicator, {
135
+ withBorder: true,
136
+ size: 13,
137
+ offset: 2,
138
+ onMouseEnter: () => setIsHoveringRoleIndicator(true),
139
+ onMouseLeave: () => setIsHoveringRoleIndicator(false),
140
+ ...indicator(isHoveringRoleIndicator),
141
+ children: button
142
+ }, undefined, false, undefined, this)
143
+ }, undefined, false, undefined, this);
144
+ }
145
+ var defaultSettings = {
146
+ hiddenPages: [],
147
+ linkSize: import_core2.rem("50px"),
148
+ iconSize: "50%",
149
+ px: "sm",
150
+ py: "md"
151
+ };
152
+ function NavbarMinimal({
153
+ logo,
154
+ pages,
155
+ user,
156
+ settings: settingsProp,
157
+ linkIndicator,
158
+ logoIndicator,
159
+ onLogout
160
+ }) {
161
+ const pathname = import_navigation.usePathname();
162
+ const theme = import_core2.useMantineTheme();
163
+ const { setColorScheme, colorScheme } = import_core2.useMantineColorScheme();
164
+ const { transparentBackground } = getCustomStyles(theme, colorScheme);
165
+ const [isHoveringRoleIndicator, setIsHoveringRoleIndicator] = import_react.useState(false);
166
+ const settings = settingsProp || defaultSettings;
167
+ const links = pages.filter((link) => !settings.hiddenPages.includes(link.href)).map((link) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(NavbarLink, {
168
+ active: link.href === pathname,
169
+ indicator: linkIndicator,
170
+ settings,
171
+ ...link
172
+ }, link.label, false, undefined, this));
173
+ const logoImage = logo({
174
+ style: {
175
+ cursor: "pointer",
176
+ width: settings.linkSize,
177
+ height: settings.linkSize
178
+ }
179
+ });
180
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Paper, {
181
+ h: "100%",
182
+ py: settings.py,
183
+ bg: transparentBackground,
184
+ radius: 0,
185
+ shadow: "md",
186
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Flex, {
187
+ direction: "column",
188
+ h: "100%",
189
+ align: "center",
190
+ px: settings.px,
191
+ children: [
192
+ logoIndicator === undefined ? logoImage : /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Indicator, {
193
+ withBorder: true,
194
+ offset: 2,
195
+ size: 13,
196
+ onMouseEnter: () => setIsHoveringRoleIndicator(true),
197
+ onMouseLeave: () => setIsHoveringRoleIndicator(false),
198
+ ...logoIndicator(isHoveringRoleIndicator),
199
+ children: logoImage
200
+ }, undefined, false, undefined, this),
201
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Divider, {
202
+ my: "md",
203
+ variant: "dashed",
204
+ w: "100%"
205
+ }, undefined, false, undefined, this),
206
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Stack, {
207
+ justify: "flex-start",
208
+ gap: 0,
209
+ flex: 1,
210
+ children: links
211
+ }, undefined, false, undefined, this),
212
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(import_core2.Stack, {
213
+ justify: "center",
214
+ gap: 0,
215
+ children: [
216
+ user !== undefined && (user === null ? /* @__PURE__ */ jsx_dev_runtime.jsxDEV(NavbarLink, {
217
+ icon: import_icons_react.IconLogin,
218
+ label: "Login",
219
+ href: "/login",
220
+ active: pathname === "/login",
221
+ settings
222
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime.jsxDEV(NavbarLink, {
223
+ icon: import_icons_react.IconLogout,
224
+ label: "Logout",
225
+ onClick: () => {
226
+ if (onLogout) {
227
+ onLogout();
228
+ }
229
+ },
230
+ href: "/login",
231
+ settings
232
+ }, undefined, false, undefined, this)),
233
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(NavbarLink, {
234
+ icon: colorScheme === "dark" ? import_icons_react.IconSun : import_icons_react.IconMoon,
235
+ onClick: () => {
236
+ if (colorScheme === "dark") {
237
+ setColorScheme("light");
238
+ } else {
239
+ setColorScheme("dark");
240
+ }
241
+ },
242
+ label: "Toggle Color Scheme",
243
+ settings
244
+ }, undefined, false, undefined, this)
245
+ ]
246
+ }, undefined, true, undefined, this)
247
+ ]
248
+ }, undefined, true, undefined, this)
249
+ }, undefined, false, undefined, this);
250
+ }
251
+
252
+ // src/lib/navbar-utils.ts
253
+ var defaultNavbarVariant = "minimal";
254
+ var defaultNavbarSettings = {
255
+ minimal: defaultSettings
256
+ };
257
+
258
+ // src/components/UserExperienceProvider/index.tsx
259
+ var import_react2 = __toESM(require("react"));
260
+ var import_react_cookie = require("react-cookie");
261
+ var jsx_dev_runtime2 = require("react/jsx-dev-runtime");
262
+ var defaultUserExperience = {
263
+ navbarVariant: defaultNavbarVariant,
264
+ navbarSettings: defaultNavbarSettings[defaultNavbarVariant],
265
+ showWelcomeMessage: true
266
+ };
267
+ var userExperienceContext = import_react2.default.createContext(defaultUserExperience);
268
+ var updateUserExperienceContext = import_react2.default.createContext(null);
269
+ var useUserExperience = () => {
270
+ return import_react2.useContext(userExperienceContext);
271
+ };
272
+ var useUpdateUserExperience = () => {
273
+ return import_react2.useContext(updateUserExperienceContext);
274
+ };
275
+ function UserExperienceProvider({
276
+ children
277
+ }) {
278
+ const [cookies, setCookie] = import_react_cookie.useCookies();
279
+ const isUserExperience = (x) => {
280
+ if (typeof x !== "object") {
281
+ return false;
282
+ }
283
+ if (!("showWelcomeMessage" in x)) {
284
+ return false;
285
+ }
286
+ if (!("navbarVariant" in x)) {
287
+ return false;
288
+ }
289
+ if (!("navbarSettings" in x)) {
290
+ return false;
291
+ }
292
+ if (typeof x.navbarSettings !== "object") {
293
+ return false;
294
+ }
295
+ if (!("hiddenPages" in x.navbarSettings)) {
296
+ return false;
297
+ }
298
+ if (!("linkSize" in x.navbarSettings)) {
299
+ return false;
300
+ }
301
+ if (!("px" in x.navbarSettings)) {
302
+ return false;
303
+ }
304
+ if (!("py" in x.navbarSettings)) {
305
+ return false;
306
+ }
307
+ return true;
308
+ };
309
+ const userExperience = cookies["userExperience"] && isUserExperience(cookies["userExperience"]) ? cookies["userExperience"] : defaultUserExperience;
310
+ const updateUserExperience = (p) => {
311
+ if (typeof p === "function") {
312
+ setCookie("userExperience", p(userExperience), { path: "/" });
313
+ return;
314
+ }
315
+ setCookie("userExperience", p, { path: "/" });
316
+ };
317
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(updateUserExperienceContext.Provider, {
318
+ value: updateUserExperience,
319
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(userExperienceContext.Provider, {
320
+ value: userExperience,
321
+ children
322
+ }, undefined, false, undefined, this)
323
+ }, undefined, false, undefined, this);
324
+ }
325
+ // src/components/AppShell/index.tsx
326
+ var import_core4 = require("@mantine/core");
327
+ var import_hooks = require("@mantine/hooks");
328
+
329
+ // src/components/AppShell/Footer/index.tsx
330
+ var import_core3 = require("@mantine/core");
331
+ var import_icons_react2 = require("@tabler/icons-react");
332
+ var jsx_dev_runtime3 = require("react/jsx-dev-runtime");
333
+ function Footer() {
334
+ const theme = import_core3.useMantineTheme();
335
+ const { colorScheme } = import_core3.useMantineColorScheme();
336
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_core3.Group, {
337
+ justify: "center",
338
+ w: "100%",
339
+ py: "md",
340
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(import_icons_react2.IconPennant, {
341
+ size: 50,
342
+ color: colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[3]
343
+ }, undefined, false, undefined, this)
344
+ }, undefined, false, undefined, this);
345
+ }
346
+
347
+ // src/components/AppShell/index.tsx
348
+ var jsx_dev_runtime4 = require("react/jsx-dev-runtime");
349
+ function AppShell({
350
+ children,
351
+ logo,
352
+ pages,
353
+ navbar,
354
+ user
355
+ }) {
356
+ const theme = import_core4.useMantineTheme();
357
+ const { colorScheme } = import_core4.useMantineColorScheme();
358
+ const { spacingPx } = getCustomStyles(theme, colorScheme);
359
+ const [opened, { toggle }] = import_hooks.useDisclosure();
360
+ const navbarVariant = navbar && navbar.variant ? navbar.variant : defaultNavbarVariant;
361
+ const navbarSettings = navbar && navbar.settings ? navbar.settings : defaultNavbarSettings[defaultNavbarVariant];
362
+ const navbarLinkSizePx = co((v) => !Number.isNaN(v), Number(import_core4.px(navbarSettings.linkSize)), 0);
363
+ const navbarPaddingPx = typeof navbarSettings.px === "number" ? navbarSettings.px : spacingPx[navbarSettings.px];
364
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.AppShell, {
365
+ header: { height: 0 },
366
+ navbar: {
367
+ width: import_core4.rem(`${navbarLinkSizePx + 2 * navbarPaddingPx}px`),
368
+ breakpoint: "sm",
369
+ collapsed: { mobile: !opened }
370
+ },
371
+ bg: colorScheme === "dark" ? theme.colors.dark[9] : theme.colors.gray[0],
372
+ children: [
373
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.AppShell.Header, {
374
+ withBorder: false,
375
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.Group, {
376
+ p: "md",
377
+ bg: colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[3],
378
+ hiddenFrom: "sm",
379
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.Burger, {
380
+ opened,
381
+ onClick: toggle,
382
+ h: 20,
383
+ size: 18
384
+ }, undefined, false, undefined, this)
385
+ }, undefined, false, undefined, this)
386
+ }, undefined, false, undefined, this),
387
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.AppShell.Navbar, {
388
+ withBorder: false,
389
+ children: navbarVariant === "minimal" && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(NavbarMinimal, {
390
+ logo,
391
+ pages,
392
+ user,
393
+ ...navbar
394
+ }, undefined, false, undefined, this)
395
+ }, undefined, false, undefined, this),
396
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.AppShell.Main, {
397
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(jsx_dev_runtime4.Fragment, {
398
+ children: [
399
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(import_core4.Paper, {
400
+ radius: 0,
401
+ my: "md",
402
+ h: 20,
403
+ hiddenFrom: "sm"
404
+ }, undefined, false, undefined, this),
405
+ children,
406
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Footer, {}, undefined, false, undefined, this)
407
+ ]
408
+ }, undefined, true, undefined, this)
409
+ }, undefined, false, undefined, this)
410
+ ]
411
+ }, undefined, true, undefined, this);
412
+ }
@@ -0,0 +1,51 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { IndicatorProps, MantineSize } from '@mantine/core';
4
+ import { Icon } from '@tabler/icons-react';
5
+ import { ImageProps } from 'next/image';
6
+ import React$1 from 'react';
7
+ import { PropsWithChildren, ReactNode } from 'react';
8
+
9
+ export interface Page {
10
+ icon: Icon;
11
+ label: string;
12
+ href: string;
13
+ }
14
+ export type NavbarVariant = "minimal";
15
+ export interface NavbarSettings {
16
+ hiddenPages: string[];
17
+ linkSize: string;
18
+ px: MantineSize | number;
19
+ py: MantineSize | number;
20
+ iconSize?: string | number;
21
+ }
22
+ export interface UserExperience {
23
+ navbarVariant: NavbarVariant;
24
+ navbarSettings: NavbarSettings;
25
+ showWelcomeMessage: boolean;
26
+ }
27
+ export type AppShellLogo = (props: Omit<ImageProps, "src" | "alt">) => React$1.ReactNode;
28
+ export interface NavbarProps {
29
+ settings?: NavbarSettings;
30
+ variant?: NavbarVariant;
31
+ linkIndicator?: (isHovering: boolean) => IndicatorProps;
32
+ logoIndicator?: (isHovering: boolean) => IndicatorProps;
33
+ onLogout?: () => void;
34
+ }
35
+ export declare const useUserExperience: () => UserExperience;
36
+ export declare const useUpdateUserExperience: () => ((p: UserExperience | ((prev: UserExperience) => UserExperience)) => void) | null;
37
+ export function UserExperienceProvider({ children, }: React$1.PropsWithChildren): React$1.JSX.Element;
38
+ export interface AppShellProps {
39
+ logo: AppShellLogo;
40
+ pages: Page[];
41
+ navbar?: NavbarProps;
42
+ user?: {
43
+ name: string;
44
+ } | null;
45
+ }
46
+ export function AppShell({ children, logo, pages, navbar, user, }: React$1.PropsWithChildren<AppShellProps>): import("react").React$1.JSX.Element;
47
+ export declare const defaultNavbarSettings: {
48
+ [V in NavbarVariant]: NavbarSettings;
49
+ };
50
+
51
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,395 @@
1
+ "use client";
2
+ // src/components/AppShell/NavbarMinimal/index.tsx
3
+ import {
4
+ Tooltip,
5
+ UnstyledButton,
6
+ Stack,
7
+ rem,
8
+ useMantineColorScheme,
9
+ Flex,
10
+ Paper,
11
+ useMantineTheme,
12
+ Divider,
13
+ Indicator
14
+ } from "@mantine/core";
15
+ import {
16
+ IconLogin,
17
+ IconLogout,
18
+ IconMoon,
19
+ IconSun
20
+ } from "@tabler/icons-react";
21
+ import Link from "next/link";
22
+ import { usePathname } from "next/navigation";
23
+ import { useState } from "react";
24
+
25
+ // src/lib/utils.ts
26
+ import {
27
+ px,
28
+ rgba
29
+ } from "@mantine/core";
30
+ var co = (condition, value, fallback) => condition(value) ? value : fallback;
31
+ var isMantinePrimaryShade = (primaryShade) => {
32
+ if (isNaN(Number(primaryShade))) {
33
+ return true;
34
+ }
35
+ return false;
36
+ };
37
+ var getCustomStyles = (theme, colorScheme) => {
38
+ return {
39
+ transparentBackground: colorScheme === "dark" ? rgba(theme.colors.dark[8], 0.8) : rgba(theme.white, 0.8),
40
+ iconSize: "1.125em",
41
+ primaryColor: theme.colors[theme.primaryColor][isMantinePrimaryShade(theme.primaryShade) ? theme.primaryShade[colorScheme === "auto" ? "light" : colorScheme] : theme.primaryShade],
42
+ spacingPx: {
43
+ xs: Number(co((v) => !Number.isNaN(v), Number(px(theme.spacing.xs)), 0)),
44
+ sm: Number(co((v) => !Number.isNaN(v), Number(px(theme.spacing.sm)), 0)),
45
+ md: Number(co((v) => !Number.isNaN(v), Number(px(theme.spacing.md)), 0)),
46
+ lg: Number(co((v) => !Number.isNaN(v), Number(px(theme.spacing.lg)), 0)),
47
+ xl: Number(co((v) => !Number.isNaN(v), Number(px(theme.spacing.xl)), 0))
48
+ }
49
+ };
50
+ };
51
+
52
+ // src/components/AppShell/NavbarMinimal/index.tsx
53
+ import { jsxDEV } from "react/jsx-dev-runtime";
54
+ function NavbarLink({
55
+ icon: Icon2,
56
+ label,
57
+ active,
58
+ onClick,
59
+ href,
60
+ indicator,
61
+ settings
62
+ }) {
63
+ const [isHoveringRoleIndicator, setIsHoveringRoleIndicator] = useState(false);
64
+ const iconProps = {
65
+ size: settings.iconSize,
66
+ stroke: 1.5
67
+ };
68
+ if (!href) {
69
+ return /* @__PURE__ */ jsxDEV(Tooltip, {
70
+ label,
71
+ position: "right",
72
+ transitionProps: { duration: 0 },
73
+ children: /* @__PURE__ */ jsxDEV(UnstyledButton, {
74
+ onClick,
75
+ className: "remoraid-navbar-minimal-link",
76
+ "data-active": active || undefined,
77
+ w: settings.linkSize,
78
+ h: settings.linkSize,
79
+ children: /* @__PURE__ */ jsxDEV(Icon2, {
80
+ ...iconProps
81
+ }, undefined, false, undefined, this)
82
+ }, undefined, false, undefined, this)
83
+ }, undefined, false, undefined, this);
84
+ }
85
+ const button = /* @__PURE__ */ jsxDEV(UnstyledButton, {
86
+ onClick,
87
+ className: "remoraid-navbar-minimal-link",
88
+ "data-active": active || undefined,
89
+ w: settings.linkSize,
90
+ h: settings.linkSize,
91
+ component: Link,
92
+ href,
93
+ children: /* @__PURE__ */ jsxDEV(Icon2, {
94
+ ...iconProps
95
+ }, undefined, false, undefined, this)
96
+ }, undefined, false, undefined, this);
97
+ return /* @__PURE__ */ jsxDEV(Tooltip, {
98
+ label,
99
+ position: "right",
100
+ transitionProps: { duration: 0 },
101
+ children: indicator === undefined ? button : /* @__PURE__ */ jsxDEV(Indicator, {
102
+ withBorder: true,
103
+ size: 13,
104
+ offset: 2,
105
+ onMouseEnter: () => setIsHoveringRoleIndicator(true),
106
+ onMouseLeave: () => setIsHoveringRoleIndicator(false),
107
+ ...indicator(isHoveringRoleIndicator),
108
+ children: button
109
+ }, undefined, false, undefined, this)
110
+ }, undefined, false, undefined, this);
111
+ }
112
+ var defaultSettings = {
113
+ hiddenPages: [],
114
+ linkSize: rem("50px"),
115
+ iconSize: "50%",
116
+ px: "sm",
117
+ py: "md"
118
+ };
119
+ function NavbarMinimal({
120
+ logo,
121
+ pages,
122
+ user,
123
+ settings: settingsProp,
124
+ linkIndicator,
125
+ logoIndicator,
126
+ onLogout
127
+ }) {
128
+ const pathname = usePathname();
129
+ const theme = useMantineTheme();
130
+ const { setColorScheme, colorScheme } = useMantineColorScheme();
131
+ const { transparentBackground } = getCustomStyles(theme, colorScheme);
132
+ const [isHoveringRoleIndicator, setIsHoveringRoleIndicator] = useState(false);
133
+ const settings = settingsProp || defaultSettings;
134
+ const links = pages.filter((link) => !settings.hiddenPages.includes(link.href)).map((link) => /* @__PURE__ */ jsxDEV(NavbarLink, {
135
+ active: link.href === pathname,
136
+ indicator: linkIndicator,
137
+ settings,
138
+ ...link
139
+ }, link.label, false, undefined, this));
140
+ const logoImage = logo({
141
+ style: {
142
+ cursor: "pointer",
143
+ width: settings.linkSize,
144
+ height: settings.linkSize
145
+ }
146
+ });
147
+ return /* @__PURE__ */ jsxDEV(Paper, {
148
+ h: "100%",
149
+ py: settings.py,
150
+ bg: transparentBackground,
151
+ radius: 0,
152
+ shadow: "md",
153
+ children: /* @__PURE__ */ jsxDEV(Flex, {
154
+ direction: "column",
155
+ h: "100%",
156
+ align: "center",
157
+ px: settings.px,
158
+ children: [
159
+ logoIndicator === undefined ? logoImage : /* @__PURE__ */ jsxDEV(Indicator, {
160
+ withBorder: true,
161
+ offset: 2,
162
+ size: 13,
163
+ onMouseEnter: () => setIsHoveringRoleIndicator(true),
164
+ onMouseLeave: () => setIsHoveringRoleIndicator(false),
165
+ ...logoIndicator(isHoveringRoleIndicator),
166
+ children: logoImage
167
+ }, undefined, false, undefined, this),
168
+ /* @__PURE__ */ jsxDEV(Divider, {
169
+ my: "md",
170
+ variant: "dashed",
171
+ w: "100%"
172
+ }, undefined, false, undefined, this),
173
+ /* @__PURE__ */ jsxDEV(Stack, {
174
+ justify: "flex-start",
175
+ gap: 0,
176
+ flex: 1,
177
+ children: links
178
+ }, undefined, false, undefined, this),
179
+ /* @__PURE__ */ jsxDEV(Stack, {
180
+ justify: "center",
181
+ gap: 0,
182
+ children: [
183
+ user !== undefined && (user === null ? /* @__PURE__ */ jsxDEV(NavbarLink, {
184
+ icon: IconLogin,
185
+ label: "Login",
186
+ href: "/login",
187
+ active: pathname === "/login",
188
+ settings
189
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(NavbarLink, {
190
+ icon: IconLogout,
191
+ label: "Logout",
192
+ onClick: () => {
193
+ if (onLogout) {
194
+ onLogout();
195
+ }
196
+ },
197
+ href: "/login",
198
+ settings
199
+ }, undefined, false, undefined, this)),
200
+ /* @__PURE__ */ jsxDEV(NavbarLink, {
201
+ icon: colorScheme === "dark" ? IconSun : IconMoon,
202
+ onClick: () => {
203
+ if (colorScheme === "dark") {
204
+ setColorScheme("light");
205
+ } else {
206
+ setColorScheme("dark");
207
+ }
208
+ },
209
+ label: "Toggle Color Scheme",
210
+ settings
211
+ }, undefined, false, undefined, this)
212
+ ]
213
+ }, undefined, true, undefined, this)
214
+ ]
215
+ }, undefined, true, undefined, this)
216
+ }, undefined, false, undefined, this);
217
+ }
218
+
219
+ // src/lib/navbar-utils.ts
220
+ var defaultNavbarVariant = "minimal";
221
+ var defaultNavbarSettings = {
222
+ minimal: defaultSettings
223
+ };
224
+
225
+ // src/components/UserExperienceProvider/index.tsx
226
+ import React, { useContext } from "react";
227
+ import { useCookies } from "react-cookie";
228
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
229
+ var defaultUserExperience = {
230
+ navbarVariant: defaultNavbarVariant,
231
+ navbarSettings: defaultNavbarSettings[defaultNavbarVariant],
232
+ showWelcomeMessage: true
233
+ };
234
+ var userExperienceContext = React.createContext(defaultUserExperience);
235
+ var updateUserExperienceContext = React.createContext(null);
236
+ var useUserExperience = () => {
237
+ return useContext(userExperienceContext);
238
+ };
239
+ var useUpdateUserExperience = () => {
240
+ return useContext(updateUserExperienceContext);
241
+ };
242
+ function UserExperienceProvider({
243
+ children
244
+ }) {
245
+ const [cookies, setCookie] = useCookies();
246
+ const isUserExperience = (x) => {
247
+ if (typeof x !== "object") {
248
+ return false;
249
+ }
250
+ if (!("showWelcomeMessage" in x)) {
251
+ return false;
252
+ }
253
+ if (!("navbarVariant" in x)) {
254
+ return false;
255
+ }
256
+ if (!("navbarSettings" in x)) {
257
+ return false;
258
+ }
259
+ if (typeof x.navbarSettings !== "object") {
260
+ return false;
261
+ }
262
+ if (!("hiddenPages" in x.navbarSettings)) {
263
+ return false;
264
+ }
265
+ if (!("linkSize" in x.navbarSettings)) {
266
+ return false;
267
+ }
268
+ if (!("px" in x.navbarSettings)) {
269
+ return false;
270
+ }
271
+ if (!("py" in x.navbarSettings)) {
272
+ return false;
273
+ }
274
+ return true;
275
+ };
276
+ const userExperience = cookies["userExperience"] && isUserExperience(cookies["userExperience"]) ? cookies["userExperience"] : defaultUserExperience;
277
+ const updateUserExperience = (p) => {
278
+ if (typeof p === "function") {
279
+ setCookie("userExperience", p(userExperience), { path: "/" });
280
+ return;
281
+ }
282
+ setCookie("userExperience", p, { path: "/" });
283
+ };
284
+ return /* @__PURE__ */ jsxDEV2(updateUserExperienceContext.Provider, {
285
+ value: updateUserExperience,
286
+ children: /* @__PURE__ */ jsxDEV2(userExperienceContext.Provider, {
287
+ value: userExperience,
288
+ children
289
+ }, undefined, false, undefined, this)
290
+ }, undefined, false, undefined, this);
291
+ }
292
+ // src/components/AppShell/index.tsx
293
+ import {
294
+ AppShell as MantineAppShell,
295
+ Burger,
296
+ rem as rem2,
297
+ Group as Group2,
298
+ useMantineTheme as useMantineTheme3,
299
+ useMantineColorScheme as useMantineColorScheme3,
300
+ Paper as Paper2,
301
+ px as px2
302
+ } from "@mantine/core";
303
+ import { useDisclosure } from "@mantine/hooks";
304
+
305
+ // src/components/AppShell/Footer/index.tsx
306
+ import { Group, useMantineColorScheme as useMantineColorScheme2, useMantineTheme as useMantineTheme2 } from "@mantine/core";
307
+ import { IconPennant } from "@tabler/icons-react";
308
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
309
+ function Footer() {
310
+ const theme = useMantineTheme2();
311
+ const { colorScheme } = useMantineColorScheme2();
312
+ return /* @__PURE__ */ jsxDEV3(Group, {
313
+ justify: "center",
314
+ w: "100%",
315
+ py: "md",
316
+ children: /* @__PURE__ */ jsxDEV3(IconPennant, {
317
+ size: 50,
318
+ color: colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[3]
319
+ }, undefined, false, undefined, this)
320
+ }, undefined, false, undefined, this);
321
+ }
322
+
323
+ // src/components/AppShell/index.tsx
324
+ import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
325
+ function AppShell({
326
+ children,
327
+ logo,
328
+ pages,
329
+ navbar,
330
+ user
331
+ }) {
332
+ const theme = useMantineTheme3();
333
+ const { colorScheme } = useMantineColorScheme3();
334
+ const { spacingPx } = getCustomStyles(theme, colorScheme);
335
+ const [opened, { toggle }] = useDisclosure();
336
+ const navbarVariant = navbar && navbar.variant ? navbar.variant : defaultNavbarVariant;
337
+ const navbarSettings = navbar && navbar.settings ? navbar.settings : defaultNavbarSettings[defaultNavbarVariant];
338
+ const navbarLinkSizePx = co((v) => !Number.isNaN(v), Number(px2(navbarSettings.linkSize)), 0);
339
+ const navbarPaddingPx = typeof navbarSettings.px === "number" ? navbarSettings.px : spacingPx[navbarSettings.px];
340
+ return /* @__PURE__ */ jsxDEV4(MantineAppShell, {
341
+ header: { height: 0 },
342
+ navbar: {
343
+ width: rem2(`${navbarLinkSizePx + 2 * navbarPaddingPx}px`),
344
+ breakpoint: "sm",
345
+ collapsed: { mobile: !opened }
346
+ },
347
+ bg: colorScheme === "dark" ? theme.colors.dark[9] : theme.colors.gray[0],
348
+ children: [
349
+ /* @__PURE__ */ jsxDEV4(MantineAppShell.Header, {
350
+ withBorder: false,
351
+ children: /* @__PURE__ */ jsxDEV4(Group2, {
352
+ p: "md",
353
+ bg: colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[3],
354
+ hiddenFrom: "sm",
355
+ children: /* @__PURE__ */ jsxDEV4(Burger, {
356
+ opened,
357
+ onClick: toggle,
358
+ h: 20,
359
+ size: 18
360
+ }, undefined, false, undefined, this)
361
+ }, undefined, false, undefined, this)
362
+ }, undefined, false, undefined, this),
363
+ /* @__PURE__ */ jsxDEV4(MantineAppShell.Navbar, {
364
+ withBorder: false,
365
+ children: navbarVariant === "minimal" && /* @__PURE__ */ jsxDEV4(NavbarMinimal, {
366
+ logo,
367
+ pages,
368
+ user,
369
+ ...navbar
370
+ }, undefined, false, undefined, this)
371
+ }, undefined, false, undefined, this),
372
+ /* @__PURE__ */ jsxDEV4(MantineAppShell.Main, {
373
+ children: /* @__PURE__ */ jsxDEV4(Fragment, {
374
+ children: [
375
+ /* @__PURE__ */ jsxDEV4(Paper2, {
376
+ radius: 0,
377
+ my: "md",
378
+ h: 20,
379
+ hiddenFrom: "sm"
380
+ }, undefined, false, undefined, this),
381
+ children,
382
+ /* @__PURE__ */ jsxDEV4(Footer, {}, undefined, false, undefined, this)
383
+ ]
384
+ }, undefined, true, undefined, this)
385
+ }, undefined, false, undefined, this)
386
+ ]
387
+ }, undefined, true, undefined, this);
388
+ }
389
+ export {
390
+ useUserExperience,
391
+ useUpdateUserExperience,
392
+ defaultNavbarSettings,
393
+ UserExperienceProvider,
394
+ AppShell
395
+ };
package/dist/ssc.cjs ADDED
@@ -0,0 +1,70 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+
29
+ // src/ssc.ts
30
+ var exports_ssc = {};
31
+ __export(exports_ssc, {
32
+ EnvironmentShell: () => EnvironmentShell
33
+ });
34
+ module.exports = __toCommonJS(exports_ssc);
35
+
36
+ // src/components/EnvironmentShell/index.tsx
37
+ var jsx_dev_runtime = require("react/jsx-dev-runtime");
38
+ function EnvironmentShell({
39
+ children,
40
+ vars
41
+ }) {
42
+ const missingVars = vars.filter((v) => !process.env[v]);
43
+ if (missingVars.length !== 0) {
44
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV("div", {
45
+ style: { padding: 5 },
46
+ children: [
47
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV("h1", {
48
+ style: { fontWeight: 700 },
49
+ children: [
50
+ "Environment variable",
51
+ missingVars.length > 1 ? "s" : "",
52
+ " missing:"
53
+ ]
54
+ }, undefined, true, undefined, this),
55
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV("ul", {
56
+ style: { margin: 5 },
57
+ children: missingVars.map((v, i) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV("li", {
58
+ children: v
59
+ }, i, false, undefined, this))
60
+ }, undefined, false, undefined, this),
61
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV("p", {
62
+ children: "Please specify in your '.env' file. See README for details."
63
+ }, undefined, false, undefined, this)
64
+ ]
65
+ }, undefined, true, undefined, this);
66
+ }
67
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(jsx_dev_runtime.Fragment, {
68
+ children
69
+ }, undefined, false, undefined, this);
70
+ }
package/dist/ssc.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { PropsWithChildren } from 'react';
4
+
5
+ export interface EnvironmentShellProps {
6
+ vars: string[];
7
+ }
8
+ export function EnvironmentShell({ children, vars, }: PropsWithChildren<EnvironmentShellProps>): import("react").JSX.Element;
9
+
10
+ export {};
package/dist/ssc.js ADDED
@@ -0,0 +1,38 @@
1
+ // src/components/EnvironmentShell/index.tsx
2
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
3
+ function EnvironmentShell({
4
+ children,
5
+ vars
6
+ }) {
7
+ const missingVars = vars.filter((v) => !process.env[v]);
8
+ if (missingVars.length !== 0) {
9
+ return /* @__PURE__ */ jsxDEV("div", {
10
+ style: { padding: 5 },
11
+ children: [
12
+ /* @__PURE__ */ jsxDEV("h1", {
13
+ style: { fontWeight: 700 },
14
+ children: [
15
+ "Environment variable",
16
+ missingVars.length > 1 ? "s" : "",
17
+ " missing:"
18
+ ]
19
+ }, undefined, true, undefined, this),
20
+ /* @__PURE__ */ jsxDEV("ul", {
21
+ style: { margin: 5 },
22
+ children: missingVars.map((v, i) => /* @__PURE__ */ jsxDEV("li", {
23
+ children: v
24
+ }, i, false, undefined, this))
25
+ }, undefined, false, undefined, this),
26
+ /* @__PURE__ */ jsxDEV("p", {
27
+ children: "Please specify in your '.env' file. See README for details."
28
+ }, undefined, false, undefined, this)
29
+ ]
30
+ }, undefined, true, undefined, this);
31
+ }
32
+ return /* @__PURE__ */ jsxDEV(Fragment, {
33
+ children
34
+ }, undefined, false, undefined, this);
35
+ }
36
+ export {
37
+ EnvironmentShell
38
+ };
@@ -0,0 +1,22 @@
1
+ .remoraid-navbar-minimal-link {
2
+ border-radius: var(--mantine-radius-md);
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-0));
7
+
8
+ &:hover {
9
+ background-color: light-dark(
10
+ var(--mantine-color-gray-0),
11
+ var(--mantine-color-dark-5)
12
+ );
13
+ }
14
+
15
+ &[data-active] {
16
+ &,
17
+ &:hover {
18
+ background-color: var(--mantine-color-blue-light);
19
+ color: var(--mantine-color-blue-light-color);
20
+ }
21
+ }
22
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "remoraid",
3
+ "version": "1.1.0",
4
+ "author": "Konrad Goldammer",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/konradag/remoraid.git"
8
+ },
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "devDependencies": {
12
+ "@types/bun": "^1.1.10",
13
+ "@types/css-modules": "^1.0.5",
14
+ "@types/react": "^19.1.2",
15
+ "bun-plugin-dts": "^0.3.0",
16
+ "next": "^15.3.1",
17
+ "react": "^19.1.0",
18
+ "react-cookie": "^8.0.1"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^19.1.0",
22
+ "react-dom": "^19.1.0",
23
+ "react-cookie": "^8.0.1",
24
+ "next": "^15.3.1",
25
+ "@mantine/core": "^7.17.4",
26
+ "@mantine/hooks": "^7.17.4",
27
+ "@tabler/icons-react": "^3.31.0"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": "./dist/index.cjs"
34
+ },
35
+ "./ssc": {
36
+ "types": "./dist/ssc.d.ts",
37
+ "import": "./dist/ssc.js",
38
+ "require": "./dist/ssc.cjs"
39
+ },
40
+ "./styles": "./dist/styles.css"
41
+ },
42
+ "bugs": "https://github.com/konradag/remoraid/issues",
43
+ "description": "A React components library built on top of Mantine",
44
+ "files": [
45
+ "dist"
46
+ ],
47
+ "keywords": [
48
+ "bun",
49
+ "react",
50
+ "mantine"
51
+ ],
52
+ "license": "MIT",
53
+ "scripts": {
54
+ "build": "bun run build.ts",
55
+ "prepublishOnly": "bun run build"
56
+ },
57
+ "type": "module",
58
+ "types": "./dist/index.d.ts"
59
+ }