@styleflow.app/flowpress-astro-core 1.0.0-beta.3 → 1.0.0-beta.30
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 +190 -1
- package/README.md +111 -3
- 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 +157 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +12 -7
- package/dist/astro/GutenbergRenderer.astro +240 -80
- package/dist/astro/StyleflowElement.astro +23 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +8 -10
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +155 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +4 -4
- package/dist/astro/blocks/HeroBlock.astro +4 -5
- package/dist/astro/blocks/ImageBlock.astro +4 -5
- package/dist/astro/blocks/ListItemFallback.astro +10 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -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 +7 -0
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +52 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +64 -45
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +87 -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/ResolvedBlocks.astro +89 -0
- package/dist/astro/native/SyncedPatternContent.astro +92 -0
- package/dist/astro/native/TermFieldValue.astro +38 -0
- package/dist/astro/native/Timeline.astro +21 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button.astro +43 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +23 -0
- package/dist/astro/native/core-home-link.astro +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 +124 -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 +94 -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 +37 -0
- package/dist/astro/native/core-post-template.astro +30 -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.js +106 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +81 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +81 -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 +118 -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 +20 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/client.d.ts +17 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +63 -9
- 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 +124 -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 +118 -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 +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +5 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +32 -0
- package/dist/links.js.map +1 -0
- package/dist/media.d.ts +28 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +212 -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/styleflow.d.ts +16 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +76 -7
- package/dist/styleflow.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- 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 +84 -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 +26 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/astro/blocks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAE7B,MAAM,oBAAoB,CAAC;AAG5B,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACp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CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAC7B,+DAA+D,CAChE,CAAC;IACF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import {\n resolveDynamicStyleflowProps,\n type StyleflowContract\n} from \"../../styleflow.js\";\nimport type { FlowpressBlock } from \"../../types.js\";\n\nexport const DEFAULT_SEMANTIC_PROPS = {\n surface: \"default\",\n layoutRole: \"stack\",\n density: \"regular\"\n};\n\nexport const DEFAULT_HERO_OBJECT_POSITION = \"50% 50%\";\n\nexport function heroObjectPosition(value: unknown): string {\n if (typeof value !== \"string\") {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n const match = value.trim().match(\n /^(\\d+(?:\\.\\d+)?|\\.\\d+)%\\s+(\\d+(?:\\.\\d+)?|\\.\\d+)%$/\n );\n if (\n !match\n || [match[1], match[2]].some((coordinate) => {\n const numeric = Number(coordinate);\n return !Number.isFinite(numeric) || numeric < 0 || numeric > 100;\n })\n ) {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n return `${match[1]}% ${match[2]}%`;\n}\n\nexport function blockHtmlAttributes(\n attributes: Record<string, unknown>,\n baseClass = \"\"\n): { id?: string; class?: string } {\n const anchor = typeof attributes.anchor === \"string\"\n ? attributes.anchor.trim()\n : \"\";\n const customClass = typeof attributes.className === \"string\"\n ? attributes.className.trim()\n : \"\";\n const className = [baseClass.trim(), customClass]\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \");\n\n return {\n ...(anchor ? { id: anchor } : {}),\n ...(className ? { class: className } : {})\n };\n}\n\nconst SEMANTIC_KEYS = [\n \"theme\",\n \"tone\",\n \"intensity\",\n \"surface\",\n \"layoutRole\",\n \"density\",\n \"ty\",\n \"v\",\n \"w\",\n \"foreground\",\n \"interactivePriority\",\n \"noBackground\",\n \"noBorder\",\n \"noPadding\",\n \"noGap\",\n \"noRadius\",\n \"noForeground\"\n] as const;\n\nexport const TEXT_HTML_TAGS = [\n \"span\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"strong\",\n \"em\",\n \"small\",\n \"mark\"\n] as const;\n\nexport type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];\n\nexport function textHtmlTag(value: unknown): TextHtmlTag {\n const candidate = String(value ?? \"span\");\n return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)\n ? candidate as TextHtmlTag\n : \"span\";\n}\n\nexport function semanticProps(\n attributes: Record<string, unknown>,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS\n): Record<string, unknown> {\n const input = Object.fromEntries(\n SEMANTIC_KEYS\n .filter((key) => attributes[key] !== undefined)\n .map((key) => [key, attributes[key]])\n );\n if (contract) {\n return resolveDynamicStyleflowProps(input, defaults, contract, {\n strict: process.env.NODE_ENV === \"production\" || process.env.STYLEFLOW_STRICT === \"1\",\n onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)\n });\n }\n\n const resolved = { ...defaults, ...input };\n for (const key of [\"tone\", \"intensity\", \"foreground\"]) {\n if (input[key] === \"inherit\") {\n delete resolved[key];\n }\n }\n return resolved;\n}\n\nconst TEXT_ALIGNMENTS = new Set([\n \"left\",\n \"center\",\n \"right\",\n \"justify\",\n \"start\",\n \"end\"\n]);\n\n/** Resolve only Gutenberg's supported text-alignment values to inline CSS. */\nexport function textAlignmentStyle(\n attributes: Record<string, unknown>\n): string | undefined {\n const style = attributes.style && typeof attributes.style === \"object\"\n && !Array.isArray(attributes.style)\n ? attributes.style as Record<string, unknown>\n : {};\n const typography = style.typography && typeof style.typography === \"object\"\n && !Array.isArray(style.typography)\n ? style.typography as Record<string, unknown>\n : {};\n const candidate = typography.textAlign ?? attributes.textAlign;\n const alignment = String(candidate ?? \"\");\n return TEXT_ALIGNMENTS.has(alignment) ? `text-align: ${alignment};` : undefined;\n}\n\nexport function prefixedTextSemanticProps(\n attributes: Record<string, unknown>,\n prefix: string,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = {}\n): Record<string, unknown> {\n const attributeName = (name: string) =>\n `${prefix}${name.charAt(0).toUpperCase()}${name.slice(1)}`;\n return semanticProps({\n ty: attributes[attributeName(\"ty\")],\n v: attributes[attributeName(\"v\")],\n w: attributes[attributeName(\"w\")],\n foreground: attributes[attributeName(\"foreground\")]\n }, contract, defaults);\n}\n\nexport function objectValue(\n block: FlowpressBlock,\n key: string\n): Record<string, unknown> {\n const value = block.attributes[key];\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n}\n\nexport function textValue(block: FlowpressBlock, key = \"text\"): string {\n return String(block.attributes[key] ?? \"\");\n}\n\n/**\n * Keep intentional blank lines visible across current and legacy RichText\n * serializations. Gutenberg can represent them either as repeated `<br>` tags,\n * empty paragraph elements, or literal newlines in an attribute value.\n */\nexport function preserveRichTextSpacing(html: string): string {\n const visibleEmptyBlocks = html\n .replace(/\\r\\n?/g, \"\\n\")\n .replace(\n /<(p|div)(\\s[^>]*)?>(?:\\s| | )*<\\/\\1>/gi,\n (_match, tag: string, attributes = \"\") =>\n `<${tag}${attributes}> </${tag}>`\n );\n\n return visibleEmptyBlocks\n .split(/(<[^>]+>)/g)\n .map((part) => {\n if (part.startsWith(\"<\") || part.trim() === \"\") {\n return part;\n }\n return part.replace(/\\n(?:[ \\t]*\\n)+/g, (newlines) =>\n \"<br>\".repeat((newlines.match(/\\n/g) || []).length)\n );\n })\n .join(\"\");\n}\n\n/** Keep an empty text element at its typographic line height without visible text. */\nexport function preserveEmptyTextBlock(html: string): string {\n return html.trim() === \"\" ? \" \" : html;\n}\n\nexport function linkValue(block: FlowpressBlock, key = \"link\"): string {\n const value = block.attributes[key];\n const href = typeof value === \"string\"\n ? value\n : String(objectValue(block, key).url ?? \"\");\n return /^(?:\\/(?!\\/)|#|https?:\\/\\/|mailto:|tel:)/i.test(href) ? href : \"\";\n}\n\nexport function responsiveValues(\n attributes: Record<string, unknown>,\n prefix: \"columns\" | \"span\",\n fallback: number\n): Record<\"base\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\", number> {\n const keys = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n const result = {} as Record<(typeof keys)[number], number>;\n let inherited = fallback;\n for (const key of keys) {\n const suffix = key === \"base\"\n ? \"Base\"\n : key === \"2xl\" ? \"2xl\" : key.charAt(0).toUpperCase() + key.slice(1);\n const candidate = Number(attributes[`${prefix}${suffix}`]);\n if (Number.isInteger(candidate) && candidate >= 1 && candidate <= 12) {\n inherited = candidate;\n }\n result[key] = inherited;\n }\n return result;\n}\n\nexport function unwrapCoreHtml(html: string): string {\n const match = html.trim().match(\n /^<(p|h[1-6]|ul|ol|li|blockquote)(?:\\s[^>]*)?>([\\s\\S]*)<\\/\\1>$/\n );\n return match?.[2] ?? html;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/astro/blocks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EAEpC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAS,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,4BAA4B,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAC9B,mDAAmD,CACpD,CAAC;I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,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,UAAmC,EACnC,MAA0B,EAC1B,QAAgB;IAEhB,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;IAC9D,MAAM,MAAM,GAAG,EAA2C,CAAC;IAC3D,IAAI,SAAS,GAAG,QAAQ,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM;YAC3B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;YACrE,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAC7B,+DAA+D,CAChE,CAAC;IACF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import {\n resolveFlowpressBlockStyleflowProps,\n type StyleflowContract\n} from \"../../styleflow.js\";\nimport type { FlowpressBlock } from \"../../types.js\";\nimport { flowpressLinkHref } from \"../../links.js\";\n\nexport const DEFAULT_SEMANTIC_PROPS = {\n surface: \"default\",\n layoutRole: \"stack\",\n density: \"regular\"\n};\n\nexport const DEFAULT_HERO_OBJECT_POSITION = \"50% 50%\";\n\nexport function heroObjectPosition(value: unknown): string {\n if (typeof value !== \"string\") {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n const match = value.trim().match(\n /^(\\d+(?:\\.\\d+)?|\\.\\d+)%\\s+(\\d+(?:\\.\\d+)?|\\.\\d+)%$/\n );\n if (\n !match\n || [match[1], match[2]].some((coordinate) => {\n const numeric = Number(coordinate);\n return !Number.isFinite(numeric) || numeric < 0 || numeric > 100;\n })\n ) {\n return DEFAULT_HERO_OBJECT_POSITION;\n }\n\n return `${match[1]}% ${match[2]}%`;\n}\n\nexport function blockHtmlAttributes(\n attributes: Record<string, unknown>,\n baseClass = \"\"\n): { id?: string; class?: string } {\n const anchor = typeof attributes.anchor === \"string\"\n ? attributes.anchor.trim()\n : \"\";\n const customClass = typeof attributes.className === \"string\"\n ? attributes.className.trim()\n : \"\";\n const className = [baseClass.trim(), customClass]\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \");\n\n return {\n ...(anchor ? { id: anchor } : {}),\n ...(className ? { class: className } : {})\n };\n}\n\nexport const TEXT_HTML_TAGS = [\n \"span\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"strong\",\n \"em\",\n \"small\",\n \"mark\"\n] as const;\n\nexport type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];\n\nfunction preferredTypographyVariant(type: string): string | undefined {\n if (type === \"heading\") return \"2\";\n if (type === \"body\" || type === \"label\" || type === \"code\") return \"md\";\n return undefined;\n}\n\n/**\n * Derive a variant only when Gutenberg omitted it. The selected typography\n * type can differ from the block's native type, so a paragraph styled as a\n * heading must not inherit the paragraph-only `md` variant.\n */\nexport function compatibleTypographyVariant(\n type: string,\n preferred: string,\n contract?: StyleflowContract\n): string {\n const variants = contract?.semantic.axes.typography.variantsByType[type];\n if (!variants?.length) return preferred;\n\n return [\n preferredTypographyVariant(type),\n preferred,\n contract?.semantic.agentPolicy.defaults.typography.ty === type\n ? contract.semantic.agentPolicy.defaults.typography.v\n : undefined,\n variants[0]\n ].find((candidate): candidate is string => (\n typeof candidate === \"string\" && variants.includes(candidate)\n )) ?? preferred;\n}\n\nexport function textBlockSemanticDefaults(\n blockName: string,\n attributes: Record<string, unknown>,\n contract?: StyleflowContract\n): Record<string, unknown> {\n const name = blockName.replace(/^sf\\//, \"\");\n const heading = name === \"heading\" || name === \"core/heading\";\n const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));\n const defaultType = heading ? \"heading\" : \"body\";\n const authored = (...values: unknown[]) => values.find((value) => value !== undefined && value !== null && value !== \"\");\n const activeType = String(authored(attributes.ty) ?? defaultType);\n const nativeVariant = heading\n ? String(level)\n : name.includes(\"quote\") ? \"lg\" : \"md\";\n const authoredVariant = authored(attributes.v, attributes.variant);\n\n return {\n ty: defaultType,\n v: authoredVariant === undefined\n ? compatibleTypographyVariant(activeType, nativeVariant, contract)\n : String(authoredVariant),\n w: String(authored(attributes.w, attributes.weight) ?? (heading ? \"strong\" : \"default\")),\n foreground: \"primary\"\n };\n}\n\nexport function textHtmlTag(value: unknown): TextHtmlTag {\n const candidate = String(value ?? \"span\");\n return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)\n ? candidate as TextHtmlTag\n : \"span\";\n}\n\nexport function semanticProps(\n attributes: Record<string, unknown>,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS\n): Record<string, unknown> {\n return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {\n strict: process.env.NODE_ENV === \"production\" || process.env.STYLEFLOW_STRICT === \"1\",\n onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)\n });\n}\n\nconst TEXT_ALIGNMENTS = new Set([\n \"left\",\n \"center\",\n \"right\",\n \"justify\",\n \"start\",\n \"end\"\n]);\n\n/** Resolve only Gutenberg's supported text-alignment values to inline CSS. */\nexport function textAlignmentStyle(\n attributes: Record<string, unknown>\n): string | undefined {\n const style = attributes.style && typeof attributes.style === \"object\"\n && !Array.isArray(attributes.style)\n ? attributes.style as Record<string, unknown>\n : {};\n const typography = style.typography && typeof style.typography === \"object\"\n && !Array.isArray(style.typography)\n ? style.typography as Record<string, unknown>\n : {};\n const candidate = typography.textAlign ?? attributes.textAlign;\n const alignment = String(candidate ?? \"\");\n return TEXT_ALIGNMENTS.has(alignment) ? `text-align: ${alignment};` : undefined;\n}\n\nexport function prefixedTextSemanticProps(\n attributes: Record<string, unknown>,\n prefix: string,\n contract?: StyleflowContract,\n defaults: Record<string, unknown> = {}\n): Record<string, unknown> {\n const attributeName = (name: string) =>\n `${prefix}${name.charAt(0).toUpperCase()}${name.slice(1)}`;\n return semanticProps({\n ty: attributes[attributeName(\"ty\")],\n v: attributes[attributeName(\"v\")],\n w: attributes[attributeName(\"w\")],\n foreground: attributes[attributeName(\"foreground\")]\n }, contract, defaults);\n}\n\nexport function objectValue(\n block: FlowpressBlock,\n key: string\n): Record<string, unknown> {\n const value = block.attributes[key];\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n}\n\nexport function textValue(block: FlowpressBlock, key = \"text\"): string {\n return String(block.attributes[key] ?? \"\");\n}\n\n/**\n * Keep intentional blank lines visible across current and legacy RichText\n * serializations. Gutenberg can represent them either as repeated `<br>` tags,\n * empty paragraph elements, or literal newlines in an attribute value.\n */\nexport function preserveRichTextSpacing(html: string): string {\n const visibleEmptyBlocks = html\n .replace(/\\r\\n?/g, \"\\n\")\n .replace(\n /<(p|div)(\\s[^>]*)?>(?:\\s| | )*<\\/\\1>/gi,\n (_match, tag: string, attributes = \"\") =>\n `<${tag}${attributes}> </${tag}>`\n );\n\n return visibleEmptyBlocks\n .split(/(<[^>]+>)/g)\n .map((part) => {\n if (part.startsWith(\"<\") || part.trim() === \"\") {\n return part;\n }\n return part.replace(/\\n(?:[ \\t]*\\n)+/g, (newlines) =>\n \"<br>\".repeat((newlines.match(/\\n/g) || []).length)\n );\n })\n .join(\"\");\n}\n\n/** Keep an empty text element at its typographic line height without visible text. */\nexport function preserveEmptyTextBlock(html: string): string {\n return html.trim() === \"\" ? \" \" : html;\n}\n\nexport function linkValue(block: FlowpressBlock, key = \"link\"): string {\n return flowpressLinkHref(block.attributes[key]);\n}\n\nexport function responsiveValues(\n attributes: Record<string, unknown>,\n prefix: \"columns\" | \"span\",\n fallback: number\n): Record<\"base\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\", number> {\n const keys = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n const result = {} as Record<(typeof keys)[number], number>;\n let inherited = fallback;\n for (const key of keys) {\n const suffix = key === \"base\"\n ? \"Base\"\n : key === \"2xl\" ? \"2xl\" : key.charAt(0).toUpperCase() + key.slice(1);\n const candidate = Number(attributes[`${prefix}${suffix}`]);\n if (Number.isInteger(candidate) && candidate >= 1 && candidate <= 12) {\n inherited = candidate;\n }\n result[key] = inherited;\n }\n return result;\n}\n\nexport function unwrapCoreHtml(html: string): string {\n const match = html.trim().match(\n /^<(p|h[1-6]|ul|ol|li|blockquote)(?:\\s[^>]*)?>([\\s\\S]*)<\\/\\1>$/\n );\n return match?.[2] ?? html;\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
resolveFlowpressBlockStyleflowProps,
|
|
3
3
|
type StyleflowContract
|
|
4
4
|
} from "../../styleflow.js";
|
|
5
5
|
import type { FlowpressBlock } from "../../types.js";
|
|
6
|
+
import { flowpressLinkHref } from "../../links.js";
|
|
6
7
|
|
|
7
8
|
export const DEFAULT_SEMANTIC_PROPS = {
|
|
8
9
|
surface: "default",
|
|
@@ -54,26 +55,6 @@ export function blockHtmlAttributes(
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
const SEMANTIC_KEYS = [
|
|
58
|
-
"theme",
|
|
59
|
-
"tone",
|
|
60
|
-
"intensity",
|
|
61
|
-
"surface",
|
|
62
|
-
"layoutRole",
|
|
63
|
-
"density",
|
|
64
|
-
"ty",
|
|
65
|
-
"v",
|
|
66
|
-
"w",
|
|
67
|
-
"foreground",
|
|
68
|
-
"interactivePriority",
|
|
69
|
-
"noBackground",
|
|
70
|
-
"noBorder",
|
|
71
|
-
"noPadding",
|
|
72
|
-
"noGap",
|
|
73
|
-
"noRadius",
|
|
74
|
-
"noForeground"
|
|
75
|
-
] as const;
|
|
76
|
-
|
|
77
58
|
export const TEXT_HTML_TAGS = [
|
|
78
59
|
"span",
|
|
79
60
|
"p",
|
|
@@ -91,6 +72,63 @@ export const TEXT_HTML_TAGS = [
|
|
|
91
72
|
|
|
92
73
|
export type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];
|
|
93
74
|
|
|
75
|
+
function preferredTypographyVariant(type: string): string | undefined {
|
|
76
|
+
if (type === "heading") return "2";
|
|
77
|
+
if (type === "body" || type === "label" || type === "code") return "md";
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Derive a variant only when Gutenberg omitted it. The selected typography
|
|
83
|
+
* type can differ from the block's native type, so a paragraph styled as a
|
|
84
|
+
* heading must not inherit the paragraph-only `md` variant.
|
|
85
|
+
*/
|
|
86
|
+
export function compatibleTypographyVariant(
|
|
87
|
+
type: string,
|
|
88
|
+
preferred: string,
|
|
89
|
+
contract?: StyleflowContract
|
|
90
|
+
): string {
|
|
91
|
+
const variants = contract?.semantic.axes.typography.variantsByType[type];
|
|
92
|
+
if (!variants?.length) return preferred;
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
preferredTypographyVariant(type),
|
|
96
|
+
preferred,
|
|
97
|
+
contract?.semantic.agentPolicy.defaults.typography.ty === type
|
|
98
|
+
? contract.semantic.agentPolicy.defaults.typography.v
|
|
99
|
+
: undefined,
|
|
100
|
+
variants[0]
|
|
101
|
+
].find((candidate): candidate is string => (
|
|
102
|
+
typeof candidate === "string" && variants.includes(candidate)
|
|
103
|
+
)) ?? preferred;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function textBlockSemanticDefaults(
|
|
107
|
+
blockName: string,
|
|
108
|
+
attributes: Record<string, unknown>,
|
|
109
|
+
contract?: StyleflowContract
|
|
110
|
+
): Record<string, unknown> {
|
|
111
|
+
const name = blockName.replace(/^sf\//, "");
|
|
112
|
+
const heading = name === "heading" || name === "core/heading";
|
|
113
|
+
const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
|
|
114
|
+
const defaultType = heading ? "heading" : "body";
|
|
115
|
+
const authored = (...values: unknown[]) => values.find((value) => value !== undefined && value !== null && value !== "");
|
|
116
|
+
const activeType = String(authored(attributes.ty) ?? defaultType);
|
|
117
|
+
const nativeVariant = heading
|
|
118
|
+
? String(level)
|
|
119
|
+
: name.includes("quote") ? "lg" : "md";
|
|
120
|
+
const authoredVariant = authored(attributes.v, attributes.variant);
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
ty: defaultType,
|
|
124
|
+
v: authoredVariant === undefined
|
|
125
|
+
? compatibleTypographyVariant(activeType, nativeVariant, contract)
|
|
126
|
+
: String(authoredVariant),
|
|
127
|
+
w: String(authored(attributes.w, attributes.weight) ?? (heading ? "strong" : "default")),
|
|
128
|
+
foreground: "primary"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
94
132
|
export function textHtmlTag(value: unknown): TextHtmlTag {
|
|
95
133
|
const candidate = String(value ?? "span");
|
|
96
134
|
return TEXT_HTML_TAGS.includes(candidate as TextHtmlTag)
|
|
@@ -103,25 +141,10 @@ export function semanticProps(
|
|
|
103
141
|
contract?: StyleflowContract,
|
|
104
142
|
defaults: Record<string, unknown> = DEFAULT_SEMANTIC_PROPS
|
|
105
143
|
): Record<string, unknown> {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
if (contract) {
|
|
112
|
-
return resolveDynamicStyleflowProps(input, defaults, contract, {
|
|
113
|
-
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
114
|
-
onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const resolved = { ...defaults, ...input };
|
|
119
|
-
for (const key of ["tone", "intensity", "foreground"]) {
|
|
120
|
-
if (input[key] === "inherit") {
|
|
121
|
-
delete resolved[key];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return resolved;
|
|
144
|
+
return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {
|
|
145
|
+
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
146
|
+
onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
|
|
147
|
+
});
|
|
125
148
|
}
|
|
126
149
|
|
|
127
150
|
const TEXT_ALIGNMENTS = new Set([
|
|
@@ -213,11 +236,7 @@ export function preserveEmptyTextBlock(html: string): string {
|
|
|
213
236
|
}
|
|
214
237
|
|
|
215
238
|
export function linkValue(block: FlowpressBlock, key = "link"): string {
|
|
216
|
-
|
|
217
|
-
const href = typeof value === "string"
|
|
218
|
-
? value
|
|
219
|
-
: String(objectValue(block, key).url ?? "");
|
|
220
|
-
return /^(?:\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i.test(href) ? href : "";
|
|
239
|
+
return flowpressLinkHref(block.attributes[key]);
|
|
221
240
|
}
|
|
222
241
|
|
|
223
242
|
export function responsiveValues(
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "./blob.css";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import { BLOB_BOX, BLOB_VARIANTS } from "./blob/blob-shapes.generated.js";
|
|
5
|
+
import {
|
|
6
|
+
morphDataAttributes,
|
|
7
|
+
resolveAspectRatio,
|
|
8
|
+
resolveContentFit,
|
|
9
|
+
resolveMorphConfig,
|
|
10
|
+
resolveOutlineWidth,
|
|
11
|
+
type BlobAspectRatio,
|
|
12
|
+
type BlobContentFit,
|
|
13
|
+
type BlobMorphMode,
|
|
14
|
+
} from "./blob/config.js";
|
|
15
|
+
import { shapeToPath } from "./blob/geometry.js";
|
|
16
|
+
import { nextBlobClipId } from "./blob/ids.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Organic mask that crops its slot. The fill takes the Styleflow props passed
|
|
20
|
+
* to the component (tone, intensity, surface, layoutRole, density, no*); the
|
|
21
|
+
* outline has its own tone/intensity. Variants 1-13 can morph into each other.
|
|
22
|
+
*/
|
|
23
|
+
interface Props {
|
|
24
|
+
/** 1-13. */
|
|
25
|
+
variant?: number | string | undefined;
|
|
26
|
+
/** `cover` stretches children over the whole shape, `center` keeps their size. */
|
|
27
|
+
contentFit?: BlobContentFit | undefined;
|
|
28
|
+
aspectRatio?: BlobAspectRatio | undefined;
|
|
29
|
+
/** Outline thickness in px; 0 hides it. */
|
|
30
|
+
outlineWidth?: number | string | undefined;
|
|
31
|
+
outlineTone?: string | undefined;
|
|
32
|
+
outlineIntensity?: string | undefined;
|
|
33
|
+
morph?: BlobMorphMode | undefined;
|
|
34
|
+
/** Variants to morph between, e.g. "2,5,9" or [2, 5, 9]; empty means all. */
|
|
35
|
+
morphTargets?: string | number[] | undefined;
|
|
36
|
+
morphDuration?: number | string | undefined;
|
|
37
|
+
/** Pause in ms between two automatic morphs. */
|
|
38
|
+
morphInterval?: number | string | undefined;
|
|
39
|
+
/** Attributes for the root element: id, class, aria-*, data-*. */
|
|
40
|
+
rootProps?: Record<string, unknown> | undefined;
|
|
41
|
+
[styleflowProp: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
variant,
|
|
46
|
+
contentFit,
|
|
47
|
+
aspectRatio,
|
|
48
|
+
outlineWidth,
|
|
49
|
+
outlineTone = "inherit",
|
|
50
|
+
outlineIntensity = "inherit",
|
|
51
|
+
morph,
|
|
52
|
+
morphTargets,
|
|
53
|
+
morphDuration,
|
|
54
|
+
morphInterval,
|
|
55
|
+
rootProps = {},
|
|
56
|
+
...fillProps
|
|
57
|
+
} = Astro.props;
|
|
58
|
+
|
|
59
|
+
const morphConfig = resolveMorphConfig(
|
|
60
|
+
{ variant, morph, targets: morphTargets, duration: morphDuration, interval: morphInterval },
|
|
61
|
+
BLOB_VARIANTS.length,
|
|
62
|
+
);
|
|
63
|
+
const base = BLOB_VARIANTS[morphConfig.base] ?? BLOB_VARIANTS[0]!;
|
|
64
|
+
const fillPath = shapeToPath(base.fill, BLOB_BOX);
|
|
65
|
+
const ringPath = shapeToPath(base.ring, BLOB_BOX);
|
|
66
|
+
const strokeWidth = resolveOutlineWidth(outlineWidth);
|
|
67
|
+
const clipId = nextBlobClipId();
|
|
68
|
+
|
|
69
|
+
// Authors leaving a Styleflow axis on "inherit" send nothing: keep a visible fill.
|
|
70
|
+
const authoredFill = Object.fromEntries(
|
|
71
|
+
Object.entries(fillProps).filter(([, value]) => value !== undefined && value !== null && value !== ""),
|
|
72
|
+
);
|
|
73
|
+
const shapeProps = { surface: "default", layoutRole: "none", ...authoredFill };
|
|
74
|
+
|
|
75
|
+
const { class: rootClassName, ...rootAttributes } = rootProps as Record<string, unknown> & { class?: string };
|
|
76
|
+
const rootClass = ["sf-blob", typeof rootClassName === "string" ? rootClassName : ""]
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join(" ");
|
|
79
|
+
const clipStyle = `clip-path:url(#${clipId})`;
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
<StyleflowElement as="div"
|
|
83
|
+
{...rootAttributes}
|
|
84
|
+
class={rootClass}
|
|
85
|
+
layoutRole="none"
|
|
86
|
+
data-sf-blob
|
|
87
|
+
{...morphDataAttributes(morphConfig)}
|
|
88
|
+
data-blob-fit={resolveContentFit(contentFit)}
|
|
89
|
+
data-blob-aspect={resolveAspectRatio(aspectRatio)}
|
|
90
|
+
>
|
|
91
|
+
<svg class="sf-blob__defs" width="0" height="0" aria-hidden="true" focusable="false">
|
|
92
|
+
<clipPath id={clipId} clipPathUnits="objectBoundingBox">
|
|
93
|
+
<path data-blob-clip-path d={fillPath}></path>
|
|
94
|
+
</clipPath>
|
|
95
|
+
</svg>
|
|
96
|
+
<!-- styleflow-ignore-next-line rule=sf-inline-style reason="Per-instance reference to the blob's SVG clip path" scope="project" -->
|
|
97
|
+
<StyleflowElement as="div" class="sf-blob__shape" {...shapeProps} data-blob-shape style={clipStyle}><slot /></StyleflowElement>
|
|
98
|
+
{strokeWidth > 0 ? (
|
|
99
|
+
<StyleflowElement as="span" class="sf-blob__ring" {...(outlineTone !== "inherit" ? {tone:outlineTone} : {})} {...(outlineIntensity !== "inherit" ? {intensity:outlineIntensity} : {})} aria-hidden="true">
|
|
100
|
+
<svg viewBox="0 0 1 1" preserveAspectRatio="none" focusable="false">
|
|
101
|
+
<path data-blob-ring-path d={ringPath} fill="none" stroke-width={strokeWidth} vector-effect="non-scaling-stroke"></path>
|
|
102
|
+
</svg>
|
|
103
|
+
</StyleflowElement>
|
|
104
|
+
) : null}
|
|
105
|
+
</StyleflowElement>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
// The static shape is complete without JavaScript: load the controller only
|
|
109
|
+
// when a blob on this page actually morphs.
|
|
110
|
+
if (document.querySelector('[data-sf-blob]:not([data-blob-morph="none"])')) {
|
|
111
|
+
void import("./blob/controller.js").then(({ initializeSfBlobs }) => initializeSfBlobs());
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Blob from "./Blob.astro";
|
|
3
|
+
import {
|
|
4
|
+
flowpressBlockHtmlProps,
|
|
5
|
+
resolveFlowpressBlockStyleflowProps,
|
|
6
|
+
resolvePrefixedFlowpressBlockStyleflowProps,
|
|
7
|
+
} from "../../index.js";
|
|
8
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
9
|
+
|
|
10
|
+
// Renders `sf/blob` wherever the semantic renderer meets it: as a top-level
|
|
11
|
+
// composition block and nested inside any other sf/* block. Called from both
|
|
12
|
+
// paths, so it must work with only `block` and `contract` (like CoverBlock).
|
|
13
|
+
type Props = Pick<FlowpressBlockRendererProps, "block"> & Partial<FlowpressBlockRendererProps>;
|
|
14
|
+
const { block, contract, styleflowProps, htmlProps } = Astro.props as Props;
|
|
15
|
+
const attributes = block.attributes;
|
|
16
|
+
const options = {
|
|
17
|
+
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
18
|
+
onDiagnostic: (diagnostic: { code: string; message: string }) =>
|
|
19
|
+
console.warn(`[${diagnostic.code}] ${diagnostic.message}`),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fill: the block's own Styleflow coordinates. Blob keeps a visible default
|
|
23
|
+
// when the author leaves tone/intensity on "inherit".
|
|
24
|
+
const fill = styleflowProps ?? resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);
|
|
25
|
+
// Outline: the same validated contract under the `outline*` attribute prefix.
|
|
26
|
+
const outline = resolvePrefixedFlowpressBlockStyleflowProps(
|
|
27
|
+
attributes,
|
|
28
|
+
"outline",
|
|
29
|
+
contract,
|
|
30
|
+
{},
|
|
31
|
+
options,
|
|
32
|
+
);
|
|
33
|
+
const text = (value: unknown): string | undefined =>
|
|
34
|
+
typeof value === "string" && value !== "" ? value : undefined;
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<Blob
|
|
38
|
+
{...fill}
|
|
39
|
+
variant={text(attributes.variant) ?? (typeof attributes.variant === "number" ? attributes.variant : undefined)}
|
|
40
|
+
contentFit={text(attributes.contentFit) as "cover" | "center" | undefined}
|
|
41
|
+
aspectRatio={text(attributes.aspectRatio) as "natural" | "square" | "portrait" | "landscape" | undefined}
|
|
42
|
+
outlineWidth={attributes.outlineWidth as number | string | undefined}
|
|
43
|
+
outlineTone={text(outline.tone)}
|
|
44
|
+
outlineIntensity={text(outline.intensity)}
|
|
45
|
+
morph={text(attributes.morph) as "none" | "auto" | "hover" | undefined}
|
|
46
|
+
morphTargets={text(attributes.morphTargets)}
|
|
47
|
+
morphDuration={attributes.morphDuration as number | string | undefined}
|
|
48
|
+
morphInterval={attributes.morphInterval as number | string | undefined}
|
|
49
|
+
rootProps={htmlProps ?? flowpressBlockHtmlProps(attributes)}
|
|
50
|
+
>
|
|
51
|
+
<slot />
|
|
52
|
+
</Blob>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import LevelTag from "./LevelTag.astro";
|
|
6
|
+
import { classNames, text, type ResolvedImage } from "./query-loop.js";
|
|
7
|
+
|
|
8
|
+
// Output of the project "Custom field" blocks. The value arrives already
|
|
9
|
+
// normalized for the chosen output (apps/cms/project/src/custom-fields.php);
|
|
10
|
+
// keep the output map in sync with it and with custom-field-editor.js.
|
|
11
|
+
type Props = Pick<FlowpressBlockRendererProps, "block" | "htmlProps" | "styleflowProps"> & {
|
|
12
|
+
baseClass: string;
|
|
13
|
+
};
|
|
14
|
+
const { block, htmlProps, styleflowProps, baseClass } = Astro.props;
|
|
15
|
+
const attributes = block.attributes;
|
|
16
|
+
const resolved = (block.resolvedData ?? {}) as { as?: string | undefined; value?: unknown | undefined; href?: string | undefined; isFallback?: boolean };
|
|
17
|
+
const options = (attributes.options && typeof attributes.options === "object" ? attributes.options : {}) as Record<string, unknown>;
|
|
18
|
+
const as = text(resolved.as);
|
|
19
|
+
const authoredAs = text(attributes.as) || "text";
|
|
20
|
+
const prefix = decodeFlowpressText(attributes.prefix);
|
|
21
|
+
const suffix = decodeFlowpressText(attributes.suffix);
|
|
22
|
+
const TEXT_TAGS = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"];
|
|
23
|
+
const textTag = authoredAs === "text" && TEXT_TAGS.includes(text(options.tag)) ? text(options.tag) : "p";
|
|
24
|
+
const rootProps = {
|
|
25
|
+
...htmlProps,
|
|
26
|
+
class: classNames(baseClass, `project-field--${as || authoredAs}`, as === "image" ? "project-field__image" : "", htmlProps.class),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const image = as === "image" ? (resolved.value ?? {}) as ResolvedImage : {};
|
|
30
|
+
const aspectRatio = text(options.aspectRatio);
|
|
31
|
+
const imageProps = {
|
|
32
|
+
src: text(image.url),
|
|
33
|
+
srcset: image.srcSet || undefined,
|
|
34
|
+
sizes: image.srcSet ? image.sizes || undefined : undefined,
|
|
35
|
+
width: image.width,
|
|
36
|
+
height: image.height,
|
|
37
|
+
alt: image.alt ?? "",
|
|
38
|
+
class: image.id ? `wp-image-${image.id}` : undefined,
|
|
39
|
+
loading: "lazy" as const,
|
|
40
|
+
decoding: "async" as const,
|
|
41
|
+
};
|
|
42
|
+
const link = as === "link" ? (resolved.value ?? {}) as { url?: string | undefined; label?: string | undefined; target?: string } : {};
|
|
43
|
+
const date = as === "date" ? (resolved.value ?? {}) as { datetime?: string | undefined; formatted?: string } : {};
|
|
44
|
+
const list = as === "list" && Array.isArray(resolved.value) ? resolved.value.map(decodeFlowpressText) : [];
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
{as === "" ? null
|
|
48
|
+
: as === "image" ? (
|
|
49
|
+
imageProps.src ? (
|
|
50
|
+
<StyleflowElement as="figure" {...rootProps} {...styleflowProps} data-aspect-ratio={aspectRatio || undefined}>
|
|
51
|
+
{resolved.href ? <StyleflowElement as="a" href={resolved.href}><StyleflowElement as="img" {...imageProps} /></StyleflowElement> : <StyleflowElement as="img" {...imageProps} />}
|
|
52
|
+
</StyleflowElement>
|
|
53
|
+
) : null
|
|
54
|
+
)
|
|
55
|
+
: as === "richtext" ? (
|
|
56
|
+
<StyleflowElement as="div" {...rootProps} {...styleflowProps}>
|
|
57
|
+
{prefix ? <StyleflowElement as="span" class="project-field__prefix">{prefix}</StyleflowElement> : null}
|
|
58
|
+
<Fragment set:html={text(resolved.value)} />
|
|
59
|
+
{suffix ? <StyleflowElement as="span" class="project-field__suffix">{suffix}</StyleflowElement> : null}
|
|
60
|
+
</StyleflowElement>
|
|
61
|
+
)
|
|
62
|
+
: as === "link" ? (
|
|
63
|
+
<StyleflowElement as="p" {...rootProps} {...styleflowProps}>
|
|
64
|
+
{prefix ? <StyleflowElement as="span" class="project-field__prefix">{prefix}</StyleflowElement> : null}
|
|
65
|
+
<StyleflowElement as="a"
|
|
66
|
+
href={link.url}
|
|
67
|
+
class={options.variant === "button" ? "wp-element-button" : undefined}
|
|
68
|
+
target={link.target === "_blank" ? "_blank" : undefined}
|
|
69
|
+
rel={link.target === "_blank" ? "noopener noreferrer" : undefined}
|
|
70
|
+
>{decodeFlowpressText(link.label || link.url)}</StyleflowElement>
|
|
71
|
+
{suffix ? <StyleflowElement as="span" class="project-field__suffix">{suffix}</StyleflowElement> : null}
|
|
72
|
+
</StyleflowElement>
|
|
73
|
+
)
|
|
74
|
+
: as === "list" ? (
|
|
75
|
+
<StyleflowElement as="div" {...rootProps} {...styleflowProps}>
|
|
76
|
+
{prefix ? <StyleflowElement as="span" class="project-field__prefix">{prefix}</StyleflowElement> : null}
|
|
77
|
+
{options.ordered
|
|
78
|
+
? <StyleflowElement as="ol" class="wp-block-list">{list.map((item) => <StyleflowElement as="li">{item}</StyleflowElement>)}</StyleflowElement>
|
|
79
|
+
: <StyleflowElement as="ul" class="wp-block-list">{list.map((item) => <StyleflowElement as="li">{item}</StyleflowElement>)}</StyleflowElement>}
|
|
80
|
+
{suffix ? <StyleflowElement as="span" class="project-field__suffix">{suffix}</StyleflowElement> : null}
|
|
81
|
+
</StyleflowElement>
|
|
82
|
+
)
|
|
83
|
+
: (
|
|
84
|
+
<LevelTag tag={textTag} {...rootProps} {...styleflowProps}>
|
|
85
|
+
{prefix}{as === "date" ? <StyleflowElement as="time" datetime={date.datetime}>{decodeFlowpressText(date.formatted)}</StyleflowElement> : decodeFlowpressText(resolved.value)}{suffix}
|
|
86
|
+
</LevelTag>
|
|
87
|
+
)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
|
|
4
|
+
// Heading (h1–h6), paragraph (0 / "p") or inline span, with Styleflow props.
|
|
5
|
+
interface Props {
|
|
6
|
+
tag: string;
|
|
7
|
+
[attribute: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
const { tag, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
{tag === "h1" ? <StyleflowElement as="h1" {...rest}><slot /></StyleflowElement>
|
|
13
|
+
: tag === "h2" ? <StyleflowElement as="h2" {...rest}><slot /></StyleflowElement>
|
|
14
|
+
: tag === "h3" ? <StyleflowElement as="h3" {...rest}><slot /></StyleflowElement>
|
|
15
|
+
: tag === "h4" ? <StyleflowElement as="h4" {...rest}><slot /></StyleflowElement>
|
|
16
|
+
: tag === "h5" ? <StyleflowElement as="h5" {...rest}><slot /></StyleflowElement>
|
|
17
|
+
: tag === "h6" ? <StyleflowElement as="h6" {...rest}><slot /></StyleflowElement>
|
|
18
|
+
: tag === "span" ? <StyleflowElement as="span" {...rest}><slot /></StyleflowElement>
|
|
19
|
+
: tag === "div" ? <StyleflowElement as="div" {...rest}><slot /></StyleflowElement>
|
|
20
|
+
: <StyleflowElement as="p" {...rest}><slot /></StyleflowElement>}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import {
|
|
4
|
+
flowpressBlockHtmlProps,
|
|
5
|
+
resolveFlowpressBlockStyleflowProps,
|
|
6
|
+
} from "../../index.js";
|
|
7
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
8
|
+
import { resolveMap } from "./map.js";
|
|
9
|
+
|
|
10
|
+
type Props = Pick<FlowpressBlockRendererProps, "block"> & Partial<FlowpressBlockRendererProps>;
|
|
11
|
+
const { block, contract, htmlProps, styleflowProps } = Astro.props as Props;
|
|
12
|
+
const html = htmlProps ?? flowpressBlockHtmlProps(block.attributes);
|
|
13
|
+
const semantic = styleflowProps ?? resolveFlowpressBlockStyleflowProps(block.attributes, contract);
|
|
14
|
+
const map = resolveMap(block.attributes as import("./map.js").MapAttributes, import.meta.env.GOOGLE_MAPS_API_KEY ?? "");
|
|
15
|
+
const label = map.address || `Mappa: ${map.query}`;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{map.query ? (
|
|
19
|
+
<StyleflowElement as="div" {...semantic} {...html}>
|
|
20
|
+
{map.iframeSrc ? (
|
|
21
|
+
<StyleflowElement as="iframe"
|
|
22
|
+
class="sf-map-frame"
|
|
23
|
+
title={label}
|
|
24
|
+
src={map.iframeSrc}
|
|
25
|
+
loading="lazy"
|
|
26
|
+
referrerpolicy="no-referrer-when-downgrade"
|
|
27
|
+
allowfullscreen
|
|
28
|
+
/>
|
|
29
|
+
) : null}
|
|
30
|
+
<StyleflowElement as="a" href={map.linkHref} target="_blank" rel="noopener noreferrer" layoutRole="control" density="compact" interactivePriority="tertiary">Apri la mappa</StyleflowElement>
|
|
31
|
+
</StyleflowElement>
|
|
32
|
+
) : null}
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.sf-map-frame {
|
|
36
|
+
display: block;
|
|
37
|
+
width: 100%;
|
|
38
|
+
min-height: var(--fp-map-min-height, 22rem);
|
|
39
|
+
border: 0;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { nativeHtmlData } from "./html.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const { html, hidden } = nativeHtmlData(block.resolvedData, block.innerHtml);
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
{!hidden && html ? (
|
|
11
|
+
<StyleflowElement as="div" {...htmlProps} {...styleflowProps} data-project-native-html set:html={html} />
|
|
12
|
+
) : null}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { nativeIconSvg, nativeIconWidth } from "./icon.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const svg = nativeIconSvg(block.attributes.icon, block.resolvedData, `fp-icon-${crypto.randomUUID()}`);
|
|
8
|
+
const dimensions = (block.attributes.style as { dimensions?: { width?: unknown } } | undefined)?.dimensions;
|
|
9
|
+
const width = nativeIconWidth(dimensions?.width) ?? "24px";
|
|
10
|
+
const label = typeof block.attributes.ariaLabel === "string" ? block.attributes.ariaLabel.trim() : "";
|
|
11
|
+
const align = ["left", "center", "right"].includes(String(block.attributes.align)) ? `align${block.attributes.align}` : "";
|
|
12
|
+
const semantic = {
|
|
13
|
+
...styleflowProps,
|
|
14
|
+
...(!block.attributes.layoutRole ? { layoutRole: "none" as const } : {}),
|
|
15
|
+
};
|
|
16
|
+
const rootProps = {
|
|
17
|
+
...htmlProps,
|
|
18
|
+
class: ["wp-block-icon", align, htmlProps.class].filter(Boolean).join(" "),
|
|
19
|
+
style: [htmlProps.style, `--fp-core-icon-width:${width}`].filter(Boolean).join(";"),
|
|
20
|
+
};
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<!-- styleflow-ignore-start rule=SF_INLINE_STYLE reason="Validated structural icon width from the native Gutenberg control" scope="Native icon pilot" -->
|
|
24
|
+
{svg ? <StyleflowElement as="div"
|
|
25
|
+
{...rootProps}
|
|
26
|
+
{...semantic}
|
|
27
|
+
data-icon={block.attributes.icon}
|
|
28
|
+
role={label ? "img" : undefined}
|
|
29
|
+
aria-label={label || undefined}
|
|
30
|
+
aria-hidden={label ? undefined : "true"}
|
|
31
|
+
set:html={svg}
|
|
32
|
+
/> : null}
|
|
33
|
+
<!-- styleflow-ignore-end -->
|
|
34
|
+
|
|
35
|
+
<style is:global>
|
|
36
|
+
/* Match the native WordPress icon geometry and inherit Styleflow foreground. */
|
|
37
|
+
.wp-block-icon { width: var(--fp-core-icon-width, 24px); max-width: 100%; line-height: 0; }
|
|
38
|
+
.wp-block-icon > svg { display: block; width: 100%; height: auto; max-width: 100%; fill: currentColor; }
|
|
39
|
+
.wp-block-icon.aligncenter { margin-inline: auto; }
|
|
40
|
+
.wp-block-icon.alignright { margin-inline-start: auto; }
|
|
41
|
+
.wp-block-icon.alignleft { margin-inline-end: auto; }
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type {
|
|
3
|
+
FlowpressBlockRendererProps
|
|
4
|
+
} from "../../index.js";
|
|
5
|
+
import Timeline from "./Timeline.astro";
|
|
6
|
+
import {
|
|
7
|
+
normalizeTimelineIntensity,
|
|
8
|
+
normalizeTimelineTone,
|
|
9
|
+
timelineItemsFromBlocks
|
|
10
|
+
} from "./timeline.js";
|
|
11
|
+
|
|
12
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
13
|
+
|
|
14
|
+
function optionalAttribute(
|
|
15
|
+
attributes: Record<string, unknown>,
|
|
16
|
+
name: string
|
|
17
|
+
): string | undefined {
|
|
18
|
+
const value = String(attributes[name] ?? "").trim();
|
|
19
|
+
return value || undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const tone = normalizeTimelineTone(block.attributes.tone);
|
|
23
|
+
const intensity = normalizeTimelineIntensity(block.attributes.intensity);
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<Timeline
|
|
27
|
+
rootProps={htmlProps}
|
|
28
|
+
styleflowProps={styleflowProps}
|
|
29
|
+
items={timelineItemsFromBlocks(block.innerBlocks ?? [])}
|
|
30
|
+
tone={tone}
|
|
31
|
+
intensity={intensity}
|
|
32
|
+
id={optionalAttribute(block.attributes, "anchor")}
|
|
33
|
+
class={optionalAttribute(block.attributes, "className")}
|
|
34
|
+
/>
|