tweakit 0.5.1 → 0.5.2
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/AGENTS.md +1 -1
- package/dist/tweaks/core.js +1 -1
- package/dist/tweaks/image-7MCLBOZ3.js +1 -0
- package/dist/tweaks/markup-ZJJ6CCWM.js +1 -0
- package/dist/tweaks.js +3 -3
- package/dist/types/tweaks/panel.d.ts +1 -0
- package/dist/types/tweaks/schema.d.ts +2 -0
- package/dist/types/tweaks/types.d.ts +11 -0
- package/package.json +1 -1
- package/dist/tweaks/image-JD2NSQYE.js +0 -1
- package/dist/tweaks/markup-MLAHTUK4.js +0 -1
|
@@ -256,6 +256,14 @@ export type SchemaObject = {
|
|
|
256
256
|
cols?: number;
|
|
257
257
|
/** The largest upload taken, in bytes (10 MB unless set); a bigger file is refused with a note. */
|
|
258
258
|
maxSize?: number;
|
|
259
|
+
/** An upload longer than this on its long side, in px, is drawn down to it before it becomes the param, and one
|
|
260
|
+
* heavier than 1.5 MB is redrawn at its size, so a phone photo can't fill storage (2560 unless set; `false` takes
|
|
261
|
+
* uploads as they are). A JPEG comes out as a JPEG at
|
|
262
|
+
* `quality`; anything else as a PNG when that is 1.5 MB or less (a screenshot, not a photo), else as a JPEG, or a WebP
|
|
263
|
+
* when it has transparency. A GIF, an SVG, a light picture within `fit` or one the redraw wouldn't make smaller is kept as it is. */
|
|
264
|
+
fit?: number | false;
|
|
265
|
+
/** The JPEG or WebP quality of a shrunk upload, 0 to 1 (0.85 unless set). */
|
|
266
|
+
quality?: number;
|
|
259
267
|
/** `false` leaves the upload button out of a gallery: the options are the whole choice. */
|
|
260
268
|
upload?: boolean;
|
|
261
269
|
/** `false` leaves Clear out of a gallery, and Delete no longer empties it: for a choice that must keep a value. */
|
|
@@ -468,6 +476,9 @@ export interface Control {
|
|
|
468
476
|
/** Release any loop the control owns (the monitor's poll, the FPS graph's rAF). Only
|
|
469
477
|
* the live controls supply it; the panel calls it from `destroy()`. */
|
|
470
478
|
destroy?(): void;
|
|
479
|
+
/** Show a short message on the control for a moment. Only the image control supplies it; the panel calls it when
|
|
480
|
+
* storage refuses the control's value. */
|
|
481
|
+
note?(message: string): void;
|
|
471
482
|
}
|
|
472
483
|
/** Options for `mountControl(host, value, opts?)` — one control, no panel. */
|
|
473
484
|
export interface MountOptions {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as _}from"./chunk-4ATI34PB.js";import{$ as Y,K as G,W as J,X as Q,Z as X,r as q,u as i,v as V,w as U}from"./chunk-7OSCMZ2J.js";var ot=e=>String(e).replace(/[\\"]/g,"\\$&").replace(/[\x00-\x1f\x7f]/g,b=>"\\"+b.charCodeAt(0).toString(16)+" "),L=e=>`url("${ot(e)}")`,j=1<<20,tt=e=>e>=j?`${Math.round(e/j*10)/10} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`,et=e=>{if(/^data:/i.test(e))return"";let b=e.split(/[?#]/)[0].split("/").pop().replace(/\.\w+$/,"");try{return decodeURIComponent(b)}catch{return b}},it=X('<path d="M12 15V4m-4.5 4.5L12 4l4.5 4.5M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/>');function st(e,b){let n=typeof e.value=="string"?e.value:"",O=new Set,v=(Array.isArray(e.options)?e.options:[]).map(t=>({value:q(t),label:t&&typeof t=="object"&&t.label!=null?String(t.label):""})).filter(t=>typeof t.value=="string"&&!!t.value&&!O.has(t.value)&&!!O.add(t.value)),at=e.upload!==!1||!v.length,S=e.clear!==!1,z=+e.maxSize>0?+e.maxSize:10*j,d=i("input","tw-image-input");d.type="file",d.accept="image/*";let I=i("span","tw-image-note"),C=i("span","tw-image-live");C.setAttribute("role","status");let E=[I,C],H,$=t=>{for(let r of E)r.textContent=t;clearTimeout(H),H=setTimeout(()=>{for(let r of E)r.textContent=""},2600)},K=t=>(/^blob:/i.test(t)?"":et(t))||(/^(data|blob):/i.test(t)?"Uploaded image":"Custom image"),k,R=0,w=(t,r=!0)=>{R++,n=t,k(),r&&b(n)},F=t=>{if(!t)return;if(!t.type.startsWith("image/"))return $("Not an image");if(t.size>z)return $(`${tt(t.size)}, max ${tt(z)}`);let r=new FileReader,c=++R;r.onload=()=>{R===c&&w(String(r.result))},r.onerror=()=>$("Couldn't read the file"),r.readAsDataURL(t)},B=(t,r)=>{let c=()=>!!p.closest(".is-disabled");t.addEventListener("dragover",u=>{c()||(u.preventDefault(),r.dataset.over="true")}),t.addEventListener("dragleave",()=>{r.dataset.over="false"}),t.addEventListener("drop",u=>{r.dataset.over="false",!c()&&(u.preventDefault(),F(u.dataTransfer?.files[0]))})};d.addEventListener("change",()=>{F(d.files?.[0]),d.value=""});let p;if(v.length){let t=_("tw-image",e.label);p=t.root;let r=i("span","tw-trigger-value"),c=i("span","tw-image-note"),u=i("span","tw-trigger-chip tw-image-thumb");t.right.append(u,c,r),E.push(c);let y=i("div","tw-color-pop tw-image-pop tw-image-gallery"),m=at?V("tw-button tw-image-upload",it):null,A=U("button","tw-image-clear","Clear");A.type="button",A.setAttribute("aria-label",`${e.label}: clear the image`);let x=i("div","tw-image-foot"),T=i("div","tw-image-foot-row"),M=i("div","tw-image-clear-slot");x.append(T),M.append(A);let f=i("div","tw-image-grid");f.setAttribute("role","radiogroup"),f.setAttribute("aria-label",e.label);let D=v.length,P=Math.min(6,Math.max(1,e.cols|0||(D<=3?Math.max(2,D):D===4?2:3)));f.style.setProperty("--tw-img-cols",String(P));let nt=(a,s)=>{let l=J("tw-image-tile",a,o=>w(o));return l.textContent="",l.setAttribute("aria-label",s),l.style.backgroundImage=L(a),l},W=v.map((a,s)=>a.label||et(a.value)||`Image ${s+1}`),h=v.map((a,s)=>{let l=nt(a.value,W[s]);return f.append(l),l}),g=V("tw-image-tile tw-image-custom");g.setAttribute("role","radio");let N=()=>g.parentNode?[...h,g]:h;k=()=>{let a=h.findIndex(o=>o._twVal===n);n&&a<0?(g._twVal=n,g.style.backgroundImage=L(n),g.setAttribute("aria-label",K(n)),g.parentNode||f.append(g)):(g.matches(":focus")&&h[Math.max(0,a)].focus(),g.remove());let s=N(),l=Math.max(0,s.findIndex(o=>o._twVal===n));s.forEach((o,rt)=>{let Z=!!n&&o._twVal===n;o.dataset.active=String(Z),o.setAttribute("aria-checked",String(Z)),o.tabIndex=rt===l?0:-1}),M.dataset.open=String(!!n),M.inert=!n,x.dataset.open=String(!!m||S&&!!n),x.inert=x.dataset.open==="false",u.dataset.set=n?"true":"false",u.style.backgroundImage=n?L(n):"",r.textContent=n?a>=0?W[a]:K(n):"None"},f.addEventListener("keydown",a=>{let s=N(),l=s.indexOf(a.target);if(l<0)return;if(S&&(a.key==="Delete"||a.key==="Backspace")&&!a.altKey&&!a.metaKey&&!a.ctrlKey){a.preventDefault(),h[0].focus(),w("");return}let o=Q(a.key,l,s.length,P);o<0||(a.preventDefault(),o!==l&&(s[o].focus(),w(s[o]._twVal)))}),A.addEventListener("click",()=>{(m||h[0]).focus(),w("")}),y.append(f,x),p.append(y,C),m&&(m.setAttribute("aria-label",`${e.label}: upload an image`),m.append(I,U("span","tw-image-text","Upload image")),m.addEventListener("click",()=>d.click()),T.append(m),p.append(d),B(t.trigger,t.trigger),B(y,y)),S&&T.append(M),G(p,t.trigger,y,{fallbackH:220,initialFocus:()=>N().find(a=>a.tabIndex===0)})}else{let t=_("tw-image",e.label);p=t.root,t.trigger.removeAttribute("aria-expanded"),t.trigger.setAttribute("aria-label",`${e.label}: choose an image`);let r=i("span","tw-image-text"),c=i("span","tw-trigger-chip tw-image-thumb");t.right.append(c,I,r),p.append(d,C),k=()=>{c.dataset.set=n?"true":"false",c.style.backgroundImage=n?L(n):"",r.textContent=n?"Replace":"Drop or choose"},t.trigger.addEventListener("click",()=>d.click()),B(t.trigger,t.trigger)}return k(),{el:p,set:t=>{t!=null&&typeof t!="string"||w(t||"",!1)},get:()=>n}}Y("image",st);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as L,aa as O,ba as T,f as H,u as k,v as C}from"./chunk-7OSCMZ2J.js";var j=[],F=e=>({...Object.fromEntries(j.map(t=>[t,a(e[t])])),mode:e.mode}),A={slider:e=>({value:a(e.value),min:a(e.min),max:a(e.max),step:a(e.step),soft:v(e.soft),unit:e.unit}),checkbox:e=>e.options?{type:"radiogrid",options:d(e.options),value:e.value,cols:a(e.cols)}:{value:e.checked==="true"},radiogrid:e=>({options:d(e.options),value:e.value,cols:a(e.cols)}),list:e=>({options:d(e.options),value:e.value}),image:e=>({value:e.value,options:e.options?d(e.options):void 0,cols:a(e.cols),maxSize:a(e.maxSize),upload:e.upload==="false"?!1:void 0,clear:e.clear==="false"?!1:void 0}),buttongroup:e=>({buttons:d(e.buttons).map(t=>({label:t}))}),separator:()=>({}),number:e=>({value:a(e.value),min:a(e.min),max:a(e.max),step:a(e.step),unit:e.unit}),text:e=>({value:e.value??"",placeholder:e.placeholder,rows:a(e.rows)}),fpsgraph:e=>({label:e.label??"FPS"}),interval:e=>({value:e.value?e.value.split(",").map(Number):void 0,min:a(e.min),max:a(e.max),step:a(e.step)}),sides:e=>({value:e.value??e,corners:v(e.corners),unit:e.unit,step:a(e.step),min:a(e.min),max:a(e.max)}),shadow:e=>({value:e.value??{...e,inset:v(e.inset)}}),spring:F,motion:e=>({...F(e),curve:e.curve&&e.curve.includes(",")?e.curve.split(",").map(Number):e.curve,duration:a(e.duration)}),cubicbezier:e=>({value:e.value?e.value.split(",").map(Number):void 0}),point:e=>{let t=(e.value||"").split(",").map(o=>parseFloat(o));return{components:d(e.components||"X,Y").map((o,i)=>({key:o.toLowerCase(),label:o,value:isNaN(t[i])?0:t[i],step:a(e.step),min:a(e.min),max:a(e.max)})),pad:v(e.pad),invertY:e.invertY==="true"}},plot:e=>({expr:e.expr,xMin:a(e.xmin),xMax:a(e.xmax),yMin:a(e.ymin),yMax:a(e.ymax),samples:a(e.samples),editable:e.editable!=="false"})},a=e=>{if(e==null||e==="")return;let t=+e;return Number.isFinite(t)?t:void 0},v=e=>e==="true"||e==="",d=e=>(e||"").split(",").map(t=>t.trim()).filter(Boolean),Y=(e,t)=>{let o=t.dataset,i=o.tw,y=o.label??H(o.key||i),b=e.hasOwn(A,i)?A[i](o,t,y):e.LAZY_IMPORT[i]||O(i)?{...o}:null;return b?e.metaFor("v",{type:i,label:y,...b}):null},I=(e,t)=>{e.dataset.value=t==null?"":Array.isArray(t)?t.join(","):typeof t=="object"?Object.values(t).join(","):String(t)},K=(e,t,o)=>{I(e,o),e.dispatchEvent(new CustomEvent("tw:change",{bubbles:!0,detail:{key:t,value:o}}))},x=(e,t)=>[...typeof e.matches=="function"&&e.matches(t)?[e]:[],...e.querySelectorAll(t)];async function q(e,t){let{createFolder:o,createControl:i,makeCopyBtn:y,makeResetBtn:b,addHintMarker:R,restoreDefault:B,hasOwn:_,valueChanged:D,ensureForMetas:N}=t;j=t.SPRING_KEYS,x(e,'.tw-panel[data-mode="inline"]:not([data-tw-panel-bound])').forEach(n=>{let r=n.querySelector(":scope > .tw-header"),c=n.querySelector(":scope > .tw-controls");if(!r||!c)return;n.setAttribute("data-tw-panel-bound","");let p=k("div","tw-body");n.insertBefore(p,c),p.append(c);let l=r.querySelector(".tw-header-toggle"),s=r.querySelector(".tw-title");if(!l&&s&&(l=C("tw-header-toggle"),s.replaceWith(l),l.append(s)),!!l&&(l.setAttribute("aria-expanded","true"),l.addEventListener("click",()=>L(n,l,p,!n.classList.contains("is-collapsed"))),!r.querySelector(".tw-toolbar"))){let f=()=>[...n.querySelectorAll("[data-tw]")].map(u=>u._tw).filter(u=>u&&u.ctrl.get()!==void 0),g=()=>{let u=Object.create(null);for(let h of f()){let M=h.key,P=2;for(;_(u,M);)M=`${h.key}-${P++}`;u[M]=h.ctrl.get()}return JSON.stringify(u,null,2)},m=()=>{for(let u of f())u.reset()},S=k("div","tw-toolbar");S.append(y(()=>[g(),-1]),b(m)),r.append(S)}}),x(e,'[data-tw="folder"]:not([data-tw-bound])').forEach(n=>{n.setAttribute("data-tw-bound","");let r=o({label:n.dataset.label||"Folder"});[...n.children].forEach(c=>r.body.append(c)),n.append(r.el)});let w=x(e,"[data-tw]:not([data-tw-bound])").map(n=>({host:n,meta:Y(t,n)})).filter(n=>n.meta);w.forEach(({host:n})=>n.setAttribute("data-tw-bound",""));let E=N(w.map(n=>n.meta));E&&await E.catch(()=>{});for(let{host:n,meta:r}of w){let c=n.dataset.key||r.label,p,l=m=>{D(p,m)&&(p=m,K(n,c,m))},s=i(r,l);if(!s)continue;n.closest(".tw-panel, .tw-portal")||n.classList.add("tw-portal"),n.append(s.el),n.dataset.hint&&R(s.el,n.dataset.hint);let f=s.get();p=f;let g={...s,set:m=>{s.set(m),l(s.get())}};n._tw={ctrl:g,raw:r.value,def:f,key:c,host:n,reset:()=>{B(s,r.value,f),l(s.get())}}}}T(q);export{A as DATA_VALUE};
|