@sito/dashboard 0.0.43 → 0.0.44

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,12 +1,6 @@
1
- import { MouseEventHandler } from 'react';
2
- export declare enum ChipVariant {
3
- empty = "empty",
4
- outlined = "outlined",
5
- default = "default"
6
- }
1
+ import { MouseEventHandler, ReactNode } from 'react';
7
2
  export type ChipPropsType = {
8
- variant?: ChipVariant;
9
- label?: string;
3
+ label?: string | ReactNode;
10
4
  onDelete?: MouseEventHandler<HTMLElement>;
11
5
  className?: string;
12
6
  spanClassName?: string;
@@ -1,7 +1,16 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { FilterType } from '../../../../lib';
3
3
  export type FilterPopupPropsType = {
4
- align?: "right" | "left";
5
- icon?: ReactNode | string;
6
4
  filters?: FilterType[];
5
+ options?: FilterOptions;
6
+ };
7
+ export type FilterOptions = {
8
+ button: {
9
+ icon?: ReactNode | string;
10
+ hide?: boolean;
11
+ };
12
+ dropdown?: {
13
+ opened: boolean;
14
+ setOpened: (value: boolean) => void;
15
+ };
7
16
  };
@@ -0,0 +1,3 @@
1
+ import { BaseDto } from '../../../../lib';
2
+ import { TableHeaderPropsType } from './types';
3
+ export declare const TableHeader: <TRow extends BaseDto>(props: TableHeaderPropsType<TRow>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './TableHeader';
2
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { ColumnType } from '../types';
3
+ import { BaseDto } from '../../../../lib';
4
+ import { FilterOptions } from '../FilterPopup';
5
+ export type TableHeaderPropsType<TRow extends BaseDto> = {
6
+ title?: string;
7
+ isLoading?: boolean;
8
+ toolbar?: ReactNode;
9
+ columns?: ColumnType<TRow>[];
10
+ filterOptions?: FilterOptions;
11
+ };
@@ -2,5 +2,6 @@ export * from './Columns';
2
2
  export * from './Empty';
3
3
  export * from './Footer';
4
4
  export * from './FilterPopup';
5
+ export * from './TableHeader';
5
6
  export * from './Rows';
6
7
  export * from './types';
@@ -1,6 +1,5 @@
1
- import { ReactNode } from 'react';
2
1
  import { BaseDto, SortOrder } from '../../lib';
3
- import { ColumnType } from './components';
2
+ import { TableHeaderPropsType } from './components';
4
3
  export type Action<TRow extends BaseDto> = {
5
4
  id: string;
6
5
  onClick: (entity: TRow) => void;
@@ -9,16 +8,12 @@ export type Action<TRow extends BaseDto> = {
9
8
  disabled?: boolean;
10
9
  hidden?: boolean;
11
10
  };
12
- export type TablePropsType<TRow extends BaseDto> = {
11
+ export interface TablePropsType<TRow extends BaseDto> extends TableHeaderPropsType<TRow> {
13
12
  entity: string;
14
- title?: string;
15
13
  data: TRow[];
16
- isLoading?: boolean;
17
14
  actions?: (row: TRow) => Action<TRow>[];
18
- columns?: ColumnType<TRow>[];
19
15
  contentClassName?: string;
20
16
  className?: string;
21
17
  softDeleteProperty?: keyof TRow;
22
- toolbar?: ReactNode;
23
18
  onSort?: (prop: string, sortOrder: SortOrder) => void;
24
- };
19
+ }
@@ -1 +1 @@
1
- var ke=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 q(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 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:"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 V(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 G=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 A(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 L=(t=>(t.error="error",t.good="good",t.default="default",t))(L||{});const B=t=>{switch(t){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},D=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:c="",labelClassName:u="",helperText:i="",helperTextClassName:g="",placeholder:d="",label:p="",name:b="",id:x="",state:h=L.default,children:v,...j}=t;return e.jsxs("div",{className:`select-input-container ${l}`,children:[e.jsx("select",{...j,id:x,ref:n,name:b,value:r,onChange:s,className:`select-input ${B(h)} peer ${c}`,children:a==null?void 0:a.map(C=>e.jsx("option",{value:C.id,children:C.value??C.name??C.id},C.id))}),e.jsx("label",{htmlFor:b,className:`select-input-label ${D(h)} ${u}`,children:p}),v,e.jsx("p",{className:`select-input-helper-text ${I(h)} ${g}`,children:h!=="error"&&h!=="good"?d:i})]})});const M=o.forwardRef(function(t,n){const{children:r,state:s=L.default,label:a="",containerClassName:l="",inputClassName:c="",labelClassName:u="",helperText:i="",helperTextClassName:g="",value:d="",...p}=t;return e.jsxs("div",{className:`text-input-container ${l}`,children:[e.jsx("input",{ref:n,value:d,className:`text-input ${B(s)} peer ${c} ${d?"has-value":""} ${p.placeholder?"has-placeholder":""}`,...p}),!!a&&e.jsxs("label",{htmlFor:p.name,className:`text-input-label ${D(s)} ${u}`,children:[a,p.required?" *":""]}),r,!!i&&e.jsx("p",{className:`text-input-helper-text ${I(s)} ${g}`,children:i})]})});const K=o.forwardRef(function(t,n){const{checked:r,onChange:s,state:a=L.default,name:l="",id:c="",type:u="text",label:i="",containerClassName:g="",inputClassName:d="",labelClassName:p="",helperText:b="",helperTextClassName:x="",...h}=t;return e.jsxs("label",{className:`input-check-container ${g}`,children:[e.jsx("input",{id:c,ref:n,name:l,type:"checkbox",checked:r,onChange:s,className:`input-check ${d}`,...h}),e.jsx("span",{className:`input-check-label ${p}`,children:i})]})});const Q=o.forwardRef(function(t,n){const{state:r,value:s,onChange:a,options:l=[],name:c="",id:u="",label:i="",containerClassName:g="",inputContainerClassName:d="",helperText:p="",placeholder:b="",multiple:x=!1,...h}=t,[v,j]=o.useState(""),[C,f]=o.useState(!1),w=l.filter(m=>{const N=String(m.value).toLowerCase().includes(v==null?void 0:v.toLowerCase());return s&&s.length?s!=null&&s.some?!(s!=null&&s.some(_=>_.id===m.id)):(s==null?void 0:s.id)!==m.id:N}),E=o.useRef(null);o.useEffect(()=>{const m=T=>{E.current&&!E.current.contains(T.target)&&f(!1)},N=T=>{T.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",N)}},[]);const z=m=>{j(m.target.value)},U=o.useCallback(m=>{j(""),m?x?Array.isArray(s)&&s.length?a([...s,m]):a([m]):a(m):a(null),f(!1)},[x,a,s]),xe=o.useCallback(m=>{const N=s.filter((T,_)=>_!==m);N.length?a(N):a(null)},[a,s]);return e.jsxs("div",{className:`autocomplete-input-container ${g}`,ref:E,children:[e.jsx(M,{state:r,name:c,id:u,value:!x&&s?s.value??s.name:v,onChange:z,placeholder:b,helperText:p,onFocus:()=>f(!0),label:i,containerClassName:`autocomplete-text-input ${d}`,ref:n,...h,children:!x&&s&&e.jsx("button",{type:"button",className:"autocomplete-delete-button",onClick:m=>{U(),m.stopPropagation()},children:e.jsx(A,{})})}),C&&e.jsx("ul",{className:"autocomplete-suggestions-container",children:w.map(m=>e.jsx("li",{className:"autocomplete-suggestion-item hover:bg-primary/20",onClick:N=>{U(m),N.stopPropagation()},children:m.value??m.name},m.id??m.value??m.name))}),x&&Array.isArray(s)&&s.length?e.jsx("ul",{className:"autocomplete-value-container",children:s.map((m,N)=>e.jsx("li",{children:e.jsx(me,{label:String(m.value??m.name),onDelete:T=>{xe(N),T.stopPropagation()}})},m.id??m.value??m.name))}):null]})});function X(t){const{color:n="stroke-blue-800",className:r="",loaderClass:s="",strokeWidth:a="4",...l}=t;return e.jsx("div",{...l,className:`loading ${r}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${s}`,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:a,strokeMiterlimit:"10"})})})})})}const Y=o.createContext({});function be(t){const{children:n,t:r}=t;return e.jsx(Y.Provider,{value:{t:r},children:n})}const k=()=>{const t=o.useContext(Y);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};var $=(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.ASC="ASC",t.DESC="DESC",t))(F||{});const ve=[20,50,100],Z=o.createContext({}),ge=t=>{const{children:n}=t,[r,s]=o.useState(0),[a,l]=o.useState(20),[c,u]=o.useState(0),[i,g]=o.useState("id"),[d,p]=o.useState(F.DESC),[b,x]=o.useState({}),h=o.useCallback((C,f)=>{let w=d;if(i===C)switch(d){case F.ASC:w=F.DESC;break;default:w=F.ASC;break}g(C),p(w),f&&f(C,w)},[i,d]),v=o.useCallback(C=>{const f=Object.entries(C).reduce((w,[E,z])=>(z&&typeof z.value<"u"&&(w[E]=z.value),w),{});x(f)},[]),j={onSort:h,total:r,setTotal:s,sortingBy:i,setSortingBy:g,sortingOrder:d,setSortingOrder:p,pageSize:a,pageSizes:ve,setPageSize:l,currentPage:c,setCurrentPage:u,filters:b,onFilterApply:v};return e.jsx(Z.Provider,{value:j,children:n})},P=()=>{const t=o.useContext(Z);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 ee=t=>{if(t){const n={},r=Object.keys(t);return r==null||r.forEach(s=>{n[s]={value:t[s]}}),n}return{}};function te(t,n){const{type:r}=n;switch(r){case y.reset:{const{filters:s}=n,a={};return s==null||s.forEach(({propertyName:l,defaultValue:c})=>{a[l]={value:c}}),{...t,...a}}case y.update:{const{toUpdate:s}=n;return{...t,...s}}default:return t}}const se=o.createContext({}),ne=t=>{const{children:n}=t,{filters:r}=P(),[s,a]=o.useReducer(te,ee(r)),l={currentFilters:s,setCurrentFilters:a};return e.jsx(se.Provider,{value:l,children:n})},O=()=>{const t=o.useContext(se);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};function ae(t){const{t:n}=k(),{entity:r="",columns:s=[],hasAction:a=!0,onSortCallback:l}=t,{onSort:c,sortingOrder:u,sortingBy:i}=P(),g=o.useMemo(()=>{var d;return(d=s.sort((p,b)=>(b.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:[g.map(d=>{var p,b,x,h,v,j,C,f;return e.jsx("th",{scope:"col",className:`table-headers-column ${d.className}`,children:e.jsxs("button",{disabled:!d.sortable,onClick:()=>c(d.id,l),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:d.label}),d.sortable&&e.jsx("span",{className:`${i===d.id?"table-headers-sort-on":"table-headers-sort"}`,children:u===F.ASC?((b=(p=d.sortOptions)==null?void 0:p.icons)==null?void 0:b.asc)??e.jsx(q,{className:((h=(x=d.sortOptions)==null?void 0:x.icons)==null?void 0:h.className)??"table-headers-sort-indicator"}):((j=(v=d.sortOptions)==null?void 0:v.icons)==null?void 0:j.desc)??e.jsx(W,{className:((f=(C=d.sortOptions)==null?void 0:C.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 re(){const{t}=k();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}const le=()=>{const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=P();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(V,{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(J,{className:"w-2.5"})})]})},oe=()=>{const{t}=k(),{total:n,pageSize:r,pageSizes:s,currentPage:a}=P(),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 ce(){const{t}=k(),{pageSizes:n,pageSize:r,setPageSize:s}=P(),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(Number(l.target.value))})]})}function je(){const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=P(),l=o.useMemo(()=>{const c=Math.ceil(n/r);return Array.from({length:c},(u,i)=>({id:i,value:i+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:c=>a(Number(c.target.value))})]})}function ie(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(je,{}),e.jsx(ce,{}),e.jsx(oe,{}),e.jsx(le,{})]})}function Ce(t){const{propertyName:n,options:r,label:s}=t,{currentFilters:a,setCurrentFilters:l}=O(),c=o.useMemo(()=>{var i;return((i=a[n])==null?void 0:i.value)??r[0]},[a]),u=o.useCallback(i=>{l({type:y.update,toUpdate:{[n]:{value:i.target.value}}})},[]);return e.jsx(R,{value:c,label:s,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u})}const fe=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=O(),l=o.useMemo(()=>{var u;return((u=s[n])==null?void 0:u.value)??""},[s]),c=o.useCallback(u=>{a({type:y.update,toUpdate:{[n]:{value:u.target.value}}})},[]);return e.jsx(M,{value:l??"",label:r,onChange:c,containerClassName:"input-widget-container",helperTextClassName:""})},Ne=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=O(),l=o.useMemo(()=>{var u;return((u=s[n])==null?void 0:u.value)??""},[s]),c=o.useCallback(u=>{a({type:y.update,toUpdate:{[n]:{value:u.target.checked}}})},[]);return e.jsx(K,{label:r,checked:l??!1,onChange:c})};function ye(t){const{propertyName:n,label:r,options:s,multiple:a=!0}=t,{currentFilters:l,setCurrentFilters:c}=O(),u=o.useMemo(()=>l[n]??s[0],[l]),i=o.useCallback(g=>{c({type:y.update,toUpdate:{[n]:{value:g}}})},[a]);return e.jsx(Q,{value:u==null?void 0:u.value,label:r,options:s,multiple:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:i})}const H=t=>{var p,b,x,h;const{propertyName:n,label:r,inputType:s}=t,{t:a}=k(),{currentFilters:l,setCurrentFilters:c}=O(),u=o.useRef(null),i=o.useRef(null),g=o.useCallback(v=>{var j;c({type:y.update,toUpdate:{[n]:{value:{end:((j=i==null?void 0:i.current)==null?void 0:j.value)??null,start:v.target.value}}}})},[]),d=o.useCallback(v=>{var j;c({type:y.update,toUpdate:{[n]:{value:{start:((j=u==null?void 0:u.current)==null?void 0:j.value)??null,end:v.target.value}}}})},[]);return e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:r}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(M,{value:((b=(p=l[n])==null?void 0:p.value)==null?void 0:b.start)??"",placeholder:a("_accessibility:components.table.filters.range.start"),type:s,ref:u,onChange:g,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(M,{value:((h=(x=l[n])==null?void 0:x.value)==null?void 0:h.end)??"",placeholder:a("_accessibility:components.table.filters.range.end"),type:s,ref:i,onChange:d,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},ue=t=>{switch(t.type){case $.text:return e.jsx(fe,{...t});case $.number:return e.jsx(H,{...t,inputType:"number"});case $.date:return e.jsx(H,{...t,inputType:"date"});case $.select:return e.jsx(Ce,{...t});case $.autocomplete:return e.jsx(ye,{...t});case $.check:return e.jsx(Ne,{...t})}return e.jsx(e.Fragment,{})};const de=t=>{const{align:n="right",filters:r=[],icon:s}=t,[a,l]=o.useState(!1),{onFilterApply:c,filters:u}=P(),{currentFilters:i,setCurrentFilters:g}=O(),{t:d}=k(),p=o.useRef(null),b=o.useRef(null);return o.useEffect(()=>{const x=({target:h})=>{var v,j;b.current&&(!a||(v=b.current)!=null&&v.contains(h)||(j=p==null?void 0:p.current)!=null&&j.contains(h)||l(!1))};return document.addEventListener("click",x),()=>document.removeEventListener("click",x)}),o.useEffect(()=>{const x=h=>{!a||h.code!=="Escape"||l(!1)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)}),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(G,{className:"filter-dropdown-trigger-icon"})]}),e.jsx("div",{className:`filter-dropdown-transition ${a?"opened":"closed"} ${n==="right"?"right":"left"}`,children:e.jsxs("div",{ref:b,children:[e.jsx("div",{className:"filter-title",children:d("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:r.map(x=>e.jsx("li",{className:"filter-container-item",children:ue(x)},x.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>g({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),c(i)},onBlur:()=>l(!1),children:d("_accessibility:buttons.applyFilters")})})]})})]})})]})},we=t=>t,pe=t=>{const{columns:n,softDeleteProperty:r="deleted",data:s,actions:a}=t,l=o.useMemo(()=>n.sort((c,u)=>(u.pos??0)-(c.pos??0)).filter(c=>c.display!=="none"),[n]);return s==null?void 0:s.map(c=>{var u;return e.jsxs("tr",{className:`table-row ${c[r]?"deleted-class":""}`,children:[l==null?void 0:l.map((i,g)=>e.jsx("td",{className:`table-row-cell ${g===0?"basic":""} ${i.className??""}`,children:i.renderBody?i.renderBody(c[i.key],c):we(c[i.key])},i.key)),a?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(u=a(c).filter(i=>!i.hidden))==null?void 0:u.map(i=>e.jsx(he,{content:i.tooltip,children:e.jsx("button",{onClick:()=>i.onClick(c),children:i.icon})},i.id))})}):null]},c.id)})};function Se(t){const{title:n="",data:r,onSort:s,entity:a="",isLoading:l=!1,actions:c,columns:u=[],contentClassName:i="",className:g="",toolbar:d=e.jsx(e.Fragment,{}),softDeleteProperty:p="deleted"}=t,b=o.useMemo(()=>u?u.sort((h,v)=>(v.pos??0)-(h.pos??0)).filter(h=>!!h.filterOptions).map(h=>{var v;return{...h.filterOptions,label:((v=h.filterOptions)==null?void 0:v.label)??h.label,propertyName:h.key}}):[],[u]),x=o.useMemo(()=>!(r!=null&&r.length),[r]);return e.jsx(ne,{children:e.jsxs("div",{className:`${g} 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,!!b&&!!b.length&&e.jsx(de,{filters:b})]})]}),l?e.jsx(X,{className:"table-loading"}):e.jsx(e.Fragment,{children:x?e.jsx(re,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(ae,{entity:a,columns:u,onSortCallback:s,hasAction:!!c}),e.jsx("tbody",{children:e.jsx(pe,{data:r,actions:c,columns:u,softDeleteProperty:p})})]})}),e.jsx(ie,{})]})})]})})}function he(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,c=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]),u=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 ${c} ${s}`,children:[e.jsx("span",{className:a,children:n}),r?e.jsx("button",{type:"button",className:"chip-delete-button",onClick:r,children:e.jsx(A,{className:u})}):null]})}exports.AutocompleteInput=Q;exports.CheckInput=K;exports.ChevronDown=W;exports.ChevronLeft=V;exports.ChevronRight=J;exports.ChevronUp=q;exports.Chip=me;exports.ChipVariant=S;exports.Close=A;exports.Columns=ae;exports.CountOfTotal=oe;exports.Empty=re;exports.FilterPopup=de;exports.FilterTypes=$;exports.Filters=G;exports.FiltersActions=y;exports.FiltersProvider=ne;exports.Footer=ie;exports.Loading=X;exports.Navigation=le;exports.PageSize=ce;exports.Rows=pe;exports.SelectInput=R;exports.SortOrder=F;exports.State=L;exports.Table=Se;exports.TableOptionsProvider=ge;exports.TextInput=M;exports.Tooltip=he;exports.TranslationProvider=be;exports.filtersReducer=te;exports.helperTextStateClassName=I;exports.initializer=ee;exports.inputStateClassName=B;exports.labelStateClassName=D;exports.renderFilterComponent=ue;exports.useFilters=O;exports.useTableOptions=P;exports.useTranslation=k;
1
+ var Se=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react");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 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 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 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 L=(t=>(t.error="error",t.good="good",t.default="default",t))(L||{});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"}},D=t=>{switch(t){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}};const M=i.forwardRef(function(t,n){const{value:a,onChange:s,options:r,containerClassName:o="",inputClassName:c="",labelClassName:u="",helperText:l="",helperTextClassName:m="",placeholder:p="",label:h="",name:v="",id:C="",state:j=L.default,children:g,...d}=t;return e.jsxs("div",{className:`select-input-container ${o}`,children:[e.jsx("select",{...d,id:C,ref:n,name:v,value:a,onChange:s,className:`select-input ${A(j)} peer ${c}`,children:r==null?void 0:r.map(x=>e.jsx("option",{value:x.id,children:x.value??x.name??x.id},x.id))}),e.jsx("label",{htmlFor:v,className:`select-input-label ${B(j)} ${u}`,children:h}),g,e.jsx("p",{className:`select-input-helper-text ${D(j)} ${m}`,children:j!=="error"&&j!=="good"?p:l})]})});const z=i.forwardRef(function(t,n){const{children:a,state:s=L.default,label:r="",containerClassName:o="",inputClassName:c="",labelClassName:u="",helperText:l="",helperTextClassName:m="",value:p="",...h}=t;return e.jsxs("div",{className:`text-input-container ${o}`,children:[e.jsx("input",{ref:n,value:p,className:`text-input ${A(s)} peer ${c} ${p?"has-value":""} ${h.placeholder?"has-placeholder":""}`,...h}),!!r&&e.jsxs("label",{htmlFor:h.name,className:`text-input-label ${B(s)} ${u}`,children:[r,h.required?" *":""]}),a,!!l&&e.jsx("p",{className:`text-input-helper-text ${D(s)} ${m}`,children:l})]})});const G=i.forwardRef(function(t,n){const{checked:a,onChange:s,state:r=L.default,name:o="",id:c="",type:u="text",label:l="",containerClassName:m="",inputClassName:p="",labelClassName:h="",helperText:v="",helperTextClassName:C="",...j}=t;return e.jsxs("label",{className:`input-check-container ${m}`,children:[e.jsx("input",{id:c,ref:n,name:o,type:"checkbox",checked:a,onChange:s,className:`input-check ${p}`,...j}),e.jsx("span",{className:`input-check-label ${h}`,children:l})]})});const K=i.forwardRef(function(t,n){const{state:a,value:s,onChange:r,options:o=[],name:c="",id:u="",label:l="",containerClassName:m="",inputContainerClassName:p="",helperText:h="",placeholder:v="",multiple:C=!1,...j}=t,[g,d]=i.useState(""),[x,N]=i.useState(!1),f=o.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(R=>R.id===b.id)):(s==null?void 0:s.id)!==b.id:w}),F=i.useRef(null);i.useEffect(()=>{const b=P=>{F.current&&!F.current.contains(P.target)&&N(!1)},w=P=>{P.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[]);const E=b=>{d(b.target.value)},I=i.useCallback(b=>{d(""),b?C?Array.isArray(s)&&s.length?r([...s,b]):r([b]):r(b):r(null),N(!1)},[C,r,s]),xe=i.useCallback(b=>{const w=s.filter((P,R)=>R!==b);w.length?r(w):r(null)},[r,s]);return e.jsxs("div",{className:`autocomplete-input-container ${m}`,ref:F,children:[e.jsx(z,{state:a,name:c,id:u,value:!C&&s?s.value??s.name:g,onChange:E,placeholder:v,helperText:h,onFocus:()=>N(!0),label:l,containerClassName:`autocomplete-text-input ${p}`,ref:n,...j,children:!C&&s&&e.jsx("button",{type:"button",className:"autocomplete-delete-button",onClick:b=>{I(),b.stopPropagation()},children:e.jsx(_,{})})}),x&&e.jsx("ul",{className:"autocomplete-suggestions-container",children:f.map(b=>e.jsx("li",{className:"autocomplete-suggestion-item",onClick:w=>{I(b),w.stopPropagation()},children:b.value??b.name},b.id??b.value??b.name))}),C&&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??b.name),onDelete:P=>{xe(w),P.stopPropagation()}})},b.id??b.value??b.name))}):null]})});function Q(t){const{color:n="stroke-blue-800",className:a="",loaderClass:s="",strokeWidth:r="4",...o}=t;return e.jsx("div",{...o,className:`loading ${a}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${s}`,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:r,strokeMiterlimit:"10"})})})})})}const X=i.createContext({});function be(t){const{children:n,t:a}=t;return e.jsx(X.Provider,{value:{t:a},children:n})}const k=()=>{const t=i.useContext(X);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};var S=(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))(S||{}),T=(t=>(t.ASC="ASC",t.DESC="DESC",t))(T||{});const je=[20,50,100],Y=i.createContext({}),Ce=t=>{const{children:n}=t,[a,s]=i.useState(0),[r,o]=i.useState(20),[c,u]=i.useState(0),[l,m]=i.useState("id"),[p,h]=i.useState(T.DESC),[v,C]=i.useState({}),j=i.useCallback((x,N)=>{let f=p;if(l===x)switch(p){case T.ASC:f=T.DESC;break;default:f=T.ASC;break}m(x),h(f),N&&N(x,f)},[l,p]),g=i.useCallback(x=>{const N=Object.entries(x).reduce((f,[F,E])=>(E&&typeof E.value<"u"&&(f[F]=E.value),f),{});C(N)},[]),d={onSort:j,total:a,setTotal:s,sortingBy:l,setSortingBy:m,sortingOrder:p,setSortingOrder:h,pageSize:r,pageSizes:je,setPageSize:o,currentPage:c,setCurrentPage:u,filters:v,onFilterApply:g};return e.jsx(Y.Provider,{value:d,children:n})},$=()=>{const t=i.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=>{if(t){const n={},a=Object.keys(t);return a==null||a.forEach(s=>{n[s]={value:t[s]}}),n}return{}};function ee(t,n){const{type:a}=n;switch(a){case y.reset:{const{filters:s}=n,r={};return s==null||s.forEach(({propertyName:o,defaultValue:c})=>{r[o]={value:c}}),{...t,...r}}case y.update:{const{toUpdate:s}=n;return{...t,...s}}default:return t}}const te=i.createContext({}),se=t=>{const{children:n}=t,{filters:a}=$(),[s,r]=i.useReducer(ee,Z(a)),o={currentFilters:s,setCurrentFilters:r};return e.jsx(te.Provider,{value:o,children:n})},O=()=>{const t=i.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:a="",columns:s=[],hasAction:r=!0,onSortCallback:o}=t,{onSort:c,sortingOrder:u,sortingBy:l}=$(),m=i.useMemo(()=>{var p;return(p=s.sort((h,v)=>(v.pos??0)-(h.pos??0)).filter(h=>h.display!=="none"))==null?void 0:p.map(h=>({id:h.key,label:h.label,className:h.className??"",sortable:h.sortable??!0,sortOptions:h.sortOptions}))},[s,a,n]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[m.map(p=>{var h,v,C,j,g,d,x,N;return e.jsx("th",{scope:"col",className:`table-headers-column ${p.className}`,children:e.jsxs("button",{disabled:!p.sortable,onClick:()=>c(p.id,o),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:p.label}),p.sortable&&e.jsx("span",{className:`${l===p.id?"table-headers-sort-on":"table-headers-sort"}`,children:u===T.ASC?((v=(h=p.sortOptions)==null?void 0:h.icons)==null?void 0:v.asc)??e.jsx(W,{className:((j=(C=p.sortOptions)==null?void 0:C.icons)==null?void 0:j.className)??"table-headers-sort-indicator"}):((d=(g=p.sortOptions)==null?void 0:g.icons)==null?void 0:d.desc)??e.jsx(H,{className:((N=(x=p.sortOptions)==null?void 0:x.icons)==null?void 0:N.className)??"table-headers-sort-indicator"})})]})},p.id)}),r&&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:a,currentPage:s,setCurrentPage:r}=$();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:()=>r(s-1),children:e.jsx(J,{className:"w-2.5"})}),e.jsx("button",{disabled:Math.floor(n/((s+1)*a))===0,className:"table-navigation-buttons",name:t("_accessibility:buttons.next"),"aria-label":t("_accessibility:buttons.next"),onClick:()=>r(s+1),children:e.jsx(q,{className:"w-2.5"})})]})},le=()=>{const{t}=k(),{total:n,pageSize:a,pageSizes:s,currentPage:r}=$(),o=(r+1)*a>n?n:(r+1)*a;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<n&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[r*a+1," - ",o," ",t("_accessibility:components.table.of")]})}),e.jsx("p",{children:n})]})};function oe(){const{t}=k(),{pageSizes:n,pageSize:a,setPageSize:s}=$(),r=i.useMemo(()=>n==null?void 0:n.map(o=>({id:o,value:o})),[n]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(M,{value:a,options:r,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:o=>s(Number(o.target.value))})]})}function ve(){const{t}=k(),{total:n,pageSize:a,currentPage:s,setCurrentPage:r}=$(),o=i.useMemo(()=>{const c=Math.ceil(n/a);return Array.from({length:c},(u,l)=>({id:l,value:l+1}))},[n,a]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:t("_accessibility:components.table.jumpToPage")}),e.jsx(M,{value:s,options:o,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:c=>r(Number(c.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 ge(t){const{propertyName:n,options:a,label:s}=t,{currentFilters:r,setCurrentFilters:o}=O(),c=i.useMemo(()=>{var l;return((l=r[n])==null?void 0:l.value)??a[0]},[r]),u=i.useCallback(l=>{o({type:y.update,toUpdate:{[n]:{value:l.target.value}}})},[]);return e.jsx(M,{value:c,label:s,options:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u})}const Ne=t=>{const{propertyName:n,label:a}=t,{currentFilters:s,setCurrentFilters:r}=O(),o=i.useMemo(()=>{var u;return((u=s[n])==null?void 0:u.value)??""},[s]),c=i.useCallback(u=>{r({type:y.update,toUpdate:{[n]:{value:u.target.value}}})},[]);return e.jsx(z,{value:o??"",label:a,onChange:c,containerClassName:"input-widget-container",helperTextClassName:""})},fe=t=>{const{propertyName:n,label:a}=t,{currentFilters:s,setCurrentFilters:r}=O(),o=i.useMemo(()=>{var u;return((u=s[n])==null?void 0:u.value)??""},[s]),c=i.useCallback(u=>{r({type:y.update,toUpdate:{[n]:{value:u.target.checked}}})},[]);return e.jsx(G,{label:a,checked:o??!1,onChange:c})};function we(t){const{propertyName:n,label:a,options:s,multiple:r=!0}=t,{currentFilters:o,setCurrentFilters:c}=O(),u=i.useMemo(()=>o[n]??s[0],[o]),l=i.useCallback(m=>{c({type:y.update,toUpdate:{[n]:{value:m}}})},[r]);return e.jsx(K,{value:u==null?void 0:u.value,label:a,options:s,multiple:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:l})}const U=t=>{var h,v,C,j;const{propertyName:n,label:a,inputType:s}=t,{t:r}=k(),{currentFilters:o,setCurrentFilters:c}=O(),u=i.useRef(null),l=i.useRef(null),m=i.useCallback(g=>{var d;c({type:y.update,toUpdate:{[n]:{value:{end:((d=l==null?void 0:l.current)==null?void 0:d.value)??null,start:g.target.value}}}})},[]),p=i.useCallback(g=>{var d;c({type:y.update,toUpdate:{[n]:{value:{start:((d=u==null?void 0:u.current)==null?void 0:d.value)??null,end:g.target.value}}}})},[]);return e.jsxs("div",{className:"range-widget-container",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:a}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(z,{value:((v=(h=o[n])==null?void 0:h.value)==null?void 0:v.start)??"",placeholder:r("_accessibility:components.table.filters.range.start"),type:s,ref:u,onChange:m,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(z,{value:((j=(C=o[n])==null?void 0:C.value)==null?void 0:j.end)??"",placeholder:r("_accessibility:components.table.filters.range.end"),type:s,ref:l,onChange:p,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},ie=t=>{switch(t.type){case S.text:return e.jsx(Ne,{...t});case S.number:return e.jsx(U,{...t,inputType:"number"});case S.date:return e.jsx(U,{...t,inputType:"date"});case S.select:return e.jsx(ge,{...t});case S.autocomplete:return e.jsx(we,{...t});case S.check:return e.jsx(fe,{...t})}return e.jsx(e.Fragment,{})};const ue=t=>{var v,C,j,g;const{filters:n=[],options:a}=t,[s,r]=i.useState(!1),{onFilterApply:o,filters:c}=$(),{currentFilters:u,setCurrentFilters:l}=O(),{t:m}=k(),p=i.useRef(null),h=i.useRef(null);return i.useEffect(()=>{const d=({target:x})=>{var N,f;h.current&&(!s||(N=h.current)!=null&&N.contains(x)||(f=p==null?void 0:p.current)!=null&&f.contains(x)||r(!1))};return document.addEventListener("click",d),()=>document.removeEventListener("click",d)}),i.useEffect(()=>{const d=x=>{!s||x.code!=="Escape"||r(!1)};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)}),e.jsxs("div",{className:"filter-dropdown-main",children:[((v=a==null?void 0:a.button)==null?void 0:v.hide)!==!0&&e.jsxs("button",{ref:p,className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>{var d,x,N;return((N=(d=a==null?void 0:a.dropdown)==null?void 0:d.setOpened)==null?void 0:N.call(d,!((x=a==null?void 0:a.dropdown)!=null&&x.opened)))??r(!s)},"aria-expanded":((C=a==null?void 0:a.dropdown)==null?void 0:C.opened)??s,children:[e.jsx("span",{className:"sr-only",children:m("_accessibility:buttons.filters")}),e.jsx("wbr",{}),((j=a==null?void 0:a.button)==null?void 0:j.icon)??e.jsx(V,{className:"filter-dropdown-trigger-icon"})]}),e.jsx("div",{className:`filter-dropdown-backdrop ${(g=a==null?void 0:a.dropdown)!=null&&g.opened||s?"opened":"closed"}`,children:e.jsxs("div",{className:"filter-popup",children:[e.jsx("div",{className:"filter-title",children:m("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:n.map(d=>e.jsx("li",{className:"filter-container-item",children:ie(d)},d.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>l({type:y.reset,filters:n}),className:"filter-dropdown-button small filter-dropdown-cancel",children:m("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit",onClick:()=>{var d,x;((x=(d=a==null?void 0:a.dropdown)==null?void 0:d.setOpened)==null?void 0:x.call(d,!1))??r(!1),o(u)},onBlur:()=>{var d,x;return((x=(d=a==null?void 0:a.dropdown)==null?void 0:d.setOpened)==null?void 0:x.call(d,!1))??r(!1)},children:m("_accessibility:buttons.applyFilters")})})]})})]})})]})},de=t=>{var u;const{columns:n,title:a,isLoading:s,toolbar:r,filterOptions:o}=t,c=i.useMemo(()=>n?n.sort((l,m)=>(m.pos??0)-(l.pos??0)).filter(l=>!!l.filterOptions).map(l=>{var m;return{...l.filterOptions,label:((m=l.filterOptions)==null?void 0:m.label)??l.label,propertyName:l.key}}):[],[n]);return e.jsxs("div",{className:`table-header ${a&&(r||!((u=o==null?void 0:o.button)!=null&&u.hide))?"two":"one"}`,children:[a&&e.jsx("h1",{className:"table-header-title",children:a}),s?null:e.jsxs("div",{className:"table-header-right",children:[r,!!c&&!!c.length&&e.jsx(ue,{filters:c,options:o})]})]})},ye=t=>t,pe=t=>{const{columns:n,softDeleteProperty:a="deleted",data:s,actions:r}=t,o=i.useMemo(()=>n.sort((c,u)=>(u.pos??0)-(c.pos??0)).filter(c=>c.display!=="none"),[n]);return s==null?void 0:s.map(c=>{var u;return e.jsxs("tr",{className:`table-row ${c[a]?"deleted-class":""}`,children:[o==null?void 0:o.map((l,m)=>e.jsx("td",{className:`table-row-cell ${m===0?"basic":""} ${l.className??""}`,children:l.renderBody?l.renderBody(c[l.key],c):ye(c[l.key])},l.key)),r?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(u=r(c).filter(l=>!l.hidden))==null?void 0:u.map(l=>e.jsx(he,{content:l.tooltip,children:e.jsx("button",{onClick:()=>l.onClick(c),children:l.icon})},l.id))})}):null]},c.id)})};function ke(t){const{data:n,onSort:a,entity:s="",isLoading:r=!1,actions:o,columns:c=[],contentClassName:u="",className:l="",softDeleteProperty:m="deleted",...p}=t,h=i.useMemo(()=>!(n!=null&&n.length),[n]);return e.jsx(se,{children:e.jsxs("div",{className:`${l} table-main`,children:[e.jsx(de,{columns:c,isLoading:r,...p}),r?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:s,columns:c,onSortCallback:a,hasAction:!!o}),e.jsx("tbody",{children:e.jsx(pe,{data:n,actions:o,columns:c,softDeleteProperty:m})})]})}),e.jsx(ce,{})]})})]})})}function he(t){const{content:n,children:a}=t;return e.jsxs("div",{className:"tooltip-container",children:[a,e.jsx("div",{className:"tooltip-text",children:n})]})}function me(t){const{label:n,onDelete:a,className:s="",spanClassName:r=""}=t;return e.jsxs("div",{className:`chip-main ${s}`,children:[e.jsx("span",{className:r,children:n}),a?e.jsx("button",{type:"button",className:"chip-delete-button",onClick:a,children:e.jsx(_,{})}):null]})}exports.AutocompleteInput=K;exports.CheckInput=G;exports.ChevronDown=H;exports.ChevronLeft=J;exports.ChevronRight=q;exports.ChevronUp=W;exports.Chip=me;exports.Close=_;exports.Columns=ne;exports.CountOfTotal=le;exports.Empty=ae;exports.FilterPopup=ue;exports.FilterTypes=S;exports.Filters=V;exports.FiltersActions=y;exports.FiltersProvider=se;exports.Footer=ce;exports.Loading=Q;exports.Navigation=re;exports.PageSize=oe;exports.Rows=pe;exports.SelectInput=M;exports.SortOrder=T;exports.State=L;exports.Table=ke;exports.TableHeader=de;exports.TableOptionsProvider=Ce;exports.TextInput=z;exports.Tooltip=he;exports.TranslationProvider=be;exports.filtersReducer=ee;exports.helperTextStateClassName=D;exports.initializer=Z;exports.inputStateClassName=A;exports.labelStateClassName=B;exports.renderFilterComponent=ie;exports.useFilters=O;exports.useTableOptions=$;exports.useTranslation=k;