@logimaxx/kgrid 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,6 +96,7 @@ const grid = await KGrid.init(document.getElementById("table-host"), {
96
96
  | [Integration guide](docs/integration.md) | `configure()`, KViews, plugins |
97
97
  | [Field types](docs/field-types.md) | Native, built-in, plugins (select2, autosuggest, custom) |
98
98
  | [Table shell template](docs/table-shell.md) | HTML template, placeholders, custom markup |
99
+ | [Release guide](docs/release.md) | Maintainer version bump, tag, npm publish |
99
100
 
100
101
  ## API overview
101
102
 
@@ -148,4 +149,5 @@ Proprietary. Copyright © Logimaxx System SRL. All rights reserved. See [LICENSE
148
149
  |----------|---------|
149
150
  | [NOTICE.md](NOTICE.md) | Company, author, contact |
150
151
  | [CONTRIBUTING.md](CONTRIBUTING.md) | Internal contribution guidelines |
152
+ | [docs/release.md](docs/release.md) | Version, tag, and publish |
151
153
  | [SECURITY.md](SECURITY.md) | Vulnerability reporting |
package/dist/kgrid.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-07-30T15:53:29.364Z */
1
+ /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-08-27T12:47:37.279Z */
2
2
 
3
3
  /* --- configure.js --- */
4
4
  /**
@@ -154,7 +154,8 @@
154
154
  "paging": false,
155
155
  "create": false,
156
156
  "update": false,
157
- "delete": false
157
+ "delete": false,
158
+ "clone": false
158
159
  },
159
160
  "defaultInteraction": "view",
160
161
  "insertFormRow": {
@@ -360,7 +361,7 @@
360
361
  if (!f) {
361
362
  return false;
362
363
  }
363
- return !!(f.delete || f.update || f.create);
364
+ return !!(f.delete || f.update || f.create || f.clone);
364
365
  };
365
366
 
366
367
  /**
@@ -896,8 +897,11 @@
896
897
  if (overrides.delete !== undefined) {
897
898
  $shell.attr("data-allow-delete", overrides.delete ? "true" : "false");
898
899
  }
900
+ if (overrides.clone !== undefined) {
901
+ $shell.attr("data-allow-clone", overrides.clone ? "true" : "false");
902
+ }
899
903
  } else if (interaction === "edit") {
900
- $shell.removeAttr("data-allow-insert data-allow-update data-allow-delete");
904
+ $shell.removeAttr("data-allow-insert data-allow-update data-allow-delete data-allow-clone");
901
905
  }
902
906
  };
903
907
  })(window.KGrid);
@@ -1524,6 +1528,13 @@
1524
1528
 
1525
1529
  if (CT.hasActionColumn(options)) {
1526
1530
  const buttonColumn = $("<td>").addClass("kgrid-row-actions").appendTo(dataRow);
1531
+ if(options.features.clone) {
1532
+ $("<div>").addClass("btn-group clone-item-grp").appendTo(buttonColumn).append(
1533
+ $("<button>").addClass("btn btn-sm btn-outline-secondary clone-item")
1534
+ .attr("type","button")
1535
+ .attr("title","Clone item")
1536
+ .append("<i class='fa-regular fa-copy'></i>"));
1537
+ }
1527
1538
  if(options.features.delete) {
1528
1539
  $("<div>").addClass("btn-group delete-item-grp").appendTo(buttonColumn).append(
1529
1540
  $("<button>").addClass("btn btn-sm btn-danger delete-item")
@@ -1826,6 +1837,15 @@
1826
1837
  });
1827
1838
  }
1828
1839
 
1840
+ if(options.features.clone) {
1841
+ view.el.find("button.clone-item").off("click").on("click",(event)=>{
1842
+ event.preventDefault();
1843
+ if (typeof options.onClone === "function") {
1844
+ options.onClone(item, view, event);
1845
+ }
1846
+ });
1847
+ }
1848
+
1829
1849
  if(options.features.delete) {
1830
1850
  view.el.find("button.delete-item").off("click").on("click",(event)=>{
1831
1851
  event.preventDefault();
@@ -1914,6 +1934,17 @@
1914
1934
 
1915
1935
  const handlers = options.handlers ?? {};
1916
1936
  delete options.handlers;
1937
+ if (typeof options.onClone === "string") {
1938
+ const fn =
1939
+ handlers[options.onClone] ||
1940
+ (options.functions && options.functions[options.onClone]);
1941
+ if (!fn || typeof fn !== "function") {
1942
+ throw new Error(
1943
+ "onClone handler " + options.onClone + " not found or is not a function"
1944
+ );
1945
+ }
1946
+ options.onClone = fn;
1947
+ }
1917
1948
  options.columns.forEach((col) => {
1918
1949
  ["insert", "update", "display"].forEach((mode) => {
1919
1950
  const events = col[mode].events;
package/dist/kgrid.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-07-30T15:53:29.364Z */
2
- !function(t){const e={log:function(){},onError:function(t){console.error(t)},confirm:function(t,e,n){"undefined"!=typeof window&&window.confirm(t)?e():n&&n()},deleteConfirm:null,serializeForm:function(t,e){const n=new FormData(t),r={};for(const[t,e]of n.entries())Object.prototype.hasOwnProperty.call(r,t)?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(e)):r[t]=e;return r},customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300};t._config=Object.assign({},e),t.configure=function(e){return e&&"object"==typeof e&&Object.assign(t._config,e),"function"==typeof t._syncCustomInputTypes&&t._syncCustomInputTypes(),t},t.log=function(){t._config.log.apply(null,arguments)},t.onError=function(e){return t._config.onError(e)},t.confirm=function(e,n,r){return t._config.confirm(e,n,r)},t.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",t._defaultDeleteConfirm=function(e,n,r){t.confirm(t.DEFAULT_DELETE_CONFIRM_MESSAGE,n,r)},t.runDeleteConfirm=function(e,n,r){const o=e.options&&"function"==typeof e.options.deleteConfirm?e.options.deleteConfirm:null,a="function"==typeof t._config.deleteConfirm?t._config.deleteConfirm:null;return(o||a||t._defaultDeleteConfirm)(e,n,r)},t.serializeForm=function(e,n){return t._config.serializeForm(e,n)},t.getKViews=function(e){const n=[e,t._config.kviews];for(let t=0;t<n.length;t++){const e=n[t];if(e&&"function"==typeof e.createCollectionInstance)return e}const r=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return r&&"function"==typeof r.createCollectionInstance?r:null},t.KVIEWS_MISSING_MSG="KGrid requires KViews: install peer @logimaxx/kviews, load it before kgrid.js (window.KViews), or call KGrid.configure({ kviews: KViews }). You can also pass kviews in table options: KGrid.init(host, { kviews, ... })."}(window.KGrid=window.KGrid||{}),function(t){t.protoOptions={url:null,type:null,filter:null,features:{filtering:!1,sorting:!1,paging:!1,create:!1,update:!1,delete:!1},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"},t.protoColumnConfig={label:null,name:null,hidden:!1,class:null,columnClass:null,attrs:{},features:{create:!1,update:!1,filter:!1,sort:!1},display:{template:null,events:[]},input:null,insert:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,events:[]},update:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,template:null,events:[]},filter:{type:"text",operator:"~=~",default:null,placeholder:"",options:null,persist:!1,debounceMs:null}},t.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],t.VALID_INPUT_TYPES=t.VALID_NATIVE_INPUT_TYPES.slice(),t.VALID_NATIVE_FILTER_TYPES=t.VALID_NATIVE_INPUT_TYPES.filter(t=>"displayonly"!==t),t.VALID_FILTER_TYPES=t.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),t.isValidInputType=function(e){return t.VALID_NATIVE_INPUT_TYPES.includes(e)||t.isPluggableFieldType(e)},t.isValidFilterType=function(e){return"displayonly"!==e&&(t.VALID_NATIVE_FILTER_TYPES.includes(e)||t.isPluggableFieldType(e))}}(window.KGrid=window.KGrid||{}),function(t){t.isPlainObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.setDefaultValues=function(e,n){const r={...e||{}};return Object.keys(n||{}).forEach(e=>{t.isPlainObject(n[e])&&t.isPlainObject(r[e])?r[e]=t.setDefaultValues(r[e],n[e]):t.isPlainObject(n[e])&&null==r[e]?r[e]=t.setDefaultValues({},n[e]):r[e]=n[e]}),r},t.normalizeColumnConfig=function(e){let n=e&&"object"==typeof e?{...e}:{};if(t.isPlainObject(n.input)){const e={...n.input};delete n.input,n.insert=t.setDefaultValues(e,n.insert||{}),n.update=t.setDefaultValues(e,n.update||{})}const r=t.setDefaultValues(t.protoColumnConfig,n);return null==r.class&&r.columnClass&&(r.class=r.columnClass),r.update&&"displayonly"===r.update.type&&!r.update.template&&r.display&&r.display.template&&(r.update.template=r.display.template),["display","insert","update"].forEach(t=>{r[t]&&"object"==typeof r[t]&&(Array.isArray(r[t].events)||(r[t].events=[]))}),r}}(window.KGrid),function(t){t.resolveHostElement=function(t){if(null==t)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof t&&t.jquery){if(!t.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return t}if("object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName)return $(t);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},t.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},t.hasActionColumn=function(t){const e=t&&t.features;return!!e&&!!(e.delete||e.update||e.create)},t.syncActionColumnColgroup=function(t,e,n){let r=t.children("colgroup.kgrid-colgroup");r.length||(r=$("<colgroup>").addClass("kgrid-colgroup").prependTo(t)),r.empty();for(let t=0;t<e;t++)r.append($("<col>"));n&&r.append($("<col>").addClass("kgrid-row-actions-col"))},t.anchorRowForm=function(t,e){if(!(t&&t.length&&e&&e.length))return t;t.attr("hidden","hidden").attr("aria-hidden","true");const n=e.children("td").first();return n.length&&t.prependTo(n),t},t.filterFormField=function(t,e){if(!t||!e)return $();const n=t.elements&&t.elements.namedItem(e);if(n)return $(n);if(t.id){const n=document.querySelector(`[form="${t.id}"][name="${e}"]`);if(n)return $(n)}return $()},t.columnClassName=function(t){if(!t)return null;const e=null!=t.class&&""!==t.class?t.class:t.columnClass;return null!=e&&""!==e?String(e):null},t.applyColumnCellMeta=function(e,n){if(!e||!e.length||!n)return e;n.name&&e.attr("data-name",n.name);const r=t.columnClassName(n);return r&&e.addClass(r),e}}(window.KGrid),function(t){t.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",t.TABLE_SHELL_TEMPLATE='\n<table class="custom-table" style="table-layout: fixed;">\n <thead class="thead-labels">\n <tr>\n <th class="align-top">\n <a class="sort" data-sortfld="" style="cursor: pointer;">\n <span class="column-label"></span>\n <i class="fas fa-sort-up sort-up" style="display: none"></i>\n <i class="fas fa-sort-down sort-down" style="display: none"></i>\n <i class="fas fa-sort sort-default"></i>\n </a>\n </th>\n </tr>\n </thead>\n <thead class="thead-filters"></thead>\n <tbody class="before-main-tbody"></tbody>\n <tbody class="main-tbody"></tbody>\n <tbody class="after-main-tbody"></tbody>\n <tbody class="no-data-tbody">\n <tr><td>{{EMPTY_ROW_MESSAGE}}</td></tr>\n </tbody>\n <tfoot class="paging-footer">\n <tr>\n <td>\n <div class="btn-group pages" data-pagesize="{{PAGES_DATA_PAGESIZE}}">\n <button type="button" name="first" class="btn btn-sm btn-outline-secondary">&lt;&lt;</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary">&lt;</button>\n <button type="button" name="page" class="btn btn-sm btn-outline-secondary">1</button>\n <button type="button" name="next" class="btn btn-sm btn-outline-secondary">&gt;</button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">&gt;&gt;</button>\n </div>\n <select class="pagesize">\n{{PAGE_SIZE_OPTIONS}}\n </select>\n {{PAGING_FOOTER_LABEL}} <span class="totalrecscount"></span>\n </td>\n </tr>\n </tfoot>\n</table>'.trim(),t._escapeTableShellText=function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t._renderPageSizeOptions=function(t,e){return t.map(t=>{const n=String(t);return` <option value="${n}"${n===String(e)?" selected":""}>${n}</option>`}).join("\n")},t.renderTableShellHtml=function(e,n){const r=Array.isArray(e.pagingPageSizes)?e.pagingPageSizes:[10,25,50,75],o=null!=e.pagingDefaultSize?e.pagingDefaultSize:r[0],a=t._escapeTableShellText(e.emptyRowMessage||t.DEFAULT_EMPTY_ROW_MESSAGE),l=t._escapeTableShellText(e.pagingFooterLabel||"records per page. Total");return(n||t.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,a).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(o)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,t._renderPageSizeOptions(r,o)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,l)},t.createTableShell=function(e){const n=t.renderTableShellHtml(e),r=$.parseHTML(n,document,!0),o=$(r).filter("table").first();if(!o.length)throw new Error("KGrid TABLE_SHELL_TEMPLATE must contain a root <table> element");return e.tableAttrs&&t.isPlainObject(e.tableAttrs)&&(Object.keys(e.tableAttrs).forEach(t=>{"class"!==t&&o.attr(t,e.tableAttrs[t])}),"string"==typeof e.tableAttrs.class&&e.tableAttrs.class&&o.addClass(e.tableAttrs.class)),o},t.mountTableShell=function(e,n){const r=e.find("table.custom-table, table").first();if(r.length)return r;const o=t.getTableInteractionHost(e);o.hasClass("custom-table-shell")||o.addClass("custom-table-shell");const a=t.createTableShell(n);return o.append(a),a}}(window.KGrid),function(t){t._fieldTypes=Object.create(null),t._configuredCustomInputTypeNames=[],t.registerFieldType=function(e,n,r){if(!e||"string"!=typeof e)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+e+"): plugin.create is required");if(t._fieldTypes[e]&&(!r||!r.overwrite))throw new Error("Field type already registered: "+e);return t._fieldTypes[e]=Object.assign({name:e},n),t},t.unregisterFieldType=function(e){return e&&t._fieldTypes[e]&&delete t._fieldTypes[e],t},t.getFieldType=function(e){return e&&t._fieldTypes[e]||null},t.listFieldTypes=function(){return Object.keys(t._fieldTypes)},t.createFieldInput=function({mode:e,col:n,config:r}){const o=r.type??"text",a=t.getFieldType(o);if(!a)return null;"function"==typeof a.validate&&a.validate(r,e,n);const l=a.create({mode:e,col:n,config:r});if(!l||!l.$input||!l.$input.length)throw new Error('Field type "'+o+'" create() must return { $input: jQuery }');return l.$input.attr("data-type",o),l},t.mountField=function(e){const n=e.config?.type??e.type,r=t.getFieldType(n);r&&"function"==typeof r.mount&&r.mount(e)},t.resolveFilterEvents=function({plugin:t,$input:e,createResult:n}){let r;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?r=n.filterEvents:t&&Object.prototype.hasOwnProperty.call(t,"filterEvents")&&(r=t.filterEvents),!1===r||null===r?null:"string"==typeof r&&r.trim()?r.trim():e.is("select")?"change":"input"},t.normalizeFilterDebounceMs=function(t,e){if(!1===t)return 0;if(void 0===t)return e;if(null===t)return e;const n=Number(t);return!Number.isFinite(n)||n<0?0:n},t.resolveFilterDebounceMs=function({filterConfig:e,plugin:n}){return e&&Object.prototype.hasOwnProperty.call(e,"debounceMs")&&null!==e.debounceMs?t.normalizeFilterDebounceMs(e.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?t.normalizeFilterDebounceMs(n.filterDebounceMs,0):t.normalizeFilterDebounceMs(t._config.filterDebounceMs,0)},t.shouldDebounceFilterSubmit=function(t,e){return!(!e||e<=0)&&!!t},t.bindFieldFilterSubmit=function(e,n,r){const o=t.getFieldType(e);o&&"function"==typeof o.bindFilterSubmit&&o.bindFilterSubmit(n,r)},t.bindFilterInputEvents=function({type:e,$input:n,onSubmit:r,createResult:o,filterConfig:a}){const l=e?t.getFieldType(e):null,i=t.resolveFilterEvents({plugin:l,$input:n,createResult:o}),s=t.resolveFilterDebounceMs({filterConfig:a,plugin:l}),u=t.wrapFilterSubmitHandler(n,r,i,s);i&&n.on(i,u),t.bindFieldFilterSubmit(e,n,u)},t.isPluggableFieldType=function(e){return!!t.getFieldType(e)},t.inputType=function(t,e){if("function"!=typeof t)throw new TypeError("inputType(mount, opts): mount must be a function");if(!e||"string"!=typeof e.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:e.filterEvents,filterDebounceMs:e.filterDebounceMs,validate:e.validate,create({mode:t}){const n=$(e.element);return!e.formInputClass||"insert"!==t&&"update"!==t||n.addClass(e.formInputClass),{$input:n,skipValueAttr:!!e.skipValueAttr}},mount(e){t(e.$input,e.config?.options??e.config,e)},bindFilterSubmit:e.bindFilterSubmit}},t._getCustomInputTypesConfig=function(){return t._config.customInputTypes??t._config.fieldTypes??null},t._syncCustomInputTypes=function(){const e=t._getCustomInputTypesConfig(),n=e&&"object"==typeof e?Object.keys(e).filter(t=>null!=e[t]):[];t._configuredCustomInputTypeNames.forEach(e=>{n.includes(e)||t.unregisterFieldType(e)}),n.forEach(n=>{const r=e[n];if(!r||"object"!=typeof r||"function"!=typeof r.create){if("function"==typeof r)throw new Error("customInputTypes."+n+' is a function — use a plugin, e.g. KGrid.select2(fn) or KGrid.inputType(fn, { element: "..." })');throw new TypeError("customInputTypes."+n+" must be a plugin with create()")}t.registerFieldType(n,r,{overwrite:!0})}),t._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(t){t.registerFieldType("multi_select",{create({config:t}){const e=$("<select class='form-select form-select-sm' multiple>");return Array.isArray(t.options)&&t.options.forEach(t=>{$("<option>").text(t.label).attr("value",t.value).appendTo(e)}),{$input:e,skipValueAttr:!0}}}),t.registerFieldType("date_range",{create:()=>({$input:$("<input autocomplete='off' type='date' class='form-control form-control-sm'/>")})})}(window.KGrid),function(t){t.resolveDefaultInteraction=function(t){return"edit"===t.defaultInteraction||"view"===t.defaultInteraction?t.defaultInteraction:!0===t.editmode?"edit":(t.editmode,"view")},t.getTableInteractionHost=function(t){if(t.hasClass("custom-table-shell"))return t;const e=t.find(".custom-table-shell").first();return e.length?e:t},t.applyInteraction=function(e,n,r){const o=t.getTableInteractionHost(e),a="edit"===n?"edit":"view";o.attr("data-interaction",a),r&&"object"==typeof r?(void 0!==r.create&&o.attr("data-allow-insert",r.create?"true":"false"),void 0!==r.update&&o.attr("data-allow-update",r.update?"true":"false"),void 0!==r.delete&&o.attr("data-allow-delete",r.delete?"true":"false")):"edit"===a&&o.removeAttr("data-allow-insert data-allow-update data-allow-delete")}}(window.KGrid),function(t){t.setupLabelsHeader=function(e,n){const r=e.children("tr"),o=r.children(),a=o.first().clone(!0);o.remove();return[...n.columns].forEach(e=>{if(e.hidden)return;let n=a.clone(!0);if(e.attrs&&"object"==typeof e.attrs&&Object.keys(e.attrs).forEach(t=>n.attr(t,e.attrs[t])),t.applyColumnCellMeta(n,e),!e.features?.sort){const o=n.empty().html(e.label??"");return t.applyColumnCellMeta(o,e),void r.append(o)}if(!e.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(e,null,2));n.find("span.column-label").text(e.label??""),n.children("a").attr("data-sortfld",e.name),n.appendTo(r)}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(r),r}}(window.KGrid),function(t){const e="kgridFilterDebounceTimer";t.cancelFilterSubmit=function(t){const n=t.data(e);n&&(clearTimeout(n),t.removeData(e))},t.cancelFilterDebounces=function(e){const n=$(e).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){t.cancelFilterSubmit($(this))})},t.flushFilterSubmit=function(t){const n=t.data(e);if(!n)return;clearTimeout(n),t.removeData(e);const r=t[0]&&t[0].form;r&&$(r).trigger("submit")},t.wrapFilterSubmitHandler=function(n,r,o,a){if(!t.shouldDebounceFilterSubmit(o,a))return r;const l=a;return function(){t.cancelFilterSubmit(n);const o=setTimeout(function(){n.removeData(e),r.call(this)}.bind(this),l);n.data(e,o)}},t.filterDefaultValue=function(t){return null!=t&&"object"==typeof t&&null!=t.value?t.value:t},t.columnFilterPersisted=function(t){const e=t&&t.filter?t.filter:{};return!(!t||!t.hidden&&"hidden"!==e.type&&!e.persist)},t.ensureFilterField=function(t,e,n,r){if(!t||!e||null==n||""===n)return null;let o=t.elements&&t.elements.namedItem(e);return o&&null!=o.length&&!o.tagName&&(o=o[0]),o&&o.tagName||(o=document.createElement("input"),o.type="hidden",o.name=e,t.appendChild(o)),o.setAttribute("data-operator",r||"="),o.value=String(n),o.defaultValue=String(n),o},t.applyColumnDefaultFilters=function(e,n){e&&n&&n.forEach(function(n){if(!n.name||n.features&&!1===n.features.filter)return;const r=n.filter;if(!r||null==r.default||""===r.default)return;const o=t.filterDefaultValue(r.default);if(null==o||""===o)return;const a=r.operator||(t.columnFilterPersisted(n)?"=":"~=~"),l=t.filterFormField(e,n.name);!n.hidden&&"hidden"!==r.type&&l.length?l.val()||(l.val(String(o)),l.attr("data-operator",a)):t.ensureFilterField(e,n.name,o,a)})},t.setupDefaultFilters=function(e,n,r){const o=$(e)[0];if(!(o&&n&&n.features&&n.features.filtering))return;const a=n.columns||[];if(t.applyColumnDefaultFilters(o,a),a.some(t.columnFilterPersisted)){let e=!1;$(o).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!e){n.preventDefault(),t.cancelFilterDebounces(o),e=!0;try{o.reset(),t.applyColumnDefaultFilters(o,a),r&&r.filtering&&"function"==typeof r.filtering.handleSubmit?r.filtering.handleSubmit(o):$(o).trigger("submit")}finally{e=!1}}})}if(!r||!r.filtering)return;const l=a.filter(function(e){return e.name&&e.filter&&null!=e.filter.default&&""!==e.filter.default&&t.columnFilterPersisted(e)});if(!l.length)return;const i=String(r.url&&r.url.parameters&&r.url.parameters.filter||"");l.some(function(t){return-1===i.indexOf(t.name+"=")})&&r.filtering.handleSubmit(o)},t.setupFilterHeader=function(e,n){if(!n.features||!n.features.filtering)return null;const r=e.find(".thead-filters");r.empty();const o=[...n.columns],a=$("<tr>");a.appendTo(r);const l="filter_form_"+t.uuid(),i=$("<form>").attr("id",l).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(e);return o.forEach(e=>{const n=e.filter||{};if(e.hidden||"hidden"===n.type){if(e.features&&!1===e.features.filter)return;if(!e.name)return;const r=t.filterDefaultValue(n.default);return void(null!=r&&""!==r?t.ensureFilterField(i[0],e.name,r,n.operator||"="):t.columnFilterPersisted(e)&&t.ensureFilterField(i[0],e.name,"",n.operator||"="))}let r,o=$("<th>").appendTo(a).attr("data-label",e.label);if(t.applyColumnCellMeta(o,e),!1===e.features.filter)return;if(!e.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(e,null,2));let s=null;const u=t.createFieldInput({mode:"filter",col:e,config:n});if(u)s=u,r=u.$input,r.appendTo(o),t.mountField({mode:"filter",$input:r,col:e,config:n});else if("select"===n.type){if(!n.options)throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));if(r=$("<select>").addClass("form-select form-select-sm"),!Array.isArray(n.options))throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));n.options.forEach(t=>{if(!t.label||"string"!=typeof t.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(r)}),r.appendTo(o)}else{if(!t.isValidFilterType(n.type))throw new Error("Unknown filter type: "+n.type);r=$(`<input autocomplete='off' type='${n.type}' class='form-control form-control-sm'/>`),r.appendTo(o)}r.attr("data-operator",n.operator),r.attr("form",l),r.attr("name",e.name);const c=t.filterDefaultValue(n.default);null==c||""===c||r.val()||(r.val(String(c)),r.attr("data-default",String(c)),r[0]&&(r[0].defaultValue=String(c)));t.bindFilterInputEvents({type:n.type,$input:r,onSubmit:function(){const t=this.form;t&&$(t).trigger("submit")},createResult:s,filterConfig:n})}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(a),i},t.FilterForm=function(e){this.form=$(e)[0],this.filter=(e,n,r="~=~")=>{if(!this.form)return this;let o=t.filterFormField(this.form,e);if(o.length||(t.ensureFilterField(this.form,e,n,r),o=t.filterFormField(this.form,e)),!o.length)return this;t.flushFilterSubmit(o),o.val(n);const a=o.attr("data-operator");return o.attr("data-operator",r),$(this.form).trigger("submit"),o.attr("data-operator",a),this},this.ensure=(e,n,r="=")=>(t.ensureFilterField(this.form,e,n,r),this),this.reset=()=>(this.form&&(t.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(t){t.setupCell=function(e,n){const r=n?n.attr("id"):null,o={...e},a=$("<td>").attr("data-label",e.label);t.applyColumnCellMeta(a,e);const l=o.attrs&&"object"==typeof o.attrs?o.attrs:{};Object.keys(l).forEach(t=>a.attr(t,l[t]));let i=$("<div>").addClass("cell-content");if(i.html(o.display.template??`{{${o.name}}}`),i.appendTo(a),null==n||!e.features.update)return i.clone(!0).removeClass("cell-content").addClass("cell-input").appendTo(a),a;if(!o.name)throw new Error("Column must have a name when column.features.update is true: \n"+JSON.stringify(e,null,2));const s=o.update,u=s.type??"text";let c,f=!1;const d=t.createFieldInput({mode:"update",col:e,config:s});if(d)c=d.$input,f=!!d.skipValueAttr;else{switch(u){case"textarea":c=$(`<textarea class='form-input form-control form-control-sm'>{{${s.value??o.name}}}</textarea>`),f=!0;break;case"select":if(c=$("<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(e,null,2));s.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(c)}),f=!0;break;case"hidden":c=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const t=s.template||o.display.template||`{{${o.name}}}`;return $("<div>").addClass("cell-input").append(t).appendTo(a),a}default:if(!t.isValidInputType(u))throw new Error("Invalid update updateConfig type: "+JSON.stringify(s,null,2));c=$(`<input autocomplete='off' type='${u}' class='form-input form-control form-control-sm'/>`)}c.attr("data-type",u)}if(s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(t=>c.attr(t,s.attrs[t])),c.attr("form",r),c.attr("name",o.name),!f&&"textarea"!==u){const t=s.value??`{{${o.name}}}`;null!=t&&"object"!=typeof t&&c.attr("value",t)}return o.hidden?(c.attr("type","hidden").appendTo(n),a):(s.disabled&&c.attr("disabled",!0),s.readonly&&c.attr("readonly",!0),s.required&&c.attr("required",!0),s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(t=>c.attr(t,s.attrs[t])),s.disabled||s.readonly||c.attr("onchange","$(this).parents('tr').addClass('editing')"),$("<div>").addClass("cell-input").append(c).appendTo(a),a)}}(window.KGrid),function(t){t.setupNoDataTbody=function(t,e,n){const r=t.find("td").attr("colspan",n);return e.noDataTemplate&&r.html(e.noDataTemplate),r},t.setupDataBody=function(e,n,r,o,a,l){const i=[...n.columns],s=$("<tr>").appendTo(e);if(n.dataRowAttrs&&"object"!=typeof n.dataRowAttrs)throw new Error("options.dataRowAttrs must be an object");const u={...n.dataRowAttrs??{}};Object.keys(u).forEach(t=>s.attr(t,u[t])),e.data("emptyview",l),n?.features?.sorting&&e.data("sort",r),a&&e.data("paging",a.find(".pages")).data("pagesizeinp",a.find(".pagesize")).data("totalrecscount",a.find(".totalrecscount")),o&&e.data("filter",o),n.type&&e.data("type",n.type);const c="data_row_form_"+t.uuid()+"_{{this.id}}",f=n.features.update?$("<form class='edit-form table-row-form'>").attr("id",c):null;if(i.forEach(e=>{const n=t.setupCell(e,f);e.hidden||n.appendTo(s)}),t.hasActionColumn(n)){const t=$("<td>").addClass("kgrid-row-actions").appendTo(s);if(n.features.delete&&$("<div>").addClass("btn-group delete-item-grp").appendTo(t).append($("<button>").addClass("btn btn-sm btn-danger delete-item").attr("type","button").attr("title","Delete item").append("<i class='fas fa-trash'></i>")),n.features.update){const e=$("<div>").addClass("btn-group edit-item-grp").appendTo(t);$("<button>").addClass("btn btn-sm btn-success save-item").attr("type","submit").attr("name","save").attr("title","Save item").attr("form",c).html("<i class='fas fa-save'></i>").appendTo(e),$("<button>").addClass("btn btn-sm btn-secondary cancel-edit").attr("type","button").attr("name","cancel").attr("title","Cancel edit").attr("form",c).attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()").html("<i class='fas fa-undo'></i>").appendTo(e)}}return f&&t.anchorRowForm(f,s),e},t.setupPagingFooter=function(e,n,r){return t.log("setupPagingFooter",e,n,r),n.pagingFooterAttrs&&t.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(t=>e.attr(t,n.pagingFooterAttrs[t])),t.log("noVisibleCols",r),e.find("td").attr("colspan",r),e}}(window.KGrid),function(t){t.setupNewRecordForm=function(e,n,r){if(!n.insertFormRow||!t.isPlainObject(n.insertFormRow))return e.find(".before-main-tbody").remove(),void e.find(".after-main-tbody").remove();const o=[...n.columns],a=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(e.find(".after-main-tbody").remove(),a.appendTo(e.find(".before-main-tbody"))):(e.find(".before-main-tbody").remove(),a.appendTo(e.find(".after-main-tbody")));const l="new_record_row_form_"+t.uuid(),i=$("<form class='table-row-form'>").attr("id",l).off("submit").on("submit",e=>{e.preventDefault();const a=t.serializeForm(e.target,o);Object.keys(a).forEach(t=>{o.find(e=>e.name===t)?.insert?.dontsave&&delete a[t]}),r.instance.newItem(a).then(()=>{e.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(a)}).catch(t.onError)});o.forEach(e=>{if(e.hidden){if(n.features?.create&&e.features?.create){const t=$("<input type='hidden'>").attr("name",e.name).attr("form",l).appendTo(i);e.insert.default&&t.val(e.insert.default)}return}if(!e.features.create){const n=$("<td>").appendTo(a).attr("data-label",e.label);return void t.applyColumnCellMeta(n,e)}const r=e.insert;if(!r||!t.isPlainObject(r))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(e,null,2));if(!r.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(e,null,2));let o;const s=r.type??"text",u=t.createFieldInput({mode:"insert",col:e,config:r});if(u)o=u.$input;else switch(s){case"textarea":o=$("<textarea class='form-input form-control form-control-sm'>");break;case"select":if(o=$("<select class='form-input form-control form-control-sm'/>"),!r.options||!Array.isArray(r.options))throw new Error("Column must have an insert.options array when column.features.insert is true: \n"+JSON.stringify(e,null,2));r.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(o)});break;case"hidden":o=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;default:if(!t.isValidInputType(s))throw new Error("Invalid type: "+JSON.stringify(r,null,2));o=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`),o.attr("data-type",s)}if(null!=r.default&&""!==r.default&&!o.val()){const t="object"==typeof r.default&&null!=r.default.value?r.default.value:r.default;String(t).trim()&&o.val(t).trigger("change")}if(r.attrs&&"object"==typeof r.attrs&&Object.keys(r.attrs).forEach(t=>o.attr(t,r.attrs[t])),o.attr("form",l).attr("name",e.name),r.disabled&&o.attr("disabled",!0),r.readonly&&o.attr("readonly",!0),r.required&&o.attr("required",!0),r.attrs&&"object"==typeof r.attrs&&Object.keys(r.attrs).forEach(t=>o.attr(t,r.attrs[t])),"hidden"!==r.type){const n=$("<td>").append(o).appendTo(a).attr("data-label",e.label);t.applyColumnCellMeta(n,e)}t.mountField({mode:"insert",$input:o,col:e,config:r,formEl:i[0],rowEl:a[0]}),r.events&&Array.isArray(r.events)&&r.events.forEach(t=>{o.off(t.event).on(t.event,function(e,...n){"function"==typeof t.callback&&t.callback(e,i[0],a[0],...n)})})}),t.anchorRowForm(i,a);const s=$("<td>").addClass("kgrid-row-actions").appendTo(a).attr("data-label","action"),u=$("<div>").addClass("btn-group").appendTo(s);return $("<button>").addClass("btn btn-sm btn-primary new-item-btn").html("<i class='fas fa-plus-square'></i>").attr("form",l).attr("type","submit").appendTo(u),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(i[0],a[0]),a}}(window.KGrid),function(t){t.setupEvents=function(e,n,r,o){const a=e.views[0];r.columns.forEach(n=>{n.display.events.forEach(t=>{if(!t.selector||!t.event||!t.callback)throw new Error("Invalid event: "+JSON.stringify(t,null,2));a.el.find(t.selector).off(t.event).on(t.event,n=>{if("function"!=typeof t.callback)throw new Error("Event callback must be a function: "+JSON.stringify(t,null,2));t.callback(n,e,a)})}),r.features.update&&n.update.events.forEach(r=>{if(!r.event||!r.callback)throw new Error("Invalid event: "+JSON.stringify(r,null,2));a.el.find("[name='"+n.name+"']").off(r.event).on(r.event,function(n,...o){if(t.log("event",r,n,this,o),"function"!=typeof r.callback)throw new Error("Event callback must be a function: "+JSON.stringify(r,null,2));r.callback(n,e,a,...o)})})}),r.features.update&&(a.el.find("[data-type]").each((n,r)=>{const l=r.getAttribute("data-type");if(!t.isPluggableFieldType(l))return;const i=o.get(r.name);i?.update&&t.mountField({mode:"update",$input:$(r),col:i,config:i.update,item:e,view:a})}),a.el.find("select[data-type='select']").each((t,n)=>{const r=o.get(n.name);if(!r)return;const a=e.attributes[r.name];null!=a&&""!==a&&$(n).val("boolean"==typeof a?String(a):a)}),a.el.find("form.edit-form").off("submit").on("submit",e=>{const n=e.target;e.preventDefault();const o=$(n).parents("[data-type=item]").data().instance,a=t.serializeForm(n);Object.keys(a).forEach(t=>{r.columns.find(e=>e.name===t)?.update?.dontsave&&delete a[t]}),o.update(a).catch(t.onError)})),r.features.delete&&a.el.find("button.delete-item").off("click").on("click",n=>{n.preventDefault(),a.el.addClass("confirm-delete");const o=()=>a.el.removeClass("confirm-delete");t.runDeleteConfirm({item:e,view:a,options:r},()=>{e.delete().catch(t.onError).finally(o)},o)}),"function"==typeof r.onRowFields&&r.onRowFields(e,a,n)}}(window.KGrid),function(t){t.init=async function(e,n){const r=t.resolveHostElement(e),o={...t.protoOptions,...n},a=t.mountTableShell(r,o);t.log("table config options",o);const l=t.resolveDefaultInteraction(o);t.applyInteraction(r,l);const i={$host:r,instance:null,filterForm:null,find:t=>r.find(t),setInteraction:(e,n)=>(t.applyInteraction(r,e,n),i),getInteraction:()=>"edit"===t.getTableInteractionHost(r).attr("data-interaction")?"edit":"view",setEditMode(t){if("boolean"!=typeof t)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return i.setInteraction(t?"edit":"view")},toggleEditMode:t=>(null!=t&&"object"==typeof t&&"function"==typeof t.preventDefault&&(t=void 0),"boolean"==typeof t?i.setInteraction(t?"edit":"view"):i.setInteraction("edit"===i.getInteraction()?"view":"edit"))};o.columns=o.columns.map(e=>t.normalizeColumnConfig(e));const s=o.handlers??{};delete o.handlers,o.columns.forEach(t=>{["insert","update","display"].forEach(e=>{const n=t[e].events;if(!n||!Array.isArray(n))throw new Error("Column "+t.name+" events are not an array");n.forEach(e=>{if("string"==typeof e.callback){const n=s[e.callback]||o.functions&&o.functions[e.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+e.callback+" not found for column "+t.name+" or is not a function");e.callback=n}else if("function"!=typeof e.callback)throw new Error("Event callback must be a function for column "+t.name)})});const e=t.display;e&&e.events&&Array.isArray(e.events)&&e.events.forEach(t=>{if("string"==typeof t.callback){const e=s[t.callback]||o.functions&&o.functions[t.callback];e&&"function"==typeof e&&(t.callback=e)}})});const u=new Map;o.columns.forEach(t=>{u.set(t.name,t)});const c=t.setupLabelsHeader(a.find(".thead-labels"),o),f=t.hasActionColumn(o),d=c.find("th").length,p=d-(f?1:0);t.syncActionColumnColgroup(a,p,f);const m=o.filterForm??t.setupFilterHeader(a,o);let y;o.features&&o.features.paging?y=t.setupPagingFooter(a.find(".paging-footer"),o,d):(y=null,a.find(".paging-footer").remove());const b=t.setupNoDataTbody(a.find(".no-data-tbody"),o,d);o.features&&o.features.create&&t.setupNewRecordForm(a,o,i),i.filterForm=new t.FilterForm(m);const g=t.setupDataBody(a.find(".main-tbody"),o,c,m,y,b),h={dontload:!0,setAttrAsId:o.setAttrAsId??!1,itemListeners:{afterrender:e=>t.setupEvents(e,i.find("table"),o,u)}},w=t.getKViews(o.kviews);if(!w)throw new Error(t.KVIEWS_MISSING_MSG);if(i.instance=await w.createCollectionInstance(g,h),o.url){i.instance.setUrl(o.url),o.deleteUrl&&(t.log("set deleteUrl",o.deleteUrl),i.instance.setUrl(o.deleteUrl,"delete")),o.updateUrl&&(t.log("set updateUrl",o.updateUrl),i.instance.setUrl(o.updateUrl,"update")),o.insertUrl&&i.instance.setUrl(o.insertUrl,"insert");try{await i.instance.loadFromRemote()}catch(e){t.onError(e)}}else{if(!o.data||o.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const t=o.data.map(t=>({attributes:t}));i.instance.loadFromData(t)}}return t.setupDefaultFilters(m,o,i.instance),i}}(window.KGrid);
1
+ /*! @logimaxx/kgrid | (c) Logimaxx System SRL — proprietary | https://logimaxx.ro | built 2026-08-27T12:47:37.279Z */
2
+ !function(t){const e={log:function(){},onError:function(t){console.error(t)},confirm:function(t,e,n){"undefined"!=typeof window&&window.confirm(t)?e():n&&n()},deleteConfirm:null,serializeForm:function(t,e){const n=new FormData(t),r={};for(const[t,e]of n.entries())Object.prototype.hasOwnProperty.call(r,t)?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(e)):r[t]=e;return r},customInputTypes:null,fieldTypes:null,kviews:null,filterDebounceMs:300};t._config=Object.assign({},e),t.configure=function(e){return e&&"object"==typeof e&&Object.assign(t._config,e),"function"==typeof t._syncCustomInputTypes&&t._syncCustomInputTypes(),t},t.log=function(){t._config.log.apply(null,arguments)},t.onError=function(e){return t._config.onError(e)},t.confirm=function(e,n,r){return t._config.confirm(e,n,r)},t.DEFAULT_DELETE_CONFIRM_MESSAGE="Delete this record?",t._defaultDeleteConfirm=function(e,n,r){t.confirm(t.DEFAULT_DELETE_CONFIRM_MESSAGE,n,r)},t.runDeleteConfirm=function(e,n,r){const o=e.options&&"function"==typeof e.options.deleteConfirm?e.options.deleteConfirm:null,a="function"==typeof t._config.deleteConfirm?t._config.deleteConfirm:null;return(o||a||t._defaultDeleteConfirm)(e,n,r)},t.serializeForm=function(e,n){return t._config.serializeForm(e,n)},t.getKViews=function(e){const n=[e,t._config.kviews];for(let t=0;t<n.length;t++){const e=n[t];if(e&&"function"==typeof e.createCollectionInstance)return e}const r=("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}).KViews;return r&&"function"==typeof r.createCollectionInstance?r:null},t.KVIEWS_MISSING_MSG="KGrid requires KViews: install peer @logimaxx/kviews, load it before kgrid.js (window.KViews), or call KGrid.configure({ kviews: KViews }). You can also pass kviews in table options: KGrid.init(host, { kviews, ... })."}(window.KGrid=window.KGrid||{}),function(t){t.protoOptions={url:null,type:null,filter:null,features:{filtering:!1,sorting:!1,paging:!1,create:!1,update:!1,delete:!1,clone:!1},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"},t.protoColumnConfig={label:null,name:null,hidden:!1,class:null,columnClass:null,attrs:{},features:{create:!1,update:!1,filter:!1,sort:!1},display:{template:null,events:[]},input:null,insert:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,events:[]},update:{type:"text",default:null,value:null,placeholder:null,disabled:!1,required:!1,options:null,template:null,events:[]},filter:{type:"text",operator:"~=~",default:null,placeholder:"",options:null,persist:!1,debounceMs:null}},t.VALID_NATIVE_INPUT_TYPES=["displayonly","text","textarea","number","date","datetime","time","checkbox","radio","file","password","email","url","search","tel","select","hidden"],t.VALID_INPUT_TYPES=t.VALID_NATIVE_INPUT_TYPES.slice(),t.VALID_NATIVE_FILTER_TYPES=t.VALID_NATIVE_INPUT_TYPES.filter(t=>"displayonly"!==t),t.VALID_FILTER_TYPES=t.VALID_NATIVE_FILTER_TYPES.concat(["multi_select","date_range"]),t.isValidInputType=function(e){return t.VALID_NATIVE_INPUT_TYPES.includes(e)||t.isPluggableFieldType(e)},t.isValidFilterType=function(e){return"displayonly"!==e&&(t.VALID_NATIVE_FILTER_TYPES.includes(e)||t.isPluggableFieldType(e))}}(window.KGrid=window.KGrid||{}),function(t){t.isPlainObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.setDefaultValues=function(e,n){const r={...e||{}};return Object.keys(n||{}).forEach(e=>{t.isPlainObject(n[e])&&t.isPlainObject(r[e])?r[e]=t.setDefaultValues(r[e],n[e]):t.isPlainObject(n[e])&&null==r[e]?r[e]=t.setDefaultValues({},n[e]):r[e]=n[e]}),r},t.normalizeColumnConfig=function(e){let n=e&&"object"==typeof e?{...e}:{};if(t.isPlainObject(n.input)){const e={...n.input};delete n.input,n.insert=t.setDefaultValues(e,n.insert||{}),n.update=t.setDefaultValues(e,n.update||{})}const r=t.setDefaultValues(t.protoColumnConfig,n);return null==r.class&&r.columnClass&&(r.class=r.columnClass),r.update&&"displayonly"===r.update.type&&!r.update.template&&r.display&&r.display.template&&(r.update.template=r.display.template),["display","insert","update"].forEach(t=>{r[t]&&"object"==typeof r[t]&&(Array.isArray(r[t].events)||(r[t].events=[]))}),r}}(window.KGrid),function(t){t.resolveHostElement=function(t){if(null==t)throw new TypeError("KGrid.init(host, opts): host is required");if("object"==typeof t&&t.jquery){if(!t.length)throw new Error("KGrid.init(host, opts): empty jQuery selection");return t}if("object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName)return $(t);throw new TypeError("KGrid.init(host, opts): host must be a DOM Element or jQuery object")},t.uuid=function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},t.hasActionColumn=function(t){const e=t&&t.features;return!!e&&!!(e.delete||e.update||e.create||e.clone)},t.syncActionColumnColgroup=function(t,e,n){let r=t.children("colgroup.kgrid-colgroup");r.length||(r=$("<colgroup>").addClass("kgrid-colgroup").prependTo(t)),r.empty();for(let t=0;t<e;t++)r.append($("<col>"));n&&r.append($("<col>").addClass("kgrid-row-actions-col"))},t.anchorRowForm=function(t,e){if(!(t&&t.length&&e&&e.length))return t;t.attr("hidden","hidden").attr("aria-hidden","true");const n=e.children("td").first();return n.length&&t.prependTo(n),t},t.filterFormField=function(t,e){if(!t||!e)return $();const n=t.elements&&t.elements.namedItem(e);if(n)return $(n);if(t.id){const n=document.querySelector(`[form="${t.id}"][name="${e}"]`);if(n)return $(n)}return $()},t.columnClassName=function(t){if(!t)return null;const e=null!=t.class&&""!==t.class?t.class:t.columnClass;return null!=e&&""!==e?String(e):null},t.applyColumnCellMeta=function(e,n){if(!e||!e.length||!n)return e;n.name&&e.attr("data-name",n.name);const r=t.columnClassName(n);return r&&e.addClass(r),e}}(window.KGrid),function(t){t.DEFAULT_EMPTY_ROW_MESSAGE="No records match your search.",t.TABLE_SHELL_TEMPLATE='\n<table class="custom-table" style="table-layout: fixed;">\n <thead class="thead-labels">\n <tr>\n <th class="align-top">\n <a class="sort" data-sortfld="" style="cursor: pointer;">\n <span class="column-label"></span>\n <i class="fas fa-sort-up sort-up" style="display: none"></i>\n <i class="fas fa-sort-down sort-down" style="display: none"></i>\n <i class="fas fa-sort sort-default"></i>\n </a>\n </th>\n </tr>\n </thead>\n <thead class="thead-filters"></thead>\n <tbody class="before-main-tbody"></tbody>\n <tbody class="main-tbody"></tbody>\n <tbody class="after-main-tbody"></tbody>\n <tbody class="no-data-tbody">\n <tr><td>{{EMPTY_ROW_MESSAGE}}</td></tr>\n </tbody>\n <tfoot class="paging-footer">\n <tr>\n <td>\n <div class="btn-group pages" data-pagesize="{{PAGES_DATA_PAGESIZE}}">\n <button type="button" name="first" class="btn btn-sm btn-outline-secondary">&lt;&lt;</button>\n <button type="button" name="prev" class="btn btn-sm btn-outline-secondary">&lt;</button>\n <button type="button" name="page" class="btn btn-sm btn-outline-secondary">1</button>\n <button type="button" name="next" class="btn btn-sm btn-outline-secondary">&gt;</button>\n <button type="button" name="last" class="btn btn-sm btn-outline-secondary">&gt;&gt;</button>\n </div>\n <select class="pagesize">\n{{PAGE_SIZE_OPTIONS}}\n </select>\n {{PAGING_FOOTER_LABEL}} <span class="totalrecscount"></span>\n </td>\n </tr>\n </tfoot>\n</table>'.trim(),t._escapeTableShellText=function(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},t._renderPageSizeOptions=function(t,e){return t.map(t=>{const n=String(t);return` <option value="${n}"${n===String(e)?" selected":""}>${n}</option>`}).join("\n")},t.renderTableShellHtml=function(e,n){const r=Array.isArray(e.pagingPageSizes)?e.pagingPageSizes:[10,25,50,75],o=null!=e.pagingDefaultSize?e.pagingDefaultSize:r[0],a=t._escapeTableShellText(e.emptyRowMessage||t.DEFAULT_EMPTY_ROW_MESSAGE),l=t._escapeTableShellText(e.pagingFooterLabel||"records per page. Total");return(n||t.TABLE_SHELL_TEMPLATE).replace(/\{\{EMPTY_ROW_MESSAGE\}\}/g,a).replace(/\{\{PAGES_DATA_PAGESIZE\}\}/g,String(o)).replace(/\{\{PAGE_SIZE_OPTIONS\}\}/g,t._renderPageSizeOptions(r,o)).replace(/\{\{PAGING_FOOTER_LABEL\}\}/g,l)},t.createTableShell=function(e){const n=t.renderTableShellHtml(e),r=$.parseHTML(n,document,!0),o=$(r).filter("table").first();if(!o.length)throw new Error("KGrid TABLE_SHELL_TEMPLATE must contain a root <table> element");return e.tableAttrs&&t.isPlainObject(e.tableAttrs)&&(Object.keys(e.tableAttrs).forEach(t=>{"class"!==t&&o.attr(t,e.tableAttrs[t])}),"string"==typeof e.tableAttrs.class&&e.tableAttrs.class&&o.addClass(e.tableAttrs.class)),o},t.mountTableShell=function(e,n){const r=e.find("table.custom-table, table").first();if(r.length)return r;const o=t.getTableInteractionHost(e);o.hasClass("custom-table-shell")||o.addClass("custom-table-shell");const a=t.createTableShell(n);return o.append(a),a}}(window.KGrid),function(t){t._fieldTypes=Object.create(null),t._configuredCustomInputTypeNames=[],t.registerFieldType=function(e,n,r){if(!e||"string"!=typeof e)throw new TypeError("registerFieldType(name, plugin): name must be a string");if(!n||"function"!=typeof n.create)throw new TypeError("registerFieldType("+e+"): plugin.create is required");if(t._fieldTypes[e]&&(!r||!r.overwrite))throw new Error("Field type already registered: "+e);return t._fieldTypes[e]=Object.assign({name:e},n),t},t.unregisterFieldType=function(e){return e&&t._fieldTypes[e]&&delete t._fieldTypes[e],t},t.getFieldType=function(e){return e&&t._fieldTypes[e]||null},t.listFieldTypes=function(){return Object.keys(t._fieldTypes)},t.createFieldInput=function({mode:e,col:n,config:r}){const o=r.type??"text",a=t.getFieldType(o);if(!a)return null;"function"==typeof a.validate&&a.validate(r,e,n);const l=a.create({mode:e,col:n,config:r});if(!l||!l.$input||!l.$input.length)throw new Error('Field type "'+o+'" create() must return { $input: jQuery }');return l.$input.attr("data-type",o),l},t.mountField=function(e){const n=e.config?.type??e.type,r=t.getFieldType(n);r&&"function"==typeof r.mount&&r.mount(e)},t.resolveFilterEvents=function({plugin:t,$input:e,createResult:n}){let r;return n&&Object.prototype.hasOwnProperty.call(n,"filterEvents")?r=n.filterEvents:t&&Object.prototype.hasOwnProperty.call(t,"filterEvents")&&(r=t.filterEvents),!1===r||null===r?null:"string"==typeof r&&r.trim()?r.trim():e.is("select")?"change":"input"},t.normalizeFilterDebounceMs=function(t,e){if(!1===t)return 0;if(void 0===t)return e;if(null===t)return e;const n=Number(t);return!Number.isFinite(n)||n<0?0:n},t.resolveFilterDebounceMs=function({filterConfig:e,plugin:n}){return e&&Object.prototype.hasOwnProperty.call(e,"debounceMs")&&null!==e.debounceMs?t.normalizeFilterDebounceMs(e.debounceMs,0):n&&Object.prototype.hasOwnProperty.call(n,"filterDebounceMs")&&null!==n.filterDebounceMs?t.normalizeFilterDebounceMs(n.filterDebounceMs,0):t.normalizeFilterDebounceMs(t._config.filterDebounceMs,0)},t.shouldDebounceFilterSubmit=function(t,e){return!(!e||e<=0)&&!!t},t.bindFieldFilterSubmit=function(e,n,r){const o=t.getFieldType(e);o&&"function"==typeof o.bindFilterSubmit&&o.bindFilterSubmit(n,r)},t.bindFilterInputEvents=function({type:e,$input:n,onSubmit:r,createResult:o,filterConfig:a}){const l=e?t.getFieldType(e):null,i=t.resolveFilterEvents({plugin:l,$input:n,createResult:o}),s=t.resolveFilterDebounceMs({filterConfig:a,plugin:l}),u=t.wrapFilterSubmitHandler(n,r,i,s);i&&n.on(i,u),t.bindFieldFilterSubmit(e,n,u)},t.isPluggableFieldType=function(e){return!!t.getFieldType(e)},t.inputType=function(t,e){if("function"!=typeof t)throw new TypeError("inputType(mount, opts): mount must be a function");if(!e||"string"!=typeof e.element)throw new TypeError("inputType(mount, opts): opts.element is required (HTML string)");return{filterEvents:e.filterEvents,filterDebounceMs:e.filterDebounceMs,validate:e.validate,create({mode:t}){const n=$(e.element);return!e.formInputClass||"insert"!==t&&"update"!==t||n.addClass(e.formInputClass),{$input:n,skipValueAttr:!!e.skipValueAttr}},mount(e){t(e.$input,e.config?.options??e.config,e)},bindFilterSubmit:e.bindFilterSubmit}},t._getCustomInputTypesConfig=function(){return t._config.customInputTypes??t._config.fieldTypes??null},t._syncCustomInputTypes=function(){const e=t._getCustomInputTypesConfig(),n=e&&"object"==typeof e?Object.keys(e).filter(t=>null!=e[t]):[];t._configuredCustomInputTypeNames.forEach(e=>{n.includes(e)||t.unregisterFieldType(e)}),n.forEach(n=>{const r=e[n];if(!r||"object"!=typeof r||"function"!=typeof r.create){if("function"==typeof r)throw new Error("customInputTypes."+n+' is a function — use a plugin, e.g. KGrid.select2(fn) or KGrid.inputType(fn, { element: "..." })');throw new TypeError("customInputTypes."+n+" must be a plugin with create()")}t.registerFieldType(n,r,{overwrite:!0})}),t._configuredCustomInputTypeNames=n.slice()}}(window.KGrid),function(t){t.registerFieldType("multi_select",{create({config:t}){const e=$("<select class='form-select form-select-sm' multiple>");return Array.isArray(t.options)&&t.options.forEach(t=>{$("<option>").text(t.label).attr("value",t.value).appendTo(e)}),{$input:e,skipValueAttr:!0}}}),t.registerFieldType("date_range",{create:()=>({$input:$("<input autocomplete='off' type='date' class='form-control form-control-sm'/>")})})}(window.KGrid),function(t){t.resolveDefaultInteraction=function(t){return"edit"===t.defaultInteraction||"view"===t.defaultInteraction?t.defaultInteraction:!0===t.editmode?"edit":(t.editmode,"view")},t.getTableInteractionHost=function(t){if(t.hasClass("custom-table-shell"))return t;const e=t.find(".custom-table-shell").first();return e.length?e:t},t.applyInteraction=function(e,n,r){const o=t.getTableInteractionHost(e),a="edit"===n?"edit":"view";o.attr("data-interaction",a),r&&"object"==typeof r?(void 0!==r.create&&o.attr("data-allow-insert",r.create?"true":"false"),void 0!==r.update&&o.attr("data-allow-update",r.update?"true":"false"),void 0!==r.delete&&o.attr("data-allow-delete",r.delete?"true":"false"),void 0!==r.clone&&o.attr("data-allow-clone",r.clone?"true":"false")):"edit"===a&&o.removeAttr("data-allow-insert data-allow-update data-allow-delete data-allow-clone")}}(window.KGrid),function(t){t.setupLabelsHeader=function(e,n){const r=e.children("tr"),o=r.children(),a=o.first().clone(!0);o.remove();return[...n.columns].forEach(e=>{if(e.hidden)return;let n=a.clone(!0);if(e.attrs&&"object"==typeof e.attrs&&Object.keys(e.attrs).forEach(t=>n.attr(t,e.attrs[t])),t.applyColumnCellMeta(n,e),!e.features?.sort){const o=n.empty().html(e.label??"");return t.applyColumnCellMeta(o,e),void r.append(o)}if(!e.name)throw new Error("Column must have a name when column.sortable is true: \n"+JSON.stringify(e,null,2));n.find("span.column-label").text(e.label??""),n.children("a").attr("data-sortfld",e.name),n.appendTo(r)}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("aria-label","Actions").appendTo(r),r}}(window.KGrid),function(t){const e="kgridFilterDebounceTimer";t.cancelFilterSubmit=function(t){const n=t.data(e);n&&(clearTimeout(n),t.removeData(e))},t.cancelFilterDebounces=function(e){const n=$(e).attr("id");n&&$(document).find("[form='"+n+"']").each(function(){t.cancelFilterSubmit($(this))})},t.flushFilterSubmit=function(t){const n=t.data(e);if(!n)return;clearTimeout(n),t.removeData(e);const r=t[0]&&t[0].form;r&&$(r).trigger("submit")},t.wrapFilterSubmitHandler=function(n,r,o,a){if(!t.shouldDebounceFilterSubmit(o,a))return r;const l=a;return function(){t.cancelFilterSubmit(n);const o=setTimeout(function(){n.removeData(e),r.call(this)}.bind(this),l);n.data(e,o)}},t.filterDefaultValue=function(t){return null!=t&&"object"==typeof t&&null!=t.value?t.value:t},t.columnFilterPersisted=function(t){const e=t&&t.filter?t.filter:{};return!(!t||!t.hidden&&"hidden"!==e.type&&!e.persist)},t.ensureFilterField=function(t,e,n,r){if(!t||!e||null==n||""===n)return null;let o=t.elements&&t.elements.namedItem(e);return o&&null!=o.length&&!o.tagName&&(o=o[0]),o&&o.tagName||(o=document.createElement("input"),o.type="hidden",o.name=e,t.appendChild(o)),o.setAttribute("data-operator",r||"="),o.value=String(n),o.defaultValue=String(n),o},t.applyColumnDefaultFilters=function(e,n){e&&n&&n.forEach(function(n){if(!n.name||n.features&&!1===n.features.filter)return;const r=n.filter;if(!r||null==r.default||""===r.default)return;const o=t.filterDefaultValue(r.default);if(null==o||""===o)return;const a=r.operator||(t.columnFilterPersisted(n)?"=":"~=~"),l=t.filterFormField(e,n.name);!n.hidden&&"hidden"!==r.type&&l.length?l.val()||(l.val(String(o)),l.attr("data-operator",a)):t.ensureFilterField(e,n.name,o,a)})},t.setupDefaultFilters=function(e,n,r){const o=$(e)[0];if(!(o&&n&&n.features&&n.features.filtering))return;const a=n.columns||[];if(t.applyColumnDefaultFilters(o,a),a.some(t.columnFilterPersisted)){let e=!1;$(o).off("reset.kgridDefaultFilters").on("reset.kgridDefaultFilters",function(n){if(!e){n.preventDefault(),t.cancelFilterDebounces(o),e=!0;try{o.reset(),t.applyColumnDefaultFilters(o,a),r&&r.filtering&&"function"==typeof r.filtering.handleSubmit?r.filtering.handleSubmit(o):$(o).trigger("submit")}finally{e=!1}}})}if(!r||!r.filtering)return;const l=a.filter(function(e){return e.name&&e.filter&&null!=e.filter.default&&""!==e.filter.default&&t.columnFilterPersisted(e)});if(!l.length)return;const i=String(r.url&&r.url.parameters&&r.url.parameters.filter||"");l.some(function(t){return-1===i.indexOf(t.name+"=")})&&r.filtering.handleSubmit(o)},t.setupFilterHeader=function(e,n){if(!n.features||!n.features.filtering)return null;const r=e.find(".thead-filters");r.empty();const o=[...n.columns],a=$("<tr>");a.appendTo(r);const l="filter_form_"+t.uuid(),i=$("<form>").attr("id",l).attr("hidden","hidden").attr("aria-hidden","true").addClass("table-filter-form").insertBefore(e);return o.forEach(e=>{const n=e.filter||{};if(e.hidden||"hidden"===n.type){if(e.features&&!1===e.features.filter)return;if(!e.name)return;const r=t.filterDefaultValue(n.default);return void(null!=r&&""!==r?t.ensureFilterField(i[0],e.name,r,n.operator||"="):t.columnFilterPersisted(e)&&t.ensureFilterField(i[0],e.name,"",n.operator||"="))}let r,o=$("<th>").appendTo(a).attr("data-label",e.label);if(t.applyColumnCellMeta(o,e),!1===e.features.filter)return;if(!e.name)throw new Error("Column must have a name when column.features.filter is true: \n"+JSON.stringify(e,null,2));let s=null;const u=t.createFieldInput({mode:"filter",col:e,config:n});if(u)s=u,r=u.$input,r.appendTo(o),t.mountField({mode:"filter",$input:r,col:e,config:n});else if("select"===n.type){if(!n.options)throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));if(r=$("<select>").addClass("form-select form-select-sm"),!Array.isArray(n.options))throw new Error("Column must have a filter.options array when column.filter.type is select: \n"+JSON.stringify(e,null,2));n.options.forEach(t=>{if(!t.label||"string"!=typeof t.value)throw new Error("Column must have an filter.options object with label and value when column.filter.type is select: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(r)}),r.appendTo(o)}else{if(!t.isValidFilterType(n.type))throw new Error("Unknown filter type: "+n.type);r=$(`<input autocomplete='off' type='${n.type}' class='form-control form-control-sm'/>`),r.appendTo(o)}r.attr("data-operator",n.operator),r.attr("form",l),r.attr("name",e.name);const c=t.filterDefaultValue(n.default);null==c||""===c||r.val()||(r.val(String(c)),r.attr("data-default",String(c)),r[0]&&(r[0].defaultValue=String(c)));t.bindFilterInputEvents({type:n.type,$input:r,onSubmit:function(){const t=this.form;t&&$(t).trigger("submit")},createResult:s,filterConfig:n})}),t.hasActionColumn(n)&&$("<th>").addClass("kgrid-row-actions").attr("data-label","Actions").appendTo(a),i},t.FilterForm=function(e){this.form=$(e)[0],this.filter=(e,n,r="~=~")=>{if(!this.form)return this;let o=t.filterFormField(this.form,e);if(o.length||(t.ensureFilterField(this.form,e,n,r),o=t.filterFormField(this.form,e)),!o.length)return this;t.flushFilterSubmit(o),o.val(n);const a=o.attr("data-operator");return o.attr("data-operator",r),$(this.form).trigger("submit"),o.attr("data-operator",a),this},this.ensure=(e,n,r="=")=>(t.ensureFilterField(this.form,e,n,r),this),this.reset=()=>(this.form&&(t.cancelFilterDebounces(this.form),this.form.reset()),this)}}(window.KGrid),function(t){t.setupCell=function(e,n){const r=n?n.attr("id"):null,o={...e},a=$("<td>").attr("data-label",e.label);t.applyColumnCellMeta(a,e);const l=o.attrs&&"object"==typeof o.attrs?o.attrs:{};Object.keys(l).forEach(t=>a.attr(t,l[t]));let i=$("<div>").addClass("cell-content");if(i.html(o.display.template??`{{${o.name}}}`),i.appendTo(a),null==n||!e.features.update)return i.clone(!0).removeClass("cell-content").addClass("cell-input").appendTo(a),a;if(!o.name)throw new Error("Column must have a name when column.features.update is true: \n"+JSON.stringify(e,null,2));const s=o.update,u=s.type??"text";let c,f=!1;const d=t.createFieldInput({mode:"update",col:e,config:s});if(d)c=d.$input,f=!!d.skipValueAttr;else{switch(u){case"textarea":c=$(`<textarea class='form-input form-control form-control-sm'>{{${s.value??o.name}}}</textarea>`),f=!0;break;case"select":if(c=$("<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(e,null,2));s.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Select update.options entries need label and value: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(c)}),f=!0;break;case"hidden":c=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;case"displayonly":{const t=s.template||o.display.template||`{{${o.name}}}`;return $("<div>").addClass("cell-input").append(t).appendTo(a),a}default:if(!t.isValidInputType(u))throw new Error("Invalid update updateConfig type: "+JSON.stringify(s,null,2));c=$(`<input autocomplete='off' type='${u}' class='form-input form-control form-control-sm'/>`)}c.attr("data-type",u)}if(s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(t=>c.attr(t,s.attrs[t])),c.attr("form",r),c.attr("name",o.name),!f&&"textarea"!==u){const t=s.value??`{{${o.name}}}`;null!=t&&"object"!=typeof t&&c.attr("value",t)}return o.hidden?(c.attr("type","hidden").appendTo(n),a):(s.disabled&&c.attr("disabled",!0),s.readonly&&c.attr("readonly",!0),s.required&&c.attr("required",!0),s.attrs&&"object"==typeof s.attrs&&Object.keys(s.attrs).forEach(t=>c.attr(t,s.attrs[t])),s.disabled||s.readonly||c.attr("onchange","$(this).parents('tr').addClass('editing')"),$("<div>").addClass("cell-input").append(c).appendTo(a),a)}}(window.KGrid),function(t){t.setupNoDataTbody=function(t,e,n){const r=t.find("td").attr("colspan",n);return e.noDataTemplate&&r.html(e.noDataTemplate),r},t.setupDataBody=function(e,n,r,o,a,l){const i=[...n.columns],s=$("<tr>").appendTo(e);if(n.dataRowAttrs&&"object"!=typeof n.dataRowAttrs)throw new Error("options.dataRowAttrs must be an object");const u={...n.dataRowAttrs??{}};Object.keys(u).forEach(t=>s.attr(t,u[t])),e.data("emptyview",l),n?.features?.sorting&&e.data("sort",r),a&&e.data("paging",a.find(".pages")).data("pagesizeinp",a.find(".pagesize")).data("totalrecscount",a.find(".totalrecscount")),o&&e.data("filter",o),n.type&&e.data("type",n.type);const c="data_row_form_"+t.uuid()+"_{{this.id}}",f=n.features.update?$("<form class='edit-form table-row-form'>").attr("id",c):null;if(i.forEach(e=>{const n=t.setupCell(e,f);e.hidden||n.appendTo(s)}),t.hasActionColumn(n)){const t=$("<td>").addClass("kgrid-row-actions").appendTo(s);if(n.features.clone&&$("<div>").addClass("btn-group clone-item-grp").appendTo(t).append($("<button>").addClass("btn btn-sm btn-outline-secondary clone-item").attr("type","button").attr("title","Clone item").append("<i class='fa-regular fa-copy'></i>")),n.features.delete&&$("<div>").addClass("btn-group delete-item-grp").appendTo(t).append($("<button>").addClass("btn btn-sm btn-danger delete-item").attr("type","button").attr("title","Delete item").append("<i class='fas fa-trash'></i>")),n.features.update){const e=$("<div>").addClass("btn-group edit-item-grp").appendTo(t);$("<button>").addClass("btn btn-sm btn-success save-item").attr("type","submit").attr("name","save").attr("title","Save item").attr("form",c).html("<i class='fas fa-save'></i>").appendTo(e),$("<button>").addClass("btn btn-sm btn-secondary cancel-edit").attr("type","button").attr("name","cancel").attr("title","Cancel edit").attr("form",c).attr("onclick","$(this).parents('[data-type=item]').data().instance.loadFromRemote()").html("<i class='fas fa-undo'></i>").appendTo(e)}}return f&&t.anchorRowForm(f,s),e},t.setupPagingFooter=function(e,n,r){return t.log("setupPagingFooter",e,n,r),n.pagingFooterAttrs&&t.isPlainObject(n.pagingFooterAttrs)&&Object.keys(n.pagingFooterAttrs).forEach(t=>e.attr(t,n.pagingFooterAttrs[t])),t.log("noVisibleCols",r),e.find("td").attr("colspan",r),e}}(window.KGrid),function(t){t.setupNewRecordForm=function(e,n,r){if(!n.insertFormRow||!t.isPlainObject(n.insertFormRow))return e.find(".before-main-tbody").remove(),void e.find(".after-main-tbody").remove();const o=[...n.columns],a=$("<tr>").addClass("new-record-row");"top"===(n.insertFormRow?.position??"top")?(e.find(".after-main-tbody").remove(),a.appendTo(e.find(".before-main-tbody"))):(e.find(".before-main-tbody").remove(),a.appendTo(e.find(".after-main-tbody")));const l="new_record_row_form_"+t.uuid(),i=$("<form class='table-row-form'>").attr("id",l).off("submit").on("submit",e=>{e.preventDefault();const a=t.serializeForm(e.target,o);Object.keys(a).forEach(t=>{o.find(e=>e.name===t)?.insert?.dontsave&&delete a[t]}),r.instance.newItem(a).then(()=>{e.target.reset(),"function"==typeof n.onNewItemCreated&&n.onNewItemCreated(a)}).catch(t.onError)});o.forEach(e=>{if(e.hidden){if(n.features?.create&&e.features?.create){const t=$("<input type='hidden'>").attr("name",e.name).attr("form",l).appendTo(i);e.insert.default&&t.val(e.insert.default)}return}if(!e.features.create){const n=$("<td>").appendTo(a).attr("data-label",e.label);return void t.applyColumnCellMeta(n,e)}const r=e.insert;if(!r||!t.isPlainObject(r))throw new Error("Column must have an insert config object when column.features.create is true: \n"+JSON.stringify(e,null,2));if(!r.type)throw new Error("Column must have an insert.type when column.features.insert is true: \n"+JSON.stringify(e,null,2));let o;const s=r.type??"text",u=t.createFieldInput({mode:"insert",col:e,config:r});if(u)o=u.$input;else switch(s){case"textarea":o=$("<textarea class='form-input form-control form-control-sm'>");break;case"select":if(o=$("<select class='form-input form-control form-control-sm'/>"),!r.options||!Array.isArray(r.options))throw new Error("Column must have an insert.options array when column.features.insert is true: \n"+JSON.stringify(e,null,2));r.options.forEach(t=>{if("string"!=typeof t.label||void 0===t.value)throw new Error("Column must have an insert.options object with label and value when column.features.insert is true: \n"+JSON.stringify(e,null,2));$("<option>").text(t.label).attr("value",t.value).appendTo(o)});break;case"hidden":o=$("<input type='hidden' class='form-input form-control form-control-sm'/>");break;default:if(!t.isValidInputType(s))throw new Error("Invalid type: "+JSON.stringify(r,null,2));o=$(`<input autocomplete='off' type='${s}' class='form-input form-control form-control-sm'/>`),o.attr("data-type",s)}if(null!=r.default&&""!==r.default&&!o.val()){const t="object"==typeof r.default&&null!=r.default.value?r.default.value:r.default;String(t).trim()&&o.val(t).trigger("change")}if(r.attrs&&"object"==typeof r.attrs&&Object.keys(r.attrs).forEach(t=>o.attr(t,r.attrs[t])),o.attr("form",l).attr("name",e.name),r.disabled&&o.attr("disabled",!0),r.readonly&&o.attr("readonly",!0),r.required&&o.attr("required",!0),r.attrs&&"object"==typeof r.attrs&&Object.keys(r.attrs).forEach(t=>o.attr(t,r.attrs[t])),"hidden"!==r.type){const n=$("<td>").append(o).appendTo(a).attr("data-label",e.label);t.applyColumnCellMeta(n,e)}t.mountField({mode:"insert",$input:o,col:e,config:r,formEl:i[0],rowEl:a[0]}),r.events&&Array.isArray(r.events)&&r.events.forEach(t=>{o.off(t.event).on(t.event,function(e,...n){"function"==typeof t.callback&&t.callback(e,i[0],a[0],...n)})})}),t.anchorRowForm(i,a);const s=$("<td>").addClass("kgrid-row-actions").appendTo(a).attr("data-label","action"),u=$("<div>").addClass("btn-group").appendTo(s);return $("<button>").addClass("btn btn-sm btn-primary new-item-btn").html("<i class='fas fa-plus-square'></i>").attr("form",l).attr("type","submit").appendTo(u),"function"==typeof n.onInsertRowReady&&n.onInsertRowReady(i[0],a[0]),a}}(window.KGrid),function(t){t.setupEvents=function(e,n,r,o){const a=e.views[0];r.columns.forEach(n=>{n.display.events.forEach(t=>{if(!t.selector||!t.event||!t.callback)throw new Error("Invalid event: "+JSON.stringify(t,null,2));a.el.find(t.selector).off(t.event).on(t.event,n=>{if("function"!=typeof t.callback)throw new Error("Event callback must be a function: "+JSON.stringify(t,null,2));t.callback(n,e,a)})}),r.features.update&&n.update.events.forEach(r=>{if(!r.event||!r.callback)throw new Error("Invalid event: "+JSON.stringify(r,null,2));a.el.find("[name='"+n.name+"']").off(r.event).on(r.event,function(n,...o){if(t.log("event",r,n,this,o),"function"!=typeof r.callback)throw new Error("Event callback must be a function: "+JSON.stringify(r,null,2));r.callback(n,e,a,...o)})})}),r.features.update&&(a.el.find("[data-type]").each((n,r)=>{const l=r.getAttribute("data-type");if(!t.isPluggableFieldType(l))return;const i=o.get(r.name);i?.update&&t.mountField({mode:"update",$input:$(r),col:i,config:i.update,item:e,view:a})}),a.el.find("select[data-type='select']").each((t,n)=>{const r=o.get(n.name);if(!r)return;const a=e.attributes[r.name];null!=a&&""!==a&&$(n).val("boolean"==typeof a?String(a):a)}),a.el.find("form.edit-form").off("submit").on("submit",e=>{const n=e.target;e.preventDefault();const o=$(n).parents("[data-type=item]").data().instance,a=t.serializeForm(n);Object.keys(a).forEach(t=>{r.columns.find(e=>e.name===t)?.update?.dontsave&&delete a[t]}),o.update(a).catch(t.onError)})),r.features.clone&&a.el.find("button.clone-item").off("click").on("click",t=>{t.preventDefault(),"function"==typeof r.onClone&&r.onClone(e,a,t)}),r.features.delete&&a.el.find("button.delete-item").off("click").on("click",n=>{n.preventDefault(),a.el.addClass("confirm-delete");const o=()=>a.el.removeClass("confirm-delete");t.runDeleteConfirm({item:e,view:a,options:r},()=>{e.delete().catch(t.onError).finally(o)},o)}),"function"==typeof r.onRowFields&&r.onRowFields(e,a,n)}}(window.KGrid),function(t){t.init=async function(e,n){const r=t.resolveHostElement(e),o={...t.protoOptions,...n},a=t.mountTableShell(r,o);t.log("table config options",o);const l=t.resolveDefaultInteraction(o);t.applyInteraction(r,l);const i={$host:r,instance:null,filterForm:null,find:t=>r.find(t),setInteraction:(e,n)=>(t.applyInteraction(r,e,n),i),getInteraction:()=>"edit"===t.getTableInteractionHost(r).attr("data-interaction")?"edit":"view",setEditMode(t){if("boolean"!=typeof t)throw new TypeError("setEditMode(editMode) expects a boolean (true = edit, false = view)");return i.setInteraction(t?"edit":"view")},toggleEditMode:t=>(null!=t&&"object"==typeof t&&"function"==typeof t.preventDefault&&(t=void 0),"boolean"==typeof t?i.setInteraction(t?"edit":"view"):i.setInteraction("edit"===i.getInteraction()?"view":"edit"))};o.columns=o.columns.map(e=>t.normalizeColumnConfig(e));const s=o.handlers??{};if(delete o.handlers,"string"==typeof o.onClone){const t=s[o.onClone]||o.functions&&o.functions[o.onClone];if(!t||"function"!=typeof t)throw new Error("onClone handler "+o.onClone+" not found or is not a function");o.onClone=t}o.columns.forEach(t=>{["insert","update","display"].forEach(e=>{const n=t[e].events;if(!n||!Array.isArray(n))throw new Error("Column "+t.name+" events are not an array");n.forEach(e=>{if("string"==typeof e.callback){const n=s[e.callback]||o.functions&&o.functions[e.callback];if(!n||"function"!=typeof n)throw new Error("Event callback function "+e.callback+" not found for column "+t.name+" or is not a function");e.callback=n}else if("function"!=typeof e.callback)throw new Error("Event callback must be a function for column "+t.name)})});const e=t.display;e&&e.events&&Array.isArray(e.events)&&e.events.forEach(t=>{if("string"==typeof t.callback){const e=s[t.callback]||o.functions&&o.functions[t.callback];e&&"function"==typeof e&&(t.callback=e)}})});const u=new Map;o.columns.forEach(t=>{u.set(t.name,t)});const c=t.setupLabelsHeader(a.find(".thead-labels"),o),f=t.hasActionColumn(o),d=c.find("th").length,p=d-(f?1:0);t.syncActionColumnColgroup(a,p,f);const m=o.filterForm??t.setupFilterHeader(a,o);let y;o.features&&o.features.paging?y=t.setupPagingFooter(a.find(".paging-footer"),o,d):(y=null,a.find(".paging-footer").remove());const b=t.setupNoDataTbody(a.find(".no-data-tbody"),o,d);o.features&&o.features.create&&t.setupNewRecordForm(a,o,i),i.filterForm=new t.FilterForm(m);const g=t.setupDataBody(a.find(".main-tbody"),o,c,m,y,b),h={dontload:!0,setAttrAsId:o.setAttrAsId??!1,itemListeners:{afterrender:e=>t.setupEvents(e,i.find("table"),o,u)}},w=t.getKViews(o.kviews);if(!w)throw new Error(t.KVIEWS_MISSING_MSG);if(i.instance=await w.createCollectionInstance(g,h),o.url){i.instance.setUrl(o.url),o.deleteUrl&&(t.log("set deleteUrl",o.deleteUrl),i.instance.setUrl(o.deleteUrl,"delete")),o.updateUrl&&(t.log("set updateUrl",o.updateUrl),i.instance.setUrl(o.updateUrl,"update")),o.insertUrl&&i.instance.setUrl(o.insertUrl,"insert");try{await i.instance.loadFromRemote()}catch(e){t.onError(e)}}else{if(!o.data||o.data.constructor!==Array)throw new Error("Invalid data: missing datasource url or data for table");{const t=o.data.map(t=>({attributes:t}));i.instance.loadFromData(t)}}return t.setupDefaultFilters(m,o,i.instance),i}}(window.KGrid);
package/docs/ai-guide.md CHANGED
@@ -158,7 +158,7 @@ Each column in `columns: []` is normalized via `KGrid.normalizeColumnConfig` (pr
158
158
 
159
159
  ## Row actions column (do not break)
160
160
 
161
- When `features.delete || features.update || features.create`:
161
+ When `features.delete || features.update || features.create || features.clone`:
162
162
 
163
163
  - Trailing column: `.kgrid-row-actions` on `th`/`td`
164
164
  - `<colgroup>` with `col.kgrid-row-actions-col` (synced at init)
package/docs/api.md CHANGED
@@ -111,7 +111,7 @@ See **[table-shell.md](table-shell.md)** for structure, placeholders, and custom
111
111
 
112
112
  | Symbol | Description |
113
113
  |--------|-------------|
114
- | `KGrid.hasActionColumn(options)` | `true` when `features.delete`, `features.update`, or `features.create` is enabled |
114
+ | `KGrid.hasActionColumn(options)` | `true` when `features.delete`, `features.update`, `features.create`, or `features.clone` is enabled |
115
115
  | `KGrid.syncActionColumnColgroup($table, dataColumnCount, hasActions)` | Prepends `<colgroup>` so the actions column can collapse in view mode without reserving width |
116
116
 
117
117
  Requires `styles/table.css` for view/edit visibility rules on `.kgrid-row-actions` and `col.kgrid-row-actions-col`.
@@ -154,16 +154,17 @@ features: {
154
154
  create: false,
155
155
  update: false,
156
156
  delete: false,
157
+ clone: false,
157
158
  }
158
159
  ```
159
160
 
160
161
  ### Row actions column
161
162
 
162
- When any of `create`, `update`, or `delete` is enabled, KGrid adds a trailing column for row controls (delete, save/cancel, insert submit). The same rule is used everywhere so header, filter row, data rows, and `colspan` stay aligned:
163
+ When any of `create`, `update`, `delete`, or `clone` is enabled, KGrid adds a trailing column for row controls (clone, delete, save/cancel, insert submit). The same rule is used everywhere so header, filter row, data rows, and `colspan` stay aligned:
163
164
 
164
165
  ```javascript
165
166
  KGrid.hasActionColumn(options)
166
- // true when features.delete || features.update || features.create
167
+ // true when features.delete || features.update || features.create || features.clone
167
168
  ```
168
169
 
169
170
  | Markup | Role |
@@ -171,7 +172,9 @@ KGrid.hasActionColumn(options)
171
172
  | `th` / `td.kgrid-row-actions` | Header, filters, data rows |
172
173
  | `colgroup col.kgrid-row-actions-col` | Width control for `table-layout: fixed` (added at init via `syncActionColumnColgroup`) |
173
174
 
174
- **View vs edit:** In **view** mode (`data-interaction="view"`), the row-actions column is collapsed (`visibility: collapse`, zero width) so data columns use the full table width. In **edit** mode, the column is shown (~100px) with delete / save / cancel buttons and the insert-row submit cell.
175
+ **View vs edit:** In **view** mode (`data-interaction="view"`), the row-actions column is collapsed (`visibility: collapse`, zero width) so data columns use the full table width. In **edit** mode, the column is shown (~130px) with clone / delete / save / cancel buttons and the insert-row submit cell.
176
+
177
+ `features.clone` (default `false`) adds a clone button. Host must supply `onClone(item, view, event)` — a function, or a string name resolved from `handlers` / `functions` (same as column event callbacks). KGrid does not clone records itself.
175
178
 
176
179
  The new-record row (`.new-record-row`) uses the same `kgrid-row-actions` class on its submit cell; the whole insert row is hidden in view mode via existing CSS.
177
180
 
@@ -0,0 +1,180 @@
1
+ # Release guide
2
+
3
+ Maintainer-only process for shipping **`@logimaxx/kgrid`**. The package is proprietary (Logimaxx System SRL); distribution is controlled, but `publishConfig.access` is `public` so authorized npm publishes succeed.
4
+
5
+ Related: [CONTRIBUTING.md](../CONTRIBUTING.md), [NOTICE.md](../NOTICE.md), `scripts/release.mjs`, `version.sh`.
6
+
7
+ ---
8
+
9
+ ## Who can release
10
+
11
+ Only maintainers with:
12
+
13
+ - Write access to `github.com/logimaxx/kgrid`
14
+ - npm publish rights for the `@logimaxx` scope
15
+ - Permission to push tags to the default branch
16
+
17
+ Contact: [sergiu@logimaxx.ro](mailto:sergiu@logimaxx.ro).
18
+
19
+ ---
20
+
21
+ ## Prerequisites
22
+
23
+ 1. Clean working tree for everything you intend to ship (except intentional `dist/` refresh — see below).
24
+ 2. On the release branch (usually `main`), up to date with remote.
25
+ 3. Logged in to npm as a user that can publish `@logimaxx/kgrid`:
26
+
27
+ ```bash
28
+ npm whoami
29
+ npm access list packages @logimaxx # or your org’s equivalent check
30
+ ```
31
+
32
+ 4. Do **not** set `"private": true` in `package.json`. That causes `npm publish` to fail with `EPRIVATE`. Access control is via registry permissions and who you grant installs to — not the `private` flag.
33
+
34
+ ---
35
+
36
+ ## Versioning
37
+
38
+ Use [semver](https://semver.org/):
39
+
40
+ | Bump | When |
41
+ |------|------|
42
+ | **patch** | Bug fixes, docs-only package tweaks, no API shape change |
43
+ | **minor** | New features / options that stay backward compatible |
44
+ | **major** | Breaking API, required config changes, or peer-dep jumps that break hosts |
45
+
46
+ Current version lives in `package.json` (`version`). `npm version` / `./version.sh` bump it and create a matching git tag (`vX.Y.Z`).
47
+
48
+ ---
49
+
50
+ ## What gets published
51
+
52
+ From `package.json` `files`:
53
+
54
+ | Path | Role |
55
+ |------|------|
56
+ | `dist/` | Bundles (`kgrid.js`, `kgrid.min.js`) — **commit these** before tagging |
57
+ | `src/` | Source |
58
+ | `styles/` | Required CSS (`table.css`) |
59
+ | `docs/` | Human + AI docs |
60
+ | `integrations/` | Optional widgets (e.g. `kgrid-widgets.js`) |
61
+ | `LICENSE`, `NOTICE.md`, `AGENTS.md` | Legal / branding |
62
+
63
+ `prepare` runs `npm run build` on install; still treat committed `dist/` as the release artifact so git-tag consumers get a ready tree.
64
+
65
+ ---
66
+
67
+ ## Release checklist
68
+
69
+ ### 1. Finish the change set
70
+
71
+ - [ ] Tests cover non-trivial logic (`test/`)
72
+ - [ ] Docs under `docs/` updated if public API or behavior changed
73
+ - [ ] Peer deps (`jquery`, `@logimaxx/kviews`) still accurate
74
+ - [ ] Demo smoke-check if UI/CRUD changed: `npm run demo`
75
+
76
+ ### 2. Prep (test + build)
77
+
78
+ ```bash
79
+ npm run release
80
+ ```
81
+
82
+ This runs `npm test` and `npm run build`, then reports whether `dist/` differs from the index.
83
+
84
+ If `dist/` is dirty:
85
+
86
+ ```bash
87
+ git add dist
88
+ git commit -m "chore: refresh dist"
89
+ ```
90
+
91
+ `npm version` requires a clean tree for the files it touches; commit dist (and any other release files) first.
92
+
93
+ ### 3. Bump, tag, push
94
+
95
+ Preferred (Unix):
96
+
97
+ ```bash
98
+ ./version.sh patch # or: minor | major
99
+ ```
100
+
101
+ That runs:
102
+
103
+ 1. `npm version <bump>` — updates `package.json` (+ lockfile if present), commits, tags
104
+ 2. `git push`
105
+ 3. `git push --tags`
106
+
107
+ Manual equivalent:
108
+
109
+ ```bash
110
+ npm version patch # or minor | major
111
+ git push && git push --tags
112
+ ```
113
+
114
+ ### 4. Publish to npm
115
+
116
+ ```bash
117
+ npm publish
118
+ ```
119
+
120
+ Scoped package name: `@logimaxx/kgrid`. Confirm the published version on the registry before notifying consumers.
121
+
122
+ ### 5. After publish
123
+
124
+ - [ ] Spot-check install in a host app (or MaxxOps alias — see below)
125
+ - [ ] Note the version in release chat / ticket if the team uses one
126
+ - [ ] If hosts pin ranges (`^0.2.2`), confirm they can resolve the new version
127
+
128
+ ---
129
+
130
+ ## Consumer install
131
+
132
+ ```bash
133
+ npm install @logimaxx/kgrid @logimaxx/kviews jquery
134
+ ```
135
+
136
+ MaxxOps-style folder alias (keeps `node_modules/kgrid/`):
137
+
138
+ ```bash
139
+ npm install kgrid@npm:@logimaxx/kgrid@^0.2.2
140
+ ```
141
+
142
+ Alternatives (authorized access required):
143
+
144
+ ```bash
145
+ npm install github:logimaxx/kgrid#v0.2.4 # or #main
146
+ npm install file:../kgrid
147
+ ```
148
+
149
+ ---
150
+
151
+ ## One-liner flow (happy path)
152
+
153
+ ```bash
154
+ # on main, changes already merged and reviewed
155
+ npm run release
156
+ # if dist dirty: commit as above, then:
157
+ ./version.sh patch
158
+ npm publish
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Troubleshooting
164
+
165
+ | Symptom | Fix |
166
+ |---------|-----|
167
+ | `npm version` refuses (dirty tree) | Commit or stash; especially commit refreshed `dist/` |
168
+ | `EPRIVATE` on publish | Remove `"private": true`; keep `publishConfig.access: "public"` |
169
+ | `ENEEDAUTH` / 403 | `npm login` with a user that can publish `@logimaxx` |
170
+ | Tag already exists | Do not force-retag casually; bump again or delete the mistaken local tag only if it was never pushed |
171
+ | Consumers still on old code | They may pin exact versions or use a stale lockfile — bump their dependency range / reinstall |
172
+
173
+ ---
174
+
175
+ ## Do not
176
+
177
+ - Publish from a dirty or untested tree
178
+ - Skip committing `dist/` when the build changed bundles
179
+ - Force-push release tags on shared remotes without maintainer agreement
180
+ - Suggest open-sourcing or changing the license as part of a routine release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logimaxx/kgrid",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "KGrid — declarative data table for KViews (filter, sort, paging, inline CRUD). Proprietary — Logimaxx System SRL.",
5
5
  "main": "dist/kgrid.js",
6
6
  "homepage": "https://logimaxx.ro",
package/src/constants.js CHANGED
@@ -12,7 +12,8 @@
12
12
  "paging": false,
13
13
  "create": false,
14
14
  "update": false,
15
- "delete": false
15
+ "delete": false,
16
+ "clone": false
16
17
  },
17
18
  "defaultInteraction": "view",
18
19
  "insertFormRow": {
package/src/data-body.js CHANGED
@@ -53,6 +53,13 @@
53
53
 
54
54
  if (CT.hasActionColumn(options)) {
55
55
  const buttonColumn = $("<td>").addClass("kgrid-row-actions").appendTo(dataRow);
56
+ if(options.features.clone) {
57
+ $("<div>").addClass("btn-group clone-item-grp").appendTo(buttonColumn).append(
58
+ $("<button>").addClass("btn btn-sm btn-outline-secondary clone-item")
59
+ .attr("type","button")
60
+ .attr("title","Clone item")
61
+ .append("<i class='fa-regular fa-copy'></i>"));
62
+ }
56
63
  if(options.features.delete) {
57
64
  $("<div>").addClass("btn-group delete-item-grp").appendTo(buttonColumn).append(
58
65
  $("<button>").addClass("btn btn-sm btn-danger delete-item")
package/src/dom.js CHANGED
@@ -40,7 +40,7 @@
40
40
  if (!f) {
41
41
  return false;
42
42
  }
43
- return !!(f.delete || f.update || f.create);
43
+ return !!(f.delete || f.update || f.create || f.clone);
44
44
  };
45
45
 
46
46
  /**
package/src/events.js CHANGED
@@ -78,6 +78,15 @@
78
78
  });
79
79
  }
80
80
 
81
+ if(options.features.clone) {
82
+ view.el.find("button.clone-item").off("click").on("click",(event)=>{
83
+ event.preventDefault();
84
+ if (typeof options.onClone === "function") {
85
+ options.onClone(item, view, event);
86
+ }
87
+ });
88
+ }
89
+
81
90
  if(options.features.delete) {
82
91
  view.el.find("button.delete-item").off("click").on("click",(event)=>{
83
92
  event.preventDefault();
package/src/init.js CHANGED
@@ -63,6 +63,17 @@
63
63
 
64
64
  const handlers = options.handlers ?? {};
65
65
  delete options.handlers;
66
+ if (typeof options.onClone === "string") {
67
+ const fn =
68
+ handlers[options.onClone] ||
69
+ (options.functions && options.functions[options.onClone]);
70
+ if (!fn || typeof fn !== "function") {
71
+ throw new Error(
72
+ "onClone handler " + options.onClone + " not found or is not a function"
73
+ );
74
+ }
75
+ options.onClone = fn;
76
+ }
66
77
  options.columns.forEach((col) => {
67
78
  ["insert", "update", "display"].forEach((mode) => {
68
79
  const events = col[mode].events;
@@ -36,8 +36,11 @@
36
36
  if (overrides.delete !== undefined) {
37
37
  $shell.attr("data-allow-delete", overrides.delete ? "true" : "false");
38
38
  }
39
+ if (overrides.clone !== undefined) {
40
+ $shell.attr("data-allow-clone", overrides.clone ? "true" : "false");
41
+ }
39
42
  } else if (interaction === "edit") {
40
- $shell.removeAttr("data-allow-insert data-allow-update data-allow-delete");
43
+ $shell.removeAttr("data-allow-insert data-allow-update data-allow-delete data-allow-clone");
41
44
  }
42
45
  };
43
46
  })(window.KGrid);
package/styles/table.css CHANGED
@@ -94,11 +94,13 @@ div.save-item{
94
94
  display: none;
95
95
  }
96
96
  .custom-table-shell[data-interaction="view"] .cell-input,
97
- .custom-table-shell[data-interaction="view"] .delete-item{
97
+ .custom-table-shell[data-interaction="view"] .delete-item,
98
+ .custom-table-shell[data-interaction="view"] .clone-item{
98
99
  display: none;
99
100
  }
100
101
  .custom-table-shell[data-interaction="edit"] .cell-input,
101
- .custom-table-shell[data-interaction="edit"] .delete-item{
102
+ .custom-table-shell[data-interaction="edit"] .delete-item,
103
+ .custom-table-shell[data-interaction="edit"] .clone-item{
102
104
  display: block;
103
105
  }
104
106
  .new-record-row{
@@ -114,6 +116,9 @@ div.save-item{
114
116
  .custom-table-shell[data-allow-delete="false"] button.delete-item {
115
117
  display: none !important;
116
118
  }
119
+ .custom-table-shell[data-allow-clone="false"] button.clone-item {
120
+ display: none !important;
121
+ }
117
122
  .custom-table-shell[data-allow-update="false"][data-interaction="edit"] .cell-input{
118
123
  display: none;
119
124
  }
@@ -148,12 +153,13 @@ div.save-item{
148
153
  overflow: hidden;
149
154
  }
150
155
  .custom-table-shell[data-interaction="edit"] col.kgrid-row-actions-col {
151
- width: 100px;
156
+ width: 130px;
152
157
  }
153
158
  .custom-table-shell[data-interaction="edit"] th.kgrid-row-actions {
154
- width: 100px;
159
+ width: 130px;
155
160
  }
156
- .editing .delete-item-grp {
161
+ .editing .delete-item-grp,
162
+ .editing .clone-item-grp {
157
163
  display: none;
158
164
  }
159
165