@oliasoft-open-source/react-ui-library 4.11.2-beta-1 → 4.11.2-beta-3
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/global.css +14 -15
- package/dist/index.js +20 -23
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-B-shawjD.js → Color-KGDBMAHA-BU5Cvr93.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-CcJF_zh-.js → DocsRenderer-PKQXORMH-giM41WN8.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-BPKMbG3k.js → accordion.stories-BlHfHegj.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-BG2zqnHT.js → buttons-and-links-BA3MNFjq.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-BbYDH_71.js → casing-loads.stories-Cl2tJipP.js} +1 -1
- package/dist/storybook/assets/{cell.stories-DC1Vo0__.js → cell.stories-rzJE_qJC.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-CM47_bXG.js → chunk-HLWAVYOI-Dvbg03uT.js} +1 -1
- package/dist/storybook/assets/{color-Cr-qn3FE.js → color-DIyQ13kP.js} +1 -1
- package/dist/storybook/assets/{footer.stories-DstLAiJp.js → footer.stories-C6M5S0UZ.js} +1 -1
- package/dist/storybook/assets/{form.stories-C8YjdHnX.js → form.stories-BNORsn6Z.js} +1 -1
- package/dist/storybook/assets/{formation.stories-Bt29JldX.js → formation.stories-1WX1Nu1P.js} +1 -1
- package/dist/storybook/assets/{iframe-CzFXqOr-.js → iframe-B0e2q2Zd.js} +2 -2
- package/dist/storybook/assets/{index-B5IpJ81Q.js → index-BXJ79Lvz.js} +1 -1
- package/dist/storybook/assets/{index-CR-eYtkm.js → index-BlyDuQBv.js} +4 -4
- package/dist/storybook/assets/{initialize-context-rEvM6bdZ.js → initialize-context-Y03pJPr5.js} +1 -1
- package/dist/storybook/assets/{input-validation-xYDgrqcS.js → input-validation-CLZKtfoW.js} +1 -1
- package/dist/storybook/assets/{inputs-BKaZW2Pv.js → inputs-DlW6Jeem.js} +1 -1
- package/dist/storybook/assets/{layout-forms-D2dIpGLv.js → layout-forms-C6ZH-nYk.js} +1 -1
- package/dist/storybook/assets/{layout-general-szYPo7Nk.js → layout-general-CWqOMwXA.js} +1 -1
- package/dist/storybook/assets/{number-input-CNnU6gOF.js → number-input-B3_gmeWr.js} +1 -1
- package/dist/storybook/assets/{number-input.stories-Bo26PJmJ.js → number-input.stories-epjUq9ve.js} +1 -1
- package/dist/storybook/assets/number-input.test-case.stories-DeEtalIU.js +95 -0
- package/dist/storybook/assets/{padding-and-spacing-rWdBf9ln.js → padding-and-spacing-CfnXk0Zn.js} +1 -1
- package/dist/storybook/assets/{preview-BpH8OxJT.js → preview-b9pkIJl_.js} +2 -2
- package/dist/storybook/assets/{preview-CVuoXXv0.js → preview-jWpKVqju.js} +1 -1
- package/dist/storybook/assets/{row.stories-DFKACj3C.js → row.stories-DRvH8Grn.js} +1 -1
- package/dist/storybook/assets/{slider-Dvdl3yGr.js → slider-CcpE4BLD.js} +4 -4
- package/dist/storybook/assets/{slider-Cf9tPrCy.css → slider-DnRddBCy.css} +1 -1
- package/dist/storybook/assets/slider.stories-BqlRLY_C.js +171 -0
- package/dist/storybook/assets/{table-CkNaVBsz.js → table-DoyDBG6l.js} +1 -1
- package/dist/storybook/assets/{table.stories-rxOOpdhc.js → table.stories-BgWKzIob.js} +1 -1
- package/dist/storybook/assets/{title.stories-CcqyFQEQ.js → title.stories-Rv6ZO_Wl.js} +1 -1
- package/dist/storybook/assets/{unit-input-Byipu-z0.js → unit-input-BXg4VphV.js} +1 -1
- package/dist/storybook/assets/{unit-input.stories-CChVbxmI.js → unit-input.stories-Btz2M_TP.js} +1 -1
- package/dist/storybook/assets/{unit-input.test-case.stories-BwKiucyc.js → unit-input.test-case.stories-CZD1jf36.js} +1 -1
- package/dist/storybook/assets/{unit-table.stories-DvpNdCS9.js → unit-table.stories-CISvZMxX.js} +1 -1
- package/dist/storybook/assets/{unit-table.test-case.stories-OSAkErH8.js → unit-table.test-case.stories-tEype9om.js} +1 -1
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/number-input.test-case.stories-BBKpBWfA.js +0 -92
- package/dist/storybook/assets/slider.stories-ai1lgqaI.js +0 -134
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import{j as n}from"./jsx-runtime-eps93zm2.js";import{S as A}from"./slider-CcpE4BLD.js";import{T as se}from"./text-B3-TSWok.js";import"./index-DhsZuJvc.js";import"./lodash-c4VUpsOs.js";import"./objectSpread2-DW4nTBoq.js";import"./index-Bk2sglWO.js";import"./inheritsLoose-DP0QEDDI.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./memoize-one.esm-CcMeOnPo.js";import"./index-BI4_Bp97.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./index-CEuq6vkz.js";const{useArgs:ae}=__STORYBOOK_MODULE_PREVIEW_API__,re=[{label:"S1...",tooltip:"S1 Production",value:20},{label:"S2...",tooltip:"S2 Cementing",value:40},{label:"S3...",tooltip:n.jsxs("span",{children:[n.jsx("strong",{children:"S3"})," Drilling"]}),value:60},{label:"S4...",tooltip:"S4 Shut in",value:80},{label:"S5...",tooltip:"S5 Circulate",value:100}],je={title:"Forms/Slider",component:A,args:{value:50,min:0,max:100,step:1,showTooltip:!1,label:""}},e=r=>{const[m,v]=ae(),b=x=>{v({value:x.target.value})};return n.jsx("div",{style:{paddingTop:40},children:n.jsx(A,{...r,onChange:b})})},h=e.bind({}),s=e.bind({});s.args={range:!0,value:[10,40]};const t=e.bind({});t.args={label:"Number of aardvarks"};const o=e.bind({});o.args={range:!0,value:[10,40],showArrows:!0};const l=r=>{const[{value:m},v]=ae(),b=x=>{v({value:x.target.value})};return n.jsx(n.Fragment,{children:n.jsx(A,{...r,label:n.jsxs("span",{children:["Fixed width label: ",n.jsx("strong",{children:m*Math.random()})]}),labelWidth:"400px",value:m,onChange:b})})},d=e.bind({});d.args={showTooltip:!0};const i=e.bind({});i.args={showTooltip:!0,tooltipFormatter:r=>n.jsx(se,{warning:!0,children:`${r} extra info lorem ipsum`})};const p=e.bind({});p.args={showArrows:!0};const g=e.bind({});g.args={marks:re};const a=e.bind({});a.args={small:!0};a.parameters={docs:{description:{story:"Reduces the vertical height of the `Slider` container to align with other `small` elements."}}};const u=e.bind({});u.args={disabled:!0};const c=e.bind({});c.args={marks:re,vertical:{enabled:!0,width:"100px",height:"400px"}};l.__docgenInfo={description:"",methods:[],displayName:"JSXLabel"};var S,C,y;h.parameters={...h.parameters,docs:{...(S=h.parameters)==null?void 0:S.docs,source:{originalSource:`args => {
|
|
2
|
+
const [_, updateArgs] = useArgs();
|
|
3
|
+
const handleChange = (evt: any) => {
|
|
4
|
+
updateArgs({
|
|
5
|
+
value: evt.target.value
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
return <div style={{
|
|
9
|
+
paddingTop: 40
|
|
10
|
+
}}>
|
|
11
|
+
<Slider
|
|
12
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
13
|
+
{...args} onChange={handleChange} />
|
|
14
|
+
</div>;
|
|
15
|
+
}`,...(y=(C=h.parameters)==null?void 0:C.docs)==null?void 0:y.source}}};var _,j,T;s.parameters={...s.parameters,docs:{...(_=s.parameters)==null?void 0:_.docs,source:{originalSource:`args => {
|
|
16
|
+
const [_, updateArgs] = useArgs();
|
|
17
|
+
const handleChange = (evt: any) => {
|
|
18
|
+
updateArgs({
|
|
19
|
+
value: evt.target.value
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return <div style={{
|
|
23
|
+
paddingTop: 40
|
|
24
|
+
}}>
|
|
25
|
+
<Slider
|
|
26
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
27
|
+
{...args} onChange={handleChange} />
|
|
28
|
+
</div>;
|
|
29
|
+
}`,...(T=(j=s.parameters)==null?void 0:j.docs)==null?void 0:T.source}}};var w,f,R;t.parameters={...t.parameters,docs:{...(w=t.parameters)==null?void 0:w.docs,source:{originalSource:`args => {
|
|
30
|
+
const [_, updateArgs] = useArgs();
|
|
31
|
+
const handleChange = (evt: any) => {
|
|
32
|
+
updateArgs({
|
|
33
|
+
value: evt.target.value
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return <div style={{
|
|
37
|
+
paddingTop: 40
|
|
38
|
+
}}>
|
|
39
|
+
<Slider
|
|
40
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
41
|
+
{...args} onChange={handleChange} />
|
|
42
|
+
</div>;
|
|
43
|
+
}`,...(R=(f=t.parameters)==null?void 0:f.docs)==null?void 0:R.source}}};var F,D,L;o.parameters={...o.parameters,docs:{...(F=o.parameters)==null?void 0:F.docs,source:{originalSource:`args => {
|
|
44
|
+
const [_, updateArgs] = useArgs();
|
|
45
|
+
const handleChange = (evt: any) => {
|
|
46
|
+
updateArgs({
|
|
47
|
+
value: evt.target.value
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
return <div style={{
|
|
51
|
+
paddingTop: 40
|
|
52
|
+
}}>
|
|
53
|
+
<Slider
|
|
54
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
55
|
+
{...args} onChange={handleChange} />
|
|
56
|
+
</div>;
|
|
57
|
+
}`,...(L=(D=o.parameters)==null?void 0:D.docs)==null?void 0:L.source}}};var E,M,O;l.parameters={...l.parameters,docs:{...(E=l.parameters)==null?void 0:E.docs,source:{originalSource:`args => {
|
|
58
|
+
const [{
|
|
59
|
+
value
|
|
60
|
+
}, updateArgs] = useArgs();
|
|
61
|
+
const handleChange = (evt: any) => {
|
|
62
|
+
updateArgs({
|
|
63
|
+
value: evt.target.value
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return <>
|
|
67
|
+
<Slider
|
|
68
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
69
|
+
{...args} label={<span>
|
|
70
|
+
Fixed width label: <strong>{value * Math.random()}</strong>
|
|
71
|
+
</span>} labelWidth="400px" value={value} onChange={handleChange} />
|
|
72
|
+
</>;
|
|
73
|
+
}`,...(O=(M=l.parameters)==null?void 0:M.docs)==null?void 0:O.source}}};var W,k,I;d.parameters={...d.parameters,docs:{...(W=d.parameters)==null?void 0:W.docs,source:{originalSource:`args => {
|
|
74
|
+
const [_, updateArgs] = useArgs();
|
|
75
|
+
const handleChange = (evt: any) => {
|
|
76
|
+
updateArgs({
|
|
77
|
+
value: evt.target.value
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return <div style={{
|
|
81
|
+
paddingTop: 40
|
|
82
|
+
}}>
|
|
83
|
+
<Slider
|
|
84
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
85
|
+
{...args} onChange={handleChange} />
|
|
86
|
+
</div>;
|
|
87
|
+
}`,...(I=(k=d.parameters)==null?void 0:k.docs)==null?void 0:I.source}}};var J,P,V;i.parameters={...i.parameters,docs:{...(J=i.parameters)==null?void 0:J.docs,source:{originalSource:`args => {
|
|
88
|
+
const [_, updateArgs] = useArgs();
|
|
89
|
+
const handleChange = (evt: any) => {
|
|
90
|
+
updateArgs({
|
|
91
|
+
value: evt.target.value
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return <div style={{
|
|
95
|
+
paddingTop: 40
|
|
96
|
+
}}>
|
|
97
|
+
<Slider
|
|
98
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
99
|
+
{...args} onChange={handleChange} />
|
|
100
|
+
</div>;
|
|
101
|
+
}`,...(V=(P=i.parameters)==null?void 0:P.docs)==null?void 0:V.source}}};var X,N,B;p.parameters={...p.parameters,docs:{...(X=p.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
|
|
102
|
+
const [_, updateArgs] = useArgs();
|
|
103
|
+
const handleChange = (evt: any) => {
|
|
104
|
+
updateArgs({
|
|
105
|
+
value: evt.target.value
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return <div style={{
|
|
109
|
+
paddingTop: 40
|
|
110
|
+
}}>
|
|
111
|
+
<Slider
|
|
112
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
113
|
+
{...args} onChange={handleChange} />
|
|
114
|
+
</div>;
|
|
115
|
+
}`,...(B=(N=p.parameters)==null?void 0:N.docs)==null?void 0:B.source}}};var K,U,Y;g.parameters={...g.parameters,docs:{...(K=g.parameters)==null?void 0:K.docs,source:{originalSource:`args => {
|
|
116
|
+
const [_, updateArgs] = useArgs();
|
|
117
|
+
const handleChange = (evt: any) => {
|
|
118
|
+
updateArgs({
|
|
119
|
+
value: evt.target.value
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return <div style={{
|
|
123
|
+
paddingTop: 40
|
|
124
|
+
}}>
|
|
125
|
+
<Slider
|
|
126
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
127
|
+
{...args} onChange={handleChange} />
|
|
128
|
+
</div>;
|
|
129
|
+
}`,...(Y=(U=g.parameters)==null?void 0:U.docs)==null?void 0:Y.source}}};var $,q,z;a.parameters={...a.parameters,docs:{...($=a.parameters)==null?void 0:$.docs,source:{originalSource:`args => {
|
|
130
|
+
const [_, updateArgs] = useArgs();
|
|
131
|
+
const handleChange = (evt: any) => {
|
|
132
|
+
updateArgs({
|
|
133
|
+
value: evt.target.value
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
return <div style={{
|
|
137
|
+
paddingTop: 40
|
|
138
|
+
}}>
|
|
139
|
+
<Slider
|
|
140
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
141
|
+
{...args} onChange={handleChange} />
|
|
142
|
+
</div>;
|
|
143
|
+
}`,...(z=(q=a.parameters)==null?void 0:q.docs)==null?void 0:z.source}}};var G,H,Q;u.parameters={...u.parameters,docs:{...(G=u.parameters)==null?void 0:G.docs,source:{originalSource:`args => {
|
|
144
|
+
const [_, updateArgs] = useArgs();
|
|
145
|
+
const handleChange = (evt: any) => {
|
|
146
|
+
updateArgs({
|
|
147
|
+
value: evt.target.value
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
return <div style={{
|
|
151
|
+
paddingTop: 40
|
|
152
|
+
}}>
|
|
153
|
+
<Slider
|
|
154
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
155
|
+
{...args} onChange={handleChange} />
|
|
156
|
+
</div>;
|
|
157
|
+
}`,...(Q=(H=u.parameters)==null?void 0:H.docs)==null?void 0:Q.source}}};var Z,ee,ne;c.parameters={...c.parameters,docs:{...(Z=c.parameters)==null?void 0:Z.docs,source:{originalSource:`args => {
|
|
158
|
+
const [_, updateArgs] = useArgs();
|
|
159
|
+
const handleChange = (evt: any) => {
|
|
160
|
+
updateArgs({
|
|
161
|
+
value: evt.target.value
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
return <div style={{
|
|
165
|
+
paddingTop: 40
|
|
166
|
+
}}>
|
|
167
|
+
<Slider
|
|
168
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
169
|
+
{...args} onChange={handleChange} />
|
|
170
|
+
</div>;
|
|
171
|
+
}`,...(ne=(ee=c.parameters)==null?void 0:ee.docs)==null?void 0:ne.source}}};const Te=["Default","Range","Label","RangeWithArrows","JSXLabel","Tooltip","FormattedTooltip","Arrows","Marks","Small","Disabled","Vertical"];export{p as Arrows,h as Default,u as Disabled,i as FormattedTooltip,l as JSXLabel,t as Label,g as Marks,s as Range,o as RangeWithArrows,a as Small,d as Tooltip,c as Vertical,Te as __namedExportsOrder,je as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-DazXb-ul.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Bax0KeqM.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-CR1nxnnq.js";import{A as h,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-Db9WkmPP.js";import{N as Me}from"./number-input-CNnU6gOF.js";import{S as Ge}from"./select-Cwks-WA0.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as ie}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-Dvdl3yGr.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-C_2P8LFJ.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_1dg3w_1",Ye="_inputHover_1dg3w_13",Je="_inputFocus_1dg3w_18",Qe="_inputError_1dg3w_25",Ze="_inputWarning_1dg3w_26",en="_inputDisabled_1dg3w_61",nn="_hideScrollbars_1dg3w_67",tn="_wrapper_1dg3w_85",rn="_bordered_1dg3w_93",an="_scroll_1dg3w_98",on="_table_1dg3w_108",sn="_striped_1dg3w_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:i})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:dn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":i,children:e})}):null,s()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:i})=>{const a=r&&r.length,o=i!=null,s=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return u>I}return!1};return a||o||s()?n.jsxs("div",{className:J.footer,children:[o?n.jsx("div",{className:J.section,children:n.jsx("div",{children:i})}):null,a||s()?n.jsxs("div",{className:J.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,i)=>{const a=i.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:i}=e,a=Math.ceil(window.innerHeight/30),[o,s]=i?S.useState(a):[r.length,null],[c,d]=i?S.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:i?n.jsx(Le,{dataLength:Math.min(r.length,o+a),next:p,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const gn="_clickableRow_m64j5_1",In="_hoverableRow_m64j5_4",yn="_rowActive_m64j5_4",Cn="_expandableRow_m64j5_8",bn="_flush_m64j5_8",hn="_dragIconCell_m64j5_34",fn="_dragIcon_m64j5_34",R={clickableRow:gn,hoverableRow:In,rowActive:yn,expandableRow:Cn,flush:bn,dragIconCell:hn,dragIcon:fn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(R.expandableRow,r?R.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:i,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:i){case h.LEFT:return r?h.LEFT:t.leftAligned;case h.RIGHT:return r?h.RIGHT:t.rightAligned;case h.CENTER:return r?h.CENTER:t.centerAligned;default:return r?h.LEFT:t.leftAligned}},_n=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const i=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return i&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_ie6ng_1",xn="_inputHover_ie6ng_13",Tn="_inputFocus_ie6ng_18",vn="_inputError_ie6ng_25",An="_inputWarning_ie6ng_26",Rn="_inputDisabled_ie6ng_61",jn="_hideScrollbars_ie6ng_67",kn="_cell_ie6ng_77",qn="_disabledLink_ie6ng_87",Nn="_inputWrapper_ie6ng_91",Sn="_numberInputWrapper_ie6ng_106",En="_breakWord_ie6ng_113",Hn="_inputCell_ie6ng_116",Ln="_sliderCell_ie6ng_119",Wn="_staticCell_ie6ng_123",Fn="_staticCellContent_ie6ng_126",Pn="_unit_ie6ng_148",Dn="_sortingCell_ie6ng_151",On="_sortingCellIcon_ie6ng_162",Bn="_icon_ie6ng_173",$n="_checkBoxCell_ie6ng_177",Mn="_iconCellWrapper_ie6ng_181",Gn="_actionsCell_ie6ng_185",Vn="_rightAligned_ie6ng_193",Un="_centerAligned_ie6ng_199",zn="_leftAligned_ie6ng_205",Kn="_popover_ie6ng_208",Xn="_disabledPointerEvents_ie6ng_211",l={inputInTable:wn,inputHover:xn,inputFocus:Tn,inputError:vn,inputWarning:An,inputDisabled:Rn,hideScrollbars:jn,cell:kn,disabledLink:qn,inputWrapper:Nn,numberInputWrapper:Sn,breakWord:En,inputCell:Hn,sliderCell:Ln,staticCell:Wn,staticCellContent:Fn,unit:Pn,sortingCell:Dn,sortingCellIcon:On,icon:Bn,checkBoxCell:$n,iconCellWrapper:Mn,actionsCell:Gn,rightAligned:Vn,centerAligned:Un,leftAligned:zn,popover:Kn,disabledPointerEvents:Xn},te=({cell:e,columnAlignment:t,testId:r,type:i})=>n.jsx($e,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:i});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var i;return(i=e.onChange)==null?void 0:i.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableCosmeticRounding:e.enableCosmeticRounding,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:i=>{var a;return(a=e.onChange)==null?void 0:a.call(e,i)},onCreate:e.onCreate?i=>e.onCreate&&e.onCreate(i):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:T(l.inputWrapper,e.type==="NumberInput"?l.numberInputWrapper:""),children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});xe.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:i,warning:a,tooltip:o,maxTooltipWidth:s}=e,c=d=>M(d);return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:c(o)||c(i)||c(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:l.staticCellContent,"data-error":i||null,"data-warning":a||null,children:n.jsx("a",{className:T((e.disabled||r)&&l.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ae=({cell:e})=>n.jsx("div",{className:l.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});Ae.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const Re=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:l.iconCellWrapper,children:n.jsx(ie,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};Re.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const je=({cell:e})=>n.jsx(ae,{actions:e.actions});je.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:i}=e;return t?n.jsxs("span",{className:l.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),i&&r?n.jsx("sup",{children:i}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const oe=({cell:e,isHeader:t,testId:r})=>{const{error:i,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:c,onSort:d,type:p}=e,u=n.jsxs("div",{className:T(l.staticCellContent,p==="Unit"?l.unit:""),onClick:c?y=>d&&d(y):()=>{},"data-error":i||null,"data-warning":a||null,"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:o&&M(o)||i&&M(i)||a&&M(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:u})})};oe.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Ke,{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:l.popover,children:n.jsx(oe,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:i})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(xe,{cell:e,columnAlignment:r,testId:i});case"Link":return n.jsx(Te,{cell:e,testId:i});case"CheckBox":return n.jsx(ve,{cell:e,testId:i});case"Slider":return n.jsx(Ae,{cell:e});case"Icon":return n.jsx(Re,{cell:e});case"Actions":return n.jsx(je,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(oe,{cell:e,isHeader:t,testId:i})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var j=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(j||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:i=h.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:p,width:u}=e,y=S.useRef(null),I={bodyAlignment:i,headerAlignment:r,isHeader:t},W=he(I,l),f=he(I,l,!0),F=e.type===j.INPUT||e.type===j.NUMBER_INPUT||e.type===j.SELECT||e.type===j.POPOVER?l.inputCell:e.type===j.SLIDER?l.sliderCell:e.type===j.CHECKBOX?l.checkBoxCell:e.type===j.ACTIONS?l.actionsCell:l.staticCell,v=T(l.cell,F,e.hasSort?l.sortingCell:null,W,e.breakWord?l.breakWord:""),E=u??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,_={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:y,className:v,style:_,colSpan:d,rowSpan:p,children:n.jsx(Ee,{cell:e,columnAlignment:f??h.RIGHT,isHeader:t,testId:s})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
|
|
1
|
+
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-DazXb-ul.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Bax0KeqM.js";import{H as Oe}from"./heading-CRNoBc7q.js";import{P as Be}from"./pagination-CR1nxnnq.js";import{A as h,I as $}from"./common-types-Sih75Sav.js";import{I as $e}from"./input-Db9WkmPP.js";import{N as Me}from"./number-input-B3_gmeWr.js";import{S as Ge}from"./select-Cwks-WA0.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as ie}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-DPLaOkRR.js";import{S as ze}from"./slider-CcpE4BLD.js";import{I as G}from"./icon-BSFY3vDO.js";import{P as Ke}from"./popover-C_2P8LFJ.js";import{H as fe}from"./help-icon-Buhx5nl6.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_1dg3w_1",Ye="_inputHover_1dg3w_13",Je="_inputFocus_1dg3w_18",Qe="_inputError_1dg3w_25",Ze="_inputWarning_1dg3w_26",en="_inputDisabled_1dg3w_61",nn="_hideScrollbars_1dg3w_67",tn="_wrapper_1dg3w_85",rn="_bordered_1dg3w_93",an="_scroll_1dg3w_98",on="_table_1dg3w_108",sn="_striped_1dg3w_188",L={inputInTable:Xe,inputHover:Ye,inputFocus:Je,inputError:Qe,inputWarning:Ze,inputDisabled:en,hideScrollbars:nn,wrapper:tn,bordered:rn,scroll:an,table:on,striped:sn},ln="_title_zn5s7_1",dn={title:ln},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:i})=>{const a=e!==null,o=t!==null;if(!a&&!o)return null;const s=()=>{if(!o)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:dn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":i,children:e})}):null,s()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const un="_footer_4sumy_1",cn="_section_4sumy_7",J={footer:un,section:cn},Z=({colSpan:e,pagination:t,actions:r,content:i})=>{const a=r&&r.length,o=i!=null,s=()=>{var d,p;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((p=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:p.value);return u>I}return!1};return a||o||s()?n.jsxs("div",{className:J.footer,children:[o?n.jsx("div",{className:J.section,children:n.jsx("div",{children:i})}):null,a||s()?n.jsxs("div",{className:J.section,children:[s()?n.jsx(Be,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,i)=>{const a=i.cells.map(o=>o.colSpan?o.colSpan:1).reduce((o,s)=>o+s,0);return r.concat(a)},[]));return isNaN(t)?0:t},pn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),mn=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:i}=e,a=Math.ceil(window.innerHeight/30),[o,s]=i?S.useState(a):[r.length,null],[c,d]=i?S.useState(o<r.length):[!1,null],p=()=>{if(o>=r.length&&d){d(!1);return}s&&s(o+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:i?n.jsx(Le,{dataLength:Math.min(r.length,o+a),next:p,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:o})}):t({visibleRows:o})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const gn="_clickableRow_m64j5_1",In="_hoverableRow_m64j5_4",yn="_rowActive_m64j5_4",Cn="_expandableRow_m64j5_8",bn="_flush_m64j5_8",hn="_dragIconCell_m64j5_34",fn="_dragIcon_m64j5_34",R={clickableRow:gn,hoverableRow:In,rowActive:yn,expandableRow:Cn,flush:bn,dragIconCell:hn,dragIcon:fn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(R.expandableRow,r?R.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:i,headerAlignment:a,isHeader:o}=e;switch(o&&a?a:i){case h.LEFT:return r?h.LEFT:t.leftAligned;case h.RIGHT:return r?h.RIGHT:t.rightAligned;case h.CENTER:return r?h.CENTER:t.centerAligned;default:return r?h.LEFT:t.leftAligned}},_n=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const i=e.every(o=>Array.isArray(o)),a=e.every(o=>typeof o=="string");return i&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},wn="_inputInTable_ie6ng_1",xn="_inputHover_ie6ng_13",Tn="_inputFocus_ie6ng_18",vn="_inputError_ie6ng_25",An="_inputWarning_ie6ng_26",Rn="_inputDisabled_ie6ng_61",jn="_hideScrollbars_ie6ng_67",kn="_cell_ie6ng_77",qn="_disabledLink_ie6ng_87",Nn="_inputWrapper_ie6ng_91",Sn="_numberInputWrapper_ie6ng_106",En="_breakWord_ie6ng_113",Hn="_inputCell_ie6ng_116",Ln="_sliderCell_ie6ng_119",Wn="_staticCell_ie6ng_123",Fn="_staticCellContent_ie6ng_126",Pn="_unit_ie6ng_148",Dn="_sortingCell_ie6ng_151",On="_sortingCellIcon_ie6ng_162",Bn="_icon_ie6ng_173",$n="_checkBoxCell_ie6ng_177",Mn="_iconCellWrapper_ie6ng_181",Gn="_actionsCell_ie6ng_185",Vn="_rightAligned_ie6ng_193",Un="_centerAligned_ie6ng_199",zn="_leftAligned_ie6ng_205",Kn="_popover_ie6ng_208",Xn="_disabledPointerEvents_ie6ng_211",l={inputInTable:wn,inputHover:xn,inputFocus:Tn,inputError:vn,inputWarning:An,inputDisabled:Rn,hideScrollbars:jn,cell:kn,disabledLink:qn,inputWrapper:Nn,numberInputWrapper:Sn,breakWord:En,inputCell:Hn,sliderCell:Ln,staticCell:Wn,staticCellContent:Fn,unit:Pn,sortingCell:Dn,sortingCellIcon:On,icon:Bn,checkBoxCell:$n,iconCellWrapper:Mn,actionsCell:Gn,rightAligned:Vn,centerAligned:Un,leftAligned:zn,popover:Kn,disabledPointerEvents:Xn},te=({cell:e,columnAlignment:t,testId:r,type:i})=>n.jsx($e,{name:e.name,value:e.value,onChange:a=>{var o;return(o=e.onChange)==null?void 0:o.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var o;return(o=e.onPaste)==null?void 0:o.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:i});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var i;return(i=e.onChange)==null?void 0:i.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableCosmeticRounding:e.enableCosmeticRounding,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:i=>{var a;return(a=e.onChange)==null?void 0:a.call(e,i)},onCreate:e.onCreate?i=>e.onCreate&&e.onCreate(i):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===h.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:T(l.inputWrapper,e.type==="NumberInput"?l.numberInputWrapper:""),children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});xe.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:i,warning:a,tooltip:o,maxTooltipWidth:s}=e,c=d=>M(d);return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:c(o)||c(i)||c(a)||!1,maxWidth:s,placement:"bottom-center",children:n.jsx("div",{className:l.staticCellContent,"data-error":i||null,"data-warning":a||null,children:n.jsx("a",{className:T((e.disabled||r)&&l.disabledLink),onClick:e.disabled||r?void 0:d=>{var p;d.stopPropagation(),(p=e.onClick)==null||p.call(e,d)},"data-testid":t,children:e.value})})})})};Te.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});ve.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ae=({cell:e})=>n.jsx("div",{className:l.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});Ae.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const Re=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:l.iconCellWrapper,children:n.jsx(ie,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};Re.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const je=({cell:e})=>n.jsx(ae,{actions:e.actions});je.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const ke=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};ke.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:l.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:$.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:i}=e;return t?n.jsxs("span",{className:l.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:$.SORT_DESCENDING})}),i&&r?n.jsx("sup",{children:i}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const oe=({cell:e,isHeader:t,testId:r})=>{const{error:i,warning:a,tooltip:o,maxTooltipWidth:s,hasSort:c,onSort:d,type:p}=e,u=n.jsxs("div",{className:T(l.staticCellContent,p==="Unit"?l.unit:""),onClick:c?y=>d&&d(y):()=>{},"data-error":i||null,"data-warning":a||null,"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(ke,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:l.inputWrapper,children:n.jsx(ie,{error:!!i,warning:!!a,text:o||i||a,enabled:o&&M(o)||i&&M(i)||a&&M(a)||!1,maxWidth:s,display:"block",placement:"bottom-center",children:u})})};oe.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o}=e;return n.jsx(Ke,{content:r,fullWidth:i,closeOnOutsideClick:a,disabled:o,children:n.jsx("div",{className:l.popover,children:n.jsx(oe,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:i})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(xe,{cell:e,columnAlignment:r,testId:i});case"Link":return n.jsx(Te,{cell:e,testId:i});case"CheckBox":return n.jsx(ve,{cell:e,testId:i});case"Slider":return n.jsx(Ae,{cell:e});case"Icon":return n.jsx(Re,{cell:e});case"Actions":return n.jsx(je,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(oe,{cell:e,isHeader:t,testId:i})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var j=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(j||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:i=h.LEFT,width:a,snapshot:o,testId:s})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:p,width:u}=e,y=S.useRef(null),I={bodyAlignment:i,headerAlignment:r,isHeader:t},W=he(I,l),f=he(I,l,!0),F=e.type===j.INPUT||e.type===j.NUMBER_INPUT||e.type===j.SELECT||e.type===j.POPOVER?l.inputCell:e.type===j.SLIDER?l.sliderCell:e.type===j.CHECKBOX?l.checkBoxCell:e.type===j.ACTIONS?l.actionsCell:l.staticCell,v=T(l.cell,F,e.hasSort?l.sortingCell:null,W,e.breakWord?l.breakWord:""),E=u??a??((o==null?void 0:o.isDragging)&&y.current&&y.current.offsetWidth)??void 0,_={width:E,minWidth:E,...c},A=t?"th":"td";return n.jsx(A,{ref:y,className:v,style:_,colSpan:d,rowSpan:p,children:n.jsx(Ee,{cell:e,columnAlignment:f??h.RIGHT,isHeader:t,testId:s})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
|
|
2
2
|
| IStaticCell
|
|
3
3
|
| ISelectCell
|
|
4
4
|
| IHelpIconCell
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-CkNaVBsz.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-Db9WkmPP.js";import{F as oe}from"./field-HrLaMLbx.js";import{H as un}from"./heading-CRNoBc7q.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-C7mC5R8Q.js";import"./styled-components.browser.esm-BQ9GQzDc.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"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.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"./pagination-CR1nxnnq.js";import"./select-Cwks-WA0.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CNnU6gOF.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-Dvdl3yGr.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./label-CqmyC9he.js";import"./flex-EllkLxgO.js";const ht={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
|
|
1
|
+
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-DoyDBG6l.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-Db9WkmPP.js";import{F as oe}from"./field-HrLaMLbx.js";import{H as un}from"./heading-CRNoBc7q.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-C7mC5R8Q.js";import"./styled-components.browser.esm-BQ9GQzDc.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"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.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"./pagination-CR1nxnnq.js";import"./select-Cwks-WA0.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-B3_gmeWr.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./help-icon-Buhx5nl6.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";import"./label-CqmyC9he.js";import"./flex-EllkLxgO.js";const ht={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
|
|
2
2
|
return <Table
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -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-DoyDBG6l.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-C7mC5R8Q.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-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.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-CR1nxnnq.js";import"./select-Cwks-WA0.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-Db9WkmPP.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-B3_gmeWr.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.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} />;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as q}from"./index-DhsZuJvc.js";import{d as a}from"./index-C0x1JmaP.js";import{c as Ce}from"./index-Bk2sglWO.js";import{c as ae,i as Ne,a as Fe,g as De,u as Me,b as Pe}from"./initialize-context-
|
|
1
|
+
import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as q}from"./index-DhsZuJvc.js";import{d as a}from"./index-C0x1JmaP.js";import{c as Ce}from"./index-Bk2sglWO.js";import{c as ae,i as Ne,a as Fe,g as De,u as Me,b as Pe}from"./initialize-context-Y03pJPr5.js";import{M as Y}from"./actions-Bax0KeqM.js";import{I as xe}from"./input-group-addon-D68iUKV2.js";import{B as je}from"./button-Cbv7WK6k.js";import{T as Ae}from"./tooltip-1V7clEnw.js";import{I as Se}from"./input-group-BaRSJAEN.js";import{S as Oe}from"./spacer-BWoNR27H.js";import{T as Le}from"./text-B3-TSWok.js";import{M as Z}from"./types-BmbYqTX_.js";import{l as v}from"./lodash-c4VUpsOs.js";import{N as We,r as Re}from"./number-input-B3_gmeWr.js";const He=()=>{const e=q.useRef(null);return q.useLayoutEffect(()=>{e.current&&(e.current(),e.current=null)}),m=>{e.current=m}};var d=(e=>(e.CUSTOM="custom",e.PREDEFINED="predefined",e))(d||{});const _e=e=>e?!!a.getUnit(e):!1,w=({value:e="",toUnit:f,unitkey:m,defaultFromUnit:P,doNotConvertValue:I})=>{const x=_e(e)||a.isValueWithUnit(e),y=a.getValue(e);return Ne(y)?{value:y}:x?ae({value:e,unitkey:m,toUnit:f,fromUnit:P,doNotConvertValue:I,exactPrecision:!0}):{value:e}},ee=e=>v.isObject(e)&&!v.isArray(e)&&!v.isFunction(e)?v.get(e,"fieldName",""):typeof e=="string"?e:"",te=(e="")=>{var f;return(f=a.KNOWN_UNITS)==null?void 0:f.includes(e)},ke=(e,f)=>{const m=a.getUnit(e||"");return te(f)&&te(m)},$e="_predefinedMenuActive_ye9w9_1",Be="_inputWrapper_ye9w9_4",ne={predefinedMenuActive:$e,inputWrapper:Be},Ke=({name:e,placeholder:f="",disabled:m=!1,disabledUnit:P=!1,error:I=null,left:x=!1,small:y=!1,width:R="100%",value:l,unitkey:u="",initUnit:ie,noConversion:re=!1,onChange:j=v.noop,onClick:Ge=v.noop,onFocus:se=v.noop,onSwitchUnit:H=v.noop,unitTemplate:_,doNotConvertValue:b=!1,testId:V,warning:k=null,predefinedOptions:g,initialPredefinedOption:le=!1,shouldLinkAutomaticly:$=!0,selectedPredefinedOptionKey:B,validationCallback:ue=()=>({name:"",error:null}),disabledValidation:oe=!1,allowEmpty:de=!1,autoValue:U,convertBackToStorageUnit:pe=!1,enableCosmeticRounding:K=!0,enableDisplayRounding:me=!1})=>{const h=Fe(),ce=He();typeof l=="number"&&(l=`${l}`);const[G="",T=""]=l!==void 0?a.split(l):[],Q=U?a.getUnit(U):"",z=q.useMemo(()=>De(u,_||(h==null?void 0:h.unitTemplate)),[u,_,h==null?void 0:h.unitTemplate]),fe=ke(l,z),c=ie||z||T,ge=Me(c),{value:J}=w({value:l,toUnit:c,unitkey:u,defaultFromUnit:T,doNotConvertValue:b}),{value:X}=w({value:U,toUnit:c,unitkey:u,defaultFromUnit:Q,doNotConvertValue:b}),ve=J!==""?{value:J,unit:c}:X!==""?{value:X,unit:c}:{value:G,unit:T},[i,A]=q.useState(ve),ye=de||(i==null?void 0:i.value)===void 0,[E,S]=q.useState(le?d.PREDEFINED:d.CUSTOM),O=G===""&&U,Ue=!!(oe||U),C=g&&g.find(t=>{if(!(t!=null&&t.value))return;if(B)return B===t.valueKey;const n=a.isValueWithUnit(t.value)?a.getUnit(t.value):"",{value:r=l}=ae({value:String(l),unitkey:u,toUnit:n});return a.withUnit(r,n)===t.value}),Te=()=>{const t=O?U:l??"",n=i.unit;if(Pe({value:t,unitkey:u,toUnit:n})){if(u)try{let s=a.altUnitsList(t,u);return a.getValue(t)===""?s.map(p=>["",p[1]]):s}catch{return null}}else{let s=a.getAltUnitsListByQuantity(u);return s==null?void 0:s.map(p=>["",p==null?void 0:p.unit])}},Ee=t=>{const n=ee(e),r=t.target,{value:s,selectionStart:p}=r,M=a.withUnit(s,(i==null?void 0:i.unit)||""),W=pe?a.withUnit(a.convertAndGetValue(M,T),T):M;j({target:{value:W,name:n}});const[qe,Ie]=a.split(M);A({value:qe,unit:Ie}),ce(()=>{r.selectionStart=p,r.selectionEnd=p})},be=(t,n)=>{n===i.unit||isNaN(Number(t))||(A({value:t,unit:n}),H&&H(n))};q.useEffect(()=>{if(c){let t,n="";if(ge!==c){const{value:r}=w({value:l,toUnit:c,unitkey:u,defaultFromUnit:T,doNotConvertValue:b});t=r,n=c}else if(a.withUnit(i.value,i.unit)!==l){const{value:r}=w({value:l,toUnit:i.unit,unitkey:u,defaultFromUnit:T,doNotConvertValue:b});t=r,n=i.unit}t!==void 0&&A({value:t,unit:n}),g&&S(C&&$?d.PREDEFINED:d.CUSTOM)}},[c,l,I,$]);const N=Te(),F=a.label(i.unit)||i.unit||"",Ve=re||!N||N&&N.length===1,L=ee(e);let D;const he=t=>{const n=t!=null&&t.value?t.value:"",[r="",s=""]=a.isValueWithUnit(n)?a.split(n):[n];return{type:Z.OPTION,inline:!0,onClick:()=>{a.validateNumber(r).valid&&!m&&(S(d.PREDEFINED),j({target:{value:n,name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||"",predefinedSelected:!0,predefinedOption:t}}))},label:o.jsxs(o.Fragment,{children:[o.jsx(Le,{children:t.label}),o.jsx(Oe,{width:"20px",height:"0"})]}),description:a.isValueWithUnit(n)?`${r} ${s}`:n,selected:C===t&&E===d.PREDEFINED}};if(D=[{type:Z.OPTION,inline:!0,onClick:()=>{E!==d.CUSTOM&&!m&&j({target:{value:a.withUnit(i.value,i.unit),name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||""}})},label:"Custom",selected:E===d.CUSTOM}],g!=null&&g.length){const t=g.map(he);D=[...D,...t]}const we=t=>{if(O){const{value:n}=w({value:U,toUnit:i.unit,unitkey:u,defaultFromUnit:Q,doNotConvertValue:b});return n}else if(a.isValueWithUnit(t)){const n=a.getUnit(t),{value:r}=w({value:t,toUnit:i.unit,unitkey:u,defaultFromUnit:n,doNotConvertValue:b});return r}return t};return o.jsx("div",{className:E===d.PREDEFINED?Ce(ne.predefinedMenuActive):"",children:o.jsxs(Se,{small:y,width:R,children:[g&&o.jsx(Ae,{text:E===d.PREDEFINED?C==null?void 0:C.label:"",children:o.jsx(Y,{maxHeight:380,groupOrder:"first",testId:V&&`${V}-predefined-menu`,disabled:m,menu:{colored:!0,trigger:"Component",component:o.jsx(je,{groupOrder:"first",active:E===d.PREDEFINED,icon:E===d.PREDEFINED?"link":"unlink"}),small:y,sections:D}})}),o.jsx("div",{className:ne.inputWrapper,children:o.jsx(We,{name:L,testId:V,disabled:m,placeholder:we(f),value:i.value,onChange:Ee,onFocus:se,error:I===null?void 0:I,warning:k===null?void 0:k,left:x,allowEmpty:ye,validationCallback:(t,n)=>ue(L,n),enableCosmeticRounding:K,enableDisplayRounding:me,groupOrder:g?"middle":"first",disableInternalErrorValidationMessages:Ue,small:y},L)}),F&&(Ve||!fe?o.jsx(xe,{groupOrder:"last",children:F}):o.jsx(Y,{maxHeight:380,groupOrder:"last",disabled:P,testId:V&&`${V}-menu`,menu:{label:F,trigger:"DropDownButton",small:y,sections:N.map(([t,n,r])=>{const s=r||n||"",p=a.isValidNum(t)?t:"";return{type:"Option",label:K?Re(p):p,inline:!0,onClick:W=>{W.stopPropagation(),be(O?"":t,n)},description:s,selected:s===F,testId:`${V}-unit-${s}`}})}}))]})})};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
2
|
target:
|
|
3
3
|
| T
|
|
4
4
|
| { name: string; value: any; label?: string; files?: FileList | null };
|
package/dist/storybook/assets/{unit-input.stories-CChVbxmI.js → unit-input.stories-Btz2M_TP.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-BXg4VphV.js";import{B as p}from"./button-Cbv7WK6k.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-BRyKdRaX.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./index-Bk2sglWO.js";import"./initialize-context-Y03pJPr5.js";import"./number-input-B3_gmeWr.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./text-B3-TSWok.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
2
|
const [_, updateArgs] = useArgs();
|
|
3
3
|
const handleChange = (evt: any) => {
|
|
4
4
|
updateArgs({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as b}from"./index-C0x1JmaP.js";import{w as f,u as l,e as r,f as V,a as D}from"./index-DMAnyMX5.js";import{U as u}from"./unit-input-Byipu-z0.js";import{B as o}from"./button-Cbv7WK6k.js";import{S as g}from"./spacer-BWoNR27H.js";import{D as fe}from"./divider-DY9nJ_7N.js";import{R as Ce,C as _}from"./row-Bmiy2Lh0.js";import{F as U}from"./field-HrLaMLbx.js";import{M as pe}from"./message-BRyKdRaX.js";import{G as ge}from"./grid-DRkC-bt8.js";import{C as v}from"./card-EcjmryU9.js";import{H as y}from"./heading-CRNoBc7q.js";import{T as N}from"./toggle-BbFVf61v.js";import{T as q}from"./text-B3-TSWok.js";import{S as xe}from"./select-Cwks-WA0.js";import{I as he}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./initialize-context-rEvM6bdZ.js";import"./number-input-CNnU6gOF.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-CJed_LLR.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const ht={title:"Forms/UnitInput/Test Cases",component:u,tags:["!autodocs"]},C=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),placeholder:"Type a value...",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};C.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const x=()=>{const[i,a]=d.useState("|m");return e.jsx(u,{name:"example-ft",onChange:t=>a(t.target.value),placeholder:"7|ft",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId-ft"})};x.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Handle input with unit only",async()=>{const n=t.getByTestId("testId-ft");await r(t.getByDisplayValue("")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Clear input and check placeholder",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await r(n).toHaveAttribute("placeholder","2.13")}),await a("Type a correct numeric value and ensure no error",async()=>{const n=t.getByTestId("testId-ft");await l.type(n,"123"),await r(t.getByDisplayValue("123")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Remove value, type incorrect value and check for error",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await l.type(n,"123abc"),await r(t.getByDisplayValue("123abc")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const T=i=>{const[a,t]=d.useState("123|m"),[s,n]=d.useState("223|m"),[c,h]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Change initUnit",onClick:()=>h(c==="m"?"ft":"m")}),e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,initUnit:c,onSwitchUnit:h}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,initUnit:c,onSwitchUnit:h}),e.jsx(fe,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,onSwitchUnit:h}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,onSwitchUnit:h})]})};T.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const I=()=>{const i="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(Ce,{children:[e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(U,{label:"Normal PUI",children:e.jsx(u,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:i,placeholder:"value|unit"})}),e.jsx(U,{label:"Disabled validation",children:e.jsx(u,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:i})}),e.jsx(U,{label:"Disabled validation and manual error",children:e.jsx(u,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:i})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};I.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const j=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("123|ft");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Storage State (Redux)"}),children:[s,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>n(b.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:i&&e.jsx(u,{name:"example",onChange:c=>n(c.target.value),value:s,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},S=()=>e.jsxs(e.Fragment,{children:[e.jsx(q,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),w=()=>e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(g,{}),e.jsx(u,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});w.play=async({canvasElement:i,step:a})=>{const t=f(i);await a("Can enter decimal values",async()=>{await r(t.getByDisplayValue("170")).toBeInTheDocument(),await r(t.getByDisplayValue("")).toBeInTheDocument()})};const B=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("psi"),[c,h]=d.useState(!1),[m,ve]=d.useState(!0),[F,ye]=d.useState(!0),[R,M]=d.useState("672.2388357750001|bar"),[W,be]=d.useState("");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Settings"}),children:[e.jsx(U,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:c,onChange:p=>h(p.target.checked)})}),e.jsx(U,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:m,onChange:p=>ve(p.target.checked)})}),e.jsx(U,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:F,onChange:p=>ye(p.target.checked)})})]}),e.jsxs(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:[e.jsx(q,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(g,{}),e.jsx(q,{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(g,{}),i&&e.jsx(u,{name:"Example",unitkey:"pressure",initUnit:s,unitTemplate:{pressure:"psi"},value:R,onChange:p=>{const{value:E}=p.target;E&&M(E)},enableDisplayRounding:c,enableCosmeticRounding:m,error:b.convertAndGetValue(R,"bar")>=0?"":"Value must be positive",validationCallback:(p,E)=>{be(E??"")},convertBackToStorageUnit:F})]}),e.jsx(v,{heading:e.jsx(y,{children:"Unit Template"}),children:e.jsx(xe,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:s,width:70,onChange:p=>n(p.target.value)})}),e.jsx(v,{heading:e.jsx(y,{children:"Test Validation Callback"}),children:W&&e.jsx(pe,{message:{content:W,icon:!0,type:"Error",visible:!0}})}),e.jsxs(v,{heading:e.jsx(y,{children:"Storage State / Redux"}),children:[R,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>M(b.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},k=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};k.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Can enter decimal values",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123.123456789"),await r(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"-1.12e3"),await r(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123,456"),await r(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"0.0000000023"),await r(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"999999999999"),await r(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const n=t.getByTestId("testId"),c=t.getByTestId("testId-menu");await l.clear(n),await l.type(n,"456.1"),await l.click(c),await l.click(s.getByTestId("testId-unit-ft")),await r(t.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};C.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};x.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"PlaceholderWithUnit"};T.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
1
|
+
import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as b}from"./index-C0x1JmaP.js";import{w as f,u as l,e as r,f as V,a as D}from"./index-DMAnyMX5.js";import{U as u}from"./unit-input-BXg4VphV.js";import{B as o}from"./button-Cbv7WK6k.js";import{S as g}from"./spacer-BWoNR27H.js";import{D as fe}from"./divider-DY9nJ_7N.js";import{R as Ce,C as _}from"./row-Bmiy2Lh0.js";import{F as U}from"./field-HrLaMLbx.js";import{M as pe}from"./message-BRyKdRaX.js";import{G as ge}from"./grid-DRkC-bt8.js";import{C as v}from"./card-EcjmryU9.js";import{H as y}from"./heading-CRNoBc7q.js";import{T as N}from"./toggle-BbFVf61v.js";import{T as q}from"./text-B3-TSWok.js";import{S as xe}from"./select-Cwks-WA0.js";import{I as he}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./initialize-context-Y03pJPr5.js";import"./number-input-B3_gmeWr.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-CJed_LLR.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const ht={title:"Forms/UnitInput/Test Cases",component:u,tags:["!autodocs"]},C=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),placeholder:"Type a value...",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};C.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const x=()=>{const[i,a]=d.useState("|m");return e.jsx(u,{name:"example-ft",onChange:t=>a(t.target.value),placeholder:"7|ft",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId-ft"})};x.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Handle input with unit only",async()=>{const n=t.getByTestId("testId-ft");await r(t.getByDisplayValue("")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Clear input and check placeholder",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await r(n).toHaveAttribute("placeholder","2.13")}),await a("Type a correct numeric value and ensure no error",async()=>{const n=t.getByTestId("testId-ft");await l.type(n,"123"),await r(t.getByDisplayValue("123")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Remove value, type incorrect value and check for error",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await l.type(n,"123abc"),await r(t.getByDisplayValue("123abc")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const T=i=>{const[a,t]=d.useState("123|m"),[s,n]=d.useState("223|m"),[c,h]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Change initUnit",onClick:()=>h(c==="m"?"ft":"m")}),e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,initUnit:c,onSwitchUnit:h}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,initUnit:c,onSwitchUnit:h}),e.jsx(fe,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,onSwitchUnit:h}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,onSwitchUnit:h})]})};T.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const I=()=>{const i="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(Ce,{children:[e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(U,{label:"Normal PUI",children:e.jsx(u,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:i,placeholder:"value|unit"})}),e.jsx(U,{label:"Disabled validation",children:e.jsx(u,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:i})}),e.jsx(U,{label:"Disabled validation and manual error",children:e.jsx(u,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:i})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};I.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const j=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("123|ft");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Storage State (Redux)"}),children:[s,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>n(b.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:i&&e.jsx(u,{name:"example",onChange:c=>n(c.target.value),value:s,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},S=()=>e.jsxs(e.Fragment,{children:[e.jsx(q,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),w=()=>e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(g,{}),e.jsx(u,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});w.play=async({canvasElement:i,step:a})=>{const t=f(i);await a("Can enter decimal values",async()=>{await r(t.getByDisplayValue("170")).toBeInTheDocument(),await r(t.getByDisplayValue("")).toBeInTheDocument()})};const B=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("psi"),[c,h]=d.useState(!1),[m,ve]=d.useState(!0),[F,ye]=d.useState(!0),[R,M]=d.useState("672.2388357750001|bar"),[W,be]=d.useState("");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Settings"}),children:[e.jsx(U,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:c,onChange:p=>h(p.target.checked)})}),e.jsx(U,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:m,onChange:p=>ve(p.target.checked)})}),e.jsx(U,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:F,onChange:p=>ye(p.target.checked)})})]}),e.jsxs(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:[e.jsx(q,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(g,{}),e.jsx(q,{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(g,{}),i&&e.jsx(u,{name:"Example",unitkey:"pressure",initUnit:s,unitTemplate:{pressure:"psi"},value:R,onChange:p=>{const{value:E}=p.target;E&&M(E)},enableDisplayRounding:c,enableCosmeticRounding:m,error:b.convertAndGetValue(R,"bar")>=0?"":"Value must be positive",validationCallback:(p,E)=>{be(E??"")},convertBackToStorageUnit:F})]}),e.jsx(v,{heading:e.jsx(y,{children:"Unit Template"}),children:e.jsx(xe,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:s,width:70,onChange:p=>n(p.target.value)})}),e.jsx(v,{heading:e.jsx(y,{children:"Test Validation Callback"}),children:W&&e.jsx(pe,{message:{content:W,icon:!0,type:"Error",visible:!0}})}),e.jsxs(v,{heading:e.jsx(y,{children:"Storage State / Redux"}),children:[R,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>M(b.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},k=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};k.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Can enter decimal values",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123.123456789"),await r(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"-1.12e3"),await r(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123,456"),await r(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"0.0000000023"),await r(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"999999999999"),await r(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const n=t.getByTestId("testId"),c=t.getByTestId("testId-menu");await l.clear(n),await l.type(n,"456.1"),await l.click(c),await l.click(s.getByTestId("testId-unit-ft")),await r(t.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};C.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};x.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"PlaceholderWithUnit"};T.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
|
|
2
2
|
target:
|
|
3
3
|
| T
|
|
4
4
|
| { name: string; value: any; label?: string; files?: FileList | null };
|