@uploadcare/file-uploader 1.13.0-alpha.3 → 1.13.1-alpha.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 (127) hide show
  1. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  2. package/abstract/UploaderPublicApi.js +4 -11
  3. package/blocks/CameraSource/CameraSource.d.ts +12 -22
  4. package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
  5. package/blocks/CameraSource/CameraSource.js +81 -83
  6. package/blocks/CameraSource/camera-source.css +1 -0
  7. package/blocks/CameraSource/constants.d.ts +15 -0
  8. package/blocks/CameraSource/constants.d.ts.map +1 -0
  9. package/blocks/CameraSource/constants.js +17 -0
  10. package/blocks/CloudImageEditor/src/CropFrame.d.ts +0 -7
  11. package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -1
  12. package/blocks/CloudImageEditor/src/CropFrame.js +0 -50
  13. package/blocks/CloudImageEditor/src/css/common.css +0 -4
  14. package/blocks/CloudImageEditor/src/lib/parseTabs.js +2 -2
  15. package/blocks/Config/Config.d.ts +3 -3
  16. package/blocks/Config/Config.d.ts.map +1 -1
  17. package/blocks/Config/Config.js +13 -3
  18. package/blocks/Config/assertions.d.ts +5 -0
  19. package/blocks/Config/assertions.d.ts.map +1 -0
  20. package/blocks/Config/assertions.js +37 -0
  21. package/blocks/Config/initialConfig.d.ts.map +1 -1
  22. package/blocks/Config/initialConfig.js +4 -5
  23. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  24. package/blocks/Config/normalizeConfigValue.js +20 -8
  25. package/blocks/Config/side-effects.d.ts +7 -0
  26. package/blocks/Config/side-effects.d.ts.map +1 -0
  27. package/blocks/Config/side-effects.js +32 -0
  28. package/blocks/FileItem/FileItem.d.ts +4 -0
  29. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  30. package/blocks/FileItem/FileItem.js +22 -2
  31. package/blocks/ProgressBar/ProgressBar.d.ts +2 -0
  32. package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
  33. package/blocks/ProgressBar/ProgressBar.js +37 -9
  34. package/blocks/ProgressBar/progress-bar.css +35 -1
  35. package/blocks/UploadList/upload-list.css +1 -0
  36. package/blocks/utils/comma-separated.d.ts +1 -1
  37. package/blocks/utils/comma-separated.d.ts.map +1 -1
  38. package/blocks/utils/comma-separated.js +5 -2
  39. package/env.d.ts +1 -1
  40. package/env.js +1 -1
  41. package/index.ssr.d.ts +1 -15
  42. package/index.ssr.d.ts.map +1 -1
  43. package/index.ssr.js +11 -18
  44. package/locales/file-uploader/ar.d.ts +1 -0
  45. package/locales/file-uploader/ar.js +1 -0
  46. package/locales/file-uploader/az.d.ts +1 -0
  47. package/locales/file-uploader/az.js +1 -0
  48. package/locales/file-uploader/ca.d.ts +1 -0
  49. package/locales/file-uploader/ca.js +1 -0
  50. package/locales/file-uploader/cs.d.ts +1 -0
  51. package/locales/file-uploader/cs.js +1 -0
  52. package/locales/file-uploader/da.d.ts +1 -0
  53. package/locales/file-uploader/da.js +1 -0
  54. package/locales/file-uploader/de.d.ts +1 -0
  55. package/locales/file-uploader/de.js +1 -0
  56. package/locales/file-uploader/el.d.ts +1 -0
  57. package/locales/file-uploader/el.js +1 -0
  58. package/locales/file-uploader/en.d.ts +1 -0
  59. package/locales/file-uploader/en.js +2 -1
  60. package/locales/file-uploader/es.d.ts +1 -0
  61. package/locales/file-uploader/es.js +1 -0
  62. package/locales/file-uploader/et.d.ts +1 -0
  63. package/locales/file-uploader/et.js +1 -0
  64. package/locales/file-uploader/fi.d.ts +1 -0
  65. package/locales/file-uploader/fi.js +1 -0
  66. package/locales/file-uploader/fr.d.ts +1 -0
  67. package/locales/file-uploader/fr.js +1 -0
  68. package/locales/file-uploader/he.d.ts +1 -0
  69. package/locales/file-uploader/he.js +1 -0
  70. package/locales/file-uploader/hy.d.ts +1 -0
  71. package/locales/file-uploader/hy.js +1 -0
  72. package/locales/file-uploader/is.d.ts +1 -0
  73. package/locales/file-uploader/is.js +1 -0
  74. package/locales/file-uploader/it.d.ts +1 -0
  75. package/locales/file-uploader/it.js +1 -0
  76. package/locales/file-uploader/ja.d.ts +1 -0
  77. package/locales/file-uploader/ja.js +1 -0
  78. package/locales/file-uploader/ka.d.ts +1 -0
  79. package/locales/file-uploader/ka.js +1 -0
  80. package/locales/file-uploader/kk.d.ts +1 -0
  81. package/locales/file-uploader/kk.js +1 -0
  82. package/locales/file-uploader/ko.d.ts +1 -0
  83. package/locales/file-uploader/ko.js +1 -0
  84. package/locales/file-uploader/lv.d.ts +1 -0
  85. package/locales/file-uploader/lv.js +1 -0
  86. package/locales/file-uploader/nb.d.ts +1 -0
  87. package/locales/file-uploader/nb.js +1 -0
  88. package/locales/file-uploader/nl.d.ts +1 -0
  89. package/locales/file-uploader/nl.js +1 -0
  90. package/locales/file-uploader/pl.d.ts +1 -0
  91. package/locales/file-uploader/pl.js +1 -0
  92. package/locales/file-uploader/pt.d.ts +1 -0
  93. package/locales/file-uploader/pt.js +1 -0
  94. package/locales/file-uploader/ro.d.ts +1 -0
  95. package/locales/file-uploader/ro.js +1 -0
  96. package/locales/file-uploader/ru.d.ts +1 -0
  97. package/locales/file-uploader/ru.js +1 -0
  98. package/locales/file-uploader/sk.d.ts +1 -0
  99. package/locales/file-uploader/sk.js +1 -0
  100. package/locales/file-uploader/sr.d.ts +1 -0
  101. package/locales/file-uploader/sr.js +1 -0
  102. package/locales/file-uploader/sv.d.ts +1 -0
  103. package/locales/file-uploader/sv.js +1 -0
  104. package/locales/file-uploader/tr.d.ts +1 -0
  105. package/locales/file-uploader/tr.js +1 -0
  106. package/locales/file-uploader/uk.d.ts +1 -0
  107. package/locales/file-uploader/uk.js +1 -0
  108. package/locales/file-uploader/vi.d.ts +1 -0
  109. package/locales/file-uploader/vi.js +1 -0
  110. package/locales/file-uploader/zh-TW.d.ts +1 -0
  111. package/locales/file-uploader/zh-TW.js +1 -0
  112. package/locales/file-uploader/zh.d.ts +1 -0
  113. package/locales/file-uploader/zh.js +1 -0
  114. package/package.json +3 -5
  115. package/types/exported.d.ts +81 -66
  116. package/web/file-uploader.iife.min.js +4 -4
  117. package/web/file-uploader.min.js +4 -4
  118. package/web/uc-basic.min.css +1 -1
  119. package/web/uc-cloud-image-editor.min.css +1 -1
  120. package/web/uc-cloud-image-editor.min.js +4 -4
  121. package/web/uc-file-uploader-inline.min.css +1 -1
  122. package/web/uc-file-uploader-inline.min.js +4 -4
  123. package/web/uc-file-uploader-minimal.min.css +1 -1
  124. package/web/uc-file-uploader-minimal.min.js +3 -3
  125. package/web/uc-file-uploader-regular.min.css +1 -1
  126. package/web/uc-file-uploader-regular.min.js +4 -4
  127. package/web/uc-img.min.js +1 -1
