@sito/dashboard 0.0.3 → 0.0.5

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 +1 @@
1
- var W=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react");var j=(t=>(t.ASC="ASC",t.DESC="DESC",t))(j||{});const P=[20,50,100],C=u.createContext({}),z=t=>{const{children:r}=t,[l,s]=u.useState(0),[a,n]=u.useState(20),[p,b]=u.useState(0),[m,f]=u.useState("id"),[c,o]=u.useState(j.ASC),x={onSort:u.useCallback(h=>{let i=c;if(m===h)switch(c){case j.ASC:i=j.DESC;break;default:i=j.ASC;break}f(h),o(i)},[m,c]),total:l,setTotal:s,sortingBy:m,sortingOrder:c,pageSize:a,pageSizes:P,setPageSize:n,currentPage:p,setCurrentPage:b};return e.jsx(C.Provider,{value:x,children:r})},v=()=>{const t=u.useContext(C);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},w=u.createContext({});function _(t){const{children:r,t:l}=t;return e.jsx(w.Provider,{value:{t:l},children:r})}const y=()=>{const t=u.useContext(w);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};function A(t){const{content:r,children:l}=t;return e.jsxs("div",{className:"tooltip-container",children:[l,e.jsx("div",{className:"tooltip-text",children:r})]})}function S(t){const{color:r="stroke-blue-800",loaderClass:l,strokeWidth:s="4",...a}=t;return e.jsx("div",{...a,className:`loading ${a.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 ${r}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:s,strokeMiterlimit:"10"})})})})})}function B(){const{t}=y();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 k(t){const{className:r}=t;return e.jsx("svg",{className:r,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(t){const{className:r}=t;return e.jsx("svg",{className:r,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 M(t){const{t:r}=y(),{entity:l="",columns:s=[],hasAction:a=!0,columnsOptions:n}=t,{onSort:p,sortingOrder:b,sortingBy:m}=v(),f=u.useMemo(()=>{const{noSortableColumns:c={},columnClassNames:o={}}=n??{};return s==null?void 0:s.map(d=>({id:d.key,label:d.label,className:o[d.key]??"",sortable:!c[d.key]}))},[s,n,l,r]);return e.jsx("thead",{className:"text-xs text-gray-700 bg-gray-50",children:e.jsxs("tr",{children:[f.map(c=>{var o,d,x,h;return e.jsx("th",{scope:"col",className:`px-6 py-3 ${c.className}`,children:e.jsxs("button",{disabled:!c.sortable,onClick:()=>p(c.id),className:"flex items-center gap-2",children:[e.jsx("span",{className:"whitespace-nowrap",children:c.label}),c.sortable&&e.jsx("span",{className:`${m===c.id?"opacity-100":"opacity-0"}`,children:b===j.ASC?((o=n==null?void 0:n.icons)==null?void 0:o.asc)??e.jsx(k,{className:((d=n==null?void 0:n.icons)==null?void 0:d.className)??"w-3"}):((x=n==null?void 0:n.icons)==null?void 0:x.desc)??e.jsx(T,{className:((h=n==null?void 0:n.icons)==null?void 0:h.className)??"w-3"})})]})},c.id)}),a&&e.jsx("th",{scope:"col",className:"px-6 py-3 text-center",children:r("_accessibility:labels.actions")})]})})}var $=(t=>(t.error="error",t.good="good",t.default="default",t))($||{});const E=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"}},D=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"}},L=t=>{switch(t){case"error":return"text-red-600";case"good":return"text-green-600";default:return"text-gray-500"}},q=u.forwardRef(function(t,r){const{value:l,onChange:s,options:a,containerClassName:n="",inputClassName:p="",labelClassName:b="",helperText:m="",helperTextClassName:f="",placeholder:c="",label:o="",name:d="",id:x="",state:h=$.default,...i}=t;return u.useEffect(()=>{var g;(!l||l==="")&&(a!=null&&a.length)&&s({target:{value:(g=a[0])==null?void 0:g.id}})},[s,a,l]),e.jsxs("div",{className:`relative z-0 w-full mb-5 group ${n}`,children:[e.jsx("select",{...i,id:x,ref:r,name:d,value:l,onChange:s,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] ${E(h)} peer ${p}`,children:a==null?void 0:a.map(g=>e.jsx("option",{value:g.id,children:g.value},g.id))}),e.jsx("label",{htmlFor:d,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 ${D(h)} ${b}`,children:o}),e.jsx("p",{className:`mt-2 text-sm ${L(h)} ${f}`,children:h!=="error"&&h!=="good"?c:m})]})}),F=q;function I(){const{t}=y(),{pageSizes:r,pageSize:l,setPageSize:s}=v(),a=u.useMemo(()=>r==null?void 0:r.map(n=>({id:n,value:n})),[r]);return e.jsxs("div",{className:"flex gap-2 items-center justify-start",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(F,{value:l,options:a,inputClassName:"!py-0 !pl-2 !pr-7 !border-none font-bold",containerClassName:"!w-auto !mb-0 !border-none",helperTextClassName:"hidden",onChange:n=>s(n.target.value)})]})}function R(){const{t}=y(),{total:r,pageSize:l,pageSizes:s,currentPage:a,setCurrentPage:n}=v(),p=(a+1)*l>r?r:(a+1)*l;return e.jsxs("div",{className:"flex w-full items-center justify-between mt-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")}),s[0]<r&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[t("_accessibility:components.table.from")," ",a*l+1," ",t("_accessibility:components.table.to")," ",p," ",t("_accessibility:components.table.of")]})}),e.jsxs("p",{children:[r," ",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:a===0,onClick:()=>n(a-1),children:t("_accessibility:buttons.previous")}),e.jsx("button",{disabled:Math.floor(r/((a+1)*l))===0,className:"disabled:text-light-primary/40",onClick:()=>n(a+1),children:t("_accessibility:buttons.next")})]})]})}function U(t){const{t:r}=y(),{title:l="",rows:s,parseRows:a,entity:n="",isLoading:p=!1,actions:b=[],columns:m=[],contentClassName:f="h-[calc(100vh-280px)]",className:c="bg-gray-50",columnsOptions:o}=t,d=u.useMemo(()=>(s==null?void 0:s.map(x=>a(x)))??[],[a,s,r]);return e.jsxs("div",{className:`${c} 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",children:l}),(s==null?void 0:s.length)&&!p&&e.jsx(I,{})]})}),e.jsx("div",{className:`${f} overflow-auto`,children:!(s!=null&&s.length)&&!p?e.jsx(B,{}):e.jsxs("table",{className:"w-full text-sm text-left text-gray-500",children:[e.jsx(M,{entity:n,columns:m,columnsOptions:o,hasAction:(b==null?void 0:b.length)>0}),!p&&!!(s!=null&&s.length)&&e.jsx("tbody",{children:d==null?void 0:d.map(x=>{var h;return e.jsxs("tr",{className:`border-b ${x.deleted.value?"bg-secondary/10":"bg-white"}`,children:[m==null?void 0:m.map((i,g)=>{var N;return e.jsx("td",{className:`px-6 py-4 font-medium ${g===0?"text-gray-900 whitespace-nowrap":""} ${o!=null&&o.columnClassNames?o==null?void 0:o.columnClassNames[i.key]:""}`,children:((N=x[i.key])==null?void 0:N.render)??x[i.key]},i.key)}),!!b.length&&e.jsx("td",{children:e.jsx("div",{className:"flex items-center gap-3 w-full justify-center",children:(h=b.filter(i=>!i.hidden||!i.hidden(x)))==null?void 0:h.map(i=>e.jsx(A,{content:i.tooltip,children:e.jsx("button",{onClick:()=>i.onClick(x),children:i.icon})},i.id))})})]},x.id)})})]})}),p&&e.jsx(S,{className:"bg-white top-0 left-0 w-full h-full"}),!p&&(s==null?void 0:s.length)&&e.jsx(R,{})]})}exports.ChevronDown=T;exports.ChevronUp=k;exports.Loading=S;exports.Table=U;exports.TableOptionsProvider=z;exports.TranslationProvider=_;exports.useTableOptions=v;exports.useTranslation=y;
1
+ var W=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react");var j=(t=>(t.ASC="ASC",t.DESC="DESC",t))(j||{});const P=[20,50,100],C=u.createContext({}),z=t=>{const{children:r}=t,[l,s]=u.useState(0),[a,n]=u.useState(20),[p,b]=u.useState(0),[m,f]=u.useState("id"),[c,o]=u.useState(j.ASC),x={onSort:u.useCallback(h=>{let i=c;if(m===h)switch(c){case j.ASC:i=j.DESC;break;default:i=j.ASC;break}f(h),o(i)},[m,c]),total:l,setTotal:s,sortingBy:m,sortingOrder:c,pageSize:a,pageSizes:P,setPageSize:n,currentPage:p,setCurrentPage:b};return e.jsx(C.Provider,{value:x,children:r})},v=()=>{const t=u.useContext(C);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},w=u.createContext({});function _(t){const{children:r,t:l}=t;return e.jsx(w.Provider,{value:{t:l},children:r})}const y=()=>{const t=u.useContext(w);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};function A(t){const{content:r,children:l}=t;return e.jsxs("div",{className:"tooltip-container",children:[l,e.jsx("div",{className:"tooltip-text",children:r})]})}function S(t){const{color:r="stroke-blue-800",loaderClass:l,strokeWidth:s="4",...a}=t;return e.jsx("div",{...a,className:`loading ${a.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 ${r}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:s,strokeMiterlimit:"10"})})})})})}function M(){const{t}=y();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 k(t){const{className:r}=t;return e.jsx("svg",{className:r,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(t){const{className:r}=t;return e.jsx("svg",{className:r,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 B(t){const{t:r}=y(),{entity:l="",columns:s=[],hasAction:a=!0,columnsOptions:n}=t,{onSort:p,sortingOrder:b,sortingBy:m}=v(),f=u.useMemo(()=>{const{noSortableColumns:c={},columnClassNames:o={}}=n??{};return s==null?void 0:s.map(d=>({id:d.key,label:d.label,className:o[d.key]??"",sortable:!c[d.key]}))},[s,n,l,r]);return e.jsx("thead",{className:"text-xs text-gray-700 bg-gray-50",children:e.jsxs("tr",{children:[f.map(c=>{var o,d,x,h;return e.jsx("th",{scope:"col",className:`px-6 py-3 ${c.className}`,children:e.jsxs("button",{disabled:!c.sortable,onClick:()=>p(c.id),className:"flex items-center gap-2",children:[e.jsx("span",{className:"whitespace-nowrap",children:c.label}),c.sortable&&e.jsx("span",{className:`${m===c.id?"opacity-100":"opacity-0"}`,children:b===j.ASC?((o=n==null?void 0:n.icons)==null?void 0:o.asc)??e.jsx(k,{className:((d=n==null?void 0:n.icons)==null?void 0:d.className)??"w-3"}):((x=n==null?void 0:n.icons)==null?void 0:x.desc)??e.jsx(T,{className:((h=n==null?void 0:n.icons)==null?void 0:h.className)??"w-3"})})]})},c.id)}),a&&e.jsx("th",{scope:"col",className:"px-6 py-3 text-center",children:r("_accessibility:labels.actions")})]})})}var $=(t=>(t.error="error",t.good="good",t.default="default",t))($||{});const E=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"}},D=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"}},L=t=>{switch(t){case"error":return"text-red-600";case"good":return"text-green-600";default:return"text-gray-500"}},F=u.forwardRef(function(t,r){const{value:l,onChange:s,options:a,containerClassName:n="",inputClassName:p="",labelClassName:b="",helperText:m="",helperTextClassName:f="",placeholder:c="",label:o="",name:d="",id:x="",state:h=$.default,...i}=t;return u.useEffect(()=>{var g;(!l||l==="")&&(a!=null&&a.length)&&s({target:{value:(g=a[0])==null?void 0:g.id}})},[s,a,l]),e.jsxs("div",{className:`relative z-0 w-full mb-5 group ${n}`,children:[e.jsx("select",{...i,id:x,ref:r,name:d,value:l,onChange:s,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] ${E(h)} peer ${p}`,children:a==null?void 0:a.map(g=>e.jsx("option",{value:g.id,children:g.value},g.id))}),e.jsx("label",{htmlFor:d,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 ${D(h)} ${b}`,children:o}),e.jsx("p",{className:`mt-2 text-sm ${L(h)} ${f}`,children:h!=="error"&&h!=="good"?c:m})]})}),q=F;function I(){const{t}=y(),{pageSizes:r,pageSize:l,setPageSize:s}=v(),a=u.useMemo(()=>r==null?void 0:r.map(n=>({id:n,value:n})),[r]);return e.jsxs("div",{className:"flex gap-2 items-center justify-start",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(q,{value:l,options:a,inputClassName:"!py-0 !pl-2 !pr-7 !border-none font-bold",containerClassName:"!w-auto !mb-0 !border-none",helperTextClassName:"hidden",onChange:n=>s(n.target.value)})]})}function R(){const{t}=y(),{total:r,pageSize:l,pageSizes:s,currentPage:a,setCurrentPage:n}=v(),p=(a+1)*l>r?r:(a+1)*l;return e.jsxs("div",{className:"flex w-full items-center justify-between mt-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")}),s[0]<r&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[t("_accessibility:components.table.from")," ",a*l+1," ",t("_accessibility:components.table.to")," ",p," ",t("_accessibility:components.table.of")]})}),e.jsxs("p",{children:[r," ",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:a===0,onClick:()=>n(a-1),children:t("_accessibility:buttons.previous")}),e.jsx("button",{disabled:Math.floor(r/((a+1)*l))===0,className:"disabled:text-light-primary/40",onClick:()=>n(a+1),children:t("_accessibility:buttons.next")})]})]})}function U(t){const{t:r}=y(),{title:l="",rows:s,parseRows:a,entity:n="",isLoading:p=!1,actions:b=[],columns:m=[],contentClassName:f="h-[calc(100vh-280px)]",className:c="bg-gray-50",columnsOptions:o}=t,d=u.useMemo(()=>(s==null?void 0:s.map(x=>a(x)))??[],[a,s,r]);return e.jsxs("div",{className:`${c} 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",children:l}),(s==null?void 0:s.length)&&!p&&e.jsx(I,{})]})}),p?e.jsxs(e.Fragment,{children:[p&&e.jsx(S,{className:"bg-white top-0 left-0 w-full h-full"}),!p&&(s==null?void 0:s.length)&&e.jsx(R,{})]}):e.jsx("div",{className:`${f} overflow-auto`,children:s!=null&&s.length?e.jsxs("table",{className:"w-full text-sm text-left text-gray-500",children:[e.jsx(B,{entity:n,columns:m,columnsOptions:o,hasAction:(b==null?void 0:b.length)>0}),e.jsx("tbody",{children:d==null?void 0:d.map(x=>{var h;return e.jsxs("tr",{className:`border-b ${x.deleted.value?"bg-secondary/10":"bg-white"}`,children:[m==null?void 0:m.map((i,g)=>{var N;return e.jsx("td",{className:`px-6 py-4 font-medium ${g===0?"text-gray-900 whitespace-nowrap":""} ${o!=null&&o.columnClassNames?o==null?void 0:o.columnClassNames[i.key]:""}`,children:((N=x[i.key])==null?void 0:N.render)??x[i.key]},i.key)}),!!b.length&&e.jsx("td",{children:e.jsx("div",{className:"flex items-center gap-3 w-full justify-center",children:(h=b.filter(i=>!i.hidden||!i.hidden(x)))==null?void 0:h.map(i=>e.jsx(A,{content:i.tooltip,children:e.jsx("button",{onClick:()=>i.onClick(x),children:i.icon})},i.id))})})]},x.id)})})]}):e.jsx(M,{})})]})}exports.ChevronDown=T;exports.ChevronUp=k;exports.Loading=S;exports.Table=U;exports.TableOptionsProvider=z;exports.TranslationProvider=_;exports.useTableOptions=v;exports.useTranslation=y;
package/dist/dashboard.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import "./main.css";
2
- import { jsx as t, jsxs as p, Fragment as _ } from "react/jsx-runtime";
3
- import { createContext as k, useState as N, useCallback as j, useContext as $, useMemo as C, forwardRef as A, useEffect as B } from "react";
2
+ import { jsx as t, jsxs as h, Fragment as k } from "react/jsx-runtime";
3
+ import { createContext as $, useState as N, useCallback as j, useContext as P, useMemo as C, forwardRef as A, useEffect as B } from "react";
4
4
  var y = /* @__PURE__ */ ((e) => (e.ASC = "ASC", e.DESC = "DESC", e))(y || {});
