@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,89 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import CompositionRenderer from "../CompositionRenderer.astro";
4
+ import GutenbergRenderer from "../GutenbergRenderer.astro";
5
+ import type {
6
+ FlowpressBlock,
7
+ FlowpressBlockRendererProps,
8
+ FlowpressCompositionV1,
9
+ } from "../../index.js";
10
+ import type { NestedPass } from "./query-loop.js";
11
+ import { decorateGridBlocks } from "./grid.js";
12
+
13
+ // Blocks resolved by a project resolver in a nested composition pass (Query
14
+ // Loop, Terms Query, one loop item). That pass cannot write into the outer
15
+ // composition, so it exports its own block types, stylesheets and
16
+ // diagnostics: merge them here, as SyncedPatternContent does for patterns.
17
+
18
+ type Props = Pick<
19
+ FlowpressBlockRendererProps,
20
+ "block" | "composition" | "contract" | "context" | "adapters"
21
+ > & {
22
+ blocks: FlowpressBlock[];
23
+ pass: NestedPass;
24
+ // Stylesheets and diagnostics belong to the whole pass: render them once,
25
+ // not once per loop item.
26
+ renderPassOutput?: boolean | undefined;
27
+ };
28
+
29
+ const { block, blocks, pass, composition, contract, context, adapters, renderPassOutput = true } = Astro.props;
30
+
31
+ const stylesheets = renderPassOutput ? pass.stylesheets ?? [] : [];
32
+ const blocking = renderPassOutput ? (pass.diagnostics ?? []).filter((diagnostic) => diagnostic.blocking) : [];
33
+ if (blocking.length > 0 && context.production) {
34
+ throw new Error(
35
+ `FlowPress ${block.name} is not renderable:\n`
36
+ + blocking.map(({ code, message }) => `- ${code}: ${message}`).join("\n"),
37
+ );
38
+ }
39
+
40
+ // Composition path: the parent chain was rendered through the adapter registry.
41
+ // Semantic-renderer path (inside sf/* blocks): no registry, so use the project
42
+ // renderers, which register every loop adapter.
43
+ // block-renderers.ts imports the loop adapters, which import this component:
44
+ // a static import would close that cycle, and Vite's SSR loader then hands
45
+ // block-renderers.ts undefined adapters (core/query rendered as a plain
46
+ // container, with the page-context pass). Load the registry at render time.
47
+ const { nativeBlockRenderers } = await import("./registry.js");
48
+ const nestedComposition: FlowpressCompositionV1 | undefined = composition && adapters && Object.keys(adapters).length > 0
49
+ ? {
50
+ ...composition,
51
+ blockTypes: [...composition.blockTypes, ...(pass.blockTypes ?? [])],
52
+ diagnostics: pass.diagnostics ?? [],
53
+ stylesheets: [],
54
+ }
55
+ : undefined;
56
+ ---
57
+
58
+ {stylesheets.map((stylesheet) => (
59
+ <style data-flowpress-composition-style={stylesheet.id} set:html={stylesheet.css} />
60
+ ))}
61
+ {blocking.length > 0 ? (
62
+ <StyleflowElement as="aside" data-flowpress-composition-diagnostics role="status">
63
+ <StyleflowElement as="ul">
64
+ {blocking.map(({ code, message }) => <StyleflowElement as="li" data-diagnostic-code={code}>{message}</StyleflowElement>)}
65
+ </StyleflowElement>
66
+ </StyleflowElement>
67
+ ) : null}
68
+ {blocks.length > 0 ? (
69
+ nestedComposition ? (
70
+ <CompositionRenderer
71
+ composition={nestedComposition}
72
+ adapters={adapters!}
73
+ blocks={decorateGridBlocks(blocks)}
74
+ contract={contract}
75
+ parentBlockName={block.name}
76
+ production={context.production}
77
+ depth={context.depth + 1}
78
+ />
79
+ ) : (
80
+ <GutenbergRenderer
81
+ blocks={decorateGridBlocks(blocks)}
82
+ contract={contract}
83
+ blockRenderers={nativeBlockRenderers}
84
+ parentBlockName={block.name}
85
+ production={context.production}
86
+ depth={context.depth + 1}
87
+ />
88
+ )
89
+ ) : null}
@@ -0,0 +1,92 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import CompositionRenderer from "../CompositionRenderer.astro";
4
+ import GutenbergRenderer from "../GutenbergRenderer.astro";
5
+ import type {
6
+ FlowpressBlock,
7
+ FlowpressBlockRenderer,
8
+ FlowpressBlockRendererProps,
9
+ FlowpressBlockTypeDescriptor,
10
+ FlowpressCompositionDiagnostic,
11
+ FlowpressCompositionStylesheet,
12
+ FlowpressCompositionV1,
13
+ } from "../../index.js";
14
+ import { decorateGridBlocks } from "./grid.js";
15
+
16
+ // Content of a synced pattern (core/block). The pattern's blocks arrive either
17
+ // as `innerBlocks` (the default slot, once FlowPress resolves core/block) or as
18
+ // `resolvedData` from the project resolver, which exports the block types,
19
+ // stylesheets and diagnostics of its own nested pass because that pass cannot
20
+ // write into the outer composition.
21
+ interface SyncedPatternData {
22
+ ref?: number | undefined;
23
+ blocks?: FlowpressBlock[] | undefined;
24
+ blockTypes?: FlowpressBlockTypeDescriptor[] | undefined;
25
+ stylesheets?: FlowpressCompositionStylesheet[] | undefined;
26
+ diagnostics?: FlowpressCompositionDiagnostic[] | undefined;
27
+ }
28
+
29
+ // `selfRenderer` lets the semantic renderer resolve patterns nested in patterns.
30
+ const { block, composition, contract, context, adapters, selfRenderer } = Astro.props as Pick<
31
+ FlowpressBlockRendererProps,
32
+ "block" | "composition" | "contract" | "context" | "adapters"
33
+ > & { selfRenderer?: FlowpressBlockRenderer };
34
+
35
+ const pattern = (block.resolvedData ?? {}) as SyncedPatternData;
36
+ const patternBlocks = pattern.blocks ?? [];
37
+ const stylesheets = pattern.stylesheets ?? [];
38
+ const blocking = (pattern.diagnostics ?? []).filter((diagnostic) => diagnostic.blocking);
39
+ if (blocking.length > 0 && context.production) {
40
+ throw new Error(
41
+ `FlowPress synced pattern ${pattern.ref ?? block.attributes.ref} is not renderable:\n`
42
+ + blocking.map(({ code, message }) => `- ${code}: ${message}`).join("\n"),
43
+ );
44
+ }
45
+
46
+ // Composition path: the parent chain was rendered through the adapter registry.
47
+ // Semantic-renderer path (inside sf/* blocks): use the project renderers so
48
+ // resolved blocks inside patterns keep their adapters too.
49
+ const { nativeBlockRenderers } = await import("./registry.js");
50
+ const patternComposition: FlowpressCompositionV1 | undefined = composition && adapters && Object.keys(adapters).length > 0
51
+ ? {
52
+ ...composition,
53
+ blockTypes: [...composition.blockTypes, ...(pattern.blockTypes ?? [])],
54
+ diagnostics: pattern.diagnostics ?? [],
55
+ stylesheets: [],
56
+ }
57
+ : undefined;
58
+ ---
59
+
60
+ {stylesheets.map((stylesheet) => (
61
+ <style data-flowpress-composition-style={stylesheet.id} set:html={stylesheet.css} />
62
+ ))}
63
+ {blocking.length > 0 ? (
64
+ <StyleflowElement as="aside" data-flowpress-composition-diagnostics role="status">
65
+ <StyleflowElement as="ul">
66
+ {blocking.map(({ code, message }) => <StyleflowElement as="li" data-diagnostic-code={code}>{message}</StyleflowElement>)}
67
+ </StyleflowElement>
68
+ </StyleflowElement>
69
+ ) : null}
70
+ {patternBlocks.length > 0 ? (
71
+ patternComposition ? (
72
+ <CompositionRenderer
73
+ composition={patternComposition}
74
+ adapters={adapters!}
75
+ blocks={decorateGridBlocks(patternBlocks)}
76
+ contract={contract}
77
+ parentBlockName={block.name}
78
+ production={context.production}
79
+ depth={context.depth + 1}
80
+ />
81
+ ) : (
82
+ <GutenbergRenderer
83
+ blocks={decorateGridBlocks(patternBlocks)}
84
+ contract={contract}
85
+ blockRenderers={{ ...nativeBlockRenderers, ...(selfRenderer ? { [block.name]: selfRenderer } : {}) }}
86
+ parentBlockName={block.name}
87
+ production={context.production}
88
+ depth={context.depth + 1}
89
+ />
90
+ )
91
+ ) : null}
92
+ <slot />
@@ -0,0 +1,38 @@
1
+ ---
2
+ import { decodeFlowpressText } from "../../text.js";
3
+ import StyleflowElement from "../StyleflowElement.astro";
4
+ import { classNames, text, type ResolvedImage } from "./query-loop.js";
5
+
6
+ // Value of a term custom field inside the link of a Post Terms item
7
+ // (apps/cms/project/src/custom-fields.php, FLOWPRESS_PROJECT_TERM_LIST_OUTPUTS).
8
+ // Inline outputs only: the block-level ones (rich text, list, link) are never
9
+ // resolved for this block, and none of them would be valid inside an <a>.
10
+ interface Props {
11
+ field: { as?: string | undefined; value?: unknown };
12
+ // Accessible name of an image that is the only content of the term link.
13
+ fallbackAlt?: string | undefined;
14
+ }
15
+ const { field, fallbackAlt = "" } = Astro.props;
16
+ const as = text(field.as);
17
+ const image = (as === "image" ? field.value ?? {} : {}) as ResolvedImage;
18
+ const date = (as === "date" ? field.value ?? {} : {}) as { datetime?: string | undefined; formatted?: string };
19
+ const imageProps = {
20
+ src: text(image.url),
21
+ srcset: image.srcSet || undefined,
22
+ sizes: image.srcSet ? image.sizes || undefined : undefined,
23
+ width: image.width,
24
+ height: image.height,
25
+ alt: image.alt || fallbackAlt,
26
+ class: classNames("wp-block-post-terms__field", image.id ? `wp-image-${image.id}` : undefined),
27
+ loading: "lazy" as const,
28
+ decoding: "async" as const,
29
+ };
30
+ ---
31
+
32
+ {as === "image" ? (
33
+ imageProps.src ? <StyleflowElement as="img" {...imageProps} /> : null
34
+ ) : as === "date" ? (
35
+ <StyleflowElement as="time" class="wp-block-post-terms__field" datetime={date.datetime}>{decodeFlowpressText(date.formatted)}</StyleflowElement>
36
+ ) : (
37
+ <StyleflowElement as="span" class="wp-block-post-terms__field">{decodeFlowpressText(field.value)}</StyleflowElement>
38
+ )}
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { decodeFlowpressText } from "../../text.js";
3
+ import StyleflowElement from "../StyleflowElement.astro";
4
+ import type { TimelineItem } from "./timeline.js";
5
+ import "./timeline.css";
6
+ interface Props { items:TimelineItem[]; tone?:string | undefined; intensity?:string | undefined; id?:string | undefined; class?:string | undefined; ariaLabel?:string | undefined; rootProps?:Record<string,unknown> | undefined; styleflowProps?:Record<string,unknown> | undefined; }
7
+ const {items,tone="inherit",intensity="inherit",id,class:className="",ariaLabel="Timeline",rootProps={},styleflowProps={}}=Astro.props;
8
+ ---
9
+ <StyleflowElement as="section" {...rootProps} {...styleflowProps} id={id ?? (typeof rootProps.id === "string" ? rootProps.id : undefined)} {...(tone !== "inherit" ? {tone} : {})} {...(intensity !== "inherit" ? {intensity} : {})} layoutRole="stack" density="regular" aria-label={ariaLabel} class:list={["flowpress-timeline",rootProps.class,className]} data-flowpress-timeline>
10
+ <StyleflowElement as="ol" layoutRole="stack" density="regular" class="flowpress-timeline__list">
11
+ {items.map(item=>(
12
+ <StyleflowElement as="li" {...(item.tone && item.tone !== "inherit" ? {tone:item.tone} : {})} {...(item.intensity && item.intensity !== "inherit" ? {intensity:item.intensity} : {})} layoutRole="stack" density="regular" surface="default" class="flowpress-timeline__item" data-flowpress-timeline-item>
13
+ {item.year && <StyleflowElement as="h3">{decodeFlowpressText(item.year)}</StyleflowElement>}
14
+ {item.image && <StyleflowElement as="img" src={item.image.url ?? item.image.sourceUrl} alt={item.image.alt ?? item.image.altText ?? ""} width={item.image.width} height={item.image.height} loading="lazy" />}
15
+ {item.description && <StyleflowElement as="p">{decodeFlowpressText(item.description)}</StyleflowElement>}
16
+ {item.metric && <StyleflowElement as="p">{decodeFlowpressText(item.metric)}</StyleflowElement>}
17
+ {(item.statisticValue || item.statisticLabel) && <StyleflowElement as="p"><StyleflowElement as="strong">{decodeFlowpressText(item.statisticValue)}</StyleflowElement> {decodeFlowpressText(item.statisticLabel)}</StyleflowElement>}
18
+ </StyleflowElement>
19
+ ))}
20
+ </StyleflowElement>
21
+ </StyleflowElement>
@@ -0,0 +1,7 @@
1
+ ---
2
+ import type { FlowpressBlockRendererProps } from "../../index.js";
3
+ import Timeline from "./Timeline.astro";
4
+ import { timelineItemsFromBlocks } from "./timeline.js";
5
+ const {block,htmlProps,styleflowProps} = Astro.props as FlowpressBlockRendererProps;
6
+ ---
7
+ <Timeline items={timelineItemsFromBlocks([block])} rootProps={htmlProps} styleflowProps={styleflowProps} />
@@ -0,0 +1,2 @@
1
+ export { BLOB_BOX, BLOB_VARIANTS } from "@styleflow.app/flowpress-components/organic-shapes";
2
+ //# sourceMappingURL=blob-shapes.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-shapes.generated.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/blob-shapes.generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { BLOB_BOX, BLOB_VARIANTS } from "@styleflow.app/flowpress-components/organic-shapes";
2
+ //# sourceMappingURL=blob-shapes.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-shapes.generated.js","sourceRoot":"","sources":["../../../../src/astro/native/blob/blob-shapes.generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC","sourcesContent":["export { BLOB_BOX, BLOB_VARIANTS } from \"@styleflow.app/flowpress-components/organic-shapes\";\n"]}
@@ -0,0 +1 @@
1
+ export { BLOB_BOX, BLOB_VARIANTS } from "@styleflow.app/flowpress-components/organic-shapes";
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Pure, DOM-free parsing of the blob authoring options. Shared by the Astro
3
+ * component (server) and the morph controller (browser) so both read the same
4
+ * `data-blob-*` contract and clamp values identically.
5
+ */
6
+ export declare const BLOB_MORPH_MODES: readonly ["none", "auto", "hover"];
7
+ export type BlobMorphMode = (typeof BLOB_MORPH_MODES)[number];
8
+ export declare const BLOB_CONTENT_FITS: readonly ["cover", "center"];
9
+ export type BlobContentFit = (typeof BLOB_CONTENT_FITS)[number];
10
+ export declare const BLOB_ASPECT_RATIOS: readonly ["natural", "square", "portrait", "landscape"];
11
+ export type BlobAspectRatio = (typeof BLOB_ASPECT_RATIOS)[number];
12
+ export declare const BLOB_DEFAULT_MORPH_DURATION = 2400;
13
+ export declare const BLOB_DEFAULT_MORPH_INTERVAL = 1200;
14
+ export declare const BLOB_DEFAULT_OUTLINE_WIDTH = 2;
15
+ export interface BlobMorphConfig {
16
+ mode: BlobMorphMode;
17
+ /** Zero-based index of the variant the blob rests on. */
18
+ base: number;
19
+ /** Zero-based variants the blob may morph into. */
20
+ targets: number[];
21
+ duration: number;
22
+ interval: number;
23
+ }
24
+ export declare function clampNumber(value: unknown, min: number, max: number, fallback: number): number;
25
+ /** Authors count from 1; the registry is zero-based. Invalid input rests on variant 1. */
26
+ export declare function resolveVariantIndex(value: unknown, count: number): number;
27
+ /**
28
+ * `"2, 5, 9"` or `[2, 5, 9]` → zero-based unique indices in authoring order.
29
+ * Empty input means every variant; unknown numbers are ignored.
30
+ */
31
+ export declare function parseVariantList(value: unknown, count: number): number[];
32
+ export declare const resolveMorphMode: (value: unknown) => BlobMorphMode;
33
+ export declare const resolveContentFit: (value: unknown) => BlobContentFit;
34
+ export declare const resolveAspectRatio: (value: unknown) => BlobAspectRatio;
35
+ export declare function resolveOutlineWidth(value: unknown): number;
36
+ export interface BlobMorphInput {
37
+ variant?: unknown;
38
+ morph?: unknown;
39
+ targets?: unknown;
40
+ duration?: unknown;
41
+ interval?: unknown;
42
+ }
43
+ export declare function resolveMorphConfig(input: BlobMorphInput, count: number): BlobMorphConfig;
44
+ /** The `data-blob-*` attributes the server writes and the controller reads back. */
45
+ export declare function morphDataAttributes(config: BlobMorphConfig): Record<string, string>;
46
+ export declare function morphConfigFromDataset(dataset: Readonly<Record<string, string | undefined>>, count: number): BlobMorphConfig;
47
+ /** Random candidate different from `current`, or `null` when nothing else is allowed. */
48
+ export declare function pickMorphTarget(candidates: readonly number[], current: number, random?: () => number): number | null;
49
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,gBAAgB,oCAAqC,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,CA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AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CAQxF;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQnF;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACrD,KAAK,EAAE,MAAM,GACZ,eAAe,CAWjB;AAED,yFAAyF;AACzF,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAM,MAAoB,GACjC,MAAM,GAAG,IAAI,CAKf"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Pure, DOM-free parsing of the blob authoring options. Shared by the Astro
3
+ * component (server) and the morph controller (browser) so both read the same
4
+ * `data-blob-*` contract and clamp values identically.
5
+ */
6
+ export const BLOB_MORPH_MODES = ["none", "auto", "hover"];
7
+ export const BLOB_CONTENT_FITS = ["cover", "center"];
8
+ export const BLOB_ASPECT_RATIOS = ["natural", "square", "portrait", "landscape"];
9
+ export const BLOB_DEFAULT_MORPH_DURATION = 2400;
10
+ export const BLOB_DEFAULT_MORPH_INTERVAL = 1200;
11
+ export const BLOB_DEFAULT_OUTLINE_WIDTH = 2;
12
+ export function clampNumber(value, min, max, fallback) {
13
+ const number = typeof value === "number" ? value : Number(value);
14
+ if (value === "" || value === null || value === undefined || !Number.isFinite(number)) {
15
+ return fallback;
16
+ }
17
+ return Math.min(max, Math.max(min, number));
18
+ }
19
+ function oneOf(values, value, fallback) {
20
+ return typeof value === "string" && values.includes(value)
21
+ ? value
22
+ : fallback;
23
+ }
24
+ /** Authors count from 1; the registry is zero-based. Invalid input rests on variant 1. */
25
+ export function resolveVariantIndex(value, count) {
26
+ const number = typeof value === "number" ? value : Number(String(value ?? ""));
27
+ return Number.isInteger(number) && number >= 1 && number <= count ? number - 1 : 0;
28
+ }
29
+ /**
30
+ * `"2, 5, 9"` or `[2, 5, 9]` → zero-based unique indices in authoring order.
31
+ * Empty input means every variant; unknown numbers are ignored.
32
+ */
33
+ export function parseVariantList(value, count) {
34
+ const parts = Array.isArray(value) ? value : String(value ?? "").split(/[\s,;]+/);
35
+ const indices = [];
36
+ for (const part of parts) {
37
+ const number = typeof part === "number" ? part : Number(String(part));
38
+ if (Number.isInteger(number) && number >= 1 && number <= count && !indices.includes(number - 1)) {
39
+ indices.push(number - 1);
40
+ }
41
+ }
42
+ return indices.length > 0 ? indices : Array.from({ length: count }, (_, index) => index);
43
+ }
44
+ export const resolveMorphMode = (value) => oneOf(BLOB_MORPH_MODES, value, "none");
45
+ export const resolveContentFit = (value) => oneOf(BLOB_CONTENT_FITS, value, "cover");
46
+ export const resolveAspectRatio = (value) => oneOf(BLOB_ASPECT_RATIOS, value, "natural");
47
+ export function resolveOutlineWidth(value) {
48
+ return clampNumber(value, 0, 12, BLOB_DEFAULT_OUTLINE_WIDTH);
49
+ }
50
+ export function resolveMorphConfig(input, count) {
51
+ return {
52
+ mode: resolveMorphMode(input.morph),
53
+ base: resolveVariantIndex(input.variant, count),
54
+ targets: parseVariantList(input.targets, count),
55
+ duration: clampNumber(input.duration, 400, 10000, BLOB_DEFAULT_MORPH_DURATION),
56
+ interval: clampNumber(input.interval, 0, 30000, BLOB_DEFAULT_MORPH_INTERVAL),
57
+ };
58
+ }
59
+ /** The `data-blob-*` attributes the server writes and the controller reads back. */
60
+ export function morphDataAttributes(config) {
61
+ return {
62
+ "data-blob-variant": String(config.base + 1),
63
+ "data-blob-morph": config.mode,
64
+ "data-blob-targets": config.targets.map((index) => index + 1).join(","),
65
+ "data-blob-duration": String(config.duration),
66
+ "data-blob-interval": String(config.interval),
67
+ };
68
+ }
69
+ export function morphConfigFromDataset(dataset, count) {
70
+ return resolveMorphConfig({
71
+ variant: dataset.blobVariant,
72
+ morph: dataset.blobMorph,
73
+ targets: dataset.blobTargets,
74
+ duration: dataset.blobDuration,
75
+ interval: dataset.blobInterval,
76
+ }, count);
77
+ }
78
+ /** Random candidate different from `current`, or `null` when nothing else is allowed. */
79
+ export function pickMorphTarget(candidates, current, random = Math.random) {
80
+ const options = candidates.filter((index) => index !== current);
81
+ if (options.length === 0)
82
+ return null;
83
+ const position = Math.min(options.length - 1, Math.floor(random() * options.length));
84
+ return options[position] ?? null;
85
+ }
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/astro/native/blob/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAGnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAU,CAAC;AAG9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAU,CAAC;AAG1F,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAY5C,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,GAAW,EAAE,GAAW,EAAE,QAAgB;IACpF,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,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AM;IAElC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IAChE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Pure, DOM-free parsing of the blob authoring options. Shared by the Astro\n * component (server) and the morph controller (browser) so both read the same\n * `data-blob-*` contract and clamp values identically.\n */\n\nexport const BLOB_MORPH_MODES = [\"none\", \"auto\", \"hover\"] as const;\nexport type BlobMorphMode = (typeof BLOB_MORPH_MODES)[number];\n\nexport const BLOB_CONTENT_FITS = [\"cover\", \"center\"] as const;\nexport type BlobContentFit = (typeof BLOB_CONTENT_FITS)[number];\n\nexport const BLOB_ASPECT_RATIOS = [\"natural\", \"square\", \"portrait\", \"landscape\"] as const;\nexport type BlobAspectRatio = (typeof BLOB_ASPECT_RATIOS)[number];\n\nexport const BLOB_DEFAULT_MORPH_DURATION = 2400;\nexport const BLOB_DEFAULT_MORPH_INTERVAL = 1200;\nexport const BLOB_DEFAULT_OUTLINE_WIDTH = 2;\n\nexport interface BlobMorphConfig {\n mode: BlobMorphMode;\n /** Zero-based index of the variant the blob rests on. */\n base: number;\n /** Zero-based variants the blob may morph into. */\n targets: number[];\n duration: number;\n interval: number;\n}\n\nexport function clampNumber(value: unknown, min: number, max: number, fallback: number): number {\n const number = typeof value === \"number\" ? value : Number(value);\n if (value === \"\" || value === null || value === undefined || !Number.isFinite(number)) {\n return fallback;\n }\n return Math.min(max, Math.max(min, number));\n}\n\nfunction oneOf<T extends string>(values: readonly T[], value: unknown, fallback: T): T {\n return typeof value === \"string\" && (values as readonly string[]).includes(value)\n ? (value as T)\n : fallback;\n}\n\n/** Authors count from 1; the registry is zero-based. Invalid input rests on variant 1. */\nexport function resolveVariantIndex(value: unknown, count: number): number {\n const number = typeof value === \"number\" ? value : Number(String(value ?? \"\"));\n return Number.isInteger(number) && number >= 1 && number <= count ? number - 1 : 0;\n}\n\n/**\n * `\"2, 5, 9\"` or `[2, 5, 9]` → zero-based unique indices in authoring order.\n * Empty input means every variant; unknown numbers are ignored.\n */\nexport function parseVariantList(value: unknown, count: number): number[] {\n const parts = Array.isArray(value) ? value : String(value ?? \"\").split(/[\\s,;]+/);\n const indices: number[] = [];\n for (const part of parts) {\n const number = typeof part === \"number\" ? part : Number(String(part));\n if (Number.isInteger(number) && number >= 1 && number <= count && !indices.includes(number - 1)) {\n indices.push(number - 1);\n }\n }\n return indices.length > 0 ? indices : Array.from({ length: count }, (_, index) => index);\n}\n\nexport const resolveMorphMode = (value: unknown): BlobMorphMode =>\n oneOf(BLOB_MORPH_MODES, value, \"none\");\nexport const resolveContentFit = (value: unknown): BlobContentFit =>\n oneOf(BLOB_CONTENT_FITS, value, \"cover\");\nexport const resolveAspectRatio = (value: unknown): BlobAspectRatio =>\n oneOf(BLOB_ASPECT_RATIOS, value, \"natural\");\n\nexport function resolveOutlineWidth(value: unknown): number {\n return clampNumber(value, 0, 12, BLOB_DEFAULT_OUTLINE_WIDTH);\n}\n\nexport interface BlobMorphInput {\n variant?: unknown;\n morph?: unknown;\n targets?: unknown;\n duration?: unknown;\n interval?: unknown;\n}\n\nexport function resolveMorphConfig(input: BlobMorphInput, count: number): BlobMorphConfig {\n return {\n mode: resolveMorphMode(input.morph),\n base: resolveVariantIndex(input.variant, count),\n targets: parseVariantList(input.targets, count),\n duration: clampNumber(input.duration, 400, 10000, BLOB_DEFAULT_MORPH_DURATION),\n interval: clampNumber(input.interval, 0, 30000, BLOB_DEFAULT_MORPH_INTERVAL),\n };\n}\n\n/** The `data-blob-*` attributes the server writes and the controller reads back. */\nexport function morphDataAttributes(config: BlobMorphConfig): Record<string, string> {\n return {\n \"data-blob-variant\": String(config.base + 1),\n \"data-blob-morph\": config.mode,\n \"data-blob-targets\": config.targets.map((index) => index + 1).join(\",\"),\n \"data-blob-duration\": String(config.duration),\n \"data-blob-interval\": String(config.interval),\n };\n}\n\nexport function morphConfigFromDataset(\n dataset: Readonly<Record<string, string | undefined>>,\n count: number,\n): BlobMorphConfig {\n return resolveMorphConfig(\n {\n variant: dataset.blobVariant,\n morph: dataset.blobMorph,\n targets: dataset.blobTargets,\n duration: dataset.blobDuration,\n interval: dataset.blobInterval,\n },\n count,\n );\n}\n\n/** Random candidate different from `current`, or `null` when nothing else is allowed. */\nexport function pickMorphTarget(\n candidates: readonly number[],\n current: number,\n random: () => number = Math.random,\n): number | null {\n const options = candidates.filter((index) => index !== current);\n if (options.length === 0) return null;\n const position = Math.min(options.length - 1, Math.floor(random() * options.length));\n return options[position] ?? null;\n}\n"]}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Pure, DOM-free parsing of the blob authoring options. Shared by the Astro
3
+ * component (server) and the morph controller (browser) so both read the same
4
+ * `data-blob-*` contract and clamp values identically.
5
+ */
6
+
7
+ export const BLOB_MORPH_MODES = ["none", "auto", "hover"] as const;
8
+ export type BlobMorphMode = (typeof BLOB_MORPH_MODES)[number];
9
+
10
+ export const BLOB_CONTENT_FITS = ["cover", "center"] as const;
11
+ export type BlobContentFit = (typeof BLOB_CONTENT_FITS)[number];
12
+
13
+ export const BLOB_ASPECT_RATIOS = ["natural", "square", "portrait", "landscape"] as const;
14
+ export type BlobAspectRatio = (typeof BLOB_ASPECT_RATIOS)[number];
15
+
16
+ export const BLOB_DEFAULT_MORPH_DURATION = 2400;
17
+ export const BLOB_DEFAULT_MORPH_INTERVAL = 1200;
18
+ export const BLOB_DEFAULT_OUTLINE_WIDTH = 2;
19
+
20
+ export interface BlobMorphConfig {
21
+ mode: BlobMorphMode;
22
+ /** Zero-based index of the variant the blob rests on. */
23
+ base: number;
24
+ /** Zero-based variants the blob may morph into. */
25
+ targets: number[];
26
+ duration: number;
27
+ interval: number;
28
+ }
29
+
30
+ export function clampNumber(value: unknown, min: number, max: number, fallback: number): number {
31
+ const number = typeof value === "number" ? value : Number(value);
32
+ if (value === "" || value === null || value === undefined || !Number.isFinite(number)) {
33
+ return fallback;
34
+ }
35
+ return Math.min(max, Math.max(min, number));
36
+ }
37
+
38
+ function oneOf<T extends string>(values: readonly T[], value: unknown, fallback: T): T {
39
+ return typeof value === "string" && (values as readonly string[]).includes(value)
40
+ ? (value as T)
41
+ : fallback;
42
+ }
43
+
44
+ /** Authors count from 1; the registry is zero-based. Invalid input rests on variant 1. */
45
+ export function resolveVariantIndex(value: unknown, count: number): number {
46
+ const number = typeof value === "number" ? value : Number(String(value ?? ""));
47
+ return Number.isInteger(number) && number >= 1 && number <= count ? number - 1 : 0;
48
+ }
49
+
50
+ /**
51
+ * `"2, 5, 9"` or `[2, 5, 9]` → zero-based unique indices in authoring order.
52
+ * Empty input means every variant; unknown numbers are ignored.
53
+ */
54
+ export function parseVariantList(value: unknown, count: number): number[] {
55
+ const parts = Array.isArray(value) ? value : String(value ?? "").split(/[\s,;]+/);
56
+ const indices: number[] = [];
57
+ for (const part of parts) {
58
+ const number = typeof part === "number" ? part : Number(String(part));
59
+ if (Number.isInteger(number) && number >= 1 && number <= count && !indices.includes(number - 1)) {
60
+ indices.push(number - 1);
61
+ }
62
+ }
63
+ return indices.length > 0 ? indices : Array.from({ length: count }, (_, index) => index);
64
+ }
65
+
66
+ export const resolveMorphMode = (value: unknown): BlobMorphMode =>
67
+ oneOf(BLOB_MORPH_MODES, value, "none");
68
+ export const resolveContentFit = (value: unknown): BlobContentFit =>
69
+ oneOf(BLOB_CONTENT_FITS, value, "cover");
70
+ export const resolveAspectRatio = (value: unknown): BlobAspectRatio =>
71
+ oneOf(BLOB_ASPECT_RATIOS, value, "natural");
72
+
73
+ export function resolveOutlineWidth(value: unknown): number {
74
+ return clampNumber(value, 0, 12, BLOB_DEFAULT_OUTLINE_WIDTH);
75
+ }
76
+
77
+ export interface BlobMorphInput {
78
+ variant?: unknown;
79
+ morph?: unknown;
80
+ targets?: unknown;
81
+ duration?: unknown;
82
+ interval?: unknown;
83
+ }
84
+
85
+ export function resolveMorphConfig(input: BlobMorphInput, count: number): BlobMorphConfig {
86
+ return {
87
+ mode: resolveMorphMode(input.morph),
88
+ base: resolveVariantIndex(input.variant, count),
89
+ targets: parseVariantList(input.targets, count),
90
+ duration: clampNumber(input.duration, 400, 10000, BLOB_DEFAULT_MORPH_DURATION),
91
+ interval: clampNumber(input.interval, 0, 30000, BLOB_DEFAULT_MORPH_INTERVAL),
92
+ };
93
+ }
94
+
95
+ /** The `data-blob-*` attributes the server writes and the controller reads back. */
96
+ export function morphDataAttributes(config: BlobMorphConfig): Record<string, string> {
97
+ return {
98
+ "data-blob-variant": String(config.base + 1),
99
+ "data-blob-morph": config.mode,
100
+ "data-blob-targets": config.targets.map((index) => index + 1).join(","),
101
+ "data-blob-duration": String(config.duration),
102
+ "data-blob-interval": String(config.interval),
103
+ };
104
+ }
105
+
106
+ export function morphConfigFromDataset(
107
+ dataset: Readonly<Record<string, string | undefined>>,
108
+ count: number,
109
+ ): BlobMorphConfig {
110
+ return resolveMorphConfig(
111
+ {
112
+ variant: dataset.blobVariant,
113
+ morph: dataset.blobMorph,
114
+ targets: dataset.blobTargets,
115
+ duration: dataset.blobDuration,
116
+ interval: dataset.blobInterval,
117
+ },
118
+ count,
119
+ );
120
+ }
121
+
122
+ /** Random candidate different from `current`, or `null` when nothing else is allowed. */
123
+ export function pickMorphTarget(
124
+ candidates: readonly number[],
125
+ current: number,
126
+ random: () => number = Math.random,
127
+ ): number | null {
128
+ const options = candidates.filter((index) => index !== current);
129
+ if (options.length === 0) return null;
130
+ const position = Math.min(options.length - 1, Math.floor(random() * options.length));
131
+ return options[position] ?? null;
132
+ }
@@ -0,0 +1,11 @@
1
+ export declare const BLOB_ROOT_SELECTOR = "[data-sf-blob]";
2
+ export declare const CARD_ANIMATION_CLASS = "card__animation";
3
+ export declare const CARD_ANIMATION_TRIGGER_SELECTOR = ".card__has_animations";
4
+ /**
5
+ * Wire every `[data-sf-blob]` with `data-blob-morph` set to `auto` or `hover`.
6
+ * Blobs are wired even while motion is reduced, so allowing it again starts
7
+ * them without a reload. Returns a disposer that restores the static state
8
+ * (for tests and view swaps).
9
+ */
10
+ export declare function initializeSfBlobs(scope?: ParentNode): () => void;
11
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/controller.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AACtD,eAAO,MAAM,+BAA+B,0BAA0B,CAAC;AAmMvE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,UAAqB,GAAG,MAAM,IAAI,CAsB1E"}