@revolist/revogrid 4.27.3 → 4.27.4

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.
@@ -146,6 +146,7 @@ const FilterPanel = class {
146
146
  }
147
147
  }
148
148
  async show(newEntity) {
149
+ this.debouncedApplyFilter.flush();
149
150
  this.hasChanges = false;
150
151
  this.changes = newEntity;
151
152
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -660,7 +661,7 @@ const FilterPanel = class {
660
661
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
661
662
  };
662
663
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
663
- return (index.h(index.Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, index.h("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
664
+ return (index.h(index.Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, index.h("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
664
665
  e.preventDefault();
665
666
  this.onCancel();
666
667
  } }, this.changes && [
@@ -669,7 +670,7 @@ const FilterPanel = class {
669
670
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
670
671
  index.h("label", { key: "filter-title" }, capts.title),
671
672
  index.h("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
672
- index.h("div", { key: "add-filter", class: "add-filter" }, index.h("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
673
+ index.h("div", { key: "add-filter", class: "add-filter" }, index.h("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
673
674
  ],
674
675
  index.h("slot", { key: "default-slot" }),
675
676
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
@@ -86,6 +86,7 @@ export class FilterPanel {
86
86
  }
87
87
  }
88
88
  async show(newEntity) {
89
+ this.debouncedApplyFilter.flush();
89
90
  this.hasChanges = false;
90
91
  this.changes = newEntity;
91
92
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -600,7 +601,7 @@ export class FilterPanel {
600
601
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
601
602
  };
602
603
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
603
- return (h(Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, h("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
604
+ return (h(Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, h("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
604
605
  e.preventDefault();
605
606
  this.onCancel();
606
607
  } }, this.changes && [
@@ -609,7 +610,7 @@ export class FilterPanel {
609
610
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
610
611
  h("label", { key: "filter-title" }, capts.title),
611
612
  h("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
612
- h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
613
+ h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
613
614
  ],
614
615
  h("slot", { key: "default-slot" }),
615
616
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
@@ -144,6 +144,7 @@ const FilterPanel = class {
144
144
  }
145
145
  }
146
146
  async show(newEntity) {
147
+ this.debouncedApplyFilter.flush();
147
148
  this.hasChanges = false;
148
149
  this.changes = newEntity;
149
150
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -658,7 +659,7 @@ const FilterPanel = class {
658
659
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
659
660
  };
660
661
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
661
- return (h(Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, h("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
662
+ return (h(Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, h("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
662
663
  e.preventDefault();
663
664
  this.onCancel();
664
665
  } }, this.changes && [
@@ -667,7 +668,7 @@ const FilterPanel = class {
667
668
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
668
669
  h("label", { key: "filter-title" }, capts.title),
669
670
  h("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
670
- h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
671
+ h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
671
672
  ],
672
673
  h("slot", { key: "default-slot" }),
673
674
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
@@ -144,6 +144,7 @@ const FilterPanel = class {
144
144
  }
145
145
  }
146
146
  async show(newEntity) {
147
+ this.debouncedApplyFilter.flush();
147
148
  this.hasChanges = false;
148
149
  this.changes = newEntity;
149
150
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -658,7 +659,7 @@ const FilterPanel = class {
658
659
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
659
660
  };
660
661
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
661
- return (h(Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, h("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
662
+ return (h(Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, h("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
662
663
  e.preventDefault();
663
664
  this.onCancel();
664
665
  } }, this.changes && [
@@ -667,7 +668,7 @@ const FilterPanel = class {
667
668
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
668
669
  h("label", { key: "filter-title" }, capts.title),
669
670
  h("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
670
- h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
671
+ h("div", { key: "add-filter", class: "add-filter" }, h("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
671
672
  ],
672
673
  h("slot", { key: "default-slot" }),
673
674
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
package/hydrate/index.js CHANGED
@@ -7693,6 +7693,7 @@ class FilterPanel {
7693
7693
  }
7694
7694
  }
7695
7695
  async show(newEntity) {
7696
+ this.debouncedApplyFilter.flush();
7696
7697
  this.hasChanges = false;
7697
7698
  this.changes = newEntity;
7698
7699
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -8207,7 +8208,7 @@ class FilterPanel {
8207
8208
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
8208
8209
  };
8209
8210
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
8210
- return (hAsync(Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, hAsync("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
8211
+ return (hAsync(Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, hAsync("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
8211
8212
  e.preventDefault();
8212
8213
  this.onCancel();
8213
8214
  } }, this.changes && [
@@ -8216,7 +8217,7 @@ class FilterPanel {
8216
8217
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
8217
8218
  hAsync("label", { key: "filter-title" }, capts.title),
8218
8219
  hAsync("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
8219
- hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
8220
+ hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
8220
8221
  ],
8221
8222
  hAsync("slot", { key: "default-slot" }),
8222
8223
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
package/hydrate/index.mjs CHANGED
@@ -7691,6 +7691,7 @@ class FilterPanel {
7691
7691
  }
7692
7692
  }
7693
7693
  async show(newEntity) {
7694
+ this.debouncedApplyFilter.flush();
7694
7695
  this.hasChanges = false;
7695
7696
  this.changes = newEntity;
7696
7697
  this.filterItems = this.cloneFilterItems((newEntity === null || newEntity === void 0 ? void 0 : newEntity.filterItems) || {});
@@ -8205,7 +8206,7 @@ class FilterPanel {
8205
8206
  top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
8206
8207
  };
8207
8208
  const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
8208
- return (hAsync(Host, { key: 'f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e' }, hAsync("dialog", { key: 'a5c46aa4822934e7a6eb455fd686513b9101afb4', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
8209
+ return (hAsync(Host, { key: 'd0207c7c243134808f89dc0f024d4b46e18fb3d9' }, hAsync("dialog", { key: '1466680fc6bf4c4464600122bd16a7627131745f', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
8209
8210
  e.preventDefault();
8210
8211
  this.onCancel();
8211
8212
  } }, this.changes && [
@@ -8214,7 +8215,7 @@ class FilterPanel {
8214
8215
  ((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
8215
8216
  hAsync("label", { key: "filter-title" }, capts.title),
8216
8217
  hAsync("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
8217
- hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: '3912f4bd9b1e66fda46e9b6d7c002d29da726345', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
8218
+ hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: 'c924b40863671e714e67eef2b6465b861805bac2', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
8218
8219
  ],
8219
8220
  hAsync("slot", { key: "default-slot" }),
8220
8221
  ((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolist/revogrid",
3
- "version": "4.27.3",
3
+ "version": "4.27.4",
4
4
  "type": "module",
5
5
  "description": "Virtual reactive data grid spreadsheet component - RevoGrid.",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as r,Host as o,transformTag as l}from"@stencil/core/internal/client";import{d as s}from"./debounce.js";import{e as n,f as a,d,i as h}from"./filter.button.js";Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;do{if(Element.prototype.matches.call(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null});const c="text/revogrid-filter-id";function p(t,e,i){if(e===i)return!1;const r=t.findIndex((t=>t.id===e)),o=t.findIndex((t=>t.id===i));if(-1===r||-1===o||r===o)return!1;const l=t.map((t=>{var e;return null!==(e=t.relation)&&void 0!==e?e:"and"})),[s]=t.splice(r,1);return t.splice(o,0,s),t.forEach(((e,i)=>{var r;e.relation=i===t.length-1?"and":null!==(r=l[i])&&void 0!==r?r:"and"})),!0}const u="none",f="add-filter",g=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.filterChange=i(this,"filterChange",7),this.resetChange=i(this,"resetChange",7),this.hasChanges=!1,this.filterCaptionsInternal={title:"Filter by",ok:"Close",save:"Save",reset:"Reset",cancel:"Cancel",add:"Add condition",placeholder:"Enter value...",and:"and",or:"or",filterCondition:"Filter condition",removeFilter:"Remove filter",reorderFilter:"Reorder filter"},this.isFilterIdSet=!1,this.filterId=0,this.currentFilterId=-1,this.currentFilterType=u,this.filterItems={},this.filterNames={},this.filterEntities={},this.disableDynamicFiltering=!1,this.closeOnOutsideClick=!0,this.allowDuplicateOperators=!0,this.debouncedApplyFilter=s((()=>{this.emitFilterChange()}),400)}onMouseDown(t){if(!this.changes)return;const e=t.composedPath(),i=this.getAddFilterSelect();if(i instanceof HTMLSelectElement){if(e.includes(i))return;i.value=u}this.currentFilterType=u,this.changes&&(this.changes.type=u),this.currentFilterId=-1,!e.includes(this.element)&&!this.isOwnFilterButton(t.target)&&this.closeOnOutsideClick&&(this.changes=void 0)}async show(t){if(this.hasChanges=!1,this.changes=t,this.filterItems=this.cloneFilterItems((null==t?void 0:t.filterItems)||{}),this.draftFilter=void 0,this.changes){this.changes.type=this.changes.type||u;const t=this.changes.prop,e=void 0===t?void 0:this.filterItems[t];if(!(null==e?void 0:e.length)&&!1!==this.changes.showDefaultFilter&&!0!==this.changes.hideDefaultFilters){const t=this.resolveDraftFilterType(this.changes.defaultFilterType);t&&(this.draftFilter={id:++this.filterId,type:t,value:"",relation:"and"})}}}async getChanges(){return this.changes}componentWillRender(){if(!this.isFilterIdSet){this.isFilterIdSet=!0;const t=Object.keys(this.filterItems);for(const e of t)this.filterId+=this.filterItems[e].length}}getFilterItemsList(){var t,e;const i=null===(t=this.changes)||void 0===t?void 0:t.prop;if(void 0===i)return"";const o=(null!==(e=this.filterItems[i])&&void 0!==e?e:[]).map(((t,e)=>({filter:t,index:e,isDraft:!1})));this.draftFilter&&o.push({filter:this.draftFilter,index:o.length,isDraft:!0});const l=o.filter((({filter:t})=>!t.hidden)),s=l.length,h=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);return r("div",{key:this.filterId},r("ul",{class:"multi-filter-list-container"},o.map((({filter:t,index:e,isDraft:o})=>{var c;let p;if(t.hidden)return;(null===(c=l[s-1])||void 0===c?void 0:c.filter.id)!==t.id&&(p=r(n,{text:"and"===t.relation?h.and:h.or,onClick:()=>this.toggleFilterAndOr(t.id)}));const u=this.renderExtra(i,e,o),f=this.draggedFilterId===t.id,g=this.dragOverFilterId===t.id&&!f,v=s>1&&!o;return r("li",{key:t.id,class:"multi-filter-list","aria-label":`${h.filterCondition} ${e+1}`},r("div",{class:{"multi-filter-list-row":!0,"filter-row-drop-active":void 0!==this.draggedFilterId&&!f,"filter-row-dragging":f,"filter-row-drag-over":g}},v?r("button",{type:"button",class:"filter-row-drop-target",tabIndex:-1,"aria-label":`${h.filterCondition} ${e+1}`,onDragOver:e=>this.onFilterDragOver(e,t.id),onDragLeave:()=>this.onFilterDragLeave(t.id),onDrop:e=>this.onFilterDrop(e,i,t.id)}):"",v?r(a,{ariaLabel:h.reorderFilter,dragging:f,dragOver:g,onDragStart:e=>this.onFilterDragStart(e,t.id),onDragEnd:()=>this.onFilterDragEnd(),onKeyDown:e=>this.onFilterReorderKeyDown(e,i,t.id)}):"",r("div",{class:{"select-input":!0}},r("select",{class:"select-css select-filter",onChange:t=>this.onFilterTypeChange(t,i,e,o)},this.renderSelectOptions(t.type,!0)),u?r("div",{class:"filter-extra"},u):""),r("div",{class:"multi-filter-list-action"},p,r(d,{ariaLabel:h.removeFilter,onClick:()=>this.onRemoveFilter(t.id)}))))}))),s?r("div",{class:"add-filter-divider"}):"")}componentDidRender(){this.syncDialog()}syncDialog(){this.dialog&&(this.changes?(this.dialog.open||this.dialog.show(),!1!==this.changes.autoCorrect&&(this.autoCorrect(this.dialog),requestAnimationFrame((()=>this.autoCorrect(this.dialog))))):this.dialog.open&&this.dialog.close())}autoCorrect(t){var e;if(!t||!this.changes)return;t.style.maxHeight="",t.style.left=this.changes.x+"px",t.style.top=this.changes.y+"px";const i=t.getBoundingClientRect(),r=null!==(e=this.changes.anchorY)&&void 0!==e?e:this.changes.y,o=this.changes.y,l=Math.max(0,r-8),s=Math.max(0,window.innerHeight-o-8),n=i.height>s&&l>s;t.style.maxHeight=Math.max(8,n?l:s)+"px";const a=t.getBoundingClientRect(),d=Math.max(8,window.innerWidth-a.width-8),h=Math.max(8,window.innerHeight-a.height-8),c=Math.min(Math.max(8,this.changes.x),d),p=Math.min(Math.max(8,n?r-a.height:o),h);t.style.left=c+"px",t.style.top=p+"px"}onFilterTypeChange(t,e,i,r=!1){if(!(t.target instanceof HTMLSelectElement))return;const o=t.target.value,l=r?this.promoteDraft(e,o):this.filterItems[e][i];l&&(l.type=o,this.hasChanges=!0,this.filterId++,setTimeout((()=>{const t=document.getElementById("filter-input-"+l.id);t instanceof HTMLInputElement&&t.focus()}),0),this.disableDynamicFiltering||this.debouncedApplyFilter())}onAddNewFilter(t){this.currentFilterType=t.target.value,this.addNewFilterToProp();const e=this.getAddFilterSelect();e&&(e.value=u,this.currentFilterType=u),this.disableDynamicFiltering||this.debouncedApplyFilter()}addNewFilterToProp(){var t;const e=null===(t=this.changes)||void 0===t?void 0:t.prop;(e||0===e)&&(this.filterItems[e]||(this.filterItems[e]=[]),"none"!==this.currentFilterType&&(this.filterId++,this.currentFilterId=this.filterId,this.draftFilter?(this.draftFilter.id=this.currentFilterId,this.draftFilter.type=this.currentFilterType,this.promoteDraft(e)):(this.filterItems[e].push({id:this.currentFilterId,type:this.currentFilterType,value:"",relation:"and"}),this.hasChanges=!0),setTimeout((()=>{const t=document.getElementById("filter-input-"+this.currentFilterId);t&&t.focus()}),0)))}onSave(){this.hasChanges&&this.emitFilterChange()}onCancel(){this.changes=void 0}onReset(){var t;this.assertChanges(),this.draftFilter=void 0;const e=null===(t=this.changes)||void 0===t?void 0:t.prop;void 0!==e&&delete this.filterItems[e],this.resetChange.emit(e),this.filterId++}onRemoveFilter(t){var e,i;this.assertChanges(),this.filterId++;const r=null===(e=this.changes)||void 0===e?void 0:e.prop;if((null===(i=this.draftFilter)||void 0===i?void 0:i.id)===t)return void(this.draftFilter=void 0);const o=this.filterItems[null!=r?r:""];if(!o)return;const l=o.findIndex((e=>e.id===t));-1!==l&&(o.splice(l,1),this.hasChanges=!0,0===o.length&&delete this.filterItems[null!=r?r:""],this.disableDynamicFiltering||this.debouncedApplyFilter())}onFilterDragStart(t,e){this.draggedFilterId=e,function(t,e){t&&(t.effectAllowed="move",t.setData(c,e+""),t.setData("text/plain",e+""))}(t.dataTransfer,e)}onFilterDragOver(t,e){void 0!==this.draggedFilterId&&this.draggedFilterId!==e&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.dragOverFilterId=e)}onFilterDragLeave(t){this.dragOverFilterId===t&&(this.dragOverFilterId=void 0)}onFilterDrop(t,e,i){var r;t.preventDefault();const o=null!==(r=this.draggedFilterId)&&void 0!==r?r:function(t){if(!t)return;const e=(t.getData(c)||t.getData("text/plain")).trim();if(!e)return;const i=Number(e);return Number.isFinite(i)?i:void 0}(t.dataTransfer);if(this.onFilterDragEnd(),void 0===o)return;const l=this.filterItems[e];l&&p(l,o,i)&&(this.hasChanges=!0,this.filterId++,this.disableDynamicFiltering||this.debouncedApplyFilter())}onFilterDragEnd(){this.draggedFilterId=void 0,this.dragOverFilterId=void 0}onFilterReorderKeyDown(t,e,i){let r=0;if("ArrowUp"===t.key)r=-1;else{if("ArrowDown"!==t.key)return;r=1}const o=this.filterItems[e];if(!o)return;const l=o.filter((t=>!t.hidden)),s=l.findIndex((t=>t.id===i));if(-1===s)return;t.preventDefault(),t.stopPropagation();const n=l[s+r];n&&p(o,i,n.id)&&(this.hasChanges=!0,this.filterId++,this.disableDynamicFiltering||this.debouncedApplyFilter())}toggleFilterAndOr(t){var e;this.assertChanges(),this.filterId++;const i=null===(e=this.changes)||void 0===e?void 0:e.prop,r=this.filterItems[null!=i?i:""];if(!r)return;const o=r.findIndex((e=>e.id===t));-1!==o&&(r[o].relation="and"===r[o].relation?"or":"and",this.hasChanges=!0,this.disableDynamicFiltering||this.debouncedApplyFilter())}assertChanges(){if(!this.changes)throw Error("Changes required per edit")}renderSelectOptions(t,e=!1){var i;if(!this.changes)return;const o=[],l=this.changes.prop;if(void 0===l)return;const s=new Set;Object.keys(this.filterItems).forEach((t=>{this.filterItems[t].forEach((t=>{t.hidden&&s.add(t.type)}))}));const n=new Set((null!==(i=this.filterItems[l])&&void 0!==i?i:[]).filter((t=>!t.hidden)).map((t=>t.type)));if(!e){const t=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);o.push(r("option",{selected:this.currentFilterType===u,value:u},l&&this.filterItems[l]&&this.filterItems[l].length>0?t.add:this.filterNames[u]))}for(let i in this.changes.filterTypes){const l=this.changes.filterTypes[i].filter((i=>!s.has(i)&&(this.allowDuplicateOperators||!n.has(i)||e&&t===i)));l.length&&(o.push(...l.map((e=>r("option",{value:e,selected:t===e},this.filterNames[e])))),o.push(r("option",{disabled:!0})))}return o}renderExtra(t,e,i=!1){var o,l;const s=i?this.draftFilter:null===(o=this.filterItems[t])||void 0===o?void 0:o[e];if(!s)return"";const n=e=>{s.value=e,i&&!this.isMeaningfulDraftValue(e)||i&&!this.promoteDraft(t)||(this.hasChanges=!0,this.disableDynamicFiltering||this.debouncedApplyFilter())},a=()=>{const t=this.getAddFilterSelect();t&&(t.value=u,this.currentFilterType=u,this.addNewFilterToProp(),t.focus())},d=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions),h=null===(l=this.filterEntities[s.type])||void 0===l?void 0:l.extra;return"function"==typeof h?h(r,{value:s.value,filter:s,prop:t,index:e,placeholder:d.placeholder,onInput:t=>{n(t)},onFocus:()=>{a()}}):"input"!==h&&"datepicker"!==h?"":r("input",{id:"filter-input-"+s.id,placeholder:d.placeholder,type:"datepicker"===h?"date":"text",value:s.value,onInput:t=>{t.target instanceof HTMLInputElement&&n(t.target.value)},onKeyDown:t=>{"enter"!==t.key.toLowerCase()?t.stopPropagation():this.getAddFilterSelect()&&a()}})}resolveDraftFilterType(t){var e,i;const r=Object.values(null!==(i=null===(e=this.changes)||void 0===e?void 0:e.filterTypes)&&void 0!==i?i:{}).flat();return t&&r.includes(t)?t:r[0]}promoteDraft(t,e){if(!this.draftFilter)return;this.filterItems[t]||(this.filterItems[t]=[]),e&&(this.draftFilter.type=e);const i=this.draftFilter;return this.filterItems[t].push(i),this.draftFilter=void 0,this.hasChanges=!0,i}isMeaningfulDraftValue(t){return""!==t&&null!=t}emitFilterChange(){this.filterChange.emit(this.cloneFilterItems(this.filterItems))}cloneFilterItems(t){return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,e.map((t=>Object.assign({},t)))])))}getAddFilterSelect(){return this.element.querySelector("#"+f)}isOwnFilterButton(t){if(!(t instanceof Element))return!1;if(!h(t))return!1;const e=this.getOwningGrid(this.element),i=this.getOwningGrid(t);return!!e&&e===i}getOwningGrid(t){const e=t.closest("revo-grid");if(e)return e;const i=t.getRootNode();return i instanceof ShadowRoot&&"revo-grid"===i.host.localName?i.host:void 0}render(){var t,e,i,l,s,n,a,d,h;const c={left:(null!==(e=null===(t=this.changes)||void 0===t?void 0:t.x)&&void 0!==e?e:0)+"px",top:(null!==(l=null===(i=this.changes)||void 0===i?void 0:i.y)&&void 0!==l?l:0)+"px"},p=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);return r(o,{key:"f7ec3ca1855a9391b4f270ad7056f9c7a4a0204e"},r("dialog",{key:"a5c46aa4822934e7a6eb455fd686513b9101afb4",class:"filter-panel-dialog",style:c,ref:t=>this.dialog=t,onCancel:t=>{t.preventDefault(),this.onCancel()}},this.changes&&[r("slot",{key:"header-slot",slot:"header"}),(null===(n=(s=this.changes).extraContent)||void 0===n?void 0:n.call(s,this.changes))||"",!0!==(null===(a=this.changes)||void 0===a?void 0:a.hideDefaultFilters)&&[r("label",{key:"filter-title"},p.title),r("div",{key:"filter-holder",class:"filter-holder"},this.getFilterItemsList()),r("div",{key:"add-filter",class:"add-filter"},r("select",{key:"3912f4bd9b1e66fda46e9b6d7c002d29da726345",id:f,class:"select-css",onChange:t=>this.onAddNewFilter(t)},this.renderSelectOptions(this.currentFilterType)))],r("slot",{key:"default-slot"}),(null===(h=(d=this.changes).extraBottomContent)||void 0===h?void 0:h.call(d,this.changes))||"",r("div",{key:"filter-actions",class:"filter-actions"},this.disableDynamicFiltering&&[r("button",{key:"save",type:"button",id:"revo-button-save","aria-label":"save",class:"revo-button green",onClick:()=>this.onSave()},p.save),r("button",{key:"cancel",type:"button",id:"revo-button-ok","aria-label":"ok",class:"revo-button green",onClick:()=>this.onCancel()},p.cancel)],!this.disableDynamicFiltering&&[r("button",{key:"ok",type:"button",id:"revo-button-ok","aria-label":"ok",class:"revo-button green",onClick:()=>this.onCancel()},p.ok),r("button",{key:"reset",type:"button",id:"revo-button-reset","aria-label":"reset",class:"revo-button outline",onClick:()=>this.onReset()},p.reset)]),r("slot",{key:"footer-slot",slot:"footer"})]))}get element(){return this}static get style(){return'.revo-button{position:relative;overflow:hidden;color:var(--rg-theme-button-text);background-color:var(--rg-theme-button-bg);height:32px;line-height:32px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:var(--rg-theme-button-success-bg)}.revo-button.red{background-color:var(--rg-theme-button-danger-bg)}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.outline{border:1px solid var(--rg-theme-button-outline-border);line-height:30px;background:none;color:var(--rg-theme-button-outline-text);box-shadow:none}revogr-filter-panel{display:block}revogr-filter-panel .filter-panel-dialog{position:fixed;top:0;left:0;z-index:100;max-height:calc(100vh - 16px);overflow:auto;opacity:1;transform:none;color:var(--rg-theme-filter-panel-text);background-color:var(--rg-theme-filter-panel-bg);border:1px solid var(--rg-theme-filter-panel-border);transform-origin:62px 0px;box-shadow:0 5px 18px -2px var(--rg-theme-filter-panel-shadow);box-sizing:border-box;padding:10px;border-radius:8px;margin:0;min-width:220px;text-align:left;animation:revogr-filter-panel-open 140ms cubic-bezier(0.2, 0, 0, 1)}revogr-filter-panel .filter-panel-dialog .filter-holder>div{display:flex;flex-direction:column}revogr-filter-panel .filter-panel-dialog label{font-size:13px;display:block;padding:8px 0}revogr-filter-panel .filter-panel-dialog select{width:100%}revogr-filter-panel .filter-panel-dialog input[type=text]{border:0;min-height:34px;margin:5px 0;color:var(--rg-theme-filter-panel-text);background:var(--rg-theme-filter-panel-input-bg);border-radius:5px;padding:0 10px;box-sizing:border-box;width:100%}revogr-filter-panel .filter-panel-dialog .filter-actions{position:sticky;right:0;bottom:-10px;left:0;z-index:1;text-align:right;margin:10px -10px -10px;padding:0 5px 10px 10px;background:var(--rg-theme-filter-panel-bg);border-top:1px solid var(--rg-theme-filter-panel-divider)}revogr-filter-panel .filter-panel-dialog .filter-actions button{margin-top:10px;margin-right:5px}@keyframes revogr-filter-panel-open{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@media (prefers-reduced-motion: reduce){revogr-filter-panel .filter-panel-dialog{animation:none}}.rgHeaderCell:hover .rv-filter{transition:opacity 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, width 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 178ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}.rgHeaderCell:hover:has(.rv-filter) .header-content,.rgHeaderCell:focus-within:has(.rv-filter) .header-content,.rgHeaderCell:has(.rv-filter.active) .header-content{margin-right:24px}.rgHeaderCell:hover:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:hover:has(.rv-filter):has(.asc) .header-content,.rgHeaderCell:focus-within:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:focus-within:has(.rv-filter):has(.asc) .header-content,.rgHeaderCell:has(.rv-filter.active):has(.desc) .header-content,.rgHeaderCell:has(.rv-filter.active):has(.asc) .header-content{margin-right:8px;padding-right:24px}.rgHeaderCell:hover .rv-filter,.rgHeaderCell:focus-within .rv-filter,.rgHeaderCell .rv-filter.active{opacity:1;width:24px}@media (hover: none), (pointer: coarse){.rgHeaderCell:has(.rv-filter) .header-content{margin-right:24px}.rgHeaderCell:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:has(.rv-filter):has(.asc) .header-content{margin-right:8px;padding-right:24px}.rgHeaderCell .rv-filter{opacity:1;width:24px}}.rgHeaderCell .rv-filter{height:24px;width:0;background:none;border:0;opacity:0;visibility:visible;cursor:pointer;border-radius:4px;position:relative;z-index:1;padding:0}.rgHeaderCell .rv-filter.active{color:var(--rg-theme-filter-panel-icon-active)}.rgHeaderCell .rv-filter .filter-img{color:var(--rg-theme-filter-panel-icon);width:11px}.select-css{display:block;font-family:sans-serif;line-height:1.3;padding:0.6em 1.4em 0.5em 0.8em;width:100%;max-width:100%;box-sizing:border-box;margin:0;color:var(--rg-theme-filter-panel-text);border:1px solid var(--rg-theme-filter-panel-select-border);box-shadow:transparent;border-radius:0.5em;appearance:none;background-color:var(--rg-theme-filter-panel-input-bg);background-image:var(--revo-grid-filter-panel-select-arrow, url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"));background-repeat:no-repeat, repeat;background-position:right 0.7em top 50%, 0 0;background-size:0.65em auto, 100%;}.select-css::-ms-expand{display:none}.select-css{}.select-css:hover{border-color:var(--rg-theme-filter-panel-select-border)}.select-css{}.select-css:focus{border-color:var(--rg-theme-filter-panel-select-border-hover);box-shadow:var(--rg-theme-filter-panel-focus-ring);outline:none}.select-css{}.select-css option{font-weight:normal}.select-css{}.select-css:disabled,.select-css[aria-disabled=true]{color:var(--rg-theme-filter-panel-muted-text);background-image:var(--revo-grid-filter-panel-select-arrow-disabled, url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22graytext%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"))}.select-css:disabled:hover,.select-css[aria-disabled=true]{border-color:var(--rg-theme-filter-panel-select-border)}.multi-filter-list{margin-top:5px;margin-bottom:5px}.multi-filter-list div{white-space:nowrap}.multi-filter-list .multi-filter-list-row{display:flex;align-items:center;gap:6px;position:relative}.multi-filter-list .multi-filter-list-row.filter-row-dragging{opacity:0.65}.multi-filter-list .multi-filter-list-row.filter-row-drag-over::before{content:"";position:absolute;top:-4px;right:0;left:0;z-index:2;height:2px;background:var(--rg-theme-filter-panel-reorder-accent);border-radius:999px;box-shadow:0 0 0 2px var(--rg-theme-filter-panel-bg)}.multi-filter-list .multi-filter-list-row.filter-row-drop-active .filter-row-drop-target{pointer-events:auto}.multi-filter-list .filter-row-drop-target{position:absolute;inset:0;z-index:1;padding:0;pointer-events:none;background:transparent;border:0}.multi-filter-list .multi-filter-list-action{display:flex;align-self:stretch;flex:0 0 auto;justify-content:flex-end;align-items:center}.multi-filter-list .and-or-button{margin:0 0 0 10px;min-width:58px;cursor:pointer}.multi-filter-list .trash-button{margin:0 0 -2px 6px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer;width:22px;height:100%;font-size:16px}.multi-filter-list .trash-button .trash-img{width:1em}.multi-filter-list .reorder-button{border:0;background:transparent;color:var(--rg-theme-filter-panel-reorder-color);cursor:grab;font-family:monospace;font-size:12px;letter-spacing:0;line-height:1;padding:6px 2px;transform:scaleX(0.8);width:16px}.multi-filter-list .reorder-button.filter-row-drag-over{color:var(--rg-theme-filter-panel-reorder-accent)}.multi-filter-list .reorder-button:active{cursor:grabbing}.multi-filter-list-container{padding:0;margin:0;list-style:none}.add-filter-divider{display:block;margin:0 -10px 10px -10px;border-bottom:1px solid var(--rg-theme-filter-panel-divider);height:10px}.select-input{display:flex;align-items:center;flex:1 1 auto;gap:6px;min-width:0}.select-input .select-filter,.select-input .filter-extra{flex:1 1 0;min-width:0}.select-input .select-filter{width:auto}.select-input .filter-extra{display:flex}.select-input .filter-extra>*{width:100%}.select-input input[type=text],.select-input input[type=date]{margin:0}'}},[260,"revogr-filter-panel",{filterNames:[16],filterEntities:[16],filterCaptions:[16],disableDynamicFiltering:[4,"disable-dynamic-filtering"],closeOnOutsideClick:[4,"close-on-outside-click"],allowDuplicateOperators:[4,"allow-duplicate-operators"],isFilterIdSet:[32],filterId:[32],currentFilterId:[32],currentFilterType:[32],changes:[32],filterItems:[32],draftFilter:[32],draggedFilterId:[32],dragOverFilterId:[32],show:[64],getChanges:[64]},[[5,"mousedown","onMouseDown"]]]),v=g,m=function(){"undefined"!=typeof customElements&&["revogr-filter-panel"].forEach((t=>{"revogr-filter-panel"===t&&(customElements.get(l(t))||customElements.define(l(t),g))}))};export{v as RevogrFilterPanel,m as defineCustomElement}
4
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as r,Host as o,transformTag as l}from"@stencil/core/internal/client";import{d as s}from"./debounce.js";import{e as n,f as a,d,i as h}from"./filter.button.js";Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){let e=this;do{if(Element.prototype.matches.call(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null});const c="text/revogrid-filter-id";function p(t,e,i){if(e===i)return!1;const r=t.findIndex((t=>t.id===e)),o=t.findIndex((t=>t.id===i));if(-1===r||-1===o||r===o)return!1;const l=t.map((t=>{var e;return null!==(e=t.relation)&&void 0!==e?e:"and"})),[s]=t.splice(r,1);return t.splice(o,0,s),t.forEach(((e,i)=>{var r;e.relation=i===t.length-1?"and":null!==(r=l[i])&&void 0!==r?r:"and"})),!0}const u="none",f="add-filter",g=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.filterChange=i(this,"filterChange",7),this.resetChange=i(this,"resetChange",7),this.hasChanges=!1,this.filterCaptionsInternal={title:"Filter by",ok:"Close",save:"Save",reset:"Reset",cancel:"Cancel",add:"Add condition",placeholder:"Enter value...",and:"and",or:"or",filterCondition:"Filter condition",removeFilter:"Remove filter",reorderFilter:"Reorder filter"},this.isFilterIdSet=!1,this.filterId=0,this.currentFilterId=-1,this.currentFilterType=u,this.filterItems={},this.filterNames={},this.filterEntities={},this.disableDynamicFiltering=!1,this.closeOnOutsideClick=!0,this.allowDuplicateOperators=!0,this.debouncedApplyFilter=s((()=>{this.emitFilterChange()}),400)}onMouseDown(t){if(!this.changes)return;const e=t.composedPath(),i=this.getAddFilterSelect();if(i instanceof HTMLSelectElement){if(e.includes(i))return;i.value=u}this.currentFilterType=u,this.changes&&(this.changes.type=u),this.currentFilterId=-1,!e.includes(this.element)&&!this.isOwnFilterButton(t.target)&&this.closeOnOutsideClick&&(this.changes=void 0)}async show(t){if(this.debouncedApplyFilter.flush(),this.hasChanges=!1,this.changes=t,this.filterItems=this.cloneFilterItems((null==t?void 0:t.filterItems)||{}),this.draftFilter=void 0,this.changes){this.changes.type=this.changes.type||u;const t=this.changes.prop,e=void 0===t?void 0:this.filterItems[t];if(!(null==e?void 0:e.length)&&!1!==this.changes.showDefaultFilter&&!0!==this.changes.hideDefaultFilters){const t=this.resolveDraftFilterType(this.changes.defaultFilterType);t&&(this.draftFilter={id:++this.filterId,type:t,value:"",relation:"and"})}}}async getChanges(){return this.changes}componentWillRender(){if(!this.isFilterIdSet){this.isFilterIdSet=!0;const t=Object.keys(this.filterItems);for(const e of t)this.filterId+=this.filterItems[e].length}}getFilterItemsList(){var t,e;const i=null===(t=this.changes)||void 0===t?void 0:t.prop;if(void 0===i)return"";const o=(null!==(e=this.filterItems[i])&&void 0!==e?e:[]).map(((t,e)=>({filter:t,index:e,isDraft:!1})));this.draftFilter&&o.push({filter:this.draftFilter,index:o.length,isDraft:!0});const l=o.filter((({filter:t})=>!t.hidden)),s=l.length,h=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);return r("div",{key:this.filterId},r("ul",{class:"multi-filter-list-container"},o.map((({filter:t,index:e,isDraft:o})=>{var c;let p;if(t.hidden)return;(null===(c=l[s-1])||void 0===c?void 0:c.filter.id)!==t.id&&(p=r(n,{text:"and"===t.relation?h.and:h.or,onClick:()=>this.toggleFilterAndOr(t.id)}));const u=this.renderExtra(i,e,o),f=this.draggedFilterId===t.id,g=this.dragOverFilterId===t.id&&!f,v=s>1&&!o;return r("li",{key:t.id,class:"multi-filter-list","aria-label":`${h.filterCondition} ${e+1}`},r("div",{class:{"multi-filter-list-row":!0,"filter-row-drop-active":void 0!==this.draggedFilterId&&!f,"filter-row-dragging":f,"filter-row-drag-over":g}},v?r("button",{type:"button",class:"filter-row-drop-target",tabIndex:-1,"aria-label":`${h.filterCondition} ${e+1}`,onDragOver:e=>this.onFilterDragOver(e,t.id),onDragLeave:()=>this.onFilterDragLeave(t.id),onDrop:e=>this.onFilterDrop(e,i,t.id)}):"",v?r(a,{ariaLabel:h.reorderFilter,dragging:f,dragOver:g,onDragStart:e=>this.onFilterDragStart(e,t.id),onDragEnd:()=>this.onFilterDragEnd(),onKeyDown:e=>this.onFilterReorderKeyDown(e,i,t.id)}):"",r("div",{class:{"select-input":!0}},r("select",{class:"select-css select-filter",onChange:t=>this.onFilterTypeChange(t,i,e,o)},this.renderSelectOptions(t.type,!0)),u?r("div",{class:"filter-extra"},u):""),r("div",{class:"multi-filter-list-action"},p,r(d,{ariaLabel:h.removeFilter,onClick:()=>this.onRemoveFilter(t.id)}))))}))),s?r("div",{class:"add-filter-divider"}):"")}componentDidRender(){this.syncDialog()}syncDialog(){this.dialog&&(this.changes?(this.dialog.open||this.dialog.show(),!1!==this.changes.autoCorrect&&(this.autoCorrect(this.dialog),requestAnimationFrame((()=>this.autoCorrect(this.dialog))))):this.dialog.open&&this.dialog.close())}autoCorrect(t){var e;if(!t||!this.changes)return;t.style.maxHeight="",t.style.left=this.changes.x+"px",t.style.top=this.changes.y+"px";const i=t.getBoundingClientRect(),r=null!==(e=this.changes.anchorY)&&void 0!==e?e:this.changes.y,o=this.changes.y,l=Math.max(0,r-8),s=Math.max(0,window.innerHeight-o-8),n=i.height>s&&l>s;t.style.maxHeight=Math.max(8,n?l:s)+"px";const a=t.getBoundingClientRect(),d=Math.max(8,window.innerWidth-a.width-8),h=Math.max(8,window.innerHeight-a.height-8),c=Math.min(Math.max(8,this.changes.x),d),p=Math.min(Math.max(8,n?r-a.height:o),h);t.style.left=c+"px",t.style.top=p+"px"}onFilterTypeChange(t,e,i,r=!1){if(!(t.target instanceof HTMLSelectElement))return;const o=t.target.value,l=r?this.promoteDraft(e,o):this.filterItems[e][i];l&&(l.type=o,this.hasChanges=!0,this.filterId++,setTimeout((()=>{const t=document.getElementById("filter-input-"+l.id);t instanceof HTMLInputElement&&t.focus()}),0),this.disableDynamicFiltering||this.debouncedApplyFilter())}onAddNewFilter(t){this.currentFilterType=t.target.value,this.addNewFilterToProp();const e=this.getAddFilterSelect();e&&(e.value=u,this.currentFilterType=u),this.disableDynamicFiltering||this.debouncedApplyFilter()}addNewFilterToProp(){var t;const e=null===(t=this.changes)||void 0===t?void 0:t.prop;(e||0===e)&&(this.filterItems[e]||(this.filterItems[e]=[]),"none"!==this.currentFilterType&&(this.filterId++,this.currentFilterId=this.filterId,this.draftFilter?(this.draftFilter.id=this.currentFilterId,this.draftFilter.type=this.currentFilterType,this.promoteDraft(e)):(this.filterItems[e].push({id:this.currentFilterId,type:this.currentFilterType,value:"",relation:"and"}),this.hasChanges=!0),setTimeout((()=>{const t=document.getElementById("filter-input-"+this.currentFilterId);t&&t.focus()}),0)))}onSave(){this.hasChanges&&this.emitFilterChange()}onCancel(){this.changes=void 0}onReset(){var t;this.assertChanges(),this.draftFilter=void 0;const e=null===(t=this.changes)||void 0===t?void 0:t.prop;void 0!==e&&delete this.filterItems[e],this.resetChange.emit(e),this.filterId++}onRemoveFilter(t){var e,i;this.assertChanges(),this.filterId++;const r=null===(e=this.changes)||void 0===e?void 0:e.prop;if((null===(i=this.draftFilter)||void 0===i?void 0:i.id)===t)return void(this.draftFilter=void 0);const o=this.filterItems[null!=r?r:""];if(!o)return;const l=o.findIndex((e=>e.id===t));-1!==l&&(o.splice(l,1),this.hasChanges=!0,0===o.length&&delete this.filterItems[null!=r?r:""],this.disableDynamicFiltering||this.debouncedApplyFilter())}onFilterDragStart(t,e){this.draggedFilterId=e,function(t,e){t&&(t.effectAllowed="move",t.setData(c,e+""),t.setData("text/plain",e+""))}(t.dataTransfer,e)}onFilterDragOver(t,e){void 0!==this.draggedFilterId&&this.draggedFilterId!==e&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.dragOverFilterId=e)}onFilterDragLeave(t){this.dragOverFilterId===t&&(this.dragOverFilterId=void 0)}onFilterDrop(t,e,i){var r;t.preventDefault();const o=null!==(r=this.draggedFilterId)&&void 0!==r?r:function(t){if(!t)return;const e=(t.getData(c)||t.getData("text/plain")).trim();if(!e)return;const i=Number(e);return Number.isFinite(i)?i:void 0}(t.dataTransfer);if(this.onFilterDragEnd(),void 0===o)return;const l=this.filterItems[e];l&&p(l,o,i)&&(this.hasChanges=!0,this.filterId++,this.disableDynamicFiltering||this.debouncedApplyFilter())}onFilterDragEnd(){this.draggedFilterId=void 0,this.dragOverFilterId=void 0}onFilterReorderKeyDown(t,e,i){let r=0;if("ArrowUp"===t.key)r=-1;else{if("ArrowDown"!==t.key)return;r=1}const o=this.filterItems[e];if(!o)return;const l=o.filter((t=>!t.hidden)),s=l.findIndex((t=>t.id===i));if(-1===s)return;t.preventDefault(),t.stopPropagation();const n=l[s+r];n&&p(o,i,n.id)&&(this.hasChanges=!0,this.filterId++,this.disableDynamicFiltering||this.debouncedApplyFilter())}toggleFilterAndOr(t){var e;this.assertChanges(),this.filterId++;const i=null===(e=this.changes)||void 0===e?void 0:e.prop,r=this.filterItems[null!=i?i:""];if(!r)return;const o=r.findIndex((e=>e.id===t));-1!==o&&(r[o].relation="and"===r[o].relation?"or":"and",this.hasChanges=!0,this.disableDynamicFiltering||this.debouncedApplyFilter())}assertChanges(){if(!this.changes)throw Error("Changes required per edit")}renderSelectOptions(t,e=!1){var i;if(!this.changes)return;const o=[],l=this.changes.prop;if(void 0===l)return;const s=new Set;Object.keys(this.filterItems).forEach((t=>{this.filterItems[t].forEach((t=>{t.hidden&&s.add(t.type)}))}));const n=new Set((null!==(i=this.filterItems[l])&&void 0!==i?i:[]).filter((t=>!t.hidden)).map((t=>t.type)));if(!e){const t=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);o.push(r("option",{selected:this.currentFilterType===u,value:u},l&&this.filterItems[l]&&this.filterItems[l].length>0?t.add:this.filterNames[u]))}for(let i in this.changes.filterTypes){const l=this.changes.filterTypes[i].filter((i=>!s.has(i)&&(this.allowDuplicateOperators||!n.has(i)||e&&t===i)));l.length&&(o.push(...l.map((e=>r("option",{value:e,selected:t===e},this.filterNames[e])))),o.push(r("option",{disabled:!0})))}return o}renderExtra(t,e,i=!1){var o,l;const s=i?this.draftFilter:null===(o=this.filterItems[t])||void 0===o?void 0:o[e];if(!s)return"";const n=e=>{s.value=e,i&&!this.isMeaningfulDraftValue(e)||i&&!this.promoteDraft(t)||(this.hasChanges=!0,this.disableDynamicFiltering||this.debouncedApplyFilter())},a=()=>{const t=this.getAddFilterSelect();t&&(t.value=u,this.currentFilterType=u,this.addNewFilterToProp(),t.focus())},d=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions),h=null===(l=this.filterEntities[s.type])||void 0===l?void 0:l.extra;return"function"==typeof h?h(r,{value:s.value,filter:s,prop:t,index:e,placeholder:d.placeholder,onInput:t=>{n(t)},onFocus:()=>{a()}}):"input"!==h&&"datepicker"!==h?"":r("input",{id:"filter-input-"+s.id,placeholder:d.placeholder,type:"datepicker"===h?"date":"text",value:s.value,onInput:t=>{t.target instanceof HTMLInputElement&&n(t.target.value)},onKeyDown:t=>{"enter"!==t.key.toLowerCase()?t.stopPropagation():this.getAddFilterSelect()&&a()}})}resolveDraftFilterType(t){var e,i;const r=Object.values(null!==(i=null===(e=this.changes)||void 0===e?void 0:e.filterTypes)&&void 0!==i?i:{}).flat();return t&&r.includes(t)?t:r[0]}promoteDraft(t,e){if(!this.draftFilter)return;this.filterItems[t]||(this.filterItems[t]=[]),e&&(this.draftFilter.type=e);const i=this.draftFilter;return this.filterItems[t].push(i),this.draftFilter=void 0,this.hasChanges=!0,i}isMeaningfulDraftValue(t){return""!==t&&null!=t}emitFilterChange(){this.filterChange.emit(this.cloneFilterItems(this.filterItems))}cloneFilterItems(t){return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,e.map((t=>Object.assign({},t)))])))}getAddFilterSelect(){return this.element.querySelector("#"+f)}isOwnFilterButton(t){if(!(t instanceof Element))return!1;if(!h(t))return!1;const e=this.getOwningGrid(this.element),i=this.getOwningGrid(t);return!!e&&e===i}getOwningGrid(t){const e=t.closest("revo-grid");if(e)return e;const i=t.getRootNode();return i instanceof ShadowRoot&&"revo-grid"===i.host.localName?i.host:void 0}render(){var t,e,i,l,s,n,a,d,h;const c={left:(null!==(e=null===(t=this.changes)||void 0===t?void 0:t.x)&&void 0!==e?e:0)+"px",top:(null!==(l=null===(i=this.changes)||void 0===i?void 0:i.y)&&void 0!==l?l:0)+"px"},p=Object.assign(Object.assign({},this.filterCaptionsInternal),this.filterCaptions);return r(o,{key:"d0207c7c243134808f89dc0f024d4b46e18fb3d9"},r("dialog",{key:"1466680fc6bf4c4464600122bd16a7627131745f",class:"filter-panel-dialog",style:c,ref:t=>this.dialog=t,onCancel:t=>{t.preventDefault(),this.onCancel()}},this.changes&&[r("slot",{key:"header-slot",slot:"header"}),(null===(n=(s=this.changes).extraContent)||void 0===n?void 0:n.call(s,this.changes))||"",!0!==(null===(a=this.changes)||void 0===a?void 0:a.hideDefaultFilters)&&[r("label",{key:"filter-title"},p.title),r("div",{key:"filter-holder",class:"filter-holder"},this.getFilterItemsList()),r("div",{key:"add-filter",class:"add-filter"},r("select",{key:"c924b40863671e714e67eef2b6465b861805bac2",id:f,class:"select-css",onChange:t=>this.onAddNewFilter(t)},this.renderSelectOptions(this.currentFilterType)))],r("slot",{key:"default-slot"}),(null===(h=(d=this.changes).extraBottomContent)||void 0===h?void 0:h.call(d,this.changes))||"",r("div",{key:"filter-actions",class:"filter-actions"},this.disableDynamicFiltering&&[r("button",{key:"save",type:"button",id:"revo-button-save","aria-label":"save",class:"revo-button green",onClick:()=>this.onSave()},p.save),r("button",{key:"cancel",type:"button",id:"revo-button-ok","aria-label":"ok",class:"revo-button green",onClick:()=>this.onCancel()},p.cancel)],!this.disableDynamicFiltering&&[r("button",{key:"ok",type:"button",id:"revo-button-ok","aria-label":"ok",class:"revo-button green",onClick:()=>this.onCancel()},p.ok),r("button",{key:"reset",type:"button",id:"revo-button-reset","aria-label":"reset",class:"revo-button outline",onClick:()=>this.onReset()},p.reset)]),r("slot",{key:"footer-slot",slot:"footer"})]))}get element(){return this}static get style(){return'.revo-button{position:relative;overflow:hidden;color:var(--rg-theme-button-text);background-color:var(--rg-theme-button-bg);height:32px;line-height:32px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:var(--rg-theme-button-success-bg)}.revo-button.red{background-color:var(--rg-theme-button-danger-bg)}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.outline{border:1px solid var(--rg-theme-button-outline-border);line-height:30px;background:none;color:var(--rg-theme-button-outline-text);box-shadow:none}revogr-filter-panel{display:block}revogr-filter-panel .filter-panel-dialog{position:fixed;top:0;left:0;z-index:100;max-height:calc(100vh - 16px);overflow:auto;opacity:1;transform:none;color:var(--rg-theme-filter-panel-text);background-color:var(--rg-theme-filter-panel-bg);border:1px solid var(--rg-theme-filter-panel-border);transform-origin:62px 0px;box-shadow:0 5px 18px -2px var(--rg-theme-filter-panel-shadow);box-sizing:border-box;padding:10px;border-radius:8px;margin:0;min-width:220px;text-align:left;animation:revogr-filter-panel-open 140ms cubic-bezier(0.2, 0, 0, 1)}revogr-filter-panel .filter-panel-dialog .filter-holder>div{display:flex;flex-direction:column}revogr-filter-panel .filter-panel-dialog label{font-size:13px;display:block;padding:8px 0}revogr-filter-panel .filter-panel-dialog select{width:100%}revogr-filter-panel .filter-panel-dialog input[type=text]{border:0;min-height:34px;margin:5px 0;color:var(--rg-theme-filter-panel-text);background:var(--rg-theme-filter-panel-input-bg);border-radius:5px;padding:0 10px;box-sizing:border-box;width:100%}revogr-filter-panel .filter-panel-dialog .filter-actions{position:sticky;right:0;bottom:-10px;left:0;z-index:1;text-align:right;margin:10px -10px -10px;padding:0 5px 10px 10px;background:var(--rg-theme-filter-panel-bg);border-top:1px solid var(--rg-theme-filter-panel-divider)}revogr-filter-panel .filter-panel-dialog .filter-actions button{margin-top:10px;margin-right:5px}@keyframes revogr-filter-panel-open{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@media (prefers-reduced-motion: reduce){revogr-filter-panel .filter-panel-dialog{animation:none}}.rgHeaderCell:hover .rv-filter{transition:opacity 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, width 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 178ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}.rgHeaderCell:hover:has(.rv-filter) .header-content,.rgHeaderCell:focus-within:has(.rv-filter) .header-content,.rgHeaderCell:has(.rv-filter.active) .header-content{margin-right:24px}.rgHeaderCell:hover:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:hover:has(.rv-filter):has(.asc) .header-content,.rgHeaderCell:focus-within:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:focus-within:has(.rv-filter):has(.asc) .header-content,.rgHeaderCell:has(.rv-filter.active):has(.desc) .header-content,.rgHeaderCell:has(.rv-filter.active):has(.asc) .header-content{margin-right:8px;padding-right:24px}.rgHeaderCell:hover .rv-filter,.rgHeaderCell:focus-within .rv-filter,.rgHeaderCell .rv-filter.active{opacity:1;width:24px}@media (hover: none), (pointer: coarse){.rgHeaderCell:has(.rv-filter) .header-content{margin-right:24px}.rgHeaderCell:has(.rv-filter):has(.desc) .header-content,.rgHeaderCell:has(.rv-filter):has(.asc) .header-content{margin-right:8px;padding-right:24px}.rgHeaderCell .rv-filter{opacity:1;width:24px}}.rgHeaderCell .rv-filter{height:24px;width:0;background:none;border:0;opacity:0;visibility:visible;cursor:pointer;border-radius:4px;position:relative;z-index:1;padding:0}.rgHeaderCell .rv-filter.active{color:var(--rg-theme-filter-panel-icon-active)}.rgHeaderCell .rv-filter .filter-img{color:var(--rg-theme-filter-panel-icon);width:11px}.select-css{display:block;font-family:sans-serif;line-height:1.3;padding:0.6em 1.4em 0.5em 0.8em;width:100%;max-width:100%;box-sizing:border-box;margin:0;color:var(--rg-theme-filter-panel-text);border:1px solid var(--rg-theme-filter-panel-select-border);box-shadow:transparent;border-radius:0.5em;appearance:none;background-color:var(--rg-theme-filter-panel-input-bg);background-image:var(--revo-grid-filter-panel-select-arrow, url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"));background-repeat:no-repeat, repeat;background-position:right 0.7em top 50%, 0 0;background-size:0.65em auto, 100%;}.select-css::-ms-expand{display:none}.select-css{}.select-css:hover{border-color:var(--rg-theme-filter-panel-select-border)}.select-css{}.select-css:focus{border-color:var(--rg-theme-filter-panel-select-border-hover);box-shadow:var(--rg-theme-filter-panel-focus-ring);outline:none}.select-css{}.select-css option{font-weight:normal}.select-css{}.select-css:disabled,.select-css[aria-disabled=true]{color:var(--rg-theme-filter-panel-muted-text);background-image:var(--revo-grid-filter-panel-select-arrow-disabled, url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22graytext%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"))}.select-css:disabled:hover,.select-css[aria-disabled=true]{border-color:var(--rg-theme-filter-panel-select-border)}.multi-filter-list{margin-top:5px;margin-bottom:5px}.multi-filter-list div{white-space:nowrap}.multi-filter-list .multi-filter-list-row{display:flex;align-items:center;gap:6px;position:relative}.multi-filter-list .multi-filter-list-row.filter-row-dragging{opacity:0.65}.multi-filter-list .multi-filter-list-row.filter-row-drag-over::before{content:"";position:absolute;top:-4px;right:0;left:0;z-index:2;height:2px;background:var(--rg-theme-filter-panel-reorder-accent);border-radius:999px;box-shadow:0 0 0 2px var(--rg-theme-filter-panel-bg)}.multi-filter-list .multi-filter-list-row.filter-row-drop-active .filter-row-drop-target{pointer-events:auto}.multi-filter-list .filter-row-drop-target{position:absolute;inset:0;z-index:1;padding:0;pointer-events:none;background:transparent;border:0}.multi-filter-list .multi-filter-list-action{display:flex;align-self:stretch;flex:0 0 auto;justify-content:flex-end;align-items:center}.multi-filter-list .and-or-button{margin:0 0 0 10px;min-width:58px;cursor:pointer}.multi-filter-list .trash-button{margin:0 0 -2px 6px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer;width:22px;height:100%;font-size:16px}.multi-filter-list .trash-button .trash-img{width:1em}.multi-filter-list .reorder-button{border:0;background:transparent;color:var(--rg-theme-filter-panel-reorder-color);cursor:grab;font-family:monospace;font-size:12px;letter-spacing:0;line-height:1;padding:6px 2px;transform:scaleX(0.8);width:16px}.multi-filter-list .reorder-button.filter-row-drag-over{color:var(--rg-theme-filter-panel-reorder-accent)}.multi-filter-list .reorder-button:active{cursor:grabbing}.multi-filter-list-container{padding:0;margin:0;list-style:none}.add-filter-divider{display:block;margin:0 -10px 10px -10px;border-bottom:1px solid var(--rg-theme-filter-panel-divider);height:10px}.select-input{display:flex;align-items:center;flex:1 1 auto;gap:6px;min-width:0}.select-input .select-filter,.select-input .filter-extra{flex:1 1 0;min-width:0}.select-input .select-filter{width:auto}.select-input .filter-extra{display:flex}.select-input .filter-extra>*{width:100%}.select-input input[type=text],.select-input input[type=date]{margin:0}'}},[260,"revogr-filter-panel",{filterNames:[16],filterEntities:[16],filterCaptions:[16],disableDynamicFiltering:[4,"disable-dynamic-filtering"],closeOnOutsideClick:[4,"close-on-outside-click"],allowDuplicateOperators:[4,"allow-duplicate-operators"],isFilterIdSet:[32],filterId:[32],currentFilterId:[32],currentFilterType:[32],changes:[32],filterItems:[32],draftFilter:[32],draggedFilterId:[32],dragOverFilterId:[32],show:[64],getChanges:[64]},[[5,"mousedown","onMouseDown"]]]),v=g,m=function(){"undefined"!=typeof customElements&&["revogr-filter-panel"].forEach((t=>{"revogr-filter-panel"===t&&(customElements.get(l(t))||customElements.define(l(t),g))}))};export{v as RevogrFilterPanel,m as defineCustomElement}