@@ -446,54 +446,10 @@ export class CropFrame extends Block {
446
446
  this.ref['svg-el'].style.cursor = hoverThumb ? thumbCursor(hoverThumb.direction) : 'initial';
447
447
  }
448
448
 
449
- /**
450
- * @private
451
- * @param {String} href
452
- */
453
- _createMask(href) {
454
- if (this._frameImage) {
455
- this._frameImage.setAttribute('href', href);
456
- return;
457
- }
458
-
459
- let svg = this.ref['svg-el'];
460
- let fr = document.createDocumentFragment();
461
-
462
- let imageNode = createSvgNode('image', {
463
- href,
464
- });
465
-
466
- imageNode.setAttribute('class', 'uc-cloud-mask');
467
-
468
- fr.appendChild(imageNode);
469
-
470
- svg.appendChild(fr);
471
-
472
- this._frameImage = imageNode;
473
- }
474
-
475
- _updateMask() {
476
- let cropBox = this.$['*cropBox'];
477
-
478
- if (!cropBox || !this._frameImage) {
479
- return;
480
- }
481
-
482
- let { x, y, width, height } = cropBox;
483
-
484
- setSvgNodeAttrs(this._frameImage, {
485
- x,
486
- y,
487
- height,
488
- width,
489
- });
490
- }
491
-
492
449
  /** @private */
493
450
  _render() {
494
451
  this._updateBackdrop();
495
452
  this._updateFrame();
496
- this._updateMask();
497
453
  }
498
454
 
499
455
  /** @param {boolean} visible */
@@ -535,12 +491,6 @@ export class CropFrame extends Block {
535
491
  });
536
492
  });
537
493
 
