@sinnstack/ui 0.2.0 → 0.3.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/CHANGELOG.md +74 -0
- package/README.md +6 -4
- package/docs/blocks.md +373 -364
- package/docs/data.md +128 -128
- package/docs/finishes.md +165 -0
- package/docs/primitives.md +4 -4
- package/docs/seo.md +191 -187
- package/package.json +15 -24
- package/src/blocks/BlockRenderer.astro +13 -7
- package/src/blocks/CTABanner.astro +8 -8
- package/src/blocks/CTAPair.astro +9 -9
- package/src/blocks/CardGrid.astro +7 -7
- package/src/blocks/ConsentEmbed.astro +1 -1
- package/src/blocks/ConsentManager.astro +1 -1
- package/src/blocks/ContactCard.astro +14 -14
- package/src/blocks/ContactForm.astro +4 -4
- package/src/blocks/ErrorPage.astro +1 -1
- package/src/blocks/FAQ.astro +9 -9
- package/src/blocks/FeatureGrid.astro +7 -7
- package/src/blocks/Hero.astro +11 -11
- package/src/blocks/HeroCarousel.astro +11 -11
- package/src/blocks/HighlightCards.astro +10 -10
- package/src/blocks/LocationHours.astro +14 -14
- package/src/blocks/LogoCloud.astro +7 -7
- package/src/blocks/MaintenancePage.astro +8 -3
- package/src/blocks/MediaText.astro +12 -12
- package/src/blocks/PageHeader.astro +9 -9
- package/src/blocks/ProseSection.astro +8 -8
- package/src/blocks/Reviews.astro +11 -11
- package/src/blocks/RichText.astro +58 -57
- package/src/blocks/StatsBand.astro +117 -117
- package/src/blocks/Steps.astro +9 -9
- package/src/blocks/Testimonials.astro +13 -13
- package/src/blocks/cms/card-grid.ts +48 -80
- package/src/blocks/cms/consent.ts +1 -30
- package/src/blocks/cms/contact-card.ts +4 -46
- package/src/blocks/cms/contact-form.ts +2 -20
- package/src/blocks/cms/cta-banner.ts +2 -23
- package/src/blocks/cms/cta-pair.ts +4 -37
- package/src/blocks/cms/data-base.ts +2 -4
- package/src/blocks/cms/data.ts +19 -19
- package/src/blocks/cms/faq.ts +4 -36
- package/src/blocks/cms/feature-grid.ts +47 -80
- package/src/blocks/cms/fixtures.ts +591 -599
- package/src/blocks/cms/hero-carousel.ts +4 -48
- package/src/blocks/cms/hero.ts +2 -46
- package/src/blocks/cms/highlight-cards.ts +4 -39
- package/src/blocks/cms/images.ts +1 -2
- package/src/blocks/cms/index.ts +59 -87
- package/src/blocks/cms/location-hours.ts +3 -85
- package/src/blocks/cms/logo-cloud.ts +36 -62
- package/src/blocks/cms/media-text.ts +2 -20
- package/src/blocks/cms/page-header.ts +27 -49
- package/src/blocks/cms/pages.ts +35 -81
- package/src/blocks/cms/prose-section.ts +2 -22
- package/src/blocks/cms/reviews.ts +5 -56
- package/src/blocks/cms/schema-dsl.ts +134 -0
- package/src/blocks/cms/schema.ts +794 -0
- package/src/blocks/cms/shared.ts +63 -115
- package/src/blocks/cms/stats-band.ts +35 -61
- package/src/blocks/cms/steps.ts +4 -31
- package/src/blocks/cms/testimonials.ts +4 -38
- package/src/blocks/cms/topbar.ts +4 -41
- package/src/blocks/cms/types.ts +1 -37
- package/src/blocks/consent.ts +2 -2
- package/src/blocks/index.ts +2 -2
- package/src/blocks/internal/Actions.astro +11 -5
- package/src/blocks/internal/BlockHeader.astro +7 -7
- package/src/blocks/internal/Placeholder.astro +3 -3
- package/src/blocks/internal/fields.ts +18 -0
- package/src/blocks/internal/registry-contract.ts +67 -0
- package/src/blocks/internal/util.ts +4 -4
- package/src/blocks/lib/contact.ts +10 -4
- package/src/blocks/lib/faq.ts +1 -1
- package/src/blocks/lib/markdown.ts +350 -0
- package/src/blocks/lib/rich-text.ts +132 -143
- package/src/blocks/scripts/consent-manager.ts +1 -1
- package/src/blocks/scripts/consent-store.ts +1 -1
- package/src/blocks/scripts/hours.ts +3 -2
- package/src/blocks/types.ts +33 -23
- package/src/data/ChartContainer.astro +2 -1
- package/src/data/cms.ts +130 -190
- package/src/data/lib/chart.ts +13 -4
- package/src/data/schema.ts +65 -0
- package/src/finishes/aurora.css +75 -0
- package/src/finishes/autumn.css +87 -0
- package/src/finishes/blueprint.css +69 -0
- package/src/finishes/brutalist.css +55 -0
- package/src/finishes/clay.css +48 -0
- package/src/finishes/day-cycle.css +46 -0
- package/src/finishes/fog.css +71 -0
- package/src/finishes/glass.css +149 -0
- package/src/finishes/holographic.css +91 -0
- package/src/finishes/night.css +77 -0
- package/src/finishes/paper.css +58 -0
- package/src/finishes/polished-glass.css +159 -0
- package/src/finishes/rain.css +84 -0
- package/src/finishes/scripts/day-cycle.ts +30 -0
- package/src/finishes/scripts/holographic.ts +37 -0
- package/src/finishes/scripts/spotlight.ts +30 -0
- package/src/finishes/spotlight.css +41 -0
- package/src/finishes/spring.css +80 -0
- package/src/finishes/terminal.css +49 -0
- package/src/primitives/Divider.astro +1 -1
- package/src/primitives/FocusRing.astro +1 -1
- package/src/primitives/FormField.astro +2 -2
- package/src/primitives/Image.astro +3 -3
- package/src/primitives/Input.astro +4 -2
- package/src/primitives/MetricCard.astro +3 -1
- package/src/primitives/Picture.astro +3 -3
- package/src/primitives/Prose.astro +1 -1
- package/src/primitives/Select.astro +4 -2
- package/src/primitives/Slider.astro +1 -1
- package/src/primitives/Table.astro +1 -1
- package/src/primitives/Textarea.astro +4 -2
- package/src/primitives/Thumbnail.astro +2 -2
- package/src/primitives/index.ts +4 -4
- package/src/primitives/internal/ChoiceField.astro +4 -2
- package/src/primitives/scripts/slider.ts +1 -1
- package/src/primitives/scripts/table-sort.ts +2 -2
- package/src/seo/cms.ts +59 -80
- package/src/seo/index.ts +1 -1
- package/src/seo/integration.ts +40 -3
- package/src/seo/lib/jsonld.ts +10 -2
- package/src/seo/lib/meta.ts +2 -2
- package/src/seo/lib/redirects.ts +14 -4
- package/src/seo/lib/rss.ts +1 -1
- package/src/seo/lib/sitemap.ts +1 -1
- package/src/seo/schema.ts +43 -0
- package/src/blocks/internal/tina.ts +0 -19
- /package/src/blocks/{lib → internal}/consent.ts +0 -0
- /package/src/blocks/{lib → internal}/reviews.ts +0 -0
- /package/src/blocks/{lib → internal}/slug.ts +0 -0
- /package/src/data/{lib → internal}/scale.ts +0 -0
- /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
- /package/src/primitives/{lib → internal}/image.ts +0 -0
- /package/src/primitives/{lib → internal}/slider.ts +0 -0
- /package/src/seo/{lib → internal}/url.ts +0 -0
|
@@ -1,143 +1,132 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rich text from the CMS:
|
|
3
|
-
*
|
|
4
|
-
* Safety by construction: RichText renders only the node types listed in BLOCK_TYPES and
|
|
5
|
-
* INLINE_TYPES, as Astro elements (text is always escaped). Raw HTML nodes, MDX templates and
|
|
6
|
-
* unknown types are dropped. Links and images keep only safe URLs (http(s), mailto, tel,
|
|
7
|
-
* relative); anything else (javascript:, data:, vbscript:…) is removed.
|
|
8
|
-
*/
|
|
9
|
-
import { safeHref } from './contact';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** Image sources: http(s) or site paths only (no data:, blob:, javascript:). */
|
|
135
|
-
export function safeMediaUrl(url: unknown): string | undefined {
|
|
136
|
-
if (typeof url !== 'string') return undefined;
|
|
137
|
-
const v = url.trim();
|
|
138
|
-
if (!v) return undefined;
|
|
139
|
-
if (v.startsWith('//')) return undefined; // protocol-relative: another host
|
|
140
|
-
if (/^https?:\/\//i.test(v) || v.startsWith('/') || v.startsWith('./') || v.startsWith('../')) return v;
|
|
141
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(v)) return undefined;
|
|
142
|
-
return v;
|
|
143
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Rich text from the CMS: Markdown or a Slate-style rich-text tree, normalized for RichText.
|
|
3
|
+
*
|
|
4
|
+
* Safety by construction: RichText renders only the node types listed in BLOCK_TYPES and
|
|
5
|
+
* INLINE_TYPES, as Astro elements (text is always escaped). Raw HTML nodes, MDX templates and
|
|
6
|
+
* unknown types are dropped. Links and images keep only safe URLs (http(s), mailto, tel,
|
|
7
|
+
* relative); anything else (javascript:, data:, vbscript:…) is removed.
|
|
8
|
+
*/
|
|
9
|
+
import { safeHref } from './contact';
|
|
10
|
+
import { markdownToRichText } from './markdown';
|
|
11
|
+
|
|
12
|
+
export interface RichTextNode {
|
|
13
|
+
type: string;
|
|
14
|
+
children?: RichTextNode[];
|
|
15
|
+
/** Text leaves. */
|
|
16
|
+
text?: string;
|
|
17
|
+
bold?: boolean;
|
|
18
|
+
italic?: boolean;
|
|
19
|
+
code?: boolean;
|
|
20
|
+
strikethrough?: boolean;
|
|
21
|
+
underline?: boolean;
|
|
22
|
+
/** Links and images. */
|
|
23
|
+
url?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
alt?: string;
|
|
26
|
+
caption?: string;
|
|
27
|
+
/** Code blocks. */
|
|
28
|
+
value?: string;
|
|
29
|
+
lang?: string;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface RichTextRoot extends RichTextNode {
|
|
33
|
+
type: 'root';
|
|
34
|
+
children: RichTextNode[];
|
|
35
|
+
}
|
|
36
|
+
/** What a block accepts: Markdown (what SinnStackCMS stores), a rich-text tree, or nothing. */
|
|
37
|
+
export type RichTextValue = RichTextRoot | RichTextNode[] | string | null | undefined;
|
|
38
|
+
|
|
39
|
+
export const BLOCK_TYPES = new Set(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'lic', 'blockquote', 'code_block', 'img', 'hr', 'table', 'thead', 'tbody', 'tr', 'th', 'td']);
|
|
40
|
+
export const INLINE_TYPES = new Set(['text', 'a', 'break']);
|
|
41
|
+
|
|
42
|
+
/** Normalize any accepted value to a root node (strings are parsed as Markdown). */
|
|
43
|
+
export function toRichTextRoot(value: RichTextValue): RichTextRoot {
|
|
44
|
+
if (value == null) return { type: 'root', children: [] };
|
|
45
|
+
if (typeof value === 'string') return markdownToRichText(value);
|
|
46
|
+
if (Array.isArray(value)) return { type: 'root', children: value };
|
|
47
|
+
if (value.type === 'root' && Array.isArray(value.children)) return value as RichTextRoot;
|
|
48
|
+
return { type: 'root', children: [value] };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** True when the value would render no visible text or media. */
|
|
52
|
+
export function isRichTextEmpty(value: RichTextValue): boolean {
|
|
53
|
+
const root = toRichTextRoot(value);
|
|
54
|
+
const visible = (n: RichTextNode): boolean => {
|
|
55
|
+
if (!n || typeof n !== 'object') return false;
|
|
56
|
+
if (n.type === 'text') return Boolean(n.text?.trim());
|
|
57
|
+
if (n.type === 'img') return Boolean(safeMediaUrl(n.url));
|
|
58
|
+
if (n.type === 'code_block') return Boolean(n.value?.trim());
|
|
59
|
+
if (n.type === 'hr') return false;
|
|
60
|
+
if (!BLOCK_TYPES.has(n.type) && !INLINE_TYPES.has(n.type)) return false;
|
|
61
|
+
return (n.children ?? []).some(visible);
|
|
62
|
+
};
|
|
63
|
+
return !root.children.some(visible);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Plain text, for structured data (FAQ answers), meta descriptions and accessible names.
|
|
68
|
+
* Paragraph-level nodes are separated by a blank line and list items by a newline.
|
|
69
|
+
*/
|
|
70
|
+
export function richTextPlain(value: RichTextValue): string {
|
|
71
|
+
const root = toRichTextRoot(value);
|
|
72
|
+
const BLOCKS = new Set(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'code_block', 'table', 'ul', 'ol']);
|
|
73
|
+
const walk = (n: RichTextNode): string => {
|
|
74
|
+
if (!n || typeof n !== 'object') return '';
|
|
75
|
+
if (n.type === 'text') return n.text ?? '';
|
|
76
|
+
if (n.type === 'break') return '\n';
|
|
77
|
+
if (n.type === 'code_block') return n.value ?? '';
|
|
78
|
+
if (n.type === 'img') return '';
|
|
79
|
+
if (!BLOCK_TYPES.has(n.type) && !INLINE_TYPES.has(n.type) && n.type !== 'root') return '';
|
|
80
|
+
const kids = n.children ?? [];
|
|
81
|
+
if (n.type === 'ul' || n.type === 'ol') return kids.map(walk).filter((s) => s.trim()).join('\n');
|
|
82
|
+
if (n.type === 'tr') return kids.map(walk).join('\t');
|
|
83
|
+
if (n.type === 'table' || n.type === 'thead' || n.type === 'tbody') return kids.map(walk).join('\n');
|
|
84
|
+
if (n.type === 'root') {
|
|
85
|
+
return kids
|
|
86
|
+
.map((k) => walk(k).trim())
|
|
87
|
+
.filter(Boolean)
|
|
88
|
+
.join('\n\n');
|
|
89
|
+
}
|
|
90
|
+
const inner = kids.map(walk).join('');
|
|
91
|
+
return BLOCKS.has(n.type) ? inner.trim() : inner;
|
|
92
|
+
};
|
|
93
|
+
return walk(root).replace(/[ \t]+\n/g, '\n').trim();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Smallest heading level used in the content (h1 → 1), or undefined when there are none. */
|
|
97
|
+
export function topHeadingLevel(value: RichTextValue): number | undefined {
|
|
98
|
+
let min: number | undefined;
|
|
99
|
+
const walk = (n: RichTextNode) => {
|
|
100
|
+
const m = /^h([1-6])$/.exec(n?.type ?? '');
|
|
101
|
+
if (m) min = Math.min(min ?? 6, Number(m[1]));
|
|
102
|
+
(n?.children ?? []).forEach(walk);
|
|
103
|
+
};
|
|
104
|
+
toRichTextRoot(value).children.forEach(walk);
|
|
105
|
+
return min;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The level a content heading renders at, so the content's top heading lands on `topLevel`
|
|
110
|
+
* (the editor's h1/h2 never competes with the page title) and relative levels are kept.
|
|
111
|
+
*/
|
|
112
|
+
export function shiftedHeading(level: number, contentTop: number | undefined, topLevel: number): 2 | 3 | 4 | 5 | 6 {
|
|
113
|
+
const shift = topLevel - (contentTop ?? level);
|
|
114
|
+
return Math.min(6, Math.max(2, Math.max(topLevel, level + shift))) as 2 | 3 | 4 | 5 | 6;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Link targets: http(s), mailto, tel, sms, relative paths and fragments. */
|
|
118
|
+
export function safeLinkUrl(url: unknown): string | undefined {
|
|
119
|
+
return typeof url === 'string' ? safeHref(url) : undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Image sources: http(s) or site paths only (no data:, blob:, javascript:). */
|
|
123
|
+
export function safeMediaUrl(url: unknown): string | undefined {
|
|
124
|
+
if (typeof url !== 'string') return undefined;
|
|
125
|
+
const v = url.trim();
|
|
126
|
+
if (!v) return undefined;
|
|
127
|
+
// Protocol-relative (another host), and the characters browsers strip or read as `/` (see safeHref).
|
|
128
|
+
if (v.startsWith('//') || /[\x00-\x1f\x7f\\]/.test(v)) return undefined;
|
|
129
|
+
if (/^https?:\/\//i.test(v) || v.startsWith('/') || v.startsWith('./') || v.startsWith('../')) return v;
|
|
130
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(v)) return undefined;
|
|
131
|
+
return v;
|
|
132
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Revoking a category that already ran scripts (analytics, marketing) reloads the page, because
|
|
7
7
|
* a script that has run can't be unloaded; embeds are unloaded in place.
|
|
8
8
|
*/
|
|
9
|
-
import { allChoices, revoked } from '../
|
|
9
|
+
import { allChoices, revoked } from '../internal/consent';
|
|
10
10
|
import { getConsentRecord, onConsentChange, openConsentSettings, setConsent } from './consent-store';
|
|
11
11
|
|
|
12
12
|
const FLAG = '__sinnConsentManager';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* (detail: `{ choices, decided, previous }`).
|
|
10
10
|
* SSR-safe: nothing touches the DOM at import time outside the browser.
|
|
11
11
|
*/
|
|
12
|
-
import { allows, CONSENT_EVENT, CONSENT_KEY, parseConsent, serializeConsent, type ConsentChoices, type ConsentRecord } from '../
|
|
12
|
+
import { allows, CONSENT_EVENT, CONSENT_KEY, parseConsent, serializeConsent, type ConsentChoices, type ConsentRecord } from '../internal/consent';
|
|
13
13
|
|
|
14
14
|
export interface ConsentChangeDetail {
|
|
15
15
|
choices: ConsentChoices;
|
|
@@ -48,12 +48,13 @@ function update(root: HTMLElement) {
|
|
|
48
48
|
const fill = (t: string, v: Record<string, string>) => t.replace(/\{(\w+)\}/g, (m, k) => v[k] ?? m);
|
|
49
49
|
const state = status.querySelector<HTMLElement>('[data-hours-state]')!;
|
|
50
50
|
const detail = status.querySelector<HTMLElement>('[data-hours-detail]')!;
|
|
51
|
+
// Narrowed with `in`, which works without strictNullChecks (Astro's base tsconfig leaves it off).
|
|
51
52
|
if (s.open) {
|
|
52
53
|
state.textContent = L.openNow;
|
|
53
|
-
detail.textContent = s
|
|
54
|
+
detail.textContent = 'closes' in s ? fill(s.closesTomorrow ? L.closesTomorrow : L.closes, { time: formatTime(s.closes, locale) }) : L.openAllDay;
|
|
54
55
|
} else {
|
|
55
56
|
state.textContent = L.closed;
|
|
56
|
-
if (s.opens && s.opensDay) {
|
|
57
|
+
if ('opens' in s && s.opens && s.opensDay) {
|
|
57
58
|
const time = formatTime(s.opens, locale);
|
|
58
59
|
detail.textContent =
|
|
59
60
|
s.opensIn === 0 ? fill(L.opensToday, { time }) : s.opensIn === 1 ? fill(L.opensTomorrow, { time }) : fill(L.opensDay, { time, day: dayName(s.opensDay as DayCode, locale, 'long') });
|
package/src/blocks/types.ts
CHANGED
|
@@ -39,16 +39,11 @@ export interface BlockProps {
|
|
|
39
39
|
*/
|
|
40
40
|
placeholder?: boolean;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Path of this block in its content entry (`blocks.2`), set by BlockRenderer when it is given
|
|
43
|
+
* `fieldPath`. Adds `data-sinn-field` attributes for SinnStackCMS visual editing. Plain prop
|
|
44
|
+
* usage can ignore it.
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Shape tinacms adds to query results for visual editing. */
|
|
49
|
-
export interface TinaSource {
|
|
50
|
-
_content_source?: { queryId: string; path: Array<string | number> };
|
|
51
|
-
[key: string]: unknown;
|
|
46
|
+
fieldPath?: string;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
export interface ImageSource {
|
|
@@ -72,6 +67,8 @@ export interface ActionItem {
|
|
|
72
67
|
newTab?: boolean;
|
|
73
68
|
/** Add a trailing arrow (→) to the button. Decorative; mirrored in right-to-left pages. */
|
|
74
69
|
arrow?: boolean;
|
|
70
|
+
/** Path relative to the block (`actions.0`), set by the CMS mappers. */
|
|
71
|
+
field?: string;
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
export interface FeatureItem {
|
|
@@ -85,7 +82,8 @@ export interface FeatureItem {
|
|
|
85
82
|
href?: string;
|
|
86
83
|
/** Short label next to the title ("New", "Beta"). */
|
|
87
84
|
badge?: string;
|
|
88
|
-
|
|
85
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
86
|
+
field?: string;
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
export interface CardItem {
|
|
@@ -97,7 +95,8 @@ export interface CardItem {
|
|
|
97
95
|
eyebrow?: string;
|
|
98
96
|
/** Muted line under the description (date, read time, author). */
|
|
99
97
|
meta?: string;
|
|
100
|
-
|
|
98
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
99
|
+
field?: string;
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
export interface LogoItem {
|
|
@@ -108,7 +107,8 @@ export interface LogoItem {
|
|
|
108
107
|
width?: number;
|
|
109
108
|
height?: number;
|
|
110
109
|
href?: string;
|
|
111
|
-
|
|
110
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
111
|
+
field?: string;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/* ---------- Newer blocks: carousel, page header, contact, steps, media + text, CTA pair ---------- */
|
|
@@ -122,7 +122,8 @@ export interface SlideItem {
|
|
|
122
122
|
/** Usually one action per slide. */
|
|
123
123
|
actions?: ActionItem[];
|
|
124
124
|
image?: ImageSource;
|
|
125
|
-
|
|
125
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
126
|
+
field?: string;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
/** One step of a Steps block. */
|
|
@@ -131,7 +132,8 @@ export interface StepItem {
|
|
|
131
132
|
description?: string;
|
|
132
133
|
/** Icon name from the block icon set. Without one, the step shows its number. */
|
|
133
134
|
icon?: string;
|
|
134
|
-
|
|
135
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
136
|
+
field?: string;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
/**
|
|
@@ -150,7 +152,8 @@ export interface ContactItem {
|
|
|
150
152
|
/** Icon name from the block icon set. Defaults by type. */
|
|
151
153
|
icon?: string;
|
|
152
154
|
newTab?: boolean;
|
|
153
|
-
|
|
155
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
156
|
+
field?: string;
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
/** One panel of a CTAPair. */
|
|
@@ -160,7 +163,8 @@ export interface CtaPanelItem {
|
|
|
160
163
|
actions?: ActionItem[];
|
|
161
164
|
/** Panel color. Defaults: the first panel `accent`, the second `neutral`. */
|
|
162
165
|
tone?: BlockTone;
|
|
163
|
-
|
|
166
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
167
|
+
field?: string;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
/** One figure in a StatsBand ("24" / "Hours a day"). */
|
|
@@ -170,7 +174,8 @@ export interface StatItem {
|
|
|
170
174
|
label: string;
|
|
171
175
|
/** Optional decorative icon: a key of the block's `icons` (default set: blockIcons). */
|
|
172
176
|
icon?: string;
|
|
173
|
-
|
|
177
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
178
|
+
field?: string;
|
|
174
179
|
}
|
|
175
180
|
|
|
176
181
|
/** One colored card in a HighlightCards row. */
|
|
@@ -186,17 +191,19 @@ export interface HighlightCardItem {
|
|
|
186
191
|
* Defaults: accent, neutral, accent… in order.
|
|
187
192
|
*/
|
|
188
193
|
tone?: BlockTone | (string & {});
|
|
189
|
-
|
|
194
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
195
|
+
field?: string;
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
/** A question and its answer (FAQ). */
|
|
193
199
|
export interface FaqItem {
|
|
194
200
|
question: string;
|
|
195
|
-
/** Rich text (
|
|
201
|
+
/** Rich text (a rich-text tree) or plain text. */
|
|
196
202
|
answer: import('./lib/rich-text').RichTextValue;
|
|
197
203
|
/** Stable anchor (`/faq#pricing`). Default: from the question's text. */
|
|
198
204
|
id?: string;
|
|
199
|
-
|
|
205
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
206
|
+
field?: string;
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
/** Where a quote or review was published, linked when there's a public copy. */
|
|
@@ -219,7 +226,8 @@ export interface TestimonialItem {
|
|
|
219
226
|
/** Star rating, when the quote came with one. */
|
|
220
227
|
rating?: number;
|
|
221
228
|
source?: QuoteSource;
|
|
222
|
-
|
|
229
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
230
|
+
field?: string;
|
|
223
231
|
}
|
|
224
232
|
|
|
225
233
|
/** A published review, shown as written. */
|
|
@@ -233,7 +241,8 @@ export interface ReviewItem {
|
|
|
233
241
|
source?: QuoteSource;
|
|
234
242
|
/** The business's public reply, if any. */
|
|
235
243
|
response?: string;
|
|
236
|
-
|
|
244
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
245
|
+
field?: string;
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
/** The overall rating on a review platform. */
|
|
@@ -258,7 +267,8 @@ export interface HoursRow {
|
|
|
258
267
|
closes?: string;
|
|
259
268
|
/** Closed on these days (shown as "Closed"). */
|
|
260
269
|
closed?: boolean;
|
|
261
|
-
|
|
270
|
+
/** Path relative to the block (`items.3`), set by the CMS mappers. */
|
|
271
|
+
field?: string;
|
|
262
272
|
}
|
|
263
273
|
|
|
264
274
|
/** A one-off change: a holiday closure or different hours on a date. */
|
|
@@ -25,6 +25,7 @@ import type { ChartModel } from './lib/chart';
|
|
|
25
25
|
import { renderTable } from './lib/render';
|
|
26
26
|
import './styles/chart.css';
|
|
27
27
|
import { renameProp } from '../primitives/lib/deprecate';
|
|
28
|
+
import { uid } from '../primitives/utils';
|
|
28
29
|
|
|
29
30
|
type Props = {
|
|
30
31
|
chart?: ChartModel;
|
|
@@ -70,7 +71,7 @@ const {
|
|
|
70
71
|
// `data-surface` is the blocks' strong/tinted section attribute; the chart card says data-background.
|
|
71
72
|
const background = renameProp('ChartContainer', 'background', backgroundProp, 'surface', surface) ?? 'default';
|
|
72
73
|
|
|
73
|
-
const base = id ?? chart?.id ??
|
|
74
|
+
const base = id ?? chart?.id ?? uid('sinn-chart');
|
|
74
75
|
const titleId = `${base}-title`;
|
|
75
76
|
const descId = description ? `${base}-desc` : undefined;
|
|
76
77
|
const summaryId = `${base}-summary`;
|