@oliasoft-open-source/react-ui-library 4.9.0 → 4.9.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.
- package/dist/index.js +83 -143
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-BnHaqcsT.js → Color-KGDBMAHA-sr_lo8VN.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DcoD1y-5.js → DocsRenderer-PKQXORMH-Dio4TQT6.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-D0wb2n-9.js → accordion.stories-BtQXhKld.js} +2 -2
- package/dist/storybook/assets/{afe.stories-DM18uTAa.js → afe.stories-DFQsvqIV.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-jPZ2UUsp.js → buttons-and-links-BOcv8xIU.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-Dga1QkGC.js → casing-loads.stories-1KCWDoR3.js} +2 -2
- package/dist/storybook/assets/{cell.stories-DfyQwzEH.js → cell.stories-CBq3IOiP.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-D2AwGCE9.js → chunk-HLWAVYOI-SLqzrZ8s.js} +1 -1
- package/dist/storybook/assets/{color-CLf9xt55.js → color-D1FmkH7Y.js} +1 -1
- package/dist/storybook/assets/footer.stories-D-rIL9Q8.js +3 -0
- package/dist/storybook/assets/form.stories-BrUnmw7R.js +49 -0
- package/dist/storybook/assets/{formation.stories-CZGQhWyA.js → formation.stories-ByGQlyM6.js} +2 -2
- package/dist/storybook/assets/iframe-NUuxNiwO.js +2 -0
- package/dist/storybook/assets/{index-Sr04i8ct.js → index-Bhtru3gK.js} +4 -4
- package/dist/storybook/assets/{index-BQ_6rM6u.js → index-DNcuiqfZ.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-EhmORqH9.js → input-group.stories-CElwRt3p.js} +3 -3
- package/dist/storybook/assets/{input-validation-Tr-aD1VJ.js → input-validation-FFJCXfNa.js} +2 -2
- package/dist/storybook/assets/{inputs-BGIgggtv.js → inputs-D3ZjmDIl.js} +1 -1
- package/dist/storybook/assets/{layout-forms-n-mRkolR.js → layout-forms-DNUCHjRh.js} +5 -5
- package/dist/storybook/assets/{layout-general-CNsKoPG6.js → layout-general-CuxE1EOt.js} +1 -1
- package/dist/storybook/assets/{modal.stories-C6Bh0Oda.js → modal.stories-LhoWfDE6.js} +2 -2
- package/dist/storybook/assets/number-input-F3bqJ0z5.js +16 -0
- package/dist/storybook/assets/number-input.stories-Dw2eW2Mc.js +166 -0
- package/dist/storybook/assets/{padding-and-spacing-B10oZ-Ww.js → padding-and-spacing-B-LaxRb4.js} +1 -1
- package/dist/storybook/assets/{pagination-DWc8zp3k.js → pagination-CLt-kUlx.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-B5cOvzik.js → pagination.stories-CTRM0Xou.js} +2 -2
- package/dist/storybook/assets/popover.stories-CGm0M5fv.js +10 -0
- package/dist/storybook/assets/{preview-Cym3ID9p.js → preview-ClcAw55r.js} +2 -2
- package/dist/storybook/assets/{preview-pQMX-q5x.js → preview-DQgT2zeu.js} +1 -1
- package/dist/storybook/assets/{projects.stories-Co_WnKSx.js → projects.stories-BQswWVCx.js} +2 -2
- package/dist/storybook/assets/{radio-button-C4ljBRED.js → radio-button-DmDuw4DA.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-BzyW2CtK.js → radio-button.stories-5gvV0LD0.js} +2 -2
- package/dist/storybook/assets/{reservoirs.stories-UW_8sofe.js → reservoirs.stories-B12tIrmZ.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-0pm7-gTq.js → rich-text-input.stories-hAHCnDHk.js} +3 -3
- package/dist/storybook/assets/{row.stories-B8OWE9yd.js → row.stories-ghcsAzwW.js} +2 -2
- package/dist/storybook/assets/select-DnRuRG_N.js +61 -0
- package/dist/storybook/assets/select.input-D0UkAPd9.js +1 -0
- package/dist/storybook/assets/{select.stories-B0KIHiMX.js → select.stories-B9w9ONzj.js} +2 -2
- package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-umpPYjkq.js} +2 -2
- package/dist/storybook/assets/{table-qmf29AIJ.js → table-BCdvBxub.js} +1 -1
- package/dist/storybook/assets/{table.stories-DzHGqXth.js → table.stories-DkmbUVHr.js} +2 -2
- package/dist/storybook/assets/{tabs-BoToLVEP.js → tabs-C3NG6m9W.js} +1 -1
- package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +30 -0
- package/dist/storybook/assets/{title.stories-B8l1sfdo.js → title.stories-DpFDK9o1.js} +3 -3
- package/dist/storybook/assets/unit-input.stories-BHTxKnOU.js +380 -0
- package/dist/storybook/assets/unit-table.stories-u1PeEt0F.js +152 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/enum-Bnn40S8Q.js +0 -1
- package/dist/storybook/assets/footer.stories-DYBxUtZh.js +0 -3
- package/dist/storybook/assets/form.stories-BLcmnfy8.js +0 -49
- package/dist/storybook/assets/helpers-JJxzGegQ.js +0 -1
- package/dist/storybook/assets/iframe-BnDar59m.js +0 -2
- package/dist/storybook/assets/number-input-DZ9ERbK_.js +0 -16
- package/dist/storybook/assets/number-input.stories-CmVUHT2d.js +0 -124
- package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +0 -10
- package/dist/storybook/assets/select-03uRbc4I.js +0 -61
- package/dist/storybook/assets/select.input-CJed_LLR.js +0 -1
- package/dist/storybook/assets/tabs.stories-B52iEaHf.js +0 -30
- package/dist/storybook/assets/unit-input.stories-BnLB_Avl.js +0 -316
- package/dist/storybook/assets/unit-table.stories-DquyyMbD.js +0 -152
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{j as p}from"./jsx-runtime-eps93zm2.js";import{l as ae}from"./lodash-c4VUpsOs.js";import{r as N,g as We}from"./index-DhsZuJvc.js";import{c as G}from"./index-Bk2sglWO.js";import{G as ie,I as Ie}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 Ue,m as Ge}from"./tooltip-1V7clEnw.js";import{p as $e}from"./index-CEuq6vkz.js";import{a as Ve,_ as Ke}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 Ye}from"./actions-D-uVCDzk.js";import{I as ce}from"./icon-BSFY3vDO.js";import{s as Be}from"./select.input-D0UkAPd9.js";const Ze="_inputInTable_1nzfr_1",Xe="_error_1nzfr_7",Je="_warning_1nzfr_7",Qe="_inputHover_1nzfr_13",en="_inputFocus_1nzfr_18",nn="_inputError_1nzfr_25",tn="_inputWarning_1nzfr_26",rn="_inputDisabled_1nzfr_61",an="_hideScrollbars_1nzfr_67",sn="_select_1nzfr_77",ln="_isInTable_1nzfr_121",on="_unSelected_1nzfr_133",un="_small_1nzfr_174",cn="_right_1nzfr_182",dn="_groupOrderFirst_1nzfr_193",mn="_groupOrderMiddle_1nzfr_194",pn="_groupOrderLast_1nzfr_198",W={inputInTable:Ze,error:Xe,warning:Je,inputHover:Qe,inputFocus:en,inputError:nn,inputWarning:tn,inputDisabled:rn,hideScrollbars:an,select:sn,isInTable:ln,unSelected:on,small:un,right:cn,groupOrderFirst:dn,groupOrderMiddle:mn,groupOrderLast:pn},Oe=({disabled:e=!1,error:n=null,warning:a=null,tooltip:d=null,options:c,onChange:v=ae.noop,onFocus:f=ae.noop,onBlur:s=ae.noop,right:o=!1,small:g=!1,tabIndex:S=0,selectedOption:b,width:T=null,groupOrder:E=null,testId:_,isInTable:t=!1,clearable:l,placeholder:i,hasNonExistentValue:r,maxTooltipWidth:u,borderRadius:m})=>{const y=N.useContext(me),h=b===null||(b==null?void 0:b.value)===null?"unselected":b==null?void 0:b.value,I=h==="unselected",L=(h==="unselected"||l?[p.jsx("option",{value:"unselected",disabled:!l,hidden:!l,children:i||"Select..."},"unselected")]:[]).concat(r?[p.jsx("option",{value:b==null?void 0:b.value,disabled:e||y,children:b==null?void 0:b.label},"selectedNonExistentValue")]:[]).concat(c.map((x,w)=>p.jsx("option",{value:x.value,"data-testid":x.testId,children:x.label},w))),R=(()=>{if(E)switch(E){case ie.FIRST:return W.groupOrderFirst;case ie.LAST:return W.groupOrderLast;default:return W.groupOrderMiddle}return""})();return p.jsx(pe,{error:!!n,warning:!!a,text:d||n||a,enabled:d&&ne(d)||n&&ne(n)||a&&ne(a)||!1,maxWidth:u,placement:"bottom-center",children:p.jsx("select",{className:G(W.select,I?W.unSelected:"",n?W.error:a?W.warning:"",o?W.right:"",g?W.small:"",t?W.isInTable:"",R),style:{width:T||"",borderRadius:m||""},onChange:x=>{const{value:w}=x.target;let q;w==="unselected"?q={value:null}:q=c.find(A=>String(A.value)===String(w))||{value:null},v(x,q)},onFocus:f,onBlur:s,tabIndex:S,value:h,disabled:e||y,"data-testid":_,children:L})})};Oe.__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:""}}};var we={exports:{}};(function(e,n){(function(a,d){e.exports=d(N,$e)})(window,function(a,d){return function(c){var v={};function f(s){if(v[s])return v[s].exports;var o=v[s]={i:s,l:!1,exports:{}};return c[s].call(o.exports,o,o.exports,f),o.l=!0,o.exports}return f.m=c,f.c=v,f.d=function(s,o,g){f.o(s,o)||Object.defineProperty(s,o,{enumerable:!0,get:g})},f.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},f.t=function(s,o){if(1&o&&(s=f(s)),8&o||4&o&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(f.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),2&o&&typeof s!="string")for(var S in s)f.d(g,S,(function(b){return s[b]}).bind(null,S));return g},f.n=function(s){var o=s&&s.__esModule?function(){return s.default}:function(){return s};return f.d(o,"a",o),o},f.o=function(s,o){return Object.prototype.hasOwnProperty.call(s,o)},f.p="",f(f.s=0)}([function(c,v,f){Object.defineProperty(v,"__esModule",{value:!0});var s=f(1);Object.defineProperty(v,"default",{enumerable:!0,get:function(){return function(o){return o&&o.__esModule?o:{default:o}}(s).default}}),c.exports=v.default},function(c,v,f){Object.defineProperty(v,"__esModule",{value:!0});var s=Object.assign||function(t){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},o=function(){function t(l,i){for(var r=0;r<i.length;r++){var u=i[r];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}return function(l,i,r){return i&&t(l.prototype,i),r&&t(l,r),l}}(),g=T(f(2)),S=T(f(3)),b=f(4);function T(t){return t&&t.__esModule?t:{default:t}}var E=[],_=function(t){function l(i){(function(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")})(this,l);var r=function(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!m||typeof m!="object"&&typeof m!="function"?u:m}(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,i));return r.handleKeyboardEvent=r.handleKeyboardEvent.bind(r),r.registerExclusiveHandler=r.registerExclusiveHandler.bind(r),r.deregisterExclusiveHandler=r.deregisterExclusiveHandler.bind(r),r}return function(i,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof r);i.prototype=Object.create(r&&r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(i,r):i.__proto__=r)}(l,g.default.Component),o(l,[{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyboardEvent,!1),document.addEventListener("keyup",this.handleKeyboardEvent,!1),document.addEventListener("keypress",this.handleKeyboardEvent,!1);var i=this.props,r=i.isExclusive,u=i.isDisabled;r&&!u&&this.registerExclusiveHandler()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyboardEvent,!1),document.removeEventListener("keyup",this.handleKeyboardEvent,!1),document.removeEventListener("keypress",this.handleKeyboardEvent,!1),this.deregisterExclusiveHandler()}},{key:"componentDidUpdate",value:function(i){var r=i.isExclusive,u=i.isDisabled;(this.props.isExclusive!==r||this.props.isDisabled!==u)&&(this.props.isExclusive&&!this.props.isDisabled?this.registerExclusiveHandler():this.deregisterExclusiveHandler())}},{key:"registerExclusiveHandler",value:function(){this.deregisterExclusiveHandler(),E.unshift(this)}},{key:"deregisterExclusiveHandler",value:function(){var i=this;E.includes(this)&&(E=E.filter(function(r){return r!==i}))}},{key:"handleKeyboardEvent",value:function(i){var r=this.props,u=r.isDisabled,m=r.handleKeys,y=r.onKeyEvent,h=r.handleEventType,I=r.children,L=r.handleFocusableElements;if(u||h!==i.type||E.length>0&&E[0]!==this)return!1;var R=i.target===document.body||L,x=this.childrenContainer&&this.childrenContainer.contains(i.target);if(!(I?x:R))return!1;var w=(0,b.findMatchedKey)(i,m);return!!w&&(y(w,i),!0)}},{key:"render",value:function(){var i=this,r=this.props.children,u=Object.assign({},this.props),m=!0,y=!1,h=void 0;try{for(var I,L=Object.keys(l.propTypes)[Symbol.iterator]();!(m=(I=L.next()).done);m=!0)delete u[I.value]}catch(R){y=!0,h=R}finally{try{!m&&L.return&&L.return()}finally{if(y)throw h}}return r?g.default.createElement("span",s({ref:function(R){i.childrenContainer=R}},u),r):null}}]),l}();v.default=_,_.propTypes={handleKeys:S.default.array,handleEventType:S.default.oneOf(["keydown","keyup","keypress"]),handleFocusableElements:S.default.bool,onKeyEvent:S.default.func,isDisabled:S.default.bool,isExclusive:S.default.bool,children:S.default.any},_.defaultProps={handleKeys:[],handleFocusableElements:!1,handleEventType:"keydown",onKeyEvent:function(){return null}},c.exports=v.default},function(c,v){c.exports=a},function(c,v){c.exports=d},function(c,v,f){function s(r,u,m){return u in r?Object.defineProperty(r,u,{value:m,enumerable:!0,configurable:!0,writable:!0}):r[u]=m,r}Object.defineProperty(v,"__esModule",{value:!0}),v.matchKeyEvent=i,v.findMatchedKey=function(r,u){var m=u.map(function(y){var h=y.toLowerCase(),I=l[h];return I||[y]}).reduce(function(y,h){return y.concat(h)},[]).find(function(y){return i(r,y)});return!m&&u.includes("all")&&(m="other"),m};var o={backspace:[8],del:[46],delete:[46],ins:[45],insert:[45],tab:[9],enter:[13],return:[13],esc:[27],space:[32],pageup:[33],pagedown:[34],end:[35],home:[36],left:[37],up:[38],right:[39],down:[40],shift:[16],ctrl:[17],alt:[18],cap:[20],num:[144],clear:[12],meta:[91],";":[186,59],"=":[187,61],",":[188,44],"-":[189,45,173,109],minus:[189,45,173,109],".":[190,110],"/":[191,111],"`":[192],"[":[219],"\\":[220],"]":[221],"*":[106],"+":[107],plus:[107],"'":[222],quote:[222]},g=Object.keys(o).reduce(function(r,u){return Object.assign(r,s({},u.toUpperCase(),o[u]))},{}),S="0123456789".split("").reduce(function(r,u,m){return Object.assign(r,s({},u,[m+48,m+96]))},{}),b="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce(function(r,u,m){return Object.assign(r,s({},u.toLowerCase(),[m+65]),s({},u,[m+65]))},{}),T="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19".split(",").reduce(function(r,u,m){return Object.assign(r,s({},"f"+u,[m+112]))},{}),E={control:"ctrl",ctrl:"ctrl",shift:"shift",meta:"meta",cmd:"meta",command:"meta",option:"alt",alt:"alt"},_=v.AllKeys=Object.assign({},o,g,S,b,T),t=Object.assign({},S,b),l={all:Object.keys(_),alphanumeric:Object.keys(t),numeric:Object.keys(S),alphabetic:Object.keys(b),function:Object.keys(T)};function i(r,u){var m=r.which||r.keyCode,y=r.type,h=Object.keys(E).filter(function(A){return r[A+"Key"]}).sort(),I=u.toLowerCase().trim(),L=I==="+"?["+"]:I.split(/\s?\+\s?/),R=L.pop(),x=_[R],w=L;if(y==="keypress")return u==String.fromCharCode(m).toLowerCase();if(w.length===0&&h.length===0)return x.indexOf(m)>=0;if(w.length>0&&h.length>0){var q=w.map(function(A){return E[A]}).sort(),F=q.length===h.length&&q.every(function(A,H){return h[H]===A});return x.indexOf(m)>=0&&F}return w.length==0&&h.length===1&&R===h[0]}}])})})(we);var fn=we.exports;const gn=We(fn),Re=()=>{const e=N.useRef(null);return[e,()=>{e.current&&e.current.focus()}]},Le=()=>{const[e,n]=N.useState(!1);return N.useEffect(()=>{(async()=>{document.fonts&&await document.fonts.ready.then(()=>n(!0))})()},[]),e};var vn=typeof performance=="object"&&typeof performance.now=="function",ve=vn?function(){return performance.now()}:function(){return Date.now()};function ye(e){cancelAnimationFrame(e.id)}function yn(e,n){var a=ve();function d(){ve()-a>=n?e.call(null):c.id=requestAnimationFrame(d)}var c={id:requestAnimationFrame(d)};return c}var oe=-1;function he(e){if(e===void 0&&(e=!1),oe===-1||e){var n=document.createElement("div"),a=n.style;a.width="50px",a.height="50px",a.overflow="scroll",document.body.appendChild(n),oe=n.offsetWidth-n.clientWidth,document.body.removeChild(n)}return oe}var ee=null;function be(e){if(e===void 0&&(e=!1),ee===null||e){var n=document.createElement("div"),a=n.style;a.width="50px",a.height="50px",a.overflow="scroll",a.direction="rtl";var d=document.createElement("div"),c=d.style;return c.width="100px",c.height="100px",n.appendChild(d),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 hn=150,bn=function(n,a){return n};function Sn(e){var n,a=e.getItemOffset,d=e.getEstimatedTotalSize,c=e.getItemSize,v=e.getOffsetForIndexAndAlignment,f=e.getStartIndexForOffset,s=e.getStopIndexForStartIndex,o=e.initInstanceProps,g=e.shouldResetStyleCacheOnItemSizeChange,S=e.validateProps;return n=function(b){Ve(T,b);function T(_){var t;return t=b.call(this,_)||this,t._instanceProps=o(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(l,i,r,u){return t.props.onItemsRendered({overscanStartIndex:l,overscanStopIndex:i,visibleStartIndex:r,visibleStopIndex:u})}),t._callOnScroll=void 0,t._callOnScroll=le(function(l,i,r){return t.props.onScroll({scrollDirection:l,scrollOffset:i,scrollUpdateWasRequested:r})}),t._getItemStyle=void 0,t._getItemStyle=function(l){var i=t.props,r=i.direction,u=i.itemSize,m=i.layout,y=t._getItemStyleCache(g&&u,g&&m,g&&r),h;if(y.hasOwnProperty(l))h=y[l];else{var I=a(t.props,l,t._instanceProps),L=c(t.props,l,t._instanceProps),R=r==="horizontal"||m==="horizontal",x=r==="rtl",w=R?I:0;y[l]=h={position:"absolute",left:x?void 0:w,right:x?w:void 0,top:R?0:I,height:R?"100%":L,width:R?L:"100%"}}return h},t._getItemStyleCache=void 0,t._getItemStyleCache=le(function(l,i,r){return{}}),t._onScrollHorizontal=function(l){var i=l.currentTarget,r=i.clientWidth,u=i.scrollLeft,m=i.scrollWidth;t.setState(function(y){if(y.scrollOffset===u)return null;var h=t.props.direction,I=u;if(h==="rtl")switch(be()){case"negative":I=-u;break;case"positive-descending":I=m-r-u;break}return I=Math.max(0,Math.min(I,m-r)),{isScrolling:!0,scrollDirection:y.scrollOffset<I?"forward":"backward",scrollOffset:I,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._onScrollVertical=function(l){var i=l.currentTarget,r=i.clientHeight,u=i.scrollHeight,m=i.scrollTop;t.setState(function(y){if(y.scrollOffset===m)return null;var h=Math.max(0,Math.min(m,u-r));return{isScrolling:!0,scrollDirection:y.scrollOffset<h?"forward":"backward",scrollOffset:h,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._outerRefSetter=function(l){var i=t.props.outerRef;t._outerRef=l,typeof i=="function"?i(l):i!=null&&typeof i=="object"&&i.hasOwnProperty("current")&&(i.current=l)},t._resetIsScrollingDebounced=function(){t._resetIsScrollingTimeoutId!==null&&ye(t._resetIsScrollingTimeoutId),t._resetIsScrollingTimeoutId=yn(t._resetIsScrolling,hn)},t._resetIsScrolling=function(){t._resetIsScrollingTimeoutId=null,t.setState({isScrolling:!1},function(){t._getItemStyleCache(-1,null)})},t}T.getDerivedStateFromProps=function(t,l){return _n(t,l),S(t),null};var E=T.prototype;return E.scrollTo=function(t){t=Math.max(0,t),this.setState(function(l){return l.scrollOffset===t?null:{scrollDirection:l.scrollOffset<t?"forward":"backward",scrollOffset:t,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},E.scrollToItem=function(t,l){l===void 0&&(l="auto");var i=this.props,r=i.itemCount,u=i.layout,m=this.state.scrollOffset;t=Math.max(0,Math.min(t,r-1));var y=0;if(this._outerRef){var h=this._outerRef;u==="vertical"?y=h.scrollWidth>h.clientWidth?he():0:y=h.scrollHeight>h.clientHeight?he():0}this.scrollTo(v(this.props,t,l,m,this._instanceProps,y))},E.componentDidMount=function(){var t=this.props,l=t.direction,i=t.initialScrollOffset,r=t.layout;if(typeof i=="number"&&this._outerRef!=null){var u=this._outerRef;l==="horizontal"||r==="horizontal"?u.scrollLeft=i:u.scrollTop=i}this._callPropsCallbacks()},E.componentDidUpdate=function(){var t=this.props,l=t.direction,i=t.layout,r=this.state,u=r.scrollOffset,m=r.scrollUpdateWasRequested;if(m&&this._outerRef!=null){var y=this._outerRef;if(l==="horizontal"||i==="horizontal")if(l==="rtl")switch(be()){case"negative":y.scrollLeft=-u;break;case"positive-ascending":y.scrollLeft=u;break;default:var h=y.clientWidth,I=y.scrollWidth;y.scrollLeft=I-h-u;break}else y.scrollLeft=u;else y.scrollTop=u}this._callPropsCallbacks()},E.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&ye(this._resetIsScrollingTimeoutId)},E.render=function(){var t=this.props,l=t.children,i=t.className,r=t.direction,u=t.height,m=t.innerRef,y=t.innerElementType,h=t.innerTagName,I=t.itemCount,L=t.itemData,R=t.itemKey,x=R===void 0?bn:R,w=t.layout,q=t.outerElementType,F=t.outerTagName,A=t.style,H=t.useIsScrolling,K=t.width,$=this.state.isScrolling,k=r==="horizontal"||w==="horizontal",P=k?this._onScrollHorizontal:this._onScrollVertical,Z=this._getRangeToRender(),te=Z[0],re=Z[1],X=[];if(I>0)for(var z=te;z<=re;z++)X.push(N.createElement(l,{data:L,key:x(z,L),index:z,isScrolling:H?$:void 0,style:this._getItemStyle(z)}));var J=d(this.props,this._instanceProps);return N.createElement(q||F||"div",{className:i,onScroll:P,ref:this._outerRefSetter,style:Ke({position:"relative",height:u,width:K,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:r},A)},N.createElement(y||h||"div",{children:X,ref:m,style:{height:k?"100%":J,pointerEvents:$?"none":void 0,width:k?J:"100%"}}))},E._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var t=this.props.itemCount;if(t>0){var l=this._getRangeToRender(),i=l[0],r=l[1],u=l[2],m=l[3];this._callOnItemsRendered(i,r,u,m)}}if(typeof this.props.onScroll=="function"){var y=this.state,h=y.scrollDirection,I=y.scrollOffset,L=y.scrollUpdateWasRequested;this._callOnScroll(h,I,L)}},E._getRangeToRender=function(){var t=this.props,l=t.itemCount,i=t.overscanCount,r=this.state,u=r.isScrolling,m=r.scrollDirection,y=r.scrollOffset;if(l===0)return[0,0,0,0];var h=f(this.props,y,this._instanceProps),I=s(this.props,h,y,this._instanceProps),L=!u||m==="backward"?Math.max(1,i):1,R=!u||m==="forward"?Math.max(1,i):1;return[Math.max(0,h-L),Math.max(0,Math.min(l-1,I+R)),h,I]},T}(N.PureComponent),n.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},n}var _n=function(n,a){n.children,n.direction,n.height,n.layout,n.innerTagName,n.outerTagName,n.width,a.instance},Tn=Sn({getItemOffset:function(n,a){var d=n.itemSize;return a*d},getItemSize:function(n,a){var d=n.itemSize;return d},getEstimatedTotalSize:function(n){var a=n.itemCount,d=n.itemSize;return d*a},getOffsetForIndexAndAlignment:function(n,a,d,c,v,f){var s=n.direction,o=n.height,g=n.itemCount,S=n.itemSize,b=n.layout,T=n.width,E=s==="horizontal"||b==="horizontal",_=E?T:o,t=Math.max(0,g*S-_),l=Math.min(t,a*S),i=Math.max(0,a*S-_+S+f);switch(d==="smart"&&(c>=i-_&&c<=l+_?d="auto":d="center"),d){case"start":return l;case"end":return i;case"center":{var r=Math.round(i+(l-i)/2);return r<Math.ceil(_/2)?0:r>t+Math.floor(_/2)?t:r}case"auto":default:return c>=i&&c<=l?c:c<i?i:l}},getStartIndexForOffset:function(n,a){var d=n.itemCount,c=n.itemSize;return Math.max(0,Math.min(d-1,Math.floor(a/c)))},getStopIndexForStartIndex:function(n,a,d){var c=n.direction,v=n.height,f=n.itemCount,s=n.itemSize,o=n.layout,g=n.width,S=c==="horizontal"||o==="horizontal",b=a*s,T=S?g:v,E=Math.ceil((T+d-b)/s);return Math.max(0,Math.min(f-1,a+E-1))},initInstanceProps:function(n){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(n){n.itemSize}});const En="_layerContainer_1lbvo_1",In="_layer_1lbvo_1",On="_small_1lbvo_23",wn="_heading_1lbvo_26",Rn="_option_1lbvo_27",Ln="_message_1lbvo_28",xn="_focused_1lbvo_64",Cn="_selected_1lbvo_68",qn="_disabled_1lbvo_71",Mn="_check_1lbvo_75",Nn="_optionContent_1lbvo_92",Fn="_label_1lbvo_97",An="_icon_1lbvo_104",jn="_details_1lbvo_109",j={layerContainer:En,layer:In,small:On,heading:wn,option:Rn,message:Ln,focused:xn,selected:Cn,disabled:qn,check:Mn,optionContent:Nn,label:Fn,icon:An,details:jn},xe=({label:e})=>p.jsx("div",{onClick:n=>n.stopPropagation(),className:j.heading,children:e});xe.__docgenInfo={description:"",methods:[],displayName:"Heading",props:{label:{required:!0,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const Ce=({details:e,label:n,icon:a,disabled:d=!1,selected:c=!1,focused:v=!1,onSelectOption:f,actions:s,closeLayer:o,testId:g})=>p.jsxs("div",{className:G(j.option,d?j.disabled:"",c?j.selected:"",v?j.focused:""),onClick:!d&&f?f:void 0,"data-testid":g,children:[p.jsx("div",{className:j.optionContent,children:p.jsxs("span",{className:j.label,title:n,children:[n,a&&p.jsx("span",{className:j.icon,children:a})]})}),e&&p.jsx("div",{className:G(j.details),children:p.jsx(ue,{faint:!0,children:e})}),!!(s!=null&&s.length)&&p.jsx("div",{className:G(j.actions),children:p.jsx(Ye,{actions:s,closeLayer:o})}),p.jsx("span",{className:j.check,children:c?p.jsx(ce,{icon:Ie.CHECK}):null})]});Ce.__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:a,onSelectOption:d,closeLayer:c})=>{const v=N.useContext(me);switch(e.type){case se.HEADING:return p.jsx(xe,{label:e.label});case se.OPTION:default:return p.jsx(Ce,{closeLayer:c,actions:e.actions,label:e.label,details:e.details,icon:e.icon,disabled:e.disabled||v,selected:n,focused:a,onSelectOption:d,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 d=document.createElement("canvas").getContext("2d");return d?(d.font=n,d.measureText(e).width):0},Me="13px",Ne="12px",Hn="Roobert",kn="sans-serif",Pn=12,Dn=8,zn=30,Wn=24,Un=5,Gn=3,$n=1,Vn=2,Se=10,Fe=(e=!1,n=!1)=>`${e?Ne:Me} ${n?Hn:kn}`,Kn=(e=!1,n=!1)=>(e?Dn:Pn)+(e?Wn:zn)+(n?17:0),_e=(e,n,a,d)=>{const c=Fe(n,a),v=d?de(d,c):0,f=Math.ceil(e.reduce((o,g)=>{var _;const S=(((_=g==null?void 0:g.actions)==null?void 0:_.length)??0)*24,b=g.icon?parseInt(n?Ne:Me)+7:0,T=`${g.label} ${g.details||""}`,E=de(T,c)+S+b;return o=E>o?E:o,o},v)),s=Kn(n,!0);return f+s},Yn=(e,n,a)=>{const d=Fe(!0,a),c=de(e.label,d),v=(n?Gn:Un)*2+$n*2+Vn;return Math.ceil(c+v)},Ae=({listRef:e,isMulti:n,sections:a,selectedOptions:d,onSelectOption:c,focusedOptionIndex:v,width:f,small:s,firstSelectedOptionIndex:o,closeLayer:g,testId:S})=>{N.useEffect(()=>{o&&o!==null&&e.current!==null&&e.current.scrollToItem(o,"start")},[o,e]);const b=s?24:30;return p.jsx("div",{"data-testid":S,className:G(j.layer,s&&j.small),children:a.length?p.jsx(Tn,{ref:e,height:a.length<Se?b*a.length:b*Se,itemCount:a.length,itemSize:b,width:f,children:({index:T,style:E})=>{var _;return p.jsx("div",{style:E,children:p.jsx(qe,{closeLayer:g,section:a[T],selected:n&&a[T].type!==se.HEADING&&Array.isArray(d)?d.some(t=>{var l;return t&&(t==null?void 0:t.value)===((l=a==null?void 0:a[T])==null?void 0:l.value)}):!Array.isArray(d)&&((_=a==null?void 0:a[T])==null?void 0:_.value)===(d==null?void 0:d.value),focused:v===T,onSelectOption:t=>c(t,a[T])})})}}):p.jsx("ul",{children:p.jsx("li",{children:p.jsx("div",{className:j.message,style:{width:f},children:"No matches"})})})})};Ae.__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 Bn="_inputInTable_nec64_1",Zn="_error_nec64_7",Xn="_warning_nec64_7",Jn="_inputHover_nec64_13",Qn="_inputFocus_nec64_18",et="_inputError_nec64_25",nt="_inputWarning_nec64_26",tt="_inputDisabled_nec64_61",rt="_hideScrollbars_nec64_67",at="_trigger_nec64_77",it="_isInTable_nec64_93",st="_input_nec64_1",lt="_isOpen_nec64_114",ot="_disabled_nec64_156",ut="_icons_nec64_162",ct="_clearAll_nec64_169",dt="_iconOpen_nec64_170",mt="_small_nec64_181",pt="_triggerInputContainer_nec64_189",ft="_right_nec64_198",gt="_multiOptions_nec64_211",vt="_multiOption_nec64_211",yt="_label_nec64_239",ht="_closeMultiOption_nec64_242",bt="_focus_nec64_253",St="_selectedSingleValue_nec64_257",_t="_placeHolder_nec64_258",Tt="_groupOrderFirst_nec64_297",Et="_groupOrderMiddle_nec64_298",It="_groupOrderLast_nec64_302",Ot="_detailedLabel_nec64_307",M={inputInTable:Bn,error:Zn,warning:Xn,inputHover:Jn,inputFocus:Qn,inputError:et,inputWarning:nt,inputDisabled:tt,hideScrollbars:rt,trigger:at,isInTable:it,input:st,isOpen:lt,disabled:ot,icons:ut,clearAll:ct,iconOpen:dt,small:mt,triggerInputContainer:pt,right:ft,multiOptions:gt,multiOption:vt,label:yt,closeMultiOption:ht,focus:bt,selectedSingleValue:St,placeHolder:_t,groupOrderFirst:Tt,groupOrderMiddle:Et,groupOrderLast:It,detailedLabel:Ot},je=({selectedOptions:e,small:n,width:a,testId:d})=>{const c=Le(),[v,f]=N.useState([]),[s,o]=N.useState([]);return N.useEffect(()=>{let g=[],S=[],b=0;e.forEach((T,E)=>{b+=Yn(T,n,c),E===e.length-1&&b<a||b<a-24?g.push(T):S.push(T)}),f(g),o(S)},[e,c,a]),p.jsxs("div",{className:M.multiOptions,"data-testid":d&&`${d}-value`,children:[v.filter(g=>g&&g.label).map((g,S)=>p.jsx("span",{className:M.multiOption,onClick:b=>{b.stopPropagation()},children:g.label},S)),s.length>0&&p.jsx(pe,{text:s.map((g,S)=>p.jsx("div",{children:g.label},S)),display:"inline-flex",children:p.jsx("span",{className:M.multiOption,children:v.length?`+${s.length}`:`${s.length} items`})})]})};je.__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 He=({selectedOptions:e,searchable:n=!1,searchValue:a,onChange:d=ae.noop,inputRef:c,error:v,placeholder:f="Select...",small:s,testId:o})=>{const g=N.useRef(null),S=Array.isArray(e),b=S?e.length>0:!!e,T=a?a.length+1:1,E=()=>{var l,i;const _=((l=g.current)==null?void 0:l.offsetWidth)||0,t=((i=c.current)==null?void 0:i.offsetWidth)||0;return _-t};return p.jsxs("div",{className:M.triggerInputContainer,ref:g,children:[b?S?p.jsx(je,{selectedOptions:e,small:s,width:E(),testId:o}):p.jsx("span",{className:M.selectedSingleValue,"data-testid":o&&`${o}-value`,children:a!=null&&a.length?"":e==null?void 0:e.label}):p.jsx("span",{className:M.placeHolder,children:a!=null&&a.length?"":f}),n?p.jsx("input",{tabIndex:-1,ref:c,size:T,className:G(M.input,v?M.error:""),value:a,onChange:_=>d(_.target.value),"data-testid":o&&`${o}-input`}):null]})};He.__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 ke=({selectedOptions:e,searchValue:n,searchable:a,clearable:d,onClickTrigger:c,element:v,error:f,warning:s,tooltip:o,small:g,isInTable:S,disabled:b,onChangeSearch:T,onClickDeselect:E,onClickClear:_,tabIndex:t,isOpen:l,triggerRef:i,clearAllIsFocused:r,focusedSelectedOptionIndex:u,onFocus:m,onBlur:y,groupOrder:h,maxTooltipWidth:I,placeholder:L,right:R,testId:x})=>{var k;const[w,q]=Re(),F=Array.isArray(e)?e.length>0&&((k=e[0])==null?void 0:k.value):e==null?void 0:e.value,A=d&&F,H=(()=>{if(h)switch(h){case ie.FIRST:return M.groupOrderFirst;case ie.LAST:return M.groupOrderLast;default:return M.groupOrderMiddle}return""})(),K=!Array.isArray(e)&&(e!=null&&e.details)?{...e,label:p.jsxs("div",{className:G(M.detailedLabel),children:[p.jsx(ue,{children:e.label}),p.jsx(ue,{muted:!0,children:e.details})]})}:e,$=p.jsxs(p.Fragment,{children:[v,p.jsxs("div",{ref:i,tabIndex:t,className:G(M.trigger,l?M.isOpen:"",f?M.error:s?M.warning:"",b?M.disabled:"",g?M.small:"",S?M.isInTable:"",R?M.right:"",H),onClick:P=>{P.stopPropagation(),typeof q=="function"&&q(),c(P)},onFocus:m,onBlur:y,"data-testid":x,children:[p.jsx(He,{selectedOptions:K,placeholder:L,searchable:a,searchValue:n,inputRef:w,onChange:T,error:f,small:g,testId:x}),p.jsx("span",{className:M.icons,children:A?p.jsx("span",{className:G(M.clearAll,r?M.focus:""),onClick:P=>{P.stopPropagation(),_&&_(P)},"data-testid":x&&`${x}-clear`,children:p.jsx(ce,{icon:Ie.CLOSE})}):p.jsx("span",{className:G(M.iconOpen),children:p.jsx(ce,{icon:"chevron down"})})})]})]});return p.jsx(p.Fragment,{children:p.jsx(pe,{error:!!f,warning:!!s,text:o||f||s,enabled:o&&ne(o)||f&&ne(f)||s&&ne(s)||!1,maxWidth:I,placement:"bottom-center",children:$})})};ke.__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 U=(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))(U||{});const Pe={options:["none","clearAll"],currentIndex:0,currentOption:!1,clearAll:!1},wt=e=>e!==null?e+1:0,De=(e,n)=>{const a=["none",...e.map((c,v)=>c.type!==se.HEADING?v:null).filter(c=>c!==null)],d=wt(n);return{options:a,currentIndex:d,current:a[d]}},Rt=(e,n)=>{const a=e==="up"?-1:1,d=n.currentIndex+a,c=(d<0?n.options.length-1:d)%n.options.length,v=n.options[c];return{...n,currentIndex:c,current:v}},Lt=(e,n,a)=>{const d=e==="left"?-1:1,c=n&&n.length?["none",...Array.from({length:n.length},(g,S)=>S),"clearAll"]:["none","clearAll"],v=a.currentIndex+d,f=(v<0?c.length-1:v)%c.length,s=c[f];return{options:c,currentIndex:f,currentOption:s,clearAll:s==="clearAll"}},Te=()=>Pe,Ee=e=>({...e,currentIndex:0,current:"none"}),xt=(e,n)=>{switch(n.type){case U.SET_VISIBLE_OPTIONS:return{...e,visibleOptions:n.options||[]};case U.RESET_LAYER_FOCUS:return{...e,layerFocus:De(n.options||[],n.firstSelectedOptionIndex||0)};case U.CLEAR_SEARCH:return{...e,visibleOptions:n.options||[],searchValue:""};case U.ON_CHANGE_SEARCH:{let d=[...(n.options||[]).filter(c=>(String(c.label)+(c.details?String(c.details):"")).toLowerCase().includes(String(n.value||"").toLowerCase()))];return n.createAble&&n.value&&n.value!==""&&d.push({label:`Create "${n.value}"`,value:n.value,createAble:!0}),{...e,searchValue:n.value,visibleOptions:d,layerFocus:Ee(e.layerFocus)}}case U.FOCUS_TRIGGER_INPUTS:return{...e,triggerFocus:Lt(n.direction||"right",n.selectedOptions||[],e.triggerFocus),layerFocus:Ee(e.layerFocus)};case U.BLUR_TRIGGER_INPUTS:return{...e,triggerFocus:Te()};case U.FOCUS_LAYER_OPTIONS:return n.nextLayerFocus?{...e,layerFocus:n.nextLayerFocus,triggerFocus:Te()}:e;case U.OPEN_LAYER:return{...e,isLayerOpen:!0};case U.CLOSE_LAYER:return{...e,isLayerOpen:!1};default:return e}},Ct={auto:!0,possiblePlacements:["bottom-start","top-start"],placement:"bottom-start",preferX:"right",preferY:"bottom"};var D=(e=>(e.CLOSE_LAYER="CLOSE_LAYER",e.OPEN_LAYER="OPEN_LAYER",e.SET_VISIBLE_OPTIONS="SET_VISIBLE_OPTIONS",e.CLEAR_SEARCH="CLEAR_SEARCH",e.RESET_LAYER_FOCUS="RESET_LAYER_FOCUS",e.FOCUS_LAYER_OPTIONS="FOCUS_LAYER_OPTIONS",e.BLUR_TRIGGER_INPUTS="BLUR_TRIGGER_INPUTS",e.FOCUS_TRIGGER_INPUTS="FOCUS_TRIGGER_INPUTS",e.ON_CHANGE_SEARCH="ON_CHANGE_SEARCH",e))(D||{}),V=(e=>(e.RIGHT="right",e.LEFT="left",e.UP="up",e.DOWN="down",e.ENTER="enter",e.ESC="esc",e.TAB="tab",e))(V||{});const qt=({state:e,dispatch:n,options:a,setTriggerFocus:d,disabled:c,disabledContext:v,onCreate:f,onChange:s,selectedOptions:o,width:g,small:S,isFontLoaded:b,placeholder:T,firstSelectedOptionIndex:E,createAble:_,listRef:t,autoLayerWidth:l})=>{const i=()=>{e.isLayerOpen&&n({type:D.CLOSE_LAYER}),d()},r=()=>n({type:D.OPEN_LAYER}),u=N.useRef(!0);N.useEffect(()=>{u.current?u.current=!1:n({type:D.SET_VISIBLE_OPTIONS,options:a})},[a]);const m=(O,C,Q)=>{if(!(c||v)){if(Q&&Q(),C){if(C.createAble&&f)f(C.value);else if(!C.disabled)if(Array.isArray(o))if(o.some(B=>B.label===C.label)){const B=o.filter(fe=>fe.label!==C.label);s&&s(O,B)}else{const B=[...o,C];s&&s(O,B)}else s&&s(O,C)}n({type:D.CLEAR_SEARCH,options:a}),d()}},y=N.useCallback(()=>g?g!=="auto"?g:_e(a,S,b,T):"100%",[a,b]),h=N.useCallback(O=>l?Math.max(_e(a,S,b,T),O==null?void 0:O.width):O==null?void 0:O.width,[a,b]),{renderLayer:I,layerProps:L,triggerProps:R,triggerBounds:x}=Ue({isOpen:(e==null?void 0:e.isLayerOpen)??!1,overflowContainer:!0,...Ct,ResizeObserver,onOutsideClick:i,onParentClose:i}),w=()=>{if(!(c||v)){if(e.isLayerOpen){i();return}n({type:D.RESET_LAYER_FOCUS,options:a,firstSelectedOptionIndex:E}),r()}},q=N.useRef(!0);N.useEffect(()=>{q.current?q.current=!1:e.isLayerOpen||n({type:D.CLEAR_SEARCH,options:a})},[e.isLayerOpen]);const F=(O,C)=>{const Q=o instanceof Array?o.filter(Y=>Y.value!==C.value):null;s&&s(O,Q)},A=O=>{const C=o instanceof Array?[]:{value:null};s&&s(O,C)},H=O=>n({type:D.ON_CHANGE_SEARCH,options:a,value:O,createAble:_}),K=()=>{r(),n({type:D.BLUR_TRIGGER_INPUTS})},$=O=>{t.current&&Number.isInteger(O)&&t.current.scrollToItem(O)},k=O=>{const C=Rt(O,e.layerFocus);n({type:D.FOCUS_LAYER_OPTIONS,nextLayerFocus:C}),$(C.current)},P=O=>{n({type:D.FOCUS_TRIGGER_INPUTS,ICustomSelectDirection:O,selectedOptions:o})},Z=O=>A(O),te=o&&o[e.triggerFocus.currentOption],re=O=>{F(O,o[e.triggerFocus.currentOption])},X=O=>{var C;m(O,(C=e==null?void 0:e.visibleOptions)==null?void 0:C[e.layerFocus.current],i)},z=e.triggerFocus.clearAll;return{getTriggerWidth:y,onKeyEvent:(O,C)=>{switch(O){case V.UP:{k(O);break}case V.DOWN:{e.isLayerOpen?k(O):K();break}case V.LEFT:case V.RIGHT:{P(O);break}case V.ENTER:{z?Z(C):te?re(C):X(C);break}case V.ESC:{i();break}}},clearAllIsFocused:z,triggerProps:R,onClickTrigger:w,onChangeSearch:H,onClickDeselectOption:F,onClickClearAll:A,renderLayer:I,layerProps:L,closeLayer:i,onSelectOption:m,getLayerWidth:h,triggerBounds:x}},ze=e=>{const{multi:n=!1,disabled:a=!1,error:d=null,warning:c=null,tooltip:v=null,options:f,selectedOptions:s,onCreate:o=null,placeholder:g="",small:S=!1,tabIndex:b=0,onFocus:T=()=>{},onBlur:E=()=>{},searchable:_=!0,clearable:t=!1,maxTooltipWidth:l,closeOnOptionActionClick:i,isInTable:r=!1,groupOrder:u,firstSelectedOptionIndex:m=0,right:y=!1,testId:h=void 0}=e,I=N.useContext(me),L=o!==null,R=N.useRef(null),[x,w]=Re(),q=Le(),[F,A]=N.useReducer(xt,{options:f,firstSelectedOptionIndex:m},({options:Y})=>({searchValue:"",visibleOptions:Y,layerFocus:De(Y,m??0),triggerFocus:Pe,isLayerOpen:!1})),{getTriggerWidth:H,onKeyEvent:K,clearAllIsFocused:$,triggerProps:k,onClickTrigger:P,onChangeSearch:Z,onClickDeselectOption:te,onClickClearAll:re,renderLayer:X,layerProps:z,closeLayer:J,onSelectOption:O,getLayerWidth:C,triggerBounds:Q}=qt({...e,state:F,dispatch:A,setTriggerFocus:w,disabledContext:I,isFontLoaded:q,createAble:L,listRef:R});return p.jsx("div",{style:{width:H()},children:p.jsxs(gn,{handleKeys:Object.values(V),onKeyEvent:K,children:[p.jsx(ke,{selectedOptions:s,searchValue:F.searchValue,isOpen:F.isLayerOpen,focusedSelectedOptionIndex:F.triggerFocus.currentOption,clearAllIsFocused:$,searchable:_,triggerRef:Ge(x,k.ref),error:d,warning:c,tooltip:v,small:S,isInTable:r,disabled:a||I,clearable:t,tabIndex:b,onClickTrigger:P,onChangeSearch:Z,onClickDeselect:te,onClickClear:re,onFocus:T,onBlur:E,groupOrder:u,maxTooltipWidth:l,placeholder:g,right:y,testId:h}),F.isLayerOpen&&X(p.jsx("div",{...z,className:j.layerContainer,children:p.jsx(Ae,{listRef:R,isMulti:n,sections:F.visibleOptions,selectedOptions:s,onSelectOption:(Y,B)=>{O(Y,B,n?void 0:J)},closeLayer:()=>{i&&J()},width:C(Q),small:S,focusedOptionIndex:F.layerFocus.current,firstSelectedOptionIndex:m??0,testId:h&&`${h}-layer`})}))]})})};ze.__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 Mt=e=>{const{name:n="",options:a=[],value:d,native:c=!1,onChange:v=ae.noop,deprecatedEventHandler:f=!1,autoScroll:s=!0,warning:o,error:g,checkNonExistentValues:S=!0,closeOnOptionActionClick:b=!0,testId:T,disabled:E}=e,_=!c&&s===!0,{multi:t,simpleInputs:l,options:i,selectedOptions:r,firstSelectedOptionIndex:u,hasNonExistentValue:m}=Be(a,d,_,S),y=!t,h=c&&y;c&&!y&&console.warn("Native select does not support provided props (see stories)");const I="Value no longer available for re-selection",L=m&&!E?o?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:o})]}):I:o,R=m&&g&&!E?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:g})]}):g,x=(w,q)=>{if(f){const F=t?q.map(A=>l?A.value:A):l?q.value:q;F&&v(F)}else{const F=!(w instanceof Event),A=t?q:q.value;if(F)w.target.name=n,w.target.value=A,t||(w.target.label=q.label),v(w);else{const H={...w,target:{...w.target,name:n,value:A,label:t?void 0:q.label}};v(H)}}};return h?p.jsx(Oe,{...e,options:i,selectedOption:r,onChange:x,hasNonExistentValue:m,warning:L,error:R,testId:T}):p.jsx(ze,{...e,options:i,selectedOptions:r,onChange:x,multi:t,firstSelectedOptionIndex:u,warning:L,error:R,testId:T,closeOnOptionActionClick:b})};Mt.__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{V as E,gn as K,Mt as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as y}from"./types-BmbYqTX_.js";const c=r=>r==null||r==="",o=r=>r instanceof Array,v=(r,n)=>n&&Array.isArray(r)?r.map(t=>typeof t=="string"||typeof t=="number"?{label:t,value:t}:t):r,f=(r,n)=>{if(n!==null&&typeof n=="object"&&n.hasOwnProperty("label")&&n.hasOwnProperty("value"))return n;{const t=n!==null&&typeof n=="object"&&n.hasOwnProperty("value")?n.value:n;return(Array.isArray(r)?r.filter(e=>e.type!==y.HEADING).find(e=>e.value==t):void 0)||(c(t)?void 0:{value:t,label:t})}},p=(r,n)=>o(n)?n.map(u=>f(r,u)).filter(u=>u!==void 0):n===null?void 0:f(r,n),A=r=>Array.isArray(r)&&r.some(n=>typeof n=="string"||typeof n=="number"),b=(r,n)=>{const t=n instanceof Array?n.length?n[0]:null:n,u=t==null?null:typeof t=="string"||typeof t=="number"?t:t.value,e=r.filter(l=>l.type!==y.HEADING).findIndex(l=>typeof l=="string"||typeof l=="number"?l==u:l.value==u);return e===-1?null:e},S=(r,n)=>!(o(n)?n:c(n)?[]:[n]).every(e=>r.find(a=>a.value===e.value)!==void 0),I=(r,n,t,u)=>{const e=Array.isArray(r)?r:[],l=o(n),a=A(e),s=v(e,a),d=t?b(e,n):null,i=p(s,n),m=u&&i!==void 0?S(s,i):!1;return{options:s,selectedOptions:i,multi:l,simpleInputs:a,firstSelectedOptionIndex:d,hasNonExistentValue:m}};export{c as i,I as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJvc.js";import{w as i,e as o,u as c}from"./index-DMAnyMX5.js";import{S as z}from"./select-
|
|
1
|
+
import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJvc.js";import{w as i,e as o,u as c}from"./index-DMAnyMX5.js";import{S as z}from"./select-DnRuRG_N.js";import{S as qa}from"./spacer-BWoNR27H.js";import{I as Z}from"./common-types-Sih75Sav.js";import{I as $}from"./icon-BSFY3vDO.js";import"./index-CF7H4eMJ.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.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-D-uVCDzk.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-D0UkAPd9.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const _a=[{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Koalas",value:"leaves"},{label:"Monkeys",value:"bananas",disabled:!0},{label:"Wombats",value:"bark"}],Fa=[{label:"Kangaroos",value:"grass",details:"(grass)"},{label:"Monkeys",value:"bananas",details:"(bananas)"},{label:"Possums",value:"slugs",details:"(slugs)"}],Ga=[{type:"Heading",label:"Large"},{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{type:"Heading",label:"Small"},{label:"Possums",value:"slugs"}],Ya=[{label:1,value:1},{label:2,value:2},{label:3,value:3},{label:4,value:4}],Za=[{label:"Yes",value:!0},{label:"No",value:!1}],$a=[{label:"Aardvarks",value:"termites"},{label:"Monkeys",value:"bananas"},{label:"Vampires",value:"blood",icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"})},{label:"Zombies",value:"brains",icon:d.jsx($,{icon:Z.ERROR,color:"var(--color-text-error)"})}],y=[{label:"Delete",icon:"delete",onClick:()=>{}},{label:"Rename",icon:"rename",onClick:()=>{}}],za=[{label:"Kangaroos",value:"grass",actions:y},{label:"Monkeys",value:"bananas",actions:y},{label:"Possums",value:"slugs",actions:y,details:"(some details)"}],Ja=[{label:"Kangaroos",value:"grass",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(grass)"},{label:"Monkeys",value:"bananas",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(bananas)"},{label:"Possums",value:"slugs",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(slugs)"}],Qa=[...Array(1e4).keys()].map((t,l)=>({label:Math.random().toString(36).substring(7),value:l})),Ua=["Aardvarks","Kangaroos","Monkeys","Possums"],Tn={title:"Forms/Select",component:z,args:{options:_a,native:!1,multi:!1,disabled:!1,autoLayerWidth:!1,clearable:!1,searchable:!0,right:!1}},a=t=>{const{multi:l,value:e}=t,[s,n]=b.useState(e||(l?[]:void 0)),u=r=>{const{value:g}=r.target;n(l?g:{value:g})};return d.jsx(z,{value:s,onChange:u,...t})},J=a.bind({}),C=a.bind({});C.args={small:!0};const x=a.bind({});x.args={width:"auto"};const I=a.bind({});I.args={width:"200px"};const w=a.bind({});w.args={native:!0};const f=a.bind({});f.args={multi:!0,clearable:!0};const T=a.bind({});T.args={options:[]};const B=a.bind({});B.args={clearable:!0};const j=a.bind({});j.args={value:{label:"Vampires",value:"blood"}};const k=a.bind({});k.args={placeholder:"Select the best animal..."};const W=a.bind({});W.args={options:Ga};const O=a.bind({});O.args={options:Fa};const D=a.bind({});D.args={options:$a};const N=a.bind({});N.args={options:za};const A=a.bind({});A.args={options:Ja};const E=a.bind({});E.args={searchable:!1};const M=a.bind({});M.args={right:!0};const v=a.bind({});v.parameters={docs:{description:{story:"Avoid autoLayerWidth for very long lists in custom selects (slow)"}}};v.args={width:"70px",autoLayerWidth:!0};const L=a.bind({});L.args={tooltip:"Some info"};const K=a.bind({});K.args={error:"Some info"};const R=a.bind({});R.args={warning:"Some info"};const P=a.bind({});P.args={disabled:!0};const H=a.bind({});H.args={options:Ya,placeholder:void 0};const _=a.bind({});_.args={options:Za};const q=a.bind({});q.args={options:Ua};const m=a.bind({});m.parameters={docs:{description:{story:"Avoid `width: auto` and autoLayerWidth for very long lists in custom selects (slow). Consider checkNonExistentValues={false}."}}};m.args={options:Qa};const F=a.bind({});F.args={deprecatedEventHandler:!0};const G=a.bind({});G.args={value:{label:"Vampires",value:"blood"},disabled:!0};const Y=()=>{const[t,l]=b.useState([{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{label:"Possums",value:"slugs"}]),[e,s]=b.useState(void 0),[n,u]=b.useState([]);return d.jsxs(d.Fragment,{children:[d.jsx(z,{name:"example",options:t,onChange:r=>s({value:r.target.value}),onCreate:r=>{const g={label:r,value:r};l([...t,g]),s(g)},value:e,clearable:!0}),d.jsx(qa,{}),d.jsx(z,{name:"example",options:t,onChange:r=>u(r.target.value),onCreate:r=>{const g={label:r,value:r};l([...t,g]),console.log(r),u([...n,g])},value:n,multi:!0,clearable:!0})]})},h=a.bind({});h.args={testId:"testId",clearable:!0};h.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&(await l("Select item with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u);const r=e.getByTestId("testId-value");await o(i(r).getByText("Wombats")).toBeInTheDocument()}),await l("Clear selected value",async()=>{const s=e.getByTestId("testId-clear");await c.click(s);const n=e.queryByTestId("testId-value");await o(n).not.toBeInTheDocument()}))};const S=a.bind({});S.args={testId:"testId",clearable:!0,multi:!0};S.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&(await l("Select items with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u);const r=i(n).getByText("Kangaroos");await c.click(r),await c.click(t),await o(n).not.toBeInTheDocument();const g=e.getByTestId("testId-value");await o(i(g).getByText("Wombats")).toBeInTheDocument(),await o(i(g).getByText("Kangaroos")).toBeInTheDocument()}),await l("Deselect item with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u),await c.click(t),await o(n).not.toBeInTheDocument();const r=e.getByTestId("testId-value");await o(i(r).queryByText("Wombats")).not.toBeInTheDocument()}),await l("Clear selected values",async()=>{const s=e.getByTestId("testId-clear");await c.click(s);const n=e.queryByTestId("testId-value");await o(n).not.toBeInTheDocument()}))};const V=a.bind({});V.args={testId:"testId",disabled:!0};V.play=async({canvasElement:t,step:l})=>{const e=i(t);await l("Clicking disabled trigger should not show layer",async()=>{await e.getByTestId("testId").click();const n=e.queryByTestId("testId-layer");await o(n).toBeNull()})};const p=()=>{const[t,l]=b.useState(_a),[e,s]=b.useState(void 0);return d.jsx(z,{testId:"testId",name:"example",options:t,onChange:n=>s({value:n.target.value}),onCreate:n=>{const u={label:n,value:n};l([...t,u]),s(u)},value:e})};p.args={testId:"testId"};p.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&await l("Create new item",async()=>{const s=e.getByTestId("testId-input");if(o(s).toBeInTheDocument(),!s)return;await c.type(s,"New value");const n=e.getByText('Create "New value"');await c.click(n);const u=e.getByTestId("testId-value");await o(i(u).getByText("New value")).toBeInTheDocument()})};Y.__docgenInfo={description:"",methods:[],displayName:"OnCreate"};p.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestCreate"};var Q,U,X;J.parameters={...J.parameters,docs:{...(Q=J.parameters)==null?void 0:Q.docs,source:{originalSource:`(args: any) => {
|
|
2
2
|
const {
|
|
3
3
|
multi,
|
|
4
4
|
value
|
|
@@ -576,4 +576,4 @@ import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJv
|
|
|
576
576
|
setOptions([...options, newValue]);
|
|
577
577
|
setSingleValue(newValue);
|
|
578
578
|
}} value={singleValue} />;
|
|
579
|
-
}`,...(Ha=(Pa=p.parameters)==null?void 0:Pa.docs)==null?void 0:Ha.source}}};const
|
|
579
|
+
}`,...(Ha=(Pa=p.parameters)==null?void 0:Pa.docs)==null?void 0:Ha.source}}};const Bn=["Default","Small","AutoWidth","FixedWidth","Native","Multiselect","Empty","Clearable","NonExistentValue","CustomPlaceholder","OptionsWithHeadings","OptionsWithDetails","OptionsWithIcons","OptionsWithActions","OptionsWithEverything","NotSearchable","RightAligned","AutoLayerWidth","Tooltip","Error","Warning","Disabled","NumericOptions","BooleanOptions","SimpleOptions","VeryLongList","DeprecatedEventHandler","TestDisabledNonExistentValue","OnCreate","Test","TestMulti","TestDisabled","TestCreate"];export{v as AutoLayerWidth,x as AutoWidth,_ as BooleanOptions,B as Clearable,k as CustomPlaceholder,J as Default,F as DeprecatedEventHandler,P as Disabled,T as Empty,K as Error,I as FixedWidth,f as Multiselect,w as Native,j as NonExistentValue,E as NotSearchable,H as NumericOptions,Y as OnCreate,N as OptionsWithActions,O as OptionsWithDetails,A as OptionsWithEverything,W as OptionsWithHeadings,D as OptionsWithIcons,M as RightAligned,q as SimpleOptions,C as Small,h as Test,p as TestCreate,V as TestDisabled,G as TestDisabledNonExistentValue,S as TestMulti,L as Tooltip,m as VeryLongList,R as Warning,Bn as __namedExportsOrder,Tn as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as x}from"./index-DhsZuJvc.js";import{I as j}from"./common-types-Sih75Sav.js";import{T as g}from"./top-bar-DkXSzzqt.js";import{S as w}from"./side-bar-CSx5wI-k.js";import{H as t}from"./heading-CRNoBc7q.js";import{B as L}from"./button-DHevvVBE.js";import{D as v}from"./drawer-DOWJp9T4.js";import{L as d}from"./list-bKpz6I9Q.js";import{F as l}from"./field-HrLaMLbx.js";import{I as a}from"./input-DTXbDJaL.js";import{C as m}from"./check-box-DPLaOkRR.js";import{P as f}from"./page-7SSpdYhb.js";import{R as o,C as i}from"./row-Bmiy2Lh0.js";import{A as u}from"./accordion-BiuI_LCA.js";import{S as s}from"./spacer-BWoNR27H.js";import{T as F}from"./tabs-
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as x}from"./index-DhsZuJvc.js";import{I as j}from"./common-types-Sih75Sav.js";import{T as g}from"./top-bar-DkXSzzqt.js";import{S as w}from"./side-bar-CSx5wI-k.js";import{H as t}from"./heading-CRNoBc7q.js";import{B as L}from"./button-DHevvVBE.js";import{D as v}from"./drawer-DOWJp9T4.js";import{L as d}from"./list-bKpz6I9Q.js";import{F as l}from"./field-HrLaMLbx.js";import{I as a}from"./input-DTXbDJaL.js";import{C as m}from"./check-box-DPLaOkRR.js";import{P as f}from"./page-7SSpdYhb.js";import{R as o,C as i}from"./row-Bmiy2Lh0.js";import{A as u}from"./accordion-BiuI_LCA.js";import{S as s}from"./spacer-BWoNR27H.js";import{T as F}from"./tabs-C3NG6m9W.js";import"./index-Bk2sglWO.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./actions-D-uVCDzk.js";import"./lodash-c4VUpsOs.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./index-BI4_Bp97.js";import"./help-icon-Buhx5nl6.js";import"./spinner-AWUe4xwQ.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./memoize-one.esm-CcMeOnPo.js";import"./card-EcjmryU9.js";import"./meta-content-DWZbURV2.js";import"./loader-XHoVniao.js";import"./label-CqmyC9he.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./select.input-D0UkAPd9.js";const C=[{label:"Import",value:"import",right:!0},{label:"Settings",value:"settings",right:!0}],S=()=>e.jsx("div",{style:{background:"#AAD3DF",borderLeft:"1px solid #8AB3BF",display:"flex",alignItems:"center",justifyContent:"center",color:"white",height:"100%"},children:"MAP"}),xe={title:"Layout/Layout Examples",parameters:{layout:"fullscreen",docs:{story:{inline:!1,iframeHeight:400}}}},n=()=>{const[r,b]=x.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsx(g,{}),e.jsx(w,{options:{title:"",sections:[]},width:"250px"}),e.jsx(f,{padding:!1,scroll:!1,children:e.jsxs(o,{spacing:0,flex:!0,children:[e.jsxs(v,{button:e.jsx(L,{onClick:()=>b(!r),round:!0,icon:j.CHEVRON_LEFT}),open:r,width:300,closedWidth:"var(--size-sidebar)",children:[e.jsx(d,{drawer:!0,narrow:!r,list:{name:"Sites",items:[{id:1,name:"Main Site",type:"Heading"},{id:2,name:"Site name here",active:!0,label:{value:1,color:"#69779b"}},{id:3,name:"Locations",type:"Heading"},{id:4,name:"Ipsum",label:{value:2,color:"#69779b"}},{id:5,name:"Dolor",label:{value:3,color:"#69779b"}}]}}),e.jsx(d,{drawer:!0,narrow:!r,list:{name:"Wells",items:[{id:1,name:"Main Wellbore",type:"Heading"},{id:2,name:"Lorem",label:{value:1,color:"#77699b"}}]}}),e.jsx(d,{drawer:!0,narrow:!r,list:{name:"Targets",items:[{id:1,name:"Lorem",label:{value:1,color:"#9b6977"}}]}})]}),e.jsxs(i,{borderLeft:!0,flexbox:!0,children:[e.jsx(s,{}),e.jsx(F,{padding:!0,margin:!1,options:C}),e.jsxs(o,{spacing:0,flex:!0,children:[e.jsxs(i,{scroll:!0,padding:!0,width:550,children:[e.jsx(t,{top:!0,children:"Site name here"}),e.jsx(l,{label:"Name",children:e.jsx(a,{value:"Site name here",width:"200px"})}),e.jsxs(u,{heading:e.jsx(t,{children:"Coordinate Reference System"}),managed:!0,children:[e.jsx(l,{label:"Label",labelLeft:!0,labelWidth:"50px",children:e.jsx(a,{value:"Value",width:"100%"})}),e.jsx(l,{label:"Label",labelLeft:!0,labelWidth:"50px",children:e.jsx(a,{value:"Value",width:"100%"})}),e.jsx(l,{label:"Label",labelLeft:!0,labelWidth:"50px",children:e.jsx(a,{value:"Value",width:"100%"})}),e.jsx(l,{children:e.jsx(m,{label:"Dolor"})})]}),e.jsx(s,{}),e.jsx(t,{marginBottom:"var(--padding)",children:"Location"}),e.jsxs(o,{children:[e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})}),e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})}),e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})}),e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})})]}),e.jsx(s,{}),e.jsx(t,{marginBottom:"var(--padding)",children:"Model"}),e.jsxs(o,{children:[e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})}),e.jsx(i,{children:e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})})]}),e.jsxs(u,{heading:e.jsx(t,{children:"Settings"}),managed:!0,children:[e.jsx(l,{children:e.jsx(m,{label:"Dolor"})}),e.jsxs(o,{children:[e.jsxs(i,{children:[e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})}),e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})]}),e.jsxs(i,{children:[e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})}),e.jsx(l,{label:"Label",children:e.jsx(a,{value:"Value",width:"100%"})})]})]})]})]}),e.jsx(i,{children:e.jsx(S,{})})]})]})]})})]})};n.__docgenInfo={description:"",methods:[],displayName:"Site"};var p,c,h;n.parameters={...n.parameters,docs:{...(p=n.parameters)==null?void 0:p.docs,source:{originalSource:`() => {
|
|
2
2
|
const [open, setOpen] = useState(true);
|
|
3
3
|
return <>
|
|
4
4
|
<TopBar />
|
|
@@ -163,4 +163,4 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as x}from"./index-DhsZuJv
|
|
|
163
163
|
</Row>
|
|
164
164
|
</Page>
|
|
165
165
|
</>;
|
|
166
|
-
}`,...(h=(c=n.parameters)==null?void 0:c.docs)==null?void 0:h.source}}};const
|
|
166
|
+
}`,...(h=(c=n.parameters)==null?void 0:c.docs)==null?void 0:h.source}}};const je=["Site"];export{n as Site,je as __namedExportsOrder,xe 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-D-uVCDzk.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as $e}from"./pagination-DWc8zp3k.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-DZ9ERbK_.js";import{S as Ge}from"./select-03uRbc4I.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-C7vnj_3M.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-rq33c1W2.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};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 mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{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,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(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),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};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 yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.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:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});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 o;return(o=e.onChange)==null?void 0:o.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,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:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):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===f.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 ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,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});ve.__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 xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({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});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.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})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__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:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.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:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__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:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{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:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};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 A=(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))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};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-D-uVCDzk.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as $e}from"./pagination-CLt-kUlx.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-F3bqJ0z5.js";import{S as Ge}from"./select-DnRuRG_N.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-C7vnj_3M.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-rq33c1W2.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};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 mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{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,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(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),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};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 yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.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:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});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 o;return(o=e.onChange)==null?void 0:o.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:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):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===f.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 ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,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});ve.__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 xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({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});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.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})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__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:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.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:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__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:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{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:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};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 A=(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))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};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-qmf29AIJ.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.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-D52aKMY1.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-D-uVCDzk.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-DHevvVBE.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-DWc8zp3k.js";import"./select-03uRbc4I.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-DZ9ERbK_.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.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-BCdvBxub.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.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-D52aKMY1.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-D-uVCDzk.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-DHevvVBE.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-CLt-kUlx.js";import"./select-DnRuRG_N.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-D0UkAPd9.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-F3bqJ0z5.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";import"./label-CqmyC9he.js";import"./flex-EllkLxgO.js";const gt={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} />;
|
|
@@ -769,4 +769,4 @@ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJv
|
|
|
769
769
|
}]
|
|
770
770
|
};
|
|
771
771
|
return <Table table={table} />;
|
|
772
|
-
}`,...(cn=(ln=Y.parameters)==null?void 0:ln.docs)==null?void 0:cn.source}}};const
|
|
772
|
+
}`,...(cn=(ln=Y.parameters)==null?void 0:ln.docs)==null?void 0:cn.source}}};const bt=["Default","FixedWidth","AutoWidth","ColumnWidths","ColumnAlignment","ColumnHeaderAlignment","InfiniteScrollFixedHeight","InfiniteScrollFullHeight","InfiniteScrollShort","InfiniteScrollWithDragAndDrop","InCard","Managed","ManagedWithSort","ManagedWithFilterAndMultipleSort","AutoAddNewRow","OnPasteCallback","ExampleTableWithInfoTooltips","ExampleTableWithInlineUnits"];export{z as AutoAddNewRow,L as AutoWidth,Q as ColumnAlignment,O as ColumnHeaderAlignment,_ as ColumnWidths,te as Default,X as ExampleTableWithInfoTooltips,Y as ExampleTableWithInlineUnits,E as FixedWidth,M as InCard,G as InfiniteScrollFixedHeight,N as InfiniteScrollFullHeight,U as InfiniteScrollShort,$ as InfiniteScrollWithDragAndDrop,q as Managed,B as ManagedWithFilterAndMultipleSort,K as ManagedWithSort,J as OnPasteCallback,bt as __namedExportsOrder,gt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{c as _}from"./index-Bk2sglWO.js";import{D as H}from"./disabled-context-rmpd7YJS.js";import{l as $}from"./lodash-c4VUpsOs.js";import{B as C}from"./badge-CLQ59MDF.js";import{s as z}from"./select.input-
|
|
1
|
+
import{j as r}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{c as _}from"./index-Bk2sglWO.js";import{D as H}from"./disabled-context-rmpd7YJS.js";import{l as $}from"./lodash-c4VUpsOs.js";import{B as C}from"./badge-CLQ59MDF.js";import{s as z}from"./select.input-D0UkAPd9.js";const G="_tabs_1y79t_1",J="_padding_1y79t_7",K="_margin_1y79t_11",Q="_contentPadding_1y79t_14",U="_item_1y79t_17",W="_active_1y79t_39",X="_hidden_1y79t_58",Y="_disabled_1y79t_61",Z="_left_1y79t_65",ee="_right_1y79t_65",a={tabs:G,padding:J,margin:K,contentPadding:Q,item:U,active:W,hidden:X,disabled:Y,left:Z,right:ee},j=({label:n,url:u,hidden:i,disabled:m,active:o,onClick:f,right:v,invalid:b,badge:s,testId:c})=>{const T=getComputedStyle(document.body).getPropertyValue("--color-text-error");return r.jsx("a",{id:n==null?void 0:n.toString(),href:u,className:_(a.item,o?a.active:"",m?a.disabled:"",i&&!o?a.hidden:"",v?a.right:a.left),onClick:f,"data-testid":c,children:b?r.jsx(C,{small:!0,margin:"-4px",color:T,title:"!",children:n}):s?r.jsx(C,{small:!0,margin:"-4px",title:s==null?void 0:s.toString(),children:n}):n})};j.__docgenInfo={description:"",methods:[],displayName:"Label",props:{label:{required:!0,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},url:{required:!1,tsType:{name:"string"},description:""},hidden:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},active:{required:!1,tsType:{name:"boolean"},description:""},onClick:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: MouseEvent<HTMLAnchorElement>) => void",signature:{arguments:[{type:{name:"MouseEvent",elements:[{name:"HTMLAnchorElement"}],raw:"MouseEvent<HTMLAnchorElement>"},name:"evt"}],return:{name:"void"}}},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},invalid:{required:!1,tsType:{name:"boolean"},description:""},badge:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const k=({children:n,activeTabIndex:u,contentPadding:i})=>Array.isArray(n)?r.jsx("div",{className:_(i?a.contentPadding:""),children:n.map((m,o)=>u===o&&m)}):null;k.__docgenInfo={description:"",methods:[],displayName:"Content",props:{children:{required:!1,tsType:{name:"union",raw:"ReactNode[] | ReactNode",elements:[{name:"Array",elements:[{name:"ReactNode"}],raw:"ReactNode[]"},{name:"ReactNode"}]},description:""},activeTabIndex:{required:!0,tsType:{name:"number"},description:""},contentPadding:{required:!1,tsType:{name:"boolean"},description:""}}};const ne=({name:n=void 0,options:u=null,children:i=null,value:m=void 0,onChange:o=$.noop,padding:f=!1,margin:v=!0,contentPadding:b=!0,onChangeTab:s,activeTabIndex:c=void 0,tabs:T=void 0,testId:E})=>{const h=D.useContext(H),g=s!==void 0,q=i?i.map((e,t)=>{var l;return{value:t,url:e.props.url,label:e.props.label,hidden:e.props.hidden,disabled:e.props.disabled||h,badge:e.props.badge,testId:((l=e.props)==null?void 0:l.testId)&&`${e.props.testId}-${t}`}}):u||T,{simpleInputs:N,options:p,selectedOptions:y}=g?{simpleInputs:!1,options:q,selectedOptions:void 0}:z(q,m),I=g||y===void 0||y===null?void 0:N?y:y.value,x=c!==void 0?c:p==null?void 0:p.findIndex(e=>e.value===I),w=x===-1?0:x,V=(e,t,l)=>{if(g){const d=t.key||t.label||null;s(e,d)}else{const d=l.target;d.name=n,d.value=t.value,d.label=t.label,o(l)}},L=(e,t)=>{const{label:l,url:d,hidden:O,disabled:P,value:A,right:F,invalid:M,badge:R,testId:S}=e;return r.jsx(j,{label:l,url:d,hidden:O,disabled:P||h,invalid:M,badge:R,right:F,active:g?t===w:A===I,onClick:B=>V(t,e,B),testId:S},t)};return p?r.jsxs("div",{children:[r.jsx("div",{className:_(a.tabs,f?a.padding:"",v?a.margin:""),"data-testid":E,children:p.map(L)}),r.jsx(k,{activeTabIndex:w??0,contentPadding:b,children:i})]}):null};ne.__docgenInfo={description:"",methods:[],displayName:"Tabs",props:{name:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"undefined",computed:!0}},options:{required:!1,tsType:{name:"union",raw:"ITabOption[] | null",elements:[{name:"Array",elements:[{name:"ITabOption"}],raw:"ITabOption[]"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},children:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},value:{required:!1,tsType:{name:"ITabSelectedOption"},description:"",defaultValue:{value:"undefined",computed:!0}},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
|
|
2
2
|
event: TChangeEvent<T>,
|
|
3
3
|
...additionalProps: { [key: string]: any }[]
|
|
4
4
|
) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as I}from"./index-DhsZuJvc.js";import{T as b}from"./tabs-C3NG6m9W.js";import"./index-Bk2sglWO.js";import"./disabled-context-rmpd7YJS.js";import"./lodash-c4VUpsOs.js";import"./badge-CLQ59MDF.js";import"./select.input-D0UkAPd9.js";import"./types-BmbYqTX_.js";const Q={title:"Navigation/Tabs",component:b,args:{name:"example",options:[{label:"Tab",value:0},{label:"Tab",value:1},{label:"With Badge",value:2,badge:"3"},{label:"Invalid",value:3,invalid:!0},{label:"Disabled",value:4,disabled:!0},{label:"Hidden tab",value:5,hidden:!0}],value:0}},s=i=>e.jsx(b,{...i}),d=s.bind({}),r=s.bind({});r.args={children:[e.jsx("div",{label:"Tab 0",children:e.jsx("h3",{children:"Tab 0 Content"})}),e.jsx("div",{label:"Tab 1",hidden:!0,children:e.jsx("h3",{children:"Tab 1 Content"})}),e.jsx("div",{label:"Tab 2",disabled:!0,children:e.jsx("h3",{children:"Tab 2 Content"})}),e.jsx("div",{label:"Tab 3",children:e.jsx("h3",{children:"Tab 3 Content"})}),e.jsx("div",{label:"Tab 4",children:e.jsx("h3",{children:"Tab 4 Content"})})]};const l=s.bind({});l.args={margin:!1};const a=s.bind({});a.parameters={layout:"fullscreen",docs:{description:{story:"When you want the divider to fill the edges of its container."}}};a.args={padding:!0};const t=s.bind({});t.args={options:[{label:"Tab 0",value:0},{label:"Tab 1",value:1},{label:"Tab 2",value:2},{label:"Tab 3",value:3,right:!0},{label:"Tab 4",value:4,right:!0}]};const o=()=>{const i=[{label:"Strawberries",value:"strawberries"},{label:"Bananas",value:"bananas"},{label:"Apples",value:"apples",disabled:!0},{label:"Pomegranates",value:"pomegranates"}],[p,D]=I.useState(i[0]);return e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"example",value:p,options:i,onChange:c=>{const{value:H,label:z}=(c==null?void 0:c.target)??{};D({value:H,label:z})}}),e.jsxs("span",{children:["Eating ",p.value,"..."]})]})},n=s.bind({});n.args={options:[{label:"Title Case Label",value:0},{label:"Mixed case label",value:1},{label:"lower case label",value:2}]};o.__docgenInfo={description:"",methods:[],displayName:"Managed"};var u,m,g;d.parameters={...d.parameters,docs:{...(u=d.parameters)==null?void 0:u.docs,source:{originalSource:"args => <Tabs {...args} />",...(g=(m=d.parameters)==null?void 0:m.docs)==null?void 0:g.source}}};var T,v,h;r.parameters={...r.parameters,docs:{...(T=r.parameters)==null?void 0:T.docs,source:{originalSource:"args => <Tabs {...args} />",...(h=(v=r.parameters)==null?void 0:v.docs)==null?void 0:h.source}}};var x,j,S;l.parameters={...l.parameters,docs:{...(x=l.parameters)==null?void 0:x.docs,source:{originalSource:"args => <Tabs {...args} />",...(S=(j=l.parameters)==null?void 0:j.docs)==null?void 0:S.source}}};var C,f,w;a.parameters={...a.parameters,docs:{...(C=a.parameters)==null?void 0:C.docs,source:{originalSource:"args => <Tabs {...args} />",...(w=(f=a.parameters)==null?void 0:f.docs)==null?void 0:w.source}}};var M,y,E;t.parameters={...t.parameters,docs:{...(M=t.parameters)==null?void 0:M.docs,source:{originalSource:"args => <Tabs {...args} />",...(E=(y=t.parameters)==null?void 0:y.docs)==null?void 0:E.source}}};var _,A,N;o.parameters={...o.parameters,docs:{...(_=o.parameters)==null?void 0:_.docs,source:{originalSource:`() => {
|
|
2
|
+
const options = [{
|
|
3
|
+
label: 'Strawberries',
|
|
4
|
+
value: 'strawberries'
|
|
5
|
+
}, {
|
|
6
|
+
label: 'Bananas',
|
|
7
|
+
value: 'bananas'
|
|
8
|
+
}, {
|
|
9
|
+
label: 'Apples',
|
|
10
|
+
value: 'apples',
|
|
11
|
+
disabled: true
|
|
12
|
+
}, {
|
|
13
|
+
label: 'Pomegranates',
|
|
14
|
+
value: 'pomegranates'
|
|
15
|
+
}];
|
|
16
|
+
const [selectedTab, setSelectedTab] = useState(options[0]);
|
|
17
|
+
return <>
|
|
18
|
+
<Tabs name="example" value={selectedTab} options={options} onChange={evt => {
|
|
19
|
+
const {
|
|
20
|
+
value,
|
|
21
|
+
label
|
|
22
|
+
} = ((evt?.target ?? {}) as any);
|
|
23
|
+
setSelectedTab({
|
|
24
|
+
value,
|
|
25
|
+
label
|
|
26
|
+
});
|
|
27
|
+
}} />
|
|
28
|
+
<span>Eating {selectedTab.value}...</span>
|
|
29
|
+
</>;
|
|
30
|
+
}`,...(N=(A=o.parameters)==null?void 0:A.docs)==null?void 0:N.source}}};var P,W,B;n.parameters={...n.parameters,docs:{...(P=n.parameters)==null?void 0:P.docs,source:{originalSource:"args => <Tabs {...args} />",...(B=(W=n.parameters)==null?void 0:W.docs)==null?void 0:B.source}}};const U=["Default","WithChildren","NoMargin","HorizontalPadding","Alignment","Managed","TestTitleCase"];export{t as Alignment,d as Default,a as HorizontalPadding,o as Managed,l as NoMargin,n as TestTitleCase,r as WithChildren,U as __namedExportsOrder,Q as default};
|