carbon-react 91.2.1 → 93.0.2
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/dialog/dialog.style.js +10 -2
- package/lib/components/dialog-full-screen/content.style.js +45 -0
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +19 -2
- 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 +3 -3
- package/lib/components/duelling-picklist/picklist-group/picklist-group.style.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/form/form.component.js +15 -51
- package/lib/components/form/form.d.ts +2 -0
- package/lib/components/form/form.style.js +40 -15
- 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,326 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
9
|
-
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Global configuration for all service classes.
|
|
22
|
-
*/
|
|
23
|
-
const config = {
|
|
24
|
-
csrfToken: null,
|
|
25
|
-
// defines the CSRF token if required by your web application
|
|
26
|
-
onSuccess: null,
|
|
27
|
-
// defines a callback to trigger on every successful response
|
|
28
|
-
onError: null // defines a callback to trigger on every erroneous response
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let Service = /*#__PURE__*/function () {
|
|
33
|
-
/**
|
|
34
|
-
* @constructor
|
|
35
|
-
*/
|
|
36
|
-
function Service(opts = {}) {
|
|
37
|
-
_classCallCheck(this, Service);
|
|
38
|
-
|
|
39
|
-
this.handleSuccess = this.handleSuccess.bind(this);
|
|
40
|
-
this.handleError = this.handleError.bind(this);
|
|
41
|
-
this.setURL = this.setURL.bind(this);
|
|
42
|
-
this.setTransformResponse = this.setTransformResponse.bind(this);
|
|
43
|
-
this.setTransformRequest = this.setTransformRequest.bind(this);
|
|
44
|
-
this.enableGlobalCallbacks = this.enableGlobalCallbacks.bind(this);
|
|
45
|
-
this.disableGlobalCallbacks = this.disableGlobalCallbacks.bind(this);
|
|
46
|
-
this.get = this.get.bind(this);
|
|
47
|
-
this.post = this.post.bind(this);
|
|
48
|
-
this.put = this.put.bind(this);
|
|
49
|
-
this.delete = this.delete.bind(this);
|
|
50
|
-
this.handleResponse = this.handleResponse.bind(this);
|
|
51
|
-
this.responseTransform = this.responseTransform.bind(this);
|
|
52
|
-
this.shouldTriggerCallback = this.shouldTriggerCallback.bind(this); // sets up the axios client with default options
|
|
53
|
-
|
|
54
|
-
this.client = _axios.default.create({
|
|
55
|
-
headers: {
|
|
56
|
-
"X-CSRF-Token": config.csrfToken,
|
|
57
|
-
Accept: "application/json",
|
|
58
|
-
"Content-Type": "application/json"
|
|
59
|
-
},
|
|
60
|
-
transformResponse: [this.responseTransform]
|
|
61
|
-
}); // applies the default axios interceptors used for manipulating the data
|
|
62
|
-
|
|
63
|
-
this.client.interceptors.response.use(this.handleSuccess, this.handleError); // turns any configured global callbacks on by default
|
|
64
|
-
|
|
65
|
-
if (opts.globalCallbacks !== false) {
|
|
66
|
-
this.enableGlobalCallbacks();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Is called after a successful response from the server, and determines how
|
|
71
|
-
* to handle the response.
|
|
72
|
-
*
|
|
73
|
-
* @method handleSuccess
|
|
74
|
-
* @param {Object} response - the reponse from the server
|
|
75
|
-
* @return {Object} the response data
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_createClass(Service, [{
|
|
80
|
-
key: "handleSuccess",
|
|
81
|
-
value: function handleSuccess(response) {
|
|
82
|
-
if (response.data && response.data.status === "error") {
|
|
83
|
-
if (this.shouldTriggerCallback(config.onError)) {
|
|
84
|
-
config.onError(response.data);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return Promise.reject(response);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (this.shouldTriggerCallback(config.onSuccess)) {
|
|
91
|
-
config.onSuccess(response.data);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return response.data;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Is called after an erroneous response from the server.
|
|
98
|
-
*
|
|
99
|
-
* @method handleError
|
|
100
|
-
* @param {Object} error - the response from the server
|
|
101
|
-
* @return {Object}
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
key: "handleError",
|
|
106
|
-
value: function handleError(error) {
|
|
107
|
-
if (this.shouldTriggerCallback(config.onError)) {
|
|
108
|
-
config.onError(error.response.data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return Promise.reject(error.response);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Sets the base URL for axios to use for all requests using this class.
|
|
115
|
-
*
|
|
116
|
-
* @method setURL
|
|
117
|
-
* @param {String} url
|
|
118
|
-
* @return {Void}
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
}, {
|
|
122
|
-
key: "setURL",
|
|
123
|
-
value: function setURL(url) {
|
|
124
|
-
this.client.defaults.baseURL = url;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Sets a function to run before a request is made, allowing manipulation of the data.
|
|
128
|
-
*
|
|
129
|
-
* @method setTransformRequest
|
|
130
|
-
* @param {Function} func
|
|
131
|
-
* @return {Void}
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
}, {
|
|
135
|
-
key: "setTransformRequest",
|
|
136
|
-
value: function setTransformRequest(func) {
|
|
137
|
-
this.client.interceptors.request.use(request => {
|
|
138
|
-
request.data = func(request.data);
|
|
139
|
-
return request;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Sets a function to run before a response is received, allowing manipulation of the data.
|
|
144
|
-
*
|
|
145
|
-
* @method setTransformResponse
|
|
146
|
-
* @param {Function} func
|
|
147
|
-
* @return {Void}
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
}, {
|
|
151
|
-
key: "setTransformResponse",
|
|
152
|
-
value: function setTransformResponse(func) {
|
|
153
|
-
this.client.interceptors.response.use(func);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Enables global callbacks (eg onSuccess and onError).
|
|
157
|
-
*
|
|
158
|
-
* @method enableGlobalCallbacks
|
|
159
|
-
* @return {Void}
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
}, {
|
|
163
|
-
key: "enableGlobalCallbacks",
|
|
164
|
-
value: function enableGlobalCallbacks() {
|
|
165
|
-
this.globalCallbacks = true;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Disables global callbacks (eg onSuccess and onError).
|
|
169
|
-
*
|
|
170
|
-
* @method disableGlobalCallbacks
|
|
171
|
-
* @return {Void}
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
|
-
}, {
|
|
175
|
-
key: "disableGlobalCallbacks",
|
|
176
|
-
value: function disableGlobalCallbacks() {
|
|
177
|
-
this.globalCallbacks = false;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Performs a GET request to the server.
|
|
181
|
-
*
|
|
182
|
-
* @method get
|
|
183
|
-
* @param {Number} id - the ID of the resource.
|
|
184
|
-
* @param {Object} options - an object with options for query params and success/error callbacks
|
|
185
|
-
* @return {Void}
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
}, {
|
|
189
|
-
key: "get",
|
|
190
|
-
value: function get(id, options) {
|
|
191
|
-
const {
|
|
192
|
-
onSuccess,
|
|
193
|
-
onError,
|
|
194
|
-
...params
|
|
195
|
-
} = options;
|
|
196
|
-
const request = this.client.get(String(id), params);
|
|
197
|
-
request.then(this.handleResponse.bind(this, onSuccess), this.handleResponse.bind(this, onError));
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Performs a POST request to the server.
|
|
201
|
-
*
|
|
202
|
-
* @method post
|
|
203
|
-
* @param {Object} data - the data to post to the server.
|
|
204
|
-
* @param {Object} options - an object with options for query params and success/error callbacks
|
|
205
|
-
* @return {Void}
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
}, {
|
|
209
|
-
key: "post",
|
|
210
|
-
value: function post(data, options) {
|
|
211
|
-
const {
|
|
212
|
-
onSuccess,
|
|
213
|
-
onError,
|
|
214
|
-
...params
|
|
215
|
-
} = options;
|
|
216
|
-
const request = this.client.post("", data, params);
|
|
217
|
-
request.then(this.handleResponse.bind(this, onSuccess), this.handleResponse.bind(this, onError));
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Performs a PUT request to the server.
|
|
221
|
-
*
|
|
222
|
-
* @method put
|
|
223
|
-
* @param {Number} id - the ID of the resource.
|
|
224
|
-
* @param {Object} data - the data to post to the server.
|
|
225
|
-
* @param {Object} options - an object with options for query params and success/error callbacks
|
|
226
|
-
* @return {Void}
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
}, {
|
|
230
|
-
key: "put",
|
|
231
|
-
value: function put(id, data, options) {
|
|
232
|
-
const {
|
|
233
|
-
onSuccess,
|
|
234
|
-
onError,
|
|
235
|
-
...params
|
|
236
|
-
} = options;
|
|
237
|
-
const request = this.client.put(String(id), data, params);
|
|
238
|
-
request.then(this.handleResponse.bind(this, onSuccess), this.handleResponse.bind(this, onError));
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Performs a DEL request to the server.
|
|
242
|
-
*
|
|
243
|
-
* @method delete
|
|
244
|
-
* @param {Number} id - the ID of the resource.
|
|
245
|
-
* @param {Object} options - an object with options for query params and success/error callbacks
|
|
246
|
-
* @return {Void}
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
|
-
}, {
|
|
250
|
-
key: "delete",
|
|
251
|
-
value: function _delete(id, options) {
|
|
252
|
-
const {
|
|
253
|
-
onSuccess,
|
|
254
|
-
onError,
|
|
255
|
-
...params
|
|
256
|
-
} = options;
|
|
257
|
-
const request = this.client.delete(String(id), params);
|
|
258
|
-
request.then(this.handleResponse.bind(this, onSuccess), this.handleResponse.bind(this, onError));
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Handles all responses from the axios promise.
|
|
262
|
-
*
|
|
263
|
-
* @method handleResponse
|
|
264
|
-
* @param {Function} callback
|
|
265
|
-
* @param {Object} response
|
|
266
|
-
* @return {Void}
|
|
267
|
-
*/
|
|
268
|
-
|
|
269
|
-
}, {
|
|
270
|
-
key: "handleResponse",
|
|
271
|
-
value: function handleResponse(callback, response) {
|
|
272
|
-
if (callback) {
|
|
273
|
-
callback(response);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* A default response transformer, to convert the data into something useful for devs.
|
|
278
|
-
*
|
|
279
|
-
* @method responseTransform
|
|
280
|
-
* @param {Object}
|
|
281
|
-
* @return {Void}
|
|
282
|
-
*/
|
|
283
|
-
|
|
284
|
-
}, {
|
|
285
|
-
key: "responseTransform",
|
|
286
|
-
value: function responseTransform(response) {
|
|
287
|
-
if (!response) {
|
|
288
|
-
return undefined;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return JSON.parse(response);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Determines if a callback should be triggered.
|
|
295
|
-
*
|
|
296
|
-
* @method shouldTriggerCallback
|
|
297
|
-
* @param {Function}
|
|
298
|
-
* @return {Boolean}
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
}, {
|
|
302
|
-
key: "shouldTriggerCallback",
|
|
303
|
-
value: function shouldTriggerCallback(method) {
|
|
304
|
-
return this.globalCallbacks && method;
|
|
305
|
-
}
|
|
306
|
-
}], [{
|
|
307
|
-
key: "configure",
|
|
308
|
-
value:
|
|
309
|
-
/**
|
|
310
|
-
* Allows the global config data to be set for your application.
|
|
311
|
-
* eg. Service.configure({ csrfToken: global.CSRF_TOKEN });
|
|
312
|
-
*
|
|
313
|
-
* @method configure
|
|
314
|
-
* @param {Object} opts - see config object above
|
|
315
|
-
* @return {Void}
|
|
316
|
-
*/
|
|
317
|
-
function configure(opts) {
|
|
318
|
-
(0, _lodash.assign)(config, config, opts);
|
|
319
|
-
}
|
|
320
|
-
}]);
|
|
321
|
-
|
|
322
|
-
return Service;
|
|
323
|
-
}();
|
|
324
|
-
|
|
325
|
-
var _default = Service;
|
|
326
|
-
exports.default = _default;
|