@oliasoft-open-source/react-ui-library 4.8.0-beta-2 → 4.8.0-beta-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-Csdt18_R.js → index-GTFdS-JF.js} +1008 -862
- package/dist/index.d.ts +8 -10
- package/dist/index.html +1 -1
- package/dist/index.js +1014 -899
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-BS-rAnbo.js → Color-KGDBMAHA-BGErnsA6.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DZ7r3cmw.js → DocsRenderer-PKQXORMH-D7WH90Ux.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-CKrpJWRn.js → accordion.stories-YV-J9E1H.js} +1 -1
- package/dist/storybook/assets/{afe.stories-80-X2oCf.js → afe.stories-BnD7J0sn.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-ES-Fuaqn.js → blowout.stories-BlyKeeED.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-sTGnmj6h.js → buttons-and-links-BCjRj0sv.js} +2 -2
- package/dist/storybook/assets/{casing-loads.stories-Do3mZuX2.js → casing-loads.stories-CEKi9p48.js} +1 -1
- package/dist/storybook/assets/{cell.stories-B0YsumDa.js → cell.stories-B0IK4EXk.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-B6vW-2Fd.js → check-box.stories-C_7Z7Ss6.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-BqK-R5cR.js → chunk-HLWAVYOI-D7npaoui.js} +1 -1
- package/dist/storybook/assets/{color-Cvx86PKp.js → color-DCR_IQPE.js} +2 -2
- package/dist/storybook/assets/{column.stories-BxfR9Tla.js → column.stories-DDTHFELF.js} +1 -1
- package/dist/storybook/assets/{footer.stories-CMN_mVki.js → footer.stories-Bl3gEVhY.js} +1 -1
- package/dist/storybook/assets/{form.stories-C1Qx3M_1.js → form.stories-JRw9Y_sV.js} +1 -1
- package/dist/storybook/assets/{formation.stories-CCJYaUpG.js → formation.stories-DNNvbCAo.js} +1 -1
- package/dist/storybook/assets/{grid-B6LFPf51.js → grid-DRkC-bt8.js} +1 -1
- package/dist/storybook/assets/{grid.stories-BhjMGl59.js → grid.stories-DqjhHHwX.js} +1 -1
- package/dist/storybook/assets/{icon.stories-C1hZXIMX.js → icon.stories-fnZUR-LK.js} +1 -1
- package/dist/storybook/assets/iframe-DNtoVJNq.js +2 -0
- package/dist/storybook/assets/index-C0x1JmaP.js +14 -0
- package/dist/storybook/assets/{index-B8zF6D3V.js → index-CEjEvyl9.js} +95 -95
- package/dist/storybook/assets/{index-omjWi7I7.js → index-C_B8BHJN.js} +1 -1
- package/dist/storybook/assets/{index-Be0hXiyp.js → index-DMAnyMX5.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-44quIZTV.js → input-group.stories-D7nvlp0S.js} +1 -1
- package/dist/storybook/assets/{input-validation-BREYBXzB.js → input-validation-Cpjs6Oco.js} +1 -1
- package/dist/storybook/assets/{inputs-DkxT6vDD.js → inputs-B0fHrXlB.js} +2 -2
- package/dist/storybook/assets/{layout-forms-Y0Chz5wF.js → layout-forms-Ck78vgFh.js} +1 -1
- package/dist/storybook/assets/{layout-general-CRJUCd3s.js → layout-general-BV8ErZlY.js} +1 -1
- package/dist/storybook/assets/{menu.stories-Dozt6Npk.js → menu.stories-mt3LwVCk.js} +1 -1
- package/dist/storybook/assets/{message.stories-K3bQ-5bJ.js → message.stories-DEMcK-wa.js} +1 -1
- package/dist/storybook/assets/{modal.stories-BX49dKIM.js → modal.stories-Benu2pYo.js} +1 -1
- package/dist/storybook/assets/number-input-FjN2w5Zq.js +4 -0
- package/dist/storybook/assets/number-input.stories-CjeUb5EQ.js +166 -0
- package/dist/storybook/assets/{padding-and-spacing-DYx_u7EA.js → padding-and-spacing-Tv64UDVi.js} +1 -1
- package/dist/storybook/assets/{pagination-iSMIbR33.js → pagination-DXnrsBZs.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-BUPaZD5R.js → pagination.stories-DKSBeVH-.js} +1 -1
- package/dist/storybook/assets/{popover.stories-Duemqiqp.js → popover.stories-BKImRt9k.js} +1 -1
- package/dist/storybook/assets/{preview-kt6m1zZo.js → preview-C4UROPMn.js} +2 -2
- package/dist/storybook/assets/{preview-B2Xzz4-3.js → preview-DV63XeY-.js} +1 -1
- package/dist/storybook/assets/{projects.stories-DU-QlBa6.js → projects.stories-BfMSNrkX.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-8QEKlNvO.js → radio-button.stories-CGJnfCk-.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-aSZ9r1Pu.js → reservoirs.stories-CZme5ZCc.js} +1 -1
- package/dist/storybook/assets/rich-text-input.stories-a2GSF6vM.js +256 -0
- package/dist/storybook/assets/{row-4iAGREkV.js → row-Bmiy2Lh0.js} +1 -1
- package/dist/storybook/assets/{row.stories-ZCrMoTuY.js → row.stories-UAENUT5Q.js} +1 -1
- package/dist/storybook/assets/{select-C8iu4-uz.js → select-Br1k0mOD.js} +1 -1
- package/dist/storybook/assets/{select.stories-DbgjgsiX.js → select.stories-Bj6BwvfZ.js} +1 -1
- package/dist/storybook/assets/{site.stories-Ci4g5W2A.js → site.stories-CRc-gQlK.js} +1 -1
- package/dist/storybook/assets/{smart-upload-modal.stories-DgnJ79fa.js → smart-upload-modal.stories-BStZdEeo.js} +1 -1
- package/dist/storybook/assets/styled-components.browser.esm-BQ9GQzDc.js +2 -0
- package/dist/storybook/assets/{table-ZQD4ELIM.js → table-DMsE4ks-.js} +1 -1
- package/dist/storybook/assets/{table.stories-DGedoAir.js → table.stories-CvFBGBd6.js} +1 -1
- package/dist/storybook/assets/{title.stories-jQBBSflc.js → title.stories-DvTVQphz.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-CAqrDYpd.js → toaster.stories-Dxg5K32_.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-t0T4HV1D.js → toggle.stories-mjk0JIle.js} +1 -1
- package/dist/storybook/assets/unit-input-5P4Cogho.css +1 -0
- package/dist/storybook/assets/unit-input.stories-s45csxB3.js +353 -0
- package/dist/storybook/assets/unit-table.stories-DtWOiSyD.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/dist/storybook/sb-addons/interactions-2/manager-bundle.js +1 -0
- package/dist/storybook/sb-manager/globals-runtime.js +1 -1
- package/dist/storybook/sb-manager/globals.js +48 -0
- package/dist/storybook/sb-preview/runtime.js +1 -0
- package/package.json +8 -4
- package/dist/storybook/assets/iframe-CUVhB5TR.js +0 -2
- package/dist/storybook/assets/index-DQs5XS8h.js +0 -14
- package/dist/storybook/assets/number-input-CD-fbjVQ.js +0 -4
- package/dist/storybook/assets/number-input.stories-h1PlFB_G.js +0 -105
- package/dist/storybook/assets/rich-text-input.stories-CsFyrKRA.js +0 -256
- package/dist/storybook/assets/styled-components.browser.esm-Bf0q9Yjk.js +0 -2
- package/dist/storybook/assets/unit-input-CoFS2qhN.css +0 -1
- package/dist/storybook/assets/unit-input.stories-C7XlUSaC.js +0 -290
- package/dist/storybook/assets/unit-table.stories-BJbxGp7Y.js +0 -150
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o}from"./jsx-runtime-eps93zm2.js";import{
|
|
1
|
+
import{j as o}from"./jsx-runtime-eps93zm2.js";import{l as x,d as y}from"./styled-components.browser.esm-BQ9GQzDc.js";import{r as h,R as $}from"./index-DhsZuJvc.js";import{c as v}from"./index-Bk2sglWO.js";const T=x`
|
|
2
2
|
scrollbar-width: none;
|
|
3
3
|
-ms-overflow-style: none;
|
|
4
4
|
&::-webkit-scrollbar {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{T as g}from"./table-
|
|
1
|
+
import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{T as g}from"./table-DMsE4ks-.js";import{T as z}from"./text-B3-TSWok.js";import{t as R,s as G,u as J,v as K,w as Q}from"./table.stories-data-CR9VpXHs.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-BHd_uQHh.js";import"./actions-CHgr8eL8.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./pagination-DXnrsBZs.js";import"./select-Br1k0mOD.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-DIKP56UZ.js";import"./input-BW9trNAW.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-FjN2w5Zq.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-BtCGePRy.js";import"./slider-DAramr8j.js";import"./index-BI4_Bp97.js";import"./popover-CzZdWNnB.js";import"./flex-EllkLxgO.js";const Ie={title:"Basic/Table/Row",component:g,args:{table:{...R}}},v=n=>o.jsx(g,{...n}),i=v.bind({});i.args={table:G};const p=v.bind({});p.args={table:J};const c=v.bind({});c.args={table:K};const d=v.bind({});d.args={table:Q};const t=v.bind({});t.args={table:{...R,striped:!1}};t.parameters={docs:{description:{story:"`striped: false` removes tinted background on alternative rows."}}};const u=()=>{const[n,e]=D.useState(null),a=r=>e(n===r?null:r);return o.jsx(g,{table:{...R,striped:!1,rows:R.rows.map((r,x)=>({...r,onRowClick:()=>a(x),expandedContent:{content:n===x?o.jsx("div",{children:"Example expanded content"}):null}}))}})},m=()=>{const n={draggable:!0,headers:[{cells:[{value:"Name"},{value:"Weight (kg)"},{value:"Energy (kcal / 100g)"},{value:"Origin"}]}],rows:[{noDrag:!0,cells:[{value:"Undraggable"},{value:100},{value:361},{value:"Vietnam"}]},{cells:[{value:"Buckwheat"},{value:50},{value:358},{value:"Poland"}]},{cells:[{value:"Couscous"},{value:10},{value:368},{value:"France"}]}]},e=(s,b,l)=>{const y=[...s];return s[l].noDrag?s:(y.splice(l,0,y.splice(b,1)[0]),y)},[a,r]=D.useState(n.rows),x=s=>{const{to:b,from:l}=s;e(a,l,b),r(e(a,l,b))};return o.jsx(g,{table:{...n,rows:a},onListReorder:x})},w=()=>{const[n,e]=D.useState("Hover any row!"),a=[1,2,3,4,5].map(r=>({cells:[{value:`Row ${r}`},{value:`${r**2}`}],onRowMouseEnter:()=>e(`Hovering row ${r}`),onRowMouseLeave:()=>e("Not hovering any row...")}));return o.jsxs(o.Fragment,{children:[o.jsx(z,{children:n}),o.jsx(g,{table:{fixedWidth:"100%",headers:[{cells:[{value:"Description"},{value:"Value"}],onRowMouseEnter:()=>e("Hovering header row"),onRowMouseLeave:()=>e("Not hovering any row...")}],rows:a}})]})};u.__docgenInfo={description:"",methods:[],displayName:"Expandable"};m.__docgenInfo={description:"",methods:[],displayName:"DragAndDrop"};w.__docgenInfo={description:"",methods:[],displayName:"OnRowEnter"};var E,h,T;i.parameters={...i.parameters,docs:{...(E=i.parameters)==null?void 0:E.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -37,4 +37,4 @@ import{j as p}from"./jsx-runtime-eps93zm2.js";import{r as N,g as We}from"./index
|
|
|
37
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 Yn="_inputInTable_1qfoj_1",Bn="_inputHover_1qfoj_13",Zn="_inputFocus_1qfoj_18",Xn="_inputError_1qfoj_25",Jn="_inputWarning_1qfoj_26",Qn="_inputDisabled_1qfoj_61",et="_hideScrollbars_1qfoj_67",nt="_trigger_1qfoj_77",tt="_isInTable_1qfoj_93",rt="_input_1qfoj_1",at="_isOpen_1qfoj_114",it="_error_1qfoj_122",st="_warning_1qfoj_139",ot="_disabled_1qfoj_156",lt="_icons_1qfoj_162",ut="_clearAll_1qfoj_169",ct="_iconOpen_1qfoj_170",dt="_small_1qfoj_181",mt="_triggerInputContainer_1qfoj_189",pt="_right_1qfoj_198",ft="_multiOptions_1qfoj_211",gt="_multiOption_1qfoj_211",vt="_label_1qfoj_239",yt="_closeMultiOption_1qfoj_242",ht="_focus_1qfoj_253",St="_selectedSingleValue_1qfoj_257",bt="_placeHolder_1qfoj_258",_t="_groupOrderFirst_1qfoj_297",Tt="_groupOrderMiddle_1qfoj_298",Et="_groupOrderLast_1qfoj_302",It="_detailedLabel_1qfoj_307",M={inputInTable:Yn,inputHover:Bn,inputFocus:Zn,inputError:Xn,inputWarning:Jn,inputDisabled:Qn,hideScrollbars:et,trigger:nt,isInTable:tt,input:rt,isOpen:at,error:it,warning:st,disabled:ot,icons:lt,clearAll:ut,iconOpen:ct,small:dt,triggerInputContainer:mt,right:pt,multiOptions:ft,multiOption:gt,label:vt,closeMultiOption:yt,focus:ht,selectedSingleValue:St,placeHolder:bt,groupOrderFirst:_t,groupOrderMiddle:Tt,groupOrderLast:Et,detailedLabel:It},Ae=({selectedOptions:e,small:n,width:a,testId:d})=>{const c=xe(),[v,f]=N.useState([]),[s,l]=N.useState([]);return N.useEffect(()=>{let g=[],b=[],S=0;e.forEach((T,E)=>{S+=Kn(T,n,c),E===e.length-1&&S<a||S<a-24?g.push(T):b.push(T)}),f(g),l(b)},[e,c,a]),p.jsxs("div",{className:M.multiOptions,"data-testid":d&&`${d}-value`,children:[v.filter(g=>g&&g.label).map((g,b)=>p.jsx("span",{className:M.multiOption,onClick:S=>{S.stopPropagation()},children:g.label},b)),s.length>0&&p.jsx(me,{text:s.map((g,b)=>p.jsx("div",{children:g.label},b)),display:"inline-flex",children:p.jsx("span",{className:M.multiOption,children:v.length?`+${s.length}`:`${s.length} items`})})]})};Ae.__docgenInfo={description:"",methods:[],displayName:"MultiSelectedOptions",props:{selectedOptions:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!0,tsType:{name:"number"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Fe=({selectedOptions:e,searchable:n=!1,searchValue:a,onChange:d=()=>{},inputRef:c,error:v,placeholder:f="Select...",small:s,testId:l})=>{const g=N.useRef(null),b=Array.isArray(e),S=b?e.length>0:!!e,T=a?a.length+1:1,E=()=>{var o,i;const _=((o=g.current)==null?void 0:o.offsetWidth)||0,t=((i=c.current)==null?void 0:i.offsetWidth)||0;return _-t};return p.jsxs("div",{className:M.triggerInputContainer,ref:g,children:[S?b?p.jsx(Ae,{selectedOptions:e,small:s,width:E(),testId:l}):p.jsx("span",{className:M.selectedSingleValue,"data-testid":l&&`${l}-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":l&&`${l}-input`}):null]})};Fe.__docgenInfo={description:"",methods:[],displayName:"Input",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},searchValue:{required:!1,tsType:{name:"string"},description:""},inputRef:{required:!0,tsType:{name:"MutableRefObject",elements:[{name:"union",raw:"HTMLInputElement | null",elements:[{name:"HTMLInputElement"},{name:"null"}]}],raw:"MutableRefObject<HTMLInputElement | null>"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:"",defaultValue:{value:"'Select...'",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const He=({selectedOptions:e,searchValue:n,searchable:a,clearable:d,onClickTrigger:c,element:v,error:f,warning:s,tooltip:l,small:g,isInTable:b,disabled:S,onChangeSearch:T,onClickDeselect:E,onClickClear:_,tabIndex:t,isOpen:o,triggerRef:i,clearAllIsFocused:r,focusedSelectedOptionIndex:u,onFocus:m,onBlur:y,groupOrder:h,maxTooltipWidth:I,placeholder:R,right:x,testId:q})=>{var H;const[w,C]=we(),A=Array.isArray(e)?e.length>0&&((H=e[0])==null?void 0:H.value):e==null?void 0:e.value,j=d&&A,z=(()=>{if(h)switch(h){case ae.FIRST:return M.groupOrderFirst;case ae.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(le,{children:e.label}),p.jsx(le,{muted:!0,children:e.details})]})}:e,$=p.jsxs(p.Fragment,{children:[v,p.jsxs("div",{ref:i,tabIndex:t,className:G(M.trigger,o?M.isOpen:"",f?M.error:s?M.warning:"",S?M.disabled:"",g?M.small:"",b?M.isInTable:"",x?M.right:"",z),onClick:P=>{P.stopPropagation(),typeof C=="function"&&C(),c(P)},onFocus:m,onBlur:y,"data-testid":q,children:[p.jsx(Fe,{selectedOptions:K,placeholder:R,searchable:a,searchValue:n,inputRef:w,onChange:T,error:f,small:g,testId:q}),p.jsx("span",{className:M.icons,children:j?p.jsx("span",{className:G(M.clearAll,r?M.focus:""),onClick:P=>{P.stopPropagation(),_&&_(P)},"data-testid":q&&`${q}-clear`,children:p.jsx(ue,{icon:Ee.CLOSE})}):p.jsx("span",{className:G(M.iconOpen),children:p.jsx(ue,{icon:"chevron down"})})})]})]});return p.jsx(p.Fragment,{children:p.jsx(me,{error:!!f,warning:!!s,text:l||f||s,enabled:l&&ne(l)||f&&ne(f)||s&&ne(s)||!1,maxWidth:I,placement:"bottom-center",children:$})})};He.__docgenInfo={description:"",methods:[],displayName:"Trigger",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchValue:{required:!1,tsType:{name:"string"},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},onClickTrigger:{required:!0,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},element:{required:!1,tsType:{name:"ReactNode"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},onChangeSearch:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onClickDeselect:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},onClickClear:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLSpanElement, MouseEvent>",elements:[{name:"HTMLSpanElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},isOpen:{required:!1,tsType:{name:"boolean"},description:""},triggerRef:{required:!1,tsType:{name:"RefObject",elements:[{name:"HTMLDivElement"}],raw:"RefObject<HTMLDivElement>"},description:""},clearAllIsFocused:{required:!1,tsType:{name:"boolean"},description:""},focusedSelectedOptionIndex:{required:!1,tsType:{name:"number"},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},groupOrder:{required:!1,tsType:{name:"union",raw:"TGroupOrder | string",elements:[{name:"union",raw:"'first' | 'middle' | 'last'",elements:[{name:"literal",value:"'first'"},{name:"literal",value:"'middle'"},{name:"literal",value:"'last'"}]},{name:"string"}]},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var 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},Ot=e=>e!==null?e+1:0,De=(e,n)=>{const a=["none",...e.map((c,v)=>c.type!==ie.HEADING?v:null).filter(c=>c!==null)],d=Ot(n);return{options:a,currentIndex:d,current:a[d]}},wt=(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}},xt=(e,n,a)=>{const d=e==="left"?-1:1,c=n&&n.length?["none",...Array.from({length:n.length},(g,b)=>b),"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"}},_e=()=>Pe,Te=e=>({...e,currentIndex:0,current:"none"}),Rt=(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:Te(e.layerFocus)}}case U.FOCUS_TRIGGER_INPUTS:return{...e,triggerFocus:xt(n.direction||"right",n.selectedOptions||[],e.triggerFocus),layerFocus:Te(e.layerFocus)};case U.BLUR_TRIGGER_INPUTS:return{...e,triggerFocus:_e()};case U.FOCUS_LAYER_OPTIONS:return n.nextLayerFocus?{...e,layerFocus:n.nextLayerFocus,triggerFocus:_e()}:e;case U.OPEN_LAYER:return{...e,isLayerOpen:!0};case U.CLOSE_LAYER:return{...e,isLayerOpen:!1};default:return e}},qt={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 Lt=({state:e,dispatch:n,options:a,setTriggerFocus:d,disabled:c,disabledContext:v,onCreate:f,onChange:s,selectedOptions:l,width:g,small:b,isFontLoaded:S,placeholder:T,firstSelectedOptionIndex:E,createAble:_,listRef:t,autoLayerWidth:o})=>{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,L,Q)=>{if(!(c||v)){if(Q&&Q(),L){if(L.createAble&&f)f(L.value);else if(!L.disabled)if(Array.isArray(l))if(l.some(B=>B.label===L.label)){const B=l.filter(pe=>pe.label!==L.label);s&&s(O,B)}else{const B=[...l,L];s&&s(O,B)}else s&&s(O,L)}n({type:D.CLEAR_SEARCH,options:a}),d()}},y=N.useCallback(()=>g?g!=="auto"?g:be(a,b,S,T):"100%",[a,S]),h=N.useCallback(O=>o?Math.max(be(a,b,S,T),O==null?void 0:O.width):O==null?void 0:O.width,[a,S]),{renderLayer:I,layerProps:R,triggerProps:x,triggerBounds:q}=Ue({isOpen:(e==null?void 0:e.isLayerOpen)??!1,overflowContainer:!0,...qt,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()}},C=N.useRef(!0);N.useEffect(()=>{C.current?C.current=!1:e.isLayerOpen||n({type:D.CLEAR_SEARCH,options:a})},[e.isLayerOpen]);const A=(O,L)=>{const Q=l instanceof Array?l.filter(Y=>Y.value!==L.value):null;s&&s(O,Q)},j=O=>{const L=l instanceof Array?[]:{value:null};s&&s(O,L)},z=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)},H=O=>{const L=wt(O,e.layerFocus);n({type:D.FOCUS_LAYER_OPTIONS,nextLayerFocus:L}),$(L.current)},P=O=>{n({type:D.FOCUS_TRIGGER_INPUTS,ICustomSelectDirection:O,selectedOptions:l})},Z=O=>j(O),te=l&&l[e.triggerFocus.currentOption],re=O=>{A(O,l[e.triggerFocus.currentOption])},X=O=>{var L;m(O,(L=e==null?void 0:e.visibleOptions)==null?void 0:L[e.layerFocus.current],i)},k=e.triggerFocus.clearAll;return{getTriggerWidth:y,onKeyEvent:(O,L)=>{switch(O){case V.UP:{H(O);break}case V.DOWN:{e.isLayerOpen?H(O):K();break}case V.LEFT:case V.RIGHT:{P(O);break}case V.ENTER:{k?Z(L):te?re(L):X(L);break}case V.ESC:{i();break}}},clearAllIsFocused:k,triggerProps:x,onClickTrigger:w,onChangeSearch:z,onClickDeselectOption:A,onClickClearAll:j,renderLayer:I,layerProps:R,closeLayer:i,onSelectOption:m,getLayerWidth:h,triggerBounds:q}},ke=e=>{const{multi:n=!1,disabled:a=!1,error:d=null,warning:c=null,tooltip:v=null,options:f,selectedOptions:s,onCreate:l=null,placeholder:g="",small:b=!1,tabIndex:S=0,onFocus:T=()=>{},onBlur:E=()=>{},searchable:_=!0,clearable:t=!1,maxTooltipWidth:o,closeOnOptionActionClick:i,isInTable:r=!1,groupOrder:u,firstSelectedOptionIndex:m=0,right:y=!1,testId:h=void 0}=e,I=N.useContext(de),R=l!==null,x=N.useRef(null),[q,w]=we(),C=xe(),[A,j]=N.useReducer(Rt,{options:f,firstSelectedOptionIndex:m},({options:Y})=>({searchValue:"",visibleOptions:Y,layerFocus:De(Y,m??0),triggerFocus:Pe,isLayerOpen:!1})),{getTriggerWidth:z,onKeyEvent:K,clearAllIsFocused:$,triggerProps:H,onClickTrigger:P,onChangeSearch:Z,onClickDeselectOption:te,onClickClearAll:re,renderLayer:X,layerProps:k,closeLayer:J,onSelectOption:O,getLayerWidth:L,triggerBounds:Q}=Lt({...e,state:A,dispatch:j,setTriggerFocus:w,disabledContext:I,isFontLoaded:C,createAble:R,listRef:x});return p.jsx("div",{style:{width:z()},children:p.jsxs(fn,{handleKeys:Object.values(V),onKeyEvent:K,children:[p.jsx(He,{selectedOptions:s,searchValue:A.searchValue,isOpen:A.isLayerOpen,focusedSelectedOptionIndex:A.triggerFocus.currentOption,clearAllIsFocused:$,searchable:_,triggerRef:Ge(q,H.ref),error:d,warning:c,tooltip:v,small:b,isInTable:r,disabled:a||I,clearable:t,tabIndex:S,onClickTrigger:P,onChangeSearch:Z,onClickDeselect:te,onClickClear:re,onFocus:T,onBlur:E,groupOrder:u,maxTooltipWidth:o,placeholder:g,right:y,testId:h}),A.isLayerOpen&&X(p.jsx("div",{...k,className:F.layerContainer,children:p.jsx(je,{listRef:x,isMulti:n,sections:A.visibleOptions,selectedOptions:s,onSelectOption:(Y,B)=>{O(Y,B,n?void 0:J)},closeLayer:()=>{i&&J()},width:L(Q),small:b,focusedOptionIndex:A.layerFocus.current,firstSelectedOptionIndex:m??0,testId:h&&`${h}-layer`})}))]})})};ke.__docgenInfo={description:"",methods:[],displayName:"CustomSelect",props:{multi:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},options:{required:!0,tsType:{name:"Array",elements:[{name:"union",raw:"ISelectSelectedOption | Heading",elements:[{name:"ISelectSelectedOption"},{name:"Heading"}]}],raw:"TCustomSelectSelectOption[]"},description:""},selectedOptions:{required:!0,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
|
|
38
38
|
evt: ChangeEvent<HTMLInputElement>,
|
|
39
39
|
newSelectedOptions: ISelectSelectedOption,
|
|
40
|
-
) => void`,signature:{arguments:[{type:{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},name:"evt"},{type:{name:"ISelectSelectedOption"},name:"newSelectedOptions"}],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 Ct=e=>{const{name:n="",options:a=[],value:d,native:c=!1,onChange:v=()=>{},deprecatedEventHandler:f=!1,autoScroll:s=!0,warning:l,error:g,checkNonExistentValues:b=!0,closeOnOptionActionClick:S=!0,testId:T,disabled:E}=e,_=!c&&s===!0,{multi:t,simpleInputs:o,options:i,selectedOptions:r,firstSelectedOptionIndex:u,hasNonExistentValue:m}=Ye(a,d,_,b),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",R=m&&!E?l?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:l})]}):I:l,x=m&&g&&!E?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:g})]}):g,q=(w,C)=>{if(f){const A=t?C.map(j=>o?j.value:j):o?C.value:C;v(A)}else{const A=!(w instanceof Event),j=t?C:C.value;A?(w.target.name=n,w.target.value=j,t||(w.target.label=C.label),v(w)):v({...w,target:{...w.target,name:n,value:j,...!t&&{label:C.label}}})}};return h?p.jsx(Ie,{...e,options:i,selectedOption:r,onChange:q,hasNonExistentValue:m,warning:R,error:x,testId:T}):p.jsx(ke,{...e,options:i,selectedOptions:r,onChange:q,multi:t,firstSelectedOptionIndex:u,warning:R,error:x,testId:T,closeOnOptionActionClick:S})};Ct.__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:"(value: any) => void",signature:{arguments:[{type:{name:"any"},name:"value"}],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{Ct as S};
|
|
40
|
+
) => void`,signature:{arguments:[{type:{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},name:"evt"},{type:{name:"ISelectSelectedOption"},name:"newSelectedOptions"}],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 Ct=e=>{const{name:n="",options:a=[],value:d,native:c=!1,onChange:v=()=>{},deprecatedEventHandler:f=!1,autoScroll:s=!0,warning:l,error:g,checkNonExistentValues:b=!0,closeOnOptionActionClick:S=!0,testId:T,disabled:E}=e,_=!c&&s===!0,{multi:t,simpleInputs:o,options:i,selectedOptions:r,firstSelectedOptionIndex:u,hasNonExistentValue:m}=Ye(a,d,_,b),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",R=m&&!E?l?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:l})]}):I:l,x=m&&g&&!E?p.jsxs("div",{children:[p.jsx("div",{children:I}),p.jsx("div",{children:g})]}):g,q=(w,C)=>{if(f){const A=t?C.map(j=>o?j.value:j):o?C.value:C;v(A)}else{const A=!(w instanceof Event),j=t?C:C.value;A?(w.target.name=n,w.target.value=j,t||(w.target.label=C.label),v(w)):v({...w,target:{...w.target,name:n,value:j,...!t&&{label:C.label}}})}};return h?p.jsx(Ie,{...e,options:i,selectedOption:r,onChange:q,hasNonExistentValue:m,warning:R,error:x,testId:T}):p.jsx(ke,{...e,options:i,selectedOptions:r,onChange:q,multi:t,firstSelectedOptionIndex:u,warning:R,error:x,testId:T,closeOnOptionActionClick:S})};Ct.__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:"(value: any) => void",signature:{arguments:[{type:{name:"any"},name:"value"}],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,fn as K,Ct 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-
|
|
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-Br1k0mOD.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"./index-Bk2sglWO.js";import"./disabled-context-rmpd7YJS.js";import"./types-UmZ4Y_CR.js";import"./lodash-BHd_uQHh.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-CHgr8eL8.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-DIKP56UZ.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
|
|
@@ -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-C_tn2Pc5.js";import{S as w}from"./side-bar-CKbHPgIV.js";import{H as t}from"./heading-CRNoBc7q.js";import{B as L}from"./button-VxhoNhrV.js";import{D as v}from"./drawer-BhuWxI7V.js";import{L as d}from"./list-yVTOdmpX.js";import{F as l}from"./field-HrLaMLbx.js";import{I as a}from"./input-BW9trNAW.js";import{C as m}from"./check-box-BtCGePRy.js";import{P as f}from"./page-7SSpdYhb.js";import{R as o,C as i}from"./row-
|
|
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-C_tn2Pc5.js";import{S as w}from"./side-bar-CKbHPgIV.js";import{H as t}from"./heading-CRNoBc7q.js";import{B as L}from"./button-VxhoNhrV.js";import{D as v}from"./drawer-BhuWxI7V.js";import{L as d}from"./list-yVTOdmpX.js";import{F as l}from"./field-HrLaMLbx.js";import{I as a}from"./input-BW9trNAW.js";import{C as m}from"./check-box-BtCGePRy.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-CAZ_dHGK.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-CHgr8eL8.js";import"./lodash-BHd_uQHh.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./types-BmbYqTX_.js";import"./types-UmZ4Y_CR.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-cbHGvPJ7.js";import"./loader-XHoVniao.js";import"./label-CqmyC9he.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./select.input-DIKP56UZ.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 />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as i}from"./index-DhsZuJvc.js";import{B as h}from"./button-VxhoNhrV.js";import{u as Q,M as z,D as G}from"./dialog-Di8hNunM.js";import{F as J}from"./file-input-BpMtsZ2S.js";import{S}from"./spacer-BWoNR27H.js";import{T as W}from"./text-B3-TSWok.js";import{P as X}from"./progress-bar-C_kV6r0Q.js";import{d as Y}from"./index-
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as i}from"./index-DhsZuJvc.js";import{B as h}from"./button-VxhoNhrV.js";import{u as Q,M as z,D as G}from"./dialog-Di8hNunM.js";import{F as J}from"./file-input-BpMtsZ2S.js";import{S}from"./spacer-BWoNR27H.js";import{T as W}from"./text-B3-TSWok.js";import{P as X}from"./progress-bar-C_kV6r0Q.js";import{d as Y}from"./index-C0x1JmaP.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./portal-GQ0_cLB6.js";import"./lodash-BHd_uQHh.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./input-group-BaRSJAEN.js";import"./input-BW9trNAW.js";import"./types-UmZ4Y_CR.js";import"./index-DRSy5Ssd.js";const U=250,g=4e4,b=20,I=500,M=({visible:s,prompt:p,onCloseModal:f,onUpload:m,onComplete:y,onFailed:n,onError:a,width:F,heading:_,dialogText:E,fileInputText:k,fileInputPlaceholder:N,uploadText:V,cancelText:B,testId:d})=>{const[c,v]=i.useState(null),[C,u]=i.useState(!1),[P,T]=i.useState(0);let o=0;const R=()=>{o=o+U,T(o)},A=t=>{let r=o+t;r>=.99*g&&(r=g),o=r,T(o)};i.useEffect(()=>{v(null)},[s]);const L=t=>{t.target.value&&v(t.target.value)},H=async()=>{T(0);const t=setInterval(R,U);try{if(!c)return;u(!0);const r=await m(p,c);if(!s)return;if(r){clearInterval(t);const K=setInterval(A,I/b,(g-o)/(b-1));setTimeout(()=>{y(r),clearInterval(K),u(!1)},I)}else n==null||n(),u(!1)}catch(r){a==null||a(r),u(!1)}finally{clearInterval(t)}},O=()=>{H()},x=()=>{f()},$=e.jsxs(e.Fragment,{children:[e.jsx(W,{children:E||"Upload file and extract data using a LLM"}),e.jsx(S,{}),e.jsx(J,{placeholder:N||"No file",label:k||"Select",file:c||void 0,onChange:L,testId:`${d}-file-input`,accept:"image/*"}),C&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsx(X,{percentage:Y.roundByMagnitudeToFixed(100*P/g,3)})]})]}),D=e.jsxs(e.Fragment,{children:[e.jsx(h,{label:V||"Upload",colored:!0,onClick:O,disabled:!c||C,testId:`${d}-button-upload`}),e.jsx(h,{label:B||"Cancel",onClick:x,testId:`${d}-button-cancel`})]});return Q("Escape",()=>x()),e.jsx(z,{visible:s,centered:!0,children:e.jsx(G,{dialog:{scroll:!0,heading:_||"Smart Upload",content:$,footer:D,onClose:x,width:F||350,testId:d}})})};M.__docgenInfo={description:"",methods:[],displayName:"SmartUploadModal",props:{visible:{required:!0,tsType:{name:"boolean"},description:""},prompt:{required:!0,tsType:{name:"string"},description:""},onCloseModal:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},onUpload:{required:!0,tsType:{name:"signature",type:"function",raw:"(prompt: string, file: File) => any",signature:{arguments:[{type:{name:"string"},name:"prompt"},{type:{name:"File"},name:"file"}],return:{name:"any"}}},description:""},onComplete:{required:!0,tsType:{name:"signature",type:"function",raw:"(data: { [key: string]: string }[]) => void",signature:{arguments:[{type:{name:"Array",elements:[{name:"signature",type:"object",raw:"{ [key: string]: string }",signature:{properties:[{key:{name:"string"},value:{name:"string",required:!0}}]}}],raw:"{ [key: string]: string }[]"},name:"data"}],return:{name:"void"}}},description:""},onFailed:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},onError:{required:!1,tsType:{name:"signature",type:"function",raw:"(error: any) => void",signature:{arguments:[{type:{name:"any"},name:"error"}],return:{name:"void"}}},description:""},width:{required:!1,tsType:{name:"number"},description:""},heading:{required:!1,tsType:{name:"string"},description:""},dialogText:{required:!1,tsType:{name:"string"},description:""},fileInputText:{required:!1,tsType:{name:"string"},description:""},fileInputPlaceholder:{required:!1,tsType:{name:"string"},description:""},uploadText:{required:!1,tsType:{name:"string"},description:""},cancelText:{required:!1,tsType:{name:"string"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ie={title:"Ai/SmartUploadModal",component:M,args:{visible:!0,prompt:"This is a prompt",onCloseModal:()=>{},onUpload:()=>{},onComplete:()=>{}},parameters:{docs:{story:{inline:!1,iframeHeight:400}}}},l=()=>{const[s,p]=i.useState(!0),f=()=>{p(!0)},m=()=>{p(!1)},y=()=>(console.log("Uploading"),new Promise(a=>{setTimeout(()=>{a([])},4e3)})),n=()=>{console.log("Completed"),m()};return e.jsxs(e.Fragment,{children:[e.jsx(M,{visible:s,prompt:"This is a prompt",onCloseModal:m,onUpload:y,onComplete:n}),e.jsx(h,{label:"Open Modal",onClick:f})]})};l.__docgenInfo={description:"",methods:[],displayName:"SmartUpload"};var j,q,w;l.parameters={...l.parameters,docs:{...(j=l.parameters)==null?void 0:j.docs,source:{originalSource:`() => {
|
|
2
2
|
const [visible, setVisible] = useState(true);
|
|
3
3
|
const openModal = () => {
|
|
4
4
|
setVisible(true);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{R as nt,r as fe}from"./index-DhsZuJvc.js";var R=function(){return R=Object.assign||function(e){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},R.apply(this,arguments)};function vt(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))}var v="-ms-",rt="-moz-",h="-webkit-",pe="comm",Ct="rule",Mt="decl",Me="@import",he="@keyframes",Ye="@layer",de=Math.abs,Yt=String.fromCharCode,Dt=Object.assign;function We(t,e){return _(t,0)^45?(((e<<2^_(t,0))<<2^_(t,1))<<2^_(t,2))<<2^_(t,3):0}function le(t){return t.trim()}function D(t,e){return(t=e.exec(t))?t[0]:t}function u(t,e,r){return t.replace(e,r)}function dt(t,e,r){return t.indexOf(e,r)}function _(t,e){return t.charCodeAt(e)|0}function H(t,e,r){return t.slice(e,r)}function O(t){return t.length}function ge(t){return t.length}function et(t,e){return e.push(t),t}function He(t,e){return t.map(e).join("")}function Zt(t,e){return t.filter(function(r){return!D(r,e)})}var xt=1,q=1,me=0,k=0,I=0,J="";function At(t,e,r,n,s,o,a,c){return{value:t,root:e,parent:r,type:n,props:s,children:o,line:xt,column:q,length:a,return:"",siblings:c}}function F(t,e){return Dt(At("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},e)}function Y(t){for(;t.root;)t=F(t.root,{children:[t]});et(t,t.siblings)}function qe(){return I}function Ke(){return I=k>0?_(J,--k):0,q--,I===10&&(q=1,xt--),I}function N(){return I=k<me?_(J,k++):0,q++,I===10&&(q=1,xt++),I}function L(){return _(J,k)}function lt(){return k}function It(t,e){return H(J,t,e)}function jt(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Ue(t){return xt=q=1,me=O(J=t),k=0,[]}function Ze(t){return J="",t}function kt(t){return le(It(k-1,zt(t===91?t+2:t===40?t+1:t)))}function Je(t){for(;(I=L())&&I<33;)N();return jt(t)>2||jt(I)>3?"":" "}function Qe(t,e){for(;--e&&N()&&!(I<48||I>102||I>57&&I<65||I>70&&I<97););return It(t,lt()+(e<6&&L()==32&&N()==32))}function zt(t){for(;N();)switch(I){case t:return k;case 34:case 39:t!==34&&t!==39&&zt(I);break;case 40:t===41&&zt(t);break;case 92:N();break}return k}function Ve(t,e){for(;N()&&t+I!==57;)if(t+I===84&&L()===47)break;return"/*"+It(e,k-1)+"*"+Yt(t===47?t:N())}function Xe(t){for(;!jt(L());)N();return It(t,k)}function tr(t){return Ze(gt("",null,null,null,[""],t=Ue(t),0,[0],t))}function gt(t,e,r,n,s,o,a,c,i){for(var l=0,d=0,g=a,m=0,p=0,S=0,x=1,$=1,A=1,w=0,b="",C=s,E=o,y=n,f=b;$;)switch(S=w,w=N()){case 40:if(S!=108&&_(f,g-1)==58){dt(f+=u(kt(w),"&","&\f"),"&\f",de(l?c[l-1]:0))!=-1&&(A=-1);break}case 34:case 39:case 91:f+=kt(w);break;case 9:case 10:case 13:case 32:f+=Je(S);break;case 92:f+=Qe(lt()-1,7);continue;case 47:switch(L()){case 42:case 47:et(er(Ve(N(),lt()),e,r,i),i);break;default:f+="/"}break;case 123*x:c[l++]=O(f)*A;case 125*x:case 59:case 0:switch(w){case 0:case 125:$=0;case 59+d:A==-1&&(f=u(f,/\f/g,"")),p>0&&O(f)-g&&et(p>32?Qt(f+";",n,r,g-1,i):Qt(u(f," ","")+";",n,r,g-2,i),i);break;case 59:f+=";";default:if(et(y=Jt(f,e,r,l,d,s,c,b,C=[],E=[],g,o),o),w===123)if(d===0)gt(f,e,y,y,C,o,g,c,E);else switch(m===99&&_(f,3)===110?100:m){case 100:case 108:case 109:case 115:gt(t,y,y,n&&et(Jt(t,y,y,0,0,s,c,b,s,C=[],g,E),E),s,E,g,c,n?C:E);break;default:gt(f,y,y,y,[""],E,0,c,E)}}l=d=p=0,x=A=1,b=f="",g=a;break;case 58:g=1+O(f),p=S;default:if(x<1){if(w==123)--x;else if(w==125&&x++==0&&Ke()==125)continue}switch(f+=Yt(w),w*x){case 38:A=d>0?1:(f+="\f",-1);break;case 44:c[l++]=(O(f)-1)*A,A=1;break;case 64:L()===45&&(f+=kt(N())),m=L(),d=g=O(b=f+=Xe(lt())),w++;break;case 45:S===45&&O(f)==2&&(x=0)}}return o}function Jt(t,e,r,n,s,o,a,c,i,l,d,g){for(var m=s-1,p=s===0?o:[""],S=ge(p),x=0,$=0,A=0;x<n;++x)for(var w=0,b=H(t,m+1,m=de($=a[x])),C=t;w<S;++w)(C=le($>0?p[w]+" "+b:u(b,/&\f/g,p[w])))&&(i[A++]=C);return At(t,e,r,s===0?Ct:c,i,l,d,g)}function er(t,e,r,n){return At(t,e,r,pe,Yt(qe()),H(t,2,-2),0,n)}function Qt(t,e,r,n,s){return At(t,e,r,Mt,H(t,0,n),H(t,n+1,-1),n,s)}function ye(t,e,r){switch(We(t,e)){case 5103:return h+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return h+t+t;case 4789:return rt+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return h+t+rt+t+v+t+t;case 5936:switch(_(t,e+11)){case 114:return h+t+v+u(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return h+t+v+u(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return h+t+v+u(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return h+t+v+t+t;case 6165:return h+t+v+"flex-"+t+t;case 5187:return h+t+u(t,/(\w+).+(:[^]+)/,h+"box-$1$2"+v+"flex-$1$2")+t;case 5443:return h+t+v+"flex-item-"+u(t,/flex-|-self/g,"")+(D(t,/flex-|baseline/)?"":v+"grid-row-"+u(t,/flex-|-self/g,""))+t;case 4675:return h+t+v+"flex-line-pack"+u(t,/align-content|flex-|-self/g,"")+t;case 5548:return h+t+v+u(t,"shrink","negative")+t;case 5292:return h+t+v+u(t,"basis","preferred-size")+t;case 6060:return h+"box-"+u(t,"-grow","")+h+t+v+u(t,"grow","positive")+t;case 4554:return h+u(t,/([^-])(transform)/g,"$1"+h+"$2")+t;case 6187:return u(u(u(t,/(zoom-|grab)/,h+"$1"),/(image-set)/,h+"$1"),t,"")+t;case 5495:case 3959:return u(t,/(image-set\([^]*)/,h+"$1$`$1");case 4968:return u(u(t,/(.+:)(flex-)?(.*)/,h+"box-pack:$3"+v+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+h+t+t;case 4200:if(!D(t,/flex-|baseline/))return v+"grid-column-align"+H(t,e)+t;break;case 2592:case 3360:return v+u(t,"template-","")+t;case 4384:case 3616:return r&&r.some(function(n,s){return e=s,D(n.props,/grid-\w+-end/)})?~dt(t+(r=r[e].value),"span",0)?t:v+u(t,"-start","")+t+v+"grid-row-span:"+(~dt(r,"span",0)?D(r,/\d+/):+D(r,/\d+/)-+D(t,/\d+/))+";":v+u(t,"-start","")+t;case 4896:case 4128:return r&&r.some(function(n){return D(n.props,/grid-\w+-start/)})?t:v+u(u(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return u(t,/(.+)-inline(.+)/,h+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(O(t)-1-e>6)switch(_(t,e+1)){case 109:if(_(t,e+4)!==45)break;case 102:return u(t,/(.+:)(.+)-([^]+)/,"$1"+h+"$2-$3$1"+rt+(_(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~dt(t,"stretch",0)?ye(u(t,"stretch","fill-available"),e,r)+t:t}break;case 5152:case 5920:return u(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,o,a,c,i,l){return v+s+":"+o+l+(a?v+s+"-span:"+(c?i:+i-+o)+l:"")+t});case 4949:if(_(t,e+6)===121)return u(t,":",":"+h)+t;break;case 6444:switch(_(t,_(t,14)===45?18:11)){case 120:return u(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+h+(_(t,14)===45?"inline-":"")+"box$3$1"+h+"$2$3$1"+v+"$2box$3")+t;case 100:return u(t,":",":"+v)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return u(t,"scroll-","scroll-snap-")+t}return t}function bt(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function rr(t,e,r,n){switch(t.type){case Ye:if(t.children.length)break;case Me:case Mt:return t.return=t.return||t.value;case pe:return"";case he:return t.return=t.value+"{"+bt(t.children,n)+"}";case Ct:if(!O(t.value=t.props.join(",")))return""}return O(r=bt(t.children,n))?t.return=t.value+"{"+r+"}":""}function nr(t){var e=ge(t);return function(r,n,s,o){for(var a="",c=0;c<e;c++)a+=t[c](r,n,s,o)||"";return a}}function sr(t){return function(e){e.root||(e=e.return)&&t(e)}}function or(t,e,r,n){if(t.length>-1&&!t.return)switch(t.type){case Mt:t.return=ye(t.value,t.length,r);return;case he:return bt([F(t,{value:u(t.value,"@","@"+h)})],n);case Ct:if(t.length)return He(r=t.props,function(s){switch(D(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Y(F(t,{props:[u(s,/:(read-\w+)/,":"+rt+"$1")]})),Y(F(t,{props:[s]})),Dt(t,{props:Zt(r,n)});break;case"::placeholder":Y(F(t,{props:[u(s,/:(plac\w+)/,":"+h+"input-$1")]})),Y(F(t,{props:[u(s,/:(plac\w+)/,":"+rt+"$1")]})),Y(F(t,{props:[u(s,/:(plac\w+)/,v+"input-$1")]})),Y(F(t,{props:[s]})),Dt(t,{props:Zt(r,n)});break}return""})}}var ar={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},P={},K=typeof process<"u"&&P!==void 0&&(P.REACT_APP_SC_ATTR||P.SC_ATTR)||"data-styled",ve="active",be="data-styled-version",Et="6.1.12",Wt=`/*!sc*/
|
|
2
|
+
`,St=typeof window<"u"&&"HTMLElement"in window,ir=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&P!==void 0&&P.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&P.REACT_APP_SC_DISABLE_SPEEDY!==""?P.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&P.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&P!==void 0&&P.SC_DISABLE_SPEEDY!==void 0&&P.SC_DISABLE_SPEEDY!==""&&P.SC_DISABLE_SPEEDY!=="false"&&P.SC_DISABLE_SPEEDY),_t=Object.freeze([]),U=Object.freeze({});function cr(t,e,r){return r===void 0&&(r=U),t.theme!==r.theme&&t.theme||e||r.theme}var Se=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),ur=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,fr=/(^-|-$)/g;function Vt(t){return t.replace(ur,"-").replace(fr,"")}var pr=/(a)(d)/gi,pt=52,Xt=function(t){return String.fromCharCode(t+(t>25?39:97))};function Ft(t){var e,r="";for(e=Math.abs(t);e>pt;e=e/pt|0)r=Xt(e%pt)+r;return(Xt(e%pt)+r).replace(pr,"$1-$2")}var Nt,we=5381,W=function(t,e){for(var r=e.length;r;)t=33*t^e.charCodeAt(--r);return t},Ce=function(t){return W(we,t)};function hr(t){return Ft(Ce(t)>>>0)}function dr(t){return t.displayName||t.name||"Component"}function Ot(t){return typeof t=="string"&&!0}var xe=typeof Symbol=="function"&&Symbol.for,Ae=xe?Symbol.for("react.memo"):60115,lr=xe?Symbol.for("react.forward_ref"):60112,gr={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},mr={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Ie={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},yr=((Nt={})[lr]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Nt[Ae]=Ie,Nt);function te(t){return("type"in(e=t)&&e.type.$$typeof)===Ae?Ie:"$$typeof"in t?yr[t.$$typeof]:gr;var e}var vr=Object.defineProperty,br=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Sr=Object.getOwnPropertyDescriptor,wr=Object.getPrototypeOf,re=Object.prototype;function Ee(t,e,r){if(typeof e!="string"){if(re){var n=wr(e);n&&n!==re&&Ee(t,n,r)}var s=br(e);ee&&(s=s.concat(ee(e)));for(var o=te(t),a=te(e),c=0;c<s.length;++c){var i=s[c];if(!(i in mr||r&&r[i]||a&&i in a||o&&i in o)){var l=Sr(e,i);try{vr(t,i,l)}catch{}}}}return t}function Z(t){return typeof t=="function"}function Ht(t){return typeof t=="object"&&"styledComponentId"in t}function B(t,e){return t&&e?"".concat(t," ").concat(e):t||e||""}function ne(t,e){if(t.length===0)return"";for(var r=t[0],n=1;n<t.length;n++)r+=t[n];return r}function st(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function Gt(t,e,r){if(r===void 0&&(r=!1),!r&&!st(t)&&!Array.isArray(t))return e;if(Array.isArray(e))for(var n=0;n<e.length;n++)t[n]=Gt(t[n],e[n]);else if(st(e))for(var n in e)t[n]=Gt(t[n],e[n]);return t}function qt(t,e){Object.defineProperty(t,"toString",{value:e})}function ot(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(e.length>0?" Args: ".concat(e.join(", ")):""))}var Cr=function(){function t(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return t.prototype.indexOfGroup=function(e){for(var r=0,n=0;n<e;n++)r+=this.groupSizes[n];return r},t.prototype.insertRules=function(e,r){if(e>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,o=s;e>=o;)if((o<<=1)<0)throw ot(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var a=s;a<o;a++)this.groupSizes[a]=0}for(var c=this.indexOfGroup(e+1),i=(a=0,r.length);a<i;a++)this.tag.insertRule(c,r[a])&&(this.groupSizes[e]++,c++)},t.prototype.clearGroup=function(e){if(e<this.length){var r=this.groupSizes[e],n=this.indexOfGroup(e),s=n+r;this.groupSizes[e]=0;for(var o=n;o<s;o++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(e){var r="";if(e>=this.length||this.groupSizes[e]===0)return r;for(var n=this.groupSizes[e],s=this.indexOfGroup(e),o=s+n,a=s;a<o;a++)r+="".concat(this.tag.getRule(a)).concat(Wt);return r},t}(),mt=new Map,wt=new Map,yt=1,ht=function(t){if(mt.has(t))return mt.get(t);for(;wt.has(yt);)yt++;var e=yt++;return mt.set(t,e),wt.set(e,t),e},xr=function(t,e){yt=e+1,mt.set(t,e),wt.set(e,t)},Ar="style[".concat(K,"][").concat(be,'="').concat(Et,'"]'),Ir=new RegExp("^".concat(K,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Er=function(t,e,r){for(var n,s=r.split(","),o=0,a=s.length;o<a;o++)(n=s[o])&&t.registerName(e,n)},_r=function(t,e){for(var r,n=((r=e.textContent)!==null&&r!==void 0?r:"").split(Wt),s=[],o=0,a=n.length;o<a;o++){var c=n[o].trim();if(c){var i=c.match(Ir);if(i){var l=0|parseInt(i[1],10),d=i[2];l!==0&&(xr(d,l),Er(t,d,i[3]),t.getTag().insertRules(l,s)),s.length=0}else s.push(c)}}},se=function(t){for(var e=document.querySelectorAll(Ar),r=0,n=e.length;r<n;r++){var s=e[r];s&&s.getAttribute(K)!==ve&&(_r(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function Rr(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var _e=function(t){var e=document.head,r=t||e,n=document.createElement("style"),s=function(c){var i=Array.from(c.querySelectorAll("style[".concat(K,"]")));return i[i.length-1]}(r),o=s!==void 0?s.nextSibling:null;n.setAttribute(K,ve),n.setAttribute(be,Et);var a=Rr();return a&&n.setAttribute("nonce",a),r.insertBefore(n,o),n},$r=function(){function t(e){this.element=_e(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(r){if(r.sheet)return r.sheet;for(var n=document.styleSheets,s=0,o=n.length;s<o;s++){var a=n[s];if(a.ownerNode===r)return a}throw ot(17)}(this.element),this.length=0}return t.prototype.insertRule=function(e,r){try{return this.sheet.insertRule(r,e),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},t.prototype.getRule=function(e){var r=this.sheet.cssRules[e];return r&&r.cssText?r.cssText:""},t}(),Pr=function(){function t(e){this.element=_e(e),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(e,r){if(e<=this.length&&e>=0){var n=document.createTextNode(r);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},t}(),kr=function(){function t(e){this.rules=[],this.length=0}return t.prototype.insertRule=function(e,r){return e<=this.length&&(this.rules.splice(e,0,r),this.length++,!0)},t.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},t.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},t}(),oe=St,Nr={isServer:!St,useCSSOMInjection:!ir},Re=function(){function t(e,r,n){e===void 0&&(e=U),r===void 0&&(r={});var s=this;this.options=R(R({},Nr),e),this.gs=r,this.names=new Map(n),this.server=!!e.isServer,!this.server&&St&&oe&&(oe=!1,se(this)),qt(this,function(){return function(o){for(var a=o.getTag(),c=a.length,i="",l=function(g){var m=function(A){return wt.get(A)}(g);if(m===void 0)return"continue";var p=o.names.get(m),S=a.getGroup(g);if(p===void 0||!p.size||S.length===0)return"continue";var x="".concat(K,".g").concat(g,'[id="').concat(m,'"]'),$="";p!==void 0&&p.forEach(function(A){A.length>0&&($+="".concat(A,","))}),i+="".concat(S).concat(x,'{content:"').concat($,'"}').concat(Wt)},d=0;d<c;d++)l(d);return i}(s)})}return t.registerId=function(e){return ht(e)},t.prototype.rehydrate=function(){!this.server&&St&&se(this)},t.prototype.reconstructWithOptions=function(e,r){return r===void 0&&(r=!0),new t(R(R({},this.options),e),this.gs,r&&this.names||void 0)},t.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(e=function(r){var n=r.useCSSOMInjection,s=r.target;return r.isServer?new kr(s):n?new $r(s):new Pr(s)}(this.options),new Cr(e)));var e},t.prototype.hasNameForId=function(e,r){return this.names.has(e)&&this.names.get(e).has(r)},t.prototype.registerName=function(e,r){if(ht(e),this.names.has(e))this.names.get(e).add(r);else{var n=new Set;n.add(r),this.names.set(e,n)}},t.prototype.insertRules=function(e,r,n){this.registerName(e,r),this.getTag().insertRules(ht(e),n)},t.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},t.prototype.clearRules=function(e){this.getTag().clearGroup(ht(e)),this.clearNames(e)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Or=/&/g,Tr=/^\s*\/\/.*$/gm;function $e(t,e){return t.map(function(r){return r.type==="rule"&&(r.value="".concat(e," ").concat(r.value),r.value=r.value.replaceAll(",",",".concat(e," ")),r.props=r.props.map(function(n){return"".concat(e," ").concat(n)})),Array.isArray(r.children)&&r.type!=="@keyframes"&&(r.children=$e(r.children,e)),r})}function Dr(t){var e,r,n,s=U,o=s.options,a=o===void 0?U:o,c=s.plugins,i=c===void 0?_t:c,l=function(m,p,S){return S.startsWith(r)&&S.endsWith(r)&&S.replaceAll(r,"").length>0?".".concat(e):m},d=i.slice();d.push(function(m){m.type===Ct&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Or,r).replace(n,l))}),a.prefix&&d.push(or),d.push(rr);var g=function(m,p,S,x){p===void 0&&(p=""),S===void 0&&(S=""),x===void 0&&(x="&"),e=x,r=p,n=new RegExp("\\".concat(r,"\\b"),"g");var $=m.replace(Tr,""),A=tr(S||p?"".concat(S," ").concat(p," { ").concat($," }"):$);a.namespace&&(A=$e(A,a.namespace));var w=[];return bt(A,nr(d.concat(sr(function(b){return w.push(b)})))),w};return g.hash=i.length?i.reduce(function(m,p){return p.name||ot(15),W(m,p.name)},we).toString():"",g}var jr=new Re,Bt=Dr(),Pe=nt.createContext({shouldForwardProp:void 0,styleSheet:jr,stylis:Bt});Pe.Consumer;nt.createContext(void 0);function ae(){return fe.useContext(Pe)}var zr=function(){function t(e,r){var n=this;this.inject=function(s,o){o===void 0&&(o=Bt);var a=n.name+o.hash;s.hasNameForId(n.id,a)||s.insertRules(n.id,a,o(n.rules,a,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=r,qt(this,function(){throw ot(12,String(n.name))})}return t.prototype.getName=function(e){return e===void 0&&(e=Bt),this.name+e.hash},t}(),Fr=function(t){return t>="A"&&t<="Z"};function ie(t){for(var e="",r=0;r<t.length;r++){var n=t[r];if(r===1&&n==="-"&&t[0]==="-")return t;Fr(n)?e+="-"+n.toLowerCase():e+=n}return e.startsWith("ms-")?"-"+e:e}var ke=function(t){return t==null||t===!1||t===""},Ne=function(t){var e,r,n=[];for(var s in t){var o=t[s];t.hasOwnProperty(s)&&!ke(o)&&(Array.isArray(o)&&o.isCss||Z(o)?n.push("".concat(ie(s),":"),o,";"):st(o)?n.push.apply(n,vt(vt(["".concat(s," {")],Ne(o),!1),["}"],!1)):n.push("".concat(ie(s),": ").concat((e=s,(r=o)==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||e in ar||e.startsWith("--")?String(r).trim():"".concat(r,"px")),";")))}return n};function M(t,e,r,n){if(ke(t))return[];if(Ht(t))return[".".concat(t.styledComponentId)];if(Z(t)){if(!Z(o=t)||o.prototype&&o.prototype.isReactComponent||!e)return[t];var s=t(e);return M(s,e,r,n)}var o;return t instanceof zr?r?(t.inject(r,n),[t.getName(n)]):[t]:st(t)?Ne(t):Array.isArray(t)?Array.prototype.concat.apply(_t,t.map(function(a){return M(a,e,r,n)})):[t.toString()]}function Gr(t){for(var e=0;e<t.length;e+=1){var r=t[e];if(Z(r)&&!Ht(r))return!1}return!0}var Br=Ce(Et),Lr=function(){function t(e,r,n){this.rules=e,this.staticRulesId="",this.isStatic=(n===void 0||n.isStatic)&&Gr(e),this.componentId=r,this.baseHash=W(Br,r),this.baseStyle=n,Re.registerId(r)}return t.prototype.generateAndInjectStyles=function(e,r,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,r,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&r.hasNameForId(this.componentId,this.staticRulesId))s=B(s,this.staticRulesId);else{var o=ne(M(this.rules,e,r,n)),a=Ft(W(this.baseHash,o)>>>0);if(!r.hasNameForId(this.componentId,a)){var c=n(o,".".concat(a),void 0,this.componentId);r.insertRules(this.componentId,a,c)}s=B(s,a),this.staticRulesId=a}else{for(var i=W(this.baseHash,n.hash),l="",d=0;d<this.rules.length;d++){var g=this.rules[d];if(typeof g=="string")l+=g;else if(g){var m=ne(M(g,e,r,n));i=W(i,m+d),l+=m}}if(l){var p=Ft(i>>>0);r.hasNameForId(this.componentId,p)||r.insertRules(this.componentId,p,n(l,".".concat(p),void 0,this.componentId)),s=B(s,p)}}return s},t}(),Oe=nt.createContext(void 0);Oe.Consumer;var Tt={};function Mr(t,e,r){var n=Ht(t),s=t,o=!Ot(t),a=e.attrs,c=a===void 0?_t:a,i=e.componentId,l=i===void 0?function(C,E){var y=typeof C!="string"?"sc":Vt(C);Tt[y]=(Tt[y]||0)+1;var f="".concat(y,"-").concat(hr(Et+y+Tt[y]));return E?"".concat(E,"-").concat(f):f}(e.displayName,e.parentComponentId):i,d=e.displayName,g=d===void 0?function(C){return Ot(C)?"styled.".concat(C):"Styled(".concat(dr(C),")")}(t):d,m=e.displayName&&e.componentId?"".concat(Vt(e.displayName),"-").concat(e.componentId):e.componentId||l,p=n&&s.attrs?s.attrs.concat(c).filter(Boolean):c,S=e.shouldForwardProp;if(n&&s.shouldForwardProp){var x=s.shouldForwardProp;if(e.shouldForwardProp){var $=e.shouldForwardProp;S=function(C,E){return x(C,E)&&$(C,E)}}else S=x}var A=new Lr(r,m,n?s.componentStyle:void 0);function w(C,E){return function(y,f,Q){var at=y.attrs,De=y.componentStyle,je=y.defaultProps,ze=y.foldedComponentIds,Fe=y.styledComponentId,Ge=y.target,Be=nt.useContext(Oe),Le=ae(),Rt=y.shouldForwardProp||Le.shouldForwardProp,Kt=cr(f,Be,je)||U,T=function(ct,X,ut){for(var tt,G=R(R({},X),{className:void 0,theme:ut}),Pt=0;Pt<ct.length;Pt+=1){var ft=Z(tt=ct[Pt])?tt(G):tt;for(var z in ft)G[z]=z==="className"?B(G[z],ft[z]):z==="style"?R(R({},G[z]),ft[z]):ft[z]}return X.className&&(G.className=B(G.className,X.className)),G}(at,f,Kt),it=T.as||Ge,V={};for(var j in T)T[j]===void 0||j[0]==="$"||j==="as"||j==="theme"&&T.theme===Kt||(j==="forwardedAs"?V.as=T.forwardedAs:Rt&&!Rt(j,it)||(V[j]=T[j]));var Ut=function(ct,X){var ut=ae(),tt=ct.generateAndInjectStyles(X,ut.styleSheet,ut.stylis);return tt}(De,T),$t=B(ze,Fe);return Ut&&($t+=" "+Ut),T.className&&($t+=" "+T.className),V[Ot(it)&&!Se.has(it)?"class":"className"]=$t,V.ref=Q,fe.createElement(it,V)}(b,C,E)}w.displayName=g;var b=nt.forwardRef(w);return b.attrs=p,b.componentStyle=A,b.displayName=g,b.shouldForwardProp=S,b.foldedComponentIds=n?B(s.foldedComponentIds,s.styledComponentId):"",b.styledComponentId=m,b.target=n?s.target:t,Object.defineProperty(b,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(C){this._foldedDefaultProps=n?function(E){for(var y=[],f=1;f<arguments.length;f++)y[f-1]=arguments[f];for(var Q=0,at=y;Q<at.length;Q++)Gt(E,at[Q],!0);return E}({},s.defaultProps,C):C}}),qt(b,function(){return".".concat(b.styledComponentId)}),o&&Ee(b,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),b}function ce(t,e){for(var r=[t[0]],n=0,s=e.length;n<s;n+=1)r.push(e[n],t[n+1]);return r}var ue=function(t){return Object.assign(t,{isCss:!0})};function Yr(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(Z(t)||st(t))return ue(M(ce(_t,vt([t],e,!0))));var n=t;return e.length===0&&n.length===1&&typeof n[0]=="string"?M(n):ue(M(ce(n,e)))}function Lt(t,e,r){if(r===void 0&&(r=U),!e)throw ot(1,e);var n=function(s){for(var o=[],a=1;a<arguments.length;a++)o[a-1]=arguments[a];return t(e,r,Yr.apply(void 0,vt([s],o,!1)))};return n.attrs=function(s){return Lt(t,e,R(R({},r),{attrs:Array.prototype.concat(r.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return Lt(t,e,R(R({},r),s))},n}var Te=function(t){return Lt(Mr,t)},Wr=Te;Se.forEach(function(t){Wr[t]=Te(t)});export{Wr as d,Yr as l};
|
|
@@ -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 v}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-BHd_uQHh.js";import{A as ae}from"./actions-CHgr8eL8.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-iSMIbR33.js";import{A as f,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-BW9trNAW.js";import{N as Me}from"./number-input-CD-fbjVQ.js";import{S as Ge}from"./select-C8iu4-uz.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-UmZ4Y_CR.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-BtCGePRy.js";import{S as ze}from"./slider-DAramr8j.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-CzZdWNnB.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_y9car_1",Ye="_inputHover_y9car_13",Je="_inputFocus_y9car_18",Qe="_inputError_y9car_25",Ze="_inputWarning_y9car_26",en="_inputDisabled_y9car_61",nn="_hideScrollbars_y9car_67",tn="_wrapper_y9car_85",rn="_bordered_y9car_93",an="_scroll_y9car_98",on="_table_y9car_108",sn="_striped_y9car_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId: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:dn.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 un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:I}=t,y=Number((p=(d=I==null?void 0:I.options)==null?void 0:d[0])==null?void 0:p.value);return u>y}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(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,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},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll: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],p=()=>{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:p,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 gn="_clickableRow_1ki29_1",yn="_hoverableRow_1ki29_4",In="_rowActive_1ki29_4",Cn="_expandableRow_1ki29_8",bn="_flush_1ki29_8",hn="_errorRow_1ki29_12",fn="_warningRow_1ki29_15",_n="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:gn,hoverableRow:yn,rowActive:In,expandableRow:Cn,flush:bn,errorRow:hn,warningRow:fn,dragIconCell:_n,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:v(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}},wn=(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."),[])},Tn="_inputInTable_u3xdj_1",vn="_inputHover_u3xdj_13",jn="_inputFocus_u3xdj_18",An="_inputError_u3xdj_25",Rn="_inputWarning_u3xdj_26",kn="_inputDisabled_u3xdj_61",qn="_hideScrollbars_u3xdj_67",Nn="_cell_u3xdj_77",Sn="_disabledLink_u3xdj_87",En="_inputWrapper_u3xdj_91",Hn="_breakWord_u3xdj_106",Ln="_inputCell_u3xdj_109",Wn="_sliderCell_u3xdj_112",Fn="_staticCell_u3xdj_116",Pn="_staticCellContent_u3xdj_119",Dn="_error_u3xdj_131",On="_warning_u3xdj_132",Bn="_unit_u3xdj_141",$n="_sortingCell_u3xdj_144",Mn="_sortingCellIcon_u3xdj_155",Gn="_icon_u3xdj_166",Vn="_checkBoxCell_u3xdj_170",Un="_iconCellWrapper_u3xdj_174",zn="_actionsCell_u3xdj_178",Kn="_rightAligned_u3xdj_186",Xn="_centerAligned_u3xdj_192",Yn="_leftAligned_u3xdj_198",Jn="_popover_u3xdj_201",Qn="_disabledPointerEvents_u3xdj_204",s={inputInTable:Tn,inputHover:vn,inputFocus:jn,inputError:An,inputWarning:Rn,inputDisabled:kn,hideScrollbars:qn,cell:Nn,disabledLink:Sn,inputWrapper:En,breakWord:Hn,inputCell:Ln,sliderCell:Wn,staticCell:Fn,staticCellContent:Pn,error:Dn,warning:On,unit:Bn,sortingCell:$n,sortingCellIcon:Mn,icon:Gn,checkBoxCell:Vn,iconCellWrapper:Un,actionsCell:zn,rightAligned:Kn,centerAligned:Xn,leftAligned:Yn,popover:Jn,disabledPointerEvents:Qn},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx($e,{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 xe=({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});xe.__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 we=({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(xe,{cell:e,columnAlignment:t,testId:r}):null});we.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error: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:v(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:v((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const 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 Ae=({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})})})};Ae.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Re=({cell:e})=>n.jsx(ae,{actions:e.actions});Re.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),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:p}=e,u=n.jsxs("div",{className:v(s.staticCellContent,p==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?I=>d&&d(I):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className: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(we,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(Te,{cell:e,testId:o});case"CheckBox":return n.jsx(ve,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(Ae,{cell:e});case"Actions":return n.jsx(Re,{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 R=(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))(R||{});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:p,width:u}=e,I=S.useRef(null),y={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(y,s),_=he(y,s,!0),F=e.type===R.INPUT||e.type===R.NUMBER_INPUT||e.type===R.SELECT||e.type===R.POPOVER?s.inputCell:e.type===R.SLIDER?s.sliderCell:e.type===R.CHECKBOX?s.checkBoxCell:e.type===R.ACTIONS?s.actionsCell:s.staticCell,j=v(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&I.current&&I.current.offsetWidth)??void 0,x={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:I,className:j,style:x,colSpan:d,rowSpan:p,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 v}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-BHd_uQHh.js";import{A as ae}from"./actions-CHgr8eL8.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-DXnrsBZs.js";import{A as f,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-BW9trNAW.js";import{N as Me}from"./number-input-FjN2w5Zq.js";import{S as Ge}from"./select-Br1k0mOD.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-UmZ4Y_CR.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-BtCGePRy.js";import{S as ze}from"./slider-DAramr8j.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-CzZdWNnB.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_y9car_1",Ye="_inputHover_y9car_13",Je="_inputFocus_y9car_18",Qe="_inputError_y9car_25",Ze="_inputWarning_y9car_26",en="_inputDisabled_y9car_61",nn="_hideScrollbars_y9car_67",tn="_wrapper_y9car_85",rn="_bordered_y9car_93",an="_scroll_y9car_98",on="_table_y9car_108",sn="_striped_y9car_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId: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:dn.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 un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:I}=t,y=Number((p=(d=I==null?void 0:I.options)==null?void 0:d[0])==null?void 0:p.value);return u>y}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(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,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},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll: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],p=()=>{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:p,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 gn="_clickableRow_1ki29_1",yn="_hoverableRow_1ki29_4",In="_rowActive_1ki29_4",Cn="_expandableRow_1ki29_8",bn="_flush_1ki29_8",hn="_errorRow_1ki29_12",fn="_warningRow_1ki29_15",_n="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:gn,hoverableRow:yn,rowActive:In,expandableRow:Cn,flush:bn,errorRow:hn,warningRow:fn,dragIconCell:_n,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:v(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}},wn=(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."),[])},Tn="_inputInTable_u3xdj_1",vn="_inputHover_u3xdj_13",jn="_inputFocus_u3xdj_18",An="_inputError_u3xdj_25",Rn="_inputWarning_u3xdj_26",kn="_inputDisabled_u3xdj_61",qn="_hideScrollbars_u3xdj_67",Nn="_cell_u3xdj_77",Sn="_disabledLink_u3xdj_87",En="_inputWrapper_u3xdj_91",Hn="_breakWord_u3xdj_106",Ln="_inputCell_u3xdj_109",Wn="_sliderCell_u3xdj_112",Fn="_staticCell_u3xdj_116",Pn="_staticCellContent_u3xdj_119",Dn="_error_u3xdj_131",On="_warning_u3xdj_132",Bn="_unit_u3xdj_141",$n="_sortingCell_u3xdj_144",Mn="_sortingCellIcon_u3xdj_155",Gn="_icon_u3xdj_166",Vn="_checkBoxCell_u3xdj_170",Un="_iconCellWrapper_u3xdj_174",zn="_actionsCell_u3xdj_178",Kn="_rightAligned_u3xdj_186",Xn="_centerAligned_u3xdj_192",Yn="_leftAligned_u3xdj_198",Jn="_popover_u3xdj_201",Qn="_disabledPointerEvents_u3xdj_204",s={inputInTable:Tn,inputHover:vn,inputFocus:jn,inputError:An,inputWarning:Rn,inputDisabled:kn,hideScrollbars:qn,cell:Nn,disabledLink:Sn,inputWrapper:En,breakWord:Hn,inputCell:Ln,sliderCell:Wn,staticCell:Fn,staticCellContent:Pn,error:Dn,warning:On,unit:Bn,sortingCell:$n,sortingCellIcon:Mn,icon:Gn,checkBoxCell:Vn,iconCellWrapper:Un,actionsCell:zn,rightAligned:Kn,centerAligned:Xn,leftAligned:Yn,popover:Jn,disabledPointerEvents:Qn},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx($e,{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 xe=({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});xe.__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 we=({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(xe,{cell:e,columnAlignment:t,testId:r}):null});we.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error: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:v(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:v((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const 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 Ae=({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})})})};Ae.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Re=({cell:e})=>n.jsx(ae,{actions:e.actions});Re.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),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:p}=e,u=n.jsxs("div",{className:v(s.staticCellContent,p==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?I=>d&&d(I):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className: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(we,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(Te,{cell:e,testId:o});case"CheckBox":return n.jsx(ve,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(Ae,{cell:e});case"Actions":return n.jsx(Re,{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 R=(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))(R||{});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:p,width:u}=e,I=S.useRef(null),y={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(y,s),_=he(y,s,!0),F=e.type===R.INPUT||e.type===R.NUMBER_INPUT||e.type===R.SELECT||e.type===R.POPOVER?s.inputCell:e.type===R.SLIDER?s.sliderCell:e.type===R.CHECKBOX?s.checkBoxCell:e.type===R.ACTIONS?s.actionsCell:s.staticCell,j=v(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&I.current&&I.current.offsetWidth)??void 0,x={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:I,className:j,style:x,colSpan:d,rowSpan:p,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-BHd_uQHh.js";import{G as le}from"./grid-B6LFPf51.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-ZQD4ELIM.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-BW9trNAW.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-CR9VpXHs.js";import"./styled-components.browser.esm-Bf0q9Yjk.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-CHgr8eL8.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./pagination-iSMIbR33.js";import"./select-C8iu4-uz.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-DIKP56UZ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CD-fbjVQ.js";import"./index-DQs5XS8h.js";import"./index-DRSy5Ssd.js";import"./check-box-BtCGePRy.js";import"./help-icon-Buhx5nl6.js";import"./slider-DAramr8j.js";import"./index-BI4_Bp97.js";import"./popover-CzZdWNnB.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 => {
|
|
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-BHd_uQHh.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-DMsE4ks-.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-BW9trNAW.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-CR9VpXHs.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-CHgr8eL8.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./pagination-DXnrsBZs.js";import"./select-Br1k0mOD.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-DIKP56UZ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-FjN2w5Zq.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-BtCGePRy.js";import"./help-icon-Buhx5nl6.js";import"./slider-DAramr8j.js";import"./index-BI4_Bp97.js";import"./popover-CzZdWNnB.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} />;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-
|
|
1
|
+
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-DMsE4ks-.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-CR9VpXHs.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-BHd_uQHh.js";import"./actions-CHgr8eL8.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./pagination-DXnrsBZs.js";import"./select-Br1k0mOD.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-DIKP56UZ.js";import"./input-BW9trNAW.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-FjN2w5Zq.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-BtCGePRy.js";import"./slider-DAramr8j.js";import"./index-BI4_Bp97.js";import"./popover-CzZdWNnB.js";import"./flex-EllkLxgO.js";const Gr={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const l=r.bind({});l.args={table:Q};var m,c,d;e.parameters={...e.parameters,docs:{...(m=e.parameters)==null?void 0:m.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as s}from"./jsx-runtime-eps93zm2.js";import{w as ss,e as l,u as y,a as E}from"./index-
|
|
1
|
+
import{j as s}from"./jsx-runtime-eps93zm2.js";import{w as ss,e as l,u as y,a as E}from"./index-DMAnyMX5.js";import{G as X}from"./grid-DRkC-bt8.js";import{T as w}from"./text-B3-TSWok.js";import{F as Z}from"./flex-EllkLxgO.js";import{t as S,d as b}from"./toaster-BNO0suPv.js";import{B as t}from"./button-VxhoNhrV.js";import{S as $}from"./spacer-BWoNR27H.js";import{a as C}from"./message-BYzRg8Ae.js";import"./index-DhsZuJvc.js";import"./index-CF7H4eMJ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./toaster-7wnI6hqB.js";import"./index-CUZDtIZe.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";const es={type:C.SUCCESS,icon:!0,heading:"Heading",content:"Great results"},os={type:C.ERROR,icon:!0,heading:"Heading",content:"An error has happened",details:"Bad input data lorem ipsum dolor est compendum lorem ipsum."},ts={type:C.WARNING,icon:!0,heading:"Heading",content:"Warning message"},as={type:C.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},Ds={title:"Modals/Toaster",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:as,autoClose:6e3,onClose:()=>{}}},h=e=>s.jsx(t,{onClick:()=>S({...e,onClose:()=>console.log("toast closed")}),label:"Show toast"}),T=h.bind({}),u=h.bind({});u.args={message:es};const d=h.bind({});d.args={message:ts};const m=h.bind({});m.args={message:os};const i=()=>s.jsx(t,{label:"Show Toast",onClick:()=>{const e=Math.random()>=.5;S({message:{type:e?"Success":"Error",icon:!0,content:e?"Success":"Error"},onClose:()=>console.log("toast closed"),id:"uniqueId"})}});i.parameters={docs:{iframeHeight:200,description:{story:"Pass a unique `id` in the `toast` object to prevent duplicates. Successive toasts with the same ID will update the existing toast."}}};const p=()=>{const e="sessionExpiring",a={type:"Info",content:s.jsxs(X,{children:[s.jsx(w,{bold:!0,children:"You will be signed out soon"}),s.jsx(w,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx($,{height:"var(--padding-xxs)"}),s.jsxs(Z,{gap:"var(--padding-xs)",children:[s.jsx(t,{label:"Extend session",small:!0,colored:"success",onClick:()=>b(e)}),s.jsx(t,{label:"Dismiss",small:!0,onClick:()=>b(e)})]})]})};return s.jsx(t,{label:"Show Toast",onClick:()=>S({message:a,autoClose:!1,id:e})})},g=()=>{const e="sessionExpiringSoon",a={type:"Error",content:s.jsxs(X,{children:[s.jsx(w,{bold:!0,children:"You will be signed out very soon"}),s.jsx(w,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx($,{height:"var(--padding-xxs)"}),s.jsxs(Z,{gap:"var(--padding-xs)",children:[s.jsx(t,{label:"Extend session",small:!0,colored:"success",onClick:()=>b(e)}),s.jsx(t,{label:"Dismiss",small:!0,onClick:()=>b(e)})]})]})};return s.jsx(t,{label:"Show Toast",onClick:()=>S({message:a,autoClose:!1,id:e})})},x=()=>{const e={type:"Success",content:"Your session has been extended for 1 hour"};return s.jsx(t,{label:"Show Toast",onClick:()=>S({message:e})})},c=h.bind({});c.args={id:"testId",autoClose:50};c.play=async({canvasElement:e,step:a})=>{const o=e.parentElement?ss(e.parentElement):null;await l(o).toBeTruthy(),o&&(await a("Toast should appear when triggered",async()=>{const r=o.getByText("Show toast");await y.click(r);const n=o.getByRole("alert");await l(n).toBeInTheDocument()}),await a("Duplicate toasts shouldn't be created",async()=>{const r=o.getByText("Show toast");await y.click(r);const n=o.queryAllByRole("alert");await l(n).toHaveLength(1)}),await a("Toast should disappear when close button pressed",async()=>{const r=o.getByRole("alert"),n=o.getByTestId("testId-dismiss");await y.click(n),await E(()=>l(r).not.toBeInTheDocument(),{timeout:2e3})}),await a("Toast should automatically close",async()=>{const r=o.getByText("Show toast");await y.click(r);const n=o.getByRole("alert");await E(()=>l(n).not.toBeInTheDocument(),{timeout:2e3})}))};i.__docgenInfo={description:"",methods:[],displayName:"PreventDuplicates"};p.__docgenInfo={description:"",methods:[],displayName:"SessionExpiring"};g.__docgenInfo={description:"",methods:[],displayName:"SessionExpiringSoon"};x.__docgenInfo={description:"",methods:[],displayName:"SessionExtended"};var I,f,B;T.parameters={...T.parameters,docs:{...(I=T.parameters)==null?void 0:I.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Button onClick={() => toast({
|
|
3
3
|
...args,
|
|
4
4
|
onClose: () => console.log('toast closed')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as de}from"./index-DhsZuJvc.js";import{w as oe,u as j,e as A}from"./index-
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as de}from"./index-DhsZuJvc.js";import{w as oe,u as j,e as A}from"./index-DMAnyMX5.js";import{F as f}from"./flex-EllkLxgO.js";import{T as C}from"./text-B3-TSWok.js";import{T as x}from"./toggle-CBpNgTrm.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";const{useArgs:le}=__STORYBOOK_MODULE_PREVIEW_API__,De={title:"Forms/Toggle",component:x,args:{label:"Label"}},s=a=>{const[{checked:r},t]=le(),n=()=>{t({checked:!r})};return e.jsx(x,{...a,onChange:n})},T=s.bind({}),d=s.bind({});d.args={disabled:!0};const l=s.bind({});l.args={checked:!0,disabled:!0};const g=s.bind({});g.args={small:!0};const p=s.bind({});p.args={label:null};const i=s.bind({});i.args={helpText:"Help text"};const h=s.bind({});h.args={onClickHelp:()=>console.log("Help clicked")};const u=()=>e.jsxs(e.Fragment,{children:[e.jsx(x,{display:"block",label:e.jsxs(f,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(C,{bold:!0,children:"Label"}),e.jsx(C,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}}),e.jsx(x,{label:e.jsxs(f,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(C,{bold:!0,children:"Label"}),e.jsx(C,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}})]}),m=()=>{const[a,r]=de.useState(!1);return e.jsx(x,{name:"name",label:"Label",checked:a,onChange:t=>{const{name:n,value:b,checked:y}=t.target;r(y),console.log(n,b,y)}})},k=s.bind({});k.args={helpText:"Help text",disabled:!0};const c=s.bind({});c.args={testId:"testId"};c.play=async({canvasElement:a,step:r})=>{const t=oe(a);await r("Clicking checkbox should toggle it",async()=>{const n=t.getByTestId("testId"),b=n.querySelector("input");await j.click(n),await A(b).toBeChecked(),await j.click(n),await A(b).not.toBeChecked()})};const o=s.bind({});o.args={testId:"testId",disabled:!0};o.play=async({canvasElement:a,step:r})=>{const t=oe(a);await r("Clicking disabled checkbox shouldn't toggle it",async()=>{const n=t.getByTestId("testId");await n.click(),await A(n.querySelector("input")).not.toBeChecked()})};u.__docgenInfo={description:"",methods:[],displayName:"Display"};m.__docgenInfo={description:"",methods:[],displayName:"TestClickevt"};var S,w,D;T.parameters={...T.parameters,docs:{...(S=T.parameters)==null?void 0:S.docs,source:{originalSource:`args => {
|
|
2
2
|
const [{
|
|
3
3
|
checked
|
|
4
4
|
}, updateArgs] = useArgs();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._predefinedMenuActive_ye9w9_1 input{background:var(--color-background-disabled)!important}._inputWrapper_ye9w9_4{flex:1}
|