@g4rcez/components 2.0.29 → 2.0.30

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.
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ export type Usable<T> = PromiseLike<T> | React.Context<T>;
3
+ interface SlotProps extends React.HTMLAttributes<HTMLElement> {
4
+ children?: React.ReactNode;
5
+ }
6
+ export declare function createSlot(ownerName: string): React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
7
+ export declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
8
+ interface SlottableProps {
9
+ children: React.ReactNode;
10
+ }
11
+ interface SlottableComponent extends React.FC<SlottableProps> {
12
+ __radixId: symbol;
13
+ }
14
+ export declare function createSlottable(ownerName: string): SlottableComponent;
15
+ export {};
16
+ //# sourceMappingURL=slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../../src/components/core/slot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAI1D,UAAU,SAAU,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAiBD,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,iFA6C3C;AAED,eAAO,MAAM,IAAI,+EAAqB,CAAC;AAgCvC,UAAU,cAAc;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,UAAU,kBAAmB,SAAQ,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,sBAOhD"}
@@ -0,0 +1,160 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ const REACT_LAZY_TYPE = Symbol.for('react.lazy');
4
+ function setRef(ref, value) {
5
+ if (typeof ref === 'function') {
6
+ return ref(value);
7
+ }
8
+ else if (ref !== null && ref !== undefined) {
9
+ ref.current = value;
10
+ }
11
+ }
12
+ function composeRefs(...refs) {
13
+ return (node) => {
14
+ let hasCleanup = false;
15
+ const cleanups = refs.map((ref) => {
16
+ const cleanup = setRef(ref, node);
17
+ if (!hasCleanup && typeof cleanup == 'function') {
18
+ hasCleanup = true;
19
+ }
20
+ return cleanup;
21
+ });
22
+ if (hasCleanup) {
23
+ return () => {
24
+ for (let i = 0; i < cleanups.length; i++) {
25
+ const cleanup = cleanups[i];
26
+ if (typeof cleanup == 'function') {
27
+ cleanup();
28
+ }
29
+ else {
30
+ setRef(refs[i], null);
31
+ }
32
+ }
33
+ };
34
+ }
35
+ };
36
+ }
37
+ const use = React[' use '.trim().toString()];
38
+ function isPromiseLike(value) {
39
+ return typeof value === 'object' && value !== null && 'then' in value;
40
+ }
41
+ function isLazyComponent(element) {
42
+ return (element != null &&
43
+ typeof element === 'object' &&
44
+ '$$typeof' in element &&
45
+ element.$$typeof === REACT_LAZY_TYPE &&
46
+ '_payload' in element &&
47
+ isPromiseLike(element._payload));
48
+ }
49
+ export function createSlot(ownerName) {
50
+ const SlotClone = createSlotClone(ownerName);
51
+ const Slot = React.forwardRef((props, forwardedRef) => {
52
+ let { children, ...slotProps } = props;
53
+ if (isLazyComponent(children) && typeof use === 'function') {
54
+ children = use(children._payload);
55
+ }
56
+ const childrenArray = React.Children.toArray(children);
57
+ const slottable = childrenArray.find(isSlottable);
58
+ if (slottable) {
59
+ // the new element to render is the one passed as a child of `Slottable`
60
+ const newElement = slottable.props.children;
61
+ const newChildren = childrenArray.map((child) => {
62
+ if (child === slottable) {
63
+ // because the new element will be the one rendered, we are only interested
64
+ // in grabbing its children (`newElement.props.children`)
65
+ if (React.Children.count(newElement) > 1)
66
+ return React.Children.only(null);
67
+ return React.isValidElement(newElement)
68
+ ? newElement.props.children
69
+ : null;
70
+ }
71
+ else {
72
+ return child;
73
+ }
74
+ });
75
+ return (_jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement)
76
+ ? React.cloneElement(newElement, undefined, newChildren)
77
+ : null }));
78
+ }
79
+ return (_jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: children }));
80
+ });
81
+ Slot.displayName = `${ownerName}.Slot`;
82
+ return Slot;
83
+ }
84
+ export const Slot = createSlot('Slot');
85
+ function createSlotClone(ownerName) {
86
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
87
+ let { children, ...slotProps } = props;
88
+ if (isLazyComponent(children) && typeof use === 'function') {
89
+ children = use(children._payload);
90
+ }
91
+ if (React.isValidElement(children)) {
92
+ const childrenRef = getElementRef(children);
93
+ const props = mergeProps(slotProps, children.props);
94
+ // do not pass ref to React.Fragment for React 19 compatibility
95
+ if (children.type !== React.Fragment) {
96
+ props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
97
+ }
98
+ return React.cloneElement(children, props);
99
+ }
100
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
101
+ });
102
+ SlotClone.displayName = `${ownerName}.SlotClone`;
103
+ return SlotClone;
104
+ }
105
+ const SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');
106
+ export function createSlottable(ownerName) {
107
+ const Slottable = ({ children }) => {
108
+ return _jsx(_Fragment, { children: children });
109
+ };
110
+ Slottable.displayName = `${ownerName}.Slottable`;
111
+ Slottable.__radixId = SLOTTABLE_IDENTIFIER;
112
+ return Slottable;
113
+ }
114
+ const Slottable = createSlottable('Slottable');
115
+ function isSlottable(child) {
116
+ return (React.isValidElement(child) &&
117
+ typeof child.type === 'function' &&
118
+ '__radixId' in child.type &&
119
+ child.type.__radixId === SLOTTABLE_IDENTIFIER);
120
+ }
121
+ function mergeProps(slotProps, childProps) {
122
+ const overrideProps = { ...childProps };
123
+ for (const propName in childProps) {
124
+ const slotPropValue = slotProps[propName];
125
+ const childPropValue = childProps[propName];
126
+ const isHandler = /^on[A-Z]/.test(propName);
127
+ if (isHandler) {
128
+ if (slotPropValue && childPropValue) {
129
+ overrideProps[propName] = (...args) => {
130
+ const result = childPropValue(...args);
131
+ slotPropValue(...args);
132
+ return result;
133
+ };
134
+ }
135
+ else if (slotPropValue) {
136
+ overrideProps[propName] = slotPropValue;
137
+ }
138
+ }
139
+ else if (propName === 'style') {
140
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
141
+ }
142
+ else if (propName === 'className') {
143
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');
144
+ }
145
+ }
146
+ return { ...slotProps, ...overrideProps };
147
+ }
148
+ function getElementRef(element) {
149
+ let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;
150
+ let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
151
+ if (mayWarn) {
152
+ return element.ref;
153
+ }
154
+ getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;
155
+ mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
156
+ if (mayWarn) {
157
+ return element.props.ref;
158
+ }
159
+ return element.props.ref || element.ref;
160
+ }
@@ -6,7 +6,7 @@ declare const variants: (props?: ({
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
7
  type NotificationOptions = Partial<{
8
8
  title: Label;
9
- duration: number;
9
+ timeout: number;
10
10
  closable: boolean;
11
11
  theme: VariantProps<typeof variants>["theme"];
12
12
  }>;
@@ -14,12 +14,12 @@ type NotificationSubscriber = {
14
14
  close: () => void;
15
15
  clear: () => void;
16
16
  };
17
- type ContextFunction = (text: Label, args?: NotificationOptions) => NotificationSubscriber;
17
+ type ContextFunction = (description: Label, args?: NotificationOptions) => NotificationSubscriber;
18
18
  export declare const useNotification: () => ContextFunction;
19
19
  export type NotificationProps = Partial<{
20
20
  max: number;
21
- duration: number;
21
+ timeout: number;
22
22
  }>;
23
- export declare function Notifications({ children, max, duration }: PropsWithChildren<NotificationProps>): import("react/jsx-runtime").JSX.Element;
23
+ export declare function Notifications({ children, max, timeout }: PropsWithChildren<NotificationProps>): import("react/jsx-runtime").JSX.Element;
24
24
  export {};
25
25
  //# sourceMappingURL=notifications.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAgD,KAAK,iBAAiB,EAAwD,MAAM,OAAO,CAAC;AAEnJ,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,QAAQ;;mFAgBb,CAAC;AAEF,KAAK,mBAAmB,GAAG,OAAO,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEvE,KAAK,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,sBAAsB,CAAC;AAM3F,eAAO,MAAM,eAAe,uBAAwC,CAAC;AA+DrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE3E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAO,EAAE,QAAe,EAAE,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,2CAyDzG"}
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAiB,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE/F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,QAAQ;;mFAgBb,CAAC;AAEF,KAAK,mBAAmB,GAAG,OAAO,CAAC;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;CAC/C,CAAC,CAAC;AAIH,KAAK,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEvE,KAAK,eAAe,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,sBAAsB,CAAC;AAMlG,eAAO,MAAM,eAAe,uBAAwC,CAAC;AAwDrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAqE1E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAO,EAAE,OAAc,EAAE,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,2CAMxG"}
@@ -1,11 +1,10 @@
1
1
  "use client";
2
- import { createElement as _createElement } from "react";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  import { cva } from "class-variance-authority";
5
4
  import { XIcon } from "lucide-react";
6
5
  import { AnimatePresence, motion } from "motion/react";
7
- import { Toast as RadixToast } from "radix-ui";
8
- import { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react";
6
+ import { Toast as Base } from "@base-ui/react/toast";
7
+ import { createContext, useCallback, useContext, useRef } from "react";
9
8
  import { useHover } from "../../hooks/use-hover";
10
9
  const variants = cva("relative isolate z-tooltip flex justify-between overflow-hidden whitespace-nowrap rounded-lg border text-sm shadow-shadow-notification", {
11
10
  variants: {
@@ -31,41 +30,45 @@ const animatedIndex = {
31
30
  2: { opacity: 1, y: [20, 25], scale: [1, 0.96] },
32
31
  default: { opacity: 1, y: [25, 30], scale: [1, 0.95] },
33
32
  };
34
- const Notification = forwardRef(function Toast(props, forwardedRef) {
35
- const closable = props.closable ?? true;
36
- const duration = props.duration;
33
+ function Notification(props) {
34
+ const closable = props.toast.data?.closable ?? true;
37
35
  const variant = props.hover ? "hover" : props.isLast ? "isLast" : "other";
38
- const className = variants({ theme: props.theme || "default" });
39
- return (_jsx(RadixToast.Root, { ref: forwardedRef, asChild: true, forceMount: true, onOpenChange: props.onClose, duration: duration, children: _jsx(motion.li, { layout: true, layoutScroll: true, animate: variant, "data-index": props.index, initial: { y: -100, zIndex: -1 }, className: "text-select pointer-events-auto absolute right-0 top-0 w-80", variants: {
36
+ const className = variants({ theme: props.toast.data?.theme || "default" });
37
+ return (_jsx(Base.Root, { toast: props.toast, swipeDirection: ["down", "right"], children: _jsx(motion.li, { layout: true, layoutScroll: true, animate: variant, "data-index": props.index, initial: { y: -100, zIndex: -1 }, className: "absolute top-0 right-0 w-80 pointer-events-auto text-select", variants: {
40
38
  isLast: { y: 10, scale: 1, animationDuration: "300ms", opacity: 1 },
41
39
  hover: { y: 0, position: "static", scale: 1, opacity: 1 },
42
40
  other: animatedIndex[props.reversedIndex] || animatedIndex.default,
43
- }, transition: { type: "spring", mass: 1.2, damping: 30, stiffness: 200 }, exit: { opacity: [0.9, 0], transition: { opacity: { bounce: 0.25, duration: 0.3 } } }, children: _jsxs("div", { className: className, children: [_jsxs("div", { className: "flex flex-col p-4", children: [props.title ? (_jsx(RadixToast.Title, { className: "select-text truncate text-lg font-medium leading-relaxed", children: props.title })) : null, _jsx(RadixToast.Description, { className: "select-text truncate", children: props.text })] }), closable ? (_jsx(RadixToast.Close, { className: "absolute right-2 top-2 rounded-full p-1 text-foreground transition hover:bg-danger/10 hover:text-danger-hover", children: _jsx(XIcon, { className: "size-5" }) })) : null] }) }) }));
44
- });
45
- export function Notifications({ children, max = 5, duration = 5000 }) {
41
+ }, transition: { type: "spring", mass: 1.2, damping: 30, stiffness: 200 }, exit: { opacity: [0.9, 0], transition: { opacity: { bounce: 0.25, duration: 0.3 } } }, children: _jsxs(Base.Content, { className: className, children: [_jsxs("div", { className: "flex flex-col p-4", children: [props.toast.title ? (_jsx(Base.Title, { className: "text-lg font-medium leading-relaxed select-text truncate" })) : null, _jsx(Base.Description, { className: "select-text truncate" })] }), closable ? (_jsx(Base.Close, { className: "absolute top-2 right-2 p-1 rounded-full transition text-foreground hover:bg-danger/10 hover:text-danger-hover", children: _jsx(XIcon, { className: "size-5" }) })) : null] }) }) }));
42
+ }
43
+ function NotificationsViewport({ max = 5 }) {
46
44
  const ref = useRef(null);
47
45
  const hover = useHover(ref);
48
- const [messages, setMessages] = useState([]);
49
- const clear = useCallback(() => setMessages([]), []);
50
- useEffect(() => {
51
- return clear;
52
- }, [clear]);
53
- const notify = useCallback((text, args) => {
54
- const id = window.crypto.randomUUID();
55
- setMessages((prev) => {
56
- const newItems = [...prev, { ...args, id, text }];
57
- if (newItems.length > max)
58
- return newItems.slice(newItems.length - max, newItems.length + 1);
59
- return newItems;
46
+ const toastManager = Base.useToastManager();
47
+ const toasts = toastManager.toasts.slice(-max);
48
+ return (_jsx(Base.Viewport, { ref: ref, "data-items": toasts.length, style: {
49
+ justifyContent: "start",
50
+ height: `${(hover ? toasts.length : Math.min(1, toasts.length)) * 7}rem`,
51
+ }, className: "fixed right-4 top-10 flex w-80 list-none flex-col-reverse items-end gap-4 overflow-y-clip overflow-x-visible data-[items=true]:pb-8 max-sm:top-20", children: _jsx(motion.ol, { className: "flex flex-col gap-4", children: _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: toasts.reverse().map((toast, index, list) => (_jsx(Notification, { toast: toast, hover: hover, index: index, isLast: list.length - 1 === index, reversedIndex: list.length - (index + 1) }, toast.id))) }) }) }));
52
+ }
53
+ function NotificationsInner({ children, max = 5 }) {
54
+ const toastManager = Base.useToastManager();
55
+ const clear = useCallback(() => {
56
+ toastManager.toasts.forEach((t) => toastManager.close(t.id));
57
+ }, [toastManager]);
58
+ const notify = useCallback((description, args) => {
59
+ const id = toastManager.add({
60
+ description,
61
+ title: args?.title,
62
+ timeout: args?.timeout,
63
+ data: { theme: args?.theme, closable: args?.closable },
60
64
  });
61
- const close = () => setMessages((prev) => prev.filter((x) => x.id !== id));
62
- return { clear, close };
63
- }, [max]);
64
- return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(motion.ol, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: messages.map((toast, index, list) => {
65
- const close = () => setMessages((prev) => prev.filter((t) => t.id !== toast.id));
66
- return (_createElement(Notification, { ...toast, hover: hover, index: index, key: toast.id, onClose: close, isLast: list.length - 1 === index, reversedIndex: list.length - (index + 1) }));
67
- }) }) }), _jsx(RadixToast.Viewport, { ref: ref, "data-items": messages.length, style: {
68
- justifyContent: "start",
69
- height: `${(hover ? messages.length : Math.min(1, messages.length)) * 7}rem`,
70
- }, className: "fixed right-4 top-10 flex w-80 list-none flex-col-reverse items-end gap-4 overflow-y-clip overflow-x-visible data-[items=true]:pb-8 max-sm:top-20" })] }));
65
+ return {
66
+ close: () => toastManager.close(id),
67
+ clear,
68
+ };
69
+ }, [toastManager, clear]);
70
+ return (_jsxs(NotificationContext.Provider, { value: notify, children: [children, _jsx(Base.Portal, { children: _jsx(NotificationsViewport, { max: max }) })] }));
71
+ }
72
+ export function Notifications({ children, max = 5, timeout = 5000 }) {
73
+ return (_jsx(Base.Provider, { limit: max, timeout: timeout, children: _jsx(NotificationsInner, { max: max, children: children }) }));
71
74
  }
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Is } from "sidekicker";
3
- import { Progress as RadixProgress } from "radix-ui";
3
+ import { Progress as RadixProgress } from "@base-ui/react/progress";
4
4
  import { css } from "../../lib/dom";
