@miso.ai/client-sdk-ui 1.10.0 → 1.10.1-beta.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.
@@ -26,7 +26,10 @@ function root(layout, state) {
26
26
  const roleAttr = role ? ` data-role="${role}"` : '';
27
27
  const data = state.value || {};
28
28
  const channelAttr = data.channel ? ` data-channel="${data.channel}"` : '';
29
- return `<div class="${className} ${status}"${roleAttr}${channelAttr}>${status === _constants.STATUS.READY ? templates[status](layout, state) : ''}</div>`;
29
+ const items = layout._getItems(state);
30
+ const itemCount = items ? items.length : undefined;
31
+ const itemCountAttr = itemCount !== undefined ? ` data-item-count="${itemCount}"` : '';
32
+ return `<div class="${className} ${status}"${roleAttr}${channelAttr}${itemCountAttr}>${status === _constants.STATUS.READY ? templates[status](layout, state) : ''}</div>`;
30
33
  }
31
34
  function ready(layout, state) {
32
35
  const {
@@ -261,14 +264,9 @@ class AffiliationLayout extends _collection.default {
261
264
  }
262
265
  _render(element, states, controls) {
263
266
  super._render(element, states, controls);
264
-
265
- // update item count, but raf to display as attribute
266
- const items = this._getItems(states.state);
267
- this._itemCount = items ? items.length : undefined;
268
- (0, _commons.requestAnimationFrame)(() => {
269
- this._syncItemCount();
270
- this._syncItemIndex();
271
- });
267
+ // sync again for incremental item rendering
268
+ this._syncItemCount(states);
269
+ this._syncItemIndex();
272
270
  }
273
271
  _syncElement(element) {
274
272
  const oldElement = this._element;
@@ -283,7 +281,11 @@ class AffiliationLayout extends _collection.default {
283
281
  newElement && this._viewable.observe(newElement);
284
282
  }
285
283
  _syncItemCount() {
286
- const itemCount = this._itemCount;
284
+ let {
285
+ state
286
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
287
+ const items = this._getItems(state);
288
+ const itemCount = this._itemCount = items ? items.length : undefined;
287
289
  if (itemCount === this._displayedCount) {
288
290
  return;
289
291
  }
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.10.0';
7
+ var _default = exports.default = '1.10.1-beta.0';
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@miso.ai/commons": "1.10.0"
29
+ "@miso.ai/commons": "1.10.1-beta.0"
30
30
  },
31
- "version": "1.10.0"
31
+ "version": "1.10.1-beta.0"
32
32
  }
@@ -13,7 +13,10 @@ function root(layout, state) {
13
13
  const roleAttr = role ? ` data-role="${role}"` : '';
14
14
  const data = state.value || {};
15
15
  const channelAttr = data.channel ? ` data-channel="${data.channel}"` : '';
16
- return `<div class="${className} ${status}"${roleAttr}${channelAttr}>${status === STATUS.READY ? templates[status](layout, state) : ''}</div>`;
16
+ const items = layout._getItems(state);
17
+ const itemCount = items ? items.length : undefined;
18
+ const itemCountAttr = itemCount !== undefined ? ` data-item-count="${itemCount}"` : '';
19
+ return `<div class="${className} ${status}"${roleAttr}${channelAttr}${itemCountAttr}>${status === STATUS.READY ? templates[status](layout, state) : ''}</div>`;
17
20
  }
18
21
 
19
22
  function ready(layout, state) {
@@ -227,15 +230,9 @@ export default class AffiliationLayout extends CollectionLayout {
227
230
 
228
231
  _render(element, states, controls) {
229
232
  super._render(element, states, controls);
230
-
231
- // update item count, but raf to display as attribute
232
- const items = this._getItems(states.state);
233
- this._itemCount = items ? items.length : undefined;
234
-
235
- raf(() => {
236
- this._syncItemCount();
237
- this._syncItemIndex();
238
- });
233
+ // sync again for incremental item rendering
234
+ this._syncItemCount(states);
235
+ this._syncItemIndex();
239
236
  }
240
237
 
241
238
  _syncElement(element) {
@@ -252,8 +249,9 @@ export default class AffiliationLayout extends CollectionLayout {
252
249
  newElement && this._viewable.observe(newElement);
253
250
  }
254
251
 
255
- _syncItemCount() {
256
- const itemCount = this._itemCount;
252
+ _syncItemCount({ state } = {}) {
253
+ const items = this._getItems(state);
254
+ const itemCount = this._itemCount = items ? items.length : undefined;
257
255
  if (itemCount === this._displayedCount) {
258
256
  return;
259
257
  }
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.10.0';
1
+ export default '1.10.1-beta.0';