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

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 (243) hide show
  1. package/CHANGELOG.md +190 -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 +157 -0
  9. package/dist/astro/DefaultBlockAdapter.astro +35 -0
  10. package/dist/astro/DefaultTemplate.astro +12 -7
  11. package/dist/astro/GutenbergRenderer.astro +240 -80
  12. package/dist/astro/StyleflowElement.astro +23 -0
  13. package/dist/astro/ThemeRuntime.astro +26 -0
  14. package/dist/astro/blocks/CarouselBlock.astro +8 -10
  15. package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
  16. package/dist/astro/blocks/ColumnBlock.astro +4 -5
  17. package/dist/astro/blocks/CoverBlock.astro +155 -0
  18. package/dist/astro/blocks/FormBlock.astro +23 -20
  19. package/dist/astro/blocks/GridBlock.astro +4 -4
  20. package/dist/astro/blocks/HeroBlock.astro +4 -5
  21. package/dist/astro/blocks/ImageBlock.astro +4 -5
  22. package/dist/astro/blocks/ListItemFallback.astro +10 -7
  23. package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
  24. package/dist/astro/blocks/SemanticElement.astro +35 -0
  25. package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
  26. package/dist/astro/blocks/TextBlock.astro +33 -28
  27. package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
  28. package/dist/astro/blocks/cover.d.ts +13 -0
  29. package/dist/astro/blocks/cover.d.ts.map +1 -0
  30. package/dist/astro/blocks/cover.js +105 -0
  31. package/dist/astro/blocks/cover.js.map +1 -0
  32. package/dist/astro/blocks/cover.ts +119 -0
  33. package/dist/astro/blocks/helpers.d.ts +7 -0
  34. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  35. package/dist/astro/blocks/helpers.js +52 -41
  36. package/dist/astro/blocks/helpers.js.map +1 -1
  37. package/dist/astro/blocks/helpers.ts +64 -45
  38. package/dist/astro/native/Blob.astro +113 -0
  39. package/dist/astro/native/BlobBlock.astro +52 -0
  40. package/dist/astro/native/CustomFieldValue.astro +87 -0
  41. package/dist/astro/native/LevelTag.astro +20 -0
  42. package/dist/astro/native/MapBlock.astro +41 -0
  43. package/dist/astro/native/NativeHtmlBlock.astro +12 -0
  44. package/dist/astro/native/NativeIconBlock.astro +42 -0
  45. package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
  46. package/dist/astro/native/ResolvedBlocks.astro +89 -0
  47. package/dist/astro/native/SyncedPatternContent.astro +92 -0
  48. package/dist/astro/native/TermFieldValue.astro +38 -0
  49. package/dist/astro/native/Timeline.astro +21 -0
  50. package/dist/astro/native/TimelineCardBlock.astro +7 -0
  51. package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
  52. package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
  53. package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
  54. package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
  55. package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
  56. package/dist/astro/native/blob/config.d.ts +49 -0
  57. package/dist/astro/native/blob/config.d.ts.map +1 -0
  58. package/dist/astro/native/blob/config.js +86 -0
  59. package/dist/astro/native/blob/config.js.map +1 -0
  60. package/dist/astro/native/blob/config.ts +132 -0
  61. package/dist/astro/native/blob/controller.d.ts +11 -0
  62. package/dist/astro/native/blob/controller.d.ts.map +1 -0
  63. package/dist/astro/native/blob/controller.js +240 -0
  64. package/dist/astro/native/blob/controller.js.map +1 -0
  65. package/dist/astro/native/blob/controller.ts +248 -0
  66. package/dist/astro/native/blob/geometry.d.ts +2 -0
  67. package/dist/astro/native/blob/geometry.d.ts.map +1 -0
  68. package/dist/astro/native/blob/geometry.js +2 -0
  69. package/dist/astro/native/blob/geometry.js.map +1 -0
  70. package/dist/astro/native/blob/geometry.ts +1 -0
  71. package/dist/astro/native/blob/ids.d.ts +7 -0
  72. package/dist/astro/native/blob/ids.d.ts.map +1 -0
  73. package/dist/astro/native/blob/ids.js +11 -0
  74. package/dist/astro/native/blob/ids.js.map +1 -0
  75. package/dist/astro/native/blob/ids.ts +11 -0
  76. package/dist/astro/native/blob.css +83 -0
  77. package/dist/astro/native/button.d.ts +13 -0
  78. package/dist/astro/native/button.d.ts.map +1 -0
  79. package/dist/astro/native/button.js +26 -0
  80. package/dist/astro/native/button.js.map +1 -0
  81. package/dist/astro/native/button.ts +26 -0
  82. package/dist/astro/native/core-block.astro +18 -0
  83. package/dist/astro/native/core-button.astro +43 -0
  84. package/dist/astro/native/core-buttons.astro +14 -0
  85. package/dist/astro/native/core-group.astro +23 -0
  86. package/dist/astro/native/core-home-link.astro +12 -0
  87. package/dist/astro/native/core-html.astro +8 -0
  88. package/dist/astro/native/core-icon.astro +7 -0
  89. package/dist/astro/native/core-image.astro +124 -0
  90. package/dist/astro/native/core-navigation-link.astro +71 -0
  91. package/dist/astro/native/core-navigation-submenu.astro +33 -0
  92. package/dist/astro/native/core-navigation.astro +94 -0
  93. package/dist/astro/native/core-page-list-data-item.astro +19 -0
  94. package/dist/astro/native/core-page-list-item.astro +8 -0
  95. package/dist/astro/native/core-page-list.astro +40 -0
  96. package/dist/astro/native/core-post-date.astro +21 -0
  97. package/dist/astro/native/core-post-excerpt.astro +26 -0
  98. package/dist/astro/native/core-post-featured-image.astro +37 -0
  99. package/dist/astro/native/core-post-template.astro +30 -0
  100. package/dist/astro/native/core-post-terms.astro +47 -0
  101. package/dist/astro/native/core-post-title.astro +23 -0
  102. package/dist/astro/native/core-query-no-results.astro +12 -0
  103. package/dist/astro/native/core-query.astro +22 -0
  104. package/dist/astro/native/core-separator.astro +20 -0
  105. package/dist/astro/native/core-site-title.astro +16 -0
  106. package/dist/astro/native/core-term-description.astro +12 -0
  107. package/dist/astro/native/core-term-name.astro +21 -0
  108. package/dist/astro/native/core-term-template.astro +30 -0
  109. package/dist/astro/native/core-terms-query.astro +19 -0
  110. package/dist/astro/native/core-transparent.astro +11 -0
  111. package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
  112. package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
  113. package/dist/astro/native/flowpress-navigation-controller.js +217 -0
  114. package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
  115. package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
  116. package/dist/astro/native/flowpress-navigation.css +17 -0
  117. package/dist/astro/native/grid-bleed.js +106 -0
  118. package/dist/astro/native/grid.css +180 -0
  119. package/dist/astro/native/grid.d.ts +17 -0
  120. package/dist/astro/native/grid.d.ts.map +1 -0
  121. package/dist/astro/native/grid.js +103 -0
  122. package/dist/astro/native/grid.js.map +1 -0
  123. package/dist/astro/native/grid.ts +118 -0
  124. package/dist/astro/native/html.d.ts +6 -0
  125. package/dist/astro/native/html.d.ts.map +1 -0
  126. package/dist/astro/native/html.js +10 -0
  127. package/dist/astro/native/html.js.map +1 -0
  128. package/dist/astro/native/html.ts +9 -0
  129. package/dist/astro/native/icon.d.ts +3 -0
  130. package/dist/astro/native/icon.d.ts.map +1 -0
  131. package/dist/astro/native/icon.js +23 -0
  132. package/dist/astro/native/icon.js.map +1 -0
  133. package/dist/astro/native/icon.ts +21 -0
  134. package/dist/astro/native/map.d.ts +14 -0
  135. package/dist/astro/native/map.d.ts.map +1 -0
  136. package/dist/astro/native/map.js +60 -0
  137. package/dist/astro/native/map.js.map +1 -0
  138. package/dist/astro/native/map.ts +70 -0
  139. package/dist/astro/native/motion-preference.d.ts +50 -0
  140. package/dist/astro/native/motion-preference.d.ts.map +1 -0
  141. package/dist/astro/native/motion-preference.js +132 -0
  142. package/dist/astro/native/motion-preference.js.map +1 -0
  143. package/dist/astro/native/motion-preference.ts +158 -0
  144. package/dist/astro/native/motion.d.ts +101 -0
  145. package/dist/astro/native/motion.d.ts.map +1 -0
  146. package/dist/astro/native/motion.js +168 -0
  147. package/dist/astro/native/motion.js.map +1 -0
  148. package/dist/astro/native/motion.ts +312 -0
  149. package/dist/astro/native/query-loop.d.ts +38 -0
  150. package/dist/astro/native/query-loop.d.ts.map +1 -0
  151. package/dist/astro/native/query-loop.js +20 -0
  152. package/dist/astro/native/query-loop.js.map +1 -0
  153. package/dist/astro/native/query-loop.ts +67 -0
  154. package/dist/astro/native/registry.d.ts +3 -0
  155. package/dist/astro/native/registry.d.ts.map +1 -0
  156. package/dist/astro/native/registry.js +81 -0
  157. package/dist/astro/native/registry.js.map +1 -0
  158. package/dist/astro/native/registry.ts +81 -0
  159. package/dist/astro/native/sf-block-binding.astro +20 -0
  160. package/dist/astro/native/sf-post-field.astro +9 -0
  161. package/dist/astro/native/sf-term-field.astro +9 -0
  162. package/dist/astro/native/timeline.css +4 -0
  163. package/dist/astro/native/timeline.d.ts +28 -0
  164. package/dist/astro/native/timeline.d.ts.map +1 -0
  165. package/dist/astro/native/timeline.js +43 -0
  166. package/dist/astro/native/timeline.js.map +1 -0
  167. package/dist/astro/native/timeline.ts +79 -0
  168. package/dist/astro/preferences/AccessibilityPanel.astro +118 -0
  169. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  170. package/dist/astro/preferences/MotionToggle.astro +27 -0
  171. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  172. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  173. package/dist/astro/preferences/Toggle.astro +50 -0
  174. package/dist/astro/preferences/preferences.css +125 -0
  175. package/dist/block-renderers.d.ts +20 -3
  176. package/dist/block-renderers.d.ts.map +1 -1
  177. package/dist/block-renderers.js.map +1 -1
  178. package/dist/client.d.ts +17 -1
  179. package/dist/client.d.ts.map +1 -1
  180. package/dist/client.js +63 -9
  181. package/dist/client.js.map +1 -1
  182. package/dist/composition.d.ts +14 -0
  183. package/dist/composition.d.ts.map +1 -0
  184. package/dist/composition.js +124 -0
  185. package/dist/composition.js.map +1 -0
  186. package/dist/default-blocks.d.ts +9 -0
  187. package/dist/default-blocks.d.ts.map +1 -0
  188. package/dist/default-blocks.js +118 -0
  189. package/dist/default-blocks.js.map +1 -0
  190. package/dist/env.d.ts +9 -0
  191. package/dist/env.d.ts.map +1 -1
  192. package/dist/env.js +20 -0
  193. package/dist/env.js.map +1 -1
  194. package/dist/index.d.ts +8 -0
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +7 -0
  197. package/dist/index.js.map +1 -1
  198. package/dist/links.d.ts +5 -0
  199. package/dist/links.d.ts.map +1 -0
  200. package/dist/links.js +32 -0
  201. package/dist/links.js.map +1 -0
  202. package/dist/media.d.ts +28 -0
  203. package/dist/media.d.ts.map +1 -0
  204. package/dist/media.js +212 -0
  205. package/dist/media.js.map +1 -0
  206. package/dist/motion-preference.d.ts +50 -0
  207. package/dist/motion-preference.d.ts.map +1 -0
  208. package/dist/motion-preference.js +132 -0
  209. package/dist/motion-preference.js.map +1 -0
  210. package/dist/preferences-runtime.d.ts +3 -0
  211. package/dist/preferences-runtime.d.ts.map +1 -0
  212. package/dist/preferences-runtime.js +23 -0
  213. package/dist/preferences-runtime.js.map +1 -0
  214. package/dist/preferences-styleflow.d.ts +3 -0
  215. package/dist/preferences-styleflow.d.ts.map +1 -0
  216. package/dist/preferences-styleflow.js +14 -0
  217. package/dist/preferences-styleflow.js.map +1 -0
  218. package/dist/preferences.d.ts +4 -0
  219. package/dist/preferences.d.ts.map +1 -0
  220. package/dist/preferences.js +4 -0
  221. package/dist/preferences.js.map +1 -0
  222. package/dist/styleflow.d.ts +16 -1
  223. package/dist/styleflow.d.ts.map +1 -1
  224. package/dist/styleflow.js +76 -7
  225. package/dist/styleflow.js.map +1 -1
  226. package/dist/templates.d.ts +16 -16
  227. package/dist/text.d.ts +3 -0
  228. package/dist/text.d.ts.map +1 -0
  229. package/dist/text.js +6 -0
  230. package/dist/text.js.map +1 -0
  231. package/dist/theme-runtime.d.ts +16 -0
  232. package/dist/theme-runtime.d.ts.map +1 -0
  233. package/dist/theme-runtime.js +100 -0
  234. package/dist/theme-runtime.js.map +1 -0
  235. package/dist/tsconfig.tsbuildinfo +1 -1
  236. package/dist/types.d.ts +84 -1
  237. package/dist/types.d.ts.map +1 -1
  238. package/dist/types.js.map +1 -1
  239. package/dist/vivid-colors-preference.d.ts +31 -0
  240. package/dist/vivid-colors-preference.d.ts.map +1 -0
  241. package/dist/vivid-colors-preference.js +102 -0
  242. package/dist/vivid-colors-preference.js.map +1 -0
  243. package/package.json +26 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/astro/native/grid.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAKhF,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAU,EAAE;IACzD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,aAA6B,EAAE,EAAW,EAAE,CAC/E,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;OACtF,UAAU,CAAC,MAAM,EAAE,IAAI,KAAK,MAAM,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAA0B,EAAU,EAAE;IAC/D,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,EAA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Breakpoints = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\nexport type GridBreakpoint = typeof gridBreakpoints[number];\ntype Values = Partial<Record<GridBreakpoint, number>>;\ntype GridAttributes = Record<string, any>;\n\nconst count = (value: unknown, fallback: number): number => {\n const n = Number(value);\n return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;\n};\n\nexport const isGrid = (name: string, attributes: GridAttributes = {}): boolean =>\n (name === \"core/group\" || name === \"core/post-template\" || name === \"core/term-template\")\n && attributes.layout?.type === \"grid\";\n\nexport const gridValues = (attributes: GridAttributes): Values => {\n const layout = attributes.layout || {};\n const values: Values = { base: count(layout.columnCount, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressColumns?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const spanValues = (attributes: GridAttributes): Values => {\n const layout = attributes.style?.layout || {};\n const values: Values = { base: count(layout.columnSpan, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressGridSpan?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const effectiveValues = (values: Values): Record<GridBreakpoint, number> => {\n let current = values.base ?? 1;\n return Object.fromEntries(gridBreakpoints.map((breakpoint) => {\n current = values[breakpoint] ?? current;\n return [breakpoint, current];\n })) as Record<GridBreakpoint, number>;\n};\n\nexport const gridClasses = (attributes: GridAttributes): string[] => {\n const values = gridValues(attributes);\n const align = attributes.layout?.flowpressAlign;\n return [\n \"fp-grid\",\n ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),\n ...( [\"start\", \"center\", \"end\", \"stretch\"].includes(align) ? [`fp-align-${align}`] : []),\n ];\n};\n\nexport const spanClasses = (attributes: GridAttributes): string[] => {\n const values = spanValues(attributes);\n return [\"fp-grid-item\", ...gridBreakpoints.flatMap((breakpoint) =>\n values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : []\n )];\n};\n\nexport const usedSpanClasses = (parent: GridAttributes, child: GridAttributes): string[] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = effectiveValues(spanValues(child));\n return gridBreakpoints.map((breakpoint) =>\n `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`\n );\n};\n\nexport const bleedClasses = (parent: GridAttributes, children: GridAttributes[]): string[][] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = children.map((child) => effectiveValues(spanValues(child)));\n const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? [\"fp-bleed-managed\"] : [] as string[]);\n for (const breakpoint of gridBreakpoints) {\n let position = 0;\n children.forEach((child, index) => {\n const width = Math.min(spans[index]![breakpoint], columns[breakpoint]);\n if (position + width > columns[breakpoint]) position = 0;\n const start = position === 0;\n const end = position + width === columns[breakpoint];\n const bleed = child.style?.layout?.flowpressGridBleed;\n const from = gridBreakpoints.indexOf(bleed?.from || \"base\");\n if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&\n ((bleed.side === \"start\" && start) || (bleed.side === \"end\" && end))) {\n result[index]!.push(`fp-bleed-${breakpoint}-${bleed.side}`);\n }\n position += width;\n if (position === columns[breakpoint]) position = 0;\n });\n }\n return result;\n};\n\nconst appendClasses = (attributes: GridAttributes, classes: string[]): GridAttributes => ({\n ...attributes,\n className: [...new Set([...(attributes.className || \"\").split(/\\s+/), ...classes].filter(Boolean))].join(\" \"),\n});\n\n/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */\nexport const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {\n const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;\n const attributes = (block.attributes || {}) as GridAttributes;\n if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;\n const children = innerBlocks ?? [];\n const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));\n return {\n ...block,\n attributes: appendClasses({ layoutRole: \"stack\", density: \"regular\", ...attributes }, gridClasses(attributes)),\n innerBlocks: children.map((child, index) => ({\n ...child,\n attributes: appendClasses(child.attributes as GridAttributes || {}, [\n ...spanClasses(child.attributes as GridAttributes || {}),\n ...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),\n ...(bleed[index] ?? []),\n ]),\n })),\n };\n});\n"]}
