najwer23morsels 1.10.26 → 1.10.28
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/index.js +1 -1
- package/lib/validator/index.js +1 -1
- package/package.json +1 -1
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 a}from"react";import{B as o}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 b}from"../TextBox-__k4jPYK.js";import{T as g}from"../Typography-CZqNLAT7.js";import{s as h,g as m}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"};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]{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:h,jsonSchema:x,jsonData:f,cellEdit:_,cellDelete:y,onCellReset:
|
|
1
|
+
import{jsxs as e,jsx as l,Fragment as t}from"react/jsx-runtime";import{useState as a}from"react";import{B as o}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 b}from"../TextBox-__k4jPYK.js";import{T as g}from"../Typography-CZqNLAT7.js";import{s as h,g as m}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"};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]{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:h,jsonSchema:x,jsonData:f,cellEdit:_,cellDelete:y,onCellReset:T,isLoading:k=!1,style:C,tableLoadingHeight:v,...S})=>{const[w,j]=a(!1),[z,D]=a(!1),[N,E]=a(0),[M,B]=a(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=()=>{T&&setTimeout(()=>T(),300)},Q=()=>{D(!1),q()},U=()=>{D(!1),j(!1),q()};return e("div",{className:[u.n23mTable,"n23mTable",h].filter(Boolean).join(" "),...S,style:{...m({"--table-loading-height":v}),...C},children:[O&&l(n,{open:w,onCancel:()=>{j(!1),q()},widthMax:"900px",children:e(d,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(g,{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=M[e.cellName];if("date"===e.cellType){const a=t||e.initialValue;return l(i,{label:e.cellText,name:e.cellName,disabled:e.disabledEdit,initialValue:a,placeholder:e.cellText},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},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},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(o,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:Y||A,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{R&&M&&D(!0)},children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Delete"})}),l(o,{type:"submit",height:"40px",width:"auto",padding:"0 10px",disabled:Y||A,backgroundColor:"#4BB543",backgroundColorDisabled:"grey",children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Save changes"})})]})]},N)]})}),R&&l(n,{open:z,onCancel:G?U:Q,widthMax:"450px",children:e(d,{layout:"container",widthMin:"min(400px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(g,{appearance:"light",variant:"subheading",style:{margin:"0 0 10px 0"},children:G?"Deleted":"Are you sure?"}),!G&&l(b,{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(b,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"red",style:{margin:"10px 0 0 0"},children:X??"Delete failed"}),G&&l(b,{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(o,{type:"button",height:"40px",width:"auto",padding:"0 10px",backgroundColor:"#4BB543",onClick:U,children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Close"})}):e(t,{children:[l(o,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:A,backgroundColor:"grey",backgroundColorDisabled:"grey",onClick:Q,children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Cancel"})}),l(o,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:A,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{P&&M&&P(M.id)},children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Yes, delete"})})]})})]})}),e("table",{className:u.table,"aria-busy":k,children:[l("thead",{children:l("tr",{children:H.map(e=>l("th",{scope:"col",children:l(b,{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: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 a=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(b,{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/lib/validator/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>""===e||(e=>{const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;const n=Number(t[1]),r=Number(t[2]),u=Number(t[3]);if(r<1||r>12)return!1;const l=[31,28,31,30,31,30,31,31,30,31,30,31];return(n%400==0||n%100!=0&&n%4==0)&&(l[1]=29),u>=1&&u<=l[r-1]})(e),t={empty:e=>""===e.trim()||null===e.trim()?"The field cannot be empty.":null,equal:(e,t)=>{const n=t?.ref?.current?.value;return e&&n&&e!==n?"Values do not match.":null},email:e=>/^(?!.*\.{2})(?!.*\.$)(?!^\.)([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(e)?null:"Incorrect email address.",numberInRange:(e,t)=>{const n=Number(e),r=t?.min??0,u=t?.max??1e4;return isNaN(n)||n<r||n>u?`The number must be between ${r} and ${u}.`:null},date:t=>e(t)?null:"The date is invalid.",existsInOptions:(e,t)=>{const n=t?.options??[],r=t?.matchBy??"value";return n.some(t=>"value"===r?t.value===e:t.label===e)?null:"Please select a value from the list."},json:e=>{try{const t=JSON.parse(e);return null===t||"object"!=typeof t&&!Array.isArray(t)?"The value must be a valid JSON":null}catch{return"The value must be a valid JSON."}},naturalNumber:e=>{if(!/^([1-9][0-9]*|0)$/.test(e))return"The number must be a natural number (positive integer).";const t=Number(e);return isNaN(t)||t<=0||!Number.isInteger(t)?"The number must be a natural number (positive integer).":null},decimalDigits:(e,t)=>{const n=Number(e);if(isNaN(n))return"The value must be a valid number.";if(void 0===t?.digits)return null;if(!e.includes("."))return`The number must have exactly ${t.digits} digit(s) after the decimal point.`;return e.split(".")[1].length!==t.digits?`The number must have exactly ${t.digits} digit(s) after the decimal point.`:null}},n=(e,n)=>n.map(n=>"options"in n?t[n.type](e,n.options):t[n.type](e)).filter(e=>null!=e);export{n as validator};
|
|
1
|
+
const e=e=>""===e||(e=>{const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;const n=Number(t[1]),r=Number(t[2]),u=Number(t[3]);if(r<1||r>12)return!1;const l=[31,28,31,30,31,30,31,31,30,31,30,31];return(n%400==0||n%100!=0&&n%4==0)&&(l[1]=29),u>=1&&u<=l[r-1]})(e),t={empty:e=>""===e.trim()||null===e.trim()?"The field cannot be empty.":null,equal:(e,t)=>{const n=t?.ref?.current?.value;return e&&n&&e!==n?"Values do not match.":null},email:e=>/^(?!.*\.{2})(?!.*\.$)(?!^\.)([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(e)?null:"Incorrect email address.",numberInRange:(e,t)=>{const n=Number(e),r=t?.min??0,u=t?.max??1e4;return isNaN(n)||n<r||n>u?`The number must be between ${r} and ${u}.`:null},date:t=>e(t)?null:"The date is invalid.",existsInOptions:(e,t)=>{const n=t?.options??[],r=t?.matchBy??"value";return n.some(t=>"value"===r?t.value===e:t.label===e)?null:"Please select a value from the list."},json:e=>{try{const t=JSON.parse(e);return null===t||"object"!=typeof t&&!Array.isArray(t)?"The value must be a valid JSON":null}catch{return"The value must be a valid JSON."}},naturalNumber:e=>{if(""===e)return null;if(!/^([1-9][0-9]*|0)$/.test(e))return"The number must be a natural number (positive integer).";const t=Number(e);return isNaN(t)||t<=0||!Number.isInteger(t)?"The number must be a natural number (positive integer).":null},decimalDigits:(e,t)=>{if(""===e)return null;const n=Number(e);if(isNaN(n))return"The value must be a valid number.";if(void 0===t?.digits)return null;if(!e.includes("."))return`The number must have exactly ${t.digits} digit(s) after the decimal point.`;return e.split(".")[1].length!==t.digits?`The number must have exactly ${t.digits} digit(s) after the decimal point.`:null}},n=(e,n)=>n.map(n=>"options"in n?t[n.type](e,n.options):t[n.type](e)).filter(e=>null!=e);export{n as validator};
|