xiod-ui 1.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/LICENSE +73 -0
- package/README.md +167 -0
- package/dist/components/accordion.d.ts +9 -0
- package/dist/components/accordion.js +46 -0
- package/dist/components/agent-steps.d.ts +47 -0
- package/dist/components/agent-steps.js +223 -0
- package/dist/components/alert-dialog.d.ts +21 -0
- package/dist/components/alert-dialog.js +74 -0
- package/dist/components/alert.d.ts +12 -0
- package/dist/components/alert.js +45 -0
- package/dist/components/aspect-ratio.d.ts +9 -0
- package/dist/components/aspect-ratio.js +22 -0
- package/dist/components/autocomplete.d.ts +35 -0
- package/dist/components/autocomplete.js +160 -0
- package/dist/components/avatar.d.ts +17 -0
- package/dist/components/avatar.js +65 -0
- package/dist/components/badge.d.ts +15 -0
- package/dist/components/badge.js +46 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.js +75 -0
- package/dist/components/button-group.d.ts +14 -0
- package/dist/components/button-group.js +45 -0
- package/dist/components/button-split.d.ts +19 -0
- package/dist/components/button-split.js +73 -0
- package/dist/components/button.d.ts +15 -0
- package/dist/components/button.js +54 -0
- package/dist/components/calendar.d.ts +63 -0
- package/dist/components/calendar.js +425 -0
- package/dist/components/card.d.ts +17 -0
- package/dist/components/card.js +139 -0
- package/dist/components/carousel.d.ts +59 -0
- package/dist/components/carousel.js +503 -0
- package/dist/components/checkbox.d.ts +16 -0
- package/dist/components/checkbox.js +86 -0
- package/dist/components/circular-progress.d.ts +28 -0
- package/dist/components/circular-progress.js +127 -0
- package/dist/components/collapsible.d.ts +8 -0
- package/dist/components/collapsible.js +27 -0
- package/dist/components/color-picker.d.ts +159 -0
- package/dist/components/color-picker.js +1589 -0
- package/dist/components/combobox.d.ts +46 -0
- package/dist/components/combobox.js +237 -0
- package/dist/components/command.d.ts +22 -0
- package/dist/components/command.js +129 -0
- package/dist/components/context-menu.d.ts +38 -0
- package/dist/components/context-menu.js +164 -0
- package/dist/components/copy-to-clipboard.d.ts +32 -0
- package/dist/components/copy-to-clipboard.js +83 -0
- package/dist/components/corner-badge.d.ts +22 -0
- package/dist/components/corner-badge.js +84 -0
- package/dist/components/dashboard-grid.d.ts +83 -0
- package/dist/components/dashboard-grid.js +486 -0
- package/dist/components/date-picker.d.ts +29 -0
- package/dist/components/date-picker.js +261 -0
- package/dist/components/dialog.d.ts +26 -0
- package/dist/components/dialog.js +97 -0
- package/dist/components/dot-matrix.d.ts +32 -0
- package/dist/components/dot-matrix.js +707 -0
- package/dist/components/draggable.d.ts +42 -0
- package/dist/components/draggable.js +346 -0
- package/dist/components/drawer.d.ts +66 -0
- package/dist/components/drawer.js +304 -0
- package/dist/components/empty.d.ts +14 -0
- package/dist/components/empty.js +75 -0
- package/dist/components/field.d.ts +12 -0
- package/dist/components/field.js +44 -0
- package/dist/components/fieldset.d.ts +7 -0
- package/dist/components/fieldset.js +21 -0
- package/dist/components/file-upload.d.ts +61 -0
- package/dist/components/file-upload.js +482 -0
- package/dist/components/form.d.ts +6 -0
- package/dist/components/form.js +14 -0
- package/dist/components/frame.d.ts +10 -0
- package/dist/components/frame.js +47 -0
- package/dist/components/gauge.d.ts +27 -0
- package/dist/components/gauge.js +74 -0
- package/dist/components/grid.d.ts +26 -0
- package/dist/components/grid.js +204 -0
- package/dist/components/group.d.ts +19 -0
- package/dist/components/group.js +45 -0
- package/dist/components/input-group.d.ts +15 -0
- package/dist/components/input-group.js +61 -0
- package/dist/components/input-otp.d.ts +24 -0
- package/dist/components/input-otp.js +50 -0
- package/dist/components/input-payment.d.ts +131 -0
- package/dist/components/input-payment.js +1140 -0
- package/dist/components/input-phone.d.ts +70 -0
- package/dist/components/input-phone.js +657 -0
- package/dist/components/input-sensitive.d.ts +12 -0
- package/dist/components/input-sensitive.js +169 -0
- package/dist/components/input.d.ts +13 -0
- package/dist/components/input.js +26 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +19 -0
- package/dist/components/kinetic-click.d.ts +48 -0
- package/dist/components/kinetic-click.js +1184 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +18 -0
- package/dist/components/list-box.d.ts +20 -0
- package/dist/components/list-box.js +148 -0
- package/dist/components/loader.d.ts +13 -0
- package/dist/components/loader.js +430 -0
- package/dist/components/marker.d.ts +15 -0
- package/dist/components/marker.js +59 -0
- package/dist/components/menu.d.ts +42 -0
- package/dist/components/menu.js +186 -0
- package/dist/components/menubar.d.ts +40 -0
- package/dist/components/menubar.js +107 -0
- package/dist/components/message.d.ts +33 -0
- package/dist/components/message.js +112 -0
- package/dist/components/meter.d.ts +10 -0
- package/dist/components/meter.js +42 -0
- package/dist/components/morphic-toast.d.ts +61 -0
- package/dist/components/morphic-toast.js +916 -0
- package/dist/components/navigation-menu.d.ts +26 -0
- package/dist/components/navigation-menu.js +116 -0
- package/dist/components/number-field.d.ts +15 -0
- package/dist/components/number-field.js +86 -0
- package/dist/components/option-picker.d.ts +18 -0
- package/dist/components/option-picker.js +89 -0
- package/dist/components/orb.d.ts +38 -0
- package/dist/components/orb.js +1413 -0
- package/dist/components/pagination.d.ts +25 -0
- package/dist/components/pagination.js +147 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +79 -0
- package/dist/components/preview-card.d.ts +16 -0
- package/dist/components/preview-card.js +60 -0
- package/dist/components/progress.d.ts +21 -0
- package/dist/components/progress.js +139 -0
- package/dist/components/radio.d.ts +16 -0
- package/dist/components/radio.js +68 -0
- package/dist/components/resizable.d.ts +58 -0
- package/dist/components/resizable.js +964 -0
- package/dist/components/ruler-picker.d.ts +27 -0
- package/dist/components/ruler-picker.js +253 -0
- package/dist/components/scroll-area.d.ts +13 -0
- package/dist/components/scroll-area.js +34 -0
- package/dist/components/scroll-bar.d.ts +13 -0
- package/dist/components/scroll-bar.js +47 -0
- package/dist/components/select.d.ts +29 -0
- package/dist/components/select.js +140 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +15 -0
- package/dist/components/sidebar.d.ts +65 -0
- package/dist/components/sidebar.js +408 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.js +12 -0
- package/dist/components/slider.d.ts +12 -0
- package/dist/components/slider.js +96 -0
- package/dist/components/sortable.d.ts +44 -0
- package/dist/components/sortable.js +327 -0
- package/dist/components/switch.d.ts +15 -0
- package/dist/components/switch.js +63 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +65 -0
- package/dist/components/tabs.d.ts +12 -0
- package/dist/components/tabs.js +39 -0
- package/dist/components/text.d.ts +14 -0
- package/dist/components/text.js +69 -0
- package/dist/components/textarea.d.ts +9 -0
- package/dist/components/textarea.js +20 -0
- package/dist/components/theme-provider.d.ts +52 -0
- package/dist/components/theme-provider.js +148 -0
- package/dist/components/timeline.d.ts +34 -0
- package/dist/components/timeline.js +147 -0
- package/dist/components/toast.d.ts +17 -0
- package/dist/components/toast.js +161 -0
- package/dist/components/toggle-group.d.ts +14 -0
- package/dist/components/toggle-group.js +53 -0
- package/dist/components/toggle.d.ts +11 -0
- package/dist/components/toggle.js +36 -0
- package/dist/components/toolbar.d.ts +11 -0
- package/dist/components/toolbar.js +49 -0
- package/dist/components/tooltip.d.ts +17 -0
- package/dist/components/tooltip.js +56 -0
- package/dist/components/waveform.d.ts +61 -0
- package/dist/components/waveform.js +500 -0
- package/dist/components/wheel-picker.d.ts +44 -0
- package/dist/components/wheel-picker.js +771 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.js +36 -0
- package/dist/hooks/use-media-query.d.ts +21 -0
- package/dist/hooks/use-media-query.js +58 -0
- package/dist/styles.css +202 -0
- package/dist/themes/afterglow.css +89 -0
- package/dist/themes/afterglow.scoped.css +90 -0
- package/dist/themes/blacklight.css +89 -0
- package/dist/themes/blacklight.scoped.css +90 -0
- package/dist/themes/cathode.css +89 -0
- package/dist/themes/cathode.scoped.css +90 -0
- package/dist/themes/cel.css +89 -0
- package/dist/themes/cel.scoped.css +90 -0
- package/dist/themes/cinder.css +89 -0
- package/dist/themes/cinder.scoped.css +90 -0
- package/dist/themes/clay.css +89 -0
- package/dist/themes/clay.scoped.css +90 -0
- package/dist/themes/cobalt.css +89 -0
- package/dist/themes/cobalt.scoped.css +90 -0
- package/dist/themes/crimson.css +89 -0
- package/dist/themes/crimson.scoped.css +90 -0
- package/dist/themes/ion.css +89 -0
- package/dist/themes/ion.scoped.css +90 -0
- package/dist/themes/iris.css +89 -0
- package/dist/themes/iris.scoped.css +90 -0
- package/dist/themes/lagoon.css +89 -0
- package/dist/themes/lagoon.scoped.css +90 -0
- package/dist/themes/mochi.css +89 -0
- package/dist/themes/mochi.scoped.css +90 -0
- package/dist/themes/riso.css +89 -0
- package/dist/themes/riso.scoped.css +90 -0
- package/dist/themes/roast.css +89 -0
- package/dist/themes/roast.scoped.css +90 -0
- package/dist/themes/sage.css +89 -0
- package/dist/themes/sage.scoped.css +90 -0
- package/dist/themes/sepia.css +89 -0
- package/dist/themes/sepia.scoped.css +90 -0
- package/dist/themes/sorbet.css +89 -0
- package/dist/themes/sorbet.scoped.css +90 -0
- package/dist/themes/taffy.css +89 -0
- package/dist/themes/taffy.scoped.css +90 -0
- package/dist/themes/toxin.css +89 -0
- package/dist/themes/toxin.scoped.css +90 -0
- package/package.json +140 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
//#region src/components/draggable.d.ts
|
|
5
|
+
export type DraggableBounds = "viewport" | "parent" | "none";
|
|
6
|
+
export declare const draggableVariants: (props?: ({
|
|
7
|
+
variant?: "default" | "expressive" | "flat" | null | undefined;
|
|
8
|
+
isDragging?: boolean | null | undefined;
|
|
9
|
+
isResizing?: boolean | null | undefined;
|
|
10
|
+
isMinimized?: boolean | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
12
|
+
export interface DraggableProps extends useRender.ComponentProps<"div">, VariantProps<typeof draggableVariants> {
|
|
13
|
+
defaultX?: number;
|
|
14
|
+
defaultY?: number;
|
|
15
|
+
defaultWidth?: number;
|
|
16
|
+
defaultHeight?: number;
|
|
17
|
+
minWidth?: number;
|
|
18
|
+
minHeight?: number;
|
|
19
|
+
maxWidth?: number;
|
|
20
|
+
maxHeight?: number;
|
|
21
|
+
bounds?: DraggableBounds;
|
|
22
|
+
isDraggable?: boolean;
|
|
23
|
+
isResizable?: boolean;
|
|
24
|
+
open?: boolean;
|
|
25
|
+
defaultOpen?: boolean;
|
|
26
|
+
onOpenChange?: (open: boolean) => void;
|
|
27
|
+
}
|
|
28
|
+
declare function Draggable({ className, variant, defaultX, defaultY, defaultWidth, defaultHeight, minWidth, minHeight, maxWidth, maxHeight, bounds, isDraggable, isResizable, open: controlledOpen, defaultOpen, onOpenChange, render, children, ...props }: DraggableProps): React$1.ReactElement | null;
|
|
29
|
+
export interface DraggableHeaderProps extends useRender.ComponentProps<"div"> {}
|
|
30
|
+
declare function DraggableHeader({ className, render, children, ...props }: DraggableHeaderProps): React$1.ReactElement;
|
|
31
|
+
export interface DraggableTitleProps extends useRender.ComponentProps<"span"> {}
|
|
32
|
+
declare function DraggableTitle({ className, render, children, ...props }: DraggableTitleProps): React$1.ReactElement;
|
|
33
|
+
export interface DraggableControlsProps extends useRender.ComponentProps<"div"> {}
|
|
34
|
+
declare function DraggableControls({ className, render, children, ...props }: DraggableControlsProps): React$1.ReactElement;
|
|
35
|
+
export interface DraggableBodyProps extends useRender.ComponentProps<"div"> {}
|
|
36
|
+
declare function DraggableBody({ className, render, children, ...props }: DraggableBodyProps): React$1.ReactElement | null;
|
|
37
|
+
export interface DraggableFooterProps extends useRender.ComponentProps<"div"> {}
|
|
38
|
+
declare function DraggableFooter({ className, render, children, ...props }: DraggableFooterProps): React$1.ReactElement | null;
|
|
39
|
+
export interface DraggableResizeHandleProps extends useRender.ComponentProps<"div"> {}
|
|
40
|
+
declare function DraggableResizeHandle({ className, render, ...props }: DraggableResizeHandleProps): React$1.ReactElement;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Draggable, DraggableBody, DraggableControls, DraggableFooter, DraggableHeader, DraggableResizeHandle, DraggableTitle };
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "cn";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { Cancel } from "xiod-icons/icons/Cancel";
|
|
7
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
8
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
9
|
+
import { ArrowExpandDiagonalUpRight } from "xiod-icons/icons/ArrowExpandDiagonalUpRight";
|
|
10
|
+
import { ArrowShrinkDiagonalUpRight } from "xiod-icons/icons/ArrowShrinkDiagonalUpRight";
|
|
11
|
+
import { GripHorizontal } from "xiod-icons/icons/GripHorizontal";
|
|
12
|
+
import { MinusSign } from "xiod-icons/icons/MinusSign";
|
|
13
|
+
//#region src/components/draggable.tsx
|
|
14
|
+
const draggableVariants = cva("fixed flex flex-col rounded-xl border bg-card/95 text-card-foreground shadow-lg/15 backdrop-blur-md overflow-hidden select-none transition-[box-shadow,border-color] duration-150 z-40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
default: "border-border/80 bg-card/95 shadow-lg/10",
|
|
18
|
+
expressive: "border-primary/30 bg-card/95 shadow-primary/10 shadow-xl/15",
|
|
19
|
+
flat: "border-border/60 bg-muted/90 shadow-xs/5"
|
|
20
|
+
},
|
|
21
|
+
isDragging: {
|
|
22
|
+
true: "z-50 shadow-2xl/25 border-primary transition-none cursor-grabbing opacity-95",
|
|
23
|
+
false: ""
|
|
24
|
+
},
|
|
25
|
+
isResizing: {
|
|
26
|
+
true: "z-50 shadow-xl/20 border-primary transition-none opacity-95",
|
|
27
|
+
false: ""
|
|
28
|
+
},
|
|
29
|
+
isMinimized: {
|
|
30
|
+
true: "h-auto! min-h-0!",
|
|
31
|
+
false: ""
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
isDragging: false,
|
|
37
|
+
isResizing: false,
|
|
38
|
+
isMinimized: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const DraggableContext = React$1.createContext(null);
|
|
42
|
+
function Draggable({ className, variant, defaultX = 40, defaultY = 40, defaultWidth = 360, defaultHeight = 300, minWidth = 240, minHeight = 160, maxWidth = 800, maxHeight = 600, bounds = "viewport", isDraggable = true, isResizable = true, open: controlledOpen, defaultOpen = true, onOpenChange, render, children, ...props }) {
|
|
43
|
+
const panelRef = React$1.useRef(null);
|
|
44
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React$1.useState(defaultOpen);
|
|
45
|
+
const isOpen = controlledOpen ?? uncontrolledOpen;
|
|
46
|
+
const [position, setPosition] = React$1.useState({
|
|
47
|
+
x: defaultX,
|
|
48
|
+
y: defaultY
|
|
49
|
+
});
|
|
50
|
+
const [size, setSize] = React$1.useState({
|
|
51
|
+
width: defaultWidth,
|
|
52
|
+
height: defaultHeight
|
|
53
|
+
});
|
|
54
|
+
const [isDragging, setIsDragging] = React$1.useState(false);
|
|
55
|
+
const [isResizing, setIsResizing] = React$1.useState(false);
|
|
56
|
+
const [isMinimized, setIsMinimized] = React$1.useState(false);
|
|
57
|
+
const [isMaximized, setIsMaximized] = React$1.useState(false);
|
|
58
|
+
const prevSizeRef = React$1.useRef({
|
|
59
|
+
width: defaultWidth,
|
|
60
|
+
height: defaultHeight
|
|
61
|
+
});
|
|
62
|
+
const prevPosRef = React$1.useRef({
|
|
63
|
+
x: defaultX,
|
|
64
|
+
y: defaultY
|
|
65
|
+
});
|
|
66
|
+
const handleClose = React$1.useCallback(() => {
|
|
67
|
+
if (controlledOpen === void 0) setUncontrolledOpen(false);
|
|
68
|
+
onOpenChange?.(false);
|
|
69
|
+
}, [controlledOpen, onOpenChange]);
|
|
70
|
+
const handleToggleMinimize = React$1.useCallback(() => {
|
|
71
|
+
setIsMinimized((prev) => !prev);
|
|
72
|
+
}, []);
|
|
73
|
+
const handleToggleMaximize = React$1.useCallback(() => {
|
|
74
|
+
if (isMaximized) {
|
|
75
|
+
setSize(prevSizeRef.current);
|
|
76
|
+
setPosition(prevPosRef.current);
|
|
77
|
+
setIsMaximized(false);
|
|
78
|
+
} else {
|
|
79
|
+
prevSizeRef.current = size;
|
|
80
|
+
prevPosRef.current = position;
|
|
81
|
+
setPosition({
|
|
82
|
+
x: 12,
|
|
83
|
+
y: 12
|
|
84
|
+
});
|
|
85
|
+
setSize({
|
|
86
|
+
width: window.innerWidth - 24,
|
|
87
|
+
height: window.innerHeight - 24
|
|
88
|
+
});
|
|
89
|
+
setIsMaximized(true);
|
|
90
|
+
}
|
|
91
|
+
}, [
|
|
92
|
+
isMaximized,
|
|
93
|
+
size,
|
|
94
|
+
position
|
|
95
|
+
]);
|
|
96
|
+
const handleDragStart = React$1.useCallback((e) => {
|
|
97
|
+
if (!isDraggable || isMaximized) return;
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
setIsDragging(true);
|
|
100
|
+
const startX = e.clientX - position.x;
|
|
101
|
+
const startY = e.clientY - position.y;
|
|
102
|
+
const onPointerMove = (moveEvent) => {
|
|
103
|
+
let newX = moveEvent.clientX - startX;
|
|
104
|
+
let newY = moveEvent.clientY - startY;
|
|
105
|
+
if (bounds === "viewport") {
|
|
106
|
+
newX = Math.max(0, Math.min(window.innerWidth - size.width, newX));
|
|
107
|
+
newY = Math.max(0, Math.min(window.innerHeight - (isMinimized ? 44 : size.height), newY));
|
|
108
|
+
}
|
|
109
|
+
setPosition({
|
|
110
|
+
x: newX,
|
|
111
|
+
y: newY
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const onPointerUp = () => {
|
|
115
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
116
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
117
|
+
setIsDragging(false);
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
120
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
121
|
+
}, [
|
|
122
|
+
isDraggable,
|
|
123
|
+
isMaximized,
|
|
124
|
+
position,
|
|
125
|
+
bounds,
|
|
126
|
+
size,
|
|
127
|
+
isMinimized
|
|
128
|
+
]);
|
|
129
|
+
const handleResizeStart = React$1.useCallback((e) => {
|
|
130
|
+
if (!isResizable || isMaximized || isMinimized) return;
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
setIsResizing(true);
|
|
134
|
+
const startX = e.clientX;
|
|
135
|
+
const startY = e.clientY;
|
|
136
|
+
const startWidth = size.width;
|
|
137
|
+
const startHeight = size.height;
|
|
138
|
+
const onPointerMove = (moveEvent) => {
|
|
139
|
+
const deltaX = moveEvent.clientX - startX;
|
|
140
|
+
const deltaY = moveEvent.clientY - startY;
|
|
141
|
+
const newWidth = Math.max(minWidth, Math.min(maxWidth, startWidth + deltaX));
|
|
142
|
+
const newHeight = Math.max(minHeight, Math.min(maxHeight, startHeight + deltaY));
|
|
143
|
+
setSize({
|
|
144
|
+
width: newWidth,
|
|
145
|
+
height: newHeight
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const onPointerUp = () => {
|
|
149
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
150
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
151
|
+
setIsResizing(false);
|
|
152
|
+
};
|
|
153
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
154
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
155
|
+
}, [
|
|
156
|
+
isResizable,
|
|
157
|
+
isMaximized,
|
|
158
|
+
isMinimized,
|
|
159
|
+
size,
|
|
160
|
+
minWidth,
|
|
161
|
+
maxWidth,
|
|
162
|
+
minHeight,
|
|
163
|
+
maxHeight
|
|
164
|
+
]);
|
|
165
|
+
const contextValue = React$1.useMemo(() => ({
|
|
166
|
+
isOpen,
|
|
167
|
+
isMinimized,
|
|
168
|
+
isMaximized,
|
|
169
|
+
isDraggable,
|
|
170
|
+
isResizable,
|
|
171
|
+
onDragStart: handleDragStart,
|
|
172
|
+
onResizeStart: handleResizeStart,
|
|
173
|
+
onToggleMinimize: handleToggleMinimize,
|
|
174
|
+
onToggleMaximize: handleToggleMaximize,
|
|
175
|
+
onClose: handleClose
|
|
176
|
+
}), [
|
|
177
|
+
isOpen,
|
|
178
|
+
isMinimized,
|
|
179
|
+
isMaximized,
|
|
180
|
+
isDraggable,
|
|
181
|
+
isResizable,
|
|
182
|
+
handleDragStart,
|
|
183
|
+
handleResizeStart,
|
|
184
|
+
handleToggleMinimize,
|
|
185
|
+
handleToggleMaximize,
|
|
186
|
+
handleClose
|
|
187
|
+
]);
|
|
188
|
+
const defaultProps = {
|
|
189
|
+
ref: panelRef,
|
|
190
|
+
className: cn(draggableVariants({
|
|
191
|
+
variant,
|
|
192
|
+
isDragging,
|
|
193
|
+
isResizing,
|
|
194
|
+
isMinimized,
|
|
195
|
+
className
|
|
196
|
+
})),
|
|
197
|
+
style: {
|
|
198
|
+
left: position.x,
|
|
199
|
+
top: position.y,
|
|
200
|
+
width: size.width,
|
|
201
|
+
height: isMinimized ? "auto" : size.height
|
|
202
|
+
},
|
|
203
|
+
"data-slot": "draggable",
|
|
204
|
+
children: /* @__PURE__ */ jsxs(DraggableContext.Provider, {
|
|
205
|
+
value: contextValue,
|
|
206
|
+
children: [children, isResizable && !isMinimized && !isMaximized && /* @__PURE__ */ jsx(DraggableResizeHandle, { onPointerDown: handleResizeStart })]
|
|
207
|
+
})
|
|
208
|
+
};
|
|
209
|
+
const renderedElement = useRender({
|
|
210
|
+
defaultTagName: "div",
|
|
211
|
+
props: mergeProps(defaultProps, props),
|
|
212
|
+
render
|
|
213
|
+
});
|
|
214
|
+
if (!isOpen) return null;
|
|
215
|
+
return renderedElement;
|
|
216
|
+
}
|
|
217
|
+
function DraggableHeader({ className, render, children, ...props }) {
|
|
218
|
+
const context = React$1.useContext(DraggableContext);
|
|
219
|
+
const defaultProps = {
|
|
220
|
+
className: cn("flex items-center justify-between gap-2 px-3 py-2 border-b border-border/40 bg-muted/30 cursor-grab active:cursor-grabbing select-none text-xs font-medium text-foreground shrink-0", className),
|
|
221
|
+
onPointerDown: context?.onDragStart,
|
|
222
|
+
"data-slot": "draggable-header",
|
|
223
|
+
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
224
|
+
className: "flex items-center gap-1.5 truncate",
|
|
225
|
+
children: [/* @__PURE__ */ jsx(GripHorizontal, { className: "size-3.5 text-muted-foreground/60 shrink-0" }), /* @__PURE__ */ jsx(DraggableTitle, {})]
|
|
226
|
+
}), /* @__PURE__ */ jsx(DraggableControls, {})] })
|
|
227
|
+
};
|
|
228
|
+
return useRender({
|
|
229
|
+
defaultTagName: "div",
|
|
230
|
+
props: mergeProps(defaultProps, props),
|
|
231
|
+
render
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function DraggableTitle({ className, render, children, ...props }) {
|
|
235
|
+
const defaultProps = {
|
|
236
|
+
className: cn("font-semibold truncate text-xs", className),
|
|
237
|
+
"data-slot": "draggable-title",
|
|
238
|
+
children: children || "Draggable Panel"
|
|
239
|
+
};
|
|
240
|
+
return useRender({
|
|
241
|
+
defaultTagName: "span",
|
|
242
|
+
props: mergeProps(defaultProps, props),
|
|
243
|
+
render
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function DraggableControls({ className, render, children, ...props }) {
|
|
247
|
+
const context = React$1.useContext(DraggableContext);
|
|
248
|
+
const defaultProps = {
|
|
249
|
+
className: cn("flex items-center gap-1 shrink-0", className),
|
|
250
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
251
|
+
"data-slot": "draggable-controls",
|
|
252
|
+
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
253
|
+
/* @__PURE__ */ jsx("button", {
|
|
254
|
+
type: "button",
|
|
255
|
+
onClick: context?.onToggleMinimize,
|
|
256
|
+
className: "p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-11",
|
|
257
|
+
"aria-label": "Minimize",
|
|
258
|
+
children: /* @__PURE__ */ jsx(MinusSign, { className: "size-3" })
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ jsx("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
onClick: context?.onToggleMaximize,
|
|
263
|
+
className: "p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-11",
|
|
264
|
+
"aria-label": "Maximize",
|
|
265
|
+
children: context?.isMaximized ? /* @__PURE__ */ jsx(ArrowShrinkDiagonalUpRight, { className: "size-3" }) : /* @__PURE__ */ jsx(ArrowExpandDiagonalUpRight, { className: "size-3" })
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ jsx("button", {
|
|
268
|
+
type: "button",
|
|
269
|
+
onClick: context?.onClose,
|
|
270
|
+
className: "p-1 rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-11",
|
|
271
|
+
"aria-label": "Close",
|
|
272
|
+
children: /* @__PURE__ */ jsx(Cancel, { className: "size-3" })
|
|
273
|
+
})
|
|
274
|
+
] })
|
|
275
|
+
};
|
|
276
|
+
return useRender({
|
|
277
|
+
defaultTagName: "div",
|
|
278
|
+
props: mergeProps(defaultProps, props),
|
|
279
|
+
render
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function DraggableBody({ className, render, children, ...props }) {
|
|
283
|
+
const context = React$1.useContext(DraggableContext);
|
|
284
|
+
const defaultProps = {
|
|
285
|
+
className: cn("flex-1 p-3 overflow-y-auto text-xs text-foreground", className),
|
|
286
|
+
"data-slot": "draggable-body",
|
|
287
|
+
children
|
|
288
|
+
};
|
|
289
|
+
const renderedElement = useRender({
|
|
290
|
+
defaultTagName: "div",
|
|
291
|
+
props: mergeProps(defaultProps, props),
|
|
292
|
+
render
|
|
293
|
+
});
|
|
294
|
+
if (context?.isMinimized) return null;
|
|
295
|
+
return renderedElement;
|
|
296
|
+
}
|
|
297
|
+
function DraggableFooter({ className, render, children, ...props }) {
|
|
298
|
+
const context = React$1.useContext(DraggableContext);
|
|
299
|
+
const defaultProps = {
|
|
300
|
+
className: cn("flex items-center justify-end gap-2 px-3 py-2 border-t border-border/40 bg-muted/20 text-xs shrink-0", className),
|
|
301
|
+
"data-slot": "draggable-footer",
|
|
302
|
+
children
|
|
303
|
+
};
|
|
304
|
+
const renderedElement = useRender({
|
|
305
|
+
defaultTagName: "div",
|
|
306
|
+
props: mergeProps(defaultProps, props),
|
|
307
|
+
render
|
|
308
|
+
});
|
|
309
|
+
if (context?.isMinimized) return null;
|
|
310
|
+
return renderedElement;
|
|
311
|
+
}
|
|
312
|
+
function DraggableResizeHandle({ className, render, ...props }) {
|
|
313
|
+
const defaultProps = {
|
|
314
|
+
className: cn("absolute bottom-1 right-1 size-4 cursor-se-resize flex items-center justify-center opacity-40 hover:opacity-100 transition-opacity touch-none pointer-coarse:after:absolute pointer-coarse:after:size-8", className),
|
|
315
|
+
"data-slot": "draggable-resize-handle",
|
|
316
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
317
|
+
className: "size-3 text-muted-foreground",
|
|
318
|
+
viewBox: "0 0 6 6",
|
|
319
|
+
fill: "currentColor",
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsx("circle", {
|
|
322
|
+
cx: "5",
|
|
323
|
+
cy: "5",
|
|
324
|
+
r: "1"
|
|
325
|
+
}),
|
|
326
|
+
/* @__PURE__ */ jsx("circle", {
|
|
327
|
+
cx: "5",
|
|
328
|
+
cy: "2",
|
|
329
|
+
r: "1"
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ jsx("circle", {
|
|
332
|
+
cx: "2",
|
|
333
|
+
cy: "5",
|
|
334
|
+
r: "1"
|
|
335
|
+
})
|
|
336
|
+
]
|
|
337
|
+
})
|
|
338
|
+
};
|
|
339
|
+
return useRender({
|
|
340
|
+
defaultTagName: "div",
|
|
341
|
+
props: mergeProps(defaultProps, props),
|
|
342
|
+
render
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { Draggable, DraggableBody, DraggableControls, DraggableFooter, DraggableHeader, DraggableResizeHandle, DraggableTitle, draggableVariants };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
|
|
5
|
+
import { Radio } from "@base-ui/react/radio";
|
|
6
|
+
import { RadioGroup } from "@base-ui/react/radio-group";
|
|
7
|
+
//#region src/components/drawer.d.ts
|
|
8
|
+
type DrawerPosition = "right" | "left" | "top" | "bottom";
|
|
9
|
+
export declare const DrawerCreateHandle: typeof DrawerPrimitive.createHandle;
|
|
10
|
+
export declare function Drawer({ swipeDirection, position, ...props }: DrawerPrimitive.Root.Props & {
|
|
11
|
+
position?: DrawerPosition;
|
|
12
|
+
}): React.ReactElement;
|
|
13
|
+
export declare const DrawerPortal: typeof DrawerPrimitive.Portal;
|
|
14
|
+
export declare function DrawerTrigger(props: DrawerPrimitive.Trigger.Props): React.ReactElement;
|
|
15
|
+
export declare function DrawerClose(props: DrawerPrimitive.Close.Props): React.ReactElement;
|
|
16
|
+
export declare function DrawerSwipeArea({ className, position: positionProp, ...props }: DrawerPrimitive.SwipeArea.Props & {
|
|
17
|
+
position?: DrawerPosition;
|
|
18
|
+
}): React.ReactElement;
|
|
19
|
+
export declare function DrawerBackdrop({ className, ...props }: DrawerPrimitive.Backdrop.Props): React.ReactElement;
|
|
20
|
+
export declare function DrawerViewport({ className, position, variant, ...props }: DrawerPrimitive.Viewport.Props & {
|
|
21
|
+
position?: DrawerPosition;
|
|
22
|
+
variant?: "default" | "straight" | "inset";
|
|
23
|
+
}): React.ReactElement;
|
|
24
|
+
export declare function DrawerPopup({ className, children, showCloseButton, position: positionProp, variant, showBar, ...props }: DrawerPrimitive.Popup.Props & {
|
|
25
|
+
showCloseButton?: boolean;
|
|
26
|
+
position?: DrawerPosition;
|
|
27
|
+
variant?: "default" | "straight" | "inset";
|
|
28
|
+
showBar?: boolean;
|
|
29
|
+
}): React.ReactElement;
|
|
30
|
+
export declare function DrawerHeader({ className, allowSelection, render, ...props }: useRender.ComponentProps<"div"> & {
|
|
31
|
+
allowSelection?: boolean;
|
|
32
|
+
}): React.ReactElement;
|
|
33
|
+
export declare function DrawerFooter({ className, variant, allowSelection, render, ...props }: useRender.ComponentProps<"div"> & {
|
|
34
|
+
variant?: "default" | "bare";
|
|
35
|
+
allowSelection?: boolean;
|
|
36
|
+
}): React.ReactElement;
|
|
37
|
+
export declare function DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props): React.ReactElement;
|
|
38
|
+
export declare function DrawerDescription({ className, ...props }: DrawerPrimitive.Description.Props): React.ReactElement;
|
|
39
|
+
export declare function DrawerPanel({ className, scrollFade, scrollable, allowSelection, render, ...props }: useRender.ComponentProps<"div"> & {
|
|
40
|
+
scrollFade?: boolean;
|
|
41
|
+
scrollable?: boolean;
|
|
42
|
+
allowSelection?: boolean;
|
|
43
|
+
}): React.ReactElement;
|
|
44
|
+
export declare function DrawerBar({ className, position: positionProp, render, ...props }: useRender.ComponentProps<"div"> & {
|
|
45
|
+
position?: DrawerPosition;
|
|
46
|
+
}): React.ReactElement;
|
|
47
|
+
export declare const DrawerContent: typeof DrawerPrimitive.Content;
|
|
48
|
+
export declare function DrawerMenu({ className, render, ...props }: useRender.ComponentProps<"nav">): React.ReactElement;
|
|
49
|
+
export declare function DrawerMenuItem({ className, variant, render, disabled, ...props }: useRender.ComponentProps<"button"> & {
|
|
50
|
+
variant?: "default" | "destructive";
|
|
51
|
+
}): React.ReactElement;
|
|
52
|
+
export declare function DrawerMenuSeparator({ className, render, ...props }: useRender.ComponentProps<"div">): React.ReactElement;
|
|
53
|
+
export declare function DrawerMenuGroup({ className, render, ...props }: useRender.ComponentProps<"div">): React.ReactElement;
|
|
54
|
+
export declare function DrawerMenuGroupLabel({ className, render, ...props }: useRender.ComponentProps<"div">): React.ReactElement;
|
|
55
|
+
export declare function DrawerMenuTrigger({ className, children, ...props }: DrawerPrimitive.Trigger.Props): React.ReactElement;
|
|
56
|
+
export declare function DrawerMenuCheckboxItem({ className, children, checked, defaultChecked, onCheckedChange, variant, disabled, render, ...props }: Checkbox.Root.Props & {
|
|
57
|
+
variant?: "default" | "switch";
|
|
58
|
+
render?: React.ReactElement;
|
|
59
|
+
}): React.ReactElement;
|
|
60
|
+
export declare function DrawerMenuRadioGroup({ className, ...props }: RadioGroup.Props): React.ReactElement;
|
|
61
|
+
export declare function DrawerMenuRadioItem({ className, children, value, disabled, render, ...props }: Radio.Root.Props & {
|
|
62
|
+
value: string;
|
|
63
|
+
render?: React.ReactElement;
|
|
64
|
+
}): React.ReactElement;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { DrawerPrimitive };
|