najwer23morsels 1.10.28 → 1.10.31
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/ButtonCopy/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{useState as r,useRef as o,useCallback as e,useEffect as i}from"react";import{B as n}from"../Button-QC014EKI.js";import{T as a}from"../TextBox-__k4jPYK.js";import"../Loader-ZYEBOkbx.js";import"../LoaderDots-BoEg_zlZ.js";import"../style-inject.es-CrVRO2OA.js";const c=({children:c,className:l,style:u,textToCopy:s,margin:m,height:p="auto",width:d="auto",padding:h="0px 3px",color:g="white",backgroundColor:y="orangered",...x})=>{const[j,B]=r(!1),C=o(null),T=e(async()=>{C.current&&(clearTimeout(C.current),C.current=null);try{await navigator.clipboard.writeText(s)}catch{return void B(!1)}B(!0),C.current=setTimeout(()=>{B(!1),C.current=null},800)},[s]);return i(()=>()=>{C.current&&clearTimeout(C.current)},[]),t("div",{className:["n23mButtonCopy",l].filter(Boolean).join(" "),style:u,...x,children:t(n,{type:"button",padding:h,height:p,width:d,margin:m,backgroundColor:j?"#4BB543":y,onClick:T,children:c??t(a,{mobileSize:10,desktopSize:10,fontWeight:600,lineHeight:"17px",color:g,children:"Copy"})})})};c.displayName="ButtonCopy";export{c as ButtonCopy};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SelectOption } from '../Select';
|
|
2
|
+
import { ValidatorOptions } from '../validator';
|
|
2
3
|
export type TableRow = Record<string, string | number | boolean> & {
|
|
3
4
|
id: string | number;
|
|
4
5
|
};
|
|
@@ -7,6 +8,7 @@ type TableColumnBase = {
|
|
|
7
8
|
cellName: string;
|
|
8
9
|
disabledAdd?: boolean;
|
|
9
10
|
disabledEdit?: boolean;
|
|
11
|
+
validatorOptions?: ValidatorOptions;
|
|
10
12
|
thAlign?: 'left' | 'right';
|
|
11
13
|
tdAlign?: 'left' | 'right';
|
|
12
14
|
};
|
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
|
|
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 b}from"../TextBox-__k4jPYK.js";import{T as h}from"../Typography-CZqNLAT7.js";import{s as g,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"};g('@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:g,jsonSchema:x,jsonData:f,cellEdit:_,cellDelete:k,onCellReset:y,isLoading:T=!1,style:v,tableLoadingHeight:C,...S})=>{const[w,j]=o(!1),[z,D]=o(!1),[N,E]=o(0),[M,B]=o(null),{onCellEdit:F,isCellEditError:I=!1,isCellEditPending:Y=!1,isCellEditSuccess:J=!1,cellEditErrorMsg:O,cellEditSuccessMsg:W}=_??{},{onCellDelete:V,isCellDeleteError:P=!1,isCellDeletePending:L=!1,isCellDeleteSuccess:A=!1,cellDeleteErrorMsg:G,cellDeleteSuccessMsg:X}=k??{},K=Boolean(F),R=Boolean(V),H=x.cols.filter(e=>"id"!==e.cellName),q=()=>{y&&setTimeout(()=>y(),300)},Q=()=>{D(!1),q()},U=()=>{D(!1),j(!1),q()};return e("div",{className:[u.n23mTable,"n23mTable",g].filter(Boolean).join(" "),...S,style:{...m({"--table-loading-height":C}),...v},children:[K&&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(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:O,successMsg:W,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 o=t||e.initialValue;return l(i,{label:e.cellText,name:e.cellName,disabled:e.disabledEdit,initialValue:o,placeholder:e.cellText,validatorOptions:e.validatorOptions},e.cellName)}if("select"===e.cellType){const o=e.options.find(e=>e.value===String(t??""))??e.initialValue;return l(p,{name:e.cellName,options:e.options,disabled:e.disabledEdit,initialValue:o,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: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||L,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(a,{type:"submit",height:"40px",width:"auto",padding:"0 10px",disabled:Y||L,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:A?U: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:A?"Deleted":"Are you sure?"}),!A&&l(b,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"black",children:"This row will be permanently deleted. This action cannot be undone."}),P&&!A&&l(b,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"red",style:{margin:"10px 0 0 0"},children:G??"Delete failed"}),A&&l(b,{tag:"p",desktopSize:16,mobileSize:16,fontWeight:400,color:"#4BB543",children:X??"Row deleted"}),l(d,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:A?"flex-end":"space-between",margin:"20px 0 0 0",children:A?l(a,{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(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:L,backgroundColor:"grey",backgroundColorDisabled:"grey",onClick:Q,children:l(b,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Cancel"})}),l(a,{type:"button",height:"40px",width:"auto",padding:"0 10px",disabled:L,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{V&&M&&V(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":T,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: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":K,onClick:K?()=>(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===o?"":String(o)})},t.cellName)})},e.id))})]})]})};x.displayName="Table";export{x as Table};
|
package/lib/validator/index.d.ts
CHANGED
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type: 'empty';
|
|
3
|
-
} | {
|
|
4
|
-
type: 'email';
|
|
5
|
-
} | {
|
|
6
|
-
type: 'numberInRange';
|
|
7
|
-
options?: {
|
|
8
|
-
min?: number;
|
|
9
|
-
max?: number;
|
|
10
|
-
};
|
|
11
|
-
} | {
|
|
12
|
-
type: 'naturalNumber';
|
|
13
|
-
} | {
|
|
14
|
-
type: 'decimalDigits';
|
|
15
|
-
options?: {
|
|
16
|
-
digits: number;
|
|
17
|
-
};
|
|
18
|
-
} | {
|
|
19
|
-
type: 'date';
|
|
20
|
-
} | {
|
|
21
|
-
type: 'json';
|
|
22
|
-
} | {
|
|
23
|
-
type: 'equal';
|
|
24
|
-
options: {
|
|
25
|
-
ref: React.RefObject<HTMLInputElement | null>;
|
|
26
|
-
};
|
|
27
|
-
} | {
|
|
28
|
-
type: 'existsInOptions';
|
|
29
|
-
options: {
|
|
30
|
-
options: {
|
|
31
|
-
value: string;
|
|
32
|
-
label: string;
|
|
33
|
-
}[];
|
|
34
|
-
matchBy?: 'value' | 'label';
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export type ValidatorOptions = ValidatorOption[];
|
|
1
|
+
import { ValidatorOptions } from './validator.types';
|
|
38
2
|
export declare const validator: (value: string, validatorOptions: ValidatorOptions) => string[];
|
|
39
|
-
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type ValidatorOption = {
|
|
2
|
+
type: 'empty';
|
|
3
|
+
} | {
|
|
4
|
+
type: 'email';
|
|
5
|
+
} | {
|
|
6
|
+
type: 'numberInRange';
|
|
7
|
+
options?: {
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
type: 'naturalNumber';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'decimalDigits';
|
|
15
|
+
options?: {
|
|
16
|
+
digits: number;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
type: 'date';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'json';
|
|
22
|
+
} | {
|
|
23
|
+
type: 'equal';
|
|
24
|
+
options: {
|
|
25
|
+
ref: React.RefObject<HTMLInputElement | null>;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
type: 'existsInOptions';
|
|
29
|
+
options: {
|
|
30
|
+
options: {
|
|
31
|
+
value: string;
|
|
32
|
+
label: string;
|
|
33
|
+
}[];
|
|
34
|
+
matchBy?: 'value' | 'label';
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type ValidatorOptions = ValidatorOption[];
|
|
38
|
+
export type ValidatorFn = (value: string, options?: any) => string | null;
|