carbon-react 92.0.0 → 93.0.0
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/lib/__internal__/checkable-input/checkable-input.component.js +1 -1
- package/lib/{utils/helpers → __internal__}/date/date.d.ts +0 -0
- package/lib/{utils/helpers → __internal__}/date/date.js +0 -0
- package/lib/{utils/helpers → __internal__}/date/index.js +0 -0
- package/lib/{utils/helpers → __internal__}/filter-object-properties/filter-object-properties.js +0 -0
- package/lib/{utils/helpers → __internal__}/filter-object-properties/index.js +0 -0
- package/lib/__internal__/form-field/form-field.component.js +1 -1
- package/lib/__internal__/full-screen-heading/full-screen-heading.component.js +1 -1
- package/lib/{utils/helpers → __internal__/input}/extract-props/extract-props.js +0 -0
- package/lib/{utils/helpers → __internal__/input}/extract-props/index.js +0 -0
- package/lib/__internal__/utils/ether/ether.js +33 -0
- package/lib/__internal__/utils/ether/index.js +18 -0
- package/lib/{utils → __internal__/utils}/helpers/browser/browser.js +0 -0
- package/lib/{utils/helpers/warn-as-deprecated → __internal__/utils/helpers/browser}/index.js +2 -2
- package/lib/{utils → __internal__/utils}/helpers/browser-type-check/browser-type-check.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/browser-type-check/index.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/events/composedPath.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/events/events.js +0 -0
- package/lib/__internal__/utils/helpers/events/index.js +15 -0
- package/lib/{utils → __internal__/utils}/helpers/guid/guid.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/guid/package.json +0 -0
- package/lib/{utils → __internal__/utils}/helpers/immutable/immutable.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/immutable/package.json +0 -0
- package/lib/__internal__/utils/helpers/tags/index.js +15 -0
- package/lib/__internal__/utils/helpers/tags/tags-specs/index.js +19 -0
- package/lib/{utils → __internal__/utils}/helpers/tags/tags-specs/tags-specs.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/tags/tags.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/with-unique-id-props/index.js +0 -0
- package/lib/{utils → __internal__/utils}/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -0
- package/lib/{utils → __internal__/utils}/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -0
- package/lib/__internal__/utils/logger/index.js +15 -0
- package/lib/{utils → __internal__/utils}/logger/logger.js +0 -9
- package/lib/__spec_helper__/mock-date-helper.js +2 -2
- package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -1
- package/lib/components/accordion/accordion.component.js +2 -2
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +1 -1
- package/lib/components/action-popover/action-popover.component.js +2 -2
- package/lib/components/action-popover/action-popover.style.js +1 -1
- package/lib/components/action-toolbar/action-toolbar.component.js +2 -2
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +1 -1
- package/lib/components/anchor-navigation/anchor-navigation.component.js +1 -1
- package/lib/components/app-wrapper/app-wrapper.component.js +2 -2
- package/lib/components/button/button.component.js +1 -1
- package/lib/components/button-toggle/button-toggle.component.js +1 -1
- package/lib/components/carousel/carousel.component.js +2 -2
- package/lib/components/carousel/slide/slide.component.js +1 -1
- package/lib/components/checkbox/checkbox-group.component.js +1 -1
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.component.js +1 -1
- package/lib/components/configurable-items/configurable-items.component.js +2 -2
- package/lib/components/confirm/confirm.component.js +1 -1
- package/lib/components/date/date-picker.component.js +1 -1
- package/lib/components/date/date.component.js +4 -4
- package/lib/components/date-range/date-range.component.js +2 -2
- package/lib/components/detail/detail.component.js +1 -1
- package/lib/components/drag-and-drop/__internal__/item-target/index.js +15 -0
- package/lib/{utils/helpers/dnd → components/drag-and-drop/__internal__}/item-target/item-target.js +0 -0
- package/lib/components/drag-and-drop/__internal__/item-types/index.js +15 -0
- package/lib/{utils/helpers/dnd → components/drag-and-drop/__internal__}/item-types/item-types.js +0 -0
- package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/index.js +15 -0
- package/lib/{utils/helpers → components/drag-and-drop/draggable-context/__internal__}/scrollable-parent/scrollable-parent.js +1 -1
- package/lib/components/drag-and-drop/draggable-context/draggable-context.js +4 -4
- package/lib/components/drag-and-drop/with-drag/with-drag.js +2 -2
- package/lib/components/drag-and-drop/with-drop/with-drop.js +11 -6
- package/lib/components/drawer/drawer.component.js +1 -1
- package/lib/components/duelling-picklist/picklist/picklist.component.js +1 -1
- package/lib/components/duelling-picklist/picklist-group/picklist-group.component.js +1 -1
- package/lib/components/duelling-picklist/picklist-item/picklist-item.component.js +1 -1
- package/lib/components/fieldset/fieldset.component.js +2 -2
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +1 -1
- package/lib/components/flat-table/sort/sort.component.js +2 -2
- package/lib/components/heading/heading.component.js +1 -1
- package/lib/components/help/help.component.js +2 -2
- package/lib/components/icon/icon.component.js +2 -2
- package/lib/components/icon/icon.style.js +1 -1
- package/lib/components/icon-button/icon-button.component.js +1 -1
- package/lib/components/inline-inputs/inline-inputs.component.js +1 -1
- package/lib/components/link/link.component.js +2 -2
- package/lib/components/loader/loader.component.js +1 -1
- package/lib/components/loader-bar/loader-bar.component.js +1 -1
- package/lib/components/menu/__internal__/keyboard-navigation/index.js +1 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -1
- package/lib/components/menu/menu-item/menu-item.component.js +1 -1
- package/lib/components/menu/menu.component.js +1 -1
- package/lib/components/menu/submenu-block/submenu-block.component.js +1 -1
- package/lib/components/message/message.component.js +1 -1
- package/lib/components/modal/modal.component.js +1 -1
- package/lib/components/mount-in-app/mount-in-app.js +1 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
- package/lib/components/multi-step-wizard/multi-step-wizard.js +1 -1
- package/lib/components/numeral-date/numeral-date.component.js +2 -2
- package/lib/components/pager/__internal__/pager-navigation.component.js +2 -2
- package/lib/components/pager/pager.component.js +1 -1
- package/lib/components/pages/page/page.component.js +1 -1
- package/lib/components/pages/pages.component.js +1 -1
- package/lib/components/pill/pill.component.js +1 -1
- package/lib/components/pod/pod.component.js +2 -2
- package/lib/components/popover-container/popover-container.component.js +1 -1
- package/lib/components/portal/portal.js +2 -2
- package/lib/components/portrait/portrait-initials.component.js +1 -1
- package/lib/components/portrait/portrait.component.js +1 -1
- package/lib/components/preview/preview.component.js +1 -1
- package/lib/components/profile/profile.component.js +9 -4
- package/lib/components/radio-button/radio-button-group.component.js +1 -1
- package/lib/components/row/column/column.component.js +1 -1
- package/lib/components/row/row.component.js +1 -1
- package/lib/components/scrollable-list/scrollable-list.component.js +3 -3
- package/lib/components/search/search.component.js +2 -2
- package/lib/components/select/filterable-select/filterable-select.component.js +1 -1
- package/lib/components/select/multi-select/multi-select.component.js +1 -1
- package/lib/components/select/simple-select/simple-select.component.js +1 -1
- package/lib/components/settings-row/settings-row.component.js +1 -1
- package/lib/components/show-edit-pod/show-edit-pod.component.js +3 -3
- package/lib/components/sidebar/__internal__/sidebar-header/sidebar-header.component.js +1 -1
- package/lib/components/simple-color-picker/simple-color/simple-color.component.js +1 -1
- package/lib/components/simple-color-picker/simple-color-picker.component.js +2 -2
- package/lib/components/split-button/split-button.component.js +2 -2
- package/lib/components/table/table-cell/table-cell.component.js +2 -2
- package/lib/components/table/table-header/table-header.component.js +1 -1
- package/lib/components/table/table-row/table-row.component.js +3 -3
- package/lib/components/table/table.component.js +1 -1
- package/lib/{utils/helpers → components/table-ajax/__internal__}/serialize/package.json +0 -0
- package/lib/{utils/helpers → components/table-ajax/__internal__}/serialize/serialize.js +0 -0
- package/lib/components/table-ajax/table-ajax.component.js +2 -2
- package/lib/components/tabs/__internal__/tab-title/tab-title.component.js +3 -3
- package/lib/components/tabs/tab/tab.component.js +1 -1
- package/lib/components/tabs/tabs.component.js +2 -2
- package/lib/components/text-editor/__internal__/toolbar/toolbar.component.js +1 -1
- package/lib/components/text-editor/text-editor.component.js +2 -2
- package/lib/components/text-editor/text-editor.style.js +1 -1
- package/lib/components/textarea/textarea.component.js +1 -1
- package/lib/components/textbox/textbox.component.js +1 -1
- package/lib/components/tile-select/tile-select-group.component.js +1 -1
- package/lib/components/tile-select/tile-select.component.js +2 -2
- package/lib/components/toast/toast.component.js +2 -2
- package/lib/components/tooltip/tooltip.component.js +1 -1
- package/lib/patterns/configurable-items/configurable-items-content/configurable-items-content.js +1 -1
- package/lib/patterns/configurable-items/configurable-items.js +1 -1
- package/lib/patterns/configurable-items/store/store.js +1 -1
- package/lib/style/utils/filter-styled-system-margin-props.js +1 -1
- package/lib/style/utils/filter-styled-system-padding-props.js +1 -1
- package/package.json +1 -2
- package/lib/utils/decorators/should-component-update/package.json +0 -4
- package/lib/utils/decorators/should-component-update/should-component-update.js +0 -104
- package/lib/utils/ether/ether.js +0 -107
- package/lib/utils/ether/package.json +0 -3
- package/lib/utils/handlers/base-registry/base-registry.js +0 -68
- package/lib/utils/handlers/base-registry/package.json +0 -3
- package/lib/utils/helpers/auto-focus/auto-focus.js +0 -22
- package/lib/utils/helpers/auto-focus/package.json +0 -3
- package/lib/utils/helpers/browser/package.json +0 -4
- package/lib/utils/helpers/chain-functions/chain-functions.js +0 -29
- package/lib/utils/helpers/chain-functions/package.json +0 -4
- package/lib/utils/helpers/dnd/item-target/package.json +0 -3
- package/lib/utils/helpers/dnd/item-types/package.json +0 -3
- package/lib/utils/helpers/events/package.json +0 -3
- package/lib/utils/helpers/poller/package.json +0 -3
- package/lib/utils/helpers/poller/poller.js +0 -181
- package/lib/utils/helpers/prop-types/package.json +0 -3
- package/lib/utils/helpers/prop-types/prop-types.js +0 -42
- package/lib/utils/helpers/scrollable-parent/package.json +0 -3
- package/lib/utils/helpers/should-component-update/package.json +0 -3
- package/lib/utils/helpers/should-component-update/should-component-update.js +0 -56
- package/lib/utils/helpers/tags/package.json +0 -3
- package/lib/utils/helpers/tags/tags-specs/package.json +0 -3
- package/lib/utils/helpers/text/package.json +0 -3
- package/lib/utils/helpers/text/text.js +0 -47
- package/lib/utils/helpers/to-array/package.json +0 -3
- package/lib/utils/helpers/to-array/to-array.js +0 -44
- package/lib/utils/helpers/validations/package.json +0 -4
- package/lib/utils/helpers/validations/validations.js +0 -27
- package/lib/utils/helpers/warn-as-deprecated/warn-as-deprecated.js +0 -23
- package/lib/utils/logger/package.json +0 -3
- package/lib/utils/service/package.json +0 -3
- package/lib/utils/service/service.js +0 -326
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Base Registry class, for building handler patterns.
|
|
14
|
-
*
|
|
15
|
-
* == How to create a handler pattern:
|
|
16
|
-
*
|
|
17
|
-
* In your file, create your own registry class which exports from the base
|
|
18
|
-
* registry class. Initialise your registry and export it.
|
|
19
|
-
*
|
|
20
|
-
* import BaseRegistry from 'carbon-react/lib/utils/handlers/base-registry';
|
|
21
|
-
*
|
|
22
|
-
* class MyRegistry extends BaseRegistry {};
|
|
23
|
-
*
|
|
24
|
-
* export default new MyRegistry;
|
|
25
|
-
*
|
|
26
|
-
* @class BaseRegistry
|
|
27
|
-
* @constructor
|
|
28
|
-
*/
|
|
29
|
-
let BaseRegistry = function BaseRegistry() {
|
|
30
|
-
_classCallCheck(this, BaseRegistry);
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "defaultHandler", {
|
|
33
|
-
call: data => {
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
_defineProperty(this, "handlers", {});
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "register", (key, handler) => {
|
|
41
|
-
this.handlers[key] = handler;
|
|
42
|
-
return handler;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
_defineProperty(this, "unregister", key => {
|
|
46
|
-
delete this.handlers[key];
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "obtain", (...params) => {
|
|
50
|
-
const handlers = [];
|
|
51
|
-
Object.keys(this.handlers).forEach(key => {
|
|
52
|
-
const handler = this.handlers[key];
|
|
53
|
-
|
|
54
|
-
if (handler.check(...params)) {
|
|
55
|
-
handlers.push(handler);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (!handlers.length) {
|
|
60
|
-
handlers.push(this.defaultHandler);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return handlers;
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var _default = BaseRegistry;
|
|
68
|
-
exports.default = _default;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _guid = _interopRequireDefault(require("../guid"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const AutoFocus = {
|
|
13
|
-
getKey: (autoFocus, previous) => {
|
|
14
|
-
if (autoFocus !== undefined && previous !== undefined && previous.autoFocus === autoFocus) {
|
|
15
|
-
return previous.key;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return (0, _guid.default)();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var _default = AutoFocus;
|
|
22
|
-
exports.default = _default;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Chain Functions
|
|
10
|
-
*
|
|
11
|
-
* Takes two functions, and return a new function which will call the two functions
|
|
12
|
-
* in order.
|
|
13
|
-
*
|
|
14
|
-
* @method chainFunctions
|
|
15
|
-
* @param {Function} newFunction function to be performed second
|
|
16
|
-
* @param {Function} originalFunction function to be performed first
|
|
17
|
-
* @return {Function} new function that called the two passed functions
|
|
18
|
-
*/
|
|
19
|
-
var _default = (newFunction, originalFunction) => {
|
|
20
|
-
return (...args) => {
|
|
21
|
-
if (originalFunction) {
|
|
22
|
-
originalFunction(...args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
newFunction(...args);
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.default = _default;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _superagent = _interopRequireDefault(require("superagent"));
|
|
9
|
-
|
|
10
|
-
var _logger = _interopRequireDefault(require("../../logger"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A helper to make poll an endpoint with a GET request
|
|
16
|
-
*
|
|
17
|
-
* The helper takes the following params
|
|
18
|
-
*
|
|
19
|
-
* - queryOptions:
|
|
20
|
-
* -- url - the url to make the GET request to
|
|
21
|
-
* -- data - any data you wish to pass with the request
|
|
22
|
-
* -- headers - any header you wish to pass with the request
|
|
23
|
-
*
|
|
24
|
-
* - functions: An object containing the custom functions
|
|
25
|
-
* -- conditionMet: Use this to test a desired condition in the response and return a boolean.
|
|
26
|
-
* If the condition is true, the callback will be executed.
|
|
27
|
-
* -- conditionNotMetCallback: Called when condition not met and poller will retry
|
|
28
|
-
* -- callback: A callback function to call when the conditionMet returns true
|
|
29
|
-
* -- handleError: a callback function that takes an error and handles it
|
|
30
|
-
* -- terminate: Use this to test a desired condition in the response and return a boolean.
|
|
31
|
-
* If the condition is true, the polling will end.
|
|
32
|
-
* -- onMaxRetries: Use this to do something when the max retries are met
|
|
33
|
-
* options:
|
|
34
|
-
* -- interval - the interval after which the request is re-submitted
|
|
35
|
-
* -- retries - number of times to re-submit the request before giving up
|
|
36
|
-
* -- endTime - a time period after which to end the polling
|
|
37
|
-
*
|
|
38
|
-
* ===Example Usage===
|
|
39
|
-
*
|
|
40
|
-
* import Poller from 'carbon-react/lib/utils/helpers/poller';
|
|
41
|
-
*
|
|
42
|
-
* let queryOptions = { url: '/foo/bar/1' }
|
|
43
|
-
* let options = { interval: 5000 };
|
|
44
|
-
* let functions = {
|
|
45
|
-
* conditionMet: function(response) => { return response.body.status === 'complete' };
|
|
46
|
-
* conditionNotMetCallback: function(response) => { notYetFunction(response) };
|
|
47
|
-
* callback: function(response) => { doSomethingFancy(reponse) };
|
|
48
|
-
* handleError: function(err) => { FlashMessage("Failed", err) };
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* Poller(queryOptions, functions);
|
|
52
|
-
*/
|
|
53
|
-
var _default = (queryOptions, functions, options) => {
|
|
54
|
-
if (!setupValid(queryOptions, functions)) {
|
|
55
|
-
return;
|
|
56
|
-
} // set default options for unprovided options
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const queryOpts = getQueryOptions(queryOptions);
|
|
60
|
-
const funcs = getFunctions(functions);
|
|
61
|
-
const opts = getOptions(options); // pollCount for use if retries option passed
|
|
62
|
-
|
|
63
|
-
let pollCount = 1;
|
|
64
|
-
|
|
65
|
-
(function poll() {
|
|
66
|
-
const now = Date.now();
|
|
67
|
-
|
|
68
|
-
if (pollCount > opts.retries || now > opts.endTime) {
|
|
69
|
-
funcs.onMaxRetries();
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
_superagent.default.get(queryOpts.url).query(queryOpts.data).set(queryOpts.headers).end((err, response) => {
|
|
74
|
-
let result;
|
|
75
|
-
|
|
76
|
-
if (err) {
|
|
77
|
-
if (funcs.handleError) {
|
|
78
|
-
result = funcs.handleError(err);
|
|
79
|
-
} else {
|
|
80
|
-
result = _logger.default.error(err.message); // eslint-disable-line no-console
|
|
81
|
-
}
|
|
82
|
-
} else if (funcs.terminate(response)) {
|
|
83
|
-
result = response;
|
|
84
|
-
} else if (funcs.conditionMet(response)) {
|
|
85
|
-
result = funcs.callback(response);
|
|
86
|
-
} else {
|
|
87
|
-
funcs.conditionNotMetCallback(response);
|
|
88
|
-
pollCount += 1;
|
|
89
|
-
setTimeout(poll, opts.interval);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return result;
|
|
93
|
-
});
|
|
94
|
-
})();
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Sets default queryOptions
|
|
98
|
-
*
|
|
99
|
-
* @method getQueryOptions
|
|
100
|
-
* @return {Object} queryOptions
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
exports.default = _default;
|
|
105
|
-
|
|
106
|
-
function getQueryOptions(queryOptions) {
|
|
107
|
-
return {
|
|
108
|
-
url: queryOptions.url,
|
|
109
|
-
data: queryOptions.data || {},
|
|
110
|
-
headers: queryOptions.headers || {}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Sets default Options for poller
|
|
115
|
-
*
|
|
116
|
-
* @method getOptions
|
|
117
|
-
* @return {Object} options
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
function getOptions(options) {
|
|
122
|
-
return {
|
|
123
|
-
interval: options.interval || 3000,
|
|
124
|
-
endTime: Date.now() + options.endTime || Infinity,
|
|
125
|
-
retries: options.retries || Infinity
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Sets default functions for poller
|
|
130
|
-
*
|
|
131
|
-
* @method getFunctions
|
|
132
|
-
* @return {Object} functions
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function getFunctions(functions) {
|
|
137
|
-
return {
|
|
138
|
-
callback: functions.callback || null,
|
|
139
|
-
handleError: functions.handleError || null,
|
|
140
|
-
conditionMet: functions.conditionMet || (() => {
|
|
141
|
-
return false;
|
|
142
|
-
}),
|
|
143
|
-
conditionNotMetCallback: functions.conditionNotMetCallback || (() => {
|
|
144
|
-
return false;
|
|
145
|
-
}),
|
|
146
|
-
terminate: functions.terminate || (() => {
|
|
147
|
-
return false;
|
|
148
|
-
}),
|
|
149
|
-
onMaxRetries: functions.onMaxRetries || (() => {
|
|
150
|
-
_logger.default.warn("The poller has made too many requests - terminating poll"); // eslint-disable-line no-console
|
|
151
|
-
|
|
152
|
-
})
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Checks that required params are present
|
|
157
|
-
*
|
|
158
|
-
* @method setupValid
|
|
159
|
-
* @return {Boolean}
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
function setupValid(queryOptions, functions) {
|
|
164
|
-
if (queryOptions === null || typeof queryOptions.url === "undefined") {
|
|
165
|
-
_logger.default.error("You must provide a url to the poller"); // eslint-disable-line no-console
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (typeof functions.conditionMet !== "undefined" && typeof functions.callback === "undefined") {
|
|
172
|
-
const msg = "You must provide a callback function if you are testing a condition with conditionMet";
|
|
173
|
-
|
|
174
|
-
_logger.default.error(msg); // eslint-disable-line no-console
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
const valueInRange = (value, min, max) => {
|
|
9
|
-
return value >= min && value <= max;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const buildErrorString = (propName, componentName, error) => {
|
|
13
|
-
return `${propName} in ${componentName} ${error}`;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const throwError = (propName, componentName, error) => {
|
|
17
|
-
return new Error(buildErrorString(propName, componentName, error));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const isTypeOfNumberOrString = value => {
|
|
21
|
-
return typeof value === "string" || typeof value === "number";
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const PropTypesHelper = {
|
|
25
|
-
inValidRange: (props, propName, componentName, min, max) => {
|
|
26
|
-
if (props[propName]) {
|
|
27
|
-
const value = props[propName];
|
|
28
|
-
|
|
29
|
-
if (isTypeOfNumberOrString(value)) {
|
|
30
|
-
if (!valueInRange(value, min, max)) {
|
|
31
|
-
return throwError(propName, componentName, `must be between ${min} and ${max}`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
return throwError(propName, componentName, "must be a String or Integer");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var _default = PropTypesHelper;
|
|
42
|
-
exports.default = _default;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
|
|
8
|
-
var _immutable = _interopRequireDefault(require("immutable"));
|
|
9
|
-
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("../../logger/logger"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A shouldComponentUpdate helper. Run this method with your instance, nextProps and nextState
|
|
18
|
-
* and it will perform a deep comparison of the properties - handling immutable objects.
|
|
19
|
-
*
|
|
20
|
-
* @method
|
|
21
|
-
* @param {Object} scope
|
|
22
|
-
* @param {Object} nextProps
|
|
23
|
-
* @param {Object} nextState
|
|
24
|
-
* @return {Boolean}
|
|
25
|
-
*/
|
|
26
|
-
let deprecatedWarnTriggered = false;
|
|
27
|
-
|
|
28
|
-
function _default(scope, nextProps, nextState) {
|
|
29
|
-
if (!deprecatedWarnTriggered) {
|
|
30
|
-
deprecatedWarnTriggered = true; // eslint-disable-next-line max-len
|
|
31
|
-
|
|
32
|
-
_logger.default.deprecate("`ShouldComponentUpdate` helper is deprecated and will soon be removed");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return !(0, _lodash.isEqualWith)(scope.props, nextProps, customCheck) || !(0, _lodash.isEqualWith)(scope.state, nextState, customCheck);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Performs a custom check of parameters from the isEqual method.
|
|
39
|
-
*
|
|
40
|
-
* @method customCheck
|
|
41
|
-
* @param current - could be any type
|
|
42
|
-
* @param next - could be any type
|
|
43
|
-
* @param {String} key
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function customCheck(current, next) {
|
|
49
|
-
// if immutable object, do custom comparison. otherwise return undefined to
|
|
50
|
-
// allow isEqual to continue as normal
|
|
51
|
-
if (_immutable.default.Iterable.isIterable(current)) {
|
|
52
|
-
return _immutable.default.is(current, next);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _browser = _interopRequireDefault(require("../browser"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Text utility methods
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
const Text = {
|
|
17
|
-
/**
|
|
18
|
-
* Clears any selected text from the current page
|
|
19
|
-
*/
|
|
20
|
-
clearSelection() {
|
|
21
|
-
const document = _browser.default.getDocument();
|
|
22
|
-
|
|
23
|
-
const window = _browser.default.getWindow();
|
|
24
|
-
|
|
25
|
-
if (document.body.createTextRange) {
|
|
26
|
-
// IE
|
|
27
|
-
const range = document.body.createTextRange();
|
|
28
|
-
range.collapse();
|
|
29
|
-
range.select();
|
|
30
|
-
} else {
|
|
31
|
-
// Chrome, Firefox, Safari, Edge
|
|
32
|
-
window.getSelection().removeAllRanges();
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Capitalises the first letter of string paramater
|
|
38
|
-
*/
|
|
39
|
-
titleCase(str) {
|
|
40
|
-
return str.replace(/\w\S*/g, txt => {
|
|
41
|
-
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
var _default = Text;
|
|
47
|
-
exports.default = _default;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Converts a string of a given format into an array.
|
|
10
|
-
*
|
|
11
|
-
* For example:
|
|
12
|
-
*
|
|
13
|
-
* "foo[bar][baz]"
|
|
14
|
-
*
|
|
15
|
-
* Will be converted to:
|
|
16
|
-
*
|
|
17
|
-
* ["foo", "bar", "baz"]
|
|
18
|
-
*
|
|
19
|
-
* @method toArray
|
|
20
|
-
* @param {String}
|
|
21
|
-
* @return {Array}
|
|
22
|
-
*/
|
|
23
|
-
function _default(str) {
|
|
24
|
-
let result = [];
|
|
25
|
-
const index = str.indexOf("[");
|
|
26
|
-
|
|
27
|
-
if (index === -1) {
|
|
28
|
-
// if there are no square brackets
|
|
29
|
-
result.push(str);
|
|
30
|
-
} else {
|
|
31
|
-
if (index > 0) {
|
|
32
|
-
// if the square bracket is not the first character, add the name at the
|
|
33
|
-
// start of the string (not in brackets)
|
|
34
|
-
const name = str.slice(0, index);
|
|
35
|
-
result.push(name);
|
|
36
|
-
} // pull out the names in brackets and add to the array
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const nestedNames = str.match(/[^[\]]+(?=])/g);
|
|
40
|
-
result = result.concat(nestedNames);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const ValidationsHelper = {
|
|
8
|
-
/**
|
|
9
|
-
* Return the comparison type depending on params
|
|
10
|
-
*
|
|
11
|
-
* @method comparisonType
|
|
12
|
-
* @param {Object} params
|
|
13
|
-
* @return {String} function type to call
|
|
14
|
-
*/
|
|
15
|
-
comparisonType: params => {
|
|
16
|
-
const is = typeof params.is !== "undefined",
|
|
17
|
-
max = typeof params.max !== "undefined",
|
|
18
|
-
min = typeof params.min !== "undefined";
|
|
19
|
-
if (is && !max && !min) return "Exact";
|
|
20
|
-
if (!is && max && !min) return "Less";
|
|
21
|
-
if (!is && min && !max) return "Greater";
|
|
22
|
-
if (!is && min && max) return "Range";
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var _default = ValidationsHelper;
|
|
27
|
-
exports.default = _default;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _logger = _interopRequireDefault(require("../../logger"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A function to display a warning in the console when a deprecated component is being used in developpment
|
|
14
|
-
*/
|
|
15
|
-
var _default = (oldName, newName) => {
|
|
16
|
-
if (process.env.NODE_ENV === "development" && oldName.length && newName.length) {
|
|
17
|
-
const warnMessage = `${oldName} is marked as deprecated, it will soon be moved to "carbon-graveyard" and be replaced by ${newName}`;
|
|
18
|
-
|
|
19
|
-
_logger.default.deprecate(warnMessage);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.default = _default;
|