@uploadcare/file-uploader 1.15.0-alpha.8 → 1.15.0-alpha.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ActivityBlock.d.ts","sourceRoot":"","sources":["ActivityBlock.js"],"names":[],"mappings":"AASA;;;;;GAKG;AAEH;IA+EE;;;;;;OAMG;IACH,kCAAsC;IArFtC,iBAAiB;IACjB,kCAAuB;IAEvB;;;;;;MAA+B;IAE/B;;MAAqE;IAErE,eAAe;IACf,oBAKC;IAED,eAAe;IACf,kBAaC;IA8BD,eAAe;IACf,sBAWC;IAED,eAAe;IACf,8BAEC;IAWD,4CAEC;IAED,iCAEC;IAED;;;;;;;OAOG;IACH;4BAHiB,IAAI;8BACJ,IAAI;yBAQpB;IAED,2BAKC;IAoBD,0BAEC;IAED,yDAAyD;IACzD,oLAEC;IAED,qBAAqB;IACrB,2BAEC;IAED,qBAAqB;IACrB,2BAEC;IAED,oBA+BC;IAhLC,8CAAyB;CAiL5B;;;;;;;;;;;;gCAlMY;IACZ,kBAAsB,EAAE,OAAO,gEAAgE,EAAE,cAAc,CAAC;IAChH,UAAc,OAAO,4CAA4C,EAAE,cAAc,CAAC;CAC/E;qCA2MU,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC;2BAChF,sBAAsB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI;sBAtNrC,YAAY"}
1
+ {"version":3,"file":"ActivityBlock.d.ts","sourceRoot":"","sources":["ActivityBlock.js"],"names":[],"mappings":"AASA;;;;;GAKG;AAEH;IA+EE;;;;;;OAMG;IACH,kCAAsC;IArFtC,iBAAiB;IACjB,kCAAuB;IAEvB;;;;;;MAA+B;IAE/B;;MAAqE;IAErE,eAAe;IACf,oBAKC;IAED,eAAe;IACf,kBAaC;IA8BD,eAAe;IACf,sBAWC;IAED,eAAe;IACf,8BAEC;IAWD,4CAEC;IAED,iCAEC;IAED;;;;;;;OAOG;IACH;4BAHiB,IAAI;8BACJ,IAAI;yBAQpB;IAED,2BAKC;IAoBD,0BAEC;IAED,yDAAyD;IACzD,oLAEC;IAED,qBAAqB;IACrB,2BAEC;IAED,qBAAqB;IACrB,2BAEC;IAED,oBA4BC;IA7KC,8CAAyB;CA8K5B;;;;;;;;;;;;gCA/LY;IACZ,kBAAsB,EAAE,OAAO,gEAAgE,EAAE,cAAc,CAAC;IAChH,UAAc,OAAO,4CAA4C,EAAE,cAAc,CAAC;CAC/E;qCAwMU,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC;2BAChF,sBAAsB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI;sBAnNrC,YAAY"}
@@ -187,9 +187,6 @@ export class ActivityBlock extends Block {
187
187
  couldOpenActivity = /** @type {ActivityBlock} */ (nextActivityBlock)?.couldOpenActivity ?? false;
188
188
  }
189
189
 
190
- // // TODO: Возможно стоит обработать поведение activity start-from для minimal mode
191
- // console.log({ nextActivity });
192
-
193
190
  nextActivity = couldOpenActivity ? nextActivity : undefined;
194
191
 
195
192
  if (nextActivity) this.modalManager.open(nextActivity);
package/abstract/Block.js CHANGED
@@ -252,7 +252,7 @@ export class Block extends BaseComponent {
252
252
 
253
253
  this.localeManager?.destroy();
254
254
 
255
- this.modalManager?.destroy();
255
+ this.modalManager && this.modalManager?.destroy();
256
256
  }
257
257
 
