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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/astro/CompositionRenderer.astro +13 -2
  3. package/dist/astro/DefaultBlockAdapter.astro +1 -0
  4. package/dist/astro/FontStylesheets.astro +35 -0
  5. package/dist/astro/GutenbergRenderer.astro +58 -19
  6. package/dist/astro/Media.astro +24 -0
  7. package/dist/astro/StyleflowElement.astro +1 -0
  8. package/dist/astro/blocks/CarouselBlock.astro +3 -0
  9. package/dist/astro/blocks/CoverBlock.astro +2 -1
  10. package/dist/astro/blocks/HeroBlock.astro +2 -1
  11. package/dist/astro/blocks/ImageBlock.astro +2 -1
  12. package/dist/astro/blocks/ListItemFallback.astro +2 -1
  13. package/dist/astro/blocks/SiteLogoBlock.astro +3 -2
  14. package/dist/astro/blocks/helpers.d.ts +3 -1
  15. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  16. package/dist/astro/blocks/helpers.js +5 -3
  17. package/dist/astro/blocks/helpers.js.map +1 -1
  18. package/dist/astro/blocks/helpers.ts +7 -4
  19. package/dist/astro/motion/AccordionRuntime.astro +9 -0
  20. package/dist/astro/motion/MotionBoot.astro +21 -0
  21. package/dist/astro/motion/MotionRuntime.astro +31 -0
  22. package/dist/astro/motion/accordion.css +163 -0
  23. package/dist/astro/motion/accordion.d.ts +3 -0
  24. package/dist/astro/motion/accordion.d.ts.map +1 -0
  25. package/dist/astro/motion/accordion.js +98 -0
  26. package/dist/astro/motion/accordion.js.map +1 -0
  27. package/dist/astro/motion/accordion.ts +109 -0
  28. package/dist/astro/motion/motion-controller.d.ts +12 -0
  29. package/dist/astro/motion/motion-controller.d.ts.map +1 -0
  30. package/dist/astro/motion/motion-controller.js +293 -0
  31. package/dist/astro/motion/motion-controller.js.map +1 -0
  32. package/dist/astro/motion/motion-controller.ts +377 -0
  33. package/dist/astro/motion/motion.css +546 -0
  34. package/dist/astro/motion/motion.d.ts +127 -0
  35. package/dist/astro/motion/motion.d.ts.map +1 -0
  36. package/dist/astro/motion/motion.js +255 -0
  37. package/dist/astro/motion/motion.js.map +1 -0
  38. package/dist/astro/motion/motion.ts +419 -0
  39. package/dist/astro/native/CustomFieldValue.astro +2 -1
  40. package/dist/astro/native/ReservedLogin.astro +107 -0
  41. package/dist/astro/native/ResolvedBlocks.astro +2 -0
  42. package/dist/astro/native/SyncedPatternContent.astro +2 -0
  43. package/dist/astro/native/TermFieldValue.astro +2 -1
  44. package/dist/astro/native/Timeline.astro +2 -1
  45. package/dist/astro/native/blob.css +1 -1
  46. package/dist/astro/native/button-template.d.ts +31 -0
  47. package/dist/astro/native/button-template.d.ts.map +1 -0
  48. package/dist/astro/native/button-template.js +54 -0
  49. package/dist/astro/native/button-template.js.map +1 -0
  50. package/dist/astro/native/button-template.ts +92 -0
  51. package/dist/astro/native/core-button-fallback.astro +43 -0
  52. package/dist/astro/native/core-button.astro +48 -26
  53. package/dist/astro/native/core-group.astro +3 -1
  54. package/dist/astro/native/core-image.astro +3 -2
  55. package/dist/astro/native/core-navigation.astro +9 -2
  56. package/dist/astro/native/core-post-featured-image.astro +3 -2
  57. package/dist/astro/native/core-post-template-fallback.astro +30 -0
  58. package/dist/astro/native/core-post-template.astro +17 -24
  59. package/dist/astro/native/grid-bleed.d.ts +2 -0
  60. package/dist/astro/native/grid-bleed.d.ts.map +1 -0
  61. package/dist/astro/native/grid-bleed.js +24 -7
  62. package/dist/astro/native/grid-bleed.js.map +1 -0
  63. package/dist/astro/native/group.css +36 -0
  64. package/dist/astro/native/group.d.ts +15 -0
  65. package/dist/astro/native/group.d.ts.map +1 -0
  66. package/dist/astro/native/group.js +66 -0
  67. package/dist/astro/native/group.js.map +1 -0
  68. package/dist/astro/native/group.ts +61 -0
  69. package/dist/astro/native/inline-text.css +15 -0
  70. package/dist/astro/native/query-carousel.d.ts +12 -0
  71. package/dist/astro/native/query-carousel.d.ts.map +1 -0
  72. package/dist/astro/native/query-carousel.js +36 -0
  73. package/dist/astro/native/query-carousel.js.map +1 -0
  74. package/dist/astro/native/query-carousel.ts +56 -0
  75. package/dist/astro/native/registry.d.ts.map +1 -1
  76. package/dist/astro/native/registry.js +3 -0
  77. package/dist/astro/native/registry.js.map +1 -1
  78. package/dist/astro/native/registry.ts +4 -0
  79. package/dist/astro/native/timeline.css +1 -1
  80. package/dist/astro/preferences/AccessibilityPanel.astro +73 -86
  81. package/dist/block-renderers.d.ts +2 -0
  82. package/dist/block-renderers.d.ts.map +1 -1
  83. package/dist/block-renderers.js.map +1 -1
  84. package/dist/composition.d.ts.map +1 -1
  85. package/dist/composition.js +2 -1
  86. package/dist/composition.js.map +1 -1
  87. package/dist/default-blocks.d.ts +1 -1
  88. package/dist/default-blocks.d.ts.map +1 -1
  89. package/dist/default-blocks.js +3 -1
  90. package/dist/default-blocks.js.map +1 -1
  91. package/dist/reserved-area.d.ts +10 -0
  92. package/dist/reserved-area.d.ts.map +1 -0
  93. package/dist/reserved-area.js +93 -0
  94. package/dist/reserved-area.js.map +1 -0
  95. package/dist/styleflow.d.ts +2 -0
  96. package/dist/styleflow.d.ts.map +1 -1
  97. package/dist/styleflow.js +6 -4
  98. package/dist/styleflow.js.map +1 -1
  99. package/dist/svg-media-runtime.d.ts +3 -0
  100. package/dist/svg-media-runtime.d.ts.map +1 -0
  101. package/dist/svg-media-runtime.js +33 -0
  102. package/dist/svg-media-runtime.js.map +1 -0
  103. package/dist/svg-media-types.d.ts +11 -0
  104. package/dist/svg-media-types.d.ts.map +1 -0
  105. package/dist/svg-media-types.js +2 -0
  106. package/dist/svg-media-types.js.map +1 -0
  107. package/dist/svg-media.d.ts +10 -0
  108. package/dist/svg-media.d.ts.map +1 -0
  109. package/dist/svg-media.js +34 -0
  110. package/dist/svg-media.js.map +1 -0
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/package.json +30 -3
@@ -0,0 +1,419 @@
1
+ export const SF_REVEAL_SELECTOR = ".sf-reveal:not(.sf-motion-static)";
2
+
3
+ export const SF_REVEAL_CLASS = "sf-reveal";
4
+
5
+ export const SF_MOTION_STATIC_CLASS = "sf-motion-static";
6
+
7
+ export const SF_MOTION_DISABLE_CLASS = "sf-motion-disable";
8
+
9
+ export const SF_MOTION_DRAWER_EXIT_MS = 820;
10
+
11
+ export const SF_REVEAL_VISIBLE_RATIO = 0.2;
12
+
13
+ export const SF_REVEAL_STAGGER_SELECTOR = ".sf-reveal-stagger";
14
+
15
+ export const SF_REVEAL_STAGGER_STEP_MS = 90;
16
+
17
+ export const SF_REVEAL_STAGGER_MAX_MS = 450;
18
+
19
+ /** Reveals matching or containing this content always start visible. */
20
+ export const SF_MOTION_PROTECTED_CONTENT_SELECTOR = [
21
+ ".flowpress-hero",
22
+ 'img[fetchpriority="high"]',
23
+ 'img[loading="eager"]',
24
+ "video[autoplay]",
25
+ "form",
26
+ "[aria-live]",
27
+ '[role="alert"]',
28
+ '[role="status"]',
29
+ ].join(",");
30
+
31
+ const SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\S+$/;
32
+
33
+ export type SfRevealModifier = `sf-reveal--${string}`;
34
+
35
+ export type SfDefaultReveal = false | SfRevealModifier;
36
+
37
+ export interface SfRevealRule {
38
+ /** Any selector accepted by `document.querySelectorAll`. */
39
+ selector: string;
40
+ /** Reveal modifier enforced on every matching element. */
41
+ reveal: SfRevealModifier;
42
+ }
43
+
44
+ export interface SfRevealClassChanges {
45
+ add: string[];
46
+ remove: SfRevealModifier[];
47
+ }
48
+
49
+ export interface SfMotionOptions {
50
+ /**
51
+ * Allows reveal elements already in the initial viewport to animate.
52
+ * Defaults to `false`, so initial content is immediately available.
53
+ */
54
+ revealAboveFold?: boolean;
55
+ /**
56
+ * Ordered selector-specific reveal rules. The first matching rule wins and
57
+ * enforces its modifier. Any valid CSS selector may be used.
58
+ */
59
+ revealRules?: readonly SfRevealRule[];
60
+ /**
61
+ * Preset applied to automatically selected elements. `false` keeps the
62
+ * reveal system strictly opt-in.
63
+ */
64
+ defaultReveal?: SfDefaultReveal;
65
+ /**
66
+ * Standard CSS selectors. Tags, classes, IDs, attributes and combinations
67
+ * can be mixed in the same array.
68
+ */
69
+ autoRevealSelectors?: readonly string[];
70
+ }
71
+
72
+ export interface ResolvedSfMotionOptions {
73
+ autoRevealSelectors: string[];
74
+ defaultReveal: SfDefaultReveal;
75
+ revealAboveFold: boolean;
76
+ revealRules: SfRevealRule[];
77
+ }
78
+
79
+ export type SfRevealState = "pending" | "visible" | "settled";
80
+
81
+ export interface InitialRevealStateInput {
82
+ bottom: number;
83
+ containsHashTarget: boolean;
84
+ protectedContent: boolean;
85
+ reducedMotion: boolean;
86
+ revealAboveFold: boolean;
87
+ top: number;
88
+ viewportHeight: number;
89
+ }
90
+
91
+ export interface RevealVisibilityInput {
92
+ bottom: number;
93
+ height: number;
94
+ top: number;
95
+ viewportHeight: number;
96
+ }
97
+
98
+ export function isSfRevealModifier(value: unknown): value is SfRevealModifier {
99
+ return typeof value === "string" && SF_REVEAL_MODIFIER_PATTERN.test(value);
100
+ }
101
+
102
+ function normalizeSelectors(value: unknown): string[] {
103
+ if (!Array.isArray(value)) return [];
104
+
105
+ return Array.from(
106
+ new Set(
107
+ value
108
+ .filter((selector): selector is string => typeof selector === "string")
109
+ .map((selector) => selector.trim())
110
+ .filter(Boolean),
111
+ ),
112
+ );
113
+ }
114
+
115
+ function normalizeRevealRules(value: unknown): SfRevealRule[] {
116
+ if (!Array.isArray(value)) return [];
117
+
118
+ const seenSelectors = new Set<string>();
119
+ return value.flatMap((rule: unknown) => {
120
+ if (!rule || typeof rule !== "object") return [];
121
+
122
+ const candidate = rule as Partial<SfRevealRule>;
123
+ const selector =
124
+ typeof candidate.selector === "string" ? candidate.selector.trim() : "";
125
+ if (
126
+ !selector ||
127
+ seenSelectors.has(selector) ||
128
+ !isSfRevealModifier(candidate.reveal)
129
+ ) {
130
+ return [];
131
+ }
132
+
133
+ seenSelectors.add(selector);
134
+ return [{ selector, reveal: candidate.reveal }];
135
+ });
136
+ }
137
+
138
+ /**
139
+ * Normalizes server- or client-provided configuration. Invalid values fail
140
+ * open by disabling automatic reveals; empty and duplicate selectors are
141
+ * removed without changing their order.
142
+ */
143
+ export function resolveSfMotionOptions(
144
+ options: SfMotionOptions = {},
145
+ ): ResolvedSfMotionOptions {
146
+ const defaultReveal = isSfRevealModifier(options.defaultReveal)
147
+ ? options.defaultReveal
148
+ : false;
149
+ return {
150
+ autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),
151
+ defaultReveal,
152
+ revealAboveFold: options.revealAboveFold === true,
153
+ revealRules: normalizeRevealRules(options.revealRules),
154
+ };
155
+ }
156
+
157
+ /** Exact class mutation required by an authoritative selector rule. */
158
+ export function ruleRevealClassChanges(
159
+ existingClasses: Iterable<string>,
160
+ reveal: SfRevealModifier,
161
+ ): SfRevealClassChanges {
162
+ const classes = Array.from(existingClasses);
163
+ if (
164
+ classes.includes(SF_MOTION_STATIC_CLASS) ||
165
+ classes.includes(SF_MOTION_DISABLE_CLASS)
166
+ ) {
167
+ return { add: [], remove: [] };
168
+ }
169
+
170
+ return {
171
+ add: [
172
+ ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
173
+ ...(classes.includes(reveal) ? [] : [reveal]),
174
+ ],
175
+ remove: classes
176
+ .filter(isSfRevealModifier)
177
+ .filter((modifier) => modifier !== reveal),
178
+ };
179
+ }
180
+
181
+ /** Delay for a zero-based participant index in a reveal stagger group. */
182
+ export function staggerRevealDelayMs(index: number): number {
183
+ if (!Number.isFinite(index) || index <= 0) return 0;
184
+ return Math.min(
185
+ Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,
186
+ SF_REVEAL_STAGGER_MAX_MS,
187
+ );
188
+ }
189
+
190
+ /**
191
+ * Returns only the classes that automatic inheritance must add. Explicit
192
+ * modifiers win over the configured default and `sf-motion-static` remains a
193
+ * complete opt-out.
194
+ */
195
+ export function automaticRevealClasses(
196
+ existingClasses: Iterable<string>,
197
+ defaultReveal: SfDefaultReveal,
198
+ ): string[] {
199
+ if (defaultReveal === false) return [];
200
+
201
+ const classes = Array.from(existingClasses);
202
+ if (
203
+ classes.includes(SF_MOTION_STATIC_CLASS) ||
204
+ classes.includes(SF_MOTION_DISABLE_CLASS)
205
+ ) {
206
+ return [];
207
+ }
208
+
209
+ return [
210
+ ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
211
+ ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),
212
+ ];
213
+ }
214
+
215
+ function cssTimeToMs(value: string): number {
216
+ const normalized = value.trim();
217
+ const amount = Number.parseFloat(normalized);
218
+ if (!Number.isFinite(amount)) return 0;
219
+
220
+ return normalized.endsWith("ms") ? amount : amount * 1000;
221
+ }
222
+
223
+ /** Returns the longest combined CSS transition duration and delay. */
224
+ export function maximumTransitionTimeMs(
225
+ transitionDuration: string,
226
+ transitionDelay: string,
227
+ ): number {
228
+ const durations = transitionDuration.split(",").map(cssTimeToMs);
229
+ const delays = transitionDelay.split(",").map(cssTimeToMs);
230
+ const itemCount = Math.max(durations.length, delays.length);
231
+
232
+ return Array.from({ length: itemCount }, (_, index) => {
233
+ const duration = durations[index % durations.length] ?? 0;
234
+ const delay = delays[index % delays.length] ?? 0;
235
+ return Math.max(0, duration + delay);
236
+ }).reduce((maximum, value) => Math.max(maximum, value), 0);
237
+ }
238
+
239
+ /**
240
+ * Initial viewport content stays static unless the project explicitly enables
241
+ * above-the-fold reveals. Deep links and protected content remain visible.
242
+ */
243
+ export function initialRevealState({
244
+ bottom,
245
+ containsHashTarget,
246
+ protectedContent,
247
+ reducedMotion,
248
+ revealAboveFold,
249
+ top,
250
+ viewportHeight,
251
+ }: InitialRevealStateInput): SfRevealState {
252
+ if (
253
+ reducedMotion ||
254
+ containsHashTarget ||
255
+ protectedContent
256
+ ) {
257
+ return "visible";
258
+ }
259
+
260
+ // reveal share of its height) waits for the scroll instead of appearing
261
+ // statically; content already scrolled past the top stays visible.
262
+ if (
263
+ !revealAboveFold &&
264
+ bottom > 0 &&
265
+ top < viewportHeight &&
266
+ (top < 0 ||
267
+ hasEnoughVisibleArea({
268
+ bottom,
269
+ height: Math.max(0, bottom - top),
270
+ top,
271
+ viewportHeight,
272
+ }))
273
+ ) {
274
+ return "visible";
275
+ }
276
+
277
+ return "pending";
278
+ }
279
+
280
+ /**
281
+ * Reveal ordinary content once 20% of its perceivable height is visible.
282
+ * For elements taller than the viewport, the viewport height is the reference.
283
+ */
284
+ export function hasEnoughVisibleArea({
285
+ bottom,
286
+ height,
287
+ top,
288
+ viewportHeight,
289
+ }: RevealVisibilityInput): boolean {
290
+ if (height <= 0 || viewportHeight <= 0) return true;
291
+
292
+ const visibleHeight = Math.max(
293
+ 0,
294
+ Math.min(bottom, viewportHeight) - Math.max(top, 0),
295
+ );
296
+ // The 1px tolerance below must not let thin elements such as a 1px <hr>
297
+ // pass while they are still entirely outside the viewport.
298
+ if (visibleHeight <= 0) return false;
299
+
300
+ const requiredHeight =
301
+ Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;
302
+
303
+ return visibleHeight + 1 >= requiredHeight;
304
+ }
305
+
306
+ /**
307
+ * Reveal is deliberately one-way: focus and viewport entry can complete it,
308
+ * while leaving the viewport never conceals content again.
309
+ */
310
+ export function nextRevealState(
311
+ current: SfRevealState,
312
+ event: "focus" | "intersect" | "leave",
313
+ ): SfRevealState {
314
+ if (current === "settled") return "settled";
315
+
316
+ if (current === "visible" || event === "focus" || event === "intersect") {
317
+ return "visible";
318
+ }
319
+
320
+ return "pending";
321
+ }
322
+
323
+ export function shouldInitializeMotion(
324
+ initialized: string | undefined,
325
+ ): boolean {
326
+ return initialized !== "true";
327
+ }
328
+
329
+ /** `<html data-sf-motion>` value from the head bootstrap until the controller arms. */
330
+ export const SF_MOTION_BOOT_STATE = "boot";
331
+
332
+ /** Failsafe: boot-hidden content shows anyway if the controller never arms. */
333
+ export const SF_MOTION_BOOT_FAILSAFE_MS = 3000;
334
+
335
+ /**
336
+ * Modifiers whose pending state keeps the element visible and hides only a
337
+ * drawn decoration, mapped to the pseudo-element carrying it.
338
+ */
339
+ export const SF_REVEAL_DECORATION_PSEUDOS: Readonly<
340
+ Record<SfRevealModifier, "::before" | "::after">
341
+ > = {
342
+ "sf-reveal--accordion-line": "::after",
343
+ };
344
+
345
+ // Everything the controller leaves visible: opt-outs, protected content and the hash target.
346
+ // :has() makes :not() invalid where unsupported, which drops the rule: content stays visible.
347
+ const SF_MOTION_BOOT_EXCLUDED = [
348
+ `.${SF_MOTION_STATIC_CLASS}`,
349
+ `.${SF_MOTION_DISABLE_CLASS}`,
350
+ `.${SF_MOTION_DISABLE_CLASS} *`,
351
+ SF_MOTION_PROTECTED_CONTENT_SELECTOR,
352
+ `:has(${SF_MOTION_PROTECTED_CONTENT_SELECTOR})`,
353
+ ":target",
354
+ ":has(:target)",
355
+ ].join(", ");
356
+
357
+ /**
358
+ * Inline `<head>` script, placed after the motion preference bootstrap: marks
359
+ * the document as booting when the controller will arm reveals, so the CSS of
360
+ * `motionBootCss` hides them before first paint.
361
+ */
362
+ export function motionBootScript(preferenceAttribute: string): string {
363
+ const attribute = JSON.stringify(preferenceAttribute);
364
+ const state = JSON.stringify(SF_MOTION_BOOT_STATE);
365
+ return `(()=>{const r=document.documentElement;if(r.getAttribute(${attribute})==="full"&&"IntersectionObserver"in window&&!r.dataset.sfMotion)r.dataset.sfMotion=${state}})()`;
366
+ }
367
+
368
+ /**
369
+ * Pre-paint counterpart of the controller for `revealAboveFold`: hides what the
370
+ * controller will arm (authored reveals, rule and automatic selectors) while
371
+ * `<html data-sf-motion="boot">`, so content is never painted, hidden, then
372
+ * revealed. Each selector gets its own rule: an invalid one only drops itself.
373
+ * Like the controller, the first matching rule decides the modifier.
374
+ * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md
375
+ */
376
+ export function motionBootCss(options: SfMotionOptions = {}): string {
377
+ const { autoRevealSelectors, defaultReveal, revealAboveFold, revealRules } =
378
+ resolveSfMotionOptions(options);
379
+ if (!revealAboveFold) return "";
380
+
381
+ const root = `html[data-sf-motion="${SF_MOTION_BOOT_STATE}"]`;
382
+ const failsafe = `${SF_MOTION_BOOT_FAILSAFE_MS}ms`;
383
+ const decorations = Object.entries(SF_REVEAL_DECORATION_PSEUDOS) as [
384
+ SfRevealModifier,
385
+ string,
386
+ ][];
387
+ const hide = (target: string, reveal: SfRevealModifier | null): string => {
388
+ const pseudo = reveal ? (SF_REVEAL_DECORATION_PSEUDOS[reveal] ?? "") : "";
389
+ return `${root} ${target}${pseudo}{opacity:0;animation:sf-motion-boot-failsafe 0s linear ${failsafe} forwards}`;
390
+ };
391
+ const rules: string[] = [];
392
+
393
+ // Authored reveals keep their own modifier; decorations hide their pseudo.
394
+ const decorationClasses = decorations.map(([modifier]) => `.${modifier}`);
395
+ rules.push(hide(
396
+ `.${SF_REVEAL_CLASS}:not(${[SF_MOTION_BOOT_EXCLUDED, ...decorationClasses].join(", ")})`,
397
+ null,
398
+ ));
399
+ decorations.forEach(([modifier]) => {
400
+ rules.push(hide(`.${SF_REVEAL_CLASS}.${modifier}:not(${SF_MOTION_BOOT_EXCLUDED})`, modifier));
401
+ });
402
+
403
+ const earlier: string[] = [];
404
+ revealRules.forEach(({ selector, reveal }) => {
405
+ const shadowed = earlier.length ? `, :is(${earlier.join(", ")})` : "";
406
+ rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, reveal));
407
+ earlier.push(selector);
408
+ });
409
+
410
+ if (defaultReveal !== false) {
411
+ const shadowed = earlier.length ? `, :is(${earlier.join(", ")})` : "";
412
+ autoRevealSelectors.forEach((selector) => {
413
+ rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, defaultReveal));
414
+ });
415
+ }
416
+
417
+ rules.push("@keyframes sf-motion-boot-failsafe{to{opacity:1}}");
418
+ return rules.join("\n");
419
+ }
@@ -1,4 +1,5 @@
1
1
  ---
