@styleflow.app/flowpress-astro-core 1.0.0-beta.15 → 1.0.0-beta.17
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 +16 -0
- package/README.md +19 -1
- package/dist/astro/BaseLayout.astro +6 -6
- package/dist/astro/CompositionRenderer.astro +23 -7
- package/dist/astro/GutenbergRenderer.astro +33 -20
- package/dist/astro/blocks/CarouselBlock.astro +3 -3
- package/dist/astro/blocks/CarouselItemBlock.astro +1 -1
- package/dist/astro/blocks/ColumnBlock.astro +1 -1
- package/dist/astro/blocks/CoverBlock.astro +3 -3
- package/dist/astro/blocks/FormBlock.astro +13 -11
- package/dist/astro/blocks/GridBlock.astro +1 -1
- package/dist/astro/blocks/HeroBlock.astro +1 -1
- package/dist/astro/blocks/ImageBlock.astro +1 -1
- package/dist/astro/blocks/NumberSpinnerBlock.astro +1 -1
- package/dist/astro/blocks/SemanticElement.astro +2 -2
- package/dist/astro/blocks/SiteLogoBlock.astro +4 -4
- package/dist/astro/blocks/TextBlock.astro +2 -2
- package/dist/astro/blocks/cover.d.ts +2 -1
- package/dist/astro/blocks/cover.d.ts.map +1 -1
- package/dist/astro/blocks/cover.js.map +1 -1
- package/dist/astro/blocks/cover.ts +3 -2
- 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 +3 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/default-blocks.d.ts +1 -1
- package/dist/default-blocks.d.ts.map +1 -1
- package/dist/default-blocks.js +36 -2
- package/dist/default-blocks.js.map +1 -1
- package/dist/media.d.ts +13 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +72 -12
- package/dist/media.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.17 — 2026-10-07
|
|
4
|
+
|
|
5
|
+
- Official native and sf/* renderers at every nesting depth; responsive grids and measured container bleed, maps, neutral organic shapes, timeline and accessible navigation.
|
|
6
|
+
- Canonical behavior, migration and verification: [pilot integration](https://github.com/StyleFlow-App/styleflow-docs/blob/main/wiki/piloti-flowpress.md), [report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-07-integrazione-piloti-flowpress.md).
|
|
7
|
+
|
|
3
8
|
## Unreleased
|
|
4
9
|
|
|
10
|
+
## 1.0.0-beta.16
|
|
11
|
+
|
|
12
|
+
- Rebase owned composition media to the current frontend, including nested
|
|
13
|
+
query data, authoring attributes and responsive sources. WordPress uploads
|
|
14
|
+
keep `/app/uploads/`; offloaded assets keep `/media/`. External media and
|
|
15
|
+
raw HTML remain unchanged.
|
|
16
|
+
- Export `rewriteFlowpressMediaUrl`, `rewriteFlowpressMediaUrls` and explicit
|
|
17
|
+
frontend/backend/offload origin options for project integrations.
|
|
18
|
+
- Follow storage redirects server-side with a bounded redirect count. Proxy
|
|
19
|
+
responses no longer expose backend/CDN `Location` headers to the browser.
|
|
20
|
+
|
|
5
21
|
## 1.0.0-beta.15
|
|
6
22
|
|
|
7
23
|
- Fixed `proxyFlowpressMedia` forwarding the `/media/` route prefix to the
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The package must not import from an application or project plugin.
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.
|
|
12
|
+
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.16 \
|
|
13
13
|
@styleflow.app/astro@1.0.0-beta.6
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -96,6 +96,22 @@ renderer and passes them as `styleflowProps`. Project adapters can therefore
|
|
|
96
96
|
apply the authored semantic context to their real root without accepting raw
|
|
97
97
|
WordPress visual values.
|
|
98
98
|
|
|
99
|
+
At the composition root, owned media URLs are rebased to the current request
|
|
100
|
+
origin using explicit `BACKEND_URL`, `FLOWPRESS_MEDIA`, `SITE_URL` and the
|
|
101
|
+
composition's canonical frontend origin. This also covers nested query items
|
|
102
|
+
and responsive `srcSet` data passed to project adapters. WordPress uploads
|
|
103
|
+
remain under `/app/uploads/` and offloaded files under `/media/`; third-party
|
|
104
|
+
assets and raw HTML/CSS/scripts are preserved. A `media` prop of type
|
|
105
|
+
`FlowpressFrontendMediaOptions` can supply explicit origins. Projects can
|
|
106
|
+
also use exported `rewriteFlowpressMediaUrl` / `rewriteFlowpressMediaUrls`
|
|
107
|
+
for data rendered outside a composition. These functions do not mutate the
|
|
108
|
+
CMS payload.
|
|
109
|
+
|
|
110
|
+
The upload and media proxies follow HTTP(S) storage redirects on the server
|
|
111
|
+
(at most five), forwarding only safe request headers and preserving range,
|
|
112
|
+
validator and cache semantics. They never return an upstream `Location` or
|
|
113
|
+
`Set-Cookie` header: the browser stays on the public frontend URL.
|
|
114
|
+
|
|
99
115
|
Every adapter also receives required normalized `htmlProps` (`anchor` → `id`
|
|
100
116
|
and the additional classes), the full composition and a deterministic render
|
|
101
117
|
context. The public HTML allowlist also preserves `title`, `role`, `lang`,
|
|
@@ -252,3 +268,5 @@ Promote to `latest` only after the DMO canary and rollback gate.
|
|
|
252
268
|
|
|
253
269
|
Release activity reports are indexed in
|
|
254
270
|
[`docs/activities/README.md`](docs/activities/README.md).
|
|
271
|
+
|
|
272
|
+
Pilot integration in `1.0.0-beta.17`: Canonical behavior, migration and verification: [pilot integration](https://github.com/StyleFlow-App/styleflow-docs/blob/main/wiki/piloti-flowpress.md), [report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-07-integrazione-piloti-flowpress.md).
|
|
@@ -4,11 +4,11 @@ import S from "@styleflow.app/astro/S.astro";
|
|
|
4
4
|
import ThemeRuntime from "./ThemeRuntime.astro";
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
lang?: string;
|
|
8
|
-
seo?: SfSeo | null;
|
|
9
|
-
siteName?: string;
|
|
10
|
-
theme?: string;
|
|
11
|
-
themes?: string[];
|
|
7
|
+
lang?: string | undefined;
|
|
8
|
+
seo?: SfSeo | null | undefined;
|
|
9
|
+
siteName?: string | undefined;
|
|
10
|
+
theme?: string | undefined;
|
|
11
|
+
themes?: string[] | undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const {
|
|
@@ -54,7 +54,7 @@ const jsonLd = seo?.jsonLd ? JSON.stringify(seo.jsonLd) : null;
|
|
|
54
54
|
<slot name="head" />
|
|
55
55
|
</head>
|
|
56
56
|
<body>
|
|
57
|
-
<S.main theme
|
|
57
|
+
<S.main {...(theme ? { theme } : {})} surface="default" layoutRole="none" density="regular">
|
|
58
58
|
<slot />
|
|
59
59
|
</S.main>
|
|
60
60
|
</body>
|
|
@@ -11,27 +11,43 @@ import {
|
|
|
11
11
|
type StyleflowContract
|
|
12
12
|
} from "../styleflow.js";
|
|
13
13
|
import type { FlowpressBlock, FlowpressCompositionV1 } from "../types.js";
|
|
14
|
+
import { rewriteFlowpressMediaUrls, type FlowpressFrontendMediaOptions } from "../media.js";
|
|
14
15
|
|
|
15
16
|
interface Props {
|
|
16
17
|
composition: FlowpressCompositionV1;
|
|
17
18
|
adapters: FlowpressBlockAdapters;
|
|
18
|
-
blocks?: FlowpressBlock[];
|
|
19
|
-
contract?: StyleflowContract;
|
|
20
|
-
parentBlockName?: string;
|
|
21
|
-
production?: boolean;
|
|
22
|
-
depth?: number;
|
|
19
|
+
blocks?: FlowpressBlock[] | undefined;
|
|
20
|
+
contract?: StyleflowContract | undefined;
|
|
21
|
+
parentBlockName?: string | undefined;
|
|
22
|
+
production?: boolean | undefined;
|
|
23
|
+
depth?: number | undefined;
|
|
24
|
+
media?: FlowpressFrontendMediaOptions | undefined;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const {
|
|
26
|
-
composition,
|
|
28
|
+
composition: sourceComposition,
|
|
27
29
|
adapters,
|
|
28
|
-
blocks
|
|
30
|
+
blocks: sourceBlocks,
|
|
29
31
|
contract,
|
|
30
32
|
parentBlockName,
|
|
31
33
|
production = import.meta.env.PROD,
|
|
32
34
|
depth = 0
|
|
33
35
|
} = Astro.props;
|
|
34
36
|
|
|
37
|
+
const mediaOptions: FlowpressFrontendMediaOptions = Astro.props.media ?? {
|
|
38
|
+
frontendOrigin: Astro.url.origin,
|
|
39
|
+
backendUrl: import.meta.env.BACKEND_URL,
|
|
40
|
+
mediaUrl: import.meta.env.FLOWPRESS_MEDIA,
|
|
41
|
+
frontendUrls: [import.meta.env.SITE_URL, sourceComposition.route.seo?.canonicalUrl]
|
|
42
|
+
.filter((url): url is string => typeof url === "string" && Boolean(url))
|
|
43
|
+
};
|
|
44
|
+
const composition = depth === 0
|
|
45
|
+
? rewriteFlowpressMediaUrls(sourceComposition, mediaOptions)
|
|
46
|
+
: sourceComposition;
|
|
47
|
+
const blocks = sourceBlocks
|
|
48
|
+
? depth === 0 ? rewriteFlowpressMediaUrls(sourceBlocks, mediaOptions) : sourceBlocks
|
|
49
|
+
: composition.blocks;
|
|
50
|
+
|
|
35
51
|
const blocking = composition.diagnostics.filter((diagnostic) => diagnostic.blocking);
|
|
36
52
|
if (blocking.length > 0 && production) {
|
|
37
53
|
throw new Error(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import "./native/grid.css";
|
|
2
3
|
import S from "@styleflow.app/astro/S.astro";
|
|
3
4
|
import type {
|
|
4
5
|
FlowpressBlockAdapters,
|
|
@@ -37,22 +38,22 @@ import {
|
|
|
37
38
|
|
|
38
39
|
interface Props {
|
|
39
40
|
blocks: FlowpressBlock[];
|
|
40
|
-
contract?: StyleflowContract;
|
|
41
|
-
blockRenderers?: FlowpressBlockRenderers;
|
|
42
|
-
iconRenderer?: FlowpressIconRenderer;
|
|
43
|
-
rootHtmlProps?: FlowpressBlockHtmlProps;
|
|
44
|
-
rootStyleflowProps?: DynamicStyleflowProps;
|
|
45
|
-
adapterDefinitions?: FlowpressBlockAdapters;
|
|
46
|
-
composition?: FlowpressCompositionV1;
|
|
47
|
-
parentBlockName?: string;
|
|
48
|
-
production?: boolean;
|
|
49
|
-
depth?: number;
|
|
50
|
-
skipCustomRendererFor?: string;
|
|
51
|
-
requireRegisteredAdapters?: boolean;
|
|
41
|
+
contract?: StyleflowContract | undefined;
|
|
42
|
+
blockRenderers?: FlowpressBlockRenderers | undefined;
|
|
43
|
+
iconRenderer?: FlowpressIconRenderer | undefined;
|
|
44
|
+
rootHtmlProps?: FlowpressBlockHtmlProps | undefined;
|
|
45
|
+
rootStyleflowProps?: DynamicStyleflowProps | undefined;
|
|
46
|
+
adapterDefinitions?: FlowpressBlockAdapters | undefined;
|
|
47
|
+
composition?: FlowpressCompositionV1 | undefined;
|
|
48
|
+
parentBlockName?: string | undefined;
|
|
49
|
+
production?: boolean | undefined;
|
|
50
|
+
depth?: number | undefined;
|
|
51
|
+
skipCustomRendererFor?: string | undefined;
|
|
52
|
+
requireRegisteredAdapters?: boolean | undefined;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const {
|
|
55
|
-
blocks,
|
|
56
|
+
blocks: rawBlocks,
|
|
56
57
|
contract,
|
|
57
58
|
blockRenderers = {},
|
|
58
59
|
iconRenderer: IconRenderer,
|
|
@@ -66,8 +67,16 @@ const {
|
|
|
66
67
|
skipCustomRendererFor,
|
|
67
68
|
requireRegisteredAdapters = false
|
|
68
69
|
} = Astro.props;
|
|
70
|
+
const { decorateGridBlocks } = await import("./native/grid.js");
|
|
71
|
+
const blocks = decorateGridBlocks(rawBlocks);
|
|
72
|
+
const { nativeBlockRenderers } = await import("./native/registry.js");
|
|
73
|
+
const effectiveRenderers = { ...nativeBlockRenderers, ...blockRenderers };
|
|
69
74
|
const descriptors = composition ? flowpressBlockTypeDescriptors(composition) : undefined;
|
|
70
75
|
|
|
76
|
+
function objectCollection(value: unknown): Record<string, unknown>[] {
|
|
77
|
+
return Array.isArray(value) ? value.filter((item): item is Record<string, unknown> => !!item && typeof item === "object") : [];
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
function youtubeEmbedUrl(value: unknown): string | null {
|
|
72
81
|
try {
|
|
73
82
|
const url = new URL(String(value ?? ""));
|
|
@@ -99,16 +108,16 @@ function nestedRendererProps(nextParentBlockName: string) {
|
|
|
99
108
|
|
|
100
109
|
{blocks.map((block, index) => {
|
|
101
110
|
const name = block.name.replace(/^sf\//, "");
|
|
102
|
-
const children = block.innerBlocks ?? [];
|
|
111
|
+
const children = decorateGridBlocks(block.innerBlocks ?? []);
|
|
103
112
|
const semantic = index === 0 && blocks.length === 1 && rootStyleflowProps
|
|
104
113
|
? rootStyleflowProps
|
|
105
114
|
: semanticProps(block.attributes, contract);
|
|
106
115
|
const htmlAttributes = index === 0 && blocks.length === 1 && rootHtmlProps
|
|
107
|
-
? rootHtmlProps
|
|
116
|
+
? { ...rootHtmlProps, class: Array.from(new Set([rootHtmlProps.class, block.attributes.className].filter(Boolean).join(" ").split(/\s+/))).join(" ") }
|
|
108
117
|
: blockHtmlAttributes(block.attributes);
|
|
109
118
|
const CustomBlockRenderer = block.name === skipCustomRendererFor
|
|
110
|
-
?
|
|
111
|
-
:
|
|
119
|
+
? nativeBlockRenderers[block.name as keyof typeof nativeBlockRenderers]
|
|
120
|
+
: effectiveRenderers[block.name as keyof typeof effectiveRenderers];
|
|
112
121
|
const compatibilityIssue = descriptors && adapterDefinitions
|
|
113
122
|
? flowpressAdapterCompatibilityIssue(block.name, descriptors, adapterDefinitions)
|
|
114
123
|
: null;
|
|
@@ -120,7 +129,7 @@ function nestedRendererProps(nextParentBlockName: string) {
|
|
|
120
129
|
if (
|
|
121
130
|
requireRegisteredAdapters
|
|
122
131
|
&& block.name !== skipCustomRendererFor
|
|
123
|
-
&& !CustomBlockRenderer
|
|
132
|
+
&& (!adapterDefinitions?.[block.name] || !CustomBlockRenderer)
|
|
124
133
|
) {
|
|
125
134
|
const message = compatibilityIssue?.message
|
|
126
135
|
?? `Missing FlowPress block adapter for "${block.name}".`;
|
|
@@ -381,7 +390,7 @@ function nestedRendererProps(nextParentBlockName: string) {
|
|
|
381
390
|
|
|
382
391
|
if (name === "gallery") {
|
|
383
392
|
const images = Array.isArray(block.attributes.images)
|
|
384
|
-
? block.attributes.images
|
|
393
|
+
? objectCollection(block.attributes.images)
|
|
385
394
|
: [];
|
|
386
395
|
return (
|
|
387
396
|
<S.div {...semantic} {...htmlAttributes}>
|
|
@@ -454,7 +463,7 @@ function nestedRendererProps(nextParentBlockName: string) {
|
|
|
454
463
|
|
|
455
464
|
if (name === "content-list" || name === "term-list") {
|
|
456
465
|
const items = Array.isArray(block.attributes.resolvedItems)
|
|
457
|
-
? block.attributes.resolvedItems
|
|
466
|
+
? objectCollection(block.attributes.resolvedItems)
|
|
458
467
|
: [];
|
|
459
468
|
const resolvedBlocks = Array.isArray(block.attributes.resolvedBlocks)
|
|
460
469
|
? block.attributes.resolvedBlocks as FlowpressBlock[][]
|
|
@@ -579,3 +588,7 @@ function nestedRendererProps(nextParentBlockName: string) {
|
|
|
579
588
|
<S.div {...semantic} {...htmlAttributes}>{fallbackContent}</S.div>
|
|
580
589
|
);
|
|
581
590
|
})}
|
|
591
|
+
|
|
592
|
+
<script>
|
|
593
|
+
import "./native/grid-bleed.js";
|
|
594
|
+
</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;
|
|
@@ -99,7 +99,7 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
99
99
|
|
|
100
100
|
if (!customElements.get("flowpress-carousel")) {
|
|
101
101
|
customElements.define("flowpress-carousel", class extends HTMLElement {
|
|
102
|
-
private instance?: Splide;
|
|
102
|
+
private instance?: Splide | undefined;
|
|
103
103
|
|
|
104
104
|
connectedCallback() {
|
|
105
105
|
if (this.instance) return;
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
|
|
22
22
|
interface Props {
|
|
23
23
|
block: FlowpressBlock;
|
|
24
|
-
contract?: StyleflowContract;
|
|
25
|
-
htmlProps?: FlowpressBlockHtmlProps;
|
|
26
|
-
styleflowProps?: DynamicStyleflowProps;
|
|
24
|
+
contract?: StyleflowContract | undefined;
|
|
25
|
+
htmlProps?: FlowpressBlockHtmlProps | undefined;
|
|
26
|
+
styleflowProps?: DynamicStyleflowProps | undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const { block, contract, htmlProps, styleflowProps } = Astro.props;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
type HTMLInputTypeAttribute = HTMLAttributes<"input">["type"];
|
|
2
4
|
import S from "@styleflow.app/astro/S.astro";
|
|
3
5
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
6
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
@@ -7,10 +9,10 @@ import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
|
7
9
|
interface FormField {
|
|
8
10
|
name: string;
|
|
9
11
|
type: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
values?: string[];
|
|
12
|
-
labels?: string[];
|
|
13
|
-
options?: string[];
|
|
12
|
+
required?: boolean | undefined;
|
|
13
|
+
values?: string[] | undefined;
|
|
14
|
+
labels?: string[] | undefined;
|
|
15
|
+
options?: string[] | undefined;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
interface FormSchema {
|
|
@@ -24,7 +26,7 @@ interface FormSchema {
|
|
|
24
26
|
|
|
25
27
|
interface Props {
|
|
26
28
|
block: FlowpressBlock;
|
|
27
|
-
contract?: StyleflowContract;
|
|
29
|
+
contract?: StyleflowContract | undefined;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
const { block, contract } = Astro.props;
|
|
@@ -63,7 +65,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
63
65
|
{(field.values || []).map((value, index) => (
|
|
64
66
|
<label>
|
|
65
67
|
<input
|
|
66
|
-
type={field.type}
|
|
68
|
+
type={field.type as HTMLInputTypeAttribute}
|
|
67
69
|
name={field.type === "checkbox" ? `${field.name}[]` : field.name}
|
|
68
70
|
value={value}
|
|
69
71
|
required={field.required}
|
|
@@ -114,7 +116,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
114
116
|
<label>
|
|
115
117
|
{labelFor(field)}
|
|
116
118
|
<input
|
|
117
|
-
type={field.type === "file" ? "file" : field.type}
|
|
119
|
+
type={field.type === "file" ? "file" : field.type as HTMLInputTypeAttribute}
|
|
118
120
|
name={field.name}
|
|
119
121
|
required={field.required}
|
|
120
122
|
/>
|
|
@@ -142,7 +144,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
142
144
|
interface Window {
|
|
143
145
|
turnstile?: {
|
|
144
146
|
render(target: Element, options: Record<string, unknown>): string;
|
|
145
|
-
reset(widgetId?: string): void;
|
|
147
|
+
reset(widgetId?: string): void | undefined;
|
|
146
148
|
};
|
|
147
149
|
}
|
|
148
150
|
}
|
|
@@ -174,7 +176,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
174
176
|
|
|
175
177
|
if (!customElements.get("flowpress-cf7-form")) {
|
|
176
178
|
customElements.define("flowpress-cf7-form", class extends HTMLElement {
|
|
177
|
-
private widgetId?: string;
|
|
179
|
+
private widgetId?: string | undefined;
|
|
178
180
|
|
|
179
181
|
connectedCallback() {
|
|
180
182
|
const form = this.querySelector<HTMLFormElement>("form");
|
|
@@ -207,8 +209,8 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
207
209
|
headers: { Accept: "application/json" }
|
|
208
210
|
});
|
|
209
211
|
const result = await response.json() as {
|
|
210
|
-
message?: string;
|
|
211
|
-
invalidFields?: Array<{ field?: string; into?: string; message?: string }
|
|
212
|
+
message?: string | undefined;
|
|
213
|
+
invalidFields?: Array<{ field?: string | undefined; into?: string | undefined; message?: string }> | undefined;
|
|
212
214
|
};
|
|
213
215
|
status.textContent = result.message || (response.ok ? "Messaggio inviato." : "Invio non riuscito.");
|
|
214
216
|
for (const invalid of result.invalidFields || []) {
|
|
@@ -8,8 +8,8 @@ type SemanticElementTag =
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
tag: SemanticElementTag;
|
|
11
|
-
attributes?: Record<string, unknown
|
|
12
|
-
html?: string;
|
|
11
|
+
attributes?: Record<string, unknown> | undefined;
|
|
12
|
+
html?: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const { tag, attributes = {}, html } = Astro.props;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import S from "@styleflow.app/astro/S.astro";
|
|
3
3
|
import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
|
|
4
4
|
|
|
5
|
-
type LogoImage = { url?: string; width?: number; height?: number; alt?: string };
|
|
5
|
+
type LogoImage = { url?: string | undefined; width?: number | undefined; height?: number | undefined; alt?: string } | undefined;
|
|
6
6
|
type LogoData = {
|
|
7
|
-
images?: { positive?: LogoImage; negative?: LogoImage };
|
|
8
|
-
homeUrl?: string;
|
|
9
|
-
override?: "auto" | "positive" | "negative";
|
|
7
|
+
images?: { positive?: LogoImage | undefined; negative?: LogoImage } | undefined;
|
|
8
|
+
homeUrl?: string | undefined;
|
|
9
|
+
override?: "auto" | "positive" | "negative" | undefined;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
|
|
@@ -16,8 +16,8 @@ import SemanticElement from "./SemanticElement.astro";
|
|
|
16
16
|
|
|
17
17
|
interface Props {
|
|
18
18
|
block: FlowpressBlock;
|
|
19
|
-
contract?: StyleflowContract;
|
|
20
|
-
hasChildren?: boolean;
|
|
19
|
+
contract?: StyleflowContract | undefined;
|
|
20
|
+
hasChildren?: boolean | undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const { block, contract, hasChildren = false } = Astro.props;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FlowpressBlock } from "../../types.js";
|
|
2
2
|
export type CoverBackgroundType = "color" | "image" | "video";
|
|
3
|
-
export
|
|
3
|
+
export type CoverTagName = "article" | "aside" | "div" | "footer" | "header" | "main" | "section";
|
|
4
|
+
export declare function coverTagName(value: unknown): CoverTagName;
|
|
4
5
|
export declare function coverMediaSource(block: FlowpressBlock): string;
|
|
5
6
|
export declare function coverPosterSource(block: FlowpressBlock): string | undefined;
|
|
6
7
|
export declare function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cover.d.ts","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAwC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"cover.d.ts","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings":"AAAA,OAA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AE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAmC;IACnE,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACnE,IAAI,eAAe,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC;IAE1D,OAAO,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;AACvD,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../types.js\";\n\nexport type CoverBackgroundType = \"color\" | \"image\" | \"video\";\n\nconst COVER_TAGS = new Set([\n \"article\",\n \"aside\",\n \"div\",\n \"footer\",\n \"header\",\n \"main\",\n \"section\"\n]);\n\nconst HEIGHT_UNITS = new Set([\n \"px\",\n \"%\",\n \"em\",\n \"rem\",\n \"vh\",\n \"svh\",\n \"lvh\",\n \"dvh\",\n \"vw\"\n]);\n\nconst CONTENT_POSITIONS: Record<string, [string, string]> = {\n \"top left\": [\"start\", \"start\"],\n \"top center\": [\"start\", \"center\"],\n \"top right\": [\"start\", \"end\"],\n \"center left\": [\"center\", \"start\"],\n \"center center\": [\"center\", \"center\"],\n \"center right\": [\"center\", \"end\"],\n \"bottom left\": [\"end\", \"start\"],\n \"bottom center\": [\"end\", \"center\"],\n \"bottom right\": [\"end\", \"end\"]\n};\n\nfunction text(value: unknown): string {\n return typeof value === \"string\" ? value.trim() : \"\";\n}\n\nexport type CoverTagName = \"article\" | \"aside\" | \"div\" | \"footer\" | \"header\" | \"main\" | \"section\";\nexport function coverTagName(value: unknown): CoverTagName {\n const candidate = text(value).toLowerCase();\n return COVER_TAGS.has(candidate) ? candidate as CoverTagName : \"div\";\n}\n\nexport function coverMediaSource(block: FlowpressBlock): string {\n return text(block.attributes.url) || text(block.resolvedData?.url);\n}\n\nexport function coverPosterSource(block: FlowpressBlock): string | undefined {\n return text(block.attributes.poster)\n || text(block.resolvedData?.poster)\n || undefined;\n}\n\nexport function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType {\n const requested = text(block.attributes.backgroundType).toLowerCase();\n if (requested === \"video\") return \"video\";\n if (requested === \"color\") return \"color\";\n return coverMediaSource(block) ? \"image\" : \"color\";\n}\n\nfunction percentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n if (numeric >= 0 && numeric <= 1) return numeric * 100;\n if (numeric >= 0 && numeric <= 100) return numeric;\n return undefined;\n}\n\nexport function coverObjectPosition(value: unknown): string {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"50% 50%\";\n }\n const focalPoint = value as Record<string, unknown>;\n const x = percentage(focalPoint.x);\n const y = percentage(focalPoint.y);\n return x === undefined || y === undefined ? \"50% 50%\" : `${x}% ${y}%`;\n}\n\nexport function coverMinimumHeight(\n value: unknown,\n unitValue: unknown\n): string | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric) || numeric < 0) return undefined;\n const requestedUnit = text(unitValue).toLowerCase();\n const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : \"px\";\n return `${numeric}${unit}`;\n}\n\nexport function coverContentPosition(value: unknown): [string, string] {\n return CONTENT_POSITIONS[text(value).toLowerCase()]\n ?? [\"center\", \"center\"];\n}\n\nexport function coverScrimEnabled(attributes: Record<string, unknown>): boolean {\n if (typeof attributes.scrimEnabled === \"boolean\") {\n return attributes.scrimEnabled;\n }\n const nativeDimRatio = Number(attributes.dimRatio);\n return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;\n}\n\nfunction clampedPercentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n return Math.min(100, Math.max(0, numeric));\n}\n\nexport function coverScrimOpacity(attributes: Record<string, unknown>): number {\n const explicitOpacity = clampedPercentage(attributes.scrimOpacity);\n if (explicitOpacity !== undefined) return explicitOpacity;\n\n return clampedPercentage(attributes.dimRatio) ?? 100;\n}\n"]}
|
|
@@ -40,9 +40,10 @@ function text(value: unknown): string {
|
|
|
40
40
|
return typeof value === "string" ? value.trim() : "";
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export
|
|
43
|
+
export type CoverTagName = "article" | "aside" | "div" | "footer" | "header" | "main" | "section";
|
|
44
|
+
export function coverTagName(value: unknown): CoverTagName {
|
|
44
45
|
const candidate = text(value).toLowerCase();
|
|
45
|
-
return COVER_TAGS.has(candidate) ? candidate : "div";
|
|
46
|
+
return COVER_TAGS.has(candidate) ? candidate as CoverTagName : "div";
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export function coverMediaSource(block: FlowpressBlock): string {
|