@ikas/storefront 0.2.0-alpha.11 → 0.2.0-alpha.13
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/index.es.js +30 -10
- package/build/index.js +30 -10
- package/package.json +1 -1
package/build/index.es.js
CHANGED
|
@@ -12094,17 +12094,37 @@ function tryForEach(items, callback, printErrors) {
|
|
|
12094
12094
|
});
|
|
12095
12095
|
}
|
|
12096
12096
|
|
|
12097
|
+
var format = function (p, n, x, s, c) {
|
|
12098
|
+
var re = "\\d(?=(\\d{" + (x || 3) + "})+" + (n > 0 ? "\\D" : "$") + ")", num = p.toFixed(Math.max(0, ~~n));
|
|
12099
|
+
return (c ? num.replace(".", c) : num).replace(new RegExp(re, "g"), "$&" + (s || ","));
|
|
12100
|
+
};
|
|
12097
12101
|
/**
|
|
12098
12102
|
*
|
|
12099
12103
|
* @param price Price to format
|
|
12100
12104
|
* @param currency Code for the currency, USD, EUR, TRY, etc..
|
|
12101
12105
|
*/
|
|
12102
12106
|
var formatMoney = function (price, currency) {
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12107
|
+
try {
|
|
12108
|
+
var symbol = getCurrencySymbol(currency);
|
|
12109
|
+
var decimalSeperator = ".";
|
|
12110
|
+
var sectionSeperator = ",";
|
|
12111
|
+
var decimalLength = 2;
|
|
12112
|
+
var sectionLength = 3;
|
|
12113
|
+
var formattedNumber = format(price, decimalLength, sectionLength, sectionSeperator, decimalSeperator);
|
|
12114
|
+
var parts = formattedNumber.split(decimalSeperator);
|
|
12115
|
+
if (parts[1] === "00")
|
|
12116
|
+
formattedNumber = parts[0];
|
|
12117
|
+
return symbol + " " + formattedNumber;
|
|
12118
|
+
}
|
|
12119
|
+
catch (err) {
|
|
12120
|
+
console.error(err);
|
|
12121
|
+
// Fallback
|
|
12122
|
+
var formatter = new Intl.NumberFormat(IkasStorefrontConfig.getCurrentLocale(), {
|
|
12123
|
+
style: "currency",
|
|
12124
|
+
currency: currency || "TRY",
|
|
12125
|
+
});
|
|
12126
|
+
return formatter.format(price);
|
|
12127
|
+
}
|
|
12108
12128
|
};
|
|
12109
12129
|
function getCurrencySymbol(currencyCode) {
|
|
12110
12130
|
return CURRENCIES[currencyCode] || currencyCode;
|
|
@@ -58213,7 +58233,7 @@ function template_formatter (template) {
|
|
|
58213
58233
|
// The result is `{ text: '8 (80 )', caret: 4 }`.
|
|
58214
58234
|
//
|
|
58215
58235
|
|
|
58216
|
-
function format(value, caret, formatter) {
|
|
58236
|
+
function format$1(value, caret, formatter) {
|
|
58217
58237
|
if (typeof formatter === 'string') {
|
|
58218
58238
|
formatter = template_formatter(formatter);
|
|
58219
58239
|
}
|
|
@@ -58415,7 +58435,7 @@ function formatInputText(input, _parse, _format, operation, on_change) {
|
|
|
58415
58435
|
// (and reposition the caret accordingly)
|
|
58416
58436
|
|
|
58417
58437
|
|
|
58418
|
-
var formatted = format(value, caret, _format);
|
|
58438
|
+
var formatted = format$1(value, caret, _format);
|
|
58419
58439
|
var text = formatted.text;
|
|
58420
58440
|
caret = formatted.caret; // Set `<input/>` textual value manually
|
|
58421
58441
|
// to prevent React from resetting the caret position
|
|
@@ -63316,7 +63336,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63316
63336
|
// Working around this issue with this simple hack.
|
|
63317
63337
|
|
|
63318
63338
|
if (newValue === value) {
|
|
63319
|
-
var newValueFormatted = format$
|
|
63339
|
+
var newValueFormatted = format$2(prefix, newValue, country, metadata);
|
|
63320
63340
|
|
|
63321
63341
|
if (newValueFormatted.indexOf(event.target.value) === 0) {
|
|
63322
63342
|
// Trim the last digit (or plus sign).
|
|
@@ -63329,7 +63349,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63329
63349
|
|
|
63330
63350
|
return React.createElement(Input, _extends$2({}, rest, {
|
|
63331
63351
|
ref: ref,
|
|
63332
|
-
value: format$
|
|
63352
|
+
value: format$2(prefix, value, country, metadata),
|
|
63333
63353
|
onChange: _onChange
|
|
63334
63354
|
}));
|
|
63335
63355
|
}
|
|
@@ -63400,7 +63420,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63400
63420
|
}
|
|
63401
63421
|
var InputBasic = createInput$1();
|
|
63402
63422
|
|
|
63403
|
-
function format$
|
|
63423
|
+
function format$2(prefix, value, country, metadata) {
|
|
63404
63424
|
return removeInputValuePrefix(formatIncompletePhoneNumber(prefix + value, country, metadata), prefix);
|
|
63405
63425
|
}
|
|
63406
63426
|
|
package/build/index.js
CHANGED
|
@@ -12111,17 +12111,37 @@ function tryForEach(items, callback, printErrors) {
|
|
|
12111
12111
|
});
|
|
12112
12112
|
}
|
|
12113
12113
|
|
|
12114
|
+
var format = function (p, n, x, s, c) {
|
|
12115
|
+
var re = "\\d(?=(\\d{" + (x || 3) + "})+" + (n > 0 ? "\\D" : "$") + ")", num = p.toFixed(Math.max(0, ~~n));
|
|
12116
|
+
return (c ? num.replace(".", c) : num).replace(new RegExp(re, "g"), "$&" + (s || ","));
|
|
12117
|
+
};
|
|
12114
12118
|
/**
|
|
12115
12119
|
*
|
|
12116
12120
|
* @param price Price to format
|
|
12117
12121
|
* @param currency Code for the currency, USD, EUR, TRY, etc..
|
|
12118
12122
|
*/
|
|
12119
12123
|
var formatMoney = function (price, currency) {
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12124
|
+
try {
|
|
12125
|
+
var symbol = getCurrencySymbol(currency);
|
|
12126
|
+
var decimalSeperator = ".";
|
|
12127
|
+
var sectionSeperator = ",";
|
|
12128
|
+
var decimalLength = 2;
|
|
12129
|
+
var sectionLength = 3;
|
|
12130
|
+
var formattedNumber = format(price, decimalLength, sectionLength, sectionSeperator, decimalSeperator);
|
|
12131
|
+
var parts = formattedNumber.split(decimalSeperator);
|
|
12132
|
+
if (parts[1] === "00")
|
|
12133
|
+
formattedNumber = parts[0];
|
|
12134
|
+
return symbol + " " + formattedNumber;
|
|
12135
|
+
}
|
|
12136
|
+
catch (err) {
|
|
12137
|
+
console.error(err);
|
|
12138
|
+
// Fallback
|
|
12139
|
+
var formatter = new Intl.NumberFormat(IkasStorefrontConfig.getCurrentLocale(), {
|
|
12140
|
+
style: "currency",
|
|
12141
|
+
currency: currency || "TRY",
|
|
12142
|
+
});
|
|
12143
|
+
return formatter.format(price);
|
|
12144
|
+
}
|
|
12125
12145
|
};
|
|
12126
12146
|
function getCurrencySymbol(currencyCode) {
|
|
12127
12147
|
return CURRENCIES[currencyCode] || currencyCode;
|
|
@@ -58190,7 +58210,7 @@ function template_formatter (template) {
|
|
|
58190
58210
|
// The result is `{ text: '8 (80 )', caret: 4 }`.
|
|
58191
58211
|
//
|
|
58192
58212
|
|
|
58193
|
-
function format(value, caret, formatter) {
|
|
58213
|
+
function format$1(value, caret, formatter) {
|
|
58194
58214
|
if (typeof formatter === 'string') {
|
|
58195
58215
|
formatter = template_formatter(formatter);
|
|
58196
58216
|
}
|
|
@@ -58392,7 +58412,7 @@ function formatInputText(input, _parse, _format, operation, on_change) {
|
|
|
58392
58412
|
// (and reposition the caret accordingly)
|
|
58393
58413
|
|
|
58394
58414
|
|
|
58395
|
-
var formatted = format(value, caret, _format);
|
|
58415
|
+
var formatted = format$1(value, caret, _format);
|
|
58396
58416
|
var text = formatted.text;
|
|
58397
58417
|
caret = formatted.caret; // Set `<input/>` textual value manually
|
|
58398
58418
|
// to prevent React from resetting the caret position
|
|
@@ -63293,7 +63313,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63293
63313
|
// Working around this issue with this simple hack.
|
|
63294
63314
|
|
|
63295
63315
|
if (newValue === value) {
|
|
63296
|
-
var newValueFormatted = format$
|
|
63316
|
+
var newValueFormatted = format$2(prefix, newValue, country, metadata);
|
|
63297
63317
|
|
|
63298
63318
|
if (newValueFormatted.indexOf(event.target.value) === 0) {
|
|
63299
63319
|
// Trim the last digit (or plus sign).
|
|
@@ -63306,7 +63326,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63306
63326
|
|
|
63307
63327
|
return React__default['default'].createElement(Input, _extends$2({}, rest, {
|
|
63308
63328
|
ref: ref,
|
|
63309
|
-
value: format$
|
|
63329
|
+
value: format$2(prefix, value, country, metadata),
|
|
63310
63330
|
onChange: _onChange
|
|
63311
63331
|
}));
|
|
63312
63332
|
}
|
|
@@ -63377,7 +63397,7 @@ function createInput$1(defaultMetadata) {
|
|
|
63377
63397
|
}
|
|
63378
63398
|
var InputBasic = createInput$1();
|
|
63379
63399
|
|
|
63380
|
-
function format$
|
|
63400
|
+
function format$2(prefix, value, country, metadata) {
|
|
63381
63401
|
return removeInputValuePrefix(formatIncompletePhoneNumber(prefix + value, country, metadata), prefix);
|
|
63382
63402
|
}
|
|
63383
63403
|
|