2
+ import Media from "../Media.astro";
2
3
  import { decodeFlowpressText } from "../../text.js";
3
4
  import StyleflowElement from "../StyleflowElement.astro";
4
5
  import type { FlowpressBlockRendererProps } from "../../index.js";
@@ -48,7 +49,7 @@ const list = as === "list" && Array.isArray(resolved.value) ? resolved.value.map
48
49
  : as === "image" ? (
49
50
  imageProps.src ? (
50
51
  <StyleflowElement as="figure" {...rootProps} {...styleflowProps} data-aspect-ratio={aspectRatio || undefined}>
51
- {resolved.href ? <StyleflowElement as="a" href={resolved.href}><StyleflowElement as="img" {...imageProps} /></StyleflowElement> : <StyleflowElement as="img" {...imageProps} />}
52
+ {resolved.href ? <StyleflowElement as="a" href={resolved.href}><Media {...imageProps} /></StyleflowElement> : <Media {...imageProps} />}
52
53
  </StyleflowElement>
53
54
  ) : null
54
55
  )
@@ -0,0 +1,107 @@
1
+ ---
2
+ import S from "../StyleflowElement.astro";
3
+ import type { FlowpressBlockRendererProps } from "../../index.js";
4
+ const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
5
+ const data = (block.resolvedData ?? {}) as { authenticated?: boolean; loginPage?: boolean; page?: number; totalPages?: number; base?: string; target?: string; targets?: { slug: string; name: string }[] };
6
+ const page = data.page ?? 1;
7
+ const total = data.totalPages ?? 0;
8
+ const base = (data.base ?? "/area-riservata/").replace(/page\/\d+\/$/, "");
9
+ const pageUrl = (n: number) => `${base}${n > 1 ? `page/${n}/` : ""}${data.target ? `?target=${encodeURIComponent(data.target)}` : ""}`;
10
+ ---
11
+ <S as="div" {...htmlProps} {...styleflowProps}>
12
+ {block.name === "flowpress/reserved-pagination" ? (
13
+ total > 1 && <S as="nav" aria-label="Pagine contenuti riservati">
14
+ {page > 1 && <S as="a" href={pageUrl(page - 1)}>Precedente</S>}
15
+ <S as="span">Pagina {page} di {total}</S>
16
+ {page < total && <S as="a" href={pageUrl(page + 1)}>Successiva</S>}
17
+ </S>
18
+ ) : data.authenticated ? (
19
+ <S as="div" class="flowpress-login flowpress-login--session">
20
+ <S as="p" class="flowpress-login__status" role="status">Accesso effettuato.</S>
21
+ <S as="div" class="flowpress-login__actions">
22
+ <S as="a" class="flowpress-login__link" href="/area-riservata/">Contenuti riservati</S>
23
+ <S as="form" method="post" action="/api/flowpress/reserved-area/logout"><S as="button" class="flowpress-login__button flowpress-login__button--secondary" type="submit">Esci</S></S>
24
+ </S>
25
+ {data.targets?.length ? <S as="form" class="flowpress-login__filter" method="get" action="/area-riservata/">
26
+ <S as="div" class="flowpress-login__field">
27
+ <S as="label" class="flowpress-login__label" for="flowpress-target">Filtra per destinatario</S>
28
+ <S as="select" class="flowpress-login__input" id="flowpress-target" name="target">
29
+ <S as="option" value="">Tutti i destinatari</S>
30
+ {data.targets.map(target => <S as="option" value={target.slug} selected={data.target === target.slug}>{target.name}</S>)}
31
+ </S>
32
+ </S>
33
+ <S as="button" class="flowpress-login__button" type="submit">Filtra</S>
34
+ </S> : null}
35
+ </S>
36
+ ) : data.loginPage ? (
37
+ <S as="form" class="flowpress-login" method="post" action="/api/flowpress/reserved-area/login" data-flowpress-login>
38
+ <S as="p" class="flowpress-login__error" data-flowpress-error id="flowpress-login-error" role="alert" hidden />
39
+ <S as="input" type="hidden" name="redirect_to" value="/area-riservata/" />
40
+ <S as="div" class="flowpress-login__field">
41
+ <S as="label" class="flowpress-login__label" for="flowpress-username">Nome utente o email</S>
42
+ <S as="input" class="flowpress-login__input" id="flowpress-username" name="username" type="text" autocomplete="username" autocapitalize="none" autocorrect="off" spellcheck="false" required />
43
+ </S>
44
+ <S as="div" class="flowpress-login__field">
45
+ <S as="label" class="flowpress-login__label" for="flowpress-password">Password</S>
46
+ <S as="div" class="flowpress-login__password">
47
+ <S as="input" class="flowpress-login__input" id="flowpress-password" name="password" type="password" autocomplete="current-password" required />
48
+ <S as="button" class="flowpress-login__toggle" type="button" data-flowpress-toggle aria-controls="flowpress-password" aria-pressed="false" aria-label="Mostra password" hidden>Mostra</S>
49
+ </S>
50
+ </S>
51
+ <S as="label" class="flowpress-login__remember"><S as="input" name="remember" type="checkbox" value="1" /> <S as="span">Ricordami su questo dispositivo</S></S>
52
+ <S as="button" class="flowpress-login__button" type="submit" data-flowpress-submit>Accedi</S>
53
+ <S as="a" class="flowpress-login__link" href="/area-riservata/">Vai ai contenuti riservati</S>
54
+ </S>
55
+ ) :
56
+ <S as="div" layoutRole="panel" class="flex flex-col" surface="default" density="comfortable">
57
+ <S as="h2" ty="heading" w="default" v="3">Area riservata</S>
58
+ <S as="a" href="/area-riservata/" layoutRole="control" density="comfortable" interactivePriority="primary" class="w-fit">Accesso area riservata</S>
59
+ </S>
60
+ }
61
+ </S>
62
+
63
+ <script>
64
+ import { safeFlowpressReservedRedirect } from "../../reserved-area.js";
65
+ const params = new URLSearchParams(window.location.search);
66
+ const errors: Record<string, string> = { credenziali: "Credenziali non valide. Controlla nome utente e password e riprova.", accesso: "Questo account non è abilitato all’area riservata.", servizio: "Servizio temporaneamente non disponibile. Riprova tra qualche minuto." };
67
+ for (const form of document.querySelectorAll<HTMLFormElement>("[data-flowpress-login]")) {
68
+ const redirect = form.elements.namedItem("redirect_to") as HTMLInputElement;
69
+ redirect.value = safeFlowpressReservedRedirect(params.get("redirect_to"));
70
+ const message = form.querySelector<HTMLElement>("[data-flowpress-error]");
71
+ const username = form.elements.namedItem("username") as HTMLInputElement;
72
+ const password = form.elements.namedItem("password") as HTMLInputElement;
73
+ const text = errors[params.get("errore") ?? ""];
74
+ if (message && text) {
75
+ message.textContent = text;
76
+ message.hidden = false;
77
+ if (params.get("errore") === "credenziali") {
78
+ for (const input of [username, password]) { input.setAttribute("aria-invalid", "true"); input.setAttribute("aria-describedby", message.id); }
79
+ }
80
+ username.focus();
81
+ }
82
+ const toggle = form.querySelector<HTMLButtonElement>("[data-flowpress-toggle]");
83
+ if (toggle) {
84
+ toggle.hidden = false;
85
+ toggle.addEventListener("click", () => {
86
+ const show = password.type === "password";
87
+ password.type = show ? "text" : "password";
88
+ toggle.textContent = show ? "Nascondi" : "Mostra";
89
+ toggle.setAttribute("aria-pressed", String(show));
90
+ toggle.setAttribute("aria-label", show ? "Nascondi password" : "Mostra password");
91
+ });
92
+ }
93
+ const submit = form.querySelector<HTMLButtonElement>("[data-flowpress-submit]");
94
+ let pending = false;
95
+ form.addEventListener("submit", event => {
96
+ if (pending) return event.preventDefault();
97
+ pending = true;
98
+ submit?.setAttribute("aria-disabled", "true");
99
+ if (submit) submit.textContent = "Accesso in corso…";
100
+ });
101
+ window.addEventListener("pageshow", () => {
102
+ pending = false;
103
+ submit?.removeAttribute("aria-disabled");
104
+ if (submit) submit.textContent = "Accedi";
105
+ });
106
+ }
107
+ </script>
@@ -75,6 +75,7 @@ const nestedComposition: FlowpressCompositionV1 | undefined = composition && ada
75
75
  parentBlockName={block.name}
