@oliasoft-open-source/react-ui-library 4.8.1 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-2ftDGfRC.js → Color-KGDBMAHA-CLI1j7TM.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-G3VSiFLs.js → DocsRenderer-PKQXORMH-C-VGLian.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-B3eUVB9V.js → accordion.stories-CjdOndbq.js} +2 -2
- package/dist/storybook/assets/{afe.stories-CSYzQy-o.js → afe.stories-D-uQj_IO.js} +2 -2
- package/dist/storybook/assets/{buttons-and-links-DgWk5FQt.js → buttons-and-links-DLCyz4fu.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-CTf1cpS3.js → casing-loads.stories-Cb2t61c-.js} +2 -2
- package/dist/storybook/assets/{cell.stories-DXApMBee.js → cell.stories-B6XrqnOz.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-CGp4-QUE.js → chunk-HLWAVYOI-B-NqvPla.js} +1 -1
- package/dist/storybook/assets/{color-JX8P2xFz.js → color-DFh0-vFc.js} +1 -1
- package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
- package/dist/storybook/assets/{footer.stories-BobRokDb.js → footer.stories-BxFhNGsz.js} +2 -2
- package/dist/storybook/assets/form.stories-C_zflIAj.js +49 -0
- package/dist/storybook/assets/{formation.stories-xm22XGgs.js → formation.stories-r9JrQX7d.js} +2 -2
- package/dist/storybook/assets/iframe-DOgYbEjR.js +2 -0
- package/dist/storybook/assets/{index-D-0J5wOk.js → index-BIH3zom3.js} +1 -1
- package/dist/storybook/assets/{index-Bh4hgpyc.js → index-MQZw3-wz.js} +4 -4
- package/dist/storybook/assets/{input-group.stories-M4a8AYtB.js → input-group.stories-dQnx3QX0.js} +2 -2
- package/dist/storybook/assets/{input-validation-CRY9hASh.js → input-validation-BhTmzA8C.js} +2 -2
- package/dist/storybook/assets/{inputs-PulLFmNE.js → inputs-BZwMYCXB.js} +2 -2
- package/dist/storybook/assets/layout-forms-j_hFXArR.js +16 -0
- package/dist/storybook/assets/{layout-general-BS3o8j_a.js → layout-general-hZ1fwnpl.js} +1 -1
- package/dist/storybook/assets/{modal.stories-PZXXHpu9.js → modal.stories-B-4WKtnM.js} +2 -2
- package/dist/storybook/assets/{number-input-CEoWDcRg.js → number-input-C8O0lnql.js} +2 -2
- package/dist/storybook/assets/number-input.stories-e-MRb-7_.js +124 -0
- package/dist/storybook/assets/{padding-and-spacing-B4zeG787.js → padding-and-spacing-DZHdCzCJ.js} +1 -1
- package/dist/storybook/assets/{pagination-T__Mixkr.js → pagination-bLx5-m9c.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-C_oRnFX_.js → pagination.stories-BHPRfynZ.js} +2 -2
- package/dist/storybook/assets/popover.stories-DyTPnA5y.js +10 -0
- package/dist/storybook/assets/{preview-_xr6Jbjy.js → preview-_veCKVNG.js} +2 -2
- package/dist/storybook/assets/{preview-D_pdGeyT.js → preview-nWTzJqHS.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-zzDr9Zir.js → reservoirs.stories-C98Z9kS0.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-be871WZn.js → rich-text-input.stories-B2p90wTh.js} +3 -3
- package/dist/storybook/assets/{row.stories-DmNKaTP6.js → row.stories-BRVnImTl.js} +2 -2
- package/dist/storybook/assets/select-BpALjE__.js +61 -0
- package/dist/storybook/assets/{select.stories-CtbKVF6A.js → select.stories-B0d_sE6g.js} +2 -2
- package/dist/storybook/assets/{table-C0QH08M6.js → table-DWBe_npR.js} +1 -1
- package/dist/storybook/assets/{table.stories-safUrF3C.js → table.stories-Cb7lE3nF.js} +2 -2
- package/dist/storybook/assets/{title.stories-By9nz9a2.js → title.stories-TUTSNdwJ.js} +2 -2
- package/dist/storybook/assets/{unit-input.stories-DTP4sTwo.js → unit-input.stories-CRAsgJro.js} +10 -10
- package/dist/storybook/assets/unit-table.stories-BdTJv4W-.js +152 -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/storybook/assets/form.stories-BCg9rFVI.js +0 -49
- package/dist/storybook/assets/iframe-EHZbBy3L.js +0 -2
- package/dist/storybook/assets/layout-forms-Dhgne9wj.js +0 -16
- package/dist/storybook/assets/number-input.stories-DqfU8Xdg.js +0 -110
- package/dist/storybook/assets/popover.stories-B9slHpqQ.js +0 -10
- package/dist/storybook/assets/select-BW0IihoR.js +0 -61
- package/dist/storybook/assets/unit-table.stories-CnyzGe3D.js +0 -152
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import{j as i}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as J}from"./immer.esm-BwVl9PS2.js";import{d as T}from"./index-C0x1JmaP.js";import{G as ne}from"./grid-DRkC-bt8.js";import{S as ae}from"./spacer-BWoNR27H.js";import{w as O,u as d,e as B,f as ie,a as re}from"./index-DMAnyMX5.js";import{C as F}from"./card-EcjmryU9.js";import{F as R}from"./field-C5_fLDpy.js";import{H as _}from"./heading-NkLgQYoP.js";import{S as P}from"./select-BW0IihoR.js";import{T as W}from"./toggle-C0zvrIOF.js";import{l as oe}from"./lodash-c4VUpsOs.js";import{u as le}from"./use-previous-D775JrO6.js";import{T as se,C as G}from"./table-C0QH08M6.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-D2piFfFj.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-T__Mixkr.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-CEoWDcRg.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";const ue=r=>r.reduce(({preferredUnits:o,storageUnits:a},{unitKey:l,preferredUnit:e,storageUnit:b})=>(o[l]=e,a[l]=b,{preferredUnits:o,storageUnits:a}),{preferredUnits:{},storageUnits:{}}),ce=({headers:r,rows:o,selectedUnits:a,storageUnits:l,onChangeUnit:e,convertBackToStorageUnit:b,enableCosmeticRounding:m,enableDisplayRounding:C})=>{const u=r?r.map(c=>({...c,cells:c.cells.map(p=>{var n;if(p.type===G.AUTO_UNIT){const{testId:x,unitKey:g}=p;return{value:a[g],type:G.SELECT,searchable:!1,options:(n=T.getUnitsForQuantity(g))==null?void 0:n.map(U=>({label:T.label(U),value:U})),native:p.native,onChange:U=>e({unitKey:g,value:U.target.value}),testId:x}}return p})})):[],s=o?o.map((c,p)=>({...c,cells:c.cells.map((n,x)=>{if("autoUnit"in n&&(n!=null&&n.autoUnit)&&(typeof(n==null?void 0:n.value)=="string"||typeof(n==null?void 0:n.value)=="number")){const{unitKey:g,value:U,formatDisplayValue:I}=n,V=C&&"roundDisplayValue"in n?n==null?void 0:n.roundDisplayValue:null,h=a[g],y=l[g],t=h!==y,f=t?T.convertAndGetValue(U,h,y):n.value,w=T.isScientificStringNum(U),k=m&&(t||!w)?T.roundToPrecision(f,14):f,S=I?I(k):k;return{...n,value:S,enableCosmeticRounding:m,enableDisplayRounding:C,roundDisplayValue:V,onChange:D=>{const{value:H}=D.target,A=l[g],E=a[g],K=E!==A,j=b?A:E,Z=K?T.convertAndGetValue(H,j,E):H;if("onChange"in n){const{onChange:ee}=n,te={...D,target:{...D.target,value:String(Z),rowIndex:p,cellIndex:x,unit:j}};ee(te)}}}}return n})})):[];return{convertedHeaders:u,convertedRows:s}},X=({table:r,unitConfig:o,convertBackToStorageUnit:a=!0,enableCosmeticRounding:l=!0,enableDisplayRounding:e=!0})=>{const{rows:b,headers:m,...C}=r,{storageUnits:u,preferredUnits:s}=ue(o),c=le(s),[p,n]=v.useState(s),x=({unitKey:h,value:y})=>{n({...p,[h]:y});const t=o.find(f=>f.unitKey===h);t&&typeof t.onChange=="function"&&t.onChange({oldUnit:p[h],newUnit:y,unitKey:h})},g=h=>ce({headers:m,rows:b,selectedUnits:h,storageUnits:u,onChangeUnit:x,convertBackToStorageUnit:a,enableCosmeticRounding:l,enableDisplayRounding:e}),U=g(p),[I,V]=v.useState(U);return v.useEffect(()=>{!oe.isEqual(s,c)&&(Object.keys(s).forEach(y=>{const t=c==null?void 0:c[y],f=s[y];t!==f&&x({unitKey:y,value:f})}),V(g(s)))},[o]),v.useEffect(()=>{V(g(p))},[r,p]),i.jsx(se,{table:{...C,headers:I.convertedHeaders,rows:I.convertedRows}})};X.__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 Tt={title:"Basic/UnitTable",args:{}},de=!0,pe=!0,ge=!0,me=!1,N="m",Y="C",he=3,be=(r,o,a)=>{const l=[o,o,a],e=[...Array(r)].map((b,m)=>{const C=m,u=m+1.25,s=4+m*.25;return[String(C),String(u),String(s)]});return[l,...e]},ye=be(he,N,Y),fe=({reduxTable:r,value:o,unit:a,rowIndex:l,cellIndex:e})=>J(r,b=>{const m=b[0][e],C=(u,s)=>s===0;return b.forEach((u,s)=>{if(C(u,s)){u[e]=a;return}if(s===l+1){u[e]=String(o);return}const c=T.convertAndGetValue(u[e],a,m);u[e]=String(c)}),b}),ve=({reduxTable:r,value:o,rowIndex:a,cellIndex:l})=>J(r,e=>{e[a+1][l]=o}),L=()=>{var h,y;const[r,o]=v.useState(N),[a,l]=v.useState(Y),[e,b]=v.useState(ye),[m,C]=v.useState(de),[u,s]=v.useState(ge),[c,p]=v.useState(pe),[n,x]=v.useState(me),[g,U]=v.useState(N),I=t=>{const{rowIndex:f,cellIndex:w,value:k,unit:S}=t.target,D=n?fe({reduxTable:e,value:k,unit:S,rowIndex:f,cellIndex:w}):ve({reduxTable:e,value:k,rowIndex:f,cellIndex:w});b(D)},V=e.reduce((t,f,w)=>(w===0?t.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"}]}]:t.rows=t.rows.concat({cells:f.map((k,S)=>{const D=w===1&&S===1;return{value:k,type:D?"Text":"NumberInput",unitKey:S===2?"temperature":"length",onChange:I,roundDisplayValue:w===3&&S===2?j=>T.roundByMagnitude(j,2):null,formatDisplayValue:D?j=>`T* ${j}`:null,autoUnit:!0,testId:`testId_${w}_${S}`}})}),t),{testId:"testId",headers:[],rows:[]});return i.jsxs(ne,{columns:"1fr 1fr",gap:!0,children:[i.jsxs(F,{heading:i.jsx(_,{children:"Settings"}),children:[i.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:m,onChange:t=>C(t.target.checked)})}),i.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:u,onChange:t=>s(t.target.checked)})}),i.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:c,onChange:t=>p(t.target.checked)})}),i.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:n,onChange:t=>x(t.target.checked)})})]}),i.jsxs(F,{heading:i.jsx(_,{children:"Unit template"}),children:[i.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(h=T.getUnitsForQuantity("length"))==null?void 0:h.map(t=>({value:t,label:T.label(t)})),value:{value:r},onChange:t=>o(t.target.value),width:"100px"})}),i.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(y=T.getUnitsForQuantity("temperature"))==null?void 0:y.map(t=>({value:t,label:T.label(t)})),value:{value:a},onChange:t=>l(t.target.value),width:"100px"})})]}),i.jsx(F,{heading:i.jsx(_,{children:"Storage State (Redux)"}),children:i.jsx("pre",{children:i.jsx("code",{children:JSON.stringify(e,null,2)})})}),i.jsxs(F,{heading:i.jsx(_,{children:"UnitTable"}),children:[i.jsx(X,{table:V,unitConfig:[{unitKey:"length",storageUnit:e[0][0],preferredUnit:r,onChange:({newUnit:t})=>U(t)},{unitKey:"temperature",storageUnit:e[0][2],preferredUnit:a}],convertBackToStorageUnit:m,enableDisplayRounding:u,enableCosmeticRounding:c}),i.jsx(ae,{height:20}),i.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:g})]})]})};L.play=async({canvasElement:r,step:o})=>{const a=O(r),l=O(r.ownerDocument.body);await o("Can enter decimal values",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123.123456789"),await d.click(r),await B(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await o("Can enter comma decimals (converts to dot)",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123,456"),await d.click(r),await B(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await o("Can enter small numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"0.0000000023"),await d.click(r),await B(e).toHaveDisplayValue("0.00")}),await o("Can enter large numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"999999999999"),await d.click(r),await B(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await o("Shows validation error for non-numeric input",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123x45s6"),await d.click(r),await ie.mouseOver(e),await re(()=>{B(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};L.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"UnitTableExample"};var q,$,Q,M,z;L.parameters={...L.parameters,docs:{...(q=L.parameters)==null?void 0:q.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=($=L.parameters)==null?void 0:$.docs)==null?void 0:Q.source},description:{story:"Story",...(z=(M=L.parameters)==null?void 0:M.docs)==null?void 0:z.description}}};const Ut=["UnitTableExample"];export{L as UnitTableExample,Ut as __namedExportsOrder,Tt as default};
|