@oliasoft-open-source/react-ui-library 4.11.0-beta-3 → 4.11.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.
Files changed (92) hide show
  1. package/dist/404.html +1 -0
  2. package/dist/global.css +643 -643
  3. package/dist/index.js +402 -421
  4. package/dist/index.js.map +1 -1
  5. package/dist/storybook/assets/{Color-KGDBMAHA-DeGjmgTY.js → Color-KGDBMAHA-B3T0ILh4.js} +1 -1
  6. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DJIj_qEG.js → DocsRenderer-PKQXORMH-CJgueRY3.js} +1 -1
  7. package/dist/storybook/assets/{accordion.stories-BTxV-ybU.js → accordion.stories-Ctfewlsk.js} +2 -2
  8. package/dist/storybook/assets/{afe.stories-DFQsvqIV.js → afe.stories-DM18uTAa.js} +2 -2
  9. package/dist/storybook/assets/{buttons-and-links-BHGzZGPV.js → buttons-and-links-BgjMT4gF.js} +1 -1
  10. package/dist/storybook/assets/{casing-loads.stories-CJpnsmsZ.js → casing-loads.stories-Cc2cl9m1.js} +2 -2
  11. package/dist/storybook/assets/{cell.stories-Bpl0Squh.js → cell.stories-D8aQP2lw.js} +2 -2
  12. package/dist/storybook/assets/check-box.stories-BJ0ShmeC.js +97 -0
  13. package/dist/storybook/assets/check-box.test-case.stories-CzuYZkUh.js +30 -0
  14. package/dist/storybook/assets/{chunk-HLWAVYOI-D2p4xoma.js → chunk-HLWAVYOI-DW5riARI.js} +1 -1
  15. package/dist/storybook/assets/{color-D9KYOiNh.js → color-Cidw5dH_.js} +1 -1
  16. package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
  17. package/dist/storybook/assets/footer.stories-DcDOHTpf.js +3 -0
  18. package/dist/storybook/assets/form.stories-BLcmnfy8.js +49 -0
  19. package/dist/storybook/assets/{formation.stories-BT8VrcqV.js → formation.stories-D9xC_fJP.js} +2 -2
  20. package/dist/storybook/assets/helpers-JJxzGegQ.js +1 -0
  21. package/dist/storybook/assets/iframe-BOQa8dKi.js +2 -0
  22. package/dist/storybook/assets/{index-CNkaN_wz.js → index-CqF2VcgG.js} +1 -1
  23. package/dist/storybook/assets/{index-C0Iaso0O.js → index-IzFttIXx.js} +88 -88
  24. package/dist/storybook/assets/initialize-context-BvejO8yS.js +1 -0
  25. package/dist/storybook/assets/{input-group.stories-CElwRt3p.js → input-group.stories-EhmORqH9.js} +3 -3
  26. package/dist/storybook/assets/{input-validation-Ccgprl1C.js → input-validation-Barn85e8.js} +2 -2
  27. package/dist/storybook/assets/{inputs-DtQ245kS.js → inputs-DhSTn98J.js} +2 -2
  28. package/dist/storybook/assets/{layout-forms-Bm7FYA3V.js → layout-forms-B7tboerR.js} +5 -5
  29. package/dist/storybook/assets/{layout-general-V7ekuEG7.js → layout-general-IRBlgjFP.js} +1 -1
  30. package/dist/storybook/assets/menu.stories-DLJSzJa-.js +82 -0
  31. package/dist/storybook/assets/menu.test-case.stories-DyrNbGBs.js +3 -0
  32. package/dist/storybook/assets/modal.stories-DOgeTuHT.js +200 -0
  33. package/dist/storybook/assets/modal.test-case.stories-DQ1Izuq6.js +21 -0
  34. package/dist/storybook/assets/{number-input-Bpg4Yqmo.js → number-input-Dq8zEk7X.js} +2 -2
  35. package/dist/storybook/assets/number-input.stories-DUvn4L-Z.js +89 -0
  36. package/dist/storybook/assets/number-input.test-case.stories-C6CDA2a8.js +92 -0
  37. package/dist/storybook/assets/{padding-and-spacing-IKi7rvQ-.js → padding-and-spacing-CZZN7tnu.js} +1 -1
  38. package/dist/storybook/assets/{pagination-CLt-kUlx.js → pagination-DWc8zp3k.js} +1 -1
  39. package/dist/storybook/assets/{pagination.stories-CTRM0Xou.js → pagination.stories-B5cOvzik.js} +2 -2
  40. package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +10 -0
  41. package/dist/storybook/assets/{preview-ZgLLfBPl.js → preview-Bb6CWa9a.js} +2 -2
  42. package/dist/storybook/assets/{preview-CtQzjqBP.js → preview-u3mhrMoU.js} +1 -1
  43. package/dist/storybook/assets/{projects.stories-BQswWVCx.js → projects.stories-Co_WnKSx.js} +2 -2
  44. package/dist/storybook/assets/{radio-button-DmDuw4DA.js → radio-button-C4ljBRED.js} +1 -1
  45. package/dist/storybook/assets/radio-button.stories-D1rWr6ms.js +61 -0
  46. package/dist/storybook/assets/radio-button.test-case.stories-DglmHlWs.js +11 -0
  47. package/dist/storybook/assets/{reservoirs.stories-B12tIrmZ.js → reservoirs.stories-UW_8sofe.js} +2 -2
  48. package/dist/storybook/assets/{rich-text-input.stories-DkaOBgbE.js → rich-text-input.stories-CK_OTGiV.js} +3 -3
  49. package/dist/storybook/assets/{row.stories-msEoNdGI.js → row.stories-D1iDHHxo.js} +2 -2
  50. package/dist/storybook/assets/select-03uRbc4I.js +61 -0
  51. package/dist/storybook/assets/select.input-CJed_LLR.js +1 -0
  52. package/dist/storybook/assets/select.stories-Bpffz9TF.js +498 -0
  53. package/dist/storybook/assets/select.stories-data-DxgWKlU6.js +1 -0
  54. package/dist/storybook/assets/select.test-case.stories-DwDNDHax.js +82 -0
  55. package/dist/storybook/assets/{site.stories-umpPYjkq.js → site.stories-ZGohyW6Z.js} +2 -2
  56. package/dist/storybook/assets/{table-5Y5KPNSk.js → table-Cw1-vdpR.js} +1 -1
  57. package/dist/storybook/assets/{table.stories-Clltxls0.js → table.stories-oLm8-Sg3.js} +2 -2
  58. package/dist/storybook/assets/{tabs-C3NG6m9W.js → tabs-BoToLVEP.js} +1 -1
  59. package/dist/storybook/assets/tabs.stories-B52iEaHf.js +30 -0
  60. package/dist/storybook/assets/{title.stories-CsrYTGde.js → title.stories-iTXgnNqS.js} +3 -3
  61. package/dist/storybook/assets/toaster.stories-G6nKp3uV.js +84 -0
  62. package/dist/storybook/assets/toaster.test-case.stories-CCHTh_U1.js +6 -0
  63. package/dist/storybook/assets/toggle.stories-BAislK3I.js +106 -0
  64. package/dist/storybook/assets/toggle.test-case.stories-CeUwdhGD.js +36 -0
  65. package/dist/storybook/assets/{tooltip.test-case.stories-CHibN8rC.js → tooltip.test-case.stories-C0wxGvKJ.js} +1 -1
  66. package/dist/storybook/assets/unit-input-DZs3wEdY.js +10 -0
  67. package/dist/storybook/assets/unit-input.stories-BRl4TnIK.js +198 -0
  68. package/dist/storybook/assets/unit-input.test-case.stories-xWsKGi4p.js +220 -0
  69. package/dist/storybook/assets/unit-table.stories-C4AcKcPO.js +152 -0
  70. package/dist/storybook/assets/unit-table.test-case.stories-Do8WFzxy.js +1 -0
  71. package/dist/storybook/iframe.html +1 -1
  72. package/dist/storybook/index.json +1 -1
  73. package/dist/storybook/project.json +1 -1
  74. package/package.json +1 -1
  75. package/dist/storybook/assets/check-box.stories-DfbWw6mD.js +0 -126
  76. package/dist/storybook/assets/footer.stories-DgjDE_JR.js +0 -3
  77. package/dist/storybook/assets/form.stories-BrUnmw7R.js +0 -49
  78. package/dist/storybook/assets/iframe-B8VgeFPT.js +0 -2
  79. package/dist/storybook/assets/initialize-context-DOqEe1Xq.js +0 -1
  80. package/dist/storybook/assets/menu.stories-xWX80Eh2.js +0 -84
  81. package/dist/storybook/assets/modal.stories-LhoWfDE6.js +0 -220
  82. package/dist/storybook/assets/number-input.stories-DhCjZ37u.js +0 -180
  83. package/dist/storybook/assets/popover.stories-CGm0M5fv.js +0 -10
  84. package/dist/storybook/assets/radio-button.stories-5gvV0LD0.js +0 -71
  85. package/dist/storybook/assets/select-DnRuRG_N.js +0 -61
  86. package/dist/storybook/assets/select.input-D0UkAPd9.js +0 -1
  87. package/dist/storybook/assets/select.stories-B9w9ONzj.js +0 -579
  88. package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +0 -30
  89. package/dist/storybook/assets/toaster.stories-HO4VBTy-.js +0 -89
  90. package/dist/storybook/assets/toggle.stories-qTHFTXxI.js +0 -141
  91. package/dist/storybook/assets/unit-input.stories-QnEpR0rY.js +0 -426
  92. package/dist/storybook/assets/unit-table.stories-BZCc0yfc.js +0 -152
