@iyulab/u-widgets 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1372 @@
1
+ import { i as g, a as D } from "./infer-CNOiD2dS.js";
2
+ const v = {
3
+ x: "X-axis / category field",
4
+ y: "Y-axis value field(s)",
5
+ label: "Label field (pie/funnel)",
6
+ value: "Value field (pie/funnel/heatmap)",
7
+ color: "Color grouping field (scatter)",
8
+ size: "Size encoding field (scatter bubble)",
9
+ axis: "Axis field (radar indicators)",
10
+ columns: "Column definitions (table)",
11
+ primary: "Primary text field (list)",
12
+ secondary: "Secondary text field (list)",
13
+ icon: "Icon letter field (list)",
14
+ avatar: "Avatar image URL field (list)",
15
+ trailing: "Trailing value field (list)",
16
+ badge: "Badge/tag field (list)"
17
+ }, k = {
18
+ field: "Key name in submitted data",
19
+ label: "Display label",
20
+ type: "Input type",
21
+ required: "Must be filled before submit",
22
+ placeholder: "Placeholder text",
23
+ options: "Choices for select/radio/checkbox",
24
+ minLength: "Minimum character length",
25
+ maxLength: "Maximum character length",
26
+ pattern: "Custom regex pattern",
27
+ rows: "Textarea visible rows",
28
+ min: "Minimum value",
29
+ max: "Maximum value",
30
+ step: "Number/range step increment",
31
+ message: "Custom validation error message"
32
+ }, C = {
33
+ // metric / stat-group
34
+ value: "The primary value to display",
35
+ label: "Display label or category name",
36
+ unit: "Value unit suffix",
37
+ prefix: "Text before the value",
38
+ suffix: "Text after the value",
39
+ change: "Delta / change amount",
40
+ trend: "Trend direction (up, down, flat)",
41
+ // content
42
+ content: "Body text or markdown content",
43
+ message: "Message body text",
44
+ level: "Severity level (info, warning, error, success)",
45
+ title: "Heading or title text",
46
+ src: "Source URL (image)",
47
+ alt: "Alt text (image)",
48
+ caption: "Caption text",
49
+ // progress
50
+ max: "Maximum bound value",
51
+ // treemap / general
52
+ name: "Node or item name",
53
+ children: "Nested child nodes",
54
+ // kv / header
55
+ language: "Programming language identifier",
56
+ key: "Key or label identifier",
57
+ text: "Display text content",
58
+ // steps
59
+ status: "Step status (done, active, pending, error)",
60
+ description: "Detailed description text",
61
+ // rating
62
+ count: "Number of reviews or votes",
63
+ // video / citation
64
+ poster: "Video poster image URL",
65
+ url: "Link URL",
66
+ snippet: "Excerpt or summary text",
67
+ source: "Source name or publisher",
68
+ // chart data
69
+ group: "Group / category identifier",
70
+ min: "Minimum stat value",
71
+ q1: "First quartile (25th percentile)",
72
+ median: "Median (50th percentile)",
73
+ q3: "Third quartile (75th percentile)"
74
+ }, w = {
75
+ // gauge / progress
76
+ min: "Minimum range value",
77
+ max: "Maximum range value",
78
+ unit: "Display unit string",
79
+ thresholds: "Color threshold breakpoints",
80
+ label: "Label template ({value}, {percent})",
81
+ // chart
82
+ smooth: "Smooth curves (line/area)",
83
+ stack: "Stack series (bar/line/area)",
84
+ horizontal: "Horizontal orientation (bar)",
85
+ donut: "Donut style (pie)",
86
+ colors: "Custom color palette",
87
+ colorRange: "Heatmap color gradient",
88
+ histogram: "Histogram mode (bar)",
89
+ referenceLines: "Reference/threshold lines",
90
+ step: "Step interpolation (line)",
91
+ legend: "Show/hide legend",
92
+ grid: "Show/hide grid lines",
93
+ animate: "Enable/disable animation",
94
+ showLabel: "Show/hide data labels",
95
+ // table / list
96
+ pageSize: "Rows per page",
97
+ compact: "Compact display mode",
98
+ searchable: "Enable search filter",
99
+ locale: "Locale for formatting/validation",
100
+ // code
101
+ lineNumbers: "Show/hide line numbers (default true)",
102
+ highlight: "Line numbers to highlight (array)",
103
+ maxHeight: 'Maximum height with scroll (e.g. "300px")',
104
+ wrap: "Word wrap long lines (default false)",
105
+ // citation
106
+ numbered: "Show numbered badges (default true)",
107
+ // rating
108
+ interactive: "Allow user input (default false)",
109
+ icon: "Icon type (star, heart, thumb)",
110
+ // video
111
+ autoplay: "Auto-play on load (default false)",
112
+ controls: "Show playback controls (default true)",
113
+ loop: "Loop playback (default false)",
114
+ muted: "Start muted (default false, auto when autoplay)",
115
+ // gallery
116
+ aspectRatio: 'Image aspect ratio (e.g. "1:1", "16:9", default auto)',
117
+ // compose / kv / actions / divider / steps
118
+ layout: "Layout mode (stack, row, grid, horizontal, vertical, wrap, column)",
119
+ columns: "Number of grid columns",
120
+ widths: 'Column width ratios (number[], "auto", "stretch")',
121
+ spacing: "Spacing size (small, default, large)",
122
+ card: "Render inside a card container with shadow and border"
123
+ }, L = {
124
+ label: "Button text",
125
+ action: "Action identifier (submit, cancel, navigate, custom)",
126
+ style: "Visual style (primary, danger, default)",
127
+ disabled: "Whether disabled",
128
+ url: "URL for navigate action"
129
+ }, N = {
130
+ "chart.bar": ["stack", "horizontal", "histogram", "colors", "referenceLines", "legend", "grid", "animate", "showLabel"],
131
+ "chart.line": ["smooth", "stack", "step", "colors", "referenceLines", "legend", "grid", "animate", "showLabel"],
132
+ "chart.area": ["smooth", "stack", "colors", "legend", "grid", "animate", "showLabel"],
133
+ "chart.pie": ["donut", "colors", "legend", "animate", "showLabel"],
134
+ "chart.scatter": ["colors", "legend", "grid", "animate", "showLabel"],
135
+ "chart.radar": ["colors", "legend", "animate", "showLabel"],
136
+ "chart.heatmap": ["colorRange", "legend", "grid", "animate", "showLabel"],
137
+ "chart.box": ["colors", "legend", "grid", "animate"],
138
+ "chart.funnel": ["colors", "legend", "animate", "showLabel"],
139
+ "chart.waterfall": ["colors", "legend", "grid", "animate", "showLabel"],
140
+ "chart.treemap": ["colors", "animate", "showLabel"],
141
+ metric: [],
142
+ "stat-group": [],
143
+ gauge: ["min", "max", "unit", "thresholds", "label"],
144
+ progress: ["min", "max", "unit", "thresholds", "label"],
145
+ table: ["pageSize", "compact", "searchable"],
146
+ list: ["compact"],
147
+ form: ["locale"],
148
+ confirm: [],
149
+ markdown: [],
150
+ image: [],
151
+ callout: [],
152
+ compose: ["layout", "columns", "widths", "card"],
153
+ kv: ["layout", "columns"],
154
+ code: ["lineNumbers", "highlight", "maxHeight", "wrap"],
155
+ citation: ["compact", "numbered"],
156
+ status: [],
157
+ steps: ["layout", "compact"],
158
+ rating: ["max", "interactive", "icon", "label"],
159
+ video: ["autoplay", "controls", "loop", "muted"],
160
+ gallery: ["columns", "aspectRatio"],
161
+ actions: ["layout"],
162
+ divider: [],
163
+ header: []
164
+ }, M = {
165
+ metric: [
166
+ { key: "value", type: "number | string", desc: "Primary value", required: !0 },
167
+ { key: "label", type: "string", desc: "Display label" },
168
+ { key: "unit", type: "string", desc: "Value unit suffix" },
169
+ { key: "prefix", type: "string", desc: "Text before value" },
170
+ { key: "suffix", type: "string", desc: "Text after value" },
171
+ { key: "change", type: "number", desc: "Delta amount" },
172
+ { key: "trend", type: '"up" | "down" | "flat"', desc: "Trend direction" },
173
+ { key: "icon", type: "string", desc: "Emoji or short text icon" },
174
+ { key: "description", type: "string", desc: "Sub-label below value" }
175
+ ],
176
+ "stat-group": [
177
+ { key: "label", type: "string", desc: "Display label", required: !0 },
178
+ { key: "value", type: "number", desc: "Primary value", required: !0 },
179
+ { key: "unit", type: "string", desc: "Value unit suffix" },
180
+ { key: "prefix", type: "string", desc: "Text before value" },
181
+ { key: "suffix", type: "string", desc: "Text after value" },
182
+ { key: "change", type: "number", desc: "Delta amount" },
183
+ { key: "trend", type: '"up" | "down" | "flat"', desc: "Trend direction" },
184
+ { key: "icon", type: "string", desc: "Emoji or short text icon" },
185
+ { key: "description", type: "string", desc: "Sub-label below value" }
186
+ ],
187
+ gauge: [
188
+ { key: "value", type: "number", desc: "Current value on the arc", required: !0 }
189
+ ],
190
+ progress: [
191
+ { key: "value", type: "number", desc: "Current value", required: !0 },
192
+ { key: "max", type: "number", desc: "Maximum bound (default 100)" }
193
+ ],
194
+ markdown: [
195
+ { key: "content", type: "string", desc: "Markdown text", required: !0 }
196
+ ],
197
+ image: [
198
+ { key: "src", type: "string", desc: "Image URL", required: !0 },
199
+ { key: "alt", type: "string", desc: "Alt text" },
200
+ { key: "caption", type: "string", desc: "Caption text" }
201
+ ],
202
+ callout: [
203
+ { key: "message", type: "string", desc: "Body text", required: !0 },
204
+ { key: "title", type: "string", desc: "Optional heading" },
205
+ { key: "level", type: '"info" | "warning" | "error" | "success"', desc: "Severity" }
206
+ ],
207
+ code: [
208
+ { key: "content", type: "string", desc: "Code text content", required: !0 },
209
+ { key: "language", type: "string", desc: "Language identifier (e.g. javascript, python, sql)" }
210
+ ],
211
+ header: [
212
+ { key: "text", type: "string", desc: "Heading text", required: !0 },
213
+ { key: "level", type: "1 | 2 | 3", desc: "Heading level (default 2)" }
214
+ ],
215
+ video: [
216
+ { key: "src", type: "string", desc: "Video URL", required: !0 },
217
+ { key: "poster", type: "string", desc: "Poster image URL" },
218
+ { key: "alt", type: "string", desc: "Accessible description" },
219
+ { key: "caption", type: "string", desc: "Caption text" }
220
+ ],
221
+ gallery: [
222
+ { key: "src", type: "string", desc: "Image URL", required: !0 },
223
+ { key: "alt", type: "string", desc: "Alt text" },
224
+ { key: "caption", type: "string", desc: "Caption text" }
225
+ ],
226
+ steps: [
227
+ { key: "label", type: "string", desc: "Step label", required: !0 },
228
+ { key: "status", type: '"done" | "active" | "pending" | "error"', desc: "Step status (default pending)" },
229
+ { key: "description", type: "string", desc: "Step detail text" },
230
+ { key: "icon", type: "string", desc: "Custom icon (emoji/text) override" }
231
+ ],
232
+ rating: [
233
+ { key: "value", type: "number", desc: "Current rating value" },
234
+ { key: "max", type: "number", desc: "Scale maximum (default 5)" },
235
+ { key: "count", type: "number", desc: "Number of reviews" }
236
+ ],
237
+ citation: [
238
+ { key: "title", type: "string", desc: "Citation title", required: !0 },
239
+ { key: "url", type: "string", desc: "Link URL" },
240
+ { key: "snippet", type: "string", desc: "Excerpt text" },
241
+ { key: "source", type: "string", desc: "Source name" }
242
+ ],
243
+ status: [
244
+ { key: "label", type: "string", desc: "Status label", required: !0 },
245
+ { key: "value", type: "string", desc: "Status value", required: !0 },
246
+ { key: "level", type: '"info" | "success" | "warning" | "error" | "neutral"', desc: "Severity level (default info)" }
247
+ ]
248
+ }, P = {
249
+ "chart.bar": "mapping omittable. First string → x, number fields → y.",
250
+ "chart.line": "mapping omittable. First string → x, numbers → y. Date-like preferred for x.",
251
+ "chart.area": "mapping omittable. Same as line — first string → x, numbers → y.",
252
+ "chart.pie": "mapping omittable. First string → label, first number → value.",
253
+ "chart.scatter": "mapping omittable. First two numbers → x, y. color/size optional.",
254
+ "chart.radar": "mapping omittable. First string → axis, numbers → series values.",
255
+ "chart.heatmap": "mapping recommended. x, y (categories), value (intensity).",
256
+ "chart.box": "mapping recommended. x (group), y mapped to [min, q1, median, q3, max].",
257
+ "chart.funnel": "mapping omittable. First string → label, first number → value.",
258
+ "chart.waterfall": "mapping omittable. First string → x, first number → y.",
259
+ "chart.treemap": "No mapping. data is [{name, value, children?}].",
260
+ metric: "No mapping needed. data is {value, label?, unit?, change?, trend?}.",
261
+ "stat-group": "No mapping needed. data is [{label, value, ...}]. Optional: icon (emoji), description (sub-label).",
262
+ gauge: "No mapping needed. data is {value}. Set min/max/unit in options.",
263
+ progress: "No mapping needed. data is {value, max?}. Set label in options.",
264
+ table: "mapping.columns omittable — auto-inferred from data keys.",
265
+ list: "mapping omittable if data has primary/secondary keys. Otherwise set mapping.",
266
+ form: "Uses fields[] or formdown, not data/mapping. data provides defaults.",
267
+ confirm: "Uses title, description, actions. data is optional.",
268
+ markdown: 'No mapping. data is {content: "markdown string"}.',
269
+ image: "No mapping. data is {src, alt?, caption?}.",
270
+ callout: "No mapping. data is {message, title?, level?}.",
271
+ compose: "Uses children[] and layout. Each child is a widget spec.",
272
+ kv: "No mapping. data is {key: val, ...} or [{key, value}]. layout in options.",
273
+ code: "No mapping. data is {content, language?}. lineNumbers/highlight/maxHeight/wrap in options.",
274
+ citation: "No mapping. data is {title, url?, snippet?, source?} or array of those. compact/numbered in options.",
275
+ status: "No mapping. data is {label, value, level?} or array of those. level: info/success/warning/error/neutral.",
276
+ video: "No mapping. data is {src, poster?, alt?, caption?}. autoplay/controls/loop/muted in options.",
277
+ gallery: "No mapping. data is [{src, alt?, caption?}]. columns/aspectRatio in options.",
278
+ steps: "No mapping. data is [{label, status?, description?, icon?}]. status: done/active/pending/error. icon: emoji/text override. layout: vertical/horizontal.",
279
+ rating: "No mapping. data is {value?, max?}. options: interactive, icon (star/heart/thumb), max, label.",
280
+ actions: "No data. Uses actions[] array. layout in options (wrap/column).",
281
+ divider: "No data. label/spacing in options.",
282
+ header: "data is {text, level?}. level defaults to 2."
283
+ }, x = {
284
+ chart: ["select"],
285
+ table: ["select"],
286
+ list: ["select"],
287
+ form: ["submit", "change", "action"],
288
+ confirm: ["submit", "action"],
289
+ citation: ["action"],
290
+ rating: ["submit"],
291
+ actions: ["action"]
292
+ };
293
+ function S(e) {
294
+ return x[e] ?? x[e.split(".")[0]] ?? [];
295
+ }
296
+ const y = [
297
+ // Charts
298
+ // Charts
299
+ { widget: "chart.bar", category: "chart", description: "Bar chart for category × value comparison", mappingKeys: ["x", "y"], dataShape: "array" },
300
+ { widget: "chart.line", category: "chart", description: "Line chart for trends over a category axis", mappingKeys: ["x", "y"], dataShape: "array" },
301
+ { widget: "chart.area", category: "chart", description: "Area chart (filled line chart)", mappingKeys: ["x", "y"], dataShape: "array" },
302
+ { widget: "chart.pie", category: "chart", description: "Pie or donut chart for proportions", mappingKeys: ["label", "value"], dataShape: "array" },
303
+ { widget: "chart.scatter", category: "chart", description: "Scatter plot for two numeric dimensions", mappingKeys: ["x", "y", "color", "size"], dataShape: "array" },
304
+ { widget: "chart.radar", category: "chart", description: "Radar chart for multi-axis comparison", mappingKeys: ["axis", "value"], dataShape: "array" },
305
+ { widget: "chart.heatmap", category: "chart", description: "Heatmap for matrix data visualization", mappingKeys: ["x", "y", "value"], dataShape: "array" },
306
+ { widget: "chart.box", category: "chart", description: "Box plot for statistical distribution", mappingKeys: ["x", "y"], dataShape: "array" },
307
+ { widget: "chart.funnel", category: "chart", description: "Funnel chart for sequential stages", mappingKeys: ["label", "value"], dataShape: "array" },
308
+ { widget: "chart.waterfall", category: "chart", description: "Waterfall chart for cumulative values", mappingKeys: ["x", "y"], dataShape: "array" },
309
+ { widget: "chart.treemap", category: "chart", description: "Treemap for hierarchical data", mappingKeys: [], dataShape: "array" },
310
+ // Display
311
+ { widget: "metric", category: "display", description: "Single KPI value with optional trend", mappingKeys: [], dataShape: "object" },
312
+ { widget: "stat-group", category: "display", description: "Multiple KPI values in a row", mappingKeys: [], dataShape: "array" },
313
+ { widget: "gauge", category: "display", description: "Arc gauge for a value within a range", mappingKeys: [], dataShape: "object" },
314
+ { widget: "progress", category: "display", description: "Progress bar for a value within a range", mappingKeys: [], dataShape: "object" },
315
+ { widget: "table", category: "display", description: "Sortable data table with auto-inferred columns", mappingKeys: ["columns"], dataShape: "array" },
316
+ { widget: "list", category: "display", description: "Structured list with avatars and trailing values", mappingKeys: ["primary", "secondary", "avatar", "icon", "trailing", "badge"], dataShape: "array" },
317
+ // Input
318
+ { widget: "form", category: "input", description: "Data entry form with typed fields", mappingKeys: [], dataShape: "object" },
319
+ { widget: "confirm", category: "input", description: "Yes/no confirmation dialog", mappingKeys: [], dataShape: "object" },
320
+ // Content
321
+ { widget: "markdown", category: "content", description: "Render markdown text (headers, bold, italic, code, links, lists, tables)", mappingKeys: [], dataShape: "object" },
322
+ { widget: "image", category: "content", description: "Display an image", mappingKeys: [], dataShape: "object" },
323
+ { widget: "callout", category: "content", description: "Callout/alert banner", mappingKeys: [], dataShape: "object" },
324
+ // Chat / Interaction
325
+ { widget: "code", category: "content", description: "Syntax-highlighted code block with line numbers and copy button", mappingKeys: [], dataShape: "object" },
326
+ { widget: "citation", category: "content", description: "Source/reference cards with title, URL, snippet, and source", mappingKeys: [], dataShape: "array" },
327
+ { widget: "status", category: "content", description: "Status indicators with label, value, and level-based coloring", mappingKeys: [], dataShape: "array" },
328
+ { widget: "steps", category: "content", description: "Multi-step progress indicator (done/active/pending/error)", mappingKeys: [], dataShape: "array" },
329
+ { widget: "rating", category: "content", description: "Star/heart/thumb rating display or input", mappingKeys: [], dataShape: "object" },
330
+ { widget: "video", category: "content", description: "Video player with controls, poster, and caption", mappingKeys: [], dataShape: "object" },
331
+ { widget: "gallery", category: "content", description: "Image gallery grid with captions", mappingKeys: [], dataShape: "array" },
332
+ { widget: "kv", category: "content", description: "Key-value pairs display (object or array of {key, value})", mappingKeys: [], dataShape: "object" },
333
+ { widget: "actions", category: "content", description: "Standalone action buttons (quick replies, suggested actions)", mappingKeys: [], dataShape: "none" },
334
+ { widget: "divider", category: "content", description: "Visual separator with optional label", mappingKeys: [], dataShape: "none" },
335
+ { widget: "header", category: "content", description: "Section heading (h1–h3)", mappingKeys: [], dataShape: "object" },
336
+ // Composition
337
+ { widget: "compose", category: "composition", description: "Combine multiple widgets with layout hints", mappingKeys: [], dataShape: "none" }
338
+ ];
339
+ function E(e) {
340
+ if (!e) return [...y];
341
+ const i = y.find((o) => o.widget === e);
342
+ if (i) return T(i);
343
+ const p = y.filter((o) => o.category === e);
344
+ return p.length > 0 ? p : y.filter((o) => o.widget.startsWith(e));
345
+ }
346
+ const A = {
347
+ "chart.bar": {
348
+ widget: "chart.bar",
349
+ data: [{ category: "A", value: 30 }, { category: "B", value: 70 }, { category: "C", value: 45 }],
350
+ mapping: { x: "category", y: "value" }
351
+ },
352
+ "chart.line": {
353
+ widget: "chart.line",
354
+ data: [{ month: "Jan", value: 100 }, { month: "Feb", value: 120 }, { month: "Mar", value: 90 }],
355
+ mapping: { x: "month", y: "value" }
356
+ },
357
+ "chart.area": {
358
+ widget: "chart.area",
359
+ data: [{ month: "Jan", value: 100 }, { month: "Feb", value: 120 }, { month: "Mar", value: 90 }],
360
+ mapping: { x: "month", y: "value" }
361
+ },
362
+ "chart.pie": {
363
+ widget: "chart.pie",
364
+ data: [{ name: "A", value: 40 }, { name: "B", value: 35 }, { name: "C", value: 25 }],
365
+ mapping: { label: "name", value: "value" }
366
+ },
367
+ "chart.scatter": {
368
+ widget: "chart.scatter",
369
+ data: [{ x: 10, y: 20 }, { x: 30, y: 40 }, { x: 50, y: 15 }],
370
+ mapping: { x: "x", y: "y" }
371
+ },
372
+ "chart.radar": {
373
+ widget: "chart.radar",
374
+ data: [{ axis: "Speed", value: 80 }, { axis: "Power", value: 90 }, { axis: "Defense", value: 60 }],
375
+ mapping: { axis: "axis", value: "value" }
376
+ },
377
+ "chart.heatmap": {
378
+ widget: "chart.heatmap",
379
+ data: [
380
+ { x: "Mon", y: "Morning", value: 10 },
381
+ { x: "Mon", y: "Afternoon", value: 20 },
382
+ { x: "Tue", y: "Morning", value: 15 },
383
+ { x: "Tue", y: "Afternoon", value: 25 }
384
+ ],
385
+ mapping: { x: "x", y: "y", value: "value" }
386
+ },
387
+ "chart.box": {
388
+ widget: "chart.box",
389
+ data: [{ group: "A", min: 10, q1: 25, median: 50, q3: 75, max: 90 }],
390
+ mapping: { x: "group", y: ["min", "q1", "median", "q3", "max"] }
391
+ },
392
+ "chart.funnel": {
393
+ widget: "chart.funnel",
394
+ data: [{ stage: "Visit", count: 1e3 }, { stage: "Click", count: 600 }, { stage: "Purchase", count: 200 }],
395
+ mapping: { label: "stage", value: "count" }
396
+ },
397
+ "chart.waterfall": {
398
+ widget: "chart.waterfall",
399
+ data: [{ item: "Revenue", amount: 500 }, { item: "Cost", amount: -200 }, { item: "Tax", amount: -50 }],
400
+ mapping: { x: "item", y: "amount" }
401
+ },
402
+ "chart.treemap": {
403
+ widget: "chart.treemap",
404
+ data: [{ name: "Group A", value: 100 }, { name: "Group B", value: 80 }]
405
+ },
406
+ metric: {
407
+ widget: "metric",
408
+ data: { value: 1284, unit: "users", change: 12.5, trend: "up" }
409
+ },
410
+ "stat-group": {
411
+ widget: "stat-group",
412
+ data: [
413
+ { label: "Users", value: 1284, suffix: "" },
414
+ { label: "Revenue", value: 42e3, suffix: "$" }
415
+ ]
416
+ },
417
+ gauge: {
418
+ widget: "gauge",
419
+ data: { value: 73 },
420
+ options: { min: 0, max: 100, unit: "%" }
421
+ },
422
+ progress: {
423
+ widget: "progress",
424
+ data: { value: 65 },
425
+ options: { min: 0, max: 100, unit: "%" }
426
+ },
427
+ table: {
428
+ widget: "table",
429
+ data: [
430
+ { name: "Alice", role: "Engineer", status: "Active" },
431
+ { name: "Bob", role: "Designer", status: "Away" }
432
+ ]
433
+ },
434
+ list: {
435
+ widget: "list",
436
+ data: [
437
+ { name: "Alice", role: "Engineer" },
438
+ { name: "Bob", role: "Designer" }
439
+ ],
440
+ mapping: { primary: "name", secondary: "role" }
441
+ },
442
+ form: {
443
+ widget: "form",
444
+ fields: [
445
+ { field: "name", label: "Name", type: "text", required: !0 },
446
+ { field: "email", label: "Email", type: "email" }
447
+ ],
448
+ actions: [
449
+ { label: "Submit", action: "submit", style: "primary" }
450
+ ]
451
+ },
452
+ confirm: {
453
+ widget: "confirm",
454
+ title: "Are you sure?",
455
+ description: "This action cannot be undone.",
456
+ actions: [
457
+ { label: "Confirm", action: "submit", style: "danger" },
458
+ { label: "Cancel", action: "cancel" }
459
+ ]
460
+ },
461
+ markdown: {
462
+ widget: "markdown",
463
+ data: { content: `# Hello
464
+
465
+ This is **markdown** content.` }
466
+ },
467
+ image: {
468
+ widget: "image",
469
+ data: { src: "https://placehold.co/300x200", alt: "Placeholder image" }
470
+ },
471
+ callout: {
472
+ widget: "callout",
473
+ data: { content: "This is an informational callout.", variant: "info" }
474
+ },
475
+ code: {
476
+ widget: "code",
477
+ data: { content: `const x = 42;
478
+ console.log(x);`, language: "javascript" }
479
+ },
480
+ citation: {
481
+ widget: "citation",
482
+ data: [
483
+ { title: "u-widgets Documentation", url: "https://github.com/iyulab/u-widgets", source: "GitHub" }
484
+ ]
485
+ },
486
+ status: {
487
+ widget: "status",
488
+ data: [
489
+ { label: "API", value: "Operational", level: "success" },
490
+ { label: "DB", value: "Degraded", level: "warning" }
491
+ ]
492
+ },
493
+ steps: {
494
+ widget: "steps",
495
+ data: [
496
+ { label: "Data collection", status: "done" },
497
+ { label: "Analysis", status: "active" },
498
+ { label: "Report", status: "pending" }
499
+ ]
500
+ },
501
+ rating: {
502
+ widget: "rating",
503
+ data: { value: 4.2 }
504
+ },
505
+ video: {
506
+ widget: "video",
507
+ data: { src: "https://example.com/demo.mp4", poster: "https://example.com/thumb.jpg" }
508
+ },
509
+ gallery: {
510
+ widget: "gallery",
511
+ data: [
512
+ { src: "https://placehold.co/300x200", alt: "Image 1" },
513
+ { src: "https://placehold.co/300x200", alt: "Image 2" },
514
+ { src: "https://placehold.co/300x200", alt: "Image 3" }
515
+ ]
516
+ },
517
+ kv: {
518
+ widget: "kv",
519
+ data: { status: "Active", plan: "Pro", expires: "2026-03-15" }
520
+ },
521
+ actions: {
522
+ widget: "actions",
523
+ actions: [
524
+ { label: "Analyze", action: "analyze" },
525
+ { label: "Export", action: "export", style: "primary" }
526
+ ]
527
+ },
528
+ divider: {
529
+ widget: "divider"
530
+ },
531
+ header: {
532
+ widget: "header",
533
+ data: { text: "Section Title" }
534
+ },
535
+ compose: {
536
+ widget: "compose",
537
+ layout: "grid",
538
+ children: [
539
+ { widget: "metric", data: { value: 42, unit: "items" } },
540
+ { widget: "metric", data: { value: 95, unit: "%" } }
541
+ ]
542
+ }
543
+ }, R = {
544
+ "chart.bar": [
545
+ {
546
+ label: "Stacked multi-series",
547
+ spec: {
548
+ widget: "chart.bar",
549
+ data: [
550
+ { quarter: "Q1", product: 80, service: 40 },
551
+ { quarter: "Q2", product: 100, service: 55 },
552
+ { quarter: "Q3", product: 90, service: 60 }
553
+ ],
554
+ mapping: { x: "quarter", y: ["product", "service"] },
555
+ options: { stack: !0 }
556
+ }
557
+ },
558
+ {
559
+ label: "Horizontal",
560
+ spec: {
561
+ widget: "chart.bar",
562
+ data: [
563
+ { lang: "JavaScript", pct: 65 },
564
+ { lang: "Python", pct: 48 },
565
+ { lang: "TypeScript", pct: 35 }
566
+ ],
567
+ options: { horizontal: !0 }
568
+ }
569
+ }
570
+ ],
571
+ "chart.line": [
572
+ {
573
+ label: "Smooth multi-series",
574
+ spec: {
575
+ widget: "chart.line",
576
+ data: [
577
+ { day: "Mon", cpu: 45, mem: 62 },
578
+ { day: "Tue", cpu: 52, mem: 58 },
579
+ { day: "Wed", cpu: 68, mem: 71 }
580
+ ],
581
+ mapping: { x: "day", y: ["cpu", "mem"] },
582
+ options: { smooth: !0 }
583
+ }
584
+ }
585
+ ],
586
+ "chart.area": [
587
+ {
588
+ label: "Stacked area",
589
+ spec: {
590
+ widget: "chart.area",
591
+ data: [
592
+ { month: "Jan", organic: 100, paid: 60 },
593
+ { month: "Feb", organic: 120, paid: 80 },
594
+ { month: "Mar", organic: 110, paid: 90 }
595
+ ],
596
+ mapping: { x: "month", y: ["organic", "paid"] },
597
+ options: { stack: !0 }
598
+ }
599
+ }
600
+ ],
601
+ "chart.pie": [
602
+ {
603
+ label: "Donut + custom colors",
604
+ spec: {
605
+ widget: "chart.pie",
606
+ data: [
607
+ { category: "Completed", count: 42 },
608
+ { category: "In Progress", count: 18 },
609
+ { category: "Blocked", count: 5 }
610
+ ],
611
+ options: { donut: !0, colors: ["#22c55e", "#f59e0b", "#ef4444"] }
612
+ }
613
+ }
614
+ ],
615
+ "chart.scatter": [
616
+ {
617
+ label: "Color groups",
618
+ spec: {
619
+ widget: "chart.scatter",
620
+ data: [
621
+ { height: 170, weight: 65, group: "A" },
622
+ { height: 175, weight: 72, group: "A" },
623
+ { height: 160, weight: 55, group: "B" },
624
+ { height: 180, weight: 80, group: "B" }
625
+ ],
626
+ mapping: { x: "height", y: "weight", color: "group" }
627
+ }
628
+ }
629
+ ],
630
+ "chart.radar": [
631
+ {
632
+ label: "Multi-person comparison",
633
+ spec: {
634
+ widget: "chart.radar",
635
+ data: [
636
+ { skill: "JS", alice: 90, bob: 70 },
637
+ { skill: "CSS", alice: 80, bob: 85 },
638
+ { skill: "Node", alice: 75, bob: 60 }
639
+ ],
640
+ mapping: { axis: "skill", y: ["alice", "bob"] }
641
+ }
642
+ }
643
+ ],
644
+ "chart.heatmap": [
645
+ {
646
+ label: "Custom colorRange",
647
+ spec: {
648
+ widget: "chart.heatmap",
649
+ data: [
650
+ { x: "Mon", y: "9am", value: 5 },
651
+ { x: "Mon", y: "12pm", value: 20 },
652
+ { x: "Tue", y: "9am", value: 8 },
653
+ { x: "Tue", y: "12pm", value: 25 }
654
+ ],
655
+ mapping: { x: "x", y: "y", value: "value" },
656
+ options: { colorRange: ["#eff6ff", "#3b82f6", "#1e3a5f"] }
657
+ }
658
+ }
659
+ ],
660
+ "chart.box": [
661
+ {
662
+ label: "Multi-group",
663
+ spec: {
664
+ widget: "chart.box",
665
+ data: [
666
+ { group: "Setosa", min: 4.3, q1: 4.8, median: 5, q3: 5.2, max: 5.8 },
667
+ { group: "Versicolor", min: 4.9, q1: 5.6, median: 5.9, q3: 6.3, max: 7 }
668
+ ]
669
+ }
670
+ }
671
+ ],
672
+ "chart.funnel": [
673
+ {
674
+ label: "Marketing funnel",
675
+ spec: {
676
+ widget: "chart.funnel",
677
+ data: [
678
+ { stage: "Impressions", count: 1e4 },
679
+ { stage: "Clicks", count: 3500 },
680
+ { stage: "Sign-ups", count: 800 },
681
+ { stage: "Purchases", count: 200 }
682
+ ]
683
+ }
684
+ }
685
+ ],
686
+ "chart.waterfall": [
687
+ {
688
+ label: "P&L waterfall",
689
+ spec: {
690
+ widget: "chart.waterfall",
691
+ data: [
692
+ { item: "Revenue", amount: 500 },
693
+ { item: "COGS", amount: -200 },
694
+ { item: "OpEx", amount: -120 },
695
+ { item: "Tax", amount: -50 }
696
+ ]
697
+ }
698
+ }
699
+ ],
700
+ "chart.treemap": [
701
+ {
702
+ label: "Nested hierarchy",
703
+ spec: {
704
+ widget: "chart.treemap",
705
+ data: [
706
+ {
707
+ name: "Engineering",
708
+ value: 100,
709
+ children: [
710
+ { name: "Frontend", value: 40 },
711
+ { name: "Backend", value: 35 },
712
+ { name: "DevOps", value: 25 }
713
+ ]
714
+ },
715
+ { name: "Design", value: 50 }
716
+ ]
717
+ }
718
+ }
719
+ ],
720
+ metric: [
721
+ {
722
+ label: "With prefix/suffix",
723
+ spec: {
724
+ widget: "metric",
725
+ data: { value: 4250, label: "Revenue", prefix: "$", suffix: "/mo", change: 8.3, trend: "up" }
726
+ }
727
+ }
728
+ ],
729
+ "stat-group": [
730
+ {
731
+ label: "With all trends",
732
+ spec: {
733
+ widget: "stat-group",
734
+ data: [
735
+ { value: 99.9, unit: "%", label: "Uptime", change: 0.1, trend: "up" },
736
+ { value: 142, label: "Requests/s", change: -5, trend: "down" },
737
+ { value: 3, label: "Incidents", change: 0, trend: "flat" }
738
+ ]
739
+ }
740
+ }
741
+ ],
742
+ gauge: [
743
+ {
744
+ label: "Threshold colors",
745
+ spec: {
746
+ widget: "gauge",
747
+ data: { value: 73 },
748
+ options: {
749
+ min: 0,
750
+ max: 100,
751
+ unit: "%",
752
+ thresholds: [
753
+ { to: 50, color: "green" },
754
+ { to: 80, color: "yellow" },
755
+ { to: 100, color: "red" }
756
+ ]
757
+ }
758
+ }
759
+ }
760
+ ],
761
+ progress: [
762
+ {
763
+ label: "Label + thresholds",
764
+ spec: {
765
+ widget: "progress",
766
+ data: { value: 35, max: 100 },
767
+ options: {
768
+ label: "{percent}% complete",
769
+ thresholds: [
770
+ { to: 30, color: "red" },
771
+ { to: 60, color: "yellow" },
772
+ { to: 100, color: "green" }
773
+ ]
774
+ }
775
+ }
776
+ }
777
+ ],
778
+ table: [
779
+ {
780
+ label: "Formatted columns",
781
+ spec: {
782
+ widget: "table",
783
+ data: [
784
+ { name: "Alice", role: "Engineer", salary: 95e3 },
785
+ { name: "Bob", role: "Designer", salary: 82e3 }
786
+ ],
787
+ mapping: {
788
+ columns: [
789
+ { field: "name", label: "Name" },
790
+ { field: "role", label: "Role" },
791
+ { field: "salary", label: "Salary", format: "currency", align: "right" }
792
+ ]
793
+ }
794
+ }
795
+ }
796
+ ],
797
+ list: [
798
+ {
799
+ label: "Avatar + trailing",
800
+ spec: {
801
+ widget: "list",
802
+ data: [
803
+ { name: "Alice Kim", role: "Engineer", hours: "32h" },
804
+ { name: "Bob Park", role: "Designer", hours: "28h" }
805
+ ],
806
+ mapping: { primary: "name", secondary: "role", trailing: "hours" }
807
+ }
808
+ }
809
+ ],
810
+ form: [
811
+ {
812
+ label: "Validation + pattern",
813
+ spec: {
814
+ widget: "form",
815
+ fields: [
816
+ { field: "username", label: "Username", type: "text", required: !0, minLength: 3, maxLength: 20 },
817
+ { field: "email", label: "Email", type: "email", required: !0 },
818
+ { field: "plan", label: "Plan", type: "radio", options: ["Free", "Pro", "Enterprise"] }
819
+ ],
820
+ actions: [
821
+ { label: "Register", action: "submit", style: "primary" }
822
+ ]
823
+ }
824
+ }
825
+ ],
826
+ confirm: [
827
+ {
828
+ label: "Danger action",
829
+ spec: {
830
+ widget: "confirm",
831
+ title: "Delete Project",
832
+ description: "This action cannot be undone.",
833
+ actions: [
834
+ { label: "Cancel", action: "cancel" },
835
+ { label: "Delete", action: "submit", style: "danger" }
836
+ ]
837
+ }
838
+ }
839
+ ],
840
+ markdown: [
841
+ {
842
+ label: "Rich content",
843
+ spec: {
844
+ widget: "markdown",
845
+ data: { content: `# Getting Started
846
+
847
+ Welcome to **u-widgets**!
848
+
849
+ - Metrics & gauges
850
+ - Charts with minimal JSON
851
+
852
+ \`\`\`json
853
+ { "widget": "metric", "data": { "value": 42 } }
854
+ \`\`\`` }
855
+ }
856
+ }
857
+ ],
858
+ image: [
859
+ {
860
+ label: "With caption",
861
+ spec: {
862
+ widget: "image",
863
+ data: { src: "https://placehold.co/400x200", alt: "Banner", caption: "Declarative widget system" }
864
+ }
865
+ }
866
+ ],
867
+ callout: [
868
+ {
869
+ label: "Info with title",
870
+ spec: {
871
+ widget: "callout",
872
+ data: { title: "Did you know?", message: "u-widgets auto-infers mappings from data shape.", level: "info" }
873
+ }
874
+ }
875
+ ],
876
+ code: [
877
+ {
878
+ label: "Python with line highlights",
879
+ spec: {
880
+ widget: "code",
881
+ data: {
882
+ content: `def fibonacci(n):
883
+ if n <= 1:
884
+ return n
885
+ return fibonacci(n-1) + fibonacci(n-2)
886
+
887
+ print(fibonacci(10))`,
888
+ language: "python"
889
+ },
890
+ options: { highlight: [2, 3] }
891
+ }
892
+ },
893
+ {
894
+ label: "SQL query",
895
+ spec: {
896
+ widget: "code",
897
+ data: {
898
+ content: `SELECT u.name, COUNT(o.id) AS orders
899
+ FROM users u
900
+ LEFT JOIN orders o ON u.id = o.user_id
901
+ WHERE u.active = TRUE
902
+ GROUP BY u.name
903
+ ORDER BY orders DESC
904
+ LIMIT 10;`,
905
+ language: "sql"
906
+ }
907
+ }
908
+ }
909
+ ],
910
+ citation: [
911
+ {
912
+ label: "Multiple sources with snippets",
913
+ spec: {
914
+ widget: "citation",
915
+ data: [
916
+ { title: "Web Components MDN", url: "https://developer.mozilla.org/docs/Web/API/Web_components", snippet: "Create reusable custom elements.", source: "MDN" },
917
+ { title: "Lit Documentation", url: "https://lit.dev/docs/", snippet: "Fast, lightweight web components.", source: "lit.dev" }
918
+ ]
919
+ }
920
+ },
921
+ {
922
+ label: "Compact mode",
923
+ spec: {
924
+ widget: "citation",
925
+ data: [
926
+ { title: "Source A", url: "https://example.com/a" },
927
+ { title: "Source B", url: "https://example.com/b" }
928
+ ],
929
+ options: { compact: !0 }
930
+ }
931
+ }
932
+ ],
933
+ status: [
934
+ {
935
+ label: "System health dashboard",
936
+ spec: {
937
+ widget: "status",
938
+ title: "System Status",
939
+ data: [
940
+ { label: "API Gateway", value: "Operational", level: "success" },
941
+ { label: "Database", value: "Degraded", level: "warning" },
942
+ { label: "CDN", value: "Operational", level: "success" },
943
+ { label: "Auth Service", value: "Down", level: "error" },
944
+ { label: "Backup", value: "Scheduled", level: "info" }
945
+ ]
946
+ }
947
+ }
948
+ ],
949
+ steps: [
950
+ {
951
+ label: "With descriptions",
952
+ spec: {
953
+ widget: "steps",
954
+ data: [
955
+ { label: "Collecting data", status: "done", description: "2M records processed" },
956
+ { label: "Running analysis", status: "active", description: "Estimated 30s remaining" },
957
+ { label: "Generating report", status: "pending" }
958
+ ]
959
+ }
960
+ },
961
+ {
962
+ label: "Horizontal layout",
963
+ spec: {
964
+ widget: "steps",
965
+ data: [
966
+ { label: "Upload", status: "done" },
967
+ { label: "Process", status: "active" },
968
+ { label: "Review", status: "pending" },
969
+ { label: "Deploy", status: "pending" }
970
+ ],
971
+ options: { layout: "horizontal" }
972
+ }
973
+ }
974
+ ],
975
+ rating: [
976
+ {
977
+ label: "Heart icon",
978
+ spec: {
979
+ widget: "rating",
980
+ data: { value: 3, max: 5 },
981
+ options: { icon: "heart" }
982
+ }
983
+ },
984
+ {
985
+ label: "Interactive star",
986
+ spec: {
987
+ widget: "rating",
988
+ options: { interactive: !0, label: "Rate this answer:" }
989
+ }
990
+ }
991
+ ],
992
+ video: [
993
+ {
994
+ label: "Autoplay muted loop",
995
+ spec: {
996
+ widget: "video",
997
+ data: { src: "https://example.com/bg.mp4", caption: "Background video" },
998
+ options: { autoplay: !0, loop: !0, muted: !0 }
999
+ }
1000
+ }
1001
+ ],
1002
+ gallery: [
1003
+ {
1004
+ label: "Square grid with captions",
1005
+ spec: {
1006
+ widget: "gallery",
1007
+ data: [
1008
+ { src: "https://placehold.co/200", alt: "A", caption: "Product A" },
1009
+ { src: "https://placehold.co/200", alt: "B", caption: "Product B" },
1010
+ { src: "https://placehold.co/200", alt: "C", caption: "Product C" },
1011
+ { src: "https://placehold.co/200", alt: "D", caption: "Product D" }
1012
+ ],
1013
+ options: { columns: 2, aspectRatio: "1:1" }
1014
+ }
1015
+ }
1016
+ ],
1017
+ kv: [
1018
+ {
1019
+ label: "Array form (ordered)",
1020
+ spec: {
1021
+ widget: "kv",
1022
+ data: [
1023
+ { key: "Name", value: "Alice Kim" },
1024
+ { key: "Email", value: "alice@example.com" },
1025
+ { key: "Role", value: "Engineer" }
1026
+ ]
1027
+ }
1028
+ },
1029
+ {
1030
+ label: "Horizontal layout",
1031
+ spec: {
1032
+ widget: "kv",
1033
+ data: { CPU: "72%", Memory: "4.2 GB", Disk: "85%" },
1034
+ options: { layout: "horizontal" }
1035
+ }
1036
+ }
1037
+ ],
1038
+ actions: [
1039
+ {
1040
+ label: "Quick replies",
1041
+ spec: {
1042
+ widget: "actions",
1043
+ actions: [
1044
+ { label: "Revenue analysis", action: "analyze_revenue" },
1045
+ { label: "Customer status", action: "customer_status" },
1046
+ { label: "Inventory check", action: "check_inventory" }
1047
+ ]
1048
+ }
1049
+ }
1050
+ ],
1051
+ divider: [
1052
+ {
1053
+ label: "With label",
1054
+ spec: {
1055
+ widget: "divider",
1056
+ options: { label: "Related items" }
1057
+ }
1058
+ }
1059
+ ],
1060
+ header: [
1061
+ {
1062
+ label: "Level 1 heading",
1063
+ spec: {
1064
+ widget: "header",
1065
+ data: { text: "Dashboard", level: 1 }
1066
+ }
1067
+ }
1068
+ ],
1069
+ compose: [
1070
+ {
1071
+ label: "Grid dashboard",
1072
+ spec: {
1073
+ widget: "compose",
1074
+ layout: "grid",
1075
+ columns: 2,
1076
+ children: [
1077
+ { widget: "metric", data: { value: 99.9, unit: "%", label: "Uptime" } },
1078
+ { widget: "metric", data: { value: 142, label: "Requests/s" } },
1079
+ { widget: "progress", data: { value: 680, max: 1e3 }, options: { label: "{value} / 1000" }, span: 2 }
1080
+ ]
1081
+ }
1082
+ },
1083
+ {
1084
+ label: "Column widths (sidebar + main)",
1085
+ spec: {
1086
+ widget: "compose",
1087
+ layout: "grid",
1088
+ columns: 2,
1089
+ options: { widths: [1, 3] },
1090
+ children: [
1091
+ { widget: "kv", data: { plan: "Pro", status: "Active" } },
1092
+ { widget: "table", data: [{ name: "Alice", role: "Dev" }, { name: "Bob", role: "PM" }] }
1093
+ ]
1094
+ }
1095
+ },
1096
+ {
1097
+ label: "Collapsed section",
1098
+ spec: {
1099
+ widget: "compose",
1100
+ children: [
1101
+ { widget: "kv", data: { summary: "All systems operational" } },
1102
+ { widget: "table", title: "Detailed logs", collapsed: !0, data: [{ time: "10:00", event: "Deploy" }] }
1103
+ ]
1104
+ }
1105
+ }
1106
+ ]
1107
+ };
1108
+ function T(e) {
1109
+ const i = e.widget, p = {};
1110
+ for (const a of e.mappingKeys)
1111
+ v[a] && (p[a] = v[a]);
1112
+ const d = {};
1113
+ for (const a of N[i] ?? [])
1114
+ w[a] && (d[a] = w[a]);
1115
+ const o = i === "form" || i === "confirm", s = [], n = A[i];
1116
+ n && s.push({ label: "Minimal", spec: JSON.parse(JSON.stringify(n)) });
1117
+ const r = R[i];
1118
+ if (r)
1119
+ for (const a of r)
1120
+ s.push({ label: a.label, spec: JSON.parse(JSON.stringify(a.spec)) });
1121
+ return {
1122
+ ...e,
1123
+ autoInference: P[i] ?? "",
1124
+ dataFields: [...M[i] ?? []],
1125
+ mappingDocs: p,
1126
+ optionDocs: d,
1127
+ ...o ? { fieldDocs: { ...k } } : {},
1128
+ ...o ? { actionDocs: { ...L } } : {},
1129
+ events: S(i),
1130
+ examples: s
1131
+ };
1132
+ }
1133
+ function O(e) {
1134
+ const i = A[e];
1135
+ if (i)
1136
+ return JSON.parse(JSON.stringify(i));
1137
+ }
1138
+ function q(e, i) {
1139
+ if (e == null) return [];
1140
+ const p = Array.isArray(e) ? e : [e];
1141
+ if (p.length === 0) return [];
1142
+ const d = p[0], o = Object.keys(d);
1143
+ if (o.length === 0) return [];
1144
+ const s = o.filter((t) => typeof d[t] == "string"), n = o.filter((t) => typeof d[t] == "number"), r = Array.isArray(e);
1145
+ if (i) {
1146
+ const t = g(i, e);
1147
+ return t ? [{ widget: i, mapping: t, confidence: 0.8, reason: `Auto-inferred mapping for ${i}` }] : [{ widget: i, confidence: 0.3, reason: `No mapping could be inferred for ${i} from this data shape` }];
1148
+ }
1149
+ const a = [];
1150
+ if (!r && n.includes("value") && a.push({
1151
+ widget: "metric",
1152
+ confidence: 0.95,
1153
+ reason: 'Object data with "value" key is ideal for a metric widget'
1154
+ }), !r && !n.includes("value") && o.length >= 2 && o.every((m) => {
1155
+ const c = d[m];
1156
+ return typeof c == "string" || typeof c == "number" || typeof c == "boolean";
1157
+ }) && a.push({
1158
+ widget: "kv",
1159
+ confidence: 0.9,
1160
+ reason: "Flat object with all primitive values is ideal for key-value display"
1161
+ }), r && o.includes("key") && o.includes("value") && o.length <= 3 && a.push({
1162
+ widget: "kv",
1163
+ confidence: 0.88,
1164
+ reason: 'Array with "key" and "value" fields matches key-value pair pattern'
1165
+ }), r && s.length >= 1 && n.length >= 1) {
1166
+ const t = g("chart.bar", e);
1167
+ a.push({
1168
+ widget: "chart.bar",
1169
+ mapping: t,
1170
+ confidence: n.length === 1 ? 0.9 : 0.7,
1171
+ reason: "Category × value pattern detected"
1172
+ });
1173
+ }
1174
+ if (r && s.length >= 1 && n.length >= 2) {
1175
+ const t = g("chart.line", e);
1176
+ a.push({
1177
+ widget: "chart.line",
1178
+ mapping: t,
1179
+ confidence: 0.8,
1180
+ reason: "Category × multiple values pattern detected (multi-series)"
1181
+ });
1182
+ }
1183
+ if (r && s.length >= 1 && n.length >= 1 && s.some((m) => D(String(p[0][m])))) {
1184
+ const m = g("chart.area", e);
1185
+ a.push({
1186
+ widget: "chart.area",
1187
+ mapping: m,
1188
+ confidence: 0.75,
1189
+ reason: "Date-like category field detected — suitable for time-series area chart"
1190
+ });
1191
+ }
1192
+ if (r && s.length >= 1 && n.length === 1) {
1193
+ const t = g("chart.pie", e);
1194
+ a.push({
1195
+ widget: "chart.pie",
1196
+ mapping: t,
1197
+ confidence: 0.6,
1198
+ reason: "Label + value pattern could work as proportions"
1199
+ });
1200
+ }
1201
+ if (r && n.length >= 2 && s.length === 0) {
1202
+ const t = g("chart.scatter", e);
1203
+ a.push({
1204
+ widget: "chart.scatter",
1205
+ mapping: t,
1206
+ confidence: 0.85,
1207
+ reason: "All-numeric data is ideal for scatter plot"
1208
+ });
1209
+ }
1210
+ if (r && o.length >= 2 && a.push({
1211
+ widget: "table",
1212
+ mapping: g("table", e),
1213
+ confidence: 0.75,
1214
+ reason: "Multi-field array renders well as a table"
1215
+ }), r && s.length >= 1) {
1216
+ const t = g("list", e);
1217
+ a.push({
1218
+ widget: "list",
1219
+ mapping: t,
1220
+ confidence: 0.5,
1221
+ reason: "String fields can display as a list"
1222
+ });
1223
+ }
1224
+ if (!r && n.includes("value") && (n.includes("min") || n.includes("max")) && a.push({
1225
+ widget: "progress",
1226
+ confidence: 0.85,
1227
+ reason: 'Object with "value" and "min"/"max" is ideal for a progress bar'
1228
+ }), !r && n.includes("value") && a.push({
1229
+ widget: "gauge",
1230
+ confidence: 0.7,
1231
+ reason: 'Object with "value" can display as a gauge'
1232
+ }), r && s.length >= 1 && n.length >= 2) {
1233
+ const t = g("chart.radar", e);
1234
+ t && a.push({
1235
+ widget: "chart.radar",
1236
+ mapping: t,
1237
+ confidence: 0.6,
1238
+ reason: "Category × multiple values can display as a radar chart"
1239
+ });
1240
+ }
1241
+ if (r && s.length >= 2 && n.length >= 1) {
1242
+ const t = g("chart.heatmap", e);
1243
+ t && a.push({
1244
+ widget: "chart.heatmap",
1245
+ mapping: t,
1246
+ confidence: 0.65,
1247
+ reason: "Two categories × value pattern suits a heatmap"
1248
+ });
1249
+ }
1250
+ if (r && n.length >= 5) {
1251
+ const t = g("chart.box", e);
1252
+ t && a.push({
1253
+ widget: "chart.box",
1254
+ mapping: t,
1255
+ confidence: 0.7,
1256
+ reason: "Five or more numeric fields fit a box plot (min/q1/median/q3/max)"
1257
+ });
1258
+ }
1259
+ if (r && s.length >= 1 && n.length === 1) {
1260
+ const t = g("chart.funnel", e);
1261
+ t && a.push({
1262
+ widget: "chart.funnel",
1263
+ mapping: t,
1264
+ confidence: 0.45,
1265
+ reason: "Label + value pattern can display as a funnel"
1266
+ });
1267
+ }
1268
+ if (r && s.length >= 1 && n.length >= 1) {
1269
+ const t = g("chart.waterfall", e);
1270
+ t && a.push({
1271
+ widget: "chart.waterfall",
1272
+ mapping: t,
1273
+ confidence: 0.4,
1274
+ reason: "Category × value pattern can display as a waterfall chart"
1275
+ });
1276
+ }
1277
+ if (r && s.length >= 1 && n.length >= 1) {
1278
+ const t = g("chart.treemap", e);
1279
+ t && a.push({
1280
+ widget: "chart.treemap",
1281
+ mapping: t,
1282
+ confidence: 0.35,
1283
+ reason: "Category × value pattern can display as a treemap"
1284
+ });
1285
+ }
1286
+ return r && o.includes("label") && o.includes("value") && a.push({
1287
+ widget: "stat-group",
1288
+ confidence: 0.85,
1289
+ reason: 'Array with "label" and "value" keys matches stat-group pattern'
1290
+ }), a.sort((t, m) => m.confidence - t.confidence), a;
1291
+ }
1292
+ function j(e) {
1293
+ const i = q(e);
1294
+ if (i.length === 0) return;
1295
+ const p = i[0];
1296
+ if (p.confidence < 0.7) return;
1297
+ const d = { widget: p.widget, data: e };
1298
+ return p.mapping && (d.mapping = p.mapping), d;
1299
+ }
1300
+ function f(e) {
1301
+ if (e == null) return "null";
1302
+ if (Array.isArray(e)) {
1303
+ if (e.length === 0) return "array";
1304
+ const i = e[0];
1305
+ return typeof i == "object" && i !== null ? "object[]" : `${typeof i}[]`;
1306
+ }
1307
+ return typeof e;
1308
+ }
1309
+ function I(e, i) {
1310
+ const p = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1311
+ for (const m of e) {
1312
+ const c = m;
1313
+ for (const l of Object.keys(c))
1314
+ l !== "widget" && p.add(l);
1315
+ const h = c.data;
1316
+ if (Array.isArray(h)) {
1317
+ for (const l of h)
1318
+ if (l && typeof l == "object")
1319
+ for (const [u, b] of Object.entries(l))
1320
+ d.set(u, f(b));
1321
+ } else if (h && typeof h == "object")
1322
+ for (const [l, u] of Object.entries(h))
1323
+ d.set(l, f(u));
1324
+ if (c.mapping && typeof c.mapping == "object")
1325
+ for (const [l, u] of Object.entries(c.mapping))
1326
+ o.set(l, Array.isArray(u) ? "string[]" : typeof u);
1327
+ if (c.options && typeof c.options == "object")
1328
+ for (const [l, u] of Object.entries(c.options))
1329
+ s.set(l, f(u));
1330
+ if (Array.isArray(c.fields))
1331
+ for (const l of c.fields) {
1332
+ for (const [u, b] of Object.entries(l))
1333
+ n.set(u, u === "options" ? "string[]" : f(b));
1334
+ typeof l.type == "string" && r.add(l.type);
1335
+ }
1336
+ if (Array.isArray(c.actions))
1337
+ for (const l of c.actions)
1338
+ typeof l.style == "string" && a.add(l.style);
1339
+ }
1340
+ const t = (m, c) => [...m.entries()].map(([h, l]) => {
1341
+ const u = c[h];
1342
+ return u ? { key: h, type: l, desc: u } : { key: h, type: l };
1343
+ });
1344
+ return {
1345
+ specKeys: [...p],
1346
+ dataFields: t(d, C),
1347
+ mappingKeys: t(o, v),
1348
+ optionKeys: t(s, w),
1349
+ fieldProps: t(n, k),
1350
+ fieldTypes: [...r],
1351
+ actionStyles: [...a],
1352
+ events: i ? S(i) : []
1353
+ };
1354
+ }
1355
+ export {
1356
+ L as ACTION_PROP_DOCS,
1357
+ C as DATA_FIELD_DOCS,
1358
+ k as FIELD_PROP_DOCS,
1359
+ v as MAPPING_DOCS,
1360
+ w as OPTION_DOCS,
1361
+ M as WIDGET_DATA_FIELDS,
1362
+ x as WIDGET_EVENTS,
1363
+ P as WIDGET_INFERENCE,
1364
+ N as WIDGET_OPTIONS,
1365
+ j as autoSpec,
1366
+ S as getWidgetEvents,
1367
+ E as help,
1368
+ I as specSurface,
1369
+ q as suggestMapping,
1370
+ O as template
1371
+ };
1372
+ //# sourceMappingURL=u-widgets-tools.js.map