@iyulab/u-widgets 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/format-DiXp3HTj.js +152 -0
- package/dist/format-DiXp3HTj.js.map +1 -0
- package/dist/tokens-byMop3gk.js +64 -0
- package/dist/tokens-byMop3gk.js.map +1 -0
- package/dist/u-widgets-charts.js +2 -1
- package/dist/u-widgets-charts.js.map +1 -1
- package/dist/u-widgets-math.d.ts +219 -0
- package/dist/u-widgets-math.js +95 -0
- package/dist/u-widgets-math.js.map +1 -0
- package/dist/u-widgets-react.d.ts +265 -0
- package/dist/u-widgets-react.js +15 -0
- package/dist/u-widgets-react.js.map +1 -0
- package/dist/u-widgets-tools.js +52 -21
- package/dist/u-widgets-tools.js.map +1 -1
- package/dist/u-widgets.d.ts +1 -1
- package/dist/u-widgets.js +68 -63
- package/dist/u-widgets.js.map +1 -1
- package/package.json +28 -3
- package/schema/u-widget.schema.json +1 -1
- package/dist/tokens-SjA7YdRs.js +0 -213
- package/dist/tokens-SjA7YdRs.js.map +0 -1
package/dist/u-widgets-tools.js
CHANGED
|
@@ -30,7 +30,7 @@ const v = {
|
|
|
30
30
|
max: "Maximum value",
|
|
31
31
|
step: "Number/range step increment",
|
|
32
32
|
message: "Custom validation error message"
|
|
33
|
-
},
|
|
33
|
+
}, L = {
|
|
34
34
|
// metric / stat-group
|
|
35
35
|
value: "The primary value to display",
|
|
36
36
|
label: "Display label or category name",
|
|
@@ -66,6 +66,8 @@ const v = {
|
|
|
66
66
|
url: "Link URL",
|
|
67
67
|
snippet: "Excerpt or summary text",
|
|
68
68
|
source: "Source name or publisher",
|
|
69
|
+
// math
|
|
70
|
+
expression: "LaTeX math expression string",
|
|
69
71
|
// chart data
|
|
70
72
|
group: "Group / category identifier",
|
|
71
73
|
min: "Minimum stat value",
|
|
@@ -121,19 +123,21 @@ const v = {
|
|
|
121
123
|
muted: "Start muted (default false, auto when autoplay)",
|
|
122
124
|
// gallery
|
|
123
125
|
aspectRatio: 'Image aspect ratio (e.g. "1:1", "16:9", default auto)',
|
|
126
|
+
// math
|
|
127
|
+
displayMode: "Block mode with centered large formula (default false = inline)",
|
|
124
128
|
// compose / kv / actions / divider / steps
|
|
125
129
|
layout: "Layout mode (stack, row, grid, horizontal, vertical, wrap, column)",
|
|
126
130
|
columns: "Number of grid columns",
|
|
127
131
|
widths: 'Column width ratios (number[], "auto", "stretch")',
|
|
128
132
|
spacing: "Spacing size (small, default, large)",
|
|
129
133
|
card: "Render inside a card container with shadow and border"
|
|
130
|
-
},
|
|
134
|
+
}, C = {
|
|
131
135
|
label: "Button text",
|
|
132
136
|
action: "Action identifier (submit, cancel, navigate, custom)",
|
|
133
137
|
style: "Visual style (primary, danger, default)",
|
|
134
138
|
disabled: "Whether disabled",
|
|
135
139
|
url: "URL for navigate action"
|
|
136
|
-
},
|
|
140
|
+
}, M = {
|
|
137
141
|
"chart.bar": ["stack", "horizontal", "histogram", "colors", "series", "referenceLines", "conditionalStyles", "xFormat", "yFormat", "legend", "grid", "animate", "showLabel"],
|
|
138
142
|
"chart.line": ["smooth", "stack", "step", "colors", "series", "referenceLines", "conditionalStyles", "xFormat", "yFormat", "legend", "grid", "animate", "showLabel"],
|
|
139
143
|
"chart.area": ["smooth", "stack", "colors", "series", "conditionalStyles", "xFormat", "yFormat", "legend", "grid", "animate", "showLabel"],
|
|
@@ -166,10 +170,11 @@ const v = {
|
|
|
166
170
|
rating: ["max", "interactive", "icon", "label"],
|
|
167
171
|
video: ["autoplay", "controls", "loop", "muted"],
|
|
168
172
|
gallery: ["columns", "aspectRatio"],
|
|
173
|
+
math: ["displayMode"],
|
|
169
174
|
actions: ["layout"],
|
|
170
175
|
divider: [],
|
|
171
176
|
header: []
|
|
172
|
-
},
|
|
177
|
+
}, N = {
|
|
173
178
|
metric: [
|
|
174
179
|
{ key: "value", type: "number | string", desc: "Primary value", required: !0 },
|
|
175
180
|
{ key: "label", type: "string", desc: "Display label" },
|
|
@@ -216,6 +221,9 @@ const v = {
|
|
|
216
221
|
{ key: "content", type: "string", desc: "Code text content", required: !0 },
|
|
217
222
|
{ key: "language", type: "string", desc: "Language identifier (e.g. javascript, python, sql)" }
|
|
218
223
|
],
|
|
224
|
+
math: [
|
|
225
|
+
{ key: "expression", type: "string", desc: "LaTeX math expression", required: !0 }
|
|
226
|
+
],
|
|
219
227
|
header: [
|
|
220
228
|
{ key: "text", type: "string", desc: "Heading text", required: !0 },
|
|
221
229
|
{ key: "level", type: "1 | 2 | 3", desc: "Heading level (default 2)" }
|
|
@@ -253,7 +261,7 @@ const v = {
|
|
|
253
261
|
{ key: "value", type: "string", desc: "Status value", required: !0 },
|
|
254
262
|
{ key: "level", type: '"info" | "success" | "warning" | "error" | "neutral"', desc: "Severity level (default info)" }
|
|
255
263
|
]
|
|
256
|
-
},
|
|
264
|
+
}, T = {
|
|
257
265
|
"chart.bar": "mapping omittable. First string → x, number fields → y.",
|
|
258
266
|
"chart.line": "mapping omittable. First string → x, numbers → y. Date-like preferred for x.",
|
|
259
267
|
"chart.area": "mapping omittable. Same as line — first string → x, numbers → y.",
|
|
@@ -286,6 +294,7 @@ const v = {
|
|
|
286
294
|
gallery: "No mapping. data is [{src, alt?, caption?}]. columns/aspectRatio in options.",
|
|
287
295
|
steps: "No mapping. data is [{label, status?, description?, icon?}]. status: done/active/pending/error. icon: emoji/text override. layout: vertical/horizontal.",
|
|
288
296
|
rating: "No mapping. data is {value?, max?}. options: interactive, icon (star/heart/thumb), max, label.",
|
|
297
|
+
math: "No mapping. data is {expression}. Renders LaTeX via KaTeX. displayMode in options.",
|
|
289
298
|
actions: "No data. Uses actions[] array. layout in options (wrap/column).",
|
|
290
299
|
divider: "No data. label/spacing in options.",
|
|
291
300
|
header: "data is {text, level?}. level defaults to 2."
|
|
@@ -340,6 +349,7 @@ const y = [
|
|
|
340
349
|
{ widget: "video", category: "content", description: "Video player with controls, poster, and caption", mappingKeys: [], dataShape: "object" },
|
|
341
350
|
{ widget: "gallery", category: "content", description: "Image gallery grid with captions", mappingKeys: [], dataShape: "array" },
|
|
342
351
|
{ widget: "kv", category: "content", description: "Key-value pairs display (object or array of {key, value})", mappingKeys: [], dataShape: "object" },
|
|
352
|
+
{ widget: "math", category: "content", description: "Render LaTeX mathematical expressions via KaTeX", mappingKeys: [], dataShape: "object" },
|
|
343
353
|
{ widget: "actions", category: "content", description: "Standalone action buttons (quick replies, suggested actions)", mappingKeys: [], dataShape: "none" },
|
|
344
354
|
{ widget: "divider", category: "content", description: "Visual separator with optional label", mappingKeys: [], dataShape: "none" },
|
|
345
355
|
{ widget: "header", category: "content", description: "Section heading (h1–h3)", mappingKeys: [], dataShape: "object" },
|
|
@@ -484,7 +494,7 @@ This is **markdown** content.` }
|
|
|
484
494
|
},
|
|
485
495
|
callout: {
|
|
486
496
|
widget: "callout",
|
|
487
|
-
data: {
|
|
497
|
+
data: { message: "This is an informational callout.", level: "info" }
|
|
488
498
|
},
|
|
489
499
|
code: {
|
|
490
500
|
widget: "code",
|
|
@@ -532,6 +542,10 @@ console.log(x);`, language: "javascript" }
|
|
|
532
542
|
widget: "kv",
|
|
533
543
|
data: { status: "Active", plan: "Pro", expires: "2026-03-15" }
|
|
534
544
|
},
|
|
545
|
+
math: {
|
|
546
|
+
widget: "math",
|
|
547
|
+
data: { expression: "E = mc^2" }
|
|
548
|
+
},
|
|
535
549
|
actions: {
|
|
536
550
|
widget: "actions",
|
|
537
551
|
actions: [
|
|
@@ -554,7 +568,7 @@ console.log(x);`, language: "javascript" }
|
|
|
554
568
|
{ widget: "metric", data: { value: 95, unit: "%" } }
|
|
555
569
|
]
|
|
556
570
|
}
|
|
557
|
-
},
|
|
571
|
+
}, P = {
|
|
558
572
|
"chart.bar": [
|
|
559
573
|
{
|
|
560
574
|
label: "Stacked multi-series",
|
|
@@ -1064,6 +1078,23 @@ LIMIT 10;`,
|
|
|
1064
1078
|
}
|
|
1065
1079
|
}
|
|
1066
1080
|
],
|
|
1081
|
+
math: [
|
|
1082
|
+
{
|
|
1083
|
+
label: "Display mode (block)",
|
|
1084
|
+
spec: {
|
|
1085
|
+
widget: "math",
|
|
1086
|
+
data: { expression: "C_{pk} = \\min\\left(\\frac{USL - \\bar{x}}{3\\sigma},\\; \\frac{\\bar{x} - LSL}{3\\sigma}\\right)" },
|
|
1087
|
+
options: { displayMode: !0 }
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
label: "Simple inline",
|
|
1092
|
+
spec: {
|
|
1093
|
+
widget: "math",
|
|
1094
|
+
data: { expression: "a^2 + b^2 = c^2" }
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
],
|
|
1067
1098
|
actions: [
|
|
1068
1099
|
{
|
|
1069
1100
|
label: "Quick replies",
|
|
@@ -1139,22 +1170,22 @@ function K(e) {
|
|
|
1139
1170
|
for (const a of e.mappingKeys)
|
|
1140
1171
|
v[a] && (d[a] = v[a]);
|
|
1141
1172
|
const p = {};
|
|
1142
|
-
for (const a of
|
|
1173
|
+
for (const a of M[i] ?? [])
|
|
1143
1174
|
w[a] && (p[a] = w[a]);
|
|
1144
1175
|
const o = i === "form" || i === "confirm", l = [], n = A[i];
|
|
1145
1176
|
n && l.push({ label: "Minimal", spec: JSON.parse(JSON.stringify(n)) });
|
|
1146
|
-
const r =
|
|
1177
|
+
const r = P[i];
|
|
1147
1178
|
if (r)
|
|
1148
1179
|
for (const a of r)
|
|
1149
1180
|
l.push({ label: a.label, spec: JSON.parse(JSON.stringify(a.spec)) });
|
|
1150
1181
|
return {
|
|
1151
1182
|
...e,
|
|
1152
|
-
autoInference:
|
|
1153
|
-
dataFields: [...
|
|
1183
|
+
autoInference: T[i] ?? "",
|
|
1184
|
+
dataFields: [...N[i] ?? []],
|
|
1154
1185
|
mappingDocs: d,
|
|
1155
1186
|
optionDocs: p,
|
|
1156
1187
|
...o ? { fieldDocs: { ...S } } : {},
|
|
1157
|
-
...o ? { actionDocs: { ...
|
|
1188
|
+
...o ? { actionDocs: { ...C } } : {},
|
|
1158
1189
|
events: k(i),
|
|
1159
1190
|
examples: l
|
|
1160
1191
|
};
|
|
@@ -1164,7 +1195,7 @@ function O(e) {
|
|
|
1164
1195
|
if (i)
|
|
1165
1196
|
return JSON.parse(JSON.stringify(i));
|
|
1166
1197
|
}
|
|
1167
|
-
function
|
|
1198
|
+
function q(e, i) {
|
|
1168
1199
|
if (e == null) return [];
|
|
1169
1200
|
const d = Array.isArray(e) ? e : [e];
|
|
1170
1201
|
if (d.length === 0) return [];
|
|
@@ -1319,7 +1350,7 @@ function R(e, i) {
|
|
|
1319
1350
|
}), a.sort((t, m) => m.confidence - t.confidence), a;
|
|
1320
1351
|
}
|
|
1321
1352
|
function j(e) {
|
|
1322
|
-
const i =
|
|
1353
|
+
const i = q(e);
|
|
1323
1354
|
if (i.length === 0) return;
|
|
1324
1355
|
const d = i[0];
|
|
1325
1356
|
if (d.confidence < 0.7) return;
|
|
@@ -1372,7 +1403,7 @@ function F(e, i) {
|
|
|
1372
1403
|
});
|
|
1373
1404
|
return {
|
|
1374
1405
|
specKeys: [...d],
|
|
1375
|
-
dataFields: t(p,
|
|
1406
|
+
dataFields: t(p, L),
|
|
1376
1407
|
mappingKeys: t(o, v),
|
|
1377
1408
|
optionKeys: t(l, w),
|
|
1378
1409
|
fieldProps: t(n, S),
|
|
@@ -1382,20 +1413,20 @@ function F(e, i) {
|
|
|
1382
1413
|
};
|
|
1383
1414
|
}
|
|
1384
1415
|
export {
|
|
1385
|
-
|
|
1386
|
-
|
|
1416
|
+
C as ACTION_PROP_DOCS,
|
|
1417
|
+
L as DATA_FIELD_DOCS,
|
|
1387
1418
|
S as FIELD_PROP_DOCS,
|
|
1388
1419
|
v as MAPPING_DOCS,
|
|
1389
1420
|
w as OPTION_DOCS,
|
|
1390
|
-
|
|
1421
|
+
N as WIDGET_DATA_FIELDS,
|
|
1391
1422
|
x as WIDGET_EVENTS,
|
|
1392
|
-
|
|
1393
|
-
|
|
1423
|
+
T as WIDGET_INFERENCE,
|
|
1424
|
+
M as WIDGET_OPTIONS,
|
|
1394
1425
|
j as autoSpec,
|
|
1395
1426
|
k as getWidgetEvents,
|
|
1396
1427
|
E as help,
|
|
1397
1428
|
F as specSurface,
|
|
1398
|
-
|
|
1429
|
+
q as suggestMapping,
|
|
1399
1430
|
O as template
|
|
1400
1431
|
};
|
|
1401
1432
|
//# sourceMappingURL=u-widgets-tools.js.map
|