najwer23morsels 1.10.21 → 1.10.22
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/lib/Table/Table.d.ts +2 -0
- package/lib/Table/index.js +1 -1
- package/package.json +1 -1
package/lib/Table/Table.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface TableProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
cellEdit?: TableCellEdit;
|
|
11
11
|
cellDelete?: TableCellDelete;
|
|
12
12
|
onCellReset?: () => void;
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
tableLoadingHeight?: React.CSSProperties['height'];
|
|
13
15
|
}
|
|
14
16
|
export declare const Table: React.FC<TableProps>;
|
|
15
17
|
export {};
|
package/lib/Table/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as l,Fragment as t}from"react/jsx-runtime";import{useState as o}from"react";import{B as
|
|
1
|
+
import{jsxs as e,jsx as l,Fragment as t}from"react/jsx-runtime";import{useState as o}from"react";import{B as a}from"../Button-QC014EKI.js";import{C as i}from"../Calendar-BkDrBfRy.js";import{D as n}from"../Dialog-8B0xk8Wx.js";import{F as r}from"../Form-CgTuTB2Q.js";import{G as d}from"../Grid-DmI4tqqG.js";import{I as s}from"../Input-Bl7_BOs4.js";import{L as c}from"../LoaderDots-BoEg_zlZ.js";import{S as p}from"../Select-QBTZllFj.js";import{T as g}from"../TextBox-__k4jPYK.js";import{T as h}from"../Typography-CZqNLAT7.js";import{s as m,g as b}from"../style-inject.es-CrVRO2OA.js";import"../Loader-ZYEBOkbx.js";import"../IconLocate-CQda7FAB.js";import"../validator/index.js";var u={n23mTable:"Table-module_n23mTable__kKVd9",table:"Table-module_table__hJFsY",loadingCell:"Table-module_loadingCell__mIX-P",loadingInner:"Table-module_loadingInner__GlNjv"};m('@layer n23mTable{.Table-module_n23mTable__kKVd9{--hover-bg:rgba(0,0,0,.11);background-attachment:local,local,scroll,scroll;background-color:#fff;background-image:linear-gradient(90deg,#fff 20px,hsla(0,0%,100%,0)),linear-gradient(270deg,#fff 20px,hsla(0,0%,100%,0)),radial-gradient(farthest-side at 0 50%,rgba(0,0,0,.25),transparent),radial-gradient(farthest-side at 100% 50%,rgba(0,0,0,.25),transparent);background-position:0,100%,0,100%;background-repeat:no-repeat;background-size:40px 100%,40px 100%,14px 100%,14px 100%;isolation:isolate;overflow-x:auto;overflow-y:hidden}.Table-module_n23mTable__kKVd9:focus-visible{outline:2px solid currentcolor;outline-offset:2px}.Table-module_table__hJFsY{border-collapse:collapse;min-width:max-content;width:100%}.Table-module_table__hJFsY td,.Table-module_table__hJFsY th{border:1px solid grey;padding:10px 12px;position:relative}.Table-module_table__hJFsY td[data-clickable=true]{cursor:pointer}.Table-module_table__hJFsY td.Table-module_loadingCell__mIX-P{cursor:default;padding:0}.Table-module_loadingInner__GlNjv{align-items:flex-start;box-sizing:border-box;display:flex;justify-content:flex-start;min-height:var(--table-loading-height,219.25px);padding:10px}@media (hover:hover){.Table-module_table__hJFsY tbody tr:hover>td{background-color:var(--hover-bg)}.Table-module_table__hJFsY tbody td:hover:after{background-color:var(--hover-bg);content:"";inset:-100vh 0;pointer-events:none;position:absolute;z-index:-1}.Table-module_table__hJFsY tbody tr:hover>td.Table-module_loadingCell__mIX-P{background-color:transparent}.Table-module_table__hJFsY tbody td.Table-module_loadingCell__mIX-P:hover:after{content:none}}}');const x=({className:m,jsonSchema:x,jsonData:f,cellEdit:_,cellDelete:y,onCellReset:k,isLoading:T=!1,style:C,tableLoadingHeight:v,...S})=>{const[w,j]=o(!1),[z,N]=o(!1),[D,E]=o(0),[M,B]=o(null),{onCellEdit:F,isCellEditError:I=!1,isCellEditPending:Y=!1,isCellEditSuccess:J=!1,cellEditErrorMsg:W,cellEditSuccessMsg:V}=_??{},{onCellDelete:P,isCellDeleteError:L=!1,isCellDeletePending:A=!1,isCellDeleteSuccess:G=!1,cellDeleteErrorMsg:X,cellDeleteSuccessMsg:K}=y??{},O=Boolean(F),R=Boolean(P),H=x.cols.filter(e=>"id"!==e.cellName),q=()=>{N(!1),k?.()},Q=()=>{N(!1),j(!1),k?.()};return e("div",{className:[u.n23mTable,"n23mTable",m].filter(Boolean).join(" "),...S,style:{...b({"--table-loading-height":v}),...C},children:[O&&l(n,{open:w,onCancel:()=>{j(!1),k?.()},widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(h,{appearance:"light",variant:"subheading",style:{margin:"0 0 20px 0"},children:"Edit Cell"}),e(r,{onSubmit:e=>{if(!F)return;if(Object.values(e).some(({error:e})=>e))return;const l=Object.fromEntries(Object.entries(e).map(([e,{value:l}])=>[e,l]));F(l)},isError:I,isPending:Y,isSuccess:J,errorMsg:W,successMsg:V,children:[l(d,{layout:"columns",col:{smallDesktop:2},gap:{col:"20px"},children:M&&x.cols.map(e=>{const t="id"===e.cellName,o=M[e.cellName];if("date"===e.cellType){const t=o||e.initialValue;return l(i,{label:e.cellText,name:e.cellName,initialValue:t,placeholder:e.cellText},e.cellName)}if("select"===e.cellType){const t=e.options.find(e=>e.value===String(o??""))??e.initialValue;return l(p,{name:e.cellName,options:e.options,initialValue:t},e.cellName)}return l(s,{label:e.cellText,name:e.cellName,type:e.cellType,step:"number"===e.cellType?.01:void 0,defaultValue:String(o??""),disabled:t,placeholder:e.cellText},e.cellName)})}),e(d,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:R?"space-between":"flex-end",alignItems:"right",margin:"20px 0 0 0",children:[R&&l(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:Y||A,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{R&&M&&N(!0)},children:l(g,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Delete"})}),l(a,{type:"submit",height:"40px",width:"auto",padding:"0 10px",disabled:Y||A,backgroundColor:"#4BB543",backgroundColorDisabled:"grey",children:l(g,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Save"})})]})]},D)]})}),R&&l(n,{open:z,onCancel:G?Q:q,widthMax:"450px",children:e(d,{layout:"container",widthMin:"min(400px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(h,{appearance:"light",variant:"subheading",style:{margin:"0 0 10px 0"},children:G?"Deleted":"Are you sure?"}),!G&&l(g,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"black",children:"This row will be permanently deleted. This action cannot be undone."}),L&&!G&&l(g,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"red",style:{margin:"10px 0 0 0"},children:X??"Delete failed"}),G&&l(g,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"#4BB543",children:K??"Row deleted"}),l(d,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:G?"flex-end":"space-between",margin:"20px 0 0 0",children:G?l(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",backgroundColor:"#4BB543",onClick:Q,children:l(g,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Close"})}):e(t,{children:[l(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:A,backgroundColor:"grey",backgroundColorDisabled:"grey",onClick:q,children:l(g,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Cancel"})}),l(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:A,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{P&&M&&P(M.id)},children:l(g,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Yes, delete"})})]})})]})}),e("table",{className:u.table,"aria-busy":T,children:[l("thead",{children:l("tr",{children:H.map(e=>l("th",{scope:"col",children:l(g,{mobileSize:16,desktopSize:20,color:"black",textAlign:e.thAlign??"left",children:e.cellText})},e.cellName))})}),l("tbody",{children:T?l("tr",{children:l("td",{className:u.loadingCell,colSpan:Math.max(H.length,1),children:l("div",{className:u.loadingInner,children:l(c,{})})})}):f.rows.map(e=>l("tr",{children:H.map(t=>{const o=e[t.cellName];return l("td",{"data-clickable":O,onClick:O?()=>(e=>{B(e),j(!0),E(e=>e+1)})(e):void 0,children:l(g,{fontWeight:400,mobileSize:16,desktopSize:16,color:"black",textAlign:t.tdAlign??"left",children:void 0===o?"":String(o)})},t.cellName)})},e.id))})]})]})};x.displayName="Table";export{x as Table};
|