538
- this.subConfigValue('cloudImageEditorMaskHref', (maskHref) => {
539
- if (maskHref) {
540
- this._createMask(maskHref);
541
- }
542
- });
543
-
544
494
  this.sub('dragging', (dragging) => {
545
495
  if (!this._frameGuides) return;
546
496
  this._frameGuides.setAttribute(
@@ -1190,7 +1190,3 @@ uc-presence-toggle.uc-initial {
1190
1190
  [uc-cloud-image-editor] button:focus-visible {
1191
1191
  outline: 1px auto -webkit-focus-ring-color;
1192
1192
  }
1193
-
1194
- [uc-cloud-image-editor] .uc-cloud-mask {
1195
- pointer-events: none;
1196
- }
@@ -1,12 +1,12 @@
1
1
  // @ts-check
2
2
 
3
- import { deserealizeCsv } from '../../../utils/comma-separated.js';
3
+ import { deserializeCsv } from '../../../utils/comma-separated.js';
4
4
  import { ALL_TABS } from '../toolbar-constants.js';
5
5
 
6
6
  /** @param {string} tabs */
7
7
  export const parseTabs = (tabs) => {
8
8
  if (!tabs) return ALL_TABS;
9
- const tabList = deserealizeCsv(tabs).filter((tab) => ALL_TABS.includes(tab));
9
+ const tabList = deserializeCsv(tabs).filter((tab) => ALL_TABS.includes(tab));
10
10
  if (tabList.length === 0) {
11
11
  return ALL_TABS;
12
12
  }
@@ -9,7 +9,7 @@
9
9
  * 'iconHrefResolver',
10
10
  * 'fileValidators',
11
11
  * 'collectionValidators',
12
- * 'mediaRecorerOptions',
12
+ * 'mediaRecorderOptions',
13
13
  * ]}
14
14
  */
15
15
  export const complexConfigKeys: [
@@ -20,7 +20,7 @@ export const complexConfigKeys: [
20
20
  'iconHrefResolver',
21
21
  'fileValidators',
22
22
  'collectionValidators',
23
- 'mediaRecorerOptions'
23
+ 'mediaRecorderOptions'
24
24
  ];
25
25
  export type Config = import('../../utils/mixinClass.js').MixinClass<typeof ConfigClass, import('../../types').ConfigType>;
26
26
  /** @typedef {import('../../utils/mixinClass.js').MixinClass<typeof ConfigClass, import('../../types').ConfigType>} Config */
@@ -64,6 +64,6 @@ declare class ConfigClass extends Block {
64
64
  }
65
65
  import { Block } from '../../abstract/Block.js';
66
66
  /** Mapping of attribute names to state */
67
- declare const attrStateMapping: Record<"pubkey" | "multiple" | "accept" | "store" | "debug" | "crop-preset" | "secure-expire" | "max-local-file-size-bytes" | "multiple-min" | "multiple-max" | "confirm-upload" | "img-only" | "external-sources-preferred-types" | "external-sources-embed-css" | "camera-mirror" | "camera-capture" | "source-list" | "thumb-size" | "show-empty-list" | "use-local-image-editor" | "use-cloud-image-editor" | "cloud-image-editor-tabs" | "remove-copyright" | "image-shrink" | "modal-scroll-lock" | "modal-backdrop-strokes" | "source-list-wrap" | "remote-tab-session-key" | "cdn-cname" | "base-url" | "social-base-url" | "secure-signature" | "secure-delivery-proxy" | "retry-throttled-request-max-times" | "multipart-min-file-size" | "multipart-chunk-size" | "max-concurrent-requests" | "multipart-max-concurrent-requests" | "multipart-max-attempts" | "check-for-url-duplicates" | "save-url-for-recurrent-uploads" | "group-output" | "user-agent-integration" | "locale-name" | "secure-uploads-expire-threshold" | "default-camera-mode" | "enable-audio-recording" | "enable-video-recording" | "max-video-recording-duration" | "cloud-image-editor-mask-href" | "secureexpire" | "croppreset" | "maxlocalfilesizebytes" | "multiplemin" | "multiplemax" | "confirmupload" | "imgonly" | "externalsourcespreferredtypes" | "externalsourcesembedcss" | "cameramirror" | "cameracapture" | "sourcelist" | "thumbsize" | "showemptylist" | "uselocalimageeditor" | "usecloudimageeditor" | "cloudimageeditortabs" | "removecopyright" | "imageshrink" | "modalscrolllock" | "modalbackdropstrokes" | "sourcelistwrap" | "remotetabsessionkey" | "cdncname" | "baseurl" | "socialbaseurl" | "securesignature" | "securedeliveryproxy" | "retrythrottledrequestmaxtimes" | "multipartminfilesize" | "multipartchunksize" | "maxconcurrentrequests" | "multipartmaxconcurrentrequests" | "multipartmaxattempts" | "checkforurlduplicates" | "saveurlforrecurrentuploads" | "groupoutput" | "useragentintegration" | "localename" | "secureuploadsexpirethreshold" | "defaultcameramode" | "enableaudiorecording" | "enablevideorecording" | "maxvideorecordingduration" | "cloudimageeditormaskhref", string>;
67
+ declare const attrStateMapping: Record<"accept" | "pubkey" | "multiple" | "store" | "debug" | "crop-preset" | "secure-expire" | "max-local-file-size-bytes" | "multiple-min" | "multiple-max" | "confirm-upload" | "img-only" | "external-sources-preferred-types" | "external-sources-embed-css" | "camera-mirror" | "camera-capture" | "source-list" | "thumb-size" | "show-empty-list" | "use-local-image-editor" | "use-cloud-image-editor" | "cloud-image-editor-tabs" | "remove-copyright" | "image-shrink" | "modal-scroll-lock" | "modal-backdrop-strokes" | "source-list-wrap" | "remote-tab-session-key" | "cdn-cname" | "base-url" | "social-base-url" | "secure-signature" | "secure-delivery-proxy" | "retry-throttled-request-max-times" | "multipart-min-file-size" | "multipart-chunk-size" | "max-concurrent-requests" | "multipart-max-concurrent-requests" | "multipart-max-attempts" | "check-for-url-duplicates" | "save-url-for-recurrent-uploads" | "group-output" | "user-agent-integration" | "locale-name" | "secure-uploads-expire-threshold" | "camera-modes" | "default-camera-mode" | "enable-audio-recording" | "enable-video-recording" | "max-video-recording-duration" | "secureexpire" | "croppreset" | "maxlocalfilesizebytes" | "multiplemin" | "multiplemax" | "confirmupload" | "imgonly" | "externalsourcespreferredtypes" | "externalsourcesembedcss" | "cameramirror" | "cameracapture" | "sourcelist" | "thumbsize" | "showemptylist" | "uselocalimageeditor" | "usecloudimageeditor" | "cloudimageeditortabs" | "removecopyright" | "imageshrink" | "modalscrolllock" | "modalbackdropstrokes" | "sourcelistwrap" | "remotetabsessionkey" | "cdncname" | "baseurl" | "socialbaseurl" | "securesignature" | "securedeliveryproxy" | "retrythrottledrequestmaxtimes" | "multipartminfilesize" | "multipartchunksize" | "maxconcurrentrequests" | "multipartmaxconcurrentrequests" | "multipartmaxattempts" | "checkforurlduplicates" | "saveurlforrecurrentuploads" | "groupoutput" | "useragentintegration" | "localename" | "secureuploadsexpirethreshold" | "cameramodes" | "defaultcameramode" | "enableaudiorecording" | "enablevideorecording" | "maxvideorecordingduration", string>;
68
68
  export {};
69
69
  //# sourceMappingURL=Config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["Config.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;GAaG;AACH,gCAXU;IACT,UAAc;IACd,0BAA8B;IAC9B,gCAAoC;IACpC,gCAAoC;IACpC,kBAAsB;IACtB,gBAAoB;IACpB,sBAA0B;IAC1B,qBAAyB;CACtB,CAWF;qBAiNY,OAAO,2BAA2B,EAAE,UAAU,CAAC,kBAAkB,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC;AAAlH,6HAA6H;AAG7H,4BAAmF;AAvLnF;IAkBE;;;;OAIG;IACH,+BAYC;IAED;;;;OAIG;IACH,2BAQC;IAED;;;;OAIG;IACH,kBAiBC;IAED;;;OAGG;IACH,kBAIC;IAED;;;;OAIG;IACH,wCAJW,MAAM,iBACN,OAAO,aACP,OAAO,QAoBjB;IA0CD;;;;OAIG;IACH,+BAJW,MAAM,uBAAuB,UAC7B,MAAM,UACN,MAAM,QAahB;CACF;sBAvOqB,yBAAyB;AAsD/C,0CAA0C;AAC1C,moEAGG"}
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["Config.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;GAaG;AACH,gCAXU;IACT,UAAc;IACd,0BAA8B;IAC9B,gCAAoC;IACpC,gCAAoC;IACpC,kBAAsB;IACtB,gBAAoB;IACpB,sBAA0B;IAC1B,sBAA0B;CACvB,CAWF;qBAyNY,OAAO,2BAA2B,EAAE,UAAU,CAAC,kBAAkB,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC;AAAlH,6HAA6H;AAG7H,4BAAmF;AA/LnF;IAkBE;;;;OAIG;IACH,+BAYC;IAED;;;;OAIG;IACH,2BAQC;IAED;;;;OAIG;IACH,kBAyBC;IAED;;;OAGG;IACH,kBAIC;IAED;;;;OAIG;IACH,wCAJW,MAAM,iBACN,OAAO,aACP,OAAO,QAoBjB;IA0CD;;;;OAIG;IACH,+BAJW,MAAM,uBAAuB,UAC7B,MAAM,UACN,MAAM,QAahB;CACF;sBAjPqB,yBAAyB;AAwD/C,0CAA0C;AAC1C,smEAGG"}
@@ -4,6 +4,8 @@ import { initialConfig } from './initialConfig.js';
4
4
  import { sharedConfigKey } from '../../abstract/sharedConfigKey.js';
5
5
  import { toKebabCase } from '../../utils/toKebabCase.js';
6
6
  import { normalizeConfigValue } from './normalizeConfigValue.js';
7
+ import { runAssertions } from './assertions.js';
8
+ import { runSideEffects } from './side-effects.js';
7
9
 
8
10
  const allConfigKeys = /** @type {(keyof import('../../types').ConfigType)[]} */ ([
9
11
  // "debug" option should go first to be able to print debug messages from the very beginning
@@ -21,7 +23,7 @@ const allConfigKeys = /** @type {(keyof import('../../types').ConfigType)[]} */
21
23
  * 'iconHrefResolver',
22
24
  * 'fileValidators',
23
25
  * 'collectionValidators',
24
- * 'mediaRecorerOptions',
26
+ * 'mediaRecorderOptions',
25
27
  * ]}
26
28
  */
27
29
  export const complexConfigKeys = [
@@ -32,7 +34,7 @@ export const complexConfigKeys = [
32
34
  'iconHrefResolver',
33
35
  'fileValidators',
34
36
  'collectionValidators',
35
- 'mediaRecorerOptions',
37
+ 'mediaRecorderOptions',
36
38
  ];
37
39
 
38
40
  /** @type {(key: keyof import('../../types').ConfigType) => key is keyof import('../../types').ConfigComplexType} */
@@ -136,6 +138,14 @@ class ConfigClass extends Block {
136
138
  this._flushValueToState(key, normalizedValue);
137
139
 
138
140
  this.debugPrint(`[uc-config] "${key}"`, normalizedValue);
141
+
142
+ runAssertions(this.cfg);
143
+ runSideEffects({
144
+ key,
145
+ value: normalizedValue ?? null,
146
+ setValue: this._setValue.bind(this),
147
+ getValue: this._getValue.bind(this),
148
+ });
139
149
  }
140
150
 
141
151
  /**
@@ -145,7 +155,7 @@ class ConfigClass extends Block {
145
155
  _getValue(key) {
146
156
  const anyThis = /** @type {typeof this & any} */ (this);
147
157
  const localPropName = getLocalPropName(key);
148
- return anyThis[localPropName];
158
+ return anyThis[localPropName] ?? this.$[sharedConfigKey(key)];
149
159
  }
150
160
 
151
161
  /**
@@ -0,0 +1,5 @@
1
+ /** Runs on every config change and warns about potential issues. */
2
+ export const runAssertions: ((cfg: import('../../types').ConfigType) => void) & {
3
+ cancel: () => void;
4
+ };
5
+ //# sourceMappingURL=assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["assertions.js"],"names":[],"mappings":"AAyBA,oEAAoE;AACpE,mCACc,OAAO,aAAa,EAAE,UAAU;;EAS5C"}
@@ -0,0 +1,37 @@
1
+ import { warnOnce } from '../../utils/warnOnce.js';
2
+ import { debounce } from '../utils/debounce.js';
3
+
4
+ const ASSERTIONS = [
5
+ {
6
+ test: (cfg) => cfg.accept && !!cfg.imgOnly,
7
+ message:
8
+ 'There could be a mistake.\n' +
9
+ 'Both `accept` and `imgOnly` parameters are set.\n' +
10
+ 'The value of `accept` will be concatenated with the internal image mime types list.',
11
+ },
12
+ {
13
+ test: (cfg) => cfg.enableVideoRecording !== null,
14
+ message:
15
+ 'The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\n' +
16
+ 'Please use the `cameraModes` parameter instead.',
17
+ },
18
+ {
19
+ test: (cfg) => cfg.defaultCameraMode !== null,
20
+ message:
21
+ 'The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\n' +
22
+ 'Please use the `cameraModes` parameter instead.',
23
+ },
24
+ ];
25
+
26
+ /** Runs on every config change and warns about potential issues. */
27
+ export const runAssertions = debounce(
28
+ /** @param {import('../../types').ConfigType} cfg */
29
+ (cfg) => {
30
+ for (const { test, message } of ASSERTIONS) {
31
+ if (test(cfg)) {
32
+ warnOnce(message);
33
+ }
34
+ }
35
+ },
36
+ 0,
37
+ );
@@ -1 +1 @@
1
- {"version":3,"file":"initialConfig.d.ts","sourceRoot":"","sources":["initialConfig.js"],"names":[],"mappings":"AAKA,uDAAwD;AACxD,+DAAgE;AAChE,sEAAuE;AAEvE,wDAAwD;AACxD,4BADW,OAAO,sBAAsB,EAAE,UAAU,CAoElD"}
1
+ {"version":3,"file":"initialConfig.d.ts","sourceRoot":"","sources":["initialConfig.js"],"names":[],"mappings":"AAKA,uDAAwD;AACxD,+DAAgE;AAChE,sEAAuE;AAEvE,wDAAwD;AACxD,4BADW,OAAO,sBAAsB,EAAE,UAAU,CAmElD"}
@@ -68,11 +68,10 @@ export const initialConfig = {
68
68
  fileValidators: [],
69
69
  collectionValidators: [],
70
70
 
71
- defaultCameraMode: 'photo',
71
+ cameraModes: 'photo, video',
72
+ defaultCameraMode: null,
72
73
  enableAudioRecording: true,
73
- enableVideoRecording: true,
74
+ enableVideoRecording: null,
74
75
  maxVideoRecordingDuration: null,
75
- mediaRecorerOptions: null,
76
-
77
- cloudImageEditorMaskHref: null,
76
+ mediaRecorderOptions: null,
78
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeConfigValue.d.ts","sourceRoot":"","sources":["normalizeConfigValue.js"],"names":[],"mappings":"AAeO,iCADK,OAAO,WAWlB;AA8JM,sGAHI,OAAO,mDAcjB"}
1
+ {"version":3,"file":"normalizeConfigValue.d.ts","sourceRoot":"","sources":["normalizeConfigValue.js"],"names":[],"mappings":"AAiBO,iCADK,OAAO,WAWlB;AAwKM,sGAHI,OAAO,mDAcjB"}
@@ -1,5 +1,7 @@
1
1
  // @ts-check
2
2
 
3
+ import { CameraSourceTypes } from '../CameraSource/constants.js';
4
+ import { deserializeCsv } from '../utils/comma-separated.js';
3
5
  import { initialConfig } from './initialConfig.js';
4
6
 
5
7
  /** @param {unknown} value */
@@ -31,18 +33,28 @@ const asStore = (value) => (value === 'auto' ? value : asBoolean(value));
31
33
  const asCameraCapture = (value) => {
32
34
  const strValue = asString(value);
33
35
  if (strValue !== 'user' && strValue !== 'environment' && strValue !== '') {
34
- throw new Error(`Invalid "cameraCapture" value: "${strValue}"`);
36
+ throw new Error(`Invalid value: "${strValue}"`);
35
37
  }
36
38
  return strValue;
37
39
  };
38
40
 
39
41
  /** @param {unknown} value */
40
- const asCameraTab = (value) => {
42
+ const asCameraMode = (value) => {
41
43
  const strValue = asString(value);
42
- if (strValue !== 'photo' && strValue !== 'video') {
43
- throw new Error(`Invalid "CameraTab" value: "${strValue}"`);
44
+ if (!Object.values(CameraSourceTypes).includes(strValue)) {
45
+ throw new Error(`Invalid value: "${strValue}"`);
44
46
  }
45
- return strValue;
47
+ return /** @type {import('../CameraSource/CameraSource.js').CameraMode} */ (strValue);
48
+ };
49
+
50
+ /** @param {unknown} value */
51
+ const asCameraModes = (value) => {
52
+ const str = asString(value);
53
+ const array = deserializeCsv(str);
54
+ if (array.some((item) => !Object.values(CameraSourceTypes).includes(item))) {
55
+ throw new Error(`Invalid value: "${JSON.stringify(array)}"`);
56
+ }
57
+ return str;
46
58
  };
47
59
 
48
60
  /** @param {unknown} value */
@@ -166,13 +178,13 @@ const mapping = {
166
178
  fileValidators: /** @type {typeof asArray<import('../../types').FileValidators>} */ (asArray),
167
179
  collectionValidators: /** @type {typeof asArray<import('../../types').CollectionValidators>} */ (asArray),
168
180
 
169
- defaultCameraMode: asCameraTab,
181
+ cameraModes: asCameraModes,
182
+ defaultCameraMode: asCameraMode,
170
183
  enableAudioRecording: asBoolean,
171
184
  enableVideoRecording: asBoolean,
172
- mediaRecorerOptions: asObject,
185
+ mediaRecorderOptions: asObject,
173
186
 
174
187
  maxVideoRecordingDuration: asNumber,
175
- cloudImageEditorMaskHref: asString,
176
188
  };
177
189
 
178
190
  /**
@@ -0,0 +1,7 @@
1
+ export function runSideEffects<T extends keyof import("../../types").ConfigType>({ key, value, setValue, getValue }: {
2
+ key: T;
3
+ value: import("../../types").ConfigType[T];
4
+ setValue: (key: T, value: import("../../types").ConfigType[T]) => void;
5
+ getValue: (key: T) => import("../../types").ConfigType[T];
6
+ }): void;
7
+ //# sourceMappingURL=side-effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-effects.d.ts","sourceRoot":"","sources":["side-effects.js"],"names":[],"mappings":"AAWO;;;sEAJgE,IAAI;;SAwB1E"}
@@ -0,0 +1,32 @@
1
+ import { deserializeCsv, serializeCsv } from '../utils/comma-separated.js';
2
+
3
+ /**
4
+ * @template {keyof import('../../types').ConfigType} T
5
+ * @param {{
6
+ * key: T;
7
+ * value: import('../../types').ConfigType[T];
8
+ * setValue: (key: T, value: import('../../types').ConfigType[T]) => void;
9
+ * getValue: (key: T) => import('../../types').ConfigType[T];
10
+ * }} options
11
+ */
12
+ export const runSideEffects = ({ key, value, setValue, getValue }) => {
13
+ if (key === 'enableVideoRecording' && value !== null) {
14
+ let cameraModes = deserializeCsv(getValue('cameraModes'));
15
+ if (value && !cameraModes.includes('video')) {
16
+ cameraModes = cameraModes.concat('video');
17
+ } else if (!value) {
18
+ cameraModes = cameraModes.filter((mode) => mode !== 'video');
19
+ }
20
+ setValue('cameraModes', serializeCsv(cameraModes));
21
+ }
22
+
23
+ if (key === 'defaultCameraMode' && value !== null) {
24
+ let cameraModes = deserializeCsv(getValue('cameraModes'));
25
+ cameraModes = cameraModes.sort((a, b) => {
26
+ if (a === value) return -1;
27
+ if (b === value) return 1;
28
+ return 0;
29
+ });
30
+ setValue('cameraModes', serializeCsv(cameraModes));
31
+ }
32
+ };
@@ -18,6 +18,7 @@ export class FileItem extends UploaderBlock {
18
18
  uid: string;
19
19
  itemName: string;
20
20
  errorText: string;
21
+ hint: string;
21
22
  thumbUrl: string;
22
23
  progressValue: number;
23
24
  progressVisible: boolean;
@@ -62,6 +63,9 @@ export class FileItem extends UploaderBlock {
62
63
  * @param {(value: any) => void} handler
63
64
  */
64
65
  private _subEntry;
66
+ _updateHint: (() => void) & {
67
+ readonly cancel: () => void;
68
+ };
65
69
  /**
66
70
  * @private
67
71
  * @param {String} id
@@ -1 +1 @@
1
- {"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["FileItem.js"],"names":[],"mappings":"AAkBA;IAIE,eAAe;IACf,mBAAuB;IACvB;;;OAGG;IACH,eAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,gCAA4E;IAC5E,eAAe;IACf,iCAA0E;IAE1E,eAAe;IACf,sBAAsB;IAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4BC;IAGH,eASC;IAED;;;OAGG;IACH,0BAaC;IAED,eAAe;IACf,wBAgBC;IAED,eAAe;IACf,2BAsCC;IAED;;;;OAIG;IACH,kBAUC;IAED;;;OAGG;IACH,uBAkDC;IAsCD,wEAAwE;IACxE,oBADY,CAAC,oBAAoB,CAAC,CAAC,MAAM,oBAAoB,CAAC,QA0B7D;IAaC,eAAe;IACf,kBAEE;IAWJ;;;MAEC;IAED;;;OAGG;IACH,uBAEC;IAED,wBAsFC;CACF;;;;;8BApa6B,iCAAiC;AAO/D;;;;;GAKG"}
1
+ {"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["FileItem.js"],"names":[],"mappings":"AAoBA;IAIE,eAAe;IACf,mBAAuB;IACvB;;;OAGG;IACH,eAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,gCAA4E;IAC5E,eAAe;IACf,iCAA0E;IAE1E,eAAe;IACf,sBAAsB;IAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BC;IAGH,eASC;IAED;;;OAGG;IACH,0BAaC;IAED,eAAe;IACf,wBAgBC;IAED,eAAe;IACf,2BAsCC;IAED;;;;OAIG;IACH,kBAUC;IAED;;MAaQ;IAER;;;OAGG;IACH,uBAmDC;IAsCD,wEAAwE;IACxE,oBADY,CAAC,oBAAoB,CAAC,CAAC,MAAM,oBAAoB,CAAC,QA0B7D;IAaC,eAAe;IACf,kBAEE;IAWJ;;;MAEC;IAED;;;OAGG;IACH,uBAEC;IAED,wBAsFC;CACF;;;;;8BAvb6B,iCAAiC;AAS/D;;;;;GAKG"}
@@ -8,6 +8,8 @@ import { fileCssBg } from '../svg-backgrounds/svg-backgrounds.js';
8
8
  import { debounce } from '../utils/debounce.js';
9
9
  import { generateThumb } from '../utils/resizeImage.js';
10
10
  import { parseShrink } from '../../utils/parseShrink.js';
11
+ import { UploadSource } from '../utils/UploadSource.js';
12
+ import { throttle } from '../utils/throttle.js';
11
13
 
12
14
  const FileItemState = Object.freeze({
13
15
  FINISHED: Symbol('FINISHED'),
@@ -45,6 +47,7 @@ export class FileItem extends UploaderBlock {
45
47
  uid: '',
46
48
  itemName: '',
47
49
  errorText: '',
50
+ hint: '',
48
51
  thumbUrl: '',
49
52
  progressValue: 0,
50
53
  progressVisible: false,
@@ -178,6 +181,21 @@ export class FileItem extends UploaderBlock {
178
181
  this._entrySubs.add(sub);
179
182
  }
180
183
 
184
+ _updateHint = throttle(() => {
185
+ const showHint =
186
+ this.$.state === FileItemState.UPLOADING &&
187
+ this._entry.getValue('externalUrl') &&
188
+ this._entry.getValue('source') !== UploadSource.URL &&
189
+ this._entry.getValue('errors').length === 0 &&
190
+ this.$.progressValue === 0;
191
+
192
+ const hint = showHint
193
+ ? this.l10n('waiting-for', { source: this.l10n(`src-type-${this._entry.getValue('source')}`) })
194
+ : '';
195
+
196
+ this.$.hint = hint;
197
+ }, 100);
198
+
181
199
  /**
182
200
  * @private
183
201
  * @param {String} id
@@ -195,6 +213,7 @@ export class FileItem extends UploaderBlock {
195
213
 
196
214
  this._subEntry('uploadProgress', (uploadProgress) => {
197
215
  this.$.progressValue = uploadProgress;
216
+ this._updateHint();
198
217
  });
199
218
 
200
219
  this._subEntry('fileName', (name) => {
@@ -280,8 +299,6 @@ export class FileItem extends UploaderBlock {
280
299
 
281
300
  if (state === FileItemState.UPLOADING) {
282
301
  this.$.isFocused = false;
283
- } else {
284
- this.$.progressValue = 0;
285
302
  }
286
303
 
287
304
  this.set$({
@@ -296,6 +313,8 @@ export class FileItem extends UploaderBlock {
296
313
  status: this.l10n(state?.description?.toLocaleLowerCase() ?? '').toLocaleLowerCase(),
297
314
  }),
298
315
  });
316
+
317
+ this._updateHint();
299
318
  }
300
319
 
301
320
  destroyCallback() {
@@ -434,6 +453,7 @@ FileItem.template = /* HTML */ `
434
453
  <div aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;">
435
454
  <span class="uc-file-name" set="@title: itemName">{{itemName}}</span>
436
455
  <span class="uc-file-error" set="@hidden: !errorText">{{errorText}}</span>
456
+ <span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span>
437
457
  </div>
438
458
  <div class="uc-file-actions">
439
459
  <button
@@ -1,6 +1,8 @@
1
1
  export class ProgressBar extends Block {
2
2
  /** @type {Number} */
3
3
  _value: number;
4
+ /** @type {Boolean} */
5
+ _visible: boolean;
4
6
  init$: any;
5
7
  }
6
8
  export namespace ProgressBar {
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"AAEA;IACE,qBAAqB;IACrB,eAAW;IAEX,WAIE;CAyBH;;;;sBAnCqB,yBAAyB"}
1
+ {"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"AAEA;IACE,qBAAqB;IACrB,eAAW;IAEX,sBAAsB;IACtB,kBAAgB;IAEhB,WAIE;CA+CH;;;;sBA5DqB,yBAAyB"}
@@ -4,6 +4,9 @@ export class ProgressBar extends Block {
4
4
  /** @type {Number} */
5
5
  _value = 0;
6
6
 
7
+ /** @type {Boolean} */
8
+ _visible = true;
9
+
7
10
  init$ = {
8
11
  ...this.init$,
9
12
  width: 0,
@@ -13,26 +16,51 @@ export class ProgressBar extends Block {
13
16
  initCallback() {
14
17
  super.initCallback();
15
18
  this.defineAccessor('value', (value) => {
16
- if (value === undefined) {
17
- return;
18
- }
19
+ if (!value) return;
19
20
  const prevValue = this._value;
20
21
  this._value = value;
22
+ if (!this._visible) return;
23
+
24
+ if (value === 100) {
25
+ this.ref.realProgressLine.addEventListener(
26
+ 'transitionend',
27
+ () => {
28
+ this.ref.realProgressLine.classList.toggle('uc-progress--hidden', true);
29
+ },
30
+ {
31
+ once: true,
32
+ },
33
+ );
34
+ }
35
+
36
+ this.ref.fakeProgressLine.classList.toggle('uc-fake-progress--hidden', value !== 0);
21
37
 
22
38
  if (value === 0 && prevValue > 0) {
23
- this.ref.line.addEventListener('transitionend', () => {
24
- this.style.setProperty('--l-width', this._value.toString());
25
- });
39
+ this.ref.realProgressLine.addEventListener(
40
+ 'transitionend',
41
+ () => {
42
+ this.style.setProperty('--l-progress-value', this._value.toString());
43
+ },
44
+ {
45
+ once: true,
46
+ },
47
+ );
26
48
  return;
27
49
  }
28
50
 
29
- this.style.setProperty('--l-width', this._value.toString());
51
+ this.style.setProperty('--l-progress-value', this._value.toString());
30
52
  });
31
53
 
32
54
  this.defineAccessor('visible', (visible) => {
33
- this.ref.line.classList.toggle('uc-progress--hidden', !visible);
55
+ this._visible = visible;
56
+
57
+ this.ref.realProgressLine.classList.toggle('uc-progress--hidden', !visible);
58
+ this.ref.fakeProgressLine.classList.toggle('uc-fake-progress--hidden', !visible);
34
59
  });
35
60
  }
36
61
  }
37
62
 
38
- ProgressBar.template = /* HTML */ ` <div ref="line" class="uc-progress"></div> `;
63
+ ProgressBar.template = /* HTML */ `
64
+ <div ref="fakeProgressLine" class="uc-fake-progress"></div>
65
+ <div ref="realProgressLine" class="uc-progress"></div>
66
+ `;
@@ -1,4 +1,6 @@
1
1
  uc-progress-bar {
2
+ --l-progress-value: 0;
3
+
2
4
  position: absolute;
3
5
  top: 0;
4
6
  bottom: 0;
@@ -10,7 +12,8 @@ uc-progress-bar {
10
12
  }
11
13
 
12
14
  uc-progress-bar .uc-progress {
13
- width: calc(var(--l-width) * 1%);
15
+ position: absolute;
16
+ width: calc(var(--l-progress-value) * 1%);
14
17
  height: 100%;
15
18
  background-color: var(--uc-primary);
16
19
  transform: translateX(0);
@@ -23,3 +26,34 @@ uc-progress-bar .uc-progress {
23
26
  uc-progress-bar .uc-progress--hidden {
24
27
  opacity: 0;
25
28
  }
29
+
30
+ uc-progress-bar .uc-fake-progress {
31
+ --l-fake-progress-width: 30;
32
+
33
+ position: absolute;
34
+ width: calc(var(--l-fake-progress-width) * 1%);
35
+ height: 100%;
36
+ background-color: var(--uc-primary);
37
+ animation: fake-progress-animation 1s ease-in-out infinite;
38
+ opacity: 1;
39
+ transition:
40
+ opacity 0.3s,
41
+ display 1s;
42
+ /* stylelint-disable-next-line property-no-unknown */
43
+ transition-behavior: allow-discrete;
44
+ }
45
+
46
+ uc-progress-bar .uc-fake-progress--hidden {
47
+ opacity: 0;
48
+ display: none;
49
+ }
50
+
51
+ @keyframes fake-progress-animation {
52
+ from {
53
+ transform: translateX(-100%);
54
+ }
55
+
56
+ to {
57
+ transform: translateX(calc(100 / var(--l-fake-progress-width) * 100 * 1%));
58
+ }
59
+ }
@@ -1,4 +1,5 @@
1
1
  uc-upload-list {
2
+ position: relative;
2
3
  display: flex;
3
4
  flex-direction: column;
4
5
  width: 100%;
@@ -1,3 +1,3 @@
1
- export function deserealizeCsv(value: string): string[];
1
+ export function deserializeCsv(value: string): string[];
2
2
  export function serializeCsv(value: unknown[]): string;
3
3
  //# sourceMappingURL=comma-separated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"comma-separated.d.ts","sourceRoot":"","sources":["comma-separated.js"],"names":[],"mappings":"AAGO,sCADK,MAAM,YAOjB;AAGM,oCADK,OAAO,EAAE,UAOpB"}
1
+ {"version":3,"file":"comma-separated.d.ts","sourceRoot":"","sources":["comma-separated.js"],"names":[],"mappings":"AAGO,sCADK,MAAM,YAUjB;AAGM,oCADK,OAAO,EAAE,UAOpB"}
@@ -1,12 +1,15 @@
1
1
  // @ts-check
2
2
 
3
3
  /** @param {string} value */
4
- export const deserealizeCsv = (value) => {
4
+ export const deserializeCsv = (value) => {
5
5
  if (!value) {
6
6
  return [];
7
7
  }
8
8
 
9
- return value.split(',').map((item) => item.trim());
9
+ return value
10
+ .split(',')
11
+ .map((item) => item.trim())
12
+ .filter(Boolean);
10
13
  };
11
14
 
12
15
  /** @param {unknown[]} value */
package/env.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** Do not edit this file manually. It's generated during build process. */
2
2
  export const PACKAGE_NAME: "blocks";
3
- export const PACKAGE_VERSION: "1.12.0";
3
+ export const PACKAGE_VERSION: "1.13.0";
4
4
  //# sourceMappingURL=env.d.ts.map
package/env.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Do not edit this file manually. It's generated during build process. */
2
2
  export const PACKAGE_NAME = 'blocks';
3
- export const PACKAGE_VERSION = '1.12.0';
3
+ export const PACKAGE_VERSION = '1.13.0';