@sito/dashboard 0.0.30 → 0.0.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,3 +1,4 @@
1
+ import { MouseEventHandler } from 'react';
1
2
  export declare enum ChipVariant {
2
3
  empty = "empty",
3
4
  outlined = "outlined",
@@ -6,7 +7,7 @@ export declare enum ChipVariant {
6
7
  export type ChipPropsType = {
7
8
  variant?: ChipVariant;
8
9
  label?: string;
9
- onDelete?: () => void;
10
+ onDelete?: MouseEventHandler<HTMLElement>;
10
11
  className?: string;
11
12
  spanClassName?: string;
12
13
  };
@@ -1,9 +1,12 @@
1
- import { FilterTypes, SortOrder } from '../../../lib';
1
+ import { ReactNode } from 'react';
2
2
  import { Action } from '../types';
3
+ import { FilterTypes, SortOrder } from '../../../lib';
3
4
  export type ColumnType = {
4
5
  key: string;
5
6
  label: string;
7
+ /** if the column can be sorted */
6
8
  sortable?: boolean;
9
+ /** only works if sortable has value true */
7
10
  sortOptions: {
8
11
  icons: {
9
12
  className: string;
@@ -13,9 +16,13 @@ export type ColumnType = {
13
16
  };
14
17
  className?: string;
15
18
  display?: "visible" | "none";
19
+ /** column position from 0 */
16
20
  pos?: number;
17
- renderBody?: (value: any, row: any) => React.ReactNode;
21
+ /** custom body of the cell */
22
+ renderBody?: (value: any, row: any) => ReactNode;
23
+ /** custom head of the cell */
18
24
  renderHead?: () => void;
25
+ /** filter options */
19
26
  filterOptions?: ColumnFilterOptions;
20
27
  };
21
28
  export type ColumnPropsType = {
@@ -1,6 +1,6 @@
1
+ import { ReactNode } from 'react';
1
2
  import { SortOrder } from '../../lib';
2
3
  import { ColumnType } from './components';
3
- import { ReactNode } from 'react';
4
4
  export type Action = {
5
5
  id: string;
6
6
  onClick: (entity: object) => void;
@@ -11,7 +11,6 @@ export type Action = {
11
11
  export type TablePropsType = {
12
12
  entity: string;
13
13
  title?: string;
14
- subtitle?: string;
15
14
  data: object[];
16
15
  isLoading?: boolean;
17
16
  actions?: (row: object) => Action[];
@@ -1 +1 @@
1
- var $e=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react");function W(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",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 H(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",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 q(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"})})}function J(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"})})}const V=t=>{const{className:n=""}=t;return e.jsx("svg",{className:n,viewBox:"0 0 16 16",children:e.jsx("path",{d:"M9 15H7a1 1 0 010-2h2a1 1 0 010 2zM11 11H5a1 1 0 010-2h6a1 1 0 010 2zM13 7H3a1 1 0 010-2h10a1 1 0 010 2zM15 3H1a1 1 0 010-2h14a1 1 0 010 2z"})})};function D(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor",children:e.jsx("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})})}var E=(t=>(t.error="error",t.good="good",t.default="default",t))(E||{});const A=t=>{switch(t){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},B=t=>{switch(t){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},I=t=>{switch(t){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}};const R=o.forwardRef(function(t,n){const{value:r,onChange:s,options:a,containerClassName:l="",inputClassName:i="",labelClassName:c="",helperText:u="",helperTextClassName:x="",placeholder:d="",label:p="",name:v="",id:h="",state:m=E.default,...g}=t;return o.useEffect(()=>{var C;(!r||r==="")&&(a!=null&&a.length)&&s({target:{value:(C=a[0])==null?void 0:C.id}})},[s,a,r]),e.jsxs("div",{className:`select-input-container ${l}`,children:[e.jsx("select",{...g,id:h,ref:n,name:v,value:r,onChange:s,className:`select-input ${A(m)} peer ${i}`,children:a==null?void 0:a.map(C=>e.jsx("option",{value:C.id,children:C.value},C.id))}),e.jsx("label",{htmlFor:v,className:`select-input-label ${B(m)} ${c}`,children:p}),e.jsx("p",{className:`select-input-helper-text ${I(m)} ${x}`,children:m!=="error"&&m!=="good"?d:u})]})});const L=o.forwardRef(function(t,n){const{children:r,value:s,onChange:a,state:l=E.default,name:i="",id:c="",type:u="text",label:x="",required:d=!1,placeholder:p="",containerClassName:v="",inputClassName:h="",labelClassName:m="",helperText:g="",helperTextClassName:C="",...j}=t;return e.jsxs("div",{className:`text-input-container ${v}`,children:[e.jsx("input",{ref:n,type:u,name:i,id:c,className:`text-input ${A(l)} peer ${h}`,placeholder:"",required:d,value:s,onChange:a,...j}),e.jsxs("label",{htmlFor:i,className:`text-input-label ${B(l)} ${m}`,children:[x,d?" *":""]}),r,e.jsx("p",{className:`text-input-helper-text ${I(l)} ${C}`,children:l!=="error"&&l!=="good"?p:g})]})});const G=o.forwardRef(function(t,n){const{checked:r,onChange:s,state:a=E.default,name:l="",id:i="",type:c="text",label:u="",containerClassName:x="",inputClassName:d="",labelClassName:p="",helperText:v="",helperTextClassName:h="",...m}=t;return e.jsxs("label",{className:`input-check-container ${x}`,children:[e.jsx("input",{id:i,ref:n,name:l,type:"checkbox",checked:r,onChange:s,className:`input-check ${d}`,...m}),e.jsx("span",{className:`input-check-label ${p}`,children:u})]})});const K=o.forwardRef(function(t,n){const{state:r,value:s,onChange:a,options:l=[],name:i="",id:c="",label:u="",containerClassName:x="",inputContainerClassName:d="",helperText:p="",placeholder:v="",multiple:h=!1,...m}=t,[g,C]=o.useState(""),[j,f]=o.useState(!1),y=l.filter(b=>{const w=String(b.value).toLowerCase().includes(g==null?void 0:g.toLowerCase());return s&&s.length?s!=null&&s.some?!(s!=null&&s.some(_=>_.id===b.id)):(s==null?void 0:s.id)!==b.id:w}),M=o.useRef(null);o.useEffect(()=>{const b=z=>{M.current&&!M.current.contains(z.target)&&f(!1)},w=z=>{z.key==="Escape"&&f(!1)};return document.addEventListener("click",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("click",b),document.removeEventListener("keydown",w)}},[]);const O=b=>{C(b.target.value)},U=o.useCallback(b=>{C(""),a(b?h?s?[...s,b]:[b]:b:null),f(!1)},[h,a,s]),he=o.useCallback(b=>{const w=s.filter((z,_)=>_!==b);w.length?a(w):a(null)},[a,s]);return e.jsxs("div",{className:`autocomplete-input-container ${x}`,ref:M,children:[e.jsx(L,{state:r,name:i,id:c,value:!h&&s?s.value:g,onChange:O,placeholder:v,helperText:p,onFocus:()=>f(!0),label:u,containerClassName:`autocomplete-text-input ${d}`,ref:n,...m,children:!h&&s&&e.jsx("button",{type:"button",className:"autocomplete-delete-button",onClick:()=>U(),children:e.jsx(D,{})})}),j&&e.jsx("ul",{className:"autocomplete-suggestions-container",children:y.map(b=>e.jsx("li",{className:"autocomplete-suggestion-item hover:bg-primary/20",onClick:()=>U(b),children:b.value},b.id))}),h&&Array.isArray(s)&&s.length?e.jsx("ul",{className:"autocomplete-value-container",children:s.map((b,w)=>e.jsx("li",{children:e.jsx(me,{label:String(b.value),onDelete:()=>he(w)})},b.value))}):null]})});function Q(t){const{color:n="stroke-blue-800",loaderClass:r,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 ${r}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${n}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:s,strokeMiterlimit:"10"})})})})})}const X=o.createContext({});function xe(t){const{children:n,t:r}=t;return e.jsx(X.Provider,{value:{t:r},children:n})}const k=()=>{const t=o.useContext(X);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};var F=(t=>(t[t.text=0]="text",t[t.number=1]="number",t[t.select=2]="select",t[t.autocomplete=3]="autocomplete",t[t.date=4]="date",t[t.check=5]="check",t))(F||{}),T=(t=>(t.ASC="ASC",t.DESC="DESC",t))(T||{});const be=[20,50,100],Y=o.createContext({}),ge=t=>{const{children:n}=t,[r,s]=o.useState(0),[a,l]=o.useState(20),[i,c]=o.useState(0),[u,x]=o.useState("id"),[d,p]=o.useState(T.DESC),[v,h]=o.useState({}),m=o.useCallback((j,f)=>{let y=d;if(u===j)switch(d){case T.ASC:y=T.DESC;break;default:y=T.ASC;break}x(j),p(y),f&&f(j,y)},[u,d]),g=o.useCallback(j=>{const f=Object.entries(j).reduce((y,[M,O])=>(O&&typeof O.value<"u"&&(y[M]=O.value),y),{});h(f)},[]),C={onSort:m,total:r,setTotal:s,sortingBy:u,setSortingBy:x,sortingOrder:d,setSortingOrder:p,pageSize:a,pageSizes:be,setPageSize:l,currentPage:i,setCurrentPage:c,filters:v,onFilterApply:g};return e.jsx(Y.Provider,{value:C,children:n})},$=()=>{const t=o.useContext(Y);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};var N=(t=>(t[t.update=0]="update",t[t.reset=1]="reset",t))(N||{});const Z=t=>{const n={},r=Object.keys(t);return r==null||r.forEach(s=>{n[s]={value:t[s]}}),n};function ee(t,n){const{type:r}=n;switch(r){case N.reset:{const{filters:s}=n,a={};return s==null||s.forEach(({propertyName:l,defaultValue:i})=>{a[l]={value:i}}),{...t,...a}}case N.update:{const{toUpdate:s}=n;return{...t,...s}}default:return t}}const te=o.createContext({}),se=t=>{const{children:n}=t,{filters:r}=$(),[s,a]=o.useReducer(ee,Z(r)),l={currentFilters:s,setCurrentFilters:a};return e.jsx(te.Provider,{value:l,children:n})},P=()=>{const t=o.useContext(te);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};function ne(t){const{t:n}=k(),{entity:r="",columns:s=[],hasAction:a=!0,onSortCallback:l}=t,{onSort:i,sortingOrder:c,sortingBy:u}=$(),x=o.useMemo(()=>{var d;return(d=s.sort((p,v)=>(v.pos??0)-(p.pos??0)).filter(p=>p.display!=="none"))==null?void 0:d.map(p=>({id:p.key,label:p.label,className:p.className??"",sortable:p.sortable??!0,sortOptions:p.sortOptions}))},[s,r,n]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[x.map(d=>{var p,v,h,m,g,C,j,f;return e.jsx("th",{scope:"col",className:`table-headers-column ${d.className}`,children:e.jsxs("button",{disabled:!d.sortable,onClick:()=>i(d.id,l),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:d.label}),d.sortable&&e.jsx("span",{className:`${u===d.id?"table-headers-sort-on":"table-headers-sort"}`,children:c===T.ASC?((v=(p=d.sortOptions)==null?void 0:p.icons)==null?void 0:v.asc)??e.jsx(H,{className:((m=(h=d.sortOptions)==null?void 0:h.icons)==null?void 0:m.className)??"table-headers-sort-indicator"}):((C=(g=d.sortOptions)==null?void 0:g.icons)==null?void 0:C.desc)??e.jsx(W,{className:((f=(j=d.sortOptions)==null?void 0:j.icons)==null?void 0:f.className)??"table-headers-sort-indicator"})})]})},d.id)}),a&&e.jsx("th",{scope:"col",className:"table-headers-action",children:n("_accessibility:labels.actions")})]})})}function ae(){const{t}=k();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}const re=()=>{const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$();return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx("button",{className:"table-navigation-buttons",disabled:s===0,"aria-label":t("_accessibility:buttons.previous"),name:t("_accessibility:buttons.previous"),onClick:()=>a(s-1),children:e.jsx(J,{className:"w-2.5"})}),e.jsx("button",{disabled:Math.floor(n/((s+1)*r))===0,className:"table-navigation-buttons",name:t("_accessibility:buttons.next"),"aria-label":t("_accessibility:buttons.next"),onClick:()=>a(s+1),children:e.jsx(q,{className:"w-2.5"})})]})},le=()=>{const{t}=k(),{total:n,pageSize:r,pageSizes:s,currentPage:a}=$(),l=(a+1)*r>n?n:(a+1)*r;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<n&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[a*r+1," - ",l," ",t("_accessibility:components.table.of")]})}),e.jsx("p",{children:n})]})};function oe(){const{t}=k(),{pageSizes:n,pageSize:r,setPageSize:s}=$(),a=o.useMemo(()=>n==null?void 0:n.map(l=>({id:l,value:l})),[n]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:r,options:a,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:l=>s(l.target.value)})]})}function ve(){const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$(),l=o.useMemo(()=>{const i=Math.ceil(n/r);return Array.from({length:i},(c,u)=>({id:u,value:u+1}))},[n,r]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:t("_accessibility:components.table.jumpToPage")}),e.jsx(R,{value:s,options:l,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:i=>a(Number(i.target.value))})]})}function ce(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ve,{}),e.jsx(oe,{}),e.jsx(le,{}),e.jsx(re,{})]})}function Ce(t){const{propertyName:n,options:r,label:s}=t,{currentFilters:a,setCurrentFilters:l}=P(),i=o.useMemo(()=>{var u;return((u=a[n])==null?void 0:u.value)??r[0]},[a]),c=o.useCallback(u=>{l({type:N.update,toUpdate:{[n]:{value:u.target.value}}})},[]);return e.jsx(R,{value:i,label:s,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:c})}const je=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},fe=t=>{const{propertyName:n,label:r,min:s,max:a}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>{var x;return((x=l[n])==null?void 0:x.value)??""},[l]),u=o.useCallback(x=>{i({type:N.update,toUpdate:{[n]:{value:x.target.value}}})},[c]);return e.jsx(L,{value:c??"",min:s,max:a,type:"number",label:r,containerClassName:"input-widget-container",onChange:u,helperTextClassName:""})},Ne=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.checked}}})},[]);return e.jsx(G,{label:r,checked:l??!1,onChange:i})};function ye(t){const{propertyName:n,label:r,options:s,multiple:a=!0}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>l[n]??s[0],[l]),u=o.useCallback(x=>{i({type:N.update,toUpdate:{[n]:{value:x}}})},[a]);return e.jsx(K,{value:c==null?void 0:c.value,label:r,options:s,multiple:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u})}const we=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c,u;return(c=s[n])!=null&&c.value?new Date(String((u=s[n])==null?void 0:u.value)).toISOString().slice(0,10):""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,type:"date",onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},ie=t=>{switch(t.type){case F.text:return e.jsx(je,{...t});case F.number:return e.jsx(fe,{...t});case F.select:return e.jsx(Ce,{...t});case F.autocomplete:return e.jsx(ye,{...t});case F.date:return e.jsx(we,{...t});case F.check:return e.jsx(Ne,{...t})}return e.jsx(e.Fragment,{})};const ue=t=>{const{align:n="right",filters:r=[],icon:s}=t,[a,l]=o.useState(!1),{onFilterApply:i,filters:c}=$(),{currentFilters:u,setCurrentFilters:x}=P(),{t:d}=k(),p=o.useRef(null),v=o.useRef(null);return o.useEffect(()=>{const h=({target:m})=>{var g,C;v.current&&(!a||(g=v.current)!=null&&g.contains(m)||(C=p==null?void 0:p.current)!=null&&C.contains(m)||l(!1))};return document.addEventListener("click",h),()=>document.removeEventListener("click",h)}),o.useEffect(()=>{const h=m=>{!a||m.code!=="Escape"||l(!1)};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)}),e.jsxs("div",{className:"filter-dropdown-main",children:[e.jsxs("button",{ref:p,className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>l(!a),"aria-expanded":a,children:[e.jsx("span",{className:"sr-only",children:d("_accessibility:buttons.filters")}),e.jsx("wbr",{}),s??e.jsx(V,{className:"filter-dropdown-trigger-icon"})]}),e.jsx("div",{className:`filter-dropdown-transition ${a?"opened":"closed"} ${n==="right"?"right":"left"}`,children:e.jsxs("div",{ref:v,children:[e.jsx("div",{className:"filter-title",children:d("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:r.map(h=>e.jsx("li",{className:"filter-container-item",children:ie(h)},h.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>x({type:N.reset}),className:"filter-dropdown-button small filter-dropdown-cancel",children:d("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit bg-primary hover:bg-light-primary",onClick:()=>{l(!1),i(u)},onBlur:()=>l(!1),children:d("_accessibility:buttons.applyFilters")})})]})})]})})]})},Se=t=>t,de=t=>{const{columns:n,softDeleteProperty:r="deleted",data:s,actions:a}=t,l=o.useMemo(()=>n.sort((i,c)=>(c.pos??0)-(i.pos??0)).filter(i=>i.display!=="none"),[n]);return s==null?void 0:s.map(i=>{var c;return e.jsxs("tr",{className:`table-row ${i[r]?"deleted-class":""}`,children:[l==null?void 0:l.map((u,x)=>e.jsx("td",{className:`table-row-cell ${x===0?"basic":""} ${u.className??""}`,children:u.renderBody?u.renderBody(i[u.key],i):Se(i[u.key])},u.key)),a?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(c=a(i).filter(u=>!u.hidden))==null?void 0:c.map(u=>e.jsx(pe,{content:u.tooltip,children:e.jsx("button",{onClick:u.onClick,children:u.icon})},u.id))})}):null]},i.id)})};function ke(t){const{title:n="",data:r,onSort:s,entity:a="",isLoading:l=!1,actions:i,columns:c=[],contentClassName:u="",className:x="",toolbar:d=e.jsx(e.Fragment,{}),softDeleteProperty:p="deleted"}=t,v=o.useMemo(()=>c?c.sort((m,g)=>(g.pos??0)-(m.pos??0)).filter(m=>!!m.filterOptions).map(m=>{var g;return{...m.filterOptions,label:((g=m.filterOptions)==null?void 0:g.label)??m.label,propertyName:m.key}}):[],[c]),h=o.useMemo(()=>!(r!=null&&r.length),[r]);return e.jsx(se,{children:e.jsxs("div",{className:`${x} table-main`,children:[e.jsxs("div",{className:"table-header",children:[e.jsx("h1",{className:"table-header-title",children:n}),l?null:e.jsxs("div",{className:"table-header-right",children:[d,e.jsx(ue,{filters:v})]})]}),l?e.jsx(Q,{className:"table-loading"}):e.jsx(e.Fragment,{children:h?e.jsx(ae,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${u} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(ne,{entity:a,columns:c,onSortCallback:s,hasAction:!!i}),e.jsx("tbody",{children:e.jsx(de,{data:r,actions:i,columns:c,softDeleteProperty:p})})]})}),e.jsx(ce,{})]})})]})})}function pe(t){const{content:n,children:r}=t;return e.jsxs("div",{className:"tooltip-container",children:[r,e.jsx("div",{className:"tooltip-text",children:n})]})}var S=(t=>(t.empty="empty",t.outlined="outlined",t.default="default",t))(S||{});function me(t){const{label:n,onDelete:r,className:s="",spanClassName:a="",variant:l=S.default}=t,i=o.useMemo(()=>{switch(l){case S.empty:return"text-primary bg-transparent";case S.outlined:return"border border-primary";case S.default:default:return"text-white bg-primary"}},[l]),c=o.useMemo(()=>{switch(l){case S.empty:case S.outlined:return"chip-delete-button-svg";case S.default:default:return"filled-chip-delete-button-svg"}},[l]);return e.jsxs("div",{className:`chip-main ${i} ${s}`,children:[e.jsx("span",{className:a,children:n}),r?e.jsx("button",{type:"button",className:"chip-delete-button",onClick:r,children:e.jsx(D,{className:c})}):null]})}exports.AutocompleteInput=K;exports.CheckInput=G;exports.ChevronDown=W;exports.ChevronLeft=J;exports.ChevronRight=q;exports.ChevronUp=H;exports.Chip=me;exports.ChipVariant=S;exports.Close=D;exports.Columns=ne;exports.CountOfTotal=le;exports.Empty=ae;exports.FilterPopup=ue;exports.Filters=V;exports.FiltersActions=N;exports.FiltersProvider=se;exports.Footer=ce;exports.Loading=Q;exports.Navigation=re;exports.PageSize=oe;exports.Rows=de;exports.SelectInput=R;exports.State=E;exports.Table=ke;exports.TableOptionsProvider=ge;exports.TextInput=L;exports.Tooltip=pe;exports.TranslationProvider=xe;exports.filtersReducer=ee;exports.helperTextStateClassName=I;exports.initializer=Z;exports.inputStateClassName=A;exports.labelStateClassName=B;exports.renderFilterComponent=ie;exports.useFilters=P;exports.useTableOptions=$;exports.useTranslation=k;
1
+ var $e=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react");function W(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",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 H(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",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 q(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"})})}function J(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"})})}const V=t=>{const{className:n=""}=t;return e.jsx("svg",{className:n,viewBox:"0 0 16 16",children:e.jsx("path",{d:"M9 15H7a1 1 0 010-2h2a1 1 0 010 2zM11 11H5a1 1 0 010-2h6a1 1 0 010 2zM13 7H3a1 1 0 010-2h10a1 1 0 010 2zM15 3H1a1 1 0 010-2h14a1 1 0 010 2z"})})};function _(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor",children:e.jsx("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})})}var z=(t=>(t.error="error",t.good="good",t.default="default",t))(z||{});const D=t=>{switch(t){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},B=t=>{switch(t){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},I=t=>{switch(t){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}};const R=o.forwardRef(function(t,n){const{value:r,onChange:s,options:a,containerClassName:l="",inputClassName:i="",labelClassName:c="",helperText:u="",helperTextClassName:x="",placeholder:d="",label:p="",name:v="",id:h="",state:m=z.default,...g}=t;return o.useEffect(()=>{var C;(!r||r==="")&&(a!=null&&a.length)&&s({target:{value:(C=a[0])==null?void 0:C.id}})},[s,a,r]),e.jsxs("div",{className:`select-input-container ${l}`,children:[e.jsx("select",{...g,id:h,ref:n,name:v,value:r,onChange:s,className:`select-input ${D(m)} peer ${i}`,children:a==null?void 0:a.map(C=>e.jsx("option",{value:C.id,children:C.value},C.id))}),e.jsx("label",{htmlFor:v,className:`select-input-label ${B(m)} ${c}`,children:p}),e.jsx("p",{className:`select-input-helper-text ${I(m)} ${x}`,children:m!=="error"&&m!=="good"?d:u})]})});const L=o.forwardRef(function(t,n){const{children:r,value:s,onChange:a,state:l=z.default,name:i="",id:c="",type:u="text",label:x="",required:d=!1,placeholder:p="",containerClassName:v="",inputClassName:h="",labelClassName:m="",helperText:g="",helperTextClassName:C="",...j}=t;return e.jsxs("div",{className:`text-input-container ${v}`,children:[e.jsx("input",{ref:n,type:u,name:i,id:c,className:`text-input ${D(l)} peer ${h}`,placeholder:"",required:d,value:s,onChange:a,...j}),e.jsxs("label",{htmlFor:i,className:`text-input-label ${B(l)} ${m}`,children:[x,d?" *":""]}),r,e.jsx("p",{className:`text-input-helper-text ${I(l)} ${C}`,children:l!=="error"&&l!=="good"?p:g})]})});const G=o.forwardRef(function(t,n){const{checked:r,onChange:s,state:a=z.default,name:l="",id:i="",type:c="text",label:u="",containerClassName:x="",inputClassName:d="",labelClassName:p="",helperText:v="",helperTextClassName:h="",...m}=t;return e.jsxs("label",{className:`input-check-container ${x}`,children:[e.jsx("input",{id:i,ref:n,name:l,type:"checkbox",checked:r,onChange:s,className:`input-check ${d}`,...m}),e.jsx("span",{className:`input-check-label ${p}`,children:u})]})});const K=o.forwardRef(function(t,n){const{state:r,value:s,onChange:a,options:l=[],name:i="",id:c="",label:u="",containerClassName:x="",inputContainerClassName:d="",helperText:p="",placeholder:v="",multiple:h=!1,...m}=t,[g,C]=o.useState(""),[j,f]=o.useState(!1),w=l.filter(b=>{const N=String(b.value).toLowerCase().includes(g==null?void 0:g.toLowerCase());return s&&s.length?s!=null&&s.some?!(s!=null&&s.some(A=>A.id===b.id)):(s==null?void 0:s.id)!==b.id:N}),E=o.useRef(null);o.useEffect(()=>{const b=F=>{E.current&&!E.current.contains(F.target)&&f(!1)},N=F=>{F.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",N)}},[]);const M=b=>{C(b.target.value)},U=o.useCallback(b=>{C(""),b?h?Array.isArray(s)&&s.length?a([...s,b]):a([b]):a(b):a(null),f(!1)},[h,a,s]),he=o.useCallback(b=>{const N=s.filter((F,A)=>A!==b);N.length?a(N):a(null)},[a,s]);return e.jsxs("div",{className:`autocomplete-input-container ${x}`,ref:E,children:[e.jsx(L,{state:r,name:i,id:c,value:!h&&s?s:g,onChange:M,placeholder:v,helperText:p,onFocus:()=>f(!0),label:u,containerClassName:`autocomplete-text-input ${d}`,ref:n,...m,children:!h&&s&&e.jsx("button",{type:"button",className:"autocomplete-delete-button",onClick:b=>{U(),b.stopPropagation()},children:e.jsx(_,{})})}),j&&e.jsx("ul",{className:"autocomplete-suggestions-container",children:w.map(b=>e.jsx("li",{className:"autocomplete-suggestion-item hover:bg-primary/20",onClick:N=>{U(b),N.stopPropagation()},children:b.value},b.id))}),h&&Array.isArray(s)&&s.length?e.jsx("ul",{className:"autocomplete-value-container",children:s.map((b,N)=>e.jsx("li",{children:e.jsx(me,{label:String(b.value),onDelete:F=>{he(N),F.stopPropagation()}})},b.value))}):null]})});function Q(t){const{color:n="stroke-blue-800",loaderClass:r,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 ${r}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${n}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:s,strokeMiterlimit:"10"})})})})})}const X=o.createContext({});function xe(t){const{children:n,t:r}=t;return e.jsx(X.Provider,{value:{t:r},children:n})}const k=()=>{const t=o.useContext(X);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};var O=(t=>(t[t.text=0]="text",t[t.number=1]="number",t[t.select=2]="select",t[t.autocomplete=3]="autocomplete",t[t.date=4]="date",t[t.check=5]="check",t))(O||{}),T=(t=>(t.ASC="ASC",t.DESC="DESC",t))(T||{});const be=[20,50,100],Y=o.createContext({}),ge=t=>{const{children:n}=t,[r,s]=o.useState(0),[a,l]=o.useState(20),[i,c]=o.useState(0),[u,x]=o.useState("id"),[d,p]=o.useState(T.DESC),[v,h]=o.useState({}),m=o.useCallback((j,f)=>{let w=d;if(u===j)switch(d){case T.ASC:w=T.DESC;break;default:w=T.ASC;break}x(j),p(w),f&&f(j,w)},[u,d]),g=o.useCallback(j=>{const f=Object.entries(j).reduce((w,[E,M])=>(M&&typeof M.value<"u"&&(w[E]=M.value),w),{});h(f)},[]),C={onSort:m,total:r,setTotal:s,sortingBy:u,setSortingBy:x,sortingOrder:d,setSortingOrder:p,pageSize:a,pageSizes:be,setPageSize:l,currentPage:i,setCurrentPage:c,filters:v,onFilterApply:g};return e.jsx(Y.Provider,{value:C,children:n})},$=()=>{const t=o.useContext(Y);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};var y=(t=>(t[t.update=0]="update",t[t.reset=1]="reset",t))(y||{});const Z=t=>{const n={},r=Object.keys(t);return r==null||r.forEach(s=>{n[s]={value:t[s]}}),n};function ee(t,n){const{type:r}=n;switch(r){case y.reset:{const{filters:s}=n,a={};return s==null||s.forEach(({propertyName:l,defaultValue:i})=>{a[l]={value:i}}),{...t,...a}}case y.update:{const{toUpdate:s}=n;return{...t,...s}}default:return t}}const te=o.createContext({}),se=t=>{const{children:n}=t,{filters:r}=$(),[s,a]=o.useReducer(ee,Z(r)),l={currentFilters:s,setCurrentFilters:a};return e.jsx(te.Provider,{value:l,children:n})},P=()=>{const t=o.useContext(te);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};function ne(t){const{t:n}=k(),{entity:r="",columns:s=[],hasAction:a=!0,onSortCallback:l}=t,{onSort:i,sortingOrder:c,sortingBy:u}=$(),x=o.useMemo(()=>{var d;return(d=s.sort((p,v)=>(v.pos??0)-(p.pos??0)).filter(p=>p.display!=="none"))==null?void 0:d.map(p=>({id:p.key,label:p.label,className:p.className??"",sortable:p.sortable??!0,sortOptions:p.sortOptions}))},[s,r,n]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[x.map(d=>{var p,v,h,m,g,C,j,f;return e.jsx("th",{scope:"col",className:`table-headers-column ${d.className}`,children:e.jsxs("button",{disabled:!d.sortable,onClick:()=>i(d.id,l),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:d.label}),d.sortable&&e.jsx("span",{className:`${u===d.id?"table-headers-sort-on":"table-headers-sort"}`,children:c===T.ASC?((v=(p=d.sortOptions)==null?void 0:p.icons)==null?void 0:v.asc)??e.jsx(H,{className:((m=(h=d.sortOptions)==null?void 0:h.icons)==null?void 0:m.className)??"table-headers-sort-indicator"}):((C=(g=d.sortOptions)==null?void 0:g.icons)==null?void 0:C.desc)??e.jsx(W,{className:((f=(j=d.sortOptions)==null?void 0:j.icons)==null?void 0:f.className)??"table-headers-sort-indicator"})})]})},d.id)}),a&&e.jsx("th",{scope:"col",className:"table-headers-action",children:n("_accessibility:labels.actions")})]})})}function ae(){const{t}=k();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}const re=()=>{const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$();return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx("button",{className:"table-navigation-buttons",disabled:s===0,"aria-label":t("_accessibility:buttons.previous"),name:t("_accessibility:buttons.previous"),onClick:()=>a(s-1),children:e.jsx(J,{className:"w-2.5"})}),e.jsx("button",{disabled:Math.floor(n/((s+1)*r))===0,className:"table-navigation-buttons",name:t("_accessibility:buttons.next"),"aria-label":t("_accessibility:buttons.next"),onClick:()=>a(s+1),children:e.jsx(q,{className:"w-2.5"})})]})},le=()=>{const{t}=k(),{total:n,pageSize:r,pageSizes:s,currentPage:a}=$(),l=(a+1)*r>n?n:(a+1)*r;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<n&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[a*r+1," - ",l," ",t("_accessibility:components.table.of")]})}),e.jsx("p",{children:n})]})};function oe(){const{t}=k(),{pageSizes:n,pageSize:r,setPageSize:s}=$(),a=o.useMemo(()=>n==null?void 0:n.map(l=>({id:l,value:l})),[n]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:r,options:a,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:l=>s(l.target.value)})]})}function ve(){const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$(),l=o.useMemo(()=>{const i=Math.ceil(n/r);return Array.from({length:i},(c,u)=>({id:u,value:u+1}))},[n,r]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:t("_accessibility:components.table.jumpToPage")}),e.jsx(R,{value:s,options:l,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:i=>a(Number(i.target.value))})]})}function ce(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ve,{}),e.jsx(oe,{}),e.jsx(le,{}),e.jsx(re,{})]})}function Ce(t){const{propertyName:n,options:r,label:s}=t,{currentFilters:a,setCurrentFilters:l}=P(),i=o.useMemo(()=>{var u;return((u=a[n])==null?void 0:u.value)??r[0]},[a]),c=o.useCallback(u=>{l({type:y.update,toUpdate:{[n]:{value:u.target.value}}})},[]);return e.jsx(R,{value:i,label:s,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:c})}const je=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:y.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},fe=t=>{const{propertyName:n,label:r,min:s,max:a}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>{var x;return((x=l[n])==null?void 0:x.value)??""},[l]),u=o.useCallback(x=>{i({type:y.update,toUpdate:{[n]:{value:x.target.value}}})},[c]);return e.jsx(L,{value:c??"",min:s,max:a,type:"number",label:r,containerClassName:"input-widget-container",onChange:u,helperTextClassName:""})},Ne=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:y.update,toUpdate:{[n]:{value:c.target.checked}}})},[]);return e.jsx(G,{label:r,checked:l??!1,onChange:i})};function ye(t){const{propertyName:n,label:r,options:s,multiple:a=!0}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>l[n]??s[0],[l]),u=o.useCallback(x=>{i({type:y.update,toUpdate:{[n]:{value:x}}})},[a]);return e.jsx(K,{value:c==null?void 0:c.value,label:r,options:s,multiple:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u})}const we=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c,u;return(c=s[n])!=null&&c.value?new Date(String((u=s[n])==null?void 0:u.value)).toISOString().slice(0,10):""},[s]),i=o.useCallback(c=>{a({type:y.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,type:"date",onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},ie=t=>{switch(t.type){case O.text:return e.jsx(je,{...t});case O.number:return e.jsx(fe,{...t});case O.select:return e.jsx(Ce,{...t});case O.autocomplete:return e.jsx(ye,{...t});case O.date:return e.jsx(we,{...t});case O.check:return e.jsx(Ne,{...t})}return e.jsx(e.Fragment,{})};const ue=t=>{const{align:n="right",filters:r=[],icon:s}=t,[a,l]=o.useState(!1),{onFilterApply:i,filters:c}=$(),{currentFilters:u,setCurrentFilters:x}=P(),{t:d}=k(),p=o.useRef(null),v=o.useRef(null);return o.useEffect(()=>{const h=({target:m})=>{var g,C;v.current&&(!a||(g=v.current)!=null&&g.contains(m)||(C=p==null?void 0:p.current)!=null&&C.contains(m)||l(!1))};return document.addEventListener("click",h),()=>document.removeEventListener("click",h)}),o.useEffect(()=>{const h=m=>{!a||m.code!=="Escape"||l(!1)};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)}),e.jsxs("div",{className:"filter-dropdown-main",children:[e.jsxs("button",{ref:p,className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>l(!a),"aria-expanded":a,children:[e.jsx("span",{className:"sr-only",children:d("_accessibility:buttons.filters")}),e.jsx("wbr",{}),s??e.jsx(V,{className:"filter-dropdown-trigger-icon"})]}),e.jsx("div",{className:`filter-dropdown-transition ${a?"opened":"closed"} ${n==="right"?"right":"left"}`,children:e.jsxs("div",{ref:v,children:[e.jsx("div",{className:"filter-title",children:d("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:r.map(h=>e.jsx("li",{className:"filter-container-item",children:ie(h)},h.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>x({type:y.reset,filters:r}),className:"filter-dropdown-button small filter-dropdown-cancel",children:d("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit bg-primary hover:bg-light-primary",onClick:()=>{l(!1),i(u)},onBlur:()=>l(!1),children:d("_accessibility:buttons.applyFilters")})})]})})]})})]})},Se=t=>t,de=t=>{const{columns:n,softDeleteProperty:r="deleted",data:s,actions:a}=t,l=o.useMemo(()=>n.sort((i,c)=>(c.pos??0)-(i.pos??0)).filter(i=>i.display!=="none"),[n]);return s==null?void 0:s.map(i=>{var c;return e.jsxs("tr",{className:`table-row ${i[r]?"deleted-class":""}`,children:[l==null?void 0:l.map((u,x)=>e.jsx("td",{className:`table-row-cell ${x===0?"basic":""} ${u.className??""}`,children:u.renderBody?u.renderBody(i[u.key],i):Se(i[u.key])},u.key)),a?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(c=a(i).filter(u=>!u.hidden))==null?void 0:c.map(u=>e.jsx(pe,{content:u.tooltip,children:e.jsx("button",{onClick:u.onClick,children:u.icon})},u.id))})}):null]},i.id)})};function ke(t){const{title:n="",data:r,onSort:s,entity:a="",isLoading:l=!1,actions:i,columns:c=[],contentClassName:u="",className:x="",toolbar:d=e.jsx(e.Fragment,{}),softDeleteProperty:p="deleted"}=t,v=o.useMemo(()=>c?c.sort((m,g)=>(g.pos??0)-(m.pos??0)).filter(m=>!!m.filterOptions).map(m=>{var g;return{...m.filterOptions,label:((g=m.filterOptions)==null?void 0:g.label)??m.label,propertyName:m.key}}):[],[c]),h=o.useMemo(()=>!(r!=null&&r.length),[r]);return e.jsx(se,{children:e.jsxs("div",{className:`${x} table-main`,children:[e.jsxs("div",{className:"table-header",children:[e.jsx("h1",{className:"table-header-title",children:n}),l?null:e.jsxs("div",{className:"table-header-right",children:[d,e.jsx(ue,{filters:v})]})]}),l?e.jsx(Q,{className:"table-loading"}):e.jsx(e.Fragment,{children:h?e.jsx(ae,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${u} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(ne,{entity:a,columns:c,onSortCallback:s,hasAction:!!i}),e.jsx("tbody",{children:e.jsx(de,{data:r,actions:i,columns:c,softDeleteProperty:p})})]})}),e.jsx(ce,{})]})})]})})}function pe(t){const{content:n,children:r}=t;return e.jsxs("div",{className:"tooltip-container",children:[r,e.jsx("div",{className:"tooltip-text",children:n})]})}var S=(t=>(t.empty="empty",t.outlined="outlined",t.default="default",t))(S||{});function me(t){const{label:n,onDelete:r,className:s="",spanClassName:a="",variant:l=S.default}=t,i=o.useMemo(()=>{switch(l){case S.empty:return"text-primary bg-transparent";case S.outlined:return"border border-primary";case S.default:default:return"text-white bg-primary"}},[l]),c=o.useMemo(()=>{switch(l){case S.empty:case S.outlined:return"chip-delete-button-svg";case S.default:default:return"filled-chip-delete-button-svg"}},[l]);return e.jsxs("div",{className:`chip-main ${i} ${s}`,children:[e.jsx("span",{className:a,children:n}),r?e.jsx("button",{type:"button",className:"chip-delete-button",onClick:r,children:e.jsx(_,{className:c})}):null]})}exports.AutocompleteInput=K;exports.CheckInput=G;exports.ChevronDown=W;exports.ChevronLeft=J;exports.ChevronRight=q;exports.ChevronUp=H;exports.Chip=me;exports.ChipVariant=S;exports.Close=_;exports.Columns=ne;exports.CountOfTotal=le;exports.Empty=ae;exports.FilterPopup=ue;exports.Filters=V;exports.FiltersActions=y;exports.FiltersProvider=se;exports.Footer=ce;exports.Loading=Q;exports.Navigation=re;exports.PageSize=oe;exports.Rows=de;exports.SelectInput=R;exports.State=z;exports.Table=ke;exports.TableOptionsProvider=ge;exports.TextInput=L;exports.Tooltip=pe;exports.TranslationProvider=xe;exports.filtersReducer=ee;exports.helperTextStateClassName=I;exports.initializer=Z;exports.inputStateClassName=D;exports.labelStateClassName=B;exports.renderFilterComponent=ie;exports.useFilters=P;exports.useTableOptions=$;exports.useTranslation=k;
package/dist/dashboard.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./main.css";
2
- import { jsx as t, jsxs as b, Fragment as M } from "react/jsx-runtime";
3
- import { forwardRef as j, useEffect as A, useState as P, useRef as H, useCallback as x, createContext as I, useContext as q, useReducer as ne, useMemo as C } from "react";
2
+ import { jsx as t, jsxs as b, Fragment as D } from "react/jsx-runtime";
3
+ import { forwardRef as j, useEffect as M, useState as P, useRef as W, useCallback as k, createContext as H, useContext as q, useReducer as ne, useMemo as C } from "react";
4
4
  function se(e) {
5
5
  const { className: s = "" } = e;
6
6
  return /* @__PURE__ */ t(
@@ -116,7 +116,7 @@ const J = j(function(e, s) {
116
116
  state: p = R.default,
117
117
  ...v
118
118
  } = e;
119
- return A(() => {
119
+ return M(() => {
120
120
  var f;
121
121
  (!a || a === "") && (r != null && r.length) && n({ target: { value: (f = r[0]) == null ? void 0 : f.id } });
122
122
  }, [n, r, a]), /* @__PURE__ */ b("div", { className: `select-input-container ${l}`, children: [
@@ -254,31 +254,31 @@ const ie = j(function(e, s) {
254
254
  placeholder: N = "",
255
255
  multiple: h = !1,
256
256
  ...p
257
- } = e, [v, f] = P(""), [y, w] = P(!1), $ = l.filter((g) => {
258
- const S = String(g.value).toLowerCase().includes(v == null ? void 0 : v.toLowerCase());
259
- return n && n.length ? n != null && n.some ? !(n != null && n.some((W) => W.id === g.id)) : (n == null ? void 0 : n.id) !== g.id : S;
260
- }), _ = H(null);
261
- A(() => {
262
- const g = (D) => {
263
- _.current && !_.current.contains(D.target) && w(!1);
264
- }, S = (D) => {
265
- D.key === "Escape" && w(!1);
257
+ } = e, [v, f] = P(""), [y, w] = P(!1), S = l.filter((g) => {
258
+ const x = String(g.value).toLowerCase().includes(v == null ? void 0 : v.toLowerCase());
259
+ return n && n.length ? n != null && n.some ? !(n != null && n.some((I) => I.id === g.id)) : (n == null ? void 0 : n.id) !== g.id : x;
260
+ }), A = W(null);
261
+ M(() => {
262
+ const g = (O) => {
263
+ A.current && !A.current.contains(O.target) && w(!1);
264
+ }, x = (O) => {
265
+ O.key === "Escape" && w(!1);
266
266
  };
267
- return document.addEventListener("click", g), document.addEventListener("keydown", S), () => {
268
- document.removeEventListener("click", g), document.removeEventListener("keydown", S);
267
+ return document.addEventListener("mousedown", g), document.addEventListener("keydown", x), () => {
268
+ document.removeEventListener("mousedown", g), document.removeEventListener("keydown", x);
269
269
  };
270
270
  }, []);
271
271
  const B = (g) => {
272
272
  f(g.target.value);
273
- }, G = x(
273
+ }, G = k(
274
274
  (g) => {
275
- f(""), r(g ? h ? n ? [...n, g] : [g] : g : null), w(!1);
275
+ f(""), g ? h ? Array.isArray(n) && n.length ? r([...n, g]) : r([g]) : r(g) : r(null), w(!1);
276
276
  },
277
277
  [h, r, n]
278
- ), te = x(
278
+ ), te = k(
279
279
  (g) => {
280
- const S = n.filter((D, W) => W !== g);
281
- S.length ? r(S) : r(null);
280
+ const x = n.filter((O, I) => I !== g);
281
+ x.length ? r(x) : r(null);
282
282
  },
283
283
  [r, n]
284
284
  );
@@ -286,7 +286,7 @@ const ie = j(function(e, s) {
286
286
  "div",
287
287
  {
288
288
  className: `autocomplete-input-container ${m}`,
289
- ref: _,
289
+ ref: A,
290
290
  children: [
291
291
  /* @__PURE__ */ t(
292
292
  U,
@@ -294,7 +294,7 @@ const ie = j(function(e, s) {
294
294
  state: a,
295
295
  name: c,
296
296
  id: o,
297
- value: !h && n ? n.value : v,
297
+ value: !h && n ? n : v,
298
298
  onChange: B,
299
299
  placeholder: N,
300
300
  helperText: u,
@@ -308,26 +308,32 @@ const ie = j(function(e, s) {
308
308
  {
309
309
  type: "button",
310
310
  className: "autocomplete-delete-button",
311
- onClick: () => G(),
311
+ onClick: (g) => {
312
+ G(), g.stopPropagation();
313
+ },
312
314
  children: /* @__PURE__ */ t(K, {})
313
315
  }
314
316
  )
315
317
  }
316
318
  ),
317
- y && /* @__PURE__ */ t("ul", { className: "autocomplete-suggestions-container", children: $.map((g) => /* @__PURE__ */ t(
319
+ y && /* @__PURE__ */ t("ul", { className: "autocomplete-suggestions-container", children: S.map((g) => /* @__PURE__ */ t(
318
320
  "li",
319
321
  {
320
322
  className: "autocomplete-suggestion-item hover:bg-primary/20",
321
- onClick: () => G(g),
323
+ onClick: (x) => {
324
+ G(g), x.stopPropagation();
325
+ },
322
326
  children: g.value
323
327
  },
324
328
  g.id
325
329
  )) }),
326
- h && Array.isArray(n) && n.length ? /* @__PURE__ */ t("ul", { className: "autocomplete-value-container", children: n.map((g, S) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
330
+ h && Array.isArray(n) && n.length ? /* @__PURE__ */ t("ul", { className: "autocomplete-value-container", children: n.map((g, x) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
327
331
  Te,
328
332
  {
329
333
  label: String(g.value),
330
- onDelete: () => te(S)
334
+ onDelete: (O) => {
335
+ te(x), O.stopPropagation();
336
+ }
331
337
  }
332
338
  ) }, g.value)) }) : null
333
339
  ]
@@ -354,37 +360,37 @@ function de(e) {
354
360
  }
355
361
  ) }) }) }) });
356
362
  }
357
- const Y = I({});
358
- function Me(e) {
363
+ const Y = H({});
364
+ function De(e) {
359
365
  const { children: s, t: a } = e;
360
366
  return /* @__PURE__ */ t(Y.Provider, { value: { t: a }, children: s });
361
367
  }
362
- const E = () => {
368
+ const L = () => {
363
369
  const e = q(Y);
364
370
  if (e === void 0)
365
371
  throw new Error("translationContext must be used within a Provider");
366
372
  return e;
367
373
  };
368
- var O = /* @__PURE__ */ ((e) => (e[e.text = 0] = "text", e[e.number = 1] = "number", e[e.select = 2] = "select", e[e.autocomplete = 3] = "autocomplete", e[e.date = 4] = "date", e[e.check = 5] = "check", e))(O || {}), T = /* @__PURE__ */ ((e) => (e.ASC = "ASC", e.DESC = "DESC", e))(T || {});
369
- const ue = [20, 50, 100], Z = I({}), Ae = (e) => {
370
- const { children: s } = e, [a, n] = P(0), [r, l] = P(20), [c, o] = P(0), [i, m] = P("id"), [d, u] = P(T.DESC), [N, h] = P({}), p = x(
374
+ var E = /* @__PURE__ */ ((e) => (e[e.text = 0] = "text", e[e.number = 1] = "number", e[e.select = 2] = "select", e[e.autocomplete = 3] = "autocomplete", e[e.date = 4] = "date", e[e.check = 5] = "check", e))(E || {}), _ = /* @__PURE__ */ ((e) => (e.ASC = "ASC", e.DESC = "DESC", e))(_ || {});
375
+ const ue = [20, 50, 100], Z = H({}), Me = (e) => {
376
+ const { children: s } = e, [a, n] = P(0), [r, l] = P(20), [c, o] = P(0), [i, m] = P("id"), [d, u] = P(_.DESC), [N, h] = P({}), p = k(
371
377
  (y, w) => {
372
- let $ = d;
378
+ let S = d;
373
379
  if (i === y)
374
380
  switch (d) {
375
- case T.ASC:
376
- $ = T.DESC;
381
+ case _.ASC:
382
+ S = _.DESC;
377
383
  break;
378
384
  default:
379
- $ = T.ASC;
385
+ S = _.ASC;
380
386
  break;
381
387
  }
382
- m(y), u($), w && w(y, $);
388
+ m(y), u(S), w && w(y, S);
383
389
  },
384
390
  [i, d]
385
- ), v = x((y) => {
391
+ ), v = k((y) => {
386
392
  const w = Object.entries(y).reduce(
387
- ($, [_, B]) => (B && typeof B.value < "u" && ($[_] = B.value), $),
393
+ (S, [A, B]) => (B && typeof B.value < "u" && (S[A] = B.value), S),
388
394
  {}
389
395
  );
390
396
  h(w);
@@ -405,13 +411,13 @@ const ue = [20, 50, 100], Z = I({}), Ae = (e) => {
405
411
  onFilterApply: v
406
412
  };
407
413
  return /* @__PURE__ */ t(Z.Provider, { value: f, children: s });
408
- }, L = () => {
414
+ }, F = () => {
409
415
  const e = q(Z);
410
416
  if (e === void 0)
411
417
  throw new Error("tableOptionsContext must be used within a Provider");
412
418
  return e;
413
419
  };
414
- var k = /* @__PURE__ */ ((e) => (e[e.update = 0] = "update", e[e.reset = 1] = "reset", e))(k || {});
420
+ var $ = /* @__PURE__ */ ((e) => (e[e.update = 0] = "update", e[e.reset = 1] = "reset", e))($ || {});
415
421
  const pe = (e) => {
416
422
  const s = {}, a = Object.keys(e);
417
423
  return a == null || a.forEach((n) => {
@@ -421,13 +427,13 @@ const pe = (e) => {
421
427
  function he(e, s) {
422
428
  const { type: a } = s;
423
429
  switch (a) {
424
- case k.reset: {
430
+ case $.reset: {
425
431
  const { filters: n } = s, r = {};
426
432
  return n == null || n.forEach(({ propertyName: l, defaultValue: c }) => {
427
433
  r[l] = { value: c };
428
434
  }), { ...e, ...r };
429
435
  }
430
- case k.update: {
436
+ case $.update: {
431
437
  const { toUpdate: n } = s;
432
438
  return { ...e, ...n };
433
439
  }
@@ -435,8 +441,8 @@ function he(e, s) {
435
441
  return e;
436
442
  }
437
443
  }
438
- const ee = I({}), me = (e) => {
439
- const { children: s } = e, { filters: a } = L(), [n, r] = ne(
444
+ const ee = H({}), me = (e) => {
445
+ const { children: s } = e, { filters: a } = F(), [n, r] = ne(
440
446
  he,
441
447
  pe(a)
442
448
  ), l = {
@@ -444,14 +450,14 @@ const ee = I({}), me = (e) => {
444
450
  setCurrentFilters: r
445
451
  };
446
452
  return /* @__PURE__ */ t(ee.Provider, { value: l, children: s });
447
- }, F = () => {
453
+ }, T = () => {
448
454
  const e = q(ee);
449
455
  if (e === void 0)
450
456
  throw new Error("tableOptionsContext must be used within a Provider");
451
457
  return e;
452
458
  };
453
459
  function be(e) {
454
- const { t: s } = E(), { entity: a = "", columns: n = [], hasAction: r = !0, onSortCallback: l } = e, { onSort: c, sortingOrder: o, sortingBy: i } = L(), m = C(() => {
460
+ const { t: s } = L(), { entity: a = "", columns: n = [], hasAction: r = !0, onSortCallback: l } = e, { onSort: c, sortingOrder: o, sortingBy: i } = F(), m = C(() => {
455
461
  var d;
456
462
  return (d = n.sort((u, N) => (N.pos ?? 0) - (u.pos ?? 0)).filter((u) => u.display !== "none")) == null ? void 0 : d.map((u) => ({
457
463
  id: u.key,
@@ -481,7 +487,7 @@ function be(e) {
481
487
  "span",
482
488
  {
483
489
  className: `${i === d.id ? "table-headers-sort-on" : "table-headers-sort"}`,
484
- children: o === T.ASC ? ((N = (u = d.sortOptions) == null ? void 0 : u.icons) == null ? void 0 : N.asc) ?? /* @__PURE__ */ t(
490
+ children: o === _.ASC ? ((N = (u = d.sortOptions) == null ? void 0 : u.icons) == null ? void 0 : N.asc) ?? /* @__PURE__ */ t(
485
491
  re,
486
492
  {
487
493
  className: ((p = (h = d.sortOptions) == null ? void 0 : h.icons) == null ? void 0 : p.className) ?? "table-headers-sort-indicator"
@@ -505,11 +511,11 @@ function be(e) {
505
511
  ] }) });
506
512
  }
507
513
  function ge() {
508
- const { t: e } = E();
514
+ const { t: e } = L();
509
515
  return /* @__PURE__ */ t("div", { className: "table-empty", children: /* @__PURE__ */ t("p", { children: e("_accessibility:components.table.empty") }) });
510
516
  }
511
517
  const ve = () => {
512
- const { t: e } = E(), { total: s, pageSize: a, currentPage: n, setCurrentPage: r } = L();
518
+ const { t: e } = L(), { total: s, pageSize: a, currentPage: n, setCurrentPage: r } = F();
513
519
  return /* @__PURE__ */ b("div", { className: "table-navigation-pages", children: [
514
520
  /* @__PURE__ */ t(
515
521
  "button",
@@ -535,9 +541,9 @@ const ve = () => {
535
541
  )
536
542
  ] });
537
543
  }, Ne = () => {
538
- const { t: e } = E(), { total: s, pageSize: a, pageSizes: n, currentPage: r } = L(), l = (r + 1) * a > s ? s : (r + 1) * a;
544
+ const { t: e } = L(), { total: s, pageSize: a, pageSizes: n, currentPage: r } = F(), l = (r + 1) * a > s ? s : (r + 1) * a;
539
545
  return /* @__PURE__ */ b("div", { className: "table-navigation-sizes", children: [
540
- n[0] < s && /* @__PURE__ */ t(M, { children: /* @__PURE__ */ b("p", { children: [
546
+ n[0] < s && /* @__PURE__ */ t(D, { children: /* @__PURE__ */ b("p", { children: [
541
547
  r * a + 1,
542
548
  " - ",
543
549
  l,
@@ -548,7 +554,7 @@ const ve = () => {
548
554
  ] });
549
555
  };
550
556
  function fe() {
551
- const { t: e } = E(), { pageSizes: s, pageSize: a, setPageSize: n } = L(), r = C(
557
+ const { t: e } = L(), { pageSizes: s, pageSize: a, setPageSize: n } = F(), r = C(
552
558
  () => s == null ? void 0 : s.map((l) => ({ id: l, value: l })),
553
559
  [s]
554
560
  );
@@ -568,7 +574,7 @@ function fe() {
568
574
  ] });
569
575
  }
570
576
  function Ce() {
571
- const { t: e } = E(), { total: s, pageSize: a, currentPage: n, setCurrentPage: r } = L(), l = C(() => {
577
+ const { t: e } = L(), { total: s, pageSize: a, currentPage: n, setCurrentPage: r } = F(), l = C(() => {
572
578
  const c = Math.ceil(s / a);
573
579
  return Array.from({ length: c }, (o, i) => ({
574
580
  id: i,
@@ -599,12 +605,12 @@ function ye() {
599
605
  ] });
600
606
  }
601
607
  function we(e) {
602
- const { propertyName: s, options: a, label: n } = e, { currentFilters: r, setCurrentFilters: l } = F(), c = C(() => {
608
+ const { propertyName: s, options: a, label: n } = e, { currentFilters: r, setCurrentFilters: l } = T(), c = C(() => {
603
609
  var i;
604
610
  return ((i = r[s]) == null ? void 0 : i.value) ?? a[0];
605
- }, [r]), o = x((i) => {
611
+ }, [r]), o = k((i) => {
606
612
  l({
607
- type: k.update,
613
+ type: $.update,
608
614
  toUpdate: { [s]: { value: i.target.value } }
609
615
  });
610
616
  }, []);
@@ -621,12 +627,12 @@ function we(e) {
621
627
  );
622
628
  }
623
629
  const xe = (e) => {
624
- const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = F(), l = C(() => {
630
+ const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = T(), l = C(() => {
625
631
  var o;
626
632
  return ((o = n[s]) == null ? void 0 : o.value) ?? "";
627
- }, [n]), c = x((o) => {
633
+ }, [n]), c = k((o) => {
628
634
  r({
629
- type: k.update,
635
+ type: $.update,
630
636
  toUpdate: { [s]: { value: o.target.value } }
631
637
  });
632
638
  }, []);
@@ -641,13 +647,13 @@ const xe = (e) => {
641
647
  }
642
648
  );
643
649
  }, ke = (e) => {
644
- const { propertyName: s, label: a, min: n, max: r } = e, { currentFilters: l, setCurrentFilters: c } = F(), o = C(() => {
650
+ const { propertyName: s, label: a, min: n, max: r } = e, { currentFilters: l, setCurrentFilters: c } = T(), o = C(() => {
645
651
  var m;
646
652
  return ((m = l[s]) == null ? void 0 : m.value) ?? "";
647
- }, [l]), i = x(
653
+ }, [l]), i = k(
648
654
  (m) => {
649
655
  c({
650
- type: k.update,
656
+ type: $.update,
651
657
  toUpdate: {
652
658
  [s]: { value: m.target.value }
653
659
  }
@@ -669,22 +675,22 @@ const xe = (e) => {
669
675
  }
670
676
  );
671
677
  }, $e = (e) => {
672
- const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = F(), l = C(() => {
678
+ const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = T(), l = C(() => {
673
679
  var o;
674
680
  return ((o = n[s]) == null ? void 0 : o.value) ?? "";
675
- }, [n]), c = x((o) => {
681
+ }, [n]), c = k((o) => {
676
682
  r({
677
- type: k.update,
683
+ type: $.update,
678
684
  toUpdate: { [s]: { value: o.target.checked } }
679
685
  });
680
686
  }, []);
681
687
  return /* @__PURE__ */ t(ce, { label: a, checked: l ?? !1, onChange: c });
682
688
  };
683
689
  function Se(e) {
684
- const { propertyName: s, label: a, options: n, multiple: r = !0 } = e, { currentFilters: l, setCurrentFilters: c } = F(), o = C(() => l[s] ?? n[0], [l]), i = x(
690
+ const { propertyName: s, label: a, options: n, multiple: r = !0 } = e, { currentFilters: l, setCurrentFilters: c } = T(), o = C(() => l[s] ?? n[0], [l]), i = k(
685
691
  (m) => {
686
692
  c({
687
- type: k.update,
693
+ type: $.update,
688
694
  toUpdate: {
689
695
  [s]: {
690
696
  value: m
@@ -708,12 +714,12 @@ function Se(e) {
708
714
  );
709
715
  }
710
716
  const Pe = (e) => {
711
- const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = F(), l = C(() => {
717
+ const { propertyName: s, label: a } = e, { currentFilters: n, setCurrentFilters: r } = T(), l = C(() => {
712
718
  var o, i;
713
719
  return (o = n[s]) != null && o.value ? new Date(String((i = n[s]) == null ? void 0 : i.value)).toISOString().slice(0, 10) : "";
714
- }, [n]), c = x((o) => {
720
+ }, [n]), c = k((o) => {
715
721
  r({
716
- type: k.update,
722
+ type: $.update,
717
723
  toUpdate: { [s]: { value: o.target.value } }
718
724
  });
719
725
  }, []);
@@ -730,30 +736,30 @@ const Pe = (e) => {
730
736
  );
731
737
  }, ze = (e) => {
732
738
  switch (e.type) {
733
- case O.text:
739
+ case E.text:
734
740
  return /* @__PURE__ */ t(xe, { ...e });
735
- case O.number:
741
+ case E.number:
736
742
  return /* @__PURE__ */ t(ke, { ...e });
737
- case O.select:
743
+ case E.select:
738
744
  return /* @__PURE__ */ t(we, { ...e });
739
- case O.autocomplete:
745
+ case E.autocomplete:
740
746
  return /* @__PURE__ */ t(Se, { ...e });
741
- case O.date:
747
+ case E.date:
742
748
  return /* @__PURE__ */ t(Pe, { ...e });
743
- case O.check:
749
+ case E.check:
744
750
  return /* @__PURE__ */ t($e, { ...e });
745
751
  }
746
- return /* @__PURE__ */ t(M, {});
752
+ return /* @__PURE__ */ t(D, {});
747
753
  };
748
754
  const Oe = (e) => {
749
- const { align: s = "right", filters: a = [], icon: n } = e, [r, l] = P(!1), { onFilterApply: c, filters: o } = L(), { currentFilters: i, setCurrentFilters: m } = F(), { t: d } = E(), u = H(null), N = H(null);
750
- return A(() => {
755
+ const { align: s = "right", filters: a = [], icon: n } = e, [r, l] = P(!1), { onFilterApply: c, filters: o } = F(), { currentFilters: i, setCurrentFilters: m } = T(), { t: d } = L(), u = W(null), N = W(null);
756
+ return M(() => {
751
757
  const h = ({ target: p }) => {
752
758
  var v, f;
753
759
  N.current && (!r || (v = N.current) != null && v.contains(p) || (f = u == null ? void 0 : u.current) != null && f.contains(p) || l(!1));
754
760
  };
755
761
  return document.addEventListener("click", h), () => document.removeEventListener("click", h);
756
- }), A(() => {
762
+ }), M(() => {
757
763
  const h = (p) => {
758
764
  !r || p.code !== "Escape" || l(!1);
759
765
  };
@@ -785,7 +791,7 @@ const Oe = (e) => {
785
791
  /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
786
792
  "button",
787
793
  {
788
- onClick: () => m({ type: k.reset }),
794
+ onClick: () => m({ type: $.reset, filters: a }),
789
795
  className: "filter-dropdown-button small filter-dropdown-cancel",
790
796
  children: d("_accessibility:buttons.clear")
791
797
  }
@@ -844,7 +850,7 @@ function je(e) {
844
850
  columns: o = [],
845
851
  contentClassName: i = "",
846
852
  className: m = "",
847
- toolbar: d = /* @__PURE__ */ t(M, {}),
853
+ toolbar: d = /* @__PURE__ */ t(D, {}),
848
854
  softDeleteProperty: u = "deleted"
849
855
  } = e, N = C(() => o ? o.sort((p, v) => (v.pos ?? 0) - (p.pos ?? 0)).filter((p) => !!p.filterOptions).map((p) => {
850
856
  var v;
@@ -862,7 +868,7 @@ function je(e) {
862
868
  /* @__PURE__ */ t(Oe, { filters: N })
863
869
  ] })
864
870
  ] }),
865
- l ? /* @__PURE__ */ t(de, { className: "table-loading" }) : /* @__PURE__ */ t(M, { children: h ? /* @__PURE__ */ t(ge, {}) : /* @__PURE__ */ b(M, { children: [
871
+ l ? /* @__PURE__ */ t(de, { className: "table-loading" }) : /* @__PURE__ */ t(D, { children: h ? /* @__PURE__ */ t(ge, {}) : /* @__PURE__ */ b(D, { children: [
866
872
  /* @__PURE__ */ t("div", { className: `${i} table-body`, children: /* @__PURE__ */ b("table", { className: "table-content", children: [
867
873
  /* @__PURE__ */ t(
868
874
  be,
@@ -942,7 +948,7 @@ export {
942
948
  ge as Empty,
943
949
  Oe as FilterPopup,
944
950
  oe as Filters,
945
- k as FiltersActions,
951
+ $ as FiltersActions,
946
952
  me as FiltersProvider,
947
953
  ye as Footer,
948
954
  de as Loading,
@@ -952,17 +958,17 @@ export {
952
958
  J as SelectInput,
953
959
  R as State,
954
960
  je as Table,
955
- Ae as TableOptionsProvider,
961
+ Me as TableOptionsProvider,
956
962
  U as TextInput,
957
963
  Fe as Tooltip,
958
- Me as TranslationProvider,
964
+ De as TranslationProvider,
959
965
  he as filtersReducer,
960
966
  X as helperTextStateClassName,
961
967
  pe as initializer,
962
968
  Q as inputStateClassName,
963
969
  V as labelStateClassName,
964
970
  ze as renderFilterComponent,
965
- F as useFilters,
966
- L as useTableOptions,
967
- E as useTranslation
971
+ T as useFilters,
972
+ F as useTableOptions,
973
+ L as useTranslation
968
974
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sito/dashboard",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.0.32",
5
5
  "type": "module",
6
6
  "description": "UI library with custom components for dashboards",
7
7
  "main": "dist/dashboard.cjs",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "author": "sito8943",
39
39
  "license": "ISC",
40
- "dependencies": {
40
+ "peerDependencies": {
41
41
  "react": "^18.3.1"
42
42
  },
43
43
  "devDependencies": {