@@ -0,0 +1,152 @@
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as f}from"./index-DhsZuJvc.js";import{f as z}from"./immer.esm-BwVl9PS2.js";import{d as w}from"./index-C0x1JmaP.js";import{G as ee}from"./grid-DRkC-bt8.js";import{S as te}from"./spacer-BWoNR27H.js";import{C as V}from"./card-EcjmryU9.js";import{F as R}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 ne}from"./lodash-c4VUpsOs.js";import{u as ae,a as ie,g as re,c as K}from"./initialize-context-BvejO8yS.js";import{T as oe,C as P}from"./table-Cw1-vdpR.js";import{s as le}from"./number-input-Dq8zEk7X.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"./check-box-DPLaOkRR.js";import"./slider-C7vnj_3M.js";import"./index-BI4_Bp97.js";import"./popover-rq33c1W2.js";const se=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:h})=>{const{unitTemplate:p=null}=ie()??{};return i[s]=a??re(s,p),r[s]=h,{preferredUnits:i,storageUnits:r}},{preferredUnits:{},storageUnits:{}}),ue=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:h,enableCosmeticRounding:p,enableDisplayRounding:T})=>{const d=l?l.map(c=>({...c,cells:c.cells.map(g=>{var t;if(g.type===P.AUTO_UNIT){const{testId:x,unitKey:u}=g;return{value:r[u],type:P.SELECT,searchable:!1,options:(t=w.getUnitsForQuantity(u))==null?void 0:t.map(v=>({label:w.label(v),value:v})),native:g.native,onChange:v=>a({unitKey:u,value:v.target.value}),testId:x}}return g})})):[],o=i?i.map((c,g)=>({...c,cells:c.cells.map((t,x)=>{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:u,value:v,formatDisplayValue:D}=t,L=T&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,m=r[u],b=s[u],e=m!==b,{value:U=v}=K({value:le(v),unitkey:u,toUnit:m,fromUnit:b}),y=e?U:t.value,k=D?D(y):y;return{...t,value:k,enableCosmeticRounding:p&&e,enableDisplayRounding:T,roundDisplayValue:L,onChange:C=>{const{value:S}=C.target,B=s[u],E=r[u],A=E!==B,_=h?B:E,{value:I=S}=K({value:String(S),unitkey:u,toUnit:_,fromUnit:E}),X=A?I:S;if("onChange"in t){const{onChange:Y}=t,Z={...C,target:{...C.target,value:String(X),rowIndex:g,cellIndex:x,unit:_}};Y(Z)}}}}return t})})):[];return{convertedHeaders:d,convertedRows:o}},M=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:h,headers:p,...T}=l,{storageUnits:d,preferredUnits:o}=se(i),c=ae(o),[g,t]=f.useState(o),x=({unitKey:m,value:b})=>{t({...g,[m]:b});const e=i.find(U=>U.unitKey===m);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:g[m],newUnit:b,unitKey:m})},u=m=>ue({headers:p,rows:h,selectedUnits:m,storageUnits:d,onChangeUnit:x,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),v=u(g),[D,L]=f.useState(v);return f.useEffect(()=>{!ne.isEqual(o,c)&&(Object.keys(o).forEach(b=>{const e=c==null?void 0:c[b],U=o[b];e!==U&&x({unitKey:b,value:U})}),L(u(o)))},[i]),f.useEffect(()=>{L(u(g))},[l,g]),n.jsx(oe,{table:{...T,headers:D.convertedHeaders,rows:D.convertedRows}})};M.__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 ft={title:"Basic/UnitTable",args:{}},de=!0,ce=!0,pe=!0,ge=!1,H="ft",J="C",me=3,he=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((h,p)=>{const T=p,d=p+1.25,o=4+p*.25;return[String(T),String(d),String(o)]});return[s,...a]},be=he(me,H,J),fe=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>z(l,h=>{const p=h[0][a],T=(d,o)=>o===0;return h.forEach((d,o)=>{if(T(d,o)){d[a]=r;return}if(o===s+1){d[a]=String(i);return}const c=w.convertAndGetValue(d[a],r,p);d[a]=String(c)}),h}),ve=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>z(l,a=>{a[r+1][s]=i}),j=()=>{var m,b;const[l,i]=f.useState(H),[r,s]=f.useState(J),[a,h]=f.useState(be),[p,T]=f.useState(de),[d,o]=f.useState(pe),[c,g]=f.useState(ce),[t,x]=f.useState(ge),[u,v]=f.useState(H),D=e=>{const{rowIndex:U,cellIndex:y,value:k,unit:C}=e.target,S=t?fe({reduxTable:a,value:k,unit:C,rowIndex:U,cellIndex:y}):ve({reduxTable:a,value:k,rowIndex:U,cellIndex:y});h(S)},L=a.reduce((e,U,y)=>(y===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:U.map((k,C)=>{const S=y===1&&C===1;return{value:k,type:S?"Text":"NumberInput",unitKey:C===2?"temperature":"length",onChange:D,roundDisplayValue:y===3&&C===2?I=>w.roundByMagnitude(I,2):null,formatDisplayValue:S?I=>`T* ${I}`:null,autoUnit:!0,testId:`testId_${y}_${C}`}})}),e),{testId:"testId",headers:[],rows:[]});return n.jsxs(ee,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(V,{heading:n.jsx(F,{children:"Settings"}),children:[n.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:p,onChange:e=>T(e.target.checked)})}),n.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:d,onChange:e=>o(e.target.checked)})}),n.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:c,onChange:e=>g(e.target.checked)})}),n.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:t,onChange:e=>x(e.target.checked)})})]}),n.jsxs(V,{heading:n.jsx(F,{children:"Unit template"}),children:[n.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(m=w.getUnitsForQuantity("length"))==null?void 0:m.map(e=>({value:e,label:w.label(e)})),value:{value:l},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(b=w.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:w.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(M,{table:L,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:l,onChange:({newUnit:e})=>v(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:p,enableDisplayRounding:d,enableCosmeticRounding:c}),n.jsx(te,{height:20}),n.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:u})]})]})};j.__docgenInfo={description:"",methods:[],displayName:"UnitTableExample"};var O,q,$,G,Q;j.parameters={...j.parameters,docs:{...(O=j.parameters)==null?void 0:O.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
+ }`,...($=(q=j.parameters)==null?void 0:q.docs)==null?void 0:$.source},description:{story:"Story",...(Q=(G=j.parameters)==null?void 0:G.docs)==null?void 0:Q.description}}};const vt=["UnitTableExample"];export{j as UnitTableExample,vt as __namedExportsOrder,ft as default};
@@ -0,0 +1 @@
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-C4AcKcPO.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"./initialize-context-BvejO8yS.js";import"./number-input-Dq8zEk7X.js";import"./input-DTXbDJaL.js";import"./table-Cw1-vdpR.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-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.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};
@@ -509,7 +509,7 @@
509
509
  }
510
510
  </script>
511
511
 
512
- <script type="module" crossorigin src="./assets/iframe-B8VgeFPT.js"></script>
512
+ <script type="module" crossorigin src="./assets/iframe-BOQa8dKi.js"></script>
513
513
  </head>
514
514
 
515
515
  <body>