@logimaxx/kgrid 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kgrid.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-10-28T14:23:09.350Z */
1
+ /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-11-03T07:47:27.707Z */
2
2
 
3
3
  /* --- configure.js --- */
4
4
  /**
@@ -1955,8 +1955,13 @@
1955
1955
  if (!root) {
1956
1956
  return;
1957
1957
  }
1958
+ const doc = hidden.ownerDocument;
1959
+ const panel = doc.getElementById(id + "_panel");
1960
+ function boundInput(selector) {
1961
+ return root.querySelector(selector) || (panel && panel.querySelector(selector));
1962
+ }
1958
1963
  const bound = hidden.getAttribute("data-kgrid-date-bound");
1959
- const visible = root.querySelector(
1964
+ const visible = boundInput(
1960
1965
  bound === "to" ? ".kgrid-date-range-to" : ".kgrid-date-range-from"
1961
1966
  );
1962
1967
  if (!visible) {
@@ -1966,6 +1971,26 @@
1966
1971
  if (visible.value !== date) {
1967
1972
  visible.value = date;
1968
1973
  }
1974
+ const display = root.querySelector(".kgrid-date-range-display");
1975
+ if (!display) {
1976
+ return;
1977
+ }
1978
+ const fromEl = boundInput(".kgrid-date-range-from");
1979
+ const toEl = boundInput(".kgrid-date-range-to");
1980
+ const text = formatDateRangeDisplay(fromEl && fromEl.value, toEl && toEl.value);
1981
+ if (display.value !== text) {
1982
+ display.value = text;
1983
+ }
1984
+ const clear = root.querySelector(".kgrid-date-range-clear");
1985
+ if (clear) {
1986
+ if (text) {
1987
+ clear.removeAttribute("hidden");
1988
+ root.classList.add("kgrid-date-range-has-value");
1989
+ } else {
1990
+ clear.setAttribute("hidden", "hidden");
1991
+ root.classList.remove("kgrid-date-range-has-value");
1992
+ }
1993
+ }
1969
1994
  };
1970
1995
 
1971
1996
  /** Fill empty date-range hiddens from `{ from, to }`. Does not replace a value already set. */
@@ -2020,6 +2045,26 @@
2020
2045
  };
2021
2046
  })();
2022
2047
 
