@sito/dashboard 0.0.66 → 0.0.67

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.
Files changed (42) hide show
  1. package/README.md +3 -2
  2. package/dist/{Chip-JDQqzO9I.js → Chip-C5ogKbFn.js} +4 -4
  3. package/dist/{Chip-a2z-338_.cjs → Chip-D17UJHW6.cjs} +1 -1
  4. package/dist/Chip.cjs +1 -1
  5. package/dist/Chip.js +1 -1
  6. package/dist/{FileInput-5tMOO7mb.cjs → FileInput-Ch-GCxrS.cjs} +1 -1
  7. package/dist/{FileInput-B--eBQVa.js → FileInput-DCR_Pyqe.js} +1 -1
  8. package/dist/{Filters-BivtNVS3.js → Filters-DL5jd8ps.js} +30 -16
  9. package/dist/{Filters-C5XEbF3V.cjs → Filters-Dyee8QYH.cjs} +1 -1
  10. package/dist/Form.cjs +1 -1
  11. package/dist/Form.js +2 -2
  12. package/dist/SvgIcons.cjs +1 -1
  13. package/dist/SvgIcons.js +7 -6
  14. package/dist/Table-BtZGG0d7.js +1056 -0
  15. package/dist/Table-DjIhOMXQ.cjs +1 -0
  16. package/dist/Table.cjs +1 -1
  17. package/dist/Table.css +1 -1
  18. package/dist/Table.js +1 -1
  19. package/dist/{TextInput-BLfTozZ9.js → TextInput-BqW5YX-3.js} +1 -1
  20. package/dist/{TextInput-Bn8zsDnU.cjs → TextInput-CY1fh4mf.cjs} +1 -1
  21. package/dist/components/Actions/Action.d.ts +18 -0
  22. package/dist/components/Actions/Actions.d.ts +14 -0
  23. package/dist/components/Actions/Actions.stories.d.ts +20 -0
  24. package/dist/components/Actions/Actions.test.d.ts +1 -0
  25. package/dist/components/Actions/ActionsDropdown.d.ts +10 -0
  26. package/dist/components/Actions/ActionsDropdown.stories.d.ts +17 -0
  27. package/dist/components/Actions/ActionsDropdown.test.d.ts +1 -0
  28. package/dist/components/Actions/index.d.ts +4 -0
  29. package/dist/components/Actions/types.d.ts +17 -0
  30. package/dist/components/Form/TextInput/TextInput.stories.d.ts +1 -0
  31. package/dist/components/SvgIcons/Ellipsis.d.ts +7 -0
  32. package/dist/components/SvgIcons/index.d.ts +1 -0
  33. package/dist/components/Table/Table.stories.d.ts +1 -0
  34. package/dist/components/Table/types.d.ts +1 -0
  35. package/dist/components/index.d.ts +1 -0
  36. package/dist/index.cjs +1 -1
  37. package/dist/index.css +1 -1
  38. package/dist/index.js +69 -65
  39. package/dist/setupTests.d.ts +0 -0
  40. package/package.json +5 -2
  41. package/dist/Table-CH9HYQ2I.js +0 -946
  42. package/dist/Table-CWss4TW5.cjs +0 -1
