@oliasoft-open-source/react-ui-library 4.2.0-beta-3 → 4.2.1-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 (136) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +35 -17
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/Color-6VNJS4EI-38f93e87.js +1 -0
  5. package/dist/storybook/assets/DocsRenderer-NNNQARDV-850c5573.js +1 -0
  6. package/dist/storybook/assets/WithTooltip-4HIR6TLV-c574e731.js +1 -0
  7. package/dist/storybook/assets/{accordion-168fa7c5.js → accordion-1b587708.js} +1 -1
  8. package/dist/storybook/assets/{accordion.stories-0f8af16e.js → accordion.stories-41aed20e.js} +2 -2
  9. package/dist/storybook/assets/{actions-2d4e1c8e.js → actions-83a2a04e.js} +1 -1
  10. package/dist/storybook/assets/{actions.stories-81a7cb7a.js → actions.stories-a38cd26e.js} +1 -1
  11. package/dist/storybook/assets/{afe.stories-afb9be07.js → afe.stories-a4fbd6ce.js} +2 -2
  12. package/dist/storybook/assets/{badge.stories-5ce7957f.js → badge.stories-1cbf35f9.js} +1 -1
  13. package/dist/storybook/assets/{blowout.stories-ee7f932b.js → blowout.stories-3d16e5ec.js} +1 -1
  14. package/dist/storybook/assets/{button-74c97e4a.js → button-050c998a.js} +1 -1
  15. package/dist/storybook/assets/{button-group-fa895d0c.js → button-group-0176fca3.js} +1 -1
  16. package/dist/storybook/assets/{button-group.stories-22f072b7.js → button-group.stories-7659a587.js} +1 -1
  17. package/dist/storybook/assets/{button.stories-9b954335.js → button.stories-5f73ddef.js} +1 -1
  18. package/dist/storybook/assets/buttons-and-links-dab2a936.js +14 -0
  19. package/dist/storybook/assets/{card.stories-537a1772.js → card.stories-0437a4e2.js} +1 -1
  20. package/dist/storybook/assets/{casing-loads.stories-cfbab702.js → casing-loads.stories-d5882170.js} +2 -2
  21. package/dist/storybook/assets/{cell.stories-524a7418.js → cell.stories-0ae4bf08.js} +2 -2
  22. package/dist/storybook/assets/{check-box-e21258d5.js → check-box-b38490e5.js} +1 -1
  23. package/dist/storybook/assets/{check-box.stories-5f7d06e0.js → check-box.stories-9bf1c260.js} +1 -1
  24. package/dist/storybook/assets/{chunk-HLWAVYOI-1b1e8383.js → chunk-HLWAVYOI-48e544a6.js} +1 -1
  25. package/dist/storybook/assets/color-c848f869.js +25 -0
  26. package/dist/storybook/assets/{column.stories-ae7588c5.js → column.stories-d5ca2c42.js} +1 -1
  27. package/dist/storybook/assets/{dialog-cd58dd09.js → dialog-c036ff34.js} +1 -1
  28. package/dist/storybook/assets/{drawer-7f450988.js → drawer-308b0a03.js} +1 -1
  29. package/dist/storybook/assets/{drawer.stories-39625e91.js → drawer.stories-d76c0577.js} +2 -2
  30. package/dist/storybook/assets/{empty.stories-e0e3ac78.js → empty.stories-30fdd793.js} +1 -1
  31. package/dist/storybook/assets/extends-98964cd2.js +1 -0
  32. package/dist/storybook/assets/{field-a094cd72.js → field-248df38c.js} +1 -1
  33. package/dist/storybook/assets/{field.stories-f1318053.js → field.stories-60d1a82f.js} +1 -1
  34. package/dist/storybook/assets/{file-input.stories-1c6ce0ea.js → file-input.stories-6878a9b8.js} +1 -1
  35. package/dist/storybook/assets/{flex.stories-09e9c602.js → flex.stories-6a278b40.js} +1 -1
  36. package/dist/storybook/assets/footer.stories-50a2e3db.js +3 -0
  37. package/dist/storybook/assets/form.stories-fb337772.js +49 -0
  38. package/dist/storybook/assets/formation.stories-3c9cd637.js +74 -0
  39. package/dist/storybook/assets/{formatter-SWP5E3XI-d3a9e021.js → formatter-SWP5E3XI-3022f287.js} +2 -2
  40. package/dist/storybook/assets/{heading-d29eb744.js → heading-39e599c8.js} +1 -1
  41. package/dist/storybook/assets/{heading.stories-9689bddc.js → heading.stories-6ff7f5ed.js} +1 -1
  42. package/dist/storybook/assets/{help-icon-d4189b1b.js → help-icon-c0abd380.js} +1 -1
  43. package/dist/storybook/assets/{help-icon.stories-15d1620d.js → help-icon.stories-a30b7058.js} +1 -1
  44. package/dist/storybook/assets/icon-8acf9925.js +8 -0
  45. package/dist/storybook/assets/{icon.stories-8dae69e1.js → icon.stories-466d158f.js} +1 -1
  46. package/dist/storybook/assets/iframe-c049b5de.js +1 -0
  47. package/dist/storybook/assets/{index-5d28dded.js → index-facfe879.js} +4 -4
  48. package/dist/storybook/assets/{index.es-85cc7dfc.js → index.es-37e2ce0d.js} +4 -4
  49. package/dist/storybook/assets/inheritsLoose-c82a83d4.js +1 -0
  50. package/dist/storybook/assets/{input-d68625a5.js → input-05f21b51.js} +1 -1
  51. package/dist/storybook/assets/{input-group.stories-a2a3400e.js → input-group.stories-602e1e93.js} +2 -2
  52. package/dist/storybook/assets/{input-validation-141270c5.js → input-validation-36225c65.js} +2 -2
  53. package/dist/storybook/assets/{input.stories-164d93ab.js → input.stories-bf58ba7c.js} +1 -1
  54. package/dist/storybook/assets/{inputs-851ed326.js → inputs-76e61ee6.js} +2 -2
  55. package/dist/storybook/assets/{label-13d490a3.js → label-e6d15b59.js} +1 -1
  56. package/dist/storybook/assets/{label.stories-427ba162.js → label.stories-1c98204a.js} +1 -1
  57. package/dist/storybook/assets/layout-forms-e5b070bb.js +16 -0
  58. package/dist/storybook/assets/{layout-general-2e5a4012.js → layout-general-86c12240.js} +2 -2
  59. package/dist/storybook/assets/{list-0dc3df85.js → list-bc0d9ad9.js} +1 -1
  60. package/dist/storybook/assets/{list-heading-88cc8a9b.js → list-heading-2215213f.js} +1 -1
  61. package/dist/storybook/assets/{list.stories-5715452e.js → list.stories-c8b4f325.js} +2 -2
  62. package/dist/storybook/assets/{list.stories-data-94f7c623.js → list.stories-data-ba40864f.js} +1 -1
  63. package/dist/storybook/assets/{loader.stories-6107832a.js → loader.stories-4e8e8df7.js} +1 -1
  64. package/dist/storybook/assets/{menu.stories-927adf3d.js → menu.stories-8d724757.js} +1 -1
  65. package/dist/storybook/assets/{message-7e627e60.js → message-0b5ae3c5.js} +1 -1
  66. package/dist/storybook/assets/{message.stories-f41a0c22.js → message.stories-9b9c40c4.js} +1 -1
  67. package/dist/storybook/assets/{modal.stories-0e068cc1.js → modal.stories-1b13be75.js} +2 -2
  68. package/dist/storybook/assets/{number-input-7d49b0b3.js → number-input-cfbd9eb7.js} +1 -1
  69. package/dist/storybook/assets/{number-input.stories-02528124.js → number-input.stories-8137782e.js} +2 -2
  70. package/dist/storybook/assets/{option-dropdown.stories-5030bdb8.js → option-dropdown.stories-4c391727.js} +1 -1
  71. package/dist/storybook/assets/{padding-and-spacing-d5b7037c.js → padding-and-spacing-27184e3b.js} +2 -2
  72. package/dist/storybook/assets/{page.stories-7cb68fed.js → page.stories-8d0476d7.js} +1 -1
  73. package/dist/storybook/assets/{pagination-8aade846.js → pagination-443065a8.js} +1 -1
  74. package/dist/storybook/assets/{pagination.stories-423b4938.js → pagination.stories-985230f7.js} +2 -2
  75. package/dist/storybook/assets/{pop-confirm.stories-81b30901.js → pop-confirm.stories-3016f322.js} +1 -1
  76. package/dist/storybook/assets/{popover-06e375a5.js → popover-c1234faa.js} +1 -1
  77. package/dist/storybook/assets/popover.stories-7542a367.js +1 -0
  78. package/dist/storybook/assets/preview-2ce67243.js +1 -0
  79. package/dist/storybook/assets/{preview-3a1dcfd9.js → preview-b8e17d34.js} +3 -3
  80. package/dist/storybook/assets/projects.stories-47d63f05.js +47 -0
  81. package/dist/storybook/assets/{radio-button-135a9615.js → radio-button-d69b72e4.js} +1 -1
  82. package/dist/storybook/assets/{radio-button.stories-0e8377ea.js → radio-button.stories-6ff0dc9b.js} +1 -1
  83. package/dist/storybook/assets/{reservoirs.stories-6b14a37f.js → reservoirs.stories-537002ca.js} +2 -2
  84. package/dist/storybook/assets/{rich-text-input.stories-661f34f1.js → rich-text-input.stories-383819b4.js} +3 -3
  85. package/dist/storybook/assets/{row.stories-d5b6b4a6.js → row.stories-c12a3e52.js} +2 -2
  86. package/dist/storybook/assets/select-d4593fc0.js +1 -0
  87. package/dist/storybook/assets/{select.stories-60f055e6.js → select.stories-6651d3f2.js} +2 -2
  88. package/dist/storybook/assets/{side-bar-88e8cf41.js → side-bar-10cceacd.js} +1 -1
  89. package/dist/storybook/assets/{side-bar.stories-2c06f8a6.js → side-bar.stories-02211e0d.js} +1 -1
  90. package/dist/storybook/assets/{site.stories-dee8ce1c.js → site.stories-9486039d.js} +2 -2
  91. package/dist/storybook/assets/slider-5d5442fe.js +7 -0
  92. package/dist/storybook/assets/{slider.stories-79ab0e97.js → slider.stories-a55df653.js} +2 -2
  93. package/dist/storybook/assets/{spacer.stories-38071af8.js → spacer.stories-a2798d47.js} +1 -1
  94. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-abcfc30f.js +1 -0
  95. package/dist/storybook/assets/{table-da6f6045.js → table-134da40b.js} +1 -1
  96. package/dist/storybook/assets/{table.stories-67a3023a.js → table.stories-8dd2a568.js} +2 -2
  97. package/dist/storybook/assets/{table.stories-data-8a836b92.js → table.stories-data-ddbcf8c3.js} +1 -1
  98. package/dist/storybook/assets/{textarea-d48efea2.js → textarea-5ebdd171.js} +1 -1
  99. package/dist/storybook/assets/{textarea.stories-89c8afd7.js → textarea.stories-02879684.js} +1 -1
  100. package/dist/storybook/assets/{title.stories-5b4a226c.js → title.stories-2ba6aa87.js} +2 -2
  101. package/dist/storybook/assets/{toaster-541ce85b.js → toaster-f096ba56.js} +1 -1
  102. package/dist/storybook/assets/{toaster.stories-5e4d95b1.js → toaster.stories-66162195.js} +1 -1
  103. package/dist/storybook/assets/{toggle-bb34b2a2.js → toggle-6f4d5797.js} +1 -1
  104. package/dist/storybook/assets/{toggle.stories-b771ed81.js → toggle.stories-a289f544.js} +1 -1
  105. package/dist/storybook/assets/{tooltip-23e84186.js → tooltip-856042a7.js} +1 -1
  106. package/dist/storybook/assets/{tooltip.stories-e8ba5fff.js → tooltip.stories-666868d0.js} +1 -1
  107. package/dist/storybook/assets/{tooltip.test-case.stories-9817078b.js → tooltip.test-case.stories-4c1ea273.js} +1 -1
  108. package/dist/storybook/assets/{top-bar-a84b9365.js → top-bar-2c70083e.js} +1 -1
  109. package/dist/storybook/assets/{top-bar.stories-e93330f0.js → top-bar.stories-bbfb7220.js} +1 -1
  110. package/dist/storybook/assets/{top-bar.testcase.stories-3a824a14.js → top-bar.testcase.stories-1d4c6e3a.js} +1 -1
  111. package/dist/storybook/assets/{tree.stories-590bdd69.js → tree.stories-729aebd7.js} +1 -1
  112. package/dist/storybook/assets/unit-input.stories-035fa696.js +265 -0
  113. package/dist/storybook/iframe.html +1 -1
  114. package/dist/storybook/index.json +1 -1
  115. package/dist/storybook/project.json +1 -1
  116. package/dist/storybook/stories.json +1 -1
  117. package/package.json +1 -1
  118. package/dist/storybook/assets/Color-6VNJS4EI-4a5d7280.js +0 -1
  119. package/dist/storybook/assets/DocsRenderer-NNNQARDV-72503a2d.js +0 -1
  120. package/dist/storybook/assets/WithTooltip-4HIR6TLV-23437932.js +0 -1
  121. package/dist/storybook/assets/buttons-and-links-c7506f52.js +0 -14
  122. package/dist/storybook/assets/color-e373f623.js +0 -25
  123. package/dist/storybook/assets/footer.stories-57f07ea2.js +0 -3
  124. package/dist/storybook/assets/form.stories-45c0cd59.js +0 -49
  125. package/dist/storybook/assets/formation.stories-5eeaa826.js +0 -74
  126. package/dist/storybook/assets/icon-e9cbb4d7.js +0 -8
  127. package/dist/storybook/assets/iframe-210f2f48.js +0 -1
  128. package/dist/storybook/assets/inheritsLoose-d4851ab8.js +0 -1
  129. package/dist/storybook/assets/layout-forms-8fb9eb93.js +0 -16
  130. package/dist/storybook/assets/popover.stories-f651a81c.js +0 -1
  131. package/dist/storybook/assets/preview-78133dba.js +0 -1
  132. package/dist/storybook/assets/projects.stories-3884a80c.js +0 -47
  133. package/dist/storybook/assets/select-205cd538.js +0 -1
  134. package/dist/storybook/assets/slider-160e2152.js +0 -7
  135. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-35b98f86.js +0 -1
  136. package/dist/storybook/assets/unit-input.stories-50ac8b0f.js +0 -257
