@g4rcez/components 2.0.4 → 2.0.6
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/button.d.ts +1 -0
- package/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/button.js +1 -0
- package/dist/components/core/tag.js +1 -1
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.js +2 -2
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +13 -15
- package/dist/components/floating/menu.js +2 -2
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +12 -15
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +59 -53
- package/dist/components/form/slider.d.ts +2 -2
- package/dist/components/form/slider.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6936 -6846
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +35 -35
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/plugin.tailwind.d.ts +4 -7
- package/dist/preset/plugin.tailwind.d.ts.map +1 -1
- package/dist/preset/plugin.tailwind.js +13 -20
- package/dist/preset/src/styles/common.d.ts +1 -1
- package/dist/preset/src/styles/common.js +1 -1
- package/dist/preset/src/styles/dark.js +2 -2
- package/dist/styles/common.d.ts +1 -1
- package/dist/styles/common.js +1 -1
- package/dist/styles/dark.js +2 -2
- package/package.json +1 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/core/button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,QAAA,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/core/button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCb,CAAC;AAeF,KAAK,QAAQ,GAAG,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI,iBAAiB,CAC/E,gBAAgB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAChC,oCAAoC;IACpC,IAAI,EAAE,KAAK,CAAC;IACZ,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAA;CACnB,CAAC,EAAE,CAAC,CAAC,CACT,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAwB5F,CAAC"}
|
|
@@ -38,7 +38,7 @@ const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
|
-
const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-
|
|
41
|
+
const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-0 items-center justify-center align-middle whitespace-nowrap", {
|
|
42
42
|
variants,
|
|
43
43
|
defaultVariants: { theme: "primary", size: "default" },
|
|
44
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/components/display/list.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,KAAK,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CAC5C,CAAC;AAIF,KAAK,iBAAiB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/components/display/list.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,KAAK,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CAC5C,CAAC;AAIF,KAAK,iBAAiB,GAAG,MAAM,CAAC;AAuDhC,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,4CAoEvE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,4CAA0C,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDis
|
|
|
4
4
|
import { AnimatePresence, motion, MotionConfig } from "motion/react";
|
|
5
5
|
import { XIcon } from "lucide-react";
|
|
6
6
|
import React, { Fragment, useCallback, useId, useState } from "react";
|
|
7
|
-
const FloatItem = ({ item, context, setter, get, refs }) => (_jsx(FloatingPortal, { children: _jsx(MotionConfig, { reducedMotion: "user", transition: { type: "tween", stiffness: 25, duration: 0.
|
|
7
|
+
const FloatItem = ({ item, context, setter, get, refs }) => (_jsx(FloatingPortal, { children: _jsx(MotionConfig, { reducedMotion: "user", transition: { type: "tween", stiffness: 25, duration: 0.3 }, children: _jsxs(AnimatePresence, { presenceAffectsLayout: true, children: [item ? (_jsx(motion.div, { exit: { opacity: 0 }, animate: { opacity: 1 }, initial: { opacity: 0 }, className: "pointer-events-none fixed inset-0 top-0 z-overlay h-screen w-screen bg-floating-overlay/70" })) : null, item ? (_jsx(FloatingOverlay, { lockScroll: true, className: "absolute inset-0 z-floating flex items-center justify-center", children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { layout: true, layoutId: `item-${item.id}`, className: "relative flex h-min w-min min-w-xs flex-col gap-4 rounded-card border border-card-border bg-card-background p-6 py-4 pb-8 shadow-shadow-card", ref: refs.setFloating, ...get(), children: [_jsx("nav", { className: "absolute right-4 top-1 lg:right-2", children: _jsx("button", { type: "button", onClick: setter, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) }), _jsxs("header", { className: "flex w-full flex-wrap items-center justify-between gap-2", children: [_jsx("h3", { className: "min-w-full text-balance text-2xl font-medium", children: item.title }), _jsx("p", { className: "text-sm leading-snug text-secondary", children: item.description })] }), item.children] }) }) })) : null] }) }) }));
|
|
8
8
|
export const AnimatedList = (props) => {
|
|
9
9
|
const [selected, setSelected] = useState(null);
|
|
10
10
|
const id = useId();
|
|
@@ -26,7 +26,7 @@ export const AnimatedList = (props) => {
|
|
|
26
26
|
const innerId = `${id}-${index}`;
|
|
27
27
|
const setter = () => setSelected({ ...item, id: innerId });
|
|
28
28
|
const Leading = item.leading;
|
|
29
|
-
return (_jsx(motion.li, { layout: true, layoutId: `item-${innerId}`, className: `border-b border-card-border py-2 last:border-transparent`, children: _jsx(motion.div, { layoutId: `toast-${innerId}`, className: "relative", children: _jsx("div", { className: "relative flex items-start space-x-3", children: _jsxs(Fragment, { children: [item.avatar ? (_jsx("div", { children: _jsx("div", { className: "relative px-1", children: _jsx("button", { onClick: setter, className: "flex size-10 items-center justify-center ring-primary", children: item.avatar }) }) })) : null, _jsx("div", { className: "min-w-0 flex-1 py-1 text-foreground", children: _jsxs("div", { className: "flex flex-row flex-nowrap justify-between gap-4", children: [_jsxs("button", { onClick: setter, className: "cursor-pointer text-left transition-all ease-out hover:
|
|
29
|
+
return (_jsx(motion.li, { layout: true, layoutId: `item-${innerId}`, className: `border-b border-card-border py-2 last:border-transparent`, children: _jsx(motion.div, { layoutId: `toast-${innerId}`, className: "relative", children: _jsx("div", { className: "relative flex items-start space-x-3", children: _jsxs(Fragment, { children: [item.avatar ? (_jsx("div", { children: _jsx("div", { className: "relative px-1", children: _jsx("button", { onClick: setter, className: "flex size-10 items-center justify-center ring-primary", children: item.avatar }) }) })) : null, _jsx("div", { className: "min-w-0 flex-1 py-1 text-foreground", children: _jsxs("div", { className: "flex flex-row flex-nowrap justify-between gap-4", children: [_jsxs("button", { onClick: setter, className: "cursor-pointer text-left transition-all ease-out hover:text-primary", children: [_jsx("h3", { children: item.title }), _jsx("p", { className: "text-sm leading-snug text-secondary", children: item.description })] }), Leading ? _jsx(Leading, { open: setter }) : null] }) })] }) }) }) }, innerId));
|
|
30
30
|
}) })] }));
|
|
31
31
|
};
|
|
32
32
|
export const AnimatedListItem = (props) => _jsx(Fragment, { children: props.children });
|
|
@@ -2,7 +2,7 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { type PropsWithChildren } from "react";
|
|
3
3
|
import { Label } from "../../types";
|
|
4
4
|
declare const variants: (props?: ({
|
|
5
|
-
theme?: "default" | "info" | "warn" | "
|
|
5
|
+
theme?: "default" | "info" | "warn" | "danger" | "success" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
7
|
type NotificationOptions = Partial<{
|
|
8
8
|
title: Label;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAA8C,KAAK,iBAAiB,EAAwD,MAAM,OAAO,CAAC;AAEjJ,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,QAAQ;;mFAcb,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,2CAuDzG"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Toast as RadixToast } from "radix-ui";
|
|
4
5
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import { XIcon } from "lucide-react";
|
|
6
6
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
-
import {
|
|
7
|
+
import { XIcon } from "lucide-react";
|
|
8
8
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
9
9
|
import { useHover } from "../../hooks/use-hover";
|
|
10
|
-
const variants = cva("relative isolate z-tooltip flex justify-between overflow-hidden whitespace-nowrap rounded-lg border text-sm shadow-shadow-notification", {
|
|
10
|
+
const variants = cva("relative isolate z-tooltip flex justify-between overflow-hidden whitespace-nowrap rounded-lg border text-sm shadow-shadow-notification supports-[backdrop-filter]:backdrop-blur-xl", {
|
|
11
11
|
variants: {
|
|
12
12
|
theme: {
|
|
13
|
+
warn: "bg-warn-notification/90 text-warn-hover border-warn/50",
|
|
14
|
+
info: "bg-info-notification supports-[backdrop-filter]:bg-info-notification/50 supports-[backdrop-filter]:bg-info/20 text-info border-info/50",
|
|
15
|
+
danger: "bg-danger-notification supports-[backdrop-filter]:bg-danger-notification/60 text-danger border-danger/50",
|
|
16
|
+
success: "bg-success-notification supports-[backdrop-filter]:bg-success-notification/50 text-success border-success/50",
|
|
13
17
|
default: "border-card-border bg-card-background text-foreground",
|
|
14
|
-
info: "bg-alert-info-bg text-alert-info-text border-alert-info-border",
|
|
15
|
-
warn: "bg-alert-warn-bg text-alert-warn-text border-alert-warn-border",
|
|
16
|
-
danger: "bg-alert-danger-bg text-alert-danger-text border-alert-danger-border",
|
|
17
|
-
success: "bg-alert-success-bg text-alert-success-text border-alert-success-border",
|
|
18
|
-
secondary: "bg-alert-secondary-bg text-alert-secondary-text border-alert-secondary-border",
|
|
19
|
-
muted: "bg-alert-muted-bg text-alert-muted-text border-alert-muted-border",
|
|
20
18
|
},
|
|
21
19
|
},
|
|
22
20
|
defaultVariants: { theme: "default" },
|
|
@@ -36,11 +34,11 @@ const Notification = forwardRef(function Toast(props, forwardedRef) {
|
|
|
36
34
|
const duration = props.duration;
|
|
37
35
|
const variant = props.hover ? "hover" : props.isLast ? "isLast" : "other";
|
|
38
36
|
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: "
|
|
37
|
+
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: "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: "
|
|
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("div", { className: className, children: [_jsxs("div", { className: "flex flex-col p-4", children: [props.title ? (_jsx(RadixToast.Title, { className: "text-lg font-medium leading-relaxed select-text truncate", children: "Title" })) : null, _jsx(RadixToast.Description, { className: "select-text truncate", children: props.text })] }), closable ? (_jsx(RadixToast.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: "w-5 h-5" }) })) : null] }) }) }));
|
|
44
42
|
});
|
|
45
43
|
export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
46
44
|
const ref = useRef(null);
|
|
@@ -61,10 +59,10 @@ export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
|
61
59
|
const close = () => setMessages((prev) => prev.filter((x) => x.id !== id));
|
|
62
60
|
return { clear, close };
|
|
63
61
|
}, [max]);
|
|
64
|
-
return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: messages.map((toast, index, list) => {
|
|
63
|
+
const close = () => setMessages((prev) => prev.filter((t) => t.id !== toast.id));
|
|
64
|
+
return (_createElement(Notification, { ...toast, key: toast.id, hover: hover, index: index, onClose: close, isLast: list.length - 1 === index, reversedIndex: list.length - (index + 1) }));
|
|
65
|
+
}) }), _jsx(RadixToast.Viewport, { ref: ref, "data-items": messages.length, style: {
|
|
68
66
|
justifyContent: "start",
|
|
69
67
|
height: `${(hover ? messages.length : Math.min(1, messages.length)) * 7}rem`,
|
|
70
68
|
}, 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" })] }));
|
|
@@ -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 "
|
|
4
|
+
import { Slot } from "radix-ui";
|
|
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, { ...getReferenceProps(parent.getItemProps({
|
|
87
|
+
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot.Root, { ...getReferenceProps(parent.getItemProps({
|
|
88
88
|
...props,
|
|
89
89
|
onFocus(event) {
|
|
90
90
|
props.onFocus?.(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,YAAY,EASpB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,eAAe,EAAqE,MAAM,cA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AAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAClC,CAAC,CACL,CAAC;AAyEF,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAI/D,eAAO,MAAM,KAAK;WAlGJ,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;;;2CAuRrC,CAAC"}
|
|
@@ -30,7 +30,7 @@ const animations = {
|
|
|
30
30
|
},
|
|
31
31
|
dialog: {
|
|
32
32
|
exit: { opacity: 0, scale: 0.95, animationDuration },
|
|
33
|
-
initial: { opacity: 0.5, scale: 0.95, animationDuration, transition: { duration: 0.5, ease:
|
|
33
|
+
initial: { opacity: 0.5, scale: 0.95, animationDuration, transition: { duration: 0.5, ease: 'easeInOut' } },
|
|
34
34
|
enter: { opacity: 1, scale: [1.05, 1], animationDuration },
|
|
35
35
|
},
|
|
36
36
|
};
|
|
@@ -50,7 +50,7 @@ const variants = cva("z-floating border border-card-border ring-0 outline-0 appe
|
|
|
50
50
|
defaultVariants: { position: "right", type: "dialog" },
|
|
51
51
|
});
|
|
52
52
|
const dragConstraints = { top: 0, left: 0, right: 0, bottom: 0 };
|
|
53
|
-
const calculateClose = (n) => n * 0.
|
|
53
|
+
const calculateClose = (n) => n * 0.65;
|
|
54
54
|
const Draggable = (props) => {
|
|
55
55
|
const onDrag = (_, info) => {
|
|
56
56
|
if (props.parent.current) {
|
|
@@ -65,22 +65,18 @@ const Draggable = (props) => {
|
|
|
65
65
|
const rect = div.getBoundingClientRect();
|
|
66
66
|
const v = props.value.get() || rect.height;
|
|
67
67
|
const result = Math.abs(v - info.delta.y);
|
|
68
|
-
const
|
|
69
|
-
const screenHeightToClose = calculateClose(max);
|
|
68
|
+
const screenHeightToClose = calculateClose(window.outerHeight);
|
|
70
69
|
if (result >= screenHeightToClose)
|
|
71
70
|
return props.value.set(result);
|
|
72
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
73
|
-
document.activeElement?.blur();
|
|
74
|
-
}
|
|
75
71
|
props.onChange(false);
|
|
76
|
-
return setTimeout(() => props.value.set(
|
|
72
|
+
return setTimeout(() => props.value.set(window.outerHeight), 350);
|
|
77
73
|
}
|
|
78
74
|
};
|
|
79
75
|
return (_jsx(motion.div, { draggable: true, dragMomentum: true, dragListener: true, dragPropagation: true, onDrag: onDrag, animate: false, initial: false, dragElastic: 0, dragDirectionLock: true, dragSnapToOrigin: true, drag: props.sheet ? "y" : "x", dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className: css("absolute rounded-lg", props.sheet ? "cursor-row-resize" : "cursor-col-resize bg-floating-border", props.sheet
|
|
80
76
|
? "top-1 flex h-3 w-full justify-center py-2"
|
|
81
77
|
: props.position === "left"
|
|
82
78
|
? "right-5 top-1/2 h-10 w-2"
|
|
83
|
-
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "
|
|
79
|
+
: "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 }));
|
|
84
80
|
};
|
|
85
81
|
const positions = { drawer: "right", sheet: "none", dialog: "none" };
|
|
86
82
|
const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
@@ -100,11 +96,12 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
100
96
|
const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
|
|
101
97
|
const animation = typeof func === "function" ? func(position) : func;
|
|
102
98
|
const type = isDesktop ? _type : forceType ? _type : "sheet";
|
|
103
|
-
const floating = useFloating({ open, onOpenChange: onChange });
|
|
104
|
-
const click = useClick(floating.context
|
|
99
|
+
const floating = useFloating({ open: open, onOpenChange: onChange, transform: true, strategy: "absolute" });
|
|
100
|
+
const click = useClick(floating.context);
|
|
105
101
|
const role = useRole(floating.context, { role: roleName });
|
|
106
102
|
const dismiss = useDismiss(floating.context, {
|
|
107
103
|
escapeKey: true,
|
|
104
|
+
referencePress: true,
|
|
108
105
|
outsidePress: overlayClickClose,
|
|
109
106
|
});
|
|
110
107
|
const interactions = useInteractions([click, role, dismiss].concat(outInteractions));
|
|
@@ -112,7 +109,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
112
109
|
const floatingSize = useMotionValue(undefined);
|
|
113
110
|
useEffect(() => {
|
|
114
111
|
floatingSize.set(undefined);
|
|
115
|
-
}, [type]);
|
|
112
|
+
}, [floatingSize, type]);
|
|
116
113
|
const onClose = () => onChange(false);
|
|
117
114
|
useImperativeHandle(externalRef, () => {
|
|
118
115
|
return { context: floating.context, floating: removeScrollRef.current };
|
|
@@ -142,10 +139,10 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
142
139
|
};
|
|
143
140
|
const animationProps = animated && type === "sheet"
|
|
144
141
|
? {
|
|
145
|
-
...commonAnimated,
|
|
146
142
|
dragElastic: 0,
|
|
147
143
|
onDrag: onDrag,
|
|
148
144
|
dragConstraints,
|
|
145
|
+
...commonAnimated,
|
|
149
146
|
dragListener: true,
|
|
150
147
|
dragMomentum: true,
|
|
151
148
|
dragPropagation: true,
|
|
@@ -155,7 +152,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
155
152
|
drag: type === "sheet" ? "y" : "x",
|
|
156
153
|
}
|
|
157
154
|
: commonAnimated;
|
|
158
|
-
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,
|
|
155
|
+
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, { mode: "wait", propagate: true, presenceAffectsLayout: true, 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, ...animationProps, ...(title
|
|
159
156
|
? {
|
|
160
157
|
"aria-labelledby": headingId,
|
|
161
158
|
"aria-describedby": descriptionId,
|
|
@@ -167,5 +164,5 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
167
164
|
position,
|
|
168
165
|
type,
|
|
169
166
|
}), className, "overscroll-contain"),
|
|
170
|
-
}), "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "
|
|
167
|
+
}), "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "px-8 pb-2 text-3xl font-medium leading-relaxed border-b select-text border-floating-border", children: title })) : null })) : null, _jsx("section", { "data-component": "modal-body", className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), 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, useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null] }) }) })) : null }, headingId) })] }));
|
|
171
168
|
});
|
|
@@ -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;
|
|
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;AAG5C,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,yGA0WxB,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { css, dispatchInput, getRemainingSize, initializeInputDataset, mergeRefs
|
|
|
13
13
|
import { safeRegex } from "../../lib/fns";
|
|
14
14
|
import { fzf } from "../../lib/fzf";
|
|
15
15
|
import { InputField } from "./input-field";
|
|
16
|
+
import { useReducer } from "use-typed-reducer";
|
|
16
17
|
const Frag = (props) => _jsx(Fragment, { children: props.children });
|
|
17
18
|
const transitionStyles = {
|
|
18
19
|
duration: 300,
|
|
@@ -33,45 +34,59 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
33
34
|
const scroller = useRef(null);
|
|
34
35
|
const fieldset = useRef(null);
|
|
35
36
|
const virtuoso = useRef(null);
|
|
36
|
-
const defaults = props.value ?? props.defaultValue ?? "";
|
|
37
|
+
const defaults = options.length === 0 ? "" : props.value ?? props.defaultValue ?? "";
|
|
37
38
|
const translation = useTranslations();
|
|
39
|
+
const [state, dispatch] = useReducer({
|
|
40
|
+
open: false,
|
|
41
|
+
shadow: "",
|
|
42
|
+
value: defaults,
|
|
43
|
+
label: options.find((x) => x.value === defaults)?.label ?? defaults,
|
|
44
|
+
index: null
|
|
45
|
+
}, (get) => ({
|
|
46
|
+
open: (open) => ({ open }),
|
|
47
|
+
index: (index) => ({ index }),
|
|
48
|
+
shadow: (shadow) => ({ shadow }),
|
|
49
|
+
option: (value, label) => ({ value, label }),
|
|
50
|
+
select: (value, label, index) => ({ open: false, shadow: "", index, value, label }),
|
|
51
|
+
caretDown: () => ({ open: true, shadow: "" }),
|
|
52
|
+
onClose: () => ({ open: false, label: "", value: "", shadow: "" }),
|
|
53
|
+
onFocus: () => {
|
|
54
|
+
const prev = get.state();
|
|
55
|
+
return { index: prev.index === null ? 0 : prev.index, open: true, shadow: "" };
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
38
58
|
const [h, setH] = useState(() => Math.min(320, MIN_SIZE * options.length));
|
|
39
|
-
const [open, setOpen] = useState(false);
|
|
40
|
-
const [shadow, setShadow] = useState("");
|
|
41
|
-
const [value, setValue] = useState(defaults);
|
|
42
|
-
const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
|
|
43
|
-
const [index, setIndex] = useState(null);
|
|
44
59
|
const listRef = useRef(emptyRef);
|
|
45
|
-
const removeScrollRef = useRemoveScroll(open, "block-only");
|
|
46
|
-
const innerOptions = dynamicOption && shadow !== ""
|
|
60
|
+
const removeScrollRef = useRemoveScroll(state.open, "block-only");
|
|
61
|
+
const innerOptions = dynamicOption && state.shadow !== ""
|
|
47
62
|
? [
|
|
48
63
|
{
|
|
49
|
-
value: shadow,
|
|
50
|
-
label: shadow,
|
|
64
|
+
value: state.shadow,
|
|
65
|
+
label: state.shadow,
|
|
51
66
|
"data-dynamic": "true",
|
|
52
67
|
},
|
|
53
68
|
...options,
|
|
54
69
|
]
|
|
55
70
|
: options;
|
|
56
|
-
const list = shadow
|
|
71
|
+
const list = state.shadow
|
|
57
72
|
? fzf(innerOptions, "value", [
|
|
58
|
-
{ key: "value", value: shadow },
|
|
59
|
-
{ key: "label", value: shadow },
|
|
73
|
+
{ key: "value", value: state.shadow },
|
|
74
|
+
{ key: "label", value: state.shadow },
|
|
60
75
|
])
|
|
61
76
|
: innerOptions;
|
|
62
77
|
const setClosed = () => {
|
|
63
|
-
setOpen(false);
|
|
64
78
|
setH(0);
|
|
79
|
+
dispatch.open(false);
|
|
65
80
|
};
|
|
66
81
|
const displayList = list.filter((x) => x.hidden !== true);
|
|
67
82
|
const pattern = dynamicOption
|
|
68
83
|
? undefined
|
|
69
84
|
: `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? "|" + safeRegex(x.label) : ""}`).join("|")})$`;
|
|
70
85
|
const { x, y, strategy, refs, context } = useFloating({
|
|
71
|
-
open,
|
|
86
|
+
open: state.open,
|
|
72
87
|
transform: true,
|
|
73
|
-
onOpenChange: setOpen,
|
|
74
88
|
placement: "bottom-start",
|
|
89
|
+
onOpenChange: dispatch.open,
|
|
75
90
|
whileElementsMounted: autoUpdate,
|
|
76
91
|
middleware: [
|
|
77
92
|
offset(4),
|
|
@@ -100,17 +115,20 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
100
115
|
loop: true,
|
|
101
116
|
virtual: true,
|
|
102
117
|
allowEscape: true,
|
|
103
|
-
activeIndex: index,
|
|
104
|
-
selectedIndex: index,
|
|
105
118
|
focusItemOnOpen: "auto",
|
|
106
119
|
openOnArrowKeyDown: true,
|
|
107
120
|
scrollItemIntoView: true,
|
|
121
|
+
activeIndex: state.index,
|
|
122
|
+
selectedIndex: state.index,
|
|
108
123
|
}),
|
|
109
124
|
]);
|
|
110
125
|
useEffect(() => {
|
|
111
126
|
if (props.value) {
|
|
127
|
+
if (options.length === 0)
|
|
128
|
+
return dispatch.option("", "");
|
|
112
129
|
const item = options.find((x) => x.value === props.value);
|
|
113
|
-
|
|
130
|
+
if (item)
|
|
131
|
+
return dispatch.option(item.value, item.label ?? item.value);
|
|
114
132
|
}
|
|
115
133
|
}, [props.value, options.length]);
|
|
116
134
|
useEffect(() => {
|
|
@@ -121,7 +139,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
121
139
|
return;
|
|
122
140
|
const s = getRemainingSize(inputRef.current, window.innerHeight);
|
|
123
141
|
setTimeout(() => setH(Math.min(s, displayList.length * MIN_SIZE)), 100);
|
|
124
|
-
}, [shadow, open, refs.reference, displayList.length]);
|
|
142
|
+
}, [state.shadow, state.open, refs.reference, displayList.length]);
|
|
125
143
|
useEffect(() => {
|
|
126
144
|
const input = refs.reference.current;
|
|
127
145
|
if (!input)
|
|
@@ -129,55 +147,43 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
129
147
|
return initializeInputDataset(input);
|
|
130
148
|
}, []);
|
|
131
149
|
const onSelect = (opt, i) => {
|
|
132
|
-
setValue(opt.value);
|
|
133
150
|
const input = refs.reference.current;
|
|
134
|
-
if (!input)
|
|
135
|
-
return;
|
|
151
|
+
if (!input) {
|
|
152
|
+
return void dispatch.option(opt.value, opt.label ?? opt.value);
|
|
153
|
+
}
|
|
136
154
|
input?.setAttribute("data-value", opt.value);
|
|
137
155
|
input.value = opt.value;
|
|
138
156
|
const event = new Event("change", { bubbles: false, cancelable: true });
|
|
139
157
|
input.dispatchEvent(event);
|
|
140
158
|
if (props.onChange)
|
|
141
159
|
props.onChange(event);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
setShadow("");
|
|
145
|
-
setIndex(i);
|
|
160
|
+
const label = options.find(x => x.value === opt.value)?.label || opt.value;
|
|
161
|
+
dispatch.select(opt.value, label, i);
|
|
146
162
|
};
|
|
147
163
|
const onChange = (event) => {
|
|
148
164
|
const value = event.target.value;
|
|
149
|
-
|
|
165
|
+
dispatch.shadow(value);
|
|
150
166
|
if (!open && value === "")
|
|
151
|
-
return
|
|
167
|
+
return dispatch.open(true);
|
|
152
168
|
event.target.name = props.name || "";
|
|
153
|
-
return value ?
|
|
169
|
+
return value ? dispatch.open(true) : props.onChange?.(event);
|
|
154
170
|
};
|
|
155
171
|
const onCaretDownClick = () => {
|
|
156
|
-
|
|
157
|
-
setShadow("");
|
|
172
|
+
dispatch.caretDown();
|
|
158
173
|
refs.reference.current?.focus();
|
|
159
174
|
};
|
|
160
|
-
const onFocus = () => {
|
|
161
|
-
setIndex((prev) => (prev === null ? 0 : prev));
|
|
162
|
-
setOpen(true);
|
|
163
|
-
setShadow("");
|
|
164
|
-
};
|
|
165
175
|
const onClose = () => {
|
|
166
176
|
refs.reference.current?.setAttribute("data-value", "");
|
|
167
|
-
|
|
168
|
-
setValue("");
|
|
169
|
-
setLabel("");
|
|
177
|
+
dispatch.onClose();
|
|
170
178
|
dispatchInput(refs.reference.current);
|
|
171
|
-
setClosed();
|
|
172
179
|
};
|
|
173
180
|
const id = props.id || props.name;
|
|
174
181
|
const shadowId = `${id}-shadow`;
|
|
175
182
|
const isEmpty = displayList.length === 0;
|
|
176
|
-
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({
|
|
183
|
+
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 })] }), state.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
184
|
...props,
|
|
178
|
-
onFocus,
|
|
185
|
+
onFocus: dispatch.onFocus,
|
|
179
186
|
pattern,
|
|
180
|
-
onChange,
|
|
181
187
|
id: shadowId,
|
|
182
188
|
name: shadowId,
|
|
183
189
|
ref: refs.setReference,
|
|
@@ -190,23 +196,23 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
190
196
|
if (!open)
|
|
191
197
|
return;
|
|
192
198
|
if (event.key === "ArrowDown") {
|
|
193
|
-
let next = Is.number(index) ? index + 1 : 0;
|
|
199
|
+
let next = Is.number(state.index) ? state.index + 1 : 0;
|
|
194
200
|
if (next > displayList.length - 1)
|
|
195
201
|
next = 0;
|
|
196
202
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
197
|
-
return
|
|
203
|
+
return dispatch.index(next);
|
|
198
204
|
}
|
|
199
205
|
if (event.key === "ArrowUp") {
|
|
200
|
-
let next = Is.number(index) ? index - 1 : displayList.length - 1;
|
|
206
|
+
let next = Is.number(state.index) ? state.index - 1 : displayList.length - 1;
|
|
201
207
|
if (next < 0)
|
|
202
208
|
next = displayList.length - 1;
|
|
203
209
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
204
|
-
return
|
|
210
|
+
return dispatch.index(next);
|
|
205
211
|
}
|
|
206
212
|
if (event.key === "Enter") {
|
|
207
|
-
if (index !== null && displayList[index]) {
|
|
213
|
+
if (state.index !== null && displayList[state.index]) {
|
|
208
214
|
event.preventDefault();
|
|
209
|
-
return onSelect(displayList[index], index);
|
|
215
|
+
return onSelect(displayList[state.index], state.index);
|
|
210
216
|
}
|
|
211
217
|
if (displayList.length === 1) {
|
|
212
218
|
event.preventDefault();
|
|
@@ -214,7 +220,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
222
|
},
|
|
217
|
-
}), "data-
|
|
223
|
+
}), "data-name": id, "data-target": id, autoComplete: "off", onChange: onChange, required: required, "data-error": !!error, "aria-autocomplete": "list", "data-value": state.value, placeholder: props.placeholder, value: state.open ? state.shadow : state.label || state.value, 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 || state.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({
|
|
218
224
|
ref: mergeRefs(removeScrollRef, refs.setFloating),
|
|
219
225
|
style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy },
|
|
220
226
|
}), 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: () => {
|
|
@@ -226,8 +232,8 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
226
232
|
return flushSync(() => setH(sum + 10));
|
|
227
233
|
}, 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, style: { height: h - 10 }, defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "max-h-[calc(100%-2px)] overscroll-contain rounded-lg border-floating bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
|
|
228
234
|
const Label = option.Render ?? Frag;
|
|
229
|
-
const active = value === option.value || value === option.label;
|
|
230
|
-
const selected = index === i;
|
|
235
|
+
const active = state.value === option.value || state.value === option.label;
|
|
236
|
+
const selected = state.index === i;
|
|
231
237
|
const children = option.label ?? option.value;
|
|
232
238
|
return (_jsx("button", { "data-value": option.value, ...getItemProps({
|
|
233
239
|
ref: (node) => void (listRef.current[i] = node),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type SliderProps =
|
|
1
|
+
import { Slider as RadixSlider } from "radix-ui";
|
|
2
|
+
type SliderProps = Parameters<typeof RadixSlider.Root>[0] & {
|
|
3
3
|
tooltip?: boolean;
|
|
4
4
|
};
|
|
5
5
|
export declare const Slider: (props: SliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/components/form/slider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/components/form/slider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAOjD,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAmCF,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,4CAoBxC,CAAC"}
|
|
@@ -11,6 +11,7 @@ export * from "./display/progress";
|
|
|
11
11
|
export * from "./display/stats";
|
|
12
12
|
export * from "./display/tabs";
|
|
13
13
|
export * from "./display/timeline";
|
|
14
|
+
export * from "./display/list";
|
|
14
15
|
export * from "./floating/command-palette";
|
|
15
16
|
export * from "./floating/dropdown";
|
|
16
17
|
export * from "./floating/expand";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAA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
12
|
export * from "./display/tabs";
|
|
13
13
|
export * from "./display/timeline";
|
|
14
|
+
export * from "./display/list";
|
|
14
15
|
export * from "./floating/command-palette";
|
|
15
16
|
export * from "./floating/dropdown";
|
|
16
17
|
export * from "./floating/expand";
|