@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,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser controller for morphing blobs. The server always renders a correct
|
|
3
|
+
* static shape; this only animates the `d` of the clip and outline paths.
|
|
4
|
+
*
|
|
5
|
+
* - `auto`: after each pause, morph into a random target and repeat.
|
|
6
|
+
* - `hover`: morph into a random target while hovered/focused, back on leave.
|
|
7
|
+
*
|
|
8
|
+
* One shared requestAnimationFrame loop drives every blob. Morphing pauses
|
|
9
|
+
* off-screen and in hidden tabs, and follows the shared motion preference
|
|
10
|
+
* (OS `prefers-reduced-motion`, overridable from the accessibility panel): with
|
|
11
|
+
* motion reduced every blob rests on its authored shape and never morphs, and
|
|
12
|
+
* it picks up again, live, when motion is allowed.
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
getMotionPreference,
|
|
16
|
+
subscribeMotionPreference,
|
|
17
|
+
type MotionPreference,
|
|
18
|
+
} from "../motion-preference.js";
|
|
19
|
+
import { BLOB_BOX, BLOB_VARIANTS } from "./blob-shapes.generated.js";
|
|
20
|
+
import { pickMorphTarget, morphConfigFromDataset, type BlobMorphConfig } from "./config.js";
|
|
21
|
+
import { easeInOutCubic, lerpShape, shapeToPath, type BlobShape } from "./geometry.js";
|
|
22
|
+
|
|
23
|
+
export const BLOB_ROOT_SELECTOR = "[data-sf-blob]";
|
|
24
|
+
export const CARD_ANIMATION_CLASS = "card__animation";
|
|
25
|
+
export const CARD_ANIMATION_TRIGGER_SELECTOR = ".card__has_animations";
|
|
26
|
+
const INITIALIZED = "blobReady";
|
|
27
|
+
|
|
28
|
+
interface Transition {
|
|
29
|
+
startedAt: number;
|
|
30
|
+
from: { fill: BlobShape; ring: BlobShape };
|
|
31
|
+
to: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class MorphingBlob {
|
|
35
|
+
private fill: BlobShape;
|
|
36
|
+
private ring: BlobShape;
|
|
37
|
+
private settled: number;
|
|
38
|
+
private transition: Transition | null = null;
|
|
39
|
+
private timer: number | undefined;
|
|
40
|
+
private visible = true;
|
|
41
|
+
private hovered = false;
|
|
42
|
+
private allowed = false;
|
|
43
|
+
private readonly clipPath: SVGPathElement | null;
|
|
44
|
+
private readonly ringPath: SVGPathElement | null;
|
|
45
|
+
private readonly disposers: Array<() => void> = [];
|
|
46
|
+
|
|
47
|
+
constructor(
|
|
48
|
+
private readonly root: HTMLElement,
|
|
49
|
+
private readonly config: BlobMorphConfig,
|
|
50
|
+
private readonly scheduler: Scheduler,
|
|
51
|
+
) {
|
|
52
|
+
const base = BLOB_VARIANTS[config.base] ?? (BLOB_VARIANTS[0] as (typeof BLOB_VARIANTS)[number]);
|
|
53
|
+
this.fill = base.fill;
|
|
54
|
+
this.ring = base.ring;
|
|
55
|
+
this.settled = config.base;
|
|
56
|
+
this.clipPath = root.querySelector<SVGPathElement>("[data-blob-clip-path]");
|
|
57
|
+
this.ringPath = root.querySelector<SVGPathElement>("[data-blob-ring-path]");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
start(): void {
|
|
61
|
+
if (this.config.mode === "auto") {
|
|
62
|
+
this.watchVisibility();
|
|
63
|
+
this.queueNext();
|
|
64
|
+
} else if (this.config.mode === "hover") {
|
|
65
|
+
// A marked blob delegates its hover/focus state to the closest card.
|
|
66
|
+
// Unmarked blobs keep their original, local hover behaviour.
|
|
67
|
+
const card = this.root.classList.contains(CARD_ANIMATION_CLASS)
|
|
68
|
+
? this.root.closest<HTMLElement>(CARD_ANIMATION_TRIGGER_SELECTOR)
|
|
69
|
+
: null;
|
|
70
|
+
const area = card ?? this.root.querySelector<HTMLElement>("[data-blob-shape]") ?? this.root;
|
|
71
|
+
this.listen(area, "pointerenter", () => this.hover(true));
|
|
72
|
+
this.listen(area, "pointerleave", () => this.hover(false));
|
|
73
|
+
this.listen(area, "focusin", () => this.hover(true));
|
|
74
|
+
this.listen(area, "focusout", (event) => {
|
|
75
|
+
const next = (event as FocusEvent).relatedTarget;
|
|
76
|
+
if (!(next instanceof Node) || !area.contains(next)) this.hover(false);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
destroy(): void {
|
|
82
|
+
window.clearTimeout(this.timer);
|
|
83
|
+
this.scheduler.remove(this);
|
|
84
|
+
this.disposers.splice(0).forEach((dispose) => dispose());
|
|
85
|
+
delete this.root.dataset[INITIALIZED];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Motion allowed: resume the automatic cycle. Motion reduced: drop back to
|
|
90
|
+
* the authored shape at once, and stay there until allowed again.
|
|
91
|
+
*/
|
|
92
|
+
setMotionAllowed(allowed: boolean): void {
|
|
93
|
+
if (this.allowed === allowed) return;
|
|
94
|
+
this.allowed = allowed;
|
|
95
|
+
if (allowed) {
|
|
96
|
+
this.queueNext();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
window.clearTimeout(this.timer);
|
|
100
|
+
this.scheduler.remove(this);
|
|
101
|
+
this.transition = null;
|
|
102
|
+
this.settled = this.config.base;
|
|
103
|
+
const base = BLOB_VARIANTS[this.config.base];
|
|
104
|
+
if (base) this.apply(base.fill, base.ring);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Jump to the resting state and stop: used off-screen and in hidden tabs. */
|
|
108
|
+
freeze(): void {
|
|
109
|
+
window.clearTimeout(this.timer);
|
|
110
|
+
this.scheduler.remove(this);
|
|
111
|
+
if (this.transition) {
|
|
112
|
+
const target = BLOB_VARIANTS[this.transition.to];
|
|
113
|
+
if (target) this.apply(target.fill, target.ring);
|
|
114
|
+
this.settled = this.transition.to;
|
|
115
|
+
this.transition = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Advance the active transition. Returns `false` once it has finished. */
|
|
120
|
+
step(now: number): boolean {
|
|
121
|
+
const transition = this.transition;
|
|
122
|
+
const target = transition ? BLOB_VARIANTS[transition.to] : undefined;
|
|
123
|
+
if (!transition || !target) return false;
|
|
124
|
+
const progress = Math.min(1, (now - transition.startedAt) / this.config.duration);
|
|
125
|
+
const eased = easeInOutCubic(progress);
|
|
126
|
+
this.apply(
|
|
127
|
+
lerpShape(transition.from.fill, target.fill, eased),
|
|
128
|
+
lerpShape(transition.from.ring, target.ring, eased),
|
|
129
|
+
);
|
|
130
|
+
if (progress < 1) return true;
|
|
131
|
+
this.settled = transition.to;
|
|
132
|
+
this.transition = null;
|
|
133
|
+
if (this.config.mode === "auto") this.queueNext();
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private listen(target: EventTarget, type: string, handler: (event: Event) => void): void {
|
|
138
|
+
target.addEventListener(type, handler);
|
|
139
|
+
this.disposers.push(() => target.removeEventListener(type, handler));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private watchVisibility(): void {
|
|
143
|
+
if (typeof IntersectionObserver === "function") {
|
|
144
|
+
const observer = new IntersectionObserver((entries) => {
|
|
145
|
+
this.visible = entries[entries.length - 1]?.isIntersecting ?? true;
|
|
146
|
+
if (this.visible) this.queueNext();
|
|
147
|
+
else this.freeze();
|
|
148
|
+
});
|
|
149
|
+
observer.observe(this.root);
|
|
150
|
+
this.disposers.push(() => observer.disconnect());
|
|
151
|
+
}
|
|
152
|
+
const onVisibility = () => (document.hidden ? this.freeze() : this.queueNext());
|
|
153
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
154
|
+
this.disposers.push(() => document.removeEventListener("visibilitychange", onVisibility));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private queueNext(): void {
|
|
158
|
+
window.clearTimeout(this.timer);
|
|
159
|
+
if (!this.allowed || this.config.mode !== "auto" || this.transition || !this.visible || document.hidden) return;
|
|
160
|
+
this.timer = window.setTimeout(() => {
|
|
161
|
+
const next = pickMorphTarget(this.config.targets, this.settled);
|
|
162
|
+
if (next !== null) this.morphTo(next);
|
|
163
|
+
}, this.config.interval);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private hover(active: boolean): void {
|
|
167
|
+
if (this.hovered === active) return;
|
|
168
|
+
this.hovered = active;
|
|
169
|
+
if (!this.allowed) return;
|
|
170
|
+
if (active) {
|
|
171
|
+
const next = pickMorphTarget(this.config.targets, this.config.base);
|
|
172
|
+
if (next !== null) this.morphTo(next);
|
|
173
|
+
} else {
|
|
174
|
+
this.morphTo(this.config.base);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private morphTo(index: number): void {
|
|
179
|
+
if (!this.allowed || !BLOB_VARIANTS[index]) return;
|
|
180
|
+
// Restarting mid-flight continues from the shape currently on screen.
|
|
181
|
+
this.transition = {
|
|
182
|
+
startedAt: performance.now(),
|
|
183
|
+
from: { fill: this.fill, ring: this.ring },
|
|
184
|
+
to: index,
|
|
185
|
+
};
|
|
186
|
+
this.scheduler.add(this);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private apply(fill: BlobShape, ring: BlobShape): void {
|
|
190
|
+
this.fill = fill;
|
|
191
|
+
this.ring = ring;
|
|
192
|
+
this.clipPath?.setAttribute("d", shapeToPath(fill, BLOB_BOX));
|
|
193
|
+
this.ringPath?.setAttribute("d", shapeToPath(ring, BLOB_BOX));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** A single rAF loop shared by every blob on the page. */
|
|
198
|
+
class Scheduler {
|
|
199
|
+
private readonly active = new Set<MorphingBlob>();
|
|
200
|
+
private frame = 0;
|
|
201
|
+
|
|
202
|
+
add(blob: MorphingBlob): void {
|
|
203
|
+
this.active.add(blob);
|
|
204
|
+
if (!this.frame) this.frame = requestAnimationFrame(this.tick);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
remove(blob: MorphingBlob): void {
|
|
208
|
+
this.active.delete(blob);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private readonly tick = (now: number): void => {
|
|
212
|
+
this.frame = 0;
|
|
213
|
+
for (const blob of [...this.active]) {
|
|
214
|
+
if (!blob.step(now)) this.active.delete(blob);
|
|
215
|
+
}
|
|
216
|
+
if (this.active.size > 0) this.frame = requestAnimationFrame(this.tick);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Wire every `[data-sf-blob]` with `data-blob-morph` set to `auto` or `hover`.
|
|
222
|
+
* Blobs are wired even while motion is reduced, so allowing it again starts
|
|
223
|
+
* them without a reload. Returns a disposer that restores the static state
|
|
224
|
+
* (for tests and view swaps).
|
|
225
|
+
*/
|
|
226
|
+
export function initializeSfBlobs(scope: ParentNode = document): () => void {
|
|
227
|
+
const scheduler = new Scheduler();
|
|
228
|
+
const blobs: MorphingBlob[] = [];
|
|
229
|
+
scope.querySelectorAll<HTMLElement>(BLOB_ROOT_SELECTOR).forEach((root) => {
|
|
230
|
+
if (root.dataset[INITIALIZED] === "true") return;
|
|
231
|
+
const config = morphConfigFromDataset(root.dataset, BLOB_VARIANTS.length);
|
|
232
|
+
if (config.mode === "none") return;
|
|
233
|
+
root.dataset[INITIALIZED] = "true";
|
|
234
|
+
const blob = new MorphingBlob(root, config, scheduler);
|
|
235
|
+
blobs.push(blob);
|
|
236
|
+
blob.start();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const applyPreference = (preference: MotionPreference) => {
|
|
240
|
+
blobs.forEach((blob) => blob.setMotionAllowed(preference === "full"));
|
|
241
|
+
};
|
|
242
|
+
applyPreference(getMotionPreference());
|
|
243
|
+
const unsubscribe = subscribeMotionPreference(applyPreference);
|
|
244
|
+
return () => {
|
|
245
|
+
unsubscribe();
|
|
246
|
+
blobs.forEach((blob) => blob.destroy());
|
|
247
|
+
};
|
|
248
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/geometry.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../../../src/astro/native/blob/geometry.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC","sourcesContent":["export * from \"@styleflow.app/flowpress-components/organic-geometry\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@styleflow.app/flowpress-components/organic-geometry";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique `<clipPath>` id per rendered blob. A module counter (instead of a
|
|
3
|
+
* random value) keeps the output deterministic for a given render order, and
|
|
4
|
+
* each blob needs its own clip because morphing rewrites the path's `d`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function nextBlobClipId(): string;
|
|
7
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/ids.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAGvC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let sequence = 0;
|
|
2
|
+
/**
|
|
3
|
+
* Unique `<clipPath>` id per rendered blob. A module counter (instead of a
|
|
4
|
+
* random value) keeps the output deterministic for a given render order, and
|
|
5
|
+
* each blob needs its own clip because morphing rewrites the path's `d`.
|
|
6
|
+
*/
|
|
7
|
+
export function nextBlobClipId() {
|
|
8
|
+
sequence += 1;
|
|
9
|
+
return `sf-blob-clip-${sequence}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../../src/astro/native/blob/ids.ts"],"names":[],"mappings":"AAAA,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,QAAQ,IAAI,CAAC,CAAC;IACd,OAAO,gBAAgB,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["let sequence = 0;\n\n/**\n * Unique `<clipPath>` id per rendered blob. A module counter (instead of a\n * random value) keeps the output deterministic for a given render order, and\n * each blob needs its own clip because morphing rewrites the path's `d`.\n */\nexport function nextBlobClipId(): string {\n sequence += 1;\n return `sf-blob-clip-${sequence}`;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let sequence = 0;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unique `<clipPath>` id per rendered blob. A module counter (instead of a
|
|
5
|
+
* random value) keeps the output deterministic for a given render order, and
|
|
6
|
+
* each blob needs its own clip because morphing rewrites the path's `d`.
|
|
7
|
+
*/
|
|
8
|
+
export function nextBlobClipId(): string {
|
|
9
|
+
sequence += 1;
|
|
10
|
+
return `sf-blob-clip-${sequence}`;
|
|
11
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* Blob: organic clipped container. Geometry only; colours come from Styleflow. */
|
|
2
|
+
.sf-blob {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: block;
|
|
5
|
+
inline-size: 100%;
|
|
6
|
+
aspect-ratio: var(--fp-blob-aspect, 1 / 1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sf-blob[data-blob-aspect="square"] {
|
|
10
|
+
aspect-ratio: 1 / 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sf-blob[data-blob-aspect="portrait"] {
|
|
14
|
+
aspect-ratio: 4 / 5;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sf-blob[data-blob-aspect="landscape"] {
|
|
18
|
+
aspect-ratio: 5 / 4;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Holds the <clipPath>; it must stay rendered (display: none disables clipping). */
|
|
22
|
+
.sf-blob__defs {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inline-size: 0;
|
|
25
|
+
block-size: 0;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sf-blob__shape {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: minmax(0, 1fr);
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
isolation: isolate;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sf-blob[data-blob-fit="cover"] .sf-blob__shape {
|
|
40
|
+
grid-auto-rows: minmax(0, 1fr);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sf-blob[data-blob-fit="cover"] .sf-blob__shape > * {
|
|
44
|
+
min-inline-size: 0;
|
|
45
|
+
min-block-size: 0;
|
|
46
|
+
inline-size: 100%;
|
|
47
|
+
block-size: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sf-blob[data-blob-fit="cover"] .sf-blob__shape :is(img, svg.flowpress-svg-media, picture, video) {
|
|
51
|
+
display: block;
|
|
52
|
+
inline-size: 100%;
|
|
53
|
+
block-size: 100%;
|
|
54
|
+
object-fit: cover;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sf-blob[data-blob-fit="center"] .sf-blob__shape {
|
|
58
|
+
place-content: center;
|
|
59
|
+
place-items: center;
|
|
60
|
+
text-align: center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* The outline sits above the content and may spill past the box edges. */
|
|
64
|
+
.sf-blob__ring {
|
|
65
|
+
position: absolute;
|
|
66
|
+
inset: 0;
|
|
67
|
+
display: block;
|
|
68
|
+
overflow: visible;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sf-blob__ring svg {
|
|
73
|
+
display: block;
|
|
74
|
+
inline-size: 100%;
|
|
75
|
+
block-size: 100%;
|
|
76
|
+
overflow: visible;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.sf-blob__ring path {
|
|
80
|
+
fill: none;
|
|
81
|
+
stroke: var(--sf-surface-default-background);
|
|
82
|
+
stroke-linejoin: round;
|
|
83
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* Geometry defaults, below Styleflow recipes and authored utilities.
|
|
2
|
+
Keep in sync with the corresponding FlowPress WordPress/Astro runtime. */
|
|
3
|
+
@layer theme, base, styleflow, components, utilities;
|
|
4
|
+
@layer base {
|
|
5
|
+
:where(.fp-native-group:not(.flowpress-button-template), .fp-grid, .flowpress-grid, .flowpress-column,
|
|
6
|
+
.flowpress-cover, .flowpress-hero, [data-flowpress-structural],
|
|
7
|
+
.wp-block-image, .wp-block-post-featured-image, [data-flowpress-image],
|
|
8
|
+
[data-type="sf/group"], [data-type="sf/flex"], [data-type="sf/section"],
|
|
9
|
+
[data-type="sf/grid"], [data-type="sf/column"], [data-type="sf/hero"],
|
|
10
|
+
[data-type="sf/image"]) {
|
|
11
|
+
width: 100%;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
/* Native flex sizing is an explicit editorial choice. */
|
|
16
|
+
:where([data-fp-flex-size="fit"], [data-fp-flex-size="fixed"]) { width: auto; }
|
|
17
|
+
:where([data-fp-flex-size="fixed"]) { flex-shrink: 0; }
|
|
18
|
+
:where(.wp-block-separator:not(.is-style-wide):not(.is-style-dots)) {
|
|
19
|
+
width: 100px;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
margin-inline: auto;
|
|
22
|
+
}
|
|
23
|
+
:where(.wp-block-separator.is-style-wide) { width: 100%; }
|
|
24
|
+
:where(.wp-block-image > a, .wp-block-post-featured-image > a) { width: 100%; }
|
|
25
|
+
:where(.wp-block-image > img, .wp-block-image > a > img,
|
|
26
|
+
.wp-block-image > svg, .wp-block-image > a > svg,
|
|
27
|
+
.wp-block-post-featured-image > img, .wp-block-post-featured-image > a > img,
|
|
28
|
+
.wp-block-post-featured-image > svg, .wp-block-post-featured-image > a > svg,
|
|
29
|
+
[data-flowpress-image] > img, [data-flowpress-image] > svg) {
|
|
30
|
+
width: 100%;
|
|
31
|
+
max-width: 100%;
|
|
32
|
+
height: auto;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type DynamicStyleflowProps, type FlowpressBlock, type StyleflowContract, type ResolveDynamicStyleflowOptions } from "../../index.js";
|
|
2
|
+
export interface ButtonTemplateDiagnostic {
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
blocking: boolean;
|
|
6
|
+
blockName?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ButtonTemplateData {
|
|
10
|
+
slug: string;
|
|
11
|
+
ref: number;
|
|
12
|
+
requested?: string | null;
|
|
13
|
+
blocks: FlowpressBlock[];
|
|
14
|
+
blockTypes?: unknown[];
|
|
15
|
+
stylesheets?: unknown[];
|
|
16
|
+
diagnostics?: ButtonTemplateDiagnostic[];
|
|
17
|
+
}
|
|
18
|
+
export interface ButtonTemplateControl {
|
|
19
|
+
/** Props of the focusable element (a, button or span). */
|
|
20
|
+
controlProps: Record<string, unknown>;
|
|
21
|
+
/** StyleFlow props of the template root, applied to the control. */
|
|
22
|
+
styleflowProps: DynamicStyleflowProps;
|
|
23
|
+
/** Blocks rendered inside the control. */
|
|
24
|
+
children: FlowpressBlock[];
|
|
25
|
+
}
|
|
26
|
+
export declare function buttonTemplateData(resolvedData: unknown): ButtonTemplateData | undefined;
|
|
27
|
+
export declare function buttonTemplateHasInteractiveBlocks(blocks: FlowpressBlock[]): boolean;
|
|
28
|
+
export declare function buttonTemplateControl(template: ButtonTemplateData, contract?: StyleflowContract, options?: ResolveDynamicStyleflowOptions): ButtonTemplateControl | undefined;
|
|
29
|
+
/** Diagnostic codes worth surfacing on the element outside production. */
|
|
30
|
+
export declare function buttonTemplateDiagnosticCodes(template: ButtonTemplateData | undefined, resolvedData: unknown): string;
|
|
31
|
+
//# sourceMappingURL=button-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-template.d.ts","sourceRoot":"","sources":["../../../src/astro/native/button-template.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACpC,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,oEAAoE;IACpE,cAAc,EAAE,qBAAqB,CAAC;IACtC,0CAA0C;IAC1C,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAID,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAOxF;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CASpF;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,OAAO,GAAE,8BAAmC,GAC3C,qBAAqB,GAAG,SAAS,CAcnC;AAED,0EAA0E;AAC1E,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAIrH"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Native button templates resolved by WordPress Core.
|
|
2
|
+
//
|
|
3
|
+
// The WordPress resolver attaches the selected template to core/button as
|
|
4
|
+
// `resolvedData.template`, resolved like a synced pattern. The template root
|
|
5
|
+
// Group becomes the focusable control, so StyleFlow interaction states
|
|
6
|
+
// (hover, focus-visible, disabled on data-interactive-priority) apply to the
|
|
7
|
+
// link itself; the root's children render inside it.
|
|
8
|
+
import { flowpressBlockHtmlProps, resolveFlowpressBlockStyleflowProps, } from "../../index.js";
|
|
9
|
+
import { nativeGroupProps } from "./group.js";
|
|
10
|
+
const CONTROL_CLASSES = ["wp-block-button__link", "wp-element-button", "flowpress-button-template"];
|
|
11
|
+
export function buttonTemplateData(resolvedData) {
|
|
12
|
+
const template = resolvedData?.template;
|
|
13
|
+
if (!template || typeof template !== "object")
|
|
14
|
+
return undefined;
|
|
15
|
+
const data = template;
|
|
16
|
+
return typeof data.slug === "string" && Array.isArray(data.blocks) && data.blocks.length > 0
|
|
17
|
+
? data
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|
|
20
|
+
export function buttonTemplateHasInteractiveBlocks(blocks) {
|
|
21
|
+
const intrinsic = new Set(["core/button", "core/buttons", "core/navigation", "core/navigation-link", "core/navigation-submenu", "core/home-link", "core/page-list", "core/block", "core/audio", "core/video", "core/embed", "sf/button", "sf/form", "sf/theme-toggle", "sf/carousel", "sf/video", "sf/video-youtube", "sf/code"]);
|
|
22
|
+
return blocks.some(block => {
|
|
23
|
+
const attrs = block.attributes ?? {};
|
|
24
|
+
const data = (block.resolvedData ?? {});
|
|
25
|
+
if (intrinsic.has(block.name) || attrs.isLink || attrs.href || attrs.link?.url || data.href || data.as === "link")
|
|
26
|
+
return true;
|
|
27
|
+
if ([attrs.content, attrs.html, block.innerHtml, data.html, data.svg?.content].some(value => typeof value === "string" && /<(?:a|button|input|select|textarea|form|iframe|summary|details|audio|video)\b/i.test(value)))
|
|
28
|
+
return true;
|
|
29
|
+
return buttonTemplateHasInteractiveBlocks(block.innerBlocks ?? []) || buttonTemplateHasInteractiveBlocks(data.blocks ?? []) || (data.items ?? []).some((item) => buttonTemplateHasInteractiveBlocks(item.blocks ?? []));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function buttonTemplateControl(template, contract, options = {}) {
|
|
33
|
+
const [root] = template.blocks;
|
|
34
|
+
if (template.blocks.length !== 1 || !root || root.name !== "core/group" || buttonTemplateHasInteractiveBlocks(template.blocks))
|
|
35
|
+
return undefined;
|
|
36
|
+
const attributes = (root.attributes ?? {});
|
|
37
|
+
const styleflowProps = resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);
|
|
38
|
+
const groupProps = nativeGroupProps(attributes, flowpressBlockHtmlProps(attributes), styleflowProps);
|
|
39
|
+
return {
|
|
40
|
+
controlProps: {
|
|
41
|
+
...groupProps,
|
|
42
|
+
class: [...CONTROL_CLASSES, groupProps.class].filter(Boolean).join(" "),
|
|
43
|
+
},
|
|
44
|
+
styleflowProps,
|
|
45
|
+
children: root.innerBlocks ?? [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Diagnostic codes worth surfacing on the element outside production. */
|
|
49
|
+
export function buttonTemplateDiagnosticCodes(template, resolvedData) {
|
|
50
|
+
const own = resolvedData
|
|
51
|
+
?.templateDiagnostics ?? [];
|
|
52
|
+
return [...own, ...(template?.diagnostics ?? [])].map(({ code }) => code).join(" ");
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=button-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-template.js","sourceRoot":"","sources":["../../../src/astro/native/button-template.ts"],"names":[],"mappings":"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","sourcesContent":["// Native button templates resolved by WordPress Core.\n//\n// The WordPress resolver attaches the selected template to core/button as\n// `resolvedData.template`, resolved like a synced pattern. The template root\n// Group becomes the focusable control, so StyleFlow interaction states\n// (hover, focus-visible, disabled on data-interactive-priority) apply to the\n// link itself; the root's children render inside it.\nimport {\n flowpressBlockHtmlProps,\n resolveFlowpressBlockStyleflowProps,\n type DynamicStyleflowProps,\n type FlowpressBlock,\n type StyleflowContract,\n type ResolveDynamicStyleflowOptions,\n} from \"../../index.js\";\nimport { nativeGroupProps } from \"./group.js\";\n\nexport interface ButtonTemplateDiagnostic {\n code: string;\n message: string;\n blocking: boolean;\n blockName?: string;\n path?: string;\n}\n\nexport interface ButtonTemplateData {\n slug: string;\n ref: number;\n requested?: string | null;\n blocks: FlowpressBlock[];\n blockTypes?: unknown[];\n stylesheets?: unknown[];\n diagnostics?: ButtonTemplateDiagnostic[];\n}\n\nexport interface ButtonTemplateControl {\n /** Props of the focusable element (a, button or span). */\n controlProps: Record<string, unknown>;\n /** StyleFlow props of the template root, applied to the control. */\n styleflowProps: DynamicStyleflowProps;\n /** Blocks rendered inside the control. */\n children: FlowpressBlock[];\n}\n\nconst CONTROL_CLASSES = [\"wp-block-button__link\", \"wp-element-button\", \"flowpress-button-template\"];\n\nexport function buttonTemplateData(resolvedData: unknown): ButtonTemplateData | undefined {\n const template = (resolvedData as { template?: unknown } | null | undefined)?.template;\n if (!template || typeof template !== \"object\") return undefined;\n const data = template as Partial<ButtonTemplateData>;\n return typeof data.slug === \"string\" && Array.isArray(data.blocks) && data.blocks.length > 0\n ? (data as ButtonTemplateData)\n : undefined;\n}\n\nexport function buttonTemplateHasInteractiveBlocks(blocks: FlowpressBlock[]): boolean {\n const intrinsic = new Set([\"core/button\",\"core/buttons\",\"core/navigation\",\"core/navigation-link\",\"core/navigation-submenu\",\"core/home-link\",\"core/page-list\",\"core/block\",\"core/audio\",\"core/video\",\"core/embed\",\"sf/button\",\"sf/form\",\"sf/theme-toggle\",\"sf/carousel\",\"sf/video\",\"sf/video-youtube\",\"sf/code\"]);\n return blocks.some(block => {\n const attrs = block.attributes ?? {};\n const data = (block.resolvedData ?? {}) as Record<string, any>;\n if (intrinsic.has(block.name) || attrs.isLink || attrs.href || (attrs.link as {url?:string}|undefined)?.url || data.href || data.as === \"link\") return true;\n if ([attrs.content, attrs.html, block.innerHtml, data.html, data.svg?.content].some(value => typeof value === \"string\" && /<(?:a|button|input|select|textarea|form|iframe|summary|details|audio|video)\\b/i.test(value))) return true;\n return buttonTemplateHasInteractiveBlocks(block.innerBlocks ?? []) || buttonTemplateHasInteractiveBlocks(data.blocks ?? []) || (data.items ?? []).some((item:{blocks?:FlowpressBlock[]}) => buttonTemplateHasInteractiveBlocks(item.blocks ?? []));\n });\n}\n\nexport function buttonTemplateControl(\n template: ButtonTemplateData,\n contract?: StyleflowContract,\n options: ResolveDynamicStyleflowOptions = {},\n): ButtonTemplateControl | undefined {\n const [root] = template.blocks;\n if (template.blocks.length !== 1 || !root || root.name !== \"core/group\" || buttonTemplateHasInteractiveBlocks(template.blocks)) return undefined;\n const attributes = (root.attributes ?? {}) as Record<string, unknown>;\n const styleflowProps = resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);\n const groupProps = nativeGroupProps(attributes, flowpressBlockHtmlProps(attributes), styleflowProps);\n return {\n controlProps: {\n ...groupProps,\n class: [...CONTROL_CLASSES, groupProps.class].filter(Boolean).join(\" \"),\n },\n styleflowProps,\n children: root.innerBlocks ?? [],\n };\n}\n\n/** Diagnostic codes worth surfacing on the element outside production. */\nexport function buttonTemplateDiagnosticCodes(template: ButtonTemplateData | undefined, resolvedData: unknown): string {\n const own = (resolvedData as { templateDiagnostics?: ButtonTemplateDiagnostic[] } | null | undefined)\n ?.templateDiagnostics ?? [];\n return [...own, ...(template?.diagnostics ?? [])].map(({ code }) => code).join(\" \");\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Native button templates resolved by WordPress Core.
|
|
2
|
+
//
|
|
3
|
+
// The WordPress resolver attaches the selected template to core/button as
|
|
4
|
+
// `resolvedData.template`, resolved like a synced pattern. The template root
|
|
5
|
+
// Group becomes the focusable control, so StyleFlow interaction states
|
|
6
|
+
// (hover, focus-visible, disabled on data-interactive-priority) apply to the
|
|
7
|
+
// link itself; the root's children render inside it.
|
|
8
|
+
import {
|
|
9
|
+
flowpressBlockHtmlProps,
|
|
10
|
+
resolveFlowpressBlockStyleflowProps,
|
|
11
|
+
type DynamicStyleflowProps,
|
|
12
|
+
type FlowpressBlock,
|
|
13
|
+
type StyleflowContract,
|
|
14
|
+
type ResolveDynamicStyleflowOptions,
|
|
15
|
+
} from "../../index.js";
|
|
16
|
+
import { nativeGroupProps } from "./group.js";
|
|
17
|
+
|
|
18
|
+
export interface ButtonTemplateDiagnostic {
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
blocking: boolean;
|
|
22
|
+
blockName?: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ButtonTemplateData {
|
|
27
|
+
slug: string;
|
|
28
|
+
ref: number;
|
|
29
|
+
requested?: string | null;
|
|
30
|
+
blocks: FlowpressBlock[];
|
|
31
|
+
blockTypes?: unknown[];
|
|
32
|
+
stylesheets?: unknown[];
|
|
33
|
+
diagnostics?: ButtonTemplateDiagnostic[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ButtonTemplateControl {
|
|
37
|
+
/** Props of the focusable element (a, button or span). */
|
|
38
|
+
controlProps: Record<string, unknown>;
|
|
39
|
+
/** StyleFlow props of the template root, applied to the control. */
|
|
40
|
+
styleflowProps: DynamicStyleflowProps;
|
|
41
|
+
/** Blocks rendered inside the control. */
|
|
42
|
+
children: FlowpressBlock[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const CONTROL_CLASSES = ["wp-block-button__link", "wp-element-button", "flowpress-button-template"];
|
|
46
|
+
|
|
47
|
+
export function buttonTemplateData(resolvedData: unknown): ButtonTemplateData | undefined {
|
|
48
|
+
const template = (resolvedData as { template?: unknown } | null | undefined)?.template;
|
|
49
|
+
if (!template || typeof template !== "object") return undefined;
|
|
50
|
+
const data = template as Partial<ButtonTemplateData>;
|
|
51
|
+
return typeof data.slug === "string" && Array.isArray(data.blocks) && data.blocks.length > 0
|
|
52
|
+
? (data as ButtonTemplateData)
|
|
53
|
+
: undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function buttonTemplateHasInteractiveBlocks(blocks: FlowpressBlock[]): boolean {
|
|
57
|
+
const intrinsic = new Set(["core/button","core/buttons","core/navigation","core/navigation-link","core/navigation-submenu","core/home-link","core/page-list","core/block","core/audio","core/video","core/embed","sf/button","sf/form","sf/theme-toggle","sf/carousel","sf/video","sf/video-youtube","sf/code"]);
|
|
58
|
+
return blocks.some(block => {
|
|
59
|
+
const attrs = block.attributes ?? {};
|
|
60
|
+
const data = (block.resolvedData ?? {}) as Record<string, any>;
|
|
61
|
+
if (intrinsic.has(block.name) || attrs.isLink || attrs.href || (attrs.link as {url?:string}|undefined)?.url || data.href || data.as === "link") return true;
|
|
62
|
+
if ([attrs.content, attrs.html, block.innerHtml, data.html, data.svg?.content].some(value => typeof value === "string" && /<(?:a|button|input|select|textarea|form|iframe|summary|details|audio|video)\b/i.test(value))) return true;
|
|
63
|
+
return buttonTemplateHasInteractiveBlocks(block.innerBlocks ?? []) || buttonTemplateHasInteractiveBlocks(data.blocks ?? []) || (data.items ?? []).some((item:{blocks?:FlowpressBlock[]}) => buttonTemplateHasInteractiveBlocks(item.blocks ?? []));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function buttonTemplateControl(
|
|
68
|
+
template: ButtonTemplateData,
|
|
69
|
+
contract?: StyleflowContract,
|
|
70
|
+
options: ResolveDynamicStyleflowOptions = {},
|
|
71
|
+
): ButtonTemplateControl | undefined {
|
|
72
|
+
const [root] = template.blocks;
|
|
73
|
+
if (template.blocks.length !== 1 || !root || root.name !== "core/group" || buttonTemplateHasInteractiveBlocks(template.blocks)) return undefined;
|
|
74
|
+
const attributes = (root.attributes ?? {}) as Record<string, unknown>;
|
|
75
|
+
const styleflowProps = resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);
|
|
76
|
+
const groupProps = nativeGroupProps(attributes, flowpressBlockHtmlProps(attributes), styleflowProps);
|
|
77
|
+
return {
|
|
78
|
+
controlProps: {
|
|
79
|
+
...groupProps,
|
|
80
|
+
class: [...CONTROL_CLASSES, groupProps.class].filter(Boolean).join(" "),
|
|
81
|
+
},
|
|
82
|
+
styleflowProps,
|
|
83
|
+
children: root.innerBlocks ?? [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Diagnostic codes worth surfacing on the element outside production. */
|
|
88
|
+
export function buttonTemplateDiagnosticCodes(template: ButtonTemplateData | undefined, resolvedData: unknown): string {
|
|
89
|
+
const own = (resolvedData as { templateDiagnostics?: ButtonTemplateDiagnostic[] } | null | undefined)
|
|
90
|
+
?.templateDiagnostics ?? [];
|
|
91
|
+
return [...own, ...(template?.diagnostics ?? [])].map(({ code }) => code).join(" ");
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** WordPress resolves the RichText; Astro restricts URL and control semantics. */
|
|
2
|
+
export declare function nativeButtonData(data?: Record<string, unknown> | null): {
|
|
3
|
+
empty: boolean;
|
|
4
|
+
tag: string;
|
|
5
|
+
label: string;
|
|
6
|
+
href: string | undefined;
|
|
7
|
+
target: string | undefined;
|
|
8
|
+
rel: string | undefined;
|
|
9
|
+
title: string | undefined;
|
|
10
|
+
type: "button" | "submit" | "reset";
|
|
11
|
+
};
|
|
12
|
+
export declare function nativeButtonsLayout(layout?: Record<string, unknown>): string;
|
|
13
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/astro/native/button.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;;;;;;;;UAgBwB,QAAQ,GAAG,QAAQ,GAAG,OAAO;EAE1H;AAED,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,UAIvE"}
|