@g4rcez/components 2.0.5 → 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.
@@ -12,6 +12,7 @@ declare const variants: {
12
12
  default: string;
13
13
  min: string;
14
14
  small: string;
15
+ tiny: string;
15
16
  };
16
17
  rounded: {
17
18
  rough: string;
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCb,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"}
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"}
@@ -14,6 +14,7 @@ const variants = {
14
14
  default: "h-10 px-4 py-2",
15
15
  min: "h-7 px-3 py-1 text-sm",
16
16
  small: "h-8 px-4 py-2 text-sm",
17
+ tiny: "h-6 px-2 py-1 text-sm",
17
18
  },
18
19
  rounded: {
19
20
  rough: "rounded-sm",
@@ -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-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
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;AA2DhC,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,4CAoEvE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,4CAA0C,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.2 }, children: _jsxs(AnimatePresence, { presenceAffectsLayout: true, children: [_jsx(AnimatePresence, { children: item ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "pointer-events-none fixed inset-0 top-0 z-floating h-screen w-screen bg-floating-overlay/70" })) : null }), _jsx(AnimatePresence, { children: item ? (_jsx(FloatingOverlay, { lockScroll: true, className: "absolute inset-0 z-tooltip 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 })] }) }) }));
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:scale-105 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));
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 });
@@ -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/react-slot";
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":"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,yGAoWxB,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
- setValue(item?.label ?? props.value);
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
- setLabel(opt.label ?? "");
143
- setClosed();
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
- setShadow(value);
165
+ dispatch.shadow(value);
150
166
  if (!open && value === "")
151
- return setOpen(true);
167
+ return dispatch.open(true);
152
168
  event.target.name = props.name || "";
153
- return value ? setOpen(true) : props.onChange?.(event);
169
+ return value ? dispatch.open(true) : props.onChange?.(event);
154
170
  };
155
171
  const onCaretDownClick = () => {
156
- setOpen(true);
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
- setShadow("");
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 setIndex(next);
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 setIndex(next);
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-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : 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({
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 { type SliderProps as RadixSliderProps } from "@radix-ui/react-slider";
2
- type SliderProps = RadixSliderProps & {
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":"AAEA,OAAO,EAAE,KAAK,WAAW,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO9E,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAmCF,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,4CAoBxC,CAAC"}
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":"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,gBAAgB,CAAC;AAC/B,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"}
@@ -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";
@@ -17,6 +17,7 @@ export var ColType;
17
17
  ColType["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 = [];
@@ -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,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,QAAQ,CAAC,IAAI,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;AAoJF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,IAAI,GAAG,IAAI,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,4CAM1D,CAAC"}
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,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,QAAQ,CAAC,IAAI,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, MarkerType, MiniMap, Position, ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, } from "@xyflow/react";
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", onDragStart: (event) => onDragStart(event, item), children: [item.Icon ? _jsx(item.Icon, { size: 16 }) : null, item.title] }, `${item.id}-flow-side-item`))) }) }));
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: props.type, position: Position.Top, className: "h-1 w-10 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-left`, type: props.type, position: Position.Left, className: "h-4 w-1 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-right`, type: props.type, position: Position.Right, className: "h-4 w-1 !bg-primary" }), _jsx(Handle, { id: `${props.id}-handle-bottom`, type: props.type, position: Position.Bottom, className: "h-1 w-10 !bg-primary" })] }));
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, type: "source" }), node.data.Item ? _jsx(node.data.Item, { ...node }) : _jsx("h3", { className: "text-center", children: node.data.title })] }));
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, type: "target" }), node.data.Item ? _jsx(node.data.Item, { ...node }) : _jsx("h3", { className: "text-center", children: node.data.title })] }));
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({ ...params, animated: true, markerEnd: { type: MarkerType.Arrow } }, eds));
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-background", nodeTypes: nodeTypes, onEdgesChange: onEdgesChange, onNodesChange: onNodesChange, attributionPosition: "top-right", fitViewOptions: { padding: 2 }, onDragStart: onDragStart, colorMode: props.theme ?? "dark", children: [_jsx(MiniMap, {}), _jsx(Background, { bgColor: "hsla(var(--floating-background))" }), _jsx(Controls, {})] }), _jsx(Sidebar, { items: props.parents })] }));
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 }) }) }));