efficient-web-builder 49.0.0 → 50.0.0
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 +28 -0
- package/dist/editor/components/EditorPagePathProvider.d.ts +4 -0
- package/dist/editor/components/EditorPagePathProvider.js +1 -0
- package/dist/editor/components/PagesPanel.js +1 -1
- package/dist/editor/components/PartSettingsPanel.js +1 -1
- package/dist/editor/components/PreviewPartAnchors.d.ts +2 -2
- package/dist/editor/components/PreviewPartAnchors.js +1 -1
- package/dist/editor/components/SectionTextPartBridge.d.ts +3 -1
- package/dist/editor/components/SectionTextPartBridge.js +1 -1
- package/dist/editor/components/SourceStatus.d.ts +3 -3
- package/dist/editor/components/SourceStatus.js +1 -1
- package/dist/editor/components/StorefrontEditor.js +1 -1
- package/dist/editor/components/WebsiteScreenParts.js +1 -1
- package/dist/editor/lib/animation/hover-fields.js +1 -1
- package/dist/editor/lib/document/add-target.js +1 -1
- package/dist/editor/lib/document/block-source-fields.d.ts +6 -0
- package/dist/editor/lib/document/block-source-fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Cards/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/ContactLocations/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Flex/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/HeroGroup/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/PaymentBadges/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Text/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/index.d.ts +2 -2
- package/dist/editor/lib/document/card-display-chips.d.ts +9 -3
- package/dist/editor/lib/document/card-display-chips.js +1 -1
- package/dist/editor/lib/document/card-row-fields.js +1 -1
- package/dist/editor/lib/document/field-groups.js +1 -1
- package/dist/editor/lib/document/mirror-cards-field.d.ts +20 -0
- package/dist/editor/lib/document/mirror-cards-field.js +1 -0
- package/dist/editor/lib/document/slot-new-children.d.ts +2 -0
- package/dist/editor/lib/document/slot-new-children.js +1 -0
- package/dist/editor/lib/sections/hero-ticker-to-strip.js +1 -1
- package/dist/editor/lib/sections/new-section-node.js +1 -1
- package/dist/format/lib/content/block-sources.d.ts +11 -0
- package/dist/format/lib/content/block-sources.js +1 -1
- package/dist/format/lib/content/box-layout.d.ts +2 -0
- package/dist/format/lib/content/box-layout.js +1 -1
- package/dist/format/lib/content/card-place.d.ts +8 -0
- package/dist/format/lib/content/card-place.js +1 -0
- package/dist/format/lib/content/card-template.d.ts +16 -2
- package/dist/format/lib/content/card-template.js +1 -1
- package/dist/format/lib/content/mirror-cards.d.ts +32 -0
- package/dist/format/lib/content/mirror-cards.js +1 -0
- package/dist/format/lib/document/blocks/general/Cards/card-seed.d.ts +15 -0
- package/dist/format/lib/document/blocks/general/Cards/card-seed.js +1 -0
- package/dist/format/lib/document/blocks/general/Cards/meta.d.ts +6 -0
- package/dist/format/lib/document/blocks/general/Cards/meta.js +1 -1
- package/dist/format/lib/document/blocks/general/text-part-shapes.json +8 -0
- package/dist/format/lib/document/cards-template-on-read.d.ts +4 -0
- package/dist/format/lib/document/cards-template-on-read.js +1 -0
- package/dist/format/lib/document/editor-page-context.js +1 -1
- package/dist/format/lib/document/renamed-props.js +1 -1
- package/dist/format/lib/document/section-catalog.js +22 -2
- package/dist/format/lib/document/seed-parts.d.ts +18 -0
- package/dist/format/lib/document/seed-parts.js +1 -0
- package/dist/format/lib/editor-page-rows.d.ts +2 -0
- package/dist/format/lib/editor-page-rows.js +1 -1
- package/dist/format/lib/editor-words-catalogue.d.ts +20 -4
- package/dist/format/lib/editor-words-catalogue.js +4 -4
- package/dist/format/lib/hero-ticker.d.ts +4 -0
- package/dist/format/lib/hero-ticker.js +1 -1
- package/dist/format/lib/page-at-own-slug.d.ts +9 -0
- package/dist/format/lib/page-at-own-slug.js +1 -0
- package/dist/format/lib/popup/new-popup.js +1 -1
- package/dist/format/lib/sections/faq-text-regions.js +1 -1
- package/dist/format/lib/sections/section-text-regions.d.ts +1 -0
- package/dist/format/lib/sections/section-text-regions.js +1 -1
- package/dist/format/lib/sections/text-regions.d.ts +2 -0
- package/dist/format/lib/sections/text-regions.js +1 -1
- package/dist/render/components/CardRowContext.d.ts +1 -0
- package/dist/render/components/CardRowContext.js +1 -1
- package/dist/render/components/Cards.d.ts +4 -2
- package/dist/render/components/Cards.js +1 -1
- package/dist/render/components/FAQ.js +1 -1
- package/dist/render/components/Flex.d.ts +6 -1
- package/dist/render/components/Flex.js +1 -1
- package/dist/render/components/MirrorContext.d.ts +3 -0
- package/dist/render/components/MirrorContext.js +1 -0
- package/dist/render/components/SiteGutterFrame.d.ts +1 -0
- package/dist/render/components/SiteGutterFrame.js +1 -1
- package/dist/render/components/Text.d.ts +3 -1
- package/dist/render/components/Text.js +1 -1
- package/dist/render/components/TextRegionRun.d.ts +7 -0
- package/dist/render/components/TextRegionRun.js +1 -0
- package/dist/render/lib/content/box-shared-columns.d.ts +31 -0
- package/dist/render/lib/content/box-shared-columns.js +1 -0
- package/dist/render/lib/document/blocks/general/Cards/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Flex/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Text/render.js +1 -1
- package/dist/render/lib/document/blocks/general/section-head-looks.d.ts +1 -2
- package/dist/render/lib/document/blocks/general/section-head-looks.js +2 -2
- package/dist/render/lib/document/blocks/general/section-to-box-row-parts.d.ts +1 -5
- package/dist/render/lib/document/blocks/general/section-to-box-row-parts.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-cards.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-locations.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-timeline.js +2 -2
- package/dist/render/lib/document/blocks/general/section-to-box-rows.js +1 -1
- package/dist/render/lib/document/editing-bridges.d.ts +2 -0
- package/dist/render/lib/document/part-styles.d.ts +26 -0
- package/dist/render/lib/document/part-styles.js +2 -2
- package/dist/render/lib/document/passes/section-width.js +1 -1
- package/dist/render/lib/sections/section-to-box.d.ts +7 -7
- package/dist/render/lib/sections/section-to-box.js +1 -1
- package/dist/render/lib/site-runtime.d.ts +2 -0
- package/dist/render/lib/site-runtime.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
import type { PartStyles } from "./part-styles.js";
|
|
2
3
|
export type SectionTextPartsProps = {
|
|
3
4
|
nodeId: string;
|
|
4
5
|
sectionType: string;
|
|
6
|
+
partStyles?: PartStyles;
|
|
5
7
|
children: ReactNode;
|
|
6
8
|
};
|
|
7
9
|
export type EditingBridges = {
|
|
@@ -2,6 +2,7 @@ import { type TextStyleCase } from "efficient-easel/draw";
|
|
|
2
2
|
import { type FontRole } from "../../../format/lib/fonts.js";
|
|
3
3
|
import type { PartEl } from "../../../editor/lib/document/part-anchors.js";
|
|
4
4
|
import { type PartNeedle } from "./text-parts.js";
|
|
5
|
+
import { type TextRegion } from "../../../format/lib/sections/text-regions.js";
|
|
5
6
|
export declare const PART_STYLES_PROP = "_partStyles";
|
|
6
7
|
export declare const PART_STYLED_ATTR = "data-sf-part-styled";
|
|
7
8
|
export declare const TEXT_STYLE_ATTR = "data-sf-text-style";
|
|
@@ -117,6 +118,13 @@ export declare function partSpacingOf(style: PartStyle): {
|
|
|
117
118
|
export declare const PART_PARAGRAPH_VAR = "--sf-part-para";
|
|
118
119
|
export declare function partPhoneDeclarations(style: PartStyle): Record<string, string>;
|
|
119
120
|
export declare function partStyleForScreen(style: PartStyle, phone: boolean): PartStyle;
|
|
121
|
+
export declare function partCanvasDeclarations(style: PartStyle, phone: boolean, options?: PartDeclarationOptions): Record<string, string>;
|
|
122
|
+
export declare function partStyleWithoutSizeBox(style: PartStyle, phone: boolean): PartStyle;
|
|
123
|
+
export type ShownDeclarations = {
|
|
124
|
+
fontFamily?: string;
|
|
125
|
+
fontSize?: string;
|
|
126
|
+
};
|
|
127
|
+
export declare function partShownDeclarations(style: PartStyle, phone: boolean, options?: PartDeclarationOptions): ShownDeclarations;
|
|
120
128
|
export declare function partStyleDeclarations(style: PartStyle, base: PartStyleBase, options?: PartDeclarationOptions): Record<string, string>;
|
|
121
129
|
export type MeasuredPartStyle = {
|
|
122
130
|
fontSize: string;
|
|
@@ -132,7 +140,25 @@ export declare function partFontKeyOf(family: string, resolve: (cssVar: string)
|
|
|
132
140
|
export declare function partStyleSource<E extends {
|
|
133
141
|
getAttribute(name: string): string | null;
|
|
134
142
|
}>(nodeId: string, selectedPartId: string | null, selectedElements: readonly E[], declaresStyle: (className: string | null) => boolean): E | null;
|
|
143
|
+
export declare function storedPartStyle(styles: PartStyles, styleKey: string): PartStyle;
|
|
135
144
|
export declare function applyPartStyles(stamps: readonly StyledPartStamp[], styles: PartStyles, baseOf?: (element: StyledPartEl) => PartStyleBase, styleKeyOf?: (partKey: string) => string, isInline?: (element: StyledPartEl) => boolean, phone?: boolean, drawsStyle?: (partKey: string) => boolean): number;
|
|
145
|
+
export declare function regionSheetStyle(style: PartStyle | undefined | null): PartStyle | null;
|
|
146
|
+
export declare function regionCanvasDeclarations(style: PartStyle | undefined | null, phone: boolean): {
|
|
147
|
+
fontFamily?: string;
|
|
148
|
+
fontSize?: string;
|
|
149
|
+
};
|
|
150
|
+
export declare function regionHasOwnLook(style: PartStyle | undefined | null): boolean;
|
|
151
|
+
export declare function regionShownDeclarations(style: PartStyle | undefined | null, region: TextRegion, phone: boolean): ShownDeclarations;
|
|
152
|
+
export declare function regionCanvasRestore(style: {
|
|
153
|
+
fontFamily: string;
|
|
154
|
+
fontSize: string;
|
|
155
|
+
}, prior: {
|
|
156
|
+
fontFamily: string;
|
|
157
|
+
fontSize: string;
|
|
158
|
+
}, painted: {
|
|
159
|
+
fontFamily?: string;
|
|
160
|
+
fontSize?: string;
|
|
161
|
+
}): void;
|
|
136
162
|
export declare const PART_PARAGRAPH_ATTR = "data-sf-part-para";
|
|
137
163
|
export declare const PART_STYLE_PROPERTIES: readonly string[];
|
|
138
164
|
export declare const SHARED_PART_PROPERTIES: readonly string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{textStyleCaseCss as q,textStyleCaseOfCss as J}from"efficient-easel/draw";import{parseHexColor as Q}from"efficient-shell/format";import{FONT_OPTIONS as tt,fontOption as et,fontRoleOf as b,SIZE_STEP_OF_ROLE as M}from"../../../format/lib/fonts.js";import{encodePartKey as nt}from"../../../format/lib/document/part-key.js";import{decodePartId as F,normalizePartText as E}from"./text-parts.js";import{COLOUR_TOKEN as L}from"../../../format/lib/word-styles.js";import{PHONE_MEDIA as rt}from"../content/view-values.js";import{plainRecord as $,propsWithPartRecord as ot,readPartRecord as it,readPartRecords as st}from"../../../format/lib/document/part-records.js";const y="_partStyles",at="data-sf-part-styled",H="data-sf-text-style",ct=/^(heading|body)-[1-7]$/;function T(t){return typeof t=="string"&&ct.test(t)}const j={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function ft(t){if(!t)return null;for(const[e,n]of Object.entries(j))if(n===t)return e;return null}function le(t){if(T(t.textStyle))return t.textStyle;const e=b(t.role);return e?j[e]:void 0}const lt=[400,500,600,700],_=["left","center","right","justify"],D=5,C=1e3,ut=-5,pt=10,dt=0,xt=64,ht=2,K={size:{min:D,max:C,step:1},sizePhone:{min:D,max:C,step:1},padding:{min:dt,max:xt,step:ht}},gt=.05,Pt=.01,mt=["line","letter"],St=.5,Tt=2.5,Rt=-1,bt=1,_t=0,At=400,Et=[...new Set(Object.values(M))];function ue(t){return[`${t} { transition: translate var(--page-motion-hover-duration) var(--page-ease-media) var(--page-motion-hover-delay) }`,`${t}:hover, ${t}:active { translate: 0 calc(-1 * var(--page-hover-lift)) }`]}function pe(t){return st(t,y)}function W(t,e){return it(t,y,e)}function de(t,e){return Object.values(W(t,e)).filter(n=>n!==void 0).length}function G(t,e,n){return ot(t,y,e,$t(n).length?n:null)}function $t(t){return Object.entries(t).filter(([,e])=>e!==void 0)}function yt(t){return mt.includes(t)}const R=(t,e,n)=>Math.min(n,Math.max(e,t));function Nt(t,e){if(yt(t)){const n=Math.round(Number(e));return!Number.isFinite(n)||n===0?null:R(n,ut,pt)}if(t==="lineHeight"){const n=Number(e);return Number.isFinite(n)?m(R(n,St,Tt),3):null}if(t==="letterSpacing"){const n=Number(e);return Number.isFinite(n)?m(R(n,Rt,bt),4):null}if(t==="paragraphSpacing"){const n=Math.round(Number(e));return!Number.isFinite(n)||n<=0?null:R(n,_t,At)}if(Object.hasOwn(K,t)){const{min:n,max:r}=K[t],o=Math.round(Number(e));return Number.isFinite(o)?R(o,n,r):null}return t==="italic"?typeof e=="boolean"?e:null:t==="role"||t==="fontRole"?b(e)?e:null:t==="sizeToken"?O(e)?e:null:t==="textStyle"?T(e)?e:null:t==="alignPhone"?_.includes(e)?e:null:e}const Ot=["weight","size","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function N(t){let e=null;const n=r=>{e??={...t},delete e[r]};for(const r of Ot){const o=t[r];o!==void 0&&!(typeof o=="number"&&Number.isFinite(o))&&n(r)}return t.align!==void 0&&!_.includes(t.align)&&n("align"),t.alignPhone!==void 0&&!_.includes(t.alignPhone)&&n("alignPhone"),t.textStyle!==void 0&&!T(t.textStyle)&&n("textStyle"),t.sizeToken!==void 0&&!O(t.sizeToken)&&n("sizeToken"),t.fontRole!==void 0&&!b(t.fontRole)&&n("fontRole"),e??t}function O(t){if(!t||typeof t!="object")return!1;const{step:e,px:n,stepPhone:r,pxPhone:o,fluid:i}=t,s=f=>typeof f=="number"&&Number.isFinite(f)&&f>0,c=f=>typeof f=="string"&&Et.includes(f);return c(e)&&s(n)&&(r===void 0||c(r))&&(o===void 0||s(o))&&(i===void 0||wt(i,n))}function wt(t,e){if(!t||typeof t!="object"||Array.isArray(t))return!1;const{minPx:n,vw:r,...o}=t;return Object.keys(o).length===0&&typeof n=="number"&&Number.isFinite(n)&&n>0&&n<e&&typeof r=="number"&&Number.isFinite(r)&&r>0&&r<=100}function X(t){return t?.pxPhone&&O(t)?{step:t.stepPhone??t.step,px:t.pxPhone}:null}function U({step:t,px:e,fluid:n}){const r=n?`clamp(${n.minPx}px, ${n.vw}vw, ${e}px)`:`${e}px`,o=`var(--size-${t}, ${r})`;return t.startsWith("heading")?`min(${o}, var(--sf-heading-max,9999px))`:o}const zt=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function It(t){const e=[];for(const[n,r]of zt)n===t?e.push(r):r===t&&e.push(n);return e}function xe(t,e,n,r){const o={...W(t,e)},i=r==null?null:Nt(n,r);if(i===null)delete o[n];else{o[n]=i;for(const s of It(n))delete o[s]}return G(t,e,o)}function he(t,e){return G(t,e,{})}function kt(t){return J(t)??"none"}function Mt(t){return q(t)??""}const V={heading:"--font-role-heading",heading2:"--font-role-heading2",heading3:"--font-role-heading3",body:"--font-role-body",accent:"--font-role-accent",label:"--font-role-label"};function Ft(t,e){const n=b(t.role);return n||(e?.blockDrawsStyle?null:ft(t.textStyle))}function ge(t,e){return t==="Text"&&e==="text"}const Lt={headingLarge:"min(clamp(64px,9vw,144px), var(--sf-heading-max,9999px))",headingMedium:"min(32px, var(--sf-heading-max,9999px))",headingSmall:"min(24px, var(--sf-heading-max,9999px))",accent:"32px",body:"14px",label:"12px"};function Ht(t){const e=M[t],n=Lt[e];return n?`var(--size-${e}, ${n})`:`var(--size-${e})`}function jt(t){const e={};return typeof t.lineHeight=="number"?e.lineHeight=t.lineHeight:t.line&&(e.lineHeight=m(Dt+t.line*gt,3)),typeof t.letterSpacing=="number"?e.letterSpacingEm=t.letterSpacing:t.letter&&(e.letterSpacingEm=m(t.letter*Pt,4)),e}const Dt=1,P="--sf-part-para";function Ct(t){t=N(t);const e={};if(typeof t.sizePhone=="number"&&t.sizePhone>0)e.fontSize=`${t.sizePhone}px`;else{const n=X(t.sizeToken);n&&(e.fontSize=U(n))}return t.alignPhone&&(e.textAlign=t.alignPhone),e}function Kt(t,e){if(!e)return t;const n=N(t);let r=t;if(typeof n.sizePhone=="number"&&n.sizePhone>0)r={...r,size:n.sizePhone};else{const o=X(n.sizeToken);o&&(r={...r,size:void 0,sizeToken:o})}return n.alignPhone&&(r={...r,align:n.alignPhone}),r}function w(t,e,n){t=N(t);const r=Ft(t,n),o=jt(t),i=t.size?`${t.size}px`:t.sizeToken?U(t.sizeToken):r?Ht(r):"";return{fontFamily:t.font?Ut(t.font):t.fontRole?`var(${V[t.fontRole]})`:r?`var(${V[r]})`:"",fontWeight:t.weight?String(t.weight):"",fontSize:i,minWidth:i?"0":"",overflowWrap:i?"break-word":"",lineHeight:o.lineHeight!==void 0?String(o.lineHeight):"",letterSpacing:o.letterSpacingEm!==void 0?`${o.letterSpacingEm}em`:"",[P]:t.paragraphSpacing?`${t.paragraphSpacing}px`:"",textTransform:Mt(t.case),textAlign:t.align??"",paddingTop:Y(t.padding),paddingBottom:Y(t.padding),color:Wt(t.color),fontStyle:t.italic===!0?"italic":t.italic===!1?"normal":""}}const Wt=t=>t===void 0||t===""?"":Object.hasOwn(L,t)?L[t]:Q(t)===t.toLowerCase()?t:"",Y=t=>t===void 0?"":`${t}px`,m=(t,e)=>Number(t.toFixed(e));function Pe(t,e){const n=Number.parseFloat(t.fontSize)||16,r=Number.parseFloat(t.lineHeight),o=Number.parseFloat(t.letterSpacing),i=Number.parseFloat(t.paddingTop);return{fontKey:e,sizePx:n,weight:Gt(Number.parseInt(t.fontWeight,10)),lineRatio:Number.isFinite(r)?m(r/n,3):1.2,letterEm:Number.isFinite(o)?m(o/n,4):0,align:Xt(t.textAlign),case:kt(t.textTransform),paddingPx:Number.isFinite(i)?Math.round(i):0}}function Gt(t){return Number.isFinite(t)?lt.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e):400}function Xt(t){for(const e of _)if(e===t)return e;return t==="end"?"right":"left"}function me(t,e){const n=v(t);if(!n)return"";for(const r of tt)if(v(e(r.cssVar))===n)return r.key;return""}const v=t=>(t.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function Ut(t){const e=et(t);return e?`var(${e.cssVar})`:""}function Se(t,e,n,r){return!e||F(e)?.nodeId!==t?null:n.find(i=>r(i.getAttribute("class")))??n[0]??null}function Te(t,e,n=()=>A,r=c=>c,o=vt,i=!1,s=()=>!1){let c=0;for(const{element:f,partId:u}of t){const l=F(u)?.propKey;if(!l)continue;const p=r(l),d=Object.hasOwn(e,p)?$(e[p])??{}:{},a=w(Kt(d,i),A,{blockDrawsStyle:s(l)});T(d.textStyle)?f.setAttribute?.(H,d.textStyle):f.removeAttribute?.(H);const h=I.some(x=>f.style[x]);let g=!1;for(const[x,S]of Object.entries(a))Bt(f,x,S),S&&(g=!0);if(h||I.some(x=>a[x]))for(const x of Vt(f,o))for(const S of I)x.style[S]=a[S]??"";g&&(c+=1)}return c}function Vt(t,e){const n=E(t.textContent??""),r=[];let o=t;for(let i=0;i<Yt&&e(o);i+=1){const s=o.parentElement;if(!s||E(s.textContent??"")!==n)break;r.push(s),o=s}return r}const Yt=8;function vt(t){const e=t;return typeof window>"u"||!e?.ownerDocument?!1:window.getComputedStyle(e).display==="inline"}const A={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Bt(t,e,n){if(!e.startsWith("--")){t.style[e]=n;return}const r=t.style;typeof r.setProperty=="function"?n?r.setProperty(e,n):r.removeProperty?.(e):r[e]=n;const o=t;e===P&&(n?o.setAttribute?.(B,""):o.removeAttribute?.(B))}const B="data-sf-part-para",Zt=Object.keys(w({},A)),z=new Set(["color","overflowWrap",P,"fontStyle"]),I=Zt.filter(t=>!z.has(t));function Re(t,e,n,r=c=>c,o=()=>!1,i=()=>null,s=[]){const c=new Map;for(const l of t){const p=nt(l.key,l.row);for(const d of l.texts){const a=c.get(d);a?(a.keys.add(l.key),a.partKeys.add(p)):c.set(d,{keys:new Set([l.key]),partKeys:new Set([p])})}}const f=new Map;for(const l of new Set([...Object.keys(e),...s])){if(!qt(l))continue;const p=Z(n,l,$(e[l])??{},!1,i(l));p&&f.set(l,p)}const u=new Map;for(const[l,{keys:p,partKeys:d}]of c){const a=d.size===1?[...d][0]:p.size===1?[...p][0]:null;if(!a)continue;const h=r(a),g=i(h);if(!Object.hasOwn(e,h)&&!g)continue;const k=$(e[h])??{},x=Z(n,a,k,o(a),g);x&&u.set(l,x)}return u.size||f.size?{rules:u,kindRules:f,drawn:new Set(c.keys())}:null}function Z(t,e,n,r,o){const i=w(n,A,{blockDrawsStyle:r}),s=Ct(n),c=T(n.textStyle)?n.textStyle:void 0;return!Object.values(i).some(Boolean)&&!Object.keys(s).length&&!c&&!o?null:{stamp:Jt(t,e),declarations:i,...Object.keys(s).length?{phone:s}:{},...c?{textStyle:c}:{},...o?{motion:o}:{}}}function qt(t){return t.startsWith("@")}function be(t,e){return t?.kindRules.get(e)??null}function Jt(t,e){const n=r=>r.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(t)}~${n(e)}`}function _e(t){const e=[],n=new Set,r=o=>{const{stamp:i,declarations:s}=o;if(n.has(i))return;n.add(i);const c=Object.entries(s).filter(([,a])=>a!==""),f=a=>a.map(([h,g])=>`${te(h)}: ${g}`).join("; "),u=`[${at}="${i}"]`,l=c.filter(([a])=>!z.has(a)),p=c.filter(([a])=>z.has(a));l.length&&e.push(`${u}, *:has(> ${u}) { ${f(l)} }`),p.length&&e.push(`${u} { ${f(p)} }`),s[P]&&(e.push(`*:has(> ${u}) { ${P}: ${s[P]} }`),e.push(...Qt(u,`*:has(> ${u})`)));const d=Object.entries(o.phone??{}).filter(([,a])=>a!=="");d.length&&e.push(`@media ${rt} { ${u}, *:has(> ${u}) { ${f(d)} } }`)};for(const o of t.rules.values())r(o);for(const o of t.kindRules.values())r(o);return e.join(`
|
|
2
|
-
`)}function
|
|
1
|
+
import{textStyleCaseCss as J,textStyleCaseOfCss as Q}from"efficient-easel/draw";import{parseHexColor as tt}from"efficient-shell/format";import{FONT_OPTIONS as et,fontOption as nt,fontRoleOf as R,SIZE_STEP_OF_ROLE as z}from"../../../format/lib/fonts.js";import{encodePartKey as ot}from"../../../format/lib/document/part-key.js";import{decodePartId as L,normalizePartText as E}from"./text-parts.js";import{COLOUR_TOKEN as M}from"../../../format/lib/word-styles.js";import{regionStyle as rt}from"../../../format/lib/sections/text-regions.js";import{PHONE_MEDIA as it}from"../content/view-values.js";import{plainRecord as O,propsWithPartRecord as at,readPartRecord as st,readPartRecords as ft}from"../../../format/lib/document/part-records.js";const $="_partStyles",ct="data-sf-part-styled",H="data-sf-text-style",ut=/^(heading|body)-[1-7]$/;function g(t){return typeof t=="string"&&ut.test(t)}const j={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function lt(t){if(!t)return null;for(const[e,n]of Object.entries(j))if(n===t)return e;return null}function Se(t){if(g(t.textStyle))return t.textStyle;const e=R(t.role);return e?j[e]:void 0}const pt=[400,500,600,700],_=["left","center","right","justify"],D=5,C=1e3,dt=-5,xt=10,ht=0,St=64,gt=2,W={size:{min:D,max:C,step:1},sizePhone:{min:D,max:C,step:1},padding:{min:ht,max:St,step:gt}},mt=.05,Pt=.01,Tt=["line","letter"],bt=.5,Rt=2.5,_t=-1,At=1,zt=0,Et=400,Ot=[...new Set(Object.values(z))];function ge(t){return[`${t} { transition: translate var(--page-motion-hover-duration) var(--page-ease-media) var(--page-motion-hover-delay) }`,`${t}:hover, ${t}:active { translate: 0 calc(-1 * var(--page-hover-lift)) }`]}function me(t){return ft(t,$)}function K(t,e){return st(t,$,e)}function Pe(t,e){return Object.values(K(t,e)).filter(n=>n!==void 0).length}function G(t,e,n){return at(t,$,e,$t(n).length?n:null)}function $t(t){return Object.entries(t).filter(([,e])=>e!==void 0)}function yt(t){return Tt.includes(t)}const b=(t,e,n)=>Math.min(n,Math.max(e,t));function wt(t,e){if(yt(t)){const n=Math.round(Number(e));return!Number.isFinite(n)||n===0?null:b(n,dt,xt)}if(t==="lineHeight"){const n=Number(e);return Number.isFinite(n)?P(b(n,bt,Rt),3):null}if(t==="letterSpacing"){const n=Number(e);return Number.isFinite(n)?P(b(n,_t,At),4):null}if(t==="paragraphSpacing"){const n=Math.round(Number(e));return!Number.isFinite(n)||n<=0?null:b(n,zt,Et)}if(Object.hasOwn(W,t)){const{min:n,max:o}=W[t],r=Math.round(Number(e));return Number.isFinite(r)?b(r,n,o):null}return t==="italic"?typeof e=="boolean"?e:null:t==="role"||t==="fontRole"?R(e)?e:null:t==="sizeToken"?w(e)?e:null:t==="textStyle"?g(e)?e:null:t==="alignPhone"?_.includes(e)?e:null:e}const Nt=["weight","size","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function y(t){let e=null;const n=o=>{e??={...t},delete e[o]};for(const o of Nt){const r=t[o];r!==void 0&&!(typeof r=="number"&&Number.isFinite(r))&&n(o)}return t.align!==void 0&&!_.includes(t.align)&&n("align"),t.alignPhone!==void 0&&!_.includes(t.alignPhone)&&n("alignPhone"),t.textStyle!==void 0&&!g(t.textStyle)&&n("textStyle"),t.sizeToken!==void 0&&!w(t.sizeToken)&&n("sizeToken"),t.fontRole!==void 0&&!R(t.fontRole)&&n("fontRole"),e??t}function w(t){if(!t||typeof t!="object")return!1;const{step:e,px:n,stepPhone:o,pxPhone:r,fluid:i}=t,a=f=>typeof f=="number"&&Number.isFinite(f)&&f>0,s=f=>typeof f=="string"&&Ot.includes(f);return s(e)&&a(n)&&(o===void 0||s(o))&&(r===void 0||a(r))&&(i===void 0||It(i,n))}function It(t,e){if(!t||typeof t!="object"||Array.isArray(t))return!1;const{minPx:n,vw:o,...r}=t;return Object.keys(r).length===0&&typeof n=="number"&&Number.isFinite(n)&&n>0&&n<e&&typeof o=="number"&&Number.isFinite(o)&&o>0&&o<=100}function v(t){return t?.pxPhone&&w(t)?{step:t.stepPhone??t.step,px:t.pxPhone}:null}function X({step:t,px:e,fluid:n}){const o=n?`clamp(${n.minPx}px, ${n.vw}vw, ${e}px)`:`${e}px`,r=`var(--size-${t}, ${o})`;return t.startsWith("heading")?`min(${r}, var(--sf-heading-max,9999px))`:r}const Ft=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function kt(t){const e=[];for(const[n,o]of Ft)n===t?e.push(o):o===t&&e.push(n);return e}function Te(t,e,n,o){const r={...K(t,e)},i=o==null?null:wt(n,o);if(i===null)delete r[n];else{r[n]=i;for(const a of kt(n))delete r[a]}return G(t,e,r)}function be(t,e){return G(t,e,{})}function Lt(t){return Q(t)??"none"}function Mt(t){return J(t)??""}const B={heading:"--font-role-heading",heading2:"--font-role-heading2",heading3:"--font-role-heading3",body:"--font-role-body",accent:"--font-role-accent",label:"--font-role-label"};function Ht(t,e){const n=R(t.role);return n||(e?.blockDrawsStyle?null:lt(t.textStyle))}function Re(t,e){return t==="Text"&&e==="text"}const jt={headingLarge:"min(clamp(64px,9vw,144px), var(--sf-heading-max,9999px))",headingMedium:"min(32px, var(--sf-heading-max,9999px))",headingSmall:"min(24px, var(--sf-heading-max,9999px))",accent:"32px",body:"14px",label:"12px"};function Dt(t){const e=z[t],n=jt[e];return n?`var(--size-${e}, ${n})`:`var(--size-${e})`}function Ct(t){const e={};return typeof t.lineHeight=="number"?e.lineHeight=t.lineHeight:t.line&&(e.lineHeight=P(Wt+t.line*mt,3)),typeof t.letterSpacing=="number"?e.letterSpacingEm=t.letterSpacing:t.letter&&(e.letterSpacingEm=P(t.letter*Pt,4)),e}const Wt=1,m="--sf-part-para";function Kt(t){t=y(t);const e={};if(typeof t.sizePhone=="number"&&t.sizePhone>0)e.fontSize=`${t.sizePhone}px`;else{const n=v(t.sizeToken);n&&(e.fontSize=X(n))}return t.alignPhone&&(e.textAlign=t.alignPhone),e}function Gt(t,e){if(!e)return t;const n=y(t);let o=t;if(typeof n.sizePhone=="number"&&n.sizePhone>0)o={...o,size:n.sizePhone};else{const r=v(n.sizeToken);r&&(o={...o,size:void 0,sizeToken:r})}return n.alignPhone&&(o={...o,align:n.alignPhone}),o}function N(t,e,n){return I(Gt(t,e),A,n)}function U(t,e){const n=e?"sizePhone":"size";if(!Object.hasOwn(t,n))return t;const o={...t};return delete o[n],o}function _e(t,e,n){const o=N(U(t,e),e,n);return{fontFamily:o.fontFamily,fontSize:o.fontSize}}function I(t,e,n){t=y(t);const o=Ht(t,n),r=Ct(t),i=t.size?`${t.size}px`:t.sizeToken?X(t.sizeToken):o?Dt(o):"";return{fontFamily:t.font?Ut(t.font):t.fontRole?`var(${B[t.fontRole]})`:o?`var(${B[o]})`:"",fontWeight:t.weight?String(t.weight):"",fontSize:i,minWidth:i?"0":"",overflowWrap:i?"break-word":"",lineHeight:r.lineHeight!==void 0?String(r.lineHeight):"",letterSpacing:r.letterSpacingEm!==void 0?`${r.letterSpacingEm}em`:"",[m]:t.paragraphSpacing?`${t.paragraphSpacing}px`:"",textTransform:Mt(t.case),textAlign:t.align??"",paddingTop:V(t.padding),paddingBottom:V(t.padding),color:vt(t.color),fontStyle:t.italic===!0?"italic":t.italic===!1?"normal":""}}const vt=t=>t===void 0||t===""?"":Object.hasOwn(M,t)?M[t]:tt(t)===t.toLowerCase()?t:"",V=t=>t===void 0?"":`${t}px`,P=(t,e)=>Number(t.toFixed(e));function Ae(t,e){const n=Number.parseFloat(t.fontSize)||16,o=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.letterSpacing),i=Number.parseFloat(t.paddingTop);return{fontKey:e,sizePx:n,weight:Xt(Number.parseInt(t.fontWeight,10)),lineRatio:Number.isFinite(o)?P(o/n,3):1.2,letterEm:Number.isFinite(r)?P(r/n,4):0,align:Bt(t.textAlign),case:Lt(t.textTransform),paddingPx:Number.isFinite(i)?Math.round(i):0}}function Xt(t){return Number.isFinite(t)?pt.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e):400}function Bt(t){for(const e of _)if(e===t)return e;return t==="end"?"right":"left"}function ze(t,e){const n=Y(t);if(!n)return"";for(const o of et)if(Y(e(o.cssVar))===n)return o.key;return""}const Y=t=>(t.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function Ut(t){const e=nt(t);return e?`var(${e.cssVar})`:""}function Ee(t,e,n,o){return!e||L(e)?.nodeId!==t?null:n.find(i=>o(i.getAttribute("class")))??n[0]??null}function Vt(t,e){return Object.hasOwn(t,e)?O(t[e])??{}:{}}function Oe(t,e,n=()=>A,o=s=>s,r=qt,i=!1,a=()=>!1){let s=0;for(const{element:f,partId:p}of t){const c=L(p)?.propKey;if(!c)continue;const l=Vt(e,o(c)),d=N(l,i,{blockDrawsStyle:a(c)});g(l.textStyle)?f.setAttribute?.(H,l.textStyle):f.removeAttribute?.(H);const u=k.some(x=>f.style[x]);let h=!1;for(const[x,S]of Object.entries(d))te(f,x,S),S&&(h=!0);if(u||k.some(x=>d[x]))for(const x of Yt(f,r))for(const S of k)x.style[S]=d[S]??"";h&&(s+=1)}return s}function Yt(t,e){const n=E(t.textContent??""),o=[];let r=t;for(let i=0;i<Zt&&e(r);i+=1){const a=r.parentElement;if(!a||E(a.textContent??"")!==n)break;o.push(a),r=a}return o}const Zt=8;function qt(t){const e=t;return typeof window>"u"||!e?.ownerDocument?!1:window.getComputedStyle(e).display==="inline"}const A={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Jt(t){if(!t||typeof t!="object")return null;const e={};return g(t.textStyle)&&(e.textStyle=t.textStyle),typeof t.size=="number"&&t.size>0&&(e.size=t.size),typeof t.sizePhone=="number"&&t.sizePhone>0&&(e.sizePhone=t.sizePhone),Object.keys(e).length?e:null}function Qt(t,e){const n=Jt(t);if(!n)return{};const o=N(n,e);return{...o.fontFamily?{fontFamily:o.fontFamily}:{},...o.fontSize?{fontSize:o.fontSize}:{}}}function $e(t){return g(t?.textStyle)||!!t?.role||typeof t?.size=="number"&&t.size>0}function ye(t,e,n){if(!t||typeof t!="object")return{};const o=rt(t.role,e,z)??{},r=e.sized?Qt(U(t,n),n):{};return{...o,...r}}function we(t,e,n){n.fontFamily&&t.fontFamily===n.fontFamily&&(t.fontFamily=e.fontFamily),n.fontSize&&t.fontSize===n.fontSize&&(t.fontSize=e.fontSize)}function te(t,e,n){if(!e.startsWith("--")){t.style[e]=n;return}const o=t.style;typeof o.setProperty=="function"?n?o.setProperty(e,n):o.removeProperty?.(e):o[e]=n;const r=t;e===m&&(n?r.setAttribute?.(Z,""):r.removeAttribute?.(Z))}const Z="data-sf-part-para",ee=Object.keys(I({},A)),F=new Set(["color","overflowWrap",m,"fontStyle"]),k=ee.filter(t=>!F.has(t));function Ne(t,e,n,o=s=>s,r=()=>!1,i=()=>null,a=[]){const s=new Map;for(const c of t){const l=ot(c.key,c.row);for(const d of c.texts){const u=s.get(d);u?(u.keys.add(c.key),u.partKeys.add(l)):s.set(d,{keys:new Set([c.key]),partKeys:new Set([l])})}}const f=new Map;for(const c of new Set([...Object.keys(e),...a])){if(!ne(c))continue;const l=q(n,c,O(e[c])??{},!1,i(c));l&&f.set(c,l)}const p=new Map;for(const[c,{keys:l,partKeys:d}]of s){const u=d.size===1?[...d][0]:l.size===1?[...l][0]:null;if(!u)continue;const h=o(u),T=i(h);if(!Object.hasOwn(e,h)&&!T)continue;const x=O(e[h])??{},S=q(n,u,x,r(u),T);S&&p.set(c,S)}return p.size||f.size?{rules:p,kindRules:f,drawn:new Set(s.keys())}:null}function q(t,e,n,o,r){const i=I(n,A,{blockDrawsStyle:o}),a=Kt(n),s=g(n.textStyle)?n.textStyle:void 0;return!Object.values(i).some(Boolean)&&!Object.keys(a).length&&!s&&!r?null:{stamp:oe(t,e),declarations:i,...Object.keys(a).length?{phone:a}:{},...s?{textStyle:s}:{},...r?{motion:r}:{}}}function ne(t){return t.startsWith("@")}function Ie(t,e){return t?.kindRules.get(e)??null}function oe(t,e){const n=o=>o.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(t)}~${n(e)}`}function Fe(t){const e=[],n=new Set,o=r=>{const{stamp:i,declarations:a}=r;if(n.has(i))return;n.add(i);const s=Object.entries(a).filter(([,u])=>u!==""),f=u=>u.map(([h,T])=>`${ie(h)}: ${T}`).join("; "),p=`[${ct}="${i}"]`,c=s.filter(([u])=>!F.has(u)),l=s.filter(([u])=>F.has(u));c.length&&e.push(`${p}, *:has(> ${p}) { ${f(c)} }`),l.length&&e.push(`${p} { ${f(l)} }`),a[m]&&(e.push(`*:has(> ${p}) { ${m}: ${a[m]} }`),e.push(...re(p,`*:has(> ${p})`)));const d=Object.entries(r.phone??{}).filter(([,u])=>u!=="");d.length&&e.push(`@media ${it} { ${p}, *:has(> ${p}) { ${f(d)} } }`)};for(const r of t.rules.values())o(r);for(const r of t.kindRules.values())o(r);return e.join(`
|
|
2
|
+
`)}function re(t,e){const n=`var(${m})`,o=":is([data-sf-bullet], [data-sf-number])";return[`${t} br:not(br + br) { display: block; content: ""; margin-top: ${n} }`,`${t} ${o}:not(:first-child) { margin-top: ${n} }`,`${t} ${o}:not(:last-child) { margin-bottom: ${n} }`,`:is(${e}) + :is(${e}) { margin-top: ${n} }`]}const ie=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);function ke(t,e){if(!t)return null;const n=E(e),o=t.rules.get(n);if(o)return o;if(n.length<ae||t.drawn.has(n))return null;let r=null;for(const[i,a]of t.rules)if(i.includes(n)){if(r&&r.stamp!==a.stamp)return null;r=a}return r}const ae=8;export{_ as PART_ALIGNS,At as PART_LETTER_EM_MAX,_t as PART_LETTER_EM_MIN,Pt as PART_LETTER_STEP,Rt as PART_LINE_HEIGHT_MAX,bt as PART_LINE_HEIGHT_MIN,mt as PART_LINE_STEP,W as PART_MEASURED_TRACKS,xt as PART_NUDGE_MAX,dt as PART_NUDGE_MIN,St as PART_PADDING_MAX,ht as PART_PADDING_MIN,gt as PART_PADDING_STEP,Z as PART_PARAGRAPH_ATTR,Et as PART_PARAGRAPH_MAX,zt as PART_PARAGRAPH_MIN,m as PART_PARAGRAPH_VAR,Tt as PART_RELATIVE_PROPS,C as PART_SIZE_MAX,D as PART_SIZE_MIN,Ot as PART_SIZE_STEPS,ct as PART_STYLED_ATTR,$ as PART_STYLES_PROP,ee as PART_STYLE_PROPERTIES,pt as PART_WEIGHTS,k as SHARED_PART_PROPERTIES,j as STYLE_ID_OF_ROLE,H as TEXT_STYLE_ATTR,Oe as applyPartStyles,Re as blockDrawsTextStyle,Se as followedStyleOf,ne as isPartKindKey,g as isTextStyleId,re as paragraphRules,N as partCanvasDeclarations,Lt as partCaseOfTransform,Mt as partCaseTransform,ze as partFontKeyOf,ge as partLiftRules,Kt as partPhoneDeclarations,Ie as partRuleForKind,ke as partRuleForText,_e as partShownDeclarations,Ct as partSpacingOf,Ae as partStyleBase,Pe as partStyleCount,Fe as partStyleCss,I as partStyleDeclarations,Gt as partStyleForScreen,Ee as partStyleSource,U as partStyleWithoutSizeBox,Te as propsWithPartStyleValue,be as propsWithoutPartStyle,Ne as publishedPartStyles,K as readPartStyle,me as readPartStyles,Qt as regionCanvasDeclarations,we as regionCanvasRestore,$e as regionHasOwnLook,Jt as regionSheetStyle,ye as regionShownDeclarations,Vt as storedPartStyle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as u}from"react/jsx-runtime";import{resolveContainerDirection as S}from"../../../../format/lib/content/container-direction.js";import{HERO_BACKGROUND_VAR as v,HERO_CHROME_CAP_VAR as A,HERO_CHROME_INSET_VAR as B,SITE_WIDTH_CAP as f,centredCap as I,heroBackgroundTokens as W}from"../../../../format/lib/content/page-width.js";import{SECTION_WIDTH_FAMILY as y,hasWidthFamily as g,resolveWidth as C,siteWidthsOf as G}from"../../../../format/lib/content/section-width.js";import{boxGutterOf as b,boxPlaceOf as F,isFrameContainer as T,siteDrawsGutter as H}from"../../../../format/lib/content/site-gutter.js";import{getEditorSiteContentWidth as P}from"../../../../format/lib/document/editor-site-widths.js";import{NestedBoxChoice as D,SplitBandAndColumn as M}from"../../../components/SiteGutterFrame.js";import{FRAME as m}from"../../../components/BlockFrame.js";import{sectionFillPassClass as k}from"../../../../format/lib/content/section-min-height.js";import{parentCapsWidth as V}from"../../../../format/lib/sections/section-head-placement.js";import{addShowWhenFacts as p,withRowsShownWhen as h}from"../../../../format/lib/document/show-when-attach.js";import{findParentNode as j,isNestedNode as L}from"../../../../format/lib/document/passes/document-position.js";const N="--sf-sw-site",U="--sf-sw-content",K="--sf-bg-cap",Y="contents [--sf-site-width:var(--sf-sw-content)] max-view-wide:[--sf-site-width:var(--sf-sw-site)]";function O(t,e){return t==="full"&&e!=="content"?"100vw":null}function E(t,e){return e===null?t:u("div",{className:"contents",style:{[N]:f},children:u("div",{className:Y,style:{[U]:e},children:t})})}const $="--sf-content-cap",q="contents max-view-wide:[--sf-content-cap:none]";function z(t,e){return t==="full"||e==="content"?null:`var(${N})`}function J(t,e){return e===null?t:u("div",{className:"contents",style:{[N]:f},children:u("div",{className:q,style:{[$]:e},children:t})})}const _=(t,e,n="")=>t==="content"?u("div",{className:n||void 0,style:I(f),children:e}):e;function x(t,e,n,o,i){return n==="full"?_(o,t({...e,contained:!1}),i):o==="content"?t({...e,contained:!0}):u(M,{children:t({...e,contained:!0})})}function Q(t,e){const n=y[e],o=t.render;t.render=i=>{const s=G(i),r=s.content??"content";if(n==="hero"){const d=s.background,l=E(o(i),O(r,d));return d==="full"?u("div",{style:{[v]:"none",[B]:"initial",[A]:"initial"},children:l}):d==="content"?u("div",{style:W(!0),children:l}):l}const c=s.background??"full",a=k(i);if(n==="scrollOver"){const d=o({...i,fullWidth:r==="full"});return c==="content"?u("div",{className:"contents",style:{[K]:f},children:d}):d}switch(n){case"both":return _(c,J(o(i),z(r,c)),a);case"contained":{const d=x(o,i,r,c,a);if(!T(e))return d;const l=b(i),w=l===void 0?r:l?"content":"full";return w===r?d:u(D,{atTop:d,nested:x(o,i,w,c,a)})}case"contentColumn":case"contentFull":case"productGrid":{const l=o({...i,widthMode:r==="full"?"full":"page"});return n==="productGrid"?c==="content"?u("div",{className:a?`${m} ${a}`:m,children:l}):l:_(c,l,a)}default:return _(c,E(o(i),O(r,c)),a)}}}const wt={name:"sectionWidth",applies:(t,e,n)=>g(t)&&!!n&&typeof n.render=="function",panel(t,e,n){if(!T(e))return;const o=n.boxGutterFields();t.fields=R(e,t,{...t.fields,...o},Object.keys(o))},draw(t,e){Q(t,e)}};function X(t,e){if(!t||!("widthMode"in t))return t;const n={...t},o=n.widthMode;return o&&(n.widthMode={...o,currentValue:e.mode,inherited:e.inherited}),n}const Z=new Set(["Heading","Text","ImageBlock","ButtonBlock"]),Ct={name:"containedWidth",applies:(t,e,n)=>Z.has(t)&&!!n&&typeof n.render=="function",panel(t,e,n){const o=n.widthField;t.fields=R(e,t,{...t.fields,...o("page")});const i=t.resolveFields;t.resolveFields=(s,r)=>{const c=i?i(s,r):r.fields,a=C(s?.props??{},"page"),d=l=>X(l,a);return c&&typeof c.then=="function"?c.then(d):d(c)}},draw(t){const e=t.render;t.render=n=>{const{mode:o}=C(n,"page");return e({...n,contained:o!=="full"})}}},tt={not:{context:"inHeroGroupRow",is:!0}},Tt={name:"buttonAlignInRow",applies:t=>t==="ButtonBlock",panel(t){const e=t;e.fields=h(e.fields??{},["align"],tt),p(e,{inHeroGroupRow:(n,o)=>{const i=j(o.appState,n.props?.id);return!!i&&i.type==="HeroGroup"&&S("HeroGroup",i.props?.direction)==="row"}})}};function et(t){return Object.values(t).some(e=>!!e&&typeof e=="object"&&e.type==="slot")}const nt={any:[]},ot={all:[{context:"
|
|
1
|
+
import{jsx as u}from"react/jsx-runtime";import{resolveContainerDirection as S}from"../../../../format/lib/content/container-direction.js";import{HERO_BACKGROUND_VAR as v,HERO_CHROME_CAP_VAR as A,HERO_CHROME_INSET_VAR as B,SITE_WIDTH_CAP as f,centredCap as I,heroBackgroundTokens as W}from"../../../../format/lib/content/page-width.js";import{SECTION_WIDTH_FAMILY as y,hasWidthFamily as g,resolveWidth as C,siteWidthsOf as G}from"../../../../format/lib/content/section-width.js";import{boxGutterOf as b,boxPlaceOf as F,isFrameContainer as T,siteDrawsGutter as H}from"../../../../format/lib/content/site-gutter.js";import{getEditorSiteContentWidth as P}from"../../../../format/lib/document/editor-site-widths.js";import{NestedBoxChoice as D,SplitBandAndColumn as M}from"../../../components/SiteGutterFrame.js";import{FRAME as m}from"../../../components/BlockFrame.js";import{sectionFillPassClass as k}from"../../../../format/lib/content/section-min-height.js";import{parentCapsWidth as V}from"../../../../format/lib/sections/section-head-placement.js";import{addShowWhenFacts as p,withRowsShownWhen as h}from"../../../../format/lib/document/show-when-attach.js";import{findParentNode as j,isNestedNode as L}from"../../../../format/lib/document/passes/document-position.js";const N="--sf-sw-site",U="--sf-sw-content",K="--sf-bg-cap",Y="contents [--sf-site-width:var(--sf-sw-content)] max-view-wide:[--sf-site-width:var(--sf-sw-site)]";function O(t,e){return t==="full"&&e!=="content"?"100vw":null}function E(t,e){return e===null?t:u("div",{className:"contents",style:{[N]:f},children:u("div",{className:Y,style:{[U]:e},children:t})})}const $="--sf-content-cap",q="contents max-view-wide:[--sf-content-cap:none]";function z(t,e){return t==="full"||e==="content"?null:`var(${N})`}function J(t,e){return e===null?t:u("div",{className:"contents",style:{[N]:f},children:u("div",{className:q,style:{[$]:e},children:t})})}const _=(t,e,n="")=>t==="content"?u("div",{className:n||void 0,style:I(f),children:e}):e;function x(t,e,n,o,i){return n==="full"?_(o,t({...e,contained:!1}),i):o==="content"?t({...e,contained:!0}):u(M,{children:t({...e,contained:!0})})}function Q(t,e){const n=y[e],o=t.render;t.render=i=>{const s=G(i),r=s.content??"content";if(n==="hero"){const d=s.background,l=E(o(i),O(r,d));return d==="full"?u("div",{style:{[v]:"none",[B]:"initial",[A]:"initial"},children:l}):d==="content"?u("div",{style:W(!0),children:l}):l}const c=s.background??"full",a=k(i);if(n==="scrollOver"){const d=o({...i,fullWidth:r==="full"});return c==="content"?u("div",{className:"contents",style:{[K]:f},children:d}):d}switch(n){case"both":return _(c,J(o(i),z(r,c)),a);case"contained":{const d=x(o,i,r,c,a);if(!T(e))return d;const l=b(i),w=l===void 0?r:l?"content":"full";return w===r?d:u(D,{atTop:d,nested:x(o,i,w,c,a)})}case"contentColumn":case"contentFull":case"productGrid":{const l=o({...i,widthMode:r==="full"?"full":"page"});return n==="productGrid"?c==="content"?u("div",{className:a?`${m} ${a}`:m,children:l}):l:_(c,l,a)}default:return _(c,E(o(i),O(r,c)),a)}}}const wt={name:"sectionWidth",applies:(t,e,n)=>g(t)&&!!n&&typeof n.render=="function",panel(t,e,n){if(!T(e))return;const o=n.boxGutterFields();t.fields=R(e,t,{...t.fields,...o},Object.keys(o))},draw(t,e){Q(t,e)}};function X(t,e){if(!t||!("widthMode"in t))return t;const n={...t},o=n.widthMode;return o&&(n.widthMode={...o,currentValue:e.mode,inherited:e.inherited}),n}const Z=new Set(["Heading","Text","ImageBlock","ButtonBlock"]),Ct={name:"containedWidth",applies:(t,e,n)=>Z.has(t)&&!!n&&typeof n.render=="function",panel(t,e,n){const o=n.widthField;t.fields=R(e,t,{...t.fields,...o("page")});const i=t.resolveFields;t.resolveFields=(s,r)=>{const c=i?i(s,r):r.fields,a=C(s?.props??{},"page"),d=l=>X(l,a);return c&&typeof c.then=="function"?c.then(d):d(c)}},draw(t){const e=t.render;t.render=n=>{const{mode:o}=C(n,"page");return e({...n,contained:o!=="full"})}}},tt={not:{context:"inHeroGroupRow",is:!0}},Tt={name:"buttonAlignInRow",applies:t=>t==="ButtonBlock",panel(t){const e=t;e.fields=h(e.fields??{},["align"],tt),p(e,{inHeroGroupRow:(n,o)=>{const i=j(o.appState,n.props?.id);return!!i&&i.type==="HeroGroup"&&S("HeroGroup",i.props?.direction)==="row"}})}};function et(t){return Object.values(t).some(e=>!!e&&typeof e=="object"&&e.type==="slot")}const nt={any:[]},ot={all:[{not:{context:"outsideBox",is:!0}},{not:{context:"insideSiteGutter",is:!0}}]},it={not:{context:"widthCappedByParent",is:!0}};function R(t,e,n,o=["widthMode"]){if(t==="ButtonBlock")return h(n,["_gWidth",...o],nt);if(et(n)){const i=(s,r)=>F(r.appState?.data?.content,s.props?.id,H(P()));return p(e,{outsideBox:(s,r)=>i(s,r)?.inBox!==!0,insideSiteGutter:(s,r)=>i(s,r)?.insideGutter}),h(n,o,ot)}return p(e,{widthCappedByParent:(i,s)=>"parent"in s?V(s.parent):L({props:i.props??{}},s)}),h(n,o,it)}export{K as SECTION_BACKGROUND_VAR,q as SECTION_CONTENT_CAP_CLASS,$ as SECTION_CONTENT_CAP_VAR,Y as SECTION_CONTENT_CLASS,U as SECTION_CONTENT_VAR,N as SITE_CONTENT_VAR,Tt as buttonAlignInRow,Ct as containedWidth,wt as sectionWidth,X as widthModeFields};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BlockSeed } from "../../../format/lib/document/seed-parts.js";
|
|
1
2
|
import type { StoredTextStyle } from "../text-styles/site-text-styles.js";
|
|
2
3
|
import { type ThemeColors, type ThemeValue } from "../../../format/lib/theme.js";
|
|
3
4
|
type Props = Record<string, unknown>;
|
|
@@ -102,11 +103,7 @@ export type ListGroups = {
|
|
|
102
103
|
rowName?: string;
|
|
103
104
|
rowProps?: Props;
|
|
104
105
|
};
|
|
105
|
-
export type BlockSeed
|
|
106
|
-
type: string;
|
|
107
|
-
props?: Props;
|
|
108
|
-
slots?: Readonly<Record<string, readonly BlockSeed[]>>;
|
|
109
|
-
};
|
|
106
|
+
export type { BlockSeed } from "../../../format/lib/document/seed-parts.js";
|
|
110
107
|
export type SlotFill = BlockSeed | ListPart;
|
|
111
108
|
type PartRowKind = {
|
|
112
109
|
kind: "text";
|
|
@@ -153,7 +150,11 @@ type PartRowKind = {
|
|
|
153
150
|
as?: string;
|
|
154
151
|
rename?: Readonly<Record<string, string>>;
|
|
155
152
|
props?: Props;
|
|
156
|
-
slots?: Readonly<Record<string, readonly SlotFill[]
|
|
153
|
+
slots?: Readonly<Record<string, readonly SlotFill[]>> | ((node: Props, ctx: ConvertContext) => Readonly<Record<string, readonly SlotFill[]>>);
|
|
154
|
+
derive?: {
|
|
155
|
+
reads: readonly string[];
|
|
156
|
+
props: (node: Props, ctx: ConvertContext) => Props;
|
|
157
|
+
};
|
|
157
158
|
};
|
|
158
159
|
export interface SectionToBoxRow {
|
|
159
160
|
name: string;
|
|
@@ -194,4 +195,3 @@ export type SectionToBoxEdit = {
|
|
|
194
195
|
nodes: SectionNode[];
|
|
195
196
|
};
|
|
196
197
|
export declare function sectionToBoxEdits(content: unknown, on?: readonly string[], ctx?: ConvertContext): SectionToBoxEdit[];
|
|
197
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readHidable as Z}from"efficient-easel/draw";import{BOX_TYPE as ee,CONTAINER_BLOCKS_SLOT as te}from"../../../format/lib/document/container-blocks.js";import{headingTextSeed as oe,labelTextSeed as ne}from"../../../format/lib/document/text-seeds.js";import{SPLITTABLE_SECTIONS as se}from"../../../format/lib/sections/section-head-placement.js";import{finiteNumber as R}from"../../../format/lib/finite-number.js";import{bucketByGroup as re}from"../../../format/lib/locations-grid.js";import{normalizeTheme as V}from"../../../format/lib/theme.js";const P=ee,E=te;function $e(t){if(t.theme)return V(t.theme);const o=t.site?.themePresets;return o?V({selected:t.site?.selectedPreset??0,themes:[...o]}):void 0}function ie(t,o){return o===0?`${t}~box`:`${t}~box-${o+1}`}const A={Flex:"the Box itself",Hero:"its slides hold Boxes of real blocks (Hero › Slide › Box), and its Scrolling Bar is a Box in its strip slot (Hero › Box)",Divider:"one block with no text, picture or button",CustomHTML:"the HTML box is the whole section; it has no parts"};function Oe(t){for(const[o,r]of Object.entries(t)){if(o in A&&A[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" is already Box-native`);A[o]=r}}function Se(t){return A[t]}const Y=new Set(["id"]),B={},H=[],ce=[];function Be(t){for(const[o,r]of Object.entries(t)){if(o in B&&B[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" already has a row`);B[o]=r}}function Te(t){return B[t]}function _e(){return Object.keys(B)}function ae(t){return t in B&&H.includes(t)}function Pe(t,o=ce){return t in B&&(o.includes(t)||ae(t))}function Ee(t){const o=se[t];if(!o)throw new Error(`lib/sections/section-to-box: "${t}" has no head row in SPLITTABLE_SECTIONS`);const r=[{kind:"text",key:o.num,role:"eyebrow"},{kind:"text",key:o.title,role:"heading"}];return o.description&&r.push({kind:"text",key:o.description,role:"body"}),o.headRows.includes("linkText")&&o.headRows.includes("linkHref")&&r.push({kind:"button",key:"linkText",href:"linkHref"}),r}const W=t=>Z(t),je=t=>W(t).text.trim()!=="";function fe(t){return t.replace(/==(.+?)==/g,(o,r)=>r.startsWith("_")&&r.endsWith("_")?o:`==_${r}_==`)}function le(t){if(t.includes("=="))return t;const o=t.indexOf("/"),r=o===-1?t:t.slice(0,o),i=r.trim();if(!i)return t;const h=r.indexOf(i);return`${r.slice(0,h)}==${i}==${r.slice(h+i.length)}${o===-1?"":t.slice(o)}`}const de=t=>t==="heading"?oe():t==="eyebrow"?ne():{};function pe(t,o,r,i){const a={...t._partStyles?.text??{},...o??{},...r??{}};return(i==="center"||i==="right")&&a.align===void 0&&(a.align=i),Object.keys(a).length?{_partStyles:{text:a}}:{}}function ue(t,o){if(t===void 0)return{};if(typeof t=="string")return{variant:t};const r=o[t.key];return{variant:typeof r=="string"&&Object.hasOwn(t.map,r)?t.map[r]:t.fallback}}function D(t,o,r,i,h={}){const a={...o};for(const y of t){const[x,S,v]=typeof y=="string"?[y,y,void 0]:y;if(r[x]===void 0)continue;const T=v?v(r[x],r,h):r[x];T===void 0?delete a[S]:a[S]=T,i(x,S,T===void 0)}return a}function he(t){const o=new Set([...Y,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),r=h=>{for(const a of h??[])o.add(typeof a=="string"?a:a[0])},i=h=>{for(const a of h)switch(a.kind){case"text":case"image":o.add(a.key),a.kind==="image"&&a.alt&&o.add(a.alt);break;case"button":o.add(a.key),o.add(a.href),typeof a.variant=="object"&&o.add(a.variant.key);break;case"list":o.add(a.key);break;case"group":case"block":r(a.box),i(a.parts??[]);break;case"core":a.keep!=="rest"&&a.keep.forEach(y=>o.add(y)),Object.keys(a.rename??{}).forEach(y=>o.add(y));for(const y of Object.values(a.slots??{}))for(const x of y)"kind"in x&&o.add(x.key);break}};for(const h of[t,...t.also??[]])r(h.box),i(h.parts);return o}function q(t,o,r={}){const i=t.props,h=o.skip?.(i);if(h!==void 0)return{node:t,nodes:[t],carried:[],dropped:[],siteWrites:[],restyled:[],skipped:h};const a=String(i.id??t.type),y=[],x=[],S=[],v=new Set,T=(n,s)=>{y.push({key:n,home:s}),v.add(n)},X=i._partStyles??{},L=he(o);let J=0;const w=(n,s)=>({type:n,props:{...s,id:`${a}~${n}-${++J}`}}),F=(n,s,b,u,g,l,$)=>{if(g){for(const c of n??[]){const p=typeof c=="string"?c:c[0];b[p]!==void 0&&$(p,`nothing — the ${u} has no parts, so it is not drawn`)}return}const e=typeof s=="function"?s(i,r):s??{};return D(n??[],e,b,(c,p,f)=>$(c,f?`nothing — the old value draws nothing (${u}: no ${p})`:`${l}${u}: ${p}`),r)},K=n=>n.map(s=>{const b={...s.props??{}};for(const[u,g]of Object.entries(s.slots??{}))b[u]=K(g);return w(s.type,b)}),M=(n,s,b)=>{const u=n.of?n.of(s):Array.isArray(s[n.key])?s[n.key]:[],g=typeof n.props=="function"?n.props(i,r):n.props??{},l=u.map((f,d)=>{const k=f??{},m=n.item?.(k,d,i)??{},j=I(m.reverse?[...n.parts].reverse():n.parts,k,!1,`item ${d+1}: `);return n.flat?m.props?j.map(_=>({..._,props:{..._.props,...m.props,id:_.props.id}})):j:[w(P,{name:`${n.name} ${d+1}`,...g,...m.props??{},[E]:j})]});if(n.groups){const f=n.groups;return b(n.key,u.length?`one Box per item (${u.length}), in a Box per group`:"nothing — the list is empty"),re(u.map(d=>d??{}),f.of,f.of).map((d,k)=>{const m=d.items.map(O=>O.item),j=f.parts?I(f.parts,f.head?.(m,i)??{},!1,`group ${k+1}: `):[],_=d.items.map(O=>l[O.index]),z=f.perRow?.(m.length,i),N=Number.isInteger(z)&&z>=1?z:1,C=[];if(f.perRow&&N<_.length)for(let O=0;O*N<_.length;O++)C.push(_.slice(O*N,(O+1)*N).flat());return w(P,{name:`${f.name} ${k+1}`,...f.props??{},[E]:[...j,w(P,{name:`${f.itemsName} ${k+1}`,...f.itemsProps?.(m.length,i)??{},[E]:C.length?C.map((O,U)=>w(P,{name:`${f.rowName??`${f.itemsName} row`} ${U+1}`,...f.rowProps??{},[E]:O})):_.flat()})]})})}const $=n.perRow?.(i),e=n.perRow?Number.isInteger($)&&$>=1?$:1:0;if(b(n.key,(u.length?n.flat?`each item's parts (${u.length} items), in order`:`one Box per item (${u.length}), its parts inside`:"nothing — the list is empty")+(e&&u.length?`, in rows of ${e}`:"")),!e)return l.flat();const c=typeof n.rowProps=="function"?n.rowProps(i,r):n.rowProps??{},p=[];for(let f=0;f*e<l.length;f++){const d=l.slice(f*e,(f+1)*e).flat(),k=n.rowFiller?e-l.slice(f*e,(f+1)*e).length:0;p.push(w(P,{name:`${n.rowName??`${n.name} row`} ${f+1}`,...c,[E]:[...d,...Array.from({length:k},(m,j)=>w(P,{name:`Empty ${j+1}`,...n.rowFiller,[E]:[]}))]}))}return p},I=(n,s,b,u)=>{const g=[],l=(e,c)=>b?T(e,c):void 0,$=e=>b?X[e]:void 0;for(const e of n)if(!(e.when&&!e.when(i,b?void 0:s)))switch(e.kind){case"text":{const c=W(s[e.key]);if(!c.text.trim()){l(e.key,"nothing — empty words draw nothing, so no block");break}const p=de(e.role??"body"),{_partStyles:f,...d}=p,k=pe(p,e.styleFrom?{...e.style,...e.styleFrom(i,r)}:e.style,$(e.key),e.props?.align);if(e.was&&b){const m=k._partStyles?.text??{};S.push({key:e.key,was:e.was,...typeof m.textStyle=="string"?{textStyle:m.textStyle}:{},...R(m.size)!==void 0?{size:R(m.size)}:{},...R(m.sizePhone)!==void 0?{sizePhone:R(m.sizePhone)}:{}})}g.push(w("Text",{text:e.mark==="accentLead"?le(c.text):e.mark==="accentItalic"?fe(c.text):c.text,...d,...e.props??{},...k,...c.hidden?{_hidden:!0}:{}})),l(e.key,`${u}Text block: its words${c.hidden?", hidden":""}`);break}case"button":{const c=W(s[e.key]);if(!c.text.trim()){l(e.key,"nothing — no words, no button"),l(e.href,"nothing — no button to link"),typeof e.variant=="object"&&l(e.variant.key,"nothing — no button to style");break}const p=typeof s[e.href]=="string"&&s[e.href]?s[e.href]:"#",f={...e.style??{},...$(e.key)??{}};g.push(w("ButtonBlock",{label:c.text,href:p,...typeof e.props=="function"?e.props(s,r):e.props??{},...ue(e.variant,s),...Object.keys(f).length?{_partStyles:{label:f}}:{},...c.hidden?{_hidden:!0}:{}})),l(e.key,`${u}Button block: its words`),l(e.href,`${u}Button block: its link`),typeof e.variant=="object"&&l(e.variant.key,`${u}Button block: its Style`);break}case"image":{const c=s[e.key];if(typeof c!="string"||!c){l(e.key,"nothing — no picture, no block"),e.alt&&l(e.alt,"nothing — no picture to describe");break}const p=e.alt&&typeof s[e.alt]=="string"?s[e.alt]:"";g.push(w("ImageBlock",{src:c,alt:p,...e.props??{}})),l(e.key,`${u}Image block: its picture`),e.alt&&l(e.alt,`${u}Image block: its alt text`);break}case"list":{g.push(...M(e,s,l));break}case"group":{const c=I(e.parts,s,b,u),p=F(e.box,e.props,s,`${e.name} Box`,!c.length&&!e.keepEmpty,u,l);p&&g.push(w(P,{name:e.name,...p,[E]:c}));break}case"block":{const c=e.parts?I(e.parts,s,b,u):[],p=F(e.box,e.props,s,`${e.type} block`,!!e.parts&&!c.length&&!e.keepEmpty,u,l);p&&g.push(w(e.type,{...p,...e.slot?{[e.slot]:c}:{}}));break}case"core":{const c=e.as??t.type,p={headPlacement:"own-box",...e.props??{}},f=e.keep==="rest"?Object.keys(s).filter(d=>!L.has(d)&&!(d in p)):e.keep;for(const d of f)s[d]!==void 0&&(p[d]=s[d],l(d,`the ${c} block inside the Box`));if(e.keep==="rest"){for(const k of Object.keys(e.props??{}))s[k]!==void 0&&!L.has(k)&&l(k,`nothing — the ${c} block inside the Box has the row's own value`);s.headPlacement!==void 0&&l("headPlacement",`the ${c} block inside the Box: own-box`);const d=Object.fromEntries(Object.entries(X).filter(([k])=>!L.has(k)));Object.keys(d).length&&(p._partStyles=d)}for(const[d,k]of Object.entries(e.rename??{}))s[d]!==void 0&&(p[k]=s[d],l(d,`the ${c} block inside the Box: ${k}`));for(const[d,k]of Object.entries(e.slots??{}))p[d]=k.flatMap(m=>"kind"in m?M(m,s,l):K([m]));g.push(w(c,p));break}}return g},Q=(n,s)=>{const b=s===0?"Box":`${n.name} Box`,u=I(n.parts,i,!0,s===0?"":`${b}: `),g=typeof n.boxProps=="function"?n.boxProps(i,r):n.boxProps??{},l=D(n.box??[],g,i,($,e,c)=>T($,c?`nothing — the old value draws nothing (${b}: no ${e})`:`${b}: ${e}`),r);return{type:P,props:{name:n.name,...l,[E]:u,id:ie(a,s)}}},G=[o,...o.also??[]].map(Q);i._partStyles!==void 0&&T("_partStyles","each old part's style moved to its new part");for(const[n,s]of Object.entries(o.reads??{}))i[n]!==void 0&&T(n,s);for(const[n,s]of Object.entries(o.drop??{}))n in i&&(x.push({key:n,why:s}),v.add(n));for(const n of Object.keys(i))Y.has(n)||v.has(n)||x.push({key:n,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:y,dropped:x,siteWrites:[...o.site?.(t,r)??[]],restyled:S}}function ve(t,o=H,r={}){const i=t.content;if(!Array.isArray(i))return t;let h=!1;const a=i.flatMap(y=>{const x=y&&typeof y.type=="string"&&o.includes(y.type)?B[y.type]:void 0;if(!x)return[y];const S=q(y,x,r);return S.skipped!==void 0?[y]:(h=!0,S.nodes)});return h?{...t,content:a}:t}function Ie(t,o=H,r={}){if(!Array.isArray(t))return[];const i=[];return t.forEach((h,a)=>{const y=h&&typeof h.type=="string"&&o.includes(h.type)?B[h.type]:void 0;if(!y)return;const x=q(h,y,r);x.skipped===void 0&&i.push({index:a,node:x.node,nodes:x.nodes})}),i}export{E as SECTION_BOX_SLOT,P as SECTION_BOX_TYPE,H as SECTION_TO_BOX_ON,ce as SECTION_TO_BOX_PRESS,Se as boxNativeReason,q as convertSection,ve as convertSectionsInPage,$e as convertTheme,ae as convertsToBox,je as hasWords,Ee as headParts,Pe as pressesAsBox,Oe as registerBoxNativeSections,Be as registerSectionToBox,ie as sectionBoxIdOf,Ie as sectionToBoxEdits,Te as sectionToBoxRow,_e as sectionToBoxTypes};
|
|
1
|
+
import{readHidable as Z}from"efficient-easel/draw";import{BOX_TYPE as ee,CONTAINER_BLOCKS_SLOT as te}from"../../../format/lib/document/container-blocks.js";import{headingTextSeed as oe,labelTextSeed as ne}from"../../../format/lib/document/text-seeds.js";import{SPLITTABLE_SECTIONS as se}from"../../../format/lib/sections/section-head-placement.js";import{finiteNumber as R}from"../../../format/lib/finite-number.js";import{seedNodes as ie}from"../../../format/lib/document/seed-parts.js";import{bucketByGroup as re}from"../../../format/lib/locations-grid.js";import{normalizeTheme as V}from"../../../format/lib/theme.js";const P=ee,v=te;function Se(t){if(t.theme)return V(t.theme);const o=t.site?.themePresets;return o?V({selected:t.site?.selectedPreset??0,themes:[...o]}):void 0}function ae(t,o){return o===0?`${t}~box`:`${t}~box-${o+1}`}const A={Flex:"the Box itself",Hero:"its slides hold Boxes of real blocks (Hero › Slide › Box), and its Scrolling Bar is a Box in its strip slot (Hero › Box)",Divider:"one block with no text, picture or button",CustomHTML:"the HTML box is the whole section; it has no parts"};function Be(t){for(const[o,i]of Object.entries(t)){if(o in A&&A[o]!==i)throw new Error(`lib/sections/section-to-box: "${o}" is already Box-native`);A[o]=i}}function Te(t){return A[t]}const Y=new Set(["id"]),T={},H=[],ce=[];function _e(t){for(const[o,i]of Object.entries(t)){if(o in T&&T[o]!==i)throw new Error(`lib/sections/section-to-box: "${o}" already has a row`);T[o]=i}}function Ee(t){return T[t]}function Pe(){return Object.keys(T)}function fe(t){return t in T&&H.includes(t)}function ve(t,o=ce){return t in T&&(o.includes(t)||fe(t))}function je(t){const o=se[t];if(!o)throw new Error(`lib/sections/section-to-box: "${t}" has no head row in SPLITTABLE_SECTIONS`);const i=[{kind:"text",key:o.num,role:"eyebrow"},{kind:"text",key:o.title,role:"heading"}];return o.description&&i.push({kind:"text",key:o.description,role:"body"}),o.headRows.includes("linkText")&&o.headRows.includes("linkHref")&&i.push({kind:"button",key:"linkText",href:"linkHref"}),i}const W=t=>Z(t),Ne=t=>W(t).text.trim()!=="";function de(t){return t.replace(/==(.+?)==/g,(o,i)=>i.startsWith("_")&&i.endsWith("_")?o:`==_${i}_==`)}function le(t){if(t.includes("=="))return t;const o=t.indexOf("/"),i=o===-1?t:t.slice(0,o),r=i.trim();if(!r)return t;const k=i.indexOf(r);return`${i.slice(0,k)}==${r}==${i.slice(k+r.length)}${o===-1?"":t.slice(o)}`}const pe=t=>t==="heading"?oe():t==="eyebrow"?ne():{};function ue(t,o,i,r){const a={...t._partStyles?.text??{},...o??{},...i??{}};return(r==="center"||r==="right")&&a.align===void 0&&(a.align=r),Object.keys(a).length?{_partStyles:{text:a}}:{}}function he(t,o){if(t===void 0)return{};if(typeof t=="string")return{variant:t};const i=o[t.key];return{variant:typeof i=="string"&&Object.hasOwn(t.map,i)?t.map[i]:t.fallback}}function D(t,o,i,r,k={}){const a={...o};for(const h of t){const[m,B,j]=typeof h=="string"?[h,h,void 0]:h;if(i[m]===void 0)continue;const _=j?j(i[m],i,k):i[m];_===void 0?delete a[B]:a[B]=_,r(m,B,_===void 0)}return a}function ye(t){const o=new Set([...Y,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),i=k=>{for(const a of k??[])o.add(typeof a=="string"?a:a[0])},r=k=>{for(const a of k)switch(a.kind){case"text":case"image":o.add(a.key),a.kind==="image"&&a.alt&&o.add(a.alt);break;case"button":o.add(a.key),o.add(a.href),typeof a.variant=="object"&&o.add(a.variant.key);break;case"list":o.add(a.key);break;case"group":case"block":i(a.box),r(a.parts??[]);break;case"core":if(a.keep!=="rest"&&a.keep.forEach(h=>o.add(h)),Object.keys(a.rename??{}).forEach(h=>o.add(h)),a.derive?.reads.forEach(h=>o.add(h)),typeof a.slots!="function")for(const h of Object.values(a.slots??{}))for(const m of h)"kind"in m&&o.add(m.key);break}};for(const k of[t,...t.also??[]])i(k.box),r(k.parts);return o}function q(t,o,i={}){const r=t.props,k=o.skip?.(r);if(k!==void 0)return{node:t,nodes:[t],carried:[],dropped:[],siteWrites:[],restyled:[],skipped:k};const a=String(r.id??t.type),h=[],m=[],B=[],j=new Set,_=(n,s)=>{h.push({key:n,home:s}),j.add(n)},X=r._partStyles??{},L=ye(o);let F=0;const $=(n,s)=>({type:n,props:{...s,id:`${a}~${n}-${++F}`}}),K=(n,s,b,y,x,d,w)=>{if(x){for(const c of n??[]){const p=typeof c=="string"?c:c[0];b[p]!==void 0&&w(p,`nothing — the ${y} has no parts, so it is not drawn`)}return}const e=typeof s=="function"?s(r,i):s??{};return D(n??[],e,b,(c,p,f)=>w(c,f?`nothing — the old value draws nothing (${y}: no ${p})`:`${d}${y}: ${p}`),i)},J=n=>ie(n,s=>`${a}~${s}-${++F}`),M=(n,s,b)=>{const y=n.of?n.of(s):Array.isArray(s[n.key])?s[n.key]:[],x=typeof n.props=="function"?n.props(r,i):n.props??{},d=y.map((f,g)=>{const l=f??{},u=n.item?.(l,g,r)??{},O=N(u.reverse?[...n.parts].reverse():n.parts,l,!1,`item ${g+1}: `);return n.flat?u.props?O.map(E=>({...E,props:{...E.props,...u.props,id:E.props.id}})):O:[$(P,{name:`${n.name} ${g+1}`,...x,...u.props??{},[v]:O})]});if(n.groups){const f=n.groups;return b(n.key,y.length?`one Box per item (${y.length}), in a Box per group`:"nothing — the list is empty"),re(y.map(g=>g??{}),f.of,f.of).map((g,l)=>{const u=g.items.map(S=>S.item),O=f.parts?N(f.parts,f.head?.(u,r)??{},!1,`group ${l+1}: `):[],E=g.items.map(S=>d[S.index]),z=f.perRow?.(u.length,r),I=Number.isInteger(z)&&z>=1?z:1,C=[];if(f.perRow&&I<E.length)for(let S=0;S*I<E.length;S++)C.push(E.slice(S*I,(S+1)*I).flat());return $(P,{name:`${f.name} ${l+1}`,...f.props??{},[v]:[...O,$(P,{name:`${f.itemsName} ${l+1}`,...f.itemsProps?.(u.length,r)??{},[v]:C.length?C.map((S,U)=>$(P,{name:`${f.rowName??`${f.itemsName} row`} ${U+1}`,...f.rowProps??{},[v]:S})):E.flat()})]})})}const w=n.perRow?.(r),e=n.perRow?Number.isInteger(w)&&w>=1?w:1:0;if(b(n.key,(y.length?n.flat?`each item's parts (${y.length} items), in order`:`one Box per item (${y.length}), its parts inside`:"nothing — the list is empty")+(e&&y.length?`, in rows of ${e}`:"")),!e)return d.flat();const c=typeof n.rowProps=="function"?n.rowProps(r,i):n.rowProps??{},p=[];for(let f=0;f*e<d.length;f++){const g=d.slice(f*e,(f+1)*e).flat(),l=n.rowFiller?e-d.slice(f*e,(f+1)*e).length:0;p.push($(P,{name:`${n.rowName??`${n.name} row`} ${f+1}`,...c,[v]:[...g,...Array.from({length:l},(u,O)=>$(P,{name:`Empty ${O+1}`,...n.rowFiller,[v]:[]}))]}))}return p},N=(n,s,b,y)=>{const x=[],d=(e,c)=>b?_(e,c):void 0,w=e=>b?X[e]:void 0;for(const e of n)if(!(e.when&&!e.when(r,b?void 0:s)))switch(e.kind){case"text":{const c=W(s[e.key]);if(!c.text.trim()){d(e.key,"nothing — empty words draw nothing, so no block");break}const p=pe(e.role??"body"),{_partStyles:f,...g}=p,l=ue(p,e.styleFrom?{...e.style,...e.styleFrom(r,i)}:e.style,w(e.key),e.props?.align);if(e.was&&b){const u=l._partStyles?.text??{};B.push({key:e.key,was:e.was,...typeof u.textStyle=="string"?{textStyle:u.textStyle}:{},...R(u.size)!==void 0?{size:R(u.size)}:{},...R(u.sizePhone)!==void 0?{sizePhone:R(u.sizePhone)}:{}})}x.push($("Text",{text:e.mark==="accentLead"?le(c.text):e.mark==="accentItalic"?de(c.text):c.text,...g,...e.props??{},...l,...c.hidden?{_hidden:!0}:{}})),d(e.key,`${y}Text block: its words${c.hidden?", hidden":""}`);break}case"button":{const c=W(s[e.key]);if(!c.text.trim()){d(e.key,"nothing — no words, no button"),d(e.href,"nothing — no button to link"),typeof e.variant=="object"&&d(e.variant.key,"nothing — no button to style");break}const p=typeof s[e.href]=="string"&&s[e.href]?s[e.href]:"#",f={...e.style??{},...w(e.key)??{}};x.push($("ButtonBlock",{label:c.text,href:p,...typeof e.props=="function"?e.props(s,i):e.props??{},...he(e.variant,s),...Object.keys(f).length?{_partStyles:{label:f}}:{},...c.hidden?{_hidden:!0}:{}})),d(e.key,`${y}Button block: its words`),d(e.href,`${y}Button block: its link`),typeof e.variant=="object"&&d(e.variant.key,`${y}Button block: its Style`);break}case"image":{const c=s[e.key];if(typeof c!="string"||!c){d(e.key,"nothing — no picture, no block"),e.alt&&d(e.alt,"nothing — no picture to describe");break}const p=e.alt&&typeof s[e.alt]=="string"?s[e.alt]:"";x.push($("ImageBlock",{src:c,alt:p,...e.props??{}})),d(e.key,`${y}Image block: its picture`),e.alt&&d(e.alt,`${y}Image block: its alt text`);break}case"list":{x.push(...M(e,s,d));break}case"group":{const c=N(e.parts,s,b,y),p=K(e.box,e.props,s,`${e.name} Box`,!c.length&&!e.keepEmpty,y,d);p&&x.push($(P,{name:e.name,...p,[v]:c}));break}case"block":{const c=e.parts?N(e.parts,s,b,y):[],p=K(e.box,e.props,s,`${e.type} block`,!!e.parts&&!c.length&&!e.keepEmpty,y,d);p&&x.push($(e.type,{...p,...e.slot?{[e.slot]:c}:{}}));break}case"core":{const c=e.as??t.type,p={headPlacement:"own-box",...e.props??{}},f=e.keep==="rest"?Object.keys(s).filter(l=>!L.has(l)&&!(l in p)):e.keep;for(const l of f)s[l]!==void 0&&(p[l]=s[l],d(l,`the ${c} block inside the Box`));if(e.keep==="rest"){for(const u of Object.keys(e.props??{}))s[u]!==void 0&&!L.has(u)&&d(u,`nothing — the ${c} block inside the Box has the row's own value`);s.headPlacement!==void 0&&d("headPlacement",`the ${c} block inside the Box: own-box`);const l=Object.fromEntries(Object.entries(X).filter(([u])=>!L.has(u)));Object.keys(l).length&&(p._partStyles=l)}for(const[l,u]of Object.entries(e.rename??{}))s[l]!==void 0&&(p[u]=s[l],d(l,`the ${c} block inside the Box: ${u}`));if(e.derive){Object.assign(p,e.derive.props(s,i));for(const l of e.derive.reads)s[l]!==void 0&&d(l,`the ${c} block inside the Box`)}const g=typeof e.slots=="function"?e.slots(s,i):e.slots??{};for(const[l,u]of Object.entries(g))p[l]=u.flatMap(O=>"kind"in O?M(O,s,d):J([O]));x.push($(c,p));break}}return x},Q=(n,s)=>{const b=s===0?"Box":`${n.name} Box`,y=N(n.parts,r,!0,s===0?"":`${b}: `),x=typeof n.boxProps=="function"?n.boxProps(r,i):n.boxProps??{},d=D(n.box??[],x,r,(w,e,c)=>_(w,c?`nothing — the old value draws nothing (${b}: no ${e})`:`${b}: ${e}`),i);return{type:P,props:{name:n.name,...d,[v]:y,id:ae(a,s)}}},G=[o,...o.also??[]].map(Q);r._partStyles!==void 0&&_("_partStyles","each old part's style moved to its new part");for(const[n,s]of Object.entries(o.reads??{}))r[n]!==void 0&&_(n,s);for(const[n,s]of Object.entries(o.drop??{}))n in r&&(m.push({key:n,why:s}),j.add(n));for(const n of Object.keys(r))Y.has(n)||j.has(n)||m.push({key:n,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:h,dropped:m,siteWrites:[...o.site?.(t,i)??[]],restyled:B}}function Ie(t,o=H,i={}){const r=t.content;if(!Array.isArray(r))return t;let k=!1;const a=r.flatMap(h=>{const m=h&&typeof h.type=="string"&&o.includes(h.type)?T[h.type]:void 0;if(!m)return[h];const B=q(h,m,i);return B.skipped!==void 0?[h]:(k=!0,B.nodes)});return k?{...t,content:a}:t}function Re(t,o=H,i={}){if(!Array.isArray(t))return[];const r=[];return t.forEach((k,a)=>{const h=k&&typeof k.type=="string"&&o.includes(k.type)?T[k.type]:void 0;if(!h)return;const m=q(k,h,i);m.skipped===void 0&&r.push({index:a,node:m.node,nodes:m.nodes})}),r}export{v as SECTION_BOX_SLOT,P as SECTION_BOX_TYPE,H as SECTION_TO_BOX_ON,ce as SECTION_TO_BOX_PRESS,Te as boxNativeReason,q as convertSection,Ie as convertSectionsInPage,Se as convertTheme,fe as convertsToBox,Ne as hasWords,je as headParts,ve as pressesAsBox,Be as registerBoxNativeSections,_e as registerSectionToBox,ae as sectionBoxIdOf,Re as sectionToBoxEdits,Ee as sectionToBoxRow,Pe as sectionToBoxTypes};
|
|
@@ -15,12 +15,14 @@ export interface SiteImageProps {
|
|
|
15
15
|
export interface SiteRuntime {
|
|
16
16
|
Link: ComponentType<SiteLinkProps>;
|
|
17
17
|
Image: ComponentType<SiteImageProps>;
|
|
18
|
+
pagePath?: string | null;
|
|
18
19
|
}
|
|
19
20
|
export declare function SiteRuntimeProvider({ runtime, children }: {
|
|
20
21
|
runtime: SiteRuntime;
|
|
21
22
|
children: ReactNode;
|
|
22
23
|
}): import("react").JSX.Element;
|
|
23
24
|
export declare function useSiteRuntime(): SiteRuntime;
|
|
25
|
+
export declare function useCurrentPagePath(): string | null;
|
|
24
26
|
export declare function SiteLink({ hrefRewrite, ...props }: SiteLinkProps & {
|
|
25
27
|
hrefRewrite?: string;
|
|
26
28
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i}from"react/jsx-runtime";import s from"next/image";import
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import s from"next/image";import u from"next/link";import{Component as l,createContext as c,lazy as m,Suspense as h,useContext as d}from"react";import{linkHrefRewrite as p}from"../../format/lib/links/link-href-rewrites.js";import{isSafeLinkHref as k}from"../../format/lib/markup.js";import{nonEmptyString as x}from"../../format/lib/non-empty-string.js";const g={Link:u,Image:s},a=c(g);function z({runtime:t,children:e}){return i(a.Provider,{value:t,children:e})}function o(){return d(a)}function E(){return o().pagePath??null}function N({hrefRewrite:t,...e}){const{Link:r}=o(),n=p(t);return n?i(w,{name:n.name,href:e.href,fallback:i(r,{...e}),children:i(S,{Link:r,rewrite:n.rewrite,...e})},n.key):i(r,{...e})}function S({Link:t,rewrite:e,...r}){const n=x(e(r.href)),f=n&&k(n)?n:r.href;return i(t,{...r,href:f})}class w extends l{state={failed:!1,href:this.props.href};static getDerivedStateFromProps(e,r){return e.href===r.href?null:{failed:!1,href:e.href}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`The link href rewrite ${this.props.name} failed; the link goes where it was typed.`,e)}render(){return this.state.failed?this.props.fallback:this.props.children}}function b(t){const{Image:e}=o();return i(e,{...t})}function B(t){const e=m(t);return function(n){return i(h,{fallback:null,children:i(e,{...n})})}}export{b as SiteImage,N as SiteLink,z as SiteRuntimeProvider,B as lazyInBrowser,E as useCurrentPagePath,o as useSiteRuntime};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-web-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "50.0.0",
|
|
4
4
|
"description": "The EFFICIENT website builder: the website editor, the general sections and the renderer that draws them, compiled. Hostable by any EFFICIENT product; nothing here imports a host.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Efficient Pty Ltd",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@types/node": "^20",
|
|
73
73
|
"@types/react": "^19",
|
|
74
74
|
"@types/react-dom": "^19",
|
|
75
|
-
"efficient-easel": "^27.
|
|
75
|
+
"efficient-easel": "^27.2.0",
|
|
76
76
|
"efficient-shell": "^11.8.0",
|
|
77
77
|
"esbuild": "^0.28.0",
|
|
78
78
|
"happy-dom": "^20.14.5",
|