@@ -1 +0,0 @@
1
- var Re=require("./Table.css");const e=require("react/jsx-runtime"),a=require("react"),T=require("./FiltersProvider-CYqLFEI9.cjs"),pe=require("./Badge-Z78MlGoQ.cjs"),V=require("./Filters-C5XEbF3V.cjs"),B=require("./lib.cjs"),F=require("./TranslationProvider-51Pc9Xrr.cjs"),_=require("./TextInput-Bn8zsDnU.cjs"),P=require("./TableOptionsProvider-BchUDA3B.cjs"),J=require("./Chip-a2z-338_.cjs"),U=require("./IconButton-CVnmT2E9.cjs"),G=require("./Tooltip-BSKAgRkc.cjs"),me=require("./query-81BrXp3i.cjs"),he=require("./Button-BlYa3uPc.cjs"),be=require("./Loading-CNECRan-.cjs");function K(n){return[...n].sort((t,i)=>(i.pos??0)-(t.pos??0)).filter(t=>t.display!=="none")}function Q(n){const{t}=F.useTranslation(),{entity:i="",columns:s=[],hasAction:l=!0,onSortCallback:r,selectionState:h,onToggleAllRows:o}=n,p=a.useRef(null);a.useEffect(()=>{p.current&&(p.current.indeterminate=!!(h?.hasSomeSelected&&!h?.allSelected))},[h]);const{onSort:c,sortingOrder:m,sortingBy:b}=P.useTableOptions(),x=a.useMemo(()=>K(s).map(u=>({id:u.key,label:u.label,className:u.className??"",sortable:u.sortable??!0,sortOptions:u.sortOptions})),[s,i,t]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:o?e.jsx("input",{type:"checkbox",ref:p,checked:h?.allSelected??!1,onChange:o,"aria-label":t("_accessibility:components.table.selectAllRows")}):null}),x.map(u=>e.jsx("th",{scope:"col",className:`table-headers-column ${u.className}`,children:e.jsxs(he.Button,{disabled:!u.sortable,onClick:()=>c(u.id,r),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:u.label}),u.sortable&&b===u.id&&e.jsx("span",{children:m===me.SortOrder.ASC?u.sortOptions?.icons?.asc??e.jsx(V.ChevronUp,{className:u.sortOptions?.icons?.className??"table-headers-sort-indicator"}):u.sortOptions?.icons?.desc??e.jsx(V.ChevronDown,{className:u.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},u.id)),l&&e.jsx("th",{scope:"col",className:"table-headers-action",children:e.jsx("span",{className:"button text default disabled",children:t("_accessibility:labels.actions")})})]})})}const Y=n=>{const{items:t,text:i,id:s,onClearFilter:l}=n;return e.jsx(J.Chip,{text:`${i}: ${t.map(r=>r.value??r.name).join(", ")}`,onDelete:()=>l(s)})},Z=n=>{const{end:t,start:i,text:s,id:l,onClearFilter:r}=n;return e.jsx(J.Chip,{text:`${s}: ${i||"♾️"} - ${t||"♾️"}`,onDelete:()=>r(l)})},ee=n=>{const{filtersDefinition:t}=n,i=a.useMemo(()=>{const o={};return t.forEach(p=>{o[p.propertyName]=p.label??p.propertyName}),o},[t]),{filters:s,clearFilters:l}=P.useTableOptions(),r=a.useMemo(()=>Object.keys(s),[s]),h=a.useCallback(o=>s[o]?.end||s[o]?.start?e.jsx(Z,{id:o,text:i[o],start:s[o].start,end:s[o].end,onClearFilter:l}):Array.isArray(s[o])?e.jsx(Y,{id:o,text:i[o],items:s[o],onClearFilter:l}):e.jsx(J.Chip,{text:`${i[o]}: ${s[o]?.value??s[o]?.name??s[o]}`,onDelete:()=>l(o)}),[s,i]);return e.jsx("ul",{className:"active-filters-main",children:r?.map(o=>e.jsx("li",{children:h(o)},o))})};function xe(n){const{propertyName:t,label:i,placeholder:s,options:l,multiple:r=!0}=n,{currentFilters:h,setCurrentFilters:o}=T.useFilters(),p=a.useMemo(()=>h[t]??l[0],[h]),c=a.useCallback(m=>{o({type:T.FiltersActions.update,toUpdate:{[t]:{value:m}}})},[r]);return e.jsx(_.AutocompleteInput,{value:p?.value,label:i,options:l,multiple:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:c,placeholder:s})}const fe=n=>{const{propertyName:t,label:i}=n,{currentFilters:s,setCurrentFilters:l}=T.useFilters(),r=a.useMemo(()=>s[t]?.value??"",[s]),h=a.useCallback(o=>{l({type:T.FiltersActions.update,toUpdate:{[t]:{value:o.target.checked}}})},[]);return e.jsx(_.CheckInput,{label:i,checked:r??!1,onChange:h})};function ge(n){const{propertyName:t,options:i,label:s,placeholder:l}=n,{currentFilters:r,setCurrentFilters:h}=T.useFilters(),o=a.useMemo(()=>r[t]?.value??i[0],[r]),p=a.useCallback(c=>{h({type:T.FiltersActions.update,toUpdate:{[t]:{value:c.target.value}}})},[]);return e.jsx(_.SelectInput,{value:o,label:s,options:i,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:p,placeholder:l})}const je=n=>{const{propertyName:t,label:i,placeholder:s}=n,{currentFilters:l,setCurrentFilters:r}=T.useFilters(),h=a.useMemo(()=>l[t]?.value??"",[l]),o=a.useCallback(p=>{r({type:T.FiltersActions.update,toUpdate:{[t]:{value:p.target.value}}})},[]);return e.jsx(_.TextInput,{value:h??"",label:i,onChange:o,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:s})},X=n=>{const{propertyName:t,label:i,inputType:s}=n,{t:l}=F.useTranslation(),{currentFilters:r,setCurrentFilters:h}=T.useFilters(),o=a.useRef(null),p=a.useRef(null),c=a.useCallback(b=>{h({type:T.FiltersActions.update,toUpdate:{[t]:{value:{end:p?.current?.value??null,start:b.target.value}}}})},[]),m=a.useCallback(b=>{h({type:T.FiltersActions.update,toUpdate:{[t]:{value:{start:o?.current?.value??null,end:b.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:i}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(_.TextInput,{value:r[t]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:s,ref:o,onChange:c,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(_.TextInput,{value:r[t]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:s,ref:p,onChange:m,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},te=n=>{switch(n.type){case B.FilterTypes.text:return e.jsx(je,{...n});case B.FilterTypes.number:return e.jsx(X,{...n,inputType:"number"});case B.FilterTypes.date:return e.jsx(X,{...n,inputType:"date"});case B.FilterTypes.select:return e.jsx(ge,{...n});case B.FilterTypes.autocomplete:return e.jsx(xe,{...n});case B.FilterTypes.check:return e.jsx(fe,{...n})}return e.jsx(e.Fragment,{})},ne=n=>{const{filters:t=[],show:i,handleShow:s}=n,{onFilterApply:l}=P.useTableOptions(),{currentFilters:r,setCurrentFilters:h}=T.useFilters(),{t:o}=F.useTranslation(),p=a.useRef(null);return a.useEffect(()=>{const c=({target:b})=>{p.current&&(b?.closest(".filter-dropdown-trigger")||!i||p.current.contains(b)||s(!1))},m=({code:b})=>{!i||b!=="Escape"||s(!1)};return document.addEventListener("click",c),document.addEventListener("keydown",m),()=>{document.removeEventListener("click",c),document.removeEventListener("keydown",m)}},[s,i]),e.jsx("div",{className:`filter-dropdown-backdrop ${i?"opened":"closed"}`,children:e.jsxs("div",{className:"filter-popup",ref:p,children:[e.jsx("div",{className:"filter-title",children:o("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:t.map(c=>e.jsx("li",{className:"filter-container-item",children:te(c)},c.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>h({type:T.FiltersActions.reset,filters:t}),className:"filter-dropdown-button small filter-dropdown-cancel",children:o("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit",onClick:()=>{s(!1),l(r)},children:o("_accessibility:buttons.applyFilters")})})]})})]})})},se=()=>{const{t:n}=F.useTranslation(),{total:t,pageSize:i,pageSizes:s,currentPage:l}=P.useTableOptions(),r=(l+1)*i>t?t:(l+1)*i;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*i+1," - ",r," ",n("_accessibility:components.table.of")]})}),e.jsx("p",{children:t})]})};function Ce(){const{t:n}=F.useTranslation(),{total:t,pageSize:i,currentPage:s,setCurrentPage:l}=P.useTableOptions(),r=a.useMemo(()=>{const h=Math.ceil(t/i);return Array.from({length:h},(o,p)=>({id:p,value:p+1}))},[t,i]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:n("_accessibility:components.table.jumpToPage")}),e.jsx(_.SelectInput,{value:s,options:r,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:h=>l(Number(h.target.value))})]})}const le=()=>{const{t:n}=F.useTranslation(),{total:t,pageSize:i,currentPage:s,setCurrentPage:l}=P.useTableOptions();return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(U.IconButton,{icon:e.jsx(V.ChevronLeft,{className:"table-navigation-icon"}),className:"table-navigation-buttons",disabled:s===0,"aria-label":n("_accessibility:buttons.previous"),name:n("_accessibility:buttons.previous"),onClick:()=>l(s-1)}),e.jsx(U.IconButton,{icon:e.jsx(V.ChevronRight,{className:"table-navigation-icon"}),disabled:Math.floor(t/((s+1)*i))===0,className:"table-navigation-buttons",name:n("_accessibility:buttons.next"),"aria-label":n("_accessibility:buttons.next"),onClick:()=>l(s+1)})]})};function re(){const{t:n}=F.useTranslation(),{pageSizes:t,pageSize:i,setPageSize:s}=P.useTableOptions(),l=a.useMemo(()=>t?.map(r=>({id:r,value:r})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:n("_accessibility:components.table.pageSizes")}),e.jsx(_.SelectInput,{value:i,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:r=>s(Number(r.target.value))})]})}function ae(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(Ce,{}),e.jsx(re,{}),e.jsx(se,{}),e.jsx(le,{})]})}const Ne=n=>n,ie=n=>{const{t}=F.useTranslation(),{columns:i,softDeleteProperty:s="deletedAt",data:l,actions:r,selectedRows:h,expandedRows:o=[],onRowSelectionChange:p,onRowExpand:c}=n,m=a.useMemo(()=>K(i),[i]),b=a.useMemo(()=>new Map(o.map(x=>[x.rowId,x])),[o]);return l?.map(x=>{const u=h.has(x.id),N=b.get(x.id),S=!!N,$=m.length+1+(r?1:0);return e.jsxs(a.Fragment,{children:[e.jsxs("tr",{className:`table-row ${c?"expandable":""} ${x[s]?"deleted-class":""} ${u?"selected":""} ${S?"expanded":""}`,onClick:()=>c?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:u,onClick:g=>g.stopPropagation(),onChange:()=>p(x),"aria-label":t("_accessibility:components.table.selectRow")})}),m?.map((g,M)=>e.jsx("td",{className:`table-row-cell ${M===0?"basic":""} ${g.className??""}`,children:g.renderBody?g.renderBody(x[g.key],x):Ne(x[g.key])},g.key)),r?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:r(x).filter(g=>!g.hidden)?.map(g=>e.jsx(G.Tooltip,{content:g.tooltip,children:e.jsx(U.IconButton,{icon:g.icon,className:"row-table-action",onClick:M=>{M.stopPropagation(),g.onClick(x)}})},g.id))})}):null]}),S&&N?.content!==null&&typeof N?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:$,children:e.jsx("div",{className:`table-row-expanded-content ${N.isVisible?"open":"closed"}`,children:e.jsx("div",{className:"table-row-expanded-inner",children:N.content})})})})]},x.id)})};function oe(){const{t:n}=F.useTranslation();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:n("_accessibility:components.table.empty")})})}const ce=n=>{const{columns:t,title:i,isLoading:s,toolbar:l,filterOptions:r}=n,{countOfFilters:h}=P.useTableOptions(),{t:o}=F.useTranslation(),p=a.useMemo(()=>t?t.sort((u,N)=>(N.pos??0)-(u.pos??0)).filter(u=>!!u.filterOptions).map(u=>({...u.filterOptions,label:u.filterOptions?.label??u.label,propertyName:u.key})):[],[t]),[c,m]=a.useState(!1),b=a.useCallback(u=>{r?.dropdown?.setOpened?r.dropdown.setOpened(u??!1):m(u??!1)},[r]),x=a.useMemo(()=>r?.dropdown?.opened??c,[r,c]);return e.jsxs("div",{className:`table-header ${x?"showing-filters":""}`,children:[e.jsxs("div",{children:[i&&e.jsx("h1",{className:"table-header-title",children:i}),s?null:e.jsxs("div",{className:"table-header-content",children:[l,r?.button?.hide!==!0&&e.jsxs(U.IconButton,{icon:r?.button?.icon??e.jsx(V.Filters,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>b(!x),"aria-expanded":x,children:[e.jsx(pe.Badge,{count:h,className:`${h>0?"show":"hide"} `}),e.jsx("span",{className:"table-header-sr",children:o("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),!!p&&!!p.length&&e.jsx(ne,{filters:p,show:x,handleShow:b,options:r}),e.jsx(ee,{filtersDefinition:p})]})};function ue({count:n,multiActions:t,onActionClick:i}){const{t:s}=F.useTranslation();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:s("_accessibility:components.table.selectedCount",{count:n})}),t.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:t.map(l=>e.jsx(G.Tooltip,{content:l.tooltip,children:e.jsx(U.IconButton,{icon:l.icon,className:"multi-table-action",onClick:()=>i(l),disabled:l.disabled})},l.id))})]})}const H=220;function ve({data:n,allowMultipleExpandedRows:t,controlledExpandedRowId:i,onExpandedRowChange:s,onRowExpand:l,findRowById:r}){const[h,o]=a.useState(null),[p,c]=a.useState(null),[m,b]=a.useState(null),[x,u]=a.useState(null),[N,S]=a.useState(!1),[$,g]=a.useState(new Set),[M,O]=a.useState([]),E=a.useRef(null),k=a.useRef(null),I=a.useRef(new Map),w=typeof i<"u",R=t&&!w,C=w?i??null:h,z=a.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null)},[]),y=a.useCallback(d=>{if(typeof d<"u"){const f=I.current.get(d);if(!f)return;clearTimeout(f),I.current.delete(d);return}I.current.forEach(f=>clearTimeout(f)),I.current.clear()},[]),D=a.useCallback(d=>{y(d),O(f=>f.some(v=>v.rowId===d)?f.map(v=>v.rowId===d?{...v,isVisible:!1}:v):f),I.current.set(d,setTimeout(()=>{O(f=>f.filter(j=>j.rowId!==d)),I.current.delete(d)},H))},[y]),W=a.useCallback((d,f)=>{y(d),O(j=>j.some(A=>A.rowId===d)?j.map(A=>A.rowId===d?{...A,content:f,isVisible:!1}:A):[...j,{rowId:d,content:f,isVisible:!1}]),requestAnimationFrame(()=>{O(j=>j.map(v=>v.rowId===d?{...v,isVisible:!0}:v))})},[y]);a.useEffect(()=>{if(!R)return;const d=new Set(n.map(f=>f.id));g(f=>{const j=new Set;return f.forEach(v=>{if(d.has(v)){j.add(v);return}y(v)}),j}),O(f=>(f.forEach(j=>{d.has(j.rowId)||y(j.rowId)}),f.filter(j=>d.has(j.rowId))))},[n,R,y]),a.useEffect(()=>{if(R)return;if(C===null){c(null),w&&(E.current=null);return}r(C)||(w||o(null),c(null),w&&(E.current=null))},[n,C,r,w,R]),a.useEffect(()=>{if(!R){if(z(),C===null||p===null){if(m===null){S(!1),u(null);return}S(!1),k.current=setTimeout(()=>{b(null),u(null),k.current=null},H);return}if(m===null){b(C),u(p),requestAnimationFrame(()=>S(!0));return}if(m===C){u(p),requestAnimationFrame(()=>S(!0));return}S(!1),k.current=setTimeout(()=>{b(C),u(p),requestAnimationFrame(()=>S(!0)),k.current=null},H)}},[z,p,C,R,m]),a.useEffect(()=>()=>{z(),y()},[z,y]),a.useEffect(()=>{if(!w)return;if(C===null){c(null),E.current=null;return}const d=r(C);if(!d){c(null),E.current=null;return}const f=E.current;c(l?.(d,f)??null),E.current=d},[C,r,w,l]);const de=a.useCallback(d=>{if(R){if($.has(d.id)){g(L=>{const q=new Set(L);return q.delete(d.id),q}),D(d.id),s?.(null,d);return}g(L=>{const q=new Set(L);return q.add(d.id),q});const A=l?.(d,null)??null;A!==null&&typeof A<"u"?W(d.id,A):(y(d.id),O(L=>L.filter(q=>q.rowId!==d.id))),s?.(d,null);return}const f=C===d.id,j=f?d:r(C);if(w){s?.(f?null:d,j);return}if(f){o(null),c(null),s?.(null,d);return}o(d.id),c(l?.(d,j)??null),s?.(d,j)},[C,D,y,W,r,$,w,R,s,l]);return{expandedRowsToRender:a.useMemo(()=>R?M:m===null||x===null||typeof x>"u"?[]:[{rowId:m,content:x,isVisible:N}],[N,R,x,m,M]),onRowExpandChange:de}}function Te({actions:n,selectedRowsData:t}){const i=a.useMemo(()=>!n||!t.length?[]:t.reduce((l,r,h)=>{const o=n(r).filter(c=>c.multiple&&!c.hidden);if(h===0)return o;const p=new Map(l.map(c=>[c.id,c]));return o.reduce((c,m)=>{const b=p.get(m.id);return b&&c.push({...b,...m,disabled:m.disabled||b.disabled}),c},[])},[]),[n,t]),s=a.useCallback(l=>{if(t.length){if(l.onMultipleClick){l.onMultipleClick(t);return}t.forEach(r=>l.onClick(r))}},[t]);return{multiActions:i,handleMultipleActionClick:s}}function ye({data:n,onRowSelect:t,onSelectedRowsChange:i}){const[s,l]=a.useState(new Set),r=a.useMemo(()=>n?.filter(c=>s.has(c.id))??[],[n,s]);a.useEffect(()=>{if(!n?.length){l(new Set);return}l(c=>{const m=new Set,b=new Set(n.map(x=>x.id));return c.forEach(x=>{b.has(x)&&m.add(x)}),m})},[n]),a.useEffect(()=>{i&&i(r)},[r,i]);const h=a.useCallback(c=>{l(m=>{const b=new Set(m);return b.has(c.id)?(b.delete(c.id),t?.(c,!1)):(b.add(c.id),t?.(c,!0)),b})},[t]),o=a.useCallback(()=>{l(c=>{const m=new Set(c),b=n??[],x=b.every(u=>m.has(u.id));return b.forEach(u=>{const N=m.has(u.id);x?N&&(m.delete(u.id),t?.(u,!1)):N||(m.add(u.id),t?.(u,!0))}),m})},[n,t]),p=a.useMemo(()=>{if(!n?.length)return{allSelected:!1,hasSomeSelected:!1};const c=n.every(b=>s.has(b.id)),m=n.some(b=>s.has(b.id));return{allSelected:c,hasSomeSelected:m}},[n,s]);return{selectedRows:s,selectedRowsData:r,selectionState:p,onRowSelectionChange:h,onToggleAllRows:o}}function Se(n){const{data:t,onSort:i,entity:s="",isLoading:l=!1,actions:r,columns:h=[],contentClassName:o="",className:p="",softDeleteProperty:c="deletedAt",onRowSelect:m,onSelectedRowsChange:b,allowMultipleExpandedRows:x=!1,expandedRowId:u,onExpandedRowChange:N,onRowExpand:S,...$}=n,g=a.useMemo(()=>!t?.length,[t]),M=a.useCallback(D=>D===null?null:t.find(W=>W.id===D)??null,[t]),{selectedRows:O,selectedRowsData:E,selectionState:k,onRowSelectionChange:I,onToggleAllRows:w}=ye({data:t,onRowSelect:m,onSelectedRowsChange:b}),{expandedRowsToRender:R,onRowExpandChange:C}=ve({data:t,allowMultipleExpandedRows:x,controlledExpandedRowId:u,onExpandedRowChange:N,onRowExpand:S,findRowById:M}),{multiActions:z,handleMultipleActionClick:y}=Te({actions:r,selectedRowsData:E});return e.jsx(T.FiltersProvider,{children:e.jsxs("div",{className:`${p} table-main`,children:[e.jsx(ce,{columns:h,isLoading:l,...$}),l?e.jsx(be.Loading,{className:"table-loading"}):e.jsx(e.Fragment,{children:g?e.jsx(oe,{}):e.jsxs(e.Fragment,{children:[!!E.length&&e.jsx(ue,{count:E.length,multiActions:z,onActionClick:y}),e.jsx("div",{className:`${o} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(Q,{entity:s,columns:h,onSortCallback:i,hasAction:!!r,selectionState:k,onToggleAllRows:w}),e.jsx("tbody",{children:e.jsx(ie,{data:t,actions:r,columns:h,softDeleteProperty:c,selectedRows:O,expandedRows:R,onRowSelectionChange:I,onRowExpand:S?C:void 0})})]})}),e.jsx(ae,{})]})})]})})}exports.ActiveFilters=ee;exports.ArrayChip=Y;exports.Columns=Q;exports.CountOfTotal=se;exports.FilterDropdown=ne;exports.Footer=ae;exports.Navigation=le;exports.PageSize=re;exports.RangeChip=Z;exports.Rows=ie;exports.Table=Se;exports.TableEmpty=oe;exports.TableHeader=ce;exports.TableSelectionBar=ue;exports.renderFilterComponent=te;