5
5
  export const Progress = (props) => {
6
- return (_jsxs(RadixProgress.Root, { max: props.max, value: props.percent, style: { transform: "translateZ(0)", }, className: css("overflow-hidden relative w-full rounded-full h-6 bg-background", props.container), children: [_jsx(RadixProgress.Indicator, { style: { transform: Is.number(props.percent) ? `translateX(-${100 - props.percent}%)` : undefined }, className: css("bg-primary transition-transform ease-in-out size-full duration-500", props.className) }), Is.number(props.percent)
6
+ return (_jsxs(RadixProgress.Root, { max: props.max, value: props.percent ?? null, style: { transform: "translateZ(0)", }, className: css("overflow-hidden relative w-full rounded-full h-6 bg-background", props.container), children: [_jsx(RadixProgress.Indicator, { style: { transform: Is.number(props.percent) ? `translateX(-${100 - props.percent}%)` : undefined }, className: css("bg-primary transition-transform ease-in-out size-full duration-500", props.className) }), Is.number(props.percent)
7
7
  ? _jsx("p", { className: css("flex absolute inset-0 justify-center items-center w-full font-semibold tabular-nums text-primary-foreground", props.textClassName), children: props.label ? props.label : `${props.percent} %` })
8
8
  : null] }));
9
9
  };
@@ -2,12 +2,12 @@ import React, { PropsWithChildren } from "react";
2
2
  type DropdownProps = {
3
3
  open?: boolean;
4
4
  arrow?: boolean;
5
- restoreFocus?: boolean;
6
5
  returnFocus?: boolean;
6
+ restoreFocus?: boolean;
7
+ buttonProps?: React.HTMLProps<"button">;
7
8
  onChange?: (nextValue: boolean) => void;
8
9
  trigger: React.ReactElement | React.ReactNode;
9
10
  title?: React.ReactNode | React.ReactElement | string;
10
- buttonProps?: React.ComponentProps<"button">;
11
11
  };
12
12
  export declare const Dropdown: (props: PropsWithChildren<DropdownProps>) => import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;IACtD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,4CAqE/D,CAAC"}
1
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;CACvD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,4CAqE/D,CAAC"}
@@ -35,5 +35,5 @@ export const Dropdown = (props) => {
35
35
  const dismiss = useDismiss(context);
36
36
  const role = useRole(context, { role: "tooltip" });
37
37
  const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
38
- return (_jsxs(Fragment, { children: [_jsx("button", { ref: refs.setReference, ...getReferenceProps(props.buttonProps), type: "button", children: props.trigger }), open && (_jsx(FloatingPortal, { preserveTabOrder: true, id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { guards: true, restoreFocus: true, returnFocus: true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", { className: "relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-4 shadow-shadow-floating", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId, ...getFloatingProps(), children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "text-left text-2xl font-medium leading-snug tracking-wide", children: props.title }) }), props.children] }) }) }))] }));
38
+ return (_jsxs(Fragment, { children: [_jsx("button", { ref: refs.setReference, ...getReferenceProps(props.buttonProps), type: "button", children: props.trigger }), open && (_jsx(FloatingPortal, { preserveTabOrder: true, id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { guards: true, restoreFocus: true, returnFocus: true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", { className: "relative p-4 rounded-lg border isolate z-floating min-w-96 border-floating-border bg-floating-background shadow-shadow-floating", ref: refs.setFloating, "aria-labelledby": headingId, style: floatingStyles, ...getFloatingProps(), children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "text-2xl font-medium tracking-wide leading-snug text-left", children: props.title }) }), props.children] }) }) }))] }));
39
39
  };
@@ -22,7 +22,7 @@ type MenuItemProps = {
22
22
  Right?: React.FC<LucideProps>;
23
23
  };
24
24
  export declare const MenuItem: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof MenuItemProps> & MenuItemProps & React.RefAttributes<HTMLButtonElement>>;
25
- export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
25
+ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "restoreFocus" | "nested" | "asChild" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
26
26
  hover: boolean;
27
27
  open?: boolean;
28
28
  nested: boolean;
@@ -34,7 +34,7 @@ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.Deta
34
34
  FloatingComponent: React.ElementType;
35
35
  } & {
36
36
  label: string;
37
- }>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
37
+ }>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "restoreFocus" | "nested" | "asChild" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
38
38
  hover: boolean;
39
39
  open?: boolean;
40
40
  nested: boolean;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useRole, useTypeahead, } from "@floating-ui/react";
4
- import { Slot } from "radix-ui";
4
+ import { Slot } from "../core/slot";
5
5
  import { ChevronRightIcon } from "lucide-react";
6
6
  import React, { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
7
7
  import { FLOATING_DELAY, TYPEAHEAD_RESET_DELAY } from "../../constants";
@@ -84,7 +84,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
84
84
  tree.events.emit("menuopen", { parentId, nodeId });
85
85
  }, [tree, isOpen, nodeId, parentId]);
86
86
  const className = isParent ? props.className : css(menuItemClassName(props.className));
87
- return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot.Root, { ...getReferenceProps(parent.getItemProps({
87
+ return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { ...getReferenceProps(parent.getItemProps({
88
88
  ...props,
89
89
  onFocus(event) {
90
90
  props.onFocus?.(event);
@@ -31,7 +31,7 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
31
31
  type ModalRef = {
32
32
  floating: HTMLElement | null;
33
33
  };
34
- export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "asChild" | "layoutId" | "trigger" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
34
+ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
35
35
  title: Label;
36
36
  ariaTitle?: string;
37
37
  } & {
@@ -54,7 +54,7 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
54
54
  trigger: Label | React.FC<any>;
55
55
  }> & {
56
56
  children?: React.ReactNode | undefined;
57
- }, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "asChild" | "layoutId" | "trigger" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
57
+ }, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
58
58
  ariaTitle: string;
59
59
  title?: Label;
60
60
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAmB,eAAe,EAAmF,MAAM,cAAc,CAAC;AAEjJ,OAAO,KAA+G,MAAM,OAAO,CAAC;AAGpI,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMnD,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,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC,CACH,CAAC;AAgFF,KAAK,QAAQ,GAAG;IAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAEjD,eAAO,MAAM,KAAK;WArGN,KAAK;gBAAc,MAAM;;UAC3B,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;aACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eAjBqB,MAAM;YAAU,KAAK;;UAClE,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;aACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CAwUjC,CAAC"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAmB,eAAe,EAAmF,MAAM,cAAc,CAAC;AACjJ,OAAO,KAA+G,MAAM,OAAO,CAAC;AAGpI,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKnD,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,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC,CACH,CAAC;AAgFF,KAAK,QAAQ,GAAG;IAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAEjD,eAAO,MAAM,KAAK;WArGN,KAAK;gBAAc,MAAM;;UAC3B,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;aACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eAjBqB,MAAM;YAAU,KAAK;;UAClE,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;aACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CA+UjC,CAAC"}
@@ -4,11 +4,10 @@ import { Dialog } from "@base-ui/react/dialog";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { XIcon } from "lucide-react";
6
6
  import { AnimatePresence, motion, MotionConfig, useMotionValue } from "motion/react";
7
- import { Slot as RadixSlot } from "radix-ui";
8
7
  import { forwardRef, Fragment, useEffect, useId, useImperativeHandle, useRef } from "react";
9
8
  import { useMediaQuery } from "../../hooks/use-media-query";
10
9
  import { css, mergeRefs } from "../../lib/dom";
11
- const Slot = RadixSlot.Slot;
10
+ import { Slot } from "../core/slot";
12
11
  const animationDuration = "500ms";
13
12
  const drawerLeft = {
14
13
  exit: { x: ["0%", "-30%"], opacity: 0, animationDuration },
@@ -160,37 +159,37 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
160
159
  : { animate: animated, initial: false };
161
160
  const scrollInitial = useMotionValue(undefined);
162
161
  const scroll = useMotionValue(undefined);
163
- return (_jsxs(Dialog.Root, { open: open, onOpenChange: onChange, children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Dialog.Trigger, { render: _jsx(Slot, {}), children: Trigger })) : (_jsx(Dialog.Trigger, { render: _jsx(motion.button, { layoutId: layoutId, type: "button" }), children: Trigger })) })) : null, _jsx(AnimatePresence, { mode: "wait", initial: false, children: open ? (_jsxs(Dialog.Portal, { keepMounted: false, children: [_jsx(Dialog.Backdrop, { className: css("fixed inset-0 flex isolate bg-floating-overlay/70 z-overlay h-[100dvh] !overflow-clip", type === "drawer" ? "" : "items-start justify-center p-10", overlayClassName) }), _jsx(MotionConfig, { reducedMotion: animated ? "user" : "always", children: _jsxs(Dialog.Popup, { render: _jsx(motion.div, { ...props, ...(title
164
- ? {
165
- "aria-labelledby": headingId,
166
- "aria-describedby": descriptionId,
167
- }
168
- : { "aria-label": ariaTitle }), ref: mergeRefs(floatingRef, removeScrollRef), className: css(variants({ position, type }), className, "isolate overscroll-contain fixed", type === "dialog" ? "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2" : ""), 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: floatingRef })) : null, title ? (_jsx(motion.header, { ...draggableMotionProps, className: "relative w-full isolate", children: _jsx(Dialog.Title, { render: _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, _jsx(motion.section, { ref: innerContent, "data-component": "modal-body", dragConstraints: dragConstraints, drag: isDesktop ? undefined : "y", onDrag: type === "sheet" ? (isDesktop ? undefined : onDragBody) : undefined, className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), onTouchEnd: () => {
169
- scroll.set(undefined);
170
- scrollInitial.set(undefined);
171
- }, onTouchStart: (e) => {
172
- const touch = e.changedTouches[0];
173
- scrollInitial.set(touch.pageY);
174
- scroll.set(touch.pageY);
175
- }, onTouchMove: (e) => {
176
- const touch = e.changedTouches[0];
177
- const y = touch.pageY;
178
- const initial = scrollInitial.get();
179
- if (initial !== undefined && initial < y) {
180
- const distanceFromTop = innerContent.current?.scrollTop;
181
- if (distanceFromTop === 0) {
182
- const div = floatingRef.current;
183
- const rect = div.getBoundingClientRect();
184
- const v = floatingSize.get() || rect.height;
185
- const diff = (initial - y) / 10;
186
- const down = v + diff;
187
- const max = window.outerHeight;
188
- const screenHeightToClose = calculateClose(max);
189
- if (down < screenHeightToClose)
190
- onChange?.(false);
191
- floatingSize.set(down);
192
- }
162
+ return (_jsxs(Dialog.Root, { open: open, onOpenChange: onChange, disablePointerDismissal: !overlayClickClose, children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Dialog.Trigger, { render: _jsx(Slot, {}), children: Trigger })) : (_jsx(Dialog.Trigger, { render: _jsx(motion.button, { layoutId: layoutId, type: "button" }), children: Trigger })) })) : null, _jsx(AnimatePresence, { mode: "wait", initial: false, children: open ? (_jsxs(Dialog.Portal, { keepMounted: false, children: [_jsx(Dialog.Backdrop, { className: css("fixed inset-0 flex isolate bg-floating-overlay/70 z-overlay h-[100dvh]", type === "drawer" ? "" : "items-start justify-center p-10", overlayClassName) }), _jsx(Dialog.Viewport, { className: css("fixed inset-0 flex isolate z-overlay h-[100dvh]", type === "drawer" ? "" : "items-start justify-center p-10", overlayClassName), children: _jsx(MotionConfig, { reducedMotion: animated ? "user" : "always", children: _jsxs(Dialog.Popup, { render: _jsx(motion.div, { ...props, ...(title
163
+ ? {
164
+ "aria-labelledby": headingId,
165
+ "aria-describedby": descriptionId,
193
166
  }
194
- scroll.set(touch.pageY);
195
- }, 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(Dialog.Close, { render: _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 })] }));
167
+ : { "aria-label": ariaTitle }), exit: "exit", layout: true, animate: "enter", initial: "initial", layoutId: layoutId, variants: animation, "data-component": "modal", ref: mergeRefs(floatingRef, removeScrollRef), style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, className: css(variants({ position, type }), className, "isolate overscroll-contain fixed", type === "dialog" ? "max-w-[calc(100vw-3rem)]" : "") }), children: [useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floatingRef })) : null, title ? (_jsx(motion.header, { ...draggableMotionProps, className: "relative w-full isolate", children: _jsx(Dialog.Title, { render: _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, _jsx(motion.section, { ref: innerContent, "data-component": "modal-body", dragConstraints: dragConstraints, drag: isDesktop ? undefined : "y", onDrag: type === "sheet" ? (isDesktop ? undefined : onDragBody) : undefined, className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), onTouchEnd: () => {
168
+ scroll.set(undefined);
169
+ scrollInitial.set(undefined);
170
+ }, onTouchStart: (e) => {
171
+ const touch = e.changedTouches[0];
172
+ scrollInitial.set(touch.pageY);
173
+ scroll.set(touch.pageY);
174
+ }, onTouchMove: (e) => {
175
+ const touch = e.changedTouches[0];
176
+ const y = touch.pageY;
177
+ const initial = scrollInitial.get();
178
+ if (initial !== undefined && initial < y) {
179
+ const distanceFromTop = innerContent.current?.scrollTop;
180
+ if (distanceFromTop === 0) {
181
+ const div = floatingRef.current;
182
+ const rect = div.getBoundingClientRect();
183
+ const v = floatingSize.get() || rect.height;
184
+ const diff = (initial - y) / 10;
185
+ const down = v + diff;
186
+ const max = window.outerHeight;
187
+ const screenHeightToClose = calculateClose(max);
188
+ if (down < screenHeightToClose)
189
+ onChange?.(false);
190
+ floatingSize.set(down);
191
+ }
192
+ }
193
+ scroll.set(touch.pageY);
194
+ }, 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(Dialog.Close, { render: _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 })] }));
196
195
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGAsWxB,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGAsWxB,CAAC"}
@@ -22,7 +22,7 @@ const transitionStyles = {
22
22
  };
23
23
  const emptyRef = [];
24
24
  const List = forwardRef(function VirtualList(props, ref) {
25
- return (_jsx(motion.ul, { ...props, ref: ref, className: "w-full overscroll-contain rounded-lg", children: _jsx(AnimatePresence, { children: props.children }) }));
25
+ return (_jsx(motion.ul, { ...props, ref: ref, className: "overscroll-contain w-full rounded-lg", children: _jsx(AnimatePresence, { children: props.children }) }));
26
26
  });
27
27
  const Item = forwardRef(function VirtualItem({ item, context, ...props }, ref) {
28
28
  return _jsx(motion.li, { ...props, ref: ref, className: "first:rounded-t-lg last:rounded-t-lg" });
@@ -174,7 +174,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
174
174
  const id = props.id || props.name;
175
175
  const shadowId = `${id}-shadow`;
176
176
  const isEmpty = displayList.length === 0;
177
- return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors link:text-danger md:p-1", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("input", { "data-shadow": "true", ...getReferenceProps({
177
+ return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex gap-0.5 items-center", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors md:p-1 link:text-primary", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors md:p-1 link:text-danger", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("input", { "data-shadow": "true", ...getReferenceProps({
178
178
  ...props,
179
179
  onFocus,
180
180
  pattern,
@@ -218,16 +218,16 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
218
218
  }), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : options.length === 0 ? "" : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-base group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.div, { ...getFloatingProps({
219
219
  ref: mergeRefs(removeScrollRef, refs.setFloating),
220
220
  style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy, height: "auto" },
221
- }), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating ease-in-out", onAnimationComplete: () => {
221
+ }), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "overscroll-contain p-0 m-0 max-h-80 list-none rounded-t-lg rounded-b-lg border ease-in-out isolate z-floating origin-[top_center] border-floating-border bg-floating-background text-foreground shadow-floating", onAnimationComplete: () => {
222
222
  if (!open)
223
223
  return setH(0);
224
224
  const ul = refs.floating.current;
225
225
  const li = ul.querySelectorAll("li").item(0);
226
226
  const sum = (li ? li.getBoundingClientRect().height : MIN_SIZE) * displayList.length;
227
227
  return flushSync(() => setH(sum + 10));
228
- }, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList,
228
+ }, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex justify-between p-2 w-full text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList,
229
229
  // style={{ height: h - 10 }}
230
- defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "max-h-full overscroll-contain rounded-lg border-floating bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
230
+ defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "overscroll-contain p-0 max-h-full rounded-lg border-floating bg-floating-background text-foreground", itemContent: (i, option) => {
231
231
  const Label = option.Render ?? Frag;
232
232
  const active = value === option.value || value === option.label;
233
233
  const selected = index === i;
@@ -1 +1 @@
1
- {"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA6F,MAAM,OAAO,CAAC;AASlH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACnC,eAAe,CAAC,OAAO,CAAC,EACxB;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACjD,CACJ,CAAC;AA0DF,eAAO,MAAM,WAAW,wGAuavB,CAAC"}
1
+ {"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA6F,MAAM,OAAO,CAAC;AASlH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,eAAe,CAAC,OAAO,CAAC,EACxB;IACE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC/C,CACF,CAAC;AA0DF,eAAO,MAAM,WAAW,wGAuavB,CAAC"}