expensify-common 2.0.181 → 2.0.183
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/dist/API.js +19 -24
- package/dist/APIDeferred.js +5 -5
- package/dist/CONST.d.ts +3 -0
- package/dist/CONST.js +4 -1
- package/dist/Cookie.d.ts +5 -5
- package/dist/Cookie.js +6 -6
- package/dist/ExpenseRule.d.ts +10 -10
- package/dist/ExpenseRule.js +9 -9
- package/dist/ExpensiMark.d.ts +23 -51
- package/dist/ExpensiMark.js +311 -333
- package/dist/Func.js +3 -1
- package/dist/Log.js +1 -1
- package/dist/Logger.d.ts +2 -2
- package/dist/Logger.js +6 -4
- package/dist/Network.js +10 -10
- package/dist/Num.d.ts +1 -1
- package/dist/Num.js +9 -5
- package/dist/PageEvent.d.ts +2 -2
- package/dist/PageEvent.js +1 -1
- package/dist/PubSub.js +7 -7
- package/dist/ReportHistoryStore.d.ts +8 -71
- package/dist/ReportHistoryStore.js +106 -180
- package/dist/Templates.d.ts +13 -13
- package/dist/Templates.js +157 -183
- package/dist/components/StepProgressBar.d.ts +8 -4
- package/dist/components/StepProgressBar.js +4 -3
- package/dist/components/form/element/combobox.d.ts +1 -8
- package/dist/components/form/element/combobox.js +37 -37
- package/dist/components/form/element/switch.d.ts +2 -2
- package/dist/components/form/element/switch.js +7 -5
- package/dist/fastMerge.js +0 -2
- package/dist/index.js +0 -1
- package/dist/jquery.expensifyIframify.d.ts +1 -2
- package/dist/jquery.expensifyIframify.js +13 -15
- package/dist/md5.js +30 -29
- package/dist/mixins/PubSub.js +2 -2
- package/dist/str.js +19 -19
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +6 -6
- package/package.json +11 -10
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
9
9
|
const classnames_1 = __importDefault(require("classnames"));
|
|
10
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
11
|
/**
|
|
11
12
|
* Form Element Switch - Displays an on/off switch
|
|
12
13
|
*/
|
|
@@ -52,7 +53,7 @@ class Switch extends react_1.default.Component {
|
|
|
52
53
|
/**
|
|
53
54
|
* Gets the value of the field
|
|
54
55
|
*
|
|
55
|
-
* @
|
|
56
|
+
* @returns {boolean}
|
|
56
57
|
*/
|
|
57
58
|
getValue() {
|
|
58
59
|
return $(this.checkbox)[0].checked;
|
|
@@ -72,16 +73,15 @@ class Switch extends react_1.default.Component {
|
|
|
72
73
|
* then we need to open a confirm modal with those settings
|
|
73
74
|
*
|
|
74
75
|
* @param {SyntheticEvent} e
|
|
75
|
-
* @
|
|
76
|
+
* @returns {Boolean}
|
|
76
77
|
*/
|
|
77
78
|
showConfirm(e) {
|
|
78
|
-
var _a;
|
|
79
79
|
// Let our event happen normally
|
|
80
80
|
if (!this.props.confirm) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
e.preventDefault();
|
|
84
|
-
Modal.confirm(Object.assign(Object.assign({}, ((
|
|
84
|
+
Modal.confirm(Object.assign(Object.assign({}, (0, get_1.default)(this.props, 'confirm', {})), { onYesCallback: () => {
|
|
85
85
|
// Toggle the checked property and then fire our change handler
|
|
86
86
|
this.checkbox.checked = !this.getValue();
|
|
87
87
|
Func.invoke(this.props.onChange, [this.getValue()]);
|
|
@@ -92,7 +92,9 @@ class Switch extends react_1.default.Component {
|
|
|
92
92
|
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('onoffswitch-wrapper js_tooltip', this.props.extraClasses), title: this.props.tooltipText, ref: (el) => (this.element = el) },
|
|
93
93
|
react_1.default.createElement("input", { ref: (el) => (this.checkbox = el), type: "checkbox", id: this.props.id, className: "onoffswitch-checkbox", checked: this.props.checked, disabled: this.props.disabled, onClick: this.showConfirm, onChange: this.fireChangeHandler }),
|
|
94
94
|
react_1.default.createElement("label", { className: "onoffswitch-label", htmlFor: this.props.id },
|
|
95
|
-
react_1.default.createElement("span", { className: (0, classnames_1.default)('onoffswitch-inner', {
|
|
95
|
+
react_1.default.createElement("span", { className: (0, classnames_1.default)('onoffswitch-inner', {
|
|
96
|
+
noText: this.props.hideEnabledDisabledText,
|
|
97
|
+
}) }),
|
|
96
98
|
react_1.default.createElement("span", { className: "onoffswitch-switch" }))));
|
|
97
99
|
}
|
|
98
100
|
}
|
package/dist/fastMerge.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'worklet';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
5
4
|
// Mostly copied from https://medium.com/@lubaka.a/how-to-remove-lodash-performance-improvement-b306669ad0e1
|
|
6
5
|
/**
|
|
7
6
|
* Checks whether the given value can be merged. It has to be an object, but not an array, RegExp or Date.
|
|
@@ -48,7 +47,6 @@ function fastMerge(target, source, shouldRemoveNullObjectValues = true) {
|
|
|
48
47
|
const isSourceKeyMergable = isMergeableObject(sourceValue);
|
|
49
48
|
if (isSourceKeyMergable && targetValue) {
|
|
50
49
|
if (!shouldRemoveNullObjectValues || isSourceKeyMergable) {
|
|
51
|
-
// eslint-disable-next-line no-use-before-define
|
|
52
50
|
destination[key] = fastMerge(targetValue, sourceValue, shouldRemoveNullObjectValues);
|
|
53
51
|
}
|
|
54
52
|
}
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.md5 = exports.TLD_REGEX = exports.Str = exports.fastMerge = exports.Url = exports.Templates = exports.ReportHistoryStore = exports.PubSub = exports.PageEvent = exports.Num = exports.Network = exports.Logger = exports.ExpensiMark = exports.Device = exports.LOGIN_PARTNER_DETAILS = exports.CredentialsWrapper = exports.Cookie = exports.PUBLIC_DOMAINS_SET = exports.UI = exports.CONST = exports.g_cloudFrontImg = exports.g_cloudFront = exports.BrowserDetect = exports.APIDeferred = exports.API = void 0;
|
|
40
|
-
// eslint-disable-next-line rulesdir/no-api-in-views
|
|
41
40
|
var API_1 = require("./API");
|
|
42
41
|
Object.defineProperty(exports, "API", { enumerable: true, get: function () { return __importDefault(API_1).default; } });
|
|
43
42
|
var APIDeferred_1 = require("./APIDeferred");
|
|
@@ -21,8 +21,7 @@ exports.default = {
|
|
|
21
21
|
/**
|
|
22
22
|
* Loads the widget into jQuery
|
|
23
23
|
*
|
|
24
|
-
* @param {jQuery} $
|
|
25
|
-
* @param {Underscore} _
|
|
24
|
+
* @param {jQuery} $ jQuery instance
|
|
26
25
|
*/
|
|
27
26
|
load($) {
|
|
28
27
|
/**
|
|
@@ -41,7 +40,7 @@ exports.default = {
|
|
|
41
40
|
const defaultOrigin = `${window.location.protocol}//${window.location.hostname}`;
|
|
42
41
|
/**
|
|
43
42
|
* This indicates from and to which domains we need to send the messages.
|
|
44
|
-
* @type {
|
|
43
|
+
* @type {object}
|
|
45
44
|
*/
|
|
46
45
|
const allowedCommunications = {
|
|
47
46
|
'https://www.expensify.com': ['https://secure.expensify.com', 'https://www.expensify.com'],
|
|
@@ -57,9 +56,9 @@ exports.default = {
|
|
|
57
56
|
/**
|
|
58
57
|
* Holds a reference to the jQuery iFrame object
|
|
59
58
|
*
|
|
60
|
-
* @type {
|
|
59
|
+
* @type {object} jQuery Element
|
|
61
60
|
*/
|
|
62
|
-
let iframeElement = null;
|
|
61
|
+
let iframeElement = null;
|
|
63
62
|
/**
|
|
64
63
|
* Whether or not the parent window is listening to the message event
|
|
65
64
|
*
|
|
@@ -85,7 +84,7 @@ exports.default = {
|
|
|
85
84
|
/**
|
|
86
85
|
* Default settings for our plugin
|
|
87
86
|
*
|
|
88
|
-
* @type {
|
|
87
|
+
* @type {object}
|
|
89
88
|
*/
|
|
90
89
|
let settings = {
|
|
91
90
|
origin: defaultOrigin,
|
|
@@ -94,11 +93,12 @@ exports.default = {
|
|
|
94
93
|
/**
|
|
95
94
|
* Holds all of our registered event handlers
|
|
96
95
|
*
|
|
97
|
-
* @type {
|
|
96
|
+
* @type {object}
|
|
98
97
|
*/
|
|
99
98
|
let eventHandlers = {};
|
|
100
99
|
/**
|
|
101
100
|
* A method for logging things to the console for debugging
|
|
101
|
+
* @param {...any} args
|
|
102
102
|
*/
|
|
103
103
|
function log(...args) {
|
|
104
104
|
if (!settings.debug) {
|
|
@@ -225,7 +225,7 @@ exports.default = {
|
|
|
225
225
|
try {
|
|
226
226
|
data = JSON.parse(msgParts[1]);
|
|
227
227
|
}
|
|
228
|
-
catch (
|
|
228
|
+
catch (_a) {
|
|
229
229
|
// This should only happen if someone didn't code something right
|
|
230
230
|
console.error('Could not parse JSON response for some reason', event.data);
|
|
231
231
|
}
|
|
@@ -313,11 +313,9 @@ exports.default = {
|
|
|
313
313
|
eventHandlers = {};
|
|
314
314
|
}
|
|
315
315
|
else {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
};
|
|
320
|
-
eventHandlers.forEach(removeEventHandler);
|
|
316
|
+
for (const handlerMap of Object.values(eventHandlers)) {
|
|
317
|
+
delete handlerMap[name];
|
|
318
|
+
}
|
|
321
319
|
}
|
|
322
320
|
},
|
|
323
321
|
/**
|
|
@@ -342,7 +340,7 @@ exports.default = {
|
|
|
342
340
|
* @param {object} args to pass to an action method
|
|
343
341
|
* @param {function} callback (optional) for event handlers
|
|
344
342
|
*
|
|
345
|
-
* @
|
|
343
|
+
* @returns {[type]}
|
|
346
344
|
*/
|
|
347
345
|
$.fn.expensifyIframeify = function (actionOrOptions, args, callback) {
|
|
348
346
|
/* eslint-enable no-param-reassign */
|
|
@@ -352,7 +350,7 @@ exports.default = {
|
|
|
352
350
|
const domainWithoutSubdomain = domainArray.join('.');
|
|
353
351
|
// There are some browsers that don't support document.domain so we have to manually create it
|
|
354
352
|
document.domain = domainWithoutSubdomain;
|
|
355
|
-
iframeElement = this;
|
|
353
|
+
iframeElement = this;
|
|
356
354
|
if (!wasInitalized) {
|
|
357
355
|
// Determine if this is the parent, or the iframe
|
|
358
356
|
// Because our site runs inside of an iframe in salesforce, the parent
|
package/dist/md5.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable one-var, no-var, no-param-reassign, no-bitwise, eqeqeq,
|
|
2
|
+
/* eslint-disable one-var, no-var, no-param-reassign, no-bitwise, eqeqeq, @typescript-eslint/no-unused-vars, no-shadow */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
/**
|
|
5
5
|
* md5 hash implementation
|
|
6
6
|
* http://www.myersdaily.org/joseph/javascript/md5-text.html
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
+
function add32(a, b) {
|
|
10
|
+
return (a + b) & 0xffffffff;
|
|
11
|
+
}
|
|
12
|
+
function cmn(q, a, b, x, s, t) {
|
|
13
|
+
a = add32(add32(a, q), add32(x, t));
|
|
14
|
+
return add32((a << s) | (a >>> (32 - s)), b);
|
|
15
|
+
}
|
|
16
|
+
function ff(a, b, c, d, x, s, t) {
|
|
17
|
+
return cmn((b & c) | (~b & d), a, b, x, s, t);
|
|
18
|
+
}
|
|
19
|
+
function gg(a, b, c, d, x, s, t) {
|
|
20
|
+
return cmn((b & d) | (c & ~d), a, b, x, s, t);
|
|
21
|
+
}
|
|
22
|
+
function hh(a, b, c, d, x, s, t) {
|
|
23
|
+
return cmn(b ^ c ^ d, a, b, x, s, t);
|
|
24
|
+
}
|
|
25
|
+
function ii(a, b, c, d, x, s, t) {
|
|
26
|
+
return cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
27
|
+
}
|
|
28
|
+
function md5blk(s) {
|
|
29
|
+
/* I figured global was faster. */
|
|
30
|
+
var md5blks = [], i; /* Andy King said do it this way. */
|
|
31
|
+
for (i = 0; i < 64; i += 4) {
|
|
32
|
+
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
|
|
33
|
+
}
|
|
34
|
+
return md5blks;
|
|
35
|
+
}
|
|
9
36
|
function md5cycle(x, k) {
|
|
10
37
|
var a = x[0], b = x[1], c = x[2], d = x[3];
|
|
11
38
|
a = ff(a, b, c, d, k[0], 7, -680876936);
|
|
@@ -77,22 +104,6 @@ function md5cycle(x, k) {
|
|
|
77
104
|
x[2] = add32(c, x[2]);
|
|
78
105
|
x[3] = add32(d, x[3]);
|
|
79
106
|
}
|
|
80
|
-
function cmn(q, a, b, x, s, t) {
|
|
81
|
-
a = add32(add32(a, q), add32(x, t));
|
|
82
|
-
return add32((a << s) | (a >>> (32 - s)), b);
|
|
83
|
-
}
|
|
84
|
-
function ff(a, b, c, d, x, s, t) {
|
|
85
|
-
return cmn((b & c) | (~b & d), a, b, x, s, t);
|
|
86
|
-
}
|
|
87
|
-
function gg(a, b, c, d, x, s, t) {
|
|
88
|
-
return cmn((b & d) | (c & ~d), a, b, x, s, t);
|
|
89
|
-
}
|
|
90
|
-
function hh(a, b, c, d, x, s, t) {
|
|
91
|
-
return cmn(b ^ c ^ d, a, b, x, s, t);
|
|
92
|
-
}
|
|
93
|
-
function ii(a, b, c, d, x, s, t) {
|
|
94
|
-
return cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
95
|
-
}
|
|
96
107
|
function md51(s) {
|
|
97
108
|
var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i;
|
|
98
109
|
for (i = 64; i <= s.length; i += 64) {
|
|
@@ -129,19 +140,12 @@ function md51(s) {
|
|
|
129
140
|
* providing access to strings as preformed UTF-8
|
|
130
141
|
* 8-bit unsigned value arrays.
|
|
131
142
|
*/
|
|
132
|
-
function md5blk(s) {
|
|
133
|
-
/* I figured global was faster. */
|
|
134
|
-
var md5blks = [], i; /* Andy King said do it this way. */
|
|
135
|
-
for (i = 0; i < 64; i += 4) {
|
|
136
|
-
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
|
|
137
|
-
}
|
|
138
|
-
return md5blks;
|
|
139
|
-
}
|
|
140
143
|
var hex_chr = '0123456789abcdef'.split('');
|
|
141
144
|
function rhex(n) {
|
|
142
145
|
var s = '', j = 0;
|
|
143
146
|
for (; j < 4; j++) {
|
|
144
|
-
|
|
147
|
+
const shift = j * 8;
|
|
148
|
+
s += hex_chr[(n >> (shift + 4)) & 0x0f] + hex_chr[(n >> shift) & 0x0f];
|
|
145
149
|
}
|
|
146
150
|
return s;
|
|
147
151
|
}
|
|
@@ -159,9 +163,6 @@ function md5(s) {
|
|
|
159
163
|
are the only ones I know of that
|
|
160
164
|
need the idiotic second function,
|
|
161
165
|
generated by an if clause. */
|
|
162
|
-
function add32(a, b) {
|
|
163
|
-
return (a + b) & 0xffffffff;
|
|
164
|
-
}
|
|
165
166
|
if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
|
|
166
167
|
function add32(x, y) {
|
|
167
168
|
var lsw = (x & 0xffff) + (y & 0xffff), msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
package/dist/mixins/PubSub.js
CHANGED
|
@@ -77,9 +77,9 @@ const PubSubMixin = {
|
|
|
77
77
|
* When the component is unmounted, we want to subscribe from all of our event IDs
|
|
78
78
|
*/
|
|
79
79
|
componentWillUnmount() {
|
|
80
|
-
this.eventIds
|
|
80
|
+
for (const eventId of this.eventIds) {
|
|
81
81
|
PubSub.unsubscribe(eventId);
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
85
|
exports.default = PubSubMixin;
|
package/dist/str.js
CHANGED
|
@@ -76,9 +76,9 @@ const Str = {
|
|
|
76
76
|
* @returns The cent value of the @p amountStr.
|
|
77
77
|
*/
|
|
78
78
|
fromUSDToNumber(amountStr, allowFraction) {
|
|
79
|
-
let amount = String(amountStr).
|
|
79
|
+
let amount = String(amountStr).replaceAll(/[^\d.\-()]+/g, '');
|
|
80
80
|
if (amount.match(/\(.*\)/)) {
|
|
81
|
-
const modifiedAmount = amount.
|
|
81
|
+
const modifiedAmount = amount.replaceAll(/[()]/g, '');
|
|
82
82
|
amount = `-${modifiedAmount}`;
|
|
83
83
|
}
|
|
84
84
|
amount = Number(amount) * 100;
|
|
@@ -102,7 +102,7 @@ const Str = {
|
|
|
102
102
|
* Convert new line to <br />
|
|
103
103
|
*/
|
|
104
104
|
nl2br(str) {
|
|
105
|
-
return str.
|
|
105
|
+
return str.replaceAll('\n', '<br />');
|
|
106
106
|
},
|
|
107
107
|
/**
|
|
108
108
|
* Decodes the given HTML encoded string.
|
|
@@ -175,7 +175,7 @@ const Str = {
|
|
|
175
175
|
*/
|
|
176
176
|
makeID(str) {
|
|
177
177
|
const modifiedString = String(str)
|
|
178
|
-
.
|
|
178
|
+
.replaceAll(/[^A-Za-z0-9]/g, '_')
|
|
179
179
|
.toUpperCase();
|
|
180
180
|
return `id_${modifiedString}`;
|
|
181
181
|
},
|
|
@@ -206,7 +206,7 @@ const Str = {
|
|
|
206
206
|
function recap_callback(t, a, b) {
|
|
207
207
|
return a + b.toUpperCase();
|
|
208
208
|
}
|
|
209
|
-
return str.
|
|
209
|
+
return str.replaceAll(
|
|
210
210
|
// **NOTE: Match to _libfop.php
|
|
211
211
|
/([^A-Za-z'.0-9])([a-z])/g, recap_callback);
|
|
212
212
|
},
|
|
@@ -214,20 +214,20 @@ const Str = {
|
|
|
214
214
|
* Replace all the non alphanumerical character by _
|
|
215
215
|
*/
|
|
216
216
|
sanitizeToAlphaNumeric(input) {
|
|
217
|
-
return String(input).
|
|
217
|
+
return String(input).replaceAll(/[^\d\w]/g, '_');
|
|
218
218
|
},
|
|
219
219
|
/**
|
|
220
220
|
* Strip out all the non numerical characters
|
|
221
221
|
*/
|
|
222
222
|
stripNonNumeric(input) {
|
|
223
|
-
return String(input).
|
|
223
|
+
return String(input).replaceAll(/[^\d]/g, '');
|
|
224
224
|
},
|
|
225
225
|
/**
|
|
226
226
|
* Strips all non ascii characters from a string
|
|
227
227
|
* @returns The ascii version of the string.
|
|
228
228
|
*/
|
|
229
229
|
stripNonASCIICharacters(input) {
|
|
230
|
-
return String(input).
|
|
230
|
+
return String(input).replaceAll(/[\u0000-\u0019\u0080-\uffff]/g, '');
|
|
231
231
|
},
|
|
232
232
|
/**
|
|
233
233
|
* Shortens the @p text to @p length and appends an ellipses to it.
|
|
@@ -241,7 +241,7 @@ const Str = {
|
|
|
241
241
|
*/
|
|
242
242
|
shortenText(val, length) {
|
|
243
243
|
// Remove extra spaces because they don't show up in html anyway.
|
|
244
|
-
const text = String(val).
|
|
244
|
+
const text = String(val).replaceAll(/\s+/g, ' ');
|
|
245
245
|
const truncatedText = text.substr(0, length - 3);
|
|
246
246
|
return text.length > length ? `${truncatedText}...` : text;
|
|
247
247
|
},
|
|
@@ -325,7 +325,7 @@ const Str = {
|
|
|
325
325
|
if (!this.isString(str)) {
|
|
326
326
|
return '';
|
|
327
327
|
}
|
|
328
|
-
return str.
|
|
328
|
+
return str.replaceAll(/<[^>]*>?/gm, '');
|
|
329
329
|
},
|
|
330
330
|
/**
|
|
331
331
|
* Modifies the string so the first letter of the string is capitalized
|
|
@@ -422,7 +422,7 @@ const Str = {
|
|
|
422
422
|
* @returns string with the trailing comma removed
|
|
423
423
|
*/
|
|
424
424
|
removeTrailingComma(str) {
|
|
425
|
-
return str.trim().
|
|
425
|
+
return str.trim().replaceAll(/(,$)/g, '');
|
|
426
426
|
},
|
|
427
427
|
/**
|
|
428
428
|
* Checks that the string is a list of coma separated email addresss.
|
|
@@ -491,7 +491,7 @@ const Str = {
|
|
|
491
491
|
* Sanitize phone number to return only numbers. Return null if non valid phone number.
|
|
492
492
|
*/
|
|
493
493
|
sanitizePhoneNumber(str) {
|
|
494
|
-
const string = str.
|
|
494
|
+
const string = str.replaceAll(/(?!^\+)\D/g, '');
|
|
495
495
|
return string.length <= 15 && string.length >= 10 ? string : null;
|
|
496
496
|
},
|
|
497
497
|
/**
|
|
@@ -509,7 +509,7 @@ const Str = {
|
|
|
509
509
|
* @returns The escaped string
|
|
510
510
|
*/
|
|
511
511
|
escapeForRegExp(str) {
|
|
512
|
-
return str.
|
|
512
|
+
return str.replaceAll(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
|
513
513
|
},
|
|
514
514
|
/**
|
|
515
515
|
* Escapes all special RegExp characters from a string except for the period
|
|
@@ -518,7 +518,7 @@ const Str = {
|
|
|
518
518
|
* @returns The escaped string
|
|
519
519
|
*/
|
|
520
520
|
escapeForExpenseRule(str) {
|
|
521
|
-
return str.
|
|
521
|
+
return str.replaceAll(/[-[\]/{}()*+?\\^$|]/g, '\\$&');
|
|
522
522
|
},
|
|
523
523
|
/**
|
|
524
524
|
* Adds a backslash in front of each of colon
|
|
@@ -528,14 +528,14 @@ const Str = {
|
|
|
528
528
|
* @returns The escaped string
|
|
529
529
|
*/
|
|
530
530
|
addBackslashBeforeColonsForTagNamesComingFromQBD(str) {
|
|
531
|
-
return str.
|
|
531
|
+
return str.replaceAll(/([^\\]):/g, '$1\\:');
|
|
532
532
|
},
|
|
533
533
|
/**
|
|
534
534
|
* Removes backslashes from string
|
|
535
535
|
* eg: myString\[\]\* -> myString[]*
|
|
536
536
|
*/
|
|
537
537
|
stripBackslashes(str) {
|
|
538
|
-
return str.
|
|
538
|
+
return str.replaceAll('\\', '');
|
|
539
539
|
},
|
|
540
540
|
/**
|
|
541
541
|
* Checks if a string's length is in the specified range
|
|
@@ -593,7 +593,7 @@ const Str = {
|
|
|
593
593
|
*/
|
|
594
594
|
ucwords(str) {
|
|
595
595
|
const capitalize = ($1) => $1.toUpperCase();
|
|
596
|
-
return String(str).
|
|
596
|
+
return String(str).replaceAll(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, capitalize);
|
|
597
597
|
},
|
|
598
598
|
/**
|
|
599
599
|
* Returns true if the haystack contains the needle
|
|
@@ -740,7 +740,7 @@ const Str = {
|
|
|
740
740
|
if (!this.isString(str) || !this.isString(mask) || str.length === 0 || !this.isNumber(num)) {
|
|
741
741
|
return str;
|
|
742
742
|
}
|
|
743
|
-
return str.substring(0, num).
|
|
743
|
+
return str.substring(0, num).replaceAll(/./g, mask) + str.substring(num);
|
|
744
744
|
},
|
|
745
745
|
/**
|
|
746
746
|
* Trim a string
|
|
@@ -881,7 +881,7 @@ const Str = {
|
|
|
881
881
|
* Returns text without our SMS domain
|
|
882
882
|
*/
|
|
883
883
|
removeSMSDomain(text) {
|
|
884
|
-
return text.
|
|
884
|
+
return text.replaceAll(REMOVE_SMS_DOMAIN_PATTERN, '');
|
|
885
885
|
},
|
|
886
886
|
/**
|
|
887
887
|
* Returns true if the text is a valid E.164 phone number with our SMS domain removed
|
package/dist/utils.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ declare function escapeText(string: string): string;
|
|
|
17
17
|
declare function unescapeText(string: string): string;
|
|
18
18
|
/**
|
|
19
19
|
* Checks if the given variable is a function
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
20
|
+
* @param variableToCheck
|
|
21
|
+
* @returns
|
|
22
22
|
*/
|
|
23
23
|
declare function isFunction(variableToCheck: unknown): boolean;
|
|
24
24
|
/**
|
|
25
25
|
* Checks if the given variable is an object
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
26
|
+
* @param obj
|
|
27
|
+
* @returns
|
|
28
28
|
*/
|
|
29
29
|
declare function isObject(obj: unknown): boolean;
|
|
30
30
|
export { isWindowAvailable, isNavigatorAvailable, escapeText, unescapeText, isFunction, isObject };
|
package/dist/utils.js
CHANGED
|
@@ -31,7 +31,7 @@ const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
|
31
31
|
* Source: https://github.com/lodash/lodash/blob/main/src/escape.ts
|
|
32
32
|
*/
|
|
33
33
|
function escapeText(string) {
|
|
34
|
-
return string && reHasUnescapedHtml.test(string) ? string.
|
|
34
|
+
return string && reHasUnescapedHtml.test(string) ? string.replaceAll(reUnescapedHtml, (chr) => htmlEscapes[chr]) : string || '';
|
|
35
35
|
}
|
|
36
36
|
const htmlUnescapes = {
|
|
37
37
|
'&': '&',
|
|
@@ -51,20 +51,20 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source);
|
|
|
51
51
|
* Source: https://github.com/lodash/lodash/blob/main/src/unescape.ts
|
|
52
52
|
* */
|
|
53
53
|
function unescapeText(string) {
|
|
54
|
-
return string && reHasEscapedHtml.test(string) ? string.
|
|
54
|
+
return string && reHasEscapedHtml.test(string) ? string.replaceAll(reEscapedHtml, (entity) => htmlUnescapes[entity] || "'") : string || '';
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Checks if the given variable is a function
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
58
|
+
* @param variableToCheck
|
|
59
|
+
* @returns
|
|
60
60
|
*/
|
|
61
61
|
function isFunction(variableToCheck) {
|
|
62
62
|
return variableToCheck instanceof Function;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Checks if the given variable is an object
|
|
66
|
-
* @param
|
|
67
|
-
* @returns
|
|
66
|
+
* @param obj
|
|
67
|
+
* @returns
|
|
68
68
|
*/
|
|
69
69
|
function isObject(obj) {
|
|
70
70
|
const type = typeof obj;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expensify-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.183",
|
|
4
4
|
"author": "Expensify, Inc.",
|
|
5
5
|
"description": "Expensify libraries and components shared across different repos",
|
|
6
6
|
"homepage": "https://expensify.com",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"typecheck": "tsc --noEmit",
|
|
19
19
|
"build": "tsc -p tsconfig.build.json && cp ./lib/*.d.ts ./dist",
|
|
20
20
|
"test": "jest",
|
|
21
|
-
"lint": "eslint lib/",
|
|
21
|
+
"lint": "eslint lib/ __tests__/",
|
|
22
22
|
"prettier": "prettier --write lib/",
|
|
23
23
|
"patch": "npm --no-git-tag-version version patch",
|
|
24
24
|
"update-tlds": "echo \"$(curl -s https://data.iana.org/TLD/tlds-alpha-by-domain.txt | sed '1d' | awk '{print length, $0}' - | sort -n -r | cut -d \" \" -f2- )|SJC|RNO|LAX\" | tr '\\n' '|' | sed s'/.$//' | printf \"const TLD_REGEX='$(cat -)';\\n\\nexport default TLD_REGEX;\\n\" > lib/tlds.jsx"
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"ua-parser-js": "^1.0.38"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@babel/eslint-parser": "^7.28.4",
|
|
47
48
|
"@babel/preset-env": "^7.26.0",
|
|
49
|
+
"@babel/preset-react": "^7.26.0",
|
|
48
50
|
"@babel/preset-typescript": "^7.24.7",
|
|
49
|
-
"@
|
|
51
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
50
52
|
"@types/jest": "^29.5.13",
|
|
51
53
|
"@types/jquery": "^3.5.30",
|
|
52
54
|
"@types/lodash": "^4.17.10",
|
|
53
55
|
"@types/punycode": "^2.1.4",
|
|
54
56
|
"@types/react-dom": "^18.3.5",
|
|
55
57
|
"@types/ua-parser-js": "^0.7.39",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
57
|
-
"@typescript-eslint/parser": "^8.24.1",
|
|
58
58
|
"babel-jest": "^29.0.0",
|
|
59
59
|
"babelify": "10.0.0",
|
|
60
|
-
"eslint": "^
|
|
61
|
-
"eslint-config-expensify": "
|
|
62
|
-
"eslint-config-prettier": "^
|
|
63
|
-
"eslint-
|
|
60
|
+
"eslint": "^9.36.0",
|
|
61
|
+
"eslint-config-expensify": "4.0.3",
|
|
62
|
+
"eslint-config-prettier": "^10.1.5",
|
|
63
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
64
64
|
"eslint-plugin-prettier": "^5.2.1",
|
|
65
65
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
66
66
|
"grunt": "1.6.2",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"jest-environment-jsdom": "^29.7.0",
|
|
71
71
|
"jit-grunt": "^0.10.0",
|
|
72
72
|
"prettier": "^3.3.3",
|
|
73
|
-
"typescript": "^5.7.2"
|
|
73
|
+
"typescript": "^5.7.2",
|
|
74
|
+
"typescript-eslint": "^8.61.0"
|
|
74
75
|
},
|
|
75
76
|
"browserify": {
|
|
76
77
|
"transform": [
|