76
76
  production={context.production}
77
77
  depth={context.depth + 1}
78
+ inheritedTone={context.effectiveTone}
78
79
  />
79
80
  ) : (
80
81
  <GutenbergRenderer
@@ -84,6 +85,7 @@ const nestedComposition: FlowpressCompositionV1 | undefined = composition && ada
84
85
  parentBlockName={block.name}
85
86
  production={context.production}
86
87
  depth={context.depth + 1}
88
+ inheritedTone={context.effectiveTone}
87
89
  />
88
90
  )
89
91
  ) : null}
@@ -77,6 +77,7 @@ const patternComposition: FlowpressCompositionV1 | undefined = composition && ad
77
77
  parentBlockName={block.name}
78
78
  production={context.production}
79
79
  depth={context.depth + 1}
80
+ inheritedTone={context.effectiveTone}
80
81
  />
81
82
  ) : (
82
83
  <GutenbergRenderer
@@ -86,6 +87,7 @@ const patternComposition: FlowpressCompositionV1 | undefined = composition && ad
86
87
  parentBlockName={block.name}
87
88
  production={context.production}
88
89
  depth={context.depth + 1}
90
+ inheritedTone={context.effectiveTone}
89
91
  />
90
92
  )
91
93
  ) : null}
@@ -1,4 +1,5 @@
1
1
  ---
