najwer23morsels 1.10.6 → 1.10.8

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,32 +1,4 @@
1
- import { SelectOption } from '../Select';
2
- type TableRow = Record<string, string | number | boolean> & {
3
- id: string | number;
4
- };
5
- type TableColumn = {
6
- cellText: string;
7
- cellName: string;
8
- cellType: 'select';
9
- options: SelectOption[];
10
- initialValue: SelectOption;
11
- thAlign?: 'left' | 'right';
12
- tdAlign?: 'left' | 'right';
13
- } | {
14
- cellText: string;
15
- cellName: string;
16
- cellType: 'date';
17
- options?: never;
18
- initialValue: '' | `${number}-${number}-${number}`;
19
- thAlign?: 'left' | 'right';
20
- tdAlign?: 'left' | 'right';
21
- } | {
22
- cellText: string;
23
- cellName: string;
24
- cellType: 'text' | 'number';
25
- initialValue?: never;
26
- options?: never;
27
- thAlign?: 'left' | 'right';
28
- tdAlign?: 'left' | 'right';
29
- };
1
+ import { TableColumn, TableRow } from './Table.types';
30
2
  interface TableProps extends React.HTMLAttributes<HTMLDivElement> {
31
3
  style?: React.CSSProperties;
32
4
  jsonSchema: {
@@ -0,0 +1,29 @@
1
+ import { SelectOption } from '../Select';
2
+ export type TableRow = Record<string, string | number | boolean> & {
3
+ id: string | number;
4
+ };
5
+ export type TableColumn = {
6
+ cellText: string;
7
+ cellName: string;
8
+ cellType: 'select';
9
+ options: SelectOption[];
10
+ initialValue: SelectOption;
11
+ thAlign?: 'left' | 'right';
12
+ tdAlign?: 'left' | 'right';
13
+ } | {
14
+ cellText: string;
15
+ cellName: string;
16
+ cellType: 'date';
17
+ options?: never;
18
+ initialValue: '' | `${number}-${number}-${number}`;
19
+ thAlign?: 'left' | 'right';
20
+ tdAlign?: 'left' | 'right';
21
+ } | {
22
+ cellText: string;
23
+ cellName: string;
24
+ cellType: 'text' | 'number';
25
+ initialValue?: never;
26
+ options?: never;
27
+ thAlign?: 'left' | 'right';
28
+ tdAlign?: 'left' | 'right';
29
+ };
@@ -1,2 +1,3 @@
1
1
  import { Table } from './Table';
2
- export { Table };
2
+ import { TableColumn, TableRow } from './Table.types';
3
+ export { Table, type TableColumn, type TableRow };
@@ -1 +1 @@
1
- import{jsxs as e,jsx as l}from"react/jsx-runtime";import{useState as a}from"react";import{B as t}from"../Button-QC014EKI.js";import{C as i}from"../Calendar-D7QM1Jwl.js";import{D as r}from"../Dialog-BSO4ohVZ.js";import{F as o}from"../Form-CgTuTB2Q.js";import{G as n}from"../Grid-DmI4tqqG.js";import{I as s}from"../Input-D8c36JF7.js";import{S as d}from"../Select-DSRwzuLg.js";import{T as c}from"../TextBox-__k4jPYK.js";import{T as m}from"../Typography-CZqNLAT7.js";import{s as p,g as b}from"../style-inject.es-CrVRO2OA.js";import"../Loader-ZYEBOkbx.js";import"../LoaderDots-BoEg_zlZ.js";import"../IconLocate-CQda7FAB.js";import"../index-uD0K440h.js";var u={n23mTable:"Table-module_n23mTable__kKVd9",table:"Table-module_table__hJFsY"};p("@layer n23mTable{.Table-module_n23mTable__kKVd9{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%;overflow-x:auto}.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}.Table-module_table__hJFsY td[data-clickable=true]{cursor:pointer}}");const h=({className:p,jsonSchema:h,jsonData:g,handleCellEdit:f,handelCellDel:x,resetQueryCellEdit:T,isErrorCellEdit:k=!1,isPendingCellEdit:_=!1,isSuccessCellEdit:j=!1,errorMsgCellEdit:y,successMsgCellEdit:C,style:S,...N})=>{const[w,v]=a(!1),[E,z]=a(0),[D,V]=a(null),B=Boolean(f),F=h.cols.filter(e=>"id"!==e.cellName);return e("div",{className:[u.n23mTable,"n23mTable",p].filter(Boolean).join(" "),...N,style:{...b({}),...S},children:[B&&l(r,{open:w,onCancel:()=>{v(!1),T?.()},widthMax:"900px",children:e(n,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(m,{appearance:"light",variant:"subheading",style:{margin:"0 0 20px 0"},children:"Edit Cell"}),e(o,{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:k,isPending:_,isSuccess:j,errorMsg:y,successMsg:C,children:[l(n,{layout:"columns",col:{smallDesktop:2},gap:{col:"20px"},children:D&&h.cols.map(e=>{const a="id"===e.cellName,t=D[e.cellName];if("date"===e.cellType){const a=t||e.initialValue;return l(i,{label:e.cellText,name:e.cellName,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(d,{name:e.cellName,options:e.options,initialValue:a},e.cellName)}return l(s,{label:e.cellText,name:e.cellName,type:"text",defaultValue:String(t??""),disabled:a,placeholder:e.cellText},e.cellName)})}),e(n,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:x?"space-between":"flex-end",alignItems:"right",margin:"20px 0 0 0",children:[x&&l(t,{type:"button",height:"40px",width:"80px",padding:0,disabled:_,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{x&&D&&(x(D.id),v(!1))},children:l(c,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Delete"})}),l(t,{type:"submit",height:"40px",width:"80px",padding:0,disabled:_,backgroundColor:"#4BB543",backgroundColorDisabled:"grey",children:l(c,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Save"})})]})]},E)]})}),e("table",{className:u.table,children:[l("thead",{children:l("tr",{children:F.map(e=>l("th",{scope:"col",children:l(c,{mobileSize:16,desktopSize:20,color:"black",textAlign:e.thAlign??"left",children:e.cellText})},e.cellName))})}),l("tbody",{children:g.rows.map(e=>l("tr",{children:F.map(a=>{const t=e[a.cellName];return l("td",{"data-clickable":B,onClick:B?()=>(e=>{V(e),v(!0),z(e=>e+1)})(e):void 0,children:l(c,{fontWeight:400,mobileSize:16,desktopSize:16,color:"black",textAlign:a.tdAlign??"left",children:void 0===t?"":String(t)})},a.cellName)})},e.id))})]})]})};h.displayName="Table";export{h as Table};
1
+ import{jsxs as e,jsx as l}from"react/jsx-runtime";import{useState as a}from"react";import{B as t}from"../Button-QC014EKI.js";import{C as i}from"../Calendar-D7QM1Jwl.js";import{D as r}from"../Dialog-BSO4ohVZ.js";import{F as o}from"../Form-CgTuTB2Q.js";import{G as n}from"../Grid-DmI4tqqG.js";import{I as s}from"../Input-D8c36JF7.js";import{S as d}from"../Select-DSRwzuLg.js";import{T as c}from"../TextBox-__k4jPYK.js";import{T as m}from"../Typography-CZqNLAT7.js";import{s as p,g as b}from"../style-inject.es-CrVRO2OA.js";import"../Loader-ZYEBOkbx.js";import"../LoaderDots-BoEg_zlZ.js";import"../IconLocate-CQda7FAB.js";import"../index-uD0K440h.js";var u={n23mTable:"Table-module_n23mTable__kKVd9",table:"Table-module_table__hJFsY"};p("@layer n23mTable{.Table-module_n23mTable__kKVd9{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%;overflow-x:auto}.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}.Table-module_table__hJFsY td[data-clickable=true]{cursor:pointer}}");const h=({className:p,jsonSchema:h,jsonData:g,handleCellEdit:f,handelCellDel:x,resetQueryCellEdit:T,isErrorCellEdit:k=!1,isPendingCellEdit:_=!1,isSuccessCellEdit:j=!1,errorMsgCellEdit:y,successMsgCellEdit:C,style:S,...N})=>{const[w,v]=a(!1),[E,z]=a(0),[D,V]=a(null),B=Boolean(f),F=h.cols.filter(e=>"id"!==e.cellName);return e("div",{className:[u.n23mTable,"n23mTable",p].filter(Boolean).join(" "),...N,style:{...b({}),...S},children:[B&&l(r,{open:w,onCancel:()=>{v(!1),T?.()},widthMax:"900px",children:e(n,{layout:"container",widthMin:"min(800px, calc(100vw - 25px))",padding:"0px 30px 30px 30px",margin:"auto",children:[l(m,{appearance:"light",variant:"subheading",style:{margin:"0 0 20px 0"},children:"Edit Cell"}),e(o,{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:k,isPending:_,isSuccess:j,errorMsg:y,successMsg:C,children:[l(n,{layout:"columns",col:{smallDesktop:2},gap:{col:"20px"},children:D&&h.cols.map(e=>{const a="id"===e.cellName,t=D[e.cellName];if("date"===e.cellType){const a=t||e.initialValue;return l(i,{label:e.cellText,name:e.cellName,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(d,{name:e.cellName,options:e.options,initialValue:a},e.cellName)}return l(s,{label:e.cellText,name:e.cellName,type:e.cellType,defaultValue:String(t??""),disabled:a,placeholder:e.cellText},e.cellName)})}),e(n,{layout:"flex",widthMax:"100%",padding:"0",justifyContent:x?"space-between":"flex-end",alignItems:"right",margin:"20px 0 0 0",children:[x&&l(t,{type:"button",height:"40px",width:"80px",padding:0,disabled:_,backgroundColor:"red",backgroundColorDisabled:"grey",onClick:()=>{x&&D&&(x(D.id),v(!1))},children:l(c,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Delete"})}),l(t,{type:"submit",height:"40px",width:"80px",padding:0,disabled:_,backgroundColor:"#4BB543",backgroundColorDisabled:"grey",children:l(c,{tag:"span",desktopSize:16,mobileSize:16,fontWeight:400,color:"white",children:"Save"})})]})]},E)]})}),e("table",{className:u.table,children:[l("thead",{children:l("tr",{children:F.map(e=>l("th",{scope:"col",children:l(c,{mobileSize:16,desktopSize:20,color:"black",textAlign:e.thAlign??"left",children:e.cellText})},e.cellName))})}),l("tbody",{children:g.rows.map(e=>l("tr",{children:F.map(a=>{const t=e[a.cellName];return l("td",{"data-clickable":B,onClick:B?()=>(e=>{V(e),v(!0),z(e=>e+1)})(e):void 0,children:l(c,{fontWeight:400,mobileSize:16,desktopSize:16,color:"black",textAlign:a.tdAlign??"left",children:void 0===t?"":String(t)})},a.cellName)})},e.id))})]})]})};h.displayName="Table";export{h as Table};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najwer23morsels",
3
- "version": "1.10.6",
3
+ "version": "1.10.8",
4
4
  "exports": {
5
5
  "./lib/*": {
6
6
  "types": "./lib/*/index.d.ts",