@oliasoft-open-source/react-ui-library 4.10.2 → 4.10.4
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.
- package/dist/storybook/assets/Color-KGDBMAHA-B_oER2eh.js +1 -0
- package/dist/storybook/assets/DocsRenderer-PKQXORMH-BOKNVKu9.js +1 -0
- package/dist/storybook/assets/{accordion-6ouB0WTt.js → accordion-BiuI_LCA.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-B3JGIRt8.js → accordion.stories-BLEGXECa.js} +2 -2
- package/dist/storybook/assets/{actions-Tr0wIZve.js → actions-D-uVCDzk.js} +1 -1
- package/dist/storybook/assets/{actions.stories-CQK6PyBH.js → actions.stories-gKfuiKQy.js} +1 -1
- package/dist/storybook/assets/{afe.stories-Dxdcf-Wr.js → afe.stories-DFQsvqIV.js} +2 -2
- package/dist/storybook/assets/{badge.stories-Blb5k20_.js → badge.stories-Dkq_XgEW.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-hdxkqScp.js → blowout.stories-DHdofVc-.js} +1 -1
- package/dist/storybook/assets/{button-CzvLc2io.js → button-DHevvVBE.js} +1 -1
- package/dist/storybook/assets/{button-group-C1PqMW-H.js → button-group-1DEZPmxq.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-QlYbfeJS.js → button-group.stories-C4V1k0z_.js} +1 -1
- package/dist/storybook/assets/{button.stories-tM18j4A3.js → button.stories-DA9DGYD2.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-dWLxxjRO.js → buttons-and-links-C9hhQd51.js} +2 -2
- package/dist/storybook/assets/{card.stories-Bn6LpucB.js → card.stories-CsTB0DuM.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-JHbJuGYF.js → casing-loads.stories-BCXgA6_-.js} +2 -2
- package/dist/storybook/assets/{cell.stories-D6TC74aG.js → cell.stories-CrIM0y6t.js} +2 -2
- package/dist/storybook/assets/{check-box-wCvXxtCz.js → check-box-DPLaOkRR.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-Q_WICJ_2.js → check-box.stories-DfbWw6mD.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-Dee0Hh16.js → chunk-HLWAVYOI-BfZEBT2B.js} +1 -1
- package/dist/storybook/assets/color-BHnVca7t.js +25 -0
- package/dist/storybook/assets/{column.stories-DATtbLrP.js → column.stories-DDTHFELF.js} +1 -1
- package/dist/storybook/assets/{dialog-B55T_62Q.js → dialog-BelCA1mt.js} +1 -1
- package/dist/storybook/assets/{drawer-CNKfMbq9.js → drawer-DOWJp9T4.js} +1 -1
- package/dist/storybook/assets/drawer.stories-DcjyDHEs.js +113 -0
- package/dist/storybook/assets/{empty.stories-CVaJlnv1.js → empty.stories-DcwF0pkK.js} +1 -1
- package/dist/storybook/assets/{field-C5_fLDpy.js → field-HrLaMLbx.js} +1 -1
- package/dist/storybook/assets/{field.stories-DhiTcelS.js → field.stories-DUGMwi1O.js} +1 -1
- package/dist/storybook/assets/{file-button.stories-oe6HKMH2.js → file-button.stories-CU2pZcEO.js} +1 -1
- package/dist/storybook/assets/{file-input-CMP44wlr.js → file-input-X3BnZaHk.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-DTRWZyqS.js → file-input.stories-CWD5XYE9.js} +1 -1
- package/dist/storybook/assets/{flex.stories-DtDxXdHB.js → flex.stories-BhvJpHpN.js} +1 -1
- package/dist/storybook/assets/footer.stories-BU-TGwM2.js +3 -0
- package/dist/storybook/assets/form.stories-BrUnmw7R.js +49 -0
- package/dist/storybook/assets/formation.stories-DxVe8Zyc.js +74 -0
- package/dist/storybook/assets/{heading-NkLgQYoP.js → heading-CRNoBc7q.js} +1 -1
- package/dist/storybook/assets/{heading.stories-nI_cFnAN.js → heading.stories-DahFxeiX.js} +1 -1
- package/dist/storybook/assets/{help-icon-41R-Z9N1.js → help-icon-Buhx5nl6.js} +1 -1
- package/dist/storybook/assets/{help-icon.stories-DBYh0YX7.js → help-icon.stories-DbmZ1fgP.js} +1 -1
- package/dist/storybook/assets/icon-BSFY3vDO.js +8 -0
- package/dist/storybook/assets/{icon.stories-C4pR7xky.js → icon.stories-fnZUR-LK.js} +1 -1
- package/dist/storybook/assets/iframe-b7FGO4kK.js +2 -0
- package/dist/storybook/assets/index-D0InYQf6.js +1 -0
- package/dist/storybook/assets/{index-AnftGY4z.js → index-DTpGZ2PI.js} +8 -8
- package/dist/storybook/assets/{index.es-D2piFfFj.js → index.es-DazXb-ul.js} +4 -4
- package/dist/storybook/assets/inheritsLoose-DP0QEDDI.js +1 -0
- package/dist/storybook/assets/{input-group.stories-CCXx8SUE.js → input-group.stories-CElwRt3p.js} +2 -2
- package/dist/storybook/assets/{input-validation-C02P3Ckw.js → input-validation-BpiPuwVL.js} +2 -2
- package/dist/storybook/assets/{inputs-CZp1G8Dj.js → inputs-Cnu7J7Dg.js} +2 -2
- package/dist/storybook/assets/{label-hiSz3I8H.js → label-CqmyC9he.js} +1 -1
- package/dist/storybook/assets/{label.stories-Cyv5jBAO.js → label.stories-C0AO5F1a.js} +1 -1
- package/dist/storybook/assets/layout-forms-QYlS6UGn.js +16 -0
- package/dist/storybook/assets/{layout-general-Ca5prsMZ.js → layout-general-DAhM0iBJ.js} +2 -2
- package/dist/storybook/assets/{list-DhjHm8bz.js → list-bKpz6I9Q.js} +1 -1
- package/dist/storybook/assets/{list.stories-2F-UkS1E.js → list.stories-Cgmt29Wv.js} +2 -2
- package/dist/storybook/assets/{list.stories-data-DqFECKJF.js → list.stories-data-D_Aj3AN4.js} +1 -1
- package/dist/storybook/assets/{loader.stories-BMe1zhEL.js → loader.stories-pS8zRM4u.js} +1 -1
- package/dist/storybook/assets/{menu.stories-B_1YsebS.js → menu.stories-xWX80Eh2.js} +2 -2
- package/dist/storybook/assets/{message-DQ3q8XF9.js → message-Y48EomV-.js} +1 -1
- package/dist/storybook/assets/{message.stories-QYFwbrO0.js → message.stories-r_UlbshI.js} +1 -1
- package/dist/storybook/assets/{meta-content-DCllGQX6.js → meta-content-DWZbURV2.js} +1 -1
- package/dist/storybook/assets/{modal.stories-BZHVz3SN.js → modal.stories-LhoWfDE6.js} +2 -2
- package/dist/storybook/assets/{number-input-CXeUTTzi.js → number-input-B5ReSBSL.js} +1 -1
- package/dist/storybook/assets/number-input.stories-DMAU21wG.js +180 -0
- package/dist/storybook/assets/{option-dropdown.stories-ntKLWycS.js → option-dropdown.stories-CIvqMhQ3.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-gYxSJiPH.js → padding-and-spacing-DIn5b2MK.js} +2 -2
- package/dist/storybook/assets/{page.stories-Dp_z8s1a.js → page.stories-DnCh8h8y.js} +1 -1
- package/dist/storybook/assets/{pagination-CUucuCPT.js → pagination-CLt-kUlx.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-CN4-LYyQ.js → pagination.stories-CTRM0Xou.js} +2 -2
- package/dist/storybook/assets/{pop-confirm.stories-D-iQo6s7.js → pop-confirm.stories-DCpooB2O.js} +1 -1
- package/dist/storybook/assets/{popover-9ZnEm5Hy.js → popover-rq33c1W2.js} +1 -1
- package/dist/storybook/assets/popover.stories-CGm0M5fv.js +10 -0
- package/dist/storybook/assets/{preview-B4kXANMy.js → preview-CSnr1bcK.js} +2 -2
- package/dist/storybook/assets/preview-D2MA-QXv.js +2 -0
- package/dist/storybook/assets/projects.stories-BQswWVCx.js +47 -0
- package/dist/storybook/assets/{radio-button-YWkXh8yt.js → radio-button-DmDuw4DA.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-DB127127.js → radio-button.stories-5gvV0LD0.js} +1 -1
- package/dist/storybook/assets/react-router-dom-Ck2Y_Fzc.js +8 -0
- package/dist/storybook/assets/{reservoirs.stories-B2mJ74TZ.js → reservoirs.stories-B12tIrmZ.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-Dnt38vUz.js → rich-text-input.stories-DkaOBgbE.js} +3 -3
- package/dist/storybook/assets/{row.stories-D1ROqb-Z.js → row.stories-C8rG1yoB.js} +2 -2
- package/dist/storybook/assets/{select-BEc_mNg5.js → select-DnRuRG_N.js} +2 -2
- package/dist/storybook/assets/{select.stories-DXD4AYSk.js → select.stories-B9w9ONzj.js} +2 -2
- package/dist/storybook/assets/{side-bar-BApSkmiM.js → side-bar-CSx5wI-k.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-BuAIJ8NV.js → side-bar.stories-M6FsuCrQ.js} +1 -1
- package/dist/storybook/assets/{site.stories-CbJ0phLn.js → site.stories-umpPYjkq.js} +2 -2
- package/dist/storybook/assets/{slider-CBE03NwD.js → slider-C7vnj_3M.js} +4 -4
- package/dist/storybook/assets/{slider.stories-7oMw2PCp.js → slider.stories-BzBb3PkP.js} +2 -2
- package/dist/storybook/assets/{smart-upload-modal.stories-CdgsGLvm.js → smart-upload-modal.stories-Dn7dIsu1.js} +1 -1
- package/dist/storybook/assets/{spacer.stories-BC7lirqi.js → spacer.stories-BBTt2LdE.js} +1 -1
- package/dist/storybook/assets/{table-BIIY_zLx.js → table-DdpQxqOc.js} +1 -1
- package/dist/storybook/assets/{table.stories-DSH0B5G3.js → table.stories-D4zMbjkS.js} +2 -2
- package/dist/storybook/assets/{table.stories-data-BKKTfwt2.js → table.stories-data-C3vJedB1.js} +1 -1
- package/dist/storybook/assets/text-link.stories-BQAkVO-W.js +14 -0
- package/dist/storybook/assets/{title.stories-B79WOjH4.js → title.stories-hThIUrWl.js} +2 -2
- package/dist/storybook/assets/{toaster-CDSt-Toh.js → toaster-BoBcvmf9.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-D1XTcQR_.js → toaster.stories-HO4VBTy-.js} +1 -1
- package/dist/storybook/assets/{toggle-C0zvrIOF.js → toggle-BbFVf61v.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-DOc7uN93.js → toggle.stories-qTHFTXxI.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-D2SX9mkM.js → tooltip.test-case.stories-CHibN8rC.js} +1 -1
- package/dist/storybook/assets/{top-bar-BQzmL0IU.js → top-bar-DkXSzzqt.js} +1 -1
- package/dist/storybook/assets/top-bar.stories-HDmWT243.js +21 -0
- package/dist/storybook/assets/{top-bar.testcase.stories-DpV-QqfZ.js → top-bar.testcase.stories-DfmrkEpT.js} +1 -1
- package/dist/storybook/assets/{tree.stories-CsmZwDmr.js → tree.stories-feLUcTtm.js} +1 -1
- package/dist/storybook/assets/unit-input.stories-CkeTteis.js +421 -0
- package/dist/storybook/assets/unit-table.stories-CEqyw4pW.js +152 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -2
- package/dist/storybook/assets/Color-KGDBMAHA-BuCHTA3n.js +0 -1
- package/dist/storybook/assets/DocsRenderer-PKQXORMH-FxQsykUE.js +0 -1
- package/dist/storybook/assets/color-CJJT4CcU.js +0 -25
- package/dist/storybook/assets/drawer.stories-BzVj2VTf.js +0 -113
- package/dist/storybook/assets/extends-CF3RwP-h.js +0 -1
- package/dist/storybook/assets/footer.stories-BIerccR-.js +0 -3
- package/dist/storybook/assets/form.stories-Bs1kjjd-.js +0 -49
- package/dist/storybook/assets/formation.stories-Bp9_Oe46.js +0 -74
- package/dist/storybook/assets/icon-BP4BO6-k.js +0 -8
- package/dist/storybook/assets/iframe-CM_t_z-T.js +0 -2
- package/dist/storybook/assets/index-vl_j9FJ3.js +0 -1
- package/dist/storybook/assets/inheritsLoose-DR8r8Ogv.js +0 -1
- package/dist/storybook/assets/layout-forms-ZrsfsvoW.js +0 -16
- package/dist/storybook/assets/number-input.stories-CV0DCIOY.js +0 -166
- package/dist/storybook/assets/popover.stories-Cxaq0SAc.js +0 -10
- package/dist/storybook/assets/preview-B0-3357o.js +0 -2
- package/dist/storybook/assets/projects.stories-B1J-8EYu.js +0 -47
- package/dist/storybook/assets/react-router-dom-CMITYWBH.js +0 -8
- package/dist/storybook/assets/text-link.stories-BsuVBOWo.js +0 -14
- package/dist/storybook/assets/top-bar.stories-Czza1RvB.js +0 -21
- package/dist/storybook/assets/unit-input.stories-AMXj61al.js +0 -403
- package/dist/storybook/assets/unit-table.stories-Dv9-DLvC.js +0 -152
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as o}from"./index-DhsZuJvc.js";import{d as l}from"./index-C0x1JmaP.js";import{w as he,u as g,e as x,f as yn,a as bn}from"./index-DMAnyMX5.js";import{c as Hn}from"./index-Bk2sglWO.js";import{u as Ln}from"./use-previous-D775JrO6.js";import{M as Oe}from"./actions-D-uVCDzk.js";import{I as Gn}from"./input-group-addon-D68iUKV2.js";import{B as p}from"./button-DHevvVBE.js";import{T as Kn}from"./tooltip-1V7clEnw.js";import{I as $n}from"./input-group-BaRSJAEN.js";import{S as y}from"./spacer-BWoNR27H.js";import{T as Ue}from"./text-B3-TSWok.js";import{M as He}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{N as zn,r as Jn}from"./number-input-B5ReSBSL.js";import{i as Yn}from"./select.input-D0UkAPd9.js";import{D as Zn}from"./divider-DY9nJ_7N.js";import{R as Cn,C as Be}from"./row-Bmiy2Lh0.js";import{F as I}from"./field-HrLaMLbx.js";import{M as xe}from"./message-Y48EomV-.js";import{G as Un}from"./grid-DRkC-bt8.js";import{C as A}from"./card-EcjmryU9.js";import{H as q}from"./heading-CRNoBc7q.js";import{T as Ne}from"./toggle-BbFVf61v.js";import{S as Qn}from"./select-DnRuRG_N.js";import{I as xn}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./input-DTXbDJaL.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./index-CEuq6vkz.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const Xn=()=>{const t=o.useRef(null);return o.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},ea=(t,a)=>{const n=a==null?void 0:a[t];return n||(console.log(`Warning: 'unitTemplate' missing for '${t}'. Using initial unit, preferred unit or value unit.`),l.unitFromQuantity(t)??"")};var U=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(U||{});const In=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),Tn=(t="",a,n="",r=!1)=>{if(r)return t;if(a&&!In(t))try{const i=l.isValueWithUnit(t)?t:l.withUnit(t,n),m=l.convertSamePrecision(i,a);return l.getValue(m)}catch{}},ta=t=>t?!!l.getUnit(t):!1,J=(t="",a,n,r)=>{const i=ta(t)||l.isValueWithUnit(t),m=l.getValue(t);return In(m)?m:i?Tn(m,a,n,r):t},Le=t=>V.isObject(t)&&!V.isArray(t)&&!V.isFunction(t)?V.get(t,"fieldName",""):typeof t=="string"?t:"",Ge=(t="")=>{var a;return(a=l.KNOWN_UNITS)==null?void 0:a.includes(t)},na=(t,a)=>{const n=l.getUnit(t||"");return Ge(a)&&Ge(n)};let aa=o.createContext(null);const ia=()=>o.useContext(aa),ra="_predefinedMenuActive_ye9w9_1",sa="_inputWrapper_ye9w9_4",Ke={predefinedMenuActive:ra,inputWrapper:sa},c=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:r=!1,error:i=null,left:m=!1,small:u=!1,width:h="100%",value:f,unitkey:S="",initUnit:Ie,noConversion:K=!1,onChange:F=V.noop,onClick:Te=V.noop,onFocus:we=V.noop,onSwitchUnit:C=V.noop,unitTemplate:j,doNotConvertValue:$=!1,testId:P,warning:De=null,predefinedOptions:k,initialPredefinedOption:wn=!1,shouldLinkAutomaticly:Ae=!0,selectedPredefinedOptionKey:qe,validationCallback:kn=()=>({name:"",error:null}),disabledValidation:Vn=!1,allowEmpty:oa=!1,autoValue:E,convertBackToStorageUnit:Sn=!1,enableCosmeticRounding:Fe=!0,enableDisplayRounding:jn=!1})=>{const R=ia(),En=Xn();typeof f=="number"&&(f=`${f}`);const[Pe="",N=""]=f!==void 0?l.split(f):[],Re=E?l.getUnit(E):"",_e=o.useMemo(()=>ea(S,j||(R==null?void 0:R.unitTemplate)),[S,j,R==null?void 0:R.unitTemplate]),Nn=na(f,_e),T=Ie||_e||N,Bn=Ln(T),Me=J(f,T,N,$),We=J(E,T,Re,$),Dn=Me!==""?{value:Me,unit:T}:We!==""?{value:We,unit:T}:{value:Pe,unit:N},[v,ke]=o.useState(Dn),An=(v==null?void 0:v.value)===void 0,[B,Ve]=o.useState(wn?U.PREDEFINED:U.CUSTOM),Se=Pe===""&&E,qn=!!(Vn||E||a&&Yn(f)),z=k&&k.find(s=>{if(!(s!=null&&s.value))return;if(qe)return qe===s.valueKey;const d=l.isValueWithUnit(s.value)?l.getUnit(s.value):"";return l.withUnit(Tn(f,d),d)===s.value}),Fn=()=>{if(S)try{const s=Se?E:f??"";let d=l.altUnitsList(s,S);return l.getValue(s)===""?d.map(w=>["",w[1]]):d}catch{return null}},Pn=s=>{const d=Le(t),w=s.target,{value:D,selectionStart:_}=w,be=l.withUnit(D,(v==null?void 0:v.unit)||""),Ee=Sn?l.withUnit(l.convertAndGetValue(be,N),N):be;F({target:{value:Ee,name:d}});const[Wn,On]=l.split(be);ke({value:Wn,unit:On}),En(()=>{w.selectionStart=_,w.selectionEnd=_})},Rn=(s,d)=>{d===v.unit||isNaN(Number(s))||(ke({value:s,unit:d}),C&&C(d))};o.useEffect(()=>{if(T){let s,d="";Bn!==T?(s=J(f,T,N,$),d=T):l.withUnit(v.value,v.unit)!==f&&(s=J(f,v.unit,N,$),d=v.unit),s!==void 0&&ke({value:s,unit:d}),k&&Ve(z&&Ae?U.PREDEFINED:U.CUSTOM)}},[T,f,i,Ae]);const ve=Fn(),fe=l.label(v.unit)||v.unit||"",_n=K||!ve||ve&&ve.length===1,je=Le(t);let ye;const Mn=s=>{const d=s!=null&&s.value?s.value:"",[w="",D=""]=l.isValueWithUnit(d)?l.split(d):[d];return{type:He.OPTION,inline:!0,onClick:()=>{l.validateNumber(w).valid&&!n&&(Ve(U.PREDEFINED),F({target:{value:d,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:s}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(Ue,{children:s.label}),e.jsx(y,{width:"20px",height:"0"})]}),description:l.isValueWithUnit(d)?`${w} ${D}`:d,selected:z===s&&B===U.PREDEFINED}};if(ye=[{type:He.OPTION,inline:!0,onClick:()=>{B!==U.CUSTOM&&!n&&F({target:{value:l.withUnit(v.value,v.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:B===U.CUSTOM}],k!=null&&k.length){const s=k.map(Mn);ye=[...ye,...s]}return e.jsx("div",{className:B===U.PREDEFINED?Hn(Ke.predefinedMenuActive):"",children:e.jsxs($n,{small:u,width:h,children:[k&&e.jsx(Kn,{text:B===U.PREDEFINED?z==null?void 0:z.label:"",children:e.jsx(Oe,{maxHeight:380,groupOrder:"first",testId:P&&`${P}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(p,{groupOrder:"first",active:B===U.PREDEFINED,icon:B===U.PREDEFINED?"link":"unlink"}),small:u,sections:ye}})}),e.jsx("div",{className:Ke.inputWrapper,children:e.jsx(zn,{name:je,testId:P,disabled:n,placeholder:Se?J(E,v.unit,Re,$):a,value:v.value,onChange:Pn,onFocus:we,error:i===null?void 0:i,warning:De===null?void 0:De,left:m,allowEmpty:An,validationCallback:(s,d)=>kn(je,d),enableCosmeticRounding:Fe,enableDisplayRounding:jn,groupOrder:k?"middle":"first",disableInternalErrorValidationMessages:qn,small:u},je)}),fe&&(_n||!Nn?e.jsx(Gn,{groupOrder:"last",children:fe}):e.jsx(Oe,{maxHeight:380,groupOrder:"last",disabled:r,testId:P&&`${P}-menu`,menu:{label:fe,trigger:"DropDownButton",small:u,sections:ve.map(([s,d,w])=>{const D=w||d||"",_=l.isValidNum(s)?s:"";return{type:"Option",label:Fe?Jn(_):_,inline:!0,onClick:Ee=>{Ee.stopPropagation(),Rn(Se?"":s,d)},description:D,selected:D===fe,testId:`${P}-unit-${D}`}})}}))]})})};c.__docgenInfo={description:"",methods:[],displayName:"UnitInput",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},disabledUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:"",defaultValue:{value:"null",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:"",defaultValue:{value:"() => ({ name: '', error: null })",computed:!1}},disabledValidation:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
2
|
+
target:
|
|
3
|
+
| T
|
|
4
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
5
|
+
}`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
|
|
6
|
+
target:
|
|
7
|
+
| T
|
|
8
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
9
|
+
}`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
|
|
10
|
+
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}}}};const{useArgs:la}=__STORYBOOK_MODULE_PREVIEW_API__,Xa={title:"Forms/UnitInput",component:c,args:{name:"example",unitkey:"length",value:"123|m"}},b=t=>{const[a,n]=la(),r=i=>{n({value:i.target.value})};return e.jsx(c,{...t,onChange:r})},Ce=b.bind({}),Y=b.bind({});Y.args={initUnit:"ft",unitTemplate:{length:"ft"}};const Z=b.bind({});Z.args={value:'123|"',unitkey:'"'};const Q=b.bind({});Q.args={width:"180px"};const X=b.bind({});X.args={noConversion:!0};const ee=b.bind({});ee.args={small:!0};const M=()=>{const[t,a]=o.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),placeholder:"Type a value...",value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};M.play=async({canvasElement:t,step:a})=>{const n=he(t),r=he(t.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"123x45s6"),await x(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await yn.mouseOver(i),await bn(()=>{x(r.getByText("Must be a numerical value")).toBeInTheDocument()})})};const te=b.bind({});te.args={error:"Error message goes here"};const ne=b.bind({});ne.args={value:"asas123asd|%"};const W=b.bind({});W.args={disabled:!0,disabledUnit:!0};W.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 ae=b.bind({});ae.args={disabled:!0,disabledUnit:!0,noConversion:!0};const ie=b.bind({});ie.args={disabledUnit:!0,unitkey:void 0};const re=b.bind({});re.args={disabledUnit:!0,unitkey:"length"};const se=b.bind({});se.args={disabledUnit:!1,disabled:!0};const O=t=>{const[a,n]=o.useState("123|m"),[r,i]=o.useState("223|m"),[m,u]=o.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change initUnit",onClick:()=>u(m==="m"?"ft":"m")}),e.jsx(y,{}),e.jsx(p,{label:"Change value",onClick:()=>n(a==="123|m"?"456|m":"123|m")}),e.jsx(y,{}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,initUnit:m,onSwitchUnit:u}),e.jsx(y,{}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:r,initUnit:m,onSwitchUnit:u}),e.jsx(Zn,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(c,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,onSwitchUnit:u}),e.jsx(c,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:r,onSwitchUnit:u})]})};O.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const le=b.bind({});le.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const H=()=>{const t="500px",[a,n]=o.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Cn,{children:[e.jsxs(Be,{width:"25%",children:[e.jsx(p,{label:"Change value infinity",onClick:()=>n(1/0)}),e.jsx("br",{}),e.jsx(p,{label:"Change value -infinity",onClick:()=>n(-1/0)}),e.jsx("br",{}),e.jsx(p,{label:"Change value null",onClick:()=>n(null)}),e.jsx("br",{}),e.jsx(p,{label:"Change value - undefined",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(p,{label:"Change value - NaN",onClick:()=>n(NaN)}),e.jsx("br",{}),e.jsx(p,{label:"Change value - nothing (empty)",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(p,{label:"Change value - empty string",onClick:()=>n("")})]}),e.jsxs(Be,{width:"25%",children:[e.jsx(p,{label:"Change value infinity|m",onClick:()=>n("Infinity|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value -infinity|m",onClick:()=>n("-Infinity|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value null|m",onClick:()=>n("null|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value - undefined|m",onClick:()=>n("undefined|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value - NaN|m",onClick:()=>n("NaN|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value - nothing (empty)|m",onClick:()=>n("|m")})]})]}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI",children:e.jsx(c,{name:"example1",onChange:r=>n(r.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit"})}),e.jsx(I,{label:"Disabled validation",children:e.jsx(c,{name:"example2",onChange:r=>n(r.target.value),value:a,unitkey:"length",disabledValidation:!0,width:t})}),e.jsx(I,{label:"Disabled validation and manual error",children:e.jsx(c,{name:"example3",onChange:r=>n(r.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(xe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},oe=()=>{const t="500px",[a,n]=o.useState("1|m"),[r,i]=o.useState("|m"),m="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Cn,{children:e.jsxs(Be,{width:"25%",children:[e.jsx(p,{label:"Change value to ''",onClick:()=>n("")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1",onClick:()=>n("1")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1|m",onClick:()=>n("1|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to |m - empty value",onClick:()=>n("|m")})]})}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI (placeholder + auto)",children:e.jsx(c,{name:"example1",onChange:u=>n(u.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:m})}),e.jsx(I,{label:"Normal PUI (only auto)",children:e.jsx(c,{name:"example1",onChange:u=>n(u.target.value),value:a,unitkey:"length",width:t,autoValue:m})}),e.jsx(I,{label:"Empty PUI with autoValue",children:e.jsx(c,{name:"example1",onChange:u=>i(u.target.value),value:r,unitkey:"length",width:t,autoValue:m})}),e.jsx(I,{label:"Normal PUI (only placeholder)",children:e.jsx(c,{name:"example1",onChange:u=>n(u.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(I,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(c,{name:"example1",onChange:u=>n(u.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(xe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};H.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const ue=()=>{const[t,a]=o.useState("123|%"),[n,r]=o.useState(null),i="This should be visible when an error appears",m=(u,h)=>(r(h),{name:u,error:h});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(c,{name:"example",onChange:u=>a(u.target.value),error:!n||i,validationCallback:m,value:t}),e.jsx("br",{}),e.jsx(y,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(xe,{message:{heading:n,visible:!0}})]})},de=()=>{const[t,a]=o.useState("123|m"),[n,r]=o.useState(""),[i,m]=o.useState("km"),u=()=>{m("ft"),r("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(c,{name:"example",onChange:h=>a(h.target.value),value:t,allowEmpty:!0,placeholder:n,initUnit:i,unitkey:"length"}),e.jsx("br",{}),e.jsx(y,{}),e.jsx(p,{label:"Change value |m and unit ft",onClick:()=>u()})]})},ce=()=>{const[t,a]=o.useState("123|m"),[n,r]=o.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:r}),e.jsx(y,{}),e.jsx(c,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:r})]})},me=()=>{const[t,a]=o.useState(!0),n=()=>{a(!1),setTimeout(()=>a(!0),0)},[r,i]=o.useState("123|ft");return e.jsxs(Un,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(A,{heading:e.jsx(q,{children:"Storage State (Redux)"}),children:[r,e.jsx(y,{}),e.jsx(p,{label:"Change value",onClick:()=>i(l.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(A,{heading:e.jsx(q,{icon:e.jsx(xn,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:n,children:"UnitInput"}),children:t&&e.jsx(c,{name:"example",onChange:m=>i(m.target.value),value:r,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},pe=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ue,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(y,{}),e.jsx(c,{name:"example",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(y,{}),e.jsx(c,{name:"example2",onChange:()=>{},value:l.withUnit(l.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),L=()=>e.jsxs(e.Fragment,{children:[e.jsx(c,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(y,{}),e.jsx(c,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});L.play=async({canvasElement:t,step:a})=>{const n=he(t);await a("Can enter decimal values",async()=>{await x(n.getByDisplayValue("170")).toBeInTheDocument(),await x(n.getByDisplayValue("")).toBeInTheDocument()})};const ge=()=>{const[t,a]=o.useState(!0),n=()=>{a(!1),setTimeout(()=>a(!0),0)},[r,i]=o.useState("psi"),[m,u]=o.useState(!1),[h,f]=o.useState(!0),[S,Ie]=o.useState(!0),[K,F]=o.useState("672.2388357750001|bar"),[Te,we]=o.useState("");return e.jsxs(Un,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(A,{heading:e.jsx(q,{children:"Settings"}),children:[e.jsx(I,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Ne,{checked:m,onChange:C=>u(C.target.checked)})}),e.jsx(I,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Ne,{checked:h,onChange:C=>f(C.target.checked)})}),e.jsx(I,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(Ne,{checked:S,onChange:C=>Ie(C.target.checked)})})]}),e.jsxs(A,{heading:e.jsx(q,{icon:e.jsx(xn,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:n,children:"UnitInput"}),children:[e.jsx(Ue,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(y,{}),e.jsx(Ue,{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(y,{}),t&&e.jsx(c,{name:"Example",unitkey:"pressure",initUnit:r,unitTemplate:{pressure:"psi"},value:K,onChange:C=>{const{value:j}=C.target;j&&F(j)},enableDisplayRounding:m,enableCosmeticRounding:h,error:l.convertAndGetValue(K,"bar")>=0?"":"Value must be positive",validationCallback:(C,j)=>{we(j??"")},convertBackToStorageUnit:S})]}),e.jsx(A,{heading:e.jsx(q,{children:"Unit Template"}),children:e.jsx(Qn,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:r,width:70,onChange:C=>i(C.target.value)})}),e.jsx(A,{heading:e.jsx(q,{children:"Test Validation Callback"}),children:Te&&e.jsx(xe,{message:{content:Te,icon:!0,type:"Error",visible:!0}})}),e.jsxs(A,{heading:e.jsx(q,{children:"Storage State / Redux"}),children:[K,e.jsx(y,{}),e.jsx(p,{label:"Change value",onClick:()=>F(l.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},G=()=>{const[t,a]=o.useState("123|m");return e.jsx(c,{name:"example",onChange:n=>a(n.target.value),value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};G.play=async({canvasElement:t,step:a})=>{const n=he(t),r=he(t.ownerDocument.body);await a("Can enter decimal values",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"123.123456789"),await x(n.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"-1.12e3"),await x(n.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"123,456"),await x(n.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"0.0000000023"),await x(n.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"999999999999"),await x(n.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const i=n.getByTestId("testId"),m=n.getByTestId("testId-menu");await g.clear(i),await g.type(i,"456.1"),await g.click(m),await g.click(r.getByTestId("testId-unit-ft")),await x(n.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await g.clear(i),await g.type(i,"123x45s6"),await x(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await yn.mouseOver(i),await bn(()=>{x(r.getByText("Must be a numerical value")).toBeInTheDocument()})})};M.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};O.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
11
|
+
target:
|
|
12
|
+
| T
|
|
13
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
14
|
+
}`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
|
|
15
|
+
target:
|
|
16
|
+
| T
|
|
17
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
18
|
+
}`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
|
|
19
|
+
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:""},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:""},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:""},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:""},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:""},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:""},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:""}}};H.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};oe.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};ue.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};de.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};ce.__docgenInfo={description:"",methods:[],displayName:"onSwitchUnit"};me.__docgenInfo={description:"",methods:[],displayName:"ManagedTestCase"};pe.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};L.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"OW_17784TestCase"};ge.__docgenInfo={description:"",methods:[],displayName:"DemoCosmeticRounding"};G.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var $e,ze,Je;Ce.parameters={...Ce.parameters,docs:{...($e=Ce.parameters)==null?void 0:$e.docs,source:{originalSource:`args => {
|
|
20
|
+
const [_, updateArgs] = useArgs();
|
|
21
|
+
const handleChange = (evt: any) => {
|
|
22
|
+
updateArgs({
|
|
23
|
+
value: evt.target.value
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
27
|
+
}`,...(Je=(ze=Ce.parameters)==null?void 0:ze.docs)==null?void 0:Je.source}}};var Ye,Ze,Qe;Y.parameters={...Y.parameters,docs:{...(Ye=Y.parameters)==null?void 0:Ye.docs,source:{originalSource:`args => {
|
|
28
|
+
const [_, updateArgs] = useArgs();
|
|
29
|
+
const handleChange = (evt: any) => {
|
|
30
|
+
updateArgs({
|
|
31
|
+
value: evt.target.value
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
35
|
+
}`,...(Qe=(Ze=Y.parameters)==null?void 0:Ze.docs)==null?void 0:Qe.source}}};var Xe,et,tt;Z.parameters={...Z.parameters,docs:{...(Xe=Z.parameters)==null?void 0:Xe.docs,source:{originalSource:`args => {
|
|
36
|
+
const [_, updateArgs] = useArgs();
|
|
37
|
+
const handleChange = (evt: any) => {
|
|
38
|
+
updateArgs({
|
|
39
|
+
value: evt.target.value
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
43
|
+
}`,...(tt=(et=Z.parameters)==null?void 0:et.docs)==null?void 0:tt.source}}};var nt,at,it;Q.parameters={...Q.parameters,docs:{...(nt=Q.parameters)==null?void 0:nt.docs,source:{originalSource:`args => {
|
|
44
|
+
const [_, updateArgs] = useArgs();
|
|
45
|
+
const handleChange = (evt: any) => {
|
|
46
|
+
updateArgs({
|
|
47
|
+
value: evt.target.value
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
51
|
+
}`,...(it=(at=Q.parameters)==null?void 0:at.docs)==null?void 0:it.source}}};var rt,st,lt;X.parameters={...X.parameters,docs:{...(rt=X.parameters)==null?void 0:rt.docs,source:{originalSource:`args => {
|
|
52
|
+
const [_, updateArgs] = useArgs();
|
|
53
|
+
const handleChange = (evt: any) => {
|
|
54
|
+
updateArgs({
|
|
55
|
+
value: evt.target.value
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
59
|
+
}`,...(lt=(st=X.parameters)==null?void 0:st.docs)==null?void 0:lt.source}}};var ot,ut,dt;ee.parameters={...ee.parameters,docs:{...(ot=ee.parameters)==null?void 0:ot.docs,source:{originalSource:`args => {
|
|
60
|
+
const [_, updateArgs] = useArgs();
|
|
61
|
+
const handleChange = (evt: any) => {
|
|
62
|
+
updateArgs({
|
|
63
|
+
value: evt.target.value
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
67
|
+
}`,...(dt=(ut=ee.parameters)==null?void 0:ut.docs)==null?void 0:dt.source}}};var ct,mt,pt;M.parameters={...M.parameters,docs:{...(ct=M.parameters)==null?void 0:ct.docs,source:{originalSource:`() => {
|
|
68
|
+
const [value, setValue] = useState('123|m');
|
|
69
|
+
return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} placeholder="Type a value..." value={value} initUnit="m" unitkey="depth" unitTemplate={{
|
|
70
|
+
depth: 'm'
|
|
71
|
+
}} testId="testId" />;
|
|
72
|
+
}`,...(pt=(mt=M.parameters)==null?void 0:mt.docs)==null?void 0:pt.source}}};var gt,ht,vt;te.parameters={...te.parameters,docs:{...(gt=te.parameters)==null?void 0:gt.docs,source:{originalSource:`args => {
|
|
73
|
+
const [_, updateArgs] = useArgs();
|
|
74
|
+
const handleChange = (evt: any) => {
|
|
75
|
+
updateArgs({
|
|
76
|
+
value: evt.target.value
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
80
|
+
}`,...(vt=(ht=te.parameters)==null?void 0:ht.docs)==null?void 0:vt.source}}};var ft,yt,bt;ne.parameters={...ne.parameters,docs:{...(ft=ne.parameters)==null?void 0:ft.docs,source:{originalSource:`args => {
|
|
81
|
+
const [_, updateArgs] = useArgs();
|
|
82
|
+
const handleChange = (evt: any) => {
|
|
83
|
+
updateArgs({
|
|
84
|
+
value: evt.target.value
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
88
|
+
}`,...(bt=(yt=ne.parameters)==null?void 0:yt.docs)==null?void 0:bt.source}}};var Ct,Ut,xt;W.parameters={...W.parameters,docs:{...(Ct=W.parameters)==null?void 0:Ct.docs,source:{originalSource:`args => {
|
|
89
|
+
const [_, updateArgs] = useArgs();
|
|
90
|
+
const handleChange = (evt: any) => {
|
|
91
|
+
updateArgs({
|
|
92
|
+
value: evt.target.value
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
96
|
+
}`,...(xt=(Ut=W.parameters)==null?void 0:Ut.docs)==null?void 0:xt.source}}};var It,Tt,wt;ae.parameters={...ae.parameters,docs:{...(It=ae.parameters)==null?void 0:It.docs,source:{originalSource:`args => {
|
|
97
|
+
const [_, updateArgs] = useArgs();
|
|
98
|
+
const handleChange = (evt: any) => {
|
|
99
|
+
updateArgs({
|
|
100
|
+
value: evt.target.value
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
104
|
+
}`,...(wt=(Tt=ae.parameters)==null?void 0:Tt.docs)==null?void 0:wt.source}}};var kt,Vt,St;ie.parameters={...ie.parameters,docs:{...(kt=ie.parameters)==null?void 0:kt.docs,source:{originalSource:`args => {
|
|
105
|
+
const [_, updateArgs] = useArgs();
|
|
106
|
+
const handleChange = (evt: any) => {
|
|
107
|
+
updateArgs({
|
|
108
|
+
value: evt.target.value
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
112
|
+
}`,...(St=(Vt=ie.parameters)==null?void 0:Vt.docs)==null?void 0:St.source}}};var jt,Et,Nt;re.parameters={...re.parameters,docs:{...(jt=re.parameters)==null?void 0:jt.docs,source:{originalSource:`args => {
|
|
113
|
+
const [_, updateArgs] = useArgs();
|
|
114
|
+
const handleChange = (evt: any) => {
|
|
115
|
+
updateArgs({
|
|
116
|
+
value: evt.target.value
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
120
|
+
}`,...(Nt=(Et=re.parameters)==null?void 0:Et.docs)==null?void 0:Nt.source}}};var Bt,Dt,At;se.parameters={...se.parameters,docs:{...(Bt=se.parameters)==null?void 0:Bt.docs,source:{originalSource:`args => {
|
|
121
|
+
const [_, updateArgs] = useArgs();
|
|
122
|
+
const handleChange = (evt: any) => {
|
|
123
|
+
updateArgs({
|
|
124
|
+
value: evt.target.value
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
128
|
+
}`,...(At=(Dt=se.parameters)==null?void 0:Dt.docs)==null?void 0:At.source}}};var qt,Ft,Pt;O.parameters={...O.parameters,docs:{...(qt=O.parameters)==null?void 0:qt.docs,source:{originalSource:`(args: IUnitInputProps) => {
|
|
129
|
+
const [value, setValue] = useState('123|m');
|
|
130
|
+
const [value2, setValue2] = useState('223|m');
|
|
131
|
+
const [initUnit, setInitUnit] = useState('ft');
|
|
132
|
+
return <>
|
|
133
|
+
<Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
|
|
134
|
+
<Spacer />
|
|
135
|
+
<Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
|
|
136
|
+
<Spacer />
|
|
137
|
+
<UnitInput name="example" onChange={evt => {
|
|
138
|
+
setValue(evt.target.value);
|
|
139
|
+
}} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
140
|
+
<Spacer />
|
|
141
|
+
<UnitInput name="example2" onChange={evt => {
|
|
142
|
+
setValue2(evt.target.value);
|
|
143
|
+
}} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
144
|
+
<Divider />
|
|
145
|
+
<h4>Without initUnit property (taken from the redux store)</h4>
|
|
146
|
+
<UnitInput name="example" onChange={evt => {
|
|
147
|
+
setValue(evt.target.value);
|
|
148
|
+
}} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
|
|
149
|
+
<UnitInput name="example2" onChange={evt => {
|
|
150
|
+
setValue2(evt.target.value);
|
|
151
|
+
}} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
|
|
152
|
+
</>;
|
|
153
|
+
}`,...(Pt=(Ft=O.parameters)==null?void 0:Ft.docs)==null?void 0:Pt.source}}};var Rt,_t,Mt;le.parameters={...le.parameters,docs:{...(Rt=le.parameters)==null?void 0:Rt.docs,source:{originalSource:`args => {
|
|
154
|
+
const [_, updateArgs] = useArgs();
|
|
155
|
+
const handleChange = (evt: any) => {
|
|
156
|
+
updateArgs({
|
|
157
|
+
value: evt.target.value
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
161
|
+
}`,...(Mt=(_t=le.parameters)==null?void 0:_t.docs)==null?void 0:Mt.source}}};var Wt,Ot,Ht;H.parameters={...H.parameters,docs:{...(Wt=H.parameters)==null?void 0:Wt.docs,source:{originalSource:`() => {
|
|
162
|
+
const width = '500px';
|
|
163
|
+
const [value, setValue] = useState<any>(undefined);
|
|
164
|
+
return <>
|
|
165
|
+
<h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
|
|
166
|
+
<Row>
|
|
167
|
+
<Column width="25%">
|
|
168
|
+
<Button label="Change value infinity" onClick={() => setValue(Infinity)} />
|
|
169
|
+
<br />
|
|
170
|
+
<Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
|
|
171
|
+
<br />
|
|
172
|
+
<Button label="Change value null" onClick={() => setValue(null)} />
|
|
173
|
+
<br />
|
|
174
|
+
<Button label="Change value - undefined" onClick={() => setValue(undefined)} />
|
|
175
|
+
<br />
|
|
176
|
+
<Button label="Change value - NaN" onClick={() => setValue(NaN)} />
|
|
177
|
+
<br />
|
|
178
|
+
<Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
|
|
179
|
+
<br />
|
|
180
|
+
<Button label="Change value - empty string" onClick={() => setValue('')} />
|
|
181
|
+
</Column>
|
|
182
|
+
<Column width="25%">
|
|
183
|
+
<Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
|
|
184
|
+
<br />
|
|
185
|
+
<Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
|
|
186
|
+
<br />
|
|
187
|
+
<Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
|
|
188
|
+
<br />
|
|
189
|
+
<Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
|
|
190
|
+
<br />
|
|
191
|
+
<Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
|
|
192
|
+
<br />
|
|
193
|
+
<Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
|
|
194
|
+
</Column>
|
|
195
|
+
</Row>
|
|
196
|
+
<br />
|
|
197
|
+
<Field label="Normal PUI">
|
|
198
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
|
|
199
|
+
</Field>
|
|
200
|
+
<Field label="Disabled validation">
|
|
201
|
+
<UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
|
|
202
|
+
</Field>
|
|
203
|
+
<Field label="Disabled validation and manual error">
|
|
204
|
+
<UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
|
|
205
|
+
</Field>
|
|
206
|
+
<Message message={{
|
|
207
|
+
heading: 'Current value inside PUI: ' + value,
|
|
208
|
+
visible: true
|
|
209
|
+
}} />
|
|
210
|
+
</>;
|
|
211
|
+
}`,...(Ht=(Ot=H.parameters)==null?void 0:Ot.docs)==null?void 0:Ht.source}}};var Lt,Gt,Kt;oe.parameters={...oe.parameters,docs:{...(Lt=oe.parameters)==null?void 0:Lt.docs,source:{originalSource:`() => {
|
|
212
|
+
const width = '500px';
|
|
213
|
+
const [value, setValue] = useState<string>('1|m');
|
|
214
|
+
const [valueB, setValueB] = useState('|m');
|
|
215
|
+
const automaticValue = '123|km';
|
|
216
|
+
return <>
|
|
217
|
+
<h4>Different cases for automatic (placeholder) values:</h4>
|
|
218
|
+
<Row>
|
|
219
|
+
<Column width="25%">
|
|
220
|
+
<Button label="Change value to ''" onClick={() => setValue('')} />
|
|
221
|
+
<br />
|
|
222
|
+
<Button label="Change value to 1" onClick={() => setValue('1')} />
|
|
223
|
+
<br />
|
|
224
|
+
<Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
|
|
225
|
+
<br />
|
|
226
|
+
<Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
|
|
227
|
+
</Column>
|
|
228
|
+
</Row>
|
|
229
|
+
<br />
|
|
230
|
+
<Field label="Normal PUI (placeholder + auto)">
|
|
231
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
|
|
232
|
+
</Field>
|
|
233
|
+
<Field label="Normal PUI (only auto)">
|
|
234
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
|
|
235
|
+
</Field>
|
|
236
|
+
<Field label="Empty PUI with autoValue">
|
|
237
|
+
<UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
|
|
238
|
+
</Field>
|
|
239
|
+
<Field label="Normal PUI (only placeholder)">
|
|
240
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
|
|
241
|
+
</Field>
|
|
242
|
+
<Field label="Normal PUI (placeholder + allowEmpty)">
|
|
243
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
|
|
244
|
+
</Field>
|
|
245
|
+
<Message message={{
|
|
246
|
+
heading: 'Current value inside PUI: ' + value,
|
|
247
|
+
visible: true
|
|
248
|
+
}} />
|
|
249
|
+
</>;
|
|
250
|
+
}`,...(Kt=(Gt=oe.parameters)==null?void 0:Gt.docs)==null?void 0:Kt.source}}};var $t,zt,Jt;ue.parameters={...ue.parameters,docs:{...($t=ue.parameters)==null?void 0:$t.docs,source:{originalSource:`() => {
|
|
251
|
+
const [value, setValue] = useState('123|%');
|
|
252
|
+
const [validation, setValidation] = useState<string | null>(null);
|
|
253
|
+
const predictedMessage = 'This should be visible when an error appears';
|
|
254
|
+
const handleValidation = (name: string, error: string | null) => {
|
|
255
|
+
setValidation(error);
|
|
256
|
+
return {
|
|
257
|
+
name,
|
|
258
|
+
error
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
return <>
|
|
262
|
+
<h4>3rd party validation message when inputting invalid value:</h4>
|
|
263
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
|
|
264
|
+
<br />
|
|
265
|
+
<Spacer />
|
|
266
|
+
<h4>Original validation message: </h4>
|
|
267
|
+
<Message message={{
|
|
268
|
+
heading: validation,
|
|
269
|
+
visible: true
|
|
270
|
+
}} />
|
|
271
|
+
</>;
|
|
272
|
+
}`,...(Jt=(zt=ue.parameters)==null?void 0:zt.docs)==null?void 0:Jt.source}}};var Yt,Zt,Qt;de.parameters={...de.parameters,docs:{...(Yt=de.parameters)==null?void 0:Yt.docs,source:{originalSource:`() => {
|
|
273
|
+
const [value, setValue] = useState('123|m');
|
|
274
|
+
const [placeholder, setPlaceholder] = useState('');
|
|
275
|
+
const [initUnit, setInitUnit] = useState('km');
|
|
276
|
+
const setPlaceholderValue = () => {
|
|
277
|
+
setInitUnit('ft');
|
|
278
|
+
setPlaceholder('placeholder');
|
|
279
|
+
setValue('|m');
|
|
280
|
+
};
|
|
281
|
+
return <>
|
|
282
|
+
<h4>Empty value case:</h4>
|
|
283
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
|
|
284
|
+
<br />
|
|
285
|
+
<Spacer />
|
|
286
|
+
<Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
|
|
287
|
+
</>;
|
|
288
|
+
}`,...(Qt=(Zt=de.parameters)==null?void 0:Zt.docs)==null?void 0:Qt.source}}};var Xt,en,tn;ce.parameters={...ce.parameters,docs:{...(Xt=ce.parameters)==null?void 0:Xt.docs,source:{originalSource:`() => {
|
|
289
|
+
const [value, setValue] = useState('123|m');
|
|
290
|
+
const [unit, setUnit] = useState('m');
|
|
291
|
+
return <>
|
|
292
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
293
|
+
<Spacer />
|
|
294
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
295
|
+
</>;
|
|
296
|
+
}`,...(tn=(en=ce.parameters)==null?void 0:en.docs)==null?void 0:tn.source}}};var nn,an,rn;me.parameters={...me.parameters,docs:{...(nn=me.parameters)==null?void 0:nn.docs,source:{originalSource:`() => {
|
|
297
|
+
const [visible, setVisible] = useState(true);
|
|
298
|
+
const triggerRerender = () => {
|
|
299
|
+
setVisible(false);
|
|
300
|
+
setTimeout(() => setVisible(true), 0);
|
|
301
|
+
};
|
|
302
|
+
const [value, setValue] = useState('123|ft');
|
|
303
|
+
return <Grid columns="1fr 1fr" gap>
|
|
304
|
+
<Card heading={<Heading>Storage State (Redux)</Heading>}>
|
|
305
|
+
{value}
|
|
306
|
+
<Spacer />
|
|
307
|
+
<Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'ft'))} />
|
|
308
|
+
</Card>
|
|
309
|
+
<Card heading={<Heading icon={<Icon icon="refresh" testId="triggerRerenderTestId" />} onIconClick={triggerRerender}>
|
|
310
|
+
UnitInput
|
|
311
|
+
</Heading>}>
|
|
312
|
+
{visible && <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
|
|
313
|
+
depth: 'm'
|
|
314
|
+
}} />}
|
|
315
|
+
</Card>
|
|
316
|
+
</Grid>;
|
|
317
|
+
}`,...(rn=(an=me.parameters)==null?void 0:an.docs)==null?void 0:rn.source}}};var sn,ln,on;pe.parameters={...pe.parameters,docs:{...(sn=pe.parameters)==null?void 0:sn.docs,source:{originalSource:`() => {
|
|
318
|
+
return <>
|
|
319
|
+
<Text faint>
|
|
320
|
+
Reproduce OW-10614 rounding noise bug when storing values in a different
|
|
321
|
+
unit to the display unit
|
|
322
|
+
</Text>
|
|
323
|
+
<Spacer />
|
|
324
|
+
<UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
|
|
325
|
+
pressure: 'psi'
|
|
326
|
+
}} />
|
|
327
|
+
<Spacer />
|
|
328
|
+
<UnitInput name="example2" onChange={() => {}} value={withUnit(convertAndGetValue('8642|lbf', 'tonneForce'), 'tonneForce')} initUnit="lbf" unitkey="force" unitTemplate={{
|
|
329
|
+
force: 'tonneForce'
|
|
330
|
+
}} />
|
|
331
|
+
</>;
|
|
332
|
+
}`,...(on=(ln=pe.parameters)==null?void 0:ln.docs)==null?void 0:on.source}}};var un,dn,cn;L.parameters={...L.parameters,docs:{...(un=L.parameters)==null?void 0:un.docs,source:{originalSource:`() => {
|
|
333
|
+
return <>
|
|
334
|
+
<UnitInput name="example" unitkey="moleWeight" initUnit="g/mol" doNotConvertValue //reproduces OW_17784
|
|
335
|
+
value="170|g/mol" unitTemplate={{
|
|
336
|
+
moleWeight: 'g/mol'
|
|
337
|
+
}} testId="case1" />
|
|
338
|
+
<Spacer />
|
|
339
|
+
<UnitInput name="gor" unitkey="moleWeight" initUnit="gor" value="Infinity|SCF/STB" testId="case2" />
|
|
340
|
+
</>;
|
|
341
|
+
}`,...(cn=(dn=L.parameters)==null?void 0:dn.docs)==null?void 0:cn.source}}};var mn,pn,gn;ge.parameters={...ge.parameters,docs:{...(mn=ge.parameters)==null?void 0:mn.docs,source:{originalSource:`() => {
|
|
342
|
+
const [visible, setVisible] = useState(true);
|
|
343
|
+
const triggerRerender = () => {
|
|
344
|
+
setVisible(false);
|
|
345
|
+
setTimeout(() => setVisible(true), 0);
|
|
346
|
+
};
|
|
347
|
+
const [preferredUnit, setPreferredUnit] = useState('psi');
|
|
348
|
+
const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
|
|
349
|
+
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
|
|
350
|
+
const [convertBackToStorageUnit, setConvertBackToStorageUnit] = useState(true);
|
|
351
|
+
const [value, setValue] = useState('672.2388357750001|bar');
|
|
352
|
+
const [callBackError, setCallBackError] = useState('');
|
|
353
|
+
return <Grid columns="1fr 1fr" gap>
|
|
354
|
+
<Card heading={<Heading>Settings</Heading>}>
|
|
355
|
+
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
356
|
+
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
357
|
+
</Field>
|
|
358
|
+
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
359
|
+
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
360
|
+
</Field>
|
|
361
|
+
<Field label="Convert back to storage unit (onChange):" labelLeft labelWidth={200}>
|
|
362
|
+
<Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
|
|
363
|
+
</Field>
|
|
364
|
+
</Card>
|
|
365
|
+
<Card heading={<Heading icon={<Icon icon="refresh" testId="triggerRerenderTestId" />} onIconClick={triggerRerender}>
|
|
366
|
+
UnitInput
|
|
367
|
+
</Heading>}>
|
|
368
|
+
<Text faint>
|
|
369
|
+
Cosmetic Rounding Test Case: type 9750 then return (compare with
|
|
370
|
+
enableCosmeticRounding on and off)
|
|
371
|
+
</Text>
|
|
372
|
+
<Spacer />
|
|
373
|
+
<Text warning>
|
|
374
|
+
Note: UnitInput uses convertSamePrecision internally (decision prior
|
|
375
|
+
to cosmetic value implementation). This means not all rounding noise
|
|
376
|
+
occurrences seen in NumberInput will be reproducible in UnitInput,
|
|
377
|
+
because they get rounded off by other logic.
|
|
378
|
+
</Text>
|
|
379
|
+
<Spacer />
|
|
380
|
+
{visible && <UnitInput name="Example" unitkey="pressure" initUnit={preferredUnit} unitTemplate={{
|
|
381
|
+
pressure: 'psi'
|
|
382
|
+
}} value={value} onChange={evt => {
|
|
383
|
+
const {
|
|
384
|
+
value
|
|
385
|
+
} = evt.target;
|
|
386
|
+
if (value) {
|
|
387
|
+
setValue(value);
|
|
388
|
+
}
|
|
389
|
+
}} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={convertAndGetValue(value, 'bar') >= 0 ? '' : 'Value must be positive'} validationCallback={(name, error) => {
|
|
390
|
+
setCallBackError(error ?? '');
|
|
391
|
+
}} convertBackToStorageUnit={convertBackToStorageUnit} />}
|
|
392
|
+
</Card>
|
|
393
|
+
<Card heading={<Heading>Unit Template</Heading>}>
|
|
394
|
+
<Select options={[{
|
|
395
|
+
label: 'Bar',
|
|
396
|
+
value: 'bar'
|
|
397
|
+
}, {
|
|
398
|
+
label: 'psi',
|
|
399
|
+
value: 'psi'
|
|
400
|
+
}]} value={preferredUnit} width={70} onChange={evt => setPreferredUnit(evt.target.value)} />
|
|
401
|
+
</Card>
|
|
402
|
+
<Card heading={<Heading>Test Validation Callback</Heading>}>
|
|
403
|
+
{callBackError && <Message message={{
|
|
404
|
+
content: callBackError,
|
|
405
|
+
icon: true,
|
|
406
|
+
type: 'Error',
|
|
407
|
+
visible: true
|
|
408
|
+
}} />}
|
|
409
|
+
</Card>
|
|
410
|
+
<Card heading={<Heading>Storage State / Redux</Heading>}>
|
|
411
|
+
{value}
|
|
412
|
+
<Spacer />
|
|
413
|
+
<Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'bar'))} />
|
|
414
|
+
</Card>
|
|
415
|
+
</Grid>;
|
|
416
|
+
}`,...(gn=(pn=ge.parameters)==null?void 0:pn.docs)==null?void 0:gn.source}}};var hn,vn,fn;G.parameters={...G.parameters,docs:{...(hn=G.parameters)==null?void 0:hn.docs,source:{originalSource:`() => {
|
|
417
|
+
const [value, setValue] = useState('123|m');
|
|
418
|
+
return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
|
|
419
|
+
depth: 'm'
|
|
420
|
+
}} testId="testId" />;
|
|
421
|
+
}`,...(fn=(vn=G.parameters)==null?void 0:vn.docs)==null?void 0:fn.source}}};const ei=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Placeholder","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","ManagedTestCase","OW_10614TestCase","OW_17784TestCase","DemoCosmeticRounding","TestUserInput"];export{de as AllowEmptyPUI,oe as AutomaticValues,Ce as Default,ge as DemoCosmeticRounding,W as Disabled,ae as DisabledNoConversion,re as DisabledUnitWithUnitKey,ie as DisabledUnitWithoutUnitKey,se as DisabledWithEnabledUnitMenu,te as Error,Y as InitUnit,ne as InternalValidationError,me as ManagedTestCase,X as NoConversion,pe as OW_10614TestCase,L as OW_17784TestCase,M as Placeholder,le as PredefinedOptionsMenu,ee as Small,H as TestEdgeCases,O as TestExternalStateChangeWithSynchronizedUnits,G as TestUserInput,ue as ValidationCallback,Q as Width,ei as __namedExportsOrder,Xa as default,Z as notKnownUnit,ce as onSwitchUnit};
|