@giddaa-housing/ui 1.2.0 → 2.0.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/css/generated/shared.css +1 -1
- package/dist/badge.js +1 -1
- package/dist/dialog-nesting.d.ts +9 -0
- package/dist/dialog-nesting.js +27 -0
- package/dist/dialog.js +9 -5
- package/dist/file-upload.d.ts +43 -0
- package/dist/file-upload.js +154 -0
- package/dist/input-otp.d.ts +23 -0
- package/dist/input-otp.js +56 -0
- package/dist/sheet.d.ts +4 -2
- package/dist/sheet.js +22 -11
- package/dist/styles.css +326 -100
- package/dist/tabs.d.ts +10 -4
- package/dist/tabs.js +14 -10
- package/package.json +9 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CircularProgressProps, ProgressProps } from "./progress.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/file-upload.d.ts
|
|
4
|
+
type FileUploadState = "pending" | "uploading" | "complete" | "error";
|
|
5
|
+
type FileUploadContextValue = {
|
|
6
|
+
state: FileUploadState;
|
|
7
|
+
value: number;
|
|
8
|
+
};
|
|
9
|
+
declare function useFileUpload(): FileUploadContextValue;
|
|
10
|
+
type FileUploadProps = ComponentProps<"div"> & {
|
|
11
|
+
state?: FileUploadState;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
declare function FileUpload({ className, state, value, "aria-busy": ariaBusy, ...props }: FileUploadProps): import("react").JSX.Element;
|
|
15
|
+
declare function FileUploadPreview({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
16
|
+
declare function FileUploadImage({ className, alt, ...props }: ComponentProps<"img">): import("react").JSX.Element;
|
|
17
|
+
declare function FileUploadOverlay({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
18
|
+
declare function FileUploadPreviewAction({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
19
|
+
declare function FileUploadIcon({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
20
|
+
declare function FileUploadContent({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
21
|
+
declare function FileUploadHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
22
|
+
declare function FileUploadName({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
23
|
+
declare function FileUploadMeta({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
24
|
+
type FileUploadStatusProps = Omit<ComponentProps<"output">, "children"> & {
|
|
25
|
+
children?: ReactNode | ((context: FileUploadContextValue) => ReactNode);
|
|
26
|
+
pendingLabel?: ReactNode;
|
|
27
|
+
uploadingLabel?: ReactNode;
|
|
28
|
+
completeLabel?: ReactNode;
|
|
29
|
+
errorLabel?: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
declare function FileUploadStatus({ className, children, pendingLabel, uploadingLabel, completeLabel, errorLabel, ...props }: FileUploadStatusProps): import("react").JSX.Element;
|
|
32
|
+
type FileUploadProgressProps = Omit<ProgressProps, "value"> & {
|
|
33
|
+
showValue?: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare function FileUploadProgress({ className, children, showValue, "aria-label": ariaLabel, ...props }: FileUploadProgressProps): import("react").JSX.Element;
|
|
36
|
+
type FileUploadCircularProgressProps = Omit<CircularProgressProps, "value">;
|
|
37
|
+
declare function FileUploadCircularProgress({ className, labelOverlay, "aria-label": ariaLabel, ...props }: FileUploadCircularProgressProps): import("react").JSX.Element;
|
|
38
|
+
type FileUploadCancelProps = ComponentProps<"button"> & {
|
|
39
|
+
variant?: "ghost" | "surface";
|
|
40
|
+
};
|
|
41
|
+
declare function FileUploadCancel({ className, type, children, variant, "aria-label": ariaLabel, ...props }: FileUploadCancelProps): import("react").JSX.Element;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { FileUpload, FileUploadCancel, type FileUploadCancelProps, FileUploadCircularProgress, type FileUploadCircularProgressProps, FileUploadContent, type FileUploadContextValue, FileUploadHeader, FileUploadIcon, FileUploadImage, FileUploadMeta, FileUploadName, FileUploadOverlay, FileUploadPreview, FileUploadPreviewAction, FileUploadProgress, type FileUploadProgressProps, type FileUploadProps, type FileUploadState, FileUploadStatus, type FileUploadStatusProps, useFileUpload };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { CircularProgress, Progress, ProgressValue } from "./progress.js";
|
|
4
|
+
import { File, X } from "lucide-react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
//#region src/file-upload.tsx
|
|
8
|
+
const FileUploadContext = createContext(null);
|
|
9
|
+
function normalizeProgress(value) {
|
|
10
|
+
if (!Number.isFinite(value)) return 0;
|
|
11
|
+
return Math.min(100, Math.max(0, Math.round(value)));
|
|
12
|
+
}
|
|
13
|
+
function useFileUpload() {
|
|
14
|
+
const context = useContext(FileUploadContext);
|
|
15
|
+
if (!context) throw new Error("FileUpload compound components must be rendered inside <FileUpload>.");
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
function FileUpload({ className, state = "uploading", value, "aria-busy": ariaBusy, ...props }) {
|
|
19
|
+
const progress = normalizeProgress(value);
|
|
20
|
+
return /* @__PURE__ */ jsx(FileUploadContext.Provider, {
|
|
21
|
+
value: {
|
|
22
|
+
state,
|
|
23
|
+
value: progress
|
|
24
|
+
},
|
|
25
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
26
|
+
"data-slot": "file-upload",
|
|
27
|
+
"data-state": state,
|
|
28
|
+
"data-value": progress,
|
|
29
|
+
"aria-busy": ariaBusy ?? (state === "uploading" || void 0),
|
|
30
|
+
className: cn("group/file-upload relative flex min-w-0 items-start gap-3 rounded-xl border border-line bg-surface p-3", "data-[state=error]:border-line-danger data-[state=error]:bg-surface-danger-subtle", className),
|
|
31
|
+
...props
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function FileUploadPreview({ className, ...props }) {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
"data-slot": "file-upload-preview",
|
|
38
|
+
className: cn("relative flex size-20 shrink-0 items-center justify-center rounded-lg bg-surface-raised", className),
|
|
39
|
+
...props
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function FileUploadImage({ className, alt = "", ...props }) {
|
|
43
|
+
return /* @__PURE__ */ jsx("img", {
|
|
44
|
+
"data-slot": "file-upload-image",
|
|
45
|
+
className: cn("size-full rounded-[inherit] object-cover", className),
|
|
46
|
+
alt,
|
|
47
|
+
...props
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function FileUploadOverlay({ className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx("div", {
|
|
52
|
+
"data-slot": "file-upload-overlay",
|
|
53
|
+
className: cn("absolute inset-0 flex items-center justify-center rounded-[inherit] bg-black/45", className),
|
|
54
|
+
...props
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function FileUploadPreviewAction({ className, ...props }) {
|
|
58
|
+
return /* @__PURE__ */ jsx("div", {
|
|
59
|
+
"data-slot": "file-upload-preview-action",
|
|
60
|
+
className: cn("absolute -top-2 -right-2 z-10", className),
|
|
61
|
+
...props
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function FileUploadIcon({ className, children, ...props }) {
|
|
65
|
+
return /* @__PURE__ */ jsx("div", {
|
|
66
|
+
"data-slot": "file-upload-icon",
|
|
67
|
+
className: cn("flex size-11 shrink-0 items-center justify-center rounded-lg bg-surface-brand-subtle text-fg-brand", "group-data-[state=error]/file-upload:bg-surface-danger-subtle group-data-[state=error]/file-upload:text-status-danger", className),
|
|
68
|
+
...props,
|
|
69
|
+
children: children ?? /* @__PURE__ */ jsx(File, {
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
className: "size-5"
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function FileUploadContent({ className, ...props }) {
|
|
76
|
+
return /* @__PURE__ */ jsx("div", {
|
|
77
|
+
"data-slot": "file-upload-content",
|
|
78
|
+
className: cn("min-w-0 flex-1", className),
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function FileUploadHeader({ className, ...props }) {
|
|
83
|
+
return /* @__PURE__ */ jsx("div", {
|
|
84
|
+
"data-slot": "file-upload-header",
|
|
85
|
+
className: cn("flex min-w-0 items-center gap-2", className),
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function FileUploadName({ className, ...props }) {
|
|
90
|
+
return /* @__PURE__ */ jsx("p", {
|
|
91
|
+
"data-slot": "file-upload-name",
|
|
92
|
+
className: cn("min-w-0 flex-1 truncate text-gdt-sm font-semibold leading-snug text-fg-primary", className),
|
|
93
|
+
...props
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function FileUploadMeta({ className, ...props }) {
|
|
97
|
+
return /* @__PURE__ */ jsx("p", {
|
|
98
|
+
"data-slot": "file-upload-meta",
|
|
99
|
+
className: cn("mt-0.5 text-gdt-xs leading-snug text-fg-secondary", className),
|
|
100
|
+
...props
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function FileUploadStatus({ className, children, pendingLabel = "Waiting to upload", uploadingLabel, completeLabel = "Upload complete", errorLabel = "Upload failed", ...props }) {
|
|
104
|
+
const context = useFileUpload();
|
|
105
|
+
const defaultLabels = {
|
|
106
|
+
pending: pendingLabel,
|
|
107
|
+
uploading: uploadingLabel ?? `${context.value}% uploaded`,
|
|
108
|
+
complete: completeLabel,
|
|
109
|
+
error: errorLabel
|
|
110
|
+
};
|
|
111
|
+
const content = typeof children === "function" ? children(context) : children ?? defaultLabels[context.state];
|
|
112
|
+
return /* @__PURE__ */ jsx("output", {
|
|
113
|
+
"data-slot": "file-upload-status",
|
|
114
|
+
"aria-live": "polite",
|
|
115
|
+
className: cn("text-gdt-xs leading-snug text-fg-secondary", "group-data-[state=complete]/file-upload:text-status-success group-data-[state=error]/file-upload:text-status-danger", className),
|
|
116
|
+
...props,
|
|
117
|
+
children: content
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function FileUploadProgress({ className, children, showValue = true, "aria-label": ariaLabel = "Upload progress", ...props }) {
|
|
121
|
+
const { state, value } = useFileUpload();
|
|
122
|
+
return /* @__PURE__ */ jsx(Progress, {
|
|
123
|
+
value,
|
|
124
|
+
"aria-label": ariaLabel,
|
|
125
|
+
className: cn("mt-2", state === "complete" && "[&_[data-slot=progress-indicator]]:bg-status-success", state === "error" && "[&_[data-slot=progress-indicator]]:bg-status-danger", className),
|
|
126
|
+
...props,
|
|
127
|
+
children: children ?? (showValue ? /* @__PURE__ */ jsx(ProgressValue, {}) : null)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function FileUploadCircularProgress({ className, labelOverlay = true, "aria-label": ariaLabel = "Upload progress", ...props }) {
|
|
131
|
+
const { state, value } = useFileUpload();
|
|
132
|
+
return /* @__PURE__ */ jsx(CircularProgress, {
|
|
133
|
+
value,
|
|
134
|
+
labelOverlay,
|
|
135
|
+
"aria-label": ariaLabel,
|
|
136
|
+
className: cn("text-white [&_circle:first-child]:text-white/35 [&_circle:last-child]:text-white", state === "complete" && "[&_circle:last-child]:text-status-success", state === "error" && "[&_circle:last-child]:text-status-danger", className),
|
|
137
|
+
...props
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function FileUploadCancel({ className, type = "button", children, variant = "ghost", "aria-label": ariaLabel = "Cancel upload", ...props }) {
|
|
141
|
+
return /* @__PURE__ */ jsx("button", {
|
|
142
|
+
"data-slot": "file-upload-cancel",
|
|
143
|
+
type,
|
|
144
|
+
"aria-label": ariaLabel,
|
|
145
|
+
className: cn("inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full border border-transparent bg-transparent p-0 text-fg-secondary", "transition-[background-color,border-color,color,box-shadow] hover:bg-surface-raised hover:text-fg-primary focus-visible:border-line-focus focus-visible:outline-none focus-visible:shadow-[0_0_0_2px_var(--color-line-focus)] disabled:pointer-events-none disabled:opacity-50", variant === "surface" && "border-line bg-surface-overlay shadow-sm hover:bg-surface-raised", className),
|
|
146
|
+
...props,
|
|
147
|
+
children: children ?? /* @__PURE__ */ jsx(X, {
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
className: "size-4"
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { FileUpload, FileUploadCancel, FileUploadCircularProgress, FileUploadContent, FileUploadHeader, FileUploadIcon, FileUploadImage, FileUploadMeta, FileUploadName, FileUploadOverlay, FileUploadPreview, FileUploadPreviewAction, FileUploadProgress, FileUploadStatus, useFileUpload };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { n as InputSize } from "./input-CfoEJ8A6.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { OTPField } from "@base-ui/react/otp-field";
|
|
4
|
+
//#region src/input-otp.d.ts
|
|
5
|
+
declare const inputOTPSlotVariants: (props?: ({
|
|
6
|
+
size?: "lg" | "md" | "sm" | "xl" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
type InputOTPProps = Omit<OTPField.Root.Props, "className"> & {
|
|
9
|
+
className?: string;
|
|
10
|
+
size?: InputSize;
|
|
11
|
+
};
|
|
12
|
+
declare function InputOTP({ className, size, ...props }: InputOTPProps): React.JSX.Element;
|
|
13
|
+
declare function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
14
|
+
type InputOTPSlotProps = Omit<OTPField.Input.Props, "className"> & {
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function InputOTPSlot({ className, ...props }: InputOTPSlotProps): React.JSX.Element;
|
|
18
|
+
type InputOTPSeparatorProps = Omit<OTPField.Separator.Props, "className"> & {
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function InputOTPSeparator({ children, className, ...props }: InputOTPSeparatorProps): React.JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { InputOTP, InputOTPGroup, type InputOTPProps, InputOTPSeparator, InputOTPSlot, type InputOTPSlotProps, inputOTPSlotVariants };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { InputSizeProvider, useInputComponentSize } from "./input-size-context.js";
|
|
4
|
+
import { MinusIcon } from "lucide-react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { OTPField } from "@base-ui/react/otp-field";
|
|
8
|
+
//#region src/input-otp.tsx
|
|
9
|
+
const inputOTPSlotVariants = cva("relative flex shrink-0 appearance-none items-center justify-center rounded-full border border-line bg-canvas text-center font-normal text-fg-primary caret-fg-primary outline-none transition-[background-color,border-color,box-shadow,color] placeholder:text-fg-caption-placeholder hover:border-line-strong focus:z-10 focus:border-line-focus focus:inset-ring-1 focus:inset-ring-line-focus data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:border-line-subtle data-disabled:bg-surface data-disabled:text-fg-caption-placeholder aria-invalid:border-line-danger aria-invalid:text-fg-danger aria-invalid:focus:border-line-danger aria-invalid:focus:inset-ring-line-danger data-invalid:border-line-danger data-invalid:text-fg-danger data-invalid:focus:border-line-danger data-invalid:focus:inset-ring-line-danger group-aria-invalid/input-otp:border-line-danger group-aria-invalid/input-otp:text-fg-danger group-aria-invalid/input-otp:focus:border-line-danger group-aria-invalid/input-otp:focus:inset-ring-line-danger", {
|
|
10
|
+
variants: { size: {
|
|
11
|
+
sm: "size-8 text-gdt-xs",
|
|
12
|
+
md: "size-10 text-gdt-sm",
|
|
13
|
+
lg: "size-12 text-gdt-md",
|
|
14
|
+
xl: "size-14 text-gdt-lg"
|
|
15
|
+
} },
|
|
16
|
+
defaultVariants: { size: "md" }
|
|
17
|
+
});
|
|
18
|
+
function InputOTP({ className, size, ...props }) {
|
|
19
|
+
const resolvedSize = useInputComponentSize(size);
|
|
20
|
+
return /* @__PURE__ */ jsx(InputSizeProvider, {
|
|
21
|
+
size: resolvedSize,
|
|
22
|
+
children: /* @__PURE__ */ jsx(OTPField.Root, {
|
|
23
|
+
"data-slot": "input-otp",
|
|
24
|
+
"data-size": resolvedSize,
|
|
25
|
+
className: cn("group/input-otp flex items-center gap-2 data-disabled:cursor-not-allowed data-disabled:opacity-50", className),
|
|
26
|
+
...props
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function InputOTPGroup({ className, ...props }) {
|
|
31
|
+
return /* @__PURE__ */ jsx("div", {
|
|
32
|
+
"data-slot": "input-otp-group",
|
|
33
|
+
"data-size": useInputComponentSize(),
|
|
34
|
+
className: cn("flex items-center rounded-full [&>[data-slot=input-otp-slot]:first-child]:rounded-l-full [&>[data-slot=input-otp-slot]:last-child]:rounded-r-full [&>[data-slot=input-otp-slot]:not(:first-child)]:-ml-px [&>[data-slot=input-otp-slot]]:rounded-none", className),
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function InputOTPSlot({ className, ...props }) {
|
|
39
|
+
const resolvedSize = useInputComponentSize();
|
|
40
|
+
return /* @__PURE__ */ jsx(OTPField.Input, {
|
|
41
|
+
"data-slot": "input-otp-slot",
|
|
42
|
+
"data-size": resolvedSize,
|
|
43
|
+
className: cn(inputOTPSlotVariants({ size: resolvedSize }), className),
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function InputOTPSeparator({ children, className, ...props }) {
|
|
48
|
+
return /* @__PURE__ */ jsx(OTPField.Separator, {
|
|
49
|
+
"data-slot": "input-otp-separator",
|
|
50
|
+
className: cn("flex items-center justify-center px-1 text-fg-secondary [&_svg:not([class*='size-'])]:size-4", className),
|
|
51
|
+
...props,
|
|
52
|
+
children: children ?? /* @__PURE__ */ jsx(MinusIcon, {})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, inputOTPSlotVariants };
|
package/dist/sheet.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare function SheetClose({ ...props }: Dialog.Close.Props): React.JSX.Element
|
|
|
8
8
|
type SheetContentProps = Dialog.Popup.Props & {
|
|
9
9
|
side?: SheetSide;
|
|
10
10
|
showCloseButton?: boolean;
|
|
11
|
+
showOverlay?: boolean;
|
|
11
12
|
} & ({
|
|
12
13
|
side: "top" | "bottom";
|
|
13
14
|
size?: "fullscreen";
|
|
@@ -15,10 +16,11 @@ type SheetContentProps = Dialog.Popup.Props & {
|
|
|
15
16
|
side?: "left" | "right";
|
|
16
17
|
size?: "sm" | "md" | "lg";
|
|
17
18
|
});
|
|
18
|
-
declare function SheetContent({ className, children, side, size, showCloseButton, ...props }: SheetContentProps): React.JSX.Element;
|
|
19
|
+
declare function SheetContent({ className, children, side, size, showCloseButton, showOverlay, ...props }: SheetContentProps): React.JSX.Element;
|
|
19
20
|
declare function SheetHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
21
|
+
declare function SheetBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
20
22
|
declare function SheetFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
21
23
|
declare function SheetTitle({ className, ...props }: Dialog.Title.Props): React.JSX.Element;
|
|
22
24
|
declare function SheetDescription({ className, ...props }: Dialog.Description.Props): React.JSX.Element;
|
|
23
25
|
//#endregion
|
|
24
|
-
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
26
|
+
export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
package/dist/sheet.js
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
3
|
import { SizeProvider } from "./size-context.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
|
+
import { DialogNestingProvider, useDialogNestingDepth } from "./dialog-nesting.js";
|
|
5
6
|
import { XIcon } from "lucide-react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { cva } from "class-variance-authority";
|
|
8
9
|
import { Dialog } from "@base-ui/react/dialog";
|
|
9
10
|
//#region src/sheet.tsx
|
|
10
11
|
function Sheet({ ...props }) {
|
|
11
|
-
return /* @__PURE__ */ jsx(Dialog.Root, {
|
|
12
|
+
return /* @__PURE__ */ jsx(DialogNestingProvider, { children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
12
13
|
"data-slot": "sheet",
|
|
13
14
|
...props
|
|
14
|
-
});
|
|
15
|
+
}) });
|
|
15
16
|
}
|
|
16
17
|
function SheetTrigger({ ...props }) {
|
|
17
18
|
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
@@ -32,13 +33,16 @@ function SheetPortal({ ...props }) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
function SheetOverlay({ className, ...props }) {
|
|
36
|
+
const nested = useDialogNestingDepth() > 1;
|
|
35
37
|
return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
38
|
+
forceRender: true,
|
|
36
39
|
"data-slot": "sheet-overlay",
|
|
37
|
-
|
|
40
|
+
"data-nested": nested || void 0,
|
|
41
|
+
className: cn("fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0", nested ? "bg-black/25" : "bg-black/55 supports-backdrop-filter:backdrop-blur-xl", className),
|
|
38
42
|
...props
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
|
-
const sheetContentVariants = cva("group/sheet-content fixed z-50 flex flex-col gap-0 overflow-visible rounded-2xl border border-line-subtle bg-surface-overlay bg-clip-padding text-fg-primary shadow-(--elevation-e2-shadow) transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 [--sheet-padding-x:1rem] [--sheet-padding-top:1rem] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:w-full data-[side=bottom]:rounded-b-none data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:w-full data-[side=top]:rounded-t-none data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:rounded-l-none data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:rounded-r-none data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem]
|
|
45
|
+
const sheetContentVariants = cva("group/sheet-content fixed z-50 flex flex-col gap-0 overflow-visible rounded-2xl border border-line-subtle bg-surface-overlay bg-clip-padding text-fg-primary shadow-(--elevation-e2-shadow) transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 [--sheet-padding-x:1rem] [--sheet-padding-top:1rem] data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:w-full data-[side=bottom]:rounded-b-none data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:w-full data-[side=top]:rounded-t-none data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:rounded-l-none data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:rounded-r-none data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=bottom]:data-[nested-dialog-open]:translate-y-[calc(var(--nested-dialogs)*-1.5rem)] data-[side=top]:data-[nested-dialog-open]:translate-y-[calc(var(--nested-dialogs)*1.5rem)] data-[side=left]:data-[nested-dialog-open]:translate-x-[calc(var(--nested-dialogs)*1.5rem)] data-[side=right]:data-[nested-dialog-open]:translate-x-[calc(var(--nested-dialogs)*-1.5rem)] data-[side=bottom]:data-[nested-dialog-open]:scale-x-[calc(1_-_var(--nested-dialogs)*0.05)] data-[side=top]:data-[nested-dialog-open]:scale-x-[calc(1_-_var(--nested-dialogs)*0.05)]", {
|
|
42
46
|
variants: { size: {
|
|
43
47
|
sm: "sm:[--sheet-padding-top:1.5rem] sm:[--sheet-padding-x:1.5rem] w-90 max-w-[calc(100vw-2.5rem)] [--sheet-title:var(--text-gdt-h5)]",
|
|
44
48
|
md: "sm:[--sheet-padding-top:1.5rem] sm:[--sheet-padding-x:2rem] xl:[--sheet-padding-x:2.5rem] w-120 max-w-[calc(100vw-2.5rem)] [--sheet-title:var(--text-gdt-h4)]",
|
|
@@ -47,9 +51,9 @@ const sheetContentVariants = cva("group/sheet-content fixed z-50 flex flex-col g
|
|
|
47
51
|
} },
|
|
48
52
|
defaultVariants: { size: "md" }
|
|
49
53
|
});
|
|
50
|
-
function SheetContent({ className, children, side = "left", size = "md", showCloseButton = true, ...props }) {
|
|
54
|
+
function SheetContent({ className, children, side = "left", size = "md", showCloseButton = true, showOverlay = true, ...props }) {
|
|
51
55
|
const resolvedSize = side === "top" || side === "bottom" ? "fullscreen" : size !== "fullscreen" ? size : "md";
|
|
52
|
-
return /* @__PURE__ */ jsxs(SheetPortal, { children: [/* @__PURE__ */ jsx(SheetOverlay, {}), /* @__PURE__ */ jsx(SizeProvider, {
|
|
56
|
+
return /* @__PURE__ */ jsxs(SheetPortal, { children: [showOverlay && /* @__PURE__ */ jsx(SheetOverlay, {}), /* @__PURE__ */ jsx(SizeProvider, {
|
|
53
57
|
size: resolvedSize === "fullscreen" ? "lg" : resolvedSize,
|
|
54
58
|
children: /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
55
59
|
"data-slot": "sheet-content",
|
|
@@ -61,8 +65,8 @@ function SheetContent({ className, children, side = "left", size = "md", showClo
|
|
|
61
65
|
"data-slot": "sheet-close",
|
|
62
66
|
render: /* @__PURE__ */ jsxs(Button, {
|
|
63
67
|
variant: "ghost",
|
|
64
|
-
className: "absolute z-10 size-
|
|
65
|
-
size: "icon-
|
|
68
|
+
className: "absolute z-10 size-7 border border-line bg-surface p-0 text-fg-primary shadow-(--elevation-e1-shadow) hover:bg-surface-raised group-data-[nested-dialog-open]/sheet-content:hidden group-data-[side=bottom]/sheet-content:-top-9 group-data-[side=bottom]/sheet-content:right-4 group-data-[side=top]/sheet-content:-bottom-9 group-data-[side=top]/sheet-content:right-4 group-data-[side=left]/sheet-content:-right-9 group-data-[side=left]/sheet-content:top-4 group-data-[side=right]/sheet-content:-left-9 group-data-[side=right]/sheet-content:top-4",
|
|
69
|
+
size: "icon-xs",
|
|
66
70
|
children: [/* @__PURE__ */ jsx(XIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
67
71
|
className: "sr-only",
|
|
68
72
|
children: "Close"
|
|
@@ -75,14 +79,21 @@ function SheetContent({ className, children, side = "left", size = "md", showClo
|
|
|
75
79
|
function SheetHeader({ className, ...props }) {
|
|
76
80
|
return /* @__PURE__ */ jsx("div", {
|
|
77
81
|
"data-slot": "sheet-header",
|
|
78
|
-
className: cn("flex flex-col gap-1
|
|
82
|
+
className: cn("flex flex-col gap-1 px-(--sheet-padding-x) pt-(--sheet-padding-top) pb-4 border-b border-line-subtle", className),
|
|
83
|
+
...props
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function SheetBody({ className, ...props }) {
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
"data-slot": "sheet-body",
|
|
89
|
+
className: cn("flex-1 overflow-y-auto px-(--sheet-padding-x) py-4", className),
|
|
79
90
|
...props
|
|
80
91
|
});
|
|
81
92
|
}
|
|
82
93
|
function SheetFooter({ className, ...props }) {
|
|
83
94
|
return /* @__PURE__ */ jsx("div", {
|
|
84
95
|
"data-slot": "sheet-footer",
|
|
85
|
-
className: cn("mt-auto flex items-center justify-end gap-2 border-t border-line-subtle
|
|
96
|
+
className: cn("mt-auto flex items-center justify-end gap-2 border-t border-line-subtle px-(--sheet-padding-x) py-4", className),
|
|
86
97
|
...props
|
|
87
98
|
});
|
|
88
99
|
}
|
|
@@ -101,4 +112,4 @@ function SheetDescription({ className, ...props }) {
|
|
|
101
112
|
});
|
|
102
113
|
}
|
|
103
114
|
//#endregion
|
|
104
|
-
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
115
|
+
export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|