tcce-design-system 0.3.31 → 0.3.32

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: (u) => {
9632
- a === "create" ? n(u) : o && r?.id && o(r.id, u);
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: u, isValid: d }) => /* @__PURE__ */ D(Nc, { children: [
9635
- s.map((f) => /* @__PURE__ */ g(
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: !d, children: a === "create" ? c.create : c.edit })
9648
+ /* @__PURE__ */ g(je, { type: "submit", disabled: !f, children: a === "create" ? c.create : c.edit })
9654
9649
  ] })
9655
9650
  ] })
9656
9651
  }
@@ -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:u=>{a==="create"?n(u):o&&r?.id&&o(r.id,u)},children:({values:u,isValid:d})=>g.jsxs(Un.Form,{children:[s.map(f=>g.jsx(Il,{...f,value:u[f.name]},f.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:!d,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`
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;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.31",
6
+ "version": "0.3.32",
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
  },