tweakit 0.4.2 → 0.4.3
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/dist/tweaks/{bezier-EH6GR3RN.js → bezier-W6K7LDKM.js} +1 -1
- package/dist/tweaks/{chunk-GDMWOXFU.js → chunk-36FYZSWP.js} +1 -1
- package/dist/tweaks/chunk-R7BLRFON.js +1 -0
- package/dist/tweaks/{chunk-5G6TFQOD.js → chunk-X5DD246E.js} +1 -1
- package/dist/tweaks/clip-7ZYA76G4.js +1 -0
- package/dist/tweaks/colour-5W24RKYH.js +1 -0
- package/dist/tweaks/core.js +1 -1
- package/dist/tweaks/{fold-FNCV4C7P.js → fold-EIXF4KHZ.js} +1 -1
- package/dist/tweaks/{gradient-RKPRTDSQ.js → gradient-7UHCGHF2.js} +1 -1
- package/dist/tweaks/{heavy-LD64N5S4.js → heavy-O4TB6NMH.js} +1 -1
- package/dist/tweaks/{image-TFIUSCCY.js → image-XHCPC5OK.js} +1 -1
- package/dist/tweaks/{interval-VFQ2O75Q.js → interval-D6SSAQB4.js} +1 -1
- package/dist/tweaks/{monitor-EAU6GD6P.js → monitor-ZDLYLKC4.js} +1 -1
- package/dist/tweaks/{motion-FUAKWKPW.js → motion-AAMZUKLO.js} +1 -1
- package/dist/tweaks/{plot-AMSWXKO7.js → plot-Z2PJJQOR.js} +1 -1
- package/dist/tweaks/{point-UF7RGMGJ.js → point-44JV524M.js} +1 -1
- package/dist/tweaks/{shadow-54LEQGQ6.js → shadow-PMJG5SZY.js} +1 -1
- package/dist/tweaks/{sides-WJF2NEGM.js → sides-JITGW2AD.js} +1 -1
- package/dist/tweaks/{spring-YHAPWWTF.js → spring-CGJCZJ6Q.js} +1 -1
- package/dist/tweaks/{tabs-C45GWZYF.js → tabs-U5XC6JHJ.js} +1 -1
- package/dist/tweaks.css +1 -1
- package/dist/tweaks.js +3 -3
- package/dist/types/tweaks/panel.d.ts +20 -1
- package/dist/types/tweaks/schema.d.ts +78 -0
- package/dist/types/tweaks/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/tweaks/chunk-3GZFWFKC.js +0 -1
- package/dist/tweaks/colour-G6UZ5HIL.js +0 -1
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import type { Schema, TweaksOptions, Panel } from "./types.js";
|
|
1
|
+
import type { Schema, TweaksOptions, Panel, Control } from "./types.js";
|
|
2
|
+
import type { Meta } from "./schema.js";
|
|
3
|
+
/** A params object or one of its folder/tabs sub-objects — the holder a control writes into. */
|
|
4
|
+
type Target = Record<string, unknown>;
|
|
5
|
+
/** A valued control's wiring: where its value lives, its set/get, the reset pair (raw, def) and its dotted path. */
|
|
6
|
+
export interface Entry {
|
|
7
|
+
target: Target;
|
|
8
|
+
key: string;
|
|
9
|
+
set: Control["set"];
|
|
10
|
+
get: Control["get"];
|
|
11
|
+
raw: unknown;
|
|
12
|
+
def: unknown;
|
|
13
|
+
path: string[];
|
|
14
|
+
persist: boolean;
|
|
15
|
+
m: Meta;
|
|
16
|
+
el: HTMLElement;
|
|
17
|
+
}
|
|
18
|
+
/** A values snapshot — params minus `_last`, as JSON round-trips it. */
|
|
19
|
+
export type Snapshot = Record<string, any>;
|
|
2
20
|
/** Build a panel from `schema`; the shell and API exist synchronously, lazy controls fill in on `ready`. */
|
|
3
21
|
export declare function tweaks(name: string, schema: Schema, opts?: TweaksOptions): Panel;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { SchemaObject, Option, Get, Control } from "./types.js";
|
|
2
|
+
/** A point control's component spec, as the public verbose form declares it. */
|
|
3
|
+
type PointComponent = Extract<SchemaObject, {
|
|
4
|
+
type: "point";
|
|
5
|
+
}>["components"][number];
|
|
6
|
+
/** One page of a tabs control: its slug key, title and the metas built inside it. */
|
|
7
|
+
interface TabPage {
|
|
8
|
+
key: string;
|
|
9
|
+
title: string;
|
|
10
|
+
children: Meta[];
|
|
11
|
+
}
|
|
12
|
+
/** The normalized control meta — ONE shape for every control type. The per-type fields are
|
|
13
|
+
* optional; type / key / label are always set. `value` is the authored default in the control's own shape. */
|
|
14
|
+
interface Meta {
|
|
15
|
+
type: string;
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
value?: any;
|
|
19
|
+
render?: (get: Get) => boolean;
|
|
20
|
+
disabled?: boolean | ((get: Get) => boolean);
|
|
21
|
+
hint?: string;
|
|
22
|
+
persist?: boolean;
|
|
23
|
+
min?: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
step?: number;
|
|
26
|
+
soft?: boolean;
|
|
27
|
+
unit?: string;
|
|
28
|
+
corners?: boolean;
|
|
29
|
+
format?: (value: number) => string;
|
|
30
|
+
parse?: (text: string) => number;
|
|
31
|
+
options?: Option[];
|
|
32
|
+
cols?: number;
|
|
33
|
+
rows?: number;
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
mode?: "time" | "physics";
|
|
36
|
+
stiffness?: number;
|
|
37
|
+
damping?: number;
|
|
38
|
+
mass?: number;
|
|
39
|
+
visualDuration?: number;
|
|
40
|
+
bounce?: number;
|
|
41
|
+
components?: PointComponent[];
|
|
42
|
+
pad?: boolean;
|
|
43
|
+
invertY?: boolean;
|
|
44
|
+
stops?: unknown;
|
|
45
|
+
expr?: string;
|
|
46
|
+
fn?: ((x: number) => number) | null;
|
|
47
|
+
xMin?: number;
|
|
48
|
+
xMax?: number;
|
|
49
|
+
yMin?: number;
|
|
50
|
+
yMax?: number;
|
|
51
|
+
samples?: number;
|
|
52
|
+
editable?: boolean;
|
|
53
|
+
get?: () => number | string;
|
|
54
|
+
graph?: boolean;
|
|
55
|
+
view?: "graph" | "text";
|
|
56
|
+
interval?: number;
|
|
57
|
+
decimals?: number;
|
|
58
|
+
action?: () => void;
|
|
59
|
+
buttons?: Record<string, () => void> | Array<{
|
|
60
|
+
label: string;
|
|
61
|
+
action: () => void;
|
|
62
|
+
}>;
|
|
63
|
+
children?: Meta[];
|
|
64
|
+
pages?: TabPage[];
|
|
65
|
+
}
|
|
66
|
+
/** A verbose handler's result: the control's own fields, or falsy for a malformed shape. */
|
|
67
|
+
type MetaFields = Partial<Meta> | false;
|
|
68
|
+
declare function metaFor(key: string, value: any, depth?: number): Meta | null;
|
|
69
|
+
declare const hasOwn: <T extends object>(o: T, k: PropertyKey) => k is keyof T;
|
|
70
|
+
declare const isReservedKey: (k: string) => k is "__proto__" | "constructor" | "prototype";
|
|
71
|
+
declare const valueChanged: (a: unknown, b: unknown) => boolean;
|
|
72
|
+
declare const restoreDefault: (ctrl: Pick<Control, "set">, raw: unknown, def: unknown) => void;
|
|
73
|
+
declare const TYPED_META: Partial<Record<SchemaObject["type"], (v: any, depth: number) => MetaFields>>;
|
|
74
|
+
declare const VALUELESS: Set<string>;
|
|
75
|
+
declare const DATA_VALUE: Partial<Record<SchemaObject["type"], (d: DOMStringMap, host: HTMLElement, label: string) => object>>;
|
|
76
|
+
declare const dataMeta: (host: HTMLElement) => Meta;
|
|
77
|
+
export { metaFor, dataMeta, valueChanged, restoreDefault, hasOwn, isReservedKey, VALUELESS, TYPED_META, DATA_VALUE };
|
|
78
|
+
export type { Meta, TabPage, PointComponent };
|
|
@@ -423,7 +423,7 @@ export interface Panel {
|
|
|
423
423
|
fromJSON(state: PanelState, options?: SetOptions): void;
|
|
424
424
|
/** Re-theme the panel live; `null` reverts to the default. */
|
|
425
425
|
setTheme(theme?: Theme | null): void;
|
|
426
|
-
/** Retitle the panel live — the header
|
|
426
|
+
/** Retitle the panel live — the header follows. The name it was built
|
|
427
427
|
* with stays its storage key (`persist: true`), so saved values and presets keep their
|
|
428
428
|
* home across a rename. */
|
|
429
429
|
setName(name: string): void;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var S=Object.assign(Object.create(null),{ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]}),L=e=>Math.min(1,Math.max(0,e)),x=15;function H(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(S[t])return S[t];let n=/^cubic-bezier\(([^()]*)\)$/.exec(t);if(!n)return null;let r=n[1].split(",").map(o=>o.trim()?Number(o):NaN);return r.length!==4||!r.every(Number.isFinite)?null:[L(r[0]),r[1],L(r[2]),r[3]]}var ce=e=>H(e)?e.trim().toLowerCase():"linear";function O(e){let t=[];for(let n=0;n<=x;n++){let r=n/x,o=1-r,i=3*o*o*r,s=3*o*r*r,a=r*r*r;t.push([i*e[0]+s*e[2]+a,L(i*e[1]+s*e[3]+a)])}return t}function de(e,t){if(t=L(t),!e)return t;let n=O(e);for(let r=1;r<n.length;r++)if(t<=n[r][0]){let[o,i]=n[r-1],[s,a]=n[r];return s>o?i+(a-i)*(t-o)/(s-o):a}return 1}var T=e=>+(e*100).toFixed(2);function F(e){let t=[...e.stops].sort((a,c)=>a.pos-c.pos),n=a=>`${a.color} ${T(a.pos)}%`,r=H(e.easing);if(!r||t.length<2)return t.map(n).join(", ");let o=O(r),i=e.interpolation||"oklch",s=[n(t[0])];for(let a=1;a<t.length;a++){let c=t[a-1],m=t[a],u=m.pos-c.pos;if(u>1e-6)for(let d=1;d<x;d++){let[f,g]=o[d];s.push(`color-mix(in ${i}, ${c.color}, ${m.color} ${T(g)}%) ${T(c.pos+u*f)}%`)}s.push(n(m))}return s.join(", ")}function $(e,t="to right"){return`linear-gradient(in ${e.interpolation||"oklch"} ${typeof t=="number"?`${t}deg`:t}, ${F(e)})`}var V=e=>e.replace(/([a-z])(?=[A-Z])|([A-Z\d])(?=[A-Z][a-z])/g,"$1$2 ").replace(/^./,t=>t.toUpperCase()).trim(),j=(e,t,n)=>Math.min(n,Math.max(t,e)),me=e=>!!e&&typeof e=="object",we=e=>typeof e=="string"&&(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e.trim())||/^(oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\(/i.test(e.trim())),P=20,_=e=>{let t=String(e),n=/e-(\d+)$/i.exec(t);if(n)return Math.min(P,Number(n[1])+(t.split("e")[0].split(".")[1]||"").length);let r=t.indexOf(".");return r===-1?0:Math.min(P,t.length-r-1)},z=(e,t,n)=>{if(!(n>0))return e;let r=_(n),o=Number((+t).toFixed(r)),i=Math.round((e-o)/n);return Number.isFinite(i)?Number((o+i*n).toFixed(r)):e},be=(e,t,n,r=e)=>{let o=a=>z(a,r,n),i=Number.isFinite(e)?o(e):-1/0,s=Number.isFinite(t)?o(t):1/0;return i<e&&(i=o(i+n)),s>t&&(s=o(s-n)),i>s?[e,e]:[i,s]},I=(e,t)=>{let n=t-e;return n<=1?.01:n<=10?.1:n<=100?1:10},pe=(e,t,n,r=0,o=null)=>{let i=+e,s=+t,a=+n;if(Number.isFinite(i)||(i=r),Number.isFinite(s)||(s=o??i+100),s<i){let c=i;i=s,s=c}return(!(a>0)||a>s-i)&&(a=I(i,s)),{min:i,max:s,step:a}},ge=(e,t,n,r,o,i=null)=>{let s=e.shiftKey?10:1;switch(e.key){case"ArrowRight":case"ArrowUp":return t+n*s;case"ArrowLeft":case"ArrowDown":return t-n*s;case"PageUp":return i!=null?t+i:null;case"PageDown":return i!=null?t-i:null;case"Home":return r;case"End":return o}return null},he=(e,t,n,r,o=0)=>{let i=e.offsetLeft,s=i+e.offsetWidth,a=t.offsetLeft,c=a+t.offsetWidth;return n<s&&n+r>i||n<c+o&&n+r>a-o},Ee=e=>e>=0?[0,e<=1?1:e*3||100]:[e>=-1?-1:e*3,0],G=e=>e==null?void 0:typeof e=="object"?e.value:e,D=e=>{try{return JSON.stringify(e)}catch{return String(e)}},K=e=>e==null?"":typeof e=="string"?V(e):typeof e=="object"?e.label??(e.value!==void 0?String(e.value):D(e)):String(e),M=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.innerHTML=n),(e=="input"||e=="textarea")&&(r.setAttribute("autocomplete","off"),r.setAttribute("data-1p-ignore",""),r.setAttribute("data-lpignore","true")),r},ve=(e,t)=>{let n=M("button",e,t);return n.type="button",n},W=(e,t,n)=>{let r=M(e,t);return r.textContent=n,e==="button"&&(r.type="button"),r},q=e=>["pointerdown","pointermove","pointerup","click"].forEach(t=>e.addEventListener(t,n=>n.stopPropagation())),X=e=>{requestAnimationFrame(e),document.fonts&&document.fonts.ready&&document.fonts.ready.then(e)},U=(e,t,n)=>{let r=e.isConnected;r||requestAnimationFrame(()=>{e.isConnected&&(r=!0)});let o=s=>{if(!e.isConnected){(r||e.closest("[data-tw-destroyed]"))&&i();return}r=!0,n(s)},i=()=>t.forEach(([s,a])=>s.removeEventListener(a,o));return t.forEach(([s,a])=>s.addEventListener(a,o)),i},ye=()=>requestAnimationFrame(()=>window.dispatchEvent(new Event("tw-reflow"))),Le=(e,t)=>{e.addEventListener("pointerenter",()=>{e.classList.add("is-hover"),t&&t()}),e.addEventListener("pointerleave",()=>e.classList.remove("is-hover"))},E=!1;typeof document<"u"&&(document.addEventListener("pointerdown",()=>{E=!0},!0),document.addEventListener("keydown",()=>{E=!1},!0));var Me=e=>{e.addEventListener("focus",()=>e.classList.toggle("tw-focus-quiet",E)),e.addEventListener("blur",()=>e.classList.remove("tw-focus-quiet"))},Z=(e,t,{width:n,fallbackH:r=300,gap:o=6,align:i="start",prefer:s="below"}={})=>{let a=e.getBoundingClientRect();n==="match"&&(t.style.width=a.width+"px");let c=n==="match"?a.width:t.offsetWidth||n||0,m=i==="end"?a.right-c:i==="center"?a.left+a.width/2-c/2:a.left;t.style.left=Math.max(8,Math.min(m,window.innerWidth-c-8))+"px";let u=t.offsetHeight||r,d=window.innerHeight-a.bottom,f=a.top,g=u+12,v=d>=g,h=f>=g,y=(s==="above"?h||!v&&f>=d:!v&&(h||f>d))?a.top-u-o:a.bottom+o;t.style.top=j(y,o,window.innerHeight-u-o)+"px"},Y=Object.assign(Object.create(null),{accent:"--tw-accent",onAccent:"--tw-on-accent",base:"--tw-base",dropdownBg:"--tw-dropdown-bg",surface:"--tw-surface",surfaceHover:"--tw-surface-hover",surfaceActive:"--tw-surface-active",border:"--tw-border",borderHover:"--tw-border-hover",selection:"--tw-selection",title:"--tw-text-root",section:"--tw-text-section",text:"--tw-text-primary",label:"--tw-text-label",textMuted:"--tw-text-secondary",textFaint:"--tw-text-tertiary",focus:"--tw-text-focus",success:"--tw-success",danger:"--tw-danger",shadow:"--tw-shadow-dropdown",shadowPanel:"--tw-shadow-panel",shadowPanelLifted:"--tw-shadow-panel-lifted",font:"--tw-font-sans",fontMono:"--tw-font-mono",radius:"--tw-radius",density:"--tw-row-height",width:"--tw-width"}),J=new Set(["radius","density","width"]),k=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),Q=e=>{e=String(e).trim();let t=/^#([0-9a-f]{3})$/i.exec(e);if(t)return t[1].split("").map(n=>parseInt(n+n,16));if(t=/^#([0-9a-f]{6})$/i.exec(e),t)return[0,2,4].map(n=>parseInt(t[1].slice(n,n+2),16));if(t=/^rgba?\(([^)]+)\)/i.exec(e),t){let n=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);return[n[0],n[1],n[2]]}return null},ee=e=>{let t=Q(e);if(!t||t.some(r=>!Number.isFinite(r)))return"#ffffff";let n=.2126*k(t[0])+.7152*k(t[1])+.0722*k(t[2]);return 1.05/(n+.05)>=(n+.05)/.0571?"#ffffff":"#161616"},Te=e=>{if(!e||typeof e!="object")return null;let t={};for(let[n,r]of Object.entries(e)){if(n.startsWith("--")){t[n]=String(r);continue}let o=Y[n];o&&(t[o]=J.has(n)&&typeof r=="number"?`${r}px`:String(r))}return t["--tw-accent"]&&!t["--tw-on-accent"]&&(t["--tw-on-accent"]=ee(t["--tw-accent"])),Object.keys(t).length?t:null},te=(e,t)=>{if(e){if(e._twAppliedVars)for(let n of e._twAppliedVars)e.style.removeProperty(n);if(e._twAppliedVars=t?Object.keys(t):null,t)for(let n in t)e.style.setProperty(n,t[n])}},ne=(e,t)=>{let n=t?.closest('[data-tw-scheme="light"]')?"light":t?.closest('[data-tw-scheme="dark"]')?"dark":null;n?e.setAttribute("data-tw-scheme",n):e.removeAttribute("data-tw-scheme")},R=(e,t)=>{te(e,t?.closest(".tw-panel")?._twTheme),ne(e,t)},p=null,A=null,xe=e=>{p&&(!e||e.contains(A))&&p()};function ke(e,t,n,r={}){let o=!1,i=null;n.classList.add("tw-portal"),n.inert=!0,n.addEventListener("pointerdown",l=>t.closest(".tw-panel")?._twEditPointer?.(l),!0),q(n);let s=0,a=0,c=()=>{Z(t,n,{width:r.width,fallbackH:r.fallbackH,gap:r.gap,align:r.align});let l=t.getBoundingClientRect();s=parseFloat(n.style.left)-l.left,a=parseFloat(n.style.top)-l.top},m=()=>{if(o){if(!e.isConnected)return w();c(),r.onReflow&&r.onReflow()}},u=()=>{if(!o)return;if(!e.isConnected)return w();let l=t.getBoundingClientRect();if(!(l.width||l.height)||l.bottom<0||l.top>window.innerHeight||l.right<0||l.left>window.innerWidth)return w();n.style.left=l.left+s+"px",n.style.top=l.top+a+"px"},d=l=>{!e.contains(l.target)&&!n.contains(l.target)&&w()},f=l=>{l.key==="Escape"&&o&&(w(),t.focus())},g=l=>{if(!o)return;let b=l.relatedTarget;(b?e.contains(b)||n.contains(b):E)||(w(),b&&!t.closest(".tw-panel")?.contains(b)&&setTimeout(()=>{!o&&document.activeElement===b&&t.focus()},0))};e.addEventListener("focusout",g),n.addEventListener("focusout",g);let v=()=>n.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'),h=()=>R(n,e),C=l=>{l.every(b=>b.target===n)||h()},y=()=>{p&&p!==w&&p(),p=w,A=t,o=!0,e.classList.add("is-open"),t.setAttribute("aria-expanded","true"),n.inert=!1,document.body.appendChild(n),R(n,e),window.addEventListener("tw-retheme",h),typeof MutationObserver=="function"&&(i=new MutationObserver(C),i.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["data-tw-scheme"]})),c(),requestAnimationFrame(()=>{if(o&&(n.classList.add("is-open"),r.onOpen&&r.onOpen(),c(),!n.contains(document.activeElement))){let l=r.initialFocus&&r.initialFocus()||v();l&&l.focus({focusVisible:!E})}}),requestAnimationFrame(function l(){if(o){if(!e.isConnected)return w();requestAnimationFrame(l)}}),setTimeout(()=>{o&&document.addEventListener("pointerdown",d,!0)},0),document.addEventListener("keydown",f),window.addEventListener("scroll",u,!0),window.addEventListener("resize",m)},w=()=>{p===w&&(p=null,A=null),n.contains(document.activeElement)&&t.focus(),o=!1,e.classList.remove("is-open"),n.classList.remove("is-open"),n.inert=!0,t.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",f),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",m),window.removeEventListener("tw-retheme",h),i&&(i.disconnect(),i=null),setTimeout(()=>{o||n.remove()},200)};return t.addEventListener("click",()=>{t.disabled||(o?w():y())}),{open:y,close:w,isOpen:()=>o,reflow:m}}var Ae=(e,t)=>{if(e=e.toLowerCase(),e.includes(t))return!0;if(t.length<3)return!1;let n=t.length,r=e.length,o=new Array(r+1).fill(0);for(let i=1;i<=n;i++){let s=[i];for(let a=1;a<=r;a++)s[a]=Math.min(o[a]+1,s[a-1]+1,o[a-1]+(t[i-1]===e[a-1]?0:1));o=s}return Math.min(...o)<=(t.length<6?1:2)},re=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):{matches:!1},oe="cubic-bezier(0.22, 1, 0.36, 1)",Ce="cubic-bezier(0.34, 1.2, 0.64, 1)",ie=(e,t)=>{re.matches||typeof e.animate!="function"||(e.style.transformOrigin=t>0?"left center":"right center",e.animate([{transform:"scaleX(1)"},{transform:"scaleX(1.18)"},{transform:"scaleX(1)"}],{duration:300,easing:oe}))},se=(e,t,n)=>{let r=e.querySelector('[data-active="true"]');if(!r)return;let o=r.offsetLeft,i=r.offsetWidth,s=parseFloat(t.style.left);t.style.left=o+"px",t.style.width=i+"px",n&&Number.isFinite(s)&&s!==o&&ie(t,o>s?1:-1)},Se=(e,t)=>{e.classList.toggle("is-disabled",t);for(let n of e.children)n.classList.contains("tw-portal")||(n.inert=t)},He=(e,t,n,r)=>{e.classList.toggle("is-collapsed",r),t.setAttribute("aria-expanded",String(!r)),n.inert=r},N=(e,t)=>{let n=e.findIndex(r=>r.dataset.value===String(t));return n<0&&e.length?0:n},ae=(e,t)=>{let n=N(e,t);e.forEach((r,o)=>{let i=r.dataset.value===String(t);r.dataset.active=String(i),r.setAttribute("aria-checked",String(i)),r.tabIndex=o===n?0:-1})},le=(e,t,n)=>{let r=W("button",e,K(t));return r.setAttribute("role","radio"),r._twVal=G(t),r.dataset.value=r._twVal,r.addEventListener("click",()=>n(r._twVal)),r},ue=(e,t,n,r=0)=>{switch(e){case"ArrowRight":return(t+1)%n;case"ArrowLeft":return(t-1+n)%n;case"ArrowDown":return r<0?-1:r?t+r<n?t+r:t:(t+1)%n;case"ArrowUp":return r<0?-1:r?t-r>=0?t-r:t:(t-1+n)%n;case"Home":return 0;case"End":return n-1}return-1};function Oe(e,t,n,r){let o=M("div","tw-seg");o.setAttribute("role","radiogroup"),r&&o.setAttribute("aria-label",r);let i=M("div","tw-seg-pill");o.append(i);let s=e.map(u=>{let d=le("tw-seg-btn",u,f=>m(f));return o.append(d),d}),a=u=>se(o,i,u),c=()=>{ae(s,t),a(!0)},m=(u,d=!0)=>{u!=null&&!s.some(f=>f._twVal===u)||(t=u,c(),d&&n(u))};return o.addEventListener("keydown",u=>{let d=N(s,t);if(d<0)return;let f=ue(u.key,d,s.length);f<0||(u.preventDefault(),m(s[f]._twVal),s[f].focus())}),c(),X(()=>{a(),o.classList.add("is-ready")}),U(o,[[window,"tw-reflow"]],()=>a()),{el:o,set:u=>m(u,!1),get:()=>t}}var Fe=(e,t="",n=2,r=24)=>`<svg${t?` class="${t}"`:""} viewBox="0 0 ${r} ${r}" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Pe=(e,t)=>({el:e,set:()=>{},get:()=>{},destroy:t}),B={},Re=(e,t)=>{B[e]=t},Ne=e=>B[e];export{H as a,ce as b,de as c,F as d,$ as e,V as f,j as g,me as h,we as i,_ as j,z as k,be as l,I as m,pe as n,ge as o,he as p,Ee as q,G as r,D as s,K as t,M as u,ve as v,W as w,q as x,X as y,U as z,ye as A,Le as B,Me as C,Z as D,Te as E,te as F,ne as G,R as H,xe as I,ke as J,Ae as K,re as L,oe as M,Ce as N,se as O,Se as P,He as Q,N as R,ae as S,le as T,ue as U,Oe as V,Fe as W,Pe as X,Re as Y,Ne as Z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as a,d as b,e as c,f as d,g as e}from"./chunk-GDMWOXFU.js";import"./chunk-5G6TFQOD.js";import"./chunk-3GZFWFKC.js";export{a as CHECKER,d as createPickerBody,b as isColor,e as oklchStr,c as parseColor};
|