@iyulab/u-widgets 0.9.2 → 0.10.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-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 +13 -3
- package/schema/u-widget.schema.json +1 -1
- package/dist/tokens-SjA7YdRs.js +0 -213
- package/dist/tokens-SjA7YdRs.js.map +0 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { nothing } from 'lit';
|
|
4
|
+
import { TemplateResult } from 'lit-html';
|
|
5
|
+
|
|
6
|
+
/** Supported input field types for form widgets. */
|
|
7
|
+
declare type FieldType = 'text' | 'email' | 'password' | 'tel' | 'url' | 'textarea' | 'number' | 'select' | 'multiselect' | 'date' | 'datetime' | 'time' | 'toggle' | 'range' | 'radio' | 'checkbox';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Action button definition.
|
|
11
|
+
*
|
|
12
|
+
* Reserved actions: `"submit"`, `"cancel"`, `"navigate"`.
|
|
13
|
+
* Custom action strings are forwarded to the host via the `u-widget-event`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```json
|
|
17
|
+
* { "label": "Submit", "action": "submit", "style": "primary" }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare interface UWidgetAction {
|
|
21
|
+
/** Button display text. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Action identifier emitted in the widget event. */
|
|
24
|
+
action: string;
|
|
25
|
+
/** Visual style hint. */
|
|
26
|
+
style?: 'primary' | 'danger' | 'default';
|
|
27
|
+
/** Whether the button is disabled. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** URL for `"navigate"` actions. */
|
|
30
|
+
url?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Child widget spec inside a compose widget.
|
|
35
|
+
* Inherits `type` and `version` from the parent — no need to repeat them.
|
|
36
|
+
*/
|
|
37
|
+
declare interface UWidgetChildSpec extends Omit<UWidgetSpec, 'type' | 'version'> {
|
|
38
|
+
/** Grid column span within the parent compose layout. */
|
|
39
|
+
span?: number;
|
|
40
|
+
/** When true, the child is initially collapsed (uses native `<details>`). */
|
|
41
|
+
collapsed?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Column definition for table widgets.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```json
|
|
49
|
+
* { "field": "price", "label": "Price", "format": "currency", "align": "right" }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare interface UWidgetColumnDefinition {
|
|
53
|
+
/** Data field name to display in this column. */
|
|
54
|
+
field: string;
|
|
55
|
+
/** Display header label. Defaults to the field name. */
|
|
56
|
+
label?: string;
|
|
57
|
+
/** Value formatting hint (e.g., `"currency"`, `"currency:EUR"`, `"percent"`). */
|
|
58
|
+
format?: 'number' | 'currency' | 'percent' | 'date' | 'datetime' | 'bytes';
|
|
59
|
+
/** Text alignment within the column. */
|
|
60
|
+
align?: 'left' | 'center' | 'right';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Field definition for form/confirm input widgets.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```json
|
|
68
|
+
* { "field": "email", "label": "Email", "type": "email", "required": true }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare interface UWidgetFieldDefinition {
|
|
72
|
+
/** Data field name (maps to `data[field]` for defaults and output). */
|
|
73
|
+
field: string;
|
|
74
|
+
/** Display label. Defaults to the field name. */
|
|
75
|
+
label?: string;
|
|
76
|
+
/** Input type. Defaults to `"text"`. */
|
|
77
|
+
type?: FieldType;
|
|
78
|
+
/** Whether the field must be filled before submit. */
|
|
79
|
+
required?: boolean;
|
|
80
|
+
/** Placeholder text shown when the field is empty. */
|
|
81
|
+
placeholder?: string;
|
|
82
|
+
/** Options for select, multiselect, radio, and checkbox types. */
|
|
83
|
+
options?: string[];
|
|
84
|
+
/** Minimum character length for text inputs. */
|
|
85
|
+
minLength?: number;
|
|
86
|
+
/** Maximum character length for text inputs. */
|
|
87
|
+
maxLength?: number;
|
|
88
|
+
/** Custom regex pattern for validation (e.g. `"^[A-Z]{3}$"`). */
|
|
89
|
+
pattern?: string;
|
|
90
|
+
/** Number of visible rows for textarea type. */
|
|
91
|
+
rows?: number;
|
|
92
|
+
/** Minimum value (number) or date string. */
|
|
93
|
+
min?: number | string;
|
|
94
|
+
/** Maximum value (number) or date string. */
|
|
95
|
+
max?: number | string;
|
|
96
|
+
/** Step increment for number and range inputs. */
|
|
97
|
+
step?: number;
|
|
98
|
+
/** Custom validation error message (overrides locale default). */
|
|
99
|
+
message?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Mapping connects data fields to visual channels.
|
|
104
|
+
*
|
|
105
|
+
* Which keys are relevant depends on the widget type:
|
|
106
|
+
* - **chart.bar/line/area:** `x`, `y`
|
|
107
|
+
* - **chart.pie/funnel:** `label`, `value`
|
|
108
|
+
* - **chart.scatter:** `x`, `y`, `color`, `size`
|
|
109
|
+
* - **chart.radar:** `axis`, `value`
|
|
110
|
+
* - **table:** `columns`
|
|
111
|
+
* - **list:** `primary`, `secondary`, `avatar`, `icon`, `trailing`
|
|
112
|
+
*
|
|
113
|
+
* When omitted, mapping is auto-inferred from the data shape.
|
|
114
|
+
*/
|
|
115
|
+
declare interface UWidgetMapping {
|
|
116
|
+
/** Category axis field (chart x-axis). */
|
|
117
|
+
x?: string;
|
|
118
|
+
/** Value axis field(s). A string for single series, string[] for multi-series. */
|
|
119
|
+
y?: string | string[];
|
|
120
|
+
/** Label field (pie/funnel charts). */
|
|
121
|
+
label?: string;
|
|
122
|
+
/** Value field (pie/funnel/heatmap). */
|
|
123
|
+
value?: string;
|
|
124
|
+
/** Color grouping field (scatter). */
|
|
125
|
+
color?: string;
|
|
126
|
+
/** Size encoding field (scatter bubble). */
|
|
127
|
+
size?: string;
|
|
128
|
+
/** Opacity encoding field (scatter). Maps data values to point opacity (0.1–1.0). */
|
|
129
|
+
opacity?: string;
|
|
130
|
+
/** Axis field (radar chart indicators). */
|
|
131
|
+
axis?: string;
|
|
132
|
+
/** Explicit column definitions for table widgets. */
|
|
133
|
+
columns?: UWidgetColumnDefinition[];
|
|
134
|
+
/** Primary text field (list widget). */
|
|
135
|
+
primary?: string;
|
|
136
|
+
/** Secondary/subtitle text field (list widget). */
|
|
137
|
+
secondary?: string;
|
|
138
|
+
/** Icon letter field (list widget fallback when no avatar). */
|
|
139
|
+
icon?: string;
|
|
140
|
+
/** Avatar image URL field (list widget). */
|
|
141
|
+
avatar?: string;
|
|
142
|
+
/** Trailing value field displayed on the right (list widget). */
|
|
143
|
+
trailing?: string;
|
|
144
|
+
/** Badge/tag field (list widget). */
|
|
145
|
+
badge?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The u-widget spec envelope — a single, consistent structure for all widgets.
|
|
150
|
+
*
|
|
151
|
+
* Only `widget` is required. All other fields are optional or auto-inferred.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const spec: UWidgetSpec = {
|
|
156
|
+
* widget: 'chart.bar',
|
|
157
|
+
* data: [{ name: 'A', value: 30 }, { name: 'B', value: 70 }],
|
|
158
|
+
* mapping: { x: 'name', y: 'value' },
|
|
159
|
+
* };
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare interface UWidgetSpec {
|
|
163
|
+
/** Widget type identifier (e.g., `"chart.bar"`, `"metric"`, `"form"`). */
|
|
164
|
+
widget: string;
|
|
165
|
+
/** Unique identifier for event correlation and compose children. */
|
|
166
|
+
id?: string;
|
|
167
|
+
/** Optional display title rendered above the widget. */
|
|
168
|
+
title?: string;
|
|
169
|
+
/** Optional description text rendered below the title. */
|
|
170
|
+
description?: string;
|
|
171
|
+
/** Inline data — an object (metric/gauge) or array of records (chart/table). */
|
|
172
|
+
data?: Record<string, unknown> | Record<string, unknown>[];
|
|
173
|
+
/** Maps data fields to visual channels. Auto-inferred when omitted. */
|
|
174
|
+
mapping?: UWidgetMapping;
|
|
175
|
+
/** Field definitions for form/confirm widgets. */
|
|
176
|
+
fields?: UWidgetFieldDefinition[];
|
|
177
|
+
/** Formdown shorthand syntax for form fields (mutually exclusive with `fields`). */
|
|
178
|
+
formdown?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Widget-specific rendering options.
|
|
181
|
+
*
|
|
182
|
+
* Chart widgets support an `echarts` sub-key for native ECharts option passthrough:
|
|
183
|
+
* ```json
|
|
184
|
+
* { "options": { "echarts": { "tooltip": { "trigger": "axis" } } } }
|
|
185
|
+
* ```
|
|
186
|
+
* All keys in `options.echarts` are deep-merged into the generated ECharts option.
|
|
187
|
+
* @see https://echarts.apache.org/en/option.html
|
|
188
|
+
*/
|
|
189
|
+
options?: Record<string, unknown>;
|
|
190
|
+
/** Action buttons displayed below the widget. */
|
|
191
|
+
actions?: UWidgetAction[];
|
|
192
|
+
/** Interchange format type marker. Always `"u-widget"` if present. */
|
|
193
|
+
type?: 'u-widget';
|
|
194
|
+
/** Interchange format version string. */
|
|
195
|
+
version?: string;
|
|
196
|
+
/** Layout mode for compose widget: `"stack"` (default), `"row"`, or `"grid"`. */
|
|
197
|
+
layout?: 'stack' | 'row' | 'grid';
|
|
198
|
+
/** Number of grid columns for compose `"grid"` layout. Default: 2. */
|
|
199
|
+
columns?: number;
|
|
200
|
+
/** Child widget specs for compose widget. */
|
|
201
|
+
children?: UWidgetChildSpec[];
|
|
202
|
+
/** Grid column span for children inside a compose `"grid"` layout. */
|
|
203
|
+
span?: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* <uw-math> — LaTeX math expression renderer via KaTeX.
|
|
208
|
+
*
|
|
209
|
+
* Uses MathML output for zero-CSS rendering in Shadow DOM.
|
|
210
|
+
* Loaded via the `u-widgets/math` entry point. Requires `katex` as a peer dependency.
|
|
211
|
+
*/
|
|
212
|
+
export declare class UwMath extends LitElement {
|
|
213
|
+
static styles: CSSResult[];
|
|
214
|
+
spec: UWidgetSpec | null;
|
|
215
|
+
theme: string | null;
|
|
216
|
+
render(): typeof nothing | TemplateResult<1>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { }
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { css as m, LitElement as u, nothing as p, html as c } from "lit";
|
|
2
|
+
import { property as d, customElement as h } from "lit/decorators.js";
|
|
3
|
+
import { t as f } from "./tokens-byMop3gk.js";
|
|
4
|
+
import g from "katex";
|
|
5
|
+
var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, l = (o, t, a, r) => {
|
|
6
|
+
for (var e = r > 1 ? void 0 : r ? y(t, a) : t, s = o.length - 1, n; s >= 0; s--)
|
|
7
|
+
(n = o[s]) && (e = (r ? n(t, a, e) : n(e)) || e);
|
|
8
|
+
return r && e && v(t, a, e), e;
|
|
9
|
+
};
|
|
10
|
+
let i = class extends u {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.spec = null, this.theme = null;
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
if (!this.spec) return p;
|
|
16
|
+
const o = this.spec.data;
|
|
17
|
+
if (!o) return p;
|
|
18
|
+
const t = String(o.expression ?? "").trim();
|
|
19
|
+
if (!t) return p;
|
|
20
|
+
const r = !!((this.spec.options ?? {}).displayMode ?? !1);
|
|
21
|
+
try {
|
|
22
|
+
const e = g.renderToString(t, {
|
|
23
|
+
displayMode: r,
|
|
24
|
+
throwOnError: !0,
|
|
25
|
+
output: "mathml"
|
|
26
|
+
});
|
|
27
|
+
return c`
|
|
28
|
+
<div
|
|
29
|
+
class="math-block"
|
|
30
|
+
part="math"
|
|
31
|
+
data-display=${String(r)}
|
|
32
|
+
.innerHTML=${e}
|
|
33
|
+
></div>
|
|
34
|
+
`;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
const s = e instanceof Error ? e.message : "Invalid expression";
|
|
37
|
+
return c`
|
|
38
|
+
<div class="math-error" part="math-error">
|
|
39
|
+
${s}
|
|
40
|
+
<code>${t}</code>
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
i.styles = [f, m`
|
|
47
|
+
:host {
|
|
48
|
+
display: block;
|
|
49
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
50
|
+
container: uw-math / inline-size;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.math-block {
|
|
54
|
+
color: var(--u-widget-text, #1a1a2e);
|
|
55
|
+
overflow-x: auto;
|
|
56
|
+
font-size: 1rem;
|
|
57
|
+
line-height: 1.6;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.math-block[data-display="true"] {
|
|
61
|
+
text-align: center;
|
|
62
|
+
padding: 8px 0;
|
|
63
|
+
font-size: 1.2rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.math-error {
|
|
67
|
+
padding: 8px 12px;
|
|
68
|
+
border-radius: 4px;
|
|
69
|
+
border: 1px solid var(--u-widget-negative, #dc2626);
|
|
70
|
+
background: color-mix(in srgb, var(--u-widget-negative, #dc2626) 8%, var(--u-widget-bg, #fff));
|
|
71
|
+
font-size: 0.8125rem;
|
|
72
|
+
color: var(--u-widget-negative, #dc2626);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.math-error code {
|
|
76
|
+
display: block;
|
|
77
|
+
margin-top: 4px;
|
|
78
|
+
font-size: 0.75rem;
|
|
79
|
+
color: var(--u-widget-text-secondary, #64748b);
|
|
80
|
+
word-break: break-all;
|
|
81
|
+
}
|
|
82
|
+
`];
|
|
83
|
+
l([
|
|
84
|
+
d({ type: Object })
|
|
85
|
+
], i.prototype, "spec", 2);
|
|
86
|
+
l([
|
|
87
|
+
d({ type: String, reflect: !0 })
|
|
88
|
+
], i.prototype, "theme", 2);
|
|
89
|
+
i = l([
|
|
90
|
+
h("uw-math")
|
|
91
|
+
], i);
|
|
92
|
+
export {
|
|
93
|
+
i as UwMath
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=u-widgets-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"u-widgets-math.js","sources":["../src/elements/uw-math.ts"],"sourcesContent":["import { LitElement, html, css, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport type { UWidgetSpec } from '../core/types.js';\nimport { themeStyles } from '../styles/tokens.js';\nimport katex from 'katex';\n\n/**\n * <uw-math> — LaTeX math expression renderer via KaTeX.\n *\n * Uses MathML output for zero-CSS rendering in Shadow DOM.\n * Loaded via the `u-widgets/math` entry point. Requires `katex` as a peer dependency.\n */\n@customElement('uw-math')\nexport class UwMath extends LitElement {\n static styles = [themeStyles, css`\n :host {\n display: block;\n font-family: system-ui, -apple-system, sans-serif;\n container: uw-math / inline-size;\n }\n\n .math-block {\n color: var(--u-widget-text, #1a1a2e);\n overflow-x: auto;\n font-size: 1rem;\n line-height: 1.6;\n }\n\n .math-block[data-display=\"true\"] {\n text-align: center;\n padding: 8px 0;\n font-size: 1.2rem;\n }\n\n .math-error {\n padding: 8px 12px;\n border-radius: 4px;\n border: 1px solid var(--u-widget-negative, #dc2626);\n background: color-mix(in srgb, var(--u-widget-negative, #dc2626) 8%, var(--u-widget-bg, #fff));\n font-size: 0.8125rem;\n color: var(--u-widget-negative, #dc2626);\n }\n\n .math-error code {\n display: block;\n margin-top: 4px;\n font-size: 0.75rem;\n color: var(--u-widget-text-secondary, #64748b);\n word-break: break-all;\n }\n `];\n\n @property({ type: Object })\n spec: UWidgetSpec | null = null;\n\n @property({ type: String, reflect: true })\n theme: string | null = null;\n\n render() {\n if (!this.spec) return nothing;\n\n const data = this.spec.data as Record<string, unknown> | undefined;\n if (!data) return nothing;\n\n const expression = String(data.expression ?? '').trim();\n if (!expression) return nothing;\n\n const options = (this.spec.options ?? {}) as Record<string, unknown>;\n const displayMode = Boolean(options.displayMode ?? false);\n\n try {\n // SAFETY: output must be 'mathml' — pure MathML has no script/event vectors,\n // making .innerHTML safe. Switching to 'html' or 'htmlAndMathml' would require\n // KaTeX CSS and introduce potential XSS via custom macros.\n const rendered = katex.renderToString(expression, {\n displayMode,\n throwOnError: true,\n output: 'mathml',\n });\n\n return html`\n <div\n class=\"math-block\"\n part=\"math\"\n data-display=${String(displayMode)}\n .innerHTML=${rendered}\n ></div>\n `;\n } catch (e) {\n const msg = e instanceof Error ? e.message : 'Invalid expression';\n return html`\n <div class=\"math-error\" part=\"math-error\">\n ${msg}\n <code>${expression}</code>\n </div>\n `;\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uw-math': UwMath;\n }\n}\n"],"names":["UwMath","LitElement","nothing","data","expression","displayMode","rendered","katex","html","msg","themeStyles","css","__decorateClass","property","customElement"],"mappings":";;;;;;;;;AAaO,IAAMA,IAAN,cAAqBC,EAAW;AAAA,EAAhC,cAAA;AAAA,UAAA,GAAA,SAAA,GAwCL,KAAA,OAA2B,MAG3B,KAAA,QAAuB;AAAA,EAAA;AAAA,EAEvB,SAAS;AACP,QAAI,CAAC,KAAK,KAAM,QAAOC;AAEvB,UAAMC,IAAO,KAAK,KAAK;AACvB,QAAI,CAACA,EAAM,QAAOD;AAElB,UAAME,IAAa,OAAOD,EAAK,cAAc,EAAE,EAAE,KAAA;AACjD,QAAI,CAACC,EAAY,QAAOF;AAGxB,UAAMG,IAAc,IADH,KAAK,KAAK,WAAW,CAAA,GACF,eAAe;AAEnD,QAAI;AAIF,YAAMC,IAAWC,EAAM,eAAeH,GAAY;AAAA,QAChD,aAAAC;AAAA,QACA,cAAc;AAAA,QACd,QAAQ;AAAA,MAAA,CACT;AAED,aAAOG;AAAA;AAAA;AAAA;AAAA,yBAIY,OAAOH,CAAW,CAAC;AAAA,uBACrBC,CAAQ;AAAA;AAAA;AAAA,IAG3B,SAAS,GAAG;AACV,YAAMG,IAAM,aAAa,QAAQ,EAAE,UAAU;AAC7C,aAAOD;AAAA;AAAA,YAEDC,CAAG;AAAA,kBACGL,CAAU;AAAA;AAAA;AAAA,IAGxB;AAAA,EACF;AACF;AArFaJ,EACJ,SAAS,CAACU,GAAaC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAoC7B;AAGDC,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAvCfb,EAwCX,WAAA,QAAA,CAAA;AAGAY,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GA1C9Bb,EA2CX,WAAA,SAAA,CAAA;AA3CWA,IAANY,EAAA;AAAA,EADNE,EAAc,SAAS;AAAA,GACXd,CAAA;"}
|
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
|