asma-ui-table 1.0.0 → 1.0.2

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.
@@ -38,4 +38,4 @@ import*as e from"react";import t,{Fragment as n,useState as o,useCallback as l,u
38
38
  *
39
39
  * @license MIT
40
40
  */
41
- function ce(t,n){return t?function(e){return function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(e)||"function"==typeof e||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(e)}(t)?e.createElement(t,n):t:null}const pe={"asma-ui-table-styled-table":"_asma-ui-table-styled-table_d8wt9_1","table-wrapper":"_table-wrapper_d8wt9_7","styled-table":"_styled-table_d8wt9_11",tbody:"_tbody_d8wt9_19","loading-icon":"_loading-icon_d8wt9_24","t-row":"_t-row_d8wt9_30","action-cell":"_action-cell_d8wt9_46","t-cell":"_t-cell_d8wt9_55",selected:"_selected_d8wt9_100","is-loading":"_is-loading_d8wt9_106","action-cell-default-background":"_action-cell-default-background_d8wt9_109","no-rows-overlay":"_no-rows-overlay_d8wt9_112","hide-table-header":"_hide-table-header_d8wt9_121","show-table-header":"_show-table-header_d8wt9_125","sortable-column":"_sortable-column_d8wt9_130",resizer:"_resizer_d8wt9_134",isResizing:"_isResizing_d8wt9_145","table-header":"_table-header_d8wt9_157","t-cell__actions":"_t-cell__actions_d8wt9_178","sort-icon":"_sort-icon_d8wt9_183","table-footer":"_table-footer_d8wt9_186"};function fe(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=fe(e[t]))&&(o&&(o+=" "),o+=n);else for(t in e)e[t]&&(o&&(o+=" "),o+=t);return o}function me(){for(var e,t,n=0,o="";n<arguments.length;)(e=arguments[n++])&&(t=fe(e))&&(o&&(o+=" "),o+=t);return o}function he({styledTableProps:e,row:t,index:o}){const{focusable:l,loading:r,getRowClassName:i,rowHeight:a,onRowClick:s,expandArrow:u,tdClassName:d,customSubRowData:g,renderSubRows:c}=e;return y.jsxs(n,{children:[y.jsx("tr",{"data-index":o,"data-test":t.id,id:t.id,tabIndex:l?-1:void 0,className:me(pe["t-row"],r&&pe["is-loading"],(t.getIsExpanded()||t.getIsSelected())&&pe.selected,null==i?void 0:i(t)),style:{height:a?`${a}px`:"inherit"},onMouseUp:e=>{var n,o;if(e.target.classList.contains("MuiModal-backdrop")||"INPUT"===e.target.nodeName||"BUTTON"===e.target.nodeName)return;t.getCanExpand()&&!u&&t.getToggleExpandedHandler()(),null==(n=document.getElementById(t.id))||n.focus();const l="Range"===(null==(o=window.getSelection())?void 0:o.type);s&&!l&&s(e,t)},children:t.getVisibleCells().map((e=>{const n="actions"===e.column.id;return y.jsx("td",{className:me(pe["t-cell"],d,n&&pe["action-cell"],n&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,n&&(null!=i&&i(t)?null==i?void 0:i(t):pe["action-cell-default-background"])),children:ce(e.column.columnDef.cell,e.getContext())},e.id)}))}),t.getIsExpanded()&&y.jsx(y.Fragment,{children:g&&c&&c({rows:g.get(t.original.id.toString())??[],row:t.original})})]},t.id)}function ve({styledTableProps:e,table:t}){const n=e.hideFooter?t.getCoreRowModel().rows:t.getRowModel().rows;return y.jsx(y.Fragment,{children:n.map(((t,n)=>y.jsx(he,{styledTableProps:e,row:t,index:n},t.id)))})}const be=({colSpan:e,noRowsOverlay:t})=>y.jsx("tr",{className:pe["no-rows-overlay"],children:y.jsx("td",{colSpan:e,children:t})});function we(e){return y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:[y.jsx("path",{fill:"currentColor",d:"M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z",opacity:.5}),y.jsx("path",{fill:"currentColor",d:"M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z",children:y.jsx("animateTransform",{attributeName:"transform",dur:"1s",from:"0 12 12",repeatCount:"indefinite",to:"360 12 12",type:"rotate"})})]})}function Se({table:e,styledTableProps:t}){const{columns:n,data:o,loading:l,noRowsOverlay:r}=t;return y.jsxs("tbody",{className:pe.tbody,children:[o.length>0&&l&&y.jsx(we,{className:pe["loading-icon"],width:50,height:50}),0===o.length&&l?y.jsx(_,{colSpan:n.length}):o.length>0?y.jsx(ve,{table:e,styledTableProps:t}):y.jsx(be,{colSpan:n.length,noRowsOverlay:r})]})}const Ce=()=>{const[e,t]=o(null),n=!!e,r=l((e=>{t(e.currentTarget)}),[]);return{open:n,handleClose:l((()=>{t(null)}),[]),handleOpen:r,anchorEl:e}};function Re(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z"})})}function ye(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z"})})}function _e(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z"})})}const xe={"table-pagination":"_table-pagination_k2a41_1","table-pagination__pages-list":"_table-pagination__pages-list_k2a41_13","table-pagination__pages-list__page":"_table-pagination__pages-list__page_k2a41_18","page-selected":"_page-selected_k2a41_29","check-icon":"_check-icon_k2a41_32"},Ee=e=>y.jsx(u,{...e,sx:{...e.sx,color:"var(--colors-gama-500)",borderColor:"var(--colors-gama-500)","&:hover":{borderColor:"var(--colors-gama-500)"}}});function Fe(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M15.41 16.58L10.83 12l4.58-4.59L14 6l-6 6l6 6z"})})}function Ve(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z"})})}function Pe({table:e,locale:t}){const{anchorEl:n,open:o,handleClose:l,handleOpen:i}=Ce(),a=r(null),s="no"===t,u=pe["asma-ui-table-styled-table"],c=()=>{var e,t,n,o;null==(o=null==(n=null==(t=null==(e=null==a?void 0:a.current)?void 0:e.closest(`.${u}`))?void 0:t.querySelectorAll('[data-index="0"]'))?void 0:n[0])||o.scrollIntoView({block:"center",inline:"start"})},p=e.getPageCount(),f=e.getState().pagination.pageIndex+1,m=Array.from({length:p},((e,t)=>t+1));return p>1?y.jsxs("div",{ref:a,className:xe["table-pagination"],children:[y.jsx(d,{title:s?"Nåværende side":"Current Page",children:y.jsx("div",{children:y.jsxs(Ee,{variant:"outlined",style:{minWidth:"160px"},onClick:e=>{i(e)},endIcon:o?y.jsx(Re,{height:24,width:24}):y.jsx(ye,{height:24,width:24}),children:[s?"Side":"Page"," ",f," ",s?"av":"of"," ",p]})})}),y.jsx(g,{open:o,anchorEl:n,onClose:l,anchorOrigin:{vertical:-5,horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"},children:y.jsx("div",{className:xe["table-pagination__pages-list"],children:m.map((t=>y.jsxs("div",{className:me(xe["table-pagination__pages-list__page"],f===t&&"page-selected"),onClick:()=>{e.setPageIndex(t-1),l(),c()},children:[f===t&&y.jsx(Ve,{className:xe["check-icon"],height:24,width:24}),y.jsxs("span",{children:[s?"Side":"Page"," ",t]})]},t)))})}),y.jsx(d,{title:1===f?"":s?"Forrige side":"Previous Page",children:y.jsx("div",{children:y.jsx(Ee,{size:"small",variant:"outlined",onClick:()=>{e.previousPage(),c()},disabled:!e.getCanPreviousPage(),children:y.jsx(Fe,{height:24,width:24})})})}),y.jsx(d,{title:f===p?"":s?"Neste side":"Next Page",children:y.jsx("div",{children:y.jsx(Ee,{size:"small",variant:"outlined",onClick:()=>{e.nextPage(),c()},disabled:!e.getCanNextPage(),children:y.jsx(_e,{height:24,width:24})})})})]}):null}function Me({table:e,styledTableProps:t}){var n;return t.hideFooter?null:y.jsxs("div",{className:pe["table-footer"],children:[null==(n=t.footer)?void 0:n.call(t,e),y.jsx(Pe,{table:e,locale:t.locale||"en"})]})}const Ie=t=>{const{columns:n,data:o,initialState:l,pageSize:r,enableRowSelection:i,tableInstanceRef:a,...s}=t,u=function(t){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[o]=e.useState((()=>({current:ae(n)}))),[l,r]=e.useState((()=>o.current.initialState));return o.current.setOptions((e=>({...e,...t,state:{...l,...t.state},onStateChange:e=>{r(e),null==t.onStateChange||t.onStateChange(e)}}))),o.current}({columns:n,data:o,initialState:{pagination:{pageIndex:0,pageSize:r||50},columnVisibility:{...null==l?void 0:l.columnVisibility,[m]:!1},...l},enableRowSelection:i,getCoreRowModel:e=>V((()=>[e.options.data]),(t=>{const n={rows:[],flatRows:[],rowsById:{}},o=function(t,l,r){void 0===l&&(l=0);const i=[];for(let s=0;s<t.length;s++){const u=se(e,e._getRowId(t[s],s,r),t[s],s,l,void 0,null==r?void 0:r.id);var a;n.flatRows.push(u),n.rowsById[u.id]=u,i.push(u),e.options.getSubRows&&(u.originalSubRows=e.options.getSubRows(t[s],s),null!=(a=u.originalSubRows)&&a.length&&(u.subRows=o(u.originalSubRows,l+1,u)))}return i};return n.rows=o(t),n}),{key:"development"===process.env.NODE_ENV&&"getRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getExpandedRowModel:e=>V((()=>[e.getState().expanded,e.getPreExpandedRowModel(),e.options.paginateExpandedRows]),((e,t,n)=>t.rows.length&&(!0===e||Object.keys(e??{}).length)&&n?ge(t):t),{key:"development"===process.env.NODE_ENV&&"getExpandedRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable}}),getFilteredRowModel:e=>V((()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter]),((t,n,o)=>{if(!t.rows.length||(null==n||!n.length)&&!o){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const l=[],r=[];(n??[]).forEach((t=>{var n;const o=e.getColumn(t.id);if(!o)return;const r=o.getFilterFn();r?l.push({id:t.id,filterFn:r,resolvedValue:null!=(n=null==r.resolveFilterValue?void 0:r.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${o.id}.`)}));const i=n.map((e=>e.id)),a=e.getGlobalFilterFn(),s=e.getAllLeafColumns().filter((e=>e.getCanGlobalFilter()));let u,d;o&&a&&s.length&&(i.push("__global__"),s.forEach((e=>{var t;r.push({id:e.id,filterFn:a,resolvedValue:null!=(t=null==a.resolveFilterValue?void 0:a.resolveFilterValue(o))?t:o})})));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},l.length)for(let e=0;e<l.length;e++){u=l[e];const t=u.id;n.columnFilters[t]=u.filterFn(n,t,u.resolvedValue,(e=>{n.columnFiltersMeta[t]=e}))}if(r.length){for(let e=0;e<r.length;e++){d=r[e];const t=d.id;if(d.filterFn(n,t,d.resolvedValue,(e=>{n.columnFiltersMeta[t]=e}))){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return de(t.rows,(e=>{for(let t=0;t<i.length;t++)if(!1===e.columnFilters[i[t]])return!1;return!0}),e)}),{key:"development"===process.env.NODE_ENV&&"getFilteredRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getSortedRowModel:e=>V((()=>[e.getState().sorting,e.getPreSortedRowModel()]),((t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const o=e.getState().sorting,l=[],r=o.filter((t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()})),i={};r.forEach((t=>{const n=e.getColumn(t.id);n&&(i[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})}));const a=e=>{const t=[...e];return t.sort(((e,t)=>{for(let o=0;o<r.length;o+=1){var n;const l=r[o],a=i[l.id],s=null!=(n=null==l?void 0:l.desc)&&n;let u=0;if(a.sortUndefined){const n=void 0===e.getValue(l.id),o=void 0===t.getValue(l.id);(n||o)&&(u=n&&o?0:n?a.sortUndefined:-a.sortUndefined)}if(0===u&&(u=a.sortingFn(e,t,l.id)),0!==u)return s&&(u*=-1),a.invertSorting&&(u*=-1),u}return e.index-t.index})),t.forEach((e=>{var t;l.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=a(e.subRows))})),t};return{rows:a(n.rows),flatRows:l,rowsById:n.rowsById}}),{key:"development"===process.env.NODE_ENV&&"getSortedRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getPaginationRowModel:e=>V((()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded]),((t,n)=>{if(!n.rows.length)return n;const{pageSize:o,pageIndex:l}=t;let{rows:r,flatRows:i,rowsById:a}=n;const s=o*l,u=s+o;let d;r=r.slice(s,u),d=e.options.paginateExpandedRows?{rows:r,flatRows:i,rowsById:a}:ge({rows:r,flatRows:i,rowsById:a}),d.flatRows=[];const g=e=>{d.flatRows.push(e),e.subRows.length&&e.subRows.forEach(g)};return d.rows.forEach(g),d}),{key:"development"===process.env.NODE_ENV&&"getPaginationRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable}}),getRowId:s.getRowId||((e,t,n)=>n?[n.id,e.id].join("."):e.id.toString()),defaultColumn:t.enableResizing?{size:void 0}:void 0,...s});return a&&(a.current=u),{table:u}},Ne=({dataTest:e,...t})=>y.jsx(c,{...t,"data-test":e,sx:{...t.sx,"&.MuiCheckbox-root":{color:"var(--colors-delta-500) !important"},"&.MuiCheckbox-root.Mui-checked":{color:"var(--colors-gama-500) !important"},"&.MuiCheckbox-root.MuiCheckbox-indeterminate":{color:"var(--colors-gama-500) !important"},"&.MuiCheckbox-root.Mui-disabled":{color:"var(--colors-delta-200) !important"},"&.MuiCheckbox-root .PrivateSwitchBase-input":{height:"100% !important",width:"100% !important"}}});function De(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2"})})}function Oe({tableData:e,actions:t}){const{anchorEl:n,open:o,handleClose:l,handleOpen:r}=Ce(),i=t(e.row).filter((e=>!e.hide));return y.jsx("div",{className:"flex justify-center items-center w-[42px]",children:i.length?y.jsxs(y.Fragment,{children:[y.jsx(Ee,{variant:"text",onClick:e=>{e.stopPropagation(),e.preventDefault(),r(e)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},sx:{minWidth:"20px"},children:y.jsx(De,{className:"text-delta-800",width:20,height:20})}),y.jsx(g,{open:o,anchorEl:n,onClose:l,onClick:l,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:t(e.row).filter((e=>!e.hide)).map(((t,n)=>y.jsx(p,{className:t.className,disabled:t.disabled,onClick:()=>{var n;null==(n=t.onClick)||n.call(t,e.row)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},children:t.label},n)))})]}):null})}function je(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M16 9V4h2V2H6v2h2v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1l1-1v-7H19v-2c-1.66 0-3-1.34-3-3"})})}function ke({headerData:e}){const{anchorEl:t,open:n,handleClose:o,handleOpen:l}=Ce();return y.jsxs("div",{className:"w-full flex items-center justify-end ",children:[y.jsx("div",{className:"px-2.5 h-[30px] flex items-center justify-center cursor-pointer",onClick:l,children:y.jsx(je,{className:"text-delta-500 hover:text-delta-600 min-w-[20px] min-h-[20px]"})}),y.jsx(g,{anchorEl:t,anchorOrigin:{horizontal:"left",vertical:"bottom"},open:n,onClose:o,children:e.table.getAllLeafColumns().filter((e=>e.getCanHide()&&e.id!==f)).map((e=>e.columnDef.header?y.jsxs(p,{onClick:()=>e.toggleVisibility(!e.getIsVisible()),children:[y.jsx(Ne,{size:"small",dataTest:"test",disableRipple:!0,className:"p-0 pr-2",checked:e.getIsVisible()}),"string"==typeof e.columnDef.header?e.columnDef.header:e.id]},e.id):null))})]})}const Ae=e=>{const{columns:t,actions:n,customActionsNode:o,headerPin:l=!0,enableRowSelection:r,expandArrow:i}=e;!t.find((e=>"actions"===e.id))&&(n||o||l)&&t.push(function(e){const{headerPin:t,actions:n,customActionsNode:o}=e;return{id:"actions",enableHiding:!1,enableSorting:!1,accessorFn:e=>e,header:e=>t?y.jsx(ke,{headerData:e}):null,cell:e=>n||o?y.jsxs("div",{className:"flex items-center justify-end",children:[o&&y.jsx("div",{className:"mr-1",children:null==o?void 0:o(e)}),n&&y.jsx(Oe,{tableData:e,actions:n})]}):null,size:50}}({headerPin:l,actions:n,customActionsNode:o})),r&&!t.find((e=>e.id===m))&&t.unshift({id:m,minSize:40,maxSize:40,size:40,header:({table:e})=>y.jsx("div",{className:"w-[25px]",children:y.jsx(Ne,{size:"small",dataTest:"cell-select-all",checked:e.getIsAllRowsSelected(),indeterminate:e.getIsSomeRowsSelected(),onChange:e.getToggleAllRowsSelectedHandler()})}),cell:({cell:e})=>y.jsx("div",{className:"w-[25px]",children:y.jsx(Ne,{size:"small",dataTest:"cell-select",checked:e.row.getIsSelected(),disabled:!e.row.getCanSelect(),onClick:e=>e.stopPropagation(),onChange:e.row.getToggleSelectedHandler()})})}),i&&!t.find((e=>e.id===h))&&t.unshift({id:h,minSize:50,maxSize:50,size:50,enableHiding:!1,enableSorting:!1,header:()=>null,cell:({cell:e})=>{const t=e.row.getIsExpanded();return e.row.getCanExpand()?y.jsx("span",{className:"flex h-fit w-full outline-none focus:outline-none items-center justify-center",onClick:()=>e.row.getToggleExpandedHandler()(),children:t?y.jsx(Re,{width:24,height:24}):y.jsx(ye,{width:24,height:24})}):null}})};function ze(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"m7 14l5-5l5 5z"})})}function Le(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"m7 10l5 5l5-5z"})})}const He=e=>{var t;const{header:n,enableResizing:o,element:l}=e;let r=n.getSize();if(!o){r&&(r=`${r}px`);const e="actions"===(null==(t=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}(n.headerGroup.headers))?void 0:t.id),o=n.headerGroup.headers[n.headerGroup.headers.length-(e?2:1)];return((null==o?void 0:o.id)===n.id||!r)&&(r="100%"),{width:r||n.column.columnDef.size,maxWidth:r||n.column.columnDef.maxSize,minWidth:r||n.column.columnDef.minSize}}const i=n.column.columnDef.size,a=n.column.columnDef.minSize;return{width:i,maxWidth:n.column.columnDef.maxSize,minWidth:a}};function Te({styledTableProps:e,header:t,tableCanResize:n=!1}){const{hideHeader:o=!1,enableResizing:l=!1}=e,i=r(null);return y.jsx("th",{ref:i,colSpan:t.colSpan,className:me(pe["t-cell"],"actions"===t.column.id&&pe["t-cell__actions"]),style:He({enableResizing:l,header:t,element:i.current}),children:y.jsxs("div",{className:me("flex items-center justify-left",o?pe["hide-table-header"]:pe["show-table-header"],t.column.getCanSort()&&pe["sortable-column"],t.column.columnDef.className),onClick:t.column.getToggleSortingHandler(),children:[ce(t.column.columnDef.header,t.getContext()),{asc:y.jsx(ze,{className:pe["sort-icon"]}),desc:y.jsx(Le,{className:pe["sort-icon"]})}[t.column.getIsSorted()]??null,n&&t.column.getCanResize()&&![m,h,v].includes(t.column.id)&&y.jsx("div",{onDoubleClick:()=>t.column.resetSize(),onMouseDown:t.getResizeHandler(),onTouchStart:t.getResizeHandler(),className:`${pe.resizer} ${t.column.getIsResizing()?pe.isResizing:""}`})]})},t.id)}function Ge({table:e,styledTableProps:t,tableCanResize:n}){const{stickyHeader:o=!1,hideHeader:l=!1}=t;return t.loading?null:y.jsx("thead",{className:me(pe["table-header"],l&&pe["hide-table-header"]),style:o&&{position:"sticky",top:-.2}||{},children:e.getHeaderGroups().map((e=>y.jsx("tr",{children:e.headers.map((e=>y.jsx(Te,{styledTableProps:t,header:e,tableCanResize:n},e.column.id)))},e.id)))})}const Be=e=>{const{className:t,height:n}=e;Ae(e);const{table:o}=Ie(e),l=a((()=>{var t,n;if(!e.enableColumnResizing)return;const l=o.getFlatHeaders(),r={};for(let e=0;e<l.length;e++){const t=l[e];r[`--header-${t.id}-size`]=t.getSize(),r[`--col-${t.column.id}-size`]=t.column.getSize()}return null==(t=e.getTableState)||t.call(e,o.getState()),null==(n=e.getColumnSizing)||n.call(e,o.getState().columnSizing),r}),[e.enableColumnResizing,o.getState().columnSizingInfo,o.getState().columnSizing]);return y.jsxs("div",{className:pe["asma-ui-table-styled-table"],children:[y.jsx("div",{className:me(pe["table-wrapper"],t),style:{height:n},children:y.jsxs("table",{className:pe["styled-table"],style:{...l},children:[y.jsx(Ge,{table:o,styledTableProps:e,tableCanResize:!!e.enableColumnResizing}),l?y.jsx(y.Fragment,{children:o.getState().columnSizingInfo.isResizingColumn?y.jsx($e,{table:o,styledTableProps:e}):y.jsx(Se,{table:o,styledTableProps:e})}):y.jsx(Se,{table:o,styledTableProps:e})]})}),y.jsx(Me,{table:o,styledTableProps:e})]})},$e=i(Se,((e,t)=>e.table.options.data===t.table.options.data));export{v as ACTIONS_COLUMN_ID,h as EXPAND_COLUMN_ID,$e as MemoizedTableBody,m as SELECT_COLUMN_ID,Be as StyledTable,ue as createColumnHelper};
41
+ function ce(t,n){return t?function(e){return function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(e)||"function"==typeof e||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(e)}(t)?e.createElement(t,n):t:null}const pe={"asma-ui-table-styled-table":"_asma-ui-table-styled-table_d8wt9_1","table-wrapper":"_table-wrapper_d8wt9_7","styled-table":"_styled-table_d8wt9_11",tbody:"_tbody_d8wt9_19","loading-icon":"_loading-icon_d8wt9_24","t-row":"_t-row_d8wt9_30","action-cell":"_action-cell_d8wt9_46","t-cell":"_t-cell_d8wt9_55",selected:"_selected_d8wt9_100","is-loading":"_is-loading_d8wt9_106","action-cell-default-background":"_action-cell-default-background_d8wt9_109","no-rows-overlay":"_no-rows-overlay_d8wt9_112","hide-table-header":"_hide-table-header_d8wt9_121","show-table-header":"_show-table-header_d8wt9_125","sortable-column":"_sortable-column_d8wt9_130",resizer:"_resizer_d8wt9_134",isResizing:"_isResizing_d8wt9_145","table-header":"_table-header_d8wt9_157","t-cell__actions":"_t-cell__actions_d8wt9_178","sort-icon":"_sort-icon_d8wt9_183","table-footer":"_table-footer_d8wt9_186"};function fe(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=fe(e[t]))&&(o&&(o+=" "),o+=n);else for(t in e)e[t]&&(o&&(o+=" "),o+=t);return o}function me(){for(var e,t,n=0,o="";n<arguments.length;)(e=arguments[n++])&&(t=fe(e))&&(o&&(o+=" "),o+=t);return o}function he({styledTableProps:e,row:t,index:o}){const{focusable:l,loading:r,getRowClassName:i,rowHeight:a,onRowClick:s,expandArrow:u,tdClassName:d,customSubRowData:g,renderSubRows:c}=e;return y.jsxs(n,{children:[y.jsx("tr",{"data-index":o,"data-test":t.id,id:t.id,tabIndex:l?-1:void 0,className:me(pe["t-row"],r&&pe["is-loading"],(t.getIsExpanded()||t.getIsSelected())&&pe.selected,null==i?void 0:i(t)),style:{height:a?`${a}px`:"inherit"},onMouseUp:e=>{var n,o;if(e.target.classList.contains("MuiModal-backdrop")||"INPUT"===e.target.nodeName||"BUTTON"===e.target.nodeName)return;t.getCanExpand()&&!u&&t.getToggleExpandedHandler()(),null==(n=document.getElementById(t.id))||n.focus();const l="Range"===(null==(o=window.getSelection())?void 0:o.type);s&&!l&&s(e,t)},children:t.getVisibleCells().map((e=>{const n="actions"===e.column.id;return y.jsx("td",{className:me(pe["t-cell"],d,n&&pe["action-cell"],n&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,n&&(null!=i&&i(t)?null==i?void 0:i(t):pe["action-cell-default-background"])),children:ce(e.column.columnDef.cell,e.getContext())},e.id)}))}),t.getIsExpanded()&&y.jsx(y.Fragment,{children:g&&c&&c({rows:g.get(t.original.id.toString())??[],row:t.original})})]},t.id)}function ve({styledTableProps:e,table:t}){const n=e.hideFooter?t.getCoreRowModel().rows:t.getRowModel().rows;return y.jsx(y.Fragment,{children:n.map(((t,n)=>y.jsx(he,{styledTableProps:e,row:t,index:n},t.id)))})}const be=({colSpan:e,noRowsOverlay:t})=>y.jsx("tr",{className:pe["no-rows-overlay"],children:y.jsx("td",{colSpan:e,children:t})});function we(e){return y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:[y.jsx("path",{fill:"currentColor",d:"M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z",opacity:.5}),y.jsx("path",{fill:"currentColor",d:"M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z",children:y.jsx("animateTransform",{attributeName:"transform",dur:"1s",from:"0 12 12",repeatCount:"indefinite",to:"360 12 12",type:"rotate"})})]})}function Se({table:e,styledTableProps:t}){const{columns:n,data:o,loading:l,noRowsOverlay:r}=t;return y.jsxs("tbody",{className:pe.tbody,children:[o.length>0&&l&&y.jsx(we,{className:pe["loading-icon"],width:50,height:50}),0===o.length&&l?y.jsx(_,{colSpan:n.length}):o.length>0?y.jsx(ve,{table:e,styledTableProps:t}):y.jsx(be,{colSpan:n.length,noRowsOverlay:r})]})}const Ce=()=>{const[e,t]=o(null),n=!!e,r=l((e=>{t(e.currentTarget)}),[]);return{open:n,handleClose:l((()=>{t(null)}),[]),handleOpen:r,anchorEl:e}};function Re(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z"})})}function ye(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z"})})}function _e(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z"})})}const xe={"table-pagination":"_table-pagination_k2a41_1","table-pagination__pages-list":"_table-pagination__pages-list_k2a41_13","table-pagination__pages-list__page":"_table-pagination__pages-list__page_k2a41_18","page-selected":"_page-selected_k2a41_29","check-icon":"_check-icon_k2a41_32"},Ee=e=>y.jsx(u,{...e,sx:{...e.sx,color:"var(--colors-gama-500)",borderColor:"var(--colors-gama-500)","&:hover":{borderColor:"var(--colors-gama-500)"}}});function Fe(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M15.41 16.58L10.83 12l4.58-4.59L14 6l-6 6l6 6z"})})}function Ve(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z"})})}function Pe({table:e,locale:t}){const{anchorEl:n,open:o,handleClose:l,handleOpen:i}=Ce(),a=r(null),s="no"===t,u=pe["asma-ui-table-styled-table"],c=()=>{var e,t,n,o;null==(o=null==(n=null==(t=null==(e=null==a?void 0:a.current)?void 0:e.closest(`.${u}`))?void 0:t.querySelectorAll('[data-index="0"]'))?void 0:n[0])||o.scrollIntoView({block:"center",inline:"start"})},p=e.getPageCount(),f=e.getState().pagination.pageIndex+1,m=Array.from({length:p},((e,t)=>t+1));return p>1?y.jsxs("div",{ref:a,className:xe["table-pagination"],children:[y.jsx(d,{title:s?"Nåværende side":"Current Page",children:y.jsx("div",{children:y.jsxs(Ee,{size:"small",variant:"outlined",style:{minWidth:"140px"},onClick:e=>{i(e)},endIcon:o?y.jsx(Re,{height:22,width:22}):y.jsx(ye,{height:22,width:22}),children:[s?"Side":"Page"," ",f," ",s?"av":"of"," ",p]})})}),y.jsx(g,{open:o,anchorEl:n,onClose:l,anchorOrigin:{vertical:-5,horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"},children:y.jsx("div",{className:xe["table-pagination__pages-list"],children:m.map((t=>y.jsxs("div",{className:me(xe["table-pagination__pages-list__page"],f===t&&"page-selected"),onClick:()=>{e.setPageIndex(t-1),l(),c()},children:[f===t&&y.jsx(Ve,{className:xe["check-icon"],height:24,width:24}),y.jsxs("span",{children:[s?"Side":"Page"," ",t]})]},t)))})}),y.jsx(d,{title:1===f?"":s?"Forrige side":"Previous Page",children:y.jsx("div",{children:y.jsx(Ee,{size:"small",variant:"outlined",onClick:()=>{e.previousPage(),c()},disabled:!e.getCanPreviousPage(),style:{minWidth:40,width:40},children:y.jsx(Fe,{height:24,width:24})})})}),y.jsx(d,{title:f===p?"":s?"Neste side":"Next Page",children:y.jsx("div",{children:y.jsx(Ee,{size:"small",variant:"outlined",onClick:()=>{e.nextPage(),c()},disabled:!e.getCanNextPage(),style:{minWidth:40,width:40},children:y.jsx(_e,{height:24,width:24})})})})]}):null}function Me({table:e,styledTableProps:t}){var n;return t.hideFooter?null:y.jsxs("div",{className:pe["table-footer"],children:[null==(n=t.footer)?void 0:n.call(t,e),y.jsx(Pe,{table:e,locale:t.locale||"en"})]})}const Ie=t=>{const{columns:n,data:o,initialState:l,pageSize:r,enableRowSelection:i,tableInstanceRef:a,...s}=t,u=function(t){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[o]=e.useState((()=>({current:ae(n)}))),[l,r]=e.useState((()=>o.current.initialState));return o.current.setOptions((e=>({...e,...t,state:{...l,...t.state},onStateChange:e=>{r(e),null==t.onStateChange||t.onStateChange(e)}}))),o.current}({columns:n,data:o,initialState:{pagination:{pageIndex:0,pageSize:r||50},columnVisibility:{...null==l?void 0:l.columnVisibility,[m]:!1},...l},enableRowSelection:i,getCoreRowModel:e=>V((()=>[e.options.data]),(t=>{const n={rows:[],flatRows:[],rowsById:{}},o=function(t,l,r){void 0===l&&(l=0);const i=[];for(let s=0;s<t.length;s++){const u=se(e,e._getRowId(t[s],s,r),t[s],s,l,void 0,null==r?void 0:r.id);var a;n.flatRows.push(u),n.rowsById[u.id]=u,i.push(u),e.options.getSubRows&&(u.originalSubRows=e.options.getSubRows(t[s],s),null!=(a=u.originalSubRows)&&a.length&&(u.subRows=o(u.originalSubRows,l+1,u)))}return i};return n.rows=o(t),n}),{key:"development"===process.env.NODE_ENV&&"getRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getExpandedRowModel:e=>V((()=>[e.getState().expanded,e.getPreExpandedRowModel(),e.options.paginateExpandedRows]),((e,t,n)=>t.rows.length&&(!0===e||Object.keys(e??{}).length)&&n?ge(t):t),{key:"development"===process.env.NODE_ENV&&"getExpandedRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable}}),getFilteredRowModel:e=>V((()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter]),((t,n,o)=>{if(!t.rows.length||(null==n||!n.length)&&!o){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const l=[],r=[];(n??[]).forEach((t=>{var n;const o=e.getColumn(t.id);if(!o)return;const r=o.getFilterFn();r?l.push({id:t.id,filterFn:r,resolvedValue:null!=(n=null==r.resolveFilterValue?void 0:r.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${o.id}.`)}));const i=n.map((e=>e.id)),a=e.getGlobalFilterFn(),s=e.getAllLeafColumns().filter((e=>e.getCanGlobalFilter()));let u,d;o&&a&&s.length&&(i.push("__global__"),s.forEach((e=>{var t;r.push({id:e.id,filterFn:a,resolvedValue:null!=(t=null==a.resolveFilterValue?void 0:a.resolveFilterValue(o))?t:o})})));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},l.length)for(let e=0;e<l.length;e++){u=l[e];const t=u.id;n.columnFilters[t]=u.filterFn(n,t,u.resolvedValue,(e=>{n.columnFiltersMeta[t]=e}))}if(r.length){for(let e=0;e<r.length;e++){d=r[e];const t=d.id;if(d.filterFn(n,t,d.resolvedValue,(e=>{n.columnFiltersMeta[t]=e}))){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return de(t.rows,(e=>{for(let t=0;t<i.length;t++)if(!1===e.columnFilters[i[t]])return!1;return!0}),e)}),{key:"development"===process.env.NODE_ENV&&"getFilteredRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getSortedRowModel:e=>V((()=>[e.getState().sorting,e.getPreSortedRowModel()]),((t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const o=e.getState().sorting,l=[],r=o.filter((t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()})),i={};r.forEach((t=>{const n=e.getColumn(t.id);n&&(i[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})}));const a=e=>{const t=[...e];return t.sort(((e,t)=>{for(let o=0;o<r.length;o+=1){var n;const l=r[o],a=i[l.id],s=null!=(n=null==l?void 0:l.desc)&&n;let u=0;if(a.sortUndefined){const n=void 0===e.getValue(l.id),o=void 0===t.getValue(l.id);(n||o)&&(u=n&&o?0:n?a.sortUndefined:-a.sortUndefined)}if(0===u&&(u=a.sortingFn(e,t,l.id)),0!==u)return s&&(u*=-1),a.invertSorting&&(u*=-1),u}return e.index-t.index})),t.forEach((e=>{var t;l.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=a(e.subRows))})),t};return{rows:a(n.rows),flatRows:l,rowsById:n.rowsById}}),{key:"development"===process.env.NODE_ENV&&"getSortedRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}}),getPaginationRowModel:e=>V((()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded]),((t,n)=>{if(!n.rows.length)return n;const{pageSize:o,pageIndex:l}=t;let{rows:r,flatRows:i,rowsById:a}=n;const s=o*l,u=s+o;let d;r=r.slice(s,u),d=e.options.paginateExpandedRows?{rows:r,flatRows:i,rowsById:a}:ge({rows:r,flatRows:i,rowsById:a}),d.flatRows=[];const g=e=>{d.flatRows.push(e),e.subRows.length&&e.subRows.forEach(g)};return d.rows.forEach(g),d}),{key:"development"===process.env.NODE_ENV&&"getPaginationRowModel",debug:()=>{var t;return null!=(t=e.options.debugAll)?t:e.options.debugTable}}),getRowId:s.getRowId||((e,t,n)=>n?[n.id,e.id].join("."):e.id.toString()),defaultColumn:t.enableResizing?{size:void 0}:void 0,...s});return a&&(a.current=u),{table:u}},Ne=({dataTest:e,...t})=>y.jsx(c,{...t,"data-test":e,sx:{...t.sx,"&.MuiCheckbox-root":{color:"var(--colors-delta-500) !important"},"&.MuiCheckbox-root.Mui-checked":{color:"var(--colors-gama-500) !important"},"&.MuiCheckbox-root.MuiCheckbox-indeterminate":{color:"var(--colors-gama-500) !important"},"&.MuiCheckbox-root.Mui-disabled":{color:"var(--colors-delta-200) !important"},"&.MuiCheckbox-root .PrivateSwitchBase-input":{height:"100% !important",width:"100% !important"}}});function De(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2"})})}function Oe({tableData:e,actions:t}){const{anchorEl:n,open:o,handleClose:l,handleOpen:r}=Ce(),i=t(e.row).filter((e=>!e.hide));return y.jsx("div",{className:"flex justify-center items-center w-[42px]",children:i.length?y.jsxs(y.Fragment,{children:[y.jsx(Ee,{variant:"text",onClick:e=>{e.stopPropagation(),e.preventDefault(),r(e)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},sx:{minWidth:"20px"},children:y.jsx(De,{className:"text-delta-800",width:20,height:20})}),y.jsx(g,{open:o,anchorEl:n,onClose:l,onClick:l,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:t(e.row).filter((e=>!e.hide)).map(((t,n)=>y.jsx(p,{className:t.className,disabled:t.disabled,onClick:()=>{var n;null==(n=t.onClick)||n.call(t,e.row)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},children:t.label},n)))})]}):null})}function je(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M16 9V4h2V2H6v2h2v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1l1-1v-7H19v-2c-1.66 0-3-1.34-3-3"})})}function ke({headerData:e}){const{anchorEl:t,open:n,handleClose:o,handleOpen:l}=Ce();return y.jsxs("div",{className:"w-full flex items-center justify-end ",children:[y.jsx("div",{className:"px-2.5 h-[30px] flex items-center justify-center cursor-pointer",onClick:l,children:y.jsx(je,{className:"text-delta-500 hover:text-delta-600 min-w-[20px] min-h-[20px]"})}),y.jsx(g,{anchorEl:t,anchorOrigin:{horizontal:"left",vertical:"bottom"},open:n,onClose:o,children:e.table.getAllLeafColumns().filter((e=>e.getCanHide()&&e.id!==f)).map((e=>e.columnDef.header?y.jsxs(p,{onClick:()=>e.toggleVisibility(!e.getIsVisible()),children:[y.jsx(Ne,{size:"small",dataTest:"test",disableRipple:!0,className:"p-0 pr-2",checked:e.getIsVisible()}),"string"==typeof e.columnDef.header?e.columnDef.header:e.id]},e.id):null))})]})}const Ae=e=>{const{columns:t,actions:n,customActionsNode:o,headerPin:l=!0,enableRowSelection:r,expandArrow:i}=e;!t.find((e=>"actions"===e.id))&&(n||o||l)&&t.push(function(e){const{headerPin:t,actions:n,customActionsNode:o}=e;return{id:"actions",enableHiding:!1,enableSorting:!1,accessorFn:e=>e,header:e=>t?y.jsx(ke,{headerData:e}):null,cell:e=>n||o?y.jsxs("div",{className:"flex items-center justify-end",children:[o&&y.jsx("div",{className:"mr-1",children:null==o?void 0:o(e)}),n&&y.jsx(Oe,{tableData:e,actions:n})]}):null,size:50}}({headerPin:l,actions:n,customActionsNode:o})),r&&!t.find((e=>e.id===m))&&t.unshift({id:m,minSize:40,maxSize:40,size:40,header:({table:e})=>y.jsx("div",{className:"w-[25px]",children:y.jsx(Ne,{size:"small",dataTest:"cell-select-all",checked:e.getIsAllRowsSelected(),indeterminate:e.getIsSomeRowsSelected(),onChange:e.getToggleAllRowsSelectedHandler()})}),cell:({cell:e})=>y.jsx("div",{className:"w-[25px]",children:y.jsx(Ne,{size:"small",dataTest:"cell-select",checked:e.row.getIsSelected(),disabled:!e.row.getCanSelect(),onClick:e=>e.stopPropagation(),onChange:e.row.getToggleSelectedHandler()})})}),i&&!t.find((e=>e.id===h))&&t.unshift({id:h,minSize:50,maxSize:50,size:50,enableHiding:!1,enableSorting:!1,header:()=>null,cell:({cell:e})=>{const t=e.row.getIsExpanded();return e.row.getCanExpand()?y.jsx("span",{className:"flex h-fit w-full outline-none focus:outline-none items-center justify-center",onClick:()=>e.row.getToggleExpandedHandler()(),children:t?y.jsx(Re,{width:24,height:24}):y.jsx(ye,{width:24,height:24})}):null}})};function ze(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"m7 14l5-5l5 5z"})})}function Le(e){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",...e,children:y.jsx("path",{fill:"currentColor",d:"m7 10l5 5l5-5z"})})}const He=e=>{var t;const{header:n,enableResizing:o,element:l}=e;let r=n.getSize();if(!o){r&&(r=`${r}px`);const e="actions"===(null==(t=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}(n.headerGroup.headers))?void 0:t.id),o=n.headerGroup.headers[n.headerGroup.headers.length-(e?2:1)];return((null==o?void 0:o.id)===n.id||!r)&&(r="100%"),{width:r||n.column.columnDef.size,maxWidth:r||n.column.columnDef.maxSize,minWidth:r||n.column.columnDef.minSize}}const i=n.column.columnDef.size,a=n.column.columnDef.minSize;return{width:i,maxWidth:n.column.columnDef.maxSize,minWidth:a}};function Te({styledTableProps:e,header:t,tableCanResize:n=!1}){const{hideHeader:o=!1,enableResizing:l=!1}=e,i=r(null);return y.jsx("th",{ref:i,colSpan:t.colSpan,className:me(pe["t-cell"],"actions"===t.column.id&&pe["t-cell__actions"]),style:He({enableResizing:l,header:t,element:i.current}),children:y.jsxs("div",{className:me("flex items-center justify-left",o?pe["hide-table-header"]:pe["show-table-header"],t.column.getCanSort()&&pe["sortable-column"],t.column.columnDef.className),onClick:t.column.getToggleSortingHandler(),children:[ce(t.column.columnDef.header,t.getContext()),{asc:y.jsx(ze,{className:pe["sort-icon"]}),desc:y.jsx(Le,{className:pe["sort-icon"]})}[t.column.getIsSorted()]??null,n&&t.column.getCanResize()&&![m,h,v].includes(t.column.id)&&y.jsx("div",{onDoubleClick:()=>t.column.resetSize(),onMouseDown:t.getResizeHandler(),onTouchStart:t.getResizeHandler(),className:`${pe.resizer} ${t.column.getIsResizing()?pe.isResizing:""}`})]})},t.id)}function Ge({table:e,styledTableProps:t,tableCanResize:n}){const{stickyHeader:o=!1,hideHeader:l=!1}=t;return t.loading?null:y.jsx("thead",{className:me(pe["table-header"],l&&pe["hide-table-header"]),style:o&&{position:"sticky",top:-.2}||{},children:e.getHeaderGroups().map((e=>y.jsx("tr",{children:e.headers.map((e=>y.jsx(Te,{styledTableProps:t,header:e,tableCanResize:n},e.column.id)))},e.id)))})}const Be=e=>{const{className:t,height:n}=e;Ae(e);const{table:o}=Ie(e),l=a((()=>{var t,n;if(!e.enableColumnResizing)return;const l=o.getFlatHeaders(),r={};for(let e=0;e<l.length;e++){const t=l[e];r[`--header-${t.id}-size`]=t.getSize(),r[`--col-${t.column.id}-size`]=t.column.getSize()}return null==(t=e.getTableState)||t.call(e,o.getState()),null==(n=e.getColumnSizing)||n.call(e,o.getState().columnSizing),r}),[e.enableColumnResizing,o.getState().columnSizingInfo,o.getState().columnSizing]);return y.jsxs("div",{className:pe["asma-ui-table-styled-table"],children:[y.jsx("div",{className:me(pe["table-wrapper"],t),style:{height:n},children:y.jsxs("table",{className:pe["styled-table"],style:{...l},children:[y.jsx(Ge,{table:o,styledTableProps:e,tableCanResize:!!e.enableColumnResizing}),l?y.jsx(y.Fragment,{children:o.getState().columnSizingInfo.isResizingColumn?y.jsx($e,{table:o,styledTableProps:e}):y.jsx(Se,{table:o,styledTableProps:e})}):y.jsx(Se,{table:o,styledTableProps:e})]})}),y.jsx(Me,{table:o,styledTableProps:e})]})},$e=i(Se,((e,t)=>e.table.options.data===t.table.options.data));export{v as ACTIONS_COLUMN_ID,h as EXPAND_COLUMN_ID,$e as MemoizedTableBody,m as SELECT_COLUMN_ID,Be as StyledTable,ue as createColumnHelper};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type StyledTableProps, type TableState } from '../types';
2
3
  import { TableBody } from './TableBody';
3
4
  import type { ColumnSizingState } from '../types';
@@ -12,7 +13,7 @@ import type { ColumnSizingState } from '../types';
12
13
  export declare const StyledTable: <TData extends {
13
14
  id: string | number;
14
15
  }, TCustomData = Record<string, unknown>>(props: StyledTableProps<TData, TCustomData> & {
15
- getColumnSizing?: ((column_sizing: ColumnSizingState) => void) | undefined;
16
- getTableState?: ((tableState: TableState) => void) | undefined;
16
+ getColumnSizing?: (column_sizing: ColumnSizingState) => void;
17
+ getTableState?: (tableState: TableState) => void;
17
18
  }) => JSX.Element;
18
19
  export declare const MemoizedTableBody: typeof TableBody;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { type ButtonProps } from '@mui/material';
2
3
  export declare const StyledButton: (props: ButtonProps) => JSX.Element;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { type MenuItemProps } from '@mui/material';
2
3
  export declare const StyledMenuItem: (props: MenuItemProps) => JSX.Element;
@@ -8,8 +8,8 @@ declare const _default: {
8
8
  screens: {
9
9
  [x: number]: string;
10
10
  length: number;
11
- toString: (() => string) & (() => string);
12
- toLocaleString: (() => string) & (() => string);
11
+ toString(): string;
12
+ toLocaleString(): string;
13
13
  pop(): string | undefined;
14
14
  push(...items: string[]): number;
15
15
  concat(...items: ConcatArray<string>[]): string[];
@@ -52,6 +52,11 @@ declare const _default: {
52
52
  findLast<S_3 extends string>(predicate: (value: string, index: number, array: string[]) => value is S_3, thisArg?: any): S_3 | undefined;
53
53
  findLast(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string | undefined;
54
54
  findLastIndex(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): number;
55
+ toReversed(): string[];
56
+ toSorted(compareFn?: ((a: string, b: string) => number) | undefined): string[];
57
+ toSpliced(start: number, deleteCount: number, ...items: string[]): string[];
58
+ toSpliced(start: number, deleteCount?: number | undefined): string[];
59
+ with(index: number, value: string): string[];
55
60
  [Symbol.iterator](): IterableIterator<string>;
56
61
  [Symbol.unscopables]: {
57
62
  [x: number]: boolean | undefined;
@@ -90,6 +95,10 @@ declare const _default: {
90
95
  at?: boolean | undefined;
91
96
  findLast?: boolean | undefined;
92
97
  findLastIndex?: boolean | undefined;
98
+ toReversed?: boolean | undefined;
99
+ toSorted?: boolean | undefined;
100
+ toSpliced?: boolean | undefined;
101
+ with?: boolean | undefined;
93
102
  [Symbol.iterator]?: boolean | undefined;
94
103
  readonly [Symbol.unscopables]?: boolean | undefined;
95
104
  };
package/package.json CHANGED
@@ -3,12 +3,10 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.0",
6
+ "version": "1.0.2",
7
7
  "type": "module",
8
8
  "files": [
9
- "dist/**/*",
10
- "dist/style.css",
11
- "tw-configs/**/*"
9
+ "dist/**/*"
12
10
  ],
13
11
  "keywords": [],
14
12
  "author": "asma-team",
@@ -113,8 +111,6 @@
113
111
  "exports": {
114
112
  ".": {
115
113
  "import": "./dist/asma-ui-table.es.js"
116
- },
117
- "./dist/style.css": "./dist/style.css",
118
- "./tw-configs/twConfigs.json": "./tw-configs/twConfigs.json"
114
+ }
119
115
  }
120
116
  }
@@ -1,111 +0,0 @@
1
- {
2
- "fontFamily": {
3
- "roboto": ["Roboto"]
4
- },
5
- "colors": {
6
- "inherit": "inherit",
7
- "color-active-component": "var(--colors-active-component)",
8
- "alpha-100": "var(--colors-alpha-100)",
9
- "alpha-500": "var(--colors-alpha-500)",
10
- "alpha-600": "var(--colors-alpha-600)",
11
- "alpha-700": "var(--colors-alpha-700)",
12
- "beta-100": "var(--colors-beta-100)",
13
- "beta-500": "var(--colors-beta-500)",
14
- "beta-600": "var(--colors-beta-600)",
15
- "beta-700": "var(--colors-beta-700)",
16
- "gama-25": "var(--colors-gama-25)",
17
- "gama-50": "var(--colors-gama-50)",
18
- "gama-100": "var(--colors-gama-100)",
19
- "gama-200": "var(--colors-gama-200)",
20
- "gama-300": "var(--colors-gama-300)",
21
- "gama-400": "var(--colors-gama-400)",
22
- "gama-500": "var(--colors-gama-500)",
23
- "gama-600": "var(--colors-gama-600)",
24
- "gama-700": "var(--colors-gama-700)",
25
- "gama-800": "var(--colors-gama-800)",
26
- "delta-10": "var(--colors-delta-10)",
27
- "delta-50": "var(--colors-delta-50)",
28
- "delta-100": "var(--colors-delta-100)",
29
- "delta-200": "var(--colors-delta-200)",
30
- "delta-300": "var(--colors-delta-300)",
31
- "delta-400": "var(--colors-delta-400)",
32
- "delta-500": "var(--colors-delta-500)",
33
- "delta-600": "var(--colors-delta-600)",
34
- "delta-700": "var(--colors-delta-700)",
35
- "delta-800": "var(--colors-delta-800)",
36
- "delta-900": "var(--colors-delta-900)",
37
- "delta-9000": "var(--colors-gray-9000)",
38
- "sigma-700": "var(--colors-sigma-700)",
39
- "theta-100": "var(--colors-theta-100)",
40
- "theta-200": "var(--colors-theta-200)",
41
- "theta-300": "var(--colors-theta-300)",
42
- "theta-400": "var(--colors-theta-400)",
43
- "theta-500": "var(--colors-theta-500)",
44
- "theta-600": "var(--colors-theta-600)",
45
- "theta-700": "var(--colors-theta-700)",
46
- "theta-800": "var(--colors-theta-800)",
47
- "theta-hover": "var(--colors-theta-hover)",
48
- "btn-bg": "var(--colors-btn-bg-standart)",
49
- "btn-bg-active": "var(--colors-btn-bg-active)",
50
- "btn-bg-hover": "var(--colors-btn-bg-hover)",
51
- "btn-bg-disabled": "var(--colors-btn-bg-disabled)",
52
- "btn-bg-danger": "var(--colors-btn-bg-danger)",
53
- "btn-bg-danger-active": "var(--colors-btn-bg-danger-active)",
54
- "btn-task-status-bg": "var(--colors-btn-task-status-bg)",
55
- "btn-bg-mini-action": "var(--colors-btn-bg-mini-action)",
56
- "btn-bg-mini-action-hover": "var(--colors-btn-bg-mini-action-hover)",
57
-
58
- "chat-ticket-message-bg": "var(--colors-chat-ticket-message-bg)",
59
- "colors-topbar-text": "var(--colors-topbar-text)",
60
- "custom-grey-01": "hsl(var(--color-cardea--grey-01) / <alpha-value>)",
61
- "custom-grey-02": "hsl(var(--color-cardea--grey-02) / <alpha-value>)",
62
- "custom-grey-03": "hsl(var(--color-cardea--grey-03) / <alpha-value>)",
63
- "custom-grey-04": "hsl(var(--color-cardea--grey-04) / <alpha-value>)",
64
- "custom-grey-06": "hsl(var(--color-cardea--grey-06) / <alpha-value>)"
65
- },
66
- "boxShadow": {
67
- "ash": "-1px 8px 18px -20px black",
68
- "mui": "0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12)"
69
- },
70
- "animation": {
71
- "slide-in": "slide-in 0.3s linear",
72
- "slide-out": "slide-out 0.3s linear",
73
- "opacity-in": "opacity-in 0.1s linear",
74
- "opacity-in-5": "opacity-in 0.5s linear",
75
- "opacity-appear-3": "opacity-appear 0.3s linear",
76
- "opacity-out": "opacity-out 0.3s linear"
77
- },
78
- "keyframes": {
79
- "slide-in": {
80
- "0%": { "margin": "0 0 0 -320px" },
81
- "100%": { "margin": "0" }
82
- },
83
- "slide-out": {
84
- "0%": { "margin": "0" },
85
- "100%": { "margin": "0 0 0 -320px" }
86
- },
87
- "opacity-in": {
88
- "0%": {
89
- "opacity": "0",
90
- "height": "100%"
91
- },
92
- "100%": {
93
- "opacity": "1",
94
- "height": "100%"
95
- }
96
- },
97
- "opacity-appear": {
98
- "0%": {
99
- "opacity": "0"
100
- },
101
- "100%": {
102
- "opacity": "1"
103
- }
104
- },
105
- "opacity-out": {
106
- "0%": { "opacity": "1", "height": "100%" },
107
- "60%": { "opacity": "1", "height": "100%" },
108
- "100%": { "opacity": "0", "height": "100%" }
109
- }
110
- }
111
- }