@oliasoft-open-source/react-ui-library 4.8.0 → 4.8.2-beta-1

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 (147) hide show
  1. package/dist/assets/{index-CvGLlWUJ.js → index-CnfDrmnZ.js} +55 -43
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.html +1 -1
  4. package/dist/index.js +146 -160
  5. package/dist/index.js.map +1 -1
  6. package/dist/storybook/assets/Color-KGDBMAHA-5t9vWuuQ.js +1 -0
  7. package/dist/storybook/assets/DocsRenderer-PKQXORMH-C4Y4AfWk.js +1 -0
  8. package/dist/storybook/assets/{accordion-BiuI_LCA.js → accordion-6ouB0WTt.js} +1 -1
  9. package/dist/storybook/assets/{accordion.stories-CNjaOE6j.js → accordion.stories-Bv00H3Md.js} +2 -2
  10. package/dist/storybook/assets/{actions-D-uVCDzk.js → actions-Tr0wIZve.js} +1 -1
  11. package/dist/storybook/assets/{actions.stories-gKfuiKQy.js → actions.stories-CQK6PyBH.js} +1 -1
  12. package/dist/storybook/assets/{afe.stories-Be4Zi8Qk.js → afe.stories-D-uQj_IO.js} +2 -2
  13. package/dist/storybook/assets/{badge.stories-Dkq_XgEW.js → badge.stories-Blb5k20_.js} +1 -1
  14. package/dist/storybook/assets/{blowout.stories-DHdofVc-.js → blowout.stories-hdxkqScp.js} +1 -1
  15. package/dist/storybook/assets/{button-DHevvVBE.js → button-CzvLc2io.js} +1 -1
  16. package/dist/storybook/assets/{button-group-1DEZPmxq.js → button-group-C1PqMW-H.js} +1 -1
  17. package/dist/storybook/assets/{button-group.stories-C4V1k0z_.js → button-group.stories-QlYbfeJS.js} +1 -1
  18. package/dist/storybook/assets/{button.stories-DA9DGYD2.js → button.stories-tM18j4A3.js} +2 -2
  19. package/dist/storybook/assets/{buttons-and-links-CGf2fkq-.js → buttons-and-links-CurhOihj.js} +1 -1
  20. package/dist/storybook/assets/{card.stories-CsTB0DuM.js → card.stories-Bn6LpucB.js} +1 -1
  21. package/dist/storybook/assets/{casing-loads.stories-9Iu4v1Y5.js → casing-loads.stories-X3nSWrJV.js} +2 -2
  22. package/dist/storybook/assets/{cell.stories-OWJtpzu1.js → cell.stories-BvYuOEua.js} +2 -2
  23. package/dist/storybook/assets/{check-box-DPLaOkRR.js → check-box-wCvXxtCz.js} +1 -1
  24. package/dist/storybook/assets/{check-box.stories-DfbWw6mD.js → check-box.stories-Q_WICJ_2.js} +1 -1
  25. package/dist/storybook/assets/{chunk-HLWAVYOI-DQmzN82L.js → chunk-HLWAVYOI-BMaNuZAP.js} +1 -1
  26. package/dist/storybook/assets/color-DAqzZJ5g.js +25 -0
  27. package/dist/storybook/assets/{column.stories-DDTHFELF.js → column.stories-DATtbLrP.js} +1 -1
  28. package/dist/storybook/assets/{dialog-BelCA1mt.js → dialog-B55T_62Q.js} +1 -1
  29. package/dist/storybook/assets/{drawer-DOWJp9T4.js → drawer-CNKfMbq9.js} +1 -1
  30. package/dist/storybook/assets/drawer.stories-BzVj2VTf.js +113 -0
  31. package/dist/storybook/assets/{empty.stories-DcwF0pkK.js → empty.stories-CVaJlnv1.js} +1 -1
  32. package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
  33. package/dist/storybook/assets/extends-CF3RwP-h.js +1 -0
  34. package/dist/storybook/assets/{field-HrLaMLbx.js → field-C5_fLDpy.js} +1 -1
  35. package/dist/storybook/assets/{field.stories-DUGMwi1O.js → field.stories-DhiTcelS.js} +1 -1
  36. package/dist/storybook/assets/{file-button.stories-CU2pZcEO.js → file-button.stories-oe6HKMH2.js} +1 -1
  37. package/dist/storybook/assets/{file-input-X3BnZaHk.js → file-input-CMP44wlr.js} +1 -1
  38. package/dist/storybook/assets/{file-input.stories-CWD5XYE9.js → file-input.stories-DTRWZyqS.js} +1 -1
  39. package/dist/storybook/assets/{flex.stories-BhvJpHpN.js → flex.stories-DtDxXdHB.js} +1 -1
  40. package/dist/storybook/assets/footer.stories-DwXUmoze.js +3 -0
  41. package/dist/storybook/assets/form.stories-C_zflIAj.js +49 -0
  42. package/dist/storybook/assets/formation.stories-BIW-Dl8H.js +74 -0
  43. package/dist/storybook/assets/{heading-CRNoBc7q.js → heading-NkLgQYoP.js} +1 -1
  44. package/dist/storybook/assets/{heading.stories-DahFxeiX.js → heading.stories-nI_cFnAN.js} +1 -1
  45. package/dist/storybook/assets/{help-icon-Buhx5nl6.js → help-icon-41R-Z9N1.js} +1 -1
  46. package/dist/storybook/assets/{help-icon.stories-DbmZ1fgP.js → help-icon.stories-DBYh0YX7.js} +1 -1
  47. package/dist/storybook/assets/icon-BP4BO6-k.js +8 -0
  48. package/dist/storybook/assets/{icon.stories-fnZUR-LK.js → icon.stories-C4pR7xky.js} +1 -1
  49. package/dist/storybook/assets/iframe-DKsrL1t6.js +2 -0
  50. package/dist/storybook/assets/index--1DEpRYI.js +1 -0
  51. package/dist/storybook/assets/{index-DaLCDjg_.js → index-C0x1JmaP.js} +1 -1
  52. package/dist/storybook/assets/{index-DLsIgQne.js → index-CZYm9n2f.js} +87 -87
  53. package/dist/storybook/assets/{index.es-DazXb-ul.js → index.es-D2piFfFj.js} +4 -4
  54. package/dist/storybook/assets/inheritsLoose-DR8r8Ogv.js +1 -0
  55. package/dist/storybook/assets/{input-group.stories-Bqx8op1f.js → input-group.stories-dQnx3QX0.js} +3 -3
  56. package/dist/storybook/assets/{input-validation-CRDfoI4h.js → input-validation-C6sI0xWh.js} +2 -2
  57. package/dist/storybook/assets/{inputs-D3qEs1Q4.js → inputs-g6Qqs79j.js} +2 -2
  58. package/dist/storybook/assets/{label-CqmyC9he.js → label-hiSz3I8H.js} +1 -1
  59. package/dist/storybook/assets/{label.stories-C0AO5F1a.js → label.stories-Cyv5jBAO.js} +1 -1
  60. package/dist/storybook/assets/layout-forms-B3vD4GnB.js +16 -0
  61. package/dist/storybook/assets/{layout-general-D9kS22a0.js → layout-general-BtQS23Q-.js} +2 -2
  62. package/dist/storybook/assets/{list-bKpz6I9Q.js → list-DhjHm8bz.js} +1 -1
  63. package/dist/storybook/assets/{list.stories-Cgmt29Wv.js → list.stories-2F-UkS1E.js} +2 -2
  64. package/dist/storybook/assets/{list.stories-data-D_Aj3AN4.js → list.stories-data-DqFECKJF.js} +1 -1
  65. package/dist/storybook/assets/{loader.stories-pS8zRM4u.js → loader.stories-BMe1zhEL.js} +1 -1
  66. package/dist/storybook/assets/{menu.stories-xWX80Eh2.js → menu.stories-B_1YsebS.js} +2 -2
  67. package/dist/storybook/assets/{message-Y48EomV-.js → message-DQ3q8XF9.js} +1 -1
  68. package/dist/storybook/assets/{message.stories-r_UlbshI.js → message.stories-QYFwbrO0.js} +1 -1
  69. package/dist/storybook/assets/{meta-content-DWZbURV2.js → meta-content-DCllGQX6.js} +1 -1
  70. package/dist/storybook/assets/{modal.stories-BcqAhYEy.js → modal.stories-B-4WKtnM.js} +2 -2
  71. package/dist/storybook/assets/{number-input-Ct8VwJX0.js → number-input-DZ9ERbK_.js} +2 -2
  72. package/dist/storybook/assets/number-input.stories-TArdbUGM.js +124 -0
  73. package/dist/storybook/assets/{option-dropdown.stories-CIvqMhQ3.js → option-dropdown.stories-ntKLWycS.js} +1 -1
  74. package/dist/storybook/assets/{padding-and-spacing-Cr5c7WxM.js → padding-and-spacing-6fonPuoc.js} +2 -2
  75. package/dist/storybook/assets/{page.stories-DnCh8h8y.js → page.stories-Dp_z8s1a.js} +1 -1
  76. package/dist/storybook/assets/{pagination-D6pYWeQM.js → pagination-bLx5-m9c.js} +1 -1
  77. package/dist/storybook/assets/{pagination.stories-ItfGvzb-.js → pagination.stories-BHPRfynZ.js} +2 -2
  78. package/dist/storybook/assets/{pop-confirm.stories-DCpooB2O.js → pop-confirm.stories-D-iQo6s7.js} +1 -1
  79. package/dist/storybook/assets/{popover-rq33c1W2.js → popover-9ZnEm5Hy.js} +1 -1
  80. package/dist/storybook/assets/popover.stories-DyTPnA5y.js +10 -0
  81. package/dist/storybook/assets/preview-I53T45Im.js +2 -0
  82. package/dist/storybook/assets/{preview-B_VD4s7b.js → preview-o8g2WtEI.js} +3 -3
  83. package/dist/storybook/assets/projects.stories-CdvyNFKw.js +47 -0
  84. package/dist/storybook/assets/{radio-button-C4ljBRED.js → radio-button-C3RuBqEf.js} +1 -1
  85. package/dist/storybook/assets/{radio-button.stories-BzyW2CtK.js → radio-button.stories-CAHs1mr6.js} +1 -1
  86. package/dist/storybook/assets/react-router-dom-CMITYWBH.js +8 -0
  87. package/dist/storybook/assets/{reservoirs.stories-FQuUA3DK.js → reservoirs.stories-C98Z9kS0.js} +2 -2
  88. package/dist/storybook/assets/{rich-text-input.stories-CmFzKTb-.js → rich-text-input.stories-B2p90wTh.js} +44 -44
  89. package/dist/storybook/assets/{row.stories-xvzQuDF0.js → row.stories-Cwjgv2sq.js} +2 -2
  90. package/dist/storybook/assets/select-BpALjE__.js +61 -0
  91. package/dist/storybook/assets/{select.stories-CV9h5z0E.js → select.stories-B0d_sE6g.js} +2 -2
  92. package/dist/storybook/assets/{side-bar-CSx5wI-k.js → side-bar-BApSkmiM.js} +1 -1
  93. package/dist/storybook/assets/{side-bar.stories-M6FsuCrQ.js → side-bar.stories-BuAIJ8NV.js} +1 -1
  94. package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-lIyAWOdt.js} +2 -2
  95. package/dist/storybook/assets/{slider-C7vnj_3M.js → slider-CBE03NwD.js} +4 -4
  96. package/dist/storybook/assets/{slider.stories-BzBb3PkP.js → slider.stories-7oMw2PCp.js} +2 -2
  97. package/dist/storybook/assets/{smart-upload-modal.stories-BKNxg_3y.js → smart-upload-modal.stories-CdgsGLvm.js} +1 -1
  98. package/dist/storybook/assets/{spacer.stories-BBTt2LdE.js → spacer.stories-BC7lirqi.js} +1 -1
  99. package/dist/storybook/assets/{table-D9JJ68Tx.js → table-D1GJPQfF.js} +1 -1
  100. package/dist/storybook/assets/{table.stories-f-cNU-ed.js → table.stories-CZbXa0mx.js} +2 -2
  101. package/dist/storybook/assets/{table.stories-data-D52aKMY1.js → table.stories-data-CYppbCAy.js} +1 -1
  102. package/dist/storybook/assets/text-link.stories-BsuVBOWo.js +14 -0
  103. package/dist/storybook/assets/{title.stories-5TyZBiBD.js → title.stories-DtNSzV-q.js} +3 -3
  104. package/dist/storybook/assets/{toaster-BoBcvmf9.js → toaster-CDSt-Toh.js} +1 -1
  105. package/dist/storybook/assets/{toaster.stories-HO4VBTy-.js → toaster.stories-D1XTcQR_.js} +1 -1
  106. package/dist/storybook/assets/{toggle-BbFVf61v.js → toggle-C0zvrIOF.js} +1 -1
  107. package/dist/storybook/assets/{toggle.stories-qTHFTXxI.js → toggle.stories-DOc7uN93.js} +1 -1
  108. package/dist/storybook/assets/{tooltip.test-case.stories-CHibN8rC.js → tooltip.test-case.stories-D2SX9mkM.js} +1 -1
  109. package/dist/storybook/assets/{top-bar-DkXSzzqt.js → top-bar-BQzmL0IU.js} +1 -1
  110. package/dist/storybook/assets/top-bar.stories-Czza1RvB.js +21 -0
  111. package/dist/storybook/assets/{top-bar.testcase.stories-DfmrkEpT.js → top-bar.testcase.stories-DpV-QqfZ.js} +1 -1
  112. package/dist/storybook/assets/{tree.stories-feLUcTtm.js → tree.stories-CsmZwDmr.js} +1 -1
  113. package/dist/storybook/assets/unit-input-5P4Cogho.css +1 -0
  114. package/dist/storybook/assets/unit-input.stories-Ds9cL2Sl.js +316 -0
  115. package/dist/storybook/assets/unit-table.stories-C0IlAwKr.js +152 -0
  116. package/dist/storybook/iframe.html +1 -1
  117. package/dist/storybook/index.json +1 -1
  118. package/dist/storybook/project.json +1 -1
  119. package/dist/storybook/sb-addons/interactions-2/manager-bundle.js +52 -52
  120. package/dist/storybook/sb-manager/globals-runtime.js +7164 -7166
  121. package/dist/storybook/sb-manager/runtime.js +1110 -1111
  122. package/dist/storybook/sb-preview/runtime.js +1485 -1483
  123. package/package.json +1 -1
  124. package/dist/404.html +0 -1
  125. package/dist/storybook/assets/Color-KGDBMAHA-BLtMCq8G.js +0 -1
  126. package/dist/storybook/assets/DocsRenderer-PKQXORMH-Cq_uPi34.js +0 -1
  127. package/dist/storybook/assets/color-CUmK6HaC.js +0 -25
  128. package/dist/storybook/assets/drawer.stories-DcjyDHEs.js +0 -113
  129. package/dist/storybook/assets/footer.stories-CCaqnn-t.js +0 -3
  130. package/dist/storybook/assets/form.stories-CX1WxUVL.js +0 -49
  131. package/dist/storybook/assets/formation.stories-BwshNr5I.js +0 -74
  132. package/dist/storybook/assets/icon-BSFY3vDO.js +0 -8
  133. package/dist/storybook/assets/iframe-aT7NCuic.js +0 -2
  134. package/dist/storybook/assets/index-CDuLcH5d.js +0 -1
  135. package/dist/storybook/assets/inheritsLoose-DP0QEDDI.js +0 -1
  136. package/dist/storybook/assets/layout-forms-CDGrrwBl.js +0 -16
  137. package/dist/storybook/assets/number-input.stories-lRKm6_tZ.js +0 -110
  138. package/dist/storybook/assets/popover.stories-B4sQDryP.js +0 -10
  139. package/dist/storybook/assets/preview-t_Zs3gQw.js +0 -2
  140. package/dist/storybook/assets/projects.stories-Co_WnKSx.js +0 -47
  141. package/dist/storybook/assets/react-router-dom-Ck2Y_Fzc.js +0 -8
  142. package/dist/storybook/assets/select-V2ZNp3Pv.js +0 -61
  143. package/dist/storybook/assets/text-link.stories-BQAkVO-W.js +0 -14
  144. package/dist/storybook/assets/top-bar.stories-HDmWT243.js +0 -21
  145. package/dist/storybook/assets/unit-input-CoFS2qhN.css +0 -1
  146. package/dist/storybook/assets/unit-input.stories-tjEyowge.js +0 -318
  147. package/dist/storybook/assets/unit-table.stories-BDYxeHSM.js +0 -152
