tp-react-elements-dev 1.14.13 → 1.15.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.
Files changed (70) hide show
  1. package/dist/_virtual/index.esm12.js +2 -2
  2. package/dist/_virtual/index.esm14.js +2 -2
  3. package/dist/_virtual/index.esm4.js +2 -2
  4. package/dist/_virtual/index.esm5.js +2 -2
  5. package/dist/_virtual/index.esm6.js +2 -2
  6. package/dist/_virtual/index.esm7.js +2 -2
  7. package/dist/components/Form/FormConstants.esm.js +6 -0
  8. package/dist/components/Form/FormRender.esm.js +3 -0
  9. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.esm.js +1 -1
  10. package/dist/components/FormComponents/Select/SingleSelectSearchApi.d.ts +6 -2
  11. package/dist/components/FormComponents/Select/SingleSelectSearchApi.esm.js +82 -199
  12. package/dist/components/FormComponents/index.esm.js +2 -2
  13. package/dist/node_modules/axios/index.esm.js +25 -0
  14. package/dist/node_modules/axios/lib/adapters/adapters.esm.js +128 -0
  15. package/dist/node_modules/axios/lib/adapters/fetch.esm.js +288 -0
  16. package/dist/node_modules/axios/lib/adapters/xhr.esm.js +202 -0
  17. package/dist/node_modules/axios/lib/axios.esm.js +86 -0
  18. package/dist/node_modules/axios/lib/cancel/CancelToken.esm.js +133 -0
  19. package/dist/node_modules/axios/lib/cancel/CanceledError.esm.js +23 -0
  20. package/dist/node_modules/axios/lib/cancel/isCancel.esm.js +5 -0
  21. package/dist/node_modules/axios/lib/core/Axios.esm.js +236 -0
  22. package/dist/node_modules/axios/lib/core/AxiosError.esm.js +108 -0
  23. package/dist/node_modules/axios/lib/core/AxiosHeaders.esm.js +312 -0
  24. package/dist/node_modules/axios/lib/core/InterceptorManager.esm.js +69 -0
  25. package/dist/node_modules/axios/lib/core/buildFullPath.esm.js +22 -0
  26. package/dist/node_modules/axios/lib/core/dispatchRequest.esm.js +81 -0
  27. package/dist/node_modules/axios/lib/core/mergeConfig.esm.js +106 -0
  28. package/dist/node_modules/axios/lib/core/settle.esm.js +27 -0
  29. package/dist/node_modules/axios/lib/core/transformData.esm.js +28 -0
  30. package/dist/node_modules/axios/lib/defaults/index.esm.js +159 -0
  31. package/dist/node_modules/axios/lib/defaults/transitional.esm.js +7 -0
  32. package/dist/node_modules/axios/lib/env/data.esm.js +3 -0
  33. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.esm.js +56 -0
  34. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.esm.js +77 -0
  35. package/dist/node_modules/axios/lib/helpers/bind.esm.js +14 -0
  36. package/dist/node_modules/axios/lib/helpers/buildURL.esm.js +67 -0
  37. package/dist/node_modules/axios/lib/helpers/combineURLs.esm.js +15 -0
  38. package/dist/node_modules/axios/lib/helpers/composeSignals.esm.js +48 -0
  39. package/dist/node_modules/axios/lib/helpers/cookies.esm.js +54 -0
  40. package/dist/node_modules/axios/lib/helpers/formDataToJSON.esm.js +93 -0
  41. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.esm.js +15 -0
  42. package/dist/node_modules/axios/lib/helpers/isAxiosError.esm.js +14 -0
  43. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.esm.js +16 -0
  44. package/dist/node_modules/axios/lib/helpers/null.esm.js +4 -0
  45. package/dist/node_modules/axios/lib/helpers/parseHeaders.esm.js +55 -0
  46. package/dist/node_modules/axios/lib/helpers/parseProtocol.esm.js +6 -0
  47. package/dist/node_modules/axios/lib/helpers/progressEventReducer.esm.js +46 -0
  48. package/dist/node_modules/axios/lib/helpers/resolveConfig.esm.js +62 -0
  49. package/dist/node_modules/axios/lib/helpers/speedometer.esm.js +53 -0
  50. package/dist/node_modules/axios/lib/helpers/spread.esm.js +28 -0
  51. package/dist/node_modules/axios/lib/helpers/throttle.esm.js +44 -0
  52. package/dist/node_modules/axios/lib/helpers/toFormData.esm.js +219 -0
  53. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.esm.js +19 -0
  54. package/dist/node_modules/axios/lib/helpers/trackStream.esm.js +88 -0
  55. package/dist/node_modules/axios/lib/helpers/validator.esm.js +99 -0
  56. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.esm.js +3 -0
  57. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.esm.js +3 -0
  58. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.esm.js +5 -0
  59. package/dist/node_modules/axios/lib/platform/browser/index.esm.js +15 -0
  60. package/dist/node_modules/axios/lib/platform/common/utils.esm.js +45 -0
  61. package/dist/node_modules/axios/lib/platform/index.esm.js +9 -0
  62. package/dist/node_modules/axios/lib/utils.esm.js +782 -0
  63. package/dist/node_modules/react-date-range/dist/components/Calendar/index.esm.js +1 -1
  64. package/dist/node_modules/react-date-range/dist/components/DateInput/index.esm.js +1 -1
  65. package/dist/node_modules/react-date-range/dist/components/DateRange/index.esm.js +1 -1
  66. package/dist/node_modules/react-date-range/dist/components/DateRangePicker/index.esm.js +1 -1
  67. package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +1 -1
  68. package/dist/node_modules/react-date-range/dist/components/Month/index.esm.js +1 -1
  69. package/dist/utils/Interface/FormInterface.d.ts +7 -1
  70. package/package.json +2 -1
