efficient-web-builder 74.6.0 → 74.8.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 +53 -0
- package/dist/editor/components/AddPageWindow.js +1 -1
- package/dist/editor/components/CustomHtmlCodeWindow.js +3 -3
- package/dist/editor/components/DuplicateToPageMenu.js +1 -1
- package/dist/editor/components/PageStarterCard.js +1 -1
- package/dist/editor/components/PagesPanel.js +1 -1
- package/dist/editor/components/PartSettingsPanel.js +1 -1
- package/dist/editor/components/PreviewPartAnchors.d.ts +2 -2
- package/dist/editor/components/PreviewPartAnchors.js +1 -1
- package/dist/editor/components/SectionTextPartBridge.js +1 -1
- package/dist/editor/components/SiteAccentField.js +1 -1
- package/dist/editor/components/SiteTextStylesField.d.ts +2 -0
- package/dist/editor/components/SiteTextStylesField.js +1 -1
- package/dist/editor/components/StandaloneSectionEditor.js +1 -1
- package/dist/editor/components/StorefrontEditor.js +1 -1
- package/dist/editor/components/WebsiteScreenParts.js +1 -1
- package/dist/editor/components/storefront-editor.css +45 -8
- package/dist/editor/components/useSocialSettings.d.ts +2 -2
- package/dist/editor/lib/content/section-one-padding.d.ts +31 -0
- package/dist/editor/lib/content/section-one-padding.js +1 -0
- package/dist/editor/lib/document/blocks/general/index.d.ts +2 -2
- package/dist/editor/lib/document/box-fields.d.ts +1 -1
- package/dist/editor/lib/document/page-root.js +2 -2
- package/dist/format/lib/content/box-shape.d.ts +1 -1
- package/dist/format/lib/content/box-side-space.d.ts +6 -2
- package/dist/format/lib/content/box-side-space.js +1 -1
- package/dist/format/lib/content/page-width.d.ts +10 -1
- package/dist/format/lib/content/page-width.js +1 -1
- package/dist/format/lib/content/view-lines.d.ts +1 -0
- package/dist/format/lib/content/view-lines.js +1 -1
- package/dist/format/lib/document/blocks/block-types.d.ts +2 -0
- package/dist/format/lib/document/passes/types.d.ts +2 -0
- package/dist/format/lib/document/style-text.d.ts +2 -0
- package/dist/format/lib/document/style-text.js +1 -1
- package/dist/format/lib/editor-words-catalogue.d.ts +1 -0
- package/dist/format/lib/editor-words-catalogue.js +1 -1
- package/dist/format/lib/editor-words-kept.js +1 -1
- package/dist/format/lib/fonts.d.ts +43 -7
- package/dist/format/lib/fonts.js +1 -1
- package/dist/format/lib/frame-viewport.d.ts +3 -0
- package/dist/format/lib/frame-viewport.js +1 -0
- package/dist/format/lib/page-starters.d.ts +2 -0
- package/dist/format/lib/page-starters.js +1 -1
- package/dist/format/lib/site-font-faces.d.ts +9 -0
- package/dist/format/lib/site-font-faces.js +2 -0
- package/dist/format/lib/site-theme-row.d.ts +29 -1
- package/dist/format/lib/site-theme-row.js +1 -0
- package/dist/format/lib/sized-image.js +1 -1
- package/dist/format/lib/source-rules/one-dropdown.js +3 -3
- package/dist/format/lib/source-rules/page-picture-place.js +3 -3
- package/dist/format/lib/source-rules/published-mounts.js +38 -38
- package/dist/format/lib/source-rules/shape-rows-use-the-picker.js +2 -2
- package/dist/format/lib/source-rules/support/element-call.d.ts +5 -0
- package/dist/format/lib/source-rules/support/element-call.js +1 -0
- package/dist/format/lib/word-styles.d.ts +7 -6
- package/dist/format/lib/word-styles.js +1 -1
- package/dist/render/components/BlockFrame.d.ts +3 -1
- package/dist/render/components/BlockFrame.js +1 -1
- package/dist/render/components/Flex.js +1 -1
- package/dist/render/components/HeroPictures.d.ts +2 -2
- package/dist/render/components/PublishedPartStylesContext.js +1 -1
- package/dist/render/components/SiteFontsContext.d.ts +11 -0
- package/dist/render/components/SiteFontsContext.js +2 -0
- package/dist/render/lib/content/section-own-pads.d.ts +2 -2
- package/dist/render/lib/content/section-own-pads.js +1 -1
- package/dist/render/lib/content/section-padding.d.ts +3 -2
- package/dist/render/lib/document/part-styles.d.ts +7 -5
- package/dist/render/lib/document/part-styles.js +2 -2
- package/dist/render/lib/document/passes/section-padding.d.ts +2 -1
- package/dist/render/lib/document/passes/section-padding.js +1 -1
- package/dist/render/lib/text-styles/site-text-styles.d.ts +3 -3
- package/dist/render/lib/text-styles/site-text-styles.js +2 -2
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 74.8.0 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
From main at `4ff3fee2`: #838, #840, #841.
|
|
6
|
+
|
|
7
|
+
A minor: the font registry takes a site's own fonts, and a host section can own its padding through meta `ownPad`. New exports and optional parameters; no export removed, no new peer, no stored value moves. A site with no custom font draws exactly as on 74.7.0.
|
|
8
|
+
|
|
9
|
+
**For hosts:**
|
|
10
|
+
- No step for now. To show a site's own fonts, pass `fontRegistry(siteFonts)` to every font reader and draw `SiteFontFaces` (storefront, storefront-blocks and admin-portal each do this in their own PR). With no registry, every reader keeps the fixed pool.
|
|
11
|
+
- A section that pads its own root can declare meta `ownPad` (`{ frame, edge? }`) and draw its root with `sectionRootPad(type, props, ownPad?)`, so "Padding top 40" draws 40 once. Nothing stored moves; a section with no `ownPad` draws the same bytes.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Site fonts registry.** `lib/fonts` `fontRegistry(siteFonts)` joins the fixed pool with a site's own fonts (`SiteFont`; keys start `site-`; CSS var `--font-site-<slug>`). Every font reader takes an optional registry (absent = `POOL_FONT_REGISTRY`): `normalizeFonts`, `fontRoleStyle`, `siteFontCssVars`, `fontOption`, `fontHasItalic`, `fontItalicIsUsable`, `fontsByCategory`, word styles, site text styles, part styles and the font pickers. A duplicate key: the first row wins.
|
|
16
|
+
- **`lib/site-font-faces`**: one `@font-face` builder (`font-display: swap`, `unicode-range` per subset, a metric-matched fallback face, the CSS vars, preload candidates up to `SITE_FONT_PRELOAD_MAX`). Only a same-origin absolute font URL is written.
|
|
17
|
+
- **`components/SiteFontsContext`** and `SiteFontFaces`: the faces and vars as one `<style>` plus preload links. The editor reads the site's fonts from the theme row (`site_fonts`, via `siteFontsFromRow`) and lists a site font first in the pickers.
|
|
18
|
+
|
|
19
|
+
- **Host own-pad path.** `BlockRender` / `PassBlock` take `ownPad?: SectionOwnPad`. `ownFrameOf(key, comp)` (`lib/document/passes/section-padding`) is the one frame lookup for the panel and the draw; `ownRootPad(own, props)` (`lib/content/section-own-pads`) is the host entry `sectionRootPad` calls.
|
|
20
|
+
- **`sectionOnePadding(host)`** (`lib/content/section-one-padding`): the one-padding guard as a rule a host repository can run over its own sections.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- The pages panel, the standalone section editor and the duplicate-to-page menu show the shell `LoadingSpinner` in place of "Loading..." text.
|
|
25
|
+
- `storefront-editor.css` uses `var(--motion-fast)` / `var(--motion-base)` for its times.
|
|
26
|
+
- Source rules and guards read element-making calls through one shared reader (`lib/source-rules/support/element-call`).
|
|
27
|
+
|
|
28
|
+
### Deprecated
|
|
29
|
+
|
|
30
|
+
- `SITE_FONTS`: use `siteTextStyleFonts`. Delete by 2026-12-23.
|
|
31
|
+
|
|
32
|
+
## 74.7.0 - 2026-11-23
|
|
33
|
+
|
|
34
|
+
From main at `001582b7`: #837.
|
|
35
|
+
|
|
36
|
+
A minor: the Add page window shows each starter as the whole page in three columns, the editor's Desktop view is never laid out narrower than 961, and the Box `Side space` row gets a third choice, **None**. New exports; no export removed, no new peer, no stored value moves.
|
|
37
|
+
|
|
38
|
+
**For hosts:**
|
|
39
|
+
- No step. A page that stores `sideSpace: "none"` on a Box (the library pages after eff-erp/efficient-backend#5118) draws edge to edge only on 74.7.0 or later; an older builder draws it as Box.
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- **Box Side space: None.** The Box `Side space` row offers Box, Site and None (stored `sideSpace: "none"`, exported as `BOX_SIDE_SPACE_NONE` from `lib/content/box-side-space`). From 800px up the top-level frame draws no side space; below 800 it keeps the site column's `min(20px, Side space)`, so a phone never puts words on the glass. A nested Box that stores "site" keeps the Side space. `components/BlockFrame` exports `FRAME_NONE_GUTTER`.
|
|
44
|
+
- **Add page: whole-page cards.** `PageStarterCard` draws the starter's whole layout on a 1440 x 800 screen (the frame's `vh`/`svh`/`dvh`/`lvh` are pinned to that screen by the new `lib/frame-viewport`), and the window deals the cards across three columns in list order (`lib/page-starters` `CARD_COLUMNS`, `dealtInto`). "+ Blank page" is the shell's secondary `Button`.
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- **Desktop canvas floor 961.** The editor lays the Desktop view out at `DESKTOP_CANVAS_MIN` (961, `lib/content/view-lines`) and scales it down, so a section's narrow-desktop layout (Split, Brand Text) no longer shows at 1440 with both panels open. `PHONE_EDGE` (800) does not move; no published page changes.
|
|
49
|
+
- `frameGutterOf` takes `boolean | SideSpace` (a boolean keeps its old meaning). `boxSideSpaceWrite` may now also return `"none"`; a caller that stored its answer as `"site" | undefined` widens its type.
|
|
50
|
+
- The `Side space` row's hint names None and drops "It has no effect when Content is Full width", which was wrong. The old hint stays in `KEPT_EDITOR_PHRASES` until 2026-12-18.
|
|
51
|
+
|
|
52
|
+
### Deprecated
|
|
53
|
+
|
|
54
|
+
- `firstSectionOf` (`lib/page-starters`): nothing in this package reads it now. Delete by 2026-12-23.
|
|
55
|
+
|
|
3
56
|
## 74.6.0 - 2026-11-22
|
|
4
57
|
|
|
5
58
|
From main at `ca2a3c7d`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as
|
|
1
|
+
"use client";import{jsx as a,jsxs as P}from"react/jsx-runtime";import{useEffect as W,useId as q,useMemo as G,useRef as H,useState as h}from"react";import{useScreenDocument as U}from"efficient-easel/screen/components/ScreenDocumentContext";import{useEaselSession as V}from"efficient-easel/screen/lib/session-context";import{uniqueSlug as E}from"efficient-easel/page-copy";import{AddIcon as J}from"efficient-easel/icons";import{Button as K,Dialog as Q,EmptyState as X,LoadingSpinner as Y,Paragraph as Z,SidebarLayout as $,SidebarNavItem as S,Title as ee,toast as L}from"efficient-shell/ui";import ae from"./PageStarterCard.js";import{useHostConfig as te}from"../lib/document/host-config.js";import{useSiteWidthsMetadata as re}from"../lib/document/overrides.js";import{say as t}from"../../format/lib/editor-words.js";import{ALL_STARTERS as i,CARD_COLUMNS as se,TEMPLATE_STARTERS as T,dealtInto as oe,shownLibraryGroups as ne,startersIn as le,templateStarters as ie}from"../../format/lib/page-starters.js";import{backendOf as de}from"../lib/website-session.js";function ce({open:d,onClose:w,takenSlugs:b,onCreated:x}){const R=V(),{adapter:c,siteId:m,templateId:M}=U(),r=de(R).pages,y=!M&&!!(r.starters&&r.createFromStarter),u=G(()=>m?{siteId:m}:{},[m]),_=te(),j=re(),[v,o]=h(null),[n,l]=h(i),[p,k]=h(null),C=H(null),N=q();W(()=>{if(!d)return;if(l(i),!y){o([]);return}let e=!0;return o(null),r.starters(u).then(s=>e&&o(s),()=>{e&&(o([]),L.error(t("Couldn’t load the pages — please retry.")))}),()=>{e=!1}},[d,y,r,u]);const A=async(e,s)=>{if(!p){k(e);try{x(await s())}catch{L.error(t("Couldn’t add the page — please retry."))}finally{k(null)}}},B=()=>{if(!c.createPage)return;const e=t("New page");A("blank",()=>c.createPage({slug:E(e,b),title:e,layout:{}}))},D=e=>{A(e.id,()=>r.createFromStarter(e.id,{title:e.title,slug:E(e.slug,b),...u}))},f=v??[],F=ne(f),I=le(n,f),z=oe(se,I),O=P("nav",{"aria-label":t("Pages"),className:"sf-add-page-nav",children:[a(S,{label:t("All pages"),active:n===i,onClick:()=>l(i)}),F.map(e=>a(S,{label:t(e.label),active:n===e.key,onClick:()=>l(e.key)},e.key)),ie(f).length>0?a("div",{className:"sf-add-page-group",children:a(S,{label:t("From your template"),active:n===T,onClick:()=>l(T)})}):null]});return a(Q,{open:d,onClose:w,size:"full",title:t("Add page"),initialFocus:C,children:a($,{sidebarTop:a("div",{className:"sf-add-page-blank",children:a(K,{variant:"secondary",size:"md",leftIcon:a(J,{"aria-hidden":!0}),onClick:B,disabled:!c.createPage||p!==null,children:t("Blank page")})}),sidebar:O,children:P("div",{ref:C,tabIndex:-1,role:"region","aria-labelledby":N,className:"sf-add-page",children:[a(ee,{id:N,level:2,as:"h3",children:t("Pages for your site")}),a(Z,{tone:"default",className:"sf-add-page-sub",children:t("Choose a page and change the text, images and more.")}),v===null?a(Y,{label:t("Loading…")}):I.length===0?a(X,{title:t("No pages to start from"),description:t("Start with a blank page, then add sections.")}):a("div",{className:"sf-add-page-cards",children:z.map((e,s)=>a("div",{className:"sf-add-page-column",children:e.map(g=>a(ae,{starter:g,config:_,metadata:j,busy:p===g.id,onAdd:D},g.id))},s))})]})})})}export{ce as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as i,Fragment as
|
|
1
|
+
"use client";import{jsx as e,jsxs as i,Fragment as oe}from"react/jsx-runtime";import{Suspense as se,useContext as ne,useEffect as M,useMemo as x,useRef as W,useState as h}from"react";import{AccordionHeading as k,Banner as ie,Button as C,Card as re,Dialog as de,DropdownMenu as ae,Segmented as le,Text as r,buttonClasses as ce,colorFill as me,colorSwatchClasses as he,fitFrameStyle as fe,fitScale as ue}from"efficient-shell/ui";import{CodeEditor as pe}from"efficient-shell/code";import{ChevronDownIcon as we}from"efficient-shell/icons/efficient";import{AlignSeparateIcon as ye}from"efficient-easel/icons";import{ScreenDocumentContext as be}from"efficient-easel/screen/components/ScreenDocumentContext";import{usePreviewHeader as ve}from"../../render/components/PreviewHeaderContext.js";import ge from"./SectionThemePicker.js";import xe from"./SiteTextStylesField.js";import{siteTextStyleSizeOf as ke}from"./WebsiteSettingsPanel.js";import{useSiteTextStylesWriter as Ce}from"../lib/site-text-styles-writer.js";import{siteTextColourNameOf as Se,siteTextColours as Ne}from"../../format/lib/text-styles/site-text-colours.js";import{faceClassOf as Te,storedTextStyles as $e,textStylesCss as Ae}from"../../render/lib/text-styles/site-text-styles.js";import{normalizeTheme as ze,themePresetAccentVars as Ee}from"../../format/lib/theme.js";import{fontRoleStyle as Oe}from"../../format/lib/fonts.js";import{useFontRegistry as _e}from"../../render/components/SiteFontsContext.js";import{SECTION_PALETTE as U}from"../../format/lib/content/ink.js";import{CONTAINER_GAP_BUILT_IN as De,SITE_BLOCK_GAP_VAR as _,siteBlockGapTokens as Pe}from"../../format/lib/content/container-gap.js";import{PHONE_EDGE as Ie}from"../../format/lib/content/view-lines.js";import{placeInsert as Re}from"../../format/lib/document/custom-html-place.js";import{toHex as Le}from"../../format/lib/document/part-inks.js";import{CUSTOM_HTML_PREVIEW_SANDBOX as Fe,customHtmlPreviewDoc as He,customHtmlRemoved as Ge,hostStylesheets as Be}from"../lib/document/custom-html-preview.js";import{say as o}from"../../format/lib/editor-words.js";const Me={bg:"Background",fg:"Text",surface:"Card","surface-2":"Card 2",line:"Line",muted:"Soft text"},j=`${De.Flex}px`,D=`var(${_}, ${j})`,We=[{key:"heading",label:"Heading and text",code:`<h2 class="font-heading2">Title</h2>
|
|
2
2
|
<p class="font-body" style="color: var(--fg-dim)">Text</p>
|
|
3
|
-
`},{key:"columns",label:"Two columns",code:`<div style="display: grid; grid-template-columns: 1fr 1fr; gap: ${
|
|
3
|
+
`},{key:"columns",label:"Two columns",code:`<div style="display: grid; grid-template-columns: 1fr 1fr; gap: ${D}">
|
|
4
4
|
<div><h3 class="font-heading3">Left</h3><p class="font-body">Text</p></div>
|
|
5
5
|
<div><h3 class="font-heading3">Right</h3><p class="font-body">Text</p></div>
|
|
6
6
|
</div>
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
<summary class="font-heading3">Question</summary>
|
|
18
18
|
<p class="font-body">Answer</p>
|
|
19
19
|
</details>
|
|
20
|
-
`}],
|
|
20
|
+
`}],Ue=()=>import("efficient-shell/code/format").then(n=>n.prettierFormatter,()=>null);function je(n){if(typeof document>"u"||!n)return n;const d=document.createElement("span");if(d.style.color=n,!d.style.color)return n;document.body.appendChild(d);const a=getComputedStyle(d).color;d.remove();const c=document.createElement("canvas").getContext("2d");if(!c)return n;c.fillStyle=a,c.fillRect(0,0,1,1);const[f,S,u]=c.getImageData(0,0,1,1).data;return(Le(`rgb(${f}, ${S}, ${u})`)??n).toUpperCase()}function Ve({open:n,onClose:d,value:a,onChange:c,loadFormatter:f=Ue}){const{theme:S,fonts:u,blockGap:P,siteLengthUnits:I}=ve(),N=_e(),m=ze(S),R=!ne(be)?.capabilities?.hasSiteTheme,p=Ce({themeFromDocument:R,persist:()=>{}}),[w,V]=h(m.selected),[T,K]=h("desktop"),[Q,q]=h(void 0),[$,L]=h(null),[F,X]=h(null),A=W(null);M(()=>{if(!n)return;let t=!0;return f().then(s=>{t&&X(s?{format:s.format}:null)}),()=>{t=!1}},[n,f]);const z=x(()=>{const t=Ee(m),s=t[`--theme-preset-${w}-bg`]?w:m.selected,l={"--accent":t[`--theme-preset-${s}-accent`]??""};for(const g of U)l[g.token]=t[`--theme-preset-${s}-${g.role}`]??"";return l},[m,w]),H=Pe(R?void 0:P,I.blockGapUnit),J=H[_]??j,G=x(()=>{const t=Object.fromEntries(Object.entries(Oe(u,N)).filter(([s])=>s.startsWith("--")));return{head:typeof document>"u"?"":Be(document),htmlClass:typeof document>"u"?"":document.documentElement.className,bodyClass:typeof document>"u"?"":document.body.className,vars:{...z,...t,...H},css:Ae($e(p.saved),N)}},[z,u,N,P,I.blockGapUnit,p.saved,n]),Y=x(()=>He(a,G),[a,G]),E=x(()=>typeof DOMParser>"u"?[]:Ge(a),[a]),B=W(null),[O,Z]=h(0);M(()=>{const t=B.current;if(!t||typeof ResizeObserver>"u")return;const s=new ResizeObserver(()=>Z(t.clientWidth));return s.observe(t),()=>s.disconnect()},[n]);const y=T==="phone"?390:O>0?Math.max(O,Ie):1280,b=T==="phone"?1:ue(O,y),v=async t=>{const s=await A.current?.place((l,g,te)=>Re(l,g,te,t));s&&L(s)},ee=async()=>{await A.current?.format()==="formatted"&&L(null)};return e(de,{open:n,onClose:d,size:"full",title:o("Custom HTML"),description:o("Build this section in HTML and CSS. The CSS changes this section only. Scripts do not run."),footer:e(C,{variant:"primary",onClick:d,children:o("Done")}),children:i("div",{className:"sf-code-window","data-code-window":"body",children:[i("aside",{className:"sf-code-window-styles","data-code-window":"styles",children:[e(k,{title:o("Styles"),level:2}),i("div",{className:"es-group-body sf-code-window-group",children:[e(r,{size:"xs",tone:"secondary",as:"p",children:o("Click a colour, text style or spacing to put a link to it in your code, at the cursor. If you change Styles later, this section changes with it.")}),e("div",{className:"es-editor sf-editor-tokens","data-code-window":"theme",children:e(ge,{value:w,onChange:V,hint:o("Shows the preview in this Theme. It adds no code. The section uses the Theme in its own settings."),canEdit:!1})})]}),e(k,{title:o("Colours"),level:2}),e("div",{className:"es-group-body",children:e("div",{className:"sf-code-window-list",role:"list",children:U.map(t=>{const s=o(Me[t.role]??t.role),l=je(z[t.token]??"");return e("div",{role:"listitem",children:i(C,{variant:"ghost",block:!0,className:"sf-code-window-row","aria-label":`${s}: ${o("add")} var(${t.token})`,onClick:()=>{q(t.token),v({kind:"value",value:`var(${t.token})`,property:"color"})},children:[e("span",{className:he({size:"sm",selected:Q===t.token}),"aria-hidden":"true",children:e("span",{className:"absolute inset-0",style:me(l)})}),e(r,{size:"sm",weight:"medium",children:s}),e(r,{size:"2xs",tone:"tertiary",mono:!0,children:l}),e("span",{className:"sf-code-window-row-sub",children:e(r,{size:"2xs",tone:"secondary",mono:!0,children:t.token})})]})},t.token)})})}),e(k,{title:o("Text styles"),level:2}),e("div",{className:"es-group-body",children:e(xe,{saved:p.saved,old:p.old,colours:Ne(m),colourNameOf:Se(m),sizeOf:ke,onChange:()=>{},onPick:t=>{v({kind:"class",className:Te(t)})}})}),e(k,{title:o("Spacing"),level:2}),e("div",{className:"es-group-body",children:i(C,{variant:"ghost",block:!0,className:"sf-code-window-row","aria-label":`${o("Gap between blocks")}: ${o("add")} ${D}`,onClick:()=>{v({kind:"value",value:D,property:"padding"})},children:[e("span",{className:"sf-code-window-row-icon","aria-hidden":"true",children:e(r,{tone:"secondary",children:e(ye,{})})}),e(r,{size:"sm",weight:"medium",children:o("Gap between blocks")}),e(r,{size:"2xs",tone:"tertiary",children:J.replace(/(\d)px$/,"$1 px")}),e("span",{className:"sf-code-window-row-sub",children:e(r,{size:"2xs",tone:"secondary",mono:!0,children:_})})]})})]}),i("div",{className:"sf-code-window-column","data-code-window":"preview-column",children:[i("div",{className:"sf-code-window-bar",children:[e(le,{size:"sm",value:T,onChange:K,options:[{value:"desktop",label:o("Desktop")},{value:"phone",label:o("Phone")}]}),e(r,{size:"xs",tone:"secondary",children:`${y} px · ${Math.round(b*100)}%`})]}),e(re,{padding:"sm",className:"sf-code-window-fill",children:e("div",{className:"sf-code-window-fill",children:e("div",{ref:B,className:"sf-code-window-stage es-editor sf-editor-tokens sf-center",children:e("div",{className:"sf-frame",style:{width:y*b,flex:"none"},children:e("iframe",{title:o("Preview"),sandbox:Fe,srcDoc:Y,"data-code-window":"preview",style:{...fe(y,b),height:`${100/b}%`}})})})})}),e("div",{role:"status","data-code-window":"status",children:e(ie,{tone:E.length?"warning":"success",emphasis:"subtle",children:E.length?`${o("Not published")}: ${E.join(", ")}. ${o("Scripts and event attributes are removed for safety.")}`:o("Everything here is published as written.")})})]}),i("div",{className:"sf-code-window-column","data-code-window":"code",children:[i("div",{className:"sf-code-window-bar",children:[e(r,{size:"xs",weight:"semibold",children:o("Code")}),i("div",{className:"sf-code-window-actions",children:[F?e(C,{variant:"secondary",onClick:()=>{ee()},children:o("Format code")}):null,e(ae,{"aria-label":o("Add a ready-made part"),triggerClassName:ce({variant:"secondary"}),align:"end",trigger:i(oe,{children:[o("Add part")," ",e(we,{size:12})]}),items:We.map(t=>({key:t.key,label:o(t.label),onSelect:()=>{v({kind:"block",code:t.code})}}))})]})]}),$?i("div",{className:"sf-code-window-added","data-code-window":"added",children:[e(r,{size:"xs",tone:"secondary",children:`${o("Added on line")} ${$.line}:`}),e(r,{size:"2xs",mono:!0,truncate:!0,children:$.text})]}):null,e("div",{className:"sf-code-window-editor",children:e(se,{fallback:null,children:e(pe,{ref:A,value:a,onChange:c,label:o("Section code"),lineWrap:!0,formatter:F??void 0})})})]})]})})}export{Ve as default,Ue as loadShellFormatter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as y,Fragment as I}from"react/jsx-runtime";import{useCallback as j,useRef as A,useState as p}from"react";import{InspectorIconButton as B}from"efficient-easel/chrome";import{useEasel as L}from"efficient-easel/easel";import{LoadingSpinner as O,PopupMenu as R,PopupMenuItem as _,PopupMenuLabel as x}from"efficient-shell/ui";import{CopyToPageIcon as W}from"efficient-easel/icons";import{backendOf as E}from"../lib/website-session.js";import{useEaselSession as z}from"efficient-easel/screen/lib/session-context";import{say as o}from"../../format/lib/editor-words.js";import{cloneNodeWithFreshIds as H}from"efficient-easel/screen/lib/document/section-doc";import{FOOTER_TYPE as K}from"efficient-easel/draw";import{settlingPages as Y}from"../lib/editor-document-adapter.js";import{withoutWebsiteKeys as $}from"../lib/pinned-chrome-doc.js";function q(i,r,l){const n=H(i,void 0,r);return l?.(n)??n}function G({node:i,currentSlug:r,siteId:l,tokenRef:n,runAuthed:c,onNotify:u}){const[s,a]=p(!1),[m,b]=p(null),d=z(),N=L(e=>e.config.components),[T,f]=p(!1),[g,P]=p(null),w=A(null),[h,v]=p(null),M=j(async()=>{if(d.usesBridgedToken&&!n.current){f(!0);return}try{b(await E(d).pages.list(l?{siteId:l}:void 0))}catch{f(!0)}},[n,l,d]),S=()=>{if(s){a(!1);return}const e=w.current?.getBoundingClientRect();e&&v({top:e.bottom+6,right:Math.max(8,window.innerWidth-e.right)}),b(null),f(!1),M(),a(!0)},k=(m??[]).filter(e=>e.slug!==r),D=async e=>{if(g)return;P(e.slug);const F=q(i,N,d.documentHooks?.storedNode),C=await c(()=>J(E(d).pages,e,F));P(null),a(!1),u?.(C?o("Duplicated to “{name}”",{name:e.label}):o("Couldn’t duplicate the section — please retry"),C?"success":"error")};return y(I,{children:[t("span",{"data-menu-toggle":!0,style:{display:"contents"},children:t(B,{buttonRef:w,label:o("Duplicate to another page"),hasPopup:"menu",expanded:s,onClick:S,children:t(W,{size:15})})}),s&&h&&t(R,{portal:!0,style:{top:h.top,right:h.right},onClose:()=>a(!1),children:y("div",{role:"menu","aria-label":o("Duplicate to page"),children:[t(x,{children:o("Duplicate to page")}),T?t(x,{children:o("Couldn’t load pages")}):m===null?t(O,{label:o("Loading…")}):k.length===0?t(x,{children:o("No other pages")}):k.map(e=>y(_,{role:"menuitem",disabled:g!==null,onClick:()=>{D(e)},children:[t("span",{className:"min-w-0 flex-1 truncate",children:e.label}),g===e.slug?t("span",{className:"shrink-0 text-xs",children:o("Copying…")}):e.draft&&t("span",{className:"shrink-0 text-xs",children:o("draft")})]},e.id))]})})]})}async function J(i,r,l){const n=Y(i),c=await n.load({id:r.id});if(!c)throw new Error(`Page "${r.slug}" no longer exists.`);const u=c.layout??{},s=Array.isArray(u.content)?[...u.content]:[],a=s.findIndex(m=>m?.type===K);s.splice(a===-1?s.length:a,0,$(l)),await n.save(r.id,{layout:{root:{},zones:{},...u,content:s}},{version:c.version,clientId:""})}export{q as copyForAnotherPage,J as copyNodeToPage,G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as d}from"react/jsx-runtime";import{useEffect as x,useState as n}from"react";import{CanvasFrame as N}from"efficient-easel/easel";import{Button as S,Card as b,FitFrame as D,Text as F}from"efficient-shell/ui";import H from"./PreviewThemeFrame.js";import P from"../../render/lib/document/page-render.js";import{SiteThemeCarrier as R,suppressPreviewNav as E}from"../lib/document/page-root.js";import{useEditorCanvasStyles as T}from"../lib/editor-canvas-styles.js";import{say as l}from"../../format/lib/editor-words.js";import{pinFrameViewport as _}from"../../format/lib/frame-viewport.js";const j=1440,s=800;function A({starter:t,config:f,metadata:h,busy:u,onAdd:p}){const{mirrorHostStyles:g}=T(),[i,v]=n(null),[C,w]=n(s),[r,y]=n(null);return x(()=>{if(!i)return;const a=_(i,s),o=i.defaultView,m=()=>{r&&w(Math.max(s,Math.ceil(r.getBoundingClientRect().height)))},c=o&&r?new o.ResizeObserver(m):null;return r&&c?.observe(r),m(),()=>{a(),c?.disconnect()}},[i,r]),d("div",{className:"sf-starter",children:[d(b,{padding:"none",className:"sf-starter-picture",children:[e("div",{inert:!0,className:"sf-starter-frame",children:e(D,{width:j,height:C,children:e(N,{id:`page-starter-${t.id}`,title:t.title,mirrorStyles:g,onDocument:v,height:"fill",children:e(H,{document:i??void 0,children:e(R,{onClickCapture:E,body:a=>e("div",{className:"sf-themed-content",style:a,children:e("div",{ref:y,style:{background:"var(--bg)"},children:e(P,{config:f,data:t.layout,metadata:h})})})})})})})}),e("div",{className:"sf-starter-add",children:e(S,{onClick:()=>p(t),loading:u,"aria-label":l("Add “{name}”",{name:t.title}),children:l("Add page")})})]}),e(F,{size:"sm",children:t.title})]})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,Fragment as ke,jsxs as R}from"react/jsx-runtime";import{Fragment as Ce,useEffect as $,useMemo as ee,useRef as Ae,useState as d}from"react";import{useScreenDocument as ne}from"efficient-easel/screen/components/ScreenDocumentContext";import{UiIcon as H}from"efficient-easel/draw/client";import Ie from"efficient-easel/screen/components/SidePanelHead";import{useWebsiteName as Re}from"./WebsiteSettingsPanel.js";import{InspectorIconButton as De}from"efficient-easel/chrome";import{Input as Oe,
|
|
1
|
+
"use client";import{jsx as n,Fragment as ke,jsxs as R}from"react/jsx-runtime";import{Fragment as Ce,useEffect as $,useMemo as ee,useRef as Ae,useState as d}from"react";import{useScreenDocument as ne}from"efficient-easel/screen/components/ScreenDocumentContext";import{UiIcon as H}from"efficient-easel/draw/client";import Ie from"efficient-easel/screen/components/SidePanelHead";import{useWebsiteName as Re}from"./WebsiteSettingsPanel.js";import{InspectorIconButton as De}from"efficient-easel/chrome";import{Input as Oe,LoadingSpinner as xe,PopupMenu as Ee,PopupMenuItem as te,toast as oe}from"efficient-shell/ui";import{LayersTree as Le,TreeGroupLabel as Ne,TreeRow as se,TreeRowAction as D}from"efficient-easel/tree";import{AddIcon as Be,DuplicateIcon as Me,PageIcon as _e,SettingsIcon as Fe}from"efficient-easel/icons";import{PagesIcon as ve}from"efficient-easel/rail";import{useEaselHost as ze}from"efficient-easel/screen/lib/host";import{bucketEditorPageRows as Ge,DYNAMIC_PAGES_GROUP_KEY as He,isDynamicPageRow as Te,isPopupPageRow as We,MAIN_PAGES_GROUP as je}from"../../format/lib/editor-page-rows.js";import{useEaselSession as T}from"efficient-easel/screen/lib/session-context";import{holdPageRow as W,usePageRows as Ue}from"../lib/page-rows.js";import{say as t,sayCount as Ye}from"../../format/lib/editor-words.js";import{canDuplicatePage as qe,DuplicatePageDialog as Je}from"efficient-easel/page-copy";import Ke from"./AddPageWindow.js";import{useTakeAddPageOnOpen as Qe}from"./AddPageOnOpen.js";import{backendOf as ae}from"../lib/website-session.js";import{shopHost as Ve}from"../../format/lib/web-runtime.js";import{newPopupPage as Xe}from"../../format/lib/popup/new-popup.js";const le="sf-editor-pages-collapsed-groups";function Ze(){const r=T(),{siteId:O,templateId:S}=ne(),w=ae(r).pages;if(!(!w.duplicate||S))return(u,y)=>w.duplicate(u.id,{...y,...O?{siteId:O}:{}})}function $e({onNavigate:r,onClose:O,activeSurface:S,onPreviewSurface:w}){const u=T().chrome?.pageRows,y=ze(),{adapter:k,capabilities:p,ready:j,currentSlug:U}=ne(),re=Re(),{rows:c,reload:x,setRows:Y,getRows:ie}=Ue(),[E,ce]=d(""),[m,q]=d(!1),[J,C]=d(null),[K,L]=d(!1),de=!!ae(T()).pages.createFromStarter,N=Ze(),[g,B]=d(null),[M,ue]=d(()=>{if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(le);return new Set(e?JSON.parse(e):[])}catch{return new Set}});$(()=>{try{window.localStorage.setItem(le,JSON.stringify([...M]))}catch{}},[M]);const pe=e=>ue(s=>{const o=new Set(s);return o.has(e)?o.delete(e):o.add(e),o}),me=ee(()=>Ge(c??[]),[c]),_=E.trim().toLowerCase(),Q=e=>!_||e.toLowerCase().includes(_),ge=e=>_?!0:!M.has(e),F=ee(()=>new Set((c??[]).map(e=>e.slug)),[c]),v=()=>{if(p.pageCreationInAdminForm&&!de){y.send("storefront-editor:new-page");return}C(null),L(!0)},fe=Qe();$(()=>{fe()&&v()},[]);const A=p.hasSiteSettings&&!!k.createPage,he=async()=>{if(!(!j||m||!k.createPage)){q(!0),C(null);try{const e=await k.createPage(Xe(t("New popup"),F));await x(),r(e.slug)}catch{C(t("Couldn’t add the popup — please retry."))}finally{q(!1)}}},V=Ae(null),[f,h]=d(null),be=()=>{if(!A)return v();if(f)return h(null);const e=V.current?.getBoundingClientRect();e&&h({top:e.bottom+6,right:Math.max(8,window.innerWidth-e.right)})},Pe=e=>{const s=c??[],o=k.deletePage;if(!j||m||!o||s.length<=1)return;const l=s.findIndex(a=>a.id===e.id),i=s.filter(a=>a.id!==e.id),b=e.slug===U;W(e.id,!0),Y(i),C(null),b&&i[0]&&r(i[0].slug);const I=()=>{W(e.id,!1);const a=ie()??[];if(a.some(ye=>ye.id===e.id))return;const P=[...a];P.splice(Math.max(0,Math.min(l,P.length)),0,e),Y(P)};oe.undoable(t("Deleted “{name}”",{name:e.label}),{actionLabel:t("Undo"),commit:async a=>{await o(e.id,a),W(e.id,!1)},undo:()=>{I(),b&&r(e.slug)},onFail:()=>{I(),oe.error(t("Couldn’t delete the page — please retry."))}})},Se=e=>y.send("storefront-editor:open-page",{slug:e}),we=e=>{if(!Q(e.label))return null;const s=!S&&e.slug===U,o=p.canDeletePagesInline&&(c??[]).length>1,l=Te(e),i=We(e),b=[...l?[{label:t("Dynamic"),tone:"info"}]:[],...i?[{label:t("Lightbox"),tone:"success"}]:[],...e.draft?[{label:t("draft"),tone:"draft"}]:[]],I=b.length>0?b:void 0,a=!!N&&qe(e),P=a||p.pageCreationInAdminForm||o?R(ke,{children:[a&&n(D,{kind:"plain",label:t("Duplicate “{name}”",{name:e.label}),disabled:m,onClick:()=>B(e),children:n(Me,{size:13})}),p.pageCreationInAdminForm&&n(D,{kind:"plain",label:t("Page settings for “{name}”",{name:e.label}),onClick:()=>Se(e.slug),children:n(Fe,{size:13})}),o&&n(D,{kind:"delete",label:t("Delete “{name}”",{name:e.label}),disabled:m,onClick:()=>Pe(e),children:n(H,{name:"trash",size:13,strokeWidth:1.7,rounded:!0})})]}):void 0;return n(se,{icon:n(_e,{size:14}),name:e.label,selected:s,onSelect:()=>r(e.slug),badge:I,actions:P,rowProps:{"data-page-slug":e.slug}},e.id)},z=(e,s,o)=>{const l=o.filter(Boolean);if(l.length===0)return null;const i=ge(e);return R(Ce,{children:[n(Ne,{count:l.length,countLabel:Ye("{n} page","{n} pages",l.length),expanded:i,onToggle:()=>pe(e),children:s}),i&&l]},e)},X=(u?.rows??[]).filter(e=>Q(e.label)).map(e=>{const s=S===e.key;return n(se,{icon:e.icon,name:e.label,selected:s,onSelect:()=>w(e.key),badge:{label:t("Preview"),tone:"warning"},actions:n(D,{kind:"plain",label:t("Open the {name} in a new tab",{name:e.label}),onClick:()=>window.open(e.href,"_blank","noopener,noreferrer"),children:n(H,{name:"external-link",size:13,strokeWidth:1.7,rounded:!0})}),rowProps:{"data-shop-surface":e.key}},e.key)}),Z=p.hasSiteSettings&&!!u,G=(()=>{if(c===null)return null;const e=[];let s=!1;for(const o of me){Z&&!s&&o.key.startsWith("system:")&&(e.push(z("shop",u.title,X)),s=!0);const l=o.key===He||o.label===je?t(o.label):o.label;e.push(z(o.key,l,o.rows.map(we)))}return Z&&!s&&e.push(z("shop",u.title,X)),e})();return R("div",{className:"sf-pages",children:[n(Ie,{icon:n(ve,{}),title:t("Pages"),context:re,actions:n(De,{buttonRef:V,label:A?t("Add"):t("New page"),hasPopup:A?"menu":void 0,expanded:A?f!==null:void 0,onClick:be,children:n(Be,{size:15})})}),f&&n(Ee,{portal:!0,style:{top:f.top,right:f.right},onClose:()=>h(null),children:R("div",{role:"menu","aria-label":t("Add"),children:[n(te,{role:"menuitem",onClick:()=>{h(null),v()},children:t("Page")}),n(te,{role:"menuitem",disabled:m,onClick:()=>{h(null),he()},children:t("Popup")})]})}),n("div",{className:"sf-pages-find",children:n(Oe,{type:"search",leftIcon:n(H,{name:"search",size:14,rounded:!0}),placeholder:t("Search all pages…"),value:E,onChange:e=>ce(e.target.value),"aria-label":t("Search all pages")})}),J&&!K&&n("div",{className:"sf-note sf-note--error",role:"alert",children:J}),G===null?n(xe,{label:t("Loading…")}):G.some(Boolean)?n(Le,{ariaLabel:t("Pages"),className:"sf-scroll",children:G}):n("div",{className:"sf-note",children:E.trim()?t("No pages match your search"):t("No pages yet. Add one with + above.")}),N&&g&&n(Je,{source:{title:g.label,slug:g.slug},taken:F,host:Ve(),duplicate:e=>N(g,e),onClose:()=>B(null),onDuplicated:e=>{B(null),x(),r(e.slug)}},g.id),K?n(Ke,{open:!0,onClose:()=>L(!1),takenSlugs:F,onCreated:e=>{L(!1),x(),r(e.slug)}}):null]})}export{$e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as o,Fragment as W,jsxs as h}from"react/jsx-runtime";import{useContext as wt,useEffect as pe,useRef as Pt,useState as Le}from"react";import{FieldSelect as vt,InspectorField as Tt,fieldShownInView as Nt}from"efficient-easel/fields";import{InertHint as Be,SettingsField as Ot}from"efficient-easel/panel";import{InspectorUpLevel as Y}from"efficient-easel/chrome";import{StylesIcon as Rt,TypeIcon as kt}from"efficient-easel/icons";import{useEasel as Ct}from"efficient-easel/easel";import{TextPartPanel as He}from"efficient-easel/copy";import{Button as Et,IconButton as It,Tooltip as zt}from"efficient-shell/ui";import{PartTextBox as Ft,partTextCells as Ue}from"./PartTextBox.js";import{SiteFields as me}from"./SiteFields.js";import{usePartMotion as _t}from"./usePartMotion.js";import{UiIcon as We}from"efficient-easel/draw/client";import{usePreviewHeader as At}from"../../render/components/PreviewHeaderContext.js";import{UpdateStyleDialog as Vt}from"./UpdateStyleDialog.js";import{ScreenDocumentContext as Lt}from"efficient-easel/screen/components/ScreenDocumentContext";import{hasStyleChange as Bt,partStyleToTextStyleValues as Ht,pushIntoStyle as Ut,resolveTextStyles as je,styleIdOfRole as Wt}from"../../render/lib/text-styles/site-text-styles.js";import{useSiteTextStylesWriter as jt}from"../lib/site-text-styles-writer.js";import{useThemeRowPersist as Dt}from"../lib/theme-row-persist.js";import{usePreviewDevice as Kt}from"efficient-easel/draw/client";import{shownTier as q}from"efficient-easel/screen/lib/document/device-fields";import{PART_PANEL_ROWS as De,partRowHasTabletValue as Gt}from"../lib/document/part-panel-rows.js";import{usePartStyle as Mt}from"./PreviewPartStyleContext.js";import{say as l}from"../../format/lib/editor-words.js";import{readHidable as J,textFieldOffPage as $t,textFieldPanelOnly as Xt}from"../lib/document/controls.js";import{TEXT_FIELD_MARKER as Yt,viewKeyAt as qt}from"efficient-easel/draw";import{useSectionOps as Jt}from"efficient-easel/screen/lib/document/use-section-ops";import{FONT_OPTIONS as Qt,FONT_ROLES as Zt,FONT_ROLE_LABELS as Ke,fontOption as ye,fontRoleOf as en}from"../../format/lib/fonts.js";import{isMultilineKind as tn,partPlaceholder as nn,typeInPlaceKind as on}from"../../render/lib/document/part-text.js";import{partRowField as ln}from"../lib/document/part-row-field.js";import{decodePartKey as sn,partPropsWithRowValue as rn,partRowValue as an}from"../../render/lib/document/part-rows.js";import{followedStyleOf as Ge,partAlignFollowed as cn,propsWithPartStyleValue as B,propsWithoutPartStyle as dn,readPartStyle as he,regionHasOwnLook as un}from"../../render/lib/document/part-styles.js";import{partThemeColors as fn}from"../../format/lib/document/part-inks.js";import{styleKeyForPart as Me}from"../../format/lib/sections/section-text-kinds.js";import{commitPartText as pn}from"../lib/document/part-typing.js";import{keysOnCanvas as mn,useCanvasTypingPart as yn}from"../lib/document/canvas-typing.js";import{useEaselHost as hn}from"efficient-easel/screen/lib/host";import{SOURCE_LINES as Sn,SOURCE_ACTIONS as gn,SOURCE_ACTION_LABEL as xn,partSourceNoteFor as bn,partSourceOf as wn,sourceMenuIdOf as Pn,sourceSlugOf as Se}from"../../format/lib/document/source-bound-parts.js";import{encodePartId as vn,holdsAuthoredText as Tn}from"../../render/lib/document/text-parts.js";import{regionsForSection as Nn}from"../../format/lib/sections/section-text-regions.js";import{regionTakesSize as On,textRegionOfPartKey as Rn}from"../../format/lib/sections/text-regions.js";import{SameInEveryViewNote as $e}from"./SameInEveryViewNote.js";function ge(t){return t?l(t):null}function Xe(t){return t.kind==="role"?Ke[t.role]:t.kind==="custom"?"Custom":null}function kn(t){const n=en(t.role);return n?{kind:"role",role:n}:null}function Cn(t,n){if(!t)return{kind:"unread"};const{faceRole:r,base:i}=t;if(n[r]===i.fontKey)return{kind:"role",role:r};const a=Object.keys(n).filter(s=>n[s]===i.fontKey);return a.length===1?{kind:"role",role:a[0]}:{kind:"custom"}}function Q(t,n,r,i){return kn(he(t,n))??Cn(r,i)}function En(t,n){if(!t.length)return null;const r=n(t[0]);return t.every(i=>n(i)===r)?r:null}function Ye(t){return[{value:j,label:l("No style"),description:l("Section’s own")},...t.map(n=>({value:n.id,label:n.name,description:n.values.font?ye(n.values.font)?.label:void 0}))]}const j="";function In({face:t,base:n,onPick:r}){const i=t.kind==="role"?t.role:j,a=[{label:l("No style"),value:j},...Zt.map(s=>({label:l(Ke[s]),value:s}))];return o(vt,{ariaLabel:l("Style"),value:i,options:a,inline:!0,onChange:s=>r(s===j?null:s),renderOption:s=>s.value===j?h(W,{children:[o("span",{className:"es-fsel-label sf-part-style-keep",children:s.label}),o("span",{className:"sf-part-style-aside","aria-hidden":"true",children:l("Section’s own")})]}):o("span",{className:"es-fsel-label",style:{fontFamily:`var(--font-role-${s.value})`},children:s.label}),renderValue:()=>o("span",{style:{fontFamily:n?.fontKey?`var(${ye(n.fontKey)?.cssVar})`:void 0,fontWeight:n?.weight},children:ge(Xe(t))}),valueText:s=>ge(Xe(t))??s?.label??""})}const qe=["regionNote","regionStyle"],zn=Object.keys(De).filter(t=>!qe.includes(t));function Je(t,n){return!t.some(n)}function Fn({sectionName:t,onBack:n,textEditor:r,styleRow:i,children:a,tabs:s}){const g=h(W,{children:[r,i,a]});return h("div",{className:"sf-part-panel",children:[o(Y,{inline:!0,name:l(t),onSelect:n}),s?s(g):g]})}function Qe({source:t,slug:n,menuId:r}){const i=hn(),a=gn[t],s=!a.needsSlug||!!n;return o("div",{className:"sf-note sf-note--source",children:h(Be,{children:[l(Sn[t]),s?h(W,{children:[" ",o(Et,{type:"button",variant:"link",size:"sm",onClick:()=>{a.type==="storefront-editor:open-menus"?i.send(a.type,{menuId:r??null}):n&&i.send(a.type,{slug:n})},children:l(xn)})]}):null]})})}const Ze=4,_n=120;function et(t){return l("Every {part} in this section follows it. The face and the size change; the letter case is the section’s own and stays as it is.",{part:l(t.label).toLowerCase()})}function tt({region:t,sizePx:n,face:r,base:i,onFollowStyle:a,source:s,slug:g,onBack:N,shows:x,sizedStyle:b,ownLook:I}){const D=t.follows;return h("div",{className:"sf-note",children:[o("p",{children:o("strong",{children:l(t.label)})}),x("regionNote")&&!I&&o("p",{children:n?l("Its size follows Styles ▸ {follows} — {px}px right now.",{follows:l(D),px:Math.round(n)}):l("Its size follows Styles ▸ {follows}.",{follows:l(D)})}),b?h(W,{children:[b,x("regionStyle")&&o("p",{className:"es-field-hint",children:et(t)})]}):a?x("regionStyle")?o(W,{children:o(Ot,{label:l("Style"),icon:o(Rt,{}),hint:et(t),children:o(In,{face:r,base:i,onPick:a})})}):null:x("regionNote")&&o("p",{className:"es-field-hint",children:l("Only the size follows a site style. This section sets its own font, weight and letter case.")}),s&&x("sourceNote")?o(Qe,{source:s,slug:g}):null,Je([...qe,"sourceNote",...b?["fontSize"]:[]],z=>x(z)&&(z!=="sourceNote"||!!s))&&o($e,{}),o(Y,{inline:!0,name:l("Page"),onSelect:N})]})}function An({onBack:t}){return h("div",{className:"sf-note",children:[o("p",{children:o("strong",{children:l("This part is no longer here.")})}),o("p",{children:l("The section it belonged to has been changed or removed.")}),o(Y,{inline:!0,name:l("Page"),onSelect:t})]})}function Vn({onBack:t,partId:n,why:r}){return h("div",{className:"sf-note",children:[o("p",{children:o("strong",{children:l("This part's settings did not open.")})}),o("p",{children:l("The words are still on your page and nothing has been lost. The editor could not work out which control belongs to them, which is a fault on our side. Go back and click the section to open its settings instead.")}),o("p",{className:"sf-note-detail",children:h("code",{children:[n," — ",r]})}),o(Y,{inline:!0,name:l("Page"),onSelect:t})]})}function Ln({nodeId:t,propKey:n,onBack:r,onEditStyle:i}){const{getItemById:a,getSelectorForId:s,config:g}=Ct(e=>e),N=Jt(),x=yn(),{partStyle:b}=Mt(),{fonts:I,textStyles:D}=At(),z=wt(Lt),xe=!z?.capabilities?.hasSiteTheme,{persist:ot}=Dt({themeFromDocument:xe,tokenRef:z?.tokenRef,siteId:z?.siteId??null}),O=jt({themeFromDocument:xe,persist:ot}),[lt,Z]=Le(!1),H=Kt(),f=e=>(q(H)!=="tablet"||Gt(e))&&Nt(De[e],H),be=Pt(null),d=a(t),p=s(t),we=d?g.components[d.type]:void 0,{key:w,row:P}=sn(n),Pe=we?.fields?.[w],S=P?ln(Pe,P):Pe,F=vn(t,n),u=d?.props??{},v=on(S),ve=$t(S),Te=Tn(S),Ne=d?wn(d.type):null,ee=d?bn(d.type,w):null,te=P?an(u[w],P):u[w],Oe=!!P&&!(Array.isArray(u[w])&&P.index<u[w].length);pe(()=>{if(mn(document))return;be.current?.querySelector(".es-copy [contenteditable='true'], .es-copy textarea, .sf-copybox textarea, .sf-copybox input")?.focus()},[F]);const[ne,Re]=Le(0);pe(()=>Re(0),[F]);const oe=!!d&&!Oe&&(!p||!S);pe(()=>{if(!oe||ne>=Ze)return;const e=setTimeout(()=>Re(c=>c+1),_n);return()=>clearTimeout(e)},[oe,ne]);const st=oe&&ne<Ze,le=_t(t,Me(d?.type,n),"textPart");if(!d||Oe)return o(An,{onBack:r});const K=Nn(d.type),ke=K?Rn(K,n):null;if(K&&ke){const e=b?.partId===F?b:null,c=K[ke],m=c.writable===!0&&!!p,T=C=>{p&&N.replaceComponent(p.zone,p.index,{...d,props:B(u,n,"role",C)})};if(m&&On(c)){const C=he(u,n),Ve=E=>{if(!p)return;let fe=u;for(const[xt,bt]of Object.entries(E))fe=B(fe,n,xt,bt??null);N.replaceComponent(p.zone,p.index,{...d,props:fe})},ht=je(O.saved,O.old),St=Ge(C)??"",gt=Ue(C,e?.base??nt,Ve,q(H)).filter(E=>E.key==="fontSize"&&f(E.key));return o(me,{motion:le,body:o(tt,{region:c,sizePx:e?.base.sizePx??null,face:Q(u,n,e,I),base:e?.base??null,source:Ne,slug:Se(u),onBack:r,shows:f,ownLook:un(C),sizedStyle:o(He,{style:f("style")?{value:St,options:Ye(ht),onChange:E=>Ve(E?{textStyle:E}:{textStyle:null,role:null}),onEditStyles:i}:void 0,cells:gt})})})}return o(me,{motion:le,body:o(tt,{region:c,sizePx:e?.base.sizePx??null,face:Q(u,n,e,I),base:e?.base??null,onFollowStyle:m?T:void 0,source:Ne,slug:Se(u),onBack:r,shows:f})})}if(!p||!S)return st?o("div",{className:"sf-note","aria-busy":"true"}):o(Vn,{onBack:r,partId:F,why:p?"no field":"no selector"});const Ce=e=>{N.replaceComponent(p.zone,p.index,{...d,props:e})},se=e=>{if(J(e).hidden!==J(te).hidden||!v){const m=P?rn(u,w,P,e):{...u,[w]:e};m&&Ce(m);return}pn({node:d,propKey:n,kind:v,zone:p.zone,index:p.index},J(e).text,N.replaceComponent)},rt=te,_=b?.partId===F?b:null,A=_?.styleOwner,G=A?a(A.owner):null,re=A&&G?s(A.owner):null,ie=!!(A&&G&&re),V=ie?G.props??{}:u,ae=ie?e=>N.replaceComponent(re.zone,re.index,{...G,props:e}):Ce,M=ie?A.kind:Me(d?.type,n),R=he(V,M),y=[{partKey:M,face:Q(V,M,_,I),sizeGroup:_?.sizeGroup??null,base:_?.base??nt,style:R}],Ee=En(y,e=>e.sizeGroup),it=fn(_?.inks),U=(e,c)=>{let m=V;for(const T of y)m=B(m,T.partKey,e,c);ae(m)},at=e=>e?U("textStyle",e):ce({textStyle:null,role:null}),ce=e=>{let c=V;for(const m of y)for(const[T,C]of Object.entries(e))c=B(c,m.partKey,T,C??null);ae(c)},de=v==="text"||v==="textarea",{text:Ie,hidden:L}=J(te),$=S?.[Yt]?.label??n,ze=L?l("Show {label} on the slide",{label:l($)}):l("Hide {label} on the slide",{label:l($)}),Fe=h("div",{className:"sf-field-head",children:[o(kt,{}),o("span",{className:"sf-field-label sf-field-label--inline",children:l($)}),de&&o(zt,{content:ze,children:o(It,{"aria-pressed":L,"aria-label":ze,onClick:()=>se({text:Ie,hidden:!L}),children:L?o(We,{name:"eye-off",size:14}):o(We,{name:"eye",size:14})})})]}),X=!ve&&Te,ct=!!v&&(Xt(S)||ve||L||!Te),_e=Q(V,M,_,I),dt=_e.kind==="role"?_e.role:null,ue=Ge(R)??Wt(dt),Ae=je(O.saved,O.old),ut=Object.entries(R).filter(([e,c])=>e!=="role"&&e!=="textStyle"&&c!==void 0).length,ft=()=>{let e=V;for(const c of y){const{role:m,textStyle:T}=c.style;e=dn(e,c.partKey),m&&(e=B(e,c.partKey,"role",m)),T&&(e=B(e,c.partKey,"textStyle",T))}ae(e)},k=ue,pt=Bt(y[0].style),mt=k?Ae.find(e=>e.id===k)?.name??k:"",yt=()=>{Z(!1),k&&(O.write(Ut({saved:O.saved,old:O.old,styleId:k,values:Ht(y[0].style)}),!0),ft())};return h(Fn,{sectionName:we?.label??d.type,onBack:r,tabs:e=>o(me,{motion:le,body:e}),textEditor:f("words")?o("div",{ref:be,className:"sf-part-text",children:ct?o(Ft,{text:Ie,onTextChange:e=>se(de?{text:e,hidden:L}:e),multiline:tn(v),markup:v!=="plainText",styled:!1,style:y[0].style,base:y[0].base,setValue:ce,colors:it,placeholder:ge(nn(S))??void 0,ariaLabel:l($),head:Fe,typedOnCanvas:x===F}):v?de?Fe:null:o(Tt,{field:S,name:n,value:rt,onChange:se,id:`sf-part-${t}-${n}`})}):void 0,children:[ee&&f("sourceNote")&&o(Qe,{source:ee,slug:Se(u),menuId:Pn(u)}),X&&o(He,{style:f("style")?{value:ue??"",options:Ye(Ae),onChange:e=>at(e||null),changed:ut>0,onEditStyles:i,onUpdateStyle:k&&pt?()=>Z(!0):void 0}:void 0,font:f("font")?{value:R.font??"",styleValue:ye(y[0].base.fontKey)?.label,options:Qt.map(e=>({label:e.label,value:e.key})),onChange:e=>U("font",e||null)}:void 0,italic:f("italic")?{value:R.italic,styleValue:Hn(D,ue),onChange:e=>U("italic",e??null)}:void 0,cells:Ue(y[0].style,y[0].base,ce,q(H)).filter(e=>f(e.key)),align:f("align")?Bn(R,y[0].base.align,q(H),U):void 0,letterCase:f("letterCase")?{value:R.case??"",styleValue:y[0].base.case,onChange:e=>U("case",e||null)}:void 0}),lt&&k&&o(Vt,{styleName:mt,onCancel:()=>Z(!1),onConfirm:yt}),X&&Ee===null&&f("fixedSizeHint")&&o(Be,{children:l("Fixed size — the site’s Text setting doesn’t resize this.")}),Je(zn,e=>f(e)&&(e==="words"||(e==="sourceNote"?!!ee:e==="fixedSizeHint"?X&&Ee===null:X)))&&o($e,{})]})}function Bn(t,n,r,i){const a=qt("align",r),s=cn(t,r);return{value:t[a]??"",styleValue:s??n,onChange:g=>i(a,g||null)}}function Hn(t,n){return!n||!Array.isArray(t)?!1:t.find(i=>i?.id===n)?.values?.italic===!0}const nt={fontKey:"",sizePx:16,weight:400,lineRatio:1.4,letterEm:0,align:"left",case:"none",paddingPx:0};export{Fn as PartPanelBody,Qe as PartSourceNote,In as PartStyleSelect,Ln as default,Q as partFace};
|
|
1
|
+
"use client";import{jsx as n,Fragment as W,jsxs as g}from"react/jsx-runtime";import{useContext as vt,useEffect as me,useRef as Tt,useState as Be}from"react";import{FieldSelect as Nt,InspectorField as Rt,fieldShownInView as kt}from"efficient-easel/fields";import{InertHint as He,SettingsField as Ct}from"efficient-easel/panel";import{InspectorUpLevel as Y}from"efficient-easel/chrome";import{StylesIcon as Ot,TypeIcon as Et}from"efficient-easel/icons";import{useEasel as It}from"efficient-easel/easel";import{TextPartPanel as Ue}from"efficient-easel/copy";import{Button as zt,IconButton as Ft,Tooltip as _t}from"efficient-shell/ui";import{PartTextBox as At,partTextCells as We}from"./PartTextBox.js";import{SiteFields as ye}from"./SiteFields.js";import{usePartMotion as Vt}from"./usePartMotion.js";import{UiIcon as je}from"efficient-easel/draw/client";import{usePreviewHeader as Lt}from"../../render/components/PreviewHeaderContext.js";import{UpdateStyleDialog as Bt}from"./UpdateStyleDialog.js";import{ScreenDocumentContext as Ht}from"efficient-easel/screen/components/ScreenDocumentContext";import{hasStyleChange as Ut,partStyleToTextStyleValues as Wt,pushIntoStyle as jt,resolveTextStyles as De,styleIdOfRole as Dt}from"../../render/lib/text-styles/site-text-styles.js";import{useSiteTextStylesWriter as Kt}from"../lib/site-text-styles-writer.js";import{useThemeRowPersist as Gt}from"../lib/theme-row-persist.js";import{usePreviewDevice as Mt}from"efficient-easel/draw/client";import{shownTier as q}from"efficient-easel/screen/lib/document/device-fields";import{PART_PANEL_ROWS as Ke,partRowHasTabletValue as $t}from"../lib/document/part-panel-rows.js";import{usePartStyle as Xt}from"./PreviewPartStyleContext.js";import{say as l}from"../../format/lib/editor-words.js";import{readHidable as J,textFieldOffPage as Yt,textFieldPanelOnly as qt}from"../lib/document/controls.js";import{TEXT_FIELD_MARKER as Jt,viewKeyAt as Qt}from"efficient-easel/draw";import{useSectionOps as Zt}from"efficient-easel/screen/lib/document/use-section-ops";import{FONT_ROLES as en,FONT_ROLE_LABELS as Ge,fontOption as he,fontRoleOf as tn,fontsInPickerOrder as nn}from"../../format/lib/fonts.js";import{useFontRegistry as Me}from"../../render/components/SiteFontsContext.js";import{isMultilineKind as on,partPlaceholder as ln,typeInPlaceKind as sn}from"../../render/lib/document/part-text.js";import{partRowField as rn}from"../lib/document/part-row-field.js";import{decodePartKey as an,partPropsWithRowValue as cn,partRowValue as dn}from"../../render/lib/document/part-rows.js";import{followedStyleOf as $e,partAlignFollowed as un,propsWithPartStyleValue as B,propsWithoutPartStyle as fn,readPartStyle as ge,regionHasOwnLook as pn}from"../../render/lib/document/part-styles.js";import{partThemeColors as mn}from"../../format/lib/document/part-inks.js";import{styleKeyForPart as Xe}from"../../format/lib/sections/section-text-kinds.js";import{commitPartText as yn}from"../lib/document/part-typing.js";import{keysOnCanvas as hn,useCanvasTypingPart as gn}from"../lib/document/canvas-typing.js";import{useEaselHost as Sn}from"efficient-easel/screen/lib/host";import{SOURCE_LINES as xn,SOURCE_ACTIONS as bn,SOURCE_ACTION_LABEL as wn,partSourceNoteFor as Pn,partSourceOf as vn,sourceMenuIdOf as Tn,sourceSlugOf as Se}from"../../format/lib/document/source-bound-parts.js";import{encodePartId as Nn,holdsAuthoredText as Rn}from"../../render/lib/document/text-parts.js";import{regionsForSection as kn}from"../../format/lib/sections/section-text-regions.js";import{regionTakesSize as Cn,textRegionOfPartKey as On}from"../../format/lib/sections/text-regions.js";import{SameInEveryViewNote as Ye}from"./SameInEveryViewNote.js";function xe(t){return t?l(t):null}function qe(t){return t.kind==="role"?Ge[t.role]:t.kind==="custom"?"Custom":null}function En(t){const o=tn(t.role);return o?{kind:"role",role:o}:null}function In(t,o){if(!t)return{kind:"unread"};const{faceRole:s,base:r}=t;if(o[s]===r.fontKey)return{kind:"role",role:s};const a=Object.keys(o).filter(d=>o[d]===r.fontKey);return a.length===1?{kind:"role",role:a[0]}:{kind:"custom"}}function Q(t,o,s,r){return En(ge(t,o))??In(s,r)}function zn(t,o){if(!t.length)return null;const s=o(t[0]);return t.every(r=>o(r)===s)?s:null}function Je(t,o){return[{value:j,label:l("No style"),description:l("Section’s own")},...t.map(s=>({value:s.id,label:s.name,description:s.values.font?he(s.values.font,o)?.label:void 0}))]}const j="";function Fn({face:t,base:o,onPick:s}){const r=Me(),a=t.kind==="role"?t.role:j,d=[{label:l("No style"),value:j},...en.map(i=>({label:l(Ge[i]),value:i}))];return n(Nt,{ariaLabel:l("Style"),value:a,options:d,inline:!0,onChange:i=>s(i===j?null:i),renderOption:i=>i.value===j?g(W,{children:[n("span",{className:"es-fsel-label sf-part-style-keep",children:i.label}),n("span",{className:"sf-part-style-aside","aria-hidden":"true",children:l("Section’s own")})]}):n("span",{className:"es-fsel-label",style:{fontFamily:`var(--font-role-${i.value})`},children:i.label}),renderValue:()=>n("span",{style:{fontFamily:o?.fontKey?`var(${he(o.fontKey,r)?.cssVar})`:void 0,fontWeight:o?.weight},children:xe(qe(t))}),valueText:i=>xe(qe(t))??i?.label??""})}const Qe=["regionNote","regionStyle"],_n=Object.keys(Ke).filter(t=>!Qe.includes(t));function Ze(t,o){return!t.some(o)}function An({sectionName:t,onBack:o,textEditor:s,styleRow:r,children:a,tabs:d}){const i=g(W,{children:[s,r,a]});return g("div",{className:"sf-part-panel",children:[n(Y,{inline:!0,name:l(t),onSelect:o}),d?d(i):i]})}function et({source:t,slug:o,menuId:s}){const r=Sn(),a=bn[t],d=!a.needsSlug||!!o;return n("div",{className:"sf-note sf-note--source",children:g(He,{children:[l(xn[t]),d?g(W,{children:[" ",n(zt,{type:"button",variant:"link",size:"sm",onClick:()=>{a.type==="storefront-editor:open-menus"?r.send(a.type,{menuId:s??null}):o&&r.send(a.type,{slug:o})},children:l(wn)})]}):null]})})}const tt=4,Vn=120;function nt(t){return l("Every {part} in this section follows it. The face and the size change; the letter case is the section’s own and stays as it is.",{part:l(t.label).toLowerCase()})}function ot({region:t,sizePx:o,face:s,base:r,onFollowStyle:a,source:d,slug:i,onBack:N,shows:x,sizedStyle:b,ownLook:z}){const D=t.follows;return g("div",{className:"sf-note",children:[n("p",{children:n("strong",{children:l(t.label)})}),x("regionNote")&&!z&&n("p",{children:o?l("Its size follows Styles ▸ {follows} — {px}px right now.",{follows:l(D),px:Math.round(o)}):l("Its size follows Styles ▸ {follows}.",{follows:l(D)})}),b?g(W,{children:[b,x("regionStyle")&&n("p",{className:"es-field-hint",children:nt(t)})]}):a?x("regionStyle")?n(W,{children:n(Ct,{label:l("Style"),icon:n(Ot,{}),hint:nt(t),children:n(Fn,{face:s,base:r,onPick:a})})}):null:x("regionNote")&&n("p",{className:"es-field-hint",children:l("Only the size follows a site style. This section sets its own font, weight and letter case.")}),d&&x("sourceNote")?n(et,{source:d,slug:i}):null,Ze([...Qe,"sourceNote",...b?["fontSize"]:[]],R=>x(R)&&(R!=="sourceNote"||!!d))&&n(Ye,{}),n(Y,{inline:!0,name:l("Page"),onSelect:N})]})}function Ln({onBack:t}){return g("div",{className:"sf-note",children:[n("p",{children:n("strong",{children:l("This part is no longer here.")})}),n("p",{children:l("The section it belonged to has been changed or removed.")}),n(Y,{inline:!0,name:l("Page"),onSelect:t})]})}function Bn({onBack:t,partId:o,why:s}){return g("div",{className:"sf-note",children:[n("p",{children:n("strong",{children:l("This part's settings did not open.")})}),n("p",{children:l("The words are still on your page and nothing has been lost. The editor could not work out which control belongs to them, which is a fault on our side. Go back and click the section to open its settings instead.")}),n("p",{className:"sf-note-detail",children:g("code",{children:[o," — ",s]})}),n(Y,{inline:!0,name:l("Page"),onSelect:t})]})}function Hn({nodeId:t,propKey:o,onBack:s,onEditStyle:r}){const{getItemById:a,getSelectorForId:d,config:i}=It(e=>e),N=Zt(),x=gn(),{partStyle:b}=Xt(),{fonts:z,textStyles:D}=Lt(),R=Me(),Z=vt(Ht),be=!Z?.capabilities?.hasSiteTheme,{persist:st}=Gt({themeFromDocument:be,tokenRef:Z?.tokenRef,siteId:Z?.siteId??null}),k=Kt({themeFromDocument:be,persist:st}),[rt,ee]=Be(!1),H=Mt(),p=e=>(q(H)!=="tablet"||$t(e))&&kt(Ke[e],H),we=Tt(null),u=a(t),m=d(t),Pe=u?i.components[u.type]:void 0,{key:w,row:P}=an(o),ve=Pe?.fields?.[w],S=P?rn(ve,P):ve,F=Nn(t,o),f=u?.props??{},v=sn(S),Te=Yt(S),Ne=Rn(S),Re=u?vn(u.type):null,te=u?Pn(u.type,w):null,ne=P?dn(f[w],P):f[w],ke=!!P&&!(Array.isArray(f[w])&&P.index<f[w].length);me(()=>{if(hn(document))return;we.current?.querySelector(".es-copy [contenteditable='true'], .es-copy textarea, .sf-copybox textarea, .sf-copybox input")?.focus()},[F]);const[oe,Ce]=Be(0);me(()=>Ce(0),[F]);const le=!!u&&!ke&&(!m||!S);me(()=>{if(!le||oe>=tt)return;const e=setTimeout(()=>Ce(c=>c+1),Vn);return()=>clearTimeout(e)},[le,oe]);const it=le&&oe<tt,se=Vt(t,Xe(u?.type,o),"textPart");if(!u||ke)return n(Ln,{onBack:s});const K=kn(u.type),Oe=K?On(K,o):null;if(K&&Oe){const e=b?.partId===F?b:null,c=K[Oe],y=c.writable===!0&&!!m,T=E=>{m&&N.replaceComponent(m.zone,m.index,{...u,props:B(f,o,"role",E)})};if(y&&Cn(c)){const E=ge(f,o),Le=I=>{if(!m)return;let pe=f;for(const[wt,Pt]of Object.entries(I))pe=B(pe,o,wt,Pt??null);N.replaceComponent(m.zone,m.index,{...u,props:pe})},St=De(k.saved,k.old),xt=$e(E)??"",bt=We(E,e?.base??lt,Le,q(H)).filter(I=>I.key==="fontSize"&&p(I.key));return n(ye,{motion:se,body:n(ot,{region:c,sizePx:e?.base.sizePx??null,face:Q(f,o,e,z),base:e?.base??null,source:Re,slug:Se(f),onBack:s,shows:p,ownLook:pn(E),sizedStyle:n(Ue,{style:p("style")?{value:xt,options:Je(St,R),onChange:I=>Le(I?{textStyle:I}:{textStyle:null,role:null}),onEditStyles:r}:void 0,cells:bt})})})}return n(ye,{motion:se,body:n(ot,{region:c,sizePx:e?.base.sizePx??null,face:Q(f,o,e,z),base:e?.base??null,onFollowStyle:y?T:void 0,source:Re,slug:Se(f),onBack:s,shows:p})})}if(!m||!S)return it?n("div",{className:"sf-note","aria-busy":"true"}):n(Bn,{onBack:s,partId:F,why:m?"no field":"no selector"});const Ee=e=>{N.replaceComponent(m.zone,m.index,{...u,props:e})},re=e=>{if(J(e).hidden!==J(ne).hidden||!v){const y=P?cn(f,w,P,e):{...f,[w]:e};y&&Ee(y);return}yn({node:u,propKey:o,kind:v,zone:m.zone,index:m.index},J(e).text,N.replaceComponent)},at=ne,_=b?.partId===F?b:null,A=_?.styleOwner,G=A?a(A.owner):null,ie=A&&G?d(A.owner):null,ae=!!(A&&G&&ie),V=ae?G.props??{}:f,ce=ae?e=>N.replaceComponent(ie.zone,ie.index,{...G,props:e}):Ee,M=ae?A.kind:Xe(u?.type,o),C=ge(V,M),h=[{partKey:M,face:Q(V,M,_,z),sizeGroup:_?.sizeGroup??null,base:_?.base??lt,style:C}],Ie=zn(h,e=>e.sizeGroup),ct=mn(_?.inks),U=(e,c)=>{let y=V;for(const T of h)y=B(y,T.partKey,e,c);ce(y)},dt=e=>e?U("textStyle",e):de({textStyle:null,role:null}),de=e=>{let c=V;for(const y of h)for(const[T,E]of Object.entries(e))c=B(c,y.partKey,T,E??null);ce(c)},ue=v==="text"||v==="textarea",{text:ze,hidden:L}=J(ne),$=S?.[Jt]?.label??o,Fe=L?l("Show {label} on the slide",{label:l($)}):l("Hide {label} on the slide",{label:l($)}),_e=g("div",{className:"sf-field-head",children:[n(Et,{}),n("span",{className:"sf-field-label sf-field-label--inline",children:l($)}),ue&&n(_t,{content:Fe,children:n(Ft,{"aria-pressed":L,"aria-label":Fe,onClick:()=>re({text:ze,hidden:!L}),children:L?n(je,{name:"eye-off",size:14}):n(je,{name:"eye",size:14})})})]}),X=!Te&&Ne,ut=!!v&&(qt(S)||Te||L||!Ne),Ae=Q(V,M,_,z),ft=Ae.kind==="role"?Ae.role:null,fe=$e(C)??Dt(ft),Ve=De(k.saved,k.old),pt=Object.entries(C).filter(([e,c])=>e!=="role"&&e!=="textStyle"&&c!==void 0).length,mt=()=>{let e=V;for(const c of h){const{role:y,textStyle:T}=c.style;e=fn(e,c.partKey),y&&(e=B(e,c.partKey,"role",y)),T&&(e=B(e,c.partKey,"textStyle",T))}ce(e)},O=fe,yt=Ut(h[0].style),ht=O?Ve.find(e=>e.id===O)?.name??O:"",gt=()=>{ee(!1),O&&(k.write(jt({saved:k.saved,old:k.old,styleId:O,values:Wt(h[0].style)}),!0),mt())};return g(An,{sectionName:Pe?.label??u.type,onBack:s,tabs:e=>n(ye,{motion:se,body:e}),textEditor:p("words")?n("div",{ref:we,className:"sf-part-text",children:ut?n(At,{text:ze,onTextChange:e=>re(ue?{text:e,hidden:L}:e),multiline:on(v),markup:v!=="plainText",styled:!1,style:h[0].style,base:h[0].base,setValue:de,colors:ct,placeholder:xe(ln(S))??void 0,ariaLabel:l($),head:_e,typedOnCanvas:x===F}):v?ue?_e:null:n(Rt,{field:S,name:o,value:at,onChange:re,id:`sf-part-${t}-${o}`})}):void 0,children:[te&&p("sourceNote")&&n(et,{source:te,slug:Se(f),menuId:Tn(f)}),X&&n(Ue,{style:p("style")?{value:fe??"",options:Je(Ve,R),onChange:e=>dt(e||null),changed:pt>0,onEditStyles:r,onUpdateStyle:O&&yt?()=>ee(!0):void 0}:void 0,font:p("font")?{value:C.font??"",styleValue:he(h[0].base.fontKey,R)?.label,options:nn(R).map(e=>({label:e.label,value:e.key})),onChange:e=>U("font",e||null)}:void 0,italic:p("italic")?{value:C.italic,styleValue:Wn(D,fe),onChange:e=>U("italic",e??null)}:void 0,cells:We(h[0].style,h[0].base,de,q(H)).filter(e=>p(e.key)),align:p("align")?Un(C,h[0].base.align,q(H),U):void 0,letterCase:p("letterCase")?{value:C.case??"",styleValue:h[0].base.case,onChange:e=>U("case",e||null)}:void 0}),rt&&O&&n(Bt,{styleName:ht,onCancel:()=>ee(!1),onConfirm:gt}),X&&Ie===null&&p("fixedSizeHint")&&n(He,{children:l("Fixed size — the site’s Text setting doesn’t resize this.")}),Ze(_n,e=>p(e)&&(e==="words"||(e==="sourceNote"?!!te:e==="fixedSizeHint"?X&&Ie===null:X)))&&n(Ye,{})]})}function Un(t,o,s,r){const a=Qt("align",s),d=un(t,s);return{value:t[a]??"",styleValue:d??o,onChange:i=>r(a,i||null)}}function Wn(t,o){return!o||!Array.isArray(t)?!1:t.find(r=>r?.id===o)?.values?.italic===!0}const lt={fontKey:"",sizePx:16,weight:400,lineRatio:1.4,letterEm:0,align:"left",case:"none",paddingPx:0};export{An as PartPanelBody,et as PartSourceNote,Fn as PartStyleSelect,Hn as default,Q as partFace};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type PartNeedle } from "../../render/lib/document/text-parts.js";
|
|
3
3
|
import { type ShownDeclarations, type PartStyleBase, type PartStyles } from "../../render/lib/document/part-styles.js";
|
|
4
|
-
import { type FontRole } from "../../format/lib/fonts.js";
|
|
4
|
+
import { type FontRegistry, type FontRole } from "../../format/lib/fonts.js";
|
|
5
5
|
import { type TypeGroup } from "../../format/lib/theme.js";
|
|
6
6
|
import { type PartMotion } from "../../render/lib/animation/part-motion.js";
|
|
7
7
|
export declare function styleTagsOf(element: HTMLElement): {
|
|
8
8
|
faceRole: FontRole;
|
|
9
9
|
sizeGroup: TypeGroup | null;
|
|
10
10
|
};
|
|
11
|
-
export declare function measureStyleBase(element: HTMLElement, shown?: ShownDeclarations): PartStyleBase;
|
|
11
|
+
export declare function measureStyleBase(element: HTMLElement, shown?: ShownDeclarations, fonts?: FontRegistry): PartStyleBase;
|
|
12
12
|
export default function PreviewPartAnchors({ needles, styles, motions, type, sizeCaps, children, }: {
|
|
13
13
|
needles: PartNeedle[];
|
|
14
14
|
styles: PartStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as j}from"react/jsx-runtime";import{readInks as
|
|
1
|
+
"use client";import{jsx as j}from"react/jsx-runtime";import{readInks as q}from"../../format/lib/document/part-inks.js";import{useEffect as U,useRef as F}from"react";import{markOverlayPortal as V}from"../../format/lib/document/overlay-portal.js";import{usePreviewParts as Q}from"efficient-easel/draw/client";import{usePartStyle as X}from"./PreviewPartStyleContext.js";import{usePreviewDevice as Z}from"efficient-easel/draw/client";import{shownTier as ee}from"efficient-easel/screen/lib/document/device-fields";import{decodePartId as C,encodePartId as te}from"efficient-easel/draw";import{BLOCK_ATTRIBUTE as re}from"efficient-easel/canvas";import{engagePartAnchors as oe}from"../lib/document/part-anchors.js";import{PART_ATTR as R,PART_STYLE_KIND_ATTR as A,PART_STYLE_OWNER_ATTR as ne,partStyleOwnerOf as O}from"../../render/lib/document/text-parts.js";import{PART_STYLE_PROPERTIES as D,applyPartStyles as k,blockCapsPartSize as z,blockDrawsTextStyle as J,partFontKeyOf as se,partShownDeclarations as ie,partStyleBase as ae,partStyleSource as le,storedPartStyle as pe}from"../../render/lib/document/part-styles.js";import{POOL_FONT_REGISTRY as ce,fontRoleOfClassName as fe,styleRoleOfClassName as ue}from"../../format/lib/fonts.js";import{useFontRegistry as me}from"../../render/components/SiteFontsContext.js";import{typeScaleGroupOfClassName as L}from"../../format/lib/theme.js";import{styleKeyForPart as h}from"../../format/lib/sections/section-text-kinds.js";import{NO_MOTIONS as de,PART_HOST_ATTR as ye}from"../../render/lib/animation/part-motion.js";import{paintPartMotion as Se}from"../lib/document/part-motion-canvas.js";import{viewOfTier as Te}from"../../format/lib/content/view-tier.js";function ge(c){let o=null,f=null;for(let t=c;t&&(o===null||f===null);t=t.parentElement){const a=t.getAttribute("class");o??=ue(a),f??=L(a)}return{faceRole:o??"body",sizeGroup:f}}function M(c,o={},f=ce){const t=c.style,a={};for(const r of D)a[r]=t[r]??"",t[r]="";o.fontFamily&&(t.fontFamily=o.fontFamily),o.fontSize&&(t.fontSize=o.fontSize);const n=getComputedStyle(c),g=getComputedStyle(c.ownerDocument.documentElement),l=ae({fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.textAlign,textTransform:n.textTransform,paddingTop:n.paddingTop},se(n.fontFamily,r=>g.getPropertyValue(r),f));for(const r of D)t[r]=a[r];return l}function Oe({needles:c,styles:o,motions:f=de,type:t,sizeCaps:a,children:n}){const g=F(null),{selectedPartId:l}=Q(),{setPartStyle:r}=X(),S=ee(Z()),u=me(),w=JSON.stringify(c),E=JSON.stringify(o),_=JSON.stringify(f),W=F(new Map);return U(()=>{const T=g.current;if(!T)return;const v=[],N=()=>T.parentElement,B=p=>{const i=N();if(!i)return null;const d=new MutationObserver(p);return d.observe(i,{attributes:!0,attributeFilter:[re]}),()=>d.disconnect()},Y=p=>{const i=new MutationObserver(p);return i.observe(T,{childList:!0,subtree:!0,characterData:!0}),()=>i.disconnect()};let m=[];v.push(()=>{for(const p of m)p();m=[]});const G=JSON.parse(w),P=JSON.parse(E),H=JSON.parse(_),$=oe(T,G,N,B,(p,i,d)=>{for(const e of m)e();m=[];const K=[];for(const e of d){const s=e,y=V(s);y&&m.push(y),s.getAttribute(R)===l&&K.push(s)}const x=le(i,l,K,e=>fe(e)!==null||L(e)!==null);if(x&&l){const e=x,s=C(l)?.propKey??"",y=O(e)?{}:ie(pe(P,h(t,s)),S,{blockDrawsStyle:J(t,s),sizeCap:z(a,s),fonts:u});r({partId:l,...ge(e),base:M(e,y,u),inks:q(e),...(()=>{const I=O(e);return I?{styleOwner:I}:{}})()})}k(d.filter(e=>!O(e)).map(e=>({element:e,partId:e.getAttribute(R)??""})),P,e=>M(e,void 0,u),e=>h(t,e),void 0,S,e=>J(t,e),e=>z(a,e),u);const b=[...T.querySelectorAll(`[${ne}="${CSS.escape(i)}"][${A}]`)];b.length&&k(b.map(e=>({element:e,partId:te(i,e.getAttribute(A)??"")})),P,void 0,e=>e,void 0,S,void 0,void 0,u),m.push(Se([...d.filter(e=>!O(e)).map(e=>{const s=e,y=C(s.getAttribute(R)??"")?.propKey??"";return{element:s,partKey:h(t,y)}}),...b.map(e=>({element:e,partKey:e.getAttribute(A)??""}))],e=>H[e],Te(S),W.current))},Y);return()=>{$();for(const p of v)p()}},[w,E,_,l,r,S,t,u]),j("div",{ref:g,[ye]:"",style:{display:"contents"},children:n})}export{Oe as default,M as measureStyleBase,ge as styleTagsOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as _}from"react/jsx-runtime";import{useEffect as I,useRef as O}from"react";import{markOverlayPortal as w}from"../../format/lib/document/overlay-portal.js";import{measureStyleBase as C,styleTagsOf as D}from"./PreviewPartAnchors.js";import{shownTier as K}from"efficient-easel/screen/lib/document/device-fields";import{usePreviewDevice as N,usePreviewParts as j}from"efficient-easel/draw/client";import{usePartStyle as k}from"./PreviewPartStyleContext.js";import{useFontRegistry as B}from"../../render/components/SiteFontsContext.js";import{REGION_PART_ATTR as z,encodePartId as G}from"../../render/lib/document/text-parts.js";import{TEXT_REGION_ATTR as F,textRegionOfAttr as X,textRegionPartKey as q}from"../../format/lib/sections/text-regions.js";import{regionsForSection as J}from"../../format/lib/sections/section-text-regions.js";import{TEXT_STYLE_ATTR as s,blockCapsPartSize as L,isTextStyleId as Y,regionCanvasDeclarations as $,regionCanvasRestore as H,regionSheetStyle as M,regionShownDeclarations as Q}from"../../render/lib/document/part-styles.js";function U({nodeId:f,sectionType:y,partStyles:u,sizeCaps:p,children:b}){const S=O(null),{selectedPartId:d}=j(),{setPartStyle:g}=k(),l=K(N()),o=B(),h=JSON.stringify([u??null,p??null]);return I(()=>{const T=S.current,r=J(y);if(!T||!f||!r)return;const a=[],A=Array.from(T.querySelectorAll(`[${F}]`));for(const t of A){const i=X(r,t.getAttribute(F));if(!i)continue;const P=w(t);P&&a.push(P);const c=q(i),m=G(f,c);t.setAttribute(z,m);const n=u?.[c];if(r[i].sized&&M(n)){const e=$(n,l,{sizeCap:L(p,c),fonts:o}),x={fontFamily:t.style.fontFamily,fontSize:t.style.fontSize},R=t.getAttribute(s);e.fontFamily&&(t.style.fontFamily=e.fontFamily),e.fontSize&&(t.style.fontSize=e.fontSize);const E={fontFamily:e.fontFamily?t.style.fontFamily:void 0,fontSize:e.fontSize?t.style.fontSize:void 0},v=n?.textStyle;Y(v)&&t.setAttribute(s,v),a.push(()=>{H(t.style,x,E),R===null?t.removeAttribute(s):t.setAttribute(s,R)})}if(m===d){const e=C(t,Q(n,r[i],l,o),o);g({partId:m,...D(t),base:e})}}return()=>{for(const t of a)t();for(const t of A)t.removeAttribute(z)}},[f,y,d,g,l,h,o]),_("div",{ref:S,style:{display:"contents"},children:b})}export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as u}from"react/jsx-runtime";import{useMemo as p}from"react";import{TextStyleItem as m,TextStylesGroup as g}from"efficient-easel/text-styles";import{siteTextStyleFonts as y}from"./SiteTextStylesField.js";import{useFontRegistry as d}from"../../render/components/SiteFontsContext.js";import{say as f}from"../../format/lib/editor-words.js";const c=["font","size","weight","emphasis"],x=500;function z({font:i,size:o,weight:t,italic:n}){const e={font:i};return o!==null&&(e.size=o),t!==null&&(e.weight=t),n!==null&&(e.italic=n),{id:"accent",kind:"heading",name:f("Emphasis"),values:e}}function C(i,o){const t=[],n=i.values,e=o.values;return e.font!==n.font&&e.font!==void 0&&t.push({key:"font",value:e.font}),e.size!==n.size&&t.push({key:"size",value:e.size??null}),e.weight!==n.weight&&t.push({key:"weight",value:e.weight??null}),e.italic!==n.italic&&t.push({key:"italic",value:e.italic??null}),t}function S(i){const{headingWeight:o,open:t,onOpenChange:n,onChange:e,withoutSize:r=!1}=i,l=z(i),a=d(),h=p(()=>y(a),[a]);return u(g,{label:f("Emphasis"),children:u(m,{style:l,fonts:h,settings:r?c.filter(s=>s!=="size"):c,auto:["size"],fallback:()=>({weight:o??x}),open:t,onOpenChange:n,onChange:s=>C(l,s).forEach(e)})})}export{C as accentChanges,z as accentTextStyle,S as default};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type TextStyleColour, type TextStyleColourNameOf, type TextStyleFont } from "efficient-easel/text-styles";
|
|
2
|
+
import { type FontRegistry } from "../../format/lib/fonts.js";
|
|
2
3
|
import { type OldSiteText, type StoredTextStyle } from "../../render/lib/text-styles/site-text-styles.js";
|
|
4
|
+
export declare function siteTextStyleFonts(registry?: FontRegistry): TextStyleFont[];
|
|
3
5
|
export declare const SITE_FONTS: TextStyleFont[];
|
|
4
6
|
export default function SiteTextStylesField({ saved, old, colours, colourNameOf, sizeOf, onChange, openId, onOpenChange, readOnly, withoutSize, onPick, }: {
|
|
5
7
|
saved: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as _}from"react/jsx-runtime";import{useMemo as E,useState as C}from"react";import{TextStylesList as F}from"efficient-easel/text-styles";import{POOL_FONT_REGISTRY as L,fontsInPickerOrder as k}from"../../format/lib/fonts.js";import{useFontRegistry as N}from"../../render/components/SiteFontsContext.js";import{viewOfTier as b}from"../../format/lib/content/view-tier.js";import{usePreviewDevice as A}from"efficient-easel/draw/client";import{applyListChange as G,resolveTextStyles as P,toPanelStyles as z}from"../../render/lib/text-styles/site-text-styles.js";const d=["font","color","size","weight","emphasis","lineSpacing","letterSpacing","paragraphSpacing","letterCase","largestSize"],R=["size","lineSpacing","letterSpacing","letterCase"],j=500;function u(o=L){return k(o).map(t=>({value:t.key,label:t.label,family:`var(${t.cssVar})`,italic:t.italicLoaded}))}const $=u();function D({saved:o,old:t,colours:m,colourNameOf:S,sizeOf:a,onChange:g,openId:l,onOpenChange:T,readOnly:y=!1,withoutSize:O=!1,onPick:c}){const h=A(),f=N(),v=E(()=>u(f),[f]),[x,w]=C(null),s=P(o,t),r=b(h),p=z(s,a,r);return _(F,{styles:p,onChange:e=>g(G({saved:o,old:t,cur:p,next:e,sizeOf:a,panelView:r})),fonts:v,colours:m,colourNameOf:S,settings:O?d.filter(e=>e!=="size"):d,auto:R,openId:l===void 0?x:l,onOpenChange:T??w,readOnly:y,device:r,onPick:c?e=>{const n=s.find(i=>i.id===e.id);n&&c(n)}:void 0,fallback:e=>{const n=s.find(I=>I.id===(e.kind==="heading"?"heading-1":"body-1")),i={};return n?.values.font&&e.id!==n.id&&(i.font=n.values.font),e.kind==="heading"&&(i.weight=j),i}})}export{$ as SITE_FONTS,D as default,u as siteTextStyleFonts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as o}from"react/jsx-runtime";import X from"./WebsiteHintsProvider.js";import{useCallback as H,useEffect as P,useMemo as l,useRef as Z,useState as f}from"react";import x from"next/dynamic";import"efficient-easel/easel.css";import"efficient-easel/shell.css";import"efficient-easel/rail.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import"efficient-easel/pick.css";import"efficient-easel/copy.css";import"efficient-easel/gold.css";import"efficient-easel/text-styles.css";import"efficient-easel/menu.css";import"efficient-easel/chrome.css";import"efficient-easel/tree.css";import"efficient-easel/screen.css";import"./storefront-editor.css";import{buildConfig as $}from"../lib/document/build-config.js";import{withTemplateMediaPlaceholders as ee}from"../../format/lib/document/templateFields.js";import{setEditorPageSlug as B}from"../../format/lib/document/editor-page-context.js";import{ScreenDocumentContext as te}from"efficient-easel/screen/components/ScreenDocumentContext";import{PreviewHeaderProvider as re}from"../../render/components/PreviewHeaderContext.js";import{PreviewTickerProvider as oe}from"../../render/components/PreviewTickerContext.js";import{PreviewHeroPartProvider as ie}from"../../render/components/PreviewHeroPartContext.js";import{PreviewPartsProvider as ne}from"efficient-easel/draw/client";import{CanvasPartsBridge as se}from"./CanvasPartsBridge.js";import{PreviewLocationPartProvider as de}from"../../render/components/PreviewLocationPartContext.js";import{PreviewPartStyleProvider as ae}from"./PreviewPartStyleContext.js";import{sectionTemplates as
|
|
1
|
+
"use client";import{jsx as o}from"react/jsx-runtime";import X from"./WebsiteHintsProvider.js";import{useCallback as H,useEffect as P,useMemo as l,useRef as Z,useState as f}from"react";import x from"next/dynamic";import"efficient-easel/easel.css";import"efficient-easel/shell.css";import"efficient-easel/rail.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import"efficient-easel/pick.css";import"efficient-easel/copy.css";import"efficient-easel/gold.css";import"efficient-easel/text-styles.css";import"efficient-easel/menu.css";import"efficient-easel/chrome.css";import"efficient-easel/tree.css";import"efficient-easel/screen.css";import"./storefront-editor.css";import{buildConfig as $}from"../lib/document/build-config.js";import{withTemplateMediaPlaceholders as ee}from"../../format/lib/document/templateFields.js";import{setEditorPageSlug as B}from"../../format/lib/document/editor-page-context.js";import{ScreenDocumentContext as te}from"efficient-easel/screen/components/ScreenDocumentContext";import{PreviewHeaderProvider as re}from"../../render/components/PreviewHeaderContext.js";import{PreviewTickerProvider as oe}from"../../render/components/PreviewTickerContext.js";import{PreviewHeroPartProvider as ie}from"../../render/components/PreviewHeroPartContext.js";import{PreviewPartsProvider as ne}from"efficient-easel/draw/client";import{CanvasPartsBridge as se}from"./CanvasPartsBridge.js";import{PreviewLocationPartProvider as de}from"../../render/components/PreviewLocationPartContext.js";import{PreviewPartStyleProvider as ae}from"./PreviewPartStyleContext.js";import{sectionTemplates as M}from"efficient-easel/screen/lib/section-templates";import{saveSectionTemplate as L}from"../lib/editor-document-adapter.js";import{nodeToDoc as me,docToNode as R}from"efficient-easel/screen/lib/document/section-doc";import{newNodeId as ce}from"efficient-easel/draw";import{migrateRenamedProps as le}from"../../format/lib/document/renamed-props.js";import{buildSlotSeedChildren as fe}from"../../render/lib/document/slot-specs.js";import{FOOTER_TYPE as ue,buildDefaultFooterBlocks as pe}from"../lib/document/footer-blocks.js";import{NO_BRIDGED_CAPABILITIES as ve,useAdminBridge as ge}from"efficient-easel/screen/lib/admin-bridge";import{useEaselHost as he}from"efficient-easel/screen/lib/host";import{ChromeWrap as Pe}from"efficient-easel/screen/lib/host-chrome";import{sessionRegistry as Se}from"efficient-easel/screen/lib/session";import{useEaselSession as Ee}from"efficient-easel/screen/lib/session-context";import{say as F}from"../../format/lib/editor-words.js";import{retargetWhenSaved as ye}from"../../format/lib/section-retarget.js";import{routeSharedHostMessage as Te}from"efficient-easel/screen/lib/host-inbound";import{routeWebsiteHostMessage as we}from"../../format/lib/website-host-inbound.js";import{DEFAULT_THEME_MODE as S,THEME_MODE_KEY as Ce}from"../../format/lib/theme.js";import{makeSitePageAdapter as U}from"../lib/editor-document-adapter.js";import{documentPermissions as Ne}from"efficient-easel/edit-lock";import{useAutosave as be}from"efficient-easel/autosave";import{saveStatusOf as ke}from"efficient-easel/screen/lib/document-switch";import{blocksOf as Ae}from"../lib/website-session.js";import{parseOption as Me}from"efficient-shell/format";import{LoadingSpinner as Oe}from"efficient-shell/ui";import{THEME_MODES as Ie}from"../../format/lib/theme.js";const De=x(()=>import("./SiteEditorProvider.js"),{ssr:!1}),_e=x(()=>import("efficient-easel/screen/components/SectionScreenShell"),{ssr:!1}),W="Hero",Y="Untitled section";function He(s,E){const d=E.components,r=d[s]?s:W,y=d[r]?.defaultProps??{},i=fe(r,u=>d[u]?.defaultProps??{}),n=r===ue?{blocks:pe()}:null;return{type:r,props:{id:ce(r),...y,...i?{[i.slot]:i.children}:null,...n}}}function xe(){if(typeof window>"u")return S;try{const s=window.localStorage.getItem(Ce);return Me(Ie,S,s)}catch{return S}}function Be({id:s,initialType:E,initialName:d=Y}){const[r,y]=f(s),i=Z(r);P(()=>{i.current=r},[r]);const n=he(),[u,j]=f(E),[O,K]=f(d),[a,T]=f(void 0),[G,q]=f(S),{token:w,tokenRef:I}=ge({onMessage:e=>{if(we(e)||Te(e))return;const t=e;if(t?.type==="storefront-editor:navigate"&&t.target?.kind==="section"&&t.target.id){const A=t.target.id;if(A===i.current)return;const Q=t.target.type,V=t.target.name;ye(N,()=>{j(Q),K(V||Y),y(A),n.address.show({kind:"section",id:A})},()=>n.send("storefront-editor:save-failed"))}}}),C=be({save:e=>L(M,e.id,e.node).then(()=>{}),onFailure:(e,t)=>{t===0&&n.send("storefront-editor:save-failed")}}),{state:p,push:D,flush:N}=C;P(()=>q(xe()),[]);const m=Ee(),v=m.usesBridgedToken?!!w:!0,g=l(()=>$(Se(m),Ae(m)),[m]);P(()=>{if(!v)return;let e=!1;return T(void 0),M.ensure(r,O,He(u??W,g)).then(t=>!e&&T(t.node)).catch(()=>!e&&T(null)),()=>{e=!0}},[r,u,O,v,g]);const b=H(e=>{n.send("storefront-editor:dirty");const t=R(e);t&&D({id:i.current,node:t})},[D,n]),h=n.send,_=H(async e=>{try{return await e(I.current??""),!0}catch{return h("storefront-editor:save-failed"),!1}},[h]),z=l(()=>ee(g,!0),[g]);P(()=>(B(null),()=>B(null)),[]);const c=l(()=>a?le(me(a)):null,[a]),k=l(()=>({target:{kind:"page",slug:""},adapter:U(void 0),capabilities:U(void 0).capabilities,templateId:null,currentSlug:"",currentKind:null,siteId:null,ready:v,token:w,tokenRef:I,notifyParent:h,runAuthed:_,docId:r,data:c,getLiveData:()=>c,error:null,redirecting:!1,saveStatus:ke(p),saveState:p,autoSaveEnabled:!0,autoSaveStoppedByConflict:!1,hasUnsavedEdits:p.pending,toggleAutoSave:()=>{},retrySave:()=>{C.retryNow()},onChange:b,flushSave:N,onPublish:async e=>{const t=R(e);t&&await L(M,i.current,t)},bridgeCapabilities:ve,access:{kind:"editing"},readOnly:!1,takeOverEditing:()=>{},viewReadOnly:()=>{},saveConflict:null,reloadFromServer:()=>{},navigate:()=>{},pendingNav:null,cancelPendingNav:()=>{},discardAndNavigate:()=>{},saveAndNavigate:async()=>{}}),[r,v,w,h,_,c,p,b,N,C.retryNow]),J=l(()=>Ne(!k.readOnly),[k.readOnly]);return a===void 0?o(Oe,{label:F("Loading…")}):a===null||!c?o("div",{className:"sf-msg sf-msg--error",children:F("Couldn’t open this section.")}):o(te.Provider,{value:k,children:o(X,{children:o(re,{themeMode:G,chromePlaceholder:!0,children:o(Pe,{wrap:m.chrome?.wrap,surface:"section",children:o(oe,{children:o(ie,{children:o(ne,{children:o(de,{children:o(se,{children:o(ae,{children:o(De,{config:z,data:c,onChange:b,permissions:J,children:o(_e,{})},r)})})})})})})})})})})}export{Be as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as Ct}from"react/jsx-runtime";import{useCallback as o,useEffect as f,useMemo as _t,useRef as g,useState as r}from"react";import"efficient-easel/easel.css";import"efficient-easel/shell.css";import"efficient-easel/rail.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import"efficient-easel/pick.css";import"efficient-easel/copy.css";import"efficient-easel/gold.css";import"efficient-easel/text-styles.css";import"efficient-easel/menu.css";import"efficient-easel/chrome.css";import"efficient-easel/tree.css";import"efficient-easel/drag.css";import"efficient-easel/screen.css";import"./storefront-editor.css";import{useHostConfig as Pt}from"../lib/document/host-config.js";import{ChromeWrap as Tt}from"efficient-easel/screen/lib/host-chrome";import{refreshSiteLiveState as Et}from"../lib/site-live-state.js";import{holdSiteWrites as yt}from"../../format/lib/site-writes.js";import{backendOf as k}from"../lib/website-session.js";import{useEaselSession as Gt}from"efficient-easel/screen/lib/session-context";import{withSiteBlockGapFields as vt}from"../../format/lib/document/site-gap-fields.js";import{withTemplateMediaPlaceholders as Ht}from"../../format/lib/document/templateFields.js";import{setEditorPage as he}from"../../format/lib/document/editor-page-context.js";import{EditorPagePathProvider as Wt}from"./EditorPagePathProvider.js";import{AddPageOnOpen as kt}from"./AddPageOnOpen.js";import{resolveSiteName as Rt}from"../../format/lib/content/site-name.js";import{normalizeSiteGutter as Bt,normalizeSiteGutterPhone as Ft,normalizeSiteWidth as It}from"../../format/lib/content/page-width.js";import{siteLengthNumber as w,siteLengthUnitsOfRow as Dt}from"../../format/lib/content/css-length.js";import{normalizeSiteBackground as ue}from"../../format/lib/content/section-width.js";import{normalizeSiteBlockGap as le}from"../../format/lib/content/container-gap.js";import Ot,{DocumentScreen as Mt}from"efficient-easel/screen/components/ScreenMount";import bt from"./WebsiteHintsProvider.js";import{useScreenDocument as Nt}from"efficient-easel/screen/components/ScreenDocumentContext";import{PreviewHeaderProvider as xt,siteThemeRow as Ut,themeEdited as At,themeSeeded as Lt}from"../../render/components/PreviewHeaderContext.js";import{PreviewFooterProvider as zt}from"./PreviewFooterContext.js";import{usePinnedChromeState as Yt}from"./usePinnedChromeState.js";import{PreviewChatProvider as jt,DEFAULT_CHAT_PREVIEW as Kt}from"./PreviewChatContext.js";import{PreviewSocialProvider as Vt}from"../../render/components/PreviewSocialContext.js";import{useSocialSettings as Xt}from"./useSocialSettings.js";import{PreviewSurfaceProvider as Zt}from"./PreviewSurfaceContext.js";import{WEBSITE_ADDRESSING as qt}from"../lib/website-document-addressing.js";import{PreviewTickerProvider as Jt}from"../../render/components/PreviewTickerContext.js";import{PreviewHeroPartProvider as Qt}from"../../render/components/PreviewHeroPartContext.js";import{PreviewPartsProvider as $t}from"efficient-easel/draw/client";import{CanvasPartsBridge as er}from"./CanvasPartsBridge.js";import{PreviewLocationPartProvider as tr}from"../../render/components/PreviewLocationPartContext.js";import{PreviewPartStyleProvider as rr}from"./PreviewPartStyleContext.js";import{CORNER_STYLE_TO_PX as or,DEFAULT_HEADING_COMPRESSION as nr,DEFAULT_HEADING_TYPOGRAPHY as ir,DEFAULT_SWITCH_SHOWN as R,DEFAULT_SIZES as ar,DEFAULT_THEME_MODE as T,normalizeCornerRadius as cr,normalizeCornerStyle as sr,normalizeCardShadow as dr,normalizeCardGap as hr,normalizeHoverEffect as ur,IDENTITY_CARD_GAP as me,IDENTITY_CARD_SHADOW as lr,IDENTITY_HOVER_EFFECT as mr,THEME_MODE_KEY as pe,THEME_STORAGE_KEY as pr,THEME_SWITCH_HIDE as Se,THEME_SWITCH_KEY as B}from"../../format/lib/theme.js";import{pictureShadowColor as Sr}from"efficient-easel/screen/lib/document/shadow-values";import{DEFAULT_FONTS as fr}from"../../format/lib/fonts.js";import{WEBSITE_SCREEN as gr}from"./WebsiteScreenParts.js";import{routeWebsiteHostMessage as wr}from"../../format/lib/website-host-inbound.js";import{siteTextFromRow as Cr}from"../../render/lib/text-styles/site-text-styles.js";import{wordStylesFromRow as _r}from"../../format/lib/word-styles.js";import{chatPreviewFrom as Pr}from"./PreviewChatContext.js";import{parseOption as Tr}from"efficient-shell/format";import{THEME_MODES as Er}from"../../format/lib/theme.js";const yr=()=>{if(typeof window>"u")return T;try{const d=window.localStorage.getItem(pe);return Tr(Er,T,d)}catch{return T}},fe=d=>{if(!(typeof window>"u"))try{window.localStorage.setItem(pe,d)}catch{}},Gr=()=>{if(typeof window>"u")return R;try{return window.localStorage.getItem(B)!==Se}catch{return R}},vr=()=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(pr)}catch{}},ge=d=>{if(!(typeof window>"u"))try{d?window.localStorage.removeItem(B):window.localStorage.setItem(B,Se)}catch{}};function Hr(){const{adapter:d,capabilities:s,templateId:F,ready:_,token:h,siteId:c,currentSlug:I,currentKind:D}=Nt();f(()=>(he(I,D),()=>he(null,null)),[I,D]);const we=Yt(d?.pinnedChrome)?.rootProps??null,E=s.placeholderFrames,[Ce,O]=r(null),[_e,M]=r("");f(()=>{const e=d.templateName;if(!_||!F||!e){M("");return}let i=!1;return e().then(u=>!i&&M(u??"")).catch(()=>{}),()=>{i=!0}},[_,h,F,d]);const[Pe,y]=r(T),[Te,G]=r(R),[b,N]=r({value:{selected:0,themes:[]},readFor:null}),Ee=b.value,[ye,x]=r(fr),[Ge,U]=r(ar),[ve,A]=r(null),[He,L]=r(nr),[We,z]=r(null),[ke,Y]=r(null),[Re,j]=r(me),[Be,K]=r(null),[Fe,V]=r(null),[Ie,X]=r(null),[De,Z]=r(null),[v,q]=r(null),[H,J]=r(null),[Oe,Q]=r({}),Me=o(e=>Q(i=>({...i,...e})),[]),l=Gt(),$=Pt(),be=_t(()=>vt(Ht($,E),v,H),[$,E,v,H]),[Ne,ee]=r(ir),[xe,te]=r(null),[Ue,re]=r(null),[Ae,oe]=r(null),[Le,ne]=r(null),[ze,ie]=r(null),ae=g(null),n=g(!1);f(()=>{y(yr()),G(Gr())},[]);const Ye=o(e=>{n.current=!0,vr(),fe(e),y(e)},[]),je=o(e=>{n.current=!0,ge(e),G(e)},[]),Ke=o(e=>{n.current=!0,N(i=>At(i,e,c??""))},[c]),Ve=o(e=>{n.current=!0,x(e)},[]),Xe=o(e=>{n.current=!0,U(e)},[]),Ze=o(e=>{n.current=!0,A(e)},[]),qe=o(e=>{n.current=!0,L(e)},[]),Je=o(e=>{n.current=!0,z(e)},[]),Qe=o(e=>{n.current=!0,Y(e)},[]),$e=o(e=>{n.current=!0,j(e)},[]),et=o(e=>{n.current=!0,K(e)},[]),tt=o(e=>{n.current=!0,ee(e)},[]),[rt,ce]=r(null),[ot,nt]=r(null),it=o(e=>{n.current=!0,ce(e)},[]),at=o(e=>{n.current=!0,V(e)},[]),ct=o(e=>{n.current=!0,X(e)},[]),st=o(e=>{n.current=!0,Z(e)},[]),dt=o(e=>{n.current=!0,q(e)},[]),ht=o(e=>{n.current=!0,J(e)},[]),ut=o(e=>{n.current=!0,te(e)},[]),lt=o(e=>{n.current=!0,re(e)},[]),mt=o(e=>{n.current=!0,oe(e)},[]),pt=o(e=>{n.current=!0,ne(e)},[]),St=o(e=>{n.current=!0,ie(e)},[]);f(()=>{const e=k(l).theme;if(!h||!s.hasSiteTheme||!e)return;const i=c??"";ae.current!==i&&(ae.current=i,n.current=!1);let u=!1;return e.get(c?{siteId:c}:void 0).then(t=>{if(u||n.current)return;fe(t.default_mode),ge(t.show_theme_switch),y(t.default_mode),G(t.show_theme_switch),N(Lt({selected:t.selected_preset,themes:t.theme_presets},i));const C=Cr(t);x(C.fonts),U(C.sizes);const S=Dt(t);Q(S),A(t.corner_radius_px===void 0?or[sr(t.corner_style)]:w(t.corner_radius_px,S.cornerRadiusUnit,cr)),L(C.compression),z(t.card_shadow==null?lr:dr(t.card_shadow)),j(t.card_gap==null?me:hr(t.card_gap)),K(t.hover_effect==null?mr:ur(t.hover_effect)),Y(Sr(t.shadow_color)),V(w(t.site_width,S.siteWidthUnit,It)),X(w(t.site_gutter,S.siteGutterUnit,Bt)),Z(w(t.site_gutter_phone,S.siteGutterPhoneUnit,Ft)),q(w(t.block_gap,S.blockGapUnit,le)),J(w(t.block_gap_phone,S.blockGapPhoneUnit,le)),ee(C.typography),ce(C.textStyles),nt(_r(t)),te(t.hero_background_follows_width===!0),re(ue(t.section_background_width)),oe(ue(t.section_content_width)),ne(t.photography_grayscale===!0),ie(t.share_button_on_posts===!0)}).catch(()=>{}),()=>{u=!0}},[h,c,s.hasSiteTheme,l]);const ft=Xt({token:h,siteId:c,enabled:s.hasSiteSettings}),[gt,se]=r(Kt),de=g(null),W=g(!1),m=g(null),p=g({}),P=o(async()=>{m.current&&clearTimeout(m.current),m.current=null;const e=p.current;p.current={};try{await k(l).chat?.update(e,c?{siteId:c}:void 0),Et()}catch(i){throw p.current={...e,...p.current},i}},[l,c]);f(()=>yt(()=>m.current||Object.keys(p.current).length>0?P():void 0),[P]);const wt=o(e=>{W.current=!0,se(i=>({...i,...e})),!(!s.hasSiteSettings||!h)&&(p.current={...p.current,...e},m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{P().catch(()=>{})},500))},[s.hasSiteSettings,h,P]);return f(()=>{if(!h||!s.hasSiteSettings)return;const e=c??"";de.current!==e&&(de.current=e,W.current=!1);let i=!1;const u=k(l).chat;if(u)return u.get(c?{siteId:c}:void 0).then(t=>{i||W.current||se(Pr(t))}).catch(()=>{}),()=>{i=!0}},[h,c,s.hasSiteSettings,l]),f(()=>{const e=d.site;if(!_||!s.hasSiteRecord||!e){O(null);return}let i=!1;return e().then(u=>{i||O(Rt(u.name))}).catch(()=>{}),()=>{i=!0}},[_,h,s.hasSiteRecord,c,d]),a(Mt,{config:be,parts:gr,wrap:(e,i)=>a(xt,{websiteName:Ce,templateChrome:E,templateName:_e||null,themeMode:Pe,onThemeModeChange:Ye,themeSwitchShown:Te,onThemeSwitchShownChange:je,theme:Ee,themeRow:Ut(s.hasSiteTheme,b.readFor,c??""),onThemeChange:Ke,fonts:ye,onFontsChange:Ve,cornerRadiusPx:ve,onCornerRadiusPxChange:Ze,cardShadow:We,onCardShadowChange:Je,shadowColor:ke,onShadowColorChange:Qe,cardGap:Re,onCardGapChange:$e,hoverEffect:Be,onHoverEffectChange:et,headingCompression:He,onHeadingCompressionChange:qe,headingTypography:Ne,onHeadingTypographyChange:tt,textStyles:rt,onTextStylesChange:it,wordStyles:ot,sizes:Ge,onSizesChange:Xe,siteWidth:Fe,onSiteWidthChange:at,siteGutter:Ie,onSiteGutterChange:ct,siteGutterPhone:De,onSiteGutterPhoneChange:st,blockGap:v,onBlockGapChange:dt,blockGapPhone:H,onBlockGapPhoneChange:ht,siteLengthUnits:Oe,onSiteLengthUnitsChange:Me,heroBackgroundFollowsWidth:xe,onHeroBackgroundFollowsWidthChange:ut,sectionBackgroundWidth:Ue,onSectionBackgroundWidthChange:lt,sectionContentWidth:Ae,onSectionContentWidthChange:mt,photographyGrayscale:Le,onPhotographyGrayscaleChange:pt,shareButtonOnPosts:ze,onShareButtonOnPostsChange:St,themeFromDocument:!s.hasSiteTheme,children:a(zt,{chromeRootProps:we,children:a(Tt,{wrap:l.chrome?.wrap,surface:"page",children:a(Jt,{children:a(Qt,{children:a($t,{children:a(tr,{children:a(er,{children:Ct(rr,{children:[a(jt,{chat:gt,onChatChange:wt,children:a(Vt,{value:ft,children:a(Zt,{children:a(Wt,{children:a(bt,{children:e})})})})}),i]})})})})})})})})})})}function Wr({target:d,openAddPage:s}){return a(kt,{open:s,children:a(Ot,{target:d,addressing:qt,onHostMessage:wr,children:a(Hr,{})})})}export{Wr as default};
|
|
1
|
+
"use client";import{jsx as a,jsxs as me}from"react/jsx-runtime";import{useCallback as o,useEffect as f,useMemo as pe,useRef as g,useState as r}from"react";import"efficient-easel/easel.css";import"efficient-easel/shell.css";import"efficient-easel/rail.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import"efficient-easel/pick.css";import"efficient-easel/copy.css";import"efficient-easel/gold.css";import"efficient-easel/text-styles.css";import"efficient-easel/menu.css";import"efficient-easel/chrome.css";import"efficient-easel/tree.css";import"efficient-easel/drag.css";import"efficient-easel/screen.css";import"./storefront-editor.css";import{useHostConfig as vt}from"../lib/document/host-config.js";import{ChromeWrap as Ht}from"efficient-easel/screen/lib/host-chrome";import{refreshSiteLiveState as kt}from"../lib/site-live-state.js";import{holdSiteWrites as Wt}from"../../format/lib/site-writes.js";import{backendOf as F}from"../lib/website-session.js";import{useEaselSession as Ft}from"efficient-easel/screen/lib/session-context";import{withSiteBlockGapFields as Rt}from"../../format/lib/document/site-gap-fields.js";import{withTemplateMediaPlaceholders as Bt}from"../../format/lib/document/templateFields.js";import{setEditorPage as Se}from"../../format/lib/document/editor-page-context.js";import{EditorPagePathProvider as It}from"./EditorPagePathProvider.js";import{AddPageOnOpen as Dt}from"./AddPageOnOpen.js";import{resolveSiteName as Ot}from"../../format/lib/content/site-name.js";import{normalizeSiteGutter as Mt,normalizeSiteGutterPhone as bt,normalizeSiteWidth as Nt}from"../../format/lib/content/page-width.js";import{siteLengthNumber as w,siteLengthUnitsOfRow as xt}from"../../format/lib/content/css-length.js";import{normalizeSiteBackground as fe}from"../../format/lib/content/section-width.js";import{normalizeSiteBlockGap as ge}from"../../format/lib/content/container-gap.js";import Ut,{DocumentScreen as At}from"efficient-easel/screen/components/ScreenMount";import Lt from"./WebsiteHintsProvider.js";import{useScreenDocument as zt}from"efficient-easel/screen/components/ScreenDocumentContext";import{PreviewHeaderProvider as Yt,siteThemeRow as Kt,themeEdited as jt,themeSeeded as Vt}from"../../render/components/PreviewHeaderContext.js";import{PreviewFooterProvider as Xt}from"./PreviewFooterContext.js";import{usePinnedChromeState as Zt}from"./usePinnedChromeState.js";import{PreviewChatProvider as qt,DEFAULT_CHAT_PREVIEW as Jt}from"./PreviewChatContext.js";import{PreviewSocialProvider as Qt}from"../../render/components/PreviewSocialContext.js";import{useSocialSettings as $t}from"./useSocialSettings.js";import{PreviewSurfaceProvider as er}from"./PreviewSurfaceContext.js";import{WEBSITE_ADDRESSING as tr}from"../lib/website-document-addressing.js";import{PreviewTickerProvider as rr}from"../../render/components/PreviewTickerContext.js";import{PreviewHeroPartProvider as or}from"../../render/components/PreviewHeroPartContext.js";import{PreviewPartsProvider as nr}from"efficient-easel/draw/client";import{CanvasPartsBridge as ir}from"./CanvasPartsBridge.js";import{PreviewLocationPartProvider as ar}from"../../render/components/PreviewLocationPartContext.js";import{PreviewPartStyleProvider as sr}from"./PreviewPartStyleContext.js";import{CORNER_STYLE_TO_PX as cr,DEFAULT_HEADING_COMPRESSION as dr,DEFAULT_HEADING_TYPOGRAPHY as hr,DEFAULT_SWITCH_SHOWN as R,DEFAULT_SIZES as ur,DEFAULT_THEME_MODE as T,normalizeCornerRadius as lr,normalizeCornerStyle as mr,normalizeCardShadow as pr,normalizeCardGap as Sr,normalizeHoverEffect as fr,IDENTITY_CARD_GAP as we,IDENTITY_CARD_SHADOW as gr,IDENTITY_HOVER_EFFECT as wr,THEME_MODE_KEY as Ce,THEME_STORAGE_KEY as Cr,THEME_SWITCH_HIDE as _e,THEME_SWITCH_KEY as B}from"../../format/lib/theme.js";import{pictureShadowColor as _r}from"efficient-easel/screen/lib/document/shadow-values";import{DEFAULT_FONTS as Pr,fontRegistry as Tr}from"../../format/lib/fonts.js";import{WEBSITE_SCREEN as Er}from"./WebsiteScreenParts.js";import{routeWebsiteHostMessage as yr}from"../../format/lib/website-host-inbound.js";import{siteTextFromRow as Gr}from"../../render/lib/text-styles/site-text-styles.js";import{wordStylesFromRow as vr}from"../../format/lib/word-styles.js";import{SiteFontFaces as Hr,SiteFontsProvider as kr}from"../../render/components/SiteFontsContext.js";import{siteFontsFromRow as Wr}from"../../format/lib/site-theme-row.js";import{chatPreviewFrom as Fr}from"./PreviewChatContext.js";import{parseOption as Rr}from"efficient-shell/format";import{THEME_MODES as Br}from"../../format/lib/theme.js";const Ir=()=>{if(typeof window>"u")return T;try{const d=window.localStorage.getItem(Ce);return Rr(Br,T,d)}catch{return T}},Pe=d=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ce,d)}catch{}},Dr=()=>{if(typeof window>"u")return R;try{return window.localStorage.getItem(B)!==_e}catch{return R}},Or=()=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Cr)}catch{}},Te=d=>{if(!(typeof window>"u"))try{d?window.localStorage.removeItem(B):window.localStorage.setItem(B,_e)}catch{}};function Mr(){const{adapter:d,capabilities:c,templateId:I,ready:_,token:h,siteId:s,currentSlug:D,currentKind:O}=zt();f(()=>(Se(D,O),()=>Se(null,null)),[D,O]);const Ee=Zt(d?.pinnedChrome)?.rootProps??null,E=c.placeholderFrames,[ye,M]=r(null),[Ge,b]=r("");f(()=>{const e=d.templateName;if(!_||!I||!e){b("");return}let i=!1;return e().then(u=>!i&&b(u??"")).catch(()=>{}),()=>{i=!0}},[_,h,I,d]);const[ve,y]=r(T),[He,G]=r(R),[N,x]=r({value:{selected:0,themes:[]},readFor:null}),ke=N.value,[We,U]=r(Pr),[Fe,A]=r(ur),[Re,L]=r(null),[Be,z]=r(dr),[Ie,Y]=r(null),[De,K]=r(null),[Oe,j]=r(we),[Me,V]=r(null),[be,X]=r(null),[Ne,Z]=r(null),[xe,q]=r(null),[v,J]=r(null),[H,Q]=r(null),[Ue,$]=r({}),Ae=o(e=>$(i=>({...i,...e})),[]),l=Ft(),ee=vt(),Le=pe(()=>Rt(Bt(ee,E),v,H),[ee,E,v,H]),[ze,te]=r(hr),[Ye,re]=r(null),[Ke,oe]=r(null),[je,ne]=r(null),[Ve,ie]=r(null),[Xe,ae]=r(null),se=g(null),n=g(!1);f(()=>{y(Ir()),G(Dr())},[]);const Ze=o(e=>{n.current=!0,Or(),Pe(e),y(e)},[]),qe=o(e=>{n.current=!0,Te(e),G(e)},[]),Je=o(e=>{n.current=!0,x(i=>jt(i,e,s??""))},[s]),Qe=o(e=>{n.current=!0,U(e)},[]),$e=o(e=>{n.current=!0,A(e)},[]),et=o(e=>{n.current=!0,L(e)},[]),tt=o(e=>{n.current=!0,z(e)},[]),rt=o(e=>{n.current=!0,Y(e)},[]),ot=o(e=>{n.current=!0,K(e)},[]),nt=o(e=>{n.current=!0,j(e)},[]),it=o(e=>{n.current=!0,V(e)},[]),at=o(e=>{n.current=!0,te(e)},[]),[st,ce]=r(null),[ct,dt]=r(null),[k,ht]=r(null),ut=pe(()=>(k??[]).map(e=>e.key),[k]),lt=o(e=>{n.current=!0,ce(e)},[]),mt=o(e=>{n.current=!0,X(e)},[]),pt=o(e=>{n.current=!0,Z(e)},[]),St=o(e=>{n.current=!0,q(e)},[]),ft=o(e=>{n.current=!0,J(e)},[]),gt=o(e=>{n.current=!0,Q(e)},[]),wt=o(e=>{n.current=!0,re(e)},[]),Ct=o(e=>{n.current=!0,oe(e)},[]),_t=o(e=>{n.current=!0,ne(e)},[]),Pt=o(e=>{n.current=!0,ie(e)},[]),Tt=o(e=>{n.current=!0,ae(e)},[]);f(()=>{const e=F(l).theme;if(!h||!c.hasSiteTheme||!e)return;const i=s??"";se.current!==i&&(se.current=i,n.current=!1);let u=!1;return e.get(s?{siteId:s}:void 0).then(t=>{if(u)return;const ue=Wr(t);ht(ue);const le=Tr(ue);if(n.current)return;Pe(t.default_mode),Te(t.show_theme_switch),y(t.default_mode),G(t.show_theme_switch),x(Vt({selected:t.selected_preset,themes:t.theme_presets},i));const C=Gr(t,le);U(C.fonts),A(C.sizes);const S=xt(t);$(S),L(t.corner_radius_px===void 0?cr[mr(t.corner_style)]:w(t.corner_radius_px,S.cornerRadiusUnit,lr)),z(C.compression),Y(t.card_shadow==null?gr:pr(t.card_shadow)),j(t.card_gap==null?we:Sr(t.card_gap)),V(t.hover_effect==null?wr:fr(t.hover_effect)),K(_r(t.shadow_color)),X(w(t.site_width,S.siteWidthUnit,Nt)),Z(w(t.site_gutter,S.siteGutterUnit,Mt)),q(w(t.site_gutter_phone,S.siteGutterPhoneUnit,bt)),J(w(t.block_gap,S.blockGapUnit,ge)),Q(w(t.block_gap_phone,S.blockGapPhoneUnit,ge)),te(C.typography),ce(C.textStyles),dt(vr(t,le)),re(t.hero_background_follows_width===!0),oe(fe(t.section_background_width)),ne(fe(t.section_content_width)),ie(t.photography_grayscale===!0),ae(t.share_button_on_posts===!0)}).catch(()=>{}),()=>{u=!0}},[h,s,c.hasSiteTheme,l]);const Et=$t({token:h,siteId:s,enabled:c.hasSiteSettings}),[yt,de]=r(Jt),he=g(null),W=g(!1),m=g(null),p=g({}),P=o(async()=>{m.current&&clearTimeout(m.current),m.current=null;const e=p.current;p.current={};try{await F(l).chat?.update(e,s?{siteId:s}:void 0),kt()}catch(i){throw p.current={...e,...p.current},i}},[l,s]);f(()=>Wt(()=>m.current||Object.keys(p.current).length>0?P():void 0),[P]);const Gt=o(e=>{W.current=!0,de(i=>({...i,...e})),!(!c.hasSiteSettings||!h)&&(p.current={...p.current,...e},m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{P().catch(()=>{})},500))},[c.hasSiteSettings,h,P]);return f(()=>{if(!h||!c.hasSiteSettings)return;const e=s??"";he.current!==e&&(he.current=e,W.current=!1);let i=!1;const u=F(l).chat;if(u)return u.get(s?{siteId:s}:void 0).then(t=>{i||W.current||de(Fr(t))}).catch(()=>{}),()=>{i=!0}},[h,s,c.hasSiteSettings,l]),f(()=>{const e=d.site;if(!_||!c.hasSiteRecord||!e){M(null);return}let i=!1;return e().then(u=>{i||M(Ot(u.name))}).catch(()=>{}),()=>{i=!0}},[_,h,c.hasSiteRecord,s,d]),a(At,{config:Le,parts:Er,wrap:(e,i)=>me(kr,{siteFonts:k,children:[a(Hr,{usedKeys:ut,preload:!1}),a(Yt,{websiteName:ye,templateChrome:E,templateName:Ge||null,themeMode:ve,onThemeModeChange:Ze,themeSwitchShown:He,onThemeSwitchShownChange:qe,theme:ke,themeRow:Kt(c.hasSiteTheme,N.readFor,s??""),onThemeChange:Je,fonts:We,onFontsChange:Qe,cornerRadiusPx:Re,onCornerRadiusPxChange:et,cardShadow:Ie,onCardShadowChange:rt,shadowColor:De,onShadowColorChange:ot,cardGap:Oe,onCardGapChange:nt,hoverEffect:Me,onHoverEffectChange:it,headingCompression:Be,onHeadingCompressionChange:tt,headingTypography:ze,onHeadingTypographyChange:at,textStyles:st,onTextStylesChange:lt,wordStyles:ct,sizes:Fe,onSizesChange:$e,siteWidth:be,onSiteWidthChange:mt,siteGutter:Ne,onSiteGutterChange:pt,siteGutterPhone:xe,onSiteGutterPhoneChange:St,blockGap:v,onBlockGapChange:ft,blockGapPhone:H,onBlockGapPhoneChange:gt,siteLengthUnits:Ue,onSiteLengthUnitsChange:Ae,heroBackgroundFollowsWidth:Ye,onHeroBackgroundFollowsWidthChange:wt,sectionBackgroundWidth:Ke,onSectionBackgroundWidthChange:Ct,sectionContentWidth:je,onSectionContentWidthChange:_t,photographyGrayscale:Ve,onPhotographyGrayscaleChange:Pt,shareButtonOnPosts:Xe,onShareButtonOnPostsChange:Tt,themeFromDocument:!c.hasSiteTheme,children:a(Xt,{chromeRootProps:Ee,children:a(Ht,{wrap:l.chrome?.wrap,surface:"page",children:a(rr,{children:a(or,{children:a(nr,{children:a(ar,{children:a(ir,{children:me(sr,{children:[a(qt,{chat:yt,onChatChange:Gt,children:a(Qt,{value:Et,children:a(er,{children:a(It,{children:a(Lt,{children:e})})})})}),i]})})})})})})})})})]})})}function br({target:d,openAddPage:c}){return a(Dt,{open:c,children:a(Ut,{target:d,addressing:tr,onHostMessage:yr,children:a(Mr,{})})})}export{br as default};
|