@bonlineza/luxity-lib 2.18.2 → 2.18.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/AddInterest.js +23 -580
- package/BrandSelector.js +23 -580
- package/CurrencyInputFormatter.js +18 -575
- package/GraphQLDropdownSelector.js +23 -580
- package/Interests.js +18 -575
- package/LuxityGraphQLDropdownSelector.js +23 -580
- package/MaterialSelector.js +23 -580
- package/ModelSelector.js +23 -580
- package/PriceRangeSelector.js +17 -574
- package/RareStepHeader.js +1 -1
- package/build/bundle.js +23 -580
- package/package.json +1 -1
|
@@ -1117,573 +1117,6 @@
|
|
|
1117
1117
|
return /*#__PURE__*/React__default.createElement(Button$4, restProps, children);
|
|
1118
1118
|
};
|
|
1119
1119
|
|
|
1120
|
-
/*! *****************************************************************************
|
|
1121
|
-
Copyright (c) Microsoft Corporation.
|
|
1122
|
-
|
|
1123
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1124
|
-
purpose with or without fee is hereby granted.
|
|
1125
|
-
|
|
1126
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1127
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1128
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1129
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1130
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1131
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1132
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1133
|
-
***************************************************************************** */
|
|
1134
|
-
|
|
1135
|
-
var __assign = function() {
|
|
1136
|
-
__assign = Object.assign || function __assign(t) {
|
|
1137
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1138
|
-
s = arguments[i];
|
|
1139
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1140
|
-
}
|
|
1141
|
-
return t;
|
|
1142
|
-
};
|
|
1143
|
-
return __assign.apply(this, arguments);
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
function __rest(s, e) {
|
|
1147
|
-
var t = {};
|
|
1148
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1149
|
-
t[p] = s[p];
|
|
1150
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1151
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1152
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1153
|
-
t[p[i]] = s[p[i]];
|
|
1154
|
-
}
|
|
1155
|
-
return t;
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
function __spreadArray(to, from, pack) {
|
|
1159
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1160
|
-
if (ar || !(i in from)) {
|
|
1161
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1162
|
-
ar[i] = from[i];
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
return to.concat(ar || from);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* Escape regex char
|
|
1170
|
-
*
|
|
1171
|
-
* See: https://stackoverflow.com/questions/17885855/use-dynamic-variable-string-as-regex-pattern-in-javascript
|
|
1172
|
-
*/
|
|
1173
|
-
var escapeRegExp = function (stringToGoIntoTheRegex) {
|
|
1174
|
-
return stringToGoIntoTheRegex.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
var abbrMap = { k: 1000, m: 1000000, b: 1000000000 };
|
|
1178
|
-
/**
|
|
1179
|
-
* Parse a value with abbreviation e.g 1k = 1000
|
|
1180
|
-
*/
|
|
1181
|
-
var parseAbbrValue = function (value, decimalSeparator) {
|
|
1182
|
-
if (decimalSeparator === void 0) { decimalSeparator = '.'; }
|
|
1183
|
-
var reg = new RegExp("(\\d+(" + escapeRegExp(decimalSeparator) + "\\d*)?)([kmb])$", 'i');
|
|
1184
|
-
var match = value.match(reg);
|
|
1185
|
-
if (match) {
|
|
1186
|
-
var digits = match[1], abbr = match[3];
|
|
1187
|
-
var multiplier = abbrMap[abbr.toLowerCase()];
|
|
1188
|
-
return Number(digits.replace(decimalSeparator, '.')) * multiplier;
|
|
1189
|
-
}
|
|
1190
|
-
return undefined;
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* Remove group separator from value eg. 1,000 > 1000
|
|
1195
|
-
*/
|
|
1196
|
-
var removeSeparators = function (value, separator) {
|
|
1197
|
-
if (separator === void 0) { separator = ','; }
|
|
1198
|
-
var reg = new RegExp(escapeRegExp(separator), 'g');
|
|
1199
|
-
return value.replace(reg, '');
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
|
-
/**
|
|
1203
|
-
* Remove invalid characters
|
|
1204
|
-
*/
|
|
1205
|
-
var removeInvalidChars = function (value, validChars) {
|
|
1206
|
-
var chars = escapeRegExp(validChars.join(''));
|
|
1207
|
-
var reg = new RegExp("[^\\d" + chars + "]", 'gi');
|
|
1208
|
-
return value.replace(reg, '');
|
|
1209
|
-
};
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
* Remove prefix, separators and extra decimals from value
|
|
1213
|
-
*/
|
|
1214
|
-
var cleanValue = function (_a) {
|
|
1215
|
-
var value = _a.value, _b = _a.groupSeparator, groupSeparator = _b === void 0 ? ',' : _b, _c = _a.decimalSeparator, decimalSeparator = _c === void 0 ? '.' : _c, _d = _a.allowDecimals, allowDecimals = _d === void 0 ? true : _d, _e = _a.decimalsLimit, decimalsLimit = _e === void 0 ? 2 : _e, _f = _a.allowNegativeValue, allowNegativeValue = _f === void 0 ? true : _f, _g = _a.disableAbbreviations, disableAbbreviations = _g === void 0 ? false : _g, _h = _a.prefix, prefix = _h === void 0 ? '' : _h, _j = _a.transformRawValue, transformRawValue = _j === void 0 ? function (rawValue) { return rawValue; } : _j;
|
|
1216
|
-
var transformedValue = transformRawValue(value);
|
|
1217
|
-
if (transformedValue === '-') {
|
|
1218
|
-
return transformedValue;
|
|
1219
|
-
}
|
|
1220
|
-
var abbreviations = disableAbbreviations ? [] : ['k', 'm', 'b'];
|
|
1221
|
-
var reg = new RegExp("((^|\\D)-\\d)|(-" + escapeRegExp(prefix) + ")");
|
|
1222
|
-
var isNegative = reg.test(transformedValue);
|
|
1223
|
-
// Is there a digit before the prefix? eg. 1$
|
|
1224
|
-
var _k = RegExp("(\\d+)-?" + escapeRegExp(prefix)).exec(value) || [], prefixWithValue = _k[0], preValue = _k[1];
|
|
1225
|
-
var withoutPrefix = prefix
|
|
1226
|
-
? prefixWithValue
|
|
1227
|
-
? transformedValue.replace(prefixWithValue, '').concat(preValue)
|
|
1228
|
-
: transformedValue.replace(prefix, '')
|
|
1229
|
-
: transformedValue;
|
|
1230
|
-
var withoutSeparators = removeSeparators(withoutPrefix, groupSeparator);
|
|
1231
|
-
var withoutInvalidChars = removeInvalidChars(withoutSeparators, __spreadArray([
|
|
1232
|
-
groupSeparator,
|
|
1233
|
-
decimalSeparator
|
|
1234
|
-
], abbreviations));
|
|
1235
|
-
var valueOnly = withoutInvalidChars;
|
|
1236
|
-
if (!disableAbbreviations) {
|
|
1237
|
-
// disallow letter without number
|
|
1238
|
-
if (abbreviations.some(function (letter) { return letter === withoutInvalidChars.toLowerCase(); })) {
|
|
1239
|
-
return '';
|
|
1240
|
-
}
|
|
1241
|
-
var parsed = parseAbbrValue(withoutInvalidChars, decimalSeparator);
|
|
1242
|
-
if (parsed) {
|
|
1243
|
-
valueOnly = String(parsed);
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
var includeNegative = isNegative && allowNegativeValue ? '-' : '';
|
|
1247
|
-
if (decimalSeparator && valueOnly.includes(decimalSeparator)) {
|
|
1248
|
-
var _l = withoutInvalidChars.split(decimalSeparator), int = _l[0], decimals = _l[1];
|
|
1249
|
-
var trimmedDecimals = decimalsLimit && decimals ? decimals.slice(0, decimalsLimit) : decimals;
|
|
1250
|
-
var includeDecimals = allowDecimals ? "" + decimalSeparator + trimmedDecimals : '';
|
|
1251
|
-
return "" + includeNegative + int + includeDecimals;
|
|
1252
|
-
}
|
|
1253
|
-
return "" + includeNegative + valueOnly;
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
var fixedDecimalValue = function (value, decimalSeparator, fixedDecimalLength) {
|
|
1257
|
-
if (fixedDecimalLength && value.length > 1) {
|
|
1258
|
-
if (value.includes(decimalSeparator)) {
|
|
1259
|
-
var _a = value.split(decimalSeparator), int = _a[0], decimals = _a[1];
|
|
1260
|
-
if (decimals.length > fixedDecimalLength) {
|
|
1261
|
-
return "" + int + decimalSeparator + decimals.slice(0, fixedDecimalLength);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
var reg = value.length > fixedDecimalLength
|
|
1265
|
-
? new RegExp("(\\d+)(\\d{" + fixedDecimalLength + "})")
|
|
1266
|
-
: new RegExp("(\\d)(\\d+)");
|
|
1267
|
-
var match = value.match(reg);
|
|
1268
|
-
if (match) {
|
|
1269
|
-
var int = match[1], decimals = match[2];
|
|
1270
|
-
return "" + int + decimalSeparator + decimals;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return value;
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
var getSuffix = function (value, _a) {
|
|
1277
|
-
var _b = _a.groupSeparator, groupSeparator = _b === void 0 ? ',' : _b, _c = _a.decimalSeparator, decimalSeparator = _c === void 0 ? '.' : _c;
|
|
1278
|
-
var suffixReg = new RegExp("\\d([^" + escapeRegExp(groupSeparator) + escapeRegExp(decimalSeparator) + "0-9]+)");
|
|
1279
|
-
var suffixMatch = value.match(suffixReg);
|
|
1280
|
-
return suffixMatch ? suffixMatch[1] : undefined;
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* Format value with decimal separator, group separator and prefix
|
|
1285
|
-
*/
|
|
1286
|
-
var formatValue = function (options) {
|
|
1287
|
-
var _value = options.value, decimalSeparator = options.decimalSeparator, intlConfig = options.intlConfig, decimalScale = options.decimalScale, _a = options.prefix, prefix = _a === void 0 ? '' : _a, _b = options.suffix, suffix = _b === void 0 ? '' : _b;
|
|
1288
|
-
if (_value === '' || _value === undefined) {
|
|
1289
|
-
return '';
|
|
1290
|
-
}
|
|
1291
|
-
if (_value === '-') {
|
|
1292
|
-
return '-';
|
|
1293
|
-
}
|
|
1294
|
-
var isNegative = new RegExp("^\\d?-" + (prefix ? escapeRegExp(prefix) + "?" : '') + "\\d").test(_value);
|
|
1295
|
-
var value = decimalSeparator !== '.'
|
|
1296
|
-
? replaceDecimalSeparator(_value, decimalSeparator, isNegative)
|
|
1297
|
-
: _value;
|
|
1298
|
-
var numberFormatter = intlConfig
|
|
1299
|
-
? new Intl.NumberFormat(intlConfig.locale, intlConfig.currency
|
|
1300
|
-
? {
|
|
1301
|
-
style: 'currency',
|
|
1302
|
-
currency: intlConfig.currency,
|
|
1303
|
-
minimumFractionDigits: decimalScale || 0,
|
|
1304
|
-
maximumFractionDigits: 20,
|
|
1305
|
-
}
|
|
1306
|
-
: undefined)
|
|
1307
|
-
: new Intl.NumberFormat(undefined, {
|
|
1308
|
-
minimumFractionDigits: decimalScale || 0,
|
|
1309
|
-
maximumFractionDigits: 20,
|
|
1310
|
-
});
|
|
1311
|
-
var parts = numberFormatter.formatToParts(Number(value));
|
|
1312
|
-
var formatted = replaceParts(parts, options);
|
|
1313
|
-
// Does intl formatting add a suffix?
|
|
1314
|
-
var intlSuffix = getSuffix(formatted, __assign({}, options));
|
|
1315
|
-
// Include decimal separator if user input ends with decimal separator
|
|
1316
|
-
var includeDecimalSeparator = _value.slice(-1) === decimalSeparator ? decimalSeparator : '';
|
|
1317
|
-
var _c = value.match(RegExp('\\d+\\.(\\d+)')) || [], decimals = _c[1];
|
|
1318
|
-
// Keep original decimal padding if no decimalScale
|
|
1319
|
-
if (decimalScale === undefined && decimals && decimalSeparator) {
|
|
1320
|
-
if (formatted.includes(decimalSeparator)) {
|
|
1321
|
-
formatted = formatted.replace(RegExp("(\\d+)(" + escapeRegExp(decimalSeparator) + ")(\\d+)", 'g'), "$1$2" + decimals);
|
|
1322
|
-
}
|
|
1323
|
-
else {
|
|
1324
|
-
if (intlSuffix && !suffix) {
|
|
1325
|
-
formatted = formatted.replace(intlSuffix, "" + decimalSeparator + decimals + intlSuffix);
|
|
1326
|
-
}
|
|
1327
|
-
else {
|
|
1328
|
-
formatted = "" + formatted + decimalSeparator + decimals;
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
if (suffix && includeDecimalSeparator) {
|
|
1333
|
-
return "" + formatted + includeDecimalSeparator + suffix;
|
|
1334
|
-
}
|
|
1335
|
-
if (intlSuffix && includeDecimalSeparator) {
|
|
1336
|
-
return formatted.replace(intlSuffix, "" + includeDecimalSeparator + intlSuffix);
|
|
1337
|
-
}
|
|
1338
|
-
if (intlSuffix && suffix) {
|
|
1339
|
-
return formatted.replace(intlSuffix, "" + includeDecimalSeparator + suffix);
|
|
1340
|
-
}
|
|
1341
|
-
return [formatted, includeDecimalSeparator, suffix].join('');
|
|
1342
|
-
};
|
|
1343
|
-
/**
|
|
1344
|
-
* Before converting to Number, decimal separator has to be .
|
|
1345
|
-
*/
|
|
1346
|
-
var replaceDecimalSeparator = function (value, decimalSeparator, isNegative) {
|
|
1347
|
-
var newValue = value;
|
|
1348
|
-
if (decimalSeparator && decimalSeparator !== '.') {
|
|
1349
|
-
newValue = newValue.replace(RegExp(escapeRegExp(decimalSeparator), 'g'), '.');
|
|
1350
|
-
if (isNegative && decimalSeparator === '-') {
|
|
1351
|
-
newValue = "-" + newValue.slice(1);
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
return newValue;
|
|
1355
|
-
};
|
|
1356
|
-
var replaceParts = function (parts, _a) {
|
|
1357
|
-
var prefix = _a.prefix, groupSeparator = _a.groupSeparator, decimalSeparator = _a.decimalSeparator, decimalScale = _a.decimalScale, _b = _a.disableGroupSeparators, disableGroupSeparators = _b === void 0 ? false : _b;
|
|
1358
|
-
return parts
|
|
1359
|
-
.reduce(function (prev, _a, i) {
|
|
1360
|
-
var type = _a.type, value = _a.value;
|
|
1361
|
-
if (i === 0 && prefix) {
|
|
1362
|
-
if (type === 'minusSign') {
|
|
1363
|
-
return [value, prefix];
|
|
1364
|
-
}
|
|
1365
|
-
if (type === 'currency') {
|
|
1366
|
-
return __spreadArray(__spreadArray([], prev), [prefix]);
|
|
1367
|
-
}
|
|
1368
|
-
return [prefix, value];
|
|
1369
|
-
}
|
|
1370
|
-
if (type === 'currency') {
|
|
1371
|
-
return prefix ? prev : __spreadArray(__spreadArray([], prev), [value]);
|
|
1372
|
-
}
|
|
1373
|
-
if (type === 'group') {
|
|
1374
|
-
return !disableGroupSeparators
|
|
1375
|
-
? __spreadArray(__spreadArray([], prev), [groupSeparator !== undefined ? groupSeparator : value]) : prev;
|
|
1376
|
-
}
|
|
1377
|
-
if (type === 'decimal') {
|
|
1378
|
-
if (decimalScale !== undefined && decimalScale === 0) {
|
|
1379
|
-
return prev;
|
|
1380
|
-
}
|
|
1381
|
-
return __spreadArray(__spreadArray([], prev), [decimalSeparator !== undefined ? decimalSeparator : value]);
|
|
1382
|
-
}
|
|
1383
|
-
if (type === 'fraction') {
|
|
1384
|
-
return __spreadArray(__spreadArray([], prev), [decimalScale !== undefined ? value.slice(0, decimalScale) : value]);
|
|
1385
|
-
}
|
|
1386
|
-
return __spreadArray(__spreadArray([], prev), [value]);
|
|
1387
|
-
}, [''])
|
|
1388
|
-
.join('');
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
var defaultConfig = {
|
|
1392
|
-
currencySymbol: '',
|
|
1393
|
-
groupSeparator: '',
|
|
1394
|
-
decimalSeparator: '',
|
|
1395
|
-
prefix: '',
|
|
1396
|
-
suffix: '',
|
|
1397
|
-
};
|
|
1398
|
-
/**
|
|
1399
|
-
* Get locale config from input or default
|
|
1400
|
-
*/
|
|
1401
|
-
var getLocaleConfig = function (intlConfig) {
|
|
1402
|
-
var _a = intlConfig || {}, locale = _a.locale, currency = _a.currency;
|
|
1403
|
-
var numberFormatter = locale
|
|
1404
|
-
? new Intl.NumberFormat(locale, currency ? { currency: currency, style: 'currency' } : undefined)
|
|
1405
|
-
: new Intl.NumberFormat();
|
|
1406
|
-
return numberFormatter.formatToParts(1000.1).reduce(function (prev, curr, i) {
|
|
1407
|
-
if (curr.type === 'currency') {
|
|
1408
|
-
if (i === 0) {
|
|
1409
|
-
return __assign(__assign({}, prev), { currencySymbol: curr.value, prefix: curr.value });
|
|
1410
|
-
}
|
|
1411
|
-
else {
|
|
1412
|
-
return __assign(__assign({}, prev), { currencySymbol: curr.value, suffix: curr.value });
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
if (curr.type === 'group') {
|
|
1416
|
-
return __assign(__assign({}, prev), { groupSeparator: curr.value });
|
|
1417
|
-
}
|
|
1418
|
-
if (curr.type === 'decimal') {
|
|
1419
|
-
return __assign(__assign({}, prev), { decimalSeparator: curr.value });
|
|
1420
|
-
}
|
|
1421
|
-
return prev;
|
|
1422
|
-
}, defaultConfig);
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
|
-
var isNumber = function (input) { return RegExp(/\d/, 'gi').test(input); };
|
|
1426
|
-
|
|
1427
|
-
var padTrimValue = function (value, decimalSeparator, decimalScale) {
|
|
1428
|
-
if (decimalSeparator === void 0) { decimalSeparator = '.'; }
|
|
1429
|
-
if (decimalScale === undefined || value === '' || value === undefined) {
|
|
1430
|
-
return value;
|
|
1431
|
-
}
|
|
1432
|
-
if (!value.match(/\d/g)) {
|
|
1433
|
-
return '';
|
|
1434
|
-
}
|
|
1435
|
-
var _a = value.split(decimalSeparator), int = _a[0], decimals = _a[1];
|
|
1436
|
-
if (decimalScale === 0) {
|
|
1437
|
-
return int;
|
|
1438
|
-
}
|
|
1439
|
-
var newValue = decimals || '';
|
|
1440
|
-
if (newValue.length < decimalScale) {
|
|
1441
|
-
while (newValue.length < decimalScale) {
|
|
1442
|
-
newValue += '0';
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
else {
|
|
1446
|
-
newValue = newValue.slice(0, decimalScale);
|
|
1447
|
-
}
|
|
1448
|
-
return "" + int + decimalSeparator + newValue;
|
|
1449
|
-
};
|
|
1450
|
-
|
|
1451
|
-
/**
|
|
1452
|
-
* Based on the last key stroke and the cursor position, update the value
|
|
1453
|
-
* and reposition the cursor to the right place
|
|
1454
|
-
*/
|
|
1455
|
-
var repositionCursor = function (_a) {
|
|
1456
|
-
var selectionStart = _a.selectionStart, value = _a.value, lastKeyStroke = _a.lastKeyStroke, stateValue = _a.stateValue, groupSeparator = _a.groupSeparator;
|
|
1457
|
-
var cursorPosition = selectionStart;
|
|
1458
|
-
var modifiedValue = value;
|
|
1459
|
-
if (stateValue && cursorPosition) {
|
|
1460
|
-
var splitValue = value.split('');
|
|
1461
|
-
// if cursor is to right of groupSeparator and backspace pressed, delete the character to the left of the separator and reposition the cursor
|
|
1462
|
-
if (lastKeyStroke === 'Backspace' && stateValue[cursorPosition] === groupSeparator) {
|
|
1463
|
-
splitValue.splice(cursorPosition - 1, 1);
|
|
1464
|
-
cursorPosition -= 1;
|
|
1465
|
-
}
|
|
1466
|
-
// if cursor is to left of groupSeparator and delete pressed, delete the character to the right of the separator and reposition the cursor
|
|
1467
|
-
if (lastKeyStroke === 'Delete' && stateValue[cursorPosition] === groupSeparator) {
|
|
1468
|
-
splitValue.splice(cursorPosition, 1);
|
|
1469
|
-
cursorPosition += 1;
|
|
1470
|
-
}
|
|
1471
|
-
modifiedValue = splitValue.join('');
|
|
1472
|
-
return { modifiedValue: modifiedValue, cursorPosition: cursorPosition };
|
|
1473
|
-
}
|
|
1474
|
-
return { modifiedValue: modifiedValue, cursorPosition: selectionStart };
|
|
1475
|
-
};
|
|
1476
|
-
|
|
1477
|
-
var CurrencyInput = React.forwardRef(function (_a, ref) {
|
|
1478
|
-
var _b = _a.allowDecimals, allowDecimals = _b === void 0 ? true : _b, _c = _a.allowNegativeValue, allowNegativeValue = _c === void 0 ? true : _c, id = _a.id, name = _a.name, className = _a.className, customInput = _a.customInput, decimalsLimit = _a.decimalsLimit, defaultValue = _a.defaultValue, _d = _a.disabled, disabled = _d === void 0 ? false : _d, userMaxLength = _a.maxLength, userValue = _a.value, onValueChange = _a.onValueChange, fixedDecimalLength = _a.fixedDecimalLength, placeholder = _a.placeholder, decimalScale = _a.decimalScale, prefix = _a.prefix, suffix = _a.suffix, intlConfig = _a.intlConfig, step = _a.step, min = _a.min, max = _a.max, _e = _a.disableGroupSeparators, disableGroupSeparators = _e === void 0 ? false : _e, _f = _a.disableAbbreviations, disableAbbreviations = _f === void 0 ? false : _f, _decimalSeparator = _a.decimalSeparator, _groupSeparator = _a.groupSeparator, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, transformRawValue = _a.transformRawValue, props = __rest(_a, ["allowDecimals", "allowNegativeValue", "id", "name", "className", "customInput", "decimalsLimit", "defaultValue", "disabled", "maxLength", "value", "onValueChange", "fixedDecimalLength", "placeholder", "decimalScale", "prefix", "suffix", "intlConfig", "step", "min", "max", "disableGroupSeparators", "disableAbbreviations", "decimalSeparator", "groupSeparator", "onChange", "onFocus", "onBlur", "onKeyDown", "onKeyUp", "transformRawValue"]);
|
|
1479
|
-
if (_decimalSeparator && isNumber(_decimalSeparator)) {
|
|
1480
|
-
throw new Error('decimalSeparator cannot be a number');
|
|
1481
|
-
}
|
|
1482
|
-
if (_groupSeparator && isNumber(_groupSeparator)) {
|
|
1483
|
-
throw new Error('groupSeparator cannot be a number');
|
|
1484
|
-
}
|
|
1485
|
-
var localeConfig = React.useMemo(function () { return getLocaleConfig(intlConfig); }, [intlConfig]);
|
|
1486
|
-
var decimalSeparator = _decimalSeparator || localeConfig.decimalSeparator || '';
|
|
1487
|
-
var groupSeparator = _groupSeparator || localeConfig.groupSeparator || '';
|
|
1488
|
-
if (decimalSeparator &&
|
|
1489
|
-
groupSeparator &&
|
|
1490
|
-
decimalSeparator === groupSeparator &&
|
|
1491
|
-
disableGroupSeparators === false) {
|
|
1492
|
-
throw new Error('decimalSeparator cannot be the same as groupSeparator');
|
|
1493
|
-
}
|
|
1494
|
-
var formatValueOptions = {
|
|
1495
|
-
decimalSeparator: decimalSeparator,
|
|
1496
|
-
groupSeparator: groupSeparator,
|
|
1497
|
-
disableGroupSeparators: disableGroupSeparators,
|
|
1498
|
-
intlConfig: intlConfig,
|
|
1499
|
-
prefix: prefix || localeConfig.prefix,
|
|
1500
|
-
suffix: suffix,
|
|
1501
|
-
};
|
|
1502
|
-
var cleanValueOptions = {
|
|
1503
|
-
decimalSeparator: decimalSeparator,
|
|
1504
|
-
groupSeparator: groupSeparator,
|
|
1505
|
-
allowDecimals: allowDecimals,
|
|
1506
|
-
decimalsLimit: decimalsLimit || fixedDecimalLength || 2,
|
|
1507
|
-
allowNegativeValue: allowNegativeValue,
|
|
1508
|
-
disableAbbreviations: disableAbbreviations,
|
|
1509
|
-
prefix: prefix || localeConfig.prefix,
|
|
1510
|
-
transformRawValue: transformRawValue,
|
|
1511
|
-
};
|
|
1512
|
-
var formattedStateValue = defaultValue !== undefined && defaultValue !== null
|
|
1513
|
-
? formatValue(__assign(__assign({}, formatValueOptions), { decimalScale: decimalScale, value: String(defaultValue) }))
|
|
1514
|
-
: userValue !== undefined && userValue !== null
|
|
1515
|
-
? formatValue(__assign(__assign({}, formatValueOptions), { decimalScale: decimalScale, value: String(userValue) }))
|
|
1516
|
-
: '';
|
|
1517
|
-
var _g = React.useState(formattedStateValue), stateValue = _g[0], setStateValue = _g[1];
|
|
1518
|
-
var _h = React.useState(false), dirty = _h[0], setDirty = _h[1];
|
|
1519
|
-
var _j = React.useState(0), cursor = _j[0], setCursor = _j[1];
|
|
1520
|
-
var _k = React.useState(0), changeCount = _k[0], setChangeCount = _k[1];
|
|
1521
|
-
var _l = React.useState(null), lastKeyStroke = _l[0], setLastKeyStroke = _l[1];
|
|
1522
|
-
var inputRef = ref || React.useRef(null);
|
|
1523
|
-
/**
|
|
1524
|
-
* Process change in value
|
|
1525
|
-
*/
|
|
1526
|
-
var processChange = function (value, selectionStart) {
|
|
1527
|
-
setDirty(true);
|
|
1528
|
-
var _a = repositionCursor({
|
|
1529
|
-
selectionStart: selectionStart,
|
|
1530
|
-
value: value,
|
|
1531
|
-
lastKeyStroke: lastKeyStroke,
|
|
1532
|
-
stateValue: stateValue,
|
|
1533
|
-
groupSeparator: groupSeparator,
|
|
1534
|
-
}), modifiedValue = _a.modifiedValue, cursorPosition = _a.cursorPosition;
|
|
1535
|
-
var stringValue = cleanValue(__assign({ value: modifiedValue }, cleanValueOptions));
|
|
1536
|
-
if (userMaxLength && stringValue.replace(/-/g, '').length > userMaxLength) {
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
if (stringValue === '' || stringValue === '-' || stringValue === decimalSeparator) {
|
|
1540
|
-
onValueChange && onValueChange(undefined, name, { float: null, formatted: '', value: '' });
|
|
1541
|
-
setStateValue(stringValue);
|
|
1542
|
-
return;
|
|
1543
|
-
}
|
|
1544
|
-
var numberValue = parseFloat(stringValue.replace(decimalSeparator, '.'));
|
|
1545
|
-
var formattedValue = formatValue(__assign({ value: stringValue }, formatValueOptions));
|
|
1546
|
-
if (cursorPosition !== undefined && cursorPosition !== null) {
|
|
1547
|
-
// Prevent cursor jumping
|
|
1548
|
-
var newCursor = cursorPosition + (formattedValue.length - value.length);
|
|
1549
|
-
newCursor = newCursor <= 0 ? (prefix ? prefix.length : 0) : newCursor;
|
|
1550
|
-
setCursor(newCursor);
|
|
1551
|
-
setChangeCount(changeCount + 1);
|
|
1552
|
-
}
|
|
1553
|
-
setStateValue(formattedValue);
|
|
1554
|
-
if (onValueChange) {
|
|
1555
|
-
var values = {
|
|
1556
|
-
float: numberValue,
|
|
1557
|
-
formatted: formattedValue,
|
|
1558
|
-
value: stringValue,
|
|
1559
|
-
};
|
|
1560
|
-
onValueChange(stringValue, name, values);
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
/**
|
|
1564
|
-
* Handle change event
|
|
1565
|
-
*/
|
|
1566
|
-
var handleOnChange = function (event) {
|
|
1567
|
-
var _a = event.target, value = _a.value, selectionStart = _a.selectionStart;
|
|
1568
|
-
processChange(value, selectionStart);
|
|
1569
|
-
onChange && onChange(event);
|
|
1570
|
-
};
|
|
1571
|
-
/**
|
|
1572
|
-
* Handle focus event
|
|
1573
|
-
*/
|
|
1574
|
-
var handleOnFocus = function (event) {
|
|
1575
|
-
onFocus && onFocus(event);
|
|
1576
|
-
return stateValue ? stateValue.length : 0;
|
|
1577
|
-
};
|
|
1578
|
-
/**
|
|
1579
|
-
* Handle blur event
|
|
1580
|
-
*
|
|
1581
|
-
* Format value by padding/trimming decimals if required by
|
|
1582
|
-
*/
|
|
1583
|
-
var handleOnBlur = function (event) {
|
|
1584
|
-
var value = event.target.value;
|
|
1585
|
-
var valueOnly = cleanValue(__assign({ value: value }, cleanValueOptions));
|
|
1586
|
-
if (valueOnly === '-' || !valueOnly) {
|
|
1587
|
-
setStateValue('');
|
|
1588
|
-
onBlur && onBlur(event);
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
var fixedDecimals = fixedDecimalValue(valueOnly, decimalSeparator, fixedDecimalLength);
|
|
1592
|
-
var newValue = padTrimValue(fixedDecimals, decimalSeparator, decimalScale !== undefined ? decimalScale : fixedDecimalLength);
|
|
1593
|
-
var numberValue = parseFloat(newValue.replace(decimalSeparator, '.'));
|
|
1594
|
-
var formattedValue = formatValue(__assign(__assign({}, formatValueOptions), { value: newValue }));
|
|
1595
|
-
if (onValueChange) {
|
|
1596
|
-
onValueChange(newValue, name, {
|
|
1597
|
-
float: numberValue,
|
|
1598
|
-
formatted: formattedValue,
|
|
1599
|
-
value: newValue,
|
|
1600
|
-
});
|
|
1601
|
-
}
|
|
1602
|
-
setStateValue(formattedValue);
|
|
1603
|
-
onBlur && onBlur(event);
|
|
1604
|
-
};
|
|
1605
|
-
/**
|
|
1606
|
-
* Handle key down event
|
|
1607
|
-
*
|
|
1608
|
-
* Increase or decrease value by step
|
|
1609
|
-
*/
|
|
1610
|
-
var handleOnKeyDown = function (event) {
|
|
1611
|
-
var key = event.key;
|
|
1612
|
-
setLastKeyStroke(key);
|
|
1613
|
-
if (step && (key === 'ArrowUp' || key === 'ArrowDown')) {
|
|
1614
|
-
event.preventDefault();
|
|
1615
|
-
setCursor(stateValue.length);
|
|
1616
|
-
var currentValue = parseFloat(userValue !== undefined && userValue !== null
|
|
1617
|
-
? String(userValue).replace(decimalSeparator, '.')
|
|
1618
|
-
: cleanValue(__assign({ value: stateValue }, cleanValueOptions))) || 0;
|
|
1619
|
-
var newValue = key === 'ArrowUp' ? currentValue + step : currentValue - step;
|
|
1620
|
-
if (min !== undefined && newValue < min) {
|
|
1621
|
-
return;
|
|
1622
|
-
}
|
|
1623
|
-
if (max !== undefined && newValue > max) {
|
|
1624
|
-
return;
|
|
1625
|
-
}
|
|
1626
|
-
var fixedLength = String(step).includes('.')
|
|
1627
|
-
? Number(String(step).split('.')[1].length)
|
|
1628
|
-
: undefined;
|
|
1629
|
-
processChange(String(fixedLength ? newValue.toFixed(fixedLength) : newValue).replace('.', decimalSeparator));
|
|
1630
|
-
}
|
|
1631
|
-
onKeyDown && onKeyDown(event);
|
|
1632
|
-
};
|
|
1633
|
-
/**
|
|
1634
|
-
* Handle key up event
|
|
1635
|
-
*
|
|
1636
|
-
* Move cursor if there is a suffix to prevent user typing past suffix
|
|
1637
|
-
*/
|
|
1638
|
-
var handleOnKeyUp = function (event) {
|
|
1639
|
-
var key = event.key, selectionStart = event.currentTarget.selectionStart;
|
|
1640
|
-
if (key !== 'ArrowUp' && key !== 'ArrowDown' && stateValue !== '-') {
|
|
1641
|
-
var suffix_1 = getSuffix(stateValue, { groupSeparator: groupSeparator, decimalSeparator: decimalSeparator });
|
|
1642
|
-
if (suffix_1 && selectionStart && selectionStart > stateValue.length - suffix_1.length) {
|
|
1643
|
-
/* istanbul ignore else */
|
|
1644
|
-
if (inputRef && typeof inputRef === 'object' && inputRef.current) {
|
|
1645
|
-
var newCursor = stateValue.length - suffix_1.length;
|
|
1646
|
-
inputRef.current.setSelectionRange(newCursor, newCursor);
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
onKeyUp && onKeyUp(event);
|
|
1651
|
-
};
|
|
1652
|
-
React.useEffect(function () {
|
|
1653
|
-
// prevent cursor jumping if editing value
|
|
1654
|
-
if (dirty &&
|
|
1655
|
-
stateValue !== '-' &&
|
|
1656
|
-
inputRef &&
|
|
1657
|
-
typeof inputRef === 'object' &&
|
|
1658
|
-
inputRef.current) {
|
|
1659
|
-
inputRef.current.setSelectionRange(cursor, cursor);
|
|
1660
|
-
}
|
|
1661
|
-
}, [stateValue, cursor, inputRef, dirty, changeCount]);
|
|
1662
|
-
/**
|
|
1663
|
-
* If user has only entered "-" or decimal separator,
|
|
1664
|
-
* keep the char to allow them to enter next value
|
|
1665
|
-
*/
|
|
1666
|
-
var getRenderValue = function () {
|
|
1667
|
-
if (userValue !== undefined &&
|
|
1668
|
-
userValue !== null &&
|
|
1669
|
-
stateValue !== '-' &&
|
|
1670
|
-
(!decimalSeparator || stateValue !== decimalSeparator)) {
|
|
1671
|
-
return formatValue(__assign(__assign({}, formatValueOptions), { decimalScale: dirty ? undefined : decimalScale, value: String(userValue) }));
|
|
1672
|
-
}
|
|
1673
|
-
return stateValue;
|
|
1674
|
-
};
|
|
1675
|
-
var inputProps = __assign({ type: 'text', inputMode: 'decimal', id: id,
|
|
1676
|
-
name: name,
|
|
1677
|
-
className: className, onChange: handleOnChange, onBlur: handleOnBlur, onFocus: handleOnFocus, onKeyDown: handleOnKeyDown, onKeyUp: handleOnKeyUp, placeholder: placeholder,
|
|
1678
|
-
disabled: disabled, value: getRenderValue(), ref: inputRef }, props);
|
|
1679
|
-
if (customInput) {
|
|
1680
|
-
var CustomInput = customInput;
|
|
1681
|
-
return React__default.createElement(CustomInput, __assign({}, inputProps));
|
|
1682
|
-
}
|
|
1683
|
-
return React__default.createElement("input", __assign({}, inputProps));
|
|
1684
|
-
});
|
|
1685
|
-
CurrencyInput.displayName = 'CurrencyInput';
|
|
1686
|
-
|
|
1687
1120
|
var _excluded$5 = ["value", "onChange", "prefix", "allowNegativeValue", "groupSeparator", "decimalSeparator"];
|
|
1688
1121
|
var unMask = function unMask() {
|
|
1689
1122
|
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
@@ -1702,13 +1135,23 @@
|
|
|
1702
1135
|
decimalSeparator = _ref.decimalSeparator,
|
|
1703
1136
|
rest = _objectWithoutProperties(_ref, _excluded$5);
|
|
1704
1137
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1138
|
+
var handleValueChange = function handleValueChange(event) {
|
|
1139
|
+
var inputValue = event.target.value;
|
|
1140
|
+
var unmaskedValue = unMask(inputValue);
|
|
1141
|
+
onChange(unmaskedValue);
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
var formatCurrency = function formatCurrency(originalValue) {
|
|
1145
|
+
var numericValue = Number(originalValue);
|
|
1146
|
+
var formattedValue = numericValue.toLocaleString('en-US');
|
|
1147
|
+
return prefix + formattedValue;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
var formattedValue = formatCurrency(value);
|
|
1151
|
+
return /*#__PURE__*/React__default.createElement("input", _extends({}, rest, {
|
|
1152
|
+
type: "text",
|
|
1153
|
+
value: formattedValue,
|
|
1154
|
+
onChange: handleValueChange
|
|
1712
1155
|
}));
|
|
1713
1156
|
};
|
|
1714
1157
|
|
|
@@ -3249,7 +2692,7 @@
|
|
|
3249
2692
|
// Clean Value
|
|
3250
2693
|
// ==============================
|
|
3251
2694
|
|
|
3252
|
-
var cleanValue
|
|
2695
|
+
var cleanValue = function cleanValue(value) {
|
|
3253
2696
|
if (Array.isArray(value)) return value.filter(Boolean);
|
|
3254
2697
|
if (_typeof(value) === 'object' && value !== null) return [value];
|
|
3255
2698
|
return [];
|
|
@@ -6516,7 +5959,7 @@
|
|
|
6516
5959
|
|
|
6517
5960
|
_this.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
|
|
6518
5961
|
|
|
6519
|
-
var _selectValue = cleanValue
|
|
5962
|
+
var _selectValue = cleanValue(value);
|
|
6520
5963
|
|
|
6521
5964
|
var _menuOptions = _this.buildMenuOptions(_props, _selectValue);
|
|
6522
5965
|
|
|
@@ -6551,7 +5994,7 @@
|
|
|
6551
5994
|
this.cacheComponents(nextProps.components); // rebuild the menu options
|
|
6552
5995
|
|
|
6553
5996
|
if (nextProps.value !== value || nextProps.options !== options || nextProps.inputValue !== inputValue) {
|
|
6554
|
-
var selectValue = cleanValue
|
|
5997
|
+
var selectValue = cleanValue(nextProps.value);
|
|
6555
5998
|
var menuOptions = this.buildMenuOptions(nextProps, selectValue);
|
|
6556
5999
|
var focusedValue = this.getNextFocusedValue(selectValue);
|
|
6557
6000
|
var focusedOption = this.getNextFocusedOption(menuOptions.focusable);
|
|
@@ -7958,7 +7401,7 @@
|
|
|
7958
7401
|
};
|
|
7959
7402
|
|
|
7960
7403
|
if (isMulti) {
|
|
7961
|
-
onChange([].concat(_toConsumableArray$1(cleanValue
|
|
7404
|
+
onChange([].concat(_toConsumableArray$1(cleanValue(value)), [newOptionData]), newActionMeta);
|
|
7962
7405
|
} else {
|
|
7963
7406
|
onChange(newOptionData, newActionMeta);
|
|
7964
7407
|
}
|
|
@@ -7991,7 +7434,7 @@
|
|
|
7991
7434
|
var options = nextProps.options || [];
|
|
7992
7435
|
var newOption = this.state.newOption;
|
|
7993
7436
|
|
|
7994
|
-
if (isValidNewOption(inputValue, cleanValue
|
|
7437
|
+
if (isValidNewOption(inputValue, cleanValue(value), options)) {
|
|
7995
7438
|
newOption = getNewOptionData(inputValue, formatCreateLabel(inputValue));
|
|
7996
7439
|
} else {
|
|
7997
7440
|
newOption = undefined;
|
|
@@ -11623,7 +11066,7 @@
|
|
|
11623
11066
|
}, function (props) {
|
|
11624
11067
|
return props.theme.rareStepColors.ntrlMin;
|
|
11625
11068
|
});
|
|
11626
|
-
var SideNavLinksContainer = styled__default.div(_templateObject19$1 || (_templateObject19$1 = _taggedTemplateLiteral(["\n {\n overflow-y:
|
|
11069
|
+
var SideNavLinksContainer = styled__default.div(_templateObject19$1 || (_templateObject19$1 = _taggedTemplateLiteral(["\n {\n overflow-y: auto;\n overflow-x: hidden;\n height: 90%;\n padding-bottom: 50px;\n overscroll-behavior: contain;\n }\n"])));
|
|
11627
11070
|
var MenuSideNavWrapper = styled__default.div(_templateObject20$1 || (_templateObject20$1 = _taggedTemplateLiteral(["\n {\n .side-nav {\n transition: left 1s ease-in-out;\n\n &--open {\n left: 0;\n }\n\n &--close {\n left: -100%;\n }\n\n &__currency {\n margin: ", " 0 0\n ", ";\n }\n }\n\n .overlay {\n transition: right 1s ease-in-out;\n\n &--open {\n right: 0;\n }\n\n &--close {\n right: 200%;\n }\n }\n }\n"])), function (props) {
|
|
11628
11071
|
return props.theme.marginPaddings[4];
|
|
11629
11072
|
}, function (props) {
|