@tempots/beatui 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/{auth-divider-D_3gKZ6g.js → auth-divider-BIATan1F.js} +3 -3
- package/dist/{auth-divider-itm5-j5G.cjs → auth-divider-CVKfA8Cp.cjs} +1 -1
- package/dist/beatui.css +393 -36
- package/dist/beatui.tailwind.css +393 -36
- package/dist/better-auth/index.cjs.js +1 -1
- package/dist/better-auth/index.es.js +2 -2
- package/dist/deep-merge-B33Qtlmw.cjs +1 -0
- package/dist/{deep-merge-CzZVsVF-.js → deep-merge-BUsrE2v4.js} +130 -130
- package/dist/{duration-input-BrYLC1js.cjs → duration-input-C5il_E0F.cjs} +1 -1
- package/dist/{duration-input-CFu6vq-y.js → duration-input-DoCCrqOG.js} +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +5609 -5130
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +107 -107
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +3 -3
- package/dist/{modal-YKqlh4Dk.js → modal-BHlp4QeT.js} +1 -1
- package/dist/{modal-DCxNGrzk.cjs → modal-BmpfNL48.cjs} +1 -1
- package/dist/{notice-Q0A1gIho.cjs → notice-BBnSXYUc.cjs} +1 -1
- package/dist/{notice-Du3tWJTW.js → notice-BXKtBEiC.js} +1 -1
- package/dist/types/components/data/data-table-context.d.ts +9 -1
- package/dist/types/components/data/data-table-row-details.d.ts +21 -0
- package/dist/types/components/data/data-table-types.d.ts +23 -0
- package/dist/types/components/data/index.d.ts +1 -0
- package/dist/types/components/form/control/control.d.ts +5 -5
- package/dist/types/components/form/control/list-control.d.ts +11 -11
- package/dist/types/components/form/fieldset/fieldset.d.ts +60 -0
- package/dist/types/components/form/fieldset/index.d.ts +1 -0
- package/dist/types/components/form/index.d.ts +1 -0
- package/dist/types/components/form/input/combobox-input.d.ts +2 -2
- package/dist/types/components/form/input/combobox-tags-input.d.ts +1 -1
- package/dist/types/components/form/input/date-time-input.d.ts +1 -1
- package/dist/types/components/form/input/dropdown-input.d.ts +2 -2
- package/dist/types/components/form/input/field-layout.d.ts +64 -0
- package/dist/types/components/form/input/{input-wrapper.d.ts → field.d.ts} +23 -14
- package/dist/types/components/form/input/index.d.ts +2 -1
- package/dist/types/components/form/input/multi-select.d.ts +2 -2
- package/dist/types/components/form/input/native-select.d.ts +1 -1
- package/dist/types/components/form/input/range-slider.d.ts +19 -2
- package/dist/types/components/form/input/select-tags-input.d.ts +1 -1
- package/dist/types/components/format/format-bigint.d.ts +64 -0
- package/dist/types/components/format/format-date-time.d.ts +54 -0
- package/dist/types/components/format/format-date.d.ts +82 -0
- package/dist/types/components/format/format-display-name.d.ts +70 -0
- package/dist/types/components/format/format-file-size.d.ts +30 -0
- package/dist/types/components/format/format-list.d.ts +61 -0
- package/dist/types/components/format/format-number.d.ts +88 -0
- package/dist/types/components/format/format-plural.d.ts +96 -0
- package/dist/types/components/format/format-relative-time.d.ts +62 -0
- package/dist/types/components/format/format-time.d.ts +66 -0
- package/dist/types/components/format/index.d.ts +11 -0
- package/dist/types/components/i18n/locale-selector.d.ts +1 -1
- package/dist/types/components/json-schema/controls/composition-shared.d.ts +1 -1
- package/dist/types/components/json-schema/controls/shared-utils.d.ts +3 -3
- package/dist/types/components/json-schema/widgets/string-controls.d.ts +2 -2
- package/dist/types/components/json-schema-display/display-wrapper.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/use-form-CP6nftVl.cjs +2 -0
- package/dist/{use-form-D_TJyZhP.js → use-form-CmQdxpOi.js} +474 -434
- package/dist/{widget-customization-DELy3SMQ.cjs → widget-customization-B0y-eesp.cjs} +1 -1
- package/dist/{widget-customization-BAchyOUo.js → widget-customization-CKbR4Dsg.js} +2 -2
- package/package.json +1 -1
- package/dist/deep-merge-Bydz6jLt.cjs +0 -1
- package/dist/use-form-BvBkVEKi.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("@tempots/dom"),k=require("./deep-merge-Bydz6jLt.cjs"),mt=require("@tempots/std"),B=require("./input-container-BkPcNDaZ.cjs"),N=require("./text-input-D_IxFd0M.cjs"),R=require("./translations-qefRsdGi.cjs"),ft=require("@tempots/ui"),Q=require("./notice-Q0A1gIho.cjs"),bt=require("./session-id-B5lJMzbB.cjs"),yt=require("./utils-DmEuG3Np.cjs");function Y(e){if(typeof e!="string")return!1;const n=e.startsWith("#")?e.slice(1):e;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function Z(e){if(typeof e!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r]=s,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(r,10);return l>=0&&l<=255&&i>=0&&i<=255&&c>=0&&c<=255}function J(e){if(typeof e!="string")return!1;const n=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r,l]=s,i=parseInt(a,10),c=parseInt(o,10),u=parseInt(r,10),p=parseFloat(l);return i>=0&&i<=255&&c>=0&&c<=255&&u>=0&&u<=255&&p>=0&&p<=1}function tt(e){if(typeof e!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r]=s,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(r,10);return l>=0&&l<=360&&i>=0&&i<=100&&c>=0&&c<=100}function wt(e){return Y(e)||Z(e)||J(e)||tt(e)}function et(e){if(!Y(e))return null;let n=e.startsWith("#")?e.slice(1):e;return n.length===3&&(n=n.split("").map(s=>s+s).join("")),`#${n.toLowerCase()}`}function q(e,n,s){const a=o=>{const r=Math.round(Math.max(0,Math.min(255,o))).toString(16);return r.length===1?"0"+r:r};return`#${a(e)}${a(n)}${a(s)}`}function D(e){const n=et(e);if(!n)return null;const s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:null}function It(e,n){const s=D(e),a=D(n);if(!s||!a)return null;const o=(u,p,d)=>{const[b,g,h]=[u,p,d].map(y=>(y=y/255,y<=.03928?y/12.92:Math.pow((y+.055)/1.055,2.4)));return .2126*b+.7152*g+.0722*h},r=o(s.r,s.g,s.b),l=o(a.r,a.g,a.b),i=Math.max(r,l),c=Math.min(r,l);return(i+.05)/(c+.05)}function nt(e){if(!e)return[0,0,0,1];const s=e.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(s){const u=s[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),d=parseInt(u.slice(2,4),16),b=parseInt(u.slice(4,6),16),g=parseInt(u.slice(6,8),16)/255;return[p,d,b,g]}if(u.length===6)return[parseInt(u.slice(0,2),16),parseInt(u.slice(2,4),16),parseInt(u.slice(4,6),16),1];if(u.length===4){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),b=parseInt(u[2]+u[2],16),g=parseInt(u[3]+u[3],16)/255;return[p,d,b,g]}if(u.length===3){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),b=parseInt(u[2]+u[2],16);return[p,d,b,1]}}const a=e.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(a)return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];const o=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);if(o)return[parseInt(o[1],10),parseInt(o[2],10),parseInt(o[3],10),1];const r=e.match(/^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(r){const u=parseFloat(r[1]),p=parseFloat(r[2]),d=parseFloat(r[3]),b=r[4]!=null?parseFloat(r[4]):1,[g,h,y]=G(u,p/100,d/100);return[g,h,y,b]}const l=e.match(/^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(l){const u=parseFloat(l[1]),p=parseFloat(l[2])/100,d=parseFloat(l[3])/100,b=l[4]!=null?parseFloat(l[4]):1,[g,h,y]=st(u,p,d);return[g,h,y,b]}const i=e.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(i){const u=i[1],p=parseFloat(i[2]),d=parseFloat(i[3]),b=i[4]!=null?parseFloat(i[4]):1,g=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[h,y,M]=lt(g,p,d);return[h,y,M,b]}const c=D(e);return c?[c.r,c.g,c.b,1]:[0,0,0,1]}function at(e,n,s,a){return`rgba(${Math.round(e)}, ${Math.round(n)}, ${Math.round(s)}, ${Math.max(0,Math.min(1,Math.round(a*100)/100))})`}function rt(e){let n=e+1831565813;return function(){return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function G(e,n,s){e=(e%360+360)%360;const a=(1-Math.abs(2*s-1))*n,o=a*(1-Math.abs(e/60%2-1)),r=s-a/2;let l,i,c;return 0<=e&&e<60?[l,i,c]=[a,o,0]:60<=e&&e<120?[l,i,c]=[o,a,0]:120<=e&&e<180?[l,i,c]=[0,a,o]:180<=e&&e<240?[l,i,c]=[0,o,a]:240<=e&&e<300?[l,i,c]=[o,0,a]:[l,i,c]=[a,0,o],[Math.round((l+r)*255),Math.round((i+r)*255),Math.round((c+r)*255)]}function st(e,n,s){e=(e%360+360)%360;const a=n+s;a>1&&(n/=a,s/=a);const[o,r,l]=G(e,1,.5).map(d=>d/255),i=1-n-s,c=o*i+n,u=r*i+n,p=l*i+n;return[Math.round(c*255),Math.round(u*255),Math.round(p*255)]}function z(e,n,s){e/=255,n/=255,s/=255;const a=Math.max(e,n,s),o=Math.min(e,n,s);let r=0,l=0;const i=(a+o)/2,c=a-o;if(c!==0){switch(l=i>.5?c/(2-a-o):c/(a+o),a){case e:r=(n-s)/c+(n<s?6:0);break;case n:r=(s-e)/c+2;break;default:r=(e-n)/c+4}r*=60}return[Math.round(r),Math.round(l*100),Math.round(i*100)]}function ot(e,n,s){const[a]=z(e,n,s),o=e/255,r=n/255,l=s/255,i=Math.min(o,r,l),c=1-Math.max(o,r,l);return[a,Math.round(i*100),Math.round(c*100)]}function U(e){const n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function L(e){const n=e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function lt(e,n,s){const a=s*Math.PI/180,o=Math.cos(a)*n,r=Math.sin(a)*n,l=e+.3963377774*o+.2158037573*r,i=e-.1055613458*o-.0638541728*r,c=e-.0894841775*o-1.291485548*r,u=l*l*l,p=i*i*i,d=c*c*c,b=4.0767416621*u-3.3077115913*p+.2309699292*d,g=-1.2684380046*u+2.6097574011*p-.3413193965*d,h=-.0041960863*u-.7034186147*p+1.707614701*d;return[L(b),L(g),L(h)]}function it(e,n,s){const a=U(e),o=U(n),r=U(s),l=.4122214708*a+.5363325363*o+.0514459929*r,i=.2119034982*a+.6806995451*o+.1073969566*r,c=.0883024619*a+.2817188376*o+.6299787005*r,u=Math.cbrt(l),p=Math.cbrt(i),d=Math.cbrt(c),b=.2104542553*u+.793617785*p-.0040720468*d,g=1.9779984951*u-2.428592205*p+.4505937099*d,h=.0259040371*u+.7827717662*p-.808675766*d,y=Math.sqrt(g*g+h*h);let M=Math.atan2(h,g)*180/Math.PI;return M<0&&(M+=360),[b,y,M]}function v(e,n,s,a,o,r){switch(o){case"hex":if(r){const l=c=>c.toString(16).padStart(2,"0"),i=Math.max(0,Math.min(255,Math.round(a*255)));return`#${l(e)}${l(n)}${l(s)}${l(i)}`}return q(e,n,s);case"rgb":return`rgb(${e}, ${n}, ${s})`;case"rgba":return`rgba(${e}, ${n}, ${s}, ${Math.round(a*100)/100})`;case"hsl":{const[l,i,c]=z(e,n,s);return`hsl(${l}, ${i}%, ${c}%)`}case"hsla":{const[l,i,c]=z(e,n,s);return`hsla(${l}, ${i}%, ${c}%, ${Math.round(a*100)/100})`}case"hwb":{const[l,i,c]=ot(e,n,s);return a<1?`hwb(${l} ${i}% ${c}% / ${Math.round(a*100)/100})`:`hwb(${l} ${i}% ${c}%)`}case"oklch":{const[l,i,c]=it(e,n,s),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(i*1e3)/1e3).toFixed(3),d=(Math.round(c*10)/10).toFixed(1),b=Math.round(a*100)/100;return r||a<1?`oklch(${u} ${p} ${d} / ${b})`:`oklch(${u} ${p} ${d})`}}}function E(e,n){return n?e==="rgb"?"rgba":e==="hsl"?"hsla":e:e==="rgba"?"rgb":e==="hsla"?"hsl":e}async function ct(e){return new Promise((n,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const o=a.result;n(o.split(",")[1])},a.onerror=o=>s(o)})}function Vt(e){return Promise.all(e.map(ct))}function xt(e){if(e.length>=4){if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e[0]===255&&e[1]===216)return"image/jpeg";if(e[0]===71&&e[1]===73&&e[2]===70)return"image/gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(e.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function Mt(e){const n=mt.decodeBase64(e??""),s=n.length,a=new Uint8Array(s);for(let o=0;o<s;o++)a[o]=n.charCodeAt(o);return a}function ut(e){const{value:n,onChange:s,onInput:a,...o}=e,r=new Map,l=t.Value.toSignal(n).map(p=>p.map((d,b)=>{const g=r.get(d),h=Mt(d??""),y=g?.type||xt(h),M=g?.name??`file-${b}`,_=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength),w=new Blob([_],{type:y});return new File([w],M,{type:y})})),i=p=>d=>{p&&Vt(d).then(b=>{for(const[g,h]of b.entries())r.set(h,{name:d[g].name,type:d[g].type});p(b)})},c=i(s),u=i(a);return k.FilesInput({...o,value:l,onChange:c,onInput:u})}function $t(e){const{value:n,onInput:s,onChange:a,...o}=e;return ut({...o,maxFiles:1,value:t.Value.map(n,r=>r==null?[]:[r]),onChange:r=>{a?.(r[0])},onInput:r=>{s?.(r[0])}})}function _t(e,n){const[s,a,o]=e,r=s<<16^a<<8^o,l=rt(r),i=6+Math.floor(l()*5),c=.18+l()*.06,u=[];for(let g=0;g<i;g++){const h=g/i*Math.PI*2,y=n*(1+(l()*2-1)*c),M=Math.cos(h)*y,_=Math.sin(h)*y;u.push({x:M,y:_})}const p=(u[0].x+u[i-1].x)/2,d=(u[0].y+u[i-1].y)/2;let b=`M ${p.toFixed(3)} ${d.toFixed(3)}`;for(let g=0;g<i;g++){const h=u[g],y=u[(g+1)%i],M=(h.x+y.x)/2,_=(h.y+y.y)/2;b+=` Q ${h.x.toFixed(3)} ${h.y.toFixed(3)} ${M.toFixed(3)} ${_.toFixed(3)}`}return b+=" Z",b}const Ct=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,displayValue:r,swatchSize:l,withAlpha:i}=e,c={xs:20,sm:26,md:32,lg:40,xl:52},u=l!=null?t.Value.map(l,m=>Number(m)):t.Value.map(e.size??"md",m=>c[m]??32),p=t.Value.map(n,m=>nt(m??"#000000")),d=t.Value.map(p,([m,V,$])=>[m,V,$]),b=t.Value.map(p,([,,,m])=>m),g=t.prop(t.Value.get(b)??1),h=t.Value.map(i??!1,m=>m),y=t.Value.map(e.colorTextFormat??"rgb",m=>m),M=t.computedOf(d,g,y,h)(([m,V,$],T,A,F)=>v(m,V,$,T??1,E(A,F),F)),_=t.Value.map(e.colorTextFormat??"hex",m=>m),w=t.Value.map(u,m=>`${-m/2} ${-m/2} ${m} ${m}`),f=t.computedOf(d,u)((m,V)=>_t(m,V/2)),I=t.computedOf(d,g,h)(([m,V,$],T,A)=>A||T<1?at(m,V,$,T):q(m,V,$)),C=t.html.div(t.attr.class("bc-color-swatch-input__control"),t.attr.class(t.Value.map(h,m=>m?"bc-color-swatch-input__control--alpha":"")),t.attr.style(t.computedOf(u)(m=>`width:${m+2}px;height:${m+2}px`)),t.svg.svg(t.attr.class("bc-color-swatch-input__svg"),t.svgAttr.viewBox(w),t.svg.path(t.svgAttr.d(f),t.svgAttr.fill(I))),t.html.input(t.attr.type("color"),N.CommonInputAttributes(e),t.attr.value(t.Value.map(d,([m,V,$])=>q(m,V,$))),t.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),s!=null?t.on.blur(s):t.Empty,a!=null?t.on.change(m=>{const V=m.target.value;if(!a)return;const{r:$,g:T,b:A}=D(V)??{r:0,g:0,b:0},F=t.Value.get(g)??1,S=E(t.Value.get(_),t.Value.get(h)),X=v($,T,A,F,S,t.Value.get(h));a(X)}):t.Empty,o!=null?t.on.input(m=>{const V=m.target.value;if(!o)return;const{r:$,g:T,b:A}=D(V)??{r:0,g:0,b:0},F=t.Value.get(g)??1,S=E(t.Value.get(_),t.Value.get(h)),X=v($,T,A,F,S,t.Value.get(h));o(X)}):t.Empty)),x=t.When(h,()=>t.html.input(t.attr.type("range"),t.attr.class("bc-color-swatch-input__alpha"),t.attr.min(0),t.attr.max(1),t.attr.step(.01),t.attr.value(t.Value.map(g,m=>String(m??1))),t.attr.disabled(e.disabled),t.on.input(m=>{const V=parseFloat(m.target.value);g.set(V);const[$,T,A]=t.Value.get(d),F=E(t.Value.get(_),t.Value.get(h)),S=v($,T,A,V,F,t.Value.get(h));o?.(S)}),t.on.change(m=>{const V=parseFloat(m.target.value);g.set(V);const[$,T,A]=t.Value.get(d),F=E(t.Value.get(_),t.Value.get(h)),S=v($,T,A,V,F,t.Value.get(h));a?.(S)}))),{swatchSize:W,displayValue:H,withAlpha:j,colorTextFormat:K,...P}=e;return B.InputContainer({baseContainer:!0,...P,growInput:!1,input:C,after:t.Fragment(t.When(r??!1,()=>t.html.span(t.attr.class("bc-color-swatch-input__rgb"),M)),x,e.after)})},pt=e=>typeof e=="string"&&e.trim()===""?null:e,dt=e=>e??"";function O(e){return n=>{const{after:s,disabled:a}=n,o=N.mapInputOptions(n,dt,pt),r=k.NullableResetAfter(n.value,a,n.onChange??n.onInput);return e({...o,after:s!=null?t.Fragment(r,s):r})}}const Tt=({startEditing:e,value:n,onChange:s,placeholder:a,disabled:o})=>{const r=t.Value.deriveProp(e??!1),l=t.prop(!1),i=t.Value.map(o??!1,c=>c);return t.html.div(t.attr.class("bc-editable-text"),t.attr.class(t.Value.map(i,c=>c?"bc-editable-text--disabled":"")),t.aria.disabled(i),t.When(r,()=>t.html.input(t.attr.placeholder(a),t.attr.value(n),t.attr.class("bc-editable-text__input"),ft.AutoSelect(),t.on.keydown(c=>{c.key==="Enter"?r.set(!1):c.key==="Escape"&&(l.set(!0),r.set(!1))}),t.on.blur(t.emitValue(c=>{if(r.set(!1),l.value){l.set(!1);return}s(c)}))),()=>t.html.span(t.on.click(()=>{t.Value.get(i)||r.set(!0)}),t.attr.class("bc-editable-text__display"),t.When(t.Value.map(n,c=>c!=null&&c.trim()!==""),()=>t.html.span(t.attr.class("bc-editable-text__text"),n),()=>t.html.span(t.attr.class("bc-editable-text__placeholder"),a)),t.When(t.Value.map(i,c=>!c),()=>t.html.button(t.attr.type("button"),t.attr.class("bc-editable-text__edit-button"),t.Use(R.BeatUII18n,c=>t.aria.label(c.$.editLabel)),t.on.click(()=>r.set(!0)),R.Icon({icon:"line-md/pencil",color:"neutral"}))))))},At=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,after:r,disabled:l}=e,i=k.NullableResetAfter(n,l,a??o);return B.InputContainer({...e,input:t.input.date(N.CommonInputAttributes(e),t.attr.valueAsDate(n),t.attr.class("bc-input"),s!=null?t.on.blur(t.emitValue(s)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDate(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDate(o)):t.Empty),after:r!=null?t.Fragment(i,r):i})},Ft=e=>{const n=e.getFullYear(),s=e.getMonth()+1,a=e.getDate(),o=e.getHours(),r=e.getMinutes(),l=e.getSeconds();return`${n}-${s.toString().padStart(2,"0")}-${a.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},kt=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,after:r,disabled:l}=e,i=t.Value.map(n,u=>u!=null?Ft(u):null),c=k.NullableResetAfter(n,l,a??o);return B.InputContainer({...e,input:t.input["datetime-local"](N.CommonInputAttributes(e),t.attr.value(t.Value.map(i,u=>u??null)),t.attr.class("bc-input"),s!=null?t.on.blur(t.emitValue(s)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDateTime(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDateTime(o)):t.Empty),after:r!=null?t.Fragment(c,r):c})},Nt=O(Q.EmailInput),St=O(N.TextInput),Rt=O(Q.PasswordInput),vt=O(k.TextArea),Et=({value:e,onChange:n,onInput:s,onBlur:a,offLabel:o,onLabel:r,disabled:l=!1,size:i="md",id:c,color:u="primary",tabIndex:p=0,matchInputHeight:d=!0,ariaLabel:b})=>{const g=c??bt.sessionId("switch");function h(w,f){const I=["bc-switch",`bc-switch--size-${f}`,`bc-switch--${f}`];return d&&I.push("bc-switch--match-input"),w&&I.push("bc-switch--disabled"),I.join(" ")}function y(w){const f=w??"primary",I=new Map,C=R.backgroundValue(f,"solid","light"),x=R.backgroundValue(f,"solid","dark");return I.set("--switch-track-on-bg",C.backgroundColor),I.set("--switch-track-on-label",C.textColor),I.set("--switch-track-on-bg-dark",x.backgroundColor),I.set("--switch-track-on-label-dark",x.textColor),I.set("--switch-track-on-border-dark",R.borderColorValue(f,"dark")),Array.from(I.entries()).map(([W,H])=>`${W}: ${H}`).join("; ")}const M=()=>{t.Value.get(l)||(n?.(!t.Value.get(e)),s?.(!t.Value.get(e)))},_=w=>{t.Value.get(l)||(w.key===" "||w.key==="Enter")&&(w.preventDefault(),M())};return t.html.div(t.attr.class(t.computedOf(l??!1,i)((w,f)=>h(w??!1,f??"md"))),t.attr.style(t.computedOf(u)(w=>y(w))),t.attr.id(g),t.attr.role("switch"),t.attr.tabindex(t.computedOf(l??!1,p)((w,f)=>w?-1:f??0)),t.aria.checked(e),t.aria.disabled(l),b!=null?t.aria.label(b):null,t.on.click(M),t.on.keydown(_),a!=null?t.on.blur(a):null,t.html.div(t.attr.class("bc-switch__track"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track--on":"bc-switch__track--off")),o!=null?t.html.div(t.aria.hidden(!0),t.attr.class("bc-switch__track-label bc-switch__track-label--off"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,r!=null?t.html.div(t.attr.class("bc-switch__track-label bc-switch__track-label--on"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),r):null,t.html.div(t.attr.class("bc-switch__thumb"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__thumb--on":"bc-switch__thumb--off")))))},Dt=O(k.UuidInput),Bt="line-md:star-alt-filled",Ot="line-md:star-alt",ht=e=>{const{value:n,onChange:s,onInput:a,disabled:o,max:r=5,fullColor:l="yellow",emptyColor:i="neutral",activeIcon:c=Bt,inactiveIcon:u=Ot,size:p="md",onBlur:d,rounding:b=1}=e,g=()=>{const f=t.Value.get(b);return f>0?f:1},h=f=>Math.min(Math.max(f,0),t.Value.get(r)),y=(f,I)=>{if(t.Value.get(o??!1))return;const x=f.currentTarget.getBoundingClientRect(),W=(f.clientX-x.left)/x.width,H=I-1+W,j=g(),K=Math.ceil(H/j)*j,P=h(K);s?.(P),a?.(P)},M=f=>{if(t.Value.get(o??!1))return;const I=g(),C=t.Value.get(n)??0;let x;switch(f.key){case"ArrowRight":case"ArrowUp":x=h(C+I);break;case"ArrowLeft":case"ArrowDown":x=h(C-I);break;case"Home":x=0;break;case"End":x=t.Value.get(r);break;default:return}f.preventDefault(),s?.(x),a?.(x)},_=t.Value.map(p,f=>`bc-icon--${f}`),w=({index:f,counter:I})=>t.html.span(t.attr.class("bc-rating-input__icon-container"),t.attr.class(_),t.on.click(t.emit(C=>y(C,I),{preventDefault:!0,stopPropagation:!0})),R.Icon({icon:u,size:p,color:i,tone:"soft"},t.attr.class("bc-rating-input__icon-empty")),t.html.span(t.attr.class("bc-rating-input__icon-clipper"),t.attr.class(_),t.style.width(t.Value.map(n,C=>{const x=Math.floor(C);return x>f?"100%":x<f?"0%":`${(C-f)*100}%`})),R.Icon({icon:c,size:p,color:l,tone:"soft"},t.attr.class("bc-rating-input__icon-full"))));return B.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...e,input:t.html.div(N.CommonInputAttributes(e),t.attr.class("bc-rating-input"),t.attr.role("slider"),t.attr.tabindex(t.Value.map(o??!1,f=>f?-1:0)),t.aria.disabled(o??!1),t.aria.valuemin(0),t.aria.valuemax(t.Value.map(r,f=>f??0)),t.aria.valuenow(t.Value.map(n,f=>f??0)),t.aria.valuetext(t.computedOf(n,r)((f,I)=>{const C=f??0,x=I??0;return`${String(C)} / ${String(x)}`})),t.on.keydown(M),d!=null?t.on.blur(d):null,t.Repeat(r,w))})},Wt=e=>{const{after:n,disabled:s}=e,a=N.mapInputOptions(e,r=>r??0,r=>r),o=k.NullableResetAfter(e.value,s,e.onChange??e.onInput);return ht({...a,after:n!=null?t.Fragment(o,n):o})},Ht=e=>{const{value:n,step:s,min:a,max:o,onBlur:r,onChange:l,onInput:i}=e;return B.InputContainer({...e,focusableSelector:'input[type="range"]',input:t.html.input(t.attr.type("range"),N.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(s),t.attr.valueAsNumber(n),t.attr.class("bc-input bc-slider-input"),r!=null?t.on.blur(t.emitValueAsNumber(r)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(l)):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(i)):t.Empty)})},Pt=e=>{const{value:n,step:s,min:a,max:o,onBlur:r,onChange:l,onInput:i}=e,c=t.Value.map(n,p=>{if(p!=null)return p;const d=a!=null?t.Value.get(a):void 0;return typeof d=="number"?d:0}),u=k.NullableResetAfter(n,e.disabled,l??i);return B.InputContainer({...e,focusableSelector:'input[type="range"]',after:u,input:t.html.input(t.attr.type("range"),N.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(s),t.attr.valueAsNumber(c),t.attr.class("bc-input bc-slider-input"),r!=null?t.on.blur(t.emitValueAsNumber(r)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(p=>{l(p)})):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(p=>{i(p)})):t.Empty)})},Ut=O(k.UrlInput);class gt{widgets=new Map;typeMapping=new Map;register(n,s){if(this.widgets.set(n,s),s.supportedTypes)for(const a of s.supportedTypes)this.typeMapping.has(a)||this.typeMapping.set(a,[]),this.typeMapping.get(a).push(n),this.typeMapping.get(a).sort((o,r)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(r)?.priority||0)-l})}unregister(n){const s=this.widgets.get(n);if(s&&(this.widgets.delete(n),s.supportedTypes))for(const a of s.supportedTypes){const o=this.typeMapping.get(a);if(o){const r=o.indexOf(n);r>=0&&o.splice(r,1),o.length===0&&this.typeMapping.delete(a)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(a=>this.widgets.get(a)).filter(Boolean)}findBestWidget(n){const s=yt.resolveWidget(n.definition,n.name);if(s?.widget){const o=this.widgets.get(s.widget);if(o)return{name:s.widget,registration:o,resolved:s}}const a=[];for(const[o,r]of this.widgets.entries())if(r.matcher)try{r.matcher(n)&&a.push({name:o,registration:r,priority:r.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(a.length>0){a.sort((r,l)=>l.priority-r.priority);const o=a[0];return{name:o.name,registration:o.registration,resolved:{widget:o.name,source:"heuristics"}}}if(typeof n.definition=="object"&&n.definition.type){const o=Array.isArray(n.definition.type)?n.definition.type[0]:n.definition.type,r=this.getForType(o);if(r.length>0){const l=this.typeMapping.get(o)[0];return{name:l,registration:r[0],resolved:{widget:l,source:"type-fallback"}}}}return null}}const Lt=new gt;function qt(e,n,s){return{factory:n,matcher:a=>{const r=a.definition["x:ui"];return r===e||typeof r=="object"&&r!==null&&r.widget===e},displayName:s?.displayName??e,priority:s?.priority??100,...s}}function zt(e,n,s){return{factory:n,matcher:a=>a.definition.format===e,displayName:s?.displayName??`${e} widget`,priority:s?.priority??75,...s}}function jt(e,n,s,a){return{factory:s,matcher:o=>{const r=o.definition;return r.type===e&&r.format===n},displayName:a?.displayName??`${e}:${n} widget`,priority:a?.priority??80,...a}}function Xt(e){const n=e?.logPrefix??"WIDGET_DIAG",s=e?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:a=>{if(!s(a))return!1;const o=a.definition,r={name:a.name,path:a.path.map(String),type:o?.type,hasRegistry:a.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${r.name??"ROOT"}" path=[${r.path.join(", ")}] type="${r.type??"unknown"}" hasRegistry=${r.hasRegistry}`),e?.onProcess?.(r),!1}}}exports.Base64Input=$t;exports.Base64sInput=ut;exports.ColorSwatchInput=Ct;exports.EditableText=Tt;exports.NullableDateInput=At;exports.NullableDateTimeInput=kt;exports.NullableEmailInput=Nt;exports.NullablePasswordInput=Rt;exports.NullableRatingInput=Wt;exports.NullableSliderInput=Pt;exports.NullableTextArea=vt;exports.NullableTextInput=St;exports.NullableUrlInput=Ut;exports.NullableUuidInput=Dt;exports.RatingInput=ht;exports.SliderInput=Ht;exports.Switch=Et;exports.WidgetRegistry=gt;exports.createDiagnosticWidget=Xt;exports.emptyToNull=pt;exports.fileToBase64=ct;exports.forFormat=zt;exports.forTypeAndFormat=jt;exports.forXUI=qt;exports.formatColor=v;exports.getContrastRatio=It;exports.globalWidgetRegistry=Lt;exports.hexToRgb=D;exports.hslToRgb=G;exports.hwbToRgb=st;exports.isValidColor=wt;exports.isValidHexColor=Y;exports.isValidHslColor=tt;exports.isValidRgbColor=Z;exports.isValidRgbaColor=J;exports.linearToSrgb=L;exports.mulberry32=rt;exports.normalizeHexColor=et;exports.nullToEmpty=dt;exports.oklchToRgb=lt;exports.parseAnyColor=nt;exports.resolveEffectiveFormat=E;exports.rgbToHex=q;exports.rgbToHsl=z;exports.rgbToHwb=ot;exports.rgbToOklch=it;exports.srgbToLinear=U;exports.toRgbaString=at;
|
|
1
|
+
"use strict";const t=require("@tempots/dom"),k=require("./deep-merge-B33Qtlmw.cjs"),mt=require("@tempots/std"),B=require("./input-container-BkPcNDaZ.cjs"),N=require("./text-input-D_IxFd0M.cjs"),R=require("./translations-qefRsdGi.cjs"),ft=require("@tempots/ui"),Q=require("./notice-BBnSXYUc.cjs"),bt=require("./session-id-B5lJMzbB.cjs"),yt=require("./utils-DmEuG3Np.cjs");function Y(e){if(typeof e!="string")return!1;const n=e.startsWith("#")?e.slice(1):e;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function Z(e){if(typeof e!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r]=s,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(r,10);return l>=0&&l<=255&&i>=0&&i<=255&&c>=0&&c<=255}function J(e){if(typeof e!="string")return!1;const n=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r,l]=s,i=parseInt(a,10),c=parseInt(o,10),u=parseInt(r,10),p=parseFloat(l);return i>=0&&i<=255&&c>=0&&c<=255&&u>=0&&u<=255&&p>=0&&p<=1}function tt(e){if(typeof e!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,s=e.match(n);if(!s)return!1;const[,a,o,r]=s,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(r,10);return l>=0&&l<=360&&i>=0&&i<=100&&c>=0&&c<=100}function wt(e){return Y(e)||Z(e)||J(e)||tt(e)}function et(e){if(!Y(e))return null;let n=e.startsWith("#")?e.slice(1):e;return n.length===3&&(n=n.split("").map(s=>s+s).join("")),`#${n.toLowerCase()}`}function q(e,n,s){const a=o=>{const r=Math.round(Math.max(0,Math.min(255,o))).toString(16);return r.length===1?"0"+r:r};return`#${a(e)}${a(n)}${a(s)}`}function D(e){const n=et(e);if(!n)return null;const s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:null}function It(e,n){const s=D(e),a=D(n);if(!s||!a)return null;const o=(u,p,d)=>{const[b,g,h]=[u,p,d].map(y=>(y=y/255,y<=.03928?y/12.92:Math.pow((y+.055)/1.055,2.4)));return .2126*b+.7152*g+.0722*h},r=o(s.r,s.g,s.b),l=o(a.r,a.g,a.b),i=Math.max(r,l),c=Math.min(r,l);return(i+.05)/(c+.05)}function nt(e){if(!e)return[0,0,0,1];const s=e.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(s){const u=s[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),d=parseInt(u.slice(2,4),16),b=parseInt(u.slice(4,6),16),g=parseInt(u.slice(6,8),16)/255;return[p,d,b,g]}if(u.length===6)return[parseInt(u.slice(0,2),16),parseInt(u.slice(2,4),16),parseInt(u.slice(4,6),16),1];if(u.length===4){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),b=parseInt(u[2]+u[2],16),g=parseInt(u[3]+u[3],16)/255;return[p,d,b,g]}if(u.length===3){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),b=parseInt(u[2]+u[2],16);return[p,d,b,1]}}const a=e.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(a)return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];const o=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);if(o)return[parseInt(o[1],10),parseInt(o[2],10),parseInt(o[3],10),1];const r=e.match(/^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(r){const u=parseFloat(r[1]),p=parseFloat(r[2]),d=parseFloat(r[3]),b=r[4]!=null?parseFloat(r[4]):1,[g,h,y]=G(u,p/100,d/100);return[g,h,y,b]}const l=e.match(/^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(l){const u=parseFloat(l[1]),p=parseFloat(l[2])/100,d=parseFloat(l[3])/100,b=l[4]!=null?parseFloat(l[4]):1,[g,h,y]=st(u,p,d);return[g,h,y,b]}const i=e.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(i){const u=i[1],p=parseFloat(i[2]),d=parseFloat(i[3]),b=i[4]!=null?parseFloat(i[4]):1,g=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[h,y,M]=lt(g,p,d);return[h,y,M,b]}const c=D(e);return c?[c.r,c.g,c.b,1]:[0,0,0,1]}function at(e,n,s,a){return`rgba(${Math.round(e)}, ${Math.round(n)}, ${Math.round(s)}, ${Math.max(0,Math.min(1,Math.round(a*100)/100))})`}function rt(e){let n=e+1831565813;return function(){return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function G(e,n,s){e=(e%360+360)%360;const a=(1-Math.abs(2*s-1))*n,o=a*(1-Math.abs(e/60%2-1)),r=s-a/2;let l,i,c;return 0<=e&&e<60?[l,i,c]=[a,o,0]:60<=e&&e<120?[l,i,c]=[o,a,0]:120<=e&&e<180?[l,i,c]=[0,a,o]:180<=e&&e<240?[l,i,c]=[0,o,a]:240<=e&&e<300?[l,i,c]=[o,0,a]:[l,i,c]=[a,0,o],[Math.round((l+r)*255),Math.round((i+r)*255),Math.round((c+r)*255)]}function st(e,n,s){e=(e%360+360)%360;const a=n+s;a>1&&(n/=a,s/=a);const[o,r,l]=G(e,1,.5).map(d=>d/255),i=1-n-s,c=o*i+n,u=r*i+n,p=l*i+n;return[Math.round(c*255),Math.round(u*255),Math.round(p*255)]}function z(e,n,s){e/=255,n/=255,s/=255;const a=Math.max(e,n,s),o=Math.min(e,n,s);let r=0,l=0;const i=(a+o)/2,c=a-o;if(c!==0){switch(l=i>.5?c/(2-a-o):c/(a+o),a){case e:r=(n-s)/c+(n<s?6:0);break;case n:r=(s-e)/c+2;break;default:r=(e-n)/c+4}r*=60}return[Math.round(r),Math.round(l*100),Math.round(i*100)]}function ot(e,n,s){const[a]=z(e,n,s),o=e/255,r=n/255,l=s/255,i=Math.min(o,r,l),c=1-Math.max(o,r,l);return[a,Math.round(i*100),Math.round(c*100)]}function U(e){const n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function L(e){const n=e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function lt(e,n,s){const a=s*Math.PI/180,o=Math.cos(a)*n,r=Math.sin(a)*n,l=e+.3963377774*o+.2158037573*r,i=e-.1055613458*o-.0638541728*r,c=e-.0894841775*o-1.291485548*r,u=l*l*l,p=i*i*i,d=c*c*c,b=4.0767416621*u-3.3077115913*p+.2309699292*d,g=-1.2684380046*u+2.6097574011*p-.3413193965*d,h=-.0041960863*u-.7034186147*p+1.707614701*d;return[L(b),L(g),L(h)]}function it(e,n,s){const a=U(e),o=U(n),r=U(s),l=.4122214708*a+.5363325363*o+.0514459929*r,i=.2119034982*a+.6806995451*o+.1073969566*r,c=.0883024619*a+.2817188376*o+.6299787005*r,u=Math.cbrt(l),p=Math.cbrt(i),d=Math.cbrt(c),b=.2104542553*u+.793617785*p-.0040720468*d,g=1.9779984951*u-2.428592205*p+.4505937099*d,h=.0259040371*u+.7827717662*p-.808675766*d,y=Math.sqrt(g*g+h*h);let M=Math.atan2(h,g)*180/Math.PI;return M<0&&(M+=360),[b,y,M]}function v(e,n,s,a,o,r){switch(o){case"hex":if(r){const l=c=>c.toString(16).padStart(2,"0"),i=Math.max(0,Math.min(255,Math.round(a*255)));return`#${l(e)}${l(n)}${l(s)}${l(i)}`}return q(e,n,s);case"rgb":return`rgb(${e}, ${n}, ${s})`;case"rgba":return`rgba(${e}, ${n}, ${s}, ${Math.round(a*100)/100})`;case"hsl":{const[l,i,c]=z(e,n,s);return`hsl(${l}, ${i}%, ${c}%)`}case"hsla":{const[l,i,c]=z(e,n,s);return`hsla(${l}, ${i}%, ${c}%, ${Math.round(a*100)/100})`}case"hwb":{const[l,i,c]=ot(e,n,s);return a<1?`hwb(${l} ${i}% ${c}% / ${Math.round(a*100)/100})`:`hwb(${l} ${i}% ${c}%)`}case"oklch":{const[l,i,c]=it(e,n,s),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(i*1e3)/1e3).toFixed(3),d=(Math.round(c*10)/10).toFixed(1),b=Math.round(a*100)/100;return r||a<1?`oklch(${u} ${p} ${d} / ${b})`:`oklch(${u} ${p} ${d})`}}}function E(e,n){return n?e==="rgb"?"rgba":e==="hsl"?"hsla":e:e==="rgba"?"rgb":e==="hsla"?"hsl":e}async function ct(e){return new Promise((n,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const o=a.result;n(o.split(",")[1])},a.onerror=o=>s(o)})}function Vt(e){return Promise.all(e.map(ct))}function xt(e){if(e.length>=4){if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e[0]===255&&e[1]===216)return"image/jpeg";if(e[0]===71&&e[1]===73&&e[2]===70)return"image/gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(e.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function Mt(e){const n=mt.decodeBase64(e??""),s=n.length,a=new Uint8Array(s);for(let o=0;o<s;o++)a[o]=n.charCodeAt(o);return a}function ut(e){const{value:n,onChange:s,onInput:a,...o}=e,r=new Map,l=t.Value.toSignal(n).map(p=>p.map((d,b)=>{const g=r.get(d),h=Mt(d??""),y=g?.type||xt(h),M=g?.name??`file-${b}`,_=h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength),w=new Blob([_],{type:y});return new File([w],M,{type:y})})),i=p=>d=>{p&&Vt(d).then(b=>{for(const[g,h]of b.entries())r.set(h,{name:d[g].name,type:d[g].type});p(b)})},c=i(s),u=i(a);return k.FilesInput({...o,value:l,onChange:c,onInput:u})}function $t(e){const{value:n,onInput:s,onChange:a,...o}=e;return ut({...o,maxFiles:1,value:t.Value.map(n,r=>r==null?[]:[r]),onChange:r=>{a?.(r[0])},onInput:r=>{s?.(r[0])}})}function _t(e,n){const[s,a,o]=e,r=s<<16^a<<8^o,l=rt(r),i=6+Math.floor(l()*5),c=.18+l()*.06,u=[];for(let g=0;g<i;g++){const h=g/i*Math.PI*2,y=n*(1+(l()*2-1)*c),M=Math.cos(h)*y,_=Math.sin(h)*y;u.push({x:M,y:_})}const p=(u[0].x+u[i-1].x)/2,d=(u[0].y+u[i-1].y)/2;let b=`M ${p.toFixed(3)} ${d.toFixed(3)}`;for(let g=0;g<i;g++){const h=u[g],y=u[(g+1)%i],M=(h.x+y.x)/2,_=(h.y+y.y)/2;b+=` Q ${h.x.toFixed(3)} ${h.y.toFixed(3)} ${M.toFixed(3)} ${_.toFixed(3)}`}return b+=" Z",b}const Ct=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,displayValue:r,swatchSize:l,withAlpha:i}=e,c={xs:20,sm:26,md:32,lg:40,xl:52},u=l!=null?t.Value.map(l,m=>Number(m)):t.Value.map(e.size??"md",m=>c[m]??32),p=t.Value.map(n,m=>nt(m??"#000000")),d=t.Value.map(p,([m,V,$])=>[m,V,$]),b=t.Value.map(p,([,,,m])=>m),g=t.prop(t.Value.get(b)??1),h=t.Value.map(i??!1,m=>m),y=t.Value.map(e.colorTextFormat??"rgb",m=>m),M=t.computedOf(d,g,y,h)(([m,V,$],T,A,F)=>v(m,V,$,T??1,E(A,F),F)),_=t.Value.map(e.colorTextFormat??"hex",m=>m),w=t.Value.map(u,m=>`${-m/2} ${-m/2} ${m} ${m}`),f=t.computedOf(d,u)((m,V)=>_t(m,V/2)),I=t.computedOf(d,g,h)(([m,V,$],T,A)=>A||T<1?at(m,V,$,T):q(m,V,$)),C=t.html.div(t.attr.class("bc-color-swatch-input__control"),t.attr.class(t.Value.map(h,m=>m?"bc-color-swatch-input__control--alpha":"")),t.attr.style(t.computedOf(u)(m=>`width:${m+2}px;height:${m+2}px`)),t.svg.svg(t.attr.class("bc-color-swatch-input__svg"),t.svgAttr.viewBox(w),t.svg.path(t.svgAttr.d(f),t.svgAttr.fill(I))),t.html.input(t.attr.type("color"),N.CommonInputAttributes(e),t.attr.value(t.Value.map(d,([m,V,$])=>q(m,V,$))),t.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),s!=null?t.on.blur(s):t.Empty,a!=null?t.on.change(m=>{const V=m.target.value;if(!a)return;const{r:$,g:T,b:A}=D(V)??{r:0,g:0,b:0},F=t.Value.get(g)??1,S=E(t.Value.get(_),t.Value.get(h)),X=v($,T,A,F,S,t.Value.get(h));a(X)}):t.Empty,o!=null?t.on.input(m=>{const V=m.target.value;if(!o)return;const{r:$,g:T,b:A}=D(V)??{r:0,g:0,b:0},F=t.Value.get(g)??1,S=E(t.Value.get(_),t.Value.get(h)),X=v($,T,A,F,S,t.Value.get(h));o(X)}):t.Empty)),x=t.When(h,()=>t.html.input(t.attr.type("range"),t.attr.class("bc-color-swatch-input__alpha"),t.attr.min(0),t.attr.max(1),t.attr.step(.01),t.attr.value(t.Value.map(g,m=>String(m??1))),t.attr.disabled(e.disabled),t.on.input(m=>{const V=parseFloat(m.target.value);g.set(V);const[$,T,A]=t.Value.get(d),F=E(t.Value.get(_),t.Value.get(h)),S=v($,T,A,V,F,t.Value.get(h));o?.(S)}),t.on.change(m=>{const V=parseFloat(m.target.value);g.set(V);const[$,T,A]=t.Value.get(d),F=E(t.Value.get(_),t.Value.get(h)),S=v($,T,A,V,F,t.Value.get(h));a?.(S)}))),{swatchSize:W,displayValue:H,withAlpha:j,colorTextFormat:K,...P}=e;return B.InputContainer({baseContainer:!0,...P,growInput:!1,input:C,after:t.Fragment(t.When(r??!1,()=>t.html.span(t.attr.class("bc-color-swatch-input__rgb"),M)),x,e.after)})},pt=e=>typeof e=="string"&&e.trim()===""?null:e,dt=e=>e??"";function O(e){return n=>{const{after:s,disabled:a}=n,o=N.mapInputOptions(n,dt,pt),r=k.NullableResetAfter(n.value,a,n.onChange??n.onInput);return e({...o,after:s!=null?t.Fragment(r,s):r})}}const Tt=({startEditing:e,value:n,onChange:s,placeholder:a,disabled:o})=>{const r=t.Value.deriveProp(e??!1),l=t.prop(!1),i=t.Value.map(o??!1,c=>c);return t.html.div(t.attr.class("bc-editable-text"),t.attr.class(t.Value.map(i,c=>c?"bc-editable-text--disabled":"")),t.aria.disabled(i),t.When(r,()=>t.html.input(t.attr.placeholder(a),t.attr.value(n),t.attr.class("bc-editable-text__input"),ft.AutoSelect(),t.on.keydown(c=>{c.key==="Enter"?r.set(!1):c.key==="Escape"&&(l.set(!0),r.set(!1))}),t.on.blur(t.emitValue(c=>{if(r.set(!1),l.value){l.set(!1);return}s(c)}))),()=>t.html.span(t.on.click(()=>{t.Value.get(i)||r.set(!0)}),t.attr.class("bc-editable-text__display"),t.When(t.Value.map(n,c=>c!=null&&c.trim()!==""),()=>t.html.span(t.attr.class("bc-editable-text__text"),n),()=>t.html.span(t.attr.class("bc-editable-text__placeholder"),a)),t.When(t.Value.map(i,c=>!c),()=>t.html.button(t.attr.type("button"),t.attr.class("bc-editable-text__edit-button"),t.Use(R.BeatUII18n,c=>t.aria.label(c.$.editLabel)),t.on.click(()=>r.set(!0)),R.Icon({icon:"line-md/pencil",color:"neutral"}))))))},At=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,after:r,disabled:l}=e,i=k.NullableResetAfter(n,l,a??o);return B.InputContainer({...e,input:t.input.date(N.CommonInputAttributes(e),t.attr.valueAsDate(n),t.attr.class("bc-input"),s!=null?t.on.blur(t.emitValue(s)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDate(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDate(o)):t.Empty),after:r!=null?t.Fragment(i,r):i})},Ft=e=>{const n=e.getFullYear(),s=e.getMonth()+1,a=e.getDate(),o=e.getHours(),r=e.getMinutes(),l=e.getSeconds();return`${n}-${s.toString().padStart(2,"0")}-${a.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},kt=e=>{const{value:n,onBlur:s,onChange:a,onInput:o,after:r,disabled:l}=e,i=t.Value.map(n,u=>u!=null?Ft(u):null),c=k.NullableResetAfter(n,l,a??o);return B.InputContainer({...e,input:t.input["datetime-local"](N.CommonInputAttributes(e),t.attr.value(t.Value.map(i,u=>u??null)),t.attr.class("bc-input"),s!=null?t.on.blur(t.emitValue(s)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDateTime(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDateTime(o)):t.Empty),after:r!=null?t.Fragment(c,r):c})},Nt=O(Q.EmailInput),St=O(N.TextInput),Rt=O(Q.PasswordInput),vt=O(k.TextArea),Et=({value:e,onChange:n,onInput:s,onBlur:a,offLabel:o,onLabel:r,disabled:l=!1,size:i="md",id:c,color:u="primary",tabIndex:p=0,matchInputHeight:d=!0,ariaLabel:b})=>{const g=c??bt.sessionId("switch");function h(w,f){const I=["bc-switch",`bc-switch--size-${f}`,`bc-switch--${f}`];return d&&I.push("bc-switch--match-input"),w&&I.push("bc-switch--disabled"),I.join(" ")}function y(w){const f=w??"primary",I=new Map,C=R.backgroundValue(f,"solid","light"),x=R.backgroundValue(f,"solid","dark");return I.set("--switch-track-on-bg",C.backgroundColor),I.set("--switch-track-on-label",C.textColor),I.set("--switch-track-on-bg-dark",x.backgroundColor),I.set("--switch-track-on-label-dark",x.textColor),I.set("--switch-track-on-border-dark",R.borderColorValue(f,"dark")),Array.from(I.entries()).map(([W,H])=>`${W}: ${H}`).join("; ")}const M=()=>{t.Value.get(l)||(n?.(!t.Value.get(e)),s?.(!t.Value.get(e)))},_=w=>{t.Value.get(l)||(w.key===" "||w.key==="Enter")&&(w.preventDefault(),M())};return t.html.div(t.attr.class(t.computedOf(l??!1,i)((w,f)=>h(w??!1,f??"md"))),t.attr.style(t.computedOf(u)(w=>y(w))),t.attr.id(g),t.attr.role("switch"),t.attr.tabindex(t.computedOf(l??!1,p)((w,f)=>w?-1:f??0)),t.aria.checked(e),t.aria.disabled(l),b!=null?t.aria.label(b):null,t.on.click(M),t.on.keydown(_),a!=null?t.on.blur(a):null,t.html.div(t.attr.class("bc-switch__track"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track--on":"bc-switch__track--off")),o!=null?t.html.div(t.aria.hidden(!0),t.attr.class("bc-switch__track-label bc-switch__track-label--off"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,r!=null?t.html.div(t.attr.class("bc-switch__track-label bc-switch__track-label--on"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),r):null,t.html.div(t.attr.class("bc-switch__thumb"),t.attr.class(t.Value.map(e,w=>w?"bc-switch__thumb--on":"bc-switch__thumb--off")))))},Dt=O(k.UuidInput),Bt="line-md:star-alt-filled",Ot="line-md:star-alt",ht=e=>{const{value:n,onChange:s,onInput:a,disabled:o,max:r=5,fullColor:l="yellow",emptyColor:i="neutral",activeIcon:c=Bt,inactiveIcon:u=Ot,size:p="md",onBlur:d,rounding:b=1}=e,g=()=>{const f=t.Value.get(b);return f>0?f:1},h=f=>Math.min(Math.max(f,0),t.Value.get(r)),y=(f,I)=>{if(t.Value.get(o??!1))return;const x=f.currentTarget.getBoundingClientRect(),W=(f.clientX-x.left)/x.width,H=I-1+W,j=g(),K=Math.ceil(H/j)*j,P=h(K);s?.(P),a?.(P)},M=f=>{if(t.Value.get(o??!1))return;const I=g(),C=t.Value.get(n)??0;let x;switch(f.key){case"ArrowRight":case"ArrowUp":x=h(C+I);break;case"ArrowLeft":case"ArrowDown":x=h(C-I);break;case"Home":x=0;break;case"End":x=t.Value.get(r);break;default:return}f.preventDefault(),s?.(x),a?.(x)},_=t.Value.map(p,f=>`bc-icon--${f}`),w=({index:f,counter:I})=>t.html.span(t.attr.class("bc-rating-input__icon-container"),t.attr.class(_),t.on.click(t.emit(C=>y(C,I),{preventDefault:!0,stopPropagation:!0})),R.Icon({icon:u,size:p,color:i,tone:"soft"},t.attr.class("bc-rating-input__icon-empty")),t.html.span(t.attr.class("bc-rating-input__icon-clipper"),t.attr.class(_),t.style.width(t.Value.map(n,C=>{const x=Math.floor(C);return x>f?"100%":x<f?"0%":`${(C-f)*100}%`})),R.Icon({icon:c,size:p,color:l,tone:"soft"},t.attr.class("bc-rating-input__icon-full"))));return B.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...e,input:t.html.div(N.CommonInputAttributes(e),t.attr.class("bc-rating-input"),t.attr.role("slider"),t.attr.tabindex(t.Value.map(o??!1,f=>f?-1:0)),t.aria.disabled(o??!1),t.aria.valuemin(0),t.aria.valuemax(t.Value.map(r,f=>f??0)),t.aria.valuenow(t.Value.map(n,f=>f??0)),t.aria.valuetext(t.computedOf(n,r)((f,I)=>{const C=f??0,x=I??0;return`${String(C)} / ${String(x)}`})),t.on.keydown(M),d!=null?t.on.blur(d):null,t.Repeat(r,w))})},Wt=e=>{const{after:n,disabled:s}=e,a=N.mapInputOptions(e,r=>r??0,r=>r),o=k.NullableResetAfter(e.value,s,e.onChange??e.onInput);return ht({...a,after:n!=null?t.Fragment(o,n):o})},Ht=e=>{const{value:n,step:s,min:a,max:o,onBlur:r,onChange:l,onInput:i}=e;return B.InputContainer({...e,focusableSelector:'input[type="range"]',input:t.html.input(t.attr.type("range"),N.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(s),t.attr.valueAsNumber(n),t.attr.class("bc-input bc-slider-input"),r!=null?t.on.blur(t.emitValueAsNumber(r)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(l)):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(i)):t.Empty)})},Pt=e=>{const{value:n,step:s,min:a,max:o,onBlur:r,onChange:l,onInput:i}=e,c=t.Value.map(n,p=>{if(p!=null)return p;const d=a!=null?t.Value.get(a):void 0;return typeof d=="number"?d:0}),u=k.NullableResetAfter(n,e.disabled,l??i);return B.InputContainer({...e,focusableSelector:'input[type="range"]',after:u,input:t.html.input(t.attr.type("range"),N.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(s),t.attr.valueAsNumber(c),t.attr.class("bc-input bc-slider-input"),r!=null?t.on.blur(t.emitValueAsNumber(r)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(p=>{l(p)})):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(p=>{i(p)})):t.Empty)})},Ut=O(k.UrlInput);class gt{widgets=new Map;typeMapping=new Map;register(n,s){if(this.widgets.set(n,s),s.supportedTypes)for(const a of s.supportedTypes)this.typeMapping.has(a)||this.typeMapping.set(a,[]),this.typeMapping.get(a).push(n),this.typeMapping.get(a).sort((o,r)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(r)?.priority||0)-l})}unregister(n){const s=this.widgets.get(n);if(s&&(this.widgets.delete(n),s.supportedTypes))for(const a of s.supportedTypes){const o=this.typeMapping.get(a);if(o){const r=o.indexOf(n);r>=0&&o.splice(r,1),o.length===0&&this.typeMapping.delete(a)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(a=>this.widgets.get(a)).filter(Boolean)}findBestWidget(n){const s=yt.resolveWidget(n.definition,n.name);if(s?.widget){const o=this.widgets.get(s.widget);if(o)return{name:s.widget,registration:o,resolved:s}}const a=[];for(const[o,r]of this.widgets.entries())if(r.matcher)try{r.matcher(n)&&a.push({name:o,registration:r,priority:r.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(a.length>0){a.sort((r,l)=>l.priority-r.priority);const o=a[0];return{name:o.name,registration:o.registration,resolved:{widget:o.name,source:"heuristics"}}}if(typeof n.definition=="object"&&n.definition.type){const o=Array.isArray(n.definition.type)?n.definition.type[0]:n.definition.type,r=this.getForType(o);if(r.length>0){const l=this.typeMapping.get(o)[0];return{name:l,registration:r[0],resolved:{widget:l,source:"type-fallback"}}}}return null}}const Lt=new gt;function qt(e,n,s){return{factory:n,matcher:a=>{const r=a.definition["x:ui"];return r===e||typeof r=="object"&&r!==null&&r.widget===e},displayName:s?.displayName??e,priority:s?.priority??100,...s}}function zt(e,n,s){return{factory:n,matcher:a=>a.definition.format===e,displayName:s?.displayName??`${e} widget`,priority:s?.priority??75,...s}}function jt(e,n,s,a){return{factory:s,matcher:o=>{const r=o.definition;return r.type===e&&r.format===n},displayName:a?.displayName??`${e}:${n} widget`,priority:a?.priority??80,...a}}function Xt(e){const n=e?.logPrefix??"WIDGET_DIAG",s=e?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:a=>{if(!s(a))return!1;const o=a.definition,r={name:a.name,path:a.path.map(String),type:o?.type,hasRegistry:a.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${r.name??"ROOT"}" path=[${r.path.join(", ")}] type="${r.type??"unknown"}" hasRegistry=${r.hasRegistry}`),e?.onProcess?.(r),!1}}}exports.Base64Input=$t;exports.Base64sInput=ut;exports.ColorSwatchInput=Ct;exports.EditableText=Tt;exports.NullableDateInput=At;exports.NullableDateTimeInput=kt;exports.NullableEmailInput=Nt;exports.NullablePasswordInput=Rt;exports.NullableRatingInput=Wt;exports.NullableSliderInput=Pt;exports.NullableTextArea=vt;exports.NullableTextInput=St;exports.NullableUrlInput=Ut;exports.NullableUuidInput=Dt;exports.RatingInput=ht;exports.SliderInput=Ht;exports.Switch=Et;exports.WidgetRegistry=gt;exports.createDiagnosticWidget=Xt;exports.emptyToNull=pt;exports.fileToBase64=ct;exports.forFormat=zt;exports.forTypeAndFormat=jt;exports.forXUI=qt;exports.formatColor=v;exports.getContrastRatio=It;exports.globalWidgetRegistry=Lt;exports.hexToRgb=D;exports.hslToRgb=G;exports.hwbToRgb=st;exports.isValidColor=wt;exports.isValidHexColor=Y;exports.isValidHslColor=tt;exports.isValidRgbColor=Z;exports.isValidRgbaColor=J;exports.linearToSrgb=L;exports.mulberry32=rt;exports.normalizeHexColor=et;exports.nullToEmpty=dt;exports.oklchToRgb=lt;exports.parseAnyColor=nt;exports.resolveEffectiveFormat=E;exports.rgbToHex=q;exports.rgbToHsl=z;exports.rgbToHwb=ot;exports.rgbToOklch=it;exports.srgbToLinear=U;exports.toRgbaString=at;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Value as p, prop as ut, computedOf as D, html as _, attr as u, svg as ot, svgAttr as J, Empty as A, on as I, When as z, Fragment as j, aria as R, emitValue as at, Use as ft, input as pt, emitValueAsNullableDate as ct, emitValueAsNullableDateTime as it, Repeat as mt, emit as bt, style as wt, emitValueAsNumber as E } from "@tempots/dom";
|
|
2
|
-
import { F as yt, N as X, T as Mt, U as It, a as $t } from "./deep-merge-
|
|
2
|
+
import { F as yt, N as X, T as Mt, U as It, a as $t } from "./deep-merge-BUsrE2v4.js";
|
|
3
3
|
import { decodeBase64 as xt } from "@tempots/std";
|
|
4
4
|
import { I as P } from "./input-container-CO3DNqpp.js";
|
|
5
5
|
import { C as O, m as dt, T as _t } from "./text-input-BAn02BzO.js";
|
|
6
6
|
import { B as kt, I as et, b as lt, a as Ft } from "./translations-DT5QQ4WO.js";
|
|
7
7
|
import { AutoSelect as Ct } from "@tempots/ui";
|
|
8
|
-
import { E as Tt, P as St } from "./notice-
|
|
8
|
+
import { E as Tt, P as St } from "./notice-BXKtBEiC.js";
|
|
9
9
|
import { s as At } from "./session-id-3KiilioY.js";
|
|
10
10
|
import { r as vt } from "./utils-vUtP6iPG.js";
|
|
11
11
|
function ht(t) {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("@tempots/dom"),B=require("./input-container-BkPcNDaZ.cjs"),A=require("./text-input-D_IxFd0M.cjs"),O=require("./use-form-BvBkVEKi.cjs"),C=require("./translations-qefRsdGi.cjs"),ut=require("./stack-dwLevGa2.cjs"),L=require("@tempots/std"),It=require("@tempots/ui");let G=null;async function H(){const n=globalThis;return n.Temporal?n.Temporal:(G||(G=Promise.resolve().then(()=>require("./index.esm-C6lZ02yY.cjs")).then(e=>{const l=e.Temporal;return n.Temporal||(n.Temporal=l),l})),G)}const ct=(n,e)=>e?t.Task(H,{then:n,pending:e.pending,error:e.error}):t.Task(H,n);function Z({onChange:n,value:e,accept:l="*/*",enableClick:r=!0,content:o,disabled:h=!1,allowMultiple:s}){return t.Use(C.BeatUII18n,f=>{const m=t.Value.deriveProp(e??[]),x=t.prop(!1),p=u=>{u.preventDefault(),u.stopPropagation(),x.value=!0},d=u=>{u.preventDefault(),u.stopPropagation(),(!u.currentTarget||!u.currentTarget.contains(u.relatedTarget))&&(x.value=!1)},b=u=>{u.preventDefault(),u.stopPropagation(),x.value=!1;const g=Array.from(u.dataTransfer?.files||[]);g.length>0&&(m.value=g,n(g,"dragdrop"))},a=u=>{t.Value.get(r)&&u.currentTarget.querySelector('input[type="file"]')?.click()};let c=null;const I=()=>{if(c==null)return;const u=Array.from(c.files??[]);u.length>0&&(m.value=u,n(u,"click")),c.value=""},k=u=>{t.Value.get(r)&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),a(u))};return t.html.div(t.attr.role("button"),t.attr.tabindex(t.Value.map(r,u=>u?0:-1)),t.attr.style("position: relative;"),t.on.dragover(p),t.on.dragleave(d),t.on.drop(b),t.on.click(a),t.on.keydown(k),t.html.input(t.attr.type("file"),t.attr.disabled(h),t.attr.accept(l),t.attr.multiple(s),t.attr.style("position: absolute; left: -9999px; opacity: 0; pointer-events: none;"),t.on.change(I),t.WithElement(u=>(c=u,m.on(g=>{const _=globalThis.DataTransfer;if(_!=null){const w=new _;g.forEach($=>w.items.add($)),u.files=w.files}}),t.Empty))),t.aria.label(t.bind(f.$.dropZoneInstructions)(r)),o({files:m,clear:()=>m.value=[],change:u=>m.set(u)}))})}const K="$$tts-exp-",pt=(n,e)=>t.WithElement(l=>{const r=`${K}${n}`;return t.OnDispose(t.Value.on(e,o=>Reflect.set(l,r,o)))}),wt=(n,e)=>{const l=`${K}${n}`;return r=>{e(Reflect.get(r.target,l))}},X=(n,e)=>{const l=`${K}${n}`;return r=>{const o=r.target,h=o.selectedIndex,s=o.options[h];e(Reflect.get(s,l))}},ft=(n,e,l)=>t.Ensure(n,r=>t.OneOfType(r,{value:o=>{const h=t.computedOf(o,l)((s,f)=>e(s.value,f));return t.html.option(t.attr.selected(h),pt("value",o.$.value),o.$.label)},group:o=>t.html.optgroup(t.attr.label(o.$.group),t.ForEach(o.$.options,h=>ft(h,e,l))),break:()=>t.html.hr()})),dt=n=>{const{value:e,onBlur:l,onChange:r,onInput:o,options:h,unselectedLabel:s,equality:f=(p,d)=>p===d,after:m}=n;let x;return B.InputContainer({...n,after:t.Fragment(B.InputIcon({icon:"ph:caret-up-down-bold",color:"neutral",size:"sm"}),m),input:t.html.select(t.WithElement(p=>{x=p;const d=new MutationObserver(b=>{const{removedNodes:a}=b[0];a.length>0&&(x.selectedIndex=0)});return d.observe(p,{childList:!0}),t.OnDispose(()=>d.disconnect())}),A.CommonInputAttributes(n),t.attr.class("bc-native-select bc-input"),t.Use(C.BeatUII18n,p=>t.html.option(t.attr.hidden("hidden"),t.coalesce(s,p.$.selectOne))),t.ForEach(h,p=>ft(p,f,e)),l!=null?t.on.blur(l):t.Empty,r!=null?t.on.change(X("value",p=>r(p))):t.Empty,o!=null?t.on.input(X("value",p=>o(p))):t.Empty)},t.on.click(()=>{if(x?.focus(),typeof x?.showPicker=="function")try{x.showPicker()}catch{}}))};function mt(n){const{controller:e,onChange:l,onBlur:r,...o}=n;return dt({...o,value:e.signal,onChange:O.makeOnChangeHandler(e,l),onBlur:O.makeOnBlurHandler(e,r)})}function Ct(n){return O.InputWrapper({...n,content:mt(n)})}function tt(n,e,l){const r=t.Value.map(n,s=>s!=null),o=t.computedOf(r,e??!1)((s,f)=>!s||f),h=C.defaultMessages.clearValue;return t.html.button(t.attr.type("button"),t.attr.class("bc-input-container__reset"),t.aria.label(h),t.attr.title(h),t.attr.disabled(o),C.Icon({icon:"mdi:close",size:"sm"}),t.on.click(s=>{s.stopPropagation(),l?.(null)}))}function Q(...n){return t.html.div(t.attr.class("bc-group"),...n)}function _t(n){const e=String(n),l=e.indexOf(".");return l===-1?0:e.length-l-1}function N(n,e){const l=_t(e);if(l===0)return Math.round(n);const r=Math.pow(10,l);return Math.round(n*r)/r}const kt=n=>{const{value:e,step:l,min:r,max:o,onBlur:h,onChange:s,onInput:f,after:m}=n,x=b=>{const a=r!=null?t.Value.get(r):void 0,c=o!=null?t.Value.get(o):void 0;return a!=null&&b<a?a:c!=null&&b>c?c:b},p=l!=null?t.Use(C.BeatUII18n,b=>{const a=t.computedOf(e,r)((u,g)=>g==null?!0:(u??0)>g),c=t.computedOf(e,o)((u,g)=>g==null?!0:(u??0)<g),I=u=>{const g=t.Value.get(e)??0,_=t.Value.get(l),w=u?.shiftKey?10:1,$=N(g-_*w,_),V=r!=null?t.Value.get(r):void 0;if(V!=null&&$<V)return;const i=x($);i!==g&&(s?.(i),f?.(i))},k=u=>{const g=t.Value.get(e)??0,_=t.Value.get(l),w=u?.shiftKey?10:1,$=N(g+_*w,_),V=o!=null?t.Value.get(o):void 0;if(V!=null&&$>V)return;const i=x($);i!==g&&(s?.(i),f?.(i))};return ut.Stack(t.attr.class("bc-number-input-steppers"),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"),t.attr.disabled(t.computedOf(c,n.disabled??!1)((u,g)=>!u||g)),t.on.click(u=>k(u)),t.aria.label(b.$.incrementValue),C.Icon({icon:"line-md:plus",size:"xs"})),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"),t.attr.disabled(t.computedOf(a,n.disabled??!1)((u,g)=>!u||g)),t.on.click(u=>I(u)),t.aria.label(b.$.decrementValue),C.Icon({icon:"line-md:minus",size:"xs"})))}):null,d=m!=null&&p!=null?t.Fragment(p,m):m??p;return B.InputContainer({...n,input:t.input.number(r!=null?t.attr.min(r):t.Empty,o!=null?t.attr.max(o):t.Empty,A.CommonInputAttributes(n),t.attr.valueAsNumber(e),t.attr.step(l),t.attr.class("bc-input bc-number-input"),h!=null?t.on.blur(t.emitValue(h)):t.Empty,s!=null?t.on.change(t.emitValueAsNumber(s)):t.Empty,f!=null?t.on.input(t.emitValueAsNumber(f)):t.Empty,l!=null?t.on.wheel(b=>{b.preventDefault();const a=t.Value.get(e)??0,c=t.Value.get(l),I=b.shiftKey?10:1,k=b.deltaY<0?c*I:-c*I,u=x(N(a+k,c));u!==a&&(s?.(u),f?.(u))}):t.Empty),after:d})};function Et(n,e){return n.length===e.length&&n.every((l,r)=>l===e[r])}function Dt(n,e,l){const r=["bc-segmented-input",`bc-segmented-input--size-${n}`];return l==="squared"&&r.push("bc-segmented-input--squared"),e&&r.push("bc-segmented-input--disabled"),r.join(" ")}function Ut(n){if(n==null)return"";const e=new Map,l=C.backgroundValue(n,"solid","light"),r=C.backgroundValue(n,"solid","dark");return e.set("--si-indicator-bg",l.backgroundColor),e.set("--si-active-text",l.textColor),e.set("--si-indicator-bg-dark",r.backgroundColor),e.set("--si-active-text-dark",r.textColor),Array.from(e.entries()).map(([o,h])=>`${o}: ${h}`).join("; ")}function $t({options:n,value:e,onChange:l,size:r="md",disabled:o=!1,variant:h="pill",color:s},...f){const m=L.objectEntries(n).map(([x,p])=>({key:x,label:p}));return t.WithElement(()=>{const x=Object.fromEntries(m.map((d,b)=>[d.key,b])),p=t.prop(m.map(()=>({left:0,width:0})),Et);return t.html.div(t.attr.class(t.computedOf(r,o,h)((d,b,a)=>Dt(d??"md",b??!1,a??"pill"))),t.attr.style(s!=null?t.Value.map(s,d=>Ut(d)):""),t.html.div(t.attr.class("bc-segmented-input__container"),t.html.div(t.attr.class("bc-segmented-input__indicator"),t.style.width(t.computedOf(e,p)((d,b)=>{const{width:a}=b[x[d]??0];return`${a}px`})),t.style.left(t.computedOf(e,p)((d,b)=>{const{left:a}=b[x[d]??0];return`${a}px`}))),m.map(({label:d,key:b},a)=>t.html.button(t.attr.type("button"),t.on.click(c=>{c.preventDefault(),t.Value.get(o)||l?.(b)}),t.attr.disabled(o),t.attr.class("bc-segmented-input__segment"),t.attr.class(t.Value.map(e,c=>c===b?"bc-segmented-input__segment--active":"bc-segmented-input__segment--inactive")),It.ElementRect(c=>{function I(){p.update(u=>{const g=[...u];return g[a]={width:c.value.width,left:c.value.localLeft},g})}const k=L.delayedAnimationFrame(I);return t.OnDispose(k,c.on(I))}),d))),...f)})}function Mt(n){const e=n.type.toLowerCase();return e.startsWith("image/")&&(e.includes("jpeg")||e.includes("jpg")||e.includes("png")||e.includes("gif")||e.includes("webp")||e.includes("svg"))}function Ot(n){const e=n.type.toLowerCase();return e.startsWith("image/")?"vscode-icons:file-type-image":e.startsWith("video/")?"vscode-icons:file-type-video":e.startsWith("audio/")?"vscode-icons:file-type-audio":e.includes("pdf")?"vscode-icons:file-type-pdf2":e.includes("word")||e.includes("document")?"vscode-icons:file-type-word":e.includes("excel")||e.includes("spreadsheet")?"vscode-icons:file-type-excel":e.includes("powerpoint")||e.includes("presentation")?"vscode-icons:file-type-powerpoint":e.includes("zip")||e.includes("archive")?"vscode-icons:file-type-zip":e.includes("text")?"vscode-icons:file-type-text":e.includes("json")?"vscode-icons:file-type-json-official":e.includes("csv")?"vscode-icons:file-type-csv":e.includes("xml")?"vscode-icons:file-type-xml":e.includes("yaml")?"vscode-icons:file-type-yaml-official":"vscode-icons:file-type-binary"}function J(n){return t.When(n.map(Mt),()=>{const e=t.prop(null);return n.on(l=>{e.value&&URL.revokeObjectURL(e.value);const r=URL.createObjectURL(l);e.value=r}),t.html.div(t.OnDispose(()=>{e.value&&URL.revokeObjectURL(e.value)}),t.attr.class("bc-file-input__thumbnail-container"),t.html.img(t.attr.src(e),t.attr.alt(n.map(l=>l.name)),t.attr.class("bc-file-input__thumbnail")))},()=>C.Icon({icon:n.map(Ot)}))}const Bt=(n,...e)=>{const{value:l=t.prop([]),accept:r="*/*",maxFiles:o,maxFileSize:h,onChange:s,onBlur:f,disabled:m,hasError:x,mode:p="default",showFileList:d=!0,...b}=n,a=l,c=t.Value.map(p,V=>V==="input"),I=t.Value.map(p,V=>V==="compact"),k=V=>{let i=V;if(o!=null){const v=t.Value.get(o);i=i.slice(0,v)}if(h){const v=t.Value.get(h);i=i.filter(E=>E.size<=v)}s?.(i)},u=V=>{const v=a.value.filter((E,D)=>D!==V);s?.(v)},g=()=>{s?.([])},_=({files:V,clear:i,change:v})=>t.Use(C.BeatUII18n,E=>t.html.div(t.attr.class("bc-file-input__drop-zone"),t.html.div(t.attr.class("bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"),C.Icon({icon:"mdi:cloud-upload-outline",size:"xl"}),t.html.div(t.attr.class("bc-file-input__drop-zone-text"),t.bind(E.$.filesInputInstructions)(o,h,E.$.fileSizeUnits.value))))),w=({files:V})=>t.Use(C.BeatUII18n,i=>t.html.div(t.attr.class("bc-file-input__compact-drop-zone"),t.When(V.map(v=>v.length>0),()=>t.html.div(t.attr.class("bc-file-input__compact-file-list"),t.ForEach(V,(v,E)=>{const D=E.index;return t.html.div(t.attr.class("bc-file-input__compact-file-item"),t.html.div(t.attr.class("bc-file-input__compact-file-icon"),J(v)),t.html.div(t.attr.class("bc-file-input__compact-file-info"),t.html.div(t.attr.class("bc-file-input__compact-file-name"),t.attr.title(v.$.name),v.$.name),t.html.div(t.attr.class("bc-file-input__compact-file-meta"),t.computedOf(v.$.size,i.$.fileSizeUnits)((y,U)=>C.formatFileSize(y,{units:U}))," • ",t.computedOf(v.$.type,i.$.unknownType)((y,U)=>y||U))),O.CloseButton({size:"sm",label:i.$.removeFile,disabled:m,onClick:()=>u(D)},t.attr.class("bc-file-input__compact-remove-button")))})),()=>t.html.div(t.attr.class("bc-file-input__compact-placeholder"),C.Icon({icon:"mdi:cloud-upload-outline",size:"lg"}),t.html.div(t.attr.class("bc-file-input__compact-placeholder-text"),t.bind(i.$.filesInputInstructions)(o,h,i.$.fileSizeUnits.value)))))),$=({files:V})=>t.Use(C.BeatUII18n,i=>t.html.div(t.attr.class("bc-file-input__compact-input"),t.When(V.map(v=>v.length>0),()=>t.html.span(t.attr.class("bc-file-input__compact-value"),t.ForEach(V,v=>t.html.span(t.attr.class("bc-file-input__compact-value-item"),J(v),t.html.span(t.attr.class("bc-file-input__compact-value-item-name"),v.$.name)))),()=>t.html.span(t.attr.class("bc-file-input__compact-placeholder"),C.Icon({icon:"mdi:cloud-upload-outline",size:"md"})," ",t.bind(i.$.filesInputInstructions)(o,h,i.$.fileSizeUnits.value)))));return t.Use(C.BeatUII18n,V=>B.InputContainer({baseContainer:t.Value.map(c,i=>!i),disabled:m,hasError:x,after:t.When(c,()=>t.When(a.map(({length:i})=>i>0),()=>O.CloseButton({size:"sm",label:V.$.clearAllFiles,disabled:m,onClick:g},t.attr.class("bc-file-input__compact-clear")))),...b,input:t.When(c,()=>t.html.div(t.attr.class("bc-file-input bc-file-input--input"),Z({value:a,accept:r,enableClick:!0,allowMultiple:t.Value.map(o??1/0,i=>i>1),disabled:m,onChange:k,content:$})),()=>t.When(I,()=>t.html.div(t.attr.class("bc-file-input bc-file-input--compact"),Z({value:a,accept:r,enableClick:!0,allowMultiple:t.Value.map(o??1/0,i=>i>1),disabled:m,onChange:k,content:w})),()=>t.html.div(t.attr.class("bc-file-input"),Z({value:a,accept:r,enableClick:!0,allowMultiple:t.Value.map(o??1/0,i=>i>1),disabled:m,onChange:k,content:_}),t.When(d,()=>t.NotEmpty(a,()=>t.Fragment(t.html.div(t.attr.class("bc-file-input__file-list"),t.ForEach(a,(i,v)=>{const E=v.index;return t.html.div(t.attr.class("bc-file-input__file-item"),t.html.div(t.attr.class("bc-file-input__file-icon"),J(i)),t.html.div(t.attr.class("bc-file-input__file-info"),t.html.div(t.attr.class("bc-file-input__file-name"),t.attr.title(i.$.name),i.$.name),t.html.div(t.attr.class("bc-file-input__file-meta"),t.computedOf(i.$.size,V.$.fileSizeUnits)((D,y)=>C.formatFileSize(D,{units:y}))," • ",t.computedOf(i.$.type,V.$.unknownType)((D,y)=>D||y))),O.CloseButton({size:"sm",label:V.$.removeFile,disabled:m,onClick:()=>u(E)},t.attr.class("bc-file-input__remove-button")))})),t.When(a.map(({length:i})=>i>1),()=>t.html.div(t.attr.class("bc-file-input__clear-all-button-container"),t.html.button(t.attr.type("button"),t.attr.class("bc-file-input__clear-all-button"),t.attr.disabled(m),V.$.clearAllFiles,t.on.click(i=>{i.preventDefault(),i.stopPropagation(),g()}))))))))))},...e))};function ht(n,e,l){const r=n.length.map(o=>o);return t.Repeat(r,o=>{const h=n.item(o.index),s=[];return t.Fragment(t.OnDispose(()=>{s.forEach(f=>f())}),e({list:n,item:h,position:o,remove:()=>n.removeAt(o.index),move:f=>{switch(f){case"up":if(o.index===0)return;n.move(o.index,o.index-1);break;case"down":if(o.index===n.length.value-1)return;n.move(o.index,o.index+1);break;case"first":n.move(o.index,0);break;case"last":n.move(o.index,n.length.value-1)}},canMove:f=>{const m=(()=>{switch(f){case"up":return t.signal(o.index>0);case"down":return n.length.map(x=>o.index<x-1)}})();return s.push(()=>m.dispose()),m},cannotMove:f=>{const m=(()=>{switch(f){case"up":return t.signal(o.index===0);case"down":return n.length.map(x=>o.index===x-1)}})();return s.push(()=>m.dispose()),m}}))},l)}const rt={9:{pattern:/^[0-9]$/},A:{pattern:/^[A-Za-z]$/,transform:n=>n.toUpperCase()},"*":{pattern:/^.$/}},St=n=>n instanceof RegExp;function bt(n,e,l){if(n==null)return[];const r=l?{...rt,...e}:e??rt,o=(s,f)=>{const m=r[f];m?s.push({type:"pattern",name:f,...m}):s.push({type:"literal",char:f})},h=[];if(typeof n=="string"){for(const s of n)o(h,s);return h}for(const s of n)if(typeof s=="string")if(s.length<=1)o(h,s);else for(const f of s)o(h,f);else St(s)?h.push({type:"pattern",pattern:s}):typeof s=="object"&&s&&h.push(s);return h}function Tt(n,e){return l=>{switch(n){case"digits":return/[0-9]/.test(l);case"letters":return/[A-Za-z]/.test(l);case"alphanumeric":return/[A-Za-z0-9]/.test(l);case"custom":return e?.(l)??!0;default:return!0}}}function ot(n,e,l,r,o,h){const s={raw:n,previousConformed:e,cursor:o??n.length,completed:!1},f=r.definitions??{},m=typeof l=="function"?l(n,s):l,x=bt(m,f,r.useDefaultDefinitions??!0),p=Tt(r.allowMode,r.allow),d=new Set;for(const y of x)y.type==="literal"&&d.add(y.char);if(r.prefix)for(const y of r.prefix)d.add(y);if(r.suffix)for(const y of r.suffix)d.add(y);const b=Array.from(n).filter(y=>p(y)&&!d.has(y));if(b.length===0)return{value:"",cursor:0,completed:!1};const a=[],c=[];let I=0,k=0,u=0,g=-1;for(const y of x){if(y.type==="literal"){a.push(y.char),c.push({kind:"literal",filled:!0});continue}k+=y.optional?0:1;const U=b[I];if(U==null)break;if(y.type==="any"){u++,a.push(y.transform?y.transform(U):U),c.push({kind:"slot",filled:!0}),g=c.length-1,I++;continue}if(y.type==="pattern")if(y.pattern.test(U)){u++;const S=y.transform?y.transform(U):U;a.push(S),c.push({kind:"slot",filled:!0}),g=c.length-1,I++}else{I++;continue}}const _=a.join(""),w=(r.prefix??"")+_+(r.suffix??"");let V=(r.prefix??"").length;if(g>=0){let y=g+1;if((h?.policy??"smart")!=="sticky")for(;y<c.length&&c[y].kind==="literal";)y++;V+=y}const i=r.completion?.mode==="min"?(r.completion.minChars??0)<=u:r.completion?.mode==="custom"?!!r.completion.isComplete?.(w):k>0&&u>=k,v=r.pipe?.(w,{...s,completed:i});let E,D=V;return v===!1?(E=e,D=e.length):typeof v=="string"?(E=v,D=v.length):typeof v=="object"&&v?(E=v.value,D=v.cursor??v.value.length):E=w,{value:E,cursor:D,completed:i}}function At(n,e){const l=e?.strategy??"none";return l==="custom"&&e?.unmask?e.unmask(n):l==="strip"?n.replace(/[^A-Za-z0-9]/g,""):n}const et=n=>{const{value:e,onBlur:l,onChange:r,onInput:o,onAccept:h,onComplete:s,mask:f,definitions:m,useDefaultDefinitions:x,extraLiterals:p,prefix:d,suffix:b,autofix:a,pipe:c,completion:I,unmask:k,allowMode:u,allow:g,placeholder:_,placeholderOptions:w}=n,$=t.computedOf(e,f,m,x,p,d,b,a,I,k,u,_,w)((i,v,E,D,y,U,S,R,P,W,F,j,T)=>v?ot(i??"","",v,{definitions:E??{},useDefaultDefinitions:D??!0,extraLiterals:y??[],autofix:R??"none",completion:P??{mode:"mask"},pipe:c??(M=>M),unmask:W??{strategy:"none"},allowMode:F??"all",allow:g,prefix:U,suffix:S}).value:i??""),V=(i,v)=>{const E=i.value??"",D=t.Value.get(e)??"",y=f!=null?t.Value.get(f):null,U=m!=null?t.Value.get(m):void 0,S=x!=null?t.Value.get(x):void 0,R=p!=null?t.Value.get(p):void 0,P=a!=null?t.Value.get(a):void 0,W=I!=null?t.Value.get(I):void 0,F=k!=null?t.Value.get(k):void 0,j=u!=null?t.Value.get(u):void 0,T=d!=null?t.Value.get(d):void 0,M=b!=null?t.Value.get(b):void 0,{value:z,cursor:Y,completed:nt}=y?ot(E,D,y,{definitions:U??{},useDefaultDefinitions:S??!0,extraLiterals:R??[],autofix:P??"none",completion:W??{mode:"mask"},pipe:c??(Vt=>Vt),unmask:F??{strategy:"none"},allowMode:j??"all",allow:g,prefix:T,suffix:M},i.selectionStart??E.length,n.cursor?t.Value.get(n.cursor):void 0):{value:E,cursor:E.length,completed:!0};if(z!==E){i.value=z;try{i.setSelectionRange(Y,Y)}catch{}}const lt=At(z,F);h?.({raw:lt,conformed:z,completed:nt,cursor:Y}),v==="input"?o?.(z):(r?.(z),nt&&s?.({raw:lt,conformed:z}))};return B.InputContainer({...n,input:t.input.text(A.CommonInputAttributes(n),t.attr.value($),t.attr.class("bc-input"),l!=null?t.on.blur(l):t.Empty,t.WithElement(i=>i instanceof HTMLInputElement?t.Fragment(t.on.input(()=>V(i,"input")),t.on.change(()=>V(i,"change")),t.on.keydown(v=>{if(v.key!=="Backspace"||!(n.cursor?t.Value.get(n.cursor)?.backspaceRubberBand??!0:!0))return;const D=i.selectionStart??0,y=i.selectionEnd??D;if(D!==y||D<=0)return;const U=i.value??"",S=f!=null?t.Value.get(f):null;if(!S)return;const R=m!=null?t.Value.get(m):void 0,P=x!=null?t.Value.get(x):!0,W=d!=null?t.Value.get(d):void 0,F=b!=null?t.Value.get(b):void 0,j=bt(typeof S=="function"?S(U,{raw:U,previousConformed:U,cursor:D,completed:!1}):S,R??{},P??!0),T=new Set;for(const M of j)M.type==="literal"&&T.add(M.char);if(W)for(const M of W)T.add(M);if(F)for(const M of F)T.add(M);if(T.has(U[D-1])){let M=D-1;for(;M>=0&&T.has(U[M]);)M--;M>=0&&(v.preventDefault(),v.stopPropagation(),i.value=U.slice(0,M)+U.slice(M+1),V(i,"input"))}})):t.Empty))})},Ft=n=>{const{value:e,onBlur:l,onChange:r,onInput:o,rows:h}=n;return B.InputContainer({...n,input:t.html.textarea(A.CommonInputAttributes(n),t.attr.rows(h??3),t.attr.value(e),t.attr.class("bc-input"),l!=null?t.on.blur(t.emitValue(l)):t.Empty,r!=null?t.on.change(t.emitValue(r)):t.Empty,o!=null?t.on.input(t.emitValue(o)):t.Empty)})},at=n=>{if(n==null||n==="")return null;const e=Number(n);return Number.isNaN(e)?null:e},zt=n=>{const{value:e,step:l,min:r,max:o,onBlur:h,onChange:s,onInput:f,after:m}=n,x=a=>{const c=r!=null?t.Value.get(r):void 0,I=o!=null?t.Value.get(o):void 0;return c!=null&&a<c?c:I!=null&&a>I?I:a},p=(()=>{if(l==null)return null;const a=t.computedOf(e,r)((g,_)=>{const w=g??0;return _==null?!0:w>_}),c=t.computedOf(e,o)((g,_)=>{const w=g??0;return _==null?!0:w<_}),I=g=>{const _=t.Value.get(e)??0,w=t.Value.get(l),$=g?.shiftKey?10:1,V=N(_-w*$,w),i=r!=null?t.Value.get(r):void 0;if(i!=null&&V<i)return;const v=x(V);v!==_&&(s?.(v),f?.(v))},k=g=>{const _=t.Value.get(e)??0,w=t.Value.get(l),$=g?.shiftKey?10:1,V=N(_+w*$,w),i=o!=null?t.Value.get(o):void 0;if(i!=null&&V>i)return;const v=x(V);v!==_&&(s?.(v),f?.(v))};return((g,_)=>ut.Stack(t.attr.class("bc-number-input-steppers"),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"),t.attr.disabled(t.computedOf(c,n.disabled??!1)((w,$)=>!w||$)),t.on.click(w=>k(w)),t.aria.label(g),C.Icon({icon:"line-md:plus",size:"xs"})),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"),t.attr.disabled(t.computedOf(a,n.disabled??!1)((w,$)=>!w||$)),t.on.click(w=>I(w)),t.aria.label(_),C.Icon({icon:"line-md:minus",size:"xs"}))))(C.defaultMessages.incrementValue,C.defaultMessages.decrementValue)})(),d=tt(e,n.disabled,s??f),b=m!=null&&p!=null?t.Fragment(p,d,m):m!=null?t.Fragment(d,m):p!=null?t.Fragment(p,d):d;return B.InputContainer({...n,input:t.input.number(r!=null?t.attr.min(r):t.Empty,o!=null?t.attr.max(o):t.Empty,A.CommonInputAttributes(n),t.attr.value(t.Value.map(e,a=>a==null?"":String(a))),t.attr.step(l),t.attr.class("bc-input bc-number-input"),h!=null?t.on.blur(t.emitValue(h)):t.Empty,s!=null?t.on.change(t.emitValue(a=>{const c=at(a);s(c)})):t.Empty,f!=null?t.on.input(t.emitValue(a=>{const c=at(a);f(c)})):t.Empty,l!=null?t.on.wheel(a=>{a.preventDefault();const c=t.Value.get(e)??0,I=t.Value.get(l),k=a.shiftKey?10:1,u=a.deltaY<0?I*k:-I*k,g=x(N(c+u,I));g!==c&&(s?.(g),f?.(g))}):t.Empty),after:b})},Lt=n=>{const e={type:"pattern",pattern:/[0-9A-Fa-f]/,transform:o=>o.toLowerCase()},l=[e,e,e,e,e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,e,e,e,e,e,e,e,e],r=n.class?t.Value.map(n.class,o=>`bc-uuid-input ${o}`):"bc-uuid-input";return et({...n,class:r,mask:l,placeholder:n.placeholder??"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})},Nt=/^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i,Wt=/^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;function gt(n){return{mask:null,allowMode:"custom",allow:e=>/[0-9ptwdhms]/i.test(e),pipe:e=>{const l=e.toUpperCase();return l.length===0?l:!l.startsWith("P")||!Nt.test(l)?!1:l},completion:{mode:"custom",isComplete:e=>{const l=e.toUpperCase();if(!Wt.test(l))return!1;try{return n(l),!0}catch{return!1}}}}}const st=(n,e)=>{if(n==null)return null;try{return n.Duration.from(e)}catch{return null}},Rt=n=>{const{value:e,onChange:l,onInput:r,after:o,disabled:h,onBlur:s}=n,f=()=>{const p=tt(e,h,l??r);return o!=null?t.Fragment(p,o):p},m=n.placeholder!=null?t.Empty:t.attr.placeholder("P0DT0H0M0S");return ct(p=>{const d=A.mapInputOptions(n,b=>b?.toString()??"",b=>b===""?null:p.Duration.from(b));return et({...d,onInput:void 0,...gt(p.Duration.from),placeholder:"P0DT0H0M0S",after:f()})},{pending:()=>{const p=d=>b=>{const c=b.currentTarget?.value??"";if(c===""){d(null);return}const I=globalThis.Temporal,k=st(I,c);if(k!=null){d(k);return}H().then(u=>{const g=st(u,c);g!=null&&d(g)}).catch(()=>{})};return B.InputContainer({...n,input:t.input.text(A.CommonInputAttributes(n),t.attr.value(t.Value.map(e,d=>d?.toString()??"")),t.attr.class("bc-input"),m,s!=null?t.on.blur(()=>s()):t.Empty,l!=null?t.on.change(p(l)):t.Empty,r!=null?t.on.input(p(r)):t.Empty),after:f()})}})},Pt=n=>{const{value:e,onBlur:l,onChange:r,onInput:o}=n;return B.InputContainer({...n,input:t.input.url(A.CommonInputAttributes(n),t.attr.value(e),t.attr.class("bc-input"),l!=null?t.on.blur(t.emitValue(l)):t.Empty,r!=null?t.on.change(t.emitValue(r)):t.Empty,o!=null?t.on.input(t.emitValue(o)):t.Empty)})};function vt(n,e){const{onMove:l,cannotMoveUp:r,cannotMoveDown:o,onRemove:h,showMove:s=!0,showRemove:f=!0,removeDisabled:m,showMoveButtons:x=!0,layout:p="aside"}=n,d=t.Value.toSignal(p).map(c=>c==="aside"),b=t.When(s,()=>t.html.div(t.attr.class("bc-list-item-controls__move"),B.Button({size:"xs",roundedness:"full",variant:"text",onClick:()=>l("up"),disabled:r},t.Use(C.BeatUII18n,c=>C.Icon({size:"xs",icon:"line-md:arrow-up",title:c.$.incrementValue}))),B.Button({size:"xs",roundedness:"full",variant:"text",onClick:()=>l("down"),disabled:o},t.Use(C.BeatUII18n,c=>C.Icon({size:"xs",icon:"line-md:arrow-down",title:c.$.decrementValue}))))),a=t.When(f,()=>t.Use(C.BeatUII18n,c=>O.CloseButton({size:"xs",label:t.Value.map(c.$.removeItem,I=>I.toLowerCase()),color:"danger",disabled:m,onClick:h})));return t.When(d,()=>t.html.div(t.attr.class("bc-list-item-controls bc-list-item-controls--aside"),t.html.div(t.attr.class("bc-list-item-controls__content"),e),t.html.div(t.attr.class("bc-list-item-controls__actions"),t.When(x,()=>b),a)),()=>t.html.div(t.attr.class("bc-list-item-controls bc-list-item-controls--below"),t.html.div(t.attr.class("bc-list-item-controls__content"),e),t.html.div(t.attr.class("bc-list-item-controls__actions"),t.When(x,()=>b,()=>t.html.div()),a)))}const xt=n=>{const{controller:e,element:l,separator:r,showMove:o=!0,showRemove:h=!0,showAdd:s=!0,createItem:f,addLabel:m,controlsLayout:x="aside",removeDisabled:p,addDisabled:d}=n,b=t.When(t.computedOf(s,f)((a,c)=>a&&c!=null),()=>Q(t.attr.class("bc-group--gap-2 bc-group--align-center bc-group--justify-center"),B.Button({size:"sm",variant:"filled",onClick:()=>e.push(f()),disabled:t.computedOf(e.disabled,d??!1)((a,c)=>a||c)},t.Use(C.BeatUII18n,a=>Q(t.attr.class("bc-group--gap-2"),C.Icon({icon:"line-md:plus"}),m??a.$.addLabel)))));return t.Fragment(ht(e,a=>vt({onMove:a.move,cannotMoveUp:a.cannotMove("up"),cannotMoveDown:a.cannotMove("down"),onRemove:a.remove,showMove:o,showRemove:h,removeDisabled:p,showMoveButtons:e.signal.map(c=>c.length>1),layout:x},l(a)),r),b)},jt=(n,...e)=>{const{controller:l,element:r,separator:o,showMove:h,showRemove:s,showAdd:f,createItem:m,addLabel:x,controlsLayout:p,removeDisabled:d,addDisabled:b,...a}=n;return O.InputWrapper({...a,content:xt({controller:l,element:r,separator:o,showMove:h,showRemove:s,showAdd:f,createItem:m,addLabel:x,controlsLayout:p,removeDisabled:d,addDisabled:b})},...e)};class qt extends O.Controller{branches;activeBranch;#e;#t=new Map;constructor(e,l,r,o,h,s,f=L.strictEqual){super(e,l,r,o,h,f),this.branches=s;const m=p=>{for(const d of s)if(d.detect(p))return d.key;return s[0]?.key??"unknown"};this.activeBranch=r.map(m,L.strictEqual);const x=p=>{if(this.#t.has(p))return this.#t.get(p);const d=s.find(a=>a.key===p);if(!d)throw new Error(`Unknown branch: ${p}`);const b=new O.Controller([...e,p],a=>{this.change(a)},this.signal.map(a=>d.detect(a)?a:d.defaultValue(),f),o.map(O.makeMapValidation([p])),{disabled:this.disabled,validationMode:this.parent.validationMode},f);return this.#t.set(p,b),b};this.#e=this.activeBranch.map(p=>x(p),L.strictEqual),this.onDispose(()=>{for(const p of this.#t.values())p.dispose();this.#t.clear(),this.activeBranch.dispose(),this.#e.dispose()})}get activeController(){return t.Value.get(this.#e)}getBranchController(e){const l=this.branches.find(o=>o.key===e);if(!l)throw new Error(`Unknown branch: ${e}`);if(this.#t.has(e))return this.#t.get(e);const r=new O.Controller([...this.path,e],o=>{this.change(o)},this.signal.map(o=>l.detect(o)?o:l.defaultValue(),L.strictEqual),this.status.map(O.makeMapValidation([e])),{disabled:this.disabled,validationMode:this.parent.validationMode},L.strictEqual);return this.#t.set(e,r),r}switchToBranch(e,l=!1){const r=this.branches.find(s=>s.key===e);if(!r)throw new Error(`Unknown branch: ${e}`);const o=t.Value.get(this.signal);if(r.detect(o))return!0;if(r.convert){const s=r.convert(o);if(s.ok)return this.change(s.value),!0}if(l&&typeof window=="object"&&typeof window.confirm=="function"&&!window.confirm(C.defaultMessages.changeTypeConfirmation))return!1;const h=r.defaultValue();return this.change(h),!0}get activeBranchDefinition(){const e=t.Value.get(this.activeBranch);return this.branches.find(l=>l.key===e)}}function Zt(n){return n.transform(e=>e??null,e=>e??void 0)}function Ht(n){return n.transform(e=>e??"",e=>e===""?void 0:e)}function Yt(n){return n.transform(e=>e??void 0,e=>e??null)}function q(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.prototype.toString.call(n)==="[object Object]"}function yt(n,e){if(e==null)return it(n);if(n==null)return e;if(q(n)&&q(e)){const l={...e};for(const r of Object.keys(n))l[r]===void 0?l[r]=it(n[r]):q(n[r])&&q(l[r])&&(l[r]=yt(n[r],l[r]));return l}return e}function it(n){return typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}exports.BaseListControl=xt;exports.BaseNativeSelectControl=mt;exports.Expando=pt;exports.FilesInput=Bt;exports.Group=Q;exports.ListControl=jt;exports.ListInput=ht;exports.ListItemControls=vt;exports.MaskInput=et;exports.NativeSelect=dt;exports.NativeSelectControl=Ct;exports.NullableDurationInput=Rt;exports.NullableNumberInput=zt;exports.NullableResetAfter=tt;exports.NumberInput=kt;exports.SegmentedInput=$t;exports.TextArea=Ft;exports.UnionController=qt;exports.UnstyledDropZone=Z;exports.UrlInput=Pt;exports.UuidInput=Lt;exports.WithTemporal=ct;exports.deepMergeDefaults=yt;exports.durationMaskConfig=gt;exports.emitExpando=wt;exports.emitOptionExpando=X;exports.ensureTemporal=H;exports.roundToStep=N;exports.transformEmptyStringToUndefined=Ht;exports.transformNullToUndefined=Zt;exports.transformUndefinedToNull=Yt;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("@tempots/dom"),_=require("./translations-qefRsdGi.cjs"),B=require("./input-container-BkPcNDaZ.cjs"),j=require("./stack-dwLevGa2.cjs"),T=require("./session-id-B5lJMzbB.cjs"),p=require("@tempots/std"),P=e.html.span(e.attr.class("bc-input-wrapper__required")," *");function G(n){const t=["bc-input-wrapper"];return n!=="vertical"&&t.push(`bc-input-wrapper--${n}`),t.join(" ")}function J(n,t){const s=["bc-input-wrapper__label-text"];return n?s.push("bc-input-wrapper__label-text--error"):t?s.push("bc-input-wrapper__label-text--disabled"):s.push("bc-input-wrapper__label-text--default"),s.join(" ")}function Q(n,t){if(n==="horizontal-fixed"&&t!=null)return`--input-wrapper-label-width: ${t}`}const O=({fullWidth:n=!1,required:t,label:s,labelChildren:i,context:r,description:l,content:o,error:a,labelFor:c,hasError:d,disabled:u,layout:m,labelWidth:g},...v)=>{const f=d??a!=null,h=u??!1,y=m??"vertical",w=T.sessionId("input-wrapper"),D=l?`${w}-description`:void 0,I=a!=null?`${w}-error`:void 0,A=e.computedOf(y)(b=>b!=="vertical"),K=e.computedOf(y,g??void 0)((b,C)=>Q(b,C));return e.html.div(e.attr.class(e.Value.map(y,b=>G(b))),e.attr.class(e.Value.map(n,b=>b?"bc-input-wrapper--full-width":"")),e.attr.style(K),s!=null||r!=null?e.html.div(e.attr.class("bc-input-wrapper__header"),e.html.div(e.attr.class("bc-input-wrapper__label-section"),e.html.label(e.attr.class("bc-input-wrapper__label"),c!=null?e.attr.for(c):e.Empty,e.html.span(e.attr.class(e.computedOf(f,h)((b,C)=>J(b??!1,C??!1))),s),s!=null&&t?P:e.Empty),e.When(e.computedOf(A,l)((b,C)=>b&&C!=null),()=>e.html.div(e.attr.class("bc-input-wrapper__description bc-input-wrapper__description--under-label"),e.attr.id(D),l))),r!=null?j.Label(r):e.Empty,i):e.Empty,e.html.div(e.attr.class("bc-input-wrapper__content"),[D,I].filter(Boolean).length>0?e.dataAttr("describedby",[D,I].filter(Boolean).join(" ")):e.Empty,t?e.dataAttr("required","true"):e.Empty,e.When(f,()=>e.dataAttr("invalid","true")),o),e.When(e.computedOf(A,l)((b,C)=>!b&&C!=null),()=>e.html.div(e.attr.class("bc-input-wrapper__description"),e.attr.id(D),l)),e.When(f,()=>e.html.div(e.attr.class("bc-input-wrapper__error"),e.attr.id(I),e.aria.live("polite"),e.attr.role("alert"),a)),...v)};function X({size:n="sm",icon:t="line-md:close",disabled:s,roundedness:i="full",color:r="base",onClick:l,label:o},...a){return e.Use(_.BeatUII18n,c=>{const d=e.coalesce(o,c.$.closeModal);return B.Button({variant:"text",size:n,roundedness:i,disabled:s,color:r,onClick:l},e.attr.title(d),e.aria.label(d),...a,_.Icon({icon:t,size:n??"sm"}))})}const Y=n=>{const{value:t,onBlur:s,onChange:i,onInput:r,placeholder:l,disabled:o,id:a,activeIcon:c,inactiveIcon:d,size:u="md"}=n,m=a??T.sessionId("checkbox"),g=`${m}-label`,v=()=>{if(e.Value.get(o??!1))return;const h=e.Value.get(t);i?.(!h),r?.(!h)},f=h=>{e.Value.get(o??!1)||(h.key===" "||h.key==="Enter")&&(h.preventDefault(),v())};return B.InputContainer({baseContainer:!0,growInput:!1,...n,input:e.html.span(e.attr.class("bc-checkbox-input"),e.html.span(e.attr.class("bc-checkbox-input__checkbox"),e.attr.class(e.Value.map(t,h=>h?"bc-checkbox-input__checkbox--checked":"bc-checkbox-input__checkbox--unchecked")),e.attr.class(e.Value.map(o??!1,h=>h?"bc-checkbox-input__checkbox--disabled":"")),e.attr.id(m),e.attr.role("checkbox"),e.attr.tabindex(e.Value.map(o??!1,h=>h?-1:0)),e.aria.checked(t),e.aria.disabled(o),l!=null?e.aria.labelledby(g):e.Empty,e.on.keydown(f),s!=null?e.on.blur(s):e.Empty,_.Icon({icon:e.computedOf(t,c,d)((h,y,w)=>h?y??"ri:checkbox-fill":w??"mdi:checkbox-blank-outline"),accessibility:"decorative",size:u})),l!=null?e.html.label(e.attr.class("bc-checkbox-input__label"),e.attr.id(g),e.attr.for(m),j.MutedLabel(l)):e.Empty)},e.on.click(v))},q=((n,t)=>()=>{n.markTouched(),t?.()}),E=(n,t)=>s=>{n.change(s),t?.(s)};function M(n,t){const{controller:s,onBlur:i,onChange:r,id:l,triggerOn:o,...a}=t;return n({id:l??s.name,disabled:s.disabled,value:s.signal,hasError:s.errorVisible,name:s.name,...a,onInput:o==="input"?E(s,r):void 0,onChange:o!=="input"?E(s,r):void 0,onBlur:q(s,i)})}function Z(n,{id:t,labelFor:s,...i},...r){const l=t??i.controller.name??T.sessionId("control"),o=s??l;return O({...i,hasError:i.controller.errorVisible,error:e.TextNode(i.controller.error.map(a=>a??"")),labelFor:o,content:M(a=>n({...a,id:l}),i)},...r)}function H(n,t){const{toInput:s,fromInput:i,controller:r,...l}=t,o=r.transform(s,i);return M(n,{...l,controller:o})}function tt(n,{id:t,labelFor:s,...i},...r){const l=t??i.controller.name??T.sessionId("control");return O({...i,labelFor:s??l,content:H(n,{...i,id:l})},...r)}function et(n){return n.split(".").map(s=>{const i=s.match(/^\[(\d+)\]$/);return i?Number(i[1]):s})}function F(n){return typeof n=="number"?`[${n}]`:`.${n}`}function $(n){if(n.length===0)return"";const[t,...s]=n;return[typeof t=="number"?`[${t}]`:t,...s.map(F)].join("")}const st={valid:p.Validation.valid,invalid(n){return p.Validation.invalid({message:n})},invalidFields(n){const t={};for(const[s,i]of Object.entries(n))t[s]=typeof i=="string"?{message:i}:i;return p.Validation.invalid({dependencies:t})},fromError(n){return p.Validation.invalid(n)}};function V(n){return function(s){if(s.type==="valid")return s;let i=s.error;for(const r of n)if(i=i?.dependencies?.[r],i==null)return p.Validation.valid;return p.Validation.invalid(i)}}class k{path;change;signal;status;error;hasError;touched;errorVisible;dirty;dependencyErrors;#t={disabled:e.prop(!1),touched:e.prop(!1)};#s;#e=e.prop(void 0);parent;disabled;#n=[];disabledOrHasErrors;constructor(t,s,i,r,l,o=p.strictEqual){this.path=t,this.change=s,this.signal=i,this.status=r,this.#s=o,this.#e.set(i.value),this.error=r.map(a=>a?.type==="invalid"?a.error?.message:void 0),this.hasError=this.error.map(a=>a!=null),this.touched=this.#t.touched,l.validationMode?this.errorVisible=e.computedOf(this.hasError,this.touched,l.validationMode)((a,c,d)=>d==="eager"?!!a:!!a&&!!c):this.errorVisible=e.computedOf(this.hasError,this.touched)((a,c)=>!!a&&!!c),this.dirty=e.computedOf(this.signal,this.#e)((a,c)=>!this.#s(a,c)),this.dependencyErrors=r.map(a=>a?.type==="invalid"?a.error?.dependencies:void 0),this.parent=l,this.disabled=e.computedOf(this.#t.disabled,l.disabled)((a,c)=>a||c),this.disabledOrHasErrors=e.computedOf(this.disabled,this.hasError)((a,c)=>a||c),this.onDispose(()=>{this.#t.disabled.dispose(),this.#t.touched.dispose(),this.disabled.dispose(),this.error.dispose(),this.errorVisible.dispose(),this.dirty.dispose(),this.#e.dispose(),this.dependencyErrors.dispose(),this.disabledOrHasErrors.dispose()})}get name(){return $(this.path)}onDispose=t=>{this.#n.push(t)};dispose=()=>{for(const t of this.#n)try{t()}catch(s){console.error("Error in dispose callback:",s)}this.#n.length=0};setDisabled=t=>{this.#t.disabled.set(t)};disable=()=>this.setDisabled(!0);enable=()=>this.setDisabled(!1);markTouched=()=>{this.#t.touched.set(!0)};resetTouched=()=>{this.#t.touched.set(!1)};markPristine=()=>{this.#e.set(this.signal.value)};reset=()=>{this.change(this.#e.value)};array=(t=p.strictEqual)=>new N(this.path,this.change,this.signal,this.status,this.parent,t);object=(t=p.strictEqual)=>new W(this.path,this.change,this.signal,this.status,this.parent,t);transform=(t,s,i=[],r=p.strictEqual)=>new k([...this.path,...i],l=>this.change(s(l)),this.signal.map(t,r),this.status.map(V(i)),this.parent,r);asyncTransform=(t,s,i,r=[],l=p.strictEqual)=>new k([...this.path,...r],o=>{s(o).then(a=>this.change(a))},this.signal.mapAsync(t,i,void 0,l),this.status.map(V(r)),this.parent,l)}class W extends k{#t=new Map;#s=new Map;#e=new Map;#n=e.prop(!1);touchedDeep=this.#n;#r=new Map;#i=new Map;#o=e.prop(!1);dirtyDeep=this.#o;#c;#h;#l=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#n.set(this.touched.value||t)};constructor(t,s,i,r,l,o){super(t,s,i.map(c=>c??{},o),r,l,o),this.#c=this.touched.on(()=>{this.#l()}),this.#h=this.dirty.on(()=>{this.#a()});const a=this.signal.on(()=>this.#a());this.onDispose(()=>{for(const c of this.#t.values())c.dispose();this.#t.clear();for(const c of this.#e.values())c();this.#e.clear(),this.#s.clear(),this.#n.dispose();for(const c of this.#i.values())c();this.#i.clear(),this.#r.clear(),this.#o.dispose(),this.#c(),this.#h(),a()})}field=t=>{if(this.#t.has(t))return this.#t.get(t);const s=async o=>{this.change({...this.signal.value,[t]:o})},i=new k([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#t.set(t,i);const r=i.touched.on(o=>{this.#s.set(t,o),this.#l()});this.#e.set(t,r);const l=i.dirty.on(o=>{this.#r.set(t,o),this.#a()});return this.#i.set(t,l),i};markAllTouched=()=>{this.markTouched();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markTouched();for(const s of this.#t.values())s.markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markPristine?.();for(const s of this.#t.values())s.markPristine?.()};#a=()=>{let t=!1;for(const s of this.#r.values())if(s){t=!0;break}this.#o.set(this.dirty.value||t)}}class N extends k{#t=new Array;length;#s=new Map;#e=new Map;#n=e.prop(!1);touchedDeep=this.#n;#r=new Map;#i=new Map;#o=e.prop(!1);dirtyDeep=this.#o;#c;#h;#l=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#n.set(this.touched.value||t)};constructor(t,s,i,r,l,o){const a=i.map(u=>u??[],o);super(t,s,a,r,l,o);const c=a.on(u=>{const m=this.#t.length-u.length;m>0&&(this.#t.splice(u.length,m).forEach((g,v)=>{const f=u.length+v;g.dispose(),this.#e.get(f)?.(),this.#e.delete(f),this.#s.delete(f),this.#i.get(f)?.(),this.#i.delete(f),this.#r.delete(f)}),this.#l(),this.#a())});this.length=a.map(u=>u.length),this.#c=this.touched.on(()=>{this.#l()}),this.#h=this.dirty.on(()=>{this.#a()});const d=this.signal.on(()=>this.#a());this.onDispose(()=>{for(const u of this.#t)u.dispose();this.length.dispose(),this.#t.length=0,c(),a.dispose();for(const u of this.#e.values())u();this.#e.clear(),this.#s.clear(),this.#n.dispose();for(const u of this.#i.values())u();this.#i.clear(),this.#r.clear(),this.#o.dispose(),this.#c(),this.#h(),d()})}item=t=>{if(this.#t[t])return this.#t[t];const s=async o=>{const a=this.signal.value.slice();a[t]=o,this.change(a)},i=new k([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#t[t]=i;const r=i.touched.on(o=>{this.#s.set(t,o),this.#l()});this.#e.set(t,r);const l=i.dirty.on(o=>{this.#r.set(t,o),this.#a()});return this.#i.set(t,l),i};push=(...t)=>{this.change([...this.signal.value,...t])};pop=()=>{this.splice(this.signal.value.length-1,1)};shift=()=>{this.splice(0,1)};unshift=(...t)=>{this.change([...t,...this.signal.value])};removeAt=t=>{this.splice(t,1)};splice=(t,s)=>{const i=this.signal.value.slice();i.splice(t,s),this.change(i)};move=(t,s,i=1)=>{if(i<1||t===s)return;const r=this.signal.value.slice(),l=r.splice(t,i);r.splice(s,0,...l),this.change(r)};markAllTouched=()=>{this.markTouched();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markPristine?.()};#a=()=>{let t=!1;for(const s of this.#r.values())if(s){t=!0;break}this.#o.set(this.dirty.value||t)}}function z(n){function t(s){return typeof s=="number"?s:s.toString()}return n.map(s=>typeof s=="object"&&s.key!=null?t(s.key):t(s))}function L(n){const t=n.filter(r=>r.path==null||r.path.length===0).map(r=>r.message),s=n.filter(r=>r.path!=null&&r.path.length>0).reduce((r,l)=>{const o=z(l.path),a=o.pop();let c=r;for(const d of o)c.dependencies==null&&(c.dependencies={}),c.dependencies[d]==null&&(c.dependencies[d]={}),c=c.dependencies[d];return c.dependencies==null&&(c.dependencies={}),c.dependencies[a]={message:l.message},r},{}),i=t.join(`
|
|
2
|
-
`);return{...s,message:i!=""?i:void 0}}function R({initialValue:n,onChange:t,validate:s,equals:i,validationMode:r,validateDebounceMs:l}){const o=e.Value.deriveProp(n),a=e.prop(p.Validation.valid),c=e.prop(!1),d=e.prop(r??"onTouched"),u=h=>{a.set(h)};let m;const g=async h=>{if(s!=null){const y=await s(h);u(y)}},v=async h=>{o.set(h),t?.(h);const y=d.value;if(s!=null){if(y==="onSubmit")return;const w=l??0;w>0?(m&&clearTimeout(m),m=setTimeout(()=>{g(h)},w)):await g(h)}},f=new k([],v,o,a,{disabled:c,validationMode:d},i??p.strictEqual);return f.onDispose(()=>{c.dispose(),o.dispose(),a.dispose(),d.dispose(),m&&clearTimeout(m)}),{controller:f,setStatus:u}}function x(n){return e.Fragment(e.attr.disabled(n.disabled),e.attr.name(n.name))}function nt(n,{triggerOn:t="change"}={}){return e.Fragment(x(n),e.attr.value(n.signal),(t==="input"?e.on.input:e.on.change)(e.emitValue(n.change)))}function it(n,{triggerOn:t="change"}={}){return e.Fragment(x(n),e.attr.valueAsNumber(n.signal),(t==="input"?e.on.input:e.on.change)(e.emitValueAsNumber(n.change)))}function S(n){return n.issues!=null?p.Validation.invalid(L(n.issues)):p.Validation.valid}async function rt({task:n,errorMessage:t,errorPath:s=["root"],validation:i}){try{const r=await n();return i!=null?i(r):p.Validation.valid}catch(r){const l=t??(r instanceof Error?r.message:"Operation failed");return s.length===1&&s[0]==="root"?p.Validation.invalid({message:l}):p.Validation.invalid({dependencies:U(s,l)})}}function U(n,t){if(n.length===1)return{[n[0]]:{message:t}};const[s,...i]=n;return{[s]:{dependencies:U(i,t)}}}function at({initialValue:n={},schema:t,onSubmit:s=async()=>p.Validation.valid,validationMode:i,validateDebounceMs:r}){const{controller:l,setStatus:o}=R({initialValue:n,validationMode:i??"onTouched",validateDebounceMs:r,validate:(i??"onTouched")==="onSubmit"||t==null?void 0:async u=>S(await t["~standard"].validate(u))}),a=e.prop(!1),c=l.object();return c.onDispose(()=>a.dispose()),{controller:c,setStatus:o,submit:async u=>{if(a.set(!0),u?.preventDefault(),c.markAllTouched(),t!=null){const g=c.signal.value,v=S(await t["~standard"].validate(g));if(o(v),v.type==="invalid"){a.set(!1);return}}const m=await s(c.signal.value);a.set(!1),m.type==="invalid"&&o(m)},submitting:a}}exports.ArrayController=N;exports.BaseControl=M;exports.BaseMappedControl=H;exports.CheckboxInput=Y;exports.CloseButton=X;exports.Control=Z;exports.Controller=k;exports.ControllerValidation=st;exports.InputWrapper=O;exports.MappedControl=tt;exports.ObjectController=W;exports.RequiredSymbol=P;exports.connectCommonAttributes=x;exports.connectNumberInput=it;exports.connectStringInput=nt;exports.convertStandardSchemaIssues=L;exports.convertStandardSchemaPathToPath=z;exports.makeMapValidation=V;exports.makeOnBlurHandler=q;exports.makeOnChangeHandler=E;exports.parsePath=et;exports.pathToString=$;exports.standardSchemaResultToValidation=S;exports.taskToValidation=rt;exports.useController=R;exports.useForm=at;exports.wrapSegment=F;
|