@sito/dashboard 0.0.15 → 0.0.17

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.
@@ -4,7 +4,9 @@ export type TableOptionsContextType = {
4
4
  total: number;
5
5
  setTotal: (total: number) => void;
6
6
  sortingBy: string;
7
+ setSortingBy: (property: string) => void;
7
8
  sortingOrder: SortOrder;
9
+ setSortingOrder: (sortOrder: SortOrder) => void;
8
10
  pageSize: number;
9
11
  pageSizes: number[];
10
12
  setPageSize: (pageSize: number) => void;
@@ -1,3 +1,4 @@
1
1
  export { useTableOptions, TableOptionsProvider, } from './hooks/TableOptionsProvider';
2
2
  export { Table } from './Table';
3
3
  export type { Action as TableAction } from './types';
4
+ export type { TableOptionsContextType, TableOptionsProviderPropsType, } from './hooks/types';
@@ -35,7 +35,7 @@ export type TablePropsType = {
35
35
  rows: object[];
36
36
  parseRows?: any;
37
37
  isLoading?: boolean;
38
- actions?: Action[];
38
+ actions?: (row: object) => Action[];
39
39
  columns?: ColumnType[];
40
40
  columnsOptions?: ColumnsOptionsType;
41
41
  contentClassName?: string;
@@ -1 +1 @@
1
- var H=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react");var y=(t=>(t.ASC="ASC",t.DESC="DESC",t))(y||{});const _=[20,50,100],w=d.createContext({}),A=t=>{const{children:s}=t,[n,l]=d.useState(0),[r,a]=d.useState(20),[m,p]=d.useState(0),[u,j]=d.useState("id"),[i,o]=d.useState(y.ASC),b={onSort:d.useCallback(c=>{let g=i;if(u===c)switch(i){case y.ASC:g=y.DESC;break;default:g=y.ASC;break}j(c),o(g)},[u,i]),total:n,setTotal:l,sortingBy:u,sortingOrder:i,pageSize:r,pageSizes:_,setPageSize:a,currentPage:m,setCurrentPage:p};return e.jsx(w.Provider,{value:b,children:s})},N=()=>{const t=d.useContext(w);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},S=d.createContext({});function M(t){const{children:s,t:n}=t;return e.jsx(S.Provider,{value:{t:n},children:s})}const v=()=>{const t=d.useContext(S);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};function E(t){const{content:s,children:n}=t;return e.jsxs("div",{className:"tooltip-container",children:[n,e.jsx("div",{className:"tooltip-text",children:s})]})}function k(t){const{color:s="stroke-blue-800",loaderClass:n,strokeWidth:l="4",...r}=t;return e.jsx("div",{...r,className:`loading ${r.className}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${n}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${s}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:l,strokeMiterlimit:"10"})})})})})}function B(){const{t}=v();return e.jsx("div",{className:"w-full flex items-center justify-center py-2 border-t-[1px]",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}function T(t){const{className:s}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function $(t){const{className:s}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function D(t){const{t:s}=v(),{entity:n="",columns:l=[],hasAction:r=!0,columnsOptions:a}=t,{onSort:m,sortingOrder:p,sortingBy:u}=N(),j=d.useMemo(()=>{const{noSortableColumns:i={},columnClassNames:o={}}=a??{};return l==null?void 0:l.map(x=>({id:x.key,label:x.label,className:o[x.key]??"",sortable:!i[x.key]}))},[l,a,n,s]);return e.jsx("thead",{className:"text-xs text-gray-700 bg-gray-50",children:e.jsxs("tr",{children:[j.map(i=>{var o,x,b,c;return e.jsx("th",{scope:"col",className:`px-6 py-3 ${i.className}`,children:e.jsxs("button",{disabled:!i.sortable,onClick:()=>m(i.id),className:"flex items-center gap-2",children:[e.jsx("span",{className:"whitespace-nowrap",children:i.label}),i.sortable&&e.jsx("span",{className:`${u===i.id?"opacity-100":"opacity-0"}`,children:p===y.ASC?((o=a==null?void 0:a.icons)==null?void 0:o.asc)??e.jsx(T,{className:((x=a==null?void 0:a.icons)==null?void 0:x.className)??"w-3"}):((b=a==null?void 0:a.icons)==null?void 0:b.desc)??e.jsx($,{className:((c=a==null?void 0:a.icons)==null?void 0:c.className)??"w-3"})})]})},i.id)}),r&&e.jsx("th",{scope:"col",className:"px-6 py-3 text-center",children:s("_accessibility:labels.actions")})]})})}var P=(t=>(t.error="error",t.good="good",t.default="default",t))(P||{});const L=t=>{switch(t){case"error":return"border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 focus:border-red-500";case"good":return"border-green-500 text-green-900 placeholder-green-700 focus:ring-green-500 focus:border-green-500";default:return"text-gray-900 border-gray-300 focus:border-blue-600"}},F=t=>{switch(t){case"error":return"peer-focus:text-red-700 text-red-700";case"good":return"peer-focus:text-green-700 text-green-700";default:return"peer-focus:text-blue-600 text-gray-500"}},q=t=>{switch(t){case"error":return"text-red-600";case"good":return"text-green-600";default:return"text-gray-500"}},I=d.forwardRef(function(t,s){const{value:n,onChange:l,options:r,containerClassName:a="",inputClassName:m="",labelClassName:p="",helperText:u="",helperTextClassName:j="",placeholder:i="",label:o="",name:x="",id:b="",state:c=P.default,...g}=t;return d.useEffect(()=>{var f;(!n||n==="")&&(r!=null&&r.length)&&l({target:{value:(f=r[0])==null?void 0:f.id}})},[l,r,n]),e.jsxs("div",{className:`relative z-0 w-full mb-5 group ${a}`,children:[e.jsx("select",{...g,id:b,ref:s,name:x,value:n,onChange:l,className:`block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none focus:outline-none focus:ring-0 disabled:text-[#6b7280] ${L(c)} peer ${m}`,children:r==null?void 0:r.map(f=>e.jsx("option",{value:f.id,children:f.value},f.id))}),e.jsx("label",{htmlFor:x,className:`peer-focus:font-medium absolute text-sm duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6 ${F(c)} ${p}`,children:o}),e.jsx("p",{className:`mt-2 text-sm ${q(c)} ${j}`,children:c!=="error"&&c!=="good"?i:u})]})}),R=I;function U(){const{t}=v(),{pageSizes:s,pageSize:n,setPageSize:l}=N(),r=d.useMemo(()=>s==null?void 0:s.map(a=>({id:a,value:a})),[s]);return e.jsxs("div",{className:"flex gap-2 items-center justify-start px-5",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:n,options:r,inputClassName:"!py-0 !pl-2 !pr-7 !border-none font-bold",containerClassName:"!w-auto !mb-0 !border-none",helperTextClassName:"hidden",onChange:a=>l(a.target.value)})]})}function W(){const{t}=v(),{total:s,pageSize:n,pageSizes:l,currentPage:r,setCurrentPage:a}=N(),m=(r+1)*n>s?s:(r+1)*n;return e.jsxs("div",{className:"flex w-full items-center justify-between mt-5 px-5",children:[e.jsxs("div",{className:"flex w-full items-center justify-start gap-1",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),l[0]<s&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[t("_accessibility:components.table.from")," ",r*n+1," ",t("_accessibility:components.table.to")," ",m," ",t("_accessibility:components.table.of")]})}),e.jsxs("p",{children:[s," ",t("_accessibility:components.table.results")]})]}),e.jsxs("div",{className:"flex gap-5 items-center justify-end",children:[e.jsx("button",{className:"disabled:text-light-primary/40",disabled:r===0,onClick:()=>a(r-1),children:t("_accessibility:buttons.previous")}),e.jsx("button",{disabled:Math.floor(s/((r+1)*n))===0,className:"disabled:text-light-primary/40",onClick:()=>a(r+1),children:t("_accessibility:buttons.next")})]})]})}function G(t){const{t:s}=v(),{title:n="",rows:l,parseRows:r,entity:a="",isLoading:m=!1,actions:p=[],columns:u=[],contentClassName:j="h-[calc(100vh-280px)]",className:i="bg-gray-50",columnsOptions:o,softDeleteProperty:x="deleted"}=t,b=d.useMemo(()=>(l==null?void 0:l.map(c=>r(c)))??[],[r,l,s]);return e.jsxs("div",{className:`${i} relative overflow-x-auto w-full h-full`,children:[e.jsx("div",{className:"mb-5 flex w-full items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mx-5",children:n}),l!=null&&l.length&&!m?e.jsx(U,{}):null]})}),m?e.jsx(k,{className:"bg-white top-0 left-0 w-full h-full"}):e.jsx("div",{className:`${j} overflow-auto`,children:l!=null&&l.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-sm text-left text-gray-500",children:[e.jsx(D,{entity:a,columns:u,columnsOptions:o,hasAction:(p==null?void 0:p.length)>0}),e.jsx("tbody",{children:b==null?void 0:b.map(c=>{var g,f;return e.jsxs("tr",{className:`border-b ${(g=c[x])!=null&&g.value?"deleted-class":"bg-white"}`,children:[u==null?void 0:u.map((h,z)=>{var C;return e.jsx("td",{className:`px-6 py-4 font-medium ${z===0?"text-gray-900 whitespace-nowrap":""} ${o!=null&&o.columnClassNames?o==null?void 0:o.columnClassNames[h.key]:""}`,children:((C=c[h.key])==null?void 0:C.render)??c[h.key]},h.key)}),p.length?e.jsx("td",{children:e.jsx("div",{className:"flex items-center gap-3 w-full justify-center",children:(f=p.filter(h=>!h.hidden||!h.hidden(c)))==null?void 0:f.map(h=>e.jsx(E,{content:h.tooltip,children:e.jsx("button",{onClick:()=>h.onClick(c),children:h.icon})},h.id))})}):null]},c.id)})})]}),e.jsx(W,{})]}):e.jsx(B,{})})]})}exports.ChevronDown=$;exports.ChevronUp=T;exports.Loading=k;exports.Table=G;exports.TableOptionsProvider=A;exports.TranslationProvider=M;exports.useTableOptions=N;exports.useTranslation=v;
1
+ var H=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react");var y=(t=>(t.ASC="ASC",t.DESC="DESC",t))(y||{});const _=[20,50,100],w=d.createContext({}),A=t=>{const{children:s}=t,[l,n]=d.useState(0),[r,a]=d.useState(20),[p,b]=d.useState(0),[u,g]=d.useState("id"),[o,i]=d.useState(y.ASC),m={onSort:d.useCallback(c=>{let j=o;if(u===c)switch(o){case y.ASC:j=y.DESC;break;default:j=y.ASC;break}g(c),i(j)},[u,o]),total:l,setTotal:n,sortingBy:u,setSortingBy:g,sortingOrder:o,setSortingOrder:i,pageSize:r,pageSizes:_,setPageSize:a,currentPage:p,setCurrentPage:b};return e.jsx(w.Provider,{value:m,children:s})},N=()=>{const t=d.useContext(w);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},S=d.createContext({});function M(t){const{children:s,t:l}=t;return e.jsx(S.Provider,{value:{t:l},children:s})}const v=()=>{const t=d.useContext(S);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};function E(t){const{content:s,children:l}=t;return e.jsxs("div",{className:"tooltip-container",children:[l,e.jsx("div",{className:"tooltip-text",children:s})]})}function k(t){const{color:s="stroke-blue-800",loaderClass:l,strokeWidth:n="4",...r}=t;return e.jsx("div",{...r,className:`loading ${r.className}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${l}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${s}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:n,strokeMiterlimit:"10"})})})})})}function B(){const{t}=v();return e.jsx("div",{className:"w-full flex items-center justify-center py-2 border-t-[1px]",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}function T(t){const{className:s}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function $(t){const{className:s}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function D(t){const{t:s}=v(),{entity:l="",columns:n=[],hasAction:r=!0,columnsOptions:a}=t,{onSort:p,sortingOrder:b,sortingBy:u}=N(),g=d.useMemo(()=>{const{noSortableColumns:o={},columnClassNames:i={}}=a??{};return n==null?void 0:n.map(x=>({id:x.key,label:x.label,className:i[x.key]??"",sortable:!o[x.key]}))},[n,a,l,s]);return e.jsx("thead",{className:"text-xs text-gray-700 bg-gray-50",children:e.jsxs("tr",{children:[g.map(o=>{var i,x,m,c;return e.jsx("th",{scope:"col",className:`px-6 py-3 ${o.className}`,children:e.jsxs("button",{disabled:!o.sortable,onClick:()=>p(o.id),className:"flex items-center gap-2",children:[e.jsx("span",{className:"whitespace-nowrap",children:o.label}),o.sortable&&e.jsx("span",{className:`${u===o.id?"opacity-100":"opacity-0"}`,children:b===y.ASC?((i=a==null?void 0:a.icons)==null?void 0:i.asc)??e.jsx(T,{className:((x=a==null?void 0:a.icons)==null?void 0:x.className)??"w-3"}):((m=a==null?void 0:a.icons)==null?void 0:m.desc)??e.jsx($,{className:((c=a==null?void 0:a.icons)==null?void 0:c.className)??"w-3"})})]})},o.id)}),r&&e.jsx("th",{scope:"col",className:"px-6 py-3 text-center",children:s("_accessibility:labels.actions")})]})})}var P=(t=>(t.error="error",t.good="good",t.default="default",t))(P||{});const L=t=>{switch(t){case"error":return"border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 focus:border-red-500";case"good":return"border-green-500 text-green-900 placeholder-green-700 focus:ring-green-500 focus:border-green-500";default:return"text-gray-900 border-gray-300 focus:border-blue-600"}},F=t=>{switch(t){case"error":return"peer-focus:text-red-700 text-red-700";case"good":return"peer-focus:text-green-700 text-green-700";default:return"peer-focus:text-blue-600 text-gray-500"}},q=t=>{switch(t){case"error":return"text-red-600";case"good":return"text-green-600";default:return"text-gray-500"}},I=d.forwardRef(function(t,s){const{value:l,onChange:n,options:r,containerClassName:a="",inputClassName:p="",labelClassName:b="",helperText:u="",helperTextClassName:g="",placeholder:o="",label:i="",name:x="",id:m="",state:c=P.default,...j}=t;return d.useEffect(()=>{var f;(!l||l==="")&&(r!=null&&r.length)&&n({target:{value:(f=r[0])==null?void 0:f.id}})},[n,r,l]),e.jsxs("div",{className:`relative z-0 w-full mb-5 group ${a}`,children:[e.jsx("select",{...j,id:m,ref:s,name:x,value:l,onChange:n,className:`block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none focus:outline-none focus:ring-0 disabled:text-[#6b7280] ${L(c)} peer ${p}`,children:r==null?void 0:r.map(f=>e.jsx("option",{value:f.id,children:f.value},f.id))}),e.jsx("label",{htmlFor:x,className:`peer-focus:font-medium absolute text-sm duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6 ${F(c)} ${b}`,children:i}),e.jsx("p",{className:`mt-2 text-sm ${q(c)} ${g}`,children:c!=="error"&&c!=="good"?o:u})]})}),R=I;function U(){const{t}=v(),{pageSizes:s,pageSize:l,setPageSize:n}=N(),r=d.useMemo(()=>s==null?void 0:s.map(a=>({id:a,value:a})),[s]);return e.jsxs("div",{className:"flex gap-2 items-center justify-start px-5",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:l,options:r,inputClassName:"!py-0 !pl-2 !pr-7 !border-none font-bold",containerClassName:"!w-auto !mb-0 !border-none",helperTextClassName:"hidden",onChange:a=>n(a.target.value)})]})}function W(){const{t}=v(),{total:s,pageSize:l,pageSizes:n,currentPage:r,setCurrentPage:a}=N(),p=(r+1)*l>s?s:(r+1)*l;return e.jsxs("div",{className:"flex w-full items-center justify-between mt-5 px-5",children:[e.jsxs("div",{className:"flex w-full items-center justify-start gap-1",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),n[0]<s&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[t("_accessibility:components.table.from")," ",r*l+1," ",t("_accessibility:components.table.to")," ",p," ",t("_accessibility:components.table.of")]})}),e.jsxs("p",{children:[s," ",t("_accessibility:components.table.results")]})]}),e.jsxs("div",{className:"flex gap-5 items-center justify-end",children:[e.jsx("button",{className:"disabled:text-light-primary/40",disabled:r===0,onClick:()=>a(r-1),children:t("_accessibility:buttons.previous")}),e.jsx("button",{disabled:Math.floor(s/((r+1)*l))===0,className:"disabled:text-light-primary/40",onClick:()=>a(r+1),children:t("_accessibility:buttons.next")})]})]})}function G(t){const{t:s}=v(),{title:l="",rows:n,parseRows:r,entity:a="",isLoading:p=!1,actions:b,columns:u=[],contentClassName:g="h-[calc(100vh-280px)]",className:o="bg-gray-50",columnsOptions:i,softDeleteProperty:x="deleted"}=t,m=d.useMemo(()=>(n==null?void 0:n.map(c=>r(c)))??[],[r,n,s]);return e.jsxs("div",{className:`${o} relative overflow-x-auto w-full h-full`,children:[e.jsx("div",{className:"mb-5 flex w-full items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mx-5",children:l}),n!=null&&n.length&&!p?e.jsx(U,{}):null]})}),p?e.jsx(k,{className:"bg-white top-0 left-0 w-full h-full"}):e.jsx("div",{className:`${g} overflow-auto`,children:n!=null&&n.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-sm text-left text-gray-500",children:[e.jsx(D,{entity:a,columns:u,columnsOptions:i,hasAction:!!b}),e.jsx("tbody",{children:m==null?void 0:m.map(c=>{var j,f;return e.jsxs("tr",{className:`border-b ${(j=c[x])!=null&&j.value?"deleted-class":"bg-white"}`,children:[u==null?void 0:u.map((h,z)=>{var C;return e.jsx("td",{className:`px-6 py-4 font-medium ${z===0?"text-gray-900 whitespace-nowrap":""} ${i!=null&&i.columnClassNames?i==null?void 0:i.columnClassNames[h.key]:""}`,children:((C=c[h.key])==null?void 0:C.render)??c[h.key]},h.key)}),b?e.jsx("td",{children:e.jsx("div",{className:"flex items-center gap-3 w-full justify-center",children:(f=b(c).filter(h=>!h.hidden))==null?void 0:f.map(h=>e.jsx(E,{content:h.tooltip,children:e.jsx("button",{onClick:h.onClick,children:h.icon})},h.id))})}):null]},c.id)})})]}),e.jsx(W,{})]}):e.jsx(B,{})})]})}exports.ChevronDown=$;exports.ChevronUp=T;exports.Loading=k;exports.Table=G;exports.TableOptionsProvider=A;exports.TranslationProvider=M;exports.useTableOptions=N;exports.useTranslation=v;
package/dist/dashboard.js CHANGED
@@ -3,34 +3,36 @@ import { jsx as t, jsxs as d, Fragment as $ } from "react/jsx-runtime";
3
3
  import { createContext as P, useState as v, useCallback as E, useContext as z, useMemo as w, forwardRef as B, useEffect as D } from "react";
