@oliasoft-open-source/react-ui-library 4.6.1 → 4.6.2-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/assets/{index-kDrJq_kq.js → index-21EwET8E.js} +2 -3
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.html +1 -1
  4. package/dist/index.js +2 -3
  5. package/dist/index.js.map +1 -1
  6. package/dist/storybook/assets/{Color-6VNJS4EI-LkypNDYY.js → Color-6VNJS4EI-tDs0DW6l.js} +1 -1
  7. package/dist/storybook/assets/{DocsRenderer-NNNQARDV-271EmMHR.js → DocsRenderer-NNNQARDV-4FhE5tBt.js} +1 -1
  8. package/dist/storybook/assets/{WithTooltip-V3YHNWJZ-5odABDuO.js → WithTooltip-V3YHNWJZ-4DkfkReL.js} +1 -1
  9. package/dist/storybook/assets/{afe.stories-gufd9PH8.js → afe.stories-yjkRmCqu.js} +1 -1
  10. package/dist/storybook/assets/{blowout.stories-TT3YZhxD.js → blowout.stories-fjMitjld.js} +1 -1
  11. package/dist/storybook/assets/{buttons-and-links-Sb4bneec.js → buttons-and-links-hjYalcqd.js} +1 -1
  12. package/dist/storybook/assets/{casing-loads.stories-58Yzw909.js → casing-loads.stories-Ilvo3kc-.js} +1 -1
  13. package/dist/storybook/assets/{chunk-HLWAVYOI-C-Uqv-lv.js → chunk-HLWAVYOI-cTxm6eFs.js} +1 -1
  14. package/dist/storybook/assets/{color-QEPOj0Ib.js → color-zQ_1Ab3p.js} +1 -1
  15. package/dist/storybook/assets/{file-input.stories-qbEqmWyt.js → file-input.stories-lKF1ABXX.js} +1 -1
  16. package/dist/storybook/assets/{form.stories-7v6JzvJl.js → form.stories-AikCzsZc.js} +1 -1
  17. package/dist/storybook/assets/{formation.stories-gIRSy7_9.js → formation.stories-4zFgtvwa.js} +1 -1
  18. package/dist/storybook/assets/{formatter-SWP5E3XI-a7sBt194.js → formatter-SWP5E3XI-Cfu_VZgT.js} +1 -1
  19. package/dist/storybook/assets/{iframe-Z5bUT4O1.js → iframe-uQDN-5FH.js} +2 -2
  20. package/dist/storybook/assets/{index-i2tVYo5N.js → index-Y7wjLv-G.js} +5 -5
  21. package/dist/storybook/assets/{input-validation-FFXJoKSI.js → input-validation-oMZurKNs.js} +1 -1
  22. package/dist/storybook/assets/{inputs-DtKO2too.js → inputs-x27d4m44.js} +1 -1
  23. package/dist/storybook/assets/{layout-forms-7ZIITxGs.js → layout-forms-kdhJZ6gZ.js} +1 -1
  24. package/dist/storybook/assets/{layout-general-zuo7KumY.js → layout-general-nsHljhz3.js} +1 -1
  25. package/dist/storybook/assets/{padding-and-spacing-3Mlm9PiC.js → padding-and-spacing-lmVoZ2oR.js} +1 -1
  26. package/dist/storybook/assets/{page.stories-OXhmRr73.js → page.stories-UQlnuZid.js} +1 -1
  27. package/dist/storybook/assets/{preview-0LPoYPAJ.js → preview-f8-piscl.js} +1 -1
  28. package/dist/storybook/assets/{preview-MDW-geT9.js → preview-oUKV_zRt.js} +2 -2
  29. package/dist/storybook/assets/{reservoirs.stories-vxBxhmZh.js → reservoirs.stories-TKohSiCU.js} +1 -1
  30. package/dist/storybook/assets/side-bar-dRjlh2Za.js +1 -0
  31. package/dist/storybook/assets/side-bar.stories-aKMnuHiZ.js +1 -0
  32. package/dist/storybook/assets/{site.stories-k6-tU36k.js → site.stories-Qfujz1ST.js} +1 -1
  33. package/dist/storybook/assets/{syntaxhighlighter-B5GMVT5T-jueltlMw.js → syntaxhighlighter-B5GMVT5T-rE3BvsrO.js} +1 -1
  34. package/dist/storybook/assets/{textarea-ygEac3d2.js → textarea-TSoWqDT8.js} +1 -1
  35. package/dist/storybook/assets/{textarea.stories-vr_I38NI.js → textarea.stories-w6XYooLd.js} +1 -1
  36. package/dist/storybook/assets/unit-table.stories-CO9oH2A7.js +107 -0
  37. package/dist/storybook/iframe.html +1 -1
  38. package/dist/storybook/index.json +1 -1
  39. package/dist/storybook/project.json +1 -1
  40. package/dist/storybook/stories.json +1 -1
  41. package/package.json +1 -1
  42. package/dist/404.html +0 -1
  43. package/dist/storybook/assets/side-bar-ZpHvA_KQ.js +0 -1
  44. package/dist/storybook/assets/side-bar.stories-GCjyz_UC.js +0 -27
  45. package/dist/storybook/assets/unit-table.stories-JkNu_Up6.js +0 -103
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "4.6.1",
3
+ "version": "4.6.2-beta-1",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {
package/dist/404.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-kDrJq_kq.js"></script><link rel="stylesheet" crossorigin href="/react-ui-library/assets/index-2LJjuVRB.css"></head><body><div id="content"></div></body>
@@ -1 +0,0 @@
1
- import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as p,R as g}from"./index-RfLt4OUa.js";import{c as v}from"./index-VW3EWkuE.js";import{i as h}from"./index-ugi_ZH6T.js";import{B as y,I as E}from"./common-types-U65vzrrz.js";import{D as I}from"./drawer-GdbVQdWk.js";import{T as j}from"./tooltip-HEHiU__l.js";import{I as T}from"./icon-8EQazuuW.js";import{B as N}from"./badge-23Ty_zBt.js";import{B as M}from"./button-shH4xakS.js";const S="_inputInTable_1ube5_1",C="_inputHover_1ube5_13",O="_inputFocus_1ube5_18",q="_inputError_1ube5_25",V="_inputWarning_1ube5_26",B="_inputDisabled_1ube5_61",k="_hideScrollbars_1ube5_67",L="_sidebar_1ube5_82",F="_inner_1ube5_93",H="_title_1ube5_103",A="_subtitle_1ube5_104",D="_label_1ube5_105",R="_collapsed_1ube5_109",W="_list_1ube5_134",P="_item_1ube5_140",z="_experimental_1ube5_155",$="_active_1ube5_159",w="_icon_1ube5_163",s={inputInTable:S,inputHover:C,inputFocus:O,inputError:q,inputWarning:V,inputDisabled:B,hideScrollbars:k,sidebar:L,inner:F,title:H,subtitle:A,label:D,collapsed:R,list:W,item:P,experimental:z,active:$,icon:w},K=p.memo(({isOpen:t,label:i,icon:a,invalid:r})=>e.jsxs(e.Fragment,{children:[e.jsx(j,{text:i,enabled:!t,placement:"right-center",possiblePlacements:["right-center"],fontSize:16,padding:"var(--padding-sm)",display:"block",children:e.jsx("span",{className:s.icon,children:e.jsx(N,{small:!0,title:r?"!":void 0,margin:4,children:e.jsx(T,{icon:a})})})}),e.jsx("span",{className:s.label,children:i})]}),(t,i)=>h(t,i)),m=({isOpen:t,items:i,sectionIndex:a,onClick:r,testId:o})=>e.jsx("div",{className:s.list,children:i.map((n,u)=>{const c=`${a}_${u}`,l=n.component||"a";return e.jsx(l,{href:n.value,to:n.value,className:v(s.item,n.isActive?s.active:"",n.isExperimental?s.experimental:""),onClick:d=>r(d,n.value,n.label,n.onClick),"data-testid":o,children:e.jsx(K,{label:n.label,icon:n.icon,invalid:n.invalid,isOpen:t},c)},c)})});try{m.displayName="Link",m.__docgenInfo={description:"",displayName:"Link",props:{isOpen:{defaultValue:null,description:"",name:"isOpen",required:!0,type:{name:"boolean"}},items:{defaultValue:null,description:"",name:"items",required:!0,type:{name:"IOptionItem[]"}},sectionIndex:{defaultValue:null,description:"",name:"sectionIndex",required:!0,type:{name:"number"}},onClick:{defaultValue:null,description:"",name:"onClick",required:!0,type:{name:"(evt: MouseEvent<HTMLAnchorElement, MouseEvent>, value: string, label: ReactNode, onClickCallback?: ((evt: MouseEvent<HTMLAnchorElement, MouseEvent>) => void) | undefined) => void"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}}}}}catch{}const _=({isOpen:t,sections:i,onClick:a})=>e.jsx(e.Fragment,{children:i.map((r,o)=>e.jsxs(g.Fragment,{children:[e.jsx("h5",{className:s.subtitle,children:r.heading.toUpperCase()}),e.jsx(m,{isOpen:t,items:r.items,sectionIndex:o,onClick:a,testId:r.testId})]},o))});try{_.displayName="Sections",_.__docgenInfo={description:"",displayName:"Sections",props:{isOpen:{defaultValue:null,description:"",name:"isOpen",required:!0,type:{name:"boolean"}},sections:{defaultValue:null,description:"",name:"sections",required:!0,type:{name:"ISection[]"}},onClick:{defaultValue:null,description:"",name:"onClick",required:!0,type:{name:"(evt: MouseEvent<HTMLAnchorElement, MouseEvent>, value: string, label: ReactNode, onClickCallback?: ((evt: MouseEvent<HTMLAnchorElement, MouseEvent>) => void) | undefined) => void"}}}}}catch{}const f=p.memo(({options:t,startOpen:i=!1,onShiftClickToggleOpen:a=()=>{},top:r})=>{const[o,n]=p.useState(i),u=(l,d,x,b)=>{typeof b=="function"&&(l.currentTarget.value=d,l.currentTarget.label=x,b(l)),n(!1)},c=t.sections.length>0;return e.jsx(I,{fixed:!0,open:o,top:r,background:"var(--color-background-sidebar)",closedWidth:"var(--size-sidebar)",buttonPosition:y.BOTTOM,buttonAnimate:!0,button:c&&e.jsx(M,{onClick:l=>{l.shiftKey&&a&&a(l),n(!o)},colored:!0,round:!0,icon:E.LEFT}),children:e.jsx("div",{className:v(s.sidebar,o?"":s.collapsed),children:c&&e.jsxs("div",{className:s.inner,children:[e.jsx("h4",{className:s.title,children:t.title}),e.jsx(_,{isOpen:o,sections:t.sections,onClick:u})]})})})},(t,i)=>h(t,i));try{f.displayName="SideBar",f.__docgenInfo={description:"",displayName:"SideBar",props:{options:{defaultValue:null,description:"",name:"options",required:!0,type:{name:"{ title: string; sections: IOptionSection[]; }"}},startOpen:{defaultValue:null,description:"",name:"startOpen",required:!1,type:{name:"boolean"}},onShiftClickToggleOpen:{defaultValue:null,description:"",name:"onShiftClickToggleOpen",required:!1,type:{name:"((evt: MouseEvent<HTMLButtonElement, MouseEvent>) => void)"}},top:{defaultValue:null,description:"",name:"top",required:!1,type:{name:"TStringOrNumber"}}}}}catch{}export{f as S};
@@ -1,27 +0,0 @@
1
- import{j as e}from"./jsx-runtime-FsUICBgo.js";import{H as R,L as s,S as T,R as r}from"./react-router-dom-EZH1n7K1.js";import{I as t}from"./common-types-U65vzrrz.js";import{S as i}from"./side-bar-ZpHvA_KQ.js";import{F as v}from"./flex-RYZsoWEN.js";import{B as I}from"./badge-23Ty_zBt.js";import{P as f}from"./page-9-f6BzS0.js";import{s as B}from"./icon-custom-PyWFQsS3.js";import"./index-RfLt4OUa.js";import"./inheritsLoose-8sb_A2v4.js";import"./index-4QtD-hFu.js";import"./tiny-invariant-R4kOKlvx.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./index-VW3EWkuE.js";import"./index-ugi_ZH6T.js";import"./drawer-GdbVQdWk.js";import"./lodash-Bmg8FrMx.js";import"./index-miLrID2P.js";import"./icon-8EQazuuW.js";import"./tslib.es6-OIsz3r9a.js";import"./disabled-context-urNQThQz.js";import"./button-shH4xakS.js";import"./spinner-R8Il4aRe.js";import"./tooltip-HEHiU__l.js";const k=[{heading:"First Heading",items:[{label:"Section A",value:"/path/to/something",onClick:()=>{},icon:B},{label:e.jsxs(v,{alignItems:"center",gap:"var(--padding-xxs)",children:["Section B",e.jsx(I,{small:!0,title:"BETA"})]}),value:"/path/to/something",onClick:()=>{},icon:t.HELP,isActive:!0},{label:"Section C",value:"/path/to/something",onClick:()=>{},icon:t.EDIT},{label:"Experimental Section",value:"/path/to/something",onClick:()=>{},icon:t.LIBRARY,isExperimental:!0}]},{heading:"Second Heading",items:[{label:"Section 1",value:"/path/to/something",onClick:()=>{},icon:t.SETTINGS},{label:"Section 2",value:"/path/to/something",onClick:()=>{},icon:t.STAR},{label:"Invalid Section",value:"/path/to/something",onClick:()=>{},icon:t.NOTIFICATION,invalid:!0}]}],W={title:"Navigation/SideBar",component:i,parameters:{layout:"fullscreen",docs:{story:{inline:!1,iframeHeight:400}}},args:{options:{title:"Title",sections:k},startOpen:!1},argTypes:{top:{control:{type:"text"}},startOpen:{control:{type:"boolean"}}}},b=x=>e.jsx(i,{...x}),a=b.bind({}),o=b.bind({});o.args={startOpen:!0};const n=()=>e.jsx(R,{children:e.jsxs(f,{top:0,children:[e.jsx(i,{options:{title:"Title",sections:[{heading:"Main",items:[{label:"Dashboard",value:"/dashboard",icon:t.LIBRARY,component:s},{label:"Settings",value:"/settings",icon:t.SETTINGS,component:s}]}]}}),e.jsxs(T,{children:[e.jsx(r,{path:"/dashboard",children:"Dashboard"}),e.jsx(r,{path:"/settings",children:"Settings"})]})]})});var c,l,p;a.parameters={...a.parameters,docs:{...(c=a.parameters)==null?void 0:c.docs,source:{originalSource:"args => <SideBar {...args} />",...(p=(l=a.parameters)==null?void 0:l.docs)==null?void 0:p.source}}};var m,d,h;o.parameters={...o.parameters,docs:{...(m=o.parameters)==null?void 0:m.docs,source:{originalSource:"args => <SideBar {...args} />",...(h=(d=o.parameters)==null?void 0:d.docs)==null?void 0:h.source}}};var u,g,S;n.parameters={...n.parameters,docs:{...(u=n.parameters)==null?void 0:u.docs,source:{originalSource:`() => {
2
- return <HashRouter>
3
- <Page top={0}>
4
- <SideBar options={{
5
- title: 'Title',
6
- sections: [{
7
- heading: 'Main',
8
- items: [{
9
- label: 'Dashboard',
10
- value: '/dashboard',
11
- icon: IconType.LIBRARY,
12
- component: Link
13
- }, {
14
- label: 'Settings',
15
- value: '/settings',
16
- icon: IconType.SETTINGS,
17
- component: Link
18
- }]
19
- }]
20
- }} />
21
- <Switch>
22
- <Route path="/dashboard">Dashboard</Route>
23
- <Route path="/settings">Settings</Route>
24
- </Switch>
25
- </Page>
26
- </HashRouter>;
27
- }`,...(S=(g=n.parameters)==null?void 0:g.docs)==null?void 0:S.source}}};const X=["Default","StartOpen","AsRouterLink"];export{n as AsRouterLink,a as Default,o as StartOpen,X as __namedExportsOrder,W as default};
@@ -1,103 +0,0 @@
1
- import{j as i}from"./jsx-runtime-FsUICBgo.js";import{r as h}from"./index-RfLt4OUa.js";import{f as $}from"./immer.esm-bD7SSJ7T.js";import{d as U}from"./index-qZmQ7nA9.js";import{G as z}from"./grid-u1mZpaML.js";import{C as D}from"./card-0r8RRVk-.js";import{F as M}from"./field-FZX0Z7IB.js";import{H as R}from"./heading-jZsIIJF0.js";import{S as W}from"./select-DZdWUrCW.js";import{l as X}from"./lodash-Bmg8FrMx.js";import{u as Y}from"./use-previous-VKMmnaK7.js";import{T as Z,C as K}from"./table-033R9jUC.js";import"./index-cCpkwrS5.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./label-uCFEME1p.js";import"./common-types-U65vzrrz.js";import"./help-icon-SKky6KLV.js";import"./tooltip-HEHiU__l.js";import"./index-miLrID2P.js";import"./icon-8EQazuuW.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-8sb_A2v4.js";import"./index-4QtD-hFu.js";import"./disabled-context-urNQThQz.js";import"./types-5uVBABF4.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./types-VB5zD18b.js";import"./text-6KQ6ntOV.js";import"./actions-mOcj9IlF.js";import"./button-shH4xakS.js";import"./spinner-R8Il4aRe.js";import"./badge-23Ty_zBt.js";import"./select.input-zP5tW20f.js";import"./index.es-VXFRDikp.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./pagination-tnyyuMkB.js";import"./input-2BhbKV-j.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-CMhEMmUd.js";import"./check-box-2gxosI3y.js";import"./slider-MN9iDCsS.js";import"./index-ugi_ZH6T.js";import"./popover-cad2llTa.js";const ee=a=>a.reduce(({preferredUnits:n,storageUnits:t},{unitKey:o,preferredUnit:u,storageUnit:c})=>(n[o]=u,t[o]=c,{preferredUnits:n,storageUnits:t}),{preferredUnits:{},storageUnits:{}}),te=({headers:a,rows:n,selectedUnits:t,storageUnits:o,onChangeUnit:u,convertBackToStorageUnit:c,enableCosmeticRounding:r,enableDisplayRounding:d,roundDisplayValue:p})=>{const f=a?a.map(s=>({...s,cells:s.cells.map(l=>{if(l.type===K.AUTO_UNIT){const{unitKey:e}=l;return{value:t[e],type:K.SELECT,options:U.getUnitsForQuantity(e),native:!0,onChange:b=>u({unitKey:e,value:b.target.value})}}return l})})):[],m=n?n.map((s,l)=>({...s,cells:s.cells.map((e,b)=>{if("autoUnit"in e&&(e!=null&&e.autoUnit)&&(typeof(e==null?void 0:e.value)=="string"||typeof(e==null?void 0:e.value)=="number")){const{formatDisplayValue:g,unitKey:y,value:T}=e,x=t[y],v=o[y],S=x!==v,N=S?U.convertAndGetValue(T,x,v):e.value,B=U.isScientificStringNum(T),A=r&&(S||!B)?U.roundToPrecision(N,14):N,k=g?g(A):A;return{...e,value:k,enableCosmeticRounding:r,enableDisplayRounding:d,roundDisplayValue:p,onChange:w=>{const{value:_}=w.target,V=o[y],I=t[y],O=I!==V?U.convertAndGetValue(_,V,I):_,L=c?V:I;if("onChange"in e){const{onChange:Q}=e,J={...w,target:{...w.target,value:String(O),rowIndex:l,cellIndex:b,unit:L}};Q(J)}}}}return e})})):[];return{convertedHeaders:f,convertedRows:m}},j=({table:a,unitConfig:n,convertBackToStorageUnit:t=!0,enableCosmeticRounding:o=!0,enableDisplayRounding:u=!0,roundDisplayValue:c})=>{const{rows:r,headers:d,...p}=a,{storageUnits:f,preferredUnits:m}=ee(n),s=Y(m),[l,e]=h.useState(m),b=({unitKey:v,value:S})=>e({...l,[v]:S}),g=v=>te({headers:d,rows:r,selectedUnits:v,storageUnits:f,onChangeUnit:b,convertBackToStorageUnit:t,enableCosmeticRounding:o,enableDisplayRounding:u,roundDisplayValue:c}),y=g(l),[T,x]=h.useState(y);return h.useEffect(()=>{!X.isEqual(m,s)&&(e(m),x(g(m)))},[n]),h.useEffect(()=>{x(g(l))},[a,l]),i.jsx(Z,{table:{...p,headers:T.convertedHeaders,rows:T.convertedRows}})};try{j.displayName="UnitTable",j.__docgenInfo={description:"",displayName:"UnitTable",props:{table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"IUnitTable"}},unitConfig:{defaultValue:null,description:"",name:"unitConfig",required:!0,type:{name:"IUnitConfigItem[]"}},convertBackToStorageUnit:{defaultValue:{value:"true"},description:"",name:"convertBackToStorageUnit",required:!1,type:{name:"boolean"}},enableCosmeticRounding:{defaultValue:{value:"true"},description:"",name:"enableCosmeticRounding",required:!1,type:{name:"boolean"}},enableDisplayRounding:{defaultValue:{value:"true"},description:"",name:"enableDisplayRounding",required:!1,type:{name:"boolean"}},roundDisplayValue:{defaultValue:null,description:"",name:"roundDisplayValue",required:!1,type:{name:"((value: TStringNumberNull) => TStringNumberNull)"}},onListReorder:{defaultValue:null,description:"",name:"onListReorder",required:!1,type:{name:"((obj: { from: number; to: number; }) => void)"}}}}}catch{}const at={title:"Basic/UnitTable",args:{}},ne=!0,re=!0,G="m",ae=3,oe=(a,n)=>{const t=[n,n,n],o=[...Array(Number(a))].map((u,c)=>{const r=c,d=c+1.25,p=d-r;return[String(r),String(d),String(p)]});return[t].concat(o)},ie=oe(ae,G),se=({reduxTable:a,value:n,rowIndex:t,cellIndex:o})=>$(a,u=>{u[t+1][o]=n}),C=()=>{const[a,n]=h.useState(G),[t,o]=h.useState(ie),u=r=>{const{rowIndex:d,cellIndex:p,value:f,unit:m}=r.target,s=se({reduxTable:t,value:f,rowIndex:d,cellIndex:p});o(s)},c=t.reduce((r,d,p)=>(p===0?r.headers=[{cells:[{value:"From"},{value:"To"},{value:"Delta"}]},{cells:[{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"}]}]:r.rows=r.rows.concat({cells:d.map((f,m)=>{const s=p===1&&m===1;return{value:f,type:s?"Text":"NumberInput",unitKey:"length",onChange:u,formatDisplayValue:s?g=>`T* ${g}`:null,autoUnit:!0}})}),r),{headers:[],rows:[]});return i.jsxs(z,{columns:"1fr 1fr",gap:!0,children:[i.jsx(D,{heading:i.jsx(R,{children:"Global View Settings"}),children:i.jsx(M,{label:"Active Unit Template",children:i.jsx(W,{options:U.getUnitsForQuantity("length"),value:{value:a},onChange:r=>n(r.target.value),width:"100px"})})}),i.jsx(D,{heading:i.jsx(R,{children:"UnitTable"}),children:i.jsx(j,{table:c,unitConfig:[{unitKey:"length",storageUnit:t[0][0],preferredUnit:a}],convertBackToStorageUnit:ne,enableCosmeticRounding:re})}),i.jsx(D,{heading:i.jsx(R,{children:"Storage State (Redux)"}),children:i.jsx("pre",{children:i.jsx("code",{children:JSON.stringify(t,null,2)})})})]})};var E,H,F,P,q;C.parameters={...C.parameters,docs:{...(E=C.parameters)==null?void 0:E.docs,source:{originalSource:`() => {
2
- const [preferredUnit, setPreferredUnit] = useState(initialUnit);
3
- const [reduxTable, setReduxTable] = useState(initialTable);
4
-
5
- /*********************************************************************************************************************
6
- Cell onChange handler
7
- *********************************************************************************************************************/
8
- const onUpdateCell = (evt: IUnitTableOnChangeEvent) => {
9
- const {
10
- rowIndex,
11
- cellIndex,
12
- value,
13
- unit
14
- } = evt.target;
15
- const nextTable = convertWholeTable ? convertStorageTable({
16
- reduxTable,
17
- value,
18
- unit,
19
- rowIndex,
20
- cellIndex
21
- }) : updateCell({
22
- reduxTable,
23
- value,
24
- rowIndex,
25
- cellIndex
26
- });
27
- setReduxTable(nextTable);
28
- };
29
-
30
- /*********************************************************************************************************************
31
- Construct table view data (same as old Table component, with a new props)
32
- *********************************************************************************************************************/
33
- const tableViewData = reduxTable.reduce((acc, row, rowIndex) => {
34
- if (rowIndex === 0) {
35
- acc.headers = [{
36
- cells: [{
37
- value: 'From'
38
- }, {
39
- value: 'To'
40
- }, {
41
- value: 'Delta'
42
- }]
43
- }, {
44
- cells: [{
45
- type: 'AutoUnit',
46
- unitKey: 'length'
47
- }, {
48
- type: 'AutoUnit',
49
- unitKey: 'length'
50
- }, {
51
- type: 'AutoUnit',
52
- unitKey: 'length'
53
- }]
54
- }];
55
- } else {
56
- acc.rows = acc.rows.concat({
57
- cells: row.map((cell, cellIndex) => {
58
- const specialCell = rowIndex === 1 && cellIndex === 1;
59
- const type = specialCell ? 'Text' : 'NumberInput';
60
- const formatDisplayValue = specialCell ? (value: number | string) => \`T* \${value}\` : null;
61
- const value = cell;
62
- return {
63
- value,
64
- type,
65
- unitKey: 'length',
66
- onChange: onUpdateCell,
67
- formatDisplayValue,
68
- autoUnit: true
69
- };
70
- })
71
- });
72
- }
73
- return acc;
74
- }, {
75
- headers: ([] as any[]),
76
- rows: ([] as IUnitTableRow[])
77
- });
78
- return <Grid columns="1fr 1fr" gap>
79
- <Card heading={<Heading>Global View Settings</Heading>}>
80
- <Field label="Active Unit Template">
81
- <Select options={getUnitsForQuantity('length')} value={{
82
- value: preferredUnit
83
- }} onChange={evt => setPreferredUnit(evt.target.value)} width="100px" />
84
- </Field>
85
- </Card>
86
- <Card heading={<Heading>UnitTable</Heading>}>
87
- <UnitTable table={tableViewData}
88
- //New props:
89
- unitConfig={[{
90
- unitKey: 'length',
91
- storageUnit: reduxTable[0][0],
92
- preferredUnit
93
- }]}
94
- //Most tables should just use the default values here (true):
95
- convertBackToStorageUnit={convertBackToStorageUnit} enableCosmeticRounding={enableCosmeticRounding} />
96
- </Card>
97
- <Card heading={<Heading>Storage State (Redux)</Heading>}>
98
- <pre>
99
- <code>{JSON.stringify(reduxTable, null, 2)}</code>
100
- </pre>
101
- </Card>
102
- </Grid>;
103
- }`,...(F=(H=C.parameters)==null?void 0:H.docs)==null?void 0:F.source},description:{story:"Story",...(q=(P=C.parameters)==null?void 0:P.docs)==null?void 0:q.description}}};const ot=["UnitTablePrototype"];export{C as UnitTablePrototype,ot as __namedExportsOrder,at as default};