Refactor #4285
parent
506fb3ee29
commit
0a97b8fe7e
|
@ -2589,7 +2589,8 @@ export default {
|
|||
let innerHTML = '';
|
||||
|
||||
if (this.responsiveOptions) {
|
||||
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * new Intl.Collator(undefined, { numeric: true }).compare(o1.breakpoint, o2.breakpoint));
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * comparer(o1.breakpoint, o2.breakpoint));
|
||||
|
||||
for (let i = 0; i < responsiveOptions.length; i++) {
|
||||
let { breakpoint, numMonths } = responsiveOptions[i];
|
||||
|
|
|
@ -528,6 +528,7 @@ export default {
|
|||
|
||||
if (this.responsiveOptions && !this.isUnstyled) {
|
||||
let _responsiveOptions = [...this.responsiveOptions];
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
|
||||
_responsiveOptions.sort((data1, data2) => {
|
||||
const value1 = data1.breakpoint;
|
||||
|
@ -537,7 +538,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return -1 * result;
|
||||
|
|
|
@ -523,6 +523,7 @@ export default {
|
|||
}
|
||||
|
||||
data.sort((data1, data2) => {
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
let value1 = resolvedFieldDatas.get(data1);
|
||||
let value2 = resolvedFieldDatas.get(data2);
|
||||
|
||||
|
@ -531,7 +532,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return this.d_sortOrder * result;
|
||||
|
@ -567,7 +568,9 @@ export default {
|
|||
|
||||
if (typeof value1 === 'string' || value1 instanceof String) {
|
||||
if (value1.localeCompare && value1 !== value2) {
|
||||
return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
|
||||
return this.d_multiSortMeta[index].order * comparer(value1, value2);
|
||||
}
|
||||
} else {
|
||||
result = value1 < value2 ? -1 : 1;
|
||||
|
|
|
@ -110,6 +110,7 @@ export default {
|
|||
sort() {
|
||||
if (this.value) {
|
||||
const value = [...this.value];
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
|
||||
value.sort((data1, data2) => {
|
||||
let value1 = ObjectUtils.resolveFieldData(data1, this.sortField);
|
||||
|
@ -119,7 +120,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return this.sortOrder * result;
|
||||
|
|
|
@ -438,6 +438,8 @@ export default {
|
|||
|
||||
if (this.responsiveOptions && !this.isUnstyled) {
|
||||
this.sortedResponsiveOptions = [...this.responsiveOptions];
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
|
||||
this.sortedResponsiveOptions.sort((data1, data2) => {
|
||||
const value1 = data1.breakpoint;
|
||||
const value2 = data2.breakpoint;
|
||||
|
@ -446,7 +448,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return -1 * result;
|
||||
|
|
|
@ -417,6 +417,7 @@ export default {
|
|||
},
|
||||
sortNodesSingle(nodes) {
|
||||
let _nodes = [...nodes];
|
||||
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
|
||||
_nodes.sort((node1, node2) => {
|
||||
const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_sortField);
|
||||
|
@ -426,7 +427,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return this.d_sortOrder * result;
|
||||
|
|
Loading…
Reference in New Issue