@styleflow.app/flowpress-astro-core 1.0.0-beta.4 → 1.0.0-beta.40

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 (316) hide show
  1. package/CHANGELOG.md +242 -1
  2. package/README.md +104 -5
  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 +37 -0
  10. package/dist/astro/FontStylesheets.astro +35 -0
  11. package/dist/astro/GutenbergRenderer.astro +267 -80
  12. package/dist/astro/Media.astro +24 -0
  13. package/dist/astro/StyleflowElement.astro +24 -0
  14. package/dist/astro/ThemeRuntime.astro +26 -0
  15. package/dist/astro/blocks/CarouselBlock.astro +11 -10
  16. package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
  17. package/dist/astro/blocks/ColumnBlock.astro +4 -5
  18. package/dist/astro/blocks/CoverBlock.astro +169 -0
  19. package/dist/astro/blocks/FormBlock.astro +23 -20
  20. package/dist/astro/blocks/GridBlock.astro +6 -4
  21. package/dist/astro/blocks/HeroBlock.astro +6 -6
  22. package/dist/astro/blocks/ImageBlock.astro +6 -6
  23. package/dist/astro/blocks/ListItemFallback.astro +9 -7
  24. package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
  25. package/dist/astro/blocks/SemanticElement.astro +35 -0
  26. package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
  27. package/dist/astro/blocks/TextBlock.astro +33 -28
  28. package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
  29. package/dist/astro/blocks/cover.d.ts +13 -0
  30. package/dist/astro/blocks/cover.d.ts.map +1 -0
  31. package/dist/astro/blocks/cover.js +105 -0
  32. package/dist/astro/blocks/cover.js.map +1 -0
  33. package/dist/astro/blocks/cover.ts +119 -0
  34. package/dist/astro/blocks/helpers.d.ts +10 -1
  35. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  36. package/dist/astro/blocks/helpers.js +55 -39
  37. package/dist/astro/blocks/helpers.js.map +1 -1
  38. package/dist/astro/blocks/helpers.ts +69 -44
  39. package/dist/astro/motion/AccordionRuntime.astro +9 -0
  40. package/dist/astro/motion/MotionBoot.astro +21 -0
  41. package/dist/astro/motion/MotionRuntime.astro +31 -0
  42. package/dist/astro/motion/accordion.css +163 -0
  43. package/dist/astro/motion/accordion.d.ts +3 -0
  44. package/dist/astro/motion/accordion.d.ts.map +1 -0
  45. package/dist/astro/motion/accordion.js +98 -0
  46. package/dist/astro/motion/accordion.js.map +1 -0
  47. package/dist/astro/motion/accordion.ts +109 -0
  48. package/dist/astro/motion/motion-controller.d.ts +12 -0
  49. package/dist/astro/motion/motion-controller.d.ts.map +1 -0
  50. package/dist/astro/motion/motion-controller.js +293 -0
  51. package/dist/astro/motion/motion-controller.js.map +1 -0
  52. package/dist/astro/motion/motion-controller.ts +377 -0
  53. package/dist/astro/motion/motion.css +546 -0
  54. package/dist/astro/motion/motion.d.ts +127 -0
  55. package/dist/astro/motion/motion.d.ts.map +1 -0
  56. package/dist/astro/motion/motion.js +255 -0
  57. package/dist/astro/motion/motion.js.map +1 -0
  58. package/dist/astro/motion/motion.ts +419 -0
  59. package/dist/astro/native/Blob.astro +113 -0
  60. package/dist/astro/native/BlobBlock.astro +52 -0
  61. package/dist/astro/native/CustomFieldValue.astro +88 -0
  62. package/dist/astro/native/LevelTag.astro +20 -0
  63. package/dist/astro/native/MapBlock.astro +41 -0
  64. package/dist/astro/native/NativeHtmlBlock.astro +12 -0
  65. package/dist/astro/native/NativeIconBlock.astro +42 -0
  66. package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
  67. package/dist/astro/native/ReservedLogin.astro +107 -0
  68. package/dist/astro/native/ResolvedBlocks.astro +91 -0
  69. package/dist/astro/native/SyncedPatternContent.astro +94 -0
  70. package/dist/astro/native/TermFieldValue.astro +39 -0
  71. package/dist/astro/native/Timeline.astro +22 -0
  72. package/dist/astro/native/TimelineCardBlock.astro +7 -0
  73. package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
  74. package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
  75. package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
  76. package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
  77. package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
  78. package/dist/astro/native/blob/config.d.ts +49 -0
  79. package/dist/astro/native/blob/config.d.ts.map +1 -0
  80. package/dist/astro/native/blob/config.js +86 -0
  81. package/dist/astro/native/blob/config.js.map +1 -0
  82. package/dist/astro/native/blob/config.ts +132 -0
  83. package/dist/astro/native/blob/controller.d.ts +11 -0
  84. package/dist/astro/native/blob/controller.d.ts.map +1 -0
  85. package/dist/astro/native/blob/controller.js +240 -0
  86. package/dist/astro/native/blob/controller.js.map +1 -0
  87. package/dist/astro/native/blob/controller.ts +248 -0
  88. package/dist/astro/native/blob/geometry.d.ts +2 -0
  89. package/dist/astro/native/blob/geometry.d.ts.map +1 -0
  90. package/dist/astro/native/blob/geometry.js +2 -0
  91. package/dist/astro/native/blob/geometry.js.map +1 -0
  92. package/dist/astro/native/blob/geometry.ts +1 -0
  93. package/dist/astro/native/blob/ids.d.ts +7 -0
  94. package/dist/astro/native/blob/ids.d.ts.map +1 -0
  95. package/dist/astro/native/blob/ids.js +11 -0
  96. package/dist/astro/native/blob/ids.js.map +1 -0
  97. package/dist/astro/native/blob/ids.ts +11 -0
  98. package/dist/astro/native/blob.css +83 -0
  99. package/dist/astro/native/button-template.d.ts +31 -0
  100. package/dist/astro/native/button-template.d.ts.map +1 -0
  101. package/dist/astro/native/button-template.js +54 -0
  102. package/dist/astro/native/button-template.js.map +1 -0
  103. package/dist/astro/native/button-template.ts +92 -0
  104. package/dist/astro/native/button.d.ts +13 -0
  105. package/dist/astro/native/button.d.ts.map +1 -0
  106. package/dist/astro/native/button.js +26 -0
  107. package/dist/astro/native/button.js.map +1 -0
  108. package/dist/astro/native/button.ts +26 -0
  109. package/dist/astro/native/core-block.astro +18 -0
  110. package/dist/astro/native/core-button-fallback.astro +43 -0
  111. package/dist/astro/native/core-button.astro +65 -0
  112. package/dist/astro/native/core-buttons.astro +14 -0
  113. package/dist/astro/native/core-group.astro +25 -0
  114. package/dist/astro/native/core-home-link.astro +12 -0
  115. package/dist/astro/native/core-html.astro +8 -0
  116. package/dist/astro/native/core-icon.astro +7 -0
  117. package/dist/astro/native/core-image.astro +139 -0
  118. package/dist/astro/native/core-navigation-link.astro +71 -0
  119. package/dist/astro/native/core-navigation-submenu.astro +33 -0
  120. package/dist/astro/native/core-navigation.astro +101 -0
  121. package/dist/astro/native/core-page-list-data-item.astro +19 -0
  122. package/dist/astro/native/core-page-list-item.astro +8 -0
  123. package/dist/astro/native/core-page-list.astro +40 -0
  124. package/dist/astro/native/core-post-date.astro +21 -0
  125. package/dist/astro/native/core-post-excerpt.astro +26 -0
  126. package/dist/astro/native/core-post-featured-image.astro +38 -0
  127. package/dist/astro/native/core-post-template-fallback.astro +30 -0
  128. package/dist/astro/native/core-post-template.astro +23 -0
  129. package/dist/astro/native/core-post-terms.astro +47 -0
  130. package/dist/astro/native/core-post-title.astro +23 -0
  131. package/dist/astro/native/core-query-no-results.astro +12 -0
  132. package/dist/astro/native/core-query.astro +22 -0
  133. package/dist/astro/native/core-separator.astro +20 -0
  134. package/dist/astro/native/core-site-title.astro +16 -0
  135. package/dist/astro/native/core-term-description.astro +12 -0
  136. package/dist/astro/native/core-term-name.astro +21 -0
  137. package/dist/astro/native/core-term-template.astro +30 -0
  138. package/dist/astro/native/core-terms-query.astro +19 -0
  139. package/dist/astro/native/core-transparent.astro +11 -0
  140. package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
  141. package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
  142. package/dist/astro/native/flowpress-navigation-controller.js +217 -0
  143. package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
  144. package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
  145. package/dist/astro/native/flowpress-navigation.css +17 -0
  146. package/dist/astro/native/grid-bleed.d.ts +2 -0
  147. package/dist/astro/native/grid-bleed.d.ts.map +1 -0
  148. package/dist/astro/native/grid-bleed.js +123 -0
  149. package/dist/astro/native/grid-bleed.js.map +1 -0
  150. package/dist/astro/native/grid.css +180 -0
  151. package/dist/astro/native/grid.d.ts +17 -0
  152. package/dist/astro/native/grid.d.ts.map +1 -0
  153. package/dist/astro/native/grid.js +103 -0
  154. package/dist/astro/native/grid.js.map +1 -0
  155. package/dist/astro/native/grid.ts +118 -0
  156. package/dist/astro/native/group.css +36 -0
  157. package/dist/astro/native/group.d.ts +15 -0
  158. package/dist/astro/native/group.d.ts.map +1 -0
  159. package/dist/astro/native/group.js +66 -0
  160. package/dist/astro/native/group.js.map +1 -0
  161. package/dist/astro/native/group.ts +61 -0
  162. package/dist/astro/native/html.d.ts +6 -0
  163. package/dist/astro/native/html.d.ts.map +1 -0
  164. package/dist/astro/native/html.js +10 -0
  165. package/dist/astro/native/html.js.map +1 -0
  166. package/dist/astro/native/html.ts +9 -0
  167. package/dist/astro/native/icon.d.ts +3 -0
  168. package/dist/astro/native/icon.d.ts.map +1 -0
  169. package/dist/astro/native/icon.js +23 -0
  170. package/dist/astro/native/icon.js.map +1 -0
  171. package/dist/astro/native/icon.ts +21 -0
  172. package/dist/astro/native/image.d.ts +5 -0
  173. package/dist/astro/native/image.d.ts.map +1 -0
  174. package/dist/astro/native/image.js +65 -0
  175. package/dist/astro/native/image.js.map +1 -0
  176. package/dist/astro/native/image.ts +56 -0
  177. package/dist/astro/native/inline-text.css +15 -0
  178. package/dist/astro/native/map.d.ts +14 -0
  179. package/dist/astro/native/map.d.ts.map +1 -0
  180. package/dist/astro/native/map.js +60 -0
  181. package/dist/astro/native/map.js.map +1 -0
  182. package/dist/astro/native/map.ts +70 -0
  183. package/dist/astro/native/motion-preference.d.ts +50 -0
  184. package/dist/astro/native/motion-preference.d.ts.map +1 -0
  185. package/dist/astro/native/motion-preference.js +132 -0
  186. package/dist/astro/native/motion-preference.js.map +1 -0
  187. package/dist/astro/native/motion-preference.ts +158 -0
  188. package/dist/astro/native/motion.d.ts +101 -0
  189. package/dist/astro/native/motion.d.ts.map +1 -0
  190. package/dist/astro/native/motion.js +168 -0
  191. package/dist/astro/native/motion.js.map +1 -0
  192. package/dist/astro/native/motion.ts +312 -0
  193. package/dist/astro/native/query-carousel.d.ts +12 -0
  194. package/dist/astro/native/query-carousel.d.ts.map +1 -0
  195. package/dist/astro/native/query-carousel.js +36 -0
  196. package/dist/astro/native/query-carousel.js.map +1 -0
  197. package/dist/astro/native/query-carousel.ts +56 -0
  198. package/dist/astro/native/query-loop.d.ts +38 -0
  199. package/dist/astro/native/query-loop.d.ts.map +1 -0
  200. package/dist/astro/native/query-loop.js +20 -0
  201. package/dist/astro/native/query-loop.js.map +1 -0
  202. package/dist/astro/native/query-loop.ts +67 -0
  203. package/dist/astro/native/registry.d.ts +3 -0
  204. package/dist/astro/native/registry.d.ts.map +1 -0
  205. package/dist/astro/native/registry.js +81 -0
  206. package/dist/astro/native/registry.js.map +1 -0
  207. package/dist/astro/native/registry.ts +82 -0
  208. package/dist/astro/native/sf-block-binding.astro +20 -0
  209. package/dist/astro/native/sf-post-field.astro +9 -0
  210. package/dist/astro/native/sf-term-field.astro +9 -0
  211. package/dist/astro/native/timeline.css +4 -0
  212. package/dist/astro/native/timeline.d.ts +28 -0
  213. package/dist/astro/native/timeline.d.ts.map +1 -0
  214. package/dist/astro/native/timeline.js +43 -0
  215. package/dist/astro/native/timeline.js.map +1 -0
  216. package/dist/astro/native/timeline.ts +79 -0
  217. package/dist/astro/preferences/AccessibilityPanel.astro +105 -0
  218. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  219. package/dist/astro/preferences/MotionToggle.astro +27 -0
  220. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  221. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  222. package/dist/astro/preferences/Toggle.astro +50 -0
  223. package/dist/astro/preferences/preferences.css +125 -0
  224. package/dist/block-renderers.d.ts +23 -3
  225. package/dist/block-renderers.d.ts.map +1 -1
  226. package/dist/block-renderers.js.map +1 -1
  227. package/dist/build-cache.d.ts +8 -0
  228. package/dist/build-cache.d.ts.map +1 -0
  229. package/dist/build-cache.js +81 -0
  230. package/dist/build-cache.js.map +1 -0
  231. package/dist/client.d.ts +23 -2
  232. package/dist/client.d.ts.map +1 -1
  233. package/dist/client.js +78 -39
  234. package/dist/client.js.map +1 -1
  235. package/dist/composition.d.ts +14 -0
  236. package/dist/composition.d.ts.map +1 -0
  237. package/dist/composition.js +125 -0
  238. package/dist/composition.js.map +1 -0
  239. package/dist/default-blocks.d.ts +9 -0
  240. package/dist/default-blocks.d.ts.map +1 -0
  241. package/dist/default-blocks.js +117 -0
  242. package/dist/default-blocks.js.map +1 -0
  243. package/dist/env.d.ts +9 -0
  244. package/dist/env.d.ts.map +1 -1
  245. package/dist/env.js +20 -0
  246. package/dist/env.js.map +1 -1
  247. package/dist/index.d.ts +7 -0
  248. package/dist/index.d.ts.map +1 -1
  249. package/dist/index.js +6 -0
  250. package/dist/index.js.map +1 -1
  251. package/dist/media.d.ts +20 -0
  252. package/dist/media.d.ts.map +1 -0
  253. package/dist/media.js +106 -0
  254. package/dist/media.js.map +1 -0
  255. package/dist/motion-preference.d.ts +50 -0
  256. package/dist/motion-preference.d.ts.map +1 -0
  257. package/dist/motion-preference.js +132 -0
  258. package/dist/motion-preference.js.map +1 -0
  259. package/dist/preferences-runtime.d.ts +3 -0
  260. package/dist/preferences-runtime.d.ts.map +1 -0
  261. package/dist/preferences-runtime.js +23 -0
  262. package/dist/preferences-runtime.js.map +1 -0
  263. package/dist/preferences-styleflow.d.ts +3 -0
  264. package/dist/preferences-styleflow.d.ts.map +1 -0
  265. package/dist/preferences-styleflow.js +14 -0
  266. package/dist/preferences-styleflow.js.map +1 -0
  267. package/dist/preferences.d.ts +4 -0
  268. package/dist/preferences.d.ts.map +1 -0
  269. package/dist/preferences.js +4 -0
  270. package/dist/preferences.js.map +1 -0
  271. package/dist/reserved-area.d.ts +10 -0
  272. package/dist/reserved-area.d.ts.map +1 -0
  273. package/dist/reserved-area.js +93 -0
  274. package/dist/reserved-area.js.map +1 -0
  275. package/dist/styleflow.d.ts +18 -1
  276. package/dist/styleflow.d.ts.map +1 -1
  277. package/dist/styleflow.js +82 -11
  278. package/dist/styleflow.js.map +1 -1
  279. package/dist/svg-media-runtime.d.ts +3 -0
  280. package/dist/svg-media-runtime.d.ts.map +1 -0
  281. package/dist/svg-media-runtime.js +33 -0
  282. package/dist/svg-media-runtime.js.map +1 -0
  283. package/dist/svg-media-types.d.ts +11 -0
  284. package/dist/svg-media-types.d.ts.map +1 -0
  285. package/dist/svg-media-types.js +2 -0
  286. package/dist/svg-media-types.js.map +1 -0
  287. package/dist/svg-media.d.ts +13 -0
  288. package/dist/svg-media.d.ts.map +1 -0
  289. package/dist/svg-media.js +47 -0
  290. package/dist/svg-media.js.map +1 -0
  291. package/dist/template-hierarchy.d.ts +0 -7
  292. package/dist/template-hierarchy.d.ts.map +1 -1
  293. package/dist/template-hierarchy.js +0 -21
  294. package/dist/template-hierarchy.js.map +1 -1
  295. package/dist/text.d.ts +3 -0
  296. package/dist/text.d.ts.map +1 -0
  297. package/dist/text.js +6 -0
  298. package/dist/text.js.map +1 -0
  299. package/dist/theme-runtime.d.ts +16 -0
  300. package/dist/theme-runtime.d.ts.map +1 -0
  301. package/dist/theme-runtime.js +100 -0
  302. package/dist/theme-runtime.js.map +1 -0
  303. package/dist/tsconfig.tsbuildinfo +1 -1
  304. package/dist/types.d.ts +75 -1
  305. package/dist/types.d.ts.map +1 -1
  306. package/dist/types.js.map +1 -1
  307. package/dist/vivid-colors-preference.d.ts +31 -0
  308. package/dist/vivid-colors-preference.d.ts.map +1 -0
  309. package/dist/vivid-colors-preference.js +102 -0
  310. package/dist/vivid-colors-preference.js.map +1 -0
  311. package/package.json +58 -7
  312. package/dist/astro/DefaultTemplate.astro +0 -42
  313. package/dist/templates.d.ts +0 -19
  314. package/dist/templates.d.ts.map +0 -1
  315. package/dist/templates.js +0 -20
  316. package/dist/templates.js.map +0 -1
