@ansible/ansible-ui-framework 2.4.1824 → 2.4.1825

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -35486,6 +35486,7 @@ function zi(e) {
35486
35486
  Te,
35487
35487
  {
35488
35488
  variant: "control",
35489
+ "data-cy": "reset",
35489
35490
  onClick: () => {
35490
35491
  var S;
35491
35492
  u(!1), a(null), x !== null && "current" in x && ((S = x.current) == null || S.focus());
package/index.umd.cjs CHANGED
@@ -390,7 +390,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
390
390
  `;function S0e(e){const{t}=Be(),[n,r]=b.useState(!1),[i,a]=b.useState(!1),[o,s]=b.useState(),[l,c]=b.useState(0),[u,f]=b.useState(),[d,h]=b.useState(!1),p=b.useRef(),[m,v]=b.useState(""),y=b.useCallback(E.debounce(k=>v(k),200),[]),x=b.useRef(e.queryOptions).current,w=b.useRef(null),S=b.useCallback(()=>{w.current&&w.current.abort();const k=new AbortController;return w.current=k,r(()=>(a(!1),s(void 0),f(P=>{if(P)return P}),x({next:p.current,signal:k.signal,search:m}).then(P=>{k.signal.aborted||(p.current=P.next,P.remaining||a(!0),f(M=>{if(k.signal.aborted)return M;let A=[...M??[],...P.options];const D=new Set;return A=A.filter(j=>D.has(j.value)?!1:(D.add(j.value),!0)),A.sort((j,$)=>{const I=j.label.toLowerCase(),z=$.label.toLowerCase();return I<z?-1:I>z?1:0}),c(P.remaining+A.length),A}))}).catch(P=>{k.signal.aborted||s(P instanceof Error?P:new Error(t("Unknown error")))}).finally(()=>{k.signal.aborted||r(!1)}),!0)),()=>k.abort()},[x,m,t]),_=b.useCallback(k=>{k.preventDefault(),k.stopPropagation(),S()},[S]),O=b.useCallback(k=>{k.preventDefault(),k.stopPropagation(),c(0),f([]),p.current=void 0,S()},[S]);b.useEffect(()=>{d&&(c(0),f([]),p.current=void 0,S())},[d,S]);const T=g.jsxs(E.Stack,{hasGutter:!0,children:[g.jsxs(E.Flex,{children:[g.jsx(E.FlexItem,{grow:{default:"grow"},children:g.jsxs(E.ActionList,{children:[e.onBrowse&&g.jsx(E.ActionListItem,{children:g.jsx(E.Button,{id:"browse",onClick:k=>{var P;k.preventDefault(),k.stopPropagation(),h(!1),(P=e.onBrowse)==null||P.call(e)},children:t("Browse")})}),!i&&g.jsx(E.ActionListItem,{children:g.jsx(E.Button,{id:"load-more",isLoading:n,onClick:_,isDisabled:n,children:t(n?"Loading...":"Load more")})})]})}),!i&&l!==0&&g.jsx(E.FlexItem,{children:t("Loaded {{count}} of {{total}}",{count:(u==null?void 0:u.length)??0,total:l})})]}),e.footer]});return o?g.jsx(O0e,{id:e.id,variant:"secondary",isDanger:!0,icon:g.jsx(ve.SyncAltIcon,{}),iconPosition:"right",onClick:O,children:typeof e.queryErrorText=="function"?e.queryErrorText(o):e.queryErrorText??t("Error loading options")}):g.jsx(FA,{id:e.id,icon:e.icon,placeholder:e.placeholder,options:u??[],values:e.values,onSelect:e.onSelect,variant:e.variant,footer:T,open:d,setOpen:h,searchValue:m,setSearchValue:y,isLoading:n,disableClearSelection:e.disableClearSelection,disableClearChips:e.disableClearChips,queryLabel:e.queryLabel})}const O0e=Pe(E.Button)`
391
391
  width: 100%;
392
392
  text-align: left;
393
- `;var qy={exports:{}};function zA(e,t=100,n={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof n=="boolean"?{immediate:n}:n;let i,a,o,s,l;function c(){const d=i,h=a;return i=void 0,a=void 0,l=e.apply(d,h),l}function u(){const d=Date.now()-s;d<t&&d>=0?o=setTimeout(u,t-d):(o=void 0,r||(l=c()))}const f=function(...d){if(i&&this!==i)throw new Error("Debounced method called with different contexts.");i=this,a=d,s=Date.now();const h=r&&!o;return o||(o=setTimeout(u,t)),h&&(l=c()),l};return f.clear=()=>{o&&(clearTimeout(o),o=void 0)},f.flush=()=>{o&&f.trigger()},f.trigger=()=>{l=c(),f.clear()},f}qy.exports.debounce=zA,qy.exports=zA;var C0e=qy.exports;const Yy=Ne(C0e);function Ii(e){const{t}=Be(),{id:n,icon:r,value:i,onSelect:a,options:o,placeholder:s,queryLabel:l}=e,[c,u]=Lh(e.open??!1,e.setOpen);b.useEffect(()=>{c&&setTimeout(()=>{var _;return(_=x.current)==null?void 0:_.focus()},1)},[c]);const[f,d]=Lh(e.searchValue??"",e.setSearchValue),h=b.useRef(null),p=b.useMemo(()=>o.find(_=>i===_.value),[o,i]),m=b.useMemo(()=>{let _=p==null?void 0:p.label;return!_&&i!==void 0&&i!==""&&i!==null&&(_=l==null?void 0:l(i)),_},[l,p==null?void 0:p.label,i]),v=_=>g.jsx(E.Tooltip,{content:e.isDisabled,trigger:e.isDisabled?void 0:"manual",children:g.jsxs(E.Flex,{flexWrap:{default:"nowrap"},children:[g.jsx(E.MenuToggle,{id:n,"data-cy":n,ref:_,icon:r??(p==null?void 0:p.icon),onClick:()=>u(!c),isExpanded:c,isDisabled:!!e.isDisabled,style:{pointerEvents:e.isDisabled?"unset":void 0,cursor:e.isDisabled?"not-allowed":void 0},onKeyDown:O=>{switch(O.key){case"Tab":case"Shift":break;default:O.preventDefault(),O.key.length===1&&d(O.key),u(!0),setTimeout(()=>{x.current&&O.key.length===1&&(x.current.value=O.key+x.current.value)},1);break}},isFullWidth:!0,children:m||g.jsx("span",{style:{opacity:.7},children:s})}),!e.isRequired&&m&&g.jsx(E.Button,{variant:"control",onClick:()=>{var O;u(!1),a(null),_!==null&&"current"in _&&((O=_.current)==null||O.focus())},children:g.jsx(E.Icon,{size:"md",style:{opacity:.7},children:g.jsx(ve.TimesIcon,{"aria-hidden":!0,style:{padding:0,margin:0}})})})]})}),y=b.useCallback((_,O)=>{const T=o.find(k=>k.key!==void 0?k.key===O:k.label===O);T&&(a(T.value),u(!1))},[a,o,u]),x=b.useRef(null);b.useEffect(()=>{c||d("")},[c,d]),b.useEffect(()=>{!e.disableAutoSelect&&e.isRequired&&!p&&o.length===1&&a(o[0].value)},[a,o,e.disableAutoSelect,e.isRequired,p]);const w=b.useMemo(()=>{let _=o;return e.setSearchValue||(_=_.filter(O=>f===""?!0:O.label.toLowerCase().includes(f.toLowerCase()))),e.disableSortOptions||(_=_.sort((O,T)=>{const k=O.label.toLowerCase(),P=T.label.toLowerCase();return k<P?-1:k>P?1:0})),_},[o,e.disableSortOptions,e.setSearchValue,f]),S=b.useMemo(()=>{if(o.some(O=>!!O.group)){const O={};for(const T of w){const k=T.group??"";O[k]||(O[k]=[]),O[k].push(T)}return O}},[o,w]);return g.jsx(WA.Provider,{value:{open:c,setOpen:u},children:g.jsxs(E.Select,{id:`${n}-select`,selected:p,onSelect:y,isOpen:c,onOpenChange:u,toggle:e.toggle??v,popperProps:{appendTo:()=>document.body},shouldFocusToggleOnSelect:!0,innerRef:h,children:[g.jsx(E.MenuSearch,{children:g.jsx(E.MenuSearchInput,{"data-cy":"search-input",children:g.jsx(E.SearchInput,{id:`${n}-search`,ref:x,value:f,onChange:(_,O)=>d(O),onClear:_=>{_.stopPropagation(),d("")},resultsCount:w.length!==o.length?`${w.length} / ${o.length}`:void 0,onKeyDown:_=>{var O;switch(_.key){case"ArrowDown":case"Tab":{_.preventDefault(),_.stopPropagation();const T=(O=h==null?void 0:h.current)==null?void 0:O.querySelector("li button:not(:disabled),li input:not(:disabled)");T&&T.focus();break}}}})})}),g.jsx(E.Divider,{}),w.length===0?g.jsx(g.Fragment,{children:e.isLoading?g.jsx(E.Bullseye,{style:{padding:16},children:g.jsx(E.Spinner,{size:"lg"})}):g.jsx(E.SelectOption,{isDisabled:!0,children:t("No results found")},"no result")}):g.jsx(E0e,{children:S?g.jsx(g.Fragment,{children:Object.keys(S).map(_=>g.jsx(E.SelectGroup,{label:_,children:g.jsx(BA,{searchRef:x,options:S[_]})},_))}):g.jsx(BA,{searchRef:x,options:w})}),e.footer&&g.jsx(E.MenuFooter,{children:e.footer})]})})}function BA(e){return g.jsx(E.SelectList,{onKeyDown:t=>{var n;switch(t.key){case"Tab":t.preventDefault(),t.stopPropagation(),(n=e.searchRef.current)==null||n.focus();break}},children:e.options.map(t=>{const n=pi(t);return g.jsx(E.SelectOption,{id:n,icon:t.icon,value:t.key!==void 0?t.key:t.label,description:t.description,"data-cy":n,children:t.label},t.key!==void 0?t.key:t.label)})})}const E0e=Pe(Cr)`
393
+ `;var qy={exports:{}};function zA(e,t=100,n={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof n=="boolean"?{immediate:n}:n;let i,a,o,s,l;function c(){const d=i,h=a;return i=void 0,a=void 0,l=e.apply(d,h),l}function u(){const d=Date.now()-s;d<t&&d>=0?o=setTimeout(u,t-d):(o=void 0,r||(l=c()))}const f=function(...d){if(i&&this!==i)throw new Error("Debounced method called with different contexts.");i=this,a=d,s=Date.now();const h=r&&!o;return o||(o=setTimeout(u,t)),h&&(l=c()),l};return f.clear=()=>{o&&(clearTimeout(o),o=void 0)},f.flush=()=>{o&&f.trigger()},f.trigger=()=>{l=c(),f.clear()},f}qy.exports.debounce=zA,qy.exports=zA;var C0e=qy.exports;const Yy=Ne(C0e);function Ii(e){const{t}=Be(),{id:n,icon:r,value:i,onSelect:a,options:o,placeholder:s,queryLabel:l}=e,[c,u]=Lh(e.open??!1,e.setOpen);b.useEffect(()=>{c&&setTimeout(()=>{var _;return(_=x.current)==null?void 0:_.focus()},1)},[c]);const[f,d]=Lh(e.searchValue??"",e.setSearchValue),h=b.useRef(null),p=b.useMemo(()=>o.find(_=>i===_.value),[o,i]),m=b.useMemo(()=>{let _=p==null?void 0:p.label;return!_&&i!==void 0&&i!==""&&i!==null&&(_=l==null?void 0:l(i)),_},[l,p==null?void 0:p.label,i]),v=_=>g.jsx(E.Tooltip,{content:e.isDisabled,trigger:e.isDisabled?void 0:"manual",children:g.jsxs(E.Flex,{flexWrap:{default:"nowrap"},children:[g.jsx(E.MenuToggle,{id:n,"data-cy":n,ref:_,icon:r??(p==null?void 0:p.icon),onClick:()=>u(!c),isExpanded:c,isDisabled:!!e.isDisabled,style:{pointerEvents:e.isDisabled?"unset":void 0,cursor:e.isDisabled?"not-allowed":void 0},onKeyDown:O=>{switch(O.key){case"Tab":case"Shift":break;default:O.preventDefault(),O.key.length===1&&d(O.key),u(!0),setTimeout(()=>{x.current&&O.key.length===1&&(x.current.value=O.key+x.current.value)},1);break}},isFullWidth:!0,children:m||g.jsx("span",{style:{opacity:.7},children:s})}),!e.isRequired&&m&&g.jsx(E.Button,{variant:"control","data-cy":"reset",onClick:()=>{var O;u(!1),a(null),_!==null&&"current"in _&&((O=_.current)==null||O.focus())},children:g.jsx(E.Icon,{size:"md",style:{opacity:.7},children:g.jsx(ve.TimesIcon,{"aria-hidden":!0,style:{padding:0,margin:0}})})})]})}),y=b.useCallback((_,O)=>{const T=o.find(k=>k.key!==void 0?k.key===O:k.label===O);T&&(a(T.value),u(!1))},[a,o,u]),x=b.useRef(null);b.useEffect(()=>{c||d("")},[c,d]),b.useEffect(()=>{!e.disableAutoSelect&&e.isRequired&&!p&&o.length===1&&a(o[0].value)},[a,o,e.disableAutoSelect,e.isRequired,p]);const w=b.useMemo(()=>{let _=o;return e.setSearchValue||(_=_.filter(O=>f===""?!0:O.label.toLowerCase().includes(f.toLowerCase()))),e.disableSortOptions||(_=_.sort((O,T)=>{const k=O.label.toLowerCase(),P=T.label.toLowerCase();return k<P?-1:k>P?1:0})),_},[o,e.disableSortOptions,e.setSearchValue,f]),S=b.useMemo(()=>{if(o.some(O=>!!O.group)){const O={};for(const T of w){const k=T.group??"";O[k]||(O[k]=[]),O[k].push(T)}return O}},[o,w]);return g.jsx(WA.Provider,{value:{open:c,setOpen:u},children:g.jsxs(E.Select,{id:`${n}-select`,selected:p,onSelect:y,isOpen:c,onOpenChange:u,toggle:e.toggle??v,popperProps:{appendTo:()=>document.body},shouldFocusToggleOnSelect:!0,innerRef:h,children:[g.jsx(E.MenuSearch,{children:g.jsx(E.MenuSearchInput,{"data-cy":"search-input",children:g.jsx(E.SearchInput,{id:`${n}-search`,ref:x,value:f,onChange:(_,O)=>d(O),onClear:_=>{_.stopPropagation(),d("")},resultsCount:w.length!==o.length?`${w.length} / ${o.length}`:void 0,onKeyDown:_=>{var O;switch(_.key){case"ArrowDown":case"Tab":{_.preventDefault(),_.stopPropagation();const T=(O=h==null?void 0:h.current)==null?void 0:O.querySelector("li button:not(:disabled),li input:not(:disabled)");T&&T.focus();break}}}})})}),g.jsx(E.Divider,{}),w.length===0?g.jsx(g.Fragment,{children:e.isLoading?g.jsx(E.Bullseye,{style:{padding:16},children:g.jsx(E.Spinner,{size:"lg"})}):g.jsx(E.SelectOption,{isDisabled:!0,children:t("No results found")},"no result")}):g.jsx(E0e,{children:S?g.jsx(g.Fragment,{children:Object.keys(S).map(_=>g.jsx(E.SelectGroup,{label:_,children:g.jsx(BA,{searchRef:x,options:S[_]})},_))}):g.jsx(BA,{searchRef:x,options:w})}),e.footer&&g.jsx(E.MenuFooter,{children:e.footer})]})})}function BA(e){return g.jsx(E.SelectList,{onKeyDown:t=>{var n;switch(t.key){case"Tab":t.preventDefault(),t.stopPropagation(),(n=e.searchRef.current)==null||n.focus();break}},children:e.options.map(t=>{const n=pi(t);return g.jsx(E.SelectOption,{id:n,icon:t.icon,value:t.key!==void 0?t.key:t.label,description:t.description,"data-cy":n,children:t.label},t.key!==void 0?t.key:t.label)})})}const E0e=Pe(Cr)`
394
394
  max-height: 40vh;
395
395
  `,WA=b.createContext({open:!1,setOpen:()=>{}});function VA(e){const{t}=Be(),{queryOptions:n}=e,[r,i]=b.useState(!1),[a,o]=b.useState(!1),[s,l]=b.useState(),[c,u]=b.useState(0),[f,d]=b.useState(),[h,p]=b.useState(!1),m=b.useRef(),[v,y]=b.useState(""),x=b.useCallback(Yy(P=>y(P),200),[]),w=b.useRef(e.onSelect).current,S=b.useRef(null),_=b.useCallback(()=>{S.current&&S.current.abort();const P=new AbortController;return S.current=P,i(()=>(o(!1),l(void 0),d(M=>{if(M)return M}),n({next:m.current,signal:P.signal,search:v}).then(M=>{P.signal.aborted||(m.current=M.next,M.remaining||o(!0),d(A=>{let D=[...A??[],...M.options];const j=new Set;return D=D.filter($=>j.has($.value)?!1:(j.add($.value),!0)),D.sort(($,I)=>{const z=$.label.toLowerCase(),N=I.label.toLowerCase();return z<N?-1:z>N?1:0}),!v&&M.remaining===0&&D.length===1&&w(D[0].value),u(M.remaining+D.length),D}))}).catch(M=>{P.signal.aborted||l(M instanceof Error?M:new Error(t("Unknown error")))}).finally(()=>{P.signal.aborted||i(!1)}),!0)),()=>P.abort()},[w,n,v,t]),O=b.useCallback(P=>{P.preventDefault(),P.stopPropagation(),_()},[_]),T=b.useCallback(P=>{P.preventDefault(),P.stopPropagation(),u(0),d([]),p(!0),m.current=void 0,_()},[_]);b.useEffect(()=>{h&&(u(0),d([]),m.current=void 0,_())},[h,_]),b.useEffect(()=>{s&&p(!1)},[s]);const k=g.jsxs(E.Stack,{hasGutter:!0,children:[g.jsxs(E.Flex,{children:[g.jsx(E.FlexItem,{grow:{default:"grow"},children:g.jsxs(E.ActionList,{children:[!a&&g.jsx(E.ActionListItem,{children:g.jsx(E.Button,{id:"load-more",isLoading:r,onClick:O,isDisabled:r,children:t(r?"Loading...":"Load more")})}),e.onBrowse&&g.jsx(E.ActionListItem,{children:g.jsx(E.Button,{id:"browse",onClick:P=>{var M;P.preventDefault(),P.stopPropagation(),p(!1),(M=e.onBrowse)==null||M.call(e)},variant:"secondary",children:t("Browse")})})]})}),!a&&c!==0&&g.jsx(E.FlexItem,{children:t("Loaded {{count}} of {{total}}",{count:(f==null?void 0:f.length)??0,total:c})})]}),e.footer]});return g.jsx(Ii,{id:e.id,icon:e.icon,placeholder:e.placeholder,options:f??[],value:e.value,onSelect:e.onSelect,isDisabled:e.isDisabled,footer:k,open:h,setOpen:p,searchValue:v,setSearchValue:x,isLoading:r,queryLabel:e.queryLabel,disableAutoSelect:!0,isRequired:e.isRequired,toggle:s?P=>g.jsx(T0e,{ref:P,id:e.id,variant:"secondary",isDanger:!0,icon:g.jsx(ve.SyncAltIcon,{}),onClick:T,children:typeof e.queryErrorText=="function"?e.queryErrorText(s):e.queryErrorText??t("Error loading options")}):void 0})}const T0e=Pe(E.Button)`
396
396
  width: 100%;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "A framework for building applications using PatternFly.",
4
- "version": "2.4.1824",
4
+ "version": "2.4.1825",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",