expensify-common 2.0.87 → 2.0.89
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
CHANGED
|
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
exports.default = API;
|
|
35
35
|
// Use this deferred lib so we don't have a dependency on jQuery (so we can use this module in mobile)
|
|
36
36
|
const simply_deferred_1 = require("simply-deferred");
|
|
37
|
-
const
|
|
37
|
+
const has_1 = __importDefault(require("lodash/has"));
|
|
38
38
|
const APIDeferred_1 = __importDefault(require("./APIDeferred"));
|
|
39
39
|
const Utils = __importStar(require("./utils"));
|
|
40
40
|
/**
|
|
@@ -166,14 +166,14 @@ function API(network, args) {
|
|
|
166
166
|
function requireParameters(parameterNames, parameters, commandName) {
|
|
167
167
|
// eslint-disable-next-line rulesdir/prefer-early-return
|
|
168
168
|
parameterNames.forEach((parameterName) => {
|
|
169
|
-
if ((0,
|
|
169
|
+
if ((0, has_1.default)(parameters, parameterName) && parameters[parameterName] !== null && parameters[parameterName] !== undefined) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
const parametersCopy = Object.assign({}, parameters);
|
|
173
|
-
if ((0,
|
|
173
|
+
if ((0, has_1.default)(parametersCopy, 'authToken')) {
|
|
174
174
|
parametersCopy.authToken = '<redacted>';
|
|
175
175
|
}
|
|
176
|
-
if ((0,
|
|
176
|
+
if ((0, has_1.default)(parametersCopy, 'password')) {
|
|
177
177
|
parametersCopy.password = '<redacted>';
|
|
178
178
|
}
|
|
179
179
|
const keys = Object.keys(parametersCopy).join(', ') || 'none';
|
package/dist/APIDeferred.js
CHANGED
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.default = APIDeferred;
|
|
27
30
|
/**
|
|
@@ -29,7 +32,7 @@ exports.default = APIDeferred;
|
|
|
29
32
|
* WIP, This is in the process of migration from web-e. Please add methods to this as is needed.|
|
|
30
33
|
* ----------------------------------------------------------------------------------------------
|
|
31
34
|
*/
|
|
32
|
-
const
|
|
35
|
+
const once_1 = __importDefault(require("lodash/once"));
|
|
33
36
|
const Utils = __importStar(require("./utils"));
|
|
34
37
|
const Func = __importStar(require("./Func"));
|
|
35
38
|
/**
|
|
@@ -148,7 +151,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
148
151
|
*/
|
|
149
152
|
done(callback) {
|
|
150
153
|
if (Utils.isFunction(callback)) {
|
|
151
|
-
doneCallbacks.push((0,
|
|
154
|
+
doneCallbacks.push((0, once_1.default)(callback));
|
|
152
155
|
ensureFutureCallbacksFire();
|
|
153
156
|
}
|
|
154
157
|
return this;
|
|
@@ -162,7 +165,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
162
165
|
*/
|
|
163
166
|
always(callback) {
|
|
164
167
|
if (Utils.isFunction(callback)) {
|
|
165
|
-
alwaysCallbacks.push((0,
|
|
168
|
+
alwaysCallbacks.push((0, once_1.default)(callback));
|
|
166
169
|
ensureFutureCallbacksFire();
|
|
167
170
|
}
|
|
168
171
|
return this;
|
|
@@ -185,7 +188,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
185
188
|
if (!errorHandlers[code]) {
|
|
186
189
|
errorHandlers[code] = [];
|
|
187
190
|
}
|
|
188
|
-
errorHandlers[code].push((0,
|
|
191
|
+
errorHandlers[code].push((0, once_1.default)(callback));
|
|
189
192
|
});
|
|
190
193
|
ensureFutureCallbacksFire();
|
|
191
194
|
}
|
|
@@ -200,7 +203,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
200
203
|
*/
|
|
201
204
|
unhandled(callback) {
|
|
202
205
|
if (Utils.isFunction(callback)) {
|
|
203
|
-
unhandledCallbacks.push((0,
|
|
206
|
+
unhandledCallbacks.push((0, once_1.default)(callback));
|
|
204
207
|
ensureFutureCallbacksFire();
|
|
205
208
|
}
|
|
206
209
|
return this;
|
|
@@ -215,7 +218,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
215
218
|
*/
|
|
216
219
|
fail(callback) {
|
|
217
220
|
if (Utils.isFunction(callback)) {
|
|
218
|
-
failCallbacks.push((0,
|
|
221
|
+
failCallbacks.push((0, once_1.default)(callback));
|
|
219
222
|
ensureFutureCallbacksFire();
|
|
220
223
|
}
|
|
221
224
|
return this;
|
package/dist/ExpensiMark.js
CHANGED
|
@@ -116,8 +116,13 @@ class ExpensiMark {
|
|
|
116
116
|
// Use the url escaped version of a backtick (`) symbol. Mobile platforms do not support lookbehinds,
|
|
117
117
|
// so capture the first and third group and place them in the replacement.
|
|
118
118
|
// but we should not replace backtick symbols if they include <pre> tags between them.
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
// At least one non-whitespace character or a specific whitespace character (" " and "\u00A0")
|
|
120
|
+
// must be present inside the backticks.
|
|
121
|
+
regex: /(\B|_|)`((?:`)*(?!`).*?[\S| |\u00A0]+?.*?(?<!`)(?:`)*)`(\B|_|)(?!`|[^<]*<\/pre>|[^<]*<\/video>)/gm,
|
|
122
|
+
replacement: (_extras, _match, g1, g2, g3) => {
|
|
123
|
+
const g2Value = g2.trim() === '' ? g2.replaceAll(' ', ' ') : g2;
|
|
124
|
+
return `${g1}<code>${g2Value}</code>${g3}`;
|
|
125
|
+
},
|
|
121
126
|
},
|
|
122
127
|
/**
|
|
123
128
|
* Converts markdown style links to anchor tags e.g. [Expensify](concierge@expensify.com)
|
package/dist/PubSub.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const has_1 = __importDefault(require("lodash/has"));
|
|
30
|
-
const
|
|
30
|
+
const once_1 = __importDefault(require("lodash/once"));
|
|
31
31
|
const Log_1 = __importDefault(require("./Log"));
|
|
32
32
|
const Utils = __importStar(require("./utils"));
|
|
33
33
|
/**
|
|
@@ -90,7 +90,7 @@ const PubSubModule = {
|
|
|
90
90
|
*/
|
|
91
91
|
once(eventName, callback, optionalScope) {
|
|
92
92
|
const scope = Utils.isObject(optionalScope) && optionalScope !== null ? optionalScope : window;
|
|
93
|
-
const functionToCallOnce = (0,
|
|
93
|
+
const functionToCallOnce = (0, once_1.default)((...args) => callback.apply(scope, args));
|
|
94
94
|
return this.subscribe(eventName, functionToCallOnce);
|
|
95
95
|
},
|
|
96
96
|
/**
|
package/dist/Templates.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const jquery_1 = __importDefault(require("jquery"));
|
|
30
|
-
const
|
|
30
|
+
const template_1 = __importDefault(require("lodash/template"));
|
|
31
31
|
const Utils = __importStar(require("./utils"));
|
|
32
32
|
/**
|
|
33
33
|
* JS Templating system, powered by underscore template
|
|
@@ -62,7 +62,7 @@ exports.default = (function () {
|
|
|
62
62
|
*/
|
|
63
63
|
get(data = {}) {
|
|
64
64
|
if (!this.compiled) {
|
|
65
|
-
this.compiled = (0,
|
|
65
|
+
this.compiled = (0, template_1.default)(this.templateValue);
|
|
66
66
|
this.templateValue = '';
|
|
67
67
|
}
|
|
68
68
|
return this.compiled(data);
|
|
@@ -94,7 +94,7 @@ exports.default = (function () {
|
|
|
94
94
|
// eslint-disable-next-line no-undef
|
|
95
95
|
dataToCompile.nestedTemplate = Templates.get;
|
|
96
96
|
if (!this.compiled) {
|
|
97
|
-
this.compiled = (0,
|
|
97
|
+
this.compiled = (0, template_1.default)((0, jquery_1.default)(`#${this.id}`).html());
|
|
98
98
|
}
|
|
99
99
|
return this.compiled(dataToCompile);
|
|
100
100
|
}
|
|
@@ -30,7 +30,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
30
30
|
const react_dom_1 = __importDefault(require("react-dom"));
|
|
31
31
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
32
32
|
const classnames_1 = __importDefault(require("classnames"));
|
|
33
|
-
const
|
|
33
|
+
const defer_1 = __importDefault(require("lodash/defer"));
|
|
34
|
+
const has_1 = __importDefault(require("lodash/has"));
|
|
35
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
36
|
+
const template_1 = __importDefault(require("lodash/template"));
|
|
37
|
+
const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
|
|
34
38
|
const str_1 = __importDefault(require("../../../str"));
|
|
35
39
|
const dropdown_1 = __importDefault(require("./dropdown"));
|
|
36
40
|
const Utils = __importStar(require("../../../utils"));
|
|
@@ -174,34 +178,34 @@ class Combobox extends react_1.default.Component {
|
|
|
174
178
|
}
|
|
175
179
|
// Our dropdown will be open, so we need to listen for our click away events
|
|
176
180
|
// and put focus on the input
|
|
177
|
-
(0,
|
|
181
|
+
(0, defer_1.default)(this.resetClickAwayHandler);
|
|
178
182
|
$(this.value).focus().select();
|
|
179
183
|
}
|
|
180
184
|
// eslint-disable-next-line react/no-unsafe
|
|
181
185
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
182
|
-
if (!nextProps.value || (0,
|
|
186
|
+
if (!nextProps.value || (0, isEqual_1.default)(nextProps.value, this.state.currentValue)) {
|
|
183
187
|
return;
|
|
184
188
|
}
|
|
185
189
|
this.setValue(nextProps.value);
|
|
186
190
|
if (nextProps.options !== undefined) {
|
|
187
191
|
// If the options have an id property, we use that to compare them and determine if they changed, if not
|
|
188
192
|
// we'll use the whole options array.
|
|
189
|
-
if ((0,
|
|
190
|
-
if (nextProps.options.some((option, index) => !(0,
|
|
191
|
-
nextProps.alreadySelectedOptions.some((alreadySelectedOption, index) => !(0,
|
|
193
|
+
if ((0, has_1.default)(nextProps.options, '0.id')) {
|
|
194
|
+
if (nextProps.options.some((option, index) => !(0, isEqual_1.default)(option.id, this.props.options[index].id)) ||
|
|
195
|
+
nextProps.alreadySelectedOptions.some((alreadySelectedOption, index) => !(0, isEqual_1.default)(alreadySelectedOption.id, this.props.alreadySelectedOptions[index].id))) {
|
|
192
196
|
this.reset(false, nextProps.options, nextProps.alreadySelectedOptions);
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
|
-
else if (!(0,
|
|
199
|
+
else if (!(0, isEqual_1.default)(nextProps.options, this.props.options) || !(0, isEqual_1.default)(nextProps.alreadySelectedOptions, this.props.alreadySelectedOptions)) {
|
|
196
200
|
this.reset(false, nextProps.options, nextProps.alreadySelectedOptions);
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
|
-
if (nextProps.openOnInit !== undefined && !(0,
|
|
203
|
+
if (nextProps.openOnInit !== undefined && !(0, isEqual_1.default)(nextProps.openOnInit, this.props.openOnInit)) {
|
|
200
204
|
this.setState({
|
|
201
205
|
isDropdownOpen: nextProps.openOnInit,
|
|
202
206
|
});
|
|
203
207
|
}
|
|
204
|
-
if (nextProps.isReadOnly !== undefined && !(0,
|
|
208
|
+
if (nextProps.isReadOnly !== undefined && !(0, isEqual_1.default)(nextProps.isReadOnly, this.props.isReadOnly)) {
|
|
205
209
|
this.setState({
|
|
206
210
|
isDisabled: nextProps.isReadOnly,
|
|
207
211
|
});
|
|
@@ -417,7 +421,7 @@ class Combobox extends react_1.default.Component {
|
|
|
417
421
|
const dividerIndex = this.options.findIndex(findDivider);
|
|
418
422
|
// Split into two arrays everything before and after the divider (if the divider does not exist then we'll return a single array)
|
|
419
423
|
const splitOptions = dividerIndex ? [this.options.slice(0, dividerIndex + 1), this.options.slice(dividerIndex + 1)] : [this.options];
|
|
420
|
-
const formatOption = (option) => (Object.assign({ focused: false, isSelected: option.selected && ((0,
|
|
424
|
+
const formatOption = (option) => (Object.assign({ focused: false, isSelected: option.selected && ((0, isEqual_1.default)(option.value, currentValue) || !!alreadySelected.find((item) => item.value === option.value)) }, option));
|
|
421
425
|
const sortByOption = (o) => {
|
|
422
426
|
// Unselectable text-only entries (isFake: true) go to the bottom and selected entries go to the top only if alwaysShowSelectedOnTop was passed
|
|
423
427
|
if (o.showLast) {
|
|
@@ -471,7 +475,7 @@ class Combobox extends react_1.default.Component {
|
|
|
471
475
|
const currentText = (optionMatchingVal === null || optionMatchingVal === void 0 ? void 0 : optionMatchingVal.text) || '';
|
|
472
476
|
const deselectOption = (initialOption) => {
|
|
473
477
|
const option = initialOption;
|
|
474
|
-
const isSelected = (0,
|
|
478
|
+
const isSelected = (0, isEqual_1.default)(option.value, val);
|
|
475
479
|
option.isSelected = isSelected || !!this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value);
|
|
476
480
|
return option;
|
|
477
481
|
};
|
|
@@ -715,7 +719,7 @@ class Combobox extends react_1.default.Component {
|
|
|
715
719
|
const matchRegexes = [new RegExp(`^${str_1.default.escapeForRegExp(value)}$`, 'i'), new RegExp(`^${str_1.default.escapeForRegExp(value)}`, 'i'), new RegExp(str_1.default.escapeForRegExp(value), 'i')];
|
|
716
720
|
let hasMoreResults = false;
|
|
717
721
|
let matches = new Set();
|
|
718
|
-
const searchOptions = (0,
|
|
722
|
+
const searchOptions = (0, uniqBy_1.default)(this.options, 'value');
|
|
719
723
|
for (let i = 0; i < matchRegexes.length; i++) {
|
|
720
724
|
if (matches.size < this.props.maxSearchResults) {
|
|
721
725
|
for (let j = 0; j < searchOptions.length; j++) {
|
|
@@ -739,7 +743,7 @@ class Combobox extends react_1.default.Component {
|
|
|
739
743
|
}
|
|
740
744
|
}
|
|
741
745
|
matches = Array.from(matches);
|
|
742
|
-
const formatOption = (option) => (Object.assign({ focused: false, isSelected: (0,
|
|
746
|
+
const formatOption = (option) => (Object.assign({ focused: false, isSelected: (0, isEqual_1.default)(option.value ? option.value.toUpperCase : '', value.toUpperCase()) || !!this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value) }, option));
|
|
743
747
|
const options = matches.map(formatOption);
|
|
744
748
|
// Focus the first option if there is one and show a message dependent on what options are present
|
|
745
749
|
if (options.length) {
|
|
@@ -756,7 +760,7 @@ class Combobox extends react_1.default.Component {
|
|
|
756
760
|
}
|
|
757
761
|
else {
|
|
758
762
|
options.push({
|
|
759
|
-
text: this.props.allowAnyValue ? value : (0,
|
|
763
|
+
text: this.props.allowAnyValue ? value : (0, template_1.default)(this.props.noResultsText)({ value }),
|
|
760
764
|
value: this.props.allowAnyValue ? value : '',
|
|
761
765
|
isSelectable: this.props.allowAnyValue,
|
|
762
766
|
isFake: true,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
8
8
|
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
-
const
|
|
9
|
+
const uniqueId_1 = __importDefault(require("lodash/uniqueId"));
|
|
10
10
|
const dropdownItem_1 = __importDefault(require("./dropdownItem"));
|
|
11
11
|
const propTypes = {
|
|
12
12
|
// These are the elements to show in the dropdown
|
|
@@ -52,7 +52,7 @@ class DropDown extends react_1.default.Component {
|
|
|
52
52
|
this.props.onChange(option.value);
|
|
53
53
|
}
|
|
54
54
|
renderOption(option) {
|
|
55
|
-
return (react_1.default.createElement(dropdownItem_1.default, { key: (0,
|
|
55
|
+
return (react_1.default.createElement(dropdownItem_1.default, { key: (0, uniqueId_1.default)(), bs4: this.props.bs4, value: option.value, text: option.text || '',
|
|
56
56
|
// eslint-disable-next-line react/no-children-prop
|
|
57
57
|
children: option.children || null, disabled: option.disabled || false, focused: option.focused || false, isSelected: option.isSelected || false, isSelectable: option.isSelectable || true, divider: option.divider || false, extraClasses: option.extraClasses || [], onClick: () => this.handleClick(option) }, option.children));
|
|
58
58
|
}
|