@oliasoft-open-source/react-ui-library 4.8.1 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-2ftDGfRC.js → Color-KGDBMAHA-CLI1j7TM.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-G3VSiFLs.js → DocsRenderer-PKQXORMH-C-VGLian.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-B3eUVB9V.js → accordion.stories-CjdOndbq.js} +2 -2
- package/dist/storybook/assets/{afe.stories-CSYzQy-o.js → afe.stories-D-uQj_IO.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-DgWk5FQt.js → buttons-and-links-DLCyz4fu.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-CTf1cpS3.js → casing-loads.stories-Cb2t61c-.js} +2 -2
- package/dist/storybook/assets/{cell.stories-DXApMBee.js → cell.stories-B6XrqnOz.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-CGp4-QUE.js → chunk-HLWAVYOI-B-NqvPla.js} +1 -1
- package/dist/storybook/assets/{color-JX8P2xFz.js → color-DFh0-vFc.js} +1 -1
- package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
- package/dist/storybook/assets/{footer.stories-BobRokDb.js → footer.stories-BxFhNGsz.js} +2 -2
- package/dist/storybook/assets/form.stories-C_zflIAj.js +49 -0
- package/dist/storybook/assets/{formation.stories-xm22XGgs.js → formation.stories-r9JrQX7d.js} +2 -2
- package/dist/storybook/assets/iframe-DOgYbEjR.js +2 -0
- package/dist/storybook/assets/{index-D-0J5wOk.js → index-BIH3zom3.js} +1 -1
- package/dist/storybook/assets/{index-Bh4hgpyc.js → index-MQZw3-wz.js} +4 -4
- package/dist/storybook/assets/{input-group.stories-M4a8AYtB.js → input-group.stories-dQnx3QX0.js} +2 -2
- package/dist/storybook/assets/{input-validation-CRY9hASh.js → input-validation-BhTmzA8C.js} +2 -2
- package/dist/storybook/assets/{inputs-PulLFmNE.js → inputs-BZwMYCXB.js} +2 -2
- package/dist/storybook/assets/layout-forms-j_hFXArR.js +16 -0
- package/dist/storybook/assets/{layout-general-BS3o8j_a.js → layout-general-hZ1fwnpl.js} +1 -1
- package/dist/storybook/assets/{modal.stories-PZXXHpu9.js → modal.stories-B-4WKtnM.js} +2 -2
- package/dist/storybook/assets/{number-input-CEoWDcRg.js → number-input-C8O0lnql.js} +2 -2
- package/dist/storybook/assets/number-input.stories-e-MRb-7_.js +124 -0
- package/dist/storybook/assets/{padding-and-spacing-B4zeG787.js → padding-and-spacing-DZHdCzCJ.js} +1 -1
- package/dist/storybook/assets/{pagination-T__Mixkr.js → pagination-bLx5-m9c.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-C_oRnFX_.js → pagination.stories-BHPRfynZ.js} +2 -2
- package/dist/storybook/assets/popover.stories-DyTPnA5y.js +10 -0
- package/dist/storybook/assets/{preview-_xr6Jbjy.js → preview-_veCKVNG.js} +2 -2
- package/dist/storybook/assets/{preview-D_pdGeyT.js → preview-nWTzJqHS.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-zzDr9Zir.js → reservoirs.stories-C98Z9kS0.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-be871WZn.js → rich-text-input.stories-B2p90wTh.js} +3 -3
- package/dist/storybook/assets/{row.stories-DmNKaTP6.js → row.stories-BRVnImTl.js} +2 -2
- package/dist/storybook/assets/select-BpALjE__.js +61 -0
- package/dist/storybook/assets/{select.stories-CtbKVF6A.js → select.stories-B0d_sE6g.js} +2 -2
- package/dist/storybook/assets/{table-C0QH08M6.js → table-DWBe_npR.js} +1 -1
- package/dist/storybook/assets/{table.stories-safUrF3C.js → table.stories-Cb7lE3nF.js} +2 -2
- package/dist/storybook/assets/{title.stories-By9nz9a2.js → title.stories-TUTSNdwJ.js} +2 -2
- package/dist/storybook/assets/{unit-input.stories-DTP4sTwo.js → unit-input.stories-CRAsgJro.js} +10 -10
- package/dist/storybook/assets/unit-table.stories-BdTJv4W-.js +152 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/form.stories-BCg9rFVI.js +0 -49
- package/dist/storybook/assets/iframe-EHZbBy3L.js +0 -2
- package/dist/storybook/assets/layout-forms-Dhgne9wj.js +0 -16
- package/dist/storybook/assets/number-input.stories-DqfU8Xdg.js +0 -110
- package/dist/storybook/assets/popover.stories-B9slHpqQ.js +0 -10
- package/dist/storybook/assets/select-BW0IihoR.js +0 -61
- package/dist/storybook/assets/unit-table.stories-CnyzGe3D.js +0 -152
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJvc.js";import{w as i,e as o,u as c}from"./index-DMAnyMX5.js";import{S as z}from"./select-
|
|
1
|
+
import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJvc.js";import{w as i,e as o,u as c}from"./index-DMAnyMX5.js";import{S as z}from"./select-BpALjE__.js";import{S as qa}from"./spacer-BWoNR27H.js";import{I as Z}from"./common-types-Sih75Sav.js";import{I as $}from"./icon-BP4BO6-k.js";import"./index-CF7H4eMJ.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const _a=[{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Koalas",value:"leaves"},{label:"Monkeys",value:"bananas",disabled:!0},{label:"Wombats",value:"bark"}],Fa=[{label:"Kangaroos",value:"grass",details:"(grass)"},{label:"Monkeys",value:"bananas",details:"(bananas)"},{label:"Possums",value:"slugs",details:"(slugs)"}],Ga=[{type:"Heading",label:"Large"},{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{type:"Heading",label:"Small"},{label:"Possums",value:"slugs"}],Ya=[{label:1,value:1},{label:2,value:2},{label:3,value:3},{label:4,value:4}],Za=[{label:"Yes",value:!0},{label:"No",value:!1}],$a=[{label:"Aardvarks",value:"termites"},{label:"Monkeys",value:"bananas"},{label:"Vampires",value:"blood",icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"})},{label:"Zombies",value:"brains",icon:d.jsx($,{icon:Z.ERROR,color:"var(--color-text-error)"})}],y=[{label:"Delete",icon:"delete",onClick:()=>{}},{label:"Rename",icon:"rename",onClick:()=>{}}],za=[{label:"Kangaroos",value:"grass",actions:y},{label:"Monkeys",value:"bananas",actions:y},{label:"Possums",value:"slugs",actions:y,details:"(some details)"}],Ja=[{label:"Kangaroos",value:"grass",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(grass)"},{label:"Monkeys",value:"bananas",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(bananas)"},{label:"Possums",value:"slugs",actions:y,icon:d.jsx($,{icon:Z.WARNING,color:"var(--color-text-warning)"}),details:"(slugs)"}],Qa=[...Array(1e4).keys()].map((t,l)=>({label:Math.random().toString(36).substring(7),value:l})),Ua=["Aardvarks","Kangaroos","Monkeys","Possums"],kn={title:"Forms/Select",component:z,args:{options:_a,native:!1,multi:!1,disabled:!1,autoLayerWidth:!1,clearable:!1,searchable:!0,right:!1}},a=t=>{const{multi:l,value:e}=t,[s,n]=b.useState(e||(l?[]:void 0)),u=r=>{const{value:g}=r.target;n(l?g:{value:g})};return d.jsx(z,{value:s,onChange:u,...t})},J=a.bind({}),C=a.bind({});C.args={small:!0};const x=a.bind({});x.args={width:"auto"};const I=a.bind({});I.args={width:"200px"};const w=a.bind({});w.args={native:!0};const f=a.bind({});f.args={multi:!0,clearable:!0};const T=a.bind({});T.args={options:[]};const B=a.bind({});B.args={clearable:!0};const j=a.bind({});j.args={value:{label:"Vampires",value:"blood"}};const k=a.bind({});k.args={placeholder:"Select the best animal..."};const W=a.bind({});W.args={options:Ga};const O=a.bind({});O.args={options:Fa};const D=a.bind({});D.args={options:$a};const N=a.bind({});N.args={options:za};const A=a.bind({});A.args={options:Ja};const E=a.bind({});E.args={searchable:!1};const M=a.bind({});M.args={right:!0};const v=a.bind({});v.parameters={docs:{description:{story:"Avoid autoLayerWidth for very long lists in custom selects (slow)"}}};v.args={width:"70px",autoLayerWidth:!0};const L=a.bind({});L.args={tooltip:"Some info"};const K=a.bind({});K.args={error:"Some info"};const R=a.bind({});R.args={warning:"Some info"};const P=a.bind({});P.args={disabled:!0};const H=a.bind({});H.args={options:Ya,placeholder:void 0};const _=a.bind({});_.args={options:Za};const q=a.bind({});q.args={options:Ua};const m=a.bind({});m.parameters={docs:{description:{story:"Avoid `width: auto` and autoLayerWidth for very long lists in custom selects (slow). Consider checkNonExistentValues={false}."}}};m.args={options:Qa};const F=a.bind({});F.args={deprecatedEventHandler:!0};const G=a.bind({});G.args={value:{label:"Vampires",value:"blood"},disabled:!0};const Y=()=>{const[t,l]=b.useState([{label:"Aardvarks",value:"termites"},{label:"Kangaroos",value:"grass"},{label:"Monkeys",value:"bananas"},{label:"Possums",value:"slugs"}]),[e,s]=b.useState(void 0),[n,u]=b.useState([]);return d.jsxs(d.Fragment,{children:[d.jsx(z,{name:"example",options:t,onChange:r=>s({value:r.target.value}),onCreate:r=>{const g={label:r,value:r};l([...t,g]),s(g)},value:e,clearable:!0}),d.jsx(qa,{}),d.jsx(z,{name:"example",options:t,onChange:r=>u(r.target.value),onCreate:r=>{const g={label:r,value:r};l([...t,g]),console.log(r),u([...n,g])},value:n,multi:!0,clearable:!0})]})},h=a.bind({});h.args={testId:"testId",clearable:!0};h.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&(await l("Select item with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u);const r=e.getByTestId("testId-value");await o(i(r).getByText("Wombats")).toBeInTheDocument()}),await l("Clear selected value",async()=>{const s=e.getByTestId("testId-clear");await c.click(s);const n=e.queryByTestId("testId-value");await o(n).not.toBeInTheDocument()}))};const S=a.bind({});S.args={testId:"testId",clearable:!0,multi:!0};S.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&(await l("Select items with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u);const r=i(n).getByText("Kangaroos");await c.click(r),await c.click(t),await o(n).not.toBeInTheDocument();const g=e.getByTestId("testId-value");await o(i(g).getByText("Wombats")).toBeInTheDocument(),await o(i(g).getByText("Kangaroos")).toBeInTheDocument()}),await l("Deselect item with click",async()=>{const s=e.getByTestId("testId");await c.click(s);const n=e.getByTestId("testId-layer");await o(n).toBeInTheDocument();const u=i(n).getByText("Wombats");await c.click(u),await c.click(t),await o(n).not.toBeInTheDocument();const r=e.getByTestId("testId-value");await o(i(r).queryByText("Wombats")).not.toBeInTheDocument()}),await l("Clear selected values",async()=>{const s=e.getByTestId("testId-clear");await c.click(s);const n=e.queryByTestId("testId-value");await o(n).not.toBeInTheDocument()}))};const V=a.bind({});V.args={testId:"testId",disabled:!0};V.play=async({canvasElement:t,step:l})=>{const e=i(t);await l("Clicking disabled trigger should not show layer",async()=>{await e.getByTestId("testId").click();const n=e.queryByTestId("testId-layer");await o(n).toBeNull()})};const p=()=>{const[t,l]=b.useState(_a),[e,s]=b.useState(void 0);return d.jsx(z,{testId:"testId",name:"example",options:t,onChange:n=>s({value:n.target.value}),onCreate:n=>{const u={label:n,value:n};l([...t,u]),s(u)},value:e})};p.args={testId:"testId"};p.play=async({canvasElement:t,step:l})=>{const e=t.parentElement?i(t.parentElement):null;await o(e).toBeTruthy(),e&&await l("Create new item",async()=>{const s=e.getByTestId("testId-input");if(o(s).toBeInTheDocument(),!s)return;await c.type(s,"New value");const n=e.getByText('Create "New value"');await c.click(n);const u=e.getByTestId("testId-value");await o(i(u).getByText("New value")).toBeInTheDocument()})};Y.__docgenInfo={description:"",methods:[],displayName:"OnCreate"};p.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestCreate"};var Q,U,X;J.parameters={...J.parameters,docs:{...(Q=J.parameters)==null?void 0:Q.docs,source:{originalSource:`(args: any) => {
|
|
2
2
|
const {
|
|
3
3
|
multi,
|
|
4
4
|
value
|
|
@@ -576,4 +576,4 @@ import{j as d}from"./jsx-runtime-eps93zm2.js";import{r as b}from"./index-DhsZuJv
|
|
|
576
576
|
setOptions([...options, newValue]);
|
|
577
577
|
setSingleValue(newValue);
|
|
578
578
|
}} value={singleValue} />;
|
|
579
|
-
}`,...(Ha=(Pa=p.parameters)==null?void 0:Pa.docs)==null?void 0:Ha.source}}};const
|
|
579
|
+
}`,...(Ha=(Pa=p.parameters)==null?void 0:Pa.docs)==null?void 0:Ha.source}}};const Wn=["Default","Small","AutoWidth","FixedWidth","Native","Multiselect","Empty","Clearable","NonExistentValue","CustomPlaceholder","OptionsWithHeadings","OptionsWithDetails","OptionsWithIcons","OptionsWithActions","OptionsWithEverything","NotSearchable","RightAligned","AutoLayerWidth","Tooltip","Error","Warning","Disabled","NumericOptions","BooleanOptions","SimpleOptions","VeryLongList","DeprecatedEventHandler","TestDisabledNonExistentValue","OnCreate","Test","TestMulti","TestDisabled","TestCreate"];export{v as AutoLayerWidth,x as AutoWidth,_ as BooleanOptions,B as Clearable,k as CustomPlaceholder,J as Default,F as DeprecatedEventHandler,P as Disabled,T as Empty,K as Error,I as FixedWidth,f as Multiselect,w as Native,j as NonExistentValue,E as NotSearchable,H as NumericOptions,Y as OnCreate,N as OptionsWithActions,O as OptionsWithDetails,A as OptionsWithEverything,W as OptionsWithHeadings,D as OptionsWithIcons,M as RightAligned,q as SimpleOptions,C as Small,h as Test,p as TestCreate,V as TestDisabled,G as TestDisabledNonExistentValue,S as TestMulti,L as Tooltip,m as VeryLongList,R as Warning,Wn as __namedExportsOrder,kn as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-D2piFfFj.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Tr0wIZve.js";import{H as Oe}from"./heading-NkLgQYoP.js";import{P as $e}from"./pagination-T__Mixkr.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-CEoWDcRg.js";import{S as Ge}from"./select-BW0IihoR.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-wCvXxtCz.js";import{S as ze}from"./slider-CBE03NwD.js";import{I as G}from"./icon-BP4BO6-k.js";import{P as Ke}from"./popover-9ZnEm5Hy.js";import{H as fe}from"./help-icon-41R-Z9N1.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var o;return(o=e.onChange)==null?void 0:o.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});ve.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var A=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
|
|
1
|
+
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-D2piFfFj.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Tr0wIZve.js";import{H as Oe}from"./heading-NkLgQYoP.js";import{P as $e}from"./pagination-bLx5-m9c.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-C8O0lnql.js";import{S as Ge}from"./select-BpALjE__.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-wCvXxtCz.js";import{S as ze}from"./slider-CBE03NwD.js";import{I as G}from"./icon-BP4BO6-k.js";import{P as Ke}from"./popover-9ZnEm5Hy.js";import{H as fe}from"./help-icon-41R-Z9N1.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var o;return(o=e.onChange)==null?void 0:o.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});ve.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var A=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
|
|
2
2
|
| IStaticCell
|
|
3
3
|
| ISelectCell
|
|
4
4
|
| IHelpIconCell
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-C0QH08M6.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.js";import{F as oe}from"./field-C5_fLDpy.js";import{H as un}from"./heading-NkLgQYoP.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-CYppbCAy.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-T__Mixkr.js";import"./select-BW0IihoR.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CEoWDcRg.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./label-hiSz3I8H.js";import"./flex-EllkLxgO.js";const ht={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
|
|
1
|
+
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-DWBe_npR.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.js";import{F as oe}from"./field-C5_fLDpy.js";import{H as un}from"./heading-NkLgQYoP.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-CYppbCAy.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./label-hiSz3I8H.js";import"./flex-EllkLxgO.js";const wt={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -769,4 +769,4 @@ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJv
|
|
|
769
769
|
}]
|
|
770
770
|
};
|
|
771
771
|
return <Table table={table} />;
|
|
772
|
-
}`,...(cn=(ln=Y.parameters)==null?void 0:ln.docs)==null?void 0:cn.source}}};const
|
|
772
|
+
}`,...(cn=(ln=Y.parameters)==null?void 0:ln.docs)==null?void 0:cn.source}}};const yt=["Default","FixedWidth","AutoWidth","ColumnWidths","ColumnAlignment","ColumnHeaderAlignment","InfiniteScrollFixedHeight","InfiniteScrollFullHeight","InfiniteScrollShort","InfiniteScrollWithDragAndDrop","InCard","Managed","ManagedWithSort","ManagedWithFilterAndMultipleSort","AutoAddNewRow","OnPasteCallback","ExampleTableWithInfoTooltips","ExampleTableWithInlineUnits"];export{z as AutoAddNewRow,L as AutoWidth,Q as ColumnAlignment,O as ColumnHeaderAlignment,_ as ColumnWidths,te as Default,X as ExampleTableWithInfoTooltips,Y as ExampleTableWithInlineUnits,E as FixedWidth,M as InCard,G as InfiniteScrollFixedHeight,N as InfiniteScrollFullHeight,U as InfiniteScrollShort,$ as InfiniteScrollWithDragAndDrop,q as Managed,B as ManagedWithFilterAndMultipleSort,K as ManagedWithSort,J as OnPasteCallback,yt as __namedExportsOrder,wt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-
|
|
1
|
+
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-DWBe_npR.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-CYppbCAy.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./flex-EllkLxgO.js";const Wr={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -34,4 +34,4 @@ import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-C0QH08M
|
|
|
34
34
|
return <Table
|
|
35
35
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
36
|
{...args} />;
|
|
37
|
-
}`,...(_=(U=m.parameters)==null?void 0:U.docs)==null?void 0:_.source}}};const
|
|
37
|
+
}`,...(_=(U=m.parameters)==null?void 0:U.docs)==null?void 0:_.source}}};const kr=["Units","ActiveRow","Title","TitleJSX","ChildComponent","Filter","Sort","HeaderActionsNoLabel","HelpAndLibraryIcons"];export{s as ActiveRow,o as ChildComponent,n as Filter,p as HeaderActionsNoLabel,m as HelpAndLibraryIcons,i as Sort,a as Title,t as TitleJSX,e as Units,kr as __namedExportsOrder,Wr as default};
|
package/dist/storybook/assets/{unit-input.stories-DTP4sTwo.js → unit-input.stories-CRAsgJro.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJvc.js";import{d as l}from"./index-C0x1JmaP.js";import{c as Un}from"./index-Bk2sglWO.js";import{u as wn}from"./use-previous-D775JrO6.js";import{M as Ee}from"./actions-Tr0wIZve.js";import{I as xn}from"./input-group-addon-D68iUKV2.js";import{B as g}from"./button-CzvLc2io.js";import{T as In}from"./tooltip-1V7clEnw.js";import{I as Tn}from"./input-group-BaRSJAEN.js";import{S as I}from"./spacer-BWoNR27H.js";import{T as Yt}from"./text-B3-TSWok.js";import{M as Ne}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{i as Vn}from"./helpers-JJxzGegQ.js";import{N as kn}from"./number-input-
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJvc.js";import{d as l}from"./index-C0x1JmaP.js";import{c as Un}from"./index-Bk2sglWO.js";import{u as wn}from"./use-previous-D775JrO6.js";import{M as Ee}from"./actions-Tr0wIZve.js";import{I as xn}from"./input-group-addon-D68iUKV2.js";import{B as g}from"./button-CzvLc2io.js";import{T as In}from"./tooltip-1V7clEnw.js";import{I as Tn}from"./input-group-BaRSJAEN.js";import{S as I}from"./spacer-BWoNR27H.js";import{T as Yt}from"./text-B3-TSWok.js";import{M as Ne}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{i as Vn}from"./helpers-JJxzGegQ.js";import{N as kn}from"./number-input-C8O0lnql.js";import{D as jn}from"./divider-DY9nJ_7N.js";import{R as Zt,C as ye}from"./row-Bmiy2Lh0.js";import{F as T}from"./field-C5_fLDpy.js";import{M as be}from"./message-DQ3q8XF9.js";import{w as de,u as d,e as w,f as Qt,a as Xt}from"./index-DMAnyMX5.js";import"./index-DRSy5Ssd.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./input-DTXbDJaL.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-hiSz3I8H.js";import"./help-icon-41R-Z9N1.js";import"./index-CF7H4eMJ.js";const Sn=()=>{const t=m.useRef(null);return m.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},En=(t,a)=>{const n=a==null?void 0:a[t];return n||(console.log(`Warning: 'unitTemplate' missing for '${t}'. Using initial unit, preferred unit or value unit.`),l.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const en=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),tn=(t="",a,n="",s=!1)=>{if(s)return t;if(a&&!en(t))try{const i=l.isValueWithUnit(t)?t:l.withUnit(t,n),p=l.convertSamePrecision(i,a);return l.getValue(p)}catch{}return t},Nn=t=>t?!!l.getUnit(t):!1,O=(t="",a,n,s)=>{if(s)return t;const i=Nn(t)||l.isValueWithUnit(t),p=l.getValue(t);return en(p)?p:i?tn(p,a,n,s):t},Ae=t=>V.isObject(t)&&!V.isArray(t)&&!V.isFunction(t)?V.get(t,"fieldName",""):typeof t=="string"?t:"",qe=(t="")=>{var a;return(a=l.KNOWN_UNITS)==null?void 0:a.includes(t)},An=(t,a)=>{const n=l.getUnit(t||"");return qe(a)&&qe(n)};let qn=m.createContext(null);const Dn=()=>m.useContext(qn),Fn="_predefinedMenuActive_ye9w9_1",Pn="_inputWrapper_ye9w9_4",De={predefinedMenuActive:Fn,inputWrapper:Pn},c=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:s=!1,error:i=null,left:p=!1,small:o=!1,width:h="100%",value:v,unitkey:ie="",initUnit:nn,noConversion:an=!1,onChange:ce=V.noop,onClick:_n=V.noop,onFocus:rn=V.noop,onSwitchUnit:Ce=V.noop,unitTemplate:Ue,doNotConvertValue:B=!1,testId:E,warning:we=null,predefinedOptions:x,initialPredefinedOption:sn=!1,shouldLinkAutomaticly:xe=!0,selectedPredefinedOptionKey:Ie,validationCallback:ln=()=>({name:"",error:null}),disabledValidation:un=!1,allowEmpty:on=!1,autoValue:k})=>{const N=Dn(),dn=Sn();typeof v=="number"&&(v=`${v}`);const[Te="",_=""]=v!==void 0?l.split(v):[],Ve=k?l.getUnit(k):"",ke=m.useMemo(()=>En(ie,Ue||(N==null?void 0:N.unitTemplate)),[ie,Ue,N==null?void 0:N.unitTemplate]),cn=An(v,ke),C=nn||ke||_,mn=wn(C),je=O(v,C,_,B),Se=O(k,C,Ve,B),pn=je!==""?{value:je,unit:C}:Se!==""?{value:Se,unit:C}:{value:Te,unit:_},[f,me]=m.useState(pn),[j,pe]=m.useState(sn?b.PREDEFINED:b.CUSTOM),ge=Te===""&&k,gn=!!(un||k||a&&Vn(v)),M=x&&x.find(r=>{if(!(r!=null&&r.value))return;if(Ie)return Ie===r.valueKey;const u=l.isValueWithUnit(r.value)?l.getUnit(r.value):"";return l.withUnit(tn(v,u),u)===r.value}),hn=()=>{if(ie)try{const r=ge?k:v??"";let u=l.altUnitsList(r,ie);return l.getValue(r)===""?u.map(U=>["",U[1]]):u}catch{return null}},vn=r=>{const u=Ae(t),U=r.target,{value:S,selectionStart:ue}=U,ve=l.withUnit(S,(f==null?void 0:f.unit)||"");ce({target:{value:ve,name:u}});const[fe,Cn]=l.split(ve);me({value:fe,unit:Cn}),dn(()=>{U.selectionStart=ue,U.selectionEnd=ue})},fn=(r,u)=>{u===f.unit||isNaN(Number(r))||(me({value:r,unit:u}),Ce&&Ce(u))};m.useEffect(()=>{if(C){let r,u="";mn!==C?(r=O(v,C,_,B),u=C):l.withUnit(f.value,f.unit)!==v&&(r=O(v,f.unit,_,B),u=f.unit),r!==void 0&&me({value:r,unit:u}),x&&pe(M&&xe?b.PREDEFINED:b.CUSTOM)}},[C,v,i,xe]);const re=hn(),se=l.label(f.unit)||f.unit||"",yn=an||!re||re&&re.length===1,he=Ae(t);let le;const bn=r=>{const u=r!=null&&r.value?r.value:"",[U="",S=""]=l.isValueWithUnit(u)?l.split(u):[u];return{type:Ne.OPTION,inline:!0,onClick:()=>{l.validateNumber(U).valid&&!n&&(pe(b.PREDEFINED),ce({target:{value:u,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:r}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(Yt,{children:r.label}),e.jsx(I,{width:"20px",height:"0"})]}),description:l.isValueWithUnit(u)?`${U} ${S}`:u,selected:M===r&&j===b.PREDEFINED}};if(le=[{type:Ne.OPTION,inline:!0,onClick:()=>{j!==b.CUSTOM&&!n&&ce({target:{value:l.withUnit(f.value,f.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:j===b.CUSTOM}],x!=null&&x.length){const r=x.map(bn);le=[...le,...r]}return e.jsx("div",{className:j===b.PREDEFINED?Un(De.predefinedMenuActive):"",children:e.jsxs(Tn,{small:o,width:h,children:[x&&e.jsx(In,{text:j===b.PREDEFINED?M==null?void 0:M.label:"",children:e.jsx(Ee,{maxHeight:380,groupOrder:"first",testId:E&&`${E}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(g,{groupOrder:"first",active:j===b.PREDEFINED,icon:j===b.PREDEFINED?"link":"unlink"}),small:o,sections:le}})}),e.jsx("div",{className:De.inputWrapper,children:e.jsx(kn,{name:he,testId:E,disabled:n,placeholder:ge?O(k,f.unit,Ve,B):a,value:f.value,onChange:vn,onFocus:rn,error:i===null?void 0:i,warning:we===null?void 0:we,left:p,allowEmpty:on,validationCallback:(r,u)=>ln(he,u),groupOrder:x?"middle":"first",disableInternalErrorValidationMessages:gn},he)}),se&&(yn||!cn?e.jsx(xn,{groupOrder:"last",children:se}):e.jsx(Ee,{maxHeight:380,groupOrder:"last",disabled:s,testId:E&&`${E}-menu`,menu:{label:se,trigger:"DropDownButton",small:o,sections:re.map(([r,u,U])=>{const S=U||u||"";return{type:"Option",label:isNaN(Number(r))?"":r,inline:!0,onClick:fe=>{fe.stopPropagation(),fn(ge?"":r,u)},description:S,selected:S===se,testId:`${E}-unit-${S}`}})}}))]})})};c.__docgenInfo={description:"",methods:[],displayName:"UnitInput",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},disabledUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:"",defaultValue:{value:"null",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:"",defaultValue:{value:"() => ({ name: '', error: null })",computed:!1}},disabledValidation:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
2
2
|
target:
|
|
3
3
|
| T
|
|
4
4
|
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
@@ -7,7 +7,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
7
7
|
| T
|
|
8
8
|
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
9
9
|
}`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
|
|
10
|
-
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""}}};const{useArgs:Bn}=__STORYBOOK_MODULE_PREVIEW_API__,wa={title:"Basic/UnitInput",component:c,args:{name:"example",unitkey:"length",value:"123|m"}},y=t=>{const[a,n]=Bn(),s=i=>{n({value:i.target.value})};return e.jsx(c,{...t,onChange:s})},oe=y.bind({}),W=y.bind({});W.args={initUnit:"ft",unitTemplate:{length:"ft"}};const R=y.bind({});R.args={value:'123|"',unitkey:'"'};const L=y.bind({});L.args={width:"180px"};const H=y.bind({});H.args={noConversion:!0};const K=y.bind({});K.args={small:!0};const A=()=>{const[t,a]=m.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),placeholder:"Type a value...",value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};A.play=async({canvasElement:t,step:a})=>{const n=de(t),s=de(t.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123x45s6"),await d.click(t),await w(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Qt.mouseOver(i),await Xt(()=>{w(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const $=y.bind({});$.args={error:"Error message goes here"};const G=y.bind({});G.args={value:"asas123asd|%"};const q=y.bind({});q.args={disabled:!0,disabledUnit:!0};q.parameters={docs:{description:{story:"Each part of UnitInput can be disabled separately. `disabled` disables only the main text input, `disabledUnit` disables only the unit menu. **Needs review (comes from Reservoir input requirements)**"}}};const z=y.bind({});z.args={disabled:!0,disabledUnit:!0,noConversion:!0};const J=y.bind({});J.args={disabledUnit:!0,unitkey:void 0};const Y=y.bind({});Y.args={disabledUnit:!0,unitkey:"length"};const Z=y.bind({});Z.args={disabledUnit:!1,disabled:!0};const D=t=>{const[a,n]=m.useState("123|m"),[s,i]=m.useState("223|m"),[p,o]=m.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Change initUnit",onClick:()=>o(p==="m"?"ft":"m")}),e.jsx(I,{}),e.jsx(g,{label:"Change value",onClick:()=>n(a==="123|m"?"456|m":"123|m")}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,initUnit:p,onSwitchUnit:o}),e.jsx(I,{}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:s,initUnit:p,onSwitchUnit:o}),e.jsx(jn,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,onSwitchUnit:o}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:s,onSwitchUnit:o})]})};D.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const Q=y.bind({});Q.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const P=()=>{const t="500px",[a,n]=m.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Zt,{children:[e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value infinity",onClick:()=>n(1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity",onClick:()=>n(-1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value null",onClick:()=>n(null)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN",onClick:()=>n(NaN)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - empty string",onClick:()=>n("")})]}),e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value infinity|m",onClick:()=>n("Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity|m",onClick:()=>n("-Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value null|m",onClick:()=>n("null|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined|m",onClick:()=>n("undefined|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN|m",onClick:()=>n("NaN|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)|m",onClick:()=>n("|m")})]})]}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI",children:e.jsx(c,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit"})}),e.jsx(T,{label:"Disabled validation",children:e.jsx(c,{name:"example2",onChange:s=>n(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:t})}),e.jsx(T,{label:"Disabled validation and manual error",children:e.jsx(c,{name:"example3",onChange:s=>n(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(be,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},X=()=>{const t="500px",[a,n]=m.useState("1|m"),[s,i]=m.useState("|m"),p="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Zt,{children:e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value to ''",onClick:()=>n("")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1",onClick:()=>n("1")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1|m",onClick:()=>n("1|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to |m - empty value",onClick:()=>n("|m")})]})}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI (placeholder + auto)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:p})}),e.jsx(T,{label:"Normal PUI (only auto)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Empty PUI with autoValue",children:e.jsx(c,{name:"example1",onChange:o=>i(o.target.value),value:s,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Normal PUI (only placeholder)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(T,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(be,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};P.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const ee=()=>{const[t,a]=m.useState("123|%"),[n,s]=m.useState(null),i="This should be visible when an error appears",p=(o,h)=>(s(h),{name:o,error:h});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(c,{name:"example",onChange:o=>a(o.target.value),error:!n||i,validationCallback:p,value:t}),e.jsx("br",{}),e.jsx(I,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(be,{message:{heading:n,visible:!0}})]})},te=()=>{const[t,a]=m.useState("123|m"),[n,s]=m.useState(""),[i,p]=m.useState("km"),o=()=>{p("ft"),s("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(c,{name:"example",onChange:h=>a(h.target.value),value:t,allowEmpty:!0,placeholder:n,initUnit:i,unitkey:"length"}),e.jsx("br",{}),e.jsx(I,{}),e.jsx(g,{label:"Change value |m and unit ft",onClick:()=>o()})]})},ne=()=>{const[t,a]=m.useState("123|m"),[n,s]=m.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:s}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:s})]})},ae=()=>e.jsxs(e.Fragment,{children:[e.jsx(Yt,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(I,{}),e.jsx(c,{name:"example2",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),F=()=>{const[t,a]=m.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};F.play=async({canvasElement:t,step:a})=>{const n=de(t),s=de(t.ownerDocument.body);await a("Can enter decimal values",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123.123456789"),await d.click(t),await w(n.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"-1.12e3"),await d.click(t),await w(n.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123,456"),await d.click(t),await w(n.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"0.0000000023"),await d.click(t),await w(n.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"999999999999"),await d.click(t),await w(n.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const i=n.getByTestId("testId"),p=n.getByTestId("testId-menu");await d.clear(i),await d.type(i,"456.1"),await d.click(t),await d.click(p),await d.click(s.getByTestId("testId-unit-ft")),await w(n.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123x45s6"),await d.click(t),await w(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Qt.mouseOver(i),await Xt(()=>{w(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};A.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};D.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
10
|
+
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""}}};const{useArgs:Bn}=__STORYBOOK_MODULE_PREVIEW_API__,xa={title:"Forms/UnitInput",component:c,args:{name:"example",unitkey:"length",value:"123|m"}},y=t=>{const[a,n]=Bn(),s=i=>{n({value:i.target.value})};return e.jsx(c,{...t,onChange:s})},oe=y.bind({}),W=y.bind({});W.args={initUnit:"ft",unitTemplate:{length:"ft"}};const R=y.bind({});R.args={value:'123|"',unitkey:'"'};const L=y.bind({});L.args={width:"180px"};const H=y.bind({});H.args={noConversion:!0};const K=y.bind({});K.args={small:!0};const A=()=>{const[t,a]=m.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),placeholder:"Type a value...",value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};A.play=async({canvasElement:t,step:a})=>{const n=de(t),s=de(t.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123x45s6"),await d.click(t),await w(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Qt.mouseOver(i),await Xt(()=>{w(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const $=y.bind({});$.args={error:"Error message goes here"};const G=y.bind({});G.args={value:"asas123asd|%"};const q=y.bind({});q.args={disabled:!0,disabledUnit:!0};q.parameters={docs:{description:{story:"Each part of UnitInput can be disabled separately. `disabled` disables only the main text input, `disabledUnit` disables only the unit menu. **Needs review (comes from Reservoir input requirements)**"}}};const z=y.bind({});z.args={disabled:!0,disabledUnit:!0,noConversion:!0};const J=y.bind({});J.args={disabledUnit:!0,unitkey:void 0};const Y=y.bind({});Y.args={disabledUnit:!0,unitkey:"length"};const Z=y.bind({});Z.args={disabledUnit:!1,disabled:!0};const D=t=>{const[a,n]=m.useState("123|m"),[s,i]=m.useState("223|m"),[p,o]=m.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Change initUnit",onClick:()=>o(p==="m"?"ft":"m")}),e.jsx(I,{}),e.jsx(g,{label:"Change value",onClick:()=>n(a==="123|m"?"456|m":"123|m")}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,initUnit:p,onSwitchUnit:o}),e.jsx(I,{}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:s,initUnit:p,onSwitchUnit:o}),e.jsx(jn,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,onSwitchUnit:o}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:s,onSwitchUnit:o})]})};D.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const Q=y.bind({});Q.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const F=()=>{const t="500px",[a,n]=m.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Zt,{children:[e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value infinity",onClick:()=>n(1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity",onClick:()=>n(-1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value null",onClick:()=>n(null)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN",onClick:()=>n(NaN)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - empty string",onClick:()=>n("")})]}),e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value infinity|m",onClick:()=>n("Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity|m",onClick:()=>n("-Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value null|m",onClick:()=>n("null|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined|m",onClick:()=>n("undefined|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN|m",onClick:()=>n("NaN|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)|m",onClick:()=>n("|m")})]})]}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI",children:e.jsx(c,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit"})}),e.jsx(T,{label:"Disabled validation",children:e.jsx(c,{name:"example2",onChange:s=>n(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:t})}),e.jsx(T,{label:"Disabled validation and manual error",children:e.jsx(c,{name:"example3",onChange:s=>n(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(be,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},X=()=>{const t="500px",[a,n]=m.useState("1|m"),[s,i]=m.useState("|m"),p="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Zt,{children:e.jsxs(ye,{width:"25%",children:[e.jsx(g,{label:"Change value to ''",onClick:()=>n("")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1",onClick:()=>n("1")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1|m",onClick:()=>n("1|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to |m - empty value",onClick:()=>n("|m")})]})}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI (placeholder + auto)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:p})}),e.jsx(T,{label:"Normal PUI (only auto)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Empty PUI with autoValue",children:e.jsx(c,{name:"example1",onChange:o=>i(o.target.value),value:s,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Normal PUI (only placeholder)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(T,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(c,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(be,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};F.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const ee=()=>{const[t,a]=m.useState("123|%"),[n,s]=m.useState(null),i="This should be visible when an error appears",p=(o,h)=>(s(h),{name:o,error:h});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(c,{name:"example",onChange:o=>a(o.target.value),error:!n||i,validationCallback:p,value:t}),e.jsx("br",{}),e.jsx(I,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(be,{message:{heading:n,visible:!0}})]})},te=()=>{const[t,a]=m.useState("123|m"),[n,s]=m.useState(""),[i,p]=m.useState("km"),o=()=>{p("ft"),s("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(c,{name:"example",onChange:h=>a(h.target.value),value:t,allowEmpty:!0,placeholder:n,initUnit:i,unitkey:"length"}),e.jsx("br",{}),e.jsx(I,{}),e.jsx(g,{label:"Change value |m and unit ft",onClick:()=>o()})]})},ne=()=>{const[t,a]=m.useState("123|m"),[n,s]=m.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:s}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:s})]})},ae=()=>e.jsxs(e.Fragment,{children:[e.jsx(Yt,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(I,{}),e.jsx(c,{name:"example",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(I,{}),e.jsx(c,{name:"example2",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),P=()=>{const[t,a]=m.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};P.play=async({canvasElement:t,step:a})=>{const n=de(t),s=de(t.ownerDocument.body);await a("Can enter decimal values",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123.123456789"),await d.click(t),await w(n.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"-1.12e3"),await d.click(t),await w(n.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123,456"),await d.click(t),await w(n.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"0.0000000023"),await d.click(t),await w(n.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"999999999999"),await d.click(t),await w(n.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const i=n.getByTestId("testId"),p=n.getByTestId("testId-menu");await d.clear(i),await d.type(i,"456.1"),await d.click(t),await d.click(p),await d.click(s.getByTestId("testId-unit-ft")),await w(n.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await d.clear(i),await d.type(i,"123x45s6"),await d.click(t),await w(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Qt.mouseOver(i),await Xt(()=>{w(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};A.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};D.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
11
11
|
target:
|
|
12
12
|
| T
|
|
13
13
|
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
@@ -16,7 +16,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
16
16
|
| T
|
|
17
17
|
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
18
18
|
}`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
|
|
19
|
-
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:""},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:""},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:""},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:""},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""}}};
|
|
19
|
+
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:""},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:""},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:""},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:""},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""}}};F.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};X.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};ee.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};te.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};ne.__docgenInfo={description:"",methods:[],displayName:"onSwitchUnit"};ae.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};P.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var Fe,Pe,Be;oe.parameters={...oe.parameters,docs:{...(Fe=oe.parameters)==null?void 0:Fe.docs,source:{originalSource:`args => {
|
|
20
20
|
const [_, updateArgs] = useArgs();
|
|
21
21
|
const handleChange = (evt: any) => {
|
|
22
22
|
updateArgs({
|
|
@@ -24,7 +24,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
return <UnitInput {...args} onChange={handleChange} />;
|
|
27
|
-
}`,...(Be=(
|
|
27
|
+
}`,...(Be=(Pe=oe.parameters)==null?void 0:Pe.docs)==null?void 0:Be.source}}};var _e,Me,Oe;W.parameters={...W.parameters,docs:{...(_e=W.parameters)==null?void 0:_e.docs,source:{originalSource:`args => {
|
|
28
28
|
const [_, updateArgs] = useArgs();
|
|
29
29
|
const handleChange = (evt: any) => {
|
|
30
30
|
updateArgs({
|
|
@@ -158,7 +158,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
160
|
return <UnitInput {...args} onChange={handleChange} />;
|
|
161
|
-
}`,...(jt=(kt=Q.parameters)==null?void 0:kt.docs)==null?void 0:jt.source}}};var St,Et,Nt;
|
|
161
|
+
}`,...(jt=(kt=Q.parameters)==null?void 0:kt.docs)==null?void 0:jt.source}}};var St,Et,Nt;F.parameters={...F.parameters,docs:{...(St=F.parameters)==null?void 0:St.docs,source:{originalSource:`() => {
|
|
162
162
|
const width = '500px';
|
|
163
163
|
const [value, setValue] = useState<any>(undefined);
|
|
164
164
|
return <>
|
|
@@ -208,7 +208,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
208
208
|
visible: true
|
|
209
209
|
}} />
|
|
210
210
|
</>;
|
|
211
|
-
}`,...(Nt=(Et=
|
|
211
|
+
}`,...(Nt=(Et=F.parameters)==null?void 0:Et.docs)==null?void 0:Nt.source}}};var At,qt,Dt;X.parameters={...X.parameters,docs:{...(At=X.parameters)==null?void 0:At.docs,source:{originalSource:`() => {
|
|
212
212
|
const width = '500px';
|
|
213
213
|
const [value, setValue] = useState<string>('1|m');
|
|
214
214
|
const [valueB, setValueB] = useState('|m');
|
|
@@ -247,7 +247,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
247
247
|
visible: true
|
|
248
248
|
}} />
|
|
249
249
|
</>;
|
|
250
|
-
}`,...(Dt=(qt=X.parameters)==null?void 0:qt.docs)==null?void 0:Dt.source}}};var Pt,
|
|
250
|
+
}`,...(Dt=(qt=X.parameters)==null?void 0:qt.docs)==null?void 0:Dt.source}}};var Ft,Pt,Bt;ee.parameters={...ee.parameters,docs:{...(Ft=ee.parameters)==null?void 0:Ft.docs,source:{originalSource:`() => {
|
|
251
251
|
const [value, setValue] = useState('123|%');
|
|
252
252
|
const [validation, setValidation] = useState<string | null>(null);
|
|
253
253
|
const predictedMessage = 'This should be visible when an error appears';
|
|
@@ -269,7 +269,7 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
269
269
|
visible: true
|
|
270
270
|
}} />
|
|
271
271
|
</>;
|
|
272
|
-
}`,...(Bt=(
|
|
272
|
+
}`,...(Bt=(Pt=ee.parameters)==null?void 0:Pt.docs)==null?void 0:Bt.source}}};var _t,Mt,Ot;te.parameters={...te.parameters,docs:{...(_t=te.parameters)==null?void 0:_t.docs,source:{originalSource:`() => {
|
|
273
273
|
const [value, setValue] = useState('123|m');
|
|
274
274
|
const [placeholder, setPlaceholder] = useState('');
|
|
275
275
|
const [initUnit, setInitUnit] = useState('km');
|
|
@@ -308,9 +308,9 @@ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJv
|
|
|
308
308
|
force: 'tonneForce'
|
|
309
309
|
}} />
|
|
310
310
|
</>;
|
|
311
|
-
}`,...($t=(Kt=ae.parameters)==null?void 0:Kt.docs)==null?void 0:$t.source}}};var Gt,zt,Jt;
|
|
311
|
+
}`,...($t=(Kt=ae.parameters)==null?void 0:Kt.docs)==null?void 0:$t.source}}};var Gt,zt,Jt;P.parameters={...P.parameters,docs:{...(Gt=P.parameters)==null?void 0:Gt.docs,source:{originalSource:`() => {
|
|
312
312
|
const [value, setValue] = useState('123|m');
|
|
313
313
|
return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
|
|
314
314
|
depth: 'm'
|
|
315
315
|
}} testId="testId" />;
|
|
316
|
-
}`,...(Jt=(zt=
|
|
316
|
+
}`,...(Jt=(zt=P.parameters)==null?void 0:zt.docs)==null?void 0:Jt.source}}};const Ia=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Placeholder","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","OW_10614TestCase","TestUserInput"];export{te as AllowEmptyPUI,X as AutomaticValues,oe as Default,q as Disabled,z as DisabledNoConversion,Y as DisabledUnitWithUnitKey,J as DisabledUnitWithoutUnitKey,Z as DisabledWithEnabledUnitMenu,$ as Error,W as InitUnit,G as InternalValidationError,H as NoConversion,ae as OW_10614TestCase,A as Placeholder,Q as PredefinedOptionsMenu,K as Small,F as TestEdgeCases,D as TestExternalStateChangeWithSynchronizedUnits,P as TestUserInput,ee as ValidationCallback,L as Width,Ia as __namedExportsOrder,xa as default,R as notKnownUnit,ne as onSwitchUnit};
|