@oliasoft-open-source/react-ui-library 4.10.8 → 4.10.10-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-DoFa61ar.js → index-DNn0fRjY.js} +6 -0
- package/dist/global.css +12 -14
- package/dist/index.html +1 -1
- package/dist/index.js +158 -152
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-Dt2NN35S.js → Color-KGDBMAHA-Ctoumk1_.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-Dt4AywHY.js → DocsRenderer-PKQXORMH-D6snvJ2n.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-BTxV-ybU.js → accordion.stories-DFLo2Xxp.js} +2 -2
- package/dist/storybook/assets/{afe.stories-DFQsvqIV.js → afe.stories-DM18uTAa.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-DeM87L0f.js → buttons-and-links-Cp6CY221.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-CJpnsmsZ.js → casing-loads.stories-D2tl6Xaj.js} +2 -2
- package/dist/storybook/assets/{cell.stories-Bpl0Squh.js → cell.stories-3u3qlMqR.js} +2 -2
- package/dist/storybook/assets/check-box.stories-BJ0ShmeC.js +97 -0
- package/dist/storybook/assets/check-box.test-case.stories-CzuYZkUh.js +30 -0
- package/dist/storybook/assets/{chunk-HLWAVYOI-CP6RR10g.js → chunk-HLWAVYOI-kUA3ddmK.js} +1 -1
- package/dist/storybook/assets/{color-BeVjwOuK.js → color-B-anC3UD.js} +1 -1
- package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
- package/dist/storybook/assets/footer.stories-BHyYr-w1.js +3 -0
- package/dist/storybook/assets/form.stories-f2Uxr04c.js +49 -0
- package/dist/storybook/assets/{formation.stories-BT8VrcqV.js → formation.stories-Djd9Xcyb.js} +2 -2
- package/dist/storybook/assets/helpers-JJxzGegQ.js +1 -0
- package/dist/storybook/assets/iframe-BPqD7cXD.js +2 -0
- package/dist/storybook/assets/{index-B4RCKdW0.js → index-C_d1lYll.js} +88 -88
- package/dist/storybook/assets/{index-BXS7i-H6.js → index-D_vfgX3I.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-CElwRt3p.js → input-group.stories-EhmORqH9.js} +3 -3
- package/dist/storybook/assets/{input-validation-Plr4Q99k.js → input-validation-DWk2h2sH.js} +2 -2
- package/dist/storybook/assets/{inputs-DRQYRbsV.js → inputs-DxXk84P7.js} +2 -2
- package/dist/storybook/assets/{layout-forms-dQ6e8ua1.js → layout-forms-DsvEdOzO.js} +5 -5
- package/dist/storybook/assets/{layout-general-B7yaYduN.js → layout-general-Be12Eyfp.js} +1 -1
- package/dist/storybook/assets/menu.stories-DLJSzJa-.js +82 -0
- package/dist/storybook/assets/menu.test-case.stories-DyrNbGBs.js +3 -0
- package/dist/storybook/assets/modal.stories-DOgeTuHT.js +200 -0
- package/dist/storybook/assets/modal.test-case.stories-DQ1Izuq6.js +21 -0
- package/dist/storybook/assets/{number-input-Bpg4Yqmo.js → number-input-CJJvhIIv.js} +1 -1
- package/dist/storybook/assets/number-input.stories-CKVq60XH.js +89 -0
- package/dist/storybook/assets/number-input.test-case.stories-Dh1F7N8M.js +92 -0
- package/dist/storybook/assets/{padding-and-spacing-D8xvyqXz.js → padding-and-spacing-BSmTd9GW.js} +1 -1
- package/dist/storybook/assets/{pagination-CLt-kUlx.js → pagination-DWc8zp3k.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-CTRM0Xou.js → pagination.stories-B5cOvzik.js} +2 -2
- package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +10 -0
- package/dist/storybook/assets/{preview-B2Y6Vmrm.js → preview-CL_1oTTQ.js} +1 -1
- package/dist/storybook/assets/{preview-CaCL0Opd.js → preview-DZPidHkD.js} +2 -2
- package/dist/storybook/assets/{projects.stories-BQswWVCx.js → projects.stories-Co_WnKSx.js} +2 -2
- package/dist/storybook/assets/{radio-button-DmDuw4DA.js → radio-button-C4ljBRED.js} +1 -1
- package/dist/storybook/assets/radio-button.stories-D1rWr6ms.js +61 -0
- package/dist/storybook/assets/radio-button.test-case.stories-DglmHlWs.js +11 -0
- package/dist/storybook/assets/{reservoirs.stories-B12tIrmZ.js → reservoirs.stories-UW_8sofe.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-DkaOBgbE.js → rich-text-input.stories-CK_OTGiV.js} +3 -3
- package/dist/storybook/assets/{row.stories-msEoNdGI.js → row.stories-BuIxD-aT.js} +2 -2
- package/dist/storybook/assets/select-03uRbc4I.js +61 -0
- package/dist/storybook/assets/select.input-CJed_LLR.js +1 -0
- package/dist/storybook/assets/select.stories-Bpffz9TF.js +498 -0
- package/dist/storybook/assets/select.stories-data-DxgWKlU6.js +1 -0
- package/dist/storybook/assets/select.test-case.stories-DwDNDHax.js +82 -0
- package/dist/storybook/assets/{site.stories-umpPYjkq.js → site.stories-ZGohyW6Z.js} +2 -2
- package/dist/storybook/assets/{slider-C7vnj_3M.js → slider-CNPYg8Sz.js} +3 -3
- package/dist/storybook/assets/{slider-DnRddBCy.css → slider-LRg-kjEJ.css} +1 -1
- package/dist/storybook/assets/slider.stories-BH6uxhwC.js +125 -0
- package/dist/storybook/assets/{table-5Y5KPNSk.js → table-B5fM_vjN.js} +1 -1
- package/dist/storybook/assets/{table.stories-Clltxls0.js → table.stories-HRJd7a1D.js} +2 -2
- package/dist/storybook/assets/{tabs-C3NG6m9W.js → tabs-BoToLVEP.js} +1 -1
- package/dist/storybook/assets/tabs.stories-B52iEaHf.js +30 -0
- package/dist/storybook/assets/{title.stories-CsrYTGde.js → title.stories-C1rVRHkF.js} +3 -3
- package/dist/storybook/assets/toaster.stories-G6nKp3uV.js +84 -0
- package/dist/storybook/assets/toaster.test-case.stories-CCHTh_U1.js +6 -0
- package/dist/storybook/assets/toggle.stories-BAislK3I.js +106 -0
- package/dist/storybook/assets/toggle.test-case.stories-CeUwdhGD.js +36 -0
- package/dist/storybook/assets/{tooltip.test-case.stories-CHibN8rC.js → tooltip.test-case.stories-C0wxGvKJ.js} +1 -1
- package/dist/storybook/assets/unit-input-maDNevEK.js +10 -0
- package/dist/storybook/assets/unit-input.stories-CZBOk2N9.js +198 -0
- package/dist/storybook/assets/unit-input.test-case.stories-DQIpam5Y.js +220 -0
- package/dist/storybook/assets/unit-table.stories-DVqdGdEC.js +152 -0
- package/dist/storybook/assets/unit-table.test-case.stories-CThfe_IO.js +1 -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/404.html +0 -1
- package/dist/storybook/assets/check-box.stories-DfbWw6mD.js +0 -126
- package/dist/storybook/assets/footer.stories-DgjDE_JR.js +0 -3
- package/dist/storybook/assets/form.stories-BrUnmw7R.js +0 -49
- package/dist/storybook/assets/iframe-CLpyA5uB.js +0 -2
- package/dist/storybook/assets/menu.stories-xWX80Eh2.js +0 -84
- package/dist/storybook/assets/modal.stories-LhoWfDE6.js +0 -220
- package/dist/storybook/assets/number-input.stories-DhCjZ37u.js +0 -180
- package/dist/storybook/assets/popover.stories-CGm0M5fv.js +0 -10
- package/dist/storybook/assets/radio-button.stories-5gvV0LD0.js +0 -71
- package/dist/storybook/assets/select-DnRuRG_N.js +0 -61
- package/dist/storybook/assets/select.input-D0UkAPd9.js +0 -1
- package/dist/storybook/assets/select.stories-B9w9ONzj.js +0 -579
- package/dist/storybook/assets/slider.stories-BzBb3PkP.js +0 -171
- package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +0 -30
- package/dist/storybook/assets/toaster.stories-HO4VBTy-.js +0 -89
- package/dist/storybook/assets/toggle.stories-qTHFTXxI.js +0 -141
- package/dist/storybook/assets/unit-input.stories-DoCaLohq.js +0 -426
- package/dist/storybook/assets/unit-table.stories-uy3ukIal.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-B5fM_vjN.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-C3vJedB1.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-DWc8zp3k.js";import"./select-03uRbc4I.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CJJvhIIv.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./slider-CNPYg8Sz.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";import"./flex-EllkLxgO.js";const Or={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 m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.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-5Y5KPNS
|
|
|
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,_;m.parameters={...m.parameters,docs:{...(N=m.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=m.parameters)==null?void 0:U.docs)==null?void 0:_.source}}};const Wr=["Units","ActiveRow","Title","TitleJSX","ChildComponent","Filter","Sort","HeaderActionsNoLabel","HelpAndLibraryIcons"];export{s as ActiveRow,o as ChildComponent,n as Filter,p as HeaderActionsNoLabel,m as HelpAndLibraryIcons,i as Sort,a as Title,t as TitleJSX,e as Units,Wr as __namedExportsOrder,Or as default};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{j as s}from"./jsx-runtime-eps93zm2.js";import{G as W}from"./grid-DRkC-bt8.js";import{T as m}from"./text-B3-TSWok.js";import{F as P}from"./flex-EllkLxgO.js";import{t as d,d as p}from"./toaster-BoBcvmf9.js";import{B as o}from"./button-DHevvVBE.js";import{S as q}from"./spacer-BWoNR27H.js";import{a as g}from"./message-Y48EomV-.js";import"./index-DhsZuJvc.js";import"./styled-components.browser.esm-BQ9GQzDc.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-1V7clEnw.js";const L={type:g.SUCCESS,icon:!0,heading:"Heading",content:"Great results"},U={type:g.ERROR,icon:!0,heading:"Heading",content:"An error has happened",details:"Bad input data lorem ipsum dolor est compendum lorem ipsum."},z={type:g.WARNING,icon:!0,heading:"Heading",content:"Warning message"},J={type:g.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},xs={title:"Modals/Toaster",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:J,autoClose:6e3,onClose:()=>{}}},x=e=>s.jsx(o,{onClick:()=>d({...e,onClose:()=>console.log("toast closed")}),label:"Show toast"}),u=x.bind({}),r=x.bind({});r.args={message:L};const a=x.bind({});a.args={message:z};const n=x.bind({});n.args={message:U};const t=()=>s.jsx(o,{label:"Show Toast",onClick:()=>{const e=Math.random()>=.5;d({message:{type:e?"Success":"Error",icon:!0,content:e?"Success":"Error"},onClose:()=>console.log("toast closed"),id:"uniqueId"})}});t.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 i=()=>{const e="sessionExpiring",S={type:"Info",content:s.jsxs(W,{children:[s.jsx(m,{bold:!0,children:"You will be signed out soon"}),s.jsx(m,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx(q,{height:"var(--padding-xxs)"}),s.jsxs(P,{gap:"var(--padding-xs)",children:[s.jsx(o,{label:"Extend session",small:!0,colored:"success",onClick:()=>p(e)}),s.jsx(o,{label:"Dismiss",small:!0,onClick:()=>p(e)})]})]})};return s.jsx(o,{label:"Show Toast",onClick:()=>d({message:S,autoClose:!1,id:e})})},c=()=>{const e="sessionExpiringSoon",S={type:"Error",content:s.jsxs(W,{children:[s.jsx(m,{bold:!0,children:"You will be signed out very soon"}),s.jsx(m,{children:"For your security, you will be automatically signed out in 30 minutes unless you extend your session."}),s.jsx(q,{height:"var(--padding-xxs)"}),s.jsxs(P,{gap:"var(--padding-xs)",children:[s.jsx(o,{label:"Extend session",small:!0,colored:"success",onClick:()=>p(e)}),s.jsx(o,{label:"Dismiss",small:!0,onClick:()=>p(e)})]})]})};return s.jsx(o,{label:"Show Toast",onClick:()=>d({message:S,autoClose:!1,id:e})})},l=()=>{const e={type:"Success",content:"Your session has been extended for 1 hour"};return s.jsx(o,{label:"Show Toast",onClick:()=>d({message:e})})};t.__docgenInfo={description:"",methods:[],displayName:"PreventDuplicates"};i.__docgenInfo={description:"",methods:[],displayName:"SessionExpiring"};c.__docgenInfo={description:"",methods:[],displayName:"SessionExpiringSoon"};l.__docgenInfo={description:"",methods:[],displayName:"SessionExtended"};var h,y,T;u.parameters={...u.parameters,docs:{...(h=u.parameters)==null?void 0:h.docs,source:{originalSource:`args => {
|
|
2
|
+
return <Button onClick={() => toast({
|
|
3
|
+
...args,
|
|
4
|
+
onClose: () => console.log('toast closed')
|
|
5
|
+
})} label="Show toast" />;
|
|
6
|
+
}`,...(T=(y=u.parameters)==null?void 0:y.docs)==null?void 0:T.source}}};var b,C,E;r.parameters={...r.parameters,docs:{...(b=r.parameters)==null?void 0:b.docs,source:{originalSource:`args => {
|
|
7
|
+
return <Button onClick={() => toast({
|
|
8
|
+
...args,
|
|
9
|
+
onClose: () => console.log('toast closed')
|
|
10
|
+
})} label="Show toast" />;
|
|
11
|
+
}`,...(E=(C=r.parameters)==null?void 0:C.docs)==null?void 0:E.source}}};var f,I,w;a.parameters={...a.parameters,docs:{...(f=a.parameters)==null?void 0:f.docs,source:{originalSource:`args => {
|
|
12
|
+
return <Button onClick={() => toast({
|
|
13
|
+
...args,
|
|
14
|
+
onClose: () => console.log('toast closed')
|
|
15
|
+
})} label="Show toast" />;
|
|
16
|
+
}`,...(w=(I=a.parameters)==null?void 0:I.docs)==null?void 0:w.source}}};var j,k,_;n.parameters={...n.parameters,docs:{...(j=n.parameters)==null?void 0:j.docs,source:{originalSource:`args => {
|
|
17
|
+
return <Button onClick={() => toast({
|
|
18
|
+
...args,
|
|
19
|
+
onClose: () => console.log('toast closed')
|
|
20
|
+
})} label="Show toast" />;
|
|
21
|
+
}`,...(_=(k=n.parameters)==null?void 0:k.docs)==null?void 0:_.source}}};var D,v,B;t.parameters={...t.parameters,docs:{...(D=t.parameters)==null?void 0:D.docs,source:{originalSource:`() => <Button label="Show Toast" onClick={() => {
|
|
22
|
+
const isSuccess = Math.random() >= 0.5;
|
|
23
|
+
toast({
|
|
24
|
+
message: ({
|
|
25
|
+
type: isSuccess ? 'Success' : 'Error',
|
|
26
|
+
icon: true,
|
|
27
|
+
content: isSuccess ? 'Success' : 'Error'
|
|
28
|
+
} as IMessageType),
|
|
29
|
+
onClose: () => console.log('toast closed'),
|
|
30
|
+
id: 'uniqueId'
|
|
31
|
+
});
|
|
32
|
+
}} />`,...(B=(v=t.parameters)==null?void 0:v.docs)==null?void 0:B.source}}};var O,A,F;i.parameters={...i.parameters,docs:{...(O=i.parameters)==null?void 0:O.docs,source:{originalSource:`() => {
|
|
33
|
+
const TOAST_ID = 'sessionExpiring';
|
|
34
|
+
const message = ({
|
|
35
|
+
type: 'Info',
|
|
36
|
+
content: <Grid>
|
|
37
|
+
<Text bold>You will be signed out soon</Text>
|
|
38
|
+
<Text>
|
|
39
|
+
For your security, you will be automatically signed out in 30 minutes
|
|
40
|
+
unless you extend your session.
|
|
41
|
+
</Text>
|
|
42
|
+
<Spacer height="var(--padding-xxs)" />
|
|
43
|
+
<Flex gap="var(--padding-xs)">
|
|
44
|
+
<Button label="Extend session" small colored="success" onClick={() => dismissToast(TOAST_ID)} />
|
|
45
|
+
<Button label="Dismiss" small onClick={() => dismissToast(TOAST_ID)} />
|
|
46
|
+
</Flex>
|
|
47
|
+
</Grid>
|
|
48
|
+
} as IMessageType);
|
|
49
|
+
return <Button label="Show Toast" onClick={() => toast({
|
|
50
|
+
message,
|
|
51
|
+
autoClose: false,
|
|
52
|
+
id: TOAST_ID
|
|
53
|
+
})} />;
|
|
54
|
+
}`,...(F=(A=i.parameters)==null?void 0:A.docs)==null?void 0:F.source}}};var G,M,N;c.parameters={...c.parameters,docs:{...(G=c.parameters)==null?void 0:G.docs,source:{originalSource:`() => {
|
|
55
|
+
const TOAST_ID = 'sessionExpiringSoon';
|
|
56
|
+
const message = ({
|
|
57
|
+
type: 'Error',
|
|
58
|
+
content: <Grid>
|
|
59
|
+
<Text bold>You will be signed out very soon</Text>
|
|
60
|
+
<Text>
|
|
61
|
+
For your security, you will be automatically signed out in 30 minutes
|
|
62
|
+
unless you extend your session.
|
|
63
|
+
</Text>
|
|
64
|
+
<Spacer height="var(--padding-xxs)" />
|
|
65
|
+
<Flex gap="var(--padding-xs)">
|
|
66
|
+
<Button label="Extend session" small colored="success" onClick={() => dismissToast(TOAST_ID)} />
|
|
67
|
+
<Button label="Dismiss" small onClick={() => dismissToast(TOAST_ID)} />
|
|
68
|
+
</Flex>
|
|
69
|
+
</Grid>
|
|
70
|
+
} as IMessageType);
|
|
71
|
+
return <Button label="Show Toast" onClick={() => toast({
|
|
72
|
+
message,
|
|
73
|
+
autoClose: false,
|
|
74
|
+
id: TOAST_ID
|
|
75
|
+
})} />;
|
|
76
|
+
}`,...(N=(M=c.parameters)==null?void 0:M.docs)==null?void 0:N.source}}};var H,Y,R;l.parameters={...l.parameters,docs:{...(H=l.parameters)==null?void 0:H.docs,source:{originalSource:`() => {
|
|
77
|
+
const message = ({
|
|
78
|
+
type: 'Success',
|
|
79
|
+
content: 'Your session has been extended for 1 hour'
|
|
80
|
+
} as IMessageType);
|
|
81
|
+
return <Button label="Show Toast" onClick={() => toast({
|
|
82
|
+
message
|
|
83
|
+
})} />;
|
|
84
|
+
}`,...(R=(Y=l.parameters)==null?void 0:Y.docs)==null?void 0:R.source}}};const Ss=["Default","Success","Warning","Error","PreventDuplicates","SessionExpiring","SessionExpiringSoon","SessionExtended"];export{u as Default,n as Error,t as PreventDuplicates,i as SessionExpiring,c as SessionExpiringSoon,l as SessionExtended,r as Success,a as Warning,Ss as __namedExportsOrder,xs as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{j as u}from"./jsx-runtime-eps93zm2.js";import{w as d,e as a,u as n,a as c}from"./index-DMAnyMX5.js";import{t as g}from"./toaster-BoBcvmf9.js";import{B as w}from"./button-DHevvVBE.js";import{a as y}from"./message-Y48EomV-.js";import"./index-DhsZuJvc.js";import"./index-CF7H4eMJ.js";import"./toaster-7wnI6hqB.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.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-1V7clEnw.js";const h={type:y.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},O={title:"Modals/Toaster/Test Cases",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:h,autoClose:6e3,onClose:()=>{}},tags:["!autodocs"]},T=r=>u.jsx(w,{onClick:()=>g({...r,onClose:()=>console.log("toast closed")}),label:"Show toast"}),s=T.bind({});s.args={id:"testId",autoClose:50};s.play=async({canvasElement:r,step:i})=>{const t=r.parentElement?d(r.parentElement):null;await a(t).toBeTruthy(),t&&(await i("Toast should appear when triggered",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.getByRole("alert");await a(e).toBeInTheDocument()}),await i("Duplicate toasts shouldn't be created",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.queryAllByRole("alert");await a(e).toHaveLength(1)}),await i("Toast should disappear when close button pressed",async()=>{const o=t.getByRole("alert"),e=t.getByTestId("testId-dismiss");await n.click(e),await c(()=>a(o).not.toBeInTheDocument(),{timeout:2e3})}),await i("Toast should automatically close",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.getByRole("alert");await c(()=>a(e).not.toBeInTheDocument(),{timeout:2e3})}))};var l,m,p;s.parameters={...s.parameters,docs:{...(l=s.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
|
|
2
|
+
return <Button onClick={() => toast({
|
|
3
|
+
...args,
|
|
4
|
+
onClose: () => console.log('toast closed')
|
|
5
|
+
})} label="Show toast" />;
|
|
6
|
+
}`,...(p=(m=s.parameters)==null?void 0:m.docs)==null?void 0:p.source}}};const q=["Test"];export{s as Test,q as __namedExportsOrder,O as default};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{F as h}from"./flex-EllkLxgO.js";import{T as g}from"./text-B3-TSWok.js";import{T as i}from"./toggle-BbFVf61v.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";const{useArgs:q}=__STORYBOOK_MODULE_PREVIEW_API__,ce={title:"Forms/Toggle",component:i,args:{label:"Label"}},n=N=>{const[{checked:U},V]=q(),Y=()=>{V({checked:!U})};return e.jsx(i,{...N,onChange:Y})},p=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 o=n.bind({});o.args={helpText:"Help text"};const c=n.bind({});c.args={onClickHelp:()=>console.log("Help clicked")};const d=()=>e.jsxs(e.Fragment,{children:[e.jsx(i,{display:"block",label:e.jsxs(h,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(g,{bold:!0,children:"Label"}),e.jsx(g,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}}),e.jsx(i,{label:e.jsxs(h,{justifyContent:"space-between",wrap:!1,gap:!0,children:[e.jsx(g,{bold:!0,children:"Label"}),e.jsx(g,{success:!0,children:"Released yesterday"})]}),onChange:()=>{}})]}),l=n.bind({});l.args={helpText:"Help text",disabled:!0};d.__docgenInfo={description:"",methods:[],displayName:"Display"};var u,m,x;p.parameters={...p.parameters,docs:{...(u=p.parameters)==null?void 0:u.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
|
+
}`,...(x=(m=p.parameters)==null?void 0:m.docs)==null?void 0:x.source}}};var b,C,k;s.parameters={...s.parameters,docs:{...(b=s.parameters)==null?void 0:b.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
|
+
}`,...(k=(C=s.parameters)==null?void 0:C.docs)==null?void 0:k.source}}};var T,A,j;a.parameters={...a.parameters,docs:{...(T=a.parameters)==null?void 0:T.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
|
+
}`,...(j=(A=a.parameters)==null?void 0:A.docs)==null?void 0:j.source}}};var y,f,S;r.parameters={...r.parameters,docs:{...(y=r.parameters)==null?void 0:y.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
|
+
}`,...(S=(f=r.parameters)==null?void 0:f.docs)==null?void 0:S.source}}};var D,_,H;t.parameters={...t.parameters,docs:{...(D=t.parameters)==null?void 0:D.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
|
+
}`,...(H=(_=t.parameters)==null?void 0:_.docs)==null?void 0:H.source}}};var w,F,O;o.parameters={...o.parameters,docs:{...(w=o.parameters)==null?void 0:w.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
|
+
}`,...(O=(F=o.parameters)==null?void 0:F.docs)==null?void 0:O.source}}};var R,L,E;c.parameters={...c.parameters,docs:{...(R=c.parameters)==null?void 0:R.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
|
+
}`,...(E=(L=c.parameters)==null?void 0:L.docs)==null?void 0:E.source}}};var I,W,P;d.parameters={...d.parameters,docs:{...(I=d.parameters)==null?void 0:I.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
|
+
</>`,...(P=(W=d.parameters)==null?void 0:W.docs)==null?void 0:P.source}}};var B,K,M;l.parameters={...l.parameters,docs:{...(B=l.parameters)==null?void 0:B.docs,source:{originalSource:`args => {
|
|
95
|
+
const [{
|
|
96
|
+
checked
|
|
97
|
+
}, updateArgs] = useArgs();
|
|
98
|
+
const handleChange = () => {
|
|
99
|
+
updateArgs({
|
|
100
|
+
checked: !checked
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return <Toggle
|
|
104
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
105
|
+
{...args} onChange={handleChange} />;
|
|
106
|
+
}`,...(M=(K=l.parameters)==null?void 0:K.docs)==null?void 0:M.source}}};const de=["Default","Disabled","DisabledChecked","Small","Standalone","HelpText","OnClickHelp","Display","DisabledWithHelpText"];export{p as Default,s as Disabled,a as DisabledChecked,l as DisabledWithHelpText,d as Display,o as HelpText,c as OnClickHelp,r as Small,t as Standalone,de as __namedExportsOrder,ce as default};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{j as _}from"./jsx-runtime-eps93zm2.js";import{r as I}from"./index-DhsZuJvc.js";import{w as v,u as g,e as d}from"./index-DMAnyMX5.js";import{T as i}from"./toggle-BbFVf61v.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";const{useArgs:w}=__STORYBOOK_MODULE_PREVIEW_API__,N={title:"Forms/Toggle/Test Cases",component:i,args:{label:"Label"},tags:["!autodocs"]},y=t=>{const[{checked:s},n]=w(),e=()=>{n({checked:!s})};return _.jsx(i,{...t,onChange:e})},o=()=>{const[t,s]=I.useState(!1);return _.jsx(i,{name:"name",label:"Label",checked:t,onChange:n=>{const{name:e,value:r,checked:l}=n.target;s(l),console.log(e,r,l)}})},a=y.bind({});a.args={testId:"testId"};a.play=async({canvasElement:t,step:s})=>{const n=v(t);await s("Clicking checkbox should toggle it",async()=>{const e=n.getByTestId("testId"),r=e.querySelector("input");await g.click(e),await d(r).toBeChecked(),await g.click(e),await d(r).not.toBeChecked()})};const c=y.bind({});c.args={testId:"testId",disabled:!0};c.play=async({canvasElement:t,step:s})=>{const n=v(t);await s("Clicking disabled checkbox shouldn't toggle it",async()=>{const e=n.getByTestId("testId");await e.click(),await d(e.querySelector("input")).not.toBeChecked()})};o.__docgenInfo={description:"",methods:[],displayName:"TestClickevt"};var p,m,h;o.parameters={...o.parameters,docs:{...(p=o.parameters)==null?void 0:p.docs,source:{originalSource:`() => {
|
|
2
|
+
const [checked, setChecked] = useState(false);
|
|
3
|
+
return <Toggle name="name" label="Label" checked={checked} onChange={evt => {
|
|
4
|
+
const {
|
|
5
|
+
name,
|
|
6
|
+
value,
|
|
7
|
+
checked
|
|
8
|
+
} = evt.target;
|
|
9
|
+
setChecked(checked);
|
|
10
|
+
console.log(name, value, checked);
|
|
11
|
+
}} />;
|
|
12
|
+
}`,...(h=(m=o.parameters)==null?void 0:m.docs)==null?void 0:h.source}}};var u,k,C;a.parameters={...a.parameters,docs:{...(u=a.parameters)==null?void 0:u.docs,source:{originalSource:`args => {
|
|
13
|
+
const [{
|
|
14
|
+
checked
|
|
15
|
+
}, updateArgs] = useArgs();
|
|
16
|
+
const handleChange = () => {
|
|
17
|
+
updateArgs({
|
|
18
|
+
checked: !checked
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
return <Toggle
|
|
22
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
23
|
+
{...args} onChange={handleChange} />;
|
|
24
|
+
}`,...(C=(k=a.parameters)==null?void 0:k.docs)==null?void 0:C.source}}};var T,b,x;c.parameters={...c.parameters,docs:{...(T=c.parameters)==null?void 0:T.docs,source:{originalSource:`args => {
|
|
25
|
+
const [{
|
|
26
|
+
checked
|
|
27
|
+
}, updateArgs] = useArgs();
|
|
28
|
+
const handleChange = () => {
|
|
29
|
+
updateArgs({
|
|
30
|
+
checked: !checked
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return <Toggle
|
|
34
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
35
|
+
{...args} onChange={handleChange} />;
|
|
36
|
+
}`,...(x=(b=c.parameters)==null?void 0:b.docs)==null?void 0:x.source}}};const U=["TestClickevt","Test","TestDisabled"];export{a as Test,o as TestClickevt,c as TestDisabled,U as __namedExportsOrder,N as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o}from"./jsx-runtime-eps93zm2.js";import{T as m}from"./tooltip-1V7clEnw.js";import{M as u}from"./actions-D-uVCDzk.js";import{m as d}from"./menu.stories-data-CQ59XhzU.js";import"./index-DhsZuJvc.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./lodash-c4VUpsOs.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./flex-EllkLxgO.js";const B={title:"Basic/Tooltip/Test Cases",component:m,args:{text:"Tooltip text"}},l=c=>o.jsx(m,{...c}),e=l.bind({});e.args={children:o.jsx(u,{menu:d}),placement:"bottom-end",display:"inline-block"};const s=l.bind({});s.args={children:o.jsx("span",{children:"Hover over me"}),text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra tellus eu cursus suscipit. Maecenas leo sapien, convallis ac urna ullamcorper, tempus porttitor eros. Suspendisse pellentesque odio ac metus semper, nec sagittis nisi cursus. Aenean felis libero, bibendum id accumsan id, commodo suscipit ex. Pellentesque gravida rhoncus neque, ac tincidunt libero maximus vel. In lacus nisi, malesuada vitae velit vel, laoreet porta nisl."};var t,r,i;e.parameters={...e.parameters,docs:{...(t=e.parameters)==null?void 0:t.docs,source:{originalSource:`args => <Tooltip
|
|
1
|
+
import{j as o}from"./jsx-runtime-eps93zm2.js";import{T as m}from"./tooltip-1V7clEnw.js";import{M as u}from"./actions-D-uVCDzk.js";import{m as d}from"./menu.stories-data-CQ59XhzU.js";import"./index-DhsZuJvc.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./lodash-c4VUpsOs.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./flex-EllkLxgO.js";const B={title:"Basic/Tooltip/Test Cases",component:m,args:{text:"Tooltip text"},tags:["!autodocs"]},l=c=>o.jsx(m,{...c}),e=l.bind({});e.args={children:o.jsx(u,{menu:d}),placement:"bottom-end",display:"inline-block"};const s=l.bind({});s.args={children:o.jsx("span",{children:"Hover over me"}),text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra tellus eu cursus suscipit. Maecenas leo sapien, convallis ac urna ullamcorper, tempus porttitor eros. Suspendisse pellentesque odio ac metus semper, nec sagittis nisi cursus. Aenean felis libero, bibendum id accumsan id, commodo suscipit ex. Pellentesque gravida rhoncus neque, ac tincidunt libero maximus vel. In lacus nisi, malesuada vitae velit vel, laoreet porta nisl."};var t,r,i;e.parameters={...e.parameters,docs:{...(t=e.parameters)==null?void 0:t.docs,source:{originalSource:`args => <Tooltip
|
|
2
2
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
3
3
|
{...args} />`,...(i=(r=e.parameters)==null?void 0:r.docs)==null?void 0:i.source}}};var a,n,p;s.parameters={...s.parameters,docs:{...(a=s.parameters)==null?void 0:a.docs,source:{originalSource:`args => <Tooltip
|
|
4
4
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{j as p}from"./jsx-runtime-eps93zm2.js";import{r as T}from"./index-DhsZuJvc.js";import{d as n}from"./index-C0x1JmaP.js";import{c as Ce}from"./index-Bk2sglWO.js";import{u as Fe}from"./use-previous-D775JrO6.js";import{M as Y}from"./actions-D-uVCDzk.js";import{I as De}from"./input-group-addon-D68iUKV2.js";import{B as Me}from"./button-DHevvVBE.js";import{T as Pe}from"./tooltip-1V7clEnw.js";import{I as xe}from"./input-group-BaRSJAEN.js";import{S as Ae}from"./spacer-BWoNR27H.js";import{T as Se}from"./text-B3-TSWok.js";import{M as Z}from"./types-BmbYqTX_.js";import{l as E}from"./lodash-c4VUpsOs.js";import{N as je,r as We}from"./number-input-CJJvhIIv.js";const Le=()=>{const e=T.useRef(null);return T.useLayoutEffect(()=>{e.current&&(e.current(),e.current=null)}),s=>{e.current=s}},Oe=(e,r)=>{const s=r==null?void 0:r[e];return s||(console.log(`Warning: 'unitTemplate' missing for '${e}'. Using initial unit, preferred unit or value unit.`),n.unitFromQuantity(e)??"")};var c=(e=>(e.CUSTOM="custom",e.PREDEFINED="predefined",e))(c||{});const ie=e=>e==="undefined"||e===void 0||e===""||e==="null"||e===null||e==="NaN"||isNaN(e),re=({value:e,unitkey:r,toUnit:s})=>{var f;const v=n.ALT_UNITS[r];return!(!v||v.length===0||!((f=n.validateNumber(e))!=null&&f.valid)||!v.includes(s))},ae=(e="",r,s,v="",f=!1)=>{var V;if(f)return e;if((V=n.validateNumber(e))!=null&&V.valid&&r&&!ie(e))try{const o=n.isValueWithUnit(e)?e:n.withUnit(e,v);if(re({value:o,toUnit:r,unitkey:s})){const l=n.convertSamePrecision(o,r);return n.getValue(l)}return n.getValue(o)}catch{}},Re=e=>e?!!n.getUnit(e):!1,C=({value:e="",toUnit:r,unitkey:s,defaultFromUnit:v,doNotConvertValue:f})=>{const V=Re(e)||n.isValueWithUnit(e),o=n.getValue(e);return ie(o)?o:V?ae(o,r,s,v,f):e},ee=e=>E.isObject(e)&&!E.isArray(e)&&!E.isFunction(e)?E.get(e,"fieldName",""):typeof e=="string"?e:"",te=(e="")=>{var r;return(r=n.KNOWN_UNITS)==null?void 0:r.includes(e)},_e=(e,r)=>{const s=n.getUnit(e||"");return te(r)&&te(s)};let He=T.createContext(null);const $e=()=>T.useContext(He),ke="_predefinedMenuActive_ye9w9_1",Be="_inputWrapper_ye9w9_4",ne={predefinedMenuActive:ke,inputWrapper:Be},Ke=({name:e,placeholder:r="",disabled:s=!1,disabledUnit:v=!1,error:f=null,left:V=!1,small:o=!1,width:A="100%",value:l,unitkey:d="",initUnit:se,noConversion:le=!1,onChange:S=E.noop,onClick:Ge=E.noop,onFocus:ue=E.noop,onSwitchUnit:_=E.noop,unitTemplate:H,doNotConvertValue:q=!1,testId:I,warning:$=null,predefinedOptions:y,initialPredefinedOption:oe=!1,shouldLinkAutomaticly:k=!0,selectedPredefinedOptionKey:B,validationCallback:de=()=>({name:"",error:null}),disabledValidation:pe=!1,allowEmpty:Qe=!1,autoValue:b,convertBackToStorageUnit:ce=!1,enableCosmeticRounding:K=!0,enableDisplayRounding:me=!1})=>{const N=$e(),fe=Le();typeof l=="number"&&(l=`${l}`);const[G="",h=""]=l!==void 0?n.split(l):[],Q=b?n.getUnit(b):"",z=T.useMemo(()=>Oe(d,H||(N==null?void 0:N.unitTemplate)),[d,H,N==null?void 0:N.unitTemplate]),ge=_e(l,z),g=se||z||h,ve=Fe(g),J=C({value:l,toUnit:g,unitkey:d,defaultFromUnit:h,doNotConvertValue:q}),X=C({value:b,toUnit:g,unitkey:d,defaultFromUnit:Q,doNotConvertValue:q}),ye=J!==""?{value:J,unit:g}:X!==""?{value:X,unit:g}:{value:G,unit:h},[a,j]=T.useState(ye),Ue=(a==null?void 0:a.value)===void 0,[w,W]=T.useState(oe?c.PREDEFINED:c.CUSTOM),L=G===""&&b,Te=!!(pe||b),F=y&&y.find(t=>{if(!(t!=null&&t.value))return;if(B)return B===t.valueKey;const i=n.isValueWithUnit(t.value)?n.getUnit(t.value):"";return n.withUnit(ae(l,i,d),i)===t.value}),Ee=()=>{const t=L?b:l??"",i=a.unit;if(re({value:t,unitkey:d,toUnit:i})){if(d)try{let u=n.altUnitsList(t,d);return n.getValue(t)===""?u.map(m=>["",m[1]]):u}catch{return null}}else{let u=n.getAltUnitsListByQuantity(d);return u==null?void 0:u.map(m=>["",m==null?void 0:m.unit])}},be=t=>{const i=ee(e),U=t.target,{value:u,selectionStart:m}=U,x=n.withUnit(u,(a==null?void 0:a.unit)||""),R=ce?n.withUnit(n.convertAndGetValue(x,h),h):x;S({target:{value:R,name:i}});const[Ie,Ne]=n.split(x);j({value:Ie,unit:Ne}),fe(()=>{U.selectionStart=m,U.selectionEnd=m})},he=(t,i)=>{i===a.unit||isNaN(Number(t))||(j({value:t,unit:i}),_&&_(i))};T.useEffect(()=>{if(g){let t,i="";ve!==g?(t=C({value:l,toUnit:g,unitkey:d,defaultFromUnit:h,doNotConvertValue:q}),i=g):n.withUnit(a.value,a.unit)!==l&&(t=C({value:l,toUnit:a.unit,unitkey:d,defaultFromUnit:h,doNotConvertValue:q}),i=a.unit),t!==void 0&&j({value:t,unit:i}),y&&W(F&&k?c.PREDEFINED:c.CUSTOM)}},[g,l,f,k]);const D=Ee(),M=n.label(a.unit)||a.unit||"",we=le||!D||D&&D.length===1,O=ee(e);let P;const Ve=t=>{const i=t!=null&&t.value?t.value:"",[U="",u=""]=n.isValueWithUnit(i)?n.split(i):[i];return{type:Z.OPTION,inline:!0,onClick:()=>{n.validateNumber(U).valid&&!s&&(W(c.PREDEFINED),S({target:{value:i,name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||"",predefinedSelected:!0,predefinedOption:t}}))},label:p.jsxs(p.Fragment,{children:[p.jsx(Se,{children:t.label}),p.jsx(Ae,{width:"20px",height:"0"})]}),description:n.isValueWithUnit(i)?`${U} ${u}`:i,selected:F===t&&w===c.PREDEFINED}};if(P=[{type:Z.OPTION,inline:!0,onClick:()=>{w!==c.CUSTOM&&!s&&S({target:{value:n.withUnit(a.value,a.unit),name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||""}})},label:"Custom",selected:w===c.CUSTOM}],y!=null&&y.length){const t=y.map(Ve);P=[...P,...t]}const qe=t=>{if(L)return C({value:b,toUnit:a.unit,unitkey:d,defaultFromUnit:Q,doNotConvertValue:q});if(n.isValueWithUnit(t)){const i=n.getUnit(t);return C({value:t,toUnit:a.unit,unitkey:d,defaultFromUnit:i,doNotConvertValue:q})}return t};return p.jsx("div",{className:w===c.PREDEFINED?Ce(ne.predefinedMenuActive):"",children:p.jsxs(xe,{small:o,width:A,children:[y&&p.jsx(Pe,{text:w===c.PREDEFINED?F==null?void 0:F.label:"",children:p.jsx(Y,{maxHeight:380,groupOrder:"first",testId:I&&`${I}-predefined-menu`,disabled:s,menu:{colored:!0,trigger:"Component",component:p.jsx(Me,{groupOrder:"first",active:w===c.PREDEFINED,icon:w===c.PREDEFINED?"link":"unlink"}),small:o,sections:P}})}),p.jsx("div",{className:ne.inputWrapper,children:p.jsx(je,{name:O,testId:I,disabled:s,placeholder:qe(r),value:a.value,onChange:be,onFocus:ue,error:f===null?void 0:f,warning:$===null?void 0:$,left:V,allowEmpty:Ue,validationCallback:(t,i)=>de(O,i),enableCosmeticRounding:K,enableDisplayRounding:me,groupOrder:y?"middle":"first",disableInternalErrorValidationMessages:Te,small:o},O)}),M&&(we||!ge?p.jsx(De,{groupOrder:"last",children:M}):p.jsx(Y,{maxHeight:380,groupOrder:"last",disabled:v,testId:I&&`${I}-menu`,menu:{label:M,trigger:"DropDownButton",small:o,sections:D.map(([t,i,U])=>{const u=U||i||"",m=n.isValidNum(t)?t:"";return{type:"Option",label:K?We(m):m,inline:!0,onClick:R=>{R.stopPropagation(),he(L?"":t,i)},description:u,selected:u===M,testId:`${I}-unit-${u}`}})}}))]})})};Ke.__docgenInfo={description:"",methods:[],displayName:"UnitInput",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},disabledUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:"",defaultValue:{value:"null",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:"",defaultValue:{value:"() => ({ name: '', error: null })",computed:!1}},disabledValidation:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
2
|
+
target:
|
|
3
|
+
| T
|
|
4
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
5
|
+
}`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
|
|
6
|
+
target:
|
|
7
|
+
| T
|
|
8
|
+
| { name: string; value: any; label?: string; files?: FileList | null };
|
|
9
|
+
}`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
|
|
10
|
+
| { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},{name:"ICustomChangeEvent"}]},name:"event"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onSwitchUnit:{required:!1,tsType:{name:"signature",type:"function",raw:"(unit: string) => void",signature:{arguments:[{type:{name:"string"},name:"unit"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onClick:{required:!1,tsType:{name:"MouseEventHandler",elements:[{name:"HTMLInputElement"}],raw:"MouseEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"FocusEventHandler",elements:[{name:"HTMLInputElement"}],raw:"FocusEventHandler<HTMLInputElement>"},description:"",defaultValue:{value:"noop",computed:!0}},unitTemplate:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"any"}],raw:"Record<string, any>"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}}}};export{Ke as U};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as u}from"./index-DhsZuJvc.js";import{U as o}from"./unit-input-maDNevEK.js";import{B as p}from"./button-DHevvVBE.js";import{S as E}from"./spacer-BWoNR27H.js";import{R as Fe,C as De}from"./row-Bmiy2Lh0.js";import{F as g}from"./field-HrLaMLbx.js";import{M as Ne}from"./message-Y48EomV-.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./index-Bk2sglWO.js";import"./use-previous-D775JrO6.js";import"./actions-D-uVCDzk.js";import"./lodash-c4VUpsOs.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./text-B3-TSWok.js";import"./number-input-CJJvhIIv.js";import"./enum-Bnn40S8Q.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";const{useArgs:Be}=__STORYBOOK_MODULE_PREVIEW_API__,Ua={title:"Forms/UnitInput",component:o,args:{name:"example",unitkey:"length",value:"123|m"}},s=n=>{const[r,a]=Be(),i=l=>{a({value:l.target.value})};return e.jsx(o,{...n,onChange:i})},P=s.bind({}),m=s.bind({});m.args={initUnit:"ft",unitTemplate:{length:"ft"}};const h=s.bind({});h.args={value:'123|"',unitkey:'"'};const v=s.bind({});v.args={width:"180px"};const C=s.bind({});C.args={noConversion:!0};const b=s.bind({});b.args={small:!0};const U=s.bind({});U.args={error:"Error message goes here"};const x=s.bind({});x.args={value:"asas123asd|%"};const c=s.bind({});c.args={disabled:!0,disabledUnit:!0};c.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 y=s.bind({});y.args={disabled:!0,disabledUnit:!0,noConversion:!0};const I=s.bind({});I.args={disabledUnit:!0,unitkey:void 0};const V=s.bind({});V.args={disabledUnit:!0,unitkey:"length"};const A=s.bind({});A.args={disabledUnit:!1,disabled:!0};const S=s.bind({});S.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const w=()=>{const n="500px",[r,a]=u.useState("1|m"),[i,l]=u.useState("|m"),d="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Fe,{children:e.jsxs(De,{width:"25%",children:[e.jsx(p,{label:"Change value to ''",onClick:()=>a("")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1",onClick:()=>a("1")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to 1|m",onClick:()=>a("1|m")}),e.jsx("br",{}),e.jsx(p,{label:"Change value to |m - empty value",onClick:()=>a("|m")})]})}),e.jsx("br",{}),e.jsx(g,{label:"Normal PUI (placeholder + auto)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"value|unit",autoValue:d})}),e.jsx(g,{label:"Normal PUI (only auto)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,autoValue:d})}),e.jsx(g,{label:"Empty PUI with autoValue",children:e.jsx(o,{name:"example1",onChange:t=>l(t.target.value),value:i,unitkey:"length",width:n,autoValue:d})}),e.jsx(g,{label:"Normal PUI (only placeholder)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"Placeholder test"})}),e.jsx(g,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(o,{name:"example1",onChange:t=>a(t.target.value),value:r,unitkey:"length",width:n,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(Ne,{message:{heading:"Current value inside PUI: "+r,visible:!0}})]})},j=()=>{const[n,r]=u.useState("123|%"),[a,i]=u.useState(null),l="This should be visible when an error appears",d=(t,_)=>(i(_),{name:t,error:_});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(o,{name:"example",onChange:t=>r(t.target.value),error:!a||l,validationCallback:d,value:n}),e.jsx("br",{}),e.jsx(E,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(Ne,{message:{heading:a,visible:!0}})]})},k=()=>{const[n,r]=u.useState("123|m"),[a,i]=u.useState(""),[l,d]=u.useState("km"),t=()=>{d("ft"),i("placeholder"),r("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(o,{name:"example",onChange:_=>r(_.target.value),value:n,allowEmpty:!0,placeholder:a,initUnit:l,unitkey:"length"}),e.jsx("br",{}),e.jsx(E,{}),e.jsx(p,{label:"Change value |m and unit ft",onClick:()=>t()})]})},f=()=>{const[n,r]=u.useState("123|m"),[a,i]=u.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(o,{name:"example",onChange:l=>r(l.target.value),value:n,initUnit:a,unitkey:"length",onSwitchUnit:i}),e.jsx(E,{}),e.jsx(o,{name:"example",onChange:l=>r(l.target.value),value:n,initUnit:a,unitkey:"length",onSwitchUnit:i})]})};w.__docgenInfo={description:"",methods:[],displayName:"AutomaticValues"};j.__docgenInfo={description:"",methods:[],displayName:"ValidationCallback"};k.__docgenInfo={description:"",methods:[],displayName:"AllowEmptyPUI"};f.__docgenInfo={description:"",methods:[],displayName:"OnSwitchUnit"};var N,F,D;P.parameters={...P.parameters,docs:{...(N=P.parameters)==null?void 0:N.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
|
+
}`,...(D=(F=P.parameters)==null?void 0:F.docs)==null?void 0:D.source}}};var B,O,M;m.parameters={...m.parameters,docs:{...(B=m.parameters)==null?void 0:B.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
|
+
}`,...(M=(O=m.parameters)==null?void 0:O.docs)==null?void 0:M.source}}};var W,R,K;h.parameters={...h.parameters,docs:{...(W=h.parameters)==null?void 0:W.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
|
+
}`,...(K=(R=h.parameters)==null?void 0:R.docs)==null?void 0:K.source}}};var T,q,L;v.parameters={...v.parameters,docs:{...(T=v.parameters)==null?void 0:T.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
|
+
}`,...(L=(q=v.parameters)==null?void 0:q.docs)==null?void 0:L.source}}};var Y,z,G;C.parameters={...C.parameters,docs:{...(Y=C.parameters)==null?void 0:Y.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
|
+
}`,...(G=(z=C.parameters)==null?void 0:z.docs)==null?void 0:G.source}}};var H,J,Q;b.parameters={...b.parameters,docs:{...(H=b.parameters)==null?void 0:H.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
|
+
}`,...(Q=(J=b.parameters)==null?void 0:J.docs)==null?void 0:Q.source}}};var X,Z,$;U.parameters={...U.parameters,docs:{...(X=U.parameters)==null?void 0:X.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
|
+
}`,...($=(Z=U.parameters)==null?void 0:Z.docs)==null?void 0:$.source}}};var ee,ae,te;x.parameters={...x.parameters,docs:{...(ee=x.parameters)==null?void 0:ee.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
|
+
}`,...(te=(ae=x.parameters)==null?void 0:ae.docs)==null?void 0:te.source}}};var ne,re,se;c.parameters={...c.parameters,docs:{...(ne=c.parameters)==null?void 0:ne.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
|
+
}`,...(se=(re=c.parameters)==null?void 0:re.docs)==null?void 0:se.source}}};var le,oe,ie;y.parameters={...y.parameters,docs:{...(le=y.parameters)==null?void 0:le.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
|
+
}`,...(ie=(oe=y.parameters)==null?void 0:oe.docs)==null?void 0:ie.source}}};var ue,de,ce;I.parameters={...I.parameters,docs:{...(ue=I.parameters)==null?void 0:ue.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
|
+
}`,...(ce=(de=I.parameters)==null?void 0:de.docs)==null?void 0:ce.source}}};var ge,pe,me;V.parameters={...V.parameters,docs:{...(ge=V.parameters)==null?void 0:ge.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
|
+
}`,...(me=(pe=V.parameters)==null?void 0:pe.docs)==null?void 0:me.source}}};var he,ve,Ce;A.parameters={...A.parameters,docs:{...(he=A.parameters)==null?void 0:he.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
|
+
}`,...(Ce=(ve=A.parameters)==null?void 0:ve.docs)==null?void 0:Ce.source}}};var be,Ue,xe;S.parameters={...S.parameters,docs:{...(be=S.parameters)==null?void 0:be.docs,source:{originalSource:`args => {
|
|
106
|
+
const [_, updateArgs] = useArgs();
|
|
107
|
+
const handleChange = (evt: any) => {
|
|
108
|
+
updateArgs({
|
|
109
|
+
value: evt.target.value
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
113
|
+
}`,...(xe=(Ue=S.parameters)==null?void 0:Ue.docs)==null?void 0:xe.source}}};var ye,Ie,Ve;w.parameters={...w.parameters,docs:{...(ye=w.parameters)==null?void 0:ye.docs,source:{originalSource:`() => {
|
|
114
|
+
const width = '500px';
|
|
115
|
+
const [value, setValue] = useState<string>('1|m');
|
|
116
|
+
const [valueB, setValueB] = useState('|m');
|
|
117
|
+
const automaticValue = '123|km';
|
|
118
|
+
return <>
|
|
119
|
+
<h4>Different cases for automatic (placeholder) values:</h4>
|
|
120
|
+
<Row>
|
|
121
|
+
<Column width="25%">
|
|
122
|
+
<Button label="Change value to ''" onClick={() => setValue('')} />
|
|
123
|
+
<br />
|
|
124
|
+
<Button label="Change value to 1" onClick={() => setValue('1')} />
|
|
125
|
+
<br />
|
|
126
|
+
<Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
|
|
127
|
+
<br />
|
|
128
|
+
<Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
|
|
129
|
+
</Column>
|
|
130
|
+
</Row>
|
|
131
|
+
<br />
|
|
132
|
+
<Field label="Normal PUI (placeholder + auto)">
|
|
133
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
|
|
134
|
+
</Field>
|
|
135
|
+
<Field label="Normal PUI (only auto)">
|
|
136
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
|
|
137
|
+
</Field>
|
|
138
|
+
<Field label="Empty PUI with autoValue">
|
|
139
|
+
<UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
|
|
140
|
+
</Field>
|
|
141
|
+
<Field label="Normal PUI (only placeholder)">
|
|
142
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
|
|
143
|
+
</Field>
|
|
144
|
+
<Field label="Normal PUI (placeholder + allowEmpty)">
|
|
145
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
|
|
146
|
+
</Field>
|
|
147
|
+
<Message message={{
|
|
148
|
+
heading: 'Current value inside PUI: ' + value,
|
|
149
|
+
visible: true
|
|
150
|
+
}} />
|
|
151
|
+
</>;
|
|
152
|
+
}`,...(Ve=(Ie=w.parameters)==null?void 0:Ie.docs)==null?void 0:Ve.source}}};var Ae,Se,we;j.parameters={...j.parameters,docs:{...(Ae=j.parameters)==null?void 0:Ae.docs,source:{originalSource:`() => {
|
|
153
|
+
const [value, setValue] = useState('123|%');
|
|
154
|
+
const [validation, setValidation] = useState<string | null>(null);
|
|
155
|
+
const predictedMessage = 'This should be visible when an error appears';
|
|
156
|
+
const handleValidation = (name: string, error: string | null) => {
|
|
157
|
+
setValidation(error);
|
|
158
|
+
return {
|
|
159
|
+
name,
|
|
160
|
+
error
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
return <>
|
|
164
|
+
<h4>3rd party validation message when inputting invalid value:</h4>
|
|
165
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
|
|
166
|
+
<br />
|
|
167
|
+
<Spacer />
|
|
168
|
+
<h4>Original validation message: </h4>
|
|
169
|
+
<Message message={{
|
|
170
|
+
heading: validation,
|
|
171
|
+
visible: true
|
|
172
|
+
}} />
|
|
173
|
+
</>;
|
|
174
|
+
}`,...(we=(Se=j.parameters)==null?void 0:Se.docs)==null?void 0:we.source}}};var je,ke,fe;k.parameters={...k.parameters,docs:{...(je=k.parameters)==null?void 0:je.docs,source:{originalSource:`() => {
|
|
175
|
+
const [value, setValue] = useState('123|m');
|
|
176
|
+
const [placeholder, setPlaceholder] = useState('');
|
|
177
|
+
const [initUnit, setInitUnit] = useState('km');
|
|
178
|
+
const setPlaceholderValue = () => {
|
|
179
|
+
setInitUnit('ft');
|
|
180
|
+
setPlaceholder('placeholder');
|
|
181
|
+
setValue('|m');
|
|
182
|
+
};
|
|
183
|
+
return <>
|
|
184
|
+
<h4>Empty value case:</h4>
|
|
185
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
|
|
186
|
+
<br />
|
|
187
|
+
<Spacer />
|
|
188
|
+
<Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
|
|
189
|
+
</>;
|
|
190
|
+
}`,...(fe=(ke=k.parameters)==null?void 0:ke.docs)==null?void 0:fe.source}}};var _e,Pe,Ee;f.parameters={...f.parameters,docs:{...(_e=f.parameters)==null?void 0:_e.docs,source:{originalSource:`() => {
|
|
191
|
+
const [value, setValue] = useState('123|m');
|
|
192
|
+
const [unit, setUnit] = useState('m');
|
|
193
|
+
return <>
|
|
194
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
195
|
+
<Spacer />
|
|
196
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
197
|
+
</>;
|
|
198
|
+
}`,...(Ee=(Pe=f.parameters)==null?void 0:Pe.docs)==null?void 0:Ee.source}}};const xa=["Default","InitUnit","NotKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","PredefinedOptionsMenu","AutomaticValues","ValidationCallback","AllowEmptyPUI","OnSwitchUnit"];export{k as AllowEmptyPUI,w as AutomaticValues,P as Default,c as Disabled,y as DisabledNoConversion,V as DisabledUnitWithUnitKey,I as DisabledUnitWithoutUnitKey,A as DisabledWithEnabledUnitMenu,U as Error,m as InitUnit,x as InternalValidationError,C as NoConversion,h as NotKnownUnit,f as OnSwitchUnit,S as PredefinedOptionsMenu,b as Small,j as ValidationCallback,v as Width,xa as __namedExportsOrder,Ua as default};
|