@@ -0,0 +1,288 @@
1
+ import platform from '../platform/index.esm.js';
2
+ import utils from '../utils.esm.js';
3
+ import AxiosError from '../core/AxiosError.esm.js';
4
+ import composeSignals from '../helpers/composeSignals.esm.js';
5
+ import { trackStream } from '../helpers/trackStream.esm.js';
6
+ import AxiosHeaders from '../core/AxiosHeaders.esm.js';
7
+ import { progressEventDecorator, progressEventReducer, asyncDecorator } from '../helpers/progressEventReducer.esm.js';
8
+ import resolveConfig from '../helpers/resolveConfig.esm.js';
9
+ import settle from '../core/settle.esm.js';
10
+
11
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
12
+
13
+ const {isFunction} = utils;
14
+
15
+ const globalFetchAPI = (({Request, Response}) => ({
16
+ Request, Response
17
+ }))(utils.global);
18
+
19
+ const {
20
+ ReadableStream, TextEncoder
21
+ } = utils.global;
22
+
23
+
24
+ const test = (fn, ...args) => {
25
+ try {
26
+ return !!fn(...args);
27
+ } catch (e) {
28
+ return false
29
+ }
30
+ };
31
+
32
+ const factory = (env) => {
33
+ env = utils.merge.call({
34
+ skipUndefined: true
35
+ }, globalFetchAPI, env);
36
+
37
+ const {fetch: envFetch, Request, Response} = env;
38
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
39
+ const isRequestSupported = isFunction(Request);
40
+ const isResponseSupported = isFunction(Response);
41
+
42
+ if (!isFetchSupported) {
43
+ return false;
44
+ }
45
+
46
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
47
+
48
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
49
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
50
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
51
+ );
52
+
53
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
54
+ let duplexAccessed = false;
55
+
56
+ const hasContentType = new Request(platform.origin, {
57
+ body: new ReadableStream(),
58
+ method: 'POST',
59
+ get duplex() {
60
+ duplexAccessed = true;
61
+ return 'half';
62
+ },
63
+ }).headers.has('Content-Type');
64
+
65
+ return duplexAccessed && !hasContentType;
66
+ });
67
+
68
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
69
+ test(() => utils.isReadableStream(new Response('').body));
70
+
71
+ const resolvers = {
72
+ stream: supportsResponseStream && ((res) => res.body)
73
+ };
74
+
75
+ isFetchSupported && ((() => {
76
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
77
+ !resolvers[type] && (resolvers[type] = (res, config) => {
78
+ let method = res && res[type];
79
+
80
+ if (method) {
81
+ return method.call(res);
82
+ }
83
+
84
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
85
+ });
86
+ });
87
+ })());
88
+
89
+ const getBodyLength = async (body) => {
90
+ if (body == null) {
91
+ return 0;
92
+ }
93
+
94
+ if (utils.isBlob(body)) {
95
+ return body.size;
96
+ }
97
+
98
+ if (utils.isSpecCompliantForm(body)) {
99
+ const _request = new Request(platform.origin, {
100
+ method: 'POST',
101
+ body,
102
+ });
103
+ return (await _request.arrayBuffer()).byteLength;
104
+ }
105
+
106
+ if (utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) {
107
+ return body.byteLength;
108
+ }
109
+
110
+ if (utils.isURLSearchParams(body)) {
111
+ body = body + '';
112
+ }
113
+
114
+ if (utils.isString(body)) {
115
+ return (await encodeText(body)).byteLength;
116
+ }
117
+ };
118
+
119
+ const resolveBodyLength = async (headers, body) => {
120
+ const length = utils.toFiniteNumber(headers.getContentLength());
121
+
122
+ return length == null ? getBodyLength(body) : length;
123
+ };
124
+
125
+ return async (config) => {
126
+ let {
127
+ url,
128
+ method,
129
+ data,
130
+ signal,
131
+ cancelToken,
132
+ timeout,
133
+ onDownloadProgress,
134
+ onUploadProgress,
135
+ responseType,
136
+ headers,
137
+ withCredentials = 'same-origin',
138
+ fetchOptions
139
+ } = resolveConfig(config);
140
+
141
+ let _fetch = envFetch || fetch;
142
+
143
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
144
+
145
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
146
+
147
+ let request = null;
148
+
149
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
150
+ composedSignal.unsubscribe();
151
+ });
152
+
153
+ let requestContentLength;
154
+
155
+ try {
156
+ if (
157
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
158
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
159
+ ) {
160
+ let _request = new Request(url, {
161
+ method: 'POST',
162
+ body: data,
163
+ duplex: "half"
164
+ });
165
+
166
+ let contentTypeHeader;
167
+
168
+ if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
169
+ headers.setContentType(contentTypeHeader);
170
+ }
171
+
172
+ if (_request.body) {
173
+ const [onProgress, flush] = progressEventDecorator(
174
+ requestContentLength,
175
+ progressEventReducer(asyncDecorator(onUploadProgress))
176
+ );
177
+
178
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
179
+ }
180
+ }
181
+
182
+ if (!utils.isString(withCredentials)) {
183
+ withCredentials = withCredentials ? 'include' : 'omit';
184
+ }
185
+
186
+ // Cloudflare Workers throws when credentials are defined
187
+ // see https://github.com/cloudflare/workerd/issues/902
188
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
189
+
190
+ const resolvedOptions = {
191
+ ...fetchOptions,
192
+ signal: composedSignal,
193
+ method: method.toUpperCase(),
194
+ headers: headers.normalize().toJSON(),
195
+ body: data,
196
+ duplex: "half",
197
+ credentials: isCredentialsSupported ? withCredentials : undefined
198
+ };
199
+
200
+ request = isRequestSupported && new Request(url, resolvedOptions);
201
+
202
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
203
+
204
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
205
+
206
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
207
+ const options = {};
208
+
209
+ ['status', 'statusText', 'headers'].forEach(prop => {
210
+ options[prop] = response[prop];
211
+ });
212
+
213
+ const responseContentLength = utils.toFiniteNumber(response.headers.get('content-length'));
214
+
215
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
216
+ responseContentLength,
217
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
218
+ ) || [];
219
+
220
+ response = new Response(
221
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
222
+ flush && flush();
223
+ unsubscribe && unsubscribe();
224
+ }),
225
+ options
226
+ );
227
+ }
228
+
229
+ responseType = responseType || 'text';
230
+
231
+ let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config);
232
+
233
+ !isStreamResponse && unsubscribe && unsubscribe();
234
+
235
+ return await new Promise((resolve, reject) => {
236
+ settle(resolve, reject, {
237
+ data: responseData,
238
+ headers: AxiosHeaders.from(response.headers),
239
+ status: response.status,
240
+ statusText: response.statusText,
241
+ config,
242
+ request
243
+ });
244
+ })
245
+ } catch (err) {
246
+ unsubscribe && unsubscribe();
247
+
248
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
249
+ throw Object.assign(
250
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
251
+ {
252
+ cause: err.cause || err
253
+ }
254
+ )
255
+ }
256
+
257
+ throw AxiosError.from(err, err && err.code, config, request);
258
+ }
259
+ }
260
+ };
261
+
262
+ const seedCache = new Map();
263
+
264
+ const getFetch = (config) => {
265
+ let env = (config && config.env) || {};
266
+ const {fetch, Request, Response} = env;
267
+ const seeds = [
268
+ Request, Response, fetch
269
+ ];
270
+
271
+ let len = seeds.length, i = len,
272
+ seed, target, map = seedCache;
273
+
274
+ while (i--) {
275
+ seed = seeds[i];
276
+ target = map.get(seed);
277
+
278
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
279
+
280
+ map = target;
281
+ }
282
+
283
+ return target;
284
+ };
285
+
286
+ getFetch();
287
+
288
+ export { getFetch };
@@ -0,0 +1,202 @@
1
+ import utils from '../utils.esm.js';
2
+ import settle from '../core/settle.esm.js';
3
+ import transitionalDefaults from '../defaults/transitional.esm.js';
4
+ import AxiosError from '../core/AxiosError.esm.js';
5
+ import CanceledError from '../cancel/CanceledError.esm.js';
6
+ import parseProtocol from '../helpers/parseProtocol.esm.js';
7
+ import platform from '../platform/index.esm.js';
8
+ import AxiosHeaders from '../core/AxiosHeaders.esm.js';
9
+ import { progressEventReducer } from '../helpers/progressEventReducer.esm.js';
10
+ import resolveConfig from '../helpers/resolveConfig.esm.js';
11
+
12
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
13
+
14
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
15
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
16
+ const _config = resolveConfig(config);
17
+ let requestData = _config.data;
18
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
19
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
20
+ let onCanceled;
21
+ let uploadThrottled, downloadThrottled;
22
+ let flushUpload, flushDownload;
23
+
24
+ function done() {
25
+ flushUpload && flushUpload(); // flush events
26
+ flushDownload && flushDownload(); // flush events
27
+
28
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
29
+
30
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
31
+ }
32
+
33
+ let request = new XMLHttpRequest();
34
+
35
+ request.open(_config.method.toUpperCase(), _config.url, true);
36
+
37
+ // Set the request timeout in MS
38
+ request.timeout = _config.timeout;
39
+
40
+ function onloadend() {
41
+ if (!request) {
42
+ return;
43
+ }
44
+ // Prepare the response
45
+ const responseHeaders = AxiosHeaders.from(
46
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
47
+ );
48
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
49
+ request.responseText : request.response;
50
+ const response = {
51
+ data: responseData,
52
+ status: request.status,
53
+ statusText: request.statusText,
54
+ headers: responseHeaders,
55
+ config,
56
+ request
57
+ };
58
+
59
+ settle(function _resolve(value) {
60
+ resolve(value);
61
+ done();
62
+ }, function _reject(err) {
63
+ reject(err);
64
+ done();
65
+ }, response);
66
+
67
+ // Clean up request
68
+ request = null;
69
+ }
70
+
71
+ if ('onloadend' in request) {
72
+ // Use onloadend if available
73
+ request.onloadend = onloadend;
74
+ } else {
75
+ // Listen for ready state to emulate onloadend
76
+ request.onreadystatechange = function handleLoad() {
77
+ if (!request || request.readyState !== 4) {
78
+ return;
79
+ }
80
+
81
+ // The request errored out and we didn't get a response, this will be
82
+ // handled by onerror instead
83
+ // With one exception: request that using file: protocol, most browsers
84
+ // will return status as 0 even though it's a successful request
85
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
86
+ return;
87
+ }
88
+ // readystate handler is calling before onerror or ontimeout handlers,
89
+ // so we should call onloadend on the next 'tick'
90
+ setTimeout(onloadend);
91
+ };
92
+ }
93
+
94
+ // Handle browser request cancellation (as opposed to a manual cancellation)
95
+ request.onabort = function handleAbort() {
96
+ if (!request) {
97
+ return;
98
+ }
99
+
100
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
101
+
102
+ // Clean up request
103
+ request = null;
104
+ };
105
+
106
+ // Handle low level network errors
107
+ request.onerror = function handleError(event) {
108
+ // Browsers deliver a ProgressEvent in XHR onerror
109
+ // (message may be empty; when present, surface it)
110
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
111
+ const msg = event && event.message ? event.message : 'Network Error';
112
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
113
+ // attach the underlying event for consumers who want details
114
+ err.event = event || null;
115
+ reject(err);
116
+ request = null;
117
+ };
118
+
119
+ // Handle timeout
120
+ request.ontimeout = function handleTimeout() {
121
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
122
+ const transitional = _config.transitional || transitionalDefaults;
123
+ if (_config.timeoutErrorMessage) {
124
+ timeoutErrorMessage = _config.timeoutErrorMessage;
125
+ }
126
+ reject(new AxiosError(
127
+ timeoutErrorMessage,
128
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
129
+ config,
130
+ request));
131
+
132
+ // Clean up request
133
+ request = null;
134
+ };
135
+
136
+ // Remove Content-Type if data is undefined
137
+ requestData === undefined && requestHeaders.setContentType(null);
138
+
139
+ // Add headers to the request
140
+ if ('setRequestHeader' in request) {
141
+ utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
142
+ request.setRequestHeader(key, val);
143
+ });
144
+ }
145
+
146
+ // Add withCredentials to request if needed
147
+ if (!utils.isUndefined(_config.withCredentials)) {
148
+ request.withCredentials = !!_config.withCredentials;
149
+ }
150
+
151
+ // Add responseType to request if needed
152
+ if (responseType && responseType !== 'json') {
153
+ request.responseType = _config.responseType;
154
+ }
155
+
156
+ // Handle progress if needed
157
+ if (onDownloadProgress) {
158
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
159
+ request.addEventListener('progress', downloadThrottled);
160
+ }
161
+
162
+ // Not all browsers support upload events
163
+ if (onUploadProgress && request.upload) {
164
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
165
+
166
+ request.upload.addEventListener('progress', uploadThrottled);
167
+
168
+ request.upload.addEventListener('loadend', flushUpload);
169
+ }
170
+
171
+ if (_config.cancelToken || _config.signal) {
172
+ // Handle cancellation
173
+ // eslint-disable-next-line func-names
174
+ onCanceled = cancel => {
175
+ if (!request) {
176
+ return;
177
+ }
178
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
179
+ request.abort();
180
+ request = null;
181
+ };
182
+
183
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
184
+ if (_config.signal) {
185
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
186
+ }
187
+ }
188
+
189
+ const protocol = parseProtocol(_config.url);
190
+
191
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
192
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
193
+ return;
194
+ }
195
+
196
+
197
+ // Send the request
198
+ request.send(requestData || null);
199
+ });
200
+ };
201
+
202
+ export { xhrAdapter as default };
@@ -0,0 +1,86 @@
1
+ import utils from './utils.esm.js';
2
+ import bind from './helpers/bind.esm.js';
3
+ import Axios from './core/Axios.esm.js';
4
+ import mergeConfig from './core/mergeConfig.esm.js';
5
+ import defaults from './defaults/index.esm.js';
6
+ import formDataToJSON from './helpers/formDataToJSON.esm.js';
7
+ import CanceledError from './cancel/CanceledError.esm.js';
8
+ import CancelToken from './cancel/CancelToken.esm.js';
9
+ import isCancel from './cancel/isCancel.esm.js';
10
+ import { VERSION } from './env/data.esm.js';
11
+ import toFormData from './helpers/toFormData.esm.js';
12
+ import AxiosError from './core/AxiosError.esm.js';
13
+ import spread from './helpers/spread.esm.js';
14
+ import isAxiosError from './helpers/isAxiosError.esm.js';
15
+ import AxiosHeaders from './core/AxiosHeaders.esm.js';
16
+ import adapters from './adapters/adapters.esm.js';
17
+ import HttpStatusCode from './helpers/HttpStatusCode.esm.js';
18
+
19
+ /**
20
+ * Create an instance of Axios
21
+ *
22
+ * @param {Object} defaultConfig The default config for the instance
23
+ *
24
+ * @returns {Axios} A new instance of Axios
25
+ */
26
+ function createInstance(defaultConfig) {
27
+ const context = new Axios(defaultConfig);
28
+ const instance = bind(Axios.prototype.request, context);
29
+
30
+ // Copy axios.prototype to instance
31
+ utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
32
+
33
+ // Copy context to instance
34
+ utils.extend(instance, context, null, {allOwnKeys: true});
35
+
36
+ // Factory for creating new instances
37
+ instance.create = function create(instanceConfig) {
38
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
39
+ };
40
+
41
+ return instance;
42
+ }
43
+
44
+ // Create the default instance to be exported
45
+ const axios = createInstance(defaults);
46
+
47
+ // Expose Axios class to allow class inheritance
48
+ axios.Axios = Axios;
49
+
50
+ // Expose Cancel & CancelToken
51
+ axios.CanceledError = CanceledError;
52
+ axios.CancelToken = CancelToken;
53
+ axios.isCancel = isCancel;
54
+ axios.VERSION = VERSION;
55
+ axios.toFormData = toFormData;
56
+
57
+ // Expose AxiosError class
58
+ axios.AxiosError = AxiosError;
59
+
60
+ // alias for CanceledError for backward compatibility
61
+ axios.Cancel = axios.CanceledError;
62
+
63
+ // Expose all/spread
64
+ axios.all = function all(promises) {
65
+ return Promise.all(promises);
66
+ };
67
+
68
+ axios.spread = spread;
69
+
70
+ // Expose isAxiosError
71
+ axios.isAxiosError = isAxiosError;
72
+
73
+ // Expose mergeConfig
74
+ axios.mergeConfig = mergeConfig;
75
+
76
+ axios.AxiosHeaders = AxiosHeaders;
77
+
78
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
79
+
80
+ axios.getAdapter = adapters.getAdapter;
81
+
82
+ axios.HttpStatusCode = HttpStatusCode;
83
+
84
+ axios.default = axios;
85
+
86
+ export { axios as default };
@@ -0,0 +1,133 @@
1
+ import CanceledError from './CanceledError.esm.js';
2
+
3
+ /**
4
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
5
+ *
6
+ * @param {Function} executor The executor function.
7
+ *
8
+ * @returns {CancelToken}
9
+ */
10
+ class CancelToken {
11
+ constructor(executor) {
12
+ if (typeof executor !== 'function') {
13
+ throw new TypeError('executor must be a function.');
14
+ }
15
+
16
+ let resolvePromise;
17
+
18
+ this.promise = new Promise(function promiseExecutor(resolve) {
19
+ resolvePromise = resolve;
20
+ });
21
+
22
+ const token = this;
23
+
24
+ // eslint-disable-next-line func-names
25
+ this.promise.then(cancel => {
26
+ if (!token._listeners) return;
27
+
28
+ let i = token._listeners.length;
29
+
30
+ while (i-- > 0) {
31
+ token._listeners[i](cancel);
32
+ }
33
+ token._listeners = null;
34
+ });
35
+
36
+ // eslint-disable-next-line func-names
37
+ this.promise.then = onfulfilled => {
38
+ let _resolve;
39
+ // eslint-disable-next-line func-names
40
+ const promise = new Promise(resolve => {
41
+ token.subscribe(resolve);
42
+ _resolve = resolve;
43
+ }).then(onfulfilled);
44
+
45
+ promise.cancel = function reject() {
46
+ token.unsubscribe(_resolve);
47
+ };
48
+
49
+ return promise;
50
+ };
51
+
52
+ executor(function cancel(message, config, request) {
53
+ if (token.reason) {
54
+ // Cancellation has already been requested
55
+ return;
56
+ }
57
+
58
+ token.reason = new CanceledError(message, config, request);
59
+ resolvePromise(token.reason);
60
+ });
61
+ }
62
+
63
+ /**
64
+ * Throws a `CanceledError` if cancellation has been requested.
65
+ */
66
+ throwIfRequested() {
67
+ if (this.reason) {
68
+ throw this.reason;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Subscribe to the cancel signal
74
+ */
75
+
76
+ subscribe(listener) {
77
+ if (this.reason) {
78
+ listener(this.reason);
79
+ return;
80
+ }
81
+
82
+ if (this._listeners) {
83
+ this._listeners.push(listener);
84
+ } else {
85
+ this._listeners = [listener];
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Unsubscribe from the cancel signal
91
+ */
92
+
93
+ unsubscribe(listener) {
94
+ if (!this._listeners) {
95
+ return;
96
+ }
97
+ const index = this._listeners.indexOf(listener);
98
+ if (index !== -1) {
99
+ this._listeners.splice(index, 1);
100
+ }
101
+ }
102
+
103
+ toAbortSignal() {
104
+ const controller = new AbortController();
105
+
106
+ const abort = (err) => {
107
+ controller.abort(err);
108
+ };
109
+
110
+ this.subscribe(abort);
111
+
112
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
113
+
114
+ return controller.signal;
115
+ }
116
+
117
+ /**
118
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
119
+ * cancels the `CancelToken`.
120
+ */
121
+ static source() {
122
+ let cancel;
123
+ const token = new CancelToken(function executor(c) {
124
+ cancel = c;
125
+ });
126
+ return {
127
+ token,
128
+ cancel
129
+ };
130
+ }
131
+ }
132
+
133
+ export { CancelToken as default };