snap-records 1.1.0 → 1.1.3
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/LICENSE +21 -0
- package/README.md +8 -8
- package/dist/snap-records.es.js +53 -12
- package/dist/snap-records.es.js.map +1 -1
- package/dist/snap-records.umd.js.map +1 -1
- package/package.json +5 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Luís Assunção
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/snap-records"><img src="https://img.shields.io/npm/v/snap-records.svg" alt="NPM Version"></a>
|
|
9
|
-
<a href="./
|
|
8
|
+
<a href="https://www.npmjs.com/package/snap-records"><img src="https://img.shields.io/npm/v/snap-records.svg?style=flat&color=blue" alt="NPM Version"></a>
|
|
9
|
+
<a href="./LICENSE"><img src="https://img.shields.io/npm/l/snap-records.svg?style=flat&color=blue" alt="License"></a>
|
|
10
10
|
<a href="https://github.com/lbassuncao/SnapRecords/actions/workflows/ci.yml"><img src="https://github.com/lbassuncao/SnapRecords/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<br>
|
|
14
14
|
|
|
15
15
|
<p align="center" style="font-size: 1.15rem">
|
|
16
|
-
<strong><a href="
|
|
17
|
-
<strong><a href="
|
|
18
|
-
<strong><a href="
|
|
19
|
-
<strong><a href="
|
|
20
|
-
<strong><a href="
|
|
21
|
-
<strong><a href="
|
|
16
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/docs/CONFIG.md">Configuration</a></strong> |
|
|
17
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/docs/BUILD.md">Build Guide</a></strong> |
|
|
18
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/docs/KEYBOARD.md">Keyboard Navigation</a></strong> |
|
|
19
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/CONTRIBUTING.md">Contributing</a></strong> |
|
|
20
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/LICENSE">License</a></strong> |
|
|
21
|
+
<strong><a href="https://github.com/lbassuncao/SnapRecords/blob/main/docs/COC.md">Code of Conduct</a></strong>
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<br>
|
package/dist/snap-records.es.js
CHANGED
|
@@ -3178,7 +3178,12 @@ class StateManager {
|
|
|
3178
3178
|
localStorage.setItem(__privateGet(this, _parent3).storageKey, JSON.stringify(stateToSave));
|
|
3179
3179
|
log(__privateGet(this, _parent3).debug, LogLevel.INFO, "State saved successfully.");
|
|
3180
3180
|
} catch (error) {
|
|
3181
|
-
log(
|
|
3181
|
+
log(
|
|
3182
|
+
__privateGet(this, _parent3).debug,
|
|
3183
|
+
LogLevel.ERROR,
|
|
3184
|
+
"Could not save state to localStorage.",
|
|
3185
|
+
error
|
|
3186
|
+
);
|
|
3182
3187
|
}
|
|
3183
3188
|
}, __privateGet(this, _DEBOUNCE_TIMEOUT_MS)));
|
|
3184
3189
|
}
|
|
@@ -3238,7 +3243,12 @@ class StateManager {
|
|
|
3238
3243
|
}
|
|
3239
3244
|
});
|
|
3240
3245
|
} catch (error) {
|
|
3241
|
-
log(
|
|
3246
|
+
log(
|
|
3247
|
+
__privateGet(this, _parent3).debug,
|
|
3248
|
+
LogLevel.ERROR,
|
|
3249
|
+
"Could not load state from localStorage.",
|
|
3250
|
+
error
|
|
3251
|
+
);
|
|
3242
3252
|
localStorage.removeItem(__privateGet(this, _parent3).storageKey);
|
|
3243
3253
|
}
|
|
3244
3254
|
}
|
|
@@ -3348,7 +3358,11 @@ class EventManager {
|
|
|
3348
3358
|
};
|
|
3349
3359
|
const pageAction = pageActions[event.key];
|
|
3350
3360
|
if (pageAction) {
|
|
3351
|
-
log(
|
|
3361
|
+
log(
|
|
3362
|
+
__privateGet(this, _parent4).debug,
|
|
3363
|
+
LogLevel.INFO,
|
|
3364
|
+
`Keyboard navigation action detected: ${event.key}`
|
|
3365
|
+
);
|
|
3352
3366
|
event.preventDefault();
|
|
3353
3367
|
pageAction();
|
|
3354
3368
|
return;
|
|
@@ -3373,7 +3387,11 @@ class EventManager {
|
|
|
3373
3387
|
};
|
|
3374
3388
|
const selectionAction = selectionActions[event.key];
|
|
3375
3389
|
if (selectionAction) {
|
|
3376
|
-
log(
|
|
3390
|
+
log(
|
|
3391
|
+
__privateGet(this, _parent4).debug,
|
|
3392
|
+
LogLevel.INFO,
|
|
3393
|
+
`Keyboard selection action detected: ${event.key}`
|
|
3394
|
+
);
|
|
3377
3395
|
event.preventDefault();
|
|
3378
3396
|
selectionAction();
|
|
3379
3397
|
}
|
|
@@ -3382,7 +3400,11 @@ class EventManager {
|
|
|
3382
3400
|
__privateAdd(this, _handleResize, (event) => {
|
|
3383
3401
|
if (__privateGet(this, _resizingColumnId) === null) return;
|
|
3384
3402
|
const width = __privateGet(this, _startWidth) + (event.clientX - __privateGet(this, _startX));
|
|
3385
|
-
log(
|
|
3403
|
+
log(
|
|
3404
|
+
__privateGet(this, _parent4).debug,
|
|
3405
|
+
LogLevel.LOG,
|
|
3406
|
+
`Column resizing: ${__privateGet(this, _resizingColumnId)} to ${width}px.`
|
|
3407
|
+
);
|
|
3386
3408
|
__privateGet(this, _parent4).stateManager.setState((draft) => {
|
|
3387
3409
|
draft.columnWidths.set(__privateGet(this, _resizingColumnId), width);
|
|
3388
3410
|
});
|
|
@@ -3391,7 +3413,11 @@ class EventManager {
|
|
|
3391
3413
|
// Stops column resizing
|
|
3392
3414
|
__privateAdd(this, _stopResize, () => {
|
|
3393
3415
|
if (__privateGet(this, _resizingColumnId) === null) return;
|
|
3394
|
-
log(
|
|
3416
|
+
log(
|
|
3417
|
+
__privateGet(this, _parent4).debug,
|
|
3418
|
+
LogLevel.INFO,
|
|
3419
|
+
`Finished column resize for: ${__privateGet(this, _resizingColumnId)}`
|
|
3420
|
+
);
|
|
3395
3421
|
__privateSet(this, _resizingColumnId, null);
|
|
3396
3422
|
document.removeEventListener("mousemove", __privateGet(this, _handleResize));
|
|
3397
3423
|
document.removeEventListener("mouseup", __privateGet(this, _stopResize));
|
|
@@ -3440,7 +3466,9 @@ class EventManager {
|
|
|
3440
3466
|
if (pageButton.disabled) return;
|
|
3441
3467
|
const pageNumText = (_a2 = pageButton.textContent) == null ? void 0 : _a2.trim();
|
|
3442
3468
|
const pageNum = pageNumText ? parseInt(pageNumText, 10) : NaN;
|
|
3443
|
-
log(__privateGet(this, _parent4).debug, LogLevel.INFO, "Pagination button clicked.", {
|
|
3469
|
+
log(__privateGet(this, _parent4).debug, LogLevel.INFO, "Pagination button clicked.", {
|
|
3470
|
+
text: pageNumText
|
|
3471
|
+
});
|
|
3444
3472
|
if (pageButton.classList.contains(config.pagination.prevButton.classNames.base)) {
|
|
3445
3473
|
__privateGet(this, _parent4).gotoPage(__privateGet(this, _parent4).state.currentPage - 1);
|
|
3446
3474
|
} else if (pageButton.classList.contains(config.pagination.nextButton.classNames.base)) {
|
|
@@ -3468,7 +3496,11 @@ class EventManager {
|
|
|
3468
3496
|
const sourceColId = (_a2 = event.dataTransfer) == null ? void 0 : _a2.getData("text/plain");
|
|
3469
3497
|
const targetColId = target == null ? void 0 : target.dataset.colId;
|
|
3470
3498
|
if (sourceColId && targetColId && sourceColId !== targetColId) {
|
|
3471
|
-
log(
|
|
3499
|
+
log(
|
|
3500
|
+
__privateGet(this, _parent4).debug,
|
|
3501
|
+
LogLevel.INFO,
|
|
3502
|
+
`Column drop: "${sourceColId}" onto "${targetColId}"`
|
|
3503
|
+
);
|
|
3472
3504
|
__privateGet(this, _callbacks).reorderColumns(sourceColId, targetColId);
|
|
3473
3505
|
}
|
|
3474
3506
|
target == null ? void 0 : target.classList.remove(config.classes.dragOver);
|
|
@@ -6720,7 +6752,10 @@ class Configuration {
|
|
|
6720
6752
|
if (this.options.columnFormatters) {
|
|
6721
6753
|
for (const key in this.options.columnFormatters) {
|
|
6722
6754
|
if (typeof this.options.columnFormatters[key] !== "function") {
|
|
6723
|
-
this.logger(
|
|
6755
|
+
this.logger(
|
|
6756
|
+
LogLevel.WARN,
|
|
6757
|
+
`columnFormatters for column '${key}' is not a function.`
|
|
6758
|
+
);
|
|
6724
6759
|
}
|
|
6725
6760
|
}
|
|
6726
6761
|
}
|
|
@@ -6731,14 +6766,20 @@ class Configuration {
|
|
|
6731
6766
|
throw new SnapRecordsConfigError("Columns option must be a non-empty array.");
|
|
6732
6767
|
}
|
|
6733
6768
|
if (this.options.columnTitles && this.options.columns.length !== this.options.columnTitles.length) {
|
|
6734
|
-
this.logger(
|
|
6769
|
+
this.logger(
|
|
6770
|
+
LogLevel.WARN,
|
|
6771
|
+
"The number of columns does not match the number of column titles."
|
|
6772
|
+
);
|
|
6735
6773
|
}
|
|
6736
6774
|
}
|
|
6737
6775
|
// Validates the rowsPerPage option
|
|
6738
6776
|
validateRowsPerPage() {
|
|
6739
6777
|
const rpp = this.options.rowsPerPage ?? RowsPerPage.DEFAULT;
|
|
6740
6778
|
if (typeof rpp !== "number" || rpp < 1 || rpp > 1e3) {
|
|
6741
|
-
this.logger(
|
|
6779
|
+
this.logger(
|
|
6780
|
+
LogLevel.WARN,
|
|
6781
|
+
`rowsPerPage value '${rpp}' is outside the recommended range (1-1000).`
|
|
6782
|
+
);
|
|
6742
6783
|
}
|
|
6743
6784
|
}
|
|
6744
6785
|
}
|
|
@@ -6747,7 +6788,7 @@ class TranslationManager {
|
|
|
6747
6788
|
// the language path, which will be provided
|
|
6748
6789
|
// by the SnapRecords instance.
|
|
6749
6790
|
constructor(langPath = "/lang", debug = false, logger) {
|
|
6750
|
-
// Debug flag from
|
|
6791
|
+
// Debug flag from
|
|
6751
6792
|
// parent SnapRecords instance
|
|
6752
6793
|
__privateAdd(this, _debug);
|
|
6753
6794
|
// Maximum number of retry
|