2
+ import Media from "../Media.astro";
2
3
  import { decodeFlowpressText } from "../../text.js";
3
4
  import StyleflowElement from "../StyleflowElement.astro";
4
5
  import { classNames, text, type ResolvedImage } from "./query-loop.js";
@@ -30,7 +31,7 @@ const imageProps = {
30
31
  ---
31
32
 
32
33
  {as === "image" ? (
33
- imageProps.src ? <StyleflowElement as="img" {...imageProps} /> : null
34
+ imageProps.src ? <Media {...imageProps} /> : null
34
35
  ) : as === "date" ? (
35
36
  <StyleflowElement as="time" class="wp-block-post-terms__field" datetime={date.datetime}>{decodeFlowpressText(date.formatted)}</StyleflowElement>
36
37
  ) : (
@@ -1,4 +1,5 @@
1
1
  ---
2
+ import Media from "../Media.astro";
2
3
  import { decodeFlowpressText } from "../../text.js";
3
4
  import StyleflowElement from "../StyleflowElement.astro";
4
5
  import type { TimelineItem } from "./timeline.js";
@@ -11,7 +12,7 @@ const {items,tone="inherit",intensity="inherit",id,class:className="",ariaLabel=
11
12
  {items.map(item=>(
12
13
  <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
14
  {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.image && <Media 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
16
  {item.description && <StyleflowElement as="p">{decodeFlowpressText(item.description)}</StyleflowElement>}
16
17
  {item.metric && <StyleflowElement as="p">{decodeFlowpressText(item.metric)}</StyleflowElement>}
17
18
  {(item.statisticValue || item.statisticLabel) && <StyleflowElement as="p"><StyleflowElement as="strong">{decodeFlowpressText(item.statisticValue)}</StyleflowElement> {decodeFlowpressText(item.statisticLabel)}</StyleflowElement>}
@@ -47,7 +47,7 @@
47
47
  block-size: 100%;
48
48
  }
49
49
 
50
- .sf-blob[data-blob-fit="cover"] .sf-blob__shape :is(img, picture, video) {
50
+ .sf-blob[data-blob-fit="cover"] .sf-blob__shape :is(img, svg.flowpress-svg-media, picture, video) {
51
51
  display: block;
52
52
  inline-size: 100%;
53
53
  block-size: 100%;
@@ -0,0 +1,31 @@
1
+ import { type DynamicStyleflowProps, type FlowpressBlock, type StyleflowContract, type ResolveDynamicStyleflowOptions } from "../../index.js";
2
+ export interface ButtonTemplateDiagnostic {
3
+ code: string;
4
+ message: string;
5
+ blocking: boolean;
6
+ blockName?: string;
7
+ path?: string;
8
+ }
9
+ export interface ButtonTemplateData {
10
+ slug: string;
11
+ ref: number;
12
+ requested?: string | null;
13
+ blocks: FlowpressBlock[];
14
+ blockTypes?: unknown[];
15
+ stylesheets?: unknown[];
16
+ diagnostics?: ButtonTemplateDiagnostic[];
17
+ }
18
+ export interface ButtonTemplateControl {
19
+ /** Props of the focusable element (a, button or span). */
20
+ controlProps: Record<string, unknown>;
21
+ /** StyleFlow props of the template root, applied to the control. */
22
+ styleflowProps: DynamicStyleflowProps;
23
+ /** Blocks rendered inside the control. */
24
+ children: FlowpressBlock[];
25
+ }
26
+ export declare function buttonTemplateData(resolvedData: unknown): ButtonTemplateData | undefined;
27
+ export declare function buttonTemplateHasInteractiveBlocks(blocks: FlowpressBlock[]): boolean;
28
+ export declare function buttonTemplateControl(template: ButtonTemplateData, contract?: StyleflowContract, options?: ResolveDynamicStyleflowOptions): ButtonTemplateControl | undefined;
29
+ /** Diagnostic codes worth surfacing on the element outside production. */
30
+ export declare function buttonTemplateDiagnosticCodes(template: ButtonTemplateData | undefined, resolvedData: unknown): string;
31
+ //# sourceMappingURL=button-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-template.d.ts","sourceRoot":"","sources":["../../../src/astro/native/button-template.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACpC,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,oEAAoE;IACpE,cAAc,EAAE,qBAAqB,CAAC;IACtC,0CAA0C;IAC1C,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAID,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAOxF;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CASpF;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,OAAO,GAAE,8BAAmC,GAC3C,qBAAqB,GAAG,SAAS,CAcnC;AAED,0EAA0E;AAC1E,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAIrH"}