@seed-ship/mcp-ui-solid 6.17.0 → 6.18.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.
Files changed (156) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +50 -3
  3. package/dist/adapters/index.d.ts +2 -0
  4. package/dist/adapters/index.d.ts.map +1 -1
  5. package/dist/adapters/presentation.cjs +141 -0
  6. package/dist/adapters/presentation.cjs.map +1 -0
  7. package/dist/adapters/presentation.d.ts +68 -0
  8. package/dist/adapters/presentation.d.ts.map +1 -0
  9. package/dist/adapters/presentation.js +141 -0
  10. package/dist/adapters/presentation.js.map +1 -0
  11. package/dist/adapters.cjs +4 -0
  12. package/dist/adapters.cjs.map +1 -1
  13. package/dist/adapters.d.cts +2 -0
  14. package/dist/adapters.d.ts +2 -0
  15. package/dist/adapters.js +4 -0
  16. package/dist/adapters.js.map +1 -1
  17. package/dist/components/ChartJSRenderer.cjs +165 -65
  18. package/dist/components/ChartJSRenderer.cjs.map +1 -1
  19. package/dist/components/ChartJSRenderer.d.ts.map +1 -1
  20. package/dist/components/ChartJSRenderer.js +168 -68
  21. package/dist/components/ChartJSRenderer.js.map +1 -1
  22. package/dist/components/ComponentToolbar.cjs.map +1 -1
  23. package/dist/components/ComponentToolbar.d.ts.map +1 -1
  24. package/dist/components/ComponentToolbar.js.map +1 -1
  25. package/dist/components/EditableLayoutContext.cjs +17 -0
  26. package/dist/components/EditableLayoutContext.cjs.map +1 -0
  27. package/dist/components/EditableLayoutContext.d.ts +5 -0
  28. package/dist/components/EditableLayoutContext.d.ts.map +1 -0
  29. package/dist/components/EditableLayoutContext.js +17 -0
  30. package/dist/components/EditableLayoutContext.js.map +1 -0
  31. package/dist/components/EditableUIResourceRenderer.cjs +87 -84
  32. package/dist/components/EditableUIResourceRenderer.cjs.map +1 -1
  33. package/dist/components/EditableUIResourceRenderer.d.ts.map +1 -1
  34. package/dist/components/EditableUIResourceRenderer.js +87 -84
  35. package/dist/components/EditableUIResourceRenderer.js.map +1 -1
  36. package/dist/components/ElicitationForm.cjs.map +1 -1
  37. package/dist/components/ElicitationForm.js.map +1 -1
  38. package/dist/components/FeedbackInline.cjs +0 -1
  39. package/dist/components/FeedbackInline.cjs.map +1 -1
  40. package/dist/components/FeedbackInline.js +0 -1
  41. package/dist/components/FeedbackInline.js.map +1 -1
  42. package/dist/components/GraphRenderer.cjs.map +1 -1
  43. package/dist/components/GraphRenderer.d.ts.map +1 -1
  44. package/dist/components/GraphRenderer.js.map +1 -1
  45. package/dist/components/GridRenderer.cjs +12 -6
  46. package/dist/components/GridRenderer.cjs.map +1 -1
  47. package/dist/components/GridRenderer.d.ts.map +1 -1
  48. package/dist/components/GridRenderer.js +13 -7
  49. package/dist/components/GridRenderer.js.map +1 -1
  50. package/dist/components/MapRenderer.cjs.map +1 -1
  51. package/dist/components/MapRenderer.d.ts.map +1 -1
  52. package/dist/components/MapRenderer.js.map +1 -1
  53. package/dist/components/PresentationFeedback.cjs +0 -1
  54. package/dist/components/PresentationFeedback.cjs.map +1 -1
  55. package/dist/components/PresentationFeedback.js +0 -1
  56. package/dist/components/PresentationFeedback.js.map +1 -1
  57. package/dist/components/UIResourceRenderer.cjs +37 -22
  58. package/dist/components/UIResourceRenderer.cjs.map +1 -1
  59. package/dist/components/UIResourceRenderer.d.ts.map +1 -1
  60. package/dist/components/UIResourceRenderer.js +38 -23
  61. package/dist/components/UIResourceRenderer.js.map +1 -1
  62. package/dist/components/VerifiedText.cjs +0 -4
  63. package/dist/components/VerifiedText.cjs.map +1 -1
  64. package/dist/components/VerifiedText.d.ts.map +1 -1
  65. package/dist/components/VerifiedText.js +0 -4
  66. package/dist/components/VerifiedText.js.map +1 -1
  67. package/dist/components/chart-data-table.cjs +73 -0
  68. package/dist/components/chart-data-table.cjs.map +1 -0
  69. package/dist/components/chart-data-table.d.ts +23 -0
  70. package/dist/components/chart-data-table.d.ts.map +1 -0
  71. package/dist/components/chart-data-table.js +73 -0
  72. package/dist/components/chart-data-table.js.map +1 -0
  73. package/dist/context/MCPUIStringsContext.cjs +10 -9
  74. package/dist/context/MCPUIStringsContext.cjs.map +1 -1
  75. package/dist/context/MCPUIStringsContext.d.ts +17 -5
  76. package/dist/context/MCPUIStringsContext.d.ts.map +1 -1
  77. package/dist/context/MCPUIStringsContext.js +11 -10
  78. package/dist/context/MCPUIStringsContext.js.map +1 -1
  79. package/dist/hooks/createResponsiveGrid.cjs +37 -0
  80. package/dist/hooks/createResponsiveGrid.cjs.map +1 -0
  81. package/dist/hooks/createResponsiveGrid.d.ts +6 -0
  82. package/dist/hooks/createResponsiveGrid.d.ts.map +1 -0
  83. package/dist/hooks/createResponsiveGrid.js +37 -0
  84. package/dist/hooks/createResponsiveGrid.js.map +1 -0
  85. package/dist/index.cjs +1 -0
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.js +1 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/mcp-ui-spec/dist/schemas.cjs +13 -1
  90. package/dist/mcp-ui-spec/dist/schemas.cjs.map +1 -1
  91. package/dist/mcp-ui-spec/dist/schemas.js +13 -1
  92. package/dist/mcp-ui-spec/dist/schemas.js.map +1 -1
  93. package/dist/services/chat-bus.cjs.map +1 -1
  94. package/dist/services/chat-bus.d.ts.map +1 -1
  95. package/dist/services/chat-bus.js.map +1 -1
  96. package/dist/services/chat-prompt-controller.cjs.map +1 -1
  97. package/dist/services/chat-prompt-controller.d.ts.map +1 -1
  98. package/dist/services/chat-prompt-controller.js.map +1 -1
  99. package/dist/services/component-registry.cjs +162 -22
  100. package/dist/services/component-registry.cjs.map +1 -1
  101. package/dist/services/component-registry.d.ts +6 -3
  102. package/dist/services/component-registry.d.ts.map +1 -1
  103. package/dist/services/component-registry.js +162 -22
  104. package/dist/services/component-registry.js.map +1 -1
  105. package/dist/services/telemetry.cjs +0 -1
  106. package/dist/services/telemetry.cjs.map +1 -1
  107. package/dist/services/telemetry.js +0 -1
  108. package/dist/services/telemetry.js.map +1 -1
  109. package/dist/services/validation.cjs +21 -7
  110. package/dist/services/validation.cjs.map +1 -1
  111. package/dist/services/validation.d.ts.map +1 -1
  112. package/dist/services/validation.js +21 -7
  113. package/dist/services/validation.js.map +1 -1
  114. package/dist/types/index.d.ts +43 -8
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types.d.cts +43 -8
  117. package/dist/types.d.ts +43 -8
  118. package/docs/briefs/VISUALIZATION-FOUNDATION-2026-09-14.md +105 -0
  119. package/package.json +4 -4
  120. package/src/adapters/index.ts +18 -0
  121. package/src/adapters/presentation.test.ts +114 -0
  122. package/src/adapters/presentation.ts +229 -0
  123. package/src/components/ChartJSRenderer.test.tsx +325 -0
  124. package/src/components/ChartJSRenderer.tsx +162 -27
  125. package/src/components/ChatPrompt.test.tsx +1 -1
  126. package/src/components/ComponentToolbar.tsx +1 -1
  127. package/src/components/EditableLayoutContext.tsx +12 -0
  128. package/src/components/EditableUIResourceRenderer.tsx +11 -8
  129. package/src/components/ElicitationForm.tsx +1 -1
  130. package/src/components/FeedbackInline.tsx +1 -1
  131. package/src/components/GraphRenderer.test.tsx +1 -2
  132. package/src/components/GraphRenderer.tsx +0 -2
  133. package/src/components/GridRenderer.tsx +6 -4
  134. package/src/components/MapRenderer.tsx +0 -3
  135. package/src/components/PresentationFeedback.tsx +1 -1
  136. package/src/components/ResponsiveGrid.test.tsx +166 -0
  137. package/src/components/TableRenderer.pagination.test.tsx +31 -0
  138. package/src/components/UIResourceRenderer.tsx +14 -9
  139. package/src/components/VerifiedText.tsx +0 -5
  140. package/src/components/chart-data-table.ts +97 -0
  141. package/src/context/MCPUIStringsContext.test.tsx +60 -0
  142. package/src/context/MCPUIStringsContext.tsx +31 -12
  143. package/src/hooks/createResponsiveGrid.ts +41 -0
  144. package/src/services/chat-bus.test.ts +1 -1
  145. package/src/services/chat-bus.ts +0 -2
  146. package/src/services/chat-prompt-controller.ts +0 -8
  147. package/src/services/component-registry.test.ts +81 -2
  148. package/src/services/component-registry.ts +167 -23
  149. package/src/services/telemetry.ts +1 -1
  150. package/src/services/validation.test.ts +1 -14
  151. package/src/services/validation.ts +23 -6
  152. package/src/services/visualization-validation.test.ts +42 -0
  153. package/src/types/index.ts +50 -9
  154. package/src/types/visualization-contracts.test.ts +66 -0
  155. package/src/utils/perf.test.ts +3 -3
  156. package/tsconfig.tsbuildinfo +1 -1
@@ -6,6 +6,7 @@ const useDragDrop = require("../hooks/useDragDrop.cjs");
6
6
  const useResize = require("../hooks/useResize.cjs");
7
7
  const DraggableGridItem = require("./DraggableGridItem.cjs");
8
8
  const UIResourceRenderer = require("./UIResourceRenderer.cjs");
9
+ const EditableLayoutContext = require("./EditableLayoutContext.cjs");
9
10
  var _tmpl$ = /* @__PURE__ */ web.template(`<div class=mcp-grid-overlay style=position:absolute;inset:0;display:grid;gap:1rem;padding:0;pointer-events:none;z-index:0>`), _tmpl$2 = /* @__PURE__ */ web.template(`<div class=mcp-grid-overlay-column style="background-color:rgba(59, 130, 246, 0.05);border:1px dashed rgba(59, 130, 246, 0.2);border-radius:4px">`), _tmpl$3 = /* @__PURE__ */ web.template(`<div><div class="grid relative"data-grid-container><!$><!/><!$><!/>`);