258
258
  /**
@@ -1,5 +1,3 @@
1
- /** @typedef {string} ModalId */
2
- /** @typedef {import('../blocks/Modal/Modal.js').Modal} ModalNode */
3
1
  export const ModalEvents: Readonly<{
4
2
  ADD: "modal:add";
5
3
  DELETE: "modal:delete";
@@ -8,6 +6,10 @@ export const ModalEvents: Readonly<{
8
6
  CLOSE_ALL: "modal:closeAll";
9
7
  DESTROY: "modal:destroy";
10
8
  }>;
9
+ /** @typedef {string} ModalId */
10
+ /** @typedef {import('../blocks/Modal/Modal.js').Modal} ModalNode */
11
+ /** @typedef {(data: { id: ModalId; modal?: ModalNode }) => void} ModalCb */
12
+ /** @typedef {(typeof ModalEvents)[keyof ModalEvents]} ModalEventType */
11
13
  export class ModalManager {
12
14
  /** @param {import('./Block.js').Block} block */
13
15
  constructor(block: import('./Block.js').Block);
@@ -79,23 +81,23 @@ export class ModalManager {
79
81
  /**
80
82
  * Subscribe to modal events
81
83
  *
82
- * @param {string} event
83
- * @param {() => void} callback
84
+ * @param {ModalEventType} event
85
+ * @param {ModalCb} callback
84
86
  * @returns {() => void}
85
87
  */
86
- subscribe(event: string, callback: () => void): () => void;
88
+ subscribe(event: ModalEventType, callback: ModalCb): () => void;
87
89
  /**
88
90
  * Unsubscribe from modal events
89
91
  *
90
- * @param {string} event
91
- * @param {() => void} callback
92
+ * @param {ModalEventType} event
93
+ * @param {ModalCb | undefined} callback
92
94
  */
93
- unsubscribe(event: string, callback: () => void): void;
95
+ unsubscribe(event: ModalEventType, callback: ModalCb | undefined): void;
94
96
  /**
95
97
  * Notify all subscribers of a modal event
96
98
  *
97
99
  * @private
98
- * @param {string} event - Event name
100
+ * @param {ModalEventType} event - Event name
99
101
  * @param {{
100
102
  * id?: ModalId | ModalId[];
101
103
  * modal?: ModalNode | ModalNode[];
@@ -110,4 +112,16 @@ export class ModalManager {
110
112
  }
111
113
  export type ModalId = string;
112
114
  export type ModalNode = import('../blocks/Modal/Modal.js').Modal;
115
+ export type ModalCb = (data: {
116
+ id: ModalId;
117
+ modal?: ModalNode;
118
+ }) => void;
119
+ export type ModalEventType = (typeof ModalEvents)[keyof {
120
+ readonly ADD: "modal:add";
121
+ readonly DELETE: "modal:delete";
122
+ readonly OPEN: "modal:open";
123
+ readonly CLOSE: "modal:close";
124
+ readonly CLOSE_ALL: "modal:closeAll";
125
+ readonly DESTROY: "modal:destroy";
126
+ }];
113
127
  //# sourceMappingURL=ModalManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["ModalManager.js"],"names":[],"mappings":"AAEA,gCAAgC;AAEhC,oEAAoE;AAEpE;;;;;;;GAOG;AAEH;IAeE,gDAAgD;IAChD,mBADY,OAAO,YAAY,EAAE,KAAK,EAGrC;IAjBD;;;OAGG;IACH,gBAAoB;IAEpB;;;OAGG;IACH,sBAA0B;IAE1B,4BAAyB;IAIvB,mCAAmB;IAGrB;;;OAGG;IACH,oBAEC;IAED;;;;;OAKG;IACH,kBAHW,OAAO,SACP,SAAS,QAKnB;IAED,4DAA4D;IAC5D,gBADY,OAAO,WASlB;IAED;;;;;OAKG;IACH,SAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;;OAKG;IACH,UAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;;OAKG;IACH,WAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;OAIG;IACH,+BAEC;IAED;;;;OAIG;IACH,QAFa,OAAO,CAWnB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAQlB;IAED;;;;;;OAMG;IACH,iBAJW,MAAM,YACN,MAAM,IAAI,GACR,MAAM,IAAI,CAStB;IAED;;;;;OAKG;IACH,mBAHW,MAAM,YACN,MAAM,IAAI,QAMpB;IAED;;;;;;;;;;;;OAYG;IACH,gBAUC;IAED,oDAAoD;IACpD,gBAKC;CACF;sBA1Na,MAAM;wBAEN,OAAO,0BAA0B,EAAE,KAAK"}
1
+ {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["ModalManager.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,gCAAgC;AAEhC,oEAAoE;AAEpE,4EAA4E;AAE5E,wEAAwE;AAExE;IAeE,gDAAgD;IAChD,mBADY,OAAO,YAAY,EAAE,KAAK,EAGrC;IAjBD;;;OAGG;IACH,gBAAoB;IAEpB;;;OAGG;IACH,sBAA0B;IAE1B,4BAAyB;IAIvB,mCAAmB;IAGrB;;;OAGG;IACH,oBAEC;IAED;;;;;OAKG;IACH,kBAHW,OAAO,SACP,SAAS,QAKnB;IAED,4DAA4D;IAC5D,gBADY,OAAO,WASlB;IAED;;;;;OAKG;IACH,SAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;;OAKG;IACH,UAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;;OAKG;IACH,WAHW,OAAO,GACL,OAAO,CAanB;IAED;;;;OAIG;IACH,+BAEC;IAED;;;;OAIG;IACH,QAFa,OAAO,CAWnB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAQlB;IAED;;;;;;OAMG;IACH,iBAJW,cAAc,YACd,OAAO,GACL,MAAM,IAAI,CAStB;IAED;;;;;OAKG;IACH,mBAHW,cAAc,YACd,OAAO,GAAG,SAAS,QAM7B;IAED;;;;;;;;;;;;OAYG;IACH,gBAUC;IAED,oDAAoD;IACpD,gBAKC;CACF;sBArNa,MAAM;wBAEN,OAAO,0BAA0B,EAAE,KAAK;6BAEjC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,KAAK,IAAI;6BAElD,CAAC,kBAAkB,CAAC,CAAC;;;;;;;CAAiB,CAAC"}
@@ -1,9 +1,5 @@
1
1
  //@ts-check
2
2
 
3
- /** @typedef {string} ModalId */
4
-
5
- /** @typedef {import('../blocks/Modal/Modal.js').Modal} ModalNode */
6
-
7
3
  export const ModalEvents = Object.freeze({
8
4
  ADD: 'modal:add',
9
5
  DELETE: 'modal:delete',
@@ -13,6 +9,14 @@ export const ModalEvents = Object.freeze({
13
9
  DESTROY: 'modal:destroy',
14
10
  });
15
11
 
12
+ /** @typedef {string} ModalId */
13
+
14
+ /** @typedef {import('../blocks/Modal/Modal.js').Modal} ModalNode */
15
+
16
+ /** @typedef {(data: { id: ModalId; modal?: ModalNode }) => void} ModalCb */
17
+
18
+ /** @typedef {(typeof ModalEvents)[keyof ModalEvents]} ModalEventType */
19
+
16
20
  export class ModalManager {
17
21
  /**
18
22
  * @private
@@ -161,8 +165,8 @@ export class ModalManager {
161
165
  /**
162
166
  * Subscribe to modal events
163
167
  *
164
- * @param {string} event
165
- * @param {() => void} callback
168
+ * @param {ModalEventType} event
169
+ * @param {ModalCb} callback
166
170
  * @returns {() => void}
167
171
  */
168
172
  subscribe(event, callback) {
@@ -177,8 +181,8 @@ export class ModalManager {
177
181
  /**
178
182
  * Unsubscribe from modal events
179
183
  *
180
- * @param {string} event
181
- * @param {() => void} callback
184
+ * @param {ModalEventType} event
185
+ * @param {ModalCb | undefined} callback
182
186
  */
183
187
  unsubscribe(event, callback) {
184
188
  if (this._subscribers.has(event)) {
@@ -190,7 +194,7 @@ export class ModalManager {
190
194
  * Notify all subscribers of a modal event
191
195
  *
192
196
  * @private
193
- * @param {string} event - Event name
197
+ * @param {ModalEventType} event - Event name
194
198
  * @param {{
195
199
  * id?: ModalId | ModalId[];
196
200
  * modal?: ModalNode | ModalNode[];
@@ -28,7 +28,7 @@ export class FileItem extends UploaderBlock {
28
28
  isUploading: boolean;
29
29
  isFocused: boolean;
30
30
  isEditable: boolean;
31
- isFileName: boolean;
31
+ showFileNames: boolean;
32
32
  state: symbol;
33
33
  ariaLabelStatusFile: string;
34
34
  onEdit: () => void;
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+BC;IAGH,eASC;IAED;;;OAGG;IACH,0BAeC;IAXC,wCAA0C;IAa5C,eAAe;IACf,wBAgBC;IAED,eAAe;IACf,2BAuCC;IAED;;;;OAIG;IACH,kBAUC;IAED;;MAaQ;IAER;;;OAGG;IACH,uBAmDC;IA+CD,wEAAwE;IACxE,oBADY,CAAC,oBAAoB,CAAC,CAAC,MAAM,oBAAoB,CAAC,QA0B7D;IAaC,eAAe;IACf,kBAEE;IAWJ;;;MAEC;IAED;;;OAGG;IACH,uBAEC;IAED,wBAsFC;CACF;;;;;8BArc6B,iCAAiC;AAS/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+BC;IAGH,eASC;IAED;;;OAGG;IACH,0BAgBC;IAZC,wCAA0C;IAc5C,eAAe;IACf,wBAgBC;IAED,eAAe;IACf,2BAuCC;IAED;;;;OAIG;IACH,kBAUC;IAED;;MAaQ;IAER;;;OAGG;IACH,uBAmDC;IAyDD,wEAAwE;IACxE,oBADY,CAAC,oBAAoB,CAAC,CAAC,MAAM,oBAAoB,CAAC,QA0B7D;IAaC,eAAe;IACf,kBAEE;IAWJ;;;MAEC;IAED;;;OAGG;IACH,uBAEC;IAED,wBAsFC;CACF;;;;;8BAhd6B,iCAAiC;AAS/D;;;;;GAKG"}
@@ -57,7 +57,7 @@ export class FileItem extends UploaderBlock {
57
57
  isUploading: false,
58
58
  isFocused: false,
59
59
  isEditable: false,
60
- isFileName: false,
60
+ showFileNames: false,
61
61
  state: FileItemState.IDLE,
62
62
  ariaLabelStatusFile: '',
63
63
  onEdit: () => {
@@ -105,6 +105,7 @@ export class FileItem extends UploaderBlock {
105
105
  this._debouncedGenerateThumb.cancel();
106
106
  } else {
107
107
  this._debouncedGenerateThumb();
108
+ // this?._observer.disconnect();
108
109
  }
109
110
  }
110
111
 
@@ -271,15 +272,25 @@ export class FileItem extends UploaderBlock {
271
272
 
272
273
  this.subConfigValue('useCloudImageEditor', () => this._debouncedCalculateState());
273
274
  this.subConfigValue('filesViewMode', (mode) => {
274
- if (mode === 'grid') {
275
- this.subConfigValue('gridShowFileNames', (value) => (this.$.isFileName = !value));
276
- } else {
277
- this.$.isFileName = false;
275
+ if (this.cfg.filesViewMode === 'grid') {
276
+ this.$.showFileNames = this.cfg.gridShowFileNames;
277
+ }
278
+ if (this.cfg.filesViewMode === 'list') {
279
+ this.$.showFileNames = true;
278
280
  }
279
281
 
280
282
  this.setAttribute('mode', mode);
281
283
  });
282
284
 
285
+ this.subConfigValue('gridShowFileNames', (value) => {
286
+ if (this.cfg.filesViewMode === 'grid') {
287
+ this.$.showFileNames = value;
288
+ }
289
+ if (this.cfg.filesViewMode === 'list') {
290
+ this.$.showFileNames = true;
291
+ }
292
+ });
293
+
283
294
  this.onclick = () => {
284
295
  FileItem.activeInstances.forEach((inst) => {
285
296
  if (inst === this) {
@@ -459,10 +470,10 @@ export class FileItem extends UploaderBlock {
459
470
 
460
471
  FileItem.template = /* HTML */ `
461
472
  <div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused">
462
- <uc-thumb set="thumbUrl:thumbUrl;badgeIcon:badgeIcon"></uc-thumb>
473
+ <uc-thumb set="uid:uid;thumbUrl:thumbUrl;badgeIcon:badgeIcon"></uc-thumb>
463
474
 
464
475
  <div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;">
465
- <span class="uc-file-name" set="@hidden: isFileName">{{itemName}}</span>
476
+ <span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span>
466
477
  <span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span>
467
478
  <span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span>
468
479
  </div>
@@ -489,7 +500,7 @@ FileItem.template = /* HTML */ `
489
500
  </div>
490
501
  <uc-progress-bar
491
502
  class="uc-progress-bar"
492
- set="value: progressValue; visible: progressVisible; @hasFileName: !isFileName"
503
+ set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames"
493
504
  >
494
505
  </uc-progress-bar>
495
506
  </div>
@@ -14,6 +14,27 @@ export class Modal extends Block {
14
14
  _handleDialogMouseUp: (e: Event) => void;
15
15
  show(): void;
16
16
  hide(): void;
17
+ /**
18
+ * @private
19
+ * @type {import('../../abstract/ModalManager.js').ModalCb}
20
+ */
21
+ private _handleModalOpen;
22
+ /**
23
+ * @private
24
+ * @type {import('../../abstract/ModalManager.js').ModalCb}
25
+ */
26
+ private _handleModalClose;
27
+ /** @private */
28
+ private _handleModalCloseAll;
29
+ handleModalOpen: ((data: {
30
+ id: string;
31
+ modal?: Modal | undefined;
32
+ }) => void) | undefined;
33
+ handleModalClose: ((data: {
34
+ id: string;
35
+ modal?: Modal | undefined;
36
+ }) => void) | undefined;
37
+ handleModalCloseAll: (() => void) | undefined;
17
38
  }
18
39
  export namespace Modal {
19
40
  let template: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["Modal.js"],"names":[],"mappings":"AAIA;IAEE,kCAAoC;IAIlC;;MAGC;IAGH,iCAEE;IAEF,yBAME;IAEF,+BAEE;IAEF,uBAAuB;IACvB,4BADY,KAAK,UAIf;IAFA,eAAe;IACf,yBAAgC;IAGlC,uBAAuB;IACvB,0BADY,KAAK,UAKf;IAEF,aAWC;IAED,aAOC;CA8CF;;;;sBA9GqB,yBAAyB"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["Modal.js"],"names":[],"mappings":"AAIA;IAEE,kCAAoC;IAIlC;;MAGC;IAGH,iCAEE;IAEF,yBAME;IAEF,+BAEE;IAEF,uBAAuB;IACvB,4BADY,KAAK,UAIf;IAFA,eAAe;IACf,yBAAgC;IAGlC,uBAAuB;IACvB,0BADY,KAAK,UAKf;IAEF,aAWC;IAED,aAOC;IAED;;;OAGG;IACH,yBAMC;IAED;;;OAGG;IACH,0BAIC;IAED,eAAe;IACf,6BAEC;IAmBC;;;4BAAuD;IACvD;;;4BAAyD;IACzD,8CAA+D;CAmBlE;;;;sBAnIqB,yBAAyB"}
@@ -65,6 +65,33 @@ export class Modal extends Block {
65
65
  }
66
66
  }
67
67
 
68
+ /**
69
+ * @private
70
+ * @type {import('../../abstract/ModalManager.js').ModalCb}
71
+ */
72
+ _handleModalOpen({ id }) {
73
+ if (id === this.id) {
74
+ this.show();
75
+ } else {
76
+ this.hide();
77
+ }
78
+ }
79
+
80
+ /**
81
+ * @private
82
+ * @type {import('../../abstract/ModalManager.js').ModalCb}
83
+ */
84
+ _handleModalClose({ id }) {
85
+ if (id === this.id) {
86
+ this.hide();
87
+ }
88
+ }
89
+
90
+ /** @private */
91
+ _handleModalCloseAll() {
92
+ this.hide();
93
+ }
94
+
68
95
  initCallback() {
69
96
  super.initCallback();
70
97
 
@@ -82,23 +109,13 @@ export class Modal extends Block {
82
109
  }
83
110
  });
84
111
 
85
- this.modalManager.subscribe(ModalEvents.OPEN, (/** @type {{ id: string }} */ { id }) => {
86
- if (id === this.id) {
87
- this.show();
88
- } else {
89
- this.hide();
90
- }
91
- });
92
-
93
- this.modalManager.subscribe(ModalEvents.CLOSE, (/** @type {{ id: string }} */ { id }) => {
94
- if (id === this.id) {
95
- this.hide();
96
- }
97
- });
112
+ this.handleModalOpen = this._handleModalOpen.bind(this);
113
+ this.handleModalClose = this._handleModalClose.bind(this);
114
+ this.handleModalCloseAll = this._handleModalCloseAll.bind(this);
98
115
 
99
- this.modalManager.subscribe(ModalEvents.CLOSE_ALL, ({}) => {
100
- this.hide();
101
- });
116
+ this.modalManager.subscribe(ModalEvents.OPEN, this.handleModalOpen);
117
+ this.modalManager.subscribe(ModalEvents.CLOSE, this.handleModalClose);
118
+ this.modalManager.subscribe(ModalEvents.CLOSE_ALL, this.handleModalCloseAll);
102
119
  }
103
120
 
104
121
  destroyCallback() {
@@ -108,6 +125,10 @@ export class Modal extends Block {
108
125
  this.ref.dialog.removeEventListener('close', this._handleDialogClose);
109
126
  this.ref.dialog.removeEventListener('mousedown', this._handleDialogMouseDown);
110
127
  this.ref.dialog.removeEventListener('mouseup', this._handleDialogMouseUp);
128
+
129
+ this.modalManager.unsubscribe(ModalEvents.OPEN, this.handleModalOpen);
130
+ this.modalManager.unsubscribe(ModalEvents.CLOSE, this.handleModalClose);
131
+ this.modalManager.unsubscribe(ModalEvents.CLOSE_ALL, this.handleModalCloseAll);
111
132
  }
112
133
  }
113
134
 
@@ -17,6 +17,7 @@ export class Thumb extends UploaderBlock {
17
17
  '*historyBack': null;
18
18
  '*closeModal': () => void;
19
19
  };
20
+ _observer: any;
20
21
  }
21
22
  export namespace Thumb {
22
23
  let template: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Thumb.d.ts","sourceRoot":"","sources":["Thumb.js"],"names":[],"mappings":"AAIA;IAII;;;;;;;;;;;;;;;;;MAKC;CAeJ;;;;8BA1B6B,iCAAiC"}
1
+ {"version":3,"file":"Thumb.d.ts","sourceRoot":"","sources":["Thumb.js"],"names":[],"mappings":"AAIA;IAII;;;;;;;;;;;;;;;;;MAKC;IAeD,eASC;CAUJ;;;;8BA7C6B,iCAAiC"}
@@ -25,6 +25,25 @@ export class Thumb extends UploaderBlock {
25
25
 
26
26
  connectedCallback() {
27
27
  super.connectedCallback();
28
+
29
+ this._observer = new IntersectionObserver(
30
+ (entries) => {
31
+ const [entry] = entries;
32
+ if (entry.isIntersecting) {
33
+ this.setAttribute('aria-hidden', 'true');
34
+ this._observer.disconnect(); // Stop observing after the first intersection
35
+ }
36
+ },
37
+ { threshold: 0.1 },
38
+ );
39
+
40
+ this._observer.observe(this);
41
+ }
42
+
43
+ disconnectedCallback() {
44
+ super.disconnectedCallback();
45
+
46
+ this._observer.disconnect();
28
47
  }
29
48
  }
30
49
 
@@ -44,5 +63,5 @@ Thumb.bindAttributes({
44
63
  // @ts-expect-error TODO: fix types inside symbiote
45
64
  badgeIcon: null,
46
65
  // @ts-expect-error TODO: fix types inside symbiote
47
- id: null,
66
+ uid: null,
48
67
  });
package/index.ssr.js CHANGED
@@ -840,10 +840,10 @@ export const ExternalUploadSource = {
840
840
  export const FileItem = class {
841
841
  static template = `
842
842
  <div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused">
843
- <uc-thumb set="thumbUrl:thumbUrl;badgeIcon:badgeIcon"></uc-thumb>
843
+ <uc-thumb set="uid:uid;thumbUrl:thumbUrl;badgeIcon:badgeIcon"></uc-thumb>
844
844
 
845
845
  <div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;">
846
- <span class="uc-file-name" set="@hidden: isFileName">{{itemName}}</span>
846
+ <span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span>
847
847
  <span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span>
848
848
  <span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span>
849
849
  </div>
@@ -870,7 +870,7 @@ export const FileItem = class {
870
870
  </div>
871
871
  <uc-progress-bar
872
872
  class="uc-progress-bar"
873
- set="value: progressValue; visible: progressVisible; @hasFileName: !isFileName"
873
+ set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames"
874
874
  >
875
875
  </uc-progress-bar>
876
876
  </div>
@@ -1299,7 +1299,7 @@ export const Thumb = class {
1299
1299
  </div>
1300
1300
  </slot>
1301
1301
  `;
1302
- static observedAttributes = ["thumbUrl", "badgeIcon", "id"];
1302
+ static observedAttributes = ["thumbUrl", "badgeIcon", "uid"];
1303
1303
  static extSrcList = {
1304
1304
  FACEBOOK: "facebook",
1305
1305
  DROPBOX: "dropbox",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/file-uploader",
3
- "version": "1.15.0-alpha.8",
3
+ "version": "1.15.0-alpha.9",
4
4
  "description": "Building blocks for Uploadcare products integration",
5
5
  "keywords": [
6
6
  "web components",
@@ -18,6 +18,22 @@ export class FileUploaderMinimal extends SolutionBlock {
18
18
  '*historyBack': null;
19
19
  '*closeModal': () => void;
20
20
  };
21
+ _handleModalOpen(data: {
22
+ id: string;
23
+ modal?: import("./index.js").Modal | undefined;
24
+ }): void;
25
+ _handleModalClose(data: {
26
+ id: string;
27
+ modal?: import("./index.js").Modal | undefined;
28
+ }): void;
29
+ handleModalOpen: ((data: {
30
+ id: string;
31
+ modal?: import("./index.js").Modal | undefined;
32
+ }) => void) | undefined;
33
+ handleModalClose: ((data: {
34
+ id: string;
35
+ modal?: import("./index.js").Modal | undefined;
36
+ }) => void) | undefined;
21
37
  }
22
38
  export namespace FileUploaderMinimal {
23
39
  let template: string;
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploaderMinimal.d.ts","sourceRoot":"","sources":["FileUploaderMinimal.js"],"names":[],"mappings":"AAQA;IAMI;;;;;;;;;;;;;;;;;;MAMC;CA+FJ;;;;8BAjH6B,oCAAoC"}
1
+ {"version":3,"file":"FileUploaderMinimal.d.ts","sourceRoot":"","sources":["FileUploaderMinimal.js"],"names":[],"mappings":"AAQA;IAMI;;;;;;;;;;;;;;;;;;MAMC;IAXF;;;aAAkD;IAAlD;;;aAAkD;IAkGjD;;;4BAAuD;IACvD;;;4BAAyD;CAW5D;;;;8BArH6B,oCAAoC"}
@@ -21,6 +21,36 @@ export class FileUploaderMinimal extends SolutionBlock {
21
21
  };
22
22
  }
23
23
 
24
+ /** @type {import('../../../abstract/ModalManager.js').ModalCb} */
25
+ _handleModalOpen() {
26
+ if (this.$['*currentActivity'] === ActivityBlock.activities.UPLOAD_LIST) {
27
+ this.set$({
28
+ classUploadList: ACTIVE_CLASS,
29
+ isHiddenStartFrom: true,
30
+ });
31
+ }
32
+
33
+ if (this.$['*uploadList']?.length <= 0) {
34
+ this.set$({
35
+ classStartFrom: ACTIVE_CLASS,
36
+ });
37
+ }
38
+ }
39
+
40
+ /** @type {import('../../../abstract/ModalManager.js').ModalCb} */
41
+ _handleModalClose(e) {
42
+ if (e.id === this.$['*currentActivity']) {
43
+ this.$['*currentActivity'] = ActivityBlock.activities.UPLOAD_LIST;
44
+ this.set$({
45
+ isHiddenStartFrom: false,
46
+ });
47
+ }
48
+
49
+ if (e.id === ActivityBlock.activities.CLOUD_IMG_EDIT) {
50
+ this.$['*currentActivity'] = ActivityBlock.activities.UPLOAD_LIST;
51
+ }
52
+ }
53
+
24
54
  initCallback() {
25
55
  super.initCallback();
26
56
 
@@ -75,43 +105,17 @@ export class FileUploaderMinimal extends SolutionBlock {
75
105
  });
76
106
  });
77
107
 
78
- this.modalManager.subscribe(ModalEvents.OPEN, () => {
79
- if (this.$['*currentActivity'] === ActivityBlock.activities.UPLOAD_LIST) {
80
- this.set$({
81
- classUploadList: ACTIVE_CLASS,
82
- isHiddenStartFrom: true,
83
- });
84
- }
85
-
86
- if (this.$['*uploadList']?.length <= 0) {
87
- this.set$({
88
- classStartFrom: ACTIVE_CLASS,
89
- });
90
- }
91
- });
108
+ this.handleModalOpen = this._handleModalOpen.bind(this);
109
+ this.handleModalClose = this._handleModalClose.bind(this);
92
110
 
93
- this.modalManager.subscribe(
94
- ModalEvents.CLOSE,
95
- (
96
- /**
97
- * @type {{
98
- * id: import('../../../abstract/ModalManager.js').ModalId;
99
- * modal: import('../../../abstract/ModalManager.js').ModalNode;
100
- * }}
101
- */ e,
102
- ) => {
103
- if (e.id === this.$['*currentActivity']) {
104
- this.$['*currentActivity'] = ActivityBlock.activities.UPLOAD_LIST;
105
- this.set$({
106
- isHiddenStartFrom: false,
107
- });
108
- }
111
+ this.modalManager.subscribe(ModalEvents.OPEN, this.handleModalOpen);
112
+ this.modalManager.subscribe(ModalEvents.CLOSE, this.handleModalClose);
113
+ }
109
114
 
110
- if (e.id === ActivityBlock.activities.CLOUD_IMG_EDIT) {
111
- this.$['*currentActivity'] = ActivityBlock.activities.UPLOAD_LIST;
112
- }
113
- },
114
- );
115
+ destroyCallback() {
116
+ super.destroyCallback();
117
+ this.modalManager.unsubscribe(ModalEvents.OPEN, this.handleModalOpen);
118
+ this.modalManager.unsubscribe(ModalEvents.CLOSE, this.handleModalClose);
115
119
  }
116
120
  }
117
121