@oliasoft-open-source/react-ui-library 4.6.15 → 4.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-6VNJS4EI--MtBZKKT.js → Color-6VNJS4EI-YEDm9gbz.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-NNNQARDV-zWIDUW8s.js → DocsRenderer-NNNQARDV-NmCW-oyQ.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-V3YHNWJZ-12HSM2HQ.js → WithTooltip-V3YHNWJZ-3DZ-8kE7.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-TsMdBhhr.js → accordion.stories-lXs4IRds.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-EBr5j6Pb.js → buttons-and-links-2FBaBkFc.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-cbxQQ8QL.js → casing-loads.stories-g4yBGv5b.js} +1 -1
- package/dist/storybook/assets/{cell.stories-S6RxEUZs.js → cell.stories-sVyam_bx.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-olKL1DOp.js → chunk-HLWAVYOI-tHzaOxem.js} +1 -1
- package/dist/storybook/assets/{color-cEIYsWoC.js → color-7OzxGyA_.js} +1 -1
- package/dist/storybook/assets/{footer.stories-C10mdMff.js → footer.stories-ZEZ_We0f.js} +1 -1
- package/dist/storybook/assets/{formation.stories-SDrsEBR-.js → formation.stories-062BdtdZ.js} +1 -1
- package/dist/storybook/assets/{formatter-SWP5E3XI-lcnUpu9o.js → formatter-SWP5E3XI-_Igw7BUr.js} +1 -1
- package/dist/storybook/assets/{iframe-tFrL7OgV.js → iframe-CpYMK6kb.js} +2 -2
- package/dist/storybook/assets/{index-i7J9GoJM.js → index-K-0S6d15.js} +5 -5
- package/dist/storybook/assets/{input-validation-PXF1N2vm.js → input-validation-gD2VptJq.js} +1 -1
- package/dist/storybook/assets/{inputs-WqrsreQN.js → inputs-xtYro1Lt.js} +1 -1
- package/dist/storybook/assets/{layout-forms-5QbjGxm5.js → layout-forms-NhJIOV9y.js} +1 -1
- package/dist/storybook/assets/{layout-general-6o2l_EdT.js → layout-general-wuAEAmS1.js} +1 -1
- package/dist/storybook/assets/{modal.stories-PLF80IYZ.js → modal.stories-aZGhb1Cl.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-A6N16ujc.js → padding-and-spacing-h7UETkPK.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-GmXpbAIC.js → pop-confirm.stories-6V_XrhKa.js} +1 -1
- package/dist/storybook/assets/popover-N9B8JT3G.js +1 -0
- package/dist/storybook/assets/popover.stories-goIrT_jy.js +10 -0
- package/dist/storybook/assets/{preview-jFWbYQuo.js → preview-T-saggOw.js} +1 -1
- package/dist/storybook/assets/{preview-xqKimQkP.js → preview-f-BBQod4.js} +2 -2
- package/dist/storybook/assets/{row.stories-JJLYUXaO.js → row.stories-ZibxnXR9.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-B5GMVT5T-MZJdrJvC.js → syntaxhighlighter-B5GMVT5T-d9li6xQn.js} +1 -1
- package/dist/storybook/assets/{table-38J6JCSb.js → table-kSTipYE0.js} +1 -1
- package/dist/storybook/assets/{table.stories-Sbzi__am.js → table.stories-zdRM5AV8.js} +1 -1
- package/dist/storybook/assets/{title.stories-qvk0Or3W.js → title.stories-tcfNoA6z.js} +1 -1
- package/dist/storybook/assets/{unit-table.stories-0Wv_gCzq.js → unit-table.stories-9k8rllRh.js} +1 -1
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/popover-Ioxe80BK.js +0 -1
- package/dist/storybook/assets/popover.stories-NbC7Zba8.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{M as r,C as n}from"./index-
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{M as r,C as n}from"./index-K-0S6d15.js";import{Center as d,SpaceBetween as a,JustifyEnd as c,Column as l}from"./flex.stories-xAOrglx5.js";import{Default as h,CustomColumnWidth as p,DefaultGap as x,CustomGap as m,Responsive as j}from"./grid.stories-hPfW-CxX.js";import{Default as u,FixedWidth as f,NoPadding as g,ResponsiveWidth as w}from"./column.stories-cX-u-DHI.js";import{useMDXComponents as s}from"./index-4YXVTraW.js";import"./index-RfLt4OUa.js";import"./iframe-CpYMK6kb.js";import"../sb-preview/runtime.js";import"./index-miLrID2P.js";import"./inheritsLoose-8sb_A2v4.js";import"./assertThisInitialized-4q6YPdh3.js";import"./index-R5dkQuFe.js";import"./index-PPLHz8o0.js";import"./flex-RYZsoWEN.js";import"./button-BiJw0fB3.js";import"./index-VW3EWkuE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./tooltip-dueTLnwA.js";import"./text-6KQ6ntOV.js";import"./grid-u1mZpaML.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./card-0r8RRVk-.js";import"./row-vFUhHoz5.js";import"./heading-4tVgoT7O.js";import"./help-icon-eelulTML.js";function t(i){const o=Object.assign({h1:"h1",h2:"h2",p:"p",code:"code",h3:"h3"},s(),i.components);return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Layout (General)"}),`
|
|
2
2
|
`,e.jsx(o.h1,{id:"layout-general",children:"Layout (General)"}),`
|
|
3
3
|
`,e.jsx(o.h2,{id:"flex",children:"Flex"}),`
|
|
4
4
|
`,e.jsxs(o.p,{children:["The ",e.jsx(o.code,{children:"Flex"})," component is a basic flexbox wrapper with optional props for ",e.jsx(o.code,{children:"alignItems"}),", ",e.jsx(o.code,{children:"justifyContent"})," and ",e.jsx(o.code,{children:"flexDirection"}),". This is a conveninent way to center items vertically and/or horizontally, to align them to opposite edges, or align them to the far side."]}),`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as h}from"./index-RfLt4OUa.js";import{T as X}from"./common-types-U65vzrrz.js";import{M as u,D as C}from"./dialog-Au78k7wS.js";import{B as o}from"./button-BiJw0fB3.js";import{P as Z}from"./popover-
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as h}from"./index-RfLt4OUa.js";import{T as X}from"./common-types-U65vzrrz.js";import{M as u,D as C}from"./dialog-Au78k7wS.js";import{B as o}from"./button-BiJw0fB3.js";import{P as Z}from"./popover-N9B8JT3G.js";import{I as Q}from"./input-fYKvBwPs.js";import{I as $}from"./input-group-R8LoqKRn.js";import{F as j}from"./field-m7XXDdEG.js";import{M as ee}from"./actions-7PO9r8zE.js";import{S as oe}from"./select-AcJYUY86.js";import{S as ne}from"./spacer-Yji9g2AW.js";import{T as le}from"./tooltip-dueTLnwA.js";import{M as k}from"./types-VB5zD18b.js";import"./index-VW3EWkuE.js";import"./portal-zPiHHKoC.js";import"./index-miLrID2P.js";import"./lodash-Bmg8FrMx.js";import"./heading-4tVgoT7O.js";import"./help-icon-eelulTML.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./disabled-context-urNQThQz.js";import"./spinner-R8Il4aRe.js";import"./types-5uVBABF4.js";import"./label-bLcoUwtK.js";import"./badge-23Ty_zBt.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./text-6KQ6ntOV.js";import"./select.input-zP5tW20f.js";const{useArgs:se}=__STORYBOOK_MODULE_ADDONS__,we={title:"Modals/Modal",component:u,args:{visible:!0,centered:!0,width:"300px",heading:"Are you sure?",content:e.jsx(e.Fragment,{children:"This will complete the transaction"}),footer:e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Okay",colored:!0,onClick:()=>{}}),e.jsx(o,{label:"Cancel",onClick:()=>{}})]}),onClose:()=>{}},parameters:{docs:{story:{inline:!1,iframeHeight:400}}}},a=()=>{const[{visible:l,centered:r,...s},n]=se(),t=()=>{n({visible:!l})};return e.jsxs(e.Fragment,{children:[e.jsx(u,{visible:l,centered:r,children:e.jsx(C,{dialog:{...s,onClose:t}})}),e.jsx(o,{label:"Open Modal",onClick:t})]})},b=a.bind({}),i=a.bind({});i.args={centered:!0};const d=a.bind({});d.args={content:["This is a","new line!"]};const c=a.bind({});c.args={scroll:!0,content:e.jsx("div",{children:"Example modal content goes here lorem ipsum. ".repeat(100)})};const g=a.bind({});g.args={width:"100%",content:e.jsx("div",{children:"Example modal content goes here lorem ipsum. ".repeat(100)})};const p=a.bind({});p.args={contentPadding:0};const m=a.bind({});m.args={content:e.jsxs(e.Fragment,{children:[e.jsx(le,{text:"Tooltip text",children:"Hover for tooltip"}),e.jsx(ne,{}),e.jsx(j,{label:"Custom Select",helpText:"Select an animal",children:e.jsx(oe,{name:"example",options:["Aardvarks","Kangaroos","Monkeys","Possums","Gorilla","Puma","Patagonian Mara","Tarsier","Koala","Panda","Red Panda","Impala","Tiger","Crocodile","Bat"],onChange:()=>{},value:"Monkeys",error:"Bad value"})}),e.jsx(j,{label:"Nested Menu",children:e.jsx(ee,{maxHeight:"240px",menu:{label:"Menu",trigger:X.DROP_DOWN_BUTTON,sections:[{type:k.MENU,menu:{trigger:"Text",label:"Children",sections:[...Array(100).keys()].map(()=>({type:"Option",label:Math.random().toString(36).substring(7),onClick:()=>{}}))}},...[...Array(100).keys()].map(()=>({type:k.OPTION,label:Math.random().toString(36).substring(7),onClick:()=>{}}))]}})}),e.jsx(Z,{content:e.jsxs($,{small:!0,children:[e.jsx(Q,{value:"Value",width:"150px",error:"Bad value"}),e.jsx(o,{colored:!0,label:"Save",onClick:()=>{}}),e.jsx(o,{label:"Cancel",onClick:()=>{}})]}),children:e.jsx(o,{colored:!0,label:"Toggle me",onClick:()=>{}})})]})};const M=()=>{const[l,r]=h.useState(!1),s=()=>{r(!0)},n=()=>{r(!1)},t=()=>{console.log("Submit action"),n()};return e.jsxs(e.Fragment,{children:[e.jsx(u,{visible:l,onEnter:()=>{console.log("Enter"),t()},onEscape:()=>{console.log("Escape"),n()},children:e.jsx(C,{dialog:{heading:"Test key handling",content:e.jsx(Q,{}),footer:e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Done",colored:"red",onClick:t}),e.jsx(o,{label:"Cancel",onClick:n})]}),onClose:n}})}),e.jsx(o,{label:"Open Modal",onClick:s})]})},v=()=>{const[l,r]=h.useState(!1),s=()=>r(!l),[n,t]=h.useState(!1),x=()=>t(!n);return e.jsxs(e.Fragment,{children:[e.jsx(u,{visible:l,children:e.jsx(C,{dialog:{heading:"Modal 1",content:"Lorem ipsum dolor sit amet",footer:e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Open modal 2",colored:!0,onClick:x}),e.jsx(u,{visible:n,children:e.jsx(C,{dialog:{heading:"Modal 2",content:"Lorem ipsum dolor sit amet",footer:e.jsx(o,{label:"Close",onClick:x}),onClose:x}})}),e.jsx(o,{label:"Close",onClick:s})]}),onClose:s}})}),e.jsx(o,{label:"Open modal 1",onClick:s})]})};var f,S,P;b.parameters={...b.parameters,docs:{...(f=b.parameters)==null?void 0:f.docs,source:{originalSource:`() => {
|
|
2
2
|
const [{
|
|
3
3
|
visible,
|
|
4
4
|
centered,
|
package/dist/storybook/assets/{padding-and-spacing-A6N16ujc.js → padding-and-spacing-h7UETkPK.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{M as r}from"./index-
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{M as r}from"./index-K-0S6d15.js";import{useMDXComponents as t}from"./index-4YXVTraW.js";import"./index-RfLt4OUa.js";import"./iframe-CpYMK6kb.js";import"../sb-preview/runtime.js";import"./index-miLrID2P.js";import"./inheritsLoose-8sb_A2v4.js";import"./assertThisInitialized-4q6YPdh3.js";import"./index-R5dkQuFe.js";import"./index-PPLHz8o0.js";function i(n){const s=Object.assign({h1:"h1",h2:"h2",p:"p",ul:"ul",li:"li",strong:"strong",code:"code"},t(),n.components);return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Padding, Margin & Size"}),`
|
|
2
2
|
`,e.jsx(s.h1,{id:"padding-margin--size",children:"Padding, Margin & Size"}),`
|
|
3
3
|
`,e.jsx(s.h2,{id:"padding--margin",children:"Padding & Margin"}),`
|
|
4
4
|
`,e.jsx(s.p,{children:"There are standard CSS spacing variables for padding and margin."}),`
|
package/dist/storybook/assets/{pop-confirm.stories-GmXpbAIC.js → pop-confirm.stories-6V_XrhKa.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t}from"./jsx-runtime-FsUICBgo.js";import{P as S}from"./popover-
|
|
1
|
+
import{j as t}from"./jsx-runtime-FsUICBgo.js";import{P as S}from"./popover-N9B8JT3G.js";import{B as c}from"./button-BiJw0fB3.js";import{T as w}from"./text-6KQ6ntOV.js";import{t as A}from"./toaster-yPcd4ELJ.js";import"./index-RfLt4OUa.js";import"./tooltip-dueTLnwA.js";import"./index-miLrID2P.js";import"./index-VW3EWkuE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./message-CRKuTfOl.js";const W="_popConfirm_1x6ye_1",$="_content_1x6ye_7",R="_buttons_1x6ye_13",v={popConfirm:W,content:$,buttons:R},x=({title:e,okText:p,onClickOk:m,disableConfirmButton:f,cancelText:C,onClickCancel:y,close:o,testId:s})=>t.jsxs("div",{className:v.popConfirm,children:[e&&t.jsx("div",{className:v.content,children:t.jsx(w,{small:!0,children:e})}),t.jsxs("div",{className:v.buttons,children:[t.jsx(c,{small:!0,colored:!0,label:p,onClick:()=>m(o),disabled:f,testId:`${s}-ok-button`}),t.jsx(c,{small:!0,label:C,onClick:()=>y(o),testId:`${s}-cancel-button`})]})]});try{x.displayName="Content",x.__docgenInfo={description:"",displayName:"Content",props:{title:{defaultValue:null,description:"",name:"title",required:!1,type:{name:"string"}},okText:{defaultValue:null,description:"",name:"okText",required:!0,type:{name:"string"}},onClickOk:{defaultValue:null,description:"",name:"onClickOk",required:!0,type:{name:"(close?: TEmpty | undefined) => void"}},disableConfirmButton:{defaultValue:null,description:"",name:"disableConfirmButton",required:!1,type:{name:"boolean"}},cancelText:{defaultValue:null,description:"",name:"cancelText",required:!0,type:{name:"string"}},onClickCancel:{defaultValue:null,description:"",name:"onClickCancel",required:!0,type:{name:"(close?: TEmpty | undefined) => void"}},close:{defaultValue:null,description:"",name:"close",required:!1,type:{name:"TEmpty"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const u=({children:e,placement:p="top-center",closeOnOutsideClick:m=!0,fullWidth:f=!1,title:C="",cancelText:y="Cancel",onClickCancel:o=l=>l&&l(),okText:s="Ok",onClickOk:N=()=>{},disableConfirmButton:D=!1,overflowContainer:I=!1,testId:b=void 0})=>{const l=t.jsx(x,{title:C,okText:s,onClickOk:N,disableConfirmButton:D,cancelText:y,onClickCancel:o,testId:b});return t.jsx(S,{content:l,placement:p,closeOnOutsideClick:m,fullWidth:f,overflowContainer:I,testId:b,children:e})};try{u.displayName="PopConfirm",u.__docgenInfo={description:"",displayName:"PopConfirm",props:{placement:{defaultValue:{value:"top-center"},description:"",name:"placement",required:!1,type:{name:"enum",value:[{value:'"top-center"'},{value:'"bottom-center"'},{value:'"center"'},{value:'"bottom-start"'},{value:'"bottom-end"'},{value:'"top-start"'},{value:'"top-end"'},{value:'"left-end"'},{value:'"left-center"'},{value:'"left-start"'},{value:'"right-end"'},{value:'"right-center"'},{value:'"right-start"'}]}},closeOnOutsideClick:{defaultValue:{value:"true"},description:"",name:"closeOnOutsideClick",required:!1,type:{name:"boolean"}},fullWidth:{defaultValue:{value:"false"},description:"",name:"fullWidth",required:!1,type:{name:"boolean"}},title:{defaultValue:{value:""},description:"",name:"title",required:!1,type:{name:"string"}},cancelText:{defaultValue:{value:"Cancel"},description:"",name:"cancelText",required:!1,type:{name:"string"}},onClickCancel:{defaultValue:{value:"(close) => close && close()"},description:"",name:"onClickCancel",required:!1,type:{name:"((close?: TEmpty) => void)"}},disableConfirmButton:{defaultValue:{value:"false"},description:"",name:"disableConfirmButton",required:!1,type:{name:"boolean"}},okText:{defaultValue:{value:"Ok"},description:"",name:"okText",required:!1,type:{name:"string"}},onClickOk:{defaultValue:{value:"() => {}"},description:"",name:"onClickOk",required:!1,type:{name:"((close?: TEmpty) => void)"}},overflowContainer:{defaultValue:{value:"false"},description:"",name:"overflowContainer",required:!1,type:{name:"boolean"}},testId:{defaultValue:{value:"undefined"},description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const Y=e=>{A({message:{type:"Success",content:"success!",details:"You successfully booked your cruise to Bahamas."}}),e()},se={title:"Basic/PopConfirm",component:u,args:{title:"Do you want a free cruise to Bahamas?",onClickCancel:e=>e(),onClickOk:Y,children:t.jsx(c,{label:"Click me!"}),overflowContainer:!0,placement:"top-center"},decorators:[e=>t.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e()})],parameters:{docs:{source:{excludeDecorators:!0}}}},d=e=>t.jsx(u,{...e}),i=d.bind({}),a=d.bind({});a.args={children:t.jsx(c,{small:!0,round:!0,basic:!0,colored:"muted",icon:"delete"})};const n=d.bind({});n.args={placement:"bottom-end"};const r=d.bind({});r.args={disableConfirmButton:!0};var g,k,_;i.parameters={...i.parameters,docs:{...(g=i.parameters)==null?void 0:g.docs,source:{originalSource:`args => <PopConfirm
|
|
2
2
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
3
3
|
{...args} />`,...(_=(k=i.parameters)==null?void 0:k.docs)==null?void 0:_.source}}};var j,q,V;a.parameters={...a.parameters,docs:{...(j=a.parameters)==null?void 0:j.docs,source:{originalSource:`args => <PopConfirm
|
|
4
4
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as n,R as c}from"./index-RfLt4OUa.js";import{u as j,A as B,i as k}from"./tooltip-dueTLnwA.js";import{c as f}from"./index-VW3EWkuE.js";import{I as P}from"./common-types-U65vzrrz.js";import{D as W}from"./disabled-context-urNQThQz.js";import{B as w}from"./button-BiJw0fB3.js";const E="_toggleBox_lhie5_1",S="_fullWidthStyleFix_lhie5_8",F="_dismiss_lhie5_13",r={toggleBox:E,fullWidthStyleFix:S,dismiss:F},p=({children:u,content:s,placement:m="top-center",closeOnOutsideClick:v=!0,fullWidth:g=!1,showCloseButton:x=!1,testId:y,disabled:t=!1,overflowContainer:h=!1,isOpen:d,onToggle:b})=>{const l=n.useContext(W),[i,o]=d!==void 0?[d,b]:n.useState(!1),a=()=>{!t&&!l&&o&&o(!1)},_=()=>{t||l||o&&o(!i)};n.useEffect(()=>{(t||l)&&a()},[t,l]);const{renderLayer:C,arrowProps:O,layerProps:V,triggerProps:q}=j({isOpen:i,placement:m,auto:!0,triggerOffset:6,onOutsideClick:v?a:void 0,ResizeObserver:k,overflowContainer:h});return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:q.ref,onClick:_,"data-testid":y,children:u}),i&&C(e.jsxs("div",{className:g?f(r.toggleBox,r.fullWidthStyleFix):f(r.toggleBox),...V,children:[e.jsxs("div",{children:[c.isValidElement(s)?c.cloneElement(s,{close:a}):s,x&&e.jsx("div",{className:r.dismiss,children:e.jsx(w,{small:!0,round:!0,onClick:a,icon:P.CLOSE})})]}),e.jsx(B,{...O,backgroundColor:"var(--color-background-layer)",borderColor:"var(--color-border)",borderWidth:1,size:6})]}))]})};try{p.displayName="Popover",p.__docgenInfo={description:"",displayName:"Popover",props:{content:{defaultValue:null,description:"",name:"content",required:!1,type:{name:"ReactNode"}},placement:{defaultValue:{value:"top-center"},description:"",name:"placement",required:!1,type:{name:"enum",value:[{value:'"top-center"'},{value:'"bottom-center"'},{value:'"center"'},{value:'"bottom-start"'},{value:'"bottom-end"'},{value:'"top-start"'},{value:'"top-end"'},{value:'"left-end"'},{value:'"left-center"'},{value:'"left-start"'},{value:'"right-end"'},{value:'"right-center"'},{value:'"right-start"'}]}},closeOnOutsideClick:{defaultValue:{value:"true"},description:"",name:"closeOnOutsideClick",required:!1,type:{name:"boolean"}},fullWidth:{defaultValue:{value:"false"},description:"",name:"fullWidth",required:!1,type:{name:"boolean"}},showCloseButton:{defaultValue:{value:"false"},description:"",name:"showCloseButton",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}},disabled:{defaultValue:{value:"false"},description:"",name:"disabled",required:!1,type:{name:"boolean"}},overflowContainer:{defaultValue:{value:"false"},description:"",name:"overflowContainer",required:!1,type:{name:"boolean"}},isOpen:{defaultValue:null,description:"",name:"isOpen",required:!1,type:{name:"boolean"}},onToggle:{defaultValue:null,description:"",name:"onToggle",required:!1,type:{name:"((isOpen: boolean) => void)"}}}}}catch{}export{p as P};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{j as r}from"./jsx-runtime-FsUICBgo.js";import{r as k}from"./index-RfLt4OUa.js";import{S as w}from"./spacer-Yji9g2AW.js";import{P as n}from"./popover-N9B8JT3G.js";import{I as c}from"./input-fYKvBwPs.js";import{B as i}from"./button-BiJw0fB3.js";import{F as D}from"./flex-RYZsoWEN.js";import{S as y}from"./select-AcJYUY86.js";import"./tooltip-dueTLnwA.js";import"./index-miLrID2P.js";import"./index-VW3EWkuE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./types-5uVBABF4.js";import"./lodash-Bmg8FrMx.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./types-VB5zD18b.js";import"./text-6KQ6ntOV.js";import"./actions-7PO9r8zE.js";import"./badge-23Ty_zBt.js";import"./select.input-zP5tW20f.js";const u=[{label:"Option 1",value:"1"},{label:"Option 2",value:"2"}],F=({close:e})=>r.jsxs(D,{gap:"var(--padding-xs)",children:[r.jsx(c,{value:"Value",width:"150px",small:!0}),r.jsx(y,{options:u,value:u[0],width:"auto",small:!0}),r.jsx(i,{colored:!0,label:"Save",onClick:()=>{},small:!0}),r.jsx(i,{label:"Cancel",onClick:e,small:!0})]}),lr={title:"Basic/Popover",component:n,args:{overflowContainer:!0,content:r.jsx(F,{}),children:r.jsx(i,{label:"Toggle me"})},decorators:[e=>r.jsx("div",{style:{display:"flex"},children:e()})],parameters:{docs:{source:{excludeDecorators:!0}}}},l=e=>r.jsx(n,{...e}),a=l.bind({}),o=l.bind({});o.args={children:r.jsx(c,{value:"Value",width:"100%"})};const s=l.bind({});s.args={closeOnOutsideClick:!1,showCloseButton:!0};const t=l.bind({});t.args={disabled:!0};const p=e=>{const[m,T]=k.useState(!1);return r.jsxs("div",{children:[r.jsx(i,{onClick:()=>T(!m),label:"Toggle Popover Externally"}),r.jsx(w,{}),r.jsx(n,{...e,isOpen:m,children:r.jsx(c,{})})]})};var d,g,x;a.parameters={...a.parameters,docs:{...(d=a.parameters)==null?void 0:d.docs,source:{originalSource:"args => <Popover {...args} />",...(x=(g=a.parameters)==null?void 0:g.docs)==null?void 0:x.source}}};var v,j,f;o.parameters={...o.parameters,docs:{...(v=o.parameters)==null?void 0:v.docs,source:{originalSource:"args => <Popover {...args} />",...(f=(j=o.parameters)==null?void 0:j.docs)==null?void 0:f.source}}};var b,S,O;s.parameters={...s.parameters,docs:{...(b=s.parameters)==null?void 0:b.docs,source:{originalSource:"args => <Popover {...args} />",...(O=(S=s.parameters)==null?void 0:S.docs)==null?void 0:O.source}}};var C,P,h;t.parameters={...t.parameters,docs:{...(C=t.parameters)==null?void 0:C.docs,source:{originalSource:"args => <Popover {...args} />",...(h=(P=t.parameters)==null?void 0:P.docs)==null?void 0:h.source}}};var I,B,E;p.parameters={...p.parameters,docs:{...(I=p.parameters)==null?void 0:I.docs,source:{originalSource:`args => {
|
|
2
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
3
|
+
return <div>
|
|
4
|
+
<Button onClick={() => setIsOpen(!isOpen)} label="Toggle Popover Externally" />
|
|
5
|
+
<Spacer />
|
|
6
|
+
<Popover {...args} isOpen={isOpen}>
|
|
7
|
+
<Input />
|
|
8
|
+
</Popover>
|
|
9
|
+
</div>;
|
|
10
|
+
}`,...(E=(B=p.parameters)==null?void 0:B.docs)==null?void 0:E.source}}};const nr=["Default","InputTrigger","CloseButton","Disabled","ExternalControl"];export{s as CloseButton,a as Default,t as Disabled,p as ExternalControl,o as InputTrigger,nr as __namedExportsOrder,lr as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as at}from"./jsx-runtime-FsUICBgo.js";import{g as Le,c as ct,a as Li,r as he,R as fe}from"./index-RfLt4OUa.js";import{T as Di}from"./toaster-yPcd4ELJ.js";import{q as ga,r as ma,s as qr,i as ki,t as ya,e as Hr,v as Mi,w as Bi,c as zr,x as Ui,y as Gi,z as qi,A as Hi,B as va,C as zi,D as Wi,E as Yi,F as Xi,G as Ki,H as Vi,I as Qi,J as Ji}from"./index-R5dkQuFe.js";import{f as Zi,k as ba,h as eo,i as to,j as ro,l as no,o as ao,m as De,p as io,q as oo,r as so,t as cn}from"./index-
|
|
1
|
+
import{j as at}from"./jsx-runtime-FsUICBgo.js";import{g as Le,c as ct,a as Li,r as he,R as fe}from"./index-RfLt4OUa.js";import{T as Di}from"./toaster-yPcd4ELJ.js";import{q as ga,r as ma,s as qr,i as ki,t as ya,e as Hr,v as Mi,w as Bi,c as zr,x as Ui,y as Gi,z as qi,A as Hi,B as va,C as zi,D as Wi,E as Yi,F as Xi,G as Ki,H as Vi,I as Qi,J as Ji}from"./index-R5dkQuFe.js";import{f as Zi,k as ba,h as eo,i as to,j as ro,l as no,o as ao,m as De,p as io,q as oo,r as so,t as cn}from"./index-K-0S6d15.js";import{a as lo}from"./isPlainObject-OQlD0fAV.js";import{d as Sa}from"./index-PPLHz8o0.js";import{e as pn}from"./index-cCpkwrS5.js";import"./chunk-HLWAVYOI-tHzaOxem.js";import"./index-miLrID2P.js";import"./message-CRKuTfOl.js";import"./index-VW3EWkuE.js";import"./common-types-U65vzrrz.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./disabled-context-urNQThQz.js";import"./iframe-CpYMK6kb.js";import"../sb-preview/runtime.js";import"./assertThisInitialized-4q6YPdh3.js";import"./react-16-hgR7FrAp.js";var hn="DARK_MODE";const{global:uo}=__STORYBOOK_MODULE_GLOBAL__;__STORYBOOK_MODULE_CLIENT_LOGGER__;function Te(){return Te=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Te.apply(this,arguments)}function fo(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Qe(t,e){return Qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Qe(t,e)}function co(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Qe(t,e)}function yr(t){return yr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},yr(t)}function po(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pt(t,e,r){return ho()?pt=Reflect.construct.bind():pt=function(n,s,o){var l=[null];l.push.apply(l,s);var a=Function.bind.apply(n,l),i=new a;return o&&Qe(i,o.prototype),i},pt.apply(null,arguments)}function vr(t){var e=typeof Map=="function"?new Map:void 0;return vr=function(r){if(r===null||!po(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,n)}function n(){return pt(r,arguments,yr(this).constructor)}return n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Qe(n,r)},vr(t)}var go={1:`Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).
|
|
2
2
|
|
|
3
3
|
`,2:`Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).
|
|
4
4
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{_ as e}from"./iframe-
|
|
1
|
+
import{_ as e}from"./iframe-CpYMK6kb.js";import"../sb-preview/runtime.js";var a={docs:{renderer:async()=>{let{DocsRenderer:r}=await e(()=>import("./DocsRenderer-NNNQARDV-NmCW-oyQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url);return new r}}};export{a as parameters};
|
|
2
2
|
function __vite__mapDeps(indexes) {
|
|
3
3
|
if (!__vite__mapDeps.viteFileDeps) {
|
|
4
|
-
__vite__mapDeps.viteFileDeps = ["./DocsRenderer-NNNQARDV-
|
|
4
|
+
__vite__mapDeps.viteFileDeps = ["./DocsRenderer-NNNQARDV-NmCW-oyQ.js","./chunk-HLWAVYOI-tHzaOxem.js","./iframe-CpYMK6kb.js","./index-RfLt4OUa.js","./react-16-hgR7FrAp.js","./index-miLrID2P.js","./index-K-0S6d15.js","./inheritsLoose-8sb_A2v4.js","./assertThisInitialized-4q6YPdh3.js","./index-R5dkQuFe.js","./index-PPLHz8o0.js"]
|
|
5
5
|
}
|
|
6
6
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o}from"./jsx-runtime-FsUICBgo.js";import{r as D}from"./index-RfLt4OUa.js";import{T as u}from"./table-
|
|
1
|
+
import{j as o}from"./jsx-runtime-FsUICBgo.js";import{r as D}from"./index-RfLt4OUa.js";import{T as u}from"./table-kSTipYE0.js";import{T as z}from"./text-6KQ6ntOV.js";import{t as R,s as G,u as J,v as K,w as Q}from"./table.stories-data-tjY9V0bM.js";import"./index-VW3EWkuE.js";import"./index.es-VXFRDikp.js";import"./inheritsLoose-8sb_A2v4.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./index-miLrID2P.js";import"./memoize-one.esm-hqe5SRxC.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./lodash-Bmg8FrMx.js";import"./actions-7PO9r8zE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./button-BiJw0fB3.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./tooltip-dueTLnwA.js";import"./types-VB5zD18b.js";import"./types-5uVBABF4.js";import"./badge-23Ty_zBt.js";import"./heading-4tVgoT7O.js";import"./help-icon-eelulTML.js";import"./pagination-DtJdggbI.js";import"./select-AcJYUY86.js";import"./assertThisInitialized-4q6YPdh3.js";import"./select.input-zP5tW20f.js";import"./input-fYKvBwPs.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-ymd7m-s5.js";import"./index-qZmQ7nA9.js";import"./index-cCpkwrS5.js";import"./check-box-KynSyTaY.js";import"./slider-n3IxC2iq.js";import"./index-ugi_ZH6T.js";import"./popover-N9B8JT3G.js";import"./flex-RYZsoWEN.js";const _e={title:"Basic/Table/Row",component:u,args:{table:{...R}}},m=n=>o.jsx(u,{...n}),i=m.bind({});i.args={table:G};const p=m.bind({});p.args={table:J};const c=m.bind({});c.args={table:K};const d=m.bind({});d.args={table:Q};const t=m.bind({});t.args={table:{...R,striped:!1}};t.parameters={docs:{description:{story:"`striped: false` removes tinted background on alternative rows."}}};const v=()=>{const[n,e]=D.useState(null),a=r=>e(n===r?null:r);return o.jsx(u,{table:{...R,striped:!1,rows:R.rows.map((r,w)=>({...r,onRowClick:()=>a(w),expandedContent:{content:n===w?o.jsx("div",{children:"Example expanded content"}):null}}))}})},x=()=>{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,g,l)=>{const y=[...s];return s[l].noDrag?s:(y.splice(l,0,y.splice(g,1)[0]),y)},[a,r]=D.useState(n.rows),w=s=>{const{to:g,from:l}=s;e(a,l,g),r(e(a,l,g))};return o.jsx(u,{table:{...n,rows:a},onListReorder:w})},b=()=>{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(u,{table:{fixedWidth:"100%",headers:[{cells:[{value:"Description"},{value:"Value"}],onRowMouseEnter:()=>e("Hovering header row"),onRowMouseLeave:()=>e("Not hovering any row...")}],rows:a}})]})};var E,T,h;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} />;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as l,c as n,s as d}from"./index-
|
|
1
|
+
import{S as l,c as n,s as d}from"./index-K-0S6d15.js";import"./iframe-CpYMK6kb.js";import"../sb-preview/runtime.js";import"./index-RfLt4OUa.js";import"./index-miLrID2P.js";import"./inheritsLoose-8sb_A2v4.js";import"./assertThisInitialized-4q6YPdh3.js";import"./index-R5dkQuFe.js";import"./index-PPLHz8o0.js";export{l as SyntaxHighlighter,n as createCopyToClipboardFunction,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as q}from"./index-RfLt4OUa.js";import{c as w}from"./index-VW3EWkuE.js";import{I as He,D as Pe,C as Le,P as De}from"./index.es-VXFRDikp.js";import{l as Fe}from"./lodash-Bmg8FrMx.js";import{A as he}from"./actions-7PO9r8zE.js";import{H as $e}from"./heading-4tVgoT7O.js";import{P as Be}from"./pagination-DtJdggbI.js";import{A as x,I as B}from"./common-types-U65vzrrz.js";import{I as Oe}from"./input-fYKvBwPs.js";import{N as Me}from"./number-input-ymd7m-s5.js";import{S as Ue}from"./select-AcJYUY86.js";import{D as Ge}from"./disabled-context-urNQThQz.js";import{i as O}from"./types-5uVBABF4.js";import{T as be}from"./tooltip-dueTLnwA.js";import{C as Xe}from"./check-box-KynSyTaY.js";import{S as ze}from"./slider-n3IxC2iq.js";import{I as M}from"./icon-8EQazuuW.js";import{P as Je}from"./popover-Ioxe80BK.js";import{H as Ee}from"./help-icon-eelulTML.js";import{T as re}from"./text-6KQ6ntOV.js";const Ke="_inputInTable_y9car_1",Ye="_inputHover_y9car_13",Qe="_inputFocus_y9car_18",Ze="_inputError_y9car_25",en="_inputWarning_y9car_26",nn="_inputDisabled_y9car_61",tn="_hideScrollbars_y9car_67",rn="_wrapper_y9car_85",an="_bordered_y9car_93",ln="_scroll_y9car_98",on="_table_y9car_108",sn="_striped_y9car_188",W={inputInTable:Ke,inputHover:Ye,inputFocus:Qe,inputError:Ze,inputWarning:en,inputDisabled:nn,hideScrollbars:tn,wrapper:rn,bordered:an,scroll:ln,table:on,striped:sn},dn="_title_zn5s7_1",cn={title:dn},z=({name:e=null,actions:t=null,actionsRight:r=!1,testId:l})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const u=n.jsx(he,{actions:t});return r?u:n.jsx("div",{children:u})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx($e,{children:n.jsx("span",{"data-testid":l,children:e})}):null,s()]})};try{z.displayName="Title",z.__docgenInfo={description:"",displayName:"Title",props:{name:{defaultValue:{value:"null"},description:"",name:"name",required:!1,type:{name:"string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null"}},actions:{defaultValue:{value:"null"},description:"",name:"actions",required:!1,type:{name:"any"}},actionsRight:{defaultValue:{value:"false"},description:"",name:"actionsRight",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const un="_footer_4sumy_1",pn="_section_4sumy_7",ae={footer:un,section:pn},J=({colSpan:e,pagination:t,actions:r,content:l})=>{const a=r&&r.length,o=l!=null,s=()=>{var d,p;if(t){const{rowCount:c,rowsPerPage:y}=t,g=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return c>g}return!1};return a||o||s()?n.jsxs("div",{className:ae.footer,children:[o?n.jsx("div",{className:ae.section,children:n.jsx("div",{children:l})}):null,a||s()?n.jsxs("div",{className:ae.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(he,{actions:r})})]}):null]}):null};try{J.displayName="Footer",J.__docgenInfo={description:"",displayName:"Footer",props:{colSpan:{defaultValue:null,description:"",name:"colSpan",required:!1,type:{name:"number"}},pagination:{defaultValue:null,description:"",name:"pagination",required:!0,type:{name:"IPagination"}},actions:{defaultValue:null,description:"",name:"actions",required:!1,type:{name:"IAction[]"}},content:{defaultValue:null,description:"",name:"content",required:!1,type:{name:"ReactNode"}}}}}catch{}const Ve=e=>{const t=Math.max(...e.reduce((r,l)=>{const a=l.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},mn=(e,t)=>{const r=[Ve(t),Ve(e)];return Math.max(...r)},Te=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),_n=(e,t)=>Te(t)>0||Te(e)>0,K=({table:e,children:t})=>{const{rows:r,infiniteScroll:l}=e,a=Math.ceil(window.innerHeight/30),[o,s]=l?q.useState(a):[r.length,null],[u,d]=l?q.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:W.scroll,children:l?n.jsx(He,{dataLength:Math.min(r.length,o+a),next:p,hasMore:u,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};try{K.displayName="TableScrollWrapper",K.__docgenInfo={description:"",displayName:"TableScrollWrapper",props:{table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"ITableProps"}}}}}catch{}const gn="_clickableRow_1ki29_1",yn="_hoverableRow_1ki29_4",fn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",bn="_flush_1ki29_8",xn="_errorRow_1ki29_12",Cn="_warningRow_1ki29_15",In="_dragIconCell_1ki29_34",jn="_dragIcon_1ki29_34",b={clickableRow:gn,hoverableRow:yn,rowActive:fn,expandableRow:hn,flush:bn,errorRow:xn,warningRow:Cn,dragIconCell:In,dragIcon:jn},Y=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:w(b.expandableRow,r?b.flush:""),children:t})});try{Y.displayName="ExpandedContentRow",Y.__docgenInfo={description:"",displayName:"ExpandedContentRow",props:{colSpan:{defaultValue:null,description:"",name:"colSpan",required:!0,type:{name:"number"}},flush:{defaultValue:null,description:"",name:"flush",required:!1,type:{name:"boolean"}}}}}catch{}const qe=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:l,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:l){case x.LEFT:return r?x.LEFT:t.leftAligned;case x.RIGHT:return r?x.RIGHT:t.rightAligned;case x.CENTER:return r?x.CENTER:t.centerAligned;default:return r?x.LEFT:t.leftAligned}},Nn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const l=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return l&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_u3xdj_1",Rn="_inputHover_u3xdj_13",An="_inputFocus_u3xdj_18",vn="_inputError_u3xdj_25",Sn="_inputWarning_u3xdj_26",Vn="_inputDisabled_u3xdj_61",Tn="_hideScrollbars_u3xdj_67",qn="_cell_u3xdj_77",kn="_disabledLink_u3xdj_87",En="_inputWrapper_u3xdj_91",Wn="_breakWord_u3xdj_106",Hn="_inputCell_u3xdj_109",Pn="_sliderCell_u3xdj_112",Ln="_staticCell_u3xdj_116",Dn="_staticCellContent_u3xdj_119",Fn="_error_u3xdj_131",$n="_warning_u3xdj_132",Bn="_unit_u3xdj_141",On="_sortingCell_u3xdj_144",Mn="_sortingCellIcon_u3xdj_155",Un="_icon_u3xdj_166",Gn="_checkBoxCell_u3xdj_170",Xn="_iconCellWrapper_u3xdj_174",zn="_actionsCell_u3xdj_178",Jn="_rightAligned_u3xdj_186",Kn="_centerAligned_u3xdj_192",Yn="_leftAligned_u3xdj_198",Qn="_popover_u3xdj_201",Zn="_disabledPointerEvents_u3xdj_204",i={inputInTable:wn,inputHover:Rn,inputFocus:An,inputError:vn,inputWarning:Sn,inputDisabled:Vn,hideScrollbars:Tn,cell:qn,disabledLink:kn,inputWrapper:En,breakWord:Wn,inputCell:Hn,sliderCell:Pn,staticCell:Ln,staticCellContent:Dn,error:Fn,warning:$n,unit:Bn,sortingCell:On,sortingCellIcon:Mn,icon:Un,checkBoxCell:Gn,iconCellWrapper:Xn,actionsCell:zn,rightAligned:Jn,centerAligned:Kn,leftAligned:Yn,popover:Qn,disabledPointerEvents:Zn},Q=({cell:e,columnAlignment:t,testId:r,type:l})=>n.jsx(Oe,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===x.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:l});try{Q.displayName="InputCell",Q.__docgenInfo={description:"",displayName:"InputCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IInputCell"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!1,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}},type:{defaultValue:null,description:"",name:"type",required:!1,type:{name:"enum",value:[{value:'"text"'},{value:'"date"'}]}}}}}catch{}const le=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var l;return(l=e.onChange)==null?void 0:l.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});try{le.displayName="NumberInputCell",le.__docgenInfo={description:"",displayName:"NumberInputCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"INumberInputCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const oe=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ue,{name:e.name,borderRadius:0,options:e.options,onChange:l=>{var a;return(a=e.onChange)==null?void 0:a.call(e,l)},onCreate:e.onCreate?l=>e.onCreate&&e.onCreate(l):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===x.RIGHT,testId:r,tabIndex:e.disabled?-1:0});try{oe.displayName="SelectCell",oe.__docgenInfo={description:"",displayName:"SelectCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISelectCell"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!1,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ie=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:i.inputWrapper,children:e.type==="Input"?n.jsx(Q,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(le,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(Q,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(oe,{cell:e,columnAlignment:t,testId:r}):null});try{ie.displayName="InputCellWrapper",ie.__docgenInfo={description:"",displayName:"InputCellWrapper",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"any"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!0,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const se=({cell:e,testId:t})=>{const r=q.useContext(Ge),{error:l,warning:a,tooltip:o,maxTooltipWidth:s}=e,u=d=>O(d);return n.jsx("div",{className:i.inputWrapper,children:n.jsx(be,{error:!!l,warning:!!a,text:o||l||a,enabled:u(o)||u(l)||u(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:w(i.staticCellContent,l?i.error:a?i.warning:""),children:n.jsx("a",{className:w((e.disabled||r)&&i.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})})})})};try{se.displayName="LinkCell",se.__docgenInfo={description:"",displayName:"LinkCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ILinkCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const de=({cell:e,testId:t})=>n.jsx(Xe,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});try{de.displayName="CheckBoxCell",de.__docgenInfo={description:"",displayName:"CheckBoxCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ICheckBoxCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ce=({cell:e})=>n.jsx("div",{className:i.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})});try{ce.displayName="SliderCell",ce.__docgenInfo={description:"",displayName:"SliderCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISliderCell"}}}}}catch{}const ue=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:i.iconCellWrapper,children:n.jsx(be,{text:t,enabled:!!t&&O(t),display:"flex",placement:"top-center",children:n.jsx(M,{icon:r})})})};try{ue.displayName="IconCell",ue.__docgenInfo={description:"",displayName:"IconCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IIconCell"}}}}}catch{}const pe=({cell:e})=>n.jsx(he,{actions:e.actions});try{pe.displayName="ActionsCell",pe.__docgenInfo={description:"",displayName:"ActionsCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IActionCell"}}}}}catch{}const me=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:i.icon,children:n.jsx(Ee,{onClick:t.onClick,text:t.tooltip})}):null};try{me.displayName="CellHelpIcon",me.__docgenInfo={description:"",displayName:"CellHelpIcon",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IHelpIconCell"}}}}}catch{}const _e=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:i.icon,children:n.jsx(Ee,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};try{_e.displayName="CellLibraryIcon",_e.__docgenInfo={description:"",displayName:"CellLibraryIcon",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ILibraryIconCell"}}}}}catch{}const ge=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:l}=e;return t?n.jsxs("span",{className:i.sortingCellIcon,children:[r==="down"?n.jsx(re,{link:!0,children:n.jsx(M,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(re,{link:!0,children:n.jsx(M,{icon:B.SORT_DESCENDING})}):n.jsx(re,{faint:!0,children:n.jsx(M,{icon:B.SORT_DESCENDING})}),l&&r?n.jsx("sup",{children:l}):null]}):null};try{ge.displayName="Sort",ge.__docgenInfo={description:"",displayName:"Sort",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISortCell"}}}}}catch{}const Z=({cell:e,isHeader:t,testId:r})=>{const{error:l,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:u,onSort:d,type:p}=e,c=n.jsxs("div",{className:w(i.staticCellContent,p==="Unit"?i.unit:"",l?i.error:a?i.warning:""),onClick:u?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(me,{cell:e}),n.jsx(_e,{cell:e}),n.jsx(ge,{cell:e})]}):null]});return n.jsx("div",{className:i.inputWrapper,children:n.jsx(be,{error:!!l,warning:!!a,text:o||l||a,enabled:o&&O(o)||l&&O(l)||a&&O(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:c})})};try{Z.displayName="StaticCell",Z.__docgenInfo={description:"",displayName:"StaticCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IStaticCell"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ye=({cell:e,testId:t})=>{const{content:r,fullWidth:l,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Je,{content:r,fullWidth:l,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:i.popover,children:n.jsx(Z,{cell:e,testId:t})})})};try{ye.displayName="PopoverCell",ye.__docgenInfo={description:"",displayName:"PopoverCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IPopoverCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const fe=({cell:e,isHeader:t,columnAlignment:r,testId:l})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ie,{cell:e,columnAlignment:r,testId:l});case"Link":return n.jsx(se,{cell:e,testId:l});case"CheckBox":return n.jsx(de,{cell:e,testId:l});case"Slider":return n.jsx(ce,{cell:e});case"Icon":return n.jsx(ue,{cell:e});case"Actions":return n.jsx(pe,{cell:e});case"Popover":return n.jsx(ye,{cell:e});default:return n.jsx(Z,{cell:e,isHeader:t,testId:l})}};try{fe.displayName="CellWrapper",fe.__docgenInfo={description:"",displayName:"CellWrapper",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"any"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!0,type:{name:"boolean"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!0,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}var v=(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))(v||{});const ee=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:l=x.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:u,colSpan:d,rowSpan:p,width:c}=e,y=q.useRef(null),g={bodyAlignment:l,headerAlignment:r,isHeader:t},H=qe(g,i),C=qe(g,i,!0),P=e.type===v.INPUT||e.type===v.NUMBER_INPUT||e.type===v.SELECT||e.type===v.POPOVER?i.inputCell:e.type===v.SLIDER?i.sliderCell:e.type===v.CHECKBOX?i.checkBoxCell:e.type===v.ACTIONS?i.actionsCell:i.staticCell,R=w(i.cell,P,e.hasSort?i.sortingCell:null,H,e.breakWord?i.breakWord:""),k=c??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,I={width:k,minWidth:k,...u},A=t?"th":"td";return n.jsx(A,{ref:y,className:R,style:I,colSpan:d,rowSpan:p,children:n.jsx(fe,{cell:e,columnAlignment:C??x.RIGHT,isHeader:t,testId:s})})};try{ee.displayName="Cell",ee.__docgenInfo={description:"",displayName:"Cell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!1,type:{name:"TCellShape"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!0,type:{name:"boolean"}},columnHeaderAlignment:{defaultValue:null,description:"",name:"columnHeaderAlignment",required:!1,type:{name:"string"}},columnAlignment:{defaultValue:{value:"Align.LEFT"},description:"",name:"columnAlignment",required:!1,type:{name:"Align.LEFT | Align.RIGHT | null"}},width:{defaultValue:null,description:"",name:"width",required:!1,type:{name:"TStringOrNumber"}},snapshot:{defaultValue:null,description:"",name:"snapshot",required:!1,type:{name:"any"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const F=({row:e,rowIndex:t,isHeader:r=!1,columnCount:l,colSpan:a,columnHeaderAlignments:o=[],columnAlignment:s=[],hasRowActions:u,draggableTable:d=!1,snapshot:p=null,provided:c=null,width:y,columnWidths:g,testId:H})=>{const C=q.useRef(null),P=Nn(o,r,t),{onRowClick:R,onRowFocus:k,onRowMouseEnter:I,onRowMouseLeave:A,expandedContent:j,error:ne,warning:L,active:E}=e,S=e.cells.map((h,T)=>{const $=`${r?0:1}_${t}_${T}`;return n.jsx(ee,{cell:h,isHeader:r,columnAlignment:s[T],columnHeaderAlignment:P[T],width:g?g[T]:void 0,snapshot:p,testId:h.testId},$)}),V=u&&n.jsx(ee,{cell:{type:v.ACTIONS,actions:e.actions},isHeader:r},l),te=(h,T)=>({minWidth:h&&`${y}px`,width:h&&"100%",display:h&&"table",background:h&&"var(--color-background-listitem-active)",border:h&&"var(--color-border)",borderTop:h&&0,opacity:h&&.1,...T}),U=()=>e.noDrag?n.jsx("td",{"aria-labelledby":"unique-label-id"}):n.jsx("td",{className:b.dragIconCell,children:n.jsx("div",{...c.dragHandleProps,className:b.dragIcon,children:n.jsx(M,{icon:B.DRAG})})});return r?n.jsxs(n.Fragment,{children:[n.jsxs("tr",{ref:C,onClick:R,onMouseEnter:I,onMouseLeave:A,onFocus:k,className:w(R?b.clickableRow:null,I?b.hoverableRow:null),children:[d?n.jsx("th",{}):null,S,V]},t),j&&j.content?n.jsx(Y,{colSpan:a,flush:j.flush===!0,children:j.content},`${t}_expanded_content`):null]}):n.jsxs(n.Fragment,{children:[n.jsxs("tr",{onClick:R,onMouseEnter:I,onMouseLeave:A,onFocus:k,className:w(R&&!R.noStyle?b.clickableRow:null,I&&!I.noStyle?b.hoverableRow:null,E?b.rowActive:null,ne?b.errorRow:null,L?b.warningRow:null),ref:(c==null?void 0:c.innerRef)||null,...(c==null?void 0:c.draggableProps)||null,style:p&&c?te(p.isDragging,c.draggableProps.style):null,children:[d?U():null,S,V]},t),j&&j.content?n.jsx(Y,{colSpan:a,flush:j.flush===!0,children:j.content},`${t}_expanded_content`):null]})};try{F.displayName="Row",F.__docgenInfo={description:"",displayName:"Row",props:{row:{defaultValue:null,description:"",name:"row",required:!0,type:{name:"TRowType"}},rowIndex:{defaultValue:null,description:"",name:"rowIndex",required:!0,type:{name:"number"}},isHeader:{defaultValue:{value:"false"},description:"",name:"isHeader",required:!1,type:{name:"boolean"}},columnCount:{defaultValue:null,description:"",name:"columnCount",required:!0,type:{name:"number"}},colSpan:{defaultValue:null,description:"",name:"colSpan",required:!0,type:{name:"number"}},columnHeaderAlignments:{defaultValue:{value:"[]"},description:"",name:"columnHeaderAlignments",required:!1,type:{name:"string[] | string[][]"}},columnAlignment:{defaultValue:{value:"[]"},description:"",name:"columnAlignment",required:!1,type:{name:"string[]"}},hasRowActions:{defaultValue:null,description:"",name:"hasRowActions",required:!0,type:{name:"boolean"}},draggableTable:{defaultValue:{value:"false"},description:"",name:"draggableTable",required:!1,type:{name:"boolean"}},snapshot:{defaultValue:{value:"null"},description:"",name:"snapshot",required:!1,type:{name:"any"}},provided:{defaultValue:{value:"null"},description:"",name:"provided",required:!1,type:{name:"any"}},width:{defaultValue:null,description:"",name:"width",required:!1,type:{name:"TStringOrNumber"}},columnWidths:{defaultValue:null,description:"",name:"columnWidths",required:!1,type:{name:"string[]"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ke=e=>{var je,Ne,we,Re,Ae,ve,Se;const{onListReorder:t=()=>{},table:r}=e,{columnWidths:l,footer:a,name:o,rows:s=[],actions:u,actionsRight:d,columnHeaderAlignments:p,columnAlignment:c,striped:y=!0,testId:g,draggable:H,defaultEmptyRow:C=null,onAddRow:P=null,bordered:R=!0,maxHeight:k,fixedWidth:I}=r,A=q.useRef(null),[j,ne]=q.useState({width:0,height:0});q.useEffect(()=>{A.current&&ne({width:A.current.offsetWidth,height:A.current.offsetHeight})},[]);const L=Fe.get(e,"table.headers",[]),E=mn(s,L),S=_n(s,L),V=E+(S?1:0),te=a?((Ne=(je=a==null?void 0:a.pagination)==null?void 0:je.rowsPerPage)==null?void 0:Ne.value)===0||Number((we=a==null?void 0:a.pagination)==null?void 0:we.selectedPage)>=Number((Re=a==null?void 0:a.pagination)==null?void 0:Re.rowCount)/Number((ve=(Ae=a==null?void 0:a.pagination)==null?void 0:Ae.rowsPerPage)==null?void 0:ve.value):!0,U=((Se=C==null?void 0:C.cells)==null?void 0:Se.length)&&P&&te,T={cells:U?C.cells.map((m,N)=>(m==null?void 0:m.type)==="Input"?{...m,onChange:_=>{var G;const f=(G=_==null?void 0:_.target)==null?void 0:G.value,D={...C,cells:C.cells.map((X,We)=>({...X,value:We===N?f:X==null?void 0:X.value}))};P({newRow:D})}}:{...m,disabled:!0}):null,testId:g?`${g}-last-empty-row`:void 0},$=U?s.concat(T):s,xe={...r,rows:$},Ce=w(W.wrapper,R?W.bordered:""),Ie={maxHeight:k,width:I,display:I==="auto"?"inline-flex":"flex"};return H?n.jsxs("div",{ref:A,className:Ce,style:Ie,children:[n.jsx(z,{actions:u,actionsRight:d,name:o,testId:g&&`${g}-title`}),n.jsx(Pe,{onDragEnd:m=>{var f,D;const N=(f=m==null?void 0:m.source)==null?void 0:f.index,_=(D=m==null?void 0:m.destination)==null?void 0:D.index;typeof N=="number"&&typeof _=="number"&&t({from:N,to:_})},children:n.jsx(Le,{droppableId:"droppable",children:m=>n.jsx(K,{table:xe,children:({visibleRows:N})=>n.jsxs("table",{className:w(W.table,y?W.striped:""),"data-testid":g,ref:m.innerRef,children:[n.jsx("thead",{children:L.map((_,f)=>n.jsx(F,{rowIndex:f,isHeader:!0,row:_,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,columnHeaderAlignments:p,draggableTable:H},`0_${f}`))}),n.jsxs("tbody",{children:[$.slice(0,N).map((_,f)=>n.jsx(De,{draggableId:f+"",index:f,isDragDisabled:_.noDrag,children:(D,G)=>n.jsx(F,{rowIndex:f,row:_,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,provided:D,snapshot:G,draggableTable:H,width:j.width},`1_${f}`)},`index_${f}`)),m.placeholder]})]})})})}),a&&n.jsx(J,{pagination:a.pagination,actions:a.actions,content:a.content})]}):n.jsxs("div",{className:Ce,style:Ie,children:[n.jsx(z,{actions:u,actionsRight:d,name:o,testId:g&&`${g}-title`}),n.jsx(K,{table:xe,children:({visibleRows:m})=>n.jsxs("table",{className:w(W.table,y?W.striped:""),"data-testid":g,children:[n.jsx("thead",{children:L.map((N,_)=>n.jsx(F,{rowIndex:_,isHeader:!0,row:N,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,columnHeaderAlignments:p},`0_${_}`))}),n.jsx("tbody",{children:$.slice(0,m).map((N,_)=>n.jsx(F,{rowIndex:_,row:N,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c},`1_${_}`))})]})}),a&&n.jsx(J,{colSpan:V,pagination:a.pagination,actions:a.actions,content:a.content})]})};try{ke.displayName="Table",ke.__docgenInfo={description:"",displayName:"Table",props:{onListReorder:{defaultValue:null,description:"",name:"onListReorder",required:!1,type:{name:"((obj: { from: number; to: number; }) => void)"}},table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"{ name?: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; ... 18 more ...; actions?: any; }"}}}}}catch{}export{v as C,ke as T};
|
|
1
|
+
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as q}from"./index-RfLt4OUa.js";import{c as w}from"./index-VW3EWkuE.js";import{I as He,D as Pe,C as Le,P as De}from"./index.es-VXFRDikp.js";import{l as Fe}from"./lodash-Bmg8FrMx.js";import{A as he}from"./actions-7PO9r8zE.js";import{H as $e}from"./heading-4tVgoT7O.js";import{P as Be}from"./pagination-DtJdggbI.js";import{A as x,I as B}from"./common-types-U65vzrrz.js";import{I as Oe}from"./input-fYKvBwPs.js";import{N as Me}from"./number-input-ymd7m-s5.js";import{S as Ue}from"./select-AcJYUY86.js";import{D as Ge}from"./disabled-context-urNQThQz.js";import{i as O}from"./types-5uVBABF4.js";import{T as be}from"./tooltip-dueTLnwA.js";import{C as Xe}from"./check-box-KynSyTaY.js";import{S as ze}from"./slider-n3IxC2iq.js";import{I as M}from"./icon-8EQazuuW.js";import{P as Je}from"./popover-N9B8JT3G.js";import{H as Ee}from"./help-icon-eelulTML.js";import{T as re}from"./text-6KQ6ntOV.js";const Ke="_inputInTable_y9car_1",Ye="_inputHover_y9car_13",Qe="_inputFocus_y9car_18",Ze="_inputError_y9car_25",en="_inputWarning_y9car_26",nn="_inputDisabled_y9car_61",tn="_hideScrollbars_y9car_67",rn="_wrapper_y9car_85",an="_bordered_y9car_93",ln="_scroll_y9car_98",on="_table_y9car_108",sn="_striped_y9car_188",W={inputInTable:Ke,inputHover:Ye,inputFocus:Qe,inputError:Ze,inputWarning:en,inputDisabled:nn,hideScrollbars:tn,wrapper:rn,bordered:an,scroll:ln,table:on,striped:sn},dn="_title_zn5s7_1",cn={title:dn},z=({name:e=null,actions:t=null,actionsRight:r=!1,testId:l})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const u=n.jsx(he,{actions:t});return r?u:n.jsx("div",{children:u})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx($e,{children:n.jsx("span",{"data-testid":l,children:e})}):null,s()]})};try{z.displayName="Title",z.__docgenInfo={description:"",displayName:"Title",props:{name:{defaultValue:{value:"null"},description:"",name:"name",required:!1,type:{name:"string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null"}},actions:{defaultValue:{value:"null"},description:"",name:"actions",required:!1,type:{name:"any"}},actionsRight:{defaultValue:{value:"false"},description:"",name:"actionsRight",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const un="_footer_4sumy_1",pn="_section_4sumy_7",ae={footer:un,section:pn},J=({colSpan:e,pagination:t,actions:r,content:l})=>{const a=r&&r.length,o=l!=null,s=()=>{var d,p;if(t){const{rowCount:c,rowsPerPage:y}=t,g=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return c>g}return!1};return a||o||s()?n.jsxs("div",{className:ae.footer,children:[o?n.jsx("div",{className:ae.section,children:n.jsx("div",{children:l})}):null,a||s()?n.jsxs("div",{className:ae.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(he,{actions:r})})]}):null]}):null};try{J.displayName="Footer",J.__docgenInfo={description:"",displayName:"Footer",props:{colSpan:{defaultValue:null,description:"",name:"colSpan",required:!1,type:{name:"number"}},pagination:{defaultValue:null,description:"",name:"pagination",required:!0,type:{name:"IPagination"}},actions:{defaultValue:null,description:"",name:"actions",required:!1,type:{name:"IAction[]"}},content:{defaultValue:null,description:"",name:"content",required:!1,type:{name:"ReactNode"}}}}}catch{}const Ve=e=>{const t=Math.max(...e.reduce((r,l)=>{const a=l.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},mn=(e,t)=>{const r=[Ve(t),Ve(e)];return Math.max(...r)},Te=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),_n=(e,t)=>Te(t)>0||Te(e)>0,K=({table:e,children:t})=>{const{rows:r,infiniteScroll:l}=e,a=Math.ceil(window.innerHeight/30),[o,s]=l?q.useState(a):[r.length,null],[u,d]=l?q.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:W.scroll,children:l?n.jsx(He,{dataLength:Math.min(r.length,o+a),next:p,hasMore:u,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};try{K.displayName="TableScrollWrapper",K.__docgenInfo={description:"",displayName:"TableScrollWrapper",props:{table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"ITableProps"}}}}}catch{}const gn="_clickableRow_1ki29_1",yn="_hoverableRow_1ki29_4",fn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",bn="_flush_1ki29_8",xn="_errorRow_1ki29_12",Cn="_warningRow_1ki29_15",In="_dragIconCell_1ki29_34",jn="_dragIcon_1ki29_34",b={clickableRow:gn,hoverableRow:yn,rowActive:fn,expandableRow:hn,flush:bn,errorRow:xn,warningRow:Cn,dragIconCell:In,dragIcon:jn},Y=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:w(b.expandableRow,r?b.flush:""),children:t})});try{Y.displayName="ExpandedContentRow",Y.__docgenInfo={description:"",displayName:"ExpandedContentRow",props:{colSpan:{defaultValue:null,description:"",name:"colSpan",required:!0,type:{name:"number"}},flush:{defaultValue:null,description:"",name:"flush",required:!1,type:{name:"boolean"}}}}}catch{}const qe=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:l,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:l){case x.LEFT:return r?x.LEFT:t.leftAligned;case x.RIGHT:return r?x.RIGHT:t.rightAligned;case x.CENTER:return r?x.CENTER:t.centerAligned;default:return r?x.LEFT:t.leftAligned}},Nn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const l=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return l&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_u3xdj_1",Rn="_inputHover_u3xdj_13",An="_inputFocus_u3xdj_18",vn="_inputError_u3xdj_25",Sn="_inputWarning_u3xdj_26",Vn="_inputDisabled_u3xdj_61",Tn="_hideScrollbars_u3xdj_67",qn="_cell_u3xdj_77",kn="_disabledLink_u3xdj_87",En="_inputWrapper_u3xdj_91",Wn="_breakWord_u3xdj_106",Hn="_inputCell_u3xdj_109",Pn="_sliderCell_u3xdj_112",Ln="_staticCell_u3xdj_116",Dn="_staticCellContent_u3xdj_119",Fn="_error_u3xdj_131",$n="_warning_u3xdj_132",Bn="_unit_u3xdj_141",On="_sortingCell_u3xdj_144",Mn="_sortingCellIcon_u3xdj_155",Un="_icon_u3xdj_166",Gn="_checkBoxCell_u3xdj_170",Xn="_iconCellWrapper_u3xdj_174",zn="_actionsCell_u3xdj_178",Jn="_rightAligned_u3xdj_186",Kn="_centerAligned_u3xdj_192",Yn="_leftAligned_u3xdj_198",Qn="_popover_u3xdj_201",Zn="_disabledPointerEvents_u3xdj_204",i={inputInTable:wn,inputHover:Rn,inputFocus:An,inputError:vn,inputWarning:Sn,inputDisabled:Vn,hideScrollbars:Tn,cell:qn,disabledLink:kn,inputWrapper:En,breakWord:Wn,inputCell:Hn,sliderCell:Pn,staticCell:Ln,staticCellContent:Dn,error:Fn,warning:$n,unit:Bn,sortingCell:On,sortingCellIcon:Mn,icon:Un,checkBoxCell:Gn,iconCellWrapper:Xn,actionsCell:zn,rightAligned:Jn,centerAligned:Kn,leftAligned:Yn,popover:Qn,disabledPointerEvents:Zn},Q=({cell:e,columnAlignment:t,testId:r,type:l})=>n.jsx(Oe,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===x.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:l});try{Q.displayName="InputCell",Q.__docgenInfo={description:"",displayName:"InputCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IInputCell"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!1,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}},type:{defaultValue:null,description:"",name:"type",required:!1,type:{name:"enum",value:[{value:'"text"'},{value:'"date"'}]}}}}}catch{}const le=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var l;return(l=e.onChange)==null?void 0:l.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});try{le.displayName="NumberInputCell",le.__docgenInfo={description:"",displayName:"NumberInputCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"INumberInputCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const oe=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ue,{name:e.name,borderRadius:0,options:e.options,onChange:l=>{var a;return(a=e.onChange)==null?void 0:a.call(e,l)},onCreate:e.onCreate?l=>e.onCreate&&e.onCreate(l):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===x.RIGHT,testId:r,tabIndex:e.disabled?-1:0});try{oe.displayName="SelectCell",oe.__docgenInfo={description:"",displayName:"SelectCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISelectCell"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!1,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ie=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:i.inputWrapper,children:e.type==="Input"?n.jsx(Q,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(le,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(Q,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(oe,{cell:e,columnAlignment:t,testId:r}):null});try{ie.displayName="InputCellWrapper",ie.__docgenInfo={description:"",displayName:"InputCellWrapper",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"any"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!0,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const se=({cell:e,testId:t})=>{const r=q.useContext(Ge),{error:l,warning:a,tooltip:o,maxTooltipWidth:s}=e,u=d=>O(d);return n.jsx("div",{className:i.inputWrapper,children:n.jsx(be,{error:!!l,warning:!!a,text:o||l||a,enabled:u(o)||u(l)||u(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:w(i.staticCellContent,l?i.error:a?i.warning:""),children:n.jsx("a",{className:w((e.disabled||r)&&i.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})})})})};try{se.displayName="LinkCell",se.__docgenInfo={description:"",displayName:"LinkCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ILinkCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const de=({cell:e,testId:t})=>n.jsx(Xe,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});try{de.displayName="CheckBoxCell",de.__docgenInfo={description:"",displayName:"CheckBoxCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ICheckBoxCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ce=({cell:e})=>n.jsx("div",{className:i.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})});try{ce.displayName="SliderCell",ce.__docgenInfo={description:"",displayName:"SliderCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISliderCell"}}}}}catch{}const ue=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:i.iconCellWrapper,children:n.jsx(be,{text:t,enabled:!!t&&O(t),display:"flex",placement:"top-center",children:n.jsx(M,{icon:r})})})};try{ue.displayName="IconCell",ue.__docgenInfo={description:"",displayName:"IconCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IIconCell"}}}}}catch{}const pe=({cell:e})=>n.jsx(he,{actions:e.actions});try{pe.displayName="ActionsCell",pe.__docgenInfo={description:"",displayName:"ActionsCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IActionCell"}}}}}catch{}const me=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:i.icon,children:n.jsx(Ee,{onClick:t.onClick,text:t.tooltip})}):null};try{me.displayName="CellHelpIcon",me.__docgenInfo={description:"",displayName:"CellHelpIcon",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IHelpIconCell"}}}}}catch{}const _e=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:i.icon,children:n.jsx(Ee,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};try{_e.displayName="CellLibraryIcon",_e.__docgenInfo={description:"",displayName:"CellLibraryIcon",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ILibraryIconCell"}}}}}catch{}const ge=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:l}=e;return t?n.jsxs("span",{className:i.sortingCellIcon,children:[r==="down"?n.jsx(re,{link:!0,children:n.jsx(M,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(re,{link:!0,children:n.jsx(M,{icon:B.SORT_DESCENDING})}):n.jsx(re,{faint:!0,children:n.jsx(M,{icon:B.SORT_DESCENDING})}),l&&r?n.jsx("sup",{children:l}):null]}):null};try{ge.displayName="Sort",ge.__docgenInfo={description:"",displayName:"Sort",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"ISortCell"}}}}}catch{}const Z=({cell:e,isHeader:t,testId:r})=>{const{error:l,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:u,onSort:d,type:p}=e,c=n.jsxs("div",{className:w(i.staticCellContent,p==="Unit"?i.unit:"",l?i.error:a?i.warning:""),onClick:u?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(me,{cell:e}),n.jsx(_e,{cell:e}),n.jsx(ge,{cell:e})]}):null]});return n.jsx("div",{className:i.inputWrapper,children:n.jsx(be,{error:!!l,warning:!!a,text:o||l||a,enabled:o&&O(o)||l&&O(l)||a&&O(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:c})})};try{Z.displayName="StaticCell",Z.__docgenInfo={description:"",displayName:"StaticCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IStaticCell"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ye=({cell:e,testId:t})=>{const{content:r,fullWidth:l,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Je,{content:r,fullWidth:l,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:i.popover,children:n.jsx(Z,{cell:e,testId:t})})})};try{ye.displayName="PopoverCell",ye.__docgenInfo={description:"",displayName:"PopoverCell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"IPopoverCell"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const fe=({cell:e,isHeader:t,columnAlignment:r,testId:l})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ie,{cell:e,columnAlignment:r,testId:l});case"Link":return n.jsx(se,{cell:e,testId:l});case"CheckBox":return n.jsx(de,{cell:e,testId:l});case"Slider":return n.jsx(ce,{cell:e});case"Icon":return n.jsx(ue,{cell:e});case"Actions":return n.jsx(pe,{cell:e});case"Popover":return n.jsx(ye,{cell:e});default:return n.jsx(Z,{cell:e,isHeader:t,testId:l})}};try{fe.displayName="CellWrapper",fe.__docgenInfo={description:"",displayName:"CellWrapper",props:{cell:{defaultValue:null,description:"",name:"cell",required:!0,type:{name:"any"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!0,type:{name:"boolean"}},columnAlignment:{defaultValue:null,description:"",name:"columnAlignment",required:!0,type:{name:"string"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}var v=(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))(v||{});const ee=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:l=x.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:u,colSpan:d,rowSpan:p,width:c}=e,y=q.useRef(null),g={bodyAlignment:l,headerAlignment:r,isHeader:t},H=qe(g,i),C=qe(g,i,!0),P=e.type===v.INPUT||e.type===v.NUMBER_INPUT||e.type===v.SELECT||e.type===v.POPOVER?i.inputCell:e.type===v.SLIDER?i.sliderCell:e.type===v.CHECKBOX?i.checkBoxCell:e.type===v.ACTIONS?i.actionsCell:i.staticCell,R=w(i.cell,P,e.hasSort?i.sortingCell:null,H,e.breakWord?i.breakWord:""),k=c??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,I={width:k,minWidth:k,...u},A=t?"th":"td";return n.jsx(A,{ref:y,className:R,style:I,colSpan:d,rowSpan:p,children:n.jsx(fe,{cell:e,columnAlignment:C??x.RIGHT,isHeader:t,testId:s})})};try{ee.displayName="Cell",ee.__docgenInfo={description:"",displayName:"Cell",props:{cell:{defaultValue:null,description:"",name:"cell",required:!1,type:{name:"TCellShape"}},isHeader:{defaultValue:null,description:"",name:"isHeader",required:!0,type:{name:"boolean"}},columnHeaderAlignment:{defaultValue:null,description:"",name:"columnHeaderAlignment",required:!1,type:{name:"string"}},columnAlignment:{defaultValue:{value:"Align.LEFT"},description:"",name:"columnAlignment",required:!1,type:{name:"Align.LEFT | Align.RIGHT | null"}},width:{defaultValue:null,description:"",name:"width",required:!1,type:{name:"TStringOrNumber"}},snapshot:{defaultValue:null,description:"",name:"snapshot",required:!1,type:{name:"any"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const F=({row:e,rowIndex:t,isHeader:r=!1,columnCount:l,colSpan:a,columnHeaderAlignments:o=[],columnAlignment:s=[],hasRowActions:u,draggableTable:d=!1,snapshot:p=null,provided:c=null,width:y,columnWidths:g,testId:H})=>{const C=q.useRef(null),P=Nn(o,r,t),{onRowClick:R,onRowFocus:k,onRowMouseEnter:I,onRowMouseLeave:A,expandedContent:j,error:ne,warning:L,active:E}=e,S=e.cells.map((h,T)=>{const $=`${r?0:1}_${t}_${T}`;return n.jsx(ee,{cell:h,isHeader:r,columnAlignment:s[T],columnHeaderAlignment:P[T],width:g?g[T]:void 0,snapshot:p,testId:h.testId},$)}),V=u&&n.jsx(ee,{cell:{type:v.ACTIONS,actions:e.actions},isHeader:r},l),te=(h,T)=>({minWidth:h&&`${y}px`,width:h&&"100%",display:h&&"table",background:h&&"var(--color-background-listitem-active)",border:h&&"var(--color-border)",borderTop:h&&0,opacity:h&&.1,...T}),U=()=>e.noDrag?n.jsx("td",{"aria-labelledby":"unique-label-id"}):n.jsx("td",{className:b.dragIconCell,children:n.jsx("div",{...c.dragHandleProps,className:b.dragIcon,children:n.jsx(M,{icon:B.DRAG})})});return r?n.jsxs(n.Fragment,{children:[n.jsxs("tr",{ref:C,onClick:R,onMouseEnter:I,onMouseLeave:A,onFocus:k,className:w(R?b.clickableRow:null,I?b.hoverableRow:null),children:[d?n.jsx("th",{}):null,S,V]},t),j&&j.content?n.jsx(Y,{colSpan:a,flush:j.flush===!0,children:j.content},`${t}_expanded_content`):null]}):n.jsxs(n.Fragment,{children:[n.jsxs("tr",{onClick:R,onMouseEnter:I,onMouseLeave:A,onFocus:k,className:w(R&&!R.noStyle?b.clickableRow:null,I&&!I.noStyle?b.hoverableRow:null,E?b.rowActive:null,ne?b.errorRow:null,L?b.warningRow:null),ref:(c==null?void 0:c.innerRef)||null,...(c==null?void 0:c.draggableProps)||null,style:p&&c?te(p.isDragging,c.draggableProps.style):null,children:[d?U():null,S,V]},t),j&&j.content?n.jsx(Y,{colSpan:a,flush:j.flush===!0,children:j.content},`${t}_expanded_content`):null]})};try{F.displayName="Row",F.__docgenInfo={description:"",displayName:"Row",props:{row:{defaultValue:null,description:"",name:"row",required:!0,type:{name:"TRowType"}},rowIndex:{defaultValue:null,description:"",name:"rowIndex",required:!0,type:{name:"number"}},isHeader:{defaultValue:{value:"false"},description:"",name:"isHeader",required:!1,type:{name:"boolean"}},columnCount:{defaultValue:null,description:"",name:"columnCount",required:!0,type:{name:"number"}},colSpan:{defaultValue:null,description:"",name:"colSpan",required:!0,type:{name:"number"}},columnHeaderAlignments:{defaultValue:{value:"[]"},description:"",name:"columnHeaderAlignments",required:!1,type:{name:"string[] | string[][]"}},columnAlignment:{defaultValue:{value:"[]"},description:"",name:"columnAlignment",required:!1,type:{name:"string[]"}},hasRowActions:{defaultValue:null,description:"",name:"hasRowActions",required:!0,type:{name:"boolean"}},draggableTable:{defaultValue:{value:"false"},description:"",name:"draggableTable",required:!1,type:{name:"boolean"}},snapshot:{defaultValue:{value:"null"},description:"",name:"snapshot",required:!1,type:{name:"any"}},provided:{defaultValue:{value:"null"},description:"",name:"provided",required:!1,type:{name:"any"}},width:{defaultValue:null,description:"",name:"width",required:!1,type:{name:"TStringOrNumber"}},columnWidths:{defaultValue:null,description:"",name:"columnWidths",required:!1,type:{name:"string[]"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const ke=e=>{var je,Ne,we,Re,Ae,ve,Se;const{onListReorder:t=()=>{},table:r}=e,{columnWidths:l,footer:a,name:o,rows:s=[],actions:u,actionsRight:d,columnHeaderAlignments:p,columnAlignment:c,striped:y=!0,testId:g,draggable:H,defaultEmptyRow:C=null,onAddRow:P=null,bordered:R=!0,maxHeight:k,fixedWidth:I}=r,A=q.useRef(null),[j,ne]=q.useState({width:0,height:0});q.useEffect(()=>{A.current&&ne({width:A.current.offsetWidth,height:A.current.offsetHeight})},[]);const L=Fe.get(e,"table.headers",[]),E=mn(s,L),S=_n(s,L),V=E+(S?1:0),te=a?((Ne=(je=a==null?void 0:a.pagination)==null?void 0:je.rowsPerPage)==null?void 0:Ne.value)===0||Number((we=a==null?void 0:a.pagination)==null?void 0:we.selectedPage)>=Number((Re=a==null?void 0:a.pagination)==null?void 0:Re.rowCount)/Number((ve=(Ae=a==null?void 0:a.pagination)==null?void 0:Ae.rowsPerPage)==null?void 0:ve.value):!0,U=((Se=C==null?void 0:C.cells)==null?void 0:Se.length)&&P&&te,T={cells:U?C.cells.map((m,N)=>(m==null?void 0:m.type)==="Input"?{...m,onChange:_=>{var G;const f=(G=_==null?void 0:_.target)==null?void 0:G.value,D={...C,cells:C.cells.map((X,We)=>({...X,value:We===N?f:X==null?void 0:X.value}))};P({newRow:D})}}:{...m,disabled:!0}):null,testId:g?`${g}-last-empty-row`:void 0},$=U?s.concat(T):s,xe={...r,rows:$},Ce=w(W.wrapper,R?W.bordered:""),Ie={maxHeight:k,width:I,display:I==="auto"?"inline-flex":"flex"};return H?n.jsxs("div",{ref:A,className:Ce,style:Ie,children:[n.jsx(z,{actions:u,actionsRight:d,name:o,testId:g&&`${g}-title`}),n.jsx(Pe,{onDragEnd:m=>{var f,D;const N=(f=m==null?void 0:m.source)==null?void 0:f.index,_=(D=m==null?void 0:m.destination)==null?void 0:D.index;typeof N=="number"&&typeof _=="number"&&t({from:N,to:_})},children:n.jsx(Le,{droppableId:"droppable",children:m=>n.jsx(K,{table:xe,children:({visibleRows:N})=>n.jsxs("table",{className:w(W.table,y?W.striped:""),"data-testid":g,ref:m.innerRef,children:[n.jsx("thead",{children:L.map((_,f)=>n.jsx(F,{rowIndex:f,isHeader:!0,row:_,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,columnHeaderAlignments:p,draggableTable:H},`0_${f}`))}),n.jsxs("tbody",{children:[$.slice(0,N).map((_,f)=>n.jsx(De,{draggableId:f+"",index:f,isDragDisabled:_.noDrag,children:(D,G)=>n.jsx(F,{rowIndex:f,row:_,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,provided:D,snapshot:G,draggableTable:H,width:j.width},`1_${f}`)},`index_${f}`)),m.placeholder]})]})})})}),a&&n.jsx(J,{pagination:a.pagination,actions:a.actions,content:a.content})]}):n.jsxs("div",{className:Ce,style:Ie,children:[n.jsx(z,{actions:u,actionsRight:d,name:o,testId:g&&`${g}-title`}),n.jsx(K,{table:xe,children:({visibleRows:m})=>n.jsxs("table",{className:w(W.table,y?W.striped:""),"data-testid":g,children:[n.jsx("thead",{children:L.map((N,_)=>n.jsx(F,{rowIndex:_,isHeader:!0,row:N,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c,columnHeaderAlignments:p},`0_${_}`))}),n.jsx("tbody",{children:$.slice(0,m).map((N,_)=>n.jsx(F,{rowIndex:_,row:N,columnCount:E,columnWidths:l,colSpan:V,hasRowActions:S,columnAlignment:c},`1_${_}`))})]})}),a&&n.jsx(J,{colSpan:V,pagination:a.pagination,actions:a.actions,content:a.content})]})};try{ke.displayName="Table",ke.__docgenInfo={description:"",displayName:"Table",props:{onListReorder:{defaultValue:null,description:"",name:"onListReorder",required:!1,type:{name:"((obj: { from: number; to: number; }) => void)"}},table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"{ name?: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; ... 18 more ...; actions?: any; }"}}}}}catch{}export{v as C,ke as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as S}from"./index-RfLt4OUa.js";import{f as B}from"./immer.esm-bD7SSJ7T.js";import{l as q}from"./lodash-Bmg8FrMx.js";import{G as le}from"./grid-u1mZpaML.js";import{T as W}from"./text-6KQ6ntOV.js";import{T as D}from"./table-38J6JCSb.js";import{C as dn}from"./card-0r8RRVk-.js";import{I as se}from"./input-fYKvBwPs.js";import{F as oe}from"./field-m7XXDdEG.js";import{H as un}from"./heading-4tVgoT7O.js";import{t as ae,x as pn,y as gn,z as mn,A as bn,B as hn,C as wn,D as vn}from"./table.stories-data-tjY9V0bM.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./index.es-VXFRDikp.js";import"./inheritsLoose-8sb_A2v4.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./index-miLrID2P.js";import"./memoize-one.esm-hqe5SRxC.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./actions-7PO9r8zE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./button-BiJw0fB3.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./index-4QtD-hFu.js";import"./tooltip-dueTLnwA.js";import"./types-VB5zD18b.js";import"./types-5uVBABF4.js";import"./badge-23Ty_zBt.js";import"./pagination-DtJdggbI.js";import"./select-AcJYUY86.js";import"./assertThisInitialized-4q6YPdh3.js";import"./select.input-zP5tW20f.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-ymd7m-s5.js";import"./index-qZmQ7nA9.js";import"./index-cCpkwrS5.js";import"./check-box-KynSyTaY.js";import"./help-icon-eelulTML.js";import"./slider-n3IxC2iq.js";import"./index-ugi_ZH6T.js";import"./popover-Ioxe80BK.js";import"./label-bLcoUwtK.js";import"./flex-RYZsoWEN.js";const bt={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),z=A.bind({}),_=A.bind({});_.args={table:{...ae,fixedWidth:"400px"}};const N=A.bind({});N.args={table:{...ae,fixedWidth:"auto"}};const O=A.bind({});O.args={table:pn};O.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 L=A.bind({});L.args={table:gn};const U=A.bind({});U.args={table:mn};U.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const Q=A.bind({});Q.args={table:bn};const E=A.bind({});E.args={table:hn};E.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const M=A.bind({});M.args={table:wn};M.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const G=A.bind({});G.args={table:vn};const $=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});$.parameters={docs:{source:{type:"dynamic"}}};const J=()=>{const h=["Section","Width","Height"];let m=["","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=m[t],b=l.target.value;m=m.map((v,s)=>s===t?b:v),o=o.map(v=>v.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),[v,s]=S.useState(!1),u=()=>{s(!v)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,g={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:m[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:m[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,y)=>({value:e[y],type:"Input",onChange:C=>i(C,I,y,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:g})};return n.jsx(w,{})},X=()=>{const h=["Section","Width","Height"];let m=[...Array(20).keys()].map((x,i)=>({Section:q.random(0,100),Width:q.random(0,100),Height:q.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,v)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-v[s];case"down":return v[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(m,x).map(r=>({cells:Object.entries(r).map(([b,v])=>({key:b,value:v,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},Y=()=>{const h=["Section","Width","Height"];let m=[...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?m.length-1:c+i,v=(e,d,I)=>e.filter(P=>Object.keys(d).every(y=>d[y]===""?!0:P[y].toString().includes(d[y]))).sort((P,y)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-y[C];case"down":return y[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,y)=>{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 K=V===""?"up":V==="up"?"down":"";y({...P,[f]:K})}}}),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=v(m,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],g={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:g})};return n.jsx(o,{})},Z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},m=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:m,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,g)=>({cells:[{type:"Select",options:m,value:{value:"tea"}},{type:"Input",value:g+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 g=B(i,e=>{e.push(a??o)});R(g)},v=({rowIndex:a})=>{const g=B(i,e=>{delete e[a]}).filter(e=>e);R(g)},s=({rowIndex:a,value:g})=>{const e=B(i,d=>{d[a].cells[0].value.value=g});R(e)},u=({rowIndex:a,value:g})=>{const e=B(i,d=>{d[a].cells[1].value=g});R(e)},j=({value:a})=>{const g=Number(a);return!q.isNaN(g)&&q.isInteger(g)&&g>0},T=i.slice(r,c).map((a,g)=>{const e=r+g;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,K,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,y=Number((ie=(K=a==null?void 0:a.cells)==null?void 0:K[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:y})?(C*y).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:()=>v({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:g}=a.target;w(Number(g))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},ee=()=>{const h=["Section","Width","Height"];let m=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)=>{m[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:m.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((v,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,{})},ne=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((m,o)=>"right"),headers:[{cells:[...Array(10)].map((m,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((m,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((m,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})},te=()=>{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})};var ce,de,ue;z.parameters={...z.parameters,docs:{...(ce=z.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
|
|
1
|
+
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as S}from"./index-RfLt4OUa.js";import{f as B}from"./immer.esm-bD7SSJ7T.js";import{l as q}from"./lodash-Bmg8FrMx.js";import{G as le}from"./grid-u1mZpaML.js";import{T as W}from"./text-6KQ6ntOV.js";import{T as D}from"./table-kSTipYE0.js";import{C as dn}from"./card-0r8RRVk-.js";import{I as se}from"./input-fYKvBwPs.js";import{F as oe}from"./field-m7XXDdEG.js";import{H as un}from"./heading-4tVgoT7O.js";import{t as ae,x as pn,y as gn,z as mn,A as bn,B as hn,C as wn,D as vn}from"./table.stories-data-tjY9V0bM.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./index.es-VXFRDikp.js";import"./inheritsLoose-8sb_A2v4.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./index-miLrID2P.js";import"./memoize-one.esm-hqe5SRxC.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./actions-7PO9r8zE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./button-BiJw0fB3.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./index-4QtD-hFu.js";import"./tooltip-dueTLnwA.js";import"./types-VB5zD18b.js";import"./types-5uVBABF4.js";import"./badge-23Ty_zBt.js";import"./pagination-DtJdggbI.js";import"./select-AcJYUY86.js";import"./assertThisInitialized-4q6YPdh3.js";import"./select.input-zP5tW20f.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-ymd7m-s5.js";import"./index-qZmQ7nA9.js";import"./index-cCpkwrS5.js";import"./check-box-KynSyTaY.js";import"./help-icon-eelulTML.js";import"./slider-n3IxC2iq.js";import"./index-ugi_ZH6T.js";import"./popover-N9B8JT3G.js";import"./label-bLcoUwtK.js";import"./flex-RYZsoWEN.js";const bt={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),z=A.bind({}),_=A.bind({});_.args={table:{...ae,fixedWidth:"400px"}};const N=A.bind({});N.args={table:{...ae,fixedWidth:"auto"}};const O=A.bind({});O.args={table:pn};O.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 L=A.bind({});L.args={table:gn};const U=A.bind({});U.args={table:mn};U.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const Q=A.bind({});Q.args={table:bn};const E=A.bind({});E.args={table:hn};E.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const M=A.bind({});M.args={table:wn};M.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const G=A.bind({});G.args={table:vn};const $=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});$.parameters={docs:{source:{type:"dynamic"}}};const J=()=>{const h=["Section","Width","Height"];let m=["","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=m[t],b=l.target.value;m=m.map((v,s)=>s===t?b:v),o=o.map(v=>v.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),[v,s]=S.useState(!1),u=()=>{s(!v)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,g={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:m[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:m[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,y)=>({value:e[y],type:"Input",onChange:C=>i(C,I,y,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:g})};return n.jsx(w,{})},X=()=>{const h=["Section","Width","Height"];let m=[...Array(20).keys()].map((x,i)=>({Section:q.random(0,100),Width:q.random(0,100),Height:q.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,v)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-v[s];case"down":return v[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(m,x).map(r=>({cells:Object.entries(r).map(([b,v])=>({key:b,value:v,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},Y=()=>{const h=["Section","Width","Height"];let m=[...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?m.length-1:c+i,v=(e,d,I)=>e.filter(P=>Object.keys(d).every(y=>d[y]===""?!0:P[y].toString().includes(d[y]))).sort((P,y)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-y[C];case"down":return y[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,y)=>{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 K=V===""?"up":V==="up"?"down":"";y({...P,[f]:K})}}}),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=v(m,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],g={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:g})};return n.jsx(o,{})},Z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},m=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:m,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,g)=>({cells:[{type:"Select",options:m,value:{value:"tea"}},{type:"Input",value:g+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 g=B(i,e=>{e.push(a??o)});R(g)},v=({rowIndex:a})=>{const g=B(i,e=>{delete e[a]}).filter(e=>e);R(g)},s=({rowIndex:a,value:g})=>{const e=B(i,d=>{d[a].cells[0].value.value=g});R(e)},u=({rowIndex:a,value:g})=>{const e=B(i,d=>{d[a].cells[1].value=g});R(e)},j=({value:a})=>{const g=Number(a);return!q.isNaN(g)&&q.isInteger(g)&&g>0},T=i.slice(r,c).map((a,g)=>{const e=r+g;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,K,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,y=Number((ie=(K=a==null?void 0:a.cells)==null?void 0:K[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:y})?(C*y).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:()=>v({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:g}=a.target;w(Number(g))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},ee=()=>{const h=["Section","Width","Height"];let m=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)=>{m[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:m.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((v,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,{})},ne=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((m,o)=>"right"),headers:[{cells:[...Array(10)].map((m,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((m,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((m,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})},te=()=>{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})};var ce,de,ue;z.parameters={...z.parameters,docs:{...(ce=z.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-FsUICBgo.js";import{T as X}from"./table-
|
|
1
|
+
import{j as G}from"./jsx-runtime-FsUICBgo.js";import{T as X}from"./table-kSTipYE0.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-tjY9V0bM.js";import"./index-RfLt4OUa.js";import"./index-VW3EWkuE.js";import"./index.es-VXFRDikp.js";import"./inheritsLoose-8sb_A2v4.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./index-miLrID2P.js";import"./memoize-one.esm-hqe5SRxC.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./lodash-Bmg8FrMx.js";import"./actions-7PO9r8zE.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./button-BiJw0fB3.js";import"./spinner-R8Il4aRe.js";import"./icon-8EQazuuW.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./tooltip-dueTLnwA.js";import"./types-VB5zD18b.js";import"./types-5uVBABF4.js";import"./badge-23Ty_zBt.js";import"./heading-4tVgoT7O.js";import"./help-icon-eelulTML.js";import"./pagination-DtJdggbI.js";import"./select-AcJYUY86.js";import"./assertThisInitialized-4q6YPdh3.js";import"./text-6KQ6ntOV.js";import"./select.input-zP5tW20f.js";import"./input-fYKvBwPs.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-ymd7m-s5.js";import"./index-qZmQ7nA9.js";import"./index-cCpkwrS5.js";import"./check-box-KynSyTaY.js";import"./slider-n3IxC2iq.js";import"./index-ugi_ZH6T.js";import"./popover-N9B8JT3G.js";import"./flex-RYZsoWEN.js";const Kr={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} />;
|
package/dist/storybook/assets/{unit-table.stories-0Wv_gCzq.js → unit-table.stories-9k8rllRh.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as v}from"./index-RfLt4OUa.js";import{f as Q}from"./immer.esm-bD7SSJ7T.js";import{d as b}from"./index-qZmQ7nA9.js";import{G as Z}from"./grid-u1mZpaML.js";import{C as L}from"./card-0r8RRVk-.js";import{F as V}from"./field-m7XXDdEG.js";import{H as E}from"./heading-4tVgoT7O.js";import{S as H}from"./select-AcJYUY86.js";import{T as F}from"./toggle-R__kwKym.js";import{l as ee}from"./lodash-Bmg8FrMx.js";import{u as te}from"./use-previous-VKMmnaK7.js";import{T as ne,C as P}from"./table-
|
|
1
|
+
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as v}from"./index-RfLt4OUa.js";import{f as Q}from"./immer.esm-bD7SSJ7T.js";import{d as b}from"./index-qZmQ7nA9.js";import{G as Z}from"./grid-u1mZpaML.js";import{C as L}from"./card-0r8RRVk-.js";import{F as V}from"./field-m7XXDdEG.js";import{H as E}from"./heading-4tVgoT7O.js";import{S as H}from"./select-AcJYUY86.js";import{T as F}from"./toggle-R__kwKym.js";import{l as ee}from"./lodash-Bmg8FrMx.js";import{u as te}from"./use-previous-VKMmnaK7.js";import{T as ne,C as P}from"./table-kSTipYE0.js";import"./index-cCpkwrS5.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./label-bLcoUwtK.js";import"./common-types-U65vzrrz.js";import"./help-icon-eelulTML.js";import"./tooltip-dueTLnwA.js";import"./index-miLrID2P.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./index-4QtD-hFu.js";import"./disabled-context-urNQThQz.js";import"./types-5uVBABF4.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./types-VB5zD18b.js";import"./text-6KQ6ntOV.js";import"./actions-7PO9r8zE.js";import"./button-BiJw0fB3.js";import"./spinner-R8Il4aRe.js";import"./badge-23Ty_zBt.js";import"./select.input-zP5tW20f.js";import"./index.es-VXFRDikp.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./pagination-DtJdggbI.js";import"./input-fYKvBwPs.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-ymd7m-s5.js";import"./check-box-KynSyTaY.js";import"./slider-n3IxC2iq.js";import"./index-ugi_ZH6T.js";import"./popover-N9B8JT3G.js";const ae=o=>o.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:g})=>(i[s]=a,r[s]=g,{preferredUnits:i,storageUnits:r}),{preferredUnits:{},storageUnits:{}}),re=({headers:o,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:g,enableCosmeticRounding:c,enableDisplayRounding:f})=>{const u=o?o.map(m=>({...m,cells:m.cells.map(p=>{var t;if(p.type===P.AUTO_UNIT){const{testId:C,unitKey:d}=p;return{value:r[d],type:P.SELECT,searchable:!1,options:(t=b.getUnitsForQuantity(d))==null?void 0:t.map(h=>({label:b.label(h),value:h})),native:p.native,onChange:h=>a({unitKey:d,value:h.target.value}),testId:C}}return p})})):[],l=i?i.map((m,p)=>({...m,cells:m.cells.map((t,C)=>{if("autoUnit"in t&&(t!=null&&t.autoUnit)&&(typeof(t==null?void 0:t.value)=="string"||typeof(t==null?void 0:t.value)=="number")){const{unitKey:d,value:h,formatDisplayValue:U}=t,x=f&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,e=r[d],T=s[d],y=e!==T,S=y?b.convertAndGetValue(h,e,T):t.value,R=b.isScientificStringNum(h),w=c&&(y||!R)?b.roundToPrecision(S,14):S,_=U?U(w):w;return{...t,value:_,enableCosmeticRounding:c,enableDisplayRounding:f,roundDisplayValue:x,onChange:j=>{const{value:W}=j.target,I=s[d],D=r[d],J=D!==I,K=g?I:D,$=J?b.convertAndGetValue(W,K,D):W;if("onChange"in t){const{onChange:X}=t,Y={...j,target:{...j.target,value:String($),rowIndex:p,cellIndex:C,unit:K}};X(Y)}}}}return t})})):[];return{convertedHeaders:u,convertedRows:l}},B=({table:o,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:g,headers:c,...f}=o,{storageUnits:u,preferredUnits:l}=ae(i),m=te(l),[p,t]=v.useState(l),C=({unitKey:e,value:T})=>t({...p,[e]:T}),d=e=>re({headers:c,rows:g,selectedUnits:e,storageUnits:u,onChangeUnit:C,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),h=d(p),[U,x]=v.useState(h);return v.useEffect(()=>{!ee.isEqual(l,m)&&(t(l),x(d(l)))},[i]),v.useEffect(()=>{x(d(p))},[o,p]),n.jsx(ne,{table:{...f,headers:U.convertedHeaders,rows:U.convertedRows}})};try{B.displayName="UnitTable",B.__docgenInfo={description:"",displayName:"UnitTable",props:{table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"IUnitTable"}},unitConfig:{defaultValue:null,description:"",name:"unitConfig",required:!0,type:{name:"IUnitConfigItem[]"}},convertBackToStorageUnit:{defaultValue:{value:"true"},description:"",name:"convertBackToStorageUnit",required:!1,type:{name:"boolean"}},enableCosmeticRounding:{defaultValue:{value:"true"},description:"",name:"enableCosmeticRounding",required:!1,type:{name:"boolean"}},enableDisplayRounding:{defaultValue:{value:"true"},description:"",name:"enableDisplayRounding",required:!1,type:{name:"boolean"}},onListReorder:{defaultValue:null,description:"",name:"onListReorder",required:!1,type:{name:"((obj: { from: number; to: number; }) => void)"}}}}}catch{}const dt={title:"Basic/UnitTable",args:{}},oe=!0,ie=!0,le=!0,se=!1,z="m",M="C",ue=3,de=(o,i,r)=>{const s=[i,i,r],a=[...Array(o)].map((g,c)=>{const f=c,u=c+1.25,l=4+c*.25;return[String(f),String(u),String(l)]});return[s,...a]},ce=de(ue,z,M),pe=({reduxTable:o,value:i,unit:r,rowIndex:s,cellIndex:a})=>Q(o,g=>{const c=g[0][a],f=(u,l)=>l===0;return g.forEach((u,l)=>{if(f(u,l)){u[a]=r;return}if(l===s+1){u[a]=String(i);return}const m=b.convertAndGetValue(u[a],r,c);u[a]=String(m)}),g}),ge=({reduxTable:o,value:i,rowIndex:r,cellIndex:s})=>Q(o,a=>{a[r+1][s]=i}),k=()=>{var U,x;const[o,i]=v.useState(z),[r,s]=v.useState(M),[a,g]=v.useState(ce),[c,f]=v.useState(oe),[u,l]=v.useState(le),[m,p]=v.useState(ie),[t,C]=v.useState(se),d=e=>{const{rowIndex:T,cellIndex:y,value:S,unit:R}=e.target,w=t?pe({reduxTable:a,value:S,unit:R,rowIndex:T,cellIndex:y}):ge({reduxTable:a,value:S,rowIndex:T,cellIndex:y});g(w)},h=a.reduce((e,T,y)=>(y===0?e.headers=[{cells:[{value:"From"},{value:"To"},{value:"Temperature"}]},{cells:[{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"temperature",testId:"table-unit-selector-3"}]}]:e.rows=e.rows.concat({cells:T.map((S,R)=>{const w=y===1&&R===1;return{value:S,type:w?"Text":"NumberInput",unitKey:R===2?"temperature":"length",onChange:d,roundDisplayValue:y===3&&R===2?D=>b.roundByMagnitude(D,2):null,formatDisplayValue:w?D=>`T* ${D}`:null,autoUnit:!0}})}),e),{headers:[],rows:[]});return n.jsxs(Z,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(L,{heading:n.jsx(E,{children:"Settings"}),children:[n.jsx(V,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(F,{checked:c,onChange:e=>f(e.target.checked)})}),n.jsx(V,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(F,{checked:u,onChange:e=>l(e.target.checked)})}),n.jsx(V,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(F,{checked:m,onChange:e=>p(e.target.checked)})}),n.jsx(V,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(F,{checked:t,onChange:e=>C(e.target.checked)})})]}),n.jsxs(L,{heading:n.jsx(E,{children:"Unit template"}),children:[n.jsx(V,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(H,{options:(U=b.getUnitsForQuantity("length"))==null?void 0:U.map(e=>({value:e,label:b.label(e)})),value:{value:o},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(V,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(H,{options:(x=b.getUnitsForQuantity("temperature"))==null?void 0:x.map(e=>({value:e,label:b.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(L,{heading:n.jsx(E,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsx(L,{heading:n.jsx(E,{children:"UnitTable"}),children:n.jsx(B,{table:h,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:o},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:c,enableDisplayRounding:u,enableCosmeticRounding:m})})]})};var A,N,q,G,O;k.parameters={...k.parameters,docs:{...(A=k.parameters)==null?void 0:A.docs,source:{originalSource:`() => {
|
|
2
2
|
const [preferredLengthUnit, setPreferredLengthUnit] = useState(initialLengthUnit);
|
|
3
3
|
const [preferredTemperatureUnit, setPreferredTemperatureUnit] = useState(initialTemperatureUnit);
|
|
4
4
|
const [reduxTable, setReduxTable] = useState<TTable>(initialTable);
|