@logimaxx/kgrid 0.5.2 → 0.5.4
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/AGENTS.md +2 -0
- package/README.md +1 -1
- package/dist/kgrid.js +166 -67
- package/dist/kgrid.min.js +2 -2
- package/docs/ai-guide.md +6 -5
- package/docs/api.md +8 -4
- package/docs/configuration.md +2 -2
- package/docs/table-shell.md +2 -2
- package/package.json +1 -1
- package/src/cells.js +1 -2
- package/src/dom.js +68 -4
- package/src/events.js +3 -0
- package/src/init.js +4 -4
- package/src/labels.js +1 -3
- package/src/preferences.js +32 -29
- package/src/row-actions.js +56 -24
- package/styles/table.css +289 -205
package/src/preferences.js
CHANGED
|
@@ -307,50 +307,53 @@
|
|
|
307
307
|
return merged;
|
|
308
308
|
};
|
|
309
309
|
|
|
310
|
-
CT.
|
|
311
|
-
if (!$
|
|
310
|
+
CT.applyLayoutToRow = function ($row, columns) {
|
|
311
|
+
if (!$row || !$row.length) {
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const chooser = CT.chooserColumns(columns);
|
|
315
|
+
const order = chooser.map(function (col) {
|
|
315
316
|
return col.name;
|
|
316
317
|
});
|
|
317
318
|
const hidden = {};
|
|
318
|
-
|
|
319
|
+
chooser.forEach(function (col) {
|
|
319
320
|
if (col.userHidden) {
|
|
320
321
|
hidden[col.name] = true;
|
|
321
322
|
}
|
|
322
323
|
});
|
|
324
|
+
const $action = $row.children(".kgrid-row-actions");
|
|
325
|
+
const byName = {};
|
|
326
|
+
$row.children("[data-name]").each(function () {
|
|
327
|
+
byName[this.getAttribute("data-name")] = this;
|
|
328
|
+
});
|
|
329
|
+
order.forEach(function (name) {
|
|
330
|
+
const el = byName[name];
|
|
331
|
+
if (!el) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if ($action.length) {
|
|
335
|
+
$(el).insertBefore($action);
|
|
336
|
+
} else {
|
|
337
|
+
$row.append(el);
|
|
338
|
+
}
|
|
339
|
+
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
CT.applyLayoutToDom = function ($table, columns, options) {
|
|
344
|
+
if (!$table || !$table.length) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
323
347
|
const $rows = $table.find(
|
|
324
348
|
".thead-labels tr, .thead-filters tr, .before-main-tbody tr, .main-tbody tr, .after-main-tbody tr"
|
|
325
349
|
);
|
|
326
350
|
$rows.each(function () {
|
|
327
|
-
|
|
328
|
-
const $action = $row.children(".kgrid-row-actions");
|
|
329
|
-
const byName = {};
|
|
330
|
-
$row.children("[data-name]").each(function () {
|
|
331
|
-
byName[this.getAttribute("data-name")] = this;
|
|
332
|
-
});
|
|
333
|
-
order.forEach(function (name) {
|
|
334
|
-
const el = byName[name];
|
|
335
|
-
if (!el) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
if ($action.length) {
|
|
339
|
-
$(el).insertBefore($action);
|
|
340
|
-
} else {
|
|
341
|
-
$row.append(el);
|
|
342
|
-
}
|
|
343
|
-
el.classList.toggle("kgrid-user-hidden", !!hidden[name]);
|
|
344
|
-
});
|
|
351
|
+
CT.applyLayoutToRow($(this), columns);
|
|
345
352
|
});
|
|
353
|
+
const visible = CT.layoutVisibleColumns(columns);
|
|
346
354
|
const hasActions = $table.find(".kgrid-row-actions").length > 0;
|
|
347
|
-
CT.syncActionColumnColgroup(
|
|
348
|
-
|
|
349
|
-
order.length,
|
|
350
|
-
hasActions,
|
|
351
|
-
options,
|
|
352
|
-
CT.chooserColumns(columns)
|
|
353
|
-
);
|
|
355
|
+
CT.syncActionColumnColgroup($table, visible.length, hasActions, options, visible);
|
|
356
|
+
CT.syncSpanningCells($table, CT.participatingColumnCount(columns, hasActions));
|
|
354
357
|
};
|
|
355
358
|
|
|
356
359
|
CT.refreshCollectionTemplate = function (api, options) {
|
package/src/row-actions.js
CHANGED
|
@@ -213,39 +213,70 @@
|
|
|
213
213
|
return (2.5 * n + 0.75).toFixed(2) + "rem";
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
CT.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
CT.closeRowActionDropdowns = function ($exceptMenu) {
|
|
217
|
+
$(".kgrid-row-actions-menu").each(function () {
|
|
218
|
+
const $wrap = $(this);
|
|
219
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
220
|
+
if ($exceptMenu && $menu[0] === $exceptMenu[0]) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
$menu.removeClass("show").css({ top: "", left: "", right: "", position: "" });
|
|
224
|
+
$wrap.children(".kgrid-actions-dropdown-toggle").attr("aria-expanded", "false").removeClass("show");
|
|
225
|
+
});
|
|
222
226
|
};
|
|
223
227
|
|
|
224
228
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
229
|
+
* Wire row-action kebab menus. Uses a small jQuery toggle (not Bootstrap Dropdown)
|
|
230
|
+
* so we do not depend on data-api / popperConfig quirks; menu is position:fixed while open.
|
|
227
231
|
* @param {JQuery} $root
|
|
228
232
|
*/
|
|
229
233
|
CT.mountRowActionDropdowns = function ($root) {
|
|
230
234
|
if (!$root || !$root.length) {
|
|
231
235
|
return;
|
|
232
236
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
237
|
+
if (!CT._rowActionsDropdownDocBound) {
|
|
238
|
+
CT._rowActionsDropdownDocBound = true;
|
|
239
|
+
$(document)
|
|
240
|
+
.on("click.kgridRowActions", function () {
|
|
241
|
+
CT.closeRowActionDropdowns();
|
|
242
|
+
})
|
|
243
|
+
.on("keydown.kgridRowActions", function (e) {
|
|
244
|
+
if (e.key === "Escape") {
|
|
245
|
+
CT.closeRowActionDropdowns();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
236
248
|
}
|
|
237
249
|
$root.find(".kgrid-row-actions-menu > .kgrid-actions-dropdown-toggle").each(function () {
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
const toggle = this;
|
|
251
|
+
const $toggle = $(toggle);
|
|
252
|
+
const $wrap = $toggle.parent(".kgrid-row-actions-menu");
|
|
253
|
+
const $menu = $wrap.children(".dropdown-menu");
|
|
254
|
+
$toggle.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
event.stopPropagation();
|
|
257
|
+
const willOpen = !$menu.hasClass("show");
|
|
258
|
+
CT.closeRowActionDropdowns();
|
|
259
|
+
if (!willOpen) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const rect = toggle.getBoundingClientRect();
|
|
263
|
+
$menu.addClass("show").css({
|
|
264
|
+
position: "fixed",
|
|
265
|
+
top: Math.round(rect.bottom + 2) + "px",
|
|
266
|
+
left: "auto",
|
|
267
|
+
right: Math.round(window.innerWidth - rect.right) + "px",
|
|
268
|
+
zIndex: 1055,
|
|
269
|
+
});
|
|
270
|
+
$toggle.addClass("show").attr("aria-expanded", "true");
|
|
271
|
+
});
|
|
272
|
+
$menu.off("click.kgridRowActions").on("click.kgridRowActions", function (event) {
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
});
|
|
275
|
+
$menu.find(".dropdown-item").off("click.kgridRowActionsClose").on("click.kgridRowActionsClose", function () {
|
|
276
|
+
// Close after the action click handlers (same tick is fine).
|
|
277
|
+
setTimeout(function () {
|
|
278
|
+
CT.closeRowActionDropdowns();
|
|
279
|
+
}, 0);
|
|
249
280
|
});
|
|
250
281
|
});
|
|
251
282
|
};
|
|
@@ -369,8 +400,9 @@
|
|
|
369
400
|
}
|
|
370
401
|
});
|
|
371
402
|
} else {
|
|
403
|
+
// span (not div): stay on one horizontal line with sibling actions
|
|
372
404
|
idleItems.forEach(function (item) {
|
|
373
|
-
const $grp = $("<
|
|
405
|
+
const $grp = $("<span>")
|
|
374
406
|
.addClass(item.groupClass || "btn-group kgrid-custom-action-grp")
|
|
375
407
|
.appendTo($buttonColumn);
|
|
376
408
|
if (item.when === "always") {
|
|
@@ -382,7 +414,7 @@
|
|
|
382
414
|
|
|
383
415
|
const editingAll = ra.editingItems.concat(editingExtras);
|
|
384
416
|
if (editingAll.length) {
|
|
385
|
-
const $grp = $("<
|
|
417
|
+
const $grp = $("<span>").addClass("btn-group edit-item-grp").appendTo($buttonColumn);
|
|
386
418
|
editingAll.forEach(function (item) {
|
|
387
419
|
appendButton($grp, item, dataRowFormId);
|
|
388
420
|
});
|