@miso.ai/client-sdk-ui 1.12.7 → 1.13.0-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.
Files changed (45) hide show
  1. package/dist/cjs/actor/index.js +21 -7
  2. package/dist/cjs/actor/trackers.js +19 -4
  3. package/dist/cjs/actor/view.js +7 -19
  4. package/dist/cjs/actor/views.js +38 -100
  5. package/dist/cjs/element/container/miso-container.js +4 -0
  6. package/dist/cjs/layout/affiliation/affiliation.js +1 -1
  7. package/dist/cjs/layout/button/more-button.js +2 -1
  8. package/dist/cjs/layout/container/container.js +10 -5
  9. package/dist/cjs/layout/input/option-list.js +1 -1
  10. package/dist/cjs/layout/input/search-box.js +2 -2
  11. package/dist/cjs/layout/input/select.js +1 -1
  12. package/dist/cjs/layout/list/collection.js +1 -1
  13. package/dist/cjs/layout/mixin/swipeable.js +1 -1
  14. package/dist/cjs/layout/text/typewriter/index.js +3 -3
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/workflow/answer-based.js +19 -1
  17. package/dist/cjs/workflow/ask.js +8 -10
  18. package/dist/cjs/workflow/base.js +6 -2
  19. package/dist/cjs/workflow/explore.js +1 -1
  20. package/dist/cjs/workflow/hybrid-search-views.js +9 -15
  21. package/dist/cjs/workflow/options/auto-query.js +4 -4
  22. package/dist/cjs/workflow/search-based.js +1 -1
  23. package/package.json +2 -2
  24. package/src/actor/index.js +1 -1
  25. package/src/actor/trackers.js +19 -4
  26. package/src/actor/view.js +10 -14
  27. package/src/actor/views.js +42 -96
  28. package/src/element/container/miso-container.js +5 -0
  29. package/src/layout/affiliation/affiliation.js +1 -1
  30. package/src/layout/button/more-button.js +2 -1
  31. package/src/layout/container/container.js +7 -6
  32. package/src/layout/input/option-list.js +1 -1
  33. package/src/layout/input/search-box.js +2 -2
  34. package/src/layout/input/select.js +1 -1
  35. package/src/layout/list/collection.js +3 -3
  36. package/src/layout/mixin/swipeable.js +2 -2
  37. package/src/layout/text/typewriter/index.js +3 -3
  38. package/src/version.js +1 -1
  39. package/src/workflow/answer-based.js +14 -2
  40. package/src/workflow/ask.js +10 -13
  41. package/src/workflow/base.js +5 -4
  42. package/src/workflow/explore.js +1 -1
  43. package/src/workflow/hybrid-search-views.js +11 -12
  44. package/src/workflow/options/auto-query.js +4 -2
  45. package/src/workflow/search-based.js +1 -1
@@ -66,7 +66,7 @@ class Explore extends _unit.default {
66
66
  }
67
67
  _initSubscriptions(args) {
68
68
  super._initSubscriptions(args);
69
- this._unsubscribes = [...this._unsubscribes, this._views.get(_constants.ROLE.RELATED_QUESTIONS).on('click', event => this._handleRelatedQuestionClick(event)), this._hub.on(_index.fields.query(), args => this._query(args))];
69
+ this._unsubscribes = [...this._unsubscribes, this._views.on(_constants.ROLE.RELATED_QUESTIONS, 'click', event => this._handleRelatedQuestionClick(event)), this._hub.on(_index.fields.query(), args => this._query(args))];
70
70
  }
71
71
 
72
72
  // configuration //
