efficient-easel 24.2.0 → 25.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/dist/{CanvasDragLayer-NZpaX6aq.d.ts → CanvasDragLayer-DXeQGrwJ.d.ts} +42 -3
- package/dist/canvas/index.d.ts +2 -139
- package/dist/canvas/index.js +1 -1
- package/dist/chrome/index.js +1 -1
- package/dist/{chunk-6NJHYXJM.js → chunk-3XECMGXX.js} +1 -1
- package/dist/{chunk-FRAIEWRC.js → chunk-62UGN7VM.js} +1 -1
- package/dist/{chunk-HNKB2ZYR.js → chunk-6ATIYLUL.js} +1 -1
- package/dist/{chunk-Y53EKN35.js → chunk-6EDVZBUO.js} +1 -1
- package/dist/{chunk-JMAOCKB2.js → chunk-6WTWYHC2.js} +3 -3
- package/dist/chunk-7UFKEX72.js +1 -0
- package/dist/chunk-BBD3FLU3.js +16 -0
- package/dist/chunk-CEC5XLN4.js +1 -0
- package/dist/chunk-CWELHADJ.js +1 -0
- package/dist/chunk-DX3VILZ3.js +6 -0
- package/dist/chunk-ERB6FAZT.js +2 -0
- package/dist/{chunk-TGZCD6IP.js → chunk-EUFDQ4KL.js} +1 -1
- package/dist/chunk-FEP6XMNX.js +1 -0
- package/dist/chunk-FR7EEKFF.js +1 -0
- package/dist/chunk-GDO4QJ4G.js +1 -0
- package/dist/{chunk-GMCZXMOV.js → chunk-GR3XRILS.js} +1 -1
- package/dist/chunk-H6BER2EU.js +1 -0
- package/dist/{chunk-G67G63O5.js → chunk-ITIVCER6.js} +1 -1
- package/dist/chunk-IW5QXREH.js +64 -0
- package/dist/chunk-JIP5JNRB.js +1 -0
- package/dist/chunk-JQQFB7EZ.js +1 -0
- package/dist/{chunk-AGWKB77Q.js → chunk-K53PQAMP.js} +1 -1
- package/dist/{chunk-4ESG53BH.js → chunk-KF3LT7J2.js} +1 -1
- package/dist/{chunk-CLOS6SSX.js → chunk-KO47WAWR.js} +1 -1
- package/dist/chunk-KVIEUWTX.js +11 -0
- package/dist/{chunk-QORC32JO.js → chunk-LUHGBFOD.js} +3 -3
- package/dist/{chunk-DDH2DYQP.js → chunk-LUOY3A3Q.js} +1 -1
- package/dist/chunk-MIX7EGRG.js +2 -0
- package/dist/{chunk-2FYFAAAK.js → chunk-OXOUGEAT.js} +1 -1
- package/dist/chunk-PMRN5Z3T.js +1 -0
- package/dist/{chunk-55KKGABA.js → chunk-PVBDKBJB.js} +1 -1
- package/dist/{chunk-RPMSET77.js → chunk-QTHQPJWA.js} +1 -1
- package/dist/{chunk-ISS72IKO.js → chunk-QZJKWKGH.js} +1 -1
- package/dist/{chunk-IYHO4XQX.js → chunk-S6YOIRXQ.js} +1 -1
- package/dist/{chunk-5PXVT7JY.js → chunk-SBVIW3KJ.js} +1 -1
- package/dist/chunk-SC6E3UUS.js +13 -0
- package/dist/{chunk-LN43DP2A.js → chunk-SQTVXE5D.js} +13 -13
- package/dist/chunk-TOKMFZPB.js +1 -0
- package/dist/chunk-U3LTJSBU.js +20 -0
- package/dist/{chunk-75C6WFNF.js → chunk-UCZQWQNS.js} +1 -1
- package/dist/chunk-UDWXBS46.js +1 -0
- package/dist/{chunk-WYTPBF3Q.js → chunk-VBEVZZTV.js} +11 -11
- package/dist/{chunk-OITNWE52.js → chunk-XLC7HWW3.js} +1 -1
- package/dist/chunk-XTDOSL2M.js +8 -0
- package/dist/chunk-YYD257TD.js +1 -0
- package/dist/copy/index.js +13 -13
- package/dist/copy-place-CQIemdtU.d.ts +25 -0
- package/dist/data/index.d.ts +4 -1
- package/dist/data/index.js +1 -1
- package/dist/dom-BpxMcHFP.d.ts +200 -0
- package/dist/drag/index.d.ts +2 -3
- package/dist/drag/index.js +1 -1
- package/dist/draw/index.d.ts +1 -1
- package/dist/draw/index.js +1 -1
- package/dist/easel/index.d.ts +67 -1
- package/dist/easel/index.js +1 -1
- package/dist/edit-lock/index.d.ts +0 -46
- package/dist/edit-lock/index.js +1 -1
- package/dist/fields/fields.css +6 -40
- package/dist/fields/index.d.ts +1 -6
- package/dist/fields/index.js +1 -1
- package/dist/node-ops/index.js +1 -1
- package/dist/page-copy/index.d.ts +110 -0
- package/dist/page-copy/index.js +5 -0
- package/dist/panel/index.d.ts +29 -34
- package/dist/panel/index.js +1 -1
- package/dist/panel/panel.css +0 -78
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.d.ts +37 -57
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +19 -11
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/SaveControls.d.ts +10 -11
- package/dist/screen/components/SaveControls.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.d.ts +5 -6
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +8 -9
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/SidePanelHead.js +1 -1
- package/dist/screen/components/panel-widths.js +1 -1
- package/dist/screen/components/usePartBridge.d.ts +10 -11
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +9 -10
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/block-set-host.d.ts +55 -0
- package/dist/screen/lib/document/block-set-host.js +1 -0
- package/dist/screen/lib/document/block-types-in.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +160 -5
- package/dist/screen/lib/document/box-fields.js +1 -9
- package/dist/screen/lib/document/device-fields.js +1 -1
- package/dist/screen/lib/document/palette-sections.d.ts +33 -97
- package/dist/screen/lib/document/palette-sections.js +1 -1
- package/dist/screen/lib/document/preview-dom.js +1 -1
- package/dist/screen/lib/document/section-doc.js +1 -1
- package/dist/screen/lib/document/style-clipboard.d.ts +10 -11
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/document-switch.js +1 -1
- package/dist/screen/lib/failure.js +1 -1
- package/dist/screen/lib/host-inbound.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/media-picker.js +1 -1
- package/dist/screen/lib/page-lock.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +251 -12
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +6 -0
- package/dist/screen/words.d.ts +9 -0
- package/dist/screen/words.js +1 -1
- package/dist/strings/index.d.ts +4 -1
- package/dist/strings/index.js +2 -2
- package/dist/style-clipboard/index.d.ts +0 -32
- package/dist/style-clipboard/index.js +1 -1
- package/dist/text-styles/index.d.ts +7 -6
- package/dist/text-styles/index.js +37 -36
- package/dist/text-styles/text-styles.css +5 -53
- package/dist/tree/index.d.ts +2 -2
- package/dist/{types-DBy3L69b.d.ts → types-CoUTWUwB.d.ts} +1 -1
- package/dist/words-Dl8Qja4K.d.ts +32 -0
- package/package.json +15 -3
- package/dist/chunk-3FIS2FRS.js +0 -1
- package/dist/chunk-7RSE6KKY.js +0 -1
- package/dist/chunk-CMPFUJ26.js +0 -8
- package/dist/chunk-CZAAGBVL.js +0 -7
- package/dist/chunk-DSKNJXB4.js +0 -1
- package/dist/chunk-FJTCSQWK.js +0 -16
- package/dist/chunk-G7ISR6DI.js +0 -1
- package/dist/chunk-H4Z2V56N.js +0 -21
- package/dist/chunk-K7MMLCTT.js +0 -2
- package/dist/chunk-KRL3IUV3.js +0 -1
- package/dist/chunk-LF3FUSCQ.js +0 -1
- package/dist/chunk-THWO5YVZ.js +0 -1
- package/dist/chunk-TOHOGVAE.js +0 -15
- package/dist/chunk-UKPZ2YWE.js +0 -64
- package/dist/chunk-V7U33NF2.js +0 -1
- package/dist/chunk-VKPOH6MK.js +0 -1
- package/dist/chunk-YU3WHLGI.js +0 -1
- package/dist/repeat-D65bJS8d.d.ts +0 -49
- package/dist/session-EsjORLQ0.d.ts +0 -43
|
@@ -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`,
|
|
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.`,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:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}};export{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,4 +1,4 @@
|
|
|
1
|
-
import{PanelToggleIcon as e}from"./chunk-UMDQ6CLQ.js";import{InspectorHead as n}from"./chunk-
|
|
1
|
+
import{PanelToggleIcon as e}from"./chunk-UMDQ6CLQ.js";import{InspectorHead as n}from"./chunk-VBEVZZTV.js";import{DEFAULT_CHROME_WORDS as i}from"./chunk-AJSDWWJW.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{Tooltip as s,IconButton as t,Button as c}from"efficient-shell/ui";import{jsx as r,jsxs as l,Fragment as d}from"react/jsx-runtime";function a({icon:e,title:i,context:o,actions:s,side:t="left",onHide:c}){/* @__PURE__ */
|
|
2
2
|
return r(n,{icon:e,name:i,kind:o,actions:s||c?/* @__PURE__ */l(d,{children:[s,c?/* @__PURE__ */r(m,{side:t,onHide:c,divider:Boolean(s)}):null]}):void 0})}function m({side:n,onHide:c,divider:a=!1}){const m=o("chrome",i);/* @__PURE__ */
|
|
3
3
|
return l(d,{children:[a?/* @__PURE__ */r("span",{className:"sf-head-divider","aria-hidden":"true"}):null,
|
|
4
4
|
/* @__PURE__ */r(s,{content:m.hidePanel,side:"bottom",children:/* @__PURE__ */r(t,{className:"es-insp-iconbtn","aria-label":m.hidePanelLabel({side:n}),onClick:c,children:/* @__PURE__ */r(e,{side:n})})})]})}function h({side:n,onShow:c}){const l=o("chrome",i);/* @__PURE__ */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{DEFAULT_PANEL_WORDS as e}from"./chunk-KFV7N2DJ.js";import{SettingsField as l}from"./chunk-MIX7EGRG.js";import{SettingsSegmented as n}from"./chunk-DX3VILZ3.js";import{AccordionHeading as a,SettingReset as i,Tooltip as t,Button as s,toast as d}from"efficient-shell/ui";export{AlignmentGrid,BorderInput,CornersInput,SidesEachToggle,SidesInput,borderSides,borderStartEach,sidesStartEach}from"efficient-shell/ui";import{jsx as o,jsxs as c,Fragment as r}from"react/jsx-runtime";import{BackgroundIcon as u,WidthIcon as b}from"efficient-shell/icons/efficient";function h({title:e,level:l=3,id:n,className:i}){/* @__PURE__ */
|
|
2
|
+
return o(a,{title:e,level:l,id:n,className:i?`es-panel-band ${i}`:"es-panel-band"})}function m({title:e,level:l=4,id:n,className:i}){/* @__PURE__ */
|
|
3
|
+
return o(a,{tier:"row",title:e,level:l,id:n,className:i})}function f({label:l,changed:n,onReset:a,detail:t,disabled:s,defaultAction:d,words:c,className:r}){const u={...e,...c},b=u.resetName({label:l});/* @__PURE__ */
|
|
4
|
+
return o(i,{label:l,changed:n,onReset:a,detail:t,disabled:s,defaultAction:d,name:b,tip:t?u.resetTitle({label:l,detail:t}):b,className:r})}function p({name:e,preview:l,offPage:n,status:a,onOpen:i,id:s,className:d}){const u=null!=l;/* @__PURE__ */
|
|
5
|
+
return c("button",{type:"button",id:s,className:d?`es-drill ${d}`:"es-drill",onClick:i,children:[
|
|
6
|
+
/* @__PURE__ */c(t,{content:u?/* @__PURE__ */c(r,{children:[e,
|
|
7
|
+
/* @__PURE__ */o("br",{}),l]}):e,describe:!1,className:"es-drill-text",children:[
|
|
8
|
+
/* @__PURE__ */o("span",{className:"es-drill-name",children:e}),u?/* @__PURE__ */o("span",{className:n?"es-drill-preview is-offpage":"es-drill-preview",children:l}):null]}),a?/* @__PURE__ */o("span",{className:"es-drill-status",children:a}):null,
|
|
9
|
+
/* @__PURE__ */o("span",{className:"es-drill-chev","aria-hidden":"true"})]})}function N({label:e,onPress:l,disabled:n,note:a,doneLabel:i,icon:t,id:r,className:u}){const b=null!=a,h=b&&r?`${r}-note`:void 0;/* @__PURE__ */
|
|
10
|
+
return c("div",{className:u?`es-action-wrap ${u}`:"es-action-wrap",children:[
|
|
11
|
+
/* @__PURE__ */o(s,{variant:"secondary",size:"lg",block:!0,id:r,disabled:n,"aria-describedby":h,onClick:()=>{const e=l();e&&"function"==typeof e.then?e.then(()=>{d.success(i)}):d.success(i)},leftIcon:t?/* @__PURE__ */o("span",{className:"es-action-icon","aria-hidden":"true",children:t}):void 0,children:/* @__PURE__ */o("span",{className:"es-action-label",children:e})}),b?/* @__PURE__ */o("p",{id:h,className:"es-action-note",children:a}):null]})}var v=["full","content"],g={label:"Background",full:"Full width",content:"Content width"};function w({value:e,changed:a,detail:i,onChange:t,onReset:s,disabled:d=!1,hint:c,labelId:r,words:b,resetWords:h}){const m={...g,...b};/* @__PURE__ */
|
|
12
|
+
return o(l,{label:m.label,labelId:r,icon:/* @__PURE__ */o(u,{}),changed:a,hint:c,action:/* @__PURE__ */o(f,{words:h,label:m.label,changed:a,detail:i,onReset:s}),children:/* @__PURE__ */o(n,{options:v.map(e=>({id:e,label:"full"===e?m.full:m.content})),value:e,onChange:t,ariaLabel:m.label,disabled:d})})}var C={label:"Content",full:"Full width",content:"Content width"};function I({mode:e,onMode:a,number:i,changed:t,detail:s,onReset:d,fullClosed:r=!1,disabled:u=!1,hint:h,labelId:m,words:p,resetWords:N}){const g={...C,...p},w=void 0!==e&&a?/* @__PURE__ */o(n,{options:v.map(e=>({id:e,label:"full"===e?g.full:g.content,disabled:"full"===e&&r})),value:e,onChange:a,ariaLabel:g.label,disabled:u}):null;/* @__PURE__ */
|
|
13
|
+
return o(l,{label:g.label,labelId:m,icon:/* @__PURE__ */o(b,{}),changed:t,hint:h,action:/* @__PURE__ */o(f,{words:N,label:g.label,changed:t,detail:s,onReset:d}),children:w&&i?/* @__PURE__ */c("div",{className:"es-width-stack",children:[w,i]}):w??i??null})}export{v as BACKGROUND_WIDTHS,g as DEFAULT_BACKGROUND_WIDTH_WORDS,C as DEFAULT_CONTENT_WIDTH_WORDS,N as SettingsAction,w as SettingsBackgroundWidth,I as SettingsContentWidth,f as SettingsDefaultReset,p as SettingsDrill,h as SettingsGroupHead,m as SettingsGroupSub};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-
|
|
2
|
-
return
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-3XECMGXX.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{useCanvasLayout as o,useCanvasTyping as i,useCanvasEvent as c,CANVAS_TYPABLE_EVENT as d}from"./chunk-TOKMFZPB.js";import{framePointToHost as u,elementScale as h,related as f,WORDS_CLEAR as p,frameRectToLayer as m,clientPointToLayer as g}from"./chunk-FR7EEKFF.js";import{isRepeatCopy as b}from"./chunk-7UFKEX72.js";import{parseZoneKey as y,ROOT_ID as x}from"./chunk-EUFDQ4KL.js";import{useRef as v,useEffect as w,useState as k,useCallback as N,useMemo as D,useSyncExternalStore as A,useId as T,useLayoutEffect as M}from"react";import{Tooltip as z,IconButton as E,solidSurfaceStyle as C,Input as $,ItemCount as S}from"efficient-shell/ui";import{AddIcon as j,CloseIcon as L,SearchIcon as B}from"efficient-shell/icons/efficient";import{jsxs as K,jsx as O}from"react/jsx-runtime";function X({label:e,onInsert:t,style:n,axis:l="y",className:r,index:a}){const s=["es-canvas-insert","x"===l?"is-x":"",r??""].filter(Boolean).join(" ");/* @__PURE__ */
|
|
2
|
+
return K("div",{className:s,style:n,"data-index":a,children:[
|
|
3
3
|
/* @__PURE__ */O("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */O("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */O(
|
|
5
|
-
/* @__PURE__ */O(
|
|
6
|
-
/* @__PURE__ */O("div",{className:"es-canvas-handle-spot",style
|
|
7
|
-
/* @__PURE__ */O("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),
|
|
8
|
-
return
|
|
4
|
+
/* @__PURE__ */O("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */O(z,{content:e,children:/* @__PURE__ */O(E,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */O(j,{})})})})]})}var F=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,I=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>F(e.box,t,n)).sort((e,t)=>I(t.s.box)-I(e.s.box)||e.at-t.at).map(({s:e})=>e)}function Y(e,t,n){return q(e,t,n).at(-1)??null}function P(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function Z(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function R(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>F(e.box,t,n)).sort((e,t)=>I(e.box)-I(t.box));for(const e of s){const s=P(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:Z(e,s)};if(!a(o))return null}return null}function H(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function Q(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var U={nodes:[],zones:[]},V="data-easel-dropzone",G="data-easel-block";function W(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function J(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return m(e.frame,W(n),t)}function ee(e,t){const{frame:n,document:l}=e,r=e=>m(n,W(e),t),a=[],s=[];for(const e of l.querySelectorAll(`[${V}]`)){if(b(e))continue;const t=e.getAttribute(V)??"";let n;try{n=y(t)}catch{continue}const l=[...e.querySelectorAll(`[${G}]`)].filter(t=>t.parentElement?.closest(`[${V}]`)===e&&!b(t)),o=l.map(r);s.push({key:t,list:n,box:r(e),axis:J(o,e),children:o}),l.forEach((e,t)=>{const l=e.getAttribute(G);l&&a.push({id:l,place:{...n,index:t},box:o[t]})})}return{nodes:a,zones:s}}var te="data-es-empty-cell",ne="data-easel-dropzone",le=140;var re=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),ae=e=>({left:e.left+2,top:Math.max(e.top-11,0)});function se(s){const{canvas:m,session:b,readOnly:y,words:T=e.canvas}=s,E=v(s);w(()=>{E.current=s});const $=v(null),S=o(m),[j,L]=k(0),B=N(()=>L(e=>e+1),[]),[F,I]=k(U);w(()=>{const e=$.current;m&&e&&I((E.current.measure??ee)(m,e))},[m,S,s.revision,j]);const Y=s.model,P=D(()=>Y(F),[Y,F]),Z=A(b.subscribe,b.shown,b.shown),H=s.choose,Q=(e,t)=>{const n=q(P.sources,e,t);return 0===n.length?null:H?H(n):n[n.length-1]},[V,G]=k(null),[W,J]=k(null),[le,se]=k(null),oe=v(null),ie=()=>{oe.current&&clearTimeout(oe.current),oe.current=null},ce=()=>{ie(),oe.current=setTimeout(()=>{b.get()||G(null)},140)};w(()=>ie,[]);const de=v(null),ue=i(m),he=v(!1);he.current=ue;const[fe,pe]=k(null),me=v(null),ge=v(V);ge.current=V,w(()=>{ue?(pe(ge.current?.key??me.current?.id??null),ie(),G(null)):pe(null)},[ue]);const[be,ye]=k(null);c(m,d,e=>{const t=e.detail?.id??null,n=t?{id:t,words:e.detail?.words??null}:null;ye(n),n&&(me.current=n)});const xe=e=>{if(!(e&&e.isConnected&&m&&$.current))return null;const t=_(m,$.current,e);return{left:t.left-p,top:t.top-p,width:t.width+2*p,height:t.height+2*p}},ve=!be||ue||y||Z?null:xe(be.words)??F.nodes.find(e=>e.id===be.id)?.box??null;c(m,"mousemove",e=>{const t=$.current;if(!m||!t)return;const n=u(m.frame,e.clientX,e.clientY,t),l=h(t),r={x:n.x/l,y:n.y/l};if(de.current=r,E.current.readOnly||b.get()||he.current)return;ie();const a=Q(r.x,r.y);G(e=>e?.key===a?.key&&e?.box===a?.box?e:a)}),c(m,"mouseout",e=>{e.relatedTarget||(de.current=null,ce())}),c(m,"mouseover",e=>{e.relatedTarget||B()});const we=v(null),ke=N(()=>{we.current?.(),we.current=null,J(null),se(null)},[]);w(()=>b.subscribe(()=>{b.get()?B():ke()}),[b,ke,B]),w(()=>ke,[ke]),("undefined"==typeof document?w:M)(()=>{if(b.get())return;const e=de.current;G(t=>y||he.current?null:e?Q(e.x,e.y):t?P.sources.find(e=>e.key===t.key)??null:null)},[P,Z,b,y,H]);const Ne=e=>{const t=b.get(),n=$.current,l=E.current.dropOn;if(!t||!n||!l)return null;const r=g(n,e.clientX,e.clientY);de.current=r;const a=q(P.sources,r.x,r.y);for(let e=a.length-1;e>=0;e-=1)if(l.accepts(t.item,a[e]))return{h:t,source:a[e]};return null},De=e=>{const t=b.get(),n=$.current;if(!t||!n)return null;const l=g(n,e.clientX,e.clientY);de.current=l;const r=R(P.zones,l.x,l.y,e=>E.current.canDrop(t.item,e),e=>!!t.from&&a(t.from,e),e=>E.current.fallThrough?.(t.item,e,t.from)??!0);return r?{h:t,t:r}:null},Ae={onDragEnter:e=>{if(we.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),a=m?l(m.document):null,s=[];t&&s.push(r(t)),a&&m&&s.push(r(a,m.frame)),we.current=s.length?()=>s.forEach(e=>e()):null},onDragOver:e=>{const n=Ne(e);if(n)return e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed),J(null),void se(e=>e&&e.key===n.source.key&&e.box===n.source.box?e:n.source);se(null);const l=De(e);if(!l)return void J(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const r={zoneKey:l.t.zone.key,line:l.t.line,axis:l.t.zone.axis};J(e=>e&&e.zoneKey===r.zoneKey&&e.line.left===r.line.left&&e.line.top===r.line.top?e:r)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(de.current=null,J(null),se(null))},onDrop:e=>{const t=Ne(e);if(t)return e.preventDefault(),b.end(),ke(),void E.current.dropOn.onDrop(t.h.item,t.source);const n=De(e);n&&(e.preventDefault(),b.end(),ke(),E.current.onDrop(n.h.item,n.t.to))}},Te={draggable:!y&&!!V,onMouseEnter:ie,onMouseLeave:()=>!b.get()&&ce(),onDragStart:e=>{if(V&&!y){b.start({key:V.key,item:V.item,from:V.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",V.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{b.end(),ke()},onClick:()=>{V&&!y&&E.current.onPick?.(V.item)}},{seams:Me=[]}=P,ze=be?.words??(ue?me.current?.words??null:null),Ee=s.tag&&m&&$.current&&!Z?(ze&&f(s.tag.element,ze)?xe(ze):null)??_(m,$.current,s.tag.element):null,Ce=V?(be&&be.id===V.key?xe(be.words):null)??V.box:null,$e=ue&&fe&&!s.tag?P.sources.find(e=>e.key===fe)??null:null,Se=$e?xe(ze)??$e.box:null,je=P.zones.filter(e=>0===e.children.length),Le=!s.onZoneAdd||y||ue?[]:je,Be=Le.map(e=>e.key).join("\n");return w(()=>{const e=m?.document;if(!e)return;const t=new Set(Be?Be.split("\n"):[]);for(const n of e.querySelectorAll(`[${ne}]`))n.toggleAttribute(te,t.has(n.getAttribute(ne)??""));return()=>{for(const t of e.querySelectorAll(`[${te}]`))t.removeAttribute(te)}},[m,Be,F,S,j]),/* @__PURE__ */K("div",{ref:$,className:"es-canvas-layer",children:[Z||!s.onSeamAdd||y||ue?null:Me.map(e=>
|
|
5
|
+
/* @__PURE__ */O(X,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??T.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */O("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===x?void 0:e.list.parentId,onClick:()=>s.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */O("span",{className:"es-canvas-empty-add",children:T.addButton({label:e.addLabel??s.zoneAddLabel??T.addBlock})})},e.key)):null,Z?/* @__PURE__ */O("div",{className:"es-canvas-catch",...Ae}):null,le&&Z?/* @__PURE__ */O("div",{className:"es-canvas-target",style:re(le.box),children:s.dropOn?.label?/* @__PURE__ */O("span",{className:"es-canvas-target-label",style:C(),children:s.dropOn.label(Z.item,le)}):null}):null,W&&!je.some(e=>e.key===W.zoneKey)?/* @__PURE__ */O("div",{className:`es-canvas-line is-${W.axis}`,style:re(W.line)}):null,ve?/* @__PURE__ */O("span",{className:"es-canvas-hint"+(ve.width<200?" is-below":""),style:{...C(),left:ve.left+ve.width,top:ve.width<200?ve.top+ve.height:ve.top},children:T.typeHint}):null,Ee&&s.tag?/* @__PURE__ */O("span",{className:"es-canvas-tag",style:ae(Ee),children:s.tag.label}):$e&&Se?/* @__PURE__ */O("span",{className:"es-canvas-tag",style:ae(Se),children:$e.label}):null,
|
|
6
|
+
/* @__PURE__ */O("div",{className:"es-canvas-handle-spot",style:Ce?{"--es-handle-x":`${ae(Ce).left}px`,"--es-handle-y":`${ae(Ce).top}px`}:void 0,children:/* @__PURE__ */O(z,{className:"es-canvas-handle-tip",side:"top",content:!V||y||Z?null:V.title??T.handle({label:V.label}),children:/* @__PURE__ */K("div",{className:["es-canvas-handle",V&&!y?"is-shown":"",Z?"is-dragging":""].filter(Boolean).join(" "),...Te,children:[
|
|
7
|
+
/* @__PURE__ */O("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var oe=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function ie({groups:t,session:n,itemFor:l,onInsert:r,onTileMenu:a,at:o,hint:i,searchLabel:c,readOnly:d,words:u=e.add}){const h=i??u.hint,f=c??u.search,[p,m]=k(""),g=T(),b=p.trim().toLowerCase(),y=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),x=t.map((e,t)=>({...e,key:y[t],tiles:b?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,b)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>r=>{if(t)r.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),r.dataTransfer.effectAllowed="copy";try{r.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
8
|
+
return K("div",{className:"es-add",children:[o?/* @__PURE__ */K("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */O("span",{children:o.label}),s(u.stop,/* @__PURE__ */O("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:o.onClear,children:/* @__PURE__ */O(L,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
10
10
|
/* @__PURE__ */O("p",{className:"es-add-hint",children:h}),
|
|
11
|
-
/* @__PURE__ */O("div",{className:"es-add-find",children:/* @__PURE__ */O(
|
|
11
|
+
/* @__PURE__ */O("div",{className:"es-add-find",children:/* @__PURE__ */O($,{id:g,type:"search","aria-label":f,placeholder:u.searchPlaceholder({label:f}),value:p,onChange:e=>m(e.target.value),leftIcon:/* @__PURE__ */O(B,{size:16,"aria-hidden":"true"}),endAction:p?{label:u.clearSearch,icon:/* @__PURE__ */O(L,{"aria-hidden":"true"}),onClick:()=>m("")}:void 0})}),0===x.length?/* @__PURE__ */K("div",{className:"es-add-empty",role:"status",children:[
|
|
12
12
|
/* @__PURE__ */O("div",{className:"es-add-empty-title",children:u.nothing({query:p.trim()})}),
|
|
13
|
-
/* @__PURE__ */O("div",{className:"es-add-empty-sub",children:u.tryAnother})]}):x.map(e=>/* @__PURE__ */
|
|
14
|
-
/* @__PURE__ */
|
|
13
|
+
/* @__PURE__ */O("div",{className:"es-add-empty-sub",children:u.tryAnother})]}):x.map(e=>/* @__PURE__ */K("section",{className:"es-add-group","aria-label":e.title,children:[
|
|
14
|
+
/* @__PURE__ */K("div",{className:"es-add-group-head",children:[
|
|
15
15
|
/* @__PURE__ */O("span",{className:"es-add-group-title",children:e.title}),
|
|
16
|
-
/* @__PURE__ */O(
|
|
17
|
-
/* @__PURE__ */O("div",{className:oe(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(d||e.disabled),l=d?void 0:e.disabled?e.disabledReason:e.title??u.tile({label:e.label});return s(l,/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */
|
|
16
|
+
/* @__PURE__ */O(S,{count:e.tiles.length,label:u.count({count:e.tiles.length,sections:oe(e)}),className:"ml-auto"})]}),
|
|
17
|
+
/* @__PURE__ */O("div",{className:oe(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(d||e.disabled),l=d?void 0:e.disabled?e.disabledReason:e.title??u.tile({label:e.label});return s(l,/* @__PURE__ */K("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":u.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&r?.(e.type),onContextMenu:a?t=>{a(e.type,{x:t.clientX,y:t.clientY,owner:t.currentTarget})&&t.preventDefault()}:void 0,children:[null!=e.cover?/* @__PURE__ */O("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */O("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
|
|
18
|
+
/* @__PURE__ */K("span",{className:"es-add-tile-label",children:[e.label,null!=e.mark?/* @__PURE__ */O("span",{className:"es-add-tile-mark","aria-hidden":"true",children:e.mark}):null]})]},e.type))})})]},e.key))]})}export{ie as AddPanel,se as CanvasDragLayer,X as CanvasInsert,U as EMPTY_MEASURE,le as HANDLE_GRACE_MS,R as canvasTarget,F as contains,P as gapInZone,Z as gapLine,H as insertSeams,ee as measureCanvas,Y as pickSource,Q as seamsBetween,q as sourcesAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{removeCanvasStyle as e,upsertCanvasStyle as n}from"./chunk-FR7EEKFF.js";import{useState as t,useEffect as o,useRef as r}from"react";var c="[data-easel-block]",s="[data-easel-dropzone]",u="iframe#preview-frame";function i(e){const n=e.contentDocument;if(!n||!e.contentWindow||"loading"===n.readyState||!n.body)return!1;if(e.hasAttribute("srcdoc"))return"about:srcdoc"===n.URL;const t=e.getAttribute("src");return!t||"about:blank"===t||"about:blank"!==n.URL}function l(e,n,{selector:t=u,readySelector:o}={}){let r=null,c=null,s=!1,l=!1,a=null;const d=()=>{a?.observer.disconnect(),a=null},m=()=>{if(l)return;let e=null;if(r&&i(r)){const n=r.contentDocument;(e=>{if(!o||e.querySelector(o))return d(),!0;if(a?.doc!==e){d();const n=e.defaultView?.MutationObserver;if(n){const t=new n(()=>m());t.observe(e,{childList:!0,subtree:!0}),a={doc:e,observer:t}}}return!1})(n)&&(e={frame:r,document:n,window:r.contentWindow})}else d();(e===c||!!e&&!!c&&e.frame===c.frame&&e.document===c.document)&&s||(s=!0,c=e,n(c))},f=()=>m(),v=()=>{const n=e.querySelector?.(t);n!==r?(r?.removeEventListener("load",f),r=n,r?.addEventListener("load",f),m()):m()},b=e.ownerDocument?.defaultView??e.defaultView,w=b?.MutationObserver,E=w?new w(e=>(e=>null!==r&&!r.isConnected||e.some(e=>[...e.addedNodes,...e.removedNodes].some(e=>"IFRAME"===e.nodeName||!!e.querySelector?.("iframe"))))(e)&&v()):null;return E?.observe(e,{childList:!0,subtree:!0}),v(),()=>{l=!0,E?.disconnect(),d(),r?.removeEventListener("load",f),r=null}}function a(e,{selector:n,readySelector:r}={}){const[c,s]=t(null);return o(()=>{const t=e.current;if(!t)return;const o=l(t,s,{selector:n,readySelector:r});return()=>{o(),s(null)}},[e,n,r]),c}var d="easel:canvas-typing",m="easel:canvas-typable";function f(e,n,t,{on:c="document",capture:s=!1}={}){const u=r(t);u.current=t;const i=e?.document??null,l=e?.window??null;o(()=>{const e="window"===c?l:i;if(!e)return;const t=e=>u.current(e);return e.addEventListener(n,t,s),()=>e.removeEventListener(n,t,s)},[i,l,n,c,s])}function v(e){const[n,o]=t(!1);return f(e,d,e=>o(Boolean(e.detail?.typing))),n}function b(t,r,c){const s=t?.document??null;o(()=>{if(!s)return;if(!c)return void e(s,r);const t=n(s,r,c),o=s.defaultView?.MutationObserver,u=o?new o(()=>{t.isConnected||n(s,r,c)}):null;return u?.observe(s.head??s.documentElement,{childList:!0}),()=>{u?.disconnect(),e(s,r)}},[s,r,c])}function w(e,{settle:n=[150,450]}={}){const[r,c]=t(0),s=e?.frame??null,u=e?.document??null,i=e?.window??null,l=n.join(",");return o(()=>{if(!s||!u||!i)return;const e=s.ownerDocument.defaultView;let t=!1,o=0;const r=()=>{if(t)return;t=!0;const n=()=>{t=!1,c(e=>e+1)};e?.requestAnimationFrame?o=e.requestAnimationFrame(n):n()},l=[],a=(e,n)=>{e.addEventListener(n,r,!0),l.push(()=>e.removeEventListener(n,r,!0))};a(u,"scroll"),a(i,"resize"),e&&(a(e,"scroll"),a(e,"resize"));const d=e?.ResizeObserver;if(d){const e=new d(r);e.observe(s),u.documentElement&&e.observe(u.documentElement),l.push(()=>e.disconnect())}const m=u.defaultView?.MutationObserver,f=u.body??u.documentElement;if(m&&f){const e=new m(r);e.observe(u===s.ownerDocument?s:f,{childList:!0,subtree:!0}),l.push(()=>e.disconnect())}const v=u.fonts;v&&a(v,"loadingdone");const b=n.map(e=>setTimeout(r,e));return r(),()=>{for(const e of l)e();for(const e of b)clearTimeout(e);o&&e?.cancelAnimationFrame&&e.cancelAnimationFrame(o)}},[s,u,i,l]),r}export{c as BLOCK_SELECTOR,u as CANVAS_SELECTOR,m as CANVAS_TYPABLE_EVENT,d as CANVAS_TYPING_EVENT,s as LIST_SELECTOR,i as isFrameReady,f as useCanvasEvent,a as useCanvasFrame,w as useCanvasLayout,b as useCanvasStyle,v as useCanvasTyping,l as watchCanvasFrame};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{noControlMetaOf as t,deviceMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{SETTINGS_BUCKETS as o,SettingsGroup as a}from"./chunk-FM6JO4WF.js";import{DEFAULT_TREE_WORDS as i}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-KFV7N2DJ.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{SettingsField as m}from"./chunk-MIX7EGRG.js";import{SettingsSegmented as h}from"./chunk-DX3VILZ3.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 k,Input as x,ItemCount as w,SortableList as C,ListRow as O,IconButton as N,ContextMenu as j,tabPanelId as $,Tabs as I,tabButtonId as D}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as S,useState as F,useLayoutEffect as P,useId as L}from"react";import{jsx as E,jsxs as M,Fragment as T}from"react/jsx-runtime";import{LockIcon as W,CloseIcon as z,MoveUpIcon as R,MoveDownIcon as A,DuplicateIcon as K,TrashIcon as V}from"efficient-shell/icons/efficient";function X({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(k,{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(x,{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 H(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function Y(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 B(e,n){return e.filter((e,t)=>t!==n)}var G='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',Z={parentId:"list",slot:"items"};function J({label:e,icon:n,noun:t,items:l,onChange:o,newItem:a,summary:s,itemName:d,thumb:u,min:m=0,max:h,readOnly:k=!1,open:x,onOpen:$,renderItem:I,renderRow:D,canRemove:L,lockedReason:X,fixed:J=!1,removeOnRow:Q=!0,canDuplicate:U,above:q,head:_=!0}){const ee=f("fields",p).list,ne=f("tree",i),te=t??ee.item,le=!k&&!J&&("number"!=typeof h||l.length<h),re=l.length<=m,oe=e=>!!L&&!L(l[e],e),ae=e=>!k&&!J&&Q&&!re&&!oe(e),ie=e=>le&&(!U||U(l[e],e)),se=(e,n)=>d?d(e,n):ee.itemName({noun:te,n:n+1}),ce=S([]),de=S(null),[ue,me]=F(null),he=S(null),[pe,fe]=F(null),[be,ge]=F("");P(()=>{const e=de.current;if(!e)return;de.current=null;const n=ce.current[e.index]?.querySelectorAll(G)[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(G)].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(Y(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}(x,e,n);a!==x&&$(a),ge(ee.moved({n:n+1,total:l.length}))},ye=e=>{le&&(o(H(l,e,a())),D?(de.current={index:e,nth:0,start:null,end:null},null!==x&&x>=e&&$(x+1)):$(e))},ke=e=>{ae(e)&&(o(B(l,e)),x===e?$(null):null!==x&&x>e&&$(x-1))},xe=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:k}),we=e=>{const n=[];return e>0&&n.push({label:ee.moveUp,icon:/* @__PURE__ */E(R,{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(K,{size:14}),onClick:()=>(e=>{ie(e)&&(o(H(l,e+1,y(l[e]))),null!==x&&x>e&&$(x+1))})(e)}),ae(e)&&n.push({label:ee.delete,icon:/* @__PURE__ */E(V,{size:14}),danger:!0,onClick:()=>ke(e)}),n},Ce=(e,n,t,l)=>{k||0===we(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
|
+
return M("div",{className:"es-list",children:[_?/* @__PURE__ */M("div",{className:"es-list-head",children:[
|
|
3
|
+
/* @__PURE__ */M("span",{className:"es-list-label",children:[n?/* @__PURE__ */E("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
|
|
4
|
+
/* @__PURE__ */E(w,{count:l.length,label:ee.count({noun:te,n:l.length}),showZero:!0})]}):null,q?/* @__PURE__ */E("div",{className:"es-list-above",children:q}):null,l.length?/* @__PURE__ */M(C,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:xe.rootProps(),children:[l.map((e,n)=>{const t=xe.row({item:n,place:{...Z,index:n}}),l=t.draggable&&ue!==n,o=!D&&x===n,a=!k&&!J&&Q&&oe(n),i=["es-list-row",D?"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,{...xe.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:!!D,active:o,title:D?void 0:/* @__PURE__ */M(T,{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:!D&&u?u(e,n):void 0,expanded:D?void 0:o,onToggle:D?void 0:()=>$(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=>{k||(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:k||J||!Q?void 0:a?v(X?X(e,n):ee.locked,/* @__PURE__ */E("span",{className:"es-list-lock",role:"img","aria-label":X?X(e,n):ee.locked,children:/* @__PURE__ */E(W,{size:13})})):v(ee.deleteItem({noun:te}),/* @__PURE__ */E(N,{size:"sm",className:"es-list-x","aria-label":ee.deleteItem({noun:te}),disabled:!ae(n),onClick:()=>ke(n),children:/* @__PURE__ */E(z,{size:14,"aria-hidden":"true"})})),below:o?/* @__PURE__ */E("div",{className:"es-list-item",children:I(e,n,Oe(n))}):void 0,children:D?/* @__PURE__ */E("div",{className:"es-list-row-main",children:D(e,n,Oe(n))}):null},n)]}),
|
|
7
|
+
/* @__PURE__ */E(r,{...xe.seam({place:{...Z,index:l.length}})})]}):null,k||J?null:/* @__PURE__ */E("button",{type:"button",className:"es-list-add",disabled:!le,onClick:()=>ye(l.length),children:ee.add({noun:te})}),
|
|
8
|
+
/* @__PURE__ */E("span",{className:"es-list-said","aria-live":"polite",children:be}),pe&&pe.index<l.length?
|
|
9
|
+
/* @__PURE__ */E(j,{at:{x:pe.x,y:pe.y},owner:pe.owner,onClose:()=>fe(null),items:c(we(pe.index))}):null]})}var Q=e=>e<6?e+1:6,U=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function q({field:e,name:t,id:l,value:r,onChange:o,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=F(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
|
|
10
|
+
return E(a,{id:`${l}-group`,title:U(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:Q(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]=F(null),f=u?d??null:h,b=u??p,g=Array.isArray(r)?r:[],v=e.getItemSummary;/* @__PURE__ */
|
|
11
|
+
return E(J,{label:U(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
|
+
return E(m,{label:U(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(X,{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
|
+
return E(m,{label:U(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
|
+
return E(m,{label:U(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(m,{label:U(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */E(h,{ariaLabel:U(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
|
+
return E(q,{...e,field:n});case"array":/* @__PURE__ */
|
|
17
|
+
return E(_,{...e,field:n});case"slot":return null}}function ne(e,n){if("mobile"!==n)return!0;const r=e;if(!r||r.marker||"slot"===r.type||"always"===t(e))return!0;const o=l(e)?.tier;return"mobile"===o||"each"===o}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&&!ne(s,t.context?.device)||(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(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 ie({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:o,tab:i,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:h,ariaLabel:p,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const w=f("panel",s),C=L(),O=h??`es-insp${C.replace(/:/g,"")}`,N=re(e,{values:n,context:o}),[j,S]=F(void 0),P=i??j,T=P&&N.buckets.includes(P)?P:N.buckets[0],[W,z]=F(null),R=W&&W.panel===O&&N.rows.some(e=>e.name===W.name)?W:null,A=d&&N.buckets.length>1,K=A&&T?$(O,T):`${O}-rows`,[V,X]=F(()=>/* @__PURE__ */new Set),H=y??V,Y=(e,n)=>{/* @__PURE__ */return E(a,{title:e.title,open:!H.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&X(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${O}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},B=e=>A&&e!==T,G=({name:e,field:a,bucket:i,fold:s})=>/* @__PURE__ */E("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!B(i)||void 0,children:/* @__PURE__ */E(ee,{field:a,name:e,id:`${O}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:o,renderers:m,openItem:R&&R.name===e?R.index:null,onOpenItem:n=>z(null===n?null:{panel:O,name:e,index:n}),headingLevel:s?Q(x):x})},e);/* @__PURE__ */
|
|
18
|
+
return M("div",{className:"es-insp",children:[A?/* @__PURE__ */E("div",{className:"es-insp-tabs",children:/* @__PURE__ */E(I,{variant:"underline",block:!0,"aria-label":p??w.settings,idPrefix:O,value:T,onChange:e=>{const n=e;void 0===i&&S(n),c?.(n)},items:N.buckets.map(e=>{const n=w.buckets[e],t=u?.[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__ */M("div",{className:"es-insp-rows",id:K,role:A?"tabpanel":void 0,"aria-labelledby":A&&T?D(O,T):void 0,children:[b&&ne(te,o?.device)?v?/* @__PURE__ */E("div",{className:"es-insp-band","data-fold":v.key,children:Y(v,b)}):b:null,ae(N.rows).map((e,n)=>{if(!e.fold)return e.rows.map(G);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:!(!B(t)&&!l)||void 0,children:Y(e.fold,e.rows.map(G))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{X as FieldText,ie as Inspector,ee as InspectorField,J as ListField,oe as bucketsOf,ne as fieldShownInView,H as insertAt,U as labelOf,Y as moveTo,re as planFields,B as removeAt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-BBD3FLU3.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-XLC7HWW3.js";import{SELECTION_MODE as e}from"./chunk-LUHGBFOD.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-BBD3FLU3.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};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{EaselRail as e}from"./chunk-MJM6SFD3.js";import{DEFAULT_NOTICE_WORDS as n,DEFAULT_CHROME_WORDS as i}from"./chunk-AJSDWWJW.js";import{DEFAULT_RAIL_WORDS as a}from"./chunk-2OAZYSWJ.js";import{holderOf as t,describeAge as s,nameOrSomeone as l}from"./chunk-
|
|
2
|
-
return c("div",{className:"es-topbar",children:e})}function
|
|
3
|
-
return c("div",{className:e?`es-cluster es-cluster--${e}`:"es-cluster",style:n,children:i})}function
|
|
1
|
+
import{EaselRail as e}from"./chunk-MJM6SFD3.js";import{DEFAULT_NOTICE_WORDS as n,DEFAULT_CHROME_WORDS as i}from"./chunk-AJSDWWJW.js";import{DEFAULT_RAIL_WORDS as a}from"./chunk-2OAZYSWJ.js";import{holderOf as t,describeAge as s,nameOrSomeone as l}from"./chunk-YYD257TD.js";import{DEFAULT_LOCK_WORDS as r}from"./chunk-RE4LP46F.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{jsx as c,jsxs as d}from"react/jsx-runtime";import{Tooltip as h,IconButton as u,Segmented as m,Switch as p,SpinnerRing as v,ResizeHandle as f,Button as k,Text as b,Banner as g}from"efficient-shell/ui";import{useState as y,useEffect as N}from"react";import{LockIcon as w,CloudPauseIcon as O,CloudSlashIcon as x,CloudAlertIcon as z,CloudArrowUpIcon as B,CloudCheckIcon as C}from"efficient-shell/icons/efficient";function R({children:e}){/* @__PURE__ */
|
|
2
|
+
return c("div",{className:"es-topbar",children:e})}function S({kind:e,style:n,children:i}){/* @__PURE__ */
|
|
3
|
+
return c("div",{className:e?`es-cluster es-cluster--${e}`:"es-cluster",style:n,children:i})}function W(){/* @__PURE__ */
|
|
4
4
|
return c("div",{className:"es-divider-v","aria-hidden":"true"})}function $({items:n,ariaLabel:i,onWords:t}){const s=o("rail",a);/* @__PURE__ */
|
|
5
5
|
return c("div",{className:"es-cluster es-cluster--rail es-rail-fit",children:/* @__PURE__ */c(e,{items:n,ariaLabel:i??s.label,orientation:"row",onLabelsShown:t})})}function j({label:e,tip:n,onClick:i,disabled:a,state:t,buttonRef:s,children:l}){/* @__PURE__ */
|
|
6
6
|
return c(h,{content:n??e,side:"bottom",children:/* @__PURE__ */c(u,{ref:s,"aria-label":e,"aria-pressed":t?"active"===t:void 0,className:"es-iconbtn",disabled:a,onClick:i,children:l})})}function L({devices:e,value:n,onChange:a,ariaLabel:t}){const s=o("chrome",i);/* @__PURE__ */
|
|
7
|
-
return c(m,{className:"es-devseg",size:"sm",label:t??s.device,value:n,onChange:e=>{e!==n&&a(e)},options:e.map(e=>({value:e.id,icon:/* @__PURE__ */c(h,{content:e.label,side:"bottom",children:/* @__PURE__ */c("span",{className:"es-devseg-glyph","aria-hidden":"true",children:e.icon})}),label:/* @__PURE__ */c("span",{className:"es-vh",children:e.label})}))})}var M={idle:"is-quiet",saved:"is-quiet is-saved",saving:"is-saving",error:"is-error",off:"is-off","off-unsaved":"is-off is-unsaved"};function
|
|
8
|
-
return d("span",{className:`es-savestate ${M[e]}`,role:s,"aria-live":"polite",children:[/* @__PURE__ */c("span",i?{ref:t,className:"es-savestate-ring is-counting",style:void 0!==a?{"--es-savewait":`${a}ms`}:void 0,"aria-hidden":"true"}:{className:"es-savestate-dot","aria-hidden":"true"}),n]})}function
|
|
9
|
-
return c("span",{className:"es-savestate-toggle",children:/* @__PURE__ */c(h,{content:n,side:"bottom",children:/* @__PURE__ */c(p,{size:"sm",checked:!e,"aria-label":n,label:a,onChange:()=>i()})})})}var
|
|
7
|
+
return c(m,{className:"es-devseg",size:"sm",label:t??s.device,value:n,onChange:e=>{e!==n&&a(e)},options:e.map(e=>({value:e.id,icon:/* @__PURE__ */c(h,{content:e.label,side:"bottom",children:/* @__PURE__ */c("span",{className:"es-devseg-glyph","aria-hidden":"true",children:e.icon})}),label:/* @__PURE__ */c("span",{className:"es-vh",children:e.label})}))})}var M={idle:"is-quiet",saved:"is-quiet is-saved",saving:"is-saving",error:"is-error",off:"is-off","off-unsaved":"is-off is-unsaved"};function Y({tone:e,label:n,counting:i,waitMs:a,ringRef:t,role:s}){/* @__PURE__ */
|
|
8
|
+
return d("span",{className:`es-savestate ${M[e]}`,role:s,"aria-live":"polite",children:[/* @__PURE__ */c("span",i?{ref:t,className:"es-savestate-ring is-counting",style:void 0!==a?{"--es-savewait":`${a}ms`}:void 0,"aria-hidden":"true"}:{className:"es-savestate-dot","aria-hidden":"true"}),n]})}function D({pressed:e,title:n,onToggle:i,children:a}){/* @__PURE__ */
|
|
9
|
+
return c("span",{className:"es-savestate-toggle",children:/* @__PURE__ */c(h,{content:n,side:"bottom",children:/* @__PURE__ */c(p,{size:"sm",checked:!e,"aria-label":n,label:a,onChange:()=>i()})})})}var T={saved:{glyph:()=>/* @__PURE__ */c(C,{}),tone:"muted"},saving:{glyph:()=>/* @__PURE__ */c(v,{className:"",ink:"",style:{width:20,height:20}}),tone:"muted"},pending:{glyph:()=>/* @__PURE__ */c(B,{}),tone:"muted"},failed:{glyph:()=>/* @__PURE__ */c(z,{}),tone:"danger"},offline:{glyph:()=>/* @__PURE__ */c(x,{}),tone:"warning"},paused:{glyph:()=>/* @__PURE__ */c(O,{}),tone:"warning"},locked:{glyph:()=>/* @__PURE__ */c(w,{}),tone:"warning"}},J=e=>T[e].tone;function P({state:e,label:n}){const i=T[e],[a,t]=y(n);return N(()=>t(n),[e]),/* @__PURE__ */d("span",{className:"es-saveicon-wrap",children:[
|
|
10
10
|
/* @__PURE__ */c(h,{content:n,side:"bottom",describe:!1,children:/* @__PURE__ */c("span",{className:"es-saveicon",role:"img","aria-label":n,tabIndex:0,"data-save-state":e,"data-tone":i.tone,children:i.glyph()})}),
|
|
11
|
-
/* @__PURE__ */c("span",{className:"es-vh",role:"status","aria-live":"polite",children:a})]})}function
|
|
11
|
+
/* @__PURE__ */c("span",{className:"es-vh",role:"status","aria-live":"polite",children:a})]})}function A({side:e,width:n,min:a,max:t,defaultWidth:s,label:l,onResize:r}){const d=o("chrome",i);/* @__PURE__ */
|
|
12
12
|
return c(f,{side:e,width:n,min:a,max:t,defaultWidth:s,label:l,hint:d.resize,onResize:e=>r(e),className:`es-resizer es-resizer--${e}`})}function F({icon:e,name:n,kind:i,actions:a}){/* @__PURE__ */
|
|
13
13
|
return d("div",{className:"es-insp-head",children:[
|
|
14
14
|
/* @__PURE__ */c("span",{className:"es-insp-chip","aria-hidden":"true",children:e}),
|
|
15
15
|
/* @__PURE__ */d("div",{className:"es-insp-titles",children:[
|
|
16
16
|
/* @__PURE__ */c(h,{content:n,describe:!1,side:"bottom",className:"es-insp-name-tip",children:/* @__PURE__ */c("h2",{className:"es-insp-name",children:n})}),
|
|
17
|
-
/* @__PURE__ */c("div",{className:"es-insp-kind",children:i})]}),a?/* @__PURE__ */c("div",{className:"es-insp-actions",children:a}):null]})}function
|
|
18
|
-
return c(h,{content:n??e,side:"bottom",children:/* @__PURE__ */c(u,{ref:r,variant:s?"ghost-danger":"ghost",className:"es-insp-iconbtn","aria-label":e,"aria-haspopup":i,"aria-expanded":l,disabled:t,onClick:a,children:o})})}function
|
|
19
|
-
/* @__PURE__ */c(b,{as:"h3",size:"sm",weight:"medium",tone:"inherit",className:"es-insp-level-title",children:s})]}):t?u:/* @__PURE__ */c("div",{className:"es-insp-up",children:u})}function
|
|
20
|
-
return c("div",{className:`es-notice is-${d.tone}`,role:d.urgent?"alert":"status",children:/* @__PURE__ */c(g,{tone:"warning"===d.tone?"warning":"info",title:d.lead,action:/* @__PURE__ */c("span",{className:"es-notice-actions",children:m}),children:d.body})})}var
|
|
17
|
+
/* @__PURE__ */c("div",{className:"es-insp-kind",children:i})]}),a?/* @__PURE__ */c("div",{className:"es-insp-actions",children:a}):null]})}function I({label:e,title:n,hasPopup:i,onClick:a,disabled:t,danger:s,expanded:l,buttonRef:r,children:o}){/* @__PURE__ */
|
|
18
|
+
return c(h,{content:n??e,side:"bottom",children:/* @__PURE__ */c(u,{ref:r,variant:s?"ghost-danger":"ghost",className:"es-insp-iconbtn","aria-label":e,"aria-haspopup":i,"aria-expanded":l,disabled:t,onClick:a,children:o})})}function q({name:e,onSelect:n,label:a,inline:t,title:s}){const l=o("chrome",i),r=a??l.upLevel,u=/* @__PURE__ */c(h,{content:r,side:"bottom",children:/* @__PURE__ */c(k,{variant:"link",size:"sm",className:"es-insp-up-btn","aria-label":l.upLevelTo({label:r,name:e}),leftIcon:/* @__PURE__ */c("span",{className:"es-insp-up-arrow","aria-hidden":"true",children:"←"}),onClick:n,children:/* @__PURE__ */c("span",{className:"es-insp-up-name",children:e})})});return s?/* @__PURE__ */d("div",{className:t?"es-insp-level":"es-insp-up es-insp-level",children:[u,
|
|
19
|
+
/* @__PURE__ */c(b,{as:"h3",size:"sm",weight:"medium",tone:"inherit",className:"es-insp-level-title",children:s})]}):t?u:/* @__PURE__ */c("div",{className:"es-insp-up",children:u})}function H({name:e,tier:n,of:a},t){const s={...i,...t};return{name:e,kind:"section"===n?s.tierSection:"block"===n?s.tierBlock:a?s.partOf({name:a}):s.tierBlock}}var E={notice:n,lock:r};function G(e,n,i,a=E){const r=a.notice,o=t(e),c={kind:"reload",label:r.reload};if(n){const e=s(n.secondsAgo,a.lock);return{tone:"warning",urgent:!0,lead:n.savedByYou?r.savedByYou({noun:i,when:e}):r.savedByOther({name:l(n.savedBy,a.lock),noun:i,when:e}),body:r.conflictBody,actions:o?[c,{kind:"take-over",label:r.takeOver,title:r.takeOverWhileDeciding}]:[c]}}if(!o)return null;const d=l(o.name,a.lock),h=s(o.secondsSinceSeen,a.lock);switch(e.kind){case"takenover":return{tone:"warning",urgent:!0,lead:r.tookOver({name:d,noun:i,when:s(o.secondsSinceHeld,a.lock)}),body:r.tookOverBody,actions:[{kind:"take-back",label:r.takeBack},c]};case"readonly":return{tone:"neutral",urgent:!1,lead:r.viewingOnly,body:r.viewingOnlyBody({name:d,noun:i,seen:h}),actions:[{kind:"take-over",label:r.takeOver}]};default:return{tone:"warning",urgent:!1,lead:r.editing({name:d,noun:i}),body:r.editingBody({seen:h}),actions:[{kind:"view-read-only",label:r.viewReadOnly},{kind:"take-over",label:r.takeOver,title:r.takeOverTold}]}}}function V({access:e,conflict:i,noun:a,onTakeOver:t,onViewReadOnly:s,onReload:l}){const d=G(e,i,a,{notice:o("notice",n),lock:o("lock",r)});if(!d)return null;const u={reload:l,"take-over":t,"take-back":t,"view-read-only":s},m=d.actions.map(e=>e.title?/* @__PURE__ */c(h,{content:e.title,side:"bottom",children:/* @__PURE__ */c(k,{variant:"secondary",size:"sm",onClick:u[e.kind],children:e.label})},e.kind):/* @__PURE__ */c(k,{variant:"secondary",size:"sm",onClick:u[e.kind],children:e.label},e.kind));/* @__PURE__ */
|
|
20
|
+
return c("div",{className:`es-notice is-${d.tone}`,role:d.urgent?"alert":"status",children:/* @__PURE__ */c(g,{tone:"warning"===d.tone?"warning":"info",title:d.lead,action:/* @__PURE__ */c("span",{className:"es-notice-actions",children:m}),children:d.body})})}var Z={left:288,right:320},K={left:240,right:220},Q=K.right,U=560;function X(e,n){const i=n?K[n]:Q;return Math.min(560,Math.max(i,Math.round(e)))}function _(e){return{"--es-left-w":`${e.left}px`,"--es-right-w":`${e.right}px`}}function ee(e,n){e.style.setProperty("--es-left-w",`${n.left}px`),e.style.setProperty("--es-right-w",`${n.right}px`)}export{Z as DEFAULT_PANEL_W,L as DeviceSwitch,j as EaselIconButton,R as EaselTopBar,V as EditNotice,F as InspectorHead,I as InspectorIconButton,q as InspectorUpLevel,U as MAX_PANEL_W,Q as MIN_PANEL_W,K as MIN_PANEL_W_BY_SIDE,A as PanelResizeHandle,P as SaveIcon,Y as SaveState,D as SaveStateToggle,S as TopBarCluster,W as TopBarDivider,$ as TopBarRail,X as clampPanelWidth,G as editNotice,H as headWords,_ as panelWidthVars,J as saveIconTone,ee as setPanelWidthVars};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-LUHGBFOD.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-BBD3FLU3.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -0,0 +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-LUHGBFOD.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-S6YOIRXQ.js";import{useEasel as u}from"./chunk-BBD3FLU3.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 O,AddIcon as C}from"efficient-shell/icons/efficient";import{ContextMenu as I,toast as F,Dialog as $,Button as B}from"efficient-shell/ui";import{jsx as E,jsxs as S,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 E($,{open:!0,role:"alertdialog",size:"sm",title:r.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */S(x,{children:[
|
|
3
|
+
/* @__PURE__ */E(B,{ref:s,variant:"secondary",onClick:o,children:r.cancel}),
|
|
4
|
+
/* @__PURE__ */E(B,{variant:"danger",loading:l,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:r.deleteShared})]}),children:r.deleteMessage({count:t})})}var G=e=>`section:${e}`,Q=e=>`block:${e}`,T=e=>`template:${e}`,H=e=>`shared:${e}`,L=e=>`preset:${e}`;function M({at:w,placeBlocks:$,canTake:B,onPick:M,itemFor:U,session:W,siteWide:z,onClose:A,onHide:J,readOnly:N}){const R=u(e=>e.config),V=a(),{labelAtLevel:Y,categoryLabel:X,firstSection:P,Icon:_,Thumbnail:K}=V,{blockIsOffered:Z,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=>Z(e,ne);return r(ne).list().then(n=>{if(e)return;const r=R.components;re(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[R,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=>Z(e,ne);return l(ne).list().then(n=>{if(e)return;const r=R.components;ce(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[R,ne,ae]);const[de,me]=b(null),[fe,ue]=b(null),ye=j(()=>e(R,V),[R]),he=e=>Y(e,"section",R.components[e]?.label??e),ke=e=>({type:e.preset?L(e.preset.key):G(e.type),label:e.name,cover:/* @__PURE__ */E(K,{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__ */E("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */E(_,{type:e,size:26})}),ve=j(()=>{const e=t(ye,P),o=/* @__PURE__ */new Map,r=e=>{e.retired||o.has(e.type)||!Z(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:Q(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:H(e.id),label:e.title,cover:/* @__PURE__ */E(K,{type:e.node.type}),mark:/* @__PURE__ */E(O,{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:T(e.id),label:e.name,cover:/* @__PURE__ */E(K,{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(R.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(R,t,X),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)})}),!B)return p;const u=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ge(e.type),n=t?B(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,R,ee,B,$,ne]);/* @__PURE__ */
|
|
5
|
+
return S(x,{children:[
|
|
6
|
+
/* @__PURE__ */E(i,{icon:/* @__PURE__ */E(C,{size:15}),title:ee.title,context:ee.contextAll,actions:/* @__PURE__ */E(s,{label:ee.done,description:ee.doneDescription,onClick:A}),onHide:J}),
|
|
7
|
+
/* @__PURE__ */S("div",{className:"sf-addside sf-scroll",children:[
|
|
8
|
+
/* @__PURE__ */E(k,{groups:ve,session:W,itemFor:e=>U(ge(e)??{kind:"section",type:e}),onInsert:M?e=>{const t=ge(e);t&&M(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__ */E(I,{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__ */E(D,{name:fe.title,pages:fe.used_on.length,onDelete:()=>(async e=>{try{await l(ne).remove(e.id)}catch{return void F.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{M as AddSidePanel,Q as blockKey,L as presetKey,G as sectionKey,H as sharedKey,T as templateKey};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_LOCK_WORDS as e}from"./chunk-RE4LP46F.js";import{newId as n}from"./chunk-EUFDQ4KL.js";var t=e=>"editing"===e.kind;function r(e){return e?{kind:"checking"}:{kind:"editing"}}var c=e=>"blocked"===e.kind||"readonly"===e.kind||"takenover"===e.kind?e.holder:null;function s(e){if(!e||"object"!=typeof e)return null;const n=e;return"string"!=typeof n.holder_name?null:{name:n.holder_name,secondsSinceSeen:"number"==typeof n.seconds_since_seen?n.seconds_since_seen:0,secondsSinceHeld:"number"==typeof n.seconds_since_held?n.seconds_since_held:0}}var a=e=>e?{edit:!0,insert:!0,delete:!0,duplicate:!0,drag:!1}:{edit:!1,insert:!1,delete:!1,duplicate:!1,drag:!1};function o(n,t=e){if(!Number.isFinite(n)||n<45)return t.justNow;const r=Math.round(n/60);if(r<60)return t.minutesAgo({count:r});const c=Math.round(r/60);return t.hoursAgo({count:c})}var i=(n,t=e)=>n.trim()||t.someone;function d(){return n("tab").slice(0,64)}var u="edit_lock_taken";function l(e,n,r){return!(t(e)||!t(n))&&(r.pending&&r.autoSaveEnabled&&!r.saveConflict)}function f(e,n,r){return!(null===c(e)||!t(n))&&(!r.pending&&!r.saveConflict)}function k(e,n){return e!==n&&Date.parse(e)>=Date.parse(n)}async function h(e){if(!e.ours)return!1;const n=await e.stored().catch(()=>null);return!(!n||!k(n,e.ours)||e.hasPending())&&(e.reload(),!0)}var b=8e3,g=3e4;function _(e){if(e.cancelled())return!1;const n=e.currentAccess();if("checking"!==n.kind)return!1;const t={kind:"editing"};return e.setAccess(t),l(n,t,e.heldWrite())&&e.releaseHeldWrite(),!0}function m(e){const{readFailure:n,conflictCode:t}=e,r=e=>{const t=n(e);return t&&409===t.status?s(t.data):null},c=e=>{const n=r(e);return n?{kind:"blocked",holder:n}:{kind:"editing"}},a=(e,n)=>{const t=r(e);return t?{kind:"blocked",holder:t}:n},o=(e,n)=>{const t=r(e);return t?{kind:"takenover",holder:t}:n},i=e=>{const t=n(e);return null!==t&&(401===t.status||403===t.status)};return{accessAfterClaimFailure:c,accessAfterTakeoverFailure:a,accessAfterHeartbeatFailure:o,isAuthRejection:i,readSaveConflict:e=>{const r=n(e);if(!r||409!==r.status)return null;if(!r.data||"object"!=typeof r.data)return null;const c=r.data;return c.code!==t?null:{savedBy:"string"==typeof c.saved_by?c.saved_by:"",savedByYou:!0===c.saved_by_you,secondsAgo:"number"==typeof c.seconds_ago?c.seconds_ago:0}},readLockTaken:e=>{const t=n(e);return t&&409===t.status&&t.data&&"object"==typeof t.data?t.data.code!==u?null:s(t.data)??{name:"",secondsSinceSeen:0,secondsSinceHeld:0}:null},makeClaimBeat:e=>{let n=!1;return async t=>{let r,s;try{const c=await e.claim(t);if(e.cancelled())return;r=e.currentAccess(),s={kind:"editing"},!n&&c.heartbeat_seconds>0&&(n=!0,e.startHeartbeat(1e3*c.heartbeat_seconds))}catch(n){if(e.cancelled())return;r=e.currentAccess(),s=t?a(n,r):"checking"===r.kind?c(n):o(n,r),i(n)&&e.stopHeartbeat()}e.setAccess(s);const d=e.heldWrite();l(r,s,d)?e.releaseHeldWrite():t&&f(r,s,d)&&e.reloadIfMoved?.()}}}}export{b as CLAIM_FAIL_OPEN_MS,u as EDIT_LOCK_TAKEN,g as FAIL_OPEN_RETRY_MS,r as accessForNewDocument,t as canWriteDocument,m as createEditLock,o as describeAge,a as documentPermissions,k as documentVersionMoved,c as holderOf,i as nameOrSomeone,d as newEaselClientId,_ as openUnansweredClaim,s as readLockHolder,h as reloadIfVersionMoved,l as shouldReleaseHeldWrite,f as shouldReloadAfterTakeover};
|
package/dist/copy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{SettingsSwitch as e}from"../chunk-OECWLNKJ.js";import{TEXT_STYLE_CASES as t}from"../chunk-YHZSBL2N.js";import{selectionToVisible as n,selectionToSource as r,richLayout as l,createHistory as o,colorRunOf as a,textRange as s,selectionBox as c,placeWindow as i,offsetOrigin as u,visibleArea as d,clearRangeOf as p,ColorWindow as h,markPress as m,pasteToMarkup as f,richInput as g,editVisible as y,MARKUP_CLIPBOARD_TYPE as v,markupOfRange as b}from"../chunk-HZSZT3BE.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,clearRangeOf,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as k}from"../chunk-PMRN5Z3T.js";import{FieldNumber as x}from"../chunk-Y2T3JX7K.js";import{FieldSelect as S}from"../chunk-KFWNGPW3.js";import{SettingsField as E}from"../chunk-MIX7EGRG.js";import{SettingsSegmented as w}from"../chunk-DX3VILZ3.js";import"../chunk-JACEEVVF.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{registerModalEscapeInterceptor as N,textToolbarRows as D,TextToolbar as T,textAlignWords as O,useShellStrings as L,textAlignOptions as R,TEXT_ALIGNS as K,LinkPicker as j,Tooltip as B,IconButton as F}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as H,useState as M,useLayoutEffect as V,useEffect as W,useId as $}from"react";import{RETIRED_MARKS as P,applyMark as z,marksIn as I,STANDARD_MARKUP as Z,listIn as q,colorIn as Y,clearStyle as A,spanFor as G,findLink as U,tokenizeInline as _,colorOver as J,setList as X,unlinkAt as Q,removeLink as ee,linkOver as te,writeLink as ne}from"efficient-shell/markup";import{jsxs as re,jsx as le,Fragment as oe}from"react/jsx-runtime";import{ParagraphSpacingIcon as ae,LetterSpacingIcon as se,LineSpacingIcon as ce,TextSizeIcon as ie,StylesIcon as ue,TypeIcon as de,AlignmentIcon as pe,ListFormatIcon as he,CaseIcon as me,ItalicIcon as fe,NumberedListIcon as ge,ListIcon as ye,ListNoneIcon as ve,CaseLowerIcon as be,CaseCapitalizedIcon as ke,CaseUpperIcon as xe,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function Ee(e,t,n,r,l){for(const o of l){if(o.kind!==n)continue;if(!e.startsWith(o.open,t))continue;const l=t+o.open.length;if(e.startsWith(r,l)&&e.startsWith(o.close,l+r.length))return o}return null}function we({value:e,rules:t=Z,className:n,layerRef:r}){const l=function(e,t){const n=[];let r=0;for(const l of _(e,t)){if("text"===l.kind){l.text.length>0&&(n.push({kind:"text",text:e.slice(r,r+l.text.length)}),r+=l.text.length);continue}const o=Ee(e,r,l.kind,l.text,t);if(!o)return[{kind:"text",text:e}];const a=r+o.open.length,s=a+l.text.length,c=s+o.close.length;n.push({kind:"delimiter",text:e.slice(r,a)}),n.push({kind:l.kind,text:e.slice(a,s)}),n.push({kind:"delimiter",text:e.slice(s,c)}),r=c}return n.map(e=>e.text).join("")!==e?[{kind:"text",text:e}]:n}(e,t);/* @__PURE__ */
|
|
2
2
|
return le("div",{ref:r,className:["es-gold-layer",n??""].filter(Boolean).join(" "),"aria-hidden":"true",children:l.map((e,t)=>function(e,t){const{kind:n,text:r}=e;switch(n){case"delimiter":/* @__PURE__ */
|
|
3
3
|
return le("span",{className:"es-gold-delim",children:r},t);case"accent":case"highlight":/* @__PURE__ */
|
|
4
4
|
return le("em",{className:"es-gold-mark es-gold-accent",children:r},t);case"bold":/* @__PURE__ */
|
|
@@ -6,24 +6,24 @@ return le("strong",{className:"es-gold-mark es-gold-bold",children:r},t);case"it
|
|
|
6
6
|
return le("em",{className:"es-gold-mark es-gold-italic",children:r},t);case"strike":/* @__PURE__ */
|
|
7
7
|
return le("s",{className:"es-gold-mark es-gold-strike",children:r},t);case"quiet":/* @__PURE__ */
|
|
8
8
|
return le("span",{className:"es-gold-mark es-gold-quiet",children:r},t);default:/* @__PURE__ */
|
|
9
|
-
return le("span",{className:"es-gold-text",children:r},t)}}(e,t))})}function Ce({value:e,onInput:t,onCommit:n,onCancel:r,multiline:l=!1,placeholder:o,className:a,rules:s=
|
|
9
|
+
return le("span",{className:"es-gold-text",children:r},t)}}(e,t))})}function Ce({value:e,onInput:t,onCommit:n,onCancel:r,multiline:l=!1,placeholder:o,className:a,rules:s=Z,ariaLabel:c,disabled:i=!1,inputRef:u}){const d=H(null),p=H(e),h=H(!1);function m(e){h.current&&(h.current=!1,n?.(e))}/* @__PURE__ */
|
|
10
10
|
return re("div",{className:["es-gold",l?"es-gold-is-multiline":"es-gold-is-single",i?"es-gold-is-off":"",a??""].filter(Boolean).join(" "),children:[
|
|
11
11
|
/* @__PURE__ */le(we,{value:e,rules:s,layerRef:d}),o&&""===e?
|
|
12
12
|
/* @__PURE__ */le("div",{className:"es-gold-placeholder","aria-hidden":"true",children:o}):null,
|
|
13
|
-
/* @__PURE__ */le("textarea",{ref:u,className:"es-gold-input",disabled:i,value:e,placeholder:o,"aria-label":c,onChange:function(e){h.current=!0,t(e.currentTarget.value)},onFocus:function(){p.current=e,h.current=!1},onBlur:function(){m(e)},onKeyDown:function(t){return"Escape"===t.key?(t.preventDefault(),h.current=!1,void r?.(p.current)):"Enter"!==t.key||l?void 0:(t.preventDefault(),void m(e))},onScroll:function(e){const t=d.current;t&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function Ne(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function De(e,t,n,r=
|
|
13
|
+
/* @__PURE__ */le("textarea",{ref:u,className:"es-gold-input",disabled:i,value:e,placeholder:o,"aria-label":c,onChange:function(e){h.current=!0,t(e.currentTarget.value)},onFocus:function(){p.current=e,h.current=!1},onBlur:function(){m(e)},onKeyDown:function(t){return"Escape"===t.key?(t.preventDefault(),h.current=!1,void r?.(p.current)):"Enter"!==t.key||l?void 0:(t.preventDefault(),void m(e))},onScroll:function(e){const t=d.current;t&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function Ne(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function De(e,t,n,r=z){const{start:l,end:o}=Ne(e,n);return r(e,l,o,t)}function Te(e,t,n){const{start:r,end:l}=Ne(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Oe(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Le(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function Re(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ke({value:e,rules:t,multiline:o,readOnly:a=!1,placeholder:s,ariaLabel:c,handle:i,onEdit:u,onSelect:d,onHistory:p,onFormat:h,pending:m,onCommit:k,onCancel:x}){const S=H(null),E=H(null),w=H(null),C=H(null),N=H(null),D=H(e),[T,O]=M(0),L=H({value:e,rules:t,multiline:o,readOnly:a,pending:m,onEdit:u,onHistory:p,onFormat:h});L.current={value:e,rules:t,multiline:o,readOnly:a,pending:m,onEdit:u,onHistory:p,onFormat:h};const R=()=>{const e=S.current,t=E.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Le(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Le(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},K=(e,t)=>{const n=S.current,r=E.current;if(!n||!r)return;const[l,o]=Re(r,e),[a,s]=Re(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};i.current={getSource(){const e=R(),t=E.current;if(!e||!t)return null;const[n,l]=r(t.layout,e[0],e[1]);return{start:n,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){S.current?.focus()},rangeOf(e,t){const r=S.current,l=E.current;if(!r||!l)return null;const[o,a]=n(l.layout,e,t),[s,c]=Re(l,o),[i,u]=Re(l,a),d=r.ownerDocument.createRange();return d.setStart(s,c),d.setEnd(i,u),d}},V(()=>{const r=S.current;if(!r||N.current)return;const o=C.current?null:R();E.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Oe(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(r,l(e,t)),w.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&r.ownerDocument.activeElement===r&&K(o[0],Math.min(o[1],E.current.layout.text.length)));C.current=null;const s=E.current.layout,[c,i]=a.vis??n(s,a.src[0],a.src[1]);r.ownerDocument.activeElement!==r&&r.focus(),K(c,i)},[e,t,T]);const j=(e,t,n)=>{const l=E.current,[o,a]=r(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==L.current.value?L.current.onEdit(e.text,{start:o,end:a},n):O(e=>e+1)};W(()=>{const e=S.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=L.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=E.current,c=R();if(!s||!c)return;const i="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=i&&!i.collapsed?[Le(s,e,i.startContainer,i.startOffset),Le(s,e,i.endContainer,i.endOffset)]:null,d=g({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?j(d.edit,d.range,d.kind):L.current.onFormat(d.style):L.current.onHistory(d.dir))},n=()=>{N.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),W(()=>{const e=S.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=i.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const B=(n,r=!1)=>{const l=R();if(!l||l[0]===l[1])return;n.preventDefault();const o=E.current;n.clipboardData.setData("text/plain",o.layout.text.slice(l[0],l[1])),n.clipboardData.setData(v,b(e,t,l[0],l[1])),r&&!a&&j(y(e,t,l[0],l[1],{text:""}),l,"edit")};/* @__PURE__ */
|
|
14
14
|
return re("div",{className:"es-rich-wrap",children:[s&&""===e?/* @__PURE__ */le("div",{className:"es-rich-placeholder","aria-hidden":"true",children:s}):null,
|
|
15
|
-
/* @__PURE__ */le("div",{ref:S,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":c,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{D.current=e},onBlur:()=>{e!==D.current&&k?.(e),D.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),x?.(D.current),void(D.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==D.current&&k?.(e),D.current=e)},onCompositionStart:()=>{const e=R()??[0,0];N.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=N.current;if(N.current=null,!t)return;const{value:n,rules:r,pending:l}=
|
|
15
|
+
/* @__PURE__ */le("div",{ref:S,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":c,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{D.current=e},onBlur:()=>{e!==D.current&&k?.(e),D.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),x?.(D.current),void(D.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==D.current&&k?.(e),D.current=e)},onCompositionStart:()=>{const e=R()??[0,0];N.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=N.current;if(N.current=null,!t)return;const{value:n,rules:r,pending:l}=L.current;e.data?j(y(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>B(e),onCut:e=>B(e,!0),onPaste:n=>{if(n.preventDefault(),a)return;const r=R();if(!r)return;const l=n.clipboardData.getData(v),s=l?o?l:l.replace(/\s*\r?\n\s*/g," "):f({html:n.clipboardData.getData("text/html"),text:n.clipboardData.getData("text/plain")},{doc:n.currentTarget.ownerDocument,multiline:o,rules:t});j(y(e,t,r[0],r[1],{markup:s}),r,"edit")}})]})}var je={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */le(ie,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */le(ce,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */le(se,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */le(ae,{}),unit:"px",step:1,shiftStep:10,min:0}};function Be(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Fe({cells:e,words:t,readOnly:n=!1}){const r=t??k.cells,l=$();/* @__PURE__ */
|
|
16
16
|
return le("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */le("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,o=e.name??(e.nameKey?r[e.nameKey]:e.key),a=e.unit??"",s=e.step??1,c=`${l}-${e.key}`;/* @__PURE__ */
|
|
17
17
|
return re("div",{className:"es-copy-cell",children:[
|
|
18
18
|
/* @__PURE__ */le("label",{className:"es-field-label es-copy-cell-name",htmlFor:c,children:o}),
|
|
19
|
-
/* @__PURE__ */le(
|
|
20
|
-
return re("div",{ref:at,className:"es-copy"+(
|
|
21
|
-
/* @__PURE__ */le(T,{className:"es-copy-toolbar","aria-label":K??de.formatting,offered:ht,pressed:
|
|
19
|
+
/* @__PURE__ */le(x,{id:c,value:Be(e.value,t),styleValue:Be(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:"compact",readOnly:n,ariaLabel:o,title:r.tip({name:o,step:s,unit:a})})]},e.key)})})})}function He({target:e,onChange:t}){const n=H(null);return V(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Me=/* @__PURE__ */new Set([...P,"clear"]);function Ve({value:t,onChange:n,onCommit:r,onCancel:l,multiline:g=!1,placeholder:y,ariaLabel:v,className:b,readOnly:x=!1,rules:S,tools:E=[],writeMark:w,align:O,actions:L,toolbar:R,barLabel:K,renderFooter:B,inputRef:F,barShows:P="always",richText:_=!0,defaultShowMarks:ae=!1,colors:se,cells:ce,letterCase:ie,lastTool:ue}){const de=C("copy",k),pe=H(null),he=F??pe,[me,fe]=M(!1),[ge,ye]=M(null),ve=H(o()).current,be=H(null);W(()=>{const e=be.current;e&&t===e.to?be.current=null:e&&t===e.from||(be.current=null,ve.reset())},[t,ve]);const ke=e=>{be.current={from:be.current?.from??t,to:e},n(e)},xe=e=>({text:t,start:e?.selectionStart??ge?.start??t.length,end:e?.selectionEnd??ge?.end??t.length}),[Se,Ee]=M(ae),we=_&&!(g&&Se),Ne=H(null),Oe=$(),[Le,Re]=M(null),[je,Be]=M(!1),Ve=()=>{if(!we)return he.current;const e=Ne.current?.getSource()??ge;return e?{selectionStart:e.start,selectionEnd:e.end}:null},We=He({target:he,onChange:ke}),$e=e=>(ye({start:e.selectionStart,end:e.selectionEnd}),e),Pe=(e,n)=>{if(!we)return void We(t=>(n&&ve.record(xe(t),"edit",Date.now()),$e(e(t))));const r=Ve(),l=$e(e(r));n&&ve.record(xe(r),"edit",Date.now()),Re(null),l.text!==t&&ke(l.text),Ne.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},ze=e=>Pe(e,!0),Ie=e=>Pe(t=>{const n=xe(t),r=ve[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Ze=H(null);V(()=>{const e=Ze.current;e&&(Ze.current=null,we?Ne.current?.setSource(e.start,e.end,t):(he.current?.focus(),he.current?.setSelectionRange(e.start,e.end),ye(e)))},[we]);const[qe,Ye]=M(null),Ae=S??Z,Ge=("string"==typeof E[0]?E:E.map(e=>e.style)).filter(e=>!Me.has(e)),Ue={};if(ge){const e=I(t,ge.start,ge.end,Ae);for(const t of Ge){const n=e.has(t)||"highlight"===t&&e.has("accent");Ue[t]=!!Le?.add.includes(t)||!Le?.drop.includes(t)&&n}Ue.link=e.has("link")}const _e=()=>{const e=Ve(),n=e?.selectionStart??t.length;return{start:n,end:e?.selectionEnd??n}},Je=e=>{if("link"!==e&&G(0,e)){const{start:n,end:r}=_e();if(n===r&&!we)return void ze(n=>De(t,e,n,(e,t,n,r)=>z(e,t,n,r,Ae,de.placeholders)));const l=m({value:t,rules:Ae,start:n,end:r,style:e,pending:Le});return void("pending"===l.kind?Re(l.pending):ze(()=>l.result))}if("link"!==e){const n=w??((e,t,n,r)=>z(e,t,n,r,Z,de.placeholders));return void ze(r=>De(t,e,r,n))}const n=Ve(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;Be(!1),Ye({start:r,end:l,link:U(t,r,l)})},Xe=Boolean(ge&&ge.start!==ge.end),Qe=ge?q(t,ge.start,ge.end,Ae):null,et=ge?Le&&void 0!==Le.color&&Le.at===ge.start?Le.color:Y(t,ge.start,ge.end,Ae):null,tt=a(et,se),nt=e=>{we?e?Ne.current?.setSource(e.start,e.end,t):Ne.current?.focus():(he.current?.focus(),e&&he.current?.setSelectionRange(e.start,e.end))},rt=()=>{const e=qe;Ye(null),nt(e?{start:e.start,end:e.end}:ge)},lt=()=>{const e=at.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Be(!1),t&&nt(ge)},ot=H(lt);ot.current=lt,W(()=>{if(je)return N(e=>{const t=at.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(ot.current(),!0)},()=>at.current?.querySelector(".es-copy-colors"))},[je]);const at=H(null),st=je||null!==qe;W(()=>{const e=at.current;if(!st||!e)return;const t=e.ownerDocument,n=()=>{Be(!1),Ye(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[st]);const ct=qe??(je?ge??{start:t.length,end:t.length}:null),it=H(()=>{});it.current=()=>{const e=at.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!ct)return;const n=we?null:e.querySelector(".es-gold-layer"),r=we?Ne.current?.rangeOf(ct.start,ct.end)??null:n?s(n,ct.start,ct.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,a=r?c(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const p=i({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:d(e),parent:u(t)});t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.setProperty("--es-pop-point",`${p.point}px`),t.dataset.side=p.above?"above":"below"},V(()=>{const e=at.current;if(!st||!e)return;const t=()=>it.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[st,je,qe,ct?.start,ct?.end,we]);const ut="always"===P||me||null!==qe||je,dt=se&&se.length>0?{run:tt,open:je,onToggle:()=>{Ye(null),je?lt():Be(!0)}}:void 0,pt=ut?ue?ue({className:"rosh-tb-btn",disabled:x,selected:Xe,keepCaret:e=>e.preventDefault(),insert:e=>ze(n=>Te(t,e,n))}):"classic"===R?L:void 0:void 0,ht=new Set(Ge),mt=O?{value:O.value,allow:O.allow,onChange:O.onChange,disabled:O.disabled}:void 0,ft={pressed:Qe,onList:e=>{const{start:n,end:r}=_e(),l=q(t,n,r,Ae);ze(()=>X(t,n,r,l===e?null:e,Ae))}},gt=p(ge,t.length),yt=x||A(t,gt.start,gt.end,Ae).text===t?void 0:{onClear:()=>{const{start:e,end:n}=p(_e(),t.length);ze(()=>A(t,e,n,Ae))}},vt=D({offered:ht,color:dt,last:pt,alignment:mt,list:ft,letterCase:ie,clear:yt});/* @__PURE__ */
|
|
20
|
+
return re("div",{ref:at,className:"es-copy"+(b?` ${b}`:""),onFocus:()=>fe(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||fe(!1)},onKeyDown:e=>{const t=e.target===he.current||Boolean(e.target.closest?.(".es-rich"));if(x||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void Ie(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ge.includes(o)&&(e.preventDefault(),e.stopPropagation(),Je(o))},onPaste:e=>{const n=he.current;if(x||!n||e.target!==n)return;e.preventDefault();const r=f({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:g,rules:Ae});ze(e=>Te(t,r,e))},style:se&&se.length>0?Object.fromEntries(se.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const e=he.current;e&&e.ownerDocument.activeElement===e&&ye({start:e.selectionStart??t.length,end:e.selectionEnd??t.length})},children:[ut&&(vt.words||vt.paragraph)?
|
|
21
|
+
/* @__PURE__ */le(T,{className:"es-copy-toolbar","aria-label":K??de.formatting,offered:ht,pressed:Ue,onMark:e=>Je(e),color:dt,linkOpen:null!==qe,last:pt,alignment:mt,list:ft,letterCase:ie,clear:yt,disabled:x,windows:/* @__PURE__ */re(oe,{children:[je&&se&&se.length>0?/* @__PURE__ */le(h,{colors:se,current:et,words:de.colors??k.colors,onPick:e=>{const{start:n,end:r}=_e();if(n!==r)ze(()=>J(t,n,r,e,Ae));else{if(!we)return;Re({add:Le?.add??[],drop:Le?.drop??[],color:e,at:n})}}}):null,qe?qe&&/* @__PURE__ */le(j,{className:"es-copy-link es-copy-pop",value:qe.link?.href??"",onApply:e=>{const n=qe;Ye(null),ze(()=>we?te(t,n.start,n.end,e,Ae):ne(t,n.start,n.end,e))},onRemove:qe.link?()=>{const e=qe.link,n=qe;Ye(null),e&&ze(()=>we?Q(t,n.start,n.end,Ae):ee(t,e))}:void 0,onCancel:rt}):null]})}):null,ce&&ce.length>0?/* @__PURE__ */le(Fe,{cells:ce,words:de.cells??k.cells,readOnly:x}):null,we?/* @__PURE__ */le(Ke,{value:t,rules:Ae,multiline:g,readOnly:x,placeholder:y,ariaLabel:v,handle:Ne,pending:Le??void 0,onEdit:(e,n,r)=>{ve.record({text:t,start:n.start,end:n.end},r,Date.now()),Re(null),ke(e)},onSelect:e=>{ye(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Le||e.start===Le.at&&e.end===Le.at||Re(null)},onHistory:Ie,onFormat:e=>{Ge.includes(e)&&Je(e)},onCommit:r,onCancel:l}):/* @__PURE__ */le(Ce,{value:t,onInput:e=>{ve.record(xe(null),"type",Date.now()),ke(e)},onCommit:r,onCancel:l,multiline:g,placeholder:y,ariaLabel:v,rules:S,disabled:x,inputRef:he,className:"es-copy-box"}),B?B({focused:me,insert:e=>ze(n=>Te(t,e,n))}):null,_&&g?
|
|
22
22
|
/* @__PURE__ */re("div",{className:"es-copy-marks",children:[
|
|
23
|
-
/* @__PURE__ */le(
|
|
24
|
-
/* @__PURE__ */le("span",{id:
|
|
25
|
-
return le(E,{label:e,icon:t,children:/* @__PURE__ */le(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function
|
|
23
|
+
/* @__PURE__ */le(e,{checked:Se,onChange:()=>{const e=Ve();Ze.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ge,Re(null),Ee(e=>!e)},ariaLabelledBy:Oe,disabled:x}),
|
|
24
|
+
/* @__PURE__ */le("span",{id:Oe,className:"es-copy-marks-label",children:de.showMarks??"Show marks"})]}):null]})}var We=["none","bullet","number"],$e=t,Pe={none:/* @__PURE__ */le(ve,{}),bullet:/* @__PURE__ */le(ye,{}),number:/* @__PURE__ */le(ge,{})},ze={none:/* @__PURE__ */le(Se,{}),upper:/* @__PURE__ */le(xe,{}),capitalize:/* @__PURE__ */le(ke,{}),lower:/* @__PURE__ */le(be,{})};function Ie({label:e,icon:t,answers:n,names:r,glyphs:l,row:o,readOnly:a}){const s=o.value||o.styleValue||"";/* @__PURE__ */
|
|
25
|
+
return le(E,{label:e,icon:t,children:/* @__PURE__ */le(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function Ze({kept:e,keptHint:t,readOnly:n=!1,style:r,font:l,italic:o,cells:a,align:s,list:c,letterCase:i}){const u=C("copy",k),d=O(L().textToolbar),p=Object.fromEntries(R(K).map(e=>[e.value,e.icon])),h={...k.panel,...u.panel},m=r&&!n?[r.onEditStyles&&{label:h.editStyles,onSelect:r.onEditStyles},r.onUpdateStyle&&{label:h.updateStyle,onSelect:r.onUpdateStyle}].filter(e=>!!e):[],f=!!o&&(o.value??o.styleValue??!1),g=o?/* @__PURE__ */le(B,{content:h.italic,children:/* @__PURE__ */le(F,{size:"md",variant:"ghost","aria-label":h.italic,"aria-pressed":f,disabled:n,onClick:()=>{if(n)return;const e=!f;o.onChange(e===(o.styleValue??!1)?void 0:e)},children:/* @__PURE__ */le(fe,{})})}):null;/* @__PURE__ */
|
|
26
26
|
return re("div",{className:"es-tpp",children:[e?/* @__PURE__ */re("div",{className:"es-tpp-kept",children:[
|
|
27
|
-
/* @__PURE__ */le(
|
|
28
|
-
/* @__PURE__ */le("div",{className:"es-tpp-font-select",children:/* @__PURE__ */le(
|
|
29
|
-
/* @__PURE__ */le(E,{label:h.italic,icon:/* @__PURE__ */le(de,{}),children:/* @__PURE__ */le("div",{className:"es-tpp-font",children:g})}):null,a?.length?/* @__PURE__ */le(Fe,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */le(Ie,{label:u.alignment,icon:/* @__PURE__ */le(pe,{}),answers:K.filter(e=>!s.allow||s.allow.includes(e)),names:d,glyphs:p,row:s,readOnly:n}):null,c?/* @__PURE__ */le(Ie,{label:h.list,icon:/* @__PURE__ */le(he,{}),answers
|
|
27
|
+
/* @__PURE__ */le(Ve,{...e,readOnly:n||e.readOnly}),t?/* @__PURE__ */le("p",{className:"es-field-hint",children:t}):null]}):null,r?/* @__PURE__ */le(E,{label:h.style,icon:/* @__PURE__ */le(ue,{}),children:/* @__PURE__ */le(S,{ariaLabel:h.style,value:r.value,options:r.options,onChange:r.onChange,changed:r.changed,footer:m,readOnly:n})}):null,l?/* @__PURE__ */le(E,{label:h.font,icon:/* @__PURE__ */le(de,{}),children:/* @__PURE__ */re("div",{className:"es-tpp-font",children:[
|
|
28
|
+
/* @__PURE__ */le("div",{className:"es-tpp-font-select",children:/* @__PURE__ */le(S,{ariaLabel:h.font,value:l.value||void 0,placeholder:l.styleValue,options:l.options,onChange:l.onChange,searchable:l.searchable,readOnly:n})}),g]})}):g?
|
|
29
|
+
/* @__PURE__ */le(E,{label:h.italic,icon:/* @__PURE__ */le(de,{}),children:/* @__PURE__ */le("div",{className:"es-tpp-font",children:g})}):null,a?.length?/* @__PURE__ */le(Fe,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */le(Ie,{label:u.alignment,icon:/* @__PURE__ */le(pe,{}),answers:K.filter(e=>!s.allow||s.allow.includes(e)),names:d,glyphs:p,row:s,readOnly:n}):null,c?/* @__PURE__ */le(Ie,{label:h.list,icon:/* @__PURE__ */le(he,{}),answers:We,names:h.lists,glyphs:Pe,row:c,readOnly:n}):null,i?/* @__PURE__ */le(Ie,{label:h.capitalization,icon:/* @__PURE__ */le(me,{}),answers:$e,names:h.cases,glyphs:ze,row:i,readOnly:n}):null]})}export{je as COPY_CELLS,Ve as CopyBox,Fe as CopyCells,Ke as RichBox,Ze as TextPartPanel,Te as insertSelection,De as markSelection,He as useCaretEdit};
|