@styleflow.app/flowpress-astro-core 1.0.0-beta.3 → 1.0.0-beta.31

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.
Files changed (304) hide show
  1. package/CHANGELOG.md +197 -1
  2. package/README.md +111 -3
  3. package/dist/accessibility-panel.d.ts +2 -0
  4. package/dist/accessibility-panel.d.ts.map +1 -0
  5. package/dist/accessibility-panel.js +81 -0
  6. package/dist/accessibility-panel.js.map +1 -0
  7. package/dist/astro/BaseLayout.astro +34 -17
  8. package/dist/astro/CompositionRenderer.astro +168 -0
  9. package/dist/astro/DefaultBlockAdapter.astro +36 -0
  10. package/dist/astro/DefaultTemplate.astro +12 -7
  11. package/dist/astro/FontStylesheets.astro +35 -0
  12. package/dist/astro/GutenbergRenderer.astro +280 -81
  13. package/dist/astro/Media.astro +24 -0
  14. package/dist/astro/StyleflowElement.astro +24 -0
  15. package/dist/astro/ThemeRuntime.astro +26 -0
  16. package/dist/astro/blocks/CarouselBlock.astro +11 -10
  17. package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
  18. package/dist/astro/blocks/ColumnBlock.astro +4 -5
  19. package/dist/astro/blocks/CoverBlock.astro +156 -0
  20. package/dist/astro/blocks/FormBlock.astro +23 -20
  21. package/dist/astro/blocks/GridBlock.astro +4 -4
  22. package/dist/astro/blocks/HeroBlock.astro +6 -6
  23. package/dist/astro/blocks/ImageBlock.astro +6 -6
  24. package/dist/astro/blocks/ListItemFallback.astro +12 -8
  25. package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
  26. package/dist/astro/blocks/SemanticElement.astro +35 -0
  27. package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
  28. package/dist/astro/blocks/TextBlock.astro +33 -28
  29. package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
  30. package/dist/astro/blocks/cover.d.ts +13 -0
  31. package/dist/astro/blocks/cover.d.ts.map +1 -0
  32. package/dist/astro/blocks/cover.js +105 -0
  33. package/dist/astro/blocks/cover.js.map +1 -0
  34. package/dist/astro/blocks/cover.ts +119 -0
  35. package/dist/astro/blocks/helpers.d.ts +10 -1
  36. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  37. package/dist/astro/blocks/helpers.js +57 -44
  38. package/dist/astro/blocks/helpers.js.map +1 -1
  39. package/dist/astro/blocks/helpers.ts +71 -49
  40. package/dist/astro/motion/AccordionRuntime.astro +9 -0
  41. package/dist/astro/motion/MotionBoot.astro +21 -0
  42. package/dist/astro/motion/MotionRuntime.astro +31 -0
  43. package/dist/astro/motion/accordion.css +163 -0
  44. package/dist/astro/motion/accordion.d.ts +3 -0
  45. package/dist/astro/motion/accordion.d.ts.map +1 -0
  46. package/dist/astro/motion/accordion.js +98 -0
  47. package/dist/astro/motion/accordion.js.map +1 -0
  48. package/dist/astro/motion/accordion.ts +109 -0
  49. package/dist/astro/motion/motion-controller.d.ts +12 -0
  50. package/dist/astro/motion/motion-controller.d.ts.map +1 -0
  51. package/dist/astro/motion/motion-controller.js +293 -0
  52. package/dist/astro/motion/motion-controller.js.map +1 -0
  53. package/dist/astro/motion/motion-controller.ts +377 -0
  54. package/dist/astro/motion/motion.css +546 -0
  55. package/dist/astro/motion/motion.d.ts +127 -0
  56. package/dist/astro/motion/motion.d.ts.map +1 -0
  57. package/dist/astro/motion/motion.js +255 -0
  58. package/dist/astro/motion/motion.js.map +1 -0
  59. package/dist/astro/motion/motion.ts +419 -0
  60. package/dist/astro/native/Blob.astro +113 -0
  61. package/dist/astro/native/BlobBlock.astro +52 -0
  62. package/dist/astro/native/CustomFieldValue.astro +88 -0
  63. package/dist/astro/native/LevelTag.astro +20 -0
  64. package/dist/astro/native/MapBlock.astro +41 -0
  65. package/dist/astro/native/NativeHtmlBlock.astro +12 -0
  66. package/dist/astro/native/NativeIconBlock.astro +42 -0
  67. package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
  68. package/dist/astro/native/ReservedLogin.astro +107 -0
  69. package/dist/astro/native/ResolvedBlocks.astro +91 -0
  70. package/dist/astro/native/SyncedPatternContent.astro +94 -0
  71. package/dist/astro/native/TermFieldValue.astro +39 -0
  72. package/dist/astro/native/Timeline.astro +22 -0
  73. package/dist/astro/native/TimelineCardBlock.astro +7 -0
  74. package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
  75. package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
  76. package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
  77. package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
  78. package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
  79. package/dist/astro/native/blob/config.d.ts +49 -0
  80. package/dist/astro/native/blob/config.d.ts.map +1 -0
  81. package/dist/astro/native/blob/config.js +86 -0
  82. package/dist/astro/native/blob/config.js.map +1 -0
  83. package/dist/astro/native/blob/config.ts +132 -0
  84. package/dist/astro/native/blob/controller.d.ts +11 -0
  85. package/dist/astro/native/blob/controller.d.ts.map +1 -0
  86. package/dist/astro/native/blob/controller.js +240 -0
  87. package/dist/astro/native/blob/controller.js.map +1 -0
  88. package/dist/astro/native/blob/controller.ts +248 -0
  89. package/dist/astro/native/blob/geometry.d.ts +2 -0
  90. package/dist/astro/native/blob/geometry.d.ts.map +1 -0
  91. package/dist/astro/native/blob/geometry.js +2 -0
  92. package/dist/astro/native/blob/geometry.js.map +1 -0
  93. package/dist/astro/native/blob/geometry.ts +1 -0
  94. package/dist/astro/native/blob/ids.d.ts +7 -0
  95. package/dist/astro/native/blob/ids.d.ts.map +1 -0
  96. package/dist/astro/native/blob/ids.js +11 -0
  97. package/dist/astro/native/blob/ids.js.map +1 -0
  98. package/dist/astro/native/blob/ids.ts +11 -0
  99. package/dist/astro/native/blob.css +83 -0
  100. package/dist/astro/native/button-template.d.ts +31 -0
  101. package/dist/astro/native/button-template.d.ts.map +1 -0
  102. package/dist/astro/native/button-template.js +54 -0
  103. package/dist/astro/native/button-template.js.map +1 -0
  104. package/dist/astro/native/button-template.ts +92 -0
  105. package/dist/astro/native/button.d.ts +13 -0
  106. package/dist/astro/native/button.d.ts.map +1 -0
  107. package/dist/astro/native/button.js +26 -0
  108. package/dist/astro/native/button.js.map +1 -0
  109. package/dist/astro/native/button.ts +26 -0
  110. package/dist/astro/native/core-block.astro +18 -0
  111. package/dist/astro/native/core-button-fallback.astro +43 -0
  112. package/dist/astro/native/core-button.astro +65 -0
  113. package/dist/astro/native/core-buttons.astro +14 -0
  114. package/dist/astro/native/core-group.astro +25 -0
  115. package/dist/astro/native/core-home-link.astro +12 -0
  116. package/dist/astro/native/core-html.astro +8 -0
  117. package/dist/astro/native/core-icon.astro +7 -0
  118. package/dist/astro/native/core-image.astro +125 -0
  119. package/dist/astro/native/core-navigation-link.astro +71 -0
  120. package/dist/astro/native/core-navigation-submenu.astro +33 -0
  121. package/dist/astro/native/core-navigation.astro +101 -0
  122. package/dist/astro/native/core-page-list-data-item.astro +19 -0
  123. package/dist/astro/native/core-page-list-item.astro +8 -0
  124. package/dist/astro/native/core-page-list.astro +40 -0
  125. package/dist/astro/native/core-post-date.astro +21 -0
  126. package/dist/astro/native/core-post-excerpt.astro +26 -0
  127. package/dist/astro/native/core-post-featured-image.astro +38 -0
  128. package/dist/astro/native/core-post-template-fallback.astro +30 -0
  129. package/dist/astro/native/core-post-template.astro +23 -0
  130. package/dist/astro/native/core-post-terms.astro +47 -0
  131. package/dist/astro/native/core-post-title.astro +23 -0
  132. package/dist/astro/native/core-query-no-results.astro +12 -0
  133. package/dist/astro/native/core-query.astro +22 -0
  134. package/dist/astro/native/core-separator.astro +20 -0
  135. package/dist/astro/native/core-site-title.astro +16 -0
  136. package/dist/astro/native/core-term-description.astro +12 -0
  137. package/dist/astro/native/core-term-name.astro +21 -0
  138. package/dist/astro/native/core-term-template.astro +30 -0
  139. package/dist/astro/native/core-terms-query.astro +19 -0
  140. package/dist/astro/native/core-transparent.astro +11 -0
  141. package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
  142. package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
  143. package/dist/astro/native/flowpress-navigation-controller.js +217 -0
  144. package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
  145. package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
  146. package/dist/astro/native/flowpress-navigation.css +17 -0
  147. package/dist/astro/native/grid-bleed.d.ts +2 -0
  148. package/dist/astro/native/grid-bleed.d.ts.map +1 -0
  149. package/dist/astro/native/grid-bleed.js +123 -0
  150. package/dist/astro/native/grid-bleed.js.map +1 -0
  151. package/dist/astro/native/grid.css +180 -0
  152. package/dist/astro/native/grid.d.ts +17 -0
  153. package/dist/astro/native/grid.d.ts.map +1 -0
  154. package/dist/astro/native/grid.js +103 -0
  155. package/dist/astro/native/grid.js.map +1 -0
  156. package/dist/astro/native/grid.ts +118 -0
  157. package/dist/astro/native/group.css +36 -0
  158. package/dist/astro/native/group.d.ts +15 -0
  159. package/dist/astro/native/group.d.ts.map +1 -0
  160. package/dist/astro/native/group.js +66 -0
  161. package/dist/astro/native/group.js.map +1 -0
  162. package/dist/astro/native/group.ts +61 -0
  163. package/dist/astro/native/html.d.ts +6 -0
  164. package/dist/astro/native/html.d.ts.map +1 -0
  165. package/dist/astro/native/html.js +10 -0
  166. package/dist/astro/native/html.js.map +1 -0
  167. package/dist/astro/native/html.ts +9 -0
  168. package/dist/astro/native/icon.d.ts +3 -0
  169. package/dist/astro/native/icon.d.ts.map +1 -0
  170. package/dist/astro/native/icon.js +23 -0
  171. package/dist/astro/native/icon.js.map +1 -0
  172. package/dist/astro/native/icon.ts +21 -0
  173. package/dist/astro/native/inline-text.css +15 -0
  174. package/dist/astro/native/map.d.ts +14 -0
  175. package/dist/astro/native/map.d.ts.map +1 -0
  176. package/dist/astro/native/map.js +60 -0
  177. package/dist/astro/native/map.js.map +1 -0
  178. package/dist/astro/native/map.ts +70 -0
  179. package/dist/astro/native/motion-preference.d.ts +50 -0
  180. package/dist/astro/native/motion-preference.d.ts.map +1 -0
  181. package/dist/astro/native/motion-preference.js +132 -0
  182. package/dist/astro/native/motion-preference.js.map +1 -0
  183. package/dist/astro/native/motion-preference.ts +158 -0
  184. package/dist/astro/native/motion.d.ts +101 -0
  185. package/dist/astro/native/motion.d.ts.map +1 -0
  186. package/dist/astro/native/motion.js +168 -0
  187. package/dist/astro/native/motion.js.map +1 -0
  188. package/dist/astro/native/motion.ts +312 -0
  189. package/dist/astro/native/query-carousel.d.ts +12 -0
  190. package/dist/astro/native/query-carousel.d.ts.map +1 -0
  191. package/dist/astro/native/query-carousel.js +36 -0
  192. package/dist/astro/native/query-carousel.js.map +1 -0
  193. package/dist/astro/native/query-carousel.ts +56 -0
  194. package/dist/astro/native/query-loop.d.ts +38 -0
  195. package/dist/astro/native/query-loop.d.ts.map +1 -0
  196. package/dist/astro/native/query-loop.js +20 -0
  197. package/dist/astro/native/query-loop.js.map +1 -0
  198. package/dist/astro/native/query-loop.ts +67 -0
  199. package/dist/astro/native/registry.d.ts +3 -0
  200. package/dist/astro/native/registry.d.ts.map +1 -0
  201. package/dist/astro/native/registry.js +84 -0
  202. package/dist/astro/native/registry.js.map +1 -0
  203. package/dist/astro/native/registry.ts +85 -0
  204. package/dist/astro/native/sf-block-binding.astro +20 -0
  205. package/dist/astro/native/sf-post-field.astro +9 -0
  206. package/dist/astro/native/sf-term-field.astro +9 -0
  207. package/dist/astro/native/timeline.css +4 -0
  208. package/dist/astro/native/timeline.d.ts +28 -0
  209. package/dist/astro/native/timeline.d.ts.map +1 -0
  210. package/dist/astro/native/timeline.js +43 -0
  211. package/dist/astro/native/timeline.js.map +1 -0
  212. package/dist/astro/native/timeline.ts +79 -0
  213. package/dist/astro/preferences/AccessibilityPanel.astro +105 -0
  214. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  215. package/dist/astro/preferences/MotionToggle.astro +27 -0
  216. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  217. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  218. package/dist/astro/preferences/Toggle.astro +50 -0
  219. package/dist/astro/preferences/preferences.css +125 -0
  220. package/dist/block-renderers.d.ts +22 -3
  221. package/dist/block-renderers.d.ts.map +1 -1
  222. package/dist/block-renderers.js.map +1 -1
  223. package/dist/client.d.ts +17 -1
  224. package/dist/client.d.ts.map +1 -1
  225. package/dist/client.js +63 -9
  226. package/dist/client.js.map +1 -1
  227. package/dist/composition.d.ts +14 -0
  228. package/dist/composition.d.ts.map +1 -0
  229. package/dist/composition.js +125 -0
  230. package/dist/composition.js.map +1 -0
  231. package/dist/default-blocks.d.ts +9 -0
  232. package/dist/default-blocks.d.ts.map +1 -0
  233. package/dist/default-blocks.js +120 -0
  234. package/dist/default-blocks.js.map +1 -0
  235. package/dist/env.d.ts +9 -0
  236. package/dist/env.d.ts.map +1 -1
  237. package/dist/env.js +20 -0
  238. package/dist/env.js.map +1 -1
  239. package/dist/index.d.ts +8 -0
  240. package/dist/index.d.ts.map +1 -1
  241. package/dist/index.js +7 -0
  242. package/dist/index.js.map +1 -1
  243. package/dist/links.d.ts +5 -0
  244. package/dist/links.d.ts.map +1 -0
  245. package/dist/links.js +32 -0
  246. package/dist/links.js.map +1 -0
  247. package/dist/media.d.ts +28 -0
  248. package/dist/media.d.ts.map +1 -0
  249. package/dist/media.js +212 -0
  250. package/dist/media.js.map +1 -0
  251. package/dist/motion-preference.d.ts +50 -0
  252. package/dist/motion-preference.d.ts.map +1 -0
  253. package/dist/motion-preference.js +132 -0
  254. package/dist/motion-preference.js.map +1 -0
  255. package/dist/preferences-runtime.d.ts +3 -0
  256. package/dist/preferences-runtime.d.ts.map +1 -0
  257. package/dist/preferences-runtime.js +23 -0
  258. package/dist/preferences-runtime.js.map +1 -0
  259. package/dist/preferences-styleflow.d.ts +3 -0
  260. package/dist/preferences-styleflow.d.ts.map +1 -0
  261. package/dist/preferences-styleflow.js +14 -0
  262. package/dist/preferences-styleflow.js.map +1 -0
  263. package/dist/preferences.d.ts +4 -0
  264. package/dist/preferences.d.ts.map +1 -0
  265. package/dist/preferences.js +4 -0
  266. package/dist/preferences.js.map +1 -0
  267. package/dist/reserved-area.d.ts +10 -0
  268. package/dist/reserved-area.d.ts.map +1 -0
  269. package/dist/reserved-area.js +93 -0
  270. package/dist/reserved-area.js.map +1 -0
  271. package/dist/styleflow.d.ts +18 -1
  272. package/dist/styleflow.d.ts.map +1 -1
  273. package/dist/styleflow.js +82 -11
  274. package/dist/styleflow.js.map +1 -1
  275. package/dist/svg-media-runtime.d.ts +3 -0
  276. package/dist/svg-media-runtime.d.ts.map +1 -0
  277. package/dist/svg-media-runtime.js +33 -0
  278. package/dist/svg-media-runtime.js.map +1 -0
  279. package/dist/svg-media-types.d.ts +11 -0
  280. package/dist/svg-media-types.d.ts.map +1 -0
  281. package/dist/svg-media-types.js +2 -0
  282. package/dist/svg-media-types.js.map +1 -0
  283. package/dist/svg-media.d.ts +10 -0
  284. package/dist/svg-media.d.ts.map +1 -0
  285. package/dist/svg-media.js +34 -0
  286. package/dist/svg-media.js.map +1 -0
  287. package/dist/templates.d.ts +16 -16
  288. package/dist/text.d.ts +3 -0
  289. package/dist/text.d.ts.map +1 -0
  290. package/dist/text.js +6 -0
  291. package/dist/text.js.map +1 -0
  292. package/dist/theme-runtime.d.ts +16 -0
  293. package/dist/theme-runtime.d.ts.map +1 -0
  294. package/dist/theme-runtime.js +100 -0
  295. package/dist/theme-runtime.js.map +1 -0
  296. package/dist/tsconfig.tsbuildinfo +1 -1
  297. package/dist/types.d.ts +84 -1
  298. package/dist/types.d.ts.map +1 -1
  299. package/dist/types.js.map +1 -1
  300. package/dist/vivid-colors-preference.d.ts +31 -0
  301. package/dist/vivid-colors-preference.d.ts.map +1 -0
  302. package/dist/vivid-colors-preference.js +102 -0
  303. package/dist/vivid-colors-preference.js.map +1 -0
  304. package/package.json +53 -4
