@reykjavik/webtools 0.1.19 → 0.1.20
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 +7 -7
- package/esm/fixIcelandicLocale.privates.js +47 -74
- package/fixIcelandicLocale.privates.js +47 -74
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
-
## 0.1.
|
|
7
|
+
## 0.1.20
|
|
8
8
|
|
|
9
9
|
_2024-03-11_
|
|
10
10
|
|
|
11
|
-
- fix:
|
|
12
|
-
(not just a single character) This fix corrects the sorting of initial
|
|
13
|
-
letters, but characters inside the string stay mixed in with their
|
|
14
|
-
unaccented base character.
|
|
15
|
-
- fix: Incorrect `Intl.ListFormat` format in narrow+unit mode
|
|
11
|
+
- fix: Make all pached `Intl.*` methods bound to their instances
|
|
16
12
|
|
|
17
|
-
## 0.1.18
|
|
13
|
+
## 0.1.18 – 0.1.19
|
|
18
14
|
|
|
19
15
|
_2024-03-11_
|
|
20
16
|
|
|
21
17
|
- `@reykjavik/webtools/fixIcelandicLocale`:
|
|
22
18
|
- feat: Patch `Intl.PluralRules` and `Intl.ListFormat`
|
|
19
|
+
- fix: Incorrect alphabetization of accented characters as part of a word …
|
|
20
|
+
(not just a single character) This fix corrects the sorting of initial
|
|
21
|
+
letters, but characters inside the string stay mixed in with their
|
|
22
|
+
unaccented base character.
|
|
23
23
|
|
|
24
24
|
## 0.1.16 – 0.1.17
|
|
25
25
|
|
|
@@ -27,29 +27,24 @@ const PatchedCollator = function Collator(locales, options) {
|
|
|
27
27
|
return new PatchedCollator(locales, options);
|
|
28
28
|
}
|
|
29
29
|
const mappedLocales = mapLocales(locales);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
constructor: PatchedCollator,
|
|
38
|
-
compare(a, b) {
|
|
39
|
-
const res1 = this.super.compare(a, b);
|
|
30
|
+
const parent = _Collator(mappedLocales || locales, options);
|
|
31
|
+
const mapped = !!mappedLocales;
|
|
32
|
+
this.compare = (a, b) => {
|
|
33
|
+
const res1 = parent.compare(a, b);
|
|
34
|
+
if (!mapped) {
|
|
35
|
+
return res1;
|
|
36
|
+
}
|
|
40
37
|
const a0 = a.charAt(0);
|
|
41
38
|
const b0 = b.charAt(0);
|
|
42
39
|
if (/\d/.test(a0 + b0)) {
|
|
43
40
|
return res1;
|
|
44
41
|
}
|
|
45
|
-
const res2 =
|
|
42
|
+
const res2 = parent.compare(a0, b0);
|
|
46
43
|
return res2 !== 0 ? res2 : res1;
|
|
47
|
-
}
|
|
48
|
-
resolvedOptions()
|
|
49
|
-
return this.super.resolvedOptions();
|
|
50
|
-
},
|
|
44
|
+
};
|
|
45
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
51
46
|
};
|
|
52
|
-
PatchedCollator.prototype =
|
|
47
|
+
PatchedCollator.prototype = { constructor: PatchedCollator };
|
|
53
48
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
54
49
|
PatchedCollator.supportedLocalesOf = _Collator.supportedLocalesOf;
|
|
55
50
|
PatchedCollator.$original = _Collator;
|
|
@@ -64,11 +59,8 @@ _patchedLocaleCompare.$original = _localeCompare;
|
|
|
64
59
|
// NumberFormat
|
|
65
60
|
// ===========================================================================
|
|
66
61
|
const _NumberFormat = Intl.NumberFormat;
|
|
67
|
-
const reformatNumberParts = function (parts) {
|
|
68
|
-
|
|
69
|
-
return parts;
|
|
70
|
-
}
|
|
71
|
-
const options = this.super.resolvedOptions();
|
|
62
|
+
const reformatNumberParts = function (parent, parts) {
|
|
63
|
+
const options = parent.resolvedOptions();
|
|
72
64
|
if (options.style === 'currency' && options.currencyDisplay === 'symbol') {
|
|
73
65
|
const currency = options.currency;
|
|
74
66
|
if (currency === 'DKK' || currency === 'ISK') {
|
|
@@ -87,31 +79,21 @@ const PatchedNumberFormat = function NumberFormat(locales, options) {
|
|
|
87
79
|
return new PatchedNumberFormat(locales, options);
|
|
88
80
|
}
|
|
89
81
|
const mappedLocales = mapLocales(locales);
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
const parent = _NumberFormat(mappedLocales || locales, options);
|
|
83
|
+
const mapped = !!mappedLocales;
|
|
84
|
+
this.format = (value) => combineParts(this.formatToParts(value));
|
|
85
|
+
this.formatRange = (value1, value2) => combineParts(this.formatRangeToParts(value1, value2));
|
|
86
|
+
this.formatToParts = (value) => {
|
|
87
|
+
const parts = parent.formatToParts(value);
|
|
88
|
+
return mapped ? reformatNumberParts(parent, parts) : parts;
|
|
89
|
+
};
|
|
90
|
+
this.formatRangeToParts = (value1, value2) => {
|
|
91
|
+
const parts = parent.formatRangeToParts(value1, value2);
|
|
92
|
+
return mapped ? reformatNumberParts(parent, parts) : parts;
|
|
93
|
+
};
|
|
94
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
92
95
|
};
|
|
93
|
-
|
|
94
|
-
// ability to instantiate without `new` is a bit of a pain.
|
|
95
|
-
// Eagerly interested in finding a better way to do this.
|
|
96
|
-
const numberFormatProto = {
|
|
97
|
-
constructor: PatchedNumberFormat,
|
|
98
|
-
format(value) {
|
|
99
|
-
return combineParts(this.formatToParts(value));
|
|
100
|
-
},
|
|
101
|
-
formatRange(value1, value2) {
|
|
102
|
-
return combineParts(this.formatRangeToParts(value1, value2));
|
|
103
|
-
},
|
|
104
|
-
formatToParts(value) {
|
|
105
|
-
return reformatNumberParts.call(this, this.super.formatToParts(value));
|
|
106
|
-
},
|
|
107
|
-
formatRangeToParts(value1, value2) {
|
|
108
|
-
return reformatNumberParts.call(this, this.super.formatRangeToParts(value1, value2));
|
|
109
|
-
},
|
|
110
|
-
resolvedOptions() {
|
|
111
|
-
return this.super.resolvedOptions();
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
PatchedNumberFormat.prototype = numberFormatProto;
|
|
96
|
+
PatchedNumberFormat.prototype = { constructor: PatchedNumberFormat };
|
|
115
97
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
116
98
|
PatchedNumberFormat.supportedLocalesOf = _NumberFormat.supportedLocalesOf;
|
|
117
99
|
PatchedNumberFormat.$original = _NumberFormat;
|
|
@@ -197,11 +179,8 @@ const partMappers = {
|
|
|
197
179
|
}
|
|
198
180
|
},
|
|
199
181
|
};
|
|
200
|
-
const reformatDateTimeParts = function (parts) {
|
|
201
|
-
|
|
202
|
-
return parts;
|
|
203
|
-
}
|
|
204
|
-
const options = this.super.resolvedOptions();
|
|
182
|
+
const reformatDateTimeParts = function (parent, parts) {
|
|
183
|
+
const options = parent.resolvedOptions();
|
|
205
184
|
parts.forEach((part, idx) => {
|
|
206
185
|
var _a;
|
|
207
186
|
const mapper = partMappers[part.type];
|
|
@@ -226,31 +205,21 @@ const PatchedDateTimeFormat = function DateTimeFormat(locales, options) {
|
|
|
226
205
|
hourCycle: 'h11',
|
|
227
206
|
};
|
|
228
207
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
},
|
|
243
|
-
formatToParts(value) {
|
|
244
|
-
return reformatDateTimeParts.call(this, this.super.formatToParts(value));
|
|
245
|
-
},
|
|
246
|
-
formatRangeToParts(value1, value2) {
|
|
247
|
-
return reformatDateTimeParts.call(this, this.super.formatRangeToParts(value1, value2));
|
|
248
|
-
},
|
|
249
|
-
resolvedOptions() {
|
|
250
|
-
return this.super.resolvedOptions();
|
|
251
|
-
},
|
|
208
|
+
const parent = _DateTimeFormat(mappedLocales || locales, options);
|
|
209
|
+
const mapped = !!mappedLocales;
|
|
210
|
+
this.format = (value) => combineParts(this.formatToParts(value));
|
|
211
|
+
this.formatRange = (value1, value2) => combineParts(this.formatRangeToParts(value1, value2));
|
|
212
|
+
this.formatToParts = (value) => {
|
|
213
|
+
const parts = parent.formatToParts(value);
|
|
214
|
+
return mapped ? reformatDateTimeParts(parent, parts) : parts;
|
|
215
|
+
};
|
|
216
|
+
this.formatRangeToParts = (value1, value2) => {
|
|
217
|
+
const parts = parent.formatRangeToParts(value1, value2);
|
|
218
|
+
return mapped ? reformatDateTimeParts(parent, parts) : parts;
|
|
219
|
+
};
|
|
220
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
252
221
|
};
|
|
253
|
-
PatchedDateTimeFormat.prototype =
|
|
222
|
+
PatchedDateTimeFormat.prototype = { constructor: PatchedDateTimeFormat };
|
|
254
223
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
255
224
|
PatchedDateTimeFormat.supportedLocalesOf = _DateTimeFormat.supportedLocalesOf;
|
|
256
225
|
PatchedDateTimeFormat.$original = _DateTimeFormat;
|
|
@@ -277,6 +246,8 @@ if (_PluralRules) {
|
|
|
277
246
|
super(mappedLocales || locales, options);
|
|
278
247
|
this.mapped = !!mappedLocales;
|
|
279
248
|
this.ord = (options === null || options === void 0 ? void 0 : options.type) === 'ordinal';
|
|
249
|
+
this.select = this.select.bind(this);
|
|
250
|
+
this.selectRange = this.selectRange.bind(this);
|
|
280
251
|
}
|
|
281
252
|
select(n) {
|
|
282
253
|
if (this.mapped) {
|
|
@@ -310,6 +281,8 @@ if (_ListFormat) {
|
|
|
310
281
|
const mappedLocales = mapLocales(locales);
|
|
311
282
|
super(mappedLocales || locales, options);
|
|
312
283
|
this.mapped = !!mappedLocales;
|
|
284
|
+
this.format = this.format.bind(this);
|
|
285
|
+
this.formatToParts = this.formatToParts.bind(this);
|
|
313
286
|
}
|
|
314
287
|
format(list) {
|
|
315
288
|
return this.mapped ? combineParts(this.formatToParts(list)) : super.format(list);
|
|
@@ -30,29 +30,24 @@ const PatchedCollator = function Collator(locales, options) {
|
|
|
30
30
|
return new PatchedCollator(locales, options);
|
|
31
31
|
}
|
|
32
32
|
const mappedLocales = mapLocales(locales);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
constructor: PatchedCollator,
|
|
41
|
-
compare(a, b) {
|
|
42
|
-
const res1 = this.super.compare(a, b);
|
|
33
|
+
const parent = _Collator(mappedLocales || locales, options);
|
|
34
|
+
const mapped = !!mappedLocales;
|
|
35
|
+
this.compare = (a, b) => {
|
|
36
|
+
const res1 = parent.compare(a, b);
|
|
37
|
+
if (!mapped) {
|
|
38
|
+
return res1;
|
|
39
|
+
}
|
|
43
40
|
const a0 = a.charAt(0);
|
|
44
41
|
const b0 = b.charAt(0);
|
|
45
42
|
if (/\d/.test(a0 + b0)) {
|
|
46
43
|
return res1;
|
|
47
44
|
}
|
|
48
|
-
const res2 =
|
|
45
|
+
const res2 = parent.compare(a0, b0);
|
|
49
46
|
return res2 !== 0 ? res2 : res1;
|
|
50
|
-
}
|
|
51
|
-
resolvedOptions()
|
|
52
|
-
return this.super.resolvedOptions();
|
|
53
|
-
},
|
|
47
|
+
};
|
|
48
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
54
49
|
};
|
|
55
|
-
PatchedCollator.prototype =
|
|
50
|
+
PatchedCollator.prototype = { constructor: PatchedCollator };
|
|
56
51
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
57
52
|
PatchedCollator.supportedLocalesOf = _Collator.supportedLocalesOf;
|
|
58
53
|
PatchedCollator.$original = _Collator;
|
|
@@ -68,11 +63,8 @@ exports._patchedLocaleCompare.$original = _localeCompare;
|
|
|
68
63
|
// NumberFormat
|
|
69
64
|
// ===========================================================================
|
|
70
65
|
const _NumberFormat = Intl.NumberFormat;
|
|
71
|
-
const reformatNumberParts = function (parts) {
|
|
72
|
-
|
|
73
|
-
return parts;
|
|
74
|
-
}
|
|
75
|
-
const options = this.super.resolvedOptions();
|
|
66
|
+
const reformatNumberParts = function (parent, parts) {
|
|
67
|
+
const options = parent.resolvedOptions();
|
|
76
68
|
if (options.style === 'currency' && options.currencyDisplay === 'symbol') {
|
|
77
69
|
const currency = options.currency;
|
|
78
70
|
if (currency === 'DKK' || currency === 'ISK') {
|
|
@@ -91,31 +83,21 @@ const PatchedNumberFormat = function NumberFormat(locales, options) {
|
|
|
91
83
|
return new PatchedNumberFormat(locales, options);
|
|
92
84
|
}
|
|
93
85
|
const mappedLocales = mapLocales(locales);
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
const parent = _NumberFormat(mappedLocales || locales, options);
|
|
87
|
+
const mapped = !!mappedLocales;
|
|
88
|
+
this.format = (value) => combineParts(this.formatToParts(value));
|
|
89
|
+
this.formatRange = (value1, value2) => combineParts(this.formatRangeToParts(value1, value2));
|
|
90
|
+
this.formatToParts = (value) => {
|
|
91
|
+
const parts = parent.formatToParts(value);
|
|
92
|
+
return mapped ? reformatNumberParts(parent, parts) : parts;
|
|
93
|
+
};
|
|
94
|
+
this.formatRangeToParts = (value1, value2) => {
|
|
95
|
+
const parts = parent.formatRangeToParts(value1, value2);
|
|
96
|
+
return mapped ? reformatNumberParts(parent, parts) : parts;
|
|
97
|
+
};
|
|
98
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
96
99
|
};
|
|
97
|
-
|
|
98
|
-
// ability to instantiate without `new` is a bit of a pain.
|
|
99
|
-
// Eagerly interested in finding a better way to do this.
|
|
100
|
-
const numberFormatProto = {
|
|
101
|
-
constructor: PatchedNumberFormat,
|
|
102
|
-
format(value) {
|
|
103
|
-
return combineParts(this.formatToParts(value));
|
|
104
|
-
},
|
|
105
|
-
formatRange(value1, value2) {
|
|
106
|
-
return combineParts(this.formatRangeToParts(value1, value2));
|
|
107
|
-
},
|
|
108
|
-
formatToParts(value) {
|
|
109
|
-
return reformatNumberParts.call(this, this.super.formatToParts(value));
|
|
110
|
-
},
|
|
111
|
-
formatRangeToParts(value1, value2) {
|
|
112
|
-
return reformatNumberParts.call(this, this.super.formatRangeToParts(value1, value2));
|
|
113
|
-
},
|
|
114
|
-
resolvedOptions() {
|
|
115
|
-
return this.super.resolvedOptions();
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
PatchedNumberFormat.prototype = numberFormatProto;
|
|
100
|
+
PatchedNumberFormat.prototype = { constructor: PatchedNumberFormat };
|
|
119
101
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
120
102
|
PatchedNumberFormat.supportedLocalesOf = _NumberFormat.supportedLocalesOf;
|
|
121
103
|
PatchedNumberFormat.$original = _NumberFormat;
|
|
@@ -202,11 +184,8 @@ const partMappers = {
|
|
|
202
184
|
}
|
|
203
185
|
},
|
|
204
186
|
};
|
|
205
|
-
const reformatDateTimeParts = function (parts) {
|
|
206
|
-
|
|
207
|
-
return parts;
|
|
208
|
-
}
|
|
209
|
-
const options = this.super.resolvedOptions();
|
|
187
|
+
const reformatDateTimeParts = function (parent, parts) {
|
|
188
|
+
const options = parent.resolvedOptions();
|
|
210
189
|
parts.forEach((part, idx) => {
|
|
211
190
|
var _a;
|
|
212
191
|
const mapper = partMappers[part.type];
|
|
@@ -231,31 +210,21 @@ const PatchedDateTimeFormat = function DateTimeFormat(locales, options) {
|
|
|
231
210
|
hourCycle: 'h11',
|
|
232
211
|
};
|
|
233
212
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
formatToParts(value) {
|
|
249
|
-
return reformatDateTimeParts.call(this, this.super.formatToParts(value));
|
|
250
|
-
},
|
|
251
|
-
formatRangeToParts(value1, value2) {
|
|
252
|
-
return reformatDateTimeParts.call(this, this.super.formatRangeToParts(value1, value2));
|
|
253
|
-
},
|
|
254
|
-
resolvedOptions() {
|
|
255
|
-
return this.super.resolvedOptions();
|
|
256
|
-
},
|
|
213
|
+
const parent = _DateTimeFormat(mappedLocales || locales, options);
|
|
214
|
+
const mapped = !!mappedLocales;
|
|
215
|
+
this.format = (value) => combineParts(this.formatToParts(value));
|
|
216
|
+
this.formatRange = (value1, value2) => combineParts(this.formatRangeToParts(value1, value2));
|
|
217
|
+
this.formatToParts = (value) => {
|
|
218
|
+
const parts = parent.formatToParts(value);
|
|
219
|
+
return mapped ? reformatDateTimeParts(parent, parts) : parts;
|
|
220
|
+
};
|
|
221
|
+
this.formatRangeToParts = (value1, value2) => {
|
|
222
|
+
const parts = parent.formatRangeToParts(value1, value2);
|
|
223
|
+
return mapped ? reformatDateTimeParts(parent, parts) : parts;
|
|
224
|
+
};
|
|
225
|
+
this.resolvedOptions = () => parent.resolvedOptions();
|
|
257
226
|
};
|
|
258
|
-
PatchedDateTimeFormat.prototype =
|
|
227
|
+
PatchedDateTimeFormat.prototype = { constructor: PatchedDateTimeFormat };
|
|
259
228
|
// Static methods (not patched since "is" is not ACTUALLY supported.)
|
|
260
229
|
PatchedDateTimeFormat.supportedLocalesOf = _DateTimeFormat.supportedLocalesOf;
|
|
261
230
|
PatchedDateTimeFormat.$original = _DateTimeFormat;
|
|
@@ -283,6 +252,8 @@ if (_PluralRules) {
|
|
|
283
252
|
super(mappedLocales || locales, options);
|
|
284
253
|
this.mapped = !!mappedLocales;
|
|
285
254
|
this.ord = (options === null || options === void 0 ? void 0 : options.type) === 'ordinal';
|
|
255
|
+
this.select = this.select.bind(this);
|
|
256
|
+
this.selectRange = this.selectRange.bind(this);
|
|
286
257
|
}
|
|
287
258
|
select(n) {
|
|
288
259
|
if (this.mapped) {
|
|
@@ -316,6 +287,8 @@ if (_ListFormat) {
|
|
|
316
287
|
const mappedLocales = mapLocales(locales);
|
|
317
288
|
super(mappedLocales || locales, options);
|
|
318
289
|
this.mapped = !!mappedLocales;
|
|
290
|
+
this.format = this.format.bind(this);
|
|
291
|
+
this.formatToParts = this.formatToParts.bind(this);
|
|
319
292
|
}
|
|
320
293
|
format(list) {
|
|
321
294
|
return this.mapped ? combineParts(this.formatToParts(list)) : super.format(list);
|
package/package.json
CHANGED