@styleflow.app/flowpress-astro-core 1.0.0-beta.15 → 1.0.0-beta.17
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.
- package/CHANGELOG.md +16 -0
- package/README.md +19 -1
- package/dist/astro/BaseLayout.astro +6 -6
- package/dist/astro/CompositionRenderer.astro +23 -7
- package/dist/astro/GutenbergRenderer.astro +33 -20
- package/dist/astro/blocks/CarouselBlock.astro +3 -3
- package/dist/astro/blocks/CarouselItemBlock.astro +1 -1
- package/dist/astro/blocks/ColumnBlock.astro +1 -1
- package/dist/astro/blocks/CoverBlock.astro +3 -3
- package/dist/astro/blocks/FormBlock.astro +13 -11
- package/dist/astro/blocks/GridBlock.astro +1 -1
- package/dist/astro/blocks/HeroBlock.astro +1 -1
- package/dist/astro/blocks/ImageBlock.astro +1 -1
- package/dist/astro/blocks/NumberSpinnerBlock.astro +1 -1
- package/dist/astro/blocks/SemanticElement.astro +2 -2
- package/dist/astro/blocks/SiteLogoBlock.astro +4 -4
- package/dist/astro/blocks/TextBlock.astro +2 -2
- package/dist/astro/blocks/cover.d.ts +2 -1
- package/dist/astro/blocks/cover.d.ts.map +1 -1
- package/dist/astro/blocks/cover.js.map +1 -1
- package/dist/astro/blocks/cover.ts +3 -2
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +86 -0
- package/dist/astro/native/LevelTag.astro +20 -0
- package/dist/astro/native/MapBlock.astro +41 -0
- package/dist/astro/native/NativeHtmlBlock.astro +12 -0
- package/dist/astro/native/NativeIconBlock.astro +33 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ResolvedBlocks.astro +89 -0
- package/dist/astro/native/SyncedPatternContent.astro +92 -0
- package/dist/astro/native/TermFieldValue.astro +37 -0
- package/dist/astro/native/Timeline.astro +20 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button.astro +43 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +23 -0
- package/dist/astro/native/core-home-link.astro +11 -0
- package/dist/astro/native/core-html.astro +8 -0
- package/dist/astro/native/core-icon.astro +7 -0
- package/dist/astro/native/core-image.astro +124 -0
- package/dist/astro/native/core-navigation-link.astro +70 -0
- package/dist/astro/native/core-navigation-submenu.astro +32 -0
- package/dist/astro/native/core-navigation.astro +94 -0
- package/dist/astro/native/core-page-list-data-item.astro +18 -0
- package/dist/astro/native/core-page-list-item.astro +7 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +20 -0
- package/dist/astro/native/core-post-excerpt.astro +25 -0
- package/dist/astro/native/core-post-featured-image.astro +37 -0
- package/dist/astro/native/core-post-template.astro +30 -0
- package/dist/astro/native/core-post-terms.astro +46 -0
- package/dist/astro/native/core-post-title.astro +23 -0
- package/dist/astro/native/core-query-no-results.astro +12 -0
- package/dist/astro/native/core-query.astro +22 -0
- package/dist/astro/native/core-site-title.astro +15 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +20 -0
- package/dist/astro/native/core-term-template.astro +30 -0
- package/dist/astro/native/core-terms-query.astro +19 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.js +217 -0
- package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
- package/dist/astro/native/flowpress-navigation.css +17 -0
- package/dist/astro/native/grid-bleed.js +106 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +72 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +72 -0
- package/dist/astro/native/sf-block-binding.astro +20 -0
- package/dist/astro/native/sf-post-field.astro +9 -0
- package/dist/astro/native/sf-term-field.astro +9 -0
- package/dist/astro/native/timeline.css +4 -0
- package/dist/astro/native/timeline.d.ts +28 -0
- package/dist/astro/native/timeline.d.ts.map +1 -0
- package/dist/astro/native/timeline.js +43 -0
- package/dist/astro/native/timeline.js.map +1 -0
- package/dist/astro/native/timeline.ts +79 -0
- package/dist/block-renderers.d.ts +3 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/default-blocks.d.ts +1 -1
- package/dist/default-blocks.d.ts.map +1 -1
- package/dist/default-blocks.js +36 -2
- package/dist/default-blocks.js.map +1 -1
- package/dist/media.d.ts +13 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +72 -12
- package/dist/media.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../../src/astro/native/motion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAE/D,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAI5C,MAAM,MAAM,gBAAgB,GAAG,cAAc,MAAM,EAAE,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,gBAAgB,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;I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AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,GAAG,EACH,cAAc,GACf,EAAE,uBAAuB,GAAG,aAAa,CA4BzC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,GAAG,EACH,cAAc,GACf,EAAE,qBAAqB,GAAG,OAAO,CAWjC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,GACrC,aAAa,CAQf;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAET"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export const SF_REVEAL_SELECTOR = ".sf-reveal:not(.sf-motion-static)";
|
|
2
|
+
export const SF_REVEAL_CLASS = "sf-reveal";
|
|
3
|
+
export const SF_MOTION_STATIC_CLASS = "sf-motion-static";
|
|
4
|
+
export const SF_MOTION_DISABLE_CLASS = "sf-motion-disable";
|
|
5
|
+
export const SF_MOTION_DRAWER_EXIT_MS = 820;
|
|
6
|
+
export const SF_REVEAL_VISIBLE_RATIO = 0.2;
|
|
7
|
+
export const SF_REVEAL_STAGGER_SELECTOR = ".sf-reveal-stagger";
|
|
8
|
+
export const SF_REVEAL_STAGGER_STEP_MS = 90;
|
|
9
|
+
export const SF_REVEAL_STAGGER_MAX_MS = 450;
|
|
10
|
+
const SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\S+$/;
|
|
11
|
+
export function isSfRevealModifier(value) {
|
|
12
|
+
return typeof value === "string" && SF_REVEAL_MODIFIER_PATTERN.test(value);
|
|
13
|
+
}
|
|
14
|
+
function normalizeSelectors(value) {
|
|
15
|
+
if (!Array.isArray(value))
|
|
16
|
+
return [];
|
|
17
|
+
return Array.from(new Set(value
|
|
18
|
+
.filter((selector) => typeof selector === "string")
|
|
19
|
+
.map((selector) => selector.trim())
|
|
20
|
+
.filter(Boolean)));
|
|
21
|
+
}
|
|
22
|
+
function normalizeRevealRules(value) {
|
|
23
|
+
if (!Array.isArray(value))
|
|
24
|
+
return [];
|
|
25
|
+
const seenSelectors = new Set();
|
|
26
|
+
return value.flatMap((rule) => {
|
|
27
|
+
if (!rule || typeof rule !== "object")
|
|
28
|
+
return [];
|
|
29
|
+
const candidate = rule;
|
|
30
|
+
const selector = typeof candidate.selector === "string" ? candidate.selector.trim() : "";
|
|
31
|
+
if (!selector ||
|
|
32
|
+
seenSelectors.has(selector) ||
|
|
33
|
+
!isSfRevealModifier(candidate.reveal)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
seenSelectors.add(selector);
|
|
37
|
+
return [{ selector, reveal: candidate.reveal }];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes server- or client-provided configuration. Invalid values fail
|
|
42
|
+
* open by disabling automatic reveals; empty and duplicate selectors are
|
|
43
|
+
* removed without changing their order.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveSfMotionOptions(options = {}) {
|
|
46
|
+
const defaultReveal = isSfRevealModifier(options.defaultReveal)
|
|
47
|
+
? options.defaultReveal
|
|
48
|
+
: false;
|
|
49
|
+
return {
|
|
50
|
+
autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),
|
|
51
|
+
defaultReveal,
|
|
52
|
+
revealAboveFold: options.revealAboveFold === true,
|
|
53
|
+
revealRules: normalizeRevealRules(options.revealRules),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Exact class mutation required by an authoritative selector rule. */
|
|
57
|
+
export function ruleRevealClassChanges(existingClasses, reveal) {
|
|
58
|
+
const classes = Array.from(existingClasses);
|
|
59
|
+
if (classes.includes(SF_MOTION_STATIC_CLASS) ||
|
|
60
|
+
classes.includes(SF_MOTION_DISABLE_CLASS)) {
|
|
61
|
+
return { add: [], remove: [] };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
add: [
|
|
65
|
+
...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
|
|
66
|
+
...(classes.includes(reveal) ? [] : [reveal]),
|
|
67
|
+
],
|
|
68
|
+
remove: classes
|
|
69
|
+
.filter(isSfRevealModifier)
|
|
70
|
+
.filter((modifier) => modifier !== reveal),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Delay for a zero-based participant index in a reveal stagger group. */
|
|
74
|
+
export function staggerRevealDelayMs(index) {
|
|
75
|
+
if (!Number.isFinite(index) || index <= 0)
|
|
76
|
+
return 0;
|
|
77
|
+
return Math.min(Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS, SF_REVEAL_STAGGER_MAX_MS);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns only the classes that automatic inheritance must add. Explicit
|
|
81
|
+
* modifiers win over the configured default and `sf-motion-static` remains a
|
|
82
|
+
* complete opt-out.
|
|
83
|
+
*/
|
|
84
|
+
export function automaticRevealClasses(existingClasses, defaultReveal) {
|
|
85
|
+
if (defaultReveal === false)
|
|
86
|
+
return [];
|
|
87
|
+
const classes = Array.from(existingClasses);
|
|
88
|
+
if (classes.includes(SF_MOTION_STATIC_CLASS) ||
|
|
89
|
+
classes.includes(SF_MOTION_DISABLE_CLASS)) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
return [
|
|
93
|
+
...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
|
|
94
|
+
...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
function cssTimeToMs(value) {
|
|
98
|
+
const normalized = value.trim();
|
|
99
|
+
const amount = Number.parseFloat(normalized);
|
|
100
|
+
if (!Number.isFinite(amount))
|
|
101
|
+
return 0;
|
|
102
|
+
return normalized.endsWith("ms") ? amount : amount * 1000;
|
|
103
|
+
}
|
|
104
|
+
/** Returns the longest combined CSS transition duration and delay. */
|
|
105
|
+
export function maximumTransitionTimeMs(transitionDuration, transitionDelay) {
|
|
106
|
+
const durations = transitionDuration.split(",").map(cssTimeToMs);
|
|
107
|
+
const delays = transitionDelay.split(",").map(cssTimeToMs);
|
|
108
|
+
const itemCount = Math.max(durations.length, delays.length);
|
|
109
|
+
return Array.from({ length: itemCount }, (_, index) => {
|
|
110
|
+
const duration = durations[index % durations.length] ?? 0;
|
|
111
|
+
const delay = delays[index % delays.length] ?? 0;
|
|
112
|
+
return Math.max(0, duration + delay);
|
|
113
|
+
}).reduce((maximum, value) => Math.max(maximum, value), 0);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Initial viewport content stays static unless the project explicitly enables
|
|
117
|
+
* above-the-fold reveals. Deep links and protected content remain visible.
|
|
118
|
+
*/
|
|
119
|
+
export function initialRevealState({ bottom, containsHashTarget, protectedContent, reducedMotion, revealAboveFold, top, viewportHeight, }) {
|
|
120
|
+
if (reducedMotion ||
|
|
121
|
+
containsHashTarget ||
|
|
122
|
+
protectedContent) {
|
|
123
|
+
return "visible";
|
|
124
|
+
}
|
|
125
|
+
// DMO: content that only peeks into the initial viewport (less than the
|
|
126
|
+
// reveal share of its height) waits for the scroll instead of appearing
|
|
127
|
+
// statically; content already scrolled past the top stays visible.
|
|
128
|
+
if (!revealAboveFold &&
|
|
129
|
+
bottom > 0 &&
|
|
130
|
+
top < viewportHeight &&
|
|
131
|
+
(top < 0 ||
|
|
132
|
+
hasEnoughVisibleArea({
|
|
133
|
+
bottom,
|
|
134
|
+
height: Math.max(0, bottom - top),
|
|
135
|
+
top,
|
|
136
|
+
viewportHeight,
|
|
137
|
+
}))) {
|
|
138
|
+
return "visible";
|
|
139
|
+
}
|
|
140
|
+
return "pending";
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Reveal ordinary content once 20% of its perceivable height is visible.
|
|
144
|
+
* For elements taller than the viewport, the viewport height is the reference.
|
|
145
|
+
*/
|
|
146
|
+
export function hasEnoughVisibleArea({ bottom, height, top, viewportHeight, }) {
|
|
147
|
+
if (height <= 0 || viewportHeight <= 0)
|
|
148
|
+
return true;
|
|
149
|
+
const visibleHeight = Math.max(0, Math.min(bottom, viewportHeight) - Math.max(top, 0));
|
|
150
|
+
const requiredHeight = Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;
|
|
151
|
+
return visibleHeight + 1 >= requiredHeight;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Reveal is deliberately one-way: focus and viewport entry can complete it,
|
|
155
|
+
* while leaving the viewport never conceals content again.
|
|
156
|
+
*/
|
|
157
|
+
export function nextRevealState(current, event) {
|
|
158
|
+
if (current === "settled")
|
|
159
|
+
return "settled";
|
|
160
|
+
if (current === "visible" || event === "focus" || event === "intersect") {
|
|
161
|
+
return "visible";
|
|
162
|
+
}
|
|
163
|
+
return "pending";
|
|
164
|
+
}
|
|
165
|
+
export function shouldInitializeMotion(initialized) {
|
|
166
|
+
return initialized !== "true";
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../../src/astro/native/motion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE/D,MAAM,CAAC,MAAM,yBAAyB,GA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CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,WAA+B;IAE/B,OAAO,WAAW,KAAK,MAAM,CAAC;AAChC,CAAC","sourcesContent":["export const SF_REVEAL_SELECTOR = \".sf-reveal:not(.sf-motion-static)\";\n\nexport const SF_REVEAL_CLASS = \"sf-reveal\";\n\nexport const SF_MOTION_STATIC_CLASS = \"sf-motion-static\";\n\nexport const SF_MOTION_DISABLE_CLASS = \"sf-motion-disable\";\n\nexport const SF_MOTION_DRAWER_EXIT_MS = 820;\n\nexport const SF_REVEAL_VISIBLE_RATIO = 0.2;\n\nexport const SF_REVEAL_STAGGER_SELECTOR = \".sf-reveal-stagger\";\n\nexport const SF_REVEAL_STAGGER_STEP_MS = 90;\n\nexport const SF_REVEAL_STAGGER_MAX_MS = 450;\n\nconst SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\\S+$/;\n\nexport type SfRevealModifier = `sf-reveal--${string}`;\n\nexport type SfDefaultReveal = false | SfRevealModifier;\n\nexport interface SfRevealRule {\n /** Any selector accepted by `document.querySelectorAll`. */\n selector: string;\n /** Reveal modifier enforced on every matching element. */\n reveal: SfRevealModifier;\n}\n\nexport interface SfRevealClassChanges {\n add: string[];\n remove: SfRevealModifier[];\n}\n\nexport interface SfMotionOptions {\n /**\n * Allows reveal elements already in the initial viewport to animate.\n * Defaults to `false`, so initial content is immediately available.\n */\n revealAboveFold?: boolean;\n /**\n * Ordered selector-specific reveal rules. The first matching rule wins and\n * enforces its modifier. Any valid CSS selector may be used.\n */\n revealRules?: readonly SfRevealRule[];\n /**\n * Preset applied to automatically selected elements. `false` keeps the\n * reveal system strictly opt-in.\n */\n defaultReveal?: SfDefaultReveal;\n /**\n * Standard CSS selectors. Tags, classes, IDs, attributes and combinations\n * can be mixed in the same array.\n */\n autoRevealSelectors?: readonly string[];\n}\n\nexport interface ResolvedSfMotionOptions {\n autoRevealSelectors: string[];\n defaultReveal: SfDefaultReveal;\n revealAboveFold: boolean;\n revealRules: SfRevealRule[];\n}\n\nexport type SfRevealState = \"pending\" | \"visible\" | \"settled\";\n\nexport interface InitialRevealStateInput {\n bottom: number;\n containsHashTarget: boolean;\n protectedContent: boolean;\n reducedMotion: boolean;\n revealAboveFold: boolean;\n top: number;\n viewportHeight: number;\n}\n\nexport interface RevealVisibilityInput {\n bottom: number;\n height: number;\n top: number;\n viewportHeight: number;\n}\n\nexport function isSfRevealModifier(value: unknown): value is SfRevealModifier {\n return typeof value === \"string\" && SF_REVEAL_MODIFIER_PATTERN.test(value);\n}\n\nfunction normalizeSelectors(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n\n return Array.from(\n new Set(\n value\n .filter((selector): selector is string => typeof selector === \"string\")\n .map((selector) => selector.trim())\n .filter(Boolean),\n ),\n );\n}\n\nfunction normalizeRevealRules(value: unknown): SfRevealRule[] {\n if (!Array.isArray(value)) return [];\n\n const seenSelectors = new Set<string>();\n return value.flatMap((rule: unknown) => {\n if (!rule || typeof rule !== \"object\") return [];\n\n const candidate = rule as Partial<SfRevealRule>;\n const selector =\n typeof candidate.selector === \"string\" ? candidate.selector.trim() : \"\";\n if (\n !selector ||\n seenSelectors.has(selector) ||\n !isSfRevealModifier(candidate.reveal)\n ) {\n return [];\n }\n\n seenSelectors.add(selector);\n return [{ selector, reveal: candidate.reveal }];\n });\n}\n\n/**\n * Normalizes server- or client-provided configuration. Invalid values fail\n * open by disabling automatic reveals; empty and duplicate selectors are\n * removed without changing their order.\n */\nexport function resolveSfMotionOptions(\n options: SfMotionOptions = {},\n): ResolvedSfMotionOptions {\n const defaultReveal = isSfRevealModifier(options.defaultReveal)\n ? options.defaultReveal\n : false;\n return {\n autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),\n defaultReveal,\n revealAboveFold: options.revealAboveFold === true,\n revealRules: normalizeRevealRules(options.revealRules),\n };\n}\n\n/** Exact class mutation required by an authoritative selector rule. */\nexport function ruleRevealClassChanges(\n existingClasses: Iterable<string>,\n reveal: SfRevealModifier,\n): SfRevealClassChanges {\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return { add: [], remove: [] };\n }\n\n return {\n add: [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.includes(reveal) ? [] : [reveal]),\n ],\n remove: classes\n .filter(isSfRevealModifier)\n .filter((modifier) => modifier !== reveal),\n };\n}\n\n/** Delay for a zero-based participant index in a reveal stagger group. */\nexport function staggerRevealDelayMs(index: number): number {\n if (!Number.isFinite(index) || index <= 0) return 0;\n return Math.min(\n Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,\n SF_REVEAL_STAGGER_MAX_MS,\n );\n}\n\n/**\n * Returns only the classes that automatic inheritance must add. Explicit\n * modifiers win over the configured default and `sf-motion-static` remains a\n * complete opt-out.\n */\nexport function automaticRevealClasses(\n existingClasses: Iterable<string>,\n defaultReveal: SfDefaultReveal,\n): string[] {\n if (defaultReveal === false) return [];\n\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return [];\n }\n\n return [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),\n ];\n}\n\nfunction cssTimeToMs(value: string): number {\n const normalized = value.trim();\n const amount = Number.parseFloat(normalized);\n if (!Number.isFinite(amount)) return 0;\n\n return normalized.endsWith(\"ms\") ? amount : amount * 1000;\n}\n\n/** Returns the longest combined CSS transition duration and delay. */\nexport function maximumTransitionTimeMs(\n transitionDuration: string,\n transitionDelay: string,\n): number {\n const durations = transitionDuration.split(\",\").map(cssTimeToMs);\n const delays = transitionDelay.split(\",\").map(cssTimeToMs);\n const itemCount = Math.max(durations.length, delays.length);\n\n return Array.from({ length: itemCount }, (_, index) => {\n const duration = durations[index % durations.length] ?? 0;\n const delay = delays[index % delays.length] ?? 0;\n return Math.max(0, duration + delay);\n }).reduce((maximum, value) => Math.max(maximum, value), 0);\n}\n\n/**\n * Initial viewport content stays static unless the project explicitly enables\n * above-the-fold reveals. Deep links and protected content remain visible.\n */\nexport function initialRevealState({\n bottom,\n containsHashTarget,\n protectedContent,\n reducedMotion,\n revealAboveFold,\n top,\n viewportHeight,\n}: InitialRevealStateInput): SfRevealState {\n if (\n reducedMotion ||\n containsHashTarget ||\n protectedContent\n ) {\n return \"visible\";\n }\n\n // DMO: content that only peeks into the initial viewport (less than the\n // reveal share of its height) waits for the scroll instead of appearing\n // statically; content already scrolled past the top stays visible.\n if (\n !revealAboveFold &&\n bottom > 0 &&\n top < viewportHeight &&\n (top < 0 ||\n hasEnoughVisibleArea({\n bottom,\n height: Math.max(0, bottom - top),\n top,\n viewportHeight,\n }))\n ) {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\n/**\n * Reveal ordinary content once 20% of its perceivable height is visible.\n * For elements taller than the viewport, the viewport height is the reference.\n */\nexport function hasEnoughVisibleArea({\n bottom,\n height,\n top,\n viewportHeight,\n}: RevealVisibilityInput): boolean {\n if (height <= 0 || viewportHeight <= 0) return true;\n\n const visibleHeight = Math.max(\n 0,\n Math.min(bottom, viewportHeight) - Math.max(top, 0),\n );\n const requiredHeight =\n Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;\n\n return visibleHeight + 1 >= requiredHeight;\n}\n\n/**\n * Reveal is deliberately one-way: focus and viewport entry can complete it,\n * while leaving the viewport never conceals content again.\n */\nexport function nextRevealState(\n current: SfRevealState,\n event: \"focus\" | \"intersect\" | \"leave\",\n): SfRevealState {\n if (current === \"settled\") return \"settled\";\n\n if (current === \"visible\" || event === \"focus\" || event === \"intersect\") {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\nexport function shouldInitializeMotion(\n initialized: string | undefined,\n): boolean {\n return initialized !== \"true\";\n}\n"]}
|
|
@@ -0,0 +1,312 @@
|
|
|
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
|
+
const SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\S+$/;
|
|
20
|
+
|
|
21
|
+
export type SfRevealModifier = `sf-reveal--${string}`;
|
|
22
|
+
|
|
23
|
+
export type SfDefaultReveal = false | SfRevealModifier;
|
|
24
|
+
|
|
25
|
+
export interface SfRevealRule {
|
|
26
|
+
/** Any selector accepted by `document.querySelectorAll`. */
|
|
27
|
+
selector: string;
|
|
28
|
+
/** Reveal modifier enforced on every matching element. */
|
|
29
|
+
reveal: SfRevealModifier;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SfRevealClassChanges {
|
|
33
|
+
add: string[];
|
|
34
|
+
remove: SfRevealModifier[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SfMotionOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Allows reveal elements already in the initial viewport to animate.
|
|
40
|
+
* Defaults to `false`, so initial content is immediately available.
|
|
41
|
+
*/
|
|
42
|
+
revealAboveFold?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Ordered selector-specific reveal rules. The first matching rule wins and
|
|
45
|
+
* enforces its modifier. Any valid CSS selector may be used.
|
|
46
|
+
*/
|
|
47
|
+
revealRules?: readonly SfRevealRule[];
|
|
48
|
+
/**
|
|
49
|
+
* Preset applied to automatically selected elements. `false` keeps the
|
|
50
|
+
* reveal system strictly opt-in.
|
|
51
|
+
*/
|
|
52
|
+
defaultReveal?: SfDefaultReveal;
|
|
53
|
+
/**
|
|
54
|
+
* Standard CSS selectors. Tags, classes, IDs, attributes and combinations
|
|
55
|
+
* can be mixed in the same array.
|
|
56
|
+
*/
|
|
57
|
+
autoRevealSelectors?: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ResolvedSfMotionOptions {
|
|
61
|
+
autoRevealSelectors: string[];
|
|
62
|
+
defaultReveal: SfDefaultReveal;
|
|
63
|
+
revealAboveFold: boolean;
|
|
64
|
+
revealRules: SfRevealRule[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type SfRevealState = "pending" | "visible" | "settled";
|
|
68
|
+
|
|
69
|
+
export interface InitialRevealStateInput {
|
|
70
|
+
bottom: number;
|
|
71
|
+
containsHashTarget: boolean;
|
|
72
|
+
protectedContent: boolean;
|
|
73
|
+
reducedMotion: boolean;
|
|
74
|
+
revealAboveFold: boolean;
|
|
75
|
+
top: number;
|
|
76
|
+
viewportHeight: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface RevealVisibilityInput {
|
|
80
|
+
bottom: number;
|
|
81
|
+
height: number;
|
|
82
|
+
top: number;
|
|
83
|
+
viewportHeight: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isSfRevealModifier(value: unknown): value is SfRevealModifier {
|
|
87
|
+
return typeof value === "string" && SF_REVEAL_MODIFIER_PATTERN.test(value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function normalizeSelectors(value: unknown): string[] {
|
|
91
|
+
if (!Array.isArray(value)) return [];
|
|
92
|
+
|
|
93
|
+
return Array.from(
|
|
94
|
+
new Set(
|
|
95
|
+
value
|
|
96
|
+
.filter((selector): selector is string => typeof selector === "string")
|
|
97
|
+
.map((selector) => selector.trim())
|
|
98
|
+
.filter(Boolean),
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function normalizeRevealRules(value: unknown): SfRevealRule[] {
|
|
104
|
+
if (!Array.isArray(value)) return [];
|
|
105
|
+
|
|
106
|
+
const seenSelectors = new Set<string>();
|
|
107
|
+
return value.flatMap((rule: unknown) => {
|
|
108
|
+
if (!rule || typeof rule !== "object") return [];
|
|
109
|
+
|
|
110
|
+
const candidate = rule as Partial<SfRevealRule>;
|
|
111
|
+
const selector =
|
|
112
|
+
typeof candidate.selector === "string" ? candidate.selector.trim() : "";
|
|
113
|
+
if (
|
|
114
|
+
!selector ||
|
|
115
|
+
seenSelectors.has(selector) ||
|
|
116
|
+
!isSfRevealModifier(candidate.reveal)
|
|
117
|
+
) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
seenSelectors.add(selector);
|
|
122
|
+
return [{ selector, reveal: candidate.reveal }];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Normalizes server- or client-provided configuration. Invalid values fail
|
|
128
|
+
* open by disabling automatic reveals; empty and duplicate selectors are
|
|
129
|
+
* removed without changing their order.
|
|
130
|
+
*/
|
|
131
|
+
export function resolveSfMotionOptions(
|
|
132
|
+
options: SfMotionOptions = {},
|
|
133
|
+
): ResolvedSfMotionOptions {
|
|
134
|
+
const defaultReveal = isSfRevealModifier(options.defaultReveal)
|
|
135
|
+
? options.defaultReveal
|
|
136
|
+
: false;
|
|
137
|
+
return {
|
|
138
|
+
autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),
|
|
139
|
+
defaultReveal,
|
|
140
|
+
revealAboveFold: options.revealAboveFold === true,
|
|
141
|
+
revealRules: normalizeRevealRules(options.revealRules),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Exact class mutation required by an authoritative selector rule. */
|
|
146
|
+
export function ruleRevealClassChanges(
|
|
147
|
+
existingClasses: Iterable<string>,
|
|
148
|
+
reveal: SfRevealModifier,
|
|
149
|
+
): SfRevealClassChanges {
|
|
150
|
+
const classes = Array.from(existingClasses);
|
|
151
|
+
if (
|
|
152
|
+
classes.includes(SF_MOTION_STATIC_CLASS) ||
|
|
153
|
+
classes.includes(SF_MOTION_DISABLE_CLASS)
|
|
154
|
+
) {
|
|
155
|
+
return { add: [], remove: [] };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
add: [
|
|
160
|
+
...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
|
|
161
|
+
...(classes.includes(reveal) ? [] : [reveal]),
|
|
162
|
+
],
|
|
163
|
+
remove: classes
|
|
164
|
+
.filter(isSfRevealModifier)
|
|
165
|
+
.filter((modifier) => modifier !== reveal),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Delay for a zero-based participant index in a reveal stagger group. */
|
|
170
|
+
export function staggerRevealDelayMs(index: number): number {
|
|
171
|
+
if (!Number.isFinite(index) || index <= 0) return 0;
|
|
172
|
+
return Math.min(
|
|
173
|
+
Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,
|
|
174
|
+
SF_REVEAL_STAGGER_MAX_MS,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Returns only the classes that automatic inheritance must add. Explicit
|
|
180
|
+
* modifiers win over the configured default and `sf-motion-static` remains a
|
|
181
|
+
* complete opt-out.
|
|
182
|
+
*/
|
|
183
|
+
export function automaticRevealClasses(
|
|
184
|
+
existingClasses: Iterable<string>,
|
|
185
|
+
defaultReveal: SfDefaultReveal,
|
|
186
|
+
): string[] {
|
|
187
|
+
if (defaultReveal === false) return [];
|
|
188
|
+
|
|
189
|
+
const classes = Array.from(existingClasses);
|
|
190
|
+
if (
|
|
191
|
+
classes.includes(SF_MOTION_STATIC_CLASS) ||
|
|
192
|
+
classes.includes(SF_MOTION_DISABLE_CLASS)
|
|
193
|
+
) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return [
|
|
198
|
+
...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),
|
|
199
|
+
...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function cssTimeToMs(value: string): number {
|
|
204
|
+
const normalized = value.trim();
|
|
205
|
+
const amount = Number.parseFloat(normalized);
|
|
206
|
+
if (!Number.isFinite(amount)) return 0;
|
|
207
|
+
|
|
208
|
+
return normalized.endsWith("ms") ? amount : amount * 1000;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Returns the longest combined CSS transition duration and delay. */
|
|
212
|
+
export function maximumTransitionTimeMs(
|
|
213
|
+
transitionDuration: string,
|
|
214
|
+
transitionDelay: string,
|
|
215
|
+
): number {
|
|
216
|
+
const durations = transitionDuration.split(",").map(cssTimeToMs);
|
|
217
|
+
const delays = transitionDelay.split(",").map(cssTimeToMs);
|
|
218
|
+
const itemCount = Math.max(durations.length, delays.length);
|
|
219
|
+
|
|
220
|
+
return Array.from({ length: itemCount }, (_, index) => {
|
|
221
|
+
const duration = durations[index % durations.length] ?? 0;
|
|
222
|
+
const delay = delays[index % delays.length] ?? 0;
|
|
223
|
+
return Math.max(0, duration + delay);
|
|
224
|
+
}).reduce((maximum, value) => Math.max(maximum, value), 0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Initial viewport content stays static unless the project explicitly enables
|
|
229
|
+
* above-the-fold reveals. Deep links and protected content remain visible.
|
|
230
|
+
*/
|
|
231
|
+
export function initialRevealState({
|
|
232
|
+
bottom,
|
|
233
|
+
containsHashTarget,
|
|
234
|
+
protectedContent,
|
|
235
|
+
reducedMotion,
|
|
236
|
+
revealAboveFold,
|
|
237
|
+
top,
|
|
238
|
+
viewportHeight,
|
|
239
|
+
}: InitialRevealStateInput): SfRevealState {
|
|
240
|
+
if (
|
|
241
|
+
reducedMotion ||
|
|
242
|
+
containsHashTarget ||
|
|
243
|
+
protectedContent
|
|
244
|
+
) {
|
|
245
|
+
return "visible";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// DMO: content that only peeks into the initial viewport (less than the
|
|
249
|
+
// reveal share of its height) waits for the scroll instead of appearing
|
|
250
|
+
// statically; content already scrolled past the top stays visible.
|
|
251
|
+
if (
|
|
252
|
+
!revealAboveFold &&
|
|
253
|
+
bottom > 0 &&
|
|
254
|
+
top < viewportHeight &&
|
|
255
|
+
(top < 0 ||
|
|
256
|
+
hasEnoughVisibleArea({
|
|
257
|
+
bottom,
|
|
258
|
+
height: Math.max(0, bottom - top),
|
|
259
|
+
top,
|
|
260
|
+
viewportHeight,
|
|
261
|
+
}))
|
|
262
|
+
) {
|
|
263
|
+
return "visible";
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return "pending";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Reveal ordinary content once 20% of its perceivable height is visible.
|
|
271
|
+
* For elements taller than the viewport, the viewport height is the reference.
|
|
272
|
+
*/
|
|
273
|
+
export function hasEnoughVisibleArea({
|
|
274
|
+
bottom,
|
|
275
|
+
height,
|
|
276
|
+
top,
|
|
277
|
+
viewportHeight,
|
|
278
|
+
}: RevealVisibilityInput): boolean {
|
|
279
|
+
if (height <= 0 || viewportHeight <= 0) return true;
|
|
280
|
+
|
|
281
|
+
const visibleHeight = Math.max(
|
|
282
|
+
0,
|
|
283
|
+
Math.min(bottom, viewportHeight) - Math.max(top, 0),
|
|
284
|
+
);
|
|
285
|
+
const requiredHeight =
|
|
286
|
+
Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;
|
|
287
|
+
|
|
288
|
+
return visibleHeight + 1 >= requiredHeight;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Reveal is deliberately one-way: focus and viewport entry can complete it,
|
|
293
|
+
* while leaving the viewport never conceals content again.
|
|
294
|
+
*/
|
|
295
|
+
export function nextRevealState(
|
|
296
|
+
current: SfRevealState,
|
|
297
|
+
event: "focus" | "intersect" | "leave",
|
|
298
|
+
): SfRevealState {
|
|
299
|
+
if (current === "settled") return "settled";
|
|
300
|
+
|
|
301
|
+
if (current === "visible" || event === "focus" || event === "intersect") {
|
|
302
|
+
return "visible";
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return "pending";
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function shouldInitializeMotion(
|
|
309
|
+
initialized: string | undefined,
|
|
310
|
+
): boolean {
|
|
311
|
+
return initialized !== "true";
|
|
312
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FlowpressBlock, FlowpressBlockTypeDescriptor, FlowpressCompositionDiagnostic, FlowpressCompositionStylesheet } from "../../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* resolvedData shapes of the project Query Loop pilot
|
|
4
|
+
* (apps/cms/project/src/query-loop.php and custom-fields.php).
|
|
5
|
+
*/
|
|
6
|
+
export interface NestedPass {
|
|
7
|
+
blockTypes?: FlowpressBlockTypeDescriptor[];
|
|
8
|
+
stylesheets?: FlowpressCompositionStylesheet[];
|
|
9
|
+
diagnostics?: FlowpressCompositionDiagnostic[];
|
|
10
|
+
}
|
|
11
|
+
export interface LoopData extends NestedPass {
|
|
12
|
+
blocks?: FlowpressBlock[];
|
|
13
|
+
}
|
|
14
|
+
export interface LoopItem {
|
|
15
|
+
id: number;
|
|
16
|
+
postType?: string;
|
|
17
|
+
taxonomy?: string;
|
|
18
|
+
blocks: FlowpressBlock[];
|
|
19
|
+
}
|
|
20
|
+
export interface LoopTemplateData extends NestedPass {
|
|
21
|
+
items?: LoopItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface ResolvedImage {
|
|
24
|
+
id?: number;
|
|
25
|
+
url?: string;
|
|
26
|
+
alt?: string;
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
srcSet?: string;
|
|
30
|
+
sizes?: string;
|
|
31
|
+
sizeSlug?: string;
|
|
32
|
+
href?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function classNames(...values: unknown[]): string | undefined;
|
|
35
|
+
export declare function text(value: unknown): string;
|
|
36
|
+
export declare function headingLevel(value: unknown, fallback?: number): number;
|
|
37
|
+
export declare function externalRel(target: unknown, rel?: unknown): string | undefined;
|
|
38
|
+
//# sourceMappingURL=query-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-loop.d.ts","sourceRoot":"","sources":["../../../src/astro/native/query-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAC5C,WAAW,CAAC,EAAE,8BAA8B,EAAE,CAAC;IAC/C,WAAW,CAAC,EAAE,8BAA8B,EAAE,CAAC;CAChD;AAED,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,UAAU,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAOnE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAI,GAAG,MAAM,CAGjE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI9E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function classNames(...values) {
|
|
2
|
+
const className = [...new Set(values
|
|
3
|
+
.flatMap((value) => String(value ?? "").split(/\s+/))
|
|
4
|
+
.filter(Boolean))].join(" ");
|
|
5
|
+
return className || undefined;
|
|
6
|
+
}
|
|
7
|
+
export function text(value) {
|
|
8
|
+
return typeof value === "string" ? value : typeof value === "number" ? String(value) : "";
|
|
9
|
+
}
|
|
10
|
+
export function headingLevel(value, fallback = 2) {
|
|
11
|
+
const level = Number(value);
|
|
12
|
+
return Number.isInteger(level) && level >= 0 && level <= 6 ? level : fallback;
|
|
13
|
+
}
|
|
14
|
+
export function externalRel(target, rel) {
|
|
15
|
+
const tokens = text(rel).split(/\s+/).filter(Boolean);
|
|
16
|
+
if (target === "_blank")
|
|
17
|
+
tokens.push("noopener", "noreferrer");
|
|
18
|
+
return tokens.length > 0 ? [...new Set(tokens)].join(" ") : undefined;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=query-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-loop.js","sourceRoot":"","sources":["../../../src/astro/native/query-loop.ts"],"names":[],"mappings":"AA4CA,MAAM,UAAU,UAAU,CAAC,GAAG,MAAiB;IAC7C,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAC3B,MAAM;aACH,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACpD,MAAM,CAAC,OAAO,CAAC,CACnB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,SAAS,IAAI,SAAS,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,QAAQ,GAAG,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAe,EAAE,GAAa;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,MAAM,KAAK,QAAQ;QAAE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC","sourcesContent":["import type {\n FlowpressBlock,\n FlowpressBlockTypeDescriptor,\n FlowpressCompositionDiagnostic,\n FlowpressCompositionStylesheet,\n} from \"../../index.js\";\n\n/**\n * resolvedData shapes of the project Query Loop pilot\n * (apps/cms/project/src/query-loop.php and custom-fields.php).\n */\nexport interface NestedPass {\n blockTypes?: FlowpressBlockTypeDescriptor[];\n stylesheets?: FlowpressCompositionStylesheet[];\n diagnostics?: FlowpressCompositionDiagnostic[];\n}\n\nexport interface LoopData extends NestedPass {\n blocks?: FlowpressBlock[];\n}\n\nexport interface LoopItem {\n id: number;\n postType?: string;\n taxonomy?: string;\n blocks: FlowpressBlock[];\n}\n\nexport interface LoopTemplateData extends NestedPass {\n items?: LoopItem[];\n}\n\nexport interface ResolvedImage {\n id?: number;\n url?: string;\n alt?: string;\n width?: number;\n height?: number;\n srcSet?: string;\n sizes?: string;\n sizeSlug?: string;\n href?: string;\n}\n\nexport function classNames(...values: unknown[]): string | undefined {\n const className = [...new Set(\n values\n .flatMap((value) => String(value ?? \"\").split(/\\s+/))\n .filter(Boolean),\n )].join(\" \");\n return className || undefined;\n}\n\nexport function text(value: unknown): string {\n return typeof value === \"string\" ? value : typeof value === \"number\" ? String(value) : \"\";\n}\n\nexport function headingLevel(value: unknown, fallback = 2): number {\n const level = Number(value);\n return Number.isInteger(level) && level >= 0 && level <= 6 ? level : fallback;\n}\n\nexport function externalRel(target: unknown, rel?: unknown): string | undefined {\n const tokens = text(rel).split(/\\s+/).filter(Boolean);\n if (target === \"_blank\") tokens.push(\"noopener\", \"noreferrer\");\n return tokens.length > 0 ? [...new Set(tokens)].join(\" \") : undefined;\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FlowpressBlock,
|
|
3
|
+
FlowpressBlockTypeDescriptor,
|
|
4
|
+
FlowpressCompositionDiagnostic,
|
|
5
|
+
FlowpressCompositionStylesheet,
|
|
6
|
+
} from "../../index.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* resolvedData shapes of the project Query Loop pilot
|
|
10
|
+
* (apps/cms/project/src/query-loop.php and custom-fields.php).
|
|
11
|
+
*/
|
|
12
|
+
export interface NestedPass {
|
|
13
|
+
blockTypes?: FlowpressBlockTypeDescriptor[];
|
|
14
|
+
stylesheets?: FlowpressCompositionStylesheet[];
|
|
15
|
+
diagnostics?: FlowpressCompositionDiagnostic[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LoopData extends NestedPass {
|
|
19
|
+
blocks?: FlowpressBlock[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface LoopItem {
|
|
23
|
+
id: number;
|
|
24
|
+
postType?: string;
|
|
25
|
+
taxonomy?: string;
|
|
26
|
+
blocks: FlowpressBlock[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface LoopTemplateData extends NestedPass {
|
|
30
|
+
items?: LoopItem[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ResolvedImage {
|
|
34
|
+
id?: number;
|
|
35
|
+
url?: string;
|
|
36
|
+
alt?: string;
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
srcSet?: string;
|
|
40
|
+
sizes?: string;
|
|
41
|
+
sizeSlug?: string;
|
|
42
|
+
href?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function classNames(...values: unknown[]): string | undefined {
|
|
46
|
+
const className = [...new Set(
|
|
47
|
+
values
|
|
48
|
+
.flatMap((value) => String(value ?? "").split(/\s+/))
|
|
49
|
+
.filter(Boolean),
|
|
50
|
+
)].join(" ");
|
|
51
|
+
return className || undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function text(value: unknown): string {
|
|
55
|
+
return typeof value === "string" ? value : typeof value === "number" ? String(value) : "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function headingLevel(value: unknown, fallback = 2): number {
|
|
59
|
+
const level = Number(value);
|
|
60
|
+
return Number.isInteger(level) && level >= 0 && level <= 6 ? level : fallback;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function externalRel(target: unknown, rel?: unknown): string | undefined {
|
|
64
|
+
const tokens = text(rel).split(/\s+/).filter(Boolean);
|
|
65
|
+
if (target === "_blank") tokens.push("noopener", "noreferrer");
|
|
66
|
+
return tokens.length > 0 ? [...new Set(tokens)].join(" ") : undefined;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAkCxE,eAAO,MAAM,oBAAoB,EAAE,uBAqClC,CAAC"}
|