@oliasoft-open-source/react-ui-library 4.7.5 → 4.7.7
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/404.html +1 -1
- package/dist/assets/{index-CbZ_B_tn.js → index-DCeIsyRy.js} +1 -0
- package/dist/global.css +576 -576
- package/dist/index.d.ts +5 -0
- package/dist/index.html +1 -1
- package/dist/index.js +1279 -1172
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-DHDKE9Re.js → Color-KGDBMAHA-B09ajdpG.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-BmaBzyAH.js → DocsRenderer-PKQXORMH-B1FePHEE.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-BWUwZ5cN.js → accordion.stories-wRr6K6oi.js} +1 -1
- package/dist/storybook/assets/{afe.stories-CC785MgO.js → afe.stories-80-X2oCf.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-CfkgVoVA.js → buttons-and-links-DrDYbdOk.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-BoG7UuIu.js → casing-loads.stories-BXcv0FiI.js} +1 -1
- package/dist/storybook/assets/{cell.stories-CfiPC1eE.js → cell.stories-MhANINNu.js} +1 -1
- package/dist/storybook/assets/check-box.stories-C_7Z7Ss6.js +126 -0
- package/dist/storybook/assets/{chunk-HLWAVYOI-CuMm7Qpv.js → chunk-HLWAVYOI-3IbBqp3W.js} +1 -1
- package/dist/storybook/assets/{color-DJNturFf.js → color-DqVXeBjc.js} +1 -1
- package/dist/storybook/assets/dialog-Di8hNunM.js +1 -0
- package/dist/storybook/assets/{file-input.stories--ZoISXk0.js → file-input.stories-Jrdw5k-s.js} +1 -1
- package/dist/storybook/assets/{footer.stories-DdUzRiYm.js → footer.stories-CGHFDUfT.js} +1 -1
- package/dist/storybook/assets/{form.stories-CDE7hTBL.js → form.stories-C1Qx3M_1.js} +1 -1
- package/dist/storybook/assets/{formation.stories-vU3zoZ2c.js → formation.stories-BEowxQZ-.js} +1 -1
- package/dist/storybook/assets/iframe-0oHxQxyh.js +2 -0
- package/dist/storybook/assets/index-CF7H4eMJ.js +28 -0
- package/dist/storybook/assets/index-DMAnyMX5.js +179 -0
- package/dist/storybook/assets/{index-DCGYYCUT.js → index-Dx_aqqZM.js} +4 -4
- package/dist/storybook/assets/{index-CQKekHCo.js → index-iPmJVpyV.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-BiReS545.js → input-group.stories-44quIZTV.js} +1 -1
- package/dist/storybook/assets/{input-validation-Bd_JP2WL.js → input-validation-CregAhZZ.js} +2 -2
- package/dist/storybook/assets/{inputs-BsGUQTI3.js → inputs-DZn0C_9Y.js} +4 -4
- package/dist/storybook/assets/{layout-forms-BH-i91Wg.js → layout-forms-zjNDNCOQ.js} +1 -1
- package/dist/storybook/assets/{layout-general-jp5QULaU.js → layout-general-_85zGG_p.js} +1 -1
- package/dist/storybook/assets/menu.stories-mt3LwVCk.js +84 -0
- package/dist/storybook/assets/message-BYzRg8Ae.js +1 -0
- package/dist/storybook/assets/{message.stories-Dmk-t8hM.js → message.stories-K3bQ-5bJ.js} +1 -1
- package/dist/storybook/assets/modal.stories-Cct1SMOP.js +220 -0
- package/dist/storybook/assets/number-input.stories-C2QTTzzN.js +110 -0
- package/dist/storybook/assets/{padding-and-spacing-D7O49YoW.js → padding-and-spacing-CPgb4ZMT.js} +1 -1
- package/dist/storybook/assets/{pagination-DzpYFhAO.js → pagination-iSMIbR33.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-CJwR-XAD.js → pagination.stories-BUPaZD5R.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-Hox7vJnl.js → pop-confirm.stories-Dhid1FK8.js} +1 -1
- package/dist/storybook/assets/{popover.stories-L5z549ww.js → popover.stories-Duemqiqp.js} +1 -1
- package/dist/storybook/assets/{preview-DOYx8RvS.js → preview-Bay6IiqP.js} +1 -1
- package/dist/storybook/assets/preview-DLBQXbKW.js +1 -0
- package/dist/storybook/assets/{preview-Bq2bLcjv.js → preview-DrVrew0c.js} +2 -2
- package/dist/storybook/assets/radio-button.stories-CGJnfCk-.js +71 -0
- package/dist/storybook/assets/{reservoirs.stories-WKT7gCnp.js → reservoirs.stories-aSZ9r1Pu.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-RjuY6LDo.js → rich-text-input.stories-CsFyrKRA.js} +1 -1
- package/dist/storybook/assets/{row.stories-B6IcyamO.js → row.stories-DL2h5FzP.js} +1 -1
- package/dist/storybook/assets/select-C8iu4-uz.js +40 -0
- package/dist/storybook/assets/select.stories-BZFdXGPs.js +579 -0
- package/dist/storybook/assets/{smart-upload-modal.stories-OBY4Jc5w.js → smart-upload-modal.stories-BmrhOtOG.js} +1 -1
- package/dist/storybook/assets/{table-BOVkj1wL.js → table-BNMxYhsu.js} +1 -1
- package/dist/storybook/assets/{table.stories-CdFHs6Xl.js → table.stories-YV04PKkU.js} +1 -1
- package/dist/storybook/assets/{title.stories-DT3HSIHi.js → title.stories-CuiMnOil.js} +1 -1
- package/dist/storybook/assets/toaster-BNO0suPv.js +1 -0
- package/dist/storybook/assets/toaster.stories-zcWIPp_X.js +89 -0
- package/dist/storybook/assets/toggle.stories-mjk0JIle.js +141 -0
- package/dist/storybook/assets/unit-input.stories-B3VwXCO8.js +295 -0
- package/dist/storybook/assets/unit-table.stories-DQrTQd6a.js +152 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.html +6 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/sb-addons/interactions-2/manager-bundle.js +233 -0
- package/dist/storybook/sb-addons/storybook-dark-mode-esm-preset-3/manager-bundle.js.LEGAL.txt +0 -0
- package/package.json +1 -1
- package/dist/storybook/assets/check-box.stories-L9T_i0RT.js +0 -102
- package/dist/storybook/assets/dialog-IAPGkLet.js +0 -1
- package/dist/storybook/assets/iframe-CgUc-Ukp.js +0 -2
- package/dist/storybook/assets/menu.stories-CSSvL08X.js +0 -82
- package/dist/storybook/assets/message-ZenLdkrf.js +0 -1
- package/dist/storybook/assets/modal.stories-BVttWvlZ.js +0 -200
- package/dist/storybook/assets/number-input.stories-CVFfJvjY.js +0 -97
- package/dist/storybook/assets/radio-button.stories-Bg5JVXpo.js +0 -61
- package/dist/storybook/assets/select-D55JvDou.js +0 -40
- package/dist/storybook/assets/select.stories-2DiOP0OZ.js +0 -914
- package/dist/storybook/assets/toaster-B8A3xIYu.js +0 -1
- package/dist/storybook/assets/toaster.stories-B61l_zxQ.js +0 -86
- package/dist/storybook/assets/toggle.stories-D4c4fr5t.js +0 -117
- package/dist/storybook/assets/unit-input.stories-DyeptPz2.js +0 -290
- package/dist/storybook/assets/unit-table.stories-BAVqAbfG.js +0 -150
- /package/dist/storybook/sb-addons/{storybook-dark-mode-esm-preset-2 → interactions-2}/manager-bundle.js.LEGAL.txt +0 -0
- /package/dist/storybook/sb-addons/{storybook-dark-mode-esm-preset-2 → storybook-dark-mode-esm-preset-3}/manager-bundle.js +0 -0
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as z}from"./immer.esm-BwVl9PS2.js";import{d as U}from"./index-CWz-hU-f.js";import{G as Z}from"./grid-B6LFPf51.js";import{S as ee}from"./spacer-BWoNR27H.js";import{C as F}from"./card-EcjmryU9.js";import{F as L}from"./field-HrLaMLbx.js";import{H as W}from"./heading-CRNoBc7q.js";import{S as P}from"./select-D55JvDou.js";import{T as I}from"./toggle-CBpNgTrm.js";import{l as te}from"./lodash-BHd_uQHh.js";import{u as ne}from"./use-previous-D775JrO6.js";import{T as ae,C as _}from"./table-BOVkj1wL.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-Bf0q9Yjk.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-UmZ4Y_CR.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-CHgr8eL8.js";import"./button-VxhoNhrV.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-DIKP56UZ.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-DzpYFhAO.js";import"./input-BW9trNAW.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-uQOVHv2N.js";import"./check-box-BtCGePRy.js";import"./slider-DAramr8j.js";import"./index-BI4_Bp97.js";import"./popover-CzZdWNnB.js";const ie=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:h})=>(i[s]=a,r[s]=h,{preferredUnits:i,storageUnits:r}),{preferredUnits:{},storageUnits:{}}),re=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:h,enableCosmeticRounding:g,enableDisplayRounding:y})=>{const u=l?l.map(d=>({...d,cells:d.cells.map(c=>{var t;if(c.type===_.AUTO_UNIT){const{testId:C,unitKey:p}=c;return{value:r[p],type:_.SELECT,searchable:!1,options:(t=U.getUnitsForQuantity(p))==null?void 0:t.map(T=>({label:U.label(T),value:T})),native:c.native,onChange:T=>a({unitKey:p,value:T.target.value}),testId:C}}return c})})):[],o=i?i.map((d,c)=>({...d,cells:d.cells.map((t,C)=>{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:w}=t,j=y&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,m=r[p],b=s[p],e=m!==b,f=e?U.convertAndGetValue(T,m,b):t.value,x=U.isScientificStringNum(T),D=g&&(e||!x)?U.roundToPrecision(f,14):f,R=w?w(D):D;return{...t,value:R,enableCosmeticRounding:g,enableDisplayRounding:y,roundDisplayValue:j,onChange:S=>{const{value:B}=S.target,A=s[p],E=r[p],N=E!==A,k=h?A:E,$=N?U.convertAndGetValue(B,k,E):B;if("onChange"in t){const{onChange:X}=t,Y={...S,target:{...S.target,value:String($),rowIndex:c,cellIndex:C,unit:k}};X(Y)}}}}return t})})):[];return{convertedHeaders:u,convertedRows:o}},M=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:h,headers:g,...y}=l,{storageUnits:u,preferredUnits:o}=ie(i),d=ne(o),[c,t]=v.useState(o),C=({unitKey:m,value:b})=>{t({...c,[m]:b});const e=i.find(f=>f.unitKey===m);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:c[m],newUnit:b,unitKey:m})},p=m=>re({headers:g,rows:h,selectedUnits:m,storageUnits:u,onChangeUnit:C,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),T=p(c),[w,j]=v.useState(T);return v.useEffect(()=>{!te.isEqual(o,d)&&(Object.keys(o).forEach(b=>{const e=d==null?void 0:d[b],f=o[b];e!==f&&C({unitKey:b,value:f})}),j(p(o)))},[i]),v.useEffect(()=>{j(p(c))},[l,c]),n.jsx(ae,{table:{...y,headers:w.convertedHeaders,rows:w.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 ct={title:"Basic/UnitTable",args:{}},oe=!0,le=!0,se=!0,ue=!1,H="m",J="C",de=3,ce=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((h,g)=>{const y=g,u=g+1.25,o=4+g*.25;return[String(y),String(u),String(o)]});return[s,...a]},pe=ce(de,H,J),ge=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>z(l,h=>{const g=h[0][a],y=(u,o)=>o===0;return h.forEach((u,o)=>{if(y(u,o)){u[a]=r;return}if(o===s+1){u[a]=String(i);return}const d=U.convertAndGetValue(u[a],r,g);u[a]=String(d)}),h}),me=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>z(l,a=>{a[r+1][s]=i}),V=()=>{var m,b;const[l,i]=v.useState(H),[r,s]=v.useState(J),[a,h]=v.useState(pe),[g,y]=v.useState(oe),[u,o]=v.useState(se),[d,c]=v.useState(le),[t,C]=v.useState(ue),[p,T]=v.useState(H),w=e=>{const{rowIndex:f,cellIndex:x,value:D,unit:R}=e.target,S=t?ge({reduxTable:a,value:D,unit:R,rowIndex:f,cellIndex:x}):me({reduxTable:a,value:D,rowIndex:f,cellIndex:x});h(S)},j=a.reduce((e,f,x)=>(x===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((D,R)=>{const S=x===1&&R===1;return{value:D,type:S?"Text":"NumberInput",unitKey:R===2?"temperature":"length",onChange:w,roundDisplayValue:x===3&&R===2?k=>U.roundByMagnitude(k,2):null,formatDisplayValue:S?k=>`T* ${k}`:null,autoUnit:!0}})}),e),{headers:[],rows:[]});return n.jsxs(Z,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(F,{heading:n.jsx(W,{children:"Settings"}),children:[n.jsx(L,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:g,onChange:e=>y(e.target.checked)})}),n.jsx(L,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:u,onChange:e=>o(e.target.checked)})}),n.jsx(L,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:d,onChange:e=>c(e.target.checked)})}),n.jsx(L,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:t,onChange:e=>C(e.target.checked)})})]}),n.jsxs(F,{heading:n.jsx(W,{children:"Unit template"}),children:[n.jsx(L,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(P,{options:(m=U.getUnitsForQuantity("length"))==null?void 0:m.map(e=>({value:e,label:U.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(P,{options:(b=U.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:U.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(F,{heading:n.jsx(W,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(F,{heading:n.jsx(W,{children:"UnitTable"}),children:[n.jsx(M,{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:g,enableDisplayRounding:u,enableCosmeticRounding:d}),n.jsx(ee,{height:20}),n.jsx(L,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:p})]})]})};V.__docgenInfo={description:"",methods:[],displayName:"UnitTablePrototype"};var K,G,O,q,Q;V.parameters={...V.parameters,docs:{...(K=V.parameters)==null?void 0:K.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
|
-
};
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return acc;
|
|
85
|
-
}, {
|
|
86
|
-
headers: ([] as any[]),
|
|
87
|
-
rows: ([] as IUnitTableRow[])
|
|
88
|
-
});
|
|
89
|
-
return <Grid columns="1fr 1fr" gap>
|
|
90
|
-
<Card heading={<Heading>Settings</Heading>}>
|
|
91
|
-
<Field label="Convert back to storage unit:" labelLeft labelWidth={200}>
|
|
92
|
-
<Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
|
|
93
|
-
</Field>
|
|
94
|
-
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
95
|
-
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
96
|
-
</Field>
|
|
97
|
-
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
98
|
-
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
99
|
-
</Field>
|
|
100
|
-
<Field label="Convert whole table:" labelLeft labelWidth={200}>
|
|
101
|
-
<Toggle checked={convertWholeTable} onChange={evt => setConvertWholeTable(evt.target.checked)} />
|
|
102
|
-
</Field>
|
|
103
|
-
</Card>
|
|
104
|
-
<Card heading={<Heading>Unit template</Heading>}>
|
|
105
|
-
<Field label="Length unit:" labelLeft labelWidth={120}>
|
|
106
|
-
<Select options={getUnitsForQuantity('length')?.map(unit => ({
|
|
107
|
-
value: unit,
|
|
108
|
-
label: label(unit)
|
|
109
|
-
}))} value={{
|
|
110
|
-
value: preferredLengthUnit
|
|
111
|
-
}} onChange={evt => setPreferredLengthUnit(evt.target.value)} width="100px" />
|
|
112
|
-
</Field>
|
|
113
|
-
<Field label="Temperature unit:" labelLeft labelWidth={120}>
|
|
114
|
-
<Select options={getUnitsForQuantity('temperature')?.map(unit => ({
|
|
115
|
-
value: unit,
|
|
116
|
-
label: label(unit)
|
|
117
|
-
}))} value={{
|
|
118
|
-
value: preferredTemperatureUnit
|
|
119
|
-
}} onChange={evt => setPreferredTemperatureUnit(evt.target.value)} width="100px" />
|
|
120
|
-
</Field>
|
|
121
|
-
</Card>
|
|
122
|
-
<Card heading={<Heading>Storage State (Redux)</Heading>}>
|
|
123
|
-
<pre>
|
|
124
|
-
<code>{JSON.stringify(reduxTable, null, 2)}</code>
|
|
125
|
-
</pre>
|
|
126
|
-
</Card>
|
|
127
|
-
<Card heading={<Heading>UnitTable</Heading>}>
|
|
128
|
-
<UnitTable table={tableViewData}
|
|
129
|
-
//New props:
|
|
130
|
-
unitConfig={[{
|
|
131
|
-
unitKey: 'length',
|
|
132
|
-
storageUnit: reduxTable[0][0],
|
|
133
|
-
preferredUnit: preferredLengthUnit,
|
|
134
|
-
onChange: ({
|
|
135
|
-
newUnit
|
|
136
|
-
}) => setDisplayedLengthUnit(newUnit)
|
|
137
|
-
}, {
|
|
138
|
-
unitKey: 'temperature',
|
|
139
|
-
storageUnit: reduxTable[0][2],
|
|
140
|
-
preferredUnit: preferredTemperatureUnit
|
|
141
|
-
}]}
|
|
142
|
-
//Most tables should just use the default values here (true):
|
|
143
|
-
convertBackToStorageUnit={convertBackToStorageUnit} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} />
|
|
144
|
-
<Spacer height={20} />
|
|
145
|
-
<Field label="Displayed length unit:" labelLeft labelWidth={150}>
|
|
146
|
-
{displayedLengthUnit}
|
|
147
|
-
</Field>
|
|
148
|
-
</Card>
|
|
149
|
-
</Grid>;
|
|
150
|
-
}`,...(O=(G=V.parameters)==null?void 0:G.docs)==null?void 0:O.source},description:{story:"Story",...(Q=(q=V.parameters)==null?void 0:q.docs)==null?void 0:Q.description}}};const pt=["UnitTablePrototype"];export{V as UnitTablePrototype,pt as __namedExportsOrder,ct as default};
|
|
File without changes
|