@@ -19,9 +19,15 @@ class HybridSearchViewsActor {
19
19
  get filters() {
20
20
  return this._subviews.results.filters;
21
21
  }
22
+ on(role, event, callback) {
23
+ return this._getSubviews(role).on(role, event, callback);
24
+ }
22
25
  get(role) {
23
26
  return this._getSubviews(role).get(role);
24
27
  }
28
+ getAll(role) {
29
+ return this._getSubviews(role).getAll(role);
30
+ }
25
31
  addContainer(element) {
26
32
  if (this._containers.has(element)) {
27
33
  return;
@@ -41,21 +47,18 @@ class HybridSearchViewsActor {
41
47
  this._containers.delete(element);
42
48
  }
43
49
  addComponent(element) {
44
- this._getViewByElement(element).element = element;
50
+ this._getSubviews(element.role).addComponent(element);
45
51
  this._addContainerToSubviews(element._container, element);
46
52
  }
47
53
  removeComponent(element) {
48
- this._getViewByElement(element).element = undefined;
54
+ this._getSubviews(element.role).removeComponent(element);
49
55
  this._removeContainerFromSubviewsIfNecessary(element._container);
50
56
  }
51
57
  updateComponentRole(element, oldRole, newRole) {
52
58
  // TODO
53
59
  }
54
60
  refreshElement(element) {
55
- const view = element.isContainer ? this._containers.get(element) : this._getViewByElement(element);
56
- view && view.refresh({
57
- force: true
58
- });
61
+ this._getSubviews(element.role).refreshElement(element);
59
62
  }
60
63
 
61
64
  // helpers //
@@ -65,15 +68,6 @@ class HybridSearchViewsActor {
65
68
  _getSubviews(role) {
66
69
  return this._subviews[getSubworkflowByRole(role)];
67
70
  }
68
- _getViewByElement(element) {
69
- let {
70
- role
71
- } = element;
72
- if (!role) {
73
- throw new Error('Component must have a role');
74
- }
75
- return this.get(role);
76
- }
77
71
  _addContainerToSubviews(container, child) {
78
72
  if (!container) {
79
73
  return;
@@ -41,10 +41,10 @@ function autoQuery(options = {}) {
41
41
  const searchParams = new URLSearchParams(window.location.search);
42
42
  const q = searchParams.get(param);
43
43
  const qs = searchParams.get(sourceParam) || undefined;
44
- const {
45
- layout
46
- } = this._views.get(_constants.ROLE.QUERY);
47
- if (layout) {
44
+ for (const view of this._views.getAll(_constants.ROLE.QUERY)) {
45
+ const {
46
+ layout
47
+ } = view;
48
48
  if (q && setValue) {
49
49
  layout.value = q;
50
50
  }
@@ -64,7 +64,7 @@ const ROLES_OPTIONS = (0, _index3.mergeRolesOptions)(_base.default.ROLES_OPTIONS
64
64
  class SearchBasedWorkflow extends _base.default {
65
65
  _initSubscriptions(args) {
66
66
  super._initSubscriptions(args);
67
- this._unsubscribes = [...this._unsubscribes, this._hub.on(_index.fields.query(), args => this._query(args)), this._hub.on(_index.fields.filters(), () => this._refine()), this._hub.on(_index.fields.more(), () => this._more()), this._views.get(_constants.ROLE.SORT).on('select', event => this._handleSortSelect(event))];
67
+ this._unsubscribes = [...this._unsubscribes, this._hub.on(_index.fields.query(), args => this._query(args)), this._hub.on(_index.fields.filters(), () => this._refine()), this._hub.on(_index.fields.more(), () => this._more()), this._views.on(_constants.ROLE.SORT, 'select', event => this._handleSortSelect(event))];
68
68
  }
69
69
  restart() {
70
70
  super.restart();
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.12.7"
29
+ "@miso.ai/commons": "1.13.0-beta.0"
30
30
  },
31
- "version": "1.12.7"
31
+ "version": "1.13.0-beta.0"
32
32
  }
@@ -6,5 +6,5 @@ export { default as SessionMaker } from './sessions.js';
6
6
  export { default as DataActor } from './data.js';
7
7
  export { default as ViewsActor } from './views.js';
8
8
  export { default as FeedbackActor } from './feedback.js';
9
- export { default as TrackersActor } from './trackers.js';
10
9
  export { default as InteractionsActor } from './interactions.js';
10
+ export * from './trackers.js';
@@ -1,21 +1,24 @@
1
1
  import { ROLE } from '../constants.js';
2
2
  import Tracker from './tracker.js';
3
3
 
4
- export default class TrackersActor {
4
+ export class TrackersActor {
5
5
 
6
- constructor(hub, { options }) {
6
+ constructor(hub, { roles, options }) {
7
7
  this._hub = hub;
8
+ this._roles = roles;
8
9
  this._options = options;
9
10
  this._trackers = {};
10
11
  }
11
12
 
12
13
  get(role) {
14
+ if (!this._roles.members.includes(role)) {
15
+ throw new Error(`Role "${role}" is not a member of this workflow.`);
16
+ }
13
17
  if (!this._trackers[role]) {
14
- const itemless = role === ROLE.CONTAINER;
15
18
  this._trackers[role] = new Tracker({
16
19
  hub: this._hub,
17
20
  role,
18
- itemless,
21
+ itemless: role === ROLE.CONTAINER,
19
22
  options: () => this._getTrackerOptions(role),
20
23
  });
21
24
  }
@@ -28,3 +31,15 @@ export default class TrackersActor {
28
31
  }
29
32
 
30
33
  }
34
+
35
+ export function proxyTrackers(trackers) {
36
+ return new Proxy(trackers, {
37
+ get: (target, prop) => {
38
+ try {
39
+ return target.get(prop);
40
+ } catch (_) {
41
+ }
42
+ return undefined;
43
+ },
44
+ });
45
+ }
package/src/actor/view.js CHANGED
@@ -2,7 +2,6 @@ import { trimObj, defineValues, delegateGetters, EventEmitter } from '@miso.ai/c
2
2
  import { STATUS, ROLE, isDataRole } from '../constants.js';
3
3
  import * as fields from './fields.js';
4
4
  import ProxyElement from '../util/proxy.js';
5
- import Tracker from './tracker.js';
6
5
 
7
6
  function statesEqual(a, b) {
8
7
  return a === b || (a && b &&
@@ -97,22 +96,13 @@ export default class ViewActor {
97
96
  }
98
97
 
99
98
  get tracker() {
100
- const { role } = this;
101
- if (role === ROLE.CONTAINER) {
102
- return this._views._getContainerTracker();
103
- }
104
- // TODO: we should move this to workflow level, as there could be multiple view of the same role in the future
105
- if (!this._tracker) {
106
- const { hub } = this;
107
- this._tracker = new Tracker({ hub, role, options: () => this.trackerOptions });
108
- }
109
- return this._tracker;
99
+ return this._views.trackers[this.role];
110
100
  }
111
101
 
112
102
  get workflow() {
113
103
  return this._views._workflow;
114
104
  }
115
-
105
+
116
106
  get workflowOptions() {
117
107
  return this._views._options.resolved;
118
108
  }
@@ -155,7 +145,7 @@ export default class ViewActor {
155
145
  };
156
146
  try {
157
147
  await this._layout.render(element, data, { notifyUpdate });
158
- } catch(error) {
148
+ } catch (error) {
159
149
  this._error(error);
160
150
  notifyUpdate({ error });
161
151
  }
@@ -188,6 +178,7 @@ export default class ViewActor {
188
178
  return trimObj(sliced);
189
179
  }
190
180
 
181
+ // TODO: move this to workflow
191
182
  _isContainerEmpty(data) {
192
183
  const { element } = this;
193
184
  if (!element) {
@@ -219,11 +210,16 @@ export default class ViewActor {
219
210
  }
220
211
  try {
221
212
  this._layout[method](...args);
222
- } catch(e) {
213
+ } catch (e) {
223
214
  this._error(e);
224
215
  }
225
216
  }
226
217
 
218
+ _emit(name, data) {
219
+ this._events.emit(name, data);
220
+ this._views._events.emit(`${this.role}:${name}`, data);
221
+ }
222
+
227
223
  _error(e) {
228
224
  this._views._error(e);
229
225
  }
@@ -1,10 +1,8 @@
1
- import { defineValues, delegateGetters } from '@miso.ai/commons';
1
+ import { defineValues, delegateGetters, EventEmitter } from '@miso.ai/commons';
2
2
  import { ROLE } from '../constants.js';
3
3
  import * as fields from './fields.js';
4
4
  import ViewActor from './view.js';
5
5
  import Filters from './filters.js';
6
- import Tracker from './tracker.js';
7
- import { normalizeTrackerOptions } from '../util/trackers.js';
8
6
 
9
7
  export default class ViewsActor {
10
8
 
@@ -23,20 +21,12 @@ export default class ViewsActor {
23
21
  this._options = options;
24
22
  this._roles = roles;
25
23
  this._containers = new Map();
26
- this._containerTracker = undefined;
27
- this._views = {};
24
+ this._components = new Map();
28
25
  this._filters = new Filters(this);
29
-
30
- for (const role of roles.members) {
31
- if (role === ROLE.CONTAINER) {
32
- continue;
33
- }
34
- this._views[role] = new ViewActor(this, role);
35
- }
26
+ this._events = new EventEmitter();
36
27
 
37
28
  defineValues(this, {
38
29
  interface: new Views(this),
39
- trackers: new Trackers(this, roles.members),
40
30
  });
41
31
 
42
32
  const syncSize = () => this.syncSize();
@@ -55,14 +45,20 @@ export default class ViewsActor {
55
45
  return this._filters;
56
46
  }
57
47
 
48
+ get trackers() {
49
+ return this._workflow.trackers;
50
+ }
51
+
52
+ on(role, name, fn) {
53
+ return this._events.on(`${role}:${name}`, fn);
54
+ }
55
+
58
56
  // elements //
59
57
  addContainer(element) {
60
58
  if (this._containers.has(element)) {
61
59
  return;
62
60
  }
63
- const view = new ViewActor(this, ROLE.CONTAINER);
64
- view.layout = this._createLayout(ROLE.CONTAINER);
65
- view.element = element;
61
+ const view = this._createView(element);
66
62
  this._containers.set(element, view);
67
63
 
68
64
  const { components } = element;
@@ -85,11 +81,20 @@ export default class ViewsActor {
85
81
  }
86
82
 
87
83
  addComponent(element) {
88
- this._getViewByElement(element).element = element;
84
+ if (this._components.has(element)) {
85
+ return;
86
+ }
87
+ const view = this._createView(element);
88
+ this._components.set(element, view);
89
89
  }
90
90
 
91
91
  removeComponent(element) {
92
- this._getViewByElement(element).element = undefined;
92
+ const view = this._components.get(element);
93
+ if (!view) {
94
+ return;
95
+ }
96
+ view._destroy();
97
+ this._components.delete(element);
93
98
  }
94
99
 
95
100
  updateComponentRole(element, oldRole, newRole) {
@@ -97,61 +102,31 @@ export default class ViewsActor {
97
102
  }
98
103
 
99
104
  containsElement(element) {
100
- return this._containers.has(element) || this._views[element.role];
105
+ return this._containers.has(element) || this._components.has(element);
101
106
  }
102
107
 
103
108
  refreshElement(element) {
104
- const view = element.isContainer ? this._containers.get(element) : this._getViewByElement(element);
109
+ const view = element.isContainer ? this._containers.get(element) : this._components.get(element);
105
110
  view && view.refresh({ force: true });
106
111
  }
107
112
 
108
- _getViewByElement(element) {
109
- let { role } = element;
110
- if (!role) {
111
- throw new Error('Component must have a role');
112
- }
113
- return this.get(role);
114
- }
115
-
116
- /*
117
- _requestSyncLayouts() {
118
- this._setLayoutRequested = true;
119
- setTimeout(() => {
120
- if (!this._setLayoutRequested) {
121
- return;
122
- }
123
- this._setLayoutRequested = false;
124
- this._syncLayouts();
125
- });
113
+ _createView(element) {
114
+ const view = new ViewActor(this, element.role);
115
+ view.layout = this._createLayout(element.role);
116
+ view.element = element;
117
+ return view;
126
118
  }
127
- */
128
119
 
129
120
  _syncLayouts() {
130
121
  // TODO: put a debug event here
131
122
  const { layouts } = this._options.resolved;
132
123
  if (layouts === false) {
133
- // containers
134
- for (const view of this._containers.values()) {
135
- view.layout = undefined;
136
- }
137
- // components
138
- for (const view of Object.values(this._views)) {
124
+ for (const view of [...this._containers.values(), ...this._components.values()]) {
139
125
  view.layout = undefined;
140
126
  }
141
127
  } else {
142
- for (let [role, [name, options]] of Object.entries(layouts)) {
143
- // TODO: try to omit if unchanged
144
- const fn = () => this._layoutFactory.create(name, { ...options, role, workflow: this._workflowName });
145
- if (role === ROLE.CONTAINER) {
146
- for (const view of this._containers.values()) {
147
- view.layout = fn();
148
- }
149
- } else {
150
- const view = this.get(role);
151
- if (view) {
152
- view.layout = fn();
153
- }
154
- }
128
+ for (const view of [...this._containers.values(), ...this._components.values()]) {
129
+ view.layout = this._createLayout(view.role);
155
130
  }
156
131
  }
157
132
  }
@@ -166,7 +141,11 @@ export default class ViewsActor {
166
141
  }
167
142
 
168
143
  get(role) {
169
- return this._views[role];
144
+ return this.getAll(role)[0];
145
+ }
146
+
147
+ getAll(role) {
148
+ return role === ROLE.CONTAINER ? this._containers.values() : this._components.values().filter(view => view.role === role);
170
149
  }
171
150
 
172
151
  get views() {
@@ -176,15 +155,16 @@ export default class ViewsActor {
176
155
  _getViews(containerFirst = true) {
177
156
  return containerFirst ? [
178
157
  ...this._containers.values(),
179
- ...Object.values(this._views),
158
+ ...this._components.values(),
180
159
  ] : [
181
- ...Object.values(this._views),
160
+ ...this._components.values(),
182
161
  ...this._containers.values(),
183
162
  ];
184
163
  }
185
164
 
186
165
  syncSize() {
187
- for (const view of Object.values(this._views)) {
166
+ // TODO: containers?
167
+ for (const view of this._components.values()) {
188
168
  view._syncSize();
189
169
  }
190
170
  }
@@ -201,21 +181,6 @@ export default class ViewsActor {
201
181
  return data || this._hub.states[fields.data()];
202
182
  }
203
183
 
204
- _getTrackerOptions(role) {
205
- const allTrackerOptions = this._options.resolved.trackers;
206
- // TODO: don't need this anymore
207
- return normalizeTrackerOptions((allTrackerOptions && allTrackerOptions[role]) || false);
208
- }
209
-
210
- _getContainerTracker() {
211
- if (!this._containerTracker) {
212
- const hub = this._hub;
213
- const role = ROLE.CONTAINER;
214
- this._containerTracker = new Tracker({ hub, role, itemless: true, options: () => this._getTrackerOptions(role) });
215
- }
216
- return this._containerTracker;
217
- }
218
-
219
184
  _error(e) {
220
185
  // TODO: hub trigger error event
221
186
  console.error(e);
@@ -252,22 +217,3 @@ class Views {
252
217
  }
253
218
 
254
219
  }
255
-
256
- class Trackers {
257
-
258
- constructor(views, roles) {
259
- this._views = views;
260
- for (const role of roles) {
261
- if (role === ROLE.CONTAINER) {
262
- continue;
263
- }
264
- Object.defineProperty(this, role, {
265
- get: () => views.get(role).tracker,
266
- });
267
- }
268
- Object.defineProperty(this, ROLE.CONTAINER, {
269
- get: () => views._getContainerTracker(),
270
- });
271
- }
272
-
273
- }
@@ -1,3 +1,4 @@
1
+ import { ROLE } from '../../constants.js';
1
2
  import MisoStubElement from '../util/miso-stub.js';
2
3
  import { getClient } from '../utils.js';
3
4
 
@@ -52,6 +53,10 @@ export default class MisoContainerElement extends MisoStubElement {
52
53
  return true;
53
54
  }
54
55
 
56
+ get role() {
57
+ return ROLE.CONTAINER;
58
+ }
59
+
55
60
  get workflow() {
56
61
  return this._workflow;
57
62
  }
@@ -270,7 +270,7 @@ export default class AffiliationLayout extends CollectionLayout {
270
270
  this._displayedIndex = index;
271
271
  listElement.style.left = `${-index * 100}%`;
272
272
  this._viewable.display(index);
273
- this._view._events.emit('display', { index });
273
+ this._view._emit('display', { index });
274
274
  }
275
275
 
276
276
  _onViewable(index) {
@@ -1,6 +1,7 @@
1
1
  import { STATUS } from '../../constants.js';
2
2
  import { fields } from '../../actor/index.js';
3
3
  import TemplateBasedLayout from '../template.js';
4
+ import { helpers } from '../templates.js';
4
5
 
5
6
  const TYPE = 'more-button';
6
7
  const DEFAULT_CLASSNAME = 'miso-more-button';
@@ -11,7 +12,7 @@ function root(layout, state) {
11
12
  const disabledAttr = state.status !== STATUS.READY ? ' disabled' : '';
12
13
  return `
13
14
  <div class="${className}"${roleAttr}${disabledAttr}>
14
- ${templates.text(layout)}
15
+ ${helpers.asFunction(templates.text)(layout)}
15
16
  </div>
16
17
  `;
17
18
  }
@@ -2,6 +2,7 @@ import { ROLE, STATUS } from '../../constants.js';
2
2
  import RafLayout from '../raf.js';
3
3
  import MisoBannerElement from '../../element/util/miso-banner.js';
4
4
  import Viewables from '../../util/viewables.js';
5
+ import { setOrRemoveAttribute } from '../../util/dom.js';
5
6
 
6
7
  const TYPE = 'container';
7
8
 
@@ -60,7 +61,9 @@ export default class ContainerLayout extends RafLayout {
60
61
  if (!element) {
61
62
  return;
62
63
  }
63
- const { status, ongoing, meta: { miso_id, empty = false, unanswerable = false } = {} } = state;
64
+ // TODO: ad-hoc for non-general status/attributes
65
+ const { status, data, ongoing, meta: { miso_id, empty = false, unanswerable = false } = {} } = state;
66
+ const { blocked_reason, finish_reason } = data || {};
64
67
  const statuses = [status, empty ? STATUS.EMPTY : STATUS.NONEMPTY];
65
68
  if (status === STATUS.READY) {
66
69
  statuses.push(ongoing ? STATUS.ONGOING : STATUS.DONE);
@@ -69,11 +72,9 @@ export default class ContainerLayout extends RafLayout {
69
72
  statuses.push(STATUS.UNANSWERABLE);
70
73
  }
71
74
  element.setAttribute('status', statuses.join(' '));
72
- if (miso_id) {
73
- element.setAttribute('miso-id', miso_id);
74
- } else {
75
- element.removeAttribute('miso-id');
76
- }
75
+ setOrRemoveAttribute(element, 'miso-id', miso_id);
76
+ setOrRemoveAttribute(element, 'blocked-reason', blocked_reason);
77
+ setOrRemoveAttribute(element, 'finish-reason', finish_reason);
77
78
  }
78
79
 
79
80
  _trackInteractions(element, state) {
@@ -123,7 +123,7 @@ export default class OptionListLayout extends TemplateBasedLayout {
123
123
  if (!value) {
124
124
  return;
125
125
  }
126
- this._view._events.emit('select', { value });
126
+ this._view._emit('select', { value });
127
127
  }
128
128
 
129
129
  destroy() {
@@ -313,7 +313,7 @@ export default class SearchBoxLayout extends TemplateBasedLayout {
313
313
  if (inputElement) {
314
314
  inputElement.value = value;
315
315
  }
316
- this._view._events.emit('select', Object.freeze({ value: item, index, domEvent: event }));
316
+ this._view._emit('select', Object.freeze({ value: item, index, domEvent: event }));
317
317
  if (!event.defaultPrevented) {
318
318
  this._submit(value);
319
319
  }
@@ -322,7 +322,7 @@ export default class SearchBoxLayout extends TemplateBasedLayout {
322
322
  return;
323
323
  }
324
324
  if (element.matches('[data-role="product-item"]')) {
325
- this._view._events.emit('select', Object.freeze({ value: item, index, domEvent: event }));
325
+ this._view._emit('select', Object.freeze({ value: item, index, domEvent: event }));
326
326
  return;
327
327
  }
328
328
  }
@@ -129,7 +129,7 @@ export default class SelectLayout extends TemplateBasedLayout {
129
129
  return;
130
130
  }
131
131
  // TODO: reflect selection right away
132
- this._view._events.emit('select', { value });
132
+ this._view._emit('select', { value });
133
133
  }
134
134
 
135
135
  destroy() {
@@ -127,8 +127,8 @@ export default class CollectionLayout extends TemplateBasedLayout {
127
127
  _shallRenderIncrementally(state, rendered) {
128
128
  // TODO: compare item ids as well
129
129
  return this.options.incremental &&
130
- rendered && rendered.value && rendered.value.length > 0 &&
131
- state.value && state.value.length >= rendered.value.length &&
130
+ rendered && rendered.value && rendered.value.length > 0 &&
131
+ state.value && state.value.length >= rendered.value.length &&
132
132
  state.session && rendered.session &&
133
133
  state.session.id === rendered.session.id;
134
134
  }
@@ -195,7 +195,7 @@ export default class CollectionLayout extends TemplateBasedLayout {
195
195
  _emitClickEvent(event, binding) {
196
196
  const { session } = this._view._state;
197
197
  const { value, element } = binding;
198
- this._view._events.emit('click', { session, value, element, domEvent: event });
198
+ this._view._emit('click', { session, value, element, domEvent: event });
199
199
  }
200
200
 
201
201
  destroy() {
@@ -6,7 +6,7 @@ export function makeSwipeable(prototype) {
6
6
  }
7
7
 
8
8
  export class SwipeableMixin {
9
-
9
+
10
10
  _initSwipeable() {
11
11
  this._swipeableContext = {
12
12
  itemCount: undefined,
@@ -138,7 +138,7 @@ export class SwipeableMixin {
138
138
  return;
139
139
  }
140
140
  context.displayEventIndex = index;
141
- this._view._events.emit('display', { index });
141
+ this._view._emit('display', { index });
142
142
  }
143
143
 
144
144
  _onClickSwipeable(event) {
@@ -157,7 +157,7 @@ export default class TypewriterLayout extends ProgressiveLayout {
157
157
  if (citationLinkElement) {
158
158
  const index = parseInt(citationLinkElement.dataset.index);
159
159
  if (!Number.isNaN(index)) {
160
- this._view._events.emit('citation-click', { event, index });
160
+ this._view._emit('citation-click', { event, index });
161
161
  }
162
162
  return;
163
163
  }
@@ -168,7 +168,7 @@ export default class TypewriterLayout extends ProgressiveLayout {
168
168
  let { q } = followUpLinkElement.dataset;
169
169
  q = q ? q.trim() : undefined;
170
170
  if (q) {
171
- this._view._events.emit('follow-up-click', { event, q });
171
+ this._view._emit('follow-up-click', { event, q });
172
172
  }
173
173
  return;
174
174
  }
@@ -180,7 +180,7 @@ export default class TypewriterLayout extends ProgressiveLayout {
180
180
  // TODO: classList, attributes
181
181
  const { href, innerText, className } = anchorElement;
182
182
  if (href) {
183
- this._view._events.emit('link-click', trimObj({
183
+ this._view._emit('link-click', trimObj({
184
184
  event,
185
185
  url: href,
186
186
  text: innerText ? innerText.trim() : '',
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.12.7';
1
+ export default '1.13.0-beta.0';