@ynput/ayon-react-components 1.4.2 → 1.4.4

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.
@@ -3,7 +3,7 @@ import * as Styled from './Dropdown.styled';
3
3
  import { IconType } from '../../Icon';
4
4
  export interface DropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
5
  message?: string;
6
- error?: string;
6
+ error?: string | null | false;
7
7
  itemStyle?: CSSProperties;
8
8
  valueStyle?: CSSProperties;
9
9
  listStyle?: CSSProperties;
@@ -10445,7 +10445,7 @@ const ks = ct(({
10445
10445
  error: "Value no longer exists"
10446
10446
  })), !!q.length];
10447
10447
  }, [ft, c]);
10448
- gr && (w = "Some values no longer exist"), c = St(() => !ie || !se || !se.length ? c : [...c].sort((q, be) => se.indexOf(be[e]) - se.indexOf(q[e])), [se, c]), c = St(() => co ? [{
10448
+ gr && w === void 0 && (w = "Some values no longer exist"), c = St(() => !ie || !se || !se.length ? c : [...c].sort((q, be) => se.indexOf(be[e]) - se.indexOf(q[e])), [se, c]), c = St(() => co ? [{
10449
10449
  [i]: Or ? "Deselect All" : "Select All",
10450
10450
  [e]: Pe
10451
10451
  }, ...c] : c, [Or, co, c]), c = St(() => Z ? [{
@@ -10978,6 +10978,7 @@ const ks = ct(({
10978
10978
  O(r);
10979
10979
  }, [r]), /* @__PURE__ */ x(fbe, {
10980
10980
  ...v,
10981
+ error: null,
10981
10982
  value: T,
10982
10983
  valueTemplate: (P, L, N) => /* @__PURE__ */ x(mbe, {
10983
10984
  value: (N ? L : P) || [],
@@ -580,7 +580,7 @@ function print() { __p += __j.call(arguments, '') }
580
580
  * @license MIT license.
581
581
  * @copyright (c) 2020 Kent C. Dodds
582
582
  * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
583
- */const wn={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},Iv=(r,a)=>String(r.rankedValue).localeCompare(String(a.rankedValue));function l_(r,a,o){o===void 0&&(o={});const{keys:t,threshold:e=wn.MATCHES,baseSort:i=Iv,sorter:c=_=>_.sort((f,h)=>Lv(f,h,i))}=o,u=r.reduce(d,[]);return c(u).map(_=>{let{item:f}=_;return f});function d(_,f,h){const v=Rv(f,t,a,o),{rank:w,keyThreshold:b=e}=v;return w>=b&&_.push({...v,item:f,index:h}),_}}l_.rankings=wn;function Rv(r,a,o,t){if(!a){const i=r;return{rankedValue:i,rank:u_(i,o,t),keyIndex:-1,keyThreshold:t.threshold}}return Wv(r,a).reduce((i,c,u)=>{let{rank:d,rankedValue:_,keyIndex:f,keyThreshold:h}=i,{itemValue:v,attributes:w}=c,b=u_(v,o,t),T=_;const{minRanking:O,maxRanking:P,threshold:L}=w;return b<O&&b>=wn.MATCHES?b=O:b>P&&(b=P),b>d&&(d=b,f=u,h=L,T=v),{rankedValue:T,rank:d,keyIndex:f,keyThreshold:h}},{rankedValue:r,rank:wn.NO_MATCH,keyIndex:-1,keyThreshold:t.threshold})}function u_(r,a,o){return r=d_(r,o),a=d_(a,o),a.length>r.length?wn.NO_MATCH:r===a?wn.CASE_SENSITIVE_EQUAL:(r=r.toLowerCase(),a=a.toLowerCase(),r===a?wn.EQUAL:r.startsWith(a)?wn.STARTS_WITH:r.includes(` ${a}`)?wn.WORD_STARTS_WITH:r.includes(a)?wn.CONTAINS:a.length===1?wn.NO_MATCH:Av(r).includes(a)?wn.ACRONYM:Nv(r,a))}function Av(r){let a="";return r.split(" ").forEach(t=>{t.split("-").forEach(i=>{a+=i.substr(0,1)})}),a}function Nv(r,a){let o=0,t=0;function e(d,_,f){for(let h=f,v=_.length;h<v;h++)if(_[h]===d)return o+=1,h+1;return-1}function i(d){const _=1/d,f=o/a.length;return wn.MATCHES+f*_}const c=e(a[0],r,0);if(c<0)return wn.NO_MATCH;t=c;for(let d=1,_=a.length;d<_;d++){const f=a[d];if(t=e(f,r,t),!(t>-1))return wn.NO_MATCH}const u=t-c;return i(u)}function Lv(r,a,o){const{rank:i,keyIndex:c}=r,{rank:u,keyIndex:d}=a;return i===u?c===d?o(r,a):c<d?-1:1:i>u?-1:1}function d_(r,a){let{keepDiacritics:o}=a;return r=`${r}`,o||(r=Vs.exports(r)),r}function Yv(r,a){typeof a=="object"&&(a=a.key);let o;if(typeof a=="function")o=a(r);else if(r==null)o=null;else if(Object.hasOwnProperty.call(r,a))o=r[a];else{if(a.includes("."))return Fv(a,r);o=null}return o==null?[]:Array.isArray(o)?o:[String(o)]}function Fv(r,a){const o=r.split(".");let t=[a];for(let e=0,i=o.length;e<i;e++){const c=o[e];let u=[];for(let d=0,_=t.length;d<_;d++){const f=t[d];if(f!=null)if(Object.hasOwnProperty.call(f,c)){const h=f[c];h!=null&&u.push(h)}else c==="*"&&(u=u.concat(f))}t=u}return Array.isArray(t[0])?[].concat(...t):t}function Wv(r,a){const o=[];for(let t=0,e=a.length;t<e;t++){const i=a[t],c=$v(i),u=Yv(r,i);for(let d=0,_=u.length;d<_;d++)o.push({itemValue:u[d],attributes:c})}return o}const __={maxRanking:1/0,minRanking:-1/0};function $v(r){return typeof r=="string"?__:{...__,...r}}function p_(r){var a,o,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var e=r.length;for(a=0;a<e;a++)r[a]&&(o=p_(r[a]))&&(t&&(t+=" "),t+=o)}else for(o in r)r[o]&&(t&&(t+=" "),t+=o);return t}function tn(){for(var r,a,o=0,t="",e=arguments.length;o<e;o++)(r=arguments[o])&&(a=p_(r))&&(t&&(t+=" "),t+=a);return t}function zv(r,a){W.useEffect(()=>{function o(t){r.every(e=>e.current&&!e.current.contains(t.target))&&a&&a()}return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[r,a])}const oa=W.forwardRef(({value:r=[],valueTemplate:a,valueStyle:o,listStyle:t,dataKey:e="value",labelKey:i="label",options:c=[],itemTemplate:u,itemStyle:d,buttonStyle:_,searchFields:f=["value"],valueIcon:h,message:v,error:w,disabled:b,onClose:T,onChange:O,onSelectionChange:P,onOpen:L,widthExpand:A=!0,align:R="left",multiSelect:N,multiSelectClose:$=!1,isMultiple:z,search:ee,searchOnNumber:G=20,placeholder:B="Select an option...",emptyMessage:F,isChanged:oe,maxOptionsShown:Q=25,style:_e,className:se,buttonClassName:pe,itemClassName:ve,valueClassName:Ce,listClassName:Me,minSelected:je=0,maxSelected:X,dropIcon:Z="expand_more",onClear:ae,clearTooltip:ue="Clear to no value",onClearNull:j,clearNullTooltip:fe="Clear to empty list",nullPlaceholder:me,editable:J,maxHeight:re=300,disabledValues:Pe=[],listInline:Ze=!1,disableOpen:Ve=!1,sortBySelected:ce=!1,onSelectAll:q,selectAllKey:Ie="__all__",buttonProps:Qe,activateKeys:Te=["Enter","Space","NumpadEnter","Tab"],...Je},Ue)=>{const[ie,Ee]=W.useState([]);W.useEffect(()=>{Ee(r===null?null:za.exports.compact(r))},[r]),!N&&ie&&ie.length>1&&(z=!0);const[Ne,st]=W.useState(!1),[ht,it]=W.useState({left:null,right:null,y:null}),[Gt,At]=W.useState(!1),[Et,jt]=W.useState(0),[xt,Pn]=W.useState(""),[mt,xn]=W.useState([]),[Nt,Xt]=W.useState(null),[dn,In]=W.useState(!1),[Rn,_n]=W.useState(Q);W.useEffect(()=>{Q!==Rn&&_n(Q)},[Q]);const jn=W.useRef(null),Lt=W.useRef(null),vn=W.useRef(null),gr=W.useRef(null),Kn=W.useRef(null);W.useEffect(()=>{if(Ne&&Lt.current&&Kn.current){const H=Lt.current.getBoundingClientRect(),ke=H.width-2,Re=H.height,ze=Kn.current.getBoundingClientRect().height,St=H.x,pn=window.innerWidth-H.x-ke;let fn=H.y+(Ze?0:Re);ze+fn+10>window.innerHeight&&(fn=H.y,At(!0)),it(R==="right"?{y:fn,right:pn,left:null}:{left:St,y:fn,right:null}),A&&jt(ke)}},[Ne,Lt,Kn,jt,it]),W.useEffect(()=>{var Ge,ze,St;if(!Ne)return;const H=(Ge=vn.current)==null?void 0:Ge.querySelector(".selected");if(!H)return;const ke=H.parentElement;if(!ke||(ke.scrollIntoView({block:"center"}),!((ze=ke.parentElement)!=null&&ze.children)))return;const Re=Array.from((St=ke.parentElement)==null?void 0:St.children).indexOf(ke);Xt(Re)},[Ne,Xt,vn]),W.useEffect(()=>{xn(ie)},[ie,xn]),W.useEffect(()=>{if(dn){const H=vn.current,ke=H==null?void 0:H.parentElement;if(!ke||!H)return;const Re=H.childNodes[Nt||0],Ge=ke.getBoundingClientRect().height||0,ze=Re==null?void 0:Re.getBoundingClientRect(),St=ke.getBoundingClientRect(),pn=(ze==null?void 0:ze.top)-((St==null?void 0:St.top)||0),fn=(ze==null?void 0:ze.bottom)-((St==null?void 0:St.top)||0);fn>Ge+1?ke.scrollTo(0,ke.scrollTop+(fn-Ge)):pn-1<0&&ke.scrollTo(0,ke.scrollTop+pn-1)}},[Nt,c,dn,vn]);const go=q&&N,Wr=W.useMemo(()=>ie&&ie.length>=c.length,[ie,c]),[Vr,vr]=W.useMemo(()=>{const H=(mt==null?void 0:mt.filter(Re=>!!Re&&!c.some(Ge=>Ge[e]===Re)))||[];return[H.map(Re=>({[i]:Re,[e]:Re,error:"Value no longer exists"})),!!H.length]},[mt,c]);vr&&(w="Some values no longer exist"),c=W.useMemo(()=>!ce||!ie||!ie.length?c:[...c].sort((H,ke)=>ie.indexOf(ke[e])-ie.indexOf(H[e])),[ie,c]),c=W.useMemo(()=>go?[{[i]:Wr?"Deselect All":"Select All",[e]:Ie},...c]:c,[Wr,go,c]),c=W.useMemo(()=>J?[{[i]:xt?`Add new "${xt}"`:"Type to add new items...",[e]:xt,icon:"add",className:"add-new"},...c]:c,[J,xt,c]);const yr=[...c];ee===void 0&&G!==void 0&&(ee=c.length>G),(ee||J)&&xt&&(c=l_(c,xt,{keys:f}));const Dn=(H,ke,Re)=>{var ze;ke=ke||mt,H==null||H.stopPropagation(),st(!1),Xt(null),T&&T(),Pn(""),jt(0),!(za.exports.isEqual(ke,ie)&&(!z||Re))&&(O&&ke&&O(ke),Ee(ke),(ze=Lt.current)==null||ze.focus())};zv([Kn,Lt],()=>Dn(void 0,void 0,!0));const An=(H,ke)=>{P&&P(H),xn(H),ke&&(Ee(H),Dn(void 0,H))},Qr=(H,ke,Re)=>{var pn;if(Re==null||Re.stopPropagation(),Re==null||Re.preventDefault(),Ie===H&&q){if(Wr){An([],!1);return}const fn=c.map(yo=>yo[e]).filter(yo=>!Pe.includes(yo)).filter(yo=>yo!==Ie);An(fn,!0),typeof q=="function"&&q(fn);return}let Ge=mt?[...mt]:[];q&&Ge.includes(Ie)&&(Ge=Ge.filter(fn=>fn!==Ie));const ze=J&&ke===0;if(!N)Ge=[H];else if(!ze||xt)if(Ge.includes(H))Ge.length>je&&Ge.splice(Ge.indexOf(H),1);else if(X&&X>0){if(X===1&&(Ge=[H]),Ge.length>X)return}else Ge.push(H);ze&&((pn=gr.current)==null||pn.focus()),An(Ge,!!(!N||ze&&xt||X===1||$))},Nn=()=>{!ae||(xn([]),ae([]),st(!1))},$o=()=>{!j||(xn([]),j(null),st(!1))},is=(H,ke)=>{if(H.target.id==="clear")return ke?void 0:Nn();if(H.target.id==="backspace")return ke?void 0:$o();if(Ne)return Dn();Ve||b||(H.stopPropagation(),st(!Ne),L&&L())},cs=H=>{},vo=(H,ke)=>{const Re=ze=>{var St;return!((St=c[ze])!=null&&St.disabled)&&!Pe.includes(c[ze][e])};if(Re(H))return H;const Ge=ke?1:-1;for(let ze=H+Ge;ze>=0&&ze<c.length;ze+=Ge)if(Re(ze))return ze},C=H=>{var Ge,ze;let ke;if(H.code==="ArrowDown"||H.code==="ArrowRight"){let St=c.length;Nt===null||Nt>=St-1?ke=vo(0,!0):ke=vo((za.exports.isNull(Nt)?-1:Nt)+1,!0)}(H.code==="ArrowUp"||H.code==="ArrowLeft")&&Nt!==null&&(Nt===0?ke=vo(c.length-1,!1):ke=vo(Nt-1,!1)),ke!==void 0&&Xt(ke);let Re;if(Nt!==null&&c[Nt]&&c[Nt][e]&&(Re=c[Nt][e]),(H.code==="ArrowDown"||H.code==="ArrowUp"||H.code==="ArrowLeft"||H.code==="ArrowRight")&&(H.preventDefault(),Ne?dn||In(!0):!N&&Re&&O&&O([Re])),Te.includes(H.code)){if(H.code==="Space"&&ee||(H.code!=="Tab"&&H.preventDefault(),H.code==="Tab"&&!Ne))return;if(!Ne)return H.target.id==="clear"?Nn():H.target.id==="backspace"?$o():st(!0);if(N){if(Re&&H.code!=="Tab")return Qr(Re,Nt||0);let St=[c[0][e]];if(J&&xt&&(St=xt.split(",").map(pn=>pn.trim())),St=St.filter(pn=>!(mt!=null&&mt.includes(pn))),c.length===1||J){const pn=[...mt||[],...St];Dn(void 0,pn,...St)}}else Re=Re?[Re]:null,c.length===1&&!J&&(Re=[c[0][e]]),J&&xt&&(Re=xt),Re||(Re=ie),Dn(void 0,Re),(Ge=Lt.current)==null||Ge.focus()}else H.code==="Space"&&H.preventDefault();(H.code==="Escape"||H.code==="Tab"&&Ne)&&(H.code==="Escape"&&((ze=Lt.current)==null||ze.focus()),H.preventDefault(),H.stopPropagation(),Dn())},ne=()=>{_n(Rn+50)},de=W.useMemo(()=>{const H=Ne?mt:ie||[];let ke=[];return yr.forEach(Re=>{H!=null&&H.includes(Re[e])&&ke.push(Re[i]||Re[e])}),ke},[c,ie,e,i,mt,Ne]),Le=W.useMemo(()=>ie!=null&&ie.length?h||(N&&ie.length>1?null:c.length&&c[J?1:0]?c[J?1:0].icon:null):null,[h,N,c]);let at=W.useMemo(()=>ee||J?[...c].splice(0,Rn):c,[c,Rn]),yt=W.useMemo(()=>c.length-at.length,[c,at]);const nt={value:Ne?mt:ie,isMultiple:z,dropIcon:Z,displayIcon:Le,onClear:ae&&Nn,clearTooltip:ue,onClearNull:j&&$o,clearNullTooltip:fe,nullPlaceholder:me,style:o,placeholder:B,isOpen:Ne,className:Ce,hasError:!!w},Ke=W.useMemo(()=>{if(typeof a=="function")return a;if(a==="tags")return()=>x(Ov,{...nt})},[a,ie,Ne,ae,j,mt,Nn,z,Z]);W.useImperativeHandle(Ue,()=>({getElement:()=>jn.current,getOptions:()=>vn.current,open:()=>st(!0),close:()=>st(!1)}),[jn,Lt,vn,gr]);const en=Ne&&c&&(ht.y||ht.y===0)&&(!A||Et);let Dt;return!de.length&&b&&B?Dt=B:q&&(ie==null?void 0:ie.includes(Ie))?Dt="All selected":de.length?Dt=de.join(", "):Dt=F,ye(yv,{onKeyDown:C,onMouseMove:()=>dn&&In(!1),style:_e,className:`dropdown ${se}`,ref:jn,...Je,children:[x(vv,{ref:Lt,onClick:is,disabled:b,$isChanged:!!oe,$isOpen:Ne,...Qe,style:_,className:`button ${pe}`,children:Ke&&Ke(ie||[],mt||[],Ne)?Ke(ie||[],mt||[],Ne):x(Ua,{...nt,children:Dt})}),Ne&&Ia.createPortal(ye(wv,{style:{opacity:en?1:0,left:(ht==null?void 0:ht.left)||"unset",right:(ht==null?void 0:ht.right)||"unset",top:(ht==null?void 0:ht.y)||"unset",translate:Gt?"0 -100%":"none",transformOrigin:Gt?"center bottom":"center top",...d},$message:v||"",$error:w||"",$isOpen:!0,$hidden:!en,onSubmit:cs,ref:Kn,children:[(ee||J)&&ye(Dv,{className:"search",children:[x(Tt,{icon:"search"}),x(qa,{value:xt,onChange:H=>Pn(H.target.value),autoFocus:!0,tabIndex:0,ref:gr,onKeyDown:H=>H.code==="Enter"&&H.preventDefault()})]}),x(kv,{style:{maxHeight:re},$message:v||"",$search:!!ee||!!J,defer:!0,children:ye(xv,{style:{minWidth:Et,...t},className:tn("options",{usingKeyboard:dn}),ref:vn,children:[[...Vr,...at].map((H,ke)=>x(a_,{onClick:Re=>!H.disabled&&!Pe.includes(H[e])&&Qr(H[e],ke,Re),$usingKeyboard:dn,tabIndex:0,className:tn("option",Me,{disabled:H.disabled||Pe.includes(H[e]),focused:dn&&Nt===ke}),"data-value":H[e],children:u?u(H,!!ie&&ie.includes(H[e]),!!(mt!=null&&mt.includes(H[e])),ke):ye(Qc,{className:tn("option-child",ve,{selected:!!(mt!=null&&mt.includes(H[e])),active:ie&&ie.includes(H[e]),error:!!H.error}),style:d,children:[H.icon&&x(Tt,{icon:H.icon}),x("span",{children:H[i]||H[e]})]})},`${H[e]}-${ke}`)),!!yt&&x(a_,{onClick:ne,$usingKeyboard:!1,className:tn("option",Me,{focused:!1}),children:x(Qc,{className:"option-child hidden",children:x("span",{children:`Show ${50} more...`})})})]})})]}),document.body)]})}),qv=be.default.div`
583
+ */const wn={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},Iv=(r,a)=>String(r.rankedValue).localeCompare(String(a.rankedValue));function l_(r,a,o){o===void 0&&(o={});const{keys:t,threshold:e=wn.MATCHES,baseSort:i=Iv,sorter:c=_=>_.sort((f,h)=>Lv(f,h,i))}=o,u=r.reduce(d,[]);return c(u).map(_=>{let{item:f}=_;return f});function d(_,f,h){const v=Rv(f,t,a,o),{rank:w,keyThreshold:b=e}=v;return w>=b&&_.push({...v,item:f,index:h}),_}}l_.rankings=wn;function Rv(r,a,o,t){if(!a){const i=r;return{rankedValue:i,rank:u_(i,o,t),keyIndex:-1,keyThreshold:t.threshold}}return Wv(r,a).reduce((i,c,u)=>{let{rank:d,rankedValue:_,keyIndex:f,keyThreshold:h}=i,{itemValue:v,attributes:w}=c,b=u_(v,o,t),T=_;const{minRanking:O,maxRanking:P,threshold:L}=w;return b<O&&b>=wn.MATCHES?b=O:b>P&&(b=P),b>d&&(d=b,f=u,h=L,T=v),{rankedValue:T,rank:d,keyIndex:f,keyThreshold:h}},{rankedValue:r,rank:wn.NO_MATCH,keyIndex:-1,keyThreshold:t.threshold})}function u_(r,a,o){return r=d_(r,o),a=d_(a,o),a.length>r.length?wn.NO_MATCH:r===a?wn.CASE_SENSITIVE_EQUAL:(r=r.toLowerCase(),a=a.toLowerCase(),r===a?wn.EQUAL:r.startsWith(a)?wn.STARTS_WITH:r.includes(` ${a}`)?wn.WORD_STARTS_WITH:r.includes(a)?wn.CONTAINS:a.length===1?wn.NO_MATCH:Av(r).includes(a)?wn.ACRONYM:Nv(r,a))}function Av(r){let a="";return r.split(" ").forEach(t=>{t.split("-").forEach(i=>{a+=i.substr(0,1)})}),a}function Nv(r,a){let o=0,t=0;function e(d,_,f){for(let h=f,v=_.length;h<v;h++)if(_[h]===d)return o+=1,h+1;return-1}function i(d){const _=1/d,f=o/a.length;return wn.MATCHES+f*_}const c=e(a[0],r,0);if(c<0)return wn.NO_MATCH;t=c;for(let d=1,_=a.length;d<_;d++){const f=a[d];if(t=e(f,r,t),!(t>-1))return wn.NO_MATCH}const u=t-c;return i(u)}function Lv(r,a,o){const{rank:i,keyIndex:c}=r,{rank:u,keyIndex:d}=a;return i===u?c===d?o(r,a):c<d?-1:1:i>u?-1:1}function d_(r,a){let{keepDiacritics:o}=a;return r=`${r}`,o||(r=Vs.exports(r)),r}function Yv(r,a){typeof a=="object"&&(a=a.key);let o;if(typeof a=="function")o=a(r);else if(r==null)o=null;else if(Object.hasOwnProperty.call(r,a))o=r[a];else{if(a.includes("."))return Fv(a,r);o=null}return o==null?[]:Array.isArray(o)?o:[String(o)]}function Fv(r,a){const o=r.split(".");let t=[a];for(let e=0,i=o.length;e<i;e++){const c=o[e];let u=[];for(let d=0,_=t.length;d<_;d++){const f=t[d];if(f!=null)if(Object.hasOwnProperty.call(f,c)){const h=f[c];h!=null&&u.push(h)}else c==="*"&&(u=u.concat(f))}t=u}return Array.isArray(t[0])?[].concat(...t):t}function Wv(r,a){const o=[];for(let t=0,e=a.length;t<e;t++){const i=a[t],c=$v(i),u=Yv(r,i);for(let d=0,_=u.length;d<_;d++)o.push({itemValue:u[d],attributes:c})}return o}const __={maxRanking:1/0,minRanking:-1/0};function $v(r){return typeof r=="string"?__:{...__,...r}}function p_(r){var a,o,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var e=r.length;for(a=0;a<e;a++)r[a]&&(o=p_(r[a]))&&(t&&(t+=" "),t+=o)}else for(o in r)r[o]&&(t&&(t+=" "),t+=o);return t}function tn(){for(var r,a,o=0,t="",e=arguments.length;o<e;o++)(r=arguments[o])&&(a=p_(r))&&(t&&(t+=" "),t+=a);return t}function zv(r,a){W.useEffect(()=>{function o(t){r.every(e=>e.current&&!e.current.contains(t.target))&&a&&a()}return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[r,a])}const oa=W.forwardRef(({value:r=[],valueTemplate:a,valueStyle:o,listStyle:t,dataKey:e="value",labelKey:i="label",options:c=[],itemTemplate:u,itemStyle:d,buttonStyle:_,searchFields:f=["value"],valueIcon:h,message:v,error:w,disabled:b,onClose:T,onChange:O,onSelectionChange:P,onOpen:L,widthExpand:A=!0,align:R="left",multiSelect:N,multiSelectClose:$=!1,isMultiple:z,search:ee,searchOnNumber:G=20,placeholder:B="Select an option...",emptyMessage:F,isChanged:oe,maxOptionsShown:Q=25,style:_e,className:se,buttonClassName:pe,itemClassName:ve,valueClassName:Ce,listClassName:Me,minSelected:je=0,maxSelected:X,dropIcon:Z="expand_more",onClear:ae,clearTooltip:ue="Clear to no value",onClearNull:j,clearNullTooltip:fe="Clear to empty list",nullPlaceholder:me,editable:J,maxHeight:re=300,disabledValues:Pe=[],listInline:Ze=!1,disableOpen:Ve=!1,sortBySelected:ce=!1,onSelectAll:q,selectAllKey:Ie="__all__",buttonProps:Qe,activateKeys:Te=["Enter","Space","NumpadEnter","Tab"],...Je},Ue)=>{const[ie,Ee]=W.useState([]);W.useEffect(()=>{Ee(r===null?null:za.exports.compact(r))},[r]),!N&&ie&&ie.length>1&&(z=!0);const[Ne,st]=W.useState(!1),[ht,it]=W.useState({left:null,right:null,y:null}),[Gt,At]=W.useState(!1),[Et,jt]=W.useState(0),[xt,Pn]=W.useState(""),[mt,xn]=W.useState([]),[Nt,Xt]=W.useState(null),[dn,In]=W.useState(!1),[Rn,_n]=W.useState(Q);W.useEffect(()=>{Q!==Rn&&_n(Q)},[Q]);const jn=W.useRef(null),Lt=W.useRef(null),vn=W.useRef(null),gr=W.useRef(null),Kn=W.useRef(null);W.useEffect(()=>{if(Ne&&Lt.current&&Kn.current){const H=Lt.current.getBoundingClientRect(),ke=H.width-2,Re=H.height,ze=Kn.current.getBoundingClientRect().height,St=H.x,pn=window.innerWidth-H.x-ke;let fn=H.y+(Ze?0:Re);ze+fn+10>window.innerHeight&&(fn=H.y,At(!0)),it(R==="right"?{y:fn,right:pn,left:null}:{left:St,y:fn,right:null}),A&&jt(ke)}},[Ne,Lt,Kn,jt,it]),W.useEffect(()=>{var Ge,ze,St;if(!Ne)return;const H=(Ge=vn.current)==null?void 0:Ge.querySelector(".selected");if(!H)return;const ke=H.parentElement;if(!ke||(ke.scrollIntoView({block:"center"}),!((ze=ke.parentElement)!=null&&ze.children)))return;const Re=Array.from((St=ke.parentElement)==null?void 0:St.children).indexOf(ke);Xt(Re)},[Ne,Xt,vn]),W.useEffect(()=>{xn(ie)},[ie,xn]),W.useEffect(()=>{if(dn){const H=vn.current,ke=H==null?void 0:H.parentElement;if(!ke||!H)return;const Re=H.childNodes[Nt||0],Ge=ke.getBoundingClientRect().height||0,ze=Re==null?void 0:Re.getBoundingClientRect(),St=ke.getBoundingClientRect(),pn=(ze==null?void 0:ze.top)-((St==null?void 0:St.top)||0),fn=(ze==null?void 0:ze.bottom)-((St==null?void 0:St.top)||0);fn>Ge+1?ke.scrollTo(0,ke.scrollTop+(fn-Ge)):pn-1<0&&ke.scrollTo(0,ke.scrollTop+pn-1)}},[Nt,c,dn,vn]);const go=q&&N,Wr=W.useMemo(()=>ie&&ie.length>=c.length,[ie,c]),[Vr,vr]=W.useMemo(()=>{const H=(mt==null?void 0:mt.filter(Re=>!!Re&&!c.some(Ge=>Ge[e]===Re)))||[];return[H.map(Re=>({[i]:Re,[e]:Re,error:"Value no longer exists"})),!!H.length]},[mt,c]);vr&&w===void 0&&(w="Some values no longer exist"),c=W.useMemo(()=>!ce||!ie||!ie.length?c:[...c].sort((H,ke)=>ie.indexOf(ke[e])-ie.indexOf(H[e])),[ie,c]),c=W.useMemo(()=>go?[{[i]:Wr?"Deselect All":"Select All",[e]:Ie},...c]:c,[Wr,go,c]),c=W.useMemo(()=>J?[{[i]:xt?`Add new "${xt}"`:"Type to add new items...",[e]:xt,icon:"add",className:"add-new"},...c]:c,[J,xt,c]);const yr=[...c];ee===void 0&&G!==void 0&&(ee=c.length>G),(ee||J)&&xt&&(c=l_(c,xt,{keys:f}));const Dn=(H,ke,Re)=>{var ze;ke=ke||mt,H==null||H.stopPropagation(),st(!1),Xt(null),T&&T(),Pn(""),jt(0),!(za.exports.isEqual(ke,ie)&&(!z||Re))&&(O&&ke&&O(ke),Ee(ke),(ze=Lt.current)==null||ze.focus())};zv([Kn,Lt],()=>Dn(void 0,void 0,!0));const An=(H,ke)=>{P&&P(H),xn(H),ke&&(Ee(H),Dn(void 0,H))},Qr=(H,ke,Re)=>{var pn;if(Re==null||Re.stopPropagation(),Re==null||Re.preventDefault(),Ie===H&&q){if(Wr){An([],!1);return}const fn=c.map(yo=>yo[e]).filter(yo=>!Pe.includes(yo)).filter(yo=>yo!==Ie);An(fn,!0),typeof q=="function"&&q(fn);return}let Ge=mt?[...mt]:[];q&&Ge.includes(Ie)&&(Ge=Ge.filter(fn=>fn!==Ie));const ze=J&&ke===0;if(!N)Ge=[H];else if(!ze||xt)if(Ge.includes(H))Ge.length>je&&Ge.splice(Ge.indexOf(H),1);else if(X&&X>0){if(X===1&&(Ge=[H]),Ge.length>X)return}else Ge.push(H);ze&&((pn=gr.current)==null||pn.focus()),An(Ge,!!(!N||ze&&xt||X===1||$))},Nn=()=>{!ae||(xn([]),ae([]),st(!1))},$o=()=>{!j||(xn([]),j(null),st(!1))},is=(H,ke)=>{if(H.target.id==="clear")return ke?void 0:Nn();if(H.target.id==="backspace")return ke?void 0:$o();if(Ne)return Dn();Ve||b||(H.stopPropagation(),st(!Ne),L&&L())},cs=H=>{},vo=(H,ke)=>{const Re=ze=>{var St;return!((St=c[ze])!=null&&St.disabled)&&!Pe.includes(c[ze][e])};if(Re(H))return H;const Ge=ke?1:-1;for(let ze=H+Ge;ze>=0&&ze<c.length;ze+=Ge)if(Re(ze))return ze},C=H=>{var Ge,ze;let ke;if(H.code==="ArrowDown"||H.code==="ArrowRight"){let St=c.length;Nt===null||Nt>=St-1?ke=vo(0,!0):ke=vo((za.exports.isNull(Nt)?-1:Nt)+1,!0)}(H.code==="ArrowUp"||H.code==="ArrowLeft")&&Nt!==null&&(Nt===0?ke=vo(c.length-1,!1):ke=vo(Nt-1,!1)),ke!==void 0&&Xt(ke);let Re;if(Nt!==null&&c[Nt]&&c[Nt][e]&&(Re=c[Nt][e]),(H.code==="ArrowDown"||H.code==="ArrowUp"||H.code==="ArrowLeft"||H.code==="ArrowRight")&&(H.preventDefault(),Ne?dn||In(!0):!N&&Re&&O&&O([Re])),Te.includes(H.code)){if(H.code==="Space"&&ee||(H.code!=="Tab"&&H.preventDefault(),H.code==="Tab"&&!Ne))return;if(!Ne)return H.target.id==="clear"?Nn():H.target.id==="backspace"?$o():st(!0);if(N){if(Re&&H.code!=="Tab")return Qr(Re,Nt||0);let St=[c[0][e]];if(J&&xt&&(St=xt.split(",").map(pn=>pn.trim())),St=St.filter(pn=>!(mt!=null&&mt.includes(pn))),c.length===1||J){const pn=[...mt||[],...St];Dn(void 0,pn,...St)}}else Re=Re?[Re]:null,c.length===1&&!J&&(Re=[c[0][e]]),J&&xt&&(Re=xt),Re||(Re=ie),Dn(void 0,Re),(Ge=Lt.current)==null||Ge.focus()}else H.code==="Space"&&H.preventDefault();(H.code==="Escape"||H.code==="Tab"&&Ne)&&(H.code==="Escape"&&((ze=Lt.current)==null||ze.focus()),H.preventDefault(),H.stopPropagation(),Dn())},ne=()=>{_n(Rn+50)},de=W.useMemo(()=>{const H=Ne?mt:ie||[];let ke=[];return yr.forEach(Re=>{H!=null&&H.includes(Re[e])&&ke.push(Re[i]||Re[e])}),ke},[c,ie,e,i,mt,Ne]),Le=W.useMemo(()=>ie!=null&&ie.length?h||(N&&ie.length>1?null:c.length&&c[J?1:0]?c[J?1:0].icon:null):null,[h,N,c]);let at=W.useMemo(()=>ee||J?[...c].splice(0,Rn):c,[c,Rn]),yt=W.useMemo(()=>c.length-at.length,[c,at]);const nt={value:Ne?mt:ie,isMultiple:z,dropIcon:Z,displayIcon:Le,onClear:ae&&Nn,clearTooltip:ue,onClearNull:j&&$o,clearNullTooltip:fe,nullPlaceholder:me,style:o,placeholder:B,isOpen:Ne,className:Ce,hasError:!!w},Ke=W.useMemo(()=>{if(typeof a=="function")return a;if(a==="tags")return()=>x(Ov,{...nt})},[a,ie,Ne,ae,j,mt,Nn,z,Z]);W.useImperativeHandle(Ue,()=>({getElement:()=>jn.current,getOptions:()=>vn.current,open:()=>st(!0),close:()=>st(!1)}),[jn,Lt,vn,gr]);const en=Ne&&c&&(ht.y||ht.y===0)&&(!A||Et);let Dt;return!de.length&&b&&B?Dt=B:q&&(ie==null?void 0:ie.includes(Ie))?Dt="All selected":de.length?Dt=de.join(", "):Dt=F,ye(yv,{onKeyDown:C,onMouseMove:()=>dn&&In(!1),style:_e,className:`dropdown ${se}`,ref:jn,...Je,children:[x(vv,{ref:Lt,onClick:is,disabled:b,$isChanged:!!oe,$isOpen:Ne,...Qe,style:_,className:`button ${pe}`,children:Ke&&Ke(ie||[],mt||[],Ne)?Ke(ie||[],mt||[],Ne):x(Ua,{...nt,children:Dt})}),Ne&&Ia.createPortal(ye(wv,{style:{opacity:en?1:0,left:(ht==null?void 0:ht.left)||"unset",right:(ht==null?void 0:ht.right)||"unset",top:(ht==null?void 0:ht.y)||"unset",translate:Gt?"0 -100%":"none",transformOrigin:Gt?"center bottom":"center top",...d},$message:v||"",$error:w||"",$isOpen:!0,$hidden:!en,onSubmit:cs,ref:Kn,children:[(ee||J)&&ye(Dv,{className:"search",children:[x(Tt,{icon:"search"}),x(qa,{value:xt,onChange:H=>Pn(H.target.value),autoFocus:!0,tabIndex:0,ref:gr,onKeyDown:H=>H.code==="Enter"&&H.preventDefault()})]}),x(kv,{style:{maxHeight:re},$message:v||"",$search:!!ee||!!J,defer:!0,children:ye(xv,{style:{minWidth:Et,...t},className:tn("options",{usingKeyboard:dn}),ref:vn,children:[[...Vr,...at].map((H,ke)=>x(a_,{onClick:Re=>!H.disabled&&!Pe.includes(H[e])&&Qr(H[e],ke,Re),$usingKeyboard:dn,tabIndex:0,className:tn("option",Me,{disabled:H.disabled||Pe.includes(H[e]),focused:dn&&Nt===ke}),"data-value":H[e],children:u?u(H,!!ie&&ie.includes(H[e]),!!(mt!=null&&mt.includes(H[e])),ke):ye(Qc,{className:tn("option-child",ve,{selected:!!(mt!=null&&mt.includes(H[e])),active:ie&&ie.includes(H[e]),error:!!H.error}),style:d,children:[H.icon&&x(Tt,{icon:H.icon}),x("span",{children:H[i]||H[e]})]})},`${H[e]}-${ke}`)),!!yt&&x(a_,{onClick:ne,$usingKeyboard:!1,className:tn("option",Me,{focused:!1}),children:x(Qc,{className:"option-child hidden",children:x("span",{children:`Show ${50} more...`})})})]})})]}),document.body)]})}),qv=be.default.div`
584
584
  border: 1px solid var(--md-sys-color-outline-variant);
585
585
  border-radius: var(--border-radius-m);
586
586
  height: 100%;
@@ -668,7 +668,7 @@ function print() { __p += __j.call(arguments, '') }
668
668
  display: none;
669
669
  }
670
670
  `}
671
- `,Kv=r=>{const{value:a,tags:o={},editor:t=!1}=r;return a!=null&&a.length||a==null||a.push("Add tags"),x(jv,{...r,hasError:void 0,valueStyle:{gap:4,display:"flex"},editor:t,children:a==null?void 0:a.map(e=>{var i;return x(Bv,{style:{color:(i=o[e])==null?void 0:i.color},children:e},e)})})},Vv=W.forwardRef(({value:r=[],onChange:a,widthExpand:o=!0,disabled:t,tags:e,tagsOrder:i,editor:c,align:u,styleDropdown:d,width:_=300,valueProps:f,isMultiple:h,...v},w)=>{const b=W.useMemo(()=>{if(!i)return Object.values(e);const P=[],L=[];for(const A of i)!e[A]||L.includes(A)||(P.push(e[A]),L.push(A));return P},[e,i]),[T,O]=W.useState([]);return W.useEffect(()=>{O(r)},[r]),x(Hv,{...v,value:T,valueTemplate:(P,L,A)=>x(Kv,{value:(A?L:P)||[],...f,tags:e,editor:c,isMultiple:h}),itemTemplate:(P,L,A,R)=>ye(Qc,{className:tn("option-child",{selected:A}),style:{color:P.color,justifyContent:R?"center":void 0},children:[P.icon&&x(Tt,{icon:P.icon}),x("span",{children:P.name||P.label})]}),options:b||[],dataKey:"name",disabled:t,onChange:P=>a&&a(P.map(L=>L.toString()).filter(L=>L&&L!=="Add tags")),widthExpand:o,multiSelect:!0,search:!0,searchFields:["name","fullName"],ref:w,editable:!0,align:u,style:d,width:_,sortBySelected:!0})}),Qv=be.default.div`
671
+ `,Kv=r=>{const{value:a,tags:o={},editor:t=!1}=r;return a!=null&&a.length||a==null||a.push("Add tags"),x(jv,{...r,hasError:void 0,valueStyle:{gap:4,display:"flex"},editor:t,children:a==null?void 0:a.map(e=>{var i;return x(Bv,{style:{color:(i=o[e])==null?void 0:i.color},children:e},e)})})},Vv=W.forwardRef(({value:r=[],onChange:a,widthExpand:o=!0,disabled:t,tags:e,tagsOrder:i,editor:c,align:u,styleDropdown:d,width:_=300,valueProps:f,isMultiple:h,...v},w)=>{const b=W.useMemo(()=>{if(!i)return Object.values(e);const P=[],L=[];for(const A of i)!e[A]||L.includes(A)||(P.push(e[A]),L.push(A));return P},[e,i]),[T,O]=W.useState([]);return W.useEffect(()=>{O(r)},[r]),x(Hv,{...v,error:null,value:T,valueTemplate:(P,L,A)=>x(Kv,{value:(A?L:P)||[],...f,tags:e,editor:c,isMultiple:h}),itemTemplate:(P,L,A,R)=>ye(Qc,{className:tn("option-child",{selected:A}),style:{color:P.color,justifyContent:R?"center":void 0},children:[P.icon&&x(Tt,{icon:P.icon}),x("span",{children:P.name||P.label})]}),options:b||[],dataKey:"name",disabled:t,onChange:P=>a&&a(P.map(L=>L.toString()).filter(L=>L&&L!=="Add tags")),widthExpand:o,multiSelect:!0,search:!0,searchFields:["name","fullName"],ref:w,editable:!0,align:u,style:d,width:_,sortBySelected:!0})}),Qv=be.default.div`
672
672
  display: flex;
673
673
  align-items: center;
674
674
  /* justify-content: center; */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ynput/ayon-react-components",
3
3
  "private": false,
4
- "version": "1.4.2",
4
+ "version": "1.4.4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",