@oliasoft-open-source/react-ui-library 4.11.0 → 4.11.2-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-DoFa61ar.js → index-BMWyiwz3.js} +308 -304
- package/dist/assets/{index-BpSdrNXy.css → index-BaYhOc6M.css} +373 -341
- package/dist/global.css +658 -657
- package/dist/index.html +1 -1
- package/dist/index.js +347 -379
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-C4DMqLTk.js → Color-KGDBMAHA-B-shawjD.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-4sK5I5fh.js → DocsRenderer-PKQXORMH-CcJF_zh-.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-BSRBp5Mg.js → accordion.stories-BPKMbG3k.js} +1 -1
- package/dist/storybook/assets/{actions-D-uVCDzk.js → actions-Bax0KeqM.js} +2 -2
- package/dist/storybook/assets/{actions.stories-gKfuiKQy.js → actions.stories-BnPZKqOJ.js} +1 -1
- package/dist/storybook/assets/{afe.stories-DM18uTAa.js → afe.stories-C9XjJj62.js} +1 -1
- package/dist/storybook/assets/{badge.stories-Dkq_XgEW.js → badge.stories-DA_eeQyi.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-DHdofVc-.js → blowout.stories-DH-sYHgB.js} +1 -1
- package/dist/storybook/assets/button-Cbv7WK6k.js +1 -0
- package/dist/storybook/assets/button-DtgxLQCF.css +1 -0
- package/dist/storybook/assets/{button-group-1DEZPmxq.js → button-group-D2fGP_bX.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-C4V1k0z_.js → button-group.stories-BETADGti.js} +1 -1
- package/dist/storybook/assets/{button.stories-DA9DGYD2.js → button.stories-C03VvX8K.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-BAJT7RF7.js → buttons-and-links-BG2zqnHT.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-CE6GJ021.js → casing-loads.stories-BbYDH_71.js} +1 -1
- package/dist/storybook/assets/{cell.stories-BkZwSf40.js → cell.stories-DC1Vo0__.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-wyESLsMA.js → chunk-HLWAVYOI-CM47_bXG.js} +1 -1
- package/dist/storybook/assets/{color-CXm-Xks7.js → color-Cr-qn3FE.js} +1 -1
- package/dist/storybook/assets/{dialog-BelCA1mt.js → dialog-DkpQscuI.js} +1 -1
- package/dist/storybook/assets/drawer-BVc1xI9q.css +1 -0
- package/dist/storybook/assets/drawer-DaQ1xGjV.js +3 -0
- package/dist/storybook/assets/{drawer.stories-DcjyDHEs.js → drawer.stories-C08XBVTq.js} +1 -1
- package/dist/storybook/assets/{empty.stories-DcwF0pkK.js → empty.stories-L7LSMcLe.js} +1 -1
- package/dist/storybook/assets/{field.stories-DUGMwi1O.js → field.stories-CYpQ669-.js} +1 -1
- package/dist/storybook/assets/{file-button.stories-CU2pZcEO.js → file-button.stories-CRaTdLfv.js} +1 -1
- package/dist/storybook/assets/{file-input-B0-ERX66.js → file-input-yalPf7-m.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-Cpd1NHbq.js → file-input.stories-DMTQqAF8.js} +1 -1
- package/dist/storybook/assets/{flex.stories-BhvJpHpN.js → flex.stories-CLwPyEMp.js} +1 -1
- package/dist/storybook/assets/{footer.stories-C1SojIiD.js → footer.stories-DstLAiJp.js} +1 -1
- package/dist/storybook/assets/{form.stories-BLcmnfy8.js → form.stories-C8YjdHnX.js} +1 -1
- package/dist/storybook/assets/{formation.stories-DZ9-Ct5F.js → formation.stories-Bt29JldX.js} +1 -1
- package/dist/storybook/assets/{iframe-DGCZgYKU.js → iframe-CzFXqOr-.js} +2 -2
- package/dist/storybook/assets/{index-DHATsyTR.js → index-B5IpJ81Q.js} +1 -1
- package/dist/storybook/assets/{index-D-ApmKaY.js → index-CR-eYtkm.js} +88 -88
- package/dist/storybook/assets/initialize-context-rEvM6bdZ.js +1 -0
- package/dist/storybook/assets/input-Db9WkmPP.js +1 -0
- package/dist/storybook/assets/input-Dz1ZZYN5.css +1 -0
- package/dist/storybook/assets/{input-group.stories-EhmORqH9.js → input-group.stories-BCajsqAk.js} +1 -1
- package/dist/storybook/assets/{input-validation-BdnKKR1J.js → input-validation-xYDgrqcS.js} +1 -1
- package/dist/storybook/assets/{input.stories-FKl0qVhm.js → input.stories-SJy3TKkD.js} +1 -1
- package/dist/storybook/assets/{inputs-Cpi6xZLB.js → inputs-BKaZW2Pv.js} +1 -1
- package/dist/storybook/assets/{layout-forms-DxC0zO_Y.js → layout-forms-D2dIpGLv.js} +1 -1
- package/dist/storybook/assets/{layout-general-Be4RMwPl.js → layout-general-szYPo7Nk.js} +1 -1
- package/dist/storybook/assets/{list-bKpz6I9Q.js → list-By3wp5Wa.js} +1 -1
- package/dist/storybook/assets/{list.stories-Cgmt29Wv.js → list.stories-BcDHHHYJ.js} +1 -1
- package/dist/storybook/assets/{list.stories-data-D_Aj3AN4.js → list.stories-data-Doo2Rqun.js} +1 -1
- package/dist/storybook/assets/{loader.stories-pS8zRM4u.js → loader.stories-Q0U2BqZX.js} +1 -1
- package/dist/storybook/assets/{menu.stories-DLJSzJa-.js → menu.stories-1I5AGGQx.js} +1 -1
- package/dist/storybook/assets/menu.test-case.stories-XN9XFV-D.js +3 -0
- package/dist/storybook/assets/message-BRyKdRaX.js +1 -0
- package/dist/storybook/assets/message-C2ZCkHX6.css +1 -0
- package/dist/storybook/assets/{message.stories-r_UlbshI.js → message.stories-bCqCYIuN.js} +1 -1
- package/dist/storybook/assets/meta-content-ByVTG0hd.css +1 -0
- package/dist/storybook/assets/meta-content-DNgQbAW0.js +9 -0
- package/dist/storybook/assets/{modal.stories-DOgeTuHT.js → modal.stories-C2d-Em5V.js} +1 -1
- package/dist/storybook/assets/modal.test-case.stories-Ci1WRYdo.js +21 -0
- package/dist/storybook/assets/{number-input-CJJvhIIv.js → number-input-CNnU6gOF.js} +2 -2
- package/dist/storybook/assets/{number-input.stories-CKVq60XH.js → number-input.stories-Bo26PJmJ.js} +1 -1
- package/dist/storybook/assets/number-input.test-case.stories-BBKpBWfA.js +92 -0
- package/dist/storybook/assets/{option-dropdown.stories-CIvqMhQ3.js → option-dropdown.stories-CznUbXVi.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-BZdh5XRo.js → padding-and-spacing-rWdBf9ln.js} +1 -1
- package/dist/storybook/assets/{page.stories-DnCh8h8y.js → page.stories-DthnK8qb.js} +1 -1
- package/dist/storybook/assets/{pagination-DWc8zp3k.js → pagination-CR1nxnnq.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-B5cOvzik.js → pagination.stories-qXmBYwYc.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-DCpooB2O.js → pop-confirm.stories-CHa0qUBe.js} +1 -1
- package/dist/storybook/assets/{popover-rq33c1W2.js → popover-C_2P8LFJ.js} +1 -1
- package/dist/storybook/assets/{popover.stories-p9_-pH_Q.js → popover.stories-DZTfimDf.js} +1 -1
- package/dist/storybook/assets/{preview-B3bzTGOp.js → preview-BpH8OxJT.js} +2 -2
- package/dist/storybook/assets/{preview-NGnahGuq.js → preview-CVuoXXv0.js} +1 -1
- package/dist/storybook/assets/{projects.stories-Co_WnKSx.js → projects.stories-BPm6ucAe.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-UW_8sofe.js → reservoirs.stories-r1Ip90kJ.js} +1 -1
- package/dist/storybook/assets/{rich-text-input-dDjxXFl-.css → rich-text-input-BJfL0Me_.css} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-CK_OTGiV.js → rich-text-input.stories-DwaseXZv.js} +4 -4
- package/dist/storybook/assets/{row.stories-D11wLSt6.js → row.stories-DFKACj3C.js} +1 -1
- package/dist/storybook/assets/select-BmYXTl_0.css +1 -0
- package/dist/storybook/assets/select-Cwks-WA0.js +61 -0
- package/dist/storybook/assets/{select.stories-Bpffz9TF.js → select.stories-DjGSNDXK.js} +1 -1
- package/dist/storybook/assets/select.test-case.stories-CrXzt4qn.js +82 -0
- package/dist/storybook/assets/side-bar-fBbBqyAT.css +1 -0
- package/dist/storybook/assets/side-bar-wpFQ5NEE.js +24 -0
- package/dist/storybook/assets/{side-bar.stories-M6FsuCrQ.js → side-bar.stories-LjClxJcG.js} +1 -1
- package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-BnWmALGd.js} +1 -1
- package/dist/storybook/assets/{slider-DnRddBCy.css → slider-Cf9tPrCy.css} +1 -1
- package/dist/storybook/assets/{slider-C7vnj_3M.js → slider-Dvdl3yGr.js} +4 -4
- package/dist/storybook/assets/slider.stories-ai1lgqaI.js +134 -0
- package/dist/storybook/assets/{smart-upload-modal.stories-xqiXR6jV.js → smart-upload-modal.stories-BlTSF64K.js} +1 -1
- package/dist/storybook/assets/{spacer.stories-BBTt2LdE.js → spacer.stories-BT2S6B0R.js} +1 -1
- package/dist/storybook/assets/table-BtBtDwPu.css +1 -0
- package/dist/storybook/assets/table-CkNaVBsz.js +86 -0
- package/dist/storybook/assets/{table.stories-data-C3vJedB1.js → table.stories-data-C7mC5R8Q.js} +1 -1
- package/dist/storybook/assets/{table.stories-C1GgZCCR.js → table.stories-rxOOpdhc.js} +1 -1
- package/dist/storybook/assets/{textarea-D6ltcKhz.js → textarea-DflOOrxV.js} +2 -2
- package/dist/storybook/assets/textarea-TqxidmV4.css +1 -0
- package/dist/storybook/assets/{textarea.stories-CJ-Oqytp.js → textarea.stories-CzsqRVpC.js} +1 -1
- package/dist/storybook/assets/{title.stories-jatDyjoM.js → title.stories-CcqyFQEQ.js} +1 -1
- package/dist/storybook/assets/{toaster-BoBcvmf9.js → toaster-O8ftrUAJ.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-G6nKp3uV.js → toaster.stories-CdpwLBSo.js} +1 -1
- package/dist/storybook/assets/toaster.test-case.stories-Cy3_Gvs_.js +6 -0
- package/dist/storybook/assets/{tooltip.test-case.stories-C0wxGvKJ.js → tooltip.test-case.stories-De9h8ThH.js} +1 -1
- package/dist/storybook/assets/{top-bar-DkXSzzqt.js → top-bar-Bjf6PQE1.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-HDmWT243.js → top-bar.stories-1hZmlzDT.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-DfmrkEpT.js → top-bar.testcase.stories-BsFYqaw6.js} +1 -1
- package/dist/storybook/assets/{tree.stories-feLUcTtm.js → tree.stories-NGZfmH_B.js} +1 -1
- package/dist/storybook/assets/unit-input-Byipu-z0.js +10 -0
- package/dist/storybook/assets/{unit-input.stories-zmSrl6iW.js → unit-input.stories-CChVbxmI.js} +1 -1
- package/dist/storybook/assets/unit-input.test-case.stories-BwKiucyc.js +220 -0
- package/dist/storybook/assets/unit-table.stories-DvpNdCS9.js +152 -0
- package/dist/storybook/assets/unit-table.test-case.stories-OSAkErH8.js +1 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/404.html +0 -1
- package/dist/storybook/assets/button-DHevvVBE.js +0 -1
- package/dist/storybook/assets/button-fAxt_G4d.css +0 -1
- package/dist/storybook/assets/drawer-DOWJp9T4.js +0 -3
- package/dist/storybook/assets/drawer-DhrjYsQu.css +0 -1
- package/dist/storybook/assets/input-DD7t4kHm.css +0 -1
- package/dist/storybook/assets/input-DTXbDJaL.js +0 -1
- package/dist/storybook/assets/menu.test-case.stories-DyrNbGBs.js +0 -3
- package/dist/storybook/assets/message-Cl3kn7ZD.css +0 -1
- package/dist/storybook/assets/message-Y48EomV-.js +0 -1
- package/dist/storybook/assets/meta-content-DWZbURV2.js +0 -9
- package/dist/storybook/assets/meta-content-DnZPPeTF.css +0 -1
- package/dist/storybook/assets/modal.test-case.stories-DQ1Izuq6.js +0 -21
- package/dist/storybook/assets/number-input.test-case.stories-Dh1F7N8M.js +0 -92
- package/dist/storybook/assets/select-03uRbc4I.js +0 -61
- package/dist/storybook/assets/select-H-9tdhwc.css +0 -1
- package/dist/storybook/assets/select.test-case.stories-DwDNDHax.js +0 -82
- package/dist/storybook/assets/side-bar-CSx5wI-k.js +0 -24
- package/dist/storybook/assets/side-bar-auov230-.css +0 -1
- package/dist/storybook/assets/slider.stories-BzBb3PkP.js +0 -171
- package/dist/storybook/assets/table-B8ojy8Nj.css +0 -1
- package/dist/storybook/assets/table-DyOsClUv.js +0 -86
- package/dist/storybook/assets/textarea-H-YTEwr8.css +0 -1
- package/dist/storybook/assets/toaster.test-case.stories-CCHTh_U1.js +0 -6
- package/dist/storybook/assets/unit-input-CooRJQnF.js +0 -10
- package/dist/storybook/assets/unit-input.test-case.stories-C1xRJ1EZ.js +0 -220
- package/dist/storybook/assets/unit-table.stories-Bl2gHPKG.js +0 -152
- package/dist/storybook/assets/unit-table.test-case.stories-DpSewGv4.js +0 -1
- package/dist/storybook/assets/use-previous-D775JrO6.js +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as Q}from"./immer.esm-BwVl9PS2.js";import{d as y}from"./index-C0x1JmaP.js";import{G as X}from"./grid-DRkC-bt8.js";import{S as Y}from"./spacer-BWoNR27H.js";import{C as V}from"./card-EcjmryU9.js";import{F as L}from"./field-HrLaMLbx.js";import{H as F}from"./heading-CRNoBc7q.js";import{S as N}from"./select-03uRbc4I.js";import{T as W}from"./toggle-BbFVf61v.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{u as ee}from"./use-previous-D775JrO6.js";import{T as te,C as K}from"./table-DyOsClUv.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-D-uVCDzk.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-DWc8zp3k.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CJJvhIIv.js";import"./check-box-DPLaOkRR.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";const ne=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:m})=>(i[s]=a,r[s]=m,{preferredUnits:i,storageUnits:r}),{preferredUnits:{},storageUnits:{}}),ae=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:m,enableCosmeticRounding:h,enableDisplayRounding:U})=>{const u=l?l.map(d=>({...d,cells:d.cells.map(c=>{var t;if(c.type===K.AUTO_UNIT){const{testId:S,unitKey:p}=c;return{value:r[p],type:K.SELECT,searchable:!1,options:(t=y.getUnitsForQuantity(p))==null?void 0:t.map(T=>({label:y.label(T),value:T})),native:c.native,onChange:T=>a({unitKey:p,value:T.target.value}),testId:S}}return c})})):[],o=i?i.map((d,c)=>({...d,cells:d.cells.map((t,S)=>{if("autoUnit"in t&&(t!=null&&t.autoUnit)&&(typeof(t==null?void 0:t.value)=="string"||typeof(t==null?void 0:t.value)=="number")){const{unitKey:p,value:T,formatDisplayValue:D}=t,j=U&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,g=r[p],b=s[p],e=g!==b,f=e?y.convertAndGetValue(T,g,b):t.value,C=D?D(f):f;return{...t,value:C,enableCosmeticRounding:h&&e,enableDisplayRounding:U,roundDisplayValue:j,onChange:w=>{const{value:x}=w.target,R=s[p],E=r[p],A=E!==R,B=m?R:E,H=A?y.convertAndGetValue(x,B,E):x;if("onChange"in t){const{onChange:I}=t,J={...w,target:{...w.target,value:String(H),rowIndex:c,cellIndex:S,unit:B}};I(J)}}}}return t})})):[];return{convertedHeaders:u,convertedRows:o}},z=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:m,headers:h,...U}=l,{storageUnits:u,preferredUnits:o}=ne(i),d=ee(o),[c,t]=v.useState(o),S=({unitKey:g,value:b})=>{t({...c,[g]:b});const e=i.find(f=>f.unitKey===g);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:c[g],newUnit:b,unitKey:g})},p=g=>ae({headers:h,rows:m,selectedUnits:g,storageUnits:u,onChangeUnit:S,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),T=p(c),[D,j]=v.useState(T);return v.useEffect(()=>{!Z.isEqual(o,d)&&(Object.keys(o).forEach(b=>{const e=d==null?void 0:d[b],f=o[b];e!==f&&S({unitKey:b,value:f})}),j(p(o)))},[i]),v.useEffect(()=>{j(p(c))},[l,c]),n.jsx(te,{table:{...U,headers:D.convertedHeaders,rows:D.convertedRows}})};z.__docgenInfo={description:"",methods:[],displayName:"UnitTable",props:{table:{required:!0,tsType:{name:"IUnitTable"},description:""},unitConfig:{required:!0,tsType:{name:"Array",elements:[{name:"IUnitConfigItem"}],raw:"IUnitConfigItem[]"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}},composes:["Omit"]};const ct={title:"Basic/UnitTable",args:{}},ie=!0,re=!0,oe=!0,le=!1,_="ft",M="C",se=3,ue=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((m,h)=>{const U=h,u=h+1.25,o=4+h*.25;return[String(U),String(u),String(o)]});return[s,...a]},de=ue(se,_,M),ce=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>Q(l,m=>{const h=m[0][a],U=(u,o)=>o===0;return m.forEach((u,o)=>{if(U(u,o)){u[a]=r;return}if(o===s+1){u[a]=String(i);return}const d=y.convertAndGetValue(u[a],r,h);u[a]=String(d)}),m}),pe=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>Q(l,a=>{a[r+1][s]=i}),k=()=>{var g,b;const[l,i]=v.useState(_),[r,s]=v.useState(M),[a,m]=v.useState(de),[h,U]=v.useState(ie),[u,o]=v.useState(oe),[d,c]=v.useState(re),[t,S]=v.useState(le),[p,T]=v.useState(_),D=e=>{const{rowIndex:f,cellIndex:C,value:w,unit:x}=e.target,R=t?ce({reduxTable:a,value:w,unit:x,rowIndex:f,cellIndex:C}):pe({reduxTable:a,value:w,rowIndex:f,cellIndex:C});m(R)},j=a.reduce((e,f,C)=>(C===0?e.headers=[{cells:[{value:"From"},{value:"To"},{value:"Temperature"}]},{cells:[{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"temperature",testId:"table-unit-selector-3"}]}]:e.rows=e.rows.concat({cells:f.map((w,x)=>{const R=C===1&&x===1;return{value:w,type:R?"Text":"NumberInput",unitKey:x===2?"temperature":"length",onChange:D,roundDisplayValue:C===3&&x===2?I=>y.roundByMagnitude(I,2):null,formatDisplayValue:R?I=>`T* ${I}`:null,autoUnit:!0,testId:`testId_${C}_${x}`}})}),e),{testId:"testId",headers:[],rows:[]});return n.jsxs(X,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(V,{heading:n.jsx(F,{children:"Settings"}),children:[n.jsx(L,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:h,onChange:e=>U(e.target.checked)})}),n.jsx(L,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:u,onChange:e=>o(e.target.checked)})}),n.jsx(L,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:d,onChange:e=>c(e.target.checked)})}),n.jsx(L,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:t,onChange:e=>S(e.target.checked)})})]}),n.jsxs(V,{heading:n.jsx(F,{children:"Unit template"}),children:[n.jsx(L,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(g=y.getUnitsForQuantity("length"))==null?void 0:g.map(e=>({value:e,label:y.label(e)})),value:{value:l},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(L,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(b=y.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:y.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(V,{heading:n.jsx(F,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(V,{heading:n.jsx(F,{children:"UnitTable"}),children:[n.jsx(z,{table:j,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:l,onChange:({newUnit:e})=>T(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:h,enableDisplayRounding:u,enableCosmeticRounding:d}),n.jsx(Y,{height:20}),n.jsx(L,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:p})]})]})};k.__docgenInfo={description:"",methods:[],displayName:"UnitTableExample"};var G,O,P,q,$;k.parameters={...k.parameters,docs:{...(G=k.parameters)==null?void 0:G.docs,source:{originalSource:`() => {
|
|
2
|
-
const [preferredLengthUnit, setPreferredLengthUnit] = useState(initialLengthUnit);
|
|
3
|
-
const [preferredTemperatureUnit, setPreferredTemperatureUnit] = useState(initialTemperatureUnit);
|
|
4
|
-
const [reduxTable, setReduxTable] = useState<TTable>(initialTable);
|
|
5
|
-
const [convertBackToStorageUnit, setConvertBackToStorageUnit] = useState(initialConvertBackToStorageUnit);
|
|
6
|
-
const [enableDisplayRounding, setEnableDisplayRounding] = useState(initialEnableDisplayRounding);
|
|
7
|
-
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(initialEnableCosmeticRounding);
|
|
8
|
-
const [convertWholeTable, setConvertWholeTable] = useState(initialConvertWholeTable);
|
|
9
|
-
const [displayedLengthUnit, setDisplayedLengthUnit] = useState(initialLengthUnit);
|
|
10
|
-
|
|
11
|
-
/*********************************************************************************************************************
|
|
12
|
-
Cell onChange handler
|
|
13
|
-
*********************************************************************************************************************/
|
|
14
|
-
const onUpdateCell = (evt: IUnitTableOnChangeEvent) => {
|
|
15
|
-
const {
|
|
16
|
-
rowIndex,
|
|
17
|
-
cellIndex,
|
|
18
|
-
value,
|
|
19
|
-
unit
|
|
20
|
-
} = evt.target;
|
|
21
|
-
const nextTable = convertWholeTable ? convertStorageTable({
|
|
22
|
-
reduxTable,
|
|
23
|
-
value,
|
|
24
|
-
unit,
|
|
25
|
-
rowIndex,
|
|
26
|
-
cellIndex
|
|
27
|
-
}) : updateCell({
|
|
28
|
-
reduxTable,
|
|
29
|
-
value,
|
|
30
|
-
rowIndex,
|
|
31
|
-
cellIndex
|
|
32
|
-
});
|
|
33
|
-
setReduxTable(nextTable);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/*********************************************************************************************************************
|
|
37
|
-
Construct table view data (same as old Table component, with a new props)
|
|
38
|
-
*********************************************************************************************************************/
|
|
39
|
-
const tableViewData = reduxTable.reduce((acc, row, rowIndex) => {
|
|
40
|
-
if (rowIndex === 0) {
|
|
41
|
-
acc.headers = [{
|
|
42
|
-
cells: [{
|
|
43
|
-
value: 'From'
|
|
44
|
-
}, {
|
|
45
|
-
value: 'To'
|
|
46
|
-
}, {
|
|
47
|
-
value: 'Temperature'
|
|
48
|
-
}]
|
|
49
|
-
}, {
|
|
50
|
-
cells: [{
|
|
51
|
-
type: 'AutoUnit',
|
|
52
|
-
unitKey: 'length'
|
|
53
|
-
}, {
|
|
54
|
-
type: 'AutoUnit',
|
|
55
|
-
unitKey: 'length'
|
|
56
|
-
}, {
|
|
57
|
-
type: 'AutoUnit',
|
|
58
|
-
unitKey: 'temperature',
|
|
59
|
-
testId: 'table-unit-selector-3'
|
|
60
|
-
}]
|
|
61
|
-
}];
|
|
62
|
-
} else {
|
|
63
|
-
acc.rows = acc.rows.concat({
|
|
64
|
-
cells: row.map((cell, cellIndex) => {
|
|
65
|
-
const specialCell = rowIndex === 1 && cellIndex === 1;
|
|
66
|
-
const type = specialCell ? 'Text' : 'NumberInput';
|
|
67
|
-
const formatDisplayValue = specialCell ? (value: number | string) => \`T* \${value}\` : null;
|
|
68
|
-
const customDisplayRounding = rowIndex === 3 && cellIndex === 2 ? (value: TStringNumberNull) => roundByMagnitude(value, 2) : null;
|
|
69
|
-
const value = cell;
|
|
70
|
-
return {
|
|
71
|
-
value,
|
|
72
|
-
type,
|
|
73
|
-
unitKey: cellIndex === 2 ? 'temperature' : 'length',
|
|
74
|
-
onChange: onUpdateCell,
|
|
75
|
-
roundDisplayValue: customDisplayRounding,
|
|
76
|
-
// optionally customize the display rounding of specific columns/cells
|
|
77
|
-
formatDisplayValue,
|
|
78
|
-
// optionally extend/customize the display formatting of specific columns/cells
|
|
79
|
-
autoUnit: true,
|
|
80
|
-
testId: \`testId_\${rowIndex}_\${cellIndex}\`
|
|
81
|
-
};
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return acc;
|
|
86
|
-
}, {
|
|
87
|
-
testId: 'testId',
|
|
88
|
-
headers: ([] as any[]),
|
|
89
|
-
rows: ([] as IUnitTableRow[])
|
|
90
|
-
});
|
|
91
|
-
return <Grid columns="1fr 1fr" gap>
|
|
92
|
-
<Card heading={<Heading>Settings</Heading>}>
|
|
93
|
-
<Field label="Convert back to storage unit:" labelLeft labelWidth={200}>
|
|
94
|
-
<Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
|
|
95
|
-
</Field>
|
|
96
|
-
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
97
|
-
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
98
|
-
</Field>
|
|
99
|
-
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
100
|
-
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
101
|
-
</Field>
|
|
102
|
-
<Field label="Convert whole table:" labelLeft labelWidth={200}>
|
|
103
|
-
<Toggle checked={convertWholeTable} onChange={evt => setConvertWholeTable(evt.target.checked)} />
|
|
104
|
-
</Field>
|
|
105
|
-
</Card>
|
|
106
|
-
<Card heading={<Heading>Unit template</Heading>}>
|
|
107
|
-
<Field label="Length unit:" labelLeft labelWidth={120}>
|
|
108
|
-
<Select options={getUnitsForQuantity('length')?.map(unit => ({
|
|
109
|
-
value: unit,
|
|
110
|
-
label: label(unit)
|
|
111
|
-
}))} value={{
|
|
112
|
-
value: preferredLengthUnit
|
|
113
|
-
}} onChange={evt => setPreferredLengthUnit(evt.target.value)} width="100px" />
|
|
114
|
-
</Field>
|
|
115
|
-
<Field label="Temperature unit:" labelLeft labelWidth={120}>
|
|
116
|
-
<Select options={getUnitsForQuantity('temperature')?.map(unit => ({
|
|
117
|
-
value: unit,
|
|
118
|
-
label: label(unit)
|
|
119
|
-
}))} value={{
|
|
120
|
-
value: preferredTemperatureUnit
|
|
121
|
-
}} onChange={evt => setPreferredTemperatureUnit(evt.target.value)} width="100px" />
|
|
122
|
-
</Field>
|
|
123
|
-
</Card>
|
|
124
|
-
<Card heading={<Heading>Storage State (Redux)</Heading>}>
|
|
125
|
-
<pre>
|
|
126
|
-
<code>{JSON.stringify(reduxTable, null, 2)}</code>
|
|
127
|
-
</pre>
|
|
128
|
-
</Card>
|
|
129
|
-
<Card heading={<Heading>UnitTable</Heading>}>
|
|
130
|
-
<UnitTable table={tableViewData}
|
|
131
|
-
//New props:
|
|
132
|
-
unitConfig={[{
|
|
133
|
-
unitKey: 'length',
|
|
134
|
-
storageUnit: reduxTable[0][0],
|
|
135
|
-
preferredUnit: preferredLengthUnit,
|
|
136
|
-
onChange: ({
|
|
137
|
-
newUnit
|
|
138
|
-
}) => setDisplayedLengthUnit(newUnit)
|
|
139
|
-
}, {
|
|
140
|
-
unitKey: 'temperature',
|
|
141
|
-
storageUnit: reduxTable[0][2],
|
|
142
|
-
preferredUnit: preferredTemperatureUnit
|
|
143
|
-
}]}
|
|
144
|
-
//Most tables should just use the default values here (true):
|
|
145
|
-
convertBackToStorageUnit={convertBackToStorageUnit} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} />
|
|
146
|
-
<Spacer height={20} />
|
|
147
|
-
<Field label="Displayed length unit:" labelLeft labelWidth={150}>
|
|
148
|
-
{displayedLengthUnit}
|
|
149
|
-
</Field>
|
|
150
|
-
</Card>
|
|
151
|
-
</Grid>;
|
|
152
|
-
}`,...(P=(O=k.parameters)==null?void 0:O.docs)==null?void 0:P.source},description:{story:"Story",...($=(q=k.parameters)==null?void 0:q.docs)==null?void 0:$.description}}};const pt=["UnitTableExample"];export{k as UnitTableExample,pt as __namedExportsOrder,ct as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{w as p,u as i,e as r,f as s,a as n}from"./index-DMAnyMX5.js";import{UnitTableExample as c}from"./unit-table.stories-Bl2gHPKG.js";import"./index-CF7H4eMJ.js";import"./jsx-runtime-eps93zm2.js";import"./index-DhsZuJvc.js";import"./immer.esm-BwVl9PS2.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./spacer-BWoNR27H.js";import"./card-EcjmryU9.js";import"./index-Bk2sglWO.js";import"./field-HrLaMLbx.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./heading-CRNoBc7q.js";import"./select-03uRbc4I.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-D-uVCDzk.js";import"./button-DHevvVBE.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./toggle-BbFVf61v.js";import"./use-previous-D775JrO6.js";import"./table-DyOsClUv.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-DWc8zp3k.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CJJvhIIv.js";import"./check-box-DPLaOkRR.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";const ut={title:"Basic/UnitTable/Test Cases",args:{},tags:["!autodocs"]},w=c.bind({});w.play=async({canvasElement:o,step:e})=>{const a=p(o),m=p(o.ownerDocument.body);await e("Can enter decimal values",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123.123456789"),await i.click(o),await r(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await e("Can enter comma decimals (converts to dot)",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123,456"),await i.click(o),await r(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await e("Can enter small numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"0.0000000023"),await i.click(o),await r(t).toHaveDisplayValue("0.00")}),await e("Can enter large numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"999999999999"),await i.click(o),await r(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await e("Shows validation error for non-numeric input",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123x45s6"),await i.click(o),await r(a.getByDisplayValue("123x45s6")).toBeInTheDocument(),await s.mouseOver(t),await n(()=>{r(m.getByText("Must be a numerical value")).toBeInTheDocument()})})};const yt=["Test"];export{w as Test,yt as __namedExportsOrder,ut as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t}from"./index-DhsZuJvc.js";const o=r=>{const e=t.useRef();return t.useEffect(()=>{e.current=r},[r]),e.current};export{o as u};
|