10
11
  const GridOverlay = (props) => {
11
12
  return web.createComponent(solidJs.Show, {
@@ -109,90 +110,92 @@ const EditableUIResourceRenderer = (props) => {
109
110
  }
110
111
  });
111
112
  }
112
- return (() => {
113
- var _el$3 = web.getNextElement(_tmpl$3), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, [_el$6, _co$] = web.getNextMarker(_el$5.nextSibling), _el$7 = _el$6.nextSibling, [_el$8, _co$2] = web.getNextMarker(_el$7.nextSibling);
114
- web.use(setGridContainerRef, _el$4);
115
- web.insert(_el$4, web.createComponent(GridOverlay, {
116
- get columns() {
117
- return props.layout.grid.columns;
118
- },
119
- get visible() {
120
- return showOverlay();
121
- }
122
- }), _el$6, _co$);
123
- web.insert(_el$4, web.createComponent(solidJs.For, {
124
- get each() {
125
- return components();
126
- },
127
- children: (component) => {
128
- const resize = useResize.useResize({
129
- componentId: component.id,
130
- currentPosition: () => component.position,
131
- onResize: (pos) => handleResize(component.id, pos),
132
- onResizePreview: (pos) => handleResizePreview(component.id, pos),
133
- constraints: dragDropConfig().constraints,
134
- gridContainer: gridContainerRef,
135
- gridColumns: props.layout.grid.columns,
136
- enabled: dragDropConfig().enabled && dragDropConfig().resize
137
- });
138
- const effectivePosition = () => getEffectivePosition(component);
139
- return web.createComponent(DraggableGridItem.DraggableGridItem, {
140
- get id() {
141
- return component.id;
142
- },
143
- get position() {
144
- return effectivePosition();
145
- },
146
- get draggable() {
147
- return web.memo(() => !!dragDropConfig().enabled)() && dragDropConfig().reorder;
148
- },
149
- get resizable() {
150
- return web.memo(() => !!dragDropConfig().enabled)() && dragDropConfig().resize;
151
- },
152
- get constraints() {
153
- return dragDropConfig().constraints;
154
- },
155
- get isDragging() {
156
- return dragDrop.isComponentDragging(component.id);
157
- },
158
- get isDropTarget() {
159
- return dragDrop.isDropTarget(component.id);
160
- },
161
- get isResizing() {
162
- return activeResizeId() === component.id;
163
- },
164
- get previewPosition() {
165
- return previewPositions().get(component.id) || null;
166
- },
167
- get dragProps() {
168
- return dragDrop.getDragProps(component.id);
169
- },
170
- onResizeStart: (edge, event) => {
171
- setActiveResizeId(component.id);
172
- resize.handleResizeStart(event, edge);
173
- },
174
- get children() {
175
- return web.createComponent(UIResourceRenderer.UIResourceRenderer, {
176
- content: component,
177
- get onError() {
178
- return props.onError;
179
- }
180
- });
181
- }
182
- });
183
- }
184
- }), _el$8, _co$2);
185
- web.effect((_p$) => {
186
- var _v$ = `w-full editable-ui-renderer ${props.class || ""}`, _v$2 = gridContainerStyle();
187
- _v$ !== _p$.e && web.className(_el$3, _p$.e = _v$);
188
- _p$.t = web.style(_el$4, _v$2, _p$.t);
189
- return _p$;
190
- }, {
191
- e: void 0,
192
- t: void 0
193
- });
194
- return _el$3;
195
- })();
113
+ return web.createComponent(EditableLayoutContext.EditableLayoutProvider, {
114
+ get children() {
115
+ var _el$3 = web.getNextElement(_tmpl$3), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, [_el$6, _co$] = web.getNextMarker(_el$5.nextSibling), _el$7 = _el$6.nextSibling, [_el$8, _co$2] = web.getNextMarker(_el$7.nextSibling);
116
+ web.use(setGridContainerRef, _el$4);
117
+ web.insert(_el$4, web.createComponent(GridOverlay, {
118
+ get columns() {
119
+ return props.layout.grid.columns;
120
+ },
121
+ get visible() {
122
+ return showOverlay();
123
+ }
124
+ }), _el$6, _co$);
125
+ web.insert(_el$4, web.createComponent(solidJs.For, {
126
+ get each() {
127
+ return components();
128
+ },
129
+ children: (component) => {
130
+ const resize = useResize.useResize({
131
+ componentId: component.id,
132
+ currentPosition: () => component.position,
133
+ onResize: (pos) => handleResize(component.id, pos),
134
+ onResizePreview: (pos) => handleResizePreview(component.id, pos),
135
+ constraints: dragDropConfig().constraints,
136
+ gridContainer: gridContainerRef,
137
+ gridColumns: props.layout.grid.columns,
138
+ enabled: dragDropConfig().enabled && dragDropConfig().resize
139
+ });
140
+ const effectivePosition = () => getEffectivePosition(component);
141
+ return web.createComponent(DraggableGridItem.DraggableGridItem, {
142
+ get id() {
143
+ return component.id;
144
+ },
145
+ get position() {
146
+ return effectivePosition();
147
+ },
148
+ get draggable() {
149
+ return web.memo(() => !!dragDropConfig().enabled)() && dragDropConfig().reorder;
150
+ },
151
+ get resizable() {
152
+ return web.memo(() => !!dragDropConfig().enabled)() && dragDropConfig().resize;
153
+ },
154
+ get constraints() {
155
+ return dragDropConfig().constraints;
156
+ },
157
+ get isDragging() {
158
+ return dragDrop.isComponentDragging(component.id);
159
+ },
160
+ get isDropTarget() {
161
+ return dragDrop.isDropTarget(component.id);
162
+ },
163
+ get isResizing() {
164
+ return activeResizeId() === component.id;
165
+ },
166
+ get previewPosition() {
167
+ return previewPositions().get(component.id) || null;
168
+ },
169
+ get dragProps() {
170
+ return dragDrop.getDragProps(component.id);
171
+ },
172
+ onResizeStart: (edge, event) => {
173
+ setActiveResizeId(component.id);
174
+ resize.handleResizeStart(event, edge);
175
+ },
176
+ get children() {
177
+ return web.createComponent(UIResourceRenderer.UIResourceRenderer, {
178
+ content: component,
179
+ get onError() {
180
+ return props.onError;
181
+ }
182
+ });
183
+ }
184
+ });
185
+ }
186
+ }), _el$8, _co$2);
187
+ web.effect((_p$) => {
188
+ var _v$ = `w-full editable-ui-renderer ${props.class || ""}`, _v$2 = gridContainerStyle();
189
+ _v$ !== _p$.e && web.className(_el$3, _p$.e = _v$);
190
+ _p$.t = web.style(_el$4, _v$2, _p$.t);
191
+ return _p$;
192
+ }, {
193
+ e: void 0,
194
+ t: void 0
195
+ });
196
+ return _el$3;
197
+ }
198
+ });
196
199
  };
197
200
  exports.EditableUIResourceRenderer = EditableUIResourceRenderer;
