@oliasoft-open-source/react-ui-library 4.7.6 → 4.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/404.html +1 -1
  2. package/dist/assets/{index-CbZ_B_tn.js → index-DCeIsyRy.js} +1 -0
  3. package/dist/global.css +576 -576
  4. package/dist/index.html +1 -1
  5. package/dist/index.js +1259 -1165
  6. package/dist/index.js.map +1 -1
  7. package/dist/storybook/assets/Color-KGDBMAHA-B09ajdpG.js +1 -0
  8. package/dist/storybook/assets/DocsRenderer-PKQXORMH-B1FePHEE.js +1 -0
  9. package/dist/storybook/assets/{accordion-6ouB0WTt.js → accordion-BiuI_LCA.js} +1 -1
  10. package/dist/storybook/assets/{accordion.stories-YuQaNHcr.js → accordion.stories-wRr6K6oi.js} +2 -2
  11. package/dist/storybook/assets/{actions-CZK3mphC.js → actions-CHgr8eL8.js} +1 -1
  12. package/dist/storybook/assets/{actions.stories-FOK1cLb3.js → actions.stories-CCDxFKFk.js} +1 -1
  13. package/dist/storybook/assets/{afe.stories-CT81gs6M.js → afe.stories-80-X2oCf.js} +2 -2
  14. package/dist/storybook/assets/{badge.stories-D30jHm96.js → badge.stories-D5DA-vxC.js} +1 -1
  15. package/dist/storybook/assets/{blowout.stories-CJrNKpKP.js → blowout.stories-ES-Fuaqn.js} +1 -1
  16. package/dist/storybook/assets/{button-C1sV-0mR.js → button-VxhoNhrV.js} +1 -1
  17. package/dist/storybook/assets/{button-group-Ai4DXqNr.js → button-group-CwJdFo2z.js} +1 -1
  18. package/dist/storybook/assets/{button-group.stories-incmyYJ-.js → button-group.stories-DU5k5qCY.js} +1 -1
  19. package/dist/storybook/assets/{button.stories-Bcy7mnLs.js → button.stories-DVtec2Eo.js} +2 -2
  20. package/dist/storybook/assets/{buttons-and-links-CtOaPZlv.js → buttons-and-links-DrDYbdOk.js} +2 -2
  21. package/dist/storybook/assets/{card.stories-Bn6LpucB.js → card.stories-CsTB0DuM.js} +1 -1
  22. package/dist/storybook/assets/{casing-loads.stories-DQy8gjj6.js → casing-loads.stories-BXcv0FiI.js} +2 -2
  23. package/dist/storybook/assets/{cell.stories-ChfAWqCt.js → cell.stories-MhANINNu.js} +2 -2
  24. package/dist/storybook/assets/{check-box-CaSrhzev.js → check-box-BtCGePRy.js} +1 -1
  25. package/dist/storybook/assets/{check-box.stories-BAH78tMZ.js → check-box.stories-C_7Z7Ss6.js} +1 -1
  26. package/dist/storybook/assets/{chunk-HLWAVYOI-CkQdzq8g.js → chunk-HLWAVYOI-3IbBqp3W.js} +1 -1
  27. package/dist/storybook/assets/color-DqVXeBjc.js +25 -0
  28. package/dist/storybook/assets/{column.stories-JMvj3_fr.js → column.stories-BxfR9Tla.js} +1 -1
  29. package/dist/storybook/assets/{dialog-vClt2ahZ.js → dialog-Di8hNunM.js} +1 -1
  30. package/dist/storybook/assets/{drawer-DSS8yvvp.js → drawer-BhuWxI7V.js} +1 -1
  31. package/dist/storybook/assets/drawer.stories-B-PsNJJ6.js +113 -0
  32. package/dist/storybook/assets/{empty.stories-G8jeIfLL.js → empty.stories-BVYXwvpa.js} +1 -1
  33. package/dist/storybook/assets/{field-C5_fLDpy.js → field-HrLaMLbx.js} +1 -1
  34. package/dist/storybook/assets/{field.stories-D5Mej0Bt.js → field.stories-B9p9nBgY.js} +1 -1
  35. package/dist/storybook/assets/{file-button.stories-DePr8MKB.js → file-button.stories-FOaiNPt-.js} +1 -1
  36. package/dist/storybook/assets/{file-input-BZecnRBy.js → file-input-BpMtsZ2S.js} +1 -1
  37. package/dist/storybook/assets/{file-input.stories-Br89AkVv.js → file-input.stories-Jrdw5k-s.js} +1 -1
  38. package/dist/storybook/assets/{flex.stories-sSdg0ChR.js → flex.stories-BEXf0VqI.js} +1 -1
  39. package/dist/storybook/assets/footer.stories-CGHFDUfT.js +3 -0
  40. package/dist/storybook/assets/form.stories-C1Qx3M_1.js +49 -0
  41. package/dist/storybook/assets/formation.stories-BEowxQZ-.js +74 -0
  42. package/dist/storybook/assets/{heading-NkLgQYoP.js → heading-CRNoBc7q.js} +1 -1
  43. package/dist/storybook/assets/{heading.stories-nI_cFnAN.js → heading.stories-DahFxeiX.js} +1 -1
  44. package/dist/storybook/assets/{help-icon-41R-Z9N1.js → help-icon-Buhx5nl6.js} +1 -1
  45. package/dist/storybook/assets/{help-icon.stories-DBYh0YX7.js → help-icon.stories-DbmZ1fgP.js} +1 -1
  46. package/dist/storybook/assets/icon-BSFY3vDO.js +8 -0
  47. package/dist/storybook/assets/{icon.stories-B-tKaIKA.js → icon.stories-C1hZXIMX.js} +1 -1
  48. package/dist/storybook/assets/iframe-0oHxQxyh.js +2 -0
  49. package/dist/storybook/assets/{index-Be0hXiyp.js → index-DMAnyMX5.js} +1 -1
  50. package/dist/storybook/assets/{index-Cf2IDQZ4.js → index-Dx_aqqZM.js} +8 -8
  51. package/dist/storybook/assets/index-iPmJVpyV.js +1 -0
  52. package/dist/storybook/assets/{index.es-D2piFfFj.js → index.es-DazXb-ul.js} +4 -4
  53. package/dist/storybook/assets/inheritsLoose-DP0QEDDI.js +1 -0
  54. package/dist/storybook/assets/{input-group.stories-BmeUtBOK.js → input-group.stories-44quIZTV.js} +2 -2
  55. package/dist/storybook/assets/{input-validation-U3o9_8IY.js → input-validation-CregAhZZ.js} +2 -2
  56. package/dist/storybook/assets/{inputs-gP7hGRtM.js → inputs-DZn0C_9Y.js} +2 -2
  57. package/dist/storybook/assets/{label-hiSz3I8H.js → label-CqmyC9he.js} +1 -1
  58. package/dist/storybook/assets/{label.stories-Cyv5jBAO.js → label.stories-C0AO5F1a.js} +1 -1
  59. package/dist/storybook/assets/layout-forms-zjNDNCOQ.js +16 -0
  60. package/dist/storybook/assets/{layout-general-Bw291PmI.js → layout-general-_85zGG_p.js} +2 -2
  61. package/dist/storybook/assets/{list-DYNKqvUR.js → list-yVTOdmpX.js} +1 -1
  62. package/dist/storybook/assets/{list.stories-BX67BegD.js → list.stories-ChqQXY5M.js} +2 -2
  63. package/dist/storybook/assets/{list.stories-data-D_ZfzaxE.js → list.stories-data-Iq66w9oH.js} +1 -1
  64. package/dist/storybook/assets/{loader.stories-DjrwwZ15.js → loader.stories-DM7ZJBgz.js} +1 -1
  65. package/dist/storybook/assets/{menu.stories-QTzp0Z7C.js → menu.stories-mt3LwVCk.js} +2 -2
  66. package/dist/storybook/assets/{message-B7G1ESkC.js → message-BYzRg8Ae.js} +1 -1
  67. package/dist/storybook/assets/{message.stories-Czui5Ym7.js → message.stories-K3bQ-5bJ.js} +1 -1
  68. package/dist/storybook/assets/{meta-content-BE7pulye.js → meta-content-cbHGvPJ7.js} +1 -1
  69. package/dist/storybook/assets/{modal.stories-DAxDpo0A.js → modal.stories-Cct1SMOP.js} +2 -2
  70. package/dist/storybook/assets/number-input.stories-C2QTTzzN.js +110 -0
  71. package/dist/storybook/assets/{option-dropdown.stories-ByLG631x.js → option-dropdown.stories-CoLsSS95.js} +1 -1
  72. package/dist/storybook/assets/{padding-and-spacing-DLeCWmND.js → padding-and-spacing-CPgb4ZMT.js} +2 -2
  73. package/dist/storybook/assets/{page.stories-br9ia4zp.js → page.stories-Cse3cMsO.js} +1 -1
  74. package/dist/storybook/assets/{pagination-BtguPxeR.js → pagination-iSMIbR33.js} +1 -1
  75. package/dist/storybook/assets/{pagination.stories-CgG4wp8P.js → pagination.stories-BUPaZD5R.js} +2 -2
  76. package/dist/storybook/assets/{pop-confirm.stories-CZpYmUBz.js → pop-confirm.stories-Dhid1FK8.js} +1 -1
  77. package/dist/storybook/assets/{popover-DgUpTRMk.js → popover-CzZdWNnB.js} +1 -1
  78. package/dist/storybook/assets/popover.stories-Duemqiqp.js +10 -0
  79. package/dist/storybook/assets/{preview-Dml2wSQG.js → preview-Bay6IiqP.js} +2 -2
  80. package/dist/storybook/assets/preview-DrVrew0c.js +2 -0
  81. package/dist/storybook/assets/projects.stories-DU-QlBa6.js +47 -0
  82. package/dist/storybook/assets/{radio-button-C_cV5TWA.js → radio-button-YBwYcMaM.js} +1 -1
  83. package/dist/storybook/assets/{radio-button.stories-BNE-U9db.js → radio-button.stories-CGJnfCk-.js} +1 -1
  84. package/dist/storybook/assets/react-router-dom-Ck2Y_Fzc.js +8 -0
  85. package/dist/storybook/assets/{reservoirs.stories-ux3hZbkX.js → reservoirs.stories-aSZ9r1Pu.js} +2 -2
  86. package/dist/storybook/assets/{rich-text-input.stories-savcIJ5B.js → rich-text-input.stories-CsFyrKRA.js} +3 -3
  87. package/dist/storybook/assets/{row.stories-CG6Eipay.js → row.stories-DL2h5FzP.js} +2 -2
  88. package/dist/storybook/assets/{select-Z-GCZ-pY.js → select-C8iu4-uz.js} +2 -2
  89. package/dist/storybook/assets/{select.stories-CX_B6BvR.js → select.stories-BZFdXGPs.js} +2 -2
  90. package/dist/storybook/assets/{side-bar-ChOjPNLR.js → side-bar-CKbHPgIV.js} +1 -1
  91. package/dist/storybook/assets/{side-bar.stories-BupidZk5.js → side-bar.stories-MUj_dj1F.js} +1 -1
  92. package/dist/storybook/assets/{site.stories-C1GnbK5P.js → site.stories-Ci4g5W2A.js} +2 -2
  93. package/dist/storybook/assets/{slider-gZmYlxxz.js → slider-DAramr8j.js} +4 -4
  94. package/dist/storybook/assets/{slider.stories-CY4GxD4Y.js → slider.stories-Cd0rLfHP.js} +2 -2
  95. package/dist/storybook/assets/{smart-upload-modal.stories-BrsVuS4a.js → smart-upload-modal.stories-BmrhOtOG.js} +1 -1
  96. package/dist/storybook/assets/{spacer.stories-D7Q45uBk.js → spacer.stories-CHEZdgDM.js} +1 -1
  97. package/dist/storybook/assets/{table-CaaSoHex.js → table-BNMxYhsu.js} +1 -1
  98. package/dist/storybook/assets/{table.stories-BiBivAvh.js → table.stories-YV04PKkU.js} +2 -2
  99. package/dist/storybook/assets/{table.stories-data-DwfKQW7P.js → table.stories-data-CR9VpXHs.js} +1 -1
  100. package/dist/storybook/assets/text-link.stories-BQAkVO-W.js +14 -0
  101. package/dist/storybook/assets/{title.stories-CfdJbgvT.js → title.stories-CuiMnOil.js} +2 -2
  102. package/dist/storybook/assets/{toaster-DJeREs3e.js → toaster-BNO0suPv.js} +1 -1
  103. package/dist/storybook/assets/{toaster.stories-QjvljKdT.js → toaster.stories-zcWIPp_X.js} +1 -1
  104. package/dist/storybook/assets/{toggle-Bo-JPbUP.js → toggle-CBpNgTrm.js} +1 -1
  105. package/dist/storybook/assets/{toggle.stories-BYrikgrA.js → toggle.stories-mjk0JIle.js} +1 -1
  106. package/dist/storybook/assets/{tooltip.test-case.stories-C74mKGrI.js → tooltip.test-case.stories-i9YQqba1.js} +1 -1
  107. package/dist/storybook/assets/{top-bar-DG4ok0uF.js → top-bar-C_tn2Pc5.js} +1 -1
  108. package/dist/storybook/assets/top-bar.stories-B2a-RgK-.js +21 -0
  109. package/dist/storybook/assets/{top-bar.testcase.stories-DzsYUZIx.js → top-bar.testcase.stories-DoPEAMYc.js} +1 -1
  110. package/dist/storybook/assets/{tree.stories-RtuZpYXn.js → tree.stories-6UHASEZu.js} +1 -1
  111. package/dist/storybook/assets/unit-input.stories-B3VwXCO8.js +295 -0
  112. package/dist/storybook/assets/unit-table.stories-DQrTQd6a.js +152 -0
  113. package/dist/storybook/iframe.html +1 -1
  114. package/dist/storybook/index.json +1 -1
  115. package/dist/storybook/project.json +1 -1
  116. package/package.json +1 -1
  117. package/dist/storybook/assets/Color-KGDBMAHA-C0EpwEFf.js +0 -1
  118. package/dist/storybook/assets/DocsRenderer-PKQXORMH-CWe5JIRI.js +0 -1
  119. package/dist/storybook/assets/color-eaylxLAo.js +0 -25
  120. package/dist/storybook/assets/drawer.stories-D6FBs1_r.js +0 -113
  121. package/dist/storybook/assets/extends-CF3RwP-h.js +0 -1
  122. package/dist/storybook/assets/footer.stories-BM5UBN62.js +0 -3
  123. package/dist/storybook/assets/form.stories-CYcggA-f.js +0 -49
  124. package/dist/storybook/assets/formation.stories-NDB_Sbor.js +0 -74
  125. package/dist/storybook/assets/icon-BP4BO6-k.js +0 -8
  126. package/dist/storybook/assets/iframe-WLuE3PcW.js +0 -2
  127. package/dist/storybook/assets/index-CXmS_Aty.js +0 -1
  128. package/dist/storybook/assets/inheritsLoose-DR8r8Ogv.js +0 -1
  129. package/dist/storybook/assets/layout-forms-r2wYyx-8.js +0 -16
  130. package/dist/storybook/assets/number-input.stories-CFTNLnHw.js +0 -105
  131. package/dist/storybook/assets/popover.stories-CtaFGXR_.js +0 -10
  132. package/dist/storybook/assets/preview-BjyexbB3.js +0 -2
  133. package/dist/storybook/assets/projects.stories-BSAMs8RG.js +0 -47
  134. package/dist/storybook/assets/react-router-dom-CMITYWBH.js +0 -8
  135. package/dist/storybook/assets/text-link.stories-BsuVBOWo.js +0 -14
  136. package/dist/storybook/assets/top-bar.stories-BI4a_ekv.js +0 -21
  137. package/dist/storybook/assets/unit-input.stories-BSWm9641.js +0 -290
  138. package/dist/storybook/assets/unit-table.stories-CgF-UOP3.js +0 -150
