@oliasoft-open-source/react-ui-library 4.4.8 → 4.5.0-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/index.d.ts +55 -0
- package/dist/index.js +209 -8
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-6VNJS4EI-mlGeGy0N.js → Color-6VNJS4EI-OKUPsN5g.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-NNNQARDV-FLE8MQVp.js → DocsRenderer-NNNQARDV-GtO0h5cy.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-4HIR6TLV-gwf45DIV.js → WithTooltip-4HIR6TLV-oJGDwI7F.js} +1 -1
- package/dist/storybook/assets/accordion-with-default-toggle-8PUIm8jP.js +1 -0
- package/dist/storybook/assets/accordion.stories-xUgAzm87.js +170 -0
- package/dist/storybook/assets/{afe.stories-u2K3NwaR.js → afe.stories-fh4-T0m2.js} +1 -1
- package/dist/storybook/assets/breadcrumb-WFZ7OoC2.js +1 -0
- package/dist/storybook/assets/breadcrumb.stories-mou0ppaX.js +1 -0
- package/dist/storybook/assets/{button.stories-f6VcbEgi.js → button.stories-PhWmZXOu.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-t1EEC4gc.js → buttons-and-links-mIhXkKfh.js} +2 -2
- package/dist/storybook/assets/{casing-loads.stories-ee6r2j2Q.js → casing-loads.stories-i9Kyuvs1.js} +1 -1
- package/dist/storybook/assets/{cell.stories-y081eSUk.js → cell.stories-QHDggPeA.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-53hWDdvc.js → chunk-HLWAVYOI-YpA4-WPj.js} +1 -1
- package/dist/storybook/assets/{color-LlgCLGE5.js → color-0ogqq8EH.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-ezk4vO0w.js → drawer.stories-BLdyJ3NA.js} +1 -1
- package/dist/storybook/assets/empty-PU0JdhZM.js +1 -0
- package/dist/storybook/assets/empty.stories-FYO6syUx.js +1 -0
- package/dist/storybook/assets/file-input-7-7kYhsS.js +1 -0
- package/dist/storybook/assets/file-input.stories-lW0gLK14.js +66 -0
- package/dist/storybook/assets/{flex-3eLDDUyy.js → flex-RYZsoWEN.js} +1 -1
- package/dist/storybook/assets/{flex.stories-_VBDAVzN.js → flex.stories-lLz0Xrt_.js} +1 -1
- package/dist/storybook/assets/{footer.stories-m5VFK6Bo.js → footer.stories-guoNYzr9.js} +1 -1
- package/dist/storybook/assets/{form.stories-z3f6tVdU.js → form.stories-tzZoKyyL.js} +1 -1
- package/dist/storybook/assets/{formatter-SWP5E3XI-TLomX0jS.js → formatter-SWP5E3XI-Z60pYM_f.js} +1 -1
- package/dist/storybook/assets/{preview-QdB_aBj_.css → global-M-3dCKk3.css} +1 -1
- package/dist/storybook/assets/{heading.stories-DmZLaZJb.js → heading.stories-HLMPkIPo.js} +1 -1
- package/dist/storybook/assets/{icon.stories-h0hheUmg.js → icon.stories-W-UgTWyK.js} +1 -1
- package/dist/storybook/assets/iframe-ybuSzuG4.js +7 -0
- package/dist/storybook/assets/{index-0dxTfrBP.js → index-isA0pQQP.js} +5 -5
- package/dist/storybook/assets/{input-validation-jCRmk_jl.js → input-validation-lBeNJX0o.js} +1 -1
- package/dist/storybook/assets/{inputs-ZpY3-Ny4.js → inputs-bYS5qR_g.js} +14 -14
- package/dist/storybook/assets/{layout-forms-tcQfdK2L.js → layout-forms-S1UZag29.js} +1 -1
- package/dist/storybook/assets/{layout-general-bz1oHjNF.js → layout-general-U3YRmnqR.js} +1 -1
- package/dist/storybook/assets/{list-8l-RGDgw.js → list-dAlCO11z.js} +1 -1
- package/dist/storybook/assets/{list.stories-uR6izjvO.js → list.stories-bt_cumRX.js} +1 -1
- package/dist/storybook/assets/{list.stories-data-9RrIjRci.js → list.stories-data-IcFu6vvd.js} +1 -1
- package/dist/storybook/assets/{menu.stories-5G4phywO.js → menu.stories-VwRF_Pbx.js} +1 -1
- package/dist/storybook/assets/{menu.stories-data-l5rlcD9_.js → menu.stories-data-hEz8P1yK.js} +1 -1
- package/dist/storybook/assets/{message-uMHaTEXV.js → message-yii7x6Na.js} +1 -1
- package/dist/storybook/assets/{message.stories-CDgUaLZP.js → message.stories-9RWD3-p1.js} +1 -1
- package/dist/storybook/assets/meta-content-2S9BpSoX.js +1 -0
- package/dist/storybook/assets/modal-BJKGBCkS.css +1 -0
- package/dist/storybook/assets/modal-Dr5HffrG.js +1 -0
- package/dist/storybook/assets/{modal.stories-15sY1c5H.js → modal.stories-rVfow_s3.js} +1 -1
- package/dist/storybook/assets/option-dropdown-6QvoS02o.js +1 -0
- package/dist/storybook/assets/option-dropdown.stories-5qw-N2Q9.js +21 -0
- package/dist/storybook/assets/{padding-and-spacing-dSuzf2dz.js → padding-and-spacing-Ej5fu8GG.js} +1 -1
- package/dist/storybook/assets/page.stories-4zM8wrxN.js +57 -0
- package/dist/storybook/assets/pop-confirm-nfz5S-f-.js +1 -0
- package/dist/storybook/assets/pop-confirm.stories-1vIAhdl-.js +9 -0
- package/dist/storybook/assets/{popover.stories-bWBLR9fB.js → popover.stories-b7Tt4S0j.js} +1 -1
- package/dist/storybook/assets/{preview-8q_cpMjL.js → preview-8d3sl769.js} +2 -2
- package/dist/storybook/assets/{preview-xbxc--KY.js → preview-UZXZGus9.js} +3 -3
- package/dist/storybook/assets/preview-agc3Xxfb.css +1 -0
- package/dist/storybook/assets/print-header-mVYWFles.js +1 -0
- package/dist/storybook/assets/{projects.stories-84p22lkF.js → projects.stories-bo3cPOP-.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-CtIlcj-X.js → reservoirs.stories-RUFcw2h6.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-7UzvJ-A1.js → rich-text-input-W-kYpvgO.js} +52 -127
- package/dist/storybook/assets/rich-text-input.stories-6-587T_0.js +76 -0
- package/dist/storybook/assets/{row.stories-uPD-qTX2.js → row.stories-TurDc49t.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-0_pud_bN.js → side-bar.stories-sxBJCVnV.js} +1 -1
- package/dist/storybook/assets/{site.stories-UH3PK5eu.js → site.stories-Hnwa5Rxk.js} +1 -1
- package/dist/storybook/assets/{spacer.stories-bgTBb3VB.js → spacer.stories-eCrKj4b3.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-NMPM6SWI-1xSal2rv.js → syntaxhighlighter-NMPM6SWI-LVCFR00p.js} +1 -1
- package/dist/storybook/assets/{table.stories-GrJ75DyI.js → table.stories-TGOwb9FU.js} +1 -1
- package/dist/storybook/assets/{table.stories-data-9XfBJddg.js → table.stories-data-txTr9mYv.js} +1 -1
- package/dist/storybook/assets/text-link-1uKYQqn_.js +1 -0
- package/dist/storybook/assets/text-link.stories-ZcuOY5VK.js +1 -0
- package/dist/storybook/assets/{textarea-u-nirfI6.js → textarea-8bcldTyf.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-Hl-oeUWU.js → textarea.stories-D9SctTMD.js} +1 -1
- package/dist/storybook/assets/{title.stories-RyQ9x-ug.js → title.stories-InoCrXr8.js} +1 -1
- package/dist/storybook/assets/{toaster-eOozfa7U.js → toaster-2HasMRmP.js} +1 -1
- package/dist/storybook/assets/{toaster.stories--z_U2gRN.js → toaster.stories-NBYloz0_.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-HiGs6slZ.js → toggle.stories-aVmjpons.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-3T_tzhJs.js → tooltip.test-case.stories-kIeZayHw.js} +1 -1
- package/dist/storybook/assets/tree-Rhl5ea49.js +6 -0
- package/dist/storybook/assets/tree.stories-dFH-G6se.js +123 -0
- package/dist/storybook/assets/unit-input-fxjK7nON.js +1 -0
- package/dist/storybook/assets/unit-input.stories--UApgPT-.js +273 -0
- package/dist/storybook/assets/unit-table.stories-Vd1Nqk2h.js +434 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/404.html +0 -1
- package/dist/storybook/assets/accordion.stories-yWtLkrNK.js +0 -170
- package/dist/storybook/assets/breadcrumb.stories-V7ozYBO-.js +0 -1
- package/dist/storybook/assets/dialog-WKHRZcjc.js +0 -1
- package/dist/storybook/assets/dialog-gTGZ42G6.css +0 -1
- package/dist/storybook/assets/empty.stories-lva3DbfI.js +0 -1
- package/dist/storybook/assets/file-input.stories-6NjWeNyC.js +0 -66
- package/dist/storybook/assets/iframe-ujjJUTtn.js +0 -7
- package/dist/storybook/assets/list-heading-Vd3hu5Pf.js +0 -1
- package/dist/storybook/assets/option-dropdown.stories-Q2zd2AcS.js +0 -21
- package/dist/storybook/assets/page.stories-9XUTUblI.js +0 -57
- package/dist/storybook/assets/pop-confirm.stories-_agvSFJd.js +0 -9
- package/dist/storybook/assets/text-link.stories-kjfUeFtk.js +0 -1
- package/dist/storybook/assets/tree.stories-_5t-Rrls.js +0 -128
- package/dist/storybook/assets/unit-input.stories-u823izRm.js +0 -273
- /package/dist/storybook/assets/{accordion-tw1O4Ru6.css → accordion-with-default-toggle-tw1O4Ru6.css} +0 -0
- /package/dist/storybook/assets/{list-heading-Y8BAUuV6.css → meta-content-Y8BAUuV6.css} +0 -0
- /package/dist/storybook/assets/{page-6iak35D6.css → print-header-6iak35D6.css} +0 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as w}from"./index-RfLt4OUa.js";import{d as v}from"./index-IQMsp8Ab.js";import{G as R}from"./grid-u1mZpaML.js";import{F as _}from"./form-row-bwoDTUga.js";import{C as I}from"./card-0r8RRVk-.js";import{F as $}from"./field-eknsj_Ll.js";import{H as x}from"./heading-Bk0bpNfe.js";import{S as L}from"./select-JjEPivho.js";/* empty css */import"./accordion-6_27SROY.js";import"./accordion-with-default-toggle-8PUIm8jP.js";import{M as ie}from"./actions-Z9jDWreP.js";import"./badge-23Ty_zBt.js";import"./breadcrumb-WFZ7OoC2.js";import{B as oe}from"./button-7V8oA22w.js";import"./button-group-q8QKkLVU.js";import"./check-box-LZdXXKhv.js";import"./row-vFUhHoz5.js";import"./divider-RwW2f_N0.js";import"./modal-Dr5HffrG.js";import"./drawer-WuErQ5Z8.js";import"./empty-PU0JdhZM.js";import"./file-input-7-7kYhsS.js";import"./flex-RYZsoWEN.js";import{I as se}from"./icon-y1a2N5SZ.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./help-icon--rUDxLUD.js";import"./input-u1He-wWs.js";import"./label-0_Qf6I8t.js";import"./list-dAlCO11z.js";import"./meta-content-2S9BpSoX.js";import"./loader-TGOJBZQG.js";import"./message-yii7x6Na.js";import"./option-dropdown-6QvoS02o.js";import"./page-9-f6BzS0.js";import"./pagination-5n5spTRo.js";import"./popover-Y3FpGdUS.js";import"./portal-zPiHHKoC.js";import"./print-header-mVYWFles.js";import"./progress-bar-NRjN2baY.js";import"./radio-button-jHcwHUA4.js";import"./rich-text-input-W-kYpvgO.js";import"./side-bar-Fjr2t9MT.js";import"./slider-nl2rJ9LF.js";import"./spacer-Yji9g2AW.js";import"./spinner-R8Il4aRe.js";import{T as de}from"./table-lfeSnryj.js";import"./tabs-fcLbHC1n.js";import"./text-6KQ6ntOV.js";import"./text-link-1uKYQqn_.js";import"./textarea-8bcldTyf.js";import"./toaster-2HasMRmP.js";import"./toggle-BPI2y-lU.js";import"./tooltip-HEHiU__l.js";import"./top-bar-3dxv0sp9.js";import"./pop-confirm-nfz5S-f-.js";import"./tree-Rhl5ea49.js";import"./number-input-SvjJIGsW.js";import"./unit-input-fxjK7nON.js";import{l as ue}from"./lodash-Bmg8FrMx.js";import"./disabled-context-urNQThQz.js";import"./index-cCpkwrS5.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./common-types-U65vzrrz.js";import"./types-5uVBABF4.js";import"./index-4QtD-hFu.js";import"./extends-dGVwEr9R.js";import"./assertThisInitialized-4q6YPdh3.js";import"./inheritsLoose-Y9jOMJLd.js";import"./memoize-one.esm-hqe5SRxC.js";import"./types-VB5zD18b.js";import"./select.input-zP5tW20f.js";import"./index-miLrID2P.js";import"./index.es-JXn3JM7k.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./index-ugi_ZH6T.js";const D=Object.freeze({ARRAY:"array",OBJECT:"object"}),pe=({tableDef:t,displayedUnits:l,handleUnitChange:m,oldStructureType:g})=>t.map(({convertible:d,unitKey:y,key:i},b)=>{var u;if(!d)return{value:""};const f=g===D.ARRAY?l[b]:l[i],c=(u=v.getAltUnitsListByQuantity(y))==null?void 0:u.map(({unit:p,label:a})=>({label:a,value:p}));return{value:f,options:c,type:"Select",onChange:({target:{value:p}})=>{p!==f&&m(i,p,b)}}}),ce=({tableDef:t})=>t.map(({header:l})=>({value:l})),me=(t,l,m,g)=>{if(!(t!=null&&t.length))return[];let d;const y=ue.cloneDeep(t);g&&([d]=y.splice(0,1));const i=y.map(b=>m.reduce((c,o,u)=>{const{key:p,defaultValue:a}=o,n=g===D.ARRAY?l[u]:l[p],h=g===D.ARRAY?d[u]:d==null?void 0:d[p],s=g===D.ARRAY?b[u]:b[p];let r=s??a;if(h&&n&&(r=v.convertAndGetValue(r,n,h)),g){if(g===D.ARRAY)return b[u]=r,b}else if(v.isValueWithUnit(s)&&n){const T=v.convertAndGetValue(r,n);r=v.isNumeric(T)?v.withUnit(T,n):r}return{...c,[p]:r}},{}));return g?[l,...i]:i},ge=(t,l,m)=>({label:"Add",icon:"plus",primary:!0,onClick:()=>t(l,m),testId:"lithology-table-add-new-row"}),M=(t,l,m)=>m===D.ARRAY?t.reduce((g,d,y)=>{const{unitKey:i}=d;return g[y]=l[i],g},[]):t.reduce((g,d)=>{const{key:y,unitKey:i}=d;return{...g,[y]:l[i]}},{}),he=({rows:t,tableDef:l,displayedUnits:m,handleUnitChange:g,tableActions:d,oldStructureType:y=D.OBJECT})=>{if(!t)return{rows:[],headers:[]};const{addRow:i}=d;return{headers:[{cells:ce({tableDef:l}),actions:i?[ge(i,t,m)]:[]},{cells:pe({tableDef:l,displayedUnits:m,handleUnitChange:g,oldStructureType:y})}],rows:t}},U=({data:t,unitTemplate:l,tableDef:m,convertToCells:g,tableActions:d,testId:y,oldStructureType:i=D.OBJECT})=>{const[b,f]=w.useState(M(m,l,i));w.useEffect(()=>{f(M(m,l,i))},[l]);const c=(p,a,n)=>{i===D.ARRAY?f(h=>{const s=[...h];return s[n]=a,s}):f(h=>({...h,[p]:a}))},{headers:o,rows:u}=w.useMemo(()=>he({rows:g(me(t,b,m,i),b),tableDef:m,displayedUnits:b,handleUnitChange:c,tableActions:d,oldStructureType:i}),[b,t]);return e.jsx(de,{table:{testId:y,headers:o,rows:u,columnAlignment:m.map(p=>p.columnAlignment),columnWidths:m.map(p=>p.columnWidth),fixedWidth:"auto"},onListReorder:(d==null?void 0:d.reorderComponents)||void 0})};try{U.displayName="UnitTable",U.__docgenInfo={description:"",displayName:"UnitTable",props:{data:{defaultValue:null,description:"",name:"data",required:!0,type:{name:"any[]"}},unitTemplate:{defaultValue:null,description:"",name:"unitTemplate",required:!0,type:{name:"Record<string, any>"}},tableDef:{defaultValue:null,description:"",name:"tableDef",required:!0,type:{name:"ITableDefinition[]"}},convertToCells:{defaultValue:null,description:"",name:"convertToCells",required:!0,type:{name:"(displayedData: any[], displayedUnits: Record<string, any>) => { cells: ICell[]; actions: IActionsType; }[]"}},tableActions:{defaultValue:null,description:"",name:"tableActions",required:!0,type:{name:"ITableActions"}},oldStructureType:{defaultValue:{value:"object"},description:"",name:"oldStructureType",required:!1,type:{name:"string | null"}},testId:{defaultValue:null,description:"",name:"testId",required:!0,type:{name:"string"}}}}}catch{}const be="#ff6600",ye=({onDeleteTableRow:t,rowid:l})=>{let m=[{type:"Option",label:"Delete",icon:e.jsx(se,{icon:"delete",color:be}),onClick:()=>t(l)}];return e.jsx(ie,{menu:{trigger:"Component",component:e.jsx(oe,{small:!0,basic:!0,round:!0,colored:"muted",icon:"menu",testId:`row-menu-${l}`}),sections:m}})};try{tablerowmenu.displayName="tablerowmenu",tablerowmenu.__docgenInfo={description:"",displayName:"tablerowmenu",props:{onDeleteTableRow:{defaultValue:null,description:"",name:"onDeleteTableRow",required:!0,type:{name:"(rowid: number) => void"}},rowid:{defaultValue:null,description:"",name:"rowid",required:!0,type:{name:"number"}}}}}catch{}const ve=["Rock","Sandstone"],te=ve.map(t=>({label:t,value:t})),fe=[{Cp:"1256.039|J/(kg*degC)",Ro:"2243|kg/m3",name:"Utsira Formation",Lambda:"1.591|W/(mK)",depth_to:"1200|m",rock_type:"Rock",depth_from:"385|m"},{Cp:"1300|J/(kg*degC)",Ro:"2200|kg/m3",name:"Sele Formation",Lambda:"1.591|W/(mK)",depth_to:"1600|m",rock_type:"Sandstone",depth_from:"1200|m"},{Cp:"1256.039|J/(kg*degC)",Ro:"2243|kg/m3",name:"Lista Formation",Lambda:"1.591|W/(mK)",depth_to:"1950|m",rock_type:"Rock",depth_from:"1600|m"},{Cp:"1256.039|J/(kg*degC)",Ro:"2243|kg/m3",name:"Våge Formation",Lambda:"1.591|W/(mK)",depth_to:"2200|m",rock_type:"Rock",depth_from:"1950|m"}],we=[{key:"rock_type",header:"Rock",translationKey:"rock",defaultValue:"",type:"Select",convertible:!1,unitKey:"",columnAlignment:"left",columnWidth:"150px",options:te},{key:"name",header:"Formation name",translationKey:"name",placeholder:"Formation Name",type:"Input",disabled:!1,convertible:!1,unitKey:"",columnAlignment:"left",columnWidth:"160px"},{key:"depth_from",header:"Top Depth (TVD)",translationKey:"top_depth",type:"NumberInput",disabled:!1,convertible:!0,unitKey:"length",columnAlignment:"right",columnWidth:"150px"},{key:"depth_to",header:"Bottom Depth (TVD)",translationKey:"bottom_depth",type:"NumberInput",disabled:!1,convertible:!0,unitKey:"length",columnAlignment:"right",columnWidth:"160px"},{key:"Ro",header:"Density",translationKey:"ro",type:"NumberInput",defaultValue:0,disabled:!0,convertible:!0,unitKey:"density",columnAlignment:"right",columnWidth:"100px"},{key:"Cp",header:"Specific Heat Capacity",translationKey:"cp",type:"NumberInput",defaultValue:0,unitKey:"specificHeatCapacity",disabled:!0,convertible:!0,columnWidth:"150px",columnAlignment:"right"},{key:"Lambda",header:"Thermal Conductivity",translationKey:"cp",type:"NumberInput",unitKey:"thermalConductivity",disabled:!0,convertible:!0,defaultValue:0,columnWidth:"150px",columnAlignment:"right"}],H={acceleration:"ft/s2",angleGradient:"deg/100ft",angles:"deg",areaOther:"ft2",areaTubular:"in2",blowoutFlowRate:"STB/d",blowoutGasFlowRate:"MMSCFD",blowoutOilFlowRate:"STB/d",density:"ppg",densityGas:"Glbm/ft3",densityOil:"lbm/ft3",densityOilGas:"lbm/ft3",densitySolid:"lbm/ft3",depth:"ft",diameters:"cm",distance:"ft",doglegSeverity:"deg/100ft",duration:"min",durationLong:"d",durationShort:"h",flowrate:"bpm",fluidCompressibility:"1/psi",force:"lbf",forceGradient:"lbf/ft",frequency:"Hz",gasliftFlowRate:"STB/d",gasVolume:"MMSCF",gor:"SCF/STB",height:"ft",inflowProductivityIndex:"STB/d/psi",injectionFlowRate:"bpm",intensity:"hhp/in2",interfacialTension:"lbf/ft",inverseStandSpeed:"min/stand",kickToleranceVolume:"bbl",length:"km",linearCapacity:"bbl/ft",location:"m",massFlowRate:"lbm/s",mixingRequirements:"m3/t",moleWeight:"lbf/mol",oilVolume:"STB",percentage:"%",permeability:"mD",power:"BTU/h",pressure:"psi",pressurechange:"psi",pressureGradient:"psi/ft",pressurePerTemperature:"psi/F",productionFlowRate:"STB/d",productionFlowRateGas:"MMSCFD",productionFlowRateOil:"STB/d",pumpRate:"bpm",rop:"ft/h",rotationalSpeed:"rpm",roughness:"in",specificHeatCapacity:"BTU/(lbm*degF)",speed:"ft/s",stress:"psi",temperature:"F",tempgrad:"F/100ft",thermalConductivity:"BTU/(h*ft*degF)",thermalExpansionCoefficient:"E-06/degF",torque:"Nm",torqueGradient:"lbf",turbulentSkin:"1/MMSCFD",viscosity:"cP",volume:"bbl",wearFactor:"E-10/psi",weight:"lbf",weightGradient:"ppf",wltubulars:"ppf",youngsModulus:"psi"},Ce=[{length:"10|m",pressure:"5|psi"},{length:"20|m",pressure:"10|psi"}],Te=[{length:"m",pressure:"psi"},{length:"10",pressure:"5"},{length:"20",pressure:"10"}],Ie=[["m","psi"],[10,5],[20,10]],G=[{key:"length",header:"Length",translationKey:"length",defaultValue:0,type:"NumberInput",convertible:!0,unitKey:"length",columnAlignment:"left",columnWidth:"150px"},{key:"pressure",header:"Pressure",translationKey:"pressure",defaultValue:0,type:"NumberInput",convertible:!0,unitKey:"pressure",columnAlignment:"left",columnWidth:"150px"}],xe=t=>t===0,De=(t,l)=>l===t-1,Re=(t,l)=>l?`(Test value text) ${t}`:t,en={title:"Basic/UnitTable",component:U},k=()=>{const[t,l]=w.useState(Ce),[m,g]=w.useState([]),[d,y]=w.useState(H),i=(c,o,u,p)=>{const{value:a}=c.target;let n;l(h=>(n=[...h],n[u][o]=v.withUnit(a,p[o]),n))},b=(c,o)=>{const u=c.map((p,a)=>{let{length:n,pressure:h}=p;return{cells:[{value:v.getValue(n),type:"NumberInput",disabled:!1,onChange:s=>i(s,"length",a,o),testId:`table-cell-${a}-0`},{value:v.getValue(h),type:"NumberInput",disabled:!1,onChange:s=>i(s,"pressure",a,o),testId:`table-cell-${a}-1`}],actions:[]}});return g(c),u},f=[{value:"m",label:"m"},{value:"ft",label:"ft"},{value:"km",label:"km"},{value:"in",label:"in"},{value:"mm",label:"mm"}];return e.jsxs(R,{columns:"1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Global View Settings"}),children:e.jsx(_,{children:e.jsx($,{label:"Active Unit Template For Length",children:e.jsx(L,{options:f,value:{value:d.length},onChange:c=>{y(o=>({...o,length:c.target.value}))},width:"100px"})})})}),e.jsx(U,{tableActions:{},data:t,tableDef:G,convertToCells:b,unitTemplate:d,testId:"Test",oldStructureType:null}),e.jsxs(R,{columns:"1fr 1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Display data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(m,null,2)})})}),e.jsx(I,{heading:e.jsx(x,{children:"Storage data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(t,null,2)})})})]})]})},F=()=>{const[t,l]=w.useState(Te),[m,g]=w.useState([]),[d,y]=w.useState(H),i=(c,o,u,p)=>{const{value:a}=c.target;if(u<0||u>=t.length){console.error("Index out of range");return}let n=[...t];const h=t[0][o],s=p[o];h!==s&&(n=n.map((r,T)=>{if(T===0)return r;const S=v.convertAndGetValue(r[o],s,h);return{...r,[o]:S}}),n[0][o]=s),n[u][o]=a,l(n)},b=(c,o)=>{const u=c.slice(1).map((p,a)=>{let{length:n,pressure:h}=p;return{cells:[{value:n,type:"NumberInput",disabled:!1,onChange:s=>i(s,"length",a+1,o),testId:`table-cell-${a+1}-0`},{value:h,type:"NumberInput",disabled:!1,onChange:s=>i(s,"pressure",a+1,o),testId:`table-cell-${a+1}-1`}],actions:[]}});return g(c),u},f=[{value:"m",label:"m"},{value:"ft",label:"ft"},{value:"km",label:"km"},{value:"in",label:"in"},{value:"mm",label:"mm"}];return e.jsxs(R,{columns:"1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Global View Settings"}),children:e.jsx(_,{children:e.jsx($,{label:"Active Unit Template For Length",children:e.jsx(L,{options:f,value:{value:d.length},onChange:c=>{y(o=>({...o,length:c.target.value}))},width:"100px"})})})}),e.jsx(U,{tableActions:{},data:t,tableDef:G,convertToCells:b,unitTemplate:d,testId:"Test"}),e.jsxs(R,{columns:"1fr 1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Display data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(m,null,2)})})}),e.jsx(I,{heading:e.jsx(x,{children:"Storage data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(t,null,2)})})})]})]})},A=()=>{const[t,l]=w.useState(Ie),[m,g]=w.useState([]),[d,y]=w.useState(H),i=(c,o,u,p)=>{const{value:a}=c.target;if(o<0||o>=t.length){console.error("Index out of range");return}let n=[...t];const h=t[0][u],s=p[u];h!==s&&(n=n.map((r,T)=>{if(T===0){const j=r;return j[u]=s,j}const S=r[u],O=v.convertAndGetValue(S,s,h);return r[u]=O,r})),n[o][u]=a,l(n)},b=(c,o)=>{const u=c.slice(1).map((p,a)=>{let[n,h]=p;return{cells:[{value:n,type:"NumberInput",disabled:!1,onChange:s=>i(s,a+1,0,o),testId:`table-cell-${a+1}-0`},{value:h,type:"NumberInput",disabled:!1,onChange:s=>i(s,a+1,1,o),testId:`table-cell-${a+1}-1`}],actions:[]}});return g(c),u},f=[{value:"m",label:"m"},{value:"ft",label:"ft"},{value:"km",label:"km"},{value:"in",label:"in"},{value:"mm",label:"mm"}];return e.jsxs(R,{columns:"1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Global View Settings"}),children:e.jsx(_,{children:e.jsx($,{label:"Active Unit Template For Length",children:e.jsx(L,{options:f,value:{value:d.length},onChange:c=>{y(o=>({...o,length:c.target.value}))},width:"100px"})})})}),e.jsx(U,{tableActions:{},data:t,tableDef:G,convertToCells:b,unitTemplate:d,testId:"Test",oldStructureType:"array"}),e.jsxs(R,{columns:"1fr 1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Display data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(m,null,2)})})}),e.jsx(I,{heading:e.jsx(x,{children:"Storage data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(t,null,2)})})})]})]})},N=()=>{const[t,l]=w.useState(fe),[m,g]=w.useState([]),[d,y]=w.useState(H),i=(a,n,h,s)=>{const{value:r}=a.target;let T;l(S=>(T=[...S],T[h][n]=n==="rock_type"||n==="name"?r:v.withUnit(r,s[n]),T))},b=()=>{const a={...t[t.length-1]};l(n=>[...n,a])},f=a=>l(n=>n.filter((h,s)=>a!==s)),c=a=>e.jsx(ye,{onDeleteTableRow:f,rowid:a}),o=(a,n)=>{const h=a.map((s,r)=>{let{rock_type:T,name:S,depth_from:O,depth_to:j,Ro:ne,Cp:ae,Lambda:le}=s;const V=xe(r),E=De(t.length,r),re=V?[]:[{childComponent:c(r)}];return{cells:[{options:te,value:T||"Rock",type:"Select",disabled:!1,onChange:C=>i(C,"rock_type",r,n),testId:`table-cell-${r}-0`},{value:S,type:"Input",placeholder:"Name",disabled:!1,onChange:C=>i(C,"name",r,n),testId:`table-cell-${r}-1`},{value:Re(v.getValue(O),V),type:V?"Static":"NumberInput",style:V?{whiteSpace:"nowrap"}:{},disabled:V,onChange:C=>i(C,"depth_from",r,n),testId:`table-cell-${r}-2`},{value:v.getValue(j),type:E?"Static":"NumberInput",style:E?{whiteSpace:"nowrap"}:{},disabled:E,onChange:C=>i(C,"depth_to",r,n),testId:`table-cell-${r}-3`},{value:v.getValue(ne),type:"NumberInput",disabled:!0,onChange:C=>i(C,"Ro",r,n),testId:`table-cell-${r}-4`},{value:v.getValue(ae),type:"NumberInput",disabled:!0,onChange:C=>i(C,"Cp",r,n),testId:`table-cell-${r}-5`},{value:v.getValue(le),type:"NumberInput",disabled:!0,onChange:C=>i(C,"Lambda",r,n),testId:`table-cell-${r}-6`}],actions:re}});return g(a),h},u={addRow:b,reorderComponents:()=>{}},p=[{value:"m",label:"m"},{value:"ft",label:"ft"},{value:"km",label:"km"},{value:"in",label:"in"},{value:"mm",label:"mm"}];return e.jsxs(R,{columns:"1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Global View Settings"}),children:e.jsx(_,{children:e.jsx($,{label:"Active Unit Template For Length",children:e.jsx(L,{options:p,value:{value:d.length},onChange:a=>{y(n=>({...n,length:a.target.value}))},width:"100px"})})})}),e.jsx(U,{tableActions:u,data:t,tableDef:we,convertToCells:o,unitTemplate:d,testId:"Test",oldStructureType:null}),e.jsxs(R,{columns:"1fr 1fr",gap:!0,children:[e.jsx(I,{heading:e.jsx(x,{children:"Display data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(m,null,2)})})}),e.jsx(I,{heading:e.jsx(x,{children:"Storage data"}),children:e.jsx("pre",{children:e.jsx("code",{children:JSON.stringify(t,null,2)})})})]})]})};var K,J,W;k.parameters={...k.parameters,docs:{...(K=k.parameters)==null?void 0:K.docs,source:{originalSource:`() => {
|
|
2
|
+
const [data, setData] = useState<any[]>(simpleData);
|
|
3
|
+
const [displayedData, setDisplayedData] = useState<any[]>([]);
|
|
4
|
+
const [unitTemplate, setUnitTemplate] = useState(initalUnitTemplate);
|
|
5
|
+
const onChangeValue = (ev: ChangeEvent<HTMLInputElement>, columnName: keyof ISimpleData, rowIx: number, displayedUnits: Record<string, string>) => {
|
|
6
|
+
const {
|
|
7
|
+
value
|
|
8
|
+
} = ev.target;
|
|
9
|
+
let newData: ISimpleData[];
|
|
10
|
+
setData(prev => {
|
|
11
|
+
newData = [...prev];
|
|
12
|
+
newData[rowIx][columnName] = withUnit(value, displayedUnits[columnName]);
|
|
13
|
+
return newData;
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const convertToCells = (displayedRows: Array<any>, displayedUnits: Record<string, any>) => {
|
|
17
|
+
const cells = displayedRows.map((item, rowIndex) => {
|
|
18
|
+
let {
|
|
19
|
+
length,
|
|
20
|
+
pressure
|
|
21
|
+
} = item;
|
|
22
|
+
return {
|
|
23
|
+
cells: [{
|
|
24
|
+
value: getValue(length),
|
|
25
|
+
type: 'NumberInput',
|
|
26
|
+
disabled: false,
|
|
27
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'length', rowIndex, displayedUnits),
|
|
28
|
+
testId: \`table-cell-\${rowIndex}-\${0}\`
|
|
29
|
+
}, {
|
|
30
|
+
value: getValue(pressure),
|
|
31
|
+
type: 'NumberInput',
|
|
32
|
+
disabled: false,
|
|
33
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'pressure', rowIndex, displayedUnits),
|
|
34
|
+
testId: \`table-cell-\${rowIndex}-\${1}\`
|
|
35
|
+
}],
|
|
36
|
+
actions: []
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
setDisplayedData(displayedRows);
|
|
40
|
+
return cells;
|
|
41
|
+
};
|
|
42
|
+
const unitOptions = [{
|
|
43
|
+
value: 'm',
|
|
44
|
+
label: 'm'
|
|
45
|
+
}, {
|
|
46
|
+
value: 'ft',
|
|
47
|
+
label: 'ft'
|
|
48
|
+
}, {
|
|
49
|
+
value: 'km',
|
|
50
|
+
label: 'km'
|
|
51
|
+
}, {
|
|
52
|
+
value: 'in',
|
|
53
|
+
label: 'in'
|
|
54
|
+
}, {
|
|
55
|
+
value: 'mm',
|
|
56
|
+
label: 'mm'
|
|
57
|
+
}];
|
|
58
|
+
return <Grid columns="1fr" gap>
|
|
59
|
+
<Card heading={<Heading>Global View Settings</Heading>}>
|
|
60
|
+
<FormRow>
|
|
61
|
+
<Field label="Active Unit Template For Length">
|
|
62
|
+
<Select options={unitOptions} value={{
|
|
63
|
+
value: unitTemplate.length
|
|
64
|
+
}} onChange={evt => {
|
|
65
|
+
setUnitTemplate(prev => ({
|
|
66
|
+
...prev,
|
|
67
|
+
length: evt.target.value
|
|
68
|
+
}));
|
|
69
|
+
}} width="100px" />
|
|
70
|
+
</Field>
|
|
71
|
+
</FormRow>
|
|
72
|
+
</Card>
|
|
73
|
+
<UnitTable tableActions={{}} data={data} tableDef={simpleTableDef} convertToCells={convertToCells} unitTemplate={unitTemplate} testId="Test" oldStructureType={null} />
|
|
74
|
+
<Grid columns="1fr 1fr" gap>
|
|
75
|
+
<Card heading={<Heading>Display data</Heading>}>
|
|
76
|
+
<pre>
|
|
77
|
+
<code>{JSON.stringify(displayedData, null, 2)}</code>
|
|
78
|
+
</pre>
|
|
79
|
+
</Card>
|
|
80
|
+
<Card heading={<Heading>Storage data</Heading>}>
|
|
81
|
+
<pre>
|
|
82
|
+
<code>{JSON.stringify(data, null, 2)}</code>
|
|
83
|
+
</pre>
|
|
84
|
+
</Card>
|
|
85
|
+
</Grid>
|
|
86
|
+
</Grid>;
|
|
87
|
+
}`,...(W=(J=k.parameters)==null?void 0:J.docs)==null?void 0:W.source}}};var B,q,Y;F.parameters={...F.parameters,docs:{...(B=F.parameters)==null?void 0:B.docs,source:{originalSource:`() => {
|
|
88
|
+
const [data, setData] = useState<any[]>(simpleOldData);
|
|
89
|
+
const [displayedData, setDisplayedData] = useState<any[]>([]);
|
|
90
|
+
const [unitTemplate, setUnitTemplate] = useState(initalUnitTemplate);
|
|
91
|
+
const onChangeValue = (ev: ChangeEvent<HTMLInputElement>, key: keyof ISimpleData, rowIx: number, displayedUnits: Record<string, any>) => {
|
|
92
|
+
const {
|
|
93
|
+
value
|
|
94
|
+
} = ev.target;
|
|
95
|
+
if (rowIx < 0 || rowIx >= data.length) {
|
|
96
|
+
console.error('Index out of range');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let newData = [...data];
|
|
100
|
+
const prevUnit = data[0][key];
|
|
101
|
+
const newUnit = displayedUnits[key];
|
|
102
|
+
// If the units have changed, convert all data in the column
|
|
103
|
+
if (prevUnit !== newUnit) {
|
|
104
|
+
newData = newData.map((row, i) => {
|
|
105
|
+
if (i === 0) return row;
|
|
106
|
+
const convertedValue = convertAndGetValue(row[key], newUnit, prevUnit);
|
|
107
|
+
return {
|
|
108
|
+
...row,
|
|
109
|
+
[key]: convertedValue
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
newData[0][key] = newUnit;
|
|
113
|
+
}
|
|
114
|
+
newData[rowIx][key] = value;
|
|
115
|
+
setData(newData);
|
|
116
|
+
};
|
|
117
|
+
const convertToCells = (displayedRows: Array<any>, displayedUnits: Record<string, any>) => {
|
|
118
|
+
const cells = displayedRows.slice(1).map((item, rowIndex) => {
|
|
119
|
+
let {
|
|
120
|
+
length,
|
|
121
|
+
pressure
|
|
122
|
+
} = item;
|
|
123
|
+
return {
|
|
124
|
+
cells: [{
|
|
125
|
+
value: length,
|
|
126
|
+
type: 'NumberInput',
|
|
127
|
+
disabled: false,
|
|
128
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'length', rowIndex + 1, displayedUnits),
|
|
129
|
+
testId: \`table-cell-\${rowIndex + 1}-\${0}\`
|
|
130
|
+
}, {
|
|
131
|
+
value: pressure,
|
|
132
|
+
type: 'NumberInput',
|
|
133
|
+
disabled: false,
|
|
134
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'pressure', rowIndex + 1, displayedUnits),
|
|
135
|
+
testId: \`table-cell-\${rowIndex + 1}-\${1}\`
|
|
136
|
+
}],
|
|
137
|
+
actions: []
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
setDisplayedData(displayedRows);
|
|
141
|
+
return cells;
|
|
142
|
+
};
|
|
143
|
+
const unitOptions = [{
|
|
144
|
+
value: 'm',
|
|
145
|
+
label: 'm'
|
|
146
|
+
}, {
|
|
147
|
+
value: 'ft',
|
|
148
|
+
label: 'ft'
|
|
149
|
+
}, {
|
|
150
|
+
value: 'km',
|
|
151
|
+
label: 'km'
|
|
152
|
+
}, {
|
|
153
|
+
value: 'in',
|
|
154
|
+
label: 'in'
|
|
155
|
+
}, {
|
|
156
|
+
value: 'mm',
|
|
157
|
+
label: 'mm'
|
|
158
|
+
}];
|
|
159
|
+
return <Grid columns="1fr" gap>
|
|
160
|
+
<Card heading={<Heading>Global View Settings</Heading>}>
|
|
161
|
+
<FormRow>
|
|
162
|
+
<Field label="Active Unit Template For Length">
|
|
163
|
+
<Select options={unitOptions} value={{
|
|
164
|
+
value: unitTemplate.length
|
|
165
|
+
}} onChange={evt => {
|
|
166
|
+
setUnitTemplate(prev => ({
|
|
167
|
+
...prev,
|
|
168
|
+
length: evt.target.value
|
|
169
|
+
}));
|
|
170
|
+
}} width="100px" />
|
|
171
|
+
</Field>
|
|
172
|
+
</FormRow>
|
|
173
|
+
</Card>
|
|
174
|
+
<UnitTable tableActions={{}} data={data} tableDef={simpleTableDef} convertToCells={convertToCells} unitTemplate={unitTemplate} testId="Test" />
|
|
175
|
+
<Grid columns="1fr 1fr" gap>
|
|
176
|
+
<Card heading={<Heading>Display data</Heading>}>
|
|
177
|
+
<pre>
|
|
178
|
+
<code>{JSON.stringify(displayedData, null, 2)}</code>
|
|
179
|
+
</pre>
|
|
180
|
+
</Card>
|
|
181
|
+
<Card heading={<Heading>Storage data</Heading>}>
|
|
182
|
+
<pre>
|
|
183
|
+
<code>{JSON.stringify(data, null, 2)}</code>
|
|
184
|
+
</pre>
|
|
185
|
+
</Card>
|
|
186
|
+
</Grid>
|
|
187
|
+
</Grid>;
|
|
188
|
+
}`,...(Y=(q=F.parameters)==null?void 0:q.docs)==null?void 0:Y.source}}};var P,z,Q;A.parameters={...A.parameters,docs:{...(P=A.parameters)==null?void 0:P.docs,source:{originalSource:`() => {
|
|
189
|
+
const [data, setData] = useState<any[]>(simpleOldStructureWithArrayUnit);
|
|
190
|
+
const [displayedData, setDisplayedData] = useState<any[]>([]);
|
|
191
|
+
const [unitTemplate, setUnitTemplate] = useState(initalUnitTemplate);
|
|
192
|
+
const onChangeValue = (ev: ChangeEvent<HTMLInputElement>, rowIx: number, colIx: number, displayedUnits: Record<string, any>) => {
|
|
193
|
+
const {
|
|
194
|
+
value
|
|
195
|
+
} = ev.target;
|
|
196
|
+
if (rowIx < 0 || rowIx >= data.length) {
|
|
197
|
+
console.error('Index out of range');
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
let newData = [...data];
|
|
201
|
+
const prevUnit = data[0][colIx];
|
|
202
|
+
const newUnit = displayedUnits[colIx];
|
|
203
|
+
// If the units have changed, convert all data in the column
|
|
204
|
+
if (prevUnit !== newUnit) {
|
|
205
|
+
newData = newData.map((row, i) => {
|
|
206
|
+
if (i === 0) {
|
|
207
|
+
const updatedUnitRow = row;
|
|
208
|
+
updatedUnitRow[colIx] = newUnit;
|
|
209
|
+
return updatedUnitRow;
|
|
210
|
+
}
|
|
211
|
+
const value = row[colIx];
|
|
212
|
+
const convertedValue = convertAndGetValue(value, newUnit, prevUnit);
|
|
213
|
+
row[colIx] = convertedValue;
|
|
214
|
+
return row;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
newData[rowIx][colIx] = value;
|
|
218
|
+
setData(newData);
|
|
219
|
+
};
|
|
220
|
+
const convertToCells = (displayedRows: Array<any>, displayedUnits: Record<string, any>) => {
|
|
221
|
+
const cells = displayedRows.slice(1).map((item, rowIndex) => {
|
|
222
|
+
let [length, pressure] = item;
|
|
223
|
+
return {
|
|
224
|
+
cells: [{
|
|
225
|
+
value: length,
|
|
226
|
+
type: 'NumberInput',
|
|
227
|
+
disabled: false,
|
|
228
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, rowIndex + 1, 0, displayedUnits),
|
|
229
|
+
testId: \`table-cell-\${rowIndex + 1}-\${0}\`
|
|
230
|
+
}, {
|
|
231
|
+
value: pressure,
|
|
232
|
+
type: 'NumberInput',
|
|
233
|
+
disabled: false,
|
|
234
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, rowIndex + 1, 1, displayedUnits),
|
|
235
|
+
testId: \`table-cell-\${rowIndex + 1}-\${1}\`
|
|
236
|
+
}],
|
|
237
|
+
actions: []
|
|
238
|
+
};
|
|
239
|
+
});
|
|
240
|
+
setDisplayedData(displayedRows);
|
|
241
|
+
return cells;
|
|
242
|
+
};
|
|
243
|
+
const unitOptions = [{
|
|
244
|
+
value: 'm',
|
|
245
|
+
label: 'm'
|
|
246
|
+
}, {
|
|
247
|
+
value: 'ft',
|
|
248
|
+
label: 'ft'
|
|
249
|
+
}, {
|
|
250
|
+
value: 'km',
|
|
251
|
+
label: 'km'
|
|
252
|
+
}, {
|
|
253
|
+
value: 'in',
|
|
254
|
+
label: 'in'
|
|
255
|
+
}, {
|
|
256
|
+
value: 'mm',
|
|
257
|
+
label: 'mm'
|
|
258
|
+
}];
|
|
259
|
+
return <Grid columns="1fr" gap>
|
|
260
|
+
<Card heading={<Heading>Global View Settings</Heading>}>
|
|
261
|
+
<FormRow>
|
|
262
|
+
<Field label="Active Unit Template For Length">
|
|
263
|
+
<Select options={unitOptions} value={{
|
|
264
|
+
value: unitTemplate.length
|
|
265
|
+
}} onChange={evt => {
|
|
266
|
+
setUnitTemplate(prev => ({
|
|
267
|
+
...prev,
|
|
268
|
+
length: evt.target.value
|
|
269
|
+
}));
|
|
270
|
+
}} width="100px" />
|
|
271
|
+
</Field>
|
|
272
|
+
</FormRow>
|
|
273
|
+
</Card>
|
|
274
|
+
<UnitTable tableActions={{}} data={data} tableDef={simpleTableDef} convertToCells={convertToCells} unitTemplate={unitTemplate} testId="Test" oldStructureType="array" />
|
|
275
|
+
<Grid columns="1fr 1fr" gap>
|
|
276
|
+
<Card heading={<Heading>Display data</Heading>}>
|
|
277
|
+
<pre>
|
|
278
|
+
<code>{JSON.stringify(displayedData, null, 2)}</code>
|
|
279
|
+
</pre>
|
|
280
|
+
</Card>
|
|
281
|
+
<Card heading={<Heading>Storage data</Heading>}>
|
|
282
|
+
<pre>
|
|
283
|
+
<code>{JSON.stringify(data, null, 2)}</code>
|
|
284
|
+
</pre>
|
|
285
|
+
</Card>
|
|
286
|
+
</Grid>
|
|
287
|
+
</Grid>;
|
|
288
|
+
}`,...(Q=(z=A.parameters)==null?void 0:z.docs)==null?void 0:Q.source}}};var X,Z,ee;N.parameters={...N.parameters,docs:{...(X=N.parameters)==null?void 0:X.docs,source:{originalSource:`() => {
|
|
289
|
+
const [data, setData] = useState<IRock[]>(rocks);
|
|
290
|
+
const [displayedData, setDisplayedData] = useState<any[]>([]);
|
|
291
|
+
const [unitTemplate, setUnitTemplate] = useState(initalUnitTemplate);
|
|
292
|
+
const onChangeValue = (ev: ChangeEvent<HTMLInputElement>, columnName: keyof IRock, rowIx: number, displayedUnits: Record<string, string>) => {
|
|
293
|
+
const {
|
|
294
|
+
value
|
|
295
|
+
} = ev.target;
|
|
296
|
+
let newData: IRock[];
|
|
297
|
+
setData(prev => {
|
|
298
|
+
newData = [...prev];
|
|
299
|
+
newData[rowIx][columnName] = columnName === 'rock_type' || columnName === 'name' ? value : withUnit(value, displayedUnits[columnName]);
|
|
300
|
+
return newData;
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
const addRow = () => {
|
|
304
|
+
const newRow = {
|
|
305
|
+
...data[data.length - 1]
|
|
306
|
+
};
|
|
307
|
+
setData(prev => [...prev, newRow]);
|
|
308
|
+
};
|
|
309
|
+
const onDeleteRow = (ix: number) => setData(prev => prev.filter((_, index) => ix !== index));
|
|
310
|
+
const rowMenu = (rowIx: number) => <TableRowMenu onDeleteTableRow={onDeleteRow} rowid={rowIx} />;
|
|
311
|
+
const convertToCells = (displayedRows: Array<any>, displayedUnits: Record<string, any>) => {
|
|
312
|
+
const cells = displayedRows.map((item, rowIndex) => {
|
|
313
|
+
let {
|
|
314
|
+
rock_type,
|
|
315
|
+
name,
|
|
316
|
+
depth_from,
|
|
317
|
+
depth_to,
|
|
318
|
+
Ro,
|
|
319
|
+
Cp,
|
|
320
|
+
Lambda
|
|
321
|
+
} = item;
|
|
322
|
+
const disabledFirstRow = isFirstRow(rowIndex);
|
|
323
|
+
const disabledLastRow = isLastRow(data.length, rowIndex);
|
|
324
|
+
const actions = disabledFirstRow ? [] : [{
|
|
325
|
+
childComponent: rowMenu(rowIndex)
|
|
326
|
+
}];
|
|
327
|
+
return {
|
|
328
|
+
cells: [{
|
|
329
|
+
options: rocksList,
|
|
330
|
+
value: rock_type || 'Rock',
|
|
331
|
+
type: 'Select',
|
|
332
|
+
disabled: false,
|
|
333
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'rock_type', rowIndex, displayedUnits),
|
|
334
|
+
testId: \`table-cell-\${rowIndex}-\${0}\`
|
|
335
|
+
}, {
|
|
336
|
+
value: name,
|
|
337
|
+
type: 'Input',
|
|
338
|
+
placeholder: 'Name',
|
|
339
|
+
disabled: false,
|
|
340
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'name', rowIndex, displayedUnits),
|
|
341
|
+
testId: \`table-cell-\${rowIndex}-\${1}\`
|
|
342
|
+
}, {
|
|
343
|
+
value: getCellLength(getValue(depth_from), disabledFirstRow),
|
|
344
|
+
type: disabledFirstRow ? 'Static' : 'NumberInput',
|
|
345
|
+
style: disabledFirstRow ? {
|
|
346
|
+
whiteSpace: 'nowrap'
|
|
347
|
+
} : {},
|
|
348
|
+
disabled: disabledFirstRow,
|
|
349
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'depth_from', rowIndex, displayedUnits),
|
|
350
|
+
testId: \`table-cell-\${rowIndex}-\${2}\`
|
|
351
|
+
}, {
|
|
352
|
+
value: getValue(depth_to),
|
|
353
|
+
type: disabledLastRow ? 'Static' : 'NumberInput',
|
|
354
|
+
style: disabledLastRow ? {
|
|
355
|
+
whiteSpace: 'nowrap'
|
|
356
|
+
} : {},
|
|
357
|
+
disabled: disabledLastRow,
|
|
358
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'depth_to', rowIndex, displayedUnits),
|
|
359
|
+
testId: \`table-cell-\${rowIndex}-\${3}\`
|
|
360
|
+
}, {
|
|
361
|
+
value: getValue(Ro),
|
|
362
|
+
type: 'NumberInput',
|
|
363
|
+
disabled: true,
|
|
364
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'Ro', rowIndex, displayedUnits),
|
|
365
|
+
testId: \`table-cell-\${rowIndex}-\${4}\`
|
|
366
|
+
}, {
|
|
367
|
+
value: getValue(Cp),
|
|
368
|
+
type: 'NumberInput',
|
|
369
|
+
disabled: true,
|
|
370
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'Cp', rowIndex, displayedUnits),
|
|
371
|
+
testId: \`table-cell-\${rowIndex}-\${5}\`
|
|
372
|
+
}, {
|
|
373
|
+
value: getValue(Lambda),
|
|
374
|
+
type: 'NumberInput',
|
|
375
|
+
disabled: true,
|
|
376
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => onChangeValue(e, 'Lambda', rowIndex, displayedUnits),
|
|
377
|
+
testId: \`table-cell-\${rowIndex}-\${6}\`
|
|
378
|
+
}],
|
|
379
|
+
actions
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
setDisplayedData(displayedRows);
|
|
383
|
+
return cells;
|
|
384
|
+
};
|
|
385
|
+
const tableActions = {
|
|
386
|
+
addRow,
|
|
387
|
+
reorderComponents: () => {}
|
|
388
|
+
};
|
|
389
|
+
const unitOptions = [{
|
|
390
|
+
value: 'm',
|
|
391
|
+
label: 'm'
|
|
392
|
+
}, {
|
|
393
|
+
value: 'ft',
|
|
394
|
+
label: 'ft'
|
|
395
|
+
}, {
|
|
396
|
+
value: 'km',
|
|
397
|
+
label: 'km'
|
|
398
|
+
}, {
|
|
399
|
+
value: 'in',
|
|
400
|
+
label: 'in'
|
|
401
|
+
}, {
|
|
402
|
+
value: 'mm',
|
|
403
|
+
label: 'mm'
|
|
404
|
+
}];
|
|
405
|
+
return <Grid columns="1fr" gap>
|
|
406
|
+
<Card heading={<Heading>Global View Settings</Heading>}>
|
|
407
|
+
<FormRow>
|
|
408
|
+
<Field label="Active Unit Template For Length">
|
|
409
|
+
<Select options={unitOptions} value={{
|
|
410
|
+
value: unitTemplate.length
|
|
411
|
+
}} onChange={evt => {
|
|
412
|
+
setUnitTemplate(prev => ({
|
|
413
|
+
...prev,
|
|
414
|
+
length: evt.target.value
|
|
415
|
+
}));
|
|
416
|
+
}} width="100px" />
|
|
417
|
+
</Field>
|
|
418
|
+
</FormRow>
|
|
419
|
+
</Card>
|
|
420
|
+
<UnitTable tableActions={tableActions} data={data} tableDef={tableDef} convertToCells={convertToCells} unitTemplate={unitTemplate} testId="Test" oldStructureType={null} />
|
|
421
|
+
<Grid columns="1fr 1fr" gap>
|
|
422
|
+
<Card heading={<Heading>Display data</Heading>}>
|
|
423
|
+
<pre>
|
|
424
|
+
<code>{JSON.stringify(displayedData, null, 2)}</code>
|
|
425
|
+
</pre>
|
|
426
|
+
</Card>
|
|
427
|
+
<Card heading={<Heading>Storage data</Heading>}>
|
|
428
|
+
<pre>
|
|
429
|
+
<code>{JSON.stringify(data, null, 2)}</code>
|
|
430
|
+
</pre>
|
|
431
|
+
</Card>
|
|
432
|
+
</Grid>
|
|
433
|
+
</Grid>;
|
|
434
|
+
}`,...(ee=(Z=N.parameters)==null?void 0:Z.docs)==null?void 0:ee.source}}};const tn=["NewStructure","OldStructure","OldStructureWithArrayUnit","Complex"];export{N as Complex,k as NewStructure,F as OldStructure,A as OldStructureWithArrayUnit,tn as __namedExportsOrder,en as default};
|