@seed-ship/mcp-ui-solid 6.0.0 → 6.2.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 (61) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/dist/components/CarouselRenderer.cjs +41 -30
  3. package/dist/components/CarouselRenderer.cjs.map +1 -1
  4. package/dist/components/CarouselRenderer.d.ts.map +1 -1
  5. package/dist/components/CarouselRenderer.js +42 -31
  6. package/dist/components/CarouselRenderer.js.map +1 -1
  7. package/dist/components/ChartJSRenderer.cjs +27 -7
  8. package/dist/components/ChartJSRenderer.cjs.map +1 -1
  9. package/dist/components/ChartJSRenderer.d.ts.map +1 -1
  10. package/dist/components/ChartJSRenderer.js +29 -9
  11. package/dist/components/ChartJSRenderer.js.map +1 -1
  12. package/dist/components/CodeBlockRenderer.cjs +88 -25
  13. package/dist/components/CodeBlockRenderer.cjs.map +1 -1
  14. package/dist/components/CodeBlockRenderer.d.ts.map +1 -1
  15. package/dist/components/CodeBlockRenderer.js +89 -26
  16. package/dist/components/CodeBlockRenderer.js.map +1 -1
  17. package/dist/components/ExpandableWrapper.cjs +1 -1
  18. package/dist/components/ExpandableWrapper.cjs.map +1 -1
  19. package/dist/components/ExpandableWrapper.d.ts.map +1 -1
  20. package/dist/components/ExpandableWrapper.js +1 -1
  21. package/dist/components/ExpandableWrapper.js.map +1 -1
  22. package/dist/components/GraphRenderer.cjs +7 -4
  23. package/dist/components/GraphRenderer.cjs.map +1 -1
  24. package/dist/components/GraphRenderer.d.ts.map +1 -1
  25. package/dist/components/GraphRenderer.js +8 -5
  26. package/dist/components/GraphRenderer.js.map +1 -1
  27. package/dist/components/ImageGalleryRenderer.cjs +101 -77
  28. package/dist/components/ImageGalleryRenderer.cjs.map +1 -1
  29. package/dist/components/ImageGalleryRenderer.d.ts.map +1 -1
  30. package/dist/components/ImageGalleryRenderer.js +102 -78
  31. package/dist/components/ImageGalleryRenderer.js.map +1 -1
  32. package/dist/components/MapRenderer.cjs +94 -34
  33. package/dist/components/MapRenderer.cjs.map +1 -1
  34. package/dist/components/MapRenderer.d.ts.map +1 -1
  35. package/dist/components/MapRenderer.js +107 -47
  36. package/dist/components/MapRenderer.js.map +1 -1
  37. package/dist/components/UIResourceRenderer.cjs +66 -54
  38. package/dist/components/UIResourceRenderer.cjs.map +1 -1
  39. package/dist/components/UIResourceRenderer.d.ts.map +1 -1
  40. package/dist/components/UIResourceRenderer.js +66 -54
  41. package/dist/components/UIResourceRenderer.js.map +1 -1
  42. package/dist/components/VideoRenderer.cjs +95 -74
  43. package/dist/components/VideoRenderer.cjs.map +1 -1
  44. package/dist/components/VideoRenderer.d.ts.map +1 -1
  45. package/dist/components/VideoRenderer.js +96 -75
  46. package/dist/components/VideoRenderer.js.map +1 -1
  47. package/dist/index.cjs +3 -3
  48. package/dist/index.js +1 -1
  49. package/package.json +1 -1
  50. package/src/components/CarouselRenderer.tsx +9 -1
  51. package/src/components/ChartJSRenderer.tsx +30 -8
  52. package/src/components/CodeBlockRenderer.tsx +65 -5
  53. package/src/components/ExpandableWrapper.tsx +7 -2
  54. package/src/components/GraphRenderer.tsx +13 -4
  55. package/src/components/ImageGalleryRenderer.test.tsx +18 -7
  56. package/src/components/ImageGalleryRenderer.tsx +22 -3
  57. package/src/components/MapRenderer.tsx +68 -14
  58. package/src/components/UIResourceRenderer.fluidity.test.tsx +101 -0
  59. package/src/components/UIResourceRenderer.tsx +23 -9
  60. package/src/components/VideoRenderer.tsx +14 -4
  61. package/tsconfig.tsbuildinfo +1 -1
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { Component, createEffect, onCleanup, createSignal, Show } from 'solid-js'
12
12
  import type { UIComponent, ChartComponentParams } from '../types'
