@constructive-io/ui 0.3.1 → 0.6.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 +21 -0
- package/README.md +17 -22
- package/dist/components/alert-dialog.cjs +333 -0
- package/dist/components/alert-dialog.cjs.map +1 -0
- package/dist/components/alert-dialog.d.cts +32 -0
- package/dist/components/alert-dialog.d.ts +16 -15
- package/dist/components/alert-dialog.js +89 -102
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.cjs +119 -0
- package/dist/components/alert.cjs.map +1 -0
- package/dist/components/alert.d.cts +19 -0
- package/dist/components/alert.d.ts +10 -5
- package/dist/components/alert.js +62 -6
- package/dist/components/alert.js.map +1 -1
- package/dist/components/app-bar.cjs +367 -0
- package/dist/components/app-bar.cjs.map +1 -0
- package/dist/components/app-bar.d.cts +26 -0
- package/dist/components/app-bar.d.ts +26 -0
- package/dist/components/app-bar.js +344 -0
- package/dist/components/app-bar.js.map +1 -0
- package/dist/components/app-shell.cjs +1792 -0
- package/dist/components/app-shell.cjs.map +1 -0
- package/dist/components/app-shell.d.cts +106 -0
- package/dist/components/app-shell.d.ts +106 -0
- package/dist/components/app-shell.js +1771 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/autocomplete.cjs +418 -0
- package/dist/components/autocomplete.cjs.map +1 -0
- package/dist/components/autocomplete.d.cts +28 -0
- package/dist/components/autocomplete.d.ts +15 -15
- package/dist/components/autocomplete.js +9 -30
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.cjs +51 -0
- package/dist/components/avatar.cjs.map +1 -0
- package/dist/components/avatar.d.cts +12 -0
- package/dist/components/avatar.d.ts +3 -4
- package/dist/components/avatar.js +11 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.cjs +66 -0
- package/dist/components/badge.cjs.map +1 -0
- package/dist/components/badge.d.cts +15 -0
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/breadcrumb.cjs +118 -0
- package/dist/components/breadcrumb.cjs.map +1 -0
- package/dist/components/breadcrumb.d.cts +14 -0
- package/dist/components/breadcrumb.d.ts +9 -9
- package/dist/components/breadcrumb.js +19 -83
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.cjs +169 -0
- package/dist/components/button.cjs.map +1 -0
- package/dist/components/button.d.cts +20 -0
- package/dist/components/button.d.ts +3 -0
- package/dist/components/button.js +105 -21
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-rac.cjs +85 -0
- package/dist/components/calendar-rac.cjs.map +1 -0
- package/dist/components/calendar-rac.d.cts +13 -0
- package/dist/components/calendar-rac.d.ts +3 -3
- package/dist/components/card.cjs +99 -0
- package/dist/components/card.cjs.map +1 -0
- package/dist/components/card.d.cts +18 -0
- package/dist/components/card.d.ts +7 -8
- package/dist/components/card.js +23 -8
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +18 -0
- package/dist/components/checkbox-group.cjs.map +1 -0
- package/dist/components/checkbox-group.d.cts +7 -0
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox.cjs +121 -0
- package/dist/components/checkbox.cjs.map +1 -0
- package/dist/components/checkbox.d.cts +8 -0
- package/dist/components/checkbox.d.ts +3 -3
- package/dist/components/checkbox.js +73 -41
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.cjs +127 -0
- package/dist/components/collapsible.cjs.map +1 -0
- package/dist/components/collapsible.d.cts +44 -0
- package/dist/components/collapsible.d.ts +8 -18
- package/dist/components/collapsible.js +7 -27
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.cjs +551 -0
- package/dist/components/combobox.cjs.map +1 -0
- package/dist/components/combobox.d.cts +43 -0
- package/dist/components/combobox.d.ts +17 -18
- package/dist/components/combobox.js +37 -48
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.cjs +236 -0
- package/dist/components/command.cjs.map +1 -0
- package/dist/components/command.d.cts +23 -0
- package/dist/components/command.d.ts +14 -15
- package/dist/components/command.js +5 -38
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.cjs +431 -0
- package/dist/components/dialog.cjs.map +1 -0
- package/dist/components/dialog.d.cts +30 -0
- package/dist/components/dialog.d.ts +13 -18
- package/dist/components/dialog.js +75 -119
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.cjs +121 -0
- package/dist/components/dock.cjs.map +1 -0
- package/dist/components/dock.d.cts +30 -0
- package/dist/components/dock.d.ts +1 -2
- package/dist/components/dock.js +7 -5
- package/dist/components/dock.js.map +1 -1
- package/dist/components/drawer.cjs +149 -0
- package/dist/components/drawer.cjs.map +1 -0
- package/dist/components/drawer.d.cts +15 -0
- package/dist/components/drawer.d.ts +10 -11
- package/dist/components/drawer.js +11 -40
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +292 -0
- package/dist/components/dropdown-menu.cjs.map +1 -0
- package/dist/components/dropdown-menu.d.cts +52 -0
- package/dist/components/dropdown-menu.d.ts +23 -21
- package/dist/components/dropdown-menu.js +67 -191
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty.cjs +106 -0
- package/dist/components/empty.cjs.map +1 -0
- package/dist/components/empty.d.cts +15 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +99 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.cjs +295 -0
- package/dist/components/field.cjs.map +1 -0
- package/dist/components/field.d.cts +46 -0
- package/dist/components/field.d.ts +34 -39
- package/dist/components/field.js +220 -72
- package/dist/components/field.js.map +1 -1
- package/dist/components/flickering-grid.cjs +176 -0
- package/dist/components/flickering-grid.cjs.map +1 -0
- package/dist/components/flickering-grid.d.cts +15 -0
- package/dist/components/flickering-grid.js +25 -2
- package/dist/components/flickering-grid.js.map +1 -1
- package/dist/components/flow-zoom-panel.cjs +194 -0
- package/dist/components/flow-zoom-panel.cjs.map +1 -0
- package/dist/components/flow-zoom-panel.d.cts +12 -0
- package/dist/components/flow-zoom-panel.d.ts +12 -0
- package/dist/components/flow-zoom-panel.js +173 -0
- package/dist/components/flow-zoom-panel.js.map +1 -0
- package/dist/components/form-control.cjs +193 -0
- package/dist/components/form-control.cjs.map +1 -0
- package/dist/components/form-control.d.cts +14 -0
- package/dist/components/form-control.d.ts +1 -2
- package/dist/components/form-control.js +2 -4
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.cjs +208 -0
- package/dist/components/form.cjs.map +1 -0
- package/dist/components/form.d.cts +36 -0
- package/dist/components/form.d.ts +7 -8
- package/dist/components/input-group.cjs +184 -0
- package/dist/components/input-group.cjs.map +1 -0
- package/dist/components/input-group.d.cts +17 -0
- package/dist/components/input-group.d.ts +6 -7
- package/dist/components/input-group.js +3 -2
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +62 -0
- package/dist/components/input.cjs.map +1 -0
- package/dist/components/input.d.cts +10 -0
- package/dist/components/input.d.ts +1 -2
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.cjs +351 -0
- package/dist/components/json-input.cjs.map +1 -0
- package/dist/components/json-input.d.cts +25 -0
- package/dist/components/json-input.d.ts +3 -3
- package/dist/components/json-input.js +89 -112
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/label.cjs +29 -0
- package/dist/components/label.cjs.map +1 -0
- package/dist/components/label.d.cts +10 -0
- package/dist/components/label.d.ts +1 -2
- package/dist/components/motion-grid.cjs +108 -0
- package/dist/components/motion-grid.cjs.map +1 -0
- package/dist/components/motion-grid.d.cts +19 -0
- package/dist/components/motion-grid.d.ts +1 -2
- package/dist/components/motion-grid.js +9 -4
- package/dist/components/motion-grid.js.map +1 -1
- package/dist/components/multi-select.cjs +796 -0
- package/dist/components/multi-select.cjs.map +1 -0
- package/dist/components/multi-select.d.cts +198 -0
- package/dist/components/multi-select.js +54 -162
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/page-header.cjs +19 -0
- package/dist/components/page-header.cjs.map +1 -0
- package/dist/components/page-header.d.cts +17 -0
- package/dist/components/page-header.d.ts +2 -2
- package/dist/components/pagination.cjs +295 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +18 -0
- package/dist/components/pagination.d.ts +7 -8
- package/dist/components/pagination.js +152 -29
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.cjs +140 -0
- package/dist/components/popover.cjs.map +1 -0
- package/dist/components/popover.d.cts +39 -0
- package/dist/components/popover.d.ts +13 -9
- package/dist/components/popover.js +56 -132
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.cjs +109 -0
- package/dist/components/portal.cjs.map +1 -0
- package/dist/components/portal.d.cts +117 -0
- package/dist/components/portal.d.ts +16 -7
- package/dist/components/portal.js +13 -8
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.cjs +31 -0
- package/dist/components/progress.cjs.map +1 -0
- package/dist/components/progress.d.cts +9 -0
- package/dist/components/progress.d.ts +1 -2
- package/dist/components/progress.js +1 -2
- package/dist/components/progress.js.map +1 -1
- package/dist/components/progressive-blur-scroll-container.cjs +144 -0
- package/dist/components/progressive-blur-scroll-container.cjs.map +1 -0
- package/dist/components/progressive-blur-scroll-container.d.cts +25 -0
- package/dist/components/progressive-blur-scroll-container.d.ts +2 -2
- package/dist/components/progressive-blur.cjs +70 -0
- package/dist/components/progressive-blur.cjs.map +1 -0
- package/dist/components/progressive-blur.d.cts +16 -0
- package/dist/components/progressive-blur.d.ts +2 -2
- package/dist/components/radio-group.cjs +52 -0
- package/dist/components/radio-group.cjs.map +1 -0
- package/dist/components/radio-group.d.cts +10 -0
- package/dist/components/radio-group.d.ts +3 -3
- package/dist/components/radio-group.js +21 -10
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/record-picker.cjs +420 -0
- package/dist/components/record-picker.cjs.map +1 -0
- package/dist/components/record-picker.d.cts +16 -0
- package/dist/components/record-picker.d.ts +2 -2
- package/dist/components/record-picker.js +76 -43
- package/dist/components/record-picker.js.map +1 -1
- package/dist/components/resizable.cjs +76 -0
- package/dist/components/resizable.cjs.map +1 -0
- package/dist/components/resizable.d.cts +10 -0
- package/dist/components/resizable.d.ts +3 -4
- package/dist/components/responsive-diagram.cjs +67 -0
- package/dist/components/responsive-diagram.cjs.map +1 -0
- package/dist/components/responsive-diagram.d.cts +10 -0
- package/dist/components/responsive-diagram.d.ts +2 -2
- package/dist/components/scroll-area.cjs +92 -0
- package/dist/components/scroll-area.cjs.map +1 -0
- package/dist/components/scroll-area.d.cts +11 -0
- package/dist/components/scroll-area.d.ts +5 -6
- package/dist/components/select.cjs +329 -0
- package/dist/components/select.cjs.map +1 -0
- package/dist/components/select.d.cts +46 -0
- package/dist/components/select.d.ts +13 -14
- package/dist/components/select.js +76 -67
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +26 -0
- package/dist/components/separator.cjs.map +1 -0
- package/dist/components/separator.d.cts +10 -0
- package/dist/components/separator.d.ts +1 -2
- package/dist/components/sheet.cjs +489 -0
- package/dist/components/sheet.cjs.map +1 -0
- package/dist/components/sheet.d.cts +107 -0
- package/dist/components/sheet.d.ts +14 -19
- package/dist/components/sheet.js +119 -264
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.cjs +1300 -0
- package/dist/components/sidebar.cjs.map +1 -0
- package/dist/components/sidebar.d.cts +70 -0
- package/dist/components/sidebar.d.ts +32 -39
- package/dist/components/sidebar.js +401 -362
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton.cjs +36 -0
- package/dist/components/skeleton.cjs.map +1 -0
- package/dist/components/skeleton.d.cts +10 -0
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +19 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/sonner.cjs +25 -0
- package/dist/components/sonner.cjs.map +1 -0
- package/dist/components/sonner.d.cts +10 -0
- package/dist/components/sonner.d.ts +2 -2
- package/dist/components/stack/index.cjs +1516 -0
- package/dist/components/stack/index.cjs.map +1 -0
- package/dist/components/stack/index.d.cts +672 -0
- package/dist/components/stack/index.d.ts +36 -38
- package/dist/components/stack/index.js +42 -31
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/stepper.cjs +314 -0
- package/dist/components/stepper.cjs.map +1 -0
- package/dist/components/stepper.d.cts +31 -0
- package/dist/components/stepper.d.ts +9 -8
- package/dist/components/stepper.js +22 -15
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.cjs +46 -0
- package/dist/components/switch.cjs.map +1 -0
- package/dist/components/switch.d.cts +7 -0
- package/dist/components/switch.d.ts +1 -2
- package/dist/components/switch.js +9 -5
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +133 -0
- package/dist/components/table.cjs.map +1 -0
- package/dist/components/table.d.cts +22 -0
- package/dist/components/table.d.ts +19 -12
- package/dist/components/table.js +72 -13
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +53 -0
- package/dist/components/tabs.cjs.map +1 -0
- package/dist/components/tabs.d.cts +9 -0
- package/dist/components/tabs.d.ts +4 -5
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.cjs +451 -0
- package/dist/components/tags.cjs.map +1 -0
- package/dist/components/tags.d.cts +40 -0
- package/dist/components/tags.d.ts +10 -10
- package/dist/components/tags.js +129 -154
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.cjs +56 -0
- package/dist/components/textarea.cjs.map +1 -0
- package/dist/components/textarea.d.cts +9 -0
- package/dist/components/textarea.d.ts +1 -2
- package/dist/components/toast/index.cjs +612 -0
- package/dist/components/toast/index.cjs.map +1 -0
- package/dist/components/toast/index.d.cts +52 -0
- package/dist/components/toast/index.js +90 -127
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/tooltip.cjs +92 -0
- package/dist/components/tooltip.cjs.map +1 -0
- package/dist/components/tooltip.d.cts +28 -0
- package/dist/components/tooltip.d.ts +5 -6
- package/dist/components/tooltip.js +23 -130
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unlink-button.cjs +197 -0
- package/dist/components/unlink-button.cjs.map +1 -0
- package/dist/components/unlink-button.d.cts +14 -0
- package/dist/components/unlink-button.d.ts +2 -2
- package/dist/components/unlink-button.js +105 -21
- package/dist/components/unlink-button.js.map +1 -1
- package/dist/index.cjs +2040 -1577
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +492 -509
- package/dist/index.d.ts +492 -509
- package/dist/index.js +1862 -1443
- package/dist/index.js.map +1 -1
- package/package.json +286 -45
- package/src/styles/globals.css +155 -203
- package/dist/components/org-chart/index.d.ts +0 -54
- package/dist/components/org-chart/index.js +0 -861
- package/dist/components/org-chart/index.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import React__default, { PropsWithChildren } from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { MotionProps, MotionValue } from 'motion/react';
|
|
5
|
+
|
|
6
|
+
interface DockProps extends VariantProps<typeof dockVariants> {
|
|
7
|
+
className?: string;
|
|
8
|
+
iconSize?: number;
|
|
9
|
+
iconMagnification?: number;
|
|
10
|
+
iconDistance?: number;
|
|
11
|
+
direction?: 'top' | 'middle' | 'bottom';
|
|
12
|
+
children: React__default.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const dockVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
|
|
15
|
+
declare const Dock: React__default.ForwardRefExoticComponent<DockProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
interface DockIconProps extends Omit<MotionProps & React__default.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
17
|
+
size?: number;
|
|
18
|
+
magnification?: number;
|
|
19
|
+
distance?: number;
|
|
20
|
+
mouseX?: MotionValue<number>;
|
|
21
|
+
className?: string;
|
|
22
|
+
children?: React__default.ReactNode;
|
|
23
|
+
props?: PropsWithChildren;
|
|
24
|
+
}
|
|
25
|
+
declare const DockIcon: {
|
|
26
|
+
({ size, magnification, distance, mouseX, className, children, ...props }: DockIconProps): React__default.JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Dock, DockIcon, type DockIconProps, type DockProps, dockVariants };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
2
|
import React__default, { PropsWithChildren } from 'react';
|
|
4
3
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -24,7 +23,7 @@ interface DockIconProps extends Omit<MotionProps & React__default.HTMLAttributes
|
|
|
24
23
|
props?: PropsWithChildren;
|
|
25
24
|
}
|
|
26
25
|
declare const DockIcon: {
|
|
27
|
-
({ size, magnification, distance, mouseX, className, children, ...props }: DockIconProps):
|
|
26
|
+
({ size, magnification, distance, mouseX, className, children, ...props }: DockIconProps): React__default.JSX.Element;
|
|
28
27
|
displayName: string;
|
|
29
28
|
};
|
|
30
29
|
|
package/dist/components/dock.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useRef } from 'react';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
|
-
import { useMotionValue, motion, useTransform, useSpring } from 'motion/react';
|
|
4
|
+
import { useMotionValue, useReducedMotion, motion, useTransform, useSpring } from 'motion/react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -20,7 +20,7 @@ var DEFAULT_MAGNIFICATION = 60;
|
|
|
20
20
|
var DEFAULT_DISTANCE = 140;
|
|
21
21
|
var dockVariants = cva(
|
|
22
22
|
// Solid themed surface (no glass/blur)
|
|
23
|
-
"mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl
|
|
23
|
+
"mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl bg-card p-2 shadow-card"
|
|
24
24
|
);
|
|
25
25
|
var Dock = React.forwardRef(
|
|
26
26
|
({
|
|
@@ -33,6 +33,7 @@ var Dock = React.forwardRef(
|
|
|
33
33
|
...props
|
|
34
34
|
}, ref) => {
|
|
35
35
|
const mouseX = useMotionValue(Infinity);
|
|
36
|
+
const prefersReducedMotion = useReducedMotion();
|
|
36
37
|
const renderChildren = () => {
|
|
37
38
|
return React.Children.map(children, (child) => {
|
|
38
39
|
if (React.isValidElement(child) && child.type === DockIcon) {
|
|
@@ -51,8 +52,8 @@ var Dock = React.forwardRef(
|
|
|
51
52
|
motion.div,
|
|
52
53
|
{
|
|
53
54
|
ref,
|
|
54
|
-
onMouseMove: (
|
|
55
|
-
onMouseLeave: () => mouseX.set(Infinity),
|
|
55
|
+
onMouseMove: prefersReducedMotion ? void 0 : (event) => mouseX.set(event.pageX),
|
|
56
|
+
onMouseLeave: prefersReducedMotion ? void 0 : () => mouseX.set(Infinity),
|
|
56
57
|
...props,
|
|
57
58
|
className: cn(dockVariants({ className }), {
|
|
58
59
|
"items-start": direction === "top",
|
|
@@ -75,6 +76,7 @@ var DockIcon = ({
|
|
|
75
76
|
...props
|
|
76
77
|
}) => {
|
|
77
78
|
const ref = useRef(null);
|
|
79
|
+
const prefersReducedMotion = useReducedMotion();
|
|
78
80
|
const padding = Math.max(6, size * 0.2);
|
|
79
81
|
const defaultMouseX = useMotionValue(Infinity);
|
|
80
82
|
const distanceCalc = useTransform(mouseX ?? defaultMouseX, (val) => {
|
|
@@ -91,7 +93,7 @@ var DockIcon = ({
|
|
|
91
93
|
motion.div,
|
|
92
94
|
{
|
|
93
95
|
ref,
|
|
94
|
-
style: { width: scaleSize, height: scaleSize, padding },
|
|
96
|
+
style: { width: prefersReducedMotion ? size : scaleSize, height: prefersReducedMotion ? size : scaleSize, padding },
|
|
95
97
|
className: cn(
|
|
96
98
|
// Solid hover target with theme-aware colors
|
|
97
99
|
"flex aspect-square cursor-pointer items-center justify-center rounded-full bg-transparent",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/motion/motion-config.ts","../../src/lib/utils.ts","../../src/components/dock.tsx"],"names":[],"mappings":";;;;;;;AA8EO,IAAM,OAAA,GAAU;AAAA,EAetB;AAAA,EAGA,MAAA,EAAQ;AAAA,IAEP,SAAA,EAAW,GAAA;AAAA,IAEX,IAAA,EAAM;AAAA,GAiBR,CAAA;AClHO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACaA,IAAM,YAAA,GAAe,EAAA;AACrB,IAAM,qBAAA,GAAwB,EAAA;AAC9B,IAAM,gBAAA,GAAmB,GAAA;AAEzB,IAAM,YAAA,GAAe,GAAA;AAAA;AAAA,EAEpB;AACD;AAEA,IAAM,OAAO,KAAA,CAAM,UAAA;AAAA,EAClB,CACC;AAAA,IACC,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA,GAAW,YAAA;AAAA,IACX,iBAAA,GAAoB,qBAAA;AAAA,IACpB,YAAA,GAAe,gBAAA;AAAA,IACf,SAAA,GAAY,QAAA;AAAA,IACZ,GAAG;AAAA,KAEJ,GAAA,KACI;AACJ,IAAA,MAAM,MAAA,GAAS,eAAe,QAAQ,CAAA;AAEtC,IAAA,MAAM,iBAAiB,MAAM;AAC5B,MAAA,OAAO,KAAA,CAAM,QAAA,CAAS,GAAA,CAAI,QAAA,EAAU,CAAC,KAAA,KAAU;AAC9C,QAAA,IAAI,MAAM,cAAA,CAA8B,KAAK,CAAA,IAAK,KAAA,CAAM,SAAS,QAAA,EAAU;AAC1E,UAAA,OAAO,KAAA,CAAM,aAAa,KAAA,EAAO;AAAA,YAChC,GAAG,KAAA,CAAM,KAAA;AAAA,YACT,MAAA;AAAA,YACA,IAAA,EAAM,QA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AA2B,EAAE,CAAA,EAAG,CAAA,EAAG,KAAA,EAAO,CAAA,EAAE;AACxE,IAAA,OAAO,GAAA,GAAM,MAAA,CAAO,CAAA,GAAI,MAAA,CAAO,KAAA,GAAQ,CAAA;AAAA,EACxC,CAAC,CAAA;AAED,EAAA,MAAM,aAAA,GAAgB,YAAA,CAAa,YAAA,EAAc,CAAC,CAAC,QAAA,EAAU,CAAA,EAAG,QAAQ,CAAA,EAAG,CAAC,IAAA,EAAM,aAAA,EAAe,IAAI,CAAC,CAAA;AAEtG,EAAA,MAAM,SAAA,GAAY,UAAU,aAAA,EAAe;AAAA,IAC1C,IAAA,EAAM,QAAQ,MAAA,CAAO,IAAA;AAAA,IACrB,SAAA,EAAW,QAAQ,MAAA,CAAO,SAAA;AAAA,IAC1B,OAAA,EAAS;AAAA,GACT,CAAA;AAED,EAAA,uBACC,GAAA;AAAA,IAAC,MAAA,CAAO,GAAA;AAAA,IAAP;AAAA,MACA,GAAA;AAAA,MACA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,MAAA,EAAQ,WAAW,OAAA,EAAQ;AAAA,MACtD,SAAA,EAAW,EAAA;AAAA;AAAA,QAEV,2FAAA;AAAA,QACA,CAAA;AAAA,yBAAA,CAAA;AAAA,QAEA;AAAA,OACD;AAAA,MACC,GAAG,KAAA;AAAA,MAEH;AAAA;AAAA,GACF;AAEF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"dock.js","sourcesContent":["import type { Transition } from 'motion/react';\n\n/**\n * Shared motion configuration for consistent animations across the app.\n * Based on practical animation tips from https://emilkowal.ski/ui/7-practical-animation-tips\n *\n * Key principles:\n * 1. Keep UI animations under 300ms\n * 2. Never animate from scale(0) - use 0.9+ for natural feel\n * 3. Use custom easing curves for more impactful animations\n * 4. Make animations origin-aware when possible\n * 5. Use blur to smooth transitions when needed\n */\n\n// =============================================================================\n// Easing Curves\n// =============================================================================\n\n/**\n * Standard easing curves for UI animations.\n * Reference: https://easings.co/\n */\nexport const easings = {\n\t/** Smooth deceleration - good for elements entering the screen */\n\teaseOut: [0.25, 0.1, 0.25, 1] as const,\n\n\t/** Smooth acceleration - good for elements leaving the screen */\n\teaseIn: [0.42, 0, 1, 1] as const,\n\n\t/** Smooth both ways - good for hover states and toggles */\n\teaseInOut: [0.42, 0, 0.58, 1] as const,\n\n\t/** Snappy entrance with soft landing - great for modals/dialogs */\n\tsnappy: [0.2, 0, 0, 1] as const,\n\n\t/** Bouncy feel - use sparingly for playful interactions */\n\tbounce: [0.34, 1.56, 0.64, 1] as const,\n\n\t/** Quick start, gradual stop - good for quick feedback */\n\temphasized: [0.4, 0, 0.2, 1] as const,\n\n\t/** Physical feel for exit animations */\n\tphysicalExit: [0.4, 0, 0.6, 1] as const,\n} as const;\n\n// =============================================================================\n// Duration Presets\n// =============================================================================\n\n/**\n * Duration presets in seconds.\n * Rule: UI animations should be under 300ms (0.3s)\n */\nexport const durations = {\n\t/** Instant feedback (button press, toggle) */\n\tinstant: 0.1,\n\n\t/** Quick transitions (tooltips, small elements) */\n\tfast: 0.15,\n\n\t/** Standard UI transitions (modals, panels) */\n\tnormal: 0.2,\n\n\t/** Deliberate animations (page transitions, complex reveals) */\n\tslow: 0.3,\n\n\t/** Maximum for UI - use rarely */\n\tdeliberate: 0.4,\n} as const;\n\n// =============================================================================\n// Spring Presets\n// =============================================================================\n\n/**\n * Spring configurations for physics-based animations.\n * These create more natural, organic motion.\n */\nexport const springs = {\n\t/** Snappy spring - good for quick interactions */\n\tsnappy: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 400,\n\t\tdamping: 30,\n\t\tmass: 0.8,\n\t},\n\n\t/** Bouncy spring - good for playful elements */\n\tbouncy: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 300,\n\t\tdamping: 20,\n\t\tmass: 0.6,\n\t},\n\n\t/** Gentle spring - good for large elements */\n\tgentle: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t\tmass: 1,\n\t},\n\n\t/** Stiff spring - good for precise movements */\n\tstiff: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 500,\n\t\tdamping: 35,\n\t\tmass: 0.5,\n\t},\n\n\t/** Panel/sheet animations */\n\tpanel: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t},\n} as const;\n\n// =============================================================================\n// Transition Presets\n// =============================================================================\n\n/**\n * Pre-configured transitions for common animation patterns.\n */\nexport const transitions = {\n\t/** Fast fade for overlays and simple elements */\n\tfade: {\n\t\tduration: durations.fast,\n\t\tease: easings.easeOut,\n\t} satisfies Transition,\n\n\t/** Standard enter/exit for UI elements */\n\tenterExit: {\n\t\tduration: durations.normal,\n\t\tease: easings.easeOut,\n\t} satisfies Transition,\n\n\t/** Snappy transition for interactive elements */\n\tsnappy: {\n\t\tduration: durations.fast,\n\t\tease: easings.snappy,\n\t} satisfies Transition,\n\n\t/** Panel slide transition */\n\tpanel: {\n\t\ttype: 'spring',\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t} satisfies Transition,\n\n\t/** Exit transition with physical feel */\n\texit: {\n\t\ttype: 'tween',\n\t\tduration: durations.normal,\n\t\tease: easings.physicalExit,\n\t} satisfies Transition,\n\n\t/** Layout animations */\n\tlayout: {\n\t\ttype: 'spring',\n\t\tstiffness: 300,\n\t\tdamping: 30,\n\t} satisfies Transition,\n} as const;\n\n// =============================================================================\n// Animation Variants\n// =============================================================================\n\n/**\n * Common animation variants for AnimatePresence patterns.\n * Follows the rule: never animate from scale(0), use 0.9+ instead.\n */\nexport const variants = {\n\t/** Fade with subtle scale - good for modals, cards */\n\tfadeScale: {\n\t\tinitial: { opacity: 0, scale: 0.95 },\n\t\tanimate: { opacity: 1, scale: 1 },\n\t\texit: { opacity: 0, scale: 0.95 },\n\t},\n\n\t/** Fade with subtle slide up - good for content reveals */\n\tfadeSlideUp: {\n\t\tinitial: { opacity: 0, y: 8 },\n\t\tanimate: { opacity: 1, y: 0 },\n\t\texit: { opacity: 0, y: -8 },\n\t},\n\n\t/** Fade with subtle slide down - good for dropdowns */\n\tfadeSlideDown: {\n\t\tinitial: { opacity: 0, y: -8 },\n\t\tanimate: { opacity: 1, y: 0 },\n\t\texit: { opacity: 0, y: 8 },\n\t},\n\n\t/** Simple fade - for overlays */\n\tfade: {\n\t\tinitial: { opacity: 0 },\n\t\tanimate: { opacity: 1 },\n\t\texit: { opacity: 0 },\n\t},\n\n\t/** Dock/floating element - scales from bottom */\n\tfloatUp: {\n\t\tinitial: { opacity: 0, y: 8, scale: 0.98 },\n\t\tanimate: { opacity: 1, y: 0, scale: 1 },\n\t\texit: { opacity: 0, y: 8, scale: 0.98 },\n\t},\n} as const;\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport React, { PropsWithChildren, useRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { motion, MotionProps, MotionValue, useMotionValue, useSpring, useTransform } from 'motion/react';\n\nimport { springs } from '../lib/motion/motion-config';\nimport { cn } from '../lib/utils';\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n\tclassName?: string;\n\ticonSize?: number;\n\ticonMagnification?: number;\n\ticonDistance?: number;\n\tdirection?: 'top' | 'middle' | 'bottom';\n\tchildren: React.ReactNode;\n}\n\nconst DEFAULT_SIZE = 40;\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n\t// Solid themed surface (no glass/blur)\n\t'mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl border bg-card p-2 shadow',\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\ticonSize = DEFAULT_SIZE,\n\t\t\ticonMagnification = DEFAULT_MAGNIFICATION,\n\t\t\ticonDistance = DEFAULT_DISTANCE,\n\t\t\tdirection = 'middle',\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst mouseX = useMotionValue(Infinity);\n\n\t\tconst renderChildren = () => {\n\t\t\treturn React.Children.map(children, (child) => {\n\t\t\t\tif (React.isValidElement<DockIconProps>(child) && child.type === DockIcon) {\n\t\t\t\t\treturn React.cloneElement(child, {\n\t\t\t\t\t\t...child.props,\n\t\t\t\t\t\tmouseX: mouseX,\n\t\t\t\t\t\tsize: iconSize,\n\t\t\t\t\t\tmagnification: iconMagnification,\n\t\t\t\t\t\tdistance: iconDistance,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn child;\n\t\t\t});\n\t\t};\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\tref={ref}\n\t\t\t\tonMouseMove={(e) => mouseX.set(e.pageX)}\n\t\t\t\tonMouseLeave={() => mouseX.set(Infinity)}\n\t\t\t\t{...props}\n\t\t\t\tclassName={cn(dockVariants({ className }), {\n\t\t\t\t\t'items-start': direction === 'top',\n\t\t\t\t\t'items-center': direction === 'middle',\n\t\t\t\t\t'items-end': direction === 'bottom',\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{renderChildren()}\n\t\t\t</motion.div>\n\t\t);\n\t},\n);\n\nDock.displayName = 'Dock';\n\nexport interface DockIconProps extends Omit<MotionProps & React.HTMLAttributes<HTMLDivElement>, 'children'> {\n\tsize?: number;\n\tmagnification?: number;\n\tdistance?: number;\n\tmouseX?: MotionValue<number>;\n\tclassName?: string;\n\tchildren?: React.ReactNode;\n\tprops?: PropsWithChildren;\n}\n\nconst DockIcon = ({\n\tsize = DEFAULT_SIZE,\n\tmagnification = DEFAULT_MAGNIFICATION,\n\tdistance = DEFAULT_DISTANCE,\n\tmouseX,\n\tclassName,\n\tchildren,\n\t...props\n}: DockIconProps) => {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst padding = Math.max(6, size * 0.2);\n\tconst defaultMouseX = useMotionValue(Infinity);\n\n\tconst distanceCalc = useTransform(mouseX ?? defaultMouseX, (val: number) => {\n\t\tconst bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n\t\treturn val - bounds.x - bounds.width / 2;\n\t});\n\n\tconst sizeTransform = useTransform(distanceCalc, [-distance, 0, distance], [size, magnification, size]);\n\n\tconst scaleSize = useSpring(sizeTransform, {\n\t\tmass: springs.gentle.mass,\n\t\tstiffness: springs.gentle.stiffness,\n\t\tdamping: 12,\n\t});\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ref}\n\t\t\tstyle={{ width: scaleSize, height: scaleSize, padding }}\n\t\t\tclassName={cn(\n\t\t\t\t// Solid hover target with theme-aware colors\n\t\t\t\t'flex aspect-square cursor-pointer items-center justify-center rounded-full bg-transparent',\n\t\t\t\t`hover:bg-muted focus-visible:bg-muted/80 focus-visible:outline-ring transition-colors duration-200\n\t\t\t\tfocus-visible:outline`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t</motion.div>\n\t);\n};\n\nDockIcon.displayName = 'DockIcon';\n\nexport { Dock, DockIcon, dockVariants };\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/motion/motion-config.ts","../../src/lib/utils.ts","../../src/components/dock.tsx"],"names":[],"mappings":";;;;;;;AA8EO,IAAM,OAAA,GAAU;AAAA,EAetB;AAAA,EAGA,MAAA,EAAQ;AAAA,IAEP,SAAA,EAAW,GAAA;AAAA,IAEX,IAAA,EAAM;AAAA,GAiBR,CAAA;AClHO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACqBA,IAAM,YAAA,GAAe,EAAA;AACrB,IAAM,qBAAA,GAAwB,EAAA;AAC9B,IAAM,gBAAA,GAAmB,GAAA;AAEzB,IAAM,YAAA,GAAe,GAAA;AAAA;AAAA,EAEpB;AACD;AAEA,IAAM,OAAO,K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;AAAA,GACT,CAAA;AAED,EAAA,uBACC,GAAA;AAAA,IAAC,MAAA,CAAO,GAAA;AAAA,IAAP;AAAA,MACA,GAAA;AAAA,MACA,KAAA,EAAO,EAAE,KAAA,EAAO,oBAAA,GAAuB,IAAA,GAAO,WAAW,MAAA,EAAQ,oBAAA,GAAuB,IAAA,GAAO,SAAA,EAAW,OAAA,EAAQ;AAAA,MAClH,SAAA,EAAW,EAAA;AAAA;AAAA,QAEV,2FAAA;AAAA,QACA,CAAA;AAAA,yBAAA,CAAA;AAAA,QAEA;AAAA,OACD;AAAA,MACC,GAAG,KAAA;AAAA,MAEH;AAAA;AAAA,GACF;AAEF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"dock.js","sourcesContent":["import type { Transition } from 'motion/react';\n\n/**\n * Shared motion configuration for consistent animations across the app.\n * Based on practical animation tips from https://emilkowal.ski/ui/7-practical-animation-tips\n *\n * Key principles:\n * 1. Keep UI animations under 300ms\n * 2. Never animate from scale(0) - use 0.9+ for natural feel\n * 3. Use custom easing curves for more impactful animations\n * 4. Make animations origin-aware when possible\n * 5. Use blur to smooth transitions when needed\n */\n\n// =============================================================================\n// Easing Curves\n// =============================================================================\n\n/**\n * Standard easing curves for UI animations.\n * Reference: https://easings.co/\n */\nexport const easings = {\n\t/** Smooth deceleration - good for elements entering the screen */\n\teaseOut: [0.25, 0.1, 0.25, 1] as const,\n\n\t/** Smooth acceleration - good for elements leaving the screen */\n\teaseIn: [0.42, 0, 1, 1] as const,\n\n\t/** Smooth both ways - good for hover states and toggles */\n\teaseInOut: [0.42, 0, 0.58, 1] as const,\n\n\t/** Snappy entrance with soft landing - great for modals/dialogs */\n\tsnappy: [0.2, 0, 0, 1] as const,\n\n\t/** Bouncy feel - use sparingly for playful interactions */\n\tbounce: [0.34, 1.56, 0.64, 1] as const,\n\n\t/** Quick start, gradual stop - good for quick feedback */\n\temphasized: [0.4, 0, 0.2, 1] as const,\n\n\t/** Physical feel for exit animations */\n\tphysicalExit: [0.4, 0, 0.6, 1] as const,\n} as const;\n\n// =============================================================================\n// Duration Presets\n// =============================================================================\n\n/**\n * Duration presets in seconds.\n * Rule: UI animations should be under 300ms (0.3s)\n */\nexport const durations = {\n\t/** Instant feedback (button press, toggle) */\n\tinstant: 0.1,\n\n\t/** Quick transitions (tooltips, small elements) */\n\tfast: 0.15,\n\n\t/** Standard UI transitions (modals, panels) */\n\tnormal: 0.2,\n\n\t/** Deliberate animations (page transitions, complex reveals) */\n\tslow: 0.3,\n\n\t/** Maximum for UI - use rarely */\n\tdeliberate: 0.4,\n} as const;\n\n// =============================================================================\n// Spring Presets\n// =============================================================================\n\n/**\n * Spring configurations for physics-based animations.\n * These create more natural, organic motion.\n */\nexport const springs = {\n\t/** Snappy spring - good for quick interactions */\n\tsnappy: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 400,\n\t\tdamping: 30,\n\t\tmass: 0.8,\n\t},\n\n\t/** Bouncy spring - good for playful elements */\n\tbouncy: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 300,\n\t\tdamping: 20,\n\t\tmass: 0.6,\n\t},\n\n\t/** Gentle spring - good for large elements */\n\tgentle: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t\tmass: 1,\n\t},\n\n\t/** Stiff spring - good for precise movements */\n\tstiff: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 500,\n\t\tdamping: 35,\n\t\tmass: 0.5,\n\t},\n\n\t/** Panel/sheet animations */\n\tpanel: {\n\t\ttype: 'spring' as const,\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t},\n} as const;\n\n// =============================================================================\n// Transition Presets\n// =============================================================================\n\n/**\n * Pre-configured transitions for common animation patterns.\n */\nexport const transitions = {\n\t/** Fast fade for overlays and simple elements */\n\tfade: {\n\t\tduration: durations.fast,\n\t\tease: easings.easeOut,\n\t} satisfies Transition,\n\n\t/** Standard enter/exit for UI elements */\n\tenterExit: {\n\t\tduration: durations.normal,\n\t\tease: easings.easeOut,\n\t} satisfies Transition,\n\n\t/** Snappy transition for interactive elements */\n\tsnappy: {\n\t\tduration: durations.fast,\n\t\tease: easings.snappy,\n\t} satisfies Transition,\n\n\t/** Panel slide transition */\n\tpanel: {\n\t\ttype: 'spring',\n\t\tstiffness: 150,\n\t\tdamping: 25,\n\t} satisfies Transition,\n\n\t/** Exit transition with physical feel */\n\texit: {\n\t\ttype: 'tween',\n\t\tduration: durations.normal,\n\t\tease: easings.physicalExit,\n\t} satisfies Transition,\n\n\t/** Layout animations */\n\tlayout: {\n\t\ttype: 'spring',\n\t\tstiffness: 300,\n\t\tdamping: 30,\n\t} satisfies Transition,\n} as const;\n\n// =============================================================================\n// Animation Variants\n// =============================================================================\n\n/**\n * Common animation variants for AnimatePresence patterns.\n * Follows the rule: never animate from scale(0), use 0.9+ instead.\n */\nexport const variants = {\n\t/** Fade with subtle scale - good for modals, cards */\n\tfadeScale: {\n\t\tinitial: { opacity: 0, scale: 0.95 },\n\t\tanimate: { opacity: 1, scale: 1 },\n\t\texit: { opacity: 0, scale: 0.95 },\n\t},\n\n\t/** Fade with subtle slide up - good for content reveals */\n\tfadeSlideUp: {\n\t\tinitial: { opacity: 0, y: 8 },\n\t\tanimate: { opacity: 1, y: 0 },\n\t\texit: { opacity: 0, y: -8 },\n\t},\n\n\t/** Fade with subtle slide down - good for dropdowns */\n\tfadeSlideDown: {\n\t\tinitial: { opacity: 0, y: -8 },\n\t\tanimate: { opacity: 1, y: 0 },\n\t\texit: { opacity: 0, y: 8 },\n\t},\n\n\t/** Simple fade - for overlays */\n\tfade: {\n\t\tinitial: { opacity: 0 },\n\t\tanimate: { opacity: 1 },\n\t\texit: { opacity: 0 },\n\t},\n\n\t/** Dock/floating element - scales from bottom */\n\tfloatUp: {\n\t\tinitial: { opacity: 0, y: 8, scale: 0.98 },\n\t\tanimate: { opacity: 1, y: 0, scale: 1 },\n\t\texit: { opacity: 0, y: 8, scale: 0.98 },\n\t},\n} as const;\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport React, { PropsWithChildren, useRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport {\n\tmotion,\n\tMotionProps,\n\tMotionValue,\n\tuseMotionValue,\n\tuseReducedMotion,\n\tuseSpring,\n\tuseTransform,\n} from 'motion/react';\n\nimport { springs } from '../lib/motion/motion-config';\nimport { cn } from '../lib/utils';\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n\tclassName?: string;\n\ticonSize?: number;\n\ticonMagnification?: number;\n\ticonDistance?: number;\n\tdirection?: 'top' | 'middle' | 'bottom';\n\tchildren: React.ReactNode;\n}\n\nconst DEFAULT_SIZE = 40;\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n\t// Solid themed surface (no glass/blur)\n\t'mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl bg-card p-2 shadow-card',\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\ticonSize = DEFAULT_SIZE,\n\t\t\ticonMagnification = DEFAULT_MAGNIFICATION,\n\t\t\ticonDistance = DEFAULT_DISTANCE,\n\t\t\tdirection = 'middle',\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst mouseX = useMotionValue(Infinity);\n\t\tconst prefersReducedMotion = useReducedMotion();\n\n\t\tconst renderChildren = () => {\n\t\t\treturn React.Children.map(children, (child) => {\n\t\t\t\tif (React.isValidElement<DockIconProps>(child) && child.type === DockIcon) {\n\t\t\t\t\treturn React.cloneElement(child, {\n\t\t\t\t\t\t...child.props,\n\t\t\t\t\t\tmouseX: mouseX,\n\t\t\t\t\t\tsize: iconSize,\n\t\t\t\t\t\tmagnification: iconMagnification,\n\t\t\t\t\t\tdistance: iconDistance,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn child;\n\t\t\t});\n\t\t};\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\tref={ref}\n\t\t\t\tonMouseMove={prefersReducedMotion ? undefined : (event) => mouseX.set(event.pageX)}\n\t\t\t\tonMouseLeave={prefersReducedMotion ? undefined : () => mouseX.set(Infinity)}\n\t\t\t\t{...props}\n\t\t\t\tclassName={cn(dockVariants({ className }), {\n\t\t\t\t\t'items-start': direction === 'top',\n\t\t\t\t\t'items-center': direction === 'middle',\n\t\t\t\t\t'items-end': direction === 'bottom',\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{renderChildren()}\n\t\t\t</motion.div>\n\t\t);\n\t},\n);\n\nDock.displayName = 'Dock';\n\nexport interface DockIconProps extends Omit<MotionProps & React.HTMLAttributes<HTMLDivElement>, 'children'> {\n\tsize?: number;\n\tmagnification?: number;\n\tdistance?: number;\n\tmouseX?: MotionValue<number>;\n\tclassName?: string;\n\tchildren?: React.ReactNode;\n\tprops?: PropsWithChildren;\n}\n\nconst DockIcon = ({\n\tsize = DEFAULT_SIZE,\n\tmagnification = DEFAULT_MAGNIFICATION,\n\tdistance = DEFAULT_DISTANCE,\n\tmouseX,\n\tclassName,\n\tchildren,\n\t...props\n}: DockIconProps) => {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst padding = Math.max(6, size * 0.2);\n\tconst defaultMouseX = useMotionValue(Infinity);\n\n\tconst distanceCalc = useTransform(mouseX ?? defaultMouseX, (val: number) => {\n\t\tconst bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n\t\treturn val - bounds.x - bounds.width / 2;\n\t});\n\n\tconst sizeTransform = useTransform(distanceCalc, [-distance, 0, distance], [size, magnification, size]);\n\n\tconst scaleSize = useSpring(sizeTransform, {\n\t\tmass: springs.gentle.mass,\n\t\tstiffness: springs.gentle.stiffness,\n\t\tdamping: 12,\n\t});\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ref}\n\t\t\tstyle={{ width: prefersReducedMotion ? size : scaleSize, height: prefersReducedMotion ? size : scaleSize, padding }}\n\t\t\tclassName={cn(\n\t\t\t\t// Solid hover target with theme-aware colors\n\t\t\t\t'flex aspect-square cursor-pointer items-center justify-center rounded-full bg-transparent',\n\t\t\t\t`hover:bg-muted focus-visible:bg-muted/80 focus-visible:outline-ring transition-colors duration-200\n\t\t\t\tfocus-visible:outline`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t</motion.div>\n\t);\n};\n\nDockIcon.displayName = 'DockIcon';\n\nexport { Dock, DockIcon, dockVariants };\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var vaul = require('vaul');
|
|
6
|
+
var portal = require('@constructive-io/ui/portal');
|
|
7
|
+
var clsx = require('clsx');
|
|
8
|
+
var tailwindMerge = require('tailwind-merge');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
+
|
|
31
|
+
function cn(...inputs) {
|
|
32
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
33
|
+
}
|
|
34
|
+
function Drawer({ ...props }) {
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(vaul.Drawer.Root, { "data-slot": "drawer", ...props });
|
|
36
|
+
}
|
|
37
|
+
function DrawerTrigger({ ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsxRuntime.jsx(vaul.Drawer.Trigger, { "data-slot": "drawer-trigger", ...props });
|
|
39
|
+
}
|
|
40
|
+
function DrawerPortal({ container: containerProp, ...props }) {
|
|
41
|
+
const rootContainer = portal.useRootPortalContainer();
|
|
42
|
+
const container = containerProp === void 0 ? rootContainer ?? void 0 : containerProp;
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx(vaul.Drawer.Portal, { "data-slot": "drawer-portal", container, ...props });
|
|
44
|
+
}
|
|
45
|
+
function DrawerClose({ ...props }) {
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(vaul.Drawer.Close, { "data-slot": "drawer-close", ...props });
|
|
47
|
+
}
|
|
48
|
+
function DrawerOverlay({ className, ...props }) {
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
vaul.Drawer.Overlay,
|
|
51
|
+
{
|
|
52
|
+
"data-slot": "drawer-overlay",
|
|
53
|
+
className: cn(
|
|
54
|
+
`fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/50
|
|
55
|
+
data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]
|
|
56
|
+
motion-reduce:animate-none`,
|
|
57
|
+
className
|
|
58
|
+
),
|
|
59
|
+
...props
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function DrawerContent({ className, children, ...props }) {
|
|
64
|
+
const [floatingContainer, setFloatingContainer] = React__namespace.useState(null);
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DrawerPortal, { children: [
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx(DrawerOverlay, {}),
|
|
67
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
68
|
+
vaul.Drawer.Content,
|
|
69
|
+
{
|
|
70
|
+
"data-slot": "drawer-content",
|
|
71
|
+
className: cn(
|
|
72
|
+
"group/drawer-content bg-background fixed z-[var(--z-layer-modal-content)] flex h-auto flex-col",
|
|
73
|
+
`data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0
|
|
74
|
+
data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh]
|
|
75
|
+
data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b`,
|
|
76
|
+
`data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0
|
|
77
|
+
data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh]
|
|
78
|
+
data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t`,
|
|
79
|
+
`data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0
|
|
80
|
+
data-[vaul-drawer-direction=right]:border-l`,
|
|
81
|
+
`data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0
|
|
82
|
+
data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r
|
|
83
|
+
data-[vaul-drawer-direction=left]:sm:max-w-sm`,
|
|
84
|
+
className
|
|
85
|
+
),
|
|
86
|
+
...props,
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: "bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full\n group-data-[vaul-drawer-direction=bottom]/drawer-content:block"
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: setFloatingContainer, "data-slot": "drawer-floating-portal", className: "contents", children: /* @__PURE__ */ jsxRuntime.jsx(portal.ModalPortalScope, { floatingContainer, floatingZIndex: "elevated", children }) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
function DrawerHeader({ className, ...props }) {
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
"data-slot": "drawer-header",
|
|
105
|
+
className: cn(
|
|
106
|
+
`flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center
|
|
107
|
+
group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left`,
|
|
108
|
+
className
|
|
109
|
+
),
|
|
110
|
+
...props
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function DrawerFooter({ className, ...props }) {
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "drawer-footer", className: cn("mt-auto flex flex-col gap-2 p-4", className), ...props });
|
|
116
|
+
}
|
|
117
|
+
function DrawerTitle({ className, ...props }) {
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
vaul.Drawer.Title,
|
|
120
|
+
{
|
|
121
|
+
"data-slot": "drawer-title",
|
|
122
|
+
className: cn("text-foreground font-semibold", className),
|
|
123
|
+
...props
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function DrawerDescription({ className, ...props }) {
|
|
128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
129
|
+
vaul.Drawer.Description,
|
|
130
|
+
{
|
|
131
|
+
"data-slot": "drawer-description",
|
|
132
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
133
|
+
...props
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exports.Drawer = Drawer;
|
|
139
|
+
exports.DrawerClose = DrawerClose;
|
|
140
|
+
exports.DrawerContent = DrawerContent;
|
|
141
|
+
exports.DrawerDescription = DrawerDescription;
|
|
142
|
+
exports.DrawerFooter = DrawerFooter;
|
|
143
|
+
exports.DrawerHeader = DrawerHeader;
|
|
144
|
+
exports.DrawerOverlay = DrawerOverlay;
|
|
145
|
+
exports.DrawerPortal = DrawerPortal;
|
|
146
|
+
exports.DrawerTitle = DrawerTitle;
|
|
147
|
+
exports.DrawerTrigger = DrawerTrigger;
|
|
148
|
+
//# sourceMappingURL=drawer.cjs.map
|
|
149
|
+
//# sourceMappingURL=drawer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/components/drawer.tsx"],"names":["twMerge","clsx","DrawerPrimitive","useRootPortalContainer","jsx","React","jsxs","ModalPortalScope"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACGA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAAsD;AAChF,EAAA,sCAAQC,WAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC5D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAyD;AAC1F,EAAA,sCAAQA,WAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACvE;AAEA,SAAS,aAAa,EAAE,SAAA,EAAW,aAAA,EAAe,GAAG,OAAM,EAAwD;AAClH,EAAA,MAAM,gBAAgBC,6BAAA,EAAuB;AAC7C,EAAA,MAAM,SAAA,GAAY,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AAA;AAAA,IAACF,WAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF","file":"drawer.cjs","sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\n\nimport { ModalPortalScope, useRootPortalContainer } from '@constructive-io/ui/portal';\nimport { cn } from '../lib/utils';\n\nfunction Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n\treturn <DrawerPrimitive.Root data-slot=\"drawer\" {...props} />;\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n\treturn <DrawerPrimitive.Trigger data-slot=\"drawer-trigger\" {...props} />;\n}\n\nfunction DrawerPortal({ container: containerProp, ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n\tconst rootContainer = useRootPortalContainer();\n\tconst container = containerProp === undefined ? (rootContainer ?? undefined) : containerProp;\n\treturn <DrawerPrimitive.Portal data-slot=\"drawer-portal\" container={container} {...props} />;\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n\treturn <DrawerPrimitive.Close data-slot=\"drawer-close\" {...props} />;\n}\n\nfunction DrawerOverlay({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n\treturn (\n\t\t<DrawerPrimitive.Overlay\n\t\t\tdata-slot=\"drawer-overlay\"\n\t\t\tclassName={cn(\n\t\t\t\t`fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/50\n\t\t\t\tdata-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]\n\t\t\t\tmotion-reduce:animate-none`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerContent({ className, children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n\tconst [floatingContainer, setFloatingContainer] = React.useState<HTMLDivElement | null>(null);\n\n\treturn (\n\t\t<DrawerPortal>\n\t\t\t<DrawerOverlay />\n\t\t\t<DrawerPrimitive.Content\n\t\t\t\tdata-slot=\"drawer-content\"\n\t\t\t\tclassName={cn(\n\t\t\t\t\t'group/drawer-content bg-background fixed z-[var(--z-layer-modal-content)] flex h-auto flex-col',\n\t\t\t\t\t`data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b`,\n\t\t\t\t\t`data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t`,\n\t\t\t\t\t`data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0\n\t\t\t\t\tdata-[vaul-drawer-direction=right]:border-l`,\n\t\t\t\t\t`data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:sm:max-w-sm`,\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName='bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full\n\t\t\t\t\t\tgroup-data-[vaul-drawer-direction=bottom]/drawer-content:block'\n\t\t\t\t/>\n\t\t\t\t<div ref={setFloatingContainer} data-slot='drawer-floating-portal' className='contents'>\n\t\t\t\t\t<ModalPortalScope floatingContainer={floatingContainer} floatingZIndex='elevated'>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</ModalPortalScope>\n\t\t\t\t</div>\n\t\t\t</DrawerPrimitive.Content>\n\t\t</DrawerPortal>\n\t);\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"drawer-header\"\n\t\t\tclassName={cn(\n\t\t\t\t`flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center\n\t\t\t\tgroup-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn <div data-slot=\"drawer-footer\" className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n\treturn (\n\t\t<DrawerPrimitive.Title\n\t\t\tdata-slot=\"drawer-title\"\n\t\t\tclassName={cn('text-foreground font-semibold', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerDescription({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n\treturn (\n\t\t<DrawerPrimitive.Description\n\t\t\tdata-slot=\"drawer-description\"\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tDrawer,\n\tDrawerPortal,\n\tDrawerOverlay,\n\tDrawerTrigger,\n\tDrawerClose,\n\tDrawerContent,\n\tDrawerHeader,\n\tDrawerFooter,\n\tDrawerTitle,\n\tDrawerDescription,\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Drawer as Drawer$1 } from 'vaul';
|
|
3
|
+
|
|
4
|
+
declare function Drawer({ ...props }: React.ComponentProps<typeof Drawer$1.Root>): React.JSX.Element;
|
|
5
|
+
declare function DrawerTrigger({ ...props }: React.ComponentProps<typeof Drawer$1.Trigger>): React.JSX.Element;
|
|
6
|
+
declare function DrawerPortal({ container: containerProp, ...props }: React.ComponentProps<typeof Drawer$1.Portal>): React.JSX.Element;
|
|
7
|
+
declare function DrawerClose({ ...props }: React.ComponentProps<typeof Drawer$1.Close>): React.JSX.Element;
|
|
8
|
+
declare function DrawerOverlay({ className, ...props }: React.ComponentProps<typeof Drawer$1.Overlay>): React.JSX.Element;
|
|
9
|
+
declare function DrawerContent({ className, children, ...props }: React.ComponentProps<typeof Drawer$1.Content>): React.JSX.Element;
|
|
10
|
+
declare function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
11
|
+
declare function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
12
|
+
declare function DrawerTitle({ className, ...props }: React.ComponentProps<typeof Drawer$1.Title>): React.JSX.Element;
|
|
13
|
+
declare function DrawerDescription({ className, ...props }: React.ComponentProps<typeof Drawer$1.Description>): React.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { Drawer as Drawer$1 } from 'vaul';
|
|
4
3
|
|
|
5
|
-
declare function Drawer({ ...props }: React.ComponentProps<typeof Drawer$1.Root>):
|
|
6
|
-
declare function DrawerTrigger({ ...props }: React.ComponentProps<typeof Drawer$1.Trigger>):
|
|
7
|
-
declare function DrawerPortal({ ...props }: React.ComponentProps<typeof Drawer$1.Portal>):
|
|
8
|
-
declare function DrawerClose({ ...props }: React.ComponentProps<typeof Drawer$1.Close>):
|
|
9
|
-
declare function DrawerOverlay({ className, ...props }: React.ComponentProps<typeof Drawer$1.Overlay>):
|
|
10
|
-
declare function DrawerContent({ className, children, ...props }: React.ComponentProps<typeof Drawer$1.Content>):
|
|
11
|
-
declare function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>):
|
|
12
|
-
declare function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>):
|
|
13
|
-
declare function DrawerTitle({ className, ...props }: React.ComponentProps<typeof Drawer$1.Title>):
|
|
14
|
-
declare function DrawerDescription({ className, ...props }: React.ComponentProps<typeof Drawer$1.Description>):
|
|
4
|
+
declare function Drawer({ ...props }: React.ComponentProps<typeof Drawer$1.Root>): React.JSX.Element;
|
|
5
|
+
declare function DrawerTrigger({ ...props }: React.ComponentProps<typeof Drawer$1.Trigger>): React.JSX.Element;
|
|
6
|
+
declare function DrawerPortal({ container: containerProp, ...props }: React.ComponentProps<typeof Drawer$1.Portal>): React.JSX.Element;
|
|
7
|
+
declare function DrawerClose({ ...props }: React.ComponentProps<typeof Drawer$1.Close>): React.JSX.Element;
|
|
8
|
+
declare function DrawerOverlay({ className, ...props }: React.ComponentProps<typeof Drawer$1.Overlay>): React.JSX.Element;
|
|
9
|
+
declare function DrawerContent({ className, children, ...props }: React.ComponentProps<typeof Drawer$1.Content>): React.JSX.Element;
|
|
10
|
+
declare function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
11
|
+
declare function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
12
|
+
declare function DrawerTitle({ className, ...props }: React.ComponentProps<typeof Drawer$1.Title>): React.JSX.Element;
|
|
13
|
+
declare function DrawerDescription({ className, ...props }: React.ComponentProps<typeof Drawer$1.Description>): React.JSX.Element;
|
|
15
14
|
|
|
16
15
|
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger };
|
|
@@ -1,43 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Drawer as Drawer$1 } from 'vaul';
|
|
3
2
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
3
|
+
import { Drawer as Drawer$1 } from 'vaul';
|
|
4
|
+
import { useRootPortalContainer, ModalPortalScope } from '@constructive-io/ui/portal';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
8
|
|
|
8
|
-
var PORTAL_ROOT_ID = "portal-root";
|
|
9
|
-
var PortalContext = React.createContext({
|
|
10
|
-
layer: "base",
|
|
11
|
-
depth: 0,
|
|
12
|
-
floatingPortalStrategy: "root",
|
|
13
|
-
floatingZIndex: "default"
|
|
14
|
-
});
|
|
15
|
-
function ModalPortalScope({
|
|
16
|
-
children,
|
|
17
|
-
floatingPortalStrategy = "nested",
|
|
18
|
-
floatingZIndex = "default"
|
|
19
|
-
}) {
|
|
20
|
-
const parentContext = React.useContext(PortalContext);
|
|
21
|
-
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
22
|
-
const value = React.useMemo(
|
|
23
|
-
() => ({
|
|
24
|
-
layer: "modal",
|
|
25
|
-
depth,
|
|
26
|
-
floatingPortalStrategy,
|
|
27
|
-
floatingZIndex
|
|
28
|
-
}),
|
|
29
|
-
[depth, floatingPortalStrategy, floatingZIndex]
|
|
30
|
-
);
|
|
31
|
-
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
32
|
-
}
|
|
33
|
-
function useRootPortalContainer() {
|
|
34
|
-
const [container, setContainer] = React.useState(null);
|
|
35
|
-
React.useLayoutEffect(() => {
|
|
36
|
-
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
37
|
-
setContainer(el);
|
|
38
|
-
}, []);
|
|
39
|
-
return container;
|
|
40
|
-
}
|
|
41
9
|
function cn(...inputs) {
|
|
42
10
|
return twMerge(clsx(inputs));
|
|
43
11
|
}
|
|
@@ -47,8 +15,9 @@ function Drawer({ ...props }) {
|
|
|
47
15
|
function DrawerTrigger({ ...props }) {
|
|
48
16
|
return /* @__PURE__ */ jsx(Drawer$1.Trigger, { "data-slot": "drawer-trigger", ...props });
|
|
49
17
|
}
|
|
50
|
-
function DrawerPortal({ ...props }) {
|
|
51
|
-
const
|
|
18
|
+
function DrawerPortal({ container: containerProp, ...props }) {
|
|
19
|
+
const rootContainer = useRootPortalContainer();
|
|
20
|
+
const container = containerProp === void 0 ? rootContainer ?? void 0 : containerProp;
|
|
52
21
|
return /* @__PURE__ */ jsx(Drawer$1.Portal, { "data-slot": "drawer-portal", container, ...props });
|
|
53
22
|
}
|
|
54
23
|
function DrawerClose({ ...props }) {
|
|
@@ -60,8 +29,9 @@ function DrawerOverlay({ className, ...props }) {
|
|
|
60
29
|
{
|
|
61
30
|
"data-slot": "drawer-overlay",
|
|
62
31
|
className: cn(
|
|
63
|
-
`
|
|
64
|
-
data-[state=open]:fade-
|
|
32
|
+
`fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/50
|
|
33
|
+
data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]
|
|
34
|
+
motion-reduce:animate-none`,
|
|
65
35
|
className
|
|
66
36
|
),
|
|
67
37
|
...props
|
|
@@ -69,6 +39,7 @@ function DrawerOverlay({ className, ...props }) {
|
|
|
69
39
|
);
|
|
70
40
|
}
|
|
71
41
|
function DrawerContent({ className, children, ...props }) {
|
|
42
|
+
const [floatingContainer, setFloatingContainer] = React.useState(null);
|
|
72
43
|
return /* @__PURE__ */ jsxs(DrawerPortal, { children: [
|
|
73
44
|
/* @__PURE__ */ jsx(DrawerOverlay, {}),
|
|
74
45
|
/* @__PURE__ */ jsxs(
|
|
@@ -98,7 +69,7 @@ function DrawerContent({ className, children, ...props }) {
|
|
|
98
69
|
className: "bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full\n group-data-[vaul-drawer-direction=bottom]/drawer-content:block"
|
|
99
70
|
}
|
|
100
71
|
),
|
|
101
|
-
/* @__PURE__ */ jsx(
|
|
72
|
+
/* @__PURE__ */ jsx("div", { ref: setFloatingContainer, "data-slot": "drawer-floating-portal", className: "contents", children: /* @__PURE__ */ jsx(ModalPortalScope, { floatingContainer, floatingZIndex: "elevated", children }) })
|
|
102
73
|
]
|
|
103
74
|
}
|
|
104
75
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/portal.tsx","../../src/lib/utils.ts","../../src/components/drawer.tsx"],"names":["jsx","DrawerPrimitive"],"mappings":";;;;;;AA4CO,IAAM,cAAA,GAAiB,aAAA;AAM9B,IAAM,gBAAsB,KAAA,CAAA,aAAA,CAAkC;AAAA,EAC7D,KAAA,EAAO,MAAA;AAAA,EACP,KAAA,EAAO,CAAA;AAAA,EACP,sBAAA,EAAwB,MAAA;AAAA,EACxB,cAAA,EAAgB;AACjB,CAAC,CAAA;AAuBM,SAAS,gBAAA,CAAiB;AAAA,EAChC,QAAA;AAAA,EACA,sBAAA,GAAyB,QAAA;AAAA,EACzB,cAAA,GAAiB;AAClB,CAAA,EAIG;AACF,EAAA,MAAM,aAAA,GAAsB,iBAAW,aAAa,CAAA;AAGpD,EAAA,MAAM,QAAQ,aAAA,CAAc,KAAA,KAAU,OAAA,GAAU,aAAA,CAAc,QAAQ,CAAA,GAAI,CAAA;AAE1E,EAAA,MAAM,KAAA,GAAc,KAAA,CAAA,OAAA;AAAA,IACnB,OAAO;AAAA,MACN,KAAA,EAAO,OAAA;AAAA,MACP,KAAA;AAAA,MACA,sBAAA;AAAA,MACA;AAAA,KACD,CA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AA;AAAA,IAAA;AAAA,MACA,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACV,CAAA;AAAA,6FAAA,CAAA;AAAA,QAEA;AAAA,OACD;AAAA,MACC,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC3E,EAAA,uBAAOA,GAAAA,CAAC,KAAA,EAAA,EAAI,WAAA,EAAU,eAAA,EAAgB,SAAA,EAAW,EAAA,CAAG,iCAAA,EAAmC,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAC/G;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuD;AACjG,EAAA,uBACCA,GAAAA;AAAA,IAACC,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,iBAAA,CAAkB,EAAE,SAAA,EAAW,GAAG,OAAM,EAA6D;AAC7G,EAAA,uBACCD,GAAAA;AAAA,IAACC,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF","file":"drawer.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Overlay layer type:\n * - 'base': Root level (page content, base floating elements)\n * - 'modal': Inside a modal overlay (dialog, sheet, drawer)\n */\nexport type OverlayLayer = 'base' | 'modal';\n\n/**\n * Where floating overlays should portal:\n * - 'root': always portal into #portal-root\n * - 'nested': let Base UI nest portals into the nearest Base UI portal node\n */\nexport type FloatingPortalStrategy = 'root' | 'nested';\n\n/**\n * Z-index mode for floating overlays.\n * - 'default': --z-layer-floating\n * - 'elevated': --z-layer-floating-elevated\n */\nexport type FloatingZIndex = 'default' | 'elevated';\n\ninterface PortalContextValue {\n\t/** Current overlay layer */\n\tlayer: OverlayLayer;\n\t/** Modal nesting depth (0 for first modal, 1 for nested, etc.) */\n\tdepth: number;\n\t/** Strategy for where floating overlays should portal */\n\tfloatingPortalStrategy: FloatingPortalStrategy;\n\t/** Z-index mode for floating overlays */\n\tfloatingZIndex: FloatingZIndex;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nexport const PORTAL_ROOT_ID = 'portal-root';\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst PortalContext = React.createContext<PortalContextValue>({\n\tlayer: 'base',\n\tdepth: 0,\n\tfloatingPortalStrategy: 'root',\n\tfloatingZIndex: 'default',\n});\n\n// ============================================================================\n// Providers\n// ============================================================================\n\n/**\n * Provider for modal overlays (Dialog, Sheet, Drawer, etc.)\n *\n * Wraps modal content to:\n * 1. Create a scoped portal container for nested floating elements\n * 2. Track the overlay layer (so floating elements know to use elevated z-index)\n * 3. Track nesting depth for stacked modals\n *\n * Usage:\n * ```tsx\n * <DialogPopup>\n * <ModalPortalScope>\n * {children} // Popovers inside here will render in the scoped container\n * </ModalPortalScope>\n * </DialogPopup>\n * ```\n */\nexport function ModalPortalScope({\n\tchildren,\n\tfloatingPortalStrategy = 'nested',\n\tfloatingZIndex = 'default',\n}: {\n\tchildren: React.ReactNode;\n\tfloatingPortalStrategy?: FloatingPortalStrategy;\n\tfloatingZIndex?: FloatingZIndex;\n}) {\n\tconst parentContext = React.useContext(PortalContext);\n\n\t// Increment depth from parent if already in modal layer\n\tconst depth = parentContext.layer === 'modal' ? parentContext.depth + 1 : 0;\n\n\tconst value = React.useMemo<PortalContextValue>(\n\t\t() => ({\n\t\t\tlayer: 'modal',\n\t\t\tdepth,\n\t\t\tfloatingPortalStrategy,\n\t\t\tfloatingZIndex,\n\t\t}),\n\t\t[depth, floatingPortalStrategy, floatingZIndex],\n\t);\n\n\treturn <PortalContext.Provider value={value}>{children}</PortalContext.Provider>;\n}\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\n/**\n * Get the current portal context value.\n * Used internally by other hooks.\n */\nexport function usePortalContext(): PortalContextValue {\n\treturn React.useContext(PortalContext);\n}\n\nexport function useInModalOverlay(): boolean {\n\treturn React.useContext(PortalContext).layer === 'modal';\n}\n\n/**\n * Get the root portal container element.\n * Used by modal components (Dialog, Sheet, etc.) to render their portals.\n *\n * @returns The root portal container, or null during SSR/before mount\n */\nexport function useRootPortalContainer(): HTMLElement | null {\n\tconst [container, setContainer] = React.useState<HTMLElement | null>(null);\n\n\tReact.useLayoutEffect(() => {\n\t\tconst el = document.getElementById(PORTAL_ROOT_ID);\n\t\tsetContainer(el);\n\t}, []);\n\n\treturn container;\n}\n\n/**\n * Centralized portal + z-index policy for floating overlays.\n *\n * - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal\n * into the nearest Base UI portal node (so dialog \"inert\" behavior includes it).\n * - When it's 'root', we portal into #portal-root.\n */\nexport function useFloatingOverlayPortalProps(): {\n\tcontainer?: HTMLElement | null;\n\tzIndexClass: string;\n} {\n\tconst rootContainer = useRootPortalContainer();\n\tconst { floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);\n\n\tconst container = floatingPortalStrategy === 'nested' ? undefined : (rootContainer ?? null);\n\tconst zIndexClass =\n\t\tfloatingZIndex === 'elevated'\n\t\t\t? 'z-[var(--z-layer-floating-elevated)]'\n\t\t\t: 'z-[var(--z-layer-floating)]';\n\n\treturn { container, zIndexClass };\n}\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Portal root component to render in app layout.\n * All overlay components will render their portals inside this container.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { PortalRoot } from '@constructive-io/ui/portal';\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * {children}\n * <PortalRoot />\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function PortalRoot() {\n\treturn (\n\t\t<div\n\t\t\tid={PORTAL_ROOT_ID}\n\t\t\tdata-slot=\"portal-root\"\n\t\t\tstyle={{\n\t\t\t\tposition: 'fixed',\n\t\t\t\tinset: 0,\n\t\t\t\tzIndex: 'var(--z-layer-portal-root)',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\t// Children (portal contents) will have pointer-events: auto\n\t\t\t}}\n\t\t/>\n\t);\n}\n\n/**\n * Hook to get the portal container element for rendering floating UI elements.\n * Returns the element with id=\"portal-root\" if it exists in the DOM.\n *\n * @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead\n */\nexport function usePortalContainer(): HTMLElement | undefined {\n\tif (typeof document === 'undefined') return undefined;\n\tconst el = document.getElementById(PORTAL_ROOT_ID);\n\treturn el instanceof HTMLElement ? el : undefined;\n}\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\n\nimport { ModalPortalScope, useRootPortalContainer } from './portal';\nimport { cn } from '../lib/utils';\n\nfunction Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n\treturn <DrawerPrimitive.Root data-slot=\"drawer\" {...props} />;\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n\treturn <DrawerPrimitive.Trigger data-slot=\"drawer-trigger\" {...props} />;\n}\n\nfunction DrawerPortal({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n\tconst container = useRootPortalContainer();\n\treturn <DrawerPrimitive.Portal data-slot=\"drawer-portal\" container={container} {...props} />;\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n\treturn <DrawerPrimitive.Close data-slot=\"drawer-close\" {...props} />;\n}\n\nfunction DrawerOverlay({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n\treturn (\n\t\t<DrawerPrimitive.Overlay\n\t\t\tdata-slot=\"drawer-overlay\"\n\t\t\tclassName={cn(\n\t\t\t\t`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\n\t\t\t\tdata-[state=open]:fade-in-0 fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/50`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerContent({ className, children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n\treturn (\n\t\t<DrawerPortal>\n\t\t\t<DrawerOverlay />\n\t\t\t<DrawerPrimitive.Content\n\t\t\t\tdata-slot=\"drawer-content\"\n\t\t\t\tclassName={cn(\n\t\t\t\t\t'group/drawer-content bg-background fixed z-[var(--z-layer-modal-content)] flex h-auto flex-col',\n\t\t\t\t\t`data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b`,\n\t\t\t\t\t`data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t`,\n\t\t\t\t\t`data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0\n\t\t\t\t\tdata-[vaul-drawer-direction=right]:border-l`,\n\t\t\t\t\t`data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:sm:max-w-sm`,\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName='bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full\n\t\t\t\t\t\tgroup-data-[vaul-drawer-direction=bottom]/drawer-content:block'\n\t\t\t\t/>\n\t\t\t\t<ModalPortalScope floatingPortalStrategy='root' floatingZIndex='elevated'>\n\t\t\t\t\t{children}\n\t\t\t\t</ModalPortalScope>\n\t\t\t</DrawerPrimitive.Content>\n\t\t</DrawerPortal>\n\t);\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"drawer-header\"\n\t\t\tclassName={cn(\n\t\t\t\t`flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center\n\t\t\t\tgroup-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn <div data-slot=\"drawer-footer\" className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n\treturn (\n\t\t<DrawerPrimitive.Title\n\t\t\tdata-slot=\"drawer-title\"\n\t\t\tclassName={cn('text-foreground font-semibold', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerDescription({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n\treturn (\n\t\t<DrawerPrimitive.Description\n\t\t\tdata-slot=\"drawer-description\"\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tDrawer,\n\tDrawerPortal,\n\tDrawerOverlay,\n\tDrawerTrigger,\n\tDrawerClose,\n\tDrawerContent,\n\tDrawerHeader,\n\tDrawerFooter,\n\tDrawerTitle,\n\tDrawerDescription,\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/components/drawer.tsx"],"names":["DrawerPrimitive"],"mappings":";;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACGA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAAsD;AAChF,EAAA,2BAAQA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC5D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAyD;AAC1F,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACvE;AAEA,SAAS,aAAa,EAAE,SAAA,EAAW,aAAA,EAAe,GAAG,OAAM,EAAwD;AAClH,EAAA,MAAM,gBAAgB,sBAAA,EAAuB;AAC7C,EAAA,MAAM,SAAA,GAAY,aAAA,KAAkB,MAAA,GAAa,aAAA,IAAiB,MAAA,GAAa,aAAA;AAC/E,EAAA,uBAAO,GAAA,CAACA,SAAgB,MAAA,EAAhB,EAAuB,aAAU,eAAA,EAAgB,SAAA,EAAuB,GAAG,KAAA,EAAO,CAAA;AAC3F;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAuD;AACtF,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACnE;AAEA,SAAS,aAAA,CAAc,EAAE,SAA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AEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC3E,EAAA,uBACC,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACA,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACV,CAAA;AAAA,6FAAA,CAAA;AAAA,QAEA;AAAA,OACD;AAAA,MACC,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC3E,EAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAI,WAAA,EAAU,eAAA,EAAgB,SAAA,EAAW,GAAG,iCAAA,EAAmC,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAC/G;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuD;AACjG,EAAA,uBACC,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,iBAAA,CAAkB,EAAE,SAAA,EAAW,GAAG,OAAM,EAA6D;AAC7G,EAAA,uBACC,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACA,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF","file":"drawer.js","sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\n\nimport { ModalPortalScope, useRootPortalContainer } from '@constructive-io/ui/portal';\nimport { cn } from '../lib/utils';\n\nfunction Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n\treturn <DrawerPrimitive.Root data-slot=\"drawer\" {...props} />;\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n\treturn <DrawerPrimitive.Trigger data-slot=\"drawer-trigger\" {...props} />;\n}\n\nfunction DrawerPortal({ container: containerProp, ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n\tconst rootContainer = useRootPortalContainer();\n\tconst container = containerProp === undefined ? (rootContainer ?? undefined) : containerProp;\n\treturn <DrawerPrimitive.Portal data-slot=\"drawer-portal\" container={container} {...props} />;\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n\treturn <DrawerPrimitive.Close data-slot=\"drawer-close\" {...props} />;\n}\n\nfunction DrawerOverlay({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n\treturn (\n\t\t<DrawerPrimitive.Overlay\n\t\t\tdata-slot=\"drawer-overlay\"\n\t\t\tclassName={cn(\n\t\t\t\t`fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/50\n\t\t\t\tdata-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]\n\t\t\t\tmotion-reduce:animate-none`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerContent({ className, children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n\tconst [floatingContainer, setFloatingContainer] = React.useState<HTMLDivElement | null>(null);\n\n\treturn (\n\t\t<DrawerPortal>\n\t\t\t<DrawerOverlay />\n\t\t\t<DrawerPrimitive.Content\n\t\t\t\tdata-slot=\"drawer-content\"\n\t\t\t\tclassName={cn(\n\t\t\t\t\t'group/drawer-content bg-background fixed z-[var(--z-layer-modal-content)] flex h-auto flex-col',\n\t\t\t\t\t`data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b`,\n\t\t\t\t\t`data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh]\n\t\t\t\t\tdata-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t`,\n\t\t\t\t\t`data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0\n\t\t\t\t\tdata-[vaul-drawer-direction=right]:border-l`,\n\t\t\t\t\t`data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r\n\t\t\t\t\tdata-[vaul-drawer-direction=left]:sm:max-w-sm`,\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName='bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full\n\t\t\t\t\t\tgroup-data-[vaul-drawer-direction=bottom]/drawer-content:block'\n\t\t\t\t/>\n\t\t\t\t<div ref={setFloatingContainer} data-slot='drawer-floating-portal' className='contents'>\n\t\t\t\t\t<ModalPortalScope floatingContainer={floatingContainer} floatingZIndex='elevated'>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</ModalPortalScope>\n\t\t\t\t</div>\n\t\t\t</DrawerPrimitive.Content>\n\t\t</DrawerPortal>\n\t);\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"drawer-header\"\n\t\t\tclassName={cn(\n\t\t\t\t`flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center\n\t\t\t\tgroup-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn <div data-slot=\"drawer-footer\" className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n\treturn (\n\t\t<DrawerPrimitive.Title\n\t\t\tdata-slot=\"drawer-title\"\n\t\t\tclassName={cn('text-foreground font-semibold', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction DrawerDescription({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n\treturn (\n\t\t<DrawerPrimitive.Description\n\t\t\tdata-slot=\"drawer-description\"\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tDrawer,\n\tDrawerPortal,\n\tDrawerOverlay,\n\tDrawerTrigger,\n\tDrawerClose,\n\tDrawerContent,\n\tDrawerHeader,\n\tDrawerFooter,\n\tDrawerTitle,\n\tDrawerDescription,\n};\n"]}
|