@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.
Files changed (138) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -4
  3. package/docs/blocks.md +373 -364
  4. package/docs/data.md +128 -128
  5. package/docs/finishes.md +165 -0
  6. package/docs/primitives.md +4 -4
  7. package/docs/seo.md +191 -187
  8. package/package.json +15 -24
  9. package/src/blocks/BlockRenderer.astro +13 -7
  10. package/src/blocks/CTABanner.astro +8 -8
  11. package/src/blocks/CTAPair.astro +9 -9
  12. package/src/blocks/CardGrid.astro +7 -7
  13. package/src/blocks/ConsentEmbed.astro +1 -1
  14. package/src/blocks/ConsentManager.astro +1 -1
  15. package/src/blocks/ContactCard.astro +14 -14
  16. package/src/blocks/ContactForm.astro +4 -4
  17. package/src/blocks/ErrorPage.astro +1 -1
  18. package/src/blocks/FAQ.astro +9 -9
  19. package/src/blocks/FeatureGrid.astro +7 -7
  20. package/src/blocks/Hero.astro +11 -11
  21. package/src/blocks/HeroCarousel.astro +11 -11
  22. package/src/blocks/HighlightCards.astro +10 -10
  23. package/src/blocks/LocationHours.astro +14 -14
  24. package/src/blocks/LogoCloud.astro +7 -7
  25. package/src/blocks/MaintenancePage.astro +8 -3
  26. package/src/blocks/MediaText.astro +12 -12
  27. package/src/blocks/PageHeader.astro +9 -9
  28. package/src/blocks/ProseSection.astro +8 -8
  29. package/src/blocks/Reviews.astro +11 -11
  30. package/src/blocks/RichText.astro +58 -57
  31. package/src/blocks/StatsBand.astro +117 -117
  32. package/src/blocks/Steps.astro +9 -9
  33. package/src/blocks/Testimonials.astro +13 -13
  34. package/src/blocks/cms/card-grid.ts +48 -80
  35. package/src/blocks/cms/consent.ts +1 -30
  36. package/src/blocks/cms/contact-card.ts +4 -46
  37. package/src/blocks/cms/contact-form.ts +2 -20
  38. package/src/blocks/cms/cta-banner.ts +2 -23
  39. package/src/blocks/cms/cta-pair.ts +4 -37
  40. package/src/blocks/cms/data-base.ts +2 -4
  41. package/src/blocks/cms/data.ts +19 -19
  42. package/src/blocks/cms/faq.ts +4 -36
  43. package/src/blocks/cms/feature-grid.ts +47 -80
  44. package/src/blocks/cms/fixtures.ts +591 -599
  45. package/src/blocks/cms/hero-carousel.ts +4 -48
  46. package/src/blocks/cms/hero.ts +2 -46
  47. package/src/blocks/cms/highlight-cards.ts +4 -39
  48. package/src/blocks/cms/images.ts +1 -2
  49. package/src/blocks/cms/index.ts +59 -87
  50. package/src/blocks/cms/location-hours.ts +3 -85
  51. package/src/blocks/cms/logo-cloud.ts +36 -62
  52. package/src/blocks/cms/media-text.ts +2 -20
  53. package/src/blocks/cms/page-header.ts +27 -49
  54. package/src/blocks/cms/pages.ts +35 -81
  55. package/src/blocks/cms/prose-section.ts +2 -22
  56. package/src/blocks/cms/reviews.ts +5 -56
  57. package/src/blocks/cms/schema-dsl.ts +134 -0
  58. package/src/blocks/cms/schema.ts +794 -0
  59. package/src/blocks/cms/shared.ts +63 -115
  60. package/src/blocks/cms/stats-band.ts +35 -61
  61. package/src/blocks/cms/steps.ts +4 -31
  62. package/src/blocks/cms/testimonials.ts +4 -38
  63. package/src/blocks/cms/topbar.ts +4 -41
  64. package/src/blocks/cms/types.ts +1 -37
  65. package/src/blocks/consent.ts +2 -2
  66. package/src/blocks/index.ts +2 -2
  67. package/src/blocks/internal/Actions.astro +11 -5
  68. package/src/blocks/internal/BlockHeader.astro +7 -7
  69. package/src/blocks/internal/Placeholder.astro +3 -3
  70. package/src/blocks/internal/fields.ts +18 -0
  71. package/src/blocks/internal/registry-contract.ts +67 -0
  72. package/src/blocks/internal/util.ts +4 -4
  73. package/src/blocks/lib/contact.ts +10 -4
  74. package/src/blocks/lib/faq.ts +1 -1
  75. package/src/blocks/lib/markdown.ts +350 -0
  76. package/src/blocks/lib/rich-text.ts +132 -143
  77. package/src/blocks/scripts/consent-manager.ts +1 -1
  78. package/src/blocks/scripts/consent-store.ts +1 -1
  79. package/src/blocks/scripts/hours.ts +3 -2
  80. package/src/blocks/types.ts +33 -23
  81. package/src/data/ChartContainer.astro +2 -1
  82. package/src/data/cms.ts +130 -190
  83. package/src/data/lib/chart.ts +13 -4
  84. package/src/data/schema.ts +65 -0
  85. package/src/finishes/aurora.css +75 -0
  86. package/src/finishes/autumn.css +87 -0
  87. package/src/finishes/blueprint.css +69 -0
  88. package/src/finishes/brutalist.css +55 -0
  89. package/src/finishes/clay.css +48 -0
  90. package/src/finishes/day-cycle.css +46 -0
  91. package/src/finishes/fog.css +71 -0
  92. package/src/finishes/glass.css +149 -0
  93. package/src/finishes/holographic.css +91 -0
  94. package/src/finishes/night.css +77 -0
  95. package/src/finishes/paper.css +58 -0
  96. package/src/finishes/polished-glass.css +159 -0
  97. package/src/finishes/rain.css +84 -0
  98. package/src/finishes/scripts/day-cycle.ts +30 -0
  99. package/src/finishes/scripts/holographic.ts +37 -0
  100. package/src/finishes/scripts/spotlight.ts +30 -0
  101. package/src/finishes/spotlight.css +41 -0
  102. package/src/finishes/spring.css +80 -0
  103. package/src/finishes/terminal.css +49 -0
  104. package/src/primitives/Divider.astro +1 -1
  105. package/src/primitives/FocusRing.astro +1 -1
  106. package/src/primitives/FormField.astro +2 -2
  107. package/src/primitives/Image.astro +3 -3
  108. package/src/primitives/Input.astro +4 -2
  109. package/src/primitives/MetricCard.astro +3 -1
  110. package/src/primitives/Picture.astro +3 -3
  111. package/src/primitives/Prose.astro +1 -1
  112. package/src/primitives/Select.astro +4 -2
  113. package/src/primitives/Slider.astro +1 -1
  114. package/src/primitives/Table.astro +1 -1
  115. package/src/primitives/Textarea.astro +4 -2
  116. package/src/primitives/Thumbnail.astro +2 -2
  117. package/src/primitives/index.ts +4 -4
  118. package/src/primitives/internal/ChoiceField.astro +4 -2
  119. package/src/primitives/scripts/slider.ts +1 -1
  120. package/src/primitives/scripts/table-sort.ts +2 -2
  121. package/src/seo/cms.ts +59 -80
  122. package/src/seo/index.ts +1 -1
  123. package/src/seo/integration.ts +40 -3
  124. package/src/seo/lib/jsonld.ts +10 -2
  125. package/src/seo/lib/meta.ts +2 -2
  126. package/src/seo/lib/redirects.ts +14 -4
  127. package/src/seo/lib/rss.ts +1 -1
  128. package/src/seo/lib/sitemap.ts +1 -1
  129. package/src/seo/schema.ts +43 -0
  130. package/src/blocks/internal/tina.ts +0 -19
  131. /package/src/blocks/{lib → internal}/consent.ts +0 -0
  132. /package/src/blocks/{lib → internal}/reviews.ts +0 -0
  133. /package/src/blocks/{lib → internal}/slug.ts +0 -0
  134. /package/src/data/{lib → internal}/scale.ts +0 -0
  135. /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
  136. /package/src/primitives/{lib → internal}/image.ts +0 -0
  137. /package/src/primitives/{lib → internal}/slider.ts +0 -0
  138. /package/src/seo/{lib → internal}/url.ts +0 -0
