@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,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import { classNames, type LoopData } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// core/query: the project resolver runs the query and resolves the loop's
|
|
8
|
+
// inner blocks again with the results in context (query-loop.php). Render that
|
|
9
|
+
// nested pass, not `innerBlocks`, which were resolved with the page context.
|
|
10
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
11
|
+
const { block, htmlProps, styleflowProps } = props;
|
|
12
|
+
const data = (block.resolvedData ?? {}) as LoopData;
|
|
13
|
+
const authored = String(block.attributes.tagName ?? "div");
|
|
14
|
+
const tag = ["div", "section", "main", "aside", "article"].includes(authored) ? authored : "div";
|
|
15
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-query", htmlProps.class) };
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{tag === "section" ? <StyleflowElement as="section" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
19
|
+
: tag === "main" ? <StyleflowElement as="main" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
20
|
+
: tag === "aside" ? <StyleflowElement as="aside" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
21
|
+
: tag === "article" ? <StyleflowElement as="article" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
22
|
+
: <StyleflowElement as="div" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames } from "./query-loop.js";
|
|
5
|
+
const { htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<StyleflowElement as="hr" {...htmlProps} {...styleflowProps}
|
|
9
|
+
class={classNames("wp-block-separator", htmlProps.class)}
|
|
10
|
+
foreground={styleflowProps.foreground || "primary"}
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<style is:global>
|
|
14
|
+
.wp-block-separator { background: transparent; border: 0; border-top: 1px solid currentColor; height: 0; opacity: 1; }
|
|
15
|
+
.wp-block-separator.is-style-dots { border: 0; height: auto; text-align: center; }
|
|
16
|
+
.wp-block-separator.is-style-dots::before { content: "···"; color: inherit; letter-spacing: 1em; padding-inline-start: 1em; }
|
|
17
|
+
.wp-block-separator[data-sf-no-border="true"] { border: 0; }
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const level = Number(block.attributes.level ?? 1);
|
|
7
|
+
const title = decodeFlowpressText(block.resolvedData?.title);
|
|
8
|
+
const url = String(block.resolvedData?.url ?? "/");
|
|
9
|
+
---
|
|
10
|
+
{level === 1 ? <StyleflowElement as="h1" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
11
|
+
: level === 2 ? <StyleflowElement as="h2" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
12
|
+
: level === 3 ? <StyleflowElement as="h3" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
13
|
+
: level === 4 ? <StyleflowElement as="h4" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
14
|
+
: level === 5 ? <StyleflowElement as="h5" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
15
|
+
: level === 6 ? <StyleflowElement as="h6" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>
|
|
16
|
+
: <StyleflowElement as="p" {...htmlProps} {...styleflowProps}><StyleflowElement as="a" href={url}>{title}</StyleflowElement></StyleflowElement>}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames, text } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Description of the current Terms Query item (sanitized by WordPress).
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const description = text(block.resolvedData?.description);
|
|
9
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-term-description", htmlProps.class) };
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
{description ? <StyleflowElement as="div" {...rootProps} {...styleflowProps}><Fragment set:html={description} /></StyleflowElement> : null}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import LevelTag from "./LevelTag.astro";
|
|
6
|
+
import { classNames, headingLevel, text } from "./query-loop.js";
|
|
7
|
+
|
|
8
|
+
// Name of the current Terms Query item.
|
|
9
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
10
|
+
const name = decodeFlowpressText(block.resolvedData?.name);
|
|
11
|
+
const url = text(block.resolvedData?.url);
|
|
12
|
+
const level = headingLevel(block.attributes.level, 0);
|
|
13
|
+
const tag = level === 0 ? "p" : `h${level}`;
|
|
14
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-term-name", htmlProps.class) };
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
{name ? (
|
|
18
|
+
<LevelTag tag={tag} {...rootProps} {...styleflowProps}>
|
|
19
|
+
{block.attributes.isLink && url ? <StyleflowElement as="a" href={url}>{name}</StyleflowElement> : name}
|
|
20
|
+
</LevelTag>
|
|
21
|
+
) : null}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import { classNames, type LoopTemplateData } from "./query-loop.js";
|
|
6
|
+
import { bleedClasses, gridClasses, isGrid, spanClasses, usedSpanClasses } from "./grid.js";
|
|
7
|
+
|
|
8
|
+
// core/term-template: one resolved copy of the template per queried term.
|
|
9
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
10
|
+
const { block, htmlProps, styleflowProps } = props;
|
|
11
|
+
const data = (block.resolvedData ?? {}) as LoopTemplateData;
|
|
12
|
+
const items = data.items ?? [];
|
|
13
|
+
const grid = isGrid(block.name, block.attributes);
|
|
14
|
+
const childAttributes = items.map((item) => item.blocks?.[0]?.attributes || {});
|
|
15
|
+
const bleed = grid ? bleedClasses(block.attributes, childAttributes) : [];
|
|
16
|
+
const rootProps = {
|
|
17
|
+
...htmlProps,
|
|
18
|
+
class: classNames("wp-block-term-template", grid ? "is-layout-grid" : "", htmlProps.class, grid ? gridClasses(block.attributes).join(" ") : ""),
|
|
19
|
+
};
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
{items.length > 0 ? (
|
|
23
|
+
<StyleflowElement as="ul" {...rootProps} {...styleflowProps}>
|
|
24
|
+
{items.map((item, index) => (
|
|
25
|
+
<StyleflowElement as="li" class={classNames("wp-block-term", `term-${item.id}`, item.taxonomy ? `taxonomy-${item.taxonomy}` : "", grid ? [...spanClasses((childAttributes[index] ?? {})), ...usedSpanClasses(block.attributes, (childAttributes[index] ?? {})), ...(bleed[index] ?? [])].join(" ") : "")}>
|
|
26
|
+
<ResolvedBlocks {...props} blocks={item.blocks} pass={data} renderPassOutput={index === 0} />
|
|
27
|
+
</StyleflowElement>
|
|
28
|
+
))}
|
|
29
|
+
</StyleflowElement>
|
|
30
|
+
) : null}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import { classNames, type LoopData } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// core/terms-query: same two-pass contract as core/query (query-loop.php).
|
|
8
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
9
|
+
const { block, htmlProps, styleflowProps } = props;
|
|
10
|
+
const data = (block.resolvedData ?? {}) as LoopData;
|
|
11
|
+
const authored = String(block.attributes.tagName ?? "div");
|
|
12
|
+
const tag = ["div", "section", "aside", "nav"].includes(authored) ? authored : "div";
|
|
13
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-terms-query", htmlProps.class) };
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{tag === "section" ? <StyleflowElement as="section" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
17
|
+
: tag === "aside" ? <StyleflowElement as="aside" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
18
|
+
: tag === "nav" ? <StyleflowElement as="nav" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>
|
|
19
|
+
: <StyleflowElement as="div" {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></StyleflowElement>}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
|
|
4
|
+
|
|
5
|
+
const { htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const ownsSemanticContext = Object.keys(styleflowProps).length > 0 || Object.keys(htmlProps).length > 0;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
{ownsSemanticContext
|
|
10
|
+
? <StyleflowElement as="div" {...htmlProps} {...styleflowProps}><slot /></StyleflowElement>
|
|
11
|
+
: <slot />}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowpress-navigation-controller.d.ts","sourceRoot":"","sources":["../../../src/astro/native/flowpress-navigation-controller.ts"],"names":[],"mappings":"AAkNA,wBAAgB,2BAA2B,SAI1C"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { SF_MOTION_DRAWER_EXIT_MS } from "./motion.js";
|
|
2
|
+
import { getMotionPreference } from "./motion-preference.js";
|
|
3
|
+
const DEFAULT_OVERLAY_BREAKPOINT = "64rem";
|
|
4
|
+
const FOCUSABLE = "a, button, summary, [tabindex]:not([tabindex='-1'])";
|
|
5
|
+
const scrollLocks = new Set();
|
|
6
|
+
let previousRootOverflow = "";
|
|
7
|
+
/** `64rem` becomes `(max-width: 63.999rem)`, the exact complement of `min-width: 64rem`. */
|
|
8
|
+
function overlayQuery(breakpoint) {
|
|
9
|
+
const match = /^(\d+(?:\.\d+)?)rem$/.exec(breakpoint.trim());
|
|
10
|
+
const rem = match ? Number(match[1]) : Number.parseFloat(DEFAULT_OVERLAY_BREAKPOINT);
|
|
11
|
+
return `(max-width: ${(rem - 0.001).toFixed(3)}rem)`;
|
|
12
|
+
}
|
|
13
|
+
class FlowpressNavigation extends HTMLElement {
|
|
14
|
+
toggleButton = null;
|
|
15
|
+
panel = null;
|
|
16
|
+
backdrop = null;
|
|
17
|
+
media;
|
|
18
|
+
closeTimer;
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
if (this.dataset.ready === "true")
|
|
21
|
+
return;
|
|
22
|
+
this.toggleButton = this.querySelector("[data-navigation-toggle]");
|
|
23
|
+
this.panel = this.querySelector("[data-navigation-panel]");
|
|
24
|
+
this.backdrop = this.querySelector("[data-navigation-backdrop]");
|
|
25
|
+
if (!this.toggleButton || !this.panel)
|
|
26
|
+
return;
|
|
27
|
+
this.media = window.matchMedia(overlayQuery(this.dataset.overlayBreakpoint || DEFAULT_OVERLAY_BREAKPOINT));
|
|
28
|
+
this.toggleButton.addEventListener("click", this.handleToggle);
|
|
29
|
+
this.backdrop?.addEventListener("click", this.handleBackdrop);
|
|
30
|
+
this.panel.addEventListener("click", this.handlePanelClick);
|
|
31
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
32
|
+
this.media.addEventListener("change", this.syncMode);
|
|
33
|
+
document.addEventListener("pointerdown", this.handleOutsidePointer);
|
|
34
|
+
this.querySelectorAll("details[data-navigation-disclosure]")
|
|
35
|
+
.forEach((details) => details.addEventListener("toggle", this.handleDisclosure));
|
|
36
|
+
this.syncMode();
|
|
37
|
+
this.dataset.ready = "true";
|
|
38
|
+
}
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
this.toggleButton?.removeEventListener("click", this.handleToggle);
|
|
41
|
+
this.backdrop?.removeEventListener("click", this.handleBackdrop);
|
|
42
|
+
this.panel?.removeEventListener("click", this.handlePanelClick);
|
|
43
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
44
|
+
this.media?.removeEventListener("change", this.syncMode);
|
|
45
|
+
document.removeEventListener("pointerdown", this.handleOutsidePointer);
|
|
46
|
+
this.querySelectorAll("details[data-navigation-disclosure]")
|
|
47
|
+
.forEach((details) => details.removeEventListener("toggle", this.handleDisclosure));
|
|
48
|
+
this.unlockDocumentScroll();
|
|
49
|
+
window.clearTimeout(this.closeTimer);
|
|
50
|
+
delete this.dataset.ready;
|
|
51
|
+
}
|
|
52
|
+
usesOverlay = () => {
|
|
53
|
+
const mode = this.dataset.overlay || "mobile";
|
|
54
|
+
return mode === "always" || (mode === "mobile" && this.media.matches);
|
|
55
|
+
};
|
|
56
|
+
isOpen = () => this.toggleButton?.getAttribute("aria-expanded") === "true";
|
|
57
|
+
label = (state) => this.dataset[state === "open" ? "openLabel" : "closeLabel"] ??
|
|
58
|
+
(state === "open" ? "Open menu" : "Close menu");
|
|
59
|
+
setToggleState = (expanded) => {
|
|
60
|
+
if (!this.toggleButton)
|
|
61
|
+
return;
|
|
62
|
+
const label = this.label(expanded ? "close" : "open");
|
|
63
|
+
this.toggleButton.setAttribute("aria-expanded", String(expanded));
|
|
64
|
+
this.toggleButton.setAttribute("aria-label", label);
|
|
65
|
+
const accessibleLabel = this.toggleButton.querySelector(".sr-only");
|
|
66
|
+
if (accessibleLabel)
|
|
67
|
+
accessibleLabel.textContent = label;
|
|
68
|
+
};
|
|
69
|
+
// Locked on <html>, not <body>: with a non-visible overflow on <html> (the site clips it
|
|
70
|
+
// horizontally) a locked <body> becomes a scroll container of its own, and the sticky
|
|
71
|
+
// header stops sticking and jumps away from the open menu.
|
|
72
|
+
lockDocumentScroll = () => {
|
|
73
|
+
if (scrollLocks.has(this))
|
|
74
|
+
return;
|
|
75
|
+
if (scrollLocks.size === 0) {
|
|
76
|
+
previousRootOverflow = document.documentElement.style.overflow;
|
|
77
|
+
document.documentElement.style.overflow = "hidden";
|
|
78
|
+
}
|
|
79
|
+
scrollLocks.add(this);
|
|
80
|
+
};
|
|
81
|
+
unlockDocumentScroll = () => {
|
|
82
|
+
if (!scrollLocks.delete(this))
|
|
83
|
+
return;
|
|
84
|
+
if (scrollLocks.size === 0)
|
|
85
|
+
document.documentElement.style.overflow = previousRootOverflow;
|
|
86
|
+
};
|
|
87
|
+
open = () => {
|
|
88
|
+
if (!this.toggleButton || !this.panel)
|
|
89
|
+
return;
|
|
90
|
+
window.clearTimeout(this.closeTimer);
|
|
91
|
+
this.panel.hidden = false;
|
|
92
|
+
this.panel.inert = false;
|
|
93
|
+
if (this.backdrop)
|
|
94
|
+
this.backdrop.hidden = false;
|
|
95
|
+
this.setToggleState(true);
|
|
96
|
+
this.lockDocumentScroll();
|
|
97
|
+
// Commit the closed styles once the panel is displayed, so the open state transitions.
|
|
98
|
+
void this.panel.offsetWidth;
|
|
99
|
+
requestAnimationFrame(() => {
|
|
100
|
+
this.panel?.setAttribute("data-sf-motion-state", "open");
|
|
101
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "open");
|
|
102
|
+
// The panel only becomes focusable once the open state has been rendered.
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
if (this.isOpen())
|
|
105
|
+
this.panel?.querySelector(FOCUSABLE)?.focus();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
close = (restoreFocus = false, immediate = false) => {
|
|
110
|
+
if (!this.toggleButton || !this.panel)
|
|
111
|
+
return;
|
|
112
|
+
this.setToggleState(false);
|
|
113
|
+
this.panel.inert = true;
|
|
114
|
+
this.panel.setAttribute("data-sf-motion-state", "closed");
|
|
115
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "closed");
|
|
116
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
117
|
+
this.unlockDocumentScroll();
|
|
118
|
+
const reducedMotion = getMotionPreference() === "reduce";
|
|
119
|
+
const delay = immediate || reducedMotion ? 0 : SF_MOTION_DRAWER_EXIT_MS;
|
|
120
|
+
window.clearTimeout(this.closeTimer);
|
|
121
|
+
this.closeTimer = window.setTimeout(() => {
|
|
122
|
+
if (!this.isOpen() && this.usesOverlay()) {
|
|
123
|
+
if (this.panel)
|
|
124
|
+
this.panel.hidden = true;
|
|
125
|
+
if (this.backdrop)
|
|
126
|
+
this.backdrop.hidden = true;
|
|
127
|
+
}
|
|
128
|
+
}, delay);
|
|
129
|
+
if (restoreFocus)
|
|
130
|
+
this.toggleButton.focus();
|
|
131
|
+
};
|
|
132
|
+
syncMode = () => {
|
|
133
|
+
if (!this.toggleButton || !this.panel)
|
|
134
|
+
return;
|
|
135
|
+
const overlay = this.usesOverlay();
|
|
136
|
+
this.dataset.overlayActive = String(overlay);
|
|
137
|
+
this.toggleButton.hidden = !overlay;
|
|
138
|
+
if (overlay) {
|
|
139
|
+
this.close(false, true);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
window.clearTimeout(this.closeTimer);
|
|
143
|
+
this.setToggleState(false);
|
|
144
|
+
this.panel.hidden = false;
|
|
145
|
+
this.panel.inert = false;
|
|
146
|
+
this.panel.setAttribute("data-sf-motion-state", "open");
|
|
147
|
+
if (this.backdrop) {
|
|
148
|
+
this.backdrop.hidden = true;
|
|
149
|
+
this.backdrop.setAttribute("data-sf-motion-state", "closed");
|
|
150
|
+
}
|
|
151
|
+
this.unlockDocumentScroll();
|
|
152
|
+
};
|
|
153
|
+
handleToggle = () => this.isOpen() ? this.close(true) : this.open();
|
|
154
|
+
handleBackdrop = () => this.close(true);
|
|
155
|
+
handlePanelClick = (event) => {
|
|
156
|
+
if (this.usesOverlay() && event.target instanceof Element && event.target.closest("a")) {
|
|
157
|
+
this.close(false);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
handleDisclosure = (event) => {
|
|
161
|
+
const current = event.currentTarget;
|
|
162
|
+
if (!(current instanceof HTMLDetailsElement) || !current.open)
|
|
163
|
+
return;
|
|
164
|
+
current.closest("ul")?.querySelectorAll(":scope > li > details[open]")
|
|
165
|
+
.forEach((details) => {
|
|
166
|
+
if (details !== current)
|
|
167
|
+
details.removeAttribute("open");
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
handleOutsidePointer = (event) => {
|
|
171
|
+
if (this.usesOverlay() || this.contains(event.target))
|
|
172
|
+
return;
|
|
173
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
174
|
+
};
|
|
175
|
+
handleKeydown = (event) => {
|
|
176
|
+
if (event.key === "Escape") {
|
|
177
|
+
if (this.usesOverlay() && this.isOpen()) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
this.close(true);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const disclosure = this.querySelector("details[open]");
|
|
183
|
+
if (disclosure) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
disclosure.removeAttribute("open");
|
|
186
|
+
disclosure.querySelector("summary")?.focus();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (event.key !== "Tab" || !this.usesOverlay() || !this.isOpen() || !this.panel || !this.toggleButton)
|
|
192
|
+
return;
|
|
193
|
+
// The toggle closes the menu, so it belongs to the same tab cycle as the links.
|
|
194
|
+
const focusable = [this.toggleButton, ...this.panel.querySelectorAll(FOCUSABLE)]
|
|
195
|
+
.filter((element) => element instanceof HTMLElement)
|
|
196
|
+
.filter((element) => !element.hasAttribute("disabled") && !element.closest("[inert]"));
|
|
197
|
+
const visibleFocusable = focusable.filter((element) => element.getClientRects().length > 0);
|
|
198
|
+
const first = visibleFocusable[0];
|
|
199
|
+
const last = visibleFocusable[visibleFocusable.length - 1];
|
|
200
|
+
if (!first || !last)
|
|
201
|
+
return;
|
|
202
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
last.focus();
|
|
205
|
+
}
|
|
206
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
first.focus();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export function registerFlowpressNavigation() {
|
|
213
|
+
if (!customElements.get("flowpress-navigation")) {
|
|
214
|
+
customElements.define("flowpress-navigation", FlowpressNavigation);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=flowpress-navigation-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowpress-navigation-controller.js","sourceRoot":"","sources":["../../../src/astro/native/flowpress-navigation-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAC3C,MAAM,SAAS,GAAG,qDAAqD,CAAC;AACxE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;AAC3C,IAAI,oBAAoB,GAAG,EAAE,CAAC;AAE9B,4FAA4F;AAC5F,SAAS,YAAY,CAAC,UAAkB;IACtC,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACrF,OAAO,eAAe,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AACvD,CAAC;AAED,MAAM,mBAAoB,SAAQ,WAAW;IACnC,YAAY,GAA6B,IAAI,CAAC;IAC9C,KAAK,GAAuB,IAAI,CAAC;IACjC,Q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AK,CAAC,QAAQ,IAAI,QAAQ,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvD,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAC9D,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;CACH;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAChD,cAAc,CAAC,MAAM,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { SF_MOTION_DRAWER_EXIT_MS } from \"./motion.js\";\nimport { getMotionPreference } from \"./motion-preference.js\";\n\nconst DEFAULT_OVERLAY_BREAKPOINT = \"64rem\";\nconst FOCUSABLE = \"a, button, summary, [tabindex]:not([tabindex='-1'])\";\nconst scrollLocks = new Set<HTMLElement>();\nlet previousRootOverflow = \"\";\n\n/** `64rem` becomes `(max-width: 63.999rem)`, the exact complement of `min-width: 64rem`. */\nfunction overlayQuery(breakpoint: string) {\n const match = /^(\\d+(?:\\.\\d+)?)rem$/.exec(breakpoint.trim());\n const rem = match ? Number(match[1]) : Number.parseFloat(DEFAULT_OVERLAY_BREAKPOINT);\n return `(max-width: ${(rem - 0.001).toFixed(3)}rem)`;\n}\n\nclass FlowpressNavigation extends HTMLElement {\n private toggleButton: HTMLButtonElement | null = null;\n private panel: HTMLElement | null = null;\n private backdrop: HTMLElement | null = null;\n private media!: MediaQueryList;\n private closeTimer: number | undefined;\n\n connectedCallback() {\n if (this.dataset.ready === \"true\") return;\n this.toggleButton = this.querySelector<HTMLButtonElement>(\"[data-navigation-toggle]\");\n this.panel = this.querySelector<HTMLElement>(\"[data-navigation-panel]\");\n this.backdrop = this.querySelector<HTMLElement>(\"[data-navigation-backdrop]\");\n if (!this.toggleButton || !this.panel) return;\n this.media = window.matchMedia(\n overlayQuery(this.dataset.overlayBreakpoint || DEFAULT_OVERLAY_BREAKPOINT),\n );\n\n this.toggleButton.addEventListener(\"click\", this.handleToggle);\n this.backdrop?.addEventListener(\"click\", this.handleBackdrop);\n this.panel.addEventListener(\"click\", this.handlePanelClick);\n this.addEventListener(\"keydown\", this.handleKeydown);\n this.media.addEventListener(\"change\", this.syncMode);\n document.addEventListener(\"pointerdown\", this.handleOutsidePointer);\n this.querySelectorAll<HTMLDetailsElement>(\"details[data-navigation-disclosure]\")\n .forEach((details) => details.addEventListener(\"toggle\", this.handleDisclosure));\n this.syncMode();\n this.dataset.ready = \"true\";\n }\n\n disconnectedCallback() {\n this.toggleButton?.removeEventListener(\"click\", this.handleToggle);\n this.backdrop?.removeEventListener(\"click\", this.handleBackdrop);\n this.panel?.removeEventListener(\"click\", this.handlePanelClick);\n this.removeEventListener(\"keydown\", this.handleKeydown);\n this.media?.removeEventListener(\"change\", this.syncMode);\n document.removeEventListener(\"pointerdown\", this.handleOutsidePointer);\n this.querySelectorAll<HTMLDetailsElement>(\"details[data-navigation-disclosure]\")\n .forEach((details) => details.removeEventListener(\"toggle\", this.handleDisclosure));\n this.unlockDocumentScroll();\n window.clearTimeout(this.closeTimer);\n delete this.dataset.ready;\n }\n\n private usesOverlay = () => {\n const mode = this.dataset.overlay || \"mobile\";\n return mode === \"always\" || (mode === \"mobile\" && this.media.matches);\n };\n\n private isOpen = () => this.toggleButton?.getAttribute(\"aria-expanded\") === \"true\";\n private label = (state: \"open\" | \"close\") =>\n this.dataset[state === \"open\" ? \"openLabel\" : \"closeLabel\"] ??\n (state === \"open\" ? \"Open menu\" : \"Close menu\");\n\n private setToggleState = (expanded: boolean) => {\n if (!this.toggleButton) return;\n const label = this.label(expanded ? \"close\" : \"open\");\n this.toggleButton.setAttribute(\"aria-expanded\", String(expanded));\n this.toggleButton.setAttribute(\"aria-label\", label);\n const accessibleLabel = this.toggleButton.querySelector<HTMLElement>(\".sr-only\");\n if (accessibleLabel) accessibleLabel.textContent = label;\n };\n\n // Locked on <html>, not <body>: with a non-visible overflow on <html> (the site clips it\n // horizontally) a locked <body> becomes a scroll container of its own, and the sticky\n // header stops sticking and jumps away from the open menu.\n private lockDocumentScroll = () => {\n if (scrollLocks.has(this)) return;\n if (scrollLocks.size === 0) {\n previousRootOverflow = document.documentElement.style.overflow;\n document.documentElement.style.overflow = \"hidden\";\n }\n scrollLocks.add(this);\n };\n\n private unlockDocumentScroll = () => {\n if (!scrollLocks.delete(this)) return;\n if (scrollLocks.size === 0) document.documentElement.style.overflow = previousRootOverflow;\n };\n\n private open = () => {\n if (!this.toggleButton || !this.panel) return;\n window.clearTimeout(this.closeTimer);\n this.panel.hidden = false;\n this.panel.inert = false;\n if (this.backdrop) this.backdrop.hidden = false;\n this.setToggleState(true);\n this.lockDocumentScroll();\n // Commit the closed styles once the panel is displayed, so the open state transitions.\n void this.panel.offsetWidth;\n requestAnimationFrame(() => {\n this.panel?.setAttribute(\"data-sf-motion-state\", \"open\");\n this.backdrop?.setAttribute(\"data-sf-motion-state\", \"open\");\n // The panel only becomes focusable once the open state has been rendered.\n requestAnimationFrame(() => {\n if (this.isOpen()) this.panel?.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n });\n });\n };\n\n private close = (restoreFocus = false, immediate = false) => {\n if (!this.toggleButton || !this.panel) return;\n this.setToggleState(false);\n this.panel.inert = true;\n this.panel.setAttribute(\"data-sf-motion-state\", \"closed\");\n this.backdrop?.setAttribute(\"data-sf-motion-state\", \"closed\");\n this.querySelectorAll(\"details[open]\").forEach((details) => details.removeAttribute(\"open\"));\n this.unlockDocumentScroll();\n\n const reducedMotion = getMotionPreference() === \"reduce\";\n const delay = immediate || reducedMotion ? 0 : SF_MOTION_DRAWER_EXIT_MS;\n window.clearTimeout(this.closeTimer);\n this.closeTimer = window.setTimeout(() => {\n if (!this.isOpen() && this.usesOverlay()) {\n if (this.panel) this.panel.hidden = true;\n if (this.backdrop) this.backdrop.hidden = true;\n }\n }, delay);\n if (restoreFocus) this.toggleButton.focus();\n };\n\n private syncMode = () => {\n if (!this.toggleButton || !this.panel) return;\n const overlay = this.usesOverlay();\n this.dataset.overlayActive = String(overlay);\n this.toggleButton.hidden = !overlay;\n if (overlay) {\n this.close(false, true);\n return;\n }\n\n window.clearTimeout(this.closeTimer);\n this.setToggleState(false);\n this.panel.hidden = false;\n this.panel.inert = false;\n this.panel.setAttribute(\"data-sf-motion-state\", \"open\");\n if (this.backdrop) {\n this.backdrop.hidden = true;\n this.backdrop.setAttribute(\"data-sf-motion-state\", \"closed\");\n }\n this.unlockDocumentScroll();\n };\n\n private handleToggle = () => this.isOpen() ? this.close(true) : this.open();\n private handleBackdrop = () => this.close(true);\n private handlePanelClick = (event: Event) => {\n if (this.usesOverlay() && event.target instanceof Element && event.target.closest(\"a\")) {\n this.close(false);\n }\n };\n private handleDisclosure = (event: Event) => {\n const current = event.currentTarget;\n if (!(current instanceof HTMLDetailsElement) || !current.open) return;\n current.closest(\"ul\")?.querySelectorAll<HTMLDetailsElement>(\":scope > li > details[open]\")\n .forEach((details) => {\n if (details !== current) details.removeAttribute(\"open\");\n });\n };\n private handleOutsidePointer = (event: PointerEvent) => {\n if (this.usesOverlay() || this.contains(event.target as Node)) return;\n this.querySelectorAll(\"details[open]\").forEach((details) => details.removeAttribute(\"open\"));\n };\n private handleKeydown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n if (this.usesOverlay() && this.isOpen()) {\n event.preventDefault();\n this.close(true);\n } else {\n const disclosure = this.querySelector<HTMLDetailsElement>(\"details[open]\");\n if (disclosure) {\n event.preventDefault();\n disclosure.removeAttribute(\"open\");\n disclosure.querySelector<HTMLElement>(\"summary\")?.focus();\n }\n }\n return;\n }\n if (event.key !== \"Tab\" || !this.usesOverlay() || !this.isOpen() || !this.panel || !this.toggleButton) return;\n // The toggle closes the menu, so it belongs to the same tab cycle as the links.\n const focusable = [this.toggleButton, ...this.panel.querySelectorAll<HTMLElement>(FOCUSABLE)]\n .filter((element): element is HTMLElement => element instanceof HTMLElement)\n .filter((element) => !element.hasAttribute(\"disabled\") && !element.closest(\"[inert]\"));\n const visibleFocusable = focusable.filter((element) => element.getClientRects().length > 0);\n const first = visibleFocusable[0];\n const last = visibleFocusable[visibleFocusable.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n}\n\nexport function registerFlowpressNavigation() {\n if (!customElements.get(\"flowpress-navigation\")) {\n customElements.define(\"flowpress-navigation\", FlowpressNavigation);\n }\n}\n"]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { SF_MOTION_DRAWER_EXIT_MS } from "./motion.js";
|
|
2
|
+
import { getMotionPreference } from "./motion-preference.js";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_OVERLAY_BREAKPOINT = "64rem";
|
|
5
|
+
const FOCUSABLE = "a, button, summary, [tabindex]:not([tabindex='-1'])";
|
|
6
|
+
const scrollLocks = new Set<HTMLElement>();
|
|
7
|
+
let previousRootOverflow = "";
|
|
8
|
+
|
|
9
|
+
/** `64rem` becomes `(max-width: 63.999rem)`, the exact complement of `min-width: 64rem`. */
|
|
10
|
+
function overlayQuery(breakpoint: string) {
|
|
11
|
+
const match = /^(\d+(?:\.\d+)?)rem$/.exec(breakpoint.trim());
|
|
12
|
+
const rem = match ? Number(match[1]) : Number.parseFloat(DEFAULT_OVERLAY_BREAKPOINT);
|
|
13
|
+
return `(max-width: ${(rem - 0.001).toFixed(3)}rem)`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class FlowpressNavigation extends HTMLElement {
|
|
17
|
+
private toggleButton: HTMLButtonElement | null = null;
|
|
18
|
+
private panel: HTMLElement | null = null;
|
|
19
|
+
private backdrop: HTMLElement | null = null;
|
|
20
|
+
private media!: MediaQueryList;
|
|
21
|
+
private closeTimer: number | undefined;
|
|
22
|
+
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
if (this.dataset.ready === "true") return;
|
|
25
|
+
this.toggleButton = this.querySelector<HTMLButtonElement>("[data-navigation-toggle]");
|
|
26
|
+
this.panel = this.querySelector<HTMLElement>("[data-navigation-panel]");
|
|
27
|
+
this.backdrop = this.querySelector<HTMLElement>("[data-navigation-backdrop]");
|
|
28
|
+
if (!this.toggleButton || !this.panel) return;
|
|
29
|
+
this.media = window.matchMedia(
|
|
30
|
+
overlayQuery(this.dataset.overlayBreakpoint || DEFAULT_OVERLAY_BREAKPOINT),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
this.toggleButton.addEventListener("click", this.handleToggle);
|
|
34
|
+
this.backdrop?.addEventListener("click", this.handleBackdrop);
|
|
35
|
+
this.panel.addEventListener("click", this.handlePanelClick);
|
|
36
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
37
|
+
this.media.addEventListener("change", this.syncMode);
|
|
38
|
+
document.addEventListener("pointerdown", this.handleOutsidePointer);
|
|
39
|
+
this.querySelectorAll<HTMLDetailsElement>("details[data-navigation-disclosure]")
|
|
40
|
+
.forEach((details) => details.addEventListener("toggle", this.handleDisclosure));
|
|
41
|
+
this.syncMode();
|
|
42
|
+
this.dataset.ready = "true";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
this.toggleButton?.removeEventListener("click", this.handleToggle);
|
|
47
|
+
this.backdrop?.removeEventListener("click", this.handleBackdrop);
|
|
48
|
+
this.panel?.removeEventListener("click", this.handlePanelClick);
|
|
49
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
50
|
+
this.media?.removeEventListener("change", this.syncMode);
|
|
51
|
+
document.removeEventListener("pointerdown", this.handleOutsidePointer);
|
|
52
|
+
this.querySelectorAll<HTMLDetailsElement>("details[data-navigation-disclosure]")
|
|
53
|
+
.forEach((details) => details.removeEventListener("toggle", this.handleDisclosure));
|
|
54
|
+
this.unlockDocumentScroll();
|
|
55
|
+
window.clearTimeout(this.closeTimer);
|
|
56
|
+
delete this.dataset.ready;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private usesOverlay = () => {
|
|
60
|
+
const mode = this.dataset.overlay || "mobile";
|
|
61
|
+
return mode === "always" || (mode === "mobile" && this.media.matches);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
private isOpen = () => this.toggleButton?.getAttribute("aria-expanded") === "true";
|
|
65
|
+
private label = (state: "open" | "close") =>
|
|
66
|
+
this.dataset[state === "open" ? "openLabel" : "closeLabel"] ??
|
|
67
|
+
(state === "open" ? "Open menu" : "Close menu");
|
|
68
|
+
|
|
69
|
+
private setToggleState = (expanded: boolean) => {
|
|
70
|
+
if (!this.toggleButton) return;
|
|
71
|
+
const label = this.label(expanded ? "close" : "open");
|
|
72
|
+
this.toggleButton.setAttribute("aria-expanded", String(expanded));
|
|
73
|
+
this.toggleButton.setAttribute("aria-label", label);
|
|
74
|
+
const accessibleLabel = this.toggleButton.querySelector<HTMLElement>(".sr-only");
|
|
75
|
+
if (accessibleLabel) accessibleLabel.textContent = label;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Locked on <html>, not <body>: with a non-visible overflow on <html> (the site clips it
|
|
79
|
+
// horizontally) a locked <body> becomes a scroll container of its own, and the sticky
|
|
80
|
+
// header stops sticking and jumps away from the open menu.
|
|
81
|
+
private lockDocumentScroll = () => {
|
|
82
|
+
if (scrollLocks.has(this)) return;
|
|
83
|
+
if (scrollLocks.size === 0) {
|
|
84
|
+
previousRootOverflow = document.documentElement.style.overflow;
|
|
85
|
+
document.documentElement.style.overflow = "hidden";
|
|
86
|
+
}
|
|
87
|
+
scrollLocks.add(this);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
private unlockDocumentScroll = () => {
|
|
91
|
+
if (!scrollLocks.delete(this)) return;
|
|
92
|
+
if (scrollLocks.size === 0) document.documentElement.style.overflow = previousRootOverflow;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
private open = () => {
|
|
96
|
+
if (!this.toggleButton || !this.panel) return;
|
|
97
|
+
window.clearTimeout(this.closeTimer);
|
|
98
|
+
this.panel.hidden = false;
|
|
99
|
+
this.panel.inert = false;
|
|
100
|
+
if (this.backdrop) this.backdrop.hidden = false;
|
|
101
|
+
this.setToggleState(true);
|
|
102
|
+
this.lockDocumentScroll();
|
|
103
|
+
// Commit the closed styles once the panel is displayed, so the open state transitions.
|
|
104
|
+
void this.panel.offsetWidth;
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
this.panel?.setAttribute("data-sf-motion-state", "open");
|
|
107
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "open");
|
|
108
|
+
// The panel only becomes focusable once the open state has been rendered.
|
|
109
|
+
requestAnimationFrame(() => {
|
|
110
|
+
if (this.isOpen()) this.panel?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
private close = (restoreFocus = false, immediate = false) => {
|
|
116
|
+
if (!this.toggleButton || !this.panel) return;
|
|
117
|
+
this.setToggleState(false);
|
|
118
|
+
this.panel.inert = true;
|
|
119
|
+
this.panel.setAttribute("data-sf-motion-state", "closed");
|
|
120
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "closed");
|
|
121
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
122
|
+
this.unlockDocumentScroll();
|
|
123
|
+
|
|
124
|
+
const reducedMotion = getMotionPreference() === "reduce";
|
|
125
|
+
const delay = immediate || reducedMotion ? 0 : SF_MOTION_DRAWER_EXIT_MS;
|
|
126
|
+
window.clearTimeout(this.closeTimer);
|
|
127
|
+
this.closeTimer = window.setTimeout(() => {
|
|
128
|
+
if (!this.isOpen() && this.usesOverlay()) {
|
|
129
|
+
if (this.panel) this.panel.hidden = true;
|
|
130
|
+
if (this.backdrop) this.backdrop.hidden = true;
|
|
131
|
+
}
|
|
132
|
+
}, delay);
|
|
133
|
+
if (restoreFocus) this.toggleButton.focus();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
private syncMode = () => {
|
|
137
|
+
if (!this.toggleButton || !this.panel) return;
|
|
138
|
+
const overlay = this.usesOverlay();
|
|
139
|
+
this.dataset.overlayActive = String(overlay);
|
|
140
|
+
this.toggleButton.hidden = !overlay;
|
|
141
|
+
if (overlay) {
|
|
142
|
+
this.close(false, true);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
window.clearTimeout(this.closeTimer);
|
|
147
|
+
this.setToggleState(false);
|
|
148
|
+
this.panel.hidden = false;
|
|
149
|
+
this.panel.inert = false;
|
|
150
|
+
this.panel.setAttribute("data-sf-motion-state", "open");
|
|
151
|
+
if (this.backdrop) {
|
|
152
|
+
this.backdrop.hidden = true;
|
|
153
|
+
this.backdrop.setAttribute("data-sf-motion-state", "closed");
|
|
154
|
+
}
|
|
155
|
+
this.unlockDocumentScroll();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
private handleToggle = () => this.isOpen() ? this.close(true) : this.open();
|
|
159
|
+
private handleBackdrop = () => this.close(true);
|
|
160
|
+
private handlePanelClick = (event: Event) => {
|
|
161
|
+
if (this.usesOverlay() && event.target instanceof Element && event.target.closest("a")) {
|
|
162
|
+
this.close(false);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
private handleDisclosure = (event: Event) => {
|
|
166
|
+
const current = event.currentTarget;
|
|
167
|
+
if (!(current instanceof HTMLDetailsElement) || !current.open) return;
|
|
168
|
+
current.closest("ul")?.querySelectorAll<HTMLDetailsElement>(":scope > li > details[open]")
|
|
169
|
+
.forEach((details) => {
|
|
170
|
+
if (details !== current) details.removeAttribute("open");
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
private handleOutsidePointer = (event: PointerEvent) => {
|
|
174
|
+
if (this.usesOverlay() || this.contains(event.target as Node)) return;
|
|
175
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
176
|
+
};
|
|
177
|
+
private handleKeydown = (event: KeyboardEvent) => {
|
|
178
|
+
if (event.key === "Escape") {
|
|
179
|
+
if (this.usesOverlay() && this.isOpen()) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
this.close(true);
|
|
182
|
+
} else {
|
|
183
|
+
const disclosure = this.querySelector<HTMLDetailsElement>("details[open]");
|
|
184
|
+
if (disclosure) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
disclosure.removeAttribute("open");
|
|
187
|
+
disclosure.querySelector<HTMLElement>("summary")?.focus();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (event.key !== "Tab" || !this.usesOverlay() || !this.isOpen() || !this.panel || !this.toggleButton) return;
|
|
193
|
+
// The toggle closes the menu, so it belongs to the same tab cycle as the links.
|
|
194
|
+
const focusable = [this.toggleButton, ...this.panel.querySelectorAll<HTMLElement>(FOCUSABLE)]
|
|
195
|
+
.filter((element): element is HTMLElement => element instanceof HTMLElement)
|
|
196
|
+
.filter((element) => !element.hasAttribute("disabled") && !element.closest("[inert]"));
|
|
197
|
+
const visibleFocusable = focusable.filter((element) => element.getClientRects().length > 0);
|
|
198
|
+
const first = visibleFocusable[0];
|
|
199
|
+
const last = visibleFocusable[visibleFocusable.length - 1];
|
|
200
|
+
if (!first || !last) return;
|
|
201
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
last.focus();
|
|
204
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
first.focus();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function registerFlowpressNavigation() {
|
|
212
|
+
if (!customElements.get("flowpress-navigation")) {
|
|
213
|
+
customElements.define("flowpress-navigation", FlowpressNavigation);
|
|
214
|
+
}
|
|
215
|
+
}
|