@@ -0,0 +1,316 @@
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-DZ9ERbK_.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
+ target:
3
+ | T
4
+ | { name: string; value: any; label?: string; files?: FileList | null };
5
+ }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
6
+ target:
7
+ | T
8
+ | { name: string; value: any; label?: string; files?: FileList | null };
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__,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
+ target:
12
+ | T
13
+ | { name: string; value: any; label?: string; files?: FileList | null };
14
+ }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
15
+ target:
16
+ | T
17
+ | { name: string; value: any; label?: string; files?: FileList | null };
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:""}}};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
+ const [_, updateArgs] = useArgs();
21
+ const handleChange = (evt: any) => {
22
+ updateArgs({
23
+ value: evt.target.value
24
+ });
25
+ };
26
+ return <UnitInput {...args} onChange={handleChange} />;
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
+ const [_, updateArgs] = useArgs();
29
+ const handleChange = (evt: any) => {
30
+ updateArgs({
31
+ value: evt.target.value
32
+ });
33
+ };
34
+ return <UnitInput {...args} onChange={handleChange} />;
35
+ }`,...(Oe=(Me=W.parameters)==null?void 0:Me.docs)==null?void 0:Oe.source}}};var We,Re,Le;R.parameters={...R.parameters,docs:{...(We=R.parameters)==null?void 0:We.docs,source:{originalSource:`args => {
36
+ const [_, updateArgs] = useArgs();
37
+ const handleChange = (evt: any) => {
38
+ updateArgs({
39
+ value: evt.target.value
40
+ });
41
+ };
42
+ return <UnitInput {...args} onChange={handleChange} />;
43
+ }`,...(Le=(Re=R.parameters)==null?void 0:Re.docs)==null?void 0:Le.source}}};var He,Ke,$e;L.parameters={...L.parameters,docs:{...(He=L.parameters)==null?void 0:He.docs,source:{originalSource:`args => {
44
+ const [_, updateArgs] = useArgs();
45
+ const handleChange = (evt: any) => {
46
+ updateArgs({
47
+ value: evt.target.value
48
+ });
49
+ };
50
+ return <UnitInput {...args} onChange={handleChange} />;
51
+ }`,...($e=(Ke=L.parameters)==null?void 0:Ke.docs)==null?void 0:$e.source}}};var Ge,ze,Je;H.parameters={...H.parameters,docs:{...(Ge=H.parameters)==null?void 0:Ge.docs,source:{originalSource:`args => {
52
+ const [_, updateArgs] = useArgs();
53
+ const handleChange = (evt: any) => {
54
+ updateArgs({
55
+ value: evt.target.value
56
+ });
57
+ };
58
+ return <UnitInput {...args} onChange={handleChange} />;
59
+ }`,...(Je=(ze=H.parameters)==null?void 0:ze.docs)==null?void 0:Je.source}}};var Ye,Ze,Qe;K.parameters={...K.parameters,docs:{...(Ye=K.parameters)==null?void 0:Ye.docs,source:{originalSource:`args => {
60
+ const [_, updateArgs] = useArgs();
61
+ const handleChange = (evt: any) => {
62
+ updateArgs({
63
+ value: evt.target.value
64
+ });
65
+ };
66
+ return <UnitInput {...args} onChange={handleChange} />;
67
+ }`,...(Qe=(Ze=K.parameters)==null?void 0:Ze.docs)==null?void 0:Qe.source}}};var Xe,et,tt;A.parameters={...A.parameters,docs:{...(Xe=A.parameters)==null?void 0:Xe.docs,source:{originalSource:`() => {
68
+ const [value, setValue] = useState('123|m');
69
+ return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} placeholder="Type a value..." value={value} initUnit="m" unitkey="depth" unitTemplate={{
70
+ depth: 'm'
71
+ }} testId="testId" />;
72
+ }`,...(tt=(et=A.parameters)==null?void 0:et.docs)==null?void 0:tt.source}}};var nt,at,it;$.parameters={...$.parameters,docs:{...(nt=$.parameters)==null?void 0:nt.docs,source:{originalSource:`args => {
73
+ const [_, updateArgs] = useArgs();
74
+ const handleChange = (evt: any) => {
75
+ updateArgs({
76
+ value: evt.target.value
77
+ });
78
+ };
79
+ return <UnitInput {...args} onChange={handleChange} />;
80
+ }`,...(it=(at=$.parameters)==null?void 0:at.docs)==null?void 0:it.source}}};var rt,st,lt;G.parameters={...G.parameters,docs:{...(rt=G.parameters)==null?void 0:rt.docs,source:{originalSource:`args => {
81
+ const [_, updateArgs] = useArgs();
82
+ const handleChange = (evt: any) => {
83
+ updateArgs({
84
+ value: evt.target.value
85
+ });
86
+ };
87
+ return <UnitInput {...args} onChange={handleChange} />;
88
+ }`,...(lt=(st=G.parameters)==null?void 0:st.docs)==null?void 0:lt.source}}};var ut,ot,dt;q.parameters={...q.parameters,docs:{...(ut=q.parameters)==null?void 0:ut.docs,source:{originalSource:`args => {
89
+ const [_, updateArgs] = useArgs();
90
+ const handleChange = (evt: any) => {
91
+ updateArgs({
92
+ value: evt.target.value
93
+ });
94
+ };
95
+ return <UnitInput {...args} onChange={handleChange} />;
96
+ }`,...(dt=(ot=q.parameters)==null?void 0:ot.docs)==null?void 0:dt.source}}};var ct,mt,pt;z.parameters={...z.parameters,docs:{...(ct=z.parameters)==null?void 0:ct.docs,source:{originalSource:`args => {
97
+ const [_, updateArgs] = useArgs();
98
+ const handleChange = (evt: any) => {
99
+ updateArgs({
100
+ value: evt.target.value
101
+ });
102
+ };
103
+ return <UnitInput {...args} onChange={handleChange} />;
104
+ }`,...(pt=(mt=z.parameters)==null?void 0:mt.docs)==null?void 0:pt.source}}};var gt,ht,vt;J.parameters={...J.parameters,docs:{...(gt=J.parameters)==null?void 0:gt.docs,source:{originalSource:`args => {
105
+ const [_, updateArgs] = useArgs();
106
+ const handleChange = (evt: any) => {
107
+ updateArgs({
108
+ value: evt.target.value
109
+ });
110
+ };
111
+ return <UnitInput {...args} onChange={handleChange} />;
112
+ }`,...(vt=(ht=J.parameters)==null?void 0:ht.docs)==null?void 0:vt.source}}};var ft,yt,bt;Y.parameters={...Y.parameters,docs:{...(ft=Y.parameters)==null?void 0:ft.docs,source:{originalSource:`args => {
113
+ const [_, updateArgs] = useArgs();
114
+ const handleChange = (evt: any) => {
115
+ updateArgs({
116
+ value: evt.target.value
117
+ });
118
+ };
119
+ return <UnitInput {...args} onChange={handleChange} />;
120
+ }`,...(bt=(yt=Y.parameters)==null?void 0:yt.docs)==null?void 0:bt.source}}};var Ct,Ut,wt;Z.parameters={...Z.parameters,docs:{...(Ct=Z.parameters)==null?void 0:Ct.docs,source:{originalSource:`args => {
121
+ const [_, updateArgs] = useArgs();
122
+ const handleChange = (evt: any) => {
123
+ updateArgs({
124
+ value: evt.target.value
125
+ });
126
+ };
127
+ return <UnitInput {...args} onChange={handleChange} />;
128
+ }`,...(wt=(Ut=Z.parameters)==null?void 0:Ut.docs)==null?void 0:wt.source}}};var xt,It,Tt;D.parameters={...D.parameters,docs:{...(xt=D.parameters)==null?void 0:xt.docs,source:{originalSource:`(args: IUnitInputProps) => {
129
+ const [value, setValue] = useState('123|m');
130
+ const [value2, setValue2] = useState('223|m');
131
+ const [initUnit, setInitUnit] = useState('ft');
132
+ return <>
133
+ <Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
134
+ <Spacer />
135
+ <Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
136
+ <Spacer />
137
+ <UnitInput name="example" onChange={evt => {
138
+ setValue(evt.target.value);
139
+ }} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
140
+ <Spacer />
141
+ <UnitInput name="example2" onChange={evt => {
142
+ setValue2(evt.target.value);
143
+ }} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
144
+ <Divider />
145
+ <h4>Without initUnit property (taken from the redux store)</h4>
146
+ <UnitInput name="example" onChange={evt => {
147
+ setValue(evt.target.value);
148
+ }} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
149
+ <UnitInput name="example2" onChange={evt => {
150
+ setValue2(evt.target.value);
151
+ }} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
152
+ </>;
153
+ }`,...(Tt=(It=D.parameters)==null?void 0:It.docs)==null?void 0:Tt.source}}};var Vt,kt,jt;Q.parameters={...Q.parameters,docs:{...(Vt=Q.parameters)==null?void 0:Vt.docs,source:{originalSource:`args => {
154
+ const [_, updateArgs] = useArgs();
155
+ const handleChange = (evt: any) => {
156
+ updateArgs({
157
+ value: evt.target.value
158
+ });
159
+ };
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;F.parameters={...F.parameters,docs:{...(St=F.parameters)==null?void 0:St.docs,source:{originalSource:`() => {
162
+ const width = '500px';
163
+ const [value, setValue] = useState<any>(undefined);
164
+ return <>
165
+ <h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
166
+ <Row>
167
+ <Column width="25%">
168
+ <Button label="Change value infinity" onClick={() => setValue(Infinity)} />
169
+ <br />
170
+ <Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
171
+ <br />
172
+ <Button label="Change value null" onClick={() => setValue(null)} />
173
+ <br />
174
+ <Button label="Change value - undefined" onClick={() => setValue(undefined)} />
175
+ <br />
176
+ <Button label="Change value - NaN" onClick={() => setValue(NaN)} />
177
+ <br />
178
+ <Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
179
+ <br />
180
+ <Button label="Change value - empty string" onClick={() => setValue('')} />
181
+ </Column>
182
+ <Column width="25%">
183
+ <Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
184
+ <br />
185
+ <Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
186
+ <br />
187
+ <Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
188
+ <br />
189
+ <Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
190
+ <br />
191
+ <Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
192
+ <br />
193
+ <Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
194
+ </Column>
195
+ </Row>
196
+ <br />
197
+ <Field label="Normal PUI">
198
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
199
+ </Field>
200
+ <Field label="Disabled validation">
201
+ <UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
202
+ </Field>
203
+ <Field label="Disabled validation and manual error">
204
+ <UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
205
+ </Field>
206
+ <Message message={{
207
+ heading: 'Current value inside PUI: ' + value,
208
+ visible: true
209
+ }} />
210
+ </>;
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
+ const width = '500px';
213
+ const [value, setValue] = useState<string>('1|m');
214
+ const [valueB, setValueB] = useState('|m');
215
+ const automaticValue = '123|km';
216
+ return <>
217
+ <h4>Different cases for automatic (placeholder) values:</h4>
218
+ <Row>
219
+ <Column width="25%">
220
+ <Button label="Change value to ''" onClick={() => setValue('')} />
221
+ <br />
222
+ <Button label="Change value to 1" onClick={() => setValue('1')} />
223
+ <br />
224
+ <Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
225
+ <br />
226
+ <Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
227
+ </Column>
228
+ </Row>
229
+ <br />
230
+ <Field label="Normal PUI (placeholder + auto)">
231
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
232
+ </Field>
233
+ <Field label="Normal PUI (only auto)">
234
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
235
+ </Field>
236
+ <Field label="Empty PUI with autoValue">
237
+ <UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
238
+ </Field>
239
+ <Field label="Normal PUI (only placeholder)">
240
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
241
+ </Field>
242
+ <Field label="Normal PUI (placeholder + allowEmpty)">
243
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
244
+ </Field>
245
+ <Message message={{
246
+ heading: 'Current value inside PUI: ' + value,
247
+ visible: true
248
+ }} />
249
+ </>;
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
+ const [value, setValue] = useState('123|%');
252
+ const [validation, setValidation] = useState<string | null>(null);
253
+ const predictedMessage = 'This should be visible when an error appears';
254
+ const handleValidation = (name: string, error: string | null) => {
255
+ setValidation(error);
256
+ return {
257
+ name,
258
+ error
259
+ };
260
+ };
261
+ return <>
262
+ <h4>3rd party validation message when inputting invalid value:</h4>
263
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
264
+ <br />
265
+ <Spacer />
266
+ <h4>Original validation message: </h4>
267
+ <Message message={{
268
+ heading: validation,
269
+ visible: true
270
+ }} />
271
+ </>;
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
+ const [value, setValue] = useState('123|m');
274
+ const [placeholder, setPlaceholder] = useState('');
275
+ const [initUnit, setInitUnit] = useState('km');
276
+ const setPlaceholderValue = () => {
277
+ setInitUnit('ft');
278
+ setPlaceholder('placeholder');
279
+ setValue('|m');
280
+ };
281
+ return <>
282
+ <h4>Empty value case:</h4>
283
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
284
+ <br />
285
+ <Spacer />
286
+ <Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
287
+ </>;
288
+ }`,...(Ot=(Mt=te.parameters)==null?void 0:Mt.docs)==null?void 0:Ot.source}}};var Wt,Rt,Lt;ne.parameters={...ne.parameters,docs:{...(Wt=ne.parameters)==null?void 0:Wt.docs,source:{originalSource:`() => {
289
+ const [value, setValue] = useState('123|m');
290
+ const [unit, setUnit] = useState('m');
291
+ return <>
292
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
293
+ <Spacer />
294
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
295
+ </>;
296
+ }`,...(Lt=(Rt=ne.parameters)==null?void 0:Rt.docs)==null?void 0:Lt.source}}};var Ht,Kt,$t;ae.parameters={...ae.parameters,docs:{...(Ht=ae.parameters)==null?void 0:Ht.docs,source:{originalSource:`() => {
297
+ return <>
298
+ <Text faint>
299
+ Reproduce OW-10614 rounding noise bug when storing values in a different
300
+ unit to the display unit
301
+ </Text>
302
+ <Spacer />
303
+ <UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
304
+ pressure: 'psi'
305
+ }} />
306
+ <Spacer />
307
+ <UnitInput name="example2" onChange={() => {}} value={withUnit(convertAndGetValue('8642|lbf', 'tonneForce'), 'tonneForce')} initUnit="lbf" unitkey="force" unitTemplate={{
308
+ force: 'tonneForce'
309
+ }} />
310
+ </>;
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
+ const [value, setValue] = useState('123|m');
313
+ return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
314
+ depth: 'm'
315
+ }} testId="testId" />;
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};
@@ -0,0 +1,152 @@
1
+ import{j as i}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as J}from"./immer.esm-BwVl9PS2.js";import{d as T}from"./index-C0x1JmaP.js";import{G as ne}from"./grid-DRkC-bt8.js";import{S as ae}from"./spacer-BWoNR27H.js";import{w as O,u as d,e as B,f as ie,a as re}from"./index-DMAnyMX5.js";import{C as F}from"./card-EcjmryU9.js";import{F as R}from"./field-C5_fLDpy.js";import{H as _}from"./heading-NkLgQYoP.js";import{S as P}from"./select-BpALjE__.js";import{T as W}from"./toggle-C0zvrIOF.js";import{l as oe}from"./lodash-c4VUpsOs.js";import{u as le}from"./use-previous-D775JrO6.js";import{T as se,C as G}from"./table-D1GJPQfF.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-CF7H4eMJ.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-Dx2TtIG9.js";import"./enum-Bnn40S8Q.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-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"./index.es-D2piFfFj.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-bLx5-m9c.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-DZ9ERbK_.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";const ue=r=>r.reduce(({preferredUnits:o,storageUnits:a},{unitKey:l,preferredUnit:e,storageUnit:b})=>(o[l]=e,a[l]=b,{preferredUnits:o,storageUnits:a}),{preferredUnits:{},storageUnits:{}}),ce=({headers:r,rows:o,selectedUnits:a,storageUnits:l,onChangeUnit:e,convertBackToStorageUnit:b,enableCosmeticRounding:m,enableDisplayRounding:C})=>{const u=r?r.map(c=>({...c,cells:c.cells.map(p=>{var n;if(p.type===G.AUTO_UNIT){const{testId:x,unitKey:g}=p;return{value:a[g],type:G.SELECT,searchable:!1,options:(n=T.getUnitsForQuantity(g))==null?void 0:n.map(U=>({label:T.label(U),value:U})),native:p.native,onChange:U=>e({unitKey:g,value:U.target.value}),testId:x}}return p})})):[],s=o?o.map((c,p)=>({...c,cells:c.cells.map((n,x)=>{if("autoUnit"in n&&(n!=null&&n.autoUnit)&&(typeof(n==null?void 0:n.value)=="string"||typeof(n==null?void 0:n.value)=="number")){const{unitKey:g,value:U,formatDisplayValue:I}=n,V=C&&"roundDisplayValue"in n?n==null?void 0:n.roundDisplayValue:null,h=a[g],y=l[g],t=h!==y,f=t?T.convertAndGetValue(U,h,y):n.value,w=T.isScientificStringNum(U),k=m&&(t||!w)?T.roundToPrecision(f,14):f,S=I?I(k):k;return{...n,value:S,enableCosmeticRounding:m,enableDisplayRounding:C,roundDisplayValue:V,onChange:D=>{const{value:H}=D.target,A=l[g],E=a[g],K=E!==A,j=b?A:E,Z=K?T.convertAndGetValue(H,j,E):H;if("onChange"in n){const{onChange:ee}=n,te={...D,target:{...D.target,value:String(Z),rowIndex:p,cellIndex:x,unit:j}};ee(te)}}}}return n})})):[];return{convertedHeaders:u,convertedRows:s}},X=({table:r,unitConfig:o,convertBackToStorageUnit:a=!0,enableCosmeticRounding:l=!0,enableDisplayRounding:e=!0})=>{const{rows:b,headers:m,...C}=r,{storageUnits:u,preferredUnits:s}=ue(o),c=le(s),[p,n]=v.useState(s),x=({unitKey:h,value:y})=>{n({...p,[h]:y});const t=o.find(f=>f.unitKey===h);t&&typeof t.onChange=="function"&&t.onChange({oldUnit:p[h],newUnit:y,unitKey:h})},g=h=>ce({headers:m,rows:b,selectedUnits:h,storageUnits:u,onChangeUnit:x,convertBackToStorageUnit:a,enableCosmeticRounding:l,enableDisplayRounding:e}),U=g(p),[I,V]=v.useState(U);return v.useEffect(()=>{!oe.isEqual(s,c)&&(Object.keys(s).forEach(y=>{const t=c==null?void 0:c[y],f=s[y];t!==f&&x({unitKey:y,value:f})}),V(g(s)))},[o]),v.useEffect(()=>{V(g(p))},[r,p]),i.jsx(se,{table:{...C,headers:I.convertedHeaders,rows:I.convertedRows}})};X.__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 Ut={title:"Basic/UnitTable",args:{}},de=!0,pe=!0,ge=!0,me=!1,N="m",Y="C",he=3,be=(r,o,a)=>{const l=[o,o,a],e=[...Array(r)].map((b,m)=>{const C=m,u=m+1.25,s=4+m*.25;return[String(C),String(u),String(s)]});return[l,...e]},ye=be(he,N,Y),fe=({reduxTable:r,value:o,unit:a,rowIndex:l,cellIndex:e})=>J(r,b=>{const m=b[0][e],C=(u,s)=>s===0;return b.forEach((u,s)=>{if(C(u,s)){u[e]=a;return}if(s===l+1){u[e]=String(o);return}const c=T.convertAndGetValue(u[e],a,m);u[e]=String(c)}),b}),ve=({reduxTable:r,value:o,rowIndex:a,cellIndex:l})=>J(r,e=>{e[a+1][l]=o}),L=()=>{var h,y;const[r,o]=v.useState(N),[a,l]=v.useState(Y),[e,b]=v.useState(ye),[m,C]=v.useState(de),[u,s]=v.useState(ge),[c,p]=v.useState(pe),[n,x]=v.useState(me),[g,U]=v.useState(N),I=t=>{const{rowIndex:f,cellIndex:w,value:k,unit:S}=t.target,D=n?fe({reduxTable:e,value:k,unit:S,rowIndex:f,cellIndex:w}):ve({reduxTable:e,value:k,rowIndex:f,cellIndex:w});b(D)},V=e.reduce((t,f,w)=>(w===0?t.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"}]}]:t.rows=t.rows.concat({cells:f.map((k,S)=>{const D=w===1&&S===1;return{value:k,type:D?"Text":"NumberInput",unitKey:S===2?"temperature":"length",onChange:I,roundDisplayValue:w===3&&S===2?j=>T.roundByMagnitude(j,2):null,formatDisplayValue:D?j=>`T* ${j}`:null,autoUnit:!0,testId:`testId_${w}_${S}`}})}),t),{testId:"testId",headers:[],rows:[]});return i.jsxs(ne,{columns:"1fr 1fr",gap:!0,children:[i.jsxs(F,{heading:i.jsx(_,{children:"Settings"}),children:[i.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:m,onChange:t=>C(t.target.checked)})}),i.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:u,onChange:t=>s(t.target.checked)})}),i.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:c,onChange:t=>p(t.target.checked)})}),i.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:n,onChange:t=>x(t.target.checked)})})]}),i.jsxs(F,{heading:i.jsx(_,{children:"Unit template"}),children:[i.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(h=T.getUnitsForQuantity("length"))==null?void 0:h.map(t=>({value:t,label:T.label(t)})),value:{value:r},onChange:t=>o(t.target.value),width:"100px"})}),i.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(y=T.getUnitsForQuantity("temperature"))==null?void 0:y.map(t=>({value:t,label:T.label(t)})),value:{value:a},onChange:t=>l(t.target.value),width:"100px"})})]}),i.jsx(F,{heading:i.jsx(_,{children:"Storage State (Redux)"}),children:i.jsx("pre",{children:i.jsx("code",{children:JSON.stringify(e,null,2)})})}),i.jsxs(F,{heading:i.jsx(_,{children:"UnitTable"}),children:[i.jsx(X,{table:V,unitConfig:[{unitKey:"length",storageUnit:e[0][0],preferredUnit:r,onChange:({newUnit:t})=>U(t)},{unitKey:"temperature",storageUnit:e[0][2],preferredUnit:a}],convertBackToStorageUnit:m,enableDisplayRounding:u,enableCosmeticRounding:c}),i.jsx(ae,{height:20}),i.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:g})]})]})};L.play=async({canvasElement:r,step:o})=>{const a=O(r),l=O(r.ownerDocument.body);await o("Can enter decimal values",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123.123456789"),await d.click(r),await B(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await o("Can enter comma decimals (converts to dot)",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123,456"),await d.click(r),await B(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await o("Can enter small numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"0.0000000023"),await d.click(r),await B(e).toHaveDisplayValue("0.00")}),await o("Can enter large numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"999999999999"),await d.click(r),await B(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await o("Shows validation error for non-numeric input",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123x45s6"),await d.click(r),await ie.mouseOver(e),await re(()=>{B(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};L.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"UnitTableExample"};var q,$,Q,M,z;L.parameters={...L.parameters,docs:{...(q=L.parameters)==null?void 0:q.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
+ testId: \`testId_\${rowIndex}_\${cellIndex}\`
81
+ };
82
+ })
83
+ });
84
+ }
85
+ return acc;
86
+ }, {
87
+ testId: 'testId',
88
+ headers: ([] as any[]),
89
+ rows: ([] as IUnitTableRow[])
90
+ });
91
+ return <Grid columns="1fr 1fr" gap>
92
+ <Card heading={<Heading>Settings</Heading>}>
93
+ <Field label="Convert back to storage unit:" labelLeft labelWidth={200}>
94
+ <Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
95
+ </Field>
96
+ <Field label="Enable display rounding:" labelLeft labelWidth={200}>
97
+ <Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
98
+ </Field>
99
+ <Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
100
+ <Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
101
+ </Field>
102
+ <Field label="Convert whole table:" labelLeft labelWidth={200}>
103
+ <Toggle checked={convertWholeTable} onChange={evt => setConvertWholeTable(evt.target.checked)} />
104
+ </Field>
105
+ </Card>
106
+ <Card heading={<Heading>Unit template</Heading>}>
107
+ <Field label="Length unit:" labelLeft labelWidth={120}>
108
+ <Select options={getUnitsForQuantity('length')?.map(unit => ({
109
+ value: unit,
110
+ label: label(unit)
111
+ }))} value={{
112
+ value: preferredLengthUnit
113
+ }} onChange={evt => setPreferredLengthUnit(evt.target.value)} width="100px" />
114
+ </Field>
115
+ <Field label="Temperature unit:" labelLeft labelWidth={120}>
116
+ <Select options={getUnitsForQuantity('temperature')?.map(unit => ({
117
+ value: unit,
118
+ label: label(unit)
119
+ }))} value={{
120
+ value: preferredTemperatureUnit
121
+ }} onChange={evt => setPreferredTemperatureUnit(evt.target.value)} width="100px" />
122
+ </Field>
123
+ </Card>
124
+ <Card heading={<Heading>Storage State (Redux)</Heading>}>
125
+ <pre>
126
+ <code>{JSON.stringify(reduxTable, null, 2)}</code>
127
+ </pre>
128
+ </Card>
129
+ <Card heading={<Heading>UnitTable</Heading>}>
130
+ <UnitTable table={tableViewData}
131
+ //New props:
132
+ unitConfig={[{
133
+ unitKey: 'length',
134
+ storageUnit: reduxTable[0][0],
135
+ preferredUnit: preferredLengthUnit,
136
+ onChange: ({
137
+ newUnit
138
+ }) => setDisplayedLengthUnit(newUnit)
139
+ }, {
140
+ unitKey: 'temperature',
141
+ storageUnit: reduxTable[0][2],
142
+ preferredUnit: preferredTemperatureUnit
143
+ }]}
144
+ //Most tables should just use the default values here (true):
145
+ convertBackToStorageUnit={convertBackToStorageUnit} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} />
146
+ <Spacer height={20} />
147
+ <Field label="Displayed length unit:" labelLeft labelWidth={150}>
148
+ {displayedLengthUnit}
149
+ </Field>
150
+ </Card>
151
+ </Grid>;
152
+ }`,...(Q=($=L.parameters)==null?void 0:$.docs)==null?void 0:Q.source},description:{story:"Story",...(z=(M=L.parameters)==null?void 0:M.docs)==null?void 0:z.description}}};const Ct=["UnitTableExample"];export{L as UnitTableExample,Ct as __namedExportsOrder,Ut as default};
@@ -509,7 +509,7 @@
509
509
  }
510
510
  </script>
511
511
 
512
- <script type="module" crossorigin src="./assets/iframe-aT7NCuic.js"></script>
512
+ <script type="module" crossorigin src="./assets/iframe-DKsrL1t6.js"></script>
513
513
  </head>
514
514
 
515
515
  <body>