@@ -0,0 +1,118 @@
1
+ import type { FlowpressBlock } from "../../index.js";
2
+
3
+ export const gridBreakpoints = ["base", "sm", "md", "lg", "xl", "2xl"] as const;
4
+ export type GridBreakpoint = typeof gridBreakpoints[number];
5
+ type Values = Partial<Record<GridBreakpoint, number>>;
6
+ type GridAttributes = Record<string, any>;
7
+
8
+ const count = (value: unknown, fallback: number): number => {
9
+ const n = Number(value);
10
+ return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;
11
+ };
12
+
13
+ export const isGrid = (name: string, attributes: GridAttributes = {}): boolean =>
14
+ (name === "core/group" || name === "core/post-template" || name === "core/term-template")
15
+ && attributes.layout?.type === "grid";
16
+
17
+ export const gridValues = (attributes: GridAttributes): Values => {
18
+ const layout = attributes.layout || {};
19
+ const values: Values = { base: count(layout.columnCount, 1) };
20
+ for (const breakpoint of gridBreakpoints.slice(1)) {
21
+ const value = layout.flowpressColumns?.[breakpoint];
22
+ if (value !== undefined) values[breakpoint] = count(value, values.base!);
23
+ }
24
+ return values;
25
+ };
26
+
27
+ export const spanValues = (attributes: GridAttributes): Values => {
28
+ const layout = attributes.style?.layout || {};
29
+ const values: Values = { base: count(layout.columnSpan, 1) };
30
+ for (const breakpoint of gridBreakpoints.slice(1)) {
31
+ const value = layout.flowpressGridSpan?.[breakpoint];
32
+ if (value !== undefined) values[breakpoint] = count(value, values.base!);
33
+ }
34
+ return values;
35
+ };
36
+
37
+ export const effectiveValues = (values: Values): Record<GridBreakpoint, number> => {
38
+ let current = values.base ?? 1;
39
+ return Object.fromEntries(gridBreakpoints.map((breakpoint) => {
40
+ current = values[breakpoint] ?? current;
41
+ return [breakpoint, current];
42
+ })) as Record<GridBreakpoint, number>;
43
+ };
44
+
45
+ export const gridClasses = (attributes: GridAttributes): string[] => {
46
+ const values = gridValues(attributes);
47
+ const align = attributes.layout?.flowpressAlign;
48
+ return [
49
+ "fp-grid",
50
+ ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),
51
+ ...( ["start", "center", "end", "stretch"].includes(align) ? [`fp-align-${align}`] : []),
52
+ ];
53
+ };
54
+
55
+ export const spanClasses = (attributes: GridAttributes): string[] => {
56
+ const values = spanValues(attributes);
57
+ return ["fp-grid-item", ...gridBreakpoints.flatMap((breakpoint) =>
58
+ values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : []
59
+ )];
60
+ };
61
+
62
+ export const usedSpanClasses = (parent: GridAttributes, child: GridAttributes): string[] => {
63
+ const columns = effectiveValues(gridValues(parent));
64
+ const spans = effectiveValues(spanValues(child));
65
+ return gridBreakpoints.map((breakpoint) =>
66
+ `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`
67
+ );
68
+ };
69
+
70
+ export const bleedClasses = (parent: GridAttributes, children: GridAttributes[]): string[][] => {
71
+ const columns = effectiveValues(gridValues(parent));
72
+ const spans = children.map((child) => effectiveValues(spanValues(child)));
73
+ const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? ["fp-bleed-managed"] : [] as string[]);
74
+ for (const breakpoint of gridBreakpoints) {
75
+ let position = 0;
76
+ children.forEach((child, index) => {
77
+ const width = Math.min(spans[index]![breakpoint], columns[breakpoint]);
78
+ if (position + width > columns[breakpoint]) position = 0;
79
+ const start = position === 0;
80
+ const end = position + width === columns[breakpoint];
81
+ const bleed = child.style?.layout?.flowpressGridBleed;
82
+ const from = gridBreakpoints.indexOf(bleed?.from || "base");
83
+ if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&
84
+ ((bleed.side === "start" && start) || (bleed.side === "end" && end))) {
85
+ result[index]!.push(`fp-bleed-${breakpoint}-${bleed.side}`);
86
+ }
87
+ position += width;
88
+ if (position === columns[breakpoint]) position = 0;
89
+ });
90
+ }
91
+ return result;
92
+ };
93
+
94
+ const appendClasses = (attributes: GridAttributes, classes: string[]): GridAttributes => ({
95
+ ...attributes,
96
+ className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
97
+ });
98
+
99
+ /** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
100
+ export const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {
101
+ const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
102
+ const attributes = (block.attributes || {}) as GridAttributes;
103
+ if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;
104
+ const children = innerBlocks ?? [];
105
+ const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));
106
+ return {
107
+ ...block,
108
+ attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
109
+ innerBlocks: children.map((child, index) => ({
110
+ ...child,
111
+ attributes: appendClasses(child.attributes as GridAttributes || {}, [
112
+ ...spanClasses(child.attributes as GridAttributes || {}),
113
+ ...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),
114
+ ...(bleed[index] ?? []),
115
+ ]),
116
+ })),
117
+ };
118
+ });
@@ -0,0 +1,6 @@
1
+ /** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */
2
+ export declare function nativeHtmlData(data?: Record<string, unknown> | null, legacyHtml?: string | null): {
3
+ html: string;
4
+ hidden: boolean;
5
+ };
6
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/astro/native/html.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAOnI"}
@@ -0,0 +1,10 @@
1
+ /** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */
2
+ export function nativeHtmlData(data, legacyHtml) {
3
+ return {
4
+ // Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).
5
+ // A present resolver (including empty output) always takes precedence.
6
+ html: typeof data?.html === "string" ? data.html : data == null ? legacyHtml ?? "" : "",
7
+ hidden: data?.hidden === true,
8
+ };
9
+ }
10
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/astro/native/html.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,IAAqC,EAAE,UAA0B;IAC9F,OAAO;QACL,wEAAwE;QACxE,uEAAuE;QACvE,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;QACvF,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["/** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */\nexport function nativeHtmlData(data?: Record<string, unknown> | null, legacyHtml?: string | null): { html: string; hidden: boolean } {\n return {\n // Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).\n // A present resolver (including empty output) always takes precedence.\n html: typeof data?.html === \"string\" ? data.html : data == null ? legacyHtml ?? \"\" : \"\",\n hidden: data?.hidden === true,\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */
2
+ export function nativeHtmlData(data?: Record<string, unknown> | null, legacyHtml?: string | null): { html: string; hidden: boolean } {
3
+ return {
4
+ // Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).
5
+ // A present resolver (including empty output) always takes precedence.
6
+ html: typeof data?.html === "string" ? data.html : data == null ? legacyHtml ?? "" : "",
7
+ hidden: data?.hidden === true,
8
+ };
9
+ }
@@ -0,0 +1,3 @@
1
+ export declare function nativeIconWidth(value: unknown): string | undefined;
2
+ export declare function nativeIconSvg(name: unknown, resolved: unknown, prefix: string): string | undefined;
3
+ //# sourceMappingURL=icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/astro/native/icon.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMlE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUlG"}
@@ -0,0 +1,23 @@
1
+ import { normalizeIconSvg, scopeIconSvgIds } from "@styleflow.app/flowpress-components/icon-svg";
2
+ export function nativeIconWidth(value) {
3
+ if (typeof value !== "string")
4
+ return undefined;
5
+ const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|rem|em|%|vw|vh)$/);
6
+ if (!match)
7
+ return undefined;
8
+ const limit = match[2] === "px" ? 1536 : ["%", "vw", "vh"].includes(match[2]) ? 100 : 96;
9
+ return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;
10
+ }
11
+ export function nativeIconSvg(name, resolved, prefix) {
12
+ if (typeof name !== "string")
13
+ return undefined;
14
+ let svg;
15
+ if (!svg) {
16
+ const data = resolved && typeof resolved === "object" ? resolved : {};
17
+ if (data.name === name && data.empty === false && typeof data.svg === "string" && data.svg) {
18
+ svg = normalizeIconSvg(data.svg, name);
19
+ }
20
+ }
21
+ return svg ? scopeIconSvgIds(svg, prefix) : undefined;
22
+ }
23
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/astro/native/icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEjG,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC/E,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1F,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAa,EAAE,QAAiB,EAAE,MAAc;IAC5E,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,GAAuB,CAAC;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,GAAG,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAmC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjG,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3F,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC","sourcesContent":["import { normalizeIconSvg, scopeIconSvgIds } from \"@styleflow.app/flowpress-components/icon-svg\";\n\nexport function nativeIconWidth(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?|\\.\\d+)(px|rem|em|%|vw|vh)$/);\n if (!match) return undefined;\n const limit = match[2] === \"px\" ? 1536 : [\"%\", \"vw\", \"vh\"].includes(match[2]!) ? 100 : 96;\n return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;\n}\n\nexport function nativeIconSvg(name: unknown, resolved: unknown, prefix: string): string | undefined {\n if (typeof name !== \"string\") return undefined;\n let svg: string | undefined;\n if (!svg) {\n const data = resolved && typeof resolved === \"object\" ? resolved as Record<string, unknown> : {};\n if (data.name === name && data.empty === false && typeof data.svg === \"string\" && data.svg) {\n svg = normalizeIconSvg(data.svg, name);\n }\n }\n return svg ? scopeIconSvgIds(svg, prefix) : undefined;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { normalizeIconSvg, scopeIconSvgIds } from "@styleflow.app/flowpress-components/icon-svg";
2
+
3
+ export function nativeIconWidth(value: unknown): string | undefined {
4
+ if (typeof value !== "string") return undefined;
5
+ const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|rem|em|%|vw|vh)$/);
6
+ if (!match) return undefined;
7
+ const limit = match[2] === "px" ? 1536 : ["%", "vw", "vh"].includes(match[2]!) ? 100 : 96;
8
+ return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;
9
+ }
10
+
11
+ export function nativeIconSvg(name: unknown, resolved: unknown, prefix: string): string | undefined {
12
+ if (typeof name !== "string") return undefined;
13
+ let svg: string | undefined;
14
+ if (!svg) {
15
+ const data = resolved && typeof resolved === "object" ? resolved as Record<string, unknown> : {};
16
+ if (data.name === name && data.empty === false && typeof data.svg === "string" && data.svg) {
17
+ svg = normalizeIconSvg(data.svg, name);
18
+ }
19
+ }
20
+ return svg ? scopeIconSvgIds(svg, prefix) : undefined;
21
+ }
@@ -0,0 +1,14 @@
1
+ export type MapAttributes = {
2
+ address?: unknown;
3
+ latitude?: unknown;
4
+ longitude?: unknown;
5
+ provider?: unknown;
6
+ zoom?: unknown;
7
+ };
8
+ export declare function resolveMap(attributes: MapAttributes, googleKey?: string): {
9
+ address: string;
10
+ query: string;
11
+ iframeSrc: string;
12
+ linkHref: string;
13
+ };
14
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/astro/native/map.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAeF,wBAAgB,UAAU,CAAC,UAAU,EAAE,aAAa,EAAE,SAAS,SAAK;;;;;EAgDnE"}
@@ -0,0 +1,60 @@
1
+ const coordinate = (value, limit) => {
2
+ if (typeof value !== "string" && typeof value !== "number")
3
+ return null;
4
+ const normalized = String(value).trim().replace(",", ".");
5
+ if (!normalized)
6
+ return null;
7
+ const number = Number(normalized);
8
+ return Number.isFinite(number) && Math.abs(number) <= limit ? number : null;
9
+ };
10
+ const zoomValue = (value) => {
11
+ const number = Number(value);
12
+ return Number.isFinite(number) ? Math.max(1, Math.min(20, Math.round(number))) : 14;
13
+ };
14
+ export function resolveMap(attributes, googleKey = "") {
15
+ const address = typeof attributes.address === "string" ? attributes.address.trim() : "";
16
+ const latitude = coordinate(attributes.latitude, 90);
17
+ const longitude = coordinate(attributes.longitude, 180);
18
+ const hasCoordinates = latitude !== null && longitude !== null;
19
+ const query = hasCoordinates ? `${latitude},${longitude}` : address;
20
+ const provider = attributes.provider === "google" ? "google" : "openstreetmap";
21
+ const zoom = zoomValue(attributes.zoom);
22
+ if (!query)
23
+ return { address, query, iframeSrc: "", linkHref: "" };
24
+ if (provider === "google") {
25
+ const link = new URL("https://www.google.com/maps/search/");
26
+ link.search = new URLSearchParams({ api: "1", query }).toString();
27
+ const embed = new URL("https://www.google.com/maps/embed/v1/place");
28
+ embed.search = new URLSearchParams({ key: googleKey, q: query, zoom: String(zoom) }).toString();
29
+ return {
30
+ address,
31
+ query,
32
+ iframeSrc: googleKey.trim() ? embed.toString() : "",
33
+ linkHref: link.toString(),
34
+ };
35
+ }
36
+ if (!hasCoordinates) {
37
+ return {
38
+ address,
39
+ query,
40
+ iframeSrc: "",
41
+ linkHref: `https://www.openstreetmap.org/search?query=${encodeURIComponent(query)}`,
42
+ };
43
+ }
44
+ const halfDelta = Math.max(0.001, 180 / 2 ** zoom);
45
+ const bbox = [
46
+ Math.max(-180, longitude - halfDelta),
47
+ Math.max(-90, latitude - halfDelta),
48
+ Math.min(180, longitude + halfDelta),
49
+ Math.min(90, latitude + halfDelta),
50
+ ].join(",");
51
+ const embed = new URL("https://www.openstreetmap.org/export/embed.html");
52
+ embed.search = new URLSearchParams({ bbox, layer: "mapnik", marker: query }).toString();
53
+ return {
54
+ address,
55
+ query,
56
+ iframeSrc: embed.toString(),
57
+ linkHref: `https://www.openstreetmap.org/?mlat=${latitude}&mlon=${longitude}#map=${zoom}/${latitude}/${longitude}`,
58
+ };
59
+ }
60
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/astro/native/map.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,KAAa,EAAiB,EAAE;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,UAAyB,EAAE,SAAS,GAAG,EAAE;IAClE,MAAM,OAAO,GAAG,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAA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\n zoom?: unknown;\n};\n\nconst coordinate = (value: unknown, limit: number): number | null => {\n if (typeof value !== \"string\" && typeof value !== \"number\") return null;\n const normalized = String(value).trim().replace(\",\", \".\");\n if (!normalized) return null;\n const number = Number(normalized);\n return Number.isFinite(number) && Math.abs(number) <= limit ? number : null;\n};\n\nconst zoomValue = (value: unknown): number => {\n const number = Number(value);\n return Number.isFinite(number) ? Math.max(1, Math.min(20, Math.round(number))) : 14;\n};\n\nexport function resolveMap(attributes: MapAttributes, googleKey = \"\") {\n const address = typeof attributes.address === \"string\" ? attributes.address.trim() : \"\";\n const latitude = coordinate(attributes.latitude, 90);\n const longitude = coordinate(attributes.longitude, 180);\n const hasCoordinates = latitude !== null && longitude !== null;\n const query = hasCoordinates ? `${latitude},${longitude}` : address;\n const provider = attributes.provider === \"google\" ? \"google\" : \"openstreetmap\";\n const zoom = zoomValue(attributes.zoom);\n\n if (!query) return { address, query, iframeSrc: \"\", linkHref: \"\" };\n\n if (provider === \"google\") {\n const link = new URL(\"https://www.google.com/maps/search/\");\n link.search = new URLSearchParams({ api: \"1\", query }).toString();\n const embed = new URL(\"https://www.google.com/maps/embed/v1/place\");\n embed.search = new URLSearchParams({ key: googleKey, q: query, zoom: String(zoom) }).toString();\n return {\n address,\n query,\n iframeSrc: googleKey.trim() ? embed.toString() : \"\",\n linkHref: link.toString(),\n };\n }\n\n if (!hasCoordinates) {\n return {\n address,\n query,\n iframeSrc: \"\",\n linkHref: `https://www.openstreetmap.org/search?query=${encodeURIComponent(query)}`,\n };\n }\n\n const halfDelta = Math.max(0.001, 180 / 2 ** zoom);\n const bbox = [\n Math.max(-180, longitude - halfDelta),\n Math.max(-90, latitude - halfDelta),\n Math.min(180, longitude + halfDelta),\n Math.min(90, latitude + halfDelta),\n ].join(\",\");\n const embed = new URL(\"https://www.openstreetmap.org/export/embed.html\");\n embed.search = new URLSearchParams({ bbox, layer: \"mapnik\", marker: query }).toString();\n return {\n address,\n query,\n iframeSrc: embed.toString(),\n linkHref: `https://www.openstreetmap.org/?mlat=${latitude}&mlon=${longitude}#map=${zoom}/${latitude}/${longitude}`,\n };\n}\n"]}
@@ -0,0 +1,70 @@
1
+ export type MapAttributes = {
2
+ address?: unknown;
3
+ latitude?: unknown;
4
+ longitude?: unknown;
5
+ provider?: unknown;
6
+ zoom?: unknown;
7
+ };
8
+
9
+ const coordinate = (value: unknown, limit: number): number | null => {
10
+ if (typeof value !== "string" && typeof value !== "number") return null;
11
+ const normalized = String(value).trim().replace(",", ".");
12
+ if (!normalized) return null;
13
+ const number = Number(normalized);
14
+ return Number.isFinite(number) && Math.abs(number) <= limit ? number : null;
15
+ };
16
+
17
+ const zoomValue = (value: unknown): number => {
18
+ const number = Number(value);
19
+ return Number.isFinite(number) ? Math.max(1, Math.min(20, Math.round(number))) : 14;
20
+ };
21
+
22
+ export function resolveMap(attributes: MapAttributes, googleKey = "") {
23
+ const address = typeof attributes.address === "string" ? attributes.address.trim() : "";
24
+ const latitude = coordinate(attributes.latitude, 90);
25
+ const longitude = coordinate(attributes.longitude, 180);
26
+ const hasCoordinates = latitude !== null && longitude !== null;
27
+ const query = hasCoordinates ? `${latitude},${longitude}` : address;
28
+ const provider = attributes.provider === "google" ? "google" : "openstreetmap";
29
+ const zoom = zoomValue(attributes.zoom);
30
+
31
+ if (!query) return { address, query, iframeSrc: "", linkHref: "" };
32
+
33
+ if (provider === "google") {
34
+ const link = new URL("https://www.google.com/maps/search/");
35
+ link.search = new URLSearchParams({ api: "1", query }).toString();
36
+ const embed = new URL("https://www.google.com/maps/embed/v1/place");
37
+ embed.search = new URLSearchParams({ key: googleKey, q: query, zoom: String(zoom) }).toString();
38
+ return {
39
+ address,
40
+ query,
41
+ iframeSrc: googleKey.trim() ? embed.toString() : "",
42
+ linkHref: link.toString(),
43
+ };
44
+ }
45
+
46
+ if (!hasCoordinates) {
47
+ return {
48
+ address,
49
+ query,
50
+ iframeSrc: "",
51
+ linkHref: `https://www.openstreetmap.org/search?query=${encodeURIComponent(query)}`,
52
+ };
53
+ }
54
+
55
+ const halfDelta = Math.max(0.001, 180 / 2 ** zoom);
56
+ const bbox = [
57
+ Math.max(-180, longitude - halfDelta),
58
+ Math.max(-90, latitude - halfDelta),
59
+ Math.min(180, longitude + halfDelta),
60
+ Math.min(90, latitude + halfDelta),
61
+ ].join(",");
62
+ const embed = new URL("https://www.openstreetmap.org/export/embed.html");
63
+ embed.search = new URLSearchParams({ bbox, layer: "mapnik", marker: query }).toString();
64
+ return {
65
+ address,
66
+ query,
67
+ iframeSrc: embed.toString(),
68
+ linkHref: `https://www.openstreetmap.org/?mlat=${latitude}&mlon=${longitude}#map=${zoom}/${latitude}/${longitude}`,
69
+ };
70
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Single source of truth for "may this page animate?".
3
+ *
4
+ * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
5
+ * choice from the accessibility panel wins in both directions and is stored in
6
+ * localStorage. The resolved value is mirrored on
7
+ * `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
8
+ * same state, and every change is announced with `sf:motion-change`.
9
+ *
10
+ * Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
11
+ * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
12
+ * by the visitor.
13
+ */
14
+ export declare const MOTION_STORAGE_KEY = "sf:motion";
15
+ export declare const MOTION_ATTRIBUTE = "data-sf-motion-preference";
16
+ export declare const MOTION_CHANGE_EVENT = "sf:motion-change";
17
+ export declare const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
18
+ export declare const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
19
+ /** `full` animates, `reduce` keeps everything still. */
20
+ export type MotionPreference = "full" | "reduce";
21
+ export declare function isMotionPreference(value: unknown): value is MotionPreference;
22
+ /** An explicit choice beats the OS; without one the OS decides. */
23
+ export declare function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference;
24
+ /**
25
+ * Inline script for `<head>`: mirrors the resolved preference on `<html>`
26
+ * before first paint, so nothing starts animating and then snaps to a stop.
27
+ */
28
+ export declare function motionPreferenceBootstrapScript(): string;
29
+ /** The browser surface this module needs, injectable for tests. */
30
+ export interface MotionEnvironment {
31
+ document: Pick<Document, "documentElement" | "dispatchEvent" | "addEventListener" | "removeEventListener">;
32
+ storage: Pick<Storage, "getItem" | "setItem"> | null;
33
+ media: Pick<MediaQueryList, "matches" | "addEventListener" | "removeEventListener"> | null;
34
+ }
35
+ export declare function browserMotionEnvironment(): MotionEnvironment;
36
+ /** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
37
+ export declare function getMotionPreference(env?: MotionEnvironment): MotionPreference;
38
+ /** Store an explicit choice and announce it. */
39
+ export declare function setMotionPreference(preference: MotionPreference, env?: MotionEnvironment): void;
40
+ /**
41
+ * Call `listener` whenever the effective preference changes: an explicit
42
+ * choice, or the OS setting while the visitor has not made one.
43
+ */
44
+ export declare function subscribeMotionPreference(listener: (preference: MotionPreference) => void, env?: MotionEnvironment): () => void;
45
+ /**
46
+ * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
47
+ * the preference, `aria-checked` mirrors it (checked means animations on).
48
+ */
49
+ export declare function initializeMotionToggles(scope?: ParentNode, env?: MotionEnvironment): () => void;
50
+ //# sourceMappingURL=motion-preference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-preference.d.ts","sourceRoot":"","sources":["../../../src/astro/native/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,gBAAgB,CAGjG;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAKxD;AAED,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,eAAe,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;IAC3G,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;IACrD,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC;CAC5F;AAED,wBAAgB,wBAAwB,IAAI,iBAAiB,CAY5D;AAeD,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,iBAA8C,GAAG,gBAAgB,CAEzG;AAQD,gDAAgD;AAChD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,gBAAgB,EAC5B,GAAG,GAAE,iBAA8C,GAClD,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,EAChD,GAAG,GAAE,iBAA8C,GAClD,MAAM,IAAI,CAeZ;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,UAAqB,EAC5B,GAAG,GAAE,iBAA8C,GAClD,MAAM,IAAI,CAsBZ"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Single source of truth for "may this page animate?".
3
+ *
4
+ * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
5
+ * choice from the accessibility panel wins in both directions and is stored in
6
+ * localStorage. The resolved value is mirrored on
7
+ * `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
8
+ * same state, and every change is announced with `sf:motion-change`.
9
+ *
10
+ * Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
11
+ * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
12
+ * by the visitor.
13
+ */
14
+ export const MOTION_STORAGE_KEY = "sf:motion";
15
+ export const MOTION_ATTRIBUTE = "data-sf-motion-preference";
16
+ export const MOTION_CHANGE_EVENT = "sf:motion-change";
17
+ export const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
18
+ export const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
19
+ export function isMotionPreference(value) {
20
+ return value === "full" || value === "reduce";
21
+ }
22
+ /** An explicit choice beats the OS; without one the OS decides. */
23
+ export function resolveMotionPreference(stored, systemReduces) {
24
+ if (isMotionPreference(stored))
25
+ return stored;
26
+ return systemReduces ? "reduce" : "full";
27
+ }
28
+ /**
29
+ * Inline script for `<head>`: mirrors the resolved preference on `<html>`
30
+ * before first paint, so nothing starts animating and then snaps to a stop.
31
+ */
32
+ export function motionPreferenceBootstrapScript() {
33
+ const key = JSON.stringify(MOTION_STORAGE_KEY);
34
+ const query = JSON.stringify(REDUCED_MOTION_QUERY);
35
+ const attribute = JSON.stringify(MOTION_ATTRIBUTE);
36
+ return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s==="full"||s==="reduce"?s:r?"reduce":"full")})()`;
37
+ }
38
+ export function browserMotionEnvironment() {
39
+ let storage = null;
40
+ try {
41
+ storage = localStorage;
42
+ }
43
+ catch {
44
+ // Blocked storage keeps the preference in memory for the page only.
45
+ }
46
+ return {
47
+ document,
48
+ storage,
49
+ media: typeof matchMedia === "function" ? matchMedia(REDUCED_MOTION_QUERY) : null,
50
+ };
51
+ }
52
+ function readStored(env) {
53
+ try {
54
+ return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ function mirrored(env) {
61
+ const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);
62
+ return isMotionPreference(value) ? value : null;
63
+ }
64
+ /** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
65
+ export function getMotionPreference(env = browserMotionEnvironment()) {
66
+ return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);
67
+ }
68
+ function apply(preference, env) {
69
+ if (mirrored(env) === preference)
70
+ return;
71
+ env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);
72
+ env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));
73
+ }
74
+ /** Store an explicit choice and announce it. */
75
+ export function setMotionPreference(preference, env = browserMotionEnvironment()) {
76
+ try {
77
+ env.storage?.setItem(MOTION_STORAGE_KEY, preference);
78
+ }
79
+ catch {
80
+ // The choice still applies to this page.
81
+ }
82
+ apply(preference, env);
83
+ }
84
+ /**
85
+ * Call `listener` whenever the effective preference changes: an explicit
86
+ * choice, or the OS setting while the visitor has not made one.
87
+ */
88
+ export function subscribeMotionPreference(listener, env = browserMotionEnvironment()) {
89
+ const onChange = (event) => {
90
+ const preference = event.detail?.preference;
91
+ if (isMotionPreference(preference))
92
+ listener(preference);
93
+ };
94
+ // Every subscriber may see the OS change; `apply` announces it only once.
95
+ const onSystemChange = () => {
96
+ if (readStored(env) === null)
97
+ apply(resolveMotionPreference(null, env.media?.matches ?? false), env);
98
+ };
99
+ env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);
100
+ env.media?.addEventListener("change", onSystemChange);
101
+ return () => {
102
+ env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);
103
+ env.media?.removeEventListener("change", onSystemChange);
104
+ };
105
+ }
106
+ const TOGGLE_BOUND = "sfMotionToggleBound";
107
+ /**
108
+ * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
109
+ * the preference, `aria-checked` mirrors it (checked means animations on).
110
+ */
111
+ export function initializeMotionToggles(scope = document, env = browserMotionEnvironment()) {
112
+ const toggles = [...scope.querySelectorAll(MOTION_TOGGLE_SELECTOR)]
113
+ .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== "true");
114
+ const sync = (preference) => {
115
+ toggles.forEach((toggle) => toggle.setAttribute("aria-checked", String(preference === "full")));
116
+ };
117
+ const flip = () => setMotionPreference(getMotionPreference(env) === "full" ? "reduce" : "full", env);
118
+ toggles.forEach((toggle) => {
119
+ toggle.dataset[TOGGLE_BOUND] = "true";
120
+ toggle.addEventListener("click", flip);
121
+ });
122
+ sync(getMotionPreference(env));
123
+ const unsubscribe = subscribeMotionPreference(sync, env);
124
+ return () => {
125
+ unsubscribe();
126
+ toggles.forEach((toggle) => {
127
+ toggle.removeEventListener("click", flip);
128
+ delete toggle.dataset[TOGGLE_BOUND];
129
+ });
130
+ };
131
+ }
132
+ //# sourceMappingURL=motion-preference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-preference.js","sourceRoot":"","sources":["../../../src/astro/native/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAKvE,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,CAAC;AAChD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,MAAe,EAAE,aAAsB;IAC7E,IAAI,kBAAkB,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;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,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QACtC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,MAAM,WAAW,GAAG,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEzD,OAAO,GAAG,EAAE;QACV,WAAW,EAAE,CAAC;QACd,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Single source of truth for \"may this page animate?\".\n *\n * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit\n * choice from the accessibility panel wins in both directions and is stored in\n * localStorage. The resolved value is mirrored on\n * `<html data-sf-motion-preference=\"full|reduce\">`, so CSS and scripts read the\n * same state, and every change is announced with `sf:motion-change`.\n *\n * Do not read `matchMedia(\"(prefers-reduced-motion)\")` or write a bare\n * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden\n * by the visitor.\n */\n\nexport const MOTION_STORAGE_KEY = \"sf:motion\";\nexport const MOTION_ATTRIBUTE = \"data-sf-motion-preference\";\nexport const MOTION_CHANGE_EVENT = \"sf:motion-change\";\nexport const MOTION_TOGGLE_SELECTOR = \"[data-sf-motion-toggle]\";\nexport const REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\n/** `full` animates, `reduce` keeps everything still. */\nexport type MotionPreference = \"full\" | \"reduce\";\n\nexport function isMotionPreference(value: unknown): value is MotionPreference {\n return value === \"full\" || value === \"reduce\";\n}\n\n/** An explicit choice beats the OS; without one the OS decides. */\nexport function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference {\n if (isMotionPreference(stored)) return stored;\n return systemReduces ? \"reduce\" : \"full\";\n}\n\n/**\n * Inline script for `<head>`: mirrors the resolved preference on `<html>`\n * before first paint, so nothing starts animating and then snaps to a stop.\n */\nexport function motionPreferenceBootstrapScript(): string {\n const key = JSON.stringify(MOTION_STORAGE_KEY);\n const query = JSON.stringify(REDUCED_MOTION_QUERY);\n const attribute = JSON.stringify(MOTION_ATTRIBUTE);\n return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s===\"full\"||s===\"reduce\"?s:r?\"reduce\":\"full\")})()`;\n}\n\n/** The browser surface this module needs, injectable for tests. */\nexport interface MotionEnvironment {\n document: Pick<Document, \"documentElement\" | \"dispatchEvent\" | \"addEventListener\" | \"removeEventListener\">;\n storage: Pick<Storage, \"getItem\" | \"setItem\"> | null;\n media: Pick<MediaQueryList, \"matches\" | \"addEventListener\" | \"removeEventListener\"> | null;\n}\n\nexport function browserMotionEnvironment(): MotionEnvironment {\n let storage: MotionEnvironment[\"storage\"] = null;\n try {\n storage = localStorage;\n } catch {\n // Blocked storage keeps the preference in memory for the page only.\n }\n return {\n document,\n storage,\n media: typeof matchMedia === \"function\" ? matchMedia(REDUCED_MOTION_QUERY) : null,\n };\n}\n\nfunction readStored(env: MotionEnvironment): string | null {\n try {\n return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction mirrored(env: MotionEnvironment): MotionPreference | null {\n const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);\n return isMotionPreference(value) ? value : null;\n}\n\n/** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */\nexport function getMotionPreference(env: MotionEnvironment = browserMotionEnvironment()): MotionPreference {\n return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);\n}\n\nfunction apply(preference: MotionPreference, env: MotionEnvironment): void {\n if (mirrored(env) === preference) return;\n env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);\n env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));\n}\n\n/** Store an explicit choice and announce it. */\nexport function setMotionPreference(\n preference: MotionPreference,\n env: MotionEnvironment = browserMotionEnvironment(),\n): void {\n try {\n env.storage?.setItem(MOTION_STORAGE_KEY, preference);\n } catch {\n // The choice still applies to this page.\n }\n apply(preference, env);\n}\n\n/**\n * Call `listener` whenever the effective preference changes: an explicit\n * choice, or the OS setting while the visitor has not made one.\n */\nexport function subscribeMotionPreference(\n listener: (preference: MotionPreference) => void,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const onChange = (event: Event) => {\n const preference = (event as CustomEvent<{ preference?: unknown }>).detail?.preference;\n if (isMotionPreference(preference)) listener(preference);\n };\n // Every subscriber may see the OS change; `apply` announces it only once.\n const onSystemChange = () => {\n if (readStored(env) === null) apply(resolveMotionPreference(null, env.media?.matches ?? false), env);\n };\n env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.addEventListener(\"change\", onSystemChange);\n return () => {\n env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.removeEventListener(\"change\", onSystemChange);\n };\n}\n\nconst TOGGLE_BOUND = \"sfMotionToggleBound\";\n\n/**\n * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips\n * the preference, `aria-checked` mirrors it (checked means animations on).\n */\nexport function initializeMotionToggles(\n scope: ParentNode = document,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const toggles = [...scope.querySelectorAll<HTMLElement>(MOTION_TOGGLE_SELECTOR)]\n .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== \"true\");\n const sync = (preference: MotionPreference) => {\n toggles.forEach((toggle) => toggle.setAttribute(\"aria-checked\", String(preference === \"full\")));\n };\n const flip = () => setMotionPreference(getMotionPreference(env) === \"full\" ? \"reduce\" : \"full\", env);\n\n toggles.forEach((toggle) => {\n toggle.dataset[TOGGLE_BOUND] = \"true\";\n toggle.addEventListener(\"click\", flip);\n });\n sync(getMotionPreference(env));\n const unsubscribe = subscribeMotionPreference(sync, env);\n\n return () => {\n unsubscribe();\n toggles.forEach((toggle) => {\n toggle.removeEventListener(\"click\", flip);\n delete toggle.dataset[TOGGLE_BOUND];\n });\n };\n}\n"]}