4
4
  var N = /* @__PURE__ */ ((e) => (e.ASC = "ASC", e.DESC = "DESC", e))(N || {});
5
5
  const M = [20, 50, 100], T = P({}), O = (e) => {
6
- const { children: r } = e, [n, l] = v(0), [s, a] = v(20), [f, m] = v(0), [h, y] = v("id"), [i, o] = v(N.ASC), b = {
6
+ const { children: r } = e, [n, l] = v(0), [s, a] = v(20), [m, b] = v(0), [p, x] = v("id"), [i, o] = v(N.ASC), f = {
7
7
  onSort: E(
8
8
  (c) => {
9
- let x = i;
10
- if (h === c)
9
+ let y = i;
10
+ if (p === c)
11
11
  switch (i) {
12
12
  case N.ASC:
13
- x = N.DESC;
13
+ y = N.DESC;
14
14
  break;
15
15
  default:
16
- x = N.ASC;
16
+ y = N.ASC;
17
17
  break;
18
18
  }
19
- y(c), o(x);
19
+ x(c), o(y);
20
20
  },
21
- [h, i]
21
+ [p, i]
22
22
  ),
23
23
  total: n,
24
24
  setTotal: l,
25
- sortingBy: h,
25
+ sortingBy: p,
26
+ setSortingBy: x,
26
27
  sortingOrder: i,
28
+ setSortingOrder: o,
27
29
  pageSize: s,
28
30
  pageSizes: M,
29
31
  setPageSize: a,
30
- currentPage: f,
31
- setCurrentPage: m
32
+ currentPage: m,
33
+ setCurrentPage: b
32
34
  };
33
- return /* @__PURE__ */ t(T.Provider, { value: b, children: r });
35
+ return /* @__PURE__ */ t(T.Provider, { value: f, children: r });
34
36
  }, S = () => {
35
37
  const e = z(T);
36
38
  if (e === void 0)
@@ -103,7 +105,7 @@ function U(e) {
103
105
  );
104
106
  }
105
107
  function W(e) {
106
- const { t: r } = C(), { entity: n = "", columns: l = [], hasAction: s = !0, columnsOptions: a } = e, { onSort: f, sortingOrder: m, sortingBy: h } = S(), y = w(() => {
108
+ const { t: r } = C(), { entity: n = "", columns: l = [], hasAction: s = !0, columnsOptions: a } = e, { onSort: m, sortingOrder: b, sortingBy: p } = S(), x = w(() => {
107
109
  const { noSortableColumns: i = {}, columnClassNames: o = {} } = a ?? {};
108
110
  return l == null ? void 0 : l.map((u) => ({
109
111
  id: u.key,
@@ -113,8 +115,8 @@ function W(e) {
113
115
  }));
114
116
  }, [l, a, n, r]);
115
117
  return /* @__PURE__ */ t("thead", { className: "text-xs text-gray-700 bg-gray-50", children: /* @__PURE__ */ d("tr", { children: [
116
- y.map((i) => {
117
- var o, u, b, c;
118
+ x.map((i) => {
119
+ var o, u, f, c;
118
120
  return /* @__PURE__ */ t(
119
121
  "th",
120
122
  {
@@ -124,20 +126,20 @@ function W(e) {
124
126
  "button",
125
127
  {
126
128
  disabled: !i.sortable,
127
- onClick: () => f(i.id),
129
+ onClick: () => m(i.id),
128
130
  className: "flex items-center gap-2",
129
131
  children: [
130
132
  /* @__PURE__ */ t("span", { className: "whitespace-nowrap", children: i.label }),
131
133
  i.sortable && /* @__PURE__ */ t(
132
134
  "span",
133
135
  {
134
- className: `${h === i.id ? "opacity-100" : "opacity-0"}`,
135
- children: m === N.ASC ? ((o = a == null ? void 0 : a.icons) == null ? void 0 : o.asc) ?? /* @__PURE__ */ t(
136
+ className: `${p === i.id ? "opacity-100" : "opacity-0"}`,
137
+ children: b === N.ASC ? ((o = a == null ? void 0 : a.icons) == null ? void 0 : o.asc) ?? /* @__PURE__ */ t(
136
138
  R,
137
139
  {
138
140
  className: ((u = a == null ? void 0 : a.icons) == null ? void 0 : u.className) ?? "w-3"
139
141
  }
140
- ) : ((b = a == null ? void 0 : a.icons) == null ? void 0 : b.desc) ?? /* @__PURE__ */ t(
142
+ ) : ((f = a == null ? void 0 : a.icons) == null ? void 0 : f.desc) ?? /* @__PURE__ */ t(
141
143
  U,
142
144
  {
143
145
  className: ((c = a == null ? void 0 : a.icons) == null ? void 0 : c.className) ?? "w-3"
@@ -189,16 +191,16 @@ const q = (e) => {
189
191
  onChange: l,
190
192
  options: s,
191
193
  containerClassName: a = "",
192
- inputClassName: f = "",
193
- labelClassName: m = "",
194
- helperText: h = "",
195
- helperTextClassName: y = "",
194
+ inputClassName: m = "",
195
+ labelClassName: b = "",
196
+ helperText: p = "",
197
+ helperTextClassName: x = "",
196
198
  placeholder: i = "",
197
199
  label: o = "",
198
200
  name: u = "",
199
- id: b = "",
201
+ id: f = "",
200
202
  state: c = j.default,
201
- ...x
203
+ ...y
202
204
  } = e;
203
205
  return D(() => {
204
206
  var g;
@@ -207,13 +209,13 @@ const q = (e) => {
207
209
  /* @__PURE__ */ t(
208
210
  "select",
209
211
  {
210
- ...x,
211
- id: b,
212
+ ...y,
213
+ id: f,
212
214
  ref: r,
213
215
  name: u,
214
216
  value: n,
215
217
  onChange: l,
216
- className: `block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none focus:outline-none focus:ring-0 disabled:text-[#6b7280] ${q(c)} peer ${f}`,
218
+ className: `block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 appearance-none focus:outline-none focus:ring-0 disabled:text-[#6b7280] ${q(c)} peer ${m}`,
217
219
  children: s == null ? void 0 : s.map((g) => /* @__PURE__ */ t("option", { value: g.id, children: g.value }, g.id))
218
220
  }
219
221
  ),
@@ -221,15 +223,15 @@ const q = (e) => {
221
223
  "label",
222
224
  {
223
225
  htmlFor: u,
224
- className: `peer-focus:font-medium absolute text-sm duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6 ${G(c)} ${m}`,
226
+ className: `peer-focus:font-medium absolute text-sm duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:start-0 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6 ${G(c)} ${b}`,
225
227
  children: o
226
228
  }
227
229
  ),
228
230
  /* @__PURE__ */ t(
229
231
  "p",
230
232
  {
231
- className: `mt-2 text-sm ${H(c)} ${y}`,
232
- children: c !== "error" && c !== "good" ? i : h
233
+ className: `mt-2 text-sm ${H(c)} ${x}`,
234
+ children: c !== "error" && c !== "good" ? i : p
233
235
  }
234
236
  )
235
237
  ] });
@@ -255,7 +257,7 @@ function Q() {
255
257
  ] });
256
258
  }
257
259
  function V() {
258
- const { t: e } = C(), { total: r, pageSize: n, pageSizes: l, currentPage: s, setCurrentPage: a } = S(), f = (s + 1) * n > r ? r : (s + 1) * n;
260
+ const { t: e } = C(), { total: r, pageSize: n, pageSizes: l, currentPage: s, setCurrentPage: a } = S(), m = (s + 1) * n > r ? r : (s + 1) * n;
259
261
  return /* @__PURE__ */ d("div", { className: "flex w-full items-center justify-between mt-5 px-5", children: [
260
262
  /* @__PURE__ */ d("div", { className: "flex w-full items-center justify-start gap-1", children: [
261
263
  /* @__PURE__ */ t("p", { children: e("_accessibility:components.table.pageSizes") }),
@@ -266,7 +268,7 @@ function V() {
266
268
  " ",
267
269
  e("_accessibility:components.table.to"),
268
270
  " ",
269
- f,
271
+ m,
270
272
  " ",
271
273
  e("_accessibility:components.table.of")
272
274
  ] }) }),
@@ -304,60 +306,58 @@ function te(e) {
304
306
  rows: l,
305
307
  parseRows: s,
306
308
  entity: a = "",
307
- isLoading: f = !1,
308
- actions: m = [],
309
- columns: h = [],
310
- contentClassName: y = "h-[calc(100vh-280px)]",
309
+ isLoading: m = !1,
310
+ actions: b,
311
+ columns: p = [],
312
+ contentClassName: x = "h-[calc(100vh-280px)]",
311
313
  className: i = "bg-gray-50",
312
314
  columnsOptions: o,
313
315
  softDeleteProperty: u = "deleted"
314
- } = e, b = w(
316
+ } = e, f = w(
315
317
  () => (l == null ? void 0 : l.map((c) => s(c))) ?? [],
316
318
  [s, l, r]
317
319
  );
318
320
  return /* @__PURE__ */ d("div", { className: `${i} relative overflow-x-auto w-full h-full`, children: [
319
321
  /* @__PURE__ */ t("div", { className: "mb-5 flex w-full items-center justify-between", children: /* @__PURE__ */ d("div", { children: [
320
322
  /* @__PURE__ */ t("h1", { className: "text-2xl md:text-3xl font-bold mx-5", children: n }),
321
- l != null && l.length && !f ? /* @__PURE__ */ t(Q, {}) : null
323
+ l != null && l.length && !m ? /* @__PURE__ */ t(Q, {}) : null
322
324
  ] }) }),
323
- f ? /* @__PURE__ */ t(F, { className: "bg-white top-0 left-0 w-full h-full" }) : /* @__PURE__ */ t("div", { className: `${y} overflow-auto`, children: l != null && l.length ? /* @__PURE__ */ d($, { children: [
325
+ m ? /* @__PURE__ */ t(F, { className: "bg-white top-0 left-0 w-full h-full" }) : /* @__PURE__ */ t("div", { className: `${x} overflow-auto`, children: l != null && l.length ? /* @__PURE__ */ d($, { children: [
324
326
  /* @__PURE__ */ d("table", { className: "w-full text-sm text-left text-gray-500", children: [
325
327
  /* @__PURE__ */ t(
326
328
  W,
327
329
  {
328
330
  entity: a,
329
- columns: h,
331
+ columns: p,
330
332
  columnsOptions: o,
331
- hasAction: (m == null ? void 0 : m.length) > 0
333
+ hasAction: !!b
332
334
  }
333
335
  ),
334
- /* @__PURE__ */ t("tbody", { children: b == null ? void 0 : b.map((c) => {
335
- var x, g;
336
+ /* @__PURE__ */ t("tbody", { children: f == null ? void 0 : f.map((c) => {
337
+ var y, g;
336
338
  return /* @__PURE__ */ d(
337
339
  "tr",
338
340
  {
339
- className: `border-b ${(x = c[u]) != null && x.value ? "deleted-class" : "bg-white"}`,
341
+ className: `border-b ${(y = c[u]) != null && y.value ? "deleted-class" : "bg-white"}`,
340
342
  children: [
341
- h == null ? void 0 : h.map((p, A) => {
343
+ p == null ? void 0 : p.map((h, A) => {
342
344
  var k;
343
345
  return /* @__PURE__ */ t(
344
346
  "td",
345
347
  {
346
- className: `px-6 py-4 font-medium ${A === 0 ? "text-gray-900 whitespace-nowrap" : ""} ${o != null && o.columnClassNames ? o == null ? void 0 : o.columnClassNames[p.key] : ""}`,
347
- children: ((k = c[p.key]) == null ? void 0 : k.render) ?? c[p.key]
348
+ className: `px-6 py-4 font-medium ${A === 0 ? "text-gray-900 whitespace-nowrap" : ""} ${o != null && o.columnClassNames ? o == null ? void 0 : o.columnClassNames[h.key] : ""}`,
349
+ children: ((k = c[h.key]) == null ? void 0 : k.render) ?? c[h.key]
348
350
  },
349
- p.key
351
+ h.key
350
352
  );
351
353
  }),
352
- m.length ? /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "flex items-center gap-3 w-full justify-center", children: (g = m.filter(
353
- (p) => !p.hidden || !p.hidden(c)
354
- )) == null ? void 0 : g.map((p) => /* @__PURE__ */ t(
354
+ b ? /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "flex items-center gap-3 w-full justify-center", children: (g = b(c).filter((h) => !h.hidden)) == null ? void 0 : g.map((h) => /* @__PURE__ */ t(
355
355
  L,
356
356
  {
357
- content: p.tooltip,
358
- children: /* @__PURE__ */ t("button", { onClick: () => p.onClick(c), children: p.icon })
357
+ content: h.tooltip,
358
+ children: /* @__PURE__ */ t("button", { onClick: h.onClick, children: h.icon })
359
359
  },
360
- p.id
360
+ h.id
361
361
  )) }) }) : null
362
362
  ]
363
363
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sito/dashboard",
3
3
  "private": false,
4
- "version": "0.0.15",
4
+ "version": "0.0.17",
5
5
  "type": "module",
6
6
  "description": "UI library with custom components for dashboards",
7
7
  "main": "dist/dashboard.cjs",