@seed-ship/mcp-ui-solid 2.0.0 → 2.1.0
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 +50 -1
- package/dist/components/AutocompleteDropdown.cjs +201 -0
- package/dist/components/AutocompleteDropdown.cjs.map +1 -0
- package/dist/components/AutocompleteDropdown.d.ts +71 -0
- package/dist/components/AutocompleteDropdown.d.ts.map +1 -0
- package/dist/components/AutocompleteDropdown.js +201 -0
- package/dist/components/AutocompleteDropdown.js.map +1 -0
- package/dist/components/AutocompleteFormField.cjs +289 -0
- package/dist/components/AutocompleteFormField.cjs.map +1 -0
- package/dist/components/AutocompleteFormField.d.ts +52 -0
- package/dist/components/AutocompleteFormField.d.ts.map +1 -0
- package/dist/components/AutocompleteFormField.js +289 -0
- package/dist/components/AutocompleteFormField.js.map +1 -0
- package/dist/components/DraggableGridItem.cjs +133 -0
- package/dist/components/DraggableGridItem.cjs.map +1 -0
- package/dist/components/DraggableGridItem.d.ts +95 -0
- package/dist/components/DraggableGridItem.d.ts.map +1 -0
- package/dist/components/DraggableGridItem.js +133 -0
- package/dist/components/DraggableGridItem.js.map +1 -0
- package/dist/components/EditableUIResourceRenderer.cjs +203 -0
- package/dist/components/EditableUIResourceRenderer.cjs.map +1 -0
- package/dist/components/EditableUIResourceRenderer.d.ts +43 -0
- package/dist/components/EditableUIResourceRenderer.d.ts.map +1 -0
- package/dist/components/EditableUIResourceRenderer.js +203 -0
- package/dist/components/EditableUIResourceRenderer.js.map +1 -0
- package/dist/components/GhostText.cjs +105 -0
- package/dist/components/GhostText.cjs.map +1 -0
- package/dist/components/GhostText.d.ts +113 -0
- package/dist/components/GhostText.d.ts.map +1 -0
- package/dist/components/GhostText.js +105 -0
- package/dist/components/GhostText.js.map +1 -0
- package/dist/components/ResizeHandle.cjs +173 -0
- package/dist/components/ResizeHandle.cjs.map +1 -0
- package/dist/components/ResizeHandle.d.ts +50 -0
- package/dist/components/ResizeHandle.d.ts.map +1 -0
- package/dist/components/ResizeHandle.js +173 -0
- package/dist/components/ResizeHandle.js.map +1 -0
- package/dist/context/AutocompleteContext.cjs +158 -0
- package/dist/context/AutocompleteContext.cjs.map +1 -0
- package/dist/context/AutocompleteContext.d.ts +77 -0
- package/dist/context/AutocompleteContext.d.ts.map +1 -0
- package/dist/context/AutocompleteContext.js +158 -0
- package/dist/context/AutocompleteContext.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useAutocomplete.cjs +234 -0
- package/dist/hooks/useAutocomplete.cjs.map +1 -0
- package/dist/hooks/useAutocomplete.d.ts +119 -0
- package/dist/hooks/useAutocomplete.d.ts.map +1 -0
- package/dist/hooks/useAutocomplete.js +234 -0
- package/dist/hooks/useAutocomplete.js.map +1 -0
- package/dist/hooks/useDragDrop.cjs +170 -0
- package/dist/hooks/useDragDrop.cjs.map +1 -0
- package/dist/hooks/useDragDrop.d.ts +100 -0
- package/dist/hooks/useDragDrop.d.ts.map +1 -0
- package/dist/hooks/useDragDrop.js +170 -0
- package/dist/hooks/useDragDrop.js.map +1 -0
- package/dist/hooks/useResize.cjs +209 -0
- package/dist/hooks/useResize.cjs.map +1 -0
- package/dist/hooks/useResize.d.ts +87 -0
- package/dist/hooks/useResize.d.ts.map +1 -0
- package/dist/hooks/useResize.js +209 -0
- package/dist/hooks/useResize.js.map +1 -0
- package/dist/hooks.cjs +6 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +6 -0
- package/dist/hooks.d.ts +6 -0
- package/dist/hooks.js +6 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/duckdb.cjs +192 -0
- package/dist/plugins/duckdb.cjs.map +1 -0
- package/dist/plugins/duckdb.d.ts +20 -0
- package/dist/plugins/duckdb.d.ts.map +1 -0
- package/dist/plugins/duckdb.js +170 -0
- package/dist/plugins/duckdb.js.map +1 -0
- package/dist/plugins/groq.cjs +97 -0
- package/dist/plugins/groq.cjs.map +1 -0
- package/dist/plugins/groq.d.ts +13 -0
- package/dist/plugins/groq.d.ts.map +1 -0
- package/dist/plugins/groq.js +97 -0
- package/dist/plugins/groq.js.map +1 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/rest.cjs +92 -0
- package/dist/plugins/rest.cjs.map +1 -0
- package/dist/plugins/rest.d.ts +13 -0
- package/dist/plugins/rest.d.ts.map +1 -0
- package/dist/plugins/rest.js +92 -0
- package/dist/plugins/rest.js.map +1 -0
- package/dist/plugins/supabase.cjs +79 -0
- package/dist/plugins/supabase.cjs.map +1 -0
- package/dist/plugins/supabase.d.ts +13 -0
- package/dist/plugins/supabase.d.ts.map +1 -0
- package/dist/plugins/supabase.js +79 -0
- package/dist/plugins/supabase.js.map +1 -0
- package/dist/services/validation.cjs +40 -1
- package/dist/services/validation.cjs.map +1 -1
- package/dist/services/validation.d.ts.map +1 -1
- package/dist/services/validation.js +40 -1
- package/dist/services/validation.js.map +1 -1
- package/dist/types/index.d.ts +430 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types.d.cts +430 -0
- package/dist/types.d.ts +430 -0
- package/package.json +16 -1
- package/src/components/AutocompleteDropdown.tsx +329 -0
- package/src/components/AutocompleteFormField.tsx +288 -0
- package/src/components/DraggableGridItem.tsx +274 -0
- package/src/components/EditableUIResourceRenderer.tsx +273 -0
- package/src/components/GhostText.tsx +262 -0
- package/src/components/ResizeHandle.tsx +262 -0
- package/src/context/AutocompleteContext.tsx +317 -0
- package/src/hooks/index.ts +23 -0
- package/src/hooks/useAutocomplete.test.ts +334 -0
- package/src/hooks/useAutocomplete.ts +466 -0
- package/src/hooks/useDragDrop.test.ts +355 -0
- package/src/hooks/useDragDrop.ts +379 -0
- package/src/hooks/useResize.test.ts +313 -0
- package/src/hooks/useResize.ts +372 -0
- package/src/index.ts +71 -0
- package/src/plugins/duckdb.ts +269 -0
- package/src/plugins/groq.ts +137 -0
- package/src/plugins/index.ts +14 -0
- package/src/plugins/rest.ts +147 -0
- package/src/plugins/supabase.ts +120 -0
- package/src/services/validation.ts +46 -0
- package/src/styles/autocomplete.css +356 -0
- package/src/styles/drag-drop.css +297 -0
- package/src/styles/index.css +7 -0
- package/src/types/index.ts +529 -0
- package/src/vite-env.d.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +2 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const solidJs = require("solid-js");
|
|
4
|
+
const web = require("solid-js/web");
|
|
5
|
+
function applyConstraints(position, constraints, gridColumns) {
|
|
6
|
+
let { colStart, colSpan, rowStart, rowSpan } = position;
|
|
7
|
+
const minColSpan = constraints.minColSpan ?? 1;
|
|
8
|
+
const maxColSpan = constraints.maxColSpan ?? gridColumns;
|
|
9
|
+
colSpan = Math.max(minColSpan, Math.min(maxColSpan, colSpan));
|
|
10
|
+
if (colStart + colSpan - 1 > gridColumns) {
|
|
11
|
+
colStart = gridColumns - colSpan + 1;
|
|
12
|
+
}
|
|
13
|
+
colStart = Math.max(1, colStart);
|
|
14
|
+
if (rowSpan !== void 0) {
|
|
15
|
+
const minRowSpan = constraints.minRowSpan ?? 1;
|
|
16
|
+
const maxRowSpan = constraints.maxRowSpan ?? 99;
|
|
17
|
+
rowSpan = Math.max(minRowSpan, Math.min(maxRowSpan, rowSpan));
|
|
18
|
+
}
|
|
19
|
+
if (rowStart !== void 0) {
|
|
20
|
+
rowStart = Math.max(1, rowStart);
|
|
21
|
+
}
|
|
22
|
+
return { colStart, colSpan, rowStart, rowSpan };
|
|
23
|
+
}
|
|
24
|
+
function useResize(options) {
|
|
25
|
+
const {
|
|
26
|
+
currentPosition,
|
|
27
|
+
onResize,
|
|
28
|
+
onResizePreview,
|
|
29
|
+
constraints = {},
|
|
30
|
+
gridContainer,
|
|
31
|
+
gridColumns = 12,
|
|
32
|
+
enabled = true
|
|
33
|
+
} = options;
|
|
34
|
+
const [isResizing, setIsResizing] = solidJs.createSignal(false);
|
|
35
|
+
const [resizeEdge, setResizeEdge] = solidJs.createSignal(null);
|
|
36
|
+
const [previewPosition, setPreviewPosition] = solidJs.createSignal(null);
|
|
37
|
+
const [startPosition, setStartPosition] = solidJs.createSignal(null);
|
|
38
|
+
const [startPointer, setStartPointer] = solidJs.createSignal(null);
|
|
39
|
+
if (web.isServer) {
|
|
40
|
+
return {
|
|
41
|
+
isResizing: () => false,
|
|
42
|
+
resizeEdge: () => null,
|
|
43
|
+
previewPosition: () => null,
|
|
44
|
+
handleResizeStart: () => {
|
|
45
|
+
},
|
|
46
|
+
getResizeHandleProps: () => ({
|
|
47
|
+
onPointerDown: () => {
|
|
48
|
+
},
|
|
49
|
+
style: {},
|
|
50
|
+
"data-resize-edge": "right"
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const handlePointerMove = (e) => {
|
|
55
|
+
if (!isResizing() || !startPosition() || !startPointer()) return;
|
|
56
|
+
const edge = resizeEdge();
|
|
57
|
+
if (!edge) return;
|
|
58
|
+
const container = (gridContainer == null ? void 0 : gridContainer()) || document.querySelector("[data-grid-container]");
|
|
59
|
+
if (!container) return;
|
|
60
|
+
const containerRect = container.getBoundingClientRect();
|
|
61
|
+
const currentPos = startPosition();
|
|
62
|
+
const start = startPointer();
|
|
63
|
+
let newPosition = { ...currentPos };
|
|
64
|
+
const deltaX = e.clientX - start.x;
|
|
65
|
+
const columnWidth = containerRect.width / gridColumns;
|
|
66
|
+
const columnDelta = Math.round(deltaX / columnWidth);
|
|
67
|
+
if (constraints.lockHorizontal && (edge === "left" || edge === "right")) ;
|
|
68
|
+
else {
|
|
69
|
+
switch (edge) {
|
|
70
|
+
case "right": {
|
|
71
|
+
const newColSpan = currentPos.colSpan + columnDelta;
|
|
72
|
+
newPosition.colSpan = Math.max(1, Math.min(gridColumns - currentPos.colStart + 1, newColSpan));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "left": {
|
|
76
|
+
const newColStart = currentPos.colStart + columnDelta;
|
|
77
|
+
const newColSpan = currentPos.colSpan - columnDelta;
|
|
78
|
+
if (newColStart >= 1 && newColSpan >= 1) {
|
|
79
|
+
newPosition.colStart = newColStart;
|
|
80
|
+
newPosition.colSpan = newColSpan;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "top":
|
|
85
|
+
case "bottom": {
|
|
86
|
+
if (!constraints.lockVertical) {
|
|
87
|
+
const rowHeight = 100;
|
|
88
|
+
const deltaY = e.clientY - start.y;
|
|
89
|
+
const rowDelta = Math.round(deltaY / rowHeight);
|
|
90
|
+
if (edge === "bottom") {
|
|
91
|
+
const currentRowSpan = currentPos.rowSpan || 1;
|
|
92
|
+
const newRowSpan = currentRowSpan + rowDelta;
|
|
93
|
+
newPosition.rowSpan = Math.max(1, newRowSpan);
|
|
94
|
+
} else if (edge === "top") {
|
|
95
|
+
const currentRowStart = currentPos.rowStart || 1;
|
|
96
|
+
const currentRowSpan = currentPos.rowSpan || 1;
|
|
97
|
+
const newRowStart = currentRowStart + rowDelta;
|
|
98
|
+
const newRowSpan = currentRowSpan - rowDelta;
|
|
99
|
+
if (newRowStart >= 1 && newRowSpan >= 1) {
|
|
100
|
+
newPosition.rowStart = newRowStart;
|
|
101
|
+
newPosition.rowSpan = newRowSpan;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
newPosition = applyConstraints(newPosition, constraints, gridColumns);
|
|
110
|
+
setPreviewPosition(newPosition);
|
|
111
|
+
onResizePreview == null ? void 0 : onResizePreview(newPosition);
|
|
112
|
+
};
|
|
113
|
+
const handlePointerUp = (_e) => {
|
|
114
|
+
if (!isResizing()) return;
|
|
115
|
+
const preview = previewPosition();
|
|
116
|
+
if (preview) {
|
|
117
|
+
onResize(preview);
|
|
118
|
+
}
|
|
119
|
+
setIsResizing(false);
|
|
120
|
+
setResizeEdge(null);
|
|
121
|
+
setPreviewPosition(null);
|
|
122
|
+
setStartPosition(null);
|
|
123
|
+
setStartPointer(null);
|
|
124
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
125
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
126
|
+
document.body.style.cursor = "";
|
|
127
|
+
document.body.style.userSelect = "";
|
|
128
|
+
};
|
|
129
|
+
const handleResizeStart = (e, edge) => {
|
|
130
|
+
if (!enabled) return;
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
setIsResizing(true);
|
|
134
|
+
setResizeEdge(edge);
|
|
135
|
+
setStartPosition(currentPosition());
|
|
136
|
+
setStartPointer({ x: e.clientX, y: e.clientY });
|
|
137
|
+
setPreviewPosition(currentPosition());
|
|
138
|
+
const cursors = {
|
|
139
|
+
left: "ew-resize",
|
|
140
|
+
right: "ew-resize",
|
|
141
|
+
top: "ns-resize",
|
|
142
|
+
bottom: "ns-resize"
|
|
143
|
+
};
|
|
144
|
+
document.body.style.cursor = cursors[edge];
|
|
145
|
+
document.body.style.userSelect = "none";
|
|
146
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
147
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
148
|
+
};
|
|
149
|
+
const getResizeHandleProps = (edge) => {
|
|
150
|
+
const baseStyle = {
|
|
151
|
+
position: "absolute",
|
|
152
|
+
zIndex: "10"
|
|
153
|
+
};
|
|
154
|
+
const edgeStyles = {
|
|
155
|
+
left: {
|
|
156
|
+
...baseStyle,
|
|
157
|
+
left: "-4px",
|
|
158
|
+
top: "0",
|
|
159
|
+
width: "8px",
|
|
160
|
+
height: "100%",
|
|
161
|
+
cursor: "ew-resize"
|
|
162
|
+
},
|
|
163
|
+
right: {
|
|
164
|
+
...baseStyle,
|
|
165
|
+
right: "-4px",
|
|
166
|
+
top: "0",
|
|
167
|
+
width: "8px",
|
|
168
|
+
height: "100%",
|
|
169
|
+
cursor: "ew-resize"
|
|
170
|
+
},
|
|
171
|
+
top: {
|
|
172
|
+
...baseStyle,
|
|
173
|
+
top: "-4px",
|
|
174
|
+
left: "0",
|
|
175
|
+
width: "100%",
|
|
176
|
+
height: "8px",
|
|
177
|
+
cursor: "ns-resize"
|
|
178
|
+
},
|
|
179
|
+
bottom: {
|
|
180
|
+
...baseStyle,
|
|
181
|
+
bottom: "-4px",
|
|
182
|
+
left: "0",
|
|
183
|
+
width: "100%",
|
|
184
|
+
height: "8px",
|
|
185
|
+
cursor: "ns-resize"
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
onPointerDown: (e) => handleResizeStart(e, edge),
|
|
190
|
+
style: edgeStyles[edge],
|
|
191
|
+
"data-resize-edge": edge
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
solidJs.onCleanup(() => {
|
|
195
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
196
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
197
|
+
document.body.style.cursor = "";
|
|
198
|
+
document.body.style.userSelect = "";
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
isResizing,
|
|
202
|
+
resizeEdge,
|
|
203
|
+
previewPosition,
|
|
204
|
+
handleResizeStart,
|
|
205
|
+
getResizeHandleProps
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
exports.useResize = useResize;
|
|
209
|
+
//# sourceMappingURL=useResize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResize.cjs","sources":["../../src/hooks/useResize.ts"],"sourcesContent":["/**\n * useResize Hook\n * Handles resizing of grid components by dragging edges\n *\n * Sprint Drag-Drop Feature\n */\n\nimport { createSignal, Accessor, onCleanup } from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport type { GridPosition, ResizeConstraints } from '../types'\n\n/**\n * Resize edge types\n */\nexport type ResizeEdge = 'left' | 'right' | 'top' | 'bottom'\n\n/**\n * Options for the useResize hook\n */\nexport interface UseResizeOptions {\n /**\n * Component ID being resized\n */\n componentId: string\n\n /**\n * Current grid position accessor\n */\n currentPosition: Accessor<GridPosition>\n\n /**\n * Callback when resize is complete\n */\n onResize: (newPosition: GridPosition) => void\n\n /**\n * Callback during resize (for preview)\n */\n onResizePreview?: (previewPosition: GridPosition) => void\n\n /**\n * Resize constraints\n */\n constraints?: ResizeConstraints\n\n /**\n * Grid container element for calculating column widths\n */\n gridContainer?: Accessor<HTMLElement | null>\n\n /**\n * Number of columns in the grid (default: 12)\n */\n gridColumns?: number\n\n /**\n * Whether resize is enabled\n */\n enabled?: boolean\n}\n\n/**\n * Return type for the useResize hook\n */\nexport interface UseResizeReturn {\n /**\n * Whether a resize is in progress\n */\n isResizing: Accessor<boolean>\n\n /**\n * Current resize edge\n */\n resizeEdge: Accessor<ResizeEdge | null>\n\n /**\n * Preview position during resize\n */\n previewPosition: Accessor<GridPosition | null>\n\n /**\n * Start resize operation\n */\n handleResizeStart: (e: PointerEvent, edge: ResizeEdge) => void\n\n /**\n * Get resize handle props for an edge\n */\n getResizeHandleProps: (edge: ResizeEdge) => ResizeHandleProps\n}\n\n/**\n * Props for resize handles\n */\nexport interface ResizeHandleProps {\n onPointerDown: (e: PointerEvent) => void\n style: Record<string, string>\n 'data-resize-edge': ResizeEdge\n}\n\n/**\n * Apply constraints to a position\n */\nfunction applyConstraints(\n position: GridPosition,\n constraints: ResizeConstraints,\n gridColumns: number\n): GridPosition {\n let { colStart, colSpan, rowStart, rowSpan } = position\n\n // Apply column constraints\n const minColSpan = constraints.minColSpan ?? 1\n const maxColSpan = constraints.maxColSpan ?? gridColumns\n\n colSpan = Math.max(minColSpan, Math.min(maxColSpan, colSpan))\n\n // Ensure colStart + colSpan doesn't exceed grid\n if (colStart + colSpan - 1 > gridColumns) {\n colStart = gridColumns - colSpan + 1\n }\n colStart = Math.max(1, colStart)\n\n // Apply row constraints\n if (rowSpan !== undefined) {\n const minRowSpan = constraints.minRowSpan ?? 1\n const maxRowSpan = constraints.maxRowSpan ?? 99\n rowSpan = Math.max(minRowSpan, Math.min(maxRowSpan, rowSpan))\n }\n\n if (rowStart !== undefined) {\n rowStart = Math.max(1, rowStart)\n }\n\n return { colStart, colSpan, rowStart, rowSpan }\n}\n\n/**\n * Hook for handling resize of grid components\n */\nexport function useResize(options: UseResizeOptions): UseResizeReturn {\n const {\n currentPosition,\n onResize,\n onResizePreview,\n constraints = {},\n gridContainer,\n gridColumns = 12,\n enabled = true\n } = options\n\n const [isResizing, setIsResizing] = createSignal(false)\n const [resizeEdge, setResizeEdge] = createSignal<ResizeEdge | null>(null)\n const [previewPosition, setPreviewPosition] = createSignal<GridPosition | null>(null)\n const [startPosition, setStartPosition] = createSignal<GridPosition | null>(null)\n const [startPointer, setStartPointer] = createSignal<{ x: number; y: number } | null>(null)\n\n // Skip on server\n if (isServer) {\n return {\n isResizing: () => false,\n resizeEdge: () => null,\n previewPosition: () => null,\n handleResizeStart: () => {},\n getResizeHandleProps: () => ({\n onPointerDown: () => {},\n style: {},\n 'data-resize-edge': 'right' as ResizeEdge\n })\n }\n }\n\n /**\n * Handle pointer move during resize\n */\n const handlePointerMove = (e: PointerEvent) => {\n if (!isResizing() || !startPosition() || !startPointer()) return\n\n const edge = resizeEdge()\n if (!edge) return\n\n // Get container for measurements\n const container = gridContainer?.() || document.querySelector('[data-grid-container]')\n if (!container) return\n\n const containerRect = container.getBoundingClientRect()\n const currentPos = startPosition()!\n const start = startPointer()!\n\n let newPosition: GridPosition = { ...currentPos }\n\n // Calculate delta in columns\n const deltaX = e.clientX - start.x\n const columnWidth = containerRect.width / gridColumns\n const columnDelta = Math.round(deltaX / columnWidth)\n\n if (constraints.lockHorizontal && (edge === 'left' || edge === 'right')) {\n // Horizontal resize is locked\n } else {\n switch (edge) {\n case 'right': {\n // Increase/decrease colSpan from the right\n const newColSpan = currentPos.colSpan + columnDelta\n newPosition.colSpan = Math.max(1, Math.min(gridColumns - currentPos.colStart + 1, newColSpan))\n break\n }\n case 'left': {\n // Increase/decrease from left (changes both colStart and colSpan)\n const newColStart = currentPos.colStart + columnDelta\n const newColSpan = currentPos.colSpan - columnDelta\n if (newColStart >= 1 && newColSpan >= 1) {\n newPosition.colStart = newColStart\n newPosition.colSpan = newColSpan\n }\n break\n }\n case 'top':\n case 'bottom': {\n // Row resizing - calculate based on Y movement\n if (!constraints.lockVertical) {\n const rowHeight = 100 // Approximate row height\n const deltaY = e.clientY - start.y\n const rowDelta = Math.round(deltaY / rowHeight)\n\n if (edge === 'bottom') {\n const currentRowSpan = currentPos.rowSpan || 1\n const newRowSpan = currentRowSpan + rowDelta\n newPosition.rowSpan = Math.max(1, newRowSpan)\n } else if (edge === 'top') {\n const currentRowStart = currentPos.rowStart || 1\n const currentRowSpan = currentPos.rowSpan || 1\n const newRowStart = currentRowStart + rowDelta\n const newRowSpan = currentRowSpan - rowDelta\n if (newRowStart >= 1 && newRowSpan >= 1) {\n newPosition.rowStart = newRowStart\n newPosition.rowSpan = newRowSpan\n }\n }\n }\n break\n }\n }\n }\n\n // Apply constraints\n newPosition = applyConstraints(newPosition, constraints, gridColumns)\n\n setPreviewPosition(newPosition)\n onResizePreview?.(newPosition)\n }\n\n /**\n * Handle pointer up to finish resize\n */\n const handlePointerUp = (_e: PointerEvent) => {\n if (!isResizing()) return\n\n const preview = previewPosition()\n if (preview) {\n onResize(preview)\n }\n\n // Cleanup\n setIsResizing(false)\n setResizeEdge(null)\n setPreviewPosition(null)\n setStartPosition(null)\n setStartPointer(null)\n\n // Remove listeners\n document.removeEventListener('pointermove', handlePointerMove)\n document.removeEventListener('pointerup', handlePointerUp)\n document.body.style.cursor = ''\n document.body.style.userSelect = ''\n }\n\n /**\n * Start resize operation\n */\n const handleResizeStart = (e: PointerEvent, edge: ResizeEdge) => {\n if (!enabled) return\n\n e.preventDefault()\n e.stopPropagation()\n\n setIsResizing(true)\n setResizeEdge(edge)\n setStartPosition(currentPosition())\n setStartPointer({ x: e.clientX, y: e.clientY })\n setPreviewPosition(currentPosition())\n\n // Set cursor\n const cursors: Record<ResizeEdge, string> = {\n left: 'ew-resize',\n right: 'ew-resize',\n top: 'ns-resize',\n bottom: 'ns-resize'\n }\n document.body.style.cursor = cursors[edge]\n document.body.style.userSelect = 'none'\n\n // Add document listeners\n document.addEventListener('pointermove', handlePointerMove)\n document.addEventListener('pointerup', handlePointerUp)\n }\n\n /**\n * Get resize handle props for an edge\n */\n const getResizeHandleProps = (edge: ResizeEdge): ResizeHandleProps => {\n const baseStyle: Record<string, string> = {\n position: 'absolute',\n zIndex: '10'\n }\n\n const edgeStyles: Record<ResizeEdge, Record<string, string>> = {\n left: {\n ...baseStyle,\n left: '-4px',\n top: '0',\n width: '8px',\n height: '100%',\n cursor: 'ew-resize'\n },\n right: {\n ...baseStyle,\n right: '-4px',\n top: '0',\n width: '8px',\n height: '100%',\n cursor: 'ew-resize'\n },\n top: {\n ...baseStyle,\n top: '-4px',\n left: '0',\n width: '100%',\n height: '8px',\n cursor: 'ns-resize'\n },\n bottom: {\n ...baseStyle,\n bottom: '-4px',\n left: '0',\n width: '100%',\n height: '8px',\n cursor: 'ns-resize'\n }\n }\n\n return {\n onPointerDown: (e) => handleResizeStart(e, edge),\n style: edgeStyles[edge],\n 'data-resize-edge': edge\n }\n }\n\n // Cleanup on unmount\n onCleanup(() => {\n document.removeEventListener('pointermove', handlePointerMove)\n document.removeEventListener('pointerup', handlePointerUp)\n document.body.style.cursor = ''\n document.body.style.userSelect = ''\n })\n\n return {\n isResizing,\n resizeEdge,\n previewPosition,\n handleResizeStart,\n getResizeHandleProps\n }\n}\n"],"names":["createSignal","isServer","onCleanup"],"m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
3
|
+
* Handles resizing of grid components by dragging edges
|
|
4
|
+
*
|
|
5
|
+
* Sprint Drag-Drop Feature
|
|
6
|
+
*/
|
|
7
|
+
import { Accessor } from 'solid-js';
|
|
8
|
+
import type { GridPosition, ResizeConstraints } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Resize edge types
|
|
11
|
+
*/
|
|
12
|
+
export type ResizeEdge = 'left' | 'right' | 'top' | 'bottom';
|
|
13
|
+
/**
|
|
14
|
+
* Options for the useResize hook
|
|
15
|
+
*/
|
|
16
|
+
export interface UseResizeOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Component ID being resized
|
|
19
|
+
*/
|
|
20
|
+
componentId: string;
|
|
21
|
+
/**
|
|
22
|
+
* Current grid position accessor
|
|
23
|
+
*/
|
|
24
|
+
currentPosition: Accessor<GridPosition>;
|
|
25
|
+
/**
|
|
26
|
+
* Callback when resize is complete
|
|
27
|
+
*/
|
|
28
|
+
onResize: (newPosition: GridPosition) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Callback during resize (for preview)
|
|
31
|
+
*/
|
|
32
|
+
onResizePreview?: (previewPosition: GridPosition) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Resize constraints
|
|
35
|
+
*/
|
|
36
|
+
constraints?: ResizeConstraints;
|
|
37
|
+
/**
|
|
38
|
+
* Grid container element for calculating column widths
|
|
39
|
+
*/
|
|
40
|
+
gridContainer?: Accessor<HTMLElement | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Number of columns in the grid (default: 12)
|
|
43
|
+
*/
|
|
44
|
+
gridColumns?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Whether resize is enabled
|
|
47
|
+
*/
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Return type for the useResize hook
|
|
52
|
+
*/
|
|
53
|
+
export interface UseResizeReturn {
|
|
54
|
+
/**
|
|
55
|
+
* Whether a resize is in progress
|
|
56
|
+
*/
|
|
57
|
+
isResizing: Accessor<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Current resize edge
|
|
60
|
+
*/
|
|
61
|
+
resizeEdge: Accessor<ResizeEdge | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Preview position during resize
|
|
64
|
+
*/
|
|
65
|
+
previewPosition: Accessor<GridPosition | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Start resize operation
|
|
68
|
+
*/
|
|
69
|
+
handleResizeStart: (e: PointerEvent, edge: ResizeEdge) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Get resize handle props for an edge
|
|
72
|
+
*/
|
|
73
|
+
getResizeHandleProps: (edge: ResizeEdge) => ResizeHandleProps;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Props for resize handles
|
|
77
|
+
*/
|
|
78
|
+
export interface ResizeHandleProps {
|
|
79
|
+
onPointerDown: (e: PointerEvent) => void;
|
|
80
|
+
style: Record<string, string>;
|
|
81
|
+
'data-resize-edge': ResizeEdge;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Hook for handling resize of grid components
|
|
85
|
+
*/
|
|
86
|
+
export declare function useResize(options: UseResizeOptions): UseResizeReturn;
|
|
87
|
+
//# sourceMappingURL=useResize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResize.d.ts","sourceRoot":"","sources":["../../src/hooks/useResize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAgB,QAAQ,EAAa,MAAM,UAAU,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,eAAe,EAAE,QAAQ,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
+
function applyConstraints(position, constraints, gridColumns) {
|
|
4
|
+
let { colStart, colSpan, rowStart, rowSpan } = position;
|
|
5
|
+
const minColSpan = constraints.minColSpan ?? 1;
|
|
6
|
+
const maxColSpan = constraints.maxColSpan ?? gridColumns;
|
|
7
|
+
colSpan = Math.max(minColSpan, Math.min(maxColSpan, colSpan));
|
|
8
|
+
if (colStart + colSpan - 1 > gridColumns) {
|
|
9
|
+
colStart = gridColumns - colSpan + 1;
|
|
10
|
+
}
|
|
11
|
+
colStart = Math.max(1, colStart);
|
|
12
|
+
if (rowSpan !== void 0) {
|
|
13
|
+
const minRowSpan = constraints.minRowSpan ?? 1;
|
|
14
|
+
const maxRowSpan = constraints.maxRowSpan ?? 99;
|
|
15
|
+
rowSpan = Math.max(minRowSpan, Math.min(maxRowSpan, rowSpan));
|
|
16
|
+
}
|
|
17
|
+
if (rowStart !== void 0) {
|
|
18
|
+
rowStart = Math.max(1, rowStart);
|
|
19
|
+
}
|
|
20
|
+
return { colStart, colSpan, rowStart, rowSpan };
|
|
21
|
+
}
|
|
22
|
+
function useResize(options) {
|
|
23
|
+
const {
|
|
24
|
+
currentPosition,
|
|
25
|
+
onResize,
|
|
26
|
+
onResizePreview,
|
|
27
|
+
constraints = {},
|
|
28
|
+
gridContainer,
|
|
29
|
+
gridColumns = 12,
|
|
30
|
+
enabled = true
|
|
31
|
+
} = options;
|
|
32
|
+
const [isResizing, setIsResizing] = createSignal(false);
|
|
33
|
+
const [resizeEdge, setResizeEdge] = createSignal(null);
|
|
34
|
+
const [previewPosition, setPreviewPosition] = createSignal(null);
|
|
35
|
+
const [startPosition, setStartPosition] = createSignal(null);
|
|
36
|
+
const [startPointer, setStartPointer] = createSignal(null);
|
|
37
|
+
if (isServer) {
|
|
38
|
+
return {
|
|
39
|
+
isResizing: () => false,
|
|
40
|
+
resizeEdge: () => null,
|
|
41
|
+
previewPosition: () => null,
|
|
42
|
+
handleResizeStart: () => {
|
|
43
|
+
},
|
|
44
|
+
getResizeHandleProps: () => ({
|
|
45
|
+
onPointerDown: () => {
|
|
46
|
+
},
|
|
47
|
+
style: {},
|
|
48
|
+
"data-resize-edge": "right"
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const handlePointerMove = (e) => {
|
|
53
|
+
if (!isResizing() || !startPosition() || !startPointer()) return;
|
|
54
|
+
const edge = resizeEdge();
|
|
55
|
+
if (!edge) return;
|
|
56
|
+
const container = (gridContainer == null ? void 0 : gridContainer()) || document.querySelector("[data-grid-container]");
|
|
57
|
+
if (!container) return;
|
|
58
|
+
const containerRect = container.getBoundingClientRect();
|
|
59
|
+
const currentPos = startPosition();
|
|
60
|
+
const start = startPointer();
|
|
61
|
+
let newPosition = { ...currentPos };
|
|
62
|
+
const deltaX = e.clientX - start.x;
|
|
63
|
+
const columnWidth = containerRect.width / gridColumns;
|
|
64
|
+
const columnDelta = Math.round(deltaX / columnWidth);
|
|
65
|
+
if (constraints.lockHorizontal && (edge === "left" || edge === "right")) ;
|
|
66
|
+
else {
|
|
67
|
+
switch (edge) {
|
|
68
|
+
case "right": {
|
|
69
|
+
const newColSpan = currentPos.colSpan + columnDelta;
|
|
70
|
+
newPosition.colSpan = Math.max(1, Math.min(gridColumns - currentPos.colStart + 1, newColSpan));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "left": {
|
|
74
|
+
const newColStart = currentPos.colStart + columnDelta;
|
|
75
|
+
const newColSpan = currentPos.colSpan - columnDelta;
|
|
76
|
+
if (newColStart >= 1 && newColSpan >= 1) {
|
|
77
|
+
newPosition.colStart = newColStart;
|
|
78
|
+
newPosition.colSpan = newColSpan;
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "top":
|
|
83
|
+
case "bottom": {
|
|
84
|
+
if (!constraints.lockVertical) {
|
|
85
|
+
const rowHeight = 100;
|
|
86
|
+
const deltaY = e.clientY - start.y;
|
|
87
|
+
const rowDelta = Math.round(deltaY / rowHeight);
|
|
88
|
+
if (edge === "bottom") {
|
|
89
|
+
const currentRowSpan = currentPos.rowSpan || 1;
|
|
90
|
+
const newRowSpan = currentRowSpan + rowDelta;
|
|
91
|
+
newPosition.rowSpan = Math.max(1, newRowSpan);
|
|
92
|
+
} else if (edge === "top") {
|
|
93
|
+
const currentRowStart = currentPos.rowStart || 1;
|
|
94
|
+
const currentRowSpan = currentPos.rowSpan || 1;
|
|
95
|
+
const newRowStart = currentRowStart + rowDelta;
|
|
96
|
+
const newRowSpan = currentRowSpan - rowDelta;
|
|
97
|
+
if (newRowStart >= 1 && newRowSpan >= 1) {
|
|
98
|
+
newPosition.rowStart = newRowStart;
|
|
99
|
+
newPosition.rowSpan = newRowSpan;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
newPosition = applyConstraints(newPosition, constraints, gridColumns);
|
|
108
|
+
setPreviewPosition(newPosition);
|
|
109
|
+
onResizePreview == null ? void 0 : onResizePreview(newPosition);
|
|
110
|
+
};
|
|
111
|
+
const handlePointerUp = (_e) => {
|
|
112
|
+
if (!isResizing()) return;
|
|
113
|
+
const preview = previewPosition();
|
|
114
|
+
if (preview) {
|
|
115
|
+
onResize(preview);
|
|
116
|
+
}
|
|
117
|
+
setIsResizing(false);
|
|
118
|
+
setResizeEdge(null);
|
|
119
|
+
setPreviewPosition(null);
|
|
120
|
+
setStartPosition(null);
|
|
121
|
+
setStartPointer(null);
|
|
122
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
123
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
124
|
+
document.body.style.cursor = "";
|
|
125
|
+
document.body.style.userSelect = "";
|
|
126
|
+
};
|
|
127
|
+
const handleResizeStart = (e, edge) => {
|
|
128
|
+
if (!enabled) return;
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
setIsResizing(true);
|
|
132
|
+
setResizeEdge(edge);
|
|
133
|
+
setStartPosition(currentPosition());
|
|
134
|
+
setStartPointer({ x: e.clientX, y: e.clientY });
|
|
135
|
+
setPreviewPosition(currentPosition());
|
|
136
|
+
const cursors = {
|
|
137
|
+
left: "ew-resize",
|
|
138
|
+
right: "ew-resize",
|
|
139
|
+
top: "ns-resize",
|
|
140
|
+
bottom: "ns-resize"
|
|
141
|
+
};
|
|
142
|
+
document.body.style.cursor = cursors[edge];
|
|
143
|
+
document.body.style.userSelect = "none";
|
|
144
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
145
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
146
|
+
};
|
|
147
|
+
const getResizeHandleProps = (edge) => {
|
|
148
|
+
const baseStyle = {
|
|
149
|
+
position: "absolute",
|
|
150
|
+
zIndex: "10"
|
|
151
|
+
};
|
|
152
|
+
const edgeStyles = {
|
|
153
|
+
left: {
|
|
154
|
+
...baseStyle,
|
|
155
|
+
left: "-4px",
|
|
156
|
+
top: "0",
|
|
157
|
+
width: "8px",
|
|
158
|
+
height: "100%",
|
|
159
|
+
cursor: "ew-resize"
|
|
160
|
+
},
|
|
161
|
+
right: {
|
|
162
|
+
...baseStyle,
|
|
163
|
+
right: "-4px",
|
|
164
|
+
top: "0",
|
|
165
|
+
width: "8px",
|
|
166
|
+
height: "100%",
|
|
167
|
+
cursor: "ew-resize"
|
|
168
|
+
},
|
|
169
|
+
top: {
|
|
170
|
+
...baseStyle,
|
|
171
|
+
top: "-4px",
|
|
172
|
+
left: "0",
|
|
173
|
+
width: "100%",
|
|
174
|
+
height: "8px",
|
|
175
|
+
cursor: "ns-resize"
|
|
176
|
+
},
|
|
177
|
+
bottom: {
|
|
178
|
+
...baseStyle,
|
|
179
|
+
bottom: "-4px",
|
|
180
|
+
left: "0",
|
|
181
|
+
width: "100%",
|
|
182
|
+
height: "8px",
|
|
183
|
+
cursor: "ns-resize"
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
onPointerDown: (e) => handleResizeStart(e, edge),
|
|
188
|
+
style: edgeStyles[edge],
|
|
189
|
+
"data-resize-edge": edge
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
onCleanup(() => {
|
|
193
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
194
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
195
|
+
document.body.style.cursor = "";
|
|
196
|
+
document.body.style.userSelect = "";
|
|
197
|
+
});
|
|
198
|
+
return {
|
|
199
|
+
isResizing,
|
|
200
|
+
resizeEdge,
|
|
201
|
+
previewPosition,
|
|
202
|
+
handleResizeStart,
|
|
203
|
+
getResizeHandleProps
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
useResize
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=useResize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResize.js","sources":["../../src/hooks/useResize.ts"],"sourcesContent":["/**\n * useResize Hook\n * Handles resizing of grid components by dragging edges\n *\n * Sprint Drag-Drop Feature\n */\n\nimport { createSignal, Accessor, onCleanup } from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport type { GridPosition, ResizeConstraints } from '../types'\n\n/**\n * Resize edge types\n */\nexport type ResizeEdge = 'left' | 'right' | 'top' | 'bottom'\n\n/**\n * Options for the useResize hook\n */\nexport interface UseResizeOptions {\n /**\n * Component ID being resized\n */\n componentId: string\n\n /**\n * Current grid position accessor\n */\n currentPosition: Accessor<GridPosition>\n\n /**\n * Callback when resize is complete\n */\n onResize: (newPosition: GridPosition) => void\n\n /**\n * Callback during resize (for preview)\n */\n onResizePreview?: (previewPosition: GridPosition) => void\n\n /**\n * Resize constraints\n */\n constraints?: ResizeConstraints\n\n /**\n * Grid container element for calculating column widths\n */\n gridContainer?: Accessor<HTMLElement | null>\n\n /**\n * Number of columns in the grid (default: 12)\n */\n gridColumns?: number\n\n /**\n * Whether resize is enabled\n */\n enabled?: boolean\n}\n\n/**\n * Return type for the useResize hook\n */\nexport interface UseResizeReturn {\n /**\n * Whether a resize is in progress\n */\n isResizing: Accessor<boolean>\n\n /**\n * Current resize edge\n */\n resizeEdge: Accessor<ResizeEdge | null>\n\n /**\n * Preview position during resize\n */\n previewPosition: Accessor<GridPosition | null>\n\n /**\n * Start resize operation\n */\n handleResizeStart: (e: PointerEvent, edge: ResizeEdge) => void\n\n /**\n * Get resize handle props for an edge\n */\n getResizeHandleProps: (edge: ResizeEdge) => ResizeHandleProps\n}\n\n/**\n * Props for resize handles\n */\nexport interface ResizeHandleProps {\n onPointerDown: (e: PointerEvent) => void\n style: Record<string, string>\n 'data-resize-edge': ResizeEdge\n}\n\n/**\n * Apply constraints to a position\n */\nfunction applyConstraints(\n position: GridPosition,\n constraints: ResizeConstraints,\n gridColumns: number\n): GridPosition {\n let { colStart, colSpan, rowStart, rowSpan } = position\n\n // Apply column constraints\n const minColSpan = constraints.minColSpan ?? 1\n const maxColSpan = constraints.maxColSpan ?? gridColumns\n\n colSpan = Math.max(minColSpan, Math.min(maxColSpan, colSpan))\n\n // Ensure colStart + colSpan doesn't exceed grid\n if (colStart + colSpan - 1 > gridColumns) {\n colStart = gridColumns - colSpan + 1\n }\n colStart = Math.max(1, colStart)\n\n // Apply row constraints\n if (rowSpan !== undefined) {\n const minRowSpan = constraints.minRowSpan ?? 1\n const maxRowSpan = constraints.maxRowSpan ?? 99\n rowSpan = Math.max(minRowSpan, Math.min(maxRowSpan, rowSpan))\n }\n\n if (rowStart !== undefined) {\n rowStart = Math.max(1, rowStart)\n }\n\n return { colStart, colSpan, rowStart, rowSpan }\n}\n\n/**\n * Hook for handling resize of grid components\n */\nexport function useResize(options: UseResizeOptions): UseResizeReturn {\n const {\n currentPosition,\n onResize,\n onResizePreview,\n constraints = {},\n gridContainer,\n gridColumns = 12,\n enabled = true\n } = options\n\n const [isResizing, setIsResizing] = createSignal(false)\n const [resizeEdge, setResizeEdge] = createSignal<ResizeEdge | null>(null)\n const [previewPosition, setPreviewPosition] = createSignal<GridPosition | null>(null)\n const [startPosition, setStartPosition] = createSignal<GridPosition | null>(null)\n const [startPointer, setStartPointer] = createSignal<{ x: number; y: number } | null>(null)\n\n // Skip on server\n if (isServer) {\n return {\n isResizing: () => false,\n resizeEdge: () => null,\n previewPosition: () => null,\n handleResizeStart: () => {},\n getResizeHandleProps: () => ({\n onPointerDown: () => {},\n style: {},\n 'data-resize-edge': 'right' as ResizeEdge\n })\n }\n }\n\n /**\n * Handle pointer move during resize\n */\n const handlePointerMove = (e: PointerEvent) => {\n if (!isResizing() || !startPosition() || !startPointer()) return\n\n const edge = resizeEdge()\n if (!edge) return\n\n // Get container for measurements\n const container = gridContainer?.() || document.querySelector('[data-grid-container]')\n if (!container) return\n\n const containerRect = container.getBoundingClientRect()\n const currentPos = startPosition()!\n const start = startPointer()!\n\n let newPosition: GridPosition = { ...currentPos }\n\n // Calculate delta in columns\n const deltaX = e.clientX - start.x\n const columnWidth = containerRect.width / gridColumns\n const columnDelta = Math.round(deltaX / columnWidth)\n\n if (constraints.lockHorizontal && (edge === 'left' || edge === 'right')) {\n // Horizontal resize is locked\n } else {\n switch (edge) {\n case 'right': {\n // Increase/decrease colSpan from the right\n const newColSpan = currentPos.colSpan + columnDelta\n newPosition.colSpan = Math.max(1, Math.min(gridColumns - currentPos.colStart + 1, newColSpan))\n break\n }\n case 'left': {\n // Increase/decrease from left (changes both colStart and colSpan)\n const newColStart = currentPos.colStart + columnDelta\n const newColSpan = currentPos.colSpan - columnDelta\n if (newColStart >= 1 && newColSpan >= 1) {\n newPosition.colStart = newColStart\n newPosition.colSpan = newColSpan\n }\n break\n }\n case 'top':\n case 'bottom': {\n // Row resizing - calculate based on Y movement\n if (!constraints.lockVertical) {\n const rowHeight = 100 // Approximate row height\n const deltaY = e.clientY - start.y\n const rowDelta = Math.round(deltaY / rowHeight)\n\n if (edge === 'bottom') {\n const currentRowSpan = currentPos.rowSpan || 1\n const newRowSpan = currentRowSpan + rowDelta\n newPosition.rowSpan = Math.max(1, newRowSpan)\n } else if (edge === 'top') {\n const currentRowStart = currentPos.rowStart || 1\n const currentRowSpan = currentPos.rowSpan || 1\n const newRowStart = currentRowStart + rowDelta\n const newRowSpan = currentRowSpan - rowDelta\n if (newRowStart >= 1 && newRowSpan >= 1) {\n newPosition.rowStart = newRowStart\n newPosition.rowSpan = newRowSpan\n }\n }\n }\n break\n }\n }\n }\n\n // Apply constraints\n newPosition = applyConstraints(newPosition, constraints, gridColumns)\n\n setPreviewPosition(newPosition)\n onResizePreview?.(newPosition)\n }\n\n /**\n * Handle pointer up to finish resize\n */\n const handlePointerUp = (_e: PointerEvent) => {\n if (!isResizing()) return\n\n const preview = previewPosition()\n if (preview) {\n onResize(preview)\n }\n\n // Cleanup\n setIsResizing(false)\n setResizeEdge(null)\n setPreviewPosition(null)\n setStartPosition(null)\n setStartPointer(null)\n\n // Remove listeners\n document.removeEventListener('pointermove', handlePointerMove)\n document.removeEventListener('pointerup', handlePointerUp)\n document.body.style.cursor = ''\n document.body.style.userSelect = ''\n }\n\n /**\n * Start resize operation\n */\n const handleResizeStart = (e: PointerEvent, edge: ResizeEdge) => {\n if (!enabled) return\n\n e.preventDefault()\n e.stopPropagation()\n\n setIsResizing(true)\n setResizeEdge(edge)\n setStartPosition(currentPosition())\n setStartPointer({ x: e.clientX, y: e.clientY })\n setPreviewPosition(currentPosition())\n\n // Set cursor\n const cursors: Record<ResizeEdge, string> = {\n left: 'ew-resize',\n right: 'ew-resize',\n top: 'ns-resize',\n bottom: 'ns-resize'\n }\n document.body.style.cursor = cursors[edge]\n document.body.style.userSelect = 'none'\n\n // Add document listeners\n document.addEventListener('pointermove', handlePointerMove)\n document.addEventListener('pointerup', handlePointerUp)\n }\n\n /**\n * Get resize handle props for an edge\n */\n const getResizeHandleProps = (edge: ResizeEdge): ResizeHandleProps => {\n const baseStyle: Record<string, string> = {\n position: 'absolute',\n zIndex: '10'\n }\n\n const edgeStyles: Record<ResizeEdge, Record<string, string>> = {\n left: {\n ...baseStyle,\n left: '-4px',\n top: '0',\n width: '8px',\n height: '100%',\n cursor: 'ew-resize'\n },\n right: {\n ...baseStyle,\n right: '-4px',\n top: '0',\n width: '8px',\n height: '100%',\n cursor: 'ew-resize'\n },\n top: {\n ...baseStyle,\n top: '-4px',\n left: '0',\n width: '100%',\n height: '8px',\n cursor: 'ns-resize'\n },\n bottom: {\n ...baseStyle,\n bottom: '-4px',\n left: '0',\n width: '100%',\n height: '8px',\n cursor: 'ns-resize'\n }\n }\n\n return {\n onPointerDown: (e) => handleResizeStart(e, edge),\n style: edgeStyles[edge],\n 'data-resize-edge': edge\n }\n }\n\n // Cleanup on unmount\n onCleanup(() => {\n document.removeEventListener('pointermove', handlePointerMove)\n document.removeEventListener('pointerup', handlePointerUp)\n document.body.style.cursor = ''\n document.body.style.userSelect = ''\n })\n\n return {\n isResizing,\n resizeEdge,\n previewPosition,\n handleResizeStart,\n getResizeHandleProps\n }\n}\n"],"names":[],"mappings":";;AAuGA,SAAS,iBACP,UACA,aACA,aACc;AACd,MAAI,EAAE,UAAU,SAAS,UAAU,YAAY;AAG/C,QAAM,aAAa,YAAY,cAAc;AAC7C,QAAM,aAAa,YAAY,cAAc;AAE7C,YAAU,KAAK,IAAI,YAAY,KAAK,IAAI,YAAY,OAAO,CAAC;AAG5D,MAAI,WAAW,UAAU,IAAI,aAAa;AACxC,eAAW,cAAc,UAAU;AAAA,EACrC;AACA,aAAW,KAAK,IAAI,GAAG,QAAQ;AAG/B,MAAI,YAAY,QAAW;AACzB,UAAM,aAAa,YAAY,cAAc;AAC7C,UAAM,aAAa,YAAY,cAAc;AAC7C,cAAU,KAAK,IAAI,YAAY,KAAK,IAAI,YAAY,OAAO,CAAC;AAAA,EAC9D;AAEA,MAAI,aAAa,QAAW;AAC1B,eAAW,KAAK,IAAI,GAAG,QAAQ;AAAA,EACjC;AAEA,SAAO,EAAE,UAAU,SAAS,UAAU,QAAA;AACxC;AAKO,SAA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;AAAA,QACH,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,QAAQ;AAAA,MAAA;AAAA,IACV;AAGF,WAAO;AAAA,MACL,eAAe,CAAC,MAAM,kBAAkB,GAAG,IAAI;AAAA,MAC/C,OAAO,WAAW,IAAI;AAAA,MACtB,oBAAoB;AAAA,IAAA;AAAA,EAExB;AAGA,YAAU,MAAM;AACd,aAAS,oBAAoB,eAAe,iBAAiB;AAC7D,aAAS,oBAAoB,aAAa,eAAe;AACzD,aAAS,KAAK,MAAM,SAAS;AAC7B,aAAS,KAAK,MAAM,aAAa;AAAA,EACnC,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/dist/hooks.cjs
CHANGED
|
@@ -5,6 +5,9 @@ const useAction = require("./hooks/useAction.cjs");
|
|
|
5
5
|
const useConditionalField = require("./hooks/useConditionalField.cjs");
|
|
6
6
|
const useModal = require("./hooks/useModal.cjs");
|
|
7
7
|
const useFormPersistence = require("./hooks/useFormPersistence.cjs");
|
|
8
|
+
const useDragDrop = require("./hooks/useDragDrop.cjs");
|
|
9
|
+
const useResize = require("./hooks/useResize.cjs");
|
|
10
|
+
const useAutocomplete = require("./hooks/useAutocomplete.cjs");
|
|
8
11
|
exports.useStreamingUI = useStreamingUI.useStreamingUI;
|
|
9
12
|
exports.useAction = useAction.useAction;
|
|
10
13
|
exports.useToolAction = useAction.useToolAction;
|
|
@@ -13,4 +16,7 @@ exports.useConditionalField = useConditionalField.useConditionalField;
|
|
|
13
16
|
exports.useConfirmModal = useModal.useConfirmModal;
|
|
14
17
|
exports.useModal = useModal.useModal;
|
|
15
18
|
exports.useFormPersistence = useFormPersistence.useFormPersistence;
|
|
19
|
+
exports.useDragDrop = useDragDrop.useDragDrop;
|
|
20
|
+
exports.useResize = useResize.useResize;
|
|
21
|
+
exports.useAutocomplete = useAutocomplete.useAutocomplete;
|
|
16
22
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -13,4 +13,10 @@ export { useModal, useConfirmModal } from './useModal';
|
|
|
13
13
|
export type { UseModalReturn, UseConfirmModalReturn } from './useModal';
|
|
14
14
|
export { useFormPersistence } from './useFormPersistence';
|
|
15
15
|
export type { UseFormPersistenceOptions, UseFormPersistenceReturn } from './useFormPersistence';
|
|
16
|
+
export { useDragDrop } from './useDragDrop';
|
|
17
|
+
export type { UseDragDropOptions, UseDragDropReturn, DragProps, } from './useDragDrop';
|
|
18
|
+
export { useResize } from './useResize';
|
|
19
|
+
export type { UseResizeOptions, UseResizeReturn, ResizeEdge, ResizeHandleProps, } from './useResize';
|
|
20
|
+
export { useAutocomplete } from './useAutocomplete';
|
|
21
|
+
export type { UseAutocompleteOptions, UseAutocompleteReturn, } from './useAutocomplete';
|
|
16
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/hooks.d.ts
CHANGED
|
@@ -13,4 +13,10 @@ export { useModal, useConfirmModal } from './useModal';
|
|
|
13
13
|
export type { UseModalReturn, UseConfirmModalReturn } from './useModal';
|
|
14
14
|
export { useFormPersistence } from './useFormPersistence';
|
|
15
15
|
export type { UseFormPersistenceOptions, UseFormPersistenceReturn } from './useFormPersistence';
|
|
16
|
+
export { useDragDrop } from './useDragDrop';
|
|
17
|
+
export type { UseDragDropOptions, UseDragDropReturn, DragProps, } from './useDragDrop';
|
|
18
|
+
export { useResize } from './useResize';
|
|
19
|
+
export type { UseResizeOptions, UseResizeReturn, ResizeEdge, ResizeHandleProps, } from './useResize';
|
|
20
|
+
export { useAutocomplete } from './useAutocomplete';
|
|
21
|
+
export type { UseAutocompleteOptions, UseAutocompleteReturn, } from './useAutocomplete';
|
|
16
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/hooks.js
CHANGED
|
@@ -3,13 +3,19 @@ import { useAction, useToolAction } from "./hooks/useAction.js";
|
|
|
3
3
|
import { evaluateCondition, useConditionalField } from "./hooks/useConditionalField.js";
|
|
4
4
|
import { useConfirmModal, useModal } from "./hooks/useModal.js";
|
|
5
5
|
import { useFormPersistence } from "./hooks/useFormPersistence.js";
|
|
6
|
+
import { useDragDrop } from "./hooks/useDragDrop.js";
|
|
7
|
+
import { useResize } from "./hooks/useResize.js";
|
|
8
|
+
import { useAutocomplete } from "./hooks/useAutocomplete.js";
|
|
6
9
|
export {
|
|
7
10
|
evaluateCondition,
|
|
8
11
|
useAction,
|
|
12
|
+
useAutocomplete,
|
|
9
13
|
useConditionalField,
|
|
10
14
|
useConfirmModal,
|
|
15
|
+
useDragDrop,
|
|
11
16
|
useFormPersistence,
|
|
12
17
|
useModal,
|
|
18
|
+
useResize,
|
|
13
19
|
useStreamingUI,
|
|
14
20
|
useToolAction
|
|
15
21
|
};
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|