@giddaa-housing/ui 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/dist/badge.js +1 -1
- package/dist/card.d.ts +4 -2
- package/dist/card.js +7 -7
- package/dist/combobox.d.ts +48 -1
- package/dist/combobox.js +77 -4
- package/dist/data-table.js +1 -1
- package/dist/date-picker.d.ts +5 -2
- package/dist/date-picker.js +11 -6
- 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/infinite-scroll.d.ts +40 -0
- package/dist/infinite-scroll.js +125 -0
- package/dist/input-otp.d.ts +23 -0
- package/dist/input-otp.js +56 -0
- package/dist/picker-xSTzeYhc.js +50 -0
- package/dist/popover.d.ts +2 -2
- package/dist/popover.js +2 -1
- package/dist/sheet.d.ts +4 -2
- package/dist/sheet.js +22 -11
- package/dist/styles.css +357 -106
- package/dist/table.js +2 -2
- package/dist/tabs.d.ts +10 -4
- package/dist/tabs.js +16 -12
- package/dist/time-picker.d.ts +4 -1
- package/dist/time-picker.js +8 -5
- package/package.json +14 -1
- package/dist/picker-lzgmsNfG.js +0 -32
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { Loader2 } from "lucide-react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
//#region src/lib/use-intersection.ts
|
|
7
|
+
function useIntersection(options) {
|
|
8
|
+
const [entry, setEntry] = useState(null);
|
|
9
|
+
const observer = useRef(null);
|
|
10
|
+
return {
|
|
11
|
+
ref: useCallback((element) => {
|
|
12
|
+
if (observer.current) {
|
|
13
|
+
observer.current.disconnect();
|
|
14
|
+
observer.current = null;
|
|
15
|
+
}
|
|
16
|
+
if (element === null) {
|
|
17
|
+
setEntry(null);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
21
|
+
setEntry(null);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
observer.current = new IntersectionObserver(([_entry]) => {
|
|
25
|
+
setEntry(_entry ?? null);
|
|
26
|
+
}, options);
|
|
27
|
+
observer.current.observe(element);
|
|
28
|
+
}, [options]),
|
|
29
|
+
entry
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/infinite-scroll.tsx
|
|
34
|
+
const InfiniteScrollContext = createContext(null);
|
|
35
|
+
function useInfiniteScrollContext(consumer) {
|
|
36
|
+
const context = useContext(InfiniteScrollContext);
|
|
37
|
+
if (!context) throw new Error(`${consumer} must be used within <InfiniteScroll>`);
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
function useInfiniteScrollSentinel({ hasNextPage, isFetchingNextPage, fetchNextPage, rootMargin = "200px" }) {
|
|
41
|
+
const { ref, entry } = useIntersection(useMemo(() => ({ rootMargin }), [rootMargin]));
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (entry?.isIntersecting && hasNextPage && !isFetchingNextPage) fetchNextPage();
|
|
44
|
+
}, [
|
|
45
|
+
entry?.isIntersecting,
|
|
46
|
+
hasNextPage,
|
|
47
|
+
isFetchingNextPage,
|
|
48
|
+
fetchNextPage
|
|
49
|
+
]);
|
|
50
|
+
return ref;
|
|
51
|
+
}
|
|
52
|
+
function InfiniteScroll({ children, isLoading, isEmpty, error, hasNextPage, isFetchingNextPage, fetchNextPage }) {
|
|
53
|
+
const value = useMemo(() => ({
|
|
54
|
+
isLoading,
|
|
55
|
+
isEmpty,
|
|
56
|
+
error,
|
|
57
|
+
hasNextPage,
|
|
58
|
+
isFetchingNextPage,
|
|
59
|
+
fetchNextPage
|
|
60
|
+
}), [
|
|
61
|
+
isLoading,
|
|
62
|
+
isEmpty,
|
|
63
|
+
error,
|
|
64
|
+
hasNextPage,
|
|
65
|
+
isFetchingNextPage,
|
|
66
|
+
fetchNextPage
|
|
67
|
+
]);
|
|
68
|
+
return /* @__PURE__ */ jsx(InfiniteScrollContext.Provider, {
|
|
69
|
+
value,
|
|
70
|
+
children
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function DefaultLoader({ label }) {
|
|
74
|
+
return /* @__PURE__ */ jsxs("output", {
|
|
75
|
+
"aria-live": "polite",
|
|
76
|
+
className: "flex items-center justify-center gap-2 px-4 py-6 text-fg-secondary text-gdt-sm",
|
|
77
|
+
children: [/* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }), /* @__PURE__ */ jsx("span", { children: label })]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function InfiniteScrollLoading({ children }) {
|
|
81
|
+
const { isLoading, isFetchingNextPage } = useInfiniteScrollContext("InfiniteScrollLoading");
|
|
82
|
+
if (!isLoading && !isFetchingNextPage) return null;
|
|
83
|
+
return children ?? /* @__PURE__ */ jsx(DefaultLoader, { label: isFetchingNextPage ? "Loading more..." : "Loading..." });
|
|
84
|
+
}
|
|
85
|
+
function InfiniteScrollContent({ children }) {
|
|
86
|
+
const { isLoading, isEmpty } = useInfiniteScrollContext("InfiniteScrollContent");
|
|
87
|
+
if (isLoading || isEmpty) return null;
|
|
88
|
+
return children;
|
|
89
|
+
}
|
|
90
|
+
function InfiniteScrollEmpty({ children }) {
|
|
91
|
+
const { isLoading, isEmpty, error } = useInfiniteScrollContext("InfiniteScrollEmpty");
|
|
92
|
+
if (isLoading || error || !isEmpty) return null;
|
|
93
|
+
return children;
|
|
94
|
+
}
|
|
95
|
+
function InfiniteScrollError({ children }) {
|
|
96
|
+
const { error } = useInfiniteScrollContext("InfiniteScrollError");
|
|
97
|
+
if (!error) return null;
|
|
98
|
+
return children ?? /* @__PURE__ */ jsx("div", {
|
|
99
|
+
role: "alert",
|
|
100
|
+
className: "px-4 py-4 text-center text-fg-danger text-gdt-sm",
|
|
101
|
+
children: error.message || "Something went wrong while loading more items."
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function InfiniteScrollEnd({ children }) {
|
|
105
|
+
const { isLoading, isEmpty, hasNextPage, error } = useInfiniteScrollContext("InfiniteScrollEnd");
|
|
106
|
+
if (isLoading || isEmpty || hasNextPage || error) return null;
|
|
107
|
+
return children;
|
|
108
|
+
}
|
|
109
|
+
function InfiniteScrollSentinel({ rootMargin, className }) {
|
|
110
|
+
const { hasNextPage, isFetchingNextPage, fetchNextPage } = useInfiniteScrollContext("InfiniteScrollSentinel");
|
|
111
|
+
const ref = useInfiniteScrollSentinel({
|
|
112
|
+
hasNextPage,
|
|
113
|
+
isFetchingNextPage,
|
|
114
|
+
fetchNextPage,
|
|
115
|
+
rootMargin
|
|
116
|
+
});
|
|
117
|
+
if (!hasNextPage) return null;
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
ref,
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
className: cn("h-px", className)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { InfiniteScroll, InfiniteScrollContent, InfiniteScrollEmpty, InfiniteScrollEnd, InfiniteScrollError, InfiniteScrollLoading, InfiniteScrollSentinel, useInfiniteScrollSentinel };
|
|
@@ -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 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
2
|
+
import { Button } from "./button.js";
|
|
3
|
+
import { useInputComponentSize } from "./input-size-context.js";
|
|
4
|
+
import { PopoverTrigger } from "./popover.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
//#region src/lib/picker.tsx
|
|
8
|
+
const PICKER_COLLISION_AVOIDANCE = {
|
|
9
|
+
side: "flip",
|
|
10
|
+
align: "shift",
|
|
11
|
+
fallbackAxisSide: "none"
|
|
12
|
+
};
|
|
13
|
+
const pickerTriggerVariants = cva("flex w-full items-center justify-between rounded-full border transition-[border-color,box-shadow] outline-none", {
|
|
14
|
+
variants: { size: {
|
|
15
|
+
sm: "h-8 px-3 text-gdt-xs [&_svg]:size-3.5",
|
|
16
|
+
md: "h-10 px-3.5 text-gdt-sm [&_svg]:size-4",
|
|
17
|
+
lg: "h-12 px-4 text-gdt-md [&_svg]:size-4.5",
|
|
18
|
+
xl: "h-14 px-4.5 text-gdt-lg [&_svg]:size-5"
|
|
19
|
+
} },
|
|
20
|
+
defaultVariants: { size: "md" }
|
|
21
|
+
});
|
|
22
|
+
function PickerTrigger({ icon: Icon, displayValue, placeholder, disabled, open, size, className }) {
|
|
23
|
+
const resolvedSize = useInputComponentSize(size);
|
|
24
|
+
return /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
25
|
+
disabled,
|
|
26
|
+
"data-size": resolvedSize,
|
|
27
|
+
className: cn(pickerTriggerVariants({ size: resolvedSize }), disabled ? "cursor-not-allowed border-line-subtle bg-surface text-fg-caption-placeholder" : open ? "border-line-focus bg-canvas text-fg-primary inset-ring-1 inset-ring-line-focus" : "border-line bg-canvas text-fg-primary hover:border-line-strong", className),
|
|
28
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
29
|
+
className: cn("min-w-0 truncate", !displayValue && "text-fg-caption-placeholder"),
|
|
30
|
+
children: displayValue || placeholder
|
|
31
|
+
}), /* @__PURE__ */ jsx(Icon, { className: cn("ml-2 shrink-0", disabled ? "text-fg-caption-placeholder" : "text-fg-secondary") })]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function PickerFooter({ secondaryLabel, onSecondary, onApply }) {
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
36
|
+
className: "flex w-full items-center justify-between border-t border-line-subtle px-4 py-3",
|
|
37
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
38
|
+
variant: "tertiary-outline",
|
|
39
|
+
size: "sm",
|
|
40
|
+
onClick: onSecondary,
|
|
41
|
+
children: secondaryLabel
|
|
42
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
43
|
+
size: "sm",
|
|
44
|
+
onClick: onApply,
|
|
45
|
+
children: "Apply"
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { PickerFooter as n, PickerTrigger as r, PICKER_COLLISION_AVOIDANCE as t };
|
package/dist/popover.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
|
4
4
|
//#region src/popover.d.ts
|
|
5
5
|
declare function Popover({ ...props }: Popover$1.Root.Props): React.JSX.Element;
|
|
6
6
|
declare function PopoverTrigger({ ...props }: Popover$1.Trigger.Props): React.JSX.Element;
|
|
7
|
-
type PopoverContentProps = Popover$1.Popup.Props & Pick<Popover$1.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset"> & {
|
|
7
|
+
type PopoverContentProps = Popover$1.Popup.Props & Pick<Popover$1.Positioner.Props, "align" | "alignOffset" | "collisionAvoidance" | "side" | "sideOffset"> & {
|
|
8
8
|
showArrow?: boolean;
|
|
9
9
|
size?: ComponentSize;
|
|
10
10
|
};
|
|
11
|
-
declare function PopoverContent({ className, align, alignOffset, side, sideOffset, showArrow, size, children, ...props }: PopoverContentProps): React.JSX.Element;
|
|
11
|
+
declare function PopoverContent({ className, align, alignOffset, collisionAvoidance, side, sideOffset, showArrow, size, children, ...props }: PopoverContentProps): React.JSX.Element;
|
|
12
12
|
declare function PopoverHeader({ className, border, ...props }: React.ComponentProps<"div"> & {
|
|
13
13
|
border?: boolean;
|
|
14
14
|
}): React.JSX.Element;
|
package/dist/popover.js
CHANGED
|
@@ -16,10 +16,11 @@ function PopoverTrigger({ ...props }) {
|
|
|
16
16
|
...props
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function PopoverContent({ className, align = "center", alignOffset = 0, side = "bottom", sideOffset = 6, showArrow = true, size = "md", children, ...props }) {
|
|
19
|
+
function PopoverContent({ className, align = "center", alignOffset = 0, collisionAvoidance, side = "bottom", sideOffset = 6, showArrow = true, size = "md", children, ...props }) {
|
|
20
20
|
return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(Popover$1.Positioner, {
|
|
21
21
|
align,
|
|
22
22
|
alignOffset,
|
|
23
|
+
collisionAvoidance,
|
|
23
24
|
side,
|
|
24
25
|
sideOffset,
|
|
25
26
|
className: "isolate z-50",
|
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 };
|