@g4rcez/components 2.0.6 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +15 -13
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +15 -12
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +3 -3
- package/dist/components/table/row.js +2 -4
- package/dist/components/table/table-lib.d.ts +2 -0
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/table-lib.js +5 -2
- package/dist/components/table/thead.js +2 -2
- package/dist/flow/flow.d.ts.map +1 -1
- package/dist/flow/flow.js +10 -8
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +430 -421
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +17 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/plugin.tailwind.d.ts +7 -4
- package/dist/preset/plugin.tailwind.d.ts.map +1 -1
- package/dist/preset/plugin.tailwind.js +20 -13
- 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 +10 -4
|
@@ -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" | "danger" | "success" | null | undefined;
|
|
5
|
+
theme?: "default" | "info" | "warn" | "muted" | "danger" | "success" | "secondary" | 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":"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,20 +1,22 @@
|
|
|
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";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
6
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
7
5
|
import { XIcon } from "lucide-react";
|
|
6
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
+
import { Toast as RadixToast } from "radix-ui";
|
|
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", {
|
|
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",
|
|
17
13
|
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",
|
|
18
20
|
},
|
|
19
21
|
},
|
|
20
22
|
defaultVariants: { theme: "default" },
|
|
@@ -34,11 +36,11 @@ const Notification = forwardRef(function Toast(props, forwardedRef) {
|
|
|
34
36
|
const duration = props.duration;
|
|
35
37
|
const variant = props.hover ? "hover" : props.isLast ? "isLast" : "other";
|
|
36
38
|
const className = variants({ theme: props.theme || "default" });
|
|
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
|
|
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: {
|
|
38
40
|
isLast: { y: 10, scale: 1, animationDuration: "300ms", opacity: 1 },
|
|
39
41
|
hover: { y: 0, position: "static", scale: 1, opacity: 1 },
|
|
40
42
|
other: animatedIndex[props.reversedIndex] || animatedIndex.default,
|
|
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
|
|
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] }) }) }));
|
|
42
44
|
});
|
|
43
45
|
export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
44
46
|
const ref = useRef(null);
|
|
@@ -59,10 +61,10 @@ export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
|
59
61
|
const close = () => setMessages((prev) => prev.filter((x) => x.id !== id));
|
|
60
62
|
return { clear, close };
|
|
61
63
|
}, [max]);
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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: {
|
|
66
68
|
justifyContent: "start",
|
|
67
69
|
height: `${(hover ? messages.length : Math.min(1, messages.length)) * 7}rem`,
|
|
68
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" })] }));
|
|
@@ -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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AC;IAC7B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAClC,CAAC,CACL,CAAC;AA6EF,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAI/D,eAAO,MAAM,KAAK;WAtGJ,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;;;2CAgSrC,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.6;
|
|
54
54
|
const Draggable = (props) => {
|
|
55
55
|
const onDrag = (_, info) => {
|
|
56
56
|
if (props.parent.current) {
|
|
@@ -65,18 +65,22 @@ 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
|
|
68
|
+
const max = window.outerHeight;
|
|
69
|
+
const screenHeightToClose = calculateClose(max);
|
|
69
70
|
if (result >= screenHeightToClose)
|
|
70
71
|
return props.value.set(result);
|
|
72
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
73
|
+
document.activeElement?.blur();
|
|
74
|
+
}
|
|
71
75
|
props.onChange(false);
|
|
72
|
-
return setTimeout(() => props.value.set(
|
|
76
|
+
return setTimeout(() => props.value.set(undefined), 350);
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
79
|
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
|
|
76
80
|
? "top-1 flex h-3 w-full justify-center py-2"
|
|
77
81
|
: props.position === "left"
|
|
78
82
|
? "right-5 top-1/2 h-10 w-2"
|
|
79
|
-
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "w-1/4
|
|
83
|
+
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "h-2 w-1/4 rounded-lg bg-floating-border" }) : null }));
|
|
80
84
|
};
|
|
81
85
|
const positions = { drawer: "right", sheet: "none", dialog: "none" };
|
|
82
86
|
const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
@@ -96,12 +100,11 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
96
100
|
const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
|
|
97
101
|
const animation = typeof func === "function" ? func(position) : func;
|
|
98
102
|
const type = isDesktop ? _type : forceType ? _type : "sheet";
|
|
99
|
-
const floating = useFloating({ open
|
|
100
|
-
const click = useClick(floating.context);
|
|
103
|
+
const floating = useFloating({ open, onOpenChange: onChange });
|
|
104
|
+
const click = useClick(floating.context, {});
|
|
101
105
|
const role = useRole(floating.context, { role: roleName });
|
|
102
106
|
const dismiss = useDismiss(floating.context, {
|
|
103
107
|
escapeKey: true,
|
|
104
|
-
referencePress: true,
|
|
105
108
|
outsidePress: overlayClickClose,
|
|
106
109
|
});
|
|
107
110
|
const interactions = useInteractions([click, role, dismiss].concat(outInteractions));
|
|
@@ -109,7 +112,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
109
112
|
const floatingSize = useMotionValue(undefined);
|
|
110
113
|
useEffect(() => {
|
|
111
114
|
floatingSize.set(undefined);
|
|
112
|
-
}, [
|
|
115
|
+
}, [type]);
|
|
113
116
|
const onClose = () => onChange(false);
|
|
114
117
|
useImperativeHandle(externalRef, () => {
|
|
115
118
|
return { context: floating.context, floating: removeScrollRef.current };
|
|
@@ -139,10 +142,10 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
139
142
|
};
|
|
140
143
|
const animationProps = animated && type === "sheet"
|
|
141
144
|
? {
|
|
145
|
+
...commonAnimated,
|
|
142
146
|
dragElastic: 0,
|
|
143
147
|
onDrag: onDrag,
|
|
144
148
|
dragConstraints,
|
|
145
|
-
...commonAnimated,
|
|
146
149
|
dragListener: true,
|
|
147
150
|
dragMomentum: true,
|
|
148
151
|
dragPropagation: true,
|
|
@@ -152,7 +155,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
152
155
|
drag: type === "sheet" ? "y" : "x",
|
|
153
156
|
}
|
|
154
157
|
: commonAnimated;
|
|
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, {
|
|
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, mode: "wait", initial: false, children: open ? (_jsx(FloatingOverlay, { lockScroll: true, className: css("inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70", type === "drawer" ? "" : "flex items-start justify-center p-10", overlayClassName), children: _jsx(FloatingFocusManager, { guards: true, visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: floating.context, children: _jsxs(motion.div, { ...props, ...animationProps, ...(title
|
|
156
159
|
? {
|
|
157
160
|
"aria-labelledby": headingId,
|
|
158
161
|
"aria-describedby": descriptionId,
|
|
@@ -164,5 +167,5 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
164
167
|
position,
|
|
165
168
|
type,
|
|
166
169
|
}), className, "overscroll-contain"),
|
|
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
|
|
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: "select-text border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", 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: "w-full select-text border-t border-floating-border px-8 pt-4", children: footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null] }) }) })) : null }, headingId) })] }));
|
|
168
171
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAA2B,cAAc,EAAoD,MAAM,OAAO,CAAC;AAMzH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAS3F,K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MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG;IACrH,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CACP,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;CAChD,CACJ,CAAC;AASF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,4CA8GxD,CAAC"}
|
|
@@ -21,14 +21,14 @@ const useTable = () => useContext(TableContext);
|
|
|
21
21
|
const TableBody = React.forwardRef(({ context, className = "", ...props }, ref) => {
|
|
22
22
|
return (_jsx("tbody", { ...props, role: "rowgroup", className: `divide-y divide-table-border ${className}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) }));
|
|
23
23
|
});
|
|
24
|
-
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-fixed border-separate text-left ${className ?? ""}` })));
|
|
24
|
+
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-fixed border-spacing-0 border-separate text-left ${className ?? ""}` })));
|
|
25
25
|
const Thead = React.forwardRef(({ context, ...props }, ref) => {
|
|
26
26
|
const ctx = useTable();
|
|
27
27
|
const style = {
|
|
28
28
|
...props?.style,
|
|
29
29
|
top: Is.number(ctx.sticky) ? `${ctx.sticky}px` : undefined,
|
|
30
30
|
};
|
|
31
|
-
return (_jsx("thead", { ...props, style: style, role: "rowgroup", className: "hidden top-0 bg-transparent md:table-header-group shadow-shadow-card group:sticky"
|
|
31
|
+
return (_jsx("thead", { ...props, ref: ref, style: style, role: "rowgroup", className: "hidden top-0 bg-transparent md:table-header-group shadow-shadow-card group:sticky" }));
|
|
32
32
|
});
|
|
33
33
|
const TRow = React.forwardRef(({ context, item, ...props }, ref) => {
|
|
34
34
|
return (_jsx("tr", { ...props, role: "row", ref: ref, className: `group-table-row flex h-fit flex-col flex-wrap justify-center gap-1 md:table-row ${props?.className ?? ""}` }));
|
|
@@ -87,7 +87,7 @@ const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, o
|
|
|
87
87
|
}, [loadingMoreRef, onScrollEndRef]);
|
|
88
88
|
const empty = rows.length === 0;
|
|
89
89
|
const context = { loading: props.loading, loadingMore: props.loadingMore, cols: cols, Aside: props.Aside };
|
|
90
|
-
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group w-full relative rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { context: context, components: components, totalCount: rows.length,
|
|
90
|
+
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group h-full w-full relative rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { context: context, components: components, totalCount: rows.length, itemContent: empty ? EmptyCell : Row, data: empty ? emptyRows : rows, useWindowScroll: getScrollRef ? false : true, fixedFooterContent: showLoadingFooter ? Frag : null, customScrollParent: getScrollRef ? getScrollRef() : undefined, fixedHeaderContent: () => (_jsx(TableHeader, { headers: cols, filters: filters, setCols: setCols, sorters: sorters, setFilters: setFilters, setSorters: setSorters, loading: !!props.loading, inlineFilter: props.inlineFilter, inlineSorter: props.inlineSorter })) }), empty ? _jsx(EmptyContent, { loading: props.loading }) : null, _jsx("div", { "aria-hidden": "true", ref: ref, className: "w-full h-0.5" })] }), pagination !== null ? _jsx(Pagination, { ...pagination }) : null] }));
|
|
91
91
|
};
|
|
92
92
|
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
93
93
|
const compareAndExec = (prev, state, exec) => (prev === state ? undefined : exec?.(state));
|
|
@@ -27,9 +27,7 @@ const RowAside = (props) => {
|
|
|
27
27
|
observer.observe(child);
|
|
28
28
|
return () => observer.disconnect();
|
|
29
29
|
}, []);
|
|
30
|
-
return (_jsx("div", { ref: parentRef, onMouseEnter: onEnter, onMouseLeave: onLeave, "data-component": "cell-aside",
|
|
31
|
-
// inert={ariaHidden ? true : undefined}
|
|
32
|
-
tabIndex: ariaHidden ? -1 : undefined, className: `group-table-cell-aside absolute inset-0 top-0 flex h-full w-full min-w-8 max-w-20 items-stretch transition-opacity duration-300 ease-in-out ${className}`, children: _jsx("div", { ref: ref, className: "isolate block h-full w-auto", children: props.children }) }));
|
|
30
|
+
return (_jsx("div", { ref: parentRef, onMouseEnter: onEnter, onMouseLeave: onLeave, "data-component": "cell-aside", inert: ariaHidden ? true : undefined, tabIndex: ariaHidden ? -1 : undefined, className: `group-table-cell-aside absolute inset-0 top-0 flex h-full w-full items-stretch transition-opacity duration-300 ease-in-out ${className}`, children: _jsx("div", { ref: ref, className: "block isolate", children: props.children }) }));
|
|
33
31
|
};
|
|
34
32
|
export const Row = (index, row, context) => {
|
|
35
33
|
const cols = context.cols;
|
|
@@ -43,7 +41,7 @@ export const Row = (index, row, context) => {
|
|
|
43
41
|
const Aside = context.Aside;
|
|
44
42
|
return (_createElement("td", { ...col.cellProps, role: "cell", "data-matrix": matrix, key: `accessor-${index}-${colIndex}`, className: `group-table-cell py-2 sm:py-2 flex flex-col md:table-cell md:h-14 md:border-l md:border-table-border px-2 first:border-transparent ${className}` },
|
|
45
43
|
exposeAside ? (_jsx(RowAside, { children: _jsx(Aside, { col: col, row: row, rowIndex: index }) })) : null,
|
|
46
|
-
_jsx("span", { className: "block
|
|
44
|
+
_jsx("span", { className: "block text-sm font-bold leading-tight md:hidden", children: col.thead }),
|
|
47
45
|
_jsx("span", { className: "relative", children: loading ? (SkeletonCell) : Component ? (_jsx(Fragment, { children: _jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value }) })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value })) })));
|
|
48
46
|
}) }));
|
|
49
47
|
};
|
|
@@ -48,7 +48,9 @@ type ColOptions<T extends POJO, K extends AllPaths<T>> = Partial<{
|
|
|
48
48
|
cellProps: React.HTMLAttributes<HTMLTableCellElement>;
|
|
49
49
|
}>;
|
|
50
50
|
export type ColConstructor<T extends POJO> = {
|
|
51
|
+
getAll: () => Col<T>[];
|
|
51
52
|
remove: <K extends AllPaths<T>>(id: K) => void;
|
|
53
|
+
filter: (c: (c: Col<T>) => boolean) => Col<T>[];
|
|
52
54
|
add: <K extends AllPaths<T>>(id: K, thead: THead, props?: ColOptions<T, K>) => void;
|
|
53
55
|
};
|
|
54
56
|
declare const cols: <T extends POJO>() => <K extends AllPaths<T>>(id: K, thead: THead, options: ColOptions<T, K>) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-lib.d.ts","sourceRoot":"","sources":["../../../src/components/table/table-lib.ts"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,QAAQ,GAAI,CAAC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Text"] = "text";
|
|
18
18
|
})(ColType || (ColType = {}));
|
|
19
19
|
export const valueFromType = (input) => (input.type === "number" ? input.valueAsNumber : input.value);
|
|
20
|
+
;
|
|
20
21
|
const cols = () => (id, thead, options) => ({ ...options, id, thead });
|
|
21
22
|
export const createColumns = (callback) => {
|
|
22
23
|
let items = [];
|
|
23
24
|
const add = (id, thead, options) => items.push({ ...options, id, thead });
|
|
24
25
|
const remove = (id) => (items = items.filter((x) => x.id !== id));
|
|
25
|
-
|
|
26
|
+
const getAll = () => Array.from(items);
|
|
27
|
+
const filter = (c) => (items = Array.from(items.filter(c)));
|
|
28
|
+
callback({ add, remove, getAll, filter });
|
|
26
29
|
return items;
|
|
27
30
|
};
|
|
28
31
|
const noop = {};
|
|
@@ -70,7 +73,7 @@ export const useWidthControl = (reorder) => {
|
|
|
70
73
|
const onChange = useCallback((cols) => {
|
|
71
74
|
stableRef.current(cols);
|
|
72
75
|
cols.forEach((x) => {
|
|
73
|
-
const c = ref.current.querySelector(`th[data-
|
|
76
|
+
const c = ref.current.querySelector(`th[data-tableheader="${x.id}"]`);
|
|
74
77
|
if (!c)
|
|
75
78
|
return;
|
|
76
79
|
c.style.width = "auto";
|
|
@@ -42,7 +42,7 @@ const HeaderChild = (props) => {
|
|
|
42
42
|
const ownSorter = props.sorters.find((x) => props.header.id === x.value);
|
|
43
43
|
const ariaSort = !ownSorter?.type ? "none" : ownSorter.type === Order.Asc ? "ascending" : "descending";
|
|
44
44
|
const label = getLabel(props.header);
|
|
45
|
-
return (_jsxs(Reorder.Item, { ...props.header.thProps, as: "th", ref: dragRef, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, role: "columnheader", "aria-sort": ariaSort, value: props.header, "aria-busy": props.loading, "data-
|
|
45
|
+
return (_jsxs(Reorder.Item, { ...props.header.thProps, as: "th", ref: dragRef, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, role: "columnheader", "aria-sort": ariaSort, value: props.header, "aria-busy": props.loading, "data-tableheader": props.header.id, whileDrag: { cursor: "grabbing" }, className: `relative min-w-0 cursor-grab font-medium ${props.header.thProps?.className ?? ""}`, children: [_jsx("span", { className: `flex h-full items-center justify-between bg-table-header px-2 py-4 ${props.isLast ? "rounded-tr-lg" : ""} ${props.index === 0 ? "rounded-tl-lg" : ""}`, children: _jsxs("span", { className: "flex gap-1 items-center", children: [props.inlineFilter && defaultAllowFilter ? (_jsx(Dropdown, { arrow: true, trigger: _jsxs("span", { children: [_jsxs("span", { id: `${props.header.id}-filter-dropdown-button`, className: "sr-only", children: [translation.tableFilterDropdownTitleUnique, " ", label] }), _jsx(FilterIcon, { "aria-labelledby": `${props.header.id}-filter-dropdown-button`, size: 14 })] }), title: _jsxs("span", { className: "text-lg", children: [translation.tableFilterDropdownTitleUnique, " ", _jsx("span", { className: "font-medium", children: label })] }), children: _jsxs("ul", { className: "font-medium", children: [ownFilters.length === 0 ? null : (_jsx(Fragment, { children: ownFilters.map((filter) => (_jsx("li", { className: "my-1", children: _jsx(ColumnHeaderFilter, { onDelete: onDelete, filter: filter, set: props.setFilters }) }, `thead-filter-${filter.id}`))) })), _jsx("li", { children: _jsxs("button", { type: "button", className: "flex gap-1 items-center text-primary", onClick: () => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header, operators.options, operators.operations))), children: [_jsx(PlusIcon, { size: 14 }), " ", translation.tableFilterNewFilter] }) })] }) })) : null, _jsx("span", { className: "text-base pointer-events-auto text-balance", children: props.header.thead }), props.inlineSorter && defaultAllowSort ? (_jsx(SorterHead, { col: props.header, setSorters: props.setSorters, sorters: props.sorters })) : null] }) }), props.isLast ? null : (_jsx(motion.button, { drag: "x", draggable: true, dragListener: true, dragMomentum: true, type: "button", animate: false, dragElastic: 0, dragPropagation: true, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, "data-type": "resizer", title: props.header.id, dragConstraints: dragConstraints, className: "block absolute top-0 h-full hover:w-1.5 active:w-1.5 -right-[0.5px] z-calendar w-[1px] cursor-col-resize bg-table-border hover:bg-primary active:bg-primary", onClick: (e) => void e.currentTarget.focus(), onKeyDown: (e) => {
|
|
46
46
|
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
47
47
|
if (th.current === null)
|
|
48
48
|
return;
|
|
@@ -67,5 +67,5 @@ const HeaderChild = (props) => {
|
|
|
67
67
|
};
|
|
68
68
|
export const TableHeader = (props) => {
|
|
69
69
|
const [ref, onChange] = useWidthControl(props.setCols);
|
|
70
|
-
return (_jsx(Reorder.Group, { layout: true, as: "tr", axis: "x", drag: "x", layoutRoot: true, role: "row", layoutScroll: true,
|
|
70
|
+
return (_jsx(Reorder.Group, { layout: true, as: "tr", axis: "x", drag: "x", ref: ref, layoutRoot: true, role: "row", layoutScroll: true, onReorder: onChange, values: props.headers, children: _jsx(AnimatePresence, { children: props.headers.map((header, index) => (_jsx(HeaderChild, { index: index, header: header, filters: props.filters, loading: props.loading, sorters: props.sorters, setFilters: props.setFilters, setSorters: props.setSorters, inlineFilter: props.inlineFilter, inlineSorter: props.inlineSorter, isLast: index === props.headers.length - 1 }, `header-child-item-${header.id}`))) }) }));
|
|
71
71
|
};
|
package/dist/flow/flow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/flow/flow.tsx"],"names":[],"mappings":"AACA,OAAO,EAQH,KAAK,IAAI,EAQZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAS,MAAM,cAAc,CAAC;AAClD,OAAO,KAAiH,MAAM,OAAO,CAAC;AAGtI,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,aAAa,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,KAAK,CA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AAI,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AA4C5F,KAAK,KAAK,CAAC,CAAC,SAAS,IAAI,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CACtC,CAAC;AAyJF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,IAAI,GAAG,IAAI,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,4CAM1D,CAAC"}
|
package/dist/flow/flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { addEdge, Background, Controls, Handle,
|
|
3
|
+
import { addEdge, Background, Controls, Handle, Position, ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, } from "@xyflow/react";
|
|
4
4
|
import { XIcon } from "lucide-react";
|
|
5
5
|
import { createContext, Fragment, memo, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { css } from "../lib/dom";
|
|
@@ -20,18 +20,18 @@ const Sidebar = (props) => {
|
|
|
20
20
|
setType(nodeType);
|
|
21
21
|
event.dataTransfer.effectAllowed = "move";
|
|
22
22
|
};
|
|
23
|
-
return (_jsx("aside", { className: "absolute top-0 right-0 p-2 rounded-lg border shadow min-w-24 border-floating-border bg-background", children: _jsx("ul", { className: "space-y-2", children: props.items.map((item) => (_jsxs("li", { draggable: true, className: "flex gap-1.5 items-center text-lg hover:cursor-grab hover:text-primary",
|
|
23
|
+
return (_jsx("aside", { className: "absolute top-0 right-0 p-2 rounded-lg border shadow min-w-24 border-floating-border bg-card-background shadow-lg", children: _jsx("ul", { className: "space-y-2", children: props.items.map((item) => (_jsxs("li", { draggable: true, onDragStart: (event) => onDragStart(event, item), className: "flex gap-1.5 items-center text-lg hover:cursor-grab hover:text-primary", children: [item.Icon ? _jsx(item.Icon, { size: 16 }) : null, item.title] }, `${item.id}-flow-side-item`))) }) }));
|
|
24
24
|
};
|
|
25
25
|
const Handlers = (props) => {
|
|
26
|
-
return (_jsxs(Fragment, { children: [_jsx(Handle, { id: `${props.id}-handle-top`, type:
|
|
26
|
+
return (_jsxs(Fragment, { children: [_jsx(Handle, { id: `${props.id}-handle-top`, type: "source", position: Position.Top, className: "h-0.5 w-10 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-left`, type: "source", position: Position.Left, className: "h-4 w-0.5 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-right`, type: "source", position: Position.Right, className: "h-4 w-0.5 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-bottom`, type: "source", position: Position.Bottom, className: "h-0.5 w-10 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-top`, type: "target", position: Position.Top, className: "h-0.5 w-10 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-left`, type: "target", position: Position.Left, className: "h-4 w-0.5 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-right`, type: "target", position: Position.Right, className: "h-4 w-0.5 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-bottom`, type: "target", position: Position.Bottom, className: "h-0.5 w-10 !bg-primary" })] }));
|
|
27
27
|
};
|
|
28
28
|
const Input = memo((node) => {
|
|
29
|
-
return (_jsxs("div", { className: css("relative flex border min-h-10 min-w-24 items-center justify-center rounded-lg bg-floating-background px-4 py-2 shadow-shadow-floating", node.selected ? "border-primary" : "", "border-floating-border"), children: [_jsx(Handlers, { id: node.data.id
|
|
29
|
+
return (_jsxs("div", { className: css("relative flex border min-h-10 min-w-24 items-center justify-center rounded-lg bg-floating-background px-4 py-2 shadow-shadow-floating", node.selected ? "border-primary" : "", "border-floating-border"), children: [_jsx(Handlers, { id: node.data.id }), node.data.Item ? _jsx(node.data.Item, { ...node }) : _jsx("h3", { className: "text-center", children: node.data.title })] }));
|
|
30
30
|
});
|
|
31
31
|
const Connection = memo((node) => {
|
|
32
32
|
const { deleteElements } = useReactFlow();
|
|
33
33
|
const onClick = () => deleteElements({ nodes: [node] }).then(noop);
|
|
34
|
-
return (_jsxs("div", { className: css("relative border flex min-h-10 min-w-24 items-center justify-center rounded-lg bg-floating-background px-4 py-2 shadow-shadow-floating", node.selected ? "border-primary" : "border-muted", "border-floating-border"), children: [_jsx("button", { className: "flex absolute top-2 right-2 justify-center items-center text-foreground hover:text-danger active:text-danger", onClick: onClick, children: _jsx(XIcon, { size: 18 }) }), _jsx(Handlers, { id: node.data.id
|
|
34
|
+
return (_jsxs("div", { className: css("relative border flex min-h-10 min-w-24 items-center justify-center rounded-lg bg-floating-background px-4 py-2 shadow-shadow-floating", node.selected ? "border-primary" : "border-muted", "border-floating-border"), children: [_jsx("button", { className: "flex absolute top-2 right-2 justify-center items-center text-foreground hover:text-danger active:text-danger", onClick: onClick, children: _jsx(XIcon, { size: 18 }) }), _jsx(Handlers, { id: node.data.id }), node.data.Item ? _jsx(node.data.Item, { ...node }) : _jsx("h3", { className: "text-center", children: node.data.title })] }));
|
|
35
35
|
});
|
|
36
36
|
const nodeTypes = { input: Input, output: Connection };
|
|
37
37
|
const AddNodeOnEdgeDrop = (props) => {
|
|
@@ -43,9 +43,11 @@ const AddNodeOnEdgeDrop = (props) => {
|
|
|
43
43
|
const { screenToFlowPosition } = useReactFlow();
|
|
44
44
|
useEffect(() => {
|
|
45
45
|
props.onChange(nodes);
|
|
46
|
-
}, [nodes.length]);
|
|
46
|
+
}, [nodes.length, edges.length]);
|
|
47
47
|
const onConnect = useCallback((params) => {
|
|
48
|
-
setEdges((eds) => addEdge({
|
|
48
|
+
setEdges((eds) => addEdge({
|
|
49
|
+
...params, animated: true, deletable: true, reconnectable: true,
|
|
50
|
+
}, eds));
|
|
49
51
|
}, [setEdges]);
|
|
50
52
|
const onDragOver = useCallback((event) => {
|
|
51
53
|
event.preventDefault();
|
|
@@ -70,6 +72,6 @@ const AddNodeOnEdgeDrop = (props) => {
|
|
|
70
72
|
event.dataTransfer.setData("text/plain", JSON.stringify(nodeType));
|
|
71
73
|
event.dataTransfer.effectAllowed = "move";
|
|
72
74
|
};
|
|
73
|
-
return (_jsxs("div", { className: "relative w-full bg-card-background", style: { height: 1000 }, ref: reactFlowWrapper, children: [_jsxs(ReactFlow, { fitView: true, ref: ref, edges: edges, nodes: nodes, onDrop: onDrop, nodeOrigin: [0, 0], onConnect: onConnect, onDragOver: onDragOver, className: "bg-
|
|
75
|
+
return (_jsxs("div", { className: "relative w-full bg-card-background", style: { height: 1000 }, ref: reactFlowWrapper, children: [_jsxs(ReactFlow, { fitView: true, ref: ref, edges: edges, nodes: nodes, onDrop: onDrop, nodeOrigin: [0, 0], onConnect: onConnect, onDragOver: onDragOver, className: "bg-transparent", nodeTypes: nodeTypes, onEdgesChange: onEdgesChange, onNodesChange: onNodesChange, attributionPosition: "bottom-left", fitViewOptions: { padding: 2 }, onDragStart: onDragStart, colorMode: props.theme ?? "dark", children: [_jsx(Controls, {}), _jsx(Background, { bgColor: "hsla(var(--floating-background))" })] }), _jsx(Sidebar, { items: props.parents })] }));
|
|
74
76
|
};
|
|
75
77
|
export const Flow = (props) => (_jsx(ReactFlowProvider, { fitView: true, initialMaxZoom: 1, children: _jsx(DnDProvider, { children: _jsx(AddNodeOnEdgeDrop, { ...props }) }) }));
|