2048
+ /** Closed field shows `DD.MM.YYYY`. One side omitted stays blank around the dash. */
2049
+ function formatDateRangeDisplay(from, to) {
2050
+ function day(iso) {
2051
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso || "");
2052
+ return match ? match[3] + "." + match[2] + "." + match[1] : "";
2053
+ }
2054
+ const start = day(from);
2055
+ const end = day(to);
2056
+ if (start && end) {
2057
+ return start + " – " + end;
2058
+ }
2059
+ if (start) {
2060
+ return start + " –";
2061
+ }
2062
+ if (end) {
2063
+ return "– " + end;
2064
+ }
2065
+ return "";
2066
+ }
2067
+
2023
2068
  function dateRangeLabel(config, key, fallback) {
2024
2069
  const value = config && config[key];
2025
2070
  return value != null && value !== "" ? String(value) : fallback;
@@ -2028,29 +2073,53 @@
2028
2073
  function buildDateRangeUi($from, config) {
2029
2074
  const $to = $from.data("kgridDateRangeTo");
2030
2075
  const rootId = "kgrid_dr_" + CT.uuid();
2076
+ const fromLabel = dateRangeLabel(config, "fromLabel", "From");
2077
+ const toLabel = dateRangeLabel(config, "toLabel", "To");
2078
+ const placeholder =
2079
+ config && config.placeholder != null && config.placeholder !== ""
2080
+ ? String(config.placeholder)
2081
+ : fromLabel + " – " + toLabel;
2031
2082
  const $root = $("<div>", { class: "kgrid-date-range", id: rootId });
2083
+ const panelId = rootId + "_panel";
2084
+ const $display = $(
2085
+ "<input type='text' readonly autocomplete='off' class='form-control form-control-sm kgrid-date-range-display'/>"
2086
+ )
2087
+ .attr("placeholder", placeholder)
2088
+ .attr("role", "button")
2089
+ .attr("aria-haspopup", "dialog")
2090
+ .attr("aria-expanded", "false")
2091
+ .attr("aria-controls", panelId);
2092
+ const $clear = $("<button>", {
2093
+ type: "button",
2094
+ class: "kgrid-date-range-clear",
2095
+ hidden: "hidden",
2096
+ "aria-label": "Clear",
2097
+ text: "×",
2098
+ });
2032
2099
  const $fromVisible = $(
2033
2100
  "<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-from'/>"
2034
2101
  );
2035
2102
  const $toVisible = $(
2036
2103
  "<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-to'/>"
2037
2104
  );
2038
- $root.append(
2105
+ const $panel = $("<div>", {
2106
+ class: "kgrid-date-range-panel",
2107
+ id: panelId,
2108
+ hidden: "hidden",
2109
+ role: "dialog",
2110
+ "aria-label": placeholder,
2111
+ });
2112
+ $panel.append(
2039
2113
  $("<label>", { class: "kgrid-date-range-bound" }).append(
2040
- $("<span>", {
2041
- class: "kgrid-date-range-label",
2042
- text: dateRangeLabel(config, "fromLabel", "From"),
2043
- }),
2114
+ $("<span>", { class: "kgrid-date-range-label", text: fromLabel }),
2044
2115
  $fromVisible
2045
2116
  ),
2046
2117
  $("<label>", { class: "kgrid-date-range-bound" }).append(
2047
- $("<span>", {
2048
- class: "kgrid-date-range-label",
2049
- text: dateRangeLabel(config, "toLabel", "To"),
2050
- }),
2118
+ $("<span>", { class: "kgrid-date-range-label", text: toLabel }),
2051
2119
  $toVisible
2052
2120
  )
2053
2121
  );
2122
+ $root.append($display, $clear, $panel);
2054
2123
  $from.before($root);
2055
2124
  $from.attr("data-kgrid-date-range", rootId);
2056
2125
  $to.attr("data-kgrid-date-range", rootId);
@@ -2074,12 +2143,91 @@
2074
2143
  }
2075
2144
  }
2076
2145
 
2146
+ function setOpen(open) {
2147
+ if (open) {
2148
+ $panel.appendTo(document.body);
2149
+ $panel.addClass("kgrid-date-range-panel-floating");
2150
+ $panel.removeAttr("hidden");
2151
+ $root.addClass("kgrid-date-range-open");
2152
+ $display.attr("aria-expanded", "true");
2153
+ positionPanel();
2154
+ } else {
2155
+ $panel.attr("hidden", "hidden");
2156
+ $root.removeClass("kgrid-date-range-open");
2157
+ $display.attr("aria-expanded", "false");
2158
+ $panel.css({ position: "", top: "", left: "", width: "", zIndex: "" });
2159
+ $panel.removeClass("kgrid-date-range-panel-floating");
2160
+ $panel.insertAfter($clear);
2161
+ }
2162
+ }
2163
+
2164
+ function positionPanel() {
2165
+ const rect = $display[0].getBoundingClientRect();
2166
+ const width = Math.min(Math.max(rect.width, 20 * 16), window.innerWidth - 16);
2167
+ let left = rect.left;
2168
+ const maxLeft = window.innerWidth - width - 8;
2169
+ if (left > maxLeft) {
2170
+ left = Math.max(8, maxLeft);
2171
+ }
2172
+ $panel.css({
2173
+ position: "fixed",
2174
+ top: rect.bottom + 2 + "px",
2175
+ left: left + "px",
2176
+ width: width + "px",
2177
+ zIndex: 1080,
2178
+ });
2179
+ const height = $panel[0].offsetHeight;
2180
+ let top = rect.bottom + 2;
2181
+ if (top + height > window.innerHeight - 8 && rect.top > height + 8) {
2182
+ top = rect.top - height - 2;
2183
+ }
2184
+ $panel.css("top", top + "px");
2185
+ }
2186
+
2077
2187
  $fromVisible.add($toVisible).on("change", function () {
2078
2188
  writePair($fromVisible.val() || "", $toVisible.val() || "", false);
2079
2189
  $from.trigger("change");
2080
2190
  });
2081
2191
 
2192
+ $display.on("click", function (e) {
2193
+ e.preventDefault();
2194
+ setOpen(!$root.hasClass("kgrid-date-range-open"));
2195
+ });
2196
+ $display.on("keydown", function (e) {
2197
+ if (e.key === "Enter" || e.key === " ") {
2198
+ e.preventDefault();
2199
+ setOpen(!$root.hasClass("kgrid-date-range-open"));
2200
+ }
2201
+ });
2202
+ $clear.on("click", function (e) {
2203
+ e.preventDefault();
2204
+ e.stopPropagation();
2205
+ writePair("", "", false);
2206
+ $from.trigger("change");
2207
+ setOpen(false);
2208
+ });
2209
+
2082
2210
  const ns = ".kgridDateRange_" + CT.uuid();
2211
+ $(document).on("mousedown" + ns, function (e) {
2212
+ if (!$root.hasClass("kgrid-date-range-open")) {
2213
+ return;
2214
+ }
2215
+ if ($(e.target).closest($root).length || $(e.target).closest($panel).length) {
2216
+ return;
2217
+ }
2218
+ setOpen(false);
2219
+ });
2220
+ $(document).on("keydown" + ns, function (e) {
2221
+ if (e.key === "Escape" && $root.hasClass("kgrid-date-range-open")) {
2222
+ setOpen(false);
2223
+ }
2224
+ });
2225
+ $(window).on("resize" + ns + " scroll" + ns, function () {
2226
+ if ($root.hasClass("kgrid-date-range-open")) {
2227
+ positionPanel();
2228
+ }
2229
+ });
2230
+
2083
2231
  const formBind = function () {
2084
2232
  const formEl = $from.prop("form") || ($from[0] && $from[0].form);
2085
2233
  if (!formEl) {
package/dist/kgrid.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-10-28T14:23:09.350Z */
2
- !function(t){function e(t){const e={},n=t&&t.elements;if(!n)return e;for(let t=0;t<n.length;t++){const o=n[t],r=o.name;if(!r||o.disabled)continue;const i=o.type;if("submit"===i||"button"===i||"reset"===i||"file"===i)continue;if("checkbox"===i){e[r]=o.checked?"1":"0";continue}if("radio"===i){if(!o.checked)continue;e[r]=o.value;continue}if("SELECT"===o.tagName&&o.multiple){e[r]=Array.from(o.selectedOptions).map(function(t){return t.value});continue}const a=o.value;Object.prototype.hasOwnProperty.call(e,r)?(Array.isArray(e[r])||(e[r]=[e[r]]),e[r].push(a)):e[r]=a}return e}t.isFlagOn=function(t){return!0===t||1===t||"1"===t},t.serializeFormDefault=e;const n={log:function(){},onError:function(t){console.error(t)},confirm:function(t,e,n){"undefined"!=typeof window&&window.confirm(t)?e():n&&n()},deleteConfirm:null,serializeForm:e,customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300,preferencesStorage:null};t._config=Object.assign({},n),t.configure=function(e){return e&&"object"==typeof e&&Object.assign(t._config,e),"function"==typeof t._syncCustomInputTypes&&t._syncCustomInputTypes(),t},t.log=function(){t._config.log.apply(null,arguments)},t.onError=function(e){return t._config.onError(e)},t.confirm=function(e,n,o){return t._config.confirm(e,n,o)},t.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",t._defaultDeleteConfirm=function(e,n,o){t.confirm(t.DEFAULT_DELETE_CONFIRM_MESSAGE,n,o)},t.runDeleteConfirm=function(e,n,o){const r=e.options&&"function"==typeof e.options.deleteConfirm?e.options.deleteConfirm:null,i="function"==typeof t._config.deleteConfirm?t._config.deleteConfirm:null;return(r||i||t._defaultDeleteConfirm)(e,n,o)},t.serializeForm=function(e,n){return t._config.serializeForm(e,n)},t.getKViews=function(e){const n=[e,t._config.kviews];for(let t=0;t<n.length;t++){const e=n[t];if(e&&"function"==typeof e.createCollectionInstance)return e}const o=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return o&&"function"==typeof o.createCollectionInstance?o:null},t.KVIEWS_MISSING_MSG="KGrid requires KViews: install peer @logimaxx/kviews, load it before kgrid.js (window.KViews), or call KGrid.configure({ kviews: KViews }). You can also pass kviews in table options: KGrid.init(host, { kviews, ... })."}(window.KGrid=window.KGrid||{}),function(t){t.protoOptions={url:null,type:null,filter:null,features:{filtering:!1,sorting:!1,paging:!1,create:!1,update:!1,delete:!1,clone:!1,columnChooser:!1},rowActions:null,storageKey:null,filterStorageScope:null,columnChooserLabel:"Columns",columnChooserResetLabel:"Reset columns",defaultInteraction:"view",insertFormRow:{position:"top"},onDuplicate:null,tableAttrs:{class:""},labelsRowAttrs:{},dataRowAttrs:{},filtersRowAttrs:null,pagingPageSizes:[10,25,50,75],pagingDefaultSize:10,emptyRowMessage:null,pagingFooterLabel:"records per page. Total"},t.protoColumnConfig={label:null,name:null,hidden:!1,locked:!1,defaultHidden:!1,userHidden:!1,class:null,columnClass:null,attrs:{},features:{create:!1,update:!1,filter:!1,sort:!1},display:{template:null,events:[]},input:null,insert:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,events:[]},update:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,template:null,events:[]},filter:{type:"text",operator:"~=~",default:null,placeholder:"",options:null,persist:!1,debounceMs:null}},t.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],t.VALID_INPUT_TYPES=t.VALID_NATIVE_INPUT_TYPES.slice(),t.VALID_NATIVE_FILTER_TYPES=t.VALID_NATIVE_INPUT_TYPES.filter(t=>"displayonly"!==t),t.VALID_FILTER_TYPES=t.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),t.isValidInputType=function(e){return t.VALID_NATIVE_INPUT_TYPES.includes(e)||t.isPluggableFieldType(e)},t.isValidFilterType=function(e){return"displayonly"!==e&&(t.VALID_NATIVE_FILTER_TYPES.includes(e)||t.isPluggableFieldType(e))}}(window.KGrid=window.KGrid||{}),function(t){t.isPlainObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.setDefaultValues=function(e,n){const o={...e||{}};return Object.keys(n||{}).forEach(e=>{t.isPlainObject(n[e])&&t.isPlainObject(o[e])?o[e]=t.setDefaultValues(o[e],n[e]):t.isPlainObject(n[e])&&null==o[e]?o[e]=t.setDefaultValues({},n[e]):o[e]=n[e]}),o},t.normalizeColumnConfig=function(e){let n=e&&"object"==typeof e?{...e}:{};if(t.isPlainObject(n.input)){const e={...n.input};delete n.input,n.insert=t.setDefaultValues(e,n.insert||{}),n.update=t.setDefaultValues(e,n.update||{})}const o=t.setDefaultValues(t.protoColumnConfig,n);return null==o.class&&o.columnClass&&(o.class=o.columnClass),o.update&&"displayonly"===o.update.type&&!o.update.template&&o.display&&o.display.template&&(o.update.template=o.display.template),["display","insert","update"].forEach(t=>{o[t]&&"object"==typeof o[t]&&(Array.isArray(o[t].events)||(o[t].events=[]))}),o};const e=["error","ignore","update"],n=["set","add","sub"];function o(t,e){const o=String(t||"").trim(),r=null==e||""===e?"set":String(e).trim();if(!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$/.test(o))throw new Error("Invalid onDuplicate field: "+t);if(-1===n.indexOf(r))throw new Error("Invalid onDuplicate operator '"+r+"' on field '"+o+"'");return{name:o,op:r}}function r(t){const e=String(t||"").trim(),n=e.lastIndexOf(":");return-1===n?o(e,"set"):o(e.slice(0,n),e.slice(n+1))}t.onDuplicateParams=function(n){if(null==n||!1===n)return null;let i,a;if("string"==typeof n)i=n.trim();else{if(!t.isPlainObject(n))throw new Error("onDuplicate must be a string or an object");i=String(n.action||n.onduplicate||"").trim(),a=null!=n.fields?n.fields:n.update}if(-1===e.indexOf(i))throw new Error("Invalid onDuplicate action: "+i);const l={onduplicate:i};if("update"!==i)return l;const s=[],u={},c=function(t){if(u[t.name])throw new Error("onDuplicate field '"+t.name+"' is listed more than once");u[t.name]=!0,s.push("set"===t.op?t.name:t.name+":"+t.op)};if("string"==typeof a)a.split(",").forEach(function(t){t.trim()&&c(r(t))});else if(Array.isArray(a))a.forEach(function(t){c(r(t))});else if(t.isPlainObject(a))Object.keys(a).forEach(function(t){c(o(t,a[t]))});else if(null!=a)throw new Error("onDuplicate fields must be an object, array, or string");if(!s.length)throw new Error("onDuplicate action 'update' requires fields");return l.update=s.join(","),l},t.applyOnDuplicateToUrl=function(e,n){const o=t.onDuplicateParams(n);if(!o||!e)return e;const r=e.indexOf("#"),i=r>=0?e.slice(r):"",a=r>=0?e.slice(0,r):e,l=a.indexOf("?"),s=l>=0?a.slice(0,l):a,u=[];return l>=0&&a.slice(l+1).split("&").forEach(function(t){if(!t)return;const e=t.indexOf("="),n=decodeURIComponent(e>=0?t.slice(0,e):t);"onduplicate"!==n&&"update"!==n&&u.push(t)}),Object.keys(o).forEach(function(t){u.push(encodeURIComponent(t)+"="+encodeURIComponent(o[t]))}),s+(u.length?"?"+u.join("&"):"")+i}}(window.KGrid),function(t){t.resolveHostElement=function(t){if(null==t)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof t&&t.jquery){if(!t.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return t}if("object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName)return $(t);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},t.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},t.columnWidthCss=function(t){if(!t||!t.attrs)return null;const e=t.attrs.width;return null==e||""===e?null:"number"==typeof e||/^\d+(\.\d+)?$/.test(String(e))?String(e)+"px":String(e)},t.applyColumnDomAttrs=function(t,e){const n=e&&e.attrs&&"object"==typeof e.attrs?e.attrs:null;return n?(Object.keys(n).forEach(function(e){"width"!==e&&t.attr(e,n[e])}),t):t},t.layoutVisibleColumns=function(t){return(t||[]).filter(function(t){return t&&t.name&&!t.hidden&&!t.userHidden})},t.participatingColumnCount=function(e,n){return t.layoutVisibleColumns(e).length+(n?1:0)},t.syncActionColumnColgroup=function(e,n,o,r,i){let a=e.children("colgroup.kgrid-colgroup");a.length||(a=$("<colgroup>").addClass("kgrid-colgroup").prependTo(e)),a.empty();const l=Array.isArray(i)?i:null;let s=0;if(l&&l.length)l.forEach(function(e){if(e&&e.userHidden)return;const n=$("<col>");e&&e.name&&n.attr("data-name",e.name);const o=t.columnWidthCss(e);o&&n.css("width",o),a.append(n),s+=1});else for(let t=0;t<n;t++)a.append($("<col>")),s+=1;return o&&a.append($("<col>").addClass("kgrid-row-actions-col").css("width",t.actionColumnWidth(r))),s},t.syncSpanningCells=function(t,e){t&&t.length&&e&&t.find(".paging-footer td, .no-data-tbody td").attr("colspan",e)},t.anchorRowForm=function(t,e){if(!(t&&t.length&&e&&e.length))return t;t.attr("hidden","hidden").attr("aria-hidden","true");const n=e.children("td").first();return n.length&&t.prependTo(n),t},t.filterFormField=function(e,n){const o=t.filterFormFields(e,n);return o.length?o.eq(0):$()},t.filterFormFields=function(t,e){if(!t||!e)return $();const n=[],o=t.elements;if(o)for(let t=0;t<o.length;t++)o[t]&&o[t].name===e&&n.push(o[t]);if(!n.length&&t.id){const o=document.querySelectorAll('[form="'+t.id+'"][name="'+e+'"]');for(let t=0;t<o.length;t++)n.push(o[t])}return $(n)},t.columnClassName=function(t){if(!t)return null;const e=null!=t.class&&""!==t.class?t.class:t.columnClass;return null!=e&&""!==e?String(e):null},t.applyColumnCellMeta=function(e,n){if(!e||!e.length||!n)return e;n.name&&e.attr("data-name",n.name);const o=t.columnClassName(n);return o&&e.addClass(o),e.toggleClass("kgrid-user-hidden",!!n.userHidden),e}}(window.KGrid),function(t){function e(t){"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t)}function n(t){return t?"<i class='"+t+"'></i>":""}function o(t,e,o){const r=$("<button>").addClass(e.btnClass||"btn btn-sm btn-outline-secondary").attr("type","save"===e.action?"submit":"button").attr("title",e.title||e.label||"");return e.class&&r.addClass(e.class),"save"!==e.action&&"cancel"!==e.action||(r.attr("name","save"===e.action?"save":"cancel"),o&&r.attr("form",o)),"cancel"===e.action&&r.attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()"),e.id&&r.attr("data-kgrid-action",e.id),e.action&&r.attr("data-kgrid-builtin",e.action),e.icon?(r.html(n(e.icon)),e.showLabel&&e.label&&r.append(document.createTextNode(" "+e.label))):e.label&&r.text(e.label),r.appendTo(t),r}function r(t,e,n){const o=n.indexOf(e);o<0||(t.attr("data-kgrid-action-index",String(o)),null!=e.visible&&t.addClass("kgrid-action-conditional kgrid-action-off"))}t.BUILTIN_ROW_ACTIONS={clone:{action:"clone",icon:"fa-regular fa-copy",label:"Clone",title:"Clone item",when:"idle",btnClass:"btn btn-sm btn-outline-secondary clone-item",groupClass:"clone-item-grp"},delete:{action:"delete",icon:"fas fa-trash",label:"Delete",title:"Delete item",when:"idle",btnClass:"btn btn-sm btn-danger delete-item",groupClass:"delete-item-grp"},save:{action:"save",icon:"fas fa-save",label:"Save",title:"Save item",when:"editing",btnClass:"btn btn-sm btn-success save-item",groupClass:"edit-item-grp"},cancel:{action:"cancel",icon:"fas fa-undo",label:"Cancel",title:"Cancel edit",when:"editing",btnClass:"btn btn-sm btn-secondary cancel-edit",groupClass:"edit-item-grp"}},t.normalizeRowActionItem=function(n,o,r){if(!n||"object"!=typeof n)return null;const i=n.action;if("save"===i||"cancel"===i)return e("KGrid: rowActions items should not list '"+i+"' — it is added automatically when features.update is true"),null;let a={};if(i&&t.BUILTIN_ROW_ACTIONS[i])a={...t.BUILTIN_ROW_ACTIONS[i]};else{if(!n.id)return e("KGrid: custom rowAction requires id: "+JSON.stringify(n)),null;a={id:n.id,when:"idle",btnClass:"btn btn-sm btn-outline-secondary",groupClass:"kgrid-custom-action-grp"}}const l={...a,...n};if(i&&t.BUILTIN_ROW_ACTIONS[i]&&(l.action=i),l.when||(l.when=l.action&&a.when||"idle"),!l.title&&l.label&&(l.title=l.label),!l.label&&l.title&&(l.label=l.title),"string"==typeof l.callback){const t=function(t,e,n){if(!t||"string"!=typeof t)return null;const o=e&&e[t]||n.functions&&n.functions[t];return"function"==typeof o?o:null}(l.callback,o,r);if(!t)throw new Error("rowAction callback "+l.callback+" not found or is not a function");l.callback=t}if(l.id&&"function"!=typeof l.callback&&!l.action)throw new Error("Custom rowAction '"+l.id+"' requires a callback");return l},t.rowActionVisible=function(t,e){if(null==e)return!0;if("function"==typeof e)return!!e(t);if(!e||"object"!=typeof e||Array.isArray(e))return!0;const n=t&&t.attributes||{};return Object.keys(e).every(function(t){const o=e[t],r=n[t];return Array.isArray(o)?o.some(function(t){return String(r??"")===String(t)}):String(r??"")===String(o)})},t.resolveRowActions=function(n,o){if(n&&n._resolvedRowActions&&arguments.length<2)return n._resolvedRowActions;const r=n&&n.features||{};let i="buttons",a=[];if(n&&null!=n.rowActions){const o=n.rowActions;Array.isArray(o)?a=o:t.isPlainObject(o)&&(i="dropdown"===o.display?"dropdown":"buttons",a=Array.isArray(o.items)?o.items:[]),(r.delete||r.clone)&&e("KGrid: features.delete / features.clone are ignored when rowActions is set")}else r.clone&&a.push({action:"clone"}),r.delete&&a.push({action:"delete"});const l=[];a.forEach(function(e){const r=t.normalizeRowActionItem(e,o,n||{});r&&l.push(r)});const s=[];r.update&&(s.push({...t.BUILTIN_ROW_ACTIONS.save}),s.push({...t.BUILTIN_ROW_ACTIONS.cancel}));const u={display:i,menuItems:l,editingItems:s};return n&&(n._resolvedRowActions=u),u},t.hasActionColumn=function(e){const n=e&&e.features;if(n&&(n.create||n.columnChooser))return!0;const o=t.resolveRowActions(e);return o.menuItems.length>0||o.editingItems.length>0},t.actionColumnWidth=function(e){const n=t.resolveRowActions(e),o=e&&e.features||{},r=n.editingItems.length,i=o.create?1:0;let a;a="dropdown"===n.display&&n.menuItems.length>0?1:n.menuItems.filter(function(t){return"editing"!==t.when}).length;return(2.5*Math.max(a,r,i,1)+.75).toFixed(2)+"rem"},t.closeRowActionDropdowns=function(t){$(".kgrid-row-actions-menu").each(function(){const e=$(this),n=e.children(".dropdown-menu");t&&n[0]===t[0]||(n.removeClass("show").css({top:"",left:"",right:"",position:""}),e.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded","false").removeClass("show"))})},t.mountRowActionDropdowns=function(e){e&&e.length&&(t._rowActionsDropdownDocBound||(t._rowActionsDropdownDocBound=!0,$(document).on("click.kgridRowActions",function(){t.closeRowActionDropdowns()}).on("keydown.kgridRowActions",function(e){"Escape"===e.key&&t.closeRowActionDropdowns()})),e.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function(){const e=this,n=$(e),o=n.parent(".kgrid-row-actions-menu").children(".dropdown-menu");n.off("click.kgridRowActions").on("click.kgridRowActions",function(r){r.preventDefault(),r.stopPropagation();const i=!o.hasClass("show");if(t.closeRowActionDropdowns(),!i)return;const a=e.getBoundingClientRect();o.addClass("show").css({position:"fixed",top:Math.round(a.bottom+2)+"px",left:"auto",right:Math.round(window.innerWidth-a.right)+"px",zIndex:1055}),n.addClass("show").attr("aria-expanded","true")}),o.off("click.kgridRowActions").on("click.kgridRowActions",function(t){t.stopPropagation()}),o.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose",function(){setTimeout(function(){t.closeRowActionDropdowns()},0)})}))},t.applyRowActionVisibility=function(e,n,o){e&&e.length&&o&&o.forEach(function(o,r){if(!o||null==o.visible)return;const i=t.rowActionVisible(n,o.visible);e.find('[data-kgrid-action-index="'+r+'"]').toggleClass("kgrid-action-off",!i)})},t.escapeHtml=t.escapeHtml||function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t.renderRowActions=function(e,i,a){const l=t.resolveRowActions(i),s=l.menuItems.filter(function(t){return"editing"!==t.when}),u=l.menuItems.filter(function(t){return"editing"===t.when});if("dropdown"===l.display&&s.length>0){const o=$("<div>").addClass("btn-group kgrid-row-actions-menu").appendTo(e);$("<button>").addClass("btn btn-sm btn-outline-secondary dropdown-toggle kgrid-actions-dropdown-toggle").attr({type:"button","aria-expanded":"false",title:"Actions"}).html("<i class='fas fa-ellipsis-v'></i>").appendTo(o);const i=$("<ul>").addClass("dropdown-menu dropdown-menu-end").appendTo(o);s.forEach(function(e){const o=$("<li>").appendTo(i);r(o,e,l.menuItems);const a=$("<button>").addClass("dropdown-item").attr("type","button").appendTo(o);"clone"===e.action?a.addClass("clone-item"):"delete"===e.action&&a.addClass("delete-item text-danger"),e.id&&a.attr("data-kgrid-action",e.id),e.action&&a.attr("data-kgrid-builtin",e.action),e.class&&a.addClass(e.class),e.btnClass&&!e.action&&/\bbtn-danger\b|\btext-danger\b|\boutline-danger\b/.test(e.btnClass)&&a.addClass("text-danger");const s=e.label||e.title||e.action||e.id;e.icon?a.html(n(e.icon)+" "+t.escapeHtml(s)):a.text(s)})}else s.forEach(function(t){const n=$("<span>").addClass(t.groupClass||"btn-group kgrid-custom-action-grp").appendTo(e);"always"===t.when&&n.addClass("kgrid-action-always"),r(n,t,l.menuItems),o(n,t,a)});const c=l.editingItems.concat(u);if(c.length){const t=$("<span>").addClass("btn-group edit-item-grp").appendTo(e);c.forEach(function(e){o(t,e,a)})}}}(window.KGrid),function(t){t.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",t.TABLE_SHELL_TEMPLATE='\n<table class="custom-table" style="table-layout: fixed;">\n <thead class="thead-labels">\n <tr>\n <th class="align-top">\n <a class="sort" data-sortfld="" style="cursor: pointer;">\n <span class="column-label"></span>\n <i class="fas fa-sort-up sort-up" style="display: none"></i>\n <i class="fas fa-sort-down sort-down" style="display: none"></i>\n <i class="fas fa-sort sort-default"></i>\n </a>\n </th>\n </tr>\n </thead>\n <thead class="thead-filters"></thead>\n <tbody class="before-main-tbody"></tbody>\n <tbody class="main-tbody"></tbody>\n <tbody class="after-main-tbody"></tbody>\n <tbody class="no-data-tbody">\n <tr><td>{{EMPTY_ROW_MESSAGE}}</td></tr>\n </tbody>\n <tfoot class="paging-footer">\n <tr>\n <td>\n <div class="btn-group pages" data-pagesize="{{PAGES_DATA_PAGESIZE}}">\n <button type="button" name="first" class="btn btn-sm btn-outline-secondary">&lt;&lt;</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary">&lt;</button>\n <button type="button" name="page" class="btn btn-sm btn-outline-secondary">1</button>\n <button type="button" name="next" class="btn btn-sm btn-outline-secondary">&gt;</button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">&gt;&gt;</button>\n </div>\n <select class="pagesize">\n{{PAGE_SIZE_OPTIONS}}\n </select>\n {{PAGING_FOOTER_LABEL}} <span class="totalrecscount"></span>\n </td>\n </tr>\n </tfoot>\n</table>'.trim(),t._escapeTableShellText=function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t._renderPageSizeOptions=function(t,e){return t.map(t=>{const n=String(t);return` <option value="${n}"${n===String(e)?" selected":""}>${n}</option>`}).join("\n")},t.renderTableShellHtml=function(e,n){const o=Array.isArray(e.pagingPageSizes)?e.pagingPageSizes:[10,25,50,75],r=null!=e.pagingDefaultSize?e.pagingDefaultSize:o[0],i=t._escapeTableShellText(e.emptyRowMessage||t.DEFAULT_EMPTY_ROW_MESSAGE),a=t._escapeTableShellText(e.pagingFooterLabel||"records per page. Total");return(n||t.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,i).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(r)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,t._renderPageSizeOptions(o,r)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,a)},t.createTableShell=function(e){const n=t.renderTableShellHtml(e),o=$.parseHTML(n,document,!0),r=$(o).filter("table").first();if(!r.length)throw new Error("KGrid TABLE_SHELL_TEMPLATE must contain a root <table> element");return e.tableAttrs&&t.isPlainObject(e.tableAttrs)&&(Object.keys(e.tableAttrs).forEach(t=>{"class"!==t&&r.attr(t,e.tableAttrs[t])}),"string"==typeof e.tableAttrs.class&&e.tableAttrs.class&&r.addClass(e.tableAttrs.class)),r},t.mountTableShell=function(e,n){const o=e.find("table.custom-table, table").first();if(o.length)return o;const r=t.getTableInteractionHost(e);r.hasClass("custom-table-shell")||r.addClass("custom-table-shell");const i=t.createTableShell(n);return r.append(i),i}}(window.KGrid),function(t){t._fieldTypes=Object.create(null),t._configuredCustomInputTypeNames=[],t.registerFieldType=function(e,n,o){if(!e||"string"!=typeof e)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+e+"): plugin.create is required");if(t._fieldTypes[e]&&(!o||!o.overwrite))throw new Error("Field type already registered: "+e);return t._fieldTypes[e]=Object.assign({name:e},n),t},t.unregisterFieldType=function(e){return e&&t._fieldTypes[e]&&delete t._fieldTypes[e],t},t.getFieldType=function(e){return e&&t._fieldTypes[e]||null},t.listFieldTypes=function(){return Object.keys(t._fieldTypes)},t.createFieldInput=function({mode:e,col:n,config:o}){const r=o.type??"text",i=t.getFieldType(r);if(!i)return null;"function"==typeof i.validate&&i.validate(o,e,n);const a=i.create({mode:e,col:n,config:o});if(!a||!a.$input||!a.$input.length)throw new Error('Field type "'+r+'" create() must return { $input: jQuery }');return a.$input.attr("data-type",r),a},t.mountField=function(e){const n=e.config?.type??e.type,o=t.getFieldType(n);o&&"function"==typeof o.mount&&o.mount(e)},t.resolveFilterEvents=function({plugin:t,$input:e,createResult:n}){let o;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?o=n.filterEvents:t&&Object.prototype.hasOwnProperty.call(t,"filterEvents")&&(o=t.filterEvents),!1===o||null===o?null:"string"==typeof o&&o.trim()?o.trim():e.is("select")?"change":"input"},t.normalizeFilterDebounceMs=function(t,e){if(!1===t)return 0;if(void 0===t)return e;if(null===t)return e;const n=Number(t);return!Number.isFinite(n)||n<0?0:n},t.resolveFilterDebounceMs=function({filterConfig:e,plugin:n}){return e&&Object.prototype.hasOwnProperty.call(e,"debounceMs")&&null!==e.debounceMs?t.normalizeFilterDebounceMs(e.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?t.normalizeFilterDebounceMs(n.filterDebounceMs,0):t.normalizeFilterDebounceMs(t._config.filterDebounceMs,0)},t.shouldDebounceFilterSubmit=function(t,e){return!(!e||e<=0)&&!!t},t.bindFieldFilterSubmit=function(e,n,o){const r=t.getFieldType(e);r&&"function"==typeof r.bindFilterSubmit&&r.bindFilterSubmit(n,o)},t.bindFilterInputEvents=function({type:e,$input:n,onSubmit:o,createResult:r,filterConfig:i}){const a=e?t.getFieldType(e):null,l=t.resolveFilterEvents({plugin:a,$input:n,createResult:r}),s=t.resolveFilterDebounceMs({filterConfig:i,plugin:a}),u=t.wrapFilterSubmitHandler(n,o,l,s);l&&n.on(l,u),t.bindFieldFilterSubmit(e,n,u)},t.isPluggableFieldType=function(e){return!!t.getFieldType(e)},t.inputType=function(t,e){if("function"!=typeof t)throw new TypeError("inputType(mount, opts): mount must be a function");if(!e||"string"!=typeof e.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:e.filterEvents,filterDebounceMs:e.filterDebounceMs,validate:e.validate,create({mode:t}){const n=$(e.element);return!e.formInputClass||"insert"!==t&&"update"!==t||n.addClass(e.formInputClass),{$input:n,skipValueAttr:!!e.skipValueAttr}},mount(e){t(e.$input,e.config?.options??e.config,e)},bindFilterSubmit:e.bindFilterSubmit}},t._getCustomInputTypesConfig=function(){return t._config.customInputTypes??t._config.fieldTypes??null},t._syncCustomInputTypes=function(){const e=t._getCustomInputTypesConfig(),n=e&&"object"==typeof e?Object.keys(e).filter(t=>null!=e[t]):[];t._configuredCustomInputTypeNames.forEach(e=>{n.includes(e)||t.unregisterFieldType(e)}),n.forEach(n=>{const o=e[n];if(!o||"object"!=typeof o||"function"!=typeof o.create){if("function"==typeof o)throw new Error("customInputTypes."+n+' is a function — use a plugin, e.g. KGrid.select2(fn) or KGrid.inputType(fn, { element: "..." })');throw new TypeError("customInputTypes."+n+" must be a plugin with create()")}t.registerFieldType(n,o,{overwrite:!0})}),t._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(t){const e="kgrid-multi-select-value",n=";";function o(t,e,n){if(!t.length)return n;if(1===t.length){const n=e.find(function(e){return e.value===t[0]});return n?n.label:t[0]}return t.length+" selected"}function r(r,i,a){const l=i.separator||n,s=i.options||[],u=function(t){return null!=t.placeholder&&""!==t.placeholder?String(t.placeholder):"All"}(i),c="filter"===a;r.data("kgridMultiSep",l),r.addClass(e);const d=$("<div>").addClass("kgrid-multi-select").attr("data-mode",a),f=$("<div>").addClass("kgrid-multi-select-panel");let p=null;function m(){const e=t.parseMultiSelectValue(r[0].value,l);f.find("input[type='checkbox']").each(function(){this.checked=-1!==e.indexOf(this.value)}),p&&p.text(o(e,s,u))}function g(t){p&&(t?(f.appendTo(document.body),f.addClass("kgrid-multi-select-panel-floating"),f.removeAttr("hidden"),d.addClass("kgrid-multi-select-open"),p.attr("aria-expanded","true"),h()):(f.attr("hidden","hidden"),d.removeClass("kgrid-multi-select-open"),p.attr("aria-expanded","false"),f.css({position:"",top:"",left:"",width:"",minWidth:"",maxWidth:"",zIndex:""}),f.removeClass("kgrid-multi-select-panel-floating"),f.insertAfter(p)))}function h(){if(!p)return;const t=p[0].getBoundingClientRect(),e=Math.max(t.width,192);let n=t.left;const o=window.innerWidth-e-8;n>o&&(n=Math.max(8,o));let r=t.bottom+2;const i=Math.min(224,28*s.length+16);r+i>window.innerHeight-8&&t.top>i+8&&(r=t.top-i-2),f.css({position:"fixed",top:r+"px",left:n+"px",width:e+"px",minWidth:e+"px",maxWidth:"min(18rem, calc(100vw - 16px))",zIndex:1080})}c?(p=$("<button>").attr({type:"button","aria-expanded":"false"}).addClass("kgrid-multi-select-toggle form-select form-select-sm"),f.attr("hidden","hidden"),d.append(p,f)):(d.addClass("kgrid-multi-select-open"),d.append(f)),s.forEach(function(e,n){const o="kgrid_ms_"+t.uuid()+"_"+n,r=$("<label>").addClass("kgrid-multi-select-option").attr("for",o);$("<input>").attr({type:"checkbox",id:o,value:e.value,class:"kgrid-multi-select-check"}).appendTo(r),$("<span>").addClass("kgrid-multi-select-label").text(e.label).appendTo(r),f.append(r)}),r.before(d),d.append(r);const y=".kgridMultiSelect_"+t.uuid();f.on("change","input[type='checkbox']",function(){!function(t){const e=[];f.find("input[type='checkbox']:checked").each(function(){e.push(this.value)});const n=e.join(l);r[0].value!==n&&(r[0].value=n,t&&r.trigger("change")),p&&p.text(o(e,s,u))}(!0)}),r.on("kgrid:multiselect:set",function(){m()}),p&&(p.on("click",function(t){t.preventDefault(),t.stopPropagation(),g(!d.hasClass("kgrid-multi-select-open"))}),$(document).on("mousedown"+y,function(t){d.hasClass("kgrid-multi-select-open")&&($(t.target).closest(d).length||$(t.target).closest(f).length||g(!1))}),$(window).on("resize"+y+" scroll"+y,function(){d.hasClass("kgrid-multi-select-open")&&h()}));const b=function(){const t=r.prop("form")||r[0]&&r[0].form;t&&$(t).off("reset"+y).on("reset"+y,function(){setTimeout(m,0)})};return b(),setTimeout(b,0),m(),d}t.normalizeMultiSelectValue=function(t,e){const o=e||n;return null==t||""===t?"":Array.isArray(t)?t.filter(function(t){return null!=t&&""!==t}).map(String).join(o):String(t)},t.parseMultiSelectValue=function(e,o){const r=t.normalizeMultiSelectValue(e,o);return r?r.split(o||n).filter(Boolean):[]},function(){const o=$.valHooks.hidden||{};$.valHooks.hidden={get:function(t){return t&&t.classList&&t.classList.contains(e)?t.value:o.get?o.get(t):void 0},set:function(r,i){if(r&&r.classList&&r.classList.contains(e)){const e=$(r).data("kgridMultiSep")||n;return r.value=t.normalizeMultiSelectValue(i,e),$(r).triggerHandler("kgrid:multiselect:set"),!0}return o.set?o.set(r,i):void 0}}}(),t.registerFieldType("multi_select",{filterEvents:"change",filterDebounceMs:0,validate(t,e){!function(t,e){if(!Array.isArray(t.options))throw new Error("multi_select requires an options array ("+e+"): "+JSON.stringify(t,null,2));t.options.forEach(function(e){if(!e||"string"!=typeof e.label||"string"!=typeof e.value)throw new Error("multi_select options need string label and value: "+JSON.stringify(t,null,2))})}(t,e)},create({config:t}){const n=$("<input type='hidden'>").addClass(e);return t.separator&&n.data("kgridMultiSep",t.separator),{$input:n,skipValueAttr:!0}},mount(t){if(r(t.$input,t.config||{},t.mode),"update"===t.mode&&t.item&&t.col&&t.col.name){const e=t.item.attributes?t.item.attributes[t.col.name]:null;null!=e&&""!==e&&t.$input.val(e)}}});const i="kgrid-date-range-value";function a(t,e,n){const o=t&&t[e];return null!=o&&""!==o?String(o):n}t.dateRangeCalendarDate=function(t){if(null==t||""===t)return"";const e=/^(\d{4}-\d{2}-\d{2})/.exec(String(t).trim());return e?e[1]:""},t.dateRangeEndValue=function(t){return t?t+" 23:59:59":""},t.normalizeDateRangeDefault=function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return{from:"",to:""};let n=t.dateRangeCalendarDate(e.from),o=t.dateRangeCalendarDate(e.to);return n&&o&&o<n&&(o=n),{from:n,to:o}},t.syncDateRangeVisible=function(e){if(!e||!e.getAttribute)return;const n=e.getAttribute("data-kgrid-date-range"),o=n&&e.ownerDocument.getElementById(n);if(!o)return;const r=e.getAttribute("data-kgrid-date-bound"),i=o.querySelector("to"===r?".kgrid-date-range-to":".kgrid-date-range-from");if(!i)return;const a=t.dateRangeCalendarDate(e.value);i.value!==a&&(i.value=a)},t.applyDateRangeDefault=function(e,n,o){const r=t.normalizeDateRangeDefault(o);if(!r.from&&!r.to)return;const i=t.filterFormFields(e,n);function a(t,e){if(!e)return;const n=i.filter(function(){return $(this).attr("data-operator")===t});n.length&&!n.val()&&(n.val(e),n[0]&&(n[0].defaultValue=n[0].value))}a(">=",r.from),a("<=",r.to)},function(){const e=$.valHooks.text||{};$.valHooks.text={get:function(t){return t&&t.classList&&t.classList.contains(i)?t.value:e.get?e.get(t):void 0},set:function(n,o){if(n&&n.classList&&n.classList.contains(i)){const e=t.dateRangeCalendarDate(o),r=n.getAttribute("data-kgrid-date-bound");return n.value="to"===r?t.dateRangeEndValue(e):e,t.syncDateRangeVisible(n),!0}return e.set?e.set(n,o):void 0}}}(),t.registerFieldType("date_range",{filterEvents:"change",filterDebounceMs:0,validate(t,e){if("filter"!==e)throw new Error("date_range is only valid as a filter")},create(){const t=$("<input type='text' autocomplete='off'>").addClass(i).attr("data-operator",">=").attr("data-kgrid-date-bound","from").attr("tabindex","-1").attr("aria-hidden","true"),e=$("<input type='text' autocomplete='off'>").addClass(i).attr("data-operator","<=").attr("data-kgrid-date-bound","to").attr("tabindex","-1").attr("aria-hidden","true");return t.data("kgridDateRangeTo",e),{$input:t,skipValueAttr:!0}},mount(e){!function(e,n){const o=e.data("kgridDateRangeTo"),r="kgrid_dr_"+t.uuid(),i=$("<div>",{class:"kgrid-date-range",id:r}),l=$("<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-from'/>"),s=$("<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-to'/>");function u(t,n,r){t&&n&&n<t&&(n=t),l.val(t||""),s.val(n||""),e.val(t||""),o.val(n||""),r&&(e[0]&&(e[0].defaultValue=e[0].value),o[0]&&(o[0].defaultValue=o[0].value))}i.append($("<label>",{class:"kgrid-date-range-bound"}).append($("<span>",{class:"kgrid-date-range-label",text:a(n,"fromLabel","From")}),l),$("<label>",{class:"kgrid-date-range-bound"}).append($("<span>",{class:"kgrid-date-range-label",text:a(n,"toLabel","To")}),s)),e.before(i),e.attr("data-kgrid-date-range",r),o.attr("data-kgrid-date-range",r),i.append(e,o),l.add(s).on("change",function(){u(l.val()||"",s.val()||"",!1),e.trigger("change")});const c=".kgridDateRange_"+t.uuid(),d=function(){const n=e.prop("form")||e[0]&&e[0].form;n&&$(n).off("reset"+c).on("reset"+c,function(){setTimeout(function(){t.syncDateRangeVisible(e[0]),t.syncDateRangeVisible(o[0])},0)})};e.data("kgridDateRangeBindReset",d),d(),setTimeout(d,0);const f=t.normalizeDateRangeDefault(t.filterDefaultValue?t.filterDefaultValue(n&&n.default):n&&n.default);(f.from||f.to)&&u(f.from,f.to,!0)}(e.$input,e.config||{})}})}(window.KGrid),function(t){t.resolveDefaultInteraction=function(t){return"edit"===t.defaultInteraction||"view"===t.defaultInteraction?t.defaultInteraction:!0===t.editmode?"edit":(t.editmode,"view")},t.getTableInteractionHost=function(t){if(t.hasClass("custom-table-shell"))return t;const e=t.find(".custom-table-shell").first();return e.length?e:t},t.applyInteraction=function(e,n,o){const r=t.getTableInteractionHost(e),i="edit"===n?"edit":"view";r.attr("data-interaction",i),o&&"object"==typeof o?(void 0!==o.create&&r.attr("data-allow-insert",o.create?"true":"false"),void 0!==o.update&&r.attr("data-allow-update",o.update?"true":"false"),void 0!==o.delete&&r.attr("data-allow-delete",o.delete?"true":"false"),void 0!==o.clone&&r.attr("data-allow-clone",o.clone?"true":"false")):"edit"===i&&r.removeAttr("data-allow-insert data-allow-update data-allow-delete data-allow-clone")}}(window.KGrid),function(t){t.setupLabelsHeader=function(e,n){const o=e.children("tr"),r=o.children(),i=r.first().clone(!0);r.remove();return[...n.columns].forEach(e=>{if(e.hidden)return;let n=i.clone(!0);t.applyColumnDomAttrs(n,e),t.applyColumnCellMeta(n,e);const r=e.label??"";if(!e.features?.sort){const i=n.empty().html(r);return""!==r&&i.attr("title",r),t.applyColumnCellMeta(i,e),void o.append(i)}if(!e.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(e,null,2));const a=n.find("span.column-label").text(r);""!==r&&a.attr("title",r),n.children("a").attr("data-sortfld",e.name),n.appendTo(o)}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(o),o}}(window.KGrid),function(t){const e="kgridFilterDebounceTimer";t.cancelFilterSubmit=function(t){const n=t.data(e);n&&(clearTimeout(n),t.removeData(e))},t.cancelFilterDebounces=function(e){const n=$(e).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){t.cancelFilterSubmit($(this))})},t.flushFilterSubmit=function(t){const n=t.data(e);if(!n)return;clearTimeout(n),t.removeData(e);const o=t[0]&&t[0].form;o&&$(o).trigger("submit")},t.wrapFilterSubmitHandler=function(n,o,r,i){if(!t.shouldDebounceFilterSubmit(r,i))return o;const a=i;return function(){t.cancelFilterSubmit(n);const r=setTimeout(function(){n.removeData(e),o.call(this)}.bind(this),a);n.data(e,r)}},t.filterDefaultValue=function(t){return null!=t&&"object"==typeof t&&null!=t.value?t.value:t},t.columnFilterPersisted=function(t){const e=t&&t.filter?t.filter:{};return!(!t||!t.hidden&&"hidden"!==e.type&&!e.persist)},t.ensureFilterField=function(t,e,n,o){if(!t||!e||null==n||""===n)return null;let r=t.elements&&t.elements.namedItem(e);return r&&null!=r.length&&!r.tagName&&(r=r[0]),r&&r.tagName||(r=document.createElement("input"),r.type="hidden",r.name=e,t.appendChild(r)),r.setAttribute("data-operator",o||"="),r.value=String(n),r.defaultValue=String(n),r},t.applyColumnDefaultFilters=function(e,n){e&&n&&n.forEach(function(n){if(!n.name||n.features&&!1===n.features.filter)return;const o=n.filter;if(!o||null==o.default||""===o.default)return;const r=t.filterDefaultValue(o.default);if(null==r||""===r)return;if("date_range"===o.type)return void t.applyDateRangeDefault(e,n.name,r);const i=o.operator||(t.columnFilterPersisted(n)?"=":"~=~"),a=t.filterFormField(e,n.name);!n.hidden&&"hidden"!==o.type&&a.length?a.val()||(a.val(String(r)),a.attr("data-operator",i)):t.ensureFilterField(e,n.name,r,i)})},t.setupDefaultFilters=function(e,n,o,r){const i=$(e)[0];if(!(i&&n&&n.features&&n.features.filtering))return;const a=n.columns||[];if(t.applyColumnDefaultFilters(i,a),a.some(t.columnFilterPersisted)){let e=!1;$(i).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!e){n.preventDefault(),t.cancelFilterDebounces(i),e=!0;try{i.reset(),t.applyColumnDefaultFilters(i,a),o&&o.filtering&&"function"==typeof o.filtering.handleSubmit?o.filtering.handleSubmit(i):$(i).trigger("submit")}finally{e=!1}}})}if(!o||!o.filtering)return;const l=a.filter(function(e){return e.name&&e.filter&&null!=e.filter.default&&""!==e.filter.default&&t.columnFilterPersisted(e)});if(!l.length)return;const s=String(o.url&&o.url.parameters&&o.url.parameters.filter||"");!l.some(function(e){if(e.filter&&"date_range"===e.filter.type){const n=t.normalizeDateRangeDefault(t.filterDefaultValue(e.filter.default));return!(!n.from||-1!==s.indexOf(e.name+">="))||!(!n.to||-1!==s.indexOf(e.name+"<="))}return-1===s.indexOf(e.name+"=")})||r&&r.skipInitSubmit||o.filtering.handleSubmit(i)},t.setupFilterHeader=function(e,n){if(!n.features||!n.features.filtering)return null;const o=e.find(".thead-filters");o.empty();const r=[...n.columns],i=$("<tr>");i.appendTo(o);const a="filter_form_"+t.uuid(),l=$("<form>").attr("id",a).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(e);return r.forEach(e=>{const n=e.filter||{};if(e.hidden||"hidden"===n.type){if(e.features&&!1===e.features.filter)return;if(!e.name)return;const o=t.filterDefaultValue(n.default);return void(null!=o&&""!==o?t.ensureFilterField(l[0],e.name,o,n.operator||"="):t.columnFilterPersisted(e)&&t.ensureFilterField(l[0],e.name,"",n.operator||"="))}let o,r=$("<th>").appendTo(i).attr("data-label",e.label);if(t.applyColumnCellMeta(r,e),!1===e.features.filter)return;if(!e.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(e,null,2));let s=null;const u=t.createFieldInput({mode:"filter",col:e,config:n});if(u)s=u,o=u.$input,o.appendTo(r),t.mountField({mode:"filter",$input:o,col:e,config:n});else if("select"===n.type){if(!n.options)throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));if(o=$("<select>").addClass("form-select form-select-sm"),!Array.isArray(n.options))throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));n.options.forEach(t=>{if(!t.label||"string"!=typeof t.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(o)}),o.appendTo(r)}else{if(!t.isValidFilterType(n.type))throw new Error("Unknown filter type: "+n.type);o=$(`<input autocomplete='off' type='${n.type}' class='form-control form-control-sm'/>`),o.appendTo(r)}if("date_range"===n.type){r.find("input.kgrid-date-range-value").each(function(){this.setAttribute("form",a),this.setAttribute("name",e.name),l[0].appendChild(this)});const t=o.data("kgridDateRangeBindReset");"function"==typeof t&&t()}else{const r=n.operator||("multi_select"===n.type?"><":void 0);null!=r&&o.attr("data-operator",r),o.attr("form",a),o.attr("name",e.name);const i=t.filterDefaultValue(n.default);if(null!=i&&""!==i&&!o.val()){const e="multi_select"===n.type?t.normalizeMultiSelectValue(i,n.separator):String(i);o.val(e),o.attr("data-default",e),o[0]&&(o[0].defaultValue=e)}}t.bindFilterInputEvents({type:n.type,$input:o,onSubmit:function(){const t=this.form;t&&$(t).trigger("submit")},createResult:s,filterConfig:n})}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(i),l},t.syncFormFiltersToCollectionUrl=function(t,e){if(!t||!e||!e.url)return;e.url.parameters||(e.url.parameters={});const n=[],o=t.elements;if(o){for(let t=0;t<o.length;t++){const e=o[t];if(!e||!e.name)continue;const r=$(e),i=r.val();if(null==i||""===i)continue;const a=r.attr("data-operator")||r.data("operator")||"=";n.push(e.name+a+i)}e.offset=0,n.length?e.url.parameters.filter=n.join(","):delete e.url.parameters.filter}},t.FilterForm=function(e){this.form=$(e)[0],this.filter=(e,n,o="~=~")=>{if(!this.form)return this;let r=t.filterFormField(this.form,e);if(r.length||(t.ensureFilterField(this.form,e,n,o),r=t.filterFormField(this.form,e)),!r.length)return this;t.flushFilterSubmit(r),r.val(n);const i=r.attr("data-operator");return r.attr("data-operator",o),$(this.form).trigger("submit"),r.attr("data-operator",i),this},this.ensure=(e,n,o="=")=>(t.ensureFilterField(this.form,e,n,o),this),this.reset=()=>(this.form&&(t.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(t){t.wrapFlagSwitch=function(t){return t.attr({type:"checkbox",role:"switch",value:"1"}).removeClass("form-control form-input form-control-sm").addClass("form-check-input"),$("<div class='form-check form-switch kgrid-flag-switch mb-0'>").append(t)},t.setupCell=function(e,n){const o=n?n.attr("id"):null,r={...e},i=$("<td>").attr("data-label",e.label);t.applyColumnCellMeta(i,e),t.applyColumnDomAttrs(i,r);let a=$("<div>").addClass("cell-content");if(a.html(r.display.template??`{{${r.name}}}`),a.appendTo(i),null==n||!e.features.update)return a.clone(!0).removeClass("cell-content").addClass("cell-input").appendTo(i),i;if(!r.name)throw new Error("Column must have a name when column.features.update is true: \n"+JSON.stringify(e,null,2));const l=r.update,s=l.type??"text";let u,c=!1;const d=t.createFieldInput({mode:"update",col:e,config:l});if(d)u=d.$input,c=!!d.skipValueAttr;else{switch(s){case"textarea":u=$(`<textarea class='form-input form-control form-control-sm'>{{${l.value??r.name}}}</textarea>`),c=!0;break;case"select":if(u=$("<select class='form-input form-control form-control-sm'/>"),!Array.isArray(l.options))throw new Error("Select column must have an update.options array when column.features.update is true: \n"+JSON.stringify(e,null,2));l.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(u)}),c=!0;break;case"hidden":u=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const t=l.template||r.display.template||`{{${r.name}}}`;return $("<div>").addClass("cell-input").append(t).appendTo(i),i}case"checkbox":u=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),c=!0;break;default:if(!t.isValidInputType(s))throw new Error("Invalid update updateConfig type: "+JSON.stringify(l,null,2));u=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`)}u.attr("data-type",s)}if(l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(t=>u.attr(t,l.attrs[t])),u.attr("form",o),u.attr("name",r.name),!c&&"textarea"!==s){const t=l.value??`{{${r.name}}}`;null!=t&&"object"!=typeof t&&u.attr("value",t)}if(r.hidden)return u.attr("type","hidden").appendTo(n),i;l.disabled&&u.attr("disabled",!0),l.readonly&&u.attr("readonly",!0),l.required&&u.attr("required",!0),l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(t=>u.attr(t,l.attrs[t])),l.disabled||l.readonly||u.attr("onchange","$(this).parents('tr').addClass('editing')");const f="checkbox"===s?t.wrapFlagSwitch(u):u;return $("<div>").addClass("cell-input").append(f).appendTo(i),i}}(window.KGrid),function(t){t.setupNoDataTbody=function(t,e,n){const o=t.find("td").attr("colspan",n);return e.noDataTemplate&&o.html(e.noDataTemplate),o},t.fillDataRow=function(e,n){const o=[...n.columns],r="data_row_form_"+t.uuid()+"_{{this.id}}",i=n.features&&n.features.update?$("<form class='edit-form table-row-form'>").attr("id",r):null;if(o.forEach(n=>{const o=t.setupCell(n,i);n.hidden||o.appendTo(e)}),t.hasActionColumn(n)){const o=$("<td>").addClass("kgrid-row-actions").appendTo(e);t.renderRowActions(o,n,r)}return i&&t.anchorRowForm(i,e),e},t.setupDataBody=function(e,n,o,r,i,a){const l=$("<tr>").appendTo(e);if(n.dataRowAttrs&&"object"!=typeof n.dataRowAttrs)throw new Error("options.dataRowAttrs must be an object");const s={...n.dataRowAttrs??{}};return Object.keys(s).forEach(t=>l.attr(t,s[t])),e.data("emptyview",a),n?.features?.sorting&&e.data("sort",o),i&&e.data("paging",i.find(".pages")).data("pagesizeinp",i.find(".pagesize")).data("totalrecscount",i.find(".totalrecscount")),r&&e.data("filter",r),n.type&&e.data("type",n.type),t.fillDataRow(l,n),e},t.setupPagingFooter=function(e,n,o){return t.log("setupPagingFooter",e,n,o),n.pagingFooterAttrs&&t.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(t=>e.attr(t,n.pagingFooterAttrs[t])),t.log("noVisibleCols",o),e.find("td").attr("colspan",o),e}}(window.KGrid),function(t){t.setupNewRecordForm=function(e,n,o){if(!n.insertFormRow||!t.isPlainObject(n.insertFormRow))return e.find(".before-main-tbody").remove(),void e.find(".after-main-tbody").remove();const r=[...n.columns],i=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(e.find(".after-main-tbody").remove(),i.appendTo(e.find(".before-main-tbody"))):(e.find(".before-main-tbody").remove(),i.appendTo(e.find(".after-main-tbody")));const a="new_record_row_form_"+t.uuid(),l=$("<form class='table-row-form'>").attr("id",a).off("submit").on("submit",e=>{e.preventDefault();const i=t.serializeForm(e.target,r);Object.keys(i).forEach(t=>{r.find(e=>e.name===t)?.insert?.dontsave&&delete i[t]}),o.instance.newItem(i).then(()=>{e.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(i,e.target)}).catch(t.onError)});r.forEach(e=>{if(e.hidden){if(n.features?.create&&e.features?.create){const t=$("<input type='hidden'>").attr("name",e.name).attr("form",a).appendTo(l);e.insert.default&&t.val(e.insert.default)}return}if(!e.features.create){const n=$("<td>").appendTo(i).attr("data-label",e.label);return void t.applyColumnCellMeta(n,e)}const o=e.insert;if(!o||!t.isPlainObject(o))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(e,null,2));if(!o.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(e,null,2));let r;const s=o.type??"text",u=t.createFieldInput({mode:"insert",col:e,config:o});if(u)r=u.$input;else switch(s){case"textarea":r=$("<textarea class='form-input form-control form-control-sm'>");break;case"select":if(r=$("<select class='form-input form-control form-control-sm'/>"),!o.options||!Array.isArray(o.options))throw new Error("Column must have an insert.options array when column.features.insert is true: \n"+JSON.stringify(e,null,2));o.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(r)});break;case"hidden":r=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"checkbox":r=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),r.attr("data-type",s);break;default:if(!t.isValidInputType(s))throw new Error("Invalid type: "+JSON.stringify(o,null,2));r=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`),r.attr("data-type",s)}const c="object"==typeof o.default&&o.default&&null!=o.default.value?o.default.value:o.default;if("checkbox"===s){const e=t.isFlagOn(c);r.prop("checked",e).prop("defaultChecked",e)}else null==o.default||""===o.default||r.val()||String(c).trim()&&(r.val(c).trigger("change"),r[0]&&"defaultValue"in r[0]&&(r[0].defaultValue=r[0].value));if(o.attrs&&"object"==typeof o.attrs&&Object.keys(o.attrs).forEach(t=>r.attr(t,o.attrs[t])),r.attr("form",a).attr("name",e.name),o.disabled&&r.attr("disabled",!0),o.readonly&&r.attr("readonly",!0),o.required&&r.attr("required",!0),o.attrs&&"object"==typeof o.attrs&&Object.keys(o.attrs).forEach(t=>r.attr(t,o.attrs[t])),"hidden"!==o.type){const n="checkbox"===s?t.wrapFlagSwitch(r):r,o=$("<td>").append(n).appendTo(i).attr("data-label",e.label);t.applyColumnCellMeta(o,e)}t.mountField({mode:"insert",$input:r,col:e,config:o,formEl:l[0],rowEl:i[0]}),o.events&&Array.isArray(o.events)&&o.events.forEach(t=>{r.off(t.event).on(t.event,function(e,...n){"function"==typeof t.callback&&t.callback(e,l[0],i[0],...n)})})}),t.anchorRowForm(l,i);const s=$("<td>").addClass("kgrid-row-actions").appendTo(i).attr("data-label","action"),u=$("<div>").addClass("btn-group").appendTo(s);return $("<button>").addClass("btn btn-sm btn-primary new-item-btn").html("<i class='fas fa-plus-square'></i>").attr("form",a).attr("type","submit").appendTo(u),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(l[0],i[0]),i}}(window.KGrid),function(t){t.setupEvents=function(e,n,o,r){const i=e.views[0];i&&i.el&&"function"==typeof t.applyLayoutToRow&&t.applyLayoutToRow(i.el,o.columns),o.columns.forEach(n=>{n.display.events.forEach(t=>{if(!t.selector||!t.event||!t.callback)throw new Error("Invalid event: "+JSON.stringify(t,null,2));i.el.find(t.selector).off(t.event).on(t.event,n=>{if("function"!=typeof t.callback)throw new Error("Event callback must be a function: "+JSON.stringify(t,null,2));t.callback(n,e,i)})}),o.features.update&&n.update.events.forEach(o=>{if(!o.event||!o.callback)throw new Error("Invalid event: "+JSON.stringify(o,null,2));i.el.find("[name='"+n.name+"']").off(o.event).on(o.event,function(n,...r){if(t.log("event",o,n,this,r),"function"!=typeof o.callback)throw new Error("Event callback must be a function: "+JSON.stringify(o,null,2));o.callback(n,e,i,...r)})})}),o.features.update&&(i.el.find("[data-type]").each((n,o)=>{const a=o.getAttribute("data-type");if(!t.isPluggableFieldType(a))return;const l=r.get(o.name);l?.update&&t.mountField({mode:"update",$input:$(o),col:l,config:l.update,item:e,view:i})}),i.el.find("select[data-type='select']").each((t,n)=>{const o=r.get(n.name);if(!o)return;const i=e.attributes[o.name];null!=i&&""!==i&&$(n).val("boolean"==typeof i?String(i):i)}),i.el.find("input[type='checkbox']").each((n,o)=>{const i=r.get(o.name);i&&(o.checked=t.isFlagOn(e.attributes[i.name]))}),i.el.find("form.edit-form").off("submit").on("submit",e=>{const n=e.target;e.preventDefault();const r=$(n).parents("[data-type=item]").data().instance,i=t.serializeForm(n);Object.keys(i).forEach(t=>{o.columns.find(e=>e.name===t)?.update?.dontsave&&delete i[t]}),r.update(i).catch(t.onError)}));const a=t.resolveRowActions(o);t.applyRowActionVisibility(i.el,e,a.menuItems),t.mountRowActionDropdowns(i.el);const l=a.menuItems.some(t=>"clone"===t.action),s=a.menuItems.some(t=>"delete"===t.action);l&&i.el.find(".clone-item").off("click").on("click",t=>{t.preventDefault(),t.stopPropagation(),"function"==typeof o.onClone&&o.onClone(e,i,t)}),s&&i.el.find(".delete-item").off("click").on("click",n=>{n.preventDefault(),n.stopPropagation(),i.el.addClass("confirm-delete");const r=()=>i.el.removeClass("confirm-delete"),l=$(n.currentTarget).closest("[data-kgrid-action-index]").attr("data-kgrid-action-index"),s=null!=l?a.menuItems[Number(l)]:null,u=s&&"string"==typeof s.confirm?s.confirm:null;(u?(e,n)=>t.confirm(u,e,n):(n,r)=>t.runDeleteConfirm({item:e,view:i,options:o},n,r))(()=>{e.delete().catch(t.onError).finally(r)},r)});const u=new Map;a.menuItems.forEach(t=>{t.id&&"function"==typeof t.callback&&u.set(t.id,t.callback)}),u.size&&i.el.find("[data-kgrid-action]").off("click.kgridAction").on("click.kgridAction",t=>{const n=t.currentTarget.getAttribute("data-kgrid-action"),o=u.get(n);o&&(t.preventDefault(),t.stopPropagation(),o(t,e,i))}),"function"==typeof o.onRowFields&&o.onRowFields(e,i,n)}}(window.KGrid),function(t){t.PREFERENCES_VERSION=1,t.localStoragePreferences={get:function(t){try{const e="undefined"!=typeof window?window:globalThis,n=e&&e.localStorage;if(!n)return null;const o=n.getItem(t);return o?JSON.parse(o):null}catch(t){return null}},set:function(t,e){try{const n="undefined"!=typeof window?window:globalThis,o=n&&n.localStorage;if(!o)return;if(null==e)return void o.removeItem(t);o.setItem(t,JSON.stringify(e))}catch(t){}}},t.preferencesStorageFor=function(e){return e&&e.preferencesStorage?e.preferencesStorage:t._config&&t._config.preferencesStorage?t._config.preferencesStorage:t.localStoragePreferences},t.layoutStorageKey=function(t){return"kgrid:"+t+":layout"},t.filtersStorageKey=function(t,e){let n="kgrid:"+t+":filters";return null!=e&&""!==String(e)&&(n+=":"+String(e)),n},t.viewStorageKey=function(t,e){let n="kgrid:"+t+":view";return null!=e&&""!==String(e)&&(n+=":"+String(e)),n},t.chooserColumns=function(t){return(t||[]).filter(function(t){return t&&t.name&&!t.hidden})},t.layoutFromColumns=function(e){return{v:t.PREFERENCES_VERSION,columns:t.chooserColumns(e).map(function(t){return{name:t.name,hidden:!!t.userHidden}})}},t.parseFilterExpression=function(t){const e=String(t||""),n=["~=~",">=","<=","!=","=",">","<"];for(let t=0;t<n.length;t++){const o=n[t],r=e.indexOf(o);if(r>0)return{name:e.slice(0,r),operator:o,value:e.slice(r+o.length)}}return null},t.isUserFilterColumn=function(t){return!(!t||!t.name||t.hidden||t.features&&!1===t.features.filter)},t.readUserFilters=function(e,n){if(!e)return[];const o=[];return(n||[]).forEach(function(n){if(!t.isUserFilterColumn(n))return;let r=t.filterFormFields(e,n.name);if(r.length||(r=t.filterFormField(e,n.name)),!r.length)return;if(r.length>1)return void r.each(function(){const t=$(this),e=t.val();null==e||""===e||Array.isArray(e)&&!e.length||o.push({name:n.name,value:Array.isArray(e)?e:String(e),operator:t.attr("data-operator")||n.filter&&n.filter.operator||">="})});const i=r,a=i.val();if(null==a||""===a||Array.isArray(a)&&!a.length)return;const l=i.attr("data-operator")||n.filter&&n.filter.operator||"~=~";o.push({name:n.name,value:Array.isArray(a)?a:String(a),operator:l})}),o},t.applyUserFilters=function(e,n,o){e&&o&&Array.isArray(o.filters)&&o.filters.forEach(function(o){if(!o||!o.name)return;const r=(n||[]).find(function(t){return t&&t.name===o.name});if(!t.isUserFilterColumn(r))return;if(null==o.value||""===o.value)return;const i=t.filterFormFields(e,o.name);if(i.length>1){if(!o.operator)return;const t=i.filter(function(){return $(this).attr("data-operator")===o.operator});return void(t.length&&t.val(o.value))}let a=t.filterFormField(e,o.name);a.length||(t.ensureFilterField(e,o.name,o.value,o.operator),a=t.filterFormField(e,o.name)),a.length&&(a.val(o.value),o.operator&&a.attr("data-operator",o.operator))})},t.ensureUrlFiltersOnForm=function(e,n){if(!(e&&n&&n.url&&n.url.parameters))return;const o=String(n.url.parameters.filter||"");o&&o.split(",").forEach(function(n){const o=t.parseFilterExpression(n.trim());if(!o||!o.name||""===o.value)return;const r=t.filterFormFields(e,o.name);if(r.length>1){const t=r.filter(function(){return $(this).attr("data-operator")===o.operator});return void(t.length&&!t.val()&&t.val(o.value))}const i=t.filterFormField(e,o.name);return i.length&&i.val()?void 0:i.length?(i.val(o.value),void i.attr("data-operator",o.operator)):void t.ensureFilterField(e,o.name,o.value,o.operator)})},t.preferencesLoadLayout=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.layoutStorageKey(e.storageKey));return n&&n.v===t.PREFERENCES_VERSION&&Array.isArray(n.columns)?n:null},t.preferencesSaveLayout=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.layoutStorageKey(e.storageKey),n)},t.preferencesLoadFilters=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.filtersStorageKey(e.storageKey,e.filterStorageScope));return n&&n.v===t.PREFERENCES_VERSION&&Array.isArray(n.filters)?n:null},t.preferencesSaveFilters=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.filtersStorageKey(e.storageKey,e.filterStorageScope),{v:t.PREFERENCES_VERSION,filters:n||[]})},t.preferencesLoadView=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.viewStorageKey(e.storageKey,e.filterStorageScope));return n&&n.v===t.PREFERENCES_VERSION&&"object"==typeof n?n:null},t.preferencesSaveView=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.viewStorageKey(e.storageKey,e.filterStorageScope),n)},t.sortableColumnNames=function(t){const e=new Set;return(t||[]).forEach(function(t){t&&t.name&&t.features&&t.features.sort&&!t.hidden&&e.add(t.name)}),e},t.sanitizeSort=function(e,n){const o=t.sortableColumnNames(n),r=[];return String(null==e?"":e).split(",").forEach(function(t){const e=/^(-*)([A-Za-z0-9_-]+)$/.exec(String(t).trim());e&&o.has(e[2])&&r.push((e[1].length?"-":"")+e[2])}),r.join(",")},t.collectionSort=function(t){const e=t&&t.url&&t.url.parameters;return e&&null!=e.sort&&""!==e.sort?String(e.sort):""},t.sortDirectionForField=function(t,e){const n=String(t||"").split(",");for(let t=0;t<n.length;t++){const o=/^(-*)([A-Za-z0-9_-]+)$/.exec(n[t].trim());if(o&&o[2]===e)return o[1].length?"desc":"asc"}return null},t.syncSortIndicators=function(e,n){e&&e.length&&e.find("[data-sortfld]").each(function(){const e=$(this),o=e.attr("data-sortfld"),r=t.sortDirectionForField(n,o),i=e.find(".sort-up"),a=e.find(".sort-down"),l=e.find(".sort-default");"asc"===r?(e.data("sortdir","up"),i.show(),a.hide(),l.hide()):"desc"===r?(e.data("sortdir","down"),i.hide(),a.show(),l.hide()):(e.removeData("sortdir"),i.hide(),a.hide(),l.show())})},t.applySavedPageSize=function(t,e,n){if(!t||!t.length||null==n)return!1;const o=String(n);if(!/^\d+$/.test(o)||"0"===o)return!1;const r=(e.pagingPageSizes||[]).map(function(t){return String(t)});if(r.length&&r.indexOf(o)<0)return!1;const i=t.find("select.pagesize");return!!i.length&&(i.val(o),t.find(".pages").attr("data-pagesize",o),!0)},t.applySavedOffset=function(t,e){t&&null!=e&&/^\d+$/.test(String(e))&&("function"!=typeof t.setOffset?t.offset=String(e):t.setOffset(String(e)))},t.applySavedSort=function(e,n,o){if(!(o&&null!=o.sort&&n&&n.features&&n.features.sorting))return;const r=e&&e.url&&e.url.parameters;if(!r)return;const i=t.sanitizeSort(o.sort,n.columns);i?r.sort=i:delete r.sort},t.persistViewState=function(e,n,o){if(!(n&&n.storageKey&&e&&n.features))return;const r=!!n.features.sorting,i=!!n.features.paging;if(!r&&!i)return;const a=t.preferencesLoadView(n)||{},l={v:t.PREFERENCES_VERSION};if(r){const o=e.url&&e.url.parameters;o&&Object.prototype.hasOwnProperty.call(o,"sort")?l.sort=t.sanitizeSort(o.sort,n.columns):"string"==typeof a.sort?l.sort=a.sort:l.sort=""}if(i){const t=o&&o.length?o.find("select.pagesize").val():null,r=(n.pagingPageSizes||[]).map(function(t){return String(t)});null!=t&&/^\d+$/.test(String(t))&&"0"!==String(t)&&(!r.length||r.indexOf(String(t))>=0)?l.pageSize=Number(t):null!=a.pageSize&&(l.pageSize=a.pageSize);const i=null!=e.offset?String(e.offset):"0";l.offset=/^\d+$/.test(i)?Number(i):0}t.preferencesSaveView(n,l)},t.bindViewPersistence=function(e,n,o){e&&"function"==typeof e.on&&n&&n.storageKey&&n.features&&(n.features.sorting||n.features.paging)&&e.on("load",function(){t.persistViewState(e,n,o),n.features.sorting&&t.syncSortIndicators(o,t.collectionSort(e))})},t.reorderColumns=function(t,e){const n=new Map,o=[];(t||[]).forEach(function(t,e){t&&t.hidden?o.push({col:t,index:e}):t&&t.name&&n.set(t.name,t)});const r=[];(e||[]).forEach(function(t){n.has(t)&&(r.push(n.get(t)),n.delete(t))}),n.forEach(function(t){r.push(t)});const i=r.slice();return o.forEach(function(t){i.splice(Math.min(t.index,i.length),0,t.col)}),i},t.columnDefaultUserHidden=function(t){return!(!t||!t.defaultHidden||t.locked||t.hidden)},t.mergeLayoutIntoColumns=function(e,n){const o=(e||[]).slice();o.forEach(function(e){e&&!e.hidden&&(e.userHidden=t.columnDefaultUserHidden(e))});const r=t.chooserColumns(o),i=new Map(r.map(function(t){return[t.name,t]})),a=[],l=new Set;(n&&Array.isArray(n.columns)?n.columns:[]).forEach(function(t){if(!t||!t.name||!i.has(t.name))return;const e=i.get(t.name);e.userHidden=!!t.hidden&&!e.locked,a.push(t.name),l.add(t.name)}),r.forEach(function(t){l.has(t.name)||a.push(t.name)});const s=t.reorderColumns(o,a),u=t.chooserColumns(s);if(u.length&&u.every(function(t){return t.userHidden})){(u.find(function(t){return!t.locked})||u[0]).userHidden=!1}return s},t.applyLayoutToRow=function(e,n){if(!e||!e.length)return;const o=t.chooserColumns(n),r=o.map(function(t){return t.name}),i={};o.forEach(function(t){t.userHidden&&(i[t.name]=!0)});const a=e.children(".kgrid-row-actions"),l={};e.children("[data-name]").each(function(){l[this.getAttribute("data-name")]=this}),r.forEach(function(t){const n=l[t];n&&(a.length?$(n).insertBefore(a):e.append(n),n.classList.toggle("kgrid-user-hidden",!!i[t]))})},t.applyLayoutToDom=function(e,n,o){if(!e||!e.length)return;e.find(".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr").each(function(){t.applyLayoutToRow($(this),n)});const r=t.layoutVisibleColumns(n),i=e.find(".kgrid-row-actions").length>0;t.syncActionColumnColgroup(e,r.length,i,o,r),t.syncSpanningCells(e,t.participatingColumnCount(n,i))},t.refreshCollectionTemplate=function(e,n){if(!e||!e.instance||"function"!=typeof t.fillDataRow)return;const o=t.getKViews(n&&n.kviews);if(!o||"function"!=typeof o.template)return;const r=$("<tr>");n.dataRowAttrs&&t.isPlainObject(n.dataRowAttrs)&&Object.keys(n.dataRowAttrs).forEach(function(t){r.attr(t,n.dataRowAttrs[t])}),t.fillDataRow(r,n);const i=$("<div>").append(r).html(),a=o.template(i);e.instance.template=a,(e.instance.items||[]).forEach(function(t){(t.views||[]).forEach(function(t){t.template=a})})},t.setupFilterPersistence=function(e,n){e&&n&&n.storageKey&&n.features&&n.features.filtering&&$(e).off("submit.kgridFilterPrefs").on("submit.kgridFilterPrefs",function(){t.preferencesSaveFilters(n,t.readUserFilters(e,n.columns))})},t.applyColumnLayout=function(e,n,o){n.columns=t.mergeLayoutIntoColumns(n.columns,o);const r=e.$host.find("table").first();if(t.applyLayoutToDom(r,n.columns,n),t.refreshCollectionTemplate(e,n),"function"==typeof t.renderColumnChooserPanel){const o=e.$host.find(".kgrid-column-chooser-panel");o.length&&t.renderColumnChooserPanel(o,n,e)}return t.layoutFromColumns(n.columns)}}(window.KGrid),function(t){function e(e){const n=[];return e.find(".kgrid-column-chooser-list li[data-name]").each(function(){const t=this.getAttribute("data-name"),e=$(this).find("input[type='checkbox']").prop("checked");n.push({name:t,hidden:!e})}),{v:t.PREFERENCES_VERSION,columns:n}}t.renderColumnChooserPanel=function(n,o,r){n.empty();const i=$("<ul>").addClass("kgrid-column-chooser-list").appendTo(n);t.chooserColumns(o.columns).forEach(function(t){const e=$("<li>").attr("draggable","true").attr("data-name",t.name).appendTo(i);$("<span>").addClass("kgrid-column-chooser-handle").attr("aria-hidden","true").text("⋮⋮").appendTo(e);const n=$("<label>").appendTo(e),o=$("<input>").attr("type","checkbox").prop("checked",!t.userHidden).appendTo(n);t.locked&&o.prop("disabled",!0).attr("title","This column cannot be hidden"),n.append(document.createTextNode(" "+(t.label||t.name)))}),$("<button>").attr("type","button").addClass("btn btn-sm btn-outline-secondary kgrid-column-chooser-reset").text(o.columnChooserResetLabel||"Reset columns").appendTo(n),n.off("change.kgridChooser").on("change.kgridChooser","input[type='checkbox']",function(){const t=e(n);(function(t){return t.columns.filter(function(t){return!t.hidden}).length})(t)<1?this.checked=!0:r.setLayout(t)}),n.off("click.kgridChooserReset").on("click.kgridChooserReset",".kgrid-column-chooser-reset",function(){r.resetLayout()});let a=null;i.off(".kgridChooserDrag"),i.on("dragstart.kgridChooserDrag","li",function(t){a=this,$(this).addClass("kgrid-column-chooser-dragging"),t.originalEvent&&t.originalEvent.dataTransfer&&(t.originalEvent.dataTransfer.effectAllowed="move",t.originalEvent.dataTransfer.setData("text/plain",this.getAttribute("data-name")))}),i.on("dragend.kgridChooserDrag","li",function(){$(this).removeClass("kgrid-column-chooser-dragging"),a=null}),i.on("dragover.kgridChooserDrag","li",function(t){if(t.preventDefault(),!a||a===this)return;const e=this.getBoundingClientRect(),n=e.top+e.height/2;(t.originalEvent?t.originalEvent.clientY:0)<n?this.parentNode.insertBefore(a,this):this.parentNode.insertBefore(a,this.nextSibling)}),i.on("drop.kgridChooserDrag","li",function(t){t.preventDefault(),r.setLayout(e(n))})},t.setupColumnChooser=function(e,n,o){if(!n.features||!n.features.columnChooser)return;const r=t.getTableInteractionHost(e);r.find(".kgrid-column-chooser").remove();const i=r.find(".thead-labels th.kgrid-row-actions").first();if(!i.length)return;r.attr("data-has-column-chooser","true");const a=n.columnChooserLabel||"Columns",l=$("<div>").addClass("kgrid-column-chooser"),s=$("<button>").attr("type","button").addClass("kgrid-column-chooser-toggle btn btn-sm btn-outline-secondary").attr("title",a).attr("aria-label",a).attr("aria-expanded","false").attr("aria-haspopup","true").html('<i class="fas fa-cog" aria-hidden="true"></i>'),u=$("<div>").addClass("kgrid-column-chooser-panel").attr("hidden","hidden");function c(){const t=s[0].getBoundingClientRect();u.css({position:"fixed",top:Math.round(t.bottom+2)+"px",left:"auto",right:Math.round(window.innerWidth-t.right)+"px",zIndex:1055})}function d(){u.attr("hidden","hidden"),s.attr("aria-expanded","false"),u.css({top:"",left:"",right:"",position:"",zIndex:""})}l.append(s,u),i.append(l),t.renderColumnChooserPanel(u,n,o),s.on("click",function(t){t.stopPropagation(),u.attr("hidden")?(u.removeAttr("hidden"),s.attr("aria-expanded","true"),c()):d()});const f="kgridChooser"+t.uuid();$(window).on("scroll."+f+" resize."+f,function(){u.attr("hidden")||c()}),$(document).on("pointerdown."+f,function(t){if(!document.body.contains(l[0]))return $(document).off("."+f),void $(window).off("."+f);l[0].contains(t.target)||d()})}}(window.KGrid),function(t){t.init=async function(e,n){const o=t.resolveHostElement(e),r={...t.protoOptions,...n},i=t.mountTableShell(o,r);t.log("table config options",r);const a=t.resolveDefaultInteraction(r);t.applyInteraction(o,a);const l={$host:o,instance:null,filterForm:null,find:t=>o.find(t),setInteraction:(e,n)=>(t.applyInteraction(o,e,n),l),getInteraction:()=>"edit"===t.getTableInteractionHost(o).attr("data-interaction")?"edit":"view",setEditMode(t){if("boolean"!=typeof t)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return l.setInteraction(t?"edit":"view")},toggleEditMode:t=>(null!=t&&"object"==typeof t&&"function"==typeof t.preventDefault&&(t=void 0),"boolean"==typeof t?l.setInteraction(t?"edit":"view"):l.setInteraction("edit"===l.getInteraction()?"view":"edit")),getLayout:()=>t.layoutFromColumns(r.columns),setLayout:e=>(t.applyColumnLayout(l,r,e),t.preferencesSaveLayout(r,l.getLayout()),l.getLayout()),resetLayout(){const e=new Map;return r.columns.forEach(function(t){t&&t.name&&e.set(t.name,t)}),r.columns=s.map(function(t){return e.get(t)}).filter(Boolean),t.preferencesSaveLayout(r,null),t.applyColumnLayout(l,r,null),l.getLayout()}};r.columns=(r.columns||[]).map(e=>t.normalizeColumnConfig(e));const s=r.columns.map(function(t){return t.name});r.columns=t.mergeLayoutIntoColumns(r.columns,t.preferencesLoadLayout(r));const u=r.handlers??{};if(delete r.handlers,"string"==typeof r.onClone){const t=u[r.onClone]||r.functions&&r.functions[r.onClone];if(!t||"function"!=typeof t)throw new Error("onClone handler "+r.onClone+" not found or is not a function");r.onClone=t}t.resolveRowActions(r,u);{const e=r._resolvedRowActions;t.getTableInteractionHost(o).attr("data-has-row-menu",e&&e.menuItems&&e.menuItems.length?"true":"false")}r.columns.forEach(t=>{["insert","update","display"].forEach(e=>{const n=t[e].events;if(!n||!Array.isArray(n))throw new Error("Column "+t.name+" events are not an array");n.forEach(e=>{if("string"==typeof e.callback){const n=u[e.callback]||r.functions&&r.functions[e.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+e.callback+" not found for column "+t.name+" or is not a function");e.callback=n}else if("function"!=typeof e.callback)throw new Error("Event callback must be a function for column "+t.name)})});const e=t.display;e&&e.events&&Array.isArray(e.events)&&e.events.forEach(t=>{if("string"==typeof t.callback){const e=u[t.callback]||r.functions&&r.functions[t.callback];e&&"function"==typeof e&&(t.callback=e)}})});const c=new Map;r.columns.forEach(t=>{c.set(t.name,t)});const d=t.setupLabelsHeader(i.find(".thead-labels"),r),f=t.hasActionColumn(r),p=t.layoutVisibleColumns(r.columns),m=t.participatingColumnCount(r.columns,f);t.syncActionColumnColgroup(i,p.length,f,r,p);const g=r.filterForm??t.setupFilterHeader(i,r);let h;const y=r.storageKey&&r.features&&(r.features.sorting||r.features.paging)?t.preferencesLoadView(r):null;r.features&&r.features.paging?(h=t.setupPagingFooter(i.find(".paging-footer"),r,m),y&&t.applySavedPageSize(h,r,y.pageSize)):(h=null,i.find(".paging-footer").remove());const b=t.setupNoDataTbody(i.find(".no-data-tbody"),r,m);r.features&&r.features.create&&t.setupNewRecordForm(i,r,l),l.filterForm=new t.FilterForm(g);const w=t.setupDataBody(i.find(".main-tbody"),r,d,g,h,b),v={dontload:!0,setAttrAsId:r.setAttrAsId??!1,itemListeners:{afterrender:e=>t.setupEvents(e,l.find("table"),r,c)}},C=t.getKViews(r.kviews);if(!C)throw new Error(t.KVIEWS_MISSING_MSG);if(l.instance=await C.createCollectionInstance(w,v),r.url){l.instance.setUrl(r.url),r.deleteUrl&&(t.log("set deleteUrl",r.deleteUrl),l.instance.setUrl(r.deleteUrl,"delete")),r.updateUrl&&(t.log("set updateUrl",r.updateUrl),l.instance.setUrl(r.updateUrl,"update"));const e=r.insertUrl||r.url,n=r.onDuplicate?t.applyOnDuplicateToUrl(e,r.onDuplicate):r.insertUrl;n&&l.instance.setUrl(n,"insert"),y&&r.features&&r.features.sorting&&t.applySavedSort(l.instance,r,y),y&&r.features&&r.features.paging&&t.applySavedOffset(l.instance,y.offset)}r.features&&r.features.sorting&&t.syncSortIndicators(i,t.collectionSort(l.instance)),t.bindViewPersistence(l.instance,r,i),t.setupDefaultFilters(g,r,l.instance,{skipInitSubmit:!0});const E=g&&(g.jquery?g[0]:g);if(t.applyUserFilters(E,r.columns,t.preferencesLoadFilters(r)),t.ensureUrlFiltersOnForm(E,l.instance),t.setupFilterPersistence(E,r),t.setupColumnChooser(o,r,l),r.url)try{r.features&&r.features.filtering&&E&&t.syncFormFiltersToCollectionUrl(E,l.instance),await l.instance.loadFromRemote()}catch(e){t.onError(e)}else{if(!r.data||r.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const t=r.data.map(t=>({attributes:t}));l.instance.loadFromData(t)}}return l}}(window.KGrid);
1
+ /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-11-03T07:47:27.707Z */
2
+ !function(t){function e(t){const e={},n=t&&t.elements;if(!n)return e;for(let t=0;t<n.length;t++){const o=n[t],r=o.name;if(!r||o.disabled)continue;const a=o.type;if("submit"===a||"button"===a||"reset"===a||"file"===a)continue;if("checkbox"===a){e[r]=o.checked?"1":"0";continue}if("radio"===a){if(!o.checked)continue;e[r]=o.value;continue}if("SELECT"===o.tagName&&o.multiple){e[r]=Array.from(o.selectedOptions).map(function(t){return t.value});continue}const i=o.value;Object.prototype.hasOwnProperty.call(e,r)?(Array.isArray(e[r])||(e[r]=[e[r]]),e[r].push(i)):e[r]=i}return e}t.isFlagOn=function(t){return!0===t||1===t||"1"===t},t.serializeFormDefault=e;const n={log:function(){},onError:function(t){console.error(t)},confirm:function(t,e,n){"undefined"!=typeof window&&window.confirm(t)?e():n&&n()},deleteConfirm:null,serializeForm:e,customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300,preferencesStorage:null};t._config=Object.assign({},n),t.configure=function(e){return e&&"object"==typeof e&&Object.assign(t._config,e),"function"==typeof t._syncCustomInputTypes&&t._syncCustomInputTypes(),t},t.log=function(){t._config.log.apply(null,arguments)},t.onError=function(e){return t._config.onError(e)},t.confirm=function(e,n,o){return t._config.confirm(e,n,o)},t.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",t._defaultDeleteConfirm=function(e,n,o){t.confirm(t.DEFAULT_DELETE_CONFIRM_MESSAGE,n,o)},t.runDeleteConfirm=function(e,n,o){const r=e.options&&"function"==typeof e.options.deleteConfirm?e.options.deleteConfirm:null,a="function"==typeof t._config.deleteConfirm?t._config.deleteConfirm:null;return(r||a||t._defaultDeleteConfirm)(e,n,o)},t.serializeForm=function(e,n){return t._config.serializeForm(e,n)},t.getKViews=function(e){const n=[e,t._config.kviews];for(let t=0;t<n.length;t++){const e=n[t];if(e&&"function"==typeof e.createCollectionInstance)return e}const o=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return o&&"function"==typeof o.createCollectionInstance?o:null},t.KVIEWS_MISSING_MSG="KGrid requires KViews: install peer @logimaxx/kviews, load it before kgrid.js (window.KViews), or call KGrid.configure({ kviews: KViews }). You can also pass kviews in table options: KGrid.init(host, { kviews, ... })."}(window.KGrid=window.KGrid||{}),function(t){t.protoOptions={url:null,type:null,filter:null,features:{filtering:!1,sorting:!1,paging:!1,create:!1,update:!1,delete:!1,clone:!1,columnChooser:!1},rowActions:null,storageKey:null,filterStorageScope:null,columnChooserLabel:"Columns",columnChooserResetLabel:"Reset columns",defaultInteraction:"view",insertFormRow:{position:"top"},onDuplicate:null,tableAttrs:{class:""},labelsRowAttrs:{},dataRowAttrs:{},filtersRowAttrs:null,pagingPageSizes:[10,25,50,75],pagingDefaultSize:10,emptyRowMessage:null,pagingFooterLabel:"records per page. Total"},t.protoColumnConfig={label:null,name:null,hidden:!1,locked:!1,defaultHidden:!1,userHidden:!1,class:null,columnClass:null,attrs:{},features:{create:!1,update:!1,filter:!1,sort:!1},display:{template:null,events:[]},input:null,insert:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,events:[]},update:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,template:null,events:[]},filter:{type:"text",operator:"~=~",default:null,placeholder:"",options:null,persist:!1,debounceMs:null}},t.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],t.VALID_INPUT_TYPES=t.VALID_NATIVE_INPUT_TYPES.slice(),t.VALID_NATIVE_FILTER_TYPES=t.VALID_NATIVE_INPUT_TYPES.filter(t=>"displayonly"!==t),t.VALID_FILTER_TYPES=t.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),t.isValidInputType=function(e){return t.VALID_NATIVE_INPUT_TYPES.includes(e)||t.isPluggableFieldType(e)},t.isValidFilterType=function(e){return"displayonly"!==e&&(t.VALID_NATIVE_FILTER_TYPES.includes(e)||t.isPluggableFieldType(e))}}(window.KGrid=window.KGrid||{}),function(t){t.isPlainObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.setDefaultValues=function(e,n){const o={...e||{}};return Object.keys(n||{}).forEach(e=>{t.isPlainObject(n[e])&&t.isPlainObject(o[e])?o[e]=t.setDefaultValues(o[e],n[e]):t.isPlainObject(n[e])&&null==o[e]?o[e]=t.setDefaultValues({},n[e]):o[e]=n[e]}),o},t.normalizeColumnConfig=function(e){let n=e&&"object"==typeof e?{...e}:{};if(t.isPlainObject(n.input)){const e={...n.input};delete n.input,n.insert=t.setDefaultValues(e,n.insert||{}),n.update=t.setDefaultValues(e,n.update||{})}const o=t.setDefaultValues(t.protoColumnConfig,n);return null==o.class&&o.columnClass&&(o.class=o.columnClass),o.update&&"displayonly"===o.update.type&&!o.update.template&&o.display&&o.display.template&&(o.update.template=o.display.template),["display","insert","update"].forEach(t=>{o[t]&&"object"==typeof o[t]&&(Array.isArray(o[t].events)||(o[t].events=[]))}),o};const e=["error","ignore","update"],n=["set","add","sub"];function o(t,e){const o=String(t||"").trim(),r=null==e||""===e?"set":String(e).trim();if(!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$/.test(o))throw new Error("Invalid onDuplicate field: "+t);if(-1===n.indexOf(r))throw new Error("Invalid onDuplicate operator '"+r+"' on field '"+o+"'");return{name:o,op:r}}function r(t){const e=String(t||"").trim(),n=e.lastIndexOf(":");return-1===n?o(e,"set"):o(e.slice(0,n),e.slice(n+1))}t.onDuplicateParams=function(n){if(null==n||!1===n)return null;let a,i;if("string"==typeof n)a=n.trim();else{if(!t.isPlainObject(n))throw new Error("onDuplicate must be a string or an object");a=String(n.action||n.onduplicate||"").trim(),i=null!=n.fields?n.fields:n.update}if(-1===e.indexOf(a))throw new Error("Invalid onDuplicate action: "+a);const l={onduplicate:a};if("update"!==a)return l;const s=[],u={},c=function(t){if(u[t.name])throw new Error("onDuplicate field '"+t.name+"' is listed more than once");u[t.name]=!0,s.push("set"===t.op?t.name:t.name+":"+t.op)};if("string"==typeof i)i.split(",").forEach(function(t){t.trim()&&c(r(t))});else if(Array.isArray(i))i.forEach(function(t){c(r(t))});else if(t.isPlainObject(i))Object.keys(i).forEach(function(t){c(o(t,i[t]))});else if(null!=i)throw new Error("onDuplicate fields must be an object, array, or string");if(!s.length)throw new Error("onDuplicate action 'update' requires fields");return l.update=s.join(","),l},t.applyOnDuplicateToUrl=function(e,n){const o=t.onDuplicateParams(n);if(!o||!e)return e;const r=e.indexOf("#"),a=r>=0?e.slice(r):"",i=r>=0?e.slice(0,r):e,l=i.indexOf("?"),s=l>=0?i.slice(0,l):i,u=[];return l>=0&&i.slice(l+1).split("&").forEach(function(t){if(!t)return;const e=t.indexOf("="),n=decodeURIComponent(e>=0?t.slice(0,e):t);"onduplicate"!==n&&"update"!==n&&u.push(t)}),Object.keys(o).forEach(function(t){u.push(encodeURIComponent(t)+"="+encodeURIComponent(o[t]))}),s+(u.length?"?"+u.join("&"):"")+a}}(window.KGrid),function(t){t.resolveHostElement=function(t){if(null==t)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof t&&t.jquery){if(!t.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return t}if("object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName)return $(t);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},t.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},t.columnWidthCss=function(t){if(!t||!t.attrs)return null;const e=t.attrs.width;return null==e||""===e?null:"number"==typeof e||/^\d+(\.\d+)?$/.test(String(e))?String(e)+"px":String(e)},t.applyColumnDomAttrs=function(t,e){const n=e&&e.attrs&&"object"==typeof e.attrs?e.attrs:null;return n?(Object.keys(n).forEach(function(e){"width"!==e&&t.attr(e,n[e])}),t):t},t.layoutVisibleColumns=function(t){return(t||[]).filter(function(t){return t&&t.name&&!t.hidden&&!t.userHidden})},t.participatingColumnCount=function(e,n){return t.layoutVisibleColumns(e).length+(n?1:0)},t.syncActionColumnColgroup=function(e,n,o,r,a){let i=e.children("colgroup.kgrid-colgroup");i.length||(i=$("<colgroup>").addClass("kgrid-colgroup").prependTo(e)),i.empty();const l=Array.isArray(a)?a:null;let s=0;if(l&&l.length)l.forEach(function(e){if(e&&e.userHidden)return;const n=$("<col>");e&&e.name&&n.attr("data-name",e.name);const o=t.columnWidthCss(e);o&&n.css("width",o),i.append(n),s+=1});else for(let t=0;t<n;t++)i.append($("<col>")),s+=1;return o&&i.append($("<col>").addClass("kgrid-row-actions-col").css("width",t.actionColumnWidth(r))),s},t.syncSpanningCells=function(t,e){t&&t.length&&e&&t.find(".paging-footer td, .no-data-tbody td").attr("colspan",e)},t.anchorRowForm=function(t,e){if(!(t&&t.length&&e&&e.length))return t;t.attr("hidden","hidden").attr("aria-hidden","true");const n=e.children("td").first();return n.length&&t.prependTo(n),t},t.filterFormField=function(e,n){const o=t.filterFormFields(e,n);return o.length?o.eq(0):$()},t.filterFormFields=function(t,e){if(!t||!e)return $();const n=[],o=t.elements;if(o)for(let t=0;t<o.length;t++)o[t]&&o[t].name===e&&n.push(o[t]);if(!n.length&&t.id){const o=document.querySelectorAll('[form="'+t.id+'"][name="'+e+'"]');for(let t=0;t<o.length;t++)n.push(o[t])}return $(n)},t.columnClassName=function(t){if(!t)return null;const e=null!=t.class&&""!==t.class?t.class:t.columnClass;return null!=e&&""!==e?String(e):null},t.applyColumnCellMeta=function(e,n){if(!e||!e.length||!n)return e;n.name&&e.attr("data-name",n.name);const o=t.columnClassName(n);return o&&e.addClass(o),e.toggleClass("kgrid-user-hidden",!!n.userHidden),e}}(window.KGrid),function(t){function e(t){"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t)}function n(t){return t?"<i class='"+t+"'></i>":""}function o(t,e,o){const r=$("<button>").addClass(e.btnClass||"btn btn-sm btn-outline-secondary").attr("type","save"===e.action?"submit":"button").attr("title",e.title||e.label||"");return e.class&&r.addClass(e.class),"save"!==e.action&&"cancel"!==e.action||(r.attr("name","save"===e.action?"save":"cancel"),o&&r.attr("form",o)),"cancel"===e.action&&r.attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()"),e.id&&r.attr("data-kgrid-action",e.id),e.action&&r.attr("data-kgrid-builtin",e.action),e.icon?(r.html(n(e.icon)),e.showLabel&&e.label&&r.append(document.createTextNode(" "+e.label))):e.label&&r.text(e.label),r.appendTo(t),r}function r(t,e,n){const o=n.indexOf(e);o<0||(t.attr("data-kgrid-action-index",String(o)),null!=e.visible&&t.addClass("kgrid-action-conditional kgrid-action-off"))}t.BUILTIN_ROW_ACTIONS={clone:{action:"clone",icon:"fa-regular fa-copy",label:"Clone",title:"Clone item",when:"idle",btnClass:"btn btn-sm btn-outline-secondary clone-item",groupClass:"clone-item-grp"},delete:{action:"delete",icon:"fas fa-trash",label:"Delete",title:"Delete item",when:"idle",btnClass:"btn btn-sm btn-danger delete-item",groupClass:"delete-item-grp"},save:{action:"save",icon:"fas fa-save",label:"Save",title:"Save item",when:"editing",btnClass:"btn btn-sm btn-success save-item",groupClass:"edit-item-grp"},cancel:{action:"cancel",icon:"fas fa-undo",label:"Cancel",title:"Cancel edit",when:"editing",btnClass:"btn btn-sm btn-secondary cancel-edit",groupClass:"edit-item-grp"}},t.normalizeRowActionItem=function(n,o,r){if(!n||"object"!=typeof n)return null;const a=n.action;if("save"===a||"cancel"===a)return e("KGrid: rowActions items should not list '"+a+"' — it is added automatically when features.update is true"),null;let i={};if(a&&t.BUILTIN_ROW_ACTIONS[a])i={...t.BUILTIN_ROW_ACTIONS[a]};else{if(!n.id)return e("KGrid: custom rowAction requires id: "+JSON.stringify(n)),null;i={id:n.id,when:"idle",btnClass:"btn btn-sm btn-outline-secondary",groupClass:"kgrid-custom-action-grp"}}const l={...i,...n};if(a&&t.BUILTIN_ROW_ACTIONS[a]&&(l.action=a),l.when||(l.when=l.action&&i.when||"idle"),!l.title&&l.label&&(l.title=l.label),!l.label&&l.title&&(l.label=l.title),"string"==typeof l.callback){const t=function(t,e,n){if(!t||"string"!=typeof t)return null;const o=e&&e[t]||n.functions&&n.functions[t];return"function"==typeof o?o:null}(l.callback,o,r);if(!t)throw new Error("rowAction callback "+l.callback+" not found or is not a function");l.callback=t}if(l.id&&"function"!=typeof l.callback&&!l.action)throw new Error("Custom rowAction '"+l.id+"' requires a callback");return l},t.rowActionVisible=function(t,e){if(null==e)return!0;if("function"==typeof e)return!!e(t);if(!e||"object"!=typeof e||Array.isArray(e))return!0;const n=t&&t.attributes||{};return Object.keys(e).every(function(t){const o=e[t],r=n[t];return Array.isArray(o)?o.some(function(t){return String(r??"")===String(t)}):String(r??"")===String(o)})},t.resolveRowActions=function(n,o){if(n&&n._resolvedRowActions&&arguments.length<2)return n._resolvedRowActions;const r=n&&n.features||{};let a="buttons",i=[];if(n&&null!=n.rowActions){const o=n.rowActions;Array.isArray(o)?i=o:t.isPlainObject(o)&&(a="dropdown"===o.display?"dropdown":"buttons",i=Array.isArray(o.items)?o.items:[]),(r.delete||r.clone)&&e("KGrid: features.delete / features.clone are ignored when rowActions is set")}else r.clone&&i.push({action:"clone"}),r.delete&&i.push({action:"delete"});const l=[];i.forEach(function(e){const r=t.normalizeRowActionItem(e,o,n||{});r&&l.push(r)});const s=[];r.update&&(s.push({...t.BUILTIN_ROW_ACTIONS.save}),s.push({...t.BUILTIN_ROW_ACTIONS.cancel}));const u={display:a,menuItems:l,editingItems:s};return n&&(n._resolvedRowActions=u),u},t.hasActionColumn=function(e){const n=e&&e.features;if(n&&(n.create||n.columnChooser))return!0;const o=t.resolveRowActions(e);return o.menuItems.length>0||o.editingItems.length>0},t.actionColumnWidth=function(e){const n=t.resolveRowActions(e),o=e&&e.features||{},r=n.editingItems.length,a=o.create?1:0;let i;i="dropdown"===n.display&&n.menuItems.length>0?1:n.menuItems.filter(function(t){return"editing"!==t.when}).length;return(2.5*Math.max(i,r,a,1)+.75).toFixed(2)+"rem"},t.closeRowActionDropdowns=function(t){$(".kgrid-row-actions-menu").each(function(){const e=$(this),n=e.children(".dropdown-menu");t&&n[0]===t[0]||(n.removeClass("show").css({top:"",left:"",right:"",position:""}),e.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded","false").removeClass("show"))})},t.mountRowActionDropdowns=function(e){e&&e.length&&(t._rowActionsDropdownDocBound||(t._rowActionsDropdownDocBound=!0,$(document).on("click.kgridRowActions",function(){t.closeRowActionDropdowns()}).on("keydown.kgridRowActions",function(e){"Escape"===e.key&&t.closeRowActionDropdowns()})),e.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function(){const e=this,n=$(e),o=n.parent(".kgrid-row-actions-menu").children(".dropdown-menu");n.off("click.kgridRowActions").on("click.kgridRowActions",function(r){r.preventDefault(),r.stopPropagation();const a=!o.hasClass("show");if(t.closeRowActionDropdowns(),!a)return;const i=e.getBoundingClientRect();o.addClass("show").css({position:"fixed",top:Math.round(i.bottom+2)+"px",left:"auto",right:Math.round(window.innerWidth-i.right)+"px",zIndex:1055}),n.addClass("show").attr("aria-expanded","true")}),o.off("click.kgridRowActions").on("click.kgridRowActions",function(t){t.stopPropagation()}),o.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose",function(){setTimeout(function(){t.closeRowActionDropdowns()},0)})}))},t.applyRowActionVisibility=function(e,n,o){e&&e.length&&o&&o.forEach(function(o,r){if(!o||null==o.visible)return;const a=t.rowActionVisible(n,o.visible);e.find('[data-kgrid-action-index="'+r+'"]').toggleClass("kgrid-action-off",!a)})},t.escapeHtml=t.escapeHtml||function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t.renderRowActions=function(e,a,i){const l=t.resolveRowActions(a),s=l.menuItems.filter(function(t){return"editing"!==t.when}),u=l.menuItems.filter(function(t){return"editing"===t.when});if("dropdown"===l.display&&s.length>0){const o=$("<div>").addClass("btn-group kgrid-row-actions-menu").appendTo(e);$("<button>").addClass("btn btn-sm btn-outline-secondary dropdown-toggle kgrid-actions-dropdown-toggle").attr({type:"button","aria-expanded":"false",title:"Actions"}).html("<i class='fas fa-ellipsis-v'></i>").appendTo(o);const a=$("<ul>").addClass("dropdown-menu dropdown-menu-end").appendTo(o);s.forEach(function(e){const o=$("<li>").appendTo(a);r(o,e,l.menuItems);const i=$("<button>").addClass("dropdown-item").attr("type","button").appendTo(o);"clone"===e.action?i.addClass("clone-item"):"delete"===e.action&&i.addClass("delete-item text-danger"),e.id&&i.attr("data-kgrid-action",e.id),e.action&&i.attr("data-kgrid-builtin",e.action),e.class&&i.addClass(e.class),e.btnClass&&!e.action&&/\bbtn-danger\b|\btext-danger\b|\boutline-danger\b/.test(e.btnClass)&&i.addClass("text-danger");const s=e.label||e.title||e.action||e.id;e.icon?i.html(n(e.icon)+" "+t.escapeHtml(s)):i.text(s)})}else s.forEach(function(t){const n=$("<span>").addClass(t.groupClass||"btn-group kgrid-custom-action-grp").appendTo(e);"always"===t.when&&n.addClass("kgrid-action-always"),r(n,t,l.menuItems),o(n,t,i)});const c=l.editingItems.concat(u);if(c.length){const t=$("<span>").addClass("btn-group edit-item-grp").appendTo(e);c.forEach(function(e){o(t,e,i)})}}}(window.KGrid),function(t){t.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",t.TABLE_SHELL_TEMPLATE='\n<table class="custom-table" style="table-layout: fixed;">\n <thead class="thead-labels">\n <tr>\n <th class="align-top">\n <a class="sort" data-sortfld="" style="cursor: pointer;">\n <span class="column-label"></span>\n <i class="fas fa-sort-up sort-up" style="display: none"></i>\n <i class="fas fa-sort-down sort-down" style="display: none"></i>\n <i class="fas fa-sort sort-default"></i>\n </a>\n </th>\n </tr>\n </thead>\n <thead class="thead-filters"></thead>\n <tbody class="before-main-tbody"></tbody>\n <tbody class="main-tbody"></tbody>\n <tbody class="after-main-tbody"></tbody>\n <tbody class="no-data-tbody">\n <tr><td>{{EMPTY_ROW_MESSAGE}}</td></tr>\n </tbody>\n <tfoot class="paging-footer">\n <tr>\n <td>\n <div class="btn-group pages" data-pagesize="{{PAGES_DATA_PAGESIZE}}">\n <button type="button" name="first" class="btn btn-sm btn-outline-secondary">&lt;&lt;</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary">&lt;</button>\n <button type="button" name="page" class="btn btn-sm btn-outline-secondary">1</button>\n <button type="button" name="next" class="btn btn-sm btn-outline-secondary">&gt;</button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">&gt;&gt;</button>\n </div>\n <select class="pagesize">\n{{PAGE_SIZE_OPTIONS}}\n </select>\n {{PAGING_FOOTER_LABEL}} <span class="totalrecscount"></span>\n </td>\n </tr>\n </tfoot>\n</table>'.trim(),t._escapeTableShellText=function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t._renderPageSizeOptions=function(t,e){return t.map(t=>{const n=String(t);return` <option value="${n}"${n===String(e)?" selected":""}>${n}</option>`}).join("\n")},t.renderTableShellHtml=function(e,n){const o=Array.isArray(e.pagingPageSizes)?e.pagingPageSizes:[10,25,50,75],r=null!=e.pagingDefaultSize?e.pagingDefaultSize:o[0],a=t._escapeTableShellText(e.emptyRowMessage||t.DEFAULT_EMPTY_ROW_MESSAGE),i=t._escapeTableShellText(e.pagingFooterLabel||"records per page. Total");return(n||t.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,a).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(r)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,t._renderPageSizeOptions(o,r)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,i)},t.createTableShell=function(e){const n=t.renderTableShellHtml(e),o=$.parseHTML(n,document,!0),r=$(o).filter("table").first();if(!r.length)throw new Error("KGrid TABLE_SHELL_TEMPLATE must contain a root <table> element");return e.tableAttrs&&t.isPlainObject(e.tableAttrs)&&(Object.keys(e.tableAttrs).forEach(t=>{"class"!==t&&r.attr(t,e.tableAttrs[t])}),"string"==typeof e.tableAttrs.class&&e.tableAttrs.class&&r.addClass(e.tableAttrs.class)),r},t.mountTableShell=function(e,n){const o=e.find("table.custom-table, table").first();if(o.length)return o;const r=t.getTableInteractionHost(e);r.hasClass("custom-table-shell")||r.addClass("custom-table-shell");const a=t.createTableShell(n);return r.append(a),a}}(window.KGrid),function(t){t._fieldTypes=Object.create(null),t._configuredCustomInputTypeNames=[],t.registerFieldType=function(e,n,o){if(!e||"string"!=typeof e)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+e+"): plugin.create is required");if(t._fieldTypes[e]&&(!o||!o.overwrite))throw new Error("Field type already registered: "+e);return t._fieldTypes[e]=Object.assign({name:e},n),t},t.unregisterFieldType=function(e){return e&&t._fieldTypes[e]&&delete t._fieldTypes[e],t},t.getFieldType=function(e){return e&&t._fieldTypes[e]||null},t.listFieldTypes=function(){return Object.keys(t._fieldTypes)},t.createFieldInput=function({mode:e,col:n,config:o}){const r=o.type??"text",a=t.getFieldType(r);if(!a)return null;"function"==typeof a.validate&&a.validate(o,e,n);const i=a.create({mode:e,col:n,config:o});if(!i||!i.$input||!i.$input.length)throw new Error('Field type "'+r+'" create() must return { $input: jQuery }');return i.$input.attr("data-type",r),i},t.mountField=function(e){const n=e.config?.type??e.type,o=t.getFieldType(n);o&&"function"==typeof o.mount&&o.mount(e)},t.resolveFilterEvents=function({plugin:t,$input:e,createResult:n}){let o;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?o=n.filterEvents:t&&Object.prototype.hasOwnProperty.call(t,"filterEvents")&&(o=t.filterEvents),!1===o||null===o?null:"string"==typeof o&&o.trim()?o.trim():e.is("select")?"change":"input"},t.normalizeFilterDebounceMs=function(t,e){if(!1===t)return 0;if(void 0===t)return e;if(null===t)return e;const n=Number(t);return!Number.isFinite(n)||n<0?0:n},t.resolveFilterDebounceMs=function({filterConfig:e,plugin:n}){return e&&Object.prototype.hasOwnProperty.call(e,"debounceMs")&&null!==e.debounceMs?t.normalizeFilterDebounceMs(e.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?t.normalizeFilterDebounceMs(n.filterDebounceMs,0):t.normalizeFilterDebounceMs(t._config.filterDebounceMs,0)},t.shouldDebounceFilterSubmit=function(t,e){return!(!e||e<=0)&&!!t},t.bindFieldFilterSubmit=function(e,n,o){const r=t.getFieldType(e);r&&"function"==typeof r.bindFilterSubmit&&r.bindFilterSubmit(n,o)},t.bindFilterInputEvents=function({type:e,$input:n,onSubmit:o,createResult:r,filterConfig:a}){const i=e?t.getFieldType(e):null,l=t.resolveFilterEvents({plugin:i,$input:n,createResult:r}),s=t.resolveFilterDebounceMs({filterConfig:a,plugin:i}),u=t.wrapFilterSubmitHandler(n,o,l,s);l&&n.on(l,u),t.bindFieldFilterSubmit(e,n,u)},t.isPluggableFieldType=function(e){return!!t.getFieldType(e)},t.inputType=function(t,e){if("function"!=typeof t)throw new TypeError("inputType(mount, opts): mount must be a function");if(!e||"string"!=typeof e.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:e.filterEvents,filterDebounceMs:e.filterDebounceMs,validate:e.validate,create({mode:t}){const n=$(e.element);return!e.formInputClass||"insert"!==t&&"update"!==t||n.addClass(e.formInputClass),{$input:n,skipValueAttr:!!e.skipValueAttr}},mount(e){t(e.$input,e.config?.options??e.config,e)},bindFilterSubmit:e.bindFilterSubmit}},t._getCustomInputTypesConfig=function(){return t._config.customInputTypes??t._config.fieldTypes??null},t._syncCustomInputTypes=function(){const e=t._getCustomInputTypesConfig(),n=e&&"object"==typeof e?Object.keys(e).filter(t=>null!=e[t]):[];t._configuredCustomInputTypeNames.forEach(e=>{n.includes(e)||t.unregisterFieldType(e)}),n.forEach(n=>{const o=e[n];if(!o||"object"!=typeof o||"function"!=typeof o.create){if("function"==typeof o)throw new Error("customInputTypes."+n+' is a function — use a plugin, e.g. KGrid.select2(fn) or KGrid.inputType(fn, { element: "..." })');throw new TypeError("customInputTypes."+n+" must be a plugin with create()")}t.registerFieldType(n,o,{overwrite:!0})}),t._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(t){const e="kgrid-multi-select-value",n=";";function o(t,e,n){if(!t.length)return n;if(1===t.length){const n=e.find(function(e){return e.value===t[0]});return n?n.label:t[0]}return t.length+" selected"}function r(r,a,i){const l=a.separator||n,s=a.options||[],u=function(t){return null!=t.placeholder&&""!==t.placeholder?String(t.placeholder):"All"}(a),c="filter"===i;r.data("kgridMultiSep",l),r.addClass(e);const d=$("<div>").addClass("kgrid-multi-select").attr("data-mode",i),f=$("<div>").addClass("kgrid-multi-select-panel");let p=null;function m(){const e=t.parseMultiSelectValue(r[0].value,l);f.find("input[type='checkbox']").each(function(){this.checked=-1!==e.indexOf(this.value)}),p&&p.text(o(e,s,u))}function g(t){p&&(t?(f.appendTo(document.body),f.addClass("kgrid-multi-select-panel-floating"),f.removeAttr("hidden"),d.addClass("kgrid-multi-select-open"),p.attr("aria-expanded","true"),h()):(f.attr("hidden","hidden"),d.removeClass("kgrid-multi-select-open"),p.attr("aria-expanded","false"),f.css({position:"",top:"",left:"",width:"",minWidth:"",maxWidth:"",zIndex:""}),f.removeClass("kgrid-multi-select-panel-floating"),f.insertAfter(p)))}function h(){if(!p)return;const t=p[0].getBoundingClientRect(),e=Math.max(t.width,192);let n=t.left;const o=window.innerWidth-e-8;n>o&&(n=Math.max(8,o));let r=t.bottom+2;const a=Math.min(224,28*s.length+16);r+a>window.innerHeight-8&&t.top>a+8&&(r=t.top-a-2),f.css({position:"fixed",top:r+"px",left:n+"px",width:e+"px",minWidth:e+"px",maxWidth:"min(18rem, calc(100vw - 16px))",zIndex:1080})}c?(p=$("<button>").attr({type:"button","aria-expanded":"false"}).addClass("kgrid-multi-select-toggle form-select form-select-sm"),f.attr("hidden","hidden"),d.append(p,f)):(d.addClass("kgrid-multi-select-open"),d.append(f)),s.forEach(function(e,n){const o="kgrid_ms_"+t.uuid()+"_"+n,r=$("<label>").addClass("kgrid-multi-select-option").attr("for",o);$("<input>").attr({type:"checkbox",id:o,value:e.value,class:"kgrid-multi-select-check"}).appendTo(r),$("<span>").addClass("kgrid-multi-select-label").text(e.label).appendTo(r),f.append(r)}),r.before(d),d.append(r);const y=".kgridMultiSelect_"+t.uuid();f.on("change","input[type='checkbox']",function(){!function(t){const e=[];f.find("input[type='checkbox']:checked").each(function(){e.push(this.value)});const n=e.join(l);r[0].value!==n&&(r[0].value=n,t&&r.trigger("change")),p&&p.text(o(e,s,u))}(!0)}),r.on("kgrid:multiselect:set",function(){m()}),p&&(p.on("click",function(t){t.preventDefault(),t.stopPropagation(),g(!d.hasClass("kgrid-multi-select-open"))}),$(document).on("mousedown"+y,function(t){d.hasClass("kgrid-multi-select-open")&&($(t.target).closest(d).length||$(t.target).closest(f).length||g(!1))}),$(window).on("resize"+y+" scroll"+y,function(){d.hasClass("kgrid-multi-select-open")&&h()}));const b=function(){const t=r.prop("form")||r[0]&&r[0].form;t&&$(t).off("reset"+y).on("reset"+y,function(){setTimeout(m,0)})};return b(),setTimeout(b,0),m(),d}t.normalizeMultiSelectValue=function(t,e){const o=e||n;return null==t||""===t?"":Array.isArray(t)?t.filter(function(t){return null!=t&&""!==t}).map(String).join(o):String(t)},t.parseMultiSelectValue=function(e,o){const r=t.normalizeMultiSelectValue(e,o);return r?r.split(o||n).filter(Boolean):[]},function(){const o=$.valHooks.hidden||{};$.valHooks.hidden={get:function(t){return t&&t.classList&&t.classList.contains(e)?t.value:o.get?o.get(t):void 0},set:function(r,a){if(r&&r.classList&&r.classList.contains(e)){const e=$(r).data("kgridMultiSep")||n;return r.value=t.normalizeMultiSelectValue(a,e),$(r).triggerHandler("kgrid:multiselect:set"),!0}return o.set?o.set(r,a):void 0}}}(),t.registerFieldType("multi_select",{filterEvents:"change",filterDebounceMs:0,validate(t,e){!function(t,e){if(!Array.isArray(t.options))throw new Error("multi_select requires an options array ("+e+"): "+JSON.stringify(t,null,2));t.options.forEach(function(e){if(!e||"string"!=typeof e.label||"string"!=typeof e.value)throw new Error("multi_select options need string label and value: "+JSON.stringify(t,null,2))})}(t,e)},create({config:t}){const n=$("<input type='hidden'>").addClass(e);return t.separator&&n.data("kgridMultiSep",t.separator),{$input:n,skipValueAttr:!0}},mount(t){if(r(t.$input,t.config||{},t.mode),"update"===t.mode&&t.item&&t.col&&t.col.name){const e=t.item.attributes?t.item.attributes[t.col.name]:null;null!=e&&""!==e&&t.$input.val(e)}}});const a="kgrid-date-range-value";function i(t,e,n){const o=t&&t[e];return null!=o&&""!==o?String(o):n}t.dateRangeCalendarDate=function(t){if(null==t||""===t)return"";const e=/^(\d{4}-\d{2}-\d{2})/.exec(String(t).trim());return e?e[1]:""},t.dateRangeEndValue=function(t){return t?t+" 23:59:59":""},t.normalizeDateRangeDefault=function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return{from:"",to:""};let n=t.dateRangeCalendarDate(e.from),o=t.dateRangeCalendarDate(e.to);return n&&o&&o<n&&(o=n),{from:n,to:o}},t.syncDateRangeVisible=function(e){if(!e||!e.getAttribute)return;const n=e.getAttribute("data-kgrid-date-range"),o=n&&e.ownerDocument.getElementById(n);if(!o)return;const r=e.ownerDocument.getElementById(n+"_panel");function a(t){return o.querySelector(t)||r&&r.querySelector(t)}const i=a("to"===e.getAttribute("data-kgrid-date-bound")?".kgrid-date-range-to":".kgrid-date-range-from");if(!i)return;const l=t.dateRangeCalendarDate(e.value);i.value!==l&&(i.value=l);const s=o.querySelector(".kgrid-date-range-display");if(!s)return;const u=a(".kgrid-date-range-from"),c=a(".kgrid-date-range-to"),d=function(t,e){function n(t){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t||"");return e?e[3]+"."+e[2]+"."+e[1]:""}const o=n(t),r=n(e);if(o&&r)return o+" – "+r;if(o)return o+" –";if(r)return"– "+r;return""}(u&&u.value,c&&c.value);s.value!==d&&(s.value=d);const f=o.querySelector(".kgrid-date-range-clear");f&&(d?(f.removeAttribute("hidden"),o.classList.add("kgrid-date-range-has-value")):(f.setAttribute("hidden","hidden"),o.classList.remove("kgrid-date-range-has-value")))},t.applyDateRangeDefault=function(e,n,o){const r=t.normalizeDateRangeDefault(o);if(!r.from&&!r.to)return;const a=t.filterFormFields(e,n);function i(t,e){if(!e)return;const n=a.filter(function(){return $(this).attr("data-operator")===t});n.length&&!n.val()&&(n.val(e),n[0]&&(n[0].defaultValue=n[0].value))}i(">=",r.from),i("<=",r.to)},function(){const e=$.valHooks.text||{};$.valHooks.text={get:function(t){return t&&t.classList&&t.classList.contains(a)?t.value:e.get?e.get(t):void 0},set:function(n,o){if(n&&n.classList&&n.classList.contains(a)){const e=t.dateRangeCalendarDate(o),r=n.getAttribute("data-kgrid-date-bound");return n.value="to"===r?t.dateRangeEndValue(e):e,t.syncDateRangeVisible(n),!0}return e.set?e.set(n,o):void 0}}}(),t.registerFieldType("date_range",{filterEvents:"change",filterDebounceMs:0,validate(t,e){if("filter"!==e)throw new Error("date_range is only valid as a filter")},create(){const t=$("<input type='text' autocomplete='off'>").addClass(a).attr("data-operator",">=").attr("data-kgrid-date-bound","from").attr("tabindex","-1").attr("aria-hidden","true"),e=$("<input type='text' autocomplete='off'>").addClass(a).attr("data-operator","<=").attr("data-kgrid-date-bound","to").attr("tabindex","-1").attr("aria-hidden","true");return t.data("kgridDateRangeTo",e),{$input:t,skipValueAttr:!0}},mount(e){!function(e,n){const o=e.data("kgridDateRangeTo"),r="kgrid_dr_"+t.uuid(),a=i(n,"fromLabel","From"),l=i(n,"toLabel","To"),s=n&&null!=n.placeholder&&""!==n.placeholder?String(n.placeholder):a+" – "+l,u=$("<div>",{class:"kgrid-date-range",id:r}),c=r+"_panel",d=$("<input type='text' readonly autocomplete='off' class='form-control form-control-sm kgrid-date-range-display'/>").attr("placeholder",s).attr("role","button").attr("aria-haspopup","dialog").attr("aria-expanded","false").attr("aria-controls",c),f=$("<button>",{type:"button",class:"kgrid-date-range-clear",hidden:"hidden","aria-label":"Clear",text:"×"}),p=$("<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-from'/>"),m=$("<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-to'/>"),g=$("<div>",{class:"kgrid-date-range-panel",id:c,hidden:"hidden",role:"dialog","aria-label":s});function h(t,n,r){t&&n&&n<t&&(n=t),p.val(t||""),m.val(n||""),e.val(t||""),o.val(n||""),r&&(e[0]&&(e[0].defaultValue=e[0].value),o[0]&&(o[0].defaultValue=o[0].value))}function y(t){t?(g.appendTo(document.body),g.addClass("kgrid-date-range-panel-floating"),g.removeAttr("hidden"),u.addClass("kgrid-date-range-open"),d.attr("aria-expanded","true"),b()):(g.attr("hidden","hidden"),u.removeClass("kgrid-date-range-open"),d.attr("aria-expanded","false"),g.css({position:"",top:"",left:"",width:"",zIndex:""}),g.removeClass("kgrid-date-range-panel-floating"),g.insertAfter(f))}function b(){const t=d[0].getBoundingClientRect(),e=Math.min(Math.max(t.width,320),window.innerWidth-16);let n=t.left;const o=window.innerWidth-e-8;n>o&&(n=Math.max(8,o)),g.css({position:"fixed",top:t.bottom+2+"px",left:n+"px",width:e+"px",zIndex:1080});const r=g[0].offsetHeight;let a=t.bottom+2;a+r>window.innerHeight-8&&t.top>r+8&&(a=t.top-r-2),g.css("top",a+"px")}g.append($("<label>",{class:"kgrid-date-range-bound"}).append($("<span>",{class:"kgrid-date-range-label",text:a}),p),$("<label>",{class:"kgrid-date-range-bound"}).append($("<span>",{class:"kgrid-date-range-label",text:l}),m)),u.append(d,f,g),e.before(u),e.attr("data-kgrid-date-range",r),o.attr("data-kgrid-date-range",r),u.append(e,o),p.add(m).on("change",function(){h(p.val()||"",m.val()||"",!1),e.trigger("change")}),d.on("click",function(t){t.preventDefault(),y(!u.hasClass("kgrid-date-range-open"))}),d.on("keydown",function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),y(!u.hasClass("kgrid-date-range-open")))}),f.on("click",function(t){t.preventDefault(),t.stopPropagation(),h("","",!1),e.trigger("change"),y(!1)});const w=".kgridDateRange_"+t.uuid();$(document).on("mousedown"+w,function(t){u.hasClass("kgrid-date-range-open")&&($(t.target).closest(u).length||$(t.target).closest(g).length||y(!1))}),$(document).on("keydown"+w,function(t){"Escape"===t.key&&u.hasClass("kgrid-date-range-open")&&y(!1)}),$(window).on("resize"+w+" scroll"+w,function(){u.hasClass("kgrid-date-range-open")&&b()});const v=function(){const n=e.prop("form")||e[0]&&e[0].form;n&&$(n).off("reset"+w).on("reset"+w,function(){setTimeout(function(){t.syncDateRangeVisible(e[0]),t.syncDateRangeVisible(o[0])},0)})};e.data("kgridDateRangeBindReset",v),v(),setTimeout(v,0);const C=t.normalizeDateRangeDefault(t.filterDefaultValue?t.filterDefaultValue(n&&n.default):n&&n.default);(C.from||C.to)&&h(C.from,C.to,!0)}(e.$input,e.config||{})}})}(window.KGrid),function(t){t.resolveDefaultInteraction=function(t){return"edit"===t.defaultInteraction||"view"===t.defaultInteraction?t.defaultInteraction:!0===t.editmode?"edit":(t.editmode,"view")},t.getTableInteractionHost=function(t){if(t.hasClass("custom-table-shell"))return t;const e=t.find(".custom-table-shell").first();return e.length?e:t},t.applyInteraction=function(e,n,o){const r=t.getTableInteractionHost(e),a="edit"===n?"edit":"view";r.attr("data-interaction",a),o&&"object"==typeof o?(void 0!==o.create&&r.attr("data-allow-insert",o.create?"true":"false"),void 0!==o.update&&r.attr("data-allow-update",o.update?"true":"false"),void 0!==o.delete&&r.attr("data-allow-delete",o.delete?"true":"false"),void 0!==o.clone&&r.attr("data-allow-clone",o.clone?"true":"false")):"edit"===a&&r.removeAttr("data-allow-insert data-allow-update data-allow-delete data-allow-clone")}}(window.KGrid),function(t){t.setupLabelsHeader=function(e,n){const o=e.children("tr"),r=o.children(),a=r.first().clone(!0);r.remove();return[...n.columns].forEach(e=>{if(e.hidden)return;let n=a.clone(!0);t.applyColumnDomAttrs(n,e),t.applyColumnCellMeta(n,e);const r=e.label??"";if(!e.features?.sort){const a=n.empty().html(r);return""!==r&&a.attr("title",r),t.applyColumnCellMeta(a,e),void o.append(a)}if(!e.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(e,null,2));const i=n.find("span.column-label").text(r);""!==r&&i.attr("title",r),n.children("a").attr("data-sortfld",e.name),n.appendTo(o)}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(o),o}}(window.KGrid),function(t){const e="kgridFilterDebounceTimer";t.cancelFilterSubmit=function(t){const n=t.data(e);n&&(clearTimeout(n),t.removeData(e))},t.cancelFilterDebounces=function(e){const n=$(e).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){t.cancelFilterSubmit($(this))})},t.flushFilterSubmit=function(t){const n=t.data(e);if(!n)return;clearTimeout(n),t.removeData(e);const o=t[0]&&t[0].form;o&&$(o).trigger("submit")},t.wrapFilterSubmitHandler=function(n,o,r,a){if(!t.shouldDebounceFilterSubmit(r,a))return o;const i=a;return function(){t.cancelFilterSubmit(n);const r=setTimeout(function(){n.removeData(e),o.call(this)}.bind(this),i);n.data(e,r)}},t.filterDefaultValue=function(t){return null!=t&&"object"==typeof t&&null!=t.value?t.value:t},t.columnFilterPersisted=function(t){const e=t&&t.filter?t.filter:{};return!(!t||!t.hidden&&"hidden"!==e.type&&!e.persist)},t.ensureFilterField=function(t,e,n,o){if(!t||!e||null==n||""===n)return null;let r=t.elements&&t.elements.namedItem(e);return r&&null!=r.length&&!r.tagName&&(r=r[0]),r&&r.tagName||(r=document.createElement("input"),r.type="hidden",r.name=e,t.appendChild(r)),r.setAttribute("data-operator",o||"="),r.value=String(n),r.defaultValue=String(n),r},t.applyColumnDefaultFilters=function(e,n){e&&n&&n.forEach(function(n){if(!n.name||n.features&&!1===n.features.filter)return;const o=n.filter;if(!o||null==o.default||""===o.default)return;const r=t.filterDefaultValue(o.default);if(null==r||""===r)return;if("date_range"===o.type)return void t.applyDateRangeDefault(e,n.name,r);const a=o.operator||(t.columnFilterPersisted(n)?"=":"~=~"),i=t.filterFormField(e,n.name);!n.hidden&&"hidden"!==o.type&&i.length?i.val()||(i.val(String(r)),i.attr("data-operator",a)):t.ensureFilterField(e,n.name,r,a)})},t.setupDefaultFilters=function(e,n,o,r){const a=$(e)[0];if(!(a&&n&&n.features&&n.features.filtering))return;const i=n.columns||[];if(t.applyColumnDefaultFilters(a,i),i.some(t.columnFilterPersisted)){let e=!1;$(a).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!e){n.preventDefault(),t.cancelFilterDebounces(a),e=!0;try{a.reset(),t.applyColumnDefaultFilters(a,i),o&&o.filtering&&"function"==typeof o.filtering.handleSubmit?o.filtering.handleSubmit(a):$(a).trigger("submit")}finally{e=!1}}})}if(!o||!o.filtering)return;const l=i.filter(function(e){return e.name&&e.filter&&null!=e.filter.default&&""!==e.filter.default&&t.columnFilterPersisted(e)});if(!l.length)return;const s=String(o.url&&o.url.parameters&&o.url.parameters.filter||"");!l.some(function(e){if(e.filter&&"date_range"===e.filter.type){const n=t.normalizeDateRangeDefault(t.filterDefaultValue(e.filter.default));return!(!n.from||-1!==s.indexOf(e.name+">="))||!(!n.to||-1!==s.indexOf(e.name+"<="))}return-1===s.indexOf(e.name+"=")})||r&&r.skipInitSubmit||o.filtering.handleSubmit(a)},t.setupFilterHeader=function(e,n){if(!n.features||!n.features.filtering)return null;const o=e.find(".thead-filters");o.empty();const r=[...n.columns],a=$("<tr>");a.appendTo(o);const i="filter_form_"+t.uuid(),l=$("<form>").attr("id",i).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(e);return r.forEach(e=>{const n=e.filter||{};if(e.hidden||"hidden"===n.type){if(e.features&&!1===e.features.filter)return;if(!e.name)return;const o=t.filterDefaultValue(n.default);return void(null!=o&&""!==o?t.ensureFilterField(l[0],e.name,o,n.operator||"="):t.columnFilterPersisted(e)&&t.ensureFilterField(l[0],e.name,"",n.operator||"="))}let o,r=$("<th>").appendTo(a).attr("data-label",e.label);if(t.applyColumnCellMeta(r,e),!1===e.features.filter)return;if(!e.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(e,null,2));let s=null;const u=t.createFieldInput({mode:"filter",col:e,config:n});if(u)s=u,o=u.$input,o.appendTo(r),t.mountField({mode:"filter",$input:o,col:e,config:n});else if("select"===n.type){if(!n.options)throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));if(o=$("<select>").addClass("form-select form-select-sm"),!Array.isArray(n.options))throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));n.options.forEach(t=>{if(!t.label||"string"!=typeof t.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(o)}),o.appendTo(r)}else{if(!t.isValidFilterType(n.type))throw new Error("Unknown filter type: "+n.type);o=$(`<input autocomplete='off' type='${n.type}' class='form-control form-control-sm'/>`),o.appendTo(r)}if("date_range"===n.type){r.find("input.kgrid-date-range-value").each(function(){this.setAttribute("form",i),this.setAttribute("name",e.name),l[0].appendChild(this)});const t=o.data("kgridDateRangeBindReset");"function"==typeof t&&t()}else{const r=n.operator||("multi_select"===n.type?"><":void 0);null!=r&&o.attr("data-operator",r),o.attr("form",i),o.attr("name",e.name);const a=t.filterDefaultValue(n.default);if(null!=a&&""!==a&&!o.val()){const e="multi_select"===n.type?t.normalizeMultiSelectValue(a,n.separator):String(a);o.val(e),o.attr("data-default",e),o[0]&&(o[0].defaultValue=e)}}t.bindFilterInputEvents({type:n.type,$input:o,onSubmit:function(){const t=this.form;t&&$(t).trigger("submit")},createResult:s,filterConfig:n})}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(a),l},t.syncFormFiltersToCollectionUrl=function(t,e){if(!t||!e||!e.url)return;e.url.parameters||(e.url.parameters={});const n=[],o=t.elements;if(o){for(let t=0;t<o.length;t++){const e=o[t];if(!e||!e.name)continue;const r=$(e),a=r.val();if(null==a||""===a)continue;const i=r.attr("data-operator")||r.data("operator")||"=";n.push(e.name+i+a)}e.offset=0,n.length?e.url.parameters.filter=n.join(","):delete e.url.parameters.filter}},t.FilterForm=function(e){this.form=$(e)[0],this.filter=(e,n,o="~=~")=>{if(!this.form)return this;let r=t.filterFormField(this.form,e);if(r.length||(t.ensureFilterField(this.form,e,n,o),r=t.filterFormField(this.form,e)),!r.length)return this;t.flushFilterSubmit(r),r.val(n);const a=r.attr("data-operator");return r.attr("data-operator",o),$(this.form).trigger("submit"),r.attr("data-operator",a),this},this.ensure=(e,n,o="=")=>(t.ensureFilterField(this.form,e,n,o),this),this.reset=()=>(this.form&&(t.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(t){t.wrapFlagSwitch=function(t){return t.attr({type:"checkbox",role:"switch",value:"1"}).removeClass("form-control form-input form-control-sm").addClass("form-check-input"),$("<div class='form-check form-switch kgrid-flag-switch mb-0'>").append(t)},t.setupCell=function(e,n){const o=n?n.attr("id"):null,r={...e},a=$("<td>").attr("data-label",e.label);t.applyColumnCellMeta(a,e),t.applyColumnDomAttrs(a,r);let i=$("<div>").addClass("cell-content");if(i.html(r.display.template??`{{${r.name}}}`),i.appendTo(a),null==n||!e.features.update)return i.clone(!0).removeClass("cell-content").addClass("cell-input").appendTo(a),a;if(!r.name)throw new Error("Column must have a name when column.features.update is true: \n"+JSON.stringify(e,null,2));const l=r.update,s=l.type??"text";let u,c=!1;const d=t.createFieldInput({mode:"update",col:e,config:l});if(d)u=d.$input,c=!!d.skipValueAttr;else{switch(s){case"textarea":u=$(`<textarea class='form-input form-control form-control-sm'>{{${l.value??r.name}}}</textarea>`),c=!0;break;case"select":if(u=$("<select class='form-input form-control form-control-sm'/>"),!Array.isArray(l.options))throw new Error("Select column must have an update.options array when column.features.update is true: \n"+JSON.stringify(e,null,2));l.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(u)}),c=!0;break;case"hidden":u=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const t=l.template||r.display.template||`{{${r.name}}}`;return $("<div>").addClass("cell-input").append(t).appendTo(a),a}case"checkbox":u=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),c=!0;break;default:if(!t.isValidInputType(s))throw new Error("Invalid update updateConfig type: "+JSON.stringify(l,null,2));u=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`)}u.attr("data-type",s)}if(l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(t=>u.attr(t,l.attrs[t])),u.attr("form",o),u.attr("name",r.name),!c&&"textarea"!==s){const t=l.value??`{{${r.name}}}`;null!=t&&"object"!=typeof t&&u.attr("value",t)}if(r.hidden)return u.attr("type","hidden").appendTo(n),a;l.disabled&&u.attr("disabled",!0),l.readonly&&u.attr("readonly",!0),l.required&&u.attr("required",!0),l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(t=>u.attr(t,l.attrs[t])),l.disabled||l.readonly||u.attr("onchange","$(this).parents('tr').addClass('editing')");const f="checkbox"===s?t.wrapFlagSwitch(u):u;return $("<div>").addClass("cell-input").append(f).appendTo(a),a}}(window.KGrid),function(t){t.setupNoDataTbody=function(t,e,n){const o=t.find("td").attr("colspan",n);return e.noDataTemplate&&o.html(e.noDataTemplate),o},t.fillDataRow=function(e,n){const o=[...n.columns],r="data_row_form_"+t.uuid()+"_{{this.id}}",a=n.features&&n.features.update?$("<form class='edit-form table-row-form'>").attr("id",r):null;if(o.forEach(n=>{const o=t.setupCell(n,a);n.hidden||o.appendTo(e)}),t.hasActionColumn(n)){const o=$("<td>").addClass("kgrid-row-actions").appendTo(e);t.renderRowActions(o,n,r)}return a&&t.anchorRowForm(a,e),e},t.setupDataBody=function(e,n,o,r,a,i){const l=$("<tr>").appendTo(e);if(n.dataRowAttrs&&"object"!=typeof n.dataRowAttrs)throw new Error("options.dataRowAttrs must be an object");const s={...n.dataRowAttrs??{}};return Object.keys(s).forEach(t=>l.attr(t,s[t])),e.data("emptyview",i),n?.features?.sorting&&e.data("sort",o),a&&e.data("paging",a.find(".pages")).data("pagesizeinp",a.find(".pagesize")).data("totalrecscount",a.find(".totalrecscount")),r&&e.data("filter",r),n.type&&e.data("type",n.type),t.fillDataRow(l,n),e},t.setupPagingFooter=function(e,n,o){return t.log("setupPagingFooter",e,n,o),n.pagingFooterAttrs&&t.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(t=>e.attr(t,n.pagingFooterAttrs[t])),t.log("noVisibleCols",o),e.find("td").attr("colspan",o),e}}(window.KGrid),function(t){t.setupNewRecordForm=function(e,n,o){if(!n.insertFormRow||!t.isPlainObject(n.insertFormRow))return e.find(".before-main-tbody").remove(),void e.find(".after-main-tbody").remove();const r=[...n.columns],a=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(e.find(".after-main-tbody").remove(),a.appendTo(e.find(".before-main-tbody"))):(e.find(".before-main-tbody").remove(),a.appendTo(e.find(".after-main-tbody")));const i="new_record_row_form_"+t.uuid(),l=$("<form class='table-row-form'>").attr("id",i).off("submit").on("submit",e=>{e.preventDefault();const a=t.serializeForm(e.target,r);Object.keys(a).forEach(t=>{r.find(e=>e.name===t)?.insert?.dontsave&&delete a[t]}),o.instance.newItem(a).then(()=>{e.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(a,e.target)}).catch(t.onError)});r.forEach(e=>{if(e.hidden){if(n.features?.create&&e.features?.create){const t=$("<input type='hidden'>").attr("name",e.name).attr("form",i).appendTo(l);e.insert.default&&t.val(e.insert.default)}return}if(!e.features.create){const n=$("<td>").appendTo(a).attr("data-label",e.label);return void t.applyColumnCellMeta(n,e)}const o=e.insert;if(!o||!t.isPlainObject(o))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(e,null,2));if(!o.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(e,null,2));let r;const s=o.type??"text",u=t.createFieldInput({mode:"insert",col:e,config:o});if(u)r=u.$input;else switch(s){case"textarea":r=$("<textarea class='form-input form-control form-control-sm'>");break;case"select":if(r=$("<select class='form-input form-control form-control-sm'/>"),!o.options||!Array.isArray(o.options))throw new Error("Column must have an insert.options array when column.features.insert is true: \n"+JSON.stringify(e,null,2));o.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(r)});break;case"hidden":r=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"checkbox":r=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),r.attr("data-type",s);break;default:if(!t.isValidInputType(s))throw new Error("Invalid type: "+JSON.stringify(o,null,2));r=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`),r.attr("data-type",s)}const c="object"==typeof o.default&&o.default&&null!=o.default.value?o.default.value:o.default;if("checkbox"===s){const e=t.isFlagOn(c);r.prop("checked",e).prop("defaultChecked",e)}else null==o.default||""===o.default||r.val()||String(c).trim()&&(r.val(c).trigger("change"),r[0]&&"defaultValue"in r[0]&&(r[0].defaultValue=r[0].value));if(o.attrs&&"object"==typeof o.attrs&&Object.keys(o.attrs).forEach(t=>r.attr(t,o.attrs[t])),r.attr("form",i).attr("name",e.name),o.disabled&&r.attr("disabled",!0),o.readonly&&r.attr("readonly",!0),o.required&&r.attr("required",!0),o.attrs&&"object"==typeof o.attrs&&Object.keys(o.attrs).forEach(t=>r.attr(t,o.attrs[t])),"hidden"!==o.type){const n="checkbox"===s?t.wrapFlagSwitch(r):r,o=$("<td>").append(n).appendTo(a).attr("data-label",e.label);t.applyColumnCellMeta(o,e)}t.mountField({mode:"insert",$input:r,col:e,config:o,formEl:l[0],rowEl:a[0]}),o.events&&Array.isArray(o.events)&&o.events.forEach(t=>{r.off(t.event).on(t.event,function(e,...n){"function"==typeof t.callback&&t.callback(e,l[0],a[0],...n)})})}),t.anchorRowForm(l,a);const s=$("<td>").addClass("kgrid-row-actions").appendTo(a).attr("data-label","action"),u=$("<div>").addClass("btn-group").appendTo(s);return $("<button>").addClass("btn btn-sm btn-primary new-item-btn").html("<i class='fas fa-plus-square'></i>").attr("form",i).attr("type","submit").appendTo(u),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(l[0],a[0]),a}}(window.KGrid),function(t){t.setupEvents=function(e,n,o,r){const a=e.views[0];a&&a.el&&"function"==typeof t.applyLayoutToRow&&t.applyLayoutToRow(a.el,o.columns),o.columns.forEach(n=>{n.display.events.forEach(t=>{if(!t.selector||!t.event||!t.callback)throw new Error("Invalid event: "+JSON.stringify(t,null,2));a.el.find(t.selector).off(t.event).on(t.event,n=>{if("function"!=typeof t.callback)throw new Error("Event callback must be a function: "+JSON.stringify(t,null,2));t.callback(n,e,a)})}),o.features.update&&n.update.events.forEach(o=>{if(!o.event||!o.callback)throw new Error("Invalid event: "+JSON.stringify(o,null,2));a.el.find("[name='"+n.name+"']").off(o.event).on(o.event,function(n,...r){if(t.log("event",o,n,this,r),"function"!=typeof o.callback)throw new Error("Event callback must be a function: "+JSON.stringify(o,null,2));o.callback(n,e,a,...r)})})}),o.features.update&&(a.el.find("[data-type]").each((n,o)=>{const i=o.getAttribute("data-type");if(!t.isPluggableFieldType(i))return;const l=r.get(o.name);l?.update&&t.mountField({mode:"update",$input:$(o),col:l,config:l.update,item:e,view:a})}),a.el.find("select[data-type='select']").each((t,n)=>{const o=r.get(n.name);if(!o)return;const a=e.attributes[o.name];null!=a&&""!==a&&$(n).val("boolean"==typeof a?String(a):a)}),a.el.find("input[type='checkbox']").each((n,o)=>{const a=r.get(o.name);a&&(o.checked=t.isFlagOn(e.attributes[a.name]))}),a.el.find("form.edit-form").off("submit").on("submit",e=>{const n=e.target;e.preventDefault();const r=$(n).parents("[data-type=item]").data().instance,a=t.serializeForm(n);Object.keys(a).forEach(t=>{o.columns.find(e=>e.name===t)?.update?.dontsave&&delete a[t]}),r.update(a).catch(t.onError)}));const i=t.resolveRowActions(o);t.applyRowActionVisibility(a.el,e,i.menuItems),t.mountRowActionDropdowns(a.el);const l=i.menuItems.some(t=>"clone"===t.action),s=i.menuItems.some(t=>"delete"===t.action);l&&a.el.find(".clone-item").off("click").on("click",t=>{t.preventDefault(),t.stopPropagation(),"function"==typeof o.onClone&&o.onClone(e,a,t)}),s&&a.el.find(".delete-item").off("click").on("click",n=>{n.preventDefault(),n.stopPropagation(),a.el.addClass("confirm-delete");const r=()=>a.el.removeClass("confirm-delete"),l=$(n.currentTarget).closest("[data-kgrid-action-index]").attr("data-kgrid-action-index"),s=null!=l?i.menuItems[Number(l)]:null,u=s&&"string"==typeof s.confirm?s.confirm:null;(u?(e,n)=>t.confirm(u,e,n):(n,r)=>t.runDeleteConfirm({item:e,view:a,options:o},n,r))(()=>{e.delete().catch(t.onError).finally(r)},r)});const u=new Map;i.menuItems.forEach(t=>{t.id&&"function"==typeof t.callback&&u.set(t.id,t.callback)}),u.size&&a.el.find("[data-kgrid-action]").off("click.kgridAction").on("click.kgridAction",t=>{const n=t.currentTarget.getAttribute("data-kgrid-action"),o=u.get(n);o&&(t.preventDefault(),t.stopPropagation(),o(t,e,a))}),"function"==typeof o.onRowFields&&o.onRowFields(e,a,n)}}(window.KGrid),function(t){t.PREFERENCES_VERSION=1,t.localStoragePreferences={get:function(t){try{const e="undefined"!=typeof window?window:globalThis,n=e&&e.localStorage;if(!n)return null;const o=n.getItem(t);return o?JSON.parse(o):null}catch(t){return null}},set:function(t,e){try{const n="undefined"!=typeof window?window:globalThis,o=n&&n.localStorage;if(!o)return;if(null==e)return void o.removeItem(t);o.setItem(t,JSON.stringify(e))}catch(t){}}},t.preferencesStorageFor=function(e){return e&&e.preferencesStorage?e.preferencesStorage:t._config&&t._config.preferencesStorage?t._config.preferencesStorage:t.localStoragePreferences},t.layoutStorageKey=function(t){return"kgrid:"+t+":layout"},t.filtersStorageKey=function(t,e){let n="kgrid:"+t+":filters";return null!=e&&""!==String(e)&&(n+=":"+String(e)),n},t.viewStorageKey=function(t,e){let n="kgrid:"+t+":view";return null!=e&&""!==String(e)&&(n+=":"+String(e)),n},t.chooserColumns=function(t){return(t||[]).filter(function(t){return t&&t.name&&!t.hidden})},t.layoutFromColumns=function(e){return{v:t.PREFERENCES_VERSION,columns:t.chooserColumns(e).map(function(t){return{name:t.name,hidden:!!t.userHidden}})}},t.parseFilterExpression=function(t){const e=String(t||""),n=["~=~",">=","<=","!=","=",">","<"];for(let t=0;t<n.length;t++){const o=n[t],r=e.indexOf(o);if(r>0)return{name:e.slice(0,r),operator:o,value:e.slice(r+o.length)}}return null},t.isUserFilterColumn=function(t){return!(!t||!t.name||t.hidden||t.features&&!1===t.features.filter)},t.readUserFilters=function(e,n){if(!e)return[];const o=[];return(n||[]).forEach(function(n){if(!t.isUserFilterColumn(n))return;let r=t.filterFormFields(e,n.name);if(r.length||(r=t.filterFormField(e,n.name)),!r.length)return;if(r.length>1)return void r.each(function(){const t=$(this),e=t.val();null==e||""===e||Array.isArray(e)&&!e.length||o.push({name:n.name,value:Array.isArray(e)?e:String(e),operator:t.attr("data-operator")||n.filter&&n.filter.operator||">="})});const a=r,i=a.val();if(null==i||""===i||Array.isArray(i)&&!i.length)return;const l=a.attr("data-operator")||n.filter&&n.filter.operator||"~=~";o.push({name:n.name,value:Array.isArray(i)?i:String(i),operator:l})}),o},t.applyUserFilters=function(e,n,o){e&&o&&Array.isArray(o.filters)&&o.filters.forEach(function(o){if(!o||!o.name)return;const r=(n||[]).find(function(t){return t&&t.name===o.name});if(!t.isUserFilterColumn(r))return;if(null==o.value||""===o.value)return;const a=t.filterFormFields(e,o.name);if(a.length>1){if(!o.operator)return;const t=a.filter(function(){return $(this).attr("data-operator")===o.operator});return void(t.length&&t.val(o.value))}let i=t.filterFormField(e,o.name);i.length||(t.ensureFilterField(e,o.name,o.value,o.operator),i=t.filterFormField(e,o.name)),i.length&&(i.val(o.value),o.operator&&i.attr("data-operator",o.operator))})},t.ensureUrlFiltersOnForm=function(e,n){if(!(e&&n&&n.url&&n.url.parameters))return;const o=String(n.url.parameters.filter||"");o&&o.split(",").forEach(function(n){const o=t.parseFilterExpression(n.trim());if(!o||!o.name||""===o.value)return;const r=t.filterFormFields(e,o.name);if(r.length>1){const t=r.filter(function(){return $(this).attr("data-operator")===o.operator});return void(t.length&&!t.val()&&t.val(o.value))}const a=t.filterFormField(e,o.name);return a.length&&a.val()?void 0:a.length?(a.val(o.value),void a.attr("data-operator",o.operator)):void t.ensureFilterField(e,o.name,o.value,o.operator)})},t.preferencesLoadLayout=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.layoutStorageKey(e.storageKey));return n&&n.v===t.PREFERENCES_VERSION&&Array.isArray(n.columns)?n:null},t.preferencesSaveLayout=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.layoutStorageKey(e.storageKey),n)},t.preferencesLoadFilters=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.filtersStorageKey(e.storageKey,e.filterStorageScope));return n&&n.v===t.PREFERENCES_VERSION&&Array.isArray(n.filters)?n:null},t.preferencesSaveFilters=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.filtersStorageKey(e.storageKey,e.filterStorageScope),{v:t.PREFERENCES_VERSION,filters:n||[]})},t.preferencesLoadView=function(e){if(!e||!e.storageKey)return null;const n=t.preferencesStorageFor(e).get(t.viewStorageKey(e.storageKey,e.filterStorageScope));return n&&n.v===t.PREFERENCES_VERSION&&"object"==typeof n?n:null},t.preferencesSaveView=function(e,n){e&&e.storageKey&&t.preferencesStorageFor(e).set(t.viewStorageKey(e.storageKey,e.filterStorageScope),n)},t.sortableColumnNames=function(t){const e=new Set;return(t||[]).forEach(function(t){t&&t.name&&t.features&&t.features.sort&&!t.hidden&&e.add(t.name)}),e},t.sanitizeSort=function(e,n){const o=t.sortableColumnNames(n),r=[];return String(null==e?"":e).split(",").forEach(function(t){const e=/^(-*)([A-Za-z0-9_-]+)$/.exec(String(t).trim());e&&o.has(e[2])&&r.push((e[1].length?"-":"")+e[2])}),r.join(",")},t.collectionSort=function(t){const e=t&&t.url&&t.url.parameters;return e&&null!=e.sort&&""!==e.sort?String(e.sort):""},t.sortDirectionForField=function(t,e){const n=String(t||"").split(",");for(let t=0;t<n.length;t++){const o=/^(-*)([A-Za-z0-9_-]+)$/.exec(n[t].trim());if(o&&o[2]===e)return o[1].length?"desc":"asc"}return null},t.syncSortIndicators=function(e,n){e&&e.length&&e.find("[data-sortfld]").each(function(){const e=$(this),o=e.attr("data-sortfld"),r=t.sortDirectionForField(n,o),a=e.find(".sort-up"),i=e.find(".sort-down"),l=e.find(".sort-default");"asc"===r?(e.data("sortdir","up"),a.show(),i.hide(),l.hide()):"desc"===r?(e.data("sortdir","down"),a.hide(),i.show(),l.hide()):(e.removeData("sortdir"),a.hide(),i.hide(),l.show())})},t.applySavedPageSize=function(t,e,n){if(!t||!t.length||null==n)return!1;const o=String(n);if(!/^\d+$/.test(o)||"0"===o)return!1;const r=(e.pagingPageSizes||[]).map(function(t){return String(t)});if(r.length&&r.indexOf(o)<0)return!1;const a=t.find("select.pagesize");return!!a.length&&(a.val(o),t.find(".pages").attr("data-pagesize",o),!0)},t.applySavedOffset=function(t,e){t&&null!=e&&/^\d+$/.test(String(e))&&("function"!=typeof t.setOffset?t.offset=String(e):t.setOffset(String(e)))},t.applySavedSort=function(e,n,o){if(!(o&&null!=o.sort&&n&&n.features&&n.features.sorting))return;const r=e&&e.url&&e.url.parameters;if(!r)return;const a=t.sanitizeSort(o.sort,n.columns);a?r.sort=a:delete r.sort},t.persistViewState=function(e,n,o){if(!(n&&n.storageKey&&e&&n.features))return;const r=!!n.features.sorting,a=!!n.features.paging;if(!r&&!a)return;const i=t.preferencesLoadView(n)||{},l={v:t.PREFERENCES_VERSION};if(r){const o=e.url&&e.url.parameters;o&&Object.prototype.hasOwnProperty.call(o,"sort")?l.sort=t.sanitizeSort(o.sort,n.columns):"string"==typeof i.sort?l.sort=i.sort:l.sort=""}if(a){const t=o&&o.length?o.find("select.pagesize").val():null,r=(n.pagingPageSizes||[]).map(function(t){return String(t)});null!=t&&/^\d+$/.test(String(t))&&"0"!==String(t)&&(!r.length||r.indexOf(String(t))>=0)?l.pageSize=Number(t):null!=i.pageSize&&(l.pageSize=i.pageSize);const a=null!=e.offset?String(e.offset):"0";l.offset=/^\d+$/.test(a)?Number(a):0}t.preferencesSaveView(n,l)},t.bindViewPersistence=function(e,n,o){e&&"function"==typeof e.on&&n&&n.storageKey&&n.features&&(n.features.sorting||n.features.paging)&&e.on("load",function(){t.persistViewState(e,n,o),n.features.sorting&&t.syncSortIndicators(o,t.collectionSort(e))})},t.reorderColumns=function(t,e){const n=new Map,o=[];(t||[]).forEach(function(t,e){t&&t.hidden?o.push({col:t,index:e}):t&&t.name&&n.set(t.name,t)});const r=[];(e||[]).forEach(function(t){n.has(t)&&(r.push(n.get(t)),n.delete(t))}),n.forEach(function(t){r.push(t)});const a=r.slice();return o.forEach(function(t){a.splice(Math.min(t.index,a.length),0,t.col)}),a},t.columnDefaultUserHidden=function(t){return!(!t||!t.defaultHidden||t.locked||t.hidden)},t.mergeLayoutIntoColumns=function(e,n){const o=(e||[]).slice();o.forEach(function(e){e&&!e.hidden&&(e.userHidden=t.columnDefaultUserHidden(e))});const r=t.chooserColumns(o),a=new Map(r.map(function(t){return[t.name,t]})),i=[],l=new Set;(n&&Array.isArray(n.columns)?n.columns:[]).forEach(function(t){if(!t||!t.name||!a.has(t.name))return;const e=a.get(t.name);e.userHidden=!!t.hidden&&!e.locked,i.push(t.name),l.add(t.name)}),r.forEach(function(t){l.has(t.name)||i.push(t.name)});const s=t.reorderColumns(o,i),u=t.chooserColumns(s);if(u.length&&u.every(function(t){return t.userHidden})){(u.find(function(t){return!t.locked})||u[0]).userHidden=!1}return s},t.applyLayoutToRow=function(e,n){if(!e||!e.length)return;const o=t.chooserColumns(n),r=o.map(function(t){return t.name}),a={};o.forEach(function(t){t.userHidden&&(a[t.name]=!0)});const i=e.children(".kgrid-row-actions"),l={};e.children("[data-name]").each(function(){l[this.getAttribute("data-name")]=this}),r.forEach(function(t){const n=l[t];n&&(i.length?$(n).insertBefore(i):e.append(n),n.classList.toggle("kgrid-user-hidden",!!a[t]))})},t.applyLayoutToDom=function(e,n,o){if(!e||!e.length)return;e.find(".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr").each(function(){t.applyLayoutToRow($(this),n)});const r=t.layoutVisibleColumns(n),a=e.find(".kgrid-row-actions").length>0;t.syncActionColumnColgroup(e,r.length,a,o,r),t.syncSpanningCells(e,t.participatingColumnCount(n,a))},t.refreshCollectionTemplate=function(e,n){if(!e||!e.instance||"function"!=typeof t.fillDataRow)return;const o=t.getKViews(n&&n.kviews);if(!o||"function"!=typeof o.template)return;const r=$("<tr>");n.dataRowAttrs&&t.isPlainObject(n.dataRowAttrs)&&Object.keys(n.dataRowAttrs).forEach(function(t){r.attr(t,n.dataRowAttrs[t])}),t.fillDataRow(r,n);const a=$("<div>").append(r).html(),i=o.template(a);e.instance.template=i,(e.instance.items||[]).forEach(function(t){(t.views||[]).forEach(function(t){t.template=i})})},t.setupFilterPersistence=function(e,n){e&&n&&n.storageKey&&n.features&&n.features.filtering&&$(e).off("submit.kgridFilterPrefs").on("submit.kgridFilterPrefs",function(){t.preferencesSaveFilters(n,t.readUserFilters(e,n.columns))})},t.applyColumnLayout=function(e,n,o){n.columns=t.mergeLayoutIntoColumns(n.columns,o);const r=e.$host.find("table").first();if(t.applyLayoutToDom(r,n.columns,n),t.refreshCollectionTemplate(e,n),"function"==typeof t.renderColumnChooserPanel){const o=e.$host.find(".kgrid-column-chooser-panel");o.length&&t.renderColumnChooserPanel(o,n,e)}return t.layoutFromColumns(n.columns)}}(window.KGrid),function(t){function e(e){const n=[];return e.find(".kgrid-column-chooser-list li[data-name]").each(function(){const t=this.getAttribute("data-name"),e=$(this).find("input[type='checkbox']").prop("checked");n.push({name:t,hidden:!e})}),{v:t.PREFERENCES_VERSION,columns:n}}t.renderColumnChooserPanel=function(n,o,r){n.empty();const a=$("<ul>").addClass("kgrid-column-chooser-list").appendTo(n);t.chooserColumns(o.columns).forEach(function(t){const e=$("<li>").attr("draggable","true").attr("data-name",t.name).appendTo(a);$("<span>").addClass("kgrid-column-chooser-handle").attr("aria-hidden","true").text("⋮⋮").appendTo(e);const n=$("<label>").appendTo(e),o=$("<input>").attr("type","checkbox").prop("checked",!t.userHidden).appendTo(n);t.locked&&o.prop("disabled",!0).attr("title","This column cannot be hidden"),n.append(document.createTextNode(" "+(t.label||t.name)))}),$("<button>").attr("type","button").addClass("btn btn-sm btn-outline-secondary kgrid-column-chooser-reset").text(o.columnChooserResetLabel||"Reset columns").appendTo(n),n.off("change.kgridChooser").on("change.kgridChooser","input[type='checkbox']",function(){const t=e(n);(function(t){return t.columns.filter(function(t){return!t.hidden}).length})(t)<1?this.checked=!0:r.setLayout(t)}),n.off("click.kgridChooserReset").on("click.kgridChooserReset",".kgrid-column-chooser-reset",function(){r.resetLayout()});let i=null;a.off(".kgridChooserDrag"),a.on("dragstart.kgridChooserDrag","li",function(t){i=this,$(this).addClass("kgrid-column-chooser-dragging"),t.originalEvent&&t.originalEvent.dataTransfer&&(t.originalEvent.dataTransfer.effectAllowed="move",t.originalEvent.dataTransfer.setData("text/plain",this.getAttribute("data-name")))}),a.on("dragend.kgridChooserDrag","li",function(){$(this).removeClass("kgrid-column-chooser-dragging"),i=null}),a.on("dragover.kgridChooserDrag","li",function(t){if(t.preventDefault(),!i||i===this)return;const e=this.getBoundingClientRect(),n=e.top+e.height/2;(t.originalEvent?t.originalEvent.clientY:0)<n?this.parentNode.insertBefore(i,this):this.parentNode.insertBefore(i,this.nextSibling)}),a.on("drop.kgridChooserDrag","li",function(t){t.preventDefault(),r.setLayout(e(n))})},t.setupColumnChooser=function(e,n,o){if(!n.features||!n.features.columnChooser)return;const r=t.getTableInteractionHost(e);r.find(".kgrid-column-chooser").remove();const a=r.find(".thead-labels th.kgrid-row-actions").first();if(!a.length)return;r.attr("data-has-column-chooser","true");const i=n.columnChooserLabel||"Columns",l=$("<div>").addClass("kgrid-column-chooser"),s=$("<button>").attr("type","button").addClass("kgrid-column-chooser-toggle btn btn-sm btn-outline-secondary").attr("title",i).attr("aria-label",i).attr("aria-expanded","false").attr("aria-haspopup","true").html('<i class="fas fa-cog" aria-hidden="true"></i>'),u=$("<div>").addClass("kgrid-column-chooser-panel").attr("hidden","hidden");function c(){const t=s[0].getBoundingClientRect();u.css({position:"fixed",top:Math.round(t.bottom+2)+"px",left:"auto",right:Math.round(window.innerWidth-t.right)+"px",zIndex:1055})}function d(){u.attr("hidden","hidden"),s.attr("aria-expanded","false"),u.css({top:"",left:"",right:"",position:"",zIndex:""})}l.append(s,u),a.append(l),t.renderColumnChooserPanel(u,n,o),s.on("click",function(t){t.stopPropagation(),u.attr("hidden")?(u.removeAttr("hidden"),s.attr("aria-expanded","true"),c()):d()});const f="kgridChooser"+t.uuid();$(window).on("scroll."+f+" resize."+f,function(){u.attr("hidden")||c()}),$(document).on("pointerdown."+f,function(t){if(!document.body.contains(l[0]))return $(document).off("."+f),void $(window).off("."+f);l[0].contains(t.target)||d()})}}(window.KGrid),function(t){t.init=async function(e,n){const o=t.resolveHostElement(e),r={...t.protoOptions,...n},a=t.mountTableShell(o,r);t.log("table config options",r);const i=t.resolveDefaultInteraction(r);t.applyInteraction(o,i);const l={$host:o,instance:null,filterForm:null,find:t=>o.find(t),setInteraction:(e,n)=>(t.applyInteraction(o,e,n),l),getInteraction:()=>"edit"===t.getTableInteractionHost(o).attr("data-interaction")?"edit":"view",setEditMode(t){if("boolean"!=typeof t)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return l.setInteraction(t?"edit":"view")},toggleEditMode:t=>(null!=t&&"object"==typeof t&&"function"==typeof t.preventDefault&&(t=void 0),"boolean"==typeof t?l.setInteraction(t?"edit":"view"):l.setInteraction("edit"===l.getInteraction()?"view":"edit")),getLayout:()=>t.layoutFromColumns(r.columns),setLayout:e=>(t.applyColumnLayout(l,r,e),t.preferencesSaveLayout(r,l.getLayout()),l.getLayout()),resetLayout(){const e=new Map;return r.columns.forEach(function(t){t&&t.name&&e.set(t.name,t)}),r.columns=s.map(function(t){return e.get(t)}).filter(Boolean),t.preferencesSaveLayout(r,null),t.applyColumnLayout(l,r,null),l.getLayout()}};r.columns=(r.columns||[]).map(e=>t.normalizeColumnConfig(e));const s=r.columns.map(function(t){return t.name});r.columns=t.mergeLayoutIntoColumns(r.columns,t.preferencesLoadLayout(r));const u=r.handlers??{};if(delete r.handlers,"string"==typeof r.onClone){const t=u[r.onClone]||r.functions&&r.functions[r.onClone];if(!t||"function"!=typeof t)throw new Error("onClone handler "+r.onClone+" not found or is not a function");r.onClone=t}t.resolveRowActions(r,u);{const e=r._resolvedRowActions;t.getTableInteractionHost(o).attr("data-has-row-menu",e&&e.menuItems&&e.menuItems.length?"true":"false")}r.columns.forEach(t=>{["insert","update","display"].forEach(e=>{const n=t[e].events;if(!n||!Array.isArray(n))throw new Error("Column "+t.name+" events are not an array");n.forEach(e=>{if("string"==typeof e.callback){const n=u[e.callback]||r.functions&&r.functions[e.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+e.callback+" not found for column "+t.name+" or is not a function");e.callback=n}else if("function"!=typeof e.callback)throw new Error("Event callback must be a function for column "+t.name)})});const e=t.display;e&&e.events&&Array.isArray(e.events)&&e.events.forEach(t=>{if("string"==typeof t.callback){const e=u[t.callback]||r.functions&&r.functions[t.callback];e&&"function"==typeof e&&(t.callback=e)}})});const c=new Map;r.columns.forEach(t=>{c.set(t.name,t)});const d=t.setupLabelsHeader(a.find(".thead-labels"),r),f=t.hasActionColumn(r),p=t.layoutVisibleColumns(r.columns),m=t.participatingColumnCount(r.columns,f);t.syncActionColumnColgroup(a,p.length,f,r,p);const g=r.filterForm??t.setupFilterHeader(a,r);let h;const y=r.storageKey&&r.features&&(r.features.sorting||r.features.paging)?t.preferencesLoadView(r):null;r.features&&r.features.paging?(h=t.setupPagingFooter(a.find(".paging-footer"),r,m),y&&t.applySavedPageSize(h,r,y.pageSize)):(h=null,a.find(".paging-footer").remove());const b=t.setupNoDataTbody(a.find(".no-data-tbody"),r,m);r.features&&r.features.create&&t.setupNewRecordForm(a,r,l),l.filterForm=new t.FilterForm(g);const w=t.setupDataBody(a.find(".main-tbody"),r,d,g,h,b),v={dontload:!0,setAttrAsId:r.setAttrAsId??!1,itemListeners:{afterrender:e=>t.setupEvents(e,l.find("table"),r,c)}},C=t.getKViews(r.kviews);if(!C)throw new Error(t.KVIEWS_MISSING_MSG);if(l.instance=await C.createCollectionInstance(w,v),r.url){l.instance.setUrl(r.url),r.deleteUrl&&(t.log("set deleteUrl",r.deleteUrl),l.instance.setUrl(r.deleteUrl,"delete")),r.updateUrl&&(t.log("set updateUrl",r.updateUrl),l.instance.setUrl(r.updateUrl,"update"));const e=r.insertUrl||r.url,n=r.onDuplicate?t.applyOnDuplicateToUrl(e,r.onDuplicate):r.insertUrl;n&&l.instance.setUrl(n,"insert"),y&&r.features&&r.features.sorting&&t.applySavedSort(l.instance,r,y),y&&r.features&&r.features.paging&&t.applySavedOffset(l.instance,y.offset)}r.features&&r.features.sorting&&t.syncSortIndicators(a,t.collectionSort(l.instance)),t.bindViewPersistence(l.instance,r,a),t.setupDefaultFilters(g,r,l.instance,{skipInitSubmit:!0});const k=g&&(g.jquery?g[0]:g);if(t.applyUserFilters(k,r.columns,t.preferencesLoadFilters(r)),t.ensureUrlFiltersOnForm(k,l.instance),t.setupFilterPersistence(k,r),t.setupColumnChooser(o,r,l),r.url)try{r.features&&r.features.filtering&&k&&t.syncFormFiltersToCollectionUrl(k,l.instance),await l.instance.loadFromRemote()}catch(e){t.onError(e)}else{if(!r.data||r.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const t=r.data.map(t=>({attributes:t}));l.instance.loadFromData(t)}}return l}}(window.KGrid);
@@ -347,9 +347,9 @@ Check types with `KGrid.isValidInputType(type)`.
347
347
  | `type` | `string` | `text` | Control type |
348
348
  | `operator` | `string` | `~=~` (`><` for `multi_select`; ignored for `date_range`) | `data-operator` for KViews (`~=~`, `=`, `><`, …) |
349
349
  | `default` | `any` | | Initial value (`string` / `string[]` for `multi_select`, `{ from, to }` for `date_range`) |
350
- | `placeholder` | `string` | `""` (`"All"` for empty `multi_select`) | Toggle label when nothing selected (`multi_select`) |
351
- | `fromLabel` | `string` | `"From"` | `date_range` only: label on the start date |
352
- | `toLabel` | `string` | `"To"` | `date_range` only: label on the end date |
350
+ | `placeholder` | `string` | `""` (`"All"` for empty `multi_select`; `"From – To"` for empty `date_range`) | Toggle label when nothing selected (`multi_select`); empty `date_range` field |
351
+ | `fromLabel` | `string` | `"From"` | `date_range` only: start label in the panel, and the left half of the placeholder |
352
+ | `toLabel` | `string` | `"To"` | `date_range` only: end label in the panel, and the right half of the placeholder |
353
353
  | `options` | `array` \| `object` | | For `select`, `multi_select`, `select2`, … |
354
354
  | `separator` | `string` | `";"` | Only `multi_select`: join selected values |
355
355
  | `persist` | `boolean` | `false` | Re-apply `default` on filter reset (also implied when column `hidden` or `type: "hidden"`) |
@@ -367,7 +367,7 @@ Filter controls use `form=""` pointing at a hidden `<form>` (rows cannot wrap on
367
367
  |------|---------|--------|
368
368
  | Native HTML | filter, insert, update | `text`, `number`, `select`, … |
369
369
  | `multi_select` | filter (also insert/update) | Checkbox list; values `a;b` with operator `><` |
370
- | `date_range` | filter | From/to dates; `col>=start,col<=end 23:59:59` |
370
+ | `date_range` | filter | One field; panel edits from/to. `col>=start,col<=end 23:59:59` |
371
371
  | `select2` | filter, insert, update | `customInputTypes: { select2: KGrid.select2(fn) }` + `kgrid-widgets.js` |
372
372
  | `autosuggest` | filter, insert, update | `customInputTypes: { autosuggest: KGrid.autosuggest(fn) }` + `kgrid-widgets.js` |
373
373
  | Custom | any | `customInputTypes` or `registerFieldType` |
@@ -114,7 +114,7 @@ Produces filter expressions like `state><DRAFT;PICKED`.
114
114
 
115
115
  ### `date_range` — from / to (filter only)
116
116
 
117
- Two date inputs in the filter cell. Each bound is its own hidden field with the column name, so KViews emits two filter clauses. `filter.operator` is ignored.
117
+ One text field in the filter cell, the same height as the other filters. It shows the range as `DD.MM.YYYY – DD.MM.YYYY` (a missing side stays blank). Click or Enter opens a panel with the two date inputs; × on the field clears both. Each bound is its own hidden field with the column name, so KViews emits two filter clauses. `filter.operator` is ignored.
118
118
 
119
119
  | Concern | Behavior |
120
120
  |---------|----------|
@@ -123,7 +123,7 @@ Two date inputs in the filter cell. Each bound is its own hidden field with the
123
123
  | Empty side | omitted |
124
124
  | Both empty | no filter on that column |
125
125
  | Order | if To is before From, To is moved to From |
126
- | Labels | `From` / `To`, or `filter.fromLabel` / `filter.toLabel` |
126
+ | Labels | panel labels and the empty placeholder: `From` / `To`, or `filter.fromLabel` / `filter.toLabel`. `filter.placeholder` replaces the placeholder |
127
127
  | Default | `{ from, to }` calendar dates; either side may be omitted |
128
128
 
129
129
  ```javascript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logimaxx/kgrid",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "KGrid — declarative data table for KViews (filter, sort, paging, inline CRUD). Proprietary — Logimaxx System SRL.",
5
5
  "main": "dist/kgrid.js",
6
6
  "homepage": "https://logimaxx.ro",
@@ -347,8 +347,13 @@
347
347
  if (!root) {
348
348
  return;
349
349
  }
350
+ const doc = hidden.ownerDocument;
351
+ const panel = doc.getElementById(id + "_panel");
352
+ function boundInput(selector) {
353
+ return root.querySelector(selector) || (panel && panel.querySelector(selector));
354
+ }
350
355
  const bound = hidden.getAttribute("data-kgrid-date-bound");
351
- const visible = root.querySelector(
356
+ const visible = boundInput(
352
357
  bound === "to" ? ".kgrid-date-range-to" : ".kgrid-date-range-from"
353
358
  );
354
359
  if (!visible) {
@@ -358,6 +363,26 @@
358
363
  if (visible.value !== date) {
359
364
  visible.value = date;
360
365
  }
366
+ const display = root.querySelector(".kgrid-date-range-display");
367
+ if (!display) {
368
+ return;
369
+ }
370
+ const fromEl = boundInput(".kgrid-date-range-from");
371
+ const toEl = boundInput(".kgrid-date-range-to");
372
+ const text = formatDateRangeDisplay(fromEl && fromEl.value, toEl && toEl.value);
373
+ if (display.value !== text) {
374
+ display.value = text;
375
+ }
376
+ const clear = root.querySelector(".kgrid-date-range-clear");
377
+ if (clear) {
378
+ if (text) {
379
+ clear.removeAttribute("hidden");
380
+ root.classList.add("kgrid-date-range-has-value");
381
+ } else {
382
+ clear.setAttribute("hidden", "hidden");
383
+ root.classList.remove("kgrid-date-range-has-value");
384
+ }
385
+ }
361
386
  };
362
387
 
363
388
  /** Fill empty date-range hiddens from `{ from, to }`. Does not replace a value already set. */
@@ -412,6 +437,26 @@
412
437
  };
413
438
  })();
414
439
 
440
+ /** Closed field shows `DD.MM.YYYY`. One side omitted stays blank around the dash. */
441
+ function formatDateRangeDisplay(from, to) {
442
+ function day(iso) {
443
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso || "");
444
+ return match ? match[3] + "." + match[2] + "." + match[1] : "";
445
+ }
446
+ const start = day(from);
447
+ const end = day(to);
448
+ if (start && end) {
449
+ return start + " – " + end;
450
+ }
451
+ if (start) {
452
+ return start + " –";
453
+ }
454
+ if (end) {
455
+ return "– " + end;
456
+ }
457
+ return "";
458
+ }
459
+
415
460
  function dateRangeLabel(config, key, fallback) {
416
461
  const value = config && config[key];
417
462
  return value != null && value !== "" ? String(value) : fallback;
@@ -420,29 +465,53 @@
420
465
  function buildDateRangeUi($from, config) {
421
466
  const $to = $from.data("kgridDateRangeTo");
422
467
  const rootId = "kgrid_dr_" + CT.uuid();
468
+ const fromLabel = dateRangeLabel(config, "fromLabel", "From");
469
+ const toLabel = dateRangeLabel(config, "toLabel", "To");
470
+ const placeholder =
471
+ config && config.placeholder != null && config.placeholder !== ""
472
+ ? String(config.placeholder)
473
+ : fromLabel + " – " + toLabel;
423
474
  const $root = $("<div>", { class: "kgrid-date-range", id: rootId });
475
+ const panelId = rootId + "_panel";
476
+ const $display = $(
477
+ "<input type='text' readonly autocomplete='off' class='form-control form-control-sm kgrid-date-range-display'/>"
478
+ )
479
+ .attr("placeholder", placeholder)
480
+ .attr("role", "button")
481
+ .attr("aria-haspopup", "dialog")
482
+ .attr("aria-expanded", "false")
483
+ .attr("aria-controls", panelId);
484
+ const $clear = $("<button>", {
485
+ type: "button",
486
+ class: "kgrid-date-range-clear",
487
+ hidden: "hidden",
488
+ "aria-label": "Clear",
489
+ text: "×",
490
+ });
424
491
  const $fromVisible = $(
425
492
  "<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-from'/>"
426
493
  );
427
494
  const $toVisible = $(
428
495
  "<input autocomplete='off' type='date' class='form-control form-control-sm kgrid-date-range-to'/>"
429
496
  );
430
- $root.append(
497
+ const $panel = $("<div>", {
498
+ class: "kgrid-date-range-panel",
499
+ id: panelId,
500
+ hidden: "hidden",
501
+ role: "dialog",
502
+ "aria-label": placeholder,
503
+ });
504
+ $panel.append(
431
505
  $("<label>", { class: "kgrid-date-range-bound" }).append(
432
- $("<span>", {
433
- class: "kgrid-date-range-label",
434
- text: dateRangeLabel(config, "fromLabel", "From"),
435
- }),
506
+ $("<span>", { class: "kgrid-date-range-label", text: fromLabel }),
436
507
  $fromVisible
437
508
  ),
438
509
  $("<label>", { class: "kgrid-date-range-bound" }).append(
439
- $("<span>", {
440
- class: "kgrid-date-range-label",
441
- text: dateRangeLabel(config, "toLabel", "To"),
442
- }),
510
+ $("<span>", { class: "kgrid-date-range-label", text: toLabel }),
443
511
  $toVisible
444
512
  )
445
513
  );
514
+ $root.append($display, $clear, $panel);
446
515
  $from.before($root);
447
516
  $from.attr("data-kgrid-date-range", rootId);
448
517
  $to.attr("data-kgrid-date-range", rootId);
@@ -466,12 +535,91 @@
466
535
  }
467
536
  }
468
537
 
538
+ function setOpen(open) {
539
+ if (open) {
540
+ $panel.appendTo(document.body);
541
+ $panel.addClass("kgrid-date-range-panel-floating");
542
+ $panel.removeAttr("hidden");
543
+ $root.addClass("kgrid-date-range-open");
544
+ $display.attr("aria-expanded", "true");
545
+ positionPanel();
546
+ } else {
547
+ $panel.attr("hidden", "hidden");
548
+ $root.removeClass("kgrid-date-range-open");
549
+ $display.attr("aria-expanded", "false");
550
+ $panel.css({ position: "", top: "", left: "", width: "", zIndex: "" });
551
+ $panel.removeClass("kgrid-date-range-panel-floating");
552
+ $panel.insertAfter($clear);
553
+ }
554
+ }
555
+
556
+ function positionPanel() {
557
+ const rect = $display[0].getBoundingClientRect();
558
+ const width = Math.min(Math.max(rect.width, 20 * 16), window.innerWidth - 16);
559
+ let left = rect.left;
560
+ const maxLeft = window.innerWidth - width - 8;
561
+ if (left > maxLeft) {
562
+ left = Math.max(8, maxLeft);
563
+ }
564
+ $panel.css({
565
+ position: "fixed",
566
+ top: rect.bottom + 2 + "px",
567
+ left: left + "px",
568
+ width: width + "px",
569
+ zIndex: 1080,
570
+ });
571
+ const height = $panel[0].offsetHeight;
572
+ let top = rect.bottom + 2;
573
+ if (top + height > window.innerHeight - 8 && rect.top > height + 8) {
574
+ top = rect.top - height - 2;
575
+ }
576
+ $panel.css("top", top + "px");
577
+ }
578
+
469
579
  $fromVisible.add($toVisible).on("change", function () {
470
580
  writePair($fromVisible.val() || "", $toVisible.val() || "", false);
471
581
  $from.trigger("change");
472
582
  });
473
583
 
584
+ $display.on("click", function (e) {
585
+ e.preventDefault();
586
+ setOpen(!$root.hasClass("kgrid-date-range-open"));
587
+ });
588
+ $display.on("keydown", function (e) {
589
+ if (e.key === "Enter" || e.key === " ") {
590
+ e.preventDefault();
591
+ setOpen(!$root.hasClass("kgrid-date-range-open"));
592
+ }
593
+ });
594
+ $clear.on("click", function (e) {
595
+ e.preventDefault();
596
+ e.stopPropagation();
597
+ writePair("", "", false);
598
+ $from.trigger("change");
599
+ setOpen(false);
600
+ });
601
+
474
602
  const ns = ".kgridDateRange_" + CT.uuid();
603
+ $(document).on("mousedown" + ns, function (e) {
604
+ if (!$root.hasClass("kgrid-date-range-open")) {
605
+ return;
606
+ }
607
+ if ($(e.target).closest($root).length || $(e.target).closest($panel).length) {
608
+ return;
609
+ }
610
+ setOpen(false);
611
+ });
612
+ $(document).on("keydown" + ns, function (e) {
613
+ if (e.key === "Escape" && $root.hasClass("kgrid-date-range-open")) {
614
+ setOpen(false);
615
+ }
616
+ });
617
+ $(window).on("resize" + ns + " scroll" + ns, function () {
618
+ if ($root.hasClass("kgrid-date-range-open")) {
619
+ positionPanel();
620
+ }
621
+ });
622
+
475
623
  const formBind = function () {
476
624
  const formEl = $from.prop("form") || ($from[0] && $from[0].form);
477
625
  if (!formEl) {
package/styles/table.css CHANGED
@@ -495,16 +495,58 @@ th.kgrid-row-actions {
495
495
  user-select: none;
496
496
  }
497
497
 
498
- /* date_range: from / to stacked in the filter cell */
498
+ /* date_range: one field in the filter cell; the two dates open in a panel */
499
499
  .kgrid-date-range {
500
- display: flex;
501
- flex-direction: column;
502
- gap: 0.35rem;
500
+ position: relative;
503
501
  min-width: 0;
504
502
  width: 100%;
505
503
  }
504
+ .kgrid-date-range-display {
505
+ width: 100%;
506
+ max-width: 100%;
507
+ min-width: 0;
508
+ cursor: pointer;
509
+ text-overflow: ellipsis;
510
+ }
511
+ .kgrid-date-range-display[readonly] {
512
+ background-color: var(--bs-body-bg, #fff);
513
+ }
514
+ .kgrid-date-range-has-value .kgrid-date-range-display {
515
+ padding-right: 1.6rem;
516
+ }
517
+ .kgrid-date-range-clear {
518
+ position: absolute;
519
+ top: 50%;
520
+ right: 0.3rem;
521
+ transform: translateY(-50%);
522
+ border: 0;
523
+ background: transparent;
524
+ padding: 0 0.2rem;
525
+ line-height: 1;
526
+ font-size: 1rem;
527
+ color: var(--kgrid-muted, var(--bs-secondary-color, #6c757d));
528
+ cursor: pointer;
529
+ }
530
+ .kgrid-date-range-panel {
531
+ display: flex;
532
+ flex-wrap: wrap;
533
+ gap: 0.5rem;
534
+ padding: 0.5rem;
535
+ background: var(--bs-body-bg, #fff);
536
+ color: var(--bs-body-color, #212529);
537
+ border: 1px solid var(--bs-border-color, #dee2e6);
538
+ border-radius: 0.375rem;
539
+ box-sizing: border-box;
540
+ }
541
+ .kgrid-date-range-panel[hidden] {
542
+ display: none !important;
543
+ }
544
+ .kgrid-date-range-panel.kgrid-date-range-panel-floating {
545
+ box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
546
+ }
506
547
  .kgrid-date-range-bound {
507
548
  display: flex;
549
+ flex: 1 1 9rem;
508
550
  flex-direction: column;
509
551
  gap: 0.15rem;
510
552
  margin: 0;