@@ -1,14 +0,0 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{H as E,L as i,S as j,R as c}from"./react-router-dom-CMITYWBH.js";import{F as y}from"./flex-EllkLxgO.js";import{T as S}from"./text-B3-TSWok.js";import"./index-DhsZuJvc.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./extends-CF3RwP-h.js";import"./tiny-invariant-DqLgxztJ.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-Bk2sglWO.js";const s=({children:a,href:o=void 0,target:T=void 0,testId:R,onClick:L,component:v="a"})=>e.jsx(v,{href:o,to:o,target:T,onClick:L,"data-testid":R,children:e.jsx(S,{link:!0,children:a})});s.__docgenInfo={description:"",methods:[],displayName:"TextLink",props:{href:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"undefined",computed:!0}},target:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"undefined",computed:!0}},testId:{required:!1,tsType:{name:"string"},description:""},onClick:{required:!1,tsType:{name:"signature",type:"function",raw:"(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLAnchorElement, MouseEvent>",elements:[{name:"HTMLAnchorElement"},{name:"MouseEvent"}]},name:"e"}],return:{name:"void"}}},description:""},children:{required:!1,tsType:{name:"ReactReactNode",raw:"React.ReactNode"},description:""},component:{required:!1,tsType:{name:"ReactElementType",raw:"React.ElementType"},description:"",defaultValue:{value:"'a'",computed:!1}}}};const I={title:"Basic/TextLink",component:s,args:{children:"Link text goes here",href:"http://oliasoft.com"}},k=a=>e.jsx(s,{...a}),n=k.bind({}),t=k.bind({});t.args={href:void 0,onClick:()=>console.log("Clicked!")};const r=()=>e.jsxs(E,{children:[e.jsxs(y,{gap:!0,children:[e.jsx(s,{component:i,href:"/dashboard",children:"Dashboard"}),e.jsx(s,{component:i,href:"/settings",children:"Settings"})]}),e.jsxs(j,{children:[e.jsx(c,{path:"/dashboard",children:"Dashboard"}),e.jsx(c,{path:"/settings",children:"Settings"})]})]});r.__docgenInfo={description:"",methods:[],displayName:"AsRouterLink"};var d,p,m;n.parameters={...n.parameters,docs:{...(d=n.parameters)==null?void 0:d.docs,source:{originalSource:"args => <TextLink {...args} />",...(m=(p=n.parameters)==null?void 0:p.docs)==null?void 0:m.source}}};var u,l,h;t.parameters={...t.parameters,docs:{...(u=t.parameters)==null?void 0:u.docs,source:{originalSource:"args => <TextLink {...args} />",...(h=(l=t.parameters)==null?void 0:l.docs)==null?void 0:h.source}}};var g,f,x;r.parameters={...r.parameters,docs:{...(g=r.parameters)==null?void 0:g.docs,source:{originalSource:`() => <HashRouter>
2
- <Flex gap>
3
- <TextLink component={Link} href="/dashboard">
4
- Dashboard
5
- </TextLink>
6
- <TextLink component={Link} href="/settings">
7
- Settings
8
- </TextLink>
9
- </Flex>
10
- <Switch>
11
- <Route path="/dashboard">Dashboard</Route>
12
- <Route path="/settings">Settings</Route>
13
- </Switch>
14
- </HashRouter>`,...(x=(f=r.parameters)==null?void 0:f.docs)==null?void 0:x.source}}};const O=["Default","OnClick","AsRouterLink"];export{r as AsRouterLink,n as Default,t as OnClick,O as __namedExportsOrder,I as default};
@@ -1,21 +0,0 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{H as I,L as c,S as D,R as l}from"./react-router-dom-CMITYWBH.js";import{I as O,T as A}from"./common-types-Sih75Sav.js";import{T as p}from"./top-bar-DG4ok0uF.js";import{P as w}from"./page-7SSpdYhb.js";import{M as N}from"./actions-CZK3mphC.js";import{B as m}from"./button-C1sV-0mR.js";import{B as P}from"./badge-CLQ59MDF.js";import{L as v}from"./logo-BVP9045W.js";import{s as H}from"./icon-custom-Xcl4YkWP.js";import{M as s}from"./types-BmbYqTX_.js";import"./index-DhsZuJvc.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./extends-CF3RwP-h.js";import"./tiny-invariant-DqLgxztJ.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-Bk2sglWO.js";import"./icon-BP4BO6-k.js";import"./disabled-context-rmpd7YJS.js";import"./lodash-BHd_uQHh.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./types-UmZ4Y_CR.js";import"./spinner-AWUe4xwQ.js";const M=[{type:"Link",label:"Link",onClick:()=>{}},{type:"Link",label:"Active",active:!0,onClick:()=>{}},{type:"Link",label:"Disabled",disabled:!0,onClick:()=>{}},{type:"Menu",label:"Dropdown",onClick:()=>{},sections:[{type:"Option",label:"Alpacas",onClick:()=>{}},{type:"Option",label:"Llamas",onClick:()=>{}}]},{type:"Button",label:"Save",colored:!0,onClick:()=>{},testId:"top-bar-button-save"}],E=[{type:"Component",component:e.jsx(P,{title:"3",small:!0,margin:"5px",children:e.jsx(m,{icon:O.NOTIFICATION,round:!0,onClick:()=>{}})})},{type:"Component",component:e.jsx(N,{menu:{trigger:A.COMPONENT,fullHeightTrigger:!0,placement:"bottom-end",component:e.jsx(m,{label:"TU",round:!0,onClick:()=>{}}),sections:[{type:s.HEADING,label:"Test User"},{type:s.OPTION,label:"Profile",icon:"user",onClick:()=>{}},{type:s.DIVIDER},{type:s.OPTION,label:"Sign out",icon:"lock",onClick:()=>{}}]}})}],le={title:"Navigation/TopBar",component:p,parameters:{layout:"fullscreen",docs:{story:{inline:!1,iframeHeight:400}}},argTypes:{height:{control:"text"}},args:{title:{logo:e.jsx("img",{src:v,alt:"logo"}),onClick:()=>{}},content:M,contentRight:E}},i=j=>e.jsx(p,{...j}),n=i.bind({}),t=i.bind({});t.args={warning:"Application update available. Please refresh your browser."};const r=i.bind({});r.args={title:{label:"Text Branding",onClick:()=>{}}};const o=i.bind({});o.args={appSwitcher:{icon:H,onClick:()=>{}}};const a=()=>e.jsx(I,{children:e.jsxs(w,{left:0,children:[e.jsx(p,{content:[{type:"Link",label:"Dashboard",component:c,url:"/dashboard"},{type:"Link",label:"Settings",component:c,url:"/settings"}]}),e.jsxs(D,{children:[e.jsx(l,{path:"/dashboard",children:"Dashboard"}),e.jsx(l,{path:"/settings",children:"Settings"})]})]})});a.__docgenInfo={description:"",methods:[],displayName:"AsRouterLink"};var d,u,g;n.parameters={...n.parameters,docs:{...(d=n.parameters)==null?void 0:d.docs,source:{originalSource:"args => <TopBar {...args} />",...(g=(u=n.parameters)==null?void 0:u.docs)==null?void 0:g.source}}};var h,b,k;t.parameters={...t.parameters,docs:{...(h=t.parameters)==null?void 0:h.docs,source:{originalSource:"args => <TopBar {...args} />",...(k=(b=t.parameters)==null?void 0:b.docs)==null?void 0:k.source}}};var T,y,f;r.parameters={...r.parameters,docs:{...(T=r.parameters)==null?void 0:T.docs,source:{originalSource:"args => <TopBar {...args} />",...(f=(y=r.parameters)==null?void 0:y.docs)==null?void 0:f.source}}};var x,S,C;o.parameters={...o.parameters,docs:{...(x=o.parameters)==null?void 0:x.docs,source:{originalSource:"args => <TopBar {...args} />",...(C=(S=o.parameters)==null?void 0:S.docs)==null?void 0:C.source}}};var L,B,R;a.parameters={...a.parameters,docs:{...(L=a.parameters)==null?void 0:L.docs,source:{originalSource:`() => {
2
- return <HashRouter>
3
- <Page left={0}>
4
- <TopBar content={[{
5
- type: 'Link',
6
- label: 'Dashboard',
7
- component: Link,
8
- url: '/dashboard'
9
- }, {
10
- type: 'Link',
11
- label: 'Settings',
12
- component: Link,
13
- url: '/settings'
14
- }]} />
15
- <Switch>
16
- <Route path="/dashboard">Dashboard</Route>
17
- <Route path="/settings">Settings</Route>
18
- </Switch>
19
- </Page>
20
- </HashRouter>;
21
- }`,...(R=(B=a.parameters)==null?void 0:B.docs)==null?void 0:R.source}}};const me=["Default","WithWarning","TextBranding","AppSwitcher","AsRouterLink"];export{o as AppSwitcher,a as AsRouterLink,n as Default,r as TextBranding,t as WithWarning,me as __namedExportsOrder,le as default};
@@ -1,290 +0,0 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJvc.js";import{d as r,r as ct}from"./index-CWz-hU-f.js";import{c as mt}from"./index-Bk2sglWO.js";import{u as pt}from"./use-previous-D775JrO6.js";import{M as Te}from"./actions-CZK3mphC.js";import{I as gt}from"./input-group-addon-D68iUKV2.js";import{B as c}from"./button-C1sV-0mR.js";import{T as ht}from"./tooltip-1V7clEnw.js";import{I as vt}from"./input-group-BaRSJAEN.js";import{S as V}from"./spacer-BWoNR27H.js";import{T as Ln}from"./text-B3-TSWok.js";import{I as ft}from"./input-BW9trNAW.js";import{M as Se}from"./types-BmbYqTX_.js";import{l as T}from"./lodash-BHd_uQHh.js";import{D as yt}from"./divider-DY9nJ_7N.js";import{R as Kn,C as ge}from"./row-4iAGREkV.js";import{F as w}from"./field-C5_fLDpy.js";import{M as he}from"./message-B7G1ESkC.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-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./styled-components.browser.esm-Bf0q9Yjk.js";import"./label-hiSz3I8H.js";import"./help-icon-41R-Z9N1.js";const Ct=()=>{const n=m.useRef(null);return m.useLayoutEffect(()=>{n.current&&(n.current(),n.current=null)}),t=>{n.current=t}},bt=(n,a)=>{const t=a==null?void 0:a[n];return t||(console.log(`Warning: 'unitTemplate' does not define a preferred unit for '${n}'. Defaulting to standard unit.`),r.unitFromQuantity(n)??"")};var C=(n=>(n.CUSTOM="custom",n.PREDEFINED="predefined",n))(C||{});const $n=n=>n==="undefined"||n===void 0||n===""||n==="null"||n===null||n==="NaN"||isNaN(n),zn=(n="",a,t="",l=!1)=>{if(l)return n;if(a&&!$n(n))try{const o=r.isValueWithUnit(n)?n:r.withUnit(n,t),d=r.convertSamePrecision(o,a);return r.getValue(d)}catch{}return n},Ut=n=>n?!!r.getUnit(n):!1,_=(n="",a,t,l)=>{if(l)return n;const o=Ut(n)||r.isValueWithUnit(n),d=r.getValue(n);return $n(d)?d:o?zn(d,a,t,l):n},Ne=n=>T.isObject(n)&&!T.isArray(n)&&!T.isFunction(n)?T.get(n,"fieldName",""):typeof n=="string"?n:"",xt=n=>T.isObjectLike(n)&&T.has(n,"message"),It=n=>typeof n=="string"?n:xt(n)?n.message:null;var wt=ct();const Vt=n=>n.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g))===0,Ae=(n,a)=>{var j;const{allowEmpty:t=!1,autoValue:l,placeholder:o,disabledValidation:d=!1}=a||{},i=String(n);if(d||l||o)return null;const g=wt.isValueWithUnit(i)?r.getValue(i):i;if(t&&g==="")return null;if(Vt(g))return"Invalid number format due to leading zeroes";const h=r.validateNumber(g);if(!h.valid){const ie=((j=h==null?void 0:h.errors)==null?void 0:j[0])??null;return It(ie)}return null},qe=(n="")=>{var a;return(a=r.KNOWN_UNITS)==null?void 0:a.includes(n)},jt=(n,a)=>{const t=r.getUnit(n||"");return qe(a)&&qe(t)},Et="_predefinedMenuActive_1yvt4_1",kt={predefinedMenuActive:Et},p=({name:n,placeholder:a="",disabled:t=!1,disabledUnit:l=!1,error:o=null,left:d=!1,small:i=!1,width:g="100%",value:h,unitkey:j="",initUnit:ie,noConversion:Gn=!1,onChange:le=()=>{},onClick:St=()=>{},onFocus:Jn=()=>{},onSwitchUnit:ve=()=>{},unitTemplate:fe,doNotConvertValue:q=!1,testId:k,warning:Yn=null,predefinedOptions:x,initialPredefinedOption:Zn=!1,shouldLinkAutomaticly:ye=!0,selectedPredefinedOptionKey:Ce,validationCallback:be=()=>({name:"",error:null}),disabledValidation:Ue=!1,allowEmpty:xe=!1,autoValue:I})=>{typeof h=="number"&&(h=`${h}`);const Qn=Ct(),[ue="",P=""]=h!==void 0?r.split(h):[],Ie=I?r.getUnit(I):"",we=m.useMemo(()=>bt(j,fe),[j,fe]),Xn=jt(h,we),U=ie||we||P,et=pt(U),Ve=_(h,U,P,q),je=_(I,U,Ie,q),nt=Ve!==""?{value:Ve,unit:U}:je!==""?{value:je,unit:U}:{value:ue,unit:P},[v,ne]=m.useState(nt),[tt,oe]=m.useState(null),[E,de]=m.useState(Zn?C.PREDEFINED:C.CUSTOM),ce=ue===""&&I,M=x&&x.find(s=>{if(!(s!=null&&s.value))return;if(Ce)return Ce===s.valueKey;const u=r.isValueWithUnit(s.value)?r.getUnit(s.value):"";return r.withUnit(zn(h,u),u)===s.value}),at=()=>{if(j)try{const s=ce?I:h??"";let u=r.altUnitsList(s,j);return r.getValue(s)===""?u.map(f=>["",f[1]]):u}catch{return null}},rt=s=>{const u=Ne(n),f=s.target,{value:b,selectionStart:D}=f,ke=r.cleanNumStr(b.replaceAll(" ","").replaceAll("|","")),me=r.withUnit(ke,(v==null?void 0:v.unit)||""),ut=r.getValue(me),pe=Ae(ut,{allowEmpty:xe,autoValue:I,placeholder:a,disabledValidation:Ue});if(pe===null){le({target:{value:me,name:u}});const[ot,dt]=r.split(me);ne({value:ot,unit:dt}),oe(null),be(u,null)}else ne({value:ke,unit:v.unit}),oe(pe),be(u,pe);Qn(()=>{f.selectionStart=D,f.selectionEnd=D})},st=(s,u)=>{u===v.unit||isNaN(Number(s))||(ne({value:s,unit:u}),ve&&ve(u))};m.useEffect(()=>{if(U){let f,b="";et!==U?(f=_(h,U,P,q),b=U):r.withUnit(v.value,v.unit)!==h&&(f=_(h,v.unit,P,q),b=v.unit),f!==void 0&&ne({value:f,unit:b}),x&&de(M&&ye?C.PREDEFINED:C.CUSTOM)}const s=r.checkAndCleanDecimalComma(ue),u=Ae(s,{allowEmpty:xe,autoValue:I,placeholder:a,disabledValidation:Ue});oe(u)},[U,h,o,ye]);const te=at(),ae=r.label(v.unit)||v.unit||"",it=Gn||!te||te&&te.length===1,Ee=Ne(n);let re;const lt=s=>{const u=s!=null&&s.value?s.value:"",[f="",b=""]=r.isValueWithUnit(u)?r.split(u):[u];return{type:Se.OPTION,inline:!0,onClick:()=>{r.validateNumber(f).valid&&!t&&(de(C.PREDEFINED),le({target:{value:u,name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||"",predefinedSelected:!0,predefinedOption:s}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(Ln,{children:s.label}),e.jsx(V,{width:"20px",height:"0"})]}),description:r.isValueWithUnit(u)?`${f} ${b}`:u,selected:M===s&&E===C.PREDEFINED}};if(re=[{type:Se.OPTION,inline:!0,onClick:()=>{E!==C.CUSTOM&&!t&&le({target:{value:r.withUnit(v.value,v.unit),name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||""}})},label:"Custom",selected:E===C.CUSTOM}],x!=null&&x.length){const s=x.map(lt);re=[...re,...s]}return e.jsx("div",{className:E===C.PREDEFINED?mt(kt.predefinedMenuActive):"",children:e.jsxs(vt,{small:i,width:g,children:[x&&e.jsx(ht,{text:E===C.PREDEFINED?M==null?void 0:M.label:"",children:e.jsx(Te,{maxHeight:380,groupOrder:"first",testId:k&&`${k}-predefined-menu`,disabled:t,menu:{colored:!0,trigger:"Component",component:e.jsx(c,{groupOrder:"first",active:E===C.PREDEFINED,icon:E===C.PREDEFINED?"link":"unlink"}),small:i,sections:re}})}),e.jsx(ft,{type:"text",name:Ee,testId:k,disabled:t,placeholder:ce?_(I,v.unit,Ie,q):a,value:v.value,onChange:rt,onFocus:Jn,error:o||tt,warning:Yn,right:!d},Ee),ae&&(it||!Xn?e.jsx(gt,{groupOrder:"last",children:ae}):e.jsx(Te,{maxHeight:380,groupOrder:"last",disabled:l,testId:k&&`${k}-menu`,menu:{label:ae,trigger:"DropDownButton",small:i,sections:te.map(([s,u,f])=>{const b=f||u||"";return{type:"Option",label:isNaN(Number(s))?"":s,inline:!0,onClick:D=>{D.stopPropagation(),st(ce?"":s,u)},description:b,selected:b===ae,testId:`${k}-unit-${b}`}})}}))]})})};p.__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:`(
2
- name: string,
3
- message: string | null,
4
- ) => { name: string; error: string | null }`,signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"message"}],return:{name:"signature",type:"object",raw:"{ name: string; error: string | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"error",value:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}],required:!0}}]}}}},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: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"ChangeEvent<HTMLInputElement> | ICustomChangeEvent",elements:[{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},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:"() => {}",computed:!1}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"() => {}",computed:!1}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"() => {}",computed:!1}},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""}}};const{useArgs:Tt}=__STORYBOOK_MODULE_PREVIEW_API__,da={title:"Basic/UnitInput",component:p,args:{name:"example",unitkey:"length",value:"123|m"}},y=n=>{const[a,t]=Tt(),l=o=>{t({value:o.target.value})};return e.jsx(p,{...n,onChange:l})},se=y.bind({}),F=y.bind({});F.args={initUnit:"ft",unitTemplate:{length:"ft"}};const O=y.bind({});O.args={value:'123|"',unitkey:'"'};const W=y.bind({});W.args={width:"180px"};const B=y.bind({});B.args={noConversion:!0};const R=y.bind({});R.args={small:!0};const H=y.bind({});H.args={error:"Error message goes here"};const L=y.bind({});L.args={value:"asas123asd|%"};const S=y.bind({});S.args={disabled:!0,disabledUnit:!0};S.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 K=y.bind({});K.args={disabled:!0,disabledUnit:!0,noConversion:!0};const $=y.bind({});$.args={disabledUnit:!0,unitkey:void 0};const z=y.bind({});z.args={disabledUnit:!0,unitkey:"length"};const G=y.bind({});G.args={disabledUnit:!1,disabled:!0};const N=n=>{const[a,t]=m.useState("123|m"),[l,o]=m.useState("223|m"),[d,i]=m.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(c,{label:"Change initUnit",onClick:()=>i(d==="m"?"ft":"m")}),e.jsx(V,{}),e.jsx(c,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(V,{}),e.jsx(p,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,initUnit:d,onSwitchUnit:i}),e.jsx(V,{}),e.jsx(p,{name:"example2",onChange:g=>{o(g.target.value)},unitkey:"length",value:l,initUnit:d,onSwitchUnit:i}),e.jsx(yt,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(p,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,onSwitchUnit:i}),e.jsx(p,{name:"example2",onChange:g=>{o(g.target.value)},unitkey:"length",value:l,onSwitchUnit:i})]})};N.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const J=y.bind({});J.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const A=()=>{const n="500px",[a,t]=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(Kn,{children:[e.jsxs(ge,{width:"25%",children:[e.jsx(c,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(ge,{width:"25%",children:[e.jsx(c,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(w,{label:"Normal PUI",children:e.jsx(p,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit"})}),e.jsx(w,{label:"Disabled validation",children:e.jsx(p,{name:"example2",onChange:l=>t(l.target.value),value:a,unitkey:"length",disabledValidation:!0,width:n})}),e.jsx(w,{label:"Disabled validation and manual error",children:e.jsx(p,{name:"example3",onChange:l=>t(l.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:n})}),e.jsx(he,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},Y=()=>{const n="500px",[a,t]=m.useState("1|m"),[l,o]=m.useState("|m"),d="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Kn,{children:e.jsxs(ge,{width:"25%",children:[e.jsx(c,{label:"Change value to ''",onClick:()=>t("")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1",onClick:()=>t("1")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1|m",onClick:()=>t("1|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to |m - empty value",onClick:()=>t("|m")})]})}),e.jsx("br",{}),e.jsx(w,{label:"Normal PUI (placeholder + auto)",children:e.jsx(p,{name:"example1",onChange:i=>t(i.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit",autoValue:d})}),e.jsx(w,{label:"Normal PUI (only auto)",children:e.jsx(p,{name:"example1",onChange:i=>t(i.target.value),value:a,unitkey:"length",width:n,autoValue:d})}),e.jsx(w,{label:"Empty PUI with autoValue",children:e.jsx(p,{name:"example1",onChange:i=>o(i.target.value),value:l,unitkey:"length",width:n,autoValue:d})}),e.jsx(w,{label:"Normal PUI (only placeholder)",children:e.jsx(p,{name:"example1",onChange:i=>t(i.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test"})}),e.jsx(w,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(p,{name:"example1",onChange:i=>t(i.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(he,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};A.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const Z=()=>{const[n,a]=m.useState("123|%"),[t,l]=m.useState(null),o="This should be visible when an error appears",d=(i,g)=>(l(g),{name:i,error:g});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(p,{name:"example",onChange:i=>a(i.target.value),error:!t||o,validationCallback:d,value:n}),e.jsx("br",{}),e.jsx(V,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(he,{message:{heading:t,visible:!0}})]})},Q=()=>{const[n,a]=m.useState("123|m"),[t,l]=m.useState(""),[o,d]=m.useState("km"),i=()=>{d("ft"),l("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(p,{name:"example",onChange:g=>a(g.target.value),value:n,allowEmpty:!0,placeholder:t,initUnit:o,unitkey:"length"}),e.jsx("br",{}),e.jsx(V,{}),e.jsx(c,{label:"Change value |m and unit ft",onClick:()=>i()})]})},X=()=>{const[n,a]=m.useState("123|m"),[t,l]=m.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(p,{name:"example",onChange:o=>a(o.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:l}),e.jsx(V,{}),e.jsx(p,{name:"example",onChange:o=>a(o.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:l})]})},ee=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ln,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(V,{}),e.jsx(p,{name:"example",onChange:()=>{},value:r.withUnit(r.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}})]});N.__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:`(
5
- name: string,
6
- message: string | null,
7
- ) => { name: string; error: string | null }`,signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"message"}],return:{name:"signature",type:"object",raw:"{ name: string; error: string | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"error",value:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}],required:!0}}]}}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(event: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"ChangeEvent<HTMLInputElement> | ICustomChangeEvent",elements:[{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},{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:""}}};A.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};Y.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};Z.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};Q.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};X.__docgenInfo={description:"",methods:[],displayName:"onSwitchUnit"};ee.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};var Pe,Me,De;se.parameters={...se.parameters,docs:{...(Pe=se.parameters)==null?void 0:Pe.docs,source:{originalSource:`args => {
8
- const [_, updateArgs] = useArgs();
9
- const handleChange = (evt: any) => {
10
- updateArgs({
11
- value: evt.target.value
12
- });
13
- };
14
- return <UnitInput {...args} onChange={handleChange} />;
15
- }`,...(De=(Me=se.parameters)==null?void 0:Me.docs)==null?void 0:De.source}}};var _e,Fe,Oe;F.parameters={...F.parameters,docs:{...(_e=F.parameters)==null?void 0:_e.docs,source:{originalSource:`args => {
16
- const [_, updateArgs] = useArgs();
17
- const handleChange = (evt: any) => {
18
- updateArgs({
19
- value: evt.target.value
20
- });
21
- };
22
- return <UnitInput {...args} onChange={handleChange} />;
23
- }`,...(Oe=(Fe=F.parameters)==null?void 0:Fe.docs)==null?void 0:Oe.source}}};var We,Be,Re;O.parameters={...O.parameters,docs:{...(We=O.parameters)==null?void 0:We.docs,source:{originalSource:`args => {
24
- const [_, updateArgs] = useArgs();
25
- const handleChange = (evt: any) => {
26
- updateArgs({
27
- value: evt.target.value
28
- });
29
- };
30
- return <UnitInput {...args} onChange={handleChange} />;
31
- }`,...(Re=(Be=O.parameters)==null?void 0:Be.docs)==null?void 0:Re.source}}};var He,Le,Ke;W.parameters={...W.parameters,docs:{...(He=W.parameters)==null?void 0:He.docs,source:{originalSource:`args => {
32
- const [_, updateArgs] = useArgs();
33
- const handleChange = (evt: any) => {
34
- updateArgs({
35
- value: evt.target.value
36
- });
37
- };
38
- return <UnitInput {...args} onChange={handleChange} />;
39
- }`,...(Ke=(Le=W.parameters)==null?void 0:Le.docs)==null?void 0:Ke.source}}};var $e,ze,Ge;B.parameters={...B.parameters,docs:{...($e=B.parameters)==null?void 0:$e.docs,source:{originalSource:`args => {
40
- const [_, updateArgs] = useArgs();
41
- const handleChange = (evt: any) => {
42
- updateArgs({
43
- value: evt.target.value
44
- });
45
- };
46
- return <UnitInput {...args} onChange={handleChange} />;
47
- }`,...(Ge=(ze=B.parameters)==null?void 0:ze.docs)==null?void 0:Ge.source}}};var Je,Ye,Ze;R.parameters={...R.parameters,docs:{...(Je=R.parameters)==null?void 0:Je.docs,source:{originalSource:`args => {
48
- const [_, updateArgs] = useArgs();
49
- const handleChange = (evt: any) => {
50
- updateArgs({
51
- value: evt.target.value
52
- });
53
- };
54
- return <UnitInput {...args} onChange={handleChange} />;
55
- }`,...(Ze=(Ye=R.parameters)==null?void 0:Ye.docs)==null?void 0:Ze.source}}};var Qe,Xe,en;H.parameters={...H.parameters,docs:{...(Qe=H.parameters)==null?void 0:Qe.docs,source:{originalSource:`args => {
56
- const [_, updateArgs] = useArgs();
57
- const handleChange = (evt: any) => {
58
- updateArgs({
59
- value: evt.target.value
60
- });
61
- };
62
- return <UnitInput {...args} onChange={handleChange} />;
63
- }`,...(en=(Xe=H.parameters)==null?void 0:Xe.docs)==null?void 0:en.source}}};var nn,tn,an;L.parameters={...L.parameters,docs:{...(nn=L.parameters)==null?void 0:nn.docs,source:{originalSource:`args => {
64
- const [_, updateArgs] = useArgs();
65
- const handleChange = (evt: any) => {
66
- updateArgs({
67
- value: evt.target.value
68
- });
69
- };
70
- return <UnitInput {...args} onChange={handleChange} />;
71
- }`,...(an=(tn=L.parameters)==null?void 0:tn.docs)==null?void 0:an.source}}};var rn,sn,ln;S.parameters={...S.parameters,docs:{...(rn=S.parameters)==null?void 0:rn.docs,source:{originalSource:`args => {
72
- const [_, updateArgs] = useArgs();
73
- const handleChange = (evt: any) => {
74
- updateArgs({
75
- value: evt.target.value
76
- });
77
- };
78
- return <UnitInput {...args} onChange={handleChange} />;
79
- }`,...(ln=(sn=S.parameters)==null?void 0:sn.docs)==null?void 0:ln.source}}};var un,on,dn;K.parameters={...K.parameters,docs:{...(un=K.parameters)==null?void 0:un.docs,source:{originalSource:`args => {
80
- const [_, updateArgs] = useArgs();
81
- const handleChange = (evt: any) => {
82
- updateArgs({
83
- value: evt.target.value
84
- });
85
- };
86
- return <UnitInput {...args} onChange={handleChange} />;
87
- }`,...(dn=(on=K.parameters)==null?void 0:on.docs)==null?void 0:dn.source}}};var cn,mn,pn;$.parameters={...$.parameters,docs:{...(cn=$.parameters)==null?void 0:cn.docs,source:{originalSource:`args => {
88
- const [_, updateArgs] = useArgs();
89
- const handleChange = (evt: any) => {
90
- updateArgs({
91
- value: evt.target.value
92
- });
93
- };
94
- return <UnitInput {...args} onChange={handleChange} />;
95
- }`,...(pn=(mn=$.parameters)==null?void 0:mn.docs)==null?void 0:pn.source}}};var gn,hn,vn;z.parameters={...z.parameters,docs:{...(gn=z.parameters)==null?void 0:gn.docs,source:{originalSource:`args => {
96
- const [_, updateArgs] = useArgs();
97
- const handleChange = (evt: any) => {
98
- updateArgs({
99
- value: evt.target.value
100
- });
101
- };
102
- return <UnitInput {...args} onChange={handleChange} />;
103
- }`,...(vn=(hn=z.parameters)==null?void 0:hn.docs)==null?void 0:vn.source}}};var fn,yn,Cn;G.parameters={...G.parameters,docs:{...(fn=G.parameters)==null?void 0:fn.docs,source:{originalSource:`args => {
104
- const [_, updateArgs] = useArgs();
105
- const handleChange = (evt: any) => {
106
- updateArgs({
107
- value: evt.target.value
108
- });
109
- };
110
- return <UnitInput {...args} onChange={handleChange} />;
111
- }`,...(Cn=(yn=G.parameters)==null?void 0:yn.docs)==null?void 0:Cn.source}}};var bn,Un,xn;N.parameters={...N.parameters,docs:{...(bn=N.parameters)==null?void 0:bn.docs,source:{originalSource:`(args: IUnitInputProps) => {
112
- const [value, setValue] = useState('123|m');
113
- const [value2, setValue2] = useState('223|m');
114
- const [initUnit, setInitUnit] = useState('ft');
115
- return <>
116
- <Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
117
- <Spacer />
118
- <Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
119
- <Spacer />
120
- <UnitInput name="example" onChange={evt => {
121
- setValue(evt.target.value);
122
- }} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
123
- <Spacer />
124
- <UnitInput name="example2" onChange={evt => {
125
- setValue2(evt.target.value);
126
- }} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
127
- <Divider />
128
- <h4>Without initUnit property (taken from the redux store)</h4>
129
- <UnitInput name="example" onChange={evt => {
130
- setValue(evt.target.value);
131
- }} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
132
- <UnitInput name="example2" onChange={evt => {
133
- setValue2(evt.target.value);
134
- }} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
135
- </>;
136
- }`,...(xn=(Un=N.parameters)==null?void 0:Un.docs)==null?void 0:xn.source}}};var In,wn,Vn;J.parameters={...J.parameters,docs:{...(In=J.parameters)==null?void 0:In.docs,source:{originalSource:`args => {
137
- const [_, updateArgs] = useArgs();
138
- const handleChange = (evt: any) => {
139
- updateArgs({
140
- value: evt.target.value
141
- });
142
- };
143
- return <UnitInput {...args} onChange={handleChange} />;
144
- }`,...(Vn=(wn=J.parameters)==null?void 0:wn.docs)==null?void 0:Vn.source}}};var jn,En,kn;A.parameters={...A.parameters,docs:{...(jn=A.parameters)==null?void 0:jn.docs,source:{originalSource:`() => {
145
- const width = '500px';
146
- const [value, setValue] = useState<any>(undefined);
147
- return <>
148
- <h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
149
- <Row>
150
- <Column width="25%">
151
- <Button label="Change value infinity" onClick={() => setValue(Infinity)} />
152
- <br />
153
- <Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
154
- <br />
155
- <Button label="Change value null" onClick={() => setValue(null)} />
156
- <br />
157
- <Button label="Change value - undefined" onClick={() => setValue(undefined)} />
158
- <br />
159
- <Button label="Change value - NaN" onClick={() => setValue(NaN)} />
160
- <br />
161
- <Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
162
- <br />
163
- <Button label="Change value - empty string" onClick={() => setValue('')} />
164
- </Column>
165
- <Column width="25%">
166
- <Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
167
- <br />
168
- <Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
169
- <br />
170
- <Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
171
- <br />
172
- <Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
173
- <br />
174
- <Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
175
- <br />
176
- <Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
177
- </Column>
178
- </Row>
179
- <br />
180
- <Field label="Normal PUI">
181
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
182
- </Field>
183
- <Field label="Disabled validation">
184
- <UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
185
- </Field>
186
- <Field label="Disabled validation and manual error">
187
- <UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
188
- </Field>
189
- <Message message={{
190
- heading: 'Current value inside PUI: ' + value,
191
- visible: true
192
- }} />
193
- </>;
194
- }`,...(kn=(En=A.parameters)==null?void 0:En.docs)==null?void 0:kn.source}}};var Tn,Sn,Nn;Y.parameters={...Y.parameters,docs:{...(Tn=Y.parameters)==null?void 0:Tn.docs,source:{originalSource:`() => {
195
- const width = '500px';
196
- const [value, setValue] = useState<string>('1|m');
197
- const [valueB, setValueB] = useState('|m');
198
- const automaticValue = '123|km';
199
- return <>
200
- <h4>Different cases for automatic (placeholder) values:</h4>
201
- <Row>
202
- <Column width="25%">
203
- <Button label="Change value to ''" onClick={() => setValue('')} />
204
- <br />
205
- <Button label="Change value to 1" onClick={() => setValue('1')} />
206
- <br />
207
- <Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
208
- <br />
209
- <Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
210
- </Column>
211
- </Row>
212
- <br />
213
- <Field label="Normal PUI (placeholder + auto)">
214
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
215
- </Field>
216
- <Field label="Normal PUI (only auto)">
217
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
218
- </Field>
219
- <Field label="Empty PUI with autoValue">
220
- <UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
221
- </Field>
222
- <Field label="Normal PUI (only placeholder)">
223
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
224
- </Field>
225
- <Field label="Normal PUI (placeholder + allowEmpty)">
226
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
227
- </Field>
228
- <Message message={{
229
- heading: 'Current value inside PUI: ' + value,
230
- visible: true
231
- }} />
232
- </>;
233
- }`,...(Nn=(Sn=Y.parameters)==null?void 0:Sn.docs)==null?void 0:Nn.source}}};var An,qn,Pn;Z.parameters={...Z.parameters,docs:{...(An=Z.parameters)==null?void 0:An.docs,source:{originalSource:`() => {
234
- const [value, setValue] = useState('123|%');
235
- const [validation, setValidation] = useState<string | null>(null);
236
- const predictedMessage = 'This should be visible when an error appears';
237
- const handleValidation = (name: string, message: string | null) => {
238
- setValidation(message);
239
- return {
240
- name,
241
- error: message
242
- };
243
- };
244
- return <>
245
- <h4>3rd party validation message when inputting invalid value:</h4>
246
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
247
- <br />
248
- <Spacer />
249
- <h4>Original validation message: </h4>
250
- <Message message={{
251
- heading: validation,
252
- visible: true
253
- }} />
254
- </>;
255
- }`,...(Pn=(qn=Z.parameters)==null?void 0:qn.docs)==null?void 0:Pn.source}}};var Mn,Dn,_n;Q.parameters={...Q.parameters,docs:{...(Mn=Q.parameters)==null?void 0:Mn.docs,source:{originalSource:`() => {
256
- const [value, setValue] = useState('123|m');
257
- const [placeholder, setPlaceholder] = useState('');
258
- const [initUnit, setInitUnit] = useState('km');
259
- const setPlaceholderValue = () => {
260
- setInitUnit('ft');
261
- setPlaceholder('placeholder');
262
- setValue('|m');
263
- };
264
- return <>
265
- <h4>Empty value case:</h4>
266
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
267
- <br />
268
- <Spacer />
269
- <Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
270
- </>;
271
- }`,...(_n=(Dn=Q.parameters)==null?void 0:Dn.docs)==null?void 0:_n.source}}};var Fn,On,Wn;X.parameters={...X.parameters,docs:{...(Fn=X.parameters)==null?void 0:Fn.docs,source:{originalSource:`() => {
272
- const [value, setValue] = useState('123|m');
273
- const [unit, setUnit] = useState('m');
274
- return <>
275
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
276
- <Spacer />
277
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
278
- </>;
279
- }`,...(Wn=(On=X.parameters)==null?void 0:On.docs)==null?void 0:Wn.source}}};var Bn,Rn,Hn;ee.parameters={...ee.parameters,docs:{...(Bn=ee.parameters)==null?void 0:Bn.docs,source:{originalSource:`() => {
280
- return <>
281
- <Text faint>
282
- Reproduce OW-10614 rounding noise bug when storing values in a different
283
- unit to the display unit
284
- </Text>
285
- <Spacer />
286
- <UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
287
- pressure: 'psi'
288
- }} />
289
- </>;
290
- }`,...(Hn=(Rn=ee.parameters)==null?void 0:Rn.docs)==null?void 0:Hn.source}}};const ca=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","OW_10614TestCase"];export{Q as AllowEmptyPUI,Y as AutomaticValues,se as Default,S as Disabled,K as DisabledNoConversion,z as DisabledUnitWithUnitKey,$ as DisabledUnitWithoutUnitKey,G as DisabledWithEnabledUnitMenu,H as Error,F as InitUnit,L as InternalValidationError,B as NoConversion,ee as OW_10614TestCase,J as PredefinedOptionsMenu,R as Small,A as TestEdgeCases,N as TestExternalStateChangeWithSynchronizedUnits,Z as ValidationCallback,W as Width,ca as __namedExportsOrder,da as default,O as notKnownUnit,X as onSwitchUnit};
@@ -1,150 +0,0 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as z}from"./immer.esm-BwVl9PS2.js";import{d as U}from"./index-CWz-hU-f.js";import{G as Z}from"./grid-B6LFPf51.js";import{S as ee}from"./spacer-BWoNR27H.js";import{C as F}from"./card-EcjmryU9.js";import{F as L}from"./field-C5_fLDpy.js";import{H as W}from"./heading-NkLgQYoP.js";import{S as P}from"./select-Z-GCZ-pY.js";import{T as I}from"./toggle-Bo-JPbUP.js";import{l as te}from"./lodash-BHd_uQHh.js";import{u as ne}from"./use-previous-D775JrO6.js";import{T as ae,C as _}from"./table-CaaSoHex.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-Bf0q9Yjk.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-UmZ4Y_CR.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-CZK3mphC.js";import"./button-C1sV-0mR.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-DIKP56UZ.js";import"./index.es-D2piFfFj.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-BtguPxeR.js";import"./input-BW9trNAW.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-uQOVHv2N.js";import"./check-box-CaSrhzev.js";import"./slider-gZmYlxxz.js";import"./index-BI4_Bp97.js";import"./popover-DgUpTRMk.js";const ie=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:h})=>(i[s]=a,r[s]=h,{preferredUnits:i,storageUnits:r}),{preferredUnits:{},storageUnits:{}}),re=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:h,enableCosmeticRounding:g,enableDisplayRounding:y})=>{const u=l?l.map(d=>({...d,cells:d.cells.map(c=>{var t;if(c.type===_.AUTO_UNIT){const{testId:C,unitKey:p}=c;return{value:r[p],type:_.SELECT,searchable:!1,options:(t=U.getUnitsForQuantity(p))==null?void 0:t.map(T=>({label:U.label(T),value:T})),native:c.native,onChange:T=>a({unitKey:p,value:T.target.value}),testId:C}}return c})})):[],o=i?i.map((d,c)=>({...d,cells:d.cells.map((t,C)=>{if("autoUnit"in t&&(t!=null&&t.autoUnit)&&(typeof(t==null?void 0:t.value)=="string"||typeof(t==null?void 0:t.value)=="number")){const{unitKey:p,value:T,formatDisplayValue:w}=t,j=y&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,m=r[p],b=s[p],e=m!==b,f=e?U.convertAndGetValue(T,m,b):t.value,x=U.isScientificStringNum(T),D=g&&(e||!x)?U.roundToPrecision(f,14):f,R=w?w(D):D;return{...t,value:R,enableCosmeticRounding:g,enableDisplayRounding:y,roundDisplayValue:j,onChange:S=>{const{value:B}=S.target,A=s[p],E=r[p],N=E!==A,k=h?A:E,$=N?U.convertAndGetValue(B,k,E):B;if("onChange"in t){const{onChange:X}=t,Y={...S,target:{...S.target,value:String($),rowIndex:c,cellIndex:C,unit:k}};X(Y)}}}}return t})})):[];return{convertedHeaders:u,convertedRows:o}},M=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:h,headers:g,...y}=l,{storageUnits:u,preferredUnits:o}=ie(i),d=ne(o),[c,t]=v.useState(o),C=({unitKey:m,value:b})=>{t({...c,[m]:b});const e=i.find(f=>f.unitKey===m);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:c[m],newUnit:b,unitKey:m})},p=m=>re({headers:g,rows:h,selectedUnits:m,storageUnits:u,onChangeUnit:C,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),T=p(c),[w,j]=v.useState(T);return v.useEffect(()=>{!te.isEqual(o,d)&&(Object.keys(o).forEach(b=>{const e=d==null?void 0:d[b],f=o[b];e!==f&&C({unitKey:b,value:f})}),j(p(o)))},[i]),v.useEffect(()=>{j(p(c))},[l,c]),n.jsx(ae,{table:{...y,headers:w.convertedHeaders,rows:w.convertedRows}})};M.__docgenInfo={description:"",methods:[],displayName:"UnitTable",props:{table:{required:!0,tsType:{name:"IUnitTable"},description:""},unitConfig:{required:!0,tsType:{name:"Array",elements:[{name:"IUnitConfigItem"}],raw:"IUnitConfigItem[]"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}},composes:["Omit"]};const pt={title:"Basic/UnitTable",args:{}},oe=!0,le=!0,se=!0,ue=!1,H="m",J="C",de=3,ce=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((h,g)=>{const y=g,u=g+1.25,o=4+g*.25;return[String(y),String(u),String(o)]});return[s,...a]},pe=ce(de,H,J),ge=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>z(l,h=>{const g=h[0][a],y=(u,o)=>o===0;return h.forEach((u,o)=>{if(y(u,o)){u[a]=r;return}if(o===s+1){u[a]=String(i);return}const d=U.convertAndGetValue(u[a],r,g);u[a]=String(d)}),h}),me=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>z(l,a=>{a[r+1][s]=i}),V=()=>{var m,b;const[l,i]=v.useState(H),[r,s]=v.useState(J),[a,h]=v.useState(pe),[g,y]=v.useState(oe),[u,o]=v.useState(se),[d,c]=v.useState(le),[t,C]=v.useState(ue),[p,T]=v.useState(H),w=e=>{const{rowIndex:f,cellIndex:x,value:D,unit:R}=e.target,S=t?ge({reduxTable:a,value:D,unit:R,rowIndex:f,cellIndex:x}):me({reduxTable:a,value:D,rowIndex:f,cellIndex:x});h(S)},j=a.reduce((e,f,x)=>(x===0?e.headers=[{cells:[{value:"From"},{value:"To"},{value:"Temperature"}]},{cells:[{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"temperature",testId:"table-unit-selector-3"}]}]:e.rows=e.rows.concat({cells:f.map((D,R)=>{const S=x===1&&R===1;return{value:D,type:S?"Text":"NumberInput",unitKey:R===2?"temperature":"length",onChange:w,roundDisplayValue:x===3&&R===2?k=>U.roundByMagnitude(k,2):null,formatDisplayValue:S?k=>`T* ${k}`:null,autoUnit:!0}})}),e),{headers:[],rows:[]});return n.jsxs(Z,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(F,{heading:n.jsx(W,{children:"Settings"}),children:[n.jsx(L,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:g,onChange:e=>y(e.target.checked)})}),n.jsx(L,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:u,onChange:e=>o(e.target.checked)})}),n.jsx(L,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:d,onChange:e=>c(e.target.checked)})}),n.jsx(L,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:t,onChange:e=>C(e.target.checked)})})]}),n.jsxs(F,{heading:n.jsx(W,{children:"Unit template"}),children:[n.jsx(L,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(P,{options:(m=U.getUnitsForQuantity("length"))==null?void 0:m.map(e=>({value:e,label:U.label(e)})),value:{value:l},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(L,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(P,{options:(b=U.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:U.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(F,{heading:n.jsx(W,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(F,{heading:n.jsx(W,{children:"UnitTable"}),children:[n.jsx(M,{table:j,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:l,onChange:({newUnit:e})=>T(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:g,enableDisplayRounding:u,enableCosmeticRounding:d}),n.jsx(ee,{height:20}),n.jsx(L,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:p})]})]})};V.__docgenInfo={description:"",methods:[],displayName:"UnitTablePrototype"};var K,G,O,q,Q;V.parameters={...V.parameters,docs:{...(K=V.parameters)==null?void 0:K.docs,source:{originalSource:`() => {
2
- const [preferredLengthUnit, setPreferredLengthUnit] = useState(initialLengthUnit);
3
- const [preferredTemperatureUnit, setPreferredTemperatureUnit] = useState(initialTemperatureUnit);
4
- const [reduxTable, setReduxTable] = useState<TTable>(initialTable);
5
- const [convertBackToStorageUnit, setConvertBackToStorageUnit] = useState(initialConvertBackToStorageUnit);
6
- const [enableDisplayRounding, setEnableDisplayRounding] = useState(initialEnableDisplayRounding);
7
- const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(initialEnableCosmeticRounding);
8
- const [convertWholeTable, setConvertWholeTable] = useState(initialConvertWholeTable);
9
- const [displayedLengthUnit, setDisplayedLengthUnit] = useState(initialLengthUnit);
10
-
11
- /*********************************************************************************************************************
12
- Cell onChange handler
13
- *********************************************************************************************************************/
14
- const onUpdateCell = (evt: IUnitTableOnChangeEvent) => {
15
- const {
16
- rowIndex,
17
- cellIndex,
18
- value,
19
- unit
20
- } = evt.target;
21
- const nextTable = convertWholeTable ? convertStorageTable({
22
- reduxTable,
23
- value,
24
- unit,
25
- rowIndex,
26
- cellIndex
27
- }) : updateCell({
28
- reduxTable,
29
- value,
30
- rowIndex,
31
- cellIndex
32
- });
33
- setReduxTable(nextTable);
34
- };
35
-
36
- /*********************************************************************************************************************
37
- Construct table view data (same as old Table component, with a new props)
38
- *********************************************************************************************************************/
39
- const tableViewData = reduxTable.reduce((acc, row, rowIndex) => {
40
- if (rowIndex === 0) {
41
- acc.headers = [{
42
- cells: [{
43
- value: 'From'
44
- }, {
45
- value: 'To'
46
- }, {
47
- value: 'Temperature'
48
- }]
49
- }, {
50
- cells: [{
51
- type: 'AutoUnit',
52
- unitKey: 'length'
53
- }, {
54
- type: 'AutoUnit',
55
- unitKey: 'length'
56
- }, {
57
- type: 'AutoUnit',
58
- unitKey: 'temperature',
59
- testId: 'table-unit-selector-3'
60
- }]
61
- }];
62
- } else {
63
- acc.rows = acc.rows.concat({
64
- cells: row.map((cell, cellIndex) => {
65
- const specialCell = rowIndex === 1 && cellIndex === 1;
66
- const type = specialCell ? 'Text' : 'NumberInput';
67
- const formatDisplayValue = specialCell ? (value: number | string) => \`T* \${value}\` : null;
68
- const customDisplayRounding = rowIndex === 3 && cellIndex === 2 ? (value: TStringNumberNull) => roundByMagnitude(value, 2) : null;
69
- const value = cell;
70
- return {
71
- value,
72
- type,
73
- unitKey: cellIndex === 2 ? 'temperature' : 'length',
74
- onChange: onUpdateCell,
75
- roundDisplayValue: customDisplayRounding,
76
- // optionally customize the display rounding of specific columns/cells
77
- formatDisplayValue,
78
- // optionally extend/customize the display formatting of specific columns/cells
79
- autoUnit: true
80
- };
81
- })
82
- });
83
- }
84
- return acc;
85
- }, {
86
- headers: ([] as any[]),
87
- rows: ([] as IUnitTableRow[])
88
- });
89
- return <Grid columns="1fr 1fr" gap>
90
- <Card heading={<Heading>Settings</Heading>}>
91
- <Field label="Convert back to storage unit:" labelLeft labelWidth={200}>
92
- <Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
93
- </Field>
94
- <Field label="Enable display rounding:" labelLeft labelWidth={200}>
95
- <Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
96
- </Field>
97
- <Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
98
- <Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
99
- </Field>
100
- <Field label="Convert whole table:" labelLeft labelWidth={200}>
101
- <Toggle checked={convertWholeTable} onChange={evt => setConvertWholeTable(evt.target.checked)} />
102
- </Field>
103
- </Card>
104
- <Card heading={<Heading>Unit template</Heading>}>
105
- <Field label="Length unit:" labelLeft labelWidth={120}>
106
- <Select options={getUnitsForQuantity('length')?.map(unit => ({
107
- value: unit,
108
- label: label(unit)
109
- }))} value={{
110
- value: preferredLengthUnit
111
- }} onChange={evt => setPreferredLengthUnit(evt.target.value)} width="100px" />
112
- </Field>
113
- <Field label="Temperature unit:" labelLeft labelWidth={120}>
114
- <Select options={getUnitsForQuantity('temperature')?.map(unit => ({
115
- value: unit,
116
- label: label(unit)
117
- }))} value={{
118
- value: preferredTemperatureUnit
119
- }} onChange={evt => setPreferredTemperatureUnit(evt.target.value)} width="100px" />
120
- </Field>
121
- </Card>
122
- <Card heading={<Heading>Storage State (Redux)</Heading>}>
123
- <pre>
124
- <code>{JSON.stringify(reduxTable, null, 2)}</code>
125
- </pre>
126
- </Card>
127
- <Card heading={<Heading>UnitTable</Heading>}>
128
- <UnitTable table={tableViewData}
129
- //New props:
130
- unitConfig={[{
131
- unitKey: 'length',
132
- storageUnit: reduxTable[0][0],
133
- preferredUnit: preferredLengthUnit,
134
- onChange: ({
135
- newUnit
136
- }) => setDisplayedLengthUnit(newUnit)
137
- }, {
138
- unitKey: 'temperature',
139
- storageUnit: reduxTable[0][2],
140
- preferredUnit: preferredTemperatureUnit
141
- }]}
142
- //Most tables should just use the default values here (true):
143
- convertBackToStorageUnit={convertBackToStorageUnit} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} />
144
- <Spacer height={20} />
145
- <Field label="Displayed length unit:" labelLeft labelWidth={150}>
146
- {displayedLengthUnit}
147
- </Field>
148
- </Card>
149
- </Grid>;
150
- }`,...(O=(G=V.parameters)==null?void 0:G.docs)==null?void 0:O.source},description:{story:"Story",...(Q=(q=V.parameters)==null?void 0:q.docs)==null?void 0:Q.description}}};const gt=["UnitTablePrototype"];export{V as UnitTablePrototype,gt as __namedExportsOrder,pt as default};