@@ -1,4 +1,5 @@
1
- import { resolveDynamicStyleflowProps } from "../../styleflow.js";
1
+ import { nativeFlexItemProps } from "../native/group.js";
2
+ import { resolveFlowpressBlockStyleflowProps } from "../../styleflow.js";
2
3
  import { flowpressLinkHref } from "../../links.js";
3
4
  export const DEFAULT_SEMANTIC_PROPS = {
4
5
  surface: "default",
@@ -31,30 +32,11 @@ export function blockHtmlAttributes(attributes, baseClass = "") {
31
32
  .filter(Boolean)
32
33
  .join(" ")
33
34
  .replace(/\s+/g, " ");
34
- return {
35
+ return nativeFlexItemProps(attributes, {
35
36
  ...(anchor ? { id: anchor } : {}),
36
37
  ...(className ? { class: className } : {})
37
- };
38
+ });
38
39
  }
39
- const SEMANTIC_KEYS = [
40
- "theme",
41
- "tone",
42
- "intensity",
43
- "surface",
44
- "layoutRole",
45
- "density",
46
- "ty",
47
- "v",
48
- "w",
49
- "foreground",
50
- "interactivePriority",
51
- "noBackground",
52
- "noBorder",
53
- "noPadding",
54
- "noGap",
55
- "noRadius",
56
- "noForeground"
57
- ];
58
40
  export const TEXT_HTML_TAGS = [
59
41
  "span",
60
42
  "p",
@@ -69,29 +51,63 @@ export const TEXT_HTML_TAGS = [
69
51
  "small",
70
52
  "mark"
71
53
  ];
54
+ function preferredTypographyVariant(type) {
55
+ if (type === "heading")
56
+ return "2";
57
+ if (type === "body" || type === "label" || type === "code")
58
+ return "md";
59
+ return undefined;
60
+ }
61
+ /**
62
+ * Derive a variant only when Gutenberg omitted it. The selected typography
63
+ * type can differ from the block's native type, so a paragraph styled as a
64
+ * heading must not inherit the paragraph-only `md` variant.
65
+ */
66
+ export function compatibleTypographyVariant(type, preferred, contract) {
67
+ const variants = contract?.semantic.axes.typography.variantsByType[type];
68
+ if (!variants?.length)
69
+ return preferred;
70
+ return [
71
+ preferredTypographyVariant(type),
72
+ preferred,
73
+ contract?.semantic.agentPolicy.defaults.typography.ty === type
74
+ ? contract.semantic.agentPolicy.defaults.typography.v
75
+ : undefined,
76
+ variants[0]
77
+ ].find((candidate) => (typeof candidate === "string" && variants.includes(candidate))) ?? preferred;
78
+ }
79
+ export function textBlockSemanticDefaults(blockName, attributes, contract) {
80
+ const name = blockName.replace(/^sf\//, "");
81
+ const heading = name === "heading" || name === "core/heading";
82
+ const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
83
+ const defaultType = heading ? "heading" : "body";
84
+ const authored = (...values) => values.find((value) => value !== undefined && value !== null && value !== "");
85
+ const activeType = String(authored(attributes.ty) ?? defaultType);
86
+ const nativeVariant = heading
87
+ ? String(level)
88
+ : name.includes("quote") ? "lg" : "md";
89
+ const authoredVariant = authored(attributes.v, attributes.variant);
90
+ return {
91
+ ty: defaultType,
92
+ v: authoredVariant === undefined
93
+ ? compatibleTypographyVariant(activeType, nativeVariant, contract)
94
+ : String(authoredVariant),
95
+ w: String(authored(attributes.w, attributes.weight) ?? (heading ? "strong" : "default")),
96
+ foreground: "primary"
97
+ };
98
+ }
72
99
  export function textHtmlTag(value) {
73
100
  const candidate = String(value ?? "span");
74
101
  return TEXT_HTML_TAGS.includes(candidate)
75
102
  ? candidate
76
103
  : "span";
77
104
  }
78
- export function semanticProps(attributes, contract, defaults = DEFAULT_SEMANTIC_PROPS) {
79
- const input = Object.fromEntries(SEMANTIC_KEYS
80
- .filter((key) => attributes[key] !== undefined)
81
- .map((key) => [key, attributes[key]]));
82
- if (contract) {
83
- return resolveDynamicStyleflowProps(input, defaults, contract, {
84
- strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
85
- onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
86
- });
87
- }
88
- const resolved = { ...defaults, ...input };
89
- for (const key of ["tone", "intensity", "foreground"]) {
90
- if (input[key] === "inherit") {
91
- delete resolved[key];
92
- }
93
- }
94
- return resolved;
105
+ export function semanticProps(attributes, contract, defaults = DEFAULT_SEMANTIC_PROPS, effectiveTone) {
106
+ return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {
107
+ effectiveTone,
108
+ strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
109
+ onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
110
+ });
95
111
  }
96
112
  const TEXT_ALIGNMENTS = new Set([
97
113
  "left",
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/astro/blocks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAE7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAS,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,4BAA4B,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAC9B,mDAAmD,CACpD,CAAC;IACF,IACE,CAAC,KAAK;WACH,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,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AAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;YACrE,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAC7B,+DAA+D,CAChE,CAAC;IACF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import {\n resolveDynamicStyleflowProps,\n type StyleflowContract\n} from \"../../styleflow.js\";\nimport type { FlowpressBlock } from \"../../types.js\";\nimport { flowpressLinkHref } from \"../../links.js\";\n\nexport const DEFAULT_SEMANTIC_PROPS = {\n surface: \"default\",\n layoutRole: \"stack\",\n density: \"regular\"\n};\n\nexport const DEFAULT_HERO_OBJECT_POSITION = \"50% 50%\";\n\nexport function heroObjectPosition(value: unknown): string {\n if (typeof value !== \"string\") {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n const match = value.trim().match(\n /^(\\d+(?:\\.\\d+)?|\\.\\d+)%\\s+(\\d+(?:\\.\\d+)?|\\.\\d+)%$/\n );\n if (\n !match\n || [match[1], match[2]].some((coordinate) => {\n const numeric = Number(coordinate);\n return !Number.isFinite(numeric) || numeric < 0 || numeric > 100;\n })\n ) {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n return `${match[1]}% ${match[2]}%`;\n}\n\nexport function blockHtmlAttributes(\n attributes: Record<string, unknown>,\n baseClass = \"\"\n): { id?: string; class?: string } {\n const anchor = typeof attributes.anchor === \"string\"\n ? attributes.anchor.trim()\n : \"\";\n const customClass = typeof attributes.className === \"string\"\n ? attributes.className.trim()\n : \"\";\n const className = [baseClass.trim(), customClass]\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \");\n\n return {\n ...(anchor ? { id: anchor } : {}),\n ...(className ? { class: className } : {})\n };\n}\n\nconst SEMANTIC_KEYS = [\n \"theme\",\n \"tone\",\n \"intensity\",\n \"surface\",\n \"layoutRole\",\n \"density\",\n \"ty\",\n \"v\",\n \"w\",\n \"foreground\",\n \"interactivePriority\",\n \"noBackground\",\n \"noBorder\",\n \"noPadding\",\n \"noGap\",\n \"noRadius\",\n \"noForeground\"\n] as const;\n\nexport const TEXT_HTML_TAGS = [\n \"span\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"strong\",\n \"em\",\n \"small\",\n \"mark\"\n] as const;\n\nexport type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];\n\nexport function textHtmlTag(value: unknown): TextHtmlTag {\n const candidate = String(value ?? \"span\");\n return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)\n ? candidate as TextHtmlTag\n : \"span\";\n}\n\nexport function semanticProps(\n attributes: Record<string, unknown>,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS\n): Record<string, unknown> {\n const input = Object.fromEntries(\n SEMANTIC_KEYS\n .filter((key) => attributes[key] !== undefined)\n .map((key) => [key, attributes[key]])\n );\n if (contract) {\n return resolveDynamicStyleflowProps(input, defaults, contract, {\n strict: process.env.NODE_ENV === \"production\" || process.env.STYLEFLOW_STRICT === \"1\",\n onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)\n });\n }\n\n const resolved = { ...defaults, ...input };\n for (const key of [\"tone\", \"intensity\", \"foreground\"]) {\n if (input[key] === \"inherit\") {\n delete resolved[key];\n }\n }\n return resolved;\n}\n\nconst TEXT_ALIGNMENTS = new Set([\n \"left\",\n \"center\",\n \"right\",\n \"justify\",\n \"start\",\n \"end\"\n]);\n\n/** Resolve only Gutenberg's supported text-alignment values to inline CSS. */\nexport function textAlignmentStyle(\n attributes: Record<string, unknown>\n): string | undefined {\n const style = attributes.style && typeof attributes.style === \"object\"\n && !Array.isArray(attributes.style)\n ? attributes.style as Record<string, unknown>\n : {};\n const typography = style.typography && typeof style.typography === \"object\"\n && !Array.isArray(style.typography)\n ? style.typography as Record<string, unknown>\n : {};\n const candidate = typography.textAlign ?? attributes.textAlign;\n const alignment = String(candidate ?? \"\");\n return TEXT_ALIGNMENTS.has(alignment) ? `text-align: ${alignment};` : undefined;\n}\n\nexport function prefixedTextSemanticProps(\n attributes: Record<string, unknown>,\n prefix: string,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = {}\n): Record<string, unknown> {\n const attributeName = (name: string) =>\n `${prefix}${name.charAt(0).toUpperCase()}${name.slice(1)}`;\n return semanticProps({\n ty: attributes[attributeName(\"ty\")],\n v: attributes[attributeName(\"v\")],\n w: attributes[attributeName(\"w\")],\n foreground: attributes[attributeName(\"foreground\")]\n }, contract, defaults);\n}\n\nexport function objectValue(\n block: FlowpressBlock,\n key: string\n): Record<string, unknown> {\n const value = block.attributes[key];\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n}\n\nexport function textValue(block: FlowpressBlock, key = \"text\"): string {\n return String(block.attributes[key] ?? \"\");\n}\n\n/**\n * Keep intentional blank lines visible across current and legacy RichText\n * serializations. Gutenberg can represent them either as repeated `<br>` tags,\n * empty paragraph elements, or literal newlines in an attribute value.\n */\nexport function preserveRichTextSpacing(html: string): string {\n const visibleEmptyBlocks = html\n .replace(/\\r\\n?/g, \"\\n\")\n .replace(\n /<(p|div)(\\s[^>]*)?>(?:\\s|&nbsp;|&#160;)*<\\/\\1>/gi,\n (_match, tag: string, attributes = \"\") =>\n `<${tag}${attributes}>&nbsp;</${tag}>`\n );\n\n return visibleEmptyBlocks\n .split(/(<[^>]+>)/g)\n .map((part) => {\n if (part.startsWith(\"<\") || part.trim() === \"\") {\n return part;\n }\n return part.replace(/\\n(?:[ \\t]*\\n)+/g, (newlines) =>\n \"<br>\".repeat((newlines.match(/\\n/g) || []).length)\n );\n })\n .join(\"\");\n}\n\n/** Keep an empty text element at its typographic line height without visible text. */\nexport function preserveEmptyTextBlock(html: string): string {\n return html.trim() === \"\" ? \"&nbsp;\" : html;\n}\n\nexport function linkValue(block: FlowpressBlock, key = \"link\"): string {\n return flowpressLinkHref(block.attributes[key]);\n}\n\nexport function responsiveValues(\n attributes: Record<string, unknown>,\n prefix: \"columns\" | \"span\",\n fallback: number\n): Record<\"base\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\", number> {\n const keys = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n const result = {} as Record<(typeof keys)[number], number>;\n let inherited = fallback;\n for (const key of keys) {\n const suffix = key === \"base\"\n ? \"Base\"\n : key === \"2xl\" ? \"2xl\" : key.charAt(0).toUpperCase() + key.slice(1);\n const candidate = Number(attributes[`${prefix}${suffix}`]);\n if (Number.isInteger(candidate) && candidate >= 1 && candidate <= 12) {\n inherited = candidate;\n }\n result[key] = inherited;\n }\n return result;\n}\n\nexport function unwrapCoreHtml(html: string): string {\n const match = html.trim().match(\n /^<(p|h[1-6]|ul|ol|li|blockquote)(?:\\s[^>]*)?>([\\s\\S]*)<\\/\\1>$/\n );\n return match?.[2] ?? html;\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/astro/blocks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,mCAAmC,EAEpC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM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AS,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAC7B,+DAA+D,CAChE,CAAC;IACF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import { nativeFlexItemProps } from \"../native/group.js\";\nimport {\n resolveFlowpressBlockStyleflowProps,\n type StyleflowContract\n} from \"../../styleflow.js\";\nimport type { FlowpressBlock } from \"../../types.js\";\nimport { flowpressLinkHref } from \"../../links.js\";\n\nexport const DEFAULT_SEMANTIC_PROPS = {\n surface: \"default\",\n layoutRole: \"stack\",\n density: \"regular\"\n};\n\nexport const DEFAULT_HERO_OBJECT_POSITION = \"50% 50%\";\n\nexport function heroObjectPosition(value: unknown): string {\n if (typeof value !== \"string\") {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n const match = value.trim().match(\n /^(\\d+(?:\\.\\d+)?|\\.\\d+)%\\s+(\\d+(?:\\.\\d+)?|\\.\\d+)%$/\n );\n if (\n !match\n || [match[1], match[2]].some((coordinate) => {\n const numeric = Number(coordinate);\n return !Number.isFinite(numeric) || numeric < 0 || numeric > 100;\n })\n ) {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n return `${match[1]}% ${match[2]}%`;\n}\n\nexport function blockHtmlAttributes(\n attributes: Record<string, unknown>,\n baseClass = \"\"\n): { id?: string; class?: string; style?: string; [key: string]: unknown } {\n const anchor = typeof attributes.anchor === \"string\"\n ? attributes.anchor.trim()\n : \"\";\n const customClass = typeof attributes.className === \"string\"\n ? attributes.className.trim()\n : \"\";\n const className = [baseClass.trim(), customClass]\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \");\n\n return nativeFlexItemProps(attributes, {\n ...(anchor ? { id: anchor } : {}),\n ...(className ? { class: className } : {})\n });\n}\n\nexport const TEXT_HTML_TAGS = [\n \"span\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"strong\",\n \"em\",\n \"small\",\n \"mark\"\n] as const;\n\nexport type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];\n\nfunction preferredTypographyVariant(type: string): string | undefined {\n if (type === \"heading\") return \"2\";\n if (type === \"body\" || type === \"label\" || type === \"code\") return \"md\";\n return undefined;\n}\n\n/**\n * Derive a variant only when Gutenberg omitted it. The selected typography\n * type can differ from the block's native type, so a paragraph styled as a\n * heading must not inherit the paragraph-only `md` variant.\n */\nexport function compatibleTypographyVariant(\n type: string,\n preferred: string,\n contract?: StyleflowContract\n): string {\n const variants = contract?.semantic.axes.typography.variantsByType[type];\n if (!variants?.length) return preferred;\n\n return [\n preferredTypographyVariant(type),\n preferred,\n contract?.semantic.agentPolicy.defaults.typography.ty === type\n ? contract.semantic.agentPolicy.defaults.typography.v\n : undefined,\n variants[0]\n ].find((candidate): candidate is string => (\n typeof candidate === \"string\" && variants.includes(candidate)\n )) ?? preferred;\n}\n\nexport function textBlockSemanticDefaults(\n blockName: string,\n attributes: Record<string, unknown>,\n contract?: StyleflowContract\n): Record<string, unknown> {\n const name = blockName.replace(/^sf\\//, \"\");\n const heading = name === \"heading\" || name === \"core/heading\";\n const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));\n const defaultType = heading ? \"heading\" : \"body\";\n const authored = (...values: unknown[]) => values.find((value) => value !== undefined && value !== null && value !== \"\");\n const activeType = String(authored(attributes.ty) ?? defaultType);\n const nativeVariant = heading\n ? String(level)\n : name.includes(\"quote\") ? \"lg\" : \"md\";\n const authoredVariant = authored(attributes.v, attributes.variant);\n\n return {\n ty: defaultType,\n v: authoredVariant === undefined\n ? compatibleTypographyVariant(activeType, nativeVariant, contract)\n : String(authoredVariant),\n w: String(authored(attributes.w, attributes.weight) ?? (heading ? \"strong\" : \"default\")),\n foreground: \"primary\"\n };\n}\n\nexport function textHtmlTag(value: unknown): TextHtmlTag {\n const candidate = String(value ?? \"span\");\n return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)\n ? candidate as TextHtmlTag\n : \"span\";\n}\n\nexport function semanticProps(\n attributes: Record<string, unknown>,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS,\n effectiveTone?: string\n): Record<string, unknown> {\n return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {\n effectiveTone,\n strict: process.env.NODE_ENV === \"production\" || process.env.STYLEFLOW_STRICT === \"1\",\n onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)\n });\n}\n\nconst TEXT_ALIGNMENTS = new Set([\n \"left\",\n \"center\",\n \"right\",\n \"justify\",\n \"start\",\n \"end\"\n]);\n\n/** Resolve only Gutenberg's supported text-alignment values to inline CSS. */\nexport function textAlignmentStyle(\n attributes: Record<string, unknown>\n): string | undefined {\n const style = attributes.style && typeof attributes.style === \"object\"\n && !Array.isArray(attributes.style)\n ? attributes.style as Record<string, unknown>\n : {};\n const typography = style.typography && typeof style.typography === \"object\"\n && !Array.isArray(style.typography)\n ? style.typography as Record<string, unknown>\n : {};\n const candidate = typography.textAlign ?? attributes.textAlign;\n const alignment = String(candidate ?? \"\");\n return TEXT_ALIGNMENTS.has(alignment) ? `text-align: ${alignment};` : undefined;\n}\n\nexport function prefixedTextSemanticProps(\n attributes: Record<string, unknown>,\n prefix: string,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = {}\n): Record<string, unknown> {\n const attributeName = (name: string) =>\n `${prefix}${name.charAt(0).toUpperCase()}${name.slice(1)}`;\n return semanticProps({\n ty: attributes[attributeName(\"ty\")],\n v: attributes[attributeName(\"v\")],\n w: attributes[attributeName(\"w\")],\n foreground: attributes[attributeName(\"foreground\")]\n }, contract, defaults);\n}\n\nexport function objectValue(\n block: FlowpressBlock,\n key: string\n): Record<string, unknown> {\n const value = block.attributes[key];\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n}\n\nexport function textValue(block: FlowpressBlock, key = \"text\"): string {\n return String(block.attributes[key] ?? \"\");\n}\n\n/**\n * Keep intentional blank lines visible across current and legacy RichText\n * serializations. Gutenberg can represent them either as repeated `<br>` tags,\n * empty paragraph elements, or literal newlines in an attribute value.\n */\nexport function preserveRichTextSpacing(html: string): string {\n const visibleEmptyBlocks = html\n .replace(/\\r\\n?/g, \"\\n\")\n .replace(\n /<(p|div)(\\s[^>]*)?>(?:\\s|&nbsp;|&#160;)*<\\/\\1>/gi,\n (_match, tag: string, attributes = \"\") =>\n `<${tag}${attributes}>&nbsp;</${tag}>`\n );\n\n return visibleEmptyBlocks\n .split(/(<[^>]+>)/g)\n .map((part) => {\n if (part.startsWith(\"<\") || part.trim() === \"\") {\n return part;\n }\n return part.replace(/\\n(?:[ \\t]*\\n)+/g, (newlines) =>\n \"<br>\".repeat((newlines.match(/\\n/g) || []).length)\n );\n })\n .join(\"\");\n}\n\n/** Keep an empty text element at its typographic line height without visible text. */\nexport function preserveEmptyTextBlock(html: string): string {\n return html.trim() === \"\" ? \"&nbsp;\" : html;\n}\n\nexport function linkValue(block: FlowpressBlock, key = \"link\"): string {\n return flowpressLinkHref(block.attributes[key]);\n}\n\nexport function responsiveValues(\n attributes: Record<string, unknown>,\n prefix: \"columns\" | \"span\",\n fallback: number\n): Record<\"base\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\", number> {\n const keys = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n const result = {} as Record<(typeof keys)[number], number>;\n let inherited = fallback;\n for (const key of keys) {\n const suffix = key === \"base\"\n ? \"Base\"\n : key === \"2xl\" ? \"2xl\" : key.charAt(0).toUpperCase() + key.slice(1);\n const candidate = Number(attributes[`${prefix}${suffix}`]);\n if (Number.isInteger(candidate) && candidate >= 1 && candidate <= 12) {\n inherited = candidate;\n }\n result[key] = inherited;\n }\n return result;\n}\n\nexport function unwrapCoreHtml(html: string): string {\n const match = html.trim().match(\n /^<(p|h[1-6]|ul|ol|li|blockquote)(?:\\s[^>]*)?>([\\s\\S]*)<\\/\\1>$/\n );\n return match?.[2] ?? html;\n}\n"]}
@@ -1,5 +1,6 @@
1
+ import { nativeFlexItemProps } from "../native/group.js";
1
2
  import {
2
- resolveDynamicStyleflowProps,
3
+ resolveFlowpressBlockStyleflowProps,
3
4
  type StyleflowContract
4
5
  } from "../../styleflow.js";
5
6
  import type { FlowpressBlock } from "../../types.js";
@@ -37,7 +38,7 @@ export function heroObjectPosition(value: unknown): string {
37
38
  export function blockHtmlAttributes(
38
39
  attributes: Record<string, unknown>,
39
40
  baseClass = ""
40
- ): { id?: string; class?: string } {
41
+ ): { id?: string; class?: string; style?: string; [key: string]: unknown } {
41
42
  const anchor = typeof attributes.anchor === "string"
42
43
  ? attributes.anchor.trim()
43
44
  : "";
@@ -49,32 +50,12 @@ export function blockHtmlAttributes(
49
50
  .join(" ")
50
51
  .replace(/\s+/g, " ");
51
52
 
52
- return {
53
+ return nativeFlexItemProps(attributes, {
53
54
  ...(anchor ? { id: anchor } : {}),
54
55
  ...(className ? { class: className } : {})
55
- };
56
+ });
56
57
  }
57
58
 
58
- const SEMANTIC_KEYS = [
59
- "theme",
60
- "tone",
61
- "intensity",
62
- "surface",
63
- "layoutRole",
64
- "density",
65
- "ty",
66
- "v",
67
- "w",
68
- "foreground",
69
- "interactivePriority",
70
- "noBackground",
71
- "noBorder",
72
- "noPadding",
73
- "noGap",
74
- "noRadius",
75
- "noForeground"
76
- ] as const;
77
-
78
59
  export const TEXT_HTML_TAGS = [
79
60
  "span",
80
61
  "p",
@@ -92,6 +73,63 @@ export const TEXT_HTML_TAGS = [
92
73
 
93
74
  export type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];
94
75
 
76
+ function preferredTypographyVariant(type: string): string | undefined {
77
+ if (type === "heading") return "2";
78
+ if (type === "body" || type === "label" || type === "code") return "md";
79
+ return undefined;
80
+ }
81
+
82
+ /**
83
+ * Derive a variant only when Gutenberg omitted it. The selected typography
84
+ * type can differ from the block's native type, so a paragraph styled as a
85
+ * heading must not inherit the paragraph-only `md` variant.
86
+ */
87
+ export function compatibleTypographyVariant(
88
+ type: string,
89
+ preferred: string,
90
+ contract?: StyleflowContract
91
+ ): string {
92
+ const variants = contract?.semantic.axes.typography.variantsByType[type];
93
+ if (!variants?.length) return preferred;
94
+
95
+ return [
96
+ preferredTypographyVariant(type),
97
+ preferred,
98
+ contract?.semantic.agentPolicy.defaults.typography.ty === type
99
+ ? contract.semantic.agentPolicy.defaults.typography.v
100
+ : undefined,
101
+ variants[0]
102
+ ].find((candidate): candidate is string => (
103
+ typeof candidate === "string" && variants.includes(candidate)
104
+ )) ?? preferred;
105
+ }
106
+
107
+ export function textBlockSemanticDefaults(
108
+ blockName: string,
109
+ attributes: Record<string, unknown>,
110
+ contract?: StyleflowContract
111
+ ): Record<string, unknown> {
112
+ const name = blockName.replace(/^sf\//, "");
113
+ const heading = name === "heading" || name === "core/heading";
114
+ const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
115
+ const defaultType = heading ? "heading" : "body";
116
+ const authored = (...values: unknown[]) => values.find((value) => value !== undefined && value !== null && value !== "");
117
+ const activeType = String(authored(attributes.ty) ?? defaultType);
118
+ const nativeVariant = heading
119
+ ? String(level)
120
+ : name.includes("quote") ? "lg" : "md";
121
+ const authoredVariant = authored(attributes.v, attributes.variant);
122
+
123
+ return {
124
+ ty: defaultType,
125
+ v: authoredVariant === undefined
126
+ ? compatibleTypographyVariant(activeType, nativeVariant, contract)
127
+ : String(authoredVariant),
128
+ w: String(authored(attributes.w, attributes.weight) ?? (heading ? "strong" : "default")),
129
+ foreground: "primary"
130
+ };
131
+ }
132
+
95
133
  export function textHtmlTag(value: unknown): TextHtmlTag {
96
134
  const candidate = String(value ?? "span");
97
135
  return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)
@@ -102,27 +140,14 @@ export function textHtmlTag(value: unknown): TextHtmlTag {
102
140
  export function semanticProps(
103
141
  attributes: Record<string, unknown>,
104
142
  contract?: StyleflowContract,
105
- defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS
143
+ defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS,
144
+ effectiveTone?: string
106
145
  ): Record<string, unknown> {
107
- const input = Object.fromEntries(
108
- SEMANTIC_KEYS
109
- .filter((key) => attributes[key] !== undefined)
110
- .map((key) => [key, attributes[key]])
111
- );
112
- if (contract) {
113
- return resolveDynamicStyleflowProps(input, defaults, contract, {
114
- strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
115
- onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
116
- });
117
- }
118
-
119
- const resolved = { ...defaults, ...input };
120
- for (const key of ["tone", "intensity", "foreground"]) {
121
- if (input[key] === "inherit") {
122
- delete resolved[key];
123
- }
124
- }
125
- return resolved;
146
+ return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {
147
+ effectiveTone,
148
+ strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
149
+ onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
150
+ });
126
151
  }
127
152
 
128
153
  const TEXT_ALIGNMENTS = new Set([
@@ -0,0 +1,9 @@
1
+ ---
2
+ import "./accordion.css";
3
+ ---
4
+ <script>
5
+ import { initializeAccordions } from "./accordion.js";
6
+ let cleanup = () => {};
7
+ const start = () => { cleanup(); cleanup = initializeAccordions(); };
8
+ start(); document.addEventListener("astro:page-load", start); document.addEventListener("astro:before-swap", () => cleanup());
9
+ </script>
@@ -0,0 +1,21 @@
1
+ ---
2
+ /**
3
+ * Head counterpart of MotionRuntime: render it right after the motion
4
+ * preference bootstrap, with the same options. Reveals that the controller
5
+ * will arm are hidden before first paint instead of after it.
6
+ * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md
7
+ */
8
+ import { motionBootCss, motionBootScript, type SfMotionOptions } from "./motion.js";
9
+ import { MOTION_ATTRIBUTE } from "../../motion-preference.js";
10
+
11
+ export interface Props extends SfMotionOptions {}
12
+
13
+ const css = motionBootCss(Astro.props);
14
+ ---
15
+
16
+ {css && (
17
+ <>
18
+ <style is:inline set:html={css}></style>
19
+ <script is:inline set:html={motionBootScript(MOTION_ATTRIBUTE)}></script>
20
+ </>
21
+ )}
@@ -0,0 +1,31 @@
1
+ ---
2
+ import {
3
+ resolveSfMotionOptions,
4
+ type SfMotionOptions,
5
+ } from "./motion.js";
6
+
7
+ export interface Props extends SfMotionOptions {}
8
+
9
+ const options = resolveSfMotionOptions(Astro.props);
10
+ ---
11
+
12
+ <style is:global>@import "./motion.css";</style>
13
+ <template data-sf-motion-options={JSON.stringify(options)}></template>
14
+
15
+ <script>
16
+ import { initializeSfMotion } from "./motion-controller.js";
17
+ import type { SfMotionOptions } from "./motion.js";
18
+
19
+ const optionsElement = document.querySelector<HTMLTemplateElement>(
20
+ "template[data-sf-motion-options]",
21
+ );
22
+ let options: SfMotionOptions = {};
23
+
24
+ try {
25
+ options = JSON.parse(optionsElement?.dataset.sfMotionOptions ?? "{}");
26
+ } catch {
27
+ // Malformed serialized configuration keeps all markup visible.
28
+ }
29
+
30
+ initializeSfMotion(options);
31
+ </script>
@@ -0,0 +1,163 @@
1
+ /* FlowPress accordion: stack > item > details, including the unmodified markup. */
2
+ /* styleflow-ignore-start rule=SF_CSS_HARDCODED reason="Disclosure geometry and motion are interaction behavior; typography uses StyleFlow tokens" scope="Project accordion" */
3
+ :where([data-layout-role="stack"]):has(> [data-layout-role="item"] > details) {
4
+ gap: 0;
5
+ }
6
+
7
+ /* Unboxed rows: the separator line below each item replaces the item frame. */
8
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]):has(> details) {
9
+ position: relative;
10
+ padding: 0;
11
+ border-width: 0;
12
+ border-radius: 0;
13
+ background: transparent;
14
+ }
15
+
16
+ /*
17
+ * Separator with the same reveal as an <hr> (`sf-reveal--line`). It is drawn
18
+ * by the item because an injected <hr> would miss the one-time reveal setup.
19
+ */
20
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]):has(> details)::after {
21
+ content: "";
22
+ position: absolute;
23
+ inset-inline: 0;
24
+ inset-block-end: 0;
25
+ block-size: 1px;
26
+ background: currentColor;
27
+ pointer-events: none;
28
+ }
29
+
30
+ /* The item only carries the reveal state: the row itself never moves or fades. */
31
+ .sf-reveal.sf-reveal--accordion-line {
32
+ --sf-reveal-duration: 1100ms;
33
+ }
34
+
35
+ html[data-sf-motion="ready"]
36
+ .sf-reveal.sf-reveal--accordion-line[data-sf-reveal-state]:not(.sf-motion-static) {
37
+ clip-path: none;
38
+ filter: none;
39
+ opacity: 1;
40
+ transform: none;
41
+ }
42
+
43
+ html[data-sf-motion="ready"]
44
+ .sf-reveal--accordion-line[data-sf-reveal-state="pending"]:not(.sf-motion-static)::after {
45
+ clip-path: inset(0 100% 0 0);
46
+ }
47
+
48
+ html[data-sf-motion="ready"]
49
+ .sf-reveal--accordion-line[data-sf-reveal-state="pending"]:not(.sf-motion-static):dir(rtl)::after {
50
+ clip-path: inset(0 0 0 100%);
51
+ }
52
+
53
+ /* Settled keeps the transition so the line never jumps if the state changes mid-draw. */
54
+ html[data-sf-motion="ready"]
55
+ .sf-reveal--accordion-line:is([data-sf-reveal-state="visible"], [data-sf-reveal-state="settled"]):not(.sf-motion-static)::after {
56
+ clip-path: inset(0);
57
+ transition: clip-path var(--sf-reveal-duration) var(--sf-motion-ease-luxury)
58
+ var(--sf-reveal-delay);
59
+ }
60
+
61
+ /* Hover styles live on details: the item's reveal states override its transitions. */
62
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details {
63
+ --fp-accordion-duration: var(--sf-motion-duration-default, 500ms);
64
+ --fp-accordion-easing: var(--sf-motion-ease-soft, cubic-bezier(0.22, 1, 0.36, 1));
65
+ --fp-accordion-hover-indent: var(--sf-layout-panel-comfortable-padding-x, 1rem);
66
+ box-sizing: border-box;
67
+ padding-inline: 0;
68
+ background-color: transparent;
69
+ transition:
70
+ background-color var(--fp-accordion-duration) var(--fp-accordion-easing),
71
+ padding-inline-start var(--fp-accordion-duration) var(--fp-accordion-easing);
72
+ }
73
+
74
+ @media (hover: hover) {
75
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details:hover {
76
+ padding-inline-start: var(--fp-accordion-hover-indent);
77
+ background-color: var(--sf-surface-sunken-background);
78
+ }
79
+ }
80
+
81
+ /* Vertical spacing stays off details: accordion.ts collapses it to the summary height. */
82
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary {
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+ gap: var(--sf-layout-panel-regular-gap, 1rem);
87
+ min-block-size: 44px;
88
+ padding-block: var(--sf-layout-panel-comfortable-padding-y, 1rem);
89
+ list-style: none;
90
+ cursor: pointer;
91
+ font-family: var(--sf-text-heading-3-light-font-family, inherit);
92
+ font-size: var(--sf-text-heading-3-light-font-size, 1.75rem);
93
+ font-style: var(--sf-text-heading-3-light-font-style, normal);
94
+ font-weight: var(--sf-text-heading-3-light-font-weight, 400);
95
+ line-height: var(--sf-text-heading-3-light-line-height, 1.1);
96
+ letter-spacing: var(--sf-text-heading-3-light-letter-spacing, -0.025em);
97
+ text-transform: var(--sf-text-heading-3-light-text-transform, none);
98
+ font-variation-settings: var(--sf-text-heading-3-light-font-variation-settings, normal);
99
+ overflow-wrap: anywhere;
100
+ }
101
+
102
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary::-webkit-details-marker {
103
+ display: none;
104
+ }
105
+
106
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary::marker {
107
+ content: "";
108
+ }
109
+
110
+ /* Two 2px bars make a decorative +; rotating 45 degrees makes the close ×. */
111
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary::after {
112
+ content: "";
113
+ flex: 0 0 auto;
114
+ inline-size: 0.75em;
115
+ block-size: 0.75em;
116
+ /* An even box keeps the centered 2px bars on whole pixels. */
117
+ inline-size: round(0.75em, 2px);
118
+ block-size: round(0.75em, 2px);
119
+ background:
120
+ linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat,
121
+ linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat;
122
+ transform: rotate(0deg);
123
+ transition: transform var(--fp-accordion-duration) var(--fp-accordion-easing);
124
+ }
125
+
126
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details[open]:not([data-accordion-expanded="false"]) > summary::after {
127
+ transform: rotate(45deg);
128
+ }
129
+
130
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary:focus-visible {
131
+ outline: 2px solid currentColor;
132
+ outline-offset: 4px;
133
+ }
134
+
135
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary ~ * {
136
+ margin-block-start: var(--sf-layout-stack-regular-gap, 0.5rem);
137
+ }
138
+
139
+ /* The summary padding already separates the first content block. */
140
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary + * {
141
+ margin-block-start: 0;
142
+ }
143
+
144
+ /* Padding, not margin: a trailing margin could collapse out below the separator. */
145
+ :where([data-layout-role="stack"]) > :where([data-layout-role="item"]) > details > summary ~ :last-child {
146
+ padding-block-end: var(--sf-layout-panel-comfortable-padding-y, 1rem);
147
+ }
148
+
149
+ /* Height is animated by accordion.ts, so closing content remains visible. */
150
+ details[data-accordion-animating="true"] {
151
+ overflow: clip;
152
+ }
153
+
154
+ html[data-sf-motion-preference="reduce"] details > summary::after {
155
+ transition: none;
156
+ }
157
+
158
+ @media (prefers-reduced-motion: reduce) {
159
+ html:not([data-sf-motion-preference]) details > summary::after {
160
+ transition: none;
161
+ }
162
+ }
163
+ /* styleflow-ignore-end */
@@ -0,0 +1,3 @@
1
+ /** Enhance the existing FlowPress markup without changing native summary controls. */
2
+ export declare function initializeAccordions(scope?: ParentNode): () => void;
3
+ //# sourceMappingURL=accordion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../src/astro/motion/accordion.ts"],"names":[],"mappings":"AAKA,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,KAAK,GAAE,UAAqB,GAAG,MAAM,IAAI,CAsG7E"}