@miso.ai/client-sdk-ui 1.11.4-beta.3 → 1.11.4-beta.5

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 (66) hide show
  1. package/dist/cjs/actor/data.js +1 -1
  2. package/dist/cjs/actor/filters.js +6 -4
  3. package/dist/cjs/actor/tracker.js +29 -13
  4. package/dist/cjs/actor/view.js +4 -2
  5. package/dist/cjs/actor/views.js +3 -6
  6. package/dist/cjs/affiliation/index.js +1 -1
  7. package/dist/cjs/combo/ask/options.js +1 -1
  8. package/dist/cjs/combo/base.js +1 -1
  9. package/dist/cjs/defaults/ask/controls.js +1 -1
  10. package/dist/cjs/defaults/common/templates.js +1 -1
  11. package/dist/cjs/layout/affiliation/affiliation.js +2 -2
  12. package/dist/cjs/layout/banner/banner.js +1 -1
  13. package/dist/cjs/layout/button/more-button.js +1 -1
  14. package/dist/cjs/layout/container/container.js +3 -3
  15. package/dist/cjs/layout/error/error.js +1 -1
  16. package/dist/cjs/layout/input/facets.js +1 -1
  17. package/dist/cjs/layout/input/option-list.js +1 -1
  18. package/dist/cjs/layout/input/search-box.js +2 -2
  19. package/dist/cjs/layout/input/select.js +1 -1
  20. package/dist/cjs/layout/list/cards.js +1 -1
  21. package/dist/cjs/layout/list/carousel.js +1 -1
  22. package/dist/cjs/layout/list/collection.js +1 -1
  23. package/dist/cjs/layout/list/list.js +1 -1
  24. package/dist/cjs/layout/radio/feedback.js +1 -1
  25. package/dist/cjs/layout/radio/radio.js +1 -1
  26. package/dist/cjs/layout/raf.js +1 -1
  27. package/dist/cjs/layout/template.js +1 -1
  28. package/dist/cjs/layout/templates.js +1 -1
  29. package/dist/cjs/layout/text/text.js +1 -1
  30. package/dist/cjs/layout/text/typewriter/index.js +56 -14
  31. package/dist/cjs/layout/trackable.js +3 -3
  32. package/dist/cjs/plugin.js +1 -1
  33. package/dist/cjs/util/trackers.js +3 -3
  34. package/dist/cjs/version.js +1 -1
  35. package/dist/cjs/workflow/answer-based.js +73 -19
  36. package/dist/cjs/workflow/ask.js +7 -7
  37. package/dist/cjs/workflow/asks.js +1 -1
  38. package/dist/cjs/workflow/autocomplete.js +1 -1
  39. package/dist/cjs/workflow/base.js +3 -2
  40. package/dist/cjs/workflow/explore.js +8 -4
  41. package/dist/cjs/workflow/hybrid-search-answer.js +1 -1
  42. package/dist/cjs/workflow/options/layouts.js +1 -1
  43. package/dist/cjs/workflow/options/trackers.js +67 -13
  44. package/dist/cjs/workflow/recommendation.js +1 -1
  45. package/dist/cjs/workflow/search-based.js +1 -1
  46. package/dist/cjs/workflow/search.js +4 -2
  47. package/package.json +2 -2
  48. package/src/actor/filters.js +7 -4
  49. package/src/actor/tracker.js +26 -11
  50. package/src/actor/view.js +2 -1
  51. package/src/actor/views.js +2 -6
  52. package/src/layout/affiliation/affiliation.js +1 -1
  53. package/src/layout/container/container.js +2 -2
  54. package/src/layout/input/search-box.js +1 -1
  55. package/src/layout/text/typewriter/index.js +40 -7
  56. package/src/layout/trackable.js +3 -3
  57. package/src/util/trackers.js +1 -1
  58. package/src/version.js +1 -1
  59. package/src/workflow/answer-based.js +47 -10
  60. package/src/workflow/ask.js +5 -3
  61. package/src/workflow/base.js +3 -3
  62. package/src/workflow/explore.js +9 -4
  63. package/src/workflow/options/trackers.js +63 -15
  64. package/src/workflow/recommendation.js +2 -2
  65. package/src/workflow/search-based.js +2 -2
  66. package/src/workflow/search.js +3 -2
@@ -9,7 +9,7 @@ var _utils = require("./utils.js");
9
9
  const _excluded = ["session"];
