@aiaiai-pt/design-system 0.41.0 → 0.42.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/components/renderer/MetabaseEmbedWidget.svelte +76 -0
- package/components/renderer/MetabaseEmbedWidget.svelte.d.ts +4 -0
- package/components/renderer/StatGridWidget.svelte +17 -1
- package/components/renderer/registry.ts +4 -0
- package/components/renderer/resolve-data.ts +3 -0
- package/components/renderer/types.d.ts +1 -1
- package/components/renderer/types.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { WidgetProps } from "./types";
|
|
3
|
+
|
|
4
|
+
// `embed` widget (#517, atelier) — a Metabase analytics embed on the unified
|
|
5
|
+
// dashboard/portal `Block[]` grid. PRESENTATION-ONLY: the DS never mints or
|
|
6
|
+
// holds a Metabase URL; the HOST resolves the signed/proxy URL and passes it
|
|
7
|
+
// as `props.src` (an `/internal/metabase-embed/…` route or a signed URL), and
|
|
8
|
+
// this widget renders an `<iframe>`. Presentational kind → `resolveData`
|
|
9
|
+
// short-circuits it (no DS fetch); the widget owns its props.
|
|
10
|
+
//
|
|
11
|
+
// props.src — the iframe URL (host-resolved). Absent ⇒ placeholder.
|
|
12
|
+
// props.title — accessible iframe title / caption.
|
|
13
|
+
// props.height — CSS height (e.g. "400px"); defaults to 400px.
|
|
14
|
+
// props.width — "full" | "half" (grid-agnostic max-width hint).
|
|
15
|
+
// props.embed_type — "dashboard" | "question" (informational; caption).
|
|
16
|
+
let { props }: WidgetProps = $props();
|
|
17
|
+
|
|
18
|
+
const src = $derived(typeof props.src === "string" ? props.src : "");
|
|
19
|
+
const title = $derived(typeof props.title === "string" && props.title ? props.title : "Metabase embed");
|
|
20
|
+
const height = $derived(typeof props.height === "string" && props.height ? props.height : "400px");
|
|
21
|
+
const half = $derived(props.width === "half");
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<figure class="mb-embed" class:half data-widget="metabase-embed">
|
|
25
|
+
{#if src}
|
|
26
|
+
<iframe {src} {title} style:height loading="lazy" referrerpolicy="strict-origin-when-cross-origin"
|
|
27
|
+
></iframe>
|
|
28
|
+
{#if props.title}<figcaption>{props.title}</figcaption>{/if}
|
|
29
|
+
{:else}
|
|
30
|
+
<div class="mb-embed-empty" style:height>
|
|
31
|
+
<p>Metabase embed not configured — set the dashboard/question id.</p>
|
|
32
|
+
</div>
|
|
33
|
+
{/if}
|
|
34
|
+
</figure>
|
|
35
|
+
|
|
36
|
+
<style>
|
|
37
|
+
.mb-embed {
|
|
38
|
+
margin: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: var(--space-sm);
|
|
42
|
+
inline-size: 100%;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.mb-embed.half {
|
|
46
|
+
max-inline-size: 50%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.mb-embed iframe {
|
|
50
|
+
inline-size: 100%;
|
|
51
|
+
border: var(--elevation-border);
|
|
52
|
+
border-radius: var(--radius-md);
|
|
53
|
+
background: var(--color-surface);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.mb-embed figcaption {
|
|
57
|
+
font-size: var(--type-caption-size);
|
|
58
|
+
color: var(--color-text-muted);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mb-embed-empty {
|
|
62
|
+
display: grid;
|
|
63
|
+
place-items: center;
|
|
64
|
+
inline-size: 100%;
|
|
65
|
+
border: var(--border-width) dashed var(--color-border);
|
|
66
|
+
border-radius: var(--radius-md);
|
|
67
|
+
background: var(--color-surface-secondary);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.mb-embed-empty p {
|
|
71
|
+
margin: 0;
|
|
72
|
+
padding: var(--space-md);
|
|
73
|
+
font-size: var(--type-body-sm-size);
|
|
74
|
+
color: var(--color-text-muted);
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
label?: string;
|
|
15
15
|
value?: string;
|
|
16
16
|
variant?: string;
|
|
17
|
+
/** #517 — optional Phosphor icon NAME (kebab-case, e.g. "chart-bar"),
|
|
18
|
+
* rendered via the Phosphor web font. Lets a dashboard KPI block carry its
|
|
19
|
+
* per-card icon through the DS widget, so KPI renders via `resolveWidget`
|
|
20
|
+
* like every other block (no host-side StatCard special-case). */
|
|
21
|
+
icon?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
const view = $derived((data ?? {}) as Record<string, unknown>);
|
|
@@ -24,10 +29,21 @@
|
|
|
24
29
|
? props.stats
|
|
25
30
|
: []) as Stat[],
|
|
26
31
|
);
|
|
32
|
+
|
|
33
|
+
// Phosphor web-font class names are kebab-case (`ph ph-chart-bar`); keep only
|
|
34
|
+
// the safe charset so a bad name can't leak into `class` (defensive — attribute
|
|
35
|
+
// values are escaped, but this keeps the class well-formed).
|
|
36
|
+
const iconClass = (name: string): string => `ph ph-${name.replace(/[^a-z0-9-]/gi, "")}`;
|
|
27
37
|
</script>
|
|
28
38
|
|
|
29
39
|
<StatGrid>
|
|
30
40
|
{#each stats as stat (stat.label)}
|
|
31
|
-
<
|
|
41
|
+
{#snippet cardIcon()}<i class={iconClass(stat.icon ?? "")} aria-hidden="true"></i>{/snippet}
|
|
42
|
+
<StatCard
|
|
43
|
+
label={stat.label}
|
|
44
|
+
value={stat.value}
|
|
45
|
+
variant={stat.variant}
|
|
46
|
+
icon={stat.icon ? cardIcon : undefined}
|
|
47
|
+
/>
|
|
32
48
|
{/each}
|
|
33
49
|
</StatGrid>
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import type { Block, OntologySchema, WidgetKind, WidgetProps } from "./types";
|
|
24
24
|
|
|
25
25
|
import EChartWidget from "./EChartWidget.svelte";
|
|
26
|
+
import MetabaseEmbedWidget from "./MetabaseEmbedWidget.svelte";
|
|
26
27
|
import ResultsChartWidget from "./ResultsChartWidget.svelte";
|
|
27
28
|
import StatGridWidget from "./StatGridWidget.svelte";
|
|
28
29
|
|
|
@@ -75,6 +76,9 @@ const _entries: RegistryEntry<WidgetComponent>[] = [
|
|
|
75
76
|
// the kind-specific registry keys + wrapper components are retired.
|
|
76
77
|
// `results-chart` stays as the SSR / no-JS a11y fallback key.
|
|
77
78
|
byTypeOnKind("chart", "aggregate", EChartWidget),
|
|
79
|
+
// #517 (atelier) — Metabase embed on the unified Block[] grid. Presentation-
|
|
80
|
+
// only (renders `props.src`); one kind-generic entry, no `type` ranking.
|
|
81
|
+
byKind("metabase-embed", "embed", MetabaseEmbedWidget),
|
|
78
82
|
];
|
|
79
83
|
|
|
80
84
|
/**
|
|
@@ -35,6 +35,9 @@ export const PRESENTATIONAL_KINDS: ReadonlySet<WidgetKind> =
|
|
|
35
35
|
new Set<WidgetKind>([
|
|
36
36
|
"hero",
|
|
37
37
|
"lookup",
|
|
38
|
+
// #517 — the Metabase embed renders from a host-resolved `props.src`; it has
|
|
39
|
+
// no DS-fetched data path, so short-circuit it like the other content kinds.
|
|
40
|
+
"embed",
|
|
38
41
|
"feature-grid",
|
|
39
42
|
"cta",
|
|
40
43
|
"media-text",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* here the descriptors are SEEDED (same staged pattern #70/#72 used).
|
|
14
14
|
*/
|
|
15
15
|
/** The bounded, governed widget kinds (spec §5 catalog). */
|
|
16
|
-
export type WidgetKind = "list" | "detail" | "form" | "map" | "calendar" | "kpi" | "content" | "vote" | "status" | "forms" | "hero" | "lookup" | "feed" | "filters" | "actions" | "aggregate" | "subscriptions" | "consent" | "deliveries" | "owned-list" | "feature-grid" | "cta" | "media-text" | "steps" | "testimonial" | "faq" | "logo-strip" | "media-gallery";
|
|
16
|
+
export type WidgetKind = "list" | "detail" | "form" | "map" | "calendar" | "kpi" | "content" | "embed" | "vote" | "status" | "forms" | "hero" | "lookup" | "feed" | "filters" | "actions" | "aggregate" | "subscriptions" | "consent" | "deliveries" | "owned-list" | "feature-grid" | "cta" | "media-text" | "steps" | "testimonial" | "faq" | "logo-strip" | "media-gallery";
|
|
17
17
|
/** The feed sub-views a `feed`/`filters` binding may toggle/scope (#308). */
|
|
18
18
|
export type FeedView = "list" | "map";
|
|
19
19
|
/** Declarative pointer — "I render <kind> of <entity|action>, scoped by filter". */
|
|
@@ -22,6 +22,12 @@ export type WidgetKind =
|
|
|
22
22
|
| "calendar"
|
|
23
23
|
| "kpi"
|
|
24
24
|
| "content"
|
|
25
|
+
// #517 (atelier) — a Metabase analytics embed. Presentational: the DS
|
|
26
|
+
// `MetabaseEmbedWidget` renders an `<iframe>` from a HOST-resolved `props.src`
|
|
27
|
+
// (the signed/proxy URL), so the DS stays presentation-only and carries no
|
|
28
|
+
// metabase auth. Lets a dashboard/portal `Block[]` hold embeds uniformly
|
|
29
|
+
// (resolved via `resolveWidget`, not a host special-case).
|
|
30
|
+
| "embed"
|
|
25
31
|
| "vote"
|
|
26
32
|
| "status"
|
|
27
33
|
| "forms"
|