@sito/dashboard 0.0.20 → 0.0.21
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.
- package/dist/dashboard.cjs +1 -1
- package/dist/main.css +1 -1
- package/package.json +1 -1
package/dist/dashboard.cjs
CHANGED
|
@@ -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,[l
|
|
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),[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:n,setTotal:l,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: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:p,sortingOrder:b,sortingBy:u}=N(),g=d.useMemo(()=>{const{noSortableColumns:o={},columnClassNames:i={}}=a??{};return l==null?void 0:l.map(x=>({id:x.key,label:x.label,className:i[x.key]??"",sortable:!o[x.key]}))},[l,a,n,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:n,onChange:l,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;(!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",{...j,id:m,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 ${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: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(),p=(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")," ",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)*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: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(()=>(l==null?void 0:l.map(c=>r(c)))??[],[r,l,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:n}),l!=null&&l.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: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: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/main.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
.tooltip-container{position:relative;display:inline-block;cursor:pointer}.tooltip-text{visibility:hidden;background-color:#000;color:#fff;text-align:center;padding:5px 10px;border-radius:5px;position:absolute;z-index:1;bottom:125%;left:50%;transform:translate(-50%);opacity:0;transition:opacity .3s}.tooltip-container:hover .tooltip-text{visibility:visible;opacity:1}.loader-container{padding:5%}.loader{width:40px;position:relative;margin:0 auto}.loader:before{content:"";padding-top:100%;display:block}.circular{width:100%;height:100%;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;animation:rotate 2s linear infinite;transform-origin:center center}.path{stroke-dasharray:1,200;stroke-dashoffset:0;animation:dash 1.5s ease-in-out infinite;stroke-linecap:round}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:89,200;stroke-dashoffset:-35px}to{stroke-dasharray:89,200;stroke-dashoffset:-124px}}.loading{display:flex;width:100%;height:100%;align-items:center;justify-content:center}
|