table-sort-js
Advanced tools
Comparing version 1.8.2 to 1.9.0
{ | ||
"name": "table-sort-js", | ||
"version": "1.8.2", | ||
"version": "1.9.0", | ||
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -53,5 +53,7 @@ ![table-sort-js](https://img.shields.io/npm/v/table-sort-js) | ||
| "order-by-desc" | Order by descending on first click. (default is aescending) | | ||
| "file-size" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) | | ||
| "data-sort" | Sort by [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), e.g <td data-sort="42"> | | ||
| "disable-sort" | Disallow sorting the table by this specific column | ||
| "file-size-sort" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) | | ||
| "alpha-sort" | Sort alphabetically (z11,z2); default is [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order) (z2,z11). | | ||
| "punct-sort" | Sort punctuation; default ignores punctuation. | | ||
| "disable-sort" | Disallow sorting the table by this specific column. | | ||
@@ -58,0 +60,0 @@ #### Development: |
@@ -210,3 +210,5 @@ /* | ||
function naturalSortAscending(a, b) { | ||
const isPunctSort = th.classList.contains("punct-sort"); | ||
const isAlphaSort = th.classList.contains("alpha-sort"); | ||
function sortAscending(a, b) { | ||
if (a.includes(`${fillValue}#`)) { | ||
@@ -220,3 +222,3 @@ return 1; | ||
navigator.languages[0] || navigator.language, | ||
{ numeric: true, ignorePunctuation: true } | ||
{ numeric: !isAlphaSort, ignorePunctuation: !isPunctSort } | ||
); | ||
@@ -226,4 +228,4 @@ } | ||
function naturalSortDescending(a, b) { | ||
return naturalSortAscending(b, a); | ||
function sortDescending(a, b) { | ||
return sortAscending(b, a); | ||
} | ||
@@ -249,4 +251,4 @@ | ||
columnData.sort(sortDirection, { | ||
numeric: true, | ||
ignorePunctuation: true, | ||
numeric: !isAlphaSort, | ||
ignorePunctuation: !isPunctSort, | ||
}); | ||
@@ -258,6 +260,6 @@ } | ||
changeTableArrow(arrowDown); | ||
sortColumn(naturalSortDescending); | ||
sortColumn(sortDescending); | ||
} else { | ||
changeTableArrow(arrowUp); | ||
sortColumn(naturalSortAscending); | ||
sortColumn(sortAscending); | ||
} | ||
@@ -268,6 +270,6 @@ } else if (timesClickedColumn === 2) { | ||
changeTableArrow(arrowUp); | ||
sortColumn(naturalSortAscending); | ||
sortColumn(sortAscending); | ||
} else { | ||
changeTableArrow(arrowDown); | ||
sortColumn(naturalSortDescending); | ||
sortColumn(sortDescending); | ||
} | ||
@@ -364,3 +366,3 @@ } | ||
const isFileSize = th.classList.contains("file-size"); | ||
const isFileSize = th.classList.contains("file-size-sort"); | ||
if (isFileSize) { | ||
@@ -367,0 +369,0 @@ sortFileSize(visibleTableRows, columnData); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20220
367
62