@styleflow.app/flowpress-astro-core 1.0.0-beta.4 → 1.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +242 -1
- package/README.md +104 -5
- package/dist/accessibility-panel.d.ts +2 -0
- package/dist/accessibility-panel.d.ts.map +1 -0
- package/dist/accessibility-panel.js +81 -0
- package/dist/accessibility-panel.js.map +1 -0
- package/dist/astro/BaseLayout.astro +34 -17
- package/dist/astro/CompositionRenderer.astro +168 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +267 -80
- package/dist/astro/Media.astro +24 -0
- package/dist/astro/StyleflowElement.astro +24 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +11 -10
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +169 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +6 -4
- package/dist/astro/blocks/HeroBlock.astro +6 -6
- package/dist/astro/blocks/ImageBlock.astro +6 -6
- package/dist/astro/blocks/ListItemFallback.astro +9 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
- package/dist/astro/blocks/TextBlock.astro +33 -28
- package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
- package/dist/astro/blocks/cover.d.ts +13 -0
- package/dist/astro/blocks/cover.d.ts.map +1 -0
- package/dist/astro/blocks/cover.js +105 -0
- package/dist/astro/blocks/cover.js.map +1 -0
- package/dist/astro/blocks/cover.ts +119 -0
- package/dist/astro/blocks/helpers.d.ts +10 -1
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +55 -39
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +69 -44
- package/dist/astro/motion/AccordionRuntime.astro +9 -0
- package/dist/astro/motion/MotionBoot.astro +21 -0
- package/dist/astro/motion/MotionRuntime.astro +31 -0
- package/dist/astro/motion/accordion.css +163 -0
- package/dist/astro/motion/accordion.d.ts +3 -0
- package/dist/astro/motion/accordion.d.ts.map +1 -0
- package/dist/astro/motion/accordion.js +98 -0
- package/dist/astro/motion/accordion.js.map +1 -0
- package/dist/astro/motion/accordion.ts +109 -0
- package/dist/astro/motion/motion-controller.d.ts +12 -0
- package/dist/astro/motion/motion-controller.d.ts.map +1 -0
- package/dist/astro/motion/motion-controller.js +293 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +377 -0
- package/dist/astro/motion/motion.css +546 -0
- package/dist/astro/motion/motion.d.ts +127 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +255 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +419 -0
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +88 -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 +42 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ReservedLogin.astro +107 -0
- package/dist/astro/native/ResolvedBlocks.astro +91 -0
- package/dist/astro/native/SyncedPatternContent.astro +94 -0
- package/dist/astro/native/TermFieldValue.astro +39 -0
- package/dist/astro/native/Timeline.astro +22 -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-template.d.ts +31 -0
- package/dist/astro/native/button-template.d.ts.map +1 -0
- package/dist/astro/native/button-template.js +54 -0
- package/dist/astro/native/button-template.js.map +1 -0
- package/dist/astro/native/button-template.ts +92 -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-fallback.astro +43 -0
- package/dist/astro/native/core-button.astro +65 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +25 -0
- package/dist/astro/native/core-home-link.astro +12 -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 +139 -0
- package/dist/astro/native/core-navigation-link.astro +71 -0
- package/dist/astro/native/core-navigation-submenu.astro +33 -0
- package/dist/astro/native/core-navigation.astro +101 -0
- package/dist/astro/native/core-page-list-data-item.astro +19 -0
- package/dist/astro/native/core-page-list-item.astro +8 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +21 -0
- package/dist/astro/native/core-post-excerpt.astro +26 -0
- package/dist/astro/native/core-post-featured-image.astro +38 -0
- package/dist/astro/native/core-post-template-fallback.astro +30 -0
- package/dist/astro/native/core-post-template.astro +23 -0
- package/dist/astro/native/core-post-terms.astro +47 -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-separator.astro +20 -0
- package/dist/astro/native/core-site-title.astro +16 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +21 -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/core-transparent.astro +11 -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.d.ts +2 -0
- package/dist/astro/native/grid-bleed.d.ts.map +1 -0
- package/dist/astro/native/grid-bleed.js +123 -0
- package/dist/astro/native/grid-bleed.js.map +1 -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/group.css +36 -0
- package/dist/astro/native/group.d.ts +15 -0
- package/dist/astro/native/group.d.ts.map +1 -0
- package/dist/astro/native/group.js +66 -0
- package/dist/astro/native/group.js.map +1 -0
- package/dist/astro/native/group.ts +61 -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/image.d.ts +5 -0
- package/dist/astro/native/image.d.ts.map +1 -0
- package/dist/astro/native/image.js +65 -0
- package/dist/astro/native/image.js.map +1 -0
- package/dist/astro/native/image.ts +56 -0
- package/dist/astro/native/inline-text.css +15 -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-carousel.d.ts +12 -0
- package/dist/astro/native/query-carousel.d.ts.map +1 -0
- package/dist/astro/native/query-carousel.js +36 -0
- package/dist/astro/native/query-carousel.js.map +1 -0
- package/dist/astro/native/query-carousel.ts +56 -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 +81 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +82 -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/astro/preferences/AccessibilityPanel.astro +105 -0
- package/dist/astro/preferences/ColorModeToggle.astro +26 -0
- package/dist/astro/preferences/MotionToggle.astro +27 -0
- package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
- package/dist/astro/preferences/ThemeToggle.astro +30 -0
- package/dist/astro/preferences/Toggle.astro +50 -0
- package/dist/astro/preferences/preferences.css +125 -0
- package/dist/block-renderers.d.ts +23 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +81 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/client.d.ts +23 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +78 -39
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +125 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +117 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +106 -0
- package/dist/media.js.map +1 -0
- package/dist/motion-preference.d.ts +50 -0
- package/dist/motion-preference.d.ts.map +1 -0
- package/dist/motion-preference.js +132 -0
- package/dist/motion-preference.js.map +1 -0
- package/dist/preferences-runtime.d.ts +3 -0
- package/dist/preferences-runtime.d.ts.map +1 -0
- package/dist/preferences-runtime.js +23 -0
- package/dist/preferences-runtime.js.map +1 -0
- package/dist/preferences-styleflow.d.ts +3 -0
- package/dist/preferences-styleflow.d.ts.map +1 -0
- package/dist/preferences-styleflow.js +14 -0
- package/dist/preferences-styleflow.js.map +1 -0
- package/dist/preferences.d.ts +4 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +4 -0
- package/dist/preferences.js.map +1 -0
- package/dist/reserved-area.d.ts +10 -0
- package/dist/reserved-area.d.ts.map +1 -0
- package/dist/reserved-area.js +93 -0
- package/dist/reserved-area.js.map +1 -0
- package/dist/styleflow.d.ts +18 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +82 -11
- package/dist/styleflow.js.map +1 -1
- package/dist/svg-media-runtime.d.ts +3 -0
- package/dist/svg-media-runtime.d.ts.map +1 -0
- package/dist/svg-media-runtime.js +33 -0
- package/dist/svg-media-runtime.js.map +1 -0
- package/dist/svg-media-types.d.ts +11 -0
- package/dist/svg-media-types.d.ts.map +1 -0
- package/dist/svg-media-types.js +2 -0
- package/dist/svg-media-types.js.map +1 -0
- package/dist/svg-media.d.ts +13 -0
- package/dist/svg-media.d.ts.map +1 -0
- package/dist/svg-media.js +47 -0
- package/dist/svg-media.js.map +1 -0
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- package/dist/text.d.ts +3 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +6 -0
- package/dist/text.js.map +1 -0
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +100 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vivid-colors-preference.d.ts +31 -0
- package/dist/vivid-colors-preference.d.ts.map +1 -0
- package/dist/vivid-colors-preference.js +102 -0
- package/dist/vivid-colors-preference.js.map +1 -0
- package/package.json +58 -7
- package/dist/astro/DefaultTemplate.astro +0 -42
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const gridBreakpoints = ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
2
|
+
const count = (value, fallback) => {
|
|
3
|
+
const n = Number(value);
|
|
4
|
+
return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;
|
|
5
|
+
};
|
|
6
|
+
export const isGrid = (name, attributes = {}) => (name === "core/group" || name === "core/post-template" || name === "core/term-template")
|
|
7
|
+
&& attributes.layout?.type === "grid";
|
|
8
|
+
export const gridValues = (attributes) => {
|
|
9
|
+
const layout = attributes.layout || {};
|
|
10
|
+
const values = { base: count(layout.columnCount, 1) };
|
|
11
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
12
|
+
const value = layout.flowpressColumns?.[breakpoint];
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
values[breakpoint] = count(value, values.base);
|
|
15
|
+
}
|
|
16
|
+
return values;
|
|
17
|
+
};
|
|
18
|
+
export const spanValues = (attributes) => {
|
|
19
|
+
const layout = attributes.style?.layout || {};
|
|
20
|
+
const values = { base: count(layout.columnSpan, 1) };
|
|
21
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
22
|
+
const value = layout.flowpressGridSpan?.[breakpoint];
|
|
23
|
+
if (value !== undefined)
|
|
24
|
+
values[breakpoint] = count(value, values.base);
|
|
25
|
+
}
|
|
26
|
+
return values;
|
|
27
|
+
};
|
|
28
|
+
export const effectiveValues = (values) => {
|
|
29
|
+
let current = values.base ?? 1;
|
|
30
|
+
return Object.fromEntries(gridBreakpoints.map((breakpoint) => {
|
|
31
|
+
current = values[breakpoint] ?? current;
|
|
32
|
+
return [breakpoint, current];
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
export const gridClasses = (attributes) => {
|
|
36
|
+
const values = gridValues(attributes);
|
|
37
|
+
const align = attributes.layout?.flowpressAlign;
|
|
38
|
+
return [
|
|
39
|
+
"fp-grid",
|
|
40
|
+
...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),
|
|
41
|
+
...(["start", "center", "end", "stretch"].includes(align) ? [`fp-align-${align}`] : []),
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
export const spanClasses = (attributes) => {
|
|
45
|
+
const values = spanValues(attributes);
|
|
46
|
+
return ["fp-grid-item", ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : [])];
|
|
47
|
+
};
|
|
48
|
+
export const usedSpanClasses = (parent, child) => {
|
|
49
|
+
const columns = effectiveValues(gridValues(parent));
|
|
50
|
+
const spans = effectiveValues(spanValues(child));
|
|
51
|
+
return gridBreakpoints.map((breakpoint) => `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`);
|
|
52
|
+
};
|
|
53
|
+
export const bleedClasses = (parent, children) => {
|
|
54
|
+
const columns = effectiveValues(gridValues(parent));
|
|
55
|
+
const spans = children.map((child) => effectiveValues(spanValues(child)));
|
|
56
|
+
const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? ["fp-bleed-managed"] : []);
|
|
57
|
+
for (const breakpoint of gridBreakpoints) {
|
|
58
|
+
let position = 0;
|
|
59
|
+
children.forEach((child, index) => {
|
|
60
|
+
const width = Math.min(spans[index][breakpoint], columns[breakpoint]);
|
|
61
|
+
if (position + width > columns[breakpoint])
|
|
62
|
+
position = 0;
|
|
63
|
+
const start = position === 0;
|
|
64
|
+
const end = position + width === columns[breakpoint];
|
|
65
|
+
const bleed = child.style?.layout?.flowpressGridBleed;
|
|
66
|
+
const from = gridBreakpoints.indexOf(bleed?.from || "base");
|
|
67
|
+
if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&
|
|
68
|
+
((bleed.side === "start" && start) || (bleed.side === "end" && end))) {
|
|
69
|
+
result[index].push(`fp-bleed-${breakpoint}-${bleed.side}`);
|
|
70
|
+
}
|
|
71
|
+
position += width;
|
|
72
|
+
if (position === columns[breakpoint])
|
|
73
|
+
position = 0;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
const appendClasses = (attributes, classes) => ({
|
|
79
|
+
...attributes,
|
|
80
|
+
className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
|
|
81
|
+
});
|
|
82
|
+
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
83
|
+
export const decorateGridBlocks = (blocks) => blocks.map((block) => {
|
|
84
|
+
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
85
|
+
const attributes = (block.attributes || {});
|
|
86
|
+
if (!isGrid(block.name, attributes))
|
|
87
|
+
return innerBlocks ? { ...block, innerBlocks } : block;
|
|
88
|
+
const children = innerBlocks ?? [];
|
|
89
|
+
const bleed = bleedClasses(attributes, children.map((child) => child.attributes || {}));
|
|
90
|
+
return {
|
|
91
|
+
...block,
|
|
92
|
+
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
93
|
+
innerBlocks: children.map((child, index) => ({
|
|
94
|
+
...child,
|
|
95
|
+
attributes: appendClasses(child.attributes || {}, [
|
|
96
|
+
...spanClasses(child.attributes || {}),
|
|
97
|
+
...usedSpanClasses(attributes, child.attributes || {}),
|
|
98
|
+
...(bleed[index] ?? []),
|
|
99
|
+
]),
|
|
100
|
+
})),
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +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,EAAE,EAAW,EAAE,CAC/E,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;OACtF,UAAU,CAAC,MAAM,EAAE,IAAI,KAAK,MAAM,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAA0B,EAAU,EAAE;IAC/D,MAAM,MAAM,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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"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { FlowpressBlock } from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export const gridBreakpoints = ["base", "sm", "md", "lg", "xl", "2xl"] as const;
|
|
4
|
+
export type GridBreakpoint = typeof gridBreakpoints[number];
|
|
5
|
+
type Values = Partial<Record<GridBreakpoint, number>>;
|
|
6
|
+
type GridAttributes = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
const count = (value: unknown, fallback: number): number => {
|
|
9
|
+
const n = Number(value);
|
|
10
|
+
return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const isGrid = (name: string, attributes: GridAttributes = {}): boolean =>
|
|
14
|
+
(name === "core/group" || name === "core/post-template" || name === "core/term-template")
|
|
15
|
+
&& attributes.layout?.type === "grid";
|
|
16
|
+
|
|
17
|
+
export const gridValues = (attributes: GridAttributes): Values => {
|
|
18
|
+
const layout = attributes.layout || {};
|
|
19
|
+
const values: Values = { base: count(layout.columnCount, 1) };
|
|
20
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
21
|
+
const value = layout.flowpressColumns?.[breakpoint];
|
|
22
|
+
if (value !== undefined) values[breakpoint] = count(value, values.base!);
|
|
23
|
+
}
|
|
24
|
+
return values;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const spanValues = (attributes: GridAttributes): Values => {
|
|
28
|
+
const layout = attributes.style?.layout || {};
|
|
29
|
+
const values: Values = { base: count(layout.columnSpan, 1) };
|
|
30
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
31
|
+
const value = layout.flowpressGridSpan?.[breakpoint];
|
|
32
|
+
if (value !== undefined) values[breakpoint] = count(value, values.base!);
|
|
33
|
+
}
|
|
34
|
+
return values;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const effectiveValues = (values: Values): Record<GridBreakpoint, number> => {
|
|
38
|
+
let current = values.base ?? 1;
|
|
39
|
+
return Object.fromEntries(gridBreakpoints.map((breakpoint) => {
|
|
40
|
+
current = values[breakpoint] ?? current;
|
|
41
|
+
return [breakpoint, current];
|
|
42
|
+
})) as Record<GridBreakpoint, number>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const gridClasses = (attributes: GridAttributes): string[] => {
|
|
46
|
+
const values = gridValues(attributes);
|
|
47
|
+
const align = attributes.layout?.flowpressAlign;
|
|
48
|
+
return [
|
|
49
|
+
"fp-grid",
|
|
50
|
+
...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),
|
|
51
|
+
...( ["start", "center", "end", "stretch"].includes(align) ? [`fp-align-${align}`] : []),
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const spanClasses = (attributes: GridAttributes): string[] => {
|
|
56
|
+
const values = spanValues(attributes);
|
|
57
|
+
return ["fp-grid-item", ...gridBreakpoints.flatMap((breakpoint) =>
|
|
58
|
+
values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : []
|
|
59
|
+
)];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const usedSpanClasses = (parent: GridAttributes, child: GridAttributes): string[] => {
|
|
63
|
+
const columns = effectiveValues(gridValues(parent));
|
|
64
|
+
const spans = effectiveValues(spanValues(child));
|
|
65
|
+
return gridBreakpoints.map((breakpoint) =>
|
|
66
|
+
`fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const bleedClasses = (parent: GridAttributes, children: GridAttributes[]): string[][] => {
|
|
71
|
+
const columns = effectiveValues(gridValues(parent));
|
|
72
|
+
const spans = children.map((child) => effectiveValues(spanValues(child)));
|
|
73
|
+
const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? ["fp-bleed-managed"] : [] as string[]);
|
|
74
|
+
for (const breakpoint of gridBreakpoints) {
|
|
75
|
+
let position = 0;
|
|
76
|
+
children.forEach((child, index) => {
|
|
77
|
+
const width = Math.min(spans[index]![breakpoint], columns[breakpoint]);
|
|
78
|
+
if (position + width > columns[breakpoint]) position = 0;
|
|
79
|
+
const start = position === 0;
|
|
80
|
+
const end = position + width === columns[breakpoint];
|
|
81
|
+
const bleed = child.style?.layout?.flowpressGridBleed;
|
|
82
|
+
const from = gridBreakpoints.indexOf(bleed?.from || "base");
|
|
83
|
+
if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&
|
|
84
|
+
((bleed.side === "start" && start) || (bleed.side === "end" && end))) {
|
|
85
|
+
result[index]!.push(`fp-bleed-${breakpoint}-${bleed.side}`);
|
|
86
|
+
}
|
|
87
|
+
position += width;
|
|
88
|
+
if (position === columns[breakpoint]) position = 0;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const appendClasses = (attributes: GridAttributes, classes: string[]): GridAttributes => ({
|
|
95
|
+
...attributes,
|
|
96
|
+
className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
100
|
+
export const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {
|
|
101
|
+
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
102
|
+
const attributes = (block.attributes || {}) as GridAttributes;
|
|
103
|
+
if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;
|
|
104
|
+
const children = innerBlocks ?? [];
|
|
105
|
+
const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));
|
|
106
|
+
return {
|
|
107
|
+
...block,
|
|
108
|
+
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
109
|
+
innerBlocks: children.map((child, index) => ({
|
|
110
|
+
...child,
|
|
111
|
+
attributes: appendClasses(child.attributes as GridAttributes || {}, [
|
|
112
|
+
...spanClasses(child.attributes as GridAttributes || {}),
|
|
113
|
+
...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),
|
|
114
|
+
...(bleed[index] ?? []),
|
|
115
|
+
]),
|
|
116
|
+
})),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* Native layout selectors have zero specificity. Authored classes win.
|
|
2
|
+
StyleFlow recipes belong in the styleflow layer; utilities are unlayered. */
|
|
3
|
+
:where(.fp-native-group) { gap: var(--fp-group-default-gap, normal); }
|
|
4
|
+
/* No gap also cancels Gutenberg layout rules and inline gaps. */
|
|
5
|
+
.fp-native-group[data-sf-no-gap="true"] { gap: 0 !important; }
|
|
6
|
+
:where(.fp-native-group:not([data-fp-group-layout="grid"])) { display: flex; flex-direction: column; flex-wrap: nowrap; }
|
|
7
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"]) { flex-direction: row; align-items: center; }
|
|
8
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"]) { align-items: flex-start; }
|
|
9
|
+
:where(.fp-native-group[data-fp-group-wrap="wrap"]) { flex-wrap: wrap; }
|
|
10
|
+
:where(.fp-native-group[data-fp-group-wrap="nowrap"]) { flex-wrap: nowrap; }
|
|
11
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-justify="left"]) { justify-content: flex-start; }
|
|
12
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-justify="center"]) { justify-content: center; }
|
|
13
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-justify="right"]) { justify-content: flex-end; }
|
|
14
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-justify="space-between"]) { justify-content: space-between; }
|
|
15
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-align="top"]) { align-items: flex-start; }
|
|
16
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-align="center"]) { align-items: center; }
|
|
17
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-align="bottom"]) { align-items: flex-end; }
|
|
18
|
+
:where(.fp-native-group[data-fp-group-layout="horizontal"][data-fp-group-align="stretch"]) { align-items: stretch; }
|
|
19
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-justify="left"]) { align-items: flex-start; }
|
|
20
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-justify="center"]) { align-items: center; }
|
|
21
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-justify="right"]) { align-items: flex-end; }
|
|
22
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-justify="stretch"]) { align-items: stretch; }
|
|
23
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-align="top"]) { justify-content: flex-start; }
|
|
24
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-align="center"]) { justify-content: center; }
|
|
25
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-align="bottom"]) { justify-content: flex-end; }
|
|
26
|
+
:where(.fp-native-group[data-fp-group-layout="vertical"][data-fp-group-align="space-between"]) { justify-content: space-between; }
|
|
27
|
+
:where(.fp-native-group[data-fp-group-row-gap="true"]) { row-gap: var(--fp-group-row-gap); }
|
|
28
|
+
:where(.fp-native-group[data-fp-group-column-gap="true"]) { column-gap: var(--fp-group-column-gap); }
|
|
29
|
+
:where(.fp-native-group[data-fp-group-layout="constrained"]) > :where(:not(.alignwide):not(.alignfull)) { max-width: var(--fp-group-content-size, var(--wp--style--global--content-size, revert-layer)); }
|
|
30
|
+
:where(.fp-native-group[data-fp-group-layout="constrained"]) > :where(.alignwide) { max-width: var(--fp-group-wide-size, var(--wp--style--global--wide-size, revert-layer)); }
|
|
31
|
+
|
|
32
|
+
:where([data-fp-flex-size="fill"]) { flex-grow: 1; }
|
|
33
|
+
:where([data-fp-flex-size="fixed"]) { flex-basis: var(--fp-flex-basis, auto); box-sizing: border-box; }
|
|
34
|
+
:where(.fp-native-group[data-fp-group-layout="constrained"][data-fp-group-justify="left"], .fp-native-group[data-fp-group-layout="default"][data-fp-group-justify="left"]) { align-items: flex-start; }
|
|
35
|
+
:where(.fp-native-group[data-fp-group-layout="constrained"][data-fp-group-justify="center"], .fp-native-group[data-fp-group-layout="default"][data-fp-group-justify="center"]) { align-items: center; }
|
|
36
|
+
:where(.fp-native-group[data-fp-group-layout="constrained"][data-fp-group-justify="right"], .fp-native-group[data-fp-group-layout="default"][data-fp-group-justify="right"]) { align-items: flex-end; }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Gutenberg Group, Row and Stack use the same core/group block. */
|
|
2
|
+
export declare function groupLength(value: unknown): string | undefined;
|
|
3
|
+
export declare function nativeGroupProps(attributes?: Record<string, any>, htmlProps?: Record<string, any>, styleflowProps?: Record<string, any>): {
|
|
4
|
+
class: string;
|
|
5
|
+
"data-fp-group-layout": any;
|
|
6
|
+
"data-fp-group-justify": any;
|
|
7
|
+
"data-fp-group-align": any;
|
|
8
|
+
"data-fp-group-wrap": string | undefined;
|
|
9
|
+
"data-fp-group-row-gap": string | undefined;
|
|
10
|
+
"data-fp-group-column-gap": string | undefined;
|
|
11
|
+
style: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** Native sizing controls on children of a flex Group. */
|
|
14
|
+
export declare function nativeFlexItemProps(attributes: Record<string, any>, htmlProps: Record<string, any>): Record<string, any>;
|
|
15
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/astro/native/group.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU9D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;;;;;;;;EAiCnJ;AAED,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAWlG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Gutenberg Group, Row and Stack use the same core/group block. */
|
|
2
|
+
export function groupLength(value) {
|
|
3
|
+
if (value === 0 || value === "0")
|
|
4
|
+
return "0";
|
|
5
|
+
if (typeof value !== "string")
|
|
6
|
+
return undefined;
|
|
7
|
+
const preset = /^var:preset\|spacing\|([a-zA-Z0-9_-]+)$/.exec(value);
|
|
8
|
+
if (preset)
|
|
9
|
+
return `var(--wp--preset--spacing--${preset[1]})`;
|
|
10
|
+
const length = value.trim();
|
|
11
|
+
if (/^(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem|em|%|vw|vh|svw|svh|dvw|dvh|ch|ex|cqw|cqh)$/.test(length))
|
|
12
|
+
return length;
|
|
13
|
+
// Accept CSS math and custom properties, never declarations or URLs.
|
|
14
|
+
if (/^(?:var|calc|min|max|clamp)\([\w\s.,%()+*/-]+\)$/.test(length))
|
|
15
|
+
return length;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
export function nativeGroupProps(attributes = {}, htmlProps = {}, styleflowProps = {}) {
|
|
19
|
+
const layout = attributes.layout ?? {};
|
|
20
|
+
const type = ["flex", "grid", "constrained", "default"].includes(layout.type) ? layout.type : "constrained";
|
|
21
|
+
const vertical = layout.orientation === "vertical";
|
|
22
|
+
const justify = ["left", "center", "right", "space-between", "stretch"].includes(layout.justifyContent) ? layout.justifyContent : undefined;
|
|
23
|
+
const align = ["top", "center", "bottom", "space-between", "stretch"].includes(layout.verticalAlignment) ? layout.verticalAlignment : undefined;
|
|
24
|
+
const gap = attributes.noGap ? undefined : attributes.style?.spacing?.blockGap;
|
|
25
|
+
const rowGap = groupLength(typeof gap === "object" && gap !== null ? gap.top : gap);
|
|
26
|
+
const columnGap = groupLength(typeof gap === "object" && gap !== null ? gap.left : gap);
|
|
27
|
+
const contentSize = groupLength(layout.contentSize);
|
|
28
|
+
const wideSize = groupLength(layout.wideSize);
|
|
29
|
+
const role = String(styleflowProps.layoutRole ?? attributes.layoutRole ?? "none");
|
|
30
|
+
const density = String(styleflowProps.density ?? attributes.density ?? "regular");
|
|
31
|
+
const defaultGap = attributes.noGap ? "0" : /^[a-zA-Z0-9_-]+$/.test(role) && /^[a-zA-Z0-9_-]+$/.test(density)
|
|
32
|
+
? `var(--sf-layout-${role}-${density}-gap, normal)` : "normal";
|
|
33
|
+
const variables = [
|
|
34
|
+
`--fp-group-default-gap:${defaultGap}`,
|
|
35
|
+
rowGap !== undefined ? `--fp-group-row-gap:${rowGap}` : "",
|
|
36
|
+
columnGap !== undefined ? `--fp-group-column-gap:${columnGap}` : "",
|
|
37
|
+
contentSize ? `--fp-group-content-size:${contentSize}` : "",
|
|
38
|
+
wideSize ? `--fp-group-wide-size:${wideSize}` : "",
|
|
39
|
+
].filter(Boolean);
|
|
40
|
+
return {
|
|
41
|
+
...htmlProps,
|
|
42
|
+
class: ["wp-block-group", "fp-native-group", htmlProps.class].filter(Boolean).join(" "),
|
|
43
|
+
"data-fp-group-layout": type === "flex" ? (vertical ? "vertical" : "horizontal") : type,
|
|
44
|
+
"data-fp-group-justify": justify,
|
|
45
|
+
"data-fp-group-align": align,
|
|
46
|
+
"data-fp-group-wrap": type === "flex" ? (layout.flexWrap === "nowrap" ? "nowrap" : "wrap") : undefined,
|
|
47
|
+
"data-fp-group-row-gap": rowGap !== undefined ? "true" : undefined,
|
|
48
|
+
"data-fp-group-column-gap": columnGap !== undefined ? "true" : undefined,
|
|
49
|
+
style: [htmlProps.style, ...variables].filter(Boolean).join(";") || undefined,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Native sizing controls on children of a flex Group. */
|
|
53
|
+
export function nativeFlexItemProps(attributes, htmlProps) {
|
|
54
|
+
const layout = attributes.style?.layout;
|
|
55
|
+
if (!layout || !["fit", "fill", "fixed"].includes(layout.selfStretch))
|
|
56
|
+
return htmlProps;
|
|
57
|
+
const size = groupLength(layout.flexSize);
|
|
58
|
+
return {
|
|
59
|
+
...htmlProps,
|
|
60
|
+
"data-fp-flex-size": layout.selfStretch,
|
|
61
|
+
...(layout.selfStretch === "fixed" && size !== undefined ? {
|
|
62
|
+
style: [htmlProps.style, `--fp-flex-basis:${size}`].filter(Boolean).join(";")
|
|
63
|
+
} : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../../src/astro/native/group.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,GAAG,CAAC;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,MAAM,GAAG,yCAAyC,CAAC,IAA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E,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;QAAE,OAAO,SAAS,CAAC;IACxF,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO;QACL,GAAG,SAAS;QACZ,mBAAmB,EAAE,MAAM,CAAC,WAAW;QACvC,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,OAAO,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC;YACzD,KAAK,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SAC9E,CAAC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC","sourcesContent":["/** Gutenberg Group, Row and Stack use the same core/group block. */\nexport function groupLength(value: unknown): string | undefined {\n if (value === 0 || value === \"0\") return \"0\";\n if (typeof value !== \"string\") return undefined;\n const preset = /^var:preset\\|spacing\\|([a-zA-Z0-9_-]+)$/.exec(value);\n if (preset) return `var(--wp--preset--spacing--${preset[1]})`;\n const length = value.trim();\n if (/^(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:px|rem|em|%|vw|vh|svw|svh|dvw|dvh|ch|ex|cqw|cqh)$/.test(length)) return length;\n // Accept CSS math and custom properties, never declarations or URLs.\n if (/^(?:var|calc|min|max|clamp)\\([\\w\\s.,%()+*/-]+\\)$/.test(length)) return length;\n return undefined;\n}\n\nexport function nativeGroupProps(attributes: Record<string, any> = {}, htmlProps: Record<string, any> = {}, styleflowProps: Record<string, any> = {}) {\n const layout = attributes.layout ?? {};\n const type = [\"flex\", \"grid\", \"constrained\", \"default\"].includes(layout.type) ? layout.type : \"constrained\";\n const vertical = layout.orientation === \"vertical\";\n const justify = [\"left\", \"center\", \"right\", \"space-between\", \"stretch\"].includes(layout.justifyContent) ? layout.justifyContent : undefined;\n const align = [\"top\", \"center\", \"bottom\", \"space-between\", \"stretch\"].includes(layout.verticalAlignment) ? layout.verticalAlignment : undefined;\n const gap = attributes.noGap ? undefined : attributes.style?.spacing?.blockGap;\n const rowGap = groupLength(typeof gap === \"object\" && gap !== null ? gap.top : gap);\n const columnGap = groupLength(typeof gap === \"object\" && gap !== null ? gap.left : gap);\n const contentSize = groupLength(layout.contentSize);\n const wideSize = groupLength(layout.wideSize);\n const role = String(styleflowProps.layoutRole ?? attributes.layoutRole ?? \"none\");\n const density = String(styleflowProps.density ?? attributes.density ?? \"regular\");\n const defaultGap = attributes.noGap ? \"0\" : /^[a-zA-Z0-9_-]+$/.test(role) && /^[a-zA-Z0-9_-]+$/.test(density)\n ? `var(--sf-layout-${role}-${density}-gap, normal)` : \"normal\";\n const variables = [\n `--fp-group-default-gap:${defaultGap}`,\n rowGap !== undefined ? `--fp-group-row-gap:${rowGap}` : \"\",\n columnGap !== undefined ? `--fp-group-column-gap:${columnGap}` : \"\",\n contentSize ? `--fp-group-content-size:${contentSize}` : \"\",\n wideSize ? `--fp-group-wide-size:${wideSize}` : \"\",\n ].filter(Boolean);\n return {\n ...htmlProps,\n class: [\"wp-block-group\", \"fp-native-group\", htmlProps.class].filter(Boolean).join(\" \"),\n \"data-fp-group-layout\": type === \"flex\" ? (vertical ? \"vertical\" : \"horizontal\") : type,\n \"data-fp-group-justify\": justify,\n \"data-fp-group-align\": align,\n \"data-fp-group-wrap\": type === \"flex\" ? (layout.flexWrap === \"nowrap\" ? \"nowrap\" : \"wrap\") : undefined,\n \"data-fp-group-row-gap\": rowGap !== undefined ? \"true\" : undefined,\n \"data-fp-group-column-gap\": columnGap !== undefined ? \"true\" : undefined,\n style: [htmlProps.style, ...variables].filter(Boolean).join(\";\") || undefined,\n };\n}\n\n/** Native sizing controls on children of a flex Group. */\nexport function nativeFlexItemProps(attributes: Record<string, any>, htmlProps: Record<string, any>) {\n const layout = attributes.style?.layout;\n if (!layout || ![\"fit\", \"fill\", \"fixed\"].includes(layout.selfStretch)) return htmlProps;\n const size = groupLength(layout.flexSize);\n return {\n ...htmlProps,\n \"data-fp-flex-size\": layout.selfStretch,\n ...(layout.selfStretch === \"fixed\" && size !== undefined ? {\n style: [htmlProps.style, `--fp-flex-basis:${size}`].filter(Boolean).join(\";\")\n } : {}),\n };\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Gutenberg Group, Row and Stack use the same core/group block. */
|
|
2
|
+
export function groupLength(value: unknown): string | undefined {
|
|
3
|
+
if (value === 0 || value === "0") return "0";
|
|
4
|
+
if (typeof value !== "string") return undefined;
|
|
5
|
+
const preset = /^var:preset\|spacing\|([a-zA-Z0-9_-]+)$/.exec(value);
|
|
6
|
+
if (preset) return `var(--wp--preset--spacing--${preset[1]})`;
|
|
7
|
+
const length = value.trim();
|
|
8
|
+
if (/^(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem|em|%|vw|vh|svw|svh|dvw|dvh|ch|ex|cqw|cqh)$/.test(length)) return length;
|
|
9
|
+
// Accept CSS math and custom properties, never declarations or URLs.
|
|
10
|
+
if (/^(?:var|calc|min|max|clamp)\([\w\s.,%()+*/-]+\)$/.test(length)) return length;
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function nativeGroupProps(attributes: Record<string, any> = {}, htmlProps: Record<string, any> = {}, styleflowProps: Record<string, any> = {}) {
|
|
15
|
+
const layout = attributes.layout ?? {};
|
|
16
|
+
const type = ["flex", "grid", "constrained", "default"].includes(layout.type) ? layout.type : "constrained";
|
|
17
|
+
const vertical = layout.orientation === "vertical";
|
|
18
|
+
const justify = ["left", "center", "right", "space-between", "stretch"].includes(layout.justifyContent) ? layout.justifyContent : undefined;
|
|
19
|
+
const align = ["top", "center", "bottom", "space-between", "stretch"].includes(layout.verticalAlignment) ? layout.verticalAlignment : undefined;
|
|
20
|
+
const gap = attributes.noGap ? undefined : attributes.style?.spacing?.blockGap;
|
|
21
|
+
const rowGap = groupLength(typeof gap === "object" && gap !== null ? gap.top : gap);
|
|
22
|
+
const columnGap = groupLength(typeof gap === "object" && gap !== null ? gap.left : gap);
|
|
23
|
+
const contentSize = groupLength(layout.contentSize);
|
|
24
|
+
const wideSize = groupLength(layout.wideSize);
|
|
25
|
+
const role = String(styleflowProps.layoutRole ?? attributes.layoutRole ?? "none");
|
|
26
|
+
const density = String(styleflowProps.density ?? attributes.density ?? "regular");
|
|
27
|
+
const defaultGap = attributes.noGap ? "0" : /^[a-zA-Z0-9_-]+$/.test(role) && /^[a-zA-Z0-9_-]+$/.test(density)
|
|
28
|
+
? `var(--sf-layout-${role}-${density}-gap, normal)` : "normal";
|
|
29
|
+
const variables = [
|
|
30
|
+
`--fp-group-default-gap:${defaultGap}`,
|
|
31
|
+
rowGap !== undefined ? `--fp-group-row-gap:${rowGap}` : "",
|
|
32
|
+
columnGap !== undefined ? `--fp-group-column-gap:${columnGap}` : "",
|
|
33
|
+
contentSize ? `--fp-group-content-size:${contentSize}` : "",
|
|
34
|
+
wideSize ? `--fp-group-wide-size:${wideSize}` : "",
|
|
35
|
+
].filter(Boolean);
|
|
36
|
+
return {
|
|
37
|
+
...htmlProps,
|
|
38
|
+
class: ["wp-block-group", "fp-native-group", htmlProps.class].filter(Boolean).join(" "),
|
|
39
|
+
"data-fp-group-layout": type === "flex" ? (vertical ? "vertical" : "horizontal") : type,
|
|
40
|
+
"data-fp-group-justify": justify,
|
|
41
|
+
"data-fp-group-align": align,
|
|
42
|
+
"data-fp-group-wrap": type === "flex" ? (layout.flexWrap === "nowrap" ? "nowrap" : "wrap") : undefined,
|
|
43
|
+
"data-fp-group-row-gap": rowGap !== undefined ? "true" : undefined,
|
|
44
|
+
"data-fp-group-column-gap": columnGap !== undefined ? "true" : undefined,
|
|
45
|
+
style: [htmlProps.style, ...variables].filter(Boolean).join(";") || undefined,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Native sizing controls on children of a flex Group. */
|
|
50
|
+
export function nativeFlexItemProps(attributes: Record<string, any>, htmlProps: Record<string, any>) {
|
|
51
|
+
const layout = attributes.style?.layout;
|
|
52
|
+
if (!layout || !["fit", "fill", "fixed"].includes(layout.selfStretch)) return htmlProps;
|
|
53
|
+
const size = groupLength(layout.flexSize);
|
|
54
|
+
return {
|
|
55
|
+
...htmlProps,
|
|
56
|
+
"data-fp-flex-size": layout.selfStretch,
|
|
57
|
+
...(layout.selfStretch === "fixed" && size !== undefined ? {
|
|
58
|
+
style: [htmlProps.style, `--fp-flex-basis:${size}`].filter(Boolean).join(";")
|
|
59
|
+
} : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/astro/native/html.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAOnI"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */
|
|
2
|
+
export function nativeHtmlData(data, legacyHtml) {
|
|
3
|
+
return {
|
|
4
|
+
// Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).
|
|
5
|
+
// A present resolver (including empty output) always takes precedence.
|
|
6
|
+
html: typeof data?.html === "string" ? data.html : data == null ? legacyHtml ?? "" : "",
|
|
7
|
+
hidden: data?.hidden === true,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/astro/native/html.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,IAAqC,EAAE,UAA0B;IAC9F,OAAO;QACL,wEAAwE;QACxE,uEAAuE;QACvE,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;QACvF,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["/** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */\nexport function nativeHtmlData(data?: Record<string, unknown> | null, legacyHtml?: string | null): { html: string; hidden: boolean } {\n return {\n // Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).\n // A present resolver (including empty output) always takes precedence.\n html: typeof data?.html === \"string\" ? data.html : data == null ? legacyHtml ?? \"\" : \"\",\n hidden: data?.hidden === true,\n };\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Prefer resolved HTML; older payloads provide a server-sanitized fragment. */
|
|
2
|
+
export function nativeHtmlData(data?: Record<string, unknown> | null, legacyHtml?: string | null): { html: string; hidden: boolean } {
|
|
3
|
+
return {
|
|
4
|
+
// Legacy FlowPress serialization supplies only wp_kses_post(innerHtml).
|
|
5
|
+
// A present resolver (including empty output) always takes precedence.
|
|
6
|
+
html: typeof data?.html === "string" ? data.html : data == null ? legacyHtml ?? "" : "",
|
|
7
|
+
hidden: data?.hidden === true,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/astro/native/icon.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMlE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUlG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { normalizeIconSvg, scopeIconSvgIds } from "@styleflow.app/flowpress-components/icon-svg";
|
|
2
|
+
export function nativeIconWidth(value) {
|
|
3
|
+
if (typeof value !== "string")
|
|
4
|
+
return undefined;
|
|
5
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|rem|em|%|vw|vh)$/);
|
|
6
|
+
if (!match)
|
|
7
|
+
return undefined;
|
|
8
|
+
const limit = match[2] === "px" ? 1536 : ["%", "vw", "vh"].includes(match[2]) ? 100 : 96;
|
|
9
|
+
return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function nativeIconSvg(name, resolved, prefix) {
|
|
12
|
+
if (typeof name !== "string")
|
|
13
|
+
return undefined;
|
|
14
|
+
let svg;
|
|
15
|
+
if (!svg) {
|
|
16
|
+
const data = resolved && typeof resolved === "object" ? resolved : {};
|
|
17
|
+
if (data.name === name && data.empty === false && typeof data.svg === "string" && data.svg) {
|
|
18
|
+
svg = normalizeIconSvg(data.svg, name);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return svg ? scopeIconSvgIds(svg, prefix) : undefined;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/astro/native/icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEjG,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC/E,IAAI,C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svg\";\n\nexport function nativeIconWidth(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?|\\.\\d+)(px|rem|em|%|vw|vh)$/);\n if (!match) return undefined;\n const limit = match[2] === \"px\" ? 1536 : [\"%\", \"vw\", \"vh\"].includes(match[2]!) ? 100 : 96;\n return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;\n}\n\nexport function nativeIconSvg(name: unknown, resolved: unknown, prefix: string): string | undefined {\n if (typeof name !== \"string\") return undefined;\n let svg: string | undefined;\n if (!svg) {\n const data = resolved && typeof resolved === \"object\" ? resolved as Record<string, unknown> : {};\n if (data.name === name && data.empty === false && typeof data.svg === \"string\" && data.svg) {\n svg = normalizeIconSvg(data.svg, name);\n }\n }\n return svg ? scopeIconSvgIds(svg, prefix) : undefined;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { normalizeIconSvg, scopeIconSvgIds } from "@styleflow.app/flowpress-components/icon-svg";
|
|
2
|
+
|
|
3
|
+
export function nativeIconWidth(value: unknown): string | undefined {
|
|
4
|
+
if (typeof value !== "string") return undefined;
|
|
5
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|rem|em|%|vw|vh)$/);
|
|
6
|
+
if (!match) return undefined;
|
|
7
|
+
const limit = match[2] === "px" ? 1536 : ["%", "vw", "vh"].includes(match[2]!) ? 100 : 96;
|
|
8
|
+
return Number(match[1]) > 0 && Number(match[1]) <= limit ? value.trim() : undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function nativeIconSvg(name: unknown, resolved: unknown, prefix: string): string | undefined {
|
|
12
|
+
if (typeof name !== "string") return undefined;
|
|
13
|
+
let svg: string | undefined;
|
|
14
|
+
if (!svg) {
|
|
15
|
+
const data = resolved && typeof resolved === "object" ? resolved as Record<string, unknown> : {};
|
|
16
|
+
if (data.name === name && data.empty === false && typeof data.svg === "string" && data.svg) {
|
|
17
|
+
svg = normalizeIconSvg(data.svg, name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return svg ? scopeIconSvgIds(svg, prefix) : undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function imageAspectRatio(value: unknown): string | undefined;
|
|
2
|
+
export declare function imageDimension(value: unknown): string | undefined;
|
|
3
|
+
export declare function imageObjectPosition(value: unknown): string;
|
|
4
|
+
export declare function imageMediaStyle(attributes: Record<string, unknown>): Record<string, string>;
|
|
5
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/astro/native/image.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQjE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM1D;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB3F"}
|