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