13
- import { ExpandableWrapper } from './ExpandableWrapper'
13
+ import { ExpandableWrapper, useExpanded } from './ExpandableWrapper'
14
14
 
15
15
  // Lazy load Chart.js to avoid bundling if not used
16
16
  let ChartJS: any = null
@@ -87,6 +87,16 @@ export const ChartJSRenderer: Component<ChartJSRendererProps> = (props) => {
87
87
  let chartInstance: any
88
88
 
89
89
  const params = () => props.component.params as ChartComponentParams
90
+ const isExpanded = useExpanded()
91
+
92
+ // v6.1.0 — export visibility :
93
+ // - undefined / true → button shown (new default, was opt-in)
94
+ // - false → button hidden (explicit opt-out, unchanged)
95
+ const exportEnabled = () => params().exportable !== false
96
+
97
+ // v6.1.0 — copy data for the ExpandableWrapper modal-header copy button.
98
+ // Lazy-stringified each time the button is clicked.
99
+ const copyDataJSON = () => JSON.stringify({ type: params().type, data: params().data }, null, 2)
90
100
 
91
101
  // Chart PNG export
92
102
  const handleExportPNG = () => {
@@ -176,16 +186,22 @@ export const ChartJSRenderer: Component<ChartJSRendererProps> = (props) => {
176
186
  })
177
187
 
178
188
  return (
179
- <ExpandableWrapper title={params().title || 'Chart'}>
180
- <div class="relative w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden p-4 group">
181
- <Show when={params().title || params().exportable}>
182
- <div class="flex items-center justify-between mb-3">
189
+ <ExpandableWrapper
190
+ title={params().title || 'Chart'}
191
+ copyData={copyDataJSON()}
192
+ copyLabel="Copy chart data (JSON)"
193
+ >
194
+ <div class={`relative w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden p-4 group ${
195
+ isExpanded() ? 'flex-1 min-h-0 flex flex-col' : ''
196
+ }`}>
197
+ <Show when={params().title || exportEnabled()}>
198
+ <div class="flex items-center justify-between mb-3 flex-shrink-0">
183
199
  <Show when={params().title}>
184
200
  <h3 class="text-sm font-semibold text-gray-900 dark:text-white">
185
201
  {params().title}
186
202
  </h3>
187
203
  </Show>
188
- <Show when={params().exportable}>
204
+ <Show when={exportEnabled()}>
189
205
  <button
190
206
  onClick={handleExportPNG}
191
207
  class="opacity-0 group-hover:opacity-60 hover:!opacity-100 px-2 py-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-all shadow-sm"
@@ -234,8 +250,14 @@ export const ChartJSRenderer: Component<ChartJSRendererProps> = (props) => {
234
250
  </Show>
235
251
 
236
252
  <div
237
- class="w-full"
238
- style={{ height: params().height || '250px', display: error() ? 'none' : 'block' }}
253
+ class={`w-full ${isExpanded() ? 'flex-1 min-h-0' : ''}`}
254
+ style={
255
+ error()
256
+ ? { display: 'none' }
257
+ : isExpanded()
258
+ ? { height: '100%', display: 'block' }
259
+ : { height: params().height || '250px', display: 'block' }
260
+ }
239
261
  >
240
262
  <canvas ref={canvasRef} />
241
263
  </div>
@@ -7,7 +7,18 @@
7
7
  import { Component, createEffect, onCleanup, createSignal, Show, For } from 'solid-js'
8
8
  import { isServer } from 'solid-js/web'
9
9
  import type { UIComponent, CodeComponentParams } from '../types'
10
- import { ExpandableWrapper } from './ExpandableWrapper'
10
+ import { ExpandableWrapper, useExpanded } from './ExpandableWrapper'
11
+ import { highlightQuery } from './UIResourceRenderer'
12
+
13
+ /** Map of `params.language` → file extension for the v6.2.0 download button. */
14
+ const LANGUAGE_EXTENSIONS: Record<string, string> = {
15
+ typescript: 'ts', tsx: 'tsx', javascript: 'js', jsx: 'jsx',
16
+ python: 'py', ruby: 'rb', go: 'go', rust: 'rs', java: 'java',
17
+ kotlin: 'kt', swift: 'swift', php: 'php', csharp: 'cs', cpp: 'cpp',
18
+ c: 'c', sql: 'sql', json: 'json', yaml: 'yml', toml: 'toml',
19
+ bash: 'sh', shell: 'sh', html: 'html', css: 'css', scss: 'scss',
20
+ markdown: 'md', xml: 'xml', graphql: 'graphql',
21
+ }
11
22
 
12
23
  // Lazy load highlight.js
13
24
  let hljs: any = null
@@ -34,6 +45,35 @@ export const CodeBlockRenderer: Component<CodeBlockRendererProps> = (props) => {
34
45
  const [wordWrap, setWordWrap] = createSignal(false)
35
46
 
36
47
  const params = () => props.params || (props.component?.params as CodeComponentParams)
48
+ const isExpanded = useExpanded()
49
+ const [searchQuery, setSearchQuery] = createSignal('')
50
+
51
+ // v6.2.0 — search highlight: re-wraps `<mark>` around matches in the
52
+ // already-highlighted (hljs) HTML output. `highlightQuery` is the same
53
+ // helper TableRenderer uses (only wraps text outside of HTML tags so
54
+ // syntax span colors stay intact).
55
+ const displayedHTML = () => {
56
+ const q = searchQuery().trim()
57
+ return q ? highlightQuery(highlightedCode(), q) : highlightedCode()
58
+ }
59
+
60
+ const handleDownload = () => {
61
+ const code = params()?.code
62
+ if (!code) return
63
+ const lang = (params()?.language || '').toLowerCase()
64
+ const ext = LANGUAGE_EXTENSIONS[lang] || 'txt'
65
+ const stem = (params()?.filename || `code-${Date.now()}`).replace(/\.[^.]+$/, '')
66
+ const filename = stem.endsWith(`.${ext}`) ? stem : `${stem}.${ext}`
67
+ const blob = new Blob([code], { type: 'text/plain' })
68
+ const url = URL.createObjectURL(blob)
69
+ const a = document.createElement('a')
70
+ a.href = url
71
+ a.download = filename
72
+ document.body.appendChild(a)
73
+ a.click()
74
+ document.body.removeChild(a)
75
+ URL.revokeObjectURL(url)
76
+ }
37
77
 
38
78
  // Load highlight.js on mount
39
79
  createEffect(async () => {
@@ -152,13 +192,33 @@ export const CodeBlockRenderer: Component<CodeBlockRendererProps> = (props) => {
152
192
 
153
193
  return (
154
194
  <ExpandableWrapper title={params()?.filename || params()?.language || 'Code'} copyData={params()?.code} copyLabel="Copy code">
155
- <div class="w-full bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden text-sm flex flex-col">
195
+ <div class={`w-full bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden text-sm flex flex-col ${isExpanded() ? 'flex-1 min-h-0' : ''}`}>
156
196
  {/* Header */}
157
197
  <div class="flex items-center justify-between px-4 py-2 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shrink-0">
158
198
  <div class="font-mono text-xs text-gray-600 dark:text-gray-400">
159
199
  {params()?.filename || params()?.language || 'Code'}
160
200
  </div>
161
201
  <div class="flex items-center gap-2">
202
+ {/* Search input (v6.2.0) */}
203
+ <input
204
+ type="text"
205
+ value={searchQuery()}
206
+ onInput={(e) => setSearchQuery(e.currentTarget.value)}
207
+ placeholder="Search…"
208
+ class="px-2 py-0.5 text-xs border border-gray-200 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none w-32"
209
+ aria-label="Search in code"
210
+ />
211
+ {/* Download button (v6.2.0) */}
212
+ <button
213
+ onClick={handleDownload}
214
+ class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 focus:outline-none transition-colors"
215
+ aria-label="Download code as file"
216
+ title="Download code"
217
+ >
218
+ <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
219
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
220
+ </svg>
221
+ </button>
162
222
  {/* Word wrap toggle */}
163
223
  <button
164
224
  onClick={() => setWordWrap(!wordWrap())}
@@ -192,8 +252,8 @@ export const CodeBlockRenderer: Component<CodeBlockRendererProps> = (props) => {
192
252
 
193
253
  {/* Code Area */}
194
254
  <div
195
- class="relative overflow-auto flex"
196
- style={params()?.maxHeight ? { 'max-height': params()?.maxHeight } : {}}
255
+ class={`relative overflow-auto flex ${isExpanded() ? 'flex-1 min-h-0' : ''}`}
256
+ style={!isExpanded() && params()?.maxHeight ? { 'max-height': params()?.maxHeight } : {}}
197
257
  >
198
258
  {/* Line Numbers */}
199
259
  <Show when={params()?.showLineNumbers !== false}>
@@ -212,7 +272,7 @@ export const CodeBlockRenderer: Component<CodeBlockRendererProps> = (props) => {
212
272
  >
213
273
  <code
214
274
  class={`hljs ${params()?.language ? `language-${params()?.language}` : ''}`}
215
- innerHTML={highlightedCode()}
275
+ innerHTML={displayedHTML()}
216
276
  />
217
277
  </pre>
218
278
  </div>
@@ -187,8 +187,13 @@ export const ExpandableWrapper: Component<ExpandableWrapperProps> = (props) => {
187
187
  </div>
188
188
  </div>
189
189
 
190
- {/* Modal slot — content is reparented here when expanded */}
191
- <div class="flex-1 overflow-auto p-4" ref={modalSlotRef} />
190
+ {/* Modal slot — content is reparented here when expanded.
191
+ v6.1.0 : `flex flex-col` lets aware children opt into
192
+ `flex-1 min-h-0` to fill the modal vertically (chart,
193
+ table, map, graph). Unaware children keep working
194
+ thanks to `overflow-auto` (their natural height
195
+ scrolls if it overflows the slot). */}
196
+ <div class="flex-1 min-h-0 overflow-auto p-4 flex flex-col" ref={modalSlotRef} />
192
197
  </div>
193
198
  </div>
194
199
 
@@ -21,7 +21,7 @@
21
21
  import { Component, createSignal, onCleanup, onMount, Show, For } from 'solid-js'
22
22
  import type { UIComponent } from '../types'
23
23
  import type { GraphComponentParams, GraphLayout, GraphNode, GraphEdge } from '@seed-ship/mcp-ui-spec'
24
- import { ExpandableWrapper } from './ExpandableWrapper'
24
+ import { ExpandableWrapper, useExpanded } from './ExpandableWrapper'
25
25
 
26
26
  // Module-scoped lazy import promise — first call triggers the dynamic
27
27
  // import, subsequent calls reuse the resolved module.
@@ -139,6 +139,7 @@ function downloadBlob(content: string | Blob, filename: string, mimeType?: strin
139
139
 
140
140
  export const GraphRenderer: Component<{ component: UIComponent }> = (props) => {
141
141
  const params = () => props.component.params as GraphComponentParams
142
+ const isExpanded = useExpanded()
142
143
  const [available, setAvailable] = createSignal<boolean | null>(null)
143
144
  const [error, setError] = createSignal<string | undefined>()
144
145
  const [exportMenuOpen, setExportMenuOpen] = createSignal(false)
@@ -264,7 +265,9 @@ export const GraphRenderer: Component<{ component: UIComponent }> = (props) => {
264
265
  copyData={toJSON(params())}
265
266
  copyLabel="Copy graph (JSON)"
266
267
  >
267
- <div class={`relative w-full ${params().className ?? ''}`}>
268
+ <div class={`relative w-full ${params().className ?? ''} ${
269
+ isExpanded() ? 'flex-1 min-h-0 flex flex-col' : ''
270
+ }`}>
268
271
  {/* Export menu — top-right, mirrors TableRenderer's pattern */}
269
272
  <div class="absolute right-2 top-2 z-10">
270
273
  <button
@@ -301,8 +304,14 @@ export const GraphRenderer: Component<{ component: UIComponent }> = (props) => {
301
304
 
302
305
  <div
303
306
  ref={containerRef}
304
- class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden"
305
- style={`height: ${params().height ?? '400px'}; width: ${params().width ?? '100%'};`}
307
+ class={`bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden ${
308
+ isExpanded() ? 'flex-1 min-h-0' : ''
309
+ }`}
310
+ style={
311
+ isExpanded()
312
+ ? `height: 100%; width: ${params().width ?? '100%'};`
313
+ : `height: ${params().height ?? '400px'}; width: ${params().width ?? '100%'};`
314
+ }
306
315
  />
307
316
  <Show when={error()}>
308
317
  <p class="text-xs text-red-600 dark:text-red-400 mt-1">Render error: {error()}</p>
@@ -120,10 +120,16 @@ describe('ImageGalleryRenderer', () => {
120
120
  })
121
121
 
122
122
  it('renders buttons for images when lightbox is enabled', () => {
123
- render(() => <ImageGalleryRenderer params={defaultParams} />)
124
-
125
- const buttons = screen.getAllByRole('button')
126
- // Should have one button per image (for opening lightbox)
123
+ const { container } = render(() => <ImageGalleryRenderer params={defaultParams} />)
124
+
125
+ // Filter to image-trigger buttons (have aria-label "View image …"). The
126
+ // ExpandableWrapper expand button (added in v6.2.0) is excluded.
127
+ // Image-trigger buttons have a tailwind `relative overflow-hidden` group
128
+ // class. The ExpandableWrapper expand button (added v6.2.0) has a
129
+ // different `absolute top-2 right-2` class — this filter excludes it.
130
+ const buttons = Array.from(container.querySelectorAll('button')).filter(
131
+ (b) => b.className.includes('relative overflow-hidden')
132
+ )
127
133
  expect(buttons.length).toBe(3)
128
134
  })
129
135
 
@@ -133,10 +139,15 @@ describe('ImageGalleryRenderer', () => {
133
139
  lightbox: false,
134
140
  }
135
141
 
136
- render(() => <ImageGalleryRenderer params={paramsNoLightbox} />)
142
+ const { container } = render(() => <ImageGalleryRenderer params={paramsNoLightbox} />)
137
143
 
138
- // Should still render buttons (for accessibility) but not open lightbox
139
- const buttons = screen.getAllByRole('button')
144
+ // Same filter as above ignore the ExpandableWrapper expand button (v6.2.0).
145
+ // Image-trigger buttons have a tailwind `relative overflow-hidden` group
146
+ // class. The ExpandableWrapper expand button (added v6.2.0) has a
147
+ // different `absolute top-2 right-2` class — this filter excludes it.
148
+ const buttons = Array.from(container.querySelectorAll('button')).filter(
149
+ (b) => b.className.includes('relative overflow-hidden')
150
+ )
140
151
  expect(buttons.length).toBe(3)
141
152
  })
142
153
 
@@ -6,6 +6,7 @@
6
6
  import { Component, createSignal, For, Show } from 'solid-js'
7
7
  import type { UIComponent, ImageGalleryParams } from '../types'
8
8
  import { LightboxOverlay } from './LightboxOverlay'
9
+ import { ExpandableWrapper, useExpanded } from './ExpandableWrapper'
9
10
 
10
11
  export interface ImageGalleryRendererProps {
11
12
  /**
@@ -19,8 +20,18 @@ export interface ImageGalleryRendererProps {
19
20
  params?: ImageGalleryParams
20
21
  }
21
22
 
23
+ /** Build a newline-separated list of image URLs (with captions when present)
24
+ * for the ExpandableWrapper copy button. v6.2.0. */
25
+ function imagesToTextList(p: ImageGalleryParams | undefined): string {
26
+ if (!p) return ''
27
+ return (p.images ?? [])
28
+ .map((img) => (img.caption ? `${img.url}\t${img.caption}` : img.url))
29
+ .join('\n')
30
+ }
31
+
22
32
  export const ImageGalleryRenderer: Component<ImageGalleryRendererProps> = (props) => {
23
33
  const [selectedIndex, setSelectedIndex] = createSignal<number | null>(null)
34
+ const isExpanded = useExpanded()
24
35
 
25
36
  const params = () => props.params || (props.component?.params as ImageGalleryParams)
26
37
 
@@ -72,16 +83,23 @@ export const ImageGalleryRenderer: Component<ImageGalleryRendererProps> = (props
72
83
  }
73
84
 
74
85
  return (
75
- <div class="w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
86
+ <ExpandableWrapper
87
+ title={params()?.title || 'Gallery'}
88
+ copyData={imagesToTextList(params())}
89
+ copyLabel="Copy image URLs"
90
+ >
91
+ <div class={`w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden ${
92
+ isExpanded() ? 'flex-1 min-h-0 flex flex-col' : ''
93
+ }`}>
76
94
  {/* Title */}
77
95
  <Show when={params()?.title}>
78
- <div class="px-4 py-3 border-b border-gray-200 dark:border-gray-700">
96
+ <div class="px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0">
79
97
  <h3 class="text-sm font-semibold text-gray-900 dark:text-white">{params()!.title}</h3>
80
98
  </div>
81
99
  </Show>
82
100
 
83
101
  {/* Gallery Grid */}
84
- <div class={`grid ${columnsClass()} ${gapClass()} p-4`}>
102
+ <div class={`grid ${columnsClass()} ${gapClass()} p-4 ${isExpanded() ? 'flex-1 min-h-0 overflow-auto' : ''}`}>
85
103
  <For each={params()?.images}>
86
104
  {(image, index) => (
87
105
  <button
@@ -142,5 +160,6 @@ export const ImageGalleryRenderer: Component<ImageGalleryRendererProps> = (props
142
160
  onNavigate={setSelectedIndex}
143
161
  />
144
162
  </div>
163
+ </ExpandableWrapper>
145
164
  )
146
165
  }
@@ -7,6 +7,7 @@
7
7
  import { Component, createEffect, onCleanup, createSignal, Show } from 'solid-js'
8
8
  import { isServer } from 'solid-js/web'
9
9
  import type { UIComponent, MapComponentParams, MapClusterOptions, MapGeoJSONStyle, MapPopupConfig, MapLayer, MapPMTilesConfig } from '../types'
10
+ import { ExpandableWrapper, useExpanded } from './ExpandableWrapper'
10
11
 
11
12
  // Lazy load leaflet (it doesn't support SSR well)
12
13
  let L: any = null
@@ -165,14 +166,55 @@ function addGeoJSONLayer(
165
166
 
166
167
  // ─── Component ──────────────────────────────────────────────
167
168
 
169
+ /**
170
+ * Build a GeoJSON FeatureCollection from the map's `markers` (and any
171
+ * inlined GeoJSON layers, when present). Used by the "Copy data" button
172
+ * shipped via `<ExpandableWrapper>` (v6.2.0). Best-effort — clusters,
173
+ * tile layers, and choropleth-only data don't get round-tripped.
174
+ */
175
+ function mapToGeoJSON(p: MapComponentParams | undefined): string {
176
+ if (!p) return '{"type":"FeatureCollection","features":[]}'
177
+ const features: any[] = []
178
+ for (const marker of p.markers ?? []) {
179
+ const pos: any = marker.position as any
180
+ // Accept both [lat, lng] tuple and {lat, lng} object shapes (v5.0.2 spec)
181
+ const lat = Array.isArray(pos) ? pos[0] : pos?.lat
182
+ const lng = Array.isArray(pos) ? pos[1] : pos?.lng
183
+ if (typeof lat !== 'number' || typeof lng !== 'number') continue
184
+ features.push({
185
+ type: 'Feature',
186
+ geometry: { type: 'Point', coordinates: [lng, lat] },
187
+ properties: {
188
+ ...(marker.tooltip ? { tooltip: marker.tooltip } : {}),
189
+ ...(marker.popup ? { popup: marker.popup } : {}),
190
+ },
191
+ })
192
+ }
193
+ return JSON.stringify({ type: 'FeatureCollection', features }, null, 2)
194
+ }
195
+
168
196
  export const MapRenderer: Component<MapRendererProps> = (props) => {
169
197
  let mapContainer: HTMLDivElement | undefined
170
198
  let mapInstance: any = null
171
199
  const [isLeafletLoaded, setIsLeafletLoaded] = createSignal(false)
172
200
  const [error, setError] = createSignal<string | null>(null)
201
+ const isExpanded = useExpanded()
173
202
 
174
203
  const params = () => props.params || (props.component?.params as MapComponentParams)
175
204
 
205
+ // v6.2.0 — Leaflet has to be told to re-measure when its container
206
+ // resizes (e.g. transitioning to fullscreen via ExpandableWrapper).
207
+ // We give the DOM a tick to settle the new dimensions, then ask
208
+ // Leaflet to reflow tiles.
209
+ createEffect(() => {
210
+ const expanded = isExpanded()
211
+ if (!mapInstance) return
212
+ // Read the signal so the effect re-runs on toggle ; the value is
213
+ // observed for its side effects on layout.
214
+ void expanded
215
+ setTimeout(() => mapInstance?.invalidateSize?.(), 100)
216
+ })
217
+
176
218
  // Initialize Map
177
219
  createEffect(async () => {
178
220
  if (isServer) return // Don't run on server
@@ -384,19 +426,31 @@ export const MapRenderer: Component<MapRendererProps> = (props) => {
384
426
  })
385
427
 
386
428
  return (
387
- <div class={`w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden ${params()?.className || ''}`}>
388
- <Show when={error()}>
389
- <div class="p-4 text-red-500 bg-red-50 dark:bg-red-900/20 text-center">
390
- {error()}
391
- </div>
392
- </Show>
393
- <Show when={!error()}>
394
- <div
395
- ref={mapContainer}
396
- style={{ height: params()?.height || '400px', width: '100%', "z-index": 0 }}
397
- class="relative z-0"
398
- />
399
- </Show>
400
- </div>
429
+ <ExpandableWrapper
430
+ title={'Map'}
431
+ copyData={mapToGeoJSON(params())}
432
+ copyLabel="Copy markers as GeoJSON"
433
+ >
434
+ <div class={`w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden ${params()?.className || ''} ${
435
+ isExpanded() ? 'flex-1 min-h-0 flex flex-col' : ''
436
+ }`}>
437
+ <Show when={error()}>
438
+ <div class="p-4 text-red-500 bg-red-50 dark:bg-red-900/20 text-center">
439
+ {error()}
440
+ </div>
441
+ </Show>
442
+ <Show when={!error()}>
443
+ <div
444
+ ref={mapContainer}
445
+ style={
446
+ isExpanded()
447
+ ? { height: '100%', width: '100%', 'z-index': 0 }
448
+ : { height: params()?.height || '400px', width: '100%', 'z-index': 0 }
449
+ }
450
+ class={`relative z-0 ${isExpanded() ? 'flex-1 min-h-0' : ''}`}
451
+ />
452
+ </Show>
453
+ </div>
454
+ </ExpandableWrapper>
401
455
  )
402
456
  }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * v6.1.0 fluidity defaults tests :
3
+ * - Table search input visible by default (was opt-in via searchable: true
4
+ * OR auto when rows > 10).
5
+ * - Table search hidden when explicitly opted out (searchable: false).
6
+ * - Chart export button visible by default (was opt-in via
7
+ * exportable: true).
8
+ * - Chart export button hidden when explicitly opted out
9
+ * (exportable: false).
10
+ *
11
+ * Responsive expanded-mode tests are NOT here — they require simulating a
12
+ * click on the expand button + asserting on the modal Portal subtree,
13
+ * which the existing harness handles less cleanly. Manual verification
14
+ * confirmed via the dev playground.
15
+ */
16
+
17
+ import { describe, it, expect, beforeEach } from 'vitest'
18
+ import { render, cleanup } from '@solidjs/testing-library'
19
+ import { UIResourceRenderer } from './UIResourceRenderer'
20
+ import type { UIComponent } from '../types'
21
+
22
+ describe('Table — search input default-on (v6.1.0)', () => {
23
+ beforeEach(() => {
24
+ cleanup()
25
+ })
26
+
27
+ function tableComponent(rows: Array<Record<string, unknown>>, params: Record<string, unknown> = {}): UIComponent {
28
+ return {
29
+ id: 'tbl',
30
+ type: 'table',
31
+ position: { colStart: 1, colSpan: 12 },
32
+ params: {
33
+ columns: [
34
+ { key: 'name', label: 'Name' },
35
+ { key: 'value', label: 'Value' },
36
+ ],
37
+ rows,
38
+ ...params,
39
+ } as any,
40
+ }
41
+ }
42
+
43
+ it('shows the search input by default on a SMALL table (was hidden before v6.1.0 unless > 10 rows)', () => {
44
+ const rows = Array.from({ length: 3 }, (_, i) => ({ name: `n${i}`, value: i }))
45
+ const { container } = render(() => <UIResourceRenderer content={tableComponent(rows)} />)
46
+ const input = container.querySelector('input[placeholder*="Recherche"]')
47
+ expect(input).toBeTruthy()
48
+ })
49
+
50
+ it('still shows the search input on a LARGE table', () => {
51
+ const rows = Array.from({ length: 50 }, (_, i) => ({ name: `n${i}`, value: i }))
52
+ const { container } = render(() => <UIResourceRenderer content={tableComponent(rows)} />)
53
+ expect(container.querySelector('input[placeholder*="Recherche"]')).toBeTruthy()
54
+ })
55
+
56
+ it('hides the search input when searchable: false is explicit (backward-compat opt-out)', () => {
57
+ const rows = Array.from({ length: 50 }, (_, i) => ({ name: `n${i}`, value: i }))
58
+ const { container } = render(() => (
59
+ <UIResourceRenderer content={tableComponent(rows, { searchable: false })} />
60
+ ))
61
+ expect(container.querySelector('input[placeholder*="Recherche"]')).toBeNull()
62
+ })
63
+ })
64
+
65
+ describe('Chart (iframe path) — exportable default (v6.1.0)', () => {
66
+ beforeEach(() => {
67
+ cleanup()
68
+ })
69
+
70
+ // Note : the native ChartJSRenderer path can't be tested here because
71
+ // chart.js is a peer-optional and even when it loads in vitest, the
72
+ // canvas API isn't supported in jsdom. We exercise the iframe-fallback
73
+ // path instead, which is also gated by the same `exportable` prop in
74
+ // its own renderer (UIResourceRenderer's ChartRenderer iframe branch).
75
+ // The export-button gating is uniform across both paths.
76
+
77
+ function chartComponent(params: Record<string, unknown> = {}): UIComponent {
78
+ return {
79
+ id: 'cht',
80
+ type: 'chart',
81
+ position: { colStart: 1, colSpan: 12 },
82
+ params: {
83
+ type: 'bar',
84
+ title: 'Sales',
85
+ data: { labels: ['A'], datasets: [{ label: 'X', data: [1] }] },
86
+ renderer: 'iframe', // force iframe path so we don't hit chart.js peer
87
+ ...params,
88
+ } as any,
89
+ }
90
+ }
91
+
92
+ it('renders chart without throwing when exportable is undefined', () => {
93
+ expect(() => render(() => <UIResourceRenderer content={chartComponent()} />)).not.toThrow()
94
+ })
95
+
96
+ it('renders chart without throwing when exportable: false', () => {
97
+ expect(() =>
98
+ render(() => <UIResourceRenderer content={chartComponent({ exportable: false })} />)
99
+ ).not.toThrow()
100
+ })
101
+ })
@@ -547,7 +547,13 @@ function TableRenderer(props: {
547
547
  const [debouncedQuery, setDebouncedQuery] = createSignal('')
548
548
  let searchTimer: ReturnType<typeof setTimeout> | null = null
549
549
 
550
- const isSearchable = () => tableParams.searchable === true || (tableParams.searchable !== false && allRows().length > 10)
550
+ // v6.1.0 search visibility :
551
+ // - undefined / true → always shown (new default, was conditional on >10 rows)
552
+ // - false → hidden (explicit opt-out, unchanged)
553
+ // Rationale: even small tables benefit from search in a chat / dashboard
554
+ // context where users scan many tables across messages. Backward-compat
555
+ // for anyone who explicitly disabled.
556
+ const isSearchable = () => tableParams.searchable !== false
551
557
  const searchPlaceholder = () => tableParams.searchPlaceholder || 'Rechercher dans le tableau...'
552
558
 
553
559
  const handleSearch = (value: string) => {
@@ -813,7 +819,9 @@ function TableRenderer(props: {
813
819
 
814
820
  return (
815
821
  <ExpandableWrapper title={tableParams.title || 'Table'} copyData={getTableCSV()} copyLabel="Copy table (CSV)">
816
- <div class={`relative w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden group ${isExpanded() ? '' : 'h-full'}`}>
822
+ <div class={`relative w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden group ${
823
+ isExpanded() ? 'flex-1 min-h-0 flex flex-col' : 'h-full'
824
+ }`}>
817
825
  <Show when={exportable} fallback={<CopyButton getText={getTableCSV} title="Copy table (CSV)" position="top-right" />}>
818
826
  <div class="absolute right-10 top-2 z-10">
819
827
  <button
@@ -841,9 +849,9 @@ function TableRenderer(props: {
841
849
  </Show>
842
850
  </div>
843
851
  </Show>
844
- <div class="p-4">
852
+ <div class={`p-4 ${isExpanded() ? 'flex-1 min-h-0 flex flex-col' : ''}`}>
845
853
  <Show when={tableParams.title}>
846
- <h3 id={`${tableId}-title`} class="text-sm font-semibold text-gray-900 dark:text-white mb-3">
854
+ <h3 id={`${tableId}-title`} class="text-sm font-semibold text-gray-900 dark:text-white mb-3 flex-shrink-0">
847
855
  {tableParams.title}
848
856
  <Show when={isVirtualizing()}>
849
857
  <span class="ml-2 text-xs font-normal text-gray-400">(virtualized: {tableParams.rows?.length} rows)</span>
@@ -880,12 +888,18 @@ function TableRenderer(props: {
880
888
 
881
889
  <div
882
890
  ref={scrollContainerRef}
883
- class="overflow-x-auto"
891
+ class={`overflow-x-auto ${isExpanded() ? 'flex-1 min-h-0' : ''}`}
884
892
  style={
885
- isVirtualizing()
886
- ? { 'max-height': '500px', 'overflow-y': 'auto' }
887
- : !isExpanded() && clientVisibleRows().length > 8
888
- ? { 'max-height': '400px', 'overflow-y': 'auto' }
893
+ // v6.1.0 — when expanded, the scroll container fills the
894
+ // remaining vertical space (flex-1 + min-h-0 above) and
895
+ // scrolls internally instead of the modal scrolling. Inline
896
+ // mode keeps the previous max-height heuristic.
897
+ isExpanded()
898
+ ? { 'overflow-y': 'auto' }
899
+ : isVirtualizing()
900
+ ? { 'max-height': '500px', 'overflow-y': 'auto' }
901
+ : clientVisibleRows().length > 8
902
+ ? { 'max-height': '400px', 'overflow-y': 'auto' }
889
903
  : {}
890
904
  }
891
905
  role="region"