@finos/perspective-viewer-datagrid
Version:
Perspective datagrid plugin based on `regular-table`
15 lines (14 loc) • 43.8 kB
JavaScript
import"regular-table";var J=`regular-table{padding:0;margin:12px 0 0 12px;scrollbar-color:transparent transparent;scrollbar-width:thin;outline:none}regular-table:hover{scrollbar-color:rgba(0,0,0,.3) transparent}.sub-cell-scroll-enabled regular-table table tbody td,.sub-cell-scroll-enabled regular-table table thead th:not(.rt-group-corner){transform:translate(var(--regular-table--transform-x, 0px))}.sub-cell-scroll-enabled regular-table table tbody{transform:translateY(var(--regular-table--transform-y, 0px))}.sub-cell-scroll-enabled regular-table table tbody tr:first-child td,.sub-cell-scroll-enabled regular-table table tbody tr:first-child th{clip-path:polygon(0 var(--regular-table--clip-y, 0),0 200%,200% 200%,200% var(--regular-table--clip-y, 0))}.sub-cell-scroll-enabled regular-table table thead th.rt-group-corner{background:var(--plugin--background, white);z-index:1}.sub-cell-scroll-enabled regular-table table tbody tr td:first-of-type{clip-path:polygon(var(--regular-table--clip-x, 0) 0,var(--regular-table--clip-x, 0) 200%,200% 200%,200% 0)}.sub-cell-scroll-enabled regular-table table tbody tr:first-child td:first-of-type{clip-path:polygon(var(--regular-table--clip-x, 0) var(--regular-table--clip-y, 0),var(--regular-table--clip-x, 0) 200%,200% 200%,200% var(--regular-table--clip-y, 0))}regular-table{font-family:inherit}regular-table div[tabindex]{outline:none}regular-table>div{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden}regular-table th{text-align:center}regular-table thead tr:not(:last-child) th{overflow:hidden;max-width:0px}regular-table thead tr:last-child .rt-float,regular-table tbody .rt-float{text-align:right}regular-table thead .rt-integer,regular-table tbody .rt-integer{text-align:right}regular-table tbody th{text-align:left}regular-table span.rt-tree-container{display:flex;align-items:center;height:100%}regular-table thead .rt-string,regular-table tbody .rt-string,regular-table thead .rt-date,regular-table tbody .rt-date,regular-table thead .rt-datetime,regular-table tbody .rt-datetime{text-align:left}regular-table thead tr:last-child th{border-bottom:1px solid #eaedef}regular-table tbody tr:first-child td,regular-table tbody tr:first-child th{border-top:1px solid transparent!important}regular-table th{position:relative}regular-table tr th span.rt-tree-group{margin-left:5px;margin-right:15px;border-left:1px solid #eee;height:100%}regular-table td,regular-table th{white-space:nowrap;font-size:12px;padding:0 5px;height:19px}regular-table tr:hover td{background:#eee;opacity:1}regular-table tr:hover{color:#333}regular-table table *{box-sizing:border-box}regular-table table{position:absolute;overflow:hidden;color:#666;outline:none}regular-table span.rt-row-header-icon{color:#aaa;padding-right:4px;font-family:var(--button--font-family, "Material Icons")}regular-table span.rt-column-header-icon{font-size:10px;padding-left:3px;display:inline-block;width:10px;font-family:var(--button--font-family, "Material Icons")}regular-table span.rt-row-header-icon:hover{color:#1a7da1;text-shadow:0px 0px 3px #1a7da1}regular-table .rt-selected td{background-color:#eee}regular-table .rt-cell-clip{overflow:hidden;text-overflow:ellipsis}regular-table td span.rt-group-name,regular-table th span.rt-group-name{margin-right:-5px;padding-right:5px;padding-left:8px;flex:1;height:100%}regular-table th span.rt-group-name{text-align:left}regular-table td th span.rt-group-leaf,regular-table th span.rt-group-leaf{margin-left:16px;height:100%}regular-table .rt-column-resize{height:100%;width:10px;position:absolute;top:0;right:0;cursor:col-resize}regular-table a{color:var(--rt-pos-cell--color)}regular-table a:visited{color:var(--active--color)}regular-table::-webkit-scrollbar,regular-table::-webkit-scrollbar-corner{background-color:transparent;height:12px;width:12px}regular-table::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#0000;border-radius:5px}regular-table::-webkit-scrollbar-thumb:horizontal{border-bottom:2px solid transparent;border-top:2px solid transparent}regular-table::-webkit-scrollbar-thumb:vertical{border-left:2px solid transparent;border-right:2px solid transparent}regular-table:hover::-webkit-scrollbar-thumb{background-color:#00000026}regular-table::-webkit-scrollbar-thumb:hover{background-color:#0000004d}.psp-header-border:not(.psp-is-top):not(.psp-header-leaf){box-shadow:1px 0 var(--inactive--color, #eaedef)}.psp-header-group{box-shadow:0 10px 0 -9px var(--inactive--color, #eaedef)}.psp-is-top{box-shadow:5px 4px 0 -4px var(--inactive--color, #eaedef)}.psp-is-top.psp-header-group:not(.psp-header-group-corner){box-shadow:5px 4px 0 -4px var(--inactive--color, #eaedef),0 10px 0 -9px var(--inactive--color, #eaedef)}.psp-header-border.psp-header-group:not(.psp-is-top):not(.psp-header-group-corner){box-shadow:1px 0 var(--inactive--color, #eaedef),0 10px 0 -9px var(--inactive--color, #eaedef)}.psp-header-leaf.psp-header-border{box-shadow:5px -4px 0 -4px var(--inactive--color, #eaedef)}tr:only-child th{box-shadow:none!important}regular-table tbody tr:hover th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td:not(.psp-row-selected):not(.psp-row-subselected){border-color:var(--rt-hover--border-color, #c5c9d080)!important;background-color:transparent;box-shadow:0 1px 0 var(--rt-hover--border-color, #c5c9d080),0 3px #0000000d,0 5px #00000003}regular-table tbody tr:hover+tr th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td:not(.psp-row-selected):not(.psp-row-subselected){border-top-color:transparent}regular-table tbody tr th:first-child:not(:empty),regular-table tbody tr th:first-child:empty+th:not(:empty),regular-table tbody tr th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr td:first-child{border-left-width:1px;border-left-color:transparent}regular-table tbody tr th:last-child,regular-table tbody tr td:last-child{border-right-width:1px;border-right-color:transparent}regular-table tbody tr:hover{color:#161616}regular-table tbody tr:hover th:first-child:not(:empty),regular-table tbody tr:hover th:first-child:empty+th:not(:empty),regular-table tbody tr:hover th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr:hover td:first-child{border-left-color:var(--rt-hover--border-color, #c5c9d080)!important}regular-table tbody tr:hover th:last-child,regular-table tbody tr:hover td:last-child{border-right-color:var(--rt-hover--border-color, #c5c9d080)!important}perspective-viewer[settings] regular-table .psp-header-leaf{height:36px;vertical-align:top;padding-top:2px}perspective-viewer[settings] regular-table .psp-header-leaf:not(.psp-header-corner):before{font-family:var(--button--font-family, inherit);content:var(--column-style-open-button--content, var(--config-button-icon--content, "\\1f527"));position:absolute;width:calc(100% - 8px);left:5px;bottom:0px;color:var(--inactive--color, #b4b7be)}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-enabled:not(.psp-header-corner):before{color:inherit;cursor:pointer}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-open:not(.psp-header-corner){pointer-events:none}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-open:not(.psp-header-corner):before{content:var(--column-style-close-button--content, "X")}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-enabled:hover:before{color:#338dcd}perspective-viewer[settings] regular-table .psp-header-leaf .rt-column-resize{height:18px}.psp-row-selected,:hover .psp-row-selected,:hover th.psp-tree-leaf.psp-row-selected,:hover th.psp-tree-label.psp-row-selected{color:#fff!important;background-color:#ea7319!important;border-color:#ea7319!important}.psp-row-selected.psp-tree-label:not(:hover):before{color:#fff}.psp-row-subselected,:hover .psp-row-subselected,:hover th.psp-tree-leaf.psp-row-subselected,:hover th.psp-tree-label.psp-row-subselected{background:rgba(234,115,25,.2)!important}.psp-error{color:red}td:focus{outline:#666;outline-style:dotted;outline-width:1px}perspective-viewer.dragging regular-table{pointer-events:none}.psp-header-border:last-child{border-right-width:0px}.psp-header-sort-desc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-desc--content, "\\2193")}.psp-header-sort-asc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-asc--content, "\\2191")}.psp-header-sort-col-desc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-col-desc--content, "\\2190")}.psp-header-sort-col-asc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-col-asc--content, "\\2192")}tbody th:last-of-type{border-right:1px solid #eaedef;overflow:hidden;text-overflow:ellipsis}tbody th:empty{background-image:linear-gradient(to right,transparent 9px,#eee 10px,transparent 11px);background-repeat:no-repeat;min-width:20px;max-width:20px;pointer-events:none}.psp-tree-label{max-width:0px;min-width:0px}.psp-tree-label:before{color:#ccc;font-family:var(--button--font-family, inherit);padding-right:11px;vertical-align:-1px}.psp-tree-label-expand:before{content:var(--tree-label-expand--content, "+")}.psp-tree-label-collapse:before{content:var(--tree-label-collapse--content, "-")}.psp-tree-label:hover:before{color:#338dcd;text-shadow:0px 0px 5px #338dcd}regular-table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--color, #eaedef)}.psp-tree-leaf{padding-left:24px}.psp-align-right{text-align:right}.psp-align-left{text-align:left}.psp-positive:not(:focus){color:var(--rt-pos-cell--color, #338dcd)}.psp-negative:not(:focus){color:var(--rt-neg-cell--color, #ff5942)}regular-table table tbody td{min-width:52px!important}.psp-is-width-override .rt-column-resize,.rt-column-resize:hover{border:1px dashed #999;border-bottom-width:0px;border-left-width:0px}.psp-bool-type{font-family:var(--button--font-family, "Material Icons")}.boolean-editable{cursor:pointer}regular-table table{user-select:none;color:#161616;border-collapse:separate}regular-table table th{font-weight:400}regular-table table td,regular-table table th{border-color:#eaedef;height:23px}regular-table table .psp-header-group{text-overflow:ellipsis}regular-table table .psp-header-leaf{border-bottom-width:0px}regular-table table td,regular-table table th.psp-tree-label,regular-table table th.psp-tree-label,regular-table table th.psp-tree-leaf,regular-table table tbody tr:first-child th{border-style:solid;border-width:0px;border-top-width:1px}regular-table table tbody th:empty{background-position:0px -10px} pulse_pos{0%{background-color:var(--pulse--background-color-start, rgba(0, 128, 255, .5))}to{background-color:var(--pulse--background-color-end, rgba(0, 128, 255, 0))}} pulse_pos2{0%{background-color:var(--pulse--background-color-start, rgba(0, 128, 255, .5))}to{background-color:var(--pulse--background-color-end, rgba(0, 128, 255, 0))}} pulse_neg{0%{background-color:var(--pulse--background-color-start, rgba(255, 25, 0, .5))}to{background-color:var(--pulse--background-color-end, rgba(255, 25, 0, 0))}} pulse_neg2{0%{background-color:var(--pulse--background-color-start, rgba(255, 25, 0, .5))}to{background-color:var(--pulse--background-color-end, rgba(255, 25, 0, 0))}}
`;function Ie(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}function K(e){let t=e._view_cache.config.row_pivots.length-1,r=Array.from(e.children[0].children[0].children);if(r.length>0){let[s]=r.splice(r.length-1,1);for(let o of s?.children){let l=e.getMeta(o),n=l.column_header?.[l.column_header?.length-1],i=this._config.sort.find(p=>p[0]===n),a=l.row_header_x===t,c=typeof l.x=="undefined";a=a||(l.x+1)%this._config.columns.length==0,o.classList.toggle("psp-header-border",a),o.classList.toggle("psp-header-group",!1),o.classList.toggle("psp-header-leaf",!0),o.classList.toggle("psp-is-top",!1),o.classList.toggle("psp-header-corner",c),o.classList.toggle("psp-header-sort-asc",!!i&&i[1]==="asc"),o.classList.toggle("psp-header-sort-desc",!!i&&i[1]==="desc"),o.classList.toggle("psp-header-sort-col-asc",!!i&&i[1]==="col asc"),o.classList.toggle("psp-header-sort-col-desc",!!i&&i[1]==="col desc");let d=Ie.call(this,l),g=d==="integer"||d==="float",f=d==="string",_=d==="date",h=d==="datetime";o.classList.toggle("psp-align-right",g),o.classList.toggle("psp-align-left",!g),o.classList.toggle("psp-menu-open",this._open_column_styles_menu[0]===l._virtual_x),o.classList.toggle("psp-menu-enabled",(f||g||_||h)&&!c),o.classList.toggle("psp-is-width-override",e._column_sizes?.override[l.size_key]!==void 0)}}}function X(e){let t=e._view_cache.config.row_pivots.length-1,r=Array.from(e.children[0].children[0].children),s=[],o=new Set,l=e.children[0];for(let n=0;n<r.length;n++){let i=l.rows[n],a=new Set;for(let c=0;c<i.cells.length;c++){let d=i.cells[c];d.style.backgroundColor="";let g=e.getMeta(d),f=g.row_header_x===t||g.x>=0;d.classList.toggle("psp-align-right",!1),d.classList.toggle("psp-align-left",!1),d.classList.toggle("psp-header-group",!0),d.classList.toggle("psp-header-leaf",!1),d.classList.toggle("psp-header-border",f),d.classList.toggle("psp-header-group-corner",typeof g.x=="undefined"),d.classList.toggle("psp-color-mode-bar",!1),d.classList.toggle("psp-header-sort-asc",!1),d.classList.toggle("psp-header-sort-desc",!1),d.classList.toggle("psp-header-sort-col-asc",!1),d.classList.toggle("psp-header-sort-col-desc",!1);let _=i.cells[c],h=c,p,y;for(;s[n]&&s[n][h];++h);for(a.add(h),p=h;p<h+_.colSpan;++p)for(y=n;y<n+_.rowSpan;++y)s[y]||(s[y]=[]),s[y][p]=!0;_.classList.toggle("psp-is-top",n===0||!o.has(p))}o=a}}var v=Symbol("Plugin Symbol");function Z(e,t,[,,,,,r,s],[,,,,,o,l]){let n=this._ids?.[e.dy]?.join("|"),i=e.column_header.join("|");if(this.last_reverse_columns?.has(i)&&this.last_reverse_ids?.has(n)){let a=this.last_reverse_ids?.get(n),c=this.last_reverse_columns.get(i);this._is_old_viewport?this.last_meta?.[c]?.[a]>e.user?(t.style.setProperty("--pulse--background-color-start",o),t.style.setProperty("--pulse--background-color-end",l),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):this.last_meta?.[c]?.[a]<e.user?(t.style.setProperty("--pulse--background-color-start",r),t.style.setProperty("--pulse--background-color-end",s),t.style.animationName==="pulse_pos"?t.style.animation="pulse_pos2 0.5s linear":t.style.animation="pulse_pos 0.5s linear"):a!==e.dy&&(t.style.animation=""):t.style.animation=""}else t.style.animation=""}import Q from"chroma-js";function F(e,t){return Q.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function L([e,t,r,s],o=[255,255,255]){function l(n,i){return((1-s)*(o[n]/255)+s*(i/255))*255}return[l(0,e),l(1,t),l(2,r)]}function E([e,t,r]){return Math.sqrt(e*e*.299+t*t*.587+r*r*.114)>130?"#161616":"#ffffff"}function Ne(e){let[t,r,s]=e.rgb(),[o,l,n]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[i,a,c]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${o},${l},${n}),rgb(${t},${r},${s}) 50%,rgb(${i},${a},${c}))`}function b(e){let t=Q(e),r=Ne(t),s=t.rgb();return[e,...s,r,`rgba(${s[0]},${s[1]},${s[2]},1)`,`rgba(${s[0]},${s[1]},${s[2]},0)`]}function ee(e,t,r){let s=r.user>0,o=r.user<0,l;e?.pos_bg_color!==void 0?l=e.pos_bg_color:l=this._pos_bg_color;let n;e?.neg_bg_color!==void 0?n=e.neg_bg_color:n=this._neg_bg_color;let i=s?l:o?n:["",...this._plugin_background,""];{let[_,h,p,y,u]=i;if(t.style.position="",e?.number_bg_mode==="color")t.style.animation="",t.style.backgroundColor=_;else if(e?.number_bg_mode==="gradient"){let m=Math.max(0,Math.min(1,Math.abs(r.user/e.bg_gradient))),x=this._plugin_background,w=E(L([h,p,y,m],x));t.style.animation="",t.style.color=w,t.style.backgroundColor=`rgba(${h},${p},${y},${m})`}else e?.number_bg_mode==="pulse"?(Z.call(this,r,t,l,n),t.style.backgroundColor=""):(e?.number_bg_mode==="disabled"||!e?.number_bg_mode,t.style.animation="",t.style.backgroundColor="")}let[a,c,d,g,f]=(()=>e?.pos_fg_color!==void 0?s?e.pos_fg_color:o?e.neg_fg_color:["",...this._plugin_background,""]:s?this._pos_fg_color:o?this._neg_fg_color:["",...this._plugin_background,""])();if(e?.number_fg_mode==="disabled")if(e?.number_bg_mode==="color"){let _=this._plugin_background,h=E(L([i[1],i[2],i[3],1],_));t.style.color=h}else e?.number_bg_mode==="gradient"||(t.style.color="");else e?.number_fg_mode==="bar"?(t.style.color="",t.style.position="relative",f!==""&&t.children.length>0&&t.children[0].nodeType===Node.ELEMENT_NODE&&(t.children[0].style.background=f)):(e?.number_fg_mode==="color"||!e?.number_fg_mode)&&(t.style.color=a)}import te from"chroma-js";function oe(e,t,r){let s=r.column_header?.[r.column_header?.length-1],[o,l,n,i,a]=(()=>e?.color!==void 0?e.color:this._color)();if(e?.string_color_mode==="foreground"&&r.user!==null)t.style.color=o,t.style.backgroundColor="",e?.format==="link"&&(t.children[0].style.color=o);else if(e?.string_color_mode==="background"&&r.user!==null){let c=this._plugin_background,d=E(L([l,n,i,1],c));t.style.color=d,t.style.backgroundColor=o}else if(e?.string_color_mode==="series"&&r.user!==null){this._series_color_map.has(s)||(this._series_color_map.set(s,new Map),this._series_color_seed.set(s,0));let c=this._series_color_map.get(s);if(!c.has(r.user)){let S=this._series_color_seed.get(s);c.set(r.user,S),this._series_color_seed.set(s,S+1)}let d=c.get(r.user),[g,f,_]=te(o).hsl();g=g+d*150%360;let h=te(g,f,_,"hsl"),[p,y,u]=h.rgb(),m=h.hex(),x=this._plugin_background,w=E(L([p,y,u,1],x));t.style.color=w,t.style.backgroundColor=m}else t.style.backgroundColor="",t.style.color=""}import"chroma-js";function re(e,t,r){let s=r.column_header?.[r.column_header?.length-1],[o,l,n,i,a]=(()=>e?.color!==void 0?e.color:this._color)();if(e?.datetime_color_mode==="foreground"&&r.user!==null)t.style.color=o,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&r.user!==null){let c=this._plugin_background,d=E(L([l,n,i,1],c));t.style.color=d,t.style.backgroundColor=o}else t.style.backgroundColor="",t.style.color=""}function se(e,t,r){let[s]=r.user===!0?this._pos_fg_color:r.user===!1?this._neg_fg_color:["",0,0,0,""];t.style.backgroundColor="",t.style.color=s}function le(e,t,r){let s=typeof r.value!=null&&typeof r.value!=null&&r.value?.toString()?.trim().length>0,o=r.row_header_x>=this._config.group_by.length,l=e.getMeta({dx:0,dy:r.y-r.y0+1}),n=l&&l.row_header&&typeof l.row_header[r.row_header_x+1]!="undefined";t.classList.toggle("psp-tree-label",s&&!o),t.classList.toggle("psp-tree-label-expand",s&&!o&&!n),t.classList.toggle("psp-tree-label-collapse",s&&!o&&n),t.classList.toggle("psp-tree-leaf",s&&o)}function De(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}function ne(e){let t=e[v]||{};for(let r of e.children[0].children[1].children)for(let s of r.children){let o=e.getMeta(s),l=o.column_header?.[o.column_header?.length-1],n=De.call(this,o),i=t[l],a=n==="integer"||n==="float";a?ee.call(this,i,s,o):n==="boolean"?se.call(this,i,s,o):n==="string"?oe.call(this,i,s,o):n==="date"||n==="datetime"?re.call(this,i,s,o):(s.style.backgroundColor="",s.style.color=""),s.classList.toggle("psp-bool-type",n==="boolean"&&o.user!==null);let c=s.tagName==="TH";c&&le.call(this,e,s,o),s.classList.toggle("psp-align-right",!c&&a),s.classList.toggle("psp-align-left",c||!a),s.classList.toggle("psp-color-mode-bar",i?.number_fg_mode==="bar"&&a)}}async function ie(e,t,r){let s=e.getMeta(r),o=s.column_header[s.column_header.length-1],n=(t.shiftKey?$e:Fe).call(this,o);this._preserve_focus_state=!0,await e.parentElement.parentElement.restore({sort:n})}function $e(e){let t=[],r=!1;for(let s of this._config.sort){let[o,l]=s;if(o===e){r=!0;let n=ae.call(this,e,l);n&&t.push(n)}else t.push(s)}return r||t.push([e,"desc"]),t}function Fe(e){for(let[t,r]of this._config.sort)if(t===e){let s=ae.call(this,e,r);return s?[s]:[]}return[[e,"desc"]]}function ae(e,t){let s=this._config.split_by.length>0?Be:He,o=t?s[t]:"desc";if(o)return[e,o]}var He={desc:"asc",asc:void 0},Be={desc:"asc",asc:"col desc","col desc":"col asc","col asc":void 0};function H(e,t,r){let s=e.getMeta(t),o=s.column_header[s.column_header.length-1],l=this._schema[o],n=l==="integer"||l==="float",i=document.createElement(`perspective-${{float:"number",integer:"number",string:"string",date:"date",datetime:"datetime"}[l]}-column-style`),a;if(n?a={fg_gradient:r,pos_fg_color:this._pos_fg_color[0],neg_fg_color:this._neg_fg_color[0],number_fg_mode:"color",bg_gradient:r,pos_bg_color:this._pos_bg_color[0],neg_bg_color:this._neg_bg_color[0],number_bg_mode:"disabled"}:a={color:this._color[0],bg_color:this._color[0]},!(l==="string"||l==="date"||l==="datetime"))if(l==="float")a.fixed=2;else if(l==="integer")a.fixed=0;else{this._open_column_styles_menu.pop(),e.draw({preserve_width:!0});return}let c=()=>i.blur(),d=h=>{let p=h.detail;p.pos_fg_color&&(p.pos_fg_color=b(p.pos_fg_color),p.neg_fg_color=b(p.neg_fg_color)),p.pos_bg_color&&(p.pos_bg_color=b(p.pos_bg_color),p.neg_bg_color=b(p.neg_bg_color)),p.color&&(p.color=b(p.color)),p.bg_color&&(p.bg_color=b(p.bg_color)),e[v]=e[v]||{},e[v][o]=p,e.draw({preserve_width:!0}),e.parentElement.parentElement.dispatchEvent(new Event("perspective-config-update"))},g=async()=>{e.removeEventListener("regular-table-scroll",c),i.removeEventListener("perspective-column-style-change",d),i.removeEventListener("blur",g),this._open_column_styles_menu.pop(),e.parentElement.parentElement.dispatchEvent(new Event("perspective-config-update")),await e.draw({preserve_width:!0}),i.destroy()};i.addEventListener("perspective-column-style-change",d),i.addEventListener("blur",g),e.addEventListener("regular-table-scroll",c);let f=e[v]||{},_=Object.assign({},f[o]=f[o]||{});(_.pos_fg_color||_.pos_bg_color)&&(_.pos_fg_color=_.pos_fg_color?.[0],_.neg_fg_color=_.neg_fg_color?.[0],_.pos_bg_color=_.pos_bg_color?.[0],_.neg_bg_color=_.neg_bg_color?.[0]),_.color&&(_.color=_.color[0]),_.bg_color&&(_.bg_color=_.bg_color[0]),i.open(t,_,a)}async function ce(e,t){let r=e.getMeta(t.target),s=t.target.classList.contains("psp-tree-label-collapse");t.shiftKey&&s?this._view.set_depth(r.row_header.filter(o=>o!==void 0).length-2):t.shiftKey?this._view.set_depth(r.row_header.filter(o=>o!==void 0).length-1):s?this._view.collapse(r.y):this._view.expand(r.y),this._num_rows=await this._view.num_rows(),this._num_columns=await this._view.num_columns(),e.draw()}async function de(e,t){if(t.which!==1)return;let r=t.target;if(r.tagName==="A")return;for(;r.tagName!=="TD"&&r.tagName!=="TH";)if(r=r.parentElement,!e.contains(r))return;if(r.classList.contains("psp-tree-label")){ce.call(this,e,t),t.stopImmediatePropagation();return}let s=r.getBoundingClientRect();if(r.classList.contains("psp-menu-enabled")&&t.clientY-s.top>16){let o=e.getMeta(r),l=o.column_header?.[o.column_header?.length-1],n=this._schema[l];if(this._open_column_styles_menu.unshift(o._virtual_x),n==="string"||n==="date"||n==="datetime")await e.draw({preserve_width:!0}),H.call(this,e,r);else{let[i,a]=await this._view.get_min_max(l);await e.draw({preserve_width:!0});let c=Math.max(Math.abs(i),Math.abs(a));c>1&&(c=Math.round(c*100)/100),H.call(this,e,r,c)}t.preventDefault(),t.stopImmediatePropagation()}else r.classList.contains("psp-header-leaf")&&!r.classList.contains("psp-header-corner")&&(ie.call(this,e,t,r),t.stopImmediatePropagation())}function _e(e,t){if(t.which!==1)return;let r=t.target;for(;r.tagName!=="TD"&&r.tagName!=="TH";)if(r=r.parentElement,!e.contains(r))return;(r.classList.contains("psp-tree-label")&&t.offsetX<26||r.classList.contains("psp-header-leaf")&&!r.classList.contains("psp-header-corner"))&&t.stopImmediatePropagation()}function pe(e,t=!1){let r=this._config.group_by.length===0&&this._config.split_by.length===0,s=e.hasAttribute("selectable"),o=t||!!e.children[0]._is_edit_mode;return r&&!s&&o}function he(e,t){let r=e[v]||{},s=pe.call(this,t);e.parentElement.classList.toggle("edit-mode-allowed",pe.call(this,t,!0));for(let o of e.querySelectorAll("td")){let l=e.getMeta(o),n=this.get_psp_type(l);if(s&&this._is_editable[l.x]){let i=l.column_header[l.column_header.length-1];n==="string"&&r[i]?.format==="link"?(o.toggleAttribute("contenteditable",!1),o.classList.toggle("boolean-editable",!1)):n==="boolean"?(o.toggleAttribute("contenteditable",!1),o.classList.toggle("boolean-editable",l.user!==null)):(s!==o.hasAttribute("contenteditable")&&o.toggleAttribute("contenteditable",s),o.classList.toggle("boolean-editable",!1))}else o.toggleAttribute("contenteditable",!1),o.classList.toggle("boolean-editable",!1)}}var A=(e,t,r)=>{let s=e.querySelectorAll("td"),o=r.get(e);if(o){for(let l of s){let n=e.getMeta(l);if(n.x===o.x&&n.y===o.y)return document.activeElement!==l&&l.focus({preventScroll:!0}),!0}document.activeElement!==document.body&&e.contains(document.activeElement)&&document.activeElement.blur()}};function Ve(e){let t;return async function(...r){if(!!t&&await t&&!!t)return;let s;t=new Promise(o=>s=o),await e.apply(this,r),t=void 0,s()}}function ge(){if(this.isContentEditable){let e=document.getSelection().getRangeAt(0),t=e.cloneRange();return t.selectNodeContents(this),t.setEnd(e.endContainer,e.endOffset),t.toString().length}else return this.target.selectionStart}function ue(e,t,r){let s=e.getMeta(r),o=t._schema[t._column_paths[s.x]];if(s){let l=r.textContent,n=t._ids[s.y-s.y0];if(o==="float"||o==="integer"){if(l=parseFloat(l.replace(/,/g,"")),isNaN(l))return!1}else if(o==="date"||o==="datetime"){if(l=Date.parse(l),isNaN(l))return!1}else o==="boolean"&&(l=l==="check"?!1:l==="close"?!0:null);let i={__INDEX__:n,[t._column_paths[s.x]]:l};return t._table.update([i],{port_id:t._edit_port}),!0}}function z(e,t=!1){let r=this._config.group_by.length===0&&this._config.split_by.length===0,s=e.hasAttribute("selectable"),o=t||!!e.children[0]._is_edit_mode;return r&&!s&&o}var M=Ve(async function(e,t,r,s,o){let l=e.getMeta(r),n=this._column_paths.length,i=this._num_rows,a=t.get(e);if(!a)return;l.x+s<n&&0<=l.x+s&&(a.x=l.x+s),l.y+o<i&&0<=l.y+o&&(a.y=l.y+o);let c=Math.max(l.x0-10,0),d=Math.min(l.x0+10,n),g=Math.max(l.y0-5,0),f=Math.min(l.y0+10,i),_=l.x0+s,h=l.y0+o;for(;!A(e,void 0,t)&&_>=c&&_<d&&h>=g&&h<f;)await e.scrollToCell(_,h,n,i),t.set(e,a),_+=s,h+=o});function fe(e,t,r,s){if(!z.call(this,t))return;let o=document.activeElement;switch(s.target.classList.remove("psp-error"),s.keyCode){case 13:s.preventDefault(),s.shiftKey?M.call(this,e,r,o,0,-1):M.call(this,e,r,o,0,1);break;case 37:ge.call(o)==0&&(s.preventDefault(),M.call(this,e,r,o,-1,0));break;case 38:s.preventDefault(),M.call(this,e,r,o,0,-1);break;case 39:ge.call(o)==o.textContent.length&&(s.preventDefault(),M.call(this,e,r,o,1,0));break;case 40:s.preventDefault(),M.call(this,e,r,o,0,1);break;default:}}function me(e,t,r){let s=e.getMeta(r.target);if(typeof s?.x!="undefined"){let o=z.call(this,t),l=this._is_editable[s.x],n=this.get_psp_type(s)==="boolean",i=r.target.textContent==="-";o&&l&&n&&!i&&write(e,this,r.target)}}function be(e,t,r,s){if(z.call(this,t)&&r.has(e)){s.target.classList.remove("psp-error");let o=r.get(e);r.delete(e),o.content!==s.target.textContent&&(ue(e,this,s.target)||(s.target.textContent=o.content,s.target.classList.add("psp-error"),s.target.focus()))}}function ye(e,t,r,s){let o=e.getMeta(s.target);if(o){let l={x:o.x,y:o.y,content:s.target.textContent};r.set(e,l)}}async function C({_view:e,_config:t},r,s){let o=t.group_by,l=t.split_by,n=r>=0?r:0,i=n+1,a=await e.to_json({start_row:n,end_row:i}),d=a.map(u=>u.__ROW_PATH__)[0]||[],g=o.map((u,m)=>{let x=d[m];return x?[u,"==",x]:void 0}).filter(u=>u),f=o.length>0?s+1:s,_=Object.keys(a[0])[f],h={row:a[0]},p=[];if(_){let u=_.split("|");h.column_names=[u[u.length-1]],p=l.map((m,x)=>{let w=u[x];return w?[m,"==",w]:void 0}).filter(m=>m).filter(([,,m])=>m!=="__ROW_PATH__")}let y=t.filter.concat(g).concat(p);return h.config={filter:y},h}async function xe(e,t,r,s){let o=e.getMeta(s.target);if(!t.hasAttribute("selectable")||s.handled||s.which!==1||!o)return;let l=this._ids[o.y-o.y0];if(o&&o.y>=0){let n=r.get(e),i=!!n&&n.reduce((d,g,f)=>d&&g===l[f],!0),a=!!n&&l.length===n.length&&i,c=[];a?r.delete(e):(r.set(e,l),c=await C(this,o.y,o.x),c=c.config.filter),await e.draw({preserve_width:!0}),s.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:{selected:!a,config:{filter:c}}}))}}function ve(e,t,r){if(!t.hasAttribute("selectable"))return;let s=r.has(e),o=r.get(e);for(let l of e.querySelectorAll("td"))if(!s)l.classList.toggle("psp-row-selected",!1),l.classList.toggle("psp-row-subselected",!1);else{let n=e.getMeta(l),i=this._ids[n.y-n.y0],a=o.reduce((c,d,g)=>c&&d===i[g],!0);l.classList.toggle("psp-row-selected",i.length===o.length&&a),l.classList.toggle("psp-row-subselected",i.length!==o.length&&a)}for(let l of e.querySelectorAll("tbody th")){let n=e.getMeta(l),i=this._ids[n.y-n.y0];if(!s||!!i[n.row_header_x])l.classList.toggle("psp-row-selected",!1),l.classList.toggle("psp-row-subselected",!1);else{let a=o.reduce((c,d,g)=>c&&d===i[g],!0);l.classList.toggle("psp-row-selected",i.length===o.length&&a),l.classList.toggle("psp-row-subselected",i.length!==o.length&&a)}}}async function we(e,t,r){r.delete(e);for(let s of e.querySelectorAll("td,th"))s.classList.toggle("psp-row-selected",!1),s.classList.toggle("psp-row-subselected",!1)}import Te from"chroma-js";import{get_type_config as O}from"@finos/perspective/src/js/config/index.js";var ke={datetime:Intl.DateTimeFormat,date:Intl.DateTimeFormat,integer:Intl.NumberFormat,float:Intl.NumberFormat,boolean:class{format(e){return e?"check":"close"}}},B=class{constructor(){this._formatters=new Map}create_datetime_formatter(t,r){let s=O(t),o={...s.format,timeZone:r.timeZone,dateStyle:r.dateStyle,timeStyle:r.timeStyle};return o.dateStyle==="disabled"?o.dateStyle=void 0:o.dateStyle===void 0&&(o.dateStyle=s.format.dateStyle),o.timeStyle==="disabled"?o.timeStyle=void 0:o.timeStyle===void 0&&(o.timeStyle=s.format.timeStyle),new Intl.DateTimeFormat([],o)}create_number_formatter(t,r){let{format:s}=O(t);return r.fixed!==void 0&&(s.minimumFractionDigits=r.fixed,s.maximumFractionDigits=r.fixed),new ke[t]([],s)}create_boolean_formatter(t,r){let s=O(t);return new ke[t]([],s.format)}get(t,r){let s=[t,r.fixed,r.timeZone,r.dateStyle,r.timeStyle].join("-");if(!this._formatters.has(s)){let o=O(t);t==="date"||t==="datetime"?this._formatters.set(s,this.create_datetime_formatter(t,r)):t==="integer"||t==="float"?this._formatters.set(s,this.create_number_formatter(t,r)):t==="boolean"?this._formatters.set(s,this.create_boolean_formatter(t,r)):this._formatters.set(s,!1)}return this._formatters.get(s)}};var Ye=new B;function P(e,t,r={},s=!1){if(t===null)return"-";let o=e[e.length-1],l=s&&this._table_schema[o]||this._schema[o]||"string",n=r[o]||{};if((l==="integer"||l==="float")&&n?.number_fg_mode==="bar"){let a=Math.max(0,Math.min(.95,Math.abs(t/n.fg_gradient)*.95)),c=this._div_factory.get(),d=t>=0?"left":"right";return c.setAttribute("style",`width:${(a*100).toFixed(2)}%;position:absolute;${d}:0;height:80%;top:10%;pointer-events:none;`),c}else if(n?.format==="link"&&l==="string"){let a=document.createElement("a");return a.setAttribute("href",t),a.setAttribute("target","_blank"),a.textContent=t,a}else if(n?.format==="bold"&&l==="string"){let a=document.createElement("b");return a.textContent=t,a}else if(n?.format==="italics"&&l==="string"){let a=document.createElement("i");return a.textContent=t,a}else{let a=Ye.get(l,n);return a?a.format(t):t}}function*Le(e=[],t,r){let s=r[v];for(let o of e){o=["TOTAL",...o];let l=o[o.length-1];o=o.slice(0,o.length-1).fill("");let n=P.call(this,[t[o.length-1]],l,s,!0);n instanceof HTMLElement?o=o.concat(n):o=o.concat({toString:()=>n}),o.length=t.length+1,yield o}}function Ee(){let e,t,r,s,o;return async function(n,i,a,c,d){let g={},f;c-i>0&&d-a>0?(this._is_old_viewport=this._last_window?.start_row===a&&this._last_window?.end_row===d&&this._last_window?.start_col===i&&this._last_window?.end_col===c,f={start_row:a,start_col:i,end_row:d,end_col:c,id:!0},g=await this._view.to_columns(f),this._last_window=f,this._ids=g.__ID__,this._reverse_columns=this._column_paths.slice(i,c).reduce((u,m,x)=>(u.set(m,x),u),new Map),this._reverse_ids=this._ids.reduce((u,m,x)=>(u.set(m?.join("|"),x),u),new Map)):this._div_factory.clear();let _=[],h=[],p=[],y=[];for(let u=i;u<Math.min(c,this._column_paths.length);++u){let m=this._column_paths[u],x=m.split("|"),w=g[m]||new Array(d-a).fill(null);_.push(w.map(S=>P.call(this,x,S,n[v]))),h.push(w),p.push(x),y.push(m)}return c-i>0&&d-a>0&&(this.last_column_paths=t,this.last_meta=e,this.last_ids=r,this.last_reverse_ids=s,this.last_reverse_columns=o,t=y,e=h,r=this._ids,s=this._reverse_ids,o=this._reverse_columns),{num_rows:this._num_rows,num_columns:this._column_paths.length,row_headers:Array.from(Le.call(this,g.__ROW_PATH__,this._config.group_by,n)),column_headers:p,data:_,metadata:h}}}function R(e,t,r){let s=window.getComputedStyle(e).getPropertyValue(t).trim();return s.length>0?s:r}var Se=class{constructor(t){this._name=t,this._elements=[],this._index=0}clear(){this._index=0}get(){this._elements[this._index]||(this._elements[this._index]=document.createElement(this._name));let t=this._elements[this._index];return this._index+=1,t}};function We(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}async function V(e,t,r,s={}){let o=await r.get_config(),l=o.expressions.map(k=>k[1]),[n,i,a,c,d,g,f]=await Promise.all([t.schema(),t.validate_expressions(l),r.num_rows(),r.schema(),r.expression_schema(),r.column_paths(),this.parentElement.getEditPort()]),_=Te(R(e,"--plugin--background","#FFFFFF")).rgb(),h=b(R(e,"--rt-pos-cell--color","#338DCD")),p=b(R(e,"--rt-neg-cell--color","#FF5942")),y=b(F(h[0],_)),u=b(F(p[0],_)),m=b(R(e,"--active--color","#ff0000")),x={...c,...d},w={...n,...i.expression_schema},S=g.filter(k=>k!=="__ROW_PATH__"&&k!=="__ID__"),W=[],q=[];for(let k of S){let U=k.split("|"),G=U[U.length-1];q.push(x[G]),W.push(!!n[G])}let j=Object.assign(s,{_edit_port:f,_view:r,_table:t,_table_schema:w,_config:o,_num_rows:a,_schema:x,_ids:[],_open_column_styles_menu:[],_plugin_background:_,_color:m,_pos_fg_color:h,_neg_fg_color:p,_pos_bg_color:y,_neg_bg_color:u,_column_paths:S,_column_types:q,_is_editable:W,_row_header_types:o.group_by.map(k=>w[k]),_series_color_map:new Map,_series_color_seed:new Map,get_psp_type:We});return j._div_factory=j._div_factory||new Se("div"),e.setDataListener(Ee().bind(j,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),j}async function Me(e,t,r){let s=e.getMeta(r.target);if(!s)return;let{x:o,y:l}=s,{row:n,column_names:i,config:a}=await C(this,l,o);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:n,column_names:i,config:a}}))}async function Ce(e){let t=this.parentElement,r=await t.getTable(!0);if(this._initialized)await V.call(this,this.regular_table,r,e,this.model);else{this.innerHTML="",this.appendChild(this.regular_table),this.model=await V.call(this,this.regular_table,r,e),this.regular_table.addStyleListener(ne.bind(this.model,this.regular_table)),this.regular_table.addStyleListener(X.bind(this.model,this.regular_table)),this.regular_table.addStyleListener(K.bind(this.model,this.regular_table)),this.regular_table.addEventListener("click",_e.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",de.bind(this.model,this.regular_table));let s=new WeakMap;this.regular_table.addStyleListener(ve.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("mousedown",xe.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("psp-deselect-all",we.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("click",Me.bind(this.model,this.regular_table,t));let o=new WeakMap;this.regular_table.addStyleListener(he.bind(this.model,this.regular_table,t)),this.regular_table.addStyleListener(A.bind(this.model,this.regular_table,t,o)),this.regular_table.addEventListener("click",me.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",ye.bind(this.model,this.regular_table,t,o)),this.regular_table.addEventListener("focusout",be.bind(this.model,this.regular_table,t,o)),this.regular_table.addEventListener("keydown",fe.bind(this.model,this.regular_table,t,o)),this._initialized=!0}}function I(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let r={},{group_by:s,columns:o}=this.model._config,l=s?.length>0?s.length+1:0;for(let n of Object.keys(e))if(n==="__ROW_PATH__")r[l-1]=e[n];else{let i=this.model._column_paths.indexOf(n);r[i+l]=e[n]}this.regular_table._column_sizes.override=r}function N(){if(!this._initialized)return[];if(this._cached_column_sizes){let l=this._cached_column_sizes;return this._cached_column_sizes=void 0,l}let e=this.regular_table._column_sizes.override,{group_by:t,columns:r}=this.model._config,s=t?.length>0?t.length+1:0,o={};for(let l of Object.keys(e))if(e[l]!==void 0){let n=l-s;n>-1?o[this.model._column_paths[n]]=e[l]:n===-1&&(o.__ROW_PATH__=e[l])}return o}function D(e=void 0){typeof e=="undefined"&&(e=!this._is_edit_mode),this._is_edit_mode=e,this.classList.toggle("editable",e),this._edit_mode!==void 0&&(this._edit_mode.classList.toggle("editable",e),e?this._edit_mode.children[0].textContent="Editable":this._edit_mode.children[0].textContent="Read Only")}function $(e=void 0){typeof e=="undefined"&&(e=!this._is_scroll_lock),this._is_scroll_lock=e,this.classList.toggle("sub-cell-scroll-enabled",!e),this._scroll_lock!==void 0&&(this._scroll_lock.classList.toggle("lock-scroll",e),e?this._scroll_lock.children[0].textContent="Align Scroll":this._scroll_lock.children[0].textContent="Free Scroll")}function je(e){e=JSON.parse(JSON.stringify(e));let t={};if(e.columns)for(let s of Object.keys(e.columns)){let o=e.columns[s];o.column_size_override!==void 0&&(t[s]=o.column_size_override,delete o.column_size_override),o?.pos_fg_color&&(o.pos_fg_color=b(o.pos_fg_color),o.neg_fg_color=b(o.neg_fg_color)),o?.pos_bg_color&&(o.pos_bg_color=b(o.pos_bg_color),o.neg_bg_color=b(o.neg_bg_color)),o?.color&&(o.color=b(o.color)),Object.keys(o).length===0&&delete e.columns[s]}"editable"in e&&D.call(this,e.editable),"scroll_lock"in e&&$.call(this,e.scroll_lock);let r=this.regular_table;try{r._resetAutoSize()}catch{}I.call(this,t,!0),r[v]=e.columns}function Ae(){this._toolbar||(this._toolbar=document.createElement("perspective-viewer-datagrid-toolbar")),this.parentElement.appendChild(this._toolbar)}function ze(){if(this.regular_table){let e=this.regular_table,t={columns:{},scroll_lock:!!this._is_scroll_lock,editable:!!this._is_edit_mode};for(let s of Object.keys(e[v]||{})){let o=Object.assign({},e[v][s]);(o?.pos_fg_color||o?.pos_bg_color)&&(o.pos_fg_color=o.pos_fg_color?.[0],o.neg_fg_color=o.neg_fg_color?.[0],o.pos_bg_color=o.pos_bg_color?.[0],o.neg_bg_color=o.neg_bg_color?.[0]),o?.color&&(o.color=o.color[0]),t.columns[s]=o}let r=N.call(this);for(let s of Object.keys(r||{}))t.columns[s]||(t.columns[s]={}),t.columns[s].column_size_override=r[s];return JSON.parse(JSON.stringify(t))}return{}}async function Oe(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null)return;let t=N.call(this),r=this.regular_table.draw({invalid_columns:!0});this.model._preserve_focus_state?this.model._preserve_focus_state=!1:(this.regular_table.scrollTop=0,this.regular_table.scrollLeft=0,this.regular_table.dispatchEvent(new CustomEvent("psp-deselect-all",{bubbles:!1})),this.regular_table._resetAutoSize()),I.call(this,t),await r,this._toolbar.classList.toggle("aggregated",this.model._config.group_by.length>0||this.model._config.split_by.length>0)}var Y=class extends HTMLElement{constructor(){super();this.regular_table=document.createElement("regular-table"),this._is_scroll_lock=!0}connectedCallback(){return Ae.call(this)}disconnectedCallback(){this._toolbar.parentElement.removeChild(this._toolbar)}async activate(t){return await Ce.call(this,t)}get name(){return"Datagrid"}get category(){return"Basic"}get select_mode(){return"toggle"}get min_config_columns(){}get config_column_names(){}async draw(t){return await Oe.call(this,t)}async update(t){this.model._num_rows=await t.num_rows(),await this.regular_table.draw()}async resize(){!this.isConnected||this.offsetParent==null||this._initialized&&await this.regular_table.draw()}async clear(){this.regular_table._resetAutoSize(),this.regular_table.clear()}save(){return ze.call(this)}restore(t){return je.call(this,t)}async restyle(t){await this.draw(t)}delete(){this.regular_table.table_model&&this.regular_table._resetAutoSize(),this.regular_table.clear()}};var Pe=`:host{position:relative;display:block}:host #container{position:absolute;display:flex;flex-direction:column;justify-content:stretch;align-items:stretch;top:0;left:0;right:0;bottom:0}:host #toolbar{display:flex;align-items:center;height:36px}:host #slot-container{flex:1;position:relative}#scroll_lock.lock-scroll:before{content:var(--toolbar-scroll-lock-active--content)}#scroll_lock:before{content:var(--toolbar-scroll-lock--content)}#select_mode:before{content:"highlight_alt"}#edit_mode:before{content:var(--toolbar-edit-mode--content)}#edit_mode.editable:before{content:var(--toolbar-edit-mode-active--content)}:host(.aggregated) #toolbar #edit_mode{display:none}.button:before{color:var(--inactive--color, #ccc);line-height:36px;font-size:14px;font-family:var(--button--font-family, "Material Icons Outlined");vertical-align:bottom;margin:0 11px}.button.editable:before,.button.lock-scroll:before{color:inherit}.button{user-select:none;width:36px;box-sizing:border-box;white-space:nowrap}.button>span{display:none;margin:0;padding:0}.button:hover{opacity:1;display:flex;align-items:center;color:inherit;cursor:pointer;min-width:var(--button--min-width, 105px);background-color:#0000000d}.button:hover:before{margin:0 6px 0 11px}.button:hover>span{display:contents;font-size:12px;font-weight:300;line-height:36px}
`;var T=class extends HTMLElement{connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute("slot","plugin-settings"),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
<style>
${Pe}
</style>
<div id="toolbar">
<span id="scroll_lock" class="lock-scroll button">
<span>Align Scroll</span>
</span>
<span id="edit_mode" class="button"><span>Read Only</span></span>
</div>
`;let t=this.parentElement,r=t.querySelector("perspective-viewer-datagrid");r._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),r._scroll_lock.addEventListener("click",()=>$.call(r)),r._edit_mode=this.shadowRoot.querySelector("#edit_mode"),r._edit_mode.addEventListener("click",()=>{D.call(r),r.regular_table.draw(),t.dispatchEvent(new Event("perspective-config-update"))})}};function Ue(){let e=document.createElement("style");e.textContent=J,document.head.insertBefore(e,document.head.firstChild)}async function Ge(){customElements.define("perspective-viewer-datagrid-toolbar",T),customElements.define("perspective-viewer-datagrid",Y),await customElements.whenDefined("perspective-viewer"),customElements.get("perspective-viewer").registerPlugin("perspective-viewer-datagrid")}Ge();Ue();
//# sourceMappingURL=perspective-viewer-datagrid.js.map