@scaleflex/widget-utils 4.1.0 → 4.4.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 (176) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +3 -3
  3. package/lib/AbortController.js +0 -20
  4. package/lib/BlurHash/base83.js +0 -10
  5. package/lib/BlurHash/decode.js +0 -80
  6. package/lib/BlurHash/error.js +0 -28
  7. package/lib/BlurHash/utils.js +0 -22
  8. package/lib/CustomDate.js +0 -157
  9. package/lib/EventTracker.js +0 -42
  10. package/lib/FOCUSABLE_ELEMENTS.js +0 -1
  11. package/lib/LinkHelper.js +0 -153
  12. package/lib/NetworkError.js +0 -30
  13. package/lib/ProgressTimeout.js +0 -45
  14. package/lib/RateLimitedQueue.js +0 -197
  15. package/lib/RequestError.js +0 -36
  16. package/lib/Timeframes/getDateRange.js +0 -45
  17. package/lib/TranslationMissingKeysConsoleHelper.js +0 -113
  18. package/lib/Translator.js +0 -200
  19. package/lib/addUrlParams.js +0 -27
  20. package/lib/adjustUpdatedFolders.js +0 -22
  21. package/lib/asyncTimeout.js +0 -6
  22. package/lib/audioMimeTypes.js +0 -3
  23. package/lib/blobToDataURI.js +0 -13
  24. package/lib/callIfFunction.js +0 -10
  25. package/lib/canEditVideo.js +0 -9
  26. package/lib/canvasToBlob.js +0 -18
  27. package/lib/capitalizeFirstLetter.js +0 -4
  28. package/lib/checkConnection.js +0 -4
  29. package/lib/checkFileOrFolderNameValidation.js +0 -4
  30. package/lib/checkIfPngSvgGIF.js +0 -3
  31. package/lib/checkImageIfPngJpegOrWebpOrAvif.js +0 -5
  32. package/lib/checkItemsSupportExportWithReason.js +0 -41
  33. package/lib/checkPermissions.js +0 -26
  34. package/lib/cloudimageSupportedInputMimeTypes.js +0 -2
  35. package/lib/clsx.js +0 -14
  36. package/lib/constants.js +0 -570
  37. package/lib/convertBytesToMb.js +0 -5
  38. package/lib/convertGbToBytes.js +0 -4
  39. package/lib/convertVideoFileTypeToSupported.js +0 -17
  40. package/lib/copyText.js +0 -25
  41. package/lib/createFolderVirtualPath.js +0 -14
  42. package/lib/createThunk.js +0 -349
  43. package/lib/customEncodeURIComponent.js +0 -47
  44. package/lib/dataURItoBlob.js +0 -33
  45. package/lib/dataURItoFile.js +0 -4
  46. package/lib/dateStrToClearDateTime.js +0 -20
  47. package/lib/debounce.js +0 -14
  48. package/lib/deepEqual.js +0 -23
  49. package/lib/deepMerge.js +0 -56
  50. package/lib/deserializeFunction.js +0 -5
  51. package/lib/documentMimeTypes.js +0 -2
  52. package/lib/downloadFromBlob.js +0 -16
  53. package/lib/emitSocketProgress.js +0 -18
  54. package/lib/escapeRegExp.js +0 -4
  55. package/lib/extractFileDataNoBlob.js +0 -12
  56. package/lib/fetchWithNetworkError.js +0 -14
  57. package/lib/fieldsQueriesGetters.js +0 -46
  58. package/lib/findAllDOMElements.js +0 -18
  59. package/lib/findAllRegexMatchesInString.js +0 -16
  60. package/lib/findDOMElement.js +0 -17
  61. package/lib/findIndex.js +0 -9
  62. package/lib/formatDuration.js +0 -22
  63. package/lib/formatNumbers.js +0 -32
  64. package/lib/formatResolution.js +0 -17
  65. package/lib/formatSeconds.js +0 -14
  66. package/lib/generateFileId.js +0 -53
  67. package/lib/generateI18nKeyFromString.js +0 -11
  68. package/lib/generatePsdThumbnail/adaptHexBoundries.js +0 -9
  69. package/lib/generatePsdThumbnail/bufferToHex.js +0 -12
  70. package/lib/generatePsdThumbnail/generatePsdThumbnail.js +0 -36
  71. package/lib/generatePsdThumbnail/generatePsdThumbnailBytes.js +0 -8
  72. package/lib/generatePsdThumbnail/generatePsdThumbnailHex.js +0 -4
  73. package/lib/generateSelectInputPlaceholder.js +0 -24
  74. package/lib/getActionErrorState.js +0 -17
  75. package/lib/getArraysMutualObjects.js +0 -12
  76. package/lib/getBytesRemaining.js +0 -9
  77. package/lib/getClientTimezone.js +0 -5
  78. package/lib/getCloudimagePrefixedUrl.js +0 -23
  79. package/lib/getDateDaysFromNow.js +0 -17
  80. package/lib/getDateMinusDay.js +0 -5
  81. package/lib/getDateString.js +0 -20
  82. package/lib/getDaysLeft.js +0 -9
  83. package/lib/getDecodedUriComponent.js +0 -10
  84. package/lib/getDownloadSpeed.js +0 -7
  85. package/lib/getDroppedFiles/index.js +0 -24
  86. package/lib/getDroppedFiles/utils/fallbackApi.js +0 -7
  87. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getFilesAndDirectoriesFromDirectory.js +0 -36
  88. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getRelativePath.js +0 -16
  89. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/index.js +0 -57
  90. package/lib/getEncodedWrappedUrl.js +0 -7
  91. package/lib/getFileAssetsTokenUrl.js +0 -14
  92. package/lib/getFileCdnLink.js +0 -6
  93. package/lib/getFileDefaultIcon.js +0 -14
  94. package/lib/getFileDetails.js +0 -81
  95. package/lib/getFileExtension.js +0 -32
  96. package/lib/getFileLink.js +0 -17
  97. package/lib/getFileNameAndExtension.js +0 -22
  98. package/lib/getFileType.js +0 -23
  99. package/lib/getFileTypeExtension.js +0 -22
  100. package/lib/getFilterFileFormatIcon.js +0 -6
  101. package/lib/getFolderDetails.js +0 -30
  102. package/lib/getFormattedPreviewUrl.js +0 -79
  103. package/lib/getHoursAndMinutes.js +0 -9
  104. package/lib/getImageEditUrl.js +0 -36
  105. package/lib/getImgFileDimensions.js +0 -25
  106. package/lib/getItemIcon.js +0 -112
  107. package/lib/getItemPath.js +0 -10
  108. package/lib/getItemPreviewWidthHeight.js +0 -10
  109. package/lib/getItemsSizeInBytes.js +0 -12
  110. package/lib/getJsonParsedValue.js +0 -11
  111. package/lib/getLinkWithNewParams.js +0 -13
  112. package/lib/getMetadataMultiSelectQuery.js +0 -66
  113. package/lib/getNormalizedItems.js +0 -55
  114. package/lib/getObjectsMutualProperties.js +0 -32
  115. package/lib/getRandomNumber.js +0 -12
  116. package/lib/getSocketHost.js +0 -7
  117. package/lib/getSpeed.js +0 -8
  118. package/lib/getTime.js +0 -18
  119. package/lib/getTimeStamp.js +0 -18
  120. package/lib/handleError.js +0 -13
  121. package/lib/handlePressEnter.js +0 -9
  122. package/lib/handlePromise.js +0 -39
  123. package/lib/hasProperty.js +0 -3
  124. package/lib/hexToRgb.js +0 -15
  125. package/lib/htmlSanitizer.js +0 -6
  126. package/lib/humanReadableDate.js +0 -45
  127. package/lib/humanReadableDateWithTranslations.js +0 -29
  128. package/lib/i18n.client.js +0 -54
  129. package/lib/ignoreEvent.js +0 -10
  130. package/lib/index.js +0 -0
  131. package/lib/injectVirtualPathToFolders.js +0 -24
  132. package/lib/isAi.js +0 -7
  133. package/lib/isArchive.js +0 -12
  134. package/lib/isAudio.js +0 -9
  135. package/lib/isAudioAndSupportsPlayback.js +0 -10
  136. package/lib/isCloudimageFastPreviewSupported.js +0 -16
  137. package/lib/isDOMElement.js +0 -9
  138. package/lib/isDocument.js +0 -10
  139. package/lib/isDragDropSupported.js +0 -20
  140. package/lib/isEmptyObject.js +0 -4
  141. package/lib/isEps.js +0 -8
  142. package/lib/isFile.js +0 -5
  143. package/lib/isFileSupportedByCloudimage.js +0 -14
  144. package/lib/isFolder.js +0 -4
  145. package/lib/isFontFile.js +0 -9
  146. package/lib/isFunction.js +0 -4
  147. package/lib/isImage.js +0 -11
  148. package/lib/isJpg.js +0 -8
  149. package/lib/isMobileDevice.js +0 -12
  150. package/lib/isNetworkError.js +0 -7
  151. package/lib/isNumber.js +0 -4
  152. package/lib/isObjectType.js +0 -5
  153. package/lib/isObjectURL.js +0 -10
  154. package/lib/isOpenedFromAdobe.js +0 -3
  155. package/lib/isOtf.js +0 -10
  156. package/lib/isPdf.js +0 -9
  157. package/lib/isPhotoshopFile.js +0 -8
  158. package/lib/isPreviewSupported.js +0 -12
  159. package/lib/isPromise.js +0 -5
  160. package/lib/metadata/checkFieldValidation.js +0 -51
  161. package/lib/metadata/generateItemMetadataState.js +0 -63
  162. package/lib/metadata/generateMetadataDefaultState.js +0 -30
  163. package/lib/metadata/getFileCustomMetadataGroups.js +0 -23
  164. package/lib/metadata/getGeoPointValidationErrors.js +0 -32
  165. package/lib/metadata/getMetaAttachmentFields.js +0 -9
  166. package/lib/metadata/getMetadataEmptyAssets.js +0 -28
  167. package/lib/metadata/getMetadataFieldGeoPointValue.js +0 -42
  168. package/lib/metadata/getMetadataFieldVariantValue.js +0 -31
  169. package/lib/metadata/getMetadataGroups.js +0 -16
  170. package/lib/metadata/getRequiredMetadataFields.js +0 -13
  171. package/lib/metadata/isM0LegacyMetaVersion.js +0 -5
  172. package/lib/metadata/isM1EdgyMetaVersion.js +0 -5
  173. package/lib/metadata/mapMetaAttachmentsObjsToUuids.js +0 -21
  174. package/lib/metadata/updateValidationErrors.js +0 -59
  175. package/lib/metadata/validateItemMetadata.js +0 -70
  176. package/lib/styledComponentsMixins/truncate.mixin.js +0 -8
