@oliasoft-open-source/react-ui-library 4.12.2 → 4.13.0-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 (163) hide show
  1. package/dist/assets/{index-BU9wzZv9.css → index-BZ1vGLnA.css} +34 -317
  2. package/dist/assets/{index-BVCFmQTa.js → index-D4oUBkZd.js} +169 -145
  3. package/dist/global.css +0 -312
  4. package/dist/index.d.ts +5 -7
  5. package/dist/index.html +1 -1
  6. package/dist/index.js +166 -134
  7. package/dist/index.js.map +1 -1
  8. package/dist/storybook/assets/{Color-KGDBMAHA-CvQEdkJ-.js → Color-KGDBMAHA-ANgdrQuZ.js} +1 -1
  9. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-C6GXR-GZ.js → DocsRenderer-PKQXORMH-Diyq_37l.js} +1 -1
  10. package/dist/storybook/assets/{accordion.stories-BlHfHegj.js → accordion.stories-CrmHu75y.js} +1 -1
  11. package/dist/storybook/assets/{buttons-and-links-B2aUSQnD.js → buttons-and-links-CtA6FoCC.js} +1 -1
  12. package/dist/storybook/assets/{casing-loads.stories-Cl2tJipP.js → casing-loads.stories-Buy0-e_n.js} +1 -1
  13. package/dist/storybook/assets/{cell.stories-rzJE_qJC.js → cell.stories-CPNfDo9l.js} +1 -1
  14. package/dist/storybook/assets/{chunk-HLWAVYOI-bMKAIsRx.js → chunk-HLWAVYOI-KJoVz4w2.js} +1 -1
  15. package/dist/storybook/assets/{color-C-IS9le6.js → color-fa-nGnuH.js} +1 -1
  16. package/dist/storybook/assets/{footer.stories-C6M5S0UZ.js → footer.stories-DniqHrTZ.js} +1 -1
  17. package/dist/storybook/assets/{form.stories-BNORsn6Z.js → form.stories-Cr5Pz40F.js} +1 -1
  18. package/dist/storybook/assets/{formation.stories-1WX1Nu1P.js → formation.stories-C4Kugh7C.js} +1 -1
  19. package/dist/storybook/assets/{iframe-QRTUElpr.js → iframe-zFwPc0wJ.js} +2 -2
  20. package/dist/storybook/assets/{index-bEJt8O9I.js → index-D6O8EiV-.js} +88 -88
  21. package/dist/storybook/assets/{index-BEnhO9y0.js → index-DKfJ8f-b.js} +1 -1
  22. package/dist/storybook/assets/{input-validation-DMG_NbpY.js → input-validation-D5ctNaQa.js} +1 -1
  23. package/dist/storybook/assets/{inputs-DBtZGdv-.js → inputs-CwLa0axN.js} +1 -1
  24. package/dist/storybook/assets/{layout-forms-CaGMNapf.js → layout-forms-5MAO2Ru7.js} +1 -1
  25. package/dist/storybook/assets/{layout-general-irIAv1Z-.js → layout-general-BH_mkxyI.js} +1 -1
  26. package/dist/storybook/assets/{padding-and-spacing-BWFXmHaT.js → padding-and-spacing-B1k2xnXg.js} +1 -1
  27. package/dist/storybook/assets/preview-B0ZyjArU.css +1 -0
  28. package/dist/storybook/assets/{preview-BQAoj8Wn.js → preview-DpTCnAn-.js} +2 -2
  29. package/dist/storybook/assets/{preview-BAhOLBiJ.js → preview-FIj3W2uF.js} +1 -1
  30. package/dist/storybook/assets/{row.stories-DRvH8Grn.js → row.stories-jKh8Ms1e.js} +1 -1
  31. package/dist/storybook/assets/{slider-DnRddBCy.css → slider-DPdTVMP0.css} +1 -1
  32. package/dist/storybook/assets/{slider-CcpE4BLD.js → slider-DxaD8LU4.js} +4 -4
  33. package/dist/storybook/assets/slider.stories-DuGie_AX.js +134 -0
  34. package/dist/storybook/assets/{table-DoyDBG6l.js → table-BSABGfWm.js} +1 -1
  35. package/dist/storybook/assets/{table.stories-BgWKzIob.js → table.stories-CHwzAdud.js} +1 -1
  36. package/dist/storybook/assets/{title.stories-Rv6ZO_Wl.js → title.stories-D0VjujmM.js} +1 -1
  37. package/dist/storybook/assets/unit-input-CFaqZ7UG.js +7 -0
  38. package/dist/storybook/assets/unit-input.stories-DBuzpBTN.js +203 -0
  39. package/dist/storybook/assets/unit-input.test-case.stories-Dzx3BsjK.js +223 -0
  40. package/dist/storybook/assets/{unit-table.stories-CISvZMxX.js → unit-table.stories-DwZVHcZo.js} +1 -1
  41. package/dist/storybook/assets/{unit-table.test-case.stories-tEype9om.js → unit-table.test-case.stories-C9Swzooe.js} +1 -1
  42. package/dist/storybook/iframe.html +1 -1
  43. package/dist/storybook/index.json +1 -1
  44. package/dist/storybook/project.json +1 -1
  45. package/package.json +1 -1
  46. package/dist/404.html +0 -1
  47. package/dist/assets/noto-sans-cyrillic-400-italic-BY-huaZy.woff +0 -0
  48. package/dist/assets/noto-sans-cyrillic-400-italic-V6PUkjg4.woff2 +0 -0
  49. package/dist/assets/noto-sans-cyrillic-400-normal--jh3sVvp.woff +0 -0
  50. package/dist/assets/noto-sans-cyrillic-400-normal-XY9qUppk.woff2 +0 -0
  51. package/dist/assets/noto-sans-cyrillic-700-italic-BsvNKSfQ.woff2 +0 -0
  52. package/dist/assets/noto-sans-cyrillic-700-italic-DSFghSMx.woff +0 -0
  53. package/dist/assets/noto-sans-cyrillic-700-normal-8ZAWbjJL.woff2 +0 -0
  54. package/dist/assets/noto-sans-cyrillic-700-normal-CTzjhoZt.woff +0 -0
  55. package/dist/assets/noto-sans-cyrillic-ext-400-italic-Bb5b47eb.woff +0 -0
  56. package/dist/assets/noto-sans-cyrillic-ext-400-italic-DGWPeY37.woff2 +0 -0
  57. package/dist/assets/noto-sans-cyrillic-ext-400-normal-CFQi7qvd.woff +0 -0
  58. package/dist/assets/noto-sans-cyrillic-ext-400-normal-CH_iUxq2.woff2 +0 -0
  59. package/dist/assets/noto-sans-cyrillic-ext-700-italic-BdqKfCVQ.woff2 +0 -0
  60. package/dist/assets/noto-sans-cyrillic-ext-700-italic-C55zR5rk.woff +0 -0
  61. package/dist/assets/noto-sans-cyrillic-ext-700-normal-B5dGcPIT.woff +0 -0
  62. package/dist/assets/noto-sans-cyrillic-ext-700-normal-CojAy5w4.woff2 +0 -0
  63. package/dist/assets/noto-sans-devanagari-400-italic-KeY3OvDe.woff +0 -0
  64. package/dist/assets/noto-sans-devanagari-400-italic-Lk_flmKd.woff2 +0 -0
  65. package/dist/assets/noto-sans-devanagari-400-normal-BV8n3Zrw.woff2 +0 -0
  66. package/dist/assets/noto-sans-devanagari-400-normal-Da_uNpmI.woff +0 -0
  67. package/dist/assets/noto-sans-devanagari-700-italic-DX_Ben-x.woff2 +0 -0
  68. package/dist/assets/noto-sans-devanagari-700-italic-Df3Sqs2H.woff +0 -0
  69. package/dist/assets/noto-sans-devanagari-700-normal-C2VYeOxD.woff +0 -0
  70. package/dist/assets/noto-sans-devanagari-700-normal-C8e99gZj.woff2 +0 -0
  71. package/dist/assets/noto-sans-greek-400-italic-BXJxTOvj.woff +0 -0
  72. package/dist/assets/noto-sans-greek-400-italic-DHwB0AdM.woff2 +0 -0
  73. package/dist/assets/noto-sans-greek-400-normal-BroOW-sQ.woff +0 -0
  74. package/dist/assets/noto-sans-greek-400-normal-CPTbu1sO.woff2 +0 -0
  75. package/dist/assets/noto-sans-greek-700-italic-CfolioWa.woff2 +0 -0
  76. package/dist/assets/noto-sans-greek-700-italic-DBCdhGrj.woff +0 -0
  77. package/dist/assets/noto-sans-greek-700-normal-BVjVfDKs.woff +0 -0
  78. package/dist/assets/noto-sans-greek-700-normal-P_B9BfF7.woff2 +0 -0
  79. package/dist/assets/noto-sans-greek-ext-400-italic-9zOpfpOs.woff2 +0 -0
  80. package/dist/assets/noto-sans-greek-ext-400-italic-D2WbBWVW.woff +0 -0
  81. package/dist/assets/noto-sans-greek-ext-400-normal-D73iK5X1.woff2 +0 -0
  82. package/dist/assets/noto-sans-greek-ext-400-normal-DWouWyWY.woff +0 -0
  83. package/dist/assets/noto-sans-greek-ext-700-italic-C5zCcdM3.woff2 +0 -0
  84. package/dist/assets/noto-sans-greek-ext-700-italic-YPo3ecki.woff +0 -0
  85. package/dist/assets/noto-sans-greek-ext-700-normal-BJpqEDTw.woff +0 -0
  86. package/dist/assets/noto-sans-greek-ext-700-normal-ZrWkOZr4.woff2 +0 -0
  87. package/dist/assets/noto-sans-latin-ext-400-italic-BOMiliBU.woff +0 -0
  88. package/dist/assets/noto-sans-latin-ext-400-italic-UXQeYjoB.woff2 +0 -0
  89. package/dist/assets/noto-sans-latin-ext-400-normal-BIBIZdeZ.woff2 +0 -0
  90. package/dist/assets/noto-sans-latin-ext-400-normal-vP3vnBxr.woff +0 -0
  91. package/dist/assets/noto-sans-latin-ext-700-italic-o2AF7PF_.woff2 +0 -0
  92. package/dist/assets/noto-sans-latin-ext-700-italic-zILg070W.woff +0 -0
  93. package/dist/assets/noto-sans-latin-ext-700-normal-BInqjRdw.woff +0 -0
  94. package/dist/assets/noto-sans-latin-ext-700-normal-BS3CI2D1.woff2 +0 -0
  95. package/dist/assets/noto-sans-vietnamese-400-italic-CDqW7NCu.woff2 +0 -0
  96. package/dist/assets/noto-sans-vietnamese-400-italic-DJmGvf9Z.woff +0 -0
  97. package/dist/assets/noto-sans-vietnamese-400-normal-DziUSn_1.woff +0 -0
  98. package/dist/assets/noto-sans-vietnamese-400-normal-l431O8bE.woff2 +0 -0
  99. package/dist/assets/noto-sans-vietnamese-700-italic-D0f5b0SE.woff +0 -0
  100. package/dist/assets/noto-sans-vietnamese-700-italic-GQhDhRZX.woff2 +0 -0
  101. package/dist/assets/noto-sans-vietnamese-700-normal-Dp2_pAUa.woff +0 -0
  102. package/dist/assets/noto-sans-vietnamese-700-normal-RhAWG0gK.woff2 +0 -0
  103. package/dist/storybook/assets/noto-sans-cyrillic-400-italic-BY-huaZy.woff +0 -0
  104. package/dist/storybook/assets/noto-sans-cyrillic-400-italic-V6PUkjg4.woff2 +0 -0
  105. package/dist/storybook/assets/noto-sans-cyrillic-400-normal--jh3sVvp.woff +0 -0
  106. package/dist/storybook/assets/noto-sans-cyrillic-400-normal-XY9qUppk.woff2 +0 -0
  107. package/dist/storybook/assets/noto-sans-cyrillic-700-italic-BsvNKSfQ.woff2 +0 -0
  108. package/dist/storybook/assets/noto-sans-cyrillic-700-italic-DSFghSMx.woff +0 -0
  109. package/dist/storybook/assets/noto-sans-cyrillic-700-normal-8ZAWbjJL.woff2 +0 -0
  110. package/dist/storybook/assets/noto-sans-cyrillic-700-normal-CTzjhoZt.woff +0 -0
  111. package/dist/storybook/assets/noto-sans-cyrillic-ext-400-italic-Bb5b47eb.woff +0 -0
  112. package/dist/storybook/assets/noto-sans-cyrillic-ext-400-italic-DGWPeY37.woff2 +0 -0
  113. package/dist/storybook/assets/noto-sans-cyrillic-ext-400-normal-CFQi7qvd.woff +0 -0
  114. package/dist/storybook/assets/noto-sans-cyrillic-ext-400-normal-CH_iUxq2.woff2 +0 -0
  115. package/dist/storybook/assets/noto-sans-cyrillic-ext-700-italic-BdqKfCVQ.woff2 +0 -0
  116. package/dist/storybook/assets/noto-sans-cyrillic-ext-700-italic-C55zR5rk.woff +0 -0
  117. package/dist/storybook/assets/noto-sans-cyrillic-ext-700-normal-B5dGcPIT.woff +0 -0
  118. package/dist/storybook/assets/noto-sans-cyrillic-ext-700-normal-CojAy5w4.woff2 +0 -0
  119. package/dist/storybook/assets/noto-sans-devanagari-400-italic-KeY3OvDe.woff +0 -0
  120. package/dist/storybook/assets/noto-sans-devanagari-400-italic-Lk_flmKd.woff2 +0 -0
  121. package/dist/storybook/assets/noto-sans-devanagari-400-normal-BV8n3Zrw.woff2 +0 -0
  122. package/dist/storybook/assets/noto-sans-devanagari-400-normal-Da_uNpmI.woff +0 -0
  123. package/dist/storybook/assets/noto-sans-devanagari-700-italic-DX_Ben-x.woff2 +0 -0
  124. package/dist/storybook/assets/noto-sans-devanagari-700-italic-Df3Sqs2H.woff +0 -0
  125. package/dist/storybook/assets/noto-sans-devanagari-700-normal-C2VYeOxD.woff +0 -0
  126. package/dist/storybook/assets/noto-sans-devanagari-700-normal-C8e99gZj.woff2 +0 -0
  127. package/dist/storybook/assets/noto-sans-greek-400-italic-BXJxTOvj.woff +0 -0
  128. package/dist/storybook/assets/noto-sans-greek-400-italic-DHwB0AdM.woff2 +0 -0
  129. package/dist/storybook/assets/noto-sans-greek-400-normal-BroOW-sQ.woff +0 -0
  130. package/dist/storybook/assets/noto-sans-greek-400-normal-CPTbu1sO.woff2 +0 -0
  131. package/dist/storybook/assets/noto-sans-greek-700-italic-CfolioWa.woff2 +0 -0
  132. package/dist/storybook/assets/noto-sans-greek-700-italic-DBCdhGrj.woff +0 -0
  133. package/dist/storybook/assets/noto-sans-greek-700-normal-BVjVfDKs.woff +0 -0
  134. package/dist/storybook/assets/noto-sans-greek-700-normal-P_B9BfF7.woff2 +0 -0
  135. package/dist/storybook/assets/noto-sans-greek-ext-400-italic-9zOpfpOs.woff2 +0 -0
  136. package/dist/storybook/assets/noto-sans-greek-ext-400-italic-D2WbBWVW.woff +0 -0
  137. package/dist/storybook/assets/noto-sans-greek-ext-400-normal-D73iK5X1.woff2 +0 -0
  138. package/dist/storybook/assets/noto-sans-greek-ext-400-normal-DWouWyWY.woff +0 -0
  139. package/dist/storybook/assets/noto-sans-greek-ext-700-italic-C5zCcdM3.woff2 +0 -0
  140. package/dist/storybook/assets/noto-sans-greek-ext-700-italic-YPo3ecki.woff +0 -0
  141. package/dist/storybook/assets/noto-sans-greek-ext-700-normal-BJpqEDTw.woff +0 -0
  142. package/dist/storybook/assets/noto-sans-greek-ext-700-normal-ZrWkOZr4.woff2 +0 -0
  143. package/dist/storybook/assets/noto-sans-latin-ext-400-italic-BOMiliBU.woff +0 -0
  144. package/dist/storybook/assets/noto-sans-latin-ext-400-italic-UXQeYjoB.woff2 +0 -0
  145. package/dist/storybook/assets/noto-sans-latin-ext-400-normal-BIBIZdeZ.woff2 +0 -0
  146. package/dist/storybook/assets/noto-sans-latin-ext-400-normal-vP3vnBxr.woff +0 -0
  147. package/dist/storybook/assets/noto-sans-latin-ext-700-italic-o2AF7PF_.woff2 +0 -0
  148. package/dist/storybook/assets/noto-sans-latin-ext-700-italic-zILg070W.woff +0 -0
  149. package/dist/storybook/assets/noto-sans-latin-ext-700-normal-BInqjRdw.woff +0 -0
  150. package/dist/storybook/assets/noto-sans-latin-ext-700-normal-BS3CI2D1.woff2 +0 -0
  151. package/dist/storybook/assets/noto-sans-vietnamese-400-italic-CDqW7NCu.woff2 +0 -0
  152. package/dist/storybook/assets/noto-sans-vietnamese-400-italic-DJmGvf9Z.woff +0 -0
  153. package/dist/storybook/assets/noto-sans-vietnamese-400-normal-DziUSn_1.woff +0 -0
  154. package/dist/storybook/assets/noto-sans-vietnamese-400-normal-l431O8bE.woff2 +0 -0
  155. package/dist/storybook/assets/noto-sans-vietnamese-700-italic-D0f5b0SE.woff +0 -0
  156. package/dist/storybook/assets/noto-sans-vietnamese-700-italic-GQhDhRZX.woff2 +0 -0
  157. package/dist/storybook/assets/noto-sans-vietnamese-700-normal-Dp2_pAUa.woff +0 -0
  158. package/dist/storybook/assets/noto-sans-vietnamese-700-normal-RhAWG0gK.woff2 +0 -0
  159. package/dist/storybook/assets/preview-DeFlgNaS.css +0 -1
  160. package/dist/storybook/assets/slider.stories-BqlRLY_C.js +0 -171
  161. package/dist/storybook/assets/unit-input-DTOrVqdm.js +0 -5
  162. package/dist/storybook/assets/unit-input.stories-BhSBzB95.js +0 -198
  163. package/dist/storybook/assets/unit-input.test-case.stories-Dk5SRvMt.js +0 -215
