tcce-design-system 0.3.31 → 0.3.33
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,4 +1,5 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes } from 'react';
|
|
2
|
+
import { AnySchema } from 'yup';
|
|
2
3
|
import { ButtonHTMLAttributes } from 'react';
|
|
3
4
|
import { Cell } from '@tanstack/react-table';
|
|
4
5
|
import { ChangeEvent } from 'react';
|
|
@@ -1907,7 +1908,7 @@ export declare type StepperSize = 'sm' | 'md' | 'lg';
|
|
|
1907
1908
|
*/
|
|
1908
1909
|
export declare const StoreDialog: <T extends {
|
|
1909
1910
|
id?: number | string;
|
|
1910
|
-
}>({ isOpen, setOpen, handleCreate, handleEdit, item, initialValues, formInputs, option, title, buttonText, }: StoreDialogProps<T>) => JSX.Element;
|
|
1911
|
+
}>({ isOpen, setOpen, handleCreate, handleEdit, item, initialValues, formInputs, option, title, buttonText, validationSchema, }: StoreDialogProps<T>) => JSX.Element;
|
|
1911
1912
|
|
|
1912
1913
|
/**
|
|
1913
1914
|
* Label set used for create and edit mode text.
|
|
@@ -1939,6 +1940,7 @@ export declare type StoreDialogOption = 'create' | 'edit';
|
|
|
1939
1940
|
* @param option - Defines whether the dialog works in create or edit mode.
|
|
1940
1941
|
* @param title - Optional heading labels for each mode.
|
|
1941
1942
|
* @param buttonText - Optional submit button labels for each mode.
|
|
1943
|
+
* @param validationSchema - Optional Yup schema passed to Formik for form validation.
|
|
1942
1944
|
*/
|
|
1943
1945
|
export declare interface StoreDialogProps<T = any> {
|
|
1944
1946
|
isOpen: boolean;
|
|
@@ -1951,6 +1953,7 @@ export declare interface StoreDialogProps<T = any> {
|
|
|
1951
1953
|
option: StoreDialogOption;
|
|
1952
1954
|
title?: StoreDialogLabels;
|
|
1953
1955
|
buttonText?: StoreDialogLabels;
|
|
1956
|
+
validationSchema?: AnySchema;
|
|
1954
1957
|
}
|
|
1955
1958
|
|
|
1956
1959
|
/**
|
|
@@ -9620,26 +9620,21 @@ const U1 = ({
|
|
|
9620
9620
|
buttonText: c = {
|
|
9621
9621
|
create: "Create",
|
|
9622
9622
|
edit: "Save Changes"
|
|
9623
|
-
}
|
|
9623
|
+
},
|
|
9624
|
+
validationSchema: u
|
|
9624
9625
|
}) => /* @__PURE__ */ D(_r, { isOpen: e, onClose: () => t(!1), showCloseButton: !0, children: [
|
|
9625
9626
|
/* @__PURE__ */ g(Nr, { children: /* @__PURE__ */ g(er, { children: a === "create" ? l.create : l.edit }) }),
|
|
9626
9627
|
/* @__PURE__ */ g(Br, { children: /* @__PURE__ */ g(
|
|
9627
9628
|
_c,
|
|
9628
9629
|
{
|
|
9629
9630
|
initialValues: i,
|
|
9631
|
+
validationSchema: u,
|
|
9630
9632
|
enableReinitialize: !0,
|
|
9631
|
-
onSubmit: (
|
|
9632
|
-
a === "create" ? n(
|
|
9633
|
+
onSubmit: (d) => {
|
|
9634
|
+
a === "create" ? n(d) : a === "edit" && o && r?.id !== void 0 && r?.id !== null && o(r.id, d);
|
|
9633
9635
|
},
|
|
9634
|
-
children: ({ values:
|
|
9635
|
-
s.map((
|
|
9636
|
-
x0,
|
|
9637
|
-
{
|
|
9638
|
-
...f,
|
|
9639
|
-
value: u[f.name]
|
|
9640
|
-
},
|
|
9641
|
-
f.name
|
|
9642
|
-
)),
|
|
9636
|
+
children: ({ values: d, isValid: f }) => /* @__PURE__ */ D(Nc, { children: [
|
|
9637
|
+
s.map((h) => /* @__PURE__ */ g(x0, { ...h, value: d[h.name] }, h.name)),
|
|
9643
9638
|
/* @__PURE__ */ D("section", { className: "flex justify-between py-4", children: [
|
|
9644
9639
|
/* @__PURE__ */ g(
|
|
9645
9640
|
je,
|
|
@@ -9650,7 +9645,7 @@ const U1 = ({
|
|
|
9650
9645
|
children: "Cancel"
|
|
9651
9646
|
}
|
|
9652
9647
|
),
|
|
9653
|
-
/* @__PURE__ */ g(je, { type: "submit", disabled: !
|
|
9648
|
+
/* @__PURE__ */ g(je, { type: "submit", disabled: !f, children: a === "create" ? c.create : c.edit })
|
|
9654
9649
|
] })
|
|
9655
9650
|
] })
|
|
9656
9651
|
}
|
|
@@ -9914,7 +9909,6 @@ const U1 = ({
|
|
|
9914
9909
|
height: 100%;
|
|
9915
9910
|
background: var(--color-main-white);
|
|
9916
9911
|
border-bottom-right-radius: var(--border-radius-article);
|
|
9917
|
-
border-right: 1px solid var(--color-main-light-borders);
|
|
9918
9912
|
z-index: ${nt.SIDEBAR_ASIDE};
|
|
9919
9913
|
width: ${({ $collapsed: e }) => e ? ut.SIDEBAR_COLLAPSED_WIDTH : ut.SIDEBAR_EXPANDED_WIDTH};
|
|
9920
9914
|
transform: translateX(${({ $open: e }) => e ? "0" : "-100%"});
|
|
@@ -13494,12 +13488,6 @@ const n1 = S(Ue.div)`
|
|
|
13494
13488
|
p.key === "Escape" && i(!1);
|
|
13495
13489
|
};
|
|
13496
13490
|
return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
|
|
13497
|
-
}, [r]), ie(() => {
|
|
13498
|
-
if (!r) {
|
|
13499
|
-
a.current?.focus();
|
|
13500
|
-
return;
|
|
13501
|
-
}
|
|
13502
|
-
l.current?.querySelector("button")?.focus();
|
|
13503
13491
|
}, [r]);
|
|
13504
13492
|
const u = (m) => {
|
|
13505
13493
|
if (!r || m.key !== "Tab" || !s.current)
|
|
@@ -13755,6 +13743,7 @@ const u1 = S.main`
|
|
|
13755
13743
|
transition: margin-left 0.3s ease-out;
|
|
13756
13744
|
background-color: var(--color-main-light-background);
|
|
13757
13745
|
padding: 1.25rem 1.5rem;
|
|
13746
|
+
border-top-left-radius: 1rem;
|
|
13758
13747
|
|
|
13759
13748
|
margin-left: ${ut.SIDEBAR_COLLAPSED_WIDTH};
|
|
13760
13749
|
`, fc = ({
|
|
@@ -1333,7 +1333,7 @@
|
|
|
1333
1333
|
background-color: var(--color-dark-600);
|
|
1334
1334
|
|
|
1335
1335
|
${({$placement:e})=>j0(e)}
|
|
1336
|
-
`,_l=({content:e,children:t,placement:n="bottom",trigger:o="hover",className:r="",arrowClassName:i="",delay:s=200,showArrow:a=!0})=>{const[l,c]=m.useState(!1),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{if(o!=="click"||!l)return;const w=x=>{d.current&&!d.current.contains(x.target)&&f.current&&!f.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l,o]),m.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]);const b=o==="hover"?{onMouseEnter:()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!0),s)},onMouseLeave:()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),100)}}:{onClick:()=>{c(w=>!w)}};return g.jsxs(N0,{children:[g.jsx(O0,{ref:f,...b,children:t}),l&&g.jsxs(H0,{ref:d,$placement:n,className:r,role:"tooltip","aria-hidden":!l,children:[e,a&&g.jsx(G0,{$placement:n,className:i})]})]})};_l.displayName="Tooltip";const U0=({isOpen:e,setOpen:t,handleCreate:n,handleEdit:o,item:r,initialValues:i,formInputs:s,option:a,title:l={create:"Create New Item",edit:"Edit Item"},buttonText:c={create:"Create",edit:"Save Changes"}})=>g.jsxs(kn,{isOpen:e,onClose:()=>t(!1),showCloseButton:!0,children:[g.jsx(Mn,{children:g.jsx(qt,{children:a==="create"?l.create:l.edit})}),g.jsx(Dn,{children:g.jsx(Un.Formik,{initialValues:i,enableReinitialize:!0,onSubmit:
|
|
1336
|
+
`,_l=({content:e,children:t,placement:n="bottom",trigger:o="hover",className:r="",arrowClassName:i="",delay:s=200,showArrow:a=!0})=>{const[l,c]=m.useState(!1),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{if(o!=="click"||!l)return;const w=x=>{d.current&&!d.current.contains(x.target)&&f.current&&!f.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l,o]),m.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]);const b=o==="hover"?{onMouseEnter:()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!0),s)},onMouseLeave:()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),100)}}:{onClick:()=>{c(w=>!w)}};return g.jsxs(N0,{children:[g.jsx(O0,{ref:f,...b,children:t}),l&&g.jsxs(H0,{ref:d,$placement:n,className:r,role:"tooltip","aria-hidden":!l,children:[e,a&&g.jsx(G0,{$placement:n,className:i})]})]})};_l.displayName="Tooltip";const U0=({isOpen:e,setOpen:t,handleCreate:n,handleEdit:o,item:r,initialValues:i,formInputs:s,option:a,title:l={create:"Create New Item",edit:"Edit Item"},buttonText:c={create:"Create",edit:"Save Changes"},validationSchema:u})=>g.jsxs(kn,{isOpen:e,onClose:()=>t(!1),showCloseButton:!0,children:[g.jsx(Mn,{children:g.jsx(qt,{children:a==="create"?l.create:l.edit})}),g.jsx(Dn,{children:g.jsx(Un.Formik,{initialValues:i,validationSchema:u,enableReinitialize:!0,onSubmit:d=>{a==="create"?n(d):a==="edit"&&o&&r?.id!==void 0&&r?.id!==null&&o(r.id,d)},children:({values:d,isValid:f})=>g.jsxs(Un.Form,{children:[s.map(h=>g.jsx(Il,{...h,value:d[h.name]},h.name)),g.jsxs("section",{className:"flex justify-between py-4",children:[g.jsx(Me,{variant:"secondary",type:"button",onClick:()=>t(!1),children:"Cancel"}),g.jsx(Me,{type:"submit",disabled:!f,children:a==="create"?c.create:c.edit})]})]})})})]}),W0=({isOpen:e,onClose:t,onConfirm:n,isLoading:o=!1,itemLabel:r="this item"})=>g.jsxs(kn,{isOpen:e,onClose:t,showCloseButton:!0,size:"sm",children:[g.jsx(Mn,{showDivider:!0,children:g.jsx(qt,{size:20,color:"var(--color-main-warning-state)",children:"Confirm Delete"})}),g.jsx(Dn,{padded:!0,children:g.jsxs(Ve,{size:14,color:"var(--color-dark-800)",children:["Are you sure you want to delete ",g.jsx("strong",{children:r}),"? This action cannot be undone."]})}),g.jsxs($r,{showDivider:!0,align:"end",children:[g.jsx(Me,{variant:"cancel",size:"md",onClick:t,disabled:o,children:"Cancel"}),g.jsx(Me,{variant:"primary",size:"md",onClick:n,isLoading:o,disabled:o,children:"Delete"})]})]}),Er=m.createContext(void 0),Bl=({children:e})=>{const[t,n]=m.useState(!0),[o,r]=m.useState(!1);return g.jsx(Er.Provider,{value:{isCollapsed:t,setIsCollapsed:n,isMobileOpen:o,setIsMobileOpen:r},children:e})},Vn=()=>{const e=m.useContext(Er);if(!e)throw new Error("useSidebar must be used within a SidebarProvider");return e},Pr=(e=[],t=[])=>!t||t.length===0?!1:t.includes("all")?!0:e.map(o=>o.name).some(o=>t.includes(o)),K0=v.css`
|
|
1337
1337
|
display: flex;
|
|
1338
1338
|
align-items: center;
|
|
1339
1339
|
justify-content: center;
|
|
@@ -1441,7 +1441,6 @@
|
|
|
1441
1441
|
height: 100%;
|
|
1442
1442
|
background: var(--color-main-white);
|
|
1443
1443
|
border-bottom-right-radius: var(--border-radius-article);
|
|
1444
|
-
border-right: 1px solid var(--color-main-light-borders);
|
|
1445
1444
|
z-index: ${je.SIDEBAR_ASIDE};
|
|
1446
1445
|
width: ${({$collapsed:e})=>e?ot.SIDEBAR_COLLAPSED_WIDTH:ot.SIDEBAR_EXPANDED_WIDTH};
|
|
1447
1446
|
transform: translateX(${({$open:e})=>e?"0":"-100%"});
|
|
@@ -2194,7 +2193,7 @@
|
|
|
2194
2193
|
&.danger {
|
|
2195
2194
|
color: var(--color-main-warning-state);
|
|
2196
2195
|
}
|
|
2197
|
-
`,Zr=({user:e,onProfileClick:t,onLogout:n,menuItems:o=[]})=>{const[r,i]=m.useState(!1),s=m.useRef(null),a=m.useRef(null),l=m.useRef(null),c=m.useId();m.useEffect(()=>{if(!r)return;const p=y=>{s.current&&!s.current.contains(y.target)&&i(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]),m.useEffect(()=>{if(!r)return;const p=y=>{y.key==="Escape"&&i(!1)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[r])
|
|
2196
|
+
`,Zr=({user:e,onProfileClick:t,onLogout:n,menuItems:o=[]})=>{const[r,i]=m.useState(!1),s=m.useRef(null),a=m.useRef(null),l=m.useRef(null),c=m.useId();m.useEffect(()=>{if(!r)return;const p=y=>{s.current&&!s.current.contains(y.target)&&i(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]),m.useEffect(()=>{if(!r)return;const p=y=>{y.key==="Escape"&&i(!1)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[r]);const u=p=>{if(!r||p.key!=="Tab"||!s.current)return;const y=s.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(y.length===0)return;const b=y[0],w=y[y.length-1],x=document.activeElement;p.shiftKey&&x===b?(p.preventDefault(),w.focus()):!p.shiftKey&&x===w&&(p.preventDefault(),b.focus())},d=p=>p.split(" ").map(y=>y[0]).join("").toUpperCase().slice(0,2),h=[...[{id:"profile",label:"Profile",icon:yg,onClick:()=>{i(!1),t?.()},variant:"default"},{id:"logout",label:"Logout",icon:pg,onClick:()=>{i(!1),n?.()},variant:"danger"}],...o];return g.jsxs("div",{ref:s,style:{position:"relative"},onKeyDown:u,children:[g.jsxs(_y,{ref:a,type:"button",onClick:()=>i(!r),"aria-haspopup":"menu","aria-expanded":r,"aria-controls":c,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i(!r))},children:[g.jsxs(By,{children:[g.jsx(Ve,{size:14,className:"font-semibold!",children:e?.name||""}),g.jsx(Ve,{size:12,children:e?.roles?.[0]?.name||""})]}),g.jsx(Ny,{className:"font-semibold!",children:d(e?.name||"")})]}),g.jsx(Ot,{children:r&&g.jsx(Oy,{id:c,ref:l,role:"menu",initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},transition:{duration:.15},children:h.map(p=>g.jsx(m.Fragment,{children:g.jsxs(zy,{type:"button",role:"menuitem",onClick:p.onClick,className:p.variant==="danger"?"danger":"",children:[g.jsx(U,{component:p.icon,size:"sm",color:p.variant==="danger"?"var(--color-main-warning-state)":"var(--color-main-blue-primary)"}),g.jsx(Ve,{size:14,color:`${p.variant==="danger"&&"var(--color-main-warning-state)"}`,children:p.label})]})},p.id))})})]})};Zr.displayName="UserProfile";const Ac=({hasNotifications:e=!1,notificationCount:t})=>{const n=(t??0)>0||e,o=t&&t>0?t:void 0,r=o?`${o} notification${o===1?"":"s"}`:n?"New notifications":"No notifications",i=`Notifications: ${r}`;return{effectiveHasNotifications:n,displayCount:o,badgeLabel:r,bellAriaLabel:i}},Hy=v.button`
|
|
2198
2197
|
position: relative;
|
|
2199
2198
|
background: transparent;
|
|
2200
2199
|
border: none;
|
|
@@ -2277,6 +2276,7 @@
|
|
|
2277
2276
|
transition: margin-left 0.3s ease-out;
|
|
2278
2277
|
background-color: var(--color-main-light-background);
|
|
2279
2278
|
padding: 1.25rem 1.5rem;
|
|
2279
|
+
border-top-left-radius: 1rem;
|
|
2280
2280
|
|
|
2281
2281
|
margin-left: ${ot.SIDEBAR_COLLAPSED_WIDTH};
|
|
2282
2282
|
`,ei=({children:e,className:t,id:n,inert:o,"aria-hidden":r})=>g.jsx(Ky,{id:n,className:t,inert:o,"aria-hidden":r,children:e});ei.displayName="LayoutMainContent";const Yy=v.div`
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.33",
|
|
7
7
|
"description": "This package provides reusable UI components to ensure consistency across all CRM frontend applications",
|
|
8
8
|
"author": "BizAppsTotal <bizapps@tcce.biz>",
|
|
9
9
|
"type": "module",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"module": "./dist/tcce-design-system-componentsfdsafds.js",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
|
|
18
17
|
"import": "./dist/tcce-design-system-components.js",
|
|
19
18
|
"require": "./dist/tcce-design-system-components.umd.cjs"
|
|
20
19
|
},
|