@@ -1,349 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import { isPlain } from '@reduxjs/toolkit';
8
- import nanoid from './nanoid';
9
- import logErrorIfDevEnv from './logErrorIfDevEnv';
10
- import handleError from './handleError';
11
- import { ABORTED_ERROR } from './constants';
12
- var REJECTIONS = {
13
- CONDITION: 'Condition',
14
- REJECTED_WITH_VALUE: 'RejectedWithValue'
15
- };
16
- var rejectionsErrors = _defineProperty(_defineProperty({}, REJECTIONS.REJECTED_WITH_VALUE, {
17
- name: 'Rejected',
18
- message: 'Rejected with a value.'
19
- }), REJECTIONS.CONDITION, {
20
- name: 'Condition',
21
- message: 'Cancelled due to `condition` callback returning false.'
22
- });
23
- var getSerializedValue = function getSerializedValue(val, path, isDev) {
24
- if (isPlain(val)) {
25
- return val;
26
- }
27
- if (isDev) {
28
- console.warn("Non-serializable value is detected in the path (".concat(path, "), it's already has been handled and won't be passed so dismiss this warning in-case u don't care about passing this payload as it's passed as an empty object ({}):"), val);
29
- }
30
- return {};
31
- };
32
- var createActionCreator = function createActionCreator(type) {
33
- function actionCreator(payload, meta) {
34
- var isDev = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
35
- var error = arguments.length > 3 ? arguments[3] : undefined;
36
- var action = {
37
- type: type
38
- };
39
- if (payload !== undefined) {
40
- action.payload = getSerializedValue(payload, "(action.payload) of action ".concat(action.type), isDev);
41
- }
42
- if (meta !== undefined) {
43
- action.meta = getSerializedValue(meta, "(action.meta) of action ".concat(action.type), isDev);
44
- }
45
- if (error !== undefined) {
46
- action.error = getSerializedValue(error, "(action.error) of action ".concat(action.type), isDev);
47
- }
48
- return action;
49
- }
50
- actionCreator.toString = function () {
51
- return type;
52
- };
53
- actionCreator.type = type;
54
- actionCreator.match = function (action) {
55
- return action && action.type === type;
56
- };
57
- return actionCreator;
58
- };
59
-
60
- // The following in-progress async thunk actions handling for ease of aborting some in-progress thunks from other not related thunks.
61
- var inProgressAsyncThunksByActions = {
62
- // [actionType]: [
63
- // {
64
- // requestId: '...', // the id of the xhr request
65
- // abort: () => {}, // Abort function to abort the request & async thunk's possible to dispatch actions.
66
- // signal: {} // Controller signal
67
- // data: undefined/{}, // other data (if needed, not recommended to use unless really needed)
68
- // }
69
- // ]
70
- };
71
- var setInProgressAsyncThunk = function setInProgressAsyncThunk(actionType, _ref) {
72
- var requestId = _ref.requestId,
73
- abort = _ref.abort,
74
- data = _ref.data;
75
- if (!requestId || !abort) {
76
- return;
77
- }
78
- if (!Array.isArray(inProgressAsyncThunksByActions[actionType])) {
79
- inProgressAsyncThunksByActions[actionType] = [];
80
- }
81
- var newAsyncThunkIndex = inProgressAsyncThunksByActions[actionType].push({
82
- requestId: requestId,
83
- abort: abort,
84
- data: data
85
- }) - 1;
86
- return newAsyncThunkIndex;
87
- };
88
- var removeInProgressAsyncThunk = function removeInProgressAsyncThunk(actionType, inProgressThunkIndex) {
89
- var _inProgressAsyncThunk;
90
- var isThunkActionFound = (_inProgressAsyncThunk = inProgressAsyncThunksByActions[actionType]) === null || _inProgressAsyncThunk === void 0 ? void 0 : _inProgressAsyncThunk[inProgressThunkIndex];
91
- if (isThunkActionFound) {
92
- inProgressAsyncThunksByActions[actionType].splice(inProgressThunkIndex, 1);
93
- if (inProgressAsyncThunksByActions[actionType].length === 0) {
94
- delete inProgressAsyncThunksByActions[actionType];
95
- }
96
- }
97
- };
98
- var getInProgressAsyncThunksByType = function getInProgressAsyncThunksByType(actionType) {
99
- return inProgressAsyncThunksByActions[actionType] || [];
100
- };
101
- var abortInProgressAsyncThunksByType = function abortInProgressAsyncThunksByType(actionType) {
102
- if (!actionType) {
103
- return;
104
- }
105
- getInProgressAsyncThunksByType(actionType).forEach(function () {
106
- var _thunk$abort;
107
- var thunk = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
108
- (_thunk$abort = thunk.abort) === null || _thunk$abort === void 0 ? void 0 : _thunk$abort.call(thunk);
109
- });
110
- return true;
111
- };
112
- var abortAllInProgressAsyncThunks = function abortAllInProgressAsyncThunks() {
113
- Object.values(inProgressAsyncThunksByActions).forEach(function () {
114
- var inProgressActionThunks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
115
- inProgressActionThunks.forEach(function () {
116
- var _thunk$abort2;
117
- var thunk = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
118
- (_thunk$abort2 = thunk.abort) === null || _thunk$abort2 === void 0 ? void 0 : _thunk$abort2.call(thunk);
119
- });
120
- });
121
- return true;
122
- };
123
-
124
- /**
125
- * Exact Similar to createAsyncThunk with some extra options:
126
- * 1. supporting both async & sync thunk functions
127
- * 2. added 1 more dispatched action ${actionType}/(loading, fulfilled, rejected & *final*)
128
- * 3. `skipDispatch` or don't provide `actionType` - incase of not wanting to dispatch any action and only need to trigger the sync/async function or manual handling for actions.
129
- * 4. `informError` - incase of wanting to inform the error to the user (ex. in a toast) and not dispatching any action.
130
- * 5. `throwRejection` - if u want to throw the error of the promise and u will handle it by catching the error by (handlePromise utility function) or .catch, then provide this `true`.
131
- *
132
- * @param {Function} dispatchedFn - the function that will be called when the thunk is dispatched
133
- * @param {Object} options - the options passed for configuring the function operation
134
- * @param {String} options.actionType - the action type that will be dispatched
135
- * @param {Function} options.condition - the condition that will be checked before calling the dispatchedFn,
136
- * -- `true`/`resolved promise` do the normal dispatch,
137
- * -- `false`/`rejected promise` cancels the dispatched function implementation and return empty resolved promise.
138
- * @param {Boolean} options.skipDispatch - incase of NOT wanting to dispatch any action and only need to trigger the sync/async function or manual handling for actions.
139
- * @param {Boolean} options.skipPendingDispatch - it disables the dispatching of pending action, and only dispatches the fulfilled/rejected/final actions.
140
- * @param {Boolean} options.informError - incase of wanting to inform the error to the user (ex. in a toast).
141
- * @param {Boolean} options.throwRejection - incase of NOT wanting to handle the rejection in the return of dispatch from the function side, in that case u have to catch it urself ex. of dispatch(...).catch(...)
142
- * @param {Boolean} options.dismissGlobalAbort - if u don't need to abort the request on calling abortInProgressThunks
143
- *
144
- * @returns Function - the thunk function
145
- */
146
- var createThunk = function createThunk(dispatchedFn) {
147
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
148
- var _options$actionType = options.actionType,
149
- actionType = _options$actionType === void 0 ? '' : _options$actionType,
150
- condition = options.condition,
151
- _options$skipDispatch = options.skipDispatch,
152
- skipDispatch = _options$skipDispatch === void 0 ? false : _options$skipDispatch,
153
- _options$skipPendingD = options.skipPendingDispatch,
154
- skipPendingDispatch = _options$skipPendingD === void 0 ? false : _options$skipPendingD,
155
- _options$informError = options.informError,
156
- informError = _options$informError === void 0 ? false : _options$informError,
157
- _options$dismissAbort = options.dismissAbortError,
158
- dismissAbortError = _options$dismissAbort === void 0 ? false : _options$dismissAbort,
159
- _options$dismissGloba = options.dismissGlobalAbort,
160
- dismissGlobalAbort = _options$dismissGloba === void 0 ? false : _options$dismissGloba;
161
- function payloadCreator(payload) {
162
- function thunkCreator(dispatch, getState, extra) {
163
- // if `true`, then we must handle .catch in the return of dispatch, ex. of dispatch(...).catch(...)
164
- var _options$throwRejecti = options.throwRejection,
165
- throwRejection = _options$throwRejecti === void 0 ? false : _options$throwRejecti;
166
- var shouldDispatch = actionType && !skipDispatch;
167
- var avoidPendingDispatch = skipPendingDispatch;
168
- var abortController = new AbortController();
169
- var isRequestFinished = false;
170
- var signal = abortController.signal;
171
- var abort = function abort() {
172
- if (isRequestFinished) {
173
- return;
174
- }
175
- abortController.abort();
176
- };
177
-
178
- // If the thunk function is sync then call it and return, no need to call the following logic of async function.
179
- // async keyword is required to be prefixed to the function to act as async thunk, otherwise it will be sync.
180
-
181
- // !TODO: Return back when problem with babel build if fixed on hub
182
- // if (dispatchedFn.constructor && dispatchedFn.constructor.name !== 'AsyncFunction' instanceof Promise) {
183
- var isAsync = false;
184
- try {
185
- // console.log('dispatchedFn.constructor.name: ', dispatchedFn?.constructor?.name)
186
- if (dispatchedFn.constructor && dispatchedFn.constructor.name === 'AsyncFunction') {
187
- isAsync = true;
188
- } else {
189
- isAsync = dispatchedFn() instanceof Promise;
190
- }
191
- } catch (error) {}
192
- if (!isAsync) {
193
- var thunkApi = {
194
- dispatch: dispatch,
195
- getState: getState,
196
- extra: extra,
197
- getInProgressAsyncThunksByType: getInProgressAsyncThunksByType,
198
- abortInProgressAsyncThunksByType: abortInProgressAsyncThunksByType,
199
- abortAllInProgressAsyncThunks: abortAllInProgressAsyncThunks
200
- };
201
- return dispatchedFn(payload, thunkApi);
202
- }
203
- var requestId = nanoid();
204
- async function asyncThunkFn() {
205
- var _ref3;
206
- var isDev = extra.filerobot.opts.dev;
207
- var fulfillWithValue = function fulfillWithValue(value) {
208
- return Promise.resolve(value);
209
- };
210
- var _rejectWithValue = function rejectWithValue(value, cbk) {
211
- cbk();
212
- return Promise.reject(value);
213
- };
214
- var replacedMetaArg = null;
215
- var dispatchError = function dispatchError(reason, err) {
216
- if (shouldDispatch) {
217
- var _ref2;
218
- dispatch(payloadCreator.rejected(reason === REJECTIONS.REJECTED_WITH_VALUE ? err : undefined, {
219
- arg: (_ref2 = replacedMetaArg || payload) !== null && _ref2 !== void 0 ? _ref2 : {},
220
- requestId: requestId,
221
- requestStatus: 'rejected',
222
- aborted: reason === ABORTED_ERROR
223
- // condition: reason === REJECTIONS.CONDITION
224
- }, isDev, reason === ABORTED_ERROR ? undefined : rejectionsErrors[reason] || err));
225
- }
226
- };
227
- var thunkApi = {
228
- dispatch: dispatch,
229
- getState: getState,
230
- extra: extra,
231
- signal: signal,
232
- abort: abort,
233
- requestId: requestId,
234
- replaceActionsMetaArg: function replaceActionsMetaArg(metaArg) {
235
- replacedMetaArg = metaArg;
236
- },
237
- // sets object in the action.meta.arg properties
238
- skipDispatch: function skipDispatch() {
239
- shouldDispatch = false;
240
- },
241
- skipPendingDispatch: function skipPendingDispatch() {
242
- avoidPendingDispatch = true;
243
- },
244
- rejectWithValue: function rejectWithValue(value) {
245
- return _rejectWithValue(value, function () {
246
- return dispatchError(REJECTIONS.REJECTED_WITH_VALUE, value);
247
- });
248
- },
249
- fulfillWithValue: fulfillWithValue,
250
- getInProgressAsyncThunksByType: getInProgressAsyncThunksByType,
251
- abortInProgressAsyncThunksByType: abortInProgressAsyncThunksByType,
252
- abortAllInProgressAsyncThunks: abortAllInProgressAsyncThunks
253
- };
254
- if (typeof condition === 'function') {
255
- var result = condition(payload, thunkApi);
256
- if (result instanceof Promise) {
257
- var conditionResult = await result;
258
- if (!conditionResult) {
259
- // dispatchError(REJECTIONS.CONDITION)
260
- return Promise.resolve();
261
- }
262
- }
263
- if (!result) {
264
- // dispatchError(REJECTIONS.CONDITION)
265
- return Promise.resolve();
266
- }
267
- }
268
-
269
- // We moved it after calling the function, in case the function's body calls (skipDispatch function), in that case we won't dispatch the actions.
270
- var functionResult = dispatchedFn(payload, thunkApi);
271
- var inProgressAsyncThunkIndex = !dismissGlobalAbort && setInProgressAsyncThunk(actionType, {
272
- requestId: requestId,
273
- abort: abort,
274
- signal: signal
275
- });
276
- var properMetaArg = (_ref3 = replacedMetaArg || payload) !== null && _ref3 !== void 0 ? _ref3 : {};
277
- if (shouldDispatch && !avoidPendingDispatch) {
278
- dispatch(payloadCreator.pending(undefined, {
279
- arg: properMetaArg,
280
- requestId: requestId,
281
- requestStatus: 'pending'
282
- }, isDev));
283
- }
284
- var dispatchFinal = function dispatchFinal() {
285
- if (shouldDispatch) {
286
- dispatch(payloadCreator["final"](undefined, {
287
- arg: properMetaArg,
288
- requestId: requestId,
289
- requestStatus: 'final'
290
- }), isDev);
291
- }
292
- };
293
- var returnedPromise = functionResult.then(function (res) {
294
- if (shouldDispatch) {
295
- dispatch(payloadCreator.fulfilled(isPlain(res) ? res : {}, {
296
- arg: properMetaArg,
297
- requestId: requestId,
298
- requestStatus: 'fulfilled'
299
- }, isDev));
300
- }
301
- return res;
302
- })["catch"](function (err) {
303
- logErrorIfDevEnv(err, isDev);
304
-
305
- // thrown ABORTED_ERROR from Client.js has the same reference as ABORTED_ERROR, so it's fine to do this error check.
306
- var isAbortErrorPassable = err !== ABORTED_ERROR || !dismissAbortError;
307
- if (shouldDispatch && isAbortErrorPassable) {
308
- var message = err.message || (err === null || err === void 0 ? void 0 : err.toString());
309
- dispatchError(err === ABORTED_ERROR ? ABORTED_ERROR : undefined, _objectSpread({
310
- message: message
311
- }, err));
312
- }
313
- // !TODO: Check if we should make informError `true` by default instead of `false` or not.
314
- if (informError && isAbortErrorPassable) {
315
- var _thunkApi$extra$filer;
316
- handleError(err, (_thunkApi$extra$filer = thunkApi.extra.filerobot) === null || _thunkApi$extra$filer === void 0 ? void 0 : _thunkApi$extra$filer.info);
317
- }
318
- if (throwRejection && isAbortErrorPassable) {
319
- return Promise.reject(err);
320
- }
321
- })["finally"](function () {
322
- removeInProgressAsyncThunk(actionType, inProgressAsyncThunkIndex);
323
- isRequestFinished = true;
324
- dispatchFinal();
325
- });
326
- return returnedPromise;
327
- }
328
- var returnedThunkPromise = asyncThunkFn();
329
- returnedThunkPromise.abort = abort;
330
- returnedThunkPromise.requestId = requestId;
331
- returnedThunkPromise.signal = signal;
332
- returnedThunkPromise.throwRejection = function () {
333
- throwRejection = true;
334
- return returnedThunkPromise;
335
- };
336
- return returnedThunkPromise;
337
- }
338
- return thunkCreator;
339
- }
340
- if (actionType && !skipDispatch) {
341
- payloadCreator.pending = createActionCreator("".concat(actionType, "/pending"));
342
- payloadCreator.fulfilled = createActionCreator("".concat(actionType, "/fulfilled"));
343
- payloadCreator.rejected = createActionCreator("".concat(actionType, "/rejected"));
344
- payloadCreator["final"] = createActionCreator("".concat(actionType, "/final"));
345
- payloadCreator.typePrefix = actionType;
346
- }
347
- return payloadCreator;
348
- };
349
- export default createThunk;
@@ -1,47 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
6
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
7
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- /*
14
- Task: https://scaleflexhq.atlassian.net/browse/FRA-4340
15
-
16
- Julian, [27 Jan 2024 at 06:47:04 (27 Jan 2024 at 06:48:19)]:
17
- I think the debugging would be much easier so it wil make save time to all PO, QA, etc. — so overall I think it's a very impactful todo
18
-
19
- In general, chars that need to be URL encoded are spaces, very special characters like:
20
- — # bcs it's the anchor
21
- — % bcs it's the start of an url encoded,
22
- — & of course bcs it's param delimiter
23
- — and + since it means an encoded-space
24
- — and maybe other non-printable ASCII characters
25
-
26
- but for our cases here, things like >, <, / .., : etc don't need to be URL-encoded
27
- maybe a way to make this todo very very simple first at low risk is simply to "re-encode" 2 chars :
28
- %2F -> /
29
- %2C -> :
30
- %3A -> ,
31
-
32
- I think just this will fix 98% of our QA-PO- etc misunderstanding and make debugging much easier
33
- when people look at Network console and copy paste things
34
- */
35
-
36
- export var customEncodeURIComponent = function customEncodeURIComponent(str, opts) {
37
- if (!str || typeof str !== 'string') {
38
- return str;
39
- }
40
- var options = _objectSpread({
41
- ignoreSymbols: [':', ',', '.', '@', '=', '+']
42
- }, opts || {});
43
- var ignoreSymbols = options.ignoreSymbols || [];
44
- return Array.isArray(ignoreSymbols) && ignoreSymbols.length > 0 ? _toConsumableArray(str).map(function (_char) {
45
- return ignoreSymbols.includes(_char) ? _char : encodeURIComponent(_char);
46
- }).join('') : encodeURIComponent(str);
47
- };
@@ -1,33 +0,0 @@
1
- export default function dataURItoBlob(dataURI, opts, toFile) {
2
- // get the base64 data
3
- var data = dataURI.split(',')[1];
4
-
5
- // user may provide mime type, if not get it from data URI
6
- var mimeType = opts.mimeType || dataURI.split(',')[0].split(':')[1].split(';')[0];
7
-
8
- // default to plain/text if data URI has no mimeType
9
- if (mimeType == null) {
10
- mimeType = 'plain/text';
11
- }
12
- var binary = atob(data);
13
- var array = [];
14
- for (var i = 0; i < binary.length; i++) {
15
- array.push(binary.charCodeAt(i));
16
- }
17
- var bytes;
18
- try {
19
- bytes = new Uint8Array(array); // eslint-disable-line compat/compat
20
- } catch (err) {
21
- return null;
22
- }
23
-
24
- // Convert to a File?
25
- if (toFile) {
26
- return new File([bytes], opts.name || '', {
27
- type: mimeType
28
- });
29
- }
30
- return new Blob([bytes], {
31
- type: mimeType
32
- });
33
- }
@@ -1,4 +0,0 @@
1
- import dataURItoBlob from './dataURItoBlob';
2
- export default function dataURItoFile(dataURI, opts) {
3
- return dataURItoBlob(dataURI, opts, true);
4
- }
@@ -1,20 +0,0 @@
1
- var dateStrToClearDateTime = function dateStrToClearDateTime(_ref) {
2
- var dateStr = _ref.dateStr,
3
- _ref$locale = _ref.locale,
4
- locale = _ref$locale === void 0 ? 'en-US' : _ref$locale,
5
- _ref$options = _ref.options,
6
- options = _ref$options === void 0 ? {
7
- dateStyle: 'long',
8
- timeStyle: 'short'
9
- } : _ref$options;
10
- if (!dateStr) {
11
- return '';
12
- }
13
- try {
14
- var date = new Date(dateStr);
15
- return !isNaN(date) ? date.toLocaleString(locale, options) : '';
16
- } catch (e) {
17
- return '';
18
- }
19
- };
20
- export default dateStrToClearDateTime;
package/lib/debounce.js DELETED
@@ -1,14 +0,0 @@
1
- var timeout;
2
- var debounce = function debounce(func, waitMs) {
3
- return function () {
4
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5
- args[_key] = arguments[_key];
6
- }
7
- clearTimeout(timeout);
8
- timeout = setTimeout(function () {
9
- timeout = null;
10
- func.apply(void 0, args);
11
- }, waitMs);
12
- };
13
- };
14
- export default debounce;
package/lib/deepEqual.js DELETED
@@ -1,23 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _deepEqual = function deepEqual(obj1, obj2) {
3
- var considerNull = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4
- if (obj1 === obj2 || !obj1 && !obj2 && _typeof(obj1) === _typeof(obj2)) {
5
- return true;
6
- }
7
- if (_typeof(obj1) !== 'object' || _typeof(obj2) !== 'object' || considerNull && (obj1 === null || obj2 === null)) {
8
- return false;
9
- }
10
- var keys1 = Object.keys(obj1 || {});
11
- var keys2 = Object.keys(obj2 || {});
12
- if (keys1.length !== keys2.length) {
13
- return false;
14
- }
15
- for (var _i = 0, _keys = keys1; _i < _keys.length; _i++) {
16
- var key = _keys[_i];
17
- if (!keys2.includes(key) || !_deepEqual(obj1[key], obj2[key])) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- };
23
- export default _deepEqual;
package/lib/deepMerge.js DELETED
@@ -1,56 +0,0 @@
1
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
11
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
- var _deepMerge = function deepMerge(source) {
14
- var object = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16
- var _ref = options || {},
17
- _ref$considerArray = _ref.considerArray,
18
- considerArray = _ref$considerArray === void 0 ? false : _ref$considerArray,
19
- _ref$removeFromArray = _ref.removeFromArray,
20
- removeFromArray = _ref$removeFromArray === void 0 ? false : _ref$removeFromArray,
21
- _ref$dismissArrayIfSo = _ref.dismissArrayIfSourceNotArray,
22
- dismissArrayIfSourceNotArray = _ref$dismissArrayIfSo === void 0 ? false : _ref$dismissArrayIfSo,
23
- defaultValueIfNull = _ref.defaultValueIfNull;
24
- if (_typeof(source) === 'object' && Object.keys(source).length === 0) {
25
- return _objectSpread({}, object);
26
- }
27
- var mergedObject = _objectSpread({}, source);
28
- var keys = Object.keys(object);
29
- keys.forEach(function (k) {
30
- // considers null in the values.
31
- var val = object[k];
32
- if (val !== undefined) {
33
- var valType = _typeof(val);
34
- if (valType !== 'object' || val === null || Array.isArray(val) || !source[k] || _typeof(source[k]) !== 'object') {
35
- if (dismissArrayIfSourceNotArray && !Array.isArray(mergedObject[k])) {
36
- return;
37
- }
38
- if (considerArray && Array.isArray(mergedObject[k]) && Array.isArray(val)) {
39
- if (removeFromArray) {
40
- mergedObject[k] = mergedObject[k].filter(function (item) {
41
- return !val.includes(item);
42
- });
43
- } else mergedObject[k] = [].concat(_toConsumableArray(mergedObject[k]), _toConsumableArray(val));
44
- } else {
45
- mergedObject[k] = val === null ? defaultValueIfNull !== null && defaultValueIfNull !== void 0 ? defaultValueIfNull : val : val;
46
- }
47
- return;
48
- }
49
-
50
- // After the above condition we now have both of them in type objects.
51
- mergedObject[k] = _deepMerge(source[k], val, options);
52
- }
53
- });
54
- return mergedObject;
55
- };
56
- export default _deepMerge;
@@ -1,5 +0,0 @@
1
- // eslint-disable-next-line no-new-func
2
- var deserializeFunction = function deserializeFunction(fnString) {
3
- return new Function("return ".concat(fnString))();
4
- };
5
- export default deserializeFunction;
@@ -1,2 +0,0 @@
1
- var DocumentMimeTypes = ['application/msword', 'application/vnd.ms-word.document.macroenabled.12', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/msword', 'application/vnd.ms-word.template.macroenabled.12', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/vnd.ms-excel', 'application/vnd.ms-excel.addin.macroenabled.12', 'application/vnd.ms-excel', 'application/x-xliff+xml', 'application/vnd.ms-excel', 'application/vnd.ms-excel', 'application/vnd.ms-excel.sheet.binary.macroenabled.12', 'application/vnd.ms-excel.sheet.macroenabled.12', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel', 'application/vnd.ms-excel.template.macroenabled.12', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'application/vnd.ms-excel', 'application/pdf'];
2
- export default DocumentMimeTypes;
@@ -1,16 +0,0 @@
1
- var downloadFromBlob = function downloadFromBlob(blob) {
2
- var fileNameAndExtension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Downloaded by Filerobot - ".concat(Date.now(), ".zip");
3
- if (!blob || blob.size === 0) {
4
- return;
5
- }
6
- var tempFileUrl = URL.createObjectURL(blob);
7
- var tempFileElem = document.createElement('a');
8
- tempFileElem.setAttribute('href', tempFileUrl);
9
- tempFileElem.setAttribute('download', fileNameAndExtension);
10
- tempFileElem.style = 'position: absolute; z-index: -1111; left: -1111%; top: -1111%';
11
- document.body.appendChild(tempFileElem);
12
- tempFileElem.click();
13
- document.body.removeChild(tempFileElem);
14
- URL.revokeObjectURL(tempFileUrl);
15
- };
16
- export default downloadFromBlob;
@@ -1,18 +0,0 @@
1
- import throttle from 'lodash.throttle';
2
- function _emitSocketProgress(filerobot, progressData, file) {
3
- var progress = progressData.progress,
4
- bytesUploaded = progressData.bytesUploaded,
5
- bytesTotal = progressData.bytesTotal;
6
- if (progress) {
7
- filerobot.filerobot.log("Upload progress: ".concat(progress));
8
- filerobot.filerobot.emit('upload-progress', file, {
9
- filerobot: filerobot,
10
- bytesFinished: bytesUploaded,
11
- bytesTotal: bytesTotal
12
- });
13
- }
14
- }
15
- export default throttle(_emitSocketProgress, 300, {
16
- leading: true,
17
- trailing: true
18
- });
@@ -1,4 +0,0 @@
1
- export function escapeRegExp(string) {
2
- return (string || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
3
- }
4
- export default escapeRegExp;
@@ -1,12 +0,0 @@
1
- var extractFileDataNoBlob = function extractFileDataNoBlob() {
2
- var fileData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3
- return {
4
- size: fileData.size,
5
- type: fileData.type,
6
- name: fileData.name,
7
- lastModified: fileData.lastModified,
8
- webkitRelativePath: fileData.webkitRelativePath,
9
- relativePath: fileData.relativePath
10
- };
11
- };
12
- export default extractFileDataNoBlob;
@@ -1,14 +0,0 @@
1
- import NetworkError from '@scaleflex/widget-utils/lib/NetworkError';
2
-
3
- /**
4
- * Wrapper around window.fetch that throws a NetworkError when appropriate
5
- */
6
- export default function fetchWithNetworkError() {
7
- return fetch.apply(void 0, arguments)["catch"](function (err) {
8
- if (err.name === 'AbortError') {
9
- throw err;
10
- } else {
11
- throw new NetworkError(err);
12
- }
13
- });
14
- }