@logimaxx/kgrid 0.2.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.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Demo custom input type for KGrid — a native HTML `<select>` wrapped as a field-type plugin.
3
+ *
4
+ * No external libraries. Use this file as a minimal reference when building your own
5
+ * `customInputTypes` plugins.
6
+ *
7
+ * Load order: jQuery → kgrid.js → this script → `KGrid.configure()` → `KGrid.init()`.
8
+ *
9
+ * @example Host wiring (see also demo/js/app.js)
10
+ * KGrid.configure({
11
+ * customInputTypes: {
12
+ * demo_select: KGrid.demoSelect(),
13
+ * },
14
+ * });
15
+ *
16
+ * @example Column config (filter, insert, and/or update)
17
+ * filter: {
18
+ * type: "demo_select",
19
+ * operator: "=",
20
+ * options: [
21
+ * { label: "All", value: "" },
22
+ * { label: "Hardware", value: "hardware" },
23
+ * ],
24
+ * },
25
+ * insert: { type: "demo_select", options: [...], events: [] },
26
+ * update: { type: "demo_select", options: [...], events: [] },
27
+ *
28
+ * Registration: `demoSelect()` returns a plugin object; KGrid registers it when you pass
29
+ * that object in `configure({ customInputTypes })` (same as `registerFieldType`, but
30
+ * grouped with other host config). You can also call `KGrid.registerFieldType("demo_select", plugin)`
31
+ * directly if you prefer.
32
+ */
33
+ (function (CT) {
34
+ /**
35
+ * Append `{ label, value }` entries to a `<select>`.
36
+ * @param {JQuery} $select
37
+ * @param {Array<{ label: string, value: string }>} options
38
+ */
39
+ function fillOptions($select, options) {
40
+ if (!Array.isArray(options)) {
41
+ throw new Error("demo_select: options must be an array");
42
+ }
43
+ options.forEach(function (opt) {
44
+ if (typeof opt.label !== "string" || typeof opt.value === "undefined") {
45
+ throw new Error("demo_select: each option needs label and value");
46
+ }
47
+ $("<option>").text(opt.label).attr("value", String(opt.value)).appendTo($select);
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Build the `demo_select` field-type plugin.
53
+ *
54
+ * Does not register by itself — pass the return value to:
55
+ * `KGrid.configure({ customInputTypes: { demo_select: KGrid.demoSelect() } })`.
56
+ *
57
+ * @returns {{ filterEvents: string, create: Function, mount: Function }}
58
+ */
59
+ CT.demoSelect = function () {
60
+ return {
61
+ /**
62
+ * Filter row: submit the hidden filter form on `change` only (not `input`, which
63
+ * would fire twice on `<select>` in some browsers).
64
+ */
65
+ filterEvents: "change",
66
+
67
+ /**
68
+ * Create the control DOM for filter, insert, or update.
69
+ * @param {{ mode: "filter"|"insert"|"update", col: object, config: object }} ctx
70
+ * @returns {{ $input: JQuery, skipValueAttr: boolean }}
71
+ */
72
+ create({ mode, config }) {
73
+ const cls =
74
+ mode === "filter"
75
+ ? "form-select form-select-sm"
76
+ : "form-input form-select form-control form-control-sm";
77
+ const $input = $("<select>").addClass(cls);
78
+ fillOptions($input, config.options);
79
+ // skipValueAttr: native update path sets <select> via mount(), not value=""
80
+ return { $input, skipValueAttr: true };
81
+ },
82
+
83
+ /**
84
+ * After the row is in the DOM (update mode): set the current value from the item.
85
+ * Built-in `type: "select"` does this in KGrid events; pluggable types must do it here.
86
+ * @param {{ mode: string, $input: JQuery, col: object, item?: object }} ctx
87
+ */
88
+ mount({ mode, $input, col, item }) {
89
+ if (mode !== "update" || !item?.attributes || !col?.name) {
90
+ return;
91
+ }
92
+ const val = item.attributes[col.name];
93
+ if (val != null && val !== "") {
94
+ $input.val(typeof val === "boolean" ? String(val) : val);
95
+ }
96
+ },
97
+ };
98
+ };
99
+ })(window.KGrid);
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Optional widgets for KGrid custom input types.
3
+ * Load after jQuery, kgrid.js, and any libraries (Select2, autosuggest, …).
4
+ *
5
+ * KGrid.configure({
6
+ * customInputTypes: {
7
+ * select2: KGrid.select2(select2wrapper),
8
+ * autosuggest: KGrid.autosuggest(function ($input, o) { return $input.autosuggest(o); }),
9
+ * },
10
+ * });
11
+ */
12
+ (function (CT) {
13
+ function assertRemoteOptions(options, typeName, mode) {
14
+ if (!options?.url || !options?.idFld || !options?.labelFld) {
15
+ throw new Error(
16
+ "Invalid " + typeName + " config (" + mode + "): " + JSON.stringify(options, null, 2)
17
+ );
18
+ }
19
+ }
20
+
21
+ function select2OptionsWithDefault($select, optionsConfig, defaultSpec) {
22
+ const opts = { ...(optionsConfig || {}) };
23
+ const $sel = $select.find("option:selected");
24
+ if ($sel.length && String($sel.val() ?? "") !== "") {
25
+ opts.default = { value: $sel.val(), label: $sel.text() };
26
+ } else if (defaultSpec && typeof defaultSpec === "object" && defaultSpec.value != null) {
27
+ opts.default = defaultSpec;
28
+ } else if (defaultSpec != null && defaultSpec !== "" && typeof defaultSpec !== "object") {
29
+ opts.default = { value: String(defaultSpec), label: String(defaultSpec) };
30
+ }
31
+ return opts;
32
+ }
33
+
34
+ function assertSelect2Options(options, context) {
35
+ if (!options?.url || !options?.idFld || !options?.labelFld) {
36
+ throw new Error("Invalid select2 config (" + context + "): " + JSON.stringify(options, null, 2));
37
+ }
38
+ }
39
+
40
+ CT.select2 = function (select2Wrapper) {
41
+ if (typeof select2Wrapper !== "function") {
42
+ throw new TypeError("select2(wrapper): wrapper must be a function");
43
+ }
44
+
45
+ function initOnField($input, wrapperOptions, context) {
46
+ assertSelect2Options(wrapperOptions, context);
47
+ const $inp = $($input);
48
+ if ($inp.data("select2")) {
49
+ $inp.select2("destroy");
50
+ }
51
+ select2Wrapper($inp, wrapperOptions);
52
+ }
53
+
54
+ return {
55
+ filterEvents: false,
56
+ filterDebounceMs: 0,
57
+ validate(config, mode) {
58
+ if (mode === "filter") {
59
+ return;
60
+ }
61
+ assertRemoteOptions(config.options, "select2", mode);
62
+ },
63
+ create({ mode, config }) {
64
+ const cls =
65
+ mode === "filter"
66
+ ? "form-select form-select-sm select2"
67
+ : "form-input form-select form-select-sm select2";
68
+ const $input = $("<select>").addClass(cls);
69
+ const defaultSpec =
70
+ mode === "filter"
71
+ ? config.default
72
+ : config.value ?? config.default;
73
+ if (defaultSpec && typeof defaultSpec === "object" && defaultSpec.value != null) {
74
+ $("<option>")
75
+ .text(defaultSpec.label ?? defaultSpec.value)
76
+ .attr("value", defaultSpec.value)
77
+ .appendTo($input);
78
+ }
79
+ return { $input, skipValueAttr: true };
80
+ },
81
+ mount({ mode, $input, config, col }) {
82
+ if (mode === "filter") {
83
+ initOnField(
84
+ $input,
85
+ select2OptionsWithDefault($($input), config.options, config.default),
86
+ "filter"
87
+ );
88
+ return;
89
+ }
90
+ if (mode === "insert") {
91
+ select2Wrapper($input, {
92
+ ...config.options,
93
+ default: col?.insert?.default ?? config.default,
94
+ });
95
+ return;
96
+ }
97
+ if (mode === "update") {
98
+ initOnField(
99
+ $input[0],
100
+ select2OptionsWithDefault($($input), config.options, config.value),
101
+ "update"
102
+ );
103
+ }
104
+ },
105
+ bindFilterSubmit($input, onSubmit) {
106
+ $input.on("select2:select select2:clear", onSubmit);
107
+ },
108
+ };
109
+ };
110
+
111
+ CT.select2.helpers = {
112
+ select2OptionsWithDefault,
113
+ assertSelect2Options,
114
+ };
115
+
116
+ CT.autosuggest = function (autosuggestWrapper) {
117
+ if (typeof autosuggestWrapper !== "function") {
118
+ throw new TypeError("autosuggest(wrapper): wrapper must be a function");
119
+ }
120
+ return CT.inputType(
121
+ function ($input, options) {
122
+ autosuggestWrapper($input, options);
123
+ },
124
+ {
125
+ element: "<input autocomplete='off' type='text' class='form-control form-control-sm'/>",
126
+ formInputClass: "form-input",
127
+ validate(config, mode) {
128
+ if (mode === "filter") {
129
+ return;
130
+ }
131
+ assertRemoteOptions(config.options, "autosuggest", mode);
132
+ },
133
+ }
134
+ );
135
+ };
136
+ })(window.KGrid);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Example: wire MAXXOPS lib.js helpers into KGrid.
3
+ * Load: lib.js, select2.js, autosuggest.js, kgrid.js, kgrid-widgets.js
4
+ */
5
+ KGrid.configure({
6
+ log: typeof klog === "function" ? klog : console.log.bind(console),
7
+ onError: modal_error,
8
+ confirm: modal_confirm,
9
+ serializeForm: serializeFormData2,
10
+ customInputTypes: {
11
+ select2: KGrid.select2(select2wrapper),
12
+ autosuggest: KGrid.autosuggest(function ($input, options) {
13
+ return $input.autosuggest(options);
14
+ }),
15
+ },
16
+ });
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@logimaxx/kgrid",
3
+ "version": "0.2.3",
4
+ "description": "KGrid — declarative data table for KViews (filter, sort, paging, inline CRUD). Proprietary — Logimaxx System SRL.",
5
+ "main": "dist/kgrid.js",
6
+ "homepage": "https://logimaxx.ro",
7
+ "author": {
8
+ "name": "Sergiu Voicu",
9
+ "email": "sergiu@logimaxx.ro",
10
+ "url": "https://logimaxx.ro"
11
+ },
12
+ "publisher": "Logimaxx System SRL",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src",
19
+ "styles",
20
+ "docs",
21
+ "integrations",
22
+ "LICENSE",
23
+ "NOTICE.md",
24
+ "AGENTS.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "node scripts/build.js",
28
+ "demo": "node demo/server.js",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "prepare": "npm run build",
32
+ "release": "node scripts/release.mjs"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/logimaxx/kgrid.git"
37
+ },
38
+ "keywords": [
39
+ "kgrid",
40
+ "kviews",
41
+ "jquery",
42
+ "data-table",
43
+ "crud"
44
+ ],
45
+ "license": "UNLICENSED",
46
+ "peerDependencies": {
47
+ "jquery": ">=3.7.0",
48
+ "@logimaxx/kviews": ">=1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@logimaxx/kviews": "^1.0.0",
52
+ "jquery": "^3.7.1",
53
+ "jsdom": "^26.1.0",
54
+ "terser": "^5.48.0",
55
+ "vitest": "^3.2.4"
56
+ }
57
+ }
package/src/cells.js ADDED
@@ -0,0 +1,113 @@
1
+ (function (CT) {
2
+ /**
3
+ * Setup data cell
4
+ * @param {Object} col
5
+ * @param {jQuery} editForm hidden anchor form (fields use form="id")
6
+ * @returns {jQuery}
7
+ */
8
+ CT.setupCell = function (col, editForm) {
9
+
10
+ const formId = editForm ? editForm.attr("id") : null;
11
+
12
+ const c = {...col };
13
+ const $cell = $("<td>").attr("data-label", col.label);
14
+ CT.applyColumnCellMeta($cell, col);
15
+
16
+ const attrs = (c.attrs && typeof c.attrs==="object") ? c.attrs : {};
17
+ Object.keys(attrs).forEach(attr => $cell.attr(attr, attrs[attr]));
18
+
19
+ let cellContent = $("<div>").addClass("cell-content");
20
+ cellContent.html(c.display.template ?? `{{${c.name}}}`);
21
+ cellContent.appendTo($cell);
22
+
23
+ if (editForm==null || !col.features.update) {
24
+ cellContent.clone(true).removeClass('cell-content').addClass('cell-input').appendTo($cell);
25
+ return $cell;
26
+ }
27
+
28
+ if(!c.name) {
29
+ throw new Error("Column must have a name when column.features.update is true: \n"+JSON.stringify(col,null,2));
30
+ }
31
+
32
+ const updateConfig = c.update;
33
+ const updateType = updateConfig.type ?? "text";
34
+ let input;
35
+ let skipValueAttr = false;
36
+
37
+ const pluggable = CT.createFieldInput({ mode: "update", col, config: updateConfig });
38
+ if (pluggable) {
39
+ input = pluggable.$input;
40
+ skipValueAttr = !!pluggable.skipValueAttr;
41
+ } else {
42
+ switch(updateType) {
43
+ case "textarea":
44
+ input = $(`<textarea class='form-input form-control form-control-sm'>{{${updateConfig.value??c.name}}}</textarea>`);
45
+ skipValueAttr = true;
46
+ break;
47
+ case "select":
48
+ input = $(`<select class='form-input form-control form-control-sm'/>`);
49
+ if(!Array.isArray(updateConfig.options)) {
50
+ throw new Error("Select column must have an update.options array when column.features.update is true: \n"+JSON.stringify(col,null,2));
51
+ }
52
+ updateConfig.options.forEach((opt) => {
53
+ if(typeof opt.label !== "string" || typeof opt.value === "undefined") {
54
+ throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(col,null,2));
55
+ }
56
+ $("<option>").text(opt.label).attr("value", opt.value).appendTo(input);
57
+ });
58
+ skipValueAttr = true;
59
+ break;
60
+ case "hidden":
61
+ input = $(`<input type='hidden' class='form-input form-control form-control-sm'/>`);
62
+ break;
63
+ case "displayonly": {
64
+ const tpl =
65
+ updateConfig.template ||
66
+ c.display.template ||
67
+ `{{${c.name}}}`;
68
+ $("<div>").addClass("cell-input").append(tpl).appendTo($cell);
69
+ return $cell;
70
+ }
71
+ default:
72
+ if(CT.isValidInputType(updateType)) {
73
+ input = $(`<input autocomplete='off' type='${updateType}' class='form-input form-control form-control-sm'/>`);
74
+ } else {
75
+ throw new Error("Invalid update updateConfig type: "+JSON.stringify(updateConfig,null,2));
76
+ }
77
+ }
78
+ input.attr("data-type", updateType);
79
+ }
80
+
81
+ if(updateConfig.attrs && typeof updateConfig.attrs === 'object') {
82
+ Object.keys(updateConfig.attrs).forEach(k => input.attr(k, updateConfig.attrs[k]));
83
+ }
84
+
85
+ input.attr("form",formId);
86
+ input.attr("name",c.name);
87
+ if (!skipValueAttr && updateType !== "textarea") {
88
+ const rawValue = updateConfig.value ?? `{{${c.name}}}`;
89
+ if (rawValue != null && typeof rawValue !== "object") {
90
+ input.attr("value", rawValue);
91
+ }
92
+ }
93
+
94
+ if(c.hidden) {
95
+ input.attr("type","hidden").appendTo(editForm);
96
+ return $cell;
97
+ }
98
+
99
+
100
+ if(updateConfig.disabled) input.attr("disabled",true);
101
+ if(updateConfig.readonly) input.attr("readonly",true);
102
+ if(updateConfig.required) input.attr("required",true);
103
+
104
+ if(updateConfig.attrs && typeof updateConfig.attrs === 'object') {
105
+ Object.keys(updateConfig.attrs).forEach(k => input.attr(k, updateConfig.attrs[k]));
106
+ }
107
+ if(!updateConfig.disabled && !updateConfig.readonly)
108
+ input.attr("onchange","$(this).parents('tr').addClass('editing')");
109
+
110
+ $("<div>").addClass("cell-input").append(input).appendTo($cell);
111
+ return $cell;
112
+ };
113
+ })(window.KGrid);
package/src/config.js ADDED
@@ -0,0 +1,59 @@
1
+ (function (CT) {
2
+ /** Plain object (not array / null) — realm-safe vs `constructor === Object`. */
3
+ CT.isPlainObject = function (value) {
4
+ return value != null && typeof value === "object" && !Array.isArray(value);
5
+ };
6
+
7
+ CT.setDefaultValues = function (proto, col) {
8
+ const newCol = { ...(proto || {}) };
9
+ Object.keys(col || {}).forEach((key) => {
10
+ if (CT.isPlainObject(col[key]) && CT.isPlainObject(newCol[key])) {
11
+ newCol[key] = CT.setDefaultValues(newCol[key], col[key]);
12
+ return;
13
+ }
14
+ if (CT.isPlainObject(col[key]) && newCol[key] == null) {
15
+ newCol[key] = CT.setDefaultValues({}, col[key]);
16
+ return;
17
+ }
18
+ newCol[key] = col[key];
19
+ });
20
+ return newCol;
21
+ };
22
+
23
+ /**
24
+ * Normalize a column: expand `input` shorthand, merge proto, ensure events[].
25
+ * @param {Object} col raw column from table options
26
+ * @returns {Object}
27
+ */
28
+ CT.normalizeColumnConfig = function (col) {
29
+ let partial = col && typeof col === "object" ? { ...col } : {};
30
+ if (CT.isPlainObject(partial.input)) {
31
+ const shared = { ...partial.input };
32
+ delete partial.input;
33
+ partial.insert = CT.setDefaultValues(shared, partial.insert || {});
34
+ partial.update = CT.setDefaultValues(shared, partial.update || {});
35
+ }
36
+ const merged = CT.setDefaultValues(CT.protoColumnConfig, partial);
37
+ if (merged.class == null && merged.columnClass) {
38
+ merged.class = merged.columnClass;
39
+ }
40
+ if (
41
+ merged.update &&
42
+ merged.update.type === "displayonly" &&
43
+ !merged.update.template &&
44
+ merged.display &&
45
+ merged.display.template
46
+ ) {
47
+ merged.update.template = merged.display.template;
48
+ }
49
+ ["display", "insert", "update"].forEach((mode) => {
50
+ if (!merged[mode] || typeof merged[mode] !== "object") {
51
+ return;
52
+ }
53
+ if (!Array.isArray(merged[mode].events)) {
54
+ merged[mode].events = [];
55
+ }
56
+ });
57
+ return merged;
58
+ };
59
+ })(window.KGrid);
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Host-app integration: call KGrid.configure({ ... }) before mounting tables.
3
+ */
4
+ (function (CT) {
5
+ const defaultConfig = {
6
+ log: function () {},
7
+ onError: function (err) {
8
+ console.error(err);
9
+ },
10
+ confirm: function (message, onConfirm, onCancel) {
11
+ if (typeof window !== "undefined" && window.confirm(message)) {
12
+ onConfirm();
13
+ } else if (onCancel) {
14
+ onCancel();
15
+ }
16
+ },
17
+ /** @type {((context: object, onConfirm: Function, onCancel?: Function) => void)|null} */
18
+ deleteConfirm: null,
19
+ serializeForm: function (form, columns) {
20
+ const fd = new FormData(form);
21
+ const out = {};
22
+ for (const [key, value] of fd.entries()) {
23
+ if (Object.prototype.hasOwnProperty.call(out, key)) {
24
+ if (!Array.isArray(out[key])) {
25
+ out[key] = [out[key]];
26
+ }
27
+ out[key].push(value);
28
+ } else {
29
+ out[key] = value;
30
+ }
31
+ }
32
+ return out;
33
+ },
34
+ /** @type {Record<string, Function|object>|null} name → wrapper fn or field type plugin */
35
+ customInputTypes: null,
36
+ /** @deprecated use customInputTypes */
37
+ fieldTypes: null,
38
+ /** @type {typeof globalThis.KViews|null} Set via configure or use window.KViews */
39
+ kviews: null,
40
+ /** Default delay (ms) before filter submit; 0 = immediate. Applies to the resolved filter-submit event. */
41
+ filterDebounceMs: 300,
42
+ };
43
+
44
+ CT._config = Object.assign({}, defaultConfig);
45
+
46
+ /**
47
+ * @param {Object} overrides
48
+ * @param {Function} [overrides.log]
49
+ * @param {Function} [overrides.onError]
50
+ * @param {Function} [overrides.confirm] (message, onConfirm, onCancel?)
51
+ * @param {Function} [overrides.deleteConfirm] (context, onConfirm, onCancel?) — row delete UX
52
+ * @param {Function} [overrides.serializeForm] (form, columns?)
53
+ * @param {Object} [overrides.customInputTypes] map of name → wrapper fn or field type plugin
54
+ * @param {Object} [overrides.fieldTypes] deprecated alias of customInputTypes
55
+ * @param {Object} [overrides.kviews] KViews module (createCollectionInstance)
56
+ * @param {number} [overrides.filterDebounceMs] default filter submit debounce (ms); 0 = off
57
+ */
58
+ CT.configure = function (overrides) {
59
+ if (overrides && typeof overrides === "object") {
60
+ Object.assign(CT._config, overrides);
61
+ }
62
+ if (typeof CT._syncCustomInputTypes === "function") {
63
+ CT._syncCustomInputTypes();
64
+ }
65
+ return CT;
66
+ };
67
+
68
+ CT.log = function () {
69
+ CT._config.log.apply(null, arguments);
70
+ };
71
+
72
+ CT.onError = function (err) {
73
+ return CT._config.onError(err);
74
+ };
75
+
76
+ CT.confirm = function (message, onConfirm, onCancel) {
77
+ return CT._config.confirm(message, onConfirm, onCancel);
78
+ };
79
+
80
+ CT.DEFAULT_DELETE_CONFIRM_MESSAGE = "Delete this record?";
81
+
82
+ CT._defaultDeleteConfirm = function (context, onConfirm, onCancel) {
83
+ CT.confirm(CT.DEFAULT_DELETE_CONFIRM_MESSAGE, onConfirm, onCancel);
84
+ };
85
+
86
+ /**
87
+ * Ask the host to confirm row delete. Per-table `options.deleteConfirm` wins over configure.
88
+ * @param {{ item: object, view: object, options?: object }} context
89
+ * @param {() => void} onConfirm run delete (e.g. item.delete())
90
+ * @param {() => void} [onCancel]
91
+ */
92
+ CT.runDeleteConfirm = function (context, onConfirm, onCancel) {
93
+ const perTable =
94
+ context.options && typeof context.options.deleteConfirm === "function"
95
+ ? context.options.deleteConfirm
96
+ : null;
97
+ const configured =
98
+ typeof CT._config.deleteConfirm === "function"
99
+ ? CT._config.deleteConfirm
100
+ : null;
101
+ const fn = perTable || configured || CT._defaultDeleteConfirm;
102
+ return fn(context, onConfirm, onCancel);
103
+ };
104
+
105
+ CT.serializeForm = function (form, columns) {
106
+ return CT._config.serializeForm(form, columns);
107
+ };
108
+
109
+ /**
110
+ * Resolve KViews from init override, configure({ kviews }), or window.KViews.
111
+ * @param {Object} [override] per-init kviews (opts.kviews)
112
+ * @returns {Object|null}
113
+ */
114
+ CT.getKViews = function (override) {
115
+ const candidates = [override, CT._config.kviews];
116
+ for (let i = 0; i < candidates.length; i++) {
117
+ const kv = candidates[i];
118
+ if (kv && typeof kv.createCollectionInstance === "function") {
119
+ return kv;
120
+ }
121
+ }
122
+ const root = typeof window !== "undefined"
123
+ ? window
124
+ : (typeof globalThis !== "undefined" ? globalThis : {});
125
+ const globalKv = root.KViews;
126
+ if (globalKv && typeof globalKv.createCollectionInstance === "function") {
127
+ return globalKv;
128
+ }
129
+ return null;
130
+ };
131
+
132
+ CT.KVIEWS_MISSING_MSG =
133
+ "KGrid requires KViews: install peer @logimaxx/kviews, load it before kgrid.js " +
134
+ "(window.KViews), or call KGrid.configure({ kviews: KViews }). " +
135
+ "You can also pass kviews in table options: KGrid.init(host, { kviews, ... }).";
136
+ })(window.KGrid = window.KGrid || {});