@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
package/dist/carousel.js
CHANGED
|
@@ -1,27 +1,74 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
export const CAROUSEL_BREAKPOINTS = ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
2
|
+
/** Splide breakpoints (min-width, px); the static CSS uses the same values in rem. */
|
|
3
|
+
const BREAKPOINT_WIDTHS = {
|
|
4
|
+
sm: 640,
|
|
5
|
+
md: 768,
|
|
6
|
+
lg: 1024,
|
|
7
|
+
xl: 1280,
|
|
8
|
+
"2xl": 1536
|
|
9
|
+
};
|
|
10
|
+
const ARROWS_POSITIONS = ["top", "top-end", "sides", "edges", "outside", "bottom", "bottom-end"];
|
|
11
|
+
const ARROWS_MOBILE_POSITIONS = ["same", "bottom", "hidden"];
|
|
12
|
+
const ARROWS_SHAPES = ["circle", "rounded", "square"];
|
|
13
|
+
const ARROWS_SIZES = ["sm", "md", "lg"];
|
|
14
|
+
const PAGINATION_STYLES = ["dots", "bars", "fraction"];
|
|
15
|
+
const PAGINATION_POSITIONS = ["below", "overlay"];
|
|
16
|
+
const ASPECT_RATIOS = ["1/1", "4/5", "3/4", "2/3", "4/3", "3/2", "16/9", "21/9"];
|
|
17
|
+
/** Peek keyword aligned with the StyleFlow container padding. */
|
|
18
|
+
export const CAROUSEL_CONTAINER_PEEK = "var(--sf-layout-container-comfortable-padding-x, 2rem)";
|
|
19
|
+
function boundedNumber(value, fallback, min, max, decimals = 0) {
|
|
3
20
|
if (value === "" || value === null || value === undefined || value === "inherit") {
|
|
4
21
|
return fallback;
|
|
5
22
|
}
|
|
6
23
|
const numeric = Number(value);
|
|
24
|
+
const factor = 10 ** decimals;
|
|
7
25
|
return Number.isFinite(numeric)
|
|
8
|
-
? Math.min(max, Math.max(min, Math.round(numeric)))
|
|
26
|
+
? Math.min(max, Math.max(min, Math.round(numeric * factor) / factor))
|
|
9
27
|
: fallback;
|
|
10
28
|
}
|
|
11
29
|
function booleanValue(value, fallback) {
|
|
12
30
|
return typeof value === "boolean" ? value : fallback;
|
|
13
31
|
}
|
|
32
|
+
function choice(value, choices, fallback) {
|
|
33
|
+
return choices.includes(value) ? value : fallback;
|
|
34
|
+
}
|
|
35
|
+
function token(value) {
|
|
36
|
+
return typeof value === "string" && /^[a-z0-9-]+$/.test(value) && value !== "inherit" ? value : "";
|
|
37
|
+
}
|
|
38
|
+
const suffix = (breakpoint) => breakpoint === "base"
|
|
39
|
+
? "Base"
|
|
40
|
+
: breakpoint === "2xl"
|
|
41
|
+
? "2xl"
|
|
42
|
+
: breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);
|
|
43
|
+
const isLength = (value) => typeof value === "string" && /^(?:0|\d+(?:\.\d+)?(?:rem|px|%|vw))$/.test(value);
|
|
44
|
+
/**
|
|
45
|
+
* Resolves a responsive string field: an empty value inherits from the smaller breakpoint and an
|
|
46
|
+
* invalid one does too. `reset` (if given) is the value that clears an inherited setting.
|
|
47
|
+
*/
|
|
48
|
+
function responsiveStrings(attributes, name, base, accept, reset) {
|
|
49
|
+
const values = {};
|
|
50
|
+
let inherited = base;
|
|
51
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
52
|
+
const raw = attributes[`${name}${suffix(breakpoint)}`];
|
|
53
|
+
const value = reset !== undefined && raw === reset
|
|
54
|
+
? ""
|
|
55
|
+
: accept(raw)
|
|
56
|
+
? raw
|
|
57
|
+
: breakpoint === "base"
|
|
58
|
+
? base
|
|
59
|
+
: inherited;
|
|
60
|
+
values[breakpoint] = value;
|
|
61
|
+
inherited = value;
|
|
62
|
+
}
|
|
63
|
+
return values;
|
|
64
|
+
}
|
|
65
|
+
const isPeek = (value) => value === "container" || isLength(value);
|
|
14
66
|
export function carouselSettings(attributes) {
|
|
15
67
|
const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, "2xl": 3 };
|
|
16
68
|
const values = {};
|
|
17
69
|
let inherited = defaults.base;
|
|
18
|
-
for (const breakpoint of
|
|
19
|
-
const
|
|
20
|
-
? "Base"
|
|
21
|
-
: breakpoint === "2xl"
|
|
22
|
-
? "2xl"
|
|
23
|
-
: breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);
|
|
24
|
-
const raw = attributes[`itemsPerView${suffix}`];
|
|
70
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
71
|
+
const raw = attributes[`itemsPerView${suffix(breakpoint)}`];
|
|
25
72
|
const fallback = breakpoint !== "base" && (raw === "" || raw === "inherit")
|
|
26
73
|
? inherited
|
|
27
74
|
: breakpoint === "base"
|
|
@@ -29,41 +76,95 @@ export function carouselSettings(attributes) {
|
|
|
29
76
|
: breakpoint === "md" || breakpoint === "lg"
|
|
30
77
|
? defaults[breakpoint]
|
|
31
78
|
: inherited;
|
|
32
|
-
const value = boundedNumber(raw, fallback, 1, 12);
|
|
79
|
+
const value = boundedNumber(raw, fallback, 1, 12, 2);
|
|
33
80
|
values[breakpoint] = value;
|
|
34
81
|
inherited = value;
|
|
35
82
|
}
|
|
36
83
|
const ariaLabel = typeof attributes.ariaLabel === "string"
|
|
37
84
|
? attributes.ariaLabel.trim()
|
|
38
85
|
: "";
|
|
86
|
+
const aspect = attributes.slideAspectRatio;
|
|
39
87
|
return {
|
|
40
88
|
ariaLabel: ariaLabel || "Carosello",
|
|
41
89
|
itemsPerView: values,
|
|
90
|
+
slideWidth: responsiveStrings(attributes, "slideWidth", "", isLength, "auto"),
|
|
91
|
+
peek: responsiveStrings(attributes, "peek", "0", isPeek),
|
|
92
|
+
focus: choice(attributes.focus, ["start", "center"], "start"),
|
|
42
93
|
itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),
|
|
43
94
|
gap: boundedNumber(attributes.gap, 24, 0, 128),
|
|
44
|
-
|
|
45
|
-
|
|
95
|
+
slideAspectRatio: ASPECT_RATIOS.includes(aspect) ? String(aspect) : "",
|
|
96
|
+
equalHeight: booleanValue(attributes.equalHeight, false),
|
|
97
|
+
effect: choice(attributes.effect, ["slide", "fade"], "slide"),
|
|
98
|
+
loop: booleanValue(attributes.loop, false),
|
|
99
|
+
rewind: booleanValue(attributes.rewind, false),
|
|
100
|
+
startIndex: boundedNumber(attributes.startIndex, 0, 0, 99),
|
|
101
|
+
speed: boundedNumber(attributes.speed, 400, 0, 5000),
|
|
46
102
|
drag: booleanValue(attributes.drag, true),
|
|
103
|
+
dragFree: booleanValue(attributes.dragFree, false),
|
|
47
104
|
keyboard: booleanValue(attributes.keyboard, true),
|
|
105
|
+
wheel: booleanValue(attributes.wheel, false),
|
|
106
|
+
showArrows: booleanValue(attributes.showArrows, true),
|
|
107
|
+
arrowsPosition: choice(attributes.arrowsPosition, ARROWS_POSITIONS, "top"),
|
|
108
|
+
arrowsPositionMobile: choice(attributes.arrowsPositionMobile, ARROWS_MOBILE_POSITIONS, "same"),
|
|
109
|
+
arrowsShape: choice(attributes.arrowsShape, ARROWS_SHAPES, "circle"),
|
|
110
|
+
arrowsSize: choice(attributes.arrowsSize, ARROWS_SIZES, "md"),
|
|
111
|
+
showPagination: booleanValue(attributes.showPagination, true),
|
|
112
|
+
paginationStyle: choice(attributes.paginationStyle, PAGINATION_STYLES, "dots"),
|
|
113
|
+
paginationPosition: choice(attributes.paginationPosition, PAGINATION_POSITIONS, "below"),
|
|
114
|
+
controlsTone: token(attributes.controlsTone),
|
|
115
|
+
controlsIntensity: token(attributes.controlsIntensity),
|
|
48
116
|
autoplay: booleanValue(attributes.autoplay, false),
|
|
49
117
|
autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),
|
|
50
118
|
pauseOnHover: booleanValue(attributes.pauseOnHover, true),
|
|
51
|
-
pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)
|
|
52
|
-
loop: booleanValue(attributes.loop, false),
|
|
53
|
-
speed: boundedNumber(attributes.speed, 400, 0, 5000)
|
|
119
|
+
pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)
|
|
54
120
|
};
|
|
55
121
|
}
|
|
122
|
+
/** CSS length of a peek setting. */
|
|
123
|
+
export function carouselPeekLength(peek) {
|
|
124
|
+
return peek === "container" ? CAROUSEL_CONTAINER_PEEK : peek;
|
|
125
|
+
}
|
|
126
|
+
function perPage(settings, breakpoint) {
|
|
127
|
+
return settings.effect === "fade" ? 1 : settings.itemsPerView[breakpoint];
|
|
128
|
+
}
|
|
129
|
+
function fixedWidth(settings, breakpoint) {
|
|
130
|
+
return settings.effect === "fade" ? "" : settings.slideWidth[breakpoint];
|
|
131
|
+
}
|
|
132
|
+
function padding(settings, breakpoint) {
|
|
133
|
+
const peek = settings.effect === "fade" ? "0" : carouselPeekLength(settings.peek[breakpoint]);
|
|
134
|
+
if (peek === "0")
|
|
135
|
+
return { left: 0, right: 0 };
|
|
136
|
+
return settings.focus === "center" ? { left: peek, right: peek } : { left: 0, right: peek };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Splide options. Options for settings that keep their previous defaults are left out, so a
|
|
140
|
+
* carousel saved with the original contract mounts with exactly the options it had before.
|
|
141
|
+
*/
|
|
56
142
|
export function carouselOptions(settings) {
|
|
143
|
+
const fade = settings.effect === "fade";
|
|
144
|
+
const usesWidth = CAROUSEL_BREAKPOINTS.some((breakpoint) => fixedWidth(settings, breakpoint) !== "");
|
|
145
|
+
const usesPadding = CAROUSEL_BREAKPOINTS.some((breakpoint) => padding(settings, breakpoint).right !== 0);
|
|
146
|
+
const sizing = (breakpoint) => ({
|
|
147
|
+
perPage: perPage(settings, breakpoint),
|
|
148
|
+
...(usesWidth ? { fixedWidth: fixedWidth(settings, breakpoint) || 0 } : {}),
|
|
149
|
+
...(usesPadding ? { padding: padding(settings, breakpoint) } : {})
|
|
150
|
+
});
|
|
151
|
+
const breakpoints = Object.fromEntries(Object.entries(BREAKPOINT_WIDTHS)
|
|
152
|
+
.map(([breakpoint, width]) => [width, sizing(breakpoint)]));
|
|
57
153
|
return {
|
|
58
154
|
label: settings.ariaLabel,
|
|
59
|
-
type: settings.loop ? "loop" : "slide",
|
|
60
|
-
|
|
155
|
+
type: fade ? "fade" : settings.loop ? "loop" : "slide",
|
|
156
|
+
...sizing("base"),
|
|
61
157
|
perMove: settings.itemsPerMove,
|
|
62
158
|
gap: `${settings.gap}px`,
|
|
159
|
+
...(settings.focus === "center" && !fade ? { focus: "center", trimSpace: false } : {}),
|
|
160
|
+
...(settings.rewind || (fade && settings.loop) ? { rewind: true } : {}),
|
|
161
|
+
...(settings.startIndex > 0 ? { start: settings.startIndex } : {}),
|
|
63
162
|
arrows: settings.showArrows,
|
|
64
|
-
pagination: settings.showPagination,
|
|
65
|
-
drag: settings.drag,
|
|
163
|
+
pagination: settings.showPagination && settings.paginationStyle !== "fraction",
|
|
164
|
+
drag: settings.drag && settings.dragFree ? "free" : settings.drag,
|
|
165
|
+
...(settings.drag && settings.dragFree ? { snap: true } : {}),
|
|
66
166
|
keyboard: settings.keyboard ? "focused" : false,
|
|
167
|
+
...(settings.wheel ? { wheel: true } : {}),
|
|
67
168
|
autoplay: settings.autoplay,
|
|
68
169
|
interval: settings.autoplayInterval,
|
|
69
170
|
pauseOnHover: settings.pauseOnHover,
|
|
@@ -71,13 +172,7 @@ export function carouselOptions(settings) {
|
|
|
71
172
|
speed: settings.speed,
|
|
72
173
|
live: true,
|
|
73
174
|
mediaQuery: "min",
|
|
74
|
-
breakpoints
|
|
75
|
-
640: { perPage: settings.itemsPerView.sm },
|
|
76
|
-
768: { perPage: settings.itemsPerView.md },
|
|
77
|
-
1024: { perPage: settings.itemsPerView.lg },
|
|
78
|
-
1280: { perPage: settings.itemsPerView.xl },
|
|
79
|
-
1536: { perPage: settings.itemsPerView["2xl"] }
|
|
80
|
-
},
|
|
175
|
+
breakpoints,
|
|
81
176
|
reducedMotion: {
|
|
82
177
|
speed: 0,
|
|
83
178
|
rewindSpeed: 0,
|
|
@@ -99,4 +194,65 @@ export function carouselOptions(settings) {
|
|
|
99
194
|
}
|
|
100
195
|
};
|
|
101
196
|
}
|
|
197
|
+
const GAP = "var(--flowpress-carousel-gap)";
|
|
198
|
+
/**
|
|
199
|
+
* Static geometry shared by the frontend before Splide mounts and by the block editor: the same
|
|
200
|
+
* slide widths, peeks and centring Splide applies at rest. Percentages in `slide` and `shift`
|
|
201
|
+
* resolve against the list, those in `edge` against the carousel root.
|
|
202
|
+
*/
|
|
203
|
+
export function carouselLayout(settings) {
|
|
204
|
+
const style = {
|
|
205
|
+
"--flowpress-carousel-gap": `${settings.gap}px`
|
|
206
|
+
};
|
|
207
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
208
|
+
const count = perPage(settings, breakpoint);
|
|
209
|
+
const width = fixedWidth(settings, breakpoint);
|
|
210
|
+
const { left, right } = padding(settings, breakpoint);
|
|
211
|
+
const start = left === 0 ? "0px" : String(left);
|
|
212
|
+
const end = right === 0 ? "0px" : String(right);
|
|
213
|
+
const slide = width || `calc((100% + ${GAP}) / ${count} - ${GAP})`;
|
|
214
|
+
const centre = settings.focus === "center" && settings.effect !== "fade";
|
|
215
|
+
const offset = settings.startIndex > 0
|
|
216
|
+
? ` - ${settings.startIndex} * (${slide} + ${GAP})`
|
|
217
|
+
: "";
|
|
218
|
+
// Width of the list once the root's peeks are removed, as a root percentage.
|
|
219
|
+
const list = `(100% - ${start} - ${end})`;
|
|
220
|
+
const rootSlide = width || `((${list} + ${GAP}) / ${count} - ${GAP})`;
|
|
221
|
+
style[`--flowpress-carousel-${breakpoint}`] = String(count);
|
|
222
|
+
style[`--flowpress-carousel-slide-${breakpoint}`] = slide;
|
|
223
|
+
style[`--flowpress-carousel-peek-start-${breakpoint}`] = start;
|
|
224
|
+
style[`--flowpress-carousel-peek-end-${breakpoint}`] = end;
|
|
225
|
+
style[`--flowpress-carousel-shift-${breakpoint}`] = centre || offset
|
|
226
|
+
? `calc(${centre ? `(100% - ${slide}) / 2` : "0px"}${offset})`
|
|
227
|
+
: "0px";
|
|
228
|
+
style[`--flowpress-carousel-edge-${breakpoint}`] = centre
|
|
229
|
+
? `calc(${start} + (${list} - ${rootSlide}) / 2 - ${GAP})`
|
|
230
|
+
: `calc(${end} - ${GAP})`;
|
|
231
|
+
}
|
|
232
|
+
if (settings.slideAspectRatio)
|
|
233
|
+
style["--flowpress-carousel-aspect"] = settings.slideAspectRatio;
|
|
234
|
+
if (settings.controlsTone) {
|
|
235
|
+
style["--flowpress-carousel-control-bg"] =
|
|
236
|
+
`var(--sf-color-${settings.controlsTone}-${settings.controlsIntensity || "base"}-default-background)`;
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
style,
|
|
240
|
+
data: {
|
|
241
|
+
"data-focus": settings.effect === "fade" ? "start" : settings.focus,
|
|
242
|
+
"data-effect": settings.effect,
|
|
243
|
+
"data-arrows": settings.arrowsPosition,
|
|
244
|
+
"data-arrows-mobile": settings.arrowsPositionMobile,
|
|
245
|
+
"data-arrows-shape": settings.arrowsShape,
|
|
246
|
+
"data-arrows-size": settings.arrowsSize,
|
|
247
|
+
"data-pagination": settings.paginationStyle,
|
|
248
|
+
"data-pagination-position": settings.paginationPosition,
|
|
249
|
+
...(settings.slideAspectRatio ? { "data-aspect": "" } : {}),
|
|
250
|
+
...(settings.equalHeight ? { "data-equal-height": "" } : {})
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Inline `style` text of a layout. */
|
|
255
|
+
export function carouselStyleText(layout) {
|
|
256
|
+
return Object.entries(layout.style).map(([name, value]) => `${name}:${value}`).join(";");
|
|
257
|
+
}
|
|
102
258
|
//# sourceMappingURL=carousel.js.map
|
package/dist/carousel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,CAA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nC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE;YACX,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE;YAC1C,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE;YAC1C,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE;YAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE;YAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;SAChD;QACD,aAAa,EAAE;YACb,KAAK,EAAE,CAAC;YACR,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE,OAAO;SAClB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,sBAAsB;YAC7B,IAAI,EAAE,sBAAsB;YAC5B,MAAM,EAAE,mBAAmB;YAC3B,KAAK,EAAE,oBAAoB;YAC3B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,gBAAgB;YACvB,QAAQ,EAAE,WAAW;YACrB,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,iCAAiC;YACzC,UAAU,EAAE,UAAU;SACvB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Options } from \"@splidejs/splide\";\n\nconst BREAKPOINTS = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n\nexport interface FlowpressCarouselSettings {\n ariaLabel: string;\n itemsPerView: Record<(typeof BREAKPOINTS)[number], number>;\n itemsPerMove: number;\n gap: number;\n showArrows: boolean;\n showPagination: boolean;\n drag: boolean;\n keyboard: boolean;\n autoplay: boolean;\n autoplayInterval: number;\n pauseOnHover: boolean;\n pauseOnFocus: boolean;\n loop: boolean;\n speed: number;\n}\n\nfunction boundedNumber(\n value: unknown,\n fallback: number,\n min: number,\n max: number\n): number {\n if (value === \"\" || value === null || value === undefined || value === \"inherit\") {\n return fallback;\n }\n const numeric = Number(value);\n return Number.isFinite(numeric)\n ? Math.min(max, Math.max(min, Math.round(numeric)))\n : fallback;\n}\n\nfunction booleanValue(value: unknown, fallback: boolean): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nexport function carouselSettings(\n attributes: Record<string, unknown>\n): FlowpressCarouselSettings {\n const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, \"2xl\": 3 };\n const values = {} as FlowpressCarouselSettings[\"itemsPerView\"];\n let inherited = defaults.base;\n for (const breakpoint of BREAKPOINTS) {\n const suffix = breakpoint === \"base\"\n ? \"Base\"\n : breakpoint === \"2xl\"\n ? \"2xl\"\n : breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);\n const raw = attributes[`itemsPerView${suffix}`];\n const fallback = breakpoint !== \"base\" && (raw === \"\" || raw === \"inherit\")\n ? inherited\n : breakpoint === \"base\"\n ? defaults.base\n : breakpoint === \"md\" || breakpoint === \"lg\"\n ? defaults[breakpoint]\n : inherited;\n const value = boundedNumber(\n raw,\n fallback,\n 1,\n 12\n );\n values[breakpoint] = value;\n inherited = value;\n }\n\n const ariaLabel = typeof attributes.ariaLabel === \"string\"\n ? attributes.ariaLabel.trim()\n : \"\";\n\n return {\n ariaLabel: ariaLabel || \"Carosello\",\n itemsPerView: values,\n itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),\n gap: boundedNumber(attributes.gap, 24, 0, 128),\n showArrows: booleanValue(attributes.showArrows, true),\n showPagination: booleanValue(attributes.showPagination, true),\n drag: booleanValue(attributes.drag, true),\n keyboard: booleanValue(attributes.keyboard, true),\n autoplay: booleanValue(attributes.autoplay, false),\n autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),\n pauseOnHover: booleanValue(attributes.pauseOnHover, true),\n pauseOnFocus: booleanValue(attributes.pauseOnFocus, true),\n loop: booleanValue(attributes.loop, false),\n speed: boundedNumber(attributes.speed, 400, 0, 5000)\n };\n}\n\nexport function carouselOptions(settings: FlowpressCarouselSettings): Options {\n return {\n label: settings.ariaLabel,\n type: settings.loop ? \"loop\" : \"slide\",\n perPage: settings.itemsPerView.base,\n perMove: settings.itemsPerMove,\n gap: `${settings.gap}px`,\n arrows: settings.showArrows,\n pagination: settings.showPagination,\n drag: settings.drag,\n keyboard: settings.keyboard ? \"focused\" : false,\n autoplay: settings.autoplay,\n interval: settings.autoplayInterval,\n pauseOnHover: settings.pauseOnHover,\n pauseOnFocus: settings.pauseOnFocus,\n speed: settings.speed,\n live: true,\n mediaQuery: \"min\",\n breakpoints: {\n 640: { perPage: settings.itemsPerView.sm },\n 768: { perPage: settings.itemsPerView.md },\n 1024: { perPage: settings.itemsPerView.lg },\n 1280: { perPage: settings.itemsPerView.xl },\n 1536: { perPage: settings.itemsPerView[\"2xl\"] }\n },\n reducedMotion: {\n speed: 0,\n rewindSpeed: 0,\n autoplay: \"pause\"\n },\n i18n: {\n prev: \"Slide precedente\",\n next: \"Slide successiva\",\n first: \"Vai alla prima slide\",\n last: \"Vai all'ultima slide\",\n slideX: \"Vai alla slide %s\",\n pageX: \"Vai alla pagina %s\",\n play: \"Avvia autoplay\",\n pause: \"Pausa autoplay\",\n carousel: \"carosello\",\n slide: \"slide\",\n select: \"Seleziona una slide da mostrare\",\n slideLabel: \"%s di %s\"\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAGrF,sFAAsF;AACtF,MAAM,iBAAiB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AE,QAAQ,CAAC,kBAAkB;YACvD,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7D;KACF,CAAC;AACJ,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import type { Options } from \"@splidejs/splide\";\n\nexport const CAROUSEL_BREAKPOINTS = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\nexport type CarouselBreakpoint = (typeof CAROUSEL_BREAKPOINTS)[number];\n\n/** Splide breakpoints (min-width, px); the static CSS uses the same values in rem. */\nconst BREAKPOINT_WIDTHS: Record<Exclude<CarouselBreakpoint, \"base\">, number> = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536\n};\n\nconst ARROWS_POSITIONS = [\"top\", \"top-end\", \"sides\", \"edges\", \"outside\", \"bottom\", \"bottom-end\"] as const;\nconst ARROWS_MOBILE_POSITIONS = [\"same\", \"bottom\", \"hidden\"] as const;\nconst ARROWS_SHAPES = [\"circle\", \"rounded\", \"square\"] as const;\nconst ARROWS_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst PAGINATION_STYLES = [\"dots\", \"bars\", \"fraction\"] as const;\nconst PAGINATION_POSITIONS = [\"below\", \"overlay\"] as const;\nconst ASPECT_RATIOS = [\"1/1\", \"4/5\", \"3/4\", \"2/3\", \"4/3\", \"3/2\", \"16/9\", \"21/9\"] as const;\n\n/** Peek keyword aligned with the StyleFlow container padding. */\nexport const CAROUSEL_CONTAINER_PEEK = \"var(--sf-layout-container-comfortable-padding-x, 2rem)\";\n\nexport interface FlowpressCarouselSettings {\n ariaLabel: string;\n itemsPerView: Record<CarouselBreakpoint, number>;\n /** Fixed slide width per breakpoint; \"\" sizes slides from `itemsPerView`. */\n slideWidth: Record<CarouselBreakpoint, string>;\n /** Visible part of the neighbouring slides per breakpoint, as a CSS length (\"0\" for none). */\n peek: Record<CarouselBreakpoint, string>;\n focus: \"start\" | \"center\";\n itemsPerMove: number;\n gap: number;\n slideAspectRatio: string;\n equalHeight: boolean;\n effect: \"slide\" | \"fade\";\n loop: boolean;\n rewind: boolean;\n startIndex: number;\n speed: number;\n drag: boolean;\n dragFree: boolean;\n keyboard: boolean;\n wheel: boolean;\n showArrows: boolean;\n arrowsPosition: (typeof ARROWS_POSITIONS)[number];\n arrowsPositionMobile: (typeof ARROWS_MOBILE_POSITIONS)[number];\n arrowsShape: (typeof ARROWS_SHAPES)[number];\n arrowsSize: (typeof ARROWS_SIZES)[number];\n showPagination: boolean;\n paginationStyle: (typeof PAGINATION_STYLES)[number];\n paginationPosition: (typeof PAGINATION_POSITIONS)[number];\n /** StyleFlow tone and intensity of the controls' background; \"\" keeps the carousel's context. */\n controlsTone: string;\n controlsIntensity: string;\n autoplay: boolean;\n autoplayInterval: number;\n pauseOnHover: boolean;\n pauseOnFocus: boolean;\n}\n\nexport interface FlowpressCarouselLayout {\n /** Custom properties for the carousel root, read by the shared carousel stylesheet. */\n style: Record<string, string>;\n /** `data-*` attributes for the carousel root. */\n data: Record<string, string>;\n}\n\nfunction boundedNumber(\n value: unknown,\n fallback: number,\n min: number,\n max: number,\n decimals = 0\n): number {\n if (value === \"\" || value === null || value === undefined || value === \"inherit\") {\n return fallback;\n }\n const numeric = Number(value);\n const factor = 10 ** decimals;\n return Number.isFinite(numeric)\n ? Math.min(max, Math.max(min, Math.round(numeric * factor) / factor))\n : fallback;\n}\n\nfunction booleanValue(value: unknown, fallback: boolean): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nfunction choice<T extends string>(value: unknown, choices: readonly T[], fallback: T): T {\n return choices.includes(value as T) ? (value as T) : fallback;\n}\n\nfunction token(value: unknown): string {\n return typeof value === \"string\" && /^[a-z0-9-]+$/.test(value) && value !== \"inherit\" ? value : \"\";\n}\n\nconst suffix = (breakpoint: CarouselBreakpoint) => breakpoint === \"base\"\n ? \"Base\"\n : breakpoint === \"2xl\"\n ? \"2xl\"\n : breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);\n\nconst isLength = (value: unknown): value is string =>\n typeof value === \"string\" && /^(?:0|\\d+(?:\\.\\d+)?(?:rem|px|%|vw))$/.test(value);\n\n/**\n * Resolves a responsive string field: an empty value inherits from the smaller breakpoint and an\n * invalid one does too. `reset` (if given) is the value that clears an inherited setting.\n */\nfunction responsiveStrings(\n attributes: Record<string, unknown>,\n name: string,\n base: string,\n accept: (value: unknown) => value is string,\n reset?: string\n): Record<CarouselBreakpoint, string> {\n const values = {} as Record<CarouselBreakpoint, string>;\n let inherited = base;\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const raw = attributes[`${name}${suffix(breakpoint)}`];\n const value = reset !== undefined && raw === reset\n ? \"\"\n : accept(raw)\n ? raw\n : breakpoint === \"base\"\n ? base\n : inherited;\n values[breakpoint] = value;\n inherited = value;\n }\n return values;\n}\n\nconst isPeek = (value: unknown): value is string => value === \"container\" || isLength(value);\n\nexport function carouselSettings(\n attributes: Record<string, unknown>\n): FlowpressCarouselSettings {\n const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, \"2xl\": 3 };\n const values = {} as FlowpressCarouselSettings[\"itemsPerView\"];\n let inherited = defaults.base;\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const raw = attributes[`itemsPerView${suffix(breakpoint)}`];\n const fallback = breakpoint !== \"base\" && (raw === \"\" || raw === \"inherit\")\n ? inherited\n : breakpoint === \"base\"\n ? defaults.base\n : breakpoint === \"md\" || breakpoint === \"lg\"\n ? defaults[breakpoint]\n : inherited;\n const value = boundedNumber(raw, fallback, 1, 12, 2);\n values[breakpoint] = value;\n inherited = value;\n }\n\n const ariaLabel = typeof attributes.ariaLabel === \"string\"\n ? attributes.ariaLabel.trim()\n : \"\";\n const aspect = attributes.slideAspectRatio;\n\n return {\n ariaLabel: ariaLabel || \"Carosello\",\n itemsPerView: values,\n slideWidth: responsiveStrings(attributes, \"slideWidth\", \"\", isLength, \"auto\"),\n peek: responsiveStrings(attributes, \"peek\", \"0\", isPeek),\n focus: choice(attributes.focus, [\"start\", \"center\"] as const, \"start\"),\n itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),\n gap: boundedNumber(attributes.gap, 24, 0, 128),\n slideAspectRatio: ASPECT_RATIOS.includes(aspect as never) ? String(aspect) : \"\",\n equalHeight: booleanValue(attributes.equalHeight, false),\n effect: choice(attributes.effect, [\"slide\", \"fade\"] as const, \"slide\"),\n loop: booleanValue(attributes.loop, false),\n rewind: booleanValue(attributes.rewind, false),\n startIndex: boundedNumber(attributes.startIndex, 0, 0, 99),\n speed: boundedNumber(attributes.speed, 400, 0, 5000),\n drag: booleanValue(attributes.drag, true),\n dragFree: booleanValue(attributes.dragFree, false),\n keyboard: booleanValue(attributes.keyboard, true),\n wheel: booleanValue(attributes.wheel, false),\n showArrows: booleanValue(attributes.showArrows, true),\n arrowsPosition: choice(attributes.arrowsPosition, ARROWS_POSITIONS, \"top\"),\n arrowsPositionMobile: choice(attributes.arrowsPositionMobile, ARROWS_MOBILE_POSITIONS, \"same\"),\n arrowsShape: choice(attributes.arrowsShape, ARROWS_SHAPES, \"circle\"),\n arrowsSize: choice(attributes.arrowsSize, ARROWS_SIZES, \"md\"),\n showPagination: booleanValue(attributes.showPagination, true),\n paginationStyle: choice(attributes.paginationStyle, PAGINATION_STYLES, \"dots\"),\n paginationPosition: choice(attributes.paginationPosition, PAGINATION_POSITIONS, \"below\"),\n controlsTone: token(attributes.controlsTone),\n controlsIntensity: token(attributes.controlsIntensity),\n autoplay: booleanValue(attributes.autoplay, false),\n autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),\n pauseOnHover: booleanValue(attributes.pauseOnHover, true),\n pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)\n };\n}\n\n/** CSS length of a peek setting. */\nexport function carouselPeekLength(peek: string): string {\n return peek === \"container\" ? CAROUSEL_CONTAINER_PEEK : peek;\n}\n\nfunction perPage(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint): number {\n return settings.effect === \"fade\" ? 1 : settings.itemsPerView[breakpoint];\n}\n\nfunction fixedWidth(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint): string {\n return settings.effect === \"fade\" ? \"\" : settings.slideWidth[breakpoint];\n}\n\nfunction padding(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint) {\n const peek = settings.effect === \"fade\" ? \"0\" : carouselPeekLength(settings.peek[breakpoint]);\n if (peek === \"0\") return { left: 0, right: 0 };\n return settings.focus === \"center\" ? { left: peek, right: peek } : { left: 0, right: peek };\n}\n\n/**\n * Splide options. Options for settings that keep their previous defaults are left out, so a\n * carousel saved with the original contract mounts with exactly the options it had before.\n */\nexport function carouselOptions(settings: FlowpressCarouselSettings): Options {\n const fade = settings.effect === \"fade\";\n const usesWidth = CAROUSEL_BREAKPOINTS.some((breakpoint) => fixedWidth(settings, breakpoint) !== \"\");\n const usesPadding = CAROUSEL_BREAKPOINTS.some((breakpoint) => padding(settings, breakpoint).right !== 0);\n const sizing = (breakpoint: CarouselBreakpoint) => ({\n perPage: perPage(settings, breakpoint),\n ...(usesWidth ? { fixedWidth: fixedWidth(settings, breakpoint) || 0 } : {}),\n ...(usesPadding ? { padding: padding(settings, breakpoint) } : {})\n });\n const breakpoints = Object.fromEntries(\n (Object.entries(BREAKPOINT_WIDTHS) as Array<[Exclude<CarouselBreakpoint, \"base\">, number]>)\n .map(([breakpoint, width]) => [width, sizing(breakpoint)])\n );\n\n return {\n label: settings.ariaLabel,\n type: fade ? \"fade\" : settings.loop ? \"loop\" : \"slide\",\n ...sizing(\"base\"),\n perMove: settings.itemsPerMove,\n gap: `${settings.gap}px`,\n ...(settings.focus === \"center\" && !fade ? { focus: \"center\" as const, trimSpace: false } : {}),\n ...(settings.rewind || (fade && settings.loop) ? { rewind: true } : {}),\n ...(settings.startIndex > 0 ? { start: settings.startIndex } : {}),\n arrows: settings.showArrows,\n pagination: settings.showPagination && settings.paginationStyle !== \"fraction\",\n drag: settings.drag && settings.dragFree ? \"free\" : settings.drag,\n ...(settings.drag && settings.dragFree ? { snap: true } : {}),\n keyboard: settings.keyboard ? \"focused\" : false,\n ...(settings.wheel ? { wheel: true } : {}),\n autoplay: settings.autoplay,\n interval: settings.autoplayInterval,\n pauseOnHover: settings.pauseOnHover,\n pauseOnFocus: settings.pauseOnFocus,\n speed: settings.speed,\n live: true,\n mediaQuery: \"min\",\n breakpoints,\n reducedMotion: {\n speed: 0,\n rewindSpeed: 0,\n autoplay: \"pause\"\n },\n i18n: {\n prev: \"Slide precedente\",\n next: \"Slide successiva\",\n first: \"Vai alla prima slide\",\n last: \"Vai all'ultima slide\",\n slideX: \"Vai alla slide %s\",\n pageX: \"Vai alla pagina %s\",\n play: \"Avvia autoplay\",\n pause: \"Pausa autoplay\",\n carousel: \"carosello\",\n slide: \"slide\",\n select: \"Seleziona una slide da mostrare\",\n slideLabel: \"%s di %s\"\n }\n };\n}\n\nconst GAP = \"var(--flowpress-carousel-gap)\";\n\n/**\n * Static geometry shared by the frontend before Splide mounts and by the block editor: the same\n * slide widths, peeks and centring Splide applies at rest. Percentages in `slide` and `shift`\n * resolve against the list, those in `edge` against the carousel root.\n */\nexport function carouselLayout(settings: FlowpressCarouselSettings): FlowpressCarouselLayout {\n const style: Record<string, string> = {\n \"--flowpress-carousel-gap\": `${settings.gap}px`\n };\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const count = perPage(settings, breakpoint);\n const width = fixedWidth(settings, breakpoint);\n const { left, right } = padding(settings, breakpoint);\n const start = left === 0 ? \"0px\" : String(left);\n const end = right === 0 ? \"0px\" : String(right);\n const slide = width || `calc((100% + ${GAP}) / ${count} - ${GAP})`;\n const centre = settings.focus === \"center\" && settings.effect !== \"fade\";\n const offset = settings.startIndex > 0\n ? ` - ${settings.startIndex} * (${slide} + ${GAP})`\n : \"\";\n // Width of the list once the root's peeks are removed, as a root percentage.\n const list = `(100% - ${start} - ${end})`;\n const rootSlide = width || `((${list} + ${GAP}) / ${count} - ${GAP})`;\n\n style[`--flowpress-carousel-${breakpoint}`] = String(count);\n style[`--flowpress-carousel-slide-${breakpoint}`] = slide;\n style[`--flowpress-carousel-peek-start-${breakpoint}`] = start;\n style[`--flowpress-carousel-peek-end-${breakpoint}`] = end;\n style[`--flowpress-carousel-shift-${breakpoint}`] = centre || offset\n ? `calc(${centre ? `(100% - ${slide}) / 2` : \"0px\"}${offset})`\n : \"0px\";\n style[`--flowpress-carousel-edge-${breakpoint}`] = centre\n ? `calc(${start} + (${list} - ${rootSlide}) / 2 - ${GAP})`\n : `calc(${end} - ${GAP})`;\n }\n if (settings.slideAspectRatio) style[\"--flowpress-carousel-aspect\"] = settings.slideAspectRatio;\n if (settings.controlsTone) {\n style[\"--flowpress-carousel-control-bg\"] =\n `var(--sf-color-${settings.controlsTone}-${settings.controlsIntensity || \"base\"}-default-background)`;\n }\n\n return {\n style,\n data: {\n \"data-focus\": settings.effect === \"fade\" ? \"start\" : settings.focus,\n \"data-effect\": settings.effect,\n \"data-arrows\": settings.arrowsPosition,\n \"data-arrows-mobile\": settings.arrowsPositionMobile,\n \"data-arrows-shape\": settings.arrowsShape,\n \"data-arrows-size\": settings.arrowsSize,\n \"data-pagination\": settings.paginationStyle,\n \"data-pagination-position\": settings.paginationPosition,\n ...(settings.slideAspectRatio ? { \"data-aspect\": \"\" } : {}),\n ...(settings.equalHeight ? { \"data-equal-height\": \"\" } : {})\n }\n };\n}\n\n/** Inline `style` text of a layout. */\nexport function carouselStyleText(layout: FlowpressCarouselLayout): string {\n return Object.entries(layout.style).map(([name, value]) => `${name}:${value}`).join(\";\");\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FlowpressCapabilities, FlowpressContent, FlowpressRoute } from "./types.js";
|
|
1
|
+
import type { FlowpressCapabilities, FlowpressCompositionV1, FlowpressContent, FlowpressRoute } from "./types.js";
|
|
2
2
|
export interface FlowpressGraphqlIssue {
|
|
3
3
|
message?: string;
|
|
4
4
|
extensions?: {
|
|
@@ -7,11 +7,24 @@ export interface FlowpressGraphqlIssue {
|
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
/** Store only successful anonymous query data; implementations may deduplicate in flight. */
|
|
11
|
+
export interface FlowpressRequestStore {
|
|
12
|
+
getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_GRAPHQL_TIMEOUT_MS = 15000;
|
|
15
|
+
export declare const DEFAULT_GRAPHQL_RETRIES = 1;
|
|
16
|
+
export declare const DEFAULT_GRAPHQL_RETRY_DELAY_MS = 1000;
|
|
10
17
|
export interface FlowpressClientOptions {
|
|
11
18
|
endpoint: string;
|
|
19
|
+
/** Per-attempt limit; every retry gets a fresh timer. */
|
|
12
20
|
timeoutMs?: number;
|
|
21
|
+
/** Extra attempts for queries after a timeout, network error or 429/502/503/504. */
|
|
22
|
+
retries?: number;
|
|
23
|
+
/** First backoff; it doubles on every further retry. */
|
|
24
|
+
retryDelayMs?: number;
|
|
13
25
|
headers?: Record<string, string>;
|
|
14
26
|
debug?: boolean;
|
|
27
|
+
requestStore?: FlowpressRequestStore;
|
|
15
28
|
}
|
|
16
29
|
export declare class FlowpressGraphqlError extends Error {
|
|
17
30
|
readonly status?: number | undefined;
|
|
@@ -23,13 +36,32 @@ export declare class FlowpressGraphqlError extends Error {
|
|
|
23
36
|
export declare class FlowpressClient {
|
|
24
37
|
readonly endpoint: string;
|
|
25
38
|
readonly timeoutMs: number;
|
|
39
|
+
readonly retries: number;
|
|
40
|
+
readonly retryDelayMs: number;
|
|
26
41
|
readonly headers: Record<string, string>;
|
|
27
42
|
readonly debug: boolean;
|
|
43
|
+
readonly requestStore: FlowpressRequestStore | undefined;
|
|
28
44
|
constructor(options: FlowpressClientOptions);
|
|
29
45
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
46
|
+
getContentRevision(): Promise<string>;
|
|
47
|
+
private requestUncached;
|
|
48
|
+
private requestOnce;
|
|
30
49
|
getCapabilities(): Promise<FlowpressCapabilities>;
|
|
31
50
|
getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null>;
|
|
32
51
|
getRoutes(locale?: string): Promise<FlowpressRoute[]>;
|
|
33
|
-
|
|
52
|
+
getComposition(uri: string, locale?: string, options?: {
|
|
53
|
+
includeContent?: boolean;
|
|
54
|
+
}): Promise<FlowpressCompositionV1 | null>;
|
|
55
|
+
/** Site Editor already returns route and content in its composition. No
|
|
56
|
+
* route preflight, retries or cross-request cache are needed for previews.
|
|
57
|
+
*/
|
|
58
|
+
getPage(uri: string, options?: {
|
|
59
|
+
locale?: string;
|
|
60
|
+
includeContent?: boolean;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
route: FlowpressRoute;
|
|
63
|
+
content: FlowpressContent | null;
|
|
64
|
+
composition: FlowpressCompositionV1;
|
|
65
|
+
} | null>;
|
|
34
66
|
}
|
|
35
67
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EACh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