@@ -1,143 +1,132 @@
1
- /**
2
- * Rich text from the CMS: TinaCMS's rich-text AST (or plain text), 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
-
11
- export interface RichTextNode {
12
- type: string;
13
- children?: RichTextNode[];
14
- /** Text leaves. */
15
- text?: string;
16
- bold?: boolean;
17
- italic?: boolean;
18
- code?: boolean;
19
- strikethrough?: boolean;
20
- underline?: boolean;
21
- /** Links and images. */
22
- url?: string;
23
- title?: string;
24
- alt?: string;
25
- caption?: string;
26
- /** Code blocks. */
27
- value?: string;
28
- lang?: string;
29
- [key: string]: unknown;
30
- }
31
- export interface RichTextRoot extends RichTextNode {
32
- type: 'root';
33
- children: RichTextNode[];
34
- }
35
- /** What a block accepts: a Tina rich-text AST, plain text (blank lines separate paragraphs), or nothing. */
36
- export type RichTextValue = RichTextRoot | RichTextNode[] | string | null | undefined;
37
-
38
- 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']);
39
- export const INLINE_TYPES = new Set(['text', 'a', 'break']);
40
-
41
- /** Normalize any accepted value to a root node (plain text becomes paragraphs and line breaks). */
42
- export function toRichTextRoot(value: RichTextValue): RichTextRoot {
43
- if (value == null) return { type: 'root', children: [] };
44
- if (typeof value === 'string') {
45
- const paragraphs = value
46
- .replace(/\r\n?/g, '\n')
47
- .split(/\n\s*\n/)
48
- .map((p) => p.trim())
49
- .filter(Boolean);
50
- return {
51
- type: 'root',
52
- children: paragraphs.map((p) => ({
53
- type: 'p',
54
- children: p.split('\n').flatMap((line, i) => (i ? [{ type: 'break' }, { type: 'text', text: line }] : [{ type: 'text', text: line }])),
55
- })),
56
- };
57
- }
58
- if (Array.isArray(value)) return { type: 'root', children: value };
59
- if (value.type === 'root' && Array.isArray(value.children)) return value as RichTextRoot;
60
- return { type: 'root', children: [value] };
61
- }
62
-
63
- /** True when the value would render no visible text or media. */
64
- export function isRichTextEmpty(value: RichTextValue): boolean {
65
- const root = toRichTextRoot(value);
66
- const visible = (n: RichTextNode): boolean => {
67
- if (!n || typeof n !== 'object') return false;
68
- if (n.type === 'text') return Boolean(n.text?.trim());
69
- if (n.type === 'img') return Boolean(safeMediaUrl(n.url));
70
- if (n.type === 'code_block') return Boolean(n.value?.trim());
71
- if (n.type === 'hr') return false;
72
- if (!BLOCK_TYPES.has(n.type) && !INLINE_TYPES.has(n.type)) return false;
73
- return (n.children ?? []).some(visible);
74
- };
75
- return !root.children.some(visible);
76
- }
77
-
78
- /**
79
- * Plain text, for structured data (FAQ answers), meta descriptions and accessible names.
80
- * Paragraph-level nodes are separated by a blank line and list items by a newline.
81
- */
82
- export function richTextPlain(value: RichTextValue): string {
83
- const root = toRichTextRoot(value);
84
- const BLOCKS = new Set(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'code_block', 'table', 'ul', 'ol']);
85
- const walk = (n: RichTextNode): string => {
86
- if (!n || typeof n !== 'object') return '';
87
- if (n.type === 'text') return n.text ?? '';
88
- if (n.type === 'break') return '\n';
89
- if (n.type === 'code_block') return n.value ?? '';
90
- if (n.type === 'img') return '';
91
- if (!BLOCK_TYPES.has(n.type) && !INLINE_TYPES.has(n.type) && n.type !== 'root') return '';
92
- const kids = n.children ?? [];
93
- if (n.type === 'ul' || n.type === 'ol') return kids.map(walk).filter((s) => s.trim()).join('\n');
94
- if (n.type === 'tr') return kids.map(walk).join('\t');
95
- if (n.type === 'table' || n.type === 'thead' || n.type === 'tbody') return kids.map(walk).join('\n');
96
- if (n.type === 'root') {
97
- return kids
98
- .map((k) => walk(k).trim())
99
- .filter(Boolean)
100
- .join('\n\n');
101
- }
102
- const inner = kids.map(walk).join('');
103
- return BLOCKS.has(n.type) ? inner.trim() : inner;
104
- };
105
- return walk(root).replace(/[ \t]+\n/g, '\n').trim();
106
- }
107
-
108
- /** Smallest heading level used in the content (h1 → 1), or undefined when there are none. */
109
- export function topHeadingLevel(value: RichTextValue): number | undefined {
110
- let min: number | undefined;
111
- const walk = (n: RichTextNode) => {
112
- const m = /^h([1-6])$/.exec(n?.type ?? '');
113
- if (m) min = Math.min(min ?? 6, Number(m[1]));
114
- (n?.children ?? []).forEach(walk);
115
- };
116
- toRichTextRoot(value).children.forEach(walk);
117
- return min;
118
- }
119
-
120
- /**
121
- * The level a content heading renders at, so the content's top heading lands on `topLevel`
122
- * (the editor's h1/h2 never competes with the page title) and relative levels are kept.
123
- */
124
- export function shiftedHeading(level: number, contentTop: number | undefined, topLevel: number): 2 | 3 | 4 | 5 | 6 {
125
- const shift = topLevel - (contentTop ?? level);
126
- return Math.min(6, Math.max(2, Math.max(topLevel, level + shift))) as 2 | 3 | 4 | 5 | 6;
127
- }
128
-
129
- /** Link targets: http(s), mailto, tel, sms, relative paths and fragments. */
130
- export function safeLinkUrl(url: unknown): string | undefined {
131
- return typeof url === 'string' ? safeHref(url) : undefined;
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 '../lib/consent';
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 '../lib/consent';
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.allDay ? L.openAllDay : fill(s.closesTomorrow ? L.closesTomorrow : L.closes, { time: formatTime(s.closes, locale) });
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') });
@@ -39,16 +39,11 @@ export interface BlockProps {
39
39
  */
40
40
  placeholder?: boolean;
41
41
  /**
42
- * The block's raw CMS data (from Tina), used only to add `data-tina-field` attributes for
43
- * click-to-edit. Plain prop usage can ignore it.
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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 (TinaCMS rich-text AST) or plain 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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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
- tina?: TinaSource;
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 ?? `sinn-chart-${Math.random().toString(36).slice(2, 8)}`;
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`;