@oliasoft-open-source/react-ui-library 4.8.0-beta-1 → 4.8.0-beta-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-DYGOUZH8.js → index-Csdt18_R.js} +2 -9
- package/dist/index.html +1 -1
- package/dist/index.js +2 -12
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-TfNjzFol.js → Color-KGDBMAHA-BS-rAnbo.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-CvKaIyAS.js → DocsRenderer-PKQXORMH-DZ7r3cmw.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-CbUgpQAC.js → accordion.stories-CKrpJWRn.js} +1 -1
- package/dist/storybook/assets/{actions-4w-EOz3m.js → actions-CHgr8eL8.js} +1 -1
- package/dist/storybook/assets/{actions.stories-CtocfSW4.js → actions.stories-CCDxFKFk.js} +1 -1
- package/dist/storybook/assets/{afe.stories-3nCmEH0q.js → afe.stories-80-X2oCf.js} +1 -1
- package/dist/storybook/assets/{badge.stories-CKnNQLZ5.js → badge.stories-D5DA-vxC.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-AxiXaQQ-.js → blowout.stories-ES-Fuaqn.js} +1 -1
- package/dist/storybook/assets/{button-CdEIDAx8.js → button-VxhoNhrV.js} +1 -1
- package/dist/storybook/assets/{button-group-BIUVa0X9.js → button-group-CwJdFo2z.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-B0Gb9kNs.js → button-group.stories-DU5k5qCY.js} +1 -1
- package/dist/storybook/assets/{button.stories-CHt71NKu.js → button.stories-DVtec2Eo.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-DQXhygpA.js → buttons-and-links-sTGnmj6h.js} +1 -1
- package/dist/storybook/assets/{card.stories-Cddrprok.js → card.stories-CsTB0DuM.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-CSdj5faI.js → casing-loads.stories-Do3mZuX2.js} +1 -1
- package/dist/storybook/assets/{cell.stories-DBLJ17se.js → cell.stories-B0YsumDa.js} +1 -1
- package/dist/storybook/assets/{check-box-2fHPdAZG.js → check-box-BtCGePRy.js} +1 -1
- package/dist/storybook/assets/check-box.stories-B6vW-2Fd.js +126 -0
- package/dist/storybook/assets/{chunk-HLWAVYOI-C9RjJIQI.js → chunk-HLWAVYOI-BqK-R5cR.js} +1 -1
- package/dist/storybook/assets/{color-DiLYh1iE.js → color-Cvx86PKp.js} +1 -1
- package/dist/storybook/assets/{column.stories-rKyxUTAG.js → column.stories-BxfR9Tla.js} +1 -1
- package/dist/storybook/assets/dialog-Di8hNunM.js +1 -0
- package/dist/storybook/assets/{drawer-BOl7GxGI.js → drawer-BhuWxI7V.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-qH2nYW2a.js → drawer.stories-B-PsNJJ6.js} +1 -1
- package/dist/storybook/assets/{empty.stories-BKEXzh9o.js → empty.stories-BVYXwvpa.js} +1 -1
- package/dist/storybook/assets/{field-nInV3MuR.js → field-HrLaMLbx.js} +1 -1
- package/dist/storybook/assets/{field.stories-eRSYmEtA.js → field.stories-B9p9nBgY.js} +1 -1
- package/dist/storybook/assets/{file-button.stories-CH6kxEKM.js → file-button.stories-FOaiNPt-.js} +1 -1
- package/dist/storybook/assets/{file-input-Amcc9o5I.js → file-input-BpMtsZ2S.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-aiTQE5UN.js → file-input.stories-Jrdw5k-s.js} +1 -1
- package/dist/storybook/assets/{flex.stories-CT6o2gii.js → flex.stories-BEXf0VqI.js} +1 -1
- package/dist/storybook/assets/{footer.stories-CpsfxWaj.js → footer.stories-CMN_mVki.js} +1 -1
- package/dist/storybook/assets/{form.stories-CqFk9g40.js → form.stories-C1Qx3M_1.js} +1 -1
- package/dist/storybook/assets/{formation.stories-DN4l7-9g.js → formation.stories-CCJYaUpG.js} +1 -1
- package/dist/storybook/assets/{heading-EzI5s4VN.js → heading-CRNoBc7q.js} +1 -1
- package/dist/storybook/assets/{heading.stories-D5x1-mKs.js → heading.stories-DahFxeiX.js} +1 -1
- package/dist/storybook/assets/{help-icon-CfV3_Ais.js → help-icon-Buhx5nl6.js} +1 -1
- package/dist/storybook/assets/{help-icon.stories-D4KS1wlT.js → help-icon.stories-DbmZ1fgP.js} +1 -1
- package/dist/storybook/assets/iframe-CUVhB5TR.js +2 -0
- package/dist/storybook/assets/{index-BesoTaoD.js → index-B8zF6D3V.js} +4 -4
- package/dist/storybook/assets/index-Be0hXiyp.js +179 -0
- package/dist/storybook/assets/index-CF7H4eMJ.js +28 -0
- package/dist/storybook/assets/{index-DGl0obec.js → index-DQs5XS8h.js} +1 -1
- package/dist/storybook/assets/{index-B9Xm8jXL.js → index-omjWi7I7.js} +1 -1
- package/dist/storybook/assets/{input-D97ganXq.js → input-BW9trNAW.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-DctjyXor.js → input-group.stories-44quIZTV.js} +1 -1
- package/dist/storybook/assets/{input-validation-BVAuiwBg.js → input-validation-BREYBXzB.js} +2 -2
- package/dist/storybook/assets/{input.stories-BHdUwYqV.js → input.stories-BruLeJ44.js} +1 -1
- package/dist/storybook/assets/{inputs-zvgQy7Ef.js → inputs-DkxT6vDD.js} +2 -2
- package/dist/storybook/assets/{label-Cz6TT90s.js → label-CqmyC9he.js} +1 -1
- package/dist/storybook/assets/{label.stories-BzSzxxM-.js → label.stories-C0AO5F1a.js} +1 -1
- package/dist/storybook/assets/{layout-forms-CiP17Xxu.js → layout-forms-Y0Chz5wF.js} +1 -1
- package/dist/storybook/assets/{layout-general-ChpChtZ5.js → layout-general-CRJUCd3s.js} +1 -1
- package/dist/storybook/assets/{list-BtA0jYMp.js → list-yVTOdmpX.js} +1 -1
- package/dist/storybook/assets/{list.stories-CmJsmJZJ.js → list.stories-ChqQXY5M.js} +1 -1
- package/dist/storybook/assets/{list.stories-data-C_w1DX5i.js → list.stories-data-Iq66w9oH.js} +1 -1
- package/dist/storybook/assets/{loader.stories-CA2m3EFj.js → loader.stories-DM7ZJBgz.js} +1 -1
- package/dist/storybook/assets/menu.stories-Dozt6Npk.js +84 -0
- package/dist/storybook/assets/message-BYzRg8Ae.js +1 -0
- package/dist/storybook/assets/{message.stories-CXOrrAOR.js → message.stories-K3bQ-5bJ.js} +1 -1
- package/dist/storybook/assets/{meta-content-BdypOdcN.js → meta-content-cbHGvPJ7.js} +1 -1
- package/dist/storybook/assets/modal.stories-BX49dKIM.js +220 -0
- package/dist/storybook/assets/number-input-CD-fbjVQ.js +4 -0
- package/dist/storybook/assets/number-input.stories-h1PlFB_G.js +105 -0
- package/dist/storybook/assets/{option-dropdown.stories-DvgAgTHQ.js → option-dropdown.stories-CoLsSS95.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-Ds9-kSBv.js → padding-and-spacing-DYx_u7EA.js} +1 -1
- package/dist/storybook/assets/{page.stories-DdAfcsOc.js → page.stories-Cse3cMsO.js} +1 -1
- package/dist/storybook/assets/{pagination-BA9mb3NP.js → pagination-iSMIbR33.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-2HPZnimC.js → pagination.stories-BUPaZD5R.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-D4L3erpj.js → pop-confirm.stories-Dhid1FK8.js} +1 -1
- package/dist/storybook/assets/popover-CzZdWNnB.js +1 -0
- package/dist/storybook/assets/{popover.stories-SMz7Cd0A.js → popover.stories-Duemqiqp.js} +1 -1
- package/dist/storybook/assets/{preview-craejBWr.js → preview-B2Xzz4-3.js} +1 -1
- package/dist/storybook/assets/preview-DLBQXbKW.js +1 -0
- package/dist/storybook/assets/{preview-AeyuE7NC.js → preview-kt6m1zZo.js} +2 -2
- package/dist/storybook/assets/{projects.stories-ApHyZURX.js → projects.stories-DU-QlBa6.js} +1 -1
- package/dist/storybook/assets/{radio-button-J4oEQdxt.js → radio-button-YBwYcMaM.js} +1 -1
- package/dist/storybook/assets/radio-button.stories-8QEKlNvO.js +71 -0
- package/dist/storybook/assets/{reservoirs.stories-D_HCj-TY.js → reservoirs.stories-aSZ9r1Pu.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-rQEM-l57.js → rich-text-input.stories-CsFyrKRA.js} +1 -1
- package/dist/storybook/assets/{row.stories-BHz3vX8n.js → row.stories-ZCrMoTuY.js} +1 -1
- package/dist/storybook/assets/select-C8iu4-uz.js +40 -0
- package/dist/storybook/assets/select.stories-DbgjgsiX.js +579 -0
- package/dist/storybook/assets/{side-bar-DAMfASqb.js → side-bar-CKbHPgIV.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-BlEIOckL.js → side-bar.stories-MUj_dj1F.js} +1 -1
- package/dist/storybook/assets/{site.stories-Kk57nhAn.js → site.stories-Ci4g5W2A.js} +1 -1
- package/dist/storybook/assets/{slider-BLU39INk.js → slider-DAramr8j.js} +1 -1
- package/dist/storybook/assets/{slider.stories-DdVxUAfH.js → slider.stories-Cd0rLfHP.js} +1 -1
- package/dist/storybook/assets/{smart-upload-modal.stories-01X4DGpB.js → smart-upload-modal.stories-DgnJ79fa.js} +1 -1
- package/dist/storybook/assets/{spacer.stories-Dd1QMhoc.js → spacer.stories-CHEZdgDM.js} +1 -1
- package/dist/storybook/assets/{table-CWxrvmPS.js → table-ZQD4ELIM.js} +1 -1
- package/dist/storybook/assets/{table.stories-DXq-XP56.js → table.stories-DGedoAir.js} +1 -1
- package/dist/storybook/assets/{table.stories-data-C6x-UHeN.js → table.stories-data-CR9VpXHs.js} +1 -1
- package/dist/storybook/assets/{textarea-DOJDK8hI.js → textarea-BV7xWEdt.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-CKm5MlQF.js → textarea.stories-aRLEoDHg.js} +1 -1
- package/dist/storybook/assets/{title.stories-D2obDA1k.js → title.stories-jQBBSflc.js} +1 -1
- package/dist/storybook/assets/toaster-BNO0suPv.js +1 -0
- package/dist/storybook/assets/toaster.stories-CAqrDYpd.js +89 -0
- package/dist/storybook/assets/{toggle-D0yzyALV.js → toggle-CBpNgTrm.js} +1 -1
- package/dist/storybook/assets/toggle.stories-t0T4HV1D.js +141 -0
- package/dist/storybook/assets/{tooltip-C_E_6ym5.js → tooltip-1V7clEnw.js} +1 -1
- package/dist/storybook/assets/{tooltip.stories-C70ADjjJ.js → tooltip.stories-1YexWg6N.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-BWJhZQg8.js → tooltip.test-case.stories-i9YQqba1.js} +1 -1
- package/dist/storybook/assets/{top-bar-mKg-xcLh.js → top-bar-C_tn2Pc5.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-CFZoJq-r.js → top-bar.stories-B2a-RgK-.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-BlbsX9By.js → top-bar.testcase.stories-DoPEAMYc.js} +1 -1
- package/dist/storybook/assets/{tree.stories-CkYwGe0X.js → tree.stories-6UHASEZu.js} +1 -1
- package/dist/storybook/assets/unit-input-CoFS2qhN.css +1 -0
- package/dist/storybook/assets/unit-input.stories-C7XlUSaC.js +290 -0
- package/dist/storybook/assets/unit-table.stories-BJbxGp7Y.js +150 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.html +6 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/sb-addons/interactions-2/manager-bundle.js +233 -0
- package/dist/storybook/sb-addons/storybook-dark-mode-esm-preset-3/manager-bundle.js.LEGAL.txt +0 -0
- package/package.json +4 -1
- package/dist/storybook/assets/check-box.stories-Do-GOmLf.js +0 -102
- package/dist/storybook/assets/dialog-B-R6eAnf.js +0 -1
- package/dist/storybook/assets/iframe-CeeVOkcX.js +0 -2
- package/dist/storybook/assets/menu.stories-Bc2kf356.js +0 -82
- package/dist/storybook/assets/message-ZenLdkrf.js +0 -1
- package/dist/storybook/assets/modal.stories-B31R5KLu.js +0 -200
- package/dist/storybook/assets/number-input-RV1zn3_t.js +0 -4
- package/dist/storybook/assets/number-input.stories-CBser6Ry.js +0 -153
- package/dist/storybook/assets/popover-CvS_kBVF.js +0 -1
- package/dist/storybook/assets/radio-button.stories-BFp_qyyE.js +0 -61
- package/dist/storybook/assets/select-BPp24Pdw.js +0 -40
- package/dist/storybook/assets/select.stories-hyJTR9B_.js +0 -914
- package/dist/storybook/assets/toaster-B8A3xIYu.js +0 -1
- package/dist/storybook/assets/toaster.stories-DuE6vvV6.js +0 -86
- package/dist/storybook/assets/toggle.stories-Cre2gnIB.js +0 -117
- package/dist/storybook/assets/unit-input-5P4Cogho.css +0 -1
- package/dist/storybook/assets/unit-input.stories-CEzR1Pvn.js +0 -354
- package/dist/storybook/assets/unit-table.stories-CWGzy_cE.js +0 -150
- /package/dist/storybook/sb-addons/{storybook-dark-mode-esm-preset-2 → interactions-2}/manager-bundle.js.LEGAL.txt +0 -0
- /package/dist/storybook/sb-addons/{storybook-dark-mode-esm-preset-2 → storybook-dark-mode-esm-preset-3}/manager-bundle.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as c}from"./jsx-runtime-eps93zm2.js";import{t,S as f}from"./toaster-7wnI6hqB.js";import{a as r,M as d,D as E}from"./message-ZenLdkrf.js";const m=({id:s,message:e={type:r.INFO,content:""},autoClose:o=6e3,onClose:a})=>{const{type:p=r.INFO}=e??{},u=({closeToast:l})=>c.jsx(E,{type:p,onClose:l,isInToast:!0}),i=c.jsx(d,{message:{...e,visible:!0,width:"100%",maxHeight:"500px",withDismiss:!1}}),n=(()=>{switch(e==null?void 0:e.type){case r.SUCCESS:return t.TYPE.SUCCESS;case r.WARNING:return t.TYPE.WARNING;case r.ERROR:return t.TYPE.ERROR;default:return t.TYPE.INFO}})();return s!==void 0&&t.isActive(s)?t.update(s,{render:i,autoClose:o,onClose:a,type:n}):t(i,{toastId:s,autoClose:o,onClose:a,hideProgressBar:o===!1,icon:!1,closeOnClick:!1,pauseOnHover:!0,draggable:!1,closeButton:u,transition:f,type:n})},x=s=>{t.dismiss(s)};export{x as d,m as t};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./jsx-runtime-eps93zm2.js";import{G as w}from"./grid-B6LFPf51.js";import{T as d}from"./text-B3-TSWok.js";import{F as v}from"./flex-EllkLxgO.js";import{t,d as u}from"./toaster-B8A3xIYu.js";import{B as o}from"./button-CdEIDAx8.js";import{S as l}from"./spacer-BWoNR27H.js";import{a as m}from"./message-ZenLdkrf.js";import"./index-DhsZuJvc.js";import"./styled-components.browser.esm-Bf0q9Yjk.js";import"./index-Bk2sglWO.js";import"./toaster-7wnI6hqB.js";import"./index-CUZDtIZe.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-C_E_6ym5.js";const O={type:m.SUCCESS,icon:!0,heading:"Heading",content:"Great results"},A={type:m.ERROR,icon:!0,heading:"Heading",content:"An error has happened",details:"Bad input data lorem ipsum dolor est compendum lorem ipsum."},F={type:m.WARNING,icon:!0,heading:"Heading",content:"Warning message"},B={type:m.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},ts={title:"Modals/Toaster",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:B,autoClose:6e3,onClose:()=>{}}},G=()=>s.jsxs(s.Fragment,{children:[s.jsx(o,{label:"Info",onClick:()=>t({message:B,onClose:()=>console.log("toast closed")})}),s.jsx(l,{}),s.jsx(o,{label:"Error",onClick:()=>t({message:A,onClose:()=>console.log("toast closed")})}),s.jsx(l,{}),s.jsx(o,{label:"Warning",onClick:()=>t({message:F,onClose:()=>console.log("toast closed")})}),s.jsx(l,{}),s.jsx(o,{label:"Success",onClick:()=>t({message:O,onClose:()=>console.log("toast closed")})})]}),c=G.bind({}),n=()=>s.jsx(o,{label:"Show Toast",onClick:()=>{const e=Math.random()>=.5;t({message:{type:e?"Success":"Error",icon:!0,content:e?"Success":"Error"},onClose:()=>console.log("toast closed"),id:"uniqueId"})}});n.parameters={docs:{iframeHeight:200,description:{story:"Pass a unique `id` in the `toast` object to prevent duplicates. Successive toasts with the same ID will update the existing toast."}}};const a=()=>{const e="sessionExpiring",p={type:"Info",content:s.jsxs(w,{children:[s.jsx(d,{bold:!0,children:"You will be signed out soon"}),s.jsx(d,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx(l,{height:"var(--padding-xxs)"}),s.jsxs(v,{gap:"var(--padding-xs)",children:[s.jsx(o,{label:"Extend session",small:!0,colored:"success",onClick:()=>u(e)}),s.jsx(o,{label:"Dismiss",small:!0,onClick:()=>u(e)})]})]})};return s.jsx(o,{label:"Show Toast",onClick:()=>t({message:p,autoClose:!1,id:e})})},r=()=>{const e="sessionExpiringSoon",p={type:"Error",content:s.jsxs(w,{children:[s.jsx(d,{bold:!0,children:"You will be signed out very soon"}),s.jsx(d,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx(l,{height:"var(--padding-xxs)"}),s.jsxs(v,{gap:"var(--padding-xs)",children:[s.jsx(o,{label:"Extend session",small:!0,colored:"success",onClick:()=>u(e)}),s.jsx(o,{label:"Dismiss",small:!0,onClick:()=>u(e)})]})]})};return s.jsx(o,{label:"Show Toast",onClick:()=>t({message:p,autoClose:!1,id:e})})},i=()=>{const e={type:"Success",content:"Your session has been extended for 1 hour"};return s.jsx(o,{label:"Show Toast",onClick:()=>t({message:e})})};n.__docgenInfo={description:"",methods:[],displayName:"PreventDuplicates"};a.__docgenInfo={description:"",methods:[],displayName:"SessionExpiring"};r.__docgenInfo={description:"",methods:[],displayName:"SessionExpiringSoon"};i.__docgenInfo={description:"",methods:[],displayName:"SessionExtended"};var g,x,S;c.parameters={...c.parameters,docs:{...(g=c.parameters)==null?void 0:g.docs,source:{originalSource:`() => {
|
|
2
|
-
return <>
|
|
3
|
-
<Button label="Info" onClick={() => toast({
|
|
4
|
-
message: messageInfo,
|
|
5
|
-
onClose: () => console.log('toast closed')
|
|
6
|
-
})} />
|
|
7
|
-
<Spacer />
|
|
8
|
-
<Button label="Error" onClick={() => toast({
|
|
9
|
-
message: messageError,
|
|
10
|
-
onClose: () => console.log('toast closed')
|
|
11
|
-
})} />
|
|
12
|
-
<Spacer />
|
|
13
|
-
<Button label="Warning" onClick={() => toast({
|
|
14
|
-
message: messageWarning,
|
|
15
|
-
onClose: () => console.log('toast closed')
|
|
16
|
-
})} />
|
|
17
|
-
<Spacer />
|
|
18
|
-
<Button label="Success" onClick={() => toast({
|
|
19
|
-
message: messageSuccess,
|
|
20
|
-
onClose: () => console.log('toast closed')
|
|
21
|
-
})} />
|
|
22
|
-
</>;
|
|
23
|
-
}`,...(S=(x=c.parameters)==null?void 0:x.docs)==null?void 0:S.source}}};var y,T,h;n.parameters={...n.parameters,docs:{...(y=n.parameters)==null?void 0:y.docs,source:{originalSource:`() => <Button label="Show Toast" onClick={() => {
|
|
24
|
-
const isSuccess = Math.random() >= 0.5;
|
|
25
|
-
toast({
|
|
26
|
-
message: ({
|
|
27
|
-
type: isSuccess ? 'Success' : 'Error',
|
|
28
|
-
icon: true,
|
|
29
|
-
content: isSuccess ? 'Success' : 'Error'
|
|
30
|
-
} as IMessageType),
|
|
31
|
-
onClose: () => console.log('toast closed'),
|
|
32
|
-
id: 'uniqueId'
|
|
33
|
-
});
|
|
34
|
-
}} />`,...(h=(T=n.parameters)==null?void 0:T.docs)==null?void 0:h.source}}};var C,b,E;a.parameters={...a.parameters,docs:{...(C=a.parameters)==null?void 0:C.docs,source:{originalSource:`() => {
|
|
35
|
-
const TOAST_ID = 'sessionExpiring';
|
|
36
|
-
const message = ({
|
|
37
|
-
type: 'Info',
|
|
38
|
-
content: <Grid>
|
|
39
|
-
<Text bold>You will be signed out soon</Text>
|
|
40
|
-
<Text>
|
|
41
|
-
For your security, you will be automatically signed out in 30 minutes
|
|
42
|
-
unless you extend your session.
|
|
43
|
-
</Text>
|
|
44
|
-
<Spacer height="var(--padding-xxs)" />
|
|
45
|
-
<Flex gap="var(--padding-xs)">
|
|
46
|
-
<Button label="Extend session" small colored="success" onClick={() => dismissToast(TOAST_ID)} />
|
|
47
|
-
<Button label="Dismiss" small onClick={() => dismissToast(TOAST_ID)} />
|
|
48
|
-
</Flex>
|
|
49
|
-
</Grid>
|
|
50
|
-
} as IMessageType);
|
|
51
|
-
return <Button label="Show Toast" onClick={() => toast({
|
|
52
|
-
message,
|
|
53
|
-
autoClose: false,
|
|
54
|
-
id: TOAST_ID
|
|
55
|
-
})} />;
|
|
56
|
-
}`,...(E=(b=a.parameters)==null?void 0:b.docs)==null?void 0:E.source}}};var f,j,I;r.parameters={...r.parameters,docs:{...(f=r.parameters)==null?void 0:f.docs,source:{originalSource:`() => {
|
|
57
|
-
const TOAST_ID = 'sessionExpiringSoon';
|
|
58
|
-
const message = ({
|
|
59
|
-
type: 'Error',
|
|
60
|
-
content: <Grid>
|
|
61
|
-
<Text bold>You will be signed out very soon</Text>
|
|
62
|
-
<Text>
|
|
63
|
-
For your security, you will be automatically signed out in 30 minutes
|
|
64
|
-
unless you extend your session.
|
|
65
|
-
</Text>
|
|
66
|
-
<Spacer height="var(--padding-xxs)" />
|
|
67
|
-
<Flex gap="var(--padding-xs)">
|
|
68
|
-
<Button label="Extend session" small colored="success" onClick={() => dismissToast(TOAST_ID)} />
|
|
69
|
-
<Button label="Dismiss" small onClick={() => dismissToast(TOAST_ID)} />
|
|
70
|
-
</Flex>
|
|
71
|
-
</Grid>
|
|
72
|
-
} as IMessageType);
|
|
73
|
-
return <Button label="Show Toast" onClick={() => toast({
|
|
74
|
-
message,
|
|
75
|
-
autoClose: false,
|
|
76
|
-
id: TOAST_ID
|
|
77
|
-
})} />;
|
|
78
|
-
}`,...(I=(j=r.parameters)==null?void 0:j.docs)==null?void 0:I.source}}};var k,_,D;i.parameters={...i.parameters,docs:{...(k=i.parameters)==null?void 0:k.docs,source:{originalSource:`() => {
|
|
79
|
-
const message = ({
|
|
80
|
-
type: 'Success',
|
|
81
|
-
content: 'Your session has been extended for 1 hour'
|
|
82
|
-
} as IMessageType);
|
|
83
|
-
return <Button label="Show Toast" onClick={() => toast({
|
|
84
|
-
message
|
|
85
|
-
})} />;
|
|
86
|
-
}`,...(D=(_=i.parameters)==null?void 0:_.docs)==null?void 0:D.source}}};const ns=["Default","PreventDuplicates","SessionExpiring","SessionExpiringSoon","SessionExtended"];export{c as Default,n as PreventDuplicates,a as SessionExpiring,r as SessionExpiringSoon,i as SessionExtended,ns as __namedExportsOrder,ts as default};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as X}from"./index-DhsZuJvc.js";import{F as C}from"./flex-EllkLxgO.js";import{T as i}from"./text-B3-TSWok.js";import{T as p}from"./toggle-D0yzyALV.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./help-icon-CfV3_Ais.js";import"./tooltip-C_E_6ym5.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";const{useArgs:Z}=__STORYBOOK_MODULE_PREVIEW_API__,ue={title:"Forms/Toggle",component:p,args:{label:"Label"}},n=u=>{const[{checked:m},x]=Z(),b=()=>{x({checked:!m})};return e.jsx(p,{...u,onChange:b})},h=n.bind({}),s=n.bind({});s.args={disabled:!0};const a=n.bind({});a.args={checked:!0,disabled:!0};const r=n.bind({});r.args={small:!0};const t=n.bind({});t.args={label:null};const c=n.bind({});c.args={helpText:"Help text"};const o=n.bind({});o.args={onClickHelp:()=>console.log("Help clicked")};const d=()=>e.jsxs(e.Fragment,{children:[e.jsx(p,{display:"block",label:e.jsxs(C,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(i,{bold:!0,children:"Label"}),e.jsx(i,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}}),e.jsx(p,{label:e.jsxs(C,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(i,{bold:!0,children:"Label"}),e.jsx(i,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}})]}),l=()=>{const[u,m]=X.useState(!1);return e.jsx(p,{name:"name",label:"Label",checked:u,onChange:x=>{const{name:b,value:Q,checked:k}=x.target;m(k),console.log(b,Q,k)}})},g=n.bind({});g.args={helpText:"Help text",disabled:!0};d.__docgenInfo={description:"",methods:[],displayName:"Display"};l.__docgenInfo={description:"",methods:[],displayName:"TestClickevt"};var T,A,j;h.parameters={...h.parameters,docs:{...(T=h.parameters)==null?void 0:T.docs,source:{originalSource:`args => {
|
|
2
|
-
const [{
|
|
3
|
-
checked
|
|
4
|
-
}, updateArgs] = useArgs();
|
|
5
|
-
const handleChange = () => {
|
|
6
|
-
updateArgs({
|
|
7
|
-
checked: !checked
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
return <Toggle
|
|
11
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
12
|
-
{...args} onChange={handleChange} />;
|
|
13
|
-
}`,...(j=(A=h.parameters)==null?void 0:A.docs)==null?void 0:j.source}}};var f,y,S;s.parameters={...s.parameters,docs:{...(f=s.parameters)==null?void 0:f.docs,source:{originalSource:`args => {
|
|
14
|
-
const [{
|
|
15
|
-
checked
|
|
16
|
-
}, updateArgs] = useArgs();
|
|
17
|
-
const handleChange = () => {
|
|
18
|
-
updateArgs({
|
|
19
|
-
checked: !checked
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
return <Toggle
|
|
23
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
24
|
-
{...args} onChange={handleChange} />;
|
|
25
|
-
}`,...(S=(y=s.parameters)==null?void 0:y.docs)==null?void 0:S.source}}};var _,D,H;a.parameters={...a.parameters,docs:{...(_=a.parameters)==null?void 0:_.docs,source:{originalSource:`args => {
|
|
26
|
-
const [{
|
|
27
|
-
checked
|
|
28
|
-
}, updateArgs] = useArgs();
|
|
29
|
-
const handleChange = () => {
|
|
30
|
-
updateArgs({
|
|
31
|
-
checked: !checked
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
return <Toggle
|
|
35
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
|
-
{...args} onChange={handleChange} />;
|
|
37
|
-
}`,...(H=(D=a.parameters)==null?void 0:D.docs)==null?void 0:H.source}}};var v,w,F;r.parameters={...r.parameters,docs:{...(v=r.parameters)==null?void 0:v.docs,source:{originalSource:`args => {
|
|
38
|
-
const [{
|
|
39
|
-
checked
|
|
40
|
-
}, updateArgs] = useArgs();
|
|
41
|
-
const handleChange = () => {
|
|
42
|
-
updateArgs({
|
|
43
|
-
checked: !checked
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
return <Toggle
|
|
47
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
48
|
-
{...args} onChange={handleChange} />;
|
|
49
|
-
}`,...(F=(w=r.parameters)==null?void 0:w.docs)==null?void 0:F.source}}};var L,O,R;t.parameters={...t.parameters,docs:{...(L=t.parameters)==null?void 0:L.docs,source:{originalSource:`args => {
|
|
50
|
-
const [{
|
|
51
|
-
checked
|
|
52
|
-
}, updateArgs] = useArgs();
|
|
53
|
-
const handleChange = () => {
|
|
54
|
-
updateArgs({
|
|
55
|
-
checked: !checked
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
return <Toggle
|
|
59
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
60
|
-
{...args} onChange={handleChange} />;
|
|
61
|
-
}`,...(R=(O=t.parameters)==null?void 0:O.docs)==null?void 0:R.source}}};var E,I,W;c.parameters={...c.parameters,docs:{...(E=c.parameters)==null?void 0:E.docs,source:{originalSource:`args => {
|
|
62
|
-
const [{
|
|
63
|
-
checked
|
|
64
|
-
}, updateArgs] = useArgs();
|
|
65
|
-
const handleChange = () => {
|
|
66
|
-
updateArgs({
|
|
67
|
-
checked: !checked
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
return <Toggle
|
|
71
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
72
|
-
{...args} onChange={handleChange} />;
|
|
73
|
-
}`,...(W=(I=c.parameters)==null?void 0:I.docs)==null?void 0:W.source}}};var N,P,B;o.parameters={...o.parameters,docs:{...(N=o.parameters)==null?void 0:N.docs,source:{originalSource:`args => {
|
|
74
|
-
const [{
|
|
75
|
-
checked
|
|
76
|
-
}, updateArgs] = useArgs();
|
|
77
|
-
const handleChange = () => {
|
|
78
|
-
updateArgs({
|
|
79
|
-
checked: !checked
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
return <Toggle
|
|
83
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
84
|
-
{...args} onChange={handleChange} />;
|
|
85
|
-
}`,...(B=(P=o.parameters)==null?void 0:P.docs)==null?void 0:B.source}}};var K,M,U;d.parameters={...d.parameters,docs:{...(K=d.parameters)==null?void 0:K.docs,source:{originalSource:`() => <>
|
|
86
|
-
<Toggle display="block" label={<Flex justifyContent="space-between" wrap={false} gap>
|
|
87
|
-
<Text bold>Label</Text>
|
|
88
|
-
<Text success>Released yesterday</Text>
|
|
89
|
-
</Flex>} onChange={() => {}} />
|
|
90
|
-
<Toggle label={<Flex justifyContent="space-between" wrap={false} gap>
|
|
91
|
-
<Text bold>Label</Text>
|
|
92
|
-
<Text success>Released yesterday</Text>
|
|
93
|
-
</Flex>} onChange={() => {}} />
|
|
94
|
-
</>`,...(U=(M=d.parameters)==null?void 0:M.docs)==null?void 0:U.source}}};var V,Y,q;l.parameters={...l.parameters,docs:{...(V=l.parameters)==null?void 0:V.docs,source:{originalSource:`() => {
|
|
95
|
-
const [checked, setChecked] = useState(false);
|
|
96
|
-
return <Toggle name="name" label="Label" checked={checked} onChange={evt => {
|
|
97
|
-
const {
|
|
98
|
-
name,
|
|
99
|
-
value,
|
|
100
|
-
checked
|
|
101
|
-
} = evt.target;
|
|
102
|
-
setChecked(checked);
|
|
103
|
-
console.log(name, value, checked);
|
|
104
|
-
}} />;
|
|
105
|
-
}`,...(q=(Y=l.parameters)==null?void 0:Y.docs)==null?void 0:q.source}}};var z,G,J;g.parameters={...g.parameters,docs:{...(z=g.parameters)==null?void 0:z.docs,source:{originalSource:`args => {
|
|
106
|
-
const [{
|
|
107
|
-
checked
|
|
108
|
-
}, updateArgs] = useArgs();
|
|
109
|
-
const handleChange = () => {
|
|
110
|
-
updateArgs({
|
|
111
|
-
checked: !checked
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
return <Toggle
|
|
115
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
116
|
-
{...args} onChange={handleChange} />;
|
|
117
|
-
}`,...(J=(G=g.parameters)==null?void 0:G.docs)==null?void 0:J.source}}};const me=["Default","Disabled","DisabledChecked","Small","Standalone","HelpText","OnClickHelp","Display","TestClickevt","DisabledWithHelpText"];export{h as Default,s as Disabled,a as DisabledChecked,g as DisabledWithHelpText,d as Display,c as HelpText,o as OnClickHelp,r as Small,t as Standalone,l as TestClickevt,me as __namedExportsOrder,ue as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._predefinedMenuActive_ye9w9_1 input{background:var(--color-background-disabled)!important}._inputWrapper_ye9w9_4{flex:1}
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as i}from"./index-DGl0obec.js";import{c as Ct}from"./index-Bk2sglWO.js";import{u as yt}from"./use-previous-D775JrO6.js";import{M as Ae}from"./actions-4w-EOz3m.js";import{I as Ut}from"./input-group-addon-D68iUKV2.js";import{B as c}from"./button-CdEIDAx8.js";import{T as xt}from"./tooltip-C_E_6ym5.js";import{I as It}from"./input-group-BaRSJAEN.js";import{S as C}from"./spacer-BWoNR27H.js";import{T as ce}from"./text-B3-TSWok.js";import{M as Pe}from"./types-BmbYqTX_.js";import{l as ue}from"./lodash-BHd_uQHh.js";import{N as Vt,r as jt}from"./number-input-RV1zn3_t.js";import{D as kt}from"./divider-DY9nJ_7N.js";import{R as Zn,C as be}from"./row-4iAGREkV.js";import{F as I}from"./field-nInV3MuR.js";import{M as pe}from"./message-ZenLdkrf.js";import{G as wt}from"./grid-B6LFPf51.js";import{C as _}from"./card-EcjmryU9.js";import{H as F}from"./heading-EzI5s4VN.js";import{T as qe}from"./toggle-D0yzyALV.js";import{S as Tt}from"./select-BPp24Pdw.js";import"./index-DRSy5Ssd.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-UmZ4Y_CR.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./input-D97ganXq.js";import"./styled-components.browser.esm-Bf0q9Yjk.js";import"./label-Cz6TT90s.js";import"./help-icon-CfV3_Ais.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-DIKP56UZ.js";const Et=()=>{const n=d.useRef(null);return d.useLayoutEffect(()=>{n.current&&(n.current(),n.current=null)}),t=>{n.current=t}},St=(n,a)=>{const t=a==null?void 0:a[n];return t||(console.log(`Warning: 'unitTemplate' does not define a preferred unit for '${n}'. Defaulting to standard unit.`),i.unitFromQuantity(n)??"")};var b=(n=>(n.CUSTOM="custom",n.PREDEFINED="predefined",n))(b||{});const Qn=n=>n==="undefined"||n===void 0||n===""||n==="null"||n===null||n==="NaN"||isNaN(n),Xn=(n="",a,t="",l=!1)=>{if(l)return n;if(a&&!Qn(n))try{const u=i.isValueWithUnit(n)?n:i.withUnit(n,t),p=i.convertSamePrecision(u,a);return i.getValue(p)}catch{}return n},Nt=n=>n?!!i.getUnit(n):!1,B=(n="",a,t,l)=>{if(l)return n;const u=Nt(n)||i.isValueWithUnit(n),p=i.getValue(n);return Qn(p)?p:u?Xn(p,a,t,l):n},De=n=>ue.isObject(n)&&!ue.isArray(n)&&!ue.isFunction(n)?ue.get(n,"fieldName",""):typeof n=="string"?n:"",Me=(n="")=>{var a;return(a=i.KNOWN_UNITS)==null?void 0:a.includes(n)},At=(n,a)=>{const t=i.getUnit(n||"");return Me(a)&&Me(t)},Pt="_predefinedMenuActive_ye9w9_1",qt="_inputWrapper_ye9w9_4",Re={predefinedMenuActive:Pt,inputWrapper:qt},m=({name:n,placeholder:a="",disabled:t=!1,disabledUnit:l=!1,error:u=null,left:p=!1,small:s=!1,width:g="100%",value:h,unitkey:E="",initUnit:y,noConversion:S=!1,onChange:me=()=>{},onClick:Mt=()=>{},onFocus:et=()=>{},onSwitchUnit:Ce=()=>{},unitTemplate:ye,doNotConvertValue:M=!1,testId:N,warning:Ue=null,predefinedOptions:V,initialPredefinedOption:nt=!1,shouldLinkAutomaticly:xe=!0,selectedPredefinedOptionKey:Ie,validationCallback:Ve=()=>({name:"",error:null}),disabledValidation:tt=!1,allowEmpty:at=!1,autoValue:j,convertBackToStorageUnit:rt=!1,enableCosmeticRounding:je=!0,enableDisplayRounding:it=!1})=>{typeof h=="number"&&(h=`${h}`);const st=Et(),[ke="",k=""]=h!==void 0?i.split(h):[],we=j?i.getUnit(j):"",Te=d.useMemo(()=>St(E,ye),[E,ye]),lt=At(h,Te),U=y||Te||k,ot=yt(U),Ee=B(h,U,k,M),Se=B(j,U,we,M),ut=Ee!==""?{value:Ee,unit:U}:Se!==""?{value:Se,unit:U}:{value:ke,unit:k},[v,ge]=d.useState(ut),[w,he]=d.useState(nt?b.PREDEFINED:b.CUSTOM),ve=ke===""&&j,dt=!!(tt||j||a),R=V&&V.find(r=>{if(!(r!=null&&r.value))return;if(Ie)return Ie===r.valueKey;const o=i.isValueWithUnit(r.value)?i.getUnit(r.value):"";return i.withUnit(Xn(h,o),o)===r.value}),ct=()=>{if(E)try{const r=ve?j:h??"";let o=i.altUnitsList(r,E);return i.getValue(r)===""?o.map(x=>["",x[1]]):o}catch{return null}},pt=r=>{const o=De(n),x=r.target,{value:T,selectionStart:A}=x,oe=i.withUnit(T,(v==null?void 0:v.unit)||""),fe=rt?i.withUnit(i.convertAndGetValue(oe,k),k):oe;me({target:{value:fe,name:o}});const[ft,bt]=i.split(oe);ge({value:ft,unit:bt}),st(()=>{x.selectionStart=A,x.selectionEnd=A})},mt=(r,o)=>{o===v.unit||isNaN(Number(r))||(ge({value:r,unit:o}),Ce&&Ce(o))};d.useEffect(()=>{if(U){let r,o="";ot!==U?(r=B(h,U,k,M),o=U):i.withUnit(v.value,v.unit)!==h&&(r=B(h,v.unit,k,M),o=v.unit),r!==void 0&&ge({value:r,unit:o}),V&&he(R&&xe?b.PREDEFINED:b.CUSTOM)}},[U,h,u,xe]);const ie=ct(),se=i.label(v.unit)||v.unit||"",gt=S||!ie||ie&&ie.length===1,Ne=De(n);let le;const ht=r=>{const o=r!=null&&r.value?r.value:"",[x="",T=""]=i.isValueWithUnit(o)?i.split(o):[o];return{type:Pe.OPTION,inline:!0,onClick:()=>{i.validateNumber(x).valid&&!t&&(he(b.PREDEFINED),me({target:{value:o,name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||"",predefinedSelected:!0,predefinedOption:r}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(ce,{children:r.label}),e.jsx(C,{width:"20px",height:"0"})]}),description:i.isValueWithUnit(o)?`${x} ${T}`:o,selected:R===r&&w===b.PREDEFINED}},vt=(r,o)=>{Ve&&Ve({name:r,error:o})};if(le=[{type:Pe.OPTION,inline:!0,onClick:()=>{w!==b.CUSTOM&&!t&&me({target:{value:i.withUnit(v.value,v.unit),name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||""}})},label:"Custom",selected:w===b.CUSTOM}],V!=null&&V.length){const r=V.map(ht);le=[...le,...r]}return e.jsx("div",{className:w===b.PREDEFINED?Ct(Re.predefinedMenuActive):"",children:e.jsxs(It,{small:s,width:g,children:[V&&e.jsx(xt,{text:w===b.PREDEFINED?R==null?void 0:R.label:"",children:e.jsx(Ae,{maxHeight:380,groupOrder:"first",testId:N&&`${N}-predefined-menu`,disabled:t,menu:{colored:!0,trigger:"Component",component:e.jsx(c,{groupOrder:"first",active:w===b.PREDEFINED,icon:w===b.PREDEFINED?"link":"unlink"}),small:s,sections:le}})}),e.jsx("div",{className:Re.inputWrapper,children:e.jsx(Vt,{name:Ne,testId:N,disabled:t,placeholder:ve?B(j,v.unit,we,M):a,value:v.value,onChange:pt,onFocus:et,error:u===null?void 0:u,warning:Ue===null?void 0:Ue,left:p,allowEmpty:at,validationCallback:vt,enableCosmeticRounding:je,enableDisplayRounding:it,groupOrder:V?"middle":"first",disableInternalErrorValidationMessages:dt},Ne)}),se&&(gt||!lt?e.jsx(Ut,{groupOrder:"last",children:se}):e.jsx(Ae,{maxHeight:380,groupOrder:"last",disabled:l,testId:N&&`${N}-menu`,menu:{label:se,trigger:"DropDownButton",small:s,sections:ie.map(([r,o,x])=>{const T=x||o||"",A=isNaN(Number(r))?"":r;return{type:"Option",label:je?jt(A):A,inline:!0,onClick:fe=>{fe.stopPropagation(),mt(ve?"":r,o)},description:T,selected:T===se,testId:`${N}-unit-${T}`}})}}))]})})};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:"(params: IUnitInputValidationCallbackPayload) => void",signature:{arguments:[{type:{name:"IUnitInputValidationCallbackPayload"},name:"params"}],return:{name:"void"}}},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: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"ChangeEvent<HTMLInputElement> | ICustomChangeEvent",elements:[{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},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:"() => {}",computed:!1}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"() => {}",computed:!1}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"() => {}",computed:!1}},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:Dt}=__STORYBOOK_MODULE_PREVIEW_API__,ja={title:"Forms/UnitInput",component:m,args:{name:"example",unitkey:"length",value:"123|m"}},f=n=>{const[a,t]=Dt(),l=u=>{t({value:u.target.value})};return e.jsx(m,{...n,onChange:l})},de=f.bind({}),W=f.bind({});W.args={initUnit:"ft",unitTemplate:{length:"ft"}};const O=f.bind({});O.args={value:'123|"',unitkey:'"'};const H=f.bind({});H.args={width:"180px"};const L=f.bind({});L.args={noConversion:!0};const K=f.bind({});K.args={small:!0};const G=f.bind({});G.args={error:"Error message goes here"};const $=f.bind({});$.args={value:"asas123asd|%"};const P=f.bind({});P.args={disabled:!0,disabledUnit:!0};P.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 z=f.bind({});z.args={disabled:!0,disabledUnit:!0,noConversion:!0};const J=f.bind({});J.args={disabledUnit:!0,unitkey:void 0};const Y=f.bind({});Y.args={disabledUnit:!0,unitkey:"length"};const Z=f.bind({});Z.args={disabledUnit:!1,disabled:!0};const q=n=>{const[a,t]=d.useState("123|m"),[l,u]=d.useState("223|m"),[p,s]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(c,{label:"Change initUnit",onClick:()=>s(p==="m"?"ft":"m")}),e.jsx(C,{}),e.jsx(c,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(C,{}),e.jsx(m,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,initUnit:p,onSwitchUnit:s}),e.jsx(C,{}),e.jsx(m,{name:"example2",onChange:g=>{u(g.target.value)},unitkey:"length",value:l,initUnit:p,onSwitchUnit:s}),e.jsx(kt,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(m,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,onSwitchUnit:s}),e.jsx(m,{name:"example2",onChange:g=>{u(g.target.value)},unitkey:"length",value:l,onSwitchUnit:s})]})};q.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const Q=f.bind({});Q.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const D=()=>{const n="500px",[a,t]=d.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Zn,{children:[e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI",children:e.jsx(m,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit"})}),e.jsx(I,{label:"Disabled validation",children:e.jsx(m,{name:"example2",onChange:l=>t(l.target.value),value:a,unitkey:"length",disabledValidation:!0,width:n})}),e.jsx(I,{label:"Disabled validation and manual error",children:e.jsx(m,{name:"example3",onChange:l=>t(l.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:n})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},X=()=>{const n="500px",[a,t]=d.useState("1|m"),[l,u]=d.useState("|m"),p="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Zn,{children:e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value to ''",onClick:()=>t("")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1",onClick:()=>t("1")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1|m",onClick:()=>t("1|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to |m - empty value",onClick:()=>t("|m")})]})}),e.jsx("br",{}),e.jsx(I,{label:"Normal PUI (placeholder + auto)",children:e.jsx(m,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit",autoValue:p})}),e.jsx(I,{label:"Normal PUI (only auto)",children:e.jsx(m,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:n,autoValue:p})}),e.jsx(I,{label:"Empty PUI with autoValue",children:e.jsx(m,{name:"example1",onChange:s=>u(s.target.value),value:l,unitkey:"length",width:n,autoValue:p})}),e.jsx(I,{label:"Normal PUI (only placeholder)",children:e.jsx(m,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test"})}),e.jsx(I,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(m,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};D.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const ee=()=>{const[n,a]=d.useState("123|%"),[t,l]=d.useState(null),u="This should be visible when an error appears",p=({name:s,error:g})=>(l(g),{name:s,error:g});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(m,{name:"example",onChange:s=>a(s.target.value),error:!t||u,validationCallback:p,value:n}),e.jsx("br",{}),e.jsx(C,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(pe,{message:{heading:t,visible:!0}})]})},ne=()=>{const[n,a]=d.useState("123|m"),[t,l]=d.useState(""),[u,p]=d.useState("km"),s=()=>{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:g=>a(g.target.value),value:n,allowEmpty:!0,placeholder:t,initUnit:u,unitkey:"length"}),e.jsx("br",{}),e.jsx(C,{}),e.jsx(c,{label:"Change value |m and unit ft",onClick:()=>s()})]})},te=()=>{const[n,a]=d.useState("123|m"),[t,l]=d.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(m,{name:"example",onChange:u=>a(u.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:l}),e.jsx(C,{}),e.jsx(m,{name:"example",onChange:u=>a(u.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:l})]})},ae=()=>e.jsxs(e.Fragment,{children:[e.jsx(ce,{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:i.withUnit(i.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}})]}),re=()=>{const[n,a]=d.useState("psi"),[t,l]=d.useState(!1),[u,p]=d.useState(!0),[s,g]=d.useState("672.2388357750001|bar"),[h,E]=d.useState("");return e.jsxs(wt,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(_,{heading:e.jsx(F,{children:"Settings"}),children:[e.jsx(I,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(qe,{checked:t,onChange:y=>l(y.target.checked)})}),e.jsx(I,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(qe,{checked:u,onChange:y=>p(y.target.checked)})})]}),e.jsxs(_,{heading:e.jsx(F,{children:"NumberInput (displayed in Meters)"}),children:[e.jsx(ce,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(C,{}),e.jsx(ce,{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:n,unitTemplate:{pressure:"psi"},value:s,onChange:y=>{const{value:S}=y.target;S&&g(S)},enableDisplayRounding:t,enableCosmeticRounding:u,error:i.convertAndGetValue(s,"bar")>=0?"":"Value must be positive",validationCallback:({name:y,error:S})=>{E(S??"")},convertBackToStorageUnit:!0})]}),e.jsx(_,{heading:e.jsx(F,{children:"Unit Template"}),children:e.jsx(Tt,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:n,width:70,onChange:y=>a(y.target.value)})}),e.jsx(_,{heading:e.jsx(F,{children:"Test Validation Callback"}),children:h&&e.jsx(pe,{message:{content:h,icon:!0,type:"Error",visible:!0}})}),e.jsxs(_,{heading:e.jsx(F,{children:"Storage State / Redux (stored in Feet)"}),children:[s,e.jsx(C,{}),e.jsx(c,{label:"Change value",onClick:()=>g(i.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})};q.__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:"(params: IUnitInputValidationCallbackPayload) => void",signature:{arguments:[{type:{name:"IUnitInputValidationCallbackPayload"},name:"params"}],return:{name:"void"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(event: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"ChangeEvent<HTMLInputElement> | ICustomChangeEvent",elements:[{name:"ChangeEvent",elements:[{name:"HTMLInputElement"}],raw:"ChangeEvent<HTMLInputElement>"},{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:""}}};D.__docgenInfo={description:"",methods:[],displayName:"TestEdgeCases"};X.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};ee.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};ne.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};te.__docgenInfo={description:"",methods:[],displayName:"onSwitchUnit"};ae.__docgenInfo={description:"",methods:[],displayName:"OW_10614TestCase"};re.__docgenInfo={description:"",methods:[],displayName:"DemoCosmeticRounding"};var _e,Fe,Be;de.parameters={...de.parameters,docs:{...(_e=de.parameters)==null?void 0:_e.docs,source:{originalSource:`args => {
|
|
2
|
-
const [_, updateArgs] = useArgs();
|
|
3
|
-
const handleChange = (evt: any) => {
|
|
4
|
-
updateArgs({
|
|
5
|
-
value: evt.target.value
|
|
6
|
-
});
|
|
7
|
-
};
|
|
8
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
9
|
-
}`,...(Be=(Fe=de.parameters)==null?void 0:Fe.docs)==null?void 0:Be.source}}};var We,Oe,He;W.parameters={...W.parameters,docs:{...(We=W.parameters)==null?void 0:We.docs,source:{originalSource:`args => {
|
|
10
|
-
const [_, updateArgs] = useArgs();
|
|
11
|
-
const handleChange = (evt: any) => {
|
|
12
|
-
updateArgs({
|
|
13
|
-
value: evt.target.value
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
17
|
-
}`,...(He=(Oe=W.parameters)==null?void 0:Oe.docs)==null?void 0:He.source}}};var Le,Ke,Ge;O.parameters={...O.parameters,docs:{...(Le=O.parameters)==null?void 0:Le.docs,source:{originalSource:`args => {
|
|
18
|
-
const [_, updateArgs] = useArgs();
|
|
19
|
-
const handleChange = (evt: any) => {
|
|
20
|
-
updateArgs({
|
|
21
|
-
value: evt.target.value
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
25
|
-
}`,...(Ge=(Ke=O.parameters)==null?void 0:Ke.docs)==null?void 0:Ge.source}}};var $e,ze,Je;H.parameters={...H.parameters,docs:{...($e=H.parameters)==null?void 0:$e.docs,source:{originalSource:`args => {
|
|
26
|
-
const [_, updateArgs] = useArgs();
|
|
27
|
-
const handleChange = (evt: any) => {
|
|
28
|
-
updateArgs({
|
|
29
|
-
value: evt.target.value
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
33
|
-
}`,...(Je=(ze=H.parameters)==null?void 0:ze.docs)==null?void 0:Je.source}}};var Ye,Ze,Qe;L.parameters={...L.parameters,docs:{...(Ye=L.parameters)==null?void 0:Ye.docs,source:{originalSource:`args => {
|
|
34
|
-
const [_, updateArgs] = useArgs();
|
|
35
|
-
const handleChange = (evt: any) => {
|
|
36
|
-
updateArgs({
|
|
37
|
-
value: evt.target.value
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
41
|
-
}`,...(Qe=(Ze=L.parameters)==null?void 0:Ze.docs)==null?void 0:Qe.source}}};var Xe,en,nn;K.parameters={...K.parameters,docs:{...(Xe=K.parameters)==null?void 0:Xe.docs,source:{originalSource:`args => {
|
|
42
|
-
const [_, updateArgs] = useArgs();
|
|
43
|
-
const handleChange = (evt: any) => {
|
|
44
|
-
updateArgs({
|
|
45
|
-
value: evt.target.value
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
49
|
-
}`,...(nn=(en=K.parameters)==null?void 0:en.docs)==null?void 0:nn.source}}};var tn,an,rn;G.parameters={...G.parameters,docs:{...(tn=G.parameters)==null?void 0:tn.docs,source:{originalSource:`args => {
|
|
50
|
-
const [_, updateArgs] = useArgs();
|
|
51
|
-
const handleChange = (evt: any) => {
|
|
52
|
-
updateArgs({
|
|
53
|
-
value: evt.target.value
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
57
|
-
}`,...(rn=(an=G.parameters)==null?void 0:an.docs)==null?void 0:rn.source}}};var sn,ln,on;$.parameters={...$.parameters,docs:{...(sn=$.parameters)==null?void 0:sn.docs,source:{originalSource:`args => {
|
|
58
|
-
const [_, updateArgs] = useArgs();
|
|
59
|
-
const handleChange = (evt: any) => {
|
|
60
|
-
updateArgs({
|
|
61
|
-
value: evt.target.value
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
65
|
-
}`,...(on=(ln=$.parameters)==null?void 0:ln.docs)==null?void 0:on.source}}};var un,dn,cn;P.parameters={...P.parameters,docs:{...(un=P.parameters)==null?void 0:un.docs,source:{originalSource:`args => {
|
|
66
|
-
const [_, updateArgs] = useArgs();
|
|
67
|
-
const handleChange = (evt: any) => {
|
|
68
|
-
updateArgs({
|
|
69
|
-
value: evt.target.value
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
73
|
-
}`,...(cn=(dn=P.parameters)==null?void 0:dn.docs)==null?void 0:cn.source}}};var pn,mn,gn;z.parameters={...z.parameters,docs:{...(pn=z.parameters)==null?void 0:pn.docs,source:{originalSource:`args => {
|
|
74
|
-
const [_, updateArgs] = useArgs();
|
|
75
|
-
const handleChange = (evt: any) => {
|
|
76
|
-
updateArgs({
|
|
77
|
-
value: evt.target.value
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
81
|
-
}`,...(gn=(mn=z.parameters)==null?void 0:mn.docs)==null?void 0:gn.source}}};var hn,vn,fn;J.parameters={...J.parameters,docs:{...(hn=J.parameters)==null?void 0:hn.docs,source:{originalSource:`args => {
|
|
82
|
-
const [_, updateArgs] = useArgs();
|
|
83
|
-
const handleChange = (evt: any) => {
|
|
84
|
-
updateArgs({
|
|
85
|
-
value: evt.target.value
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
89
|
-
}`,...(fn=(vn=J.parameters)==null?void 0:vn.docs)==null?void 0:fn.source}}};var bn,Cn,yn;Y.parameters={...Y.parameters,docs:{...(bn=Y.parameters)==null?void 0:bn.docs,source:{originalSource:`args => {
|
|
90
|
-
const [_, updateArgs] = useArgs();
|
|
91
|
-
const handleChange = (evt: any) => {
|
|
92
|
-
updateArgs({
|
|
93
|
-
value: evt.target.value
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
97
|
-
}`,...(yn=(Cn=Y.parameters)==null?void 0:Cn.docs)==null?void 0:yn.source}}};var Un,xn,In;Z.parameters={...Z.parameters,docs:{...(Un=Z.parameters)==null?void 0:Un.docs,source:{originalSource:`args => {
|
|
98
|
-
const [_, updateArgs] = useArgs();
|
|
99
|
-
const handleChange = (evt: any) => {
|
|
100
|
-
updateArgs({
|
|
101
|
-
value: evt.target.value
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
105
|
-
}`,...(In=(xn=Z.parameters)==null?void 0:xn.docs)==null?void 0:In.source}}};var Vn,jn,kn;q.parameters={...q.parameters,docs:{...(Vn=q.parameters)==null?void 0:Vn.docs,source:{originalSource:`(args: IUnitInputProps) => {
|
|
106
|
-
const [value, setValue] = useState('123|m');
|
|
107
|
-
const [value2, setValue2] = useState('223|m');
|
|
108
|
-
const [initUnit, setInitUnit] = useState('ft');
|
|
109
|
-
return <>
|
|
110
|
-
<Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
|
|
111
|
-
<Spacer />
|
|
112
|
-
<Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
|
|
113
|
-
<Spacer />
|
|
114
|
-
<UnitInput name="example" onChange={evt => {
|
|
115
|
-
setValue(evt.target.value);
|
|
116
|
-
}} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
117
|
-
<Spacer />
|
|
118
|
-
<UnitInput name="example2" onChange={evt => {
|
|
119
|
-
setValue2(evt.target.value);
|
|
120
|
-
}} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
121
|
-
<Divider />
|
|
122
|
-
<h4>Without initUnit property (taken from the redux store)</h4>
|
|
123
|
-
<UnitInput name="example" onChange={evt => {
|
|
124
|
-
setValue(evt.target.value);
|
|
125
|
-
}} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
|
|
126
|
-
<UnitInput name="example2" onChange={evt => {
|
|
127
|
-
setValue2(evt.target.value);
|
|
128
|
-
}} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
|
|
129
|
-
</>;
|
|
130
|
-
}`,...(kn=(jn=q.parameters)==null?void 0:jn.docs)==null?void 0:kn.source}}};var wn,Tn,En;Q.parameters={...Q.parameters,docs:{...(wn=Q.parameters)==null?void 0:wn.docs,source:{originalSource:`args => {
|
|
131
|
-
const [_, updateArgs] = useArgs();
|
|
132
|
-
const handleChange = (evt: any) => {
|
|
133
|
-
updateArgs({
|
|
134
|
-
value: evt.target.value
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
return <UnitInput {...args} onChange={handleChange} />;
|
|
138
|
-
}`,...(En=(Tn=Q.parameters)==null?void 0:Tn.docs)==null?void 0:En.source}}};var Sn,Nn,An;D.parameters={...D.parameters,docs:{...(Sn=D.parameters)==null?void 0:Sn.docs,source:{originalSource:`() => {
|
|
139
|
-
const width = '500px';
|
|
140
|
-
const [value, setValue] = useState<any>(undefined);
|
|
141
|
-
return <>
|
|
142
|
-
<h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
|
|
143
|
-
<Row>
|
|
144
|
-
<Column width="25%">
|
|
145
|
-
<Button label="Change value infinity" onClick={() => setValue(Infinity)} />
|
|
146
|
-
<br />
|
|
147
|
-
<Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
|
|
148
|
-
<br />
|
|
149
|
-
<Button label="Change value null" onClick={() => setValue(null)} />
|
|
150
|
-
<br />
|
|
151
|
-
<Button label="Change value - undefined" onClick={() => setValue(undefined)} />
|
|
152
|
-
<br />
|
|
153
|
-
<Button label="Change value - NaN" onClick={() => setValue(NaN)} />
|
|
154
|
-
<br />
|
|
155
|
-
<Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
|
|
156
|
-
<br />
|
|
157
|
-
<Button label="Change value - empty string" onClick={() => setValue('')} />
|
|
158
|
-
</Column>
|
|
159
|
-
<Column width="25%">
|
|
160
|
-
<Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
|
|
161
|
-
<br />
|
|
162
|
-
<Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
|
|
163
|
-
<br />
|
|
164
|
-
<Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
|
|
165
|
-
<br />
|
|
166
|
-
<Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
|
|
167
|
-
<br />
|
|
168
|
-
<Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
|
|
169
|
-
<br />
|
|
170
|
-
<Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
|
|
171
|
-
</Column>
|
|
172
|
-
</Row>
|
|
173
|
-
<br />
|
|
174
|
-
<Field label="Normal PUI">
|
|
175
|
-
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
|
|
176
|
-
</Field>
|
|
177
|
-
<Field label="Disabled validation">
|
|
178
|
-
<UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
|
|
179
|
-
</Field>
|
|
180
|
-
<Field label="Disabled validation and manual error">
|
|
181
|
-
<UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
|
|
182
|
-
</Field>
|
|
183
|
-
<Message message={{
|
|
184
|
-
heading: 'Current value inside PUI: ' + value,
|
|
185
|
-
visible: true
|
|
186
|
-
}} />
|
|
187
|
-
</>;
|
|
188
|
-
}`,...(An=(Nn=D.parameters)==null?void 0:Nn.docs)==null?void 0:An.source}}};var Pn,qn,Dn;X.parameters={...X.parameters,docs:{...(Pn=X.parameters)==null?void 0:Pn.docs,source:{originalSource:`() => {
|
|
189
|
-
const width = '500px';
|
|
190
|
-
const [value, setValue] = useState<string>('1|m');
|
|
191
|
-
const [valueB, setValueB] = useState('|m');
|
|
192
|
-
const automaticValue = '123|km';
|
|
193
|
-
return <>
|
|
194
|
-
<h4>Different cases for automatic (placeholder) values:</h4>
|
|
195
|
-
<Row>
|
|
196
|
-
<Column width="25%">
|
|
197
|
-
<Button label="Change value to ''" onClick={() => setValue('')} />
|
|
198
|
-
<br />
|
|
199
|
-
<Button label="Change value to 1" onClick={() => setValue('1')} />
|
|
200
|
-
<br />
|
|
201
|
-
<Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
|
|
202
|
-
<br />
|
|
203
|
-
<Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
|
|
204
|
-
</Column>
|
|
205
|
-
</Row>
|
|
206
|
-
<br />
|
|
207
|
-
<Field label="Normal PUI (placeholder + auto)">
|
|
208
|
-
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
|
|
209
|
-
</Field>
|
|
210
|
-
<Field label="Normal PUI (only auto)">
|
|
211
|
-
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
|
|
212
|
-
</Field>
|
|
213
|
-
<Field label="Empty PUI with autoValue">
|
|
214
|
-
<UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
|
|
215
|
-
</Field>
|
|
216
|
-
<Field label="Normal PUI (only placeholder)">
|
|
217
|
-
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
|
|
218
|
-
</Field>
|
|
219
|
-
<Field label="Normal PUI (placeholder + allowEmpty)">
|
|
220
|
-
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
|
|
221
|
-
</Field>
|
|
222
|
-
<Message message={{
|
|
223
|
-
heading: 'Current value inside PUI: ' + value,
|
|
224
|
-
visible: true
|
|
225
|
-
}} />
|
|
226
|
-
</>;
|
|
227
|
-
}`,...(Dn=(qn=X.parameters)==null?void 0:qn.docs)==null?void 0:Dn.source}}};var Mn,Rn,_n;ee.parameters={...ee.parameters,docs:{...(Mn=ee.parameters)==null?void 0:Mn.docs,source:{originalSource:`() => {
|
|
228
|
-
const [value, setValue] = useState('123|%');
|
|
229
|
-
const [validation, setValidation] = useState<string | null>(null);
|
|
230
|
-
const predictedMessage = 'This should be visible when an error appears';
|
|
231
|
-
const handleValidation = ({
|
|
232
|
-
name,
|
|
233
|
-
error
|
|
234
|
-
}: IUnitInputValidationCallbackPayload) => {
|
|
235
|
-
setValidation(error);
|
|
236
|
-
return {
|
|
237
|
-
name,
|
|
238
|
-
error
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
return <>
|
|
242
|
-
<h4>3rd party validation message when inputting invalid value:</h4>
|
|
243
|
-
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
|
|
244
|
-
<br />
|
|
245
|
-
<Spacer />
|
|
246
|
-
<h4>Original validation message: </h4>
|
|
247
|
-
<Message message={{
|
|
248
|
-
heading: validation,
|
|
249
|
-
visible: true
|
|
250
|
-
}} />
|
|
251
|
-
</>;
|
|
252
|
-
}`,...(_n=(Rn=ee.parameters)==null?void 0:Rn.docs)==null?void 0:_n.source}}};var Fn,Bn,Wn;ne.parameters={...ne.parameters,docs:{...(Fn=ne.parameters)==null?void 0:Fn.docs,source:{originalSource:`() => {
|
|
253
|
-
const [value, setValue] = useState('123|m');
|
|
254
|
-
const [placeholder, setPlaceholder] = useState('');
|
|
255
|
-
const [initUnit, setInitUnit] = useState('km');
|
|
256
|
-
const setPlaceholderValue = () => {
|
|
257
|
-
setInitUnit('ft');
|
|
258
|
-
setPlaceholder('placeholder');
|
|
259
|
-
setValue('|m');
|
|
260
|
-
};
|
|
261
|
-
return <>
|
|
262
|
-
<h4>Empty value case:</h4>
|
|
263
|
-
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
|
|
264
|
-
<br />
|
|
265
|
-
<Spacer />
|
|
266
|
-
<Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
|
|
267
|
-
</>;
|
|
268
|
-
}`,...(Wn=(Bn=ne.parameters)==null?void 0:Bn.docs)==null?void 0:Wn.source}}};var On,Hn,Ln;te.parameters={...te.parameters,docs:{...(On=te.parameters)==null?void 0:On.docs,source:{originalSource:`() => {
|
|
269
|
-
const [value, setValue] = useState('123|m');
|
|
270
|
-
const [unit, setUnit] = useState('m');
|
|
271
|
-
return <>
|
|
272
|
-
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
273
|
-
<Spacer />
|
|
274
|
-
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
275
|
-
</>;
|
|
276
|
-
}`,...(Ln=(Hn=te.parameters)==null?void 0:Hn.docs)==null?void 0:Ln.source}}};var Kn,Gn,$n;ae.parameters={...ae.parameters,docs:{...(Kn=ae.parameters)==null?void 0:Kn.docs,source:{originalSource:`() => {
|
|
277
|
-
return <>
|
|
278
|
-
<Text faint>
|
|
279
|
-
Reproduce OW-10614 rounding noise bug when storing values in a different
|
|
280
|
-
unit to the display unit
|
|
281
|
-
</Text>
|
|
282
|
-
<Spacer />
|
|
283
|
-
<UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
|
|
284
|
-
pressure: 'psi'
|
|
285
|
-
}} />
|
|
286
|
-
</>;
|
|
287
|
-
}`,...($n=(Gn=ae.parameters)==null?void 0:Gn.docs)==null?void 0:$n.source}}};var zn,Jn,Yn;re.parameters={...re.parameters,docs:{...(zn=re.parameters)==null?void 0:zn.docs,source:{originalSource:`() => {
|
|
288
|
-
const [preferredUnit, setPreferredUnit] = useState('psi');
|
|
289
|
-
const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
|
|
290
|
-
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
|
|
291
|
-
const [value, setValue] = useState('672.2388357750001|bar');
|
|
292
|
-
const [callBackError, setCallBackError] = useState('');
|
|
293
|
-
return <Grid columns="1fr 1fr" gap>
|
|
294
|
-
<Card heading={<Heading>Settings</Heading>}>
|
|
295
|
-
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
296
|
-
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
297
|
-
</Field>
|
|
298
|
-
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
299
|
-
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
300
|
-
</Field>
|
|
301
|
-
</Card>
|
|
302
|
-
<Card heading={<Heading>NumberInput (displayed in Meters)</Heading>}>
|
|
303
|
-
<Text faint>
|
|
304
|
-
Cosmetic Rounding Test Case: type 9750 then return (compare with
|
|
305
|
-
enableCosmeticRounding on and off)
|
|
306
|
-
</Text>
|
|
307
|
-
<Spacer />
|
|
308
|
-
<Text warning>
|
|
309
|
-
Note: UnitInput uses convertSamePrecision internally (decision prior
|
|
310
|
-
to cosmetic value implementation). This means not all rounding noise
|
|
311
|
-
occurrences seen in NumberInput will be reproducible in UnitInput,
|
|
312
|
-
because they get rounded off by other logic.
|
|
313
|
-
</Text>
|
|
314
|
-
<Spacer />
|
|
315
|
-
<UnitInput name="Example" unitkey="pressure" initUnit={preferredUnit} unitTemplate={{
|
|
316
|
-
pressure: 'psi'
|
|
317
|
-
}} value={value} onChange={evt => {
|
|
318
|
-
const {
|
|
319
|
-
value
|
|
320
|
-
} = evt.target;
|
|
321
|
-
if (value) {
|
|
322
|
-
setValue(value);
|
|
323
|
-
}
|
|
324
|
-
}} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={convertAndGetValue(value, 'bar') >= 0 ? '' : 'Value must be positive'} validationCallback={({
|
|
325
|
-
name,
|
|
326
|
-
error
|
|
327
|
-
}) => {
|
|
328
|
-
setCallBackError(error ?? '');
|
|
329
|
-
}} convertBackToStorageUnit />
|
|
330
|
-
</Card>
|
|
331
|
-
<Card heading={<Heading>Unit Template</Heading>}>
|
|
332
|
-
<Select options={[{
|
|
333
|
-
label: 'Bar',
|
|
334
|
-
value: 'bar'
|
|
335
|
-
}, {
|
|
336
|
-
label: 'psi',
|
|
337
|
-
value: 'psi'
|
|
338
|
-
}]} value={preferredUnit} width={70} onChange={evt => setPreferredUnit(evt.target.value)} />
|
|
339
|
-
</Card>
|
|
340
|
-
<Card heading={<Heading>Test Validation Callback</Heading>}>
|
|
341
|
-
{callBackError && <Message message={{
|
|
342
|
-
content: callBackError,
|
|
343
|
-
icon: true,
|
|
344
|
-
type: 'Error',
|
|
345
|
-
visible: true
|
|
346
|
-
}} />}
|
|
347
|
-
</Card>
|
|
348
|
-
<Card heading={<Heading>Storage State / Redux (stored in Feet)</Heading>}>
|
|
349
|
-
{value}
|
|
350
|
-
<Spacer />
|
|
351
|
-
<Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'bar'))} />
|
|
352
|
-
</Card>
|
|
353
|
-
</Grid>;
|
|
354
|
-
}`,...(Yn=(Jn=re.parameters)==null?void 0:Jn.docs)==null?void 0:Yn.source}}};const ka=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","OW_10614TestCase","DemoCosmeticRounding"];export{ne as AllowEmptyPUI,X as AutomaticValues,de as Default,re as DemoCosmeticRounding,P as Disabled,z as DisabledNoConversion,Y as DisabledUnitWithUnitKey,J as DisabledUnitWithoutUnitKey,Z as DisabledWithEnabledUnitMenu,G as Error,W as InitUnit,$ as InternalValidationError,L as NoConversion,ae as OW_10614TestCase,Q as PredefinedOptionsMenu,K as Small,D as TestEdgeCases,q as TestExternalStateChangeWithSynchronizedUnits,ee as ValidationCallback,H as Width,ka as __namedExportsOrder,ja as default,O as notKnownUnit,te as onSwitchUnit};
|