@toolbox-web/grid 0.0.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/all.d.ts +3518 -0
- package/all.js +3762 -0
- package/all.js.map +1 -0
- package/index.d.ts +2367 -0
- package/index.js +3105 -0
- package/index.js.map +1 -0
- package/lib/plugins/clipboard/index.js +365 -0
- package/lib/plugins/clipboard/index.js.map +1 -0
- package/lib/plugins/column-virtualization/index.js +255 -0
- package/lib/plugins/column-virtualization/index.js.map +1 -0
- package/lib/plugins/context-menu/index.js +341 -0
- package/lib/plugins/context-menu/index.js.map +1 -0
- package/lib/plugins/export/index.js +305 -0
- package/lib/plugins/export/index.js.map +1 -0
- package/lib/plugins/filtering/index.js +759 -0
- package/lib/plugins/filtering/index.js.map +1 -0
- package/lib/plugins/grouping-columns/index.js +283 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -0
- package/lib/plugins/grouping-rows/index.js +494 -0
- package/lib/plugins/grouping-rows/index.js.map +1 -0
- package/lib/plugins/master-detail/index.js +303 -0
- package/lib/plugins/master-detail/index.js.map +1 -0
- package/lib/plugins/multi-sort/index.js +270 -0
- package/lib/plugins/multi-sort/index.js.map +1 -0
- package/lib/plugins/pinned-columns/index.js +221 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -0
- package/lib/plugins/pinned-rows/index.js +459 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -0
- package/lib/plugins/pivot/index.js +326 -0
- package/lib/plugins/pivot/index.js.map +1 -0
- package/lib/plugins/reorder/index.js +260 -0
- package/lib/plugins/reorder/index.js.map +1 -0
- package/lib/plugins/selection/index.js +426 -0
- package/lib/plugins/selection/index.js.map +1 -0
- package/lib/plugins/server-side/index.js +241 -0
- package/lib/plugins/server-side/index.js.map +1 -0
- package/lib/plugins/tree/index.js +383 -0
- package/lib/plugins/tree/index.js.map +1 -0
- package/lib/plugins/undo-redo/index.js +289 -0
- package/lib/plugins/undo-redo/index.js.map +1 -0
- package/lib/plugins/visibility/index.js +430 -0
- package/lib/plugins/visibility/index.js.map +1 -0
- package/package.json +53 -0
- package/themes/dg-theme-contrast.css +43 -0
- package/themes/dg-theme-large.css +54 -0
- package/themes/dg-theme-standard.css +19 -0
- package/themes/dg-theme-vibrant.css +16 -0
- package/umd/grid.all.umd.js +660 -0
- package/umd/grid.all.umd.js.map +1 -0
- package/umd/grid.umd.js +105 -0
- package/umd/grid.umd.js.map +1 -0
- package/umd/plugins/clipboard.umd.js +9 -0
- package/umd/plugins/clipboard.umd.js.map +1 -0
- package/umd/plugins/column-virtualization.umd.js +2 -0
- package/umd/plugins/column-virtualization.umd.js.map +1 -0
- package/umd/plugins/context-menu.umd.js +53 -0
- package/umd/plugins/context-menu.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +14 -0
- package/umd/plugins/export.umd.js.map +1 -0
- package/umd/plugins/filtering.umd.js +175 -0
- package/umd/plugins/filtering.umd.js.map +1 -0
- package/umd/plugins/grouping-columns.umd.js +29 -0
- package/umd/plugins/grouping-columns.umd.js.map +1 -0
- package/umd/plugins/grouping-rows.umd.js +40 -0
- package/umd/plugins/grouping-rows.umd.js.map +1 -0
- package/umd/plugins/master-detail.umd.js +27 -0
- package/umd/plugins/master-detail.umd.js.map +1 -0
- package/umd/plugins/multi-sort.umd.js +26 -0
- package/umd/plugins/multi-sort.umd.js.map +1 -0
- package/umd/plugins/pinned-columns.umd.js +2 -0
- package/umd/plugins/pinned-columns.umd.js.map +1 -0
- package/umd/plugins/pinned-rows.umd.js +73 -0
- package/umd/plugins/pinned-rows.umd.js.map +1 -0
- package/umd/plugins/pivot.umd.js +8 -0
- package/umd/plugins/pivot.umd.js.map +1 -0
- package/umd/plugins/reorder.umd.js +31 -0
- package/umd/plugins/reorder.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +34 -0
- package/umd/plugins/selection.umd.js.map +1 -0
- package/umd/plugins/server-side.umd.js +2 -0
- package/umd/plugins/server-side.umd.js.map +1 -0
- package/umd/plugins/tree.umd.js +11 -0
- package/umd/plugins/tree.umd.js.map +1 -0
- package/umd/plugins/undo-redo.umd.js +2 -0
- package/umd/plugins/undo-redo.umd.js.map +1 -0
- package/umd/plugins/visibility.umd.js +94 -0
- package/umd/plugins/visibility.umd.js.map +1 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
class p {
|
|
2
|
+
/** Plugin version - override in subclass if needed */
|
|
3
|
+
version = "1.0.0";
|
|
4
|
+
/** CSS styles to inject into the grid's shadow DOM */
|
|
5
|
+
styles;
|
|
6
|
+
/** Custom cell renderers keyed by type name */
|
|
7
|
+
cellRenderers;
|
|
8
|
+
/** Custom header renderers keyed by type name */
|
|
9
|
+
headerRenderers;
|
|
10
|
+
/** Custom cell editors keyed by type name */
|
|
11
|
+
cellEditors;
|
|
12
|
+
/** The grid instance this plugin is attached to */
|
|
13
|
+
grid;
|
|
14
|
+
/** Plugin configuration - merged with defaults in attach() */
|
|
15
|
+
config;
|
|
16
|
+
/** User-provided configuration from constructor */
|
|
17
|
+
userConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Default configuration - subclasses should override this getter.
|
|
20
|
+
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
21
|
+
* since property initializers run after parent constructor.
|
|
22
|
+
*/
|
|
23
|
+
get defaultConfig() {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
constructor(e = {}) {
|
|
27
|
+
this.userConfig = e;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Called when the plugin is attached to a grid.
|
|
31
|
+
* Override to set up event listeners, initialize state, etc.
|
|
32
|
+
*/
|
|
33
|
+
attach(e) {
|
|
34
|
+
this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Called when the plugin is detached from a grid.
|
|
38
|
+
* Override to clean up event listeners, timers, etc.
|
|
39
|
+
*/
|
|
40
|
+
detach() {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get another plugin instance from the same grid.
|
|
44
|
+
* Use for inter-plugin communication.
|
|
45
|
+
*/
|
|
46
|
+
getPlugin(e) {
|
|
47
|
+
return this.grid?.getPlugin(e);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emit a custom event from the grid.
|
|
51
|
+
*/
|
|
52
|
+
emit(e, t) {
|
|
53
|
+
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request a re-render of the grid.
|
|
57
|
+
*/
|
|
58
|
+
requestRender() {
|
|
59
|
+
this.grid?.requestRender?.();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Request a lightweight style update without rebuilding DOM.
|
|
63
|
+
* Use this instead of requestRender() when only CSS classes need updating.
|
|
64
|
+
*/
|
|
65
|
+
requestAfterRender() {
|
|
66
|
+
this.grid?.requestAfterRender?.();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the current rows from the grid.
|
|
70
|
+
*/
|
|
71
|
+
get rows() {
|
|
72
|
+
return this.grid?.rows ?? [];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the original unfiltered/unprocessed rows from the grid.
|
|
76
|
+
* Use this when you need all source data regardless of active filters.
|
|
77
|
+
*/
|
|
78
|
+
get sourceRows() {
|
|
79
|
+
return this.grid?.sourceRows ?? [];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the current columns from the grid.
|
|
83
|
+
*/
|
|
84
|
+
get columns() {
|
|
85
|
+
return this.grid?.columns ?? [];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get only visible columns from the grid (excludes hidden).
|
|
89
|
+
* Use this for rendering that needs to match the grid template.
|
|
90
|
+
*/
|
|
91
|
+
get visibleColumns() {
|
|
92
|
+
return this.grid?.visibleColumns ?? [];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the shadow root of the grid.
|
|
96
|
+
*/
|
|
97
|
+
get shadowRoot() {
|
|
98
|
+
return this.grid?.shadowRoot ?? null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Log a warning message.
|
|
102
|
+
*/
|
|
103
|
+
warn(e) {
|
|
104
|
+
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function h(b) {
|
|
108
|
+
const e = b.meta ?? {};
|
|
109
|
+
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
110
|
+
}
|
|
111
|
+
class g extends p {
|
|
112
|
+
name = "visibility";
|
|
113
|
+
version = "1.0.0";
|
|
114
|
+
/** Tool panel ID for shell integration */
|
|
115
|
+
static PANEL_ID = "columns";
|
|
116
|
+
get defaultConfig() {
|
|
117
|
+
return {
|
|
118
|
+
enabled: !0,
|
|
119
|
+
allowHideAll: !1
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// ===== Internal State =====
|
|
123
|
+
columnListElement = null;
|
|
124
|
+
// Drag state for reorder integration
|
|
125
|
+
isDragging = !1;
|
|
126
|
+
draggedField = null;
|
|
127
|
+
draggedIndex = null;
|
|
128
|
+
dropIndex = null;
|
|
129
|
+
// ===== Lifecycle =====
|
|
130
|
+
detach() {
|
|
131
|
+
this.columnListElement = null, this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
|
|
132
|
+
}
|
|
133
|
+
// ===== Shell Integration =====
|
|
134
|
+
/**
|
|
135
|
+
* Register the column visibility tool panel with the shell.
|
|
136
|
+
*/
|
|
137
|
+
getToolPanel() {
|
|
138
|
+
if (this.config.enabled)
|
|
139
|
+
return {
|
|
140
|
+
id: g.PANEL_ID,
|
|
141
|
+
title: "Columns",
|
|
142
|
+
icon: "☰",
|
|
143
|
+
tooltip: "Column visibility",
|
|
144
|
+
order: 100,
|
|
145
|
+
// High order so it appears last
|
|
146
|
+
render: (e) => this.renderPanelContent(e)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// ===== Public API =====
|
|
150
|
+
/**
|
|
151
|
+
* Show the visibility sidebar panel.
|
|
152
|
+
*/
|
|
153
|
+
show() {
|
|
154
|
+
this.grid.openToolPanel(g.PANEL_ID);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Hide the visibility sidebar panel.
|
|
158
|
+
*/
|
|
159
|
+
hide() {
|
|
160
|
+
this.grid.closeToolPanel();
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Toggle the visibility sidebar panel.
|
|
164
|
+
*/
|
|
165
|
+
toggle() {
|
|
166
|
+
this.grid.toggleToolPanel(g.PANEL_ID);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Check if a specific column is visible.
|
|
170
|
+
* Delegates to grid.isColumnVisible().
|
|
171
|
+
* @param field - The field name to check
|
|
172
|
+
* @returns True if the column is visible
|
|
173
|
+
*/
|
|
174
|
+
isColumnVisible(e) {
|
|
175
|
+
return this.grid.isColumnVisible(e);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Set visibility for a specific column.
|
|
179
|
+
* Delegates to grid.setColumnVisible().
|
|
180
|
+
* @param field - The field name of the column
|
|
181
|
+
* @param visible - Whether the column should be visible
|
|
182
|
+
*/
|
|
183
|
+
setColumnVisible(e, t) {
|
|
184
|
+
this.grid.setColumnVisible(e, t);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get list of all visible column fields.
|
|
188
|
+
* @returns Array of visible field names
|
|
189
|
+
*/
|
|
190
|
+
getVisibleColumns() {
|
|
191
|
+
return this.grid.getAllColumns().filter((t) => t.visible).map((t) => t.field);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get list of all hidden column fields.
|
|
195
|
+
* @returns Array of hidden field names
|
|
196
|
+
*/
|
|
197
|
+
getHiddenColumns() {
|
|
198
|
+
return this.grid.getAllColumns().filter((t) => !t.visible).map((t) => t.field);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Show all columns.
|
|
202
|
+
* Delegates to grid.showAllColumns().
|
|
203
|
+
*/
|
|
204
|
+
showAll() {
|
|
205
|
+
this.grid.showAllColumns();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Toggle visibility for a specific column.
|
|
209
|
+
* Delegates to grid.toggleColumnVisibility().
|
|
210
|
+
* @param field - The field name of the column
|
|
211
|
+
*/
|
|
212
|
+
toggleColumn(e) {
|
|
213
|
+
this.grid.toggleColumnVisibility(e);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Show a specific column.
|
|
217
|
+
* Delegates to grid.setColumnVisible().
|
|
218
|
+
* @param field - The field name of the column to show
|
|
219
|
+
*/
|
|
220
|
+
showColumn(e) {
|
|
221
|
+
this.grid.setColumnVisible(e, !0);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Hide a specific column.
|
|
225
|
+
* Delegates to grid.setColumnVisible().
|
|
226
|
+
* @param field - The field name of the column to hide
|
|
227
|
+
*/
|
|
228
|
+
hideColumn(e) {
|
|
229
|
+
this.grid.setColumnVisible(e, !1);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get all columns with their visibility status.
|
|
233
|
+
* Useful for building visibility UI.
|
|
234
|
+
* @returns Array of column info with visibility status
|
|
235
|
+
*/
|
|
236
|
+
getAllColumns() {
|
|
237
|
+
return this.grid.getAllColumns();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Check if the sidebar panel is currently open.
|
|
241
|
+
* @returns True if the panel is open
|
|
242
|
+
*/
|
|
243
|
+
isPanelVisible() {
|
|
244
|
+
return this.grid.activeToolPanel === g.PANEL_ID;
|
|
245
|
+
}
|
|
246
|
+
// ===== Private Methods =====
|
|
247
|
+
/**
|
|
248
|
+
* Render the panel content into the shell's tool panel container.
|
|
249
|
+
* Returns a cleanup function.
|
|
250
|
+
*/
|
|
251
|
+
renderPanelContent(e) {
|
|
252
|
+
const t = this.grid, s = document.createElement("div");
|
|
253
|
+
s.className = "tbw-visibility-content";
|
|
254
|
+
const o = document.createElement("div");
|
|
255
|
+
o.className = "tbw-visibility-list", s.appendChild(o);
|
|
256
|
+
const i = document.createElement("button");
|
|
257
|
+
return i.className = "tbw-visibility-show-all", i.textContent = "Show All", i.addEventListener("click", () => {
|
|
258
|
+
t.showAllColumns(), this.rebuildToggles(o);
|
|
259
|
+
}), s.appendChild(i), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(s), () => {
|
|
260
|
+
this.columnListElement = null, s.remove();
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Check if a reorder plugin is present (by name to avoid static import).
|
|
265
|
+
*/
|
|
266
|
+
hasReorderPlugin() {
|
|
267
|
+
const e = this.grid?.getPluginByName?.("reorder");
|
|
268
|
+
return !!(e && typeof e.moveColumn == "function");
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Build the column toggle checkboxes.
|
|
272
|
+
* When a reorder plugin is present, adds drag handles for reordering.
|
|
273
|
+
*/
|
|
274
|
+
rebuildToggles(e) {
|
|
275
|
+
const t = this.grid, s = this.hasReorderPlugin();
|
|
276
|
+
e.innerHTML = "";
|
|
277
|
+
const o = t.getAllColumns();
|
|
278
|
+
for (let i = 0; i < o.length; i++) {
|
|
279
|
+
const l = o[i], n = l.header || l.field, r = document.createElement("div");
|
|
280
|
+
r.className = l.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", r.setAttribute("data-field", l.field), r.setAttribute("data-index", String(i)), s && h(l) && (r.draggable = !0, r.classList.add("reorderable"), this.setupDragListeners(r, l.field, i, e));
|
|
281
|
+
const d = document.createElement("label");
|
|
282
|
+
d.className = "tbw-visibility-label";
|
|
283
|
+
const a = document.createElement("input");
|
|
284
|
+
a.type = "checkbox", a.checked = l.visible, a.disabled = l.lockVisible ?? !1, a.addEventListener("change", () => {
|
|
285
|
+
t.toggleColumnVisibility(l.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
286
|
+
});
|
|
287
|
+
const u = document.createElement("span");
|
|
288
|
+
if (u.textContent = n, d.appendChild(a), d.appendChild(u), s && h(l)) {
|
|
289
|
+
const c = document.createElement("span");
|
|
290
|
+
c.className = "tbw-visibility-handle", c.textContent = "⋮⋮", c.title = "Drag to reorder", r.appendChild(c);
|
|
291
|
+
}
|
|
292
|
+
r.appendChild(d), e.appendChild(r);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Set up drag-and-drop event listeners for a row.
|
|
297
|
+
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
298
|
+
*/
|
|
299
|
+
setupDragListeners(e, t, s, o) {
|
|
300
|
+
e.addEventListener("dragstart", (i) => {
|
|
301
|
+
this.isDragging = !0, this.draggedField = t, this.draggedIndex = s, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
|
|
302
|
+
}), e.addEventListener("dragend", () => {
|
|
303
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((i) => {
|
|
304
|
+
i.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
305
|
+
});
|
|
306
|
+
}), e.addEventListener("dragover", (i) => {
|
|
307
|
+
if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
308
|
+
const l = e.getBoundingClientRect(), n = l.top + l.height / 2;
|
|
309
|
+
this.dropIndex = i.clientY < n ? s : s + 1, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
|
|
310
|
+
r !== e && r.classList.remove("drop-target", "drop-before", "drop-after");
|
|
311
|
+
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < n), e.classList.toggle("drop-after", i.clientY >= n);
|
|
312
|
+
}), e.addEventListener("dragleave", () => {
|
|
313
|
+
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
314
|
+
}), e.addEventListener("drop", (i) => {
|
|
315
|
+
i.preventDefault();
|
|
316
|
+
const l = this.draggedField, n = this.draggedIndex, r = this.dropIndex;
|
|
317
|
+
if (!this.isDragging || l === null || n === null || r === null)
|
|
318
|
+
return;
|
|
319
|
+
const d = r > n ? r - 1 : r;
|
|
320
|
+
if (d !== n) {
|
|
321
|
+
const a = {
|
|
322
|
+
field: l,
|
|
323
|
+
fromIndex: n,
|
|
324
|
+
toIndex: d
|
|
325
|
+
};
|
|
326
|
+
this.emit("column-reorder-request", a), setTimeout(() => {
|
|
327
|
+
this.rebuildToggles(o);
|
|
328
|
+
}, 0);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
// ===== Styles =====
|
|
333
|
+
styles = `
|
|
334
|
+
.tbw-visibility-content {
|
|
335
|
+
display: flex;
|
|
336
|
+
flex-direction: column;
|
|
337
|
+
height: 100%;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.tbw-visibility-list {
|
|
341
|
+
flex: 1;
|
|
342
|
+
overflow-y: auto;
|
|
343
|
+
padding: 8px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.tbw-visibility-row {
|
|
347
|
+
display: flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
gap: 8px;
|
|
350
|
+
padding: 6px 4px;
|
|
351
|
+
cursor: pointer;
|
|
352
|
+
font-size: 13px;
|
|
353
|
+
border-radius: var(--tbw-border-radius, 4px);
|
|
354
|
+
position: relative;
|
|
355
|
+
}
|
|
356
|
+
.tbw-visibility-row:hover {
|
|
357
|
+
background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));
|
|
358
|
+
}
|
|
359
|
+
.tbw-visibility-row input[type="checkbox"] {
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
}
|
|
362
|
+
.tbw-visibility-row.locked span {
|
|
363
|
+
color: var(--tbw-color-fg-muted, #888);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/* Drag handle */
|
|
367
|
+
.tbw-visibility-handle {
|
|
368
|
+
cursor: grab;
|
|
369
|
+
color: var(--tbw-color-fg-muted, #888);
|
|
370
|
+
font-size: 10px;
|
|
371
|
+
letter-spacing: -2px;
|
|
372
|
+
user-select: none;
|
|
373
|
+
flex-shrink: 0;
|
|
374
|
+
}
|
|
375
|
+
.tbw-visibility-row.reorderable:hover .tbw-visibility-handle {
|
|
376
|
+
color: var(--tbw-color-fg, #1f2937);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/* Label wrapper for checkbox and text */
|
|
380
|
+
.tbw-visibility-label {
|
|
381
|
+
display: flex;
|
|
382
|
+
align-items: center;
|
|
383
|
+
gap: 8px;
|
|
384
|
+
flex: 1;
|
|
385
|
+
cursor: pointer;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/* Drag states */
|
|
389
|
+
.tbw-visibility-row.dragging {
|
|
390
|
+
opacity: 0.5;
|
|
391
|
+
cursor: grabbing;
|
|
392
|
+
}
|
|
393
|
+
.tbw-visibility-row.drop-before::before {
|
|
394
|
+
content: '';
|
|
395
|
+
position: absolute;
|
|
396
|
+
left: 0;
|
|
397
|
+
right: 0;
|
|
398
|
+
top: 0;
|
|
399
|
+
height: 2px;
|
|
400
|
+
background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));
|
|
401
|
+
}
|
|
402
|
+
.tbw-visibility-row.drop-after::after {
|
|
403
|
+
content: '';
|
|
404
|
+
position: absolute;
|
|
405
|
+
left: 0;
|
|
406
|
+
right: 0;
|
|
407
|
+
bottom: 0;
|
|
408
|
+
height: 2px;
|
|
409
|
+
background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.tbw-visibility-show-all {
|
|
413
|
+
margin: 8px;
|
|
414
|
+
padding: 8px 12px;
|
|
415
|
+
border: 1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));
|
|
416
|
+
border-radius: var(--tbw-border-radius, 4px);
|
|
417
|
+
background: var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));
|
|
418
|
+
color: var(--tbw-color-fg, #1f2937);
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
font-size: 13px;
|
|
421
|
+
}
|
|
422
|
+
.tbw-visibility-show-all:hover {
|
|
423
|
+
background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));
|
|
424
|
+
}
|
|
425
|
+
`;
|
|
426
|
+
}
|
|
427
|
+
export {
|
|
428
|
+
g as VisibilityPlugin
|
|
429
|
+
};
|
|
430
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../libs/grid/src/lib/core/plugin/base-plugin.ts","../../../../../../libs/grid/src/lib/plugins/visibility/VisibilityPlugin.ts"],"sourcesContent":["/**\r\n * Base Grid Plugin Class\r\n *\r\n * All plugins extend this abstract class.\r\n * Plugins are instantiated per-grid and manage their own state.\r\n */\r\n\r\nimport type { ColumnConfig, ColumnState, HeaderContentDefinition, ToolPanelDefinition } from '../types';\r\n\r\n// Forward declare to avoid circular imports\r\nexport interface GridElement {\r\n shadowRoot: ShadowRoot | null;\r\n rows: any[];\r\n columns: ColumnConfig[];\r\n gridConfig: any;\r\n requestRender(): void;\r\n requestAfterRender(): void;\r\n forceLayout(): Promise<void>;\r\n getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined;\r\n getPluginByName(name: string): BaseGridPlugin | undefined;\r\n dispatchEvent(event: Event): boolean;\r\n}\r\n\r\n/**\r\n * Keyboard modifier flags\r\n */\r\nexport interface KeyboardModifiers {\r\n ctrl?: boolean;\r\n shift?: boolean;\r\n alt?: boolean;\r\n meta?: boolean;\r\n}\r\n\r\n/**\r\n * Cell coordinates\r\n */\r\nexport interface CellCoords {\r\n row: number;\r\n col: number;\r\n}\r\n\r\n/**\r\n * Cell click event\r\n */\r\nexport interface CellClickEvent {\r\n rowIndex: number;\r\n colIndex: number;\r\n field: string;\r\n value: any;\r\n row: any;\r\n cellEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Row click event\r\n */\r\nexport interface RowClickEvent {\r\n rowIndex: number;\r\n row: any;\r\n rowEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Header click event\r\n */\r\nexport interface HeaderClickEvent {\r\n colIndex: number;\r\n field: string;\r\n column: ColumnConfig;\r\n headerEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Scroll event\r\n */\r\nexport interface ScrollEvent {\r\n scrollTop: number;\r\n scrollLeft: number;\r\n scrollHeight: number;\r\n scrollWidth: number;\r\n clientHeight: number;\r\n clientWidth: number;\r\n originalEvent?: Event;\r\n}\r\n\r\n/**\r\n * Cell mouse event (for drag operations, selection, etc.)\r\n */\r\nexport interface CellMouseEvent {\r\n /** Event type: mousedown, mousemove, or mouseup */\r\n type: 'mousedown' | 'mousemove' | 'mouseup';\r\n /** Row index, undefined if not over a data cell */\r\n rowIndex?: number;\r\n /** Column index, undefined if not over a cell */\r\n colIndex?: number;\r\n /** Field name, undefined if not over a cell */\r\n field?: string;\r\n /** Cell value, undefined if not over a data cell */\r\n value?: unknown;\r\n /** Row data object, undefined if not over a data row */\r\n row?: unknown;\r\n /** Column configuration, undefined if not over a column */\r\n column?: ColumnConfig;\r\n /** The cell element, undefined if not over a cell */\r\n cellElement?: HTMLElement;\r\n /** The row element, undefined if not over a row */\r\n rowElement?: HTMLElement;\r\n /** Whether the event is over a header cell */\r\n isHeader: boolean;\r\n /** Cell coordinates if over a valid data cell */\r\n cell?: CellCoords;\r\n /** The original mouse event */\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Context menu parameters\r\n */\r\nexport interface ContextMenuParams {\r\n x: number;\r\n y: number;\r\n rowIndex?: number;\r\n colIndex?: number;\r\n field?: string;\r\n value?: any;\r\n row?: any;\r\n column?: ColumnConfig;\r\n isHeader?: boolean;\r\n}\r\n\r\n/**\r\n * Context menu item\r\n */\r\nexport interface ContextMenuItem {\r\n id: string;\r\n label: string;\r\n icon?: string;\r\n disabled?: boolean;\r\n separator?: boolean;\r\n children?: ContextMenuItem[];\r\n action?: (params: ContextMenuParams) => void;\r\n}\r\n\r\n/**\r\n * Cell render context for plugin cell renderers.\r\n * Provides full context including position and editing state.\r\n *\r\n * Note: This differs from the core `CellRenderContext` in types.ts which is\r\n * simpler and used for column view renderers. This version provides additional\r\n * context needed by plugins that register custom cell renderers.\r\n */\r\nexport interface PluginCellRenderContext {\r\n /** The cell value */\r\n value: any;\r\n /** The field/column key */\r\n field: string;\r\n /** The row data object */\r\n row: any;\r\n /** Row index in the data array */\r\n rowIndex: number;\r\n /** Column index */\r\n colIndex: number;\r\n /** Column configuration */\r\n column: ColumnConfig;\r\n /** Whether the cell is currently in edit mode */\r\n isEditing: boolean;\r\n}\r\n\r\n/**\r\n * Header render context for plugin header renderers.\r\n */\r\nexport interface PluginHeaderRenderContext {\r\n /** Column configuration */\r\n column: ColumnConfig;\r\n /** Column index */\r\n colIndex: number;\r\n}\r\n\r\n/**\r\n * Cell renderer function type for plugins.\r\n */\r\nexport type CellRenderer = (ctx: PluginCellRenderContext) => string | HTMLElement;\r\n\r\n/**\r\n * Header renderer function type for plugins.\r\n */\r\nexport type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string | HTMLElement;\r\n\r\n/**\r\n * Cell editor interface for plugins.\r\n */\r\nexport interface CellEditor {\r\n create(ctx: PluginCellRenderContext, commitFn: (value: any) => void, cancelFn: () => void): HTMLElement;\r\n getValue?(element: HTMLElement): any;\r\n focus?(element: HTMLElement): void;\r\n}\r\n\r\n/**\r\n * Abstract base class for all grid plugins.\r\n *\r\n * @template TConfig - Configuration type for the plugin\r\n */\r\nexport abstract class BaseGridPlugin<TConfig = unknown> {\r\n /** Unique plugin identifier (derived from class name by default) */\r\n abstract readonly name: string;\r\n\r\n /** Plugin version - override in subclass if needed */\r\n readonly version: string = '1.0.0';\r\n\r\n /** CSS styles to inject into the grid's shadow DOM */\r\n readonly styles?: string;\r\n\r\n /** Custom cell renderers keyed by type name */\r\n readonly cellRenderers?: Record<string, CellRenderer>;\r\n\r\n /** Custom header renderers keyed by type name */\r\n readonly headerRenderers?: Record<string, HeaderRenderer>;\r\n\r\n /** Custom cell editors keyed by type name */\r\n readonly cellEditors?: Record<string, CellEditor>;\r\n\r\n /** The grid instance this plugin is attached to */\r\n protected grid!: GridElement;\r\n\r\n /** Plugin configuration - merged with defaults in attach() */\r\n protected config!: TConfig;\r\n\r\n /** User-provided configuration from constructor */\r\n private readonly userConfig: Partial<TConfig>;\r\n\r\n /**\r\n * Default configuration - subclasses should override this getter.\r\n * Note: This must be a getter (not property initializer) for proper inheritance\r\n * since property initializers run after parent constructor.\r\n */\r\n protected get defaultConfig(): Partial<TConfig> {\r\n return {};\r\n }\r\n\r\n constructor(config: Partial<TConfig> = {}) {\r\n this.userConfig = config;\r\n }\r\n\r\n /**\r\n * Called when the plugin is attached to a grid.\r\n * Override to set up event listeners, initialize state, etc.\r\n */\r\n attach(grid: GridElement): void {\r\n this.grid = grid;\r\n // Merge config here (after subclass construction is complete)\r\n this.config = { ...this.defaultConfig, ...this.userConfig } as TConfig;\r\n }\r\n\r\n /**\r\n * Called when the plugin is detached from a grid.\r\n * Override to clean up event listeners, timers, etc.\r\n */\r\n detach(): void {\r\n // Override in subclass\r\n }\r\n\r\n /**\r\n * Get another plugin instance from the same grid.\r\n * Use for inter-plugin communication.\r\n */\r\n protected getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined {\r\n return this.grid?.getPlugin(PluginClass);\r\n }\r\n\r\n /**\r\n * Emit a custom event from the grid.\r\n */\r\n protected emit<T>(eventName: string, detail: T): void {\r\n this.grid?.dispatchEvent?.(new CustomEvent(eventName, { detail, bubbles: true }));\r\n }\r\n\r\n /**\r\n * Request a re-render of the grid.\r\n */\r\n protected requestRender(): void {\r\n this.grid?.requestRender?.();\r\n }\r\n\r\n /**\r\n * Request a lightweight style update without rebuilding DOM.\r\n * Use this instead of requestRender() when only CSS classes need updating.\r\n */\r\n protected requestAfterRender(): void {\r\n this.grid?.requestAfterRender?.();\r\n }\r\n\r\n /**\r\n * Get the current rows from the grid.\r\n */\r\n protected get rows(): any[] {\r\n return this.grid?.rows ?? [];\r\n }\r\n\r\n /**\r\n * Get the original unfiltered/unprocessed rows from the grid.\r\n * Use this when you need all source data regardless of active filters.\r\n */\r\n protected get sourceRows(): any[] {\r\n return (this.grid as any)?.sourceRows ?? [];\r\n }\r\n\r\n /**\r\n * Get the current columns from the grid.\r\n */\r\n protected get columns(): ColumnConfig[] {\r\n return this.grid?.columns ?? [];\r\n }\r\n\r\n /**\r\n * Get only visible columns from the grid (excludes hidden).\r\n * Use this for rendering that needs to match the grid template.\r\n */\r\n protected get visibleColumns(): ColumnConfig[] {\r\n return (this.grid as any)?.visibleColumns ?? [];\r\n }\r\n\r\n /**\r\n * Get the shadow root of the grid.\r\n */\r\n protected get shadowRoot(): ShadowRoot | null {\r\n return this.grid?.shadowRoot ?? null;\r\n }\r\n\r\n /**\r\n * Log a warning message.\r\n */\r\n protected warn(message: string): void {\r\n console.warn(`[tbw-grid:${this.name}] ${message}`);\r\n }\r\n\r\n // ===== Lifecycle Hooks (override as needed) =====\r\n\r\n /**\r\n * Transform rows before rendering.\r\n * Called during each render cycle before rows are rendered to the DOM.\r\n * Use this to filter, sort, or add computed properties to rows.\r\n *\r\n * @param rows - The current rows array (readonly to encourage returning a new array)\r\n * @returns The modified rows array to render\r\n *\r\n * @example\r\n * ```ts\r\n * processRows(rows: readonly any[]): any[] {\r\n * // Filter out hidden rows\r\n * return rows.filter(row => !row._hidden);\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * processRows(rows: readonly any[]): any[] {\r\n * // Add computed properties\r\n * return rows.map(row => ({\r\n * ...row,\r\n * _fullName: `${row.firstName} ${row.lastName}`\r\n * }));\r\n * }\r\n * ```\r\n */\r\n processRows?(rows: readonly any[]): any[];\r\n\r\n /**\r\n * Transform columns before rendering.\r\n * Called during each render cycle before column headers and cells are rendered.\r\n * Use this to add, remove, or modify column definitions.\r\n *\r\n * @param columns - The current columns array (readonly to encourage returning a new array)\r\n * @returns The modified columns array to render\r\n *\r\n * @example\r\n * ```ts\r\n * processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\r\n * // Add a selection checkbox column\r\n * return [\r\n * { field: '_select', header: '', width: 40 },\r\n * ...columns\r\n * ];\r\n * }\r\n * ```\r\n */\r\n processColumns?(columns: readonly ColumnConfig[]): ColumnConfig[];\r\n\r\n /**\r\n * Called before each render cycle begins.\r\n * Use this to prepare state or cache values needed during rendering.\r\n *\r\n * @example\r\n * ```ts\r\n * beforeRender(): void {\r\n * this.visibleRowCount = this.calculateVisibleRows();\r\n * }\r\n * ```\r\n */\r\n beforeRender?(): void;\r\n\r\n /**\r\n * Called after each render cycle completes.\r\n * Use this for DOM manipulation, adding event listeners to rendered elements,\r\n * or applying visual effects like selection highlights.\r\n *\r\n * @example\r\n * ```ts\r\n * afterRender(): void {\r\n * // Apply selection styling to rendered rows\r\n * const rows = this.shadowRoot?.querySelectorAll('.data-row');\r\n * rows?.forEach((row, i) => {\r\n * row.classList.toggle('selected', this.selectedRows.has(i));\r\n * });\r\n * }\r\n * ```\r\n */\r\n afterRender?(): void;\r\n\r\n /**\r\n * Render a custom row, bypassing the default row rendering.\r\n * Use this for special row types like group headers, detail rows, or footers.\r\n *\r\n * @param row - The row data object\r\n * @param rowEl - The row DOM element to render into\r\n * @param rowIndex - The index of the row in the data array\r\n * @returns `true` if the plugin handled rendering (prevents default), `false`/`void` for default rendering\r\n *\r\n * @example\r\n * ```ts\r\n * renderRow(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void {\r\n * if (row._isGroupHeader) {\r\n * rowEl.innerHTML = `<div class=\"group-header\">${row._groupLabel}</div>`;\r\n * return true; // Handled - skip default rendering\r\n * }\r\n * // Return void to let default rendering proceed\r\n * }\r\n * ```\r\n */\r\n renderRow?(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void;\r\n\r\n // ===== Interaction Hooks (override as needed) =====\r\n\r\n /**\r\n * Handle keyboard events on the grid.\r\n * Called when a key is pressed while the grid or a cell has focus.\r\n *\r\n * @param event - The native KeyboardEvent\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onKeyDown(event: KeyboardEvent): boolean | void {\r\n * // Handle Ctrl+A for select all\r\n * if (event.ctrlKey && event.key === 'a') {\r\n * this.selectAllRows();\r\n * return true; // Prevent default browser select-all\r\n * }\r\n * }\r\n * ```\r\n */\r\n onKeyDown?(event: KeyboardEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell click events.\r\n * Called when a data cell is clicked (not headers).\r\n *\r\n * @param event - Cell click event with row/column context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onCellClick(event: CellClickEvent): boolean | void {\r\n * if (event.field === '_select') {\r\n * this.toggleRowSelection(event.rowIndex);\r\n * return true; // Handled\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellClick?(event: CellClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle row click events.\r\n * Called when any part of a data row is clicked.\r\n * Note: This is called in addition to onCellClick, not instead of.\r\n *\r\n * @param event - Row click event with row context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onRowClick(event: RowClickEvent): boolean | void {\r\n * if (this.config.mode === 'row') {\r\n * this.selectRow(event.rowIndex, event.originalEvent);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onRowClick?(event: RowClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle header click events.\r\n * Called when a column header is clicked. Commonly used for sorting.\r\n *\r\n * @param event - Header click event with column context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onHeaderClick(event: HeaderClickEvent): boolean | void {\r\n * if (event.column.sortable !== false) {\r\n * this.toggleSort(event.field);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onHeaderClick?(event: HeaderClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle scroll events on the grid viewport.\r\n * Called during scrolling. Note: This may be called frequently; debounce if needed.\r\n *\r\n * @param event - Scroll event with scroll position and viewport dimensions\r\n *\r\n * @example\r\n * ```ts\r\n * onScroll(event: ScrollEvent): void {\r\n * // Update sticky column positions\r\n * this.updateStickyPositions(event.scrollLeft);\r\n * }\r\n * ```\r\n */\r\n onScroll?(event: ScrollEvent): void;\r\n\r\n /**\r\n * Handle cell mousedown events.\r\n * Used for initiating drag operations like range selection or column resize.\r\n *\r\n * @param event - Mouse event with cell context\r\n * @returns `true` to indicate drag started (prevents text selection), `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseDown(event: CellMouseEvent): boolean | void {\r\n * if (event.rowIndex !== undefined && this.config.mode === 'range') {\r\n * this.startDragSelection(event.rowIndex, event.colIndex);\r\n * return true; // Prevent text selection\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseDown?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell mousemove events during drag operations.\r\n * Only called when a drag is in progress (after mousedown returned true).\r\n *\r\n * @param event - Mouse event with current cell context\r\n * @returns `true` to continue handling the drag, `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseMove(event: CellMouseEvent): boolean | void {\r\n * if (this.isDragging && event.rowIndex !== undefined) {\r\n * this.extendSelection(event.rowIndex, event.colIndex);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseMove?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell mouseup events to end drag operations.\r\n *\r\n * @param event - Mouse event with final cell context\r\n * @returns `true` if drag was finalized, `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseUp(event: CellMouseEvent): boolean | void {\r\n * if (this.isDragging) {\r\n * this.finalizeDragSelection();\r\n * this.isDragging = false;\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseUp?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Provide context menu items when right-clicking on the grid.\r\n * Multiple plugins can contribute items; they are merged into a single menu.\r\n *\r\n * @param params - Context about where the menu was triggered (row, column, etc.)\r\n * @returns Array of menu items to display\r\n *\r\n * @example\r\n * ```ts\r\n * getContextMenuItems(params: ContextMenuParams): ContextMenuItem[] {\r\n * if (params.isHeader) {\r\n * return [\r\n * { id: 'sort-asc', label: 'Sort Ascending', action: () => this.sortAsc(params.field) },\r\n * { id: 'sort-desc', label: 'Sort Descending', action: () => this.sortDesc(params.field) },\r\n * ];\r\n * }\r\n * return [\r\n * { id: 'copy', label: 'Copy Cell', action: () => this.copyCell(params) },\r\n * ];\r\n * }\r\n * ```\r\n */\r\n getContextMenuItems?(params: ContextMenuParams): ContextMenuItem[];\r\n\r\n // ===== Column State Hooks (override as needed) =====\r\n\r\n /**\r\n * Contribute plugin-specific state for a column.\r\n * Called by the grid when collecting column state for serialization.\r\n * Plugins can add their own properties to the column state.\r\n *\r\n * @param field - The field name of the column\r\n * @returns Partial column state with plugin-specific properties, or undefined if no state to contribute\r\n *\r\n * @example\r\n * ```ts\r\n * getColumnState(field: string): Partial<ColumnState> | undefined {\r\n * const filterModel = this.filterModels.get(field);\r\n * if (filterModel) {\r\n * // Uses module augmentation to add filter property to ColumnState\r\n * return { filter: filterModel } as Partial<ColumnState>;\r\n * }\r\n * return undefined;\r\n * }\r\n * ```\r\n */\r\n getColumnState?(field: string): Partial<ColumnState> | undefined;\r\n\r\n /**\r\n * Apply plugin-specific state to a column.\r\n * Called by the grid when restoring column state from serialized data.\r\n * Plugins should restore their internal state based on the provided state.\r\n *\r\n * @param field - The field name of the column\r\n * @param state - The column state to apply (may contain plugin-specific properties)\r\n *\r\n * @example\r\n * ```ts\r\n * applyColumnState(field: string, state: ColumnState): void {\r\n * // Check for filter property added via module augmentation\r\n * const filter = (state as any).filter;\r\n * if (filter) {\r\n * this.filterModels.set(field, filter);\r\n * this.applyFilter();\r\n * }\r\n * }\r\n * ```\r\n */\r\n applyColumnState?(field: string, state: ColumnState): void;\r\n\r\n // ===== Shell Integration Hooks (override as needed) =====\r\n\r\n /**\r\n * Register a tool panel for this plugin.\r\n * Return undefined if plugin has no tool panel.\r\n * The shell will create a toolbar toggle button and render the panel content\r\n * when the user opens the panel.\r\n *\r\n * @returns Tool panel definition, or undefined if plugin has no panel\r\n *\r\n * @example\r\n * ```ts\r\n * getToolPanel(): ToolPanelDefinition | undefined {\r\n * return {\r\n * id: 'columns',\r\n * title: 'Columns',\r\n * icon: '☰',\r\n * tooltip: 'Show/hide columns',\r\n * order: 10,\r\n * render: (container) => {\r\n * this.renderColumnList(container);\r\n * return () => this.cleanup();\r\n * },\r\n * };\r\n * }\r\n * ```\r\n */\r\n getToolPanel?(): ToolPanelDefinition | undefined;\r\n\r\n /**\r\n * Register content for the shell header center section.\r\n * Return undefined if plugin has no header content.\r\n * Examples: search input, selection summary, status indicators.\r\n *\r\n * @returns Header content definition, or undefined if plugin has no header content\r\n *\r\n * @example\r\n * ```ts\r\n * getHeaderContent(): HeaderContentDefinition | undefined {\r\n * return {\r\n * id: 'quick-filter',\r\n * order: 10,\r\n * render: (container) => {\r\n * const input = document.createElement('input');\r\n * input.type = 'text';\r\n * input.placeholder = 'Search...';\r\n * input.addEventListener('input', this.handleInput);\r\n * container.appendChild(input);\r\n * return () => input.removeEventListener('input', this.handleInput);\r\n * },\r\n * };\r\n * }\r\n * ```\r\n */\r\n getHeaderContent?(): HeaderContentDefinition | undefined;\r\n}\r\n","/**\r\n * Column Visibility Plugin (Class-based)\r\n *\r\n * Provides a UI for column visibility control via the shell's tool panel system.\r\n * Column visibility is a core grid feature - this plugin provides:\r\n * - A tool panel for column visibility management (registered with the shell)\r\n * - Backward-compatible API methods that delegate to grid.setColumnVisible(), etc.\r\n *\r\n * The grid emits 'column-visibility' events when columns are shown/hidden,\r\n * allowing consumers to save user preferences.\r\n *\r\n * When a reorder plugin is present, column rows become draggable for reordering.\r\n * Drag-drop emits 'column-reorder-request' events that the ReorderPlugin can listen for.\r\n */\r\n\r\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\r\nimport type { ColumnConfig, ToolPanelDefinition } from '../../core/types';\r\nimport type { VisibilityConfig } from './types';\r\n\r\n/**\r\n * Detail for column-reorder-request events emitted when users drag-drop in the visibility panel.\r\n */\r\nexport interface ColumnReorderRequestDetail {\r\n /** The field name of the column to move */\r\n field: string;\r\n /** The source index (before move) */\r\n fromIndex: number;\r\n /** The target index (after move) */\r\n toIndex: number;\r\n}\r\n\r\n/**\r\n * Check if a column can be moved (respects lockPosition/suppressMovable).\r\n * Inlined to avoid importing from reorder plugin.\r\n */\r\nfunction canMoveColumn(column: ColumnConfig): boolean {\r\n const meta = column.meta ?? {};\r\n return meta.lockPosition !== true && meta.suppressMovable !== true;\r\n}\r\n\r\n/** Extended grid interface with visibility methods */\r\ninterface GridWithVisibility {\r\n shadowRoot: ShadowRoot | null;\r\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }>;\r\n setColumnVisible(field: string, visible: boolean): void;\r\n toggleColumnVisibility(field: string): void;\r\n showAllColumns(): void;\r\n isColumnVisible(field: string): boolean;\r\n requestRender(): void;\r\n openToolPanel(id: string): void;\r\n closeToolPanel(): void;\r\n toggleToolPanel(id: string): void;\r\n activeToolPanel: string | undefined;\r\n}\r\n\r\n/**\r\n * Column Visibility Plugin for tbw-grid\r\n *\r\n * @example\r\n * ```ts\r\n * new VisibilityPlugin({ enabled: true, allowHideAll: false })\r\n * ```\r\n */\r\nexport class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {\r\n readonly name = 'visibility';\r\n override readonly version = '1.0.0';\r\n\r\n /** Tool panel ID for shell integration */\r\n static readonly PANEL_ID = 'columns';\r\n\r\n protected override get defaultConfig(): Partial<VisibilityConfig> {\r\n return {\r\n enabled: true,\r\n allowHideAll: false,\r\n };\r\n }\r\n\r\n // ===== Internal State =====\r\n private columnListElement: HTMLElement | null = null;\r\n\r\n // Drag state for reorder integration\r\n private isDragging = false;\r\n private draggedField: string | null = null;\r\n private draggedIndex: number | null = null;\r\n private dropIndex: number | null = null;\r\n\r\n // ===== Lifecycle =====\r\n\r\n override detach(): void {\r\n this.columnListElement = null;\r\n this.isDragging = false;\r\n this.draggedField = null;\r\n this.draggedIndex = null;\r\n this.dropIndex = null;\r\n }\r\n\r\n // ===== Shell Integration =====\r\n\r\n /**\r\n * Register the column visibility tool panel with the shell.\r\n */\r\n override getToolPanel(): ToolPanelDefinition | undefined {\r\n if (!this.config.enabled) return undefined;\r\n\r\n return {\r\n id: VisibilityPlugin.PANEL_ID,\r\n title: 'Columns',\r\n icon: '☰',\r\n tooltip: 'Column visibility',\r\n order: 100, // High order so it appears last\r\n render: (container) => this.renderPanelContent(container),\r\n };\r\n }\r\n\r\n // ===== Public API =====\r\n\r\n /**\r\n * Show the visibility sidebar panel.\r\n */\r\n show(): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.openToolPanel(VisibilityPlugin.PANEL_ID);\r\n }\r\n\r\n /**\r\n * Hide the visibility sidebar panel.\r\n */\r\n hide(): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.closeToolPanel();\r\n }\r\n\r\n /**\r\n * Toggle the visibility sidebar panel.\r\n */\r\n toggle(): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.toggleToolPanel(VisibilityPlugin.PANEL_ID);\r\n }\r\n\r\n /**\r\n * Check if a specific column is visible.\r\n * Delegates to grid.isColumnVisible().\r\n * @param field - The field name to check\r\n * @returns True if the column is visible\r\n */\r\n isColumnVisible(field: string): boolean {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n return grid.isColumnVisible(field);\r\n }\r\n\r\n /**\r\n * Set visibility for a specific column.\r\n * Delegates to grid.setColumnVisible().\r\n * @param field - The field name of the column\r\n * @param visible - Whether the column should be visible\r\n */\r\n setColumnVisible(field: string, visible: boolean): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.setColumnVisible(field, visible);\r\n }\r\n\r\n /**\r\n * Get list of all visible column fields.\r\n * @returns Array of visible field names\r\n */\r\n getVisibleColumns(): string[] {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n return grid\r\n .getAllColumns()\r\n .filter((c) => c.visible)\r\n .map((c) => c.field);\r\n }\r\n\r\n /**\r\n * Get list of all hidden column fields.\r\n * @returns Array of hidden field names\r\n */\r\n getHiddenColumns(): string[] {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n return grid\r\n .getAllColumns()\r\n .filter((c) => !c.visible)\r\n .map((c) => c.field);\r\n }\r\n\r\n /**\r\n * Show all columns.\r\n * Delegates to grid.showAllColumns().\r\n */\r\n showAll(): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.showAllColumns();\r\n }\r\n\r\n /**\r\n * Toggle visibility for a specific column.\r\n * Delegates to grid.toggleColumnVisibility().\r\n * @param field - The field name of the column\r\n */\r\n toggleColumn(field: string): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.toggleColumnVisibility(field);\r\n }\r\n\r\n /**\r\n * Show a specific column.\r\n * Delegates to grid.setColumnVisible().\r\n * @param field - The field name of the column to show\r\n */\r\n showColumn(field: string): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.setColumnVisible(field, true);\r\n }\r\n\r\n /**\r\n * Hide a specific column.\r\n * Delegates to grid.setColumnVisible().\r\n * @param field - The field name of the column to hide\r\n */\r\n hideColumn(field: string): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n grid.setColumnVisible(field, false);\r\n }\r\n\r\n /**\r\n * Get all columns with their visibility status.\r\n * Useful for building visibility UI.\r\n * @returns Array of column info with visibility status\r\n */\r\n getAllColumns(): Array<{ field: string; header: string; visible: boolean; lockVisible?: boolean }> {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n return grid.getAllColumns();\r\n }\r\n\r\n /**\r\n * Check if the sidebar panel is currently open.\r\n * @returns True if the panel is open\r\n */\r\n isPanelVisible(): boolean {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n return grid.activeToolPanel === VisibilityPlugin.PANEL_ID;\r\n }\r\n\r\n // ===== Private Methods =====\r\n\r\n /**\r\n * Render the panel content into the shell's tool panel container.\r\n * Returns a cleanup function.\r\n */\r\n private renderPanelContent(container: HTMLElement): (() => void) | void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n\r\n // Create content wrapper\r\n const wrapper = document.createElement('div');\r\n wrapper.className = 'tbw-visibility-content';\r\n\r\n // Column list container\r\n const columnList = document.createElement('div');\r\n columnList.className = 'tbw-visibility-list';\r\n wrapper.appendChild(columnList);\r\n\r\n // Show all button\r\n const showAllBtn = document.createElement('button');\r\n showAllBtn.className = 'tbw-visibility-show-all';\r\n showAllBtn.textContent = 'Show All';\r\n showAllBtn.addEventListener('click', () => {\r\n grid.showAllColumns();\r\n this.rebuildToggles(columnList);\r\n });\r\n wrapper.appendChild(showAllBtn);\r\n\r\n // Store reference\r\n this.columnListElement = columnList;\r\n\r\n // Build initial toggles\r\n this.rebuildToggles(columnList);\r\n\r\n // Append to container\r\n container.appendChild(wrapper);\r\n\r\n // Return cleanup function\r\n return () => {\r\n this.columnListElement = null;\r\n wrapper.remove();\r\n };\r\n }\r\n\r\n /**\r\n * Check if a reorder plugin is present (by name to avoid static import).\r\n */\r\n private hasReorderPlugin(): boolean {\r\n const plugin = this.grid?.getPluginByName?.('reorder');\r\n // Duck-type check - just verify the plugin exists and has a moveColumn method\r\n return !!(plugin && typeof (plugin as { moveColumn?: unknown }).moveColumn === 'function');\r\n }\r\n\r\n /**\r\n * Build the column toggle checkboxes.\r\n * When a reorder plugin is present, adds drag handles for reordering.\r\n */\r\n private rebuildToggles(columnList: HTMLElement): void {\r\n const grid = this.grid as unknown as GridWithVisibility;\r\n const reorderEnabled = this.hasReorderPlugin();\r\n\r\n columnList.innerHTML = '';\r\n\r\n // getAllColumns() now returns columns in their effective display order\r\n const allColumns = grid.getAllColumns();\r\n\r\n for (let i = 0; i < allColumns.length; i++) {\r\n const col = allColumns[i];\r\n const label = col.header || col.field;\r\n\r\n const row = document.createElement('div');\r\n row.className = col.lockVisible ? 'tbw-visibility-row locked' : 'tbw-visibility-row';\r\n row.setAttribute('data-field', col.field);\r\n row.setAttribute('data-index', String(i));\r\n\r\n // Add drag handle if reorder is enabled\r\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\r\n row.draggable = true;\r\n row.classList.add('reorderable');\r\n\r\n this.setupDragListeners(row, col.field, i, columnList);\r\n }\r\n\r\n const labelWrapper = document.createElement('label');\r\n labelWrapper.className = 'tbw-visibility-label';\r\n\r\n const checkbox = document.createElement('input');\r\n checkbox.type = 'checkbox';\r\n checkbox.checked = col.visible;\r\n checkbox.disabled = col.lockVisible ?? false;\r\n checkbox.addEventListener('change', () => {\r\n grid.toggleColumnVisibility(col.field);\r\n // Refresh after toggle (grid may re-render)\r\n setTimeout(() => this.rebuildToggles(columnList), 0);\r\n });\r\n\r\n const text = document.createElement('span');\r\n text.textContent = label;\r\n\r\n labelWrapper.appendChild(checkbox);\r\n labelWrapper.appendChild(text);\r\n\r\n // Add drag handle icon if reorderable\r\n if (reorderEnabled && canMoveColumn(col as unknown as ColumnConfig)) {\r\n const handle = document.createElement('span');\r\n handle.className = 'tbw-visibility-handle';\r\n handle.textContent = '⋮⋮';\r\n handle.title = 'Drag to reorder';\r\n row.appendChild(handle);\r\n }\r\n\r\n row.appendChild(labelWrapper);\r\n columnList.appendChild(row);\r\n }\r\n }\r\n\r\n /**\r\n * Set up drag-and-drop event listeners for a row.\r\n * On drop, emits a 'column-reorder-request' event for other plugins to handle.\r\n */\r\n private setupDragListeners(row: HTMLElement, field: string, index: number, columnList: HTMLElement): void {\r\n row.addEventListener('dragstart', (e: DragEvent) => {\r\n this.isDragging = true;\r\n this.draggedField = field;\r\n this.draggedIndex = index;\r\n\r\n if (e.dataTransfer) {\r\n e.dataTransfer.effectAllowed = 'move';\r\n e.dataTransfer.setData('text/plain', field);\r\n }\r\n\r\n row.classList.add('dragging');\r\n });\r\n\r\n row.addEventListener('dragend', () => {\r\n this.isDragging = false;\r\n this.draggedField = null;\r\n this.draggedIndex = null;\r\n this.dropIndex = null;\r\n\r\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\r\n r.classList.remove('dragging', 'drop-target', 'drop-before', 'drop-after');\r\n });\r\n });\r\n\r\n row.addEventListener('dragover', (e: DragEvent) => {\r\n e.preventDefault();\r\n if (!this.isDragging || this.draggedField === field) return;\r\n\r\n const rect = row.getBoundingClientRect();\r\n const midY = rect.top + rect.height / 2;\r\n\r\n this.dropIndex = e.clientY < midY ? index : index + 1;\r\n\r\n // Clear other row highlights\r\n columnList.querySelectorAll('.tbw-visibility-row').forEach((r) => {\r\n if (r !== row) r.classList.remove('drop-target', 'drop-before', 'drop-after');\r\n });\r\n\r\n row.classList.add('drop-target');\r\n row.classList.toggle('drop-before', e.clientY < midY);\r\n row.classList.toggle('drop-after', e.clientY >= midY);\r\n });\r\n\r\n row.addEventListener('dragleave', () => {\r\n row.classList.remove('drop-target', 'drop-before', 'drop-after');\r\n });\r\n\r\n row.addEventListener('drop', (e: DragEvent) => {\r\n e.preventDefault();\r\n const draggedField = this.draggedField;\r\n const draggedIndex = this.draggedIndex;\r\n const dropIndex = this.dropIndex;\r\n\r\n if (!this.isDragging || draggedField === null || draggedIndex === null || dropIndex === null) {\r\n return;\r\n }\r\n\r\n // Calculate the effective target index\r\n const effectiveToIndex = dropIndex > draggedIndex ? dropIndex - 1 : dropIndex;\r\n\r\n if (effectiveToIndex !== draggedIndex) {\r\n // Emit a request event - other plugins (like ReorderPlugin) can listen and handle\r\n const detail: ColumnReorderRequestDetail = {\r\n field: draggedField,\r\n fromIndex: draggedIndex,\r\n toIndex: effectiveToIndex,\r\n };\r\n this.emit<ColumnReorderRequestDetail>('column-reorder-request', detail);\r\n\r\n // Rebuild the panel after reorder (deferred to allow re-render)\r\n setTimeout(() => {\r\n this.rebuildToggles(columnList);\r\n }, 0);\r\n }\r\n });\r\n }\r\n\r\n // ===== Styles =====\r\n\r\n override readonly styles = `\r\n .tbw-visibility-content {\r\n display: flex;\r\n flex-direction: column;\r\n height: 100%;\r\n }\r\n\r\n .tbw-visibility-list {\r\n flex: 1;\r\n overflow-y: auto;\r\n padding: 8px;\r\n }\r\n\r\n .tbw-visibility-row {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n padding: 6px 4px;\r\n cursor: pointer;\r\n font-size: 13px;\r\n border-radius: var(--tbw-border-radius, 4px);\r\n position: relative;\r\n }\r\n .tbw-visibility-row:hover {\r\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\r\n }\r\n .tbw-visibility-row input[type=\"checkbox\"] {\r\n cursor: pointer;\r\n }\r\n .tbw-visibility-row.locked span {\r\n color: var(--tbw-color-fg-muted, #888);\r\n }\r\n\r\n /* Drag handle */\r\n .tbw-visibility-handle {\r\n cursor: grab;\r\n color: var(--tbw-color-fg-muted, #888);\r\n font-size: 10px;\r\n letter-spacing: -2px;\r\n user-select: none;\r\n flex-shrink: 0;\r\n }\r\n .tbw-visibility-row.reorderable:hover .tbw-visibility-handle {\r\n color: var(--tbw-color-fg, #1f2937);\r\n }\r\n\r\n /* Label wrapper for checkbox and text */\r\n .tbw-visibility-label {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n flex: 1;\r\n cursor: pointer;\r\n }\r\n\r\n /* Drag states */\r\n .tbw-visibility-row.dragging {\r\n opacity: 0.5;\r\n cursor: grabbing;\r\n }\r\n .tbw-visibility-row.drop-before::before {\r\n content: '';\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n top: 0;\r\n height: 2px;\r\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\r\n }\r\n .tbw-visibility-row.drop-after::after {\r\n content: '';\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n height: 2px;\r\n background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));\r\n }\r\n\r\n .tbw-visibility-show-all {\r\n margin: 8px;\r\n padding: 8px 12px;\r\n border: 1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));\r\n border-radius: var(--tbw-border-radius, 4px);\r\n background: var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));\r\n color: var(--tbw-color-fg, #1f2937);\r\n cursor: pointer;\r\n font-size: 13px;\r\n }\r\n .tbw-visibility-show-all:hover {\r\n background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));\r\n }\r\n `;\r\n}\r\n"],"names":["BaseGridPlugin","config","grid","PluginClass","eventName","detail","message","canMoveColumn","column","meta","VisibilityPlugin","container","field","visible","c","wrapper","columnList","showAllBtn","plugin","reorderEnabled","allColumns","col","label","row","labelWrapper","checkbox","text","handle","index","e","r","rect","midY","draggedField","draggedIndex","dropIndex","effectiveToIndex"],"mappings":"AA6MO,MAAeA,EAAkC;AAAA;AAAA,EAK7C,UAAkB;AAAA;AAAA,EAGlB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGC;AAAA;AAAA,EAGA;AAAA;AAAA,EAGO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjB,IAAc,gBAAkC;AAC9C,WAAO,CAAA;AAAA,EACT;AAAA,EAEA,YAAYC,IAA2B,IAAI;AACzC,SAAK,aAAaA;AAAA,EACpB;AAAA;AAAA;AA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6F7B;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toolbox-web/grid",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "High-performance data grid web component",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./all": {
|
|
15
|
+
"types": "./all.d.ts",
|
|
16
|
+
"import": "./all.js"
|
|
17
|
+
},
|
|
18
|
+
"./plugins/*": {
|
|
19
|
+
"types": "./lib/plugins/*/index.d.ts",
|
|
20
|
+
"import": "./lib/plugins/*/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./themes/*": "./themes/*",
|
|
23
|
+
"./umd/*": "./umd/*"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"**/*.js",
|
|
27
|
+
"**/*.d.ts",
|
|
28
|
+
"**/*.css",
|
|
29
|
+
"**/*.map",
|
|
30
|
+
"custom-elements.json"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": [
|
|
33
|
+
"*.css"
|
|
34
|
+
],
|
|
35
|
+
"keywords": [
|
|
36
|
+
"web-component",
|
|
37
|
+
"data-grid",
|
|
38
|
+
"table",
|
|
39
|
+
"virtualization"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"author": "Oystein Amundsen",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/OysteinAmundsen/toolbox.git",
|
|
46
|
+
"directory": "libs/grid"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/OysteinAmundsen/toolbox/tree/main/libs/grid#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/OysteinAmundsen/toolbox/issues"
|
|
51
|
+
},
|
|
52
|
+
"customElements": "custom-elements.json"
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* High contrast accessibility-focused theme */
|
|
2
|
+
tbw-grid {
|
|
3
|
+
color-scheme: light dark;
|
|
4
|
+
--tbw-color-bg: light-dark(#ffffff, #000000);
|
|
5
|
+
--tbw-color-fg: light-dark(#000000, #ffffff);
|
|
6
|
+
--tbw-color-fg-muted: light-dark(#222222, #dddddd);
|
|
7
|
+
--tbw-color-border: light-dark(#000000, #ffffff);
|
|
8
|
+
--tbw-color-border-strong: light-dark(#000000, #ffffff);
|
|
9
|
+
--tbw-color-accent: light-dark(#c00000, #ff4d4d);
|
|
10
|
+
--tbw-color-accent-fg: #ffffff;
|
|
11
|
+
--tbw-color-selection: light-dark(#ffe9a8, #333333);
|
|
12
|
+
--tbw-color-row-alt: light-dark(#f2f2f2, #111111);
|
|
13
|
+
--tbw-color-row-hover: light-dark(#e6f2ff, #1c1c1c);
|
|
14
|
+
--tbw-color-header-bg: light-dark(#e8e8e8, #141414);
|
|
15
|
+
--tbw-color-border-cell: light-dark(#333, #eee);
|
|
16
|
+
--tbw-color-border-header: light-dark(#444, #ccc);
|
|
17
|
+
--tbw-resize-handle-color-hover: var(--tbw-color-accent);
|
|
18
|
+
--tbw-focus-outline: 2px solid var(--tbw-color-accent);
|
|
19
|
+
|
|
20
|
+
/* Typography & spacing */
|
|
21
|
+
--tbw-font-size: 14px;
|
|
22
|
+
--tbw-font-size-header: 17px;
|
|
23
|
+
--tbw-font-weight-header: bold;
|
|
24
|
+
--tbw-cell-padding-header: 15px 8px;
|
|
25
|
+
--tbw-cell-padding: 2px 8px;
|
|
26
|
+
--tbw-cell-padding-input: 2px 6px;
|
|
27
|
+
--tbw-row-height: 40px; /* taller rows */
|
|
28
|
+
--tbw-header-height: 44px;
|
|
29
|
+
--tbw-border-radius: 0;
|
|
30
|
+
--tbw-resize-handle-width: 6px;
|
|
31
|
+
--tbw-resize-handle-border-radius: 2px;
|
|
32
|
+
--tbw-checkbox-size: 20px;
|
|
33
|
+
--tbw-focus-outline-offset: 0;
|
|
34
|
+
--tbw-row-divider: 2px solid light-dark(#000000, #ffffff);
|
|
35
|
+
--tbw-border-header: 2px solid light-dark(#000000, #ffffff);
|
|
36
|
+
--tbw-editing-border: 2px solid var(--tbw-color-accent);
|
|
37
|
+
--tbw-active-row-outline: 2px solid var(--tbw-color-accent);
|
|
38
|
+
--tbw-row-hover-outline: 2px solid var(--tbw-color-accent);
|
|
39
|
+
--tbw-sort-indicator-color: var(--tbw-color-fg-muted);
|
|
40
|
+
--tbw-sort-indicator-active-color: var(--tbw-color-accent);
|
|
41
|
+
--tbw-transition-duration: 0ms; /* reduce motion */
|
|
42
|
+
--tbw-font-size-editor: 1rem;
|
|
43
|
+
}
|