@reactloom/dnd 0.0.0-stage → 1.0.1

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/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @reactloom/dnd
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ React components for reordering a list or responsive grid and transferring items between two lists.
4
+
5
+ ```tsx
6
+ import '@reactloom/theme/theme.css';
7
+ import '@reactloom/dnd/styles.css';
8
+ import { SortableList } from '@reactloom/dnd';
9
+
10
+ <SortableList label="Approval steps" items={steps} onChange={setSteps} />;
11
+ ```
12
+
13
+ Each item needs a stable string `id` and a string `label`. Sortable components accept a
14
+ controlled array and emit it in the new order. TransferList takes all items and the IDs
15
+ of the destination list. Update the controlled prop to commit the change. Import the
16
+ stylesheet once and wrap the components in your existing ReactLoom theme scope.
17
+
18
+ Drag a handle with a mouse, or focus it and press Enter or Space to begin keyboard drag. Use Tab to
19
+ choose a destination, Enter to drop, and Escape to cancel. Direct move buttons are available
20
+ for each item, including on touch devices. Use `messages` to translate the component’s labels and
21
+ announcements and `LocaleProvider` from `@reactloom/ui` for the underlying React Aria drag instructions.
22
+ Each instance owns its drop targets, so a drag cannot transfer items to an unrelated list.
23
+
24
+
25
+ `KanbanBoard` displays cards in named workflow columns. Drag to reorder or
26
+ transfer cards, use the column selector to move directly, or use the step
27
+ buttons to reorder within the current column. Keep the cards in your application
28
+ and apply the array emitted by `onChange` to commit the new order.
29
+
30
+ Documentation and live examples: <https://www.reactloom.dev/components/sortable> ·
31
+ <https://www.reactloom.dev/components/kanban-board> · <https://www.reactloom.dev/components/flow-canvas>
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ReactLoom UI contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ import { useCallback, useState } from "react";
2
+ // ../hooks/src/use-controllable-state.ts
3
+ /**
4
+ * State that can be controlled (`value` defined) or uncontrolled (`defaultValue`).
5
+ * `onChange` fires on every requested change in both modes; no-op changes are ignored.
6
+ */
7
+ function useControllableState(params) {
8
+ const { value, defaultValue, onChange } = params;
9
+ const [internal, setInternal] = useState(defaultValue);
10
+ const controlled = value !== void 0;
11
+ const current = controlled ? value : internal;
12
+ return [current, useCallback((next) => {
13
+ if (Object.is(next, current)) return;
14
+ if (!controlled) setInternal(next);
15
+ onChange?.(next);
16
+ }, [
17
+ controlled,
18
+ current,
19
+ onChange
20
+ ])];
21
+ }
22
+ export { useControllableState };
23
+
24
+ //# sourceMappingURL=use-controllable-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-controllable-state.js","names":[],"sources":["../../../../hooks/src/use-controllable-state.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\n/**\n * State that can be controlled (`value` defined) or uncontrolled (`defaultValue`).\n * `onChange` fires on every requested change in both modes; no-op changes are ignored.\n */\nexport function useControllableState<T>(params: {\n value: T | undefined;\n defaultValue: T;\n onChange?: ((value: T) => void) | undefined;\n}): [T, (next: T) => void] {\n const { value, defaultValue, onChange } = params;\n const [internal, setInternal] = useState(defaultValue);\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n\n const setValue = useCallback(\n (next: T) => {\n if (Object.is(next, current)) return;\n if (!controlled) setInternal(next);\n onChange?.(next);\n },\n [controlled, current, onChange],\n );\n\n return [current, setValue];\n}\n"],"mappings":";;;;;;AAMA,SAAgB,qBAAwB,QAIb;CACzB,MAAM,EAAE,OAAO,cAAc,aAAa;CAC1C,MAAM,CAAC,UAAU,eAAe,SAAS,YAAY;CACrD,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,UAAU,aAAa,QAAQ;CAWrC,OAAO,CAAC,SATS,aACd,SAAY;EACX,IAAI,OAAO,GAAG,MAAM,OAAO,GAAG;EAC9B,IAAI,CAAC,YAAY,YAAY,IAAI;EACjC,WAAW,IAAI;CACjB,GACA;EAAC;EAAY;EAAS;CAAQ,CAGf,CAAQ;AAC3B"}
@@ -0,0 +1,7 @@
1
+ import { useEffect, useLayoutEffect } from "react";
2
+ // ../hooks/src/use-isomorphic-layout-effect.ts
3
+ /** `useLayoutEffect` in the browser, `useEffect` on the server (avoids SSR warnings). */
4
+ var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
5
+ export { useIsomorphicLayoutEffect };
6
+
7
+ //# sourceMappingURL=use-isomorphic-layout-effect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-isomorphic-layout-effect.js","names":[],"sources":["../../../../hooks/src/use-isomorphic-layout-effect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server (avoids SSR warnings). */\nexport const useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect;\n"],"mappings":";;;AAGA,IAAa,4BAA4B,OAAO,aAAa,cAAc,kBAAkB"}
@@ -0,0 +1,30 @@
1
+ // src/dnd.module.css
2
+ var list = "pl-dnd-list-3C7zgf";
3
+ var grid = "pl-dnd-grid-3C7zgf";
4
+ var item = "pl-dnd-item-3C7zgf";
5
+ var content = "pl-dnd-content-3C7zgf";
6
+ var actions = "pl-dnd-actions-3C7zgf";
7
+ var handle = "pl-dnd-handle-3C7zgf";
8
+ var button = "pl-dnd-button-3C7zgf";
9
+ var side = "pl-dnd-side-3C7zgf";
10
+ var transfer = "pl-dnd-transfer-3C7zgf";
11
+ var sideLabel = "pl-dnd-side-label-3C7zgf";
12
+ var empty = "pl-dnd-empty-3C7zgf";
13
+ var status = "pl-dnd-status-3C7zgf";
14
+ var dnd_module_default = {
15
+ list,
16
+ grid,
17
+ item,
18
+ content,
19
+ actions,
20
+ handle,
21
+ button,
22
+ side,
23
+ transfer,
24
+ sideLabel,
25
+ empty,
26
+ status
27
+ };
28
+ export { actions, button, content, dnd_module_default as default, empty, grid, handle, item, list, side, sideLabel, status, transfer };
29
+
30
+ //# sourceMappingURL=dnd.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd.module.js","names":[],"sources":[],"mappings":""}
package/dist/drag.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { type RefObject } from 'react';
2
+ import { useDrop } from 'react-aria/useDrop';
3
+ export interface DragItem {
4
+ /** A stable, unique identifier within the collection. */
5
+ id: string;
6
+ label: string;
7
+ }
8
+ interface ActiveDrag {
9
+ id: string;
10
+ handle: HTMLButtonElement;
11
+ }
12
+ type DragScope = RefObject<ActiveDrag | null>;
13
+ export declare function useDragScope(): DragScope;
14
+ export declare function DragHandle({ scopeRef, item, label, disabled }: {
15
+ scopeRef: DragScope;
16
+ item: DragItem;
17
+ label: string;
18
+ disabled: boolean;
19
+ }): import("react").JSX.Element;
20
+ export declare function useItemDrop<E extends HTMLElement>(scopeRef: DragScope, canMove: (id: string) => boolean, move: (id: string, handle: HTMLButtonElement) => void, disabled: boolean): Pick<ReturnType<typeof useDrop>, 'dropProps' | 'isDropTarget'> & {
21
+ ref: RefObject<E | null>;
22
+ };
23
+ /** Restore focus only while it still belongs to the move that just committed. */
24
+ export declare function restoreMoveFocus(previous: Element | null, button?: HTMLElement): void;
25
+ export {};
26
+ //# sourceMappingURL=drag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.d.ts","sourceRoot":"","sources":["../src/drag.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AACD,KAAK,SAAS,GAAG,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;AAE9C,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC9D,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB,+BAoBA;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/C,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,EAChC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,EACrD,QAAQ,EAAE,OAAO,GAChB,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,GAAG;IAAE,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CAAE,CAmB/F;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,WAAW,QAI9E"}
package/dist/drag.js ADDED
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import dnd_module_default from "./dnd.module.js";
3
+ import { useRef } from "react";
4
+ import { useButton } from "react-aria/useButton";
5
+ import { useDrag } from "react-aria/useDrag";
6
+ import { useDrop } from "react-aria/useDrop";
7
+ import { jsx } from "react/jsx-runtime";
8
+ // src/drag.tsx
9
+ var TYPE = "application/x-reactloom-item";
10
+ function useDragScope() {
11
+ return useRef(null);
12
+ }
13
+ function DragHandle({ scopeRef, item, label, disabled }) {
14
+ const handleRef = useRef(null);
15
+ const { dragProps, dragButtonProps, isDragging } = useDrag({
16
+ hasDragButton: true,
17
+ isDisabled: disabled,
18
+ getItems: () => [{ [TYPE]: item.id }],
19
+ getAllowedDropOperations: () => ["move"],
20
+ onDragStart: () => {
21
+ if (handleRef.current) scopeRef.current = {
22
+ id: item.id,
23
+ handle: handleRef.current
24
+ };
25
+ },
26
+ onDragEnd: () => {
27
+ scopeRef.current = null;
28
+ }
29
+ });
30
+ const { buttonProps } = useButton({
31
+ ...dragButtonProps,
32
+ isDisabled: disabled,
33
+ "aria-label": label
34
+ }, handleRef);
35
+ return /* @__PURE__ */ jsx("button", {
36
+ ...buttonProps,
37
+ ...dragProps,
38
+ ref: handleRef,
39
+ className: dnd_module_default.handle,
40
+ "data-dragging": isDragging || void 0,
41
+ children: /* @__PURE__ */ jsx("span", {
42
+ "aria-hidden": "true",
43
+ children: "⠿"
44
+ })
45
+ });
46
+ }
47
+ function useItemDrop(scopeRef, canMove, move, disabled) {
48
+ const ref = useRef(null);
49
+ const { dropProps, isDropTarget } = useDrop({
50
+ ref,
51
+ isDisabled: disabled,
52
+ getDropOperation: (types, operations) => types.has(TYPE) && operations.includes("move") && scopeRef.current !== null && canMove(scopeRef.current.id) ? "move" : "cancel",
53
+ onDrop: ({ items, dropOperation }) => {
54
+ const drag = scopeRef.current;
55
+ if (dropOperation === "move" && drag && canMove(drag.id) && items.some((item) => item.kind === "text" && item.types.has(TYPE))) move(drag.id, drag.handle);
56
+ }
57
+ });
58
+ return {
59
+ ref,
60
+ dropProps,
61
+ isDropTarget
62
+ };
63
+ }
64
+ /** Restore focus only while it still belongs to the move that just committed. */
65
+ function restoreMoveFocus(previous, button) {
66
+ if (!button?.isConnected) return;
67
+ const { activeElement, body } = button.ownerDocument;
68
+ if (activeElement === previous || activeElement === body) button.focus();
69
+ }
70
+ export { DragHandle, restoreMoveFocus, useDragScope, useItemDrop };
71
+
72
+ //# sourceMappingURL=drag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.js","names":["styles"],"sources":["../src/drag.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, type RefObject } from 'react';\nimport { useButton } from 'react-aria/useButton';\nimport { useDrag } from 'react-aria/useDrag';\nimport { useDrop } from 'react-aria/useDrop';\nimport styles from './dnd.module.css';\n\nexport interface DragItem {\n /** A stable, unique identifier within the collection. */\n id: string;\n label: string;\n}\n\nconst TYPE = 'application/x-reactloom-item';\ninterface ActiveDrag {\n id: string;\n handle: HTMLButtonElement;\n}\ntype DragScope = RefObject<ActiveDrag | null>;\n\nexport function useDragScope(): DragScope {\n return useRef<ActiveDrag | null>(null);\n}\n\nexport function DragHandle({ scopeRef, item, label, disabled }: {\n scopeRef: DragScope;\n item: DragItem;\n label: string;\n disabled: boolean;\n}) {\n const handleRef = useRef<HTMLButtonElement>(null);\n const { dragProps, dragButtonProps, isDragging } = useDrag({\n hasDragButton: true,\n isDisabled: disabled,\n getItems: () => [{ [TYPE]: item.id }],\n getAllowedDropOperations: () => ['move'],\n onDragStart: () => {\n if (handleRef.current) scopeRef.current = { id: item.id, handle: handleRef.current };\n },\n onDragEnd: () => { scopeRef.current = null; },\n });\n const { buttonProps } = useButton({\n ...dragButtonProps, isDisabled: disabled, 'aria-label': label,\n }, handleRef);\n return (\n <button {...buttonProps} {...dragProps} ref={handleRef} className={styles.handle} data-dragging={isDragging || undefined}>\n <span aria-hidden=\"true\">⠿</span>\n </button>\n );\n}\n\nexport function useItemDrop<E extends HTMLElement>(\n scopeRef: DragScope,\n canMove: (id: string) => boolean,\n move: (id: string, handle: HTMLButtonElement) => void,\n disabled: boolean,\n): Pick<ReturnType<typeof useDrop>, 'dropProps' | 'isDropTarget'> & { ref: RefObject<E | null> } {\n const ref = useRef<E>(null);\n const { dropProps, isDropTarget } = useDrop({\n ref,\n isDisabled: disabled,\n getDropOperation: (types, operations) =>\n types.has(TYPE) && operations.includes('move') && scopeRef.current !== null && canMove(scopeRef.current.id)\n ? 'move'\n : 'cancel',\n onDrop: ({ items, dropOperation }) => {\n const drag = scopeRef.current;\n // The local scope also prevents drops from other instances or from outside this page.\n if (dropOperation === 'move' && drag && canMove(drag.id) &&\n items.some((item) => item.kind === 'text' && item.types.has(TYPE))) {\n move(drag.id, drag.handle);\n }\n },\n });\n return { ref, dropProps, isDropTarget };\n}\n\n/** Restore focus only while it still belongs to the move that just committed. */\nexport function restoreMoveFocus(previous: Element | null, button?: HTMLElement) {\n if (!button?.isConnected) return;\n const { activeElement, body } = button.ownerDocument;\n if (activeElement === previous || (activeElement === body)) button.focus();\n}\n"],"mappings":";;;;;;;;AAcA,IAAM,OAAO;AAOb,SAAgB,eAA0B;CACxC,OAAO,OAA0B,IAAI;AACvC;AAEA,SAAgB,WAAW,EAAE,UAAU,MAAM,OAAO,YAKjD;CACD,MAAM,YAAY,OAA0B,IAAI;CAChD,MAAM,EAAE,WAAW,iBAAiB,eAAe,QAAQ;EACzD,eAAe;EACf,YAAY;EACZ,gBAAgB,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC;EACpC,gCAAgC,CAAC,MAAM;EACvC,mBAAmB;GACjB,IAAI,UAAU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';
8
+ }
9
+ export interface FlowEdge {
10
+ id: string;
11
+ from: string;
12
+ to: string;
13
+ label?: string;
14
+ }
15
+ export interface FlowCanvasProps {
16
+ nodes?: readonly FlowNode[];
17
+ defaultNodes?: readonly FlowNode[];
18
+ onNodesChange?: (nodes: FlowNode[]) => void;
19
+ edges: readonly FlowEdge[];
20
+ onSelectNode?: (id: string | null) => void;
21
+ /** Accessible name of the workflow canvas. @default 'Workflow diagram' */
22
+ label?: string;
23
+ /** Canvas height in pixels. @default 380 */
24
+ height?: number;
25
+ readOnly?: boolean;
26
+ className?: string;
27
+ }
28
+ /**
29
+ * Interactive node-and-edge workflow canvas with pointer dragging, keyboard node positioning,
30
+ * zoom controls, and smooth SVG Bezier connectors.
31
+ */
32
+ export declare function FlowCanvas({ nodes: nodesProp, defaultNodes, onNodesChange, edges, onSelectNode, label, height, readOnly, className, }: FlowCanvasProps): import("react").JSX.Element;
33
+ //# sourceMappingURL=flow-canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-canvas.d.ts","sourceRoot":"","sources":["../src/flow-canvas.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;CACrD;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAC5C,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3C,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAiB,EACjB,aAAa,EACb,KAAK,EACL,YAAY,EACZ,KAA0B,EAC1B,MAAY,EACZ,QAAgB,EAChB,SAAS,GACV,EAAE,eAAe,+BAoIjB"}
@@ -0,0 +1,201 @@
1
+ "use client";
2
+ import { useControllableState } from "./_internal/hooks/use-controllable-state.js";
3
+ import flow_canvas_module_default from "./flow-canvas.module.js";
4
+ import { useRef, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/flow-canvas.tsx
7
+ var NODE_W = 164;
8
+ var NODE_H = 58;
9
+ /**
10
+ * Interactive node-and-edge workflow canvas with pointer dragging, keyboard node positioning,
11
+ * zoom controls, and smooth SVG Bezier connectors.
12
+ */
13
+ function FlowCanvas({ nodes: nodesProp, defaultNodes = [], onNodesChange, edges, onSelectNode, label = "Workflow diagram", height = 380, readOnly = false, className }) {
14
+ const [nodes, setNodes] = useControllableState({
15
+ value: nodesProp ? [...nodesProp] : void 0,
16
+ defaultValue: [...defaultNodes],
17
+ onChange: onNodesChange
18
+ });
19
+ const [selectedId, setSelectedId] = useState(null);
20
+ const [zoom, setZoom] = useState(1);
21
+ const dragRef = useRef(null);
22
+ const select = (id) => {
23
+ setSelectedId(id);
24
+ onSelectNode?.(id);
25
+ };
26
+ const moveNode = (id, dx, dy) => {
27
+ if (readOnly) return;
28
+ setNodes(nodes.map((n) => n.id === id ? {
29
+ ...n,
30
+ x: Math.max(8, Math.round(n.x + dx)),
31
+ y: Math.max(8, Math.round(n.y + dy))
32
+ } : n));
33
+ };
34
+ const byId = new Map(nodes.map((n) => [n.id, n]));
35
+ return /* @__PURE__ */ jsxs("div", {
36
+ className: [flow_canvas_module_default.root, className].filter(Boolean).join(" "),
37
+ children: [/* @__PURE__ */ jsxs("div", {
38
+ className: flow_canvas_module_default.toolbar,
39
+ children: [/* @__PURE__ */ jsx("span", {
40
+ className: flow_canvas_module_default.title,
41
+ children: label
42
+ }), /* @__PURE__ */ jsxs("div", {
43
+ className: flow_canvas_module_default.controls,
44
+ children: [
45
+ /* @__PURE__ */ jsx("button", {
46
+ type: "button",
47
+ className: flow_canvas_module_default.toolBtn,
48
+ "aria-label": "Zoom out",
49
+ onClick: () => setZoom((z) => Math.max(.5, Math.round((z - .1) * 10) / 10)),
50
+ children: "−"
51
+ }),
52
+ /* @__PURE__ */ jsxs("span", {
53
+ className: flow_canvas_module_default.zoomLabel,
54
+ "aria-live": "polite",
55
+ children: [Math.round(zoom * 100), "%"]
56
+ }),
57
+ /* @__PURE__ */ jsx("button", {
58
+ type: "button",
59
+ className: flow_canvas_module_default.toolBtn,
60
+ "aria-label": "Zoom in",
61
+ onClick: () => setZoom((z) => Math.min(1.6, Math.round((z + .1) * 10) / 10)),
62
+ children: "+"
63
+ }),
64
+ /* @__PURE__ */ jsx("button", {
65
+ type: "button",
66
+ className: flow_canvas_module_default.toolBtn,
67
+ onClick: () => setZoom(1),
68
+ children: "Reset"
69
+ })
70
+ ]
71
+ })]
72
+ }), /* @__PURE__ */ jsx("div", {
73
+ role: "region",
74
+ "aria-label": label,
75
+ className: flow_canvas_module_default.viewport,
76
+ style: { height },
77
+ onPointerDown: (e) => {
78
+ if (e.target === e.currentTarget) select(null);
79
+ },
80
+ children: /* @__PURE__ */ jsxs("div", {
81
+ className: flow_canvas_module_default.stage,
82
+ style: {
83
+ transform: `scale(${zoom})`,
84
+ transformOrigin: "0 0"
85
+ },
86
+ children: [/* @__PURE__ */ jsxs("svg", {
87
+ className: flow_canvas_module_default.edges,
88
+ "aria-hidden": "true",
89
+ children: [/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("marker", {
90
+ id: "rl-flow-arrow",
91
+ viewBox: "0 0 10 10",
92
+ refX: "8",
93
+ refY: "5",
94
+ markerWidth: "6",
95
+ markerHeight: "6",
96
+ orient: "auto-start-reverse",
97
+ children: /* @__PURE__ */ jsx("path", {
98
+ d: "M 0 1 L 10 5 L 0 9 z",
99
+ fill: "var(--pl-color-border-strong)"
100
+ })
101
+ }) }), edges.map((edge) => {
102
+ const a = byId.get(edge.from);
103
+ const b = byId.get(edge.to);
104
+ if (!a || !b) return null;
105
+ const x1 = a.x + NODE_W;
106
+ const y1 = a.y + NODE_H / 2;
107
+ const x2 = b.x;
108
+ const y2 = b.y + NODE_H / 2;
109
+ const cxOffset = Math.max(40, Math.abs(x2 - x1) * .45);
110
+ const d = `M ${x1} ${y1} C ${x1 + cxOffset} ${y1}, ${x2 - cxOffset} ${y2}, ${x2} ${y2}`;
111
+ const mx = (x1 + x2) / 2;
112
+ const my = (y1 + y2) / 2;
113
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("path", {
114
+ d,
115
+ className: flow_canvas_module_default.edgePath,
116
+ markerEnd: "url(#rl-flow-arrow)"
117
+ }), edge.label && /* @__PURE__ */ jsx("text", {
118
+ x: mx,
119
+ y: my - 6,
120
+ textAnchor: "middle",
121
+ className: flow_canvas_module_default.edgeLabel,
122
+ children: edge.label
123
+ })] }, edge.id);
124
+ })]
125
+ }), nodes.map((node) => {
126
+ const isSelected = selectedId === node.id;
127
+ return /* @__PURE__ */ jsxs("div", {
128
+ role: "button",
129
+ tabIndex: 0,
130
+ "aria-pressed": isSelected,
131
+ className: flow_canvas_module_default.node,
132
+ "data-selected": isSelected ? "" : void 0,
133
+ "data-tone": node.tone ?? "default",
134
+ style: {
135
+ transform: `translate(${node.x}px, ${node.y}px)`,
136
+ width: NODE_W,
137
+ minHeight: NODE_H
138
+ },
139
+ onClick: (e) => {
140
+ e.stopPropagation();
141
+ select(node.id);
142
+ },
143
+ onPointerDown: (e) => {
144
+ if (readOnly) return;
145
+ e.stopPropagation();
146
+ select(node.id);
147
+ e.currentTarget.setPointerCapture?.(e.pointerId);
148
+ dragRef.current = {
149
+ id: node.id,
150
+ startX: e.clientX,
151
+ startY: e.clientY,
152
+ origX: node.x,
153
+ origY: node.y
154
+ };
155
+ },
156
+ onPointerMove: (e) => {
157
+ const d = dragRef.current;
158
+ if (!d || d.id !== node.id) return;
159
+ const nx = Math.max(8, Math.round(d.origX + (e.clientX - d.startX) / zoom));
160
+ const ny = Math.max(8, Math.round(d.origY + (e.clientY - d.startY) / zoom));
161
+ setNodes(nodes.map((n) => n.id === node.id ? {
162
+ ...n,
163
+ x: nx,
164
+ y: ny
165
+ } : n));
166
+ },
167
+ onPointerUp: () => {
168
+ dragRef.current = null;
169
+ },
170
+ onKeyDown: (e) => {
171
+ const step = e.shiftKey ? 48 : 16;
172
+ if (e.key === "ArrowRight") {
173
+ e.preventDefault();
174
+ moveNode(node.id, step, 0);
175
+ } else if (e.key === "ArrowLeft") {
176
+ e.preventDefault();
177
+ moveNode(node.id, -step, 0);
178
+ } else if (e.key === "ArrowDown") {
179
+ e.preventDefault();
180
+ moveNode(node.id, 0, step);
181
+ } else if (e.key === "ArrowUp") {
182
+ e.preventDefault();
183
+ moveNode(node.id, 0, -step);
184
+ }
185
+ },
186
+ children: [/* @__PURE__ */ jsx("span", {
187
+ className: flow_canvas_module_default.nodeTitle,
188
+ children: node.label
189
+ }), node.description && /* @__PURE__ */ jsx("span", {
190
+ className: flow_canvas_module_default.nodeDesc,
191
+ children: node.description
192
+ })]
193
+ }, node.id);
194
+ })]
195
+ })
196
+ })]
197
+ });
198
+ }
199
+ export { FlowCanvas };
200
+
201
+ //# sourceMappingURL=flow-canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-canvas.js","names":["styles"],"sources":["../src/flow-canvas.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useState } from 'react';\nimport { useControllableState } from '@reactloom/hooks';\nimport styles from './flow-canvas.module.css';\n\nexport interface FlowNode {\n id: string;\n label: string;\n description?: string;\n x: number;\n y: number;\n tone?: 'default' | 'accent' | 'success' | 'warning';\n}\n\nexport interface FlowEdge {\n id: string;\n from: string;\n to: string;\n label?: string;\n}\n\nexport interface FlowCanvasProps {\n nodes?: readonly FlowNode[];\n defaultNodes?: readonly FlowNode[];\n onNodesChange?: (nodes: FlowNode[]) => void;\n edges: readonly FlowEdge[];\n onSelectNode?: (id: string | null) => void;\n /** Accessible name of the workflow canvas. @default 'Workflow diagram' */\n label?: string;\n /** Canvas height in pixels. @default 380 */\n height?: number;\n readOnly?: boolean;\n className?: string;\n}\n\nconst NODE_W = 164;\nconst NODE_H = 58;\n\n/**\n * Interactive node-and-edge workflow canvas with pointer dragging, keyboard node positioning,\n * zoom controls, and smooth SVG Bezier connectors.\n */\nexport function FlowCanvas({\n nodes: nodesProp,\n defaultNodes = [],\n onNodesChange,\n edges,\n onSelectNode,\n label = 'Workflow diagram',\n height = 380,\n readOnly = false,\n className,\n}: FlowCanvasProps) {\n const [nodes, setNodes] = useControllableState<FlowNode[]>({\n value: nodesProp ? [...nodesProp] : undefined,\n defaultValue: [...defaultNodes],\n onChange: onNodesChange,\n });\n const [selectedId, setSelectedId] = useState<string | null>(null);\n const [zoom, setZoom] = useState(1);\n const dragRef = useRef<{ id: string; startX: number; startY: number; origX: number; origY: number } | null>(null);\n\n const select = (id: string | null) => {\n setSelectedId(id);\n onSelectNode?.(id);\n };\n\n const moveNode = (id: string, dx: number, dy: number) => {\n if (readOnly) return;\n setNodes(nodes.map((n) => (n.id === id ? { ...n, x: Math.max(8, Math.round(n.x + dx)), y: Math.max(8, Math.round(n.y + dy)) } : n)));\n };\n\n const byId = new Map(nodes.map((n) => [n.id, n]));\n\n return (\n <div className={[styles.root, className].filter(Boolean).join(' ')}>\n <div className={styles.toolbar}>\n <span className={styles.title}>{label}</span>\n <div className={styles.controls}>\n <button type=\"button\" className={styles.toolBtn} aria-label=\"Zoom out\" onClick={() => setZoom((z) => Math.max(0.5, Math.round((z - 0.1) * 10) / 10))}>\n −\n </button>\n <span className={styles.zoomLabel} aria-live=\"polite\">{Math.round(zoom * 100)}%</span>\n <button type=\"button\" className={styles.toolBtn} aria-label=\"Zoom in\" onClick={() => setZoom((z) => Math.min(1.6, Math.round((z + 0.1) * 10) / 10))}>\n +\n </button>\n <button type=\"button\" className={styles.toolBtn} onClick={() => setZoom(1)}>\n Reset\n </button>\n </div>\n </div>\n\n <div\n role=\"region\"\n aria-label={label}\n className={styles.viewport}\n style={{ height }}\n onPointerDown={(e) => {\n if (e.target === e.currentTarget) select(null);\n }}\n >\n <div className={styles.stage} style={{ transform: `scale(${zoom})`, transformOrigin: '0 0' }}>\n <svg className={styles.edges} aria-hidden=\"true\">\n <defs>\n <marker id=\"rl-flow-arrow\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">\n <path d=\"M 0 1 L 10 5 L 0 9 z\" fill=\"var(--pl-color-border-strong)\" />\n </marker>\n </defs>\n {edges.map((edge) => {\n const a = byId.get(edge.from);\n const b = byId.get(edge.to);\n if (!a || !b) return null;\n const x1 = a.x + NODE_W;\n const y1 = a.y + NODE_H / 2;\n const x2 = b.x;\n const y2 = b.y + NODE_H / 2;\n const cxOffset = Math.max(40, Math.abs(x2 - x1) * 0.45);\n const d = `M ${x1} ${y1} C ${x1 + cxOffset} ${y1}, ${x2 - cxOffset} ${y2}, ${x2} ${y2}`;\n const mx = (x1 + x2) / 2;\n const my = (y1 + y2) / 2;\n return (\n <g key={edge.id}>\n <path d={d} className={styles.edgePath} markerEnd=\"url(#rl-flow-arrow)\" />\n {edge.label && (\n <text x={mx} y={my - 6} textAnchor=\"middle\" className={styles.edgeLabel}>\n {edge.label}\n </text>\n )}\n </g>\n );\n })}\n </svg>\n\n {nodes.map((node) => {\n const isSelected = selectedId === node.id;\n return (\n <div\n key={node.id}\n role=\"button\"\n tabIndex={0}\n aria-pressed={isSelected}\n // Named by its visible title and description (WCAG 2.5.3).\n className={styles.node}\n data-selected={isSelected ? '' : undefined}\n data-tone={node.tone ?? 'default'}\n style={{ transform: `translate(${node.x}px, ${node.y}px)`, width: NODE_W, minHeight: NODE_H }}\n onClick={(e) => {\n e.stopPropagation();\n select(node.id);\n }}\n onPointerDown={(e) => {\n if (readOnly) return;\n e.stopPropagation();\n select(node.id);\n e.currentTarget.setPointerCapture?.(e.pointerId);\n dragRef.current = { id: node.id, startX: e.clientX, startY: e.clientY, origX: node.x, origY: node.y };\n }}\n onPointerMove={(e) => {\n const d = dragRef.current;\n if (!d || d.id !== node.id) return;\n const nx = Math.max(8, Math.round(d.origX + (e.clientX - d.startX) / zoom));\n const ny = Math.max(8, Math.round(d.origY + (e.clientY - d.startY) / zoom));\n setNodes(nodes.map((n) => (n.id === node.id ? { ...n, x: nx, y: ny } : n)));\n }}\n onPointerUp={() => {\n dragRef.current = null;\n }}\n onKeyDown={(e) => {\n const step = e.shiftKey ? 48 : 16;\n if (e.key === 'ArrowRight') { e.preventDefault(); moveNode(node.id, step, 0); }\n else if (e.key === 'ArrowLeft') { e.preventDefault(); moveNode(node.id, -step, 0); }\n else if (e.key === 'ArrowDown') { e.preventDefault(); moveNode(node.id, 0, step); }\n else if (e.key === 'ArrowUp') { e.preventDefault(); moveNode(node.id, 0, -step); }\n }}\n >\n <span className={styles.nodeTitle}>{node.label}</span>\n {node.description && <span className={styles.nodeDesc}>{node.description}</span>}\n </div>\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n\n"],"mappings":";;;;;;AAoCA,IAAM,SAAS;AACf,IAAM,SAAS;;;;;AAMf,SAAgB,WAAW,EAC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";
5
+ var controls = "pl-flow-canvas-controls-EFgZ7R";
6
+ var toolBtn = "pl-flow-canvas-toolBtn-EFgZ7R";
7
+ var zoomLabel = "pl-flow-canvas-zoomLabel-EFgZ7R";
8
+ var viewport = "pl-flow-canvas-viewport-EFgZ7R";
9
+ var stage = "pl-flow-canvas-stage-EFgZ7R";
10
+ var edges = "pl-flow-canvas-edges-EFgZ7R";
11
+ var edgePath = "pl-flow-canvas-edgePath-EFgZ7R";
12
+ var edgeLabel = "pl-flow-canvas-edgeLabel-EFgZ7R";
13
+ var node = "pl-flow-canvas-node-EFgZ7R";
14
+ var nodeTitle = "pl-flow-canvas-nodeTitle-EFgZ7R";
15
+ var nodeDesc = "pl-flow-canvas-nodeDesc-EFgZ7R";
16
+ var flow_canvas_module_default = {
17
+ root,
18
+ toolbar,
19
+ title,
20
+ controls,
21
+ toolBtn,
22
+ zoomLabel,
23
+ viewport,
24
+ stage,
25
+ edges,
26
+ edgePath,
27
+ edgeLabel,
28
+ node,
29
+ nodeTitle,
30
+ nodeDesc
31
+ };
32
+ export { controls, flow_canvas_module_default as default, edgeLabel, edgePath, edges, node, nodeDesc, nodeTitle, root, stage, title, toolBtn, toolbar, viewport, zoomLabel };
33
+
34
+ //# sourceMappingURL=flow-canvas.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-canvas.module.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export { SortableList, SortableGrid } from './sortable.js';
2
+ export type { SortableListProps, SortableGridProps, SortableMessages } from './sortable.js';
3
+ export { TransferList } from './transfer.js';
4
+ export type { TransferListProps, TransferMessages } from './transfer.js';
5
+ export type { DragItem } from './drag.js';
6
+ export { KanbanBoard, type KanbanBoardProps, type KanbanCard, type KanbanColumn, type KanbanMessages } from './kanban-board.js';
7
+ export { FlowCanvas, type FlowCanvasProps, type FlowNode, type FlowEdge } from './flow-canvas.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAChI,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { SortableGrid, SortableList } from "./sortable.js";
2
+ import { TransferList } from "./transfer.js";
3
+ import { KanbanBoard } from "./kanban-board.js";
4
+ import { FlowCanvas } from "./flow-canvas.js";
5
+ export { FlowCanvas, KanbanBoard, SortableGrid, SortableList, TransferList };
@@ -0,0 +1,29 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type DragItem } from './drag.js';
3
+ export interface KanbanColumn {
4
+ id: string;
5
+ label: string;
6
+ }
7
+ export interface KanbanCard extends DragItem {
8
+ columnId: string;
9
+ }
10
+ export interface KanbanBoardProps<T extends KanbanCard> {
11
+ label: string;
12
+ columns: readonly KanbanColumn[];
13
+ cards: readonly T[];
14
+ onChange: (cards: T[]) => void;
15
+ renderCard?: (card: T) => ReactNode;
16
+ disabled?: boolean;
17
+ messages?: Partial<KanbanMessages>;
18
+ className?: string;
19
+ }
20
+ export interface KanbanMessages {
21
+ drag: (card: string) => string;
22
+ move: (card: string) => string;
23
+ earlier: (card: string) => string;
24
+ later: (card: string) => string;
25
+ moved: (card: string, column: string, position: number) => string;
26
+ empty: string;
27
+ }
28
+ export declare function KanbanBoard<T extends KanbanCard>({ label, columns, cards, onChange, renderCard, disabled, messages: overrides, className, }: KanbanBoardProps<T>): import("react").JSX.Element;
29
+ //# sourceMappingURL=kanban-board.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kanban-board.d.ts","sourceRoot":"","sources":["../src/kanban-board.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAA2D,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGnG,MAAM,WAAW,YAAY;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC3D,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAAG,QAAQ,EAAE,MAAM,CAAA;CAAE;AAEjE,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC,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