@chalabi/svelte-sheets 2.0.4 → 2.0.5
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/dist/Sheet.svelte +18 -6
- package/package.json +1 -1
package/dist/Sheet.svelte
CHANGED
|
@@ -131,11 +131,23 @@ $: {
|
|
|
131
131
|
currentValue = "";
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
function getDefaultColWidth() {
|
|
135
|
+
const w = config.defaultColWidth;
|
|
136
|
+
if (typeof w === "string") {
|
|
137
|
+
return Number(w.replace("px", "")) || 50;
|
|
138
|
+
}
|
|
139
|
+
return Number(w) || 50;
|
|
140
|
+
}
|
|
134
141
|
function getColumnsWidth(i) {
|
|
135
|
-
var _a
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
var _a;
|
|
143
|
+
const colWidth = (_a = columns[i]) === null || _a === void 0 ? void 0 : _a.width;
|
|
144
|
+
if (colWidth !== undefined && colWidth !== null) {
|
|
145
|
+
if (typeof colWidth === "string") {
|
|
146
|
+
return Number(colWidth.replace("px", "")) || getDefaultColWidth();
|
|
147
|
+
}
|
|
148
|
+
return Number(colWidth) || getDefaultColWidth();
|
|
149
|
+
}
|
|
150
|
+
return getDefaultColWidth();
|
|
139
151
|
}
|
|
140
152
|
function getRowHeight(i) {
|
|
141
153
|
var _a, _b, _c, _d;
|
|
@@ -185,7 +197,7 @@ function refresh(data, viewport_height, viewport_width) {
|
|
|
185
197
|
const { scrollTop, scrollLeft } = viewport;
|
|
186
198
|
yield tick(); // wait until the DOM is up to date
|
|
187
199
|
const defaultHeight = 24;
|
|
188
|
-
const defaultWidth =
|
|
200
|
+
const defaultWidth = getDefaultColWidth();
|
|
189
201
|
// Safety limits to prevent infinite loops
|
|
190
202
|
const maxRowsToRender = Math.max(data.length, Math.ceil((viewport_height + bottom_buffer * 2) / defaultHeight) + 10, 100);
|
|
191
203
|
const maxColsToRender = Math.max(columns.length, Math.ceil((viewport_width + right_buffer * 2) / defaultWidth) + 10, 50);
|
|
@@ -244,7 +256,7 @@ $: (function scrollX() {
|
|
|
244
256
|
return;
|
|
245
257
|
// Ensure we have valid dimensions to work with
|
|
246
258
|
const totalCols = Math.max(columns.length, endX, 1);
|
|
247
|
-
const defaultWidth =
|
|
259
|
+
const defaultWidth = getDefaultColWidth();
|
|
248
260
|
// if (!scrollLeft) ;
|
|
249
261
|
// horizontal scrolling
|
|
250
262
|
for (let v = 0; v < colElements.length; v += 1) {
|