datatables.net-columncontrol 1.0.3 → 1.0.5
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! ColumnControl 1.0.
|
|
1
|
+
/*! ColumnControl 1.0.5
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*
|
|
4
4
|
* SVG icons: ISC License
|
|
5
5
|
* Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT).
|
|
6
6
|
* All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
7
7
|
*/
|
|
8
|
-
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function createElement(t,e,n,r){void 0===e&&(e=[]),void 0===n&&(n=null),void 0===r&&(r=[]);var o=document.createElement(t);return addClass(o,e),n&&(o.innerHTML=n),r.forEach(function(t){o.appendChild(t)}),o}function addClass(e,t){t&&(t=Array.isArray(t)?t:[t]).forEach(function(t){t&&e.classList.add(t)})}function wrap(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">'+t+"</svg>"}var icons={chevronRight:wrap('<path d="m9 18 6-6-6-6"/>'),columns:wrap('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/><path d="M15 3v18"/>'),contains:wrap('<path d="M10 3h4v18h-4z"/><path d="M18 8h3v9h-3"/><path d="M6 17H3V8h3"/>'),empty:wrap('<circle cx="12" cy="12" r="10"/>'),ends:wrap('<path d="M21 3h-4v18h4z"/><path d="M13 8H3v9h10"/>'),equal:wrap('<line x1="5" x2="19" y1="9" y2="9"/><line x1="5" x2="19" y1="15" y2="15"/>'),greater:wrap('<path d="m9 18 6-6-6-6"/>'),greaterOrEqual:wrap('<path d="m9 16 6-6-6-6"/><path d="m9 21 6-6"/>'),less:wrap('<path d="m15 18-6-6 6-6"/>'),lessOrEqual:wrap('<path d="m15 16-6-6 6-6"/><path d="m15 21-6-6"/>'),menu:wrap('<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>'),move:wrap('<line x1="12" x2="12" y1="3" y2="21"/><polyline points="8 8 4 12 8 16"/><polyline points="16 16 20 12 16 8"/>'),moveLeft:wrap('<path d="m9 6-6 6 6 6"/><path d="M3 12h14"/><path d="M21 19V5"/>'),moveRight:wrap('<path d="M3 5v14"/><path d="M21 12H7"/><path d="m15 18 6-6-6-6"/>'),notContains:wrap('<path d="M15 4 9 20"/><path d="M3 8h18v9H3z"/>'),notEmpty:wrap('<circle cx="12" cy="12" r="10"/><line x1="9" x2="15" y1="15" y2="9"/>'),notEqual:wrap('<path d="M5 9h14"/><path d="M5 15h14"/><path d="M15 5 9 19"/>'),orderAddAsc:wrap('<path d="M17 21v-8"/><path d="M3 4h6"/><path d="M3 8h9"/><path d="M3 12h10"/><path d="M13 17h8"/>'),orderAddDesc:wrap('<path d="M17 21v-8"/><path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="M13 17h8"/>'),orderAsc:wrap('<path d="m3 8 4-4 4 4"/><path d="M7 4v16"/><path d="M11 12h4"/><path d="M11 16h7"/><path d="M11 20h10"/>'),orderClear:wrap('<path d="m21 21-8-8"/><path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="m13 21 8-8"/>'),orderDesc:wrap('<path d="m3 16 4 4 4-4"/><path d="M7 20V4"/><path d="M11 4h10"/><path d="M11 8h7"/><path d="M11 12h4"/>'),orderRemove:wrap('<path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="M13 17h8"/>'),orderNone:wrap('<path d="m3 8 4-4 4 4"/><path d="m11 16-4 4-4-4"/><path d="M7 4v16"/><path d="M15 8h6"/><path d="M15 16h6"/><path d="M13 12h8"/>'),search:wrap('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),searchClear:wrap('<path d="m13.5 8.5-5 5"/><path d="m8.5 8.5 5 5"/><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),starts:wrap('<path d="M3 3h4v18H3z"/><path d="M11 8h10v9H11"/>'),tick:wrap('<path d="M20 6 9 17l-5-5"/>'),x:wrap('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>')};function close(e){void 0===e&&(e=null),document.querySelectorAll("div.dtcc-dropdown").forEach(function(t){null!==e&&t.contains(e.target)||(t._close(),e._closed||(e._closed=[]),e._closed.push(t))})}function positionDropdown(t,e,n){var e=e.table().container(),r=n.closest("div.dt-column-header"),r=getComputedStyle(r),o=t.offsetWidth,i=relativePosition(e,n),a=i.top+n.offsetHeight,r="row-reverse"===r.flexDirection?i.left:i.left-o+n.offsetWidth,i=e.offsetWidth;i<r+o&&(r-=r+o-i),r<0&&(r=0),t.style.top=a+"px",t.style.left=r+"px"}function attachDropdown(e,t,n){function r(t){e._shown?t.target===e||e.contains(t.target)||(e._close(),document.body.removeEventListener("click",r)):document.body.removeEventListener("click",r)}var o=t.table().container();e._shown=!0,o.append(e),positionDropdown(e,t,n.element());return document.body.addEventListener("click",r),r}function relativePosition(t,e){for(var n=0,r=0;e&&e!==t&&e!==document.body;)n+=e.offsetTop,r+=e.offsetLeft,e.scrollTop&&(r-=e.scrollTop),e.scrollLeft&&(r-=e.scrollLeft),e=e.offsetParent;return{top:n,left:r}}var dropdownContent={classes:{container:"dtcc-dropdown",liner:"dtcc-dropdown-liner"},defaults:{className:"dropdown",content:[],icon:"menu",text:"More..."},init:function(e){for(var n=this.dt(),r=createElement("div",dropdownContent.classes.container,"",[createElement("div",dropdownContent.classes.liner)]),t=(r._shown=!1,r._close=function(){r.remove(),r._shown=!1},r.childNodes[0]),o=new Button(n).text(n.i18n("columnControl.dropdown",e.text)).icon(e.icon).className(e.className).dropdownDisplay(t).handler(function(t){t._closed&&t._closed.includes(r)||attachDropdown(r,n,e._parents?e._parents[0]:o)}),i=0;i<e.content.length;i++){var a=this.resolve(e.content[i]),a=(a.config._parents||(a.config._parents=[]),a.config._parents.push(o),a.plugin.init.call(this,a.config));t.appendChild(a)}return e._parents&&e._parents.length&&o.extra("chevronRight"),n.on("columns-reordered",function(){positionDropdown(r,n,o.element())}),o.element()}},_namespace=0,Button=(()=>{function e(t){this._s={active:!1,activeList:[],buttonClick:null,dt:null,enabled:!0,label:"",namespace:"",value:null},this._s.dt=t,this._dom={button:createElement("button",e.classes.container),dropdownDisplay:null,extra:createElement("span","dtcc-button-extra"),icon:createElement("span","dtcc-button-icon"),state:createElement("span","dtcc-button-state"),text:createElement("span","dtcc-button-text")},this._dom.button.append(this._dom.icon),this._dom.button.append(this._dom.text),this._dom.button.append(this._dom.state),this._dom.button.append(this._dom.extra),this.enable(!0)}return e.prototype.active=function(t){return void 0===t?this._s.active:(this._s.active=t,this._checkActive(),this)},e.prototype.activeList=function(t,e){return this._s.activeList[t]=e,this._checkActive(),this},e.prototype.checkDisplay=function(){for(var t=0,e=this._dom.dropdownDisplay.childNodes,n=0;n<e.length;n++)"none"!==e[n].style.display&&t++;return 0===t&&(this._dom.button.style.display="none"),this},e.prototype.className=function(t){return this._dom.button.classList.add("dtcc-button_"+t),this},e.prototype.destroy=function(){this._s.buttonClick&&this._dom.button.removeEventListener("click",this._s.buttonClick),this._s.namespace&&this._s.dt.off("destroy."+this._s.namespace)},e.prototype.dropdownDisplay=function(t){return this._dom.dropdownDisplay=t,this},e.prototype.element=function(){return this._dom.button},e.prototype.enable=function(t){return this._dom.button.classList.toggle("dtcc-button_disabled",!t),this._s.enabled=t,this},e.prototype.extra=function(t){return this._dom.extra.innerHTML=t?icons[t]:"",this},e.prototype.handler=function(e){function t(t){close(t),t.stopPropagation(),t.preventDefault(),n._s.enabled&&e(t)}var n=this;return this._s.buttonClick=t,this._s.namespace="dtcc-"+_namespace++,this._dom.button.addEventListener("click",t),this._s.dt.on("destroy."+this._s.namespace,function(){n.destroy()}),this},e.prototype.icon=function(t){return this._dom.icon.innerHTML=t?icons[t]:"",this},e.prototype.text=function(t){return void 0===t?this._s.label:(this._dom.text.innerHTML=t,this._s.label=t,this)},e.prototype.value=function(t){return void 0===t?this._s.value:(this._s.value=t,this)},e.prototype._checkActive=function(){return!0===this._s.active||Object.values(this._s.activeList).includes(!0)?(this._dom.state.innerHTML=icons.tick,this._dom.button.classList.add("dtcc-button_active")):(this._dom.state.innerHTML="",this._dom.button.classList.remove("dtcc-button_active")),this},e.classes={container:"dtcc-button"},e})(),CheckList=(()=>{function s(t,e){function n(){i._s.search=a.search.value,i._redraw()}function r(t){i.selectAll(),i._s.handler(t,null,i._s.buttons),i._updateCount()}function o(t){i.selectNone(),i._s.handler(t,null,i._s.buttons),i._updateCount()}var i=this,a=(this._s={buttons:[],dt:null,handler:function(){},search:""},this._s.dt=t,this._dom={buttons:createElement("div","dtcc-list-buttons"),container:createElement("div",s.classes.container),controls:createElement("div","dtcc-list-controls"),title:createElement("div","dtcc-list-title"),selectAll:createElement("button","dtcc-list-selectAll",t.i18n("columnControl.list.all","Select all")),selectAllCount:createElement("span"),selectNone:createElement("button","dtcc-list-selectNone",t.i18n("columnControl.list.none","Deselect")),selectNoneCount:createElement("span"),search:createElement("input",s.classes.input)},this._dom);a.search.setAttribute("type","text"),a.container.append(a.title),a.container.append(a.controls),a.container.append(a.buttons),e.select&&(a.controls.append(a.selectAll),a.controls.append(a.selectNone),a.selectAll.append(a.selectAllCount),a.selectNone.append(a.selectNoneCount));e.search&&(a.controls.append(a.search),a.search.setAttribute("placeholder",t.i18n("columnControl.list.search","Search...")),a.search.addEventListener("input",n)),a.selectAll.addEventListener("click",r),a.selectNone.addEventListener("click",o),t.on("destroy",function(){a.selectAll.removeEventListener("click",r),a.selectNone.removeEventListener("click",o),a.search.removeEventListener("input",n)})}return s.prototype.add=function(n,t){for(var r=this,o=(Array.isArray(n)||(n=[n]),this),e=0;e<n.length;e++)(t=>{var t=n[t],e=new Button(o._s.dt).active(t.active||!1).handler(function(t){r._s.handler(t,e,r._s.buttons),r._updateCount()}).icon(t.icon||"").text(t.label).value(t.value);o._s.buttons.push(e)})(e);var i=this._s.buttons.length;return!0!==t&&void 0!==t||(this._dom.selectAllCount.innerHTML=i?"("+i+")":"",this._redraw()),this},s.prototype.button=function(t){for(var e=this._s.buttons,n=0;n<e.length;n++)if(e[n].value()===t)return e[n];return null},s.prototype.clear=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].destroy();return this._dom.buttons.replaceChildren(),this._s.buttons.length=0,this},s.prototype.element=function(){return this._dom.container},s.prototype.handler=function(t){return this._s.handler=t,this},s.prototype.searchListener=function(t,n){var r=this;return t.on("cc-search-clear",function(t,e){e===n.idx()&&(r.selectNone(),r._s.handler(t,null,r._s.buttons),r._s.search="",r._dom.search.value="",r._redraw(),r._updateCount())}),this},s.prototype.selectAll=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].active(!0);return this},s.prototype.selectNone=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].active(!1);return this},s.prototype.title=function(t){return this._dom.title.innerHTML=t,this},s.prototype.values=function(t){var e,n=[],r=this._s.buttons;if(void 0!==t){for(e=0;e<r.length;e++)t.includes(r[e].value())&&r[e].active(!0);return this._updateCount(),this}for(e=0;e<r.length;e++)r[e].active()&&n.push(r[e].value());return n},s.prototype._updateCount=function(){var t=this.values().length;this._dom.selectNoneCount.innerHTML=t?"("+t+")":""},s.prototype._redraw=function(){var t=this._s.buttons,e=this._dom.buttons,n=this._s.search.toLowerCase();e.replaceChildren();for(var r=0;r<t.length;r++){var o=t[r];n&&!o.text().toLowerCase().includes(n)||e.appendChild(o.element())}},s.classes={container:"dtcc-list",input:"dtcc-list-search"},s})(),colVis={defaults:{className:"colVis",columns:"",search:!1,select:!1,title:"Column visibility"},init:function(t){function n(){o.columns(t.columns).every(function(){i.add({active:this.visible(),label:this.title(),value:this.index()})})}var o=this.dt(),i=new CheckList(o,{search:t.search,select:t.select}).title(o.i18n("columnControl.colVis",t.title)).handler(function(t,e,n){e&&e.active(!e.active()),r(n)}),r=function(t){for(var e=0;e<t.length;e++){var n=t[e],r=n.value(),r=o.column(r);n.active()&&!r.visible()?r.visible(!0):!n.active()&&r.visible()&&r.visible(!1)}};return n(),o.on("column-visibility",function(t,e,n,r){n=i.button(n);n&&n.active(r)}),o.on("columns-reordered",function(t,e){i.clear(),n()}),i.element()}},colVisDropdown={defaults:{className:"colVis",columns:"",search:!1,select:!1,text:"Column visibility",title:"Column visibility"},extend:function(t){return{extend:"dropdown",icon:"columns",text:this.dt().i18n("columnControl.colVisDropdown",t.text),content:[Object.assign(t,{extend:"colVis"})]}}},reorder={defaults:{className:"reorder",icon:"move",text:"Reorder columns"},init:function(t){var n=this,e=this.dt(),r=new Button(e).text(e.i18n("columnControl.reorder",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();0<t&&e.colReorder.move(t,t-1)});return 0===this.idx()&&r.enable(!1),e.on("columns-reordered",function(t,e){r.enable(0<n.idx())}),e.init().colReorder||new DataTable.ColReorder(e,{}),r.element()}},reorderLeft={defaults:{className:"reorderLeft",icon:"moveLeft",text:"Move column left"},init:function(t){var n=this,e=this.dt(),r=new Button(e).text(e.i18n("columnControl.reorderLeft",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();0<t&&e.colReorder.move(t,t-1)});return 0===this.idx()&&r.enable(!1),e.on("columns-reordered",function(t,e){r.enable(0<n.idx())}),r.element()}},reorderRight={defaults:{className:"reorderRight",icon:"moveRight",text:"Move column right"},init:function(t){var n=this,r=this.dt(),o=new Button(r).text(r.i18n("columnControl.reorderRight",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();t<r.columns().count()-1&&r.colReorder.move(t,t+1)});return this.idx()===r.columns().count()-1&&o.enable(!1),r.on("columns-reordered",function(t,e){o.enable(n.idx()<r.columns().count()-1)}),o.element()}},order={defaults:{className:"order",iconAsc:"orderAsc",iconDesc:"orderDesc",iconNone:"orderNone",statusOnly:!1,text:"Toggle ordering"},init:function(r){var o=this,t=this.dt(),i=new Button(t).text(t.i18n("columnControl.order",r.text)).icon("orderAsc").className(r.className);return r.statusOnly||t.order.listener(i.element(),this.idx(),function(){}),t.on("order",function(t,e,n){n=n.find(function(t){return t.col===o.idx()});n?"asc"===n.dir?i.active(!0).icon(r.iconAsc):"desc"===n.dir&&i.active(!0).icon(r.iconDesc):i.active(!1).icon(r.iconNone)}),i.element()}},orderAddAsc={defaults:{className:"orderAddAsc",icon:"orderAddAsc",text:"Add Sort Ascending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAddAsc",t.text)).icon(t.icon).className(t.className).handler(function(){e.order().push([r.idx(),"asc"]),e.draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(!n)}),o.element()}},orderAddDesc={defaults:{className:"orderAddDesc",icon:"orderAddDesc",text:"Add Sort Descending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAddDesc",t.text)).icon(t.icon).className(t.className).handler(function(){e.order().push([r.idx(),"desc"]),e.draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(!n)}),o.element()}},orderAsc={defaults:{className:"orderAsc",icon:"orderAsc",text:"Sort Ascending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAsc",t.text)).icon(t.icon).className(t.className).handler(function(){r.dt().order([{idx:r.idx(),dir:"asc"}]).draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()&&"asc"===t.dir});o.active(n)}),o.element()}},orderClear={defaults:{className:"orderClear",icon:"orderClear",text:"Clear sort"},init:function(t){var e=this.dt(),r=new Button(e).text(e.i18n("columnControl.orderClear",t.text)).icon(t.icon).className(t.className).handler(function(){e.order([]).draw()});return e.on("order",function(t,e,n){r.enable(0<n.length)}),0===e.order().length&&r.enable(!1),r.element()}},orderDesc={defaults:{className:"orderDesc",icon:"orderDesc",text:"Sort Descending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderDesc",t.text)).icon(t.icon).className(t.className).handler(function(){r.dt().order([{idx:r.idx(),dir:"desc"}]).draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()&&"desc"===t.dir});o.active(n)}),o.element()}},orderRemove={defaults:{className:"orderRemove",icon:"orderRemove",text:"Remove from sort"},init:function(t){var r=this,n=this.dt(),o=new Button(n).text(n.i18n("columnControl.orderRemove",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.order(),e=t.findIndex(function(t){return t[0]===r.idx()});t.splice(e,1),n.order(t).draw()});return n.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(n)}),o.enable(!1),o.element()}},orderStatus={defaults:{className:"order",iconAsc:"orderAsc",iconDesc:"orderDesc",iconNone:"orderNone",statusOnly:!0,text:"Sort status"},extend:function(t){return Object.assign(t,{extend:"order"})}},SearchInput=(()=>{function c(n,r){function t(){i.runSearch()}function e(){a.typeIcon.innerHTML=icons[a.select.value],i.runSearch()}function o(){i.clear()}var i=this,a=(this._type="text",this._dt=n,this._idx=r,this._dom={clear:createElement("span","dtcc-search-clear",icons.x),container:createElement("div",c.classes.container),typeIcon:createElement("div","dtcc-search-type-icon"),searchIcon:createElement("div","dtcc-search-icon",icons.search),input:createElement("input",c.classes.input),inputs:createElement("div"),select:createElement("select",c.classes.select),title:createElement("div","dtcc-search-title")},this._dom),s=r;a.input.setAttribute("type","text"),a.container.append(a.title,a.inputs),a.inputs.append(a.typeIcon,a.select,a.searchIcon,a.clear,a.input);a.input.addEventListener("input",t),a.select.addEventListener("input",e),a.clear.addEventListener("click",o),n.on("destroy",function(){a.input.removeEventListener("input",t),a.select.removeEventListener("input",e),a.clear.removeEventListener("click",o)}),n.on("stateSaveParams",function(t,e,n){n.columnControl||(n.columnControl={}),n.columnControl[r]||(n.columnControl[r]={}),n.columnControl[r].searchInput={logic:a.select.value,type:i._type,value:a.input.value}}),n.on("stateLoaded",function(t,e,n){i._stateLoad(n)}),n.on("columns-reordered",function(t,e){i._idx=n.colReorder.transpose(s,"fromOriginal")}),n.on("cc-search-clear",function(t,e){e===i._idx&&i.clear()})}return c.prototype.addClass=function(t){return this._dom.container.classList.add(t),this},c.prototype.clear=function(){return this.set(this._dom.select.children[0].getAttribute("value"),""),this},c.prototype.clearable=function(t){return t||this._dom.clear.remove(),this},c.prototype.element=function(){return this._dom.container},c.prototype.input=function(){return this._dom.input},c.prototype.options=function(t){for(var e=this._dom.select,n=0;n<t.length;n++)e.add(new Option(t[n].label,t[n].value));return this._dom.typeIcon.innerHTML=icons[t[0].value],this},c.prototype.placeholder=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.input.placeholder=t.replace("[title]",e)),this},c.prototype.runSearch=function(){var t=this._dom,e="empty"===t.select.value||"notEmpty"===t.select.value||""!==t.input.value;t.container.classList.toggle("dtcc-search_active",e),!this._search||this._lastValue===t.input.value&&this._lastType===t.select.value||(this._search(t.select.value,t.input.value,this._loadingState),this._lastValue=t.input.value,this._lastType=t.select.value)},c.prototype.search=function(t){return this._search=t,this._stateLoad(this._dt.state.loaded()),this},c.prototype.set=function(t,e){var n=this._dom;return n.input.value=e,n.select.value=t,n.typeIcon.innerHTML=icons[n.select.value],this.runSearch(),this},c.prototype.title=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.title.innerHTML=t.replace("[title]",e)),this},c.prototype.titleAttr=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.input.title=t.replace("[title]",e)),this},c.prototype.type=function(t){return this._type=t,this},c.prototype._stateLoad=function(t){var e=this._dom,n=this._idx,n=null==(t=null==(t=null==t?void 0:t.columnControl)?void 0:t[n])?void 0:t.searchInput;n&&(this._loadingState=!0,e.select.value=n.logic,e.input.value=n.value,e.select.dispatchEvent(new Event("input")),this._loadingState=!1)},c.classes={container:["dtcc-content","dtcc-search"],input:"",select:""},c})(),searchDateTime={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(i){var a,s=this,c=!1,l=DataTable.use("moment"),d=DataTable.use("luxon"),u=this.dt(),h="",e=new SearchInput(u,this.idx()).type("date").addClass("dtcc-searchDateTime").clearable(i.clear).placeholder(i.placeholder).title(i.title).titleAttr(i.titleAttr).options([{label:"Equals",value:"equal"},{label:"Does not equal",value:"notEqual"},{label:"After",value:"greater"},{label:"Before",value:"less"},{label:"Empty",value:"empty"},{label:"Not empty",value:"notEmpty"}]).search(function(t,e,n){var r=u.column(s.idx()),o=""===e?"":dateToNum(a&&c?a.val():e.trim(),h,l,d);if("empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===o)return;o?"equal"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)==o}):"notEqual"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)!=o}):"greater"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)>o}):"less"===t&&r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)<o}):r.search.fixed("dtcc","")}i._parents&&i._parents.forEach(function(t){return t.activeList(s.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()});return u.ready(function(){var t=DataTable.use("datetime");h=getFormat(u,s.idx()),t&&(a=new t(e.input(),{format:h,onChange:function(){c=!0,e.runSearch(),c=!1}}))}),e.element()}};function getFormat(t,e){t=t.column(e).type();if(t)if("datetime"===t){var e=DataTable.use("moment"),n=DataTable.use("luxon");if(e)return e().creationData().locale._longDateFormat.L;if(n)return n.DateTime.fromISO("1999-08-07").toLocaleString().replace("07","dd").replace("7","d").replace("08","MM").replace("8","M").replace("1999","yyyy").replace("99","yy")}else{if(t.includes("datetime-"))return t.replace(/datetime-/g,"");if(t.includes("moment"))return t.replace(/moment-/g,"");if(t.includes("luxon"))return t.replace(/luxon-/g,"")}return"YYYY-MM-DD"}function dateToNum(t,e,n,r){return""===t?"":t instanceof Date?t.getTime():"YYYY-MM-DD"!==e&&(n||r)?n?1e3*n(t,e).unix():r.DateTime.fromFormat(t,e).toMillis():new Date(t).getTime()}function setOptions(t,e){var n=t.values();t.clear();for(var r=0;r<e.length;r++)"object"==typeof e[r]?t.add({active:!1,label:e[r].label,value:e[r].value},r===e.length-1):t.add({active:!1,label:e[r],value:e[r]},r===e.length-1);n.length&&t.values(n)}function getState(t,e){t=null==(e=null==(e=null==e?void 0:e.columnControl)?void 0:e[t])?void 0:e.searchList;if(t)return t}function getJsonOptions(t,e){var n=null==(n=t.ajax.json())?void 0:n.columnControl,t=t.column(e),r=t.name(),t=t.dataSrc();return n&&n[r]?n[r]:n&&"string"==typeof t&&n[t]?n[t]:n&&n[e]?n[e]:null}function reloadOptions(t,e,n,r,o){var i=null==(i=t.ajax.json())?void 0:i.columnControl,a=[],s=getJsonOptions(t,n);if(s)a=s;else{if(i&&e.ajaxOnly)return r.element().style.display="none",void(e._parents&&e._parents.forEach(function(t){return t.checkDisplay()}));for(var c={},l=t.rows({order:n}).indexes().toArray(),d=t.settings()[0],u=0;u<l.length;u++){var h=d.fastData(l[u],n,"filter");c[h]||(c[h]=!0,a.push({label:d.fastData(l[u],n,"display"),value:h}))}}setOptions(r,a),o&&r.values(o)}var searchList={defaults:{ajaxOnly:!0,className:"searchList",options:null,search:!0,select:!0,title:""},init:function(r){function n(e){var t=a.column(o.idx());e&&(0===e.length?t.search.fixed("dtcc-list",""):t.search.fixed("dtcc-list",function(t){return e.includes(t)}),r._parents)&&r._parents.forEach(function(t){return t.activeList(o.unique(),!!e.length)})}var o=this,i=null,a=this.dt(),s=new CheckList(a,{search:r.search,select:r.select}).searchListener(a,this).title(a.i18n("columnControl.searchList",r.title).replace("[title]",a.column(this.idx()).title())).handler(function(t,e){e&&e.active(!e.active()),n(s.values()),a.draw()});return r.options?setOptions(s,r.options):a.ready(function(){reloadOptions(a,r,o.idx(),s,i)}),a.on("xhr",function(t,e,n){reloadOptions(a,r,o.idx(),s,i)}),a.on("stateLoaded",function(t,e,n){n=getState(o.idx(),n);n&&s.values(n)}),a.on("stateSaveParams",function(t,e,n){var r=o.idx();n.columnControl||(n.columnControl={}),n.columnControl[r]||(n.columnControl[r]={}),n.columnControl[r].searchList=a.ready()?s.values():i}),i=getState(this.idx(),a.state.loaded()),n(i),s.element()}},searchNumber={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(o){var i=this,a=this.dt(),t=new SearchInput(a,this.idx()).type("num").addClass("dtcc-searchNumber").clearable(o.clear).placeholder(o.placeholder).title(o.title).titleAttr(o.titleAttr).options([{label:"Equals",value:"equal"},{label:"Does not equal",value:"notEqual"},{label:"Greater than",value:"greater"},{label:"Greater or equal",value:"greaterOrEqual"},{label:"Less than",value:"less"},{label:"Less or equal",value:"lessOrEqual"},{label:"Empty",value:"empty"},{label:"Not empty",value:"notEmpty"}]).search(function(t,e,n){var r=a.column(i.idx());if("empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===e)return;""===e?r.search.fixed("dtcc",""):"equal"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)==e}):"notEqual"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)!=e}):"greater"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)>e}):"greaterOrEqual"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)>=e}):"less"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)<e}):"lessOrEqual"===t&&r.search.fixed("dtcc",function(t){return stringToNum(t)<=e})}o._parents&&o._parents.forEach(function(t){return t.activeList(i.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()});return t.input().setAttribute("inputmode","numeric"),t.input().setAttribute("pattern","[0-9]*"),t.element()}},_re_html=/<([^>]*>)/g,_re_formatted_numeric=/['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;function stringToNum(t){var e;return 0===t||t&&"-"!==t?"number"==(e=typeof t)||"bigint"==e?t:+(t=t.replace?t.replace(_re_html,"").replace(_re_formatted_numeric,""):t):-1/0}var searchText={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(o){var i=this,a=this.dt();return new SearchInput(a,this.idx()).addClass("dtcc-searchText").clearable(o.clear).placeholder(o.placeholder).title(o.title).titleAttr(o.titleAttr).options([{label:"Contains",value:"contains"},{label:"Does not contain",value:"notContains"},{label:"Equals",value:"equal"},{label:"Does not equal",value:"notEqual"},{label:"Starts",value:"starts"},{label:"Ends",value:"ends"},{label:"Empty",value:"empty"},{label:"Not empty",value:"notEmpty"}]).search(function(t,e,n){var r=a.column(i.idx());if(e=e.toLowerCase(),"empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===e)return;""===e?r.search.fixed("dtcc",""):"equal"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase()==e}):"notEqual"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase()!=e}):"contains"===t?r.search.fixed("dtcc",e):"notContains"===t?r.search.fixed("dtcc",function(t){return!t.toLowerCase().includes(e)}):"starts"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase().startsWith(e)}):"ends"===t&&r.search.fixed("dtcc",function(t){return t.toLowerCase().endsWith(e)})}o._parents&&o._parents.forEach(function(t){return t.activeList(i.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()}).element()}},search={defaults:{allowSearchList:!1},init:function(n){function e(t){var e=getJsonOptions(i,a);return n.allowSearchList&&e?searchList.init.call(o,Object.assign({},searchList.defaults,n)):"date"===t||t.startsWith("datetime")?searchDateTime.init.call(o,Object.assign({},searchDateTime.defaults,n)):t.includes("num")?searchNumber.init.call(o,Object.assign({},searchNumber.defaults,n)):searchText.init.call(o,Object.assign({},searchText.defaults,n))}var r,o=this,i=this.dt(),a=this.idx(),t=null==(t=null==(t=null==(t=i.state.loaded())?void 0:t.columnControl)?void 0:t[a])?void 0:t.searchInput;return t?r=e(t.type):(r=document.createElement("div"),i.ready(function(){var t=i.column(a),t=e(t.type());r.replaceWith(t)})),r}},searchClear={defaults:{className:"searchClear",icon:"searchClear",text:"Clear Search"},init:function(t){var n=this,r=this.dt(),o=new Button(r).text(r.i18n("columnControl.searchClear",t.text)).icon(t.icon).className(t.className).handler(function(){r.column(n.idx()).ccSearchClear()}).enable(!1);return r.on("draw",function(){var t=r.column(n.idx()).search.fixed("dtcc"),e=r.column(n.idx()).search.fixed("dtcc-list");o.enable(!(!t&&!e))}),o.element()}},searchDropdown={defaults:{ajaxOnly:!0,allowSearchList:!0,className:"searchDropdown",clear:!0,columns:"",options:null,placeholder:"",search:!0,select:!0,text:"Search",title:"",titleAttr:""},extend:function(t){return{extend:"dropdown",icon:"search",text:this.dt().i18n("columnControl.searchDropdown",t.text),content:[Object.assign(t,{extend:"search"})]}}},spacer={defaults:{className:"dtcc-spacer",text:""},init:function(t){var e=this.dt();return createElement("div",t.className,e.i18n("columnControl.spacer",t.text))}},title={defaults:{className:"dtcc-title",text:null},init:function(t){var e=this.dt().column(this.idx()).title(),n=null===t.text?"[title]":t.text;return createElement("div",t.className,n.replace("[title]",e))}},contentTypes={colVis:colVis,colVisDropdown:colVisDropdown,dropdown:dropdownContent,reorder:reorder,reorderLeft:reorderLeft,reorderRight:reorderRight,order:order,orderAddAsc:orderAddAsc,orderAddDesc:orderAddDesc,orderAsc:orderAsc,orderClear:orderClear,orderDesc:orderDesc,orderRemove:orderRemove,orderStatus:orderStatus,search:search,searchClear:searchClear,searchDropdown:searchDropdown,searchDateTime:searchDateTime,searchList:searchList,searchNumber:searchNumber,searchText:searchText,spacer:spacer,title:title},ColumnControl=(()=>{function i(n,t,e){var r=this,o=(this._dom={target:null,wrapper:null},this._c={},this._s={columnIdx:null,unique:null},this._dt=n,this._s.columnIdx=t,this._s.unique=Math.random(),t);Object.assign(this._c,i.defaults,e),this._dom.target=this._target(),e.className&&addClass(this._dom.target.closest("tr"),e.className),this._c.content&&(n.on("columns-reordered",function(t,e){r._s.columnIdx=n.colReorder.transpose(o,"fromOriginal")}),this._dom.wrapper=document.createElement("span"),this._dom.wrapper.classList.add("dtcc"),this._dom.target.appendChild(this._dom.wrapper),this._c.content.forEach(function(t){t=r.resolve(t),t=t.plugin.init.call(r,t.config);r._dom.wrapper.appendChild(t)}),n.on("destroy",function(){r._dom.wrapper.remove()}))}return i.prototype.dt=function(){return this._dt},i.prototype.idx=function(){return this._s.columnIdx},i.prototype.resolve=function(t){var e=null,n=null,r=null;if("string"==typeof t?(e=i.content[r=t],n=Object.assign({},null==e?void 0:e.defaults)):Array.isArray(t)?(e=i.content[r="dropdown"],n=Object.assign({},null==e?void 0:e.defaults,{content:t})):t.extend&&(r=t.extend,e=i.content[r],n=Object.assign({},null==e?void 0:e.defaults,t)),e)return e.extend?(t=e.extend.call(this,n),this.resolve(t)):{config:n,type:r,plugin:e};throw new Error("Unknown ColumnControl content type: "+r)},i.prototype.unique=function(){return this._s.unique},i.prototype._target=function(){var t,e,n=this._c.target,r=this._dt.column(this._s.columnIdx),o="header";return"number"==typeof n?t=r.header(n):(e="tfoot"!==(n=n.split(":"))[0],n=n[1]?parseInt(n[1]):0,e?t=r.header(n):(t=r.footer(n),o="footer")),t.querySelector("div.dt-column-"+o)},i.Button=Button,i.CheckList=CheckList,i.SearchInput=SearchInput,i.content=contentTypes,i.defaults={className:"",content:null,target:0},i.icons=icons,i.version="1.0.3",i})();function assetTarget(t,e,n){if(!t[e]){var r=!0,o=0,i=("number"==typeof e?o=e:("tfoot"===(i=e.split(":"))[0]&&(r=!1),i[1]&&(o=parseInt(i[1]))),r?n.table().header():n.table().footer());if(!i.querySelectorAll("tr")[o]){var a=n.columns().count(),s=createElement("tr");s.setAttribute("data-dt-order","disable");for(var c=0;c<a;c++)s.appendChild(createElement("td"));i.appendChild(s)}t[e]=!0}}function getOptionsForTarget(t,e){var n=ColumnControl.defaults.target;if(isIContentArray(e)){if(n===t)return{target:n,content:e}}else if(Array.isArray(e))for(var r=0;r<e.length;r++){var o=e[r];if(isIContentArray(o)){if(n===t)return{target:n,content:o}}else if(isIConfig(o)){if(t===(void 0!==o.target?o.target:n))return o}else if(t===n)return{target:n,content:e}}else if("object"==typeof e)if(isIConfig(e)){if(t===(void 0!==e.target?e.target:n))return e}else if(t===n)return{target:n,content:e}}function identifyTargets(e,t){function n(t){e.includes(t)||e.push(t)}return Array.isArray(t)?t.forEach(function(t){n(("object"==typeof t&&void 0!==t.target?t:ColumnControl.defaults).target)}):"object"==typeof t&&n((void 0!==t.target?t:ColumnControl.defaults).target),e}function isIConfig(t){return"object"==typeof t&&void 0!==t.target}function isIContentArray(t){var e=!1;if(!Array.isArray(t))return!1;for(var n=0;n<t.length;n++)if(isIConfig(t[n])){e=!0;break}return!e}DataTable.ColumnControl=ColumnControl,$(document).on("i18n.dt",function(t,e){if("dt"===t.namespace){var n=new DataTable.Api(e),t=n.table().header(),r=e.oInit.columnControl,o=ColumnControl.defaults,i=[],a={};t.querySelectorAll("tr").length<=1&&null===e.titleRow&&(e.titleRow=0),identifyTargets(i,r),identifyTargets(i,o),n.columns().every(function(t){var e=this.init().columnControl;identifyTargets(i,e)});for(var s=0;s<i.length;s++)assetTarget(a,i[s],n)}}),$(document).on("preInit.dt",function(t,e){var s,c,l,d;"dt"===t.namespace&&(s=new DataTable.Api(e),c=e.oInit.columnControl,l=ColumnControl.defaults,identifyTargets(d=[],c),identifyTargets(d,l),s.columns().every(function(t){for(var e=this.init().columnControl,n=identifyTargets(d.slice(),e),r=0;r<n.length;r++){var o=getOptionsForTarget(n[r],e),i=getOptionsForTarget(n[r],c),a=getOptionsForTarget(n[r],l);(a||i||o)&&new ColumnControl(s,this.index(),Object.assign({},a||{},i||{},o||{}))}}))}),DataTable.Api.registerPlural("columns().ccSearchClear()","column().ccSearchClear()",function(){var n=this;return this.iterator("column",function(t,e){n.trigger("cc-search-clear",[e])})}),DataTable.ext.buttons.ccSearchClear={text:"Clear search",init:function(n,t,e){var r=this;n.on("draw",function(){var t=!1,e=!!n.search();e||n.columns().every(function(){(this.search.fixed("dtcc")||this.search.fixed("dtcc-list"))&&(t=!0)}),r.enable(e||t)}),this.enable(!1)},action:function(t,e,n,r){e.search(""),e.columns().ccSearchClear()}};export default DataTable;
|
|
8
|
+
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function createElement(t,e,n,r){void 0===e&&(e=[]),void 0===n&&(n=null),void 0===r&&(r=[]);var o=document.createElement(t);return addClass(o,e),n&&(o.innerHTML=n),r.forEach(function(t){o.appendChild(t)}),o}function addClass(e,t){t&&(t=Array.isArray(t)?t:[t]).forEach(function(t){e&&t&&e.classList.add(t)})}function wrap(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">'+t+"</svg>"}var icons={chevronRight:wrap('<path d="m9 18 6-6-6-6"/>'),columns:wrap('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/><path d="M15 3v18"/>'),contains:wrap('<path d="M10 3h4v18h-4z"/><path d="M18 8h3v9h-3"/><path d="M6 17H3V8h3"/>'),empty:wrap('<circle cx="12" cy="12" r="10"/>'),ends:wrap('<path d="M21 3h-4v18h4z"/><path d="M13 8H3v9h10"/>'),equal:wrap('<line x1="5" x2="19" y1="9" y2="9"/><line x1="5" x2="19" y1="15" y2="15"/>'),greater:wrap('<path d="m9 18 6-6-6-6"/>'),greaterOrEqual:wrap('<path d="m9 16 6-6-6-6"/><path d="m9 21 6-6"/>'),less:wrap('<path d="m15 18-6-6 6-6"/>'),lessOrEqual:wrap('<path d="m15 16-6-6 6-6"/><path d="m15 21-6-6"/>'),menu:wrap('<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>'),move:wrap('<line x1="12" x2="12" y1="3" y2="21"/><polyline points="8 8 4 12 8 16"/><polyline points="16 16 20 12 16 8"/>'),moveLeft:wrap('<path d="m9 6-6 6 6 6"/><path d="M3 12h14"/><path d="M21 19V5"/>'),moveRight:wrap('<path d="M3 5v14"/><path d="M21 12H7"/><path d="m15 18 6-6-6-6"/>'),notContains:wrap('<path d="M15 4 9 20"/><path d="M3 8h18v9H3z"/>'),notEmpty:wrap('<circle cx="12" cy="12" r="10"/><line x1="9" x2="15" y1="15" y2="9"/>'),notEqual:wrap('<path d="M5 9h14"/><path d="M5 15h14"/><path d="M15 5 9 19"/>'),orderAddAsc:wrap('<path d="M17 21v-8"/><path d="M3 4h6"/><path d="M3 8h9"/><path d="M3 12h10"/><path d="M13 17h8"/>'),orderAddDesc:wrap('<path d="M17 21v-8"/><path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="M13 17h8"/>'),orderAsc:wrap('<path d="m3 8 4-4 4 4"/><path d="M7 4v16"/><path d="M11 12h4"/><path d="M11 16h7"/><path d="M11 20h10"/>'),orderClear:wrap('<path d="m21 21-8-8"/><path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="m13 21 8-8"/>'),orderDesc:wrap('<path d="m3 16 4 4 4-4"/><path d="M7 20V4"/><path d="M11 4h10"/><path d="M11 8h7"/><path d="M11 12h4"/>'),orderRemove:wrap('<path d="M3 4h12"/><path d="M3 8h9"/><path d="M3 12h6"/><path d="M13 17h8"/>'),orderNone:wrap('<path d="m3 8 4-4 4 4"/><path d="m11 16-4 4-4-4"/><path d="M7 4v16"/><path d="M15 8h6"/><path d="M15 16h6"/><path d="M13 12h8"/>'),search:wrap('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),searchClear:wrap('<path d="m13.5 8.5-5 5"/><path d="m8.5 8.5 5 5"/><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),starts:wrap('<path d="M3 3h4v18H3z"/><path d="M11 8h10v9H11"/>'),tick:wrap('<path d="M20 6 9 17l-5-5"/>'),x:wrap('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>')};function close(e){void 0===e&&(e=null),document.querySelectorAll("div.dtcc-dropdown").forEach(function(t){null!==e&&t.contains(e.target)||(t._close(),e._closed||(e._closed=[]),e._closed.push(t))})}function getContainer(t,e){return e.closest("div.dtfh-floatingparent")||t.table().container()}function positionDropdown(t,e,n){var r=n.closest("div.dt-column-header"),e=getContainer(e,n),r=getComputedStyle(r),o=t.offsetWidth,i=relativePosition(e,n),a=i.top+n.offsetHeight,r="row-reverse"===r.flexDirection?i.left:i.left-o+n.offsetWidth,i=e.offsetWidth;i<r+o&&(r-=r+o-i),r<0&&(r=0),t.style.top=a+"px",t.style.left=r+"px"}function attachDropdown(e,t,n){function r(t){e._shown?t.target===e||e.contains(t.target)||(e._close(),document.body.removeEventListener("click",r)):document.body.removeEventListener("click",r)}var o=getContainer(t,n.element());e._shown=!0,o.append(e),positionDropdown(e,t,n.element());return document.body.addEventListener("click",r),r}function relativePosition(t,e){for(var n=0,r=0;e&&e!==t&&e!==document.body;)n+=e.offsetTop,r+=e.offsetLeft,e.scrollTop&&(r-=e.scrollTop),e.scrollLeft&&(r-=e.scrollLeft),e=e.offsetParent;return{top:n,left:r}}function focusCapture(r,o){return function(t){var e,n;r._shown&&(e=Array.from(r.querySelectorAll("a, button, input, select")),n=document.activeElement,"Escape"===t.key?(r._close(),o.focus()):"Tab"===t.key&&0!==e.length&&(e.includes(n)?t.shiftKey?n===e[0]&&(e[e.length-1].focus(),t.preventDefault()):n===e[e.length-1]&&(e[0].focus(),t.preventDefault()):(e[0].focus(),t.preventDefault())))}}var dropdownContent={classes:{container:"dtcc-dropdown",liner:"dtcc-dropdown-liner"},defaults:{className:"dropdown",content:[],icon:"menu",text:"More..."},init:function(n){var r=this.dt(),o=createElement("div",dropdownContent.classes.container,"",[createElement("div",dropdownContent.classes.liner)]),t=(o._shown=!1,o._close=function(){o.remove(),o._shown=!1},o.setAttribute("role","dialog"),o.setAttribute("aria-label",r.i18n("columnControl.dropdown",n.text)),r.on("fixedheader-mode",function(){o._shown&&attachDropdown(o,r,n._parents?n._parents[0]:i)}),o.childNodes[0]),i=new Button(r).text(r.i18n("columnControl.dropdown",n.text)).icon(n.icon).className(n.className).dropdownDisplay(t).handler(function(t){var e;t._closed&&t._closed.includes(o)||(attachDropdown(o,r,n._parents?n._parents[0]:i),e=o.querySelector("input, a, button"),console.log(t.type,t),e&&"keypress"===t.type&&e.focus())});i.element().setAttribute("aria-haspopup","dialog");for(var e=0;e<n.content.length;e++){var a=this.resolve(n.content[e]),a=(a.config._parents||(a.config._parents=[]),a.config._parents.push(i),a.plugin.init.call(this,a.config));t.appendChild(a)}n._parents&&n._parents.length&&i.extra("chevronRight"),r.on("columns-reordered",function(){positionDropdown(o,r,i.element())});var s=focusCapture(o,i.element());return document.body.addEventListener("keydown",s),r.on("destroy",function(){document.body.removeEventListener("keydown",s)}),i.element()}},_namespace=0,Button=(()=>{function e(t){this._s={active:!1,activeList:[],buttonClick:null,dt:null,enabled:!0,label:"",namespace:"",value:null},this._s.dt=t,this._dom={button:createElement("button",e.classes.container),dropdownDisplay:null,extra:createElement("span","dtcc-button-extra"),icon:createElement("span","dtcc-button-icon"),state:createElement("span","dtcc-button-state"),text:createElement("span","dtcc-button-text")},this._dom.button.append(this._dom.icon),this._dom.button.append(this._dom.text),this._dom.button.append(this._dom.state),this._dom.button.append(this._dom.extra),this.enable(!0)}return e.prototype.active=function(t){return void 0===t?this._s.active:(this._s.active=t,this._checkActive(),this)},e.prototype.activeList=function(t,e){return this._s.activeList[t]=e,this._checkActive(),this},e.prototype.checkDisplay=function(){for(var t=0,e=this._dom.dropdownDisplay.childNodes,n=0;n<e.length;n++)"none"!==e[n].style.display&&t++;return 0===t&&(this._dom.button.style.display="none"),this},e.prototype.className=function(t){return this._dom.button.classList.add("dtcc-button_"+t),this},e.prototype.destroy=function(){this._s.buttonClick&&(this._dom.button.removeEventListener("click",this._s.buttonClick),this._dom.button.removeEventListener("keypress",this._s.buttonClick)),this._s.namespace&&this._s.dt.off("destroy."+this._s.namespace)},e.prototype.dropdownDisplay=function(t){return this._dom.dropdownDisplay=t,this},e.prototype.element=function(){return this._dom.button},e.prototype.enable=function(t){return this._dom.button.classList.toggle("dtcc-button_disabled",!t),this._s.enabled=t,this},e.prototype.extra=function(t){return this._dom.extra.innerHTML=t?icons[t]:"",this},e.prototype.handler=function(e){function t(t){close(t),t.stopPropagation(),t.preventDefault(),n._s.enabled&&e(t)}var n=this;return this._s.buttonClick=t,this._s.namespace="dtcc-"+_namespace++,this._dom.button.addEventListener("click",t),this._dom.button.addEventListener("keypress",t),this._s.dt.on("destroy."+this._s.namespace,function(){n.destroy()}),this},e.prototype.icon=function(t){return this._dom.icon.innerHTML=t?icons[t]:"",this},e.prototype.text=function(t){return void 0===t?this._s.label:(this._dom.text.innerHTML=t,this._s.label=t,this._dom.button.setAttribute("aria-label",t),this)},e.prototype.value=function(t){return void 0===t?this._s.value:(this._s.value=t,this)},e.prototype._checkActive=function(){return!0===this._s.active||Object.values(this._s.activeList).includes(!0)?(this._dom.state.innerHTML=icons.tick,this._dom.button.classList.add("dtcc-button_active")):(this._dom.state.innerHTML="",this._dom.button.classList.remove("dtcc-button_active")),this},e.classes={container:"dtcc-button"},e})(),CheckList=(()=>{function s(t,e){function n(){i._s.search=a.search.value,i._redraw()}function r(t){i.selectAll(),i._s.handler(t,null,i._s.buttons,!0),i._updateCount()}function o(t){i.selectNone(),i._s.handler(t,null,i._s.buttons,!0),i._updateCount()}var i=this,a=(this._s={buttons:[],dt:null,handler:function(){},search:""},this._s.dt=t,this._dom={buttons:createElement("div","dtcc-list-buttons"),container:createElement("div",s.classes.container),controls:createElement("div","dtcc-list-controls"),title:createElement("div","dtcc-list-title"),selectAll:createElement("button","dtcc-list-selectAll",t.i18n("columnControl.list.all","Select all")),selectAllCount:createElement("span"),selectNone:createElement("button","dtcc-list-selectNone",t.i18n("columnControl.list.none","Deselect")),selectNoneCount:createElement("span"),search:createElement("input",s.classes.input)},this._dom);a.search.setAttribute("type","text"),a.container.append(a.title),a.container.append(a.controls),a.container.append(a.buttons),e.select&&(a.controls.append(a.selectAll),a.controls.append(a.selectNone),a.selectAll.append(a.selectAllCount),a.selectNone.append(a.selectNoneCount));e.search&&(a.controls.append(a.search),a.search.setAttribute("placeholder",t.i18n("columnControl.list.search","Search...")),a.search.addEventListener("input",n)),a.selectAll.addEventListener("click",r),a.selectNone.addEventListener("click",o),t.on("destroy",function(){a.selectAll.removeEventListener("click",r),a.selectNone.removeEventListener("click",o),a.search.removeEventListener("input",n)})}return s.prototype.add=function(n,t){for(var r=this,o=(Array.isArray(n)||(n=[n]),this),e=0;e<n.length;e++)(t=>{var t=n[t],e=new Button(o._s.dt).active(t.active||!1).handler(function(t){r._s.handler(t,e,r._s.buttons,!0),r._updateCount()}).icon(t.icon||"").text(""!==t.label?t.label:o._s.dt.i18n("columnControl.list.emptyOption","Empty")).value(t.value);""===t.label&&e.className("empty"),o._s.buttons.push(e)})(e);var i=this._s.buttons.length;return!0!==t&&void 0!==t||(this._dom.selectAllCount.innerHTML=i?"("+i+")":"",this._redraw()),this},s.prototype.button=function(t){for(var e=this._s.buttons,n=0;n<e.length;n++)if(e[n].value()===t)return e[n];return null},s.prototype.clear=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].destroy();return this._dom.buttons.replaceChildren(),this._s.buttons.length=0,this},s.prototype.element=function(){return this._dom.container},s.prototype.handler=function(t){return this._s.handler=t,this},s.prototype.searchListener=function(t,n){var r=this;return t.on("cc-search-clear",function(t,e){e===n.idx()&&(r.selectNone(),r._s.handler(t,null,r._s.buttons,!1),r._s.search="",r._dom.search.value="",r._redraw(),r._updateCount())}),this},s.prototype.selectAll=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].active(!0);return this},s.prototype.selectNone=function(){for(var t=0;t<this._s.buttons.length;t++)this._s.buttons[t].active(!1);return this},s.prototype.title=function(t){return this._dom.title.innerHTML=t,this},s.prototype.values=function(t){var e,n=[],r=this._s.buttons;if(void 0!==t){for(e=0;e<r.length;e++)t.includes(r[e].value())&&r[e].active(!0);return this._updateCount(),this}for(e=0;e<r.length;e++)r[e].active()&&n.push(r[e].value());return n},s.prototype._updateCount=function(){var t=this.values().length;this._dom.selectNoneCount.innerHTML=t?"("+t+")":""},s.prototype._redraw=function(){var t=this._s.buttons,e=this._dom.buttons,n=this._s.search.toLowerCase();e.replaceChildren();for(var r=0;r<t.length;r++){var o=t[r];n&&!o.text().toLowerCase().includes(n)||e.appendChild(o.element())}},s.classes={container:"dtcc-list",input:"dtcc-list-search"},s})(),colVis={defaults:{className:"colVis",columns:"",search:!1,select:!1,title:"Column visibility"},init:function(t){function n(){o.columns(t.columns).every(function(){i.add({active:this.visible(),label:this.title(),value:this.index()})})}var o=this.dt(),i=new CheckList(o,{search:t.search,select:t.select}).title(o.i18n("columnControl.colVis",t.title)).handler(function(t,e,n){e&&e.active(!e.active()),r(n)}),r=function(t){for(var e=0;e<t.length;e++){var n=t[e],r=n.value(),r=o.column(r);n.active()&&!r.visible()?r.visible(!0):!n.active()&&r.visible()&&r.visible(!1)}};return n(),o.on("column-visibility",function(t,e,n,r){n=i.button(n);n&&n.active(r)}),o.on("columns-reordered",function(t,e){i.clear(),n()}),i.element()}},colVisDropdown={defaults:{className:"colVis",columns:"",search:!1,select:!1,text:"Column visibility",title:"Column visibility"},extend:function(t){return{extend:"dropdown",icon:"columns",text:this.dt().i18n("columnControl.colVisDropdown",t.text),content:[Object.assign(t,{extend:"colVis"})]}}},reorder={defaults:{className:"reorder",icon:"move",text:"Reorder columns"},init:function(t){var n=this,e=this.dt(),r=new Button(e).text(e.i18n("columnControl.reorder",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();0<t&&e.colReorder.move(t,t-1)});return 0===this.idx()&&r.enable(!1),e.on("columns-reordered",function(t,e){r.enable(0<n.idx())}),e.init().colReorder||new DataTable.ColReorder(e,{}),r.element()}},reorderLeft={defaults:{className:"reorderLeft",icon:"moveLeft",text:"Move column left"},init:function(t){var n=this,e=this.dt(),r=new Button(e).text(e.i18n("columnControl.reorderLeft",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();0<t&&e.colReorder.move(t,t-1)});return 0===this.idx()&&r.enable(!1),e.on("columns-reordered",function(t,e){r.enable(0<n.idx())}),r.element()}},reorderRight={defaults:{className:"reorderRight",icon:"moveRight",text:"Move column right"},init:function(t){var n=this,r=this.dt(),o=new Button(r).text(r.i18n("columnControl.reorderRight",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.idx();t<r.columns().count()-1&&r.colReorder.move(t,t+1)});return this.idx()===r.columns().count()-1&&o.enable(!1),r.on("columns-reordered",function(t,e){o.enable(n.idx()<r.columns().count()-1)}),o.element()}},order={defaults:{className:"order",iconAsc:"orderAsc",iconDesc:"orderDesc",iconNone:"orderNone",statusOnly:!1,text:"Toggle ordering"},init:function(r){var o=this,t=this.dt(),i=new Button(t).text(t.i18n("columnControl.order",r.text)).icon("orderAsc").className(r.className);return r.statusOnly||t.order.listener(i.element(),DataTable.versionCheck("2.3.2")?function(){return[o.idx()]}:this.idx(),function(){}),t.on("order",function(t,e,n){n=n.find(function(t){return t.col===o.idx()});n?"asc"===n.dir?i.active(!0).icon(r.iconAsc):"desc"===n.dir&&i.active(!0).icon(r.iconDesc):i.active(!1).icon(r.iconNone)}),i.element()}},orderAddAsc={defaults:{className:"orderAddAsc",icon:"orderAddAsc",text:"Add Sort Ascending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAddAsc",t.text)).icon(t.icon).className(t.className).handler(function(){e.order().push([r.idx(),"asc"]),e.draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(!n)}),o.element()}},orderAddDesc={defaults:{className:"orderAddDesc",icon:"orderAddDesc",text:"Add Sort Descending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAddDesc",t.text)).icon(t.icon).className(t.className).handler(function(){e.order().push([r.idx(),"desc"]),e.draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(!n)}),o.element()}},orderAsc={defaults:{className:"orderAsc",icon:"orderAsc",text:"Sort Ascending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderAsc",t.text)).icon(t.icon).className(t.className).handler(function(){r.dt().order([{idx:r.idx(),dir:"asc"}]).draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()&&"asc"===t.dir});o.active(n)}),o.element()}},orderClear={defaults:{className:"orderClear",icon:"orderClear",text:"Clear sort"},init:function(t){var e=this.dt(),r=new Button(e).text(e.i18n("columnControl.orderClear",t.text)).icon(t.icon).className(t.className).handler(function(){e.order([]).draw()});return e.on("order",function(t,e,n){r.enable(0<n.length)}),0===e.order().length&&r.enable(!1),r.element()}},orderDesc={defaults:{className:"orderDesc",icon:"orderDesc",text:"Sort Descending"},init:function(t){var r=this,e=this.dt(),o=new Button(e).text(e.i18n("columnControl.orderDesc",t.text)).icon(t.icon).className(t.className).handler(function(){r.dt().order([{idx:r.idx(),dir:"desc"}]).draw()});return e.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()&&"desc"===t.dir});o.active(n)}),o.element()}},orderRemove={defaults:{className:"orderRemove",icon:"orderRemove",text:"Remove from sort"},init:function(t){var r=this,n=this.dt(),o=new Button(n).text(n.i18n("columnControl.orderRemove",t.text)).icon(t.icon).className(t.className).handler(function(){var t=n.order(),e=t.findIndex(function(t){return t[0]===r.idx()});t.splice(e,1),n.order(t).draw()});return n.on("order",function(t,e,n){n=n.some(function(t){return t.col===r.idx()});o.enable(n)}),o.enable(!1),o.element()}},orderStatus={defaults:{className:"order",iconAsc:"orderAsc",iconDesc:"orderDesc",iconNone:"orderNone",statusOnly:!0,text:"Sort status"},extend:function(t){return Object.assign(t,{extend:"order"})}},SearchInput=(()=>{function c(n,r){function t(){i.runSearch()}function e(){a.typeIcon.innerHTML=icons[a.select.value],i.runSearch()}function o(){i.clear()}var i=this,a=(this._type="text",this._dt=n,this._idx=r,this._dom={clear:createElement("span","dtcc-search-clear",icons.x),container:createElement("div",c.classes.container),typeIcon:createElement("div","dtcc-search-type-icon"),searchIcon:createElement("div","dtcc-search-icon",icons.search),input:createElement("input",c.classes.input),inputs:createElement("div"),select:createElement("select",c.classes.select),title:createElement("div","dtcc-search-title")},this._dom),s=r;a.input.setAttribute("type","text"),a.container.append(a.title,a.inputs),a.inputs.append(a.typeIcon,a.select,a.searchIcon,a.clear,a.input);a.input.addEventListener("input",t),a.select.addEventListener("input",e),a.clear.addEventListener("click",o),n.on("destroy",function(){a.input.removeEventListener("input",t),a.select.removeEventListener("input",e),a.clear.removeEventListener("click",o)}),n.on("stateSaveParams",function(t,e,n){n.columnControl||(n.columnControl={}),n.columnControl[r]||(n.columnControl[r]={}),n.columnControl[r].searchInput={logic:a.select.value,type:i._type,value:a.input.value}}),n.on("stateLoaded",function(t,e,n){i._stateLoad(n)}),n.on("columns-reordered",function(t,e){i._idx=n.colReorder.transpose(s,"fromOriginal")}),n.on("cc-search-clear",function(t,e){e===i._idx&&(i._loadingState=!0,i.clear(),i._loadingState=!1)})}return c.prototype.addClass=function(t){return this._dom.container.classList.add(t),this},c.prototype.clear=function(){return this.set(this._dom.select.children[0].getAttribute("value"),""),this},c.prototype.clearable=function(t){return t||this._dom.clear.remove(),this},c.prototype.element=function(){return this._dom.container},c.prototype.input=function(){return this._dom.input},c.prototype.options=function(t){for(var e=this._dom.select,n=0;n<t.length;n++)e.add(new Option(t[n].label,t[n].value));return this._dom.typeIcon.innerHTML=icons[t[0].value],this},c.prototype.placeholder=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.input.placeholder=t.replace("[title]",e)),this},c.prototype.runSearch=function(){var t=this._dom,e="empty"===t.select.value||"notEmpty"===t.select.value||""!==t.input.value;t.container.classList.toggle("dtcc-search_active",e),!this._search||this._lastValue===t.input.value&&this._lastType===t.select.value||(this._search(t.select.value,t.input.value,this._loadingState),this._lastValue=t.input.value,this._lastType=t.select.value)},c.prototype.search=function(t){return this._search=t,this._stateLoad(this._dt.state.loaded()),this},c.prototype.set=function(t,e){var n=this._dom;return n.input.value=e,n.select.value=t,n.typeIcon.innerHTML=icons[n.select.value],this.runSearch(),this},c.prototype.title=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.title.innerHTML=t.replace("[title]",e)),this},c.prototype.titleAttr=function(t){var e;return t&&(e=this._dt.column(this._idx).title(),this._dom.input.title=t.replace("[title]",e)),this},c.prototype.type=function(t){return this._type=t,this},c.prototype._stateLoad=function(t){var e=this._dom,n=this._idx,n=null==(t=null==(t=null==t?void 0:t.columnControl)?void 0:t[n])?void 0:t.searchInput;n&&(this._loadingState=!0,e.select.value=n.logic,e.input.value=n.value,e.select.dispatchEvent(new Event("input")),this._loadingState=!1)},c.classes={container:["dtcc-content","dtcc-search"],input:"",select:""},c})(),searchDateTime={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(i){var a,s=this,c=!1,l=DataTable.use("moment"),d=DataTable.use("luxon"),u=this.dt(),t="columnControl.search.datetime.",h="",e=new SearchInput(u,this.idx()).type("date").addClass("dtcc-searchDateTime").clearable(i.clear).placeholder(i.placeholder).title(i.title).titleAttr(i.titleAttr).options([{label:u.i18n(t+"equal","Equals"),value:"equal"},{label:u.i18n(t+"notEqual","Does not equal"),value:"notEqual"},{label:u.i18n(t+"greater","After"),value:"greater"},{label:u.i18n(t+"less","Before"),value:"less"},{label:u.i18n(t+"empty","Empty"),value:"empty"},{label:u.i18n(t+"notEmpty","Not empty"),value:"notEmpty"}]).search(function(t,e,n){var r=u.column(s.idx()),o=""===e?"":dateToNum(a&&c?a.val():e.trim(),h,l,d);if("empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===o)return;o?"equal"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)==o}):"notEqual"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)!=o}):"greater"===t?r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)>o}):"less"===t&&r.search.fixed("dtcc",function(t){return dateToNum(t,h,l,d)<o}):r.search.fixed("dtcc","")}i._parents&&i._parents.forEach(function(t){return t.activeList(s.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()});return u.ready(function(){var t=DataTable.use("datetime");h=getFormat(u,s.idx()),t&&(a=new t(e.input(),{format:h,i18n:u.settings()[0].oLanguage.datetime,onChange:function(){c=!0,e.runSearch(),c=!1}}))}),e.element()}};function getFormat(t,e){t=t.column(e).type();if(t)if("datetime"===t){var e=DataTable.use("moment"),n=DataTable.use("luxon");if(e)return e().creationData().locale._longDateFormat.L;if(n)return n.DateTime.fromISO("1999-08-07").toLocaleString().replace("07","dd").replace("7","d").replace("08","MM").replace("8","M").replace("1999","yyyy").replace("99","yy")}else{if(t.includes("datetime-"))return t.replace(/datetime-/g,"");if(t.includes("moment"))return t.replace(/moment-/g,"");if(t.includes("luxon"))return t.replace(/luxon-/g,"")}return"YYYY-MM-DD"}function dateToNum(t,e,n,r){return""===t?"":t instanceof Date?t.getTime():"YYYY-MM-DD"!==e&&(n||r)?n?1e3*n(t,e).unix():r.DateTime.fromFormat(t,e).toMillis():new Date(t).getTime()}function setOptions(t,e){var n=t.values();t.clear();for(var r=0;r<e.length;r++)"object"==typeof e[r]?t.add({active:!1,label:e[r].label,value:e[r].value},r===e.length-1):t.add({active:!1,label:e[r],value:e[r]},r===e.length-1);n.length&&t.values(n)}function getState(t,e){t=null==(e=null==(e=null==e?void 0:e.columnControl)?void 0:e[t])?void 0:e.searchList;if(t)return t}function getJsonOptions(t,e){var n=null==(n=t.ajax.json())?void 0:n.columnControl,t=t.column(e),r=t.name(),t=t.dataSrc();return n&&n[r]?n[r]:n&&"string"==typeof t&&n[t]?n[t]:n&&n[e]?n[e]:null}function reloadOptions(t,e,n,r,o){var i=null==(i=t.ajax.json())?void 0:i.columnControl,a=[],s=getJsonOptions(t,n);if(s)a=s;else{if(i&&e.ajaxOnly)return r.element().style.display="none",void(e._parents&&e._parents.forEach(function(t){return t.checkDisplay()}));for(var c={},l=t.rows({order:n}).indexes().toArray(),d=t.settings()[0],u=0;u<l.length;u++){var h=d.fastData(l[u],n,"filter");c[h]||(c[h]=!0,a.push({label:d.fastData(l[u],n,"display"),value:h}))}}setOptions(r,a),o&&r.values(o)}var searchList={defaults:{ajaxOnly:!0,className:"searchList",options:null,search:!0,select:!0,title:""},init:function(r){function o(e){var t=s.column(i.idx());e&&(0===e.length?t.search.fixed("dtcc-list",""):t.search.fixed("dtcc-list",function(t){return e.includes(t)}),r._parents)&&r._parents.forEach(function(t){return t.activeList(i.unique(),!!e.length)})}var i=this,a=null,s=this.dt(),c=new CheckList(s,{search:r.search,select:r.select}).searchListener(s,this).title(s.i18n("columnControl.searchList",r.title).replace("[title]",s.column(this.idx()).title())).handler(function(t,e,n,r){e&&e.active(!e.active()),o(c.values()),r&&s.draw()});return r.options?setOptions(c,r.options):s.ready(function(){reloadOptions(s,r,i.idx(),c,a)}),s.on("xhr",function(t,e,n){reloadOptions(s,r,i.idx(),c,a)}),s.on("stateLoaded",function(t,e,n){n=getState(i.idx(),n);n&&c.values(n)}),s.on("stateSaveParams",function(t,e,n){var r=i.idx();n.columnControl||(n.columnControl={}),n.columnControl[r]||(n.columnControl[r]={}),n.columnControl[r].searchList=s.ready()?c.values():a}),a=getState(this.idx(),s.state.loaded()),o(a),c.element()}},searchNumber={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(o){var i=this,a=this.dt(),t="columnControl.search.number.",t=new SearchInput(a,this.idx()).type("num").addClass("dtcc-searchNumber").clearable(o.clear).placeholder(o.placeholder).title(o.title).titleAttr(o.titleAttr).options([{label:a.i18n(t+"equal","Equals"),value:"equal"},{label:a.i18n(t+"notEqual","Does not equal"),value:"notEqual"},{label:a.i18n(t+"greater","Greater than"),value:"greater"},{label:a.i18n(t+"greaterOrEqual","Greater or equal"),value:"greaterOrEqual"},{label:a.i18n(t+"less","Less than"),value:"less"},{label:a.i18n(t+"lessOrEqual","Less or equal"),value:"lessOrEqual"},{label:a.i18n(t+"empty","Empty"),value:"empty"},{label:a.i18n(t+"notEmpty","Not empty"),value:"notEmpty"}]).search(function(t,e,n){var r=a.column(i.idx());if("empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===e)return;""===e?r.search.fixed("dtcc",""):"equal"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)==e}):"notEqual"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)!=e}):"greater"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)>e}):"greaterOrEqual"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)>=e}):"less"===t?r.search.fixed("dtcc",function(t){return stringToNum(t)<e}):"lessOrEqual"===t&&r.search.fixed("dtcc",function(t){return stringToNum(t)<=e})}o._parents&&o._parents.forEach(function(t){return t.activeList(i.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()});return t.input().setAttribute("inputmode","numeric"),t.input().setAttribute("pattern","[0-9]*"),t.element()}},_re_html=/<([^>]*>)/g,_re_formatted_numeric=/['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;function stringToNum(t){var e;return 0===t||t&&"-"!==t?"number"==(e=typeof t)||"bigint"==e?t:+(t=t.replace?t.replace(_re_html,"").replace(_re_formatted_numeric,""):t):-1/0}var searchText={defaults:{clear:!0,placeholder:"",title:"",titleAttr:""},init:function(o){var i=this,a=this.dt(),t="columnControl.search.text.";return new SearchInput(a,this.idx()).addClass("dtcc-searchText").clearable(o.clear).placeholder(o.placeholder).title(o.title).titleAttr(o.titleAttr).options([{label:a.i18n(t+"contains","Contains"),value:"contains"},{label:a.i18n(t+"notContains","Does not contain"),value:"notContains"},{label:a.i18n(t+"equal","Equals"),value:"equal"},{label:a.i18n(t+"notEqual","Does not equal"),value:"notEqual"},{label:a.i18n(t+"starts","Starts"),value:"starts"},{label:a.i18n(t+"ends","Ends"),value:"ends"},{label:a.i18n(t+"empty","Empty"),value:"empty"},{label:a.i18n(t+"notEmpty","Not empty"),value:"notEmpty"}]).search(function(t,e,n){var r=a.column(i.idx());if(e=e.toLowerCase(),"empty"===t)r.search.fixed("dtcc",function(t){return!t});else if("notEmpty"===t)r.search.fixed("dtcc",function(t){return!!t});else{if(""===r.search.fixed("dtcc")&&""===e)return;""===e?r.search.fixed("dtcc",""):"equal"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase()==e}):"notEqual"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase()!=e}):"contains"===t?r.search.fixed("dtcc",e):"notContains"===t?r.search.fixed("dtcc",function(t){return!t.toLowerCase().includes(e)}):"starts"===t?r.search.fixed("dtcc",function(t){return t.toLowerCase().startsWith(e)}):"ends"===t&&r.search.fixed("dtcc",function(t){return t.toLowerCase().endsWith(e)})}o._parents&&o._parents.forEach(function(t){return t.activeList(i.unique(),!!r.search.fixed("dtcc"))}),n||r.draw()}).element()}},search={defaults:{allowSearchList:!1},init:function(n){function e(t){var e=getJsonOptions(i,a);return n.allowSearchList&&e?searchList.init.call(o,Object.assign({},searchList.defaults,n)):"date"===t||t.startsWith("datetime")?searchDateTime.init.call(o,Object.assign({},searchDateTime.defaults,n)):t.includes("num")?searchNumber.init.call(o,Object.assign({},searchNumber.defaults,n)):searchText.init.call(o,Object.assign({},searchText.defaults,n))}var r,o=this,i=this.dt(),a=this.idx(),t=null==(t=null==(t=null==(t=i.state.loaded())?void 0:t.columnControl)?void 0:t[a])?void 0:t.searchInput;return t?r=e(t.type):(r=document.createElement("div"),i.ready(function(){var t=i.column(a),t=e(t.type());r.replaceWith(t)})),r}},searchClear={defaults:{className:"searchClear",icon:"searchClear",text:"Clear Search"},init:function(t){var n=this,r=this.dt(),o=new Button(r).text(r.i18n("columnControl.searchClear",t.text)).icon(t.icon).className(t.className).handler(function(){r.column(n.idx()).ccSearchClear().draw()}).enable(!1);return r.on("draw",function(){var t=r.column(n.idx()).search.fixed("dtcc"),e=r.column(n.idx()).search.fixed("dtcc-list");o.enable(!(!t&&!e))}),o.element()}},searchDropdown={defaults:{ajaxOnly:!0,allowSearchList:!0,className:"searchDropdown",clear:!0,columns:"",options:null,placeholder:"",search:!0,select:!0,text:"Search",title:"",titleAttr:""},extend:function(t){return{extend:"dropdown",icon:"search",text:this.dt().i18n("columnControl.searchDropdown",t.text),content:[Object.assign(t,{extend:"search"})]}}},spacer={defaults:{className:"dtcc-spacer",text:""},init:function(t){var e=this.dt(),e=createElement("div",t.className,e.i18n("columnControl.spacer",t.text));return e.setAttribute("role","separator"),e}},title={defaults:{className:"dtcc-title",text:null},init:function(t){var e=this.dt().column(this.idx()).title(),n=null===t.text?"[title]":t.text;return createElement("div",t.className,n.replace("[title]",e))}},contentTypes={colVis:colVis,colVisDropdown:colVisDropdown,dropdown:dropdownContent,reorder:reorder,reorderLeft:reorderLeft,reorderRight:reorderRight,order:order,orderAddAsc:orderAddAsc,orderAddDesc:orderAddDesc,orderAsc:orderAsc,orderClear:orderClear,orderDesc:orderDesc,orderRemove:orderRemove,orderStatus:orderStatus,search:search,searchClear:searchClear,searchDropdown:searchDropdown,searchDateTime:searchDateTime,searchList:searchList,searchNumber:searchNumber,searchText:searchText,spacer:spacer,title:title},ColumnControl=(()=>{function i(n,t,e){var r=this,o=(this._dom={target:null,wrapper:null},this._c={},this._s={columnIdx:null,unique:null},this._dt=n,this._s.columnIdx=t,this._s.unique=Math.random(),t);Object.assign(this._c,i.defaults,e),this._dom.target=this._target(),e.className&&addClass(this._dom.target.closest("tr"),e.className),this._c.content&&(n.on("columns-reordered",function(t,e){r._s.columnIdx=n.colReorder.transpose(o,"fromOriginal")}),this._dom.wrapper=document.createElement("span"),this._dom.wrapper.classList.add("dtcc"),this._dom.target.appendChild(this._dom.wrapper),this._c.content.forEach(function(t){t=r.resolve(t),t=t.plugin.init.call(r,t.config);r._dom.wrapper.appendChild(t)}),n.on("destroy",function(){r._dom.wrapper.remove()}))}return i.prototype.dt=function(){return this._dt},i.prototype.idx=function(){return this._s.columnIdx},i.prototype.resolve=function(t){var e=null,n=null,r=null;if("string"==typeof t?(e=i.content[r=t],n=Object.assign({},null==e?void 0:e.defaults)):Array.isArray(t)?(e=i.content[r="dropdown"],n=Object.assign({},null==e?void 0:e.defaults,{content:t})):t.extend&&(r=t.extend,e=i.content[r],n=Object.assign({},null==e?void 0:e.defaults,t)),e)return e.extend?(t=e.extend.call(this,n),this.resolve(t)):{config:n,type:r,plugin:e};throw new Error("Unknown ColumnControl content type: "+r)},i.prototype.unique=function(){return this._s.unique},i.prototype._target=function(){var t,e,n=this._c.target,r=this._dt.column(this._s.columnIdx),o="header";return"number"==typeof n?t=r.header(n):(e="tfoot"!==(n=n.split(":"))[0],n=n[1]?parseInt(n[1]):0,e?t=r.header(n):(t=r.footer(n),o="footer")),t.querySelector("div.dt-column-"+o)},i.Button=Button,i.CheckList=CheckList,i.SearchInput=SearchInput,i.content=contentTypes,i.defaults={className:"",content:null,target:0},i.icons=icons,i.version="1.0.5",i})();function assetTarget(t,e,n){if(!t[e]){var r=!0,o=0,i=("number"==typeof e?o=e:("tfoot"===(i=e.split(":"))[0]&&(r=!1),i[1]&&(o=parseInt(i[1]))),r?n.table().header():n.table().footer());if(!i.querySelectorAll("tr")[o]){var a=n.columns().count(),s=createElement("tr");s.setAttribute("data-dt-order","disable");for(var c=0;c<a;c++)s.appendChild(createElement("td"));i.appendChild(s)}t[e]=!0}}function getOptionsForTarget(t,e){var n=ColumnControl.defaults.target;if(isIContentArray(e)){if(n===t)return{target:n,content:e}}else if(Array.isArray(e))for(var r=0;r<e.length;r++){var o=e[r];if(isIContentArray(o)){if(n===t)return{target:n,content:o}}else if(isIConfig(o)){if(t===(void 0!==o.target?o.target:n))return o}else if(t===n)return{target:n,content:e}}else if("object"==typeof e)if(isIConfig(e)){if(t===(void 0!==e.target?e.target:n))return e}else if(t===n)return{target:n,content:e}}function identifyTargets(e,t){function n(t){e.includes(t)||e.push(t)}return Array.isArray(t)?t.forEach(function(t){n(("object"==typeof t&&void 0!==t.target?t:ColumnControl.defaults).target)}):"object"==typeof t&&n((void 0!==t.target?t:ColumnControl.defaults).target),e}function isIConfig(t){return"object"==typeof t&&void 0!==t.target}function isIContentArray(t){var e=!1;if(!Array.isArray(t))return!1;for(var n=0;n<t.length;n++)if(isIConfig(t[n])){e=!0;break}return!e}DataTable.ColumnControl=ColumnControl,$(document).on("i18n.dt",function(t,e){if("dt"===t.namespace){var n=new DataTable.Api(e),t=n.table().header(),r=e.oInit.columnControl,o=ColumnControl.defaults,i=[],a={};t.querySelectorAll("tr").length<=1&&null===e.titleRow&&(e.titleRow=0),identifyTargets(i,r),identifyTargets(i,o),n.columns().every(function(t){var e=this.init().columnControl;identifyTargets(i,e)});for(var s=0;s<i.length;s++)assetTarget(a,i[s],n)}}),$(document).on("preInit.dt",function(t,e){var s,c,l,d;"dt"===t.namespace&&(s=new DataTable.Api(e),c=e.oInit.columnControl,l=ColumnControl.defaults,identifyTargets(d=[],c),identifyTargets(d,l),s.columns().every(function(t){for(var e=this.init().columnControl,n=identifyTargets(d.slice(),e),r=0;r<n.length;r++){var o=getOptionsForTarget(n[r],e),i=getOptionsForTarget(n[r],c),a=getOptionsForTarget(n[r],l);(a||i||o)&&new ColumnControl(s,this.index(),Object.assign({},a||{},i||{},o||{}))}}))}),DataTable.Api.registerPlural("columns().ccSearchClear()","column().ccSearchClear()",function(){var n=this;return this.iterator("column",function(t,e){n.trigger("cc-search-clear",[e])})}),DataTable.ext.buttons.ccSearchClear={text:function(t){return t.i18n("columnControl.buttons.searchClear","Clear search")},init:function(n,t,e){var r=this;n.on("draw",function(){var t=!1,e=!!n.search();e||n.columns().every(function(){(this.search.fixed("dtcc")||this.search.fixed("dtcc-list"))&&(t=!0)}),r.enable(e||t)}),this.enable(!1)},action:function(t,e,n,r){e.search(""),e.columns().ccSearchClear(),e.draw()}};export default DataTable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! ColumnControl 1.0.
|
|
1
|
+
/*! ColumnControl 1.0.5
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*
|
|
4
4
|
* SVG icons: ISC License
|
|
@@ -35,7 +35,7 @@ function addClass(el, classes) {
|
|
|
35
35
|
classes = [classes];
|
|
36
36
|
}
|
|
37
37
|
classes.forEach(function (className) {
|
|
38
|
-
if (className) {
|
|
38
|
+
if (el && className) {
|
|
39
39
|
el.classList.add(className);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -117,6 +117,9 @@ function close(e) {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
+
function getContainer(dt, btn) {
|
|
121
|
+
return btn.closest('div.dtfh-floatingparent') || dt.table().container();
|
|
122
|
+
}
|
|
120
123
|
/**
|
|
121
124
|
* Position the dropdown relative to the button that activated it, with possible corrections
|
|
122
125
|
* to make sure it is visible on the page.
|
|
@@ -126,11 +129,11 @@ function close(e) {
|
|
|
126
129
|
* @param btn Button the dropdown emanates from
|
|
127
130
|
*/
|
|
128
131
|
function positionDropdown(dropdown, dt, btn) {
|
|
129
|
-
var dtContainer = dt.table().container();
|
|
130
132
|
var header = btn.closest('div.dt-column-header');
|
|
133
|
+
var container = getContainer(dt, btn);
|
|
131
134
|
var headerStyle = getComputedStyle(header);
|
|
132
135
|
var dropdownWidth = dropdown.offsetWidth;
|
|
133
|
-
var position = relativePosition(
|
|
136
|
+
var position = relativePosition(container, btn);
|
|
134
137
|
var left, top;
|
|
135
138
|
top = position.top + btn.offsetHeight;
|
|
136
139
|
if (headerStyle.flexDirection === 'row-reverse') {
|
|
@@ -142,7 +145,7 @@ function positionDropdown(dropdown, dt, btn) {
|
|
|
142
145
|
left = position.left - dropdownWidth + btn.offsetWidth;
|
|
143
146
|
}
|
|
144
147
|
// Corrections - don't extend past the DataTable to the left and right
|
|
145
|
-
var containerWidth =
|
|
148
|
+
var containerWidth = container.offsetWidth;
|
|
146
149
|
if (left + dropdownWidth > containerWidth) {
|
|
147
150
|
left -= left + dropdownWidth - containerWidth;
|
|
148
151
|
}
|
|
@@ -161,7 +164,7 @@ function positionDropdown(dropdown, dt, btn) {
|
|
|
161
164
|
* @returns Function to call when the dropdown should be removed from the document
|
|
162
165
|
*/
|
|
163
166
|
function attachDropdown(dropdown, dt, btn) {
|
|
164
|
-
var dtContainer = dt.
|
|
167
|
+
var dtContainer = getContainer(dt, btn.element());
|
|
165
168
|
dropdown._shown = true;
|
|
166
169
|
dtContainer.append(dropdown);
|
|
167
170
|
positionDropdown(dropdown, dt, btn.element());
|
|
@@ -209,6 +212,51 @@ function relativePosition(parent, origin) {
|
|
|
209
212
|
left: left
|
|
210
213
|
};
|
|
211
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Function that will provide the keyboard navigation for the dropdown
|
|
217
|
+
*
|
|
218
|
+
* @param dropdown Dropdown element in question
|
|
219
|
+
* @returns Function that can be bound to `keypress`
|
|
220
|
+
*/
|
|
221
|
+
function focusCapture(dropdown, host) {
|
|
222
|
+
return function (e) {
|
|
223
|
+
// Do nothing if not shown
|
|
224
|
+
if (!dropdown._shown) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// Focus trap for tab key
|
|
228
|
+
var elements = Array.from(dropdown.querySelectorAll('a, button, input, select'));
|
|
229
|
+
var active = document.activeElement;
|
|
230
|
+
// An escape key should close the dropdown
|
|
231
|
+
if (e.key === 'Escape') {
|
|
232
|
+
dropdown._close();
|
|
233
|
+
host.focus(); // Restore focus to the host
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
else if (e.key !== 'Tab' || elements.length === 0) {
|
|
237
|
+
// Anything other than tab we aren't interested in from here
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (!elements.includes(active)) {
|
|
241
|
+
// If new focus is not inside the popover we want to drag it back in
|
|
242
|
+
elements[0].focus();
|
|
243
|
+
e.preventDefault();
|
|
244
|
+
}
|
|
245
|
+
else if (e.shiftKey) {
|
|
246
|
+
// Reverse tabbing order when shift key is pressed
|
|
247
|
+
if (active === elements[0]) {
|
|
248
|
+
elements[elements.length - 1].focus();
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if (active === elements[elements.length - 1]) {
|
|
254
|
+
elements[0].focus();
|
|
255
|
+
e.preventDefault();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
212
260
|
var dropdownContent = {
|
|
213
261
|
classes: {
|
|
214
262
|
container: 'dtcc-dropdown',
|
|
@@ -230,6 +278,15 @@ var dropdownContent = {
|
|
|
230
278
|
dropdown.remove();
|
|
231
279
|
dropdown._shown = false;
|
|
232
280
|
};
|
|
281
|
+
dropdown.setAttribute('role', 'dialog');
|
|
282
|
+
dropdown.setAttribute('aria-label', dt.i18n('columnControl.dropdown', config.text));
|
|
283
|
+
// When FixedHeader is used, the transition between states messes up positioning, so if
|
|
284
|
+
// shown we just reattach the dropdown.
|
|
285
|
+
dt.on('fixedheader-mode', function () {
|
|
286
|
+
if (dropdown._shown) {
|
|
287
|
+
attachDropdown(dropdown, dt, config._parents ? config._parents[0] : btn);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
233
290
|
// A liner element allows more styling options, so the contents go inside this
|
|
234
291
|
var liner = dropdown.childNodes[0];
|
|
235
292
|
var btn = new Button(dt)
|
|
@@ -244,7 +301,14 @@ var dropdownContent = {
|
|
|
244
301
|
return;
|
|
245
302
|
}
|
|
246
303
|
attachDropdown(dropdown, dt, config._parents ? config._parents[0] : btn);
|
|
304
|
+
// When activated using a key - auto focus on the first item in the popover
|
|
305
|
+
var focusable = dropdown.querySelector('input, a, button');
|
|
306
|
+
console.log(e.type, e);
|
|
307
|
+
if (focusable && e.type === 'keypress') {
|
|
308
|
+
focusable.focus();
|
|
309
|
+
}
|
|
247
310
|
});
|
|
311
|
+
btn.element().setAttribute('aria-haspopup', 'dialog');
|
|
248
312
|
// Add the content for the dropdown
|
|
249
313
|
for (var i = 0; i < config.content.length; i++) {
|
|
250
314
|
var content = this.resolve(config.content[i]);
|
|
@@ -265,6 +329,12 @@ var dropdownContent = {
|
|
|
265
329
|
dt.on('columns-reordered', function () {
|
|
266
330
|
positionDropdown(dropdown, dt, btn.element());
|
|
267
331
|
});
|
|
332
|
+
// Focus capture events
|
|
333
|
+
var capture = focusCapture(dropdown, btn.element());
|
|
334
|
+
document.body.addEventListener('keydown', capture);
|
|
335
|
+
dt.on('destroy', function () {
|
|
336
|
+
document.body.removeEventListener('keydown', capture);
|
|
337
|
+
});
|
|
268
338
|
return btn.element();
|
|
269
339
|
}
|
|
270
340
|
};
|
|
@@ -361,6 +431,7 @@ var Button = /** @class */ (function () {
|
|
|
361
431
|
Button.prototype.destroy = function () {
|
|
362
432
|
if (this._s.buttonClick) {
|
|
363
433
|
this._dom.button.removeEventListener('click', this._s.buttonClick);
|
|
434
|
+
this._dom.button.removeEventListener('keypress', this._s.buttonClick);
|
|
364
435
|
}
|
|
365
436
|
if (this._s.namespace) {
|
|
366
437
|
this._s.dt.off('destroy.' + this._s.namespace);
|
|
@@ -428,6 +499,7 @@ var Button = /** @class */ (function () {
|
|
|
428
499
|
this._s.buttonClick = buttonClick;
|
|
429
500
|
this._s.namespace = 'dtcc-' + _namespace++;
|
|
430
501
|
this._dom.button.addEventListener('click', buttonClick);
|
|
502
|
+
this._dom.button.addEventListener('keypress', buttonClick);
|
|
431
503
|
// Use a unique namespace to be able to easily remove per button
|
|
432
504
|
this._s.dt.on('destroy.' + this._s.namespace, function () {
|
|
433
505
|
_this.destroy();
|
|
@@ -450,6 +522,7 @@ var Button = /** @class */ (function () {
|
|
|
450
522
|
}
|
|
451
523
|
this._dom.text.innerHTML = text;
|
|
452
524
|
this._s.label = text; // for fast retrieval
|
|
525
|
+
this._dom.button.setAttribute('aria-label', text);
|
|
453
526
|
return this;
|
|
454
527
|
};
|
|
455
528
|
Button.prototype.value = function (val) {
|
|
@@ -523,12 +596,12 @@ var CheckList = /** @class */ (function () {
|
|
|
523
596
|
};
|
|
524
597
|
var selectAllClick = function (e) {
|
|
525
598
|
_this.selectAll();
|
|
526
|
-
_this._s.handler(e, null, _this._s.buttons);
|
|
599
|
+
_this._s.handler(e, null, _this._s.buttons, true);
|
|
527
600
|
_this._updateCount();
|
|
528
601
|
};
|
|
529
602
|
var selectNoneClick = function (e) {
|
|
530
603
|
_this.selectNone();
|
|
531
|
-
_this._s.handler(e, null, _this._s.buttons);
|
|
604
|
+
_this._s.handler(e, null, _this._s.buttons, true);
|
|
532
605
|
_this._updateCount();
|
|
533
606
|
};
|
|
534
607
|
if (opts.search) {
|
|
@@ -560,12 +633,17 @@ var CheckList = /** @class */ (function () {
|
|
|
560
633
|
var btn = new Button(this_1._s.dt)
|
|
561
634
|
.active(option.active || false)
|
|
562
635
|
.handler(function (e) {
|
|
563
|
-
_this._s.handler(e, btn, _this._s.buttons);
|
|
636
|
+
_this._s.handler(e, btn, _this._s.buttons, true);
|
|
564
637
|
_this._updateCount();
|
|
565
638
|
})
|
|
566
639
|
.icon(option.icon || '')
|
|
567
|
-
.text(option.label
|
|
640
|
+
.text(option.label !== ''
|
|
641
|
+
? option.label
|
|
642
|
+
: this_1._s.dt.i18n('columnControl.list.emptyOption', 'Empty'))
|
|
568
643
|
.value(option.value);
|
|
644
|
+
if (option.label === '') {
|
|
645
|
+
btn.className('empty');
|
|
646
|
+
}
|
|
569
647
|
this_1._s.buttons.push(btn);
|
|
570
648
|
};
|
|
571
649
|
var this_1 = this;
|
|
@@ -638,7 +716,7 @@ var CheckList = /** @class */ (function () {
|
|
|
638
716
|
dt.on('cc-search-clear', function (e, colIdx) {
|
|
639
717
|
if (colIdx === parent.idx()) {
|
|
640
718
|
_this.selectNone();
|
|
641
|
-
_this._s.handler(e, null, _this._s.buttons);
|
|
719
|
+
_this._s.handler(e, null, _this._s.buttons, false);
|
|
642
720
|
_this._s.search = '';
|
|
643
721
|
_this._dom.search.value = '';
|
|
644
722
|
_this._redraw();
|
|
@@ -925,7 +1003,7 @@ var order = {
|
|
|
925
1003
|
.icon('orderAsc')
|
|
926
1004
|
.className(config.className);
|
|
927
1005
|
if (!config.statusOnly) {
|
|
928
|
-
dt.order.listener(btn.element(), this.idx(), function () { });
|
|
1006
|
+
dt.order.listener(btn.element(), DataTable.versionCheck('2.3.2') ? function () { return [_this.idx()]; } : this.idx(), function () { });
|
|
929
1007
|
}
|
|
930
1008
|
dt.on('order', function (e, s, order) {
|
|
931
1009
|
var found = order.find(function (o) { return o.col === _this.idx(); });
|
|
@@ -1193,7 +1271,10 @@ var SearchInput = /** @class */ (function () {
|
|
|
1193
1271
|
// Column control search clearing (column().ccSearchClear() method)
|
|
1194
1272
|
dt.on('cc-search-clear', function (e, colIdx) {
|
|
1195
1273
|
if (colIdx === _this._idx) {
|
|
1274
|
+
// Don't want an automatic redraw on this event
|
|
1275
|
+
_this._loadingState = true;
|
|
1196
1276
|
_this.clear();
|
|
1277
|
+
_this._loadingState = false;
|
|
1197
1278
|
}
|
|
1198
1279
|
});
|
|
1199
1280
|
}
|
|
@@ -1390,6 +1471,7 @@ var searchDateTime = {
|
|
|
1390
1471
|
var moment = DataTable.use('moment');
|
|
1391
1472
|
var luxon = DataTable.use('luxon');
|
|
1392
1473
|
var dt = this.dt();
|
|
1474
|
+
var i18nBase = 'columnControl.search.datetime.';
|
|
1393
1475
|
var displayFormat = '';
|
|
1394
1476
|
var dateTime;
|
|
1395
1477
|
var searchInput = new SearchInput(dt, this.idx())
|
|
@@ -1400,12 +1482,12 @@ var searchDateTime = {
|
|
|
1400
1482
|
.title(config.title)
|
|
1401
1483
|
.titleAttr(config.titleAttr)
|
|
1402
1484
|
.options([
|
|
1403
|
-
{ label: 'Equals', value: 'equal' },
|
|
1404
|
-
{ label: 'Does not equal', value: 'notEqual' },
|
|
1405
|
-
{ label: 'After', value: 'greater' },
|
|
1406
|
-
{ label: 'Before', value: 'less' },
|
|
1407
|
-
{ label: 'Empty', value: 'empty' },
|
|
1408
|
-
{ label: 'Not empty', value: 'notEmpty' }
|
|
1485
|
+
{ label: dt.i18n(i18nBase + 'equal', 'Equals'), value: 'equal' },
|
|
1486
|
+
{ label: dt.i18n(i18nBase + 'notEqual', 'Does not equal'), value: 'notEqual' },
|
|
1487
|
+
{ label: dt.i18n(i18nBase + 'greater', 'After'), value: 'greater' },
|
|
1488
|
+
{ label: dt.i18n(i18nBase + 'less', 'Before'), value: 'less' },
|
|
1489
|
+
{ label: dt.i18n(i18nBase + 'empty', 'Empty'), value: 'empty' },
|
|
1490
|
+
{ label: dt.i18n(i18nBase + 'notEmpty', 'Not empty'), value: 'notEmpty' }
|
|
1409
1491
|
])
|
|
1410
1492
|
.search(function (searchType, searchTerm, loadingState) {
|
|
1411
1493
|
var column = dt.column(_this.idx());
|
|
@@ -1458,6 +1540,7 @@ var searchDateTime = {
|
|
|
1458
1540
|
if (DateTime) {
|
|
1459
1541
|
dateTime = new DateTime(searchInput.input(), {
|
|
1460
1542
|
format: displayFormat,
|
|
1543
|
+
i18n: dt.settings()[0].oLanguage.datetime, // could be undefined
|
|
1461
1544
|
onChange: function () {
|
|
1462
1545
|
fromPicker = true;
|
|
1463
1546
|
searchInput.runSearch();
|
|
@@ -1681,12 +1764,14 @@ var searchList = {
|
|
|
1681
1764
|
.title(dt
|
|
1682
1765
|
.i18n('columnControl.searchList', config.title)
|
|
1683
1766
|
.replace('[title]', dt.column(this.idx()).title()))
|
|
1684
|
-
.handler(function (e, btn) {
|
|
1767
|
+
.handler(function (e, btn, btns, redraw) {
|
|
1685
1768
|
if (btn) {
|
|
1686
1769
|
btn.active(!btn.active());
|
|
1687
1770
|
}
|
|
1688
1771
|
applySearch(checkList.values());
|
|
1689
|
-
|
|
1772
|
+
if (redraw) {
|
|
1773
|
+
dt.draw();
|
|
1774
|
+
}
|
|
1690
1775
|
});
|
|
1691
1776
|
if (config.options) {
|
|
1692
1777
|
setOptions(checkList, config.options);
|
|
@@ -1740,6 +1825,7 @@ var searchNumber = {
|
|
|
1740
1825
|
init: function (config) {
|
|
1741
1826
|
var _this = this;
|
|
1742
1827
|
var dt = this.dt();
|
|
1828
|
+
var i18nBase = 'columnControl.search.number.';
|
|
1743
1829
|
var searchInput = new SearchInput(dt, this.idx())
|
|
1744
1830
|
.type('num')
|
|
1745
1831
|
.addClass('dtcc-searchNumber')
|
|
@@ -1748,14 +1834,17 @@ var searchNumber = {
|
|
|
1748
1834
|
.title(config.title)
|
|
1749
1835
|
.titleAttr(config.titleAttr)
|
|
1750
1836
|
.options([
|
|
1751
|
-
{ label: 'Equals', value: 'equal' },
|
|
1752
|
-
{ label: 'Does not equal', value: 'notEqual' },
|
|
1753
|
-
{ label: 'Greater than', value: 'greater' },
|
|
1754
|
-
{
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
{ label: '
|
|
1837
|
+
{ label: dt.i18n(i18nBase + 'equal', 'Equals'), value: 'equal' },
|
|
1838
|
+
{ label: dt.i18n(i18nBase + 'notEqual', 'Does not equal'), value: 'notEqual' },
|
|
1839
|
+
{ label: dt.i18n(i18nBase + 'greater', 'Greater than'), value: 'greater' },
|
|
1840
|
+
{
|
|
1841
|
+
label: dt.i18n(i18nBase + 'greaterOrEqual', 'Greater or equal'),
|
|
1842
|
+
value: 'greaterOrEqual'
|
|
1843
|
+
},
|
|
1844
|
+
{ label: dt.i18n(i18nBase + 'less', 'Less than'), value: 'less' },
|
|
1845
|
+
{ label: dt.i18n(i18nBase + 'lessOrEqual', 'Less or equal'), value: 'lessOrEqual' },
|
|
1846
|
+
{ label: dt.i18n(i18nBase + 'empty', 'Empty'), value: 'empty' },
|
|
1847
|
+
{ label: dt.i18n(i18nBase + 'notEmpty', 'Not empty'), value: 'notEmpty' }
|
|
1759
1848
|
])
|
|
1760
1849
|
.search(function (searchType, searchTerm, loadingState) {
|
|
1761
1850
|
var column = dt.column(_this.idx());
|
|
@@ -1834,6 +1923,7 @@ var searchText = {
|
|
|
1834
1923
|
init: function (config) {
|
|
1835
1924
|
var _this = this;
|
|
1836
1925
|
var dt = this.dt();
|
|
1926
|
+
var i18nBase = 'columnControl.search.text.';
|
|
1837
1927
|
var searchInput = new SearchInput(dt, this.idx())
|
|
1838
1928
|
.addClass('dtcc-searchText')
|
|
1839
1929
|
.clearable(config.clear)
|
|
@@ -1841,14 +1931,17 @@ var searchText = {
|
|
|
1841
1931
|
.title(config.title)
|
|
1842
1932
|
.titleAttr(config.titleAttr)
|
|
1843
1933
|
.options([
|
|
1844
|
-
{ label: 'Contains', value: 'contains' },
|
|
1845
|
-
{
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
{ label: '
|
|
1850
|
-
{ label: '
|
|
1851
|
-
{ label: '
|
|
1934
|
+
{ label: dt.i18n(i18nBase + 'contains', 'Contains'), value: 'contains' },
|
|
1935
|
+
{
|
|
1936
|
+
label: dt.i18n(i18nBase + 'notContains', 'Does not contain'),
|
|
1937
|
+
value: 'notContains'
|
|
1938
|
+
},
|
|
1939
|
+
{ label: dt.i18n(i18nBase + 'equal', 'Equals'), value: 'equal' },
|
|
1940
|
+
{ label: dt.i18n(i18nBase + 'notEqual', 'Does not equal'), value: 'notEqual' },
|
|
1941
|
+
{ label: dt.i18n(i18nBase + 'starts', 'Starts'), value: 'starts' },
|
|
1942
|
+
{ label: dt.i18n(i18nBase + 'ends', 'Ends'), value: 'ends' },
|
|
1943
|
+
{ label: dt.i18n(i18nBase + 'empty', 'Empty'), value: 'empty' },
|
|
1944
|
+
{ label: dt.i18n(i18nBase + 'notEmpty', 'Not empty'), value: 'notEmpty' }
|
|
1852
1945
|
])
|
|
1853
1946
|
.search(function (searchType, searchTerm, loadingState) {
|
|
1854
1947
|
var column = dt.column(_this.idx());
|
|
@@ -1971,7 +2064,7 @@ var searchClear = {
|
|
|
1971
2064
|
.icon(config.icon)
|
|
1972
2065
|
.className(config.className)
|
|
1973
2066
|
.handler(function () {
|
|
1974
|
-
dt.column(_this.idx()).ccSearchClear();
|
|
2067
|
+
dt.column(_this.idx()).ccSearchClear().draw();
|
|
1975
2068
|
})
|
|
1976
2069
|
.enable(false);
|
|
1977
2070
|
dt.on('draw', function () {
|
|
@@ -2022,6 +2115,7 @@ var spacer = {
|
|
|
2022
2115
|
init: function (config) {
|
|
2023
2116
|
var dt = this.dt();
|
|
2024
2117
|
var spacer = createElement('div', config.className, dt.i18n('columnControl.spacer', config.text));
|
|
2118
|
+
spacer.setAttribute('role', 'separator');
|
|
2025
2119
|
return spacer;
|
|
2026
2120
|
}
|
|
2027
2121
|
};
|
|
@@ -2226,7 +2320,7 @@ var ColumnControl = /** @class */ (function () {
|
|
|
2226
2320
|
/** SVG icons that can be used by the content plugins */
|
|
2227
2321
|
ColumnControl.icons = icons;
|
|
2228
2322
|
/** Version */
|
|
2229
|
-
ColumnControl.version = '1.0.
|
|
2323
|
+
ColumnControl.version = '1.0.5';
|
|
2230
2324
|
return ColumnControl;
|
|
2231
2325
|
}());
|
|
2232
2326
|
|
|
@@ -2296,11 +2390,14 @@ $(document).on('preInit.dt', function (e, settings) {
|
|
|
2296
2390
|
DataTable.Api.registerPlural('columns().ccSearchClear()', 'column().ccSearchClear()', function () {
|
|
2297
2391
|
var ctx = this;
|
|
2298
2392
|
return this.iterator('column', function (settings, idx) {
|
|
2393
|
+
// Note that the listeners for this will not redraw the table.
|
|
2299
2394
|
ctx.trigger('cc-search-clear', [idx]);
|
|
2300
2395
|
});
|
|
2301
2396
|
});
|
|
2302
2397
|
DataTable.ext.buttons.ccSearchClear = {
|
|
2303
|
-
text:
|
|
2398
|
+
text: function (dt) {
|
|
2399
|
+
return dt.i18n('columnControl.buttons.searchClear', 'Clear search');
|
|
2400
|
+
},
|
|
2304
2401
|
init: function (dt, node, config) {
|
|
2305
2402
|
var _this = this;
|
|
2306
2403
|
dt.on('draw', function () {
|
|
@@ -2321,6 +2418,7 @@ DataTable.ext.buttons.ccSearchClear = {
|
|
|
2321
2418
|
action: function (e, dt, node, config) {
|
|
2322
2419
|
dt.search('');
|
|
2323
2420
|
dt.columns().ccSearchClear();
|
|
2421
|
+
dt.draw();
|
|
2324
2422
|
}
|
|
2325
2423
|
};
|
|
2326
2424
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "js/dataTables.columnControl.js",
|
|
5
5
|
"module": "js/dataTables.columnControl.mjs",
|
|
6
6
|
"types": "./types/types.d.ts",
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.5",
|
|
8
8
|
"files": [
|
|
9
9
|
"js/**/*.js",
|
|
10
10
|
"js/**/*.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"sort"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"datatables.net": "^2.3"
|
|
25
|
+
"datatables.net": "^2.3.2"
|
|
26
26
|
},
|
|
27
27
|
"moduleType": [
|
|
28
28
|
"globals",
|