@styleflow.app/flowpress-astro-core 1.0.0-beta.46 → 1.0.0-beta.48
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 +14 -0
- package/dist/astro/CompositionRenderer.astro +6 -4
- package/dist/astro/GutenbergRenderer.astro +7 -5
- package/dist/astro/native/AccordionRuntime.astro +11 -0
- package/dist/astro/native/accordion-controller.d.ts +3 -0
- package/dist/astro/native/accordion-controller.d.ts.map +1 -0
- package/dist/astro/native/accordion-controller.js +132 -0
- package/dist/astro/native/accordion-controller.js.map +1 -0
- package/dist/astro/native/accordion-controller.ts +97 -0
- package/dist/astro/native/accordion.css +29 -0
- package/dist/astro/native/accordion.d.ts +23 -0
- package/dist/astro/native/accordion.d.ts.map +1 -0
- package/dist/astro/native/accordion.js +58 -0
- package/dist/astro/native/accordion.js.map +1 -0
- package/dist/astro/native/accordion.ts +70 -0
- package/dist/astro/native/core-accordion-heading.astro +21 -0
- package/dist/astro/native/core-accordion-item.astro +8 -0
- package/dist/astro/native/core-accordion-panel.astro +8 -0
- package/dist/astro/native/core-accordion.astro +8 -0
- package/dist/astro/native/grid.d.ts.map +1 -1
- package/dist/astro/native/grid.js +7 -2
- package/dist/astro/native/grid.js.map +1 -1
- package/dist/astro/native/grid.ts +16 -2
- package/dist/astro/native/registry.d.ts.map +1 -1
- package/dist/astro/native/registry.js +10 -0
- package/dist/astro/native/registry.js.map +1 -1
- package/dist/astro/native/registry.ts +11 -0
- package/dist/astro/native/sf-slot.astro +6 -0
- package/dist/default-blocks.d.ts +1 -1
- package/dist/default-blocks.d.ts.map +1 -1
- package/dist/default-blocks.js +6 -1
- package/dist/default-blocks.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.48 — 2026-11-17
|
|
4
|
+
|
|
5
|
+
- Aggiunge i quattro adapter ufficiali della famiglia `core/accordion`, catalogo default v8, props StyleFlow sul pulsante e icone configurabili risolte dal CMS.
|
|
6
|
+
- Runtime autonomo con scorrimento e rotazione da variabili CSS globali, tastiera, autoclose, hash, gruppi annidati, cleanup Astro e contenuti leggibili senza JavaScript. I renderer `sf/*` rimangono disponibili.
|
|
7
|
+
- [Rapporto canonico](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-11-17-accordion-nativo.md).
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.47 — 2026-11-16
|
|
10
|
+
|
|
11
|
+
- Add the official `sf/slot` adapter. WordPress materializes each instance's blocks as `innerBlocks`; Astro renders only those children, with no wrapper, HTML attributes or visual context from the slot.
|
|
12
|
+
- Preserve the rendered parent and inherited tone through nested slots. Responsive grids count and decorate the actual slot children, including empty and nested slots, so spans and edge bleed match the DOM.
|
|
13
|
+
- Verify empty and populated slots, inherited context, synced-pattern content and responsive grid children through both Gutenberg and Site Editor renderer builds.
|
|
14
|
+
- Depend on `@styleflow.app/flowpress-components` 1.0.0-beta.19 for the shared structural slot contract.
|
|
15
|
+
- [Canonical report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-11-16-slot-pattern-sincronizzati.md).
|
|
16
|
+
|
|
3
17
|
## 1.0.0-beta.46 — 2026-11-04
|
|
4
18
|
|
|
5
19
|
- Menu toggle of `core/navigation`: the two bars sit 0.5rem apart and the cross is centred on the button. `flowpress-navigation.css` placed the bars at 35%/65% with `inset-inline: 0` and won over the `motion.css` insets, while `motion.css` still applied its centred transforms, so every offset counted twice: bars 14px apart and 10px left of the icon, cross 10px above the button centre (seen on friviera.it).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import "./native/inline-text.css";
|
|
3
|
+
import { decorateAccordionBlocks, accordionRenderPrefix } from "./native/accordion.js";
|
|
3
4
|
import { registerFlowpressRenderSvgMedia, type FlowpressSvgMediaLocals } from "../svg-media.js";
|
|
4
5
|
import "./native/grid.css";
|
|
5
6
|
import "./native/group.css";
|
|
@@ -59,7 +60,7 @@ const inputBlocks = sourceBlocks
|
|
|
59
60
|
: composition.blocks;
|
|
60
61
|
// Prepare the whole authored tree once, before adapters render native groups.
|
|
61
62
|
// Nested resolved passes prepare their own trees through ResolvedBlocks.
|
|
62
|
-
const blocks = depth === 0 ? decorateGridBlocks(inputBlocks) : inputBlocks;
|
|
63
|
+
const blocks = decorateAccordionBlocks(depth === 0 ? decorateGridBlocks(inputBlocks) : inputBlocks, accordionRenderPrefix(Astro.locals));
|
|
63
64
|
|
|
64
65
|
const prepared = Astro.props.prepared ?? {
|
|
65
66
|
descriptors: flowpressBlockTypeDescriptors(composition),
|
|
@@ -109,8 +110,9 @@ const logoStyles = parentBlockName === undefined
|
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
const Adapter = adapter.renderer;
|
|
113
|
+
const isSlot = block.name === "sf/slot";
|
|
112
114
|
const children = block.innerBlocks ?? [];
|
|
113
|
-
const styleflowProps = resolveFlowpressBlockStyleflowProps(
|
|
115
|
+
const styleflowProps = isSlot ? {} : resolveFlowpressBlockStyleflowProps(
|
|
114
116
|
block.attributes,
|
|
115
117
|
contract,
|
|
116
118
|
{},
|
|
@@ -122,7 +124,7 @@ const logoStyles = parentBlockName === undefined
|
|
|
122
124
|
)
|
|
123
125
|
}
|
|
124
126
|
);
|
|
125
|
-
const htmlProps = flowpressBlockHtmlProps(block.attributes);
|
|
127
|
+
const htmlProps = isSlot ? {} : flowpressBlockHtmlProps(block.attributes);
|
|
126
128
|
return (
|
|
127
129
|
<>
|
|
128
130
|
{issue && (
|
|
@@ -152,7 +154,7 @@ const logoStyles = parentBlockName === undefined
|
|
|
152
154
|
adapters={adapters}
|
|
153
155
|
blocks={children}
|
|
154
156
|
contract={contract}
|
|
155
|
-
parentBlockName={block.name}
|
|
157
|
+
parentBlockName={isSlot ? parentBlockName : block.name}
|
|
156
158
|
production={production}
|
|
157
159
|
depth={depth + 1}
|
|
158
160
|
inheritedTone={typeof styleflowProps.tone === "string" ? styleflowProps.tone : inheritedTone}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import "./native/inline-text.css";
|
|
3
|
+
import { decorateAccordionBlocks, accordionRenderPrefix } from "./native/accordion.js";
|
|
3
4
|
import { registerFlowpressRenderSvgMedia, type FlowpressSvgMediaLocals } from "../svg-media.js";
|
|
4
5
|
import Media from "./Media.astro";
|
|
5
6
|
import { decodeFlowpressText } from "../text.js";
|
|
@@ -81,7 +82,7 @@ const {
|
|
|
81
82
|
registerFlowpressRenderSvgMedia(rawBlocks, Astro.locals as FlowpressSvgMediaLocals);
|
|
82
83
|
|
|
83
84
|
const { decorateGridBlocks } = await import("./native/grid.js");
|
|
84
|
-
const blocks = decorateGridBlocks(rawBlocks);
|
|
85
|
+
const blocks = decorateAccordionBlocks(decorateGridBlocks(rawBlocks), accordionRenderPrefix(Astro.locals));
|
|
85
86
|
const { nativeBlockRenderers } = await import("./native/registry.js");
|
|
86
87
|
const effectiveRenderers = { ...nativeBlockRenderers, ...blockRenderers };
|
|
87
88
|
const descriptors = Astro.props.descriptorIndex ?? (composition ? flowpressBlockTypeDescriptors(composition) : undefined);
|
|
@@ -123,14 +124,15 @@ function nestedRendererProps(nextParentBlockName: string, attrs: Record<string,
|
|
|
123
124
|
|
|
124
125
|
{blocks.map((block, index) => {
|
|
125
126
|
const name = block.name.replace(/^sf\//, "");
|
|
127
|
+
const isSlot = block.name === "sf/slot";
|
|
126
128
|
const children = decorateGridBlocks(block.innerBlocks ?? []);
|
|
127
129
|
if (interactiveAncestor && /^(?:core|sf)\/(?:paragraph|heading)$/.test(block.name) && !block.attributes.foreground) block = {...block, attributes:{...block.attributes, foreground:"inherit"}};
|
|
128
|
-
const semantic = index === 0 && blocks.length === 1 && rootStyleflowProps
|
|
130
|
+
const semantic = isSlot ? {} : index === 0 && blocks.length === 1 && rootStyleflowProps
|
|
129
131
|
? rootStyleflowProps
|
|
130
132
|
: semanticProps(block.attributes, contract,
|
|
131
133
|
block.name.startsWith("core/") && block.name !== "core/group" ? {} : undefined,
|
|
132
134
|
inheritedTone);
|
|
133
|
-
const htmlAttributes = index === 0 && blocks.length === 1 && rootHtmlProps
|
|
135
|
+
const htmlAttributes = isSlot ? {} : index === 0 && blocks.length === 1 && rootHtmlProps
|
|
134
136
|
? { ...rootHtmlProps, class: Array.from(new Set([rootHtmlProps.class, block.attributes.className].filter(Boolean).join(" ").split(/\s+/))).join(" ") }
|
|
135
137
|
: blockHtmlAttributes(block.attributes);
|
|
136
138
|
const CustomBlockRenderer = block.name === skipCustomRendererFor
|
|
@@ -193,11 +195,11 @@ function nestedRendererProps(nextParentBlockName: string, attrs: Record<string,
|
|
|
193
195
|
iconRenderer={IconRenderer}
|
|
194
196
|
adapterDefinitions={adapterDefinitions}
|
|
195
197
|
composition={composition}
|
|
196
|
-
parentBlockName={block.name}
|
|
198
|
+
parentBlockName={isSlot ? parentBlockName : block.name}
|
|
197
199
|
production={production}
|
|
198
200
|
depth={depth + 1}
|
|
199
201
|
inheritedTone={typeof semantic.tone === "string" ? semantic.tone : inheritedTone}
|
|
200
|
-
interactiveAncestor={interactiveAncestor || Boolean(block.attributes.interactivePriority && !["none", "inherit"].includes(String(block.attributes.interactivePriority)))}
|
|
202
|
+
interactiveAncestor={interactiveAncestor || (!isSlot && Boolean(block.attributes.interactivePriority && !["none", "inherit"].includes(String(block.attributes.interactivePriority))))}
|
|
201
203
|
requireRegisteredAdapters={requireRegisteredAdapters}
|
|
202
204
|
/>
|
|
203
205
|
</CustomBlockRenderer>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "./accordion.css";
|
|
3
|
+
---
|
|
4
|
+
<script>
|
|
5
|
+
import { initializeNativeAccordions } from "./accordion-controller.js";
|
|
6
|
+
let cleanup = () => {};
|
|
7
|
+
const start = () => { cleanup(); cleanup = initializeNativeAccordions(); };
|
|
8
|
+
start();
|
|
9
|
+
document.addEventListener("astro:page-load", start);
|
|
10
|
+
document.addEventListener("astro:before-swap", () => cleanup());
|
|
11
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion-controller.d.ts","sourceRoot":"","sources":["../../../src/astro/native/accordion-controller.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,wBAAgB,0BAA0B,CAAC,KAAK,GAAE,UAAqB,GAAG,MAAM,IAAI,CA4FnF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { getMotionPreference, subscribeMotionPreference } from "../../motion-preference.js";
|
|
2
|
+
const owner = (element, group) => element.closest("[data-fp-accordion]") === group;
|
|
3
|
+
/** Each invocation owns only the groups it binds; safe under Astro navigation. */
|
|
4
|
+
export function initializeNativeAccordions(scope = document) {
|
|
5
|
+
const cleanups = [];
|
|
6
|
+
scope.querySelectorAll("[data-fp-accordion]").forEach(group => {
|
|
7
|
+
if (group.dataset.fpAccordionReady === "true")
|
|
8
|
+
return;
|
|
9
|
+
const reduced = () => getMotionPreference() === "reduce" || Boolean(group.closest(".sf-motion-disable"));
|
|
10
|
+
const items = [...group.querySelectorAll("[data-fp-accordion-item]")].filter(el => owner(el, group)).flatMap(item => {
|
|
11
|
+
const button = [...item.querySelectorAll("[data-fp-accordion-toggle]")].find(el => el.closest("[data-fp-accordion-item]") === item);
|
|
12
|
+
const panel = [...item.querySelectorAll("[data-fp-accordion-panel]")].find(el => el.closest("[data-fp-accordion-item]") === item);
|
|
13
|
+
if (!button || !panel)
|
|
14
|
+
return [];
|
|
15
|
+
let expanded = item.dataset.fpAccordionInitialOpen === "true";
|
|
16
|
+
let animation;
|
|
17
|
+
const sync = () => {
|
|
18
|
+
button.setAttribute("aria-expanded", String(expanded));
|
|
19
|
+
item.classList.toggle("is-open", expanded);
|
|
20
|
+
panel.inert = !expanded;
|
|
21
|
+
};
|
|
22
|
+
const settle = () => {
|
|
23
|
+
animation?.cancel();
|
|
24
|
+
animation = undefined;
|
|
25
|
+
delete panel.dataset.fpAccordionAnimating;
|
|
26
|
+
panel.hidden = !expanded;
|
|
27
|
+
sync();
|
|
28
|
+
};
|
|
29
|
+
const setExpanded = (next, animate = true) => {
|
|
30
|
+
if (next === expanded)
|
|
31
|
+
return;
|
|
32
|
+
const from = panel.hidden ? 0 : panel.getBoundingClientRect().height;
|
|
33
|
+
animation?.cancel();
|
|
34
|
+
animation = undefined;
|
|
35
|
+
expanded = next;
|
|
36
|
+
panel.hidden = false;
|
|
37
|
+
sync();
|
|
38
|
+
panel.dataset.fpAccordionAnimating = "true";
|
|
39
|
+
const style = getComputedStyle(panel);
|
|
40
|
+
const time = style.getPropertyValue("--fp-accordion-computed-panel-duration").trim();
|
|
41
|
+
const duration = parseFloat(time) * (time.endsWith("ms") ? 1 : 1000);
|
|
42
|
+
const to = expanded ? panel.getBoundingClientRect().height : 0;
|
|
43
|
+
if (!animate || reduced() || panel.closest(".sf-motion-disable") || !panel.animate || !Number.isFinite(duration) || duration <= 0 || from === to) {
|
|
44
|
+
settle();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
animation = panel.animate([{ height: `${from}px` }, { height: `${to}px` }], {
|
|
49
|
+
duration, easing: style.getPropertyValue("--fp-accordion-computed-panel-easing").trim() || "ease-out", fill: "both",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
settle();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
animation.onfinish = settle;
|
|
57
|
+
};
|
|
58
|
+
settle();
|
|
59
|
+
return [{ item, button, panel, setExpanded, settle, isOpen: () => expanded }];
|
|
60
|
+
});
|
|
61
|
+
const onClick = (event) => {
|
|
62
|
+
if (!(event.target instanceof Element))
|
|
63
|
+
return;
|
|
64
|
+
const button = event.target.closest("[data-fp-accordion-toggle]");
|
|
65
|
+
const current = items.find(item => item.button === button);
|
|
66
|
+
if (!current || !button || !owner(button, group) || event.defaultPrevented)
|
|
67
|
+
return;
|
|
68
|
+
const next = !current.isOpen();
|
|
69
|
+
if (next && group.dataset.fpAccordionAutoclose === "true")
|
|
70
|
+
items.forEach(item => { if (item !== current)
|
|
71
|
+
item.setExpanded(false); });
|
|
72
|
+
current.setExpanded(next);
|
|
73
|
+
};
|
|
74
|
+
const onKey = (event) => {
|
|
75
|
+
const index = items.findIndex(item => item.button === event.target);
|
|
76
|
+
if (index < 0 || !["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key))
|
|
77
|
+
return;
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : Math.max(0, Math.min(items.length - 1, index + (event.key === "ArrowDown" ? 1 : -1)));
|
|
80
|
+
items[next]?.button.focus();
|
|
81
|
+
};
|
|
82
|
+
const onHash = () => {
|
|
83
|
+
let id;
|
|
84
|
+
try {
|
|
85
|
+
id = decodeURIComponent(window.location.hash.slice(1));
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const target = id ? document.getElementById(id) : null;
|
|
91
|
+
if (!target)
|
|
92
|
+
return;
|
|
93
|
+
const current = items.find(item => item.panel === target || item.panel.contains(target));
|
|
94
|
+
if (!current)
|
|
95
|
+
return;
|
|
96
|
+
if (group.dataset.fpAccordionAutoclose === "true")
|
|
97
|
+
items.forEach(item => { if (item !== current)
|
|
98
|
+
item.setExpanded(false, false); });
|
|
99
|
+
current.setExpanded(true, false);
|
|
100
|
+
requestAnimationFrame(() => target.scrollIntoView());
|
|
101
|
+
};
|
|
102
|
+
const syncMotion = () => {
|
|
103
|
+
group.dataset.fpAccordionMotion = reduced() ? "reduce" : "full";
|
|
104
|
+
if (reduced())
|
|
105
|
+
items.forEach(item => item.settle());
|
|
106
|
+
};
|
|
107
|
+
syncMotion();
|
|
108
|
+
const unsubscribe = subscribeMotionPreference(syncMotion);
|
|
109
|
+
group.dataset.fpAccordionReady = "true";
|
|
110
|
+
group.addEventListener("click", onClick);
|
|
111
|
+
group.addEventListener("keydown", onKey);
|
|
112
|
+
window.addEventListener("hashchange", onHash);
|
|
113
|
+
onHash();
|
|
114
|
+
cleanups.push(() => {
|
|
115
|
+
unsubscribe();
|
|
116
|
+
group.removeEventListener("click", onClick);
|
|
117
|
+
group.removeEventListener("keydown", onKey);
|
|
118
|
+
window.removeEventListener("hashchange", onHash);
|
|
119
|
+
delete group.dataset.fpAccordionReady;
|
|
120
|
+
delete group.dataset.fpAccordionMotion;
|
|
121
|
+
items.forEach(({ item, button, panel, settle }) => {
|
|
122
|
+
settle();
|
|
123
|
+
panel.hidden = false;
|
|
124
|
+
panel.inert = false;
|
|
125
|
+
button.setAttribute("aria-expanded", "true");
|
|
126
|
+
item.classList.remove("is-open");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
return () => cleanups.forEach(cleanup => cleanup());
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=accordion-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion-controller.js","sourceRoot":"","sources":["../../../src/astro/native/accordion-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,MAAM,KAAK,GAAG,CAAC,OAAgB,EAAE,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,KAAK,CAAC;AACrG,kFAAkF;AAClF,MAAM,UAAU,0BAA0B,CAAC,QAAoB,QAAQ;IACrE,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,CAAC,gBAAgB,CAAc,qBAAqB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzE,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,KAAK,MAAM;YAAE,OAAO;QACtD,MAAM,OAAO,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otionPreference } from \"../../motion-preference.js\";\n\nconst owner = (element: Element, group: Element) => element.closest(\"[data-fp-accordion]\") === group;\n/** Each invocation owns only the groups it binds; safe under Astro navigation. */\nexport function initializeNativeAccordions(scope: ParentNode = document): () => void {\n const cleanups: (() => void)[] = [];\n scope.querySelectorAll<HTMLElement>(\"[data-fp-accordion]\").forEach(group => {\n if (group.dataset.fpAccordionReady === \"true\") return;\n const reduced = () => getMotionPreference() === \"reduce\" || Boolean(group.closest(\".sf-motion-disable\"));\n const items = [...group.querySelectorAll<HTMLElement>(\"[data-fp-accordion-item]\")].filter(el => owner(el, group)).flatMap(item => {\n const button = [...item.querySelectorAll<HTMLButtonElement>(\"[data-fp-accordion-toggle]\")].find(el => el.closest(\"[data-fp-accordion-item]\") === item);\n const panel = [...item.querySelectorAll<HTMLElement>(\"[data-fp-accordion-panel]\")].find(el => el.closest(\"[data-fp-accordion-item]\") === item);\n if (!button || !panel) return [];\n let expanded = item.dataset.fpAccordionInitialOpen === \"true\";\n let animation: Animation | undefined;\n const sync = () => {\n button.setAttribute(\"aria-expanded\", String(expanded));\n item.classList.toggle(\"is-open\", expanded);\n panel.inert = !expanded;\n };\n const settle = () => {\n animation?.cancel(); animation = undefined;\n delete panel.dataset.fpAccordionAnimating;\n panel.hidden = !expanded;\n sync();\n };\n const setExpanded = (next: boolean, animate = true) => {\n if (next === expanded) return;\n const from = panel.hidden ? 0 : panel.getBoundingClientRect().height;\n animation?.cancel(); animation = undefined;\n expanded = next; panel.hidden = false;\n sync();\n panel.dataset.fpAccordionAnimating = \"true\";\n const style = getComputedStyle(panel);\n const time = style.getPropertyValue(\"--fp-accordion-computed-panel-duration\").trim();\n const duration = parseFloat(time) * (time.endsWith(\"ms\") ? 1 : 1000);\n const to = expanded ? panel.getBoundingClientRect().height : 0;\n if (!animate || reduced() || panel.closest(\".sf-motion-disable\") || !panel.animate || !Number.isFinite(duration) || duration <= 0 || from === to) { settle(); return; }\n try {\n animation = panel.animate([{ height: `${from}px` }, { height: `${to}px` }], {\n duration, easing: style.getPropertyValue(\"--fp-accordion-computed-panel-easing\").trim() || \"ease-out\", fill: \"both\",\n });\n } catch { settle(); return; }\n animation.onfinish = settle;\n };\n settle();\n return [{ item, button, panel, setExpanded, settle, isOpen: () => expanded }];\n });\n const onClick = (event: Event) => {\n if (!(event.target instanceof Element)) return;\n const button = event.target.closest(\"[data-fp-accordion-toggle]\");\n const current = items.find(item => item.button === button);\n if (!current || !button || !owner(button, group) || event.defaultPrevented) return;\n const next = !current.isOpen();\n if (next && group.dataset.fpAccordionAutoclose === \"true\") items.forEach(item => { if (item !== current) item.setExpanded(false); });\n current.setExpanded(next);\n };\n const onKey = (event: KeyboardEvent) => {\n const index = items.findIndex(item => item.button === event.target);\n if (index < 0 || ![\"ArrowUp\", \"ArrowDown\", \"Home\", \"End\"].includes(event.key)) return;\n event.preventDefault();\n const next = event.key === \"Home\" ? 0 : event.key === \"End\" ? items.length - 1 : Math.max(0, Math.min(items.length - 1, index + (event.key === \"ArrowDown\" ? 1 : -1)));\n items[next]?.button.focus();\n };\n const onHash = () => {\n let id: string;\n try { id = decodeURIComponent(window.location.hash.slice(1)); } catch { return; }\n const target = id ? document.getElementById(id) : null;\n if (!target) return;\n const current = items.find(item => item.panel === target || item.panel.contains(target));\n if (!current) return;\n if (group.dataset.fpAccordionAutoclose === \"true\") items.forEach(item => { if (item !== current) item.setExpanded(false, false); });\n current.setExpanded(true, false);\n requestAnimationFrame(() => target.scrollIntoView());\n };\n const syncMotion = () => {\n group.dataset.fpAccordionMotion = reduced() ? \"reduce\" : \"full\";\n if (reduced()) items.forEach(item => item.settle());\n };\n syncMotion();\n const unsubscribe = subscribeMotionPreference(syncMotion);\n group.dataset.fpAccordionReady = \"true\";\n group.addEventListener(\"click\", onClick);\n group.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"hashchange\", onHash);\n onHash();\n cleanups.push(() => {\n unsubscribe(); group.removeEventListener(\"click\", onClick); group.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"hashchange\", onHash);\n delete group.dataset.fpAccordionReady; delete group.dataset.fpAccordionMotion;\n items.forEach(({ item, button, panel, settle }) => {\n settle(); panel.hidden = false; panel.inert = false; button.setAttribute(\"aria-expanded\", \"true\"); item.classList.remove(\"is-open\");\n });\n });\n });\n return () => cleanups.forEach(cleanup => cleanup());\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getMotionPreference, subscribeMotionPreference } from "../../motion-preference.js";
|
|
2
|
+
|
|
3
|
+
const owner = (element: Element, group: Element) => element.closest("[data-fp-accordion]") === group;
|
|
4
|
+
/** Each invocation owns only the groups it binds; safe under Astro navigation. */
|
|
5
|
+
export function initializeNativeAccordions(scope: ParentNode = document): () => void {
|
|
6
|
+
const cleanups: (() => void)[] = [];
|
|
7
|
+
scope.querySelectorAll<HTMLElement>("[data-fp-accordion]").forEach(group => {
|
|
8
|
+
if (group.dataset.fpAccordionReady === "true") return;
|
|
9
|
+
const reduced = () => getMotionPreference() === "reduce" || Boolean(group.closest(".sf-motion-disable"));
|
|
10
|
+
const items = [...group.querySelectorAll<HTMLElement>("[data-fp-accordion-item]")].filter(el => owner(el, group)).flatMap(item => {
|
|
11
|
+
const button = [...item.querySelectorAll<HTMLButtonElement>("[data-fp-accordion-toggle]")].find(el => el.closest("[data-fp-accordion-item]") === item);
|
|
12
|
+
const panel = [...item.querySelectorAll<HTMLElement>("[data-fp-accordion-panel]")].find(el => el.closest("[data-fp-accordion-item]") === item);
|
|
13
|
+
if (!button || !panel) return [];
|
|
14
|
+
let expanded = item.dataset.fpAccordionInitialOpen === "true";
|
|
15
|
+
let animation: Animation | undefined;
|
|
16
|
+
const sync = () => {
|
|
17
|
+
button.setAttribute("aria-expanded", String(expanded));
|
|
18
|
+
item.classList.toggle("is-open", expanded);
|
|
19
|
+
panel.inert = !expanded;
|
|
20
|
+
};
|
|
21
|
+
const settle = () => {
|
|
22
|
+
animation?.cancel(); animation = undefined;
|
|
23
|
+
delete panel.dataset.fpAccordionAnimating;
|
|
24
|
+
panel.hidden = !expanded;
|
|
25
|
+
sync();
|
|
26
|
+
};
|
|
27
|
+
const setExpanded = (next: boolean, animate = true) => {
|
|
28
|
+
if (next === expanded) return;
|
|
29
|
+
const from = panel.hidden ? 0 : panel.getBoundingClientRect().height;
|
|
30
|
+
animation?.cancel(); animation = undefined;
|
|
31
|
+
expanded = next; panel.hidden = false;
|
|
32
|
+
sync();
|
|
33
|
+
panel.dataset.fpAccordionAnimating = "true";
|
|
34
|
+
const style = getComputedStyle(panel);
|
|
35
|
+
const time = style.getPropertyValue("--fp-accordion-computed-panel-duration").trim();
|
|
36
|
+
const duration = parseFloat(time) * (time.endsWith("ms") ? 1 : 1000);
|
|
37
|
+
const to = expanded ? panel.getBoundingClientRect().height : 0;
|
|
38
|
+
if (!animate || reduced() || panel.closest(".sf-motion-disable") || !panel.animate || !Number.isFinite(duration) || duration <= 0 || from === to) { settle(); return; }
|
|
39
|
+
try {
|
|
40
|
+
animation = panel.animate([{ height: `${from}px` }, { height: `${to}px` }], {
|
|
41
|
+
duration, easing: style.getPropertyValue("--fp-accordion-computed-panel-easing").trim() || "ease-out", fill: "both",
|
|
42
|
+
});
|
|
43
|
+
} catch { settle(); return; }
|
|
44
|
+
animation.onfinish = settle;
|
|
45
|
+
};
|
|
46
|
+
settle();
|
|
47
|
+
return [{ item, button, panel, setExpanded, settle, isOpen: () => expanded }];
|
|
48
|
+
});
|
|
49
|
+
const onClick = (event: Event) => {
|
|
50
|
+
if (!(event.target instanceof Element)) return;
|
|
51
|
+
const button = event.target.closest("[data-fp-accordion-toggle]");
|
|
52
|
+
const current = items.find(item => item.button === button);
|
|
53
|
+
if (!current || !button || !owner(button, group) || event.defaultPrevented) return;
|
|
54
|
+
const next = !current.isOpen();
|
|
55
|
+
if (next && group.dataset.fpAccordionAutoclose === "true") items.forEach(item => { if (item !== current) item.setExpanded(false); });
|
|
56
|
+
current.setExpanded(next);
|
|
57
|
+
};
|
|
58
|
+
const onKey = (event: KeyboardEvent) => {
|
|
59
|
+
const index = items.findIndex(item => item.button === event.target);
|
|
60
|
+
if (index < 0 || !["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : Math.max(0, Math.min(items.length - 1, index + (event.key === "ArrowDown" ? 1 : -1)));
|
|
63
|
+
items[next]?.button.focus();
|
|
64
|
+
};
|
|
65
|
+
const onHash = () => {
|
|
66
|
+
let id: string;
|
|
67
|
+
try { id = decodeURIComponent(window.location.hash.slice(1)); } catch { return; }
|
|
68
|
+
const target = id ? document.getElementById(id) : null;
|
|
69
|
+
if (!target) return;
|
|
70
|
+
const current = items.find(item => item.panel === target || item.panel.contains(target));
|
|
71
|
+
if (!current) return;
|
|
72
|
+
if (group.dataset.fpAccordionAutoclose === "true") items.forEach(item => { if (item !== current) item.setExpanded(false, false); });
|
|
73
|
+
current.setExpanded(true, false);
|
|
74
|
+
requestAnimationFrame(() => target.scrollIntoView());
|
|
75
|
+
};
|
|
76
|
+
const syncMotion = () => {
|
|
77
|
+
group.dataset.fpAccordionMotion = reduced() ? "reduce" : "full";
|
|
78
|
+
if (reduced()) items.forEach(item => item.settle());
|
|
79
|
+
};
|
|
80
|
+
syncMotion();
|
|
81
|
+
const unsubscribe = subscribeMotionPreference(syncMotion);
|
|
82
|
+
group.dataset.fpAccordionReady = "true";
|
|
83
|
+
group.addEventListener("click", onClick);
|
|
84
|
+
group.addEventListener("keydown", onKey);
|
|
85
|
+
window.addEventListener("hashchange", onHash);
|
|
86
|
+
onHash();
|
|
87
|
+
cleanups.push(() => {
|
|
88
|
+
unsubscribe(); group.removeEventListener("click", onClick); group.removeEventListener("keydown", onKey);
|
|
89
|
+
window.removeEventListener("hashchange", onHash);
|
|
90
|
+
delete group.dataset.fpAccordionReady; delete group.dataset.fpAccordionMotion;
|
|
91
|
+
items.forEach(({ item, button, panel, settle }) => {
|
|
92
|
+
settle(); panel.hidden = false; panel.inert = false; button.setAttribute("aria-expanded", "true"); item.classList.remove("is-open");
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
return () => cleanups.forEach(cleanup => cleanup());
|
|
97
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* Structural disclosure behavior. All visual recipes belong to StyleFlow props. */
|
|
2
|
+
/* styleflow-ignore-start rule=SF_CSS_HARDCODED reason="Native accordion control geometry and state" scope="Native accordion" */
|
|
3
|
+
:where([data-fp-accordion-toggle]) {
|
|
4
|
+
display: flex; align-items: center; inline-size: 100%; text-align: inherit;
|
|
5
|
+
font: inherit; color: inherit; cursor: pointer;
|
|
6
|
+
gap: var(--sf-layout-control-regular-gap, .5em);
|
|
7
|
+
}
|
|
8
|
+
:where([data-fp-accordion-toggle]) > .wp-block-accordion-heading__toggle-title { flex: 1; }
|
|
9
|
+
:where([data-fp-accordion-toggle]) > .wp-block-accordion-heading__toggle-icon { display: inline-flex; flex: 0 0 auto; inline-size: 1.2em; block-size: 1.2em; align-items: center; justify-content: center; }
|
|
10
|
+
:where([data-fp-accordion-toggle][data-fp-accordion-icon-position="left"]) > .wp-block-accordion-heading__toggle-icon { order: -1; }
|
|
11
|
+
:where([data-fp-accordion-toggle]) .wp-block-accordion-heading__toggle-icon > span { display: inline-flex; inline-size: 100%; block-size: 100%; align-items: center; justify-content: center; }
|
|
12
|
+
:where([data-fp-accordion-toggle]) .wp-block-accordion-heading__toggle-icon svg { display: block; inline-size: 100%; block-size: 100%; }
|
|
13
|
+
[data-fp-accordion-toggle] > .wp-block-accordion-heading__toggle-icon { transform: none !important; transition: none !important; }
|
|
14
|
+
[data-fp-accordion-toggle][aria-expanded="true"] [data-fp-accordion-icon-closed],
|
|
15
|
+
[data-fp-accordion-toggle][aria-expanded="false"] [data-fp-accordion-icon-open] { display: none; }
|
|
16
|
+
[data-fp-accordion-toggle][aria-expanded="true"][data-fp-accordion-icon-animation="rotate"] [data-fp-accordion-icon-single] { transform: rotate(var(--fp-accordion-icon-rotation, 45deg)); }
|
|
17
|
+
[data-fp-accordion-ready="true"] [data-fp-accordion-icon-single] {
|
|
18
|
+
transition: transform var(--fp-accordion-icon-duration, var(--sf-motion-duration-fast, 200ms)) var(--fp-accordion-icon-easing, var(--sf-motion-ease-soft, ease-in-out));
|
|
19
|
+
}
|
|
20
|
+
[data-fp-accordion-panel] {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
--fp-accordion-computed-panel-duration: var(--fp-accordion-panel-duration, var(--sf-motion-duration-default, 300ms));
|
|
23
|
+
--fp-accordion-computed-panel-easing: var(--fp-accordion-panel-easing, var(--sf-motion-ease-soft, ease-out));
|
|
24
|
+
}
|
|
25
|
+
[data-fp-accordion-panel][data-fp-accordion-animating="true"] { display: block !important; overflow: clip; }
|
|
26
|
+
[data-fp-accordion-panel][hidden] { display: none !important; }
|
|
27
|
+
[data-fp-accordion-motion="reduce"] [data-fp-accordion-icon-single],
|
|
28
|
+
.sf-motion-disable [data-fp-accordion-icon-single] { transition: none; }
|
|
29
|
+
/* styleflow-ignore-end */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FlowpressBlock } from "../../types.js";
|
|
2
|
+
export interface AccordionSettings {
|
|
3
|
+
autoclose: boolean;
|
|
4
|
+
level: number;
|
|
5
|
+
showIcon: boolean;
|
|
6
|
+
iconPosition: string;
|
|
7
|
+
animation: string;
|
|
8
|
+
rotation: number;
|
|
9
|
+
closedIcon?: string | undefined;
|
|
10
|
+
openIcon?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface AccordionItemData extends AccordionSettings {
|
|
13
|
+
id: string;
|
|
14
|
+
panelId: string;
|
|
15
|
+
open: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function accordionData(block: FlowpressBlock): Partial<AccordionItemData>;
|
|
18
|
+
export declare function accordionRenderPrefix(locals: object): string;
|
|
19
|
+
/** Prepare only a rendered copy; pattern/query passes receive their own unique prefix. */
|
|
20
|
+
export declare function decorateAccordionBlocks(blocks: FlowpressBlock[], prefix: string): FlowpressBlock[];
|
|
21
|
+
/** Source attributes may be absent in a parser-only payload; retain nested rich text. */
|
|
22
|
+
export declare function accordionTitle(block: FlowpressBlock): string;
|
|
23
|
+
//# sourceMappingURL=accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../src/astro/native/accordion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AACD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE/E;AACD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D;AACD,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAmClG;AACD,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAG5D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { nativeIconSvg } from "./icon.js";
|
|
2
|
+
const object = (value) => value && typeof value === "object" ? value : {};
|
|
3
|
+
const level = (value, fallback) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 6 ? Number(value) : fallback;
|
|
4
|
+
export function accordionData(block) {
|
|
5
|
+
return object(block.resolvedData?.flowpressAccordion);
|
|
6
|
+
}
|
|
7
|
+
export function accordionRenderPrefix(locals) {
|
|
8
|
+
const state = locals;
|
|
9
|
+
state.flowpressAccordionSequence = (state.flowpressAccordionSequence ?? 0) + 1;
|
|
10
|
+
return `fp-accordion-${state.flowpressAccordionSequence}`;
|
|
11
|
+
}
|
|
12
|
+
/** Prepare only a rendered copy; pattern/query passes receive their own unique prefix. */
|
|
13
|
+
export function decorateAccordionBlocks(blocks, prefix) {
|
|
14
|
+
let sequence = 0;
|
|
15
|
+
const visit = (block, settings, item) => {
|
|
16
|
+
if (block.resolvedData?.flowpressAccordion)
|
|
17
|
+
return block;
|
|
18
|
+
const attrs = block.attributes;
|
|
19
|
+
let data;
|
|
20
|
+
if (block.name === "core/accordion") {
|
|
21
|
+
const icons = object(block.resolvedData?.accordionIcons);
|
|
22
|
+
const rotation = Number(attrs.flowpressAccordionIconRotation ?? 45);
|
|
23
|
+
settings = {
|
|
24
|
+
autoclose: attrs.autoclose === true,
|
|
25
|
+
level: level(attrs.headingLevel, 3), showIcon: attrs.showIcon !== false,
|
|
26
|
+
iconPosition: attrs.iconPosition === "left" ? "left" : "right",
|
|
27
|
+
animation: attrs.flowpressAccordionIconAnimation === "none" ? "none" : "rotate",
|
|
28
|
+
rotation: Number.isFinite(rotation) ? Math.max(-360, Math.min(360, rotation)) : 45,
|
|
29
|
+
closedIcon: nativeIconSvg(attrs.flowpressAccordionIcon, icons.closed, `${prefix}-icon-${sequence++}`),
|
|
30
|
+
openIcon: nativeIconSvg(attrs.flowpressAccordionOpenIcon, icons.open, `${prefix}-icon-${sequence++}`),
|
|
31
|
+
};
|
|
32
|
+
data = settings;
|
|
33
|
+
item = undefined;
|
|
34
|
+
}
|
|
35
|
+
else if (block.name === "core/accordion-item" && settings) {
|
|
36
|
+
const id = `${prefix}-item-${sequence++}`;
|
|
37
|
+
const panel = block.innerBlocks?.find(child => child.name === "core/accordion-panel");
|
|
38
|
+
item = { ...settings, id, panelId: typeof panel?.attributes.anchor === "string" && panel.attributes.anchor ? panel.attributes.anchor : `${id}-panel`, open: attrs.openByDefault === true };
|
|
39
|
+
data = item;
|
|
40
|
+
}
|
|
41
|
+
else if (["core/accordion-heading", "core/accordion-panel"].includes(block.name) && item) {
|
|
42
|
+
data = { ...item, level: level(attrs.level, item.level) };
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...block,
|
|
46
|
+
...(data ? { resolvedData: { ...block.resolvedData, flowpressAccordion: data } } : {}),
|
|
47
|
+
...(block.innerBlocks ? { innerBlocks: block.innerBlocks.map(child => visit(child, settings, item)) } : {}),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
return blocks.map(block => visit(block));
|
|
51
|
+
}
|
|
52
|
+
/** Source attributes may be absent in a parser-only payload; retain nested rich text. */
|
|
53
|
+
export function accordionTitle(block) {
|
|
54
|
+
if (typeof block.attributes.title === "string")
|
|
55
|
+
return block.attributes.title;
|
|
56
|
+
return block.innerHtml?.match(/<span\b[^>]*class=["'][^"']*wp-block-accordion-heading__toggle-title[^"']*["'][^>]*>([\s\S]*?)<\/span>\s*(?=<span\b[^>]*class=["'][^"']*wp-block-accordion-heading__toggle-icon|<\/button>)/i)?.[1] ?? "";
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.js","sourceRoot":"","sources":["../../../src/astro/native/accordion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAiB1C,MAAM,MAAM,GAAG,CAAC,KAAc,EAAuB,EAAE,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,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,KAAK,CAAC;IAC9E,OAAO,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,8LAA8L,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3O,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../types.js\";\nimport { nativeIconSvg } from \"./icon.js\";\n\nexport interface AccordionSettings {\n autoclose: boolean;\n level: number;\n showIcon: boolean;\n iconPosition: string;\n animation: string;\n rotation: number;\n closedIcon?: string | undefined;\n openIcon?: string | undefined;\n}\nexport interface AccordionItemData extends AccordionSettings {\n id: string;\n panelId: string;\n open: boolean;\n}\nconst object = (value: unknown): Record<string, any> => value && typeof value === \"object\" ? value as Record<string, any> : {};\nconst level = (value: unknown, fallback: number) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 6 ? Number(value) : fallback;\nexport function accordionData(block: FlowpressBlock): Partial<AccordionItemData> {\n return object(block.resolvedData?.flowpressAccordion);\n}\nexport function accordionRenderPrefix(locals: object): string {\n const state = locals as { flowpressAccordionSequence?: number };\n state.flowpressAccordionSequence = (state.flowpressAccordionSequence ?? 0) + 1;\n return `fp-accordion-${state.flowpressAccordionSequence}`;\n}\n/** Prepare only a rendered copy; pattern/query passes receive their own unique prefix. */\nexport function decorateAccordionBlocks(blocks: FlowpressBlock[], prefix: string): FlowpressBlock[] {\n let sequence = 0;\n const visit = (block: FlowpressBlock, settings?: AccordionSettings, item?: AccordionItemData): FlowpressBlock => {\n if (block.resolvedData?.flowpressAccordion) return block;\n const attrs = block.attributes;\n let data: Partial<AccordionItemData> | undefined;\n if (block.name === \"core/accordion\") {\n const icons = object(block.resolvedData?.accordionIcons);\n const rotation = Number(attrs.flowpressAccordionIconRotation ?? 45);\n settings = {\n autoclose: attrs.autoclose === true,\n level: level(attrs.headingLevel, 3), showIcon: attrs.showIcon !== false,\n iconPosition: attrs.iconPosition === \"left\" ? \"left\" : \"right\",\n animation: attrs.flowpressAccordionIconAnimation === \"none\" ? \"none\" : \"rotate\",\n rotation: Number.isFinite(rotation) ? Math.max(-360, Math.min(360, rotation)) : 45,\n closedIcon: nativeIconSvg(attrs.flowpressAccordionIcon, icons.closed, `${prefix}-icon-${sequence++}`),\n openIcon: nativeIconSvg(attrs.flowpressAccordionOpenIcon, icons.open, `${prefix}-icon-${sequence++}`),\n };\n data = settings;\n item = undefined;\n } else if (block.name === \"core/accordion-item\" && settings) {\n const id = `${prefix}-item-${sequence++}`;\n const panel = block.innerBlocks?.find(child => child.name === \"core/accordion-panel\");\n item = { ...settings, id, panelId: typeof panel?.attributes.anchor === \"string\" && panel.attributes.anchor ? panel.attributes.anchor : `${id}-panel`, open: attrs.openByDefault === true };\n data = item;\n } else if ([\"core/accordion-heading\", \"core/accordion-panel\"].includes(block.name) && item) {\n data = { ...item, level: level(attrs.level, item.level) };\n }\n return {\n ...block,\n ...(data ? { resolvedData: { ...block.resolvedData, flowpressAccordion: data } } : {}),\n ...(block.innerBlocks ? { innerBlocks: block.innerBlocks.map(child => visit(child, settings, item)) } : {}),\n };\n };\n return blocks.map(block => visit(block));\n}\n/** Source attributes may be absent in a parser-only payload; retain nested rich text. */\nexport function accordionTitle(block: FlowpressBlock): string {\n if (typeof block.attributes.title === \"string\") return block.attributes.title;\n return block.innerHtml?.match(/<span\\b[^>]*class=[\"'][^\"']*wp-block-accordion-heading__toggle-title[^\"']*[\"'][^>]*>([\\s\\S]*?)<\\/span>\\s*(?=<span\\b[^>]*class=[\"'][^\"']*wp-block-accordion-heading__toggle-icon|<\\/button>)/i)?.[1] ?? \"\";\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { FlowpressBlock } from "../../types.js";
|
|
2
|
+
import { nativeIconSvg } from "./icon.js";
|
|
3
|
+
|
|
4
|
+
export interface AccordionSettings {
|
|
5
|
+
autoclose: boolean;
|
|
6
|
+
level: number;
|
|
7
|
+
showIcon: boolean;
|
|
8
|
+
iconPosition: string;
|
|
9
|
+
animation: string;
|
|
10
|
+
rotation: number;
|
|
11
|
+
closedIcon?: string | undefined;
|
|
12
|
+
openIcon?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface AccordionItemData extends AccordionSettings {
|
|
15
|
+
id: string;
|
|
16
|
+
panelId: string;
|
|
17
|
+
open: boolean;
|
|
18
|
+
}
|
|
19
|
+
const object = (value: unknown): Record<string, any> => value && typeof value === "object" ? value as Record<string, any> : {};
|
|
20
|
+
const level = (value: unknown, fallback: number) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 6 ? Number(value) : fallback;
|
|
21
|
+
export function accordionData(block: FlowpressBlock): Partial<AccordionItemData> {
|
|
22
|
+
return object(block.resolvedData?.flowpressAccordion);
|
|
23
|
+
}
|
|
24
|
+
export function accordionRenderPrefix(locals: object): string {
|
|
25
|
+
const state = locals as { flowpressAccordionSequence?: number };
|
|
26
|
+
state.flowpressAccordionSequence = (state.flowpressAccordionSequence ?? 0) + 1;
|
|
27
|
+
return `fp-accordion-${state.flowpressAccordionSequence}`;
|
|
28
|
+
}
|
|
29
|
+
/** Prepare only a rendered copy; pattern/query passes receive their own unique prefix. */
|
|
30
|
+
export function decorateAccordionBlocks(blocks: FlowpressBlock[], prefix: string): FlowpressBlock[] {
|
|
31
|
+
let sequence = 0;
|
|
32
|
+
const visit = (block: FlowpressBlock, settings?: AccordionSettings, item?: AccordionItemData): FlowpressBlock => {
|
|
33
|
+
if (block.resolvedData?.flowpressAccordion) return block;
|
|
34
|
+
const attrs = block.attributes;
|
|
35
|
+
let data: Partial<AccordionItemData> | undefined;
|
|
36
|
+
if (block.name === "core/accordion") {
|
|
37
|
+
const icons = object(block.resolvedData?.accordionIcons);
|
|
38
|
+
const rotation = Number(attrs.flowpressAccordionIconRotation ?? 45);
|
|
39
|
+
settings = {
|
|
40
|
+
autoclose: attrs.autoclose === true,
|
|
41
|
+
level: level(attrs.headingLevel, 3), showIcon: attrs.showIcon !== false,
|
|
42
|
+
iconPosition: attrs.iconPosition === "left" ? "left" : "right",
|
|
43
|
+
animation: attrs.flowpressAccordionIconAnimation === "none" ? "none" : "rotate",
|
|
44
|
+
rotation: Number.isFinite(rotation) ? Math.max(-360, Math.min(360, rotation)) : 45,
|
|
45
|
+
closedIcon: nativeIconSvg(attrs.flowpressAccordionIcon, icons.closed, `${prefix}-icon-${sequence++}`),
|
|
46
|
+
openIcon: nativeIconSvg(attrs.flowpressAccordionOpenIcon, icons.open, `${prefix}-icon-${sequence++}`),
|
|
47
|
+
};
|
|
48
|
+
data = settings;
|
|
49
|
+
item = undefined;
|
|
50
|
+
} else if (block.name === "core/accordion-item" && settings) {
|
|
51
|
+
const id = `${prefix}-item-${sequence++}`;
|
|
52
|
+
const panel = block.innerBlocks?.find(child => child.name === "core/accordion-panel");
|
|
53
|
+
item = { ...settings, id, panelId: typeof panel?.attributes.anchor === "string" && panel.attributes.anchor ? panel.attributes.anchor : `${id}-panel`, open: attrs.openByDefault === true };
|
|
54
|
+
data = item;
|
|
55
|
+
} else if (["core/accordion-heading", "core/accordion-panel"].includes(block.name) && item) {
|
|
56
|
+
data = { ...item, level: level(attrs.level, item.level) };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
...block,
|
|
60
|
+
...(data ? { resolvedData: { ...block.resolvedData, flowpressAccordion: data } } : {}),
|
|
61
|
+
...(block.innerBlocks ? { innerBlocks: block.innerBlocks.map(child => visit(child, settings, item)) } : {}),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
return blocks.map(block => visit(block));
|
|
65
|
+
}
|
|
66
|
+
/** Source attributes may be absent in a parser-only payload; retain nested rich text. */
|
|
67
|
+
export function accordionTitle(block: FlowpressBlock): string {
|
|
68
|
+
if (typeof block.attributes.title === "string") return block.attributes.title;
|
|
69
|
+
return block.innerHtml?.match(/<span\b[^>]*class=["'][^"']*wp-block-accordion-heading__toggle-title[^"']*["'][^>]*>([\s\S]*?)<\/span>\s*(?=<span\b[^>]*class=["'][^"']*wp-block-accordion-heading__toggle-icon|<\/button>)/i)?.[1] ?? "";
|
|
70
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "../StyleflowElement.astro";
|
|
3
|
+
import { accordionData, accordionTitle } from "./accordion.js";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const data = accordionData(block);
|
|
7
|
+
const tag = `h${data.level ?? 3}`;
|
|
8
|
+
const title = accordionTitle(block);
|
|
9
|
+
const dual = Boolean(data.openIcon);
|
|
10
|
+
---
|
|
11
|
+
<!-- styleflow-ignore-start rule=SF_INLINE_STYLE reason="Validated accordion icon rotation is interaction geometry" scope="Native accordion" -->
|
|
12
|
+
<S as={tag} id={htmlProps.id} class={["wp-block-accordion-heading", htmlProps.class].filter(Boolean).join(" ")}>
|
|
13
|
+
<S as="button" {...htmlProps} {...styleflowProps} id={data.id} class="wp-block-accordion-heading__toggle" type="button" aria-expanded="true" aria-controls={data.panelId} data-fp-accordion-toggle data-fp-accordion-icon-position={data.iconPosition ?? "right"} data-fp-accordion-icon-animation={dual ? "none" : data.animation ?? "rotate"} style={[htmlProps.style, `--fp-accordion-icon-rotation:${data.rotation ?? 45}deg`].filter(Boolean).join(";")}>
|
|
14
|
+
<span class="wp-block-accordion-heading__toggle-title" set:html={title} />
|
|
15
|
+
{data.showIcon !== false && <span class="wp-block-accordion-heading__toggle-icon" aria-hidden="true">
|
|
16
|
+
<span data-fp-accordion-icon-closed={!dual ? undefined : ""} data-fp-accordion-icon-single={dual ? undefined : ""}>{data.closedIcon ? <Fragment set:html={data.closedIcon} /> : "+"}</span>
|
|
17
|
+
{dual && <span data-fp-accordion-icon-open set:html={data.openIcon} />}
|
|
18
|
+
</span>}
|
|
19
|
+
</S>
|
|
20
|
+
</S>
|
|
21
|
+
<!-- styleflow-ignore-end -->
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "../StyleflowElement.astro";
|
|
3
|
+
import { accordionData } from "./accordion.js";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const data = accordionData(block);
|
|
7
|
+
---
|
|
8
|
+
<S as="div" {...htmlProps} {...styleflowProps} class={["wp-block-accordion-item", htmlProps.class].filter(Boolean).join(" ")} data-fp-accordion-item data-fp-accordion-initial-open={String(data.open === true)}><slot /></S>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "../StyleflowElement.astro";
|
|
3
|
+
import { accordionData } from "./accordion.js";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const data = accordionData(block);
|
|
7
|
+
---
|
|
8
|
+
<S as="div" {...htmlProps} {...styleflowProps} class={["wp-block-accordion-panel", htmlProps.class].filter(Boolean).join(" ")} id={data.panelId ?? htmlProps.id} role="region" aria-labelledby={data.id} data-fp-accordion-panel><slot /></S>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "../StyleflowElement.astro";
|
|
3
|
+
import Runtime from "./AccordionRuntime.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
---
|
|
7
|
+
<S as="div" {...htmlProps} {...styleflowProps} class={["wp-block-accordion", htmlProps.class].filter(Boolean).join(" ")} role="group" data-fp-accordion data-fp-accordion-autoclose={String(block.attributes.autoclose === true)}><slot /></S>
|
|
8
|
+
<Runtime />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/astro/native/grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,E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AACtD,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAO1C,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,aAAY,cAAmB,KAAG,OAEhC,CAAC;AAExC,eAAO,MAAM,UAAU,GAAI,YAAY,cAAc,KAAG,MAQvD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,YAAY,cAAc,KAAG,MAQvD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAAM,CAAC,cAAc,EAAE,MAAM,CAM7E,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,YAAY,cAAc,KAAG,MAAM,EAQ9D,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,YAAY,cAAc,KAAG,MAAM,EAK9D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,cAAc,EAAE,OAAO,cAAc,KAAG,MAAM,EAMrF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,cAAc,EAAE,UAAU,cAAc,EAAE,KAAG,MAAM,EAAE,EAsBzF,CAAC;AAqBF,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,cAAc,EAAE,KAAG,cAAc,EAkB1E,CAAC"}
|
|
@@ -79,18 +79,23 @@ const appendClasses = (attributes, classes) => ({
|
|
|
79
79
|
...attributes,
|
|
80
80
|
className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
|
|
81
81
|
});
|
|
82
|
+
/** Slot children occupy their own grid cells because the slot has no DOM root. */
|
|
83
|
+
const visibleChildren = (blocks) => blocks.flatMap((block) => block.name === "sf/slot" ? visibleChildren(block.innerBlocks ?? []) : [block]);
|
|
84
|
+
const mapVisibleChildren = (blocks, decorate, cursor = { index: 0 }) => blocks.map((block) => block.name === "sf/slot"
|
|
85
|
+
? { ...block, innerBlocks: mapVisibleChildren(block.innerBlocks ?? [], decorate, cursor) }
|
|
86
|
+
: decorate(block, cursor.index++));
|
|
82
87
|
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
83
88
|
export const decorateGridBlocks = (blocks) => blocks.map((block) => {
|
|
84
89
|
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
85
90
|
const attributes = (block.attributes || {});
|
|
86
91
|
if (!isGrid(block.name, attributes))
|
|
87
92
|
return innerBlocks ? { ...block, innerBlocks } : block;
|
|
88
|
-
const children = innerBlocks ?? [];
|
|
93
|
+
const children = visibleChildren(innerBlocks ?? []);
|
|
89
94
|
const bleed = bleedClasses(attributes, children.map((child) => child.attributes || {}));
|
|
90
95
|
return {
|
|
91
96
|
...block,
|
|
92
97
|
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
93
|
-
innerBlocks:
|
|
98
|
+
innerBlocks: mapVisibleChildren(innerBlocks ?? [], (child, index) => ({
|
|
94
99
|
...child,
|
|
95
100
|
attributes: appendClasses(child.attributes || {}, [
|
|
96
101
|
...spanClasses(child.attributes || {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/astro/native/grid.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAKhF,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAU,EAAE;IACzD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,aAA6B,E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C,UAA4B,IAAI,EAAE,CAAC;gBACxD,GAAG,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,UAA4B,IAAI,EAAE,CAAC;gBACxE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aACxB,CAAC;SACH,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../index.js\";\n\nexport const gridBreakpoints = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\nexport type GridBreakpoint = typeof gridBreakpoints[number];\ntype Values = Partial<Record<GridBreakpoint, number>>;\ntype GridAttributes = Record<string, any>;\n\nconst count = (value: unknown, fallback: number): number => {\n const n = Number(value);\n return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;\n};\n\nexport const isGrid = (name: string, attributes: GridAttributes = {}): boolean =>\n (name === \"core/group\" || name === \"core/post-template\" || name === \"core/term-template\")\n && attributes.layout?.type === \"grid\";\n\nexport const gridValues = (attributes: GridAttributes): Values => {\n const layout = attributes.layout || {};\n const values: Values = { base: count(layout.columnCount, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressColumns?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const spanValues = (attributes: GridAttributes): Values => {\n const layout = attributes.style?.layout || {};\n const values: Values = { base: count(layout.columnSpan, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressGridSpan?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const effectiveValues = (values: Values): Record<GridBreakpoint, number> => {\n let current = values.base ?? 1;\n return Object.fromEntries(gridBreakpoints.map((breakpoint) => {\n current = values[breakpoint] ?? current;\n return [breakpoint, current];\n })) as Record<GridBreakpoint, number>;\n};\n\nexport const gridClasses = (attributes: GridAttributes): string[] => {\n const values = gridValues(attributes);\n const align = attributes.layout?.flowpressAlign;\n return [\n \"fp-grid\",\n ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),\n ...( [\"start\", \"center\", \"end\", \"stretch\"].includes(align) ? [`fp-align-${align}`] : []),\n ];\n};\n\nexport const spanClasses = (attributes: GridAttributes): string[] => {\n const values = spanValues(attributes);\n return [\"fp-grid-item\", ...gridBreakpoints.flatMap((breakpoint) =>\n values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : []\n )];\n};\n\nexport const usedSpanClasses = (parent: GridAttributes, child: GridAttributes): string[] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = effectiveValues(spanValues(child));\n return gridBreakpoints.map((breakpoint) =>\n `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`\n );\n};\n\nexport const bleedClasses = (parent: GridAttributes, children: GridAttributes[]): string[][] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = children.map((child) => effectiveValues(spanValues(child)));\n const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? [\"fp-bleed-managed\"] : [] as string[]);\n for (const breakpoint of gridBreakpoints) {\n let position = 0;\n children.forEach((child, index) => {\n const width = Math.min(spans[index]![breakpoint], columns[breakpoint]);\n if (position + width > columns[breakpoint]) position = 0;\n const start = position === 0;\n const end = position + width === columns[breakpoint];\n const bleed = child.style?.layout?.flowpressGridBleed;\n const from = gridBreakpoints.indexOf(bleed?.from || \"base\");\n if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&\n ((bleed.side === \"start\" && start) || (bleed.side === \"end\" && end))) {\n result[index]!.push(`fp-bleed-${breakpoint}-${bleed.side}`);\n }\n position += width;\n if (position === columns[breakpoint]) position = 0;\n });\n }\n return result;\n};\n\nconst appendClasses = (attributes: GridAttributes, classes: string[]): GridAttributes => ({\n ...attributes,\n className: [...new Set([...(attributes.className || \"\").split(/\\s+/), ...classes].filter(Boolean))].join(\" \"),\n});\n\n/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */\nexport const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {\n const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;\n const attributes = (block.attributes || {}) as GridAttributes;\n if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;\n const children = innerBlocks ?? [];\n const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));\n return {\n ...block,\n attributes: appendClasses({ layoutRole: \"stack\", density: \"regular\", ...attributes }, gridClasses(attributes)),\n innerBlocks: children.map((child, index) => ({\n ...child,\n attributes: appendClasses(child.attributes as GridAttributes || {}, [\n ...spanClasses(child.attributes as GridAttributes || {}),\n ...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),\n ...(bleed[index] ?? []),\n ]),\n })),\n };\n});\n"]}
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/astro/native/grid.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAKhF,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAU,EAAE;IACzD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,aAA6B,EAAE,EAAW,EAAE,CAC/E,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;OACtF,UAAU,CAAC,MAAM,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,GAAG,eAAe,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAA4B,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1G,OAAO;QACL,GAAG,KAAK;QACR,UAAU,EAAE,aAAa,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;QAC9G,WAAW,EAAE,kBAAkB,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACpE,GAAG,KAAK;YACR,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,UAA4B,IAAI,EAAE,EAAE;gBAClE,GAAG,WAAW,CAAC,KAAK,CAAC,UAA4B,IAAI,EAAE,CAAC;gBACxD,GAAG,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,UAA4B,IAAI,EAAE,CAAC;gBACxE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aACxB,CAAC;SACH,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../index.js\";\n\nexport const gridBreakpoints = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\nexport type GridBreakpoint = typeof gridBreakpoints[number];\ntype Values = Partial<Record<GridBreakpoint, number>>;\ntype GridAttributes = Record<string, any>;\n\nconst count = (value: unknown, fallback: number): number => {\n const n = Number(value);\n return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;\n};\n\nexport const isGrid = (name: string, attributes: GridAttributes = {}): boolean =>\n (name === \"core/group\" || name === \"core/post-template\" || name === \"core/term-template\")\n && attributes.layout?.type === \"grid\";\n\nexport const gridValues = (attributes: GridAttributes): Values => {\n const layout = attributes.layout || {};\n const values: Values = { base: count(layout.columnCount, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressColumns?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const spanValues = (attributes: GridAttributes): Values => {\n const layout = attributes.style?.layout || {};\n const values: Values = { base: count(layout.columnSpan, 1) };\n for (const breakpoint of gridBreakpoints.slice(1)) {\n const value = layout.flowpressGridSpan?.[breakpoint];\n if (value !== undefined) values[breakpoint] = count(value, values.base!);\n }\n return values;\n};\n\nexport const effectiveValues = (values: Values): Record<GridBreakpoint, number> => {\n let current = values.base ?? 1;\n return Object.fromEntries(gridBreakpoints.map((breakpoint) => {\n current = values[breakpoint] ?? current;\n return [breakpoint, current];\n })) as Record<GridBreakpoint, number>;\n};\n\nexport const gridClasses = (attributes: GridAttributes): string[] => {\n const values = gridValues(attributes);\n const align = attributes.layout?.flowpressAlign;\n return [\n \"fp-grid\",\n ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),\n ...( [\"start\", \"center\", \"end\", \"stretch\"].includes(align) ? [`fp-align-${align}`] : []),\n ];\n};\n\nexport const spanClasses = (attributes: GridAttributes): string[] => {\n const values = spanValues(attributes);\n return [\"fp-grid-item\", ...gridBreakpoints.flatMap((breakpoint) =>\n values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : []\n )];\n};\n\nexport const usedSpanClasses = (parent: GridAttributes, child: GridAttributes): string[] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = effectiveValues(spanValues(child));\n return gridBreakpoints.map((breakpoint) =>\n `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`\n );\n};\n\nexport const bleedClasses = (parent: GridAttributes, children: GridAttributes[]): string[][] => {\n const columns = effectiveValues(gridValues(parent));\n const spans = children.map((child) => effectiveValues(spanValues(child)));\n const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? [\"fp-bleed-managed\"] : [] as string[]);\n for (const breakpoint of gridBreakpoints) {\n let position = 0;\n children.forEach((child, index) => {\n const width = Math.min(spans[index]![breakpoint], columns[breakpoint]);\n if (position + width > columns[breakpoint]) position = 0;\n const start = position === 0;\n const end = position + width === columns[breakpoint];\n const bleed = child.style?.layout?.flowpressGridBleed;\n const from = gridBreakpoints.indexOf(bleed?.from || \"base\");\n if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&\n ((bleed.side === \"start\" && start) || (bleed.side === \"end\" && end))) {\n result[index]!.push(`fp-bleed-${breakpoint}-${bleed.side}`);\n }\n position += width;\n if (position === columns[breakpoint]) position = 0;\n });\n }\n return result;\n};\n\nconst appendClasses = (attributes: GridAttributes, classes: string[]): GridAttributes => ({\n ...attributes,\n className: [...new Set([...(attributes.className || \"\").split(/\\s+/), ...classes].filter(Boolean))].join(\" \"),\n});\n\n/** Slot children occupy their own grid cells because the slot has no DOM root. */\nconst visibleChildren = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.flatMap((block) =>\n block.name === \"sf/slot\" ? visibleChildren(block.innerBlocks ?? []) : [block]\n);\n\nconst mapVisibleChildren = (\n blocks: FlowpressBlock[],\n decorate: (block: FlowpressBlock, index: number) => FlowpressBlock,\n cursor = { index: 0 }\n): FlowpressBlock[] => blocks.map((block) => block.name === \"sf/slot\"\n ? { ...block, innerBlocks: mapVisibleChildren(block.innerBlocks ?? [], decorate, cursor) }\n : decorate(block, cursor.index++)\n);\n\n/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */\nexport const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {\n const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;\n const attributes = (block.attributes || {}) as GridAttributes;\n if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;\n const children = visibleChildren(innerBlocks ?? []);\n const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));\n return {\n ...block,\n attributes: appendClasses({ layoutRole: \"stack\", density: \"regular\", ...attributes }, gridClasses(attributes)),\n innerBlocks: mapVisibleChildren(innerBlocks ?? [], (child, index) => ({\n ...child,\n attributes: appendClasses(child.attributes as GridAttributes || {}, [\n ...spanClasses(child.attributes as GridAttributes || {}),\n ...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),\n ...(bleed[index] ?? []),\n ]),\n })),\n };\n});\n"]}
|
|
@@ -96,17 +96,31 @@ const appendClasses = (attributes: GridAttributes, classes: string[]): GridAttri
|
|
|
96
96
|
className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
/** Slot children occupy their own grid cells because the slot has no DOM root. */
|
|
100
|
+
const visibleChildren = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.flatMap((block) =>
|
|
101
|
+
block.name === "sf/slot" ? visibleChildren(block.innerBlocks ?? []) : [block]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const mapVisibleChildren = (
|
|
105
|
+
blocks: FlowpressBlock[],
|
|
106
|
+
decorate: (block: FlowpressBlock, index: number) => FlowpressBlock,
|
|
107
|
+
cursor = { index: 0 }
|
|
108
|
+
): FlowpressBlock[] => blocks.map((block) => block.name === "sf/slot"
|
|
109
|
+
? { ...block, innerBlocks: mapVisibleChildren(block.innerBlocks ?? [], decorate, cursor) }
|
|
110
|
+
: decorate(block, cursor.index++)
|
|
111
|
+
);
|
|
112
|
+
|
|
99
113
|
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
100
114
|
export const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {
|
|
101
115
|
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
102
116
|
const attributes = (block.attributes || {}) as GridAttributes;
|
|
103
117
|
if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;
|
|
104
|
-
const children = innerBlocks ?? [];
|
|
118
|
+
const children = visibleChildren(innerBlocks ?? []);
|
|
105
119
|
const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));
|
|
106
120
|
return {
|
|
107
121
|
...block,
|
|
108
122
|
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
109
|
-
innerBlocks:
|
|
123
|
+
innerBlocks: mapVisibleChildren(innerBlocks ?? [], (child, index) => ({
|
|
110
124
|
...child,
|
|
111
125
|
attributes: appendClasses(child.attributes as GridAttributes || {}, [
|
|
112
126
|
...spanClasses(child.attributes as GridAttributes || {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAyCxE,eAAO,MAAM,oBAAoB,EAAE,uBA+ClC,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import NativeAccordion from "./core-accordion.astro";
|
|
2
|
+
import NativeAccordionItem from "./core-accordion-item.astro";
|
|
3
|
+
import NativeAccordionHeading from "./core-accordion-heading.astro";
|
|
4
|
+
import NativeAccordionPanel from "./core-accordion-panel.astro";
|
|
1
5
|
import Renderer0 from "./core-term-name.astro";
|
|
2
6
|
import Renderer2 from "./core-post-terms.astro";
|
|
3
7
|
import Renderer3 from "./core-button.astro";
|
|
@@ -36,12 +40,18 @@ import SeparatorBlock from "./core-separator.astro";
|
|
|
36
40
|
import SiteLogoBlock from "../blocks/SiteLogoBlock.astro";
|
|
37
41
|
import ThemeToggleBlock from "../blocks/ThemeToggleBlock.astro";
|
|
38
42
|
import ReservedLogin from "./ReservedLogin.astro";
|
|
43
|
+
import Slot from "./sf-slot.astro";
|
|
39
44
|
export const nativeBlockRenderers = {
|
|
45
|
+
"core/accordion": NativeAccordion,
|
|
46
|
+
"core/accordion-item": NativeAccordionItem,
|
|
47
|
+
"core/accordion-heading": NativeAccordionHeading,
|
|
48
|
+
"core/accordion-panel": NativeAccordionPanel,
|
|
40
49
|
"core/separator": SeparatorBlock,
|
|
41
50
|
"core/post-content": TransparentBlock,
|
|
42
51
|
"core/template-part": TransparentBlock,
|
|
43
52
|
"core/site-logo": SiteLogoBlock,
|
|
44
53
|
"sf/theme-toggle": ThemeToggleBlock,
|
|
54
|
+
"sf/slot": Slot,
|
|
45
55
|
"core/term-name": Renderer0,
|
|
46
56
|
"core/post-terms": Renderer2,
|
|
47
57
|
"core/button": Renderer3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAEhE,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,UAAU,MAAM,mBAAmB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E,mBAAmB;IAC1C,wBAAwB,EAAE,sBAAsB;IAChD,sBAAsB,EAAE,oBAAoB;IAE5C,gBAAgB,EAAE,cAAc;IAChC,mBAAmB,EAAE,gBAAgB;IACrC,oBAAoB,EAAE,gBAAgB;IACtC,gBAAgB,EAAE,aAAa;IAC/B,iBAAiB,EAAE,gBAAgB;IACnC,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,SAAS;IAC3B,iBAAiB,EAAE,SAAS;IAC5B,aAAa,EAAE,SAAS;IACxB,gBAAgB,EAAE,SAAS;IAC3B,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,SAAS;IAC9B,uBAAuB,EAAE,SAAS;IAClC,oBAAoB,EAAE,SAAS;IAC/B,YAAY,EAAE,SAAS;IACvB,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,UAAU;IACxB,iBAAiB,EAAE,UAAU;IAC7B,0BAA0B,EAAE,UAAU;IACtC,gBAAgB,EAAE,UAAU;IAC5B,kBAAkB,EAAE,UAAU;IAC9B,cAAc,EAAE,UAAU;IAC1B,YAAY,EAAE,UAAU;IACxB,iBAAiB,EAAE,aAAa;IAChC,+BAA+B,EAAE,aAAa;IAC9C,uBAAuB,EAAE,UAAU;IACnC,oBAAoB,EAAE,UAAU;IAChC,iBAAiB,EAAE,UAAU;IAC7B,yBAAyB,EAAE,UAAU;IACrC,YAAY,EAAE,UAAU;IACxB,gBAAgB,EAAE,UAAU;IAC5B,qBAAqB,EAAE,UAAU;IACjC,sBAAsB,EAAE,UAAU;IAClC,iBAAiB,EAAE,UAAU;IAC7B,eAAe,EAAE,UAAU;IAC3B,kBAAkB,EAAE,UAAU;IAC9B,eAAe,EAAE,UAAU;IAC3B,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,UAAU;IACzB,kBAAkB,EAAE,iBAAiB;CACtC,CAAC","sourcesContent":["import NativeAccordion from \"./core-accordion.astro\";\nimport NativeAccordionItem from \"./core-accordion-item.astro\";\nimport NativeAccordionHeading from \"./core-accordion-heading.astro\";\nimport NativeAccordionPanel from \"./core-accordion-panel.astro\";\nimport type { FlowpressBlockRenderers } from \"../../block-renderers.js\";\nimport Renderer0 from \"./core-term-name.astro\";\nimport Renderer2 from \"./core-post-terms.astro\";\nimport Renderer3 from \"./core-button.astro\";\nimport Renderer4 from \"./core-post-date.astro\";\nimport Renderer5 from \"./core-icon.astro\";\nimport Renderer6 from \"./core-post-excerpt.astro\";\nimport Renderer7 from \"./core-term-description.astro\";\nimport Renderer8 from \"./core-post-template.astro\";\nimport Renderer9 from \"./core-group.astro\";\nimport Renderer10 from \"./core-html.astro\";\nimport Renderer11 from \"./core-block.astro\";\nimport Renderer12 from \"./core-site-title.astro\";\nimport Renderer13 from \"./core-post-featured-image.astro\";\nimport Renderer14 from \"./core-page-list.astro\";\nimport Renderer15 from \"./core-terms-query.astro\";\nimport Renderer16 from \"./core-buttons.astro\";\nimport Renderer17 from \"./core-image.astro\";\nimport Renderer18 from \"./core-query-no-results.astro\";\nimport Renderer19 from \"./core-term-template.astro\";\nimport Renderer20 from \"./core-navigation.astro\";\nimport Renderer21 from \"./core-navigation-submenu.astro\";\nimport Renderer22 from \"./core-query.astro\";\nimport Renderer23 from \"./core-home-link.astro\";\nimport Renderer24 from \"./core-page-list-item.astro\";\nimport Renderer25 from \"./core-navigation-link.astro\";\nimport Renderer26 from \"./core-post-title.astro\";\nimport Renderer27 from \"./sf-post-field.astro\";\nimport Renderer28 from \"./sf-block-binding.astro\";\nimport Renderer29 from \"./sf-term-field.astro\";\nimport Renderer30 from \"./MapBlock.astro\";\nimport Renderer31 from \"./ProjectTimelineBlock.astro\";\nimport TimelineCardBlock from \"./TimelineCardBlock.astro\";\nimport BlobBlock from \"./BlobBlock.astro\";\nimport TransparentBlock from \"./core-transparent.astro\";\nimport SeparatorBlock from \"./core-separator.astro\";\nimport SiteLogoBlock from \"../blocks/SiteLogoBlock.astro\";\nimport ThemeToggleBlock from \"../blocks/ThemeToggleBlock.astro\";\nimport ReservedLogin from \"./ReservedLogin.astro\";\nimport Slot from \"./sf-slot.astro\";\n\nexport const nativeBlockRenderers: FlowpressBlockRenderers = {\n \"core/accordion\": NativeAccordion,\n \"core/accordion-item\": NativeAccordionItem,\n \"core/accordion-heading\": NativeAccordionHeading,\n \"core/accordion-panel\": NativeAccordionPanel,\n\n \"core/separator\": SeparatorBlock,\n \"core/post-content\": TransparentBlock,\n \"core/template-part\": TransparentBlock,\n \"core/site-logo\": SiteLogoBlock,\n \"sf/theme-toggle\": ThemeToggleBlock,\n \"sf/slot\": Slot,\n \"core/term-name\": Renderer0,\n \"core/post-terms\": Renderer2,\n \"core/button\": Renderer3,\n \"core/post-date\": Renderer4,\n \"core/icon\": Renderer5,\n \"core/post-excerpt\": Renderer6,\n \"core/term-description\": Renderer7,\n \"core/post-template\": Renderer8,\n \"core/group\": Renderer9,\n \"core/html\": Renderer10,\n \"core/block\": Renderer11,\n \"core/site-title\": Renderer12,\n \"core/post-featured-image\": Renderer13,\n \"core/page-list\": Renderer14,\n \"core/terms-query\": Renderer15,\n \"core/buttons\": Renderer16,\n \"core/image\": Renderer17,\n \"flowpress/login\": ReservedLogin,\n \"flowpress/reserved-pagination\": ReservedLogin,\n \"core/query-no-results\": Renderer18,\n \"core/term-template\": Renderer19,\n \"core/navigation\": Renderer20,\n \"core/navigation-submenu\": Renderer21,\n \"core/query\": Renderer22,\n \"core/home-link\": Renderer23,\n \"core/page-list-item\": Renderer24,\n \"core/navigation-link\": Renderer25,\n \"core/post-title\": Renderer26,\n \"sf/post-field\": Renderer27,\n \"sf/block-binding\": Renderer28,\n \"sf/term-field\": Renderer29,\n \"sf/blob\": BlobBlock,\n \"sf/map\": Renderer30,\n \"sf/timeline\": Renderer31,\n \"sf/timeline-card\": TimelineCardBlock,\n};\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import NativeAccordion from "./core-accordion.astro";
|
|
2
|
+
import NativeAccordionItem from "./core-accordion-item.astro";
|
|
3
|
+
import NativeAccordionHeading from "./core-accordion-heading.astro";
|
|
4
|
+
import NativeAccordionPanel from "./core-accordion-panel.astro";
|
|
1
5
|
import type { FlowpressBlockRenderers } from "../../block-renderers.js";
|
|
2
6
|
import Renderer0 from "./core-term-name.astro";
|
|
3
7
|
import Renderer2 from "./core-post-terms.astro";
|
|
@@ -37,13 +41,20 @@ import SeparatorBlock from "./core-separator.astro";
|
|
|
37
41
|
import SiteLogoBlock from "../blocks/SiteLogoBlock.astro";
|
|
38
42
|
import ThemeToggleBlock from "../blocks/ThemeToggleBlock.astro";
|
|
39
43
|
import ReservedLogin from "./ReservedLogin.astro";
|
|
44
|
+
import Slot from "./sf-slot.astro";
|
|
40
45
|
|
|
41
46
|
export const nativeBlockRenderers: FlowpressBlockRenderers = {
|
|
47
|
+
"core/accordion": NativeAccordion,
|
|
48
|
+
"core/accordion-item": NativeAccordionItem,
|
|
49
|
+
"core/accordion-heading": NativeAccordionHeading,
|
|
50
|
+
"core/accordion-panel": NativeAccordionPanel,
|
|
51
|
+
|
|
42
52
|
"core/separator": SeparatorBlock,
|
|
43
53
|
"core/post-content": TransparentBlock,
|
|
44
54
|
"core/template-part": TransparentBlock,
|
|
45
55
|
"core/site-logo": SiteLogoBlock,
|
|
46
56
|
"sf/theme-toggle": ThemeToggleBlock,
|
|
57
|
+
"sf/slot": Slot,
|
|
47
58
|
"core/term-name": Renderer0,
|
|
48
59
|
"core/post-terms": Renderer2,
|
|
49
60
|
"core/button": Renderer3,
|
package/dist/default-blocks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAuFD,eAAO,MAAM,4BAA4B,EAAE,SAAS,iCAAiC,EACc,CAAC;AAIpG,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA+BlF"}
|
package/dist/default-blocks.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = "
|
|
1
|
+
export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = "8";
|
|
2
2
|
const blockNames = [
|
|
3
|
+
"core/accordion",
|
|
4
|
+
"core/accordion-item",
|
|
5
|
+
"core/accordion-heading",
|
|
6
|
+
"core/accordion-panel",
|
|
3
7
|
"core/separator",
|
|
4
8
|
"core/post-content",
|
|
5
9
|
"core/site-logo",
|
|
@@ -72,6 +76,7 @@ const blockNames = [
|
|
|
72
76
|
"sf/quote",
|
|
73
77
|
"sf/rich-text",
|
|
74
78
|
"sf/section",
|
|
79
|
+
"sf/slot",
|
|
75
80
|
"sf/template",
|
|
76
81
|
"sf/term-list",
|
|
77
82
|
"sf/video",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,eAAe;IACf,SAAS;IACT,UAAU;IACV,YAAY;IACZ,eAAe;IACf,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AwC,CAAC,SAAiB;IACxE,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO;;;;;;;;;;;;;;;CAeV,CAAC;IACA,CAAC;IACD,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC","sourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"
|
|
1
|
+
{"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,wBAAwB;IACxB,sBAAsB;IACtB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,eAAe;IACf,SAAS;IACT,UAAU;IACV,YAAY;IACZ,eAAe;IACf,iBAAiB;IAEjB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,iBAAiB;IACjB,+BAA+B;IAC/B,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,iBAAiB;IACjB,yBAAyB;IACzB,YAAY;IACZ,gBAAgB;IAChB,qBAAqB;IACrB,sBAAsB;IACtB,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,eAAe;IACf,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,SAAS;IACT,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,kBAAkB;IAClB,QAAQ;IACR,mBAAmB;IACnB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,SAAS;IACT,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GACvC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;AAEpG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,UAAU,CAAC,CAAC;AAE9C,MAAM,UAAU,+BAA+B,CAAC,SAAiB;IAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wCAAwC,CAAC,SAAiB;IACxE,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO;;;;;;;;;;;;;;;CAeV,CAAC;IACA,CAAC;IACD,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC","sourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"8\" as const;\n\nexport interface FlowpressDefaultBlockCatalogEntry {\n blockName: string;\n template: \"DefaultBlockAdapter.astro\";\n}\n\nconst blockNames = [\n \"core/accordion\",\n \"core/accordion-item\",\n \"core/accordion-heading\",\n \"core/accordion-panel\",\n \"core/separator\",\n \"core/post-content\",\n \"core/site-logo\",\n \"core/template-part\",\n \"sf/accordion\",\n \"sf/collection\",\n \"sf/flex\",\n \"sf/group\",\n \"sf/marquee\",\n \"sf/media-text\",\n \"sf/theme-toggle\",\n\n \"core/term-name\",\n \"core/post-terms\",\n \"core/button\",\n \"flowpress/login\",\n \"flowpress/reserved-pagination\",\n \"core/post-date\",\n \"core/icon\",\n \"core/post-excerpt\",\n \"core/term-description\",\n \"core/post-template\",\n \"core/html\",\n \"core/block\",\n \"core/site-title\",\n \"core/post-featured-image\",\n \"core/page-list\",\n \"core/terms-query\",\n \"core/buttons\",\n \"core/image\",\n \"core/query-no-results\",\n \"core/term-template\",\n \"core/navigation\",\n \"core/navigation-submenu\",\n \"core/query\",\n \"core/home-link\",\n \"core/page-list-item\",\n \"core/navigation-link\",\n \"core/post-title\",\n \"sf/post-field\",\n \"sf/block-binding\",\n \"sf/term-field\",\n \"sf/timeline\",\n \"core/cover\",\n \"core/group\",\n \"core/heading\",\n \"core/list\",\n \"core/list-item\",\n \"core/paragraph\",\n \"core/quote\",\n \"sf/accordion-item\",\n \"sf/button\",\n \"sf/card\",\n \"sf/carousel\",\n \"sf/carousel-item\",\n \"sf/chip\",\n \"sf/code\",\n \"sf/column\",\n \"sf/content-list\",\n \"sf/form\",\n \"sf/gallery\",\n \"sf/grid\",\n \"sf/heading\",\n \"sf/hero\",\n \"sf/icon\",\n \"sf/image\",\n \"sf/blob\",\n \"sf/timeline-card\",\n \"sf/map\",\n \"sf/number-spinner\",\n \"sf/quote\",\n \"sf/rich-text\",\n \"sf/section\",\n \"sf/slot\",\n \"sf/template\",\n \"sf/term-list\",\n \"sf/video\",\n \"sf/video-youtube\"\n] as const;\n\nexport const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[] =\n [...blockNames].sort().map((blockName) => ({ blockName, template: \"DefaultBlockAdapter.astro\" }));\n\nconst supported = new Set<string>(blockNames);\n\nexport function hasFlowpressDefaultBlockAdapter(blockName: string): boolean {\n return supported.has(blockName);\n}\n\nexport function createFlowpressDefaultBlockAdapterSource(blockName: string): string {\n if (!hasFlowpressDefaultBlockAdapter(blockName)) {\n throw new Error(`FlowPress has no official default adapter for ${blockName}.`);\n }\n if (blockName === \"core/cover\") {\n return `---\nimport CoverBlock from \"@styleflow.app/flowpress-astro-core/blocks/CoverBlock.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst { block, contract, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;\n---\n\n<CoverBlock\n block={block}\n contract={contract}\n htmlProps={htmlProps}\n styleflowProps={styleflowProps}\n>\n <slot />\n</CoverBlock>\n`;\n }\n return `---\nimport DefaultBlockAdapter from \"@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst props = Astro.props as FlowpressBlockRendererProps;\n---\n\n<DefaultBlockAdapter {...props} />\n`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/build-cache.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/reserved-area.ts","../src/style-classes.ts","../src/styleflow.ts","../src/svg-media-types.ts","../src/svg-media.ts","../src/template-hierarchy.ts","../src/text.ts","../src/theme-runtime.ts","../src/types.ts","../src/vivid-colors-preference.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/motion/accordion.ts","../src/astro/motion/motion-controller.ts","../src/astro/motion/motion.ts","../src/astro/native/button-template.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/group.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/image.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-carousel.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts","../src/svg-media-runtime.js","../src/astro/native/grid-bleed.js"],"version":"5.9.3"}
|
|
1
|
+
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/build-cache.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/reserved-area.ts","../src/style-classes.ts","../src/styleflow.ts","../src/svg-media-types.ts","../src/svg-media.ts","../src/template-hierarchy.ts","../src/text.ts","../src/theme-runtime.ts","../src/types.ts","../src/vivid-colors-preference.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/motion/accordion.ts","../src/astro/motion/motion-controller.ts","../src/astro/motion/motion.ts","../src/astro/native/accordion-controller.ts","../src/astro/native/accordion.ts","../src/astro/native/button-template.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/group.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/image.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-carousel.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts","../src/svg-media-runtime.js","../src/astro/native/grid-bleed.js"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleflow.app/flowpress-astro-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.48",
|
|
4
4
|
"description": "Project-agnostic WordPress routing, templates, SEO and GraphQL runtime for FlowPress Astro apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@splidejs/splide": "4.1.4",
|
|
97
97
|
"@styleflow.app/astro": "1.0.0-beta.11",
|
|
98
|
-
"@styleflow.app/flowpress-components": "1.0.0-beta.
|
|
98
|
+
"@styleflow.app/flowpress-components": "1.0.0-beta.20",
|
|
99
99
|
"entities": "8.1.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|