@oliasoft-open-source/react-ui-library 4.12.0-beta-1 → 4.12.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/global.css +643 -643
  2. package/dist/index.js +340 -365
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-CK3d59Om.js → Color-KGDBMAHA-BODMLRvZ.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-C_QE44cn.js → DocsRenderer-PKQXORMH-DEi7ICVq.js} +1 -1
  6. package/dist/storybook/assets/{accordion.stories-C3VY77Jy.js → accordion.stories-C_Vx7GEC.js} +1 -1
  7. package/dist/storybook/assets/{afe.stories-C9XjJj62.js → afe.stories-OEYJqexC.js} +1 -1
  8. package/dist/storybook/assets/{buttons-and-links-FQEbqz9H.js → buttons-and-links-BHNS6Ebw.js} +1 -1
  9. package/dist/storybook/assets/{casing-loads.stories-B7JIoJVk.js → casing-loads.stories-BAdZ87Oc.js} +1 -1
  10. package/dist/storybook/assets/{cell.stories-xZiHEc0P.js → cell.stories-Bu5u9qEl.js} +1 -1
  11. package/dist/storybook/assets/{chunk-HLWAVYOI-EhWEisNT.js → chunk-HLWAVYOI-BbzmrmoZ.js} +1 -1
  12. package/dist/storybook/assets/{color-B3dajHjs.js → color-oeF0-Pph.js} +1 -1
  13. package/dist/storybook/assets/{footer.stories-BxzKeFAK.js → footer.stories-LUxEpSgD.js} +1 -1
  14. package/dist/storybook/assets/{form.stories-BNORsn6Z.js → form.stories-B7V77yuI.js} +1 -1
  15. package/dist/storybook/assets/{formation.stories-C5Hkb3iK.js → formation.stories-D7MX0dSY.js} +1 -1
  16. package/dist/storybook/assets/{iframe-DOUoMheZ.js → iframe-nuCPRPrd.js} +2 -2
  17. package/dist/storybook/assets/{index-AKsHS-dO.js → index-BFtO1KgR.js} +4 -4
  18. package/dist/storybook/assets/{index-KVAIZqzA.js → index-CN6H1a0D.js} +1 -1
  19. package/dist/storybook/assets/{input-group.stories-BCajsqAk.js → input-group.stories-BdQ1prY4.js} +1 -1
  20. package/dist/storybook/assets/{input-validation-BNoUk3q6.js → input-validation-Ccu8WMpy.js} +1 -1
  21. package/dist/storybook/assets/{inputs-Dql6Fq32.js → inputs-C4fsY4Ua.js} +1 -1
  22. package/dist/storybook/assets/{layout-forms-DuFo_rwV.js → layout-forms-DOgsanng.js} +1 -1
  23. package/dist/storybook/assets/{layout-general-C-UddRr1.js → layout-general-DtDx77FI.js} +1 -1
  24. package/dist/storybook/assets/menu.test-case.stories-W-jG-Jk8.js +3 -0
  25. package/dist/storybook/assets/{modal.stories-C2d-Em5V.js → modal.stories-DUXRRhK-.js} +1 -1
  26. package/dist/storybook/assets/{modal.test-case.stories-H8AYyvAl.js → modal.test-case.stories-Ci1WRYdo.js} +2 -2
  27. package/dist/storybook/assets/{number-input.test-case.stories-BBKpBWfA.js → number-input.test-case.stories-CHGSaGbj.js} +1 -1
  28. package/dist/storybook/assets/{padding-and-spacing-B9ObVTUS.js → padding-and-spacing-Mfm_1hn5.js} +1 -1
  29. package/dist/storybook/assets/{pagination-CR1nxnnq.js → pagination-CoyQUC4R.js} +1 -1
  30. package/dist/storybook/assets/{pagination.stories-qXmBYwYc.js → pagination.stories-qfpnU8DC.js} +1 -1
  31. package/dist/storybook/assets/{popover.stories-DZTfimDf.js → popover.stories-TwNkFkWa.js} +1 -1
  32. package/dist/storybook/assets/{preview-_21fnvwa.js → preview-BIv_KaBF.js} +2 -2
  33. package/dist/storybook/assets/{preview-dBqj-M8_.js → preview-DVjsIOwK.js} +1 -1
  34. package/dist/storybook/assets/{reservoirs.stories-r1Ip90kJ.js → reservoirs.stories-DE9FrS0f.js} +1 -1
  35. package/dist/storybook/assets/{rich-text-input.stories-DwaseXZv.js → rich-text-input.stories-BNwcnp92.js} +1 -1
  36. package/dist/storybook/assets/{row.stories-BrPMTnKK.js → row.stories-D3Bnp8i4.js} +1 -1
  37. package/dist/storybook/assets/select-BQzJMnK1.js +61 -0
  38. package/dist/storybook/assets/{select.stories-DjGSNDXK.js → select.stories-BRGk9iYK.js} +1 -1
  39. package/dist/storybook/assets/select.test-case.stories-BYMK9M8u.js +82 -0
  40. package/dist/storybook/assets/{table-iVsvoMpy.js → table-DPbEkZqw.js} +1 -1
  41. package/dist/storybook/assets/{table.stories-DmGMjcFw.js → table.stories-BBzqpsyH.js} +1 -1
  42. package/dist/storybook/assets/{title.stories-D2LDNgbT.js → title.stories-B4PYbA22.js} +1 -1
  43. package/dist/storybook/assets/toaster.test-case.stories-Cy3_Gvs_.js +6 -0
  44. package/dist/storybook/assets/{unit-input.test-case.stories-BwKiucyc.js → unit-input.test-case.stories-BeFM9DuK.js} +1 -1
  45. package/dist/storybook/assets/{unit-table.stories-B7rN0MF0.js → unit-table.stories-9x5S71wv.js} +1 -1
  46. package/dist/storybook/assets/{unit-table.test-case.stories-BIMbgiTz.js → unit-table.test-case.stories-DZJ-hZ72.js} +1 -1
  47. package/dist/storybook/iframe.html +1 -1
  48. package/dist/storybook/project.json +1 -1
  49. package/package.json +1 -1
  50. package/dist/storybook/assets/menu.test-case.stories-BFYhvtSH.js +0 -3
  51. package/dist/storybook/assets/select-Cwks-WA0.js +0 -61
  52. package/dist/storybook/assets/select.test-case.stories-B6On-PjA.js +0 -82
  53. package/dist/storybook/assets/toaster.test-case.stories-BhWnh4Cd.js +0 -6
