@hazem3500/palette 0.9.156 → 0.9.157

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.
@@ -0,0 +1 @@
1
+ import{a as e,b as t,d as n}from"./chunk-LI6OHQIO.js";import{f as i}from"./chunk-WWMQITEG.js";import{d as r}from"./chunk-4FX5IS2U.js";var o=0;var l='.design-inspector__controls>*+*{border-top:1px solid #ffffff0d}.design-group{--palette-inset:12px;padding:0 var(--palette-inset) 10px}.design-section>.design-group{padding-bottom:12px}.design-group summary{cursor:pointer;display:flex;align-items:center;gap:4px;height:36px;color:#e9e6e1;font-size:11px;font-weight:600;list-style:none}.design-group summary::-webkit-details-marker{display:none}.design-group summary:after{content:"";width:5px;height:5px;margin:-2px 0 0 3px;border:solid #77736f;border-width:0 1.2px 1.2px 0;rotate:45deg;opacity:0;transition:opacity .12s,rotate .2s var(--ease-smooth-out)}.design-group:not([open]) summary:after{rotate:-45deg;margin:0 0 0 2px}.design-group summary:is(:hover,:focus-visible):after,.design-group:not([open]) summary:after{opacity:1}.design-group summary:focus-visible{outline-offset:-2px;border-radius:6px}.design-section{position:relative;--palette-inset:12px}.design-section__title{display:flex;align-items:center;height:36px;padding:0 var(--palette-inset);color:#898680;font-size:11px;font-weight:600}.design-section__tools{position:absolute;z-index:1;top:6px;right:calc(var(--palette-inset) - 4px);display:flex;gap:2px}.design-section__tools button{display:grid;place-items:center;width:24px;height:24px;border-radius:6px;color:#898680;font-size:16px;line-height:1}.design-section__tools button:hover{background:#ffffff12;color:#f1efeb}.design-text-edit{font-size:0!important}.design-text-edit:before{content:"T";font:600 13px/1 Georgia,Times New Roman,serif}.design-text-edit[aria-label^=Finish]{background:#bda6ef33;color:#e6dcfb!important}.design-text-edit:disabled{opacity:.35;cursor:default}.design-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px 8px}.design-field{position:relative;--lead:4px;min-width:0;height:28px;display:flex;align-items:center;border-radius:6px;background:#ffffff0a;color:#898680;transition:box-shadow .12s var(--ease-smooth-out)}.design-field:hover{box-shadow:inset 0 0 0 1px #ffffff1c}.design-field:focus-within{box-shadow:inset 0 0 0 1px #bda6ef}.design-field:has([aria-invalid=true]){box-shadow:inset 0 0 0 1px #fda29b}.design-field[data-wide]{grid-column:1/-1}.design-field:has(.design-field__glyph){--lead:22px}.design-field--color{--lead:26px}.design-field>input:not([type=color]),.design-field>select{flex:1;box-sizing:border-box;width:100%;min-width:0;height:100%;margin:0;padding:0 8px;border:0;border-radius:6px;outline:0;box-shadow:none;background:none;color:#f1efeb;font:inherit;font-size:11px;font-variant-numeric:tabular-nums;text-overflow:ellipsis}.design-field input[type=number]{appearance:textfield;-moz-appearance:textfield}.design-field input::-webkit-inner-spin-button{appearance:none}.design-field__glyph{flex:none;display:grid;place-items:center;width:22px;height:100%;margin-right:-6px;color:#77736f;font-size:10px;font-weight:600;cursor:ew-resize;user-select:none;touch-action:none}.design-field__glyph:hover{color:#e9e6e1}.design-field__glyph svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.1}.design-field input[type=color]{flex:none;width:16px;height:16px;margin:0 -2px 0 6px;padding:0;border:0;border-radius:4px;box-shadow:inset 0 0 0 1px #ffffff26;background:none;cursor:pointer}.design-field input[type=color]::-webkit-color-swatch-wrapper{padding:0}.design-field input[type=color]::-webkit-color-swatch{border:0;border-radius:4px;box-shadow:inset 0 0 0 1px #ffffff26}.design-field input[type=color]::-moz-color-swatch{border:0;border-radius:4px}.design-field input[data-clear]::-webkit-color-swatch{background:repeating-conic-gradient(#999 0 25%,#eee 0 50%) 0 0/8px 8px!important}.design-box{grid-column:1/-1;min-width:0}.design-box__body .design-field{height:28px}@media(max-width:520px)and (pointer:coarse){.design-box__body .design-field{height:44px}.design-inspector :is(.design-text-edit,.design-inspector__eye){min-width:44px;min-height:44px}}@media(pointer:coarse){.design-section__title{height:44px}.design-section__tools{top:10px;right:var(--palette-inset)}.design-section__tools button{position:relative}.design-section__tools button:before{content:"";position:absolute;inset:-10px}.design-field input[type=color]{position:relative;z-index:1;width:44px;height:44px;margin:-14px -16px -14px -8px;box-shadow:none}.design-field input[type=color]::-webkit-color-swatch-wrapper{padding:14px}.design-field:has(>.design-segments){grid-column:1/-1;height:44px}}\n',a=new WeakMap;function d(e,n){for(let t of e.querySelectorAll(".design-box__body"))a.get(t)?.();t(e,n)}var p=["top","right","bottom","left"],s=["M1.5 1.5h9M4 5h4v4H4z","M10.5 1.5v9M3 4h4v4H3z","M1.5 10.5h9M4 3h4v4H4z","M1.5 1.5v9M5 4h4v4H5z"],c=["M1.5 10.5V6A4.5 4.5 0 0 1 6 1.5h4.5","M1.5 1.5H6a4.5 4.5 0 0 1 4.5 4.5v4.5","M1.5 10.5H6A4.5 4.5 0 0 0 10.5 6V1.5","M1.5 1.5V6a4.5 4.5 0 0 0 4.5 4.5h4.5"],g=e=>e[0].toUpperCase()+e.slice(1),u=e=>p.map((t,n)=>({property:`${e}-${t}`,label:`${g(e)} ${t}`,kind:"length",glyph:s[n],compact:!0,min:"margin"===e?-200:0,max:200})),h=["top-left","top-right","bottom-right","bottom-left"].map((e,t)=>({property:`border-${e}-radius`,label:`Radius ${e.replace("-"," ")}`,kind:"length",glyph:c[t],compact:!0,max:96})),m=[{property:"width",label:"Width",kind:"size",glyph:"W"},{property:"height",label:"Height",kind:"size",glyph:"H"},{property:"padding",label:"Padding",kind:"length",glyph:"M1.5 1.5h9v9h-9zM4.5 4.5h3v3h-3z",max:200,compact:!0},{property:"gap",label:"Gap",kind:"length",glyph:"M1.5 1.5h3v9h-3zM7.5 1.5h3v9h-3z",max:200},{property:"row-gap",label:"Row gap",kind:"length",glyph:"M1.5 1.5h9v3h-9zM1.5 7.5h9v3h-9z",max:200},{property:"column-gap",label:"Column gap",kind:"length",glyph:"M1.5 1.5h3v9h-3zM7.5 1.5h3v9h-3z",max:200},{property:"margin",label:"Margin",kind:"length",glyph:"M4 4h4v4H4zM1 3V1h2m6 0h2v2m0 6v2H9m-6 0H1V9",min:-200,max:200,compact:!0},{property:"border-radius",label:"Corner radius",kind:"length",glyph:"M1.5 10.5V6A4.5 4.5 0 0 1 6 1.5h4.5",max:96,compact:!0},...u("padding"),...u("margin"),...h,{property:"display",label:"Layout",kind:"select",values:["block","flex","grid","inline-flex","inline-grid"]},{property:"flex-direction",label:"Direction",kind:"select",values:["row","column","row-reverse","column-reverse"],wide:!0},{property:"flex-wrap",label:"Wrap",kind:"select",values:["nowrap","wrap"],wide:!0},{property:"justify-content",label:"Justify",kind:"select",values:["flex-start","center","flex-end","space-between","space-around"],wide:!0},{property:"align-items",label:"Align",kind:"select",values:["flex-start","center","flex-end","stretch","baseline"],wide:!0},{property:"font-family",label:"Font family",kind:"text",wide:!0,placeholder:"system-ui, sans-serif"},{property:"font-size",label:"Font size",kind:"length",wide:!0,glyph:"M2 3V1.5h8V3M6 1.5v9m-1.5 0h3",min:1,max:160},{property:"line-height",label:"Line height",kind:"text",glyph:"M1 1.5h10M1 10.5h10M3.5 8.5 6 3l2.5 5.5",placeholder:"1.4 or 24px"},{property:"letter-spacing",label:"Letter spacing",kind:"text",glyph:"M1 2.5v7M11 2.5v7M3.5 9.5 6 2.5l2.5 7M4.4 7h3.2",placeholder:"0 or 0.02em"},{property:"font-weight",label:"Weight",kind:"select",values:["300","400","500","600","700","800"]},{property:"text-align",label:"Alignment",kind:"select",values:["left","center","right","justify"]},{property:"color",label:"Text color",kind:"color",wide:!0},{property:"background-color",label:"Fill",kind:"color",wide:!0},{property:"border-width",label:"Border width",kind:"length",glyph:"M1 2.5h10M1 6h10M1 9.5h10",max:24},{property:"border-style",label:"Border style",kind:"select",values:["none","solid","dashed","dotted"]},{property:"border-color",label:"Border color",kind:"color"},{property:"fill",label:"Fill",kind:"color",wide:!0},{property:"stroke",label:"Stroke",kind:"color",wide:!0},{property:"opacity",label:"Layer opacity",kind:"text",glyph:"M6 1.5a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9v9",min:0,max:1,step:.01,placeholder:"0–1"},{property:"box-shadow",label:"Shadow",kind:"text",wide:!0},{property:"stroke-width",label:"Stroke width",kind:"length",min:0,max:24}],f=import("./select-menu-OZVNHZ73.js").catch(()=>null),b=import("./live-colors-D426RBEC.js").catch(()=>null),x=import("./field-controls-ZGI4DUIK.js").catch(()=>null),y=["font-family","font-size","line-height","letter-spacing","font-weight","text-align","color"];function v(e){let t=e.match(/^rgba\(.*,\s*([\d.]+)\)$/)?.[1];return void 0===t?/^rgb\(/.test(e)?r(e):e||"transparent":Number(t)?e:"transparent"}function w(e,t,n){let i=(n||getComputedStyle(t).getPropertyValue(e.property)).trim();if("color"===e.kind)return v(i);if("length"===e.kind||"size"===e.kind){let t=i.match(/^(-?\d+(?:\.\d+)?)px$/);return t?String(Math.round(10*Number(t[1]))/10):"size"===e.kind?i||"auto":"0"}return i}var k=(e,t)=>{e&&(e.value=r(t),e.toggleAttribute("data-clear",/^transparent$|^#(...0|.{6}00)$|(^rgba?\((.+,){3}|\/)\s*0?\.?0*%?\s*\)$/i.test(t.trim())))};function E(t,r){let{element:l}=r,a=document.createElement("div");a.className=`design-field design-field--${t.kind}`,a.dataset.fieldProperty=t.property,a.toggleAttribute("data-wide",!!t.wide);let d="select"===t.kind?document.createElement("select"):document.createElement("input");if(d instanceof HTMLSelectElement)for(let e of t.values??[]){let t=document.createElement("option");t.value=t.textContent=e,d.append(t)}else d.type="length"===t.kind?"number":"text",d.autocomplete="off",d.spellcheck=!1,d.placeholder=t.placeholder??"","length"===t.kind&&(d.min=String(t.min??0),d.max=String(t.max??1e3),d.setAttribute("inputmode","decimal"));let p=function(e,t,n,i=!1){n.dataset.fieldLabel=t.label,i||(n.style.marginTop="20px");let r=document.createElement("label");return r.className="design-field__label",i||(r.style.cssText="position:absolute;inset:auto 0 calc(100% + 4px);color:#b5b1ab;font-size:10px;line-height:14px;white-space:normal;overflow-wrap:anywhere;cursor:default"),e.id||="palette-field-"+ ++o,r.htmlFor=e.id,r.textContent=t.label,r}(d,t,a,!!t.compact);t.compact&&(p.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap");let s="length"===t.kind||"size"===t.kind||"text"===t.kind&&!!t.glyph;s&&t.glyph&&d.setAttribute("role","spinbutton"),a.append(p),d.dataset.property=t.property,d.setAttribute("aria-label",t.label);let c=()=>{let e=w(t,l);d instanceof HTMLSelectElement&&![...d.options].some(t=>t.value===e)&&d.prepend(new Option(e,e)),d.value=e,k(a.querySelector('input[type="color"]'),e)};c();let g=()=>r.begin(d,t.property),u=()=>b(()=>{r.apply(d,t.property,n(t,d)),r.commit(d,t.property,!1)}),h=()=>b(()=>r.commit(d,t.property)),m=()=>{if("color"===t.kind&&d.value.trim()&&!1===globalThis.CSS?.supports?.("color",d.value))return c();if(!(s&&d instanceof HTMLInputElement))return;let e=i(d.value);void 0!==e&&(d.value="length"===t.kind?e.replace(/px$/,""):e,u())};if(d.addEventListener("focus",g),d.addEventListener("input",u),d.addEventListener("change",m),d.addEventListener("blur",m),d.addEventListener("change",h),d.addEventListener("blur",h),"color"===t.kind){let e=document.createElement("input");e.type="color",e.setAttribute("aria-label",`${t.label} picker`);let n=()=>k(e,d.value);n(),e.addEventListener("pointerdown",g),e.addEventListener("focus",g),e.addEventListener("input",()=>{d.value=e.value,e.removeAttribute("data-clear"),u()}),e.addEventListener("change",h),d.addEventListener("input",n),a.append(e)}if(t.glyph){let e=e=>"text"===t.kind&&!e,n=()=>{let e=d.value.trim().match(/^(-?\d*\.?\d+)([a-z%]*)$/i);return{unit:e?e[2]:"text"===t.kind?"px":"",start:e?Number(e[1]):parseFloat(getComputedStyle(l).getPropertyValue(t.property))||0}},i=(e,n)=>{let i=Math.round(100*e)/100;("text"!==t.kind||t.max)&&(i=Math.min(t.max??1e4,Math.max(t.min??0,i))),d.value=`${i}${n}`,u()},r=r=>{let{unit:o,start:l}=n();i(l+r*(t.step??(e(o)?.1:1)),o)},o=document.createElement("span");o.className="design-field__glyph",o.setAttribute("aria-hidden","true"),o.title=`${t.label} · drag to adjust`,t.glyph.length>1?o.innerHTML=`<svg viewBox="0 0 12 12"><path d="${t.glyph}"/></svg>`:o.textContent=t.glyph,p.style.cssText+=";cursor:ew-resize;user-select:none;touch-action:none";for(let r of[o,p])r.addEventListener("pointerdown",o=>{if(o.button)return;o.preventDefault(),g(),r.setPointerCapture?.(o.pointerId);let{unit:l,start:a}=n(),s=t.step??(e(l)?.1:1),c=o.clientX,u=0,m=0,f=!1,b=!1,x=()=>{f=!1,i(a+u*s,l)},y=e=>{let t=e.altKey?.1:e.shiftKey?10:1;u+=(e.clientX-c)*t,c=e.clientX,b||=!!u,f||(f=!0,m=requestAnimationFrame(x))},v=()=>{r.removeEventListener("pointermove",y),f&&cancelAnimationFrame(m),b&&x(),h(),!b&&r===p&&d.focus()};r.addEventListener("pointermove",y),r.addEventListener("pointerup",v,{once:!0}),r.addEventListener("pointercancel",v,{once:!0})});d.addEventListener("keydown",e=>{"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),r(("ArrowUp"===e.key?1:-1)*(e.shiftKey?10:e.altKey?.1:1)))}),a.append(o)}let f=()=>{let e=d.getRootNode();if(e.activeElement!==d)return;let t=!d.closest(".design-quickbar")&&e.querySelector?.(".design-geometry__frame");if(!t||!t.getClientRects().length)return d.blur();t.dataset.landed="",t.addEventListener("blur",()=>delete t.dataset.landed,{once:!0}),t.focus({preventScroll:!0})};d instanceof HTMLInputElement&&d.addEventListener("keydown",e=>{if("Enter"===e.key){if(m(),!d.closest(".design-quickbar"))return f();h(),d.select()}}),a.addEventListener("keydown",e=>{if("Escape"!==e.key)return;let n=e.target===d;if(!r.cancel)return n&&f();e.preventDefault(),e.stopImmediatePropagation(),r.cancel(d,t.property),c(),n&&f(),queueMicrotask(()=>{"custom"!==a.dataset.tokenMode&&a.querySelector(".design-token-binding select")?.focus()})}),a.append(d);let b=e(d,t,r,c);return a}function M(e,t,n,i){let r=document.createElement("div");r.className="design-box",r.setAttribute("role","group"),r.setAttribute("aria-label",t);let o=document.createElement("div");o.className="design-box__head";let l=document.createElement("span");l.textContent=t;let d=document.createElement("button");d.type="button",d.className="design-box__link";let p=document.createElement("div");p.className="design-box__body";let s=()=>i.map(t=>w(t,e.element)),c=1===new Set(s()).size,g=!1;a.set(p,()=>{if(p.contains(p.getRootNode().activeElement))return;let e=new Set(s()).size>1;(c?e:g&&!e)&&(g=c,c=!c,u())});let u=()=>{d.setAttribute("aria-pressed",String(c)),d.setAttribute("aria-label",c?`Edit ${t.toLowerCase()} one by one`:`Link ${t.toLowerCase()}`),d.title=d.getAttribute("aria-label"),p.dataset.linked=String(c),p.replaceChildren(...(c?[n]:i).map(t=>E(t,e))),c&&(p.querySelector("input").type="text"),x.then(t=>t?.enhance(p,e.element))};return d.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M5 7a2 2 0 0 0 2.8 0l2-2a2 2 0 0 0-2.8-2.8l-.6.6M7 5a2 2 0 0 0-2.8 0l-2 2A2 2 0 0 0 5 9.8l.6-.6"/></svg>',d.addEventListener("click",()=>{if(c=!c,g=!1,c){let[t,...i]=s();if(i.some(e=>e!==t)){let i=document.createElement("input");e.begin(i,n.property),e.apply(i,n.property,`${t}px`),e.commit(i,n.property)}}u()}),o.append(l,d),u(),r.append(o,p),r}function _(e,t,n,i=[]){let r=document.createElement("section");r.className="design-section";let o=document.createElement("div");if(o.className="design-section__tools",o.append(...i),!n){let e=document.createElement("span");return e.className="design-section__title",e.textContent=t,r.append(e,o),r}let l=document.createElement("details");l.className="design-group",l.open=!e.collapsed.has(t);let a=document.createElement("summary");a.textContent=t;let d=document.createElement("div");d.className="design-grid";let p=e=>m.find(t=>t.property===e);for(let t of n){if("@padding"===t){d.append(M(e,"Padding",p("padding"),u("padding")));continue}if("@margin"===t){d.append(M(e,"Margin",p("margin"),u("margin")));continue}if("@radius"===t){d.append(M(e,"Corner radius",p("border-radius"),h));continue}let n=p(t);d.append(E("http://www.w3.org/2000/svg"===e.element.namespaceURI&&"color"===t?{...n,label:"Color"}:n,e))}return l.append(a,d),l.addEventListener("toggle",()=>{l.isConnected&&(l.open?e.collapsed.delete(t):e.collapsed.add(t))}),r.append(o,l),r}function L(e,t){let n=[...e.querySelectorAll(".design-field--color")];n.length&&b.then(e=>e?.liveColors(n,t,w))}function z(e,t){let{element:n,changed:i}=t;f.then(n=>n?.attach(e,t.element,t.reserved)),x.then(n=>n?.enhance(e,t.element));let r=getComputedStyle(n);if("http://www.w3.org/2000/svg"===n.namespaceURI)return e.append(_(t,"Layout","svg"===n.localName?["width","height","display"]:["display"]),_(t,"Appearance",["color","fill","stroke","stroke-width"])),L(e,n);let o=e=>e.some(e=>i?.has(e)),l=!!n.textContent?.trim()||/(?:^|;)\s*(?:color|font|line-height|text-align)/.test(n.getAttribute("style")??"")||o(y),a=/flex|grid/.test(r.display)||o(["gap"]),d="transparent"!==v(r.backgroundColor)||o(["background-color"]),p=["top","right","bottom","left"].some(e=>parseFloat(r.getPropertyValue(`border-${e}-width`))>0&&"none"!==r.getPropertyValue(`border-${e}-style`))||o(["border","border-width","border-style","border-color"]),s=r.boxShadow&&"none"!==r.boxShadow||o(["box-shadow"]),c=(n,i,r,o)=>function(e,t,n){let i=document.createElement("button");return i.type="button",i.title=e,i.setAttribute("aria-label",e),i.textContent=t,i.addEventListener("click",n),i}(`Add ${n}`,"+",()=>{let n=document.createElement("input");t.begin(n,i),t.apply(n,i,r),t.commit(n,i),t.rerender(),e.querySelector(`[data-property="${o}"]`)?.focus()}),g=/grid/.test(r.display);e.append(_(t,"Layout",["width","height","display",.../flex/.test(r.display)?["flex-direction","flex-wrap"]:[],.../flex|grid/.test(r.display)?["justify-content","align-items"]:[],...g?["row-gap","column-gap"]:a?["gap"]:[],"@padding","@margin",...p?[]:["@radius"]])),l&&e.append(_(t,"Typography",y,[t.editText])),e.append(d?_(t,"Fill",["background-color"]):_(t,"Fill",null,[c("fill","background-color","#ffffff","background-color")]),p?_(t,"Border",["border-width","@radius","border-style","border-color"]):_(t,"Border",null,[c("border","border","1px solid","border-width")]),_(t,"Effects",s?["opacity","box-shadow"]:["opacity"],s?[]:[c("shadow","box-shadow","0 1px 3px rgba(0, 0, 0, 0.12)","box-shadow")])),L(e,n)}export{l as a,d as b,m as c,w as d,E as e,z as f};