@oliasoft-open-source/react-ui-library 4.9.0 → 4.9.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.
- package/dist/index.js +83 -143
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-BnHaqcsT.js → Color-KGDBMAHA-sr_lo8VN.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DcoD1y-5.js → DocsRenderer-PKQXORMH-Dio4TQT6.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-D0wb2n-9.js → accordion.stories-BtQXhKld.js} +2 -2
- package/dist/storybook/assets/{afe.stories-DM18uTAa.js → afe.stories-DFQsvqIV.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-jPZ2UUsp.js → buttons-and-links-BOcv8xIU.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-Dga1QkGC.js → casing-loads.stories-1KCWDoR3.js} +2 -2
- package/dist/storybook/assets/{cell.stories-DfyQwzEH.js → cell.stories-CBq3IOiP.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-D2AwGCE9.js → chunk-HLWAVYOI-SLqzrZ8s.js} +1 -1
- package/dist/storybook/assets/{color-CLf9xt55.js → color-D1FmkH7Y.js} +1 -1
- package/dist/storybook/assets/footer.stories-D-rIL9Q8.js +3 -0
- package/dist/storybook/assets/form.stories-BrUnmw7R.js +49 -0
- package/dist/storybook/assets/{formation.stories-CZGQhWyA.js → formation.stories-ByGQlyM6.js} +2 -2
- package/dist/storybook/assets/iframe-NUuxNiwO.js +2 -0
- package/dist/storybook/assets/{index-Sr04i8ct.js → index-Bhtru3gK.js} +4 -4
- package/dist/storybook/assets/{index-BQ_6rM6u.js → index-DNcuiqfZ.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-EhmORqH9.js → input-group.stories-CElwRt3p.js} +3 -3
- package/dist/storybook/assets/{input-validation-Tr-aD1VJ.js → input-validation-FFJCXfNa.js} +2 -2
- package/dist/storybook/assets/{inputs-BGIgggtv.js → inputs-D3ZjmDIl.js} +1 -1
- package/dist/storybook/assets/{layout-forms-n-mRkolR.js → layout-forms-DNUCHjRh.js} +5 -5
- package/dist/storybook/assets/{layout-general-CNsKoPG6.js → layout-general-CuxE1EOt.js} +1 -1
- package/dist/storybook/assets/{modal.stories-C6Bh0Oda.js → modal.stories-LhoWfDE6.js} +2 -2
- package/dist/storybook/assets/number-input-F3bqJ0z5.js +16 -0
- package/dist/storybook/assets/number-input.stories-Dw2eW2Mc.js +166 -0
- package/dist/storybook/assets/{padding-and-spacing-B10oZ-Ww.js → padding-and-spacing-B-LaxRb4.js} +1 -1
- package/dist/storybook/assets/{pagination-DWc8zp3k.js → pagination-CLt-kUlx.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-B5cOvzik.js → pagination.stories-CTRM0Xou.js} +2 -2
- package/dist/storybook/assets/popover.stories-CGm0M5fv.js +10 -0
- package/dist/storybook/assets/{preview-Cym3ID9p.js → preview-ClcAw55r.js} +2 -2
- package/dist/storybook/assets/{preview-pQMX-q5x.js → preview-DQgT2zeu.js} +1 -1
- package/dist/storybook/assets/{projects.stories-Co_WnKSx.js → projects.stories-BQswWVCx.js} +2 -2
- package/dist/storybook/assets/{radio-button-C4ljBRED.js → radio-button-DmDuw4DA.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-BzyW2CtK.js → radio-button.stories-5gvV0LD0.js} +2 -2
- package/dist/storybook/assets/{reservoirs.stories-UW_8sofe.js → reservoirs.stories-B12tIrmZ.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-0pm7-gTq.js → rich-text-input.stories-hAHCnDHk.js} +3 -3
- package/dist/storybook/assets/{row.stories-B8OWE9yd.js → row.stories-ghcsAzwW.js} +2 -2
- package/dist/storybook/assets/select-DnRuRG_N.js +61 -0
- package/dist/storybook/assets/select.input-D0UkAPd9.js +1 -0
- package/dist/storybook/assets/{select.stories-B0KIHiMX.js → select.stories-B9w9ONzj.js} +2 -2
- package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-umpPYjkq.js} +2 -2
- package/dist/storybook/assets/{table-qmf29AIJ.js → table-BCdvBxub.js} +1 -1
- package/dist/storybook/assets/{table.stories-DzHGqXth.js → table.stories-DkmbUVHr.js} +2 -2
- package/dist/storybook/assets/{tabs-BoToLVEP.js → tabs-C3NG6m9W.js} +1 -1
- package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +30 -0
- package/dist/storybook/assets/{title.stories-B8l1sfdo.js → title.stories-DpFDK9o1.js} +3 -3
- package/dist/storybook/assets/unit-input.stories-BHTxKnOU.js +380 -0
- package/dist/storybook/assets/unit-table.stories-u1PeEt0F.js +152 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/enum-Bnn40S8Q.js +0 -1
- package/dist/storybook/assets/footer.stories-DYBxUtZh.js +0 -3
- package/dist/storybook/assets/form.stories-BLcmnfy8.js +0 -49
- package/dist/storybook/assets/helpers-JJxzGegQ.js +0 -1
- package/dist/storybook/assets/iframe-BnDar59m.js +0 -2
- package/dist/storybook/assets/number-input-DZ9ERbK_.js +0 -16
- package/dist/storybook/assets/number-input.stories-CmVUHT2d.js +0 -124
- package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +0 -10
- package/dist/storybook/assets/select-03uRbc4I.js +0 -61
- package/dist/storybook/assets/select.input-CJed_LLR.js +0 -1
- package/dist/storybook/assets/tabs.stories-B52iEaHf.js +0 -30
- package/dist/storybook/assets/unit-input.stories-BnLB_Avl.js +0 -316
- package/dist/storybook/assets/unit-table.stories-DquyyMbD.js +0 -152
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-
|
|
1
|
+
import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-BCdvBxub.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-D52aKMY1.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-DazXb-ul.js";import"./inheritsLoose-DP0QEDDI.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-D-uVCDzk.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-CRNoBc7q.js";import"./help-icon-Buhx5nl6.js";import"./pagination-CLt-kUlx.js";import"./select-DnRuRG_N.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-D0UkAPd9.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-F3bqJ0z5.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";import"./flex-EllkLxgO.js";const Gr={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const l=r.bind({});l.args={table:Q};var m,c,d;e.parameters={...e.parameters,docs:{...(m=e.parameters)==null?void 0:m.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -30,8 +30,8 @@ import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-qmf29AI
|
|
|
30
30
|
return <Table
|
|
31
31
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
32
32
|
{...args} />;
|
|
33
|
-
}`,...(E=(y=p.parameters)==null?void 0:y.docs)==null?void 0:E.source}}};var N,U,_;
|
|
33
|
+
}`,...(E=(y=p.parameters)==null?void 0:y.docs)==null?void 0:E.source}}};var N,U,_;l.parameters={...l.parameters,docs:{...(N=l.parameters)==null?void 0:N.docs,source:{originalSource:`args => {
|
|
34
34
|
return <Table
|
|
35
35
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
36
|
{...args} />;
|
|
37
|
-
}`,...(_=(U=
|
|
37
|
+
}`,...(_=(U=l.parameters)==null?void 0:U.docs)==null?void 0:_.source}}};const Kr=["Units","ActiveRow","Title","TitleJSX","ChildComponent","Filter","Sort","HeaderActionsNoLabel","HelpAndLibraryIcons"];export{s as ActiveRow,o as ChildComponent,n as Filter,p as HeaderActionsNoLabel,l as HelpAndLibraryIcons,i as Sort,a as Title,t as TitleJSX,e as Units,Kr as __namedExportsOrder,Gr as default};
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as u}from"./index-DhsZuJvc.js";import{d as s}from"./index-C0x1JmaP.js";import{w as ve,u as c,e as I,f as on,a as un}from"./index-DMAnyMX5.js";import{c as Dn}from"./index-Bk2sglWO.js";import{u as qn}from"./use-previous-D775JrO6.js";import{M as Pe}from"./actions-D-uVCDzk.js";import{I as An}from"./input-group-addon-D68iUKV2.js";import{B as g}from"./button-DHevvVBE.js";import{T as Bn}from"./tooltip-1V7clEnw.js";import{I as Fn}from"./input-group-BaRSJAEN.js";import{S as C}from"./spacer-BWoNR27H.js";import{T as fe}from"./text-B3-TSWok.js";import{M as _e}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{N as Pn,r as _n}from"./number-input-F3bqJ0z5.js";import{i as Rn}from"./select.input-D0UkAPd9.js";import{D as Mn}from"./divider-DY9nJ_7N.js";import{R as dn,C as Te}from"./row-Bmiy2Lh0.js";import{F as T}from"./field-HrLaMLbx.js";import{M as ye}from"./message-Y48EomV-.js";import{G as On}from"./grid-DRkC-bt8.js";import{C as H}from"./card-EcjmryU9.js";import{H as G}from"./heading-CRNoBc7q.js";import{T as Re}from"./toggle-BbFVf61v.js";import{S as Wn}from"./select-DnRuRG_N.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.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"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";const Ln=()=>{const t=u.useRef(null);return u.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},Hn=(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.`),s.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const cn=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),mn=(t="",a,n="",l=!1)=>{if(l)return t;if(a&&!cn(t))try{const i=s.isValueWithUnit(t)?t:s.withUnit(t,n),p=s.convertSamePrecision(i,a);return s.getValue(p)}catch{}return t},Gn=t=>t?!!s.getUnit(t):!1,K=(t="",a,n,l)=>{if(l)return t;const i=Gn(t)||s.isValueWithUnit(t),p=s.getValue(t);return cn(p)?p:i?mn(p,a,n,l):t},Me=t=>V.isObject(t)&&!V.isArray(t)&&!V.isFunction(t)?V.get(t,"fieldName",""):typeof t=="string"?t:"",Oe=(t="")=>{var a;return(a=s.KNOWN_UNITS)==null?void 0:a.includes(t)},Kn=(t,a)=>{const n=s.getUnit(t||"");return Oe(a)&&Oe(n)};let $n=u.createContext(null);const zn=()=>u.useContext($n),Jn="_predefinedMenuActive_ye9w9_1",Yn="_inputWrapper_ye9w9_4",We={predefinedMenuActive:Jn,inputWrapper:Yn},m=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:l=!1,error:i=null,left:p=!1,small:o=!1,width:h="100%",value:v,unitkey:D="",initUnit:U,noConversion:q=!1,onChange:be=V.noop,onClick:Qn=V.noop,onFocus:pn=V.noop,onSwitchUnit:ke=V.noop,unitTemplate:Ve,doNotConvertValue:W=!1,testId:A,warning:je=null,predefinedOptions:k,initialPredefinedOption:gn=!1,shouldLinkAutomaticly:Se=!0,selectedPredefinedOptionKey:Ee,validationCallback:hn=()=>({name:"",error:null}),disabledValidation:vn=!1,allowEmpty:fn=!1,autoValue:j,convertBackToStorageUnit:yn=!1,enableCosmeticRounding:Ne=!1,enableDisplayRounding:bn=!1})=>{const B=zn(),Cn=Ln();typeof v=="number"&&(v=`${v}`);const[De="",S=""]=v!==void 0?s.split(v):[],qe=j?s.getUnit(j):"",Ae=u.useMemo(()=>Hn(D,Ve||(B==null?void 0:B.unitTemplate)),[D,Ve,B==null?void 0:B.unitTemplate]),Un=Kn(v,Ae),x=U||Ae||S,xn=qn(x),Be=K(v,x,S,W),Fe=K(j,x,qe,W),wn=Be!==""?{value:Be,unit:x}:Fe!==""?{value:Fe,unit:x}:{value:De,unit:S},[f,Ce]=u.useState(wn),[E,Ue]=u.useState(gn?b.PREDEFINED:b.CUSTOM),xe=De===""&&j,In=!!(vn||j||a&&Rn(v)),L=k&&k.find(r=>{if(!(r!=null&&r.value))return;if(Ee)return Ee===r.valueKey;const d=s.isValueWithUnit(r.value)?s.getUnit(r.value):"";return s.withUnit(mn(v,d),d)===r.value}),Tn=()=>{if(D)try{const r=xe?j:v??"";let d=s.altUnitsList(r,D);return s.getValue(r)===""?d.map(w=>["",w[1]]):d}catch{return null}},kn=r=>{const d=Me(t),w=r.target,{value:N,selectionStart:F}=w,ge=s.withUnit(N,(f==null?void 0:f.unit)||""),Ie=yn?s.withUnit(s.convertAndGetValue(ge,S),S):ge;be({target:{value:Ie,name:d}});const[En,Nn]=s.split(ge);Ce({value:En,unit:Nn}),Cn(()=>{w.selectionStart=F,w.selectionEnd=F})},Vn=(r,d)=>{d===f.unit||isNaN(Number(r))||(Ce({value:r,unit:d}),ke&&ke(d))};u.useEffect(()=>{if(x){let r,d="";xn!==x?(r=K(v,x,S,W),d=x):s.withUnit(f.value,f.unit)!==v&&(r=K(v,f.unit,S,W),d=f.unit),r!==void 0&&Ce({value:r,unit:d}),k&&Ue(L&&Se?b.PREDEFINED:b.CUSTOM)}},[x,v,i,Se]);const ce=Tn(),me=s.label(f.unit)||f.unit||"",jn=q||!ce||ce&&ce.length===1,we=Me(t);let pe;const Sn=r=>{const d=r!=null&&r.value?r.value:"",[w="",N=""]=s.isValueWithUnit(d)?s.split(d):[d];return{type:_e.OPTION,inline:!0,onClick:()=>{s.validateNumber(w).valid&&!n&&(Ue(b.PREDEFINED),be({target:{value:d,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:r}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(fe,{children:r.label}),e.jsx(C,{width:"20px",height:"0"})]}),description:s.isValueWithUnit(d)?`${w} ${N}`:d,selected:L===r&&E===b.PREDEFINED}};if(pe=[{type:_e.OPTION,inline:!0,onClick:()=>{E!==b.CUSTOM&&!n&&be({target:{value:s.withUnit(f.value,f.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:E===b.CUSTOM}],k!=null&&k.length){const r=k.map(Sn);pe=[...pe,...r]}return e.jsx("div",{className:E===b.PREDEFINED?Dn(We.predefinedMenuActive):"",children:e.jsxs(Fn,{small:o,width:h,children:[k&&e.jsx(Bn,{text:E===b.PREDEFINED?L==null?void 0:L.label:"",children:e.jsx(Pe,{maxHeight:380,groupOrder:"first",testId:A&&`${A}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(g,{groupOrder:"first",active:E===b.PREDEFINED,icon:E===b.PREDEFINED?"link":"unlink"}),small:o,sections:pe}})}),e.jsx("div",{className:We.inputWrapper,children:e.jsx(Pn,{name:we,testId:A,disabled:n,placeholder:xe?K(j,f.unit,qe,W):a,value:f.value,onChange:kn,onFocus:pn,error:i===null?void 0:i,warning:je===null?void 0:je,left:p,allowEmpty:fn,validationCallback:(r,d)=>hn(we,d),enableCosmeticRounding:Ne,enableDisplayRounding:bn,groupOrder:k?"middle":"first",disableInternalErrorValidationMessages:In,small:o},we)}),me&&(jn||!Un?e.jsx(An,{groupOrder:"last",children:me}):e.jsx(Pe,{maxHeight:380,groupOrder:"last",disabled:l,testId:A&&`${A}-menu`,menu:{label:me,trigger:"DropDownButton",small:o,sections:ce.map(([r,d,w])=>{const N=w||d||"",F=isNaN(Number(r))?"":r;return{type:"Option",label:Ne?_n(F):F,inline:!0,onClick:Ie=>{Ie.stopPropagation(),Vn(xe?"":r,d)},description:N,selected:N===me,testId:`${A}-unit-${N}`}})}}))]})})};m.__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:"false",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}}}};const{useArgs:Zn}=__STORYBOOK_MODULE_PREVIEW_API__,La={title:"Forms/UnitInput",component:m,args:{name:"example",unitkey:"length",value:"123|m"}},y=t=>{const[a,n]=Zn(),l=i=>{n({value:i.target.value})};return e.jsx(m,{...t,onChange:l})},he=y.bind({}),$=y.bind({});$.args={initUnit:"ft",unitTemplate:{length:"ft"}};const z=y.bind({});z.args={value:'123|"',unitkey:'"'};const J=y.bind({});J.args={width:"180px"};const Y=y.bind({});Y.args={noConversion:!0};const Z=y.bind({});Z.args={small:!0};const P=()=>{const[t,a]=u.useState("123|m");return e.jsx(m,{name:"example",onChange:n=>a(n.target.value),placeholder:"Type a value...",value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};P.play=async({canvasElement:t,step:a})=>{const n=ve(t),l=ve(t.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"123x45s6"),await c.click(t),await I(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await on.mouseOver(i),await un(()=>{I(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};const Q=y.bind({});Q.args={error:"Error message goes here"};const X=y.bind({});X.args={value:"asas123asd|%"};const _=y.bind({});_.args={disabled:!0,disabledUnit:!0};_.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 ee=y.bind({});ee.args={disabled:!0,disabledUnit:!0,noConversion:!0};const te=y.bind({});te.args={disabledUnit:!0,unitkey:void 0};const ne=y.bind({});ne.args={disabledUnit:!0,unitkey:"length"};const ae=y.bind({});ae.args={disabledUnit:!1,disabled:!0};const R=t=>{const[a,n]=u.useState("123|m"),[l,i]=u.useState("223|m"),[p,o]=u.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Change initUnit",onClick:()=>o(p==="m"?"ft":"m")}),e.jsx(C,{}),e.jsx(g,{label:"Change value",onClick:()=>n(a==="123|m"?"456|m":"123|m")}),e.jsx(C,{}),e.jsx(m,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,initUnit:p,onSwitchUnit:o}),e.jsx(C,{}),e.jsx(m,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:l,initUnit:p,onSwitchUnit:o}),e.jsx(Mn,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(m,{name:"example",onChange:h=>{n(h.target.value)},unitkey:"length",value:a,onSwitchUnit:o}),e.jsx(m,{name:"example2",onChange:h=>{i(h.target.value)},unitkey:"length",value:l,onSwitchUnit:o})]})};R.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const ie=y.bind({});ie.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const M=()=>{const t="500px",[a,n]=u.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(dn,{children:[e.jsxs(Te,{width:"25%",children:[e.jsx(g,{label:"Change value infinity",onClick:()=>n(1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity",onClick:()=>n(-1/0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value null",onClick:()=>n(null)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN",onClick:()=>n(NaN)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)",onClick:()=>n(void 0)}),e.jsx("br",{}),e.jsx(g,{label:"Change value - empty string",onClick:()=>n("")})]}),e.jsxs(Te,{width:"25%",children:[e.jsx(g,{label:"Change value infinity|m",onClick:()=>n("Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value -infinity|m",onClick:()=>n("-Infinity|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value null|m",onClick:()=>n("null|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - undefined|m",onClick:()=>n("undefined|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - NaN|m",onClick:()=>n("NaN|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value - nothing (empty)|m",onClick:()=>n("|m")})]})]}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI",children:e.jsx(m,{name:"example1",onChange:l=>n(l.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit"})}),e.jsx(T,{label:"Disabled validation",children:e.jsx(m,{name:"example2",onChange:l=>n(l.target.value),value:a,unitkey:"length",disabledValidation:!0,width:t})}),e.jsx(T,{label:"Disabled validation and manual error",children:e.jsx(m,{name:"example3",onChange:l=>n(l.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:t})}),e.jsx(ye,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},re=()=>{const t="500px",[a,n]=u.useState("1|m"),[l,i]=u.useState("|m"),p="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(dn,{children:e.jsxs(Te,{width:"25%",children:[e.jsx(g,{label:"Change value to ''",onClick:()=>n("")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1",onClick:()=>n("1")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to 1|m",onClick:()=>n("1|m")}),e.jsx("br",{}),e.jsx(g,{label:"Change value to |m - empty value",onClick:()=>n("|m")})]})}),e.jsx("br",{}),e.jsx(T,{label:"Normal PUI (placeholder + auto)",children:e.jsx(m,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"value|unit",autoValue:p})}),e.jsx(T,{label:"Normal PUI (only auto)",children:e.jsx(m,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Empty PUI with autoValue",children:e.jsx(m,{name:"example1",onChange:o=>i(o.target.value),value:l,unitkey:"length",width:t,autoValue:p})}),e.jsx(T,{label:"Normal PUI (only placeholder)",children:e.jsx(m,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test"})}),e.jsx(T,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(m,{name:"example1",onChange:o=>n(o.target.value),value:a,unitkey:"length",width:t,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(ye,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};M.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const se=()=>{const[t,a]=u.useState("123|%"),[n,l]=u.useState(null),i="This should be visible when an error appears",p=(o,h)=>(l(h),{name:o,error:h});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(m,{name:"example",onChange:o=>a(o.target.value),error:!n||i,validationCallback:p,value:t}),e.jsx("br",{}),e.jsx(C,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(ye,{message:{heading:n,visible:!0}})]})},le=()=>{const[t,a]=u.useState("123|m"),[n,l]=u.useState(""),[i,p]=u.useState("km"),o=()=>{p("ft"),l("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(m,{name:"example",onChange:h=>a(h.target.value),value:t,allowEmpty:!0,placeholder:n,initUnit:i,unitkey:"length"}),e.jsx("br",{}),e.jsx(C,{}),e.jsx(g,{label:"Change value |m and unit ft",onClick:()=>o()})]})},oe=()=>{const[t,a]=u.useState("123|m"),[n,l]=u.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(m,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:l}),e.jsx(C,{}),e.jsx(m,{name:"example",onChange:i=>a(i.target.value),value:t,initUnit:n,unitkey:"length",onSwitchUnit:l})]})},ue=()=>e.jsxs(e.Fragment,{children:[e.jsx(fe,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(C,{}),e.jsx(m,{name:"example",onChange:()=>{},value:s.withUnit(s.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(C,{}),e.jsx(m,{name:"example2",onChange:()=>{},value:s.withUnit(s.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),de=()=>{const[t,a]=u.useState("psi"),[n,l]=u.useState(!1),[i,p]=u.useState(!0),[o,h]=u.useState("672.2388357750001|bar"),[v,D]=u.useState("");return e.jsxs(On,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(H,{heading:e.jsx(G,{children:"Settings"}),children:[e.jsx(T,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Re,{checked:n,onChange:U=>l(U.target.checked)})}),e.jsx(T,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Re,{checked:i,onChange:U=>p(U.target.checked)})})]}),e.jsxs(H,{heading:e.jsx(G,{children:"NumberInput (displayed in Meters)"}),children:[e.jsx(fe,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(C,{}),e.jsx(fe,{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(C,{}),e.jsx(m,{name:"Example",unitkey:"pressure",initUnit:t,unitTemplate:{pressure:"psi"},value:o,onChange:U=>{const{value:q}=U.target;q&&h(q)},enableDisplayRounding:n,enableCosmeticRounding:i,error:s.convertAndGetValue(o,"bar")>=0?"":"Value must be positive",validationCallback:(U,q)=>{D(q??"")},convertBackToStorageUnit:!0})]}),e.jsx(H,{heading:e.jsx(G,{children:"Unit Template"}),children:e.jsx(Wn,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:t,width:70,onChange:U=>a(U.target.value)})}),e.jsx(H,{heading:e.jsx(G,{children:"Test Validation Callback"}),children:v&&e.jsx(ye,{message:{content:v,icon:!0,type:"Error",visible:!0}})}),e.jsxs(H,{heading:e.jsx(G,{children:"Storage State / Redux (stored in Feet)"}),children:[o,e.jsx(C,{}),e.jsx(g,{label:"Change value",onClick:()=>h(s.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},O=()=>{const[t,a]=u.useState("123|m");return e.jsx(m,{name:"example",onChange:n=>a(n.target.value),value:t,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};O.play=async({canvasElement:t,step:a})=>{const n=ve(t),l=ve(t.ownerDocument.body);await a("Can enter decimal values",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"123.123456789"),await c.click(t),await I(n.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"-1.12e3"),await c.click(t),await I(n.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"123,456"),await c.click(t),await I(n.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"0.0000000023"),await c.click(t),await I(n.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"999999999999"),await c.click(t),await I(n.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const i=n.getByTestId("testId"),p=n.getByTestId("testId-menu");await c.clear(i),await c.type(i,"456.1"),await c.click(t),await c.click(p),await c.click(l.getByTestId("testId-unit-ft")),await I(n.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const i=n.getByTestId("testId");await c.clear(i),await c.type(i,"123x45s6"),await c.click(t),await I(n.getByDisplayValue("123x45s6")).toBeInTheDocument(),await on.mouseOver(i),await un(()=>{I(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};P.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};R.__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:""}}};M.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};re.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};se.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};le.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};oe.__docgenInfo={description:"",methods:[],displayName:"onSwitchUnit"};ue.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};de.__docgenInfo={description:"",methods:[],displayName:"DemoCosmeticRounding"};O.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var Le,He,Ge;he.parameters={...he.parameters,docs:{...(Le=he.parameters)==null?void 0:Le.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
|
+
}`,...(Ge=(He=he.parameters)==null?void 0:He.docs)==null?void 0:Ge.source}}};var Ke,$e,ze;$.parameters={...$.parameters,docs:{...(Ke=$.parameters)==null?void 0:Ke.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
|
+
}`,...(ze=($e=$.parameters)==null?void 0:$e.docs)==null?void 0:ze.source}}};var Je,Ye,Ze;z.parameters={...z.parameters,docs:{...(Je=z.parameters)==null?void 0:Je.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
|
+
}`,...(Ze=(Ye=z.parameters)==null?void 0:Ye.docs)==null?void 0:Ze.source}}};var Qe,Xe,et;J.parameters={...J.parameters,docs:{...(Qe=J.parameters)==null?void 0:Qe.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
|
+
}`,...(et=(Xe=J.parameters)==null?void 0:Xe.docs)==null?void 0:et.source}}};var tt,nt,at;Y.parameters={...Y.parameters,docs:{...(tt=Y.parameters)==null?void 0:tt.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
|
+
}`,...(at=(nt=Y.parameters)==null?void 0:nt.docs)==null?void 0:at.source}}};var it,rt,st;Z.parameters={...Z.parameters,docs:{...(it=Z.parameters)==null?void 0:it.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
|
+
}`,...(st=(rt=Z.parameters)==null?void 0:rt.docs)==null?void 0:st.source}}};var lt,ot,ut;P.parameters={...P.parameters,docs:{...(lt=P.parameters)==null?void 0:lt.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
|
+
}`,...(ut=(ot=P.parameters)==null?void 0:ot.docs)==null?void 0:ut.source}}};var dt,ct,mt;Q.parameters={...Q.parameters,docs:{...(dt=Q.parameters)==null?void 0:dt.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
|
+
}`,...(mt=(ct=Q.parameters)==null?void 0:ct.docs)==null?void 0:mt.source}}};var pt,gt,ht;X.parameters={...X.parameters,docs:{...(pt=X.parameters)==null?void 0:pt.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
|
+
}`,...(ht=(gt=X.parameters)==null?void 0:gt.docs)==null?void 0:ht.source}}};var vt,ft,yt;_.parameters={..._.parameters,docs:{...(vt=_.parameters)==null?void 0:vt.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
|
+
}`,...(yt=(ft=_.parameters)==null?void 0:ft.docs)==null?void 0:yt.source}}};var bt,Ct,Ut;ee.parameters={...ee.parameters,docs:{...(bt=ee.parameters)==null?void 0:bt.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
|
+
}`,...(Ut=(Ct=ee.parameters)==null?void 0:Ct.docs)==null?void 0:Ut.source}}};var xt,wt,It;te.parameters={...te.parameters,docs:{...(xt=te.parameters)==null?void 0:xt.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
|
+
}`,...(It=(wt=te.parameters)==null?void 0:wt.docs)==null?void 0:It.source}}};var Tt,kt,Vt;ne.parameters={...ne.parameters,docs:{...(Tt=ne.parameters)==null?void 0:Tt.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
|
+
}`,...(Vt=(kt=ne.parameters)==null?void 0:kt.docs)==null?void 0:Vt.source}}};var jt,St,Et;ae.parameters={...ae.parameters,docs:{...(jt=ae.parameters)==null?void 0:jt.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
|
+
}`,...(Et=(St=ae.parameters)==null?void 0:St.docs)==null?void 0:Et.source}}};var Nt,Dt,qt;R.parameters={...R.parameters,docs:{...(Nt=R.parameters)==null?void 0:Nt.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
|
+
}`,...(qt=(Dt=R.parameters)==null?void 0:Dt.docs)==null?void 0:qt.source}}};var At,Bt,Ft;ie.parameters={...ie.parameters,docs:{...(At=ie.parameters)==null?void 0:At.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
|
+
}`,...(Ft=(Bt=ie.parameters)==null?void 0:Bt.docs)==null?void 0:Ft.source}}};var Pt,_t,Rt;M.parameters={...M.parameters,docs:{...(Pt=M.parameters)==null?void 0:Pt.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
|
+
}`,...(Rt=(_t=M.parameters)==null?void 0:_t.docs)==null?void 0:Rt.source}}};var Mt,Ot,Wt;re.parameters={...re.parameters,docs:{...(Mt=re.parameters)==null?void 0:Mt.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
|
+
}`,...(Wt=(Ot=re.parameters)==null?void 0:Ot.docs)==null?void 0:Wt.source}}};var Lt,Ht,Gt;se.parameters={...se.parameters,docs:{...(Lt=se.parameters)==null?void 0:Lt.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
|
+
}`,...(Gt=(Ht=se.parameters)==null?void 0:Ht.docs)==null?void 0:Gt.source}}};var Kt,$t,zt;le.parameters={...le.parameters,docs:{...(Kt=le.parameters)==null?void 0:Kt.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
|
+
}`,...(zt=($t=le.parameters)==null?void 0:$t.docs)==null?void 0:zt.source}}};var Jt,Yt,Zt;oe.parameters={...oe.parameters,docs:{...(Jt=oe.parameters)==null?void 0:Jt.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
|
+
}`,...(Zt=(Yt=oe.parameters)==null?void 0:Yt.docs)==null?void 0:Zt.source}}};var Qt,Xt,en;ue.parameters={...ue.parameters,docs:{...(Qt=ue.parameters)==null?void 0:Qt.docs,source:{originalSource:`() => {
|
|
297
|
+
return <>
|
|
298
|
+
<Text faint>
|
|
299
|
+
Reproduce OW-10614 rounding noise bug when storing values in a different
|
|
300
|
+
unit to the display unit
|
|
301
|
+
</Text>
|
|
302
|
+
<Spacer />
|
|
303
|
+
<UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
|
|
304
|
+
pressure: 'psi'
|
|
305
|
+
}} />
|
|
306
|
+
<Spacer />
|
|
307
|
+
<UnitInput name="example2" onChange={() => {}} value={withUnit(convertAndGetValue('8642|lbf', 'tonneForce'), 'tonneForce')} initUnit="lbf" unitkey="force" unitTemplate={{
|
|
308
|
+
force: 'tonneForce'
|
|
309
|
+
}} />
|
|
310
|
+
</>;
|
|
311
|
+
}`,...(en=(Xt=ue.parameters)==null?void 0:Xt.docs)==null?void 0:en.source}}};var tn,nn,an;de.parameters={...de.parameters,docs:{...(tn=de.parameters)==null?void 0:tn.docs,source:{originalSource:`() => {
|
|
312
|
+
const [preferredUnit, setPreferredUnit] = useState('psi');
|
|
313
|
+
const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
|
|
314
|
+
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
|
|
315
|
+
const [value, setValue] = useState('672.2388357750001|bar');
|
|
316
|
+
const [callBackError, setCallBackError] = useState('');
|
|
317
|
+
return <Grid columns="1fr 1fr" gap>
|
|
318
|
+
<Card heading={<Heading>Settings</Heading>}>
|
|
319
|
+
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
320
|
+
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
321
|
+
</Field>
|
|
322
|
+
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
323
|
+
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
324
|
+
</Field>
|
|
325
|
+
</Card>
|
|
326
|
+
<Card heading={<Heading>NumberInput (displayed in Meters)</Heading>}>
|
|
327
|
+
<Text faint>
|
|
328
|
+
Cosmetic Rounding Test Case: type 9750 then return (compare with
|
|
329
|
+
enableCosmeticRounding on and off)
|
|
330
|
+
</Text>
|
|
331
|
+
<Spacer />
|
|
332
|
+
<Text warning>
|
|
333
|
+
Note: UnitInput uses convertSamePrecision internally (decision prior
|
|
334
|
+
to cosmetic value implementation). This means not all rounding noise
|
|
335
|
+
occurrences seen in NumberInput will be reproducible in UnitInput,
|
|
336
|
+
because they get rounded off by other logic.
|
|
337
|
+
</Text>
|
|
338
|
+
<Spacer />
|
|
339
|
+
<UnitInput name="Example" unitkey="pressure" initUnit={preferredUnit} unitTemplate={{
|
|
340
|
+
pressure: 'psi'
|
|
341
|
+
}} value={value} onChange={evt => {
|
|
342
|
+
const {
|
|
343
|
+
value
|
|
344
|
+
} = evt.target;
|
|
345
|
+
if (value) {
|
|
346
|
+
setValue(value);
|
|
347
|
+
}
|
|
348
|
+
}} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={convertAndGetValue(value, 'bar') >= 0 ? '' : 'Value must be positive'} validationCallback={(name, error) => {
|
|
349
|
+
setCallBackError(error ?? '');
|
|
350
|
+
}} convertBackToStorageUnit />
|
|
351
|
+
</Card>
|
|
352
|
+
<Card heading={<Heading>Unit Template</Heading>}>
|
|
353
|
+
<Select options={[{
|
|
354
|
+
label: 'Bar',
|
|
355
|
+
value: 'bar'
|
|
356
|
+
}, {
|
|
357
|
+
label: 'psi',
|
|
358
|
+
value: 'psi'
|
|
359
|
+
}]} value={preferredUnit} width={70} onChange={evt => setPreferredUnit(evt.target.value)} />
|
|
360
|
+
</Card>
|
|
361
|
+
<Card heading={<Heading>Test Validation Callback</Heading>}>
|
|
362
|
+
{callBackError && <Message message={{
|
|
363
|
+
content: callBackError,
|
|
364
|
+
icon: true,
|
|
365
|
+
type: 'Error',
|
|
366
|
+
visible: true
|
|
367
|
+
}} />}
|
|
368
|
+
</Card>
|
|
369
|
+
<Card heading={<Heading>Storage State / Redux (stored in Feet)</Heading>}>
|
|
370
|
+
{value}
|
|
371
|
+
<Spacer />
|
|
372
|
+
<Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'bar'))} />
|
|
373
|
+
</Card>
|
|
374
|
+
</Grid>;
|
|
375
|
+
}`,...(an=(nn=de.parameters)==null?void 0:nn.docs)==null?void 0:an.source}}};var rn,sn,ln;O.parameters={...O.parameters,docs:{...(rn=O.parameters)==null?void 0:rn.docs,source:{originalSource:`() => {
|
|
376
|
+
const [value, setValue] = useState('123|m');
|
|
377
|
+
return <UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit="m" unitkey="depth" unitTemplate={{
|
|
378
|
+
depth: 'm'
|
|
379
|
+
}} testId="testId" />;
|
|
380
|
+
}`,...(ln=(sn=O.parameters)==null?void 0:sn.docs)==null?void 0:ln.source}}};const Ha=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Placeholder","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","OW_10614TestCase","DemoCosmeticRounding","TestUserInput"];export{le as AllowEmptyPUI,re as AutomaticValues,he as Default,de as DemoCosmeticRounding,_ as Disabled,ee as DisabledNoConversion,ne as DisabledUnitWithUnitKey,te as DisabledUnitWithoutUnitKey,ae as DisabledWithEnabledUnitMenu,Q as Error,$ as InitUnit,X as InternalValidationError,Y as NoConversion,ue as OW_10614TestCase,P as Placeholder,ie as PredefinedOptionsMenu,Z as Small,M as TestEdgeCases,R as TestExternalStateChangeWithSynchronizedUnits,O as TestUserInput,se as ValidationCallback,J as Width,Ha as __namedExportsOrder,La as default,z as notKnownUnit,oe as onSwitchUnit};
|