@oliasoft-open-source/react-ui-library 4.2.0 → 4.2.1-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/assets/{index-9e4179c3.css → index-0d78a198.css} +3 -0
  2. package/dist/assets/{index-cfa07a3f.js → index-26f804a8.js} +180 -175
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.html +1 -1
  5. package/dist/index.js +27 -16
  6. package/dist/index.js.map +1 -1
  7. package/dist/storybook/assets/Color-6VNJS4EI-6b48c85b.js +1 -0
  8. package/dist/storybook/assets/DocsRenderer-NNNQARDV-25c0f625.js +1 -0
  9. package/dist/storybook/assets/WithTooltip-4HIR6TLV-9ebd09dc.js +1 -0
  10. package/dist/storybook/assets/{accordion-1b587708.js → accordion-168fa7c5.js} +1 -1
  11. package/dist/storybook/assets/{accordion.stories-d52a4724.js → accordion.stories-0f8af16e.js} +1 -1
  12. package/dist/storybook/assets/{actions-83a2a04e.js → actions-2d4e1c8e.js} +1 -1
  13. package/dist/storybook/assets/{actions.stories-a38cd26e.js → actions.stories-81a7cb7a.js} +1 -1
  14. package/dist/storybook/assets/{afe.stories-dbb9e71e.js → afe.stories-afb9be07.js} +2 -2
  15. package/dist/storybook/assets/{badge.stories-1cbf35f9.js → badge.stories-5ce7957f.js} +1 -1
  16. package/dist/storybook/assets/{blowout.stories-af7f9432.js → blowout.stories-ee7f932b.js} +1 -1
  17. package/dist/storybook/assets/{button-050c998a.js → button-74c97e4a.js} +1 -1
  18. package/dist/storybook/assets/{button-group-0176fca3.js → button-group-fa895d0c.js} +1 -1
  19. package/dist/storybook/assets/{button-group.stories-7659a587.js → button-group.stories-22f072b7.js} +1 -1
  20. package/dist/storybook/assets/{button.stories-5f73ddef.js → button.stories-9b954335.js} +1 -1
  21. package/dist/storybook/assets/buttons-and-links-16cf8577.js +14 -0
  22. package/dist/storybook/assets/{card.stories-0437a4e2.js → card.stories-537a1772.js} +1 -1
  23. package/dist/storybook/assets/{casing-loads.stories-97ec4b66.js → casing-loads.stories-cfbab702.js} +1 -1
  24. package/dist/storybook/assets/{cell.stories-4a847cd0.js → cell.stories-524a7418.js} +1 -1
  25. package/dist/storybook/assets/{check-box-b38490e5.js → check-box-e21258d5.js} +1 -1
  26. package/dist/storybook/assets/{check-box.stories-9bf1c260.js → check-box.stories-5f7d06e0.js} +1 -1
  27. package/dist/storybook/assets/{chunk-HLWAVYOI-15cd9aaa.js → chunk-HLWAVYOI-1c498991.js} +1 -1
  28. package/dist/storybook/assets/color-8b40ecf4.js +25 -0
  29. package/dist/storybook/assets/{column.stories-d5ca2c42.js → column.stories-ae7588c5.js} +1 -1
  30. package/dist/storybook/assets/{dialog-c036ff34.js → dialog-cd58dd09.js} +1 -1
  31. package/dist/storybook/assets/{drawer-308b0a03.js → drawer-7f450988.js} +1 -1
  32. package/dist/storybook/assets/{drawer.stories-d76c0577.js → drawer.stories-39625e91.js} +2 -2
  33. package/dist/storybook/assets/{empty.stories-30fdd793.js → empty.stories-e0e3ac78.js} +1 -1
  34. package/dist/storybook/assets/{field-248df38c.js → field-a094cd72.js} +1 -1
  35. package/dist/storybook/assets/{field.stories-60d1a82f.js → field.stories-f1318053.js} +1 -1
  36. package/dist/storybook/assets/{file-input.stories-a7e96582.js → file-input.stories-1c6ce0ea.js} +1 -1
  37. package/dist/storybook/assets/{flex.stories-6a278b40.js → flex.stories-09e9c602.js} +1 -1
  38. package/dist/storybook/assets/footer.stories-57f07ea2.js +3 -0
  39. package/dist/storybook/assets/form.stories-45c0cd59.js +49 -0
  40. package/dist/storybook/assets/formation.stories-5eeaa826.js +74 -0
  41. package/dist/storybook/assets/{formatter-SWP5E3XI-bc797410.js → formatter-SWP5E3XI-521171e8.js} +2 -2
  42. package/dist/storybook/assets/{heading-39e599c8.js → heading-d29eb744.js} +1 -1
  43. package/dist/storybook/assets/{heading.stories-6ff7f5ed.js → heading.stories-9689bddc.js} +1 -1
  44. package/dist/storybook/assets/{help-icon-c0abd380.js → help-icon-d4189b1b.js} +1 -1
  45. package/dist/storybook/assets/{help-icon.stories-a30b7058.js → help-icon.stories-15d1620d.js} +1 -1
  46. package/dist/storybook/assets/icon-e9cbb4d7.js +8 -0
  47. package/dist/storybook/assets/{icon.stories-466d158f.js → icon.stories-8dae69e1.js} +1 -1
  48. package/dist/storybook/assets/iframe-5eee0790.js +1 -0
  49. package/dist/storybook/assets/{number-input-7cb3ea4d.js → index-57d7693e.js} +9 -9
  50. package/dist/storybook/assets/{index-ded8dd51.js → index-665bded2.js} +4 -4
  51. package/dist/storybook/assets/{index.es-37e2ce0d.js → index.es-85cc7dfc.js} +4 -4
  52. package/dist/storybook/assets/inheritsLoose-d4851ab8.js +1 -0
  53. package/dist/storybook/assets/{input-05f21b51.js → input-d68625a5.js} +1 -1
  54. package/dist/storybook/assets/{input-group.stories-602e1e93.js → input-group.stories-a2a3400e.js} +2 -2
  55. package/dist/storybook/assets/{input-validation-98dcb1cc.js → input-validation-560fd9e3.js} +2 -2
  56. package/dist/storybook/assets/{input.stories-bf58ba7c.js → input.stories-164d93ab.js} +1 -1
  57. package/dist/storybook/assets/{inputs-95a86db4.js → inputs-ed0fc7ad.js} +1 -1
  58. package/dist/storybook/assets/{label-e6d15b59.js → label-13d490a3.js} +1 -1
  59. package/dist/storybook/assets/{label.stories-1c98204a.js → label.stories-427ba162.js} +1 -1
  60. package/dist/storybook/assets/layout-forms-e9b95540.js +16 -0
  61. package/dist/storybook/assets/{layout-general-d43e1deb.js → layout-general-7a81d7f9.js} +2 -2
  62. package/dist/storybook/assets/{list-bc0d9ad9.js → list-0dc3df85.js} +1 -1
  63. package/dist/storybook/assets/{list-heading-2215213f.js → list-heading-88cc8a9b.js} +1 -1
  64. package/dist/storybook/assets/{list.stories-c8b4f325.js → list.stories-5715452e.js} +2 -2
  65. package/dist/storybook/assets/{list.stories-data-ba40864f.js → list.stories-data-94f7c623.js} +1 -1
  66. package/dist/storybook/assets/{loader.stories-4e8e8df7.js → loader.stories-6107832a.js} +1 -1
  67. package/dist/storybook/assets/{menu.stories-8d724757.js → menu.stories-927adf3d.js} +1 -1
  68. package/dist/storybook/assets/{message-0b5ae3c5.js → message-7e627e60.js} +1 -1
  69. package/dist/storybook/assets/{message.stories-9b9c40c4.js → message.stories-f41a0c22.js} +1 -1
  70. package/dist/storybook/assets/{modal.stories-1b13be75.js → modal.stories-0e068cc1.js} +2 -2
  71. package/dist/storybook/assets/number-input-7d49b0b3.js +1 -0
  72. package/dist/storybook/assets/{number-input.stories-a78d1390.js → number-input.stories-02528124.js} +1 -1
  73. package/dist/storybook/assets/{option-dropdown.stories-4c391727.js → option-dropdown.stories-5030bdb8.js} +1 -1
  74. package/dist/storybook/assets/{padding-and-spacing-175c928c.js → padding-and-spacing-ea2bf22c.js} +2 -2
  75. package/dist/storybook/assets/{page.stories-b69a6953.js → page.stories-7cb68fed.js} +1 -1
  76. package/dist/storybook/assets/{pagination-443065a8.js → pagination-8aade846.js} +1 -1
  77. package/dist/storybook/assets/{pagination.stories-985230f7.js → pagination.stories-423b4938.js} +2 -2
  78. package/dist/storybook/assets/{pop-confirm.stories-3016f322.js → pop-confirm.stories-81b30901.js} +1 -1
  79. package/dist/storybook/assets/{popover-c1234faa.js → popover-06e375a5.js} +1 -1
  80. package/dist/storybook/assets/popover.stories-f651a81c.js +1 -0
  81. package/dist/storybook/assets/{preview-5b4b7caf.js → preview-51e87244.js} +3 -3
  82. package/dist/storybook/assets/preview-987fd1ab.js +1 -0
  83. package/dist/storybook/assets/projects.stories-3884a80c.js +47 -0
  84. package/dist/storybook/assets/{radio-button-d69b72e4.js → radio-button-135a9615.js} +1 -1
  85. package/dist/storybook/assets/{radio-button.stories-6ff0dc9b.js → radio-button.stories-0e8377ea.js} +1 -1
  86. package/dist/storybook/assets/{reservoirs.stories-0306bd1a.js → reservoirs.stories-6b14a37f.js} +2 -2
  87. package/dist/storybook/assets/{rich-text-input.stories-383819b4.js → rich-text-input.stories-661f34f1.js} +3 -3
  88. package/dist/storybook/assets/{row.stories-d565ec28.js → row.stories-d5b6b4a6.js} +1 -1
  89. package/dist/storybook/assets/select-205cd538.js +1 -0
  90. package/dist/storybook/assets/{select.stories-6651d3f2.js → select.stories-60f055e6.js} +2 -2
  91. package/dist/storybook/assets/{side-bar-10cceacd.js → side-bar-88e8cf41.js} +1 -1
  92. package/dist/storybook/assets/{side-bar.stories-02211e0d.js → side-bar.stories-2c06f8a6.js} +1 -1
  93. package/dist/storybook/assets/{site.stories-ae79a20c.js → site.stories-dee8ce1c.js} +2 -2
  94. package/dist/storybook/assets/slider-160e2152.js +7 -0
  95. package/dist/storybook/assets/{slider.stories-a55df653.js → slider.stories-79ab0e97.js} +2 -2
  96. package/dist/storybook/assets/{spacer.stories-a2798d47.js → spacer.stories-38071af8.js} +1 -1
  97. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-96abff19.js +1 -0
  98. package/dist/storybook/assets/{table-a19b5c53.js → table-da6f6045.js} +1 -1
  99. package/dist/storybook/assets/{table.stories-4b24d81a.js → table.stories-67a3023a.js} +1 -1
  100. package/dist/storybook/assets/{table.stories-data-ddbcf8c3.js → table.stories-data-8a836b92.js} +1 -1
  101. package/dist/storybook/assets/{textarea-598f9fff.js → textarea-d48efea2.js} +1 -1
  102. package/dist/storybook/assets/{textarea.stories-3902f4aa.js → textarea.stories-89c8afd7.js} +1 -1
  103. package/dist/storybook/assets/{title.stories-00dc9f42.js → title.stories-5b4a226c.js} +1 -1
  104. package/dist/storybook/assets/{toaster-f096ba56.js → toaster-541ce85b.js} +1 -1
  105. package/dist/storybook/assets/{toaster.stories-66162195.js → toaster.stories-5e4d95b1.js} +1 -1
  106. package/dist/storybook/assets/{toggle-6f4d5797.js → toggle-bb34b2a2.js} +1 -1
  107. package/dist/storybook/assets/{toggle.stories-a289f544.js → toggle.stories-b771ed81.js} +1 -1
  108. package/dist/storybook/assets/{tooltip-856042a7.js → tooltip-23e84186.js} +1 -1
  109. package/dist/storybook/assets/{tooltip.stories-666868d0.js → tooltip.stories-e8ba5fff.js} +1 -1
  110. package/dist/storybook/assets/{tooltip.test-case.stories-4c1ea273.js → tooltip.test-case.stories-9817078b.js} +1 -1
  111. package/dist/storybook/assets/{top-bar-38689fe2.js → top-bar-a84b9365.js} +1 -1
  112. package/dist/storybook/assets/{top-bar.stories-3d9a6da1.js → top-bar.stories-e93330f0.js} +1 -1
  113. package/dist/storybook/assets/{top-bar.testcase.stories-dc051455.js → top-bar.testcase.stories-3a824a14.js} +1 -1
  114. package/dist/storybook/assets/{tree.stories-729aebd7.js → tree.stories-590bdd69.js} +1 -1
  115. package/dist/storybook/assets/unit-input.stories-0eea1703.js +265 -0
  116. package/dist/storybook/assets/unit-input.stories-c251e2c8.css +1 -0
  117. package/dist/storybook/iframe.html +1 -1
  118. package/dist/storybook/index.json +1 -1
  119. package/dist/storybook/project.json +1 -1
  120. package/dist/storybook/stories.json +1 -1
  121. package/package.json +1 -1
  122. package/dist/404.html +0 -1
  123. package/dist/storybook/assets/Color-6VNJS4EI-b934ab6b.js +0 -1
  124. package/dist/storybook/assets/DocsRenderer-NNNQARDV-ddf564a7.js +0 -1
  125. package/dist/storybook/assets/WithTooltip-4HIR6TLV-8e7953d1.js +0 -1
  126. package/dist/storybook/assets/buttons-and-links-bea8e431.js +0 -14
  127. package/dist/storybook/assets/color-d7525af7.js +0 -25
  128. package/dist/storybook/assets/extends-98964cd2.js +0 -1
  129. package/dist/storybook/assets/footer.stories-da256be2.js +0 -3
  130. package/dist/storybook/assets/form.stories-7c1518fa.js +0 -49
  131. package/dist/storybook/assets/formation.stories-a033bc86.js +0 -74
  132. package/dist/storybook/assets/icon-8acf9925.js +0 -8
  133. package/dist/storybook/assets/iframe-615023be.js +0 -1
  134. package/dist/storybook/assets/inheritsLoose-c82a83d4.js +0 -1
  135. package/dist/storybook/assets/layout-forms-2d1a89fa.js +0 -16
  136. package/dist/storybook/assets/popover.stories-7542a367.js +0 -1
  137. package/dist/storybook/assets/preview-e85ca407.js +0 -1
  138. package/dist/storybook/assets/projects.stories-104a0c19.js +0 -47
  139. package/dist/storybook/assets/select-d4593fc0.js +0 -1
  140. package/dist/storybook/assets/slider-5d5442fe.js +0 -7
  141. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-696a62ca.js +0 -1