@@ -0,0 +1,61 @@
1
+ import{j as o}from"./jsx-runtime-eps93zm2.js";import{l as ae}from"./lodash-c4VUpsOs.js";import{r as M}from"./index-DhsZuJvc.js";import{c as G}from"./index-Bk2sglWO.js";import{G as ie,I as Ee}from"./common-types-Sih75Sav.js";import{D as me}from"./disabled-context-rmpd7YJS.js";import{i as ne}from"./types-Dx2TtIG9.js";import{T as pe,u as Pe,m as We}from"./tooltip-1V7clEnw.js";import{A as P,E as B,K as ze}from"./enum-Bnn40S8Q.js";import{a as Ge,_ as $e}from"./inheritsLoose-DP0QEDDI.js";import{_ as ge}from"./assertThisInitialized-B9jnkVVz.js";import{m as le}from"./memoize-one.esm-CcMeOnPo.js";import{M as se}from"./types-BmbYqTX_.js";import{T as ue}from"./text-B3-TSWok.js";import{A as Ue}from"./actions-Bax0KeqM.js";import{I as ce}from"./icon-BSFY3vDO.js";import{s as Ve}from"./select.input-CJed_LLR.js";const Ye="_inputInTable_sl2b5_1",Ke="_inputHover_sl2b5_13",Be="_inputFocus_sl2b5_18",Ze="_inputError_sl2b5_25",Xe="_inputWarning_sl2b5_26",Je="_inputDisabled_sl2b5_61",Qe="_hideScrollbars_sl2b5_67",en="_select_sl2b5_77",nn="_isInTable_sl2b5_121",tn="_unSelected_sl2b5_133",rn="_small_sl2b5_174",an="_right_sl2b5_182",sn="_groupOrderFirst_sl2b5_193",ln="_groupOrderMiddle_sl2b5_194",on="_groupOrderLast_sl2b5_198",U={inputInTable:Ye,inputHover:Ke,inputFocus:Be,inputError:Ze,inputWarning:Xe,inputDisabled:Je,hideScrollbars:Qe,select:en,isInTable:nn,unSelected:tn,small:rn,right:an,groupOrderFirst:sn,groupOrderMiddle:ln,groupOrderLast:on},we=({disabled:e=!1,error:n=null,warning:r=null,tooltip:a=null,options:l,onChange:g=ae.noop,onFocus:T=ae.noop,onBlur:u=ae.noop,right:c=!1,small:d=!1,tabIndex:S=0,selectedOption:m,width:b=null,groupOrder:E=null,testId:v,isInTable:t=!1,clearable:i,placeholder:s,hasNonExistentValue:p,maxTooltipWidth:y,borderRadius:I})=>{const f=M.useContext(me),h=m===null||(m==null?void 0:m.value)===null?"unselected":m==null?void 0:m.value,w=h==="unselected",N=(h==="unselected"||i?[o.jsx("option",{value:"unselected",disabled:!i,hidden:!i,children:s||"Select..."},"unselected")]:[]).concat(p?[o.jsx("option",{value:m==null?void 0:m.value,disabled:e||f,children:m==null?void 0:m.label},"selectedNonExistentValue")]:[]).concat(l.map((L,R)=>o.jsx("option",{value:L.value,"data-testid":L.testId,children:L.label},R))),q=(()=>{if(E)switch(E){case ie.FIRST:return U.groupOrderFirst;case ie.LAST:return U.groupOrderLast;default:return U.groupOrderMiddle}return""})();return o.jsx(pe,{error:!!n,warning:!!r,text:a||n||r,enabled:a&&ne(a)||n&&ne(n)||r&&ne(r)||!1,maxWidth:y,placement:"bottom-center",children:o.jsx("select",{className:G(U.select,w?U.unSelected:"",c?U.right:"",d?U.small:"",t?U.isInTable:"",q),style:{width:b||"",borderRadius:I||""},onChange:L=>{const{value:R}=L.target;let x;R==="unselected"?x={value:null}:x=l.find(F=>String(F.value)===String(R))||{value:null},g(L,x)},onFocus:T,onBlur:u,tabIndex:S,value:h,disabled:e||f,"data-error":n||null,"data-warning":r||null,"data-testid":v,children:N})})};we.__docgenInfo={description:"",methods:[],displayName:"NativeSelect",props:{borderRadius:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},options:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
2
+ evt: ChangeEvent<HTMLSelectElement>,
3
+ value: ISelectSelectedOption | { value: null },
4
+ ) => void`,signature:{arguments:[{type:{name:"ChangeEvent",elements:[{name:"HTMLSelectElement"}],raw:"ChangeEvent<HTMLSelectElement>"},name:"evt"},{type:{name:"union",raw:"ISelectSelectedOption | { value: null }",elements:[{name:"ISelectSelectedOption"},{name:"signature",type:"object",raw:"{ value: null }",signature:{properties:[{key:"value",value:{name:"null",required:!0}}]}}]},name:"value"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},right:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},tabIndex:{required:!1,tsType:{name:"number"},description:"",defaultValue:{value:"0",computed:!1}},selectedOption:{required:!1,tsType:{name:"ISelectSelectedOption"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},groupOrder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},testId:{required:!1,tsType:{name:"union",raw:"string | undefined",elements:[{name:"string"},{name:"undefined"}]},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},clearable:{required:!1,tsType:{name:"boolean"},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},hasNonExistentValue:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const Oe=()=>{const e=M.useRef(null);return[e,()=>{e.current&&e.current.focus()}]};var un=typeof performance=="object"&&typeof performance.now=="function",ve=un?function(){return performance.now()}:function(){return Date.now()};function ye(e){cancelAnimationFrame(e.id)}function cn(e,n){var r=ve();function a(){ve()-r>=n?e.call(null):l.id=requestAnimationFrame(a)}var l={id:requestAnimationFrame(a)};return l}var oe=-1;function he(e){if(e===void 0&&(e=!1),oe===-1||e){var n=document.createElement("div"),r=n.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(n),oe=n.offsetWidth-n.clientWidth,document.body.removeChild(n)}return oe}var ee=null;function Te(e){if(e===void 0&&(e=!1),ee===null||e){var n=document.createElement("div"),r=n.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";var a=document.createElement("div"),l=a.style;return l.width="100px",l.height="100px",n.appendChild(a),document.body.appendChild(n),n.scrollLeft>0?ee="positive-descending":(n.scrollLeft=1,n.scrollLeft===0?ee="negative":ee="positive-ascending"),document.body.removeChild(n),ee}return ee}var dn=150,mn=function(n,r){return n};function pn(e){var n,r=e.getItemOffset,a=e.getEstimatedTotalSize,l=e.getItemSize,g=e.getOffsetForIndexAndAlignment,T=e.getStartIndexForOffset,u=e.getStopIndexForStartIndex,c=e.initInstanceProps,d=e.shouldResetStyleCacheOnItemSizeChange,S=e.validateProps;return n=function(m){Ge(b,m);function b(v){var t;return t=m.call(this,v)||this,t._instanceProps=c(t.props,ge(t)),t._outerRef=void 0,t._resetIsScrollingTimeoutId=null,t.state={instance:ge(t),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof t.props.initialScrollOffset=="number"?t.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},t._callOnItemsRendered=void 0,t._callOnItemsRendered=le(function(i,s,p,y){return t.props.onItemsRendered({overscanStartIndex:i,overscanStopIndex:s,visibleStartIndex:p,visibleStopIndex:y})}),t._callOnScroll=void 0,t._callOnScroll=le(function(i,s,p){return t.props.onScroll({scrollDirection:i,scrollOffset:s,scrollUpdateWasRequested:p})}),t._getItemStyle=void 0,t._getItemStyle=function(i){var s=t.props,p=s.direction,y=s.itemSize,I=s.layout,f=t._getItemStyleCache(d&&y,d&&I,d&&p),h;if(f.hasOwnProperty(i))h=f[i];else{var w=r(t.props,i,t._instanceProps),N=l(t.props,i,t._instanceProps),q=p==="horizontal"||I==="horizontal",L=p==="rtl",R=q?w:0;f[i]=h={position:"absolute",left:L?void 0:R,right:L?R:void 0,top:q?0:w,height:q?"100%":N,width:q?N:"100%"}}return h},t._getItemStyleCache=void 0,t._getItemStyleCache=le(function(i,s,p){return{}}),t._onScrollHorizontal=function(i){var s=i.currentTarget,p=s.clientWidth,y=s.scrollLeft,I=s.scrollWidth;t.setState(function(f){if(f.scrollOffset===y)return null;var h=t.props.direction,w=y;if(h==="rtl")switch(Te()){case"negative":w=-y;break;case"positive-descending":w=I-p-y;break}return w=Math.max(0,Math.min(w,I-p)),{isScrolling:!0,scrollDirection:f.scrollOffset<w?"forward":"backward",scrollOffset:w,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._onScrollVertical=function(i){var s=i.currentTarget,p=s.clientHeight,y=s.scrollHeight,I=s.scrollTop;t.setState(function(f){if(f.scrollOffset===I)return null;var h=Math.max(0,Math.min(I,y-p));return{isScrolling:!0,scrollDirection:f.scrollOffset<h?"forward":"backward",scrollOffset:h,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._outerRefSetter=function(i){var s=t.props.outerRef;t._outerRef=i,typeof s=="function"?s(i):s!=null&&typeof s=="object"&&s.hasOwnProperty("current")&&(s.current=i)},t._resetIsScrollingDebounced=function(){t._resetIsScrollingTimeoutId!==null&&ye(t._resetIsScrollingTimeoutId),t._resetIsScrollingTimeoutId=cn(t._resetIsScrolling,dn)},t._resetIsScrolling=function(){t._resetIsScrollingTimeoutId=null,t.setState({isScrolling:!1},function(){t._getItemStyleCache(-1,null)})},t}b.getDerivedStateFromProps=function(t,i){return fn(t,i),S(t),null};var E=b.prototype;return E.scrollTo=function(t){t=Math.max(0,t),this.setState(function(i){return i.scrollOffset===t?null:{scrollDirection:i.scrollOffset<t?"forward":"backward",scrollOffset:t,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},E.scrollToItem=function(t,i){i===void 0&&(i="auto");var s=this.props,p=s.itemCount,y=s.layout,I=this.state.scrollOffset;t=Math.max(0,Math.min(t,p-1));var f=0;if(this._outerRef){var h=this._outerRef;y==="vertical"?f=h.scrollWidth>h.clientWidth?he():0:f=h.scrollHeight>h.clientHeight?he():0}this.scrollTo(g(this.props,t,i,I,this._instanceProps,f))},E.componentDidMount=function(){var t=this.props,i=t.direction,s=t.initialScrollOffset,p=t.layout;if(typeof s=="number"&&this._outerRef!=null){var y=this._outerRef;i==="horizontal"||p==="horizontal"?y.scrollLeft=s:y.scrollTop=s}this._callPropsCallbacks()},E.componentDidUpdate=function(){var t=this.props,i=t.direction,s=t.layout,p=this.state,y=p.scrollOffset,I=p.scrollUpdateWasRequested;if(I&&this._outerRef!=null){var f=this._outerRef;if(i==="horizontal"||s==="horizontal")if(i==="rtl")switch(Te()){case"negative":f.scrollLeft=-y;break;case"positive-ascending":f.scrollLeft=y;break;default:var h=f.clientWidth,w=f.scrollWidth;f.scrollLeft=w-h-y;break}else f.scrollLeft=y;else f.scrollTop=y}this._callPropsCallbacks()},E.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&ye(this._resetIsScrollingTimeoutId)},E.render=function(){var t=this.props,i=t.children,s=t.className,p=t.direction,y=t.height,I=t.innerRef,f=t.innerElementType,h=t.innerTagName,w=t.itemCount,N=t.itemData,q=t.itemKey,L=q===void 0?mn:q,R=t.layout,x=t.outerElementType,A=t.outerTagName,F=t.style,z=t.useIsScrolling,V=t.width,$=this.state.isScrolling,j=p==="horizontal"||R==="horizontal",D=j?this._onScrollHorizontal:this._onScrollVertical,Z=this._getRangeToRender(),te=Z[0],re=Z[1],X=[];if(w>0)for(var k=te;k<=re;k++)X.push(M.createElement(i,{data:N,key:L(k,N),index:k,isScrolling:z?$:void 0,style:this._getItemStyle(k)}));var J=a(this.props,this._instanceProps);return M.createElement(x||A||"div",{className:s,onScroll:D,ref:this._outerRefSetter,style:$e({position:"relative",height:y,width:V,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:p},F)},M.createElement(f||h||"div",{children:X,ref:I,style:{height:j?"100%":J,pointerEvents:$?"none":void 0,width:j?J:"100%"}}))},E._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var t=this.props.itemCount;if(t>0){var i=this._getRangeToRender(),s=i[0],p=i[1],y=i[2],I=i[3];this._callOnItemsRendered(s,p,y,I)}}if(typeof this.props.onScroll=="function"){var f=this.state,h=f.scrollDirection,w=f.scrollOffset,N=f.scrollUpdateWasRequested;this._callOnScroll(h,w,N)}},E._getRangeToRender=function(){var t=this.props,i=t.itemCount,s=t.overscanCount,p=this.state,y=p.isScrolling,I=p.scrollDirection,f=p.scrollOffset;if(i===0)return[0,0,0,0];var h=T(this.props,f,this._instanceProps),w=u(this.props,h,f,this._instanceProps),N=!y||I==="backward"?Math.max(1,s):1,q=!y||I==="forward"?Math.max(1,s):1;return[Math.max(0,h-N),Math.max(0,Math.min(i-1,w+q)),h,w]},b}(M.PureComponent),n.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},n}var fn=function(n,r){n.children,n.direction,n.height,n.layout,n.innerTagName,n.outerTagName,n.width,r.instance},gn=pn({getItemOffset:function(n,r){var a=n.itemSize;return r*a},getItemSize:function(n,r){var a=n.itemSize;return a},getEstimatedTotalSize:function(n){var r=n.itemCount,a=n.itemSize;return a*r},getOffsetForIndexAndAlignment:function(n,r,a,l,g,T){var u=n.direction,c=n.height,d=n.itemCount,S=n.itemSize,m=n.layout,b=n.width,E=u==="horizontal"||m==="horizontal",v=E?b:c,t=Math.max(0,d*S-v),i=Math.min(t,r*S),s=Math.max(0,r*S-v+S+T);switch(a==="smart"&&(l>=s-v&&l<=i+v?a="auto":a="center"),a){case"start":return i;case"end":return s;case"center":{var p=Math.round(s+(i-s)/2);return p<Math.ceil(v/2)?0:p>t+Math.floor(v/2)?t:p}case"auto":default:return l>=s&&l<=i?l:l<s?s:i}},getStartIndexForOffset:function(n,r){var a=n.itemCount,l=n.itemSize;return Math.max(0,Math.min(a-1,Math.floor(r/l)))},getStopIndexForStartIndex:function(n,r,a){var l=n.direction,g=n.height,T=n.itemCount,u=n.itemSize,c=n.layout,d=n.width,S=l==="horizontal"||c==="horizontal",m=r*u,b=S?d:g,E=Math.ceil((b+a-m)/u);return Math.max(0,Math.min(T-1,r+E-1))},initInstanceProps:function(n){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(n){n.itemSize}});const vn="_layerContainer_1lbvo_1",yn="_layer_1lbvo_1",hn="_small_1lbvo_23",Tn="_heading_1lbvo_26",Sn="_option_1lbvo_27",bn="_message_1lbvo_28",_n="_focused_1lbvo_64",In="_selected_1lbvo_68",En="_disabled_1lbvo_71",wn="_check_1lbvo_75",On="_optionContent_1lbvo_92",Ln="_label_1lbvo_97",Rn="_icon_1lbvo_104",qn="_details_1lbvo_109",H={layerContainer:vn,layer:yn,small:hn,heading:Tn,option:Sn,message:bn,focused:_n,selected:In,disabled:En,check:wn,optionContent:On,label:Ln,icon:Rn,details:qn},Le=({label:e})=>o.jsx("div",{onClick:n=>n.stopPropagation(),className:H.heading,children:e});Le.__docgenInfo={description:"",methods:[],displayName:"Heading",props:{label:{required:!0,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const Re=({details:e,label:n,icon:r,disabled:a=!1,selected:l=!1,focused:g=!1,onSelectOption:T,actions:u,closeLayer:c,testId:d})=>o.jsxs("div",{className:G(H.option,a?H.disabled:"",l?H.selected:"",g?H.focused:""),onClick:!a&&T?T:void 0,"data-testid":d,children:[o.jsx("div",{className:H.optionContent,children:o.jsxs("span",{className:H.label,title:n,children:[n,r&&o.jsx("span",{className:H.icon,children:r})]})}),e&&o.jsx("div",{className:G(H.details),children:o.jsx(ue,{faint:!0,children:e})}),!!(u!=null&&u.length)&&o.jsx("div",{className:G(H.actions),children:o.jsx(Ue,{actions:u,closeLayer:c})}),o.jsx("span",{className:H.check,children:l?o.jsx(ce,{icon:Ee.CHECK}):null})]});Re.__docgenInfo={description:"",methods:[],displayName:"Option",props:{details:{required:!1,tsType:{name:"string"},description:""},label:{required:!0,tsType:{name:"string"},description:""},icon:{required:!1,tsType:{name:"ReactNode"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},selected:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},focused:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},onSelectOption:{required:!1,tsType:{name:"signature",type:"function",raw:`(
5
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
6
+ section?: ISelectSectionProps,
7
+ ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"signature",type:"object",raw:`{
8
+ section: ISelectSection;
9
+ selected?: boolean;
10
+ focused?: boolean;
11
+ onSelectOption?: (
12
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
13
+ section?: ISelectSectionProps,
14
+ ) => void;
15
+ closeLayer?: TEmpty;
16
+ }`,signature:{properties:[{key:"section",value:{name:"ISelectSection",required:!0}},{key:"selected",value:{name:"boolean",required:!1}},{key:"focused",value:{name:"boolean",required:!1}},{key:"onSelectOption",value:{name:"signature",type:"function",raw:`(
17
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
18
+ section?: ISelectSectionProps,
19
+ ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSectionProps"},name:"section"}],return:{name:"void"}},required:!1}},{key:"closeLayer",value:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}},required:!1}}]}},name:"section"}],return:{name:"void"}}},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"any"}],raw:"any[]"},description:""},closeLayer:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const qe=({section:e,selected:n,focused:r,onSelectOption:a,closeLayer:l})=>{const g=M.useContext(me);switch(e.type){case se.HEADING:return o.jsx(Le,{label:e.label});case se.OPTION:default:return o.jsx(Re,{closeLayer:l,actions:e.actions,label:e.label,details:e.details,icon:e.icon,disabled:e.disabled||g,selected:n,focused:r,onSelectOption:a,testId:e.testId})}};qe.__docgenInfo={description:"",methods:[],displayName:"Section",props:{section:{required:!0,tsType:{name:"ISelectSection"},description:""},selected:{required:!1,tsType:{name:"boolean"},description:""},focused:{required:!1,tsType:{name:"boolean"},description:""},onSelectOption:{required:!1,tsType:{name:"signature",type:"function",raw:`(
20
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
21
+ section?: ISelectSectionProps,
22
+ ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"signature",type:"object",raw:`{
23
+ section: ISelectSection;
24
+ selected?: boolean;
25
+ focused?: boolean;
26
+ onSelectOption?: (
27
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
28
+ section?: ISelectSectionProps,
29
+ ) => void;
30
+ closeLayer?: TEmpty;
31
+ }`,signature:{properties:[{key:"section",value:{name:"ISelectSection",required:!0}},{key:"selected",value:{name:"boolean",required:!1}},{key:"focused",value:{name:"boolean",required:!1}},{key:"onSelectOption",value:{name:"signature",type:"function",raw:`(
32
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
33
+ section?: ISelectSectionProps,
34
+ ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSectionProps"},name:"section"}],return:{name:"void"}},required:!1}},{key:"closeLayer",value:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}},required:!1}}]}},name:"section"}],return:{name:"void"}}},description:""},closeLayer:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""}}};const de=(e,n)=>{const a=document.createElement("canvas").getContext("2d");return a?(a.font=n,a.measureText(e).width):0},xe="13px",Ce="12px",xn="Roobert",Cn="sans-serif",Mn=12,Nn=8,An=30,Fn=24,Hn=5,jn=3,Dn=1,kn=2,Se=10,Me=(e=!1,n=!1)=>`${e?Ce:xe} ${n?xn:Cn}`,Pn=(e=!1,n=!1)=>(e?Nn:Mn)+(e?Fn:An)+(n?17:0),be=(e,n,r,a)=>{const l=Me(n,r),g=a?de(a,l):0,T=Math.ceil(e.reduce((c,d)=>{var v;const S=(((v=d==null?void 0:d.actions)==null?void 0:v.length)??0)*24,m=d.icon?parseInt(n?Ce:xe)+7:0,b=`${d.label} ${d.details||""}`,E=de(b,l)+S+m;return c=E>c?E:c,c},g)),u=Pn(n,!0);return T+u},Wn=(e,n,r)=>{const a=Me(!0,r),l=de(e.label,a),g=(n?jn:Hn)*2+Dn*2+kn;return Math.ceil(l+g)},Ne=({listRef:e,isMulti:n,sections:r,selectedOptions:a,onSelectOption:l,focusedOptionIndex:g,width:T,small:u,firstSelectedOptionIndex:c,closeLayer:d,testId:S})=>{M.useEffect(()=>{c&&c!==null&&e.current!==null&&e.current.scrollToItem(c,"start")},[c,e]);const m=u?24:30;return o.jsx("div",{"data-testid":S,className:G(H.layer,u&&H.small),children:r.length?o.jsx(gn,{ref:e,height:r.length<Se?m*r.length:m*Se,itemCount:r.length,itemSize:m,width:T,children:({index:b,style:E})=>{var v;return o.jsx("div",{style:E,children:o.jsx(qe,{closeLayer:d,section:r[b],selected:n&&r[b].type!==se.HEADING&&Array.isArray(a)?a.some(t=>{var i;return t&&(t==null?void 0:t.value)===((i=r==null?void 0:r[b])==null?void 0:i.value)}):!Array.isArray(a)&&((v=r==null?void 0:r[b])==null?void 0:v.value)===(a==null?void 0:a.value),focused:g===b,onSelectOption:t=>l(t,r[b])})})}}):o.jsx("ul",{children:o.jsx("li",{children:o.jsx("div",{className:H.message,style:{width:T},children:"No matches"})})})})};Ne.__docgenInfo={description:"",methods:[],displayName:"Layer",props:{listRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"any"}],raw:"RefObject<any>"},description:""},isMulti:{required:!1,tsType:{name:"boolean"},description:""},sections:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSection"}],raw:"ISelectSection[]"},description:""},selectedOptions:{required:!0,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},onSelectOption:{required:!0,tsType:{name:"signature",type:"function",raw:`(
35
+ event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
36
+ section?: ISelectSection,
37
+ ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSection"},name:"section"}],return:{name:"void"}}},description:""},focusedOptionIndex:{required:!1,tsType:{name:"number"},description:""},width:{required:!0,tsType:{name:"number"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},firstSelectedOptionIndex:{required:!1,tsType:{name:"number"},description:""},closeLayer:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const zn="_inputInTable_7uwhv_1",Gn="_inputHover_7uwhv_13",$n="_inputFocus_7uwhv_18",Un="_inputError_7uwhv_25",Vn="_inputWarning_7uwhv_26",Yn="_inputDisabled_7uwhv_61",Kn="_hideScrollbars_7uwhv_67",Bn="_trigger_7uwhv_77",Zn="_isInTable_7uwhv_93",Xn="_input_7uwhv_1",Jn="_isOpen_7uwhv_114",Qn="_disabled_7uwhv_156",et="_icons_7uwhv_162",nt="_clearAll_7uwhv_169",tt="_iconOpen_7uwhv_170",rt="_small_7uwhv_181",at="_triggerInputContainer_7uwhv_189",it="_right_7uwhv_198",st="_multiOptions_7uwhv_211",lt="_multiOption_7uwhv_211",ot="_label_7uwhv_239",ut="_closeMultiOption_7uwhv_242",ct="_focus_7uwhv_253",dt="_selectedSingleValue_7uwhv_257",mt="_placeHolder_7uwhv_258",pt="_groupOrderFirst_7uwhv_297",ft="_groupOrderMiddle_7uwhv_298",gt="_groupOrderLast_7uwhv_302",vt="_detailedLabel_7uwhv_307",C={inputInTable:zn,inputHover:Gn,inputFocus:$n,inputError:Un,inputWarning:Vn,inputDisabled:Yn,hideScrollbars:Kn,trigger:Bn,isInTable:Zn,input:Xn,isOpen:Jn,disabled:Qn,icons:et,clearAll:nt,iconOpen:tt,small:rt,triggerInputContainer:at,right:it,multiOptions:st,multiOption:lt,label:ot,closeMultiOption:ut,focus:ct,selectedSingleValue:dt,placeHolder:mt,groupOrderFirst:pt,groupOrderMiddle:ft,groupOrderLast:gt,detailedLabel:vt},Ae=({selectedOptions:e,small:n,width:r,testId:a})=>{const[g,T]=M.useState([]),[u,c]=M.useState([]);return M.useEffect(()=>{let d=[],S=[],m=0;e.forEach((b,E)=>{m+=Wn(b,n,!0),E===e.length-1&&m<r||m<r-24?d.push(b):S.push(b)}),T(d),c(S)},[e,!0,r]),o.jsxs("div",{className:C.multiOptions,"data-testid":a&&`${a}-value`,children:[g.filter(d=>d&&d.label).map((d,S)=>o.jsx("span",{className:C.multiOption,onClick:m=>{m.stopPropagation()},children:d.label},S)),u.length>0&&o.jsx(pe,{text:u.map((d,S)=>o.jsx("div",{children:d.label},S)),display:"inline-flex",children:o.jsx("span",{className:C.multiOption,children:g.length?`+${u.length}`:`${u.length} items`})})]})};Ae.__docgenInfo={description:"",methods:[],displayName:"MultiSelectedOptions",props:{selectedOptions:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!0,tsType:{name:"number"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Fe=({selectedOptions:e,searchable:n=!1,searchValue:r,onChange:a=ae.noop,inputRef:l,error:g,placeholder:T="Select...",small:u,testId:c})=>{const d=M.useRef(null),S=Array.isArray(e),m=S?e.length>0:!!e,b=r?r.length+1:1,E=()=>{var i,s;const v=((i=d.current)==null?void 0:i.offsetWidth)||0,t=((s=l.current)==null?void 0:s.offsetWidth)||0;return v-t};return o.jsxs("div",{className:C.triggerInputContainer,ref:d,children:[m?S?o.jsx(Ae,{selectedOptions:e,small:u,width:E(),testId:c}):o.jsx("span",{className:C.selectedSingleValue,"data-testid":c&&`${c}-value`,children:r!=null&&r.length?"":e==null?void 0:e.label}):o.jsx("span",{className:C.placeHolder,children:r!=null&&r.length?"":T}),n?o.jsx("input",{tabIndex:-1,ref:l,size:b,className:C.input,value:r,onChange:v=>a(v.target.value),"data-error":g||null,"data-testid":c&&`${c}-input`}):null]})};Fe.__docgenInfo={description:"",methods:[],displayName:"Input",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},searchValue:{required:!1,tsType:{name:"string"},description:""},inputRef:{required:!0,tsType:{name:"MutableRefObject",elements:[{name:"union",raw:"HTMLInputElement | null",elements:[{name:"HTMLInputElement"},{name:"null"}]}],raw:"MutableRefObject<HTMLInputElement | null>"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:"",defaultValue:{value:"'Select...'",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const He=({selectedOptions:e,searchValue:n,searchable:r,clearable:a,onClickTrigger:l,element:g,error:T,warning:u,tooltip:c,small:d,isInTable:S,disabled:m,onChangeSearch:b,onClickDeselect:E,onClickClear:v,tabIndex:t,isOpen:i,triggerRef:s,clearAllIsFocused:p,focusedSelectedOptionIndex:y,onFocus:I,onBlur:f,groupOrder:h,maxTooltipWidth:w,placeholder:N,right:q,testId:L})=>{var j;const[R,x]=Oe(),A=Array.isArray(e)?e.length>0&&((j=e[0])==null?void 0:j.value):e==null?void 0:e.value,F=a&&A,z=(()=>{if(h)switch(h){case ie.FIRST:return C.groupOrderFirst;case ie.LAST:return C.groupOrderLast;default:return C.groupOrderMiddle}return""})(),V=!Array.isArray(e)&&(e!=null&&e.details)?{...e,label:o.jsxs("div",{className:G(C.detailedLabel),children:[o.jsx(ue,{children:e.label}),o.jsx(ue,{muted:!0,children:e.details})]})}:e,$=o.jsxs(o.Fragment,{children:[g,o.jsxs("div",{ref:s,tabIndex:t,className:G(C.trigger,i?C.isOpen:"",m?C.disabled:"",d?C.small:"",S?C.isInTable:"",q?C.right:"",z),onClick:D=>{D.stopPropagation(),typeof x=="function"&&x(),l(D)},onFocus:I,onBlur:f,"data-error":T||null,"data-warning":u||null,"data-testid":L,children:[o.jsx(Fe,{selectedOptions:V,placeholder:N,searchable:r,searchValue:n,inputRef:R,onChange:b,error:T,small:d,testId:L}),o.jsx("span",{className:C.icons,children:F?o.jsx("span",{className:G(C.clearAll,p?C.focus:""),onClick:D=>{D.stopPropagation(),v&&v(D)},"data-testid":L&&`${L}-clear`,children:o.jsx(ce,{icon:Ee.CLOSE})}):o.jsx("span",{className:G(C.iconOpen),children:o.jsx(ce,{icon:"chevron down"})})})]})]});return o.jsx(o.Fragment,{children:o.jsx(pe,{error:!!T,warning:!!u,text:c||T||u,enabled:c&&ne(c)||T&&ne(T)||u&&ne(u)||!1,maxWidth:w,placement:"bottom-center",children:$})})};He.__docgenInfo={description:"",methods:[],displayName:"Trigger",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchValue:{required:!1,tsType:{name:"string"},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},onClickTrigger:{required:!0,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},element:{required:!1,tsType:{name:"ReactNode"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},onChangeSearch:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onClickDeselect:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},onClickClear:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLSpanElement, MouseEvent>",elements:[{name:"HTMLSpanElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},isOpen:{required:!1,tsType:{name:"boolean"},description:""},triggerRef:{required:!1,tsType:{name:"RefObject",elements:[{name:"HTMLDivElement"}],raw:"RefObject<HTMLDivElement>"},description:""},clearAllIsFocused:{required:!1,tsType:{name:"boolean"},description:""},focusedSelectedOptionIndex:{required:!1,tsType:{name:"number"},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},groupOrder:{required:!1,tsType:{name:"union",raw:"TGroupOrder | string",elements:[{name:"union",raw:"'first' | 'middle' | 'last'",elements:[{name:"literal",value:"'first'"},{name:"literal",value:"'middle'"},{name:"literal",value:"'last'"}]},{name:"string"}]},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var W=(e=>(e.SET_VISIBLE_OPTIONS="SET_VISIBLE_OPTIONS",e.RESET_LAYER_FOCUS="RESET_LAYER_FOCUS",e.CLEAR_SEARCH="CLEAR_SEARCH",e.ON_CHANGE_SEARCH="ON_CHANGE_SEARCH",e.FOCUS_TRIGGER_INPUTS="FOCUS_TRIGGER_INPUTS",e.BLUR_TRIGGER_INPUTS="BLUR_TRIGGER_INPUTS",e.FOCUS_LAYER_OPTIONS="FOCUS_LAYER_OPTIONS",e.OPEN_LAYER="OPEN_LAYER",e.CLOSE_LAYER="CLOSE_LAYER",e))(W||{});const je={options:["none","clearAll"],currentIndex:0,currentOption:!1,clearAll:!1},yt=e=>e!==null?e+1:0,De=(e,n)=>{const r=["none",...e.map((l,g)=>l.type!==se.HEADING?g:null).filter(l=>l!==null)],a=yt(n);return{options:r,currentIndex:a,current:r[a]}},ht=(e,n)=>{const r=e==="up"?-1:1,a=n.currentIndex+r,l=(a<0?n.options.length-1:a)%n.options.length,g=n.options[l];return{...n,currentIndex:l,current:g}},Tt=(e,n,r)=>{const a=e==="left"?-1:1,l=n&&n.length?["none",...Array.from({length:n.length},(d,S)=>S),"clearAll"]:["none","clearAll"],g=r.currentIndex+a,T=(g<0?l.length-1:g)%l.length,u=l[T];return{options:l,currentIndex:T,currentOption:u,clearAll:u==="clearAll"}},_e=()=>je,Ie=e=>({...e,currentIndex:0,current:"none"}),St=(e,n)=>{switch(n.type){case W.SET_VISIBLE_OPTIONS:return{...e,visibleOptions:n.options||[]};case W.RESET_LAYER_FOCUS:return{...e,layerFocus:De(n.options||[],n.firstSelectedOptionIndex||0)};case W.CLEAR_SEARCH:return{...e,visibleOptions:n.options||[],searchValue:""};case W.ON_CHANGE_SEARCH:{let a=[...(n.options||[]).filter(l=>(String(l.label)+(l.details?String(l.details):"")).toLowerCase().includes(String(n.value||"").toLowerCase()))];return n.createAble&&n.value&&n.value!==""&&a.push({label:`Create "${n.value}"`,value:n.value,createAble:!0}),{...e,searchValue:n.value,visibleOptions:a,layerFocus:Ie(e.layerFocus)}}case W.FOCUS_TRIGGER_INPUTS:return{...e,triggerFocus:Tt(n.direction||"right",n.selectedOptions||[],e.triggerFocus),layerFocus:Ie(e.layerFocus)};case W.BLUR_TRIGGER_INPUTS:return{...e,triggerFocus:_e()};case W.FOCUS_LAYER_OPTIONS:return n.nextLayerFocus?{...e,layerFocus:n.nextLayerFocus,triggerFocus:_e()}:e;case W.OPEN_LAYER:return{...e,isLayerOpen:!0};case W.CLOSE_LAYER:return{...e,isLayerOpen:!1};default:return e}},bt={auto:!0,possiblePlacements:["bottom-start","top-start"],placement:"bottom-start",preferX:"right",preferY:"bottom"},_t=({state:e,dispatch:n,options:r,setTriggerFocus:a,disabled:l,disabledContext:g,onCreate:T,onChange:u,selectedOptions:c,width:d,small:S,isFontLoaded:m,placeholder:b,firstSelectedOptionIndex:E,createAble:v,listRef:t,autoLayerWidth:i})=>{const s=()=>{e.isLayerOpen&&n({type:P.CLOSE_LAYER}),a()},p=()=>n({type:P.OPEN_LAYER}),y=M.useRef(!0);M.useEffect(()=>{y.current?y.current=!1:n({type:P.SET_VISIBLE_OPTIONS,options:r})},[r]);const I=(_,O,Q)=>{if(!(l||g)){if(Q&&Q(),O){if(O.createAble&&T)T(O.value);else if(!O.disabled)if(Array.isArray(c))if(c.some(K=>K.label===O.label)){const K=c.filter(fe=>fe.label!==O.label);u&&u(_,K)}else{const K=[...c,O];u&&u(_,K)}else u&&u(_,O)}n({type:P.CLEAR_SEARCH,options:r}),a()}},f=M.useCallback(()=>d?d!=="auto"?d:be(r,S,m,b):"100%",[r,m]),h=M.useCallback(_=>i?Math.max(be(r,S,m,b),_==null?void 0:_.width):_==null?void 0:_.width,[r,m]),{renderLayer:w,layerProps:N,triggerProps:q,triggerBounds:L}=Pe({isOpen:(e==null?void 0:e.isLayerOpen)??!1,overflowContainer:!0,...bt,ResizeObserver,onOutsideClick:s,onParentClose:s}),R=()=>{if(!(l||g)){if(e.isLayerOpen){s();return}n({type:P.RESET_LAYER_FOCUS,options:r,firstSelectedOptionIndex:E}),p()}},x=M.useRef(!0);M.useEffect(()=>{x.current?x.current=!1:e.isLayerOpen||n({type:P.CLEAR_SEARCH,options:r})},[e.isLayerOpen]);const A=(_,O)=>{const Q=c instanceof Array?c.filter(Y=>Y.value!==O.value):null;u&&u(_,Q)},F=_=>{const O=c instanceof Array?[]:{value:null};u&&u(_,O)},z=_=>n({type:P.ON_CHANGE_SEARCH,options:r,value:_,createAble:v}),V=()=>{p(),n({type:P.BLUR_TRIGGER_INPUTS})},$=_=>{t.current&&Number.isInteger(_)&&t.current.scrollToItem(_)},j=_=>{const O=ht(_,e.layerFocus);n({type:P.FOCUS_LAYER_OPTIONS,nextLayerFocus:O}),$(O.current)},D=_=>{n({type:P.FOCUS_TRIGGER_INPUTS,ICustomSelectDirection:_,selectedOptions:c})},Z=_=>F(_),te=c&&c[e.triggerFocus.currentOption],re=_=>{A(_,c[e.triggerFocus.currentOption])},X=_=>{var O;I(_,(O=e==null?void 0:e.visibleOptions)==null?void 0:O[e.layerFocus.current],s)},k=e.triggerFocus.clearAll;return{getTriggerWidth:f,onKeyEvent:(_,O)=>{switch(_){case B.UP:{j(_);break}case B.DOWN:{e.isLayerOpen?j(_):V();break}case B.LEFT:case B.RIGHT:{D(_);break}case B.ENTER:{k?Z(O):te?re(O):X(O);break}case B.ESC:{s();break}}},clearAllIsFocused:k,triggerProps:q,onClickTrigger:R,onChangeSearch:z,onClickDeselectOption:A,onClickClearAll:F,renderLayer:w,layerProps:N,closeLayer:s,onSelectOption:I,getLayerWidth:h,triggerBounds:L}},ke=e=>{const{multi:n=!1,disabled:r=!1,error:a=null,warning:l=null,tooltip:g=null,options:T,selectedOptions:u,onCreate:c=null,placeholder:d="",small:S=!1,tabIndex:m=0,onFocus:b=()=>{},onBlur:E=()=>{},searchable:v=!0,clearable:t=!1,maxTooltipWidth:i,closeOnOptionActionClick:s,isInTable:p=!1,groupOrder:y,firstSelectedOptionIndex:I=0,right:f=!1,testId:h=void 0}=e,w=M.useContext(me),N=c!==null,q=M.useRef(null),[L,R]=Oe(),x=!0,[A,F]=M.useReducer(St,{options:T,firstSelectedOptionIndex:I},({options:Y})=>({searchValue:"",visibleOptions:Y,layerFocus:De(Y,I??0),triggerFocus:je,isLayerOpen:!1})),{getTriggerWidth:z,onKeyEvent:V,clearAllIsFocused:$,triggerProps:j,onClickTrigger:D,onChangeSearch:Z,onClickDeselectOption:te,onClickClearAll:re,renderLayer:X,layerProps:k,closeLayer:J,onSelectOption:_,getLayerWidth:O,triggerBounds:Q}=_t({...e,state:A,dispatch:F,setTriggerFocus:R,disabledContext:w,isFontLoaded:x,createAble:N,listRef:q});return o.jsx("div",{style:{width:z()},children:o.jsxs(ze,{handleKeys:Object.values(B),onKeyEvent:V,children:[o.jsx(He,{selectedOptions:u,searchValue:A.searchValue,isOpen:A.isLayerOpen,focusedSelectedOptionIndex:A.triggerFocus.currentOption,clearAllIsFocused:$,searchable:v,triggerRef:We(L,j.ref),error:a,warning:l,tooltip:g,small:S,isInTable:p,disabled:r||w,clearable:t,tabIndex:m,onClickTrigger:D,onChangeSearch:Z,onClickDeselect:te,onClickClear:re,onFocus:b,onBlur:E,groupOrder:y,maxTooltipWidth:i,placeholder:d,right:f,testId:h}),A.isLayerOpen&&X(o.jsx("div",{...k,className:H.layerContainer,children:o.jsx(Ne,{listRef:q,isMulti:n,sections:A.visibleOptions,selectedOptions:u,onSelectOption:(Y,K)=>{_(Y,K,n?void 0:J)},closeLayer:()=>{s&&J()},width:O(Q),small:S,focusedOptionIndex:A.layerFocus.current,firstSelectedOptionIndex:I??0,testId:h&&`${h}-layer`})}))]})})};ke.__docgenInfo={description:"",methods:[],displayName:"CustomSelect",props:{multi:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},options:{required:!0,tsType:{name:"Array",elements:[{name:"union",raw:"ISelectSelectedOption | Heading",elements:[{name:"ISelectSelectedOption"},{name:"Heading"}]}],raw:"TCustomSelectSelectOption[]"},description:""},selectedOptions:{required:!0,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
38
+ event: TChangeEvent<T>,
39
+ ...additionalProps: { [key: string]: any }[]
40
+ ) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
41
+ target:
42
+ | T
43
+ | { name: string; value: any; label?: string; files?: FileList | null };
44
+ }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
45
+ target:
46
+ | T
47
+ | { name: string; value: any; label?: string; files?: FileList | null };
48
+ }`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
49
+ | { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},name:"event"},{type:{name:"Array",elements:[{name:"signature",type:"object",raw:"{ [key: string]: any }",signature:{properties:[{key:{name:"string"},value:{name:"any",required:!0}}]}}],raw:"{ [key: string]: any }[]"},name:"additionalProps",rest:!0}],return:{name:"void"}}},description:""},onCreate:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:""},autoLayerWidth:{required:!1,tsType:{name:"boolean"},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},groupOrder:{required:!1,tsType:{name:"union",raw:"TGroupOrder | string",elements:[{name:"union",raw:"'first' | 'middle' | 'last'",elements:[{name:"literal",value:"'first'"},{name:"literal",value:"'middle'"},{name:"literal",value:"'last'"}]},{name:"string"}]},description:""},firstSelectedOptionIndex:{required:!0,tsType:{name:"union",raw:"number | null",elements:[{name:"number"},{name:"null"}]},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},closeOnOptionActionClick:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | undefined",elements:[{name:"string"},{name:"undefined"}]},description:""}}};const It=e=>{const{name:n="",options:r=[],value:a,native:l=!1,onChange:g=ae.noop,deprecatedEventHandler:T=!1,autoScroll:u=!0,warning:c,error:d,checkNonExistentValues:S=!0,closeOnOptionActionClick:m=!0,testId:b,disabled:E}=e,v=!l&&u===!0,{multi:t,simpleInputs:i,options:s,selectedOptions:p,firstSelectedOptionIndex:y,hasNonExistentValue:I}=Ve(r,a,v,S),f=!t,h=l&&f;l&&!f&&console.warn("Native select does not support provided props (see stories)");const w="Value no longer available for re-selection",N=I&&!E?c?o.jsxs("div",{children:[o.jsx("div",{children:w}),o.jsx("div",{children:c})]}):w:c,q=I&&d&&!E?o.jsxs("div",{children:[o.jsx("div",{children:w}),o.jsx("div",{children:d})]}):d,L=(R,x)=>{if(T){const A=t?x.map(F=>i?F.value:F):i?x.value:x;A&&g(A)}else{const A=!(R instanceof Event),F=t?x:x.value;if(A)R.target.name=n,R.target.value=F,t||(R.target.label=x.label),g(R);else{const z={...R,target:{...R.target,name:n,value:F,label:t?void 0:x.label}};g(z)}}};return h?o.jsx(we,{...e,options:s,selectedOption:p,onChange:L,hasNonExistentValue:I,warning:N,error:q,testId:b}):o.jsx(ke,{...e,options:s,selectedOptions:p,onChange:L,multi:t,firstSelectedOptionIndex:y,warning:N,error:q,testId:b,closeOnOptionActionClick:m})};It.__docgenInfo={description:"",methods:[],displayName:"Select",props:{name:{required:!1,tsType:{name:"string"},description:""},multi:{required:!1,tsType:{name:"boolean"},description:""},options:{required:!1,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},value:{required:!1,tsType:{name:"any"},description:""},native:{required:!1,tsType:{name:"boolean"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
50
+ event: TChangeEvent<T>,
51
+ ...additionalProps: { [key: string]: any }[]
52
+ ) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
53
+ target:
54
+ | T
55
+ | { name: string; value: any; label?: string; files?: FileList | null };
56
+ }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
57
+ target:
58
+ | T
59
+ | { name: string; value: any; label?: string; files?: FileList | null };
60
+ }`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
61
+ | { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},name:"event"},{type:{name:"Array",elements:[{name:"signature",type:"object",raw:"{ [key: string]: any }",signature:{properties:[{key:{name:"string"},value:{name:"any",required:!0}}]}}],raw:"{ [key: string]: any }[]"},name:"additionalProps",rest:!0}],return:{name:"void"}}},description:""},deprecatedEventHandler:{required:!1,tsType:{name:"boolean"},description:""},autoScroll:{required:!1,tsType:{name:"boolean"},description:""},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},checkNonExistentValues:{required:!1,tsType:{name:"boolean"},description:""},closeOnOptionActionClick:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:""},borderRadius:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},onCreate:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: any) => any",signature:{arguments:[{type:{name:"any"},name:"evt"}],return:{name:"any"}}},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},autoLayerWidth:{required:!1,tsType:{name:"boolean"},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};export{It as S};
@@ -1,4 +1,4 @@
1
- import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as _}from"./index-DhsZuJvc.js";import{S as F}from"./select-Cwks-WA0.js";import{S as Sn}from"./spacer-BWoNR27H.js";import{o as Vn,a as Cn,b as bn,c as xn,d as yn,e as fn,f as jn,g as Wn,h as On,i as En}from"./select.stories-data-DxgWKlU6.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";const na={title:"Forms/Select",component:F,args:{options:Vn,native:!1,multi:!1,disabled:!1,autoLayerWidth:!1,clearable:!1,searchable:!0,right:!1}},e=t=>{const{multi:o,value:P}=t,[M,H]=_.useState(P||(o?[]:void 0)),I=n=>{const{value:a}=n.target;H(o?a:{value:a})};return s.jsx(F,{value:M,onChange:I,...t})},k=e.bind({}),u=e.bind({});u.args={small:!0};const c=e.bind({});c.args={width:"auto"};const i=e.bind({});i.args={width:"200px"};const d=e.bind({});d.args={native:!0};const g=e.bind({});g.args={multi:!0,clearable:!0};const p=e.bind({});p.args={options:[]};const m=e.bind({});m.args={clearable:!0};const v=e.bind({});v.args={value:{label:"Vampires",value:"blood"}};const h=e.bind({});h.args={placeholder:"Select the best animal..."};const S=e.bind({});S.args={options:Cn};const V=e.bind({});V.args={options:bn};const C=e.bind({});C.args={options:xn};const b=e.bind({});b.args={options:yn};const x=e.bind({});x.args={options:fn};const y=e.bind({});y.args={searchable:!1};const f=e.bind({});f.args={right:!0};const l=e.bind({});l.parameters={docs:{description:{story:"Avoid autoLayerWidth for very long lists in custom selects (slow)"}}};l.args={width:"70px",autoLayerWidth:!0};const j=e.bind({});j.args={tooltip:"Some info"};const W=e.bind({});W.args={error:"Some info"};const O=e.bind({});O.args={warning:"Some info"};const E=e.bind({});E.args={disabled:!0};const w=e.bind({});w.args={options:jn,placeholder:void 0};const A=e.bind({});A.args={options:Wn};const L=e.bind({});L.args={options:On};const r=e.bind({});r.parameters={docs:{description:{story:"Avoid `width: auto` and autoLayerWidth for very long lists in custom selects (slow). Consider checkNonExistentValues={false}."}}};r.args={options:En};const N=e.bind({});N.args={deprecatedEventHandler:!0};const D=()=>{const[t,o]=_.useState([{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{label:"Possums",value:"slugs"}]),[P,M]=_.useState(void 0),[H,I]=_.useState([]);return s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"example",options:t,onChange:n=>M({value:n.target.value}),onCreate:n=>{const a={label:n,value:n};o([...t,a]),M(a)},value:P,clearable:!0}),s.jsx(Sn,{}),s.jsx(F,{name:"example",options:t,onChange:n=>I(n.target.value),onCreate:n=>{const a={label:n,value:n};o([...t,a]),console.log(n),I([...H,a])},value:H,multi:!0,clearable:!0})]})};D.__docgenInfo={description:"",methods:[],displayName:"OnCreate"};var B,R,T;k.parameters={...k.parameters,docs:{...(B=k.parameters)==null?void 0:B.docs,source:{originalSource:`(args: any) => {
1
+ import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as _}from"./index-DhsZuJvc.js";import{S as F}from"./select-BQzJMnK1.js";import{S as Sn}from"./spacer-BWoNR27H.js";import{o as Vn,a as Cn,b as bn,c as xn,d as yn,e as fn,f as jn,g as Wn,h as On,i as En}from"./select.stories-data-DxgWKlU6.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";const na={title:"Forms/Select",component:F,args:{options:Vn,native:!1,multi:!1,disabled:!1,autoLayerWidth:!1,clearable:!1,searchable:!0,right:!1}},e=t=>{const{multi:o,value:P}=t,[M,H]=_.useState(P||(o?[]:void 0)),I=n=>{const{value:a}=n.target;H(o?a:{value:a})};return s.jsx(F,{value:M,onChange:I,...t})},k=e.bind({}),u=e.bind({});u.args={small:!0};const c=e.bind({});c.args={width:"auto"};const i=e.bind({});i.args={width:"200px"};const d=e.bind({});d.args={native:!0};const g=e.bind({});g.args={multi:!0,clearable:!0};const p=e.bind({});p.args={options:[]};const m=e.bind({});m.args={clearable:!0};const v=e.bind({});v.args={value:{label:"Vampires",value:"blood"}};const h=e.bind({});h.args={placeholder:"Select the best animal..."};const S=e.bind({});S.args={options:Cn};const V=e.bind({});V.args={options:bn};const C=e.bind({});C.args={options:xn};const b=e.bind({});b.args={options:yn};const x=e.bind({});x.args={options:fn};const y=e.bind({});y.args={searchable:!1};const f=e.bind({});f.args={right:!0};const l=e.bind({});l.parameters={docs:{description:{story:"Avoid autoLayerWidth for very long lists in custom selects (slow)"}}};l.args={width:"70px",autoLayerWidth:!0};const j=e.bind({});j.args={tooltip:"Some info"};const W=e.bind({});W.args={error:"Some info"};const O=e.bind({});O.args={warning:"Some info"};const E=e.bind({});E.args={disabled:!0};const w=e.bind({});w.args={options:jn,placeholder:void 0};const A=e.bind({});A.args={options:Wn};const L=e.bind({});L.args={options:On};const r=e.bind({});r.parameters={docs:{description:{story:"Avoid `width: auto` and autoLayerWidth for very long lists in custom selects (slow). Consider checkNonExistentValues={false}."}}};r.args={options:En};const N=e.bind({});N.args={deprecatedEventHandler:!0};const D=()=>{const[t,o]=_.useState([{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{label:"Possums",value:"slugs"}]),[P,M]=_.useState(void 0),[H,I]=_.useState([]);return s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"example",options:t,onChange:n=>M({value:n.target.value}),onCreate:n=>{const a={label:n,value:n};o([...t,a]),M(a)},value:P,clearable:!0}),s.jsx(Sn,{}),s.jsx(F,{name:"example",options:t,onChange:n=>I(n.target.value),onCreate:n=>{const a={label:n,value:n};o([...t,a]),console.log(n),I([...H,a])},value:H,multi:!0,clearable:!0})]})};D.__docgenInfo={description:"",methods:[],displayName:"OnCreate"};var B,R,T;k.parameters={...k.parameters,docs:{...(B=k.parameters)==null?void 0:B.docs,source:{originalSource:`(args: any) => {
2
2
  const {
3
3
  multi,
4
4
  value
@@ -0,0 +1,82 @@
1
+ import{j as q}from"./jsx-runtime-eps93zm2.js";import{r as I}from"./index-DhsZuJvc.js";import{w as s,u as c,e as l,a as F}from"./index-DMAnyMX5.js";import{S as T}from"./select-BQzJMnK1.js";import{o as K}from"./select.stories-data-DxgWKlU6.js";import"./index-CF7H4eMJ.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";const me={title:"Forms/Select/Test Cases",component:T,args:{options:K},tags:["!autodocs"]},v=n=>{const{multi:o,value:a}=n,[r,t]=I.useState(a||(o?[]:void 0)),e=i=>{const{value:u}=i.target;t(o?u:{value:u})};return q.jsx(T,{value:r,onChange:e,...n})},y=v.bind({});y.args={value:{label:"Vampires",value:"blood"},disabled:!0};const m=v.bind({});m.args={testId:"testId",clearable:!0};m.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Select item with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i);const u=await a.findByTestId("testId-value");l(s(u).getByText("Wombats")).toBeInTheDocument()}),await o("Clear selected value",async()=>{const t=a.getByTestId("testId-clear");await c.click(t);const e=a.queryByTestId("testId-value");l(e).not.toBeInTheDocument()})};const p=v.bind({});p.args={testId:"testId",clearable:!0,multi:!0};p.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Select items with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i);const u=s(e).getByText("Kangaroos");await c.click(u),await c.click(n),l(e).not.toBeInTheDocument();const w=await a.findByTestId("testId-value");l(s(w).getByText("Wombats")).toBeInTheDocument(),l(s(w).getByText("Kangaroos")).toBeInTheDocument()}),await o("Deselect item with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i),await c.click(n),l(e).not.toBeInTheDocument();const u=await a.findByTestId("testId-value");l(s(u).queryByText("Wombats")).not.toBeInTheDocument()}),await o("Clear selected values",async()=>{const t=a.getByTestId("testId-clear");await c.click(t),await F(()=>{const e=a.queryByTestId("testId-value");l(e).not.toBeInTheDocument()})})};const g=v.bind({});g.args={testId:"testId",disabled:!0};g.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Clicking disabled trigger should not show layer",async()=>{await a.getByTestId("testId").click(),await F(()=>{const e=r.queryByTestId("testId-layer");l(e).not.toBeInTheDocument()})})};const d=()=>{const[n,o]=I.useState(K),[a,r]=I.useState(void 0);return q.jsx(T,{testId:"testId",name:"example",options:n,onChange:t=>r({value:t.target.value}),onCreate:t=>{const e={label:t,value:t};o([...n,e]),r(e)},value:a})};d.args={testId:"testId"};d.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Create new item",async()=>{const t=a.getByTestId("testId-input");if(l(t).toBeInTheDocument(),!t)return;await c.type(t,"New value");const e=r.getByText('Create "New value"');await c.click(e);const i=await a.findByTestId("testId-value");l(s(i).getByText("New value")).toBeInTheDocument()})};d.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestCreate"};var h,B,S;y.parameters={...y.parameters,docs:{...(h=y.parameters)==null?void 0:h.docs,source:{originalSource:`(args: any) => {
2
+ const {
3
+ multi,
4
+ value
5
+ } = args;
6
+ const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
7
+ const handleChange = (evt: any) => {
8
+ const {
9
+ value
10
+ } = evt.target;
11
+ setSelectedValue(multi ? value : {
12
+ value
13
+ });
14
+ };
15
+ return <Select value={selectedValue} onChange={handleChange}
16
+ // eslint-disable-next-line react/jsx-props-no-spreading
17
+ {...args} />;
18
+ }`,...(S=(B=y.parameters)==null?void 0:B.docs)==null?void 0:S.source}}};var b,V,x;m.parameters={...m.parameters,docs:{...(b=m.parameters)==null?void 0:b.docs,source:{originalSource:`(args: any) => {
19
+ const {
20
+ multi,
21
+ value
22
+ } = args;
23
+ const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
24
+ const handleChange = (evt: any) => {
25
+ const {
26
+ value
27
+ } = evt.target;
28
+ setSelectedValue(multi ? value : {
29
+ value
30
+ });
31
+ };
32
+ return <Select value={selectedValue} onChange={handleChange}
33
+ // eslint-disable-next-line react/jsx-props-no-spreading
34
+ {...args} />;
35
+ }`,...(x=(V=m.parameters)==null?void 0:V.docs)==null?void 0:x.source}}};var C,D,f;p.parameters={...p.parameters,docs:{...(C=p.parameters)==null?void 0:C.docs,source:{originalSource:`(args: any) => {
36
+ const {
37
+ multi,
38
+ value
39
+ } = args;
40
+ const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
41
+ const handleChange = (evt: any) => {
42
+ const {
43
+ value
44
+ } = evt.target;
45
+ setSelectedValue(multi ? value : {
46
+ value
47
+ });
48
+ };
49
+ return <Select value={selectedValue} onChange={handleChange}
50
+ // eslint-disable-next-line react/jsx-props-no-spreading
51
+ {...args} />;
52
+ }`,...(f=(D=p.parameters)==null?void 0:D.docs)==null?void 0:f.source}}};var k,j,N;g.parameters={...g.parameters,docs:{...(k=g.parameters)==null?void 0:k.docs,source:{originalSource:`(args: any) => {
53
+ const {
54
+ multi,
55
+ value
56
+ } = args;
57
+ const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
58
+ const handleChange = (evt: any) => {
59
+ const {
60
+ value
61
+ } = evt.target;
62
+ setSelectedValue(multi ? value : {
63
+ value
64
+ });
65
+ };
66
+ return <Select value={selectedValue} onChange={handleChange}
67
+ // eslint-disable-next-line react/jsx-props-no-spreading
68
+ {...args} />;
69
+ }`,...(N=(j=g.parameters)==null?void 0:j.docs)==null?void 0:N.source}}};var W,_,O;d.parameters={...d.parameters,docs:{...(W=d.parameters)==null?void 0:W.docs,source:{originalSource:`() => {
70
+ const [options, setOptions] = useState(storyData.options);
71
+ const [singleValue, setSingleValue] = useState<ISelectSelectedOption | undefined>(undefined);
72
+ return <Select testId="testId" name="example" options={options} onChange={evt => setSingleValue({
73
+ value: evt.target.value
74
+ })} onCreate={value => {
75
+ const newValue = {
76
+ label: value,
77
+ value
78
+ };
79
+ setOptions([...options, newValue]);
80
+ setSingleValue(newValue);
81
+ }} value={singleValue} />;
82
+ }`,...(O=(_=d.parameters)==null?void 0:_.docs)==null?void 0:O.source}}};const pe=["TestDisabledNonExistentValue","Test","TestMulti","TestDisabled","TestCreate"];export{m as Test,d as TestCreate,g as TestDisabled,y as TestDisabledNonExistentValue,p as TestMulti,pe as __namedExportsOrder,me as default};
@@ -1,4 +1,4 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-DazXb-ul.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Bax0KeqM.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-CR1nxnnq.js";import{A as h,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-Db9WkmPP.js";import{N as Me}from"./number-input-CNnU6gOF.js";import{S as Ge}from"./select-Cwks-WA0.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as ie}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-CcpE4BLD.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-C_2P8LFJ.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_1dg3w_1",Ye="_inputHover_1dg3w_13",Je="_inputFocus_1dg3w_18",Qe="_inputError_1dg3w_25",Ze="_inputWarning_1dg3w_26",en="_inputDisabled_1dg3w_61",nn="_hideScrollbars_1dg3w_67",tn="_wrapper_1dg3w_85",rn="_bordered_1dg3w_93",an="_scroll_1dg3w_98",on="_table_1dg3w_108",sn="_striped_1dg3w_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:i})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:dn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":i,children:e})}):null,s()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:i})=>{const a=r&&r.length,o=i!=null,s=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return u>I}return!1};return a||o||s()?n.jsxs("div",{className:J.footer,children:[o?n.jsx("div",{className:J.section,children:n.jsx("div",{children:i})}):null,a||s()?n.jsxs("div",{className:J.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,i)=>{const a=i.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:i}=e,a=Math.ceil(window.innerHeight/30),[o,s]=i?S.useState(a):[r.length,null],[c,d]=i?S.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:i?n.jsx(Le,{dataLength:Math.min(r.length,o+a),next:p,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const gn="_clickableRow_m64j5_1",In="_hoverableRow_m64j5_4",yn="_rowActive_m64j5_4",Cn="_expandableRow_m64j5_8",bn="_flush_m64j5_8",hn="_dragIconCell_m64j5_34",fn="_dragIcon_m64j5_34",R={clickableRow:gn,hoverableRow:In,rowActive:yn,expandableRow:Cn,flush:bn,dragIconCell:hn,dragIcon:fn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(R.expandableRow,r?R.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:i,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:i){case h.LEFT:return r?h.LEFT:t.leftAligned;case h.RIGHT:return r?h.RIGHT:t.rightAligned;case h.CENTER:return r?h.CENTER:t.centerAligned;default:return r?h.LEFT:t.leftAligned}},_n=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const i=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return i&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_ie6ng_1",xn="_inputHover_ie6ng_13",Tn="_inputFocus_ie6ng_18",vn="_inputError_ie6ng_25",An="_inputWarning_ie6ng_26",Rn="_inputDisabled_ie6ng_61",jn="_hideScrollbars_ie6ng_67",kn="_cell_ie6ng_77",qn="_disabledLink_ie6ng_87",Nn="_inputWrapper_ie6ng_91",Sn="_numberInputWrapper_ie6ng_106",En="_breakWord_ie6ng_113",Hn="_inputCell_ie6ng_116",Ln="_sliderCell_ie6ng_119",Wn="_staticCell_ie6ng_123",Fn="_staticCellContent_ie6ng_126",Pn="_unit_ie6ng_148",Dn="_sortingCell_ie6ng_151",On="_sortingCellIcon_ie6ng_162",Bn="_icon_ie6ng_173",$n="_checkBoxCell_ie6ng_177",Mn="_iconCellWrapper_ie6ng_181",Gn="_actionsCell_ie6ng_185",Vn="_rightAligned_ie6ng_193",Un="_centerAligned_ie6ng_199",zn="_leftAligned_ie6ng_205",Kn="_popover_ie6ng_208",Xn="_disabledPointerEvents_ie6ng_211",l={inputInTable:wn,inputHover:xn,inputFocus:Tn,inputError:vn,inputWarning:An,inputDisabled:Rn,hideScrollbars:jn,cell:kn,disabledLink:qn,inputWrapper:Nn,numberInputWrapper:Sn,breakWord:En,inputCell:Hn,sliderCell:Ln,staticCell:Wn,staticCellContent:Fn,unit:Pn,sortingCell:Dn,sortingCellIcon:On,icon:Bn,checkBoxCell:$n,iconCellWrapper:Mn,actionsCell:Gn,rightAligned:Vn,centerAligned:Un,leftAligned:zn,popover:Kn,disabledPointerEvents:Xn},te=({cell:e,columnAlignment:t,testId:r,type:i})=>n.jsx($e,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:i});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var i;return(i=e.onChange)==null?void 0:i.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableCosmeticRounding:e.enableCosmeticRounding,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:i=>{var a;return(a=e.onChange)==null?void 0:a.call(e,i)},onCreate:e.onCreate?i=>e.onCreate&&e.onCreate(i):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:T(l.inputWrapper,e.type==="NumberInput"?l.numberInputWrapper:""),children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});xe.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:i,warning:a,tooltip:o,maxTooltipWidth:s}=e,c=d=>M(d);return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:c(o)||c(i)||c(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:l.staticCellContent,"data-error":i||null,"data-warning":a||null,children:n.jsx("a",{className:T((e.disabled||r)&&l.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ae=({cell:e})=>n.jsx("div",{className:l.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});Ae.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const Re=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:l.iconCellWrapper,children:n.jsx(ie,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};Re.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const je=({cell:e})=>n.jsx(ae,{actions:e.actions});je.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:i}=e;return t?n.jsxs("span",{className:l.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),i&&r?n.jsx("sup",{children:i}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const oe=({cell:e,isHeader:t,testId:r})=>{const{error:i,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:c,onSort:d,type:p}=e,u=n.jsxs("div",{className:T(l.staticCellContent,p==="Unit"?l.unit:""),onClick:c?y=>d&&d(y):()=>{},"data-error":i||null,"data-warning":a||null,"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:o&&M(o)||i&&M(i)||a&&M(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:u})})};oe.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Ke,{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:l.popover,children:n.jsx(oe,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:i})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(xe,{cell:e,columnAlignment:r,testId:i});case"Link":return n.jsx(Te,{cell:e,testId:i});case"CheckBox":return n.jsx(ve,{cell:e,testId:i});case"Slider":return n.jsx(Ae,{cell:e});case"Icon":return n.jsx(Re,{cell:e});case"Actions":return n.jsx(je,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(oe,{cell:e,isHeader:t,testId:i})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var j=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(j||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:i=h.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:p,width:u}=e,y=S.useRef(null),I={bodyAlignment:i,headerAlignment:r,isHeader:t},W=he(I,l),f=he(I,l,!0),F=e.type===j.INPUT||e.type===j.NUMBER_INPUT||e.type===j.SELECT||e.type===j.POPOVER?l.inputCell:e.type===j.SLIDER?l.sliderCell:e.type===j.CHECKBOX?l.checkBoxCell:e.type===j.ACTIONS?l.actionsCell:l.staticCell,v=T(l.cell,F,e.hasSort?l.sortingCell:null,W,e.breakWord?l.breakWord:""),E=u??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,_={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:y,className:v,style:_,colSpan:d,rowSpan:p,children:n.jsx(Ee,{cell:e,columnAlignment:f??h.RIGHT,isHeader:t,testId:s})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-DazXb-ul.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Bax0KeqM.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-CoyQUC4R.js";import{A as h,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-Db9WkmPP.js";import{N as Me}from"./number-input-CNnU6gOF.js";import{S as Ge}from"./select-BQzJMnK1.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as ie}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-CcpE4BLD.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-C_2P8LFJ.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_1dg3w_1",Ye="_inputHover_1dg3w_13",Je="_inputFocus_1dg3w_18",Qe="_inputError_1dg3w_25",Ze="_inputWarning_1dg3w_26",en="_inputDisabled_1dg3w_61",nn="_hideScrollbars_1dg3w_67",tn="_wrapper_1dg3w_85",rn="_bordered_1dg3w_93",an="_scroll_1dg3w_98",on="_table_1dg3w_108",sn="_striped_1dg3w_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:i})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:dn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":i,children:e})}):null,s()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:i})=>{const a=r&&r.length,o=i!=null,s=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return u>I}return!1};return a||o||s()?n.jsxs("div",{className:J.footer,children:[o?n.jsx("div",{className:J.section,children:n.jsx("div",{children:i})}):null,a||s()?n.jsxs("div",{className:J.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,i)=>{const a=i.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:i}=e,a=Math.ceil(window.innerHeight/30),[o,s]=i?S.useState(a):[r.length,null],[c,d]=i?S.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:i?n.jsx(Le,{dataLength:Math.min(r.length,o+a),next:p,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const gn="_clickableRow_m64j5_1",In="_hoverableRow_m64j5_4",yn="_rowActive_m64j5_4",Cn="_expandableRow_m64j5_8",bn="_flush_m64j5_8",hn="_dragIconCell_m64j5_34",fn="_dragIcon_m64j5_34",R={clickableRow:gn,hoverableRow:In,rowActive:yn,expandableRow:Cn,flush:bn,dragIconCell:hn,dragIcon:fn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(R.expandableRow,r?R.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:i,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:i){case h.LEFT:return r?h.LEFT:t.leftAligned;case h.RIGHT:return r?h.RIGHT:t.rightAligned;case h.CENTER:return r?h.CENTER:t.centerAligned;default:return r?h.LEFT:t.leftAligned}},_n=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const i=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return i&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_ie6ng_1",xn="_inputHover_ie6ng_13",Tn="_inputFocus_ie6ng_18",vn="_inputError_ie6ng_25",An="_inputWarning_ie6ng_26",Rn="_inputDisabled_ie6ng_61",jn="_hideScrollbars_ie6ng_67",kn="_cell_ie6ng_77",qn="_disabledLink_ie6ng_87",Nn="_inputWrapper_ie6ng_91",Sn="_numberInputWrapper_ie6ng_106",En="_breakWord_ie6ng_113",Hn="_inputCell_ie6ng_116",Ln="_sliderCell_ie6ng_119",Wn="_staticCell_ie6ng_123",Fn="_staticCellContent_ie6ng_126",Pn="_unit_ie6ng_148",Dn="_sortingCell_ie6ng_151",On="_sortingCellIcon_ie6ng_162",Bn="_icon_ie6ng_173",$n="_checkBoxCell_ie6ng_177",Mn="_iconCellWrapper_ie6ng_181",Gn="_actionsCell_ie6ng_185",Vn="_rightAligned_ie6ng_193",Un="_centerAligned_ie6ng_199",zn="_leftAligned_ie6ng_205",Kn="_popover_ie6ng_208",Xn="_disabledPointerEvents_ie6ng_211",l={inputInTable:wn,inputHover:xn,inputFocus:Tn,inputError:vn,inputWarning:An,inputDisabled:Rn,hideScrollbars:jn,cell:kn,disabledLink:qn,inputWrapper:Nn,numberInputWrapper:Sn,breakWord:En,inputCell:Hn,sliderCell:Ln,staticCell:Wn,staticCellContent:Fn,unit:Pn,sortingCell:Dn,sortingCellIcon:On,icon:Bn,checkBoxCell:$n,iconCellWrapper:Mn,actionsCell:Gn,rightAligned:Vn,centerAligned:Un,leftAligned:zn,popover:Kn,disabledPointerEvents:Xn},te=({cell:e,columnAlignment:t,testId:r,type:i})=>n.jsx($e,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:i});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var i;return(i=e.onChange)==null?void 0:i.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableCosmeticRounding:e.enableCosmeticRounding,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:i=>{var a;return(a=e.onChange)==null?void 0:a.call(e,i)},onCreate:e.onCreate?i=>e.onCreate&&e.onCreate(i):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:T(l.inputWrapper,e.type==="NumberInput"?l.numberInputWrapper:""),children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});xe.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:i,warning:a,tooltip:o,maxTooltipWidth:s}=e,c=d=>M(d);return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:c(o)||c(i)||c(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:l.staticCellContent,"data-error":i||null,"data-warning":a||null,children:n.jsx("a",{className:T((e.disabled||r)&&l.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ae=({cell:e})=>n.jsx("div",{className:l.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});Ae.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const Re=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:l.iconCellWrapper,children:n.jsx(ie,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};Re.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const je=({cell:e})=>n.jsx(ae,{actions:e.actions});je.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:i}=e;return t?n.jsxs("span",{className:l.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),i&&r?n.jsx("sup",{children:i}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const oe=({cell:e,isHeader:t,testId:r})=>{const{error:i,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:c,onSort:d,type:p}=e,u=n.jsxs("div",{className:T(l.staticCellContent,p==="Unit"?l.unit:""),onClick:c?y=>d&&d(y):()=>{},"data-error":i||null,"data-warning":a||null,"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:o&&M(o)||i&&M(i)||a&&M(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:u})})};oe.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Ke,{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:l.popover,children:n.jsx(oe,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:i})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(xe,{cell:e,columnAlignment:r,testId:i});case"Link":return n.jsx(Te,{cell:e,testId:i});case"CheckBox":return n.jsx(ve,{cell:e,testId:i});case"Slider":return n.jsx(Ae,{cell:e});case"Icon":return n.jsx(Re,{cell:e});case"Actions":return n.jsx(je,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(oe,{cell:e,isHeader:t,testId:i})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var j=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(j||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:i=h.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:p,width:u}=e,y=S.useRef(null),I={bodyAlignment:i,headerAlignment:r,isHeader:t},W=he(I,l),f=he(I,l,!0),F=e.type===j.INPUT||e.type===j.NUMBER_INPUT||e.type===j.SELECT||e.type===j.POPOVER?l.inputCell:e.type===j.SLIDER?l.sliderCell:e.type===j.CHECKBOX?l.checkBoxCell:e.type===j.ACTIONS?l.actionsCell:l.staticCell,v=T(l.cell,F,e.hasSort?l.sortingCell:null,W,e.breakWord?l.breakWord:""),E=u??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,_={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:y,className:v,style:_,colSpan:d,rowSpan:p,children:n.jsx(Ee,{cell:e,columnAlignment:f??h.RIGHT,isHeader:t,testId:s})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
2
2
  | IStaticCell
3
3
  | ISelectCell
4
4
  | IHelpIconCell
@@ -1,4 +1,4 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-iVsvoMpy.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-Db9WkmPP.js";import{F as oe}from"./field-HrLaMLbx.js";import{H as un}from"./heading-CRNoBc7q.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-C7mC5R8Q.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-CR1nxnnq.js";import"./select-Cwks-WA0.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CNnU6gOF.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./label-CqmyC9he.js";import"./flex-EllkLxgO.js";const ht={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-DPbEkZqw.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-Db9WkmPP.js";import{F as oe}from"./field-HrLaMLbx.js";import{H as un}from"./heading-CRNoBc7q.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-C7mC5R8Q.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-CoyQUC4R.js";import"./select-BQzJMnK1.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CNnU6gOF.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./label-CqmyC9he.js";import"./flex-EllkLxgO.js";const ht={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
2
2
  return <Table
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -1,4 +1,4 @@
1
- import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-iVsvoMpy.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-C7mC5R8Q.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./pagination-CR1nxnnq.js";import"./select-Cwks-WA0.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CNnU6gOF.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./flex-EllkLxgO.js";const Or={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
1
+ import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-DPbEkZqw.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-C7mC5R8Q.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./pagination-CoyQUC4R.js";import"./select-BQzJMnK1.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CNnU6gOF.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./flex-EllkLxgO.js";const Or={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
2
2
  return <Table
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -0,0 +1,6 @@
1
+ import{j as g}from"./jsx-runtime-eps93zm2.js";import{w as l,u as n,e as c,a as m}from"./index-DMAnyMX5.js";import{t as w}from"./toaster-O8ftrUAJ.js";import{B as y}from"./button-Cbv7WK6k.js";import{a as h}from"./message-BRyKdRaX.js";import"./index-DhsZuJvc.js";import"./index-CF7H4eMJ.js";import"./toaster-7wnI6hqB.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";const T={type:h.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},O={title:"Modals/Toaster/Test Cases",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:T,autoClose:6e3,onClose:()=>{}},tags:["!autodocs"]},B=s=>g.jsx(y,{onClick:()=>w({...s,onClose:()=>console.log("toast closed")}),label:"Show toast"}),e=B.bind({});e.args={id:"testId",autoClose:50};e.play=async({canvasElement:s,step:a})=>{const r=l(s),i=l(s.ownerDocument.body);await a("Toast should appear when triggered",async()=>{const t=r.getByText("Show toast");await n.click(t);const o=i.getByRole("alert");await c(o).toBeInTheDocument()}),await a("Duplicate toasts shouldn't be created",async()=>{const t=r.getByText("Show toast");await n.click(t);const o=i.queryAllByRole("alert");await c(o).toHaveLength(1)}),await a("Toast should disappear when close button pressed",async()=>{const t=i.getByRole("alert"),o=r.getByTestId("testId-dismiss");await n.click(o),await m(()=>c(t).not.toBeInTheDocument(),{timeout:2500})}),await a("Toast should automatically close",async()=>{const t=i.queryByRole("alert"),o=r.getByText("Show toast");await n.click(o),await m(()=>c(t).not.toBeInTheDocument(),{timeout:2500})})};var p,d,u;e.parameters={...e.parameters,docs:{...(p=e.parameters)==null?void 0:p.docs,source:{originalSource:`args => {
2
+ return <Button onClick={() => toast({
3
+ ...args,
4
+ onClose: () => console.log('toast closed')
5
+ })} label="Show toast" />;
6
+ }`,...(u=(d=e.parameters)==null?void 0:d.docs)==null?void 0:u.source}}};const A=["Test"];export{e as Test,A as __namedExportsOrder,O as default};