efficient-web-builder 47.2.0 → 48.1.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.
Files changed (173) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/editor/components/HeroPartPanel.js +1 -1
  3. package/dist/editor/components/HoverEffectField.d.ts +1 -0
  4. package/dist/editor/components/HoverEffectField.js +1 -1
  5. package/dist/editor/components/MediaUploadField.d.ts +9 -0
  6. package/dist/editor/components/MediaUploadField.js +1 -1
  7. package/dist/editor/components/PartSettingsPanel.d.ts +2 -1
  8. package/dist/editor/components/PartSettingsPanel.js +1 -1
  9. package/dist/editor/components/PreviewPartAnchors.d.ts +3 -1
  10. package/dist/editor/components/PreviewPartAnchors.js +1 -1
  11. package/dist/editor/components/SameInEveryViewNote.d.ts +1 -0
  12. package/dist/editor/components/SameInEveryViewNote.js +1 -0
  13. package/dist/editor/components/SaveAsTemplateButton.d.ts +5 -0
  14. package/dist/editor/components/SaveAsTemplateButton.js +1 -0
  15. package/dist/editor/components/SectionIcon.js +1 -1
  16. package/dist/editor/components/SiteFields.d.ts +4 -1
  17. package/dist/editor/components/SiteFields.js +1 -1
  18. package/dist/editor/components/SiteRestoreNotice.js +1 -1
  19. package/dist/editor/components/SiteTextStylesField.js +1 -1
  20. package/dist/editor/components/TickerSettingsPanel.js +1 -1
  21. package/dist/editor/components/VersionHistoryDrawer.js +1 -1
  22. package/dist/editor/components/WebsitePreviewButton.d.ts +2 -1
  23. package/dist/editor/components/WebsitePreviewButton.js +1 -1
  24. package/dist/editor/components/WebsiteScreenParts.js +1 -1
  25. package/dist/editor/components/usePartMotion.d.ts +10 -0
  26. package/dist/editor/components/usePartMotion.js +1 -0
  27. package/dist/editor/components/useSocialSettings.d.ts +2 -2
  28. package/dist/editor/lib/animation/AnimationDurationRow.js +1 -1
  29. package/dist/editor/lib/animation/fields.d.ts +1 -1
  30. package/dist/editor/lib/animation/fields.js +1 -1
  31. package/dist/editor/lib/animation/hover-fields.d.ts +1 -0
  32. package/dist/editor/lib/animation/hover-fields.js +1 -0
  33. package/dist/editor/lib/document/add-target.d.ts +2 -1
  34. package/dist/editor/lib/document/add-target.js +1 -1
  35. package/dist/editor/lib/document/blocks/general/ButtonBlock/fields.js +1 -1
  36. package/dist/editor/lib/document/blocks/general/Contents/fields.d.ts +2 -0
  37. package/dist/editor/lib/document/blocks/general/Contents/fields.js +1 -0
  38. package/dist/editor/lib/document/blocks/general/Divider/fields.js +1 -1
  39. package/dist/editor/lib/document/blocks/general/Flex/fields.js +1 -1
  40. package/dist/editor/lib/document/blocks/general/HeroGroup/fields.js +1 -1
  41. package/dist/editor/lib/document/blocks/general/index.d.ts +2 -2
  42. package/dist/editor/lib/document/blocks/general/index.js +1 -1
  43. package/dist/editor/lib/document/build-config.js +1 -1
  44. package/dist/editor/lib/document/canvas-typing.d.ts +1 -0
  45. package/dist/editor/lib/document/canvas-typing.js +1 -1
  46. package/dist/editor/lib/document/card-display-chips.js +1 -1
  47. package/dist/editor/lib/document/controls.d.ts +7 -3
  48. package/dist/editor/lib/document/controls.js +1 -1
  49. package/dist/editor/lib/document/field-groups.js +1 -1
  50. package/dist/editor/lib/document/geocode-resolve.d.ts +1 -0
  51. package/dist/editor/lib/document/geocode-resolve.js +1 -1
  52. package/dist/editor/lib/document/overrides.js +1 -1
  53. package/dist/editor/lib/document/page-root.js +2 -2
  54. package/dist/editor/lib/document/part-motion-canvas.d.ts +9 -0
  55. package/dist/editor/lib/document/part-motion-canvas.js +1 -0
  56. package/dist/format/lib/animation/hover.d.ts +5 -0
  57. package/dist/format/lib/animation/hover.js +1 -0
  58. package/dist/format/lib/content/anchor-name.d.ts +2 -0
  59. package/dist/format/lib/content/anchor-name.js +1 -0
  60. package/dist/format/lib/content/box-layout.d.ts +8 -0
  61. package/dist/format/lib/content/box-layout.js +1 -1
  62. package/dist/format/lib/content/box-link.js +1 -1
  63. package/dist/format/lib/content/box-separator.js +1 -1
  64. package/dist/format/lib/content/card-template.d.ts +8 -0
  65. package/dist/format/lib/content/card-template.js +1 -1
  66. package/dist/format/lib/content/container-gap.d.ts +2 -1
  67. package/dist/format/lib/content/container-gap.js +1 -1
  68. package/dist/format/lib/content/list-number.d.ts +1 -0
  69. package/dist/format/lib/content/list-number.js +1 -0
  70. package/dist/format/lib/content/section-min-height.d.ts +3 -2
  71. package/dist/format/lib/content/section-min-height.js +1 -1
  72. package/dist/format/lib/content/section-sticky.js +1 -1
  73. package/dist/format/lib/content/sticky-aside.d.ts +2 -0
  74. package/dist/format/lib/content/sticky-aside.js +1 -0
  75. package/dist/format/lib/document/blocks/general/Contents/meta.d.ts +5 -0
  76. package/dist/format/lib/document/blocks/general/Contents/meta.js +1 -0
  77. package/dist/format/lib/document/blocks/general/metas.d.ts +1 -0
  78. package/dist/format/lib/document/blocks/general/metas.js +1 -1
  79. package/dist/format/lib/document/blocks/general/text-part-shapes.json +10 -0
  80. package/dist/format/lib/document/container-blocks.js +1 -1
  81. package/dist/format/lib/document/easel-row-words.d.ts +1 -0
  82. package/dist/format/lib/document/easel-row-words.js +1 -1
  83. package/dist/format/lib/document/general-order.d.ts +1 -1
  84. package/dist/format/lib/document/general-order.js +1 -1
  85. package/dist/format/lib/document/panel-tabs.d.ts +8 -0
  86. package/dist/format/lib/document/panel-tabs.js +1 -0
  87. package/dist/format/lib/document/part-records.d.ts +6 -0
  88. package/dist/format/lib/document/part-records.js +1 -0
  89. package/dist/format/lib/document/passes/registry-context.d.ts +1 -1
  90. package/dist/format/lib/document/passes/registry-context.js +1 -1
  91. package/dist/format/lib/document/passes/types.d.ts +2 -0
  92. package/dist/format/lib/document/section-groups.d.ts +1 -1
  93. package/dist/format/lib/editor-words-catalogue.d.ts +6 -0
  94. package/dist/format/lib/editor-words-catalogue.js +3 -3
  95. package/dist/format/lib/hero-ticker.d.ts +1 -0
  96. package/dist/format/lib/hero-ticker.js +1 -1
  97. package/dist/format/lib/links/page-link-rules.js +1 -1
  98. package/dist/format/lib/sections/contents-text-regions.d.ts +3 -0
  99. package/dist/format/lib/sections/contents-text-regions.js +1 -0
  100. package/dist/format/lib/sections/section-text-regions.js +1 -1
  101. package/dist/format/lib/sections/strip-shape.js +1 -1
  102. package/dist/render/components/CardRowContext.d.ts +3 -1
  103. package/dist/render/components/CardRowContext.js +1 -1
  104. package/dist/render/components/ContentsList.d.ts +14 -0
  105. package/dist/render/components/ContentsList.js +1 -0
  106. package/dist/render/components/DocBody.d.ts +18 -0
  107. package/dist/render/components/DocBody.js +5 -5
  108. package/dist/render/components/FAQ.js +1 -1
  109. package/dist/render/components/Flex.d.ts +3 -1
  110. package/dist/render/components/Flex.js +1 -1
  111. package/dist/render/components/Grid.d.ts +2 -1
  112. package/dist/render/components/Grid.js +1 -1
  113. package/dist/render/components/HeroGroup.d.ts +2 -1
  114. package/dist/render/components/HeroGroup.js +1 -1
  115. package/dist/render/components/HeroSection.d.ts +2 -1
  116. package/dist/render/components/HeroSection.js +1 -1
  117. package/dist/render/components/HeroSingle.d.ts +2 -1
  118. package/dist/render/components/HeroSingle.js +1 -1
  119. package/dist/render/components/PageContentsContext.d.ts +14 -0
  120. package/dist/render/components/PageContentsContext.js +1 -0
  121. package/dist/render/components/PartStyledKind.js +1 -1
  122. package/dist/render/components/PartStyledText.js +1 -1
  123. package/dist/render/components/PublishedPartStylesContext.d.ts +4 -1
  124. package/dist/render/components/PublishedPartStylesContext.js +1 -1
  125. package/dist/render/components/Reel.js +1 -1
  126. package/dist/render/components/SectionAnimation.d.ts +10 -3
  127. package/dist/render/components/SectionAnimation.js +1 -1
  128. package/dist/render/components/Text.d.ts +2 -1
  129. package/dist/render/components/Text.js +1 -1
  130. package/dist/render/components/Timeline.js +1 -1
  131. package/dist/render/components/goldPhrases.d.ts +1 -1
  132. package/dist/render/components/goldPhrases.js +2 -2
  133. package/dist/render/lib/animation/entrance.d.ts +1 -0
  134. package/dist/render/lib/animation/entrance.js +1 -1
  135. package/dist/render/lib/animation/part-motion.d.ts +25 -0
  136. package/dist/render/lib/animation/part-motion.js +2 -0
  137. package/dist/render/lib/content/button-look.js +1 -1
  138. package/dist/render/lib/content/page-contents.d.ts +17 -0
  139. package/dist/render/lib/content/page-contents.js +1 -0
  140. package/dist/render/lib/document/blocks/general/Contents/render.d.ts +2 -0
  141. package/dist/render/lib/document/blocks/general/Contents/render.js +1 -0
  142. package/dist/render/lib/document/blocks/general/Flex/render.js +1 -1
  143. package/dist/render/lib/document/blocks/general/Grid/render.js +1 -1
  144. package/dist/render/lib/document/blocks/general/Hero/render.js +1 -1
  145. package/dist/render/lib/document/blocks/general/HeroGroup/render.js +1 -1
  146. package/dist/render/lib/document/blocks/general/HeroSingle/render.js +1 -1
  147. package/dist/render/lib/document/blocks/general/Text/render.js +1 -1
  148. package/dist/render/lib/document/blocks/general/renders.d.ts +1 -0
  149. package/dist/render/lib/document/blocks/general/renders.js +1 -1
  150. package/dist/render/lib/document/blocks/general/section-to-box-row-parts.d.ts +3 -0
  151. package/dist/render/lib/document/blocks/general/section-to-box-row-parts.js +1 -1
  152. package/dist/render/lib/document/blocks/general/section-to-box-rows-cards.js +1 -1
  153. package/dist/render/lib/document/blocks/general/section-to-box-rows-docbody.d.ts +2 -0
  154. package/dist/render/lib/document/blocks/general/section-to-box-rows-docbody.js +2 -0
  155. package/dist/render/lib/document/blocks/general/section-to-box-rows-locations.js +1 -1
  156. package/dist/render/lib/document/blocks/general/section-to-box-rows-pageheader.d.ts +2 -0
  157. package/dist/render/lib/document/blocks/general/section-to-box-rows-pageheader.js +1 -0
  158. package/dist/render/lib/document/blocks/general/section-to-box-rows.js +1 -1
  159. package/dist/render/lib/document/hero-media-parts.d.ts +2 -2
  160. package/dist/render/lib/document/page-render.js +1 -1
  161. package/dist/render/lib/document/part-styles.d.ts +10 -1
  162. package/dist/render/lib/document/part-styles.js +2 -2
  163. package/dist/render/lib/document/passes/clickable-parts.js +1 -1
  164. package/dist/render/lib/document/passes/section-anchor.d.ts +1 -0
  165. package/dist/render/lib/document/passes/section-anchor.js +1 -1
  166. package/dist/render/lib/document/passes/section-padding.js +1 -1
  167. package/dist/render/lib/sections/section-to-box.d.ts +1 -0
  168. package/dist/render/lib/sections/section-to-box.js +1 -1
  169. package/dist/render/lib/text-styles/site-text-styles.d.ts +16 -4
  170. package/dist/render/lib/text-styles/site-text-styles.js +2 -2
  171. package/package.json +3 -3
  172. package/dist/editor/lib/document/selected-host.d.ts +0 -2
  173. package/dist/editor/lib/document/selected-host.js +0 -1