198
201
  //# sourceMappingURL=EditableUIResourceRenderer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditableUIResourceRenderer.cjs","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"sourcesContent":["/**\n * EditableUIResourceRenderer Component\n * Extends UIResourceRenderer with drag-and-drop reordering and resizing capabilities\n *\n * Sprint Drag-Drop Feature\n */\n\nimport {\n Component,\n For,\n Show,\n createSignal,\n createMemo,\n createEffect,\n on,\n JSX\n} from 'solid-js'\nimport type {\n UIComponent,\n UILayout,\n RendererError,\n GridPosition,\n DragDropConfig\n} from '../types'\nimport { useDragDrop } from '../hooks/useDragDrop'\nimport { useResize, ResizeEdge } from '../hooks/useResize'\nimport { DraggableGridItem } from './DraggableGridItem'\nimport { UIResourceRenderer } from './UIResourceRenderer'\n\n/**\n * Props for EditableUIResourceRenderer\n */\nexport interface EditableUIResourceRendererProps {\n /**\n * Layout to render (must be UILayout, not single component)\n */\n layout: UILayout\n\n /**\n * Drag-drop configuration\n */\n dragDrop?: DragDropConfig\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Callback when layout changes (reorder or resize)\n */\n onLayoutChange?: (layout: UILayout) => void\n\n /**\n * Custom CSS class\n */\n class?: string\n\n /**\n * Show grid overlay during editing\n */\n showGridOverlay?: boolean\n}\n\n/**\n * Grid overlay component for visual feedback\n */\nconst GridOverlay: Component<{ columns: number; visible: boolean }> = (props) => {\n return (\n <Show when={props.visible}>\n <div\n class=\"mcp-grid-overlay\"\n style={{\n position: 'absolute',\n inset: '0',\n display: 'grid',\n 'grid-template-columns': `repeat(${props.columns}, 1fr)`,\n gap: '1rem',\n padding: '0',\n 'pointer-events': 'none',\n 'z-index': '0'\n }}\n >\n <For each={Array(props.columns).fill(0)}>\n {() => (\n <div\n class=\"mcp-grid-overlay-column\"\n style={{\n 'background-color': 'rgba(59, 130, 246, 0.05)',\n border: '1px dashed rgba(59, 130, 246, 0.2)',\n 'border-radius': '4px'\n }}\n />\n )}\n </For>\n </div>\n </Show>\n )\n}\n\n/**\n * EditableUIResourceRenderer Component\n */\nexport const EditableUIResourceRenderer: Component<EditableUIResourceRendererProps> = (props) => {\n // Internal state for components (allows editing)\n const [components, setComponents] = createSignal<UIComponent[]>(props.layout.components)\n const [activeResizeId, setActiveResizeId] = createSignal<string | null>(null)\n const [previewPositions, setPreviewPositions] = createSignal<Map<string, GridPosition>>(new Map())\n const [gridContainerRef, setGridContainerRef] = createSignal<HTMLElement | null>(null)\n\n // Sync with external layout changes\n createEffect(on(() => props.layout.components, (newComponents) => {\n setComponents(newComponents)\n }))\n\n // Drag-drop configuration\n const dragDropConfig = createMemo(() => ({\n enabled: props.dragDrop?.enabled ?? false,\n reorder: props.dragDrop?.reorder ?? true,\n resize: props.dragDrop?.resize ?? true,\n constraints: props.dragDrop?.constraints ?? {},\n showGridLines: props.dragDrop?.showGridLines ?? true,\n animationDuration: props.dragDrop?.animationDuration ?? 200\n }))\n\n // Handle reorder from drag-drop\n const handleReorder = (newComponents: UIComponent[]) => {\n setComponents(newComponents)\n\n const newLayout: UILayout = {\n ...props.layout,\n components: newComponents\n }\n\n props.dragDrop?.onReorder?.(newComponents)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize completion\n const handleResize = (componentId: string, newPosition: GridPosition) => {\n const updatedComponents = components().map(c =>\n c.id === componentId ? { ...c, position: newPosition } : c\n )\n\n setComponents(updatedComponents)\n setActiveResizeId(null)\n setPreviewPositions(new Map())\n\n const newLayout: UILayout = {\n ...props.layout,\n components: updatedComponents\n }\n\n props.dragDrop?.onResize?.(componentId, newPosition)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize preview\n const handleResizePreview = (componentId: string, previewPosition: GridPosition) => {\n setPreviewPositions(prev => {\n const next = new Map(prev)\n next.set(componentId, previewPosition)\n return next\n })\n }\n\n // Initialize drag-drop hook\n const dragDrop = useDragDrop({\n components,\n onReorder: handleReorder,\n enabled: dragDropConfig().enabled && dragDropConfig().reorder\n })\n\n // Grid container style\n const gridContainerStyle = createMemo((): JSX.CSSProperties => ({\n display: 'grid',\n 'grid-template-columns': `repeat(${props.layout.grid.columns}, 1fr)`,\n gap: props.layout.grid.gap,\n position: 'relative'\n }))\n\n // Check if we should show grid overlay\n const showOverlay = createMemo(() =>\n dragDropConfig().showGridLines && (dragDrop.isDragging() || activeResizeId() !== null)\n )\n\n // Get effective position for a component (preview if resizing, otherwise actual)\n const getEffectivePosition = (component: UIComponent): GridPosition => {\n const preview = previewPositions().get(component.id)\n return preview || component.position\n }\n\n // If drag-drop is not enabled, just render the standard UIResourceRenderer\n if (!props.dragDrop?.enabled) {\n return (\n <UIResourceRenderer\n content={props.layout}\n onError={props.onError}\n class={props.class}\n />\n )\n }\n\n return (\n <div class={`w-full editable-ui-renderer ${props.class || ''}`}>\n <div\n ref={setGridContainerRef}\n class=\"grid relative\"\n style={gridContainerStyle()}\n data-grid-container\n >\n {/* Grid overlay */}\n <GridOverlay\n columns={props.layout.grid.columns}\n visible={showOverlay()}\n />\n\n {/* Render components with drag-drop wrappers */}\n <For each={components()}>\n {(component) => {\n // Create resize hook for each component\n const resize = useResize({\n componentId: component.id,\n currentPosition: () => component.position,\n onResize: (pos) => handleResize(component.id, pos),\n onResizePreview: (pos) => handleResizePreview(component.id, pos),\n constraints: dragDropConfig().constraints,\n gridContainer: gridContainerRef,\n gridColumns: props.layout.grid.columns,\n enabled: dragDropConfig().enabled && dragDropConfig().resize\n })\n\n const effectivePosition = () => getEffectivePosition(component)\n\n return (\n <DraggableGridItem\n id={component.id}\n position={effectivePosition()}\n draggable={dragDropConfig().enabled && dragDropConfig().reorder}\n resizable={dragDropConfig().enabled && dragDropConfig().resize}\n constraints={dragDropConfig().constraints}\n isDragging={dragDrop.isComponentDragging(component.id)}\n isDropTarget={dragDrop.isDropTarget(component.id)}\n isResizing={activeResizeId() === component.id}\n previewPosition={previewPositions().get(component.id) || null}\n dragProps={dragDrop.getDragProps(component.id)}\n onResizeStart={(edge, event) => {\n setActiveResizeId(component.id)\n resize.handleResizeStart(event, edge as ResizeEdge)\n }}\n >\n {/* Render component using UIResourceRenderer for single component */}\n <UIResourceRenderer\n content={component}\n onError={props.onError}\n />\n </DraggableGridItem>\n )\n }}\n </For>\n </div>\n </div>\n )\n}\n\nexport default EditableUIResourceRenderer\n"],"names":["GridOverlay","props","_$createComponent","Show","when","visible","children","_el$","_$getNextElement","_tmpl$","_$insert","For","each","Array","columns","fill","_tmpl$2","_$effect","_$p","_$setStyleProperty","EditableUIResourceRenderer","components","setComponents","createSignal","layout","activeResizeId","setActiveResizeId","previewPositions","setPreviewPositions","Map","gridContainerRef","setGridContainerRef","createEffect","on","newComponents","dragDropConfig","createMemo","enabled","dragDrop","reorder","resize","constraints","showGridLines","animationDuration","handleReorder","newLayout","onReorder","onChange","onLayoutChange","handleResize","componentId","newPosition","updatedComponents","map","c","id","position","onResize","handleResizePreview","previewPosition","prev","next","set","useDragDrop","gridContainerStyle","display","grid","gap","showOverlay","isDragging","getEffectivePosition","component","preview","get","UIResourceRenderer","content","onError","class","_el$3","_tmpl$3","_el$4","firstChild","_el$5","_el$6","_co$","_$getNextMarker","nextSibling","_el$7","_el$8","_co$2","_$use","useResize","currentPosition","pos","onResizePreview","gridContainer","gridColumns","effectivePosition","DraggableGridItem","draggable","_$memo","resizable","isComponentDragging","isDropTarget","isResizing","dragProps","getDragProps","onResizeStart","edge","event","handleResizeStart","_p$","_v$","_v$2","e","_$className","t","_$style","undefined"],"mappings":";;;;;;;;;AAmEA,MAAMA,cAAiEC,CAAAA,UAAU;AAC/E,SAAAC,IAAAA,gBACGC,QAAAA,MAAI;AAAA,IAAA,IAACC,OAAI;AAAA,aAAEH,MAAMI;AAAAA,IAAO;AAAA,IAAA,IAAAC,WAAA;AAAA,UAAAC,OAAAC,IAAAA,eAAAC,MAAA;AAAAC,iBAAAH,MAAAL,IAAAA,gBAcpBS,aAAG;AAAA,QAAA,IAACC,OAAI;AAAA,iBAAEC,MAAMZ,MAAMa,OAAO,EAAEC,KAAK,CAAC;AAAA,QAAC;AAAA,QAAAT,UACpCA,MAAAE,IAAAA,eAAAQ,OAAA;AAAA,MAAA,CASA,CAAA;AAAAC,UAAAA,OAAAC,CAAAA,QAAAC,IAAAA,iBAAAZ,MAAA,yBAjBwB,UAAUN,MAAMa,OAAO,QAAQ,CAAA;AAAA,aAAAP;AAAAA,IAAA;AAAA,EAAA,CAAA;AAsBlE;AAKO,MAAMa,6BAA0EnB,CAAAA,UAAU;;AAE/F,QAAM,CAACoB,YAAYC,aAAa,IAAIC,QAAAA,aAA4BtB,MAAMuB,OAAOH,UAAU;AACvF,QAAM,CAACI,gBAAgBC,iBAAiB,IAAIH,QAAAA,aAA4B,IAAI;AAC5E,QAAM,CAACI,kBAAkBC,mBAAmB,IAAIL,QAAAA,aAAwC,oBAAIM,KAAK;AACjG,QAAM,CAACC,kBAAkBC,mBAAmB,IAAIR,QAAAA,aAAiC,IAAI;AAGrFS,UAAAA,aAAaC,QAAAA,GAAG,MAAMhC,MAAMuB,OAAOH,YAAaa,CAAAA,kBAAkB;AAChEZ,kBAAcY,aA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A,CAAC,GAAAY,OAAAC,KAAA;AAAAxE,QAAAA,OAAA8F,CAAAA,QAAA;AAAA,UAAAC,MAtDK,+BAA+B/G,MAAM4E,SAAS,EAAE,IAAEoC,OAInDjD,mBAAAA;AAAoBgD,cAAAD,IAAAG,KAAAC,IAAAA,UAAArC,OAAAiC,IAAAG,IAAAF,GAAA;AAAAD,UAAAK,IAAAC,IAAAA,MAAArC,OAAAiC,MAAAF,IAAAK,CAAA;AAAA,aAAAL;AAAAA,IAAA,GAAA;AAAA,MAAAG,GAAAI;AAAAA,MAAAF,GAAAE;AAAAA,IAAAA,CAAA;AAAA,WAAAxC;AAAAA,EAAA,GAAA;AAuDnC;;"}
