najwer23morsels 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{jsxs as e,jsx as l,Fragment as t}from"react/jsx-runtime";import{useState as a}from"react";import{B as i}from"../Button-BDPxqgFb.js";import{C as o}from"../Calendar-BCqWc3BZ.js";import{D as n}from"../Dialog-eSjNkfJK.js";import{F as r}from"../Form-GEUDMZ7Z.js";import{G as d}from"../Grid-DmI4tqqG.js";import{I as s}from"../Input-BJj54qdT.js";import{L as c}from"../LoaderDots-BoEg_zlZ.js";import{S as p}from"../Select-CQBKuf2T.js";import{T as m}from"../TextBox-__k4jPYK.js";import{T as b}from"../Typography-CR1DOKsN.js";import{s as h,g}from"../style-inject.es-CrVRO2OA.js";import{V as u}from"../validator.const-LBF9whmW.js";import"../IconLocate-BXomEqkx.js";import"../Loader-ZYEBOkbx.js";import"../validator/index.js";var f={n23mTable:"Table-module_n23mTable__kKVd9",table:"Table-module_table__hJFsY",loadingCell:"Table-module_loadingCell__mIX-P",loadingInner:"Table-module_loadingInner__GlNjv"};h('@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]{-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.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:h,jsonSchema:x,jsonData:_,cellEdit:v,cellDelete:y,onCellReset:T,isLoading:k=!1,style:S,tableLoadingHeight:C,...j})=>{const[z,w]=a(!1),[N,E]=a(!1),[D,M]=a(0),[F,I]=a(null),{onCellEdit:Y,isCellEditError:J=!1,isCellEditPending:O=!1,isCellEditSuccess:V=!1,cellEditErrorMsg:W,cellEditSuccessMsg:P}=v??{},{onCellDelete:B,isCellDeleteError:L=!1,isCellDeletePending:A=!1,isCellDeleteSuccess:G=!1,cellDeleteErrorMsg:X,cellDeleteSuccessMsg:K}=y??{},R=Boolean(Y),H=Boolean(B),q=x.cols.filter(e=>"id"!==e.cellName),Q=()=>{T&&setTimeout(()=>T(),300)},U=()=>{E(!1),Q()},Z=()=>{E(!1),w(!1),Q()};return e("div",{className:[f.n23mTable,"n23mTable",h].filter(Boolean).join(" "),...j,style:{...g({"--table-loading-height":C}),...S},children:[R&&l(n,{open:z,onCancel:()=>{w(!1),Q()},widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(b,{appearance:"light",variant:"subheading",tag:"h2",style:{margin:"0 0 20px 0"},children:"Edit Cell"}),e(r,{onSubmit:e=>{if(!Y)return;if(Object.values(e).some(({error:e})=>e))return;const l=Object.fromEntries(Object.entries(e).map(([e,{value:l}])=>[e,l]));Y(l)},isError:J,isPending:O,isSuccess:V,errorMsg:W,successMsg:P,children:[l(d,{layout:"columns",col:{smallDesktop:2},gap:{col:"20px"},children:F&&x.cols.map(e=>{const t=F[e.cellName];if("date"===e.cellType){const a=t||e.initialValue;return l(o,{label:e.cellText,name:e.cellName,disabled:e.disabledEdit,initialValue:a,placeholder:e.cellText,validatorOptions:e.validatorOptions},e.cellName)}if("select"===e.cellType){const a=e.options.find(e=>e.value===String(t??""))??e.initialValue;return l(p,{name:e.cellName,options:e.options,disabled:e.disabledEdit,initialValue:a,validatorOptions:e.validatorOptions},e.cellName)}return l(s,{label:e.cellText,name:e.cellName,type:e.cellType,step:"number"===e.cellType?.01:void 0,defaultValue:String(t??""),disabled:e.disabledEdit,placeholder:e.cellText,validatorOptions:e.validatorOptions},e.cellName)})}),e(d,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:H?"space-between":"flex-end",alignItems:"right",margin:"20px 0 0 0",children:[H&&l(i,{type:"button",variant:"danger",disabled:O||A,onClick:()=>{H&&F&&E(!0)},children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Delete"})}),l(i,{type:"submit",variant:"success",disabled:O||A,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Save changes"})})]})]},D)]})}),H&&l(n,{open:N,onCancel:G?Z:U,widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(500px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(b,{appearance:"light",variant:"subheading",tag:"h2",style:{margin:"0 0 10px 0"},children:G?"Deleted":"Are you sure?"}),!G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,children:"This row will be permanently deleted. This action cannot be undone."}),L&&!G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:u.error,style:{margin:"10px 0 0 0"},children:X??"Delete failed"}),G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:u.success,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(i,{type:"button",variant:"success",onClick:Z,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Close"})}):e(t,{children:[l(i,{type:"button",variant:"secondary",disabled:A,onClick:U,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Cancel"})}),l(i,{type:"button",variant:"danger",disabled:A,onClick:()=>{B&&F&&B(F.id)},children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Yes, delete"})})]})})]})}),e("table",{className:f.table,"aria-busy":k,children:[l("thead",{children:l("tr",{children:q.map(e=>l("th",{scope:"col",children:l(b,{variant:"body",tag:"span",mobileSize:16,desktopSize:20,color:"black",textAlign:e.thAlign??"left",children:e.cellText})},e.cellName))})}),l("tbody",{children:k?l("tr",{children:l("td",{className:f.loadingCell,colSpan:Math.max(q.length,1),children:l("div",{className:f.loadingInner,children:l(c,{})})})}):_.rows.map(e=>l("tr",{children:q.map(t=>{const a=e[t.cellName];return l("td",{"data-clickable":R,onClick:R?()=>(e=>{I(e),w(!0),M(e=>e+1)})(e):void 0,children:l(b,{variant:"body",tag:"span",fontWeight:400,mobileSize:16,desktopSize:16,color:"black",textAlign:t.tdAlign??"left",children:void 0===a?"":String(a)})},t.cellName)})},e.id))})]})]})};x.displayName="Table";export{x as Table};
1
+ import{jsxs as e,jsx as l,Fragment as t}from"react/jsx-runtime";import{useState as a}from"react";import{B as i}from"../Button-BDPxqgFb.js";import{C as o}from"../Calendar-BCqWc3BZ.js";import{D as n}from"../Dialog-eSjNkfJK.js";import{F as r}from"../Form-GEUDMZ7Z.js";import{G as d}from"../Grid-DmI4tqqG.js";import{I as s}from"../Input-BJj54qdT.js";import{L as c}from"../LoaderDots-BoEg_zlZ.js";import{S as p}from"../Select-CQBKuf2T.js";import{T as m}from"../TextBox-__k4jPYK.js";import{T as b}from"../Typography-CR1DOKsN.js";import{s as h,g}from"../style-inject.es-CrVRO2OA.js";import{V as u}from"../validator.const-LBF9whmW.js";import"../IconLocate-BXomEqkx.js";import"../Loader-ZYEBOkbx.js";import"../validator/index.js";var f={n23mTable:"Table-module_n23mTable__kKVd9",table:"Table-module_table__hJFsY",loadingCell:"Table-module_loadingCell__mIX-P",loadingInner:"Table-module_loadingInner__GlNjv"};h('@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]{-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.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:h,jsonSchema:x,jsonData:_,cellEdit:v,cellDelete:y,onCellReset:T,isLoading:k=!1,style:S,tableLoadingHeight:C,...j})=>{const[z,w]=a(!1),[N,E]=a(!1),[D,M]=a(0),[F,I]=a(null),{onCellEdit:Y,isCellEditError:J=!1,isCellEditPending:O=!1,isCellEditSuccess:V=!1,cellEditErrorMsg:W,cellEditSuccessMsg:P}=v??{},{onCellDelete:B,isCellDeleteError:L=!1,isCellDeletePending:A=!1,isCellDeleteSuccess:G=!1,cellDeleteErrorMsg:X,cellDeleteSuccessMsg:K}=y??{},R=Boolean(Y),H=Boolean(B),q=x.cols.filter(e=>"id"!==e.cellName),Q=()=>{T&&setTimeout(()=>T(),300)},U=()=>{E(!1),Q()},Z=()=>{E(!1),w(!1),Q()};return e("div",{className:[f.n23mTable,"n23mTable",h].filter(Boolean).join(" "),...j,style:{...g({"--table-loading-height":C}),...S},children:[R&&l(n,{open:z,onCancel:()=>{w(!1),Q()},widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(b,{appearance:"light",variant:"subheading",tag:"h2",style:{margin:"0 0 20px 0"},children:"Edit Cell"}),e(r,{onSubmit:e=>{if(!Y)return;if(Object.values(e).some(({error:e})=>e))return;const l=Object.fromEntries(Object.entries(e).map(([e,{value:l}])=>[e,l]));Y(l)},isError:J,isPending:O,isSuccess:V,errorMsg:W,successMsg:P,children:[l(d,{layout:"columns",col:{smallDesktop:2},gap:{col:"20px"},children:F&&x.cols.map(e=>{const t=F[e.cellName];if("date"===e.cellType){const a=t||e.initialValue;return l(o,{label:e.cellText,name:e.cellName,disabled:e.disabledEdit,initialValue:a,placeholder:e.cellText,validatorOptions:e.validatorOptions},e.cellName)}if("select"===e.cellType){const a=e.options.find(e=>e.value===String(t??""))??e.initialValue;return l(p,{name:e.cellName,options:e.options,disabled:e.disabledEdit,initialValue:a,validatorOptions:e.validatorOptions},e.cellName)}return l(s,{label:e.cellText,name:e.cellName,type:e.cellType,step:"number"===e.cellType?.01:void 0,defaultValue:String(t??""),disabled:e.disabledEdit,placeholder:e.cellText,validatorOptions:e.validatorOptions},e.cellName)})}),e(d,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:H?"space-between":"flex-end",alignItems:"right",margin:"20px 0 0 0",children:[H&&l(i,{type:"button",variant:"danger",disabled:O||A,onClick:()=>{H&&F&&E(!0)},children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Delete"})}),l(i,{type:"submit",variant:"success",disabled:O||A,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Save changes"})})]})]},D)]})}),H&&l(n,{open:N,onCancel:G?Z:U,widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(500px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(b,{appearance:"light",variant:"subheading",tag:"h2",style:{margin:"0 0 20px 0"},children:G?"Deleted":"Are you sure?"}),!G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,children:"This row will be permanently deleted. This action cannot be undone."}),L&&!G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:u.error,style:{margin:"10px 0 0 0"},children:X??"Delete failed"}),G&&l(b,{variant:"body",tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:u.success,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(i,{type:"button",variant:"success",onClick:Z,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Close"})}):e(t,{children:[l(i,{type:"button",variant:"secondary",disabled:A,onClick:U,children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Cancel"})}),l(i,{type:"button",variant:"danger",disabled:A,onClick:()=>{B&&F&&B(F.id)},children:l(m,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"inherit",children:"Yes, delete"})})]})})]})}),e("table",{className:f.table,"aria-busy":k,children:[l("thead",{children:l("tr",{children:q.map(e=>l("th",{scope:"col",children:l(b,{variant:"body",tag:"span",mobileSize:16,desktopSize:20,color:"black",textAlign:e.thAlign??"left",children:e.cellText})},e.cellName))})}),l("tbody",{children:k?l("tr",{children:l("td",{className:f.loadingCell,colSpan:Math.max(q.length,1),children:l("div",{className:f.loadingInner,children:l(c,{})})})}):_.rows.map(e=>l("tr",{children:q.map(t=>{const a=e[t.cellName];return l("td",{"data-clickable":R,onClick:R?()=>(e=>{I(e),w(!0),M(e=>e+1)})(e):void 0,children:l(b,{variant:"body",tag:"span",fontWeight:400,mobileSize:16,desktopSize:16,color:"black",textAlign:t.tdAlign??"left",children:void 0===a?"":String(a)})},t.cellName)})},e.id))})]})]})};x.displayName="Table";export{x as Table};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najwer23morsels",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "exports": {
5
5
  "./lib/*": {
6
6
  "types": "./lib/*/index.d.ts",