efficient-easel 0.96.0 → 0.98.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 +98 -3
- package/dist/autosave/index.d.ts +4 -4
- package/dist/blocks/index.d.ts +15 -4
- package/dist/{buckets-1vRlQceY.d.ts → buckets-CuLM47h9.d.ts} +1 -1
- package/dist/chrome/chrome.css +25 -16
- package/dist/chrome/index.d.ts +6 -6
- package/dist/chrome/index.js +6 -6
- package/dist/chunk-2UX75JDP.js +1 -0
- package/dist/{chunk-STFMZJKU.js → chunk-66CKSTXP.js} +6 -6
- package/dist/{chunk-6JDII7N3.js → chunk-6PS6STGA.js} +1 -1
- package/dist/{chunk-EFTTSIMK.js → chunk-D2BCHTQR.js} +1 -1
- package/dist/{chunk-YIMRTIBN.js → chunk-IBOFSS56.js} +1 -1
- package/dist/chunk-KRXQM65X.js +1 -0
- package/dist/chunk-PI26YXYD.js +462 -0
- package/dist/{chunk-FJE4IDBQ.js → chunk-YRLPFZW3.js} +1 -1
- package/dist/copy/copy.css +5 -5
- package/dist/copy/index.d.ts +5 -5
- package/dist/copy/index.js +10 -10
- package/dist/data/index.d.ts +171 -4
- package/dist/data/index.js +1 -1
- package/dist/drag/drag.css +15 -15
- package/dist/drag/index.d.ts +1 -1
- package/dist/drag/index.js +15 -15
- package/dist/edit-lock/index.d.ts +1 -1
- package/dist/editor/index.d.ts +9 -9
- package/dist/editor/index.js +6 -6
- package/dist/fields/fields.css +126 -12
- package/dist/fields/index.d.ts +61 -13
- package/dist/fields/index.js +41 -34
- package/dist/gold/index.d.ts +1 -1
- package/dist/icons/index.d.ts +26 -5
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/menu/menu.css +4 -4
- package/dist/node-ops/index.d.ts +3 -3
- package/dist/node-ops/index.js +1 -1
- package/dist/panel/index.d.ts +10 -10
- package/dist/panel/panel.css +34 -25
- package/dist/pick/pick.css +8 -8
- package/dist/{plan-DtNw2VuI.d.ts → plan-DChbUXdS.d.ts} +1 -1
- package/dist/rail/index.d.ts +2 -2
- package/dist/rail/index.js +1 -1
- package/dist/rail/rail.css +1 -1
- package/dist/render/index.d.ts +2 -2
- package/dist/{resolve-DpH8YQOA.d.ts → resolve-D68pb3Bx.d.ts} +1 -1
- package/dist/shell/index.d.ts +24 -4
- package/dist/shell/index.js +1 -1
- package/dist/shell/shell.css +12 -2
- package/dist/strings/catalogue.d.ts +4 -4
- package/dist/strings/index.d.ts +4 -4
- package/dist/style-clipboard/index.js +1 -1
- package/dist/tree/index.d.ts +1 -1
- package/dist/tree/index.js +1 -1
- package/dist/tree/tree.css +11 -11
- package/dist/{types-DziKCwsN.d.ts → types-41704JE4.d.ts} +8 -1
- package/dist/{types-CEqUFH2j.d.ts → types-C7HFvdtk.d.ts} +26 -4
- package/dist/{types-CuNiSnX6.d.ts → types-CnRzp9oc.d.ts} +1 -1
- package/dist/{types-_Vayx8ov.d.ts → types-Dy6oR6Z2.d.ts} +2 -2
- package/dist/{useNodeOps-6IAej9jy.d.ts → useNodeOps-BF0fQsif.d.ts} +2 -2
- package/dist/{words-CsRWXkY4.d.ts → words-Cqmyey0s.d.ts} +2 -2
- package/dist/{words-DfxEp_RH.d.ts → words-bOMsUJk9.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-FI23ALVJ.js +0 -1
- package/dist/chunk-LPRQDDQO.js +0 -1
- package/dist/chunk-YNZZYHA4.js +0 -450
package/dist/editor/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{DEFAULT_CANVAS_WORDS as e}from"../chunk-GGTPNGFJ.js";import{useResolvedFields as t}from"../chunk-FJE4IDBQ.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r}from"../chunk-EFTTSIMK.js";import{useWords as i}from"../chunk-MFIRYGHW.js";import{setCanvasNonce as a}from"../chunk-ZNCEOSXO.js";import{find as s,ROOT_ID as l,getList as d,remove as c,parseZoneKey as u,move as p,duplicate as h,replaceNode as f,createNode as m,insert as v,normalizeData as y,createResolveCache as g,resolveNodeData as k,ROOT_SLOT as b}from"../chunk-LPRQDDQO.js";import{topLevelSlotKeys as w,fieldsFrom as I,defaultsFrom as S}from"../chunk-NKB3KVAB.js";import{createContext as C,useEffect as D,useContext as E,useRef as O,useSyncExternalStore as x,useState as A,useLayoutEffect as z,useMemo as M,useCallback as Z}from"react";import{jsx as $,jsxs as N}from"react/jsx-runtime";import{createPortal as B}from"react-dom";function P(e){return!["setData","setUi","set"].includes(e.type)}var R=(e,t,n,o)=>{const r=d(e,t,u(n));return r?.[o]??null},j=(e,t,n,o,r)=>{const i=R(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function F(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function K(e,t,n){return n?"node"===n.kind?s(e,t,n.id)?n:null:n.parentId===l?d(e,t,n)?n:null:s(e,t,n.parentId)&&d(e,t,n)?n:null:null}function L(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var d;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(d=a)?{kind:"slot",parentId:d.parentId,slot:d.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function T(e,t,n){const o=V(e,t,n);if(o===e)return e;const r=K(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function V(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return L(e,n,"function"==typeof t.ui?t.ui(F(e,n)):t.ui);case"set":{const r={data:o,ui:F(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=L(a,n,i.ui,!0)),a}case"insert":{const r={...u(t.destinationZone),index:t.destinationIndex},i=m(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:v(o,n,r,i)}}case"replace":{const r=j(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:f(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=j(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=h(o,n,r.props.id),a=R(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return V(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=R(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...u(t.destinationZone),index:t.destinationIndex};return{...e,data:p(o,n,r.props.id,i)}}case"remove":{const r=j(o,n,t.zone,t.index,"remove");return{...e,data:c(o,n,r.props.id)}}default:return e}}var H={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},q={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},G=0,Q=()=>`history-${G+=1}`;function U(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const l=y(e.data,t);let c={data:l,selection:null,ui:{...q}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:l,selection:r?{kind:"slot",...r}:o(l,t,n??null),ui:{...q,...i}}}let u=[{core:c,at:-1/0,sealed:!0,id:Q()}],p=0;const h=e=>{const t=u[p],n=r();!e&&p===u.length-1&&p>0&&!t.sealed&&n-t.at<i?u=[...u.slice(0,p),{...t,core:c,at:n}]:(u=[...u.slice(0,p+1),{core:c,at:n,sealed:e,id:Q()}],p=u.length-1)},m=/* @__PURE__ */new Set;let v=null,b=null,w=0,I=null,S=!1;const C=()=>{for(const e of[...m])e()},D=()=>{u=[...u.slice(0,p),{...u[p],core:c},...u.slice(p+1)]},E=(t,n)=>{w>0?S=S||n:(n?h(!1):c!==t&&D(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&C())},O=e=>{const n=c;if(c=T(c,e,t),c===n)return;const o=e.recordHistory??P(e);E(n,o&&c.data!==n.data)},x=t=>{0===w&&(I=c,S=!1),w+=1;try{t()}catch(e){throw w-=1,0===w&&I&&(c=I,I=null),e}if(w-=1,w>0||!I)return;const n=I;I=null,S&&c.data!==n.data?h(!0):c!==n&&D(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},A=e=>{const n=c,o=K(c.data,t,e);var r,i;(r=o,i=c.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(c={...c,selection:o},E(n,!1))},z=t=>{const n=c;p=t,c=u[p].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},M=(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...H,...a,...n}},Z=g(),$={resolveCache:Z,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...l]=await Promise.all([k(r,t,{cache:Z,trigger:e,metadata:n}),...i.map(o=>k(o,t,{cache:Z,trigger:e,metadata:n}))]);x(()=>{const e=c;let n=c.data;l.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,l=s(n,t,a)?.node;l&&l===s(o,t,a)?.node&&(n=f(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==c.data&&(c={...c,data:n,selection:K(n,t,c.selection)},E(e,!1))})},get config(){return t},getState(){if(v&&b===c)return v;const e=c,o={data:e.data,ui:F(e,t)},r="node"===e.selection?.kind?s(e.data,t,e.selection.id)?.node??null:null;return v={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:O,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:p>0,hasFuture:p<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:F(e.core,t)}})),index:p,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==p&&z(e)}},getPermissions:M,getItemById:n=>s(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return d(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},b=e,v},subscribe:e=>(m.add(e),()=>{m.delete(e)}),dispatch:O,batch:x,select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){x(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:K(e.data,t,o)},E(n,e.data!==n.data)})},load(e,n={}){const o=c,r=y(e,t);c={...c,data:r,selection:K(r,t,n.selection??c.selection)},n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Q()}],p=0),c!==o&&C()},undo(){p>0&&z(p-1)},redo(){p<u.length-1&&z(p+1)},setPermissions(e){a=e,v=null,C()},setConfig(e){e!==t&&(t=e,v=null,C())}};return $}function Y(e,t){const n=e=>{if(e.altKey)return;e.metaKey!==e.ctrlKey&&("KeyZ"===e.code?(e.preventDefault(),e.shiftKey?t.redo():t.undo()):"KeyY"!==e.code||e.shiftKey||(e.preventDefault(),t.redo()))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}var J=C(null);function W({editor:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return D(()=>{n&&e.resolveAll()},[e,n]),D(()=>{if(t&&"undefined"!=typeof document)return Y(document,e)},[e,t]),/* @__PURE__ */$(J.Provider,{value:e,children:o})}function X(){const e=E(J);if(!e)throw new Error("useEditor: no <EditorProvider> above this component");return e}function _(e){const t=X(),n=O({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return x(t.subscribe,o,o)}function ee(){return function(e){return _(e)}}var te="data-puck-component",ne="data-puck-dropzone",oe={},re="data-es-mirror";function ie(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${re}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(re,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ae({children:t,id:n="preview-frame",title:o,className:r,style:s,mirrorStyles:l=!0,onDocument:d,height:c="auto",nonce:u}){const p=i("canvas",e),h=O(null),[f,m]=A(null);return z(()=>{const e=h.current,t=f?.ownerDocument.defaultView;if("auto"!==c||!e||!f||!t)return;const n=()=>{e.style.height=`${Math.ceil(f.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(f),()=>r?.disconnect()},[f,c]),z(()=>{let e=h.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=h.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),a(e,u),m(t),d?.(e);let n=null;const o=h.current?.ownerDocument;if(l&&o){ie(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ie(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),d?.(null)}},[]),/* @__PURE__ */$("iframe",{ref:h,id:n,title:o??p.frame,className:r,style:{border:0,width:"100%",display:"block",..."fill"===c?{height:"100%"}:null,...s},children:f?B(t,f):null})}var se=C(null),le=C(oe),de=[];function ce({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128}){const i=X(),a=_(n=>d(n.appState.data,i.config,{parentId:e,slot:t})??de),s=_(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==l),c=_(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=E(se),p=["es-zone"];return a.length&&p.push("has-children"),e===l&&p.push("is-root"),(s||c)&&p.push("is-area-selected"),null!==u&&u===e&&e!==l&&p.push("is-hovering-area"),n&&p.push(n),/* @__PURE__ */$("div",{className:p.join(" "),[ne]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`},children:a.map(e=>/* @__PURE__ */$(he,{node:e},e.props.id))})}function ue(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of w(I(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"../chunk-GGTPNGFJ.js";import{useResolvedFields as t}from"../chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r}from"../chunk-D2BCHTQR.js";import{useWords as i}from"../chunk-MFIRYGHW.js";import{setCanvasNonce as a}from"../chunk-ZNCEOSXO.js";import{find as s,ROOT_ID as l,getList as d,remove as c,parseZoneKey as u,move as p,duplicate as h,replaceNode as f,createNode as m,insert as v,normalizeData as y,createResolveCache as g,resolveNodeData as k,ROOT_SLOT as b}from"../chunk-KRXQM65X.js";import{topLevelSlotKeys as w,fieldsFrom as S,defaultsFrom as I}from"../chunk-NKB3KVAB.js";import{createContext as C,useEffect as x,useContext as O,useRef as D,useSyncExternalStore as E,useState as A,useLayoutEffect as z,useMemo as M,useCallback as Z}from"react";import{jsx as $,jsxs as R}from"react/jsx-runtime";import{createPortal as N}from"react-dom";function B(e){return!["setData","setUi","set"].includes(e.type)}var P=(e,t,n,o)=>{const r=d(e,t,u(n));return r?.[o]??null},j=(e,t,n,o,r)=>{const i=P(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function K(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function L(e,t,n){return n?"node"===n.kind?s(e,t,n.id)?n:null:n.parentId===l?d(e,t,n)?n:null:s(e,t,n.parentId)&&d(e,t,n)?n:null:null}function F(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var d;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(d=a)?{kind:"slot",parentId:d.parentId,slot:d.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function H(e,t,n){const o=V(e,t,n);if(o===e)return e;const r=L(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function V(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return F(e,n,"function"==typeof t.ui?t.ui(K(e,n)):t.ui);case"set":{const r={data:o,ui:K(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=F(a,n,i.ui,!0)),a}case"insert":{const r={...u(t.destinationZone),index:t.destinationIndex},i=m(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:v(o,n,r,i)}}case"replace":{const r=j(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:f(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=j(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=h(o,n,r.props.id),a=P(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return V(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=P(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...u(t.destinationZone),index:t.destinationIndex};return{...e,data:p(o,n,r.props.id,i)}}case"remove":{const r=j(o,n,t.zone,t.index,"remove");return{...e,data:c(o,n,r.props.id)}}default:return e}}var T={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},q={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},G=0,Y=()=>`history-${G+=1}`;function U(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const l=y(e.data,t);let c={data:l,selection:null,ui:{...q}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:l,selection:r?{kind:"slot",...r}:o(l,t,n??null),ui:{...q,...i}}}let u=[{core:c,at:-1/0,sealed:!0,id:Y()}],p=0;const h=e=>{const t=u[p],n=r();!e&&p===u.length-1&&p>0&&!t.sealed&&n-t.at<i?u=[...u.slice(0,p),{...t,core:c,at:n}]:(u=[...u.slice(0,p+1),{core:c,at:n,sealed:e,id:Y()}],p=u.length-1)},m=/* @__PURE__ */new Set;let v=null,b=null,w=0,S=null,I=!1;const C=()=>{for(const e of[...m])e()},x=()=>{u=[...u.slice(0,p),{...u[p],core:c},...u.slice(p+1)]},O=(t,n)=>{w>0?I=I||n:(n?h(!1):c!==t&&x(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&C())},D=e=>{const n=c;if(c=H(c,e,t),c===n)return;const o=e.recordHistory??B(e);O(n,o&&c.data!==n.data)},E=t=>{0===w&&(S=c,I=!1),w+=1;try{t()}catch(e){throw w-=1,0===w&&S&&(c=S,S=null),e}if(w-=1,w>0||!S)return;const n=S;S=null,I&&c.data!==n.data?h(!0):c!==n&&x(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},A=e=>{const n=c,o=L(c.data,t,e);var r,i;(r=o,i=c.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(c={...c,selection:o},O(n,!1))},z=t=>{const n=c;p=t,c=u[p].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&C()},M=(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...T,...a,...n}},Z=g(),$={resolveCache:Z,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...l]=await Promise.all([k(r,t,{cache:Z,trigger:e,metadata:n}),...i.map(o=>k(o,t,{cache:Z,trigger:e,metadata:n}))]);E(()=>{const e=c;let n=c.data;l.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,l=s(n,t,a)?.node;l&&l===s(o,t,a)?.node&&(n=f(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==c.data&&(c={...c,data:n,selection:L(n,t,c.selection)},O(e,!1))})},get config(){return t},getState(){if(v&&b===c)return v;const e=c,o={data:e.data,ui:K(e,t)},r="node"===e.selection?.kind?s(e.data,t,e.selection.id)?.node??null:null;return v={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:p>0,hasFuture:p<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:K(e.core,t)}})),index:p,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==p&&z(e)}},getPermissions:M,getItemById:n=>s(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return d(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},b=e,v},subscribe:e=>(m.add(e),()=>{m.delete(e)}),dispatch:D,batch:E,select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){E(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:L(e.data,t,o)},O(n,e.data!==n.data)})},load(e,n={}){const o=c,r=y(e,t);c={...c,data:r,selection:L(r,t,n.selection??c.selection)},n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Y()}],p=0),c!==o&&C()},undo(){p>0&&z(p-1)},redo(){p<u.length-1&&z(p+1)},setPermissions(e){a=e,v=null,C()},setConfig(e){e!==t&&(t=e,v=null,C())}};return $}function W(e,t){const n=e=>{if(e.altKey)return;e.metaKey!==e.ctrlKey&&("KeyZ"===e.code?(e.preventDefault(),e.shiftKey?t.redo():t.undo()):"KeyY"!==e.code||e.shiftKey||(e.preventDefault(),t.redo()))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}var X=C(null);function Q({editor:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return x(()=>{n&&e.resolveAll()},[e,n]),x(()=>{if(t&&"undefined"!=typeof document)return W(document,e)},[e,t]),/* @__PURE__ */$(X.Provider,{value:e,children:o})}function J(){const e=O(X);if(!e)throw new Error("useEditor: no <EditorProvider> above this component");return e}function _(e){const t=J(),n=D({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return E(t.subscribe,o,o)}function ee(){return function(e){return _(e)}}var te="data-puck-component",ne="data-puck-dropzone",oe={},re="data-es-mirror";function ie(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${re}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(re,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ae({children:t,id:n="preview-frame",title:o,className:r,style:s,mirrorStyles:l=!0,onDocument:d,height:c="auto",nonce:u}){const p=i("canvas",e),h=D(null),[f,m]=A(null);return z(()=>{const e=h.current,t=f?.ownerDocument.defaultView;if("auto"!==c||!e||!f||!t)return;const n=()=>{e.style.height=`${Math.ceil(f.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(f),()=>r?.disconnect()},[f,c]),z(()=>{let e=h.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=h.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),a(e,u),m(t),d?.(e);let n=null;const o=h.current?.ownerDocument;if(l&&o){ie(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ie(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),d?.(null)}},[]),/* @__PURE__ */$("iframe",{ref:h,id:n,title:o??p.frame,className:r,style:{border:0,width:"100%",display:"block",..."fill"===c?{height:"100%"}:null,...s},children:f?N(t,f):null})}var se=C(null),le=C(oe),de=[];function ce({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128}){const i=J(),a=_(n=>d(n.appState.data,i.config,{parentId:e,slot:t})??de),s=_(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==l),c=_(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=O(se),p=["es-zone"];return a.length&&p.push("has-children"),e===l&&p.push("is-root"),(s||c)&&p.push("is-area-selected"),null!==u&&u===e&&e!==l&&p.push("is-hovering-area"),n&&p.push(n),/* @__PURE__ */$("div",{className:p.join(" "),[ne]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`},children:a.map(e=>/* @__PURE__ */$(he,{node:e},e.props.id))})}function ue(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of w(S(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
2
2
|
return $(ce,{parentId:n,slot:e,...t})};return i}function pe(e){return function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
-
return $(ce,{parentId:e,slot:t,...n})}}function he({node:e}){const t=
|
|
4
|
-
return $(le.Provider,{value:e??oe,children:i})}function me({id:e,kind:t,overlay:n}){const o=
|
|
3
|
+
return $(ce,{parentId:e,slot:t,...n})}}function he({node:e}){const t=J().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=D(null);return M(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(te),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(te,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),i=O(le);if(!n?.render)return null;const a=n.render,s=ue(t,e.type,o,{...I(n),...e.props}),l={renderDropZone:pe(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...i,...n.metadata}};return n.inline?/* @__PURE__ */$(a,{...s,puck:l,editMode:!0}):/* @__PURE__ */$("div",{[te]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */$(a,{...s,puck:l,editMode:!0})})}function fe({metadata:e}){const t=_(e=>e.config),n=_(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */$(ce,{parentId:l,slot:b}),i=o?/* @__PURE__ */$(o,{id:"puck-root",...ue(t,"root",l,n),puck:{renderDropZone:pe(l),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
|
|
4
|
+
return $(le.Provider,{value:e??oe,children:i})}function me({id:e,kind:t,overlay:n}){const o=D(null),[r,i]=A(null);z(()=>{const t=o.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!e)return void i(null);let r=0;const a=()=>{r=0;const a=function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(t.querySelector(`[${te}="${n.CSS?.escape?n.CSS.escape(e):e}"]`),o.current?.parentElement??null);i(e=>{return(t=e)===(n=a)||t&&n&&t.top===n.top&&t.left===n.left&&t.width===n.width&&t.height===n.height?e:a;var t,n})},s=()=>{r||(r=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const d="ResizeObserver"in n?new n.ResizeObserver(s):null;return d?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),d?.disconnect(),n.removeEventListener("resize",s),r&&(n.cancelAnimationFrame??n.clearTimeout)(r)}},[e]);const a=/* @__PURE__ */$("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */$(n,{componentId:e,kind:t,children:a}):a}function ve({frame:e=!0,className:t,style:n,metadata:o,mirrorStyles:r,onDocument:i,height:a,title:s,nonce:l,frameWrapper:d,overlay:c,children:u}){const p=J(),[h,f]=A(void 0),m=_(e=>"node"===e.selection?.kind?e.selection.id:null),[v,y]=A(null),g=/* @__PURE__ */R("div",{className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;t.closest?.("a[href]")&&e.preventDefault();const n=t.closest?.(`[${te}]`);n?p.select(n.getAttribute(te)):t.hasAttribute?.(ne)||p.select(null)},onMouseOver:e=>{const t=e.target.closest?.(`[${te}]`),n=t?.getAttribute(te)??null;n!==v&&y(n)},onMouseLeave:()=>y(null),children:[
|
|
5
5
|
/* @__PURE__ */$(se.Provider,{value:v,children:/* @__PURE__ */$(fe,{metadata:o})}),
|
|
6
|
-
/* @__PURE__ */
|
|
6
|
+
/* @__PURE__ */R("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
7
7
|
/* @__PURE__ */$(me,{id:v&&v!==m?v:null,kind:"hover",overlay:c}),
|
|
8
|
-
/* @__PURE__ */$(me,{id:m,kind:"selected",overlay:c})]}),u]}),k=d?/* @__PURE__ */$(d,{document:h,children:g}):g,b=
|
|
9
|
-
return $("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"",children:e?/* @__PURE__ */$(ae,{mirrorStyles:r,onDocument:e=>{b.current?.(),b.current=e?
|
|
8
|
+
/* @__PURE__ */$(me,{id:m,kind:"selected",overlay:c})]}),u]}),k=d?/* @__PURE__ */$(d,{document:h,children:g}):g,b=D(null);/* @__PURE__ */
|
|
9
|
+
return $("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"",children:e?/* @__PURE__ */$(ae,{mirrorStyles:r,onDocument:e=>{b.current?.(),b.current=e?W(e,p):null,f(e??void 0),i?.(e)},height:a,title:s,nonce:l,children:k}):/* @__PURE__ */$("div",{id:"preview-frame","data-puck-entry":"",children:k})})}function ye(e={}){const t=J(),n=_(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function ge(){const e=J(),n=_(e=>e.config),o=e.resolveCache,r=_(e=>e.selectedItem),i=_(e=>e.appState.data.root),a=r?r.props.id:"root",l=i.props??{},d=M(()=>r||{type:"root",props:l},[r,l]),c=r?n.components[r.type]:n.root,u=e.getState(),p=r?s(u.appState.data,n,a):null,h=p&&"root"!==p.place.parentId?p.place.parentId:null,f=h?u.getItemById(h)??null:null,{fields:m}=t({id:a,node:d,block:c,parent:f,appState:u.appState}),v=u.getPermissions(r?{item:r}:{root:!0}),y=Z((t,r)=>{(async()=>{const i=e.getState();if("root"!==a){const s=i.getItemById(a),l=i.getSelectorForId(a);if(!s||!l)return;const d={...s,props:{...s.props,[t]:r}},{node:c}=await k(d,n,{cache:o,trigger:"replace"}),u=e.getState().getSelectorForId(a);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const s=i.appState.data.root.props??{},{node:l}=await k({type:"root",props:{...s,[t]:r}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:l.props,readOnly:l.readOnly},recordHistory:!0})})()},[e,n,o,a]);return{id:a,node:d,fields:m,values:d.props,readOnly:!1===v.edit,onChange:y}}export{ae as CanvasFrame,q as DEFAULT_UI,fe as EditDocument,ve as EditorCanvas,Q as EditorProvider,W as bindUndoKeys,U as createEditor,ee as createUseEditor,B as recordsByDefault,H as reduce,K as uiView,_ as useEditor,J as useEditorApi,ye as useEditorNodeOps,ge as useSelectedFields,L as validSelection};
|
package/dist/fields/fields.css
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
width: 100%;
|
|
19
19
|
min-width: 0;
|
|
20
20
|
height: 32px;
|
|
21
|
-
padding: 0
|
|
21
|
+
padding: 0 12px;
|
|
22
22
|
border: 1px solid var(--es-input-border);
|
|
23
23
|
border-radius: var(--es-field-radius);
|
|
24
24
|
background: var(--es-field-bg);
|
|
@@ -41,22 +41,136 @@
|
|
|
41
41
|
.es-fin--area {
|
|
42
42
|
height: auto;
|
|
43
43
|
min-height: 64px;
|
|
44
|
-
padding: 8px
|
|
44
|
+
padding: 8px 12px;
|
|
45
45
|
resize: vertical;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/* ── a number: the
|
|
48
|
+
/* ── a number: the cell (plan step E4) ─────────────────────────────────────
|
|
49
|
+
icon · number · unit · two stacked arrows, in ONE box with react-os-shell's
|
|
50
|
+
Input look (32px tall, the shell's border and radius, 14px text). The ring
|
|
51
|
+
is on the whole cell while the number inside has focus, as the design draws
|
|
52
|
+
it: react-os-shell's blue-400 line and a 2px ring at 30%.
|
|
53
|
+
|
|
54
|
+
SPACING IS THE SCALE ONLY (2 / 4 / 8 / 12 / 16 / 32), read from the
|
|
55
|
+
`--es-space-*` tokens. The fallback after each is the same step, for a host
|
|
56
|
+
whose sheet is older than the scale. */
|
|
49
57
|
|
|
50
58
|
.es-fnum {
|
|
59
|
+
box-sizing: border-box;
|
|
51
60
|
display: flex;
|
|
52
|
-
align-items:
|
|
53
|
-
gap:
|
|
61
|
+
align-items: stretch;
|
|
62
|
+
gap: var(--es-space-4, 4px);
|
|
54
63
|
width: 100%;
|
|
55
64
|
min-width: 0;
|
|
65
|
+
height: 32px;
|
|
66
|
+
padding-inline: var(--es-space-8, 8px);
|
|
67
|
+
border: 1px solid var(--es-input-border);
|
|
68
|
+
border-radius: var(--es-field-radius);
|
|
69
|
+
background: var(--es-field-bg);
|
|
70
|
+
color: var(--es-field-text);
|
|
71
|
+
}
|
|
72
|
+
.es-fnum--arrows { padding-inline-end: 0; }
|
|
73
|
+
.es-fnum:hover:not(.is-readonly):not(:focus-within) { border-color: var(--es-muted); }
|
|
74
|
+
.es-fnum:focus-within {
|
|
75
|
+
border-color: var(--es-focus-line, #60a5fa);
|
|
76
|
+
box-shadow: 0 0 0 2px var(--es-focus-ring, rgba(96, 165, 250, 0.3));
|
|
77
|
+
}
|
|
78
|
+
.es-fnum.is-readonly { background: var(--es-track-bg); color: var(--es-muted); }
|
|
79
|
+
|
|
80
|
+
.es-fnum-icon { display: flex; align-items: center; flex: none; color: var(--es-field-placeholder); }
|
|
81
|
+
.es-fnum-icon svg { width: 14px; height: 14px; }
|
|
82
|
+
|
|
83
|
+
.es-fnum-box {
|
|
84
|
+
flex: 1 1 auto;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
width: 100%;
|
|
87
|
+
padding: 0;
|
|
88
|
+
border: 0;
|
|
89
|
+
outline: none;
|
|
90
|
+
background: none;
|
|
91
|
+
color: inherit;
|
|
92
|
+
font: inherit;
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
font-variant-numeric: tabular-nums;
|
|
95
|
+
}
|
|
96
|
+
.es-fnum-box::placeholder { color: var(--es-field-placeholder); opacity: 1; }
|
|
97
|
+
/* A grey number follows the style: what shows is the style's, not the cell's. */
|
|
98
|
+
.es-fnum.is-style .es-fnum-box { color: var(--es-field-placeholder); }
|
|
99
|
+
|
|
100
|
+
.es-fnum-unit { align-self: center; flex: none; font-size: 12px; color: var(--es-muted); white-space: nowrap; }
|
|
101
|
+
|
|
102
|
+
.es-fnum-arrows {
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
flex: none;
|
|
106
|
+
width: 18px;
|
|
107
|
+
border-left: 1px solid var(--es-line);
|
|
108
|
+
}
|
|
109
|
+
.es-fnum-arrow {
|
|
110
|
+
flex: 1 1 0;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
min-height: 0;
|
|
115
|
+
padding: 0;
|
|
116
|
+
border: 0;
|
|
117
|
+
background: none;
|
|
118
|
+
color: var(--es-icon);
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
touch-action: none;
|
|
121
|
+
}
|
|
122
|
+
.es-fnum-arrow--up {
|
|
123
|
+
border-bottom: 1px solid var(--es-line);
|
|
124
|
+
border-top-right-radius: calc(var(--es-field-radius) - 1px);
|
|
125
|
+
}
|
|
126
|
+
.es-fnum-arrow--down { border-bottom-right-radius: calc(var(--es-field-radius) - 1px); }
|
|
127
|
+
.es-fnum-arrow:hover:not(:disabled) { background: var(--es-hover); color: var(--es-text); }
|
|
128
|
+
.es-fnum-arrow:disabled { color: var(--es-disabled); cursor: default; }
|
|
129
|
+
.es-fnum-arrow svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
130
|
+
|
|
131
|
+
/* ── a slider row (Site styles, Email styles; plan step E4) ────────────────
|
|
132
|
+
The name left and the value right on one line, the slider under them. The
|
|
133
|
+
value is a quiet box until it is hovered or has focus. */
|
|
134
|
+
|
|
135
|
+
.es-fslider { display: flex; flex-direction: column; gap: var(--es-space-4, 4px); min-width: 0; }
|
|
136
|
+
.es-fslider-top {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: baseline;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
gap: var(--es-space-8, 8px);
|
|
141
|
+
min-width: 0;
|
|
56
142
|
}
|
|
57
|
-
.es-
|
|
58
|
-
|
|
59
|
-
|
|
143
|
+
.es-fslider-name {
|
|
144
|
+
min-width: 0;
|
|
145
|
+
overflow: hidden;
|
|
146
|
+
text-overflow: ellipsis;
|
|
147
|
+
white-space: nowrap;
|
|
148
|
+
font-size: 12px;
|
|
149
|
+
font-weight: 500;
|
|
150
|
+
color: var(--es-text-secondary);
|
|
151
|
+
}
|
|
152
|
+
.es-fslider-read { display: inline-flex; align-items: baseline; gap: var(--es-space-2, 2px); flex: none; }
|
|
153
|
+
.es-fslider-value {
|
|
154
|
+
box-sizing: content-box;
|
|
155
|
+
width: 5ch;
|
|
156
|
+
padding: var(--es-space-2, 2px) var(--es-space-4, 4px);
|
|
157
|
+
border: 0;
|
|
158
|
+
border-radius: 4px;
|
|
159
|
+
outline: none;
|
|
160
|
+
background: none;
|
|
161
|
+
color: var(--es-field-text);
|
|
162
|
+
font: inherit;
|
|
163
|
+
font-size: 12.5px;
|
|
164
|
+
font-variant-numeric: tabular-nums;
|
|
165
|
+
text-align: right;
|
|
166
|
+
cursor: text;
|
|
167
|
+
}
|
|
168
|
+
.es-fslider-value:hover { background: var(--es-hover); }
|
|
169
|
+
.es-fslider-value:focus { background: var(--es-field-bg); box-shadow: inset 0 0 0 1px var(--es-focus-line, #60a5fa); }
|
|
170
|
+
.es-fslider-value::placeholder { color: var(--es-field-placeholder); opacity: 1; }
|
|
171
|
+
.es-fslider.is-style .es-fslider-value { color: var(--es-field-placeholder); }
|
|
172
|
+
.es-fslider-unit { font-size: 12px; color: var(--es-field-placeholder); }
|
|
173
|
+
.es-fslider-range { width: 100%; height: 18px; margin: 0; accent-color: var(--es-accent); }
|
|
60
174
|
|
|
61
175
|
.es-fbtn {
|
|
62
176
|
height: 28px;
|
|
@@ -116,7 +230,7 @@
|
|
|
116
230
|
}
|
|
117
231
|
.es-fsel-list:focus { outline: none; }
|
|
118
232
|
.es-fsel-option {
|
|
119
|
-
padding:
|
|
233
|
+
padding: 8px;
|
|
120
234
|
border-radius: var(--es-field-radius);
|
|
121
235
|
font-size: 12px;
|
|
122
236
|
color: var(--es-text);
|
|
@@ -155,7 +269,7 @@
|
|
|
155
269
|
justify-content: space-between;
|
|
156
270
|
gap: 8px;
|
|
157
271
|
}
|
|
158
|
-
.es-list-label { display: inline-flex; align-items: center; gap:
|
|
272
|
+
.es-list-label { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--es-text); }
|
|
159
273
|
.es-list-count { font-size: 11px; color: var(--es-muted); }
|
|
160
274
|
/* The rows are Layers' rows (tree.css); the list lets them reach the panel's
|
|
161
275
|
edges the way Layers' do, so a row's hover reads as the same row. */
|
|
@@ -181,9 +295,9 @@
|
|
|
181
295
|
align-self: flex-start;
|
|
182
296
|
display: inline-flex;
|
|
183
297
|
align-items: center;
|
|
184
|
-
gap:
|
|
298
|
+
gap: 8px;
|
|
185
299
|
height: 28px;
|
|
186
|
-
padding: 0 8px
|
|
300
|
+
padding: 0 8px;
|
|
187
301
|
border: 0;
|
|
188
302
|
border-radius: var(--es-field-radius);
|
|
189
303
|
background: var(--es-hover);
|
package/dist/fields/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { S as SettingsBucket } from '../buckets-
|
|
4
|
-
import { I as InspectorFields, a as InspectorFieldDef, F as FieldRenderer, b as FieldTextProps, c as FieldNumberProps, d as
|
|
5
|
-
export { A as ArrayFieldDef, C as CustomFieldDef,
|
|
6
|
-
import { R as ResolvableItem } from '../resolve-
|
|
2
|
+
import { ReactNode, KeyboardEvent } from 'react';
|
|
3
|
+
import { S as SettingsBucket } from '../buckets-CuLM47h9.js';
|
|
4
|
+
import { I as InspectorFields, a as InspectorFieldDef, F as FieldRenderer, b as FieldTextProps, c as FieldNumberProps, d as FieldSliderProps, e as FieldSelectProps, f as FieldOption } from '../types-C7HFvdtk.js';
|
|
5
|
+
export { A as ArrayFieldDef, C as CustomFieldDef, g as CustomFieldRenderProps, N as NumberFieldDef, O as ObjectFieldDef, R as RadioFieldDef, S as SelectFieldDef, h as SlotFieldDef, T as TextFieldDef, i as TextareaFieldDef } from '../types-C7HFvdtk.js';
|
|
6
|
+
import { R as ResolvableItem } from '../resolve-D68pb3Bx.js';
|
|
7
7
|
export { F as FieldsWords } from '../words-CD3WADyb.js';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-41704JE4.js';
|
|
9
9
|
|
|
10
10
|
interface InspectorProps {
|
|
11
11
|
/** The selected node's fields, already resolved by the host. */
|
|
@@ -243,17 +243,65 @@ declare function FieldText({ id, value, onChange, placeholder, multiline, rows,
|
|
|
243
243
|
declare function clampNumber(n: number, min?: number, max?: number): number;
|
|
244
244
|
/** What a typed string means as a number: null for nothing or not-a-number. */
|
|
245
245
|
declare function parseTyped(text: string): number | null;
|
|
246
|
+
interface NumberEntryOptions {
|
|
247
|
+
value: number | undefined;
|
|
248
|
+
onChange: (value: number | undefined) => void;
|
|
249
|
+
min?: number;
|
|
250
|
+
max?: number;
|
|
251
|
+
step?: number;
|
|
252
|
+
shiftStep?: number;
|
|
253
|
+
styleValue?: number;
|
|
254
|
+
readOnly?: boolean;
|
|
255
|
+
}
|
|
246
256
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
257
|
+
* What a typed number box does, shared by the number cell and the slider
|
|
258
|
+
* row's value, so the two cannot drift.
|
|
249
259
|
*
|
|
250
260
|
* It keeps the TYPED TEXT while you type, so "1." and "-" are allowed on the way
|
|
251
261
|
* to a number, and writes only when the text is a number. It writes as you type
|
|
252
|
-
* (the canvas follows)
|
|
253
|
-
*
|
|
254
|
-
* `
|
|
262
|
+
* (the canvas follows). Enter or leaving the box clamps to `min` / `max`; Esc
|
|
263
|
+
* puts back the value the box had when you came in. ↑↓ move by `step`, Shift
|
|
264
|
+
* by `shiftStep` (ten steps unless the host says). An empty box writes
|
|
265
|
+
* `undefined`: the setting goes back to the style, whose number `styleValue`
|
|
266
|
+
* then shows, grey, and is where a step starts from.
|
|
267
|
+
*/
|
|
268
|
+
declare function useNumberEntry({ value, onChange, min, max, step, shiftStep, styleValue, readOnly }: NumberEntryOptions): {
|
|
269
|
+
inputProps: {
|
|
270
|
+
value: string;
|
|
271
|
+
readOnly: boolean;
|
|
272
|
+
placeholder: string | undefined;
|
|
273
|
+
onFocus: () => void;
|
|
274
|
+
onChange: (e: {
|
|
275
|
+
target: {
|
|
276
|
+
value: string;
|
|
277
|
+
};
|
|
278
|
+
}) => void;
|
|
279
|
+
onBlur: () => void;
|
|
280
|
+
onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
281
|
+
};
|
|
282
|
+
nudge: (dir: 1 | -1, big?: boolean) => void;
|
|
283
|
+
set: (n: number | undefined) => void;
|
|
284
|
+
/** Nothing of its own: the style's number shows, grey. */
|
|
285
|
+
isStyle: boolean;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* A number value (blueprint step 4.1; the cell, plan step E4): one box holding
|
|
289
|
+
* an optional icon, the number, an optional unit and, with `steppers`, two
|
|
290
|
+
* small stacked arrows. What the typing, the keys and the arrows do is
|
|
291
|
+
* {@link useNumberEntry}'s.
|
|
292
|
+
*/
|
|
293
|
+
declare function FieldNumber({ id, value, onChange, min, max, step, shiftStep, styleValue, icon, unit, steppers, placeholder, readOnly, ariaLabel, ariaLabelledBy, }: FieldNumberProps): react.JSX.Element;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A slider row (plan step E4), for Site styles and Email styles: the name on
|
|
297
|
+
* the left and the value on the right on one line, the slider under them.
|
|
298
|
+
*
|
|
299
|
+
* The value is typed and takes ↑↓ (Shift = ten steps), exactly as the number
|
|
300
|
+
* cell does — it is the same {@link useNumberEntry} — and may go past the
|
|
301
|
+
* slider's own travel (`sliderMin` / `sliderMax`); only `min` / `max` hold it.
|
|
302
|
+
* The slider then rests at its end. A grey value follows the style.
|
|
255
303
|
*/
|
|
256
|
-
declare function
|
|
304
|
+
declare function FieldSlider({ id, label, value, onChange, min, max, step, shiftStep, styleValue, unit, sliderMin, sliderMax, readOnly, }: FieldSliderProps): react.JSX.Element;
|
|
257
305
|
|
|
258
306
|
/** The option a stored value names: equal by `Object.is`, so `0`, `false` and `''` are values too. */
|
|
259
307
|
declare function optionFor<V>(options: readonly FieldOption<V>[], value: V | undefined): FieldOption<V> | undefined;
|
|
@@ -270,4 +318,4 @@ declare function optionFor<V>(options: readonly FieldOption<V>[], value: V | und
|
|
|
270
318
|
*/
|
|
271
319
|
declare function FieldSelect<V>({ id, value, options, onChange, placeholder, readOnly, ariaLabel, ariaLabelledBy, }: FieldSelectProps<V>): react.JSX.Element;
|
|
272
320
|
|
|
273
|
-
export { FieldNumber, FieldNumberProps, FieldOption, type FieldPlan, FieldRenderer, FieldSelect, FieldSelectProps, FieldText, FieldTextProps, type FieldsBlock, Inspector, InspectorField, InspectorFieldDef, type InspectorFieldProps, InspectorFields, type InspectorProps, ListField, type ListFieldProps, type PlannedRow, type ResolvedFieldsInput, SettingsBucket, bucketsOf, clampNumber, copyItem, insertAt, labelOf, moveTo, optionFor, parseTyped, planFields, removeAt, useResolvedFields };
|
|
321
|
+
export { FieldNumber, FieldNumberProps, FieldOption, type FieldPlan, FieldRenderer, FieldSelect, FieldSelectProps, FieldSlider, FieldSliderProps, FieldText, FieldTextProps, type FieldsBlock, Inspector, InspectorField, InspectorFieldDef, type InspectorFieldProps, InspectorFields, type InspectorProps, ListField, type ListFieldProps, type NumberEntryOptions, type PlannedRow, type ResolvedFieldsInput, SettingsBucket, bucketsOf, clampNumber, copyItem, insertAt, labelOf, moveTo, optionFor, parseTyped, planFields, removeAt, useNumberEntry, useResolvedFields };
|
package/dist/fields/index.js
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
import{LayersTree as e,TreeSeam as n,TreeRow as t,TreeRowAction as
|
|
2
|
-
return
|
|
3
|
-
|
|
4
|
-
/* @__PURE__ */k("
|
|
5
|
-
/* @__PURE__ */k(
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */k("span",{className:
|
|
1
|
+
import{LayersTree as e,TreeSeam as n,TreeRow as t,TreeRowAction as r}from"../chunk-66CKSTXP.js";import{SettingsField as l,SETTINGS_BUCKETS as a,SettingsTabs as i,SettingsGroup as s}from"../chunk-67VZRQLG.js";import{DEFAULT_FIELDS_WORDS as o}from"../chunk-SUO5627P.js";import{DEFAULT_TREE_WORDS as c}from"../chunk-H4B72XCJ.js";import{DEFAULT_PANEL_WORDS as d}from"../chunk-7A7O2JWQ.js";export{useResolvedFields}from"../chunk-YRLPFZW3.js";import{SettingsSegmented as u}from"../chunk-QB3BZIRA.js";import{useWords as m}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{useTreeDrag as p,gapToMoveIndex as h}from"../chunk-6PS6STGA.js";import"../chunk-PI26YXYD.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";import{useState as f,useRef as b,useEffect as v,useId as y}from"react";import{jsxs as g,jsx as k,Fragment as x}from"react/jsx-runtime";function w(e,n,t){let r=e;return"number"==typeof n&&r<n&&(r=n),"number"==typeof t&&r>t&&(r=t),r}function N(e){const n=e.trim().replace(",",".");if(""===n||"-"===n||"."===n||"-."===n)return null;const t=Number(n);return Number.isFinite(t)?t:null}function C(e){const n=String(e),t=n.indexOf(".");return t<0?0:n.length-t-1}function O({value:e,onChange:n,min:t,max:r,step:l=1,shiftStep:a,styleValue:i,readOnly:s=!1}){const o="number"==typeof e&&Number.isFinite(e)?e:void 0,c=void 0===o?"":String(o),[d,u]=f(c),m=b(o),p=b(o);v(()=>{m.current=o,u(e=>N(e)===(o??null)?e:c)},[o,c]);const h=e=>{s||(m.current=e,n(e))},y=e=>{s||(u(void 0===e?"":String(e)),e!==m.current&&h(e))},g=(e,n=!1)=>{if(s)return;const o=w(function(e,n){const t=Math.max(C(e),C(n));return Number((e+n).toFixed(t))}(m.current??i??t??0,e*(n?a??10*l:l)),t,r);u(String(o)),h(o)},k=()=>{const e=N(d);null!==e?y(w(e,t,r)):u(void 0===m.current?"":String(m.current))};return{inputProps:{value:d,readOnly:s,placeholder:void 0===i?void 0:String(i),onFocus:()=>{p.current=m.current},onChange:e=>{const n=e.target.value;if(u(n),""===n.trim())h(void 0);else{const e=N(n);null!==e&&h(e)}},onBlur:k,onKeyDown:e=>{"ArrowUp"===e.key||"ArrowDown"===e.key?(e.preventDefault(),g("ArrowUp"===e.key?1:-1,e.shiftKey)):"Enter"===e.key?(e.preventDefault(),k(),p.current=m.current):"Escape"===e.key&&(e.preventDefault(),y(p.current))}},nudge:g,set:y,isStyle:void 0!==i&&""===d.trim()}}function S({dir:e,label:n,disabled:t,nudge:r}){const l=b(null),a=b(r);a.current=r;const i=b({}),s=()=>{const e=i.current;void 0!==e.wait&&clearTimeout(e.wait),void 0!==e.every&&clearInterval(e.every),e.off?.(),i.current={}};v(()=>{const e=l.current;return e?.addEventListener("pointerleave",s),e?.addEventListener("pointercancel",s),()=>{e?.removeEventListener("pointerleave",s),e?.removeEventListener("pointercancel",s),s()}},[]);/* @__PURE__ */
|
|
2
|
+
return k("button",{ref:l,type:"button",tabIndex:-1,className:"es-fnum-arrow es-fnum-arrow--"+(e>0?"up":"down"),"aria-label":n,disabled:t,onPointerDown:n=>{if(0!==n.button||t)return;n.preventDefault(),s();const r=n.shiftKey;a.current(e,r);const l=n.currentTarget.ownerDocument;l.addEventListener("pointerup",s),i.current={off:()=>l.removeEventListener("pointerup",s),wait:setTimeout(()=>{i.current.every=setInterval(()=>a.current(e,r),60)},350)}},onClick:n=>{0===n.detail&&a.current(e,n.shiftKey)},children:/* @__PURE__ */k("svg",{viewBox:"0 0 10 10","aria-hidden":"true",focusable:"false",children:/* @__PURE__ */k("path",{d:e>0?"M2.5 6.25 5 3.75l2.5 2.5":"M2.5 3.75 5 6.25l2.5-2.5"})})})}function $({id:e,value:n,onChange:t,min:r,max:l,step:a=1,shiftStep:i,styleValue:s,icon:c,unit:d,steppers:u=!1,placeholder:p,readOnly:h=!1,ariaLabel:f,ariaLabelledBy:b}){const v=m("fields",o),{inputProps:y,nudge:x,isStyle:w}=O({value:n,onChange:t,min:r,max:l,step:a,shiftStep:i,styleValue:s,readOnly:h});/* @__PURE__ */
|
|
3
|
+
return g("div",{className:`es-fnum${u?" es-fnum--arrows":""}${w?" is-style":""}${h?" is-readonly":""}`,children:[c?/* @__PURE__ */k("span",{className:"es-fnum-icon","aria-hidden":"true",children:c}):null,
|
|
4
|
+
/* @__PURE__ */k("input",{id:e,type:"text",inputMode:"decimal",className:"es-fnum-box","aria-label":f,"aria-labelledby":b,...y,placeholder:y.placeholder??p}),d?/* @__PURE__ */k("span",{className:"es-fnum-unit",children:d}):null,u?/* @__PURE__ */g("span",{className:"es-fnum-arrows",children:[
|
|
5
|
+
/* @__PURE__ */k(S,{dir:1,label:v.more,disabled:h,nudge:x}),
|
|
6
|
+
/* @__PURE__ */k(S,{dir:-1,label:v.less,disabled:h,nudge:x})]}):null]})}function I(e,n){return e.find(e=>Object.is(e.value,n))}function L({id:e,value:n,options:t,onChange:r,placeholder:l,readOnly:a=!1,ariaLabel:i,ariaLabelledBy:s}){const c=m("fields",o),d=y(),[u,p]=f(!1),[h,x]=f(0),w=b(null),N=b(null),C=b(null),O=I(t,n),S=O?t.indexOf(O):-1,$=()=>{a||0===t.length||(x(S>=0?S:0),p(!0))},L=e=>{p(!1),e&&N.current?.focus()},j=e=>{const l=t[e];l&&!l.disabled&&(Object.is(l.value,n)||r(l.value),L(!0))};v(()=>{if(!u)return;C.current?.focus();const e=w.current?.ownerDocument;if(!e)return;const n=e=>{w.current&&!w.current.contains(e.target)&&p(!1)};return e.addEventListener("click",n,!0),()=>e.removeEventListener("click",n,!0)},[u]);const D=e=>{const n=t.length;if(0===n)return;let r=(e%n+n)%n;for(let l=0;l<n&&t[r]?.disabled;l++)r=(r+(e>=h?1:-1)+n)%n;x(r)};/* @__PURE__ */
|
|
7
|
+
return g("div",{className:"es-fsel",ref:w,children:[
|
|
8
|
+
/* @__PURE__ */g("button",{ref:N,id:e,type:"button",className:"es-fin es-fsel-button","aria-haspopup":"listbox","aria-expanded":u,"aria-controls":u?d:void 0,"aria-label":i,"aria-labelledby":s,disabled:a,onClick:()=>u?L(!1):$(),onKeyDown:e=>{"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),$())},children:[
|
|
9
|
+
/* @__PURE__ */k("span",{className:O?"es-fsel-value":"es-fsel-value is-empty",children:O?O.label:l??c.choose}),
|
|
10
|
+
/* @__PURE__ */k("span",{className:"es-fsel-chev","aria-hidden":"true"})]}),u?/* @__PURE__ */k("ul",{ref:C,id:d,role:"listbox",tabIndex:-1,className:"es-fsel-list","aria-activedescendant":`${d}-${h}`,"aria-labelledby":s,"aria-label":s?void 0:i,onKeyDown:e=>{switch(e.key){case"ArrowDown":return e.preventDefault(),void D(h+1);case"ArrowUp":return e.preventDefault(),void D(h-1);case"Home":return e.preventDefault(),void D(0);case"End":return e.preventDefault(),void D(t.length-1);case"Enter":case" ":return e.preventDefault(),void j(h);case"Escape":return e.preventDefault(),e.stopPropagation(),void L(!0);case"Tab":return void L(!1);default:if(1===e.key.length&&/\S/.test(e.key)){const n=e.key.toLowerCase(),r=t.length;for(let e=1;e<=r;e++){const l=(h+e)%r;if(!t[l]?.disabled&&t[l]?.label.toLowerCase().startsWith(n))return void x(l)}}}},children:t.map((e,n)=>/* @__PURE__ */k("li",{id:`${d}-${n}`,role:"option","aria-selected":n===S,"aria-disabled":e.disabled||void 0,className:`es-fsel-option${n===h?" is-active":""}${n===S?" is-chosen":""}`,onMouseEnter:()=>x(n),onClick:()=>j(n),children:e.label},`${n}-${String(e.value)}`))}):null]})}function j({id:e,value:n,onChange:t,placeholder:r,multiline:l=!1,rows:a=3,readOnly:i=!1,ariaLabel:s,ariaLabelledBy:o}){const c=n??"";return l?/* @__PURE__ */k("textarea",{id:e,className:"es-fin es-fin--area",value:c,rows:a,placeholder:r,readOnly:i,"aria-label":s,"aria-labelledby":o,onChange:e=>t(e.target.value)}):/* @__PURE__ */k("input",{id:e,type:"text",className:"es-fin",value:c,placeholder:r,readOnly:i,"aria-label":s,"aria-labelledby":o,onChange:e=>t(e.target.value)})}function D(e,n,t){const r=e.slice();return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function M(e,n,t){const r=e.slice(),[l]=r.splice(n,1);return r.splice(Math.max(0,Math.min(t,r.length)),0,l),r}function P(e,n){return e.filter((e,t)=>t!==n)}function A(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}function B(){/* @__PURE__ */
|
|
10
11
|
return g("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[
|
|
11
12
|
/* @__PURE__ */k("circle",{cx:"9",cy:"6",r:"1.6"}),
|
|
12
13
|
/* @__PURE__ */k("circle",{cx:"15",cy:"6",r:"1.6"}),
|
|
13
14
|
/* @__PURE__ */k("circle",{cx:"9",cy:"12",r:"1.6"}),
|
|
14
15
|
/* @__PURE__ */k("circle",{cx:"15",cy:"12",r:"1.6"}),
|
|
15
16
|
/* @__PURE__ */k("circle",{cx:"9",cy:"18",r:"1.6"}),
|
|
16
|
-
/* @__PURE__ */k("circle",{cx:"15",cy:"18",r:"1.6"})]})}var
|
|
17
|
+
/* @__PURE__ */k("circle",{cx:"15",cy:"18",r:"1.6"})]})}var E={parentId:"list",slot:"items"};function F({label:l,icon:a,noun:i,items:s,onChange:d,newItem:u,summary:f,itemName:b,thumb:v,min:y=0,max:w,readOnly:N=!1,open:C,onOpen:O,renderItem:S}){const $=m("fields",o).list,I=m("tree",c),L=i??$.item,j=!N&&("number"!=typeof w||s.length<w),F=!N&&s.length>y,K=(e,n)=>b?b(e,n):$.itemName({noun:L,n:n+1}),V=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===E.parentId&&n.slot===E.slot,onDrop:(e,n)=>{const t=h({...E,index:e},n);t!==e&&d(M(s,e,t))},onStep:(e,n)=>d(M(s,e,e+n)),canStep:(e,n)=>e+n>=0&&e+n<s.length,readOnly:N}),T=e=>{j&&d(D(s,e,u()))},R=e=>{j&&d(D(s,e+1,A(s[e])))},W=e=>{F&&(d(P(s,e)),null!==C&&O(null))};if(null!==C&&C>=0&&C<s.length){const e=s[C];/* @__PURE__ */
|
|
17
18
|
return g("div",{className:"es-list is-open",children:[
|
|
18
|
-
/* @__PURE__ */g("button",{type:"button",className:"es-list-back",onClick:()=>
|
|
19
|
-
/* @__PURE__ */k("span",{className:"es-list-back-chev","aria-hidden":"true"}),
|
|
19
|
+
/* @__PURE__ */g("button",{type:"button",className:"es-list-back",onClick:()=>O(null),children:[
|
|
20
|
+
/* @__PURE__ */k("span",{className:"es-list-back-chev","aria-hidden":"true"}),l]}),
|
|
20
21
|
/* @__PURE__ */g("div",{className:"es-list-title",children:[
|
|
21
|
-
/* @__PURE__ */k("span",{className:"es-list-name",children:
|
|
22
|
-
/* @__PURE__ */k("span",{className:"es-list-count",children:$.position({n:
|
|
23
|
-
/* @__PURE__ */k("div",{className:"es-list-item",children:
|
|
24
|
-
/* @__PURE__ */k("button",{type:"button",className:"es-fbtn",disabled:!
|
|
25
|
-
/* @__PURE__ */k("button",{type:"button",className:"es-fbtn es-fbtn--danger",disabled:!
|
|
22
|
+
/* @__PURE__ */k("span",{className:"es-list-name",children:K(e,C)}),
|
|
23
|
+
/* @__PURE__ */k("span",{className:"es-list-count",children:$.position({n:C+1,total:s.length})})]}),
|
|
24
|
+
/* @__PURE__ */k("div",{className:"es-list-item",children:S(e,C,e=>{const n=s.slice();n[C]=e,d(n)})}),N?null:/* @__PURE__ */g("div",{className:"es-list-item-actions",children:[
|
|
25
|
+
/* @__PURE__ */k("button",{type:"button",className:"es-fbtn",disabled:!j,onClick:()=>R(C),children:$.duplicate}),
|
|
26
|
+
/* @__PURE__ */k("button",{type:"button",className:"es-fbtn es-fbtn--danger",disabled:!F,onClick:()=>W(C),children:$.deleteItem({noun:L})})]})]})}/* @__PURE__ */
|
|
26
27
|
return g("div",{className:"es-list",children:[
|
|
27
28
|
/* @__PURE__ */g("div",{className:"es-list-head",children:[
|
|
28
|
-
/* @__PURE__ */g("span",{className:"es-list-label",children:[
|
|
29
|
-
/* @__PURE__ */k("span",{className:"es-list-count",children:s.length})]}),s.length?/* @__PURE__ */g(e,{className:"es-list-tree",rootProps:
|
|
30
|
-
return g("div",{className:"es-list-entry",children:[
|
|
31
|
-
/* @__PURE__ */k(t,{icon:v?v(e,
|
|
32
|
-
/* @__PURE__ */k(
|
|
29
|
+
/* @__PURE__ */g("span",{className:"es-list-label",children:[a?/* @__PURE__ */k("span",{className:"es-field-icon","aria-hidden":"true",children:a}):null,l]}),
|
|
30
|
+
/* @__PURE__ */k("span",{className:"es-list-count",children:s.length})]}),s.length?/* @__PURE__ */g(e,{className:"es-list-tree",rootProps:V.rootProps(),children:[s.map((e,l)=>{const a={...E,index:l},i=V.row({item:l,place:a});/* @__PURE__ */
|
|
31
|
+
return g("div",{className:"es-list-entry",children:[l>0?/* @__PURE__ */k(n,{...V.seam({place:a}),onAdd:j?()=>T(l):void 0,label:$.addHere({noun:L})}):null,
|
|
32
|
+
/* @__PURE__ */k(t,{icon:v?v(e,l):/* @__PURE__ */k(B,{}),name:K(e,l),preview:f?f(e,l):void 0,draggable:i.draggable,dragging:i.dragging,drop:i.drop,rowProps:i.rowProps,words:I,onSelect:()=>O(l),actions:N?void 0:/* @__PURE__ */g(x,{children:[
|
|
33
|
+
/* @__PURE__ */k(r,{kind:"plain",label:$.duplicateItem({noun:L}),disabled:!j,onClick:()=>R(l),children:/* @__PURE__ */g("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[
|
|
33
34
|
/* @__PURE__ */k("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),
|
|
34
35
|
/* @__PURE__ */k("path",{d:"M5 15V6a2 2 0 0 1 2-2h9"})]})}),
|
|
35
|
-
/* @__PURE__ */k(
|
|
36
|
-
/* @__PURE__ */k(n,{...
|
|
37
|
-
return k(s,{id:`${t}-group`,title:
|
|
38
|
-
return k(F,{label:
|
|
39
|
-
return k(
|
|
40
|
-
return k(
|
|
41
|
-
return k(
|
|
42
|
-
return k(
|
|
43
|
-
return k(
|
|
44
|
-
return k(
|
|
45
|
-
return g("div",{className:"es-insp",children:[
|
|
46
|
-
/* @__PURE__ */g("div",{className:"es-insp-rows",id:M,role:
|
|
36
|
+
/* @__PURE__ */k(r,{kind:"delete",label:$.deleteItem({noun:L}),disabled:!F,onClick:()=>W(l),children:/* @__PURE__ */k("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:/* @__PURE__ */k("path",{d:"M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3"})})})]})})]},l)}),
|
|
37
|
+
/* @__PURE__ */k(n,{...V.seam({place:{...E,index:s.length}})})]}):null,N?null:/* @__PURE__ */k("button",{type:"button",className:"es-list-add",disabled:!j,onClick:()=>T(s.length),children:$.add({noun:L})})]})}var K=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function V({field:e,name:n,id:t,value:r,onChange:l,readOnly:a,context:i,renderers:o}){const[c,d]=f(!0),u=r&&"object"==typeof r?r:{};/* @__PURE__ */
|
|
38
|
+
return k(s,{id:`${t}-group`,title:K(e,n),open:c,onToggle:d,children:Object.entries(e.objectFields).map(([e,r])=>/* @__PURE__ */k(R,{field:r,name:`${n}.${e}`,id:`${t}-${e}`,value:u[e],onChange:n=>l({...u,[e]:n}),readOnly:a,context:i,renderers:o},e))})}function T({field:e,name:n,id:t,value:r,onChange:l,readOnly:a,context:i,renderers:s,openItem:o,onOpenItem:c}){const[d,u]=f(null),m=c?o??null:d,p=c??u,h=Array.isArray(r)?r:[],b=e.getItemSummary;/* @__PURE__ */
|
|
39
|
+
return k(F,{label:K(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:h,onChange:l,newItem:()=>A({...e.defaultItemProps??{}}),summary:b?(e,n)=>b(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:m,onOpen:p,renderItem:(r,l,o)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */k(R,{field:c,name:`${n}[${l}].${e}`,id:`${t}-${l}-${e}`,value:r?.[e],onChange:n=>o({...r,[e]:n}),readOnly:a,context:i,renderers:s},e))})}function R(e){const{field:n,name:t,id:r,value:a,onChange:i,readOnly:s,context:o,renderers:c}=e;if(!n||n.marker||!1===n.visible)return null;const d=c?.[n.type];if(d)return d({field:n,name:t,id:r,value:a,onChange:i,readOnly:s});switch(n.type){case"custom":{const e={...o,field:n,name:t,id:r,value:a,onChange:i,readOnly:s};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
40
|
+
return k(l,{label:K(n,t),htmlFor:r,icon:n.icon,hint:n.hint,children:/* @__PURE__ */k(j,{id:r,value:"string"==typeof a?a:null==a?"":String(a),onChange:i,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:s})});case"number":/* @__PURE__ */
|
|
41
|
+
return k(l,{label:K(n,t),htmlFor:r,icon:n.icon,hint:n.hint,children:/* @__PURE__ */k($,{id:r,value:"number"==typeof a?a:void 0,onChange:i,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:s})});case"select":/* @__PURE__ */
|
|
42
|
+
return k(l,{label:K(n,t),htmlFor:r,icon:n.icon,hint:n.hint,children:/* @__PURE__ */k(L,{id:r,value:a,options:n.options,onChange:i,readOnly:s})});case"radio":/* @__PURE__ */
|
|
43
|
+
return k(l,{label:K(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */k(u,{ariaLabel:K(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||s})),onChange:e=>{s||i(e)}})});case"object":/* @__PURE__ */
|
|
44
|
+
return k(V,{...e,field:n});case"array":/* @__PURE__ */
|
|
45
|
+
return k(T,{...e,field:n});case"slot":return null}}var W=e=>a.includes(e);function X(e){let n=a[0];const t=[],r=/* @__PURE__ */new Set;for(const[l,a]of Object.entries(e))a&&(W(a.bucket)&&(n=a.bucket),a.marker||!1===a.visible||(t.push({name:l,field:a,bucket:n}),"slot"!==a.type&&r.add(n)));return{rows:t,buckets:a.filter(e=>r.has(e))}}function U(e){return new Map(X(e).rows.map(e=>[e.name,e.bucket]))}function H({fields:e,values:n,onChange:t,readOnly:r=!1,context:l,tab:a,onTab:s,tabs:o=!0,tabIcons:c,renderers:u,idPrefix:p,ariaLabel:h,children:b}){const v=m("panel",d),x=y(),w=p??`es-insp${x.replace(/:/g,"")}`,N=X(e),[C,O]=f(void 0),S=a??C,$=S&&N.buckets.includes(S)?S:N.buckets[0],[I,L]=f(null),j=I&&I.panel===w&&N.rows.some(e=>e.name===I.name)?I:null,D=o&&N.buckets.length>1&&!j,M=`${w}-rows`,P=e=>`${w}-tab-${e.toLowerCase()}`;/* @__PURE__ */
|
|
46
|
+
return g("div",{className:"es-insp",children:[D?/* @__PURE__ */k("div",{className:"es-insp-tabs",children:/* @__PURE__ */k(i,{ariaLabel:h??v.settings,activeId:$,onSelect:e=>{const n=e;void 0===a&&O(n),s?.(n)},items:N.buckets.map(e=>({id:e,label:v.buckets[e],icon:c?.[e],htmlId:P(e),panelId:M}))})}):null,
|
|
47
|
+
/* @__PURE__ */g("div",{className:"es-insp-rows",id:M,role:D?"tabpanel":void 0,"aria-labelledby":D&&$?P($):void 0,children:[N.rows.map(({name:e,field:a,bucket:i})=>/* @__PURE__ */k("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!(j?j.name!==e:D&&i!==$)||void 0,children:/* @__PURE__ */k(R,{field:a,name:e,id:`${w}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:r,context:l,renderers:u,openItem:j&&j.name===e?j.index:null,onOpenItem:n=>L(null===n?null:{panel:w,name:e,index:n})})},e)),j?null:b]})]})}function J({id:e,label:n,value:t,onChange:r,min:l,max:a,step:i=1,shiftStep:s,styleValue:o,unit:c,sliderMin:d,sliderMax:u,readOnly:m=!1}){const p=y(),h=e??p,{inputProps:f,set:b,isStyle:v}=O({value:t,onChange:r,min:l,max:a,step:i,shiftStep:s,styleValue:o,readOnly:m}),x="number"==typeof t&&Number.isFinite(t)?t:o??d;/* @__PURE__ */
|
|
48
|
+
return g("div",{className:"es-fslider"+(v?" is-style":""),children:[
|
|
49
|
+
/* @__PURE__ */g("div",{className:"es-fslider-top",children:[
|
|
50
|
+
/* @__PURE__ */k("label",{className:"es-fslider-name",htmlFor:h,children:n}),
|
|
51
|
+
/* @__PURE__ */g("span",{className:"es-fslider-read",children:[
|
|
52
|
+
/* @__PURE__ */k("input",{id:h,type:"text",inputMode:"decimal",className:"es-fslider-value",...f}),c?/* @__PURE__ */k("span",{className:"es-fslider-unit",children:c}):null]})]}),
|
|
53
|
+
/* @__PURE__ */k("input",{type:"range",className:"es-fslider-range",min:d,max:u,step:i,value:w(x,d,u),disabled:m,"aria-label":n,onChange:e=>b(Number(e.target.value))})]})}export{$ as FieldNumber,L as FieldSelect,J as FieldSlider,j as FieldText,H as Inspector,R as InspectorField,F as ListField,U as bucketsOf,w as clampNumber,A as copyItem,D as insertAt,K as labelOf,M as moveTo,I as optionFor,N as parseTyped,X as planFields,P as removeAt,O as useNumberEntry};
|
package/dist/gold/index.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ declare function goldSegments(value: string, rules: readonly InlineRule[]): Gold
|
|
|
195
195
|
*
|
|
196
196
|
* NOTHING HERE IS INVENTED (CLAUDE.md — "the tokens are not ours to invent"):
|
|
197
197
|
* - the gold defers to the page's own `--gold`, falling back to the
|
|
198
|
-
* storefront's light-theme value (`efficient-
|
|
198
|
+
* storefront's light-theme value (`efficient-storefront/app/globals.css` → `--gold:
|
|
199
199
|
* #c9a461`), so the mark in the box matches the mark on the page;
|
|
200
200
|
* - the caret and the placeholder defer to the shell layer's `--es-text` /
|
|
201
201
|
* `--es-field-placeholder` (see `shell/tokens.ts`) with the same values as
|