@citygross/components 0.17.3 → 0.17.4
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/build/cjs/components/src/components/AddressBlock/AddressBlock.js +0 -1
- package/build/cjs/components/src/components/AddressBlock/AddressBlock.js.map +1 -1
- package/build/cjs/components/src/containers/TwoColumnsContainer/TwoColumnsPageContainer.js +2 -2
- package/build/es/components/src/components/AddressBlock/AddressBlock.js +0 -1
- package/build/es/components/src/components/AddressBlock/AddressBlock.js.map +1 -1
- package/build/es/components/src/containers/TwoColumnsContainer/TwoColumnsPageContainer.js +2 -2
- package/package.json +2 -2
- package/build/cjs/_virtual/index2.js +0 -8
- package/build/cjs/_virtual/index2.js.map +0 -1
- package/build/cjs/utils/build/index.js +0 -641
- package/build/cjs/utils/build/index.js.map +0 -1
- package/build/es/_virtual/index2.js +0 -4
- package/build/es/_virtual/index2.js.map +0 -1
- package/build/es/utils/build/index.js +0 -631
- package/build/es/utils/build/index.js.map +0 -1
|
@@ -1,641 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index = require('../../_virtual/index2.js');
|
|
6
|
-
var React$1 = require('react');
|
|
7
|
-
var require$$1 = require('date-fns');
|
|
8
|
-
var require$$2 = require('date-fns/locale');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var React__default$1 = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
13
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
14
|
-
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(index.__exports, '__esModule', { value: true });
|
|
17
|
-
|
|
18
|
-
var React = React__default$1["default"];
|
|
19
|
-
var dateFns = require$$1__default["default"];
|
|
20
|
-
var locale = require$$2__default["default"];
|
|
21
|
-
|
|
22
|
-
function _interopDefaultLegacy$1 (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy$1(React);
|
|
25
|
-
|
|
26
|
-
var formatPrice = function (price, withParenthesis) {
|
|
27
|
-
if (price === null || price === undefined) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
var formattedPrice = price === 0
|
|
31
|
-
? 0
|
|
32
|
-
: (Math.round(price * 100) / 100)
|
|
33
|
-
.toFixed(2)
|
|
34
|
-
.replace('.', ',')
|
|
35
|
-
.replace(',00', '');
|
|
36
|
-
return "".concat(withParenthesis ? "(".concat(formattedPrice, " kr)") : "".concat(formattedPrice, " kr"));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var formatPriceWithDecimalsReduced = function (price) {
|
|
40
|
-
if ((price !== 0 && !price) || isNaN(price)) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
var priceArr = price && price.toString().split('.');
|
|
44
|
-
var decimalCount = priceArr && priceArr[1] ? priceArr[1].length : 0;
|
|
45
|
-
//Remove decimals
|
|
46
|
-
var priceInteger = Math.trunc(price);
|
|
47
|
-
// Avoid rounding errors, since JS can't do math
|
|
48
|
-
var priceDecimals = (price - priceInteger).toFixed(2).toString();
|
|
49
|
-
var decimalsArr = priceDecimals.split('.');
|
|
50
|
-
priceDecimals = decimalsArr.length > 1 ? decimalsArr[1] : priceDecimals;
|
|
51
|
-
// Pad with leading 0 if single number
|
|
52
|
-
var priceDecimalsReduced = priceDecimals.length < 2 ? '0' + priceDecimals : priceDecimals;
|
|
53
|
-
return {
|
|
54
|
-
value: priceInteger,
|
|
55
|
-
decimal: priceDecimalsReduced,
|
|
56
|
-
decimalCount: decimalCount
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var formatPriceWithNoZero = function (price) {
|
|
61
|
-
if ((price !== 0 && !price) || isNaN(price)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
var formattedPrice = formatPriceWithDecimalsReduced(price);
|
|
65
|
-
return "".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.value).concat("".concat((formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) !== '00' ? ",".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) : ''));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var capitalizeFirstLetter = function (string) {
|
|
69
|
-
if (string.length > 1) {
|
|
70
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
71
|
-
}
|
|
72
|
-
if (string[0]) {
|
|
73
|
-
return string.toUpperCase();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
var capitalizedAllWords = function (string) {
|
|
77
|
-
return string.replace(/(^\w|\s\w)/g, function (match) { return match.toUpperCase(); });
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
var languageCodeToCountryMap = {
|
|
81
|
-
AD: 'Andorra',
|
|
82
|
-
AE: 'Förenade Arabemiraten',
|
|
83
|
-
AF: 'Afghanistan',
|
|
84
|
-
AG: 'Antigua och Barbuda',
|
|
85
|
-
AI: 'Anguilla',
|
|
86
|
-
AL: 'Albanien',
|
|
87
|
-
AM: 'Armenien',
|
|
88
|
-
AO: 'Angola',
|
|
89
|
-
AQ: 'Antarktis',
|
|
90
|
-
AR: 'Argentina',
|
|
91
|
-
AS: 'Amerikanska Samoa',
|
|
92
|
-
AT: 'Österrike',
|
|
93
|
-
AU: 'Australien',
|
|
94
|
-
AW: 'Aruba',
|
|
95
|
-
AX: 'Åland',
|
|
96
|
-
AZ: 'Azerbajdzjan',
|
|
97
|
-
BA: 'Bosnien och Hercegovina',
|
|
98
|
-
BB: 'Barbados',
|
|
99
|
-
BD: 'Bangladesh',
|
|
100
|
-
BE: 'Belgien',
|
|
101
|
-
BF: 'Burkina Faso',
|
|
102
|
-
BG: 'Bulgarien',
|
|
103
|
-
BH: 'Bahrain',
|
|
104
|
-
BI: 'Burundi',
|
|
105
|
-
BJ: 'Benin',
|
|
106
|
-
BL: 'Saint-Barthélemy',
|
|
107
|
-
BM: 'Bermuda',
|
|
108
|
-
BN: 'Brunei',
|
|
109
|
-
BO: 'Bolivia',
|
|
110
|
-
BQ: 'Bonaire, Sint Eustatius and Saba',
|
|
111
|
-
BR: 'Brasilien',
|
|
112
|
-
BS: 'Bahamas',
|
|
113
|
-
BT: 'Bhutan',
|
|
114
|
-
BV: 'Bouvetön',
|
|
115
|
-
BW: 'Botswana',
|
|
116
|
-
BY: 'Belarus',
|
|
117
|
-
BZ: 'Belize',
|
|
118
|
-
CA: 'Kanada',
|
|
119
|
-
CC: 'Kokosöarna',
|
|
120
|
-
CD: 'Kongo-Kinshasa',
|
|
121
|
-
CF: 'Centralafrikanska republiken',
|
|
122
|
-
CG: 'Kongo-Brazzaville',
|
|
123
|
-
CH: 'Schweiz',
|
|
124
|
-
CI: 'Elfenbenskusten',
|
|
125
|
-
CK: 'Cooköarna',
|
|
126
|
-
CL: 'Chile',
|
|
127
|
-
CM: 'Kamerun',
|
|
128
|
-
CN: 'Kina',
|
|
129
|
-
CO: 'Colombia',
|
|
130
|
-
CR: 'Costa Rica',
|
|
131
|
-
CU: 'Kuba',
|
|
132
|
-
CV: 'Kap Verde',
|
|
133
|
-
CW: 'Curaçao',
|
|
134
|
-
CX: 'Julön',
|
|
135
|
-
CY: 'Cypern',
|
|
136
|
-
CZ: 'Tjeckien',
|
|
137
|
-
DE: 'Tyskland',
|
|
138
|
-
DJ: 'Djibouti',
|
|
139
|
-
DK: 'Danmark',
|
|
140
|
-
DM: 'Dominica',
|
|
141
|
-
DO: 'Dominikanska republiken',
|
|
142
|
-
DZ: 'Algeriet',
|
|
143
|
-
EC: 'Ecuador',
|
|
144
|
-
EE: 'Estland',
|
|
145
|
-
EG: 'Egypten',
|
|
146
|
-
EH: 'Västsahara',
|
|
147
|
-
ER: 'Eritrea',
|
|
148
|
-
ES: 'Spanien',
|
|
149
|
-
ET: 'Etiopien',
|
|
150
|
-
FI: 'Finland',
|
|
151
|
-
FJ: 'Fiji',
|
|
152
|
-
FK: 'Falklandsöarna',
|
|
153
|
-
FM: 'Mikronesiska federationen',
|
|
154
|
-
FO: 'Färöarna',
|
|
155
|
-
FR: 'Frankrike',
|
|
156
|
-
GA: 'Gabon',
|
|
157
|
-
GB: 'Storbritannien',
|
|
158
|
-
GD: 'Grenada',
|
|
159
|
-
GE: 'Georgien',
|
|
160
|
-
GF: 'Franska Guyana',
|
|
161
|
-
GG: 'Guernsey',
|
|
162
|
-
GH: 'Ghana',
|
|
163
|
-
GI: 'Gibraltar',
|
|
164
|
-
GL: 'Grönland',
|
|
165
|
-
GM: 'Gambia',
|
|
166
|
-
GN: 'Guinea',
|
|
167
|
-
GP: 'Guadeloupe',
|
|
168
|
-
GQ: 'Ekvatorialguinea',
|
|
169
|
-
GR: 'Grekland',
|
|
170
|
-
GS: 'Sydgeorgien',
|
|
171
|
-
GT: 'Guatemala',
|
|
172
|
-
GU: 'Guam',
|
|
173
|
-
GW: 'Guinea-Bissau',
|
|
174
|
-
GY: 'Guyana',
|
|
175
|
-
HK: 'Hongkong',
|
|
176
|
-
HM: 'Heard- och McDonaldöarna',
|
|
177
|
-
HN: 'Honduras',
|
|
178
|
-
HR: 'Kroatien',
|
|
179
|
-
HT: 'Haiti',
|
|
180
|
-
HU: 'Ungern',
|
|
181
|
-
ID: 'Indonesien',
|
|
182
|
-
IE: 'Irland',
|
|
183
|
-
IL: 'Israel',
|
|
184
|
-
IM: 'Isle of Man',
|
|
185
|
-
IN: 'Indien',
|
|
186
|
-
IO: 'Brittiska territoriet i Indiska Oceanen',
|
|
187
|
-
IQ: 'Irak',
|
|
188
|
-
IR: 'Iran',
|
|
189
|
-
IS: 'Island',
|
|
190
|
-
IT: 'Italien',
|
|
191
|
-
JE: 'Jersey',
|
|
192
|
-
JM: 'Jamaica',
|
|
193
|
-
JO: 'Jordanien',
|
|
194
|
-
JP: 'Japan',
|
|
195
|
-
KE: 'Kenya',
|
|
196
|
-
KG: 'Kirgizistan',
|
|
197
|
-
KH: 'Kambodja',
|
|
198
|
-
KI: 'Kiribati',
|
|
199
|
-
KM: 'Komorerna',
|
|
200
|
-
KN: 'Saint Kitts och Nevis',
|
|
201
|
-
KP: 'Nordkorea',
|
|
202
|
-
KR: 'Sydkorea',
|
|
203
|
-
KW: 'Kuwait',
|
|
204
|
-
KY: 'Caymanöarna',
|
|
205
|
-
KZ: 'Kazakstan',
|
|
206
|
-
LA: 'Laos',
|
|
207
|
-
LB: 'Libanon',
|
|
208
|
-
LC: 'Saint Lucia',
|
|
209
|
-
LI: 'Liechtenstein',
|
|
210
|
-
LK: 'Sri Lanka',
|
|
211
|
-
LR: 'Liberia',
|
|
212
|
-
LS: 'Lesotho',
|
|
213
|
-
LT: 'Litauen',
|
|
214
|
-
LU: 'Luxemburg',
|
|
215
|
-
LV: 'Lettland',
|
|
216
|
-
LY: 'Libyen',
|
|
217
|
-
MA: 'Marocko',
|
|
218
|
-
MC: 'Monaco',
|
|
219
|
-
MD: 'Moldavien',
|
|
220
|
-
ME: 'Montenegro',
|
|
221
|
-
MF: 'Saint-Martin',
|
|
222
|
-
MG: 'Madagaskar',
|
|
223
|
-
MH: 'Marshallöarna',
|
|
224
|
-
MK: 'Nordmakedonien',
|
|
225
|
-
ML: 'Mali',
|
|
226
|
-
MM: 'Myanmar',
|
|
227
|
-
MN: 'Mongoliet',
|
|
228
|
-
MO: 'Macao',
|
|
229
|
-
MP: 'Nordmarianerna',
|
|
230
|
-
MQ: 'Martinique',
|
|
231
|
-
MR: 'Mauretanien',
|
|
232
|
-
MS: 'Montserrat',
|
|
233
|
-
MT: 'Malta',
|
|
234
|
-
MU: 'Mauritius',
|
|
235
|
-
MV: 'Maldiverna',
|
|
236
|
-
MW: 'Malawi',
|
|
237
|
-
MX: 'Mexiko',
|
|
238
|
-
MY: 'Malaysia',
|
|
239
|
-
MZ: 'Moçambique',
|
|
240
|
-
NA: 'Namibia',
|
|
241
|
-
NC: 'Nya Kaledonien',
|
|
242
|
-
NE: 'Niger',
|
|
243
|
-
NF: 'Norfolkön',
|
|
244
|
-
NG: 'Nigeria',
|
|
245
|
-
NI: 'Nicaragua',
|
|
246
|
-
NL: 'Nederländerna',
|
|
247
|
-
NO: 'Norge',
|
|
248
|
-
NP: 'Nepal',
|
|
249
|
-
NR: 'Nauru',
|
|
250
|
-
NU: 'Niue',
|
|
251
|
-
NZ: 'Nya Zeeland',
|
|
252
|
-
OM: 'Oman',
|
|
253
|
-
PA: 'Panama',
|
|
254
|
-
PE: 'Peru',
|
|
255
|
-
PF: 'Franska Polynesien',
|
|
256
|
-
PG: 'Papua Nya Guinea',
|
|
257
|
-
PH: 'Filippinerna',
|
|
258
|
-
PK: 'Pakistan',
|
|
259
|
-
PL: 'Polen',
|
|
260
|
-
PM: 'Saint-Pierre och Miquelon',
|
|
261
|
-
PN: 'Pitcairnöarna',
|
|
262
|
-
PR: 'Puerto Rico',
|
|
263
|
-
PS: 'Palestina',
|
|
264
|
-
PT: 'Portugal',
|
|
265
|
-
PW: 'Palau',
|
|
266
|
-
PY: 'Paraguay',
|
|
267
|
-
QA: 'Qatar',
|
|
268
|
-
RE: 'Réunion',
|
|
269
|
-
RO: 'Rumänien',
|
|
270
|
-
RS: 'Serbien',
|
|
271
|
-
RU: 'Ryssland',
|
|
272
|
-
RW: 'Rwanda',
|
|
273
|
-
SA: 'Saudiarabien',
|
|
274
|
-
SB: 'Salomonöarna',
|
|
275
|
-
SC: 'Seychellerna',
|
|
276
|
-
SD: 'Sudan',
|
|
277
|
-
SE: 'Sverige',
|
|
278
|
-
SG: 'Singapore',
|
|
279
|
-
SH: 'Sankta Helena',
|
|
280
|
-
SI: 'Slovenien',
|
|
281
|
-
SJ: 'Svalbard och Jan Mayen',
|
|
282
|
-
SK: 'Slovakien',
|
|
283
|
-
SL: 'Sierra Leone',
|
|
284
|
-
SM: 'San Marino',
|
|
285
|
-
SN: 'Senegal',
|
|
286
|
-
SO: 'Somalia',
|
|
287
|
-
SR: 'Surinam',
|
|
288
|
-
SS: 'Sydsudan',
|
|
289
|
-
ST: 'São Tomé och Príncipe',
|
|
290
|
-
SV: 'El Salvador',
|
|
291
|
-
SX: 'Sint Maarten',
|
|
292
|
-
SY: 'Syrien',
|
|
293
|
-
SZ: 'Swaziland',
|
|
294
|
-
TC: 'Turks- och Caicosöarna',
|
|
295
|
-
TD: 'Tchad',
|
|
296
|
-
TF: 'Franska södra territorierna',
|
|
297
|
-
TG: 'Togo',
|
|
298
|
-
TH: 'Thailand',
|
|
299
|
-
TJ: 'Tadzjikistan',
|
|
300
|
-
TK: 'Tokelauöarna',
|
|
301
|
-
TL: 'Östtimor',
|
|
302
|
-
TM: 'Turkmenistan',
|
|
303
|
-
TN: 'Tunisien',
|
|
304
|
-
TO: 'Tonga',
|
|
305
|
-
TR: 'Turkiet',
|
|
306
|
-
TT: 'Trinidad och Tobago',
|
|
307
|
-
TV: 'Tuvalu',
|
|
308
|
-
TW: 'Taiwan',
|
|
309
|
-
TZ: 'Tanzania',
|
|
310
|
-
UA: 'Ukraina',
|
|
311
|
-
UG: 'Uganda',
|
|
312
|
-
UM: 'Förenta staternas mindre öar i Oceanien och Västindien',
|
|
313
|
-
US: 'USA',
|
|
314
|
-
UY: 'Uruguay',
|
|
315
|
-
UZ: 'Uzbekistan',
|
|
316
|
-
VA: 'Vatikanstaten',
|
|
317
|
-
VC: 'Saint Vincent och Grenadinerna',
|
|
318
|
-
VE: 'Venezuela',
|
|
319
|
-
VG: 'Brittiska Jungfruöarna',
|
|
320
|
-
VI: 'Amerikanska Jungfruöarna',
|
|
321
|
-
VN: 'Vietnam',
|
|
322
|
-
VU: 'Vanuatu',
|
|
323
|
-
WF: 'Wallis- och Futunaöarna',
|
|
324
|
-
WS: 'Samoa',
|
|
325
|
-
YE: 'Jemen',
|
|
326
|
-
YT: 'Mayotte',
|
|
327
|
-
ZA: 'Sydafrika',
|
|
328
|
-
ZM: 'Zambia',
|
|
329
|
-
ZW: 'Zimbabwe'
|
|
330
|
-
};
|
|
331
|
-
var getCountryFromLanguageCode = function (languageCode) {
|
|
332
|
-
return languageCodeToCountryMap[languageCode] || '';
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
var useDetectDevice = function () {
|
|
336
|
-
var _a = React__default["default"].useState(false), isMobile = _a[0], setMobile = _a[1];
|
|
337
|
-
React__default["default"].useEffect(function () {
|
|
338
|
-
var userAgent = typeof window.navigator === 'undefined' ? '' : navigator.userAgent;
|
|
339
|
-
var mobile = Boolean(userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile|WPDesktop/i) || window.screen.width < 1024);
|
|
340
|
-
setMobile(mobile);
|
|
341
|
-
}, []);
|
|
342
|
-
return { isMobile: isMobile };
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
function useWindowSize() {
|
|
346
|
-
var _a = React.useState({
|
|
347
|
-
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
348
|
-
height: typeof window !== 'undefined' ? window.innerHeight : 0
|
|
349
|
-
}), windowSize = _a[0], setWindowSize = _a[1];
|
|
350
|
-
React.useEffect(function () {
|
|
351
|
-
function handleResize() {
|
|
352
|
-
setWindowSize({
|
|
353
|
-
width: window.innerWidth,
|
|
354
|
-
height: window.innerHeight
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
window.addEventListener('resize', handleResize);
|
|
358
|
-
handleResize();
|
|
359
|
-
// Remove event listener on cleanup
|
|
360
|
-
return function () { return window.removeEventListener('resize', handleResize); };
|
|
361
|
-
}, []);
|
|
362
|
-
return { width: windowSize.width, height: windowSize.height };
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var useOutsideClick = function (ref, callback) {
|
|
366
|
-
React.useEffect(function () {
|
|
367
|
-
var handleClick = function (e) {
|
|
368
|
-
var target = e.target;
|
|
369
|
-
if ((ref === null || ref === void 0 ? void 0 : ref.current) && target && !ref.current.contains(target)) {
|
|
370
|
-
callback();
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
document === null || document === void 0 ? void 0 : document.addEventListener('click', handleClick, true);
|
|
374
|
-
return function () {
|
|
375
|
-
document === null || document === void 0 ? void 0 : document.removeEventListener('click', handleClick, true);
|
|
376
|
-
};
|
|
377
|
-
}, [ref, callback]);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
var useFixedModalScroll = function (active, querySelector) {
|
|
381
|
-
var _a = React.useState(0), prevPosition = _a[0], setPrevPosition = _a[1];
|
|
382
|
-
React.useEffect(function () {
|
|
383
|
-
var pos = window === null || window === void 0 ? void 0 : window.scrollY;
|
|
384
|
-
var selector = querySelector || (document === null || document === void 0 ? void 0 : document.body);
|
|
385
|
-
if (!selector)
|
|
386
|
-
return;
|
|
387
|
-
var savedStyles = {
|
|
388
|
-
top: selector.style.top,
|
|
389
|
-
overflowY: selector.style.overflowY,
|
|
390
|
-
position: selector.style.position,
|
|
391
|
-
scrollY: pos
|
|
392
|
-
};
|
|
393
|
-
if (active) {
|
|
394
|
-
setPrevPosition(pos);
|
|
395
|
-
selector.style.overflowY = 'scroll';
|
|
396
|
-
selector.style.position = 'fixed';
|
|
397
|
-
selector.style.top = -pos + 'px';
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
selector.style.removeProperty('top');
|
|
401
|
-
selector.style.overflowY = 'auto';
|
|
402
|
-
selector.style.position = 'relative';
|
|
403
|
-
if (prevPosition) {
|
|
404
|
-
window.scrollTo(0, prevPosition);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return function () {
|
|
408
|
-
if (selector) {
|
|
409
|
-
if (savedStyles.top) {
|
|
410
|
-
selector.style.top = savedStyles.top;
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
selector.style.removeProperty('top');
|
|
414
|
-
}
|
|
415
|
-
if (savedStyles.overflowY) {
|
|
416
|
-
selector.style.overflowY = savedStyles.overflowY;
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
selector.style.overflowY = 'auto';
|
|
420
|
-
}
|
|
421
|
-
if (savedStyles.position) {
|
|
422
|
-
selector.style.position = savedStyles.position;
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
selector.style.position = 'relative';
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
}, [active, querySelector]);
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
function comparisonTypes(type) {
|
|
433
|
-
if (!type) {
|
|
434
|
-
return '';
|
|
435
|
-
}
|
|
436
|
-
switch (type) {
|
|
437
|
-
case 'KGM':
|
|
438
|
-
return 'kg';
|
|
439
|
-
case 'G':
|
|
440
|
-
return 'g';
|
|
441
|
-
case 'LTR':
|
|
442
|
-
return 'l';
|
|
443
|
-
case 'PCE':
|
|
444
|
-
return 'st';
|
|
445
|
-
case 'H87':
|
|
446
|
-
return 'st';
|
|
447
|
-
case 'm':
|
|
448
|
-
return 'm';
|
|
449
|
-
case 'MM':
|
|
450
|
-
return 'm';
|
|
451
|
-
case 'MTR':
|
|
452
|
-
return 'm';
|
|
453
|
-
case 'DSK':
|
|
454
|
-
return 'disk';
|
|
455
|
-
case 'TVA':
|
|
456
|
-
return 'tvätt';
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
var phoneRegex = /^[0-9]{7,14}$/;
|
|
461
|
-
var nameRegex = /^[a-ö, A-Ö]$/;
|
|
462
|
-
var zipRegex = /(^\d{5}$)|(^\d{3} \d{2}$)/;
|
|
463
|
-
// Taken from https://stackoverflow.com/a/46181
|
|
464
|
-
var emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
465
|
-
var validateInput = function (input, regex) {
|
|
466
|
-
return regex.test(input);
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
var makeCateringPortionsString = function (variant, cartItem, unit) {
|
|
470
|
-
var _a, _b;
|
|
471
|
-
if (unit !== 'per person')
|
|
472
|
-
return;
|
|
473
|
-
var qString = '';
|
|
474
|
-
if ((variant === null || variant === void 0 ? void 0 : variant.quantityFrom) || (variant === null || variant === void 0 ? void 0 : variant.quantityTo)) {
|
|
475
|
-
if (variant === null || variant === void 0 ? void 0 : variant.quantityFrom)
|
|
476
|
-
qString += variant === null || variant === void 0 ? void 0 : variant.quantityFrom;
|
|
477
|
-
if (variant === null || variant === void 0 ? void 0 : variant.quantityTo)
|
|
478
|
-
qString += " - ".concat(variant === null || variant === void 0 ? void 0 : variant.quantityTo);
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
qString = (variant === null || variant === void 0 ? void 0 : variant.quantityFrom)
|
|
482
|
-
? (_a = variant === null || variant === void 0 ? void 0 : variant.quantityFrom) === null || _a === void 0 ? void 0 : _a.toString()
|
|
483
|
-
: (_b = cartItem === null || cartItem === void 0 ? void 0 : cartItem.value) === null || _b === void 0 ? void 0 : _b.toString();
|
|
484
|
-
}
|
|
485
|
-
return qString;
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var focusableSelectors = 'button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
489
|
-
var focusTrap = function (_a) {
|
|
490
|
-
var _b;
|
|
491
|
-
var exitFunction = _a.exitFunction, ref = _a.ref;
|
|
492
|
-
var focusableElements = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(focusableSelectors);
|
|
493
|
-
if (focusableElements &&
|
|
494
|
-
focusableElements.length > 0 &&
|
|
495
|
-
focusableElements[0] instanceof HTMLElement) {
|
|
496
|
-
focusableElements[0].focus();
|
|
497
|
-
}
|
|
498
|
-
var handleKeyDown = function (e) {
|
|
499
|
-
if (!ref.current)
|
|
500
|
-
return;
|
|
501
|
-
var focusable = Array.from(ref.current.querySelectorAll(focusableSelectors));
|
|
502
|
-
if (focusable.length === 0)
|
|
503
|
-
return;
|
|
504
|
-
var firstElement = focusable[0];
|
|
505
|
-
var lastElement = focusable[focusable.length - 1];
|
|
506
|
-
if (e.key === 'Tab') {
|
|
507
|
-
if (e.shiftKey && document.activeElement === firstElement) {
|
|
508
|
-
e.preventDefault();
|
|
509
|
-
lastElement.focus();
|
|
510
|
-
}
|
|
511
|
-
else if (!e.shiftKey && document.activeElement === lastElement) {
|
|
512
|
-
e.preventDefault();
|
|
513
|
-
firstElement.focus();
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
else if (e.key === 'Escape')
|
|
517
|
-
exitFunction();
|
|
518
|
-
};
|
|
519
|
-
if (ref.current)
|
|
520
|
-
ref.current.addEventListener('keydown', handleKeyDown);
|
|
521
|
-
return function () {
|
|
522
|
-
if (ref.current)
|
|
523
|
-
ref.current.removeEventListener('keydown', handleKeyDown);
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
var escapeKeyboardEventHandler = function (_a) {
|
|
528
|
-
var event = _a.event, onEscape = _a.onEscape;
|
|
529
|
-
if (event.key === 'Escape')
|
|
530
|
-
onEscape();
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
var selectKeyboardEventHandler = function (_a) {
|
|
534
|
-
var event = _a.event, isDisabled = _a.isDisabled, onClick = _a.onClick, onKeyDown = _a.onKeyDown, value = _a.value;
|
|
535
|
-
if ((event.key === 'Enter' || event.key === ' ') && !isDisabled) {
|
|
536
|
-
event.preventDefault();
|
|
537
|
-
onClick(value);
|
|
538
|
-
}
|
|
539
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
var toggleInert = function (_a) {
|
|
543
|
-
var elements = _a.elements, isInert = _a.isInert;
|
|
544
|
-
var list = elements.filter(function (element) {
|
|
545
|
-
return Boolean(element);
|
|
546
|
-
});
|
|
547
|
-
if (!isInert) {
|
|
548
|
-
list.forEach(function (element) {
|
|
549
|
-
var hadInert = element.hasAttribute('inert');
|
|
550
|
-
if (!hadInert) {
|
|
551
|
-
element.removeAttribute('inert');
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
return function () { };
|
|
555
|
-
}
|
|
556
|
-
var snapshots = list.map(function (element) { return ({
|
|
557
|
-
element: element,
|
|
558
|
-
setByThisCall: !element.hasAttribute('inert')
|
|
559
|
-
}); });
|
|
560
|
-
snapshots.forEach(function (_a) {
|
|
561
|
-
var element = _a.element, setByThisCall = _a.setByThisCall;
|
|
562
|
-
if (setByThisCall) {
|
|
563
|
-
element.setAttribute('inert', '');
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
return function () {
|
|
567
|
-
snapshots.forEach(function (_a) {
|
|
568
|
-
var element = _a.element, setByThisCall = _a.setByThisCall;
|
|
569
|
-
if (setByThisCall) {
|
|
570
|
-
element.removeAttribute('inert');
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
var formatLeadingZero = function (day) { return day.replace(/^0+/, ''); };
|
|
577
|
-
|
|
578
|
-
var formatPostalCode = function (postalCode, spaceIndex) {
|
|
579
|
-
var _a;
|
|
580
|
-
if (!(postalCode === null || postalCode === void 0 ? void 0 : postalCode.length))
|
|
581
|
-
return null;
|
|
582
|
-
return (_a = postalCode.split('')) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, curr, index) {
|
|
583
|
-
if (index === (spaceIndex || 3)) {
|
|
584
|
-
return "".concat(acc, " ").concat(curr);
|
|
585
|
-
}
|
|
586
|
-
return "".concat(acc).concat(curr);
|
|
587
|
-
});
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
var formatDateToLocale = function (date, withYear, withDay) {
|
|
591
|
-
var _a;
|
|
592
|
-
return (_a = dateFns.format(new Date(date), "".concat(withDay ? 'EEEE ' : '', "d MMMM ").concat(withYear ? 'yyyy' : ''), { locale: locale.sv })) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
function getDateInfo(dateStr) {
|
|
596
|
-
var date = new Date(dateStr);
|
|
597
|
-
return {
|
|
598
|
-
day: {
|
|
599
|
-
name: dateFns.format(date, 'EEEE', { locale: locale.sv }),
|
|
600
|
-
number: dateFns.format(date, 'd')
|
|
601
|
-
},
|
|
602
|
-
isTomorrow: dateFns.isSameDay(date, dateFns.addDays(new Date(), 1)),
|
|
603
|
-
month: {
|
|
604
|
-
name: dateFns.format(date, 'MMMM', { locale: locale.sv }),
|
|
605
|
-
number: dateFns.format(date, 'M')
|
|
606
|
-
},
|
|
607
|
-
year: dateFns.format(date, 'yyyy')
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
index.__exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
612
|
-
index.__exports.capitalizedAllWords = capitalizedAllWords;
|
|
613
|
-
index.__exports.comparisonTypes = comparisonTypes;
|
|
614
|
-
index.__exports.emailRegex = emailRegex;
|
|
615
|
-
index.__exports.escapeKeyboardEventHandler = escapeKeyboardEventHandler;
|
|
616
|
-
index.__exports.focusTrap = focusTrap;
|
|
617
|
-
index.__exports.focusableSelectors = focusableSelectors;
|
|
618
|
-
index.__exports.formatDateToLocale = formatDateToLocale;
|
|
619
|
-
index.__exports.formatLeadingZero = formatLeadingZero;
|
|
620
|
-
index.__exports.formatPostalCode = formatPostalCode;
|
|
621
|
-
index.__exports.formatPrice = formatPrice;
|
|
622
|
-
index.__exports.formatPriceWithDecimalsReduced = formatPriceWithDecimalsReduced;
|
|
623
|
-
index.__exports.formatPriceWithNoZero = formatPriceWithNoZero;
|
|
624
|
-
index.__exports.getCountryFromLanguageCode = getCountryFromLanguageCode;
|
|
625
|
-
index.__exports.getDateInfo = getDateInfo;
|
|
626
|
-
index.__exports.languageCodeToCountryMap = languageCodeToCountryMap;
|
|
627
|
-
index.__exports.makeCateringPortionsString = makeCateringPortionsString;
|
|
628
|
-
index.__exports.nameRegex = nameRegex;
|
|
629
|
-
index.__exports.phoneRegex = phoneRegex;
|
|
630
|
-
index.__exports.selectKeyboardEventHandler = selectKeyboardEventHandler;
|
|
631
|
-
index.__exports.toggleInert = toggleInert;
|
|
632
|
-
index.__exports.useDetectDevice = useDetectDevice;
|
|
633
|
-
index.__exports.useFixedModalScroll = useFixedModalScroll;
|
|
634
|
-
index.__exports.useOutsideClick = useOutsideClick;
|
|
635
|
-
var useWindowSize_1 = index.__exports.useWindowSize = useWindowSize;
|
|
636
|
-
index.__exports.validateInput = validateInput;
|
|
637
|
-
index.__exports.zipRegex = zipRegex;
|
|
638
|
-
|
|
639
|
-
exports["default"] = index.__exports;
|
|
640
|
-
exports.useWindowSize = useWindowSize_1;
|
|
641
|
-
//# sourceMappingURL=index.js.map
|