@styleflow.app/flowpress-astro-core 1.0.0-beta.2 → 1.0.0-beta.20
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 +146 -1
- package/README.md +111 -3
- package/dist/astro/BaseLayout.astro +10 -6
- package/dist/astro/CompositionRenderer.astro +148 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +6 -1
- package/dist/astro/GutenbergRenderer.astro +231 -72
- package/dist/astro/ThemeRuntime.astro +24 -0
- package/dist/astro/blocks/CarouselBlock.astro +7 -9
- package/dist/astro/blocks/CarouselItemBlock.astro +3 -3
- package/dist/astro/blocks/ColumnBlock.astro +3 -4
- package/dist/astro/blocks/CoverBlock.astro +155 -0
- package/dist/astro/blocks/FormBlock.astro +18 -16
- package/dist/astro/blocks/GridBlock.astro +3 -3
- package/dist/astro/blocks/HeroBlock.astro +3 -4
- package/dist/astro/blocks/ImageBlock.astro +3 -4
- package/dist/astro/blocks/ListItemFallback.astro +7 -5
- package/dist/astro/blocks/NumberSpinnerBlock.astro +25 -19
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
- package/dist/astro/blocks/TextBlock.astro +29 -25
- package/dist/astro/blocks/ThemeToggleBlock.astro +23 -0
- package/dist/astro/blocks/cover.d.ts +13 -0
- package/dist/astro/blocks/cover.d.ts.map +1 -0
- package/dist/astro/blocks/cover.js +105 -0
- package/dist/astro/blocks/cover.js.map +1 -0
- package/dist/astro/blocks/cover.ts +119 -0
- package/dist/astro/blocks/helpers.d.ts +7 -0
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +51 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +63 -45
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +86 -0
- package/dist/astro/native/LevelTag.astro +20 -0
- package/dist/astro/native/MapBlock.astro +41 -0
- package/dist/astro/native/NativeHtmlBlock.astro +12 -0
- package/dist/astro/native/NativeIconBlock.astro +33 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ResolvedBlocks.astro +89 -0
- package/dist/astro/native/SyncedPatternContent.astro +92 -0
- package/dist/astro/native/TermFieldValue.astro +37 -0
- package/dist/astro/native/Timeline.astro +20 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button.astro +43 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +23 -0
- package/dist/astro/native/core-home-link.astro +11 -0
- package/dist/astro/native/core-html.astro +8 -0
- package/dist/astro/native/core-icon.astro +7 -0
- package/dist/astro/native/core-image.astro +124 -0
- package/dist/astro/native/core-navigation-link.astro +70 -0
- package/dist/astro/native/core-navigation-submenu.astro +32 -0
- package/dist/astro/native/core-navigation.astro +94 -0
- package/dist/astro/native/core-page-list-data-item.astro +18 -0
- package/dist/astro/native/core-page-list-item.astro +7 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +20 -0
- package/dist/astro/native/core-post-excerpt.astro +25 -0
- package/dist/astro/native/core-post-featured-image.astro +37 -0
- package/dist/astro/native/core-post-template.astro +30 -0
- package/dist/astro/native/core-post-terms.astro +46 -0
- package/dist/astro/native/core-post-title.astro +23 -0
- package/dist/astro/native/core-query-no-results.astro +12 -0
- package/dist/astro/native/core-query.astro +22 -0
- package/dist/astro/native/core-site-title.astro +15 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +20 -0
- package/dist/astro/native/core-term-template.astro +30 -0
- package/dist/astro/native/core-terms-query.astro +19 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.js +217 -0
- package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
- package/dist/astro/native/flowpress-navigation.css +17 -0
- package/dist/astro/native/grid-bleed.js +106 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +72 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +72 -0
- package/dist/astro/native/sf-block-binding.astro +20 -0
- package/dist/astro/native/sf-post-field.astro +9 -0
- package/dist/astro/native/sf-term-field.astro +9 -0
- package/dist/astro/native/timeline.css +4 -0
- package/dist/astro/native/timeline.d.ts +28 -0
- package/dist/astro/native/timeline.d.ts.map +1 -0
- package/dist/astro/native/timeline.js +43 -0
- package/dist/astro/native/timeline.js.map +1 -0
- package/dist/astro/native/timeline.ts +79 -0
- package/dist/block-renderers.d.ts +20 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/client.d.ts +17 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +63 -9
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +124 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +107 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +5 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +32 -0
- package/dist/links.js.map +1 -0
- package/dist/media.d.ts +28 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +212 -0
- package/dist/media.js.map +1 -0
- package/dist/styleflow.d.ts +16 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +67 -7
- package/dist/styleflow.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +77 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +84 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -4
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
---
|
|
2
|
+
import "./native/grid.css";
|
|
2
3
|
import S from "@styleflow.app/astro/S.astro";
|
|
3
4
|
import type {
|
|
5
|
+
FlowpressBlockAdapters,
|
|
4
6
|
FlowpressBlockRenderers,
|
|
5
7
|
FlowpressIconRenderer
|
|
6
8
|
} from "../block-renderers.js";
|
|
9
|
+
import {
|
|
10
|
+
flowpressAdapterCompatibilityIssue,
|
|
11
|
+
flowpressBlockTypeDescriptors
|
|
12
|
+
} from "../composition.js";
|
|
7
13
|
import type { StyleflowContract } from "../styleflow.js";
|
|
8
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
FlowpressBlock,
|
|
16
|
+
FlowpressBlockHtmlProps,
|
|
17
|
+
FlowpressCompositionV1,
|
|
18
|
+
FlowpressBlockTypeDescriptor
|
|
19
|
+
} from "../types.js";
|
|
20
|
+
import type { DynamicStyleflowProps } from "../styleflow.js";
|
|
9
21
|
import ColumnBlock from "./blocks/ColumnBlock.astro";
|
|
10
22
|
import CarouselBlock from "./blocks/CarouselBlock.astro";
|
|
11
23
|
import CarouselItemBlock from "./blocks/CarouselItemBlock.astro";
|
|
24
|
+
import CoverBlock from "./blocks/CoverBlock.astro";
|
|
12
25
|
import FormBlock from "./blocks/FormBlock.astro";
|
|
13
26
|
import GridBlock from "./blocks/GridBlock.astro";
|
|
14
27
|
import HeroBlock from "./blocks/HeroBlock.astro";
|
|
@@ -26,12 +39,45 @@ import {
|
|
|
26
39
|
|
|
27
40
|
interface Props {
|
|
28
41
|
blocks: FlowpressBlock[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
descriptorIndex?: ReadonlyMap<string, FlowpressBlockTypeDescriptor> | undefined;
|
|
43
|
+
contract?: StyleflowContract | undefined;
|
|
44
|
+
blockRenderers?: FlowpressBlockRenderers | undefined;
|
|
45
|
+
iconRenderer?: FlowpressIconRenderer | undefined;
|
|
46
|
+
rootHtmlProps?: FlowpressBlockHtmlProps | undefined;
|
|
47
|
+
rootStyleflowProps?: DynamicStyleflowProps | undefined;
|
|
48
|
+
adapterDefinitions?: FlowpressBlockAdapters | undefined;
|
|
49
|
+
composition?: FlowpressCompositionV1 | undefined;
|
|
50
|
+
parentBlockName?: string | undefined;
|
|
51
|
+
production?: boolean | undefined;
|
|
52
|
+
depth?: number | undefined;
|
|
53
|
+
skipCustomRendererFor?: string | undefined;
|
|
54
|
+
requireRegisteredAdapters?: boolean | undefined;
|
|
32
55
|
}
|
|
33
56
|
|
|
34
|
-
const {
|
|
57
|
+
const {
|
|
58
|
+
blocks: rawBlocks,
|
|
59
|
+
contract,
|
|
60
|
+
blockRenderers = {},
|
|
61
|
+
iconRenderer: IconRenderer,
|
|
62
|
+
rootHtmlProps,
|
|
63
|
+
rootStyleflowProps,
|
|
64
|
+
adapterDefinitions,
|
|
65
|
+
composition,
|
|
66
|
+
parentBlockName,
|
|
67
|
+
production = import.meta.env.PROD,
|
|
68
|
+
depth = 0,
|
|
69
|
+
skipCustomRendererFor,
|
|
70
|
+
requireRegisteredAdapters = false
|
|
71
|
+
} = Astro.props;
|
|
72
|
+
const { decorateGridBlocks } = await import("./native/grid.js");
|
|
73
|
+
const blocks = decorateGridBlocks(rawBlocks);
|
|
74
|
+
const { nativeBlockRenderers } = await import("./native/registry.js");
|
|
75
|
+
const effectiveRenderers = { ...nativeBlockRenderers, ...blockRenderers };
|
|
76
|
+
const descriptors = Astro.props.descriptorIndex ?? (composition ? flowpressBlockTypeDescriptors(composition) : undefined);
|
|
77
|
+
|
|
78
|
+
function objectCollection(value: unknown): Record<string, unknown>[] {
|
|
79
|
+
return Array.isArray(value) ? value.filter((item): item is Record<string, unknown> => !!item && typeof item === "object") : [];
|
|
80
|
+
}
|
|
35
81
|
|
|
36
82
|
function youtubeEmbedUrl(value: unknown): string | null {
|
|
37
83
|
try {
|
|
@@ -49,36 +95,104 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
49
95
|
return null;
|
|
50
96
|
}
|
|
51
97
|
}
|
|
98
|
+
|
|
99
|
+
function nestedRendererProps(nextParentBlockName: string) {
|
|
100
|
+
return {
|
|
101
|
+
adapterDefinitions,
|
|
102
|
+
composition,
|
|
103
|
+
parentBlockName: nextParentBlockName,
|
|
104
|
+
production,
|
|
105
|
+
depth: depth + 1,
|
|
106
|
+
requireRegisteredAdapters
|
|
107
|
+
};
|
|
108
|
+
}
|
|
52
109
|
---
|
|
53
110
|
|
|
54
|
-
{blocks.map((block) => {
|
|
111
|
+
{blocks.map((block, index) => {
|
|
55
112
|
const name = block.name.replace(/^sf\//, "");
|
|
56
|
-
const children = block.innerBlocks ?? [];
|
|
57
|
-
const semantic =
|
|
58
|
-
|
|
59
|
-
|
|
113
|
+
const children = decorateGridBlocks(block.innerBlocks ?? []);
|
|
114
|
+
const semantic = index === 0 && blocks.length === 1 && rootStyleflowProps
|
|
115
|
+
? rootStyleflowProps
|
|
116
|
+
: semanticProps(block.attributes, contract);
|
|
117
|
+
const htmlAttributes = index === 0 && blocks.length === 1 && rootHtmlProps
|
|
118
|
+
? { ...rootHtmlProps, class: Array.from(new Set([rootHtmlProps.class, block.attributes.className].filter(Boolean).join(" ").split(/\s+/))).join(" ") }
|
|
119
|
+
: blockHtmlAttributes(block.attributes);
|
|
120
|
+
const CustomBlockRenderer = block.name === skipCustomRendererFor
|
|
121
|
+
? nativeBlockRenderers[block.name as keyof typeof nativeBlockRenderers]
|
|
122
|
+
: effectiveRenderers[block.name as keyof typeof effectiveRenderers];
|
|
123
|
+
const compatibilityIssue = descriptors && adapterDefinitions
|
|
124
|
+
? flowpressAdapterCompatibilityIssue(block.name, descriptors, adapterDefinitions)
|
|
125
|
+
: null;
|
|
126
|
+
|
|
127
|
+
if (compatibilityIssue && production && block.name !== skipCustomRendererFor) {
|
|
128
|
+
throw new Error(compatibilityIssue.message);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
requireRegisteredAdapters
|
|
133
|
+
&& block.name !== skipCustomRendererFor
|
|
134
|
+
&& (!adapterDefinitions?.[block.name] || !CustomBlockRenderer)
|
|
135
|
+
) {
|
|
136
|
+
const message = compatibilityIssue?.message
|
|
137
|
+
?? `Missing FlowPress block adapter for "${block.name}".`;
|
|
138
|
+
if (production) throw new Error(message);
|
|
139
|
+
return (
|
|
140
|
+
<aside data-flowpress-compatibility="missing-adapter" data-block-name={block.name} role="status">
|
|
141
|
+
<strong>{message}</strong>
|
|
142
|
+
<code>{compatibilityIssue?.command ?? `pnpm cms:block-adapter ${block.name}`}</code>
|
|
143
|
+
</aside>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
60
146
|
|
|
61
147
|
if (CustomBlockRenderer) {
|
|
62
148
|
return (
|
|
63
|
-
|
|
64
|
-
|
|
149
|
+
<>
|
|
150
|
+
{compatibilityIssue ? (
|
|
151
|
+
<aside data-flowpress-compatibility={compatibilityIssue.code} data-block-name={block.name} role="status">
|
|
152
|
+
<strong>{compatibilityIssue.message}</strong>
|
|
153
|
+
<code>{compatibilityIssue.command}</code>
|
|
154
|
+
</aside>
|
|
155
|
+
) : null}
|
|
156
|
+
<CustomBlockRenderer
|
|
157
|
+
block={block}
|
|
158
|
+
contract={contract}
|
|
159
|
+
composition={composition}
|
|
160
|
+
adapters={adapterDefinitions ?? {}}
|
|
161
|
+
htmlProps={htmlAttributes}
|
|
162
|
+
styleflowProps={semantic}
|
|
163
|
+
parentBlockName={parentBlockName}
|
|
164
|
+
context={{
|
|
165
|
+
...(parentBlockName ? { parentBlockName } : {}),
|
|
166
|
+
depth,
|
|
167
|
+
production
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Astro.self descriptorIndex={descriptors}
|
|
65
171
|
blocks={children}
|
|
66
172
|
contract={contract}
|
|
67
173
|
blockRenderers={blockRenderers}
|
|
68
174
|
iconRenderer={IconRenderer}
|
|
175
|
+
adapterDefinitions={adapterDefinitions}
|
|
176
|
+
composition={composition}
|
|
177
|
+
parentBlockName={block.name}
|
|
178
|
+
production={production}
|
|
179
|
+
depth={depth + 1}
|
|
180
|
+
requireRegisteredAdapters={requireRegisteredAdapters}
|
|
69
181
|
/>
|
|
70
182
|
</CustomBlockRenderer>
|
|
183
|
+
</>
|
|
71
184
|
);
|
|
72
185
|
}
|
|
73
186
|
|
|
74
187
|
if (name === "hero") {
|
|
75
188
|
return (
|
|
76
189
|
<HeroBlock block={block} contract={contract}>
|
|
77
|
-
<Astro.self
|
|
190
|
+
<Astro.self descriptorIndex={descriptors}
|
|
78
191
|
blocks={children}
|
|
79
192
|
contract={contract}
|
|
80
193
|
blockRenderers={blockRenderers}
|
|
81
194
|
iconRenderer={IconRenderer}
|
|
195
|
+
{...nestedRendererProps(block.name)}
|
|
82
196
|
/>
|
|
83
197
|
</HeroBlock>
|
|
84
198
|
);
|
|
@@ -87,11 +201,12 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
87
201
|
if (name === "grid") {
|
|
88
202
|
return (
|
|
89
203
|
<GridBlock block={block} contract={contract}>
|
|
90
|
-
<Astro.self
|
|
204
|
+
<Astro.self descriptorIndex={descriptors}
|
|
91
205
|
blocks={children}
|
|
92
206
|
contract={contract}
|
|
93
207
|
blockRenderers={blockRenderers}
|
|
94
208
|
iconRenderer={IconRenderer}
|
|
209
|
+
{...nestedRendererProps(block.name)}
|
|
95
210
|
/>
|
|
96
211
|
</GridBlock>
|
|
97
212
|
);
|
|
@@ -100,11 +215,12 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
100
215
|
if (name === "column") {
|
|
101
216
|
return (
|
|
102
217
|
<ColumnBlock block={block} contract={contract}>
|
|
103
|
-
<Astro.self
|
|
218
|
+
<Astro.self descriptorIndex={descriptors}
|
|
104
219
|
blocks={children}
|
|
105
220
|
contract={contract}
|
|
106
221
|
blockRenderers={blockRenderers}
|
|
107
222
|
iconRenderer={IconRenderer}
|
|
223
|
+
{...nestedRendererProps(block.name)}
|
|
108
224
|
/>
|
|
109
225
|
</ColumnBlock>
|
|
110
226
|
);
|
|
@@ -121,11 +237,12 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
121
237
|
validChildren={invalidChildNames.length === 0}
|
|
122
238
|
invalidChildNames={invalidChildNames}
|
|
123
239
|
>
|
|
124
|
-
<Astro.self
|
|
240
|
+
<Astro.self descriptorIndex={descriptors}
|
|
125
241
|
blocks={children}
|
|
126
242
|
contract={contract}
|
|
127
243
|
blockRenderers={blockRenderers}
|
|
128
244
|
iconRenderer={IconRenderer}
|
|
245
|
+
{...nestedRendererProps(block.name)}
|
|
129
246
|
/>
|
|
130
247
|
</CarouselBlock>
|
|
131
248
|
);
|
|
@@ -134,11 +251,12 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
134
251
|
if (name === "carousel-item") {
|
|
135
252
|
return (
|
|
136
253
|
<CarouselItemBlock block={block} contract={contract}>
|
|
137
|
-
<Astro.self
|
|
254
|
+
<Astro.self descriptorIndex={descriptors}
|
|
138
255
|
blocks={children}
|
|
139
256
|
contract={contract}
|
|
140
257
|
blockRenderers={blockRenderers}
|
|
141
258
|
iconRenderer={IconRenderer}
|
|
259
|
+
{...nestedRendererProps(block.name)}
|
|
142
260
|
/>
|
|
143
261
|
</CarouselItemBlock>
|
|
144
262
|
);
|
|
@@ -148,6 +266,25 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
148
266
|
return <NumberSpinnerBlock block={block} contract={contract} />;
|
|
149
267
|
}
|
|
150
268
|
|
|
269
|
+
if (block.name === "core/cover") {
|
|
270
|
+
return (
|
|
271
|
+
<CoverBlock
|
|
272
|
+
block={block}
|
|
273
|
+
contract={contract}
|
|
274
|
+
htmlProps={htmlAttributes}
|
|
275
|
+
styleflowProps={semantic}
|
|
276
|
+
>
|
|
277
|
+
<Astro.self descriptorIndex={descriptors}
|
|
278
|
+
blocks={children}
|
|
279
|
+
contract={contract}
|
|
280
|
+
blockRenderers={blockRenderers}
|
|
281
|
+
iconRenderer={IconRenderer}
|
|
282
|
+
{...nestedRendererProps(block.name)}
|
|
283
|
+
/>
|
|
284
|
+
</CoverBlock>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
151
288
|
if ([
|
|
152
289
|
"heading",
|
|
153
290
|
"rich-text",
|
|
@@ -160,18 +297,19 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
160
297
|
].includes(name)) {
|
|
161
298
|
return (
|
|
162
299
|
<TextBlock block={block} contract={contract} hasChildren={children.length > 0}>
|
|
163
|
-
<Astro.self
|
|
300
|
+
<Astro.self descriptorIndex={descriptors}
|
|
164
301
|
blocks={children}
|
|
165
302
|
contract={contract}
|
|
166
303
|
blockRenderers={blockRenderers}
|
|
167
304
|
iconRenderer={IconRenderer}
|
|
305
|
+
{...nestedRendererProps(block.name)}
|
|
168
306
|
/>
|
|
169
307
|
</TextBlock>
|
|
170
308
|
);
|
|
171
309
|
}
|
|
172
310
|
|
|
173
311
|
if (name === "button") {
|
|
174
|
-
const href = linkValue(block, "href")
|
|
312
|
+
const href = linkValue(block, "href");
|
|
175
313
|
const link = objectValue(block, "href");
|
|
176
314
|
const opensInNewTab = Boolean(link.opensInNewTab);
|
|
177
315
|
const icon = String(block.attributes.icon ?? "").trim();
|
|
@@ -185,19 +323,32 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
185
323
|
const buttonIcon = IconRenderer && icon ? (
|
|
186
324
|
<IconRenderer name={icon} display="inline" size={4} />
|
|
187
325
|
) : null;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
326
|
+
const buttonContent = (
|
|
327
|
+
<>
|
|
328
|
+
{iconPosition === "before" ? buttonIcon : null}
|
|
329
|
+
{textValue(block, "label")}
|
|
330
|
+
{iconPosition === "after" ? buttonIcon : null}
|
|
331
|
+
</>
|
|
332
|
+
);
|
|
333
|
+
return href ? (
|
|
334
|
+
<S.a
|
|
191
335
|
href={href}
|
|
192
336
|
target={opensInNewTab ? "_blank" : undefined}
|
|
193
337
|
rel={opensInNewTab ? "noopener noreferrer" : undefined}
|
|
194
338
|
{...buttonSemantic}
|
|
195
339
|
{...htmlAttributes}
|
|
196
340
|
>
|
|
197
|
-
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
341
|
+
{buttonContent}
|
|
342
|
+
</S.a>
|
|
343
|
+
) : (
|
|
344
|
+
<S.span
|
|
345
|
+
aria-disabled="true"
|
|
346
|
+
data-flowpress-link-unresolved
|
|
347
|
+
{...buttonSemantic}
|
|
348
|
+
{...htmlAttributes}
|
|
349
|
+
>
|
|
350
|
+
{buttonContent}
|
|
351
|
+
</S.span>
|
|
201
352
|
);
|
|
202
353
|
}
|
|
203
354
|
|
|
@@ -241,10 +392,10 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
241
392
|
|
|
242
393
|
if (name === "gallery") {
|
|
243
394
|
const images = Array.isArray(block.attributes.images)
|
|
244
|
-
? block.attributes.images
|
|
395
|
+
? objectCollection(block.attributes.images)
|
|
245
396
|
: [];
|
|
246
397
|
return (
|
|
247
|
-
<S
|
|
398
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
248
399
|
{images.map((image) => image.url ? (
|
|
249
400
|
<img
|
|
250
401
|
src={String(image.url)}
|
|
@@ -253,7 +404,7 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
253
404
|
decoding="async"
|
|
254
405
|
/>
|
|
255
406
|
) : null)}
|
|
256
|
-
</S>
|
|
407
|
+
</S.div>
|
|
257
408
|
);
|
|
258
409
|
}
|
|
259
410
|
|
|
@@ -261,7 +412,7 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
261
412
|
const video = objectValue(block, "video");
|
|
262
413
|
const poster = objectValue(block, "poster");
|
|
263
414
|
return video.url ? (
|
|
264
|
-
<S
|
|
415
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
265
416
|
<video
|
|
266
417
|
src={String(video.url)}
|
|
267
418
|
poster={poster.url ? String(poster.url) : undefined}
|
|
@@ -270,14 +421,14 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
270
421
|
muted={Boolean(block.attributes.autoplay)}
|
|
271
422
|
playsinline
|
|
272
423
|
/>
|
|
273
|
-
</S>
|
|
424
|
+
</S.div>
|
|
274
425
|
) : null;
|
|
275
426
|
}
|
|
276
427
|
|
|
277
428
|
if (name === "video-youtube") {
|
|
278
429
|
const embed = youtubeEmbedUrl(block.attributes.url);
|
|
279
430
|
return embed ? (
|
|
280
|
-
<S
|
|
431
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
281
432
|
<iframe
|
|
282
433
|
src={embed}
|
|
283
434
|
title={String(block.attributes.title ?? "YouTube video")}
|
|
@@ -285,15 +436,15 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
285
436
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
286
437
|
allowfullscreen
|
|
287
438
|
/>
|
|
288
|
-
</S>
|
|
439
|
+
</S.div>
|
|
289
440
|
) : null;
|
|
290
441
|
}
|
|
291
442
|
|
|
292
443
|
if (name === "chip") {
|
|
293
444
|
return (
|
|
294
|
-
<S
|
|
445
|
+
<S.span {...semantic} {...htmlAttributes}>
|
|
295
446
|
{textValue(block, "label")}
|
|
296
|
-
</S>
|
|
447
|
+
</S.span>
|
|
297
448
|
);
|
|
298
449
|
}
|
|
299
450
|
|
|
@@ -301,60 +452,63 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
301
452
|
const media = objectValue(block, "image");
|
|
302
453
|
const href = linkValue(block);
|
|
303
454
|
return (
|
|
304
|
-
<S
|
|
455
|
+
<S.article {...semantic} {...htmlAttributes}>
|
|
305
456
|
{media.url && (
|
|
306
457
|
<img src={String(media.url)} alt={String(media.alt ?? "")} loading="lazy" />
|
|
307
458
|
)}
|
|
308
|
-
{block.attributes.title && <S
|
|
309
|
-
{block.attributes.text && <S
|
|
310
|
-
{href && <S
|
|
311
|
-
</S>
|
|
459
|
+
{block.attributes.title && <S.h3>{String(block.attributes.title)}</S.h3>}
|
|
460
|
+
{block.attributes.text && <S.p>{String(block.attributes.text)}</S.p>}
|
|
461
|
+
{href && <S.a href={href}>Scopri</S.a>}
|
|
462
|
+
</S.article>
|
|
312
463
|
);
|
|
313
464
|
}
|
|
314
465
|
|
|
315
466
|
if (name === "content-list" || name === "term-list") {
|
|
316
467
|
const items = Array.isArray(block.attributes.resolvedItems)
|
|
317
|
-
? block.attributes.resolvedItems
|
|
468
|
+
? objectCollection(block.attributes.resolvedItems)
|
|
318
469
|
: [];
|
|
319
470
|
const resolvedBlocks = Array.isArray(block.attributes.resolvedBlocks)
|
|
320
471
|
? block.attributes.resolvedBlocks as FlowpressBlock[][]
|
|
321
472
|
: [];
|
|
322
473
|
return (
|
|
323
|
-
<S
|
|
474
|
+
<S.ul {...semantic} {...htmlAttributes}>
|
|
324
475
|
{items.map((item, index) => (
|
|
325
|
-
<S
|
|
476
|
+
<S.li>
|
|
326
477
|
{resolvedBlocks[index]?.length ? (
|
|
327
|
-
<Astro.self
|
|
478
|
+
<Astro.self descriptorIndex={descriptors}
|
|
328
479
|
blocks={resolvedBlocks[index]}
|
|
329
480
|
contract={contract}
|
|
330
481
|
blockRenderers={blockRenderers}
|
|
331
482
|
iconRenderer={IconRenderer}
|
|
483
|
+
{...nestedRendererProps(block.name)}
|
|
332
484
|
/>
|
|
333
485
|
) : (
|
|
334
486
|
<ListItemFallback item={item} />
|
|
335
487
|
)}
|
|
336
|
-
</S>
|
|
488
|
+
</S.li>
|
|
337
489
|
))}
|
|
338
|
-
</S>
|
|
490
|
+
</S.ul>
|
|
339
491
|
);
|
|
340
492
|
}
|
|
341
493
|
|
|
342
494
|
if (name === "template") {
|
|
343
495
|
return Object.keys(htmlAttributes).length > 0 ? (
|
|
344
496
|
<div {...htmlAttributes}>
|
|
345
|
-
<Astro.self
|
|
497
|
+
<Astro.self descriptorIndex={descriptors}
|
|
346
498
|
blocks={children}
|
|
347
499
|
contract={contract}
|
|
348
500
|
blockRenderers={blockRenderers}
|
|
349
501
|
iconRenderer={IconRenderer}
|
|
502
|
+
{...nestedRendererProps(block.name)}
|
|
350
503
|
/>
|
|
351
504
|
</div>
|
|
352
505
|
) : (
|
|
353
|
-
<Astro.self
|
|
506
|
+
<Astro.self descriptorIndex={descriptors}
|
|
354
507
|
blocks={children}
|
|
355
508
|
contract={contract}
|
|
356
509
|
blockRenderers={blockRenderers}
|
|
357
510
|
iconRenderer={IconRenderer}
|
|
511
|
+
{...nestedRendererProps(block.name)}
|
|
358
512
|
/>
|
|
359
513
|
);
|
|
360
514
|
}
|
|
@@ -365,17 +519,18 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
365
519
|
|
|
366
520
|
if (name === "accordion-item") {
|
|
367
521
|
return (
|
|
368
|
-
<S
|
|
522
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
369
523
|
<details>
|
|
370
524
|
<summary>{String(block.attributes.title ?? "")}</summary>
|
|
371
|
-
<Astro.self
|
|
525
|
+
<Astro.self descriptorIndex={descriptors}
|
|
372
526
|
blocks={children}
|
|
373
527
|
contract={contract}
|
|
374
528
|
blockRenderers={blockRenderers}
|
|
375
529
|
iconRenderer={IconRenderer}
|
|
530
|
+
{...nestedRendererProps(block.name)}
|
|
376
531
|
/>
|
|
377
532
|
</details>
|
|
378
|
-
</S>
|
|
533
|
+
</S.div>
|
|
379
534
|
);
|
|
380
535
|
}
|
|
381
536
|
|
|
@@ -396,42 +551,46 @@ function youtubeEmbedUrl(value: unknown): string | null {
|
|
|
396
551
|
+ `?key=${encodeURIComponent(googleMapsApiKey)}`
|
|
397
552
|
+ `&q=${encodeURIComponent(query)}`;
|
|
398
553
|
return (
|
|
399
|
-
<S
|
|
554
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
400
555
|
<iframe
|
|
401
556
|
src={source}
|
|
402
557
|
title={address || "Map"}
|
|
403
558
|
loading="lazy"
|
|
404
559
|
referrerpolicy="no-referrer-when-downgrade"
|
|
405
560
|
/>
|
|
406
|
-
</S>
|
|
561
|
+
</S.div>
|
|
407
562
|
);
|
|
408
563
|
}
|
|
409
564
|
return query ? (
|
|
410
|
-
<S
|
|
411
|
-
<S
|
|
412
|
-
as="a"
|
|
565
|
+
<S.div {...semantic} {...htmlAttributes}>
|
|
566
|
+
<S.a
|
|
413
567
|
href={`https://www.openstreetmap.org/search?query=${encodeURIComponent(query)}`}
|
|
414
568
|
rel="noreferrer"
|
|
415
569
|
>
|
|
416
570
|
{address || query}
|
|
417
|
-
</S>
|
|
418
|
-
</S>
|
|
571
|
+
</S.a>
|
|
572
|
+
</S.div>
|
|
419
573
|
) : null;
|
|
420
574
|
}
|
|
421
575
|
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
576
|
+
const fallbackContent = block.innerHtml && children.length === 0
|
|
577
|
+
? <S.div set:html={block.innerHtml} />
|
|
578
|
+
: (
|
|
579
|
+
<Astro.self descriptorIndex={descriptors}
|
|
580
|
+
blocks={children}
|
|
581
|
+
contract={contract}
|
|
582
|
+
blockRenderers={blockRenderers}
|
|
583
|
+
iconRenderer={IconRenderer}
|
|
584
|
+
{...nestedRendererProps(block.name)}
|
|
585
|
+
/>
|
|
586
|
+
);
|
|
587
|
+
return name === "section" ? (
|
|
588
|
+
<S.section {...semantic} {...htmlAttributes}>{fallbackContent}</S.section>
|
|
589
|
+
) : (
|
|
590
|
+
<S.div {...semantic} {...htmlAttributes}>{fallbackContent}</S.div>
|
|
436
591
|
);
|
|
437
592
|
})}
|
|
593
|
+
|
|
594
|
+
<script>
|
|
595
|
+
import "./native/grid-bleed.js";
|
|
596
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { styleflowThemeBootstrapScript } from "../theme-runtime.js";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
themes: string[];
|
|
6
|
+
defaultTheme: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { themes, defaultTheme } = Astro.props;
|
|
10
|
+
const bootstrap = styleflowThemeBootstrapScript(themes, defaultTheme);
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<script is:inline set:html={bootstrap}></script>
|
|
14
|
+
<script>
|
|
15
|
+
import { initializeStyleflowThemeRuntime } from "../theme-runtime.js";
|
|
16
|
+
|
|
17
|
+
const initialize = () => initializeStyleflowThemeRuntime();
|
|
18
|
+
if (document.readyState === "loading") {
|
|
19
|
+
document.addEventListener("DOMContentLoaded", initialize, { once: true });
|
|
20
|
+
} else {
|
|
21
|
+
initialize();
|
|
22
|
+
}
|
|
23
|
+
document.addEventListener("astro:page-load", initialize);
|
|
24
|
+
</script>
|
|
@@ -8,9 +8,9 @@ import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
block: FlowpressBlock;
|
|
11
|
-
contract?: StyleflowContract;
|
|
11
|
+
contract?: StyleflowContract | undefined;
|
|
12
12
|
validChildren: boolean;
|
|
13
|
-
invalidChildNames?: string[];
|
|
13
|
+
invalidChildNames?: string[] | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const { block, contract, validChildren, invalidChildNames = [] } = Astro.props;
|
|
@@ -44,8 +44,7 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
44
44
|
|
|
45
45
|
{validChildren ? (
|
|
46
46
|
<flowpress-carousel>
|
|
47
|
-
<S
|
|
48
|
-
as="section"
|
|
47
|
+
<S.section
|
|
49
48
|
{...semantic}
|
|
50
49
|
{...htmlAttributes}
|
|
51
50
|
aria-label={settings.ariaLabel}
|
|
@@ -79,11 +78,10 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
79
78
|
<span class="splide__toggle__pause">Pausa</span>
|
|
80
79
|
</button>
|
|
81
80
|
) : null}
|
|
82
|
-
</S>
|
|
81
|
+
</S.section>
|
|
83
82
|
</flowpress-carousel>
|
|
84
83
|
) : (
|
|
85
|
-
<S
|
|
86
|
-
as="section"
|
|
84
|
+
<S.section
|
|
87
85
|
{...semantic}
|
|
88
86
|
{...htmlAttributes}
|
|
89
87
|
aria-label={settings.ariaLabel}
|
|
@@ -92,7 +90,7 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
92
90
|
style={style}
|
|
93
91
|
>
|
|
94
92
|
<slot />
|
|
95
|
-
</S>
|
|
93
|
+
</S.section>
|
|
96
94
|
)}
|
|
97
95
|
|
|
98
96
|
<script>
|
|
@@ -101,7 +99,7 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
101
99
|
|
|
102
100
|
if (!customElements.get("flowpress-carousel")) {
|
|
103
101
|
customElements.define("flowpress-carousel", class extends HTMLElement {
|
|
104
|
-
private instance?: Splide;
|
|
102
|
+
private instance?: Splide | undefined;
|
|
105
103
|
|
|
106
104
|
connectedCallback() {
|
|
107
105
|
if (this.instance) return;
|
|
@@ -6,7 +6,7 @@ import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
block: FlowpressBlock;
|
|
9
|
-
contract?: StyleflowContract;
|
|
9
|
+
contract?: StyleflowContract | undefined;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const { block, contract } = Astro.props;
|
|
@@ -17,9 +17,9 @@ const htmlAttributes = blockHtmlAttributes(
|
|
|
17
17
|
);
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
<S
|
|
20
|
+
<S.li {...semantic} {...htmlAttributes}>
|
|
21
21
|
<slot />
|
|
22
|
-
</S>
|
|
22
|
+
</S.li>
|
|
23
23
|
|
|
24
24
|
<style>
|
|
25
25
|
.flowpress-carousel-item { min-width: 0; }
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
block: FlowpressBlock;
|
|
13
|
-
contract?: StyleflowContract;
|
|
13
|
+
contract?: StyleflowContract | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const { block, contract } = Astro.props;
|
|
@@ -33,8 +33,7 @@ const style = [
|
|
|
33
33
|
].join(";");
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
-
<S
|
|
37
|
-
as="div"
|
|
36
|
+
<S.div
|
|
38
37
|
{...semantic}
|
|
39
38
|
{...htmlAttributes}
|
|
40
39
|
data-partial={partial}
|
|
@@ -42,7 +41,7 @@ const style = [
|
|
|
42
41
|
style={style}
|
|
43
42
|
>
|
|
44
43
|
<slot />
|
|
45
|
-
</S>
|
|
44
|
+
</S.div>
|
|
46
45
|
|
|
47
46
|
<style>
|
|
48
47
|
.flowpress-column {
|