@eutobias/serenojs 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +682 -2
- package/admin-dist/assets/index-B3EgqtT6.js +9 -0
- package/admin-dist/assets/index-D2m0Eb4k.css +2 -0
- package/admin-dist/index.html +17 -0
- package/dist/auth/auth.server.d.ts +31 -0
- package/dist/auth/auth.server.js +141 -0
- package/dist/auth/config.d.ts +32 -0
- package/dist/auth/config.js +25 -0
- package/dist/auth/cookies.server.d.ts +7 -0
- package/dist/auth/cookies.server.js +65 -0
- package/dist/auth/http.server.d.ts +8 -0
- package/dist/auth/http.server.js +30 -0
- package/dist/auth/password.server.d.ts +2 -0
- package/dist/auth/password.server.js +21 -0
- package/dist/auth/session.server.d.ts +2 -0
- package/dist/auth/session.server.js +14 -0
- package/dist/auth/users.server.d.ts +16 -0
- package/dist/auth/users.server.js +123 -0
- package/dist/config.d.ts +91 -0
- package/dist/config.js +39 -0
- package/dist/core/backup.server.d.ts +52 -0
- package/dist/core/backup.server.js +349 -0
- package/dist/core/db.server.d.ts +24 -0
- package/dist/core/db.server.js +526 -0
- package/dist/core/media.d.ts +22 -0
- package/dist/core/media.js +76 -0
- package/dist/core/media.server.d.ts +18 -0
- package/dist/core/media.server.js +102 -0
- package/dist/core/schema.d.ts +26 -0
- package/dist/core/schema.js +99 -0
- package/dist/core/types.d.ts +143 -0
- package/dist/core/types.js +1 -0
- package/dist/core/validation.d.ts +16 -0
- package/dist/core/validation.js +192 -0
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +14 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.js +37 -0
- package/dist/server/app.d.ts +20 -0
- package/dist/server/app.js +661 -0
- package/dist/ui/admin/admin-shell.d.ts +16 -0
- package/dist/ui/admin/admin-shell.js +38 -0
- package/dist/ui/admin/backup-manager.d.ts +5 -0
- package/dist/ui/admin/backup-manager.js +165 -0
- package/dist/ui/admin/collection-icon.d.ts +22 -0
- package/dist/ui/admin/collection-icon.js +34 -0
- package/dist/ui/admin/collection-manager.d.ts +7 -0
- package/dist/ui/admin/collection-manager.js +212 -0
- package/dist/ui/admin/display.d.ts +7 -0
- package/dist/ui/admin/display.js +65 -0
- package/dist/ui/admin/field-control.d.ts +14 -0
- package/dist/ui/admin/field-control.js +58 -0
- package/dist/ui/admin/i18n.d.ts +27 -0
- package/dist/ui/admin/i18n.js +324 -0
- package/dist/ui/admin/item-form.d.ts +20 -0
- package/dist/ui/admin/item-form.js +60 -0
- package/dist/ui/admin/list-control.d.ts +13 -0
- package/dist/ui/admin/list-control.js +31 -0
- package/dist/ui/admin/locales.d.ts +4 -0
- package/dist/ui/admin/locales.js +8 -0
- package/dist/ui/admin/login-form.d.ts +3 -0
- package/dist/ui/admin/login-form.js +52 -0
- package/dist/ui/admin/media-control.d.ts +14 -0
- package/dist/ui/admin/media-control.js +74 -0
- package/dist/ui/admin/media-list-control.d.ts +14 -0
- package/dist/ui/admin/media-list-control.js +91 -0
- package/dist/ui/admin/pagination.d.ts +11 -0
- package/dist/ui/admin/pagination.js +14 -0
- package/dist/ui/admin/relation-control.d.ts +14 -0
- package/dist/ui/admin/relation-control.js +33 -0
- package/dist/ui/admin/router.d.ts +17 -0
- package/dist/ui/admin/router.js +58 -0
- package/dist/ui/admin/runtime.d.ts +28 -0
- package/dist/ui/admin/runtime.js +29 -0
- package/dist/ui/admin/sidebar.d.ts +13 -0
- package/dist/ui/admin/sidebar.js +29 -0
- package/dist/ui/admin/standalone-manager.d.ts +11 -0
- package/dist/ui/admin/standalone-manager.js +51 -0
- package/dist/ui/admin/table.d.ts +21 -0
- package/dist/ui/admin/table.js +23 -0
- package/dist/ui/admin/toast.d.ts +16 -0
- package/dist/ui/admin/toast.js +59 -0
- package/dist/ui/admin/users-manager.d.ts +6 -0
- package/dist/ui/admin/users-manager.js +157 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +14 -0
- package/dist/ui/box.d.ts +17 -0
- package/dist/ui/box.js +14 -0
- package/dist/ui/button.d.ts +25 -0
- package/dist/ui/button.js +28 -0
- package/dist/ui/card.d.ts +45 -0
- package/dist/ui/card.js +49 -0
- package/dist/ui/container.d.ts +13 -0
- package/dist/ui/container.js +13 -0
- package/dist/ui/drawer.d.ts +15 -0
- package/dist/ui/drawer.js +31 -0
- package/dist/ui/field-wrapper.d.ts +15 -0
- package/dist/ui/field-wrapper.js +11 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.js +8 -0
- package/dist/ui/text.d.ts +19 -0
- package/dist/ui/text.js +40 -0
- package/package.json +81 -3
- package/src/admin/app.tsx +371 -0
- package/src/admin/index.html +16 -0
- package/src/admin/main.tsx +42 -0
- package/src/admin/styles.css +9 -0
- package/src/auth/auth.server.ts +203 -0
- package/src/auth/config.ts +46 -0
- package/src/auth/cookies.server.ts +84 -0
- package/src/auth/http.server.ts +32 -0
- package/src/auth/password.server.ts +25 -0
- package/src/auth/session.server.ts +16 -0
- package/src/auth/users.server.ts +159 -0
- package/src/config.ts +120 -0
- package/src/core/backup.server.ts +446 -0
- package/src/core/db.server.ts +685 -0
- package/src/core/media.server.ts +136 -0
- package/src/core/media.ts +91 -0
- package/src/core/schema.ts +126 -0
- package/src/core/types.ts +194 -0
- package/src/core/validation.ts +215 -0
- package/src/global.d.ts +1 -0
- package/src/locale.ts +16 -0
- package/src/runtime.ts +54 -0
- package/src/server/app.ts +737 -0
- package/src/ui/admin/admin-shell.tsx +106 -0
- package/src/ui/admin/backup-manager.tsx +327 -0
- package/src/ui/admin/collection-icon.tsx +69 -0
- package/src/ui/admin/collection-manager.tsx +408 -0
- package/src/ui/admin/display.tsx +138 -0
- package/src/ui/admin/field-control.tsx +214 -0
- package/src/ui/admin/i18n.tsx +401 -0
- package/src/ui/admin/item-form.tsx +200 -0
- package/src/ui/admin/list-control.tsx +121 -0
- package/src/ui/admin/locales.ts +12 -0
- package/src/ui/admin/login-form.tsx +98 -0
- package/src/ui/admin/media-control.tsx +161 -0
- package/src/ui/admin/media-list-control.tsx +242 -0
- package/src/ui/admin/pagination.tsx +58 -0
- package/src/ui/admin/relation-control.tsx +142 -0
- package/src/ui/admin/router.tsx +105 -0
- package/src/ui/admin/runtime.tsx +58 -0
- package/src/ui/admin/sidebar.tsx +178 -0
- package/src/ui/admin/standalone-manager.tsx +103 -0
- package/src/ui/admin/table.tsx +129 -0
- package/src/ui/admin/toast.tsx +126 -0
- package/src/ui/admin/users-manager.tsx +344 -0
- package/src/ui/badge.tsx +27 -0
- package/src/ui/box.tsx +33 -0
- package/src/ui/button.tsx +77 -0
- package/src/ui/card.tsx +92 -0
- package/src/ui/container.tsx +28 -0
- package/src/ui/drawer.tsx +104 -0
- package/src/ui/field-wrapper.tsx +54 -0
- package/src/ui/index.ts +8 -0
- package/src/ui/text.tsx +93 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
import { Box } from "./box.js";
|
|
6
|
+
import { Text } from "./text.js";
|
|
7
|
+
|
|
8
|
+
export type DrawerProps = {
|
|
9
|
+
open: boolean;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
title: string;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
footer?: ReactNode;
|
|
15
|
+
width?: "md" | "lg";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const widths = {
|
|
19
|
+
md: "max-w-md",
|
|
20
|
+
lg: "max-w-2xl",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Right-side sliding panel used for create/edit forms and confirmations.
|
|
25
|
+
* Built on top of `Box`/`Text`.
|
|
26
|
+
*/
|
|
27
|
+
export const Drawer = ({
|
|
28
|
+
open,
|
|
29
|
+
onClose,
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
children,
|
|
33
|
+
footer,
|
|
34
|
+
width = "md",
|
|
35
|
+
}: DrawerProps) => {
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!open) return;
|
|
38
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
39
|
+
if (event.key === "Escape") onClose();
|
|
40
|
+
};
|
|
41
|
+
const previous = document.body.style.overflow;
|
|
42
|
+
document.body.style.overflow = "hidden";
|
|
43
|
+
window.addEventListener("keydown", onKeyDown);
|
|
44
|
+
return () => {
|
|
45
|
+
document.body.style.overflow = previous;
|
|
46
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
47
|
+
};
|
|
48
|
+
}, [open, onClose]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Box
|
|
52
|
+
aria-hidden={!open}
|
|
53
|
+
className={`fixed inset-0 z-50 ${
|
|
54
|
+
open ? "" : "pointer-events-none"
|
|
55
|
+
}`}
|
|
56
|
+
>
|
|
57
|
+
<Box
|
|
58
|
+
onClick={onClose}
|
|
59
|
+
className={`absolute inset-0 bg-gray-900/40 transition-opacity duration-200 ${
|
|
60
|
+
open ? "opacity-100" : "opacity-0"
|
|
61
|
+
}`}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<Box
|
|
65
|
+
as="aside"
|
|
66
|
+
className={`absolute right-0 top-0 h-full w-full flex-col bg-white shadow-2xl transition-transform duration-200 ease-out ${
|
|
67
|
+
widths[width]
|
|
68
|
+
} ${open ? "translate-x-0" : "translate-x-full"}`}
|
|
69
|
+
>
|
|
70
|
+
<Box className="items-start justify-between border-b border-gray-200 px-6 py-4">
|
|
71
|
+
<Box className="flex-col gap-0.5">
|
|
72
|
+
<Text size="subtitle" className="font-semibold text-gray-900">
|
|
73
|
+
{title}
|
|
74
|
+
</Text>
|
|
75
|
+
{description ? (
|
|
76
|
+
<Text size="caption" className="text-gray-500">
|
|
77
|
+
{description}
|
|
78
|
+
</Text>
|
|
79
|
+
) : null}
|
|
80
|
+
</Box>
|
|
81
|
+
<Box
|
|
82
|
+
as="button"
|
|
83
|
+
type="button"
|
|
84
|
+
onClick={onClose}
|
|
85
|
+
aria-label="Fechar"
|
|
86
|
+
className="items-center justify-center rounded-md p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700"
|
|
87
|
+
>
|
|
88
|
+
<Text as="span" size="subtitle" className="leading-none">
|
|
89
|
+
×
|
|
90
|
+
</Text>
|
|
91
|
+
</Box>
|
|
92
|
+
</Box>
|
|
93
|
+
|
|
94
|
+
<Box className="flex-1 flex-col overflow-y-auto px-6 py-5">{children}</Box>
|
|
95
|
+
|
|
96
|
+
{footer ? (
|
|
97
|
+
<Box className="items-center justify-end gap-2 border-t border-gray-200 bg-gray-50 px-6 py-4">
|
|
98
|
+
{footer}
|
|
99
|
+
</Box>
|
|
100
|
+
) : null}
|
|
101
|
+
</Box>
|
|
102
|
+
</Box>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { Box } from "./box.js";
|
|
4
|
+
import { Text } from "./text.js";
|
|
5
|
+
|
|
6
|
+
const inputClass =
|
|
7
|
+
"w-full rounded-md border bg-white px-3 py-2 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-gray-900 focus:ring-1 focus:ring-gray-900 disabled:bg-gray-50 disabled:text-gray-500";
|
|
8
|
+
|
|
9
|
+
export type FieldWrapperProps = {
|
|
10
|
+
label: string;
|
|
11
|
+
htmlFor?: string | undefined;
|
|
12
|
+
required?: boolean | undefined;
|
|
13
|
+
help?: string | undefined;
|
|
14
|
+
error?: string | undefined;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Label + control + help/error wrapper built on `Box`/`Text`.
|
|
20
|
+
*/
|
|
21
|
+
export const FieldWrapper = ({
|
|
22
|
+
label,
|
|
23
|
+
htmlFor,
|
|
24
|
+
required,
|
|
25
|
+
help,
|
|
26
|
+
error,
|
|
27
|
+
children,
|
|
28
|
+
}: FieldWrapperProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Box className="flex-col gap-1.5">
|
|
31
|
+
<Text
|
|
32
|
+
as="label"
|
|
33
|
+
htmlFor={htmlFor}
|
|
34
|
+
size="caption"
|
|
35
|
+
className="font-medium text-gray-700"
|
|
36
|
+
>
|
|
37
|
+
{label}
|
|
38
|
+
{required ? <span className="text-red-500"> *</span> : null}
|
|
39
|
+
</Text>
|
|
40
|
+
{children}
|
|
41
|
+
{error ? (
|
|
42
|
+
<Text size="caption" className="text-red-600">
|
|
43
|
+
{error}
|
|
44
|
+
</Text>
|
|
45
|
+
) : help ? (
|
|
46
|
+
<Text size="caption" className="text-gray-400">
|
|
47
|
+
{help}
|
|
48
|
+
</Text>
|
|
49
|
+
) : null}
|
|
50
|
+
</Box>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { inputClass };
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Badge, type BadgeTone } from "./badge.js";
|
|
2
|
+
export { Box } from "./box.js";
|
|
3
|
+
export { Button, IconButton } from "./button.js";
|
|
4
|
+
export { Card } from "./card.js";
|
|
5
|
+
export { Container } from "./container.js";
|
|
6
|
+
export { Drawer } from "./drawer.js";
|
|
7
|
+
export { FieldWrapper, inputClass } from "./field-wrapper.js";
|
|
8
|
+
export { Text } from "./text.js";
|
package/src/ui/text.tsx
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ElementType,
|
|
3
|
+
type ComponentPropsWithoutRef,
|
|
4
|
+
type ReactElement,
|
|
5
|
+
} from "react";
|
|
6
|
+
|
|
7
|
+
/** Design-system type scale (see docs/design.md). */
|
|
8
|
+
export type TextSize =
|
|
9
|
+
| "display"
|
|
10
|
+
| "heading"
|
|
11
|
+
| "subheading"
|
|
12
|
+
| "cardTitle"
|
|
13
|
+
| "lead"
|
|
14
|
+
| "body"
|
|
15
|
+
| "small"
|
|
16
|
+
| "mono"
|
|
17
|
+
| "monoSm"
|
|
18
|
+
| "monoXs"
|
|
19
|
+
// Legacy aliases kept for the admin UI.
|
|
20
|
+
| "title/xl"
|
|
21
|
+
| "title/lg"
|
|
22
|
+
| "title"
|
|
23
|
+
| "subtitle"
|
|
24
|
+
| "caption";
|
|
25
|
+
|
|
26
|
+
export type TextFont = "sans" | "mono";
|
|
27
|
+
|
|
28
|
+
export type TextProps<T extends ElementType = "span"> = {
|
|
29
|
+
size?: TextSize;
|
|
30
|
+
font?: TextFont;
|
|
31
|
+
as?: T;
|
|
32
|
+
className?: string;
|
|
33
|
+
} & ComponentPropsWithoutRef<T>;
|
|
34
|
+
|
|
35
|
+
const sizeStyles: Record<TextSize, string> = {
|
|
36
|
+
display: "text-[30px] leading-[1.2] tracking-[-0.02em] font-extrabold sm:text-[48px]",
|
|
37
|
+
heading: "text-[28px] leading-[1.3] tracking-[-0.01em] font-extrabold sm:text-[36px]",
|
|
38
|
+
subheading: "text-[24px] leading-[1.3] font-bold sm:text-[28px]",
|
|
39
|
+
cardTitle: "text-[20px] leading-[1.4] font-bold",
|
|
40
|
+
lead: "text-[18px] leading-[1.6] font-medium",
|
|
41
|
+
body: "text-[16px] leading-[1.6] font-medium",
|
|
42
|
+
small: "text-[14px] leading-[1.5] font-medium",
|
|
43
|
+
mono: "text-[14px] leading-[1.6] font-medium",
|
|
44
|
+
monoSm: "text-[12px] leading-[1.5] font-medium",
|
|
45
|
+
monoXs: "text-[10px] leading-[1.4] font-medium",
|
|
46
|
+
// Legacy
|
|
47
|
+
"title/xl": "text-[30px] leading-[1.2] font-extrabold sm:text-[48px]",
|
|
48
|
+
"title/lg": "text-[28px] leading-[1.3] font-extrabold sm:text-[36px]",
|
|
49
|
+
title: "text-[24px] leading-[1.3] font-bold sm:text-[28px]",
|
|
50
|
+
subtitle: "text-[20px] leading-[1.4] font-bold",
|
|
51
|
+
caption: "text-[14px] leading-[1.5]",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const monoFonts = new Set<TextSize>([
|
|
55
|
+
"mono",
|
|
56
|
+
"monoSm",
|
|
57
|
+
"monoXs",
|
|
58
|
+
"display",
|
|
59
|
+
"heading",
|
|
60
|
+
"subheading",
|
|
61
|
+
"cardTitle",
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Typography primitive driven by the design-system type scale.
|
|
66
|
+
*
|
|
67
|
+
* Colors and other surface decisions belong to the components that compose
|
|
68
|
+
* `Text` (passed through `className`).
|
|
69
|
+
*/
|
|
70
|
+
export const Text = <T extends ElementType = "div">({
|
|
71
|
+
size = "body",
|
|
72
|
+
font,
|
|
73
|
+
as,
|
|
74
|
+
className = "",
|
|
75
|
+
children,
|
|
76
|
+
...props
|
|
77
|
+
}: TextProps<T>): ReactElement => {
|
|
78
|
+
const Tag = as ?? "p";
|
|
79
|
+
const family = font ?? (monoFonts.has(size) ? "mono" : "sans");
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<Tag
|
|
83
|
+
className={`${sizeStyles[size]} ${
|
|
84
|
+
family === "mono" ? "font-mono" : "font-sans"
|
|
85
|
+
} ${className}`}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</Tag>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { sizeStyles };
|