@styleflow.app/flowpress-astro-core 1.0.0-beta.16 → 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 +5 -0
- package/README.md +2 -0
- package/dist/astro/BaseLayout.astro +6 -6
- package/dist/astro/CompositionRenderer.astro +6 -6
- 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/templates.d.ts +16 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
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
|
|
|
5
10
|
## 1.0.0-beta.16
|
package/README.md
CHANGED
|
@@ -268,3 +268,5 @@ Promote to `latest` only after the DMO canary and rollback gate.
|
|
|
268
268
|
|
|
269
269
|
Release activity reports are indexed in
|
|
270
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>
|
|
@@ -16,12 +16,12 @@ import { rewriteFlowpressMediaUrls, type FlowpressFrontendMediaOptions } from ".
|
|
|
16
16
|
interface Props {
|
|
17
17
|
composition: FlowpressCompositionV1;
|
|
18
18
|
adapters: FlowpressBlockAdapters;
|
|
19
|
-
blocks?: FlowpressBlock[];
|
|
20
|
-
contract?: StyleflowContract;
|
|
21
|
-
parentBlockName?: string;
|
|
22
|
-
production?: boolean;
|
|
23
|
-
depth?: number;
|
|
24
|
-
media?: FlowpressFrontendMediaOptions;
|
|
19
|
+
blocks?: FlowpressBlock[] | undefined;
|
|
20
|
+
contract?: StyleflowContract | undefined;
|
|
21
|
+
parentBlockName?: string | undefined;
|
|
22
|
+
production?: boolean | undefined;
|
|
23
|
+
depth?: number | undefined;
|
|
24
|
+
media?: FlowpressFrontendMediaOptions | undefined;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const {
|
|
@@ -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,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAwC9D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG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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 {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "./blob.css";
|
|
3
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
4
|
+
import { BLOB_BOX, BLOB_VARIANTS } from "./blob/blob-shapes.generated.js";
|
|
5
|
+
import {
|
|
6
|
+
morphDataAttributes,
|
|
7
|
+
resolveAspectRatio,
|
|
8
|
+
resolveContentFit,
|
|
9
|
+
resolveMorphConfig,
|
|
10
|
+
resolveOutlineWidth,
|
|
11
|
+
type BlobAspectRatio,
|
|
12
|
+
type BlobContentFit,
|
|
13
|
+
type BlobMorphMode,
|
|
14
|
+
} from "./blob/config.js";
|
|
15
|
+
import { shapeToPath } from "./blob/geometry.js";
|
|
16
|
+
import { nextBlobClipId } from "./blob/ids.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Organic mask that crops its slot. The fill takes the Styleflow props passed
|
|
20
|
+
* to the component (tone, intensity, surface, layoutRole, density, no*); the
|
|
21
|
+
* outline has its own tone/intensity. Variants 1-13 can morph into each other.
|
|
22
|
+
*/
|
|
23
|
+
interface Props {
|
|
24
|
+
/** 1-13. */
|
|
25
|
+
variant?: number | string | undefined;
|
|
26
|
+
/** `cover` stretches children over the whole shape, `center` keeps their size. */
|
|
27
|
+
contentFit?: BlobContentFit | undefined;
|
|
28
|
+
aspectRatio?: BlobAspectRatio | undefined;
|
|
29
|
+
/** Outline thickness in px; 0 hides it. */
|
|
30
|
+
outlineWidth?: number | string | undefined;
|
|
31
|
+
outlineTone?: string | undefined;
|
|
32
|
+
outlineIntensity?: string | undefined;
|
|
33
|
+
morph?: BlobMorphMode | undefined;
|
|
34
|
+
/** Variants to morph between, e.g. "2,5,9" or [2, 5, 9]; empty means all. */
|
|
35
|
+
morphTargets?: string | number[] | undefined;
|
|
36
|
+
morphDuration?: number | string | undefined;
|
|
37
|
+
/** Pause in ms between two automatic morphs. */
|
|
38
|
+
morphInterval?: number | string | undefined;
|
|
39
|
+
/** Attributes for the root element: id, class, aria-*, data-*. */
|
|
40
|
+
rootProps?: Record<string, unknown> | undefined;
|
|
41
|
+
[styleflowProp: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
variant,
|
|
46
|
+
contentFit,
|
|
47
|
+
aspectRatio,
|
|
48
|
+
outlineWidth,
|
|
49
|
+
outlineTone = "inherit",
|
|
50
|
+
outlineIntensity = "inherit",
|
|
51
|
+
morph,
|
|
52
|
+
morphTargets,
|
|
53
|
+
morphDuration,
|
|
54
|
+
morphInterval,
|
|
55
|
+
rootProps = {},
|
|
56
|
+
...fillProps
|
|
57
|
+
} = Astro.props;
|
|
58
|
+
|
|
59
|
+
const morphConfig = resolveMorphConfig(
|
|
60
|
+
{ variant, morph, targets: morphTargets, duration: morphDuration, interval: morphInterval },
|
|
61
|
+
BLOB_VARIANTS.length,
|
|
62
|
+
);
|
|
63
|
+
const base = BLOB_VARIANTS[morphConfig.base] ?? BLOB_VARIANTS[0]!;
|
|
64
|
+
const fillPath = shapeToPath(base.fill, BLOB_BOX);
|
|
65
|
+
const ringPath = shapeToPath(base.ring, BLOB_BOX);
|
|
66
|
+
const strokeWidth = resolveOutlineWidth(outlineWidth);
|
|
67
|
+
const clipId = nextBlobClipId();
|
|
68
|
+
|
|
69
|
+
// Authors leaving a Styleflow axis on "inherit" send nothing: keep a visible fill.
|
|
70
|
+
const authoredFill = Object.fromEntries(
|
|
71
|
+
Object.entries(fillProps).filter(([, value]) => value !== undefined && value !== null && value !== ""),
|
|
72
|
+
);
|
|
73
|
+
const shapeProps = { surface: "default", layoutRole: "none", ...authoredFill };
|
|
74
|
+
|
|
75
|
+
const { class: rootClassName, ...rootAttributes } = rootProps as Record<string, unknown> & { class?: string };
|
|
76
|
+
const rootClass = ["sf-blob", typeof rootClassName === "string" ? rootClassName : ""]
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join(" ");
|
|
79
|
+
const clipStyle = `clip-path:url(#${clipId})`;
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
<S.div
|
|
83
|
+
{...rootAttributes}
|
|
84
|
+
class={rootClass}
|
|
85
|
+
layoutRole="none"
|
|
86
|
+
data-sf-blob
|
|
87
|
+
{...morphDataAttributes(morphConfig)}
|
|
88
|
+
data-blob-fit={resolveContentFit(contentFit)}
|
|
89
|
+
data-blob-aspect={resolveAspectRatio(aspectRatio)}
|
|
90
|
+
>
|
|
91
|
+
<svg class="sf-blob__defs" width="0" height="0" aria-hidden="true" focusable="false">
|
|
92
|
+
<clipPath id={clipId} clipPathUnits="objectBoundingBox">
|
|
93
|
+
<path data-blob-clip-path d={fillPath}></path>
|
|
94
|
+
</clipPath>
|
|
95
|
+
</svg>
|
|
96
|
+
<!-- styleflow-ignore-next-line rule=sf-inline-style reason="Per-instance reference to the blob's SVG clip path" scope="project" -->
|
|
97
|
+
<S.div class="sf-blob__shape" {...shapeProps} data-blob-shape style={clipStyle}><slot /></S.div>
|
|
98
|
+
{strokeWidth > 0 ? (
|
|
99
|
+
<S.span class="sf-blob__ring" {...(outlineTone !== "inherit" ? {tone:outlineTone} : {})} {...(outlineIntensity !== "inherit" ? {intensity:outlineIntensity} : {})} aria-hidden="true">
|
|
100
|
+
<svg viewBox="0 0 1 1" preserveAspectRatio="none" focusable="false">
|
|
101
|
+
<path data-blob-ring-path d={ringPath} fill="none" stroke-width={strokeWidth} vector-effect="non-scaling-stroke"></path>
|
|
102
|
+
</svg>
|
|
103
|
+
</S.span>
|
|
104
|
+
) : null}
|
|
105
|
+
</S.div>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
// The static shape is complete without JavaScript: load the controller only
|
|
109
|
+
// when a blob on this page actually morphs.
|
|
110
|
+
if (document.querySelector('[data-sf-blob]:not([data-blob-morph="none"])')) {
|
|
111
|
+
void import("./blob/controller.js").then(({ initializeSfBlobs }) => initializeSfBlobs());
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Blob from "./Blob.astro";
|
|
3
|
+
import {
|
|
4
|
+
flowpressBlockHtmlProps,
|
|
5
|
+
resolveFlowpressBlockStyleflowProps,
|
|
6
|
+
resolvePrefixedFlowpressBlockStyleflowProps,
|
|
7
|
+
} from "../../index.js";
|
|
8
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
9
|
+
|
|
10
|
+
// Renders `sf/blob` wherever the semantic renderer meets it: as a top-level
|
|
11
|
+
// composition block and nested inside any other sf/* block. Called from both
|
|
12
|
+
// paths, so it must work with only `block` and `contract` (like CoverBlock).
|
|
13
|
+
type Props = Pick<FlowpressBlockRendererProps, "block"> & Partial<FlowpressBlockRendererProps>;
|
|
14
|
+
const { block, contract, styleflowProps, htmlProps } = Astro.props as Props;
|
|
15
|
+
const attributes = block.attributes;
|
|
16
|
+
const options = {
|
|
17
|
+
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
18
|
+
onDiagnostic: (diagnostic: { code: string; message: string }) =>
|
|
19
|
+
console.warn(`[${diagnostic.code}] ${diagnostic.message}`),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fill: the block's own Styleflow coordinates. Blob keeps a visible default
|
|
23
|
+
// when the author leaves tone/intensity on "inherit".
|
|
24
|
+
const fill = styleflowProps ?? resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);
|
|
25
|
+
// Outline: the same validated contract under the `outline*` attribute prefix.
|
|
26
|
+
const outline = resolvePrefixedFlowpressBlockStyleflowProps(
|
|
27
|
+
attributes,
|
|
28
|
+
"outline",
|
|
29
|
+
contract,
|
|
30
|
+
{},
|
|
31
|
+
options,
|
|
32
|
+
);
|
|
33
|
+
const text = (value: unknown): string | undefined =>
|
|
34
|
+
typeof value === "string" && value !== "" ? value : undefined;
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<Blob
|
|
38
|
+
{...fill}
|
|
39
|
+
variant={text(attributes.variant) ?? (typeof attributes.variant === "number" ? attributes.variant : undefined)}
|
|
40
|
+
contentFit={text(attributes.contentFit) as "cover" | "center" | undefined}
|
|
41
|
+
aspectRatio={text(attributes.aspectRatio) as "natural" | "square" | "portrait" | "landscape" | undefined}
|
|
42
|
+
outlineWidth={attributes.outlineWidth as number | string | undefined}
|
|
43
|
+
outlineTone={text(outline.tone)}
|
|
44
|
+
outlineIntensity={text(outline.intensity)}
|
|
45
|
+
morph={text(attributes.morph) as "none" | "auto" | "hover" | undefined}
|
|
46
|
+
morphTargets={text(attributes.morphTargets)}
|
|
47
|
+
morphDuration={attributes.morphDuration as number | string | undefined}
|
|
48
|
+
morphInterval={attributes.morphInterval as number | string | undefined}
|
|
49
|
+
rootProps={htmlProps ?? flowpressBlockHtmlProps(attributes)}
|
|
50
|
+
>
|
|
51
|
+
<slot />
|
|
52
|
+
</Blob>
|