@styleflow.app/flowpress-astro-core 1.0.0-beta.5 → 1.0.0-beta.50
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 +307 -1
- package/README.md +121 -6
- 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 +170 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/EditorialMedia.astro +47 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +270 -84
- package/dist/astro/Media.astro +27 -0
- package/dist/astro/StyleflowElement.astro +25 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +72 -101
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +158 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +5 -4
- package/dist/astro/blocks/HeroBlock.astro +6 -6
- package/dist/astro/blocks/ImageBlock.astro +6 -6
- package/dist/astro/blocks/ListItemFallback.astro +9 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +54 -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 +10 -1
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +55 -39
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +69 -44
- package/dist/astro/motion/AccordionRuntime.astro +9 -0
- package/dist/astro/motion/MotionBoot.astro +21 -0
- package/dist/astro/motion/MotionRuntime.astro +31 -0
- package/dist/astro/motion/accordion.css +163 -0
- package/dist/astro/motion/accordion.d.ts +3 -0
- package/dist/astro/motion/accordion.d.ts.map +1 -0
- package/dist/astro/motion/accordion.js +98 -0
- package/dist/astro/motion/accordion.js.map +1 -0
- package/dist/astro/motion/accordion.ts +109 -0
- package/dist/astro/motion/motion-controller.d.ts +12 -0
- package/dist/astro/motion/motion-controller.d.ts.map +1 -0
- package/dist/astro/motion/motion-controller.js +312 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +393 -0
- package/dist/astro/motion/motion.css +600 -0
- package/dist/astro/motion/motion.d.ts +132 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +265 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +430 -0
- package/dist/astro/native/AccordionRuntime.astro +11 -0
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +88 -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/ReservedLogin.astro +107 -0
- package/dist/astro/native/ResolvedBlocks.astro +91 -0
- package/dist/astro/native/SyncedPatternContent.astro +94 -0
- package/dist/astro/native/TermFieldValue.astro +39 -0
- package/dist/astro/native/Timeline.astro +22 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/accordion-controller.d.ts +3 -0
- package/dist/astro/native/accordion-controller.d.ts.map +1 -0
- package/dist/astro/native/accordion-controller.js +143 -0
- package/dist/astro/native/accordion-controller.js.map +1 -0
- package/dist/astro/native/accordion-controller.ts +108 -0
- package/dist/astro/native/accordion.css +36 -0
- package/dist/astro/native/accordion.d.ts +24 -0
- package/dist/astro/native/accordion.d.ts.map +1 -0
- package/dist/astro/native/accordion.js +82 -0
- package/dist/astro/native/accordion.js.map +1 -0
- package/dist/astro/native/accordion.ts +91 -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/block-sizing.css +34 -0
- package/dist/astro/native/button-template.d.ts +31 -0
- package/dist/astro/native/button-template.d.ts.map +1 -0
- package/dist/astro/native/button-template.js +54 -0
- package/dist/astro/native/button-template.js.map +1 -0
- package/dist/astro/native/button-template.ts +92 -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/carousel.css +323 -0
- package/dist/astro/native/core-accordion-heading.astro +23 -0
- package/dist/astro/native/core-accordion-item.astro +8 -0
- package/dist/astro/native/core-accordion-panel.astro +8 -0
- package/dist/astro/native/core-accordion.astro +8 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button-fallback.astro +43 -0
- package/dist/astro/native/core-button.astro +65 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +25 -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 +136 -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 +101 -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 +40 -0
- package/dist/astro/native/core-post-template-fallback.astro +30 -0
- package/dist/astro/native/core-post-template.astro +23 -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 +18 -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 +18 -0
- package/dist/astro/native/grid-bleed.d.ts +2 -0
- package/dist/astro/native/grid-bleed.d.ts.map +1 -0
- package/dist/astro/native/grid-bleed.js +123 -0
- package/dist/astro/native/grid-bleed.js.map +1 -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 +108 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +132 -0
- package/dist/astro/native/group.css +36 -0
- package/dist/astro/native/group.d.ts +15 -0
- package/dist/astro/native/group.d.ts.map +1 -0
- package/dist/astro/native/group.js +66 -0
- package/dist/astro/native/group.js.map +1 -0
- package/dist/astro/native/group.ts +61 -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/image.d.ts +5 -0
- package/dist/astro/native/image.d.ts.map +1 -0
- package/dist/astro/native/image.js +65 -0
- package/dist/astro/native/image.js.map +1 -0
- package/dist/astro/native/image.ts +56 -0
- package/dist/astro/native/inline-text.css +15 -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-carousel.d.ts +13 -0
- package/dist/astro/native/query-carousel.d.ts.map +1 -0
- package/dist/astro/native/query-carousel.js +36 -0
- package/dist/astro/native/query-carousel.js.map +1 -0
- package/dist/astro/native/query-carousel.ts +60 -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 +91 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +93 -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-slot.astro +6 -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 +105 -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 +23 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +82 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/carousel.d.ts +56 -6
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +183 -27
- package/dist/carousel.js.map +1 -1
- package/dist/client.d.ts +34 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -42
- 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 +125 -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 +122 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +53 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +106 -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/reserved-area.d.ts +10 -0
- package/dist/reserved-area.d.ts.map +1 -0
- package/dist/reserved-area.js +93 -0
- package/dist/reserved-area.js.map +1 -0
- package/dist/styleflow.d.ts +18 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +82 -11
- package/dist/styleflow.js.map +1 -1
- package/dist/svg-media-runtime.d.ts +3 -0
- package/dist/svg-media-runtime.d.ts.map +1 -0
- package/dist/svg-media-runtime.js +33 -0
- package/dist/svg-media-runtime.js.map +1 -0
- package/dist/svg-media-types.d.ts +11 -0
- package/dist/svg-media-types.d.ts.map +1 -0
- package/dist/svg-media-types.js +2 -0
- package/dist/svg-media-types.js.map +1 -0
- package/dist/svg-media.d.ts +13 -0
- package/dist/svg-media.d.ts.map +1 -0
- package/dist/svg-media.js +47 -0
- package/dist/svg-media.js.map +1 -0
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- 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 +75 -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 +58 -7
- package/dist/astro/DefaultTemplate.astro +0 -42
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
|
@@ -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>
|
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
---
|
|
2
2
|
import "@splidejs/splide/css/core";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import "../native/carousel.css";
|
|
4
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
5
|
+
import {
|
|
6
|
+
carouselLayout,
|
|
7
|
+
carouselOptions,
|
|
8
|
+
carouselSettings,
|
|
9
|
+
carouselStyleText
|
|
10
|
+
} from "../../carousel.js";
|
|
5
11
|
import type { FlowpressBlock } from "../../types.js";
|
|
6
12
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
7
13
|
import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
8
14
|
|
|
9
15
|
interface Props {
|
|
10
16
|
block: FlowpressBlock;
|
|
11
|
-
contract?: StyleflowContract;
|
|
17
|
+
contract?: StyleflowContract | undefined;
|
|
12
18
|
validChildren: boolean;
|
|
13
|
-
invalidChildNames?: string[];
|
|
19
|
+
invalidChildNames?: string[] | undefined;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
const { block, contract, validChildren, invalidChildNames = [] } = Astro.props;
|
|
17
23
|
const settings = carouselSettings(block.attributes);
|
|
18
24
|
const options = carouselOptions(settings);
|
|
25
|
+
const layout = carouselLayout(settings);
|
|
19
26
|
const semantic = semanticProps(block.attributes, contract, {
|
|
20
27
|
surface: "default",
|
|
21
28
|
layoutRole: "container",
|
|
22
29
|
density: "regular"
|
|
23
30
|
});
|
|
24
|
-
const htmlAttributes = blockHtmlAttributes(
|
|
31
|
+
const { style: nativeStyle, ...htmlAttributes } = blockHtmlAttributes(
|
|
25
32
|
block.attributes,
|
|
26
33
|
`flowpress-carousel${validChildren ? " splide" : " flowpress-carousel--static"}`
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
) as Record<string, unknown>;
|
|
35
|
+
// Native flex-item sizing (e.g. --fp-flex-basis) and the carousel geometry share the root style.
|
|
36
|
+
const style = [nativeStyle, carouselStyleText(layout)].filter(Boolean).join(";");
|
|
37
|
+
const slideCount = block.innerBlocks?.length ?? 0;
|
|
38
|
+
const counter = settings.showPagination && settings.paginationStyle === "fraction";
|
|
39
|
+
const pagination = settings.showPagination && !counter;
|
|
40
|
+
const chevron = {
|
|
41
|
+
prev: "M15 18l-6-6 6-6",
|
|
42
|
+
next: "M9 6l6 6-6 6"
|
|
43
|
+
};
|
|
37
44
|
|
|
38
45
|
if (!validChildren && import.meta.env.DEV) {
|
|
39
46
|
console.warn(
|
|
@@ -44,10 +51,10 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
44
51
|
|
|
45
52
|
{validChildren ? (
|
|
46
53
|
<flowpress-carousel>
|
|
47
|
-
<
|
|
48
|
-
as="section"
|
|
54
|
+
<StyleflowElement as="section"
|
|
49
55
|
{...semantic}
|
|
50
56
|
{...htmlAttributes}
|
|
57
|
+
{...layout.data}
|
|
51
58
|
aria-label={settings.ariaLabel}
|
|
52
59
|
data-flowpress-carousel-root
|
|
53
60
|
data-carousel-options={JSON.stringify(options)}
|
|
@@ -55,20 +62,32 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
55
62
|
>
|
|
56
63
|
{settings.showArrows ? (
|
|
57
64
|
<div class="splide__arrows" data-flowpress-carousel-controls>
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
{(["prev", "next"] as const).map((direction) => (
|
|
66
|
+
<button
|
|
67
|
+
class={`splide__arrow splide__arrow--${direction}`}
|
|
68
|
+
type="button"
|
|
69
|
+
aria-label={direction === "prev" ? "Slide precedente" : "Slide successiva"}
|
|
70
|
+
>
|
|
71
|
+
<span class="flowpress-carousel__icon" aria-hidden="true">
|
|
72
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" focusable="false">
|
|
73
|
+
<path d={chevron[direction]} />
|
|
74
|
+
</svg>
|
|
75
|
+
</span>
|
|
76
|
+
</button>
|
|
77
|
+
))}
|
|
64
78
|
</div>
|
|
65
79
|
) : null}
|
|
66
|
-
<div class="splide__track">
|
|
80
|
+
<div class="splide__track sf-reveal-skip">
|
|
67
81
|
<ul class="splide__list">
|
|
68
82
|
<slot />
|
|
69
83
|
</ul>
|
|
70
84
|
</div>
|
|
71
|
-
{
|
|
85
|
+
{pagination ? <ul class="splide__pagination"></ul> : null}
|
|
86
|
+
{counter ? (
|
|
87
|
+
<div class="flowpress-carousel__counter" aria-hidden="true" data-flowpress-carousel-counter>
|
|
88
|
+
{`${Math.min(settings.startIndex, Math.max(slideCount - 1, 0)) + 1} / ${slideCount}`}
|
|
89
|
+
</div>
|
|
90
|
+
) : null}
|
|
72
91
|
{settings.autoplay ? (
|
|
73
92
|
<button
|
|
74
93
|
class="splide__toggle"
|
|
@@ -79,11 +98,10 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
79
98
|
<span class="splide__toggle__pause">Pausa</span>
|
|
80
99
|
</button>
|
|
81
100
|
) : null}
|
|
82
|
-
</
|
|
101
|
+
</StyleflowElement>
|
|
83
102
|
</flowpress-carousel>
|
|
84
103
|
) : (
|
|
85
|
-
<
|
|
86
|
-
as="section"
|
|
104
|
+
<StyleflowElement as="section"
|
|
87
105
|
{...semantic}
|
|
88
106
|
{...htmlAttributes}
|
|
89
107
|
aria-label={settings.ariaLabel}
|
|
@@ -92,16 +110,18 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
92
110
|
style={style}
|
|
93
111
|
>
|
|
94
112
|
<slot />
|
|
95
|
-
</
|
|
113
|
+
</StyleflowElement>
|
|
96
114
|
)}
|
|
97
115
|
|
|
98
116
|
<script>
|
|
99
117
|
import Splide from "@splidejs/splide";
|
|
100
118
|
import type { Options } from "@splidejs/splide";
|
|
119
|
+
import { getMotionPreference, subscribeMotionPreference } from "../../motion-preference.js";
|
|
101
120
|
|
|
102
121
|
if (!customElements.get("flowpress-carousel")) {
|
|
103
122
|
customElements.define("flowpress-carousel", class extends HTMLElement {
|
|
104
|
-
private instance?: Splide;
|
|
123
|
+
private instance?: Splide | undefined;
|
|
124
|
+
private unsubscribe?: (() => void) | undefined;
|
|
105
125
|
|
|
106
126
|
connectedCallback() {
|
|
107
127
|
if (this.instance) return;
|
|
@@ -109,14 +129,33 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
109
129
|
if (!root) return;
|
|
110
130
|
try {
|
|
111
131
|
const options = JSON.parse(root.dataset.carouselOptions || "{}") as Options;
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
const speed = options.speed ?? 400;
|
|
133
|
+
// The site's motion switch counts as much as the operating system setting.
|
|
134
|
+
if (getMotionPreference() === "reduce") {
|
|
135
|
+
options.speed = 0;
|
|
136
|
+
if (options.autoplay) options.autoplay = "pause";
|
|
137
|
+
}
|
|
138
|
+
const instance = new Splide(root, options);
|
|
139
|
+
const counter = root.querySelector<HTMLElement>("[data-flowpress-carousel-counter]");
|
|
140
|
+
if (counter) {
|
|
141
|
+
instance.on("mounted move", () => {
|
|
142
|
+
counter.textContent = `${instance.index + 1} / ${instance.length}`;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
instance.mount();
|
|
146
|
+
this.instance = instance;
|
|
147
|
+
this.unsubscribe = subscribeMotionPreference((preference) => {
|
|
148
|
+
instance.options = { speed: preference === "reduce" ? 0 : speed };
|
|
149
|
+
if (preference === "reduce") instance.Components.Autoplay?.pause();
|
|
150
|
+
});
|
|
114
151
|
} catch (error) {
|
|
115
152
|
console.error("[flowpress-carousel-init] Unable to initialize carousel.", error);
|
|
116
153
|
}
|
|
117
154
|
}
|
|
118
155
|
|
|
119
156
|
disconnectedCallback() {
|
|
157
|
+
this.unsubscribe?.();
|
|
158
|
+
this.unsubscribe = undefined;
|
|
120
159
|
this.instance?.destroy(true);
|
|
121
160
|
this.instance = undefined;
|
|
122
161
|
}
|
|
@@ -124,76 +163,8 @@ if (!validChildren && import.meta.env.DEV) {
|
|
|
124
163
|
}
|
|
125
164
|
</script>
|
|
126
165
|
|
|
127
|
-
<style>
|
|
166
|
+
<style is:global>
|
|
128
167
|
flowpress-carousel { display: block; }
|
|
129
|
-
.flowpress-carousel { min-width: 0; }
|
|
130
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
131
|
-
display: grid;
|
|
132
|
-
grid-template-columns: repeat(var(--flowpress-carousel-base), minmax(0, 1fr));
|
|
133
|
-
gap: var(--flowpress-carousel-gap);
|
|
134
|
-
}
|
|
135
|
-
.flowpress-carousel:not(.is-initialized) [data-flowpress-carousel-controls],
|
|
136
|
-
.flowpress-carousel:not(.is-initialized) .splide__pagination {
|
|
137
|
-
display: none;
|
|
138
|
-
}
|
|
139
|
-
.flowpress-carousel--static {
|
|
140
|
-
display: grid;
|
|
141
|
-
gap: var(--flowpress-carousel-gap);
|
|
142
|
-
}
|
|
143
|
-
.splide__arrows {
|
|
144
|
-
display: flex;
|
|
145
|
-
justify-content: space-between;
|
|
146
|
-
gap: 0.5rem;
|
|
147
|
-
margin-block-end: 0.75rem;
|
|
148
|
-
}
|
|
149
|
-
.splide__arrow:disabled { opacity: 0.45; }
|
|
150
|
-
.splide__pagination {
|
|
151
|
-
display: flex;
|
|
152
|
-
justify-content: center;
|
|
153
|
-
gap: 0.5rem;
|
|
154
|
-
margin: 0.75rem 0 0;
|
|
155
|
-
padding: 0;
|
|
156
|
-
}
|
|
157
|
-
:global(.splide__pagination__page) {
|
|
158
|
-
width: 0.75rem;
|
|
159
|
-
height: 0.75rem;
|
|
160
|
-
border-radius: 999px;
|
|
161
|
-
}
|
|
162
|
-
.splide__toggle { margin-block-start: 0.75rem; }
|
|
163
|
-
.splide__toggle__pause { display: none; }
|
|
164
|
-
.splide__toggle.is-active .splide__toggle__play { display: none; }
|
|
165
|
-
.splide__toggle.is-active .splide__toggle__pause { display: inline; }
|
|
166
|
-
.splide__arrow:focus-visible,
|
|
167
|
-
:global(.splide__pagination__page:focus-visible),
|
|
168
|
-
.splide__toggle:focus-visible {
|
|
169
|
-
outline: 3px solid currentColor;
|
|
170
|
-
outline-offset: 3px;
|
|
171
|
-
}
|
|
172
|
-
@media (min-width: 40rem) {
|
|
173
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
174
|
-
grid-template-columns: repeat(var(--flowpress-carousel-sm), minmax(0, 1fr));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
@media (min-width: 48rem) {
|
|
178
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
179
|
-
grid-template-columns: repeat(var(--flowpress-carousel-md), minmax(0, 1fr));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
@media (min-width: 64rem) {
|
|
183
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
184
|
-
grid-template-columns: repeat(var(--flowpress-carousel-lg), minmax(0, 1fr));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
@media (min-width: 80rem) {
|
|
188
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
189
|
-
grid-template-columns: repeat(var(--flowpress-carousel-xl), minmax(0, 1fr));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
@media (min-width: 96rem) {
|
|
193
|
-
.flowpress-carousel:not(.is-initialized) .splide__list {
|
|
194
|
-
grid-template-columns: repeat(var(--flowpress-carousel-2xl), minmax(0, 1fr));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
168
|
@media (prefers-reduced-motion: reduce) {
|
|
198
169
|
.flowpress-carousel * { scroll-behavior: auto !important; }
|
|
199
170
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
3
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
4
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
5
|
import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
block: FlowpressBlock;
|
|
9
|
-
contract?: StyleflowContract;
|
|
9
|
+
contract?: StyleflowContract | undefined;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const { block, contract } = Astro.props;
|
|
@@ -17,9 +17,9 @@ const htmlAttributes = blockHtmlAttributes(
|
|
|
17
17
|
);
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
<
|
|
20
|
+
<StyleflowElement as="li" {...semantic} {...htmlAttributes}>
|
|
21
21
|
<slot />
|
|
22
|
-
</
|
|
22
|
+
</StyleflowElement>
|
|
23
23
|
|
|
24
24
|
<style>
|
|
25
25
|
.flowpress-carousel-item { min-width: 0; }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
3
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
4
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
5
|
import {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
block: FlowpressBlock;
|
|
13
|
-
contract?: StyleflowContract;
|
|
13
|
+
contract?: StyleflowContract | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const { block, contract } = Astro.props;
|
|
@@ -33,8 +33,7 @@ const style = [
|
|
|
33
33
|
].join(";");
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
-
<
|
|
37
|
-
as="div"
|
|
36
|
+
<StyleflowElement as="div"
|
|
38
37
|
{...semantic}
|
|
39
38
|
{...htmlAttributes}
|
|
40
39
|
data-partial={partial}
|
|
@@ -42,7 +41,7 @@ const style = [
|
|
|
42
41
|
style={style}
|
|
43
42
|
>
|
|
44
43
|
<slot />
|
|
45
|
-
</
|
|
44
|
+
</StyleflowElement>
|
|
46
45
|
|
|
47
46
|
<style>
|
|
48
47
|
.flowpress-column {
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Media from "../Media.astro";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { DynamicStyleflowProps, StyleflowContract } from "../../styleflow.js";
|
|
5
|
+
import { resolvePrefixedFlowpressBlockStyleflowProps } from "../../styleflow.js";
|
|
6
|
+
import type {
|
|
7
|
+
FlowpressBlock,
|
|
8
|
+
FlowpressBlockHtmlProps
|
|
9
|
+
} from "../../types.js";
|
|
10
|
+
import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
11
|
+
import {
|
|
12
|
+
coverBackgroundType,
|
|
13
|
+
coverContentPosition,
|
|
14
|
+
coverMediaSource,
|
|
15
|
+
coverMinimumHeight,
|
|
16
|
+
coverObjectPosition,
|
|
17
|
+
coverPosterSource,
|
|
18
|
+
coverScrimEnabled,
|
|
19
|
+
coverScrimOpacity,
|
|
20
|
+
coverTagName
|
|
21
|
+
} from "./cover.js";
|
|
22
|
+
|
|
23
|
+
interface Props {
|
|
24
|
+
block: FlowpressBlock;
|
|
25
|
+
contract?: StyleflowContract | undefined;
|
|
26
|
+
htmlProps?: FlowpressBlockHtmlProps | undefined;
|
|
27
|
+
styleflowProps?: DynamicStyleflowProps | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { block, contract, htmlProps, styleflowProps } = Astro.props;
|
|
31
|
+
const attributes = block.attributes;
|
|
32
|
+
const rootStyleflowProps = styleflowProps ?? semanticProps(attributes, contract, {
|
|
33
|
+
layoutRole: "region",
|
|
34
|
+
density: "regular"
|
|
35
|
+
});
|
|
36
|
+
const normalizedHtmlProps = htmlProps ?? blockHtmlAttributes(attributes);
|
|
37
|
+
const rootHtmlProps = {
|
|
38
|
+
...normalizedHtmlProps,
|
|
39
|
+
class: ["wp-block-cover", "flowpress-cover", normalizedHtmlProps.class]
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.join(" ")
|
|
42
|
+
};
|
|
43
|
+
const backgroundType = coverBackgroundType(block);
|
|
44
|
+
const source = coverMediaSource(block);
|
|
45
|
+
const poster = coverPosterSource(block);
|
|
46
|
+
const alt = String(attributes.alt ?? block.resolvedData?.alt ?? "");
|
|
47
|
+
const width = Number(block.resolvedData?.width) || undefined;
|
|
48
|
+
const height = Number(block.resolvedData?.height) || undefined;
|
|
49
|
+
const objectPosition = coverObjectPosition(attributes.focalPoint);
|
|
50
|
+
const minimumHeight = coverMinimumHeight(
|
|
51
|
+
attributes.minHeight,
|
|
52
|
+
attributes.minHeightUnit
|
|
53
|
+
);
|
|
54
|
+
const [contentBlockPosition, contentInlinePosition] = coverContentPosition(
|
|
55
|
+
attributes.contentPosition
|
|
56
|
+
);
|
|
57
|
+
const scrimOpacity = coverScrimOpacity(attributes);
|
|
58
|
+
const rootStyle = [
|
|
59
|
+
`--flowpress-cover-object-position:${objectPosition}`,
|
|
60
|
+
minimumHeight ? `--flowpress-cover-min-height:${minimumHeight}` : "",
|
|
61
|
+
`--flowpress-cover-content-block:${contentBlockPosition}`,
|
|
62
|
+
`--flowpress-cover-content-inline:${contentInlinePosition}`,
|
|
63
|
+
`--flowpress-cover-scrim-opacity:${scrimOpacity / 100}`
|
|
64
|
+
].filter(Boolean).join(";");
|
|
65
|
+
const scrimEnabled = backgroundType !== "color" && coverScrimEnabled(attributes);
|
|
66
|
+
const scrimStyleflowProps = resolvePrefixedFlowpressBlockStyleflowProps(
|
|
67
|
+
attributes,
|
|
68
|
+
"scrim",
|
|
69
|
+
contract,
|
|
70
|
+
{},
|
|
71
|
+
{
|
|
72
|
+
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
73
|
+
onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
const tagName = coverTagName(attributes.tagName);
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
<StyleflowElement as={tagName} {...rootStyleflowProps} {...rootHtmlProps} style={rootStyle}>
|
|
80
|
+
{backgroundType === "image" && source ? (
|
|
81
|
+
<Media
|
|
82
|
+
class="wp-block-cover__image-background flowpress-cover__media"
|
|
83
|
+
src={source}
|
|
84
|
+
width={width}
|
|
85
|
+
height={height}
|
|
86
|
+
alt={alt}
|
|
87
|
+
aria-hidden={alt ? undefined : "true"}
|
|
88
|
+
loading="lazy"
|
|
89
|
+
decoding="async"
|
|
90
|
+
/>
|
|
91
|
+
) : null}
|
|
92
|
+
{backgroundType === "video" && source ? (
|
|
93
|
+
<video
|
|
94
|
+
class="wp-block-cover__video-background flowpress-cover__media"
|
|
95
|
+
src={source}
|
|
96
|
+
poster={poster}
|
|
97
|
+
autoplay
|
|
98
|
+
muted
|
|
99
|
+
loop
|
|
100
|
+
playsinline
|
|
101
|
+
preload="metadata"
|
|
102
|
+
aria-hidden="true"
|
|
103
|
+
tabindex="-1"
|
|
104
|
+
/>
|
|
105
|
+
) : null}
|
|
106
|
+
{scrimEnabled ? (
|
|
107
|
+
<StyleflowElement as="span"
|
|
108
|
+
class="wp-block-cover__background flowpress-cover__scrim"
|
|
109
|
+
{...scrimStyleflowProps}
|
|
110
|
+
data-flowpress-cover-scrim
|
|
111
|
+
aria-hidden="true"
|
|
112
|
+
/>
|
|
113
|
+
) : null}
|
|
114
|
+
<StyleflowElement as="div" class="wp-block-cover__inner-container flowpress-cover__content">
|
|
115
|
+
<slot />
|
|
116
|
+
</StyleflowElement>
|
|
117
|
+
</StyleflowElement>
|
|
118
|
+
|
|
119
|
+
<style>
|
|
120
|
+
.flowpress-cover {
|
|
121
|
+
position: relative;
|
|
122
|
+
display: grid;
|
|
123
|
+
min-height: var(--flowpress-cover-min-height, 0);
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
isolation: isolate;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.flowpress-cover__media,
|
|
129
|
+
.flowpress-cover__scrim {
|
|
130
|
+
position: absolute;
|
|
131
|
+
inset: 0;
|
|
132
|
+
width: 100%;
|
|
133
|
+
height: 100%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.flowpress-cover__media {
|
|
137
|
+
z-index: 0;
|
|
138
|
+
object-fit: cover;
|
|
139
|
+
object-position: var(--flowpress-cover-object-position, 50% 50%);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.flowpress-cover__scrim {
|
|
143
|
+
z-index: 1;
|
|
144
|
+
background: var(--sf-background);
|
|
145
|
+
opacity: var(--flowpress-cover-scrim-opacity, 1);
|
|
146
|
+
pointer-events: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.flowpress-cover__content {
|
|
150
|
+
width: 100%;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
position: relative;
|
|
153
|
+
z-index: 2;
|
|
154
|
+
display: grid;
|
|
155
|
+
align-items: var(--flowpress-cover-content-block, center);
|
|
156
|
+
justify-items: var(--flowpress-cover-content-inline, center);
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
type HTMLInputTypeAttribute = HTMLAttributes<"input">["type"];
|
|
5
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
6
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
7
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
8
|
import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
@@ -7,10 +10,10 @@ import { blockHtmlAttributes, semanticProps } from "./helpers.js";
|
|
|
7
10
|
interface FormField {
|
|
8
11
|
name: string;
|
|
9
12
|
type: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
values?: string[];
|
|
12
|
-
labels?: string[];
|
|
13
|
-
options?: string[];
|
|
13
|
+
required?: boolean | undefined;
|
|
14
|
+
values?: string[] | undefined;
|
|
15
|
+
labels?: string[] | undefined;
|
|
16
|
+
options?: string[] | undefined;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
interface FormSchema {
|
|
@@ -24,7 +27,7 @@ interface FormSchema {
|
|
|
24
27
|
|
|
25
28
|
interface Props {
|
|
26
29
|
block: FlowpressBlock;
|
|
27
|
-
contract?: StyleflowContract;
|
|
30
|
+
contract?: StyleflowContract | undefined;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const { block, contract } = Astro.props;
|
|
@@ -35,21 +38,21 @@ const labelFor = (field: FormField): string => field.name
|
|
|
35
38
|
.replace(/[-_]+/g, " ")
|
|
36
39
|
.replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
37
40
|
const optionLabel = (field: FormField, index: number): string =>
|
|
38
|
-
field.labels?.[index] || field.values?.[index] || "";
|
|
41
|
+
decodeFlowpressText(field.labels?.[index] || field.values?.[index] || "");
|
|
39
42
|
---
|
|
40
43
|
|
|
41
44
|
{schema?.available ? (
|
|
42
|
-
<
|
|
45
|
+
<StyleflowElement as="div" {...semantic} {...htmlAttributes}>
|
|
43
46
|
<flowpress-cf7-form>
|
|
44
47
|
<form action={schema.submitUrl} method="post" enctype="multipart/form-data" novalidate>
|
|
45
48
|
{block.attributes.title || schema.title ? (
|
|
46
|
-
<
|
|
49
|
+
<StyleflowElement as="h2">{decodeFlowpressText(block.attributes.title || schema.title)}</StyleflowElement>
|
|
47
50
|
) : null}
|
|
48
51
|
{schema.fields.map((field) => {
|
|
49
52
|
if (field.type === "submit") {
|
|
50
53
|
return (
|
|
51
54
|
<button type="submit">
|
|
52
|
-
{field.values?.[0] || "Invia"}
|
|
55
|
+
{decodeFlowpressText(field.values?.[0] || "Invia")}
|
|
53
56
|
</button>
|
|
54
57
|
);
|
|
55
58
|
}
|
|
@@ -63,7 +66,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
63
66
|
{(field.values || []).map((value, index) => (
|
|
64
67
|
<label>
|
|
65
68
|
<input
|
|
66
|
-
type={field.type}
|
|
69
|
+
type={field.type as HTMLInputTypeAttribute}
|
|
67
70
|
name={field.type === "checkbox" ? `${field.name}[]` : field.name}
|
|
68
71
|
value={value}
|
|
69
72
|
required={field.required}
|
|
@@ -79,7 +82,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
79
82
|
return (
|
|
80
83
|
<label>
|
|
81
84
|
<input type="checkbox" name={field.name} value="1" required={field.required} />
|
|
82
|
-
{field.values?.[0] || labelFor(field)}
|
|
85
|
+
{decodeFlowpressText(field.values?.[0] || labelFor(field))}
|
|
83
86
|
<span data-field-error={field.name}></span>
|
|
84
87
|
</label>
|
|
85
88
|
);
|
|
@@ -114,7 +117,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
114
117
|
<label>
|
|
115
118
|
{labelFor(field)}
|
|
116
119
|
<input
|
|
117
|
-
type={field.type === "file" ? "file" : field.type}
|
|
120
|
+
type={field.type === "file" ? "file" : field.type as HTMLInputTypeAttribute}
|
|
118
121
|
name={field.name}
|
|
119
122
|
required={field.required}
|
|
120
123
|
/>
|
|
@@ -130,11 +133,11 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
130
133
|
<p data-form-status role="status" aria-live="polite"></p>
|
|
131
134
|
</form>
|
|
132
135
|
</flowpress-cf7-form>
|
|
133
|
-
</
|
|
136
|
+
</StyleflowElement>
|
|
134
137
|
) : (
|
|
135
|
-
<
|
|
138
|
+
<StyleflowElement as="p" {...semantic} {...htmlAttributes} role="status">
|
|
136
139
|
Il modulo non è temporaneamente disponibile.
|
|
137
|
-
</
|
|
140
|
+
</StyleflowElement>
|
|
138
141
|
)}
|
|
139
142
|
|
|
140
143
|
<script>
|
|
@@ -142,7 +145,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
142
145
|
interface Window {
|
|
143
146
|
turnstile?: {
|
|
144
147
|
render(target: Element, options: Record<string, unknown>): string;
|
|
145
|
-
reset(widgetId?: string): void;
|
|
148
|
+
reset(widgetId?: string): void | undefined;
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
151
|
}
|
|
@@ -174,7 +177,7 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
174
177
|
|
|
175
178
|
if (!customElements.get("flowpress-cf7-form")) {
|
|
176
179
|
customElements.define("flowpress-cf7-form", class extends HTMLElement {
|
|
177
|
-
private widgetId?: string;
|
|
180
|
+
private widgetId?: string | undefined;
|
|
178
181
|
|
|
179
182
|
connectedCallback() {
|
|
180
183
|
const form = this.querySelector<HTMLFormElement>("form");
|
|
@@ -207,8 +210,8 @@ const optionLabel = (field: FormField, index: number): string =>
|
|
|
207
210
|
headers: { Accept: "application/json" }
|
|
208
211
|
});
|
|
209
212
|
const result = await response.json() as {
|
|
210
|
-
message?: string;
|
|
211
|
-
invalidFields?: Array<{ field?: string; into?: string; message?: string }
|
|
213
|
+
message?: string | undefined;
|
|
214
|
+
invalidFields?: Array<{ field?: string | undefined; into?: string | undefined; message?: string }> | undefined;
|
|
212
215
|
};
|
|
213
216
|
status.textContent = result.message || (response.ok ? "Messaggio inviato." : "Invio non riuscito.");
|
|
214
217
|
for (const invalid of result.invalidFields || []) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
3
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
4
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
5
|
import {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
block: FlowpressBlock;
|
|
13
|
-
contract?: StyleflowContract;
|
|
13
|
+
contract?: StyleflowContract | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const { block, contract } = Astro.props;
|
|
@@ -38,13 +38,14 @@ const style = [
|
|
|
38
38
|
].join(";");
|
|
39
39
|
---
|
|
40
40
|
|
|
41
|
-
<
|
|
41
|
+
<StyleflowElement as="div" {...semantic} {...htmlAttributes} data-align={align} style={style}>
|
|
42
42
|
<slot />
|
|
43
|
-
</
|
|
43
|
+
</StyleflowElement>
|
|
44
44
|
|
|
45
45
|
<style>
|
|
46
46
|
.flowpress-grid {
|
|
47
47
|
display: grid;
|
|
48
|
+
min-width: 0;
|
|
48
49
|
grid-template-columns: repeat(var(--flowpress-grid-base), minmax(0, 1fr));
|
|
49
50
|
align-items: var(--flowpress-grid-align, stretch);
|
|
50
51
|
}
|