@@ -0,0 +1,26 @@
1
+ ---
2
+ import { decodeFlowpressText } from "../../text.js";
3
+ import StyleflowElement from "../StyleflowElement.astro";
4
+ import type { FlowpressBlockRendererProps } from "../../index.js";
5
+ import { classNames, text } from "./query-loop.js";
6
+
7
+ // Excerpt of the current loop item, trimmed to `excerptLength` words.
8
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
9
+ const attributes = block.attributes;
10
+ const excerpt = decodeFlowpressText(block.resolvedData?.excerpt);
11
+ const url = text(block.resolvedData?.url);
12
+ const moreText = decodeFlowpressText(attributes.moreText).trim();
13
+ const rootProps = { ...htmlProps, class: classNames("wp-block-post-excerpt", htmlProps.class) };
14
+ ---
15
+
16
+ {excerpt ? (
17
+ <StyleflowElement as="div" {...rootProps} {...styleflowProps}>
18
+ <StyleflowElement as="p" class="wp-block-post-excerpt__excerpt">
19
+ {excerpt}
20
+ {moreText && url && !attributes.showMoreOnNewLine ? <> <StyleflowElement as="a" class="wp-block-post-excerpt__more-link" href={url}>{moreText}</StyleflowElement></> : null}
21
+ </StyleflowElement>
22
+ {moreText && url && attributes.showMoreOnNewLine ? (
23
+ <StyleflowElement as="p" class="wp-block-post-excerpt__more-text"><StyleflowElement as="a" class="wp-block-post-excerpt__more-link" href={url}>{moreText}</StyleflowElement></StyleflowElement>
24
+ ) : null}
25
+ </StyleflowElement>
26
+ ) : null}
@@ -0,0 +1,38 @@
1
+ ---
2
+ import Media from "../Media.astro";
3
+ import StyleflowElement from "../StyleflowElement.astro";
4
+ import type { FlowpressBlockRendererProps } from "../../index.js";
5
+ import { classNames, externalRel, text, type ResolvedImage } from "./query-loop.js";
6
+
7
+ // Featured image of the current loop item, with WordPress responsive sources.
8
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
9
+ const attributes = block.attributes;
10
+ const image = (block.resolvedData ?? {}) as ResolvedImage;
11
+ const src = text(image.url);
12
+ const href = attributes.isLink ? text(image.href) : "";
13
+ const aspectRatio = text(attributes.aspectRatio).replace(/\s+/g, "");
14
+ const rootProps = {
15
+ ...htmlProps,
16
+ class: classNames("wp-block-post-featured-image", "project-field__image", htmlProps.class),
17
+ "data-aspect-ratio": aspectRatio && aspectRatio !== "auto" ? aspectRatio : undefined,
18
+ };
19
+ const imageProps = {
20
+ src,
21
+ srcset: image.srcSet || undefined,
22
+ sizes: image.srcSet ? image.sizes || undefined : undefined,
23
+ width: image.width,
24
+ height: image.height,
25
+ alt: typeof attributes.alt === "string" && attributes.alt ? attributes.alt : image.alt ?? "",
26
+ class: image.id ? `wp-image-${image.id}` : undefined,
27
+ loading: "lazy" as const,
28
+ decoding: "async" as const,
29
+ };
30
+ ---
31
+
32
+ {src ? (
33
+ <StyleflowElement as="figure" {...rootProps} {...styleflowProps}>
34
+ {href
35
+ ? <StyleflowElement as="a" href={href} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><Media {...imageProps} /></StyleflowElement>
36
+ : <Media {...imageProps} />}
37
+ </StyleflowElement>
38
+ ) : 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/post-template: one resolved copy of the template per queried post.
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-post-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-post", `post-${item.id}`, item.postType ? `type-${item.postType}` : "", 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,23 @@
1
+ ---
2
+ import DefaultBlockAdapter from "./core-post-template-fallback.astro";
3
+ // Query Loop carousel with the shared static fallback.
4
+ import ResolvedBlocks from "./ResolvedBlocks.astro";
5
+ import type { FlowpressBlockRendererProps } from "../../index.js";
6
+ import { queryCarouselBlocks, type QueryCarouselData } from "./query-carousel.js";
7
+
8
+ const props = Astro.props as FlowpressBlockRendererProps;
9
+ const blocks = queryCarouselBlocks(props);
10
+ const pass = (props.block.resolvedData ?? {}) as QueryCarouselData;
11
+ ---
12
+
13
+ {blocks === undefined ? (
14
+ <DefaultBlockAdapter {...props} />
15
+ ) : (
16
+ <ResolvedBlocks {...props} blocks={blocks} pass={pass} />
17
+ )}
18
+
19
+ <style is:global>
20
+ /* Splide core hides its root until mount. Keep the shared static grid
21
+ readable when JavaScript is unavailable or initialization fails. */
22
+ .flowpress-query-carousel:not(.is-initialized) { visibility: visible; }
23
+ </style>
@@ -0,0 +1,47 @@
1
+ ---
2
+ import { decodeFlowpressText } from "../../text.js";
3
+ import StyleflowElement from "../StyleflowElement.astro";
4
+ import type { FlowpressBlockRendererProps } from "../../index.js";
5
+ import TermFieldValue from "./TermFieldValue.astro";
6
+ import { classNames, text } from "./query-loop.js";
7
+
8
+ // Terms of one taxonomy assigned to the current loop item. With a term custom
9
+ // field picked (custom-fields.php) each term shows the field instead of, or
10
+ // next to, its name; a term without a value keeps its name.
11
+ interface TermField { as?: string | undefined; value?: unknown }
12
+ interface TermLink { id: number; name: string; url: string; field?: TermField }
13
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
14
+ const attributes = block.attributes;
15
+ const terms = (Array.isArray(block.resolvedData?.terms) ? block.resolvedData.terms : []) as TermLink[];
16
+ const display = text(block.resolvedData?.display);
17
+ const separator = typeof attributes.separator === "string" ? decodeFlowpressText(attributes.separator) : ", ";
18
+ const prefix = decodeFlowpressText(attributes.prefix);
19
+ const suffix = decodeFlowpressText(attributes.suffix);
20
+ const rootProps = {
21
+ ...htmlProps,
22
+ class: classNames("wp-block-post-terms", `taxonomy-${text(attributes.term)}`, htmlProps.class),
23
+ };
24
+ ---
25
+
26
+ {terms.length > 0 ? (
27
+ <StyleflowElement as="div" {...rootProps} {...styleflowProps}>
28
+ {prefix ? <StyleflowElement as="span" class="wp-block-post-terms__prefix">{prefix}</StyleflowElement> : null}
29
+ {terms.map((term, index) => {
30
+ const field = display === "name" ? undefined : term.field;
31
+ const label = field ? (
32
+ <>
33
+ {display === "both" ? <StyleflowElement as="span" class="wp-block-post-terms__name">{decodeFlowpressText(term.name)}</StyleflowElement> : null}
34
+ {display === "both" ? " " : null}
35
+ <TermFieldValue field={field} fallbackAlt={display === "field" ? term.name : ""} />
36
+ </>
37
+ ) : decodeFlowpressText(term.name);
38
+ return (
39
+ <>
40
+ {index > 0 ? <StyleflowElement as="span" class="wp-block-post-terms__separator">{separator}</StyleflowElement> : null}
41
+ {term.url ? <StyleflowElement as="a" href={term.url} rel="tag">{label}</StyleflowElement> : <StyleflowElement as="span">{label}</StyleflowElement>}
42
+ </>
43
+ );
44
+ })}
45
+ {suffix ? <StyleflowElement as="span" class="wp-block-post-terms__suffix">{suffix}</StyleflowElement> : null}
46
+ </StyleflowElement>
47
+ ) : null}
@@ -0,0 +1,23 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import type { FlowpressBlockRendererProps } from "../../index.js";
4
+ import LevelTag from "./LevelTag.astro";
5
+ import { classNames, externalRel, headingLevel, text } from "./query-loop.js";
6
+
7
+ // Title of the current loop item (or of the route's post outside a loop).
8
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
9
+ const attributes = block.attributes;
10
+ const title = text(block.resolvedData?.title);
11
+ const url = text(block.resolvedData?.url);
12
+ const level = headingLevel(attributes.level, 2);
13
+ const tag = level === 0 ? "p" : `h${level}`;
14
+ const rootProps = { ...htmlProps, class: classNames("wp-block-post-title", htmlProps.class) };
15
+ ---
16
+
17
+ {title ? (
18
+ <LevelTag tag={tag} {...rootProps} {...styleflowProps}>
19
+ {attributes.isLink && url
20
+ ? <StyleflowElement as="a" href={url} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><Fragment set:html={title} /></StyleflowElement>
21
+ : <Fragment set:html={title} />}
22
+ </LevelTag>
23
+ ) : null}
@@ -0,0 +1,12 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import type { FlowpressBlockRendererProps } from "../../index.js";
4
+ import { classNames } from "./query-loop.js";
5
+
6
+ // Shown only when the parent Query Loop returned no posts (query-loop.php).
7
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
8
+ const visible = block.resolvedData?.visible === true;
9
+ const rootProps = { ...htmlProps, class: classNames("wp-block-query-no-results", htmlProps.class) };
10
+ ---
11
+
12
+ {visible ? <StyleflowElement as="div" {...rootProps} {...styleflowProps}><slot /></StyleflowElement> : null}
@@ -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,20 @@
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:not(.is-style-wide):not(.is-style-dots) { width: 100px; max-width: 100%; margin-inline: auto; }
16
+ .wp-block-separator.is-style-wide { width: 100%; }
17
+ .wp-block-separator.is-style-dots { border: 0; height: auto; text-align: center; }
18
+ .wp-block-separator.is-style-dots::before { content: "···"; color: inherit; letter-spacing: 1em; padding-inline-start: 1em; }
19
+ .wp-block-separator[data-sf-no-border="true"] { border: 0; }
20
+ </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,2 @@
1
+ export declare function registerFlowpressNavigation(): void;
2
+ //# sourceMappingURL=flowpress-navigation-controller.d.ts.map
@@ -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