@@ -1,198 +0,0 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as u}from"./index-DhsZuJvc.js";import{U as o}from"./unit-input-DTOrVqdm.js";import{B as p}from"./button-Cbv7WK6k.js";import{S as E}from"./spacer-BWoNR27H.js";import{R as Fe,C as De}from"./row-Bmiy2Lh0.js";import{F as g}from"./field-HrLaMLbx.js";import{M as Ne}from"./message-BRyKdRaX.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./index-Bk2sglWO.js";import"./initialize-context-Y03pJPr5.js";import"./number-input-B3_gmeWr.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./text-B3-TSWok.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";const{useArgs:Be}=__STORYBOOK_MODULE_PREVIEW_API__,Ua={title:"Forms/UnitInput",component:o,args:{name:"example",unitkey:"length",value:"123|m"}},s=n=>{const[r,a]=Be(),i=l=>{a({value:l.target.value})};return e.jsx(o,{...n,onChange:i})},P=s.bind({}),m=s.bind({});m.args={initUnit:"ft",unitTemplate:{length:"ft"}};const h=s.bind({});h.args={value:'123|"',unitkey:'"'};const v=s.bind({});v.args={width:"180px"};const C=s.bind({});C.args={noConversion:!0};const b=s.bind({});b.args={small:!0};const U=s.bind({});U.args={error:"Error message goes here"};const x=s.bind({});x.args={value:"asas123asd|%"};const c=s.bind({});c.args={disabled:!0,disabledUnit:!0};c.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 y=s.bind({});y.args={disabled:!0,disabledUnit:!0,noConversion:!0};const I=s.bind({});I.args={disabledUnit:!0,unitkey:void 0};const V=s.bind({});V.args={disabledUnit:!0,unitkey:"length"};const A=s.bind({});A.args={disabledUnit:!1,disabled:!0};const S=s.bind({});S.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const w=()=>{const n="500px",[r,a]=u.useState("1|m"),[i,l]=u.useState("|m"),d="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Fe,{children:e.jsxs(De,{width:"25%",children:[e.jsx(p,{label:"Change value to ''",onClick:()=>a("")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1",onClick:()=>a("1")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1|m",onClick:()=>a("1|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to |m - empty value",onClick:()=>a("|m")})]})}),e.jsx("br",{}),e.jsx(g,{label:"Normal PUI (placeholder + auto)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"value|unit",autoValue:d})}),e.jsx(g,{label:"Normal PUI (only auto)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,autoValue:d})}),e.jsx(g,{label:"Empty PUI with autoValue",children:e.jsx(o,{name:"example1",onChange:t=>l(t.target.value),value:i,unitkey:"length",width:n,autoValue:d})}),e.jsx(g,{label:"Normal PUI (only placeholder)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"Placeholder test"})}),e.jsx(g,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(Ne,{message:{heading:"Current value inside PUI: "+r,visible:!0}})]})},j=()=>{const[n,r]=u.useState("123|%"),[a,i]=u.useState(null),l="This should be visible when an error appears",d=(t,_)=>(i(_),{name:t,error:_});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(o,{name:"example",onChange:t=>r(t.target.value),error:!a||l,validationCallback:d,value:n}),e.jsx("br",{}),e.jsx(E,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(Ne,{message:{heading:a,visible:!0}})]})},k=()=>{const[n,r]=u.useState("123|m"),[a,i]=u.useState(""),[l,d]=u.useState("km"),t=()=>{d("ft"),i("placeholder"),r("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(o,{name:"example",onChange:_=>r(_.target.value),value:n,allowEmpty:!0,placeholder:a,initUnit:l,unitkey:"length"}),e.jsx("br",{}),e.jsx(E,{}),e.jsx(p,{label:"Change value |m and unit ft",onClick:()=>t()})]})},f=()=>{const[n,r]=u.useState("123|m"),[a,i]=u.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(o,{name:"example",onChange:l=>r(l.target.value),value:n,initUnit:a,unitkey:"length",onSwitchUnit:i}),e.jsx(E,{}),e.jsx(o,{name:"example",onChange:l=>r(l.target.value),value:n,initUnit:a,unitkey:"length",onSwitchUnit:i})]})};w.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};j.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};k.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};f.__docgenInfo={description:"",methods:[],displayName:"OnSwitchUnit"};var N,F,D;P.parameters={...P.parameters,docs:{...(N=P.parameters)==null?void 0:N.docs,source:{originalSource:`args => {
2
- const [_, updateArgs] = useArgs();
3
- const handleChange = (evt: any) => {
4
- updateArgs({
5
- value: evt.target.value
6
- });
7
- };
8
- return <UnitInput {...args} onChange={handleChange} />;
9
- }`,...(D=(F=P.parameters)==null?void 0:F.docs)==null?void 0:D.source}}};var B,O,M;m.parameters={...m.parameters,docs:{...(B=m.parameters)==null?void 0:B.docs,source:{originalSource:`args => {
10
- const [_, updateArgs] = useArgs();
11
- const handleChange = (evt: any) => {
12
- updateArgs({
13
- value: evt.target.value
14
- });
15
- };
16
- return <UnitInput {...args} onChange={handleChange} />;
17
- }`,...(M=(O=m.parameters)==null?void 0:O.docs)==null?void 0:M.source}}};var W,R,K;h.parameters={...h.parameters,docs:{...(W=h.parameters)==null?void 0:W.docs,source:{originalSource:`args => {
18
- const [_, updateArgs] = useArgs();
19
- const handleChange = (evt: any) => {
20
- updateArgs({
21
- value: evt.target.value
22
- });
23
- };
24
- return <UnitInput {...args} onChange={handleChange} />;
25
- }`,...(K=(R=h.parameters)==null?void 0:R.docs)==null?void 0:K.source}}};var T,q,L;v.parameters={...v.parameters,docs:{...(T=v.parameters)==null?void 0:T.docs,source:{originalSource:`args => {
26
- const [_, updateArgs] = useArgs();
27
- const handleChange = (evt: any) => {
28
- updateArgs({
29
- value: evt.target.value
30
- });
31
- };
32
- return <UnitInput {...args} onChange={handleChange} />;
33
- }`,...(L=(q=v.parameters)==null?void 0:q.docs)==null?void 0:L.source}}};var Y,z,G;C.parameters={...C.parameters,docs:{...(Y=C.parameters)==null?void 0:Y.docs,source:{originalSource:`args => {
34
- const [_, updateArgs] = useArgs();
35
- const handleChange = (evt: any) => {
36
- updateArgs({
37
- value: evt.target.value
38
- });
39
- };
40
- return <UnitInput {...args} onChange={handleChange} />;
41
- }`,...(G=(z=C.parameters)==null?void 0:z.docs)==null?void 0:G.source}}};var H,J,Q;b.parameters={...b.parameters,docs:{...(H=b.parameters)==null?void 0:H.docs,source:{originalSource:`args => {
42
- const [_, updateArgs] = useArgs();
43
- const handleChange = (evt: any) => {
44
- updateArgs({
45
- value: evt.target.value
46
- });
47
- };
48
- return <UnitInput {...args} onChange={handleChange} />;
49
- }`,...(Q=(J=b.parameters)==null?void 0:J.docs)==null?void 0:Q.source}}};var X,Z,$;U.parameters={...U.parameters,docs:{...(X=U.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
50
- const [_, updateArgs] = useArgs();
51
- const handleChange = (evt: any) => {
52
- updateArgs({
53
- value: evt.target.value
54
- });
55
- };
56
- return <UnitInput {...args} onChange={handleChange} />;
57
- }`,...($=(Z=U.parameters)==null?void 0:Z.docs)==null?void 0:$.source}}};var ee,ae,te;x.parameters={...x.parameters,docs:{...(ee=x.parameters)==null?void 0:ee.docs,source:{originalSource:`args => {
58
- const [_, updateArgs] = useArgs();
59
- const handleChange = (evt: any) => {
60
- updateArgs({
61
- value: evt.target.value
62
- });
63
- };
64
- return <UnitInput {...args} onChange={handleChange} />;
65
- }`,...(te=(ae=x.parameters)==null?void 0:ae.docs)==null?void 0:te.source}}};var ne,re,se;c.parameters={...c.parameters,docs:{...(ne=c.parameters)==null?void 0:ne.docs,source:{originalSource:`args => {
66
- const [_, updateArgs] = useArgs();
67
- const handleChange = (evt: any) => {
68
- updateArgs({
69
- value: evt.target.value
70
- });
71
- };
72
- return <UnitInput {...args} onChange={handleChange} />;
73
- }`,...(se=(re=c.parameters)==null?void 0:re.docs)==null?void 0:se.source}}};var le,oe,ie;y.parameters={...y.parameters,docs:{...(le=y.parameters)==null?void 0:le.docs,source:{originalSource:`args => {
74
- const [_, updateArgs] = useArgs();
75
- const handleChange = (evt: any) => {
76
- updateArgs({
77
- value: evt.target.value
78
- });
79
- };
80
- return <UnitInput {...args} onChange={handleChange} />;
81
- }`,...(ie=(oe=y.parameters)==null?void 0:oe.docs)==null?void 0:ie.source}}};var ue,de,ce;I.parameters={...I.parameters,docs:{...(ue=I.parameters)==null?void 0:ue.docs,source:{originalSource:`args => {
82
- const [_, updateArgs] = useArgs();
83
- const handleChange = (evt: any) => {
84
- updateArgs({
85
- value: evt.target.value
86
- });
87
- };
88
- return <UnitInput {...args} onChange={handleChange} />;
89
- }`,...(ce=(de=I.parameters)==null?void 0:de.docs)==null?void 0:ce.source}}};var ge,pe,me;V.parameters={...V.parameters,docs:{...(ge=V.parameters)==null?void 0:ge.docs,source:{originalSource:`args => {
90
- const [_, updateArgs] = useArgs();
91
- const handleChange = (evt: any) => {
92
- updateArgs({
93
- value: evt.target.value
94
- });
95
- };
96
- return <UnitInput {...args} onChange={handleChange} />;
97
- }`,...(me=(pe=V.parameters)==null?void 0:pe.docs)==null?void 0:me.source}}};var he,ve,Ce;A.parameters={...A.parameters,docs:{...(he=A.parameters)==null?void 0:he.docs,source:{originalSource:`args => {
98
- const [_, updateArgs] = useArgs();
99
- const handleChange = (evt: any) => {
100
- updateArgs({
101
- value: evt.target.value
102
- });
103
- };
104
- return <UnitInput {...args} onChange={handleChange} />;
105
- }`,...(Ce=(ve=A.parameters)==null?void 0:ve.docs)==null?void 0:Ce.source}}};var be,Ue,xe;S.parameters={...S.parameters,docs:{...(be=S.parameters)==null?void 0:be.docs,source:{originalSource:`args => {
106
- const [_, updateArgs] = useArgs();
107
- const handleChange = (evt: any) => {
108
- updateArgs({
109
- value: evt.target.value
110
- });
111
- };
112
- return <UnitInput {...args} onChange={handleChange} />;
113
- }`,...(xe=(Ue=S.parameters)==null?void 0:Ue.docs)==null?void 0:xe.source}}};var ye,Ie,Ve;w.parameters={...w.parameters,docs:{...(ye=w.parameters)==null?void 0:ye.docs,source:{originalSource:`() => {
114
- const width = '500px';
115
- const [value, setValue] = useState<string>('1|m');
116
- const [valueB, setValueB] = useState('|m');
117
- const automaticValue = '123|km';
118
- return <>
119
- <h4>Different cases for automatic (placeholder) values:</h4>
120
- <Row>
121
- <Column width="25%">
122
- <Button label="Change value to ''" onClick={() => setValue('')} />
123
- <br />
124
- <Button label="Change value to 1" onClick={() => setValue('1')} />
125
- <br />
126
- <Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
127
- <br />
128
- <Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
129
- </Column>
130
- </Row>
131
- <br />
132
- <Field label="Normal PUI (placeholder + auto)">
133
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
134
- </Field>
135
- <Field label="Normal PUI (only auto)">
136
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
137
- </Field>
138
- <Field label="Empty PUI with autoValue">
139
- <UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
140
- </Field>
141
- <Field label="Normal PUI (only placeholder)">
142
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
143
- </Field>
144
- <Field label="Normal PUI (placeholder + allowEmpty)">
145
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
146
- </Field>
147
- <Message message={{
148
- heading: 'Current value inside PUI: ' + value,
149
- visible: true
150
- }} />
151
- </>;
152
- }`,...(Ve=(Ie=w.parameters)==null?void 0:Ie.docs)==null?void 0:Ve.source}}};var Ae,Se,we;j.parameters={...j.parameters,docs:{...(Ae=j.parameters)==null?void 0:Ae.docs,source:{originalSource:`() => {
153
- const [value, setValue] = useState('123|%');
154
- const [validation, setValidation] = useState<string | null>(null);
155
- const predictedMessage = 'This should be visible when an error appears';
156
- const handleValidation = (name: string, error: string | null) => {
157
- setValidation(error);
158
- return {
159
- name,
160
- error
161
- };
162
- };
163
- return <>
164
- <h4>3rd party validation message when inputting invalid value:</h4>
165
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
166
- <br />
167
- <Spacer />
168
- <h4>Original validation message: </h4>
169
- <Message message={{
170
- heading: validation,
171
- visible: true
172
- }} />
173
- </>;
174
- }`,...(we=(Se=j.parameters)==null?void 0:Se.docs)==null?void 0:we.source}}};var je,ke,fe;k.parameters={...k.parameters,docs:{...(je=k.parameters)==null?void 0:je.docs,source:{originalSource:`() => {
175
- const [value, setValue] = useState('123|m');
176
- const [placeholder, setPlaceholder] = useState('');
177
- const [initUnit, setInitUnit] = useState('km');
178
- const setPlaceholderValue = () => {
179
- setInitUnit('ft');
180
- setPlaceholder('placeholder');
181
- setValue('|m');
182
- };
183
- return <>
184
- <h4>Empty value case:</h4>
185
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
186
- <br />
187
- <Spacer />
188
- <Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
189
- </>;
190
- }`,...(fe=(ke=k.parameters)==null?void 0:ke.docs)==null?void 0:fe.source}}};var _e,Pe,Ee;f.parameters={...f.parameters,docs:{...(_e=f.parameters)==null?void 0:_e.docs,source:{originalSource:`() => {
191
- const [value, setValue] = useState('123|m');
192
- const [unit, setUnit] = useState('m');
193
- return <>
194
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
195
- <Spacer />
196
- <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
197
- </>;
198
- }`,...(Ee=(Pe=f.parameters)==null?void 0:Pe.docs)==null?void 0:Ee.source}}};const xa=["Default","InitUnit","NotKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","PredefinedOptionsMenu","AutomaticValues","ValidationCallback","AllowEmptyPUI","OnSwitchUnit"];export{k as AllowEmptyPUI,w as AutomaticValues,P as Default,c as Disabled,y as DisabledNoConversion,V as DisabledUnitWithUnitKey,I as DisabledUnitWithoutUnitKey,A as DisabledWithEnabledUnitMenu,U as Error,m as InitUnit,x as InternalValidationError,C as NoConversion,h as NotKnownUnit,f as OnSwitchUnit,S as PredefinedOptionsMenu,b as Small,j as ValidationCallback,v as Width,xa as __namedExportsOrder,Ua as default};
@@ -1,215 +0,0 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as b}from"./index-C0x1JmaP.js";import{w as f,u as l,e as r,f as V,a as D}from"./index-DMAnyMX5.js";import{U as u}from"./unit-input-DTOrVqdm.js";import{B as o}from"./button-Cbv7WK6k.js";import{S as g}from"./spacer-BWoNR27H.js";import{D as fe}from"./divider-DY9nJ_7N.js";import{R as Ce,C as F}from"./row-Bmiy2Lh0.js";import{F as U}from"./field-HrLaMLbx.js";import{M as pe}from"./message-BRyKdRaX.js";import{G as ge}from"./grid-DRkC-bt8.js";import{C as v}from"./card-EcjmryU9.js";import{H as y}from"./heading-CRNoBc7q.js";import{T as N}from"./toggle-BbFVf61v.js";import{T as q}from"./text-B3-TSWok.js";import{S as xe}from"./select-Cwks-WA0.js";import{I as he}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./initialize-context-Y03pJPr5.js";import"./number-input-B3_gmeWr.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-CJed_LLR.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const ht={title:"Forms/UnitInput/Test Cases",component:u,tags:["!autodocs"]},C=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),placeholder:"Type a value...",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};C.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const x=()=>{const[i,a]=d.useState("|m");return e.jsx(u,{name:"example-ft",onChange:t=>a(t.target.value),placeholder:"7|ft",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId-ft"})};x.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Handle input with unit only",async()=>{const n=t.getByTestId("testId-ft");await r(t.getByDisplayValue("")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Clear input and check placeholder",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await r(n).toHaveAttribute("placeholder","2.13")}),await a("Type a correct numeric value and ensure no error",async()=>{const n=t.getByTestId("testId-ft");await l.type(n,"123"),await r(t.getByDisplayValue("123")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Remove value, type incorrect value and check for error",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await l.type(n,"123abc"),await r(t.getByDisplayValue("123abc")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const T=i=>{const[a,t]=d.useState("123|m"),[s,n]=d.useState("223|m"),[c,h]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Change initUnit",onClick:()=>h(c==="m"?"ft":"m")}),e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,initUnit:c,onSwitchUnit:h}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,initUnit:c,onSwitchUnit:h}),e.jsx(fe,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,onSwitchUnit:h}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,onSwitchUnit:h})]})};T.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const I=()=>{const i="500px",[a,t]=d.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Ce,{children:[e.jsxs(F,{width:"25%",children:[e.jsx(o,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(F,{width:"25%",children:[e.jsx(o,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(U,{label:"Normal PUI",children:e.jsx(u,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:i,placeholder:"value|unit"})}),e.jsx(U,{label:"Disabled validation",children:e.jsx(u,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:i})}),e.jsx(U,{label:"Disabled validation and manual error",children:e.jsx(u,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:i})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};I.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const j=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("123|ft");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Storage State (Redux)"}),children:[s,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>n(b.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:i&&e.jsx(u,{name:"example",onChange:c=>n(c.target.value),value:s,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},S=()=>e.jsxs(e.Fragment,{children:[e.jsx(q,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),w=()=>e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(g,{}),e.jsx(u,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});w.play=async({canvasElement:i,step:a})=>{const t=f(i);await a("Can enter decimal values",async()=>{await r(t.getByDisplayValue("170")).toBeInTheDocument(),await r(t.getByDisplayValue("")).toBeInTheDocument()})};const B=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("psi"),[c,h]=d.useState(!1),[m,ve]=d.useState(!0),[M,ye]=d.useState(!0),[R,W]=d.useState("672.2388357750001|bar"),[O,be]=d.useState("");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Settings"}),children:[e.jsx(U,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:c,onChange:p=>h(p.target.checked)})}),e.jsx(U,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:m,onChange:p=>ve(p.target.checked)})}),e.jsx(U,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:M,onChange:p=>ye(p.target.checked)})})]}),e.jsxs(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:[e.jsx(q,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(g,{}),e.jsx(q,{warning:!0,children:"Note: UnitInput uses convertSamePrecision internally (decision prior to cosmetic value implementation). This means not all rounding noise occurrences seen in NumberInput will be reproducible in UnitInput, because they get rounded off by other logic."}),e.jsx(g,{}),i&&e.jsx(u,{name:"Example",unitkey:"pressure",initUnit:s,unitTemplate:{pressure:"psi"},value:R,onChange:p=>{const{value:E}=p.target;E&&W(E)},enableDisplayRounding:c,enableCosmeticRounding:m,error:b.convertAndGetValue(R,"bar")>=0?"":"Value must be positive",validationCallback:(p,E)=>{be(E??"")},convertBackToStorageUnit:M})]}),e.jsx(v,{heading:e.jsx(y,{children:"Unit Template"}),children:e.jsx(xe,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:s,width:70,onChange:p=>n(p.target.value)})}),e.jsx(v,{heading:e.jsx(y,{children:"Test Validation Callback"}),children:O&&e.jsx(pe,{message:{content:O,icon:!0,type:"Error",visible:!0}})}),e.jsxs(v,{heading:e.jsx(y,{children:"Storage State / Redux"}),children:[R,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>W(b.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},k=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};k.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Can enter decimal values",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123.123456789"),await r(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"-1.12e3"),await r(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123,456"),await r(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"0.0000000023"),await r(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"999999999999"),await r(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const n=t.getByTestId("testId"),c=t.getByTestId("testId-menu");await l.clear(n),await l.type(n,"456.1"),await l.click(c),await l.click(s.getByTestId("testId-unit-ft")),await r(t.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};C.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};x.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"PlaceholderWithUnit"};T.__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:"(evt: TOnChangeEvent) => void",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ target: TOnChangeEventTarget }",signature:{properties:[{key:"target",value:{name:"union",raw:`| TOnChangeEventBaseTarget
2
- | (TOnChangeEventBaseTarget & {
3
- predefinedSelected: boolean;
4
- predefinedOption: IPredefinedOption;
5
- })`,elements:[{name:"signature",type:"object",raw:"{ name: string; value: string }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"string",required:!0}}]}},{name:"unknown"}],required:!0}}]}},name:"evt"}],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:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:""},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:""},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:""}}};I.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};j.__docgenInfo={description:"",methods:[],displayName:"ManagedTestCase"};S.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};w.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"OW_17784TestCase"};B.__docgenInfo={description:"",methods:[],displayName:"DemoCosmeticRounding"};k.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var _,H,P;C.parameters={...C.parameters,docs:{...(_=C.parameters)==null?void 0:_.docs,source:{originalSource:`() => {
6
- const [value, setValue] = useState('123|m');
7
- return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} placeholder="Type a value..." value={value} initUnit="m" unitkey="depth" unitTemplate={{
8
- depth: 'm'
9
- }} testId="testId" />;
10
- }`,...(P=(H=C.parameters)==null?void 0:H.docs)==null?void 0:P.source}}};var A,G,L;x.parameters={...x.parameters,docs:{...(A=x.parameters)==null?void 0:A.docs,source:{originalSource:`() => {
11
- const [value, setValue] = useState('|m');
12
- return <UnitInput name="example-ft" onChange={evt => setValue(evt.target.value)} placeholder="7|ft" value={value} initUnit="m" unitkey="depth" unitTemplate={{
13
- depth: 'm'
14
- }} testId="testId-ft" />;
15
- }`,...(L=(G=x.parameters)==null?void 0:G.docs)==null?void 0:L.source}}};var z,J,Y;T.parameters={...T.parameters,docs:{...(z=T.parameters)==null?void 0:z.docs,source:{originalSource:`(args: IUnitInputProps) => {
16
- const [value, setValue] = useState('123|m');
17
- const [value2, setValue2] = useState('223|m');
18
- const [initUnit, setInitUnit] = useState('ft');
19
- return <>
20
- <Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
21
- <Spacer />
22
- <Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
23
- <Spacer />
24
- <UnitInput name="example" onChange={evt => {
25
- setValue(evt.target.value);
26
- }} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
27
- <Spacer />
28
- <UnitInput name="example2" onChange={evt => {
29
- setValue2(evt.target.value);
30
- }} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
31
- <Divider />
32
- <h4>Without initUnit property (taken from the redux store)</h4>
33
- <UnitInput name="example" onChange={evt => {
34
- setValue(evt.target.value);
35
- }} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
36
- <UnitInput name="example2" onChange={evt => {
37
- setValue2(evt.target.value);
38
- }} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
39
- </>;
40
- }`,...(Y=(J=T.parameters)==null?void 0:J.docs)==null?void 0:Y.source}}};var Z,K,Q;I.parameters={...I.parameters,docs:{...(Z=I.parameters)==null?void 0:Z.docs,source:{originalSource:`() => {
41
- const width = '500px';
42
- const [value, setValue] = useState<any>(undefined);
43
- return <>
44
- <h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
45
- <Row>
46
- <Column width="25%">
47
- <Button label="Change value infinity" onClick={() => setValue(Infinity)} />
48
- <br />
49
- <Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
50
- <br />
51
- <Button label="Change value null" onClick={() => setValue(null)} />
52
- <br />
53
- <Button label="Change value - undefined" onClick={() => setValue(undefined)} />
54
- <br />
55
- <Button label="Change value - NaN" onClick={() => setValue(NaN)} />
56
- <br />
57
- <Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
58
- <br />
59
- <Button label="Change value - empty string" onClick={() => setValue('')} />
60
- </Column>
61
- <Column width="25%">
62
- <Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
63
- <br />
64
- <Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
65
- <br />
66
- <Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
67
- <br />
68
- <Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
69
- <br />
70
- <Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
71
- <br />
72
- <Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
73
- </Column>
74
- </Row>
75
- <br />
76
- <Field label="Normal PUI">
77
- <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
78
- </Field>
79
- <Field label="Disabled validation">
80
- <UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
81
- </Field>
82
- <Field label="Disabled validation and manual error">
83
- <UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
84
- </Field>
85
- <Message message={{
86
- heading: 'Current value inside PUI: ' + value,
87
- visible: true
88
- }} />
89
- </>;
90
- }`,...(Q=(K=I.parameters)==null?void 0:K.docs)==null?void 0:Q.source}}};var X,$,ee;j.parameters={...j.parameters,docs:{...(X=j.parameters)==null?void 0:X.docs,source:{originalSource:`() => {
91
- const [visible, setVisible] = useState(true);
92
- const triggerRerender = () => {
93
- setVisible(false);
94
- setTimeout(() => setVisible(true), 0);
95
- };
96
- const [value, setValue] = useState('123|ft');
97
- return <Grid columns="1fr 1fr" gap>
98
- <Card heading={<Heading>Storage State (Redux)</Heading>}>
99
- {value}
100
- <Spacer />
101
- <Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'ft'))} />
102
- </Card>
103
- <Card heading={<Heading icon={<Icon icon="refresh" testId="triggerRerenderTestId" />} onIconClick={triggerRerender}>
104
- UnitInput
105
- </Heading>}>
106
- {visible && <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
107
- depth: 'm'
108
- }} />}
109
- </Card>
110
- </Grid>;
111
- }`,...(ee=($=j.parameters)==null?void 0:$.docs)==null?void 0:ee.source}}};var te,ne,ae;S.parameters={...S.parameters,docs:{...(te=S.parameters)==null?void 0:te.docs,source:{originalSource:`() => {
112
- return <>
113
- <Text faint>
114
- Reproduce OW-10614 rounding noise bug when storing values in a different
115
- unit to the display unit
116
- </Text>
117
- <Spacer />
118
- <UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
119
- pressure: 'psi'
120
- }} />
121
- <Spacer />
122
- <UnitInput name="example2" onChange={() => {}} value={withUnit(convertAndGetValue('8642|lbf', 'tonneForce'), 'tonneForce')} initUnit="lbf" unitkey="force" unitTemplate={{
123
- force: 'tonneForce'
124
- }} />
125
- </>;
126
- }`,...(ae=(ne=S.parameters)==null?void 0:ne.docs)==null?void 0:ae.source}}};var ie,re,se;w.parameters={...w.parameters,docs:{...(ie=w.parameters)==null?void 0:ie.docs,source:{originalSource:`() => {
127
- return <>
128
- <UnitInput name="example" unitkey="moleWeight" initUnit="g/mol" doNotConvertValue //reproduces OW_17784
129
- value="170|g/mol" unitTemplate={{
130
- moleWeight: 'g/mol'
131
- }} testId="case1" />
132
- <Spacer />
133
- <UnitInput name="gor" unitkey="moleWeight" initUnit="gor" value="Infinity|SCF/STB" testId="case2" />
134
- </>;
135
- }`,...(se=(re=w.parameters)==null?void 0:re.docs)==null?void 0:se.source}}};var le,oe,ue;B.parameters={...B.parameters,docs:{...(le=B.parameters)==null?void 0:le.docs,source:{originalSource:`() => {
136
- const [visible, setVisible] = useState(true);
137
- const triggerRerender = () => {
138
- setVisible(false);
139
- setTimeout(() => setVisible(true), 0);
140
- };
141
- const [preferredUnit, setPreferredUnit] = useState('psi');
142
- const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
143
- const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
144
- const [convertBackToStorageUnit, setConvertBackToStorageUnit] = useState(true);
145
- const [value, setValue] = useState('672.2388357750001|bar');
146
- const [callBackError, setCallBackError] = useState('');
147
- return <Grid columns="1fr 1fr" gap>
148
- <Card heading={<Heading>Settings</Heading>}>
149
- <Field label="Enable display rounding:" labelLeft labelWidth={200}>
150
- <Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
151
- </Field>
152
- <Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
153
- <Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
154
- </Field>
155
- <Field label="Convert back to storage unit (onChange):" labelLeft labelWidth={200}>
156
- <Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
157
- </Field>
158
- </Card>
159
- <Card heading={<Heading icon={<Icon icon="refresh" testId="triggerRerenderTestId" />} onIconClick={triggerRerender}>
160
- UnitInput
161
- </Heading>}>
162
- <Text faint>
163
- Cosmetic Rounding Test Case: type 9750 then return (compare with
164
- enableCosmeticRounding on and off)
165
- </Text>
166
- <Spacer />
167
- <Text warning>
168
- Note: UnitInput uses convertSamePrecision internally (decision prior
169
- to cosmetic value implementation). This means not all rounding noise
170
- occurrences seen in NumberInput will be reproducible in UnitInput,
171
- because they get rounded off by other logic.
172
- </Text>
173
- <Spacer />
174
- {visible && <UnitInput name="Example" unitkey="pressure" initUnit={preferredUnit} unitTemplate={{
175
- pressure: 'psi'
176
- }} value={value} onChange={evt => {
177
- const {
178
- value
179
- } = evt.target;
180
- if (value) {
181
- setValue(value);
182
- }
183
- }} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={convertAndGetValue(value, 'bar') >= 0 ? '' : 'Value must be positive'} validationCallback={(name, error) => {
184
- setCallBackError(error ?? '');
185
- }} convertBackToStorageUnit={convertBackToStorageUnit} />}
186
- </Card>
187
- <Card heading={<Heading>Unit Template</Heading>}>
188
- <Select options={[{
189
- label: 'Bar',
190
- value: 'bar'
191
- }, {
192
- label: 'psi',
193
- value: 'psi'
194
- }]} value={preferredUnit} width={70} onChange={evt => setPreferredUnit(evt.target.value)} />
195
- </Card>
196
- <Card heading={<Heading>Test Validation Callback</Heading>}>
197
- {callBackError && <Message message={{
198
- content: callBackError,
199
- icon: true,
200
- type: 'Error',
201
- visible: true
202
- }} />}
203
- </Card>
204
- <Card heading={<Heading>Storage State / Redux</Heading>}>
205
- {value}
206
- <Spacer />
207
- <Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'bar'))} />
208
- </Card>
209
- </Grid>;
210
- }`,...(ue=(oe=B.parameters)==null?void 0:oe.docs)==null?void 0:ue.source}}};var de,ce,me;k.parameters={...k.parameters,docs:{...(de=k.parameters)==null?void 0:de.docs,source:{originalSource:`() => {
211
- const [value, setValue] = useState('123|m');
212
- return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
213
- depth: 'm'
214
- }} testId="testId" />;
215
- }`,...(me=(ce=k.parameters)==null?void 0:ce.docs)==null?void 0:me.source}}};const vt=["Placeholder","PlaceholderWithUnit","TestExternalStateChangeWithSynchronizedUnits","TestEdgeCases","ManagedTestCase","OW_10614TestCase","OW_17784TestCase","DemoCosmeticRounding","TestUserInput"];export{B as DemoCosmeticRounding,j as ManagedTestCase,S as OW_10614TestCase,w as OW_17784TestCase,C as Placeholder,x as PlaceholderWithUnit,I as TestEdgeCases,T as TestExternalStateChangeWithSynchronizedUnits,k as TestUserInput,vt as __namedExportsOrder,ht as default};