@scaleflex/widget-utils 4.0.7 → 4.3.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 (65) hide show
  1. package/CHANGELOG.md +7278 -7250
  2. package/LICENSE +21 -21
  3. package/README.md +58 -58
  4. package/lib/AbortController.js +2 -2
  5. package/lib/BlurHash/decode.js +4 -4
  6. package/lib/CustomDate.js +27 -27
  7. package/lib/EventTracker.js +3 -3
  8. package/lib/LinkHelper.js +26 -26
  9. package/lib/ProgressTimeout.js +5 -5
  10. package/lib/RateLimitedQueue.js +2 -2
  11. package/lib/TranslationMissingKeysConsoleHelper.js +13 -13
  12. package/lib/Translator.js +39 -39
  13. package/lib/addUrlParams.js +6 -6
  14. package/lib/adjustUpdatedFolders.js +7 -7
  15. package/lib/canvasToBlob.js +5 -5
  16. package/lib/checkItemsSupportExportWithReason.js +5 -5
  17. package/lib/checkPermissions.js +6 -6
  18. package/lib/clsx.js +3 -3
  19. package/lib/convertVideoFileTypeToSupported.js +9 -9
  20. package/lib/copyText.js +10 -10
  21. package/lib/createThunk.js +21 -21
  22. package/lib/customEncodeURIComponent.js +21 -21
  23. package/lib/fetchWithNetworkError.js +2 -2
  24. package/lib/findAllDOMElements.js +5 -5
  25. package/lib/findDOMElement.js +5 -5
  26. package/lib/findIndex.js +2 -2
  27. package/lib/formatDuration.js +8 -8
  28. package/lib/formatResolution.js +9 -9
  29. package/lib/formatSeconds.js +6 -6
  30. package/lib/generateFileId.js +12 -12
  31. package/lib/generateSelectInputPlaceholder.js +6 -6
  32. package/lib/getCloudimagePrefixedUrl.js +6 -6
  33. package/lib/getDateDaysFromNow.js +5 -5
  34. package/lib/getDateString.js +2 -2
  35. package/lib/getDroppedFiles/index.js +8 -8
  36. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getFilesAndDirectoriesFromDirectory.js +7 -7
  37. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/getRelativePath.js +6 -6
  38. package/lib/getDroppedFiles/utils/webkitGetAsEntryApi/index.js +5 -5
  39. package/lib/getFileNameAndExtension.js +5 -5
  40. package/lib/getFormattedPreviewUrl.js +18 -18
  41. package/lib/getHoursAndMinutes.js +4 -4
  42. package/lib/getMetadataMultiSelectQuery.js +6 -6
  43. package/lib/getNormalizedItems.js +15 -15
  44. package/lib/getRandomNumber.js +5 -5
  45. package/lib/getTime.js +2 -2
  46. package/lib/getTimeStamp.js +4 -4
  47. package/lib/handlePromise.js +8 -8
  48. package/lib/humanReadableDate.js +4 -4
  49. package/lib/humanReadableDateWithTranslations.js +2 -2
  50. package/lib/injectVirtualPathToFolders.js +5 -5
  51. package/lib/isDOMElement.js +4 -4
  52. package/lib/isDragDropSupported.js +4 -4
  53. package/lib/isFileSupportedByCloudimage.js +5 -5
  54. package/lib/isMobileDevice.js +5 -5
  55. package/lib/isObjectURL.js +5 -5
  56. package/lib/metadata/checkFieldValidation.js +9 -9
  57. package/lib/metadata/generateItemMetadataState.js +8 -8
  58. package/lib/metadata/generateMetadataDefaultState.js +4 -4
  59. package/lib/metadata/updateValidationErrors.js +8 -8
  60. package/lib/nanoid.js +4 -4
  61. package/lib/recursiveFnCall.js +2 -2
  62. package/lib/removeDuplicatesFromArray.js +9 -9
  63. package/lib/toArray.js +2 -2
  64. package/package.json +3 -3
  65. package/types/index.d.ts +279 -279
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 scaleflex
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 scaleflex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,58 +1,58 @@
1
- # `@scaleflex/widget-utils`
2
-
3
- [![Plugins][plugins-image]](#plugins)
4
- [![Website][filerobot-image]][sfx-url]
5
- [![Version][filerobot-version]][version-url]
6
- [![Scaleflex team][made-by-image]][sfx-url]
7
- [![License][license-image]][license-url]
8
- [![CodeSandbox][codeSandbox-image]][codeSandbox-url]
9
-
10
-
11
- <div align='center'>
12
- <img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
13
- </div>
14
-
15
- A helper NPM package contains all utils used by [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) plugins.
16
-
17
- ## Usage
18
-
19
- ### NPM
20
-
21
- ```bash
22
- npm install --save @scaleflex/widget-utils
23
- ```
24
-
25
- ### YARN
26
-
27
- ```bash
28
- yarn add @scaleflex/widget-utils
29
- ```
30
-
31
- then
32
-
33
- ```js
34
- import getFileLink, { constants } from '@scaleflex/widget-utils'
35
- ...
36
- ...
37
- ...
38
- <TickArrowIcon color="#FFFFFF" onClick={() => console.log('tick')} />
39
- ```
40
-
41
- > Note: Check each function's params from the function's file itself.
42
-
43
-
44
- <!-- Variables -->
45
-
46
- [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-utils
47
- [license-url]: https://opensource.org/licenses/MIT
48
- [sfx-url]: https://www.scaleflex.com/
49
- [version-url]: https://www.npmjs.com/package/@scaleflex/widget-utils
50
- [codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
51
-
52
- [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
53
- [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
54
- [made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
55
- [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
56
- [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
57
- [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-utils?label=Version&style=for-the-badge&logo=npm
58
- [codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
1
+ # `@scaleflex/widget-utils`
2
+
3
+ [![Plugins][plugins-image]](#plugins)
4
+ [![Website][filerobot-image]][sfx-url]
5
+ [![Version][filerobot-version]][version-url]
6
+ [![Scaleflex team][made-by-image]][sfx-url]
7
+ [![License][license-image]][license-url]
8
+ [![CodeSandbox][codeSandbox-image]][codeSandbox-url]
9
+
10
+
11
+ <div align='center'>
12
+ <img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
13
+ </div>
14
+
15
+ A helper NPM package contains all utils used by [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) plugins.
16
+
17
+ ## Usage
18
+
19
+ ### NPM
20
+
21
+ ```bash
22
+ npm install --save @scaleflex/widget-utils
23
+ ```
24
+
25
+ ### YARN
26
+
27
+ ```bash
28
+ yarn add @scaleflex/widget-utils
29
+ ```
30
+
31
+ then
32
+
33
+ ```js
34
+ import getFileLink, { constants } from '@scaleflex/widget-utils'
35
+ ...
36
+ ...
37
+ ...
38
+ <TickArrowIcon color="#FFFFFF" onClick={() => console.log('tick')} />
39
+ ```
40
+
41
+ > Note: Check each function's params from the function's file itself.
42
+
43
+
44
+ <!-- Variables -->
45
+
46
+ [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-utils
47
+ [license-url]: https://opensource.org/licenses/MIT
48
+ [sfx-url]: https://www.scaleflex.com/
49
+ [version-url]: https://www.npmjs.com/package/@scaleflex/widget-utils
50
+ [codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
51
+
52
+ [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
53
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
54
+ [made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
55
+ [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
56
+ [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
57
+ [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-utils?label=Version&style=for-the-badge&logo=npm
58
+ [codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
@@ -1,5 +1,5 @@
1
- /**
2
- * Little AbortController proxy module so we can swap out the implementation easily later.
1
+ /**
2
+ * Little AbortController proxy module so we can swap out the implementation easily later.
3
3
  */
4
4
 
5
5
  import { AbortController, AbortSignal } from 'abortcontroller-polyfill/dist/abortcontroller';
@@ -2,10 +2,10 @@ import { decode83 } from './base83';
2
2
  import { sRGBToLinear, signPow, linearTosRGB } from './utils';
3
3
  import { ValidationError } from './error';
4
4
 
5
- /**
6
- * Returns an error message if invalid or undefined if valid
7
- *
8
- * @param blurhash
5
+ /**
6
+ * Returns an error message if invalid or undefined if valid
7
+ *
8
+ * @param blurhash
9
9
  */
10
10
 
11
11
  var validateBlurhash = function validateBlurhash(blurhash) {
package/lib/CustomDate.js CHANGED
@@ -35,8 +35,8 @@ export var DATE_TIME_OPTIONS = {
35
35
  minute: '2-digit'
36
36
  };
37
37
 
38
- /**
39
- * CustomDate is wrapped Date class created to provide more useful methods.
38
+ /**
39
+ * CustomDate is wrapped Date class created to provide more useful methods.
40
40
  */
41
41
  var CustomDate = /*#__PURE__*/function (_Date) {
42
42
  function CustomDate() {
@@ -47,28 +47,28 @@ var CustomDate = /*#__PURE__*/function (_Date) {
47
47
  return _createClass(CustomDate, [{
48
48
  key: "getUTCOffsetInMinutes",
49
49
  value:
50
- /**
51
- * @returns {number} Timezone offset in minutes for specified date (could be difference according to DST (for ex. CET and CEST time))
50
+ /**
51
+ * @returns {number} Timezone offset in minutes for specified date (could be difference according to DST (for ex. CET and CEST time))
52
52
  */
53
53
  function getUTCOffsetInMinutes() {
54
54
  return -this.getTimezoneOffset();
55
55
  }
56
56
 
57
- /**
58
- * @returns {number} Current timezone offset in hours
57
+ /**
58
+ * @returns {number} Current timezone offset in hours
59
59
  */
60
60
  }, {
61
61
  key: "getHoursString",
62
62
  value:
63
- /**
64
- * @returns {string} Get amount of hours as a 2 symbols string
63
+ /**
64
+ * @returns {string} Get amount of hours as a 2 symbols string
65
65
  */
66
66
  function getHoursString() {
67
67
  return "0".concat(this.getHours()).slice(-2);
68
68
  }
69
69
 
70
- /**
71
- * @returns {string} Get amount of minutes as a 2 symbols string
70
+ /**
71
+ * @returns {string} Get amount of minutes as a 2 symbols string
72
72
  */
73
73
  }, {
74
74
  key: "getMinutesString",
@@ -76,9 +76,9 @@ var CustomDate = /*#__PURE__*/function (_Date) {
76
76
  return "0".concat(this.getMinutes()).slice(-2);
77
77
  }
78
78
 
79
- /**
80
- * Notice! This method send month from 1-12, not the same as getMonth when month count starts from 0
81
- * @returns {string} Get amount of months as a 2 symbols string
79
+ /**
80
+ * Notice! This method send month from 1-12, not the same as getMonth when month count starts from 0
81
+ * @returns {string} Get amount of months as a 2 symbols string
82
82
  */
83
83
  }, {
84
84
  key: "getMonthString",
@@ -86,8 +86,8 @@ var CustomDate = /*#__PURE__*/function (_Date) {
86
86
  return "0".concat(this.getMonth() + 1).slice(-2);
87
87
  }
88
88
 
89
- /**
90
- * @returns {string} Get date as a 2 symbols string
89
+ /**
90
+ * @returns {string} Get date as a 2 symbols string
91
91
  */
92
92
  }, {
93
93
  key: "getDateString",
@@ -95,10 +95,10 @@ var CustomDate = /*#__PURE__*/function (_Date) {
95
95
  return "0".concat(this.getDate()).slice(-2);
96
96
  }
97
97
 
98
- /**
99
- * @param {string} [language="en"]
100
- * @param {string|object} [dateTimeOpts="dateTimeLong"] - Preset name dateTimeLong|dateOnly or opts object for toLocaleTimeString method
101
- * @returns {string} Formatted date and time value, for instance "Apr 8, 2024 12:00 AM"
98
+ /**
99
+ * @param {string} [language="en"]
100
+ * @param {string|object} [dateTimeOpts="dateTimeLong"] - Preset name dateTimeLong|dateOnly or opts object for toLocaleTimeString method
101
+ * @returns {string} Formatted date and time value, for instance "Apr 8, 2024 12:00 AM"
102
102
  */
103
103
  }, {
104
104
  key: "getFormattedDate",
@@ -117,8 +117,8 @@ var CustomDate = /*#__PURE__*/function (_Date) {
117
117
  }], [{
118
118
  key: "getCurrentUTCOffsetInMinutes",
119
119
  value:
120
- /**
121
- * @returns {number} Current timezone offset in minutes
120
+ /**
121
+ * @returns {number} Current timezone offset in minutes
122
122
  */
123
123
  function getCurrentUTCOffsetInMinutes() {
124
124
  return -new Date().getTimezoneOffset();
@@ -129,10 +129,10 @@ var CustomDate = /*#__PURE__*/function (_Date) {
129
129
  return this.getCurrentUTCOffsetInMinutes() / 60;
130
130
  }
131
131
 
132
- /**
133
- * @param {Object} opts
134
- * @param {boolean} [opts.withUTCPrefix=false] - If it's TRUE returned value will be like "UTC+2" otherwise "+2"
135
- * @returns {string} Current timezone offset string like "UTC+2"
132
+ /**
133
+ * @param {Object} opts
134
+ * @param {boolean} [opts.withUTCPrefix=false] - If it's TRUE returned value will be like "UTC+2" otherwise "+2"
135
+ * @returns {string} Current timezone offset string like "UTC+2"
136
136
  */
137
137
  }, {
138
138
  key: "getCurrentUTCOffsetString",
@@ -144,8 +144,8 @@ var CustomDate = /*#__PURE__*/function (_Date) {
144
144
  return "".concat(withUTCPrefix ? 'UTC' : '').concat(offset > -1 ? '+' : '-').concat(offset);
145
145
  }
146
146
 
147
- /**
148
- * @returns {string} TimeZone label, for ex. "Europe/Zagreb"
147
+ /**
148
+ * @returns {string} TimeZone label, for ex. "Europe/Zagreb"
149
149
  */
150
150
  }, {
151
151
  key: "getTimezone",
@@ -10,9 +10,9 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
10
10
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
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
- * Create a wrapper around an event emitter with a `remove` method to remove
15
- * all events that were added using the wrapped emitter.
13
+ /**
14
+ * Create a wrapper around an event emitter with a `remove` method to remove
15
+ * all events that were added using the wrapped emitter.
16
16
  */
17
17
  var EventTracker = /*#__PURE__*/function () {
18
18
  function EventTracker(emitter) {
package/lib/LinkHelper.js CHANGED
@@ -16,17 +16,17 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
16
16
  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); }
17
17
  import getEncodedWrappedUrl from './getEncodedWrappedUrl';
18
18
  var LinkHelper = /*#__PURE__*/function () {
19
- /**
20
- * @param {string} href
19
+ /**
20
+ * @param {string} href
21
21
  */
22
22
  function LinkHelper(_ref) {
23
23
  var href = _ref.href,
24
24
  _ref$wrapEncodeUrl = _ref.wrapEncodeUrl,
25
25
  wrapEncodeUrl = _ref$wrapEncodeUrl === void 0 ? false : _ref$wrapEncodeUrl;
26
26
  _classCallCheck(this, LinkHelper);
27
- /**
28
- * @type {HTMLAnchorElement}
29
- * @private
27
+ /**
28
+ * @type {HTMLAnchorElement}
29
+ * @private
30
30
  */
31
31
  _defineProperty(this, "_link", void 0);
32
32
  this._link = document.createElement('a');
@@ -34,8 +34,8 @@ var LinkHelper = /*#__PURE__*/function () {
34
34
  this._link.href = wrapEncodeUrl ? getEncodedWrappedUrl(href) : href;
35
35
  }
36
36
 
37
- /**
38
- * @returns {HTMLAnchorElement}
37
+ /**
38
+ * @returns {HTMLAnchorElement}
39
39
  */
40
40
  return _createClass(LinkHelper, [{
41
41
  key: "link",
@@ -43,8 +43,8 @@ var LinkHelper = /*#__PURE__*/function () {
43
43
  return this._link;
44
44
  }
45
45
 
46
- /**
47
- * @returns {string}
46
+ /**
47
+ * @returns {string}
48
48
  */
49
49
  }, {
50
50
  key: "href",
@@ -52,8 +52,8 @@ var LinkHelper = /*#__PURE__*/function () {
52
52
  return this._link.href;
53
53
  }
54
54
 
55
- /**
56
- * @returns {string}
55
+ /**
56
+ * @returns {string}
57
57
  */
58
58
  }, {
59
59
  key: "origin",
@@ -61,8 +61,8 @@ var LinkHelper = /*#__PURE__*/function () {
61
61
  return this._link.origin;
62
62
  }
63
63
 
64
- /**
65
- * @returns {string}
64
+ /**
65
+ * @returns {string}
66
66
  */
67
67
  }, {
68
68
  key: "search",
@@ -70,8 +70,8 @@ var LinkHelper = /*#__PURE__*/function () {
70
70
  return this._link.search;
71
71
  }
72
72
 
73
- /**
74
- * @returns {Object}
73
+ /**
74
+ * @returns {Object}
75
75
  */
76
76
  }, {
77
77
  key: "searchParams",
@@ -105,17 +105,17 @@ var LinkHelper = /*#__PURE__*/function () {
105
105
  return _searchParams;
106
106
  }
107
107
 
108
- /**
109
- * @description automatically prepends '?' symbol
110
- * @param {Object} params
111
- * @returns {string}
108
+ /**
109
+ * @description automatically prepends '?' symbol
110
+ * @param {Object} params
111
+ * @returns {string}
112
112
  */
113
113
  }, {
114
114
  key: "transferSearchTo",
115
115
  value:
116
- /**
117
- * @param {string} href
118
- * @returns {string}
116
+ /**
117
+ * @param {string} href
118
+ * @returns {string}
119
119
  */
120
120
  function transferSearchTo(href) {
121
121
  var newLink = document.createElement('a');
@@ -124,10 +124,10 @@ var LinkHelper = /*#__PURE__*/function () {
124
124
  return newLink.href;
125
125
  }
126
126
 
127
- /**
128
- * @description duplicates are replaced by the newer params
129
- * @param {Object} params
130
- * @returns {string} returns href
127
+ /**
128
+ * @description duplicates are replaced by the newer params
129
+ * @param {Object} params
130
+ * @returns {string} returns href
131
131
  */
132
132
  }, {
133
133
  key: "appendSearchParams",
@@ -4,11 +4,11 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
4
4
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
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
- /**
8
- * Helper to abort upload requests if there has not been any progress for `timeout` ms.
9
- * Create an instance using `timer = new ProgressTimeout(10000, onTimeout)`
10
- * Call `timer.progress()` to signal that there has been progress of any kind.
11
- * Call `timer.done()` when the upload has completed.
7
+ /**
8
+ * Helper to abort upload requests if there has not been any progress for `timeout` ms.
9
+ * Create an instance using `timer = new ProgressTimeout(10000, onTimeout)`
10
+ * Call `timer.progress()` to signal that there has been progress of any kind.
11
+ * Call `timer.done()` when the upload has completed.
12
12
  */
13
13
  var ProgressTimeout = /*#__PURE__*/function () {
14
14
  function ProgressTimeout(timeout, timeoutHandler) {
@@ -4,8 +4,8 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
4
4
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
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
- /**
8
- * Array.prototype.findIndex ponyfill for old browsers.
7
+ /**
8
+ * Array.prototype.findIndex ponyfill for old browsers.
9
9
  */
10
10
  function findIndex(array, predicate) {
11
11
  for (var i = 0; i < array.length; i++) {
@@ -15,19 +15,19 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
15
15
  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); }
16
16
  import { I18N_GRID_UUID, I18N_PROD_BASE_URL } from '@scaleflex/widget-utils/lib/constants';
17
17
 
18
- /**
19
- * Class to console log all missing translation keys and generate curl for convenience.
20
- *
21
- * How to use?
22
- * - Create instance for your project:
23
- * const missingKeysConsoleHelper = new TranslationMissingKeysConsoleHelper({ name, gridUuid, ... })
24
- * > Notice! Each project should have only one instance of the class (e.g one instance for Hub and one more for Widget)
25
- * - Run method handleMissingKey each time when missing key detected:
26
- * missingKeysConsoleHelper.handleMissingKey(key, valueOrDefault)
27
- * - Enable console helper by adding localStorage prop "translationMissingKeysConsoleHelperEnabled"=true OR by enabled config
28
- * As the result you should see all missing keys in browser console with generated cURL for convenience.
29
- *
30
- * IMPORTANT! For any updates in the class need to sync and double check Hub project as well!
18
+ /**
19
+ * Class to console log all missing translation keys and generate curl for convenience.
20
+ *
21
+ * How to use?
22
+ * - Create instance for your project:
23
+ * const missingKeysConsoleHelper = new TranslationMissingKeysConsoleHelper({ name, gridUuid, ... })
24
+ * > Notice! Each project should have only one instance of the class (e.g one instance for Hub and one more for Widget)
25
+ * - Run method handleMissingKey each time when missing key detected:
26
+ * missingKeysConsoleHelper.handleMissingKey(key, valueOrDefault)
27
+ * - Enable console helper by adding localStorage prop "translationMissingKeysConsoleHelperEnabled"=true OR by enabled config
28
+ * As the result you should see all missing keys in browser console with generated cURL for convenience.
29
+ *
30
+ * IMPORTANT! For any updates in the class need to sync and double check Hub project as well!
31
31
  */
32
32
  var TranslationMissingKeysConsoleHelper = /*#__PURE__*/function () {
33
33
  function TranslationMissingKeysConsoleHelper() {
package/lib/Translator.js CHANGED
@@ -12,23 +12,23 @@ import has from './hasProperty';
12
12
  // import { sendMissingTranslationToBackend } from './i18n.client'
13
13
  import TranslationMissingKeysConsoleHelper from './TranslationMissingKeysConsoleHelper';
14
14
 
15
- /**
16
- * Translates strings with interpolation & pluralization support.
17
- * Extensible with custom dictionaries and pluralization functions.
18
- *
19
- * Borrows heavily from and inspired by Polyglot https://github.com/airbnb/polyglot.js,
20
- * basically a stripped-down version of it. Differences: pluralization functions are not hardcoded
21
- * and can be easily added among with dictionaries, nested objects are used for pluralization
22
- * as opposed to `||||` delimeter
23
- *
24
- * Usage example: `translator.translate('files_chosen', {smart_count: 3})`
15
+ /**
16
+ * Translates strings with interpolation & pluralization support.
17
+ * Extensible with custom dictionaries and pluralization functions.
18
+ *
19
+ * Borrows heavily from and inspired by Polyglot https://github.com/airbnb/polyglot.js,
20
+ * basically a stripped-down version of it. Differences: pluralization functions are not hardcoded
21
+ * and can be easily added among with dictionaries, nested objects are used for pluralization
22
+ * as opposed to `||||` delimeter
23
+ *
24
+ * Usage example: `translator.translate('files_chosen', {smart_count: 3})`
25
25
  */
26
26
 
27
27
  var sentKeys = {};
28
28
  var missingKeysConsoleHelper = new TranslationMissingKeysConsoleHelper();
29
29
  var Translator = /*#__PURE__*/function () {
30
- /**
31
- * @param {object|Array<object>} locales - locale or list of locales.
30
+ /**
31
+ * @param {object|Array<object>} locales - locale or list of locales.
32
32
  */
33
33
  function Translator(locales) {
34
34
  var _this = this;
@@ -70,16 +70,16 @@ var Translator = /*#__PURE__*/function () {
70
70
  this.locale.pluralize = locale.pluralize || prevLocale.pluralize;
71
71
  }
72
72
 
73
- /**
74
- * Takes a string with placeholder variables like `%{smart_count} file selected`
75
- * and replaces it with values from options `{smart_count: 5}`
76
- *
77
- * @license https://github.com/airbnb/polyglot.js/blob/master/LICENSE
78
- * taken from https://github.com/airbnb/polyglot.js/blob/master/lib/polyglot.js#L299
79
- *
80
- * @param {string} phrase that needs interpolation, with placeholders
81
- * @param {object} options with values that will be used to replace placeholders
82
- * @returns {string} interpolated
73
+ /**
74
+ * Takes a string with placeholder variables like `%{smart_count} file selected`
75
+ * and replaces it with values from options `{smart_count: 5}`
76
+ *
77
+ * @license https://github.com/airbnb/polyglot.js/blob/master/LICENSE
78
+ * taken from https://github.com/airbnb/polyglot.js/blob/master/lib/polyglot.js#L299
79
+ *
80
+ * @param {string} phrase that needs interpolation, with placeholders
81
+ * @param {object} options with values that will be used to replace placeholders
82
+ * @returns {string} interpolated
83
83
  */
84
84
  }, {
85
85
  key: "interpolate",
@@ -121,12 +121,12 @@ var Translator = /*#__PURE__*/function () {
121
121
  }
122
122
  }
123
123
 
124
- /**
125
- * Public translate method
126
- *
127
- * @param {string} key
128
- * @param {object} options with values that will be used later to replace placeholders in string
129
- * @returns {string} translated (and interpolated)
124
+ /**
125
+ * Public translate method
126
+ *
127
+ * @param {string} key
128
+ * @param {object} options with values that will be used later to replace placeholders in string
129
+ * @returns {string} translated (and interpolated)
130
130
  */
131
131
  }, {
132
132
  key: "translate",
@@ -135,14 +135,14 @@ var Translator = /*#__PURE__*/function () {
135
135
  return (_this$translateArray = this.translateArray(key, options)) === null || _this$translateArray === void 0 ? void 0 : _this$translateArray.join('');
136
136
  }
137
137
 
138
- /**
139
- * Get a translation and return the translated and interpolated parts as an array.
140
- *
141
- * @param {string} key
142
- * @param {object} options with values that will be used to replace placeholders or default string value if key doesn't have value
143
- * - string => used as default value
144
- * - object => uses the `default` property as the translation default value and others for placeholder.
145
- * @returns {Array} The translated and interpolated parts, in order.
138
+ /**
139
+ * Get a translation and return the translated and interpolated parts as an array.
140
+ *
141
+ * @param {string} key
142
+ * @param {object} options with values that will be used to replace placeholders or default string value if key doesn't have value
143
+ * - string => used as default value
144
+ * - object => uses the `default` property as the translation default value and others for placeholder.
145
+ * @returns {Array} The translated and interpolated parts, in order.
146
146
  */
147
147
  }, {
148
148
  key: "translateArray",
@@ -161,9 +161,9 @@ var Translator = /*#__PURE__*/function () {
161
161
  if (key && Translator.BACKEND_TRANSLATIONS && !Translator.BACKEND_TRANSLATIONS[key] && !sentKeys[key]) {
162
162
  var valueOrDefaultWithStrPlural = hasPluralForms ? JSON.stringify(valueOrDefault) : valueOrDefault;
163
163
 
164
- /**
165
- * Auto translations disabled. Should be used manual creation instead of that.
166
- * As a helper could be used "Missing keys Console Helper" -- https://scaleflexhq.atlassian.net/wiki/spaces/FIL/pages/594444447/Hub+Widget+projects+translations#Missing-keys-Console-Helper
164
+ /**
165
+ * Auto translations disabled. Should be used manual creation instead of that.
166
+ * As a helper could be used "Missing keys Console Helper" -- https://scaleflexhq.atlassian.net/wiki/spaces/FIL/pages/594444447/Hub+Widget+projects+translations#Missing-keys-Console-Helper
167
167
  */
168
168
  // if (!Translator.IS_DEV) {
169
169
  // sendMissingTranslationToBackend({
@@ -4,12 +4,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
4
4
  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; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
- /**
8
- * Check if the passed url has query params already or not and based on this add ?newProp=value or &newProp=value
9
- * to the url.
10
- * @param {string} url - any valid URL
11
- * @param {object | string} newParams - new parameters to be added to the url as query param { newParam: value, newParam2: value2 } or 'newProp=value&newProp2=value2...'
12
- * @returns {string} - url with newProp added to it
7
+ /**
8
+ * Check if the passed url has query params already or not and based on this add ?newProp=value or &newProp=value
9
+ * to the url.
10
+ * @param {string} url - any valid URL
11
+ * @param {object | string} newParams - new parameters to be added to the url as query param { newParam: value, newParam2: value2 } or 'newProp=value&newProp2=value2...'
12
+ * @returns {string} - url with newProp added to it
13
13
  */
14
14
  export default (function () {
15
15
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';