@@ -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 s,r as Xt}from"./index-57d7693e.js";import{c as en}from"./index-a80ed1cf.js";import{M as ke}from"./actions-2d4e1c8e.js";import{I as tn}from"./input-group-addon-f8f6683a.js";import{B as d}from"./button-74c97e4a.js";import{T as nn}from"./tooltip-23e84186.js";import{I as an}from"./input-group-20c3add3.js";import{S as N}from"./spacer-54db0620.js";import{T as ln}from"./text-ad1f5f1d.js";import{I as rn}from"./input-d68625a5.js";import{M as Se}from"./types-cc224262.js";import{l as w}from"./lodash-75c70a11.js";import{D as sn}from"./divider-182aa58c.js";import{R as Dt,C as me}from"./row-2299f0e7.js";import{F as I}from"./field-a094cd72.js";import{a as pe}from"./message-7e627e60.js";import"./index-54f0d271.js";import"./common-types-2c81813f.js";import"./disabled-context-d654f6ff.js";import"./icon-e9cbb4d7.js";import"./inheritsLoose-d4851ab8.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-13d490a3.js";import"./help-icon-d4189b1b.js";const un=()=>{const t=m.useRef(null);return m.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},on=t=>{const a=m.useRef();return m.useEffect(()=>{a.current=t},[t]),a.current},dn=(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.`),s.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const Mt=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),Ft=(t="",a,n="",i=!1)=>{if(i)return t;if(a&&!Mt(t))try{const c=s.isValueWithUnit(t)?t:s.withUnit(t,n),u=s.convertSamePrecision(c,a);return s.getValue(u)}catch{}return t},cn=t=>t?!!s.getUnit(t):!1,M=(t="",a,n,i)=>{if(i)return t;const c=cn(t)||s.isValueWithUnit(t),u=s.getValue(t);return Mt(u)?u:c?Ft(u,a,n,i):t},we=t=>w.isObject(t)&&!w.isArray(t)&&!w.isFunction(t)?w.get(t,"fieldName",""):typeof t=="string"?t:"",mn=t=>w.isObjectLike(t)&&w.has(t,"message"),pn=t=>typeof t=="string"?t:mn(t)?t.message:null;var gn=Xt();const hn=t=>t.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g))===0,Ee=(t,a)=>{var j;const{allowEmpty:n=!1,autoValue:i,placeholder:c,disabledValidation:u=!1}=a||{},r=String(t);if(u||i||c)return null;const p=gn.isValueWithUnit(r)?s.getValue(r):r;if(n&&p==="")return null;if(hn(p))return"Invalid number format due to leading zeroes";const h=s.validateNumber(p);if(!h.valid){const le=((j=h==null?void 0:h.errors)==null?void 0:j[0])??null;return pn(le)}return null},vn="_predefinedMenuActive_1yvt4_1",fn={predefinedMenuActive:vn},g=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:i=!1,error:c=null,left:u=!1,small:r=!1,width:p="100%",value:h,unitkey:j="",initUnit:le,noConversion:_t=!1,onChange:re=()=>{},onClick:bn=()=>{},onFocus:Ot=()=>{},onSwitchUnit:ge=()=>{},unitTemplate:he,doNotConvertValue:A=!1,testId:S,warning:Bt=null,predefinedOptions:x,initialPredefinedOption:qt=!1,shouldLinkAutomaticly:ve=!0,selectedPredefinedOptionKey:fe,validationCallback:Ce=()=>({name:"",error:null}),disabledValidation:be=!1,allowEmpty:ye=!1,autoValue:V})=>{typeof h=="number"&&(h=`${h}`);const Wt=un(),[se="",P=""]=h!==void 0?s.split(h):[],Ue=V?s.getUnit(V):"",Rt=m.useMemo(()=>dn(j,he),[j,he]),y=le||Rt||P,Tt=on(y),xe=M(h,y,P,A),Ve=M(V,y,Ue,A),Lt=xe!==""?{value:xe,unit:y}:Ve!==""?{value:Ve,unit:y}:{value:se,unit:P},[v,Y]=m.useState(Lt),[Kt,ie]=m.useState(null),[k,ue]=m.useState(qt?b.PREDEFINED:b.CUSTOM),oe=se===""&&V,D=x&&x.find(l=>{if(fe)return fe===l.valueKey;const o=s.isValueWithUnit(l.value)?s.getUnit(l.value):"";return s.withUnit(Ft(h,o),o)===l.value}),$t=()=>{if(j)try{const l=oe?V:h??"";let o=s.altUnitsList(l,j);return s.getValue(l)===""?o.map(f=>["",f[1]]):o}catch{return null}},Ht=l=>{const o=we(t),f=l.target,{value:U,selectionStart:X}=f,je=s.cleanNumStr(U.replaceAll(" ","").replaceAll("|","")),de=s.withUnit(je,(v==null?void 0:v.unit)||""),Zt=s.getValue(de),ce=Ee(Zt,{allowEmpty:ye,autoValue:V,placeholder:a,disabledValidation:be});if(ce===null){re({target:{value:de,name:o}});const[Gt,Qt]=s.split(de);Y({value:Gt,unit:Qt}),ie(null),Ce(o,null)}else Y({value:je,unit:v.unit}),ie(ce),Ce(o,ce);Wt(()=>{f.selectionStart=X,f.selectionEnd=X})},zt=(l,o)=>{o===v.unit||isNaN(Number(l))||(Y({value:l,unit:o}),ge&&ge(o))};m.useEffect(()=>{if(y){let f,U="";Tt!==y?(f=M(h,y,P,A),U=y):s.withUnit(v.value,v.unit)!==h&&(f=M(h,v.unit,P,A),U=v.unit),f!==void 0&&Y({value:f,unit:U}),x&&ue(D&&ve?b.PREDEFINED:b.CUSTOM)}const l=s.checkAndCleanDecimalComma(se),o=Ee(l,{allowEmpty:ye,autoValue:V,placeholder:a,disabledValidation:be});ie(o)},[y,h,c,ve]);const Z=$t(),G=s.label(v.unit)||v.unit||"",Jt=_t||!Z||Z&&Z.length===1,Ie=we(t);let Q;const Yt=l=>{const[o,f=""]=s.isValueWithUnit(l.value)?s.split(l.value):[l.value];return{type:Se.OPTION,inline:!0,onClick:()=>{s.validateNumber(o).valid&&!n&&(ue(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(ln,{children:l.label}),e.jsx(N,{width:"20px",height:"0"})]}),description:s.isValueWithUnit(l.value)?`${o} ${f}`:l.value,selected:D===l&&k===b.PREDEFINED}};if(Q=[{type:Se.OPTION,inline:!0,onClick:()=>{k!==b.CUSTOM&&!n&&re({target:{value:s.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(Yt);Q=[...Q,...l]}return e.jsx("div",{className:k===b.PREDEFINED?en(fn.predefinedMenuActive):"",children:e.jsxs(an,{small:r,width:p,children:[x&&e.jsx(nn,{text:k===b.PREDEFINED?D==null?void 0:D.label:"",children:e.jsx(ke,{maxHeight:380,groupOrder:"first",testId:S&&`${S}-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:r,sections:Q}})}),e.jsx(rn,{type:"text",name:Ie,testId:S,disabled:n,placeholder:oe?M(V,v.unit,Ue,A):a,value:v.value,onChange:Ht,onFocus:Ot,error:c||Kt,warning:Bt,right:!u},Ie),G&&(Jt?e.jsx(tn,{groupOrder:"last",children:G}):e.jsx(ke,{maxHeight:380,groupOrder:"last",disabled:i,testId:S&&`${S}-menu`,menu:{label:G,trigger:"DropDownButton",small:r,sections:Z.map(([l,o,f])=>{const U=f||o||"";return{type:"Option",label:isNaN(Number(l))?"":l,inline:!0,onClick:X=>{X.stopPropagation(),zt(oe?"":l,o)},description:U,selected:U===G,testId:`${S}-unit-${U}`}})}}))]})})};try{g.displayName="UnitInput",g.__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:Cn}=__STORYBOOK_MODULE_ADDONS__,Qn={title:"Basic/UnitInput",component:g,args:{name:"example",unitkey:"length",value:"123|m"}},C=t=>{const[a,n]=Cn(),i=c=>{n({value:c.target.value})};return e.jsx(g,{...t,onChange:i})},ee=C.bind({}),F=C.bind({});F.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,r]=m.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(d,{label:"Change initUnit",onClick:()=>r(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(g,{name:"example",onChange:p=>{n(p.target.value)},unitkey:"length",value:a,initUnit:u,onSwitchUnit:r}),e.jsx(N,{}),e.jsx(g,{name:"example2",onChange:p=>{c(p.target.value)},unitkey:"length",value:i,initUnit:u,onSwitchUnit:r}),e.jsx(sn,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(g,{name:"example",onChange:p=>{n(p.target.value)},unitkey:"length",value:a,onSwitchUnit:r}),e.jsx(g,{name:"example2",onChange:p=>{c(p.target.value)},unitkey:"length",value:i,onSwitchUnit:r})]})};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(Dt,{children:[e.jsxs(me,{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(me,{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(g,{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(g,{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(g,{name:"example3",onChange:i=>n(i.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(pe,{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(Dt,{children:e.jsxs(me,{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(g,{name:"example1",onChange:r=>n(r.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:u})}),e.jsx(I,{label:"Normal PUI (only auto)",children:e.jsx(g,{name:"example1",onChange:r=>n(r.target.value),value:a,unitkey:"length",width:t,autoValue:u})}),e.jsx(I,{label:"Empty PUI with autoValue",children:e.jsx(g,{name:"example1",onChange:r=>c(r.target.value),value:i,unitkey:"length",width:t,autoValue:u})}),e.jsx(I,{label:"Normal PUI (only placeholder)",children:e.jsx(g,{name:"example1",onChange:r=>n(r.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(I,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(g,{name:"example1",onChange:r=>n(r.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(pe,{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=(r,p)=>(i(p),{name:r,error:p});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(g,{name:"example",onChange:r=>a(r.target.value),error:!n||c,validationCallback:u,value:t}),e.jsx("br",{}),e.jsx(N,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(pe,{message:{heading:n,visible:!0}})]})},ae=()=>{const[t,a]=m.useState("123|m"),[n,i]=m.useState(""),[c,u]=m.useState("km"),r=()=>{u("ft"),i("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(g,{name:"example",onChange:p=>a(p.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:()=>r()})]})};var Ne,Ae,Pe;ee.parameters={...ee.parameters,docs:{...(Ne=ee.parameters)==null?void 0:Ne.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
+ }`,...(Pe=(Ae=ee.parameters)==null?void 0:Ae.docs)==null?void 0:Pe.source}}};var De,Me,Fe;F.parameters={...F.parameters,docs:{...(De=F.parameters)==null?void 0:De.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
+ }`,...(Fe=(Me=F.parameters)==null?void 0:Me.docs)==null?void 0:Fe.source}}};var _e,Oe,Be;_.parameters={..._.parameters,docs:{...(_e=_.parameters)==null?void 0:_e.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
+ }`,...(Be=(Oe=_.parameters)==null?void 0:Oe.docs)==null?void 0:Be.source}}};var qe,We,Re;O.parameters={...O.parameters,docs:{...(qe=O.parameters)==null?void 0:qe.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
+ }`,...(Re=(We=O.parameters)==null?void 0:We.docs)==null?void 0:Re.source}}};var Te,Le,Ke;B.parameters={...B.parameters,docs:{...(Te=B.parameters)==null?void 0:Te.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
+ }`,...(Ke=(Le=B.parameters)==null?void 0:Le.docs)==null?void 0:Ke.source}}};var $e,He,ze;q.parameters={...q.parameters,docs:{...($e=q.parameters)==null?void 0:$e.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=(He=q.parameters)==null?void 0:He.docs)==null?void 0:ze.source}}};var Je,Ye,Ze;W.parameters={...W.parameters,docs:{...(Je=W.parameters)==null?void 0:Je.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
+ }`,...(Ze=(Ye=W.parameters)==null?void 0:Ye.docs)==null?void 0:Ze.source}}};var Ge,Qe,Xe;R.parameters={...R.parameters,docs:{...(Ge=R.parameters)==null?void 0:Ge.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
+ }`,...(Xe=(Qe=R.parameters)==null?void 0:Qe.docs)==null?void 0:Xe.source}}};var et,tt,nt;E.parameters={...E.parameters,docs:{...(et=E.parameters)==null?void 0:et.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
+ }`,...(nt=(tt=E.parameters)==null?void 0:tt.docs)==null?void 0:nt.source}}};var at,lt,rt;T.parameters={...T.parameters,docs:{...(at=T.parameters)==null?void 0:at.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
+ }`,...(rt=(lt=T.parameters)==null?void 0:lt.docs)==null?void 0:rt.source}}};var st,it,ut;L.parameters={...L.parameters,docs:{...(st=L.parameters)==null?void 0:st.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
+ }`,...(ut=(it=L.parameters)==null?void 0:it.docs)==null?void 0:ut.source}}};var ot,dt,ct;K.parameters={...K.parameters,docs:{...(ot=K.parameters)==null?void 0:ot.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
+ }`,...(ct=(dt=K.parameters)==null?void 0:dt.docs)==null?void 0:ct.source}}};var mt,pt,gt;$.parameters={...$.parameters,docs:{...(mt=$.parameters)==null?void 0:mt.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
+ }`,...(gt=(pt=$.parameters)==null?void 0:pt.docs)==null?void 0:gt.source}}};var ht,vt,ft;H.parameters={...H.parameters,docs:{...(ht=H.parameters)==null?void 0:ht.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
+ }`,...(ft=(vt=H.parameters)==null?void 0:vt.docs)==null?void 0:ft.source}}};var Ct,bt,yt;z.parameters={...z.parameters,docs:{...(Ct=z.parameters)==null?void 0:Ct.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
+ }`,...(yt=(bt=z.parameters)==null?void 0:bt.docs)==null?void 0:yt.source}}};var Ut,xt,Vt;J.parameters={...J.parameters,docs:{...(Ut=J.parameters)==null?void 0:Ut.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
+ }`,...(Vt=(xt=J.parameters)==null?void 0:xt.docs)==null?void 0:Vt.source}}};var It,jt,kt;te.parameters={...te.parameters,docs:{...(It=te.parameters)==null?void 0:It.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
+ }`,...(kt=(jt=te.parameters)==null?void 0:jt.docs)==null?void 0:kt.source}}};var St,wt,Et;ne.parameters={...ne.parameters,docs:{...(St=ne.parameters)==null?void 0:St.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
+ }`,...(Et=(wt=ne.parameters)==null?void 0:wt.docs)==null?void 0:Et.source}}};var Nt,At,Pt;ae.parameters={...ae.parameters,docs:{...(Nt=ae.parameters)==null?void 0:Nt.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
+ }`,...(Pt=(At=ae.parameters)==null?void 0:At.docs)==null?void 0:Pt.source}}};const Xn=["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,F 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,Xn as __namedExportsOrder,Qn as default,_ as notKnownUnit};
@@ -0,0 +1 @@
1
+ ._predefinedMenuActive_1yvt4_1 input{background:var(--color-background-disabled)!important}
@@ -357,7 +357,7 @@
357
357
  }
358
358
  </script>
359
359
 
360
- <script type="module" crossorigin src="./assets/iframe-615023be.js"></script>
360
+ <script type="module" crossorigin src="./assets/iframe-5eee0790.js"></script>
361
361
  </head>
362
362
 
363
363
  <body>