@uploadcare/file-uploader 1.15.0-alpha.15 → 1.15.0-alpha.16

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.
@@ -7,6 +7,7 @@ export class Thumb extends FileItemConfig {
7
7
  */
8
8
  private _thumbRect;
9
9
  _isIntersecting: boolean;
10
+ _firstViewMode: string;
10
11
  init$: {
11
12
  thumbUrl: string;
12
13
  badgeIcon: string;
@@ -38,6 +39,11 @@ export class Thumb extends FileItemConfig {
38
39
  * @param {IntersectionObserverEntry[]} entries
39
40
  */
40
41
  private _observerCallback;
42
+ /**
43
+ * @private
44
+ * @param {String} id
45
+ */
46
+ private _handleEntryId;
41
47
  _observer: IntersectionObserver | undefined;
42
48
  }
43
49
  export namespace Thumb {
@@ -1 +1 @@
1
- {"version":3,"file":"Thumb.d.ts","sourceRoot":"","sources":["Thumb.js"],"names":[],"mappings":"AAQA;IACE,eAAe;IACf,0BAA0B;IAE1B;;;OAGG;IACH,mBAAkB;IAElB,yBAAwB;IAKtB;;;;;;;+CAEU,gBACV;mCAMF,gBAAQ;6BAEa,2BACJ;;wCAKH,wCACD;;;;;;MAbV;IAGH,+BAA+B;IAC/B,oBADY,MAAM,gBAgBjB;IAED,6CAgBC;IAED,eAAe;IACf,2BA2CG;IAEH;;MAA4E;IAE5E;;;OAGG;IACH,0BAaC;IA4CC,4CAAuG;CAY1G;;;;+BAzL8B,+BAA+B"}
1
+ {"version":3,"file":"Thumb.d.ts","sourceRoot":"","sources":["Thumb.js"],"names":[],"mappings":"AAQA;IACE,eAAe;IACf,0BAA0B;IAE1B;;;OAGG;IACH,mBAAkB;IAElB,yBAAwB;IAExB,uBAAoB;IAKlB;;;;;;;+CACO,gBACX;mCAMU,gBAAU;6BAGd,2BAAoB;;wCAKpB,wCACa;;;;;;MAZd;IAGH,+BAA+B;IAC/B,oBADY,MAAM,gBAgBjB;IAED,6CAgBC;IAED,eAAe;IACf,2BA2CG;IAEH;;MAA4E;IAE5E;;;OAGG;IACH,0BAaC;IAED;;;OAGG;IACH,uBA0BC;IAgCC,4CAAuG;CAY1G;;;;+BA/M8B,+BAA+B"}
@@ -18,6 +18,8 @@ export class Thumb extends FileItemConfig {
18
18
 
19
19
  _isIntersecting = false;
20
20
 
21
+ _firstViewMode = '';
22
+
21
23
  constructor() {
22
24
  super();
23
25
 
@@ -132,18 +134,16 @@ export class Thumb extends FileItemConfig {
132
134
  }
133
135
  }
134
136
 
135
- initCallback() {
136
- super.initCallback();
137
-
138
- this.defineAccessor('badgeIcon', (/** @type {string} */ val) => (this.$.badgeIcon = val));
139
-
140
- this.defineAccessor('uid', (/** @type {string} */ value) => {
141
- this.set$({ uid: value });
142
- });
143
-
144
- this.sub('uid', (value) => {
145
- this._entry = this.uploadCollection.read(value);
146
- });
137
+ /**
138
+ * @private
139
+ * @param {String} id
140
+ */
141
+ _handleEntryId(id) {
142
+ let entry = this.uploadCollection?.read(id);
143
+ this._entry = entry;
144
+ if (!entry) {
145
+ return;
146
+ }
147
147
 
148
148
  this._subEntry('fileInfo', (fileInfo) => {
149
149
  if (fileInfo?.isImage && this._isIntersecting) {
@@ -161,9 +161,31 @@ export class Thumb extends FileItemConfig {
161
161
  }
162
162
  });
163
163
 
164
+ if (this._isIntersecting) {
165
+ this._debouncedGenerateThumb();
166
+ }
167
+ }
168
+
169
+ initCallback() {
170
+ super.initCallback();
171
+
172
+ this._firstViewMode = this.cfg.filesViewMode;
173
+
174
+ this.defineAccessor('badgeIcon', (/** @type {string} */ val) => (this.$.badgeIcon = val));
175
+
176
+ this.defineAccessor('uid', (/** @type {string} */ value) => {
177
+ this.set$({ uid: value });
178
+ });
179
+
180
+ this.sub('uid', (uid) => {
181
+ this._handleEntryId(uid);
182
+ });
183
+
164
184
  this.subConfigValue('filesViewMode', (viewMode) => {
165
- if (!this._renderedGridOnce && viewMode === 'grid') {
166
- this._debouncedGenerateThumb(true);
185
+ if (viewMode === 'grid' && !this._renderedGridOnce) {
186
+ if (this._firstViewMode === 'list') {
187
+ this._debouncedGenerateThumb(true);
188
+ }
167
189
  this._renderedGridOnce = true;
168
190
  }
169
191
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/file-uploader",
3
- "version": "1.15.0-alpha.15",
3
+ "version": "1.15.0-alpha.16",
4
4
  "description": "Building blocks for Uploadcare products integration",
5
5
  "keywords": [
6
6
  "web components",