efficient-easel 26.16.0 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/{chunk-YTF65TZA.js → chunk-2262JGFV.js} +5 -5
- package/dist/chunk-53QUHEHK.js +1 -0
- package/dist/{chunk-W2S2VJOQ.js → chunk-5JNVMCCB.js} +1 -1
- package/dist/{chunk-XFI3UPB2.js → chunk-5OWAV3MH.js} +1 -1
- package/dist/chunk-76MUJIZE.js +17 -0
- package/dist/{chunk-JDQSRKJG.js → chunk-AAZIMKLQ.js} +1 -1
- package/dist/{chunk-RN5AYO53.js → chunk-DAKKPW2Z.js} +1 -1
- package/dist/chunk-DIOTWSCO.js +1 -0
- package/dist/chunk-FW35PCK7.js +1 -0
- package/dist/{chunk-C4TJN6GR.js → chunk-G2VZ4DET.js} +1 -1
- package/dist/{chunk-LWFE6QDN.js → chunk-HG65R6IN.js} +12 -12
- package/dist/chunk-L2WK5JYB.js +2 -0
- package/dist/{chunk-RQO3UDKP.js → chunk-L7PSERQH.js} +8 -8
- package/dist/{chunk-H4TUOPI7.js → chunk-NTG5ODKZ.js} +1 -1
- package/dist/{chunk-T5U2UZO6.js → chunk-O4OWODU2.js} +31 -31
- package/dist/chunk-TDEBPOWV.js +3 -0
- package/dist/{chunk-6DUCOSHW.js → chunk-TYTMUHUK.js} +1 -1
- package/dist/chunk-W3UZNKGS.js +7 -0
- package/dist/{chunk-CLAADE4J.js → chunk-XWTQTANN.js} +5 -5
- package/dist/{chunk-MGEXTIZH.js → chunk-YES5F7OS.js} +1 -1
- package/dist/chunk-ZFEAWEFS.js +4 -0
- package/dist/chunk-ZNLODQD4.js +3 -0
- package/dist/copy/index.d.ts +1 -1
- package/dist/copy/index.js +13 -13
- package/dist/draw/index.js +1 -1
- package/dist/easel/index.d.ts +1 -1
- package/dist/fields/index.d.ts +43 -16
- package/dist/fields/index.js +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/{rowMarks-CO5TpfLY.d.ts → rowMarks-D2cO7UTi.d.ts} +5 -5
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/content/view-tiers.d.ts +11 -1
- package/dist/screen/lib/content/view-tiers.js +1 -1
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +41 -13
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/device-fields.d.ts +10 -17
- package/dist/screen/lib/document/device-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/panel-no-control-mark.d.ts +2 -2
- package/dist/screen/lib/document/shadow-fields.js +1 -1
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/style-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +0 -10
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +0 -6
- package/dist/screen/words.d.ts +1 -3
- package/dist/screen/words.js +1 -1
- package/dist/strings/index.js +2 -2
- package/dist/text-styles/index.d.ts +6 -5
- package/dist/text-styles/index.js +37 -37
- package/dist/text-styles/model.d.ts +24 -14
- package/dist/text-styles/model.js +1 -1
- package/dist/{types-CVHwspYM.d.ts → types-DcyH17ij.d.ts} +2 -0
- package/package.json +1 -1
- package/dist/chunk-5U6DUZE2.js +0 -7
- package/dist/chunk-BLE3U2GS.js +0 -2
- package/dist/chunk-CPIWSFGR.js +0 -2
- package/dist/chunk-E52W3M5I.js +0 -1
- package/dist/chunk-OGG6FMBA.js +0 -17
- package/dist/chunk-TXNCWF67.js +0 -4
- package/dist/chunk-U4TG43PD.js +0 -1
- package/dist/chunk-YHZSBL2N.js +0 -1
- package/dist/chunk-ZEH6QLBH.js +0 -4
package/README.md
CHANGED
|
@@ -684,9 +684,9 @@ by `AUTO_RULES[kind]`; Phone's parent is Tablet, Tablet's is Desktop. The kinds:
|
|
|
684
684
|
40), `columns` (at most 2, then 1), `stack` (Phone stacked), `textSize`
|
|
685
685
|
(x0.85 and x0.7, to 1px), `heightMode` (Phone: px → fit, Screen % stays),
|
|
686
686
|
`heightPx` (x0.75) and `same`. The breakpoints are `VIEW_TABLET_MIN` 720 and
|
|
687
|
-
`VIEW_DESKTOP_MIN` 1100. A text style
|
|
688
|
-
|
|
689
|
-
|
|
687
|
+
`VIEW_DESKTOP_MIN` 1100. A text style keeps Size, Line spacing, Letter spacing, Paragraph spacing and
|
|
688
|
+
Largest size per view (`<key>Tablet`, `<key>Phone`; absent = the next wider view).
|
|
689
|
+
The website's rendering reads the engine in later releases. Never store what `resolveViewValue` returns for
|
|
690
690
|
an auto view.
|
|
691
691
|
|
|
692
692
|
Nothing moved: each name is re-exported from the module that defines it, and
|
|
@@ -1074,8 +1074,11 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
|
|
|
1074
1074
|
is not planned or drawn (it would write the desktop value). A heading mark, a
|
|
1075
1075
|
slot and a field that draws no control anywhere stay; the `Inspector`'s `lead`
|
|
1076
1076
|
is not drawn. `fieldShownInView(field, device, siblings?)`
|
|
1077
|
-
is the one answer, exported from `efficient-easel/fields`.
|
|
1078
|
-
|
|
1077
|
+
is the one answer, exported from `efficient-easel/fields`. The tablet view is
|
|
1078
|
+
the same with `deviceField("tablet", …)`. Desktop and no device: every row, as
|
|
1079
|
+
before. `phoneTwinFields(key, row, VIEW_KEY_ACCESS)` gives a row its tablet and
|
|
1080
|
+
phone values under `<key>Tablet` and `<key>Phone`; `rowViewState`,
|
|
1081
|
+
`innerRowCount` and `viewReadsIn` are the census a host's guard reads. A kept key (a field with `reachedBy`:
|
|
1079
1082
|
`keptByRow`, a padding side, Position's y) is shown in the phone view only
|
|
1080
1083
|
if its row is shown (`siblings` is the fields it sits among; `planFields`
|
|
1081
1084
|
passes them); with no siblings it is hidden on the phone. `planFields` also
|
|
@@ -1278,9 +1281,7 @@ the Footer is drawn; `pinned.band` names the sections between the pins, folds
|
|
|
1278
1281
|
them under a row of their own and ends them with an "Add section" row; and
|
|
1279
1282
|
`useDocumentLabel` is the head's context line. A row's name, its quieter
|
|
1280
1283
|
words, its marks and buttons of the layer's own are `blockLook.rowName`,
|
|
1281
|
-
`rowPreview`, `rowMarks` and `rowActions
|
|
1282
|
-
block a small tab above it on the canvas while it is selected or under the
|
|
1283
|
-
pointer ("Designs shown" for a number filled from a live count). A block config's
|
|
1284
|
+
`rowPreview`, `rowMarks` and `rowActions`. A block config's
|
|
1284
1285
|
`permissions.delete` / `duplicate` set to `false` takes the action off the
|
|
1285
1286
|
block's rows and its menu, and the inspector is handed the answer for its
|
|
1286
1287
|
head (`nodeActions`). The frame's words (the pinned labels,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-3W2O22DZ.js";import{Inspector as i}from"./chunk-
|
|
2
|
-
return f(r,{height:"fill"})}function
|
|
3
|
-
return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var
|
|
4
|
-
return f(
|
|
5
|
-
return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return A().Inspector??
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-3W2O22DZ.js";import{Inspector as i}from"./chunk-HG65R6IN.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.every(n=>Object.is(t[n],r[n]))}function m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},O=()=>b,j=()=>"",w=()=>null,C=()=>{},S={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},N={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},D={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},I={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
|
|
2
|
+
return f(r,{height:"fill"})}function B(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
|
|
3
|
+
return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var G=l({});function x({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return f(G.Provider,{value:n,children:e})}function A(){return s(G)}function F(){return(A().useOwnerName??j)()}function T(){return(A().useDocumentLabel??w)()}function R(n,e,t,r){return(A().useBridges??O)(n,e,t,r)}function Y(n){return(A().useStandaloneBridges??O)(n)}function H(n,e){(A().useDocumentPass??C)(n,e)}function Q(){return A().blockRules??S}function V(){return A().blockLook??L}function W(){return A().devices??N}function X(){return A().leftView??D}function Z(){return A().pinned??I}function E(){return A().saveSwitch??!0}function K(e){n(!0===A().pickFollowsSelection,e)}function M(){return A().storageNamespace||void 0}function q(){return A().styleClipboard??null}function z(){return A().nodeKeys??!0}function J(){return A().notify??null}function U(){return A().Canvas??P}function $(){return A().CanvasHead??null}function _(){return A().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return A().Inspector??B}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,x as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,V as useScreenBlockLook,Q as useScreenBlockRules,R as useScreenBridges,_ as useScreenCanvasDrag,U as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,W as useScreenDevices,T as useScreenDocumentLabel,H as useScreenDocumentPass,rn as useScreenInspectorPanel,X as useScreenLeftView,z as useScreenNodeKeys,J as useScreenNotify,F as useScreenOwnerName,A as useScreenParts,K as useScreenPickFollowsSelection,Z as useScreenPinned,E as useScreenSaveSwitch,M as useScreenStorageNamespace,q as useScreenStyleClipboard,Y as useStandaloneScreenBridges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveViewValue as n,FOLLOW_RULES as e}from"./chunk-DIOTWSCO.js";var i=["none","upper","capitalize","lower"],t={none:"none",upper:"uppercase",capitalize:"capitalize",lower:"lowercase"};function a(n){return i.includes(n)}function r(n){return a(n)?t[n]:void 0}function o(n){return i.find(e=>t[e]===n)}var s=["size","lineSpacing","letterSpacing","paragraphSpacing","largestSize"];function d(n,e){return`${n}${"tablet"===e?"Tablet":"Phone"}`}function l(i,t){if("desktop"===t)return i;let a=i;for(const r of s){const o=n("same",i[r],i[d(r,"tablet")],i[d(r,"phone")],e),s="phone"===t?o.phone:o.tablet;null!=s&&s!==i[r]&&(a={...a,[r]:s})}return a}var u=["font","color","size","weight","emphasis","lineSpacing","letterSpacing","paragraphSpacing","letterCase","largestSize"],c=["font","color","size","weight","lineSpacing","letterSpacing","paragraphSpacing","letterCase"],p=["heading","body"],f=7,h={heading:3,body:5},m={min:5,max:void 0,sliderMin:12,sliderMax:72,step:1,shiftStep:10,unit:"px"},g={size:m,weight:{min:100,max:900,sliderMin:300,sliderMax:900,step:100,shiftStep:100,unit:""},lineSpacing:{min:50,max:250,sliderMin:50,sliderMax:250,step:1,shiftStep:10,unit:"%"},letterSpacing:{min:-10,max:void 0,sliderMin:-5,sliderMax:10,step:.1,shiftStep:1,unit:"px"},paragraphSpacing:{min:0,max:void 0,sliderMin:0,sliderMax:48,step:1,shiftStep:10,unit:"px"},largestSize:m},x=(n,e)=>`${"heading"===n?"Heading":"Body"} ${e}`;function S(n=({kind:n,n:e})=>x(n,e)){return p.flatMap(e=>Array.from({length:h[e]},(i,t)=>({id:`${e}-${t+1}`,kind:e,name:n({kind:e,n:t+1}),values:{}})))}function k(n,e,i=f){return n.filter(n=>n.kind===e).length<i}function v(n,e){const i=new RegExp(`^${e}-([1-9]\\d*)$`).exec(n);return i?Number(i[1]):void 0}function M(n){const e=v(n.id,n.kind);return void 0!==e&&e<=h[n.kind]}function z(n,e,i={}){const{max:t=f,name:a=({kind:n,n:e})=>x(n,e),make:r}=i;if(!k(n,e,t))return null;const o=n.filter(n=>n.kind===e);let s=o.length+1;const d=new Set(n.map(n=>n.name));for(;d.has(a({kind:e,n:s}));)s+=1;const l=new Set(n.map(n=>n.id));let u=Math.max(s,...o.map(n=>(v(n.id,e)??0)+1));for(;l.has(`${e}-${u}`);)u+=1;const c=o.at(-1),p=r?r(e,s):{id:`${e}-${u}`,kind:e,name:a({kind:e,n:s}),values:{...c?.values??{}}},h=c?n.indexOf(c)+1:"heading"===e?0:n.length;return{styles:[...n.slice(0,h),p,...n.slice(h)],added:p}}function w(n,e,i={}){const{name:t=({kind:n,n:e})=>x(n,e)}=i,a=n.find(n=>n.id===e);if(!a||M(a))return null;const r=n.filter(n=>n.kind===a.kind),o=r.indexOf(a),s=/* @__PURE__ */new Map;return r.forEach((n,e)=>{e>o&&n.name===t({kind:n.kind,n:e+1})&&s.set(n,t({kind:n.kind,n:e}))}),{styles:n.filter(n=>n!==a).map(n=>s.has(n)?{...n,name:s.get(n)}:n),removed:a}}function b(n,e){const i=n.find(n=>n.id===e);if(i)return i;for(const i of p){const t=v(e,i);if(void 0===t)continue;let a;for(const e of n){const n=e.kind===i?v(e.id,i):void 0;void 0!==n&&n<t&&(!a||n>a.n)&&(a={n:n,style:e})}return a?.style}}function $(n,e,i){return n.map(n=>{if(n.id!==e)return n;const t={...n.values};for(const[n,e]of Object.entries(i))void 0===e?delete t[n]:t[n]=e;return{...n,values:t}})}function y(n){return Math.min(20,Math.max(12,Math.round(.5*n+6)))}function O(n,e){const i=e.weights;return[i.thin,i.extraLight,i.light,i.regular,i.medium,i.semibold,i.bold,i.extraBold,i.black][Math.min(8,Math.max(0,Math.round(n/100)-1))]}function C(n,e,i,t={}){const a=e.find(e=>e.value===n.font)?.label??n.font??"",r=void 0===n.size?t.autoSize?i.auto:"":i.px({n:n.size});return i.summary({font:a,size:r,weight:O(n.weight??400,i)})}export{c as CAMPAIGN_TEXT_STYLE_SETTINGS,i as TEXT_STYLE_CASES,t as TEXT_STYLE_CASE_CSS,h as TEXT_STYLE_DEFAULT_COUNT,p as TEXT_STYLE_KINDS,f as TEXT_STYLE_MAX,g as TEXT_STYLE_RANGES,u as TEXT_STYLE_SETTINGS,s as TEXT_STYLE_VIEW_NUMBERS,z as addTextStyle,k as canAddTextStyle,S as defaultTextStyles,C as describeTextStyle,M as isDefaultTextStyle,a as isTextStyleCase,w as removeTextStyle,b as resolveTextStyle,r as textStyleCaseCss,o as textStyleCaseOfCss,y as textStyleRowSize,d as textStyleViewKey,l as textStyleViewValues,$ as updateTextStyle,O as weightWord};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-2262JGFV.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-G2VZ4DET.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
|
|
2
2
|
/* @__PURE__ */o("span",{children:e.group}),
|
|
3
3
|
/* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
4
4
|
return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useSectionOps as o}from"./chunk-
|
|
1
|
+
import{useSectionOps as o}from"./chunk-TYTMUHUK.js";import{SELECTION_MODE as e}from"./chunk-2262JGFV.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-3W2O22DZ.js";import{usePreviewParts as p}from"./chunk-467WWV4I.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),f=o(),{setSelectedPartId:k,setSelectHandler:l}=p(),I=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{l(I)},[l,I]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{k(h)},[h,k]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&f.select(r)},[i,u,f]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{sidesStartEach as e,SidesInput as n,SidesEachToggle as t}from"./chunk-XWTQTANN.js";import{SettingsDefaultReset as l}from"./chunk-2T22IY3J.js";import{deviceField as o}from"./chunk-ZNLODQD4.js";import{noControlField as a,NoControlMark as i}from"./chunk-22I55W37.js";import{describedAs as r}from"./chunk-LX23TCTP.js";import{withStyleKind as s}from"./chunk-CWELHADJ.js";import{foldMetaOf as u,FOLD_FIELD_MARKER as c}from"./chunk-ANPOR6EY.js";import{useSelectedHost as d,useEasel as p}from"./chunk-3W2O22DZ.js";import{DEFAULT_PANEL_WORDS as f}from"./chunk-56ID6FKZ.js";import{SettingsSwitch as b}from"./chunk-OECWLNKJ.js";import{phoneKey as m,tabletKey as h,viewFollows as v,isAuto as g}from"./chunk-DIOTWSCO.js";import{FieldSelect as y}from"./chunk-KFWNGPW3.js";import{SettingsSegmented as w}from"./chunk-DX3VILZ3.js";import{SettingsField as k}from"./chunk-MIX7EGRG.js";import{useWords as x}from"./chunk-MFIRYGHW.js";import{useState as C}from"react";import{AlignmentIcon as j,BoxJustifyIcon as F,WrapIcon as O,ArrowRightIcon as L,GapIcon as K,WidthIcon as S,PlacementIcon as P,NudgeIcon as V,DesktopIcon as E,BoxXEndIcon as A,BoxXCenterIcon as R,BoxXStartIcon as W,PaddingAllIcon as I,BoxYBetweenIcon as M,BoxYStretchIcon as N,BoxYEndIcon as T,BoxYCenterIcon as B,BoxYStartIcon as $,BoxXBetweenIcon as D,BoxXStretchIcon as G,BoxItemAlignmentIcon as J}from"efficient-shell/icons/efficient";import{textAlignOptions as H,AlignmentGrid as X,PositionInput as _,Slider as z}from"efficient-shell/ui";import{jsx as Y,Fragment as Z,jsxs as Q}from"react/jsx-runtime";var U=e=>e;function q(e,n,t="desktop"){return e("tablet"===t?"{value} on tablet":"{value} on desktop").replace("{value}",n)}var ee=()=>{};function ne(){return null}function te(e){if(!e.trim())throw new Error("noGlyph() needs a reason naming the ruling that decided it.");/* @__PURE__ */
|
|
2
|
+
return Y(ne,{},e)}function le(e){return e.type===ne}function oe(e){return le(e)?void 0:e}function ae(e){for(const[n,t]of Object.entries(e))t&&"object"==typeof t&&!u(t)&&s(t,`section:${n}`);return e}function ie(e,n){return{type:"custom",[c]:{label:e,level:n},marker:!0,fold:e,render:()=>/* @__PURE__ */Y(Z,{})}}function re(e){return ie(e,2)}function se(e){return ie(e,1)}var ue=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"Space between",value:"between"},{label:"End",value:"end"}],ce=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"End",value:"end"},{label:"Stretch",value:"stretch"}],de="Wrap",pe=[{label:"Wrap",value:"wrap"},{label:"No wrap",value:"nowrap"}],fe="Direction",be=[{label:"Stacked",value:"column"},{label:"One row",value:"row"}],me={min:-32,max:64,step:2,builtIn:0},he={min:30,max:100,step:5,fallback:60},ve=["top-left","top-center","top-right","left","center","right","bottom-left","bottom-center","bottom-right"],ge="bottom-left",ye={"top-left":"Top left","top-center":"Top center","top-right":"Top right",left:"Left",center:"Center",right:"Right","bottom-left":"Bottom left","bottom-center":"Bottom center","bottom-right":"Bottom right"},we=ve.map(e=>({value:e,label:ye[e]}));function ke(e,n=ge){return ve.includes(e)?e:n}var xe=40,Ce=e=>"number"==typeof e?e:null;function je(e,n,t){const l={};for(const o of["x","y"])t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}var Fe=["top","right","bottom","left"],Oe={top:"sectionPaddingTop",right:"sectionPaddingRight",bottom:"sectionPaddingBottom",left:"sectionPaddingLeft"},Le=e=>"number"==typeof e?e:null;function Ke(e,n,t){const l={};for(const o of Fe)t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}function Se(e){if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const n=e&&"object"==typeof e?e:{};return Object.fromEntries(Fe.map(e=>[e,Le(n[e])]))}function Pe(e){const n={};for(const t of Fe)"number"==typeof e[t]&&(n[t]=e[t]);return Object.keys(n).length?n:void 0}function Ve(e,n={}){const t=n=>{const t=n[e];return t&&"object"==typeof t?t:{}},l=e=>Object.hasOwn(n,e)?n[e]:e;return{read:(e,n)=>t(e)[l(n)],write:(n,o,a)=>{const i={...t(n)};return void 0===a?delete i[l(o)]:i[l(o)]=a,{[e]:Object.keys(i).length?i:void 0}}}}function Ee(e,n,t){const l=Ae(e),o=d();if(t)return[t.value,t.onChange];const a=o?.values??{};return[e.read(a,n),e=>l([[n,e]])]}function Ae(e){const n=d();return t=>{n&&n.onChangeMany(n=>{let l={};for(const[o,a]of t)l={...l,...e.write({...n,...l},o,a)};return l})}}var Re={read:(e,n)=>e[n],write:(e,n,t)=>({[n]:t})},We={fieldKey:m,ownField:!0,read:(e,n)=>e[m(n)],write:(e,n,t)=>({[m(n)]:t})},Ie={fieldKey:h,ownField:!0,read:(e,n)=>e[h(n)],write:(e,n,t)=>({[h(n)]:t})},Me={...We,tablet:Ie};function Ne(e){return{...Ve(e),fieldKey:n=>`_${e}_${n}`}}function Te({row:e,desktopKey:n,access:t,wider:l,props:o}){const a=d(),i=a?.values??{},r=l?.read(i,n),s=v(i[n],r),u=g(r)?"desktop":"tablet",[c,p]=Ee(t,n);return t.ownField?e.render({...o,follows:s,followsView:u,twinAccess:t,widerAccess:l}):e.render({...o,value:c,storedValue:c,follows:s,followsView:u,twinAccess:t,widerAccess:l,onChange:p})}function Be(e,n,t=We,l={}){const a=l.phoneRow??n,i=(n,t)=>({...a,render:l=>/* @__PURE__ */Y(Te,{row:a,desktopKey:e,access:n,wider:t,props:l})}),r=t.tablet;return{[e]:o("desktop",n),...r?{[r.fieldKey(e)]:o("tablet",i(r))}:{},[t.fieldKey(e)]:o("mobile",i(t,r))}}var $e=["left","center","right"];function De(e,{options:n,value:t,onChange:l,ariaLabel:o,disabled:a=!1}){/* @__PURE__ */
|
|
3
|
+
return Y(w,{options:n.map(n=>n.picture?{id:n.value,label:n.picture,title:e(n.title??n.label)}:{id:n.value,label:e(n.label),title:void 0===n.title?void 0:e(n.title)}),value:t,onChange:l,ariaLabel:e(o),disabled:a})}function Ge(e,{label:n,value:t,onChange:l,points:o}){const a=o.find(e=>e.disabled),i=o.map(n=>({...n,label:e(n.label),...n.title?{title:e(n.title)}:null}));/* @__PURE__ */
|
|
4
|
+
return Y(k,{label:e(n),icon:/* @__PURE__ */Y(P,{}),hint:a?.title?e(a.title):void 0,children:/* @__PURE__ */Y(X,{label:e(n),value:t,points:i,onChange:l})})}function Je({say:e,label:n,value:t,onChange:l,pointsFor:o}){const{appState:a,selectedItem:i}=p(e=>e),r=i?.props?.id?String(i.props.id):void 0;return Ge(e,{label:n,value:t,onChange:l,points:o(a?.data,r)})}function He({say:e,o:n}){const t=d(),o=x("panel",f),a=t?.values??{},i={x:Ce(a[n.keys.x]),y:Ce(a[n.keys.y])},r=e(n.label??"Position"),s=Boolean(i.x||i.y),u=e=>{const l=je(n.keys,i,e);Object.keys(l).length&&t?.onChangeMany(l)},c=/* @__PURE__ */Y(_,{label:r,value:i,onChange:u,words:{x:e("Left and right"),y:e("Up and down"),unit:"px"},placeholder:{x:"0",y:"0"},min:n.min,max:n.max,step:n.step??1}),p=/* @__PURE__ */Y(l,{words:o,label:r,changed:s,detail:"0 px, 0 px",onReset:()=>u({x:null,y:null})});return null===n.label?/* @__PURE__ */Q("div",{className:"sf-position-line",children:[c,p]}):/* @__PURE__ */Y(k,{label:r,icon:/* @__PURE__ */Y(V,{}),changed:s,action:p,children:c})}var Xe={x:{start:/* @__PURE__ */Y(W,{}),center:/* @__PURE__ */Y(R,{}),end:/* @__PURE__ */Y(A,{}),stretch:/* @__PURE__ */Y(G,{}),between:/* @__PURE__ */Y(D,{})},y:{start:/* @__PURE__ */Y($,{}),center:/* @__PURE__ */Y(B,{}),end:/* @__PURE__ */Y(T,{}),stretch:/* @__PURE__ */Y(N,{}),between:/* @__PURE__ */Y(M,{})}},_e=e=>"row"===e?"row":"column";function ze({say:e,kind:n,label:t,options:l,value:o,onChange:a,o:i}){const r=d(),s="justify"===n==("row"===(i.runs??_e)(r?.values?.[i.directionKey??"direction"]))?"x":"y";return De(e,{options:l.map(e=>({label:e.label,value:e.value,picture:Xe[s][e.value]})),value:o,onChange:a,ariaLabel:t})}function Ye(e,n){const t=(e.useFallback??ee)(n);return Object.fromEntries(Fe.map(n=>[n,t?.[n]??e.fallback[n]]))}function Ze({say:e,tier:n,o:t,props:l}){const o=Ye(t,l),a=d(),i=a?.values??{},r="mobile"===n?t.phoneKeys:"tablet"===n?t.tabletKeys:t.keys,s=Object.fromEntries(Fe.map(e=>[e,Le(i[r[e]])])),u="desktop"===n?null:Object.fromEntries(Fe.map(e=>[e,v(Le(i[t.keys[e]]),"mobile"===n?Le(i[t.tabletKeys[e]]):null)]));/* @__PURE__ */
|
|
5
|
+
return Y(Ue,{say:e,o:t,fallback:o,value:s,follows:u,followsView:"mobile"===n&&Fe.some(e=>null!==Le(i[t.tabletKeys[e]]))?"tablet":"desktop",readOnly:l.readOnly,onChange:e=>{const n=Ke(r,s,e);Object.keys(n).length&&a?.onChangeMany(n)}})}function Qe({say:e,o:n,props:t}){const l=Ye(n,t);/* @__PURE__ */
|
|
6
|
+
return Y(Ue,{say:e,o:n,fallback:l,value:Se(t.value),follows:"follows"in t?Se(t.follows):null,followsView:t.followsView,readOnly:t.readOnly,onChange:e=>t.onChange(Pe(e))})}function Ue({say:o,o:a,fallback:i,value:r,follows:s,followsView:u,readOnly:c,onChange:d}){const p=Object.fromEntries(Fe.map(e=>[e,String(s?.[e]??i[e])])),[b,m]=C(()=>e(r,p)),h=x("panel",f),v=Fe.map(e=>p[e]),g=`${1===new Set(v).size?v[0]:v.join(" / ")}px`;/* @__PURE__ */
|
|
7
|
+
return Y(k,{label:o(a.label),icon:a.icon??/* @__PURE__ */Y(I,{}),action:/* @__PURE__ */Q(Z,{children:[
|
|
8
|
+
/* @__PURE__ */Y(t,{each:b,label:o("Each side"),onChange:m,disabled:c}),
|
|
9
|
+
/* @__PURE__ */Y(l,{words:h,label:o(a.label),changed:Fe.some(e=>"number"==typeof r[e]),detail:s?q(o,g,u):g,disabled:c,onReset:()=>d({top:null,right:null,bottom:null,left:null})})]}),children:/* @__PURE__ */Y(n,{label:o(a.label),each:b,value:r,placeholder:p,min:a.min,max:a.max,step:a.step,readOnly:c,onChange:d,words:{sides:{top:o("Padding top"),right:o("Padding right"),bottom:o("Padding bottom"),left:o("Padding left")},vertical:o("Top and bottom"),horizontal:o("Left and right"),unit:"px"}})})}var qe=e=>""===e||"px"===e?e:` ${e}`;function en({label:e,value:n,onChange:t,min:o,max:a,step:i=1,unit:r="",hint:s,emptyLabel:u,inputMax:c,readOnly:d=!1,clears:p,detail:f,resetWords:b}){const m="number"==typeof n,h=p?/* @__PURE__ */Y(l,{label:e,changed:m,detail:f??u??(void 0===s?void 0:`${s}${qe(r)}`),disabled:d,onReset:()=>t(void 0),...b?{words:b}:{}}):void 0;return{track:/* @__PURE__ */Y("div",{className:"sf-slider",children:/* @__PURE__ */Y(z,{min:o,max:a,step:i,value:n,suffix:r||void 0,showInput:!0,label:e,disabled:d,...p&&void 0!==s?{placeholderValue:s}:{},...u?{emptyLabel:u}:{},...void 0!==c?{inputMax:c}:{},size:"sm",boxSize:"md",className:"sf-slider-track",onChange:e=>{null===e?p&&m&&t(void 0):e!==n&&t(e)}})}),reset:h}}function nn({caption:e,label:n,value:t,hint:l,emptyLabel:o,...a}){const i=void 0!==l||void 0!==o,r="number"==typeof t,{track:s,reset:u}=en({...a,label:n,value:r?t:i?null:a.min,hint:l,emptyLabel:o,clears:i});/* @__PURE__ */
|
|
10
|
+
return Y(k,{label:e??n,action:u,children:s})}function tn({draw:e,props:n,useMax:t,useHint:l}){return e(n,{max:(t??ee)(n),hint:(l??ee)(n)})}function ln(e=U){function n(n,t,l,o,a,i,s="",u){const c="function"==typeof u?{action:u}:u??{},{action:d,clear:p}=c,f=(r,u)=>{const f="storedValue"in r?r.storedValue:r.value,b="follows"in r,m=b&&!1!==p?.phoneFollows,h=b||void 0!==p,v="number"==typeof r.value,g=void 0===p?i:u.hint??("function"==typeof p.hint?p.hint(r):p.hint)??i,y=m&&"number"==typeof r.follows?r.follows:g,w=qe(s),x=!p?.emptyLabel||m&&"number"==typeof r.follows?void 0:p.emptyLabel,C=x??`${y}${w}`,j="function"==typeof c.hint?c.hint(r):c.hint,{track:F,reset:O}=en({label:e(n),value:v?r.value:h?null:i,onChange:e=>r.onChange(e),min:l,max:u.max??o,step:a,unit:s,hint:h?y:void 0,emptyLabel:x,inputMax:c.inputMax,readOnly:!0===r.readOnly,clears:h,detail:m?q(e,C,r.followsView):C});/* @__PURE__ */
|
|
11
|
+
return Y(k,{label:e(n),icon:oe(t),hint:void 0===j?void 0:e(j),action:h?O:d?d(f,r.onChange):void 0,children:F})},b=c.useMax,m=p?.useHint;return{type:"custom",...r({},{type:"number",label:n}),render:b||m?e=>/* @__PURE__ */Y(tn,{draw:f,props:e,useMax:b,useHint:m}):e=>f(e,{})}}function t(n){return De(e,n)}function s(n,o,a,i,s={}){const u=a.map(e=>"string"==typeof e?{label:e,value:e}:e);return{type:"custom",...r({},{type:"radio",label:n,options:u.map(e=>({value:e.value,label:e.label}))}),render:a=>{const{value:r,onChange:c,field:d}=a,p=u.some(e=>e.value===r),f=!0===a.readOnly;if("follows"in a&&!u.some(e=>""===e.value)){const d=s.phoneRest?s.phoneRest(a.follows):a.follows,b=u.find(e=>e.value===d)??u.find(e=>e.value===i);/* @__PURE__ */
|
|
12
|
+
return Y(k,{label:e(n),icon:oe(o),action:/* @__PURE__ */Y(l,{label:e(n),changed:p,detail:q(e,e(b?.label??""),a.followsView),disabled:f,onReset:()=>c(void 0)}),children:t({options:u,value:p?r:b?.value??i,onChange:c,ariaLabel:n,disabled:f})})}const b="follows"in a&&s.followsLabel?s.followsLabel(a.follows):void 0;/* @__PURE__ */
|
|
13
|
+
return Y(k,{label:e(n),icon:oe(o),action:"follows"in a&&s.followsLabel?/* @__PURE__ */Y(l,{label:e(n),changed:null!=r&&""!==r,detail:void 0===b?void 0:q(e,e(b),a.followsView),disabled:f,onReset:()=>c(void 0)}):void 0,children:t({options:u,value:p?r:r||d?.currentValue||i,onChange:c,ariaLabel:n,disabled:f})})}}}function u(e,n){return n.phone?e.unshift({label:"Match desktop",value:"",picture:/* @__PURE__ */Y(E,{})}):n.inherit&&e.unshift({label:n.inherit,value:""}),e}function c(e,n){return n.inherit||n.phone?{...e,render:n=>e.render({...n,onChange:e=>n.onChange(""===e?void 0:e)})}:e}function d(e,n,t,l){if(l.access){const o=l.inherit?"":l.fallback??"left",a=t({...l,phone:!1}),i=e=>{const n="string"==typeof e&&""!==e&&a.some(n=>n.value===e)?e:o;return a.find(e=>e.value===n)?.label};return Be(e,n(l,o),l.access,{phoneRow:n({...l,phone:!0},"",i)})}return{[e]:o("desktop",n(l)),[m(e)]:o("mobile",n({...l,phone:!0},""))}}function p(e){return u(H(e.allow??$e).map(e=>({label:e.label,value:e.value,picture:e.icon})),e)}function f(e,n=e.fallback??"left",t){return c(s(e.label??"Text alignment",/* @__PURE__ */Y(j,{}),p(e),n,t?{followsLabel:t}:{}),e)}function v(e){const n={left:Xe.x.start,center:Xe.x.center,right:Xe.x.end};return u(H((e.allow??$e).filter(e=>e in n)).map(e=>({label:e.label,value:e.value,picture:n[e.value]})),e)}function g(e,n=e.fallback??"left",t){return c(s(e.label??"Block alignment",/* @__PURE__ */Y(F,{}),v(e),n,t?{followsLabel:t}:{}),e)}function w(n,t,l,o,a,i){return{type:"custom",options:o,fallback:a,...r({},{type:"radio",label:t,options:o.map(e=>({value:e.value,label:e.label}))}),render:({value:r,onChange:s,field:u})=>{const c=u.options??o,d=u.fallback??a,p=c.some(e=>e.value===r)?r:d;/* @__PURE__ */
|
|
14
|
+
return Y(k,{label:e(t),icon:oe(l),children:/* @__PURE__ */Y(ze,{say:e,kind:n,label:t,options:c,value:p,onChange:s,o:i})})}}}function x(e={}){return w("justify","Justify",/* @__PURE__ */Y(F,{}),ue,ue[0].value,e)}function C(e={}){return w("align","Item alignment",/* @__PURE__ */Y(J,{}),ce,"stretch",e)}function P(){const n=de;return{type:"custom",options:pe,fallback:pe[1].value,...r({},{type:"radio",label:n,options:pe.map(e=>({value:e.value,label:e.label}))}),render:({value:t,onChange:l,id:o,name:a})=>{const i=`${o??a??n}-label`;/* @__PURE__ */
|
|
15
|
+
return Y(k,{label:e(n),labelId:i,icon:/* @__PURE__ */Y(O,{}),action:/* @__PURE__ */Y(b,{checked:(r=t,!0===r||"wrap"===r),onChange:e=>l(e?pe[0].value:pe[1].value),ariaLabelledBy:i})});var r}}}function V({offered:e,fallback:n,resolve:t}){const l=t??(t=>e.some(e=>e.value===t)?t:n),o=s(fe,
|
|
16
|
+
/* @__PURE__ */Y(L,{}),e.map(e=>({label:e.label,value:e.value})),l(void 0));return{type:"custom",render:e=>o.render({...e,value:l(e.value),onChange:n=>e.onChange(n)})}}function A({min:e,max:t,step:l,builtIn:o,resolve:a,action:i,mark:r}){const s=n("Gap",/* @__PURE__ */Y(K,{}),e,t,l,o,"px",i),u=a??(e=>"number"==typeof e?e:o);return{...r,type:"custom",render:e=>s.render({...e,value:u(e.value,e.field),storedValue:e.value,onChange:n=>e.onChange(n)})}}function R(n,{fallback:t=ge,pointsFor:l}={}){return{type:"custom",render:({value:o,onChange:a})=>{const i=ke(o,t);return l?/* @__PURE__ */Y(Je,{say:e,label:n,value:i,onChange:a,pointsFor:l}):Ge(e,{label:n,value:i,onChange:a,points:we})}}}function W(n){return{[n.keys.x]:{type:"custom",render:()=>/* @__PURE__ */Y(He,{say:e,o:n})},[n.keys.y]:{...a({type:"custom",render:()=>/* @__PURE__ */Y(i,{})},"always"),reachedBy:n.keys.x}}}function I(n={}){const t={...Oe,...n.keys},l={keys:t,tabletKeys:Object.fromEntries(Fe.map(e=>[e,h(t[e])])),phoneKeys:Object.fromEntries(Fe.map(e=>[e,m(t[e])])),fallback:{top:0,right:0,bottom:0,left:0,...n.fallback},useFallback:n.useFallback,label:n.label??"Padding",icon:n.icon,min:n.min??0,max:n.max??200,step:n.step??4},r=!1!==n.phone,s=!1===n.group?{}:{_gSpacing:re("Padding")};if(n.object){const t={type:"custom",render:n=>/* @__PURE__ */Y(Qe,{say:e,o:l,props:n})};return ae({...s,...r?Be(n.object.key,t,n.object.phone):{[n.object.key]:t}})}const u=r&&!0===n.tablet,c=n=>{const t={type:"custom",render:t=>/* @__PURE__ */Y(Ze,{say:e,tier:n,o:l,props:t})};return r?o(n,t):t},d=()=>a({type:"custom",render:()=>/* @__PURE__ */Y(i,{})},"always"),p=Fe.filter(e=>"top"!==e);return ae({...s,[l.keys.top]:c("desktop"),...u?{[l.tabletKeys.top]:c("tablet")}:{},...r?{[l.phoneKeys.top]:c("mobile")}:{},...Object.fromEntries(p.map(e=>[l.keys[e],{...d(),reachedBy:l.keys.top}])),...u?Object.fromEntries(p.map(e=>[l.tabletKeys[e],o("tablet",d())])):{},...r?Object.fromEntries(p.map(e=>[l.phoneKeys[e],o("mobile",d())])):{}})}return{slider:n,select:function(n,t,o,a,i){const{note:s,phoneRest:u}="string"==typeof i?{note:i,phoneRest:void 0}:i??{};return{type:"custom",options:o,fallback:a,...s?{note:s}:{},...r({},{type:"select",label:n}),render:i=>{const{value:r,onChange:c,field:d}=i,p=d.options??o,f=d.fallback??a,b=p.some(e=>e.value===r),m="follows"in i,h=m?u?u(i.follows):i.follows:void 0,v=m?p.find(e=>e.value===h)??p.find(e=>e.value===f):void 0,g=b?r:v?.value??f,w=!0===i.readOnly;/* @__PURE__ */
|
|
17
|
+
return Y(k,{label:e(n),icon:oe(t),action:m?/* @__PURE__ */Y(l,{label:e(n),changed:null!=r&&""!==r,detail:v?q(e,e(v.label),i.followsView):void 0,disabled:w,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */Y(y,{value:g,ariaLabel:e(n),readOnly:w,onChange:c,options:[...s?[{label:e(s),value:"\0note",disabled:!0}]:[],...p.map(n=>({label:e(n.label),value:n.value}))]})})}}},Segmented:t,segmented:s,boxJustifyField:x,boxAlignField:C,boxWrapField:P,directionField:V,gapField:A,placementField:R,PlacementGridView:function(n){return Ge(e,n)},positionFields:W,sidesPaddingFields:I,alignmentField:function(e={},n=e.fallback??"left"){return f(e,n)},alignmentFields:function(e="align",n={}){return d(e,f,p,n)},AlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:p(e),value:n,onChange:l,ariaLabel:o,disabled:a})},blockAlignmentField:function(e={},n=e.fallback??"left"){return g(e,n)},blockAlignmentFields:function(e="align",n={}){return d(e,g,v,n)},BlockAlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:v(e),value:n,onChange:l,ariaLabel:o,disabled:a})},boxFieldSet:function(e={}){const t=e.width??he,l=e.nudge?.limit??40,o=e.direction??{offered:be,fallback:"column"},a=o.resolve??(e=>o.offered.some(n=>n.value===e)?e:o.fallback),i={runs:e=>"row"===a(e)?"row":"column"};return{_gLayout:re("Layout"),placement:R("Placement",e.placement),width:n("Width",/* @__PURE__ */Y(S,{}),t.min,t.max,t.step,t.fallback,"%"),direction:V(o),gap:A(e.gap??me),justify:x(i),align:C(i),wrap:P(),_gNudge:re("Nudge"),...W({keys:e.nudge?.keys??{x:"nudgeX",y:"nudgeY"},min:-l,max:l,label:null}),...I(e.padding)}}}}var{slider:on,select:an,Segmented:rn,segmented:sn,boxJustifyField:un,boxAlignField:cn,boxWrapField:dn,directionField:pn,gapField:fn,placementField:bn,PlacementGridView:mn,positionFields:hn,sidesPaddingFields:vn,alignmentField:gn,alignmentFields:yn,AlignmentStrip:wn,blockAlignmentField:kn,blockAlignmentFields:xn,BlockAlignmentStrip:Cn,boxFieldSet:jn}=ln();export{ye as ANCHOR_LABELS,wn as AlignmentStrip,ce as BOX_ALIGN_POINTS,be as BOX_DIRECTIONS,fe as BOX_DIRECTION_LABEL,me as BOX_GAP,ue as BOX_JUSTIFY_POINTS,xe as BOX_NUDGE_LIMIT,ve as BOX_PLACEMENTS,ge as BOX_PLACEMENT_DEFAULT,he as BOX_WIDTH,de as BOX_WRAP_LABEL,pe as BOX_WRAP_POINTS,Cn as BlockAlignmentStrip,Re as FLAT_ACCESS,we as OPEN_PLACEMENT_POINTS,We as PHONE_KEY_ACCESS,mn as PlacementGridView,Oe as SIDE_PAD_KEYS,rn as Segmented,nn as SliderControl,Me as VIEW_KEY_ACCESS,gn as alignmentField,yn as alignmentFields,kn as blockAlignmentField,xn as blockAlignmentFields,cn as boxAlignField,ln as boxFieldBuilders,jn as boxFieldSet,un as boxJustifyField,dn as boxWrapField,pn as directionField,fn as gapField,re as group,oe as iconOf,le as isNoGlyph,te as noGlyph,ke as normaliseBoxPlacement,Ve as objectAccess,q as onDesktopWords,Ne as phoneObjectAccess,Be as phoneTwinFields,bn as placementField,hn as positionFields,je as positionPatch,se as section,sn as segmented,an as select,ae as sharedStyleKinds,Se as sidesFromObject,vn as sidesPaddingFields,Ke as sidesPaddingPatch,Pe as sidesToObject,on as slider,Ae as useAccessPatch,Ee as useAccessValue};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-2262JGFV.js";import{useEaselHost as e}from"./chunk-LX23TCTP.js";import{createEasel as r,EaselProvider as o}from"./chunk-3W2O22DZ.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
|
|
2
2
|
return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styleFieldBuilders as e,keptByRow as s}from"./chunk-
|
|
1
|
+
import{styleFieldBuilders as e,keptByRow as s}from"./chunk-ZFEAWEFS.js";import{boxFieldBuilders as o,PHONE_KEY_ACCESS as l,phoneTwinFields as r,section as i}from"./chunk-76MUJIZE.js";import{deviceField as t}from"./chunk-ZNLODQD4.js";import{BUTTON_STYLE_KEYS as c,BUTTON_PAD_KEYS as n}from"./chunk-PLTTPHK5.js";import{TextColorIcon as u,GroundIcon as d}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";function a(a){const p=o(a.say),F=e(a.say),y=c,m=a.style,k=a.phone??l;return{...a.padding&&{_dSize:i("Size"),...p.sidesPaddingFields({keys:n,group:!1,...a.padding})},_dDesign:i("Design"),[y.fill]:F.colourField({key:y.fill,access:m,label:"Fill color",icon:/* @__PURE__ */f(d,{}),useFollows:a.follows.useFill,usePresets:a.usePresets,resetTo:a.resetTo,opacity:{key:y.fillOpacity,useUnset:a.follows.useFillOpacity}}),[y.fillOpacity]:s(y.fill),[y.border]:F.borderField({key:y.border,access:m,useFollows:a.follows.useBorder}),[y.text]:F.colourField({key:y.text,access:m,label:"Text color",icon:/* @__PURE__ */f(u,{}),useFollows:a.follows.useText,usePresets:a.usePresets,resetTo:a.resetTo}),[y.corners]:F.cornersField({key:y.corners,access:m,sidesKey:y.cornerSides,useFollows:a.follows.useCorners,useFollowsSides:a.follows.useCornerSides}),[y.cornerSides]:s(y.corners),_dLayout:i("Layout"),...r("align",p.blockAlignmentField({phone:!0},""),k),align:t("desktop",p.blockAlignmentField())}}export{a as buttonFieldSet};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=["desktop","tablet","mobile"],e={desktop:"Desktop",tablet:"Tablet",mobile:"Phone"},n=720,o=1100;function r(t){return t>=1100?"desktop":t>=720?"tablet":"mobile"}function a(t){return`${t}Tablet`}function u(t){return`${t}Phone`}function b(t){return null==t}var p=t=>e=>"number"==typeof e?e*t:e,h=t=>t;var l={spacing:{tablet:p(.75),phone:p(2/3),round:function(t){const e=Math.ceil(Math.abs(t)/4-.5);return 4*(t<0?-e:e)+0}},columns:{tablet:t=>"number"==typeof t?Math.min(t,2):t,phone:t=>"number"==typeof t?1:t},stack:{tablet:h,phone:t=>void 0===t?t:"stacked"},textSize:{tablet:p(.85),phone:p(.7/.85),round:Math.round},heightMode:{tablet:h,phone:t=>"px"===t?"fit":t},heightPx:{tablet:p(.75),phone:h,round:Math.round},same:{tablet:h,phone:h}},i=Object.fromEntries(Object.keys(l).map(t=>[t,{tablet:h,phone:h}]));function c(t,e,n,o,r=l){const a=r[t],u=t=>a.round&&"number"==typeof t?a.round(t):t,p=b(n)?a.tablet(e):n,h=b(o)?a.phone(p):o;return{desktop:e,tablet:b(n)?u(p):n,phone:b(o)?u(h):o}}function s(t,e){return c("same",t,e,void 0,i).phone}export{l as AUTO_RULES,i as FOLLOW_RULES,o as VIEW_DESKTOP_MIN,n as VIEW_TABLET_MIN,t as VIEW_TIERS,e as VIEW_TIER_LABEL,b as isAuto,u as phoneKey,c as resolveViewValue,a as tabletKey,s as viewFollows,r as viewTierForWidth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{DESIGN_GROUP_KEY as o,BUCKET_KEY as n}from"./chunk-3QB2ZQXK.js";import{withoutDeviceGate as e}from"./chunk-ZNLODQD4.js";import{STYLE_KIND as r,fieldKind as s,copyStyle as i,heldStyle as c,planPaste as p,pasteMessage as u}from"./chunk-CWELHADJ.js";import{ANCHOR_FIELD_KEYS as a,foldMetaOf as f,MEDIA_FIELD_MARKER as l,TEXT_FIELD_MARKER as m,LINK_FIELD_MARKER as h}from"./chunk-ANPOR6EY.js";import{deviceMetaOf as y}from"./chunk-YCSZAP7T.js";var j=/* @__PURE__ */new Set([o.Size,o.Design,o.Layout,o.Position]),w=new Set(Object.values(o)),b=new Set(Object.values(n)),S=new Set(a),k=/* @__PURE__ */new Set(["focal","imageFocal"]),g=[l,m,h];function v(t){return`site:${t??""}`}function A(t){if(!t||"object"!=typeof t)return null;const o=t,n=e(t)??t,i=o[r]??n[r];if("string"==typeof i)return i;const c=o.options??n.options;if(Array.isArray(c)){return`choice:${c.map(t=>String(t?.value)).sort().join("|")}`}return s(n)}function D(t){const o=t,n=e(t);return g.some(t=>t in o||n&&t in n)}function L(o,e){const r=t(o,e)??{},s=[];let i=!0,c=!1;for(const[t,o]of Object.entries(r))b.has(t)?(i=t===n.Design,c=!1):w.has(t)?i&&(c=j.has(t)):c&&o&&"object"==typeof o&&!t.startsWith("_")&&(f(o)||S.has(t)||k.has(t)||D(o)||"slot"!==o.type&&s.push({path:[t],kind:A(o),counted:"mobile"!==y(o)?.tier&&"tablet"!==y(o)?.tier}));return s}function O(t,o,n,e,r){i({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function d(t,o,n,e,r,s){const i=c(n);if(!i)return null;const a=p(i,{type:e.type,rows:t(o,e),props:e.props});return{...a,message:u(a,i.sourceLabel,r,s)}}function P(t,o,n,e){O(L,t,o,n,e)}function Q(t,o,n,e,r){return d(L,t,o,n,e,r)}var X={scope:t=>v(t.siteId),rows:(t,o)=>L(t,o),copy:(t,o,n,e)=>P(e,t,o,n),plan:(t,o,n,e)=>Q(e,t,o,n)};function Z(t,o){if(!t&&!o)return X;const n=t?.rows,e=n?(t,o)=>n(t,o):L;return{scope:t?.scope??X.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>O(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>d(e,s,t,n,r,o))}}export{P as copyNodeStyle,L as nodeStyleRows,Q as planNodePaste,A as shopFieldKind,v as siteStyleScope,Z as styleClipboardOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,writeLate:"That took too long. Your change is kept, but the last step did not finish.",add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{
|
|
1
|
+
var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,writeLate:"That took too long. Your change is kept, but the last step did not finish.",add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{mobile:"Showing the phone settings for this section."}},s={focus:"Image focus",onDesktop:e=>`${e} on desktop`,pasteLink:"or paste an image URL",pasteName:"Image URL",template:"Templates don’t store images. This slot stays a placeholder. Each website picks its own after it’s created.",templateVideo:"Templates don’t store videos. This slot stays a placeholder. Each website picks its own after it’s created."};export{s as DEFAULT_IMAGE_ROW_WORDS,e as DEFAULT_SCREEN_ADD_WORDS,o as DEFAULT_SCREEN_SAVE_STATUS_WORDS,t as DEFAULT_SCREEN_SHARED_WORDS,n as DEFAULT_SCREEN_WORDS};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{
|
|
1
|
+
import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{deviceMetaOf as t,noControlMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{SETTINGS_BUCKETS as o,SettingsGroup as a}from"./chunk-D4TH4QQR.js";import{DEFAULT_TREE_WORDS as i}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-56ID6FKZ.js";import{easelMenuEntries as c}from"./chunk-FIVU2COQ.js";import{FieldNumber as d}from"./chunk-Y2T3JX7K.js";import{FieldSelect as u}from"./chunk-KFWNGPW3.js";import{SettingsSegmented as m}from"./chunk-DX3VILZ3.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{DEFAULT_FIELDS_WORDS as p}from"./chunk-JACEEVVF.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{useTreeDrag as b,gapToMoveIndex as g}from"./chunk-3XECMGXX.js";import{withTip as v}from"./chunk-P2VEMZH5.js";import{clone as y}from"./chunk-EUFDQ4KL.js";import{Textarea as w,Input as k,ItemCount as x,SortableList as C,ListRow as O,IconButton as j,ContextMenu as N,tabPanelId as D,Tabs as $,tabButtonId as I}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as S,useState as P,useLayoutEffect as F,useId as L}from"react";import{jsx as E,jsxs as T,Fragment as M}from"react/jsx-runtime";import{LockIcon as R,CloseIcon as z,MoveUpIcon as W,MoveDownIcon as A,DuplicateIcon as B,TrashIcon as H}from"efficient-shell/icons/efficient";function K({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:o=3,readOnly:a=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */E(w,{id:e,size:"sm",className:"es-fin",value:c,rows:o,placeholder:l,readOnly:a,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */E(k,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:a,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function X(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function V(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function Y(e,n){return e.filter((e,t)=>t!==n)}var Q='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',Z={parentId:"list",slot:"items"};function G({label:e,icon:n,noun:t,items:l,onChange:o,newItem:a,summary:s,itemName:d,thumb:u,min:m=0,max:h,readOnly:w=!1,open:k,onOpen:D,renderItem:$,renderRow:I,canRemove:L,lockedReason:K,fixed:G=!1,removeOnRow:U=!0,canDuplicate:q,above:J,head:_=!0}){const ee=f("fields",p).list,ne=f("tree",i),te=t??ee.item,le=!w&&!G&&("number"!=typeof h||l.length<h),re=l.length<=m,oe=e=>!!L&&!L(l[e],e),ae=e=>!w&&!G&&U&&!re&&!oe(e),ie=e=>le&&(!q||q(l[e],e)),se=(e,n)=>d?d(e,n):ee.itemName({noun:te,n:n+1}),ce=S([]),de=S(null),[ue,me]=P(null),he=S(null),[pe,fe]=P(null),[be,ge]=P("");F(()=>{const e=de.current;if(!e)return;de.current=null;const n=ce.current[e.index]?.querySelectorAll(Q)[e.nth]??ce.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const ve=(e,n)=>{if(n<0||n>=l.length||n===e)return;const t=ce.current[e],r=t?.ownerDocument.activeElement;if(t&&r&&t.contains(r)){const e=[...t.querySelectorAll(Q)].indexOf(r),l=r;de.current={index:n,nth:e,start:"number"==typeof l.selectionStart?l.selectionStart:null,end:"number"==typeof l.selectionEnd?l.selectionEnd:null}}o(V(l,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(k,e,n);a!==k&&D(a),ge(ee.moved({n:n+1,total:l.length}))},ye=e=>{le&&(o(X(l,e,a())),I?(de.current={index:e,nth:0,start:null,end:null},null!==k&&k>=e&&D(k+1)):D(e))},we=e=>{ae(e)&&(o(Y(l,e)),k===e?D(null):null!==k&&k>e&&D(k-1))},ke=b({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===Z.parentId&&n.slot===Z.slot,onDrop:(e,n)=>{const t=g({...Z,index:e},n);t!==e&&ve(e,t)},onStep:(e,n)=>ve(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<l.length,readOnly:w}),xe=e=>{const n=[];return e>0&&n.push({label:ee.moveUp,icon:/* @__PURE__ */E(W,{size:14}),shortcut:"⌥↑",onClick:()=>ve(e,e-1)}),e<l.length-1&&n.push({label:ee.moveDown,icon:/* @__PURE__ */E(A,{size:14}),shortcut:"⌥↓",onClick:()=>ve(e,e+1)}),ie(e)&&n.push({label:ee.duplicate,icon:/* @__PURE__ */E(B,{size:14}),onClick:()=>(e=>{ie(e)&&(o(X(l,e+1,y(l[e]))),null!==k&&k>e&&D(k+1))})(e)}),ae(e)&&n.push({label:ee.delete,icon:/* @__PURE__ */E(H,{size:14}),danger:!0,onClick:()=>we(e)}),n},Ce=(e,n,t,l)=>{w||0===xe(e).length||fe({index:e,x:n,y:t,owner:l})},Oe=e=>n=>{const t=l.slice();t[e]=n,o(t)};/* @__PURE__ */
|
|
2
2
|
return T("div",{className:"es-list",children:[_?/* @__PURE__ */T("div",{className:"es-list-head",children:[
|
|
3
3
|
/* @__PURE__ */T("span",{className:"es-list-label",children:[n?/* @__PURE__ */E("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
|
|
4
|
-
/* @__PURE__ */E(
|
|
5
|
-
/* @__PURE__ */E(O,{className:i,flat:!!
|
|
6
|
-
/* @__PURE__ */E("span",{className:"es-list-row-name",children:se(e,n)}),
|
|
7
|
-
/* @__PURE__ */E(r,{...
|
|
4
|
+
/* @__PURE__ */E(x,{count:l.length,label:ee.count({noun:te,n:l.length}),showZero:!0})]}):null,J?/* @__PURE__ */E("div",{className:"es-list-above",children:J}):null,l.length?/* @__PURE__ */T(C,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ke.rootProps(),children:[l.map((e,n)=>{const t=ke.row({item:n,place:{...Z,index:n}}),l=t.draggable&&ue!==n,o=!I&&k===n,a=!w&&!G&&U&&oe(n),i=["es-list-row",I?"is-inline":"is-item",o?"is-open":"",l?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */E(r,{...ke.seam({place:{...Z,index:n}}),onAdd:le?()=>ye(n):void 0,label:ee.addHere({noun:te})},`seam-${n}`):null,
|
|
5
|
+
/* @__PURE__ */E(O,{className:i,flat:!!I,active:o,title:I?void 0:/* @__PURE__ */T(M,{children:[
|
|
6
|
+
/* @__PURE__ */E("span",{className:"es-list-row-name",children:se(e,n)}),s?/* @__PURE__ */E("span",{className:"es-list-row-summary",children:s(e,n)}):null]}),thumb:!I&&u?u(e,n):void 0,expanded:I?void 0:o,onToggle:I?void 0:()=>D(o?null:n),draggable:t.draggable,dragHint:ne.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>ve(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{ce.current[n]=e},rowProps:{...t.rowProps,draggable:l||void 0,onPointerDown:e=>{const l=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!l&&l===l.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!r,he.current=l&&!r?l:null,me(r?n:null)},onDragStart:e=>{const n=he.current;he.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),Ce(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void Ce(n,r.left+24,r.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:w||G||!U?void 0:a?v(K?K(e,n):ee.locked,/* @__PURE__ */E("span",{className:"es-list-lock",role:"img","aria-label":K?K(e,n):ee.locked,children:/* @__PURE__ */E(R,{size:13})})):v(ee.deleteItem({noun:te}),/* @__PURE__ */E(j,{size:"sm",className:"es-list-x","aria-label":ee.deleteItem({noun:te}),disabled:!ae(n),onClick:()=>we(n),children:/* @__PURE__ */E(z,{size:14,"aria-hidden":"true"})})),below:o?/* @__PURE__ */E("div",{className:"es-list-item",children:$(e,n,Oe(n))}):void 0,children:I?/* @__PURE__ */E("div",{className:"es-list-row-main",children:I(e,n,Oe(n))}):null},n)]}),
|
|
7
|
+
/* @__PURE__ */E(r,{...ke.seam({place:{...Z,index:l.length}})})]}):null,w||G?null:/* @__PURE__ */E("button",{type:"button",className:"es-list-add",disabled:!le,onClick:()=>ye(l.length),children:ee.add({noun:te})}),
|
|
8
8
|
/* @__PURE__ */E("span",{className:"es-list-said","aria-live":"polite",children:be}),pe&&pe.index<l.length?
|
|
9
|
-
/* @__PURE__ */E(
|
|
10
|
-
return E(
|
|
9
|
+
/* @__PURE__ */E(N,{at:{x:pe.x,y:pe.y},owner:pe.owner,onClose:()=>fe(null),items:c(xe(pe.index))}):null]})}var U=e=>e<6?e+1:6,q=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function J({field:e,name:t,id:l,value:r,onChange:o,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=P(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
|
|
10
|
+
return E(a,{id:`${l}-group`,title:q(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */E(ee,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>o({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:U(u)},e))})}function _({field:e,name:t,id:l,value:r,onChange:o,readOnly:a,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=P(null),f=u?d??null:h,b=u??p,g=Array.isArray(r)?r:[],v=e.getItemSummary;/* @__PURE__ */
|
|
11
11
|
return E(G,{label:q(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:o,newItem:()=>y({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:f,onOpen:b,renderItem:(r,o,d)=>Object.entries(n(e.arrayFields,{values:r,context:s})).map(([e,n])=>/* @__PURE__ */E(ee,{field:n,name:`${t}[${o}].${e}`,id:`${l}-${o}-${e}`,value:r?.[e],onChange:n=>d({...r,[e]:n}),readOnly:a,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function ee(e){const{field:n,name:t,id:l,value:r,onChange:o,readOnly:a,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const c=s?.[n.type];if(c)return c({field:n,name:t,id:l,value:r,onChange:o,readOnly:a});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:r,onChange:o,readOnly:a};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
12
12
|
return E(h,{label:q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(K,{id:l,value:"string"==typeof r?r:null==r?"":String(r),onChange:o,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:a})});case"number":/* @__PURE__ */
|
|
13
13
|
return E(h,{label:q(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(d,{id:l,value:"number"==typeof r?r:void 0,onChange:o,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:a})});case"select":{const e=`${l}-label`;/* @__PURE__ */
|
|
14
14
|
return E(h,{label:q(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(u,{id:l,value:r,options:n.options,onChange:o,readOnly:a,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
|
|
15
|
-
return E(h,{label:q(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(
|
|
15
|
+
return E(h,{label:q(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(m,{ariaLabel:q(n,t),value:r,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||a})),onChange:e=>{a||o(e)}})});case"object":/* @__PURE__ */
|
|
16
16
|
return E(J,{...e,field:n});case"array":/* @__PURE__ */
|
|
17
|
-
return E(_,{...e,field:n});case"slot":return null}}function ne(e,n,r){if("mobile"!==n)return!0;const o=e;if(o&&"string"==typeof o.reachedBy){const t=r?.[o.reachedBy];return void 0!==t&&t!==e&&ne(t,n)}if(!o||o.marker||"slot"===o.type
|
|
18
|
-
return T("div",{className:"es-insp",children:[X?/* @__PURE__ */E("div",{className:"es-insp-tabs",children:/* @__PURE__ */E(
|
|
19
|
-
/* @__PURE__ */T("div",{className:"es-insp-rows",id:V,role:X?"tabpanel":void 0,"aria-labelledby":X&&A?
|
|
20
|
-
return E("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!q(t)&&!l)||void 0,children:G(e.fold,e.rows.map(J))},`fold-${e.fold.key}-${n}`)}),y]})]})}export{K as FieldText,se as Inspector,ee as InspectorField,G as ListField,oe as bucketsOf,ne as fieldShownInView,X as insertAt,q as labelOf,V as moveTo,re as planFields,Y as removeAt};
|
|
17
|
+
return E(_,{...e,field:n});case"slot":return null}}function ne(e,n,r){if("mobile"!==n&&"tablet"!==n)return!0;const o=e;if(o&&"string"==typeof o.reachedBy){const t=r?.[o.reachedBy];return void 0!==t&&t!==e&&ne(t,n)}if(!o||o.marker||"slot"===o.type)return!0;const a=t(e)?.tier;return a?a===n||"each"===a:"always"===l(e)}var te={},le=e=>o.includes(e);function re(n,t){let l,r=o[0];const a=[],i=/* @__PURE__ */new Set;for(const[o,s]of Object.entries(n))s&&(le(s.bucket)&&((s.marker||s.bucket!==r)&&(l=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?l={key:o,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||t&&!ae(s,n,t)||t&&!ne(s,t.context?.device,n)||(a.push(l?{name:o,field:s,bucket:r,fold:l}:{name:o,field:s,bucket:r}),"slot"!==s.type&&i.add(r)));return{rows:a,buckets:o.filter(e=>i.has(e))}}function oe(e){return new Map(re(e).rows.map(e=>[e.name,e.bucket]))}function ae(n,t,l){const r=n.reachedBy;if("string"!=typeof r)return!0;const o=t[r];return!!o&&!1!==o.visible&&e(o,l)}function ie(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function se({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:i,tab:c,onTab:d,tabs:u=!0,allTabs:m=!1,tabIcons:h,renderers:p,idPrefix:b,ariaLabel:g,lead:v,children:y,leadFold:w,closedFolds:k,onFold:x,headingLevel:C=3}){const O=f("panel",s),j=L(),N=b??`es-insp${j.replace(/:/g,"")}`,S=re(e,{values:n,context:i}),[F,M]=P(void 0),R=F&&(F.panel===N||S.buckets.includes(F.tab))?F.tab:void 0,z=c??R,W=m?o:S.buckets,A=z&&W.includes(z)?z:S.buckets[0]??W[0],[B,H]=P(null),K=B&&B.panel===N&&S.rows.some(e=>e.name===B.name)?B:null,X=u&&W.length>1,V=X&&A?D(N,A):`${N}-rows`,[Y,Q]=P(()=>/* @__PURE__ */new Set),Z=k??Y,G=(e,n)=>{/* @__PURE__ */return E(a,{title:e.title,open:!Z.has(e.key),onToggle:n=>((e,n)=>{void 0===k&&Q(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),x?.(e,n)})(e.key,n),id:`${N}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:C,children:n});var t},q=e=>X&&e!==A,J=({name:e,field:o,bucket:a,fold:s})=>/* @__PURE__ */E("div",{className:"es-insp-row","data-field":e,"data-bucket":a,hidden:!!q(a)||void 0,children:/* @__PURE__ */E(ee,{field:o,name:e,id:`${N}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:i,renderers:p,openItem:K&&K.name===e?K.index:null,onOpenItem:n=>H(null===n?null:{panel:N,name:e,index:n}),headingLevel:s?U(C):C})},e);/* @__PURE__ */
|
|
18
|
+
return T("div",{className:"es-insp",children:[X?/* @__PURE__ */E("div",{className:"es-insp-tabs",children:/* @__PURE__ */E($,{variant:"underline",block:!0,"aria-label":g??O.settings,idPrefix:N,value:A,onChange:e=>{const n=e;void 0===c&&M({panel:N,tab:n}),d?.(n)},items:W.map(e=>{const n=O.buckets[e],t=h?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */E("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
|
|
19
|
+
/* @__PURE__ */T("div",{className:"es-insp-rows",id:V,role:X?"tabpanel":void 0,"aria-labelledby":X&&A?I(N,A):void 0,children:[v&&ne(te,i?.device)?w?/* @__PURE__ */E("div",{className:"es-insp-band","data-fold":w.key,children:G(w,v)}):v:null,ie(S.rows).map((e,n)=>{if(!e.fold)return e.rows.map(J);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
|
|
20
|
+
return E("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!q(t)&&!l)||void 0,children:G(e.fold,e.rows.map(J))},`fold-${e.fold.key}-${n}`)}),y]})]})}function ce(e,n,l=ne){const r=t(e)?.tier,o=t=>l(e,t,n)&&r!==t&&"each"!==r?1:0;return{phoneShared:o("mobile"),tabletShared:o("tablet")}}function de(e){const{arrayFields:n,objectFields:t}=e;return Object.values(n??t??{}).reduce((e,n)=>e+1+de(n),0)}var ue=/\buse(?:PreviewDevice\(\)|(?:Context)?\(PreviewDeviceContext\))|\b(?:previewD|d)evice\s*(?:[!=]==?|\?)|(?:[!=]==?)\s*(?:previewD|d)evice\b|switch\s*\(\s*(?:previewD|d)evice\b|shownTier\(\w+\)\s*[!=]==|\btier\s*[!=]==\s*"(?:mobile|tablet|desktop|each)"|context:\s*"device"/g;function me(e){return e.match(ue)??[]}export{K as FieldText,se as Inspector,ee as InspectorField,G as ListField,oe as bucketsOf,ne as fieldShownInView,de as innerRowCount,X as insertAt,q as labelOf,V as moveTo,re as planFields,Y as removeAt,ce as rowViewState,me as viewReadsIn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-G2VZ4DET.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as b,CLAIM_FAIL_OPEN_MS as S,holderOf as I}from"./chunk-YYD257TD.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as E,useMemo as T,useCallback as B,useEffect as A,useRef as C}from"react";import{jsx as H}from"react/jsx-runtime";var D={content:[],root:{},zones:{}};var L=j(null);function N(){const e=R(L);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function O({target:j,addressing:R=o,onHostMessage:N,children:O}){const Y=R,{homeSlug:F,entryMayBounce:M,entryBounce:W,onSwitch:V,tellsHost:G,adapterFor:K,migrateRenamedProps:U,describeMissing:X,onLoadFailed:x}=Y,[Q,Z]=E(j),z=k(),J=d(),_=T(()=>f(J),[J]),q=T(()=>t(J),[J]),$="template"===Q.kind,ee="template"===Q.kind?Q.id:null,re="template"===Q.kind?Q.pageSlug??F??"":"document"===Q.kind?Q.slug??"":Q.slug,ne="page"===Q.kind?Q.siteId??null:null,te=J.blocks,oe=T(()=>K(Q,_,te),[K,_,te,Q.kind,"template"===Q.kind?Q.id:"document"===Q.kind?Q.record:Q.siteId]),ue=oe.capabilities,ae=B(e=>J.documentHooks?.stored?.(e)??e,[J]);A(()=>{m(J,ne)},[J,ne]);const se=C(Q);A(()=>{se.current=Q},[Q]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(N?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Er(e.target)}}}),de=!J.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=E(null),[ge,pe]=E(null),[he,ye]=E(null),[we,be]=E(null),Se=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,Se):null,[Pe,je]=E(null),Re=C(null),Ee=C(null),[Te,Be]=E(!1),Ae=C(null),[Ce,He]=E(null),De=C(null),[Le,Ne]=E(null),[Oe,Ye]=E(!1),Fe=C(null);A(()=>{Fe.current=Le},[Le]);const[Me,We]=E(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ve=C(Me);A(()=>{Ve.current=Me},[Me]);const Ge=C(()=>Promise.resolve(!1)),Ke=B(e=>{Ee.current=e,Be(!0)},[]),Ue=g({save:async({id:e,data:r})=>{if(p(Ve.current)){if(!await Ge.current(e,r)){if(!p(Ve.current))return void Ke({id:e,data:r});throw new Error("page save did not land")}}else Ke({id:e,data:r})},onFailure:(e,r)=>{0===r&&z.send("storefront-editor:save-failed")}}),{state:Xe,push:xe,flush:Qe,pause:Ze,resume:ze,stop:Je,reset:_e,retryNow:qe,hasPending:$e}=Ue,er=C(Xe);A(()=>{er.current=Xe},[Xe]);const rr=u(Xe),nr=B(()=>{const e=Ee.current;e&&(Ee.current=null,Be(!1),xe(e))},[xe]),tr=C("");tr.current||(tr.current=h());const[or,ur]=E(0),ar=C(!1),[sr,ir]=E(M(j)),lr=C(!1);A(()=>{if(lr.current)return;lr.current=!0;const e=z.address.search(),r=W(j,e);r?z.address.load(r):M(j)&&ir(!1)},[j,z]);const cr=z.send;A(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=J.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void z.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:X?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),De.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:D,s=U(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},J),cause:r(o,J)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=B(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=B(async e=>{const r=le.current;if(!r&&J.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,J)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,J]),mr=B(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=B(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ve.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,De.current,tr.current));if(t.ok)return De.current=t.value.version??De.current,Ye(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ve.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return De.current=n.value,Ge.current(e,r,!0)}Je(),Fe.current=u,Ne(u)}return Ye(i(t.error,J)?.status===c),!1},[oe,fr,Je,J]);A(()=>{Ge.current=kr},[kr]);const vr=B(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ae.current=r,p(Ve.current)?xe({id:ke,data:r}):Ke({id:ke,data:r})},[ke,cr,Ke,xe,ae]),gr=B(async()=>{p(Ve.current)&&nr();return await Qe()&&null==Ee.current},[nr,Qe]),pr=C(gr);A(()=>{pr.current=gr},[gr]);const hr=C(fr);A(()=>{hr.current=fr},[fr]);const yr=B(()=>{z.address.reload()},[z]),wr=C(()=>Promise.resolve(!1));A(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:De.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const br=null!==Pe;A(()=>{if(!fe||!ke||!de||br)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ve.current,heldWrite:()=>({pending:null!=Ee.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ve.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(b)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,br]);const Sr=B(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=B(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=B(()=>{er.current.paused?(p(Ve.current)&&nr(),ze()):Ze()},[nr,Ze,ze]),jr=B(()=>{qe()},[qe]),Rr=B(e=>{Ae.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Ee.current=null,Be(!1)},setVersion:e=>{De.current=e},setSaveConflict:Ne,setAccess:We}),V(e),Z(e),Re.current=null,je(null),ve(null),pe(null),ye(null),be(null),z.address.show(e),"document"!==e.kind&&G(e)&&z.send("storefront-editor:navigated",{target:e})},[_e,z,me,V,G]),Er=B(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Ee.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?He(e):Qe().then(r=>{r?Rr(e):He(e)})},[Rr,$e,Qe,F]),Tr=B(()=>He(null),[]),Br=B(()=>{He(e=>(e&&Rr(e),null))},[Rr]),Ar=B(async()=>{const e=Ce;if(!e)return;await gr()&&(He(null),Rr(e))},[Ce,gr,Rr]),Cr=B(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ve.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,De.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}De.current=t.value.version??De.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
|
|
2
|
+
return H(L.Provider,{value:{target:Q,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ae.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Xe,autoSaveEnabled:!Xe.paused,autoSaveStoppedByConflict:Xe.stopped,hasUnsavedEdits:Xe.pending||Te,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Cr,access:Me,readOnly:null!==I(Me)||null!==Pe||null!==Le,readOnlyReason:Pe,takeOverEditing:Sr,viewReadOnly:Ir,saveConflict:Le,saveUnreachable:Oe,reloadFromServer:yr,navigate:Er,pendingNav:Ce,cancelPendingNav:Tr,discardAndNavigate:Br,saveAndNavigate:Ar},children:O})}export{L as ScreenDocumentContext,O as ScreenDocumentProvider,N as useScreenDocument};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-GDO4QJ4G.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as r}from"./chunk-N7E6264U.js";import{sharedSectionsOf as l}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SBVIW3KJ.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as p,useScreenPinned as d}from"./chunk-
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */F
|
|
4
|
-
/* @__PURE__ */F
|
|
5
|
-
return x
|
|
6
|
-
/* @__PURE__ */
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-GDO4QJ4G.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as r}from"./chunk-N7E6264U.js";import{sharedSectionsOf as l}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SBVIW3KJ.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as p,useScreenPinned as d}from"./chunk-2262JGFV.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-G2VZ4DET.js";import{useEasel as u}from"./chunk-3W2O22DZ.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SQTVXE5D.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as w}from"react";import{SharedIcon as C,AddIcon as O}from"efficient-shell/icons/efficient";import{ContextMenu as E,toast as I,Dialog as $,Button as F}from"efficient-shell/ui";import{jsx as G,jsxs as T,Fragment as x}from"react/jsx-runtime";function D({name:e,pages:t,onDelete:n,onCancel:o}){const r=h("screen",f).shared,[l,i]=b(!1),s=w(null);/* @__PURE__ */
|
|
2
|
+
return G($,{open:!0,role:"alertdialog",size:"sm",title:r.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */T(x,{children:[
|
|
3
|
+
/* @__PURE__ */G(F,{ref:s,variant:"secondary",onClick:o,children:r.cancel}),
|
|
4
|
+
/* @__PURE__ */G(F,{variant:"danger",loading:l,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:r.deleteShared})]}),children:r.deleteMessage({count:t})})}var S=e=>`section:${e}`,W=e=>`block:${e}`,M=e=>`template:${e}`,Q=e=>`shared:${e}`,V=e=>`preset:${e}`;function B({at:w,placeBlocks:$,canTake:F,onPick:B,itemFor:H,session:J,siteWide:z,onClose:A,onHide:L,readOnly:N}){const U=u(e=>e.config),R=a(),{labelAtLevel:Y,categoryLabel:Z,firstSection:P,Icon:X,Thumbnail:_}=R,{blockIsOffered:K,canAddTo:q}=p(),ee=h("screen",f).add,te=h("drag",g).add,ne=m(),[oe,re]=b([]);v(()=>{let e=!1;const t=e=>K(e,ne);return r(ne).list().then(n=>{if(e)return;const r=U.components;re(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[U,ne]);const le=d().shared,ie=h("screen",f).shared,[se,ce]=b([]),[ae,pe]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>K(e,ne);return l(ne).list().then(n=>{if(e)return;const r=U.components;ce(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[U,ne,ae]);const[de,me]=b(null),[fe,ue]=b(null),ye=j(()=>e(U,R),[U]),he=e=>Y(e,"section",U.components[e]?.label??e),ke=e=>({type:e.preset?V(e.preset.key):S(e.type),label:e.name,cover:/* @__PURE__ */G(_,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:ee.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ge=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=oe.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=se.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}if("preset"===n){const e=ye.find(e=>e.preset?.key===o)?.preset;return e?{kind:"preset",preset:e}:null}return null},be=e=>/* @__PURE__ */G("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */G(X,{type:e,size:26})}),ve=j(()=>{const e=t(ye,P),o=/* @__PURE__ */new Map,r=e=>{e.retired||o.has(e.type)||!K(e.type,ne)||o.set(e.type,e)};for(const t of e?[e]:ye.filter(e=>!e.preset)){const e=q(t.type)?.choices??[];e.forEach(r),e.forEach(e=>q(e.type,1)?.choices?.forEach(r))}$?.forEach(r);const l=new Set(ye.filter(e=>!e.preset).map(e=>e.type)),i=[...o.values()].filter(e=>!l.has(e.type)),s=e=>({type:W(e.type),label:e.label,cover:be(e.type),title:ee.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>!e.preset&&o.has(e.type)?{...ke(e),cover:be(e.type)}:ke(e),p=[];se.length>0&&p.push({key:"shared",title:ie.group,tiles:se.map(e=>({type:Q(e.id),label:e.title,cover:/* @__PURE__ */G(_,{type:e.node.type}),mark:/* @__PURE__ */G(C,{size:12}),title:ie.onPages({count:e.used_on.length}),keywords:[he(e.node.type),e.node.type]}))}),oe.length>0&&p.push({key:"templates",title:ee.templates,tiles:oe.map(e=>({type:M(e.id),label:e.name,cover:/* @__PURE__ */G(_,{type:e.node.type}),keywords:[he(e.node.type),e.node.type]}))});const d=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(U.categories??{})){const o=ye.filter(e=>e.cat===t);if(0===o.length)continue;const r=e&&o.some(t=>t.type===e.type)?e:null,l=(r?[r,...o.filter(e=>e.type!==r.type)]:o).map(a);r&&!m&&(l.splice(1,0,...d.map(s)),m=!0),p.push({key:`category:${t}`,title:n(U,t,Z),tiles:l})}const f=p.find(e=>e.key?.startsWith("category:"));if(!m&&f&&d.length>0&&(f.tiles=[...f.tiles,...d.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!F)return p;const u=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ge(e.type),n=t?F(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[oe,se,ie,ye,U,ee,F,$,ne]);/* @__PURE__ */
|
|
5
|
+
return T(x,{children:[
|
|
6
|
+
/* @__PURE__ */G(i,{icon:/* @__PURE__ */G(O,{size:15}),title:ee.title,context:ee.contextAll,actions:/* @__PURE__ */G(s,{label:ee.done,description:ee.doneDescription,onClick:A}),onHide:L}),
|
|
7
|
+
/* @__PURE__ */T("div",{className:"sf-addside sf-scroll",children:[
|
|
8
|
+
/* @__PURE__ */G(k,{groups:ve,session:J,itemFor:e=>H(ge(e)??{kind:"section",type:e}),onInsert:B?e=>{const t=ge(e);t&&B(t)}:void 0,onTileMenu:(e,t)=>{const n=ge(e);return"shared"===n?.kind&&!N&&(me({section:n.section,...t}),!0)},at:w,hint:ee.hint,searchLabel:ee.search,readOnly:N,words:te}),z??null]}),de?/* @__PURE__ */G(E,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>me(null),"aria-label":de.section.title,items:y([{label:ie.deleteShared,danger:!0,onClick:()=>{ue(de.section),me(null)}}])}):null,fe?/* @__PURE__ */G(D,{name:fe.title,pages:fe.used_on.length,onDelete:()=>(async e=>{try{await l(ne).remove(e.id)}catch{return void I.error(ie.deleteFailed)}ue(null),le?.removed?.(e),ce(t=>t.filter(t=>t.id!==e.id)),pe(e=>e+1)})(fe),onCancel:()=>ue(null)}):null]})}export{B as AddSidePanel,W as blockKey,V as presetKey,S as sectionKey,Q as sharedKey,M as templateKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-G2VZ4DET.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-JQQFB7EZ.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{useCanvasEvent as d}from"./chunk-TOKMFZPB.js";import{isTypingTarget as p,framePointToHost as f}from"./chunk-FR7EEKFF.js";import{zoneKey as m,ROOT_SLOT as y,ROOT_ID as h}from"./chunk-EUFDQ4KL.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as w,AddIcon as C,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as P,RedoIcon as A,PasteIcon as E,StylesIcon as j,LayersIcon as D,CopyIcon as K}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var L=s(),I=/* @__PURE__ */new WeakMap;function Y(e){if(e.claimsPage)return L;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=I.get(n);return t||(t=s(),I.set(n,t)),t}function F(){return Y(e())}function S(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:y,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function B(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function X(e,n,t){const o=e.canPasteAt;if(!o)return m(n.from)===t.zone?S(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function V(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=B(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:X(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function U(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=B(e,i,t),k=T(e,n),b=d.held,v=b&&!p?X(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...N(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:Z(x?Q(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?W(e).pinned:void 0})}function Q(e,n){const o=e.copyItem;if(!o||!n)return null;const l=W(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */M(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */M(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */M(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */M(w,{}),danger:!0,onClick:s("delete")}]}}function Z(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function N(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var W=e=>e.words?.screen??t.menu;function G(e){const n=W(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(P,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=S(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):m(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */M(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */M(D,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=W(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=V(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),d(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=f(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),d(t,"mousedown",i),d(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */M($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?J(e,n.el):G(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{L as EASEL_NODE_CLIPBOARD,T as ancestorChain,Y as nodeClipboardOf,B as nodeClipboardRules,U as nodeMenuItems,R as nodeShortcut,G as pageMenuItems,X as pastePlace,V as runNodeShortcut,J as textMenuItems,F as useNodeClipboard,H as useNodeContextMenu};
|