@hxtos/hx-components 0.23.3 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -24003,14 +24003,11 @@ function Hte({
24003
24003
  fe(!0);
24004
24004
  }
24005
24005
  function ee() {
24006
- if (z >= Math.ceil(a / be) - 1) {
24007
- ke(!1);
24008
- return;
24009
- }
24010
- ke(!0);
24006
+ const ae = Math.ceil(a / be);
24007
+ z >= ae - 1 ? ke(!1) : ke(!0);
24011
24008
  }
24012
24009
  k(), ee();
24013
- }, [z, a]), /* @__PURE__ */ E.jsxs(Qy, { children: [
24010
+ }, [z, a, be]), /* @__PURE__ */ E.jsxs(Qy, { children: [
24014
24011
  r && /* @__PURE__ */ E.jsx(cte, { setFilter: Ye, placeholder: c }),
24015
24012
  n && /* @__PURE__ */ E.jsx(a4, { spinnerMessage: l }),
24016
24013
  e.length === 0 && !n && /* @__PURE__ */ E.jsx(t4, { noRecordsMessage: u }),
package/dist/index.umd.js CHANGED
@@ -187,7 +187,7 @@ You should wrap it with \`css\` like this:
187
187
  * LICENSE.md file in the root directory of this source tree.
188
188
  *
189
189
  * @license MIT
190
- */function d3(e,t){return e?Fz(e)?ne.createElement(e,t):e:null}function Fz(e){return Mz(e)||typeof e=="function"||Rz(e)}function Mz(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Rz(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function h3(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=ne.useState(()=>({current:Az(t)})),[r,i]=ne.useState(()=>n.current.initialState);return n.current.setOptions(a=>({...a,...e,state:{...r,...e.state},onStateChange:l=>{i(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function p3({children:e}){return A.jsx("div",{className:"text-black dark:text-white",children:e})}function g3({itemsPerPageMessage:e,pageSeparatorMessage:t,totalRecords:n,size:r,pageIndex:i,canNextPage:a,canPreviousPage:l,onPageSizeChange:u,onGoFirstPage:c,onGoPreviousPage:f,onGoLastPage:h,onGoNextPage:p}){return A.jsxs("div",{className:"flex items-center justify-end gap-2 px-2 py-2 my-2 text-sm text-brand-text dark:text-white",children:[A.jsx("p",{children:e}),A.jsx("select",{className:et("w-20 border-0 border-b border-brand-disabled focus:outline-none focus:ring-0 focus:border-l-0 focus:border-b focus:border-brand-primary","bg-brand-light-gray dark:bg-brand-dark-gray-dark","text-brand-secondary-text dark:text-brand-gray"),value:r,onChange:u,children:[5,10,25,50].map(m=>A.jsx("option",{value:m,children:m},`page-size-option-${m}`))}),A.jsxs("span",{children:[i+1," ",t," ",n]}),A.jsx("button",{onClick:c,disabled:!l,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(m4,{})}),A.jsx("button",{onClick:f,disabled:!l,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(Q1,{})}),A.jsx("button",{onClick:p,disabled:!a,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(ep,{})}),A.jsx("button",{onClick:h,disabled:!a,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(v4,{})})]})}function m3({noRecordsMessage:e}){return A.jsx("p",{className:"text-sm text-center",children:e})}function v3(e){var t,n,r,i,a,l,u;return((r=(n=(t=e==null?void 0:e.column)==null?void 0:t.parent)==null?void 0:n.columns)==null?void 0:r.length)&&((l=(a=(i=e==null?void 0:e.column)==null?void 0:i.parent)==null?void 0:a.columns[0])==null?void 0:l.id)===((u=e==null?void 0:e.column)==null?void 0:u.id)}function b3(e){var t,n,r,i,a,l,u;return((r=(n=(t=e==null?void 0:e.column)==null?void 0:t.parent)==null?void 0:n.columns)==null?void 0:r.length)&&((l=(a=(i=e==null?void 0:e.column)==null?void 0:i.parent)==null?void 0:a.columns[e.column.parent.columns.length-1])==null?void 0:l.id)===((u=e==null?void 0:e.column)==null?void 0:u.id)}function Ql(e){var t;return((t=e==null?void 0:e.subHeaders)==null?void 0:t.length)>0}function y3({headerGroup:e,isPagination:t=!0,onSort:n,onColumn:r}){function i(l){return l.id==="select"?50:l.getSize()}function a(l,u){function c(){const h=l.column.getIsSorted();return h?h==="desc"?A.jsx(C4,{}):A.jsx(y4,{}):A.jsx(x4,{})}function f(h){const p=h.column.getIsSorted();n(typeof p=="boolean"?"":p),r(h.id)}return A.jsx(A.Fragment,{children:A.jsx("th",{className:et("px-2 py-3 text-xs text-left select-none border-b border-brand-disabled",{"border-r":Ql(l)||b3(l),"border-l":Ql(l)||v3(l)}),colSpan:l.colSpan,style:{width:i(l)},children:A.jsxs("div",{className:"flex items-center justify-between",children:[Ql(l)&&A.jsx("div",{}),A.jsxs("div",{className:"flex flex-row items-center space-x-4 text-sm font-bold text-brand-primary",children:[A.jsx("span",{className:"w-full",children:d3(l.column.columnDef.header,l.getContext())}),l.column.columnDef.sortingFn&&!Ql(l)&&A.jsx("span",{className:`px-2 ${l.column.getCanSort()?"cursor-pointer":""}`,onClick:async h=>{await l.column.getToggleSortingHandler()(h),t&&f(l)},children:c()})]}),l.id!=="select"&&A.jsx("div",{onMouseDown:l.getResizeHandler(),onTouchStart:l.getResizeHandler(),className:"w-3 h-full text-brand-gray cursor-col-resize",children:A.jsx(b4,{})})]})},`thead-th-${l.id}-${u}`)})}return A.jsx("tr",{className:"mx-auto",children:e.headers.map(a)},`thead-tr-${e.id}`)}function C3({row:e,index:t,renderSubComponent:n}){function r(i,a){return A.jsx("td",{className:et("px-2 children:align-middle overflow-ellipsis whitespace-nowrap border-brand-disabled",{"border-r":b3(i),"border-l":v3(i)}),children:d3(i.column.columnDef.cell,i.getContext())},`tbody-td-${i.id}-${a}`)}return A.jsxs(b.Fragment,{children:[A.jsx("tr",{className:"mx-auto children:text-sm children:py-3 children:text-brand-text dark:children:text-white children:last-of-type:border-b children:last-of-type:border-brand-disabled",children:e.getVisibleCells().map(r)},`tbody-tr-${e.id}-${t}`),e.getIsExpanded()?A.jsx("tr",{children:A.jsx("td",{colSpan:e.getVisibleCells().length,children:n({row:e})})}):null]},`tbody-fragmment-${e.id}-${t}`)}function x3({spinnerMessage:e}){return A.jsx("div",{className:"flex items-center justify-center mt-10",children:A.jsx(hd,{size:50,children:e})})}function w3({indeterminate:e,className:t="w-5 h-5 rounded-md border-brand-primary border-1 text-brand-primary focus:ring-0",...n}){const r=b.useRef(null);return b.useEffect(()=>{typeof e=="boolean"&&(r.current.indeterminate=!n.checked&&e)},[r,e]),A.jsx("input",{type:"checkbox",ref:r,className:t+" cursor-pointer",...n})}function S3(e,t){return e?[{id:"select",sortingFn:!1,header:({table:r})=>A.jsx(w3,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>A.jsx("div",{className:"px-1",children:A.jsx(w3,{checked:r.getIsSelected(),disabled:!r.getCanSelect(),indeterminate:r.getIsSomeSelected(),onChange:r.getToggleSelectedHandler()})})},...t]:t}function Lz({setFilter:e,placeholder:t}){let n=0;function r(i){clearTimeout(n),n=setTimeout(()=>{e(i.target.value||void 0)},500)}return A.jsxs("div",{className:"flex items-center gap-2 px-2 my-2 bg-gray-100 border-b-2 border-gray-200 rounded-sm focus-within:border-0 focus-within:border-b focus-within:border-brand-primary focus-within:ring-brand-primary dark:bg-gray-700",children:[A.jsx(Xu,{className:"text-brand-secondary-text dark:text-brand-gray"}),A.jsx("input",{className:"flex-1 py-2 bg-transparent text-sm border-none appearance-none focus:outline-none focus:ring-0",placeholder:t,onChange:r})]})}function Vz({data:e,columns:t,isFetching:n,searchable:r=!0,isRowSelection:i=!1,totalRecords:a,spinnerMessage:l="Carregando...",noRecordsMessage:u="Nenhuma entrada encontrada.",searchPlaceholder:c="Buscar...",itemsPerPageMessage:f="Itens por página:",pageSeparatorMessage:h="de",onRowSelection:p,renderSubComponent:m,getRowCanExpand:v,onSearch:x,onSize:S,onPage:E,onColumn:P,onSort:M}){const L="onChange",[D,N]=b.useState([]),[z,X]=b.useState(0),[Y,fe]=b.useState(!1),[Te,Ge]=b.useState(!1),[Xe,pe]=b.useState({}),xe=h3({data:e,columns:S3(i,t),columnResizeMode:L,initialState:{pagination:{pageSize:5}},defaultColumn:{minSize:100,size:150,maxSize:1e3},state:{rowSelection:Xe,sorting:D},getRowCanExpand:v,onRowSelectionChange:pe,getCoreRowModel:a3(),getFilteredRowModel:s3(),getPaginationRowModel:f3(),onSortingChange:N,getSortedRowModel:l3(),getExpandedRowModel:u3()}),be=xe.getState().pagination.pageSize;function Ee(j){E(j),X(j)}function $e(j){Ee(0),S(Number(j.target.value)),xe.setPageSize(Number(j.target.value))}function Je(j){Ee(0),x(j)}function O(){Ee(0)}function T(){const j=z-1;Ee(j)}function R(){const j=z+1;Ee(j)}function F(){const j=Math.ceil(a/be)-1;Ee(j)}function y(){return p(xe.getSelectedRowModel().flatRows)}return b.useEffect(()=>{function j(){if(z===0){fe(!1);return}fe(!0)}function ee(){if(z>=Math.ceil(a/be)-1){Ge(!1);return}Ge(!0)}j(),ee()},[z,a]),A.jsxs(p3,{children:[r&&A.jsx(Lz,{setFilter:Je,placeholder:c}),n&&A.jsx(x3,{spinnerMessage:l}),e.length===0&&!n&&A.jsx(m3,{noRecordsMessage:u}),e.length>0&&!n&&A.jsx("div",{className:"flex justify-center items-center",children:A.jsx("div",{className:"overflow-x-auto",children:A.jsxs("table",{style:{width:xe.getCenterTotalSize()},children:[A.jsx("thead",{children:xe.getHeaderGroups().map(j=>A.jsx(y3,{headerGroup:j,onColumn:P,onSort:M}))}),A.jsx("tbody",{className:"divide-y divide-brand-disabled",children:xe.getRowModel().rows.map((j,ee)=>A.jsx(C3,{index:ee,row:j,renderSubComponent:m},j.id))})]})})}),A.jsx(g3,{itemsPerPageMessage:f,pageSeparatorMessage:h,totalRecords:Math.ceil(a/be),size:be,pageIndex:z,canNextPage:Te,canPreviousPage:Y,onPageSizeChange:$e,onGoFirstPage:O,onGoPreviousPage:T,onGoLastPage:F,onGoNextPage:R}),i&&p&&y()]})}function Dz({value:e,onChange:t,placeholder:n,debounce:r=500,...i}){const[a,l]=b.useState(e);return b.useEffect(()=>{l(e)},[e]),b.useEffect(()=>{const u=setTimeout(()=>{t(a)},r);return()=>clearTimeout(u)},[a]),A.jsxs("div",{className:"flex items-center gap-2 px-2 my-2 bg-gray-100 border-b-2 border-gray-200 rounded-sm focus-within:border-0 focus-within:border-b focus-within:border-brand-primary focus-within:ring-brand-primary dark:bg-gray-700",children:[A.jsx(Xu,{className:"text-brand-secondary-text dark:text-brand-gray"}),A.jsx("input",{...i,value:a,className:"flex-1 py-2 bg-transparent text-sm border-none appearance-none focus:outline-none focus:ring-0",placeholder:n,onChange:u=>l(u.target.value)})]})}function Nz({data:e,columns:t,isFetching:n,searchable:r=!0,isRowSelection:i=!1,spinnerMessage:a="Carregando...",noRecordsMessage:l="Nenhuma entrada encontrada.",searchPlaceholder:u="Buscar...",itemsPerPageMessage:c="Itens por página:",pageSeparatorMessage:f="de",onRowSelection:h,renderSubComponent:p,getRowCanExpand:m}){const v="onChange",[x,S]=b.useState([]),[E,P]=b.useState({}),[M,L]=b.useState(""),D=h3({data:e,columns:S3(i,t),columnResizeMode:v,initialState:{pagination:{pageSize:5}},defaultColumn:{minSize:100,size:150,maxSize:1e3},state:{rowSelection:E,sorting:x,globalFilter:M},getRowCanExpand:m,onGlobalFilterChange:L,onRowSelectionChange:P,getCoreRowModel:a3(),getFilteredRowModel:s3(),getPaginationRowModel:f3(),onSortingChange:S,getSortedRowModel:l3(),getExpandedRowModel:u3()}),N=D.getState().pagination.pageSize;function z(Y){D.setPageSize(Number(Y.target.value))}function X(){return h(D.getSelectedRowModel().flatRows)}return A.jsxs(p3,{children:[r&&A.jsx(Dz,{value:M??"",onChange:Y=>L(String(Y)),placeholder:u}),n&&A.jsx(x3,{spinnerMessage:a}),e.length===0&&!n&&A.jsx(m3,{noRecordsMessage:l}),e.length>0&&!n&&A.jsx("div",{className:"flex justify-center items-center",children:A.jsx("div",{className:"overflow-x-auto",children:A.jsxs("table",{style:{width:D.getCenterTotalSize()},children:[A.jsx("thead",{children:D.getHeaderGroups().map(Y=>A.jsx(y3,{headerGroup:Y,isPagination:!1,onColumn:()=>null,onSort:()=>null}))}),A.jsx("tbody",{className:"divide-y divide-brand-disabled",children:D.getRowModel().rows.map((Y,fe)=>A.jsx(C3,{index:fe,row:Y,renderSubComponent:p},Y.id))})]})})}),A.jsx(g3,{itemsPerPageMessage:c,pageSeparatorMessage:f,totalRecords:D.getPageCount(),size:N,pageIndex:D.getState().pagination.pageIndex,canNextPage:D.getCanNextPage(),canPreviousPage:D.getCanPreviousPage(),onPageSizeChange:z,onGoFirstPage:()=>D.setPageIndex(0),onGoPreviousPage:()=>D.previousPage(),onGoLastPage:()=>D.setPageIndex(D.getPageCount()-1),onGoNextPage:()=>D.nextPage()}),i&&h&&X()]})}const I3=({children:e,tooltip:t})=>A.jsxs("div",{className:"relative inline-block group",children:[e,A.jsx("span",{className:`${et("invisible","group-hover:visible","opacity-0","group-hover:opacity-100","z-0","group-hover:z-50","transition","transform","left-1/2","text-xs","-top-9","-translate-x-1/2","bg-brand-text","text-white","p-2","rounded","absolute","whitespace-nowrap")}`,children:t})]}),$z=({children:e,className:t,id:n,tooltip:r,variant:i,...a})=>A.jsx(A.Fragment,{children:A.jsx(I3,{tooltip:r,children:A.jsx("button",{className:`${et("w-8 h-8 rounded","flex items-center justify-center","transition outline-none outline-2","shadow-action-button hover:shadow-action-button-hover","hover:bg-brand-secondary hover:text-white disabled:bg-brand-disabled disabled:text-white","disabled:shadow-none disabled:hover:cursor-not-allowed",{"bg-brand-primary text-white":i==="primary","bg-brand-tertiary-light text-brand-primary":i==="secondary"},t)}`,...a,children:e})},n)}),Nh=({Container:e,children:t,fileName:n,disabled:r,onChange:i,accept:a="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"})=>{const l=b.useRef(null),u=()=>{var f;return(f=l.current)==null?void 0:f.click()},c=f=>{const h=f.target;h.value=""};return A.jsxs(A.Fragment,{children:[A.jsx(e,{type:"button",disabled:r,onClick:u,fileName:n,children:t}),A.jsx("input",{ref:l,type:"file",className:"hidden",accept:a,onClick:c,onChange:f=>{i(f.target.files[0])}})]})},Bz=e=>A.jsx(Ki,{variant:"primary",...e}),kz=e=>A.jsx(Ki,{variant:"secondary",...e}),jz=({children:e,disabled:t,fileName:n,...r})=>A.jsx("button",{disabled:t,className:`relative ${t?"bg-gray-300 text-white cursor-not-allowed border-2 border-gray-900 border-dashed":"bg-white text-primary-500 hover:bg-primary-100 hover:mb-0 border-2 border-gray-800 border-dashed cursor-pointer"}
190
+ */function d3(e,t){return e?Fz(e)?ne.createElement(e,t):e:null}function Fz(e){return Mz(e)||typeof e=="function"||Rz(e)}function Mz(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Rz(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function h3(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=ne.useState(()=>({current:Az(t)})),[r,i]=ne.useState(()=>n.current.initialState);return n.current.setOptions(a=>({...a,...e,state:{...r,...e.state},onStateChange:l=>{i(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function p3({children:e}){return A.jsx("div",{className:"text-black dark:text-white",children:e})}function g3({itemsPerPageMessage:e,pageSeparatorMessage:t,totalRecords:n,size:r,pageIndex:i,canNextPage:a,canPreviousPage:l,onPageSizeChange:u,onGoFirstPage:c,onGoPreviousPage:f,onGoLastPage:h,onGoNextPage:p}){return A.jsxs("div",{className:"flex items-center justify-end gap-2 px-2 py-2 my-2 text-sm text-brand-text dark:text-white",children:[A.jsx("p",{children:e}),A.jsx("select",{className:et("w-20 border-0 border-b border-brand-disabled focus:outline-none focus:ring-0 focus:border-l-0 focus:border-b focus:border-brand-primary","bg-brand-light-gray dark:bg-brand-dark-gray-dark","text-brand-secondary-text dark:text-brand-gray"),value:r,onChange:u,children:[5,10,25,50].map(m=>A.jsx("option",{value:m,children:m},`page-size-option-${m}`))}),A.jsxs("span",{children:[i+1," ",t," ",n]}),A.jsx("button",{onClick:c,disabled:!l,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(m4,{})}),A.jsx("button",{onClick:f,disabled:!l,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(Q1,{})}),A.jsx("button",{onClick:p,disabled:!a,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(ep,{})}),A.jsx("button",{onClick:h,disabled:!a,className:"text-gray-500 disabled:text-gray-300 hover:text-gray-700",children:A.jsx(v4,{})})]})}function m3({noRecordsMessage:e}){return A.jsx("p",{className:"text-sm text-center",children:e})}function v3(e){var t,n,r,i,a,l,u;return((r=(n=(t=e==null?void 0:e.column)==null?void 0:t.parent)==null?void 0:n.columns)==null?void 0:r.length)&&((l=(a=(i=e==null?void 0:e.column)==null?void 0:i.parent)==null?void 0:a.columns[0])==null?void 0:l.id)===((u=e==null?void 0:e.column)==null?void 0:u.id)}function b3(e){var t,n,r,i,a,l,u;return((r=(n=(t=e==null?void 0:e.column)==null?void 0:t.parent)==null?void 0:n.columns)==null?void 0:r.length)&&((l=(a=(i=e==null?void 0:e.column)==null?void 0:i.parent)==null?void 0:a.columns[e.column.parent.columns.length-1])==null?void 0:l.id)===((u=e==null?void 0:e.column)==null?void 0:u.id)}function Ql(e){var t;return((t=e==null?void 0:e.subHeaders)==null?void 0:t.length)>0}function y3({headerGroup:e,isPagination:t=!0,onSort:n,onColumn:r}){function i(l){return l.id==="select"?50:l.getSize()}function a(l,u){function c(){const h=l.column.getIsSorted();return h?h==="desc"?A.jsx(C4,{}):A.jsx(y4,{}):A.jsx(x4,{})}function f(h){const p=h.column.getIsSorted();n(typeof p=="boolean"?"":p),r(h.id)}return A.jsx(A.Fragment,{children:A.jsx("th",{className:et("px-2 py-3 text-xs text-left select-none border-b border-brand-disabled",{"border-r":Ql(l)||b3(l),"border-l":Ql(l)||v3(l)}),colSpan:l.colSpan,style:{width:i(l)},children:A.jsxs("div",{className:"flex items-center justify-between",children:[Ql(l)&&A.jsx("div",{}),A.jsxs("div",{className:"flex flex-row items-center space-x-4 text-sm font-bold text-brand-primary",children:[A.jsx("span",{className:"w-full",children:d3(l.column.columnDef.header,l.getContext())}),l.column.columnDef.sortingFn&&!Ql(l)&&A.jsx("span",{className:`px-2 ${l.column.getCanSort()?"cursor-pointer":""}`,onClick:async h=>{await l.column.getToggleSortingHandler()(h),t&&f(l)},children:c()})]}),l.id!=="select"&&A.jsx("div",{onMouseDown:l.getResizeHandler(),onTouchStart:l.getResizeHandler(),className:"w-3 h-full text-brand-gray cursor-col-resize",children:A.jsx(b4,{})})]})},`thead-th-${l.id}-${u}`)})}return A.jsx("tr",{className:"mx-auto",children:e.headers.map(a)},`thead-tr-${e.id}`)}function C3({row:e,index:t,renderSubComponent:n}){function r(i,a){return A.jsx("td",{className:et("px-2 children:align-middle overflow-ellipsis whitespace-nowrap border-brand-disabled",{"border-r":b3(i),"border-l":v3(i)}),children:d3(i.column.columnDef.cell,i.getContext())},`tbody-td-${i.id}-${a}`)}return A.jsxs(b.Fragment,{children:[A.jsx("tr",{className:"mx-auto children:text-sm children:py-3 children:text-brand-text dark:children:text-white children:last-of-type:border-b children:last-of-type:border-brand-disabled",children:e.getVisibleCells().map(r)},`tbody-tr-${e.id}-${t}`),e.getIsExpanded()?A.jsx("tr",{children:A.jsx("td",{colSpan:e.getVisibleCells().length,children:n({row:e})})}):null]},`tbody-fragmment-${e.id}-${t}`)}function x3({spinnerMessage:e}){return A.jsx("div",{className:"flex items-center justify-center mt-10",children:A.jsx(hd,{size:50,children:e})})}function w3({indeterminate:e,className:t="w-5 h-5 rounded-md border-brand-primary border-1 text-brand-primary focus:ring-0",...n}){const r=b.useRef(null);return b.useEffect(()=>{typeof e=="boolean"&&(r.current.indeterminate=!n.checked&&e)},[r,e]),A.jsx("input",{type:"checkbox",ref:r,className:t+" cursor-pointer",...n})}function S3(e,t){return e?[{id:"select",sortingFn:!1,header:({table:r})=>A.jsx(w3,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>A.jsx("div",{className:"px-1",children:A.jsx(w3,{checked:r.getIsSelected(),disabled:!r.getCanSelect(),indeterminate:r.getIsSomeSelected(),onChange:r.getToggleSelectedHandler()})})},...t]:t}function Lz({setFilter:e,placeholder:t}){let n=0;function r(i){clearTimeout(n),n=setTimeout(()=>{e(i.target.value||void 0)},500)}return A.jsxs("div",{className:"flex items-center gap-2 px-2 my-2 bg-gray-100 border-b-2 border-gray-200 rounded-sm focus-within:border-0 focus-within:border-b focus-within:border-brand-primary focus-within:ring-brand-primary dark:bg-gray-700",children:[A.jsx(Xu,{className:"text-brand-secondary-text dark:text-brand-gray"}),A.jsx("input",{className:"flex-1 py-2 bg-transparent text-sm border-none appearance-none focus:outline-none focus:ring-0",placeholder:t,onChange:r})]})}function Vz({data:e,columns:t,isFetching:n,searchable:r=!0,isRowSelection:i=!1,totalRecords:a,spinnerMessage:l="Carregando...",noRecordsMessage:u="Nenhuma entrada encontrada.",searchPlaceholder:c="Buscar...",itemsPerPageMessage:f="Itens por página:",pageSeparatorMessage:h="de",onRowSelection:p,renderSubComponent:m,getRowCanExpand:v,onSearch:x,onSize:S,onPage:E,onColumn:P,onSort:M}){const L="onChange",[D,N]=b.useState([]),[z,X]=b.useState(0),[Y,fe]=b.useState(!1),[Te,Ge]=b.useState(!1),[Xe,pe]=b.useState({}),xe=h3({data:e,columns:S3(i,t),columnResizeMode:L,initialState:{pagination:{pageSize:5}},defaultColumn:{minSize:100,size:150,maxSize:1e3},state:{rowSelection:Xe,sorting:D},getRowCanExpand:v,onRowSelectionChange:pe,getCoreRowModel:a3(),getFilteredRowModel:s3(),getPaginationRowModel:f3(),onSortingChange:N,getSortedRowModel:l3(),getExpandedRowModel:u3()}),be=xe.getState().pagination.pageSize;function Ee(j){E(j),X(j)}function $e(j){Ee(0),S(Number(j.target.value)),xe.setPageSize(Number(j.target.value))}function Je(j){Ee(0),x(j)}function O(){Ee(0)}function T(){const j=z-1;Ee(j)}function R(){const j=z+1;Ee(j)}function F(){const j=Math.ceil(a/be)-1;Ee(j)}function y(){return p(xe.getSelectedRowModel().flatRows)}return b.useEffect(()=>{function j(){if(z===0){fe(!1);return}fe(!0)}function ee(){const ae=Math.ceil(a/be);z>=ae-1?Ge(!1):Ge(!0)}j(),ee()},[z,a,be]),A.jsxs(p3,{children:[r&&A.jsx(Lz,{setFilter:Je,placeholder:c}),n&&A.jsx(x3,{spinnerMessage:l}),e.length===0&&!n&&A.jsx(m3,{noRecordsMessage:u}),e.length>0&&!n&&A.jsx("div",{className:"flex justify-center items-center",children:A.jsx("div",{className:"overflow-x-auto",children:A.jsxs("table",{style:{width:xe.getCenterTotalSize()},children:[A.jsx("thead",{children:xe.getHeaderGroups().map(j=>A.jsx(y3,{headerGroup:j,onColumn:P,onSort:M}))}),A.jsx("tbody",{className:"divide-y divide-brand-disabled",children:xe.getRowModel().rows.map((j,ee)=>A.jsx(C3,{index:ee,row:j,renderSubComponent:m},j.id))})]})})}),A.jsx(g3,{itemsPerPageMessage:f,pageSeparatorMessage:h,totalRecords:Math.ceil(a/be),size:be,pageIndex:z,canNextPage:Te,canPreviousPage:Y,onPageSizeChange:$e,onGoFirstPage:O,onGoPreviousPage:T,onGoLastPage:F,onGoNextPage:R}),i&&p&&y()]})}function Dz({value:e,onChange:t,placeholder:n,debounce:r=500,...i}){const[a,l]=b.useState(e);return b.useEffect(()=>{l(e)},[e]),b.useEffect(()=>{const u=setTimeout(()=>{t(a)},r);return()=>clearTimeout(u)},[a]),A.jsxs("div",{className:"flex items-center gap-2 px-2 my-2 bg-gray-100 border-b-2 border-gray-200 rounded-sm focus-within:border-0 focus-within:border-b focus-within:border-brand-primary focus-within:ring-brand-primary dark:bg-gray-700",children:[A.jsx(Xu,{className:"text-brand-secondary-text dark:text-brand-gray"}),A.jsx("input",{...i,value:a,className:"flex-1 py-2 bg-transparent text-sm border-none appearance-none focus:outline-none focus:ring-0",placeholder:n,onChange:u=>l(u.target.value)})]})}function Nz({data:e,columns:t,isFetching:n,searchable:r=!0,isRowSelection:i=!1,spinnerMessage:a="Carregando...",noRecordsMessage:l="Nenhuma entrada encontrada.",searchPlaceholder:u="Buscar...",itemsPerPageMessage:c="Itens por página:",pageSeparatorMessage:f="de",onRowSelection:h,renderSubComponent:p,getRowCanExpand:m}){const v="onChange",[x,S]=b.useState([]),[E,P]=b.useState({}),[M,L]=b.useState(""),D=h3({data:e,columns:S3(i,t),columnResizeMode:v,initialState:{pagination:{pageSize:5}},defaultColumn:{minSize:100,size:150,maxSize:1e3},state:{rowSelection:E,sorting:x,globalFilter:M},getRowCanExpand:m,onGlobalFilterChange:L,onRowSelectionChange:P,getCoreRowModel:a3(),getFilteredRowModel:s3(),getPaginationRowModel:f3(),onSortingChange:S,getSortedRowModel:l3(),getExpandedRowModel:u3()}),N=D.getState().pagination.pageSize;function z(Y){D.setPageSize(Number(Y.target.value))}function X(){return h(D.getSelectedRowModel().flatRows)}return A.jsxs(p3,{children:[r&&A.jsx(Dz,{value:M??"",onChange:Y=>L(String(Y)),placeholder:u}),n&&A.jsx(x3,{spinnerMessage:a}),e.length===0&&!n&&A.jsx(m3,{noRecordsMessage:l}),e.length>0&&!n&&A.jsx("div",{className:"flex justify-center items-center",children:A.jsx("div",{className:"overflow-x-auto",children:A.jsxs("table",{style:{width:D.getCenterTotalSize()},children:[A.jsx("thead",{children:D.getHeaderGroups().map(Y=>A.jsx(y3,{headerGroup:Y,isPagination:!1,onColumn:()=>null,onSort:()=>null}))}),A.jsx("tbody",{className:"divide-y divide-brand-disabled",children:D.getRowModel().rows.map((Y,fe)=>A.jsx(C3,{index:fe,row:Y,renderSubComponent:p},Y.id))})]})})}),A.jsx(g3,{itemsPerPageMessage:c,pageSeparatorMessage:f,totalRecords:D.getPageCount(),size:N,pageIndex:D.getState().pagination.pageIndex,canNextPage:D.getCanNextPage(),canPreviousPage:D.getCanPreviousPage(),onPageSizeChange:z,onGoFirstPage:()=>D.setPageIndex(0),onGoPreviousPage:()=>D.previousPage(),onGoLastPage:()=>D.setPageIndex(D.getPageCount()-1),onGoNextPage:()=>D.nextPage()}),i&&h&&X()]})}const I3=({children:e,tooltip:t})=>A.jsxs("div",{className:"relative inline-block group",children:[e,A.jsx("span",{className:`${et("invisible","group-hover:visible","opacity-0","group-hover:opacity-100","z-0","group-hover:z-50","transition","transform","left-1/2","text-xs","-top-9","-translate-x-1/2","bg-brand-text","text-white","p-2","rounded","absolute","whitespace-nowrap")}`,children:t})]}),$z=({children:e,className:t,id:n,tooltip:r,variant:i,...a})=>A.jsx(A.Fragment,{children:A.jsx(I3,{tooltip:r,children:A.jsx("button",{className:`${et("w-8 h-8 rounded","flex items-center justify-center","transition outline-none outline-2","shadow-action-button hover:shadow-action-button-hover","hover:bg-brand-secondary hover:text-white disabled:bg-brand-disabled disabled:text-white","disabled:shadow-none disabled:hover:cursor-not-allowed",{"bg-brand-primary text-white":i==="primary","bg-brand-tertiary-light text-brand-primary":i==="secondary"},t)}`,...a,children:e})},n)}),Nh=({Container:e,children:t,fileName:n,disabled:r,onChange:i,accept:a="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"})=>{const l=b.useRef(null),u=()=>{var f;return(f=l.current)==null?void 0:f.click()},c=f=>{const h=f.target;h.value=""};return A.jsxs(A.Fragment,{children:[A.jsx(e,{type:"button",disabled:r,onClick:u,fileName:n,children:t}),A.jsx("input",{ref:l,type:"file",className:"hidden",accept:a,onClick:c,onChange:f=>{i(f.target.files[0])}})]})},Bz=e=>A.jsx(Ki,{variant:"primary",...e}),kz=e=>A.jsx(Ki,{variant:"secondary",...e}),jz=({children:e,disabled:t,fileName:n,...r})=>A.jsx("button",{disabled:t,className:`relative ${t?"bg-gray-300 text-white cursor-not-allowed border-2 border-gray-900 border-dashed":"bg-white text-primary-500 hover:bg-primary-100 hover:mb-0 border-2 border-gray-800 border-dashed cursor-pointer"}
191
191
  flex items-center justify-center w-full h-full p-2 overflow-hidden transition-all duration-300 ease-out transform focus:outline-none rounded-2xl border-opacity-20 dark:bg-brand-dark-gray-dark`,...r,children:A.jsxs("div",{className:`flex ${n?"flex-row":"flex-col"} items-center justify-center`,children:[A.jsx("div",{children:n?A.jsx(o4,{}):A.jsx(_4,{})}),A.jsx("div",{children:A.jsx("span",{className:"w-full text-sm text-center text-gray-900 dark:text-brand-secondary-text",children:e})})]})}),Gz={PrimaryButton:e=>A.jsx(Nh,{...e,Container:Bz}),OutlineButton:e=>A.jsx(Nh,{...e,Container:kz}),BoxButton:e=>A.jsx(Nh,{...e,Container:jz})};var eu={exports:{}};/**
192
192
  * @license
193
193
  * Lodash <https://lodash.com/>
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Hxtos"
5
5
  },
6
6
  "private": false,
7
- "version": "0.23.3",
7
+ "version": "0.24.0",
8
8
  "license": "MIT",
9
9
  "description": "Biblioteca de componentes Hxtos",
10
10
  "type": "module",