@@ -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 _=ee,P=te;function ge(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)",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[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 we(t){return A[t]}const Y=new Set(["id"]),j={},H=[];function $e(t){for(const[o,r]of Object.entries(t)){if(o in j&&j[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" already has a row`);j[o]=r}}function Oe(t){return j[t]}function Se(){return Object.keys(j)}function Be(t){return t in j&&H.includes(t)}function Te(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 F=t=>Z(t),_e=t=>F(t).text.trim()!=="";function ae(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 ce=t=>t==="heading"?oe():t==="eyebrow"?ne():{};function fe(t,o,r,i){const c={...t._partStyles?.text??{},...o??{},...r??{}};return(i==="center"||i==="right")&&c.align===void 0&&(c.align=i),Object.keys(c).length?{_partStyles:{text:c}}:{}}function le(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 c={...o};for(const y of t){const[g,S,v]=typeof y=="string"?[y,y,void 0]:y;if(r[g]===void 0)continue;const B=v?v(r[g],r,h):r[g];B===void 0?delete c[S]:c[S]=B,i(g,S,B===void 0)}return c}function de(t){const o=new Set([...Y,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),r=h=>{for(const c of h??[])o.add(typeof c=="string"?c:c[0])},i=h=>{for(const c of h)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),i(c.parts??[]);break;case"core":c.keep!=="rest"&&c.keep.forEach(y=>o.add(y)),Object.keys(c.rename??{}).forEach(y=>o.add(y));for(const y of Object.values(c.slots??{}))for(const g of y)"kind"in g&&o.add(g.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 c=String(i.id??t.type),y=[],g=[],S=[],v=new Set,B=(n,s)=>{y.push({key:n,home:s}),v.add(n)},X=i._partStyles??{},L=de(o);let J=0;const w=(n,s)=>({type:n,props:{...s,id:`${c}~${n}-${++J}`}}),K=(n,s,b,u,x,l,$)=>{if(x){for(const a of n??[]){const p=typeof a=="string"?a:a[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,(a,p,f)=>$(a,f?`nothing — the old value draws nothing (${u}: no ${p})`:`${l}${u}: ${p}`),r)},M=n=>n.map(s=>{const b={...s.props??{}};for(const[u,x]of Object.entries(s.slots??{}))b[u]=M(x);return w(s.type,b)}),W=(n,s,b)=>{const u=Array.isArray(s[n.key])?s[n.key]:[],x=typeof n.props=="function"?n.props(i,r):n.props??{},l=u.map((f,d)=>{const k=f??{},m=n.item?.(k,d,i)??{},E=N(m.reverse?[...n.parts].reverse():n.parts,k,!1,`item ${d+1}: `);return n.flat?m.props?E.map(T=>({...T,props:{...T.props,...m.props,id:T.props.id}})):E:[w(_,{name:`${n.name} ${d+1}`,...x,...m.props??{},[P]:E})]});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),E=f.parts?N(f.parts,f.head?.(m,i)??{},!1,`group ${k+1}: `):[],T=d.items.map(O=>l[O.index]),z=f.perRow?.(m.length,i),I=Number.isInteger(z)&&z>=1?z:1,C=[];if(f.perRow&&I<T.length)for(let O=0;O*I<T.length;O++)C.push(T.slice(O*I,(O+1)*I).flat());return w(_,{name:`${f.name} ${k+1}`,...f.props??{},[P]:[...E,w(_,{name:`${f.itemsName} ${k+1}`,...f.itemsProps?.(m.length,i)??{},[P]:C.length?C.map((O,U)=>w(_,{name:`${f.rowName??`${f.itemsName} row`} ${U+1}`,...f.rowProps??{},[P]:O})):T.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 a=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(_,{name:`${n.rowName??`${n.name} row`} ${f+1}`,...a,[P]:[...d,...Array.from({length:k},(m,E)=>w(_,{name:`Empty ${E+1}`,...n.rowFiller,[P]:[]}))]}))}return p},N=(n,s,b,u)=>{const x=[],l=(e,a)=>b?B(e,a):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 a=F(s[e.key]);if(!a.text.trim()){l(e.key,"nothing — empty words draw nothing, so no block");break}const p=ce(e.role??"body"),{_partStyles:f,...d}=p,k=fe(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)}:{}})}x.push(w("Text",{text:e.mark==="accentLead"?ae(a.text):a.text,...d,...e.props??{},...k,...a.hidden?{_hidden:!0}:{}})),l(e.key,`${u}Text block: its words${a.hidden?", hidden":""}`);break}case"button":{const a=F(s[e.key]);if(!a.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)??{}};x.push(w("ButtonBlock",{label:a.text,href:p,...typeof e.props=="function"?e.props(s,r):e.props??{},...le(e.variant,s),...Object.keys(f).length?{_partStyles:{label:f}}:{},...a.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 a=s[e.key];if(typeof a!="string"||!a){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]:"";x.push(w("ImageBlock",{src:a,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":{x.push(...W(e,s,l));break}case"group":{const a=N(e.parts,s,b,u),p=K(e.box,e.props,s,`${e.name} Box`,!a.length&&!e.keepEmpty,u,l);p&&x.push(w(_,{name:e.name,...p,[P]:a}));break}case"block":{const a=e.parts?N(e.parts,s,b,u):[],p=K(e.box,e.props,s,`${e.type} block`,!!e.parts&&!a.length&&!e.keepEmpty,u,l);p&&x.push(w(e.type,{...p,...e.slot?{[e.slot]:a}:{}}));break}case"core":{const a=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 ${a} 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 ${a} block inside the Box has the row's own value`);s.headPlacement!==void 0&&l("headPlacement",`the ${a} 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 ${a} block inside the Box: ${k}`));for(const[d,k]of Object.entries(e.slots??{}))p[d]=k.flatMap(m=>"kind"in m?W(m,s,l):M([m]));x.push(w(a,p));break}}return x},Q=(n,s)=>{const b=s===0?"Box":`${n.name} Box`,u=N(n.parts,i,!0,s===0?"":`${b}: `),x=typeof n.boxProps=="function"?n.boxProps(i,r):n.boxProps??{},l=D(n.box??[],x,i,($,e,a)=>B($,a?`nothing — the old value draws nothing (${b}: no ${e})`:`${b}: ${e}`),r);return{type:_,props:{name:n.name,...l,[P]:u,id:ie(c,s)}}},G=[o,...o.also??[]].map(Q);i._partStyles!==void 0&&B("_partStyles","each old part's style moved to its new part");for(const[n,s]of Object.entries(o.reads??{}))i[n]!==void 0&&B(n,s);for(const[n,s]of Object.entries(o.drop??{}))n in i&&(g.push({key:n,why:s}),v.add(n));for(const n of Object.keys(i))Y.has(n)||v.has(n)||g.push({key:n,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:y,dropped:g,siteWrites:[...o.site?.(t,r)??[]],restyled:S}}function Pe(t,o=H,r={}){const i=t.content;if(!Array.isArray(i))return t;let h=!1;const c=i.flatMap(y=>{const g=y&&typeof y.type=="string"&&o.includes(y.type)?j[y.type]:void 0;if(!g)return[y];const S=q(y,g,r);return S.skipped!==void 0?[y]:(h=!0,S.nodes)});return h?{...t,content:c}:t}function je(t,o=H,r={}){if(!Array.isArray(t))return[];const i=[];return t.forEach((h,c)=>{const y=h&&typeof h.type=="string"&&o.includes(h.type)?j[h.type]:void 0;if(!y)return;const g=q(h,y,r);g.skipped===void 0&&i.push({index:c,node:g.node,nodes:g.nodes})}),i}export{P as SECTION_BOX_SLOT,_ as SECTION_BOX_TYPE,H as SECTION_TO_BOX_ON,we as boxNativeReason,q as convertSection,Pe as convertSectionsInPage,ge as convertTheme,Be as convertsToBox,_e as hasWords,Te as headParts,xe as registerBoxNativeSections,$e as registerSectionToBox,ie as sectionBoxIdOf,je as sectionToBoxEdits,Oe as sectionToBoxRow,Se 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{bucketByGroup as re}from"../../../format/lib/locations-grid.js";import{normalizeTheme as V}from"../../../format/lib/theme.js";const _=ee,P=te;function ge(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)",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[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 we(t){return A[t]}const Y=new Set(["id"]),j={},H=[];function $e(t){for(const[o,r]of Object.entries(t)){if(o in j&&j[o]!==r)throw new Error(`lib/sections/section-to-box: "${o}" already has a row`);j[o]=r}}function Oe(t){return j[t]}function Se(){return Object.keys(j)}function Be(t){return t in j&&H.includes(t)}function Te(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 F=t=>Z(t),_e=t=>F(t).text.trim()!=="";function ae(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 ce=t=>t==="heading"?oe():t==="eyebrow"?ne():{};function fe(t,o,r,i){const c={...t._partStyles?.text??{},...o??{},...r??{}};return(i==="center"||i==="right")&&c.align===void 0&&(c.align=i),Object.keys(c).length?{_partStyles:{text:c}}:{}}function le(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 c={...o};for(const y of t){const[g,S,v]=typeof y=="string"?[y,y,void 0]:y;if(r[g]===void 0)continue;const B=v?v(r[g],r,h):r[g];B===void 0?delete c[S]:c[S]=B,i(g,S,B===void 0)}return c}function de(t){const o=new Set([...Y,"headPlacement","_partStyles",...Object.keys(t.drop??{}),...Object.keys(t.reads??{})]),r=h=>{for(const c of h??[])o.add(typeof c=="string"?c:c[0])},i=h=>{for(const c of h)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),i(c.parts??[]);break;case"core":c.keep!=="rest"&&c.keep.forEach(y=>o.add(y)),Object.keys(c.rename??{}).forEach(y=>o.add(y));for(const y of Object.values(c.slots??{}))for(const g of y)"kind"in g&&o.add(g.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 c=String(i.id??t.type),y=[],g=[],S=[],v=new Set,B=(n,s)=>{y.push({key:n,home:s}),v.add(n)},X=i._partStyles??{},L=de(o);let J=0;const w=(n,s)=>({type:n,props:{...s,id:`${c}~${n}-${++J}`}}),K=(n,s,b,u,x,l,$)=>{if(x){for(const a of n??[]){const p=typeof a=="string"?a:a[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,(a,p,f)=>$(a,f?`nothing — the old value draws nothing (${u}: no ${p})`:`${l}${u}: ${p}`),r)},M=n=>n.map(s=>{const b={...s.props??{}};for(const[u,x]of Object.entries(s.slots??{}))b[u]=M(x);return w(s.type,b)}),W=(n,s,b)=>{const u=n.of?n.of(s):Array.isArray(s[n.key])?s[n.key]:[],x=typeof n.props=="function"?n.props(i,r):n.props??{},l=u.map((f,d)=>{const k=f??{},m=n.item?.(k,d,i)??{},E=N(m.reverse?[...n.parts].reverse():n.parts,k,!1,`item ${d+1}: `);return n.flat?m.props?E.map(T=>({...T,props:{...T.props,...m.props,id:T.props.id}})):E:[w(_,{name:`${n.name} ${d+1}`,...x,...m.props??{},[P]:E})]});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),E=f.parts?N(f.parts,f.head?.(m,i)??{},!1,`group ${k+1}: `):[],T=d.items.map(O=>l[O.index]),z=f.perRow?.(m.length,i),I=Number.isInteger(z)&&z>=1?z:1,C=[];if(f.perRow&&I<T.length)for(let O=0;O*I<T.length;O++)C.push(T.slice(O*I,(O+1)*I).flat());return w(_,{name:`${f.name} ${k+1}`,...f.props??{},[P]:[...E,w(_,{name:`${f.itemsName} ${k+1}`,...f.itemsProps?.(m.length,i)??{},[P]:C.length?C.map((O,U)=>w(_,{name:`${f.rowName??`${f.itemsName} row`} ${U+1}`,...f.rowProps??{},[P]:O})):T.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 a=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(_,{name:`${n.rowName??`${n.name} row`} ${f+1}`,...a,[P]:[...d,...Array.from({length:k},(m,E)=>w(_,{name:`Empty ${E+1}`,...n.rowFiller,[P]:[]}))]}))}return p},N=(n,s,b,u)=>{const x=[],l=(e,a)=>b?B(e,a):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 a=F(s[e.key]);if(!a.text.trim()){l(e.key,"nothing — empty words draw nothing, so no block");break}const p=ce(e.role??"body"),{_partStyles:f,...d}=p,k=fe(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)}:{}})}x.push(w("Text",{text:e.mark==="accentLead"?ae(a.text):a.text,...d,...e.props??{},...k,...a.hidden?{_hidden:!0}:{}})),l(e.key,`${u}Text block: its words${a.hidden?", hidden":""}`);break}case"button":{const a=F(s[e.key]);if(!a.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)??{}};x.push(w("ButtonBlock",{label:a.text,href:p,...typeof e.props=="function"?e.props(s,r):e.props??{},...le(e.variant,s),...Object.keys(f).length?{_partStyles:{label:f}}:{},...a.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 a=s[e.key];if(typeof a!="string"||!a){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]:"";x.push(w("ImageBlock",{src:a,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":{x.push(...W(e,s,l));break}case"group":{const a=N(e.parts,s,b,u),p=K(e.box,e.props,s,`${e.name} Box`,!a.length&&!e.keepEmpty,u,l);p&&x.push(w(_,{name:e.name,...p,[P]:a}));break}case"block":{const a=e.parts?N(e.parts,s,b,u):[],p=K(e.box,e.props,s,`${e.type} block`,!!e.parts&&!a.length&&!e.keepEmpty,u,l);p&&x.push(w(e.type,{...p,...e.slot?{[e.slot]:a}:{}}));break}case"core":{const a=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 ${a} 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 ${a} block inside the Box has the row's own value`);s.headPlacement!==void 0&&l("headPlacement",`the ${a} 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 ${a} block inside the Box: ${k}`));for(const[d,k]of Object.entries(e.slots??{}))p[d]=k.flatMap(m=>"kind"in m?W(m,s,l):M([m]));x.push(w(a,p));break}}return x},Q=(n,s)=>{const b=s===0?"Box":`${n.name} Box`,u=N(n.parts,i,!0,s===0?"":`${b}: `),x=typeof n.boxProps=="function"?n.boxProps(i,r):n.boxProps??{},l=D(n.box??[],x,i,($,e,a)=>B($,a?`nothing — the old value draws nothing (${b}: no ${e})`:`${b}: ${e}`),r);return{type:_,props:{name:n.name,...l,[P]:u,id:ie(c,s)}}},G=[o,...o.also??[]].map(Q);i._partStyles!==void 0&&B("_partStyles","each old part's style moved to its new part");for(const[n,s]of Object.entries(o.reads??{}))i[n]!==void 0&&B(n,s);for(const[n,s]of Object.entries(o.drop??{}))n in i&&(g.push({key:n,why:s}),v.add(n));for(const n of Object.keys(i))Y.has(n)||v.has(n)||g.push({key:n,why:"not in the row — not carried"});return{node:G[0],nodes:G,carried:y,dropped:g,siteWrites:[...o.site?.(t,r)??[]],restyled:S}}function Pe(t,o=H,r={}){const i=t.content;if(!Array.isArray(i))return t;let h=!1;const c=i.flatMap(y=>{const g=y&&typeof y.type=="string"&&o.includes(y.type)?j[y.type]:void 0;if(!g)return[y];const S=q(y,g,r);return S.skipped!==void 0?[y]:(h=!0,S.nodes)});return h?{...t,content:c}:t}function je(t,o=H,r={}){if(!Array.isArray(t))return[];const i=[];return t.forEach((h,c)=>{const y=h&&typeof h.type=="string"&&o.includes(h.type)?j[h.type]:void 0;if(!y)return;const g=q(h,y,r);g.skipped===void 0&&i.push({index:c,node:g.node,nodes:g.nodes})}),i}export{P as SECTION_BOX_SLOT,_ as SECTION_BOX_TYPE,H as SECTION_TO_BOX_ON,we as boxNativeReason,q as convertSection,Pe as convertSectionsInPage,ge as convertTheme,Be as convertsToBox,_e as hasWords,Te as headParts,xe as registerBoxNativeSections,$e as registerSectionToBox,ie as sectionBoxIdOf,je as sectionToBoxEdits,Oe as sectionToBoxRow,Se as sectionToBoxTypes};
@@ -1,5 +1,6 @@
1
- import { type TextStyle, type TextStyleCase } from "efficient-easel/text-styles/model";
1
+ import { type TextStyle, type TextStyleCase, type TextStyleDevice } from "efficient-easel/text-styles/model";
2
2
  import { type FontRole, type FontsValue } from "../../../format/lib/fonts.js";
3
+ import { viewRules } from "../content/view-values.js";
3
4
  import { type PartStyle } from "../document/part-styles.js";
4
5
  import { faceClassOf } from "../../../format/lib/text-style-face.js";
5
6
  export { faceClassOf };
@@ -17,6 +18,15 @@ export type StoredTextStyleValues = {
17
18
  letterCase?: TextStyleCase;
18
19
  largestSize?: number;
19
20
  sizePhone?: number;
21
+ sizeTablet?: number;
22
+ lineHeightTablet?: number;
23
+ lineHeightPhone?: number;
24
+ letterSpacingTablet?: number;
25
+ letterSpacingPhone?: number;
26
+ paragraphSpacingTablet?: number;
27
+ paragraphSpacingPhone?: number;
28
+ largestSizeTablet?: number;
29
+ largestSizePhone?: number;
20
30
  };
21
31
  export type StoredTextStyle = {
22
32
  id: string;
@@ -31,16 +41,18 @@ export type OldSiteText = {
31
41
  compression: string;
32
42
  typography: Partial<ResolvedHeadingTypography> | Record<string, unknown>;
33
43
  };
44
+ export declare function viewSizeOf(values: StoredTextStyleValues, desktopPx: number, view: TextStyleDevice, rules?: ReturnType<typeof viewRules>): number;
34
45
  export declare function textStylesFromOld(old: OldSiteText): StoredTextStyle[];
35
46
  export declare function storedTextStyles(value: unknown): StoredTextStyle[];
36
47
  export declare function listToWrite(saved: unknown): StoredTextStyle[];
37
48
  export declare function resolveTextStyles(saved: unknown, old: OldSiteText): StoredTextStyle[];
38
- export declare function applyListChange({ saved, old, cur, next, sizeOf, }: {
49
+ export declare function applyListChange({ saved, old, cur, next, sizeOf, panelView, }: {
39
50
  saved: unknown;
40
51
  old: OldSiteText;
41
52
  cur: readonly TextStyle[];
42
53
  next: readonly TextStyle[];
43
54
  sizeOf: (style: StoredTextStyle) => number;
55
+ panelView?: TextStyleDevice;
44
56
  }): {
45
57
  saved: StoredTextStyle[];
46
58
  old: OldSiteText;
@@ -49,8 +61,8 @@ export declare function listChangePatch(next: {
49
61
  saved: StoredTextStyle[];
50
62
  old: OldSiteText;
51
63
  }, prev: OldSiteText): SiteThemeRowPatch;
52
- export declare function toPanelStyles(stored: readonly StoredTextStyle[], sizeOf: (s: StoredTextStyle) => number): TextStyle[];
53
- export declare function fromPanelStyles(list: readonly TextStyle[], sizeOf: (s: StoredTextStyle) => number): StoredTextStyle[];
64
+ export declare function toPanelStyles(stored: readonly StoredTextStyle[], sizeOf: (s: StoredTextStyle) => number, device?: TextStyleDevice): TextStyle[];
65
+ export declare function fromPanelStyles(list: readonly TextStyle[], sizeOf: (s: StoredTextStyle) => number, device?: TextStyleDevice): StoredTextStyle[];
54
66
  export type SiteTextSeed = {
55
67
  fonts: FontsValue;
56
68
  sizes: SizesValue;
@@ -1,2 +1,2 @@
1
- import{defaultTextStyles as A,textStyleCaseCss as Y}from"efficient-easel/text-styles/model";import{parseHexColor as G}from"efficient-shell/format";import{FONT_OPTIONS as U,normalizeFonts as I}from"../../../format/lib/fonts.js";import{PHONE_MEDIA as X}from"../content/view-values.js";import{STYLE_ID_OF_ROLE as Z,TEXT_STYLE_ATTR as q,paragraphRules as B,partSpacingOf as K}from"../document/part-styles.js";import{faceClassOf as L}from"../../../format/lib/text-style-face.js";import{compressionMetrics as Q,headingTypographyFromRow as ee,normalizeHeadingCompression as k,normalizeSizes as j}from"../../../format/lib/theme.js";import{finiteNumber as m}from"../../../format/lib/finite-number.js";import{nonEmptyString as _}from"../../../format/lib/non-empty-string.js";const H=e=>e==="sentence"?"none":void 0,F=["font","color","size","sizePhone","weight","italic","lineHeight","letterSpacing","paragraphSpacing","letterCase","largestSize"];function g(e){const i={};for(const n of F)e[n]!==void 0&&(i[n]=e[n]);return i}function T(e,i){const{auto:n,...t}=e,o=new Set(i??[]),r=F.filter(a=>o.has(a)&&e.values[a]===void 0);return r.length?{...t,auto:r}:t}function M(e){const i=e.fonts,n=e.sizes,t=e.typography,o=Q(e.compression),r={"heading-1":{font:_(i.heading),size:m(n.headingLarge),weight:m(t.weight),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:H(t.case),largestSize:m(t.maxPx)},"heading-2":{font:_(i.heading2),size:m(n.headingMedium),weight:m(t.weight2),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:H(t.case2)},"heading-3":{font:_(i.heading3),size:m(n.headingSmall),weight:m(t.weight3),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:H(t.case3)},"body-1":{font:_(i.body),size:m(n.body)},"body-5":{font:_(i.label),size:m(n.label)}};return A().map(({id:a,kind:l,name:d})=>({id:a,kind:l,name:d,values:g(r[a]??{})}))}function C(e){return Array.isArray(e)&&e.every(n=>n&&typeof n=="object"&&typeof n.id=="string"&&(n.kind==="heading"||n.kind==="body")&&typeof n.name=="string")?e.map(n=>T({...n,values:g(n.values??{})},Array.isArray(n.auto)?n.auto:void 0)):null}function he(e){return C(e)??[]}function R(e){return C(e)??A().map(({id:i,kind:n,name:t})=>({id:i,kind:n,name:t,values:{}}))}function O(e,i){const n=M(i),t=C(e);return t?t.map(o=>{const r={...w(n,o.id)};for(const a of o.auto??[])delete r[a];return{...o,values:g({...r,...o.values})}}):n}const w=(e,i)=>e.find(n=>n.id===i)?.values??{},V=["heading-1","heading-2","heading-3"];function me({saved:e,old:i,cur:n,next:t,sizeOf:o}){const r=M(i),a=R(e),l=O(a,i),d=[],S=t.map(s=>{const c=n.find(f=>f.id===s.id),x=a.find(f=>f.id===s.id);if(!c||!x)return ne([s],o)[0];const u={...x.values},z=new Set(x.auto??[]),v=s.values,E=c.values,N=[...new Set([...Object.keys(v),...Object.keys(E)])].filter(f=>JSON.stringify(v[f])!==JSON.stringify(E[f]));N.sort((f,y)=>+(f==="letterSpacing")-+(y==="letterSpacing"));for(const f of N){const y=f==="lineSpacing"?"lineHeight":f,$=v[f];if($===void 0){delete u[y],w(r,s.id)[y]!==void 0&&(d.push([s.id,y]),z.add(y));continue}if(z.delete(y),f==="lineSpacing")u.lineHeight=b($/100,3);else if(f==="letterSpacing"){const J=l.find(W=>W.id===s.id),P=o({...s,values:g({...J?.values??{},...u})});u.letterSpacing=P?b($/P,4):0}else u[y]=$}return T({id:s.id,kind:s.kind,name:s.name,values:g(u)},z)});let p=i.compression;if(d.some(([s,c])=>(c==="lineHeight"||c==="letterSpacing")&&V.includes(s))&&k(p)!=="normal"){for(const s of V){const c=S.find(u=>u.id===s);if(!c)continue;const x={...c.values};for(const u of["lineHeight","letterSpacing"])d.some(([z,v])=>z===s&&v===u)||x[u]===void 0&&!(c.auto??[]).includes(u)&&(x[u]=w(r,s)[u]);c.values=g(x)}p="normal"}return{saved:S,old:{...i,compression:p}}}function ye(e,i){const n={text_styles:e.saved};return e.old.compression!==i.compression&&(n.heading_compression=k(e.old.compression)),n}const b=(e,i)=>Number(e.toFixed(i));function Se(e,i){return e.map(n=>{const{lineHeight:t,letterSpacing:o,...r}=n.values,a={...r};return t!==void 0&&(a.lineSpacing=b(t*100,1)),o!==void 0&&(a.letterSpacing=b(o*i(n),2)),{id:n.id,kind:n.kind,name:n.name,values:a}})}function ne(e,i){return e.map(n=>{const{lineSpacing:t,letterSpacing:o,...r}=n.values,a={id:n.id,kind:n.kind,name:n.name,values:g({...r})},l={...a.values};if(t!==void 0&&(l.lineHeight=b(t/100,3)),o!==void 0){const d=i({...a,values:{...a.values}});l.letterSpacing=d?b(o/d,4):0}return{...a,values:g(l)}})}function xe(e){const i={fonts:I({heading:e.heading_font??void 0,heading2:e.heading_2_font??void 0,heading3:e.heading_3_font??void 0,body:e.body_font??void 0,accent:e.accent_font??void 0,label:e.label_font??void 0}),sizes:j({headingLarge:e.heading_size_large_px,headingMedium:e.heading_size_medium_px,headingSmall:e.heading_size_small_px,accent:e.accent_size_px,body:e.body_size_px,label:e.label_size_px}),compression:k(e.heading_compression),typography:ee(e)},n=e.text_styles??null,t=Array.isArray(n)?D(O(n,i),i):i;return{fonts:I(t.fonts),sizes:j(t.sizes),compression:k(t.compression),typography:t.typography,textStyles:n}}function D(e,i){const n=s=>e.find(c=>c.id===s)?.values??{},t=n("heading-1"),o=n("heading-2"),r=n("heading-3"),a=n("body-1"),l=n("body-5"),d=i.fonts,S=i.sizes,p=i.typography,h=s=>s==="none"?"sentence":"authored";return{fonts:{...d,heading:t.font??d.heading,heading2:o.font??t.font??d.heading2,heading3:r.font??t.font??d.heading3,body:a.font??d.body,label:l.font??d.label},sizes:{...S,headingLarge:t.size??null,headingMedium:o.size??null,headingSmall:r.size??null,body:a.size??null,label:l.size??null},compression:i.compression,typography:{...p,case:h(t.letterCase),weight:t.weight??null,maxPx:t.largestSize??null,weight2:o.weight??null,weight3:r.weight??null,case2:h(o.letterCase),case3:h(r.letterCase)}}}function be(e){const i=C(e.textStyles);if(!i||i.every(o=>Object.keys(o.values).length===0&&!o.auto))return e;const n={fonts:e.fonts??{},sizes:e.sizes??{},compression:String(e.headingCompression??"normal"),typography:e.headingTypography??{}},t=D(O(i,n),n);return{...e,fonts:t.fonts,sizes:t.sizes,headingCompression:t.compression,headingTypography:t.typography}}function te(e){return e==="accent"?"var(--accent)":e==="text"?"var(--fg)":e==="labels"?"var(--fg-dim)":G(e)===e.toLowerCase()?e:null}function ze(e){const i=[];for(const n of e){const t=n.values,o=`.${L(n)}`,r=`[${q}="${n.id}"]`,a=`${o}, ${r}`,l=[],d=t.font!==void 0?U.find(s=>s.key===t.font)?.cssVar:void 0;if(d&&l.push(`font-family: var(${d})`),t.size!==void 0){const s=t.largestSize!==void 0?Math.min(t.size,t.largestSize):t.size;l.push(`font-size: ${s}px`)}const S=t.color!==void 0?te(t.color):null;S&&l.push(`color: ${S}`),t.italic===!0&&l.push("font-style: italic"),t.weight!==void 0&&l.push(`font-weight: ${t.weight}`);const p=[];t.lineHeight!==void 0&&p.push(`line-height: ${t.lineHeight}`),t.letterSpacing!==void 0&&p.push(`letter-spacing: ${t.letterSpacing}em`),n.kind==="body"&&l.push(...p);const h=Y(t.letterCase);if(h&&n.kind==="body"&&l.push(`text-transform: ${h}`),t.paragraphSpacing&&l.push(`--sf-part-para: ${t.paragraphSpacing}px`),l.length&&i.push(`${a} { ${l.join("; ")} }`),n.kind==="heading"&&p.length&&i.push(`${a}, ${o}:is(h1, h2, h3, h4), ${r}:is(h1, h2, h3, h4) { ${p.join("; ")} }`),n.kind==="heading"&&h&&i.push(`${r}, ${o}:is(h1, h2, h3, h4) { text-transform: ${h} }`),t.paragraphSpacing&&(i.push(`*:has(> ${r}) { --sf-part-para: ${t.paragraphSpacing}px }`),i.push(...B(`:is(${a})`,`*:has(> ${r})`))),t.sizePhone!==void 0){const s=ie[n.id],c=[`${a} { font-size: ${t.sizePhone}px }`];s&&c.push(`.sf-themed-content { --size-${s}: ${t.sizePhone}px !important }`),i.push(`@media ${X} { ${c.join(" ")} }`)}}return i.join(`
2
- `)}const ie={"heading-1":"headingLarge","heading-2":"headingMedium","heading-3":"headingSmall","body-1":"body","body-5":"label"};function ve(e){return e!==!0&&e!==!1?"":`em.text-accent { font-style: ${e?"italic":"normal"} }`}function _e(e){return e?Z[e]:void 0}function oe(e){const i=K(e);return g({font:e.font,color:e.color,size:e.size,weight:e.weight,italic:e.italic,lineHeight:i.lineHeight,letterSpacing:i.letterSpacingEm,paragraphSpacing:e.paragraphSpacing,letterCase:e.case})}function $e(e){return Object.keys(oe(e)).length>0}function ke({saved:e,old:i,styleId:n,values:t}){const o=R(e);return{saved:se(o,n,t),old:i}}function se(e,i,n){return e.map(t=>t.id===i?T({...t,values:g({...t.values,...n})},t.auto):t)}function Ce(e){const i=e.filter(n=>n.kind==="body").map(n=>Number(/^body-(\d+)$/.exec(n.id)?.[1])).filter(n=>Number.isInteger(n)&&n>0);return i.length?`body-${Math.max(...i)}`:"body-1"}export{ve as accentItalicCss,me as applyListChange,Ce as eyebrowStyleId,L as faceClassOf,ne as fromPanelStyles,$e as hasStyleChange,ye as listChangePatch,R as listToWrite,oe as partStyleToTextStyleValues,ke as pushIntoStyle,O as resolveTextStyles,se as setStyleValues,xe as siteTextFromRow,he as storedTextStyles,_e as styleIdOfRole,ze as textStylesCss,M as textStylesFromOld,D as textStylesToOld,be as themeWithTextStyles,Se as toPanelStyles};
1
+ import{defaultTextStyles as Y,textStyleCaseCss as re,textStyleViewKey as le}from"efficient-easel/text-styles/model";import{phoneKey as ce,resolveViewValue as B,tabletKey as de}from"efficient-easel/draw";import{parseHexColor as pe}from"efficient-shell/format";import{FONT_OPTIONS as fe,normalizeFonts as U}from"../../../format/lib/fonts.js";import{PHONE_MEDIA as ue,TABLET_MEDIA as ge,viewOverrides as H,viewRules as X}from"../content/view-values.js";import{STYLE_ID_OF_ROLE as he,TEXT_STYLE_ATTR as me,paragraphRules as Z,partSpacingOf as Se}from"../document/part-styles.js";import{faceClassOf as q}from"../../../format/lib/text-style-face.js";import{compressionMetrics as ye,headingTypographyFromRow as be,normalizeHeadingCompression as E,normalizeSizes as Q}from"../../../format/lib/theme.js";import{finiteNumber as v}from"../../../format/lib/finite-number.js";import{nonEmptyString as O}from"../../../format/lib/non-empty-string.js";const N=e=>e==="sentence"?"none":void 0,ee=["font","color","size","sizeTablet","sizePhone","weight","italic","lineHeight","lineHeightTablet","lineHeightPhone","letterSpacing","letterSpacingTablet","letterSpacingPhone","paragraphSpacing","paragraphSpacingTablet","paragraphSpacingPhone","letterCase","largestSize","largestSizeTablet","largestSizePhone"],T=["desktop","tablet","phone"],C=(e,t)=>t==="desktop"?e:t==="tablet"?de(e):ce(e),k=(e,t)=>t==="desktop"?e:le(e,t);function j(e,t,i,n=X()){return B("textSize",t,e.sizeTablet,e.sizePhone,n)[i]}const xe=[["lineSpacing","lineHeight","line"],["letterSpacing","letterSpacing","letter"]];function V(e){for(const[t,i,n]of xe)for(const o of T)if(e===k(t,o))return{key:C(i,o),view:o,spacing:n};return{key:e,view:"desktop",spacing:null}}function b(e){const t={};for(const i of ee)e[i]!==void 0&&(t[i]=e[i]);return t}function M(e,t){const{auto:i,...n}=e,o=new Set(t??[]),r=ee.filter(s=>o.has(s)&&e.values[s]===void 0);return r.length?{...n,auto:r}:n}function ne(e){const t=e.fonts,i=e.sizes,n=e.typography,o=ye(e.compression),r={"heading-1":{font:O(t.heading),size:v(i.headingLarge),weight:v(n.weight),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:N(n.case),largestSize:v(n.maxPx)},"heading-2":{font:O(t.heading2),size:v(i.headingMedium),weight:v(n.weight2),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:N(n.case2)},"heading-3":{font:O(t.heading3),size:v(i.headingSmall),weight:v(n.weight3),lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,letterCase:N(n.case3)},"body-1":{font:O(t.body),size:v(i.body)},"body-5":{font:O(t.label),size:v(i.label)}};return Y().map(({id:s,kind:l,name:d})=>({id:s,kind:l,name:d,values:b(r[s]??{})}))}function I(e){return Array.isArray(e)&&e.every(i=>i&&typeof i=="object"&&typeof i.id=="string"&&(i.kind==="heading"||i.kind==="body")&&typeof i.name=="string")?e.map(i=>M({...i,values:b(i.values??{})},Array.isArray(i.auto)?i.auto:void 0)):null}function je(e){return I(e)??[]}function te(e){return I(e)??Y().map(({id:t,kind:i,name:n})=>({id:t,kind:i,name:n,values:{}}))}function R(e,t){const i=ne(t),n=I(e);return n?n.map(o=>{const r={...F(i,o.id)};for(const s of o.auto??[])delete r[s];return{...o,values:b({...r,...o.values})}}):i}const F=(e,t)=>e.find(i=>i.id===t)?.values??{},ie=["heading-1","heading-2","heading-3"];function Ve({saved:e,old:t,cur:i,next:n,sizeOf:o,panelView:r="desktop"}){const s=ne(t),l=te(e),d=R(l,t),c=[],f=n.map(a=>{const S=i.find(m=>m.id===a.id),g=l.find(m=>m.id===a.id);if(!S||!g)return ze([a],o,r)[0];const p={...g.values},x=new Set(g.auto??[]),y=a.values,_=S.values,z=[...new Set([...Object.keys(y),...Object.keys(_)])].filter(m=>JSON.stringify(y[m])!==JSON.stringify(_[m])),D=m=>V(m).spacing==="letter";z.sort((m,L)=>Number(D(m))-Number(D(L)));for(const m of z){const{key:L,view:ae,spacing:K}=V(m),$=L,P=y[m];if(P===void 0){delete p[$],F(s,a.id)[$]!==void 0&&(c.push([a.id,$]),x.add($));continue}if(x.delete($),K==="line")p[$]=w(P/100,3);else if(K==="letter"){const W={...d.find(A=>A.id===a.id)?.values??{}};for(const A of z)y[A]===void 0&&delete W[V(A).key];const G=b({...W,...p}),J=j(G,o({...a,values:G}),ae);p[$]=J?w(P/J,4):0}else p[$]=P}return M({id:a.id,kind:a.kind,name:a.name,values:b(p)},x)});let u=t.compression;if(c.some(([a,S])=>(S==="lineHeight"||S==="letterSpacing")&&ie.includes(a))&&E(u)!=="normal"){for(const a of ie){const S=f.find(p=>p.id===a);if(!S)continue;const g={...S.values};for(const p of["lineHeight","letterSpacing"])c.some(([x,y])=>x===a&&y===p)||g[p]===void 0&&!(S.auto??[]).includes(p)&&(g[p]=F(s,a)[p]);S.values=b(g)}u="normal"}return{saved:f,old:{...t,compression:u}}}function Me(e,t){const i={text_styles:e.saved};return e.old.compression!==t.compression&&(i.heading_compression=E(e.old.compression)),i}const w=(e,t)=>Number(e.toFixed(t)),oe=(e,t)=>T.indexOf(e)<T.indexOf(t)?t:e;function Re(e,t,i="desktop"){return e.map(n=>{const o={...n.values},r=t(n);for(const s of T){const l=C("lineHeight",s),d=n.values[l],c=n.values[C("letterSpacing",s)];delete o[l],d!==void 0&&(o[k("lineSpacing",s)]=w(d*100,1));const f=oe(s,i);c!==void 0&&(o[k("letterSpacing",s)]=w(c*j(n.values,r,f),f===s?2:4))}return{id:n.id,kind:n.kind,name:n.name,values:o}})}function ze(e,t,i="desktop"){return e.map(n=>{const o=n.values,r={...o};for(const c of T)delete r[k("lineSpacing",c)],delete r[k("letterSpacing",c)];const s={id:n.id,kind:n.kind,name:n.name,values:b(r)},l={...s.values},d=t({...s,values:{...s.values}});for(const c of T){const f=o[k("lineSpacing",c)],u=o[k("letterSpacing",c)];if(typeof f=="number"&&(l[C("lineHeight",c)]=w(f/100,3)),typeof u=="number"){const h=j(s.values,d,oe(c,i));l[C("letterSpacing",c)]=h?w(u/h,4):0}}return{...s,values:b(l)}})}function Fe(e){const t={fonts:U({heading:e.heading_font??void 0,heading2:e.heading_2_font??void 0,heading3:e.heading_3_font??void 0,body:e.body_font??void 0,accent:e.accent_font??void 0,label:e.label_font??void 0}),sizes:Q({headingLarge:e.heading_size_large_px,headingMedium:e.heading_size_medium_px,headingSmall:e.heading_size_small_px,accent:e.accent_size_px,body:e.body_size_px,label:e.label_size_px}),compression:E(e.heading_compression),typography:be(e)},i=e.text_styles??null,n=Array.isArray(i)?se(R(i,t),t):t;return{fonts:U(n.fonts),sizes:Q(n.sizes),compression:E(n.compression),typography:n.typography,textStyles:i}}function se(e,t){const i=h=>e.find(a=>a.id===h)?.values??{},n=i("heading-1"),o=i("heading-2"),r=i("heading-3"),s=i("body-1"),l=i("body-5"),d=t.fonts,c=t.sizes,f=t.typography,u=h=>h==="none"?"sentence":"authored";return{fonts:{...d,heading:n.font??d.heading,heading2:o.font??n.font??d.heading2,heading3:r.font??n.font??d.heading3,body:s.font??d.body,label:l.font??d.label},sizes:{...c,headingLarge:n.size??null,headingMedium:o.size??null,headingSmall:r.size??null,body:s.size??null,label:l.size??null},compression:t.compression,typography:{...f,case:u(n.letterCase),weight:n.weight??null,maxPx:n.largestSize??null,weight2:o.weight??null,weight3:r.weight??null,case2:u(o.letterCase),case3:u(r.letterCase)}}}function De(e){const t=I(e.textStyles);if(!t||t.every(o=>Object.keys(o.values).length===0&&!o.auto))return e;const i={fonts:e.fonts??{},sizes:e.sizes??{},compression:String(e.headingCompression??"normal"),typography:e.headingTypography??{}},n=se(R(t,i),i);return{...e,fonts:n.fonts,sizes:n.sizes,headingCompression:n.compression,headingTypography:n.typography}}function ve(e){return e==="accent"?"var(--accent)":e==="text"?"var(--fg)":e==="labels"?"var(--fg-dim)":pe(e)===e.toLowerCase()?e:null}function Ke(e){const t=[];for(const i of e){const n=i.values,o=`.${q(i)}`,r=`[${me}="${i.id}"]`,s=`${o}, ${r}`,l=[],d=n.font!==void 0?fe.find(h=>h.key===n.font)?.cssVar:void 0;if(d&&l.push(`font-family: var(${d})`),n.size!==void 0){const h=n.largestSize!==void 0?Math.min(n.size,n.largestSize):n.size;l.push(`font-size: ${h}px`)}const c=n.color!==void 0?ve(n.color):null;c&&l.push(`color: ${c}`),n.italic===!0&&l.push("font-style: italic"),n.weight!==void 0&&l.push(`font-weight: ${n.weight}`);const f=[];n.lineHeight!==void 0&&f.push(`line-height: ${n.lineHeight}`),n.letterSpacing!==void 0&&f.push(`letter-spacing: ${n.letterSpacing}em`),i.kind==="body"&&l.push(...f);const u=re(n.letterCase);u&&i.kind==="body"&&l.push(`text-transform: ${u}`),n.paragraphSpacing&&l.push(`--sf-part-para: ${n.paragraphSpacing}px`),l.length&&t.push(`${s} { ${l.join("; ")} }`),i.kind==="heading"&&f.length&&t.push(`${s}, ${o}:is(h1, h2, h3, h4), ${r}:is(h1, h2, h3, h4) { ${f.join("; ")} }`),i.kind==="heading"&&u&&t.push(`${r}, ${o}:is(h1, h2, h3, h4) { text-transform: ${u} }`),n.paragraphSpacing&&(t.push(`*:has(> ${r}) { --sf-part-para: ${n.paragraphSpacing}px }`),t.push(...Z(`:is(${s})`,`*:has(> ${r})`))),t.push(...$e(i,s,o,r))}return t.join(`
2
+ `)}function $e(e,t,i,n){const o=e.values,r=H("textSize",o.size,o.sizeTablet,o.sizePhone),s=H("textSize",o.largestSize,o.largestSizeTablet,o.largestSizePhone),l=H("same",o.lineHeight,o.lineHeightTablet,o.lineHeightPhone),d=H("same",o.letterSpacing,o.letterSpacingTablet,o.letterSpacingPhone),c=H("spacing",o.paragraphSpacing,o.paragraphSpacingTablet,o.paragraphSpacingPhone),f=B("textSize",o.size,o.sizeTablet,o.sizePhone,X()),u=_e[e.id],h=[];for(const[a,S]of[["tablet",ge],["phone",ue]]){const g=[],p=[],x=f[a],y=s[a],_=r[a]===void 0&&y===void 0||x===void 0?void 0:y===void 0?x:Math.min(x,y);_!==void 0&&p.push(`font-size: ${_}px`);const z=[];l[a]!==void 0&&z.push(`line-height: ${l[a]}`),d[a]!==void 0&&z.push(`letter-spacing: ${d[a]}em`),e.kind==="body"&&p.push(...z),c[a]!==void 0&&p.push(`--sf-part-para: ${c[a]}px`),p.length&&g.push(`${t} { ${p.join("; ")} }`),e.kind==="heading"&&z.length&&g.push(`${t}, ${i}:is(h1, h2, h3, h4), ${n}:is(h1, h2, h3, h4) { ${z.join("; ")} }`),c[a]!==void 0&&g.push(`*:has(> ${n}) { --sf-part-para: ${c[a]}px }`),c[a]!==void 0&&!o.paragraphSpacing&&g.push(...Z(`:is(${t})`,`*:has(> ${n})`)),_!==void 0&&u&&g.push(`.sf-themed-content { --size-${u}: ${_}px !important }`),g.length&&h.push(`@media ${S} { ${g.join(" ")} }`)}return h}const _e={"heading-1":"headingLarge","heading-2":"headingMedium","heading-3":"headingSmall","body-1":"body","body-5":"label"};function We(e){return e!==!0&&e!==!1?"":`em.text-accent { font-style: ${e?"italic":"normal"} }`}function Ge(e){return e?he[e]:void 0}function ke(e){const t=Se(e);return b({font:e.font,color:e.color,size:e.size,weight:e.weight,italic:e.italic,lineHeight:t.lineHeight,letterSpacing:t.letterSpacingEm,paragraphSpacing:e.paragraphSpacing,letterCase:e.case})}function Je(e){return Object.keys(ke(e)).length>0}function Ye({saved:e,old:t,styleId:i,values:n}){const o=te(e);return{saved:Te(o,i,n),old:t}}function Te(e,t,i){return e.map(n=>n.id===t?M({...n,values:b({...n.values,...i})},n.auto):n)}function Be(e){const t=e.filter(i=>i.kind==="body").map(i=>Number(/^body-(\d+)$/.exec(i.id)?.[1])).filter(i=>Number.isInteger(i)&&i>0);return t.length?`body-${Math.max(...t)}`:"body-1"}export{We as accentItalicCss,Ve as applyListChange,Be as eyebrowStyleId,q as faceClassOf,ze as fromPanelStyles,Je as hasStyleChange,Me as listChangePatch,te as listToWrite,ke as partStyleToTextStyleValues,Ye as pushIntoStyle,R as resolveTextStyles,Te as setStyleValues,Fe as siteTextFromRow,je as storedTextStyles,Ge as styleIdOfRole,Ke as textStylesCss,ne as textStylesFromOld,se as textStylesToOld,De as themeWithTextStyles,Re as toPanelStyles,j as viewSizeOf};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-web-builder",
3
- "version": "47.2.0",
3
+ "version": "48.1.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": "^26.7.0",
56
+ "efficient-easel": "^27.0.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": "^26.12.0",
75
+ "efficient-easel": "^27.0.0",
76
76
  "efficient-shell": "^11.8.0",
77
77
  "esbuild": "^0.28.0",
78
78
  "happy-dom": "^20.14.5",
@@ -1,2 +0,0 @@
1
- import { useSelectedFields } from "efficient-easel/easel";
2
- export declare function useSelectedHost(): ReturnType<typeof useSelectedFields> | null;
@@ -1 +0,0 @@
1
- import{useSelectedFields as e}from"efficient-easel/easel";function r(){try{return e()}catch{return null}}export{r as useSelectedHost};