10
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  class DataActor {
14
14
  constructor(hub, _ref) {
15
15
  let {
@@ -115,8 +115,7 @@ class Facets {
115
115
  this._options = options;
116
116
  }
117
117
  isSelected(field, value) {
118
- const state = this._filters._states.facets[field];
119
- return state && state.includes(value);
118
+ return this._getFieldValues(field).includes(value);
120
119
  }
121
120
  select(field, value) {
122
121
  if (this.isSelected(field, value)) {
@@ -137,8 +136,11 @@ class Facets {
137
136
  this._select(field, value);
138
137
  }
139
138
  }
139
+ _getFieldValues(field) {
140
+ return this._filters._getStates().facets[field] || [];
141
+ }
140
142
  _select(field, value) {
141
- const values = this._options.multivalued ? [...(this._filters._states.facets[field] || []), value] : [value];
143
+ const values = this._options.multivalued ? [...this._getFieldValues(field), value] : [value];
142
144
  values.sort();
143
145
  this._filters.update({
144
146
  facets: {
@@ -147,7 +149,7 @@ class Facets {
147
149
  });
148
150
  }
149
151
  _unselect(field, value) {
150
- let values = this._filters._states.facets[field].filter(v => v !== value);
152
+ let values = this._getFieldValues(field).filter(v => v !== value);
151
153
  if (values.length === 0) {
152
154
  values = undefined;
153
155
  }
@@ -11,39 +11,55 @@ var _states = _interopRequireDefault(require("../util/states.js"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- const VALUELESS_ITEMS = [Symbol('valueless')];
14
+ // a dummy item array for manipulating deduplication
15
+ const ITEMLESS_DUMMY_ITEMS = [Symbol('itemless')];
15
16
  class Tracker {
16
17
  constructor(_ref) {
17
18
  let {
18
19
  hub,
19
20
  role,
20
- valueless = false
21
+ options
21
22
  } = _ref;
22
23
  this._hub = hub;
23
24
  this._role = role;
24
- this._valueless = !!valueless;
25
+ this._options = options;
25
26
  // TODO: know item type
26
27
 
27
28
  this._states = new _states.default(this._getSessionId());
28
29
  }
30
+ get options() {
31
+ return typeof this._options === 'function' ? this._options() : this._options;
32
+ }
29
33
  getState(item) {
30
34
  return this._states.getFullState(item);
31
35
  }
32
- _trigger(type, items) {
36
+ _trigger(type, items, meta) {
33
37
  (0, _constants.validateEventType)(type);
34
- if (this._valueless) {
35
- items = VALUELESS_ITEMS;
38
+ const {
39
+ options
40
+ } = this;
41
+ if (!options) {
42
+ return;
36
43
  }
37
44
  this._syncSession();
38
- items = this._states.untriggered((0, _commons.asArray)(items), type);
39
- if (items.length === 0) {
40
- return;
45
+ const {
46
+ deduplicated = true,
47
+ itemless = false
48
+ } = options;
49
+ if (deduplicated) {
50
+ if (itemless) {
51
+ items = ITEMLESS_DUMMY_ITEMS;
52
+ }
53
+ items = this._states.untriggered((0, _commons.asArray)(items), type);
54
+ if (items.length === 0) {
55
+ return;
56
+ }
57
+ this._states.set(items, type, _constants.TRACKING_STATUS.TRIGGERED);
41
58
  }
42
- this._states.set(items, type, _constants.TRACKING_STATUS.TRIGGERED);
43
- this._sendToHub({
59
+ this._sendToHub(Object.assign({
44
60
  type,
45
- items: this._valueless ? undefined : items
46
- });
61
+ items: itemless ? undefined : items
62
+ }, meta));
47
63
  }
48
64
  submit(_ref2) {
49
65
  let {
@@ -13,7 +13,7 @@ const _excluded = ["value", "error", "status", "meta"];
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
16
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
17
17
  function statesEqual(a, b) {
18
18
  return a === b || a && b && a.status === b.status && a.error === b.error && a.value === b.value &&
19
19
  // skip deep equals
@@ -100,13 +100,15 @@ class ViewActor {
100
100
  if (role === _constants.ROLE.CONTAINER) {
101
101
  return this._views._getContainerTracker();
102
102
  }
103
+ // TODO: we should move this to workflow level, as there could be multiple view of the same role in the future
103
104
  if (!this._tracker) {
104
105
  const {
105
106
  hub
106
107
  } = this;
107
108
  this._tracker = new _tracker.default({
108
109
  hub,
109
- role
110
+ role,
111
+ options: () => this.trackerOptions
110
112
  });
111
113
  }
112
114
  return this._tracker;
@@ -32,7 +32,6 @@ class ViewsActor {
32
32
  this._containers = new Map();
33
33
  this._containerTracker = undefined;
34
34
  this._views = {};
35
- this._trackers = new Trackers(this, roles.members);
36
35
  this._filters = new _filters.default(this);
37
36
  for (const role of roles.members) {
38
37
  if (role === _constants.ROLE.CONTAINER) {
@@ -41,7 +40,8 @@ class ViewsActor {
41
40
  this._views[role] = new _view.default(this, role);
42
41
  }
43
42
  (0, _commons.defineValues)(this, {
44
- interface: new Views(this)
43
+ interface: new Views(this),
44
+ trackers: new Trackers(this, roles.members)
45
45
  });
46
46
  const syncSize = () => this.syncSize();
47
47
  window.addEventListener('resize', syncSize);
@@ -50,9 +50,6 @@ class ViewsActor {
50
50
  })), options.on('layouts', () => this._syncLayouts())];
51
51
  this._syncLayouts();
52
52
  }
53
- get trackers() {
54
- return this._trackers;
55
- }
56
53
  get filters() {
57
54
  return this._filters;
58
55
  }
@@ -228,7 +225,7 @@ class ViewsActor {
228
225
  this._containerTracker = new _tracker.default({
229
226
  hub,
230
227
  role,
231
- valueless: true,
228
+ itemless: true,
232
229
  options: () => this._getTrackerOptions(role)
233
230
  });
234
231
  }
@@ -9,7 +9,7 @@ var _commons = require("@miso.ai/commons");
9
9
  const _excluded = ["sovrn_aff"],
10
10
  _excluded2 = ["products"],
11
11
  _excluded3 = ["id", "deeplink", "headline", "description", "currency", "retailPrice", "salePrice", "discountRate", "image", "thumbnail", "merchant"];
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  function processData(data) {
14
14
  if (!data || !data.value) {
15
15
  return data;
@@ -8,7 +8,7 @@ exports.mergeOptions = mergeOptions;
8
8
  var _commons = require("@miso.ai/commons");
9
9
  var _index = require("../../defaults/ask/index.js");
10
10
  const _excluded = ["api_key", "api_host", "templates", "phrases"];
11
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
11
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
12
12
  // TODO: generalize
13
13
 
14
14
  const {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _commons = require("@miso.ai/commons");
8
8
  const _excluded = ["name", "plugin", "MisoClient"];
9
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
9
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
10
  class Combo extends _commons.Component {
11
11
  constructor(_ref) {
12
12
  let {
@@ -7,7 +7,7 @@ exports.wireFollowUps = wireFollowUps;
7
7
  exports.wireRelatedResources = wireRelatedResources;
8
8
  var _templates = require("./templates.js");
9
9
  const _excluded = ["template"];
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  function wireFollowUps(client, element) {
12
12
  let _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
13
13
  let {
@@ -8,7 +8,7 @@ exports.externalize = externalize;
8
8
  var _commons = require("@miso.ai/commons");
9
9
  const _excluded = ["classPrefix", "circledCitationIndex", "phrases"],
10
10
  _excluded2 = ["classes"];
11
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
11
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
12
12
  // TODO: rename classPrefix -> rootClass?
13
13
  // TODO: placeholder
14
14
 
@@ -11,7 +11,7 @@ var _templates = require("../templates.js");
11
11
  var _svgs = require("../../asset/svgs.js");
12
12
  const _excluded = ["className", "templates", "autoplay"];
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
14
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
15
  const TYPE = 'affiliation';
16
16
  const DEFAULT_CLASSNAME = 'miso-affiliation';
17
17
  function root(layout, state) {
@@ -203,7 +203,7 @@ class AffiliationLayout extends _collection.default {
203
203
  super.initialize(view);
204
204
  const {
205
205
  viewable: options
206
- } = this._view.trackerOptions || {};
206
+ } = this._view.tracker.options || {};
207
207
  this._viewable = new _commons.CarouselItemViewabilityObserver(this._onViewable.bind(this), options);
208
208
  }
209
209
 
@@ -8,7 +8,7 @@ var _template = _interopRequireDefault(require("../template.js"));
8
8
  var _svgs = require("../svgs.js");
9
9
  const _excluded = ["className", "templates"];
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
11
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
12
12
  const TYPE = 'banner';
13
13
  const DEFAULT_CLASSNAME = 'miso-banner';
14
14
  function root(layout) {
@@ -9,7 +9,7 @@ var _index = require("../../actor/index.js");
9
9
  var _template = _interopRequireDefault(require("../template.js"));
10
10
  const _excluded = ["className", "templates"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  const TYPE = 'more-button';
14
14
  const DEFAULT_CLASSNAME = 'miso-more-button';
15
15
  function root(layout, state) {
@@ -10,7 +10,7 @@ var _misoBanner = _interopRequireDefault(require("../../element/miso-banner.js")
10
10
  var _viewables = _interopRequireDefault(require("../../util/viewables.js"));
11
11
  const _excluded = ["logo"];
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
13
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
14
14
  const TYPE = 'container';
15
15
  class ContainerLayout extends _raf.default {
16
16
  static get type() {
@@ -106,7 +106,7 @@ class ContainerLayout extends _raf.default {
106
106
  _trackImpression() {
107
107
  const {
108
108
  impression: options
109
- } = this._view.trackerOptions || {};
109
+ } = this._view.tracker.options || {};
110
110
  if (!options) {
111
111
  return;
112
112
  }
@@ -119,7 +119,7 @@ class ContainerLayout extends _raf.default {
119
119
  async _trackViewable(element) {
120
120
  const {
121
121
  viewable: options
122
- } = this._view.trackerOptions || {};
122
+ } = this._view.tracker.options || {};
123
123
  if (!options) {
124
124
  return;
125
125
  }
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _template = _interopRequireDefault(require("../template.js"));
8
8
  const _excluded = ["className", "templates"];
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  const TYPE = 'error';
12
12
  const DEFAULT_CLASSNAME = 'miso-error';
13
13
  function root(layout, state) {
@@ -10,7 +10,7 @@ var _template = _interopRequireDefault(require("../template.js"));
10
10
  var _bindings = _interopRequireDefault(require("../../util/bindings.js"));
11
11
  const _excluded = ["className", "templates"];
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
13
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
14
14
  const TYPE = 'facets';
15
15
  const DEFAULT_CLASSNAME = 'miso-facets';
16
16
  const DEDAULT_FACET_CLASSNAME = 'miso-facet';
@@ -10,7 +10,7 @@ var _template = _interopRequireDefault(require("../template.js"));
10
10
  var _trackable = require("../trackable.js");
11
11
  const _excluded = ["className", "templates"];
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
13
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
14
14
  const TYPE = 'option-list';
15
15
  const DEFAULT_CLASSNAME = 'miso-option-list';
16
16
  function root(layout, state) {
@@ -12,7 +12,7 @@ var _templates = require("../templates.js");
12
12
  var _svgs = require("../../asset/svgs.js");
13
13
  const _excluded = ["className", "templates", "autocomplete"];
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
15
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
16
16
  const TYPE = 'search-box';
17
17
  const DEFAULT_CLASSNAME = 'miso-search-box';
18
18
  const DEFAULT_AUTOCOMPLETE_CLASSNAME = 'miso-autocomplete';
@@ -396,7 +396,7 @@ class SearchBoxLayout extends _template.default {
396
396
  _trackSubmit(value) {
397
397
  const {
398
398
  [_constants.EVENT_TYPE.SUBMIT]: options
399
- } = this._view.trackerOptions || {};
399
+ } = this._view.tracker.options || {};
400
400
  if (!options) {
401
401
  return;
402
402
  }
@@ -9,7 +9,7 @@ var _template = _interopRequireDefault(require("../template.js"));
9
9
  var _trackable = require("../trackable.js");
10
10
  const _excluded = ["className", "templates"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  const TYPE = 'select';
14
14
  const DEFAULT_CLASSNAME = 'miso-select';
15
15
  function root(layout, state) {
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _collection = _interopRequireDefault(require("./collection.js"));
8
8
  const _excluded = ["className"];
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  const TYPE = 'cards';
12
12
  const DEFAULT_CLASSNAME = 'miso-cards';
13
13
  class CardsLayout extends _collection.default {
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _collection = _interopRequireDefault(require("./collection.js"));
8
8
  const _excluded = ["className", "templates"];
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  const TYPE = 'carousel';
12
12
  const DEFAULT_CLASSNAME = 'miso-carousel';
13
13
  const DEFAULT_TEMPLATES = Object.freeze({
@@ -11,7 +11,7 @@ var _triggerable = require("../triggerable.js");
11
11
  var _templates = require("../templates.js");
12
12
  const _excluded = ["templates", "itemType"];
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
14
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
15
  function root(layout, state) {
16
16
  const {
17
17
  className,
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _collection = _interopRequireDefault(require("./collection.js"));
8
8
  const _excluded = ["className"];
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  const TYPE = 'list';
12
12
  const DEFAULT_CLASSNAME = 'miso-list';
13
13
  class ListLayout extends _collection.default {
@@ -9,7 +9,7 @@ var _radio = _interopRequireDefault(require("./radio.js"));
9
9
  var _svgs = require("../svgs.js");
10
10
  const _excluded = ["className", "templates"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  const TYPE = 'feedback';
14
14
  const DEFAULT_CLASSNAME = 'miso-feedback';
15
15
  const OPTIONS = ['helpful', 'unhelpful'];
@@ -9,7 +9,7 @@ var _template = _interopRequireDefault(require("../template.js"));
9
9
  var _templates = require("../templates.js");
10
10
  const _excluded = ["className", "templates", "field", "defaultValue"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  function root(layout) {
14
14
  const {
15
15
  className,
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _commons = require("@miso.ai/commons");
8
8
  const _excluded = ["role", "workflow"];
9
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
9
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
10
10
  class RafLayout {
11
11
  constructor() {
12
12
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -9,7 +9,7 @@ var _raf = _interopRequireDefault(require("./raf.js"));
9
9
  var _templates = require("./templates.js");
10
10
  const _excluded = ["className", "templates"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
13
  class TemplateBasedLayout extends _raf.default {
14
14
  constructor() {
15
15
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -26,7 +26,7 @@ exports.unimplemented = unimplemented;
26
26
  var _commons = require("@miso.ai/commons");
27
27
  var _constants = require("../constants.js");
28
28
  const _excluded = ["classSuffix", "role"];
29
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
29
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
30
30
  function requiresImplementation() {
31
31
  for (var _len = arguments.length, names = new Array(_len), _key = 0; _key < _len; _key++) {
32
32
  names[_key] = arguments[_key];
@@ -8,7 +8,7 @@ var _commons = require("@miso.ai/commons");
8
8
  var _template = _interopRequireDefault(require("../template.js"));
9
9
  const _excluded = ["className", "templates", "tag"];
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
11
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
12
12
  const TYPE = 'text';
13
13
  const DEFAULT_CLASSNAME = 'miso-text';
14
14
  function root(layout, _ref) {
@@ -11,7 +11,7 @@ var _plaintext = _interopRequireDefault(require("./plaintext.js"));
11
11
  var _utils = require("./utils.js");
12
12
  const _excluded = ["className", "tag", "format", "tooltip", "speed", "acceleration", "nextCursorFn"];
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
14
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
15
  const TYPE = 'typewriter';
16
16
  const DEFAULT_CLASSNAME = 'miso-typewriter';
17
17
  class TypewriterLayout extends _progressive.default {
@@ -80,14 +80,16 @@ class TypewriterLayout extends _progressive.default {
80
80
  const cursorClass = (0, _utils.cursorClassName)(this.className);
81
81
  const {
82
82
  onDebug,
83
- onCitationLink
83
+ onCitationLink,
84
+ variant
84
85
  } = this.options;
85
86
  // TODO: options
86
87
  this._renderer = context.createRenderer({
87
88
  cursorClass,
88
89
  getSource: index => this._getSource(index),
89
90
  onCitationLink,
90
- onDebug: (0, _utils.normalizeOnDebug)(onDebug)
91
+ onDebug: (0, _utils.normalizeOnDebug)(onDebug),
92
+ variant
91
93
  });
92
94
  // capture citation link click if necessary
93
95
  this._unsubscribes.push(this._view.proxyElement.on('click', e => this._onClick(e)));
@@ -177,21 +179,61 @@ class TypewriterLayout extends _progressive.default {
177
179
  }
178
180
 
179
181
  // event //
180
- _onClick(_ref5) {
181
- let {
182
+ _onClick(event) {
183
+ const {
182
184
  target
183
- } = _ref5;
184
- const element = target.closest(`[data-role="citation-link"]`);
185
- if (!element) {
185
+ } = event;
186
+ const citationLinkElement = target.closest(`[data-role="citation-link"]`);
187
+ // citation link click
188
+ if (citationLinkElement) {
189
+ const index = parseInt(citationLinkElement.dataset.index);
190
+ if (!Number.isNaN(index)) {
191
+ this._view._events.emit('citation-click', {
192
+ index
193
+ });
194
+ }
186
195
  return;
187
196
  }
188
- const index = parseInt(element.dataset.index);
189
- if (Number.isNaN(index)) {
197
+ // generic link click
198
+ const anchorElement = target.closest('a');
199
+ if (anchorElement) {
200
+ if (!event.defaultPrevented) {
201
+ // TODO: classList, attributes
202
+ const {
203
+ href,
204
+ innerText,
205
+ className
206
+ } = anchorElement;
207
+ if (href) {
208
+ this._view._events.emit('link-click', (0, _commons.trimObj)({
209
+ url: href,
210
+ text: innerText ? innerText.trim() : '',
211
+ className: className || '',
212
+ attributes: dumpElementAttributes(anchorElement)
213
+ }));
214
+ }
215
+ }
190
216
  return;
191
217
  }
192
- this._view._events.emit('citation-click', {
193
- index
194
- });
195
218
  }
196
219
  }
197
- exports.default = TypewriterLayout;
220
+ exports.default = TypewriterLayout;
221
+ function dumpElementAttributes(element) {
222
+ const {
223
+ attributes
224
+ } = element;
225
+ const attrs = {};
226
+ for (const {
227
+ name,
228
+ value
229
+ } of attributes) {
230
+ if (name.startsWith('data-')) {
231
+ attrs[name] = value;
232
+ }
233
+ }
234
+ try {
235
+ return JSON.stringify(attrs);
236
+ } catch (e) {
237
+ return '{}';
238
+ }
239
+ }
@@ -56,7 +56,7 @@ class TrackableMixin {
56
56
  }
57
57
  const {
58
58
  impression: options
59
- } = this._view.trackerOptions || {};
59
+ } = this._view.tracker.options || {};
60
60
  if (!options) {
61
61
  return;
62
62
  }
@@ -80,7 +80,7 @@ class TrackableMixin {
80
80
  }
81
81
  const {
82
82
  viewable: options
83
- } = this._view.trackerOptions || {};
83
+ } = this._view.tracker.options || {};
84
84
  if (!options) {
85
85
  return;
86
86
  }
@@ -94,7 +94,7 @@ class TrackableMixin {
94
94
  _trackClick(event, binding) {
95
95
  const {
96
96
  click: options
97
- } = this._view.trackerOptions || {};
97
+ } = this._view.tracker.options || {};
98
98
  if ((0, _trackers.validateClick)(options, event, binding)) {
99
99
  this._view.tracker.click([binding.value]);
100
100
  }
@@ -19,7 +19,7 @@ const _excluded = ["containers", "roles", "combos"];
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
22
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
23
23
  const PLUGIN_ID = 'std:ui';
24
24
  class UiPlugin extends _commons.Component {
25
25
  static get id() {
@@ -7,7 +7,7 @@ exports.normalizeTrackerOptions = normalizeTrackerOptions;
7
7
  exports.validateClick = validateClick;
8
8
  var _commons = require("@miso.ai/commons");
9
9
  const _excluded = ["impression", "viewable", "click"];
10
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
10
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
11
  // TODO: think about how to incorporate this with workflow options
12
12
 
13
13
  const DEFAULT_TRACKER_OPTIONS = Object.freeze({
@@ -18,14 +18,14 @@ const DEFAULT_TRACKER_OPTIONS = Object.freeze({
18
18
  }),
19
19
  click: Object.freeze({
20
20
  lenient: false
21
- }),
22
- watch: false
21
+ })
23
22
  });
24
23
  function mergeOptions(def, opt) {
25
24
  // if opt is falsy then return false, merge otherwise
26
25
  return !!opt && Object.assign({}, def, opt);
27
26
  }
28
27
  function normalizeTrackerOptions(options) {
28
+ // TODO: make this { active: false } to keep it an object
29
29
  if (options === false) {
30
30
  return false; // turn off all tracking
31
31
  }