@styleflow.app/flowpress-astro-core 1.0.0-beta.5 → 1.0.0-beta.50
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 +307 -1
- package/README.md +121 -6
- 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 +170 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/EditorialMedia.astro +47 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +270 -84
- package/dist/astro/Media.astro +27 -0
- package/dist/astro/StyleflowElement.astro +25 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +72 -101
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +158 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +5 -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 +312 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +393 -0
- package/dist/astro/motion/motion.css +600 -0
- package/dist/astro/motion/motion.d.ts +132 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +265 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +430 -0
- package/dist/astro/native/AccordionRuntime.astro +11 -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/accordion-controller.d.ts +3 -0
- package/dist/astro/native/accordion-controller.d.ts.map +1 -0
- package/dist/astro/native/accordion-controller.js +143 -0
- package/dist/astro/native/accordion-controller.js.map +1 -0
- package/dist/astro/native/accordion-controller.ts +108 -0
- package/dist/astro/native/accordion.css +36 -0
- package/dist/astro/native/accordion.d.ts +24 -0
- package/dist/astro/native/accordion.d.ts.map +1 -0
- package/dist/astro/native/accordion.js +82 -0
- package/dist/astro/native/accordion.js.map +1 -0
- package/dist/astro/native/accordion.ts +91 -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/block-sizing.css +34 -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/carousel.css +323 -0
- package/dist/astro/native/core-accordion-heading.astro +23 -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/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 +136 -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 +40 -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 +18 -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 +18 -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 +108 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +132 -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 +13 -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 +60 -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 +91 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +93 -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-slot.astro +6 -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 +82 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/carousel.d.ts +56 -6
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +183 -27
- package/dist/carousel.js.map +1 -1
- package/dist/client.d.ts +34 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -42
- 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 +122 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +53 -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,132 @@
|
|
|
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
|
+
/** 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
|
+
|
|
113
|
+
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
114
|
+
export const decorateGridBlocks = (blocks: FlowpressBlock[]): FlowpressBlock[] => blocks.map((block) => {
|
|
115
|
+
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
116
|
+
const attributes = (block.attributes || {}) as GridAttributes;
|
|
117
|
+
if (!isGrid(block.name, attributes)) return innerBlocks ? { ...block, innerBlocks } : block;
|
|
118
|
+
const children = visibleChildren(innerBlocks ?? []);
|
|
119
|
+
const bleed = bleedClasses(attributes, children.map((child) => child.attributes as GridAttributes || {}));
|
|
120
|
+
return {
|
|
121
|
+
...block,
|
|
122
|
+
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
123
|
+
innerBlocks: mapVisibleChildren(innerBlocks ?? [], (child, index) => ({
|
|
124
|
+
...child,
|
|
125
|
+
attributes: appendClasses(child.attributes as GridAttributes || {}, [
|
|
126
|
+
...spanClasses(child.attributes as GridAttributes || {}),
|
|
127
|
+
...usedSpanClasses(attributes, child.attributes as GridAttributes || {}),
|
|
128
|
+
...(bleed[index] ?? []),
|
|
129
|
+
]),
|
|
130
|
+
})),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
@@ -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
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AC,MAAM,CAAC,CAAC,CAAC,SAAS;QACxE,KAAK,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS;KAC9E,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,mBAAmB,CAAC,UAA+B,EAAE,SAA8B;IACjG,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;IACxC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,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
|
+
//#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AAI,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3F,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC","sourcesContent":["import { normalizeIconSvg, scopeIconSvgIds } from \"@styleflow.app/flowpress-components/icon-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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** Presentation of the existing WordPress core/image attributes. */
|
|
2
|
+
const cssNumber = /^(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
3
|
+
const dimensionUnits = new Set(["px", "%", "em", "rem", "ex", "ch", "lh", "rlh", "vw", "vh", "vmin", "vmax", "vi", "vb", "svw", "svh", "lvw", "lvh", "dvw", "dvh", "cm", "mm", "q", "in", "pt", "pc"]);
|
|
4
|
+
function positiveNumber(value) {
|
|
5
|
+
const number = Number(value);
|
|
6
|
+
return cssNumber.test(value) && Number.isFinite(number) && number > 0 ? String(number) : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function imageAspectRatio(value) {
|
|
9
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
10
|
+
return undefined;
|
|
11
|
+
const candidate = String(value).trim();
|
|
12
|
+
if (candidate === "auto")
|
|
13
|
+
return candidate;
|
|
14
|
+
const parts = candidate.split("/").map(part => positiveNumber(part.trim()));
|
|
15
|
+
if (parts.length === 1)
|
|
16
|
+
return parts[0];
|
|
17
|
+
return parts.length === 2 && parts[0] && parts[1] ? `${parts[0]} / ${parts[1]}` : undefined;
|
|
18
|
+
}
|
|
19
|
+
export function imageDimension(value) {
|
|
20
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
21
|
+
return undefined;
|
|
22
|
+
const candidate = String(value).trim().toLowerCase();
|
|
23
|
+
if (candidate === "auto")
|
|
24
|
+
return candidate;
|
|
25
|
+
const match = candidate.match(/^((?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z%]*)$/);
|
|
26
|
+
if (!match || !Number.isFinite(Number(match[1])))
|
|
27
|
+
return undefined;
|
|
28
|
+
const unit = match[2] || "px";
|
|
29
|
+
return dimensionUnits.has(unit) ? `${Number(match[1])}${unit}` : undefined;
|
|
30
|
+
}
|
|
31
|
+
export function imageObjectPosition(value) {
|
|
32
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
33
|
+
return "50% 50%";
|
|
34
|
+
const { x, y } = value;
|
|
35
|
+
if (typeof x !== "number" || typeof y !== "number" || !Number.isFinite(x) || !Number.isFinite(y))
|
|
36
|
+
return "50% 50%";
|
|
37
|
+
const percentage = (coordinate) => Number((Math.min(1, Math.max(0, coordinate)) * 100).toFixed(6));
|
|
38
|
+
return `${percentage(x)}% ${percentage(y)}%`;
|
|
39
|
+
}
|
|
40
|
+
export function imageMediaStyle(attributes) {
|
|
41
|
+
const ratio = imageAspectRatio(attributes.aspectRatio);
|
|
42
|
+
const width = imageDimension(attributes.width);
|
|
43
|
+
const height = imageDimension(attributes.height);
|
|
44
|
+
const hasRatio = ratio !== undefined && ratio !== "auto";
|
|
45
|
+
const scale = ["cover", "contain", "fill"].includes(String(attributes.scale))
|
|
46
|
+
? String(attributes.scale)
|
|
47
|
+
: hasRatio || (height !== undefined && height !== "auto") ? "cover" : undefined;
|
|
48
|
+
const style = {};
|
|
49
|
+
if (ratio)
|
|
50
|
+
style["aspect-ratio"] = ratio;
|
|
51
|
+
if (scale) {
|
|
52
|
+
style["object-fit"] = scale;
|
|
53
|
+
style["object-position"] = imageObjectPosition(attributes.focalPoint);
|
|
54
|
+
}
|
|
55
|
+
if (width !== undefined)
|
|
56
|
+
style.width = width;
|
|
57
|
+
else if (hasRatio && height !== undefined && height !== "auto")
|
|
58
|
+
style.width = "auto";
|
|
59
|
+
if (height !== undefined)
|
|
60
|
+
style.height = height;
|
|
61
|
+
else if (ratio || width !== undefined)
|
|
62
|
+
style.height = "auto";
|
|
63
|
+
return style;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/astro/native/image.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,SAAS,GAAG,sCAAsC,CAAC;AACzD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,E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AAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;SACxC,IAAI,QAAQ,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,MAAM;QAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;IACrF,IAAI,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SAC3C,IAAI,KAAK,IAAI,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/** Presentation of the existing WordPress core/image attributes. */\nconst cssNumber = /^(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?$/i;\nconst dimensionUnits = new Set([\"px\", \"%\", \"em\", \"rem\", \"ex\", \"ch\", \"lh\", \"rlh\", \"vw\", \"vh\", \"vmin\", \"vmax\", \"vi\", \"vb\", \"svw\", \"svh\", \"lvw\", \"lvh\", \"dvw\", \"dvh\", \"cm\", \"mm\", \"q\", \"in\", \"pt\", \"pc\"]);\n\nfunction positiveNumber(value: string): string | undefined {\n const number = Number(value);\n return cssNumber.test(value) && Number.isFinite(number) && number > 0 ? String(number) : undefined;\n}\n\nexport function imageAspectRatio(value: unknown): string | undefined {\n if (typeof value !== \"string\" && typeof value !== \"number\") return undefined;\n const candidate = String(value).trim();\n if (candidate === \"auto\") return candidate;\n const parts = candidate.split(\"/\").map(part => positiveNumber(part.trim()));\n if (parts.length === 1) return parts[0];\n return parts.length === 2 && parts[0] && parts[1] ? `${parts[0]} / ${parts[1]}` : undefined;\n}\n\nexport function imageDimension(value: unknown): string | undefined {\n if (typeof value !== \"string\" && typeof value !== \"number\") return undefined;\n const candidate = String(value).trim().toLowerCase();\n if (candidate === \"auto\") return candidate;\n const match = candidate.match(/^((?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?)([a-z%]*)$/);\n if (!match || !Number.isFinite(Number(match[1]))) return undefined;\n const unit = match[2] || \"px\";\n return dimensionUnits.has(unit) ? `${Number(match[1])}${unit}` : undefined;\n}\n\nexport function imageObjectPosition(value: unknown): string {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return \"50% 50%\";\n const { x, y } = value as Record<string, unknown>;\n if (typeof x !== \"number\" || typeof y !== \"number\" || !Number.isFinite(x) || !Number.isFinite(y)) return \"50% 50%\";\n const percentage = (coordinate: number) => Number((Math.min(1, Math.max(0, coordinate)) * 100).toFixed(6));\n return `${percentage(x)}% ${percentage(y)}%`;\n}\n\nexport function imageMediaStyle(attributes: Record<string, unknown>): Record<string, string> {\n const ratio = imageAspectRatio(attributes.aspectRatio);\n const width = imageDimension(attributes.width);\n const height = imageDimension(attributes.height);\n const hasRatio = ratio !== undefined && ratio !== \"auto\";\n const scale = [\"cover\", \"contain\", \"fill\"].includes(String(attributes.scale))\n ? String(attributes.scale)\n : hasRatio || (height !== undefined && height !== \"auto\") ? \"cover\" : undefined;\n const style: Record<string, string> = {};\n if (ratio) style[\"aspect-ratio\"] = ratio;\n if (scale) {\n style[\"object-fit\"] = scale;\n style[\"object-position\"] = imageObjectPosition(attributes.focalPoint);\n }\n if (width !== undefined) style.width = width;\n else if (hasRatio && height !== undefined && height !== \"auto\") style.width = \"auto\";\n if (height !== undefined) style.height = height;\n else if (ratio || width !== undefined) style.height = \"auto\";\n return style;\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Presentation of the existing WordPress core/image attributes. */
|
|
2
|
+
const cssNumber = /^(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
3
|
+
const dimensionUnits = new Set(["px", "%", "em", "rem", "ex", "ch", "lh", "rlh", "vw", "vh", "vmin", "vmax", "vi", "vb", "svw", "svh", "lvw", "lvh", "dvw", "dvh", "cm", "mm", "q", "in", "pt", "pc"]);
|
|
4
|
+
|
|
5
|
+
function positiveNumber(value: string): string | undefined {
|
|
6
|
+
const number = Number(value);
|
|
7
|
+
return cssNumber.test(value) && Number.isFinite(number) && number > 0 ? String(number) : undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function imageAspectRatio(value: unknown): string | undefined {
|
|
11
|
+
if (typeof value !== "string" && typeof value !== "number") return undefined;
|
|
12
|
+
const candidate = String(value).trim();
|
|
13
|
+
if (candidate === "auto") return candidate;
|
|
14
|
+
const parts = candidate.split("/").map(part => positiveNumber(part.trim()));
|
|
15
|
+
if (parts.length === 1) return parts[0];
|
|
16
|
+
return parts.length === 2 && parts[0] && parts[1] ? `${parts[0]} / ${parts[1]}` : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function imageDimension(value: unknown): string | undefined {
|
|
20
|
+
if (typeof value !== "string" && typeof value !== "number") return undefined;
|
|
21
|
+
const candidate = String(value).trim().toLowerCase();
|
|
22
|
+
if (candidate === "auto") return candidate;
|
|
23
|
+
const match = candidate.match(/^((?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z%]*)$/);
|
|
24
|
+
if (!match || !Number.isFinite(Number(match[1]))) return undefined;
|
|
25
|
+
const unit = match[2] || "px";
|
|
26
|
+
return dimensionUnits.has(unit) ? `${Number(match[1])}${unit}` : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function imageObjectPosition(value: unknown): string {
|
|
30
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return "50% 50%";
|
|
31
|
+
const { x, y } = value as Record<string, unknown>;
|
|
32
|
+
if (typeof x !== "number" || typeof y !== "number" || !Number.isFinite(x) || !Number.isFinite(y)) return "50% 50%";
|
|
33
|
+
const percentage = (coordinate: number) => Number((Math.min(1, Math.max(0, coordinate)) * 100).toFixed(6));
|
|
34
|
+
return `${percentage(x)}% ${percentage(y)}%`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function imageMediaStyle(attributes: Record<string, unknown>): Record<string, string> {
|
|
38
|
+
const ratio = imageAspectRatio(attributes.aspectRatio);
|
|
39
|
+
const width = imageDimension(attributes.width);
|
|
40
|
+
const height = imageDimension(attributes.height);
|
|
41
|
+
const hasRatio = ratio !== undefined && ratio !== "auto";
|
|
42
|
+
const scale = ["cover", "contain", "fill"].includes(String(attributes.scale))
|
|
43
|
+
? String(attributes.scale)
|
|
44
|
+
: hasRatio || (height !== undefined && height !== "auto") ? "cover" : undefined;
|
|
45
|
+
const style: Record<string, string> = {};
|
|
46
|
+
if (ratio) style["aspect-ratio"] = ratio;
|
|
47
|
+
if (scale) {
|
|
48
|
+
style["object-fit"] = scale;
|
|
49
|
+
style["object-position"] = imageObjectPosition(attributes.focalPoint);
|
|
50
|
+
}
|
|
51
|
+
if (width !== undefined) style.width = width;
|
|
52
|
+
else if (hasRatio && height !== undefined && height !== "auto") style.width = "auto";
|
|
53
|
+
if (height !== undefined) style.height = height;
|
|
54
|
+
else if (ratio || width !== undefined) style.height = "auto";
|
|
55
|
+
return style;
|
|
56
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* Inline text inherits its typed ancestor; explicitly typed children retain their contract rules. */
|
|
2
|
+
@layer styleflow {
|
|
3
|
+
:where([data-text-style]) :is(a, strong, em) {
|
|
4
|
+
font-family: inherit;
|
|
5
|
+
font-size: inherit;
|
|
6
|
+
font-style: inherit;
|
|
7
|
+
font-weight: inherit;
|
|
8
|
+
line-height: inherit;
|
|
9
|
+
letter-spacing: inherit;
|
|
10
|
+
text-transform: inherit;
|
|
11
|
+
font-variation-settings: inherit;
|
|
12
|
+
}
|
|
13
|
+
:where([data-text-style]) strong { font-weight: var(--sf-text-body-md-strong-font-weight, bolder); }
|
|
14
|
+
:where([data-text-style]) em { font-style: italic; }
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type MapAttributes = {
|
|
2
|
+
address?: unknown;
|
|
3
|
+
latitude?: unknown;
|
|
4
|
+
longitude?: unknown;
|
|
5
|
+
provider?: unknown;
|
|
6
|
+
zoom?: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveMap(attributes: MapAttributes, googleKey?: string): {
|
|
9
|
+
address: string;
|
|
10
|
+
query: string;
|
|
11
|
+
iframeSrc: string;
|
|
12
|
+
linkHref: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=map.d.ts.map
|