@hazem3500/palette 0.9.145 → 0.9.147
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/cli/design-edit.mjs +17 -1
- package/dist/accent-picker-B5LQWAPK.js +1 -0
- package/dist/account-tokens-ZMRW3JYS.js +1 -0
- package/dist/{chunk-5JHJGDSP.js → chunk-5MFM5GPR.js} +1 -1
- package/dist/{chunk-5TP5P77H.js → chunk-A75MS3NI.js} +1 -1
- package/dist/chunk-BKIUQ7QJ.js +1 -0
- package/dist/{chunk-2JHO4ZDE.js → chunk-EWC2YAAK.js} +1 -1
- package/dist/chunk-GAHDL7C2.js +1 -0
- package/dist/chunk-MKWOTTCN.js +1 -0
- package/dist/chunk-QALADLZS.js +1 -0
- package/dist/{chunk-UWTBLOTJ.js → chunk-TFFPX3O4.js} +1 -1
- package/dist/{chunk-SQH6FIXB.js → chunk-TJBTE5VK.js} +1 -1
- package/dist/color-editor-BRURQZA7.js +1 -0
- package/dist/design-comment-A433M6JL.js +1 -0
- package/dist/design-comment.d.ts +4 -0
- package/dist/design-export-5QM7HHRT.js +1 -0
- package/dist/design-export.d.ts +10 -4
- package/dist/design-geometry-XO6RM4YB.js +1 -0
- package/dist/design-mode.js +1 -1
- package/dist/design-spacing-YL6QH2P3.js +1 -0
- package/dist/design-spacing.d.ts +23 -0
- package/dist/frame-iframe-ZLYVQEQD.js +1 -0
- package/dist/index.js +1 -1
- package/dist/{inline-text-editor-2K7YELB6.js → inline-text-editor-RSHGHTFR.js} +1 -1
- package/dist/node.mjs +1 -1
- package/dist/onboarding-2TITOWW3.js +1 -0
- package/dist/pin-groups-J24YDQIU.js +1 -0
- package/dist/pin-move-HKUATGE2.js +1 -0
- package/dist/react-props-panel-IUOMUL2Z.js +1 -0
- package/dist/react.js +1 -1
- package/dist/review-layout.d.ts +16 -4
- package/dist/server.js +1 -1
- package/dist/setup.js +1 -1
- package/dist/shortcut-help-M45D4PUL.js +1 -0
- package/dist/snapshot-annotate-DMJKY2I6.js +1 -0
- package/dist/thread-snapshot-PQJ6QIUN.js +1 -0
- package/dist/token-custom-QUDSPT6I.js +1 -0
- package/dist/token-page-LLR4EMEC.js +1 -0
- package/dist/token-picker-76CU4ZP5.js +1 -0
- package/dist/toolbar-runtime-RKA2HVCZ.js +1 -0
- package/package.json +1 -1
- package/server/setup-client.txt +109 -68
- package/dist/accent-picker-2SDJUWFU.js +0 -1
- package/dist/account-tokens-ZZYU6CPG.js +0 -1
- package/dist/chunk-B5MDOH7H.js +0 -1
- package/dist/chunk-D2E65BP7.js +0 -1
- package/dist/chunk-QFONAD5S.js +0 -1
- package/dist/color-editor-D3KUEQLZ.js +0 -1
- package/dist/design-comment-FO6ZJ3DP.js +0 -1
- package/dist/design-export-N6WWIQXA.js +0 -1
- package/dist/design-geometry-4GK7D57Z.js +0 -1
- package/dist/frame-iframe-FFHZB3T6.js +0 -1
- package/dist/onboarding-BQ4BDKUS.js +0 -1
- package/dist/pin-groups-677GE533.js +0 -1
- package/dist/pin-move-TASTN2BX.js +0 -1
- package/dist/react-props-panel-NPOEFJCV.js +0 -1
- package/dist/shortcut-help-ZBS3ALR6.js +0 -1
- package/dist/snapshot-annotate-25A74DZZ.js +0 -1
- package/dist/thread-snapshot-DVL3GSVL.js +0 -1
- package/dist/token-custom-S3637QZ2.js +0 -1
- package/dist/token-page-Q73LPPMT.js +0 -1
- package/dist/token-picker-B32ZAZ3X.js +0 -1
- package/dist/toolbar-runtime-PNP3WOJM.js +0 -1
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n,d as o}from"./chunk-
|
|
1
|
+
import{a as n,d as o}from"./chunk-BKIUQ7QJ.js";import"./chunk-5MFM5GPR.js";import"./chunk-HHUTDVTM.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-TFFPX3O4.js";import"./chunk-VX6XCU4E.js";import"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";function r(r){return(t={})=>o(n({...r,...t}))}var t=r;export{t as defineKomo,r as definePalette};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-RBHY7UDS.js";import{a as e,b as o,c as r,d as a}from"./chunk-VX6XCU4E.js";import{j as s,l as i,s as n}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var l=(t,e,o,r={})=>({label:t,group:o,shortcut:{key:e,label:e,alt:!1,shift:!1,ctrl:!1,meta:!1,...r}});function p(o=e(),r,a=t()){let s="Design canvas",i="Experimental geometry",n="Text editing",p="Compare",c=(t,e,o)=>({label:t,group:e,shortcut:o}),u="enter"!==a.child?.key||a.child.alt||a.child.shift||a.child.ctrl||a.child.meta?a.child:null;return[c("Next sibling",s,a.next),c("Previous sibling",s,a.prev),c("Parent element",s,a.parent),l("Post comment","Enter",s),...u?[c("First child",s,u)]:[],l(u?"First child (alternative)":"First child","ArrowDown",s,{alt:!0}),l("Parent element (alternative)","ArrowUp",s,{alt:!0}),l("Exit Design mode","Escape",s),l("Undo last preview","z",s,o?{meta:!0}:{ctrl:!0}),l("Redo last undo","z",s,o?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),...o?[]:[l("Redo last undo","y",s,{ctrl:!0})],l("Focus selection to move or resize","M",s),l("Move before previous sibling","ArrowUp",i,{alt:!0}),l("Move after next sibling","ArrowDown",i,{alt:!0}),l("Move out, after its parent","ArrowUp",i,{alt:!0,shift:!0}),l("Move into previous sibling","ArrowDown",i,{alt:!0,shift:!0}),l("Resize width","ArrowRight",i,o?{meta:!0}:{ctrl:!0}),l("Resize height","ArrowDown",i,o?{meta:!0}:{ctrl:!0}),l("Resize by 10px","ArrowRight",i,o?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),l("Back to the canvas","Escape",i),...r?[{label:"Hide or show selection · hold to peek",group:s,shortcut:r}]:[],l("Commit text","Enter",n),l("New line","Enter",n,{shift:!0}),l("Cancel text edit","Escape",n),l("Toggle before and after","B",p),c("Show before",p,a.before),c("Show after",p,a.after)]}function c(t=e()){let o="Design canvas";return[{label:"Inspect element",group:o,keys:[],gesture:"Click",aria:"Click"},{label:"Select inner element",group:o,keys:[t?"⌘":"Ctrl"],gesture:"Click",aria:(t?"Command":"Control")+" + Click"},{label:"Edit text",group:o,keys:[],gesture:"Double-click",aria:"Double-click"},{label:"Keyboard shortcuts",group:o,keys:["?"],aria:"?"}]}function u(t,e,u=!1,h,d,m=!1){let b=t.querySelector("dialog.palette-shortcuts");if(b)return b.querySelector("[autofocus]")?.focus();let f=t.activeElement??document.activeElement,g=f?.closest(".morphing-menu__panel")?t.querySelector('[data-menu-item="more"]'):f,x=s("dialog","palette-shortcuts");x.setAttribute("aria-modal","true"),x.setAttribute("aria-labelledby","palette-shortcuts-title");let v=s("h2","","Keyboard shortcuts");v.id="palette-shortcuts-title";let k=i("Close",()=>M(),"icon palette-shortcuts__close","close");k.removeAttribute("title");let w=s("span","morphing-menu__tooltip palette-shortcuts__tip","Close");w.setAttribute("aria-hidden","true"),w.append(a(["Esc"],"Escape"));let y=s("header");y.append(v,k,w);let _=s("input");_.type="search",_.placeholder="Filter shortcuts",_.setAttribute("aria-label","Filter shortcuts"),_.autocomplete="off",_.spellcheck=!1;let C=s("div","palette-shortcuts__body");C.tabIndex=0,C.setAttribute("autofocus",""),C.setAttribute("role","region"),C.setAttribute("aria-label","Shortcuts");let A=u?[...c(),...p(void 0,e.find(t=>/^(Hide|Show) comments$/.test(t.label))?.shortcut,d)]:[],E=[...e,l("Post comment","Enter","Comments"),l("New line","Enter","Comments",{shift:!0}),{label:"Select several pins",group:"Comments",keys:["Shift"],gesture:"Click",aria:"Shift + Click"},...m?[l("Zoom to fit","1","Frame",{shift:!0}),l("Zoom to 100%","0","Frame",{shift:!0})]:[]],S=("design"===h?[...A,...E]:[...E,...A]).filter(t=>t.shortcut||t.keys?.length||t.gesture),D=[...new Set(S.map(t=>t.group??"General"))].sort((t,e)=>+("comment"===h&&"Comments"===e)-+("comment"===h&&"Comments"===t)),z=[];for(let t of D){let e=s("section");e.append(s("h3","",t));for(let i of S.filter(e=>(e.group??"General")===t)){let t=s("div","palette-shortcuts__row"),n=i.shortcut?o(i.shortcut):void 0;n&&t.setAttribute("aria-keyshortcuts",n.aria);let l=i.shortcut?r(i.shortcut):a(i.keys,i.aria??i.keys.join(" + "));i.gesture&&l.append(s("span","",i.gesture)),t.append(s("span","",i.label),l),e.append(t),z.push([t,`${i.label} ${l.getAttribute("aria-label")} ${l.textContent}`.toLowerCase()])}C.append(e)}let F=s("p","","No matching shortcuts");F.setAttribute("role","status"),F.hidden=!0,C.append(F,s("p","","Shortcuts pause while typing in a text field.")),_.addEventListener("input",()=>{let t=_.value.toLowerCase().split(/\s+/).filter(Boolean);for(let[e,o]of z)e.hidden=!t.every(t=>o.includes(t));for(let t of C.querySelectorAll("section"))t.hidden=!t.querySelector(".palette-shortcuts__row:not([hidden])");F.hidden=z.some(([t])=>!t.hidden)}),x.append(Object.assign(s("style"),{textContent:'.palette-shortcuts{box-sizing:border-box;width:min(720px,calc(100vw - 32px));max-width:none;max-height:min(680px,calc(100dvh - 32px));margin:auto;padding:0;overflow:hidden;border:0;border-radius:16px;background:var(--mm-surface);color:var(--mm-ink);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--mm-ink) 12%,transparent),0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}\n.palette-shortcuts[open]{display:flex;flex-direction:column;animation:palette-help-in var(--duration-fast) var(--ease-smooth-out)}\n.palette-shortcuts::backdrop{background:rgb(0 0 0/40%);pointer-events:auto}\n@keyframes palette-help-in{from{opacity:0;scale:.98;translate:0 4px}}\n.palette-shortcuts header{flex:none;position:relative;display:flex;align-items:center;gap:8px;padding:10px 10px 4px 16px}\n.palette-shortcuts h2{flex:1;margin:0;font-size:14px;font-weight:600}\n.palette-shortcuts__close{width:28px;height:28px;border-radius:8px;color:color-mix(in oklab,var(--mm-ink) 60%,transparent)}\n.palette-shortcuts__close:hover{background:color-mix(in oklab,var(--mm-ink) 8%,transparent);color:var(--mm-ink)}\n.palette-shortcuts__close svg{width:16px;height:16px}\n.palette-shortcuts .palette-shortcuts__tip{top:50%;bottom:auto;right:44px;translate:0 -50%;opacity:0;transition:opacity var(--duration-quick) var(--ease-smooth-out)}\n.palette-shortcuts__close:hover+.palette-shortcuts__tip,.palette-shortcuts__close:focus-visible+.palette-shortcuts__tip{opacity:1;transition-delay:400ms}\n.palette-shortcuts input{flex:none;width:auto;height:30px;margin:6px 16px;padding:0 10px;border-radius:8px;background:color-mix(in oklab,var(--mm-ink) 7%,transparent);box-shadow:none}\n.palette-shortcuts input:focus{box-shadow:inset 0 0 0 1px var(--accent,#bda6ef)}\n.palette-shortcuts input::placeholder{color:color-mix(in oklab,var(--mm-ink) 50%,transparent)}\n.palette-shortcuts__close:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:-2px}\n.palette-shortcuts__body{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:4px 16px 14px;columns:2 240px;column-gap:28px;outline:0}\n.palette-shortcuts section{break-inside:avoid;padding-bottom:10px}\n.palette-shortcuts h3{margin:0;padding:6px 0 2px;font-size:11px;font-weight:600;color:color-mix(in oklab,var(--mm-ink) 62%,transparent)}\n.palette-shortcuts__row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px}\n.palette-shortcuts [hidden]{display:none}\n.palette-shortcuts .palette-kbd{align-items:center;gap:4px}\n.palette-shortcuts__row kbd{box-sizing:border-box;display:inline-grid;place-items:center;min-width:20px;height:20px;padding:0 5px;border-radius:5px;font-size:11px;line-height:1}\n.palette-shortcuts .palette-kbd span,.palette-shortcuts p{color:color-mix(in oklab,var(--mm-ink) 55%,transparent)}\n.palette-shortcuts p{column-span:all;margin:4px 0 0;font-size:11px}\n@media (prefers-reduced-motion:reduce){.palette-shortcuts[open]{animation:none}}\n@media (pointer:coarse){.palette-shortcuts__close{width:44px;height:44px}}'}),y,_,C);let L=new AbortController,{signal:j}=L,M=()=>{j.aborted||(L.abort(),x.close(),x.remove(),g?.isConnected&&g.focus({preventScroll:!0}))};x.addEventListener("close",M,{signal:j}),window.addEventListener("keydown",e=>{let o=e.composedPath().find(t=>t instanceof HTMLDialogElement&&t.open);if(o&&o!==x||(e.stopImmediatePropagation(),e.isComposing))return;let r=t.activeElement===_;if("Escape"!==e.key&&("?"!==e.key||r||e.ctrlKey||e.metaKey||e.altKey)){if("Tab"===e.key){let o=[k,_,C],r=o.indexOf(t.activeElement);e.preventDefault(),o[r<0?e.shiftKey?2:0:(r+(e.shiftKey?2:1))%3].focus()}}else e.preventDefault(),M()},{capture:!0,signal:j}),n(x,M,j),t.append(x),x.showModal()}export{u as showShortcutHelp};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./chunk-JWGDIIKJ.js";import{j as t,l as a}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var r=[["pen","Pen"],["arrow","Arrow"],["rectangle","Rectangle"],["highlight","Highlight"]],o=[["Red","#fa5252"],["Yellow","#ffd43b"],["Blue","#4dabf7"],["Green","#51cf66"]];function l(e,t,a){let{points:[r,...o],tool:l,color:n}=t,p=o.at(-1)??r;if(e.save(),e.strokeStyle=e.fillStyle=n,e.lineWidth=a,e.lineJoin=e.lineCap="round",e.beginPath(),"rectangle"===l){let t=Math.abs(p.x-r.x),o=Math.abs(p.y-r.y);e.roundRect(Math.min(r.x,p.x),Math.min(r.y,p.y),t,o,Math.min(a,t/2,o/2)),e.stroke()}else if("arrow"===l){let t=Math.atan2(p.y-r.y,p.x-r.x),o=Math.min(4.5*a,.6*Math.hypot(p.x-r.x,p.y-r.y)),l={x:p.x-o*Math.cos(t),y:p.y-o*Math.sin(t)};e.moveTo(r.x,r.y),e.lineTo(l.x,l.y),e.stroke(),e.beginPath(),e.moveTo(p.x,p.y);for(let a of[-1,1])e.lineTo(l.x+a*o*.42*Math.sin(t),l.y-a*o*.42*Math.cos(t));e.closePath(),e.fill()}else{if("highlight"===l&&(e.globalAlpha=.38,e.lineWidth=5*a),e.moveTo(r.x,r.y),o.length){for(let t=0;t<o.length-1;t++){let a=o[t],r=o[t+1];e.quadraticCurveTo(a.x,a.y,(a.x+r.x)/2,(a.y+r.y)/2)}e.lineTo(p.x,p.y)}else e.lineTo(r.x+.1,r.y);e.stroke()}e.restore()}async function n(n,p,i,d,s,u){if(n.querySelector(".palette-markup[open]"))return;let h=d?.source??p,c=new Image;if(c.src=h,await c.decode(),s.aborted||!n.host.isConnected||n.querySelector(".palette-markup[open]"))return;let m=n.activeElement,f=t("dialog","palette-snapshot-viewer palette-markup");f.setAttribute("aria-label","Image preview");let g=t("style","",'\n.palette-snapshot-viewer.palette-markup{box-sizing:border-box;width:min(1040px,calc(100vw - 32px));padding:0;background:#1b1b1d;color:#f4f4f5}\n.palette-markup header{padding:10px 14px;margin:0;border-bottom:1px solid #ffffff14}\n.palette-markup h2{font-size:14px;padding:0}\n.palette-markup .palette-markup-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:2px 14px 4px}\n.palette-markup-tools,.palette-markup-colors,.palette-markup-history{display:flex;align-items:center;gap:3px}\n.palette-markup-tools{background:#ffffff0a;border:1px solid #ffffff0d;border-radius:9px;padding:2px}\n.palette-markup .palette-markup-control{border:0;border-radius:6px;background:transparent;color:#d4d4d8;padding:0 9px;min-height:34px;font:inherit;cursor:pointer}\n.palette-markup .palette-markup-control[aria-pressed=true]{background:#ffffff1a;color:#fff}\n.palette-markup .palette-markup-control:disabled{opacity:.36;cursor:default}\n.palette-markup .palette-markup-control:focus-visible,.palette-markup-swatch:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-markup-swatch{display:grid;place-items:center;width:30px;height:34px;padding:0;background:none;border:0;border-radius:6px;cursor:pointer}\n.palette-markup-swatch::before{content:"";width:13px;height:13px;border-radius:50%;background:var(--swatch)}\n.palette-markup-swatch[aria-pressed=true]::before{outline:1px solid currentColor;outline-offset:3px}\n.palette-markup .palette-markup-done{background:#e6dcfb;color:#26212e;font-weight:600}\n.palette-markup .palette-markup-history{margin-left:auto}\n.palette-markup-stage{display:grid;place-items:center;min-width:0;padding:20px;overflow:hidden;background:#101012;border-block-start:1px solid #ffffff12}\n.palette-markup-stage canvas{display:block;max-width:100%;height:auto;border-radius:4px;touch-action:none;cursor:crosshair}\n.palette-markup-stage canvas[data-tool=highlight]{cursor:cell}\n.palette-markup-status:not(:empty){margin:0;padding:0 14px 10px;color:#fda4af}\n@media(hover:hover){.palette-markup .palette-markup-control:enabled:hover{background:#ffffff19;color:#fff}.palette-markup .palette-markup-done:enabled:hover{background:#f0e9ff;color:#26212e}}\n@media(pointer:coarse){.palette-markup .palette-markup-control,.palette-markup-swatch{min-height:44px}.palette-markup-swatch{width:44px}}\n@media(max-width:520px){.palette-snapshot-viewer.palette-markup{width:calc(100vw - 16px);max-width:calc(100vw - 16px)}.palette-markup header,.palette-markup .palette-markup-toolbar{padding-inline:10px}.palette-markup .palette-markup-history{margin-left:0}.palette-markup-stage{padding:12px}}\n'),k=t("header"),x=t("div","palette-markup-toolbar");x.setAttribute("aria-label","Image annotation tools"),x.setAttribute("role","toolbar");let b=t("div","palette-markup-tools"),w=t("div","palette-markup-colors"),v=t("div","palette-markup-history"),y=t("div","palette-markup-stage"),M=t("canvas");M.setAttribute("aria-label","Image with annotations"),M.setAttribute("role","img"),M.width=c.naturalWidth,M.height=c.naturalHeight,M.style.width=`min(100%, calc(max(60px, 100dvh - 220px) * ${M.width/M.height}))`;let A=M.getContext("2d");if(!A)throw new Error("Canvas is unavailable.");let C=[...d?.marks??[]],I=[],E="pen",L=o[0][1],S=null,T=null,P=0,R=!1,D=Math.max(2,M.width/180),j=()=>{A.clearRect(0,0,M.width,M.height),A.drawImage(c,0,0);for(let e of C)l(A,e,D);T&&l(A,T,D)},q=()=>{P||=requestAnimationFrame(()=>{P=0,j()})},K=e=>{let t=M.getBoundingClientRect();return{x:Math.max(0,Math.min(M.width,(e.clientX-t.left)*M.width/t.width)),y:Math.max(0,Math.min(M.height,(e.clientY-t.top)*M.height/t.height))}},W=r.map(([e,t])=>a(t,()=>{E=e,"highlight"===e&&(L=o[1][1]),Q()},"palette-markup-control")),z=o.map(([e,t])=>{let r=a(e,()=>{L=t,Q()},"palette-markup-swatch");return r.textContent="",r.style.setProperty("--swatch",t),r});M.addEventListener("pointerdown",e=>{0!==e.button||null!==S||R||(M.setPointerCapture(e.pointerId),S=e.pointerId,T={tool:E,color:L,points:[K(e)]},Q(),q())});let G=e=>{if(!T)return;let t=K(e);"arrow"===T.tool||"rectangle"===T.tool?T.points[1]=t:T.points.push(t)};M.addEventListener("pointermove",e=>{e.pointerId===S&&(G(e),q())}),M.addEventListener("pointerup",e=>{e.pointerId!==S||!T||(G(e),C.push(T),I.length=0,T=null,S=null,Q(),q())});let H=e=>{e.pointerId===S&&(S=null,T=null,Q(),q())};M.addEventListener("pointercancel",H),M.addEventListener("lostpointercapture",H);let J=a("Undo",()=>{let e=C.pop();e&&I.push(e),Q(),q()},"palette-markup-control"),B=a("Redo",()=>{let e=I.pop();e&&C.push(e),Q(),q()},"palette-markup-control"),F=t("p","palette-markup-status");F.setAttribute("role","status");let Y=a("Done",()=>{if(T||R)return;let t=d?.marks??[];C.length===t.length&&C.every((e,a)=>e===t[a])?f.close():(R=!0,Q(),j(),e(M,{x:0,y:0,width:M.width,height:M.height},i).then(e=>{f.open&&(f.close(),u(e,{source:h,marks:C}))},()=>{F.textContent="Could not save the image.",R=!1,Q()}))},"palette-markup-control palette-markup-done");function Q(){M.dataset.tool=E,W.forEach((e,t)=>e.setAttribute("aria-pressed",String(E===r[t][0]))),z.forEach((e,t)=>e.setAttribute("aria-pressed",String(L===o[t][1]))),J.disabled=!C.length||!!T||R,B.disabled=!I.length||!!T||R,Y.disabled=!!T||R}b.append(...W),w.append(...z),v.append(J,B),x.append(b,w,v);let U=a("Close image preview",()=>f.close(),"icon","close");k.append(t("h2","","Image preview"),Y,U),y.append(M),f.append(g,k,x,y,F);let X=new AbortController;window.addEventListener("keydown",e=>{if(!f.open)return;let t=e.key.toLowerCase(),a=(e.metaKey||e.ctrlKey)&&("z"===t||"y"===t);("escape"===t||a)&&(e.preventDefault(),"escape"===t?f.close():("y"===t||e.shiftKey?B:J).click()),e.stopImmediatePropagation()},{capture:!0,signal:X.signal});let Z=()=>{X.abort(),f.close()};s.addEventListener("abort",Z,{once:!0}),f.addEventListener("close",()=>{s.removeEventListener("abort",Z),X.abort(),cancelAnimationFrame(P),f.remove(),m?.isConnected&&m.focus({preventScroll:!0})},{once:!0}),n.append(f),Q(),j(),f.showModal()}export{n as annotateImage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,l as t,s as n}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var a=new WeakMap;function o(t){let n=a.get(t);n?.isConnected||(n=e("style","",'.palette-snapshot{display:block;width:fit-content;margin-top:8px;padding:0;border:0;border-radius:6px;background:none;color:inherit;font:inherit;cursor:zoom-in;line-height:0}\n.palette-snapshot img{display:block;width:72px;height:48px;border-radius:6px;object-fit:contain;background:color-mix(in oklab,currentColor 8%,transparent);outline:1px solid color-mix(in oklab,currentColor 16%,transparent);outline-offset:-1px}\n.palette-snapshot:not([data-ready]){background:color-mix(in oklab,currentColor 8%,transparent)}\n.palette-snapshot:not([data-ready]) img{visibility:hidden}\n.palette-snapshot[hidden]{display:none}\n.palette-snapshot:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot[data-large]{width:auto;max-width:100%}\n.palette-snapshot[data-large] img{width:auto;height:auto;min-width:72px;min-height:48px;max-width:100%;max-height:180px;object-fit:contain}\n.thread-item>.palette-snapshot{margin:6px 12px 0 calc(12px + var(--palette-avatar,20px) + var(--palette-gutter,8px))}\n.dialog:has(.thread-navigation:not([hidden]) .palette-snapshot-view) .message .palette-snapshot{display:none}\n.palette-snapshot-view{margin-top:8px}\n.palette-snapshot-view p{margin:0 0 6px}\n.palette-snapshot-code{box-sizing:border-box;max-height:160px;margin:0;padding:8px;overflow:auto;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;scrollbar-width:thin}\n.palette-snapshot-code:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot-text{justify-self:start;margin-top:8px;padding:4px 8px;border:0;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);color:inherit;font-family:inherit;font-size:11px;line-height:1.4;cursor:pointer}\n.palette-snapshot-draft{display:grid;grid-template-columns:1fr auto;align-items:center;gap:6px;margin-top:8px;font-size:12px;color:#999}\n.palette-snapshot-draft .palette-snapshot{grid-column:1/-1;width:100%;margin:0;background:#ffffff08}\n.palette-snapshot-draft .palette-snapshot img{width:100%;height:94px;object-fit:contain}\n.palette-snapshot-draft .palette-snapshot:hover img{outline-color:var(--accent,#bda6ef)}\n.palette-snapshot-draft span{flex:1;min-width:0}\n.palette-snapshot-draft .icon{width:28px;height:28px}\n.palette-snapshot-viewer{box-sizing:border-box;max-width:min(1200px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:12px;overflow:hidden;border:0;border-radius:16px;background:#242424;color:#eee;box-shadow:inset 0 0 0 1px #ffffff1f,0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}\n.palette-snapshot-viewer[open]{display:flex;flex-direction:column;gap:8px;animation:palette-snapshot-in var(--duration-fast,250ms) var(--ease-smooth-out,cubic-bezier(.22,1,.36,1))}\n.palette-snapshot-viewer::backdrop{background:rgb(0 0 0/40%);pointer-events:auto}\n.palette-snapshot-viewer header{display:flex;align-items:center;gap:8px}\n.palette-snapshot-viewer h2{flex:1;margin:0;padding-left:4px;font-size:13px;font-weight:600}\n.palette-snapshot-viewer .secondary{background:#ffffff14;color:inherit}\n.palette-snapshot-viewer .primary{background:#e6dcfb;color:#242424}\n.palette-snapshot-viewer .row{flex-wrap:wrap;justify-content:flex-end}\n.palette-snapshot-viewer .icon{width:28px;height:28px;border-radius:8px;color:#bbb}\n.palette-snapshot-viewer .icon:hover{background:#ffffff14;color:#eee}\n.palette-snapshot-viewer .icon:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:-2px}\n.palette-snapshot-viewer img{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;border-radius:8px;object-fit:contain}\n.palette-snapshot-viewer .palette-snapshot-code{max-height:calc(100dvh - 104px);width:min(720px,calc(100vw - 56px))}\n@keyframes palette-snapshot-in{from{opacity:0;scale:.98;translate:0 4px}}\n@media (prefers-reduced-motion:reduce){.palette-snapshot-viewer[open]{animation:none}}\n@media (pointer:coarse){.palette-snapshot-viewer .icon,.palette-snapshot-draft .icon{width:44px;height:44px}}'),a.set(t,n),t.append(n))}var r=20,i=[],s=0,p=[],l=0;function d(){let e=performance.now();for(;p.length&&e-p[0]>=6e4;)p.shift();for(;i.length&&s<2&&p.length<20;)s++,p.push(e),i.shift()();i.length&&!l&&p.length>=20&&(l=window.setTimeout(()=>(l=0,d()),6e4-(e-p[0])))}var c=new Map;function h(e,t){let n,a=t.token();try{n=new URL(e)}catch{return Promise.resolve(null)}if(!a||n.origin!==t.origin())return Promise.resolve(null);let o=`${a} ${e}`,r=c.get(o);if(r)return r;r=new Promise(e=>{i.push(()=>e(()=>(s--,d()))),d()}).then(async e=>{try{let e=await fetch(n,{headers:{Authorization:`Bearer ${a}`},credentials:"omit",signal:AbortSignal.timeout(15e3)});if(404===e.status)return null;if(!e.ok)throw new Error(String(e.status));return await e.blob()}finally{e()}}),c.set(o,r),r.catch(()=>c.get(o)===r&&c.delete(o));for(let e of c.keys())c.size>40&&c.delete(e);return r}var f,u=new WeakMap,m=new Map,g=new WeakSet,x="img[data-palette-snapshot]";function b(e){let t=u.get(e);!t||m.has(e)||!e.isConnected||h(t.url,t.context).then(n=>{if(!e.isConnected||m.has(e))return;if(!n)return t.done?.(!1);let a=URL.createObjectURL(n);m.set(e,a),e.src=a,t.done?.(!0)},()=>t.done?.(!1))}function v(e){f?f.observe(e):b(e)}function w(e){g.has(e)||(g.add(e),"function"==typeof IntersectionObserver&&(f??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&b(t.target)})),new MutationObserver(e=>{for(let t of e){for(let e of t.removedNodes)if(e instanceof Element)for(let t of e.matches(x)?[e]:e.querySelectorAll(x))t.isConnected||f?.unobserve(t);for(let e of t.addedNodes)if(e instanceof Element&&e.isConnected)for(let t of e.matches(x)?[e]:e.querySelectorAll(x))v(t)}!function(){for(let[e,t]of m)e.isConnected||(URL.revokeObjectURL(t),m.delete(e),e.removeAttribute("src"))}()}).observe(e,{childList:!0,subtree:!0}))}function y(e){for(let t of[...C.get(e)??[]])t();for(let[t,n]of m)t.getRootNode()===e&&(URL.revokeObjectURL(n),m.delete(t),t.removeAttribute("src"),f?.unobserve(t))}function k(e){let{context:t,text:n}=e.anchor,a=(t?.label||n||"").replace(/\s+/g," ").trim();return`Snapshot of ${a?`“${a.length>60?`${a.slice(0,59)}…`:a}”`:t?.tag?`the ${t.tag} element`:"the commented element"} when the comment was left`}var L=/^<!-- (?:palette|komo): (no image snapshot, [^>]*?)\.? -->\s*/;function S(e){let t=L.exec(e);return t?{note:`${t[1][0].toUpperCase()}${t[1].slice(1)}.`,code:e.slice(t[0].length)}:{note:"",code:e}}function A(t){let n=e("pre","palette-snapshot-code");return n.textContent=t,n.tabIndex=0,n.setAttribute("role","region"),n.setAttribute("aria-label","HTML snapshot"),n}var C=new Map;async function R(a,r,i){o(a);let s=a.activeElement,p=e("dialog","palette-snapshot-viewer");p.setAttribute("aria-modal","true"),p.setAttribute("aria-label",r.alt);let l=e("header"),d=t("Close snapshot",()=>f(),"icon","close");if(d.removeAttribute("title"),l.append(e("h2","",r.src?"Snapshot":"HTML snapshot"),d),p.append(l),r.src){let t=e("img");t.alt=r.alt,t.src=r.src,p.append(t),await t.decode().catch(()=>{})}else{let{note:t,code:n}=S(r.html??"");t&&p.append(e("p","",t)),p.append(A(n))}if(!a.host.isConnected)return i?.();let c=new AbortController,{signal:h}=c,f=()=>{h.aborted||(c.abort(),C.get(a)?.delete(f),p.close(),p.remove(),i?.(),s?.isConnected&&s.focus({preventScroll:!0}))};return p.addEventListener("close",f,{signal:h}),C.set(a,(C.get(a)??new Set).add(f)),window.addEventListener("keydown",e=>{e.stopImmediatePropagation(),"Escape"===e.key&&(e.preventDefault(),f())},{capture:!0,signal:h}),n(p,f,h),a.append(p),p.showModal(),d.focus(),p}function M(t,n,a,o=!1,r){let i=k(n),s=e("img");s.alt=i,s.dataset.paletteSnapshot="",s.decoding="async";let p=e("button","palette-snapshot");return p.type="button",p.setAttribute("aria-haspopup","dialog"),o&&(p.dataset.large=""),p.append(s),u.set(s,{url:t,context:a,done:e=>{e?p.dataset.ready="":p.dataset.ready||(r?r():p.hidden=!0)}}),p.addEventListener("click",()=>{h(t,a).then(e=>{if(!e)return;let t=URL.createObjectURL(e);R(a.root,{src:t,alt:i},()=>URL.revokeObjectURL(t))})}),p}function U(e,t,n){w(n),e.replaceWith(t);let a=t.querySelector(x);a?.isConnected&&v(a)}function j(e,t,n,a){o(t.root),U(e,M(n,{anchor:a},t),t.root)}function E(n,a,r,i,s){let{image:p,html:l}=i.snapshot??{};if(o(a.root),3===r)return void s?.then(o=>{o&&(o.image||o.html)&&n.isConnected&&!a.dropped.has(i.anchor)&&U(n,function(n,a,o){let r=e("div","palette-snapshot-draft"),i=k({anchor:a});if(n.image){let t=e("button","palette-snapshot");t.type="button",t.dataset.ready="",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-label","Open image preview");let s=e("img");s.alt=i,s.src=n.image,t.append(s),t.addEventListener("click",()=>{o.annotate?o.annotate(a,n):R(o.root,{src:n.image,alt:i})}),r.append(t)}r.append(e("span","",n.image?n.html?"Snapshot and HTML attached":"Snapshot attached":"HTML snapshot attached"));let s=t("Remove snapshot",()=>{o.dropped.add(a),r.closest("form")?.querySelector("textarea")?.focus(),r.remove()},"icon","trash");return r.append(s),r}(o,i.anchor,a),a.root)});let d=r>1?(p||l)&&function(t,n){let{image:a,html:o}=t.snapshot,r=e("div","palette-snapshot-view"),i=()=>{if(!o)return r.remove();h(o,n).then(async t=>{if(!t)return r.remove();let{note:n,code:a}=S(await t.text());r.replaceChildren(e("p","",n||"How it looked, as HTML:"),A(a))},()=>r.remove())};return r.append(e("p","","How it looked:")),a?r.append(M(a,t,n,!0,i)):i(),r}(i,a):p?M(p,i,a):r&&l&&function(e,n,a){let o=t("HTML snapshot",()=>{h(e,a).then(async e=>{e&&R(a.root,{html:await e.text(),alt:k(n)})})},"palette-snapshot-text");return o.removeAttribute("title"),o.setAttribute("aria-haspopup","dialog"),o}(l,i,a);if(4===r){let t=e("div");t.append(function(t,n){let a=new URL(t.page,location.origin);a.searchParams.set("comment",t.id);let o=e("a","thread-route",t.page);o.href=a.href,o.addEventListener("click",e=>{e.preventDefault(),n.go(a)});let r=e("p","","Left on ");return r.append(o),r}(i,a),...d?[d]:[]),d=t}d&&U(n,d,a.root)}function z(e,t){t.notify("Remove this comment’s snapshot?",{label:"Remove",run:()=>{t.remove(e),t.notify("Snapshot removed")}})}export{r as READS_PER_MINUTE,z as confirmRemove,y as disposeSnapshots,j as mountCommentImage,E as mountSnapshot,R as openSnapshotViewer,h as readSnapshot,k as snapshotAlt,S as splitNote};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as t,d as l,e as i}from"./chunk-KIVVWQD7.js";import{j as o}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var a=/^([+-]?(?:\d*\.)?\d+)([a-z%]*)$/i;function p(e){return e.filter(e=>!e.hidden).map(e=>[...e.inset?["inset"]:[],...e.lengths,e.color].filter(Boolean).join(" ")).join(", ")||"none"}var n=["px","%","rem","em","vw","vh","ch","vmin","vmax","dvh"];function r(e,t,l,i){let a=o("button","palette-typed__icon");return a.type="button",a.innerHTML=t,a.title=e,a.setAttribute("aria-label",e),void 0!==i&&a.setAttribute("aria-pressed",String(i)),a.onclick=l,a}function d(e,t,l,i,p,{unitless:r=!1,optional:d=!1}={}){let s=o("div","palette-typed__field"),f=o("span");t?f.textContent=t:f.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M1 6h10M3 4 1 6l2 2M9 4l2 2-2 2"/></svg>',f.title=`${e} · drag to adjust`;let u=o("input");u.setAttribute("aria-label",e),u.inputMode="decimal",u.autocomplete="off",u.spellcheck=!1;let c=o("select");c.setAttribute("aria-label",`${e} unit`);let h=a.exec(l)??["","",""];u.value=h[1];let y=h[2]||(r||!h[1]&&d?"":"px");for(let e of new Set([y,...n,...r?[""]:[]])){let t=o("option","",e||"—");t.value=e,e||(t.title="No unit"),c.append(t)}c.value=y;let g=!1,_=e=>{let t=d&&!u.value.trim(),l=t||a.test(u.value.trim()+c.value);l?p.delete(u):p.add(u);let o=l&&i(t?"":u.value.trim()+c.value,e);return u.setAttribute("aria-invalid",String(!l)),e&&(g=!1),o},x=(e,t)=>{let l=a.exec(function(e,t){let l=a.exec(e.trim());if(!l)return e;let i=!l[2]||/^r?em$/i.test(l[2]);return`${Math.round(1e3*(parseFloat(l[1])+t*(i?.1:1)))/1e3}${l[2]}`}(u.value.trim()+c.value,e));l&&(u.value=l[1],_(t))};return u.oninput=()=>{g=!0,_(!1)},u.onkeydown=e=>{"Enter"===e.key?(e.preventDefault(),e.stopPropagation(),_(!0)):("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),x(("ArrowUp"===e.key?1:-1)*(e.shiftKey?10:1),!0))},u.onblur=()=>{g&&_(!0)},c.onchange=()=>_(!0),f.onpointerdown=e=>{if(e.button)return;e.preventDefault(),f.setPointerCapture?.(e.pointerId);let t=e.clientX,l=!1;f.onpointermove=e=>{let i=Math.trunc((e.clientX-t)/2);i&&(t+=2*i,l=!0,x(i*(e.shiftKey?10:1),!1))},f.onpointerup=f.onpointercancel=()=>{f.onpointermove=f.onpointerup=f.onpointercancel=null,l?_(!0):u.focus()}},s.append(f,u,c),s}function s(n,s,f,u,c,h,y=[],g=()=>{}){let _=o("div","palette-typed"),x=o("details","palette-typed palette-typed__advanced"),m=o("summary","","Edit as CSS");m.onclick=e=>{e.preventDefault(),e.stopPropagation(),x.open=!x.open};let v=o("div","palette-typed__field");u.title=s,u.autocomplete="off",u.spellcheck=!1,v.append(o("span","","CSS"),u),x.append(m,v),n.append(_,x);let b=!1,w=new Set;u.oninput=()=>{b=!0,c(u.value,!1)&&S(u.value,!0)},u.onkeydown=e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),b=!1,c(u.value,!0))},u.onblur=()=>{b&&(b=!1,c(u.value,!0))};let k=(e,t,l,i,a,p)=>{let n=o("select","palette-typed__menu");n.setAttribute("aria-label",e);for(let[e,l]of t){let t=o("option","",l);t.value=e,t.title=e,p&&e&&(t.style[p]=e),n.append(t)}return n.value=l,n.onchange=()=>i(n.value),a&&n.addEventListener("palette-preview",e=>{let t=e.detail;g(null===t?void 0:a(t))}),n};function S(n,f=!1){if(f||(u.value=n),w.clear(),_.replaceChildren(),"font-family"===s){let e=o("div","palette-typed__sample"),l=o("b","","Aa"),i=o("span","",t(n));e.title=n,l.style.fontFamily=n,e.append(l,i),_.append(e);let a=y.filter(e=>"fontFamily"===e.type&&e.value&&CSS.supports(s,e.value));a.length?_.append(k("Font family choices",[[n,`Custom · ${t(n)}`],...a.map(e=>[e.value,e.label||t(e.value)])],n,e=>{c(e,!0)&&S(e)},e=>e,"fontFamily")):x.open=!0}else if(/^(box|text)-shadow$/.test(s)){let t=function(t,l="box-shadow"){if("none"===t)return[];let i=[];for(let o of e(t,!0)){let t=e(o),p=[],n="",r=!1,d=!1;for(let e of t)if("inset"!==e||"box-shadow"!==l||r)if(a.test(e)){if(d)return;p.push(e)}else{if(n||/var\(/i.test(e)||!CSS.supports("color",e))return;n=e,d=p.length>0}else r=!0;if(p.length<2||p.length>("box-shadow"===l?4:3))return;i.push({lengths:p,color:n,inset:r})}return i.length?i:void 0}(n,s);if(!t)return _.append(o("span","palette-typed__hint","Complex shadow · edit it as CSS below.")),void(x.open=!0);let l="box-shadow"===s,i=o("div","palette-typed__tile"),f=o("i","",l?"":"Ag");i.setAttribute("aria-hidden","true"),i.append(f);let u=e=>(f.style.setProperty(s,p(t)),c(p(t),e));f.style.setProperty(s,p(t));let h=o("div","palette-typed__head");h.append(o("b","","Layers"),r("Add shadow layer",'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg>',()=>{t.push({lengths:["0px","2px","4px","0px"].slice(0,l?4:3),color:"#00000040",inset:!1}),u(!0)&&S(p(t))})),_.append(i,h),t.forEach((e,i)=>{let a=`Layer ${i+1}`,n=o("div","palette-typed__layer");n.setAttribute("role","group"),n.setAttribute("aria-label",`Shadow layer ${i+1}`),n.toggleAttribute("data-hidden",!!e.hidden);let s=o("div","palette-typed__row");l&&s.append(k(`${a} type`,[["drop","Drop"],["inner","Inner"]],e.inset?"inner":"drop",t=>{e.inset="inner"===t,u(!0)}));let f=o("button","palette-typed__color");f.type="button",f.setAttribute("aria-label",`${a} color`),f.setAttribute("aria-expanded","false");let c=o("i"),h=o("span"),g=o("span","palette-typed__alpha");f.append(c,h,g);let x,m=()=>{let[t,l="100%"]=function(e){let t=document.createElement("i").style;t.color=e.trim(),t.color&&(e=t.color);let l=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i.exec(e.trim());if(!l)return e||"currentColor";let i=`#${l.slice(1,4).map(e=>Math.round(Number(e)).toString(16).padStart(2,"0")).join("")}`,o=void 0===l[4]?1:Number(l[4])/(l[5]?100:1);return o<1?`${i} · ${Math.round(100*o)}%`:i}(e.color).split(" · ");c.style.setProperty("--c",e.color||"currentColor"),h.textContent=t.replace(/^#/,"").toUpperCase(),g.textContent=e.color?l:"",f.title=e.color||"currentColor"};m(),f.onclick=async()=>{if(x)return x.remove(),x=void 0,void f.setAttribute("aria-expanded","false");f.setAttribute("aria-expanded","true");let{pickerEditor:t}=await import("./color-editor-BRURQZA7.js");!f.isConnected||x||(x=t({trigger:f,tokens:y,property:"color",onSelect(){},custom:{value:e.color||"#000000",onPreview:()=>()=>{},onSelect(){}}},{preview(t){e.color=t,m(),u(!1)},commit(t){e.color=t,m(),u(!0)},token(t){e.color=t.value,m(),u(!0)}}),n.append(x))};let v=r(`${a} visible`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/></svg>',()=>{e.hidden=!e.hidden,v.setAttribute("aria-pressed",String(!e.hidden)),n.toggleAttribute("data-hidden",!!e.hidden),u(!0)},!e.hidden);s.append(f,v,r(`Remove layer ${i+1}`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h9"/></svg>',()=>{t.splice(i,1),u(!0)&&S(p(t))}));let b=o("div","palette-typed__grid");[["X offset","X"],["Y offset","Y"],["Blur","Blur"],["Spread","Spread"]].slice(0,l?4:3).forEach(([t,l],i)=>b.append(d(`${a} ${t.toLowerCase()}`,l,e.lengths[i]||"0px",(t,l)=>{for(;e.lengths.length<=i;)e.lengths.push("0px");return e.lengths[i]=t,!w.size&&u(l)},w))),n.append(s,b),_.append(n)})}else if("font"===s){let e=l(n);if(!e)return _.append(o("span","palette-typed__hint","Custom expression · edit it as CSS below.")),void(x.open=!0);let a=o("div","palette-typed__sample"),p=o("b","","Aa"),r=o("span");a.setAttribute("aria-hidden","true"),a.append(p,r);let s=()=>{Object.assign(p.style,{fontStyle:e.style,fontWeight:e.weight,fontFamily:e.family}),r.textContent=[e.family?t(e.family):"Inherited family",e.weight,e.size+(e.lineHeight?`/${e.lineHeight}`:"")].filter(Boolean).join(" · ")},f=t=>(s(),c(i(e),t));s();let u=y.filter(t=>"fontFamily"===t.type&&t.value&&CSS.supports("font-family",t.value)&&t.value!==e.family),h=o("div","palette-typed__grid palette-typed__font");h.append(k("Font weight",[...new Set([e.weight||"400","100","200","300","400","500","600","700","800","900"])].map(e=>[e,e]),e.weight||"400",t=>{e.weight=t,f(!0)},t=>i({...e,weight:t}),"fontWeight"),d("Font size","Size",e.size,(t,l)=>(e.size=t,!w.size&&f(l)),w),d("Line height","LH",e.lineHeight,(t,l)=>(e.lineHeight=t,!w.size&&f(l)),w,{unitless:!0,optional:!0})),_.append(a,k("Font family",[[e.family,e.family?t(e.family):"Inherited family"],...u.map(e=>[e.value,e.label||t(e.value)])],e.family,t=>{e.family=t,f(!0)},t=>i({...e,family:t}),"fontFamily"),h)}else if(h?.values?.length)_.append(k(h.label,[...new Set([n,...h.values])].map(e=>[e,e]),n,e=>c(e,!0),e=>e));else{let t=e(n),l=/^(padding|margin|border-(width|radius)|gap)$/.test(s);if(t.length&&t.every(e=>a.test(e))&&(1===t.length||l&&t.length<=4)){let e=h?.label||s,l=1===t.length?[[e,""]]:"gap"===s?[["Row gap","Row"],["Column gap","Col"]]:"border-radius"===s?[["Top left","TL"],["Top right","TR"],["Bottom right","BR"],["Bottom left","BL"]]:[["Top","T"],["Right","R"],["Bottom","B"],["Left","L"]];if(t.length>1&&"gap"!==s){let[e,l=e,i=e,o=l]=t;t.splice(0,t.length,e,l,i,o)}let i=t.map((e,i)=>d(l[i][0],l[i][1],e,(e,l)=>(t[i]=e,!w.size&&c(t.join(" "),l)),w));if(i.length>1){let e=o("div","palette-typed__grid");e.append(...i),_.append(e)}else _.append(...i)}else _.append(o("span","palette-typed__hint","Custom expression · preserved exactly below.")),x.open=!0}}return S(f),S}function f(e,t){let{property:i}=e,a=e.custom.value,p=o("div","palette-custom"),n=o("div","palette-custom__body"),r=o("input");r.value=a,r.setAttribute("aria-label","CSS value");let d=!1,f=!1;p.append(o("style","",".palette-custom{display:flex;flex:1;flex-direction:column;min-height:0}.palette-custom__body{display:grid;gap:8px;padding:8px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-typed{display:grid;gap:6px;min-width:0}.palette-typed__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.palette-typed__field,.palette-typed__color,.palette-typed__menu{display:flex;align-items:center;box-sizing:border-box;width:100%;min-width:0;height:28px;border-radius:6px;background:#ffffff0a;box-shadow:none;color:#f1efeb;font:inherit;font-size:11px}.palette-typed__field:hover,.palette-typed__color:hover,.palette-typed__menu:hover{box-shadow:inset 0 0 0 1px #ffffff1c}.palette-typed__field:focus-within,.palette-typed__color:focus-visible,.palette-typed__menu:focus-visible{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-typed__field>span{flex:none;display:grid;place-items:center;min-width:24px;height:100%;padding:0 2px 0 6px;color:#77736f;font-size:10px;font-weight:500;cursor:ew-resize;user-select:none;touch-action:none}.palette-typed__field>span:hover{color:#e9e6e1}.palette-typed__field>span svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.1}.palette-typed__field input{flex:1;width:100%;min-width:0;height:100%;margin:0;padding:0 2px;border:0;border-radius:0;outline:0;box-shadow:none;background:none;color:inherit;font:inherit;font-variant-numeric:tabular-nums}.palette-typed__field input:focus,.palette-typed__field input:focus-visible,.palette-typed__field select:focus,.palette-typed__field select:focus-visible{outline:0;box-shadow:none}.palette-typed__field select{flex:none;width:auto;max-width:44px;height:100%;margin:0;padding:0 8px 0 2px;border:0;border-radius:0 6px 6px 0;box-shadow:none;appearance:none;background:none;color:#77736f;font:inherit;font-size:10px;text-align:right;cursor:pointer}.palette-typed__field select:hover{color:#f1efeb}.palette-typed__menu{padding:0 20px 0 8px;border:0;appearance:none;background:#ffffff0a url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1.5 3 4 5.5 6.5 3' fill='none' stroke='%23898680' stroke-width='1.2'/%3E%3C/svg%3E\") right 7px center/8px no-repeat;cursor:pointer}.palette-typed [aria-invalid=true]{color:#f8a898}.palette-typed__layer{display:grid;gap:6px}.palette-typed__layer[data-hidden] .palette-typed__grid{opacity:.45}.palette-typed__row{display:flex;align-items:center;gap:4px;min-width:0}.palette-typed__row>.palette-typed__menu{flex:none;width:64px}.palette-typed__row>.palette-typed__color{flex:1;gap:6px;padding:0 6px}.palette-typed__color .palette-typed__alpha{flex:none;margin-left:auto;color:#898680;font-size:10px}.palette-typed button.palette-typed__icon{display:grid;place-items:center;flex:none;width:24px;padding:0}.palette-typed__icon svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round}.palette-typed__tile{display:grid;place-items:center;height:56px;border-radius:6px;background:repeating-conic-gradient(#ffffff0a 0 25%,#ffffff04 0 50%) 0 0/12px 12px}.palette-typed__tile i{display:grid;place-items:center;width:32px;height:32px;border-radius:6px;background:#f1efeb;color:#f1efeb;font-style:normal;font-size:20px;font-weight:600}.palette-typed__tile i:not(:empty){width:auto;height:auto;background:none}.palette-typed__layer+.palette-typed__layer{padding-top:8px;border-top:1px solid #ffffff0d}.palette-typed__head{display:flex;align-items:center;gap:2px;min-height:24px}.palette-typed__head b{flex:1;color:#b5b1ab;font-size:10px;font-weight:500}.palette-typed button:not(.palette-typed__color,.palette-color *){height:24px;padding:0 8px;border:0;border-radius:5px;background:none;color:#898680;font:inherit;font-size:10px;cursor:pointer}.palette-typed button:not(.palette-typed__color,.palette-color *):hover{background:#ffffff14;color:#f1efeb}.palette-typed button[aria-pressed=true]{background:#bda6ef24;color:#e6dcfb}.palette-typed button:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px}.palette-typed__color{gap:8px;padding:0 8px;border:0;justify-content:flex-start;text-align:left;font-variant-numeric:tabular-nums;cursor:pointer}.palette-typed__color i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-typed__color span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-typed .palette-color{padding:0}.palette-typed__sample{display:flex;align-items:center;gap:8px;min-width:0;height:36px;padding:0 8px;border-radius:6px;background:#ffffff08}.palette-typed__sample b{flex:none;font-size:20px;font-weight:400}.palette-typed__sample span{overflow:hidden;color:#b5b1ab;text-overflow:ellipsis;white-space:nowrap}.palette-typed__hint{color:#898680;font-size:10px;line-height:1.5}.palette-custom .palette-typed__advanced>summary{display:flex;align-items:center;height:auto;min-height:24px;color:#77736f;font-size:10px;font-weight:500;list-style:none;cursor:pointer}.palette-typed__advanced>summary::-webkit-details-marker{display:none}.palette-custom .palette-typed__advanced>summary:hover{color:#e9e6e1}.palette-typed__advanced>summary:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px;border-radius:4px}@media (max-width:520px){.palette-typed__font{grid-template-columns:minmax(0,1fr)}}@media (pointer:coarse){.palette-typed__field,.palette-typed__color,.palette-typed__menu{height:36px}.palette-typed button:not(.palette-typed__color,.palette-color *){height:32px}}"),n);let u=s(n,i,a,r,(e,o)=>{if(f)return!1;d=!0;let a=!!e.trim()&&(CSS.supports(i,e)||"font"===i&&!!l(e))&&!/[{};]/.test(e);return r.setAttribute("aria-invalid",String(!a)),!!a&&(r!==r.getRootNode().activeElement&&(r.value=e),o?t.commit(e):t.preview(e),!0)},e.custom?.field,e.tokens,e=>{f||t.hover?.(e)});return Object.assign(p,{live:!0,destroy(){f=!0},refresh(e){if(d)return;let{selectionStart:t,selectionEnd:l}=r;u(e),null!==t&&null!==l&&r.setSelectionRange(t,l)}})}export{f as pickerEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e}from"./chunk-QALADLZS.js";import{e as t,t as n}from"./chunk-GAHDL7C2.js";var o=(e,t)=>`${t??""} ${e}`,i=e=>e.replace(/→/g,"->").replace(/\s+/g," ").trim()||"(unset)";function r(e){let n=[];for(let o of Array.isArray(e?.themes)?e.themes:[])if(Array.isArray(o?.options)&&!(o.options.length<2))try{n.push(String(o.current(t())))}catch{}return n.length?n.join("+"):void 0}function a(e,n={}){let i,r=()=>!!n.before?.(),a=new Map,s=[],l=[],d="",p=o=>{let r=o.map(({path:e,value:t,theme:n,alias:o})=>({path:e,value:t,...n?{theme:n}:{},...o?{alias:o}:{}})),a=n.theme?.(),s=r.length?JSON.stringify([a,r]):"";if(s===d)return;let l=i;i=void 0,d=s;try{l?.()}catch{}if(r.length&&e.previewValues)try{i=e.previewValues(r,a,t())}catch{}},c=()=>p(r()?[]:[...a.values()]),g=e=>[...a].filter(([t])=>t!==e).map(([,e])=>e);return{get size(){return a.size},get canUndo(){return s.length>0},get steps(){return s},list:()=>[...a.values()],get:(e,t)=>a.get(o(e,t)),set(e){let t=o(e.path,e.theme),n=a.get(t);return(n?.to??e.from)!==e.to&&(s.push({key:t,edit:n}),l.length=0,e.to===e.from?a.delete(t):a.set(t,e),c(),!0)},preview:e=>(p(r()?[]:[...g(o(e.path,e.theme)),...e.to===e.from?[]:[e]]),c),undo(){let e=s.pop();e&&(l.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},redo(){let e=l.pop();e&&(s.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},reset(e,t){let n=o(e,t);a.delete(n);for(let e=s.length;e--;)s[e].key===n&&s.splice(e,1);c()},resetAll(){a.clear(),s.length=0,c()},sync:c,stop(){a.clear(),s.length=0,p([])}}}function s(e,t){if(e.length)return["Proposed token changes (preview only)",...e.map(e=>`Token: ${e.path}${e.theme?` (${e.theme})`:""} ${i(e.from)} → ${i(e.to)}`),`Token adapter: ${t}`].join("\n")}function l(e){return e.map(({path:e,theme:t,from:n,to:o})=>({kind:"token-value",path:e,...t?{theme:t}:{},from:n,to:o}))}var d={color:"color",dimension:"width",fontFamily:"font-family",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",shadow:"box-shadow",typography:"font",duration:"transition-duration"},p=e=>"typography"===e.type?"font":e.properties?.[0]??d[e.type]??"--token",c=".design-inspector[data-tokens] .design-inspector__identity{visibility:visible}.design-inspector[data-tokens] .design-inspector__controls{display:flex;flex-direction:column;place-items:stretch;overflow:hidden}.design-inspector[data-tokens] .design-inspector__parent{display:none}.design-inspector[data-tokens]>.design-inspector__bar:not(.design-token-bar),.design-inspector[data-tokens] .design-inspector__pending,.design-inspector:not([data-tokens])>.design-token-bar{display:none}.design-token-page{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;height:min(520px,calc(100dvh - 190px))}:host([data-sidebar=background]) .design-token-page{height:auto}.design-token-page>.palette-tokens__bar{flex:none;padding:0 12px 8px;background:none;border:0}.design-token-page>p{margin:0 12px 8px;color:#e7c27d;font-size:11px}.design-token-page>p[hidden]{display:none}.design-token-page__list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 8px 8px}.design-token-page__list small{position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#0d0d0d;color:#77736f;font-size:10px;font-weight:500}.design-token-page__list>p{margin:0;padding:12px 8px;color:#77736f}.design-token-row{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 24px;align-items:center;gap:2px;border-radius:7px}.design-token-row:hover{background:#ffffff0a}.design-token-row>button{border:0;background:none;color:inherit;font:inherit}.design-token-row>button:first-child{display:grid;grid-template-columns:20px minmax(0,1fr) auto;align-items:center;gap:8px;min-width:0;min-height:32px;padding:6px 8px;border-radius:7px;color:#d9d6d1;text-align:left}.design-token-row b{overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.design-token-row i{max-width:110px;overflow:hidden;color:#77736f;font-style:normal;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.design-token-row[data-changed] b{color:#e6dcfb}.design-token-row[data-changed]::before{content:'';position:absolute;top:calc(50% - 2px);left:-2px;width:4px;height:4px;border-radius:50%;background:#bda6ef}.design-token-row>button+button{display:grid;place-items:center;width:24px;height:24px;padding:0;border-radius:5px;color:#77736f}.design-token-row>button+button:disabled{visibility:hidden}.design-token-row>button+button:hover{background:#ffffff14;color:#f1efeb}.design-token-row svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.design-token-row .palette-tokens{font-size:11px}@media (pointer:coarse){.design-token-row>button:first-child{min-height:44px}.design-token-row>button+button{width:32px;height:32px}}",g=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="${e}"/></svg>`,u=g("M2.5 2.5v3h3M3 5.5a5.5 5.5 0 1 1-.5 2.5"),h=g("M5.5 3.5 2.5 6.5l3 3m-3-3h7a4 4 0 0 1 0 8h-2"),f=new WeakMap;async function k(o,i){let l=await Promise.all([import("./token-picker-76CU4ZP5.js"),import("./react-props-panel-IUOMUL2Z.js"),import("./design-export-5QM7HHRT.js")]),d=f.get(o);d||f.set(o,d=function(o,i,[l,d,g]){let k=i.design?.tokens??d.cssVariableTokens(),m="function"==typeof k.previewValues,v=()=>o.hasAttribute("data-before"),y=a(k,{before:v,theme:()=>r(i.design)}),w=b("style");w.textContent=c,i.root.append(w),l.stylePicker(o);let x=b("section","design-token-page");x.setAttribute("aria-label","Tokens");let _=b("p","","No live preview · edits are recorded as proposals");_.hidden=m;let A=b("div","palette-tokens__bar"),C=b("input");C.type="search",C.placeholder="Search tokens",C.autocomplete="off",C.spellcheck=!1,C.setAttribute("aria-label","Search tokens"),A.append(C);let L=b("div","design-token-page__list");x.append(_,A,L);let $=(e,t)=>{let n=t.getBoundingClientRect(),i=o.getBoundingClientRect();i.left-16>e.offsetWidth?(e.style.left=i.left-8-e.offsetWidth/2+"px",e.style.top=`${n.top+(n.height-e.offsetHeight)/2}px`):i.top-16>e.offsetHeight&&(e.style.top=i.top-8-e.offsetHeight+"px")},E=b("div","design-inspector__bar design-token-bar"),S=b("span","design-inspector__count"),T=b("div","design-inspector__compare");T.setAttribute("role","group"),T.setAttribute("aria-label","Compare with the page");let M=["Before","After"].map((e,t)=>{let n=b("button","",e);return n.type="button",n.dataset.tip=`${e} · ${t?"→":"←"} or B`,n.addEventListener("click",()=>W(!t)),T.append(n),n}),P=b("p","design-inspector__status");P.setAttribute("role","status");let z=b("div","design-inspector__actions"),j=(e,t,n)=>{let o=b("button","design-inspector__tool");return o.type="button",o.dataset.tip=e,o.setAttribute("aria-label",e),o.innerHTML=t,o.addEventListener("click",()=>{W(!1),n(),Z()}),o},H=j("Undo",h,()=>y.undo()),B=j("Reset all",u,()=>y.resetAll()),U=b("button","","Comment");U.type="button";let N=()=>s(y.list(),k.id),R=()=>{y.resetAll(),Z()};U.addEventListener("click",()=>{let e=N();e&&(R(),i.onComment(t().document.body,e))}),z.append(H,B,U),E.append(S,T,P,z);let O,V=[],q=0,K=new Map;function W(e){e!==v()&&o.querySelectorAll(".design-inspector__bar:not(.design-token-bar) .design-inspector__compare button")[e?0:1]?.click(),y.sync(),D()}function D(){let e=y.size;S.textContent=e?`${e} change${e>1?"s":""}`:"",E.toggleAttribute("data-changes",e>0||y.canUndo),H.disabled=!y.canUndo,B.disabled=U.disabled=!e,T.hidden=!m||!e&&!v(),M.forEach((e,t)=>e.setAttribute("aria-pressed",String(!t===v()))),e?o.dataset.tokenEdits=String(e):delete o.dataset.tokenEdits,oe?.()}function Z(){for(let e of K.values())e();D()}let F=e=>{let t=V.find(t=>t.path===e);return t?l.tokenLabel(t):e};function I(e,t){let n=r(i.design),o=y.get(e.path,n),a=e.alias?`{${e.alias}}`:e.value,s=(t,o)=>({path:e.path,value:t,from:a,to:o?`{${o}}`:t,...n?{theme:n}:{},...o?{alias:o}:{}}),d=e=>{y.set(e)&&Z()},c=e.alias?V.filter(t=>t.type===e.type&&t.path!==e.path&&t.alias!==e.path):[];l.openTokenPicker({trigger:t,tokens:c,property:p(e),title:l.tokenLabel(e),current:o?o.alias:e.alias,onPreview:e=>y.preview(s(e.value,e.path)),onSelect:e=>d(s(e.value,e.path)),custom:{value:o?.value??e.value,onPreview:e=>y.preview(s(e)),onSelect:e=>d(s(e))}},!0)}let J=new Map;function Q(e){let t=()=>J.get(e.path)??e,n=b("div","design-token-row"),o=b("button");o.type="button",o.setAttribute("aria-haspopup","dialog");let a=b("b","",l.tokenLabel(e)),s=b("i"),d=b("button");d.type="button",d.title="Reset to page value",d.setAttribute("aria-label",`Reset ${e.path}`),d.innerHTML=u,n.append(o,d);let p=()=>{let e=t();a.textContent=l.tokenLabel(e);let p=y.get(e.path,r(i.design)),c=p?p.alias:e.alias,g=p?.value??e.value;s.textContent=c?F(c):g,o.replaceChildren(l.tokenPreview({...e,value:g}),a,s),o.dataset.tip=[e.path,e.ref,c?`${c} · ${g}`:g,e.description].filter(Boolean).join(" · "),o.setAttribute("aria-label",`${a.textContent}, ${s.textContent}${p?", edited":""}`),n.toggleAttribute("data-changed",!!p),d.disabled=!p};return o.addEventListener("click",()=>I(t(),o)),d.addEventListener("click",()=>{W(!1),y.reset(e.path,r(i.design)),Z(),o.focus({preventScroll:!0})}),K.set(e.path,p),p(),n}let G="";function X(){for(let e of V)J.set(e.path,e);let e=C.value.toLowerCase().split(/\s+/).filter(Boolean),t=new Map([["",[]]]);for(let n of V){let o=y.get(n.path,r(i.design))?.to??n.value,a=`${l.tokenLabel(n)} ${n.path} ${n.ref??""} ${o}`.toLowerCase();if(!e.every(e=>a.includes(e)))continue;let s=n.group??"";t.set(s,[...t.get(s)??[],n])}let n=JSON.stringify([...t].map(([e,t])=>[e,t.map(e=>e.path)]));if(n===G&&K.size)return Z();G=n,K.clear(),L.replaceChildren();let a=0;for(let[e,n]of t){if(!n.length)continue;let t=L;if(e){t=b("div"),t.setAttribute("role","group");let n=b("small","",e);n.id="design-token-group-"+ ++a,t.setAttribute("aria-labelledby",n.id),t.append(n),L.append(t)}for(let e of n)t.append(Q(e))}K.size||L.append(b("p","",e.length?"No matching tokens":"No tokens"));let s=o.querySelector(".design-inspector__identity small");s&&(s.textContent=`${V.length} token${1===V.length?"":"s"}`),D()}async function Y(){let e=++q,t=[];try{t=await d.listTokens(k,d.themeState(i.design))}catch{P.textContent="Tokens unavailable · try again"}y.sync(),e===q&&x.isConnected&&(V=t,X())}function ee(){O?.abort(),O=void 0,o.removeAttribute("data-tokens"),E.remove()}let te=new AbortController;new MutationObserver((e,t)=>{if("true"===o.getAttribute("aria-hidden")&&d.restoreThemes(o),o.isConnected)return y.sync(),D();t.disconnect(),te.abort(),ee(),y.stop(),oe?.(),w.remove(),f.delete(o)}).observe(o,{attributes:!0,attributeFilter:["data-before","aria-hidden"]}),i.root.addEventListener("palette-theme-change",()=>y.sync(),{signal:te.signal}),C.addEventListener("input",X);let ne={open(){let t=o.querySelector(".design-inspector__controls");if(t){if(!x.isConnected){O=new AbortController;let{signal:r}=O;o.toggleAttribute("data-tokens",!0),t.replaceChildren(x),o.append(E);let a=o.querySelector(".design-inspector__target");a&&(a.textContent="Tokens");let s=new MutationObserver(()=>{x.isConnected||ee()});s.observe(t,{childList:!0}),r.addEventListener("abort",()=>s.disconnect(),{once:!0}),d.attachThemeSwitcher(x,i.design,()=>{Y()},i.root,r),i.root.addEventListener("palette-theme-change",()=>{Y()},{signal:r});let l=!1,p=e=>{l||g.footerTips(E,i.root,r,e),l=!0};E.addEventListener("pointerover",p,{signal:r}),E.addEventListener("focusin",p,{signal:r});let c=!1,u=e=>{c||g.footerTips(L,i.root,r,e,$),c=!0};L.addEventListener("pointerover",u,{signal:r}),L.addEventListener("focusin",u,{signal:r});let h=t=>{let n=t.key.toLowerCase(),o=t.composedPath()[0];T.hidden||t.metaKey||t.ctrlKey||t.altKey||!["b","arrowleft","arrowright"].includes(n)||e(o)||"b"!==n&&o.matches?.("input,select,[role=slider],[role=radio]")||(t.preventDefault(),t.stopImmediatePropagation(),W("b"===n?!v():"arrowleft"===n))};document.addEventListener("keydown",h,{capture:!0,signal:r}),n("keydown",h,{capture:!0,signal:r}),X(),Y()}globalThis.matchMedia?.("(pointer:coarse)")?.matches||C.focus({preventScroll:!0})}}},oe=i.link?.({get size(){return y.size},get steps(){return y.steps},undo(){y.undo(),Z()},redo(){y.redo(),Z()},reset:R,proposal:N,open:ne.open});return ne}(o,i,l)),d.open()}function b(e,t="",n){let o=document.createElement(e);return o.className=t,void 0!==n&&(o.textContent=n),o}export{k as openTokenPage,r as themeKey,a as tokenEdits,s as tokenProposal,l as tokenValueChanges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e,o as t}from"./chunk-TJBTE5VK.js";import{a as o,b as n,c as i}from"./chunk-PF4NYFZK.js";import"./chunk-4FX5IS2U.js";import"./chunk-XOMOONGK.js";import{j as l}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var r,a={font:"Typography","box-shadow":"Shadow","text-shadow":"Text shadow"},s=new WeakSet,p=0;function d(e){return e.label||e.path.slice(e.path.lastIndexOf(".")+1)||e.path}var c=(e,t,o)=>Math.min(o,Math.max(t,e));function f(e){let t=l("span","palette-tokens__pv");t.setAttribute("aria-hidden","true");let o=e=>{let o=l("span",`palette-tokens__${e}`);return t.append(o),o},n=e.value??"",{type:i}=e;if("color"===i){let e=o("sw"),t=l("span");u(n)?t.style.background=n:(t.dataset.unresolved="",t.textContent="?"),e.append(t)}else if("dimension"===i||"letterSpacing"===i){let i=function(e){let t=/^(-?[\d.]+)(px|r?em)?$/.exec(e.trim());return t?parseFloat(t[1])*(t[2]?"px"===t[2]?1:16:1):void 0}(n);if(void 0===i)return t;let l=/radius/.test(`${e.path} ${e.properties?.join(" ")}`),r=o(l?"corner":"dim");l?r.style.borderTopLeftRadius=`${c(i,0,12)}px`:r.style.width=`${c(i/2,2,24)}px`}else if("shadow"===i)o("shadow").style.boxShadow=n;else if("typography"===i||"fontWeight"===i||"fontFamily"===i){let e=o("ag");e.textContent="Ag","typography"===i?(e.style.font=n,e.style.fontSize="13px",e.style.lineHeight="1"):"fontWeight"===i?e.style.fontWeight=n:e.style.fontFamily=n}return t}function u(e){if(!e||/var\(/i.test(e))return!1;let t=l("span").style;return t.color=e,!!t.color}function h(e,o,n,i){let r=l("div");r.id=o,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(n));let a=l("span","palette-tokens__name"),s=l("span","",d(e));a.append(s);let p=l("span","palette-tokens__check");p.setAttribute("aria-hidden","true");let c="color"===e.type&&!u(e.value),h=i.flatMap(t=>{let o=t.values.get(e.path);return o&&"color"===e.type?[`${t.label} ${o}`]:[]}),g=h.length>1?h.join(", "):e.value??"",m=l("span","palette-tokens__sub",[e.path,g].filter(Boolean).join(" · "));return m.setAttribute("aria-hidden","true"),r.append(f(e),a,p,m),r.setAttribute("aria-label",[e.label,t(e,g,c?"Unresolved; no swatch available":"")].filter(Boolean).join(" · ")),r}function g(e){let t=e.getRootNode();if((t instanceof ShadowRoot||t===document)&&!s.has(t)){s.add(t);let e=l("style");e.textContent=o+".palette-tokens{display:flex;flex-direction:column;overflow:hidden}.palette-tokens__head{flex:none;display:flex;align-items:center;gap:4px;min-height:36px;padding:0 12px;color:#f1efeb;font-weight:500}.palette-tokens__back{display:grid;place-items:center;width:20px;height:20px;margin-left:-6px;padding:0;border:0;border-radius:5px;background:none;color:#898680;cursor:pointer}.palette-tokens__back:hover{background:#ffffff14;color:#f1efeb}.palette-tokens__back svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.palette-tokens__bar{flex:none;display:flex;gap:4px;padding:0 8px 8px;background:#232323;border-bottom:1px solid #ffffff0d}.palette-tokens__bar input{flex:1;min-width:0;height:28px;box-sizing:border-box;margin:0;padding:0 8px;border:0;border-radius:6px;outline:0;box-shadow:none;background:#ffffff0a;color:#f1efeb;font:inherit}.palette-tokens__bar input:focus{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-tokens__widen{flex:none;height:28px;margin:0 4px 4px;padding:0 8px;border:0;border-radius:6px;background:none;color:#898680;font:inherit;text-align:left;cursor:pointer}.palette-tokens__widen:hover,.palette-tokens__more:hover{background:#ffffff0f;color:#f1efeb}.palette-tokens__more{flex:none;display:flex;align-items:center;gap:8px;min-height:36px;padding:0 12px;border:0;border-top:1px solid #ffffff0d;background:none;color:#d9d6d1;font:inherit;text-align:left;cursor:pointer}.palette-tokens__more b{margin-right:auto;font-weight:500}.palette-tokens__more i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-tokens__more span{max-width:50%;overflow:hidden;color:#898680;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [role=listbox]{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 4px 4px}.palette-tokens small:not(.palette-select *){position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#232323;color:#77736f;font-size:10px;font-weight:500}.palette-tokens [role=option]:not(.palette-select *){display:grid;grid-template-columns:20px minmax(0,1fr) 14px;align-items:center;gap:4px 8px;box-sizing:border-box;min-height:32px;padding:6px 8px;border-radius:7px;cursor:pointer}.palette-tokens [data-active]{background:#ffffff14;color:#f1efeb}.palette-tokens [aria-selected=true] .palette-tokens__name{color:#e6dcfb}.palette-tokens__name{grid-column:2;min-width:0;font-weight:500}.palette-tokens__name>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-tokens__sub{grid-column:2/4;display:none;min-width:0;overflow:hidden;color:#77736f;font-size:10px;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [data-active] .palette-tokens__sub{display:block}.palette-tokens__check{grid-column:3;justify-self:center}.palette-tokens [aria-selected=true] .palette-tokens__check{width:7px;height:3.5px;margin-top:-3px;border:solid #bda6ef;border-width:0 0 1.5px 1.5px;rotate:-45deg}.palette-tokens__pv{display:flex;align-items:center;height:16px;overflow:hidden}.palette-tokens__sw{display:flex;width:16px;height:16px;border-radius:4px;overflow:hidden;background:repeating-conic-gradient(#ffffff40 0 25%,#ffffff0d 0 50%) 0 0/8px 8px;outline:1px solid #ffffff1f;outline-offset:-1px}.palette-tokens__sw>span{flex:1}.palette-tokens__sw>[data-unresolved]{display:grid;place-items:center;background:#393939;color:#b6b1aa;font-size:10px}.palette-tokens__dim{height:4px;min-width:2px;border-radius:2px;background:#bda6ef}.palette-tokens__corner{width:12px;height:12px;box-sizing:border-box;border:solid #bda6ef;border-width:1.5px 0 0 1.5px}.palette-tokens__shadow{width:16px;height:12px;margin-left:2px;border-radius:3px;background:#f1efeb}.palette-tokens__ag{color:#f1efeb;font-size:13px;line-height:1;white-space:nowrap}.palette-tokens__empty{padding:12px 8px;color:#77736f}@media (pointer:coarse){.palette-tokens{font-size:13px}.palette-tokens [role=option]:not(.palette-select *){min-height:44px}.palette-tokens__bar input,.palette-tokens__bar button{height:36px}}.palette-tokens__custom{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-tokens__custom>.palette-custom{flex:none}.palette-tokens__custom .palette-custom__body{overflow:visible}.palette-tokens [hidden]{display:none!important}.palette-tokens button:focus-visible,.palette-tokens [role=listbox]:focus-visible{outline:1px solid #bda6ef;outline-offset:-2px}.palette-tokens[popover]{position:fixed;inset:auto;margin:0;border:0;padding:0}",(t instanceof ShadowRoot?t:document.head).append(e)}return t}function m(e,t){r?.trigger===e&&r.refresh(t)}function b(t,o=!1){let s=t.trigger.dataset.start;if(delete t.trigger.dataset.start,o&&r?.trigger===t.trigger)return r.close(!0);r?.close();let{trigger:f,property:u}=t,m=t.tokens,b=g(f),x="palette-tokens-"+ ++p,k=/color|^(fill|stroke)$/.test(u),v=l("div","palette-tokens");v.id=`${x}-popup`,v.setAttribute("role","dialog"),v.setAttribute("aria-label",`Edit ${u}`);let _=l("div","palette-tokens__head"),w=l("button","palette-tokens__back");w.type="button",w.setAttribute("aria-label","Back to tokens"),w.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M7.5 2.5 4 6l3.5 3.5"/></svg>';let y=l("span","",t.title||t.custom?.field?.label||a[u]||u);_.append(w,y);let A=l("div","palette-tokens__bar"),E=l("input");E.type="text",E.placeholder="Search tokens",E.autocomplete="off",E.spellcheck=!1,E.setAttribute("role","combobox"),E.setAttribute("aria-expanded","true"),E.setAttribute("aria-controls",x),E.setAttribute("aria-autocomplete","list"),E.setAttribute("aria-label",`Search tokens for ${u}`);let $=l("div","palette-tokens__list");$.id=x,$.tabIndex=0,$.setAttribute("role","listbox"),$.setAttribute("aria-label",`Tokens for ${u}`);let S=e(m,u),L=!S.length,C=l("button","palette-tokens__widen");C.type="button",A.append(E);let T=l("button","palette-tokens__more");T.type="button";let M=l("i"),H=l("span");T.append(l("b","","Custom…"),M,H);let P=l("div","palette-tokens__custom");v.append(_,A,$,C,T),t.custom&&v.append(P);let j,z,R,B,D=()=>new Map(m.map(e=>[e,`${d(e)} ${e.path} ${e.ref??""} ${e.value??""}`.toLowerCase()])),I=D(),U=[],K=[],N=0,F=-1,O=$,W=-1,q=!1,Q=!1,Z=!1,G=()=>{let e=z;z=void 0,W=-1,e?.()},V=e=>{G(),R=e,z=t.custom?.onPreview(e)},X=()=>{W<0||(G(),void 0!==R&&V(R))},J=()=>!t.custom||!!S.length,Y=()=>{let e=J()&&!Z,o=L||E.value?m:S;$.hidden=A.hidden=!e,E.hidden=!e||!Q&&o.length<=8&&!E.value,A.hidden||=E.hidden,C.hidden=!e||!!E.value||!S.length||S.length===m.length,C.textContent=L?"Show relevant tokens":`Show all ${m.length} tokens`,C.setAttribute("aria-pressed",String(L)),T.hidden=!e||!t.custom,P.hidden=e,w.hidden=!Z||!J(),y.textContent=Z&&J()?k?"Custom colour":"Custom value":t.title||t.custom?.field?.label||a[u]||u,v.toggleAttribute("data-custom",!e);let n=t.custom?.value??"",i=/^rgba?\((\d+)[ ,]+(\d+)[ ,]+(\d+)(?:[ ,/]+([\d.]+))?/.exec(n);H.textContent=k?i?i.slice(1,4).map(e=>Number(e).toString(16).padStart(2,"0")).join("").toUpperCase()+(i[4]&&+i[4]<1?` ${Math.round(100*+i[4])}%`:""):n.replace(/^#/,"").toUpperCase():n,M.hidden=!k||!n,M.style.setProperty("--c",n),T.title=n},ee=e=>{for(;N<Math.min(e,K.length);N++){let{token:e,group:o}=K[N];if(o!==j&&(j=o,O=$,o)){O=l("div"),O.setAttribute("role","group");let e=l("small");e.id=`${x}-g${N}`,e.textContent=o,O.setAttribute("aria-labelledby",e.id),O.append(e),$.append(O)}O.append(h(e,`${x}-${N}`,e.path===t.current,U))}},te=e=>$.querySelector(`#${x}-${e}`),oe=(e,o=!0,n=!0)=>{if(e<0||e>=K.length)return;if(e!==W&&n){G(),W=e;let o=K[e].token;o.path!==t.current&&(z=t.onPreview?.(o))}ee(e+60),te(F)?.removeAttribute("data-active"),F=e;let i=te(e);if(i.toggleAttribute("data-active",!0),E.setAttribute("aria-activedescendant",i.id),$.setAttribute("aria-activedescendant",i.id),!o)return;let l=i.offsetTop-(i.parentElement===$?0:i.parentElement.firstElementChild.offsetHeight),r=i.offsetTop+i.offsetHeight;l<$.scrollTop?$.scrollTop=l-4:r>$.scrollTop+$.clientHeight&&($.scrollTop=r-$.clientHeight+4)},ne=(e=!1,t=!1)=>{let o=t?K[F]?.token.path:void 0,n=$.scrollTop,i=t?N:60;W>=0&&G();let r=E.value.toLowerCase().split(/\s+/).filter(Boolean),a=L||r.length?m:S,s=r.length?a.filter(e=>r.every(t=>I.get(e).includes(t))):a,p=L?s:[...s.filter(e=>S.includes(e)),...s.filter(e=>!S.includes(e))],d=new Map([["",[]]]);for(let e of p){let t=e.group??"";d.set(t,[...d.get(t)??[],e])}if(K=[...[...d].flatMap(([e,t])=>t.map(t=>({token:t,group:e})))],$.replaceChildren(),$.scrollTop=0,N=0,F=-1,j=void 0,E.removeAttribute("aria-activedescendant"),$.removeAttribute("aria-activedescendant"),Y(),!K.length){let e=l("div","palette-tokens__empty",r.length?"No matching tokens":"No tokens");return void $.append(e)}ee(i),oe(Math.max(0,K.findIndex(e=>e.token.path===o)),!1,e),t&&($.scrollTop=n)},ie=new AbortController,{signal:le}=ie,re=!!globalThis.matchMedia?.("(pointer:coarse)")?.matches;function ae(e=!1,o=!1){if(r?.close!==ae)return;r=void 0;let n=B?.live&&R;G(),n&&!o&&(t.custom?.onCommit??t.custom?.onSelect)?.(n),t.custom?.[o?"onCancel":"onDone"]?.(),ie.abort(),B?.destroy(),v.remove(),f.setAttribute("aria-expanded","false"),f.removeAttribute("aria-controls"),e&&f.isConnected&&f.focus({preventScroll:!0})}r={trigger:f,close:ae,refresh(o){if(!o)return q||=W>=0,G();let n=q||W>=0;q=!1,t=o,m=o.tokens,S=e(m,u),I=D(),U=[],ne(n&&!Z,!0),t.current&&t.custom&&B?.refresh(t.custom.value),W<0&&!z&&void 0!==R&&V(R),ve()}};let se=e=>{G(),R=void 0,t.custom?.onCancel?.(),ae(!0),e.path!==t.current&&t.onSelect(e)},pe=t.custom?k?import("./color-editor-BRURQZA7.js"):import("./token-custom-QUDSPT6I.js"):void 0;function de(e,o=!re){X(),Z=e,Y(),ge="",me(),Z?async function(e){let o=await pe;if(r?.close!==ae)return;B||(B=o.pickerEditor(t,{preview:V,commit(e){if(!t.custom?.onCommit)return V(e);G(),R=void 0,t.custom.onCommit(e)},token:se,hover(e){G(),void 0!==e?z=t.custom?.onPreview(e):void 0!==R&&V(R)}}),P.append(B)),ge="",me();let n=!!v.getClientRects().length,i=[...v.querySelectorAll("input,select,summary,button")].filter(e=>(!n||e.getClientRects().length)&&!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)"));e&&(i.find(e=>e instanceof HTMLInputElement&&P.contains(e))??i[0])?.focus({preventScroll:!0})}(o):o&&(E.hidden?T:E).focus({preventScroll:!0})}let ce=e=>{let t=K[e]?.token;t&&se(t)};T.addEventListener("click",()=>de(!0),{signal:le}),w.addEventListener("click",()=>de(!1),{signal:le}),E.addEventListener("input",()=>ne(!0),{signal:le}),C.addEventListener("click",()=>{L=!L,ne(!0),re||(E.hidden?$:E).focus({preventScroll:!0})},{signal:le}),addEventListener("keydown",e=>{if(!f.isConnected)return ae();let t=e.composedPath();if(!t.includes(v)&&!t.includes(f))return;let{key:o}=e,n={ArrowDown:1,ArrowUp:-1,PageDown:8,PageUp:-8}[o];if(!(e.ctrlKey||e.metaKey||e.altKey||"Escape"===o&&t[0]instanceof HTMLSelectElement&&t[0]!==f&&"true"===t[0].getAttribute("aria-expanded"))){if("Escape"===o)ae(!0,!0);else if("Tab"===o){let o=[...v.querySelectorAll("button,input,select,summary,[tabindex='0']")].filter(e=>!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)")&&e.getClientRects().length);if(t[0]!==o[e.shiftKey?0:o.length-1])return;o[e.shiftKey?o.length-1:0]?.focus()}else if(t[0]===T&&"ArrowUp"===o&&K.length)$.focus({preventScroll:!0}),oe(K.length-1);else{if($.hidden||t[0]!==E&&t[0]!==f&&t[0]!==$)return;if(n>0&&t[0]===$&&F===K.length-1&&!T.hidden)X(),T.focus({preventScroll:!0});else if(n)oe(c(F+n,0,K.length-1));else if("Home"!==o&&"End"!==o||t[0]===E)if("Enter"===o)ce(F);else{if(t[0]!==$||1!==o.length||" "===o)return;Q=!0,E.value+=o,ne(!0),E.focus({preventScroll:!0})}else oe("Home"===o?0:K.length-1)}e.preventDefault(),e.stopImmediatePropagation()}},{capture:!0,signal:le}),addEventListener("pointerdown",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le}),addEventListener("focusin",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le});let fe=e=>{e.target===$?$.scrollTop+$.clientHeight>$.scrollHeight-200&&ee(N+60):e.target instanceof Node&&v.contains(e.target)||ae()};addEventListener("scroll",fe,{capture:!0,signal:le}),b.addEventListener("scroll",fe,{capture:!0,signal:le}),addEventListener("resize",()=>ae(),{signal:le}),i(f,()=>ae(),le),$.addEventListener("mousedown",e=>e.preventDefault(),{signal:le});let ue=e=>{let t=e.target.closest?.("[role=option]");return t&&$.contains(t)?Number(t.id.slice(x.length+1)):-1};$.addEventListener("pointermove",e=>{let t=ue(e);t>=0&&oe(t,!1)},{signal:le}),$.addEventListener("pointerleave",X,{signal:le}),T.addEventListener("focusin",X,{signal:le}),P.addEventListener("focusin",X,{signal:le}),v.addEventListener("click",e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLButtonElement||e.preventDefault();let t=ue(e);t>=0&&ce(t)},{signal:le}),ne();let he=f.closest(".design-field")??f.parentElement;v.popover="manual",he.append(v),v.showPopover?.(),he.addEventListener("palette-field-sync",()=>{z||!t.custom||(B?.refresh(t.custom.value),Y())},{signal:le}),f.setAttribute("aria-expanded","true"),f.setAttribute("aria-controls",v.id);let ge="",me=()=>{let e=he.getBoundingClientRect();if(ge===`${e.left} ${e.top}`)return;ge=`${e.left} ${e.top}`;let t=n(he),o=c(t.right-t.left-8,120,256),i=innerHeight-e.bottom-12,l=e.top-12;v.style.maxHeight="";let r=i<Math.min(460,Math.max(v.scrollHeight,200))&&l>i,a=Math.min(460,innerHeight-16,Math.max(r?l:i,200));v.style.width=`${o}px`,v.style.maxHeight=`${a}px`,v.style.left=`${c(e.left,t.left+4,t.right-o-4)}px`,v.style.top=r?"":`${Math.min(e.bottom+4,innerHeight-8-a)}px`,v.style.bottom=r?`${Math.min(innerHeight-e.top+4,innerHeight-8-a)}px`:"",v.toggleAttribute("data-up",r)};me();let be=new MutationObserver(me);be.observe(b,{attributes:!0,childList:!0,subtree:!0}),le.addEventListener("abort",()=>be.disconnect());let xe=K.findIndex(e=>e.token.path===t.current);xe>=0&&oe(xe,!0,!1),!J()||"custom"===s&&t.custom?de(!0):re||(E.hidden?$:E).focus({preventScroll:!0,focusVisible:!1});let ke=0;function ve(){let e=++ke;Promise.resolve(t.themes?.()).then(t=>{!t||t.length<2||r?.close!==ae||e!==ke||(U=t,$.hidden||ne(W>=0,!0))},()=>{})}return ve(),()=>ae()}export{b as openTokenPicker,m as refreshTokenPicker,g as stylePicker,d as tokenLabel,f as tokenPreview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as t,c as r,m as n,n as i,o}from"./chunk-LMXFSXO6.js";import{b as a,c as l}from"./chunk-VX6XCU4E.js";import{c,i as u,m as s,p as d}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";import{a as m,b as p,c as h,d as f}from"./chunk-GGU2XLWE.js";import{createRoot as g}from"react-dom/client";import{flushSync as y}from"react-dom";import{createElement as b}from"react";import*as v from"react";var k=({size:e=24,color:t="currentColor",...r})=>v.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},v.createElement("path",{d:"M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm7 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}));k.displayName="DotsHorizontal";import*as _ from"react";var w=({size:e=24,color:t="currentColor",...r})=>_.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},_.createElement("path",{d:"M18 6 6 18M6 6l12 12"}));w.displayName="XClose";import*as x from"react";var N=({size:e=24,color:t="currentColor",...r})=>x.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},x.createElement("path",{d:"M19 12H5m0 0 7 7m-7-7 7-7"}));N.displayName="ArrowLeft";import*as T from"react";var E=({size:e=24,color:t="currentColor",...r})=>T.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},T.createElement("path",{d:"m9 18 6-6-6-6"}));E.displayName="ChevronRight";import{useEffect as L,useId as C,useLayoutEffect as M,useRef as A,useState as S}from"react";import{useState as $}from"react";import{Fragment as j,jsx as B,jsxs as P}from"react/jsx-runtime";function I({items:l,bar:c,defaultActiveId:s,activeId:d,edge:g="bottom",alignEnd:y=!1,onActiveChange:b,label:v="App navigation",moreLabel:_="More",backLabel:x="Back",className:T="",style:E}){let I=C(),[O,R]=S({kind:"collapsed"}),[z,X]=S(s??l[0]?.id),[K,q]=S(null),Y=A(null),F=A(null),Z=A(g),G="left"===g||"right"===g;M(()=>{let e=F.current;if(!e||!K)return;let t=0,r=0,n=document.documentElement.clientWidth,i=window.innerHeight;for(let o=e.parentNode;o instanceof Element&&o!==document.body;o=o.parentNode instanceof ShadowRoot?o.parentNode.host:o.parentNode){let e=getComputedStyle(o),a=o.getBoundingClientRect();"visible"!==e.overflowX&&(t=Math.max(t,a.left),n=Math.min(n,a.right)),"visible"!==e.overflowY&&(r=Math.max(r,a.top),i=Math.min(i,a.bottom))}e.style.maxWidth=`${Math.max(0,n-t-16)}px`,e.style.left=`${K.x}px`,e.style.top=`${K.y}px`;let o=e.getBoundingClientRect(),a=Math.max(t+8-o.left,Math.min(0,n-8-o.right)),l=Math.max(r+8-o.top,Math.min(0,i-8-o.bottom));e.style.left=`${K.x+a}px`,e.style.top=`${K.y+l}px`},[K]);let U=A(null),Q=A(null),V=A(O),J=A("more"),ee=A(!1),te=A(!1),re=A(!1),ne=A(null),ie=A(void 0),oe=A(void 0),ae=A(!1),le=A(!1),ce=function(){!p.current&&h();let[e]=$(m.current);return e}(),ue=d??z,se="collapsed"!==O.kind,de=n(l,c).filter(e=>"|"===e||"more"===e||l.some(t=>t.id===e)),me=de.filter(e=>"|"!==e).length,pe=l.filter(e=>e.children?.length),he=A(new Map),fe=A(new Map),ge=de.join(" ");function ye(){clearTimeout(ie.current),q(null)}function be(){ye(),clearTimeout(oe.current),ae.current=!1}function ve(e,t,r=!1){clearTimeout(ie.current);let n=Y.current,i=Q.current;if(!n||!i||se||te.current||re.current&&!r)return;let o=n.getBoundingClientRect(),a=e.getBoundingClientRect(),l={label:t?t.count?`${t.label} · ${t.count} open`:t.label:_,shortcut:t?.shortcut,x:"left"===g?o.width+8:"right"===g?-8:a.left-o.left+a.width/2,y:"top"===g?o.height+8:"bottom"===g?-8:a.top-o.top+a.height/2};clearTimeout(oe.current);let c=()=>{ae.current=!0,q(l)};r||ae.current?c():ie.current=setTimeout(c,400)}function ke(e,t,r){be(),se||(J.current=t,ee.current=r),ne.current="first",R(e)}function _e(e=!0,t=J.current){be(),re.current=!0,ne.current=e&&ee.current?t:null,R({kind:"collapsed"})}function we(){"group"===O.kind&&(ne.current=O.id,R({kind:"main"}))}function xe(e,t){let r=!!e.children?.length,n=ue===e.id||!!e.children?.some(e=>e.id===ue),l=!t&&e.keepOpenOnSelect,c=(t,r=!1)=>B(D,{label:e.label,icon:r,reduced:!!ce,children:t}),u=n&&e.activeIcon?e.activeIcon:e.icon,s=P(j,{children:[B("span",{className:"morphing-menu__icon","aria-hidden":"true",style:l?{display:"grid"}:void 0,children:l?c(u,!0):u}),!t&&B("span",{className:"morphing-menu__label",style:l?{display:"grid"}:void 0,children:l?c(e.label):e.label}),t&&!!e.count&&B("span",{className:"morphing-menu__badge","aria-hidden":"true",children:i(e.count)}),!t&&P("span",{className:"morphing-menu__trailing",children:[!!e.count&&B("span",{className:"morphing-menu__count","aria-hidden":"true",children:e.count}),e.shortcut&&B(H,{shortcut:e.shortcut})]}),!t&&r&&B(W,{})]}),d={className:t?"morphing-menu__shortcut":"morphing-menu__row","data-menu-item":e.id,"aria-label":o(e.label,e.count),"aria-keyshortcuts":e.shortcut?a(e.shortcut).aria:void 0,"aria-pressed":e.checked,"aria-current":n?r?"true":"page":void 0,"aria-expanded":r?"group"===O.kind&&O.id===e.id:void 0,"aria-controls":r?`${I}-group-${e.id}`:void 0,onClick:t=>r?ke({kind:"group",id:e.id},e.id,0===t.detail):function(e){X(e.id),b?.(e.id),se&&!e.keepOpenOnSelect?_e(!0,"group"===O.kind?O.id:e.id):be(),e.onSelect?.()}(e),onPointerEnter:r=>{t&&"mouse"===r.pointerType&&ve(r.currentTarget,e)},onPointerLeave:ye,onPointerDown:be,onFocus:r=>{t&&r.currentTarget.matches(":focus-visible")&&ve(r.currentTarget,e,!0)},onBlur:ye};return e.href&&!r?B("a",{href:e.href,...d,children:s},e.id):B("button",{type:"button",...d,children:s},e.id)}M(()=>{let t=new Map,r=[...Q.current?.querySelectorAll("[data-menu-item]")??[]].map(e=>{let r=e.dataset.menuItem,n=[e.offsetLeft,e.offsetTop];return t.set(r,n),{node:e,id:r,position:n,before:he.current.get(r)}});for(let{node:t,id:n,position:i,before:o}of r)ce||ee.current?(fe.current.get(n)?.complete(),fe.current.delete(n)):o&&(o[0]!==i[0]||o[1]!==i[1])&&(fe.current.get(n)?.complete(),fe.current.set(n,f(t,{x:[o[0]-i[0],0],y:[o[1]-i[1],0]},e)));for(let[e,r]of fe.current)t.has(e)||(r.stop(),fe.current.delete(e));he.current=t},[ge,g,O,ce]),L(()=>()=>{for(let e of fe.current.values())e.stop()},[]),M(()=>{let n=Y.current,i=U.current,o=Q.current;if(!n||!i||!o)return;let a=Z.current!==g;Z.current=g;let l=V.current;V.current=O;let c=[...n.querySelectorAll(".morphing-menu__panel")],u=c.find(e=>"false"===e.getAttribute("aria-hidden")),s=[],d=!1,m=e=>(s.push(e),e),p=()=>({width:u?.offsetWidth??o.offsetWidth,height:u?.offsetHeight??o.offsetHeight}),h=a||l.kind!==O.kind||"group"===l.kind&&"group"===O.kind&&l.id!==O.id,y="collapsed"===l.kind!=("collapsed"===O.kind),b=ce||!h;if(b)(()=>{let e=p();i.style.width=`${e.width}px`,i.style.height=`${e.height}px`})();else if(y&&!se)m(f(i,p(),r));else if(y){let r=Math.min(o.offsetWidth,o.offsetWidth>250?280:200);m(f(i,{width:r,height:o.offsetHeight>52?32:28},t)).finished.then(()=>{d||m(f(i,p(),{...e,bounce:se?.24:.15}))}).catch(()=>{})}else m(f(i,p(),{...e,duration:.25,bounce:.1}));m(f(o,{opacity:se?0:1,scale:se&&!ce?.8:1,filter:se&&!ce?"blur(8px)":"blur(0px)"},{duration:b?0:se?.15:.22,delay:b||se?0:.08,...se?{}:{ease:"easeOut"}}));for(let t of c){let r=t===u;for(let[n,i]of[...t.querySelectorAll(".morphing-menu__row")].entries())r&&y&&!b&&Object.assign(i.style,{opacity:"0",transform:"translateY(48px)",filter:"blur(4px)"}),m(f(i,{opacity:r?1:0,y:r||ce?0:16,filter:r||ce?"blur(0px)":"blur(2px)"},{...e,duration:b?0:r?y?.4:.25:.12,bounce:y?.3:0,delay:!b&&r?(y?.2:0)+.02*n:0}))}let v=[...(se?u:o)?.querySelectorAll("[data-menu-item]")??[]],k=ne.current;ne.current=null,k&&(te.current=!0,(("first"===k?v[0]:v.find(e=>e.dataset.menuItem===k))??(se?void 0:v.find(e=>"more"===e.dataset.menuItem)))?.focus({preventScroll:!0}),te.current=!1);let _=()=>R(e=>({...e}));return window.addEventListener("resize",_),()=>{d=!0,s.forEach(e=>e.stop()),window.removeEventListener("resize",_)}},[O,ce,g,l.length,ge]),L(()=>{if(!se)return;let e=new AbortController;return u(Y.current,"pointerdown",e=>{e.target instanceof Node&&!e.composedPath().includes(Y.current)&&_e(!1)},{signal:e.signal}),()=>e.abort()},[se]),L(()=>()=>{clearTimeout(ie.current),clearTimeout(oe.current)},[]);let Ne=P("button",{type:"button",className:"morphing-menu__row","data-menu-item":"close",onClick:()=>_e(!0,"more"),children:[B(w,{"aria-hidden":"true"}),B("span",{className:"morphing-menu__label",children:"Close menu"})]});return P("nav",{ref:Y,"aria-label":v,className:["morphing-menu",T].filter(Boolean).join(" "),"data-view":O.kind,"data-edge":g,"data-vertical":G,"data-align-end":y,style:{"--mm-count":me,"--mm-gaps":de.length-me,...E},onPointerMove:e=>{if(!re.current||"mouse"!==e.pointerType||!e.movementX&&!e.movementY)return;re.current=!1;let t=e.target instanceof Element?e.target.closest(".morphing-menu__shortcut"):null;t&&ve(t,l.find(e=>e.id===t.dataset.menuItem)??null)},onKeyDown:e=>{"Escape"===e.key&&(re.current=!0,be(),se&&(e.preventDefault(),e.stopPropagation(),"group"===O.kind?we():_e()))},onBlur:e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||(se?e.relatedTarget instanceof Node&&_e(!1):le.current||be())},children:[P("div",{ref:U,className:"morphing-menu__shell",children:[B("div",{ref:Q,className:"morphing-menu__bar","aria-hidden":se,inert:se,onPointerEnter:e=>{"mouse"===e.pointerType&&(le.current=!0,clearTimeout(oe.current))},onPointerLeave:e=>{"mouse"===e.pointerType&&(le.current=!1,ye(),clearTimeout(oe.current),oe.current=setTimeout(()=>{ae.current=!1},300))},onKeyDown:e=>{let t={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[e.key],r=[...e.currentTarget.querySelectorAll("[data-menu-item]")],n=r.indexOf(e.target);n<0||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||!t&&"Home"!==e.key&&"End"!==e.key||(e.preventDefault(),r["Home"===e.key?0:"End"===e.key?r.length-1:(n+t+r.length)%r.length].focus({preventScroll:!0}))},children:de.map((e,t)=>"|"===e?B("span",{className:"morphing-menu__separator","aria-hidden":"true"},`separator-${t}`):"more"!==e?xe(l.find(t=>t.id===e),!0):B("button",{type:"button",className:"morphing-menu__shortcut","data-menu-item":"more","aria-label":_,"aria-expanded":se,"aria-controls":`${I}-main`,onClick:e=>ke({kind:"main"},"more",0===e.detail),onPointerEnter:e=>{"mouse"===e.pointerType&&ve(e.currentTarget,null)},onPointerLeave:ye,onPointerDown:be,onBlur:ye,onFocus:e=>{e.currentTarget.matches(":focus-visible")&&ve(e.currentTarget,null,!0)},children:B(k,{"aria-hidden":"true"})},"more"))}),P("div",{id:`${I}-main`,className:"morphing-menu__panel","aria-hidden":"main"!==O.kind,inert:"main"!==O.kind,children:[Ne,[...new Set(l.map(e=>e.group??""))].map(e=>P("section",{"aria-label":e||void 0,className:"morphing-menu__section",children:[e&&B("h3",{children:e}),[...l].filter(t=>(t.group??"")===e).sort((e,t)=>(e.expandedOrder??0)-(t.expandedOrder??0)).map(e=>xe(e,!1))]},e))]}),pe.map(e=>{let t="group"===O.kind&&O.id===e.id;return P("div",{id:`${I}-group-${e.id}`,className:"morphing-menu__panel","aria-label":e.label,"aria-hidden":!t,inert:!t,children:[P("button",{type:"button",className:"morphing-menu__row","data-menu-item":"back",onClick:we,children:[B(N,{"aria-hidden":"true"}),B("span",{children:x})]}),e.children.map(e=>xe(e,!1)),Ne]},e.id)})]}),K&&!se&&P("div",{ref:F,className:"morphing-menu__tooltip","aria-hidden":"true",style:{left:K.x,top:K.y},children:[K.label,K.shortcut&&B(H,{shortcut:K.shortcut})]})]})}function W(){return B(E,{className:"morphing-menu__chevron","aria-hidden":"true"})}function D({label:e,icon:t,reduced:r,children:n}){let i=A(null),o=A(null);return M(()=>{let n=i.current,a=o.current;if(o.current={label:e,node:n.cloneNode(!0)},!a||a.label===e||r)return;let l=a.node;l.setAttribute("aria-hidden","true"),n.parentElement.append(l);let c={duration:200,easing:"cubic-bezier(.22,1,.36,1)"},u=n.animate([{opacity:0,transform:t?"scale(.7)":"translateY(4px)",filter:"blur(2px)"},{opacity:1,transform:"none",filter:"blur(0px)"}],c),s=l.animate([{opacity:1,transform:"none",filter:"blur(0px)"},{opacity:0,transform:t?"scale(.7)":"translateY(-4px)",filter:"blur(2px)"}],c);return s.finished.then(()=>l.remove()).catch(()=>{}),()=>{u.cancel(),s.cancel(),l.remove()}},[e,t,r]),B("span",{ref:i,style:{gridArea:"1 / 1",display:"flex",alignItems:"center"},children:n})}function H({shortcut:e}){let t=A(null);return M(()=>{t.current?.replaceChildren(l(e))},[e.label]),B("span",{ref:t})}function O(e){if("glyph"in e)return b("span",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:c[e.glyph]}});let{user:t}=e,r=t&&d(t);return b("span",{className:"review-avatar"},t?s(t.name):O({glyph:"person"}),r&&b("img",{key:r,src:r,alt:"",referrerPolicy:"no-referrer",decoding:"async",onError:e=>{e.currentTarget.hidden=!0}}))}var R=e=>b(I,{...e,items:e.items.map(e=>({...e,icon:O(e.icon),children:e.children?.map(e=>({...e,icon:O(e.icon)}))}))});function z(e,t){e.replaceChildren();let r=g(e);return y(()=>r.render(R(t))),{render:e=>r.render(R(e)),unmount:()=>r.unmount()}}export{z as mountToolbar};
|