asma-ui-table 1.0.7 → 1.0.8
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/asma-ui-table.es.js +2 -2
- package/package.json +1 -1
package/dist/asma-ui-table.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode("._asma-ui-table-styled-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode("._asma-ui-table-styled-table_2axop_1 *,._asma-ui-table-styled-table_2axop_1 *:after,._asma-ui-table-styled-table_2axop_1 *:before{box-sizing:border-box;-webkit-box-sizing:border-box}._asma-ui-table-styled-table_2axop_1 ._table-wrapper_2axop_7{overflow:auto;width:100%}._asma-ui-table-styled-table_2axop_1 ._styled-table_2axop_11{display:table;margin:0;border-collapse:separate;border-spacing:0 .5px;max-width:inherit;width:100%}._asma-ui-table-styled-table_2axop_1 ._styled-table_2axop_11 ._tbody_2axop_19{display:table-row-group;vertical-align:middle;max-width:inherit}._asma-ui-table-styled-table_2axop_1 ._loading-icon_2axop_24{position:absolute;top:50%;left:50%;z-index:10}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30{margin-top:1px;display:table-row;border-style:solid;border-left-width:.5px;border-right-width:.5px;border-top-width:.5px;border-bottom-width:.5px;border-left-color:transparent;border-right-color:transparent;border-top-color:var(--colors-delta-300)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:hover{background-color:var(--colors-gama-25);cursor:pointer}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:hover ._action-cell_2axop_46,._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:hover ._fixed-cell_2axop_49{background-color:var(--colors-gama-25)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus{background-color:var(--colors-gama-50)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus ._action-cell_2axop_46{background-color:var(--colors-gama-50)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus ._fixed-cell_2axop_49{background-color:var(--colors-gama-50)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus ._t-cell_2axop_61{border-top:.5px solid var(--colors-gama-500);border-bottom:.5px solid var(--colors-gama-500)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus ._t-cell_2axop_61:first-child{border-left:.5px solid var(--colors-gama-500)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus ._t-cell_2axop_61:last-child{border-right:.5px solid var(--colors-gama-500)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:focus-visible{outline:none}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:last-child{border-bottom-color:transparent}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30:first-child{border-top-color:transparent}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._t-cell_2axop_61{overflow-wrap:break-word;vertical-align:middle;font-size:14px;line-height:20px;color:var(--colors-delta-900);display:table-cell;white-space:pre-wrap;padding:0 5px;border-top:.5px solid transparent;border-bottom:.5px solid var(--colors-delta-300)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._t-cell_2axop_61:first-child{border-left:.5px solid transparent}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._t-cell_2axop_61:last-child{border-right:.5px solid transparent}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._action-cell_2axop_46{height:100%;position:sticky;right:0px;z-index:1}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._action-cell_2axop_46._selected_2axop_107{background-color:var(--colors-gama-50)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._action-cell_2axop_46._shadowed_2axop_110{box-shadow:-15px 0 15px #0000001a}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._fixed-cell_2axop_49{height:100%;position:sticky;left:0;z-index:1;box-shadow:15px 0 15px #0000001a}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30 ._fixed-cell_2axop_49._selected_2axop_107,._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30._selected_2axop_107{background-color:var(--colors-gama-50)}._asma-ui-table-styled-table_2axop_1 ._t-row_2axop_30._is-loading_2axop_126{opacity:.5}._asma-ui-table-styled-table_2axop_1 ._action-cell-default-background_2axop_129,._asma-ui-table-styled-table_2axop_1 ._fixed-cell-default-background_2axop_132{background-color:#fff}._asma-ui-table-styled-table_2axop_1 tr._no-rows-overlay_2axop_135{height:112px}._asma-ui-table-styled-table_2axop_1 tr._no-rows-overlay_2axop_135 td{font-size:.875rem;line-height:1.25rem;text-align:center;vertical-align:middle}._asma-ui-table-styled-table_2axop_1 ._hide-table-header_2axop_144{height:0px;opacity:0}._asma-ui-table-styled-table_2axop_1 ._show-table-header_2axop_148{position:relative;height:30px;opacity:1}._asma-ui-table-styled-table_2axop_1 ._sortable-column_2axop_153{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}._asma-ui-table-styled-table_2axop_1 ._resizer_2axop_157{position:absolute;top:0;height:100%;right:0;width:5px;background:var(--colors-delta-300);cursor:col-resize;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none}._asma-ui-table-styled-table_2axop_1 ._resizer_2axop_157._isResizing_2axop_168{background:var(--colors-gama-500);opacity:1}@media (hover: hover){._asma-ui-table-styled-table_2axop_1 ._resizer_2axop_157{opacity:0}._asma-ui-table-styled-table_2axop_1 *:hover>._resizer_2axop_157{opacity:1}}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180{display:table-header-group;z-index:49;background-color:#fcfcfd;cursor:default}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180 ._t-cell_2axop_61{text-transform:uppercase;background-color:transparent;font-size:10px;font-weight:600;text-align:start;color:var(--colors-delta-500);white-space:pre-wrap;padding:0 5px;border-top:.5px solid var(--colors-delta-300);border-bottom:.5px solid var(--colors-delta-300)}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180 ._t-cell_2axop_61._t-cell__actions_2axop_201{position:sticky;right:0;background-color:#fcfcfd}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180 ._t-cell_2axop_61._t-cell__actions_2axop_201._shadowed_2axop_110{box-shadow:-15px 0 15px #0000001a}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180 ._t-cell_2axop_61._t-cell__fixed_2axop_209{position:sticky;left:0;background-color:#fcfcfd;z-index:160;box-shadow:15px 0 15px #0000001a}._asma-ui-table-styled-table_2axop_1 ._table-header_2axop_180 ._sort-icon_2axop_216{color:var(--colors-delta-800)}._asma-ui-table-styled-table_2axop_1 ._table-footer_2axop_219{display:flex;width:100%;gap:8px;background-color:transparent;flex-direction:row;padding-top:4px;padding-bottom:4px;align-items:center;justify-content:flex-end}._table-pagination_k2a41_1{display:flex;width:-moz-fit-content;width:fit-content;gap:8px;background-color:transparent;flex-direction:row;padding-top:4px;padding-bottom:4px;align-items:center;justify-content:flex-end}._table-pagination__pages-list_k2a41_13{overflow:auto;width:160px;max-height:200px}._table-pagination__pages-list_k2a41_13 ._table-pagination__pages-list__page_k2a41_18{height:36px;position:relative;display:flex;align-items:center;padding-left:40px;cursor:pointer}._table-pagination__pages-list_k2a41_13 ._table-pagination__pages-list__page_k2a41_18:hover{background-color:var(--colors-delta-30)}._table-pagination__pages-list_k2a41_13 ._table-pagination__pages-list__page_k2a41_18._page-selected_k2a41_29{background-color:var(--colors-gama-50)}._table-pagination__pages-list_k2a41_13 ._table-pagination__pages-list__page_k2a41_18 ._check-icon_k2a41_32{position:absolute;left:8px;top:4px;color:var(--colors-gama-500)}")),document.head.appendChild(a)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
2
|
import*as e from"react";import t,{useMemo as n,Fragment as o,useState as l,useCallback as r,useRef as i,memo as a}from"react";import{Skeleton as s,Button as u,Tooltip as d,Popover as g,Checkbox as c,MenuItem as p}from"@mui/material";const f=e=>void 0!==e.component,m="select",h="expand-column-id",v="actions";var b,w={exports:{}},S={};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -38,4 +38,4 @@ import*as e from"react";import t,{useMemo as n,Fragment as o,useState as l,useCa
|
|
|
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_d651u_1","table-wrapper":"_table-wrapper_d651u_7","styled-table":"_styled-table_d651u_11",tbody:"_tbody_d651u_19","loading-icon":"_loading-icon_d651u_24","t-row":"_t-row_d651u_30","action-cell":"_action-cell_d651u_46","fixed-cell":"_fixed-cell_d651u_49","t-cell":"_t-cell_d651u_61",selected:"_selected_d651u_106",shadowed:"_shadowed_d651u_109","is-loading":"_is-loading_d651u_124","action-cell-default-background":"_action-cell-default-background_d651u_127","fixed-cell-default-background":"_fixed-cell-default-background_d651u_130","no-rows-overlay":"_no-rows-overlay_d651u_133","hide-table-header":"_hide-table-header_d651u_142","show-table-header":"_show-table-header_d651u_146","sortable-column":"_sortable-column_d651u_151",resizer:"_resizer_d651u_155",isResizing:"_isResizing_d651u_166","table-header":"_table-header_d651u_178","t-cell__actions":"_t-cell__actions_d651u_199","t-cell__fixed":"_t-cell__fixed_d651u_207","sort-icon":"_sort-icon_d651u_214","table-footer":"_table-footer_d651u_217"};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:l}){const{focusable:r,loading:i,getRowClassName:a,rowHeight:s,onRowClick:u,expandArrow:d,tdClassName:g,customSubRowData:c,renderSubRows:p}=e,f=t.getVisibleCells(),m=n((()=>f.map(((e,t)=>({...e,left:f.slice(0,t).reduce(((e,t)=>e+(t.column.getSize()||0)),0)})))),[f]),h=n((()=>m.some((e=>!0===e.column.columnDef.fixedLeft))),[m]);return y.jsxs(o,{children:[y.jsx("tr",{"data-index":l,"data-test":t.id,id:t.id,tabIndex:r?-1:void 0,className:me(pe["t-row"],i&&pe["is-loading"],(t.getIsExpanded()||t.getIsSelected())&&pe.selected,null==a?void 0:a(t)),style:{height:s?`${s}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()&&!d&&t.getToggleExpandedHandler()(),null==(n=document.getElementById(t.id))||n.focus();const l="Range"===(null==(o=window.getSelection())?void 0:o.type);u&&!l&&u(e,t)},children:m.map((e=>{const n="actions"===e.column.id,o=e.column.columnDef.fixedLeft;return y.jsx("td",{className:me(pe["t-cell"],g,n&&pe["action-cell"],n&&h&&pe.shadowed,n&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,n&&(null!=a&&a(t)?null==a?void 0:a(t):pe["action-cell-default-background"]),o&&pe["fixed-cell"],o&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,o&&(null!=a&&a(t)?null==a?void 0:a(t):pe["fixed-cell-default-background"])),style:o?{left:e.left}:{},children:ce(e.column.columnDef.cell,e.getContext())},e.id)}))}),t.getIsExpanded()&&y.jsx(y.Fragment,{children:c&&p&&p({rows:c.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(x,{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]=l(null),n=!!e,o=r((e=>{t(e.currentTarget)}),[]);return{open:n,handleClose:r((()=>{t(null)}),[]),handleOpen:o,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 xe(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 _e={"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"},Fe=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 Ee(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:r}=Ce(),a=i(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:_e["table-pagination"],children:[y.jsx(d,{title:s?"Nåværende side":"Current Page",children:y.jsx("div",{children:y.jsxs(Fe,{size:"small",variant:"outlined",style:{minWidth:"140px",height:32},onClick:e=>{r(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:_e["table-pagination__pages-list"],children:m.map((t=>y.jsxs("div",{className:me(_e["table-pagination__pages-list__page"],f===t&&"page-selected"),onClick:()=>{e.setPageIndex(t-1),l(),c()},children:[f===t&&y.jsx(Ve,{className:_e["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(Fe,{size:"small",variant:"outlined",onClick:()=>{e.previousPage(),c()},disabled:!e.getCanPreviousPage(),style:{minWidth:40,width:40},children:y.jsx(Ee,{height:24,width:24})})})}),y.jsx(d,{title:f===p?"":s?"Neste side":"Next Page",children:y.jsx("div",{children:y.jsx(Fe,{size:"small",variant:"outlined",onClick:()=>{e.nextPage(),c()},disabled:!e.getCanNextPage(),style:{minWidth:40,width:40},children:y.jsx(xe,{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"})})}const Oe=e=>{var t;return y.jsx(p,{...e,classes:{root:me("px-3 py-2.5",null==(t=e.classes)?void 0:t.root),...e.classes}})};function je({tableData:e,actions:n}){const{anchorEl:o,open:l,handleClose:r,handleOpen:i}=Ce(),a=n(e.row);return y.jsx("div",{className:"flex justify-center items-center w-[42px]",children:a.length?y.jsxs(y.Fragment,{children:[y.jsx(Fe,{variant:"text",onClick:e=>{e.stopPropagation(),e.preventDefault(),i(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:l,anchorEl:o,onClose:r,onClick:r,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:n(e.row).map(((n,o)=>{if(f(n)){const l=n.component(e.row,r);return t.isValidElement(l)?y.jsx(t.Fragment,{children:l},o):null}return n.hide?null:y.jsx(Oe,{className:n.className,disabled:n.disabled,onClick:()=>{var t;null==(t=n.onClick)||t.call(n,e.row)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},children:n.label},o)}))})]}):null})}function ke(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 ze({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(ke,{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,sx:{"& .MuiPaper-root":{maxHeight:"calc(7 * 44px)",overflowY:"auto",scrollbarWidth:"thin"}},children:e.table.getAllLeafColumns().filter((e=>e.getCanHide()&&e.id!==m)).map((e=>e.columnDef.header?y.jsxs(Oe,{onClick:()=>e.toggleVisibility(!e.getIsVisible()),className:"h-[44px]",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(ze,{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(je,{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 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 14l5-5l5 5z"})})}function He(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 Ge=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,left:o,hasFixedLeftColumn:l}){const{hideHeader:r=!1,enableResizing:a=!1}=e,s=i(null);return y.jsx("th",{ref:s,colSpan:t.colSpan,className:me(pe["t-cell"],"actions"===t.column.id&&pe["t-cell__actions"],l&&"actions"===t.column.id&&pe.shadowed,!0===t.column.columnDef.fixedLeft&&pe["t-cell__fixed"]),style:{...Ge({enableResizing:a,header:t,element:s.current}),...t.column.columnDef.fixedLeft&&{left:o}},children:y.jsxs("div",{className:me("flex items-center justify-left",r?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(Le,{className:pe["sort-icon"]}),desc:y.jsx(He,{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 Be({table:e,styledTableProps:t,tableCanResize:n}){const{stickyHeader:o=!1,hideHeader:l=!1}=t;if(t.loading)return null;const r=e.getHeaderGroups().some((e=>e.headers.some((e=>!0===e.column.columnDef.fixedLeft))));return 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(((o,l)=>{const i=o.column.columnDef.fixedLeft,a=e.headers.slice(0,l).reduce(((e,t)=>e+(t.column.getSize()||0)),0);return y.jsx(Te,{styledTableProps:t,header:o,tableCanResize:n,left:i?a:0,hasFixedLeftColumn:r},o.column.id)}))},e.id)))})}const $e=e=>{const{className:t,height:o}=e;Ae(e);const{table:l}=Ie(e),r=n((()=>{var t,n;if(!e.enableColumnResizing)return;const o=l.getFlatHeaders(),r={};for(let e=0;e<o.length;e++){const t=o[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,l.getState()),null==(n=e.getColumnSizing)||n.call(e,l.getState().columnSizing),r}),[e.enableColumnResizing,l.getState().columnSizingInfo,l.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:o},children:y.jsxs("table",{className:pe["styled-table"],style:{...r},children:[y.jsx(Be,{table:l,styledTableProps:e,tableCanResize:!!e.enableColumnResizing}),r?y.jsx(y.Fragment,{children:l.getState().columnSizingInfo.isResizingColumn?y.jsx(qe,{table:l,styledTableProps:e}):y.jsx(Se,{table:l,styledTableProps:e})}):y.jsx(Se,{table:l,styledTableProps:e})]})}),y.jsx(Me,{table:l,styledTableProps:e})]})},qe=a(Se,((e,t)=>e.table.options.data===t.table.options.data));export{v as ACTIONS_COLUMN_ID,h as EXPAND_COLUMN_ID,qe as MemoizedTableBody,m as SELECT_COLUMN_ID,$e as StyledTable,ue as createColumnHelper,f as isCustomAction};
|
|
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_2axop_1","table-wrapper":"_table-wrapper_2axop_7","styled-table":"_styled-table_2axop_11",tbody:"_tbody_2axop_19","loading-icon":"_loading-icon_2axop_24","t-row":"_t-row_2axop_30","action-cell":"_action-cell_2axop_46","fixed-cell":"_fixed-cell_2axop_49","t-cell":"_t-cell_2axop_61",selected:"_selected_2axop_107",shadowed:"_shadowed_2axop_110","is-loading":"_is-loading_2axop_126","action-cell-default-background":"_action-cell-default-background_2axop_129","fixed-cell-default-background":"_fixed-cell-default-background_2axop_132","no-rows-overlay":"_no-rows-overlay_2axop_135","hide-table-header":"_hide-table-header_2axop_144","show-table-header":"_show-table-header_2axop_148","sortable-column":"_sortable-column_2axop_153",resizer:"_resizer_2axop_157",isResizing:"_isResizing_2axop_168","table-header":"_table-header_2axop_180","t-cell__actions":"_t-cell__actions_2axop_201","t-cell__fixed":"_t-cell__fixed_2axop_209","sort-icon":"_sort-icon_2axop_216","table-footer":"_table-footer_2axop_219"};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:l}){const{focusable:r,loading:i,getRowClassName:a,rowHeight:s,onRowClick:u,expandArrow:d,tdClassName:g,customSubRowData:c,renderSubRows:p}=e,f=t.getVisibleCells(),m=n((()=>f.map(((e,t)=>({...e,left:f.slice(0,t).reduce(((e,t)=>e+(t.column.getSize()||0)),0)})))),[f]),h=n((()=>m.some((e=>!0===e.column.columnDef.fixedLeft))),[m]);return y.jsxs(o,{children:[y.jsx("tr",{"data-index":l,"data-test":t.id,id:t.id,tabIndex:r?-1:void 0,className:me(pe["t-row"],i&&pe["is-loading"],(t.getIsExpanded()||t.getIsSelected())&&pe.selected,null==a?void 0:a(t)),style:{height:s?`${s}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()&&!d&&t.getToggleExpandedHandler()(),null==(n=document.getElementById(t.id))||n.focus();const l="Range"===(null==(o=window.getSelection())?void 0:o.type);u&&!l&&u(e,t)},children:m.map((e=>{const n="actions"===e.column.id,o=e.column.columnDef.fixedLeft;return y.jsx("td",{className:me(pe["t-cell"],g,n&&pe["action-cell"],n&&h&&pe.shadowed,n&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,n&&(null!=a&&a(t)?null==a?void 0:a(t):pe["action-cell-default-background"]),o&&pe["fixed-cell"],o&&(t.getIsExpanded()||t.getIsSelected())&&pe.selected,o&&(null!=a&&a(t)?null==a?void 0:a(t):pe["fixed-cell-default-background"])),style:o?{left:e.left}:{},children:ce(e.column.columnDef.cell,e.getContext())},e.id)}))}),t.getIsExpanded()&&y.jsx(y.Fragment,{children:c&&p&&p({rows:c.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(x,{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]=l(null),n=!!e,o=r((e=>{t(e.currentTarget)}),[]);return{open:n,handleClose:r((()=>{t(null)}),[]),handleOpen:o,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 xe(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 _e={"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"},Fe=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 Ee(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:r}=Ce(),a=i(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:_e["table-pagination"],children:[y.jsx(d,{title:s?"Nåværende side":"Current Page",children:y.jsx("div",{children:y.jsxs(Fe,{size:"small",variant:"outlined",style:{minWidth:"140px",height:32},onClick:e=>{r(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:_e["table-pagination__pages-list"],children:m.map((t=>y.jsxs("div",{className:me(_e["table-pagination__pages-list__page"],f===t&&"page-selected"),onClick:()=>{e.setPageIndex(t-1),l(),c()},children:[f===t&&y.jsx(Ve,{className:_e["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(Fe,{size:"small",variant:"outlined",onClick:()=>{e.previousPage(),c()},disabled:!e.getCanPreviousPage(),style:{minWidth:40,width:40},children:y.jsx(Ee,{height:24,width:24})})})}),y.jsx(d,{title:f===p?"":s?"Neste side":"Next Page",children:y.jsx("div",{children:y.jsx(Fe,{size:"small",variant:"outlined",onClick:()=>{e.nextPage(),c()},disabled:!e.getCanNextPage(),style:{minWidth:40,width:40},children:y.jsx(xe,{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"})})}const Oe=e=>{var t;return y.jsx(p,{...e,classes:{root:me("px-3 py-2.5",null==(t=e.classes)?void 0:t.root),...e.classes}})};function je({tableData:e,actions:n}){const{anchorEl:o,open:l,handleClose:r,handleOpen:i}=Ce(),a=n(e.row);return y.jsx("div",{className:"flex justify-center items-center w-[42px]",children:a.length?y.jsxs(y.Fragment,{children:[y.jsx(Fe,{variant:"text",onClick:e=>{e.stopPropagation(),e.preventDefault(),i(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:l,anchorEl:o,onClose:r,onClick:r,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:n(e.row).map(((n,o)=>{if(f(n)){const l=n.component(e.row,r);return t.isValidElement(l)?y.jsx(t.Fragment,{children:l},o):null}return n.hide?null:y.jsx(Oe,{className:n.className,disabled:n.disabled,onClick:()=>{var t;null==(t=n.onClick)||t.call(n,e.row)},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onMouseUp:e=>{e.stopPropagation(),e.preventDefault()},children:n.label},o)}))})]}):null})}function ke(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 ze({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(ke,{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,sx:{"& .MuiPaper-root":{maxHeight:"calc(7 * 44px)",overflowY:"auto",scrollbarWidth:"thin"}},children:e.table.getAllLeafColumns().filter((e=>e.getCanHide()&&e.id!==m)).map((e=>e.columnDef.header?y.jsxs(Oe,{onClick:()=>e.toggleVisibility(!e.getIsVisible()),className:"h-[44px]",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(ze,{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(je,{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 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 14l5-5l5 5z"})})}function He(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 Ge=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,left:o,hasFixedLeftColumn:l}){const{hideHeader:r=!1,enableResizing:a=!1}=e,s=i(null);return y.jsx("th",{ref:s,colSpan:t.colSpan,className:me(pe["t-cell"],"actions"===t.column.id&&pe["t-cell__actions"],l&&"actions"===t.column.id&&pe.shadowed,!0===t.column.columnDef.fixedLeft&&pe["t-cell__fixed"]),style:{...Ge({enableResizing:a,header:t,element:s.current}),...t.column.columnDef.fixedLeft&&{left:o}},children:y.jsxs("div",{className:me("flex items-center justify-left",r?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(Le,{className:pe["sort-icon"]}),desc:y.jsx(He,{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 Be({table:e,styledTableProps:t,tableCanResize:n}){const{stickyHeader:o=!1,hideHeader:l=!1}=t;if(t.loading)return null;const r=e.getHeaderGroups().some((e=>e.headers.some((e=>!0===e.column.columnDef.fixedLeft))));return 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(((o,l)=>{const i=o.column.columnDef.fixedLeft,a=e.headers.slice(0,l).reduce(((e,t)=>e+(t.column.getSize()||0)),0);return y.jsx(Te,{styledTableProps:t,header:o,tableCanResize:n,left:i?a:0,hasFixedLeftColumn:r},o.column.id)}))},e.id)))})}const $e=e=>{const{className:t,height:o}=e;Ae(e);const{table:l}=Ie(e),r=n((()=>{var t,n;if(!e.enableColumnResizing)return;const o=l.getFlatHeaders(),r={};for(let e=0;e<o.length;e++){const t=o[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,l.getState()),null==(n=e.getColumnSizing)||n.call(e,l.getState().columnSizing),r}),[e.enableColumnResizing,l.getState().columnSizingInfo,l.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:o},children:y.jsxs("table",{className:pe["styled-table"],style:{...r},children:[y.jsx(Be,{table:l,styledTableProps:e,tableCanResize:!!e.enableColumnResizing}),r?y.jsx(y.Fragment,{children:l.getState().columnSizingInfo.isResizingColumn?y.jsx(qe,{table:l,styledTableProps:e}):y.jsx(Se,{table:l,styledTableProps:e})}):y.jsx(Se,{table:l,styledTableProps:e})]})}),y.jsx(Me,{table:l,styledTableProps:e})]})},qe=a(Se,((e,t)=>e.table.options.data===t.table.options.data));export{v as ACTIONS_COLUMN_ID,h as EXPAND_COLUMN_ID,qe as MemoizedTableBody,m as SELECT_COLUMN_ID,$e as StyledTable,ue as createColumnHelper,f as isCustomAction};
|