doom-design-system 0.4.0 → 0.4.2
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/dist/components/ActionRow/ActionRow.d.ts +1 -1
- package/dist/components/ActionRow/ActionRow.js +7 -7
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/FileUpload/FileUpload.js +3 -3
- package/dist/components/Image/Image.d.ts +1 -1
- package/dist/components/Image/Image.js +68 -37
- package/dist/components/Image/Image.module.css +25 -6
- package/dist/components/Layout/Layout.d.ts +98 -3
- package/dist/components/Layout/Layout.js +55 -9
- package/dist/components/Layout/Layout.module.css +64 -5
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/Slat/Slat.js +1 -1
- package/dist/components/Table/Table.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
3
|
var t = {};
|
|
4
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -11,12 +11,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { Text } from
|
|
15
|
-
import { Flex } from
|
|
16
|
-
import { ChevronRight } from
|
|
17
|
-
import clsx from
|
|
18
|
-
import styles from
|
|
14
|
+
import { Text } from "../Text/Text.js";
|
|
15
|
+
import { Flex } from "../Layout/Layout.js";
|
|
16
|
+
import { ChevronRight } from "lucide-react";
|
|
17
|
+
import clsx from "clsx";
|
|
18
|
+
import styles from "./ActionRow.module.css";
|
|
19
19
|
export function ActionRow(_a) {
|
|
20
20
|
var { icon, title, description, onClick, className } = _a, props = __rest(_a, ["icon", "title", "description", "onClick", "className"]);
|
|
21
|
-
return (_jsxs(Flex, Object.assign({ align: "center", gap:
|
|
21
|
+
return (_jsxs(Flex, Object.assign({ align: "center", gap: 6, onClick: onClick, className: clsx(styles.actionRow, className) }, props, { children: [_jsx("div", { className: styles.iconWrapper, children: icon }), _jsxs(Flex, { direction: "column", gap: 1, style: { flex: 1 }, children: [_jsx(Text, { variant: "h6", weight: "bold", children: title }), description && (_jsx(Text, { color: "muted", variant: "small", children: description }))] }), _jsx(ChevronRight, { size: 20, strokeWidth: 2.5, style: { color: "var(--muted-foreground)" } })] })));
|
|
22
22
|
}
|
|
@@ -189,7 +189,7 @@ export const FileUpload = ({ label, helperText, accept, maxSize, multiple = fals
|
|
|
189
189
|
}) }, handleDragHandlers, { children: [_jsxs(Switcher, { threshold: "xxs", className: clsx(styles.header, {
|
|
190
190
|
[styles.errorHeader]: status === Status.Error,
|
|
191
191
|
[styles.disabledHeader]: disabled,
|
|
192
|
-
}), justify: "space-between", align: "center", gap:
|
|
192
|
+
}), justify: "space-between", align: "center", gap: 2, children: [_jsx("div", { className: styles.headerContent, children: _jsxs(Text, { className: styles.headerTitle, id: "upload-title", children: [label || "Upload Files", required && (_jsx("span", { className: styles.requiredMark, children: _jsx(Asterisk, { size: 14, "aria-label": "required" }) }))] }) }), _jsx(Badge, { variant: status === Status.Error
|
|
193
193
|
? "error"
|
|
194
194
|
: status === Status.HasFiles
|
|
195
195
|
? "success"
|
|
@@ -216,9 +216,9 @@ export const FileUpload = ({ label, helperText, accept, maxSize, multiple = fals
|
|
|
216
216
|
e.preventDefault();
|
|
217
217
|
handleClick();
|
|
218
218
|
}
|
|
219
|
-
}, role: "button", tabIndex: disabled ? -1 : 0, children: _jsxs(Stack, { gap:
|
|
219
|
+
}, role: "button", tabIndex: disabled ? -1 : 0, children: _jsxs(Stack, { gap: 4, align: "center", children: [_jsx("div", { className: styles.voidIconWrapper, "aria-hidden": "true", children: _jsx(Upload, { className: styles.icon, size: 48, strokeWidth: 2 }) }), _jsxs(Stack, { gap: 1, align: "center", children: [_jsx(Text, { weight: "bold", className: styles.voidText, children: isDragging || isActive || forceActive
|
|
220
220
|
? "Drop files now"
|
|
221
|
-
: "Drag and drop files" }), _jsx(Text, { variant: "small", className: styles.secondary, children: "or click to browse" })] }), helperText && (_jsx(Text, { variant: "small", className: styles.helperText, id: "upload-helper", children: helperText })), displayError && (_jsx(Text, { variant: "small", className: styles.errorText, id: "upload-error", children: displayError }))] }) })) : (_jsxs(Flex, { direction: "column", justify: "space-between", gap:
|
|
221
|
+
: "Drag and drop files" }), _jsx(Text, { variant: "small", className: styles.secondary, children: "or click to browse" })] }), helperText && (_jsx(Text, { variant: "small", className: styles.helperText, id: "upload-helper", children: helperText })), displayError && (_jsx(Text, { variant: "small", className: styles.errorText, id: "upload-error", children: displayError }))] }) })) : (_jsxs(Flex, { direction: "column", justify: "space-between", gap: 4, className: styles.fileList, children: [_jsx(Stack, { gap: 2, children: files.map((file, index) => {
|
|
222
222
|
const previewUrl = previews[file.name];
|
|
223
223
|
return (_jsx(Slat, { label: file.name, secondaryLabel: formatFileSize(file.size), prependContent: previewUrl ? (_jsx(PreviewImage, { src: previewUrl, alt: file.name })) : (getFileIcon(file.name)), appendContent: _jsx(Button, { type: "button", variant: "danger", size: "sm", onClick: (e) => {
|
|
224
224
|
e.stopPropagation();
|
|
@@ -5,4 +5,4 @@ export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
|
5
5
|
aspectRatio?: string | number;
|
|
6
6
|
rounded?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare function Image({ src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function Image({ src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded, width, height, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,50 +11,81 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useState,
|
|
14
|
+
import React, { useState, useEffect, useCallback } from "react";
|
|
15
15
|
import clsx from "clsx";
|
|
16
16
|
import styles from "./Image.module.css";
|
|
17
17
|
import { Skeleton } from "../Skeleton/Skeleton.js";
|
|
18
18
|
export function Image(_a) {
|
|
19
|
-
var { src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded = true } = _a, props = __rest(_a, ["src", "alt", "className", "fit", "style", "onLoad", "onError", "fallbackSrc", "aspectRatio", "rounded"]);
|
|
20
|
-
const [
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
const
|
|
19
|
+
var { src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded = true, width, height } = _a, props = __rest(_a, ["src", "alt", "className", "fit", "style", "onLoad", "onError", "fallbackSrc", "aspectRatio", "rounded", "width", "height"]);
|
|
20
|
+
const [status, setStatus] = useState("loading");
|
|
21
|
+
const [showSkeleton, setShowSkeleton] = useState(true);
|
|
22
|
+
// Helper to extract intrinsic numeric value and convert to CSS
|
|
23
|
+
const toCssValue = (val) => {
|
|
24
|
+
if (val === undefined || val === null)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof val === "number")
|
|
27
|
+
return `${val}px`;
|
|
28
|
+
return val;
|
|
29
|
+
};
|
|
30
|
+
const getIntrinsicSize = (val) => {
|
|
31
|
+
if (typeof val === "number")
|
|
32
|
+
return val;
|
|
33
|
+
if (typeof val === "string" && !val.endsWith("%")) {
|
|
34
|
+
const parsed = parseFloat(val);
|
|
35
|
+
return isNaN(parsed) ? undefined : parsed;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
const computedAspectRatio = React.useMemo(() => {
|
|
40
|
+
if (aspectRatio)
|
|
41
|
+
return aspectRatio;
|
|
42
|
+
const w = getIntrinsicSize(width);
|
|
43
|
+
const h = getIntrinsicSize(height);
|
|
44
|
+
return w && h ? `${w} / ${h}` : undefined;
|
|
45
|
+
}, [aspectRatio, width, height]);
|
|
46
|
+
// Reset state when source changes
|
|
24
47
|
useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setShowSkeleton(false);
|
|
28
|
-
if (timerRef.current)
|
|
29
|
-
clearTimeout(timerRef.current);
|
|
30
|
-
timerRef.current = setTimeout(() => {
|
|
31
|
-
setShowSkeleton(true);
|
|
32
|
-
}, 150);
|
|
33
|
-
return () => {
|
|
34
|
-
if (timerRef.current)
|
|
35
|
-
clearTimeout(timerRef.current);
|
|
36
|
-
};
|
|
48
|
+
setStatus("loading");
|
|
49
|
+
setShowSkeleton(true);
|
|
37
50
|
}, [src]);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
// When loaded, keep skeleton for a moment to allow cross-fade
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (status === "loaded") {
|
|
54
|
+
const timer = setTimeout(() => {
|
|
55
|
+
setShowSkeleton(false);
|
|
56
|
+
}, 500); // 500ms delay to allow image to fade in completely
|
|
57
|
+
return () => clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
}, [status]);
|
|
60
|
+
const handleLoad = useCallback(async (e) => {
|
|
42
61
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
const img = e.currentTarget;
|
|
63
|
+
try {
|
|
64
|
+
if (img.decode) {
|
|
65
|
+
await img.decode();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
// ignore decode errors (e.g. invalid image data)
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
setStatus("loaded");
|
|
48
73
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
}, [onLoad]);
|
|
75
|
+
const handleError = useCallback((e) => {
|
|
76
|
+
if (fallbackSrc && status !== "error") {
|
|
77
|
+
// Prevents infinite loop if fallback also fails
|
|
78
|
+
if (e.currentTarget.src !== fallbackSrc) {
|
|
79
|
+
e.currentTarget.src = fallbackSrc;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
setStatus("error");
|
|
84
|
+
setShowSkeleton(false); // Remove skeleton immediately on error to show broken image icon or alt
|
|
52
85
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
53
|
-
};
|
|
54
|
-
return (_jsxs("div", { className: clsx(styles.wrapper, rounded && styles.rounded, className), style: Object.assign({ aspectRatio }, style), children: [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
width: "100%",
|
|
59
|
-
} })), _jsx("img", Object.assign({ src: hasError ? fallbackSrc : src, alt: alt, className: clsx(styles.image, fit && styles[`fit-${fit}`], showSkeleton && styles["with-transition"]), onLoad: handleLoad, onError: handleError, "data-loaded": isLoaded ? "true" : "false", style: { width: "100%", height: "100%" } }, props))] }));
|
|
86
|
+
}, [fallbackSrc, status, onError]);
|
|
87
|
+
return (_jsxs("div", { className: clsx(styles.wrapper, rounded && styles.rounded, className), style: Object.assign({ aspectRatio: computedAspectRatio, width: toCssValue(width), height: toCssValue(height) }, style), children: [_jsx("div", { className: clsx(styles.skeletonLayer, status === "loaded" && styles.fadeOut), "aria-hidden": "true", children: showSkeleton && (_jsx(Skeleton, { style: {
|
|
88
|
+
width: "100%",
|
|
89
|
+
height: "100%",
|
|
90
|
+
} })) }), _jsx("img", Object.assign({ src: src, alt: alt, className: clsx(styles.image, fit && styles[`fit-${fit}`], status === "loaded" ? styles.visible : styles.hidden), onLoad: handleLoad, onError: handleError, width: width, height: height }, props))] }));
|
|
60
91
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
.image {
|
|
2
2
|
display: block;
|
|
3
|
-
|
|
4
|
-
height:
|
|
5
|
-
}
|
|
6
|
-
.image[data-loaded=false] {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
7
5
|
opacity: 0;
|
|
6
|
+
transition: opacity 0.5s ease-in-out;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
}
|
|
9
|
+
.image.visible {
|
|
10
|
+
opacity: 1;
|
|
8
11
|
}
|
|
9
|
-
.image.
|
|
10
|
-
|
|
12
|
+
.image.hidden {
|
|
13
|
+
opacity: 0;
|
|
11
14
|
}
|
|
12
15
|
.image.fit-cover {
|
|
13
16
|
object-fit: cover;
|
|
@@ -29,6 +32,22 @@
|
|
|
29
32
|
position: relative;
|
|
30
33
|
display: block;
|
|
31
34
|
overflow: hidden;
|
|
35
|
+
background-color: var(--surface-accent);
|
|
36
|
+
isolation: isolate;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.skeletonLayer {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
transition: opacity 0.5s ease-in-out;
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
.skeletonLayer.fadeOut {
|
|
50
|
+
opacity: 0;
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
.rounded {
|
|
@@ -1,31 +1,126 @@
|
|
|
1
1
|
import React, { ElementType } from "react";
|
|
2
|
-
|
|
2
|
+
declare const SPACING_MAP: {
|
|
3
|
+
readonly 0: "0";
|
|
4
|
+
readonly 1: "0.25rem";
|
|
5
|
+
readonly 2: "0.5rem";
|
|
6
|
+
readonly 3: "0.75rem";
|
|
7
|
+
readonly 4: "1rem";
|
|
8
|
+
readonly 5: "1.25rem";
|
|
9
|
+
readonly 6: "1.5rem";
|
|
10
|
+
readonly 8: "2rem";
|
|
11
|
+
readonly 10: "2.5rem";
|
|
12
|
+
readonly 12: "3rem";
|
|
13
|
+
readonly 16: "4rem";
|
|
14
|
+
};
|
|
15
|
+
export type Spacing = keyof typeof SPACING_MAP;
|
|
16
|
+
export interface LayoutProps extends React.HTMLAttributes<HTMLElement> {
|
|
17
|
+
/** The content to be rendered inside the layout container. */
|
|
3
18
|
children?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* The HTML element or React component to render as the root node.
|
|
21
|
+
* @default "div"
|
|
22
|
+
*/
|
|
4
23
|
as?: ElementType;
|
|
5
24
|
}
|
|
6
25
|
export interface GridProps extends LayoutProps {
|
|
26
|
+
/**
|
|
27
|
+
* Defines the columns of the grid.
|
|
28
|
+
* Accepts a number (e.g., `3` for 3 equal columns) or a CSS string (e.g., `"1fr 2fr"`).
|
|
29
|
+
* @default "1fr"
|
|
30
|
+
*/
|
|
7
31
|
columns?: string | number;
|
|
8
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Spacing between grid items.
|
|
34
|
+
* Maps to the design system spacing tokens (e.g., `4` = 1rem).
|
|
35
|
+
* @default 4
|
|
36
|
+
*/
|
|
37
|
+
gap?: Spacing;
|
|
9
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A CSS Grid container for creating two-dimensional layouts.
|
|
41
|
+
* Use this when you need precise control over columns and rows, or complex grid placements.
|
|
42
|
+
*/
|
|
10
43
|
export declare function Grid({ children, columns, gap, className, style, as: Component, ...props }: GridProps): import("react/jsx-runtime").JSX.Element;
|
|
11
44
|
export interface FlexProps extends LayoutProps {
|
|
45
|
+
/**
|
|
46
|
+
* The direction in which flex items are placed in the flex container.
|
|
47
|
+
* @default "row"
|
|
48
|
+
*/
|
|
12
49
|
direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
50
|
+
/**
|
|
51
|
+
* Alignment of items along the main axis.
|
|
52
|
+
* @default "flex-start"
|
|
53
|
+
*/
|
|
13
54
|
justify?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
55
|
+
/**
|
|
56
|
+
* Alignment of items along the cross axis.
|
|
57
|
+
* @default "stretch"
|
|
58
|
+
*/
|
|
14
59
|
align?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
15
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Spacing between flex items.
|
|
62
|
+
* Maps to the design system spacing tokens.
|
|
63
|
+
* @default 0
|
|
64
|
+
*/
|
|
65
|
+
gap?: Spacing;
|
|
66
|
+
/**
|
|
67
|
+
* Controls whether flex items are forced onto one line or can wrap onto multiple lines.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
16
70
|
wrap?: boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
17
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* A flexible box container for one-dimensional layouts.
|
|
74
|
+
* Use this as your primary layout tool for aligning items in a row or column,
|
|
75
|
+
* distributing space, and handling wrapping.
|
|
76
|
+
*/
|
|
18
77
|
export declare function Flex({ children, direction, justify, align, gap, wrap, className, style, as: Component, ...props }: FlexProps): import("react/jsx-runtime").JSX.Element;
|
|
19
78
|
export interface StackProps extends Omit<FlexProps, "direction"> {
|
|
79
|
+
/**
|
|
80
|
+
* The direction to stack items. Defaults to vertical ("column").
|
|
81
|
+
* Can be overridden to "row" for semantic or responsive adjustments.
|
|
82
|
+
* @default "column"
|
|
83
|
+
*/
|
|
20
84
|
direction?: "column" | "column-reverse" | "row" | "row-reverse";
|
|
21
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* A specialized Flex container explicitly optimized for vertical stacking.
|
|
88
|
+
* Use this for lists, form fields, card content, or any group of elements
|
|
89
|
+
* that should be arranged vertically with consistent spacing.
|
|
90
|
+
* Note: While it defaults to column, `direction="row"` is supported for semantic overrides.
|
|
91
|
+
*/
|
|
22
92
|
export declare function Stack({ children, direction, gap, align, ...props }: StackProps): import("react/jsx-runtime").JSX.Element;
|
|
23
93
|
export interface SwitcherProps extends FlexProps {
|
|
94
|
+
/**
|
|
95
|
+
* The breakpoint threshold at which the layout switches from horizontal to vertical.
|
|
96
|
+
* e.g., "xs" means it will be horizontal on screens larger than "xs" (480px), and vertical below.
|
|
97
|
+
* @default "xs"
|
|
98
|
+
*/
|
|
24
99
|
threshold?: "xxs" | "xs" | "sm" | "md";
|
|
25
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* A responsive layout component that switches from horizontal to vertical layout
|
|
103
|
+
* based on a container query or breakpoint threshold.
|
|
104
|
+
* Use this for "sidebar + main content" layouts or any pattern that needs
|
|
105
|
+
* to stack on smaller screens but sit side-by-side on larger ones.
|
|
106
|
+
*/
|
|
26
107
|
export declare function Switcher({ children, threshold, className, ...props }: SwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
27
108
|
export interface ContainerProps extends LayoutProps {
|
|
109
|
+
/**
|
|
110
|
+
* The maximum width of the container.
|
|
111
|
+
* - `sm`: 640px
|
|
112
|
+
* - `md`: 768px
|
|
113
|
+
* - `lg`: 1024px
|
|
114
|
+
* - `xl`: 1280px
|
|
115
|
+
* - `fluid`: 100%
|
|
116
|
+
* @default "xl"
|
|
117
|
+
*/
|
|
28
118
|
maxWidth?: "sm" | "md" | "lg" | "xl" | "fluid";
|
|
29
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* A specific layout component for centering content horizontally on the page.
|
|
122
|
+
* Use this to constrain the maximum width of your page content or sections,
|
|
123
|
+
* ensuring consistent margins and readability on large screens.
|
|
124
|
+
*/
|
|
30
125
|
export declare function Container({ children, maxWidth, className, as: Component, ...props }: ContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
31
126
|
export {};
|
|
@@ -13,27 +13,73 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import clsx from "clsx";
|
|
15
15
|
import styles from "./Layout.module.css";
|
|
16
|
+
const SPACING_MAP = {
|
|
17
|
+
0: "0",
|
|
18
|
+
1: "0.25rem",
|
|
19
|
+
2: "0.5rem",
|
|
20
|
+
3: "0.75rem",
|
|
21
|
+
4: "1rem",
|
|
22
|
+
5: "1.25rem",
|
|
23
|
+
6: "1.5rem",
|
|
24
|
+
8: "2rem",
|
|
25
|
+
10: "2.5rem",
|
|
26
|
+
12: "3rem",
|
|
27
|
+
16: "4rem",
|
|
28
|
+
};
|
|
29
|
+
function resolveGap(gap) {
|
|
30
|
+
if (gap === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
return SPACING_MAP[gap];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A CSS Grid container for creating two-dimensional layouts.
|
|
36
|
+
* Use this when you need precise control over columns and rows, or complex grid placements.
|
|
37
|
+
*/
|
|
16
38
|
export function Grid(_a) {
|
|
17
|
-
var { children, columns = "1fr", gap =
|
|
39
|
+
var { children, columns = "1fr", gap = 4, className, style, as: Component = "div" } = _a, props = __rest(_a, ["children", "columns", "gap", "className", "style", "as"]);
|
|
18
40
|
const gridTemplateColumns = typeof columns === "number" ? `repeat(${columns}, 1fr)` : columns;
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
const gridClasses = clsx(styles.grid, className);
|
|
42
|
+
return (_jsx(Component, Object.assign({ className: gridClasses, style: Object.assign({ gridTemplateColumns, gap: resolveGap(gap) }, style) }, props, { children: children })));
|
|
21
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A flexible box container for one-dimensional layouts.
|
|
46
|
+
* Use this as your primary layout tool for aligning items in a row or column,
|
|
47
|
+
* distributing space, and handling wrapping.
|
|
48
|
+
*/
|
|
22
49
|
export function Flex(_a) {
|
|
23
|
-
var { children, direction = "row", justify = "flex-start", align = "stretch", gap =
|
|
50
|
+
var { children, direction = "row", justify = "flex-start", align = "stretch", gap = 0, wrap = false, className, style, as: Component = "div" } = _a, props = __rest(_a, ["children", "direction", "justify", "align", "gap", "wrap", "className", "style", "as"]);
|
|
24
51
|
const flexWrap = typeof wrap === "boolean" ? (wrap ? "wrap" : "nowrap") : wrap;
|
|
25
|
-
|
|
26
|
-
|
|
52
|
+
const flexClasses = clsx(styles.flex, styles[`direction-${direction}`], justify && styles[`justify-${justify}`], align && styles[`align-${align}`], className);
|
|
53
|
+
return (_jsx(Component, Object.assign({ className: flexClasses, style: Object.assign({ gap: resolveGap(gap), flexWrap }, style) }, props, { children: children })));
|
|
27
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* A specialized Flex container explicitly optimized for vertical stacking.
|
|
57
|
+
* Use this for lists, form fields, card content, or any group of elements
|
|
58
|
+
* that should be arranged vertically with consistent spacing.
|
|
59
|
+
* Note: While it defaults to column, `direction="row"` is supported for semantic overrides.
|
|
60
|
+
*/
|
|
28
61
|
export function Stack(_a) {
|
|
29
|
-
var { children, direction = "column", gap =
|
|
62
|
+
var { children, direction = "column", gap = 4, align = "stretch" } = _a, props = __rest(_a, ["children", "direction", "gap", "align"]);
|
|
30
63
|
return (_jsx(Flex, Object.assign({ direction: direction, gap: gap, align: align }, props, { children: children })));
|
|
31
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* A responsive layout component that switches from horizontal to vertical layout
|
|
67
|
+
* based on a container query or breakpoint threshold.
|
|
68
|
+
* Use this for "sidebar + main content" layouts or any pattern that needs
|
|
69
|
+
* to stack on smaller screens but sit side-by-side on larger ones.
|
|
70
|
+
*/
|
|
32
71
|
export function Switcher(_a) {
|
|
33
72
|
var { children, threshold = "xs", className } = _a, props = __rest(_a, ["children", "threshold", "className"]);
|
|
34
|
-
|
|
73
|
+
const switcherClasses = clsx(styles.switcher, styles[`switch-${threshold}`], className);
|
|
74
|
+
return (_jsx(Flex, Object.assign({ className: switcherClasses }, props, { children: children })));
|
|
35
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A specific layout component for centering content horizontally on the page.
|
|
78
|
+
* Use this to constrain the maximum width of your page content or sections,
|
|
79
|
+
* ensuring consistent margins and readability on large screens.
|
|
80
|
+
*/
|
|
36
81
|
export function Container(_a) {
|
|
37
82
|
var { children, maxWidth = "xl", className, as: Component = "div" } = _a, props = __rest(_a, ["children", "maxWidth", "className", "as"]);
|
|
38
|
-
|
|
83
|
+
const containerClasses = clsx(styles.container, styles[maxWidth], className);
|
|
84
|
+
return (_jsx(Component, Object.assign({ className: containerClasses }, props, { children: children })));
|
|
39
85
|
}
|
|
@@ -6,6 +6,66 @@
|
|
|
6
6
|
display: flex;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.direction-row {
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.direction-column {
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.direction-row-reverse {
|
|
18
|
+
flex-direction: row-reverse;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.direction-column-reverse {
|
|
22
|
+
flex-direction: column-reverse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.justify-flex-start {
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.justify-flex-end {
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.justify-center {
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.justify-space-between {
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.justify-space-around {
|
|
42
|
+
justify-content: space-around;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.justify-space-evenly {
|
|
46
|
+
justify-content: space-evenly;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.align-flex-start {
|
|
50
|
+
align-items: flex-start;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.align-flex-end {
|
|
54
|
+
align-items: flex-end;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.align-center {
|
|
58
|
+
align-items: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.align-stretch {
|
|
62
|
+
align-items: stretch;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.align-baseline {
|
|
66
|
+
align-items: baseline;
|
|
67
|
+
}
|
|
68
|
+
|
|
9
69
|
.container {
|
|
10
70
|
width: 100%;
|
|
11
71
|
margin-left: auto;
|
|
@@ -31,29 +91,28 @@
|
|
|
31
91
|
|
|
32
92
|
.switcher {
|
|
33
93
|
display: flex;
|
|
34
|
-
flex-direction: row;
|
|
35
94
|
}
|
|
36
95
|
@media (max-width: 360px) {
|
|
37
96
|
.switcher.switch-xxs {
|
|
38
97
|
flex-direction: column;
|
|
39
|
-
align-items: flex-start
|
|
98
|
+
align-items: flex-start;
|
|
40
99
|
}
|
|
41
100
|
}
|
|
42
101
|
@media (max-width: 480px) {
|
|
43
102
|
.switcher.switch-xs {
|
|
44
103
|
flex-direction: column;
|
|
45
|
-
align-items: flex-start
|
|
104
|
+
align-items: flex-start;
|
|
46
105
|
}
|
|
47
106
|
}
|
|
48
107
|
@media (max-width: 640px) {
|
|
49
108
|
.switcher.switch-sm {
|
|
50
109
|
flex-direction: column;
|
|
51
|
-
align-items: flex-start
|
|
110
|
+
align-items: flex-start;
|
|
52
111
|
}
|
|
53
112
|
}
|
|
54
113
|
@media (max-width: 768px) {
|
|
55
114
|
.switcher.switch-md {
|
|
56
115
|
flex-direction: column;
|
|
57
|
-
align-items: flex-start
|
|
116
|
+
align-items: flex-start;
|
|
58
117
|
}
|
|
59
118
|
}
|
|
@@ -31,7 +31,7 @@ export function ModalBody({ children, className, }) {
|
|
|
31
31
|
return _jsx("div", { className: clsx(styles.body, className), children: children });
|
|
32
32
|
}
|
|
33
33
|
export function ModalFooter({ children, className, }) {
|
|
34
|
-
return (_jsx(Flex, { justify: "flex-end", align: "center", gap:
|
|
34
|
+
return (_jsx(Flex, { justify: "flex-end", align: "center", gap: 4, className: clsx(styles.footer, className), children: children }));
|
|
35
35
|
}
|
|
36
36
|
export function Modal(_a) {
|
|
37
37
|
var { isOpen, onClose, title, children, footer, className, style, variant = "default" } = _a, props = __rest(_a, ["isOpen", "onClose", "title", "children", "footer", "className", "style", "variant"]);
|
|
@@ -22,6 +22,6 @@ export const Slat = React.forwardRef((_a, ref) => {
|
|
|
22
22
|
e.preventDefault();
|
|
23
23
|
onClick(e);
|
|
24
24
|
}
|
|
25
|
-
} }, props, { children: _jsxs(Flex, { justify: "space-between", align: "center", gap:
|
|
25
|
+
} }, props, { children: _jsxs(Flex, { justify: "space-between", align: "center", gap: 2, children: [_jsxs(Flex, { gap: 2, align: "center", style: { flex: 1, minWidth: 0 }, children: [prependContent && (_jsx("div", { className: styles.prepend, children: prependContent })), _jsxs(Stack, { gap: 0, style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { className: styles.label, children: label }), secondaryLabel && (_jsx(Text, { variant: "small", className: styles.secondaryLabel, children: secondaryLabel }))] })] }), _jsx(Flex, { align: "center", gap: 2, children: appendContent && (_jsx("div", { className: styles.append, children: appendContent })) })] }) })));
|
|
26
26
|
});
|
|
27
27
|
Slat.displayName = "Slat";
|
|
@@ -45,7 +45,7 @@ export function Table({ data, columns, enablePagination = true, enableFiltering
|
|
|
45
45
|
overscan: 5,
|
|
46
46
|
});
|
|
47
47
|
const isVirtual = !!height;
|
|
48
|
-
return (_jsxs("div", { className: clsx(styles.container, variant === "flat" && styles.flat, className), style: style, children: [enableFiltering && (_jsxs("div", { className: styles.toolbar, children: [_jsx("div", { style: { width: "300px" }, children: _jsx(Input, { placeholder: "Search...", value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : "", onChange: (e) => setGlobalFilter(e.target.value) }) }), toolbarContent && (_jsx(Flex, { gap:
|
|
48
|
+
return (_jsxs("div", { className: clsx(styles.container, variant === "flat" && styles.flat, className), style: style, children: [enableFiltering && (_jsxs("div", { className: styles.toolbar, children: [_jsx("div", { style: { width: "300px" }, children: _jsx(Input, { placeholder: "Search...", value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : "", onChange: (e) => setGlobalFilter(e.target.value) }) }), toolbarContent && (_jsx(Flex, { gap: 4, align: "center", children: toolbarContent }))] })), _jsxs("div", { ref: parentRef, tabIndex: 0, style: {
|
|
49
49
|
height: height ? height : "auto",
|
|
50
50
|
overflowY: height ? "auto" : "visible",
|
|
51
51
|
overflowX: "auto",
|
|
@@ -68,7 +68,7 @@ export function Table({ data, columns, enablePagination = true, enableFiltering
|
|
|
68
68
|
}), rowVirtualizer.getVirtualItems().length > 0 && (_jsx("tr", { style: {
|
|
69
69
|
height: `${rowVirtualizer.getTotalSize() -
|
|
70
70
|
rowVirtualizer.getVirtualItems()[rowVirtualizer.getVirtualItems().length - 1].end}px`,
|
|
71
|
-
}, children: _jsx("td", { colSpan: columns.length, style: { border: 0, padding: 0 } }) }))] })) : (_jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx("tr", { className: clsx(styles.tr, striped && styles.striped, "group"), children: row.getVisibleCells().map((cell) => (_jsx("td", { className: clsx(styles.td, styles[density]), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) }))] }), table.getRowModel().rows.length === 0 && (_jsx("div", { className: styles.noResults, children: "No results found." }))] }), enablePagination && !isVirtual && (_jsx("div", { className: styles.paginationContainer, children: _jsxs(Flex, { gap:
|
|
71
|
+
}, children: _jsx("td", { colSpan: columns.length, style: { border: 0, padding: 0 } }) }))] })) : (_jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx("tr", { className: clsx(styles.tr, striped && styles.striped, "group"), children: row.getVisibleCells().map((cell) => (_jsx("td", { className: clsx(styles.td, styles[density]), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) }))] }), table.getRowModel().rows.length === 0 && (_jsx("div", { className: styles.noResults, children: "No results found." }))] }), enablePagination && !isVirtual && (_jsx("div", { className: styles.paginationContainer, children: _jsxs(Flex, { gap: 4, align: "center", style: { width: "100%", justifyContent: "space-between" }, children: [_jsx("div", { style: { flexShrink: 0 }, children: _jsx(Select, { value: table.getState().pagination.pageSize, onChange: (e) => {
|
|
72
72
|
table.setPageSize(Number(e.target.value));
|
|
73
73
|
}, options: [
|
|
74
74
|
{ value: 10, label: "10 rows" },
|