5
- const E = [20, 50, 100], P = k({}), Y = (e) => {
6
- const { children: a } = e, [n, r] = N(0), [s, l] = N(20), [m, b] = N(0), [f, x] = N("id"), [c, o] = N(y.ASC), u = {
5
+ const E = [20, 50, 100], z = $({}), Y = (e) => {
6
+ const { children: s } = e, [n, r] = N(0), [a, l] = N(20), [m, b] = N(0), [f, x] = N("id"), [c, o] = N(y.ASC), u = {
7
7
  onSort: j(
8
- (h) => {
8
+ (p) => {
9
9
  let i = c;
10
- if (f === h)
10
+ if (f === p)
11
11
  switch (c) {
12
12
  case y.ASC:
13
13
  i = y.DESC;
@@ -16,7 +16,7 @@ const E = [20, 50, 100], P = k({}), Y = (e) => {
16
16
  i = y.ASC;
17
17
  break;
18
18
  }
19
- x(h), o(i);
19
+ x(p), o(i);
20
20
  },
21
21
  [f, c]
22
22
  ),
@@ -24,47 +24,47 @@ const E = [20, 50, 100], P = k({}), Y = (e) => {
24
24
  setTotal: r,
25
25
  sortingBy: f,
26
26
  sortingOrder: c,
27
- pageSize: s,
27
+ pageSize: a,
28
28
  pageSizes: E,
29
29
  setPageSize: l,
30
30
  currentPage: m,
31
31
  setCurrentPage: b
32
32
  };
33
- return /* @__PURE__ */ t(P.Provider, { value: u, children: a });
33
+ return /* @__PURE__ */ t(z.Provider, { value: u, children: s });
34
34
  }, w = () => {
35
- const e = $(P);
35
+ const e = P(z);
36
36
  if (e === void 0)
37
37
  throw new Error("tableOptionsContext must be used within a Provider");
38
38
  return e;
39
- }, z = k({});
39
+ }, T = $({});
40
40
  function Z(e) {
41
- const { children: a, t: n } = e;
42
- return /* @__PURE__ */ t(z.Provider, { value: { t: n }, children: a });
41
+ const { children: s, t: n } = e;
42
+ return /* @__PURE__ */ t(T.Provider, { value: { t: n }, children: s });
43
43
  }
44
44
  const v = () => {
45
- const e = $(z);
45
+ const e = P(T);
46
46
  if (e === void 0)
47
47
  throw new Error("translationContext must be used within a Provider");
48
48
  return e;
49
49
  };
50
50
  function M(e) {
51
- const { content: a, children: n } = e;
52
- return /* @__PURE__ */ p("div", { className: "tooltip-container", children: [
51
+ const { content: s, children: n } = e;
52
+ return /* @__PURE__ */ h("div", { className: "tooltip-container", children: [
53
53
  n,
54
- /* @__PURE__ */ t("div", { className: "tooltip-text", children: a })
54
+ /* @__PURE__ */ t("div", { className: "tooltip-text", children: s })
55
55
  ] });
56
56
  }
57
57
  function D(e) {
58
58
  const {
59
- color: a = "stroke-blue-800",
59
+ color: s = "stroke-blue-800",
60
60
  loaderClass: n,
61
61
  strokeWidth: r = "4",
62
- ...s
62
+ ...a
63
63
  } = e;
64
- return /* @__PURE__ */ t("div", { ...s, className: `loading ${s.className}`, children: /* @__PURE__ */ t("div", { className: "loader-container", children: /* @__PURE__ */ t("div", { className: `loader ${n}`, children: /* @__PURE__ */ t("svg", { className: "circular", viewBox: "25 25 50 50", children: /* @__PURE__ */ t(
64
+ return /* @__PURE__ */ t("div", { ...a, className: `loading ${a.className}`, children: /* @__PURE__ */ t("div", { className: "loader-container", children: /* @__PURE__ */ t("div", { className: `loader ${n}`, children: /* @__PURE__ */ t("svg", { className: "circular", viewBox: "25 25 50 50", children: /* @__PURE__ */ t(
65
65
  "circle",
66
66
  {
67
- className: `path ${a}`,
67
+ className: `path ${s}`,
68
68
  cx: "50",
69
69
  cy: "50",
70
70
  r: "20",
@@ -79,11 +79,11 @@ function L() {
79
79
  return /* @__PURE__ */ t("div", { className: "w-full flex items-center justify-center py-2 border-t-[1px]", children: /* @__PURE__ */ t("p", { children: e("_accessibility:components.table.empty") }) });
80
80
  }
81
81
  function F(e) {
82
- const { className: a } = e;
82
+ const { className: s } = e;
83
83
  return /* @__PURE__ */ t(
84
84
  "svg",
85
85
  {
86
- className: a,
86
+ className: s,
87
87
  xmlns: "http://www.w3.org/2000/svg",
88
88
  viewBox: "0 0 512 512",
89
89
  children: /* @__PURE__ */ t("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" })
@@ -91,11 +91,11 @@ function F(e) {
91
91
  );
92
92
  }
93
93
  function I(e) {
94
- const { className: a } = e;
94
+ const { className: s } = e;
95
95
  return /* @__PURE__ */ t(
96
96
  "svg",
97
97
  {
98
- className: a,
98
+ className: s,
99
99
  xmlns: "http://www.w3.org/2000/svg",
100
100
  viewBox: "0 0 512 512",
101
101
  children: /* @__PURE__ */ t("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" })
@@ -103,7 +103,7 @@ function I(e) {
103
103
  );
104
104
  }
105
105
  function R(e) {
106
- const { t: a } = v(), { entity: n = "", columns: r = [], hasAction: s = !0, columnsOptions: l } = e, { onSort: m, sortingOrder: b, sortingBy: f } = w(), x = C(() => {
106
+ const { t: s } = v(), { entity: n = "", columns: r = [], hasAction: a = !0, columnsOptions: l } = e, { onSort: m, sortingOrder: b, sortingBy: f } = w(), x = C(() => {
107
107
  const { noSortableColumns: c = {}, columnClassNames: o = {} } = l ?? {};
108
108
  return r == null ? void 0 : r.map((d) => ({
109
109
  id: d.key,
@@ -111,16 +111,16 @@ function R(e) {
111
111
  className: o[d.key] ?? "",
112
112
  sortable: !c[d.key]
113
113
  }));
114
- }, [r, l, n, a]);
115
- return /* @__PURE__ */ t("thead", { className: "text-xs text-gray-700 bg-gray-50", children: /* @__PURE__ */ p("tr", { children: [
114
+ }, [r, l, n, s]);
115
+ return /* @__PURE__ */ t("thead", { className: "text-xs text-gray-700 bg-gray-50", children: /* @__PURE__ */ h("tr", { children: [
116
116
  x.map((c) => {
117
- var o, d, u, h;
117
+ var o, d, u, p;
118
118
  return /* @__PURE__ */ t(
119
119
  "th",
120
120
  {
121
121
  scope: "col",
122
122
  className: `px-6 py-3 ${c.className}`,
123
- children: /* @__PURE__ */ p(
123
+ children: /* @__PURE__ */ h(
124
124
  "button",
125
125
  {
126
126
  disabled: !c.sortable,
@@ -140,7 +140,7 @@ function R(e) {
140
140
  ) : ((u = l == null ? void 0 : l.icons) == null ? void 0 : u.desc) ?? /* @__PURE__ */ t(
141
141
  I,
142
142
  {
143
- className: ((h = l == null ? void 0 : l.icons) == null ? void 0 : h.className) ?? "w-3"
143
+ className: ((p = l == null ? void 0 : l.icons) == null ? void 0 : p.className) ?? "w-3"
144
144
  }
145
145
  )
146
146
  }
@@ -152,10 +152,10 @@ function R(e) {
152
152
  c.id
153
153
  );
154
154
  }),
155
- s && /* @__PURE__ */ t("th", { scope: "col", className: "px-6 py-3 text-center", children: a("_accessibility:labels.actions") })
155
+ a && /* @__PURE__ */ t("th", { scope: "col", className: "px-6 py-3 text-center", children: s("_accessibility:labels.actions") })
156
156
  ] }) });
157
157
  }
158
- var T = /* @__PURE__ */ ((e) => (e.error = "error", e.good = "good", e.default = "default", e))(T || {});
158
+ var _ = /* @__PURE__ */ ((e) => (e.error = "error", e.good = "good", e.default = "default", e))(_ || {});
159
159
  const U = (e) => {
160
160
  switch (e) {
161
161
  case "error":
@@ -183,11 +183,11 @@ const U = (e) => {
183
183
  default:
184
184
  return "text-gray-500";
185
185
  }
186
- }, G = A(function(e, a) {
186
+ }, G = A(function(e, s) {
187
187
  const {
188
188
  value: n,
189
189
  onChange: r,
190
- options: s,
190
+ options: a,
191
191
  containerClassName: l = "",
192
192
  inputClassName: m = "",
193
193
  labelClassName: b = "",
@@ -197,55 +197,55 @@ const U = (e) => {
197
197
  label: o = "",
198
198
  name: d = "",
199
199
  id: u = "",
200
- state: h = T.default,
200
+ state: p = _.default,
201
201
  ...i
202
202
  } = e;
203
203
  return B(() => {
204
204
  var g;
205
- (!n || n === "") && (s != null && s.length) && r({ target: { value: (g = s[0]) == null ? void 0 : g.id } });
206
- }, [r, s, n]), /* @__PURE__ */ p("div", { className: `relative z-0 w-full mb-5 group ${l}`, children: [
205
+ (!n || n === "") && (a != null && a.length) && r({ target: { value: (g = a[0]) == null ? void 0 : g.id } });
206
+ }, [r, a, n]), /* @__PURE__ */ h("div", { className: `relative z-0 w-full mb-5 group ${l}`, children: [
207
207
  /* @__PURE__ */ t(
208
208
  "select",
209
209
  {
210
210
  ...i,
211
211
  id: u,
212
- ref: a,
212
+ ref: s,
213
213
  name: d,
214
214
  value: n,
215
215
  onChange: r,
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] ${U(h)} peer ${m}`,
217
- children: s == null ? void 0 : s.map((g) => /* @__PURE__ */ t("option", { value: g.id, children: g.value }, g.id))
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] ${U(p)} peer ${m}`,
217
+ children: a == null ? void 0 : a.map((g) => /* @__PURE__ */ t("option", { value: g.id, children: g.value }, g.id))
218
218
  }
219
219
  ),
220
220
  /* @__PURE__ */ t(
221
221
  "label",
222
222
  {
223
223
  htmlFor: d,
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 ${W(h)} ${b}`,
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 ${W(p)} ${b}`,
225
225
  children: o
226
226
  }
227
227
  ),
228
228
  /* @__PURE__ */ t(
229
229
  "p",
230
230
  {
231
- className: `mt-2 text-sm ${q(h)} ${x}`,
232
- children: h !== "error" && h !== "good" ? c : f
231
+ className: `mt-2 text-sm ${q(p)} ${x}`,
232
+ children: p !== "error" && p !== "good" ? c : f
233
233
  }
234
234
  )
235
235
  ] });
236
236
  }), H = G;
237
237
  function J() {
238
- const { t: e } = v(), { pageSizes: a, pageSize: n, setPageSize: r } = w(), s = C(
239
- () => a == null ? void 0 : a.map((l) => ({ id: l, value: l })),
240
- [a]
238
+ const { t: e } = v(), { pageSizes: s, pageSize: n, setPageSize: r } = w(), a = C(
239
+ () => s == null ? void 0 : s.map((l) => ({ id: l, value: l })),
240
+ [s]
241
241
  );
242
- return /* @__PURE__ */ p("div", { className: "flex gap-2 items-center justify-start", children: [
242
+ return /* @__PURE__ */ h("div", { className: "flex gap-2 items-center justify-start", children: [
243
243
  /* @__PURE__ */ t("p", { children: e("_accessibility:components.table.pageSizes") }),
244
244
  /* @__PURE__ */ t(
245
245
  H,
246
246
  {
247
247
  value: n,
248
- options: s,
248
+ options: a,
249
249
  inputClassName: "!py-0 !pl-2 !pr-7 !border-none font-bold",
250
250
  containerClassName: "!w-auto !mb-0 !border-none",
251
251
  helperTextClassName: "hidden",
@@ -255,14 +255,14 @@ function J() {
255
255
  ] });
256
256
  }
257
257
  function K() {
258
- const { t: e } = v(), { total: a, pageSize: n, pageSizes: r, currentPage: s, setCurrentPage: l } = w(), m = (s + 1) * n > a ? a : (s + 1) * n;
259
- return /* @__PURE__ */ p("div", { className: "flex w-full items-center justify-between mt-5", children: [
260
- /* @__PURE__ */ p("div", { className: "flex w-full items-center justify-start gap-1", children: [
258
+ const { t: e } = v(), { total: s, pageSize: n, pageSizes: r, currentPage: a, setCurrentPage: l } = w(), m = (a + 1) * n > s ? s : (a + 1) * n;
259
+ return /* @__PURE__ */ h("div", { className: "flex w-full items-center justify-between mt-5", children: [
260
+ /* @__PURE__ */ h("div", { className: "flex w-full items-center justify-start gap-1", children: [
261
261
  /* @__PURE__ */ t("p", { children: e("_accessibility:components.table.pageSizes") }),
262
- r[0] < a && /* @__PURE__ */ t(_, { children: /* @__PURE__ */ p("p", { children: [
262
+ r[0] < s && /* @__PURE__ */ t(k, { children: /* @__PURE__ */ h("p", { children: [
263
263
  e("_accessibility:components.table.from"),
264
264
  " ",
265
- s * n + 1,
265
+ a * n + 1,
266
266
  " ",
267
267
  e("_accessibility:components.table.to"),
268
268
  " ",
@@ -270,28 +270,28 @@ function K() {
270
270
  " ",
271
271
  e("_accessibility:components.table.of")
272
272
  ] }) }),
273
- /* @__PURE__ */ p("p", { children: [
274
- a,
273
+ /* @__PURE__ */ h("p", { children: [
274
+ s,
275
275
  " ",
276
276
  e("_accessibility:components.table.results")
277
277
  ] })
278
278
  ] }),
279
- /* @__PURE__ */ p("div", { className: "flex gap-5 items-center justify-end", children: [
279
+ /* @__PURE__ */ h("div", { className: "flex gap-5 items-center justify-end", children: [
280
280
  /* @__PURE__ */ t(
281
281
  "button",
282
282
  {
283
283
  className: "disabled:text-light-primary/40",
284
- disabled: s === 0,
285
- onClick: () => l(s - 1),
284
+ disabled: a === 0,
285
+ onClick: () => l(a - 1),
286
286
  children: e("_accessibility:buttons.previous")
287
287
  }
288
288
  ),
289
289
  /* @__PURE__ */ t(
290
290
  "button",
291
291
  {
292
- disabled: Math.floor(a / ((s + 1) * n)) === 0,
292
+ disabled: Math.floor(s / ((a + 1) * n)) === 0,
293
293
  className: "disabled:text-light-primary/40",
294
- onClick: () => l(s + 1),
294
+ onClick: () => l(a + 1),
295
295
  children: e("_accessibility:buttons.next")
296
296
  }
297
297
  )
@@ -299,10 +299,10 @@ function K() {
299
299
  ] });
300
300
  }
301
301
  function O(e) {
302
- const { t: a } = v(), {
302
+ const { t: s } = v(), {
303
303
  title: n = "",
304
304
  rows: r,
305
- parseRows: s,
305
+ parseRows: a,
306
306
  entity: l = "",
307
307
  isLoading: m = !1,
308
308
  actions: b = [],
@@ -311,15 +311,18 @@ function O(e) {
311
311
  className: c = "bg-gray-50",
312
312
  columnsOptions: o
313
313
  } = e, d = C(
314
- () => (r == null ? void 0 : r.map((u) => s(u))) ?? [],
315
- [s, r, a]
314
+ () => (r == null ? void 0 : r.map((u) => a(u))) ?? [],
315
+ [a, r, s]
316
316
  );
317
- return /* @__PURE__ */ p("div", { className: `${c} relative overflow-x-auto w-full h-full`, children: [
318
- /* @__PURE__ */ t("div", { className: "mb-5 flex w-full items-center justify-between", children: /* @__PURE__ */ p("div", { children: [
317
+ return /* @__PURE__ */ h("div", { className: `${c} relative overflow-x-auto w-full h-full`, children: [
318
+ /* @__PURE__ */ t("div", { className: "mb-5 flex w-full items-center justify-between", children: /* @__PURE__ */ h("div", { children: [
319
319
  /* @__PURE__ */ t("h1", { className: "text-2xl md:text-3xl font-bold", children: n }),
320
320
  (r == null ? void 0 : r.length) && !m && /* @__PURE__ */ t(J, {})
321
321
  ] }) }),
322
- /* @__PURE__ */ t("div", { className: `${x} overflow-auto`, children: !(r != null && r.length) && !m ? /* @__PURE__ */ t(L, {}) : /* @__PURE__ */ p("table", { className: "w-full text-sm text-left text-gray-500", children: [
322
+ m ? /* @__PURE__ */ h(k, { children: [
323
+ m && /* @__PURE__ */ t(D, { className: "bg-white top-0 left-0 w-full h-full" }),
324
+ !m && (r == null ? void 0 : r.length) && /* @__PURE__ */ t(K, {})
325
+ ] }) : /* @__PURE__ */ t("div", { className: `${x} overflow-auto`, children: r != null && r.length ? /* @__PURE__ */ h("table", { className: "w-full text-sm text-left text-gray-500", children: [
323
326
  /* @__PURE__ */ t(
324
327
  R,
325
328
  {
@@ -329,9 +332,9 @@ function O(e) {
329
332
  hasAction: (b == null ? void 0 : b.length) > 0
330
333
  }
331
334
  ),
332
- !m && !!(r != null && r.length) && /* @__PURE__ */ t("tbody", { children: d == null ? void 0 : d.map((u) => {
333
- var h;
334
- return /* @__PURE__ */ p(
335
+ /* @__PURE__ */ t("tbody", { children: d == null ? void 0 : d.map((u) => {
336
+ var p;
337
+ return /* @__PURE__ */ h(
335
338
  "tr",
336
339
  {
337
340
  className: `border-b ${u.deleted.value ? "bg-secondary/10" : "bg-white"}`,
@@ -347,17 +350,15 @@ function O(e) {
347
350
  i.key
348
351
  );
349
352
  }),
350
- !!b.length && /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "flex items-center gap-3 w-full justify-center", children: (h = b.filter(
353
+ !!b.length && /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "flex items-center gap-3 w-full justify-center", children: (p = b.filter(
351
354
  (i) => !i.hidden || !i.hidden(u)
352
- )) == null ? void 0 : h.map((i) => /* @__PURE__ */ t(M, { content: i.tooltip, children: /* @__PURE__ */ t("button", { onClick: () => i.onClick(u), children: i.icon }) }, i.id)) }) })
355
+ )) == null ? void 0 : p.map((i) => /* @__PURE__ */ t(M, { content: i.tooltip, children: /* @__PURE__ */ t("button", { onClick: () => i.onClick(u), children: i.icon }) }, i.id)) }) })
353
356
  ]
354
357
  },
355
358
  u.id
356
359
  );
357
360
  }) })
358
- ] }) }),
359
- m && /* @__PURE__ */ t(D, { className: "bg-white top-0 left-0 w-full h-full" }),
360
- !m && (r == null ? void 0 : r.length) && /* @__PURE__ */ t(K, {})
361
+ ] }) : /* @__PURE__ */ t(L, {}) })
361
362
  ] });
362
363
  }
363
364
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sito/dashboard",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "description": "UI library with custom components for dashboards",
7
7
  "main": "dist/dashboard.cjs",