1
+ {"version":3,"file":"EditableUIResourceRenderer.cjs","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"sourcesContent":["/**\n * EditableUIResourceRenderer Component\n * Extends UIResourceRenderer with drag-and-drop reordering and resizing capabilities\n *\n * Sprint Drag-Drop Feature\n */\n\nimport {\n Component,\n For,\n Show,\n createSignal,\n createMemo,\n createEffect,\n on,\n JSX\n} from 'solid-js'\nimport type {\n UIComponent,\n UILayout,\n RendererError,\n GridPosition,\n DragDropConfig\n} from '../types'\nimport { useDragDrop } from '../hooks/useDragDrop'\nimport { useResize, ResizeEdge } from '../hooks/useResize'\nimport { DraggableGridItem } from './DraggableGridItem'\nimport { UIResourceRenderer } from './UIResourceRenderer'\nimport { EditableLayoutProvider } from './EditableLayoutContext'\n\n/**\n * Props for EditableUIResourceRenderer\n */\nexport interface EditableUIResourceRendererProps {\n /**\n * Layout to render (must be UILayout, not single component)\n */\n layout: UILayout\n\n /**\n * Drag-drop configuration\n */\n dragDrop?: DragDropConfig\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Callback when layout changes (reorder or resize)\n */\n onLayoutChange?: (layout: UILayout) => void\n\n /**\n * Custom CSS class\n */\n class?: string\n\n /**\n * Show grid overlay during editing\n */\n showGridOverlay?: boolean\n}\n\n/**\n * Grid overlay component for visual feedback\n */\nconst GridOverlay: Component<{ columns: number; visible: boolean }> = (props) => {\n return (\n <Show when={props.visible}>\n <div\n class=\"mcp-grid-overlay\"\n style={{\n position: 'absolute',\n inset: '0',\n display: 'grid',\n 'grid-template-columns': `repeat(${props.columns}, 1fr)`,\n gap: '1rem',\n padding: '0',\n 'pointer-events': 'none',\n 'z-index': '0'\n }}\n >\n <For each={Array(props.columns).fill(0)}>\n {() => (\n <div\n class=\"mcp-grid-overlay-column\"\n style={{\n 'background-color': 'rgba(59, 130, 246, 0.05)',\n border: '1px dashed rgba(59, 130, 246, 0.2)',\n 'border-radius': '4px'\n }}\n />\n )}\n </For>\n </div>\n </Show>\n )\n}\n\n/**\n * EditableUIResourceRenderer Component\n */\nexport const EditableUIResourceRenderer: Component<EditableUIResourceRendererProps> = (props) => {\n // Internal state for components (allows editing)\n const [components, setComponents] = createSignal<UIComponent[]>(props.layout.components)\n const [activeResizeId, setActiveResizeId] = createSignal<string | null>(null)\n const [previewPositions, setPreviewPositions] = createSignal<Map<string, GridPosition>>(new Map())\n const [gridContainerRef, setGridContainerRef] = createSignal<HTMLElement | null>(null)\n\n // Sync with external layout changes\n createEffect(on(() => props.layout.components, (newComponents) => {\n setComponents(newComponents)\n }))\n\n // Drag-drop configuration\n const dragDropConfig = createMemo(() => ({\n enabled: props.dragDrop?.enabled ?? false,\n reorder: props.dragDrop?.reorder ?? true,\n resize: props.dragDrop?.resize ?? true,\n constraints: props.dragDrop?.constraints ?? {},\n showGridLines: props.dragDrop?.showGridLines ?? true,\n animationDuration: props.dragDrop?.animationDuration ?? 200\n }))\n\n // Handle reorder from drag-drop\n const handleReorder = (newComponents: UIComponent[]) => {\n setComponents(newComponents)\n\n const newLayout: UILayout = {\n ...props.layout,\n components: newComponents\n }\n\n props.dragDrop?.onReorder?.(newComponents)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize completion\n const handleResize = (componentId: string, newPosition: GridPosition) => {\n const updatedComponents = components().map(c =>\n c.id === componentId ? { ...c, position: newPosition } : c\n )\n\n setComponents(updatedComponents)\n setActiveResizeId(null)\n setPreviewPositions(new Map())\n\n const newLayout: UILayout = {\n ...props.layout,\n components: updatedComponents\n }\n\n props.dragDrop?.onResize?.(componentId, newPosition)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize preview\n const handleResizePreview = (componentId: string, previewPosition: GridPosition) => {\n setPreviewPositions(prev => {\n const next = new Map(prev)\n next.set(componentId, previewPosition)\n return next\n })\n }\n\n // Initialize drag-drop hook\n const dragDrop = useDragDrop({\n components,\n onReorder: handleReorder,\n enabled: dragDropConfig().enabled && dragDropConfig().reorder\n })\n\n // Grid container style\n const gridContainerStyle = createMemo((): JSX.CSSProperties => ({\n display: 'grid',\n 'grid-template-columns': `repeat(${props.layout.grid.columns}, 1fr)`,\n gap: props.layout.grid.gap,\n position: 'relative'\n }))\n\n // Check if we should show grid overlay\n const showOverlay = createMemo(() =>\n dragDropConfig().showGridLines && (dragDrop.isDragging() || activeResizeId() !== null)\n )\n\n // Get effective position for a component (preview if resizing, otherwise actual)\n const getEffectivePosition = (component: UIComponent): GridPosition => {\n const preview = previewPositions().get(component.id)\n return preview || component.position\n }\n\n // If drag-drop is not enabled, just render the standard UIResourceRenderer\n if (!props.dragDrop?.enabled) {\n return (\n <UIResourceRenderer\n content={props.layout}\n onError={props.onError}\n class={props.class}\n />\n )\n }\n\n return (\n <EditableLayoutProvider>\n <div class={`w-full editable-ui-renderer ${props.class || ''}`}>\n <div\n ref={setGridContainerRef}\n class=\"grid relative\"\n style={gridContainerStyle()}\n data-grid-container\n >\n {/* Grid overlay */}\n <GridOverlay\n columns={props.layout.grid.columns}\n visible={showOverlay()}\n />\n\n {/* Render components with drag-drop wrappers */}\n <For each={components()}>\n {(component) => {\n // Create resize hook for each component\n const resize = useResize({\n componentId: component.id,\n currentPosition: () => component.position,\n onResize: (pos) => handleResize(component.id, pos),\n onResizePreview: (pos) => handleResizePreview(component.id, pos),\n constraints: dragDropConfig().constraints,\n gridContainer: gridContainerRef,\n gridColumns: props.layout.grid.columns,\n enabled: dragDropConfig().enabled && dragDropConfig().resize\n })\n\n const effectivePosition = () => getEffectivePosition(component)\n\n return (\n <DraggableGridItem\n id={component.id}\n position={effectivePosition()}\n draggable={dragDropConfig().enabled && dragDropConfig().reorder}\n resizable={dragDropConfig().enabled && dragDropConfig().resize}\n constraints={dragDropConfig().constraints}\n isDragging={dragDrop.isComponentDragging(component.id)}\n isDropTarget={dragDrop.isDropTarget(component.id)}\n isResizing={activeResizeId() === component.id}\n previewPosition={previewPositions().get(component.id) || null}\n dragProps={dragDrop.getDragProps(component.id)}\n onResizeStart={(edge, event) => {\n setActiveResizeId(component.id)\n resize.handleResizeStart(event, edge as ResizeEdge)\n }}\n >\n {/* Render component using UIResourceRenderer for single component */}\n <UIResourceRenderer\n content={component}\n onError={props.onError}\n />\n </DraggableGridItem>\n )\n }}\n </For>\n </div>\n </div>\n </EditableLayoutProvider>\n )\n}\n\nexport default EditableUIResourceRenderer\n"],"names":["GridOverlay","props","_$createComponent","Show","when","visible","children","_el$","_$getNextElement","_tmpl$","_$insert","For","each","Array","columns","fill","_tmpl$2","_$effect","_$p","_$setStyleProperty","EditableUIResourceRenderer","components","setComponents","createSignal","layout","activeResizeId","setActiveResizeId","previewPositions","setPreviewPositions","Map","gridContainerRef","setGridContainerRef","createEffect","on","newComponents","dragDropConfig","createMemo","enabled","dragDrop","reorder","resize","constraints","showGridLines","animationDuration","handleReorder","newLayout","onReorder","onChange","onLayoutChange","handleResize","componentId","newPosition","updatedComponents","map","c","id","position","onResize","handleResizePreview","previewPosition","prev","next","set","useDragDrop","gridContainerStyle","display","grid","gap","showOverlay","isDragging","getEffectivePosition","component","preview","get","UIResourceRenderer","content","onError","class","EditableLayoutProvider","_el$3","_tmpl$3","_el$4","firstChild","_el$5","_el$6","_co$","_$getNextMarker","nextSibling","_el$7","_el$8","_co$2","_$use","useResize","currentPosition","pos","onResizePreview","gridContainer","gridColumns","effectivePosition","DraggableGridItem","draggable","_$memo","resizable","isComponentDragging","isDropTarget","isResizing","dragProps","getDragProps","onResizeStart","edge","event","handleResizeStart","_p$","_v$","_v$2","e","_$className","t","_$style","undefined"],"mappings":";;;;;;;;;;AAoEA,MAAMA,cAAiEC,CAAAA,UAAU;AAC/E,SAAAC,IAAAA,gBACGC,QAAAA,MAAI;AAAA,IAAA,IAACC,OAAI;AAAA,aAAEH,MAAMI;AAAAA,IAAO;AAAA,IAAA,IAAAC,WAAA;AAAA,UAAAC,OAAAC,IAAAA,eAAAC,MAAA;AAAAC,iBAAAH,MAAAL,IAAAA,gBAcpBS,aAAG;AAAA,QAAA,IAACC,OAAI;AAAA,iBAAEC,MAAMZ,MAAMa,OAAO,EAAEC,KAAK,CAAC;AAAA,QAAC;AAAA,QAAAT,UACpCA,MAAAE,IAAAA,eAAAQ,OAAA;AAAA,MAAA,CASA,CAAA;AAAAC,UAAAA,OAAAC,CAAAA,QAAAC,IAAAA,iBAAAZ,MAAA,yBAjBwB,UAAUN,MAAMa,OAAO,QAAQ,CAAA;AAAA,aAAAP;AAAAA,IAAA;AAAA,EAAA,CAAA;AAsBlE;AAKO,MAAMa,6BAA0EnB,CAAAA,UAAU;;AAE/F,QAAM,CAACoB,YAAYC,aAAa,IAAIC,QAAAA,aAA4BtB,MAAMuB,OAAOH,UAAU;AACvF,QAAM,CAACI,gBAAgBC,iBAAiB,IAAIH,QAAAA,aAA4B,IAAI;AAC5E,QAAM,CAACI,kBAAkBC,mBAAmB,IAAIL,QAAAA,aAAwC,oBAAIM,KAAK;AACjG,QAAM,CAACC,kBAAkBC,mBAAmB,IAAIR,QAAAA,aAAiC,IAAI;AAGrFS,UAAAA,aAAaC,QAAAA,GAAG,MAAMhC,MAAMuB,OAAOH,YAAaa,CAAAA,kBAAkB;AAChEZ,kBAAcY,aAAa;AAAA,EAC7B,CAAC,CAAC;AAGF,QAAMC,iBAA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AAAA,QAI9B;AAAA,MAAA,CAAC,GAAAa,OAAAC,KAAA;AAAAzE,UAAAA,OAAA+F,CAAAA,QAAA;AAAA,YAAAC,MAtDO,+BAA+BhH,MAAM4E,SAAS,EAAE,IAAEqC,OAInDlD,mBAAAA;AAAoBiD,gBAAAD,IAAAG,KAAAC,IAAAA,UAAArC,OAAAiC,IAAAG,IAAAF,GAAA;AAAAD,YAAAK,IAAAC,IAAAA,MAAArC,OAAAiC,MAAAF,IAAAK,CAAA;AAAA,eAAAL;AAAAA,MAAA,GAAA;AAAA,QAAAG,GAAAI;AAAAA,QAAAF,GAAAE;AAAAA,MAAAA,CAAA;AAAA,aAAAxC;AAAAA,IAAA;AAAA,EAAA,CAAA;AAwDrC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditableUIResourceRenderer.d.ts","sourceRoot":"","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EAQV,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,QAAQ,EACR,aAAa,EAEb,cAAc,EACf,MAAM,UAAU,CAAA;AAMjB;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAA;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAsCD;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,CAAC,+BAA+B,CAkKjF,CAAA;AAED,eAAe,0BAA0B,CAAA"}
1
+ {"version":3,"file":"EditableUIResourceRenderer.d.ts","sourceRoot":"","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EAQV,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAEV,QAAQ,EACR,aAAa,EAEb,cAAc,EACf,MAAM,UAAU,CAAA;AAOjB;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAA;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAsCD;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,CAAC,+BAA+B,CAoKjF,CAAA;AAED,eAAe,0BAA0B,CAAA"}
@@ -4,6 +4,7 @@ import { useDragDrop } from "../hooks/useDragDrop.js";
4
4
  import { useResize } from "../hooks/useResize.js";
5
5
  import { DraggableGridItem } from "./DraggableGridItem.js";
6
6
  import { UIResourceRenderer } from "./UIResourceRenderer.js";
7
+ import { EditableLayoutProvider } from "./EditableLayoutContext.js";
7
8
  var _tmpl$ = /* @__PURE__ */ template(`<div class=mcp-grid-overlay style=position:absolute;inset:0;display:grid;gap:1rem;padding:0;pointer-events:none;z-index:0>`), _tmpl$2 = /* @__PURE__ */ template(`<div class=mcp-grid-overlay-column style="background-color:rgba(59, 130, 246, 0.05);border:1px dashed rgba(59, 130, 246, 0.2);border-radius:4px">`), _tmpl$3 = /* @__PURE__ */ template(`<div><div class="grid relative"data-grid-container><!$><!/><!$><!/>`);
8
9
  const GridOverlay = (props) => {
9
10
  return createComponent(Show, {
@@ -107,90 +108,92 @@ const EditableUIResourceRenderer = (props) => {
107
108
  }
108
109
  });
109
110
  }
110
- return (() => {
111
- var _el$3 = getNextElement(_tmpl$3), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, [_el$6, _co$] = getNextMarker(_el$5.nextSibling), _el$7 = _el$6.nextSibling, [_el$8, _co$2] = getNextMarker(_el$7.nextSibling);
112
- use(setGridContainerRef, _el$4);
113
- insert(_el$4, createComponent(GridOverlay, {
114
- get columns() {
115
- return props.layout.grid.columns;
116
- },
117
- get visible() {
118
- return showOverlay();
119
- }
120
- }), _el$6, _co$);
121
- insert(_el$4, createComponent(For, {
122
- get each() {
123
- return components();
124
- },
125
- children: (component) => {
126
- const resize = useResize({
127
- componentId: component.id,
128
- currentPosition: () => component.position,
129
- onResize: (pos) => handleResize(component.id, pos),
130
- onResizePreview: (pos) => handleResizePreview(component.id, pos),
131
- constraints: dragDropConfig().constraints,
132
- gridContainer: gridContainerRef,
133
- gridColumns: props.layout.grid.columns,
134
- enabled: dragDropConfig().enabled && dragDropConfig().resize
135
- });
136
- const effectivePosition = () => getEffectivePosition(component);
137
- return createComponent(DraggableGridItem, {
138
- get id() {
139
- return component.id;
140
- },
141
- get position() {
142
- return effectivePosition();
143
- },
144
- get draggable() {
145
- return memo(() => !!dragDropConfig().enabled)() && dragDropConfig().reorder;
146
- },
147
- get resizable() {
148
- return memo(() => !!dragDropConfig().enabled)() && dragDropConfig().resize;
149
- },
150
- get constraints() {
151
- return dragDropConfig().constraints;
152
- },
153
- get isDragging() {
154
- return dragDrop.isComponentDragging(component.id);
155
- },
156
- get isDropTarget() {
157
- return dragDrop.isDropTarget(component.id);
158
- },
159
- get isResizing() {
160
- return activeResizeId() === component.id;
161
- },
162
- get previewPosition() {
163
- return previewPositions().get(component.id) || null;
164
- },
165
- get dragProps() {
166
- return dragDrop.getDragProps(component.id);
167
- },
168
- onResizeStart: (edge, event) => {
169
- setActiveResizeId(component.id);
170
- resize.handleResizeStart(event, edge);
171
- },
172
- get children() {
173
- return createComponent(UIResourceRenderer, {
174
- content: component,
175
- get onError() {
176
- return props.onError;
177
- }
178
- });
179
- }
180
- });
181
- }
182
- }), _el$8, _co$2);
183
- effect((_p$) => {
184
- var _v$ = `w-full editable-ui-renderer ${props.class || ""}`, _v$2 = gridContainerStyle();
185
- _v$ !== _p$.e && className(_el$3, _p$.e = _v$);
186
- _p$.t = style(_el$4, _v$2, _p$.t);
187
- return _p$;
188
- }, {
189
- e: void 0,
190
- t: void 0
191
- });
192
- return _el$3;
193
- })();
111
+ return createComponent(EditableLayoutProvider, {
112
+ get children() {
113
+ var _el$3 = getNextElement(_tmpl$3), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, [_el$6, _co$] = getNextMarker(_el$5.nextSibling), _el$7 = _el$6.nextSibling, [_el$8, _co$2] = getNextMarker(_el$7.nextSibling);
114
+ use(setGridContainerRef, _el$4);
115
+ insert(_el$4, createComponent(GridOverlay, {
116
+ get columns() {
117
+ return props.layout.grid.columns;
118
+ },
119
+ get visible() {
120
+ return showOverlay();
121
+ }
122
+ }), _el$6, _co$);
123
+ insert(_el$4, createComponent(For, {
124
+ get each() {
125
+ return components();
126
+ },
127
+ children: (component) => {
128
+ const resize = useResize({
129
+ componentId: component.id,
130
+ currentPosition: () => component.position,
131
+ onResize: (pos) => handleResize(component.id, pos),
132
+ onResizePreview: (pos) => handleResizePreview(component.id, pos),
133
+ constraints: dragDropConfig().constraints,
134
+ gridContainer: gridContainerRef,
135
+ gridColumns: props.layout.grid.columns,
136
+ enabled: dragDropConfig().enabled && dragDropConfig().resize
137
+ });
138
+ const effectivePosition = () => getEffectivePosition(component);
139
+ return createComponent(DraggableGridItem, {
140
+ get id() {
141
+ return component.id;
142
+ },
143
+ get position() {
144
+ return effectivePosition();
145
+ },
146
+ get draggable() {
147
+ return memo(() => !!dragDropConfig().enabled)() && dragDropConfig().reorder;
148
+ },
149
+ get resizable() {
150
+ return memo(() => !!dragDropConfig().enabled)() && dragDropConfig().resize;
151
+ },
152
+ get constraints() {
153
+ return dragDropConfig().constraints;
154
+ },
155
+ get isDragging() {
156
+ return dragDrop.isComponentDragging(component.id);
157
+ },
158
+ get isDropTarget() {
159
+ return dragDrop.isDropTarget(component.id);
160
+ },
161
+ get isResizing() {
162
+ return activeResizeId() === component.id;
163
+ },
164
+ get previewPosition() {
165
+ return previewPositions().get(component.id) || null;
166
+ },
167
+ get dragProps() {
168
+ return dragDrop.getDragProps(component.id);
169
+ },
170
+ onResizeStart: (edge, event) => {
171
+ setActiveResizeId(component.id);
172
+ resize.handleResizeStart(event, edge);
173
+ },
174
+ get children() {
175
+ return createComponent(UIResourceRenderer, {
176
+ content: component,
177
+ get onError() {
178
+ return props.onError;
179
+ }
180
+ });
181
+ }
182
+ });
183
+ }
184
+ }), _el$8, _co$2);
185
+ effect((_p$) => {
186
+ var _v$ = `w-full editable-ui-renderer ${props.class || ""}`, _v$2 = gridContainerStyle();
187
+ _v$ !== _p$.e && className(_el$3, _p$.e = _v$);
188
+ _p$.t = style(_el$4, _v$2, _p$.t);
189
+ return _p$;
190
+ }, {
191
+ e: void 0,
192
+ t: void 0
193
+ });
194
+ return _el$3;
195
+ }
196
+ });
194
197
  };
