@svgrid/grid 2.6.21 → 2.6.23
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/CHANGELOG.md +62 -0
- package/README.md +22 -0
- package/dist/GridMenus.svelte +201 -18
- package/dist/SvAutoComplete.svelte +4 -0
- package/dist/SvComboBox.svelte +5 -1
- package/dist/SvDateRangeInput.svelte +25 -3
- package/dist/SvDropDownList.svelte +4 -0
- package/dist/SvForm.svelte +8 -8
- package/dist/SvGrid.controller.svelte.d.ts +61 -9
- package/dist/SvGrid.controller.svelte.js +363 -123
- package/dist/SvGrid.css +222 -1
- package/dist/SvGrid.helpers.d.ts +55 -0
- package/dist/SvGrid.helpers.js +83 -0
- package/dist/SvGrid.svelte +255 -56
- package/dist/SvGrid.types.d.ts +146 -1
- package/dist/SvGridCellEditor.svelte +99 -17
- package/dist/SvGridSelect.svelte +6 -2
- package/dist/SvGridSelect.svelte.d.ts +1 -1
- package/dist/SvListBox.svelte +8 -0
- package/dist/SvMultiSelect.svelte +6 -2
- package/dist/SvMultiSelect.svelte.d.ts +1 -1
- package/dist/SvNumberInput.svelte +4 -0
- package/dist/SvRichCell.svelte +125 -0
- package/dist/SvRichCell.svelte.d.ts +15 -0
- package/dist/SvTextArea.svelte +5 -1
- package/dist/SvTreeSelect.svelte +6 -2
- package/dist/SvTreeSelect.svelte.d.ts +1 -1
- package/dist/builtin-editors.d.ts +2 -2
- package/dist/builtin-editors.js +19 -3
- package/dist/cdn/GridMenus-BzWXQjv3.js +600 -0
- package/dist/cdn/GridMenus-xr_rHx8F.js +601 -0
- package/dist/cdn/SvDateRangeInput-CaOuMs8O.js +198 -0
- package/dist/cdn/SvDateRangeInput-DMLKmGEc.js +199 -0
- package/dist/cdn/SvDateTimePicker-CCbDZNZB.js +816 -0
- package/dist/cdn/SvDateTimePicker-sonaH0oh.js +812 -0
- package/dist/cdn/SvGridCellEditor-BAPSC7EL.js +550 -0
- package/dist/cdn/SvGridCellEditor-BwzmUWtL.js +549 -0
- package/dist/cdn/column-resize-DsfNXMom.js +102 -0
- package/dist/cdn/date-format-BNii4zeD.js +1393 -0
- package/dist/cdn/date-format-BnnHlqGw.js +1395 -0
- package/dist/cdn/{editor-registry-CiI0xlKg.js → editor-registry-BhgE3S84.js} +51 -25
- package/dist/cdn/row-resize-BRcimkUT.js +95 -0
- package/dist/cdn/{src-DBel9wRZ.js → src-DGo7IHug.js} +10017 -9488
- package/dist/cdn/{src-BYq-qyrp.js → src-skQN5eqh.js} +7829 -7300
- package/dist/cdn/svgrid.js +14 -10
- package/dist/cdn/svgrid.svelte-external.js +14 -10
- package/dist/cell-values.d.ts +16 -0
- package/dist/cell-values.js +28 -0
- package/dist/clipboard.d.ts +22 -0
- package/dist/clipboard.js +405 -27
- package/dist/column-groups.js +1 -1
- package/dist/column-resize.d.ts +46 -0
- package/dist/column-resize.js +205 -0
- package/dist/columns.d.ts +0 -3
- package/dist/columns.js +0 -57
- package/dist/core.d.ts +19 -4
- package/dist/core.js +460 -119
- package/dist/editing.js +12 -7
- package/dist/editors/cell-editors.d.ts +11 -0
- package/dist/editors/cell-editors.js +18 -1
- package/dist/filtering/excel-filters.js +28 -0
- package/dist/grid-messages.d.ts +15 -0
- package/dist/grid-messages.js +15 -0
- package/dist/group-display.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -0
- package/dist/list-option.d.ts +6 -0
- package/dist/menus.js +41 -8
- package/dist/row-resize.d.ts +11 -0
- package/dist/row-resize.js +7 -1
- package/dist/sanitize-html.d.ts +37 -0
- package/dist/sanitize-html.js +234 -0
- package/dist/selection-bar-view.svelte.d.ts +25 -0
- package/dist/selection-bar-view.svelte.js +13 -0
- package/dist/selection.d.ts +2 -1
- package/dist/selection.js +133 -8
- package/dist/spreadsheet.d.ts +1 -1
- package/dist/spreadsheet.js +1 -1
- package/package.json +1 -1
- package/src/GridMenus.svelte +201 -18
- package/src/SvAutoComplete.svelte +4 -0
- package/src/SvComboBox.svelte +5 -1
- package/src/SvDateRangeInput.svelte +25 -3
- package/src/SvDropDownList.svelte +4 -0
- package/src/SvForm.svelte +8 -8
- package/src/SvGrid.controller.svelte.ts +404 -133
- package/src/SvGrid.css +222 -1
- package/src/SvGrid.helpers.ts +87 -0
- package/src/SvGrid.svelte +255 -56
- package/src/SvGrid.types.ts +153 -1
- package/src/SvGridCellEditor.svelte +99 -17
- package/src/SvGridSelect.svelte +6 -2
- package/src/SvListBox.svelte +8 -0
- package/src/SvMultiSelect.svelte +6 -2
- package/src/SvNumberInput.svelte +4 -0
- package/src/SvRichCell.svelte +125 -0
- package/src/SvTextArea.svelte +5 -1
- package/src/SvTreeSelect.svelte +6 -2
- package/src/builtin-editors.test.ts +18 -1
- package/src/builtin-editors.ts +19 -3
- package/src/cell-values.ts +30 -0
- package/src/clipboard.test.ts +93 -20
- package/src/clipboard.ts +433 -33
- package/src/column-groups.ts +1 -1
- package/src/column-resize.test.ts +381 -0
- package/src/column-resize.ts +227 -0
- package/src/columns.test.ts +0 -103
- package/src/columns.ts +0 -58
- package/src/core.aggregate.test.ts +134 -0
- package/src/core.filter.test.ts +156 -0
- package/src/core.grouping.test.ts +146 -0
- package/src/core.row-shape.test.ts +119 -0
- package/src/core.rowmodel-cache.test.ts +121 -0
- package/src/core.sort.test.ts +293 -0
- package/src/core.ts +516 -119
- package/src/date-string-column.test.ts +87 -0
- package/src/editing.test.ts +25 -0
- package/src/editing.ts +12 -9
- package/src/editor-block-prop.test.ts +132 -0
- package/src/editors/cell-editors.ts +27 -1
- package/src/filtering/excel-filters.ts +30 -0
- package/src/filtering/normalize-fast-path.test.ts +104 -0
- package/src/grid-messages.ts +34 -0
- package/src/group-display.ts +1 -1
- package/src/index.ts +25 -1
- package/src/list-option.ts +6 -0
- package/src/menus.test.ts +43 -0
- package/src/menus.ts +38 -8
- package/src/move-cells.test.ts +850 -0
- package/src/number-editor-literal.test.ts +84 -0
- package/src/number-editor.grid.test.ts +160 -0
- package/src/resize-props.test.ts +361 -0
- package/src/row-resize.test.ts +31 -0
- package/src/row-resize.ts +21 -3
- package/src/sanitize-html.test.ts +182 -0
- package/src/sanitize-html.ts +235 -0
- package/src/selection-bar-view.svelte.ts +36 -0
- package/src/selection.test.ts +157 -0
- package/src/selection.ts +135 -8
- package/src/spreadsheet.ts +1 -1
- package/src/svgrid.filter-menu-listbox.svelte.test.ts +56 -10
- package/src/svgrid.in-suggest-snapshot.svelte.test.ts +91 -0
- package/src/svgrid.menu-scroll-close.test.ts +204 -0
- package/src/svgrid.selection-bar-seam.test.ts +185 -0
- package/src/svgrid.upsell-license.test.ts +117 -0
- package/dist/cdn/GridMenus-BfTAKn84.js +0 -488
- package/dist/cdn/GridMenus-C3bJd7w8.js +0 -489
- package/dist/cdn/SvDateTimePicker-CHnUkWcH.js +0 -2206
- package/dist/cdn/SvDateTimePicker-CRQH_U7E.js +0 -2201
- package/dist/cdn/SvGridCellEditor-BGUCzuPB.js +0 -523
- package/dist/cdn/SvGridCellEditor-G8IMWIws.js +0 -522
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column-resize Svelte action - drag a header's right edge to widen / narrow
|
|
3
|
+
* the column. Counterpart of `rowResize`, and built the same way for the same
|
|
4
|
+
* reason: `<SvGrid columnResize>` is opt-in, so the code behind it must not sit
|
|
5
|
+
* in the base bundle of every grid that leaves it off. The grid pulls this
|
|
6
|
+
* module through `import()` the first time a consumer turns the prop on.
|
|
7
|
+
*
|
|
8
|
+
* Handles are injected rather than rendered, so nothing about them compiles
|
|
9
|
+
* into `SvGrid.svelte`. A header cell is keyed by `data-svgrid-header-col` -
|
|
10
|
+
* body cells use `data-col-id`, which is a different attribute on purpose, and
|
|
11
|
+
* matching the wrong one finds nothing. One handle goes into every such `th`
|
|
12
|
+
* under `node`, and a MutationObserver keeps up with virtualized columns
|
|
13
|
+
* scrolling in and out.
|
|
14
|
+
*
|
|
15
|
+
* <div use:columnResize={{ getWidth, onResize }}>
|
|
16
|
+
* <SvGrid ... />
|
|
17
|
+
* </div>
|
|
18
|
+
*
|
|
19
|
+
* Visual: a 5px strip on the header's right edge with an accent centre pill,
|
|
20
|
+
* from SvGrid.css. Cursor is `col-resize`.
|
|
21
|
+
*/
|
|
22
|
+
const HANDLE_CLASS = 'sv-grid-resize-handle';
|
|
23
|
+
export function columnResize(node, opts) {
|
|
24
|
+
let current = opts;
|
|
25
|
+
let drag = null;
|
|
26
|
+
// Coalesce onto the animation frame: pointermove fires many times per frame
|
|
27
|
+
// and each width write triggers a full recompute of the column-layout
|
|
28
|
+
// pipeline. Without this the grid stutters for the whole drag.
|
|
29
|
+
let raf = null;
|
|
30
|
+
let pendingWidth = 0;
|
|
31
|
+
const minWidth = () => current.min ?? 40;
|
|
32
|
+
function columnIdOf(el) {
|
|
33
|
+
return el.closest('[data-svgrid-header-col]')?.dataset.svgridHeaderCol ?? null;
|
|
34
|
+
}
|
|
35
|
+
function commit() {
|
|
36
|
+
if (!drag)
|
|
37
|
+
return;
|
|
38
|
+
current.onResize(drag.columnId, pendingWidth);
|
|
39
|
+
}
|
|
40
|
+
function onPointerMove(e) {
|
|
41
|
+
if (!drag)
|
|
42
|
+
return;
|
|
43
|
+
pendingWidth = Math.max(minWidth(), drag.startWidth + (e.clientX - drag.startX));
|
|
44
|
+
if (raf !== null)
|
|
45
|
+
return;
|
|
46
|
+
raf = requestAnimationFrame(() => {
|
|
47
|
+
raf = null;
|
|
48
|
+
commit();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function onPointerUp(e) {
|
|
52
|
+
if (!drag)
|
|
53
|
+
return;
|
|
54
|
+
if (raf !== null) {
|
|
55
|
+
cancelAnimationFrame(raf);
|
|
56
|
+
raf = null;
|
|
57
|
+
}
|
|
58
|
+
// Commit the final width even if the last frame was cancelled mid-flight.
|
|
59
|
+
pendingWidth = Math.max(minWidth(), drag.startWidth + (e.clientX - drag.startX));
|
|
60
|
+
commit();
|
|
61
|
+
drag.handle.classList.remove('is-resizing');
|
|
62
|
+
syncAria(drag.handle, drag.columnId);
|
|
63
|
+
try {
|
|
64
|
+
drag.handle.releasePointerCapture(e.pointerId);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
/* release is best-effort */
|
|
68
|
+
}
|
|
69
|
+
drag = null;
|
|
70
|
+
window.removeEventListener('pointermove', onPointerMove);
|
|
71
|
+
window.removeEventListener('pointerup', onPointerUp);
|
|
72
|
+
window.removeEventListener('pointercancel', onPointerUp);
|
|
73
|
+
document.body.style.cursor = '';
|
|
74
|
+
}
|
|
75
|
+
function onPointerDown(e) {
|
|
76
|
+
if (current.disabled)
|
|
77
|
+
return;
|
|
78
|
+
const t = e.target;
|
|
79
|
+
if (!t?.classList.contains(HANDLE_CLASS))
|
|
80
|
+
return;
|
|
81
|
+
const columnId = columnIdOf(t);
|
|
82
|
+
if (!columnId || current.canResize?.(columnId) === false)
|
|
83
|
+
return;
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
t.classList.add('is-resizing');
|
|
87
|
+
pendingWidth = current.getWidth(columnId);
|
|
88
|
+
drag = { columnId, startX: e.clientX, startWidth: pendingWidth, handle: t };
|
|
89
|
+
try {
|
|
90
|
+
t.setPointerCapture(e.pointerId);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
/* capture is best-effort */
|
|
94
|
+
}
|
|
95
|
+
document.body.style.cursor = 'col-resize';
|
|
96
|
+
window.addEventListener('pointermove', onPointerMove);
|
|
97
|
+
window.addEventListener('pointerup', onPointerUp);
|
|
98
|
+
window.addEventListener('pointercancel', onPointerUp);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Keyboard resize (#79). The handle is a focusable `role="separator"` acting
|
|
102
|
+
* as a splitter, so it has to answer the arrow keys. Left/Right shrink/grow,
|
|
103
|
+
* Shift gives a 1px step - the same contract `rowResize` uses vertically.
|
|
104
|
+
*/
|
|
105
|
+
function onKeyDown(e) {
|
|
106
|
+
if (current.disabled)
|
|
107
|
+
return;
|
|
108
|
+
const t = e.target;
|
|
109
|
+
if (!t?.classList.contains(HANDLE_CLASS))
|
|
110
|
+
return;
|
|
111
|
+
const step = e.shiftKey ? 1 : 10;
|
|
112
|
+
let delta = 0;
|
|
113
|
+
if (e.key === 'ArrowLeft')
|
|
114
|
+
delta = -step;
|
|
115
|
+
else if (e.key === 'ArrowRight')
|
|
116
|
+
delta = step;
|
|
117
|
+
else
|
|
118
|
+
return;
|
|
119
|
+
const columnId = columnIdOf(t);
|
|
120
|
+
if (!columnId || current.canResize?.(columnId) === false)
|
|
121
|
+
return;
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
const next = Math.max(minWidth(), Math.round(current.getWidth(columnId) + delta));
|
|
125
|
+
current.onResize(columnId, next);
|
|
126
|
+
syncAria(t, columnId);
|
|
127
|
+
}
|
|
128
|
+
/** A focusable separator is a widget, so ARIA wants a current value. */
|
|
129
|
+
function syncAria(handle, columnId) {
|
|
130
|
+
const w = Math.round(current.getWidth(columnId));
|
|
131
|
+
handle.setAttribute('aria-valuenow', String(w));
|
|
132
|
+
handle.setAttribute('aria-valuemin', String(minWidth()));
|
|
133
|
+
handle.setAttribute('aria-valuetext', `${w} pixels`);
|
|
134
|
+
}
|
|
135
|
+
/** One handle per header cell. Skips group headers and spacer columns,
|
|
136
|
+
* which have no id to resize. */
|
|
137
|
+
function decorate() {
|
|
138
|
+
if (current.disabled) {
|
|
139
|
+
removeAll();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const heads = node.querySelectorAll('th.sv-grid-column[data-svgrid-header-col]');
|
|
143
|
+
for (const th of heads) {
|
|
144
|
+
if (th.classList.contains('sv-grid-column-spacer'))
|
|
145
|
+
continue;
|
|
146
|
+
const columnId = th.dataset.svgridHeaderCol;
|
|
147
|
+
if (!columnId)
|
|
148
|
+
continue;
|
|
149
|
+
if (current.canResize?.(columnId) === false) {
|
|
150
|
+
// The column may have been resizable a moment ago - a re-decorate has
|
|
151
|
+
// to take the handle away, not just stop adding one.
|
|
152
|
+
th.querySelector(`:scope > .${HANDLE_CLASS}`)?.remove();
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (th.querySelector(`:scope > .${HANDLE_CLASS}`))
|
|
156
|
+
continue;
|
|
157
|
+
const handle = document.createElement('div');
|
|
158
|
+
handle.className = HANDLE_CLASS;
|
|
159
|
+
handle.setAttribute('role', 'separator');
|
|
160
|
+
handle.setAttribute('aria-orientation', 'vertical');
|
|
161
|
+
handle.setAttribute('aria-label', `Resize ${current.label?.(columnId) ?? columnId}`);
|
|
162
|
+
handle.tabIndex = 0;
|
|
163
|
+
syncAria(handle, columnId);
|
|
164
|
+
// Double-click the handle to size the column to its content - the
|
|
165
|
+
// spreadsheet gesture. Stop it there so it does not also reach the
|
|
166
|
+
// header, where a double-click would toggle the sort twice.
|
|
167
|
+
handle.addEventListener('dblclick', (ev) => {
|
|
168
|
+
ev.stopPropagation();
|
|
169
|
+
ev.preventDefault();
|
|
170
|
+
if (current.disabled)
|
|
171
|
+
return;
|
|
172
|
+
current.onAutosize?.(columnId);
|
|
173
|
+
syncAria(handle, columnId);
|
|
174
|
+
});
|
|
175
|
+
th.appendChild(handle);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function removeAll() {
|
|
179
|
+
node.querySelectorAll(`.${HANDLE_CLASS}`).forEach((el) => el.remove());
|
|
180
|
+
}
|
|
181
|
+
node.addEventListener('pointerdown', onPointerDown, { capture: true });
|
|
182
|
+
node.addEventListener('keydown', onKeyDown, { capture: true });
|
|
183
|
+
const observer = new MutationObserver(() => decorate());
|
|
184
|
+
observer.observe(node, { childList: true, subtree: true });
|
|
185
|
+
decorate();
|
|
186
|
+
return {
|
|
187
|
+
update(next) {
|
|
188
|
+
const wasDisabled = current.disabled;
|
|
189
|
+
current = next;
|
|
190
|
+
if (wasDisabled !== current.disabled)
|
|
191
|
+
decorate();
|
|
192
|
+
},
|
|
193
|
+
destroy() {
|
|
194
|
+
node.removeEventListener('pointerdown', onPointerDown, { capture: true });
|
|
195
|
+
node.removeEventListener('keydown', onKeyDown, { capture: true });
|
|
196
|
+
window.removeEventListener('pointermove', onPointerMove);
|
|
197
|
+
window.removeEventListener('pointerup', onPointerUp);
|
|
198
|
+
window.removeEventListener('pointercancel', onPointerUp);
|
|
199
|
+
if (raf !== null)
|
|
200
|
+
cancelAnimationFrame(raf);
|
|
201
|
+
observer.disconnect();
|
|
202
|
+
removeAll();
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
package/dist/columns.d.ts
CHANGED
|
@@ -20,9 +20,6 @@ export declare function createColumns<TFeatures extends TableFeatures = TableFea
|
|
|
20
20
|
toggleGroupInPanel: (columnId: string) => void;
|
|
21
21
|
getColumnBaseWidth: (columnId: string) => any;
|
|
22
22
|
getColumnWidth: (columnId: string) => any;
|
|
23
|
-
startColumnResize: (event: PointerEvent, columnId: string) => void;
|
|
24
|
-
onColumnResizeMove: (event: PointerEvent) => void;
|
|
25
|
-
endColumnResize: () => void;
|
|
26
23
|
measureText: (text: string, font: string) => number;
|
|
27
24
|
autosizeColumn: (columnId: string) => void;
|
|
28
25
|
autosizeAllColumns: () => void;
|
package/dist/columns.js
CHANGED
|
@@ -156,60 +156,6 @@ export function createColumns(ctx) {
|
|
|
156
156
|
return fitted;
|
|
157
157
|
return getColumnBaseWidth(columnId);
|
|
158
158
|
}
|
|
159
|
-
function startColumnResize(event, columnId) {
|
|
160
|
-
event.stopPropagation();
|
|
161
|
-
event.preventDefault();
|
|
162
|
-
ctx.resizingColumnId = columnId;
|
|
163
|
-
ctx.resizeStartX = event.clientX;
|
|
164
|
-
ctx.resizeStartWidth = getColumnWidth(columnId);
|
|
165
|
-
// Capture the pointer so the drag keeps tracking when it leaves the 4px
|
|
166
|
-
// handle - without this, touch (and fast mouse) drags drop mid-resize (#59).
|
|
167
|
-
try {
|
|
168
|
-
event.currentTarget?.setPointerCapture?.(event.pointerId);
|
|
169
|
-
}
|
|
170
|
-
catch { /* capture is best-effort */ }
|
|
171
|
-
document.addEventListener("pointermove", onColumnResizeMove);
|
|
172
|
-
document.addEventListener("pointerup", endColumnResize);
|
|
173
|
-
document.addEventListener("pointercancel", endColumnResize);
|
|
174
|
-
}
|
|
175
|
-
function onColumnResizeMove(event) {
|
|
176
|
-
if (!ctx.resizingColumnId)
|
|
177
|
-
return;
|
|
178
|
-
// Coalesce updates onto the animation frame: pointermove can fire many
|
|
179
|
-
// times per frame, and each $state mutation triggers a full reactive
|
|
180
|
-
// recompute of the column-layout pipeline. Without rAF coalescing the
|
|
181
|
-
// grid stutters during the drag.
|
|
182
|
-
ctx.resizePendingWidth = Math.max(ctx.MIN_COLUMN_WIDTH, ctx.resizeStartWidth + (event.clientX - ctx.resizeStartX));
|
|
183
|
-
if (ctx.resizeRaf !== null)
|
|
184
|
-
return;
|
|
185
|
-
ctx.resizeRaf = requestAnimationFrame(() => {
|
|
186
|
-
ctx.resizeRaf = null;
|
|
187
|
-
if (!ctx.resizingColumnId)
|
|
188
|
-
return;
|
|
189
|
-
ctx.columnWidths = {
|
|
190
|
-
...ctx.columnWidths,
|
|
191
|
-
[ctx.resizingColumnId]: ctx.resizePendingWidth,
|
|
192
|
-
};
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function endColumnResize() {
|
|
196
|
-
if (ctx.resizeRaf !== null) {
|
|
197
|
-
cancelAnimationFrame(ctx.resizeRaf);
|
|
198
|
-
ctx.resizeRaf = null;
|
|
199
|
-
}
|
|
200
|
-
if (ctx.resizingColumnId && ctx.resizePendingWidth) {
|
|
201
|
-
// Make sure the final width is committed even if the last rAF was
|
|
202
|
-
// canceled mid-flight.
|
|
203
|
-
ctx.columnWidths = {
|
|
204
|
-
...ctx.columnWidths,
|
|
205
|
-
[ctx.resizingColumnId]: ctx.resizePendingWidth,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
ctx.resizingColumnId = null;
|
|
209
|
-
document.removeEventListener("pointermove", onColumnResizeMove);
|
|
210
|
-
document.removeEventListener("pointerup", endColumnResize);
|
|
211
|
-
document.removeEventListener("pointercancel", endColumnResize);
|
|
212
|
-
}
|
|
213
159
|
function measureText(text, font) {
|
|
214
160
|
if (!text)
|
|
215
161
|
return 0;
|
|
@@ -280,9 +226,6 @@ export function createColumns(ctx) {
|
|
|
280
226
|
toggleGroupInPanel,
|
|
281
227
|
getColumnBaseWidth,
|
|
282
228
|
getColumnWidth,
|
|
283
|
-
startColumnResize,
|
|
284
|
-
onColumnResizeMove,
|
|
285
|
-
endColumnResize,
|
|
286
229
|
measureText,
|
|
287
230
|
autosizeColumn,
|
|
288
231
|
autosizeAllColumns,
|
package/dist/core.d.ts
CHANGED
|
@@ -201,7 +201,7 @@ export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
201
201
|
columns?: Array<ColumnDef<TFeatures, TData>>;
|
|
202
202
|
/**
|
|
203
203
|
* Declarative cell spanning (merged cells). Return how many COLUMNS this
|
|
204
|
-
* cell spans to the right (1 = no span). Value-driven
|
|
204
|
+
* cell spans to the right (1 = no span). Value-driven. Feed
|
|
205
205
|
* `spansToMerges(rows, columns)` into `spreadsheetLayout` to apply - it uses
|
|
206
206
|
* the same real `colspan`/`rowspan` merge engine (no separate code path).
|
|
207
207
|
*/
|
|
@@ -240,7 +240,7 @@ export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
240
240
|
columnGroupShow?: 'open' | 'closed';
|
|
241
241
|
/**
|
|
242
242
|
* For a GROUP column (one with `columns: [...]`): start the group expanded.
|
|
243
|
-
* Defaults to `false` (collapsed),
|
|
243
|
+
* Defaults to `false` (collapsed), the conventional default - so only the always-on
|
|
244
244
|
* and `columnGroupShow: 'closed'` children show until the user expands it.
|
|
245
245
|
*/
|
|
246
246
|
openByDefault?: boolean;
|
|
@@ -263,7 +263,7 @@ export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
263
263
|
*/
|
|
264
264
|
tooltip?: string | ((ctx: CellContext<TData>) => string | null | undefined);
|
|
265
265
|
/**
|
|
266
|
-
* Declarative per-cell validation
|
|
266
|
+
* Declarative per-cell validation. Runs for EVERY
|
|
267
267
|
* rendered cell - including values already present in `data` on load, not
|
|
268
268
|
* just on edit - so bad data is flagged immediately. Invalid cells get the
|
|
269
269
|
* `sv-grid-cell-invalid` class (red highlight) and the returned message as
|
|
@@ -302,7 +302,7 @@ export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
302
302
|
* Transform the committed edit value before it is written to the row.
|
|
303
303
|
* Runs after the built-in per-`editorType` coercion, so `newValue` is
|
|
304
304
|
* already type-parsed; return the final value to store (e.g. round a
|
|
305
|
-
* number, uppercase a code, look up an id).
|
|
305
|
+
* number, uppercase a code, look up an id). A `valueParser` hook.
|
|
306
306
|
*/
|
|
307
307
|
valueParser?: (params: ValueParserParams<TData>) => unknown;
|
|
308
308
|
/**
|
|
@@ -388,6 +388,21 @@ export type ColumnDef<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
388
388
|
sparkline?: SparklineConfig;
|
|
389
389
|
/** Initial column width in pixels. Falls back to the grid's `columnWidth` prop. */
|
|
390
390
|
width?: number;
|
|
391
|
+
/**
|
|
392
|
+
* Whether the user may resize this column. Only consulted when the grid has
|
|
393
|
+
* `columnResize` on - it narrows that, it does not enable anything.
|
|
394
|
+
*
|
|
395
|
+
* `false` removes the column's drag handle entirely, so pointer drag, the
|
|
396
|
+
* keyboard arrows and double-click-to-autosize are all gone with it, and the
|
|
397
|
+
* column menu drops its Autosize item. Use it for the columns whose width is
|
|
398
|
+
* part of the layout rather than a preference: a row-number gutter, a
|
|
399
|
+
* checkbox column, a fixed icon column.
|
|
400
|
+
*
|
|
401
|
+
* Programmatic sizing is unaffected - `api.autosizeColumn()`,
|
|
402
|
+
* `api.setColumnWidth()` and `fitColumns` all still apply, the same way they
|
|
403
|
+
* do when `columnResize` is off. This governs the user affordance only.
|
|
404
|
+
*/
|
|
405
|
+
resizable?: boolean;
|
|
391
406
|
/**
|
|
392
407
|
* Initial visibility. Set `false` to start the column hidden while still
|
|
393
408
|
* listing it in the Choose Columns UI for the user to re-enable. Applied
|