@@ -0,0 +1,265 @@
1
+ import{j as e}from"./jsx-runtime-f961835c.js";import{r as m}from"./index-f80c8c95.js";import{d as r,r as tn}from"./index-57d7693e.js";import{c as nn}from"./index-a80ed1cf.js";import{M as Se}from"./actions-83a2a04e.js";import{I as an}from"./input-group-addon-f8f6683a.js";import{B as d}from"./button-050c998a.js";import{T as ln}from"./tooltip-856042a7.js";import{I as rn}from"./input-group-20c3add3.js";import{S as N}from"./spacer-54db0620.js";import{T as sn}from"./text-ad1f5f1d.js";import{I as un}from"./input-05f21b51.js";import{M as Ee}from"./types-cc224262.js";import{l as S}from"./lodash-75c70a11.js";import{D as on}from"./divider-182aa58c.js";import{R as _t,C as pe}from"./row-2299f0e7.js";import{F as I}from"./field-248df38c.js";import{a as ge}from"./message-0b5ae3c5.js";import"./index-54f0d271.js";import"./common-types-2c81813f.js";import"./disabled-context-d654f6ff.js";import"./icon-8acf9925.js";import"./inheritsLoose-c82a83d4.js";import"./tslib.es6-dfef685f.js";import"./index-c89a1915.js";import"./types-332ceaf3.js";import"./badge-20e7ee0b.js";import"./spinner-a81ebe38.js";import"./index-3d476d02.js";import"./styled-components.browser.esm-416d73e5.js";import"./label-e6d15b59.js";import"./help-icon-c0abd380.js";const dn=()=>{const t=m.useRef(null);return m.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},cn=t=>{const a=m.useRef();return m.useEffect(()=>{a.current=t},[t]),a.current},mn=(t,a)=>{const n=a==null?void 0:a[t];return n||(console.log(`Warning: 'unitTemplate' does not define a preferred unit for '${t}'. Defaulting to standard unit.`),r.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const Ot=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),Bt=(t="",a,n="",i=!1)=>{if(i)return t;if(a&&!Ot(t))try{const c=r.isValueWithUnit(t)?t:r.withUnit(t,n),u=r.convertSamePrecision(c,a);return r.getValue(u)}catch{}return t},F=(t="",a,n,i)=>{if(i)return t;const c=r.isValueWithUnit(t),u=r.getValue(t);return Ot(u)?u:c?Bt(u,a,n,i):t},Ne=t=>S.isObject(t)&&!S.isArray(t)&&!S.isFunction(t)?S.get(t,"fieldName",""):typeof t=="string"?t:"",pn=t=>S.isObjectLike(t)&&S.has(t,"message"),gn=t=>typeof t=="string"?t:pn(t)?t.message:null;var hn=tn();const vn=t=>t.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g))===0,Ae=(t,a)=>{var j;const{allowEmpty:n=!1,autoValue:i,placeholder:c,disabledValidation:u=!1}=a||{},s=String(t);if(u||i||c)return null;const g=hn.isValueWithUnit(s)?r.getValue(s):s;if(n&&g==="")return null;if(vn(g))return"Invalid number format due to leading zeroes";const p=r.validateNumber(g);if(!p.valid){const le=((j=p==null?void 0:p.errors)==null?void 0:j[0])??null;return gn(le)}return null},Pe=(t="")=>{var a;return(a=r.KNOWN_UNITS)==null?void 0:a.includes(t)},fn=(t,a)=>{const n=r.getUnit(t||"");return Pe(a)&&Pe(n)},Cn="_predefinedMenuActive_1yvt4_1",bn={predefinedMenuActive:Cn},h=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:i=!1,error:c=null,left:u=!1,small:s=!1,width:g="100%",value:p,unitkey:j="",initUnit:le,noConversion:qt=!1,onChange:re=()=>{},onClick:Un=()=>{},onFocus:Wt=()=>{},onSwitchUnit:he=()=>{},unitTemplate:ve,doNotConvertValue:A=!1,testId:w,warning:Rt=null,predefinedOptions:x,initialPredefinedOption:Tt=!1,shouldLinkAutomaticly:fe=!0,selectedPredefinedOptionKey:Ce,validationCallback:be=()=>({name:"",error:null}),disabledValidation:ye=!1,allowEmpty:Ue=!1,autoValue:V})=>{typeof p=="number"&&(p=`${p}`);const Lt=dn(),[se="",P=""]=p!==void 0?r.split(p):[],xe=V?r.getUnit(V):"",Ve=m.useMemo(()=>mn(j,ve),[j,ve]),ie=fn(p,Ve),y=le||Ve||P,Kt=cn(y),Ie=F(p,y,P,A),je=F(V,y,xe,A),$t=Ie!==""?{value:Ie,unit:y}:je!==""?{value:je,unit:y}:{value:se,unit:P},[v,Y]=m.useState($t),[Ht,ue]=m.useState(null),[k,oe]=m.useState(Tt?b.PREDEFINED:b.CUSTOM),de=se===""&&V,D=x&&x.find(l=>{if(Ce)return Ce===l.valueKey;const o=r.isValueWithUnit(l.value)?r.getUnit(l.value):"";return r.withUnit(Bt(p,o),o)===l.value}),zt=()=>{if(j)try{const l=de?V:p??"";let o=r.altUnitsList(l,j);return r.getValue(l)===""?o.map(f=>["",f[1]]):o}catch{return null}},Jt=l=>{const o=Ne(t),f=l.target,{value:U,selectionStart:X}=f,we=r.cleanNumStr(U.replaceAll(" ","").replaceAll("|","")),ce=r.withUnit(we,(v==null?void 0:v.unit)||""),Qt=r.getValue(ce),me=Ae(Qt,{allowEmpty:Ue,autoValue:V,placeholder:a,disabledValidation:ye});if(me===null){re({target:{value:ce,name:o}});const[Xt,en]=r.split(ce);Y({value:Xt,unit:en}),ue(null),be(o,null)}else Y({value:we,unit:v.unit}),ue(me),be(o,me);Lt(()=>{f.selectionStart=X,f.selectionEnd=X})},Yt=(l,o)=>{o===v.unit||isNaN(Number(l))||(Y({value:l,unit:o}),he&&he(o))};m.useEffect(()=>{if(y){let f,U="";Kt!==y&&ie?(f=F(p,y,P,A),U=y):r.withUnit(v.value,v.unit)!==p&&ie?(f=F(p,v.unit,P,A),U=v.unit):ie||(f=r.getValue(p??""),U=y),f!==void 0&&Y({value:f,unit:U}),x&&oe(D&&fe?b.PREDEFINED:b.CUSTOM)}const l=r.checkAndCleanDecimalComma(se),o=Ae(l,{allowEmpty:Ue,autoValue:V,placeholder:a,disabledValidation:ye});ue(o)},[y,p,c,fe]);const Z=zt(),G=r.label(v.unit)||v.unit||"",Zt=qt||!Z||Z&&Z.length===1,ke=Ne(t);let Q;const Gt=l=>{const[o,f=""]=r.isValueWithUnit(l.value)?r.split(l.value):[l.value];return{type:Ee.OPTION,inline:!0,onClick:()=>{r.validateNumber(o).valid&&!n&&(oe(b.PREDEFINED),re({target:{value:l.value,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:l}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(sn,{children:l.label}),e.jsx(N,{width:"20px",height:"0"})]}),description:r.isValueWithUnit(l.value)?`${o} ${f}`:l.value,selected:D===l&&k===b.PREDEFINED}};if(Q=[{type:Ee.OPTION,inline:!0,onClick:()=>{k!==b.CUSTOM&&!n&&re({target:{value:r.withUnit(v.value,v.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:k===b.CUSTOM}],x!=null&&x.length){const l=x.map(Gt);Q=[...Q,...l]}return e.jsx("div",{className:k===b.PREDEFINED?nn(bn.predefinedMenuActive):"",children:e.jsxs(rn,{small:s,width:g,children:[x&&e.jsx(ln,{text:k===b.PREDEFINED?D==null?void 0:D.label:"",children:e.jsx(Se,{maxHeight:380,groupOrder:"first",testId:w&&`${w}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(d,{groupOrder:"first",active:k===b.PREDEFINED,icon:k===b.PREDEFINED?"link":"unlink"}),small:s,sections:Q}})}),e.jsx(un,{type:"text",name:ke,testId:w,disabled:n,placeholder:de?F(V,v.unit,xe,A):a,value:v.value,onChange:Jt,onFocus:Wt,error:c||Ht,warning:Rt,right:!u},ke),G&&(Zt?e.jsx(an,{groupOrder:"last",children:G}):e.jsx(Se,{maxHeight:380,groupOrder:"last",disabled:i,testId:w&&`${w}-menu`,menu:{label:G,trigger:"DropDownButton",small:s,sections:Z.map(([l,o,f])=>{const U=f||o||"";return{type:"Option",label:isNaN(Number(l))?"":l,inline:!0,onClick:X=>{X.stopPropagation(),Yt(de?"":l,o)},description:U,selected:U===G,testId:`${w}-unit-${U}`}})}}))]})})};try{h.displayName="UnitInput",h.__docgenInfo={description:"",displayName:"UnitInput",props:{name:{defaultValue:null,description:"",name:"name",required:!0,type:{name:"string | { fieldName?: string | undefined; }"}},placeholder:{defaultValue:{value:""},description:"",name:"placeholder",required:!1,type:{name:"string"}},disabled:{defaultValue:{value:"false"},description:"",name:"disabled",required:!1,type:{name:"boolean"}},disabledUnit:{defaultValue:{value:"false"},description:"",name:"disabledUnit",required:!1,type:{name:"boolean"}},error:{defaultValue:{value:"null"},description:"",name:"error",required:!1,type:{name:"string | boolean | null"}},left:{defaultValue:{value:"false"},description:"",name:"left",required:!1,type:{name:"boolean"}},small:{defaultValue:{value:"false"},description:"",name:"small",required:!1,type:{name:"boolean"}},width:{defaultValue:{value:"100%"},description:"",name:"width",required:!1,type:{name:"string | number"}},value:{defaultValue:null,description:"",name:"value",required:!1,type:{name:"string"}},unitkey:{defaultValue:{value:""},description:"",name:"unitkey",required:!1,type:{name:"string"}},initUnit:{defaultValue:null,description:"",name:"initUnit",required:!1,type:{name:"string"}},noConversion:{defaultValue:{value:"false"},description:"",name:"noConversion",required:!1,type:{name:"boolean"}},doNotConvertValue:{defaultValue:{value:"false"},description:"",name:"doNotConvertValue",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}},warning:{defaultValue:{value:"null"},description:"",name:"warning",required:!1,type:{name:"string | null"}},predefinedOptions:{defaultValue:null,description:"",name:"predefinedOptions",required:!1,type:{name:"IPredefinedOption[]"}},initialPredefinedOption:{defaultValue:{value:"false"},description:"",name:"initialPredefinedOption",required:!1,type:{name:"boolean"}},shouldLinkAutomaticly:{defaultValue:{value:"true"},description:"",name:"shouldLinkAutomaticly",required:!1,type:{name:"boolean"}},selectedPredefinedOptionKey:{defaultValue:null,description:"",name:"selectedPredefinedOptionKey",required:!1,type:{name:"string"}},validationCallback:{defaultValue:{value:"() => ({ name: '', error: null })"},description:"",name:"validationCallback",required:!1,type:{name:"((name: string, message: string | null) => { name: string; error: string | null; })"}},disabledValidation:{defaultValue:{value:"false"},description:"",name:"disabledValidation",required:!1,type:{name:"boolean"}},allowEmpty:{defaultValue:{value:"false"},description:"",name:"allowEmpty",required:!1,type:{name:"boolean"}},autoValue:{defaultValue:null,description:"",name:"autoValue",required:!1,type:{name:"string"}},onChange:{defaultValue:{value:"() => {}"},description:"",name:"onChange",required:!1,type:{name:"(event: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void"}},onSwitchUnit:{defaultValue:{value:"() => {}"},description:"",name:"onSwitchUnit",required:!1,type:{name:"((unit: string) => void)"}},onClick:{defaultValue:{value:"() => {}"},description:"",name:"onClick",required:!1,type:{name:"MouseEventHandler<HTMLInputElement>"}},onFocus:{defaultValue:{value:"() => {}"},description:"",name:"onFocus",required:!1,type:{name:"FocusEventHandler<HTMLInputElement>"}},unitTemplate:{defaultValue:null,description:"",name:"unitTemplate",required:!1,type:{name:"Record<string, any>"}}}}}catch{}const{useArgs:yn}=__STORYBOOK_MODULE_ADDONS__,ea={title:"Basic/UnitInput",component:h,args:{name:"example",unitkey:"length",value:"123|m"}},C=t=>{const[a,n]=yn(),i=c=>{n({value:c.target.value})};return e.jsx(h,{...t,onChange:i})},ee=C.bind({}),M=C.bind({});M.args={initUnit:"ft",unitTemplate:{length:"ft"}};const _=C.bind({});_.args={value:'123|"',unitkey:'"',noConversion:!0};const O=C.bind({});O.args={width:"180px"};const B=C.bind({});B.args={noConversion:!0};const q=C.bind({});q.args={small:!0};const W=C.bind({});W.args={error:"Error message goes here"};const R=C.bind({});R.args={value:"asas123asd|%"};const E=C.bind({});E.args={disabled:!0,disabledUnit:!0};E.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 T=C.bind({});T.args={disabled:!0,disabledUnit:!0,noConversion:!0};const L=C.bind({});L.args={disabledUnit:!0,unitkey:void 0};const K=C.bind({});K.args={disabledUnit:!0,unitkey:"length"};const $=C.bind({});$.args={disabledUnit:!1,disabled:!0};const H=t=>{const[a,n]=m.useState("123|m"),[i,c]=m.useState("223|m"),[u,s]=m.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(d,{label:"Change initUnit",onClick:()=>s(u==="m"?"ft":"m")}),e.jsx(N,{}),e.jsx(d,{label:"Change value",onClick:()=>n(a==="123|m"?"456|m":"123|m")}),e.jsx(N,{}),e.jsx(h,{name:"example",onChange:g=>{n(g.target.value)},unitkey:"length",value:a,initUnit:u,onSwitchUnit:s}),e.jsx(N,{}),e.jsx(h,{name:"example2",onChange:g=>{c(g.target.value)},unitkey:"length",value:i,initUnit:u,onSwitchUnit:s}),e.jsx(on,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(h,{name:"example",onChange:g=>{n(g.target.value)},unitkey:"length",value:a,onSwitchUnit:s}),e.jsx(h,{name:"example2",onChange:g=>{c(g.target.value)},unitkey:"length",value:i,onSwitchUnit:s})]})};H.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const z=C.bind({});z.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const J=()=>{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(_t,{children:[e.jsxs(pe,{width:"25%",children:[e.jsx(d,{label:"Change value infinity",onClick:()=>n(1/0)}),e.jsx("br",{}),e.jsx(d,{label:"Change value -infinity",onClick:()=>n(-1/0)}),e.jsx("br",{}),e.jsx(d,{label:"Change value null",onClick:()=>n(null)}),e.jsx("br",{}),e.jsx(d,{label:"Change value - undefined",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(d,{label:"Change value - NaN",onClick:()=>n(NaN)}),e.jsx("br",{}),e.jsx(d,{label:"Change value - nothing (empty)",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(d,{label:"Change value - empty string",onClick:()=>n("")})]}),e.jsxs(pe,{width:"25%",children:[e.jsx(d,{label:"Change value infinity|m",onClick:()=>n("Infinity|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value -infinity|m",onClick:()=>n("-Infinity|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value null|m",onClick:()=>n(null+"|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value - undefined|m",onClick:()=>n(void 0+"|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value - NaN|m",onClick:()=>n("NaN|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value - nothing (empty)|m",onClick:()=>n("|m")})]})]}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI",children:e.jsx(h,{name:"example1",onChange:i=>n(i.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit"})}),e.jsx(I,{label:"Disabled validation",children:e.jsx(h,{name:"example2",onChange:i=>n(i.target.value),value:a,unitkey:"length",disabledValidation:!0,width:t})}),e.jsx(I,{label:"Disabled validation and manual error",children:e.jsx(h,{name:"example3",onChange:i=>n(i.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(ge,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},te=()=>{const t="500px",[a,n]=m.useState("1|m"),[i,c]=m.useState("|m"),u="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(_t,{children:e.jsxs(pe,{width:"25%",children:[e.jsx(d,{label:"Change value to ''",onClick:()=>n("")}),e.jsx("br",{}),e.jsx(d,{label:"Change value to 1",onClick:()=>n("1")}),e.jsx("br",{}),e.jsx(d,{label:"Change value to 1|m",onClick:()=>n("1|m")}),e.jsx("br",{}),e.jsx(d,{label:"Change value to |m - empty value",onClick:()=>n("|m")})]})}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI (placeholder + auto)",children:e.jsx(h,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:u})}),e.jsx(I,{label:"Normal PUI (only auto)",children:e.jsx(h,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,autoValue:u})}),e.jsx(I,{label:"Empty PUI with autoValue",children:e.jsx(h,{name:"example1",onChange:s=>c(s.target.value),value:i,unitkey:"length",width:t,autoValue:u})}),e.jsx(I,{label:"Normal PUI (only placeholder)",children:e.jsx(h,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(I,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(h,{name:"example1",onChange:s=>n(s.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(ge,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};J.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const ne=()=>{const[t,a]=m.useState("123|%"),[n,i]=m.useState(null),c="This should be visible when an error appears",u=(s,g)=>(i(g),{name:s,error:g});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(h,{name:"example",onChange:s=>a(s.target.value),error:!n||c,validationCallback:u,value:t}),e.jsx("br",{}),e.jsx(N,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(ge,{message:{heading:n,visible:!0}})]})},ae=()=>{const[t,a]=m.useState("123|m"),[n,i]=m.useState(""),[c,u]=m.useState("km"),s=()=>{u("ft"),i("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(h,{name:"example",onChange:g=>a(g.target.value),value:t,allowEmpty:!0,placeholder:n,initUnit:c,unitkey:"length"}),e.jsx("br",{}),e.jsx(N,{}),e.jsx(d,{label:"Change value |m and unit ft",onClick:()=>s()})]})};var De,Fe,Me;ee.parameters={...ee.parameters,docs:{...(De=ee.parameters)==null?void 0:De.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
+ }`,...(Me=(Fe=ee.parameters)==null?void 0:Fe.docs)==null?void 0:Me.source}}};var _e,Oe,Be;M.parameters={...M.parameters,docs:{...(_e=M.parameters)==null?void 0:_e.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
+ }`,...(Be=(Oe=M.parameters)==null?void 0:Oe.docs)==null?void 0:Be.source}}};var qe,We,Re;_.parameters={..._.parameters,docs:{...(qe=_.parameters)==null?void 0:qe.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
+ }`,...(Re=(We=_.parameters)==null?void 0:We.docs)==null?void 0:Re.source}}};var Te,Le,Ke;O.parameters={...O.parameters,docs:{...(Te=O.parameters)==null?void 0:Te.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
+ }`,...(Ke=(Le=O.parameters)==null?void 0:Le.docs)==null?void 0:Ke.source}}};var $e,He,ze;B.parameters={...B.parameters,docs:{...($e=B.parameters)==null?void 0:$e.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
+ }`,...(ze=(He=B.parameters)==null?void 0:He.docs)==null?void 0:ze.source}}};var Je,Ye,Ze;q.parameters={...q.parameters,docs:{...(Je=q.parameters)==null?void 0:Je.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
+ }`,...(Ze=(Ye=q.parameters)==null?void 0:Ye.docs)==null?void 0:Ze.source}}};var Ge,Qe,Xe;W.parameters={...W.parameters,docs:{...(Ge=W.parameters)==null?void 0:Ge.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
+ }`,...(Xe=(Qe=W.parameters)==null?void 0:Qe.docs)==null?void 0:Xe.source}}};var et,tt,nt;R.parameters={...R.parameters,docs:{...(et=R.parameters)==null?void 0:et.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
+ }`,...(nt=(tt=R.parameters)==null?void 0:tt.docs)==null?void 0:nt.source}}};var at,lt,rt;E.parameters={...E.parameters,docs:{...(at=E.parameters)==null?void 0:at.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
+ }`,...(rt=(lt=E.parameters)==null?void 0:lt.docs)==null?void 0:rt.source}}};var st,it,ut;T.parameters={...T.parameters,docs:{...(st=T.parameters)==null?void 0:st.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
+ }`,...(ut=(it=T.parameters)==null?void 0:it.docs)==null?void 0:ut.source}}};var ot,dt,ct;L.parameters={...L.parameters,docs:{...(ot=L.parameters)==null?void 0:ot.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
+ }`,...(ct=(dt=L.parameters)==null?void 0:dt.docs)==null?void 0:ct.source}}};var mt,pt,gt;K.parameters={...K.parameters,docs:{...(mt=K.parameters)==null?void 0:mt.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
+ }`,...(gt=(pt=K.parameters)==null?void 0:pt.docs)==null?void 0:gt.source}}};var ht,vt,ft;$.parameters={...$.parameters,docs:{...(ht=$.parameters)==null?void 0:ht.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
+ }`,...(ft=(vt=$.parameters)==null?void 0:vt.docs)==null?void 0:ft.source}}};var Ct,bt,yt;H.parameters={...H.parameters,docs:{...(Ct=H.parameters)==null?void 0:Ct.docs,source:{originalSource:`(args: IUnitInputProps) => {
106
+ const [value, setValue] = useState('123|m');
107
+ const [value2, setValue2] = useState('223|m');
108
+ const [initUnit, setInitUnit] = useState('ft');
109
+ return <>
110
+ <Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
111
+ <Spacer />
112
+ <Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
113
+ <Spacer />
114
+ <UnitInput name="example" onChange={evt => {
115
+ setValue(evt.target.value);
116
+ }} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
117
+ <Spacer />
118
+ <UnitInput name="example2" onChange={evt => {
119
+ setValue2(evt.target.value);
120
+ }} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
121
+ <Divider />
122
+ <h4>Without initUnit property (taken from the redux store)</h4>
123
+ <UnitInput name="example" onChange={evt => {
124
+ setValue(evt.target.value);
125
+ }} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
126
+ <UnitInput name="example2" onChange={evt => {
127
+ setValue2(evt.target.value);
128
+ }} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
129
+ </>;
130
+ }`,...(yt=(bt=H.parameters)==null?void 0:bt.docs)==null?void 0:yt.source}}};var Ut,xt,Vt;z.parameters={...z.parameters,docs:{...(Ut=z.parameters)==null?void 0:Ut.docs,source:{originalSource:`args => {
131
+ const [_, updateArgs] = useArgs();
132
+ const handleChange = (evt: any) => {
133
+ updateArgs({
134
+ value: evt.target.value
135
+ });
136
+ };
137
+ return <UnitInput {...args} onChange={handleChange} />;
138
+ }`,...(Vt=(xt=z.parameters)==null?void 0:xt.docs)==null?void 0:Vt.source}}};var It,jt,kt;J.parameters={...J.parameters,docs:{...(It=J.parameters)==null?void 0:It.docs,source:{originalSource:`() => {
139
+ const width = '500px';
140
+ const [value, setValue] = useState<any>(undefined);
141
+ return <>
142
+ <h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
143
+ <Row>
144
+ <Column width="25%">
145
+ <Button label="Change value infinity" onClick={() => setValue(Infinity)} />
146
+ <br />
147
+ <Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
148
+ <br />
149
+ <Button label="Change value null" onClick={() => setValue(null)} />
150
+ <br />
151
+ <Button label="Change value - undefined" onClick={() => setValue(undefined)} />
152
+ <br />
153
+ <Button label="Change value - NaN" onClick={() => setValue(NaN)} />
154
+ <br />
155
+ <Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
156
+ <br />
157
+ <Button label="Change value - empty string" onClick={() => setValue('')} />
158
+ </Column>
159
+ <Column width="25%">
160
+ <Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
161
+ <br />
162
+ <Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
163
+ <br />
164
+ <Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
165
+ <br />
166
+ <Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
167
+ <br />
168
+ <Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
169
+ <br />
170
+ <Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
171
+ </Column>
172
+ </Row>
173
+ <br />
174
+ <Field label="Normal PUI">
175
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
176
+ </Field>
177
+ <Field label="Disabled validation">
178
+ <UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
179
+ </Field>
180
+ <Field label="Disabled validation and manual error">
181
+ <UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
182
+ </Field>
183
+ <Message message={{
184
+ heading: 'Current value inside PUI: ' + value,
185
+ visible: true
186
+ }} />
187
+ </>;
188
+ }`,...(kt=(jt=J.parameters)==null?void 0:jt.docs)==null?void 0:kt.source}}};var wt,St,Et;te.parameters={...te.parameters,docs:{...(wt=te.parameters)==null?void 0:wt.docs,source:{originalSource:`() => {
189
+ const width = '500px';
190
+ const [value, setValue] = useState<string>('1|m');
191
+ const [valueB, setValueB] = useState('|m');
192
+ const automaticValue = '123|km';
193
+ return <>
194
+ <h4>Different cases for automatic (placeholder) values:</h4>
195
+ <Row>
196
+ <Column width="25%">
197
+ <Button label="Change value to ''" onClick={() => setValue('')} />
198
+ <br />
199
+ <Button label="Change value to 1" onClick={() => setValue('1')} />
200
+ <br />
201
+ <Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
202
+ <br />
203
+ <Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
204
+ </Column>
205
+ </Row>
206
+ <br />
207
+ <Field label="Normal PUI (placeholder + auto)">
208
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
209
+ </Field>
210
+ <Field label="Normal PUI (only auto)">
211
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
212
+ </Field>
213
+ <Field label="Empty PUI with autoValue">
214
+ <UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
215
+ </Field>
216
+ <Field label="Normal PUI (only placeholder)">
217
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
218
+ </Field>
219
+ <Field label="Normal PUI (placeholder + allowEmpty)">
220
+ <UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
221
+ </Field>
222
+ <Message message={{
223
+ heading: 'Current value inside PUI: ' + value,
224
+ visible: true
225
+ }} />
226
+ </>;
227
+ }`,...(Et=(St=te.parameters)==null?void 0:St.docs)==null?void 0:Et.source}}};var Nt,At,Pt;ne.parameters={...ne.parameters,docs:{...(Nt=ne.parameters)==null?void 0:Nt.docs,source:{originalSource:`() => {
228
+ const [value, setValue] = useState('123|%');
229
+ const [validation, setValidation] = useState<string | null>(null);
230
+ const predictedMessage = 'This should be visible when an error appears';
231
+ const handleValidation = (name: string, message: string | null) => {
232
+ setValidation(message);
233
+ return {
234
+ name,
235
+ error: message
236
+ };
237
+ };
238
+ return <>
239
+ <h4>3rd party validation message when inputting invalid value:</h4>
240
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
241
+ <br />
242
+ <Spacer />
243
+ <h4>Original validation message: </h4>
244
+ <Message message={{
245
+ heading: validation,
246
+ visible: true
247
+ }} />
248
+ </>;
249
+ }`,...(Pt=(At=ne.parameters)==null?void 0:At.docs)==null?void 0:Pt.source}}};var Dt,Ft,Mt;ae.parameters={...ae.parameters,docs:{...(Dt=ae.parameters)==null?void 0:Dt.docs,source:{originalSource:`() => {
250
+ const [value, setValue] = useState('123|m');
251
+ const [placeholder, setPlaceholder] = useState('');
252
+ const [initUnit, setInitUnit] = useState('km');
253
+ const setPlaceholderValue = () => {
254
+ setInitUnit('ft');
255
+ setPlaceholder('placeholder');
256
+ setValue('|m');
257
+ };
258
+ return <>
259
+ <h4>Empty value case:</h4>
260
+ <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
261
+ <br />
262
+ <Spacer />
263
+ <Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
264
+ </>;
265
+ }`,...(Mt=(Ft=ae.parameters)==null?void 0:Ft.docs)==null?void 0:Mt.source}}};const ta=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI"];export{ae as AllowEmptyPUI,te as AutomaticValues,ee as Default,E as Disabled,T as DisabledNoConversion,K as DisabledUnitWithUnitKey,L as DisabledUnitWithoutUnitKey,$ as DisabledWithEnabledUnitMenu,W as Error,M as InitUnit,R as InternalValidationError,B as NoConversion,z as PredefinedOptionsMenu,q as Small,J as TestEdgeCases,H as TestExternalStateChangeWithSynchronizedUnits,ne as ValidationCallback,O as Width,ta as __namedExportsOrder,ea as default,_ as notKnownUnit};
@@ -357,7 +357,7 @@
357
357
  }
358
358
  </script>
359
359
 
360
- <script type="module" crossorigin src="./assets/iframe-210f2f48.js"></script>
360
+ <script type="module" crossorigin src="./assets/iframe-c049b5de.js"></script>
361
361
  </head>
362
362
 
363
363
  <body>