efficient-web-builder 45.0.0 → 46.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 +14 -0
- package/dist/editor/components/ApplyCornersToSiblings.d.ts +1 -3
- package/dist/editor/components/ApplyCornersToSiblings.js +1 -1
- package/dist/editor/components/PartSettingsPanel.js +1 -1
- package/dist/editor/components/SectionThumbnail.js +1 -1
- package/dist/editor/components/StorefrontEditor.js +1 -1
- package/dist/editor/components/WebsiteScreenParts.js +1 -1
- package/dist/editor/components/useSectionToBoxPass.d.ts +8 -1
- package/dist/editor/components/useSectionToBoxPass.js +1 -1
- package/dist/editor/components/useSocialSettings.d.ts +2 -2
- package/dist/editor/lib/document/blocks/general/ButtonBlock/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Eyebrow/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Heading/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Hero/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/LogoBlock/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Split/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Text/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/TitleWithButtons/fields.js +1 -1
- package/dist/editor/lib/document/blocks/shared-fields.d.ts +0 -1
- package/dist/editor/lib/document/blocks/shared-fields.js +1 -1
- package/dist/editor/lib/document/box-fields.d.ts +4 -0
- package/dist/editor/lib/document/box-fields.js +1 -1
- package/dist/editor/lib/document/canvas-typing.js +1 -1
- package/dist/editor/lib/document/part-panel-rows.js +1 -1
- package/dist/editor/lib/sections/city-presets.d.ts +4 -0
- package/dist/editor/lib/sections/city-presets.js +1 -0
- package/dist/editor/lib/sections/text-layouts.d.ts +1 -1
- package/dist/editor/lib/sections/text-layouts.js +1 -1
- package/dist/format/lib/content/block-align.d.ts +2 -0
- package/dist/format/lib/content/block-align.js +1 -1
- package/dist/format/lib/editor-words-catalogue.d.ts +4 -1
- package/dist/format/lib/editor-words-catalogue.js +2 -2
- package/dist/format/lib/source-rules/one-alignment-row.d.ts +9 -0
- package/dist/format/lib/source-rules/one-alignment-row.js +7 -0
- package/dist/format/lib/theme.d.ts +3 -0
- package/dist/format/lib/theme.js +4 -4
- package/dist/render/components/ButtonBlock.d.ts +1 -0
- package/dist/render/components/ButtonBlock.js +1 -1
- package/dist/render/components/Eyebrow.d.ts +2 -1
- package/dist/render/components/Eyebrow.js +1 -1
- package/dist/render/components/Heading.d.ts +2 -4
- package/dist/render/components/Heading.js +1 -1
- package/dist/render/components/LogoBlock.d.ts +1 -0
- package/dist/render/components/LogoBlock.js +1 -1
- package/dist/render/components/PreviewHeaderContext.d.ts +11 -1
- package/dist/render/components/PreviewHeaderContext.js +1 -1
- package/dist/render/components/Split.d.ts +2 -1
- package/dist/render/components/Split.js +1 -1
- package/dist/render/components/Text.d.ts +3 -2
- package/dist/render/components/Text.js +1 -1
- package/dist/render/components/TitleWithButtons.d.ts +2 -1
- package/dist/render/components/TitleWithButtons.js +1 -1
- package/dist/render/lib/document/blocks/general/ButtonBlock/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Eyebrow/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Heading/render.js +1 -1
- package/dist/render/lib/document/blocks/general/LogoBlock/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Split/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Text/render.js +1 -1
- package/dist/render/lib/document/blocks/general/TitleWithButtons/render.js +1 -1
- 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-timeline.d.ts +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/page-render.js +1 -1
- package/dist/render/lib/document/part-styles.d.ts +1 -0
- package/dist/render/lib/document/part-styles.js +2 -2
- package/dist/render/lib/document/text-parts.d.ts +4 -0
- package/dist/render/lib/document/text-parts.js +1 -1
- package/dist/render/lib/sections/section-to-box.d.ts +5 -3
- package/dist/render/lib/sections/section-to-box.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasWords as x,registerSectionToBox as o}from"../../../sections/section-to-box.js";import{BUTTON as m,DIM as d,DROP_COMMON as n,DROP_SIDE_PADDING as p,INNER_BOX as t,SAME_KEYS as
|
|
1
|
+
import{hasWords as x,registerSectionToBox as o}from"../../../sections/section-to-box.js";import{BUTTON as m,DIM as d,DROP_COMMON as n,DROP_SIDE_PADDING as p,INNER_BOX as t,SAME_KEYS as i,SECTION_BOX as r,TEXT as s,headingCaseOf as O,innerPad as c,innerPadKeys as y,smallText as a,wrapperPad as l,wrapperPadKeys as h}from"./section-to-box-row-parts.js";import{CARDS_SECTION_TO_BOX as T}from"./section-to-box-rows-cards.js";import{finiteNumber as f}from"../../../../../format/lib/finite-number.js";import{STATS_SECTION_TO_BOX as B}from"./section-to-box-rows-stats.js";import{LOGOS_SECTION_TO_BOX as _}from"./section-to-box-rows-logos.js";import{STRIP_SECTION_TO_BOX as N}from"./section-to-box-rows-strip.js";import{TIMELINE_SECTION_TO_BOX as E}from"./section-to-box-rows-timeline.js";import{LOCATIONS_SECTION_TO_BOX as H}from"./section-to-box-rows-locations.js";import{HEAD_ONLY_SECTION_TO_BOX as I}from"./section-to-box-rows-head.js";import{headTree as b}from"./section-head-looks.js";const u={top:72,bottom:72,topPhone:72,bottomPhone:72},v={name:"Editorial Text",boxProps:e=>({...r,direction:"column",gap:28,sectionBorder:{top:1},...l(e,u)}),box:[["topBorder","sectionBorder",e=>e===!1?void 0:{top:1}],...i,...h(u)],parts:[b("Prose"),{kind:"text",key:"body",props:{...d,maxWidth:680},style:{textStyle:"body-1",lineHeight:1.7,paragraphSpacing:18},was:{size:16}}],drop:{...n,...p,headPlacement:"needs a row per head placement: an own-box Prose draws no head (its words sit in a Section Header above it), the row always draws the head. 0 of 123 live nodes store it (JJ's export, 2026-10-24)"}},A={buttonPaddingTop:20,buttonPaddingBottom:20,buttonPaddingLeft:28,buttonPaddingRight:28},w=(e,k)=>({kind:"list",key:"buttons",name:"Button",flat:!0,when:e,parts:[{kind:"button",key:"label",href:"href",variant:{key:"variant",map:{primary:"primary",outline:"ghost"},fallback:"ghost"},style:{letterSpacing:.3},props:{...m,...A,...k}}]}),g=e=>x(e.title),C={name:"Call-to-Action Heading",boxProps:e=>({...r,direction:"row",align:"center",justify:g(e)?"between":"end",gap:60,share:"content",sectionBorder:{bottom:1},...c(e,"TitleWithButtons")}),box:[...i,...y("TitleWithButtons")],parts:[{kind:"group",name:"Title",props:t,parts:[{kind:"text",key:"title",role:"heading",props:{...s,maxWidth:1e3},style:{textStyle:"heading-1",lineHeight:.94,letterSpacing:-.035}}]},{kind:"group",name:"Buttons",props:{...t,gap:14},parts:[w(g,{widthFit:"fill",iconPosition:"end"}),w(e=>!g(e),{})]}],site:O("title"),drop:{...n,buttonsAlign:"moves the buttons only when there is no heading (4 of 128 live nodes), where the Box puts them at the end. 0 of 128 live nodes store it (JJ's export, 2026-10-24)",buttonsAlignPhone:"the phone's own side of `buttonsAlign`, read only with no heading; no old node stores it (it is new with the Phone view's Block alignment row), so nothing moves"}},S={top:40,bottom:64,topPhone:24,bottomPhone:36},W={name:"Section Header",boxProps:e=>({...r,direction:"column",gap:0,...l(e,S)}),box:[...i,...h(S)],parts:[b("SectionHeader")],drop:{...n,...p,headStyle:"needs a row per head look: the row draws the standard look; the editorial, simple, statement, natural and essay looks are other layouts. 0 of 69 live nodes store it (JJ's export, 2026-10-24)",eyebrowLook:"read only by the simple, statement, natural and essay looks, which this row does not draw. 0 of 69 live nodes store it",rowGap:"read only by the natural look, which this row does not draw. 0 of 69 live nodes store it",descriptionSize:"read only by the natural look, which this row does not draw. 0 of 69 live nodes store it",numStyle:"Solid (the default; 4 of 69 live nodes store it) IS the eyebrow Text the row draws; Outlined (0 live) needs an outlined-number text look"}},R={name:"Lead Text",boxProps:e=>({...r,direction:"column",gap:40,sectionBorder:{bottom:1},...c(e,"ParagraphsA")}),box:[...i,...y("ParagraphsA")],parts:[{kind:"group",name:"Numbers",props:{...t,direction:"row",justify:"between",gap:60,share:"content",sectionBorder:{bottom:1},sectionPaddingBottom:40},parts:[a("eyebrow",{color:"labels",letterSpacing:.24}),{kind:"group",name:"Stats",props:{...t,align:"end"},parts:[{kind:"list",key:"stats",name:"Stat",props:{...t,direction:"row",share:"content",justify:"end",gap:8},parts:[a("value",{color:"text",letterSpacing:.18,lineHeight:1.8}),a("label",{color:"labels",letterSpacing:.18,lineHeight:1.8})]}]}]},{kind:"group",name:"Words",props:{...t,direction:"row",align:"end",gap:60,share:"bigLeft"},parts:[{kind:"text",key:"lead",props:{...s,maxWidth:780},style:{textStyle:"body-1",lineHeight:1.45,letterSpacing:-.005,paragraphSpacing:0},was:{size:22,sizePhone:20}},{kind:"group",name:"Founders",props:{...t,gap:8},parts:[{kind:"group",name:"Note",props:{...t,gap:6},parts:[{kind:"text",key:"foundersHeading",props:s,style:{textStyle:"body-1",weight:500,letterSpacing:-.01,lineHeight:1.7},was:{size:18,sizePhone:16}},{kind:"text",key:"foundersBody",props:d,style:{textStyle:"body-5",lineHeight:1.7},was:{size:14,sizePhone:12}}]},a("attribution",{letterSpacing:.24,lineHeight:1.7})]}]}],drop:{...n}},P={top:24,bottom:24,topPhone:24,bottomPhone:24},L={name:"Banner",boxProps:e=>({...r,direction:"column",gap:0,...l(e,P)}),box:[...i,"contained",...h(P)],parts:[{kind:"group",name:"Card",keepEmpty:!0,props:{...t,gap:28,placement:"top-left",darken:60,darkenStyle:"even",sectionBorder:{width:1},sectionPaddingTop:64,sectionPaddingBottom:64,sectionPaddingTopPhone:40,sectionPaddingBottomPhone:40,sectionPaddingLeft:40,sectionPaddingRight:40,sectionPaddingLeftPhone:24,sectionPaddingRightPhone:24},box:[["imageSrc","bgImage"],["overlay","darken",e=>Math.min(Math.max(f(e)??60,0),100)]],parts:[{kind:"group",name:"Words",props:{...t,gap:20},parts:[a("eyebrow"),{kind:"text",key:"title",role:"heading",props:{...s,maxWidth:680},style:{weight:500,lineHeight:1.05,letterSpacing:-.03,case:"none"}},{kind:"text",key:"body",props:{...d,maxWidth:680},style:{textStyle:"body-1",lineHeight:1.6},was:{size:16}}]},{kind:"button",key:"ctaText",href:"ctaHref",variant:"primary",props:m}]}],drop:{...n,...p}},X={Prose:v,TitleWithButtons:C,SectionHeader:W,ParagraphsA:R,Banner:L};function Q(){o(X),o(B),o(_),o(T),o(N),o(E),o(H),o(I)}export{X as GENERAL_SECTION_TO_BOX,Q as registerGeneralSectionRows};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t}from"react/jsx-runtime";import{Render as m}from"efficient-easel/render";import{capHeroGroups as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Render as m}from"efficient-easel/render";import{capHeroGroups as i}from"../../../format/lib/document/cap-hero-groups.js";import{oneH1 as a}from"../../../format/lib/document/one-h1.js";import{migrateLegacyPageData as n}from"./migrate-legacy.js";import{migrateRenamedProps as f}from"../../../format/lib/document/renamed-props.js";import{convertSectionsInPage as p,SECTION_TO_BOX_ON as s}from"../sections/section-to-box.js";import{siteThemeOf as c}from"../../../format/lib/theme.js";import{registerGeneralSectionRows as g}from"./blocks/general/section-to-box-rows.js";function d({config:e,data:o,metadata:r}){return g(),t(m,{config:e,metadata:r,data:a(i(p(f(n(o)),s,{theme:c(r)})))})}export{d as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{textStyleCaseCss as v,textStyleCaseOfCss as tt}from"efficient-easel/draw";import{parseHexColor as et}from"efficient-shell/format";import{FONT_OPTIONS as nt,fontOption as rt,fontRoleOf as E,SIZE_STEP_OF_ROLE as I}from"../../../format/lib/fonts.js";import{encodePartKey as ot}from"../../../format/lib/document/part-key.js";import{decodePartId as k,normalizePartText as O}from"./text-parts.js";import{COLOUR_TOKEN as M}from"../../../format/lib/word-styles.js";import{PHONE_MEDIA as it}from"../content/view-values.js";const N="_partStyles",st="data-sf-part-styled",F="data-sf-text-style",ct=/^(heading|body)-[1-7]$/;function m(t){return typeof t=="string"&&ct.test(t)}const L={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function at(t){if(!t)return null;for(const[e,n]of Object.entries(L))if(n===t)return e;return null}function se(t){if(m(t.textStyle))return t.textStyle;const e=E(t.role);return e?L[e]:void 0}const ft=[400,500,600,700],j=["left","center","right","justify"],H=5,D=1e3,lt=-5,ut=10,pt=0,dt=64,xt=2,C={size:{min:H,max:D,step:1},sizePhone:{min:H,max:D,step:1},padding:{min:pt,max:dt,step:xt}},ht=.05,St=.01,gt=["line","letter"],mt=.5,Pt=2.5,Tt=-1,bt=1,_t=0,Rt=400,At=[...new Set(Object.values(I))];function b(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function K(t){return b(t?.[N])??{}}function W(t,e){const n=K(t);return Object.hasOwn(n,e)?b(n[e])??{}:{}}function ce(t,e){return Object.values(W(t,e)).filter(n=>n!==void 0).length}function G(t,e,n){const r={...K(t)};if(Et(n).length?r[e]=n:delete r[e],!Object.keys(r).length){const{[N]:o,...i}=t;return i}return{...t,[N]:r}}function Et(t){return Object.entries(t).filter(([,e])=>e!==void 0)}function yt(t){return gt.includes(t)}const _=(t,e,n)=>Math.min(n,Math.max(e,t));function Ot(t,e){if(yt(t)){const n=Math.round(Number(e));return!Number.isFinite(n)||n===0?null:_(n,lt,ut)}if(t==="lineHeight"){const n=Number(e);return Number.isFinite(n)?P(_(n,mt,Pt),3):null}if(t==="letterSpacing"){const n=Number(e);return Number.isFinite(n)?P(_(n,Tt,bt),4):null}if(t==="paragraphSpacing"){const n=Math.round(Number(e));return!Number.isFinite(n)||n<=0?null:_(n,_t,Rt)}if(Object.hasOwn(C,t)){const{min:n,max:r}=C[t],o=Math.round(Number(e));return Number.isFinite(o)?_(o,n,r):null}return t==="italic"?typeof e=="boolean"?e:null:t==="role"||t==="fontRole"?E(e)?e:null:t==="sizeToken"?$(e)?e:null:t==="textStyle"?m(e)?e:null:e}const Nt=["weight","size","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function X(t){let e=null;const n=r=>{e??={...t},delete e[r]};for(const r of Nt){const o=t[r];o!==void 0&&!(typeof o=="number"&&Number.isFinite(o))&&n(r)}return t.align!==void 0&&!j.includes(t.align)&&n("align"),t.textStyle!==void 0&&!m(t.textStyle)&&n("textStyle"),t.sizeToken!==void 0&&!$(t.sizeToken)&&n("sizeToken"),t.fontRole!==void 0&&!E(t.fontRole)&&n("fontRole"),e??t}function $(t){if(!t||typeof t!="object")return!1;const{step:e,px:n,stepPhone:r,pxPhone:o,fluid:i}=t,c=s=>typeof s=="number"&&Number.isFinite(s)&&s>0,p=s=>typeof s=="string"&&At.includes(s);return p(e)&&c(n)&&(r===void 0||p(r))&&(o===void 0||c(o))&&(i===void 0||$t(i,n))}function $t(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 U(t){return t?.pxPhone&&$(t)?{step:t.stepPhone??t.step,px:t.pxPhone}:null}function B({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 wt=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function zt(t){const e=[];for(const[n,r]of wt)n===t?e.push(r):r===t&&e.push(n);return e}function ae(t,e,n,r){const o={...W(t,e)},i=r==null?null:Ot(n,r);if(i===null)delete o[n];else{o[n]=i;for(const c of zt(n))delete o[c]}return G(t,e,o)}function fe(t,e){return G(t,e,{})}function It(t){return tt(t)??"none"}function kt(t){return v(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 Mt(t,e){const n=E(t.role);return n||(e?.blockDrawsStyle?null:at(t.textStyle))}function le(t,e){return t==="Text"&&e==="text"}const Ft={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 Lt(t){const e=I[t],n=Ft[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=P(Ht+t.line*ht,3)),typeof t.letterSpacing=="number"?e.letterSpacingEm=t.letterSpacing:t.letter&&(e.letterSpacingEm=P(t.letter*St,4)),e}const Ht=1,S="--sf-part-para";function Y(t){if(t=X(t),typeof t.sizePhone=="number"&&t.sizePhone>0)return{fontSize:`${t.sizePhone}px`};const e=U(t.sizeToken);return e?{fontSize:B(e)}:{}}function Dt(t,e){if(!e)return t;if(typeof t.sizePhone=="number"&&t.sizePhone>0)return{...t,size:t.sizePhone};const n=U(t.sizeToken);return n?{...t,size:void 0,sizeToken:n}:t}function y(t,e,n){t=X(t);const r=Mt(t,n),o=jt(t),i=t.size?`${t.size}px`:t.sizeToken?B(t.sizeToken):r?Lt(r):"";return{fontFamily:t.font?Gt(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`:"",[S]:t.paragraphSpacing?`${t.paragraphSpacing}px`:"",textTransform:kt(t.case),textAlign:t.align??"",paddingTop:Z(t.padding),paddingBottom:Z(t.padding),color:Ct(t.color),fontStyle:t.italic===!0?"italic":t.italic===!1?"normal":""}}const Ct=t=>t===void 0||t===""?"":Object.hasOwn(M,t)?M[t]:et(t)===t.toLowerCase()?t:"",Z=t=>t===void 0?"":`${t}px`,P=(t,e)=>Number(t.toFixed(e));function ue(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:Kt(Number.parseInt(t.fontWeight,10)),lineRatio:Number.isFinite(r)?P(r/n,3):1.2,letterEm:Number.isFinite(o)?P(o/n,4):0,align:Wt(t.textAlign),case:It(t.textTransform),paddingPx:Number.isFinite(i)?Math.round(i):0}}function Kt(t){return Number.isFinite(t)?ft.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e):400}function Wt(t){for(const e of j)if(e===t)return e;return t==="end"?"right":"left"}function pe(t,e){const n=q(t);if(!n)return"";for(const r of nt)if(q(e(r.cssVar))===n)return r.key;return""}const q=t=>(t.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function Gt(t){const e=rt(t);return e?`var(${e.cssVar})`:""}function de(t,e,n,r){return!e||k(e)?.nodeId!==t?null:n.find(i=>r(i.getAttribute("class")))??n[0]??null}function xe(t,e,n=()=>R,r=p=>p,o=Bt,i=!1,c=()=>!1){let p=0;for(const{element:s,partId:a}of t){const u=k(a)?.propKey;if(!u)continue;const f=r(u),d=Object.hasOwn(e,f)?b(e[f])??{}:{},l=y(Dt(d,i),R,{blockDrawsStyle:c(u)});m(d.textStyle)?s.setAttribute?.(F,d.textStyle):s.removeAttribute?.(F);const g=z.some(h=>s.style[h]);let x=!1;for(const[h,T]of Object.entries(l))Vt(s,h,T),T&&(x=!0);if(g||z.some(h=>l[h]))for(const h of Xt(s,o))for(const T of z)h.style[T]=l[T]??"";x&&(p+=1)}return p}function Xt(t,e){const n=O(t.textContent??""),r=[];let o=t;for(let i=0;i<Ut&&e(o);i+=1){const c=o.parentElement;if(!c||O(c.textContent??"")!==n)break;r.push(c),o=c}return r}const Ut=8;function Bt(t){const e=t;return typeof window>"u"||!e?.ownerDocument?!1:window.getComputedStyle(e).display==="inline"}const R={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Vt(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===S&&(n?o.setAttribute?.(J,""):o.removeAttribute?.(J))}const J="data-sf-part-para",Yt=Object.keys(y({},R)),w=new Set(["color","overflowWrap",S,"fontStyle"]),z=Yt.filter(t=>!w.has(t));function he(t,e,n,r=i=>i,o=()=>!1){const i=new Map;for(const s of t){const a=ot(s.key,s.row);for(const u of s.texts){const f=i.get(u);f?(f.keys.add(s.key),f.partKeys.add(a)):i.set(u,{keys:new Set([s.key]),partKeys:new Set([a])})}}const c=new Map;for(const s of Object.keys(e)){if(!Zt(s))continue;const a=b(e[s])??{},u=y(a,R),f=Y(a),d=m(a.textStyle)?a.textStyle:void 0;!Object.values(u).some(Boolean)&&!Object.keys(f).length&&!d||c.set(s,{stamp:Q(n,s),declarations:u,...Object.keys(f).length?{phone:f}:{},...d?{textStyle:d}:{}})}const p=new Map;for(const[s,{keys:a,partKeys:u}]of i){const f=u.size===1?[...u][0]:a.size===1?[...a][0]:null;if(!f)continue;const d=r(f);if(!Object.hasOwn(e,d))continue;const l=b(e[d])??{},g=y(l,R,{blockDrawsStyle:o(f)}),x=Y(l),A=m(l.textStyle)?l.textStyle:void 0;!Object.values(g).some(Boolean)&&!Object.keys(x).length&&!A||p.set(s,{stamp:Q(n,f),declarations:g,...Object.keys(x).length?{phone:x}:{},...A?{textStyle:A}:{}})}return p.size||c.size?{rules:p,kindRules:c,drawn:new Set(i.keys())}:null}function Zt(t){return t.startsWith("@")}function Se(t,e){return t?.kindRules.get(e)??null}function Q(t,e){const n=r=>r.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(t)}~${n(e)}`}function ge(t){const e=[],n=new Set,r=o=>{const{stamp:i,declarations:c}=o;if(n.has(i))return;n.add(i);const p=Object.entries(c).filter(([,l])=>l!==""),s=l=>l.map(([g,x])=>`${Jt(g)}: ${x}`).join("; "),a=`[${st}="${i}"]`,u=p.filter(([l])=>!w.has(l)),f=p.filter(([l])=>w.has(l));u.length&&e.push(`${a}, *:has(> ${a}) { ${s(u)} }`),f.length&&e.push(`${a} { ${s(f)} }`),c[S]&&(e.push(`*:has(> ${a}) { ${S}: ${c[S]} }`),e.push(...qt(a,`*:has(> ${a})`)));const d=Object.entries(o.phone??{}).filter(([,l])=>l!=="");d.length&&e.push(`@media ${it} { ${a}, *:has(> ${a}) { ${s(d)} } }`)};for(const o of t.rules.values())r(o);for(const o of t.kindRules.values())r(o);return e.join(`
|
|
2
|
-
`)}function qt(t,e){const n=`var(${
|
|
1
|
+
import{textStyleCaseCss as v,textStyleCaseOfCss as tt}from"efficient-easel/draw";import{parseHexColor as et}from"efficient-shell/format";import{FONT_OPTIONS as nt,fontOption as ot,fontRoleOf as E,SIZE_STEP_OF_ROLE as M}from"../../../format/lib/fonts.js";import{encodePartKey as rt}from"../../../format/lib/document/part-key.js";import{decodePartId as F,normalizePartText as N}from"./text-parts.js";import{COLOUR_TOKEN as L}from"../../../format/lib/word-styles.js";import{PHONE_MEDIA as it}from"../content/view-values.js";const $="_partStyles",st="data-sf-part-styled",j="data-sf-text-style",ct=/^(heading|body)-[1-7]$/;function m(t){return typeof t=="string"&&ct.test(t)}const H={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function at(t){if(!t)return null;for(const[e,n]of Object.entries(H))if(n===t)return e;return null}function se(t){if(m(t.textStyle))return t.textStyle;const e=E(t.role);return e?H[e]:void 0}const ft=[400,500,600,700],y=["left","center","right","justify"],D=5,C=1e3,lt=-5,ut=10,pt=0,dt=64,xt=2,K={size:{min:D,max:C,step:1},sizePhone:{min:D,max:C,step:1},padding:{min:pt,max:dt,step:xt}},ht=.05,gt=.01,St=["line","letter"],mt=.5,Pt=2.5,Tt=-1,bt=1,_t=0,Rt=400,At=[...new Set(Object.values(M))];function b(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function W(t){return b(t?.[$])??{}}function G(t,e){const n=W(t);return Object.hasOwn(n,e)?b(n[e])??{}:{}}function ce(t,e){return Object.values(G(t,e)).filter(n=>n!==void 0).length}function X(t,e,n){const o={...W(t)};if(Et(n).length?o[e]=n:delete o[e],!Object.keys(o).length){const{[$]:r,...i}=t;return i}return{...t,[$]:o}}function Et(t){return Object.entries(t).filter(([,e])=>e!==void 0)}function yt(t){return St.includes(t)}const _=(t,e,n)=>Math.min(n,Math.max(e,t));function Ot(t,e){if(yt(t)){const n=Math.round(Number(e));return!Number.isFinite(n)||n===0?null:_(n,lt,ut)}if(t==="lineHeight"){const n=Number(e);return Number.isFinite(n)?P(_(n,mt,Pt),3):null}if(t==="letterSpacing"){const n=Number(e);return Number.isFinite(n)?P(_(n,Tt,bt),4):null}if(t==="paragraphSpacing"){const n=Math.round(Number(e));return!Number.isFinite(n)||n<=0?null:_(n,_t,Rt)}if(Object.hasOwn(K,t)){const{min:n,max:o}=K[t],r=Math.round(Number(e));return Number.isFinite(r)?_(r,n,o):null}return t==="italic"?typeof e=="boolean"?e:null:t==="role"||t==="fontRole"?E(e)?e:null:t==="sizeToken"?z(e)?e:null:t==="textStyle"?m(e)?e:null:t==="alignPhone"?y.includes(e)?e:null:e}const Nt=["weight","size","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function w(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&&!y.includes(t.align)&&n("align"),t.alignPhone!==void 0&&!y.includes(t.alignPhone)&&n("alignPhone"),t.textStyle!==void 0&&!m(t.textStyle)&&n("textStyle"),t.sizeToken!==void 0&&!z(t.sizeToken)&&n("sizeToken"),t.fontRole!==void 0&&!E(t.fontRole)&&n("fontRole"),e??t}function z(t){if(!t||typeof t!="object")return!1;const{step:e,px:n,stepPhone:o,pxPhone:r,fluid:i}=t,c=s=>typeof s=="number"&&Number.isFinite(s)&&s>0,p=s=>typeof s=="string"&&At.includes(s);return p(e)&&c(n)&&(o===void 0||p(o))&&(r===void 0||c(r))&&(i===void 0||$t(i,n))}function $t(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 U(t){return t?.pxPhone&&z(t)?{step:t.stepPhone??t.step,px:t.pxPhone}:null}function B({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 wt=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function zt(t){const e=[];for(const[n,o]of wt)n===t?e.push(o):o===t&&e.push(n);return e}function ae(t,e,n,o){const r={...G(t,e)},i=o==null?null:Ot(n,o);if(i===null)delete r[n];else{r[n]=i;for(const c of zt(n))delete r[c]}return X(t,e,r)}function fe(t,e){return X(t,e,{})}function It(t){return tt(t)??"none"}function kt(t){return v(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 Mt(t,e){const n=E(t.role);return n||(e?.blockDrawsStyle?null:at(t.textStyle))}function le(t,e){return t==="Text"&&e==="text"}const Ft={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 Lt(t){const e=M[t],n=Ft[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=P(Ht+t.line*ht,3)),typeof t.letterSpacing=="number"?e.letterSpacingEm=t.letterSpacing:t.letter&&(e.letterSpacingEm=P(t.letter*gt,4)),e}const Ht=1,g="--sf-part-para";function Y(t){t=w(t);const e={};if(typeof t.sizePhone=="number"&&t.sizePhone>0)e.fontSize=`${t.sizePhone}px`;else{const n=U(t.sizeToken);n&&(e.fontSize=B(n))}return t.alignPhone&&(e.textAlign=t.alignPhone),e}function Dt(t,e){if(!e)return t;const n=w(t);let o=t;if(typeof n.sizePhone=="number"&&n.sizePhone>0)o={...o,size:n.sizePhone};else{const r=U(n.sizeToken);r&&(o={...o,size:void 0,sizeToken:r})}return n.alignPhone&&(o={...o,align:n.alignPhone}),o}function O(t,e,n){t=w(t);const o=Mt(t,n),r=jt(t),i=t.size?`${t.size}px`:t.sizeToken?B(t.sizeToken):o?Lt(o):"";return{fontFamily:t.font?Gt(t.font):t.fontRole?`var(${V[t.fontRole]})`:o?`var(${V[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`:"",[g]:t.paragraphSpacing?`${t.paragraphSpacing}px`:"",textTransform:kt(t.case),textAlign:t.align??"",paddingTop:Z(t.padding),paddingBottom:Z(t.padding),color:Ct(t.color),fontStyle:t.italic===!0?"italic":t.italic===!1?"normal":""}}const Ct=t=>t===void 0||t===""?"":Object.hasOwn(L,t)?L[t]:et(t)===t.toLowerCase()?t:"",Z=t=>t===void 0?"":`${t}px`,P=(t,e)=>Number(t.toFixed(e));function ue(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:Kt(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:Wt(t.textAlign),case:It(t.textTransform),paddingPx:Number.isFinite(i)?Math.round(i):0}}function Kt(t){return Number.isFinite(t)?ft.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e):400}function Wt(t){for(const e of y)if(e===t)return e;return t==="end"?"right":"left"}function pe(t,e){const n=q(t);if(!n)return"";for(const o of nt)if(q(e(o.cssVar))===n)return o.key;return""}const q=t=>(t.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function Gt(t){const e=ot(t);return e?`var(${e.cssVar})`:""}function de(t,e,n,o){return!e||F(e)?.nodeId!==t?null:n.find(i=>o(i.getAttribute("class")))??n[0]??null}function xe(t,e,n=()=>R,o=p=>p,r=Bt,i=!1,c=()=>!1){let p=0;for(const{element:s,partId:a}of t){const u=F(a)?.propKey;if(!u)continue;const f=o(u),d=Object.hasOwn(e,f)?b(e[f])??{}:{},l=O(Dt(d,i),R,{blockDrawsStyle:c(u)});m(d.textStyle)?s.setAttribute?.(j,d.textStyle):s.removeAttribute?.(j);const S=k.some(h=>s.style[h]);let x=!1;for(const[h,T]of Object.entries(l))Vt(s,h,T),T&&(x=!0);if(S||k.some(h=>l[h]))for(const h of Xt(s,r))for(const T of k)h.style[T]=l[T]??"";x&&(p+=1)}return p}function Xt(t,e){const n=N(t.textContent??""),o=[];let r=t;for(let i=0;i<Ut&&e(r);i+=1){const c=r.parentElement;if(!c||N(c.textContent??"")!==n)break;o.push(c),r=c}return o}const Ut=8;function Bt(t){const e=t;return typeof window>"u"||!e?.ownerDocument?!1:window.getComputedStyle(e).display==="inline"}const R={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Vt(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===g&&(n?r.setAttribute?.(J,""):r.removeAttribute?.(J))}const J="data-sf-part-para",Yt=Object.keys(O({},R)),I=new Set(["color","overflowWrap",g,"fontStyle"]),k=Yt.filter(t=>!I.has(t));function he(t,e,n,o=i=>i,r=()=>!1){const i=new Map;for(const s of t){const a=rt(s.key,s.row);for(const u of s.texts){const f=i.get(u);f?(f.keys.add(s.key),f.partKeys.add(a)):i.set(u,{keys:new Set([s.key]),partKeys:new Set([a])})}}const c=new Map;for(const s of Object.keys(e)){if(!Zt(s))continue;const a=b(e[s])??{},u=O(a,R),f=Y(a),d=m(a.textStyle)?a.textStyle:void 0;!Object.values(u).some(Boolean)&&!Object.keys(f).length&&!d||c.set(s,{stamp:Q(n,s),declarations:u,...Object.keys(f).length?{phone:f}:{},...d?{textStyle:d}:{}})}const p=new Map;for(const[s,{keys:a,partKeys:u}]of i){const f=u.size===1?[...u][0]:a.size===1?[...a][0]:null;if(!f)continue;const d=o(f);if(!Object.hasOwn(e,d))continue;const l=b(e[d])??{},S=O(l,R,{blockDrawsStyle:r(f)}),x=Y(l),A=m(l.textStyle)?l.textStyle:void 0;!Object.values(S).some(Boolean)&&!Object.keys(x).length&&!A||p.set(s,{stamp:Q(n,f),declarations:S,...Object.keys(x).length?{phone:x}:{},...A?{textStyle:A}:{}})}return p.size||c.size?{rules:p,kindRules:c,drawn:new Set(i.keys())}:null}function Zt(t){return t.startsWith("@")}function ge(t,e){return t?.kindRules.get(e)??null}function Q(t,e){const n=o=>o.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(t)}~${n(e)}`}function Se(t){const e=[],n=new Set,o=r=>{const{stamp:i,declarations:c}=r;if(n.has(i))return;n.add(i);const p=Object.entries(c).filter(([,l])=>l!==""),s=l=>l.map(([S,x])=>`${Jt(S)}: ${x}`).join("; "),a=`[${st}="${i}"]`,u=p.filter(([l])=>!I.has(l)),f=p.filter(([l])=>I.has(l));u.length&&e.push(`${a}, *:has(> ${a}) { ${s(u)} }`),f.length&&e.push(`${a} { ${s(f)} }`),c[g]&&(e.push(`*:has(> ${a}) { ${g}: ${c[g]} }`),e.push(...qt(a,`*:has(> ${a})`)));const d=Object.entries(r.phone??{}).filter(([,l])=>l!=="");d.length&&e.push(`@media ${it} { ${a}, *:has(> ${a}) { ${s(d)} } }`)};for(const r of t.rules.values())o(r);for(const r of t.kindRules.values())o(r);return e.join(`
|
|
2
|
+
`)}function qt(t,e){const n=`var(${g})`,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 Jt=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);function me(t,e){if(!t)return null;const n=N(e),o=t.rules.get(n);if(o)return o;if(n.length<Qt||t.drawn.has(n))return null;let r=null;for(const[i,c]of t.rules)if(i.includes(n)){if(r&&r.stamp!==c.stamp)return null;r=c}return r}const Qt=8;export{y as PART_ALIGNS,bt as PART_LETTER_EM_MAX,Tt as PART_LETTER_EM_MIN,gt as PART_LETTER_STEP,Pt as PART_LINE_HEIGHT_MAX,mt as PART_LINE_HEIGHT_MIN,ht as PART_LINE_STEP,K as PART_MEASURED_TRACKS,ut as PART_NUDGE_MAX,lt as PART_NUDGE_MIN,dt as PART_PADDING_MAX,pt as PART_PADDING_MIN,xt as PART_PADDING_STEP,J as PART_PARAGRAPH_ATTR,Rt as PART_PARAGRAPH_MAX,_t as PART_PARAGRAPH_MIN,g as PART_PARAGRAPH_VAR,St as PART_RELATIVE_PROPS,C as PART_SIZE_MAX,D as PART_SIZE_MIN,At as PART_SIZE_STEPS,st as PART_STYLED_ATTR,$ as PART_STYLES_PROP,Yt as PART_STYLE_PROPERTIES,ft as PART_WEIGHTS,k as SHARED_PART_PROPERTIES,H as STYLE_ID_OF_ROLE,j as TEXT_STYLE_ATTR,xe as applyPartStyles,le as blockDrawsTextStyle,se as followedStyleOf,Zt as isPartKindKey,m as isTextStyleId,qt as paragraphRules,It as partCaseOfTransform,kt as partCaseTransform,pe as partFontKeyOf,Y as partPhoneDeclarations,ge as partRuleForKind,me as partRuleForText,jt as partSpacingOf,ue as partStyleBase,ce as partStyleCount,Se as partStyleCss,O as partStyleDeclarations,Dt as partStyleForScreen,de as partStyleSource,ae as propsWithPartStyleValue,fe as propsWithoutPartStyle,he as publishedPartStyles,G as readPartStyle,W as readPartStyles};
|
|
@@ -27,6 +27,10 @@ export declare function holdsAuthoredText(field: unknown): boolean;
|
|
|
27
27
|
export declare function partLabel(field: Record<string, unknown>, key: string): string;
|
|
28
28
|
export declare function partHeadLabel(label: string): string;
|
|
29
29
|
export declare function partNeedles(fields: Record<string, unknown> | undefined, props: Record<string, unknown> | undefined): PartNeedle[];
|
|
30
|
+
export declare function canTypeOnCanvas(part: {
|
|
31
|
+
offPage: boolean;
|
|
32
|
+
hidden: boolean;
|
|
33
|
+
}): boolean;
|
|
30
34
|
export type SectionTextPart = {
|
|
31
35
|
key: string;
|
|
32
36
|
label: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decodePartId as
|
|
1
|
+
import{decodePartId as g,encodePartId as O}from"efficient-easel/draw";import{stripMarkup as m}from"../../../format/lib/markup.js";import{LINK_FIELD_MARKER as R,SCAFFOLD_FIELD_MARKER as y,TEXT_FIELD_MARKER as u}from"efficient-easel/draw";import{readHidable as A}from"efficient-easel/draw";import{SCALAR_TEXT_CONTROLS as E}from"efficient-easel/draw";import{isStructuralTextProp as _}from"../../../format/lib/document/neutralization-contracts.js";import{fieldInOwnBox as L}from"../../../format/lib/document/own-box.js";import{partRowTexts as I}from"./part-rows.js";import{nonEmptyString as S}from"../../../format/lib/non-empty-string.js";const $="data-sf-part",G="data-sf-region-part",q="data-sf-part-row";function J(e,t){return`${e}[${t}]`}const Q="data-sf-part-kind",j="data-sf-part-style-owner",N="data-sf-part-style-kind";function U(e){for(let t=e;t;t=t.parentElement){const r=t.getAttribute(j),n=t.getAttribute(N);if(r&&n)return{owner:r,kind:n};if(t.getAttribute("data-easel-block"))return null}return null}const b=2;function h(e){return m(e).replace(/\s+/gu,"")}function l(e,t,r){const n=e[u];if(n){if(n.control==="textList"){const o=n.itemKey??"text";if(!Array.isArray(t))return;for(const s of t){const c=s?.[o];typeof c=="string"&&r.push(c)}return}const{text:i}=A(t);i?r.push(i):n.placeholder&&r.push(n.placeholder);return}if(!e[R]){if(e.type==="text"||e.type==="textarea"){const i=S(t);i&&r.push(i);return}if(e.arrayFields&&Array.isArray(t)){for(const i of t)for(const[o,s]of Object.entries(e.arrayFields))l(s,i?.[o],r);return}if(e.objectFields&&t&&typeof t=="object")for(const[i,o]of Object.entries(e.objectFields))l(o,t[i],r)}}function V(e){if(!e||typeof e!="object")return!1;const t=e;return t[R]?!1:!!t[u]||t.type==="text"||t.type==="textarea"}function w(e,t){const r=e[u];return r?.label?r.label:typeof e.label=="string"?e.label:t}function F(e){const t=e.indexOf(" (");return(t>0?e.slice(0,t):e).trim()}function Z(e,t){if(!e)return[];const r=[];for(const[n,i]of Object.entries(e)){if(!i||typeof i!="object"||_(n))continue;const o=i,s=[];l(o,t?.[n],s),!s.length&&o[y]!==void 0&&l(o,o[y],s);const c=w(o,n),a=new Set;for(const{row:d,text:f}of I(o,t?.[n])){const T=h(f);T.length<b||(a.add(T),r.push({key:n,label:c,texts:[T],row:d}))}const p=new Set(a),x=[];for(const d of s){const f=h(d);f.length<b||p.has(f)||(p.add(f),x.push(f))}x.length&&r.push({key:n,label:c,texts:x})}return r}function K(e){return!e.offPage&&!e.hidden}const k=E;function P(e,t){if(!t||typeof t!="object"||_(e)||L(t))return null;const r=t[u];return!r||!k.includes(r.control)?null:r}function v(e,t){const r=P(e,t);return r!==null&&r.identifier!==!0}function tt(e,t){if(!e)return[];const r=[];for(const[n,i]of Object.entries(e)){const o=P(n,i);if(!o)continue;const{text:s,hidden:c}=A(t?.[n]);if(K({offPage:o.offPage===!0,hidden:!!c}))continue;const a=s||o.placeholder||"",p=m(a).replace(/\s+/gu," ").trim();r.push({key:n,label:F(w(i,n)),preview:p,offPage:o.offPage===!0,identifier:o.identifier===!0,hidden:!!c})}return r}export{$ as PART_ATTR,Q as PART_KIND_ATTR,q as PART_ROW_ATTR,N as PART_STYLE_KIND_ATTR,j as PART_STYLE_OWNER_ATTR,G as REGION_PART_ATTR,K as canTypeOnCanvas,g as decodePartId,O as encodePartId,J as encodePartRow,P as entryPartMetaOf,v as fieldDrawsEntryRow,V as holdsAuthoredText,h as normalizePartText,F as partHeadLabel,w as partLabel,Z as partNeedles,U as partStyleOwnerOf,tt as sectionTextParts};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoredTextStyle } from "../text-styles/site-text-styles.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ThemeColors, type ThemeValue } from "../../../format/lib/theme.js";
|
|
3
3
|
type Props = Record<string, unknown>;
|
|
4
4
|
export type SectionNode = {
|
|
5
5
|
type: string;
|
|
@@ -36,7 +36,9 @@ export type SiteFacts = {
|
|
|
36
36
|
};
|
|
37
37
|
export type ConvertContext = {
|
|
38
38
|
site?: SiteFacts;
|
|
39
|
+
theme?: ThemeValue;
|
|
39
40
|
};
|
|
41
|
+
export declare function convertTheme(ctx: ConvertContext): ThemeValue | undefined;
|
|
40
42
|
export type Restyled = {
|
|
41
43
|
key: string;
|
|
42
44
|
was: {
|
|
@@ -178,11 +180,11 @@ export declare const hasWords: (v: unknown) => boolean;
|
|
|
178
180
|
export declare function convertSection(node: SectionNode, row: SectionToBoxRow, ctx?: ConvertContext): SectionConversion;
|
|
179
181
|
export declare function convertSectionsInPage<D extends {
|
|
180
182
|
content?: unknown;
|
|
181
|
-
}>(data: D, on?: readonly string[]): D;
|
|
183
|
+
}>(data: D, on?: readonly string[], ctx?: ConvertContext): D;
|
|
182
184
|
export type SectionToBoxEdit = {
|
|
183
185
|
index: number;
|
|
184
186
|
node: SectionNode;
|
|
185
187
|
nodes: SectionNode[];
|
|
186
188
|
};
|
|
187
|
-
export declare function sectionToBoxEdits(content: unknown, on?: readonly string[]): SectionToBoxEdit[];
|
|
189
|
+
export declare function sectionToBoxEdits(content: unknown, on?: readonly string[], ctx?: ConvertContext): SectionToBoxEdit[];
|
|
188
190
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readHidable as Q}from"efficient-easel/draw";import{BOX_TYPE as U,CONTAINER_BLOCKS_SLOT as Z}from"../../../format/lib/document/container-blocks.js";import{headingTextSeed as ee,labelTextSeed as te}from"../../../format/lib/document/text-seeds.js";import{SPLITTABLE_SECTIONS as oe}from"../../../format/lib/sections/section-head-placement.js";import{finiteNumber as I}from"../../../format/lib/finite-number.js";import{bucketByGroup as ne}from"../../../format/lib/locations-grid.js";const _=U,j=Z;function se(t,o){return o===0?`${t}~box`:`${t}~box-${o+1}`}const R={Flex:"the Box itself",Hero:"its slides hold Boxes of real blocks (Hero › Slide › Box)",Divider:"one block with no text, picture or button",CustomHTML:"the HTML box is the whole section; it has no parts"};function ke(t){for(const[o,r]of Object.entries(t)){if(o in R&&R[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" is already Box-native`);R[o]=r}}function be(t){return R[t]}const V=new Set(["id"]),T={},C=[];function me(t){for(const[o,r]of Object.entries(t)){if(o in T&&T[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" already has a row`);T[o]=r}}function xe(t){return T[t]}function ge(){return Object.keys(T)}function $e(t){return t in T&&C.includes(t)}function we(t){const o=oe[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 H=t=>Q(t),Oe=t=>H(t).text.trim()!=="";function ie(t){if(t.includes("=="))return t;const o=t.indexOf("/"),r=o===-1?t:t.slice(0,o),a=r.trim();if(!a)return t;const y=r.indexOf(a);return`${r.slice(0,y)}==${a}==${r.slice(y+a.length)}${o===-1?"":t.slice(o)}`}const re=t=>t==="heading"?ee():t==="eyebrow"?te():{};function ae(t,o,r){const y={...t._partStyles?.text??{},...o??{},...r??{}};return Object.keys(y).length?{_partStyles:{text:y}}:{}}function ce(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 Y(t,o,r,a,y={}){const c={...o};for(const h of t){const[g,E,P]=typeof h=="string"?[h,h,void 0]:h;if(r[g]===void 0)continue;const S=P?P(r[g],r,y):r[g];S===void 0?delete c[E]:c[E]=S,a(g,E,S===void 0)}return c}function fe(t){const o=new Set([...V,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),r=y=>{for(const c of y??[])o.add(typeof c=="string"?c:c[0])},a=y=>{for(const c of y)switch(c.kind){case"text":case"image":o.add(c.key),c.kind==="image"&&c.alt&&o.add(c.alt);break;case"button":o.add(c.key),o.add(c.href),typeof c.variant=="object"&&o.add(c.variant.key);break;case"list":o.add(c.key);break;case"group":case"block":r(c.box),a(c.parts??[]);break;case"core":c.keep!=="rest"&&c.keep.forEach(h=>o.add(h)),Object.keys(c.rename??{}).forEach(h=>o.add(h));for(const h of Object.values(c.slots??{}))for(const g of h)"kind"in g&&o.add(g.key);break}};for(const y of[t,...t.also??[]])r(y.box),a(y.parts);return o}function D(t,o,r={}){const a=t.props,y=o.skip?.(a);if(y!==void 0)return{node:t,nodes:[t],carried:[],dropped:[],siteWrites:[],restyled:[],skipped:y};const c=String(a.id??t.type),h=[],g=[],E=[],P=new Set,S=(n,i)=>{h.push({key:n,home:i}),P.add(n)},X=a._partStyles??{},L=fe(o);let F=0;const $=(n,i)=>({type:n,props:{...i,id:`${c}~${n}-${++F}`}}),K=(n,i,k,l,b,d,w)=>{if(b){for(const f of n??[]){const s=typeof f=="string"?f:f[0];k[s]!==void 0&&w(s,`nothing — the ${l} has no parts, so it is not drawn`)}return}const e=typeof i=="function"?i(a,r):i??{};return Y(n??[],e,k,(f,s,m)=>w(f,m?`nothing — the old value draws nothing (${l}: no ${s})`:`${d}${l}: ${s}`),r)},M=n=>n.map(i=>{const k={...i.props??{}};for(const[l,b]of Object.entries(i.slots??{}))k[l]=M(b);return $(i.type,k)}),W=(n,i,k)=>{const l=Array.isArray(i[n.key])?i[n.key]:[],b=typeof n.props=="function"?n.props(a,r):n.props??{},d=l.map((s,m)=>{const p=s??{},u=n.item?.(p,m,a)??{},x=v(u.reverse?[...n.parts].reverse():n.parts,p,!1,`item ${m+1}: `);return n.flat?u.props?x.map(B=>({...B,props:{...B.props,...u.props,id:B.props.id}})):x:[$(_,{name:`${n.name} ${m+1}`,...b,...u.props??{},[j]:x})]});if(n.groups){const s=n.groups;return k(n.key,l.length?`one Box per item (${l.length}), in a Box per group`:"nothing — the list is empty"),ne(l.map(m=>m??{}),s.of,s.of).map((m,p)=>{const u=m.items.map(O=>O.item),x=s.parts?v(s.parts,s.head?.(u,a)??{},!1,`group ${p+1}: `):[],B=m.items.map(O=>d[O.index]),A=s.perRow?.(u.length,a),N=Number.isInteger(A)&&A>=1?A:1,z=[];if(s.perRow&&N<B.length)for(let O=0;O*N<B.length;O++)z.push(B.slice(O*N,(O+1)*N).flat());return $(_,{name:`${s.name} ${p+1}`,...s.props??{},[j]:[...x,$(_,{name:`${s.itemsName} ${p+1}`,...s.itemsProps?.(u.length,a)??{},[j]:z.length?z.map((O,J)=>$(_,{name:`${s.rowName??`${s.itemsName} row`} ${J+1}`,...s.rowProps??{},[j]:O})):B.flat()})]})})}const w=n.perRow?.(a),e=n.perRow?Number.isInteger(w)&&w>=1?w:1:0;if(k(n.key,(l.length?n.flat?`each item's parts (${l.length} items), in order`:`one Box per item (${l.length}), its parts inside`:"nothing — the list is empty")+(e&&l.length?`, in rows of ${e}`:"")),!e)return d.flat();const f=[];for(let s=0;s*e<d.length;s++)f.push($(_,{name:`${n.rowName??`${n.name} row`} ${s+1}`,...n.rowProps??{},[j]:d.slice(s*e,(s+1)*e).flat()}));return f},v=(n,i,k,l)=>{const b=[],d=(e,f)=>k?S(e,f):void 0,w=e=>k?X[e]:void 0;for(const e of n)if(!(e.when&&!e.when(a,k?void 0:i)))switch(e.kind){case"text":{const f=H(i[e.key]);if(!f.text.trim()){d(e.key,"nothing — empty words draw nothing, so no block");break}const s=re(e.role??"body"),{_partStyles:m,...p}=s,u=ae(s,e.style,w(e.key));if(e.was&&k){const x=u._partStyles?.text??{};E.push({key:e.key,was:e.was,...typeof x.textStyle=="string"?{textStyle:x.textStyle}:{},...I(x.size)!==void 0?{size:I(x.size)}:{},...I(x.sizePhone)!==void 0?{sizePhone:I(x.sizePhone)}:{}})}b.push($("Text",{text:e.mark==="accentLead"?ie(f.text):f.text,...p,...e.props??{},...u,...f.hidden?{_hidden:!0}:{}})),d(e.key,`${l}Text block: its words${f.hidden?", hidden":""}`);break}case"button":{const f=H(i[e.key]);if(!f.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 s=typeof i[e.href]=="string"&&i[e.href]?i[e.href]:"#",m={...e.style??{},...w(e.key)??{}};b.push($("ButtonBlock",{label:f.text,href:s,...typeof e.props=="function"?e.props(i,r):e.props??{},...ce(e.variant,i),...Object.keys(m).length?{_partStyles:{label:m}}:{},...f.hidden?{_hidden:!0}:{}})),d(e.key,`${l}Button block: its words`),d(e.href,`${l}Button block: its link`),typeof e.variant=="object"&&d(e.variant.key,`${l}Button block: its Style`);break}case"image":{const f=i[e.key];if(typeof f!="string"||!f){d(e.key,"nothing — no picture, no block"),e.alt&&d(e.alt,"nothing — no picture to describe");break}const s=e.alt&&typeof i[e.alt]=="string"?i[e.alt]:"";b.push($("ImageBlock",{src:f,alt:s,...e.props??{}})),d(e.key,`${l}Image block: its picture`),e.alt&&d(e.alt,`${l}Image block: its alt text`);break}case"list":{b.push(...W(e,i,d));break}case"group":{const f=v(e.parts,i,k,l),s=K(e.box,e.props,i,`${e.name} Box`,!f.length&&!e.keepEmpty,l,d);s&&b.push($(_,{name:e.name,...s,[j]:f}));break}case"block":{const f=e.parts?v(e.parts,i,k,l):[],s=K(e.box,e.props,i,`${e.type} block`,!!e.parts&&!f.length&&!e.keepEmpty,l,d);s&&b.push($(e.type,{...s,...e.slot?{[e.slot]:f}:{}}));break}case"core":{const f=e.as??t.type,s={headPlacement:"own-box",...e.props??{}},m=e.keep==="rest"?Object.keys(i).filter(p=>!L.has(p)&&!(p in s)):e.keep;for(const p of m)i[p]!==void 0&&(s[p]=i[p],d(p,`the ${f} block inside the Box`));if(e.keep==="rest"){for(const u of Object.keys(e.props??{}))i[u]!==void 0&&!L.has(u)&&d(u,`nothing — the ${f} block inside the Box has the row's own value`);i.headPlacement!==void 0&&d("headPlacement",`the ${f} block inside the Box: own-box`);const p=Object.fromEntries(Object.entries(X).filter(([u])=>!L.has(u)));Object.keys(p).length&&(s._partStyles=p)}for(const[p,u]of Object.entries(e.rename??{}))i[p]!==void 0&&(s[u]=i[p],d(p,`the ${f} block inside the Box: ${u}`));for(const[p,u]of Object.entries(e.slots??{}))s[p]=u.flatMap(x=>"kind"in x?W(x,i,d):M([x]));b.push($(f,s));break}}return b},q=(n,i)=>{const k=i===0?"Box":`${n.name} Box`,l=v(n.parts,a,!0,i===0?"":`${k}: `),b=typeof n.boxProps=="function"?n.boxProps(a,r):n.boxProps??{},d=Y(n.box??[],b,a,(w,e,f)=>S(w,f?`nothing — the old value draws nothing (${k}: no ${e})`:`${k}: ${e}`),r);return{type:_,props:{name:n.name,...d,[j]:l,id:se(c,i)}}},G=[o,...o.also??[]].map(q);a._partStyles!==void 0&&S("_partStyles","each old part's style moved to its new part");for(const[n,i]of Object.entries(o.reads??{}))a[n]!==void 0&&S(n,i);for(const[n,i]of Object.entries(o.drop??{}))n in a&&(g.push({key:n,why:i}),P.add(n));for(const n of Object.keys(a))V.has(n)||P.has(n)||g.push({key:n,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:h,dropped:g,siteWrites:[...o.site?.(t,r)??[]],restyled:E}}function Se(t,o=C){const r=t.content;if(!Array.isArray(r))return t;let a=!1;const y=r.flatMap(c=>{const h=c&&typeof c.type=="string"&&o.includes(c.type)?T[c.type]:void 0;if(!h)return[c];const g=D(c,h);return g.skipped!==void 0?[c]:(a=!0,g.nodes)});return a?{...t,content:y}:t}function Be(t,o=C){if(!Array.isArray(t))return[];const r=[];return t.forEach((a,y)=>{const c=a&&typeof a.type=="string"&&o.includes(a.type)?T[a.type]:void 0;if(!c)return;const h=D(a,c);h.skipped===void 0&&r.push({index:y,node:h.node,nodes:h.nodes})}),r}export{j as SECTION_BOX_SLOT,_ as SECTION_BOX_TYPE,C as SECTION_TO_BOX_ON,be as boxNativeReason,D as convertSection,Se as convertSectionsInPage,$e as convertsToBox,Oe as hasWords,we as headParts,ke as registerBoxNativeSections,me as registerSectionToBox,se as sectionBoxIdOf,Be as sectionToBoxEdits,xe as sectionToBoxRow,ge as sectionToBoxTypes};
|
|
1
|
+
import{readHidable as U}from"efficient-easel/draw";import{BOX_TYPE as Z,CONTAINER_BLOCKS_SLOT as ee}from"../../../format/lib/document/container-blocks.js";import{headingTextSeed as te,labelTextSeed as ne}from"../../../format/lib/document/text-seeds.js";import{SPLITTABLE_SECTIONS as oe}from"../../../format/lib/sections/section-head-placement.js";import{finiteNumber as I}from"../../../format/lib/finite-number.js";import{bucketByGroup as se}from"../../../format/lib/locations-grid.js";import{normalizeTheme as V}from"../../../format/lib/theme.js";const j=Z,E=ee;function be(t){if(t.theme)return V(t.theme);const n=t.site?.themePresets;return n?V({selected:t.site?.selectedPreset??0,themes:[...n]}):void 0}function re(t,n){return n===0?`${t}~box`:`${t}~box-${n+1}`}const R={Flex:"the Box itself",Hero:"its slides hold Boxes of real blocks (Hero › Slide › Box)",Divider:"one block with no text, picture or button",CustomHTML:"the HTML box is the whole section; it has no parts"};function xe(t){for(const[n,i]of Object.entries(t)){if(n in R&&R[n]!==i)throw new Error(`lib/sections/section-to-box: "${n}" is already Box-native`);R[n]=i}}function ge(t){return R[t]}const Y=new Set(["id"]),_={},C=[];function $e(t){for(const[n,i]of Object.entries(t)){if(n in _&&_[n]!==i)throw new Error(`lib/sections/section-to-box: "${n}" already has a row`);_[n]=i}}function we(t){return _[t]}function Oe(){return Object.keys(_)}function Se(t){return t in _&&C.includes(t)}function Be(t){const n=oe[t];if(!n)throw new Error(`lib/sections/section-to-box: "${t}" has no head row in SPLITTABLE_SECTIONS`);const i=[{kind:"text",key:n.num,role:"eyebrow"},{kind:"text",key:n.title,role:"heading"}];return n.description&&i.push({kind:"text",key:n.description,role:"body"}),n.headRows.includes("linkText")&&n.headRows.includes("linkHref")&&i.push({kind:"button",key:"linkText",href:"linkHref"}),i}const H=t=>U(t),Te=t=>H(t).text.trim()!=="";function ie(t){if(t.includes("=="))return t;const n=t.indexOf("/"),i=n===-1?t:t.slice(0,n),a=i.trim();if(!a)return t;const u=i.indexOf(a);return`${i.slice(0,u)}==${a}==${i.slice(u+a.length)}${n===-1?"":t.slice(n)}`}const ae=t=>t==="heading"?te():t==="eyebrow"?ne():{};function ce(t,n,i,a){const f={...t._partStyles?.text??{},...n??{},...i??{}};return(a==="center"||a==="right")&&f.align===void 0&&(f.align=a),Object.keys(f).length?{_partStyles:{text:f}}:{}}function fe(t,n){if(t===void 0)return{};if(typeof t=="string")return{variant:t};const i=n[t.key];return{variant:typeof i=="string"&&Object.hasOwn(t.map,i)?t.map[i]:t.fallback}}function D(t,n,i,a,u={}){const f={...n};for(const h of t){const[m,S,P]=typeof h=="string"?[h,h,void 0]:h;if(i[m]===void 0)continue;const B=P?P(i[m],i,u):i[m];B===void 0?delete f[S]:f[S]=B,a(m,S,B===void 0)}return f}function de(t){const n=new Set([...Y,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),i=u=>{for(const f of u??[])n.add(typeof f=="string"?f:f[0])},a=u=>{for(const f of u)switch(f.kind){case"text":case"image":n.add(f.key),f.kind==="image"&&f.alt&&n.add(f.alt);break;case"button":n.add(f.key),n.add(f.href),typeof f.variant=="object"&&n.add(f.variant.key);break;case"list":n.add(f.key);break;case"group":case"block":i(f.box),a(f.parts??[]);break;case"core":f.keep!=="rest"&&f.keep.forEach(h=>n.add(h)),Object.keys(f.rename??{}).forEach(h=>n.add(h));for(const h of Object.values(f.slots??{}))for(const m of h)"kind"in m&&n.add(m.key);break}};for(const u of[t,...t.also??[]])i(u.box),a(u.parts);return n}function F(t,n,i={}){const a=t.props,u=n.skip?.(a);if(u!==void 0)return{node:t,nodes:[t],carried:[],dropped:[],siteWrites:[],restyled:[],skipped:u};const f=String(a.id??t.type),h=[],m=[],S=[],P=new Set,B=(o,r)=>{h.push({key:o,home:r}),P.add(o)},X=a._partStyles??{},L=de(n);let q=0;const $=(o,r)=>({type:o,props:{...r,id:`${f}~${o}-${++q}`}}),K=(o,r,k,l,b,d,w)=>{if(b){for(const c of o??[]){const s=typeof c=="string"?c:c[0];k[s]!==void 0&&w(s,`nothing — the ${l} has no parts, so it is not drawn`)}return}const e=typeof r=="function"?r(a,i):r??{};return D(o??[],e,k,(c,s,x)=>w(c,x?`nothing — the old value draws nothing (${l}: no ${s})`:`${d}${l}: ${s}`),i)},M=o=>o.map(r=>{const k={...r.props??{}};for(const[l,b]of Object.entries(r.slots??{}))k[l]=M(b);return $(r.type,k)}),W=(o,r,k)=>{const l=Array.isArray(r[o.key])?r[o.key]:[],b=typeof o.props=="function"?o.props(a,i):o.props??{},d=l.map((s,x)=>{const p=s??{},y=o.item?.(p,x,a)??{},g=v(y.reverse?[...o.parts].reverse():o.parts,p,!1,`item ${x+1}: `);return o.flat?y.props?g.map(T=>({...T,props:{...T.props,...y.props,id:T.props.id}})):g:[$(j,{name:`${o.name} ${x+1}`,...b,...y.props??{},[E]:g})]});if(o.groups){const s=o.groups;return k(o.key,l.length?`one Box per item (${l.length}), in a Box per group`:"nothing — the list is empty"),se(l.map(x=>x??{}),s.of,s.of).map((x,p)=>{const y=x.items.map(O=>O.item),g=s.parts?v(s.parts,s.head?.(y,a)??{},!1,`group ${p+1}: `):[],T=x.items.map(O=>d[O.index]),A=s.perRow?.(y.length,a),N=Number.isInteger(A)&&A>=1?A:1,z=[];if(s.perRow&&N<T.length)for(let O=0;O*N<T.length;O++)z.push(T.slice(O*N,(O+1)*N).flat());return $(j,{name:`${s.name} ${p+1}`,...s.props??{},[E]:[...g,$(j,{name:`${s.itemsName} ${p+1}`,...s.itemsProps?.(y.length,a)??{},[E]:z.length?z.map((O,Q)=>$(j,{name:`${s.rowName??`${s.itemsName} row`} ${Q+1}`,...s.rowProps??{},[E]:O})):T.flat()})]})})}const w=o.perRow?.(a),e=o.perRow?Number.isInteger(w)&&w>=1?w:1:0;if(k(o.key,(l.length?o.flat?`each item's parts (${l.length} items), in order`:`one Box per item (${l.length}), its parts inside`:"nothing — the list is empty")+(e&&l.length?`, in rows of ${e}`:"")),!e)return d.flat();const c=[];for(let s=0;s*e<d.length;s++)c.push($(j,{name:`${o.rowName??`${o.name} row`} ${s+1}`,...o.rowProps??{},[E]:d.slice(s*e,(s+1)*e).flat()}));return c},v=(o,r,k,l)=>{const b=[],d=(e,c)=>k?B(e,c):void 0,w=e=>k?X[e]:void 0;for(const e of o)if(!(e.when&&!e.when(a,k?void 0:r)))switch(e.kind){case"text":{const c=H(r[e.key]);if(!c.text.trim()){d(e.key,"nothing — empty words draw nothing, so no block");break}const s=ae(e.role??"body"),{_partStyles:x,...p}=s,y=ce(s,e.style,w(e.key),e.props?.align);if(e.was&&k){const g=y._partStyles?.text??{};S.push({key:e.key,was:e.was,...typeof g.textStyle=="string"?{textStyle:g.textStyle}:{},...I(g.size)!==void 0?{size:I(g.size)}:{},...I(g.sizePhone)!==void 0?{sizePhone:I(g.sizePhone)}:{}})}b.push($("Text",{text:e.mark==="accentLead"?ie(c.text):c.text,...p,...e.props??{},...y,...c.hidden?{_hidden:!0}:{}})),d(e.key,`${l}Text block: its words${c.hidden?", hidden":""}`);break}case"button":{const c=H(r[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 s=typeof r[e.href]=="string"&&r[e.href]?r[e.href]:"#",x={...e.style??{},...w(e.key)??{}};b.push($("ButtonBlock",{label:c.text,href:s,...typeof e.props=="function"?e.props(r,i):e.props??{},...fe(e.variant,r),...Object.keys(x).length?{_partStyles:{label:x}}:{},...c.hidden?{_hidden:!0}:{}})),d(e.key,`${l}Button block: its words`),d(e.href,`${l}Button block: its link`),typeof e.variant=="object"&&d(e.variant.key,`${l}Button block: its Style`);break}case"image":{const c=r[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 s=e.alt&&typeof r[e.alt]=="string"?r[e.alt]:"";b.push($("ImageBlock",{src:c,alt:s,...e.props??{}})),d(e.key,`${l}Image block: its picture`),e.alt&&d(e.alt,`${l}Image block: its alt text`);break}case"list":{b.push(...W(e,r,d));break}case"group":{const c=v(e.parts,r,k,l),s=K(e.box,e.props,r,`${e.name} Box`,!c.length&&!e.keepEmpty,l,d);s&&b.push($(j,{name:e.name,...s,[E]:c}));break}case"block":{const c=e.parts?v(e.parts,r,k,l):[],s=K(e.box,e.props,r,`${e.type} block`,!!e.parts&&!c.length&&!e.keepEmpty,l,d);s&&b.push($(e.type,{...s,...e.slot?{[e.slot]:c}:{}}));break}case"core":{const c=e.as??t.type,s={headPlacement:"own-box",...e.props??{}},x=e.keep==="rest"?Object.keys(r).filter(p=>!L.has(p)&&!(p in s)):e.keep;for(const p of x)r[p]!==void 0&&(s[p]=r[p],d(p,`the ${c} block inside the Box`));if(e.keep==="rest"){for(const y of Object.keys(e.props??{}))r[y]!==void 0&&!L.has(y)&&d(y,`nothing — the ${c} block inside the Box has the row's own value`);r.headPlacement!==void 0&&d("headPlacement",`the ${c} block inside the Box: own-box`);const p=Object.fromEntries(Object.entries(X).filter(([y])=>!L.has(y)));Object.keys(p).length&&(s._partStyles=p)}for(const[p,y]of Object.entries(e.rename??{}))r[p]!==void 0&&(s[y]=r[p],d(p,`the ${c} block inside the Box: ${y}`));for(const[p,y]of Object.entries(e.slots??{}))s[p]=y.flatMap(g=>"kind"in g?W(g,r,d):M([g]));b.push($(c,s));break}}return b},J=(o,r)=>{const k=r===0?"Box":`${o.name} Box`,l=v(o.parts,a,!0,r===0?"":`${k}: `),b=typeof o.boxProps=="function"?o.boxProps(a,i):o.boxProps??{},d=D(o.box??[],b,a,(w,e,c)=>B(w,c?`nothing — the old value draws nothing (${k}: no ${e})`:`${k}: ${e}`),i);return{type:j,props:{name:o.name,...d,[E]:l,id:re(f,r)}}},G=[n,...n.also??[]].map(J);a._partStyles!==void 0&&B("_partStyles","each old part's style moved to its new part");for(const[o,r]of Object.entries(n.reads??{}))a[o]!==void 0&&B(o,r);for(const[o,r]of Object.entries(n.drop??{}))o in a&&(m.push({key:o,why:r}),P.add(o));for(const o of Object.keys(a))Y.has(o)||P.has(o)||m.push({key:o,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:h,dropped:m,siteWrites:[...n.site?.(t,i)??[]],restyled:S}}function _e(t,n=C,i={}){const a=t.content;if(!Array.isArray(a))return t;let u=!1;const f=a.flatMap(h=>{const m=h&&typeof h.type=="string"&&n.includes(h.type)?_[h.type]:void 0;if(!m)return[h];const S=F(h,m,i);return S.skipped!==void 0?[h]:(u=!0,S.nodes)});return u?{...t,content:f}:t}function je(t,n=C,i={}){if(!Array.isArray(t))return[];const a=[];return t.forEach((u,f)=>{const h=u&&typeof u.type=="string"&&n.includes(u.type)?_[u.type]:void 0;if(!h)return;const m=F(u,h,i);m.skipped===void 0&&a.push({index:f,node:m.node,nodes:m.nodes})}),a}export{E as SECTION_BOX_SLOT,j as SECTION_BOX_TYPE,C as SECTION_TO_BOX_ON,ge as boxNativeReason,F as convertSection,_e as convertSectionsInPage,be as convertTheme,Se as convertsToBox,Te as hasWords,Be as headParts,xe as registerBoxNativeSections,$e as registerSectionToBox,re as sectionBoxIdOf,je as sectionToBoxEdits,we as sectionToBoxRow,Oe as sectionToBoxTypes};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-web-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "46.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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@tabler/icons-react": "^3.46.0",
|
|
56
|
-
"efficient-easel": "^
|
|
56
|
+
"efficient-easel": "^26.1.0",
|
|
57
57
|
"efficient-shell": "^11.8.0",
|
|
58
58
|
"isomorphic-dompurify": "^3.18.0",
|
|
59
59
|
"next": ">=16",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@types/node": "^20",
|
|
73
73
|
"@types/react": "^19",
|
|
74
74
|
"@types/react-dom": "^19",
|
|
75
|
-
"efficient-easel": "^
|
|
75
|
+
"efficient-easel": "^26.1.0",
|
|
76
76
|
"efficient-shell": "^11.8.0",
|
|
77
77
|
"esbuild": "^0.28.0",
|
|
78
78
|
"happy-dom": "^20.14.5",
|