@maxhealth.tech/prefab 0.2.40 → 0.3.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.
- package/CHANGELOG.md +43 -0
- package/README.md +3 -3
- package/dist/app.d.ts +24 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +46 -9
- package/dist/app.js.map +1 -1
- package/dist/components/charts/index.d.ts +56 -4
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/index.js +33 -7
- package/dist/components/charts/index.js.map +1 -1
- package/dist/core/theme-css.d.ts +32 -0
- package/dist/core/theme-css.d.ts.map +1 -0
- package/dist/core/theme-css.js +55 -0
- package/dist/core/theme-css.js.map +1 -0
- package/dist/core/validate.d.ts.map +1 -1
- package/dist/core/validate.js +24 -1
- package/dist/core/validate.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/display.d.ts +6 -2
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +8 -2
- package/dist/mcp/display.js.map +1 -1
- package/dist/renderer/components/chart-helpers.d.ts +63 -0
- package/dist/renderer/components/chart-helpers.d.ts.map +1 -0
- package/dist/renderer/components/chart-helpers.js +202 -0
- package/dist/renderer/components/chart-helpers.js.map +1 -0
- package/dist/renderer/components/chart-tooltip.d.ts +1 -1
- package/dist/renderer/components/chart-tooltip.d.ts.map +1 -1
- package/dist/renderer/components/charts.d.ts +4 -20
- package/dist/renderer/components/charts.d.ts.map +1 -1
- package/dist/renderer/components/charts.js +246 -195
- package/dist/renderer/components/charts.js.map +1 -1
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +65 -24
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/theme.d.ts +15 -0
- package/dist/renderer/theme.d.ts.map +1 -1
- package/dist/renderer/theme.js +26 -18
- package/dist/renderer/theme.js.map +1 -1
- package/dist/renderer.auto.min.js +14 -12
- package/dist/renderer.min.js +14 -12
- package/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.3.1] — 2026-06-27
|
|
6
|
+
|
|
7
|
+
Documentation and tooling release. No runtime or API changes: `src/` is unchanged aside from the version bump, so the published bundle is functionally identical to 0.3.0.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Corrected the wire-protocol version label across the user-facing docs. The README badge and tagline, the skill header, the homepage feature text, and a version-pin example still advertised `0.2`, but the library has shipped protocol `0.3` since 0.3.0 (the renderer still accepts legacy `0.2` payloads).
|
|
12
|
+
|
|
13
|
+
### Docs
|
|
14
|
+
|
|
15
|
+
- Deduplicated the Guide and Reference sections. Each reference topic now lives in one place, and the Guide pages are concise conceptual pages that link into the reference, removing a large amount of duplicated content.
|
|
16
|
+
- Single-sourced the example UIs. The demo and playground now load one canonical set of `$prefab` examples from `docs/public/examples/` at runtime instead of embedding their own copies, and the skill bundle's example assets are generated from that same set.
|
|
17
|
+
- The programmatic API reference (actions, rx, mcp, auto, renderer) is now generated from the source TSDoc with TypeDoc, so it stays in sync with the code. The component catalog, wire format, and MCP Apps pages remain hand-written.
|
|
18
|
+
|
|
19
|
+
## [0.3.0] — 2026-06-16
|
|
20
|
+
|
|
21
|
+
### Wire Format (Breaking) — protocol `0.3`
|
|
22
|
+
|
|
23
|
+
Catches up to upstream PrefectHQ/prefab v0.20.x ("Wire Transfer", PR #431). The `$prefab.version` envelope is now **`0.3`**. The renderer still accepts `0.2` payloads, so existing stored wire data keeps rendering.
|
|
24
|
+
|
|
25
|
+
- **New top-level `css` field** — an array of inline CSS blocks, injected as `<style>` tags. The **theme is now compiled into this array** (`:root` for light, `.dark, [data-theme="dark"]` for dark) instead of shipping a structured `theme` object; `PrefabApp.toJSON()` no longer emits a `theme` key. New `compileThemeCss()` / `ThemeVars` exports expose the compiler.
|
|
26
|
+
- **`stylesheets` redefined as external URLs** — rendered as `<link rel="stylesheet" href="…">`. The renderer keeps a heuristic that still injects inline CSS found in `stylesheets` as `<style>` for backward compatibility with `0.2` payloads.
|
|
27
|
+
- **New top-level `mode` field** (`'light' | 'dark'`) — forces a color scheme. The renderer applies it via both the `data-theme` attribute and the `dark`/`light` class (so upstream-compiled `.dark {}` CSS resolves), and `toHTML()` stamps it on `<html>`.
|
|
28
|
+
- **`PrefabApp` / `DisplayOptions`** gain `css` and `mode` options; `display()` merges `css` (concatenated) and `mode` (override) like the other options.
|
|
29
|
+
- `toHTML()` now emits `css`/`stylesheets`/`mode` into `<head>` and strips them from the embedded JSON to avoid double-injection (mirrors upstream `html()`).
|
|
30
|
+
|
|
31
|
+
### Charts
|
|
32
|
+
|
|
33
|
+
- **`valueFormat` parity (PR #454)** — added the canonical `valueFormat` prop to cartesian/pie/radial charts (value-axis ticks + tooltip values), matching upstream's field name so chart formats are wire-compatible in both directions. `yAxisFormat` / `yAxisRightFormat` remain TS-only overrides for dual-axis charts. The renderer reads `valueFormat` as the base format and treats `"auto"` as "no explicit format".
|
|
34
|
+
- **Pie/Radial/Scatter data-binding parity** — `PieChart` and `RadialChart` now use upstream's `dataKey` (value) + `nameKey` (label) model, and `ScatterChart` gains `xAxis`/`yAxis`/`zAxis` (z = bubble size). The legacy `series`/`xAxis` inputs are still accepted and mapped onto the canonical fields (**dual-accept**, non-breaking), and the Pie renderer reads both shapes — so these charts now round-trip with the Python renderer. New exports: `CategoricalChartProps`, `PieChartProps`, `ScatterChartProps`.
|
|
35
|
+
- **Native Radial, Scatter & Radar renderers** — replaced the "not yet supported" placeholders with real SVG renderers, so **every chart type now draws natively** (the fallback is gone):
|
|
36
|
+
- `RadialChart` — concentric value arcs (muted track + coloured value), configurable `innerRadius`/`startAngle`/`endAngle`.
|
|
37
|
+
- `ScatterChart` — points over min/max axes with optional grid, tooltips, and **bubble sizing** from `zAxis`.
|
|
38
|
+
- `RadarChart` — one polygon per series over angular axes, with `axisKey` spoke labels, `filled`, and `showDots`; legacy `xAxis` maps to `axisKey`.
|
|
39
|
+
- All honour `valueFormat`.
|
|
40
|
+
- **Refactor** — the chart renderers' shared toolkit (colours, axes, SVG primitives, value formatting, legend) was extracted into `chart-helpers.ts` to keep each renderer file under the 700-LOC limit.
|
|
41
|
+
|
|
42
|
+
### Internal
|
|
43
|
+
|
|
44
|
+
- **DRY theme compilation** — `applyTheme()` (the legacy `theme`-object path) now routes its dark block through the same `compileThemeCss()` the wire path uses, so both paths emit byte-identical dark CSS. The CSS sanitizers are shared too.
|
|
45
|
+
|
|
46
|
+
> **Fixtures verified against upstream.** Golden fixtures were regenerated from upstream `prefab-ui` **0.20.2**: 9/10 are byte-identical to the previous `0.2` fixtures apart from the version bump (confirming parity, and that upstream emits `0.3`). The 10th (chart) now carries upstream's `valueFormat`, which the builder also emits.
|
|
47
|
+
|
|
5
48
|
## [0.2.40] — 2026-05-15
|
|
6
49
|
|
|
7
50
|
### New Features
|
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
[](https://github.com/Max-Health-Inc/prefab/actions/workflows/ci.yml)
|
|
4
4
|
[-brightgreen)](https://github.com/Max-Health-Inc/prefab/actions/workflows/ci.yml)
|
|
5
5
|
[](https://www.npmjs.com/package/@maxhealth.tech/prefab)
|
|
6
|
-
[](https://maxhealth.tech/prefab/reference/wire-format.html)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
|
-
TypeScript declarative UI component library for MCP apps. Wire-compatible with PrefectHQ's Python [prefab-ui](https://github.com/PrefectHQ/prefab) —
|
|
10
|
+
TypeScript declarative UI component library for MCP apps. Wire-compatible with PrefectHQ's Python [prefab-ui](https://github.com/PrefectHQ/prefab) — **`$prefab` v0.3 wire protocol** (still renders legacy `0.2` payloads).
|
|
11
11
|
|
|
12
12
|
**[Live Demo](https://maxhealth.tech/prefab/demo/)** · **[Playground](https://maxhealth.tech/prefab/playground/)**
|
|
13
13
|
|
|
@@ -441,7 +441,7 @@ All UIs serialize to the `$prefab` wire format (JSON):
|
|
|
441
441
|
|
|
442
442
|
```json
|
|
443
443
|
{
|
|
444
|
-
"$prefab": { "version": "0.
|
|
444
|
+
"$prefab": { "version": "0.3" },
|
|
445
445
|
"view": {
|
|
446
446
|
"type": "Column",
|
|
447
447
|
"children": [
|
package/dist/app.d.ts
CHANGED
|
@@ -9,11 +9,22 @@ import type { ComponentJSON } from './core/component.js';
|
|
|
9
9
|
import type { Action, ActionJSON } from './actions/types.js';
|
|
10
10
|
import type { PipeFn } from './rx/pipes.js';
|
|
11
11
|
/** Package version — injected by build script, updated at release time. */
|
|
12
|
-
export declare const VERSION = "0.
|
|
12
|
+
export declare const VERSION = "0.3.1";
|
|
13
|
+
/**
|
|
14
|
+
* Wire protocol version emitted in `$prefab.version`.
|
|
15
|
+
*
|
|
16
|
+
* `0.3` matches upstream PrefectHQ/prefab: the theme is folded into the
|
|
17
|
+
* `css` array, `stylesheets` carries external URLs, and `mode` forces a
|
|
18
|
+
* color scheme (PR #431, "Wire Transfer"). The renderer still accepts `0.2`
|
|
19
|
+
* payloads for backward compatibility.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PROTOCOL_VERSION = "0.3";
|
|
13
22
|
export interface Theme {
|
|
14
23
|
light?: Record<string, string>;
|
|
15
24
|
dark?: Record<string, string>;
|
|
16
25
|
}
|
|
26
|
+
/** Forced color scheme for the renderer, independent of OS preference. */
|
|
27
|
+
export type ColorMode = 'light' | 'dark';
|
|
17
28
|
/** Declarative size hints for the host container (iframe, panel, etc.). */
|
|
18
29
|
export interface LayoutHints {
|
|
19
30
|
/** Preferred height in pixels — host should allocate this before first paint. */
|
|
@@ -29,11 +40,15 @@ export interface PrefabWireFormat {
|
|
|
29
40
|
};
|
|
30
41
|
view: ComponentJSON;
|
|
31
42
|
state?: Record<string, unknown>;
|
|
32
|
-
theme?: Theme;
|
|
33
43
|
defs?: Record<string, ComponentJSON>;
|
|
34
44
|
keyBindings?: Record<string, ActionJSON | ActionJSON[]>;
|
|
35
45
|
onMount?: ActionJSON | ActionJSON[];
|
|
46
|
+
/** Inline CSS blocks injected as `<style>` (protocol 0.3). Includes the compiled theme. */
|
|
47
|
+
css?: string[];
|
|
48
|
+
/** External CSS URLs loaded as `<link rel="stylesheet">` (protocol 0.3). */
|
|
36
49
|
stylesheets?: string[];
|
|
50
|
+
/** Forced color scheme, independent of OS preference (protocol 0.3). */
|
|
51
|
+
mode?: ColorMode;
|
|
37
52
|
/** Custom pipe source code — hydrated by the renderer on mount. */
|
|
38
53
|
pipes?: Record<string, string>;
|
|
39
54
|
/** Size hints for the host container. */
|
|
@@ -45,8 +60,13 @@ export interface PrefabAppOptions {
|
|
|
45
60
|
state?: Record<string, unknown>;
|
|
46
61
|
theme?: Theme;
|
|
47
62
|
defs?: Record<string, Component>;
|
|
63
|
+
/** Inline CSS blocks injected as `<style>`. Merged after the compiled theme. */
|
|
64
|
+
css?: string[];
|
|
65
|
+
/** External CSS URLs loaded as `<link rel="stylesheet">`. */
|
|
48
66
|
stylesheets?: string[];
|
|
49
67
|
scripts?: string[];
|
|
68
|
+
/** Forced color scheme, independent of OS preference. */
|
|
69
|
+
mode?: ColorMode;
|
|
50
70
|
onMount?: Action | Action[];
|
|
51
71
|
keyBindings?: Record<string, Action | Action[]>;
|
|
52
72
|
cssClass?: string;
|
|
@@ -61,8 +81,10 @@ export declare class PrefabApp {
|
|
|
61
81
|
readonly state?: Record<string, unknown>;
|
|
62
82
|
readonly theme?: Theme;
|
|
63
83
|
readonly defs?: Record<string, Component>;
|
|
84
|
+
readonly css?: string[];
|
|
64
85
|
readonly stylesheets?: string[];
|
|
65
86
|
readonly scripts?: string[];
|
|
87
|
+
readonly mode?: ColorMode;
|
|
66
88
|
readonly onMount?: Action | Action[];
|
|
67
89
|
readonly keyBindings?: Record<string, Action | Action[]>;
|
|
68
90
|
readonly cssClass?: string;
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,2EAA2E;AAC3E,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AAIrC,MAAM,WAAW,KAAK;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B;AAED,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;AAIxC,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uCAAuC;IACvC,SAAS,CAAC,EAAE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GG;IACH,MAAM,IAAI,gBAAgB;IA4D1B;;;;;;;;;;OAUG;IACH,WAAW,IAAI;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;IAQxG;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;CA6D1F"}
|
package/dist/app.js
CHANGED
|
@@ -6,16 +6,28 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {} from './core/component.js';
|
|
8
8
|
import { drainAutoState } from './rx/state-collector.js';
|
|
9
|
+
import { compileThemeCss } from './core/theme-css.js';
|
|
9
10
|
/** Package version — injected by build script, updated at release time. */
|
|
10
|
-
export const VERSION = '0.
|
|
11
|
+
export const VERSION = '0.3.1';
|
|
12
|
+
/**
|
|
13
|
+
* Wire protocol version emitted in `$prefab.version`.
|
|
14
|
+
*
|
|
15
|
+
* `0.3` matches upstream PrefectHQ/prefab: the theme is folded into the
|
|
16
|
+
* `css` array, `stylesheets` carries external URLs, and `mode` forces a
|
|
17
|
+
* color scheme (PR #431, "Wire Transfer"). The renderer still accepts `0.2`
|
|
18
|
+
* payloads for backward compatibility.
|
|
19
|
+
*/
|
|
20
|
+
export const PROTOCOL_VERSION = '0.3';
|
|
11
21
|
export class PrefabApp {
|
|
12
22
|
title;
|
|
13
23
|
view;
|
|
14
24
|
state;
|
|
15
25
|
theme;
|
|
16
26
|
defs;
|
|
27
|
+
css;
|
|
17
28
|
stylesheets;
|
|
18
29
|
scripts;
|
|
30
|
+
mode;
|
|
19
31
|
onMount;
|
|
20
32
|
keyBindings;
|
|
21
33
|
cssClass;
|
|
@@ -34,8 +46,10 @@ export class PrefabApp {
|
|
|
34
46
|
this.state = merged;
|
|
35
47
|
this.theme = opts.theme;
|
|
36
48
|
this.defs = opts.defs;
|
|
49
|
+
this.css = opts.css;
|
|
37
50
|
this.stylesheets = opts.stylesheets;
|
|
38
51
|
this.scripts = opts.scripts;
|
|
52
|
+
this.mode = opts.mode;
|
|
39
53
|
this.onMount = opts.onMount;
|
|
40
54
|
this.keyBindings = opts.keyBindings;
|
|
41
55
|
this.cssClass = opts.cssClass;
|
|
@@ -55,15 +69,22 @@ export class PrefabApp {
|
|
|
55
69
|
children: [this.view.toJSON()],
|
|
56
70
|
};
|
|
57
71
|
const wire = {
|
|
58
|
-
$prefab: { version:
|
|
72
|
+
$prefab: { version: PROTOCOL_VERSION },
|
|
59
73
|
view: rootView,
|
|
60
74
|
};
|
|
61
75
|
if (this.state)
|
|
62
76
|
wire.state = this.state;
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
// Theme is compiled into the `css` array (protocol 0.3) — the wire no
|
|
78
|
+
// longer carries a structured `theme` object. Compiled theme CSS comes
|
|
79
|
+
// first so user-supplied `css` can override it.
|
|
80
|
+
const cssParts = [compileThemeCss(this.theme), ...(this.css ?? [])]
|
|
81
|
+
.filter(s => s.trim().length > 0);
|
|
82
|
+
if (cssParts.length > 0)
|
|
83
|
+
wire.css = cssParts;
|
|
65
84
|
if (this.stylesheets != null && this.stylesheets.length > 0)
|
|
66
85
|
wire.stylesheets = this.stylesheets;
|
|
86
|
+
if (this.mode != null)
|
|
87
|
+
wire.mode = this.mode;
|
|
67
88
|
if (this.defs) {
|
|
68
89
|
wire.defs = {};
|
|
69
90
|
for (const [name, comp] of Object.entries(this.defs)) {
|
|
@@ -122,27 +143,43 @@ export class PrefabApp {
|
|
|
122
143
|
toHTML(opts) {
|
|
123
144
|
const cdnVersion = opts?.cdnVersion ?? VERSION;
|
|
124
145
|
const includeStyles = opts?.includeStyles !== false;
|
|
146
|
+
// css / stylesheets / mode are emitted into <head> below, so strip them
|
|
147
|
+
// from the embedded wire data to avoid the renderer injecting them twice.
|
|
148
|
+
const wire = this.toJSON();
|
|
149
|
+
const { css: cssBlocks, stylesheets, mode, ...embedded } = wire;
|
|
150
|
+
void cssBlocks;
|
|
151
|
+
void stylesheets;
|
|
152
|
+
void mode;
|
|
125
153
|
const jsonStr = opts?.pretty
|
|
126
|
-
? JSON.stringify(
|
|
127
|
-
: JSON.stringify(
|
|
154
|
+
? JSON.stringify(embedded, null, 2)
|
|
155
|
+
: JSON.stringify(embedded);
|
|
128
156
|
// Escape </script> in JSON to prevent breaking out of the inline script tag
|
|
129
157
|
const safeJsonStr = jsonStr.replace(/<\//g, '<\\/');
|
|
130
158
|
const baseStyleTag = includeStyles
|
|
131
159
|
? `\n <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@maxhealth.tech/prefab@${cdnVersion}/dist/prefab.css">`
|
|
132
160
|
: '';
|
|
161
|
+
// Inline CSS blocks (compiled theme + user css) as <style> tags.
|
|
162
|
+
const cssTags = (wire.css ?? [])
|
|
163
|
+
.map(c => `<style>${c.replace(/<\/(style)/gi, '<\\/$1')}</style>`)
|
|
164
|
+
.join('\n ');
|
|
165
|
+
// External stylesheet URLs as <link> tags.
|
|
133
166
|
const stylesheetTags = (this.stylesheets ?? [])
|
|
134
167
|
.map(s => s.startsWith('<') ? s : `<link rel="stylesheet" href="${escapeHtml(s)}">`)
|
|
135
168
|
.join('\n ');
|
|
136
169
|
const scriptTags = (this.scripts ?? [])
|
|
137
170
|
.map(s => `<script src="${escapeHtml(s)}"></script>`)
|
|
138
171
|
.join('\n ');
|
|
172
|
+
// Force the color scheme on the document root using both conventions.
|
|
173
|
+
const modeAttr = this.mode ? ` data-theme="${this.mode}" class="${this.mode}"` : '';
|
|
174
|
+
const headExtras = [baseStyleTag, cssTags && `\n ${cssTags}`, stylesheetTags && `\n ${stylesheetTags}`]
|
|
175
|
+
.filter(Boolean)
|
|
176
|
+
.join('');
|
|
139
177
|
return `<!DOCTYPE html>
|
|
140
|
-
<html lang="en">
|
|
178
|
+
<html lang="en"${modeAttr}>
|
|
141
179
|
<head>
|
|
142
180
|
<meta charset="utf-8">
|
|
143
181
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
144
|
-
<title>${escapeHtml(this.title)}</title>${
|
|
145
|
-
${stylesheetTags}
|
|
182
|
+
<title>${escapeHtml(this.title)}</title>${headExtras}
|
|
146
183
|
<script src="https://cdn.jsdelivr.net/npm/@maxhealth.tech/prefab@${cdnVersion}/dist/renderer.min.js"></script>
|
|
147
184
|
${scriptTags}
|
|
148
185
|
</head>
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAA;AAqErC,MAAM,OAAO,SAAS;IACX,KAAK,CAAQ;IACb,IAAI,CAAW;IACf,KAAK,CAA0B;IAC/B,KAAK,CAAQ;IACb,IAAI,CAA4B;IAChC,GAAG,CAAW;IACd,WAAW,CAAW;IACtB,OAAO,CAAW;IAClB,IAAI,CAAY;IAChB,OAAO,CAAoB;IAC3B,WAAW,CAAoC;IAC/C,QAAQ,CAAS;IACjB,KAAK,CAAyB;IAC9B,MAAM,CAA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,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -27,12 +27,45 @@ export interface BaseChartProps extends ComponentProps {
|
|
|
27
27
|
showTooltip?: boolean;
|
|
28
28
|
showGrid?: boolean;
|
|
29
29
|
showYAxis?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Canonical pipe format for value-axis ticks and tooltip values
|
|
32
|
+
* (e.g. "compact", "currency", "percent:1"). Matches upstream prefab's
|
|
33
|
+
* `valueFormat` (PR #454). `"auto"` (the default) means no explicit format.
|
|
34
|
+
*/
|
|
35
|
+
valueFormat?: string;
|
|
36
|
+
/** Left-axis format override for dual-axis charts (TS extension). Overrides `valueFormat`. */
|
|
30
37
|
yAxisFormat?: string;
|
|
31
38
|
/** Show a secondary Y-axis on the right for series with yAxisId:'right'. */
|
|
32
39
|
showYAxisRight?: boolean;
|
|
40
|
+
/** Right-axis format for dual-axis charts (TS extension). */
|
|
33
41
|
yAxisRightFormat?: string;
|
|
34
42
|
animate?: boolean;
|
|
35
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Props for categorical charts that plot one numeric value per data row
|
|
46
|
+
* (Pie, Radial). Matches upstream prefab's `dataKey` (value) + `nameKey`
|
|
47
|
+
* (label) model. The legacy `series`/`xAxis` inputs are still accepted and
|
|
48
|
+
* mapped onto `dataKey`/`nameKey`, so existing series-based code keeps working.
|
|
49
|
+
*/
|
|
50
|
+
export interface CategoricalChartProps extends ComponentProps {
|
|
51
|
+
data: unknown[];
|
|
52
|
+
/** Numeric value field (upstream canonical). */
|
|
53
|
+
dataKey?: string;
|
|
54
|
+
/** Slice/segment label field (upstream canonical). */
|
|
55
|
+
nameKey?: string;
|
|
56
|
+
/** Legacy series-based input — `series[0].dataKey` becomes the value field. Prefer `dataKey`. */
|
|
57
|
+
series?: ChartSeries[];
|
|
58
|
+
/** Legacy label field. Prefer `nameKey`. */
|
|
59
|
+
xAxis?: string;
|
|
60
|
+
/** Legacy label key. Prefer `nameKey`. */
|
|
61
|
+
tooltipXKey?: string;
|
|
62
|
+
height?: number;
|
|
63
|
+
showLegend?: boolean;
|
|
64
|
+
showTooltip?: boolean;
|
|
65
|
+
animate?: boolean;
|
|
66
|
+
/** Value format pipe for tooltip values (e.g. "currency", "percent:1"). */
|
|
67
|
+
valueFormat?: string;
|
|
68
|
+
}
|
|
36
69
|
export interface BarChartProps extends BaseChartProps {
|
|
37
70
|
stacked?: boolean;
|
|
38
71
|
horizontal?: boolean;
|
|
@@ -41,9 +74,28 @@ export interface BarChartProps extends BaseChartProps {
|
|
|
41
74
|
export declare function BarChart(props: BarChartProps): Component;
|
|
42
75
|
export declare function LineChart(props: BaseChartProps): Component;
|
|
43
76
|
export declare function AreaChart(props: BaseChartProps): Component;
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
export interface PieChartProps extends CategoricalChartProps {
|
|
78
|
+
innerRadius?: number;
|
|
79
|
+
showLabel?: boolean;
|
|
80
|
+
paddingAngle?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare function PieChart(props: PieChartProps): Component;
|
|
83
|
+
export interface RadarChartProps extends BaseChartProps {
|
|
84
|
+
/** Data key for angular axis (spoke) labels — upstream `axisKey`; falls back to `xAxis`. */
|
|
85
|
+
axisKey?: string;
|
|
86
|
+
/** Fill the radar polygons (default true; set false for outline only). */
|
|
87
|
+
filled?: boolean;
|
|
88
|
+
/** Show dots at polygon vertices. */
|
|
89
|
+
showDots?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export declare function RadarChart(props: RadarChartProps): Component;
|
|
92
|
+
export interface ScatterChartProps extends BaseChartProps {
|
|
93
|
+
/** Data key for y-axis values (upstream). */
|
|
94
|
+
yAxis?: string;
|
|
95
|
+
/** Data key for bubble size (upstream, optional). */
|
|
96
|
+
zAxis?: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function ScatterChart(props: ScatterChartProps): Component;
|
|
47
99
|
export interface SparklineProps extends ComponentProps {
|
|
48
100
|
data: number[];
|
|
49
101
|
variant?: string;
|
|
@@ -52,7 +104,7 @@ export interface SparklineProps extends ComponentProps {
|
|
|
52
104
|
mode?: 'line' | 'bar';
|
|
53
105
|
}
|
|
54
106
|
export declare function Sparkline(props: SparklineProps): Component;
|
|
55
|
-
export interface RadialChartProps extends
|
|
107
|
+
export interface RadialChartProps extends CategoricalChartProps {
|
|
56
108
|
innerRadius?: number;
|
|
57
109
|
startAngle?: number;
|
|
58
110
|
endAngle?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/charts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAI7D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC1B,4GAA4G;IAC5G,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAID,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0GAA0G;IAC1G,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,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AA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAW1D"}
|
|
@@ -15,6 +15,7 @@ function chartGetProps(props, extra) {
|
|
|
15
15
|
...(props.showTooltip !== undefined && { showTooltip: props.showTooltip }),
|
|
16
16
|
...(props.showGrid !== undefined && { showGrid: props.showGrid }),
|
|
17
17
|
...(props.showYAxis !== undefined && { showYAxis: props.showYAxis }),
|
|
18
|
+
...(props.valueFormat && { valueFormat: props.valueFormat }),
|
|
18
19
|
...(props.yAxisFormat && { yAxisFormat: props.yAxisFormat }),
|
|
19
20
|
...(props.showYAxisRight !== undefined && { showYAxisRight: props.showYAxisRight }),
|
|
20
21
|
...(props.yAxisRightFormat && { yAxisRightFormat: props.yAxisRightFormat }),
|
|
@@ -22,6 +23,22 @@ function chartGetProps(props, extra) {
|
|
|
22
23
|
...extra,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
function categoricalGetProps(props, extra) {
|
|
27
|
+
// Resolve the upstream canonical fields from either the new or legacy inputs.
|
|
28
|
+
const dataKey = props.dataKey ?? props.series?.[0]?.dataKey;
|
|
29
|
+
const nameKey = props.nameKey ?? props.tooltipXKey ?? props.xAxis;
|
|
30
|
+
return {
|
|
31
|
+
data: props.data,
|
|
32
|
+
...(dataKey && { dataKey }),
|
|
33
|
+
...(nameKey && { nameKey }),
|
|
34
|
+
...(props.height !== undefined && { height: props.height }),
|
|
35
|
+
...(props.showLegend !== undefined && { showLegend: props.showLegend }),
|
|
36
|
+
...(props.showTooltip !== undefined && { showTooltip: props.showTooltip }),
|
|
37
|
+
...(props.animate !== undefined && { animate: props.animate }),
|
|
38
|
+
...(props.valueFormat && { valueFormat: props.valueFormat }),
|
|
39
|
+
...extra,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
25
42
|
export function BarChart(props) {
|
|
26
43
|
const c = new Component('BarChart', props);
|
|
27
44
|
c.getProps = () => chartGetProps(props, {
|
|
@@ -43,22 +60,31 @@ export function AreaChart(props) {
|
|
|
43
60
|
c.getProps = () => chartGetProps(props);
|
|
44
61
|
return c;
|
|
45
62
|
}
|
|
46
|
-
// ── PieChart ─────────────────────────────────────────────────────────────────
|
|
47
63
|
export function PieChart(props) {
|
|
48
64
|
const c = new Component('PieChart', props);
|
|
49
|
-
c.getProps = () =>
|
|
65
|
+
c.getProps = () => categoricalGetProps(props, {
|
|
66
|
+
...(props.innerRadius !== undefined && { innerRadius: props.innerRadius }),
|
|
67
|
+
...(props.showLabel !== undefined && { showLabel: props.showLabel }),
|
|
68
|
+
...(props.paddingAngle !== undefined && { paddingAngle: props.paddingAngle }),
|
|
69
|
+
});
|
|
50
70
|
return c;
|
|
51
71
|
}
|
|
52
|
-
// ── RadarChart ───────────────────────────────────────────────────────────────
|
|
53
72
|
export function RadarChart(props) {
|
|
54
73
|
const c = new Component('RadarChart', props);
|
|
55
|
-
|
|
74
|
+
const axisKey = props.axisKey ?? props.xAxis;
|
|
75
|
+
c.getProps = () => chartGetProps(props, {
|
|
76
|
+
...(axisKey && { axisKey }),
|
|
77
|
+
...(props.filled !== undefined && { filled: props.filled }),
|
|
78
|
+
...(props.showDots !== undefined && { showDots: props.showDots }),
|
|
79
|
+
});
|
|
56
80
|
return c;
|
|
57
81
|
}
|
|
58
|
-
// ── ScatterChart ─────────────────────────────────────────────────────────────
|
|
59
82
|
export function ScatterChart(props) {
|
|
60
83
|
const c = new Component('ScatterChart', props);
|
|
61
|
-
c.getProps = () => chartGetProps(props
|
|
84
|
+
c.getProps = () => chartGetProps(props, {
|
|
85
|
+
...(props.yAxis && { yAxis: props.yAxis }),
|
|
86
|
+
...(props.zAxis && { zAxis: props.zAxis }),
|
|
87
|
+
});
|
|
62
88
|
return c;
|
|
63
89
|
}
|
|
64
90
|
export function Sparkline(props) {
|
|
@@ -74,7 +100,7 @@ export function Sparkline(props) {
|
|
|
74
100
|
}
|
|
75
101
|
export function RadialChart(props) {
|
|
76
102
|
const c = new Component('RadialChart', props);
|
|
77
|
-
c.getProps = () =>
|
|
103
|
+
c.getProps = () => categoricalGetProps(props, {
|
|
78
104
|
...(props.innerRadius !== undefined && { innerRadius: props.innerRadius }),
|
|
79
105
|
...(props.startAngle !== undefined && { startAngle: props.startAngle }),
|
|
80
106
|
...(props.endAngle !== undefined && { endAngle: props.endAngle }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/charts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/charts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AA+CnD,SAAS,aAAa,CAAC,KAAqB,EAAE,KAA+B;IAC3E,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1C,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5D,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5D,GAAG,CAAC,KAAK,CAAC,cAAc,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC;QACrE,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,C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S,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;QACpE,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;KACrE,CAAC,CAAA;IACF,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme → CSS compilation.
|
|
3
|
+
*
|
|
4
|
+
* Shared between the serializer ([app.ts]) and the renderer ([renderer/theme.ts]).
|
|
5
|
+
* Protocol 0.3 (upstream PrefectHQ/prefab PR #431) folds the theme into the
|
|
6
|
+
* wire `css` array instead of shipping a structured `theme` object, so the
|
|
7
|
+
* builder compiles `{ light, dark }` variable maps into a CSS string here.
|
|
8
|
+
*
|
|
9
|
+
* Selector convention: light variables target `:root`; dark variables target
|
|
10
|
+
* BOTH `.dark` (upstream's class convention) and `[data-theme="dark"]`
|
|
11
|
+
* (this port's attribute convention) so the emitted CSS renders correctly
|
|
12
|
+
* under either renderer.
|
|
13
|
+
*/
|
|
14
|
+
export interface ThemeVars {
|
|
15
|
+
light?: Record<string, string>;
|
|
16
|
+
dark?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/** Strip characters that could break out of a CSS property name. */
|
|
19
|
+
export declare function sanitizeCssIdent(key: string): string;
|
|
20
|
+
/** Strip characters/patterns that could escape CSS value context. */
|
|
21
|
+
export declare function sanitizeCssValue(value: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Compile a `{ light, dark }` theme into a single CSS string.
|
|
24
|
+
*
|
|
25
|
+
* - `light` vars target `:root`
|
|
26
|
+
* - `dark` vars target `.dark, [data-theme="dark"]` plus a
|
|
27
|
+
* `prefers-color-scheme: dark` block (unless an explicit light scope opts out)
|
|
28
|
+
*
|
|
29
|
+
* Returns an empty string when the theme has no variables.
|
|
30
|
+
*/
|
|
31
|
+
export declare function compileThemeCss(theme: ThemeVars | undefined): string;
|
|
32
|
+
//# sourceMappingURL=theme-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-css.d.ts","sourceRoot":"","sources":["../../src/core/theme-css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGtD;AASD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAqBpE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme → CSS compilation.
|
|
3
|
+
*
|
|
4
|
+
* Shared between the serializer ([app.ts]) and the renderer ([renderer/theme.ts]).
|
|
5
|
+
* Protocol 0.3 (upstream PrefectHQ/prefab PR #431) folds the theme into the
|
|
6
|
+
* wire `css` array instead of shipping a structured `theme` object, so the
|
|
7
|
+
* builder compiles `{ light, dark }` variable maps into a CSS string here.
|
|
8
|
+
*
|
|
9
|
+
* Selector convention: light variables target `:root`; dark variables target
|
|
10
|
+
* BOTH `.dark` (upstream's class convention) and `[data-theme="dark"]`
|
|
11
|
+
* (this port's attribute convention) so the emitted CSS renders correctly
|
|
12
|
+
* under either renderer.
|
|
13
|
+
*/
|
|
14
|
+
/** Strip characters that could break out of a CSS property name. */
|
|
15
|
+
export function sanitizeCssIdent(key) {
|
|
16
|
+
return key.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
17
|
+
}
|
|
18
|
+
/** Strip characters/patterns that could escape CSS value context. */
|
|
19
|
+
export function sanitizeCssValue(value) {
|
|
20
|
+
// Remove braces/angle brackets/semicolons and url()/expression() to prevent injection.
|
|
21
|
+
return value.replace(/[{}<>;]/g, '').replace(/\b(url|expression)\s*\(/gi, '');
|
|
22
|
+
}
|
|
23
|
+
/** Render a variable map as indented `--key: value;` declaration lines. */
|
|
24
|
+
function declarations(vars, indent = ' ') {
|
|
25
|
+
return Object.entries(vars)
|
|
26
|
+
.map(([key, value]) => `${indent}--${sanitizeCssIdent(key)}: ${sanitizeCssValue(value)};`)
|
|
27
|
+
.join('\n');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compile a `{ light, dark }` theme into a single CSS string.
|
|
31
|
+
*
|
|
32
|
+
* - `light` vars target `:root`
|
|
33
|
+
* - `dark` vars target `.dark, [data-theme="dark"]` plus a
|
|
34
|
+
* `prefers-color-scheme: dark` block (unless an explicit light scope opts out)
|
|
35
|
+
*
|
|
36
|
+
* Returns an empty string when the theme has no variables.
|
|
37
|
+
*/
|
|
38
|
+
export function compileThemeCss(theme) {
|
|
39
|
+
if (!theme)
|
|
40
|
+
return '';
|
|
41
|
+
const blocks = [];
|
|
42
|
+
if (theme.light && Object.keys(theme.light).length > 0) {
|
|
43
|
+
blocks.push(`:root {\n${declarations(theme.light)}\n}`);
|
|
44
|
+
}
|
|
45
|
+
if (theme.dark && Object.keys(theme.dark).length > 0) {
|
|
46
|
+
const decls = declarations(theme.dark);
|
|
47
|
+
blocks.push(`.dark, [data-theme="dark"] {\n${decls}\n}`);
|
|
48
|
+
blocks.push(`@media (prefers-color-scheme: dark) {\n` +
|
|
49
|
+
` :root:not([data-theme="light"]):not(.light) {\n` +
|
|
50
|
+
`${declarations(theme.dark, ' ')}\n` +
|
|
51
|
+
` }\n}`);
|
|
52
|
+
}
|
|
53
|
+
return blocks.join('\n');
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=theme-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|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,CAAC;QACrD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,CAAC,IAAI,CAAC,iCAAiC,KAAK,KAAK,CAAC,CAAA;QACxD,MAAM,CAAC,IAAI,CACT,yCAAyC;YACvC,mDAAmD;YACnD,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI;YACvC,QAAQ,CACX,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAIjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AA0CD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAIjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AA0CD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,gBAAgB,CA8ElB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAEzE"}
|