195
198
  export {
196
199
  EditableUIResourceRenderer
@@ -1 +1 @@
1
- {"version":3,"file":"EditableUIResourceRenderer.js","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"sourcesContent":["/**\n * EditableUIResourceRenderer Component\n * Extends UIResourceRenderer with drag-and-drop reordering and resizing capabilities\n *\n * Sprint Drag-Drop Feature\n */\n\nimport {\n Component,\n For,\n Show,\n createSignal,\n createMemo,\n createEffect,\n on,\n JSX\n} from 'solid-js'\nimport type {\n UIComponent,\n UILayout,\n RendererError,\n GridPosition,\n DragDropConfig\n} from '../types'\nimport { useDragDrop } from '../hooks/useDragDrop'\nimport { useResize, ResizeEdge } from '../hooks/useResize'\nimport { DraggableGridItem } from './DraggableGridItem'\nimport { UIResourceRenderer } from './UIResourceRenderer'\n\n/**\n * Props for EditableUIResourceRenderer\n */\nexport interface EditableUIResourceRendererProps {\n /**\n * Layout to render (must be UILayout, not single component)\n */\n layout: UILayout\n\n /**\n * Drag-drop configuration\n */\n dragDrop?: DragDropConfig\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Callback when layout changes (reorder or resize)\n */\n onLayoutChange?: (layout: UILayout) => void\n\n /**\n * Custom CSS class\n */\n class?: string\n\n /**\n * Show grid overlay during editing\n */\n showGridOverlay?: boolean\n}\n\n/**\n * Grid overlay component for visual feedback\n */\nconst GridOverlay: Component<{ columns: number; visible: boolean }> = (props) => {\n return (\n <Show when={props.visible}>\n <div\n class=\"mcp-grid-overlay\"\n style={{\n position: 'absolute',\n inset: '0',\n display: 'grid',\n 'grid-template-columns': `repeat(${props.columns}, 1fr)`,\n gap: '1rem',\n padding: '0',\n 'pointer-events': 'none',\n 'z-index': '0'\n }}\n >\n <For each={Array(props.columns).fill(0)}>\n {() => (\n <div\n class=\"mcp-grid-overlay-column\"\n style={{\n 'background-color': 'rgba(59, 130, 246, 0.05)',\n border: '1px dashed rgba(59, 130, 246, 0.2)',\n 'border-radius': '4px'\n }}\n />\n )}\n </For>\n </div>\n </Show>\n )\n}\n\n/**\n * EditableUIResourceRenderer Component\n */\nexport const EditableUIResourceRenderer: Component<EditableUIResourceRendererProps> = (props) => {\n // Internal state for components (allows editing)\n const [components, setComponents] = createSignal<UIComponent[]>(props.layout.components)\n const [activeResizeId, setActiveResizeId] = createSignal<string | null>(null)\n const [previewPositions, setPreviewPositions] = createSignal<Map<string, GridPosition>>(new Map())\n const [gridContainerRef, setGridContainerRef] = createSignal<HTMLElement | null>(null)\n\n // Sync with external layout changes\n createEffect(on(() => props.layout.components, (newComponents) => {\n setComponents(newComponents)\n }))\n\n // Drag-drop configuration\n const dragDropConfig = createMemo(() => ({\n enabled: props.dragDrop?.enabled ?? false,\n reorder: props.dragDrop?.reorder ?? true,\n resize: props.dragDrop?.resize ?? true,\n constraints: props.dragDrop?.constraints ?? {},\n showGridLines: props.dragDrop?.showGridLines ?? true,\n animationDuration: props.dragDrop?.animationDuration ?? 200\n }))\n\n // Handle reorder from drag-drop\n const handleReorder = (newComponents: UIComponent[]) => {\n setComponents(newComponents)\n\n const newLayout: UILayout = {\n ...props.layout,\n components: newComponents\n }\n\n props.dragDrop?.onReorder?.(newComponents)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize completion\n const handleResize = (componentId: string, newPosition: GridPosition) => {\n const updatedComponents = components().map(c =>\n c.id === componentId ? { ...c, position: newPosition } : c\n )\n\n setComponents(updatedComponents)\n setActiveResizeId(null)\n setPreviewPositions(new Map())\n\n const newLayout: UILayout = {\n ...props.layout,\n components: updatedComponents\n }\n\n props.dragDrop?.onResize?.(componentId, newPosition)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize preview\n const handleResizePreview = (componentId: string, previewPosition: GridPosition) => {\n setPreviewPositions(prev => {\n const next = new Map(prev)\n next.set(componentId, previewPosition)\n return next\n })\n }\n\n // Initialize drag-drop hook\n const dragDrop = useDragDrop({\n components,\n onReorder: handleReorder,\n enabled: dragDropConfig().enabled && dragDropConfig().reorder\n })\n\n // Grid container style\n const gridContainerStyle = createMemo((): JSX.CSSProperties => ({\n display: 'grid',\n 'grid-template-columns': `repeat(${props.layout.grid.columns}, 1fr)`,\n gap: props.layout.grid.gap,\n position: 'relative'\n }))\n\n // Check if we should show grid overlay\n const showOverlay = createMemo(() =>\n dragDropConfig().showGridLines && (dragDrop.isDragging() || activeResizeId() !== null)\n )\n\n // Get effective position for a component (preview if resizing, otherwise actual)\n const getEffectivePosition = (component: UIComponent): GridPosition => {\n const preview = previewPositions().get(component.id)\n return preview || component.position\n }\n\n // If drag-drop is not enabled, just render the standard UIResourceRenderer\n if (!props.dragDrop?.enabled) {\n return (\n <UIResourceRenderer\n content={props.layout}\n onError={props.onError}\n class={props.class}\n />\n )\n }\n\n return (\n <div class={`w-full editable-ui-renderer ${props.class || ''}`}>\n <div\n ref={setGridContainerRef}\n class=\"grid relative\"\n style={gridContainerStyle()}\n data-grid-container\n >\n {/* Grid overlay */}\n <GridOverlay\n columns={props.layout.grid.columns}\n visible={showOverlay()}\n />\n\n {/* Render components with drag-drop wrappers */}\n <For each={components()}>\n {(component) => {\n // Create resize hook for each component\n const resize = useResize({\n componentId: component.id,\n currentPosition: () => component.position,\n onResize: (pos) => handleResize(component.id, pos),\n onResizePreview: (pos) => handleResizePreview(component.id, pos),\n constraints: dragDropConfig().constraints,\n gridContainer: gridContainerRef,\n gridColumns: props.layout.grid.columns,\n enabled: dragDropConfig().enabled && dragDropConfig().resize\n })\n\n const effectivePosition = () => getEffectivePosition(component)\n\n return (\n <DraggableGridItem\n id={component.id}\n position={effectivePosition()}\n draggable={dragDropConfig().enabled && dragDropConfig().reorder}\n resizable={dragDropConfig().enabled && dragDropConfig().resize}\n constraints={dragDropConfig().constraints}\n isDragging={dragDrop.isComponentDragging(component.id)}\n isDropTarget={dragDrop.isDropTarget(component.id)}\n isResizing={activeResizeId() === component.id}\n previewPosition={previewPositions().get(component.id) || null}\n dragProps={dragDrop.getDragProps(component.id)}\n onResizeStart={(edge, event) => {\n setActiveResizeId(component.id)\n resize.handleResizeStart(event, edge as ResizeEdge)\n }}\n >\n {/* Render component using UIResourceRenderer for single component */}\n <UIResourceRenderer\n content={component}\n onError={props.onError}\n />\n </DraggableGridItem>\n )\n }}\n </For>\n </div>\n </div>\n )\n}\n\nexport default EditableUIResourceRenderer\n"],"names":["GridOverlay","props","_$createComponent","Show","when","visible","children","_el$","_$getNextElement","_tmpl$","_$insert","For","each","Array","columns","fill","_tmpl$2","_$effect","_$p","_$setStyleProperty","EditableUIResourceRenderer","components","setComponents","createSignal","layout","activeResizeId","setActiveResizeId","previewPositions","setPreviewPositions","Map","gridContainerRef","setGridContainerRef","createEffect","on","newComponents","dragDropConfig","createMemo","enabled","dragDrop","reorder","resize","constraints","showGridLines","animationDuration","handleReorder","newLayout","onReorder","onChange","onLayoutChange","handleResize","componentId","newPosition","updatedComponents","map","c","id","position","onResize","handleResizePreview","previewPosition","prev","next","set","useDragDrop","gridContainerStyle","display","grid","gap","showOverlay","isDragging","getEffectivePosition","component","preview","get","UIResourceRenderer","content","onError","class","_el$3","_tmpl$3","_el$4","firstChild","_el$5","_el$6","_co$","_$getNextMarker","nextSibling","_el$7","_el$8","_co$2","_$use","useResize","currentPosition","pos","onResizePreview","gridContainer","gridColumns","effectivePosition","DraggableGridItem","draggable","_$memo","resizable","isComponentDragging","isDropTarget","isResizing","dragProps","getDragProps","onResizeStart","edge","event","handleResizeStart","_p$","_v$","_v$2","e","_$className","t","_$style","undefined"],"mappings":";;;;;;;AAmEA,MAAMA,cAAiEC,CAAAA,UAAU;AAC/E,SAAAC,gBACGC,MAAI;AAAA,IAAA,IAACC,OAAI;AAAA,aAAEH,MAAMI;AAAAA,IAAO;AAAA,IAAA,IAAAC,WAAA;AAAA,UAAAC,OAAAC,eAAAC,MAAA;AAAAC,aAAAH,MAAAL,gBAcpBS,KAAG;AAAA,QAAA,IAACC,OAAI;AAAA,iBAAEC,MAAMZ,MAAMa,OAAO,EAAEC,KAAK,CAAC;AAAA,QAAC;AAAA,QAAAT,UACpCA,MAAAE,eAAAQ,OAAA;AAAA,MAAA,CASA,CAAA;AAAAC,aAAAC,CAAAA,QAAAC,iBAAAZ,MAAA,yBAjBwB,UAAUN,MAAMa,OAAO,QAAQ,CAAA;AAAA,aAAAP;AAAAA,IAAA;AAAA,EAAA,CAAA;AAsBlE;AAKO,MAAMa,6BAA0EnB,CAAAA,UAAU;;AAE/F,QAAM,CAACoB,YAAYC,aAAa,IAAIC,aAA4BtB,MAAMuB,OAAOH,UAAU;AACvF,QAAM,CAACI,gBAAgBC,iBAAiB,IAAIH,aAA4B,IAAI;AAC5E,QAAM,CAACI,kBAAkBC,mBAAmB,IA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,QAAA,CAAA;AAAA,MAI9B;AAAA,IAAA,CAAC,GAAAY,OAAAC,KAAA;AAAAxE,WAAA8F,CAAAA,QAAA;AAAA,UAAAC,MAtDK,+BAA+B/G,MAAM4E,SAAS,EAAE,IAAEoC,OAInDjD,mBAAAA;AAAoBgD,cAAAD,IAAAG,KAAAC,UAAArC,OAAAiC,IAAAG,IAAAF,GAAA;AAAAD,UAAAK,IAAAC,MAAArC,OAAAiC,MAAAF,IAAAK,CAAA;AAAA,aAAAL;AAAAA,IAAA,GAAA;AAAA,MAAAG,GAAAI;AAAAA,MAAAF,GAAAE;AAAAA,IAAAA,CAAA;AAAA,WAAAxC;AAAAA,EAAA,GAAA;AAuDnC;"}
1
+ {"version":3,"file":"EditableUIResourceRenderer.js","sources":["../../src/components/EditableUIResourceRenderer.tsx"],"sourcesContent":["/**\n * EditableUIResourceRenderer Component\n * Extends UIResourceRenderer with drag-and-drop reordering and resizing capabilities\n *\n * Sprint Drag-Drop Feature\n */\n\nimport {\n Component,\n For,\n Show,\n createSignal,\n createMemo,\n createEffect,\n on,\n JSX\n} from 'solid-js'\nimport type {\n UIComponent,\n UILayout,\n RendererError,\n GridPosition,\n DragDropConfig\n} from '../types'\nimport { useDragDrop } from '../hooks/useDragDrop'\nimport { useResize, ResizeEdge } from '../hooks/useResize'\nimport { DraggableGridItem } from './DraggableGridItem'\nimport { UIResourceRenderer } from './UIResourceRenderer'\nimport { EditableLayoutProvider } from './EditableLayoutContext'\n\n/**\n * Props for EditableUIResourceRenderer\n */\nexport interface EditableUIResourceRendererProps {\n /**\n * Layout to render (must be UILayout, not single component)\n */\n layout: UILayout\n\n /**\n * Drag-drop configuration\n */\n dragDrop?: DragDropConfig\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Callback when layout changes (reorder or resize)\n */\n onLayoutChange?: (layout: UILayout) => void\n\n /**\n * Custom CSS class\n */\n class?: string\n\n /**\n * Show grid overlay during editing\n */\n showGridOverlay?: boolean\n}\n\n/**\n * Grid overlay component for visual feedback\n */\nconst GridOverlay: Component<{ columns: number; visible: boolean }> = (props) => {\n return (\n <Show when={props.visible}>\n <div\n class=\"mcp-grid-overlay\"\n style={{\n position: 'absolute',\n inset: '0',\n display: 'grid',\n 'grid-template-columns': `repeat(${props.columns}, 1fr)`,\n gap: '1rem',\n padding: '0',\n 'pointer-events': 'none',\n 'z-index': '0'\n }}\n >\n <For each={Array(props.columns).fill(0)}>\n {() => (\n <div\n class=\"mcp-grid-overlay-column\"\n style={{\n 'background-color': 'rgba(59, 130, 246, 0.05)',\n border: '1px dashed rgba(59, 130, 246, 0.2)',\n 'border-radius': '4px'\n }}\n />\n )}\n </For>\n </div>\n </Show>\n )\n}\n\n/**\n * EditableUIResourceRenderer Component\n */\nexport const EditableUIResourceRenderer: Component<EditableUIResourceRendererProps> = (props) => {\n // Internal state for components (allows editing)\n const [components, setComponents] = createSignal<UIComponent[]>(props.layout.components)\n const [activeResizeId, setActiveResizeId] = createSignal<string | null>(null)\n const [previewPositions, setPreviewPositions] = createSignal<Map<string, GridPosition>>(new Map())\n const [gridContainerRef, setGridContainerRef] = createSignal<HTMLElement | null>(null)\n\n // Sync with external layout changes\n createEffect(on(() => props.layout.components, (newComponents) => {\n setComponents(newComponents)\n }))\n\n // Drag-drop configuration\n const dragDropConfig = createMemo(() => ({\n enabled: props.dragDrop?.enabled ?? false,\n reorder: props.dragDrop?.reorder ?? true,\n resize: props.dragDrop?.resize ?? true,\n constraints: props.dragDrop?.constraints ?? {},\n showGridLines: props.dragDrop?.showGridLines ?? true,\n animationDuration: props.dragDrop?.animationDuration ?? 200\n }))\n\n // Handle reorder from drag-drop\n const handleReorder = (newComponents: UIComponent[]) => {\n setComponents(newComponents)\n\n const newLayout: UILayout = {\n ...props.layout,\n components: newComponents\n }\n\n props.dragDrop?.onReorder?.(newComponents)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize completion\n const handleResize = (componentId: string, newPosition: GridPosition) => {\n const updatedComponents = components().map(c =>\n c.id === componentId ? { ...c, position: newPosition } : c\n )\n\n setComponents(updatedComponents)\n setActiveResizeId(null)\n setPreviewPositions(new Map())\n\n const newLayout: UILayout = {\n ...props.layout,\n components: updatedComponents\n }\n\n props.dragDrop?.onResize?.(componentId, newPosition)\n props.dragDrop?.onChange?.(newLayout)\n props.onLayoutChange?.(newLayout)\n }\n\n // Handle resize preview\n const handleResizePreview = (componentId: string, previewPosition: GridPosition) => {\n setPreviewPositions(prev => {\n const next = new Map(prev)\n next.set(componentId, previewPosition)\n return next\n })\n }\n\n // Initialize drag-drop hook\n const dragDrop = useDragDrop({\n components,\n onReorder: handleReorder,\n enabled: dragDropConfig().enabled && dragDropConfig().reorder\n })\n\n // Grid container style\n const gridContainerStyle = createMemo((): JSX.CSSProperties => ({\n display: 'grid',\n 'grid-template-columns': `repeat(${props.layout.grid.columns}, 1fr)`,\n gap: props.layout.grid.gap,\n position: 'relative'\n }))\n\n // Check if we should show grid overlay\n const showOverlay = createMemo(() =>\n dragDropConfig().showGridLines && (dragDrop.isDragging() || activeResizeId() !== null)\n )\n\n // Get effective position for a component (preview if resizing, otherwise actual)\n const getEffectivePosition = (component: UIComponent): GridPosition => {\n const preview = previewPositions().get(component.id)\n return preview || component.position\n }\n\n // If drag-drop is not enabled, just render the standard UIResourceRenderer\n if (!props.dragDrop?.enabled) {\n return (\n <UIResourceRenderer\n content={props.layout}\n onError={props.onError}\n class={props.class}\n />\n )\n }\n\n return (\n <EditableLayoutProvider>\n <div class={`w-full editable-ui-renderer ${props.class || ''}`}>\n <div\n ref={setGridContainerRef}\n class=\"grid relative\"\n style={gridContainerStyle()}\n data-grid-container\n >\n {/* Grid overlay */}\n <GridOverlay\n columns={props.layout.grid.columns}\n visible={showOverlay()}\n />\n\n {/* Render components with drag-drop wrappers */}\n <For each={components()}>\n {(component) => {\n // Create resize hook for each component\n const resize = useResize({\n componentId: component.id,\n currentPosition: () => component.position,\n onResize: (pos) => handleResize(component.id, pos),\n onResizePreview: (pos) => handleResizePreview(component.id, pos),\n constraints: dragDropConfig().constraints,\n gridContainer: gridContainerRef,\n gridColumns: props.layout.grid.columns,\n enabled: dragDropConfig().enabled && dragDropConfig().resize\n })\n\n const effectivePosition = () => getEffectivePosition(component)\n\n return (\n <DraggableGridItem\n id={component.id}\n position={effectivePosition()}\n draggable={dragDropConfig().enabled && dragDropConfig().reorder}\n resizable={dragDropConfig().enabled && dragDropConfig().resize}\n constraints={dragDropConfig().constraints}\n isDragging={dragDrop.isComponentDragging(component.id)}\n isDropTarget={dragDrop.isDropTarget(component.id)}\n isResizing={activeResizeId() === component.id}\n previewPosition={previewPositions().get(component.id) || null}\n dragProps={dragDrop.getDragProps(component.id)}\n onResizeStart={(edge, event) => {\n setActiveResizeId(component.id)\n resize.handleResizeStart(event, edge as ResizeEdge)\n }}\n >\n {/* Render component using UIResourceRenderer for single component */}\n <UIResourceRenderer\n content={component}\n onError={props.onError}\n />\n </DraggableGridItem>\n )\n }}\n </For>\n </div>\n </div>\n </EditableLayoutProvider>\n )\n}\n\nexport default EditableUIResourceRenderer\n"],"names":["GridOverlay","props","_$createComponent","Show","when","visible","children","_el$","_$getNextElement","_tmpl$","_$insert","For","each","Array","columns","fill","_tmpl$2","_$effect","_$p","_$setStyleProperty","EditableUIResourceRenderer","components","setComponents","createSignal","layout","activeResizeId","setActiveResizeId","previewPositions","setPreviewPositions","Map","gridContainerRef","setGridContainerRef","createEffect","on","newComponents","dragDropConfig","createMemo","enabled","dragDrop","reorder","resize","constraints","showGridLines","animationDuration","handleReorder","newLayout","onReorder","onChange","onLayoutChange","handleResize","componentId","newPosition","updatedComponents","map","c","id","position","onResize","handleResizePreview","previewPosition","prev","next","set","useDragDrop","gridContainerStyle","display","grid","gap","showOverlay","isDragging","getEffectivePosition","component","preview","get","UIResourceRenderer","content","onError","class","EditableLayoutProvider","_el$3","_tmpl$3","_el$4","firstChild","_el$5","_el$6","_co$","_$getNextMarker","nextSibling","_el$7","_el$8","_co$2","_$use","useResize","currentPosition","pos","onResizePreview","gridContainer","gridColumns","effectivePosition","DraggableGridItem","draggable","_$memo","resizable","isComponentDragging","isDropTarget","isResizing","dragProps","getDragProps","onResizeStart","edge","event","handleResizeStart","_p$","_v$","_v$2","e","_$className","t","_$style","undefined"],"mappings":";;;;;;;;AAoEA,MAAMA,cAAiEC,CAAAA,UAAU;AAC/E,SAAAC,gBACGC,MAAI;AAAA,IAAA,IAACC,OAAI;AAAA,aAAEH,MAAMI;AAAAA,IAAO;AAAA,IAAA,IAAAC,WAAA;AAAA,UAAAC,OAAAC,eAAAC,MAAA;AAAAC,aAAAH,MAAAL,gBAcpBS,KAAG;AAAA,QAAA,IAACC,OAAI;AAAA,iBAAEC,MAAMZ,MAAMa,OAAO,EAAEC,KAAK,CAAC;AAAA,QAAC;AAAA,QAAAT,UACpCA,MAAAE,eAAAQ,OAAA;AAAA,MAAA,CASA,CAAA;AAAAC,aAAAC,CAAAA,QAAAC,iBAAAZ,MAAA,yBAjBwB,UAAUN,MAAMa,OAAO,QAAQ,CAAA;AAAA,aAAAP;AAAAA,IAAA;AAAA,EAAA,CAAA;AAsBlE;AAKO,MAAMa,6BAA0EnB,CAAAA,UAAU;;AAE/F,QAAM,CAACoB,YAAYC,aAAa,IAAIC,aAA4BtB,MAAMuB,OAAOH,UAAU;AACvF,QAAM,CAACI,gBAAgBC,iBAAiB,IAAIH,aAA4B,IAAI;AAC5E,QAAM,CAACI,kBAAkBC,mBAAmB,IAAIL,aAAwC,oBAAIM,KAAK;AACjG,QAAM,CAACC,kBAAkBC,mBAAmB,IAAIR,aAAiC,IAAI;AAGrFS,eAAaC,GAAG,MAAMhC,MAAMuB,OAAOH,YAAaa,CAAAA,kBAAkB;AAChEZ,kBAAcY,aAAa;AAAA,EAC7B,CAAC,CAAC;AAGF,QAAMC,iBAAiBC,WAAW,MAAA;;AAAO;AAAA,MACvCC,WAASpC,MAAAA,MAAMqC,aAANrC,gBAAAA,IAAgBoC,Y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K,IAAAC,MAAArC,OAAAiC,MAAAF,IAAAK,CAAA;AAAA,eAAAL;AAAAA,MAAA,GAAA;AAAA,QAAAG,GAAAI;AAAAA,QAAAF,GAAAE;AAAAA,MAAAA,CAAA;AAAA,aAAAxC;AAAAA,IAAA;AAAA,EAAA,CAAA;AAwDrC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ElicitationForm.cjs","sources":["../../src/components/ElicitationForm.tsx"],"sourcesContent":["/**\n * ElicitationForm — schema-driven renderer for MCP `elicitation/create` requests\n *\n * @experimental\n * @since v5.3.0\n *\n * Thin wrapper over `<ChatPrompt>` + `elicitationToPromptConfig()` that\n * accepts a spec-shaped `ElicitationEvent` (MCP 2025-06-18) and exposes a\n * spec-shaped `onAccept(content)` callback whose payload is ready to send\n * back as the `accept` outcome of an `elicitation/create` reply.\n *\n * The mapping (boolean → confirm, single enum ≤4 → choice, else → form) is\n * delegated to the `elicitationToPromptConfig` helper — same rules, same\n * tests. This component owns the inverse mapping : extracting a spec-shaped\n * `Record<string, unknown>` from the `ChatPromptResponse`.\n *\n * ## Outcome semantics (per MCP spec 2025-06-18)\n *\n * | User action | Callback fired | Payload |\n * |---------------------------------------|--------------------|----------------------------------|\n * | Submit form / pick choice / confirm | `onAccept(content)`| `{ [propName]: value, ... }` |\n * | X icon / Cancel button | `onCancel()` *or* `onDecline()` if provided | none |\n *\n * mcp-ui's `<ChatPrompt>` does not natively distinguish \"decline\" (explicit\n * refusal) from \"cancel\" (passive close). To surface a decline action,\n * pass `dismissLabel=\"Decline\"` and route the callback via `onDecline`.\n *\n * @example\n * ```tsx\n * bus.events.on('onElicitation', ({ elicitation }) => {\n * render(() => (\n * <ElicitationForm\n * event={elicitation}\n * onAccept={(content) => sendElicitationReply({ action: 'accept', content })}\n * onCancel={() => sendElicitationReply({ action: 'cancel' })}\n * />\n * ), mountPoint)\n * })\n * ```\n */\n\nimport { Component } from 'solid-js'\nimport { ChatPrompt } from './ChatPrompt'\nimport { elicitationToPromptConfig } from '../services/chat-bus'\nimport type {\n ChatPromptResponse,\n ElicitationEvent,\n ElicitationPropertySchema,\n} from '../types/chat-bus'\n\nexport interface ElicitationFormProps {\n /** MCP `elicitation/create` request payload to render. */\n event: ElicitationEvent\n /**\n * Called when user submits a valid response. `content` is keyed by the\n * elicitation `requestedSchema.properties` names — ready to send back as\n * the `accept` outcome of an `elicitation/create` reply.\n */\n onAccept: (content: Record<string, unknown>) => void\n /** Called when user dismisses (X icon, confirm-cancel button). */\n onCancel?: () => void\n /**\n * Optional explicit decline action. When provided, takes precedence over\n * `onCancel` on dismiss. Pair with `dismissLabel=\"Decline\"` to surface as\n * a decline action in the UI.\n */\n onDecline?: () => void\n /** Label on the dismiss button (default: X icon). */\n dismissLabel?: string\n}\n\n/**\n * @experimental\n * Schema-driven renderer for MCP `elicitation/create` requests.\n */\nexport const ElicitationForm: Component<ElicitationFormProps> = (props) => {\n const config = () => elicitationToPromptConfig(props.event)\n\n const handleSubmit = (response: ChatPromptResponse): void => {\n if (response.dismissed) {\n ;(props.onDecline ?? props.onCancel)?.()\n return\n }\n props.onAccept(extractContent(response, props.event))\n }\n\n return <ChatPrompt config={config()} dismissLabel={props.dismissLabel} onSubmit={handleSubmit} />\n}\n\nfunction extractContent(\n response: ChatPromptResponse,\n event: ElicitationEvent\n): Record<string, unknown> {\n // Form: response.value is already a Record keyed by property names.\n if (typeof response.value !== 'string') {\n return response.value\n }\n\n const propEntries = Object.entries(event.requestedSchema.properties)\n\n // Single-property cases (boolean confirm or single enum choice).\n if (propEntries.length === 1) {\n const [name, schema] = propEntries[0]\n return { [name]: coerceScalar(response.value, schema) }\n }\n\n // Multi-property string response — shouldn't happen since the helper\n // routes multi-prop schemas to 'form'. Fall back gracefully.\n console.warn(\n '[MCP-UI] ElicitationForm: received string value for multi-property schema. Falling back to _value.'\n )\n return { _value: response.value }\n}\n\nfunction coerceScalar(value: string, schema: ElicitationPropertySchema): unknown {\n // Confirm always emits the literal 'confirmed' on accept (cancel path is\n // trapped earlier by `dismissed: true`). Map to boolean true.\n if (schema.type === 'boolean') return true\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const n = Number(value)\n return Number.isFinite(n) ? n : value\n }\n\n return value\n}\n"],"names":["ElicitationForm","props","config","elicitationToPromptConfig","event","handleSubmit","response","dismissed","onDecline","onCancel","onAccept","extractContent","_$createComponent","ChatPrompt","dismissLabel","onSubmit","value","propEntries","Object","entries","requestedSchema","properties","length","name","schema","coerceScalar","console","warn","_value","type","n","Number","isFinite"],"mappings":";;;;;AA2EO,MAAMA,kBAAoDC,CAAAA,UAAU;AACzE,QAAMC,SAASA,MAAMC,kCAA0BF,MAAMG,KAAK;AAE1D,QAAMC,eAAeA,CAACC,aAAuC;;AAC3D,QAAIA,SAASC,WAAW;AACrB,OAACN,WAAMO,aAAaP,MAAMQ,aAAzBR;AACF;AAAA,IACF;AACAA,UAAMS,SAASC,eAAeL,UAAUL,MAAMG,KAAK,CAAC;AAAA,EACtD;AAEA,SAAAQ,IAAAA,gBAAQC,WAAAA,YAAU;AAAA,IAAA,IAACX,SAAM;AAAA,aAAEA,OAAAA;AAAAA,IAAQ;AAAA,IAAA,IAAEY,eAAY;AAAA,aAAEb,MAAMa;AAAAA,IAAY;AAAA,IAAEC,UAAUV;AAAAA,EAAAA,CAAY;AAC/F;AAEA,SAASM,eACPL,UACAF,OACyB;AAEzB,MAAI,OAAOE,SAASU,UAAU,UAAU;AACtC,WAAOV,SAASU;AAAAA,EAClB;AAEA,QAAMC,cAAcC,OAAOC,QAAQf,MAAMgB,gBAAgBC,UAAU;AAGnE,MAAIJ,YAAYK,WAAW,GAAG;AAC5B,UAAM,CAACC,MAAMC,MAAM,IAAIP,YAAY,CAAC;AACpC,WAAO;AAAA,MAAE,CAACM,IAAI,GAAGE,aAAanB,SAASU,OAAOQ,MAAM;AAAA,IAAA;AAAA,EACtD;AAIAE,UAAQC,KACN,oGACF;AACA,SAAO;AAAA,IAAEC,QAAQtB,SAASU;AAAAA,EAAAA;AAC5B;AAEA,SAASS,aAAaT,OAAeQ,QAA4C;AAG/E,MAAIA,OAAOK,SAAS,UAAW,QAAO;AAEtC,MAAIL,OAAOK,SAAS,YAAYL,OAAOK,SAAS,WAAW;AACzD,UAAMC,IAAIC,OAAOf,KAAK;AACtB,WAAOe,OAAOC,SAASF,CAAC,IAAIA,IAAId;AAAAA,EAClC;AAEA,SAAOA;AACT;;"}
1
+ {"version":3,"file":"ElicitationForm.cjs","sources":["../../src/components/ElicitationForm.tsx"],"sourcesContent":["/**\n * ElicitationForm — schema-driven renderer for MCP `elicitation/create` requests\n *\n * @experimental\n * @since v5.3.0\n *\n * Thin wrapper over `<ChatPrompt>` + `elicitationToPromptConfig()` that\n * accepts a spec-shaped `ElicitationEvent` (MCP 2025-06-18) and exposes a\n * spec-shaped `onAccept(content)` callback whose payload is ready to send\n * back as the `accept` outcome of an `elicitation/create` reply.\n *\n * The mapping (boolean → confirm, single enum ≤4 → choice, else → form) is\n * delegated to the `elicitationToPromptConfig` helper — same rules, same\n * tests. This component owns the inverse mapping : extracting a spec-shaped\n * `Record<string, unknown>` from the `ChatPromptResponse`.\n *\n * ## Outcome semantics (per MCP spec 2025-06-18)\n *\n * | User action | Callback fired | Payload |\n * |---------------------------------------|--------------------|----------------------------------|\n * | Submit form / pick choice / confirm | `onAccept(content)`| `{ [propName]: value, ... }` |\n * | X icon / Cancel button | `onCancel()` *or* `onDecline()` if provided | none |\n *\n * mcp-ui's `<ChatPrompt>` does not natively distinguish \"decline\" (explicit\n * refusal) from \"cancel\" (passive close). To surface a decline action,\n * pass `dismissLabel=\"Decline\"` and route the callback via `onDecline`.\n *\n * @example\n * ```tsx\n * bus.events.on('onElicitation', ({ elicitation }) => {\n * render(() => (\n * <ElicitationForm\n * event={elicitation}\n * onAccept={(content) => sendElicitationReply({ action: 'accept', content })}\n * onCancel={() => sendElicitationReply({ action: 'cancel' })}\n * />\n * ), mountPoint)\n * })\n * ```\n */\n\nimport { Component } from 'solid-js'\nimport { ChatPrompt } from './ChatPrompt'\nimport { elicitationToPromptConfig } from '../services/chat-bus'\nimport type {\n ChatPromptResponse,\n ElicitationEvent,\n ElicitationPropertySchema,\n} from '../types/chat-bus'\n\nexport interface ElicitationFormProps {\n /** MCP `elicitation/create` request payload to render. */\n event: ElicitationEvent\n /**\n * Called when user submits a valid response. `content` is keyed by the\n * elicitation `requestedSchema.properties` names — ready to send back as\n * the `accept` outcome of an `elicitation/create` reply.\n */\n onAccept: (content: Record<string, unknown>) => void\n /** Called when user dismisses (X icon, confirm-cancel button). */\n onCancel?: () => void\n /**\n * Optional explicit decline action. When provided, takes precedence over\n * `onCancel` on dismiss. Pair with `dismissLabel=\"Decline\"` to surface as\n * a decline action in the UI.\n */\n onDecline?: () => void\n /** Label on the dismiss button (default: X icon). */\n dismissLabel?: string\n}\n\n/**\n * @experimental\n * Schema-driven renderer for MCP `elicitation/create` requests.\n */\nexport const ElicitationForm: Component<ElicitationFormProps> = (props) => {\n const config = () => elicitationToPromptConfig(props.event)\n\n const handleSubmit = (response: ChatPromptResponse): void => {\n if (response.dismissed) {\n (props.onDecline ?? props.onCancel)?.()\n return\n }\n props.onAccept(extractContent(response, props.event))\n }\n\n return <ChatPrompt config={config()} dismissLabel={props.dismissLabel} onSubmit={handleSubmit} />\n}\n\nfunction extractContent(\n response: ChatPromptResponse,\n event: ElicitationEvent\n): Record<string, unknown> {\n // Form: response.value is already a Record keyed by property names.\n if (typeof response.value !== 'string') {\n return response.value\n }\n\n const propEntries = Object.entries(event.requestedSchema.properties)\n\n // Single-property cases (boolean confirm or single enum choice).\n if (propEntries.length === 1) {\n const [name, schema] = propEntries[0]\n return { [name]: coerceScalar(response.value, schema) }\n }\n\n // Multi-property string response — shouldn't happen since the helper\n // routes multi-prop schemas to 'form'. Fall back gracefully.\n console.warn(\n '[MCP-UI] ElicitationForm: received string value for multi-property schema. Falling back to _value.'\n )\n return { _value: response.value }\n}\n\nfunction coerceScalar(value: string, schema: ElicitationPropertySchema): unknown {\n // Confirm always emits the literal 'confirmed' on accept (cancel path is\n // trapped earlier by `dismissed: true`). Map to boolean true.\n if (schema.type === 'boolean') return true\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const n = Number(value)\n return Number.isFinite(n) ? n : value\n }\n\n return value\n}\n"],"names":["ElicitationForm","props","config","elicitationToPromptConfig","event","handleSubmit","response","dismissed","onDecline","onCancel","onAccept","extractContent","_$createComponent","ChatPrompt","dismissLabel","onSubmit","value","propEntries","Object","entries","requestedSchema","properties","length","name","schema","coerceScalar","console","warn","_value","type","n","Number","isFinite"],"mappings":";;;;;AA2EO,MAAMA,kBAAoDC,CAAAA,UAAU;AACzE,QAAMC,SAASA,MAAMC,kCAA0BF,MAAMG,KAAK;AAE1D,QAAMC,eAAeA,CAACC,aAAuC;;AAC3D,QAAIA,SAASC,WAAW;AACtB,OAACN,WAAMO,aAAaP,MAAMQ,aAAzBR;AACD;AAAA,IACF;AACAA,UAAMS,SAASC,eAAeL,UAAUL,MAAMG,KAAK,CAAC;AAAA,EACtD;AAEA,SAAAQ,IAAAA,gBAAQC,WAAAA,YAAU;AAAA,IAAA,IAACX,SAAM;AAAA,aAAEA,OAAAA;AAAAA,IAAQ;AAAA,IAAA,IAAEY,eAAY;AAAA,aAAEb,MAAMa;AAAAA,IAAY;AAAA,IAAEC,UAAUV;AAAAA,EAAAA,CAAY;AAC/F;AAEA,SAASM,eACPL,UACAF,OACyB;AAEzB,MAAI,OAAOE,SAASU,UAAU,UAAU;AACtC,WAAOV,SAASU;AAAAA,EAClB;AAEA,QAAMC,cAAcC,OAAOC,QAAQf,MAAMgB,gBAAgBC,UAAU;AAGnE,MAAIJ,YAAYK,WAAW,GAAG;AAC5B,UAAM,CAACC,MAAMC,MAAM,IAAIP,YAAY,CAAC;AACpC,WAAO;AAAA,MAAE,CAACM,IAAI,GAAGE,aAAanB,SAASU,OAAOQ,MAAM;AAAA,IAAA;AAAA,EACtD;AAIAE,UAAQC,KACN,oGACF;AACA,SAAO;AAAA,IAAEC,QAAQtB,SAASU;AAAAA,EAAAA;AAC5B;AAEA,SAASS,aAAaT,OAAeQ,QAA4C;AAG/E,MAAIA,OAAOK,SAAS,UAAW,QAAO;AAEtC,MAAIL,OAAOK,SAAS,YAAYL,OAAOK,SAAS,WAAW;AACzD,UAAMC,IAAIC,OAAOf,KAAK;AACtB,WAAOe,OAAOC,SAASF,CAAC,IAAIA,IAAId;AAAAA,EAClC;AAEA,SAAOA;AACT;;"}