@logimaxx/kgrid 0.5.1 → 0.5.3
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/README.md +1 -1
- package/dist/kgrid.js +183 -46
- package/dist/kgrid.min.js +2 -2
- package/docs/ai-guide.md +5 -4
- package/docs/api.md +8 -4
- package/docs/configuration.md +2 -2
- package/docs/table-shell.md +2 -2
- package/package.json +1 -1
- package/src/cells.js +1 -2
- package/src/dom.js +68 -4
- package/src/events.js +7 -0
- package/src/init.js +4 -4
- package/src/labels.js +1 -3
- package/src/preferences.js +32 -29
- package/src/row-actions.js +69 -3
- package/styles/table.css +19 -16
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ const grid = await KGrid.init(document.getElementById("table-host"), {
|
|
|
106
106
|
| `KGrid.init(host, opts)` | Empty host or existing `<table>`; returns grid API |
|
|
107
107
|
| `KGrid.TABLE_SHELL_TEMPLATE` | Default table HTML (editable) |
|
|
108
108
|
| `KGrid.hasActionColumn(opts)` | Whether a trailing row-actions column is rendered |
|
|
109
|
-
| `opts.rowActions` | `{ display, items }` for delete/clone/custom;
|
|
109
|
+
| `opts.rowActions` | `{ display, items }` for delete/clone/custom; kebab menus are KGrid-toggled (`position:fixed`), not Bootstrap Dropdown |
|
|
110
110
|
| `KGrid.registerFieldType(name, plugin)` | Custom filter/insert/update widgets |
|
|
111
111
|
| `grid.setInteraction('view' \| 'edit')` | View or edit; menu actions can stay visible in view |
|
|
112
112
|
| `grid.getLayout()` / `setLayout()` / `resetLayout()` | Column order and user-hidden columns |
|
package/dist/kgrid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-09-
|
|
1
|
+
/*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-09-18T05:41:38.912Z */
|
|
2
2
|
|
|
3
3
|
/* --- configure.js --- */
|
|
4
4
|
/**
|
|
@@ -425,12 +425,61 @@
|
|
|
425
425
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
426
426
|
};
|
|
427
427
|
|
|
428
|
+
/** CSS width for a visible column from `attrs.width` (px if numeric). */
|
|
429
|
+
CT.columnWidthCss = function (col) {
|
|
430
|
+
if (!col || !col.attrs) {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
const w = col.attrs.width;
|
|
434
|
+
if (w == null || w === "") {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
if (typeof w === "number" || /^\d+(\.\d+)?$/.test(String(w))) {
|
|
438
|
+
return String(w) + "px";
|
|
439
|
+
}
|
|
440
|
+
return String(w);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
/** Copy `col.attrs` onto a cell, except layout `width` (that belongs on `<col>`). */
|
|
444
|
+
CT.applyColumnDomAttrs = function ($el, col) {
|
|
445
|
+
const attrs = col && col.attrs && typeof col.attrs === "object" ? col.attrs : null;
|
|
446
|
+
if (!attrs) {
|
|
447
|
+
return $el;
|
|
448
|
+
}
|
|
449
|
+
Object.keys(attrs).forEach(function (attr) {
|
|
450
|
+
if (attr === "width") {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
$el.attr(attr, attrs[attr]);
|
|
454
|
+
});
|
|
455
|
+
return $el;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Columns that occupy a table-layout slot (named, not schema-hidden, not user-hidden).
|
|
460
|
+
* `display:none` cells do not participate, so colgroup must list only these.
|
|
461
|
+
*/
|
|
462
|
+
CT.layoutVisibleColumns = function (columns) {
|
|
463
|
+
return (columns || []).filter(function (col) {
|
|
464
|
+
return col && col.name && !col.hidden && !col.userHidden;
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
/** Header/body/footer participating column count (visible data + optional actions). */
|
|
469
|
+
CT.participatingColumnCount = function (columns, hasActions) {
|
|
470
|
+
return CT.layoutVisibleColumns(columns).length + (hasActions ? 1 : 0);
|
|
471
|
+
};
|
|
472
|
+
|
|
428
473
|
/**
|
|
429
|
-
* Sync <colgroup>
|
|
474
|
+
* Sync <colgroup> for `table-layout: fixed`.
|
|
475
|
+
* One `<col>` per participating data column, then optional row-actions.
|
|
476
|
+
* Never emit a col for user-hidden fields: `display:none` cells skip a slot,
|
|
477
|
+
* so a leftover col (even width 0) remaps every following cell onto the wrong width.
|
|
430
478
|
* @param {JQuery} $table
|
|
431
|
-
* @param {number} dataColumnCount
|
|
479
|
+
* @param {number} dataColumnCount participating data columns (no row-actions)
|
|
432
480
|
* @param {boolean} hasActions
|
|
433
481
|
* @param {Object} [options] table options (for action column width)
|
|
482
|
+
* @param {Array} [layoutColumns] column objects in display order; userHidden entries are skipped
|
|
434
483
|
*/
|
|
435
484
|
CT.syncActionColumnColgroup = function ($table, dataColumnCount, hasActions, options, layoutColumns) {
|
|
436
485
|
let $colgroup = $table.children("colgroup.kgrid-colgroup");
|
|
@@ -439,20 +488,27 @@
|
|
|
439
488
|
}
|
|
440
489
|
$colgroup.empty();
|
|
441
490
|
const named = Array.isArray(layoutColumns) ? layoutColumns : null;
|
|
491
|
+
let emitted = 0;
|
|
442
492
|
if (named && named.length) {
|
|
443
493
|
named.forEach(function (col) {
|
|
494
|
+
if (col && col.userHidden) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
444
497
|
const $col = $("<col>");
|
|
445
498
|
if (col && col.name) {
|
|
446
499
|
$col.attr("data-name", col.name);
|
|
447
500
|
}
|
|
448
|
-
|
|
449
|
-
|
|
501
|
+
const cssW = CT.columnWidthCss(col);
|
|
502
|
+
if (cssW) {
|
|
503
|
+
$col.css("width", cssW);
|
|
450
504
|
}
|
|
451
505
|
$colgroup.append($col);
|
|
506
|
+
emitted += 1;
|
|
452
507
|
});
|
|
453
508
|
} else {
|
|
454
509
|
for (let i = 0; i < dataColumnCount; i++) {
|
|
455
510
|
$colgroup.append($("<col>"));
|
|
511
|
+
emitted += 1;
|
|
456
512
|
}
|
|
457
513
|
}
|
|
458
514
|
if (hasActions) {
|
|
@@ -462,6 +518,14 @@
|
|
|
462
518
|
.css("width", CT.actionColumnWidth(options))
|
|
463
519
|
);
|
|
464
520
|
}
|
|
521
|
+
return emitted;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
CT.syncSpanningCells = function ($table, span) {
|
|
525
|
+
if (!$table || !$table.length || !span) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
$table.find(".paging-footer td, .no-data-tbody td").attr("colspan", span);
|
|
465
529
|
};
|
|
466
530
|
|
|
467
531
|
/**
|
|
@@ -741,6 +805,74 @@
|
|
|
741
805
|
return (2.5 * n + 0.75).toFixed(2) + "rem";
|
|
742
806
|
};
|
|
743
807
|
|
|
808
|
+
CT.closeRowActionDropdowns = function ($exceptMenu) {
|
|
809
|
+
$(".kgrid-row-actions-menu").each(function () {
|
|
810
|
+
const $wrap = $(this);
|
|
811
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
812
|
+
if ($exceptMenu && $menu[0] === $exceptMenu[0]) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
$menu.removeClass("show").css({ top: "", left: "", right: "", position: "" });
|
|
816
|
+
$wrap.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded", "false").removeClass("show");
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Wire row-action kebab menus. Uses a small jQuery toggle (not Bootstrap Dropdown)
|
|
822
|
+
* so we do not depend on data-api / popperConfig quirks; menu is position:fixed while open.
|
|
823
|
+
* @param {JQuery} $root
|
|
824
|
+
*/
|
|
825
|
+
CT.mountRowActionDropdowns = function ($root) {
|
|
826
|
+
if (!$root || !$root.length) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (!CT._rowActionsDropdownDocBound) {
|
|
830
|
+
CT._rowActionsDropdownDocBound = true;
|
|
831
|
+
$(document)
|
|
832
|
+
.on("click.kgridRowActions", function () {
|
|
833
|
+
CT.closeRowActionDropdowns();
|
|
834
|
+
})
|
|
835
|
+
.on("keydown.kgridRowActions", function (e) {
|
|
836
|
+
if (e.key === "Escape") {
|
|
837
|
+
CT.closeRowActionDropdowns();
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
$root.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function () {
|
|
842
|
+
const toggle = this;
|
|
843
|
+
const $toggle = $(toggle);
|
|
844
|
+
const $wrap = $toggle.parent(".kgrid-row-actions-menu");
|
|
845
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
846
|
+
$toggle.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
847
|
+
event.preventDefault();
|
|
848
|
+
event.stopPropagation();
|
|
849
|
+
const willOpen = !$menu.hasClass("show");
|
|
850
|
+
CT.closeRowActionDropdowns();
|
|
851
|
+
if (!willOpen) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const rect = toggle.getBoundingClientRect();
|
|
855
|
+
$menu.addClass("show").css({
|
|
856
|
+
position: "fixed",
|
|
857
|
+
top: Math.round(rect.bottom + 2) + "px",
|
|
858
|
+
left: "auto",
|
|
859
|
+
right: Math.round(window.innerWidth - rect.right) + "px",
|
|
860
|
+
zIndex: 1055,
|
|
861
|
+
});
|
|
862
|
+
$toggle.addClass("show").attr("aria-expanded", "true");
|
|
863
|
+
});
|
|
864
|
+
$menu.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
865
|
+
event.stopPropagation();
|
|
866
|
+
});
|
|
867
|
+
$menu.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose", function () {
|
|
868
|
+
// Close after the action click handlers (same tick is fine).
|
|
869
|
+
setTimeout(function () {
|
|
870
|
+
CT.closeRowActionDropdowns();
|
|
871
|
+
}, 0);
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
|
|
744
876
|
function iconHtml(icon) {
|
|
745
877
|
if (!icon) {
|
|
746
878
|
return "";
|
|
@@ -815,11 +947,9 @@
|
|
|
815
947
|
.addClass("btn-group kgrid-row-actions-menu")
|
|
816
948
|
.appendTo($buttonColumn);
|
|
817
949
|
$("<button>")
|
|
818
|
-
.addClass("btn btn-sm btn-outline-secondary dropdown-toggle")
|
|
950
|
+
.addClass("btn btn-sm btn-outline-secondary dropdown-toggle kgrid-actions-dropdown-toggle")
|
|
819
951
|
.attr({
|
|
820
952
|
type: "button",
|
|
821
|
-
"data-bs-toggle": "dropdown",
|
|
822
|
-
"data-bs-popper-config": JSON.stringify({ strategy: "fixed" }),
|
|
823
953
|
"aria-expanded": "false",
|
|
824
954
|
title: "Actions",
|
|
825
955
|
})
|
|
@@ -1657,9 +1787,7 @@
|
|
|
1657
1787
|
}
|
|
1658
1788
|
|
|
1659
1789
|
let cell = labelTemplate.clone(true);
|
|
1660
|
-
|
|
1661
|
-
Object.keys(col.attrs).forEach((attr) => cell.attr(attr, col.attrs[attr]));
|
|
1662
|
-
}
|
|
1790
|
+
CT.applyColumnDomAttrs(cell, col);
|
|
1663
1791
|
CT.applyColumnCellMeta(cell, col);
|
|
1664
1792
|
|
|
1665
1793
|
if (!col.features?.sort) {
|
|
@@ -2160,8 +2288,7 @@
|
|
|
2160
2288
|
const $cell = $("<td>").attr("data-label", col.label);
|
|
2161
2289
|
CT.applyColumnCellMeta($cell, col);
|
|
2162
2290
|
|
|
2163
|
-
|
|
2164
|
-
Object.keys(attrs).forEach(attr => $cell.attr(attr, attrs[attr]));
|
|
2291
|
+
CT.applyColumnDomAttrs($cell, c);
|
|
2165
2292
|
|
|
2166
2293
|
let cellContent = $("<div>").addClass("cell-content");
|
|
2167
2294
|
cellContent.html(c.display.template ?? `{{${c.name}}}`);
|
|
@@ -2545,6 +2672,9 @@
|
|
|
2545
2672
|
*/
|
|
2546
2673
|
CT.setupEvents = function (item, table, options, colMap) {
|
|
2547
2674
|
const view = item.views[0];
|
|
2675
|
+
if (view && view.el && typeof CT.applyLayoutToRow === "function") {
|
|
2676
|
+
CT.applyLayoutToRow(view.el, options.columns);
|
|
2677
|
+
}
|
|
2548
2678
|
|
|
2549
2679
|
options.columns.forEach(col=>{
|
|
2550
2680
|
col.display.events.forEach(event=>{
|
|
@@ -2628,12 +2758,14 @@
|
|
|
2628
2758
|
}
|
|
2629
2759
|
|
|
2630
2760
|
const ra = CT.resolveRowActions(options);
|
|
2761
|
+
CT.mountRowActionDropdowns(view.el);
|
|
2631
2762
|
const hasClone = ra.menuItems.some((it) => it.action === "clone");
|
|
2632
2763
|
const hasDelete = ra.menuItems.some((it) => it.action === "delete");
|
|
2633
2764
|
|
|
2634
2765
|
if (hasClone) {
|
|
2635
2766
|
view.el.find(".clone-item").off("click").on("click", (event) => {
|
|
2636
2767
|
event.preventDefault();
|
|
2768
|
+
event.stopPropagation();
|
|
2637
2769
|
if (typeof options.onClone === "function") {
|
|
2638
2770
|
options.onClone(item, view, event);
|
|
2639
2771
|
}
|
|
@@ -2643,6 +2775,7 @@
|
|
|
2643
2775
|
if (hasDelete) {
|
|
2644
2776
|
view.el.find(".delete-item").off("click").on("click", (event) => {
|
|
2645
2777
|
event.preventDefault();
|
|
2778
|
+
event.stopPropagation();
|
|
2646
2779
|
view.el.addClass("confirm-delete");
|
|
2647
2780
|
const clearConfirmState = () => view.el.removeClass("confirm-delete");
|
|
2648
2781
|
CT.runDeleteConfirm(
|
|
@@ -2672,6 +2805,7 @@
|
|
|
2672
2805
|
return;
|
|
2673
2806
|
}
|
|
2674
2807
|
event.preventDefault();
|
|
2808
|
+
event.stopPropagation();
|
|
2675
2809
|
cb(event, item, view);
|
|
2676
2810
|
});
|
|
2677
2811
|
}
|
|
@@ -2993,50 +3127,53 @@
|
|
|
2993
3127
|
return merged;
|
|
2994
3128
|
};
|
|
2995
3129
|
|
|
2996
|
-
CT.
|
|
2997
|
-
if (!$
|
|
3130
|
+
CT.applyLayoutToRow = function ($row, columns) {
|
|
3131
|
+
if (!$row || !$row.length) {
|
|
2998
3132
|
return;
|
|
2999
3133
|
}
|
|
3000
|
-
const
|
|
3134
|
+
const chooser = CT.chooserColumns(columns);
|
|
3135
|
+
const order = chooser.map(function (col) {
|
|
3001
3136
|
return col.name;
|
|
3002
3137
|
});
|
|
3003
3138
|
const hidden = {};
|
|
3004
|
-
|
|
3139
|
+
chooser.forEach(function (col) {
|
|
3005
3140
|
if (col.userHidden) {
|
|
3006
3141
|
hidden[col.name] = true;
|
|
3007
3142
|
}
|
|
3008
3143
|
});
|
|
3144
|
+
const $action = $row.children(".kgrid-row-actions");
|
|
3145
|
+
const byName = {};
|
|
3146
|
+
$row.children("[data-name]").each(function () {
|
|
3147
|
+
byName[this.getAttribute("data-name")] = this;
|
|
3148
|
+
});
|
|
3149
|
+
order.forEach(function (name) {
|
|
3150
|
+
const el = byName[name];
|
|
3151
|
+
if (!el) {
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
if ($action.length) {
|
|
3155
|
+
$(el).insertBefore($action);
|
|
3156
|
+
} else {
|
|
3157
|
+
$row.append(el);
|
|
3158
|
+
}
|
|
3159
|
+
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
3160
|
+
});
|
|
3161
|
+
};
|
|
3162
|
+
|
|
3163
|
+
CT.applyLayoutToDom = function ($table, columns, options) {
|
|
3164
|
+
if (!$table || !$table.length) {
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3009
3167
|
const $rows = $table.find(
|
|
3010
3168
|
".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr"
|
|
3011
3169
|
);
|
|
3012
3170
|
$rows.each(function () {
|
|
3013
|
-
|
|
3014
|
-
const $action = $row.children(".kgrid-row-actions");
|
|
3015
|
-
const byName = {};
|
|
3016
|
-
$row.children("[data-name]").each(function () {
|
|
3017
|
-
byName[this.getAttribute("data-name")] = this;
|
|
3018
|
-
});
|
|
3019
|
-
order.forEach(function (name) {
|
|
3020
|
-
const el = byName[name];
|
|
3021
|
-
if (!el) {
|
|
3022
|
-
return;
|
|
3023
|
-
}
|
|
3024
|
-
if ($action.length) {
|
|
3025
|
-
$(el).insertBefore($action);
|
|
3026
|
-
} else {
|
|
3027
|
-
$row.append(el);
|
|
3028
|
-
}
|
|
3029
|
-
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
3030
|
-
});
|
|
3171
|
+
CT.applyLayoutToRow($(this), columns);
|
|
3031
3172
|
});
|
|
3173
|
+
const visible = CT.layoutVisibleColumns(columns);
|
|
3032
3174
|
const hasActions = $table.find(".kgrid-row-actions").length > 0;
|
|
3033
|
-
CT.syncActionColumnColgroup(
|
|
3034
|
-
|
|
3035
|
-
order.length,
|
|
3036
|
-
hasActions,
|
|
3037
|
-
options,
|
|
3038
|
-
CT.chooserColumns(columns)
|
|
3039
|
-
);
|
|
3175
|
+
CT.syncActionColumnColgroup($table, visible.length, hasActions, options, visible);
|
|
3176
|
+
CT.syncSpanningCells($table, CT.participatingColumnCount(columns, hasActions));
|
|
3040
3177
|
};
|
|
3041
3178
|
|
|
3042
3179
|
CT.refreshCollectionTemplate = function (api, options) {
|
|
@@ -3419,14 +3556,14 @@
|
|
|
3419
3556
|
const labelsRow = CT.setupLabelsHeader(table.find(".thead-labels"), options);
|
|
3420
3557
|
|
|
3421
3558
|
const hasActionColumn = CT.hasActionColumn(options);
|
|
3422
|
-
const
|
|
3423
|
-
const
|
|
3559
|
+
const layoutCols = CT.layoutVisibleColumns(options.columns);
|
|
3560
|
+
const visibleColumnsCount = CT.participatingColumnCount(options.columns, hasActionColumn);
|
|
3424
3561
|
CT.syncActionColumnColgroup(
|
|
3425
3562
|
table,
|
|
3426
|
-
|
|
3563
|
+
layoutCols.length,
|
|
3427
3564
|
hasActionColumn,
|
|
3428
3565
|
options,
|
|
3429
|
-
|
|
3566
|
+
layoutCols
|
|
3430
3567
|
);
|
|
3431
3568
|
|
|
3432
3569
|
const filterForm = options.filterForm ?? CT.setupFilterHeader(table, options);
|
package/dist/kgrid.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-09-
|
|
2
|
-
!function(e){function t(e){const t={},n=e&&e.elements;if(!n)return t;for(let e=0;e<n.length;e++){const o=n[e],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){t[r]=o.checked?"1":"0";continue}if("radio"===a){if(!o.checked)continue;t[r]=o.value;continue}if("SELECT"===o.tagName&&o.multiple){t[r]=Array.from(o.selectedOptions).map(function(e){return e.value});continue}const i=o.value;Object.prototype.hasOwnProperty.call(t,r)?(Array.isArray(t[r])||(t[r]=[t[r]]),t[r].push(i)):t[r]=i}return t}e.isFlagOn=function(e){return!0===e||1===e||"1"===e},e.serializeFormDefault=t;const n={log:function(){},onError:function(e){console.error(e)},confirm:function(e,t,n){"undefined"!=typeof window&&window.confirm(e)?t():n&&n()},deleteConfirm:null,serializeForm:t,customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300,preferencesStorage:null};e._config=Object.assign({},n),e.configure=function(t){return t&&"object"==typeof t&&Object.assign(e._config,t),"function"==typeof e._syncCustomInputTypes&&e._syncCustomInputTypes(),e},e.log=function(){e._config.log.apply(null,arguments)},e.onError=function(t){return e._config.onError(t)},e.confirm=function(t,n,o){return e._config.confirm(t,n,o)},e.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",e._defaultDeleteConfirm=function(t,n,o){e.confirm(e.DEFAULT_DELETE_CONFIRM_MESSAGE,n,o)},e.runDeleteConfirm=function(t,n,o){const r=t.options&&"function"==typeof t.options.deleteConfirm?t.options.deleteConfirm:null,a="function"==typeof e._config.deleteConfirm?e._config.deleteConfirm:null;return(r||a||e._defaultDeleteConfirm)(t,n,o)},e.serializeForm=function(t,n){return e._config.serializeForm(t,n)},e.getKViews=function(t){const n=[t,e._config.kviews];for(let e=0;e<n.length;e++){const t=n[e];if(t&&"function"==typeof t.createCollectionInstance)return t}const o=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return o&&"function"==typeof o.createCollectionInstance?o:null},e.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(e){e.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"},tableAttrs:{class:""},labelsRowAttrs:{},dataRowAttrs:{},filtersRowAttrs:null,pagingPageSizes:[10,25,50,75],pagingDefaultSize:10,emptyRowMessage:null,pagingFooterLabel:"records per page. Total"},e.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}},e.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],e.VALID_INPUT_TYPES=e.VALID_NATIVE_INPUT_TYPES.slice(),e.VALID_NATIVE_FILTER_TYPES=e.VALID_NATIVE_INPUT_TYPES.filter(e=>"displayonly"!==e),e.VALID_FILTER_TYPES=e.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),e.isValidInputType=function(t){return e.VALID_NATIVE_INPUT_TYPES.includes(t)||e.isPluggableFieldType(t)},e.isValidFilterType=function(t){return"displayonly"!==t&&(e.VALID_NATIVE_FILTER_TYPES.includes(t)||e.isPluggableFieldType(t))}}(window.KGrid=window.KGrid||{}),function(e){e.isPlainObject=function(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)},e.setDefaultValues=function(t,n){const o={...t||{}};return Object.keys(n||{}).forEach(t=>{e.isPlainObject(n[t])&&e.isPlainObject(o[t])?o[t]=e.setDefaultValues(o[t],n[t]):e.isPlainObject(n[t])&&null==o[t]?o[t]=e.setDefaultValues({},n[t]):o[t]=n[t]}),o},e.normalizeColumnConfig=function(t){let n=t&&"object"==typeof t?{...t}:{};if(e.isPlainObject(n.input)){const t={...n.input};delete n.input,n.insert=e.setDefaultValues(t,n.insert||{}),n.update=e.setDefaultValues(t,n.update||{})}const o=e.setDefaultValues(e.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(e=>{o[e]&&"object"==typeof o[e]&&(Array.isArray(o[e].events)||(o[e].events=[]))}),o}}(window.KGrid),function(e){e.resolveHostElement=function(e){if(null==e)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof e&&e.jquery){if(!e.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return e}if("object"==typeof e&&1===e.nodeType&&"string"==typeof e.nodeName)return $(e);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},e.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},e.syncActionColumnColgroup=function(t,n,o,r,a){let i=t.children("colgroup.kgrid-colgroup");i.length||(i=$("<colgroup>").addClass("kgrid-colgroup").prependTo(t)),i.empty();const l=Array.isArray(a)?a:null;if(l&&l.length)l.forEach(function(e){const t=$("<col>");e&&e.name&&t.attr("data-name",e.name),e&&e.userHidden&&t.addClass("kgrid-user-hidden"),i.append(t)});else for(let e=0;e<n;e++)i.append($("<col>"));o&&i.append($("<col>").addClass("kgrid-row-actions-col").css("width",e.actionColumnWidth(r)))},e.anchorRowForm=function(e,t){if(!(e&&e.length&&t&&t.length))return e;e.attr("hidden","hidden").attr("aria-hidden","true");const n=t.children("td").first();return n.length&&e.prependTo(n),e},e.filterFormField=function(e,t){if(!e||!t)return $();const n=e.elements&&e.elements.namedItem(t);if(n)return $(n);if(e.id){const n=document.querySelector(`[form="${e.id}"][name="${t}"]`);if(n)return $(n)}return $()},e.columnClassName=function(e){if(!e)return null;const t=null!=e.class&&""!==e.class?e.class:e.columnClass;return null!=t&&""!==t?String(t):null},e.applyColumnCellMeta=function(t,n){if(!t||!t.length||!n)return t;n.name&&t.attr("data-name",n.name);const o=e.columnClassName(n);return o&&t.addClass(o),t.toggleClass("kgrid-user-hidden",!!n.userHidden),t}}(window.KGrid),function(e){function t(e){"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(e)}function n(e){return e?"<i class='"+e+"'></i>":""}function o(e,t,o){const r=$("<button>").addClass(t.btnClass||"btn btn-sm btn-outline-secondary").attr("type","save"===t.action?"submit":"button").attr("title",t.title||t.label||"");return t.class&&r.addClass(t.class),"save"!==t.action&&"cancel"!==t.action||(r.attr("name","save"===t.action?"save":"cancel"),o&&r.attr("form",o)),"cancel"===t.action&&r.attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()"),t.id&&r.attr("data-kgrid-action",t.id),t.action&&r.attr("data-kgrid-builtin",t.action),t.icon?(r.html(n(t.icon)),t.showLabel&&t.label&&r.append(document.createTextNode(" "+t.label))):t.label&&r.text(t.label),r.appendTo(e),r}e.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"}},e.normalizeRowActionItem=function(n,o,r){if(!n||"object"!=typeof n)return null;const a=n.action;if("save"===a||"cancel"===a)return t("KGrid: rowActions items should not list '"+a+"' — it is added automatically when features.update is true"),null;let i={};if(a&&e.BUILTIN_ROW_ACTIONS[a])i={...e.BUILTIN_ROW_ACTIONS[a]};else{if(!n.id)return t("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&&e.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 e=function(e,t,n){if(!e||"string"!=typeof e)return null;const o=t&&t[e]||n.functions&&n.functions[e];return"function"==typeof o?o:null}(l.callback,o,r);if(!e)throw new Error("rowAction callback "+l.callback+" not found or is not a function");l.callback=e}if(l.id&&"function"!=typeof l.callback&&!l.action)throw new Error("Custom rowAction '"+l.id+"' requires a callback");return l},e.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:e.isPlainObject(o)&&(a="dropdown"===o.display?"dropdown":"buttons",i=Array.isArray(o.items)?o.items:[]),(r.delete||r.clone)&&t("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(t){const r=e.normalizeRowActionItem(t,o,n||{});r&&l.push(r)});const s=[];r.update&&(s.push({...e.BUILTIN_ROW_ACTIONS.save}),s.push({...e.BUILTIN_ROW_ACTIONS.cancel}));const c={display:a,menuItems:l,editingItems:s};return n&&(n._resolvedRowActions=c),c},e.hasActionColumn=function(t){const n=t&&t.features;if(n&&n.create)return!0;const o=e.resolveRowActions(t);return o.menuItems.length>0||o.editingItems.length>0},e.actionColumnWidth=function(t){const n=e.resolveRowActions(t),o=t&&t.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(e){return"editing"!==e.when}).length;return(2.5*Math.max(i,r,a,1)+.75).toFixed(2)+"rem"},e.escapeHtml=e.escapeHtml||function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},e.renderRowActions=function(t,r,a){const i=e.resolveRowActions(r),l=i.menuItems.filter(function(e){return"editing"!==e.when}),s=i.menuItems.filter(function(e){return"editing"===e.when});if("dropdown"===i.display&&l.length>0){const o=$("<div>").addClass("btn-group kgrid-row-actions-menu").appendTo(t);$("<button>").addClass("btn btn-sm btn-outline-secondary dropdown-toggle").attr({type:"button","data-bs-toggle":"dropdown","data-bs-popper-config":JSON.stringify({strategy:"fixed"}),"aria-expanded":"false",title:"Actions"}).html("<i class='fas fa-ellipsis-v'></i>").appendTo(o);const r=$("<ul>").addClass("dropdown-menu dropdown-menu-end").appendTo(o);l.forEach(function(t){const o=$("<li>").appendTo(r),a=$("<button>").addClass("dropdown-item").attr("type","button").appendTo(o);"clone"===t.action?a.addClass("clone-item"):"delete"===t.action&&a.addClass("delete-item text-danger"),t.id&&a.attr("data-kgrid-action",t.id),t.action&&a.attr("data-kgrid-builtin",t.action),t.class&&a.addClass(t.class),t.btnClass&&!t.action&&/\bbtn-danger\b|\btext-danger\b|\boutline-danger\b/.test(t.btnClass)&&a.addClass("text-danger");const i=t.label||t.title||t.action||t.id;t.icon?a.html(n(t.icon)+" "+e.escapeHtml(i)):a.text(i)})}else l.forEach(function(e){const n=$("<div>").addClass(e.groupClass||"btn-group kgrid-custom-action-grp").appendTo(t);"always"===e.when&&n.addClass("kgrid-action-always"),o(n,e,a)});const c=i.editingItems.concat(s);if(c.length){const e=$("<div>").addClass("btn-group edit-item-grp").appendTo(t);c.forEach(function(t){o(e,t,a)})}}}(window.KGrid),function(e){e.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",e.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"><<</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary"><</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">></button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">>></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(),e._escapeTableShellText=function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},e._renderPageSizeOptions=function(e,t){return e.map(e=>{const n=String(e);return` <option value="${n}"${n===String(t)?" selected":""}>${n}</option>`}).join("\n")},e.renderTableShellHtml=function(t,n){const o=Array.isArray(t.pagingPageSizes)?t.pagingPageSizes:[10,25,50,75],r=null!=t.pagingDefaultSize?t.pagingDefaultSize:o[0],a=e._escapeTableShellText(t.emptyRowMessage||e.DEFAULT_EMPTY_ROW_MESSAGE),i=e._escapeTableShellText(t.pagingFooterLabel||"records per page. Total");return(n||e.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,a).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(r)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,e._renderPageSizeOptions(o,r)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,i)},e.createTableShell=function(t){const n=e.renderTableShellHtml(t),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 t.tableAttrs&&e.isPlainObject(t.tableAttrs)&&(Object.keys(t.tableAttrs).forEach(e=>{"class"!==e&&r.attr(e,t.tableAttrs[e])}),"string"==typeof t.tableAttrs.class&&t.tableAttrs.class&&r.addClass(t.tableAttrs.class)),r},e.mountTableShell=function(t,n){const o=t.find("table.custom-table, table").first();if(o.length)return o;const r=e.getTableInteractionHost(t);r.hasClass("custom-table-shell")||r.addClass("custom-table-shell");const a=e.createTableShell(n);return r.append(a),a}}(window.KGrid),function(e){e._fieldTypes=Object.create(null),e._configuredCustomInputTypeNames=[],e.registerFieldType=function(t,n,o){if(!t||"string"!=typeof t)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+t+"): plugin.create is required");if(e._fieldTypes[t]&&(!o||!o.overwrite))throw new Error("Field type already registered: "+t);return e._fieldTypes[t]=Object.assign({name:t},n),e},e.unregisterFieldType=function(t){return t&&e._fieldTypes[t]&&delete e._fieldTypes[t],e},e.getFieldType=function(t){return t&&e._fieldTypes[t]||null},e.listFieldTypes=function(){return Object.keys(e._fieldTypes)},e.createFieldInput=function({mode:t,col:n,config:o}){const r=o.type??"text",a=e.getFieldType(r);if(!a)return null;"function"==typeof a.validate&&a.validate(o,t,n);const i=a.create({mode:t,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},e.mountField=function(t){const n=t.config?.type??t.type,o=e.getFieldType(n);o&&"function"==typeof o.mount&&o.mount(t)},e.resolveFilterEvents=function({plugin:e,$input:t,createResult:n}){let o;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?o=n.filterEvents:e&&Object.prototype.hasOwnProperty.call(e,"filterEvents")&&(o=e.filterEvents),!1===o||null===o?null:"string"==typeof o&&o.trim()?o.trim():t.is("select")?"change":"input"},e.normalizeFilterDebounceMs=function(e,t){if(!1===e)return 0;if(void 0===e)return t;if(null===e)return t;const n=Number(e);return!Number.isFinite(n)||n<0?0:n},e.resolveFilterDebounceMs=function({filterConfig:t,plugin:n}){return t&&Object.prototype.hasOwnProperty.call(t,"debounceMs")&&null!==t.debounceMs?e.normalizeFilterDebounceMs(t.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?e.normalizeFilterDebounceMs(n.filterDebounceMs,0):e.normalizeFilterDebounceMs(e._config.filterDebounceMs,0)},e.shouldDebounceFilterSubmit=function(e,t){return!(!t||t<=0)&&!!e},e.bindFieldFilterSubmit=function(t,n,o){const r=e.getFieldType(t);r&&"function"==typeof r.bindFilterSubmit&&r.bindFilterSubmit(n,o)},e.bindFilterInputEvents=function({type:t,$input:n,onSubmit:o,createResult:r,filterConfig:a}){const i=t?e.getFieldType(t):null,l=e.resolveFilterEvents({plugin:i,$input:n,createResult:r}),s=e.resolveFilterDebounceMs({filterConfig:a,plugin:i}),c=e.wrapFilterSubmitHandler(n,o,l,s);l&&n.on(l,c),e.bindFieldFilterSubmit(t,n,c)},e.isPluggableFieldType=function(t){return!!e.getFieldType(t)},e.inputType=function(e,t){if("function"!=typeof e)throw new TypeError("inputType(mount, opts): mount must be a function");if(!t||"string"!=typeof t.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:t.filterEvents,filterDebounceMs:t.filterDebounceMs,validate:t.validate,create({mode:e}){const n=$(t.element);return!t.formInputClass||"insert"!==e&&"update"!==e||n.addClass(t.formInputClass),{$input:n,skipValueAttr:!!t.skipValueAttr}},mount(t){e(t.$input,t.config?.options??t.config,t)},bindFilterSubmit:t.bindFilterSubmit}},e._getCustomInputTypesConfig=function(){return e._config.customInputTypes??e._config.fieldTypes??null},e._syncCustomInputTypes=function(){const t=e._getCustomInputTypesConfig(),n=t&&"object"==typeof t?Object.keys(t).filter(e=>null!=t[e]):[];e._configuredCustomInputTypeNames.forEach(t=>{n.includes(t)||e.unregisterFieldType(t)}),n.forEach(n=>{const o=t[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()")}e.registerFieldType(n,o,{overwrite:!0})}),e._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(e){const t="kgrid-multi-select-value",n=";";function o(e,t,n){if(!e.length)return n;if(1===e.length){const n=t.find(function(t){return t.value===e[0]});return n?n.label:e[0]}return e.length+" selected"}function r(r,a,i){const l=a.separator||n,s=a.options||[],c=function(e){return null!=e.placeholder&&""!==e.placeholder?String(e.placeholder):"All"}(a),u="filter"===i;r.data("kgridMultiSep",l),r.addClass(t);const d=$("<div>").addClass("kgrid-multi-select").attr("data-mode",i),f=$("<div>").addClass("kgrid-multi-select-panel");let p=null;function m(){const t=e.parseMultiSelectValue(r[0].value,l);f.find("input[type='checkbox']").each(function(){this.checked=-1!==t.indexOf(this.value)}),p&&p.text(o(t,s,c))}function g(e){p&&(e?(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 e=p[0].getBoundingClientRect(),t=Math.max(e.width,192);let n=e.left;const o=window.innerWidth-t-8;n>o&&(n=Math.max(8,o));let r=e.bottom+2;const a=Math.min(224,28*s.length+16);r+a>window.innerHeight-8&&e.top>a+8&&(r=e.top-a-2),f.css({position:"fixed",top:r+"px",left:n+"px",width:t+"px",minWidth:t+"px",maxWidth:"min(18rem, calc(100vw - 16px))",zIndex:1080})}u?(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(t,n){const o="kgrid_ms_"+e.uuid()+"_"+n,r=$("<label>").addClass("kgrid-multi-select-option").attr("for",o);$("<input>").attr({type:"checkbox",id:o,value:t.value,class:"kgrid-multi-select-check"}).appendTo(r),$("<span>").addClass("kgrid-multi-select-label").text(t.label).appendTo(r),f.append(r)}),r.before(d),d.append(r);const y=".kgridMultiSelect_"+e.uuid();f.on("change","input[type='checkbox']",function(){!function(e){const t=[];f.find("input[type='checkbox']:checked").each(function(){t.push(this.value)});const n=t.join(l);r[0].value!==n&&(r[0].value=n,e&&r.trigger("change")),p&&p.text(o(t,s,c))}(!0)}),r.on("kgrid:multiselect:set",function(){m()}),p&&(p.on("click",function(e){e.preventDefault(),e.stopPropagation(),g(!d.hasClass("kgrid-multi-select-open"))}),$(document).on("mousedown"+y,function(e){d.hasClass("kgrid-multi-select-open")&&($(e.target).closest(d).length||$(e.target).closest(f).length||g(!1))}),$(window).on("resize"+y+" scroll"+y,function(){d.hasClass("kgrid-multi-select-open")&&h()}));const b=function(){const e=r.prop("form")||r[0]&&r[0].form;e&&$(e).off("reset"+y).on("reset"+y,function(){setTimeout(m,0)})};return b(),setTimeout(b,0),m(),d}e.normalizeMultiSelectValue=function(e,t){const o=t||n;return null==e||""===e?"":Array.isArray(e)?e.filter(function(e){return null!=e&&""!==e}).map(String).join(o):String(e)},e.parseMultiSelectValue=function(t,o){const r=e.normalizeMultiSelectValue(t,o);return r?r.split(o||n).filter(Boolean):[]},function(){const o=$.valHooks.hidden||{};$.valHooks.hidden={get:function(e){return e&&e.classList&&e.classList.contains(t)?e.value:o.get?o.get(e):void 0},set:function(r,a){if(r&&r.classList&&r.classList.contains(t)){const t=$(r).data("kgridMultiSep")||n;return r.value=e.normalizeMultiSelectValue(a,t),$(r).triggerHandler("kgrid:multiselect:set"),!0}return o.set?o.set(r,a):void 0}}}(),e.registerFieldType("multi_select",{filterEvents:"change",filterDebounceMs:0,validate(e,t){!function(e,t){if(!Array.isArray(e.options))throw new Error("multi_select requires an options array ("+t+"): "+JSON.stringify(e,null,2));e.options.forEach(function(t){if(!t||"string"!=typeof t.label||"string"!=typeof t.value)throw new Error("multi_select options need string label and value: "+JSON.stringify(e,null,2))})}(e,t)},create({config:e}){const n=$("<input type='hidden'>").addClass(t);return e.separator&&n.data("kgridMultiSep",e.separator),{$input:n,skipValueAttr:!0}},mount(e){if(r(e.$input,e.config||{},e.mode),"update"===e.mode&&e.item&&e.col&&e.col.name){const t=e.item.attributes?e.item.attributes[e.col.name]:null;null!=t&&""!==t&&e.$input.val(t)}}}),e.registerFieldType("date_range",{create:()=>({$input:$("<input autocomplete='off' type='date' class='form-control form-control-sm'/>")})})}(window.KGrid),function(e){e.resolveDefaultInteraction=function(e){return"edit"===e.defaultInteraction||"view"===e.defaultInteraction?e.defaultInteraction:!0===e.editmode?"edit":(e.editmode,"view")},e.getTableInteractionHost=function(e){if(e.hasClass("custom-table-shell"))return e;const t=e.find(".custom-table-shell").first();return t.length?t:e},e.applyInteraction=function(t,n,o){const r=e.getTableInteractionHost(t),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(e){e.setupLabelsHeader=function(t,n){const o=t.children("tr"),r=o.children(),a=r.first().clone(!0);r.remove();return[...n.columns].forEach(t=>{if(t.hidden)return;let n=a.clone(!0);if(t.attrs&&"object"==typeof t.attrs&&Object.keys(t.attrs).forEach(e=>n.attr(e,t.attrs[e])),e.applyColumnCellMeta(n,t),!t.features?.sort){const r=n.empty().html(t.label??"");return e.applyColumnCellMeta(r,t),void o.append(r)}if(!t.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(t,null,2));n.find("span.column-label").text(t.label??""),n.children("a").attr("data-sortfld",t.name),n.appendTo(o)}),e.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(o),o}}(window.KGrid),function(e){const t="kgridFilterDebounceTimer";e.cancelFilterSubmit=function(e){const n=e.data(t);n&&(clearTimeout(n),e.removeData(t))},e.cancelFilterDebounces=function(t){const n=$(t).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){e.cancelFilterSubmit($(this))})},e.flushFilterSubmit=function(e){const n=e.data(t);if(!n)return;clearTimeout(n),e.removeData(t);const o=e[0]&&e[0].form;o&&$(o).trigger("submit")},e.wrapFilterSubmitHandler=function(n,o,r,a){if(!e.shouldDebounceFilterSubmit(r,a))return o;const i=a;return function(){e.cancelFilterSubmit(n);const r=setTimeout(function(){n.removeData(t),o.call(this)}.bind(this),i);n.data(t,r)}},e.filterDefaultValue=function(e){return null!=e&&"object"==typeof e&&null!=e.value?e.value:e},e.columnFilterPersisted=function(e){const t=e&&e.filter?e.filter:{};return!(!e||!e.hidden&&"hidden"!==t.type&&!t.persist)},e.ensureFilterField=function(e,t,n,o){if(!e||!t||null==n||""===n)return null;let r=e.elements&&e.elements.namedItem(t);return r&&null!=r.length&&!r.tagName&&(r=r[0]),r&&r.tagName||(r=document.createElement("input"),r.type="hidden",r.name=t,e.appendChild(r)),r.setAttribute("data-operator",o||"="),r.value=String(n),r.defaultValue=String(n),r},e.applyColumnDefaultFilters=function(t,n){t&&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=e.filterDefaultValue(o.default);if(null==r||""===r)return;const a=o.operator||(e.columnFilterPersisted(n)?"=":"~=~"),i=e.filterFormField(t,n.name);!n.hidden&&"hidden"!==o.type&&i.length?i.val()||(i.val(String(r)),i.attr("data-operator",a)):e.ensureFilterField(t,n.name,r,a)})},e.setupDefaultFilters=function(t,n,o,r){const a=$(t)[0];if(!(a&&n&&n.features&&n.features.filtering))return;const i=n.columns||[];if(e.applyColumnDefaultFilters(a,i),i.some(e.columnFilterPersisted)){let t=!1;$(a).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!t){n.preventDefault(),e.cancelFilterDebounces(a),t=!0;try{a.reset(),e.applyColumnDefaultFilters(a,i),o&&o.filtering&&"function"==typeof o.filtering.handleSubmit?o.filtering.handleSubmit(a):$(a).trigger("submit")}finally{t=!1}}})}if(!o||!o.filtering)return;const l=i.filter(function(t){return t.name&&t.filter&&null!=t.filter.default&&""!==t.filter.default&&e.columnFilterPersisted(t)});if(!l.length)return;const s=String(o.url&&o.url.parameters&&o.url.parameters.filter||"");!l.some(function(e){return-1===s.indexOf(e.name+"=")})||r&&r.skipInitSubmit||o.filtering.handleSubmit(a)},e.setupFilterHeader=function(t,n){if(!n.features||!n.features.filtering)return null;const o=t.find(".thead-filters");o.empty();const r=[...n.columns],a=$("<tr>");a.appendTo(o);const i="filter_form_"+e.uuid(),l=$("<form>").attr("id",i).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(t);return r.forEach(t=>{const n=t.filter||{};if(t.hidden||"hidden"===n.type){if(t.features&&!1===t.features.filter)return;if(!t.name)return;const o=e.filterDefaultValue(n.default);return void(null!=o&&""!==o?e.ensureFilterField(l[0],t.name,o,n.operator||"="):e.columnFilterPersisted(t)&&e.ensureFilterField(l[0],t.name,"",n.operator||"="))}let o,r=$("<th>").appendTo(a).attr("data-label",t.label);if(e.applyColumnCellMeta(r,t),!1===t.features.filter)return;if(!t.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(t,null,2));let s=null;const c=e.createFieldInput({mode:"filter",col:t,config:n});if(c)s=c,o=c.$input,o.appendTo(r),e.mountField({mode:"filter",$input:o,col:t,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(t,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(t,null,2));n.options.forEach(e=>{if(!e.label||"string"!=typeof e.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.value).appendTo(o)}),o.appendTo(r)}else{if(!e.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)}const u=n.operator||("multi_select"===n.type?"><":void 0);null!=u&&o.attr("data-operator",u),o.attr("form",i),o.attr("name",t.name);const d=e.filterDefaultValue(n.default);if(null!=d&&""!==d&&!o.val()){const t="multi_select"===n.type?e.normalizeMultiSelectValue(d,n.separator):String(d);o.val(t),o.attr("data-default",t),o[0]&&(o[0].defaultValue=t)}e.bindFilterInputEvents({type:n.type,$input:o,onSubmit:function(){const e=this.form;e&&$(e).trigger("submit")},createResult:s,filterConfig:n})}),e.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(a),l},e.syncFormFiltersToCollectionUrl=function(e,t){if(!e||!t||!t.url)return;t.url.parameters||(t.url.parameters={});const n=[],o=e.elements;if(o){for(let e=0;e<o.length;e++){const t=o[e];if(!t||!t.name)continue;const r=$(t),a=r.val();if(null==a||""===a)continue;const i=r.attr("data-operator")||r.data("operator")||"=";n.push(t.name+i+a)}t.offset=0,n.length?t.url.parameters.filter=n.join(","):delete t.url.parameters.filter}},e.FilterForm=function(t){this.form=$(t)[0],this.filter=(t,n,o="~=~")=>{if(!this.form)return this;let r=e.filterFormField(this.form,t);if(r.length||(e.ensureFilterField(this.form,t,n,o),r=e.filterFormField(this.form,t)),!r.length)return this;e.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=(t,n,o="=")=>(e.ensureFilterField(this.form,t,n,o),this),this.reset=()=>(this.form&&(e.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(e){e.wrapFlagSwitch=function(e){return e.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(e)},e.setupCell=function(t,n){const o=n?n.attr("id"):null,r={...t},a=$("<td>").attr("data-label",t.label);e.applyColumnCellMeta(a,t);const i=r.attrs&&"object"==typeof r.attrs?r.attrs:{};Object.keys(i).forEach(e=>a.attr(e,i[e]));let l=$("<div>").addClass("cell-content");if(l.html(r.display.template??`{{${r.name}}}`),l.appendTo(a),null==n||!t.features.update)return l.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(t,null,2));const s=r.update,c=s.type??"text";let u,d=!1;const f=e.createFieldInput({mode:"update",col:t,config:s});if(f)u=f.$input,d=!!f.skipValueAttr;else{switch(c){case"textarea":u=$(`<textarea class='form-input form-control form-control-sm'>{{${s.value??r.name}}}</textarea>`),d=!0;break;case"select":if(u=$("<select class='form-input form-control form-control-sm'/>"),!Array.isArray(s.options))throw new Error("Select column must have an update.options array when column.features.update is true: \n"+JSON.stringify(t,null,2));s.options.forEach(e=>{if("string"!=typeof e.label||void 0===e.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.value).appendTo(u)}),d=!0;break;case"hidden":u=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const e=s.template||r.display.template||`{{${r.name}}}`;return $("<div>").addClass("cell-input").append(e).appendTo(a),a}case"checkbox":u=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),d=!0;break;default:if(!e.isValidInputType(c))throw new Error("Invalid update updateConfig type: "+JSON.stringify(s,null,2));u=$(`<input autocomplete='off' type='${c}' class='form-input form-control form-control-sm'/>`)}u.attr("data-type",c)}if(s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(e=>u.attr(e,s.attrs[e])),u.attr("form",o),u.attr("name",r.name),!d&&"textarea"!==c){const e=s.value??`{{${r.name}}}`;null!=e&&"object"!=typeof e&&u.attr("value",e)}if(r.hidden)return u.attr("type","hidden").appendTo(n),a;s.disabled&&u.attr("disabled",!0),s.readonly&&u.attr("readonly",!0),s.required&&u.attr("required",!0),s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(e=>u.attr(e,s.attrs[e])),s.disabled||s.readonly||u.attr("onchange","$(this).parents('tr').addClass('editing')");const p="checkbox"===c?e.wrapFlagSwitch(u):u;return $("<div>").addClass("cell-input").append(p).appendTo(a),a}}(window.KGrid),function(e){e.setupNoDataTbody=function(e,t,n){const o=e.find("td").attr("colspan",n);return t.noDataTemplate&&o.html(t.noDataTemplate),o},e.fillDataRow=function(t,n){const o=[...n.columns],r="data_row_form_"+e.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=e.setupCell(n,a);n.hidden||o.appendTo(t)}),e.hasActionColumn(n)){const o=$("<td>").addClass("kgrid-row-actions").appendTo(t);e.renderRowActions(o,n,r)}return a&&e.anchorRowForm(a,t),t},e.setupDataBody=function(t,n,o,r,a,i){const l=$("<tr>").appendTo(t);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(e=>l.attr(e,s[e])),t.data("emptyview",i),n?.features?.sorting&&t.data("sort",o),a&&t.data("paging",a.find(".pages")).data("pagesizeinp",a.find(".pagesize")).data("totalrecscount",a.find(".totalrecscount")),r&&t.data("filter",r),n.type&&t.data("type",n.type),e.fillDataRow(l,n),t},e.setupPagingFooter=function(t,n,o){return e.log("setupPagingFooter",t,n,o),n.pagingFooterAttrs&&e.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(e=>t.attr(e,n.pagingFooterAttrs[e])),e.log("noVisibleCols",o),t.find("td").attr("colspan",o),t}}(window.KGrid),function(e){e.setupNewRecordForm=function(t,n,o){if(!n.insertFormRow||!e.isPlainObject(n.insertFormRow))return t.find(".before-main-tbody").remove(),void t.find(".after-main-tbody").remove();const r=[...n.columns],a=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(t.find(".after-main-tbody").remove(),a.appendTo(t.find(".before-main-tbody"))):(t.find(".before-main-tbody").remove(),a.appendTo(t.find(".after-main-tbody")));const i="new_record_row_form_"+e.uuid(),l=$("<form class='table-row-form'>").attr("id",i).off("submit").on("submit",t=>{t.preventDefault();const a=e.serializeForm(t.target,r);Object.keys(a).forEach(e=>{r.find(t=>t.name===e)?.insert?.dontsave&&delete a[e]}),o.instance.newItem(a).then(()=>{t.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(a,t.target)}).catch(e.onError)});r.forEach(t=>{if(t.hidden){if(n.features?.create&&t.features?.create){const e=$("<input type='hidden'>").attr("name",t.name).attr("form",i).appendTo(l);t.insert.default&&e.val(t.insert.default)}return}if(!t.features.create){const n=$("<td>").appendTo(a).attr("data-label",t.label);return void e.applyColumnCellMeta(n,t)}const o=t.insert;if(!o||!e.isPlainObject(o))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(t,null,2));if(!o.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(t,null,2));let r;const s=o.type??"text",c=e.createFieldInput({mode:"insert",col:t,config:o});if(c)r=c.$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(t,null,2));o.options.forEach(e=>{if("string"!=typeof e.label||void 0===e.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.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(!e.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 u="object"==typeof o.default&&o.default&&null!=o.default.value?o.default.value:o.default;if("checkbox"===s){const t=e.isFlagOn(u);r.prop("checked",t).prop("defaultChecked",t)}else null==o.default||""===o.default||r.val()||String(u).trim()&&(r.val(u).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(e=>r.attr(e,o.attrs[e])),r.attr("form",i).attr("name",t.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(e=>r.attr(e,o.attrs[e])),"hidden"!==o.type){const n="checkbox"===s?e.wrapFlagSwitch(r):r,o=$("<td>").append(n).appendTo(a).attr("data-label",t.label);e.applyColumnCellMeta(o,t)}e.mountField({mode:"insert",$input:r,col:t,config:o,formEl:l[0],rowEl:a[0]}),o.events&&Array.isArray(o.events)&&o.events.forEach(e=>{r.off(e.event).on(e.event,function(t,...n){"function"==typeof e.callback&&e.callback(t,l[0],a[0],...n)})})}),e.anchorRowForm(l,a);const s=$("<td>").addClass("kgrid-row-actions").appendTo(a).attr("data-label","action"),c=$("<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(c),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(l[0],a[0]),a}}(window.KGrid),function(e){e.setupEvents=function(t,n,o,r){const a=t.views[0];o.columns.forEach(n=>{n.display.events.forEach(e=>{if(!e.selector||!e.event||!e.callback)throw new Error("Invalid event: "+JSON.stringify(e,null,2));a.el.find(e.selector).off(e.event).on(e.event,n=>{if("function"!=typeof e.callback)throw new Error("Event callback must be a function: "+JSON.stringify(e,null,2));e.callback(n,t,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(e.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,t,a,...r)})})}),o.features.update&&(a.el.find("[data-type]").each((n,o)=>{const i=o.getAttribute("data-type");if(!e.isPluggableFieldType(i))return;const l=r.get(o.name);l?.update&&e.mountField({mode:"update",$input:$(o),col:l,config:l.update,item:t,view:a})}),a.el.find("select[data-type='select']").each((e,n)=>{const o=r.get(n.name);if(!o)return;const a=t.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=e.isFlagOn(t.attributes[a.name]))}),a.el.find("form.edit-form").off("submit").on("submit",t=>{const n=t.target;t.preventDefault();const r=$(n).parents("[data-type=item]").data().instance,a=e.serializeForm(n);Object.keys(a).forEach(e=>{o.columns.find(t=>t.name===e)?.update?.dontsave&&delete a[e]}),r.update(a).catch(e.onError)}));const i=e.resolveRowActions(o),l=i.menuItems.some(e=>"clone"===e.action),s=i.menuItems.some(e=>"delete"===e.action);l&&a.el.find(".clone-item").off("click").on("click",e=>{e.preventDefault(),"function"==typeof o.onClone&&o.onClone(t,a,e)}),s&&a.el.find(".delete-item").off("click").on("click",n=>{n.preventDefault(),a.el.addClass("confirm-delete");const r=()=>a.el.removeClass("confirm-delete");e.runDeleteConfirm({item:t,view:a,options:o},()=>{t.delete().catch(e.onError).finally(r)},r)});const c=new Map;i.menuItems.forEach(e=>{e.id&&"function"==typeof e.callback&&c.set(e.id,e.callback)}),c.size&&a.el.find("[data-kgrid-action]").off("click.kgridAction").on("click.kgridAction",e=>{const n=e.currentTarget.getAttribute("data-kgrid-action"),o=c.get(n);o&&(e.preventDefault(),o(e,t,a))}),"function"==typeof o.onRowFields&&o.onRowFields(t,a,n)}}(window.KGrid),function(e){e.PREFERENCES_VERSION=1,e.localStoragePreferences={get:function(e){try{const t="undefined"!=typeof window?window:globalThis,n=t&&t.localStorage;if(!n)return null;const o=n.getItem(e);return o?JSON.parse(o):null}catch(e){return null}},set:function(e,t){try{const n="undefined"!=typeof window?window:globalThis,o=n&&n.localStorage;if(!o)return;if(null==t)return void o.removeItem(e);o.setItem(e,JSON.stringify(t))}catch(e){}}},e.preferencesStorageFor=function(t){return t&&t.preferencesStorage?t.preferencesStorage:e._config&&e._config.preferencesStorage?e._config.preferencesStorage:e.localStoragePreferences},e.layoutStorageKey=function(e){return"kgrid:"+e+":layout"},e.filtersStorageKey=function(e,t){let n="kgrid:"+e+":filters";return null!=t&&""!==String(t)&&(n+=":"+String(t)),n},e.chooserColumns=function(e){return(e||[]).filter(function(e){return e&&e.name&&!e.hidden})},e.layoutFromColumns=function(t){return{v:e.PREFERENCES_VERSION,columns:e.chooserColumns(t).map(function(e){return{name:e.name,hidden:!!e.userHidden}})}},e.parseFilterExpression=function(e){const t=String(e||""),n=["~=~",">=","<=","!=","=",">","<"];for(let e=0;e<n.length;e++){const o=n[e],r=t.indexOf(o);if(r>0)return{name:t.slice(0,r),operator:o,value:t.slice(r+o.length)}}return null},e.isUserFilterColumn=function(e){return!(!e||!e.name||e.hidden||e.features&&!1===e.features.filter)},e.readUserFilters=function(t,n){if(!t)return[];const o=[];return(n||[]).forEach(function(n){if(!e.isUserFilterColumn(n))return;const r=e.filterFormField(t,n.name);if(!r.length)return;const a=r.val();if(null==a||""===a||Array.isArray(a)&&!a.length)return;const i=r.attr("data-operator")||n.filter&&n.filter.operator||"~=~";o.push({name:n.name,value:Array.isArray(a)?a:String(a),operator:i})}),o},e.applyUserFilters=function(t,n,o){t&&o&&Array.isArray(o.filters)&&o.filters.forEach(function(o){if(!o||!o.name)return;const r=(n||[]).find(function(e){return e&&e.name===o.name});if(!e.isUserFilterColumn(r))return;if(null==o.value||""===o.value)return;let a=e.filterFormField(t,o.name);a.length||(e.ensureFilterField(t,o.name,o.value,o.operator),a=e.filterFormField(t,o.name)),a.length&&(a.val(o.value),o.operator&&a.attr("data-operator",o.operator))})},e.ensureUrlFiltersOnForm=function(t,n){if(!(t&&n&&n.url&&n.url.parameters))return;const o=String(n.url.parameters.filter||"");o&&o.split(",").forEach(function(n){const o=e.parseFilterExpression(n.trim());if(!o||!o.name||""===o.value)return;const r=e.filterFormField(t,o.name);return r.length&&r.val()?void 0:r.length?(r.val(o.value),void r.attr("data-operator",o.operator)):void e.ensureFilterField(t,o.name,o.value,o.operator)})},e.preferencesLoadLayout=function(t){if(!t||!t.storageKey)return null;const n=e.preferencesStorageFor(t).get(e.layoutStorageKey(t.storageKey));return n&&n.v===e.PREFERENCES_VERSION&&Array.isArray(n.columns)?n:null},e.preferencesSaveLayout=function(t,n){t&&t.storageKey&&e.preferencesStorageFor(t).set(e.layoutStorageKey(t.storageKey),n)},e.preferencesLoadFilters=function(t){if(!t||!t.storageKey)return null;const n=e.preferencesStorageFor(t).get(e.filtersStorageKey(t.storageKey,t.filterStorageScope));return n&&n.v===e.PREFERENCES_VERSION&&Array.isArray(n.filters)?n:null},e.preferencesSaveFilters=function(t,n){t&&t.storageKey&&e.preferencesStorageFor(t).set(e.filtersStorageKey(t.storageKey,t.filterStorageScope),{v:e.PREFERENCES_VERSION,filters:n||[]})},e.reorderColumns=function(e,t){const n=new Map,o=[];(e||[]).forEach(function(e,t){e&&e.hidden?o.push({col:e,index:t}):e&&e.name&&n.set(e.name,e)});const r=[];(t||[]).forEach(function(e){n.has(e)&&(r.push(n.get(e)),n.delete(e))}),n.forEach(function(e){r.push(e)});const a=r.slice();return o.forEach(function(e){a.splice(Math.min(e.index,a.length),0,e.col)}),a},e.columnDefaultUserHidden=function(e){return!(!e||!e.defaultHidden||e.locked||e.hidden)},e.mergeLayoutIntoColumns=function(t,n){const o=(t||[]).slice();o.forEach(function(t){t&&!t.hidden&&(t.userHidden=e.columnDefaultUserHidden(t))});const r=e.chooserColumns(o),a=new Map(r.map(function(e){return[e.name,e]})),i=[],l=new Set;(n&&Array.isArray(n.columns)?n.columns:[]).forEach(function(e){if(!e||!e.name||!a.has(e.name))return;const t=a.get(e.name);t.userHidden=!!e.hidden&&!t.locked,i.push(e.name),l.add(e.name)}),r.forEach(function(e){l.has(e.name)||i.push(e.name)});const s=e.reorderColumns(o,i),c=e.chooserColumns(s);if(c.length&&c.every(function(e){return e.userHidden})){(c.find(function(e){return!e.locked})||c[0]).userHidden=!1}return s},e.applyLayoutToDom=function(t,n,o){if(!t||!t.length)return;const r=e.chooserColumns(n).map(function(e){return e.name}),a={};e.chooserColumns(n).forEach(function(e){e.userHidden&&(a[e.name]=!0)});t.find(".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr").each(function(){const e=$(this),t=e.children(".kgrid-row-actions"),n={};e.children("[data-name]").each(function(){n[this.getAttribute("data-name")]=this}),r.forEach(function(o){const r=n[o];r&&(t.length?$(r).insertBefore(t):e.append(r),r.classList.toggle("kgrid-user-hidden",!!a[o]))})});const i=t.find(".kgrid-row-actions").length>0;e.syncActionColumnColgroup(t,r.length,i,o,e.chooserColumns(n))},e.refreshCollectionTemplate=function(t,n){if(!t||!t.instance||"function"!=typeof e.fillDataRow)return;const o=e.getKViews(n&&n.kviews);if(!o||"function"!=typeof o.template)return;const r=$("<tr>");n.dataRowAttrs&&e.isPlainObject(n.dataRowAttrs)&&Object.keys(n.dataRowAttrs).forEach(function(e){r.attr(e,n.dataRowAttrs[e])}),e.fillDataRow(r,n);const a=$("<div>").append(r).html(),i=o.template(a);t.instance.template=i,(t.instance.items||[]).forEach(function(e){(e.views||[]).forEach(function(e){e.template=i})})},e.setupFilterPersistence=function(t,n){t&&n&&n.storageKey&&n.features&&n.features.filtering&&$(t).off("submit.kgridFilterPrefs").on("submit.kgridFilterPrefs",function(){e.preferencesSaveFilters(n,e.readUserFilters(t,n.columns))})},e.applyColumnLayout=function(t,n,o){n.columns=e.mergeLayoutIntoColumns(n.columns,o);const r=t.$host.find("table").first();if(e.applyLayoutToDom(r,n.columns,n),e.refreshCollectionTemplate(t,n),"function"==typeof e.renderColumnChooserPanel){const o=t.$host.find(".kgrid-column-chooser-panel");o.length&&e.renderColumnChooserPanel(o,n,t)}return e.layoutFromColumns(n.columns)}}(window.KGrid),function(e){function t(t){const n=[];return t.find(".kgrid-column-chooser-list li[data-name]").each(function(){const e=this.getAttribute("data-name"),t=$(this).find("input[type='checkbox']").prop("checked");n.push({name:e,hidden:!t})}),{v:e.PREFERENCES_VERSION,columns:n}}e.renderColumnChooserPanel=function(n,o,r){n.empty();const a=$("<ul>").addClass("kgrid-column-chooser-list").appendTo(n);e.chooserColumns(o.columns).forEach(function(e){const t=$("<li>").attr("draggable","true").attr("data-name",e.name).appendTo(a);$("<span>").addClass("kgrid-column-chooser-handle").attr("aria-hidden","true").text("⋮⋮").appendTo(t);const n=$("<label>").appendTo(t),o=$("<input>").attr("type","checkbox").prop("checked",!e.userHidden).appendTo(n);e.locked&&o.prop("disabled",!0).attr("title","This column cannot be hidden"),n.append(document.createTextNode(" "+(e.label||e.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 e=t(n);(function(e){return e.columns.filter(function(e){return!e.hidden}).length})(e)<1?this.checked=!0:r.setLayout(e)}),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(e){i=this,$(this).addClass("kgrid-column-chooser-dragging"),e.originalEvent&&e.originalEvent.dataTransfer&&(e.originalEvent.dataTransfer.effectAllowed="move",e.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(e){if(e.preventDefault(),!i||i===this)return;const t=this.getBoundingClientRect(),n=t.top+t.height/2;(e.originalEvent?e.originalEvent.clientY:0)<n?this.parentNode.insertBefore(i,this):this.parentNode.insertBefore(i,this.nextSibling)}),a.on("drop.kgridChooserDrag","li",function(e){e.preventDefault(),r.setLayout(t(n))})},e.setupColumnChooser=function(t,n,o){if(!n.features||!n.features.columnChooser)return;const r=e.getTableInteractionHost(t);r.find(".kgrid-column-chooser").remove();const a=n.columnChooserLabel||"Columns",i=$("<div>").addClass("kgrid-column-chooser"),l=$("<button>").attr("type","button").addClass("kgrid-column-chooser-toggle btn btn-sm btn-outline-secondary").attr("title",a).attr("aria-expanded","false").attr("aria-haspopup","true").html('<i class="fas fa-table-columns" aria-hidden="true"></i><span class="kgrid-column-chooser-toggle-label"> '+$("<div>").text(a).html()+"</span>"),s=$("<div>").addClass("kgrid-column-chooser-panel").attr("hidden","hidden");function c(){s.attr("hidden","hidden"),l.attr("aria-expanded","false")}i.append(l,s),r.prepend(i),e.renderColumnChooserPanel(s,n,o),l.on("click",function(e){e.stopPropagation();!s.attr("hidden")?c():(s.removeAttr("hidden"),l.attr("aria-expanded","true"))});const u="kgridChooser"+e.uuid();$(document).on("pointerdown."+u,function(e){document.body.contains(i[0])?i[0].contains(e.target)||c():$(document).off("pointerdown."+u)})}}(window.KGrid),function(e){e.init=async function(t,n){const o=e.resolveHostElement(t),r={...e.protoOptions,...n},a=e.mountTableShell(o,r);e.log("table config options",r);const i=e.resolveDefaultInteraction(r);e.applyInteraction(o,i);const l={$host:o,instance:null,filterForm:null,find:e=>o.find(e),setInteraction:(t,n)=>(e.applyInteraction(o,t,n),l),getInteraction:()=>"edit"===e.getTableInteractionHost(o).attr("data-interaction")?"edit":"view",setEditMode(e){if("boolean"!=typeof e)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return l.setInteraction(e?"edit":"view")},toggleEditMode:e=>(null!=e&&"object"==typeof e&&"function"==typeof e.preventDefault&&(e=void 0),"boolean"==typeof e?l.setInteraction(e?"edit":"view"):l.setInteraction("edit"===l.getInteraction()?"view":"edit")),getLayout:()=>e.layoutFromColumns(r.columns),setLayout:t=>(e.applyColumnLayout(l,r,t),e.preferencesSaveLayout(r,l.getLayout()),l.getLayout()),resetLayout(){const t=new Map;return r.columns.forEach(function(e){e&&e.name&&t.set(e.name,e)}),r.columns=s.map(function(e){return t.get(e)}).filter(Boolean),e.preferencesSaveLayout(r,null),e.applyColumnLayout(l,r,null),l.getLayout()}};r.columns=(r.columns||[]).map(t=>e.normalizeColumnConfig(t));const s=r.columns.map(function(e){return e.name});r.columns=e.mergeLayoutIntoColumns(r.columns,e.preferencesLoadLayout(r));const c=r.handlers??{};if(delete r.handlers,"string"==typeof r.onClone){const e=c[r.onClone]||r.functions&&r.functions[r.onClone];if(!e||"function"!=typeof e)throw new Error("onClone handler "+r.onClone+" not found or is not a function");r.onClone=e}e.resolveRowActions(r,c);{const t=r._resolvedRowActions;e.getTableInteractionHost(o).attr("data-has-row-menu",t&&t.menuItems&&t.menuItems.length?"true":"false")}r.columns.forEach(e=>{["insert","update","display"].forEach(t=>{const n=e[t].events;if(!n||!Array.isArray(n))throw new Error("Column "+e.name+" events are not an array");n.forEach(t=>{if("string"==typeof t.callback){const n=c[t.callback]||r.functions&&r.functions[t.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+t.callback+" not found for column "+e.name+" or is not a function");t.callback=n}else if("function"!=typeof t.callback)throw new Error("Event callback must be a function for column "+e.name)})});const t=e.display;t&&t.events&&Array.isArray(t.events)&&t.events.forEach(e=>{if("string"==typeof e.callback){const t=c[e.callback]||r.functions&&r.functions[e.callback];t&&"function"==typeof t&&(e.callback=t)}})});const u=new Map;r.columns.forEach(e=>{u.set(e.name,e)});const d=e.setupLabelsHeader(a.find(".thead-labels"),r),f=e.hasActionColumn(r),p=d.find("th").length,m=p-(f?1:0);e.syncActionColumnColgroup(a,m,f,r,e.chooserColumns(r.columns));const g=r.filterForm??e.setupFilterHeader(a,r);let h;r.features&&r.features.paging?h=e.setupPagingFooter(a.find(".paging-footer"),r,p):(h=null,a.find(".paging-footer").remove());const y=e.setupNoDataTbody(a.find(".no-data-tbody"),r,p);r.features&&r.features.create&&e.setupNewRecordForm(a,r,l),l.filterForm=new e.FilterForm(g);const b=e.setupDataBody(a.find(".main-tbody"),r,d,g,h,y),w={dontload:!0,setAttrAsId:r.setAttrAsId??!1,itemListeners:{afterrender:t=>e.setupEvents(t,l.find("table"),r,u)}},v=e.getKViews(r.kviews);if(!v)throw new Error(e.KVIEWS_MISSING_MSG);l.instance=await v.createCollectionInstance(b,w),r.url&&(l.instance.setUrl(r.url),r.deleteUrl&&(e.log("set deleteUrl",r.deleteUrl),l.instance.setUrl(r.deleteUrl,"delete")),r.updateUrl&&(e.log("set updateUrl",r.updateUrl),l.instance.setUrl(r.updateUrl,"update")),r.insertUrl&&l.instance.setUrl(r.insertUrl,"insert")),e.setupDefaultFilters(g,r,l.instance,{skipInitSubmit:!0});const C=g&&(g.jquery?g[0]:g);if(e.applyUserFilters(C,r.columns,e.preferencesLoadFilters(r)),e.ensureUrlFiltersOnForm(C,l.instance),e.setupFilterPersistence(C,r),e.setupColumnChooser(o,r,l),r.url)try{r.features&&r.features.filtering&&C&&e.syncFormFiltersToCollectionUrl(C,l.instance),await l.instance.loadFromRemote()}catch(t){e.onError(t)}else{if(!r.data||r.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const e=r.data.map(e=>({attributes:e}));l.instance.loadFromData(e)}}return l}}(window.KGrid);
|
|
1
|
+
/*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-09-18T05:41:38.912Z */
|
|
2
|
+
!function(e){function t(e){const t={},n=e&&e.elements;if(!n)return t;for(let e=0;e<n.length;e++){const o=n[e],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){t[r]=o.checked?"1":"0";continue}if("radio"===i){if(!o.checked)continue;t[r]=o.value;continue}if("SELECT"===o.tagName&&o.multiple){t[r]=Array.from(o.selectedOptions).map(function(e){return e.value});continue}const a=o.value;Object.prototype.hasOwnProperty.call(t,r)?(Array.isArray(t[r])||(t[r]=[t[r]]),t[r].push(a)):t[r]=a}return t}e.isFlagOn=function(e){return!0===e||1===e||"1"===e},e.serializeFormDefault=t;const n={log:function(){},onError:function(e){console.error(e)},confirm:function(e,t,n){"undefined"!=typeof window&&window.confirm(e)?t():n&&n()},deleteConfirm:null,serializeForm:t,customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300,preferencesStorage:null};e._config=Object.assign({},n),e.configure=function(t){return t&&"object"==typeof t&&Object.assign(e._config,t),"function"==typeof e._syncCustomInputTypes&&e._syncCustomInputTypes(),e},e.log=function(){e._config.log.apply(null,arguments)},e.onError=function(t){return e._config.onError(t)},e.confirm=function(t,n,o){return e._config.confirm(t,n,o)},e.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",e._defaultDeleteConfirm=function(t,n,o){e.confirm(e.DEFAULT_DELETE_CONFIRM_MESSAGE,n,o)},e.runDeleteConfirm=function(t,n,o){const r=t.options&&"function"==typeof t.options.deleteConfirm?t.options.deleteConfirm:null,i="function"==typeof e._config.deleteConfirm?e._config.deleteConfirm:null;return(r||i||e._defaultDeleteConfirm)(t,n,o)},e.serializeForm=function(t,n){return e._config.serializeForm(t,n)},e.getKViews=function(t){const n=[t,e._config.kviews];for(let e=0;e<n.length;e++){const t=n[e];if(t&&"function"==typeof t.createCollectionInstance)return t}const o=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return o&&"function"==typeof o.createCollectionInstance?o:null},e.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(e){e.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"},tableAttrs:{class:""},labelsRowAttrs:{},dataRowAttrs:{},filtersRowAttrs:null,pagingPageSizes:[10,25,50,75],pagingDefaultSize:10,emptyRowMessage:null,pagingFooterLabel:"records per page. Total"},e.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}},e.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],e.VALID_INPUT_TYPES=e.VALID_NATIVE_INPUT_TYPES.slice(),e.VALID_NATIVE_FILTER_TYPES=e.VALID_NATIVE_INPUT_TYPES.filter(e=>"displayonly"!==e),e.VALID_FILTER_TYPES=e.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),e.isValidInputType=function(t){return e.VALID_NATIVE_INPUT_TYPES.includes(t)||e.isPluggableFieldType(t)},e.isValidFilterType=function(t){return"displayonly"!==t&&(e.VALID_NATIVE_FILTER_TYPES.includes(t)||e.isPluggableFieldType(t))}}(window.KGrid=window.KGrid||{}),function(e){e.isPlainObject=function(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)},e.setDefaultValues=function(t,n){const o={...t||{}};return Object.keys(n||{}).forEach(t=>{e.isPlainObject(n[t])&&e.isPlainObject(o[t])?o[t]=e.setDefaultValues(o[t],n[t]):e.isPlainObject(n[t])&&null==o[t]?o[t]=e.setDefaultValues({},n[t]):o[t]=n[t]}),o},e.normalizeColumnConfig=function(t){let n=t&&"object"==typeof t?{...t}:{};if(e.isPlainObject(n.input)){const t={...n.input};delete n.input,n.insert=e.setDefaultValues(t,n.insert||{}),n.update=e.setDefaultValues(t,n.update||{})}const o=e.setDefaultValues(e.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(e=>{o[e]&&"object"==typeof o[e]&&(Array.isArray(o[e].events)||(o[e].events=[]))}),o}}(window.KGrid),function(e){e.resolveHostElement=function(e){if(null==e)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof e&&e.jquery){if(!e.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return e}if("object"==typeof e&&1===e.nodeType&&"string"==typeof e.nodeName)return $(e);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},e.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},e.columnWidthCss=function(e){if(!e||!e.attrs)return null;const t=e.attrs.width;return null==t||""===t?null:"number"==typeof t||/^\d+(\.\d+)?$/.test(String(t))?String(t)+"px":String(t)},e.applyColumnDomAttrs=function(e,t){const n=t&&t.attrs&&"object"==typeof t.attrs?t.attrs:null;return n?(Object.keys(n).forEach(function(t){"width"!==t&&e.attr(t,n[t])}),e):e},e.layoutVisibleColumns=function(e){return(e||[]).filter(function(e){return e&&e.name&&!e.hidden&&!e.userHidden})},e.participatingColumnCount=function(t,n){return e.layoutVisibleColumns(t).length+(n?1:0)},e.syncActionColumnColgroup=function(t,n,o,r,i){let a=t.children("colgroup.kgrid-colgroup");a.length||(a=$("<colgroup>").addClass("kgrid-colgroup").prependTo(t)),a.empty();const l=Array.isArray(i)?i:null;let s=0;if(l&&l.length)l.forEach(function(t){if(t&&t.userHidden)return;const n=$("<col>");t&&t.name&&n.attr("data-name",t.name);const o=e.columnWidthCss(t);o&&n.css("width",o),a.append(n),s+=1});else for(let e=0;e<n;e++)a.append($("<col>")),s+=1;return o&&a.append($("<col>").addClass("kgrid-row-actions-col").css("width",e.actionColumnWidth(r))),s},e.syncSpanningCells=function(e,t){e&&e.length&&t&&e.find(".paging-footer td, .no-data-tbody td").attr("colspan",t)},e.anchorRowForm=function(e,t){if(!(e&&e.length&&t&&t.length))return e;e.attr("hidden","hidden").attr("aria-hidden","true");const n=t.children("td").first();return n.length&&e.prependTo(n),e},e.filterFormField=function(e,t){if(!e||!t)return $();const n=e.elements&&e.elements.namedItem(t);if(n)return $(n);if(e.id){const n=document.querySelector(`[form="${e.id}"][name="${t}"]`);if(n)return $(n)}return $()},e.columnClassName=function(e){if(!e)return null;const t=null!=e.class&&""!==e.class?e.class:e.columnClass;return null!=t&&""!==t?String(t):null},e.applyColumnCellMeta=function(t,n){if(!t||!t.length||!n)return t;n.name&&t.attr("data-name",n.name);const o=e.columnClassName(n);return o&&t.addClass(o),t.toggleClass("kgrid-user-hidden",!!n.userHidden),t}}(window.KGrid),function(e){function t(e){"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(e)}function n(e){return e?"<i class='"+e+"'></i>":""}function o(e,t,o){const r=$("<button>").addClass(t.btnClass||"btn btn-sm btn-outline-secondary").attr("type","save"===t.action?"submit":"button").attr("title",t.title||t.label||"");return t.class&&r.addClass(t.class),"save"!==t.action&&"cancel"!==t.action||(r.attr("name","save"===t.action?"save":"cancel"),o&&r.attr("form",o)),"cancel"===t.action&&r.attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()"),t.id&&r.attr("data-kgrid-action",t.id),t.action&&r.attr("data-kgrid-builtin",t.action),t.icon?(r.html(n(t.icon)),t.showLabel&&t.label&&r.append(document.createTextNode(" "+t.label))):t.label&&r.text(t.label),r.appendTo(e),r}e.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"}},e.normalizeRowActionItem=function(n,o,r){if(!n||"object"!=typeof n)return null;const i=n.action;if("save"===i||"cancel"===i)return t("KGrid: rowActions items should not list '"+i+"' — it is added automatically when features.update is true"),null;let a={};if(i&&e.BUILTIN_ROW_ACTIONS[i])a={...e.BUILTIN_ROW_ACTIONS[i]};else{if(!n.id)return t("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&&e.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 e=function(e,t,n){if(!e||"string"!=typeof e)return null;const o=t&&t[e]||n.functions&&n.functions[e];return"function"==typeof o?o:null}(l.callback,o,r);if(!e)throw new Error("rowAction callback "+l.callback+" not found or is not a function");l.callback=e}if(l.id&&"function"!=typeof l.callback&&!l.action)throw new Error("Custom rowAction '"+l.id+"' requires a callback");return l},e.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:e.isPlainObject(o)&&(i="dropdown"===o.display?"dropdown":"buttons",a=Array.isArray(o.items)?o.items:[]),(r.delete||r.clone)&&t("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(t){const r=e.normalizeRowActionItem(t,o,n||{});r&&l.push(r)});const s=[];r.update&&(s.push({...e.BUILTIN_ROW_ACTIONS.save}),s.push({...e.BUILTIN_ROW_ACTIONS.cancel}));const c={display:i,menuItems:l,editingItems:s};return n&&(n._resolvedRowActions=c),c},e.hasActionColumn=function(t){const n=t&&t.features;if(n&&n.create)return!0;const o=e.resolveRowActions(t);return o.menuItems.length>0||o.editingItems.length>0},e.actionColumnWidth=function(t){const n=e.resolveRowActions(t),o=t&&t.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(e){return"editing"!==e.when}).length;return(2.5*Math.max(a,r,i,1)+.75).toFixed(2)+"rem"},e.closeRowActionDropdowns=function(e){$(".kgrid-row-actions-menu").each(function(){const t=$(this),n=t.children(".dropdown-menu");e&&n[0]===e[0]||(n.removeClass("show").css({top:"",left:"",right:"",position:""}),t.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded","false").removeClass("show"))})},e.mountRowActionDropdowns=function(t){t&&t.length&&(e._rowActionsDropdownDocBound||(e._rowActionsDropdownDocBound=!0,$(document).on("click.kgridRowActions",function(){e.closeRowActionDropdowns()}).on("keydown.kgridRowActions",function(t){"Escape"===t.key&&e.closeRowActionDropdowns()})),t.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function(){const t=this,n=$(t),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(e.closeRowActionDropdowns(),!i)return;const a=t.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(e){e.stopPropagation()}),o.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose",function(){setTimeout(function(){e.closeRowActionDropdowns()},0)})}))},e.escapeHtml=e.escapeHtml||function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},e.renderRowActions=function(t,r,i){const a=e.resolveRowActions(r),l=a.menuItems.filter(function(e){return"editing"!==e.when}),s=a.menuItems.filter(function(e){return"editing"===e.when});if("dropdown"===a.display&&l.length>0){const o=$("<div>").addClass("btn-group kgrid-row-actions-menu").appendTo(t);$("<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 r=$("<ul>").addClass("dropdown-menu dropdown-menu-end").appendTo(o);l.forEach(function(t){const o=$("<li>").appendTo(r),i=$("<button>").addClass("dropdown-item").attr("type","button").appendTo(o);"clone"===t.action?i.addClass("clone-item"):"delete"===t.action&&i.addClass("delete-item text-danger"),t.id&&i.attr("data-kgrid-action",t.id),t.action&&i.attr("data-kgrid-builtin",t.action),t.class&&i.addClass(t.class),t.btnClass&&!t.action&&/\bbtn-danger\b|\btext-danger\b|\boutline-danger\b/.test(t.btnClass)&&i.addClass("text-danger");const a=t.label||t.title||t.action||t.id;t.icon?i.html(n(t.icon)+" "+e.escapeHtml(a)):i.text(a)})}else l.forEach(function(e){const n=$("<div>").addClass(e.groupClass||"btn-group kgrid-custom-action-grp").appendTo(t);"always"===e.when&&n.addClass("kgrid-action-always"),o(n,e,i)});const c=a.editingItems.concat(s);if(c.length){const e=$("<div>").addClass("btn-group edit-item-grp").appendTo(t);c.forEach(function(t){o(e,t,i)})}}}(window.KGrid),function(e){e.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",e.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"><<</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary"><</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">></button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">>></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(),e._escapeTableShellText=function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},e._renderPageSizeOptions=function(e,t){return e.map(e=>{const n=String(e);return` <option value="${n}"${n===String(t)?" selected":""}>${n}</option>`}).join("\n")},e.renderTableShellHtml=function(t,n){const o=Array.isArray(t.pagingPageSizes)?t.pagingPageSizes:[10,25,50,75],r=null!=t.pagingDefaultSize?t.pagingDefaultSize:o[0],i=e._escapeTableShellText(t.emptyRowMessage||e.DEFAULT_EMPTY_ROW_MESSAGE),a=e._escapeTableShellText(t.pagingFooterLabel||"records per page. Total");return(n||e.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,i).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(r)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,e._renderPageSizeOptions(o,r)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,a)},e.createTableShell=function(t){const n=e.renderTableShellHtml(t),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 t.tableAttrs&&e.isPlainObject(t.tableAttrs)&&(Object.keys(t.tableAttrs).forEach(e=>{"class"!==e&&r.attr(e,t.tableAttrs[e])}),"string"==typeof t.tableAttrs.class&&t.tableAttrs.class&&r.addClass(t.tableAttrs.class)),r},e.mountTableShell=function(t,n){const o=t.find("table.custom-table, table").first();if(o.length)return o;const r=e.getTableInteractionHost(t);r.hasClass("custom-table-shell")||r.addClass("custom-table-shell");const i=e.createTableShell(n);return r.append(i),i}}(window.KGrid),function(e){e._fieldTypes=Object.create(null),e._configuredCustomInputTypeNames=[],e.registerFieldType=function(t,n,o){if(!t||"string"!=typeof t)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+t+"): plugin.create is required");if(e._fieldTypes[t]&&(!o||!o.overwrite))throw new Error("Field type already registered: "+t);return e._fieldTypes[t]=Object.assign({name:t},n),e},e.unregisterFieldType=function(t){return t&&e._fieldTypes[t]&&delete e._fieldTypes[t],e},e.getFieldType=function(t){return t&&e._fieldTypes[t]||null},e.listFieldTypes=function(){return Object.keys(e._fieldTypes)},e.createFieldInput=function({mode:t,col:n,config:o}){const r=o.type??"text",i=e.getFieldType(r);if(!i)return null;"function"==typeof i.validate&&i.validate(o,t,n);const a=i.create({mode:t,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},e.mountField=function(t){const n=t.config?.type??t.type,o=e.getFieldType(n);o&&"function"==typeof o.mount&&o.mount(t)},e.resolveFilterEvents=function({plugin:e,$input:t,createResult:n}){let o;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?o=n.filterEvents:e&&Object.prototype.hasOwnProperty.call(e,"filterEvents")&&(o=e.filterEvents),!1===o||null===o?null:"string"==typeof o&&o.trim()?o.trim():t.is("select")?"change":"input"},e.normalizeFilterDebounceMs=function(e,t){if(!1===e)return 0;if(void 0===e)return t;if(null===e)return t;const n=Number(e);return!Number.isFinite(n)||n<0?0:n},e.resolveFilterDebounceMs=function({filterConfig:t,plugin:n}){return t&&Object.prototype.hasOwnProperty.call(t,"debounceMs")&&null!==t.debounceMs?e.normalizeFilterDebounceMs(t.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?e.normalizeFilterDebounceMs(n.filterDebounceMs,0):e.normalizeFilterDebounceMs(e._config.filterDebounceMs,0)},e.shouldDebounceFilterSubmit=function(e,t){return!(!t||t<=0)&&!!e},e.bindFieldFilterSubmit=function(t,n,o){const r=e.getFieldType(t);r&&"function"==typeof r.bindFilterSubmit&&r.bindFilterSubmit(n,o)},e.bindFilterInputEvents=function({type:t,$input:n,onSubmit:o,createResult:r,filterConfig:i}){const a=t?e.getFieldType(t):null,l=e.resolveFilterEvents({plugin:a,$input:n,createResult:r}),s=e.resolveFilterDebounceMs({filterConfig:i,plugin:a}),c=e.wrapFilterSubmitHandler(n,o,l,s);l&&n.on(l,c),e.bindFieldFilterSubmit(t,n,c)},e.isPluggableFieldType=function(t){return!!e.getFieldType(t)},e.inputType=function(e,t){if("function"!=typeof e)throw new TypeError("inputType(mount, opts): mount must be a function");if(!t||"string"!=typeof t.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:t.filterEvents,filterDebounceMs:t.filterDebounceMs,validate:t.validate,create({mode:e}){const n=$(t.element);return!t.formInputClass||"insert"!==e&&"update"!==e||n.addClass(t.formInputClass),{$input:n,skipValueAttr:!!t.skipValueAttr}},mount(t){e(t.$input,t.config?.options??t.config,t)},bindFilterSubmit:t.bindFilterSubmit}},e._getCustomInputTypesConfig=function(){return e._config.customInputTypes??e._config.fieldTypes??null},e._syncCustomInputTypes=function(){const t=e._getCustomInputTypesConfig(),n=t&&"object"==typeof t?Object.keys(t).filter(e=>null!=t[e]):[];e._configuredCustomInputTypeNames.forEach(t=>{n.includes(t)||e.unregisterFieldType(t)}),n.forEach(n=>{const o=t[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()")}e.registerFieldType(n,o,{overwrite:!0})}),e._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(e){const t="kgrid-multi-select-value",n=";";function o(e,t,n){if(!e.length)return n;if(1===e.length){const n=t.find(function(t){return t.value===e[0]});return n?n.label:e[0]}return e.length+" selected"}function r(r,i,a){const l=i.separator||n,s=i.options||[],c=function(e){return null!=e.placeholder&&""!==e.placeholder?String(e.placeholder):"All"}(i),u="filter"===a;r.data("kgridMultiSep",l),r.addClass(t);const d=$("<div>").addClass("kgrid-multi-select").attr("data-mode",a),f=$("<div>").addClass("kgrid-multi-select-panel");let p=null;function m(){const t=e.parseMultiSelectValue(r[0].value,l);f.find("input[type='checkbox']").each(function(){this.checked=-1!==t.indexOf(this.value)}),p&&p.text(o(t,s,c))}function g(e){p&&(e?(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 e=p[0].getBoundingClientRect(),t=Math.max(e.width,192);let n=e.left;const o=window.innerWidth-t-8;n>o&&(n=Math.max(8,o));let r=e.bottom+2;const i=Math.min(224,28*s.length+16);r+i>window.innerHeight-8&&e.top>i+8&&(r=e.top-i-2),f.css({position:"fixed",top:r+"px",left:n+"px",width:t+"px",minWidth:t+"px",maxWidth:"min(18rem, calc(100vw - 16px))",zIndex:1080})}u?(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(t,n){const o="kgrid_ms_"+e.uuid()+"_"+n,r=$("<label>").addClass("kgrid-multi-select-option").attr("for",o);$("<input>").attr({type:"checkbox",id:o,value:t.value,class:"kgrid-multi-select-check"}).appendTo(r),$("<span>").addClass("kgrid-multi-select-label").text(t.label).appendTo(r),f.append(r)}),r.before(d),d.append(r);const y=".kgridMultiSelect_"+e.uuid();f.on("change","input[type='checkbox']",function(){!function(e){const t=[];f.find("input[type='checkbox']:checked").each(function(){t.push(this.value)});const n=t.join(l);r[0].value!==n&&(r[0].value=n,e&&r.trigger("change")),p&&p.text(o(t,s,c))}(!0)}),r.on("kgrid:multiselect:set",function(){m()}),p&&(p.on("click",function(e){e.preventDefault(),e.stopPropagation(),g(!d.hasClass("kgrid-multi-select-open"))}),$(document).on("mousedown"+y,function(e){d.hasClass("kgrid-multi-select-open")&&($(e.target).closest(d).length||$(e.target).closest(f).length||g(!1))}),$(window).on("resize"+y+" scroll"+y,function(){d.hasClass("kgrid-multi-select-open")&&h()}));const b=function(){const e=r.prop("form")||r[0]&&r[0].form;e&&$(e).off("reset"+y).on("reset"+y,function(){setTimeout(m,0)})};return b(),setTimeout(b,0),m(),d}e.normalizeMultiSelectValue=function(e,t){const o=t||n;return null==e||""===e?"":Array.isArray(e)?e.filter(function(e){return null!=e&&""!==e}).map(String).join(o):String(e)},e.parseMultiSelectValue=function(t,o){const r=e.normalizeMultiSelectValue(t,o);return r?r.split(o||n).filter(Boolean):[]},function(){const o=$.valHooks.hidden||{};$.valHooks.hidden={get:function(e){return e&&e.classList&&e.classList.contains(t)?e.value:o.get?o.get(e):void 0},set:function(r,i){if(r&&r.classList&&r.classList.contains(t)){const t=$(r).data("kgridMultiSep")||n;return r.value=e.normalizeMultiSelectValue(i,t),$(r).triggerHandler("kgrid:multiselect:set"),!0}return o.set?o.set(r,i):void 0}}}(),e.registerFieldType("multi_select",{filterEvents:"change",filterDebounceMs:0,validate(e,t){!function(e,t){if(!Array.isArray(e.options))throw new Error("multi_select requires an options array ("+t+"): "+JSON.stringify(e,null,2));e.options.forEach(function(t){if(!t||"string"!=typeof t.label||"string"!=typeof t.value)throw new Error("multi_select options need string label and value: "+JSON.stringify(e,null,2))})}(e,t)},create({config:e}){const n=$("<input type='hidden'>").addClass(t);return e.separator&&n.data("kgridMultiSep",e.separator),{$input:n,skipValueAttr:!0}},mount(e){if(r(e.$input,e.config||{},e.mode),"update"===e.mode&&e.item&&e.col&&e.col.name){const t=e.item.attributes?e.item.attributes[e.col.name]:null;null!=t&&""!==t&&e.$input.val(t)}}}),e.registerFieldType("date_range",{create:()=>({$input:$("<input autocomplete='off' type='date' class='form-control form-control-sm'/>")})})}(window.KGrid),function(e){e.resolveDefaultInteraction=function(e){return"edit"===e.defaultInteraction||"view"===e.defaultInteraction?e.defaultInteraction:!0===e.editmode?"edit":(e.editmode,"view")},e.getTableInteractionHost=function(e){if(e.hasClass("custom-table-shell"))return e;const t=e.find(".custom-table-shell").first();return t.length?t:e},e.applyInteraction=function(t,n,o){const r=e.getTableInteractionHost(t),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(e){e.setupLabelsHeader=function(t,n){const o=t.children("tr"),r=o.children(),i=r.first().clone(!0);r.remove();return[...n.columns].forEach(t=>{if(t.hidden)return;let n=i.clone(!0);if(e.applyColumnDomAttrs(n,t),e.applyColumnCellMeta(n,t),!t.features?.sort){const r=n.empty().html(t.label??"");return e.applyColumnCellMeta(r,t),void o.append(r)}if(!t.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(t,null,2));n.find("span.column-label").text(t.label??""),n.children("a").attr("data-sortfld",t.name),n.appendTo(o)}),e.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(o),o}}(window.KGrid),function(e){const t="kgridFilterDebounceTimer";e.cancelFilterSubmit=function(e){const n=e.data(t);n&&(clearTimeout(n),e.removeData(t))},e.cancelFilterDebounces=function(t){const n=$(t).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){e.cancelFilterSubmit($(this))})},e.flushFilterSubmit=function(e){const n=e.data(t);if(!n)return;clearTimeout(n),e.removeData(t);const o=e[0]&&e[0].form;o&&$(o).trigger("submit")},e.wrapFilterSubmitHandler=function(n,o,r,i){if(!e.shouldDebounceFilterSubmit(r,i))return o;const a=i;return function(){e.cancelFilterSubmit(n);const r=setTimeout(function(){n.removeData(t),o.call(this)}.bind(this),a);n.data(t,r)}},e.filterDefaultValue=function(e){return null!=e&&"object"==typeof e&&null!=e.value?e.value:e},e.columnFilterPersisted=function(e){const t=e&&e.filter?e.filter:{};return!(!e||!e.hidden&&"hidden"!==t.type&&!t.persist)},e.ensureFilterField=function(e,t,n,o){if(!e||!t||null==n||""===n)return null;let r=e.elements&&e.elements.namedItem(t);return r&&null!=r.length&&!r.tagName&&(r=r[0]),r&&r.tagName||(r=document.createElement("input"),r.type="hidden",r.name=t,e.appendChild(r)),r.setAttribute("data-operator",o||"="),r.value=String(n),r.defaultValue=String(n),r},e.applyColumnDefaultFilters=function(t,n){t&&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=e.filterDefaultValue(o.default);if(null==r||""===r)return;const i=o.operator||(e.columnFilterPersisted(n)?"=":"~=~"),a=e.filterFormField(t,n.name);!n.hidden&&"hidden"!==o.type&&a.length?a.val()||(a.val(String(r)),a.attr("data-operator",i)):e.ensureFilterField(t,n.name,r,i)})},e.setupDefaultFilters=function(t,n,o,r){const i=$(t)[0];if(!(i&&n&&n.features&&n.features.filtering))return;const a=n.columns||[];if(e.applyColumnDefaultFilters(i,a),a.some(e.columnFilterPersisted)){let t=!1;$(i).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!t){n.preventDefault(),e.cancelFilterDebounces(i),t=!0;try{i.reset(),e.applyColumnDefaultFilters(i,a),o&&o.filtering&&"function"==typeof o.filtering.handleSubmit?o.filtering.handleSubmit(i):$(i).trigger("submit")}finally{t=!1}}})}if(!o||!o.filtering)return;const l=a.filter(function(t){return t.name&&t.filter&&null!=t.filter.default&&""!==t.filter.default&&e.columnFilterPersisted(t)});if(!l.length)return;const s=String(o.url&&o.url.parameters&&o.url.parameters.filter||"");!l.some(function(e){return-1===s.indexOf(e.name+"=")})||r&&r.skipInitSubmit||o.filtering.handleSubmit(i)},e.setupFilterHeader=function(t,n){if(!n.features||!n.features.filtering)return null;const o=t.find(".thead-filters");o.empty();const r=[...n.columns],i=$("<tr>");i.appendTo(o);const a="filter_form_"+e.uuid(),l=$("<form>").attr("id",a).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(t);return r.forEach(t=>{const n=t.filter||{};if(t.hidden||"hidden"===n.type){if(t.features&&!1===t.features.filter)return;if(!t.name)return;const o=e.filterDefaultValue(n.default);return void(null!=o&&""!==o?e.ensureFilterField(l[0],t.name,o,n.operator||"="):e.columnFilterPersisted(t)&&e.ensureFilterField(l[0],t.name,"",n.operator||"="))}let o,r=$("<th>").appendTo(i).attr("data-label",t.label);if(e.applyColumnCellMeta(r,t),!1===t.features.filter)return;if(!t.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(t,null,2));let s=null;const c=e.createFieldInput({mode:"filter",col:t,config:n});if(c)s=c,o=c.$input,o.appendTo(r),e.mountField({mode:"filter",$input:o,col:t,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(t,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(t,null,2));n.options.forEach(e=>{if(!e.label||"string"!=typeof e.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.value).appendTo(o)}),o.appendTo(r)}else{if(!e.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)}const u=n.operator||("multi_select"===n.type?"><":void 0);null!=u&&o.attr("data-operator",u),o.attr("form",a),o.attr("name",t.name);const d=e.filterDefaultValue(n.default);if(null!=d&&""!==d&&!o.val()){const t="multi_select"===n.type?e.normalizeMultiSelectValue(d,n.separator):String(d);o.val(t),o.attr("data-default",t),o[0]&&(o[0].defaultValue=t)}e.bindFilterInputEvents({type:n.type,$input:o,onSubmit:function(){const e=this.form;e&&$(e).trigger("submit")},createResult:s,filterConfig:n})}),e.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(i),l},e.syncFormFiltersToCollectionUrl=function(e,t){if(!e||!t||!t.url)return;t.url.parameters||(t.url.parameters={});const n=[],o=e.elements;if(o){for(let e=0;e<o.length;e++){const t=o[e];if(!t||!t.name)continue;const r=$(t),i=r.val();if(null==i||""===i)continue;const a=r.attr("data-operator")||r.data("operator")||"=";n.push(t.name+a+i)}t.offset=0,n.length?t.url.parameters.filter=n.join(","):delete t.url.parameters.filter}},e.FilterForm=function(t){this.form=$(t)[0],this.filter=(t,n,o="~=~")=>{if(!this.form)return this;let r=e.filterFormField(this.form,t);if(r.length||(e.ensureFilterField(this.form,t,n,o),r=e.filterFormField(this.form,t)),!r.length)return this;e.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=(t,n,o="=")=>(e.ensureFilterField(this.form,t,n,o),this),this.reset=()=>(this.form&&(e.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(e){e.wrapFlagSwitch=function(e){return e.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(e)},e.setupCell=function(t,n){const o=n?n.attr("id"):null,r={...t},i=$("<td>").attr("data-label",t.label);e.applyColumnCellMeta(i,t),e.applyColumnDomAttrs(i,r);let a=$("<div>").addClass("cell-content");if(a.html(r.display.template??`{{${r.name}}}`),a.appendTo(i),null==n||!t.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(t,null,2));const l=r.update,s=l.type??"text";let c,u=!1;const d=e.createFieldInput({mode:"update",col:t,config:l});if(d)c=d.$input,u=!!d.skipValueAttr;else{switch(s){case"textarea":c=$(`<textarea class='form-input form-control form-control-sm'>{{${l.value??r.name}}}</textarea>`),u=!0;break;case"select":if(c=$("<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(t,null,2));l.options.forEach(e=>{if("string"!=typeof e.label||void 0===e.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.value).appendTo(c)}),u=!0;break;case"hidden":c=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const e=l.template||r.display.template||`{{${r.name}}}`;return $("<div>").addClass("cell-input").append(e).appendTo(i),i}case"checkbox":c=$("<input autocomplete='off' type='checkbox' class='form-check-input'/>"),u=!0;break;default:if(!e.isValidInputType(s))throw new Error("Invalid update updateConfig type: "+JSON.stringify(l,null,2));c=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`)}c.attr("data-type",s)}if(l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(e=>c.attr(e,l.attrs[e])),c.attr("form",o),c.attr("name",r.name),!u&&"textarea"!==s){const e=l.value??`{{${r.name}}}`;null!=e&&"object"!=typeof e&&c.attr("value",e)}if(r.hidden)return c.attr("type","hidden").appendTo(n),i;l.disabled&&c.attr("disabled",!0),l.readonly&&c.attr("readonly",!0),l.required&&c.attr("required",!0),l.attrs&&"object"==typeof l.attrs&&Object.keys(l.attrs).forEach(e=>c.attr(e,l.attrs[e])),l.disabled||l.readonly||c.attr("onchange","$(this).parents('tr').addClass('editing')");const f="checkbox"===s?e.wrapFlagSwitch(c):c;return $("<div>").addClass("cell-input").append(f).appendTo(i),i}}(window.KGrid),function(e){e.setupNoDataTbody=function(e,t,n){const o=e.find("td").attr("colspan",n);return t.noDataTemplate&&o.html(t.noDataTemplate),o},e.fillDataRow=function(t,n){const o=[...n.columns],r="data_row_form_"+e.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=e.setupCell(n,i);n.hidden||o.appendTo(t)}),e.hasActionColumn(n)){const o=$("<td>").addClass("kgrid-row-actions").appendTo(t);e.renderRowActions(o,n,r)}return i&&e.anchorRowForm(i,t),t},e.setupDataBody=function(t,n,o,r,i,a){const l=$("<tr>").appendTo(t);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(e=>l.attr(e,s[e])),t.data("emptyview",a),n?.features?.sorting&&t.data("sort",o),i&&t.data("paging",i.find(".pages")).data("pagesizeinp",i.find(".pagesize")).data("totalrecscount",i.find(".totalrecscount")),r&&t.data("filter",r),n.type&&t.data("type",n.type),e.fillDataRow(l,n),t},e.setupPagingFooter=function(t,n,o){return e.log("setupPagingFooter",t,n,o),n.pagingFooterAttrs&&e.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(e=>t.attr(e,n.pagingFooterAttrs[e])),e.log("noVisibleCols",o),t.find("td").attr("colspan",o),t}}(window.KGrid),function(e){e.setupNewRecordForm=function(t,n,o){if(!n.insertFormRow||!e.isPlainObject(n.insertFormRow))return t.find(".before-main-tbody").remove(),void t.find(".after-main-tbody").remove();const r=[...n.columns],i=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(t.find(".after-main-tbody").remove(),i.appendTo(t.find(".before-main-tbody"))):(t.find(".before-main-tbody").remove(),i.appendTo(t.find(".after-main-tbody")));const a="new_record_row_form_"+e.uuid(),l=$("<form class='table-row-form'>").attr("id",a).off("submit").on("submit",t=>{t.preventDefault();const i=e.serializeForm(t.target,r);Object.keys(i).forEach(e=>{r.find(t=>t.name===e)?.insert?.dontsave&&delete i[e]}),o.instance.newItem(i).then(()=>{t.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(i,t.target)}).catch(e.onError)});r.forEach(t=>{if(t.hidden){if(n.features?.create&&t.features?.create){const e=$("<input type='hidden'>").attr("name",t.name).attr("form",a).appendTo(l);t.insert.default&&e.val(t.insert.default)}return}if(!t.features.create){const n=$("<td>").appendTo(i).attr("data-label",t.label);return void e.applyColumnCellMeta(n,t)}const o=t.insert;if(!o||!e.isPlainObject(o))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(t,null,2));if(!o.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(t,null,2));let r;const s=o.type??"text",c=e.createFieldInput({mode:"insert",col:t,config:o});if(c)r=c.$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(t,null,2));o.options.forEach(e=>{if("string"!=typeof e.label||void 0===e.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(t,null,2));$("<option>").text(e.label).attr("value",e.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(!e.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 u="object"==typeof o.default&&o.default&&null!=o.default.value?o.default.value:o.default;if("checkbox"===s){const t=e.isFlagOn(u);r.prop("checked",t).prop("defaultChecked",t)}else null==o.default||""===o.default||r.val()||String(u).trim()&&(r.val(u).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(e=>r.attr(e,o.attrs[e])),r.attr("form",a).attr("name",t.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(e=>r.attr(e,o.attrs[e])),"hidden"!==o.type){const n="checkbox"===s?e.wrapFlagSwitch(r):r,o=$("<td>").append(n).appendTo(i).attr("data-label",t.label);e.applyColumnCellMeta(o,t)}e.mountField({mode:"insert",$input:r,col:t,config:o,formEl:l[0],rowEl:i[0]}),o.events&&Array.isArray(o.events)&&o.events.forEach(e=>{r.off(e.event).on(e.event,function(t,...n){"function"==typeof e.callback&&e.callback(t,l[0],i[0],...n)})})}),e.anchorRowForm(l,i);const s=$("<td>").addClass("kgrid-row-actions").appendTo(i).attr("data-label","action"),c=$("<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(c),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(l[0],i[0]),i}}(window.KGrid),function(e){e.setupEvents=function(t,n,o,r){const i=t.views[0];i&&i.el&&"function"==typeof e.applyLayoutToRow&&e.applyLayoutToRow(i.el,o.columns),o.columns.forEach(n=>{n.display.events.forEach(e=>{if(!e.selector||!e.event||!e.callback)throw new Error("Invalid event: "+JSON.stringify(e,null,2));i.el.find(e.selector).off(e.event).on(e.event,n=>{if("function"!=typeof e.callback)throw new Error("Event callback must be a function: "+JSON.stringify(e,null,2));e.callback(n,t,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(e.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,t,i,...r)})})}),o.features.update&&(i.el.find("[data-type]").each((n,o)=>{const a=o.getAttribute("data-type");if(!e.isPluggableFieldType(a))return;const l=r.get(o.name);l?.update&&e.mountField({mode:"update",$input:$(o),col:l,config:l.update,item:t,view:i})}),i.el.find("select[data-type='select']").each((e,n)=>{const o=r.get(n.name);if(!o)return;const i=t.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=e.isFlagOn(t.attributes[i.name]))}),i.el.find("form.edit-form").off("submit").on("submit",t=>{const n=t.target;t.preventDefault();const r=$(n).parents("[data-type=item]").data().instance,i=e.serializeForm(n);Object.keys(i).forEach(e=>{o.columns.find(t=>t.name===e)?.update?.dontsave&&delete i[e]}),r.update(i).catch(e.onError)}));const a=e.resolveRowActions(o);e.mountRowActionDropdowns(i.el);const l=a.menuItems.some(e=>"clone"===e.action),s=a.menuItems.some(e=>"delete"===e.action);l&&i.el.find(".clone-item").off("click").on("click",e=>{e.preventDefault(),e.stopPropagation(),"function"==typeof o.onClone&&o.onClone(t,i,e)}),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");e.runDeleteConfirm({item:t,view:i,options:o},()=>{t.delete().catch(e.onError).finally(r)},r)});const c=new Map;a.menuItems.forEach(e=>{e.id&&"function"==typeof e.callback&&c.set(e.id,e.callback)}),c.size&&i.el.find("[data-kgrid-action]").off("click.kgridAction").on("click.kgridAction",e=>{const n=e.currentTarget.getAttribute("data-kgrid-action"),o=c.get(n);o&&(e.preventDefault(),e.stopPropagation(),o(e,t,i))}),"function"==typeof o.onRowFields&&o.onRowFields(t,i,n)}}(window.KGrid),function(e){e.PREFERENCES_VERSION=1,e.localStoragePreferences={get:function(e){try{const t="undefined"!=typeof window?window:globalThis,n=t&&t.localStorage;if(!n)return null;const o=n.getItem(e);return o?JSON.parse(o):null}catch(e){return null}},set:function(e,t){try{const n="undefined"!=typeof window?window:globalThis,o=n&&n.localStorage;if(!o)return;if(null==t)return void o.removeItem(e);o.setItem(e,JSON.stringify(t))}catch(e){}}},e.preferencesStorageFor=function(t){return t&&t.preferencesStorage?t.preferencesStorage:e._config&&e._config.preferencesStorage?e._config.preferencesStorage:e.localStoragePreferences},e.layoutStorageKey=function(e){return"kgrid:"+e+":layout"},e.filtersStorageKey=function(e,t){let n="kgrid:"+e+":filters";return null!=t&&""!==String(t)&&(n+=":"+String(t)),n},e.chooserColumns=function(e){return(e||[]).filter(function(e){return e&&e.name&&!e.hidden})},e.layoutFromColumns=function(t){return{v:e.PREFERENCES_VERSION,columns:e.chooserColumns(t).map(function(e){return{name:e.name,hidden:!!e.userHidden}})}},e.parseFilterExpression=function(e){const t=String(e||""),n=["~=~",">=","<=","!=","=",">","<"];for(let e=0;e<n.length;e++){const o=n[e],r=t.indexOf(o);if(r>0)return{name:t.slice(0,r),operator:o,value:t.slice(r+o.length)}}return null},e.isUserFilterColumn=function(e){return!(!e||!e.name||e.hidden||e.features&&!1===e.features.filter)},e.readUserFilters=function(t,n){if(!t)return[];const o=[];return(n||[]).forEach(function(n){if(!e.isUserFilterColumn(n))return;const r=e.filterFormField(t,n.name);if(!r.length)return;const i=r.val();if(null==i||""===i||Array.isArray(i)&&!i.length)return;const a=r.attr("data-operator")||n.filter&&n.filter.operator||"~=~";o.push({name:n.name,value:Array.isArray(i)?i:String(i),operator:a})}),o},e.applyUserFilters=function(t,n,o){t&&o&&Array.isArray(o.filters)&&o.filters.forEach(function(o){if(!o||!o.name)return;const r=(n||[]).find(function(e){return e&&e.name===o.name});if(!e.isUserFilterColumn(r))return;if(null==o.value||""===o.value)return;let i=e.filterFormField(t,o.name);i.length||(e.ensureFilterField(t,o.name,o.value,o.operator),i=e.filterFormField(t,o.name)),i.length&&(i.val(o.value),o.operator&&i.attr("data-operator",o.operator))})},e.ensureUrlFiltersOnForm=function(t,n){if(!(t&&n&&n.url&&n.url.parameters))return;const o=String(n.url.parameters.filter||"");o&&o.split(",").forEach(function(n){const o=e.parseFilterExpression(n.trim());if(!o||!o.name||""===o.value)return;const r=e.filterFormField(t,o.name);return r.length&&r.val()?void 0:r.length?(r.val(o.value),void r.attr("data-operator",o.operator)):void e.ensureFilterField(t,o.name,o.value,o.operator)})},e.preferencesLoadLayout=function(t){if(!t||!t.storageKey)return null;const n=e.preferencesStorageFor(t).get(e.layoutStorageKey(t.storageKey));return n&&n.v===e.PREFERENCES_VERSION&&Array.isArray(n.columns)?n:null},e.preferencesSaveLayout=function(t,n){t&&t.storageKey&&e.preferencesStorageFor(t).set(e.layoutStorageKey(t.storageKey),n)},e.preferencesLoadFilters=function(t){if(!t||!t.storageKey)return null;const n=e.preferencesStorageFor(t).get(e.filtersStorageKey(t.storageKey,t.filterStorageScope));return n&&n.v===e.PREFERENCES_VERSION&&Array.isArray(n.filters)?n:null},e.preferencesSaveFilters=function(t,n){t&&t.storageKey&&e.preferencesStorageFor(t).set(e.filtersStorageKey(t.storageKey,t.filterStorageScope),{v:e.PREFERENCES_VERSION,filters:n||[]})},e.reorderColumns=function(e,t){const n=new Map,o=[];(e||[]).forEach(function(e,t){e&&e.hidden?o.push({col:e,index:t}):e&&e.name&&n.set(e.name,e)});const r=[];(t||[]).forEach(function(e){n.has(e)&&(r.push(n.get(e)),n.delete(e))}),n.forEach(function(e){r.push(e)});const i=r.slice();return o.forEach(function(e){i.splice(Math.min(e.index,i.length),0,e.col)}),i},e.columnDefaultUserHidden=function(e){return!(!e||!e.defaultHidden||e.locked||e.hidden)},e.mergeLayoutIntoColumns=function(t,n){const o=(t||[]).slice();o.forEach(function(t){t&&!t.hidden&&(t.userHidden=e.columnDefaultUserHidden(t))});const r=e.chooserColumns(o),i=new Map(r.map(function(e){return[e.name,e]})),a=[],l=new Set;(n&&Array.isArray(n.columns)?n.columns:[]).forEach(function(e){if(!e||!e.name||!i.has(e.name))return;const t=i.get(e.name);t.userHidden=!!e.hidden&&!t.locked,a.push(e.name),l.add(e.name)}),r.forEach(function(e){l.has(e.name)||a.push(e.name)});const s=e.reorderColumns(o,a),c=e.chooserColumns(s);if(c.length&&c.every(function(e){return e.userHidden})){(c.find(function(e){return!e.locked})||c[0]).userHidden=!1}return s},e.applyLayoutToRow=function(t,n){if(!t||!t.length)return;const o=e.chooserColumns(n),r=o.map(function(e){return e.name}),i={};o.forEach(function(e){e.userHidden&&(i[e.name]=!0)});const a=t.children(".kgrid-row-actions"),l={};t.children("[data-name]").each(function(){l[this.getAttribute("data-name")]=this}),r.forEach(function(e){const n=l[e];n&&(a.length?$(n).insertBefore(a):t.append(n),n.classList.toggle("kgrid-user-hidden",!!i[e]))})},e.applyLayoutToDom=function(t,n,o){if(!t||!t.length)return;t.find(".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr").each(function(){e.applyLayoutToRow($(this),n)});const r=e.layoutVisibleColumns(n),i=t.find(".kgrid-row-actions").length>0;e.syncActionColumnColgroup(t,r.length,i,o,r),e.syncSpanningCells(t,e.participatingColumnCount(n,i))},e.refreshCollectionTemplate=function(t,n){if(!t||!t.instance||"function"!=typeof e.fillDataRow)return;const o=e.getKViews(n&&n.kviews);if(!o||"function"!=typeof o.template)return;const r=$("<tr>");n.dataRowAttrs&&e.isPlainObject(n.dataRowAttrs)&&Object.keys(n.dataRowAttrs).forEach(function(e){r.attr(e,n.dataRowAttrs[e])}),e.fillDataRow(r,n);const i=$("<div>").append(r).html(),a=o.template(i);t.instance.template=a,(t.instance.items||[]).forEach(function(e){(e.views||[]).forEach(function(e){e.template=a})})},e.setupFilterPersistence=function(t,n){t&&n&&n.storageKey&&n.features&&n.features.filtering&&$(t).off("submit.kgridFilterPrefs").on("submit.kgridFilterPrefs",function(){e.preferencesSaveFilters(n,e.readUserFilters(t,n.columns))})},e.applyColumnLayout=function(t,n,o){n.columns=e.mergeLayoutIntoColumns(n.columns,o);const r=t.$host.find("table").first();if(e.applyLayoutToDom(r,n.columns,n),e.refreshCollectionTemplate(t,n),"function"==typeof e.renderColumnChooserPanel){const o=t.$host.find(".kgrid-column-chooser-panel");o.length&&e.renderColumnChooserPanel(o,n,t)}return e.layoutFromColumns(n.columns)}}(window.KGrid),function(e){function t(t){const n=[];return t.find(".kgrid-column-chooser-list li[data-name]").each(function(){const e=this.getAttribute("data-name"),t=$(this).find("input[type='checkbox']").prop("checked");n.push({name:e,hidden:!t})}),{v:e.PREFERENCES_VERSION,columns:n}}e.renderColumnChooserPanel=function(n,o,r){n.empty();const i=$("<ul>").addClass("kgrid-column-chooser-list").appendTo(n);e.chooserColumns(o.columns).forEach(function(e){const t=$("<li>").attr("draggable","true").attr("data-name",e.name).appendTo(i);$("<span>").addClass("kgrid-column-chooser-handle").attr("aria-hidden","true").text("⋮⋮").appendTo(t);const n=$("<label>").appendTo(t),o=$("<input>").attr("type","checkbox").prop("checked",!e.userHidden).appendTo(n);e.locked&&o.prop("disabled",!0).attr("title","This column cannot be hidden"),n.append(document.createTextNode(" "+(e.label||e.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 e=t(n);(function(e){return e.columns.filter(function(e){return!e.hidden}).length})(e)<1?this.checked=!0:r.setLayout(e)}),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(e){a=this,$(this).addClass("kgrid-column-chooser-dragging"),e.originalEvent&&e.originalEvent.dataTransfer&&(e.originalEvent.dataTransfer.effectAllowed="move",e.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(e){if(e.preventDefault(),!a||a===this)return;const t=this.getBoundingClientRect(),n=t.top+t.height/2;(e.originalEvent?e.originalEvent.clientY:0)<n?this.parentNode.insertBefore(a,this):this.parentNode.insertBefore(a,this.nextSibling)}),i.on("drop.kgridChooserDrag","li",function(e){e.preventDefault(),r.setLayout(t(n))})},e.setupColumnChooser=function(t,n,o){if(!n.features||!n.features.columnChooser)return;const r=e.getTableInteractionHost(t);r.find(".kgrid-column-chooser").remove();const i=n.columnChooserLabel||"Columns",a=$("<div>").addClass("kgrid-column-chooser"),l=$("<button>").attr("type","button").addClass("kgrid-column-chooser-toggle btn btn-sm btn-outline-secondary").attr("title",i).attr("aria-expanded","false").attr("aria-haspopup","true").html('<i class="fas fa-table-columns" aria-hidden="true"></i><span class="kgrid-column-chooser-toggle-label"> '+$("<div>").text(i).html()+"</span>"),s=$("<div>").addClass("kgrid-column-chooser-panel").attr("hidden","hidden");function c(){s.attr("hidden","hidden"),l.attr("aria-expanded","false")}a.append(l,s),r.prepend(a),e.renderColumnChooserPanel(s,n,o),l.on("click",function(e){e.stopPropagation();!s.attr("hidden")?c():(s.removeAttr("hidden"),l.attr("aria-expanded","true"))});const u="kgridChooser"+e.uuid();$(document).on("pointerdown."+u,function(e){document.body.contains(a[0])?a[0].contains(e.target)||c():$(document).off("pointerdown."+u)})}}(window.KGrid),function(e){e.init=async function(t,n){const o=e.resolveHostElement(t),r={...e.protoOptions,...n},i=e.mountTableShell(o,r);e.log("table config options",r);const a=e.resolveDefaultInteraction(r);e.applyInteraction(o,a);const l={$host:o,instance:null,filterForm:null,find:e=>o.find(e),setInteraction:(t,n)=>(e.applyInteraction(o,t,n),l),getInteraction:()=>"edit"===e.getTableInteractionHost(o).attr("data-interaction")?"edit":"view",setEditMode(e){if("boolean"!=typeof e)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return l.setInteraction(e?"edit":"view")},toggleEditMode:e=>(null!=e&&"object"==typeof e&&"function"==typeof e.preventDefault&&(e=void 0),"boolean"==typeof e?l.setInteraction(e?"edit":"view"):l.setInteraction("edit"===l.getInteraction()?"view":"edit")),getLayout:()=>e.layoutFromColumns(r.columns),setLayout:t=>(e.applyColumnLayout(l,r,t),e.preferencesSaveLayout(r,l.getLayout()),l.getLayout()),resetLayout(){const t=new Map;return r.columns.forEach(function(e){e&&e.name&&t.set(e.name,e)}),r.columns=s.map(function(e){return t.get(e)}).filter(Boolean),e.preferencesSaveLayout(r,null),e.applyColumnLayout(l,r,null),l.getLayout()}};r.columns=(r.columns||[]).map(t=>e.normalizeColumnConfig(t));const s=r.columns.map(function(e){return e.name});r.columns=e.mergeLayoutIntoColumns(r.columns,e.preferencesLoadLayout(r));const c=r.handlers??{};if(delete r.handlers,"string"==typeof r.onClone){const e=c[r.onClone]||r.functions&&r.functions[r.onClone];if(!e||"function"!=typeof e)throw new Error("onClone handler "+r.onClone+" not found or is not a function");r.onClone=e}e.resolveRowActions(r,c);{const t=r._resolvedRowActions;e.getTableInteractionHost(o).attr("data-has-row-menu",t&&t.menuItems&&t.menuItems.length?"true":"false")}r.columns.forEach(e=>{["insert","update","display"].forEach(t=>{const n=e[t].events;if(!n||!Array.isArray(n))throw new Error("Column "+e.name+" events are not an array");n.forEach(t=>{if("string"==typeof t.callback){const n=c[t.callback]||r.functions&&r.functions[t.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+t.callback+" not found for column "+e.name+" or is not a function");t.callback=n}else if("function"!=typeof t.callback)throw new Error("Event callback must be a function for column "+e.name)})});const t=e.display;t&&t.events&&Array.isArray(t.events)&&t.events.forEach(e=>{if("string"==typeof e.callback){const t=c[e.callback]||r.functions&&r.functions[e.callback];t&&"function"==typeof t&&(e.callback=t)}})});const u=new Map;r.columns.forEach(e=>{u.set(e.name,e)});const d=e.setupLabelsHeader(i.find(".thead-labels"),r),f=e.hasActionColumn(r),p=e.layoutVisibleColumns(r.columns),m=e.participatingColumnCount(r.columns,f);e.syncActionColumnColgroup(i,p.length,f,r,p);const g=r.filterForm??e.setupFilterHeader(i,r);let h;r.features&&r.features.paging?h=e.setupPagingFooter(i.find(".paging-footer"),r,m):(h=null,i.find(".paging-footer").remove());const y=e.setupNoDataTbody(i.find(".no-data-tbody"),r,m);r.features&&r.features.create&&e.setupNewRecordForm(i,r,l),l.filterForm=new e.FilterForm(g);const b=e.setupDataBody(i.find(".main-tbody"),r,d,g,h,y),w={dontload:!0,setAttrAsId:r.setAttrAsId??!1,itemListeners:{afterrender:t=>e.setupEvents(t,l.find("table"),r,u)}},C=e.getKViews(r.kviews);if(!C)throw new Error(e.KVIEWS_MISSING_MSG);l.instance=await C.createCollectionInstance(b,w),r.url&&(l.instance.setUrl(r.url),r.deleteUrl&&(e.log("set deleteUrl",r.deleteUrl),l.instance.setUrl(r.deleteUrl,"delete")),r.updateUrl&&(e.log("set updateUrl",r.updateUrl),l.instance.setUrl(r.updateUrl,"update")),r.insertUrl&&l.instance.setUrl(r.insertUrl,"insert")),e.setupDefaultFilters(g,r,l.instance,{skipInitSubmit:!0});const v=g&&(g.jquery?g[0]:g);if(e.applyUserFilters(v,r.columns,e.preferencesLoadFilters(r)),e.ensureUrlFiltersOnForm(v,l.instance),e.setupFilterPersistence(v,r),e.setupColumnChooser(o,r,l),r.url)try{r.features&&r.features.filtering&&v&&e.syncFormFiltersToCollectionUrl(v,l.instance),await l.instance.loadFromRemote()}catch(t){e.onError(t)}else{if(!r.data||r.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const e=r.data.map(e=>({attributes:e}));l.instance.loadFromData(e)}}return l}}(window.KGrid);
|
package/docs/ai-guide.md
CHANGED
|
@@ -159,7 +159,7 @@ Each column in `columns: []` is normalized via `KGrid.normalizeColumnConfig` (pr
|
|
|
159
159
|
|
|
160
160
|
**Hidden / persist filters:** columns with `hidden: true` or `filter.type: "hidden"` get a hidden form field (no filter-row cell). `filter.persist` (or hidden) re-applies `filter.default` on form reset.
|
|
161
161
|
|
|
162
|
-
**User column layout + filter reload:** `storageKey` persists layout (all companies) and filter values (`filterStorageScope` suffixes filters, e.g. company id) to `localStorage`. `features.columnChooser` adds a Columns panel (reorder + hide). Schema `hidden` columns stay out of the chooser. `defaultHidden: true` starts the column
|
|
162
|
+
**User column layout + filter reload:** `storageKey` persists layout (all companies) and filter values (`filterStorageScope` suffixes filters, e.g. company id) to `localStorage`. `features.columnChooser` adds a Columns panel (reorder + hide). Schema `hidden` columns stay out of the chooser. `defaultHidden: true` starts the column hidden (`display:none`, omitted from `<colgroup>`) but still listed in the chooser. `locked: true` columns cannot be hidden. Hidden columns keep filter/insert/update inputs in the DOM. `grid.getLayout()` / `setLayout()` / `resetLayout()` (reset restores `defaultHidden`, not “all visible”).
|
|
163
163
|
|
|
164
164
|
---
|
|
165
165
|
|
|
@@ -173,7 +173,7 @@ When `KGrid.hasActionColumn(options)`:
|
|
|
173
173
|
- `<colgroup>` with `col.kgrid-row-actions-col` (synced at init)
|
|
174
174
|
- **View mode:** column collapsed unless `data-has-row-menu` (idle menu actions present) — full width for data columns when collapsed
|
|
175
175
|
- **Edit mode:** column visible — menu/idle actions + save/cancel; insert row submit in `.new-record-row`
|
|
176
|
-
- **Dropdown mode:** `.kgrid-row-actions-menu` for idle items; save/cancel stay as buttons
|
|
176
|
+
- **Dropdown mode:** `.kgrid-row-actions-menu` for idle items; save/cancel stay as buttons. Menu is `position:fixed` while open (not Bootstrap Dropdown / Popper). Do not call `bootstrap.Dropdown` on `.kgrid-actions-dropdown-toggle`.
|
|
177
177
|
|
|
178
178
|
Rule: always use `KGrid.hasActionColumn(options)` — do not add action `<th>` only in header or only in body. Do not invent a data column for action buttons.
|
|
179
179
|
|
|
@@ -248,7 +248,8 @@ Deprecated: `setEditMode`, `toggleEditMode` — use `setInteraction`.
|
|
|
248
248
|
10. **Editing `dist/kgrid.js` in node_modules** — change `src/` in the package or fork; rebuild with `npm run build`.
|
|
249
249
|
11. **Assuming cancel edit reloads local `data`** — cancel button calls `loadFromRemote()`; local-only grids need a custom approach.
|
|
250
250
|
12. **Breaking class names** — `custom-table-shell`, `data-interaction`, `main-tbody`, `kgrid-row-actions` are required by CSS and KViews wiring.
|
|
251
|
-
13. **
|
|
251
|
+
13. **Emitting a `<col>` for a user-hidden column** — `display:none` cells skip that slot; leftover cols remap widths. Colgroup lists only participating columns. Do not set `width` on `th`/`td`.
|
|
252
|
+
14. **Init `bootstrap.Dropdown` on kebab toggles** — KGrid already binds the menu (`mountRowActionDropdowns`); Bootstrap Dropdown / Popper clips or swallows item clicks.
|
|
252
253
|
|
|
253
254
|
---
|
|
254
255
|
|
|
@@ -284,4 +285,4 @@ Run demo locally: `npm run demo` in the kgrid package → `http://localhost:5173
|
|
|
284
285
|
|
|
285
286
|
## Version
|
|
286
287
|
|
|
287
|
-
This guide matches **@logimaxx/kgrid@0.
|
|
288
|
+
This guide matches **@logimaxx/kgrid@0.5.2** (declarative `rowActions`, kebab menus without Bootstrap Dropdown, column chooser, `defaultHidden`, persisted layout/filters). If APIs differ in another version, prefer `docs/api.md` in the installed package.
|
package/docs/api.md
CHANGED
|
@@ -117,10 +117,14 @@ See **[table-shell.md](table-shell.md)** for structure, placeholders, and custom
|
|
|
117
117
|
| `KGrid.hasActionColumn(options)` | `true` when `features.create`, or resolved `rowActions` / shimmed delete·clone / `features.update` (save/cancel) |
|
|
118
118
|
| `KGrid.actionColumnWidth(options)` | Compact CSS width for the actions column under `table-layout: fixed` |
|
|
119
119
|
| `KGrid.resolveRowActions(options, handlers?)` | Normalize `rowActions` (or shim from features); caches on `options` |
|
|
120
|
-
| `KGrid.renderRowActions($td, options, formId?)` | Fill a data-row actions cell (buttons or dropdown) |
|
|
121
|
-
| `KGrid.
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
| `KGrid.renderRowActions($td, options, formId?)` | Fill a data-row actions cell (buttons or kebab dropdown) |
|
|
121
|
+
| `KGrid.mountRowActionDropdowns($root)` | Bind kebab toggles under `$root` (jQuery click; menu `position:fixed` while open). Called after each row render. |
|
|
122
|
+
| `KGrid.closeRowActionDropdowns($exceptMenu?)` | Close open kebab menus (also on document click and Escape) |
|
|
123
|
+
| `KGrid.layoutVisibleColumns(columns)` | Named, not schema-hidden, not user-hidden — the columns that occupy a table-layout slot |
|
|
124
|
+
| `KGrid.syncActionColumnColgroup($table, dataColumnCount, hasActions, options?, layoutColumns?)` | Prepends `<colgroup>`; one `<col>` per participating data column; skips `userHidden`; action col from `actionColumnWidth` |
|
|
125
|
+
| `KGrid.applyLayoutToRow($row, columns)` | Reorder cells + toggle `.kgrid-user-hidden` (also from `afterrender` after paging) |
|
|
126
|
+
|
|
127
|
+
Kebab menus (`rowActions.display: "dropdown"`) use Bootstrap **markup** (`.dropdown-toggle`, `.dropdown-menu`) but **not** `bootstrap.Dropdown` / Popper. Requires `styles/table.css` for view/edit visibility on `.kgrid-row-actions` / `col.kgrid-row-actions-col`, kebab `.dropdown-menu.show`, and user-hidden columns (`display: none`; no colgroup slot).
|
|
124
128
|
|
|
125
129
|
### Low-level setup (advanced / tests)
|
|
126
130
|
|
package/docs/configuration.md
CHANGED
|
@@ -179,7 +179,7 @@ Column flags:
|
|
|
179
179
|
| `locked: true` | Visible; chooser cannot hide it (still reorderable). Use on required list fields such as name. |
|
|
180
180
|
| `userHidden` | Runtime only — set via chooser / `setLayout` |
|
|
181
181
|
|
|
182
|
-
User-hidden columns use
|
|
182
|
+
User-hidden columns use **`display: none`** on cells and are **omitted from `<colgroup>`**. `table-layout: fixed` maps each participating cell to the next `<col>`; a leftover zero-width col remaps every following column (letter-stacked headers, blank gaps). Chrome also treats `visibility: collapse` as `hidden`, so that is not a substitute. Filter/insert/update controls stay in the DOM. Filter values on hidden columns remain until Reset.
|
|
183
183
|
|
|
184
184
|
`filter.persist` still means “keep `filter.default` on form reset” — it is not reload persistence. Reload persistence is `storageKey`.
|
|
185
185
|
|
|
@@ -206,7 +206,7 @@ onClone: "cloneRow",
|
|
|
206
206
|
| `delete` | `fas fa-trash` | idle | `deleteConfirm` then `item.delete()` |
|
|
207
207
|
| `save` / `cancel` | save / undo | editing | **Not listed in `items`** — added when `features.update` |
|
|
208
208
|
|
|
209
|
-
`display: "dropdown"` puts idle/menu items in a Bootstrap
|
|
209
|
+
`display: "dropdown"` puts idle/menu items in a kebab (Bootstrap classes `.dropdown-toggle` / `.dropdown-menu`). KGrid opens and closes the menu itself (`position: fixed` while open, so the table does not clip it). Click outside or Escape closes it. **`bootstrap.Dropdown` / Popper is not used** and must not be initialized on these toggles — it fights the click handlers. Save / Cancel stay as separate buttons.
|
|
210
210
|
|
|
211
211
|
**Deprecated:** `features.delete` / `features.clone` still work (shim into `rowActions`) when `rowActions` is omitted. If both are set, `rowActions` wins and KGrid warns.
|
|
212
212
|
|
package/docs/table-shell.md
CHANGED
|
@@ -94,8 +94,8 @@ Simplest path: put your table inside the host before init — KGrid detects it a
|
|
|
94
94
|
|
|
95
95
|
## Styling and icons
|
|
96
96
|
|
|
97
|
-
- Include `styles/table.css` from the package (required for view/edit modes
|
|
98
|
-
- The default template uses **Bootstrap** button classes (`btn`, `btn-sm`, …) and **Font Awesome** sort icons (`fa-sort`, `fa-sort-up`, `fa-sort-down`). Load both in the host page, or edit the template to match your design system.
|
|
97
|
+
- Include `styles/table.css` from the package (required for view/edit modes, row-actions column collapse, user-hidden columns, and kebab `.dropdown-menu.show`).
|
|
98
|
+
- The default template uses **Bootstrap** button classes (`btn`, `btn-sm`, …) and **Font Awesome** sort icons (`fa-sort`, `fa-sort-up`, `fa-sort-down`). Load both in the host page, or edit the template to match your design system. Kebab `rowActions` reuse those classes; the open/close behavior is KGrid’s, not `bootstrap.Dropdown`.
|
|
99
99
|
|
|
100
100
|
If you provide your own `<table>` in the host, call `KGrid.init` as usual — `syncActionColumnColgroup` still runs when row actions are enabled.
|
|
101
101
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logimaxx/kgrid",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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",
|
package/src/cells.js
CHANGED
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
const $cell = $("<td>").attr("data-label", col.label);
|
|
27
27
|
CT.applyColumnCellMeta($cell, col);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
Object.keys(attrs).forEach(attr => $cell.attr(attr, attrs[attr]));
|
|
29
|
+
CT.applyColumnDomAttrs($cell, c);
|
|
31
30
|
|
|
32
31
|
let cellContent = $("<div>").addClass("cell-content");
|
|
33
32
|
cellContent.html(c.display.template ?? `{{${c.name}}}`);
|
package/src/dom.js
CHANGED
|
@@ -30,12 +30,61 @@
|
|
|
30
30
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
/** CSS width for a visible column from `attrs.width` (px if numeric). */
|
|
34
|
+
CT.columnWidthCss = function (col) {
|
|
35
|
+
if (!col || !col.attrs) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const w = col.attrs.width;
|
|
39
|
+
if (w == null || w === "") {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (typeof w === "number" || /^\d+(\.\d+)?$/.test(String(w))) {
|
|
43
|
+
return String(w) + "px";
|
|
44
|
+
}
|
|
45
|
+
return String(w);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Copy `col.attrs` onto a cell, except layout `width` (that belongs on `<col>`). */
|
|
49
|
+
CT.applyColumnDomAttrs = function ($el, col) {
|
|
50
|
+
const attrs = col && col.attrs && typeof col.attrs === "object" ? col.attrs : null;
|
|
51
|
+
if (!attrs) {
|
|
52
|
+
return $el;
|
|
53
|
+
}
|
|
54
|
+
Object.keys(attrs).forEach(function (attr) {
|
|
55
|
+
if (attr === "width") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
$el.attr(attr, attrs[attr]);
|
|
59
|
+
});
|
|
60
|
+
return $el;
|
|
61
|
+
};
|
|
62
|
+
|
|
33
63
|
/**
|
|
34
|
-
*
|
|
64
|
+
* Columns that occupy a table-layout slot (named, not schema-hidden, not user-hidden).
|
|
65
|
+
* `display:none` cells do not participate, so colgroup must list only these.
|
|
66
|
+
*/
|
|
67
|
+
CT.layoutVisibleColumns = function (columns) {
|
|
68
|
+
return (columns || []).filter(function (col) {
|
|
69
|
+
return col && col.name && !col.hidden && !col.userHidden;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Header/body/footer participating column count (visible data + optional actions). */
|
|
74
|
+
CT.participatingColumnCount = function (columns, hasActions) {
|
|
75
|
+
return CT.layoutVisibleColumns(columns).length + (hasActions ? 1 : 0);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sync <colgroup> for `table-layout: fixed`.
|
|
80
|
+
* One `<col>` per participating data column, then optional row-actions.
|
|
81
|
+
* Never emit a col for user-hidden fields: `display:none` cells skip a slot,
|
|
82
|
+
* so a leftover col (even width 0) remaps every following cell onto the wrong width.
|
|
35
83
|
* @param {JQuery} $table
|
|
36
|
-
* @param {number} dataColumnCount
|
|
84
|
+
* @param {number} dataColumnCount participating data columns (no row-actions)
|
|
37
85
|
* @param {boolean} hasActions
|
|
38
86
|
* @param {Object} [options] table options (for action column width)
|
|
87
|
+
* @param {Array} [layoutColumns] column objects in display order; userHidden entries are skipped
|
|
39
88
|
*/
|
|
40
89
|
CT.syncActionColumnColgroup = function ($table, dataColumnCount, hasActions, options, layoutColumns) {
|
|
41
90
|
let $colgroup = $table.children("colgroup.kgrid-colgroup");
|
|
@@ -44,20 +93,27 @@
|
|
|
44
93
|
}
|
|
45
94
|
$colgroup.empty();
|
|
46
95
|
const named = Array.isArray(layoutColumns) ? layoutColumns : null;
|
|
96
|
+
let emitted = 0;
|
|
47
97
|
if (named && named.length) {
|
|
48
98
|
named.forEach(function (col) {
|
|
99
|
+
if (col && col.userHidden) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
49
102
|
const $col = $("<col>");
|
|
50
103
|
if (col && col.name) {
|
|
51
104
|
$col.attr("data-name", col.name);
|
|
52
105
|
}
|
|
53
|
-
|
|
54
|
-
|
|
106
|
+
const cssW = CT.columnWidthCss(col);
|
|
107
|
+
if (cssW) {
|
|
108
|
+
$col.css("width", cssW);
|
|
55
109
|
}
|
|
56
110
|
$colgroup.append($col);
|
|
111
|
+
emitted += 1;
|
|
57
112
|
});
|
|
58
113
|
} else {
|
|
59
114
|
for (let i = 0; i < dataColumnCount; i++) {
|
|
60
115
|
$colgroup.append($("<col>"));
|
|
116
|
+
emitted += 1;
|
|
61
117
|
}
|
|
62
118
|
}
|
|
63
119
|
if (hasActions) {
|
|
@@ -67,6 +123,14 @@
|
|
|
67
123
|
.css("width", CT.actionColumnWidth(options))
|
|
68
124
|
);
|
|
69
125
|
}
|
|
126
|
+
return emitted;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
CT.syncSpanningCells = function ($table, span) {
|
|
130
|
+
if (!$table || !$table.length || !span) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
$table.find(".paging-footer td, .no-data-tbody td").attr("colspan", span);
|
|
70
134
|
};
|
|
71
135
|
|
|
72
136
|
/**
|
package/src/events.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
CT.setupEvents = function (item, table, options, colMap) {
|
|
6
6
|
const view = item.views[0];
|
|
7
|
+
if (view && view.el && typeof CT.applyLayoutToRow === "function") {
|
|
8
|
+
CT.applyLayoutToRow(view.el, options.columns);
|
|
9
|
+
}
|
|
7
10
|
|
|
8
11
|
options.columns.forEach(col=>{
|
|
9
12
|
col.display.events.forEach(event=>{
|
|
@@ -87,12 +90,14 @@
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
const ra = CT.resolveRowActions(options);
|
|
93
|
+
CT.mountRowActionDropdowns(view.el);
|
|
90
94
|
const hasClone = ra.menuItems.some((it) => it.action === "clone");
|
|
91
95
|
const hasDelete = ra.menuItems.some((it) => it.action === "delete");
|
|
92
96
|
|
|
93
97
|
if (hasClone) {
|
|
94
98
|
view.el.find(".clone-item").off("click").on("click", (event) => {
|
|
95
99
|
event.preventDefault();
|
|
100
|
+
event.stopPropagation();
|
|
96
101
|
if (typeof options.onClone === "function") {
|
|
97
102
|
options.onClone(item, view, event);
|
|
98
103
|
}
|
|
@@ -102,6 +107,7 @@
|
|
|
102
107
|
if (hasDelete) {
|
|
103
108
|
view.el.find(".delete-item").off("click").on("click", (event) => {
|
|
104
109
|
event.preventDefault();
|
|
110
|
+
event.stopPropagation();
|
|
105
111
|
view.el.addClass("confirm-delete");
|
|
106
112
|
const clearConfirmState = () => view.el.removeClass("confirm-delete");
|
|
107
113
|
CT.runDeleteConfirm(
|
|
@@ -131,6 +137,7 @@
|
|
|
131
137
|
return;
|
|
132
138
|
}
|
|
133
139
|
event.preventDefault();
|
|
140
|
+
event.stopPropagation();
|
|
134
141
|
cb(event, item, view);
|
|
135
142
|
});
|
|
136
143
|
}
|
package/src/init.js
CHANGED
|
@@ -164,14 +164,14 @@
|
|
|
164
164
|
const labelsRow = CT.setupLabelsHeader(table.find(".thead-labels"), options);
|
|
165
165
|
|
|
166
166
|
const hasActionColumn = CT.hasActionColumn(options);
|
|
167
|
-
const
|
|
168
|
-
const
|
|
167
|
+
const layoutCols = CT.layoutVisibleColumns(options.columns);
|
|
168
|
+
const visibleColumnsCount = CT.participatingColumnCount(options.columns, hasActionColumn);
|
|
169
169
|
CT.syncActionColumnColgroup(
|
|
170
170
|
table,
|
|
171
|
-
|
|
171
|
+
layoutCols.length,
|
|
172
172
|
hasActionColumn,
|
|
173
173
|
options,
|
|
174
|
-
|
|
174
|
+
layoutCols
|
|
175
175
|
);
|
|
176
176
|
|
|
177
177
|
const filterForm = options.filterForm ?? CT.setupFilterHeader(table, options);
|
package/src/labels.js
CHANGED
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
let cell = labelTemplate.clone(true);
|
|
19
|
-
|
|
20
|
-
Object.keys(col.attrs).forEach((attr) => cell.attr(attr, col.attrs[attr]));
|
|
21
|
-
}
|
|
19
|
+
CT.applyColumnDomAttrs(cell, col);
|
|
22
20
|
CT.applyColumnCellMeta(cell, col);
|
|
23
21
|
|
|
24
22
|
if (!col.features?.sort) {
|
package/src/preferences.js
CHANGED
|
@@ -307,50 +307,53 @@
|
|
|
307
307
|
return merged;
|
|
308
308
|
};
|
|
309
309
|
|
|
310
|
-
CT.
|
|
311
|
-
if (!$
|
|
310
|
+
CT.applyLayoutToRow = function ($row, columns) {
|
|
311
|
+
if (!$row || !$row.length) {
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const chooser = CT.chooserColumns(columns);
|
|
315
|
+
const order = chooser.map(function (col) {
|
|
315
316
|
return col.name;
|
|
316
317
|
});
|
|
317
318
|
const hidden = {};
|
|
318
|
-
|
|
319
|
+
chooser.forEach(function (col) {
|
|
319
320
|
if (col.userHidden) {
|
|
320
321
|
hidden[col.name] = true;
|
|
321
322
|
}
|
|
322
323
|
});
|
|
324
|
+
const $action = $row.children(".kgrid-row-actions");
|
|
325
|
+
const byName = {};
|
|
326
|
+
$row.children("[data-name]").each(function () {
|
|
327
|
+
byName[this.getAttribute("data-name")] = this;
|
|
328
|
+
});
|
|
329
|
+
order.forEach(function (name) {
|
|
330
|
+
const el = byName[name];
|
|
331
|
+
if (!el) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if ($action.length) {
|
|
335
|
+
$(el).insertBefore($action);
|
|
336
|
+
} else {
|
|
337
|
+
$row.append(el);
|
|
338
|
+
}
|
|
339
|
+
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
CT.applyLayoutToDom = function ($table, columns, options) {
|
|
344
|
+
if (!$table || !$table.length) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
323
347
|
const $rows = $table.find(
|
|
324
348
|
".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr"
|
|
325
349
|
);
|
|
326
350
|
$rows.each(function () {
|
|
327
|
-
|
|
328
|
-
const $action = $row.children(".kgrid-row-actions");
|
|
329
|
-
const byName = {};
|
|
330
|
-
$row.children("[data-name]").each(function () {
|
|
331
|
-
byName[this.getAttribute("data-name")] = this;
|
|
332
|
-
});
|
|
333
|
-
order.forEach(function (name) {
|
|
334
|
-
const el = byName[name];
|
|
335
|
-
if (!el) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
if ($action.length) {
|
|
339
|
-
$(el).insertBefore($action);
|
|
340
|
-
} else {
|
|
341
|
-
$row.append(el);
|
|
342
|
-
}
|
|
343
|
-
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
344
|
-
});
|
|
351
|
+
CT.applyLayoutToRow($(this), columns);
|
|
345
352
|
});
|
|
353
|
+
const visible = CT.layoutVisibleColumns(columns);
|
|
346
354
|
const hasActions = $table.find(".kgrid-row-actions").length > 0;
|
|
347
|
-
CT.syncActionColumnColgroup(
|
|
348
|
-
|
|
349
|
-
order.length,
|
|
350
|
-
hasActions,
|
|
351
|
-
options,
|
|
352
|
-
CT.chooserColumns(columns)
|
|
353
|
-
);
|
|
355
|
+
CT.syncActionColumnColgroup($table, visible.length, hasActions, options, visible);
|
|
356
|
+
CT.syncSpanningCells($table, CT.participatingColumnCount(columns, hasActions));
|
|
354
357
|
};
|
|
355
358
|
|
|
356
359
|
CT.refreshCollectionTemplate = function (api, options) {
|
package/src/row-actions.js
CHANGED
|
@@ -213,6 +213,74 @@
|
|
|
213
213
|
return (2.5 * n + 0.75).toFixed(2) + "rem";
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
+
CT.closeRowActionDropdowns = function ($exceptMenu) {
|
|
217
|
+
$(".kgrid-row-actions-menu").each(function () {
|
|
218
|
+
const $wrap = $(this);
|
|
219
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
220
|
+
if ($exceptMenu && $menu[0] === $exceptMenu[0]) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
$menu.removeClass("show").css({ top: "", left: "", right: "", position: "" });
|
|
224
|
+
$wrap.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded", "false").removeClass("show");
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Wire row-action kebab menus. Uses a small jQuery toggle (not Bootstrap Dropdown)
|
|
230
|
+
* so we do not depend on data-api / popperConfig quirks; menu is position:fixed while open.
|
|
231
|
+
* @param {JQuery} $root
|
|
232
|
+
*/
|
|
233
|
+
CT.mountRowActionDropdowns = function ($root) {
|
|
234
|
+
if (!$root || !$root.length) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!CT._rowActionsDropdownDocBound) {
|
|
238
|
+
CT._rowActionsDropdownDocBound = true;
|
|
239
|
+
$(document)
|
|
240
|
+
.on("click.kgridRowActions", function () {
|
|
241
|
+
CT.closeRowActionDropdowns();
|
|
242
|
+
})
|
|
243
|
+
.on("keydown.kgridRowActions", function (e) {
|
|
244
|
+
if (e.key === "Escape") {
|
|
245
|
+
CT.closeRowActionDropdowns();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
$root.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function () {
|
|
250
|
+
const toggle = this;
|
|
251
|
+
const $toggle = $(toggle);
|
|
252
|
+
const $wrap = $toggle.parent(".kgrid-row-actions-menu");
|
|
253
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
254
|
+
$toggle.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
event.stopPropagation();
|
|
257
|
+
const willOpen = !$menu.hasClass("show");
|
|
258
|
+
CT.closeRowActionDropdowns();
|
|
259
|
+
if (!willOpen) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const rect = toggle.getBoundingClientRect();
|
|
263
|
+
$menu.addClass("show").css({
|
|
264
|
+
position: "fixed",
|
|
265
|
+
top: Math.round(rect.bottom + 2) + "px",
|
|
266
|
+
left: "auto",
|
|
267
|
+
right: Math.round(window.innerWidth - rect.right) + "px",
|
|
268
|
+
zIndex: 1055,
|
|
269
|
+
});
|
|
270
|
+
$toggle.addClass("show").attr("aria-expanded", "true");
|
|
271
|
+
});
|
|
272
|
+
$menu.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
});
|
|
275
|
+
$menu.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose", function () {
|
|
276
|
+
// Close after the action click handlers (same tick is fine).
|
|
277
|
+
setTimeout(function () {
|
|
278
|
+
CT.closeRowActionDropdowns();
|
|
279
|
+
}, 0);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
|
|
216
284
|
function iconHtml(icon) {
|
|
217
285
|
if (!icon) {
|
|
218
286
|
return "";
|
|
@@ -287,11 +355,9 @@
|
|
|
287
355
|
.addClass("btn-group kgrid-row-actions-menu")
|
|
288
356
|
.appendTo($buttonColumn);
|
|
289
357
|
$("<button>")
|
|
290
|
-
.addClass("btn btn-sm btn-outline-secondary dropdown-toggle")
|
|
358
|
+
.addClass("btn btn-sm btn-outline-secondary dropdown-toggle kgrid-actions-dropdown-toggle")
|
|
291
359
|
.attr({
|
|
292
360
|
type: "button",
|
|
293
|
-
"data-bs-toggle": "dropdown",
|
|
294
|
-
"data-bs-popper-config": JSON.stringify({ strategy: "fixed" }),
|
|
295
361
|
"aria-expanded": "false",
|
|
296
362
|
title: "Actions",
|
|
297
363
|
})
|
package/styles/table.css
CHANGED
|
@@ -182,11 +182,14 @@ div.save-item{
|
|
|
182
182
|
white-space: nowrap;
|
|
183
183
|
overflow: visible;
|
|
184
184
|
}
|
|
185
|
-
/*
|
|
185
|
+
/* Kebab row-actions menu: fixed while open (set inline); escape table stacking. */
|
|
186
186
|
.kgrid-row-actions-menu .dropdown-menu {
|
|
187
187
|
z-index: 1055;
|
|
188
188
|
}
|
|
189
|
-
.
|
|
189
|
+
.kgrid-row-actions-menu .dropdown-menu.show {
|
|
190
|
+
display: block;
|
|
191
|
+
}
|
|
192
|
+
.custom-table-shell tr:has(.kgrid-row-actions-menu .kgrid-actions-dropdown-toggle.show) {
|
|
190
193
|
position: relative;
|
|
191
194
|
z-index: 6;
|
|
192
195
|
}
|
|
@@ -197,22 +200,15 @@ div.save-item{
|
|
|
197
200
|
display: none;
|
|
198
201
|
}
|
|
199
202
|
|
|
200
|
-
/* User-hidden columns (chooser):
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
/* User-hidden columns (chooser): keep cells in the DOM for filters/forms, but
|
|
204
|
+
they must not occupy a table-layout slot. `display:none` removes the cell from
|
|
205
|
+
the column mapping, so colgroup must omit that column too (see layoutVisibleColumns).
|
|
206
|
+
Do not leave a width:0 <col> — remaining cells then map onto the wrong widths
|
|
207
|
+
(letter-stacked headers, blank gaps after paging). Chrome also treats
|
|
208
|
+
visibility:collapse as hidden, so that is not a substitute. */
|
|
205
209
|
th.kgrid-user-hidden,
|
|
206
210
|
td.kgrid-user-hidden {
|
|
207
|
-
|
|
208
|
-
width: 0 !important;
|
|
209
|
-
max-width: 0;
|
|
210
|
-
padding: 0 !important;
|
|
211
|
-
border-width: 0 !important;
|
|
212
|
-
overflow: hidden;
|
|
213
|
-
white-space: nowrap;
|
|
214
|
-
line-height: 0;
|
|
215
|
-
font-size: 0;
|
|
211
|
+
display: none !important;
|
|
216
212
|
}
|
|
217
213
|
|
|
218
214
|
.kgrid-column-chooser {
|
|
@@ -325,6 +321,13 @@ td.kgrid-user-hidden {
|
|
|
325
321
|
.custom-table .thead-labels th{
|
|
326
322
|
background-color: #2c3e50;
|
|
327
323
|
color: #fff;
|
|
324
|
+
white-space: nowrap;
|
|
325
|
+
overflow: hidden;
|
|
326
|
+
text-overflow: ellipsis;
|
|
327
|
+
}
|
|
328
|
+
.custom-table .main-tbody td {
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
vertical-align: middle;
|
|
328
331
|
}
|
|
329
332
|
.custom-table th,.custom-table td{
|
|
330
333
|
padding: 5px;
|