@r_masseater/masseater-utils 0.6.1 → 0.8.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/README.md +40 -22
- package/dist/browser-test/vite.d.mts +6 -0
- package/dist/browser-test/vite.mjs +29 -0
- package/dist/browser-test/vite.mjs.map +1 -0
- package/dist/button-variants-BLMlMm-s.mjs +31 -0
- package/dist/button-variants-BLMlMm-s.mjs.map +1 -0
- package/dist/button-variants-Bupz7GI3.d.mts +6 -0
- package/dist/cn-DtxpfSUK.mjs +7 -0
- package/dist/cn-DtxpfSUK.mjs.map +1 -0
- package/dist/effect2cs.d.mts +27 -0
- package/dist/effect2cs.mjs +75 -0
- package/dist/effect2cs.mjs.map +1 -0
- package/dist/effect2rs.d.mts +52 -0
- package/dist/effect2rs.mjs +870 -0
- package/dist/effect2rs.mjs.map +1 -0
- package/dist/github-workflow.d.mts +3 -33
- package/dist/github-workflow.mjs +2 -46
- package/dist/github-workflow.mjs.map +1 -1
- package/dist/headers-BK-aW9Kw.d.mts +81 -0
- package/dist/headers-Cr6gAurg.mjs +115 -0
- package/dist/headers-Cr6gAurg.mjs.map +1 -0
- package/dist/heading-class-CDq0WZpR.d.mts +10 -0
- package/dist/heading-class-H4Z13Bpn.mjs +14 -0
- package/dist/heading-class-H4Z13Bpn.mjs.map +1 -0
- package/dist/index-BkZOsFv4.d.mts +139 -0
- package/dist/index-CLb1-l_c.d.mts +28 -0
- package/dist/index-ChbPLmqu.d.mts +33 -0
- package/dist/lapse/sdk.d.mts +4 -0
- package/dist/lapse/sdk.mjs +11 -0
- package/dist/lapse/sdk.mjs.map +1 -0
- package/dist/lapse.d.mts +8 -0
- package/dist/lapse.mjs +43 -0
- package/dist/lapse.mjs.map +1 -0
- package/dist/local-server/node.d.mts +21 -0
- package/dist/local-server/node.mjs +81 -0
- package/dist/local-server/node.mjs.map +1 -0
- package/dist/local-server/serve.d.mts +9 -0
- package/dist/local-server/serve.mjs +13 -0
- package/dist/local-server/serve.mjs.map +1 -0
- package/dist/local-server.d.mts +19 -0
- package/dist/local-server.mjs +36 -0
- package/dist/local-server.mjs.map +1 -0
- package/dist/plugin-kit.d.mts +103 -2
- package/dist/plugin-kit.mjs +310 -8
- package/dist/plugin-kit.mjs.map +1 -1
- package/dist/portfolio-BQJtJtfK.mjs +45 -0
- package/dist/portfolio-BQJtJtfK.mjs.map +1 -0
- package/dist/process-_W_7DeKe.d.mts +34 -0
- package/dist/process-lKS6nYWh.mjs +49 -0
- package/dist/process-lKS6nYWh.mjs.map +1 -0
- package/dist/process.d.mts +2 -0
- package/dist/process.mjs +1 -0
- package/dist/security-headers/http.d.mts +10 -0
- package/dist/security-headers/http.mjs +25 -0
- package/dist/security-headers/http.mjs.map +1 -0
- package/dist/security-headers/request.d.mts +3 -0
- package/dist/security-headers/request.mjs +15 -0
- package/dist/security-headers/request.mjs.map +1 -0
- package/dist/security-headers/response.d.mts +2 -0
- package/dist/security-headers/response.mjs +17 -0
- package/dist/security-headers/response.mjs.map +1 -0
- package/dist/security-headers/static.d.mts +2 -0
- package/dist/security-headers/static.mjs +1 -0
- package/dist/security-headers/vite.d.mts +2 -0
- package/dist/security-headers/vite.mjs +1 -0
- package/dist/security-headers.d.mts +3 -0
- package/dist/security-headers.mjs +3 -0
- package/dist/socket-port-CTg-qfiP.mjs +20 -0
- package/dist/socket-port-CTg-qfiP.mjs.map +1 -0
- package/dist/static-page-headers-_B0WGkew.mjs +133 -0
- package/dist/static-page-headers-_B0WGkew.mjs.map +1 -0
- package/dist/sync-BkyZGGDA.mjs +121 -0
- package/dist/sync-BkyZGGDA.mjs.map +1 -0
- package/dist/table-class-BeiCXlFj.d.mts +14 -0
- package/dist/table-class-RQvT6MYy.mjs +21 -0
- package/dist/table-class-RQvT6MYy.mjs.map +1 -0
- package/dist/ui/backdrop-palette.d.mts +10 -0
- package/dist/ui/backdrop-palette.mjs +13 -0
- package/dist/ui/backdrop-palette.mjs.map +1 -0
- package/dist/ui/badge.d.mts +12 -0
- package/dist/ui/badge.mjs +18 -0
- package/dist/ui/badge.mjs.map +1 -0
- package/dist/ui/browser-runtime.d.mts +3 -0
- package/dist/ui/browser-runtime.mjs +18 -0
- package/dist/ui/browser-runtime.mjs.map +1 -0
- package/dist/ui/button-variants.d.mts +2 -0
- package/dist/ui/button-variants.mjs +1 -0
- package/dist/ui/button.d.mts +7 -0
- package/dist/ui/button.mjs +30 -0
- package/dist/ui/button.mjs.map +1 -0
- package/dist/ui/cn.d.mts +3 -0
- package/dist/ui/cn.mjs +1 -0
- package/dist/ui/color-scheme.d.mts +2 -0
- package/dist/ui/color-scheme.mjs +13 -0
- package/dist/ui/color-scheme.mjs.map +1 -0
- package/dist/ui/heading-class.d.mts +2 -0
- package/dist/ui/heading-class.mjs +1 -0
- package/dist/ui/heading.d.mts +8 -0
- package/dist/ui/heading.mjs +34 -0
- package/dist/ui/heading.mjs.map +1 -0
- package/dist/ui/input-class.d.mts +2 -0
- package/dist/ui/input-class.mjs +5 -0
- package/dist/ui/input-class.mjs.map +1 -0
- package/dist/ui/native-select-class.d.mts +2 -0
- package/dist/ui/native-select-class.mjs +5 -0
- package/dist/ui/native-select-class.mjs.map +1 -0
- package/dist/ui/next-page-trigger.d.mts +5 -0
- package/dist/ui/next-page-trigger.mjs +29 -0
- package/dist/ui/next-page-trigger.mjs.map +1 -0
- package/dist/ui/page-footer.d.mts +10 -0
- package/dist/ui/page-footer.mjs +24 -0
- package/dist/ui/page-footer.mjs.map +1 -0
- package/dist/ui/page-header.d.mts +11 -0
- package/dist/ui/page-header.mjs +22 -0
- package/dist/ui/page-header.mjs.map +1 -0
- package/dist/ui/pointer.d.mts +14 -0
- package/dist/ui/pointer.mjs +51 -0
- package/dist/ui/pointer.mjs.map +1 -0
- package/dist/ui/portfolio.d.mts +31 -0
- package/dist/ui/portfolio.mjs +1 -0
- package/dist/ui/table-class.d.mts +2 -0
- package/dist/ui/table-class.mjs +1 -0
- package/dist/ui/table.d.mts +30 -0
- package/dist/ui/table.mjs +64 -0
- package/dist/ui/table.mjs.map +1 -0
- package/dist/ui/to-wavy-letters.d.mts +12 -0
- package/dist/ui/to-wavy-letters.mjs +9 -0
- package/dist/ui/to-wavy-letters.mjs.map +1 -0
- package/dist/ui/web-analytics.d.mts +18 -0
- package/dist/ui/web-analytics.mjs +19 -0
- package/dist/ui/web-analytics.mjs.map +1 -0
- package/dist/web-analytics-BM9LdncT.d.mts +4 -0
- package/dist/web-analytics-Bz6nyJmQ.mjs +6 -0
- package/dist/web-analytics-Bz6nyJmQ.mjs.map +1 -0
- package/dist/yohaku-protocol/sync.d.mts +2 -0
- package/dist/yohaku-protocol/sync.mjs +1 -0
- package/dist/yohaku-protocol.d.mts +2 -0
- package/dist/yohaku-protocol.mjs +1 -0
- package/package.json +131 -4
- package/skills/share-types-with-rust/SKILL.md +90 -0
- package/src/app/browser-test-fonts.conf +28 -0
- package/src/app/ui-styles.css +185 -0
- package/src/app/ui-theme.css +81 -0
- package/src/app/ui-view-transition.css +5 -0
- package/src/shared/lib/button-variants.ts +33 -0
- package/src/shared/lib/input-class.ts +2 -0
- package/src/shared/lib/native-select-class.ts +2 -0
- package/src/shared/lib/table-class.ts +35 -0
- package/src/shared/ui/badge.tsx +29 -0
- package/src/shared/ui/button.tsx +39 -0
- package/src/shared/ui/heading.tsx +38 -0
- package/src/shared/ui/next-page-trigger.tsx +34 -0
- package/src/shared/ui/page-footer.tsx +34 -0
- package/src/shared/ui/page-header.tsx +29 -0
- package/src/shared/ui/table/column-headings.tsx +30 -0
- package/src/shared/ui/table/index.ts +10 -0
- package/src/shared/ui/table/table-body.tsx +8 -0
- package/src/shared/ui/table/table-caption.tsx +8 -0
- package/src/shared/ui/table/table-cell.tsx +8 -0
- package/src/shared/ui/table/table-head.tsx +13 -0
- package/src/shared/ui/table/table-header.tsx +8 -0
- package/src/shared/ui/table/table-row.tsx +8 -0
- package/src/shared/ui/table/table.tsx +31 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const buttonVariants = cva(
|
|
4
|
+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
9
|
+
destructive:
|
|
10
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
|
|
11
|
+
outline:
|
|
12
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
13
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
14
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
15
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
19
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
20
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
21
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
22
|
+
icon: "size-9",
|
|
23
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
24
|
+
"icon-sm": "size-8",
|
|
25
|
+
"icon-lg": "size-10",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
variant: "default",
|
|
30
|
+
size: "default",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const INPUT_CLASS =
|
|
2
|
+
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-colors outline-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export const TABLE_CONTAINER_CLASS = "relative w-full overflow-x-auto";
|
|
5
|
+
|
|
6
|
+
export const TABLE_CLASS = "w-full caption-bottom text-sm";
|
|
7
|
+
|
|
8
|
+
export const TABLE_HEADER_CLASS = "[&_tr]:border-b";
|
|
9
|
+
|
|
10
|
+
export const TABLE_BODY_CLASS = "[&_tr:last-child]:border-0";
|
|
11
|
+
|
|
12
|
+
export const TABLE_ROW_CLASS =
|
|
13
|
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted";
|
|
14
|
+
|
|
15
|
+
export const TABLE_CELL_CLASS =
|
|
16
|
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5";
|
|
17
|
+
|
|
18
|
+
export const TABLE_CAPTION_CLASS = "mt-4 text-sm text-muted-foreground";
|
|
19
|
+
|
|
20
|
+
export const tableHeadVariants = cva(
|
|
21
|
+
"text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
plain: "h-10 px-2 font-medium text-foreground",
|
|
26
|
+
tinted: "h-10 bg-muted px-4 text-xs font-bold text-muted-foreground",
|
|
27
|
+
ruled: "border-b-2 border-input px-2 py-2 text-xs font-bold text-muted-foreground",
|
|
28
|
+
compact: "bg-muted px-3 py-2 font-medium",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: { variant: "plain" },
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export type TableHeadVariant = NonNullable<VariantProps<typeof tableHeadVariants>["variant"]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
|
|
5
|
+
export type BadgeStyle<Variant extends string> = Readonly<{
|
|
6
|
+
base: string;
|
|
7
|
+
variants: Readonly<Record<Variant, string>>;
|
|
8
|
+
fallback: NoInfer<Variant>;
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
export type BadgeProps<Variant extends string> = ComponentProps<"span"> &
|
|
12
|
+
Readonly<{ variant?: Variant | null | undefined }>;
|
|
13
|
+
|
|
14
|
+
export const badgeOf = <Variant extends string>(
|
|
15
|
+
style: BadgeStyle<Variant>,
|
|
16
|
+
): ((props: BadgeProps<Variant>) => ReactNode) => {
|
|
17
|
+
const Badge = ({ className, variant, ...props }: BadgeProps<Variant>): ReactNode => {
|
|
18
|
+
const kind = variant ?? style.fallback;
|
|
19
|
+
return (
|
|
20
|
+
<span
|
|
21
|
+
data-slot="badge"
|
|
22
|
+
data-variant={kind}
|
|
23
|
+
className={cn(style.base, style.variants[kind], className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
return Badge;
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { Slot } from "radix-ui";
|
|
3
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
import { buttonVariants } from "#/shared/lib/button-variants.ts";
|
|
6
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
7
|
+
|
|
8
|
+
export const Button = ({
|
|
9
|
+
className,
|
|
10
|
+
variant = "default",
|
|
11
|
+
size = "default",
|
|
12
|
+
asChild = false,
|
|
13
|
+
...props
|
|
14
|
+
}: ComponentProps<"button"> &
|
|
15
|
+
Readonly<VariantProps<typeof buttonVariants>> &
|
|
16
|
+
Readonly<{ asChild?: boolean }>): ReactNode => {
|
|
17
|
+
const classes = cn(buttonVariants({ variant, size, className }));
|
|
18
|
+
if (asChild) {
|
|
19
|
+
return (
|
|
20
|
+
<Slot.Root
|
|
21
|
+
data-slot="button"
|
|
22
|
+
data-variant={variant}
|
|
23
|
+
data-size={size}
|
|
24
|
+
className={classes}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return (
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
data-slot="button"
|
|
33
|
+
data-variant={variant}
|
|
34
|
+
data-size={size}
|
|
35
|
+
className={classes}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Option } from "effect";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
HEADING_MARK_CLASS,
|
|
6
|
+
headingCountVariants,
|
|
7
|
+
headingVariants,
|
|
8
|
+
} from "#/shared/lib/heading-class.ts";
|
|
9
|
+
import type { HeadingVariant } from "#/shared/lib/heading-class.ts";
|
|
10
|
+
|
|
11
|
+
const Count = ({
|
|
12
|
+
variant,
|
|
13
|
+
value,
|
|
14
|
+
}: Readonly<{ variant: HeadingVariant; value: number | string | undefined }>): ReactNode =>
|
|
15
|
+
Option.match(Option.fromUndefinedOr(value), {
|
|
16
|
+
onNone: () => false,
|
|
17
|
+
onSome: (shown) => <span className={headingCountVariants({ variant })}>{shown}</span>,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const MARK = <span aria-hidden="true" className={HEADING_MARK_CLASS} data-slot="heading-mark" />;
|
|
21
|
+
|
|
22
|
+
const MARKS = { marked: MARK, ruled: false } as const satisfies Record<HeadingVariant, ReactNode>;
|
|
23
|
+
|
|
24
|
+
export const Heading = ({
|
|
25
|
+
variant,
|
|
26
|
+
count,
|
|
27
|
+
children,
|
|
28
|
+
}: Readonly<{
|
|
29
|
+
variant: HeadingVariant;
|
|
30
|
+
count?: number | string | undefined;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}>): ReactNode => (
|
|
33
|
+
<h2 className={headingVariants({ variant })} data-slot="heading">
|
|
34
|
+
{MARKS[variant]}
|
|
35
|
+
{children}
|
|
36
|
+
<Count variant={variant} value={count} />
|
|
37
|
+
</h2>
|
|
38
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Array, Option, pipe } from "effect";
|
|
2
|
+
import { constVoid } from "effect/Function";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import type { ReactNode, RefCallback } from "react";
|
|
5
|
+
|
|
6
|
+
const AHEAD = { rootMargin: "0px 0px 100% 0px" } as const;
|
|
7
|
+
|
|
8
|
+
export const NextPageTrigger = ({ onVisible }: Readonly<{ onVisible: () => void }>): ReactNode => {
|
|
9
|
+
const watch: RefCallback<HTMLDivElement> = useCallback(
|
|
10
|
+
(element) => {
|
|
11
|
+
const observer = new IntersectionObserver((entries) => {
|
|
12
|
+
if (
|
|
13
|
+
pipe(
|
|
14
|
+
entries,
|
|
15
|
+
Array.some(({ isIntersecting }) => isIntersecting),
|
|
16
|
+
)
|
|
17
|
+
) {
|
|
18
|
+
onVisible();
|
|
19
|
+
}
|
|
20
|
+
}, AHEAD);
|
|
21
|
+
return Option.match(Option.fromNullOr(element), {
|
|
22
|
+
onNone: () => constVoid,
|
|
23
|
+
onSome: (target) => {
|
|
24
|
+
observer.observe(target);
|
|
25
|
+
return () => {
|
|
26
|
+
observer.disconnect();
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
[onVisible],
|
|
32
|
+
);
|
|
33
|
+
return <div ref={watch} className="h-px shrink-0" />;
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
const footerVariants = cva("", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
rule: "mt-16 border-t",
|
|
9
|
+
links: "font-display flex items-center justify-center gap-4 px-4 pb-8",
|
|
10
|
+
credit: "text-muted-foreground px-6 pb-4 text-right text-xs",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const innerVariants = cva("", {
|
|
16
|
+
variants: {
|
|
17
|
+
variant: {
|
|
18
|
+
rule: "text-muted-foreground mx-auto max-w-6xl px-4 py-8 text-sm",
|
|
19
|
+
links: "contents",
|
|
20
|
+
credit: "contents",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const PageFooter = ({
|
|
26
|
+
variant,
|
|
27
|
+
children,
|
|
28
|
+
}: Readonly<
|
|
29
|
+
Required<VariantProps<typeof footerVariants>> & { children: ReactNode }
|
|
30
|
+
>): ReactNode => (
|
|
31
|
+
<footer className={footerVariants({ variant })} data-slot="page-footer">
|
|
32
|
+
<div className={innerVariants({ variant })}>{children}</div>
|
|
33
|
+
</footer>
|
|
34
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
const headerVariants = cva("flex", {
|
|
6
|
+
variants: { layout: { stacked: "flex-col gap-5", bar: "items-center gap-3" } },
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const titleVariants = cva("", {
|
|
10
|
+
variants: {
|
|
11
|
+
layout: {
|
|
12
|
+
stacked: "text-3xl leading-tight font-bold md:text-4xl",
|
|
13
|
+
bar: "flex-1 text-xl font-semibold",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const PageHeader = ({
|
|
19
|
+
layout,
|
|
20
|
+
title,
|
|
21
|
+
children,
|
|
22
|
+
}: Readonly<
|
|
23
|
+
Required<VariantProps<typeof headerVariants>> & { title: string; children: ReactNode }
|
|
24
|
+
>): ReactNode => (
|
|
25
|
+
<header className={headerVariants({ layout })} data-slot="page-header">
|
|
26
|
+
<h1 className={titleVariants({ layout })}>{title}</h1>
|
|
27
|
+
{children}
|
|
28
|
+
</header>
|
|
29
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Array as Arr, pipe } from "effect";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import type { TableHeadVariant } from "#/shared/lib/table-class.ts";
|
|
5
|
+
import { TableHead } from "#/shared/ui/table/table-head.tsx";
|
|
6
|
+
import { TableHeader } from "#/shared/ui/table/table-header.tsx";
|
|
7
|
+
import { TableRow } from "#/shared/ui/table/table-row.tsx";
|
|
8
|
+
|
|
9
|
+
export type ColumnHeading = Readonly<{ key?: string; label: string; className?: string }>;
|
|
10
|
+
|
|
11
|
+
export const ColumnHeadings = ({
|
|
12
|
+
columns,
|
|
13
|
+
variant,
|
|
14
|
+
}: Readonly<{
|
|
15
|
+
columns: readonly ColumnHeading[];
|
|
16
|
+
variant?: TableHeadVariant;
|
|
17
|
+
}>): ReactNode => (
|
|
18
|
+
<TableHeader>
|
|
19
|
+
<TableRow>
|
|
20
|
+
{pipe(
|
|
21
|
+
columns,
|
|
22
|
+
Arr.map(({ key, label, className }) => (
|
|
23
|
+
<TableHead key={key ?? label} scope="col" variant={variant} className={className}>
|
|
24
|
+
{label}
|
|
25
|
+
</TableHead>
|
|
26
|
+
)),
|
|
27
|
+
)}
|
|
28
|
+
</TableRow>
|
|
29
|
+
</TableHeader>
|
|
30
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ColumnHeadings } from "#/shared/ui/table/column-headings.tsx";
|
|
2
|
+
export type { ColumnHeading } from "#/shared/ui/table/column-headings.tsx";
|
|
3
|
+
export type { TableHeadVariant } from "#/shared/lib/table-class.ts";
|
|
4
|
+
export { Table } from "#/shared/ui/table/table.tsx";
|
|
5
|
+
export { TableBody } from "#/shared/ui/table/table-body.tsx";
|
|
6
|
+
export { TableCaption } from "#/shared/ui/table/table-caption.tsx";
|
|
7
|
+
export { TableCell } from "#/shared/ui/table/table-cell.tsx";
|
|
8
|
+
export { TableHead } from "#/shared/ui/table/table-head.tsx";
|
|
9
|
+
export { TableHeader } from "#/shared/ui/table/table-header.tsx";
|
|
10
|
+
export { TableRow } from "#/shared/ui/table/table-row.tsx";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_BODY_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
export const TableBody = ({ className, ...props }: ComponentProps<"tbody">): ReactNode => (
|
|
7
|
+
<tbody data-slot="table-body" className={cn(TABLE_BODY_CLASS, className)} {...props} />
|
|
8
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_CAPTION_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
export const TableCaption = ({ className, ...props }: ComponentProps<"caption">): ReactNode => (
|
|
7
|
+
<caption data-slot="table-caption" className={cn(TABLE_CAPTION_CLASS, className)} {...props} />
|
|
8
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_CELL_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
export const TableCell = ({ className, ...props }: ComponentProps<"td">): ReactNode => (
|
|
7
|
+
<td data-slot="table-cell" className={cn(TABLE_CELL_CLASS, className)} {...props} />
|
|
8
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
5
|
+
import { tableHeadVariants } from "#/shared/lib/table-class.ts";
|
|
6
|
+
|
|
7
|
+
export const TableHead = ({
|
|
8
|
+
className,
|
|
9
|
+
variant,
|
|
10
|
+
...props
|
|
11
|
+
}: ComponentProps<"th"> & Readonly<VariantProps<typeof tableHeadVariants>>): ReactNode => (
|
|
12
|
+
<th data-slot="table-head" className={cn(tableHeadVariants({ variant }), className)} {...props} />
|
|
13
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_HEADER_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
export const TableHeader = ({ className, ...props }: ComponentProps<"thead">): ReactNode => (
|
|
7
|
+
<thead data-slot="table-header" className={cn(TABLE_HEADER_CLASS, className)} {...props} />
|
|
8
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_ROW_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
export const TableRow = ({ className, ...props }: ComponentProps<"tr">): ReactNode => (
|
|
7
|
+
<tr data-slot="table-row" className={cn(TABLE_ROW_CLASS, className)} {...props} />
|
|
8
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/shared/lib/cn.ts";
|
|
4
|
+
import { TABLE_CLASS, TABLE_CONTAINER_CLASS } from "#/shared/lib/table-class.ts";
|
|
5
|
+
|
|
6
|
+
const FOCUSABLE = 0;
|
|
7
|
+
|
|
8
|
+
export type TableProps = ComponentProps<"table"> &
|
|
9
|
+
Readonly<{ containerClassName?: string }> &
|
|
10
|
+
(
|
|
11
|
+
| Readonly<{ label: string; labelledBy?: never }>
|
|
12
|
+
| Readonly<{ labelledBy: string; label?: never }>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const Table = ({
|
|
16
|
+
className,
|
|
17
|
+
containerClassName,
|
|
18
|
+
label,
|
|
19
|
+
labelledBy,
|
|
20
|
+
...props
|
|
21
|
+
}: TableProps): ReactNode => (
|
|
22
|
+
<section
|
|
23
|
+
data-slot="table-container"
|
|
24
|
+
aria-label={label}
|
|
25
|
+
aria-labelledby={labelledBy}
|
|
26
|
+
className={cn(TABLE_CONTAINER_CLASS, containerClassName)}
|
|
27
|
+
tabIndex={FOCUSABLE}
|
|
28
|
+
>
|
|
29
|
+
<table data-slot="table" className={cn(TABLE_CLASS, className)} {...props} />
|
|
30
|
+
</section>
|
|
31
|
+
);
|