expensify-common 2.0.188 → 2.0.190
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/Logger.js +11 -1
- package/dist/esm/API.d.ts +11 -0
- package/dist/esm/API.js +786 -0
- package/dist/esm/APIDeferred.d.ts +7 -0
- package/dist/esm/APIDeferred.js +216 -0
- package/dist/esm/BrowserDetect.d.ts +19 -0
- package/dist/esm/BrowserDetect.js +105 -0
- package/dist/esm/CLI.js +37 -29
- package/dist/esm/CONST.d.ts +1727 -0
- package/dist/esm/CONST.js +1847 -0
- package/dist/esm/Cookie.d.ts +68 -0
- package/dist/esm/Cookie.js +159 -0
- package/dist/esm/CredentialsWrapper.d.ts +32 -0
- package/dist/esm/CredentialsWrapper.js +46 -0
- package/dist/esm/Device.d.ts +8 -0
- package/dist/esm/Device.js +24 -0
- package/dist/esm/ExpenseRule.d.ts +39 -0
- package/dist/esm/ExpenseRule.js +77 -0
- package/dist/esm/ExpensiMark.d.ts +197 -0
- package/dist/esm/ExpensiMark.js +1374 -0
- package/dist/esm/Func.d.ts +40 -0
- package/dist/esm/Func.js +69 -0
- package/dist/esm/Log.d.ts +3 -0
- package/dist/esm/Log.js +35 -0
- package/dist/esm/Logger.d.ts +82 -0
- package/dist/esm/Logger.js +148 -0
- package/dist/esm/Network.d.ts +6 -0
- package/dist/esm/Network.js +168 -0
- package/dist/esm/Num.d.ts +95 -0
- package/dist/esm/Num.js +190 -0
- package/dist/esm/PageEvent.d.ts +25 -0
- package/dist/esm/PageEvent.js +22 -0
- package/dist/esm/PubSub.d.ts +2 -0
- package/dist/esm/PubSub.js +111 -0
- package/dist/esm/ReportHistoryStore.d.ts +8 -0
- package/dist/esm/ReportHistoryStore.js +199 -0
- package/dist/esm/SafeString.js +2 -2
- package/dist/esm/Templates.d.ts +58 -0
- package/dist/esm/Templates.js +196 -0
- package/dist/esm/Url.d.ts +10 -0
- package/dist/esm/Url.js +15 -0
- package/dist/esm/components/CopyText.d.ts +45 -0
- package/dist/esm/components/CopyText.js +56 -0
- package/dist/esm/components/StepProgressBar.d.ts +26 -0
- package/dist/esm/components/StepProgressBar.js +40 -0
- package/dist/esm/components/form/element/combobox.d.ts +231 -0
- package/dist/esm/components/form/element/combobox.js +812 -0
- package/dist/esm/components/form/element/dropdown.d.ts +35 -0
- package/dist/esm/components/form/element/dropdown.js +61 -0
- package/dist/esm/components/form/element/dropdownItem.d.ts +55 -0
- package/dist/esm/components/form/element/dropdownItem.js +113 -0
- package/dist/esm/components/form/element/onOffSwitch.d.ts +94 -0
- package/dist/esm/components/form/element/onOffSwitch.js +167 -0
- package/dist/esm/components/form/element/switch.d.ts +58 -0
- package/dist/esm/components/form/element/switch.js +98 -0
- package/dist/esm/fastMerge.d.ts +9 -0
- package/dist/esm/fastMerge.js +58 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/jquery.expensifyIframify.d.ts +9 -0
- package/dist/esm/jquery.expensifyIframify.js +397 -0
- package/dist/esm/md5.d.ts +2 -0
- package/dist/esm/md5.js +170 -0
- package/dist/esm/mixins/PubSub.d.ts +20 -0
- package/dist/esm/mixins/PubSub.js +47 -0
- package/dist/esm/mixins/extraClasses.d.ts +8 -0
- package/dist/esm/mixins/extraClasses.js +37 -0
- package/dist/esm/mixins/validationClasses.d.ts +12 -0
- package/dist/esm/mixins/validationClasses.js +30 -0
- package/dist/esm/str.d.ts +604 -0
- package/dist/esm/str.js +1036 -0
- package/dist/esm/tlds.d.ts +2 -0
- package/dist/esm/tlds.js +2 -0
- package/dist/esm/utils.d.ts +30 -0
- package/dist/esm/utils.js +65 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -1
- package/package.json +221 -4
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import createTemplate from 'lodash/template';
|
|
3
|
+
import * as Utils from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* JS Templating system, powered by underscore template
|
|
6
|
+
*
|
|
7
|
+
* Templates is a global namespace for each template, HTML ones or inlines ones.
|
|
8
|
+
*
|
|
9
|
+
* @type Module
|
|
10
|
+
* @class
|
|
11
|
+
*/
|
|
12
|
+
const templateStore = {};
|
|
13
|
+
/**
|
|
14
|
+
* @param {String} templateValue
|
|
15
|
+
* @returns {{get: function(Object=): String}}
|
|
16
|
+
*/
|
|
17
|
+
function createInlineTemplate(templateValue) {
|
|
18
|
+
let compiled = null;
|
|
19
|
+
let storedValue = templateValue;
|
|
20
|
+
return {
|
|
21
|
+
get(data = {}) {
|
|
22
|
+
if (!compiled) {
|
|
23
|
+
compiled = createTemplate(storedValue, {
|
|
24
|
+
imports: {
|
|
25
|
+
// Here we ignore the eslint rule because _ is imported from OD which does not exist in this repo
|
|
26
|
+
// eslint-disable-next-line no-undef, object-shorthand
|
|
27
|
+
_: _,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
storedValue = '';
|
|
31
|
+
}
|
|
32
|
+
return compiled(data);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param {String} id
|
|
38
|
+
* @param {function} getNestedTemplate
|
|
39
|
+
* @returns {{get: function(Object=): String}}
|
|
40
|
+
*/
|
|
41
|
+
function createDOMTemplate(id, getNestedTemplate) {
|
|
42
|
+
let compiled = null;
|
|
43
|
+
return {
|
|
44
|
+
get(data = {}) {
|
|
45
|
+
// Add the "template" object to the parameter to allow nested templates
|
|
46
|
+
const dataToCompile = Object.assign({}, data);
|
|
47
|
+
dataToCompile.nestedTemplate = getNestedTemplate;
|
|
48
|
+
if (!compiled) {
|
|
49
|
+
compiled = createTemplate($(`#${id}`).html(), {
|
|
50
|
+
imports: {
|
|
51
|
+
// Here we ignore the eslint rule because _ is imported from OD which does not exist in this repo
|
|
52
|
+
// eslint-disable-next-line no-undef, object-shorthand
|
|
53
|
+
_: _,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return compiled(dataToCompile);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the template
|
|
63
|
+
*
|
|
64
|
+
* @param {Array} templatePath
|
|
65
|
+
* @returns {InlineTemplate|undefined}
|
|
66
|
+
*/
|
|
67
|
+
function getTemplate(templatePath) {
|
|
68
|
+
let template = templateStore;
|
|
69
|
+
for (const pathname of templatePath) {
|
|
70
|
+
template = template[pathname];
|
|
71
|
+
}
|
|
72
|
+
return template;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Based on an array of string, return a reference to the object that should hold the template
|
|
76
|
+
* used to augment the template object
|
|
77
|
+
*
|
|
78
|
+
* @param {Array} wantedNamespace Array of string reprensenting the namespace
|
|
79
|
+
* @returns {Object} Referene to the object holding the namespace
|
|
80
|
+
*/
|
|
81
|
+
function getTemplateNamespace(wantedNamespace) {
|
|
82
|
+
let namespace = templateStore;
|
|
83
|
+
let currentArgument;
|
|
84
|
+
for (let argumentNumber = 0; argumentNumber < wantedNamespace.length; argumentNumber++) {
|
|
85
|
+
currentArgument = wantedNamespace[argumentNumber];
|
|
86
|
+
if (namespace[currentArgument] === undefined) {
|
|
87
|
+
namespace[currentArgument] = {};
|
|
88
|
+
}
|
|
89
|
+
namespace = namespace[currentArgument];
|
|
90
|
+
}
|
|
91
|
+
return namespace;
|
|
92
|
+
}
|
|
93
|
+
const Templates = {
|
|
94
|
+
/**
|
|
95
|
+
* Given a templatePath, return the value
|
|
96
|
+
*
|
|
97
|
+
* @param {Array} templatePath
|
|
98
|
+
* @param {Object} [data] Information that need to be injected into the template
|
|
99
|
+
* @returns {String}
|
|
100
|
+
*/
|
|
101
|
+
get(templatePath, data = {}) {
|
|
102
|
+
const template = getTemplate(templatePath);
|
|
103
|
+
if (template === undefined) {
|
|
104
|
+
throw Error(`Template '${templatePath}' is not defined`);
|
|
105
|
+
}
|
|
106
|
+
// Check for the absense of get which means someone is likely using
|
|
107
|
+
// the templating engine wrong and trying to access a template namespace
|
|
108
|
+
if (!{}.propertyIsEnumerable.call(template, 'get')) {
|
|
109
|
+
throw Error(`'${templatePath}' is not a valid template path`);
|
|
110
|
+
}
|
|
111
|
+
return template.get(data);
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Given a templatePath, does it have a registered template?
|
|
115
|
+
* @param {Array} templatePath
|
|
116
|
+
* @returns {Boolean}
|
|
117
|
+
*/
|
|
118
|
+
has(templatePath) {
|
|
119
|
+
return getTemplate(templatePath) !== undefined;
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Inits the templating engine, and slurps all DOM templates in an internal data structure
|
|
123
|
+
*/
|
|
124
|
+
init() {
|
|
125
|
+
// Read the DOM to find all the templates, and make them available to the code
|
|
126
|
+
for (const $el of $('.js_template').toArray()) {
|
|
127
|
+
const namespaceElements = $el.id.split('_');
|
|
128
|
+
const id = namespaceElements.pop();
|
|
129
|
+
// remove the prefix "template" that MUST be added to have clean HTML ids
|
|
130
|
+
namespaceElements.shift();
|
|
131
|
+
const namespace = getTemplateNamespace(namespaceElements);
|
|
132
|
+
namespace[id] = createDOMTemplate($el.id, Templates.get);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* Register a new json object in the template manager
|
|
137
|
+
*
|
|
138
|
+
* @param {Array} wantedNamespace Namespace where we want to store the templates
|
|
139
|
+
* @param {object} templateData The literal object that contain the templates
|
|
140
|
+
*/
|
|
141
|
+
register(wantedNamespace, templateData) {
|
|
142
|
+
const namespace = getTemplateNamespace(wantedNamespace);
|
|
143
|
+
for (const key of Object.keys(templateData)) {
|
|
144
|
+
const template = templateData[key];
|
|
145
|
+
if (Utils.isObject(template)) {
|
|
146
|
+
// If the template is an object, add templates for all keys
|
|
147
|
+
namespace[key] = {};
|
|
148
|
+
for (const templateKey of Object.keys(template)) {
|
|
149
|
+
namespace[key][templateKey] = createInlineTemplate(template[templateKey]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
namespace[key] = createInlineTemplate(template);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Removes a namespace from the templateStore (only used for testing purposes)
|
|
159
|
+
*
|
|
160
|
+
* @param {String} nameSpace
|
|
161
|
+
*/
|
|
162
|
+
unregister(nameSpace) {
|
|
163
|
+
delete templateStore[nameSpace];
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Replace the DOM HTML with the template value
|
|
167
|
+
*
|
|
168
|
+
* @param {jQuery} $target Element(s) that will be updated
|
|
169
|
+
* @param {Array} templatePath
|
|
170
|
+
* @param {Object} [data] Information that need to be injected into the template
|
|
171
|
+
*/
|
|
172
|
+
insert($target, templatePath, data = {}) {
|
|
173
|
+
$target.html(this.get(templatePath, data));
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Append the template value into a DOM elements
|
|
177
|
+
*
|
|
178
|
+
* @param {jQuery} $target Element(s) that will be updated
|
|
179
|
+
* @param {Array} templatePath
|
|
180
|
+
* @param {Object} data Information that need to be injected into the template
|
|
181
|
+
*/
|
|
182
|
+
prepend($target, templatePath, data) {
|
|
183
|
+
$target.prepend(this.get(templatePath, data));
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* Prepend the template value into a DOM elements
|
|
187
|
+
*
|
|
188
|
+
* @param {jQuery} $target Element(s) that will be updated
|
|
189
|
+
* @param {array} templatePath
|
|
190
|
+
* @param {object} [data] Information that need to be injected into the template
|
|
191
|
+
*/
|
|
192
|
+
append($target, templatePath, data) {
|
|
193
|
+
$target.append(this.get(templatePath, data));
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
export default Templates;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const URL_WEBSITE_REGEX: string;
|
|
2
|
+
export const URL_PATH_REGEX: string;
|
|
3
|
+
export const URL_PARAM_REGEX: string;
|
|
4
|
+
export const URL_FRAGMENT_REGEX: string;
|
|
5
|
+
export const URL_REGEX: string;
|
|
6
|
+
export const URL_REGEX_WITH_REQUIRED_PROTOCOL: string;
|
|
7
|
+
export const URL_PROTOCOL_REGEX: "((ht|f)tps?:\\/\\/)";
|
|
8
|
+
export const LOOSE_URL_REGEX: string;
|
|
9
|
+
export const LOOSE_URL_WEBSITE_REGEX: "((ht|f)tps?:\\/\\/)((?!-)[-a-z0-9]+(?<!-)(?:\\.(?!-)[-a-z0-9]+(?<!-))*)(?:\\:([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])|\\b|(?=_))";
|
|
10
|
+
export const MARKDOWN_URL_REGEX: string;
|
package/dist/esm/Url.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TLD_REGEX from './tlds';
|
|
2
|
+
const ALLOWED_PORTS = '([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])';
|
|
3
|
+
const URL_PROTOCOL_REGEX = '((ht|f)tps?:\\/\\/)';
|
|
4
|
+
const URL_WEBSITE_REGEX = `${URL_PROTOCOL_REGEX}?((?:www\\.)?[a-z0-9](?=(?<label>[-a-z0-9]*[a-z0-9])?)\\k<label>\\.)+(?:${TLD_REGEX})\
|
|
5
|
+
(?:\\:${ALLOWED_PORTS}|\\b|(?=_))(?!@(?:[a-z\\d-]+\\.)+[a-z]{2,})`;
|
|
6
|
+
const addEscapedChar = (reg) => `(?:${reg}|&(?:amp|#x27);)`;
|
|
7
|
+
const URL_PATH_REGEX = `(?:${addEscapedChar('[.,=(+$!*]')}?\\/${addEscapedChar('[-\\w$@.+!*:(),=%~]')}*${addEscapedChar('[-\\w~@:%)]')}|\\/)*`;
|
|
8
|
+
const URL_PARAM_REGEX = `(?:\\?${addEscapedChar('[-\\w$@.+!*()\\/,=%{}:;\\[\\]\\|_|~]')}+)?`;
|
|
9
|
+
const URL_FRAGMENT_REGEX = `(?:#${addEscapedChar('[-\\w$@.+!*()[\\],=%;\\/:~]')}*)?`;
|
|
10
|
+
const URL_REGEX = `((${URL_WEBSITE_REGEX})${URL_PATH_REGEX}(?:${URL_PARAM_REGEX}|${URL_FRAGMENT_REGEX})*)`;
|
|
11
|
+
const URL_REGEX_WITH_REQUIRED_PROTOCOL = URL_REGEX.replace(`${URL_PROTOCOL_REGEX}?`, URL_PROTOCOL_REGEX);
|
|
12
|
+
const LOOSE_URL_WEBSITE_REGEX = `${URL_PROTOCOL_REGEX}((?!-)[-a-z0-9]+(?<!-)(?:\\.(?!-)[-a-z0-9]+(?<!-))*)(?:\\:${ALLOWED_PORTS}|\\b|(?=_))`;
|
|
13
|
+
const LOOSE_URL_REGEX = `((${LOOSE_URL_WEBSITE_REGEX})${URL_PATH_REGEX}(?:${URL_PARAM_REGEX}|${URL_FRAGMENT_REGEX})*)`;
|
|
14
|
+
const MARKDOWN_URL_REGEX = `(${LOOSE_URL_REGEX}|${URL_REGEX})`;
|
|
15
|
+
export { URL_WEBSITE_REGEX, URL_PATH_REGEX, URL_PARAM_REGEX, URL_FRAGMENT_REGEX, URL_REGEX, URL_REGEX_WITH_REQUIRED_PROTOCOL, URL_PROTOCOL_REGEX, LOOSE_URL_REGEX, LOOSE_URL_WEBSITE_REGEX, MARKDOWN_URL_REGEX, };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default CopyText;
|
|
2
|
+
/**
|
|
3
|
+
* Simple render prop component that encapsulates the Clipboard feature and exposes a function that can be tied to any event
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* <React.c.CopyText textContent="I am some text" onSuccess={() => {}}>
|
|
8
|
+
* {copy => (
|
|
9
|
+
* <React.c.Button onClick={copy}>
|
|
10
|
+
* Copy Me!
|
|
11
|
+
* </React.c.Button>
|
|
12
|
+
* )}
|
|
13
|
+
* </React.c.CopyText>
|
|
14
|
+
*/
|
|
15
|
+
declare class CopyText extends React.Component<any, any, any> {
|
|
16
|
+
constructor(props: any);
|
|
17
|
+
constructor(props: any, context: any);
|
|
18
|
+
componentDidMount(): void;
|
|
19
|
+
hiddenLink: HTMLAnchorElement | undefined;
|
|
20
|
+
clipboard: Clipboard | undefined;
|
|
21
|
+
componentWillUnmount(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Fires click event on invisible link
|
|
24
|
+
*/
|
|
25
|
+
copyTextToClipboard(): void;
|
|
26
|
+
render(): any;
|
|
27
|
+
}
|
|
28
|
+
declare namespace CopyText {
|
|
29
|
+
export { propTypes };
|
|
30
|
+
export { defaultProps };
|
|
31
|
+
}
|
|
32
|
+
import React from 'react';
|
|
33
|
+
import Clipboard from 'clipboard';
|
|
34
|
+
declare namespace propTypes {
|
|
35
|
+
let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
|
+
let textContent: PropTypes.Requireable<string>;
|
|
37
|
+
let children: PropTypes.Validator<(...args: any[]) => any>;
|
|
38
|
+
}
|
|
39
|
+
declare namespace defaultProps {
|
|
40
|
+
export function onSuccess_1(): void;
|
|
41
|
+
export { onSuccess_1 as onSuccess };
|
|
42
|
+
let textContent_1: string;
|
|
43
|
+
export { textContent_1 as textContent };
|
|
44
|
+
}
|
|
45
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Clipboard from 'clipboard';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
const propTypes = {
|
|
5
|
+
// Callback fired when text has been copied - useful to display UI confirmation
|
|
6
|
+
onSuccess: PropTypes.func,
|
|
7
|
+
// The text to be copied
|
|
8
|
+
textContent: PropTypes.string,
|
|
9
|
+
// Function as a child exposes the copyTextToClipboard fuction
|
|
10
|
+
children: PropTypes.func.isRequired,
|
|
11
|
+
};
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
onSuccess: () => { },
|
|
14
|
+
textContent: '',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Simple render prop component that encapsulates the Clipboard feature and exposes a function that can be tied to any event
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* <React.c.CopyText textContent="I am some text" onSuccess={() => {}}>
|
|
22
|
+
* {copy => (
|
|
23
|
+
* <React.c.Button onClick={copy}>
|
|
24
|
+
* Copy Me!
|
|
25
|
+
* </React.c.Button>
|
|
26
|
+
* )}
|
|
27
|
+
* </React.c.CopyText>
|
|
28
|
+
*/
|
|
29
|
+
class CopyText extends React.Component {
|
|
30
|
+
componentDidMount() {
|
|
31
|
+
this.hiddenLink = document.createElement('a');
|
|
32
|
+
// Sets up the clipboard instance
|
|
33
|
+
this.clipboard = new Clipboard(this.hiddenLink, {
|
|
34
|
+
text: () => this.props.textContent,
|
|
35
|
+
});
|
|
36
|
+
// Fires callback when the clipboard has succesfully copied
|
|
37
|
+
this.clipboard.on('success', () => {
|
|
38
|
+
this.props.onSuccess();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
this.clipboard.destroy();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fires click event on invisible link
|
|
46
|
+
*/
|
|
47
|
+
copyTextToClipboard() {
|
|
48
|
+
this.hiddenLink.click();
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
return this.props.children(() => this.copyTextToClipboard());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
CopyText.propTypes = propTypes;
|
|
55
|
+
CopyText.defaultProps = defaultProps;
|
|
56
|
+
export default CopyText;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default StepProgressBar;
|
|
2
|
+
/**
|
|
3
|
+
* Step progress bar.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} props Component props
|
|
6
|
+
* @param {array} props.steps Array of {id, title}
|
|
7
|
+
* @param {string} props.currentStep Current step id
|
|
8
|
+
*
|
|
9
|
+
* @returns {React.Component}
|
|
10
|
+
*/
|
|
11
|
+
declare function StepProgressBar({ steps, currentStep }: {
|
|
12
|
+
steps: array;
|
|
13
|
+
currentStep: string;
|
|
14
|
+
}): React.Component;
|
|
15
|
+
declare namespace StepProgressBar {
|
|
16
|
+
export { propTypes };
|
|
17
|
+
}
|
|
18
|
+
import React from 'react';
|
|
19
|
+
declare namespace propTypes {
|
|
20
|
+
let steps: PropTypes.Validator<(PropTypes.InferProps<{
|
|
21
|
+
id: PropTypes.Validator<string>;
|
|
22
|
+
title: PropTypes.Validator<string>;
|
|
23
|
+
}> | null | undefined)[]>;
|
|
24
|
+
let currentStep: PropTypes.Validator<string>;
|
|
25
|
+
}
|
|
26
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import * as UIConstants from '../CONST';
|
|
5
|
+
const stepShape = {
|
|
6
|
+
id: PropTypes.string.isRequired,
|
|
7
|
+
title: PropTypes.string.isRequired,
|
|
8
|
+
};
|
|
9
|
+
const propTypes = {
|
|
10
|
+
steps: PropTypes.arrayOf(PropTypes.shape(stepShape)).isRequired,
|
|
11
|
+
currentStep: PropTypes.string.isRequired,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Step progress bar.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} props Component props
|
|
17
|
+
* @param {array} props.steps Array of {id, title}
|
|
18
|
+
* @param {string} props.currentStep Current step id
|
|
19
|
+
*
|
|
20
|
+
* @returns {React.Component}
|
|
21
|
+
*/
|
|
22
|
+
function StepProgressBar({ steps, currentStep }) {
|
|
23
|
+
const isCurrentStep = (step) => step.id === currentStep;
|
|
24
|
+
const currentStepIndex = Math.max(0, steps.findIndex(isCurrentStep));
|
|
25
|
+
const renderStep = (step, i) => {
|
|
26
|
+
let status = currentStepIndex === i ? UIConstants.UI.ACTIVE : '';
|
|
27
|
+
if (currentStepIndex > i) {
|
|
28
|
+
status = 'complete';
|
|
29
|
+
}
|
|
30
|
+
return (React.createElement("div", { key: step.id, className: cn('progress-step', 'js_step', step.id, status) },
|
|
31
|
+
React.createElement("div", { className: "progress-dot" },
|
|
32
|
+
React.createElement("div", { className: "inner" })),
|
|
33
|
+
React.createElement("div", { className: "progress-desc" },
|
|
34
|
+
React.createElement("span", { className: "js_step_title" }, step.title))));
|
|
35
|
+
};
|
|
36
|
+
return (React.createElement("div", { id: "js_steps_progress", className: "progress-wrapper" },
|
|
37
|
+
React.createElement("div", { className: "progress" }, steps.map(renderStep))));
|
|
38
|
+
}
|
|
39
|
+
StepProgressBar.propTypes = propTypes;
|
|
40
|
+
export default StepProgressBar;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
export default Combobox;
|
|
2
|
+
/**
|
|
3
|
+
* A combobox useful for searching for values in a large list
|
|
4
|
+
*/
|
|
5
|
+
declare class Combobox extends React.Component<any, any, any> {
|
|
6
|
+
constructor(props: any);
|
|
7
|
+
/**
|
|
8
|
+
* @param {Boolean} noDefaultValue Overrides the default value to have '' as the currentValue
|
|
9
|
+
* @param {Object[]} [newOptions] when resetting this component, we can specify new options to use
|
|
10
|
+
* @param {Object[]} [newAlreadySelectedOptions] when resetting this component, we can specify new already selected options to use
|
|
11
|
+
*
|
|
12
|
+
* @returns {Object}
|
|
13
|
+
*/
|
|
14
|
+
getStartState(noDefaultValue: boolean, newOptions?: Object[], newAlreadySelectedOptions?: Object[]): Object;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a set of our full options according to the maxItemsToShow
|
|
17
|
+
*
|
|
18
|
+
* @param {String|Number} currentValue
|
|
19
|
+
* @param {Object[]} [newAlreadySelectedOptions]
|
|
20
|
+
* @returns {Array}
|
|
21
|
+
*/
|
|
22
|
+
getTruncatedOptions(currentValue: string | number, newAlreadySelectedOptions?: Object[]): any[];
|
|
23
|
+
/**
|
|
24
|
+
* Returns the selected value(s)
|
|
25
|
+
*
|
|
26
|
+
* @returns {String}
|
|
27
|
+
*/
|
|
28
|
+
getValue(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the current value
|
|
31
|
+
*
|
|
32
|
+
* @param {String} val
|
|
33
|
+
*/
|
|
34
|
+
setValue(val: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Hard sets the current text to what we want
|
|
37
|
+
*
|
|
38
|
+
* @param {String} val
|
|
39
|
+
*/
|
|
40
|
+
setText(val: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the disabled state of this component
|
|
43
|
+
*
|
|
44
|
+
* @param {Boolean} isDisabled
|
|
45
|
+
*/
|
|
46
|
+
setDisabled(isDisabled: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Set an error for a specific tag
|
|
49
|
+
*/
|
|
50
|
+
setError(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Deselects any current option if it exists
|
|
53
|
+
*/
|
|
54
|
+
deselectCurrentOption(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Swaps the focused index from {oldFocusedIndex} to {newFocusedIndex}
|
|
57
|
+
*
|
|
58
|
+
* @param {number} oldFocusedIndex
|
|
59
|
+
* @param {number} newFocusedIndex
|
|
60
|
+
*/
|
|
61
|
+
switchFocusedIndex(oldFocusedIndex: number, newFocusedIndex: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the selector to it's original state
|
|
64
|
+
*
|
|
65
|
+
* @param {Boolean} noDefaultValue Overrides the initials state defaultValue by setting the currentValue to ''
|
|
66
|
+
* @param {Object[]} [newOptions] we can recreate it with new options
|
|
67
|
+
* @param {Object[]} [newAlreadySelectedOptions] we can recreate it with new already selected options
|
|
68
|
+
*/
|
|
69
|
+
reset(noDefaultValue: boolean, newOptions?: Object[], newAlreadySelectedOptions?: Object[]): void;
|
|
70
|
+
/**
|
|
71
|
+
* When the dropdown is closed, we reset the focused property of all of our options
|
|
72
|
+
*/
|
|
73
|
+
resetFocusedElements(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Fired when we "click away" with the dropdown open
|
|
76
|
+
*
|
|
77
|
+
* @param {SyntheticEvent} e
|
|
78
|
+
*/
|
|
79
|
+
handleClickAway(e: SyntheticEvent): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets a clicklistener to close the dropdown if it is currently open
|
|
82
|
+
*/
|
|
83
|
+
resetClickAwayHandler(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Clear an error for a specific tag
|
|
86
|
+
*/
|
|
87
|
+
clearError(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Opens or closes the dropdown
|
|
90
|
+
*/
|
|
91
|
+
toggleDropdown(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Just open the dropdown (when the input gets focus)
|
|
94
|
+
*/
|
|
95
|
+
openDropdown(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Closes the dropdown and removes the click handler that calls this function after the dropdown is closed
|
|
98
|
+
*
|
|
99
|
+
* @param {SyntheticEvent} [e]
|
|
100
|
+
*/
|
|
101
|
+
closeDropdown(e?: SyntheticEvent): void;
|
|
102
|
+
/**
|
|
103
|
+
* If the user presses tab when the dropdown button is focused, then we close the dropdown
|
|
104
|
+
* because they are trying to get to the next form components
|
|
105
|
+
*
|
|
106
|
+
* @param {SyntheticEvent} e
|
|
107
|
+
*/
|
|
108
|
+
closeDropdownOnTabOut(e: SyntheticEvent): void;
|
|
109
|
+
/**
|
|
110
|
+
* This is triggered whenever there is a key up event in the text input
|
|
111
|
+
*
|
|
112
|
+
* @param {SyntheticEvent} e
|
|
113
|
+
*/
|
|
114
|
+
handleKeyDown(e: SyntheticEvent): void;
|
|
115
|
+
/**
|
|
116
|
+
* This is triggered whenever there is a change event in the text input
|
|
117
|
+
* (from any valid input that's not being handled from the keyUp event)
|
|
118
|
+
*
|
|
119
|
+
* @param {SyntheticEvent} e
|
|
120
|
+
*/
|
|
121
|
+
performSearch(e: SyntheticEvent): void;
|
|
122
|
+
/**
|
|
123
|
+
* Handle state changes for when a user clicks on an item in the dropdown
|
|
124
|
+
*
|
|
125
|
+
* @param {String|Number} selectedValue
|
|
126
|
+
*/
|
|
127
|
+
handleClick(selectedValue: string | number): void;
|
|
128
|
+
state: Object;
|
|
129
|
+
scrollPosition: number;
|
|
130
|
+
componentDidMount(): void;
|
|
131
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
132
|
+
componentDidUpdate(): void;
|
|
133
|
+
componentWillUnmount(): void;
|
|
134
|
+
initialValue: any;
|
|
135
|
+
options: any;
|
|
136
|
+
initialText: any;
|
|
137
|
+
render(): React.JSX.Element | null;
|
|
138
|
+
value: HTMLInputElement | null | undefined;
|
|
139
|
+
dropDown: DropDown | null | undefined;
|
|
140
|
+
}
|
|
141
|
+
declare namespace Combobox {
|
|
142
|
+
export { propTypes };
|
|
143
|
+
export { defaultProps };
|
|
144
|
+
}
|
|
145
|
+
import React from 'react';
|
|
146
|
+
import DropDown from './dropdown';
|
|
147
|
+
declare namespace propTypes {
|
|
148
|
+
let options: PropTypes.Validator<(PropTypes.InferProps<{
|
|
149
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
150
|
+
text: PropTypes.Requireable<string>;
|
|
151
|
+
children: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
152
|
+
hasError: PropTypes.Requireable<boolean>;
|
|
153
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
154
|
+
id: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
155
|
+
divider: PropTypes.Requireable<boolean>;
|
|
156
|
+
selected: PropTypes.Requireable<boolean>;
|
|
157
|
+
}> | null | undefined)[]>;
|
|
158
|
+
let defaultValue: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
159
|
+
let value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
160
|
+
let alreadySelectedOptions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
161
|
+
id: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
162
|
+
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
163
|
+
text: PropTypes.Requireable<string>;
|
|
164
|
+
}> | null | undefined)[]>;
|
|
165
|
+
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
166
|
+
let onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
167
|
+
let onDropdownStateChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
168
|
+
let maxItemsToShow: PropTypes.Requireable<number>;
|
|
169
|
+
let maxSearchResults: PropTypes.Requireable<number>;
|
|
170
|
+
let propertyToDisplay: PropTypes.Requireable<string>;
|
|
171
|
+
let openOnInit: PropTypes.Requireable<boolean>;
|
|
172
|
+
let allowAnyValue: PropTypes.Requireable<boolean>;
|
|
173
|
+
let noResultsText: PropTypes.Requireable<string>;
|
|
174
|
+
let isReadOnly: PropTypes.Requireable<boolean>;
|
|
175
|
+
let placeholder: PropTypes.Requireable<string>;
|
|
176
|
+
let extraClasses: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
177
|
+
let hideUntilManuallyOpened: PropTypes.Requireable<boolean>;
|
|
178
|
+
let alwaysShowSelectedOnTop: PropTypes.Requireable<boolean>;
|
|
179
|
+
let hasInitialError: PropTypes.Requireable<boolean>;
|
|
180
|
+
let bs4: PropTypes.Requireable<boolean>;
|
|
181
|
+
let showDisabledOptionsInResults: PropTypes.Requireable<boolean>;
|
|
182
|
+
let autoScrollToTop: PropTypes.Requireable<boolean>;
|
|
183
|
+
let dropDownClasses: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
184
|
+
}
|
|
185
|
+
declare namespace defaultProps {
|
|
186
|
+
let defaultValue_1: string;
|
|
187
|
+
export { defaultValue_1 as defaultValue };
|
|
188
|
+
let value_1: string;
|
|
189
|
+
export { value_1 as value };
|
|
190
|
+
export function onChange_1(): void;
|
|
191
|
+
export { onChange_1 as onChange };
|
|
192
|
+
export function onClear_1(): void;
|
|
193
|
+
export { onClear_1 as onClear };
|
|
194
|
+
export function onDropdownStateChange_1(): void;
|
|
195
|
+
export { onDropdownStateChange_1 as onDropdownStateChange };
|
|
196
|
+
let maxItemsToShow_1: number;
|
|
197
|
+
export { maxItemsToShow_1 as maxItemsToShow };
|
|
198
|
+
let maxSearchResults_1: number;
|
|
199
|
+
export { maxSearchResults_1 as maxSearchResults };
|
|
200
|
+
let propertyToDisplay_1: string;
|
|
201
|
+
export { propertyToDisplay_1 as propertyToDisplay };
|
|
202
|
+
let allowAnyValue_1: boolean;
|
|
203
|
+
export { allowAnyValue_1 as allowAnyValue };
|
|
204
|
+
let openOnInit_1: boolean;
|
|
205
|
+
export { openOnInit_1 as openOnInit };
|
|
206
|
+
let isReadOnly_1: boolean;
|
|
207
|
+
export { isReadOnly_1 as isReadOnly };
|
|
208
|
+
let alreadySelectedOptions_1: never[];
|
|
209
|
+
export { alreadySelectedOptions_1 as alreadySelectedOptions };
|
|
210
|
+
let noResultsText_1: string;
|
|
211
|
+
export { noResultsText_1 as noResultsText };
|
|
212
|
+
let placeholder_1: string;
|
|
213
|
+
export { placeholder_1 as placeholder };
|
|
214
|
+
let extraClasses_1: never[];
|
|
215
|
+
export { extraClasses_1 as extraClasses };
|
|
216
|
+
let hideUntilManuallyOpened_1: boolean;
|
|
217
|
+
export { hideUntilManuallyOpened_1 as hideUntilManuallyOpened };
|
|
218
|
+
let alwaysShowSelectedOnTop_1: boolean;
|
|
219
|
+
export { alwaysShowSelectedOnTop_1 as alwaysShowSelectedOnTop };
|
|
220
|
+
let hasInitialError_1: boolean;
|
|
221
|
+
export { hasInitialError_1 as hasInitialError };
|
|
222
|
+
let bs4_1: boolean;
|
|
223
|
+
export { bs4_1 as bs4 };
|
|
224
|
+
let showDisabledOptionsInResults_1: boolean;
|
|
225
|
+
export { showDisabledOptionsInResults_1 as showDisabledOptionsInResults };
|
|
226
|
+
let autoScrollToTop_1: boolean;
|
|
227
|
+
export { autoScrollToTop_1 as autoScrollToTop };
|
|
228
|
+
let dropDownClasses_1: never[];
|
|
229
|
+
export { dropDownClasses_1 as dropDownClasses };
|
|
230
|
+
}
|
|
231
|
+
import PropTypes from 'prop-types';
|