@g4rcez/components 2.0.34 → 2.0.36
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/core/typography.d.ts.map +1 -1
- package/dist/components/core/typography.jsx +17 -17
- package/dist/components/floating/modal.d.ts +3 -3
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.jsx +41 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5430 -5437
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../src/components/core/typography.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,CAAC,GAAG,CAAC,sBAEnD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,cAAc,CAAC,GAAG,CAAC,sBAErD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../src/components/core/typography.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,CAAC,GAAG,CAAC,sBAEnD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,cAAc,CAAC,GAAG,CAAC,sBAErD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,sBAS7D,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,sBAKpE,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,KAAK,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,iBAAiB,CAAC,eAAe,CAAC,sBAWnE,CAAA"}
|
|
@@ -3,24 +3,24 @@ import { css } from "../../lib/dom";
|
|
|
3
3
|
export const Paragraph = (props) => (<p {...props} className={css("text-base leading-snug", props.className)}/>);
|
|
4
4
|
export const Description = (props) => (<p {...props} className={css("mb-kilo text-sm text-secondary", props.className)}/>);
|
|
5
5
|
export const Info = (props) => (<div className={css(`flex ${props.row ? "flex-row items-center" : "flex-col"} gap-1`, props.className)}>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
<Fragment>
|
|
7
|
+
<span className="text-sm font-medium tracking-wide">{props.row ? `${props.label}:` : props.label}</span>
|
|
8
|
+
<span className={`w-fit ${props.disabled ? "text-disabled" : ""} ${props.row ? "text-base" : "text-lg"}`}>
|
|
9
|
+
{props.children}
|
|
10
|
+
</span>
|
|
11
|
+
</Fragment>
|
|
12
|
+
</div>);
|
|
13
13
|
export const PageTitle = (props) => (<div>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
<h2 className="text-3xl font-bold typography tracking-wide">{props.title}</h2>
|
|
15
|
+
<p className="text-secondary typography">{props.children}</p>
|
|
16
|
+
</div>);
|
|
17
17
|
export const PageHeader = (props) => {
|
|
18
18
|
return (<header className="flex flex-row flex-wrap justify-between items-center gap-mega">
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
<div>
|
|
20
|
+
<PageTitle title={props.title}>{props.description}</PageTitle>
|
|
21
|
+
</div>
|
|
22
|
+
<div className="flex gap-kilo items-center flex-wrap">
|
|
23
|
+
{props.children}
|
|
24
|
+
</div>
|
|
25
|
+
</header>);
|
|
26
26
|
};
|
|
@@ -27,7 +27,7 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
|
|
|
27
27
|
overlayClassName: string;
|
|
28
28
|
position: DrawerPosition;
|
|
29
29
|
overlayClickClose: boolean;
|
|
30
|
-
role: "dialog"
|
|
30
|
+
role: "dialog";
|
|
31
31
|
interactions: ElementProps[];
|
|
32
32
|
trigger: Label | React.FC<any>;
|
|
33
33
|
}>>;
|
|
@@ -55,7 +55,7 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
|
|
|
55
55
|
overlayClassName: string;
|
|
56
56
|
position: DrawerPosition;
|
|
57
57
|
overlayClickClose: boolean;
|
|
58
|
-
role: "dialog"
|
|
58
|
+
role: "dialog";
|
|
59
59
|
interactions: ElementProps[];
|
|
60
60
|
trigger: Label | React.FC<any>;
|
|
61
61
|
}> & {
|
|
@@ -80,7 +80,7 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
|
|
|
80
80
|
overlayClassName: string;
|
|
81
81
|
position: DrawerPosition;
|
|
82
82
|
overlayClickClose: boolean;
|
|
83
|
-
role: "dialog"
|
|
83
|
+
role: "dialog";
|
|
84
84
|
interactions: ElementProps[];
|
|
85
85
|
trigger: Label | React.FC<any>;
|
|
86
86
|
}> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASL,KAAK,YAAY,EAClB,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,EASL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,eAAe,EAA4F,MAAM,cAAc,CAAC;AAE1J,OAAO,KAA+G,MAAM,OAAO,CAAC;AAGpI,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAInD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAuD9C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC9E,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAA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loating, useInteractions, useRole, } from "@floating-ui/react";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
import { XIcon } from "lucide-react";
|
|
5
|
-
import { AnimatePresence, motion, MotionConfig, useMotionValue } from "motion/react";
|
|
5
|
+
import { AnimatePresence, motion, MotionConfig, useMotionValue, animate } from "motion/react";
|
|
6
6
|
import { Slot } from "../core/slot";
|
|
7
7
|
import React, { forwardRef, Fragment, useEffect, useId, useImperativeHandle, useRef } from "react";
|
|
8
8
|
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
@@ -91,7 +91,7 @@ const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
|
91
91
|
return forceType ? positions[type] : positions.sheet;
|
|
92
92
|
};
|
|
93
93
|
const noop = [];
|
|
94
|
-
export const Modal = forwardRef(({ open, title, footer, asChild, trigger, children, onChange, ariaTitle, className, bodyClassName, resizer = true, animated = true, closable = true, forceType = false, layoutId = undefined, overlayClassName = "", type: _type = "dialog", position: propsPosition, overlayClickClose = false,
|
|
94
|
+
export const Modal = forwardRef(({ open, title, footer, asChild, trigger, children, onChange, ariaTitle, className, bodyClassName, resizer = true, animated = true, closable = true, forceType = false, layoutId = undefined, overlayClassName = "", type: _type = "dialog", position: propsPosition, overlayClickClose = false, interactions: outInteractions = noop, ...props }, externalRef) => {
|
|
95
95
|
const innerContent = useRef(null);
|
|
96
96
|
const removeScrollRef = useRef(null);
|
|
97
97
|
const headingId = useId();
|
|
@@ -104,17 +104,22 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
104
104
|
const useResizer = type !== "dialog";
|
|
105
105
|
const floating = useFloating({ open, onOpenChange: onChange, strategy: "fixed" });
|
|
106
106
|
const click = useClick(floating.context, {});
|
|
107
|
-
const role = useRole(floating.context, { role:
|
|
107
|
+
const role = useRole(floating.context, { role: "dialog" });
|
|
108
108
|
const dismiss = useDismiss(floating.context, {
|
|
109
109
|
bubbles: true,
|
|
110
110
|
escapeKey: true,
|
|
111
|
-
ancestorScroll: true,
|
|
112
111
|
outsidePress: overlayClickClose,
|
|
113
112
|
});
|
|
114
113
|
const interactions = useInteractions([click, dismiss, role].concat(outInteractions));
|
|
115
114
|
const Trigger = trigger;
|
|
116
115
|
const floatingSize = useMotionValue(undefined);
|
|
117
|
-
|
|
116
|
+
const sheetY = useMotionValue(undefined);
|
|
117
|
+
const isDragging = useRef(false);
|
|
118
|
+
const dragStart = useRef(0);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
floatingSize.set(undefined);
|
|
121
|
+
sheetY.set(undefined);
|
|
122
|
+
}, [type, floatingSize, sheetY]);
|
|
118
123
|
const onClose = () => onChange(false);
|
|
119
124
|
useImperativeHandle(externalRef, () => ({ context: floating.context, floating: removeScrollRef.current }), [floating.context, removeScrollRef]);
|
|
120
125
|
const onDragHeader = (_, info) => {
|
|
@@ -132,25 +137,6 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
132
137
|
onChange?.(false);
|
|
133
138
|
return setTimeout(() => floatingSize.set(undefined), 350);
|
|
134
139
|
};
|
|
135
|
-
const onDragBody = (_, info) => {
|
|
136
|
-
const div = floating.refs.floating.current;
|
|
137
|
-
if (info.delta.y < 0 && info.offset.y < 0) {
|
|
138
|
-
div.scrollTo({ top: div.scrollTop + Math.abs(info.offset.y), behavior: "smooth" });
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const rect = div.getBoundingClientRect();
|
|
142
|
-
const v = floatingSize.get() || rect.height;
|
|
143
|
-
const result = Math.abs(v - info.delta.y);
|
|
144
|
-
const max = window.outerHeight;
|
|
145
|
-
const screenHeightToClose = calculateClose(max);
|
|
146
|
-
if (result >= screenHeightToClose)
|
|
147
|
-
return floatingSize.set(result);
|
|
148
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
149
|
-
document.activeElement?.blur();
|
|
150
|
-
}
|
|
151
|
-
onChange?.(false);
|
|
152
|
-
return setTimeout(() => floatingSize.set(undefined), 350);
|
|
153
|
-
};
|
|
154
140
|
const draggableMotionProps = type === "sheet" ? {
|
|
155
141
|
drag: "y",
|
|
156
142
|
animate: false,
|
|
@@ -187,40 +173,52 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
187
173
|
"aria-modal": open,
|
|
188
174
|
ref: mergeRefs(floating.refs.setFloating, removeScrollRef),
|
|
189
175
|
className: css(variants({ position, type }), className, "isolate overscroll-contain"),
|
|
190
|
-
})} exit="exit" layout={true} animate="enter" initial="initial" layoutId={layoutId} variants={animation} data-component="modal" style={type === "drawer" ? { width: floatingSize } : { height: floatingSize }}>
|
|
176
|
+
})} exit="exit" layout={true} animate="enter" initial="initial" layoutId={layoutId} variants={animation} data-component="modal" style={type === "drawer" ? { width: floatingSize } : { height: floatingSize, y: sheetY }}>
|
|
191
177
|
{useResizer && resizer ? (<Draggable onChange={onChange} value={floatingSize} sheet={type === "sheet"} position={position} parent={floating.refs.floating}/>) : null}
|
|
192
178
|
{title ? (<motion.header {...draggableMotionProps} className="relative w-full isolate">
|
|
193
179
|
{title ? (<h2 id={headingId} className="block px-8 pb-2 text-3xl font-medium leading-relaxed border-b select-text border-floating-border">
|
|
194
180
|
{title}
|
|
195
181
|
</h2>) : null}
|
|
196
182
|
</motion.header>) : null}
|
|
197
|
-
<motion.section ref={innerContent} data-component="modal-body"
|
|
183
|
+
<motion.section ref={innerContent} data-component="modal-body" className={css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName)} onTouchEnd={async () => {
|
|
198
184
|
scroll.set(undefined);
|
|
199
185
|
scrollInitial.set(undefined);
|
|
200
|
-
|
|
186
|
+
if (isDragging.current) {
|
|
187
|
+
const currentY = sheetY.get() || 0;
|
|
188
|
+
const threshold = window.innerHeight * 0.2;
|
|
189
|
+
if (currentY > threshold) {
|
|
190
|
+
await animate(sheetY, window.innerHeight, { duration: 0.2, ease: "easeIn" }).finished;
|
|
191
|
+
onChange(false);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
animate(sheetY, 0, { type: "spring", bounce: 0, duration: 0.3 });
|
|
195
|
+
}
|
|
196
|
+
isDragging.current = false;
|
|
197
|
+
}
|
|
198
|
+
}} onTouchStart={(e) => {
|
|
201
199
|
const touch = e.changedTouches[0];
|
|
202
200
|
scrollInitial.set(touch.pageY);
|
|
203
201
|
scroll.set(touch.pageY);
|
|
204
|
-
|
|
202
|
+
isDragging.current = false;
|
|
203
|
+
}} onTouchMove={(e) => {
|
|
205
204
|
const touch = e.changedTouches[0];
|
|
206
205
|
const y = touch.pageY;
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
floatingSize.set(down);
|
|
206
|
+
const prevY = scroll.get() || y;
|
|
207
|
+
const scrollTop = innerContent.current?.scrollTop || 0;
|
|
208
|
+
if (!isDragging.current && scrollTop <= 0 && y > prevY && type === "sheet") {
|
|
209
|
+
isDragging.current = true;
|
|
210
|
+
dragStart.current = y;
|
|
211
|
+
}
|
|
212
|
+
if (isDragging.current) {
|
|
213
|
+
const delta = y - dragStart.current;
|
|
214
|
+
if (delta < 0) {
|
|
215
|
+
sheetY.set(delta * 0.2);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
sheetY.set(delta);
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
|
-
scroll.set(
|
|
221
|
+
scroll.set(y);
|
|
224
222
|
}}>
|
|
225
223
|
{children}
|
|
226
224
|
</motion.section>
|