@g4rcez/components 2.0.13 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/display/calendar.js +2 -2
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +38 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1130 -1130
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +22 -22
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -44,12 +44,12 @@ const focusDate = (origin, root, next, delay = 0) => {
|
|
|
44
44
|
const select = () => {
|
|
45
45
|
if (origin?.dataset.focustrap) {
|
|
46
46
|
const el = root.current?.querySelector(`button[data-focustrap="${origin?.dataset.focustrap}"]`);
|
|
47
|
-
return setTimeout(() => el?.focus({ preventScroll:
|
|
47
|
+
return setTimeout(() => el?.focus({ preventScroll: true }), delay);
|
|
48
48
|
}
|
|
49
49
|
if (root.current) {
|
|
50
50
|
const element = root.current.querySelector(`button[data-date="${d}"]`);
|
|
51
51
|
if (element)
|
|
52
|
-
return element.focus({ preventScroll:
|
|
52
|
+
return element.focus({ preventScroll: true });
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
if (delay === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASH,KAAK,YAAY,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,eAAe,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASH,KAAK,YAAY,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,eAAe,EAAmF,MAAM,cAAc,CAAC;AAEjJ,OAAO,KAA+G,MAAM,OAAO,CAAC;AAIpI,OAAO,EAAE,KAAK,EAAO,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WAzGJ,KAAK;gBAAc,MAAM;;UACzB,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;UACpB,QAAQ,GAAG,SAAS;kBACZ,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eAnBmB,MAAM;YAAU,KAAK;;UAChE,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;UACpB,QAAQ,GAAG,SAAS;kBACZ,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CA8UrC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { XIcon } from "lucide-react";
|
|
6
|
-
import { AnimatePresence, motion, useMotionValue } from "motion/react";
|
|
6
|
+
import { AnimatePresence, motion, MotionConfig, useMotionValue } from "motion/react";
|
|
7
7
|
import { Slot as RadixSlot } from "radix-ui";
|
|
8
8
|
import { forwardRef, Fragment, useEffect, useId, useImperativeHandle, useRef } from "react";
|
|
9
9
|
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
@@ -82,7 +82,7 @@ const Draggable = (props) => {
|
|
|
82
82
|
? "top-1 flex h-3 w-full justify-center py-2"
|
|
83
83
|
: props.position === "left"
|
|
84
84
|
? "right-5 top-1/2 h-10 w-2"
|
|
85
|
-
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "
|
|
85
|
+
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "w-1/4 h-2 rounded-lg bg-floating-border" }) : null }));
|
|
86
86
|
};
|
|
87
87
|
const positions = { drawer: "right", sheet: "none", dialog: "none" };
|
|
88
88
|
const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
@@ -168,41 +168,41 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
168
168
|
} : { animate: animated, initial: false };
|
|
169
169
|
const scrollInitial = useMotionValue(undefined);
|
|
170
170
|
const scroll = useMotionValue(undefined);
|
|
171
|
-
return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: floating.refs.setReference, ...interactions.getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: floating.refs.setReference, ...interactions.getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(AnimatePresence, { propagate: true, mode: "wait", initial: false, children: open ? (_jsx(FloatingOverlay, { lockScroll: true, className: css("inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70", type === "drawer" ? "" : "flex items-start justify-center p-10", overlayClassName), children: _jsx(FloatingFocusManager, { guards: true, visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: floating.context, children: _jsxs(motion.div, { ...props, ...(title
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
171
|
+
return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: floating.refs.setReference, ...interactions.getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: floating.refs.setReference, ...interactions.getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(AnimatePresence, { propagate: true, mode: "wait", initial: false, children: open ? (_jsx(FloatingOverlay, { lockScroll: true, className: css("inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70", type === "drawer" ? "" : "flex items-start justify-center p-10", overlayClassName), children: _jsx(MotionConfig, { reducedMotion: animated ? "user" : "always", children: _jsx(FloatingFocusManager, { guards: true, visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: floating.context, children: _jsxs(motion.div, { ...props, ...(title
|
|
172
|
+
? {
|
|
173
|
+
"aria-labelledby": headingId,
|
|
174
|
+
"aria-describedby": descriptionId,
|
|
175
|
+
}
|
|
176
|
+
: { "aria-label": ariaTitle }), ...interactions.getFloatingProps({
|
|
177
|
+
"aria-modal": open,
|
|
178
|
+
ref: mergeRefs(floating.refs.setFloating, removeScrollRef),
|
|
179
|
+
className: css(variants({ position, type }), className, "isolate overscroll-contain"),
|
|
180
|
+
}), exit: "exit", layout: true, animate: "enter", initial: "initial", layoutId: layoutId, variants: animation, "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null, title ? (_jsx(motion.header, { ...draggableMotionProps, className: "relative w-full isolate", children: title ? (_jsx("h2", { id: headingId, className: "block px-8 pb-2 text-3xl font-medium leading-relaxed border-b select-text border-floating-border", children: title })) : null })) : null, _jsx(motion.section, { ref: innerContent, "data-component": "modal-body", dragConstraints: dragConstraints, drag: isDesktop ? "y" : undefined, onDrag: type === "sheet" ? (isDesktop ? onDragBody : undefined) : undefined, className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), onTouchEnd: () => {
|
|
181
|
+
scroll.set(undefined);
|
|
182
|
+
scrollInitial.set(undefined);
|
|
183
|
+
}, onTouchStart: e => {
|
|
184
|
+
const touch = e.changedTouches[0];
|
|
185
|
+
scrollInitial.set(touch.pageY);
|
|
186
|
+
scroll.set(touch.pageY);
|
|
187
|
+
}, onTouchMove: e => {
|
|
188
|
+
const touch = e.changedTouches[0];
|
|
189
|
+
const y = touch.pageY;
|
|
190
|
+
const initial = scrollInitial.get();
|
|
191
|
+
if (initial < y) {
|
|
192
|
+
const distanceFromTop = innerContent.current?.scrollTop;
|
|
193
|
+
if (distanceFromTop === 0) {
|
|
194
|
+
const div = floating.refs.floating.current;
|
|
195
|
+
const rect = div.getBoundingClientRect();
|
|
196
|
+
const v = floatingSize.get() || rect.height;
|
|
197
|
+
const diff = (initial - y) / 10;
|
|
198
|
+
const down = v + diff;
|
|
199
|
+
const max = window.outerHeight;
|
|
200
|
+
const screenHeightToClose = calculateClose(max);
|
|
201
|
+
if (down < screenHeightToClose)
|
|
202
|
+
onChange?.(false);
|
|
203
|
+
floatingSize.set(down);
|
|
204
|
+
}
|
|
204
205
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}, children: children }), footer ? (_jsx("footer", { className: "w-full select-text border-t border-floating-border px-8 pt-4", children: footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null] }) }) })) : null }, headingId) })] }));
|
|
206
|
+
scroll.set(touch.pageY);
|
|
207
|
+
}, children: children }), footer ? (_jsx("footer", { className: "px-8 pt-4 w-full border-t select-text border-floating-border", children: footer })) : null, closable ? (_jsx("nav", { className: "absolute top-1 right-4 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:opacity-100 hover:text-danger focus:text-danger", children: _jsx(XIcon, {}) }) })) : null] }) }) }) })) : null }, headingId) })] }));
|
|
208
208
|
});
|