@miso.ai/client-sdk-ui 1.12.1-beta.2 → 1.12.1-beta.3

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 (39) hide show
  1. package/dist/cjs/actor/view.js +0 -13
  2. package/dist/cjs/affiliation/index.js +17 -2
  3. package/dist/cjs/defaults/ask/templates.js +3 -3
  4. package/dist/cjs/defaults/common/templates.js +2 -0
  5. package/dist/cjs/element/container/miso-container.js +8 -2
  6. package/dist/cjs/element/role/index.js +6 -6
  7. package/dist/cjs/element/util/index.js +3 -3
  8. package/dist/cjs/element/util/miso-stub.js +81 -0
  9. package/dist/cjs/element/utils.js +0 -10
  10. package/dist/cjs/layout/templates.js +7 -2
  11. package/dist/cjs/plugin.js +5 -4
  12. package/dist/cjs/trait/collapsible.js +57 -0
  13. package/dist/cjs/trait/helpers.js +65 -0
  14. package/dist/cjs/trait/index.js +13 -0
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/workflow/ask.js +3 -26
  17. package/package.json +2 -2
  18. package/src/actor/view.js +0 -11
  19. package/src/affiliation/index.js +18 -2
  20. package/src/defaults/ask/templates.js +3 -3
  21. package/src/defaults/common/templates.js +2 -2
  22. package/src/element/container/miso-container.js +10 -2
  23. package/src/element/role/index.js +1 -1
  24. package/src/element/util/index.js +1 -1
  25. package/src/element/util/miso-stub.js +85 -0
  26. package/src/element/utils.js +0 -10
  27. package/src/layout/templates.js +8 -2
  28. package/src/plugin.js +4 -4
  29. package/src/trait/collapsible.js +51 -0
  30. package/src/trait/helpers.js +48 -0
  31. package/src/trait/index.js +1 -0
  32. package/src/version.js +1 -1
  33. package/src/workflow/ask.js +3 -24
  34. package/dist/cjs/element/util/miso-collapsible.js +0 -52
  35. package/dist/cjs/element/util/miso-utility.js +0 -83
  36. package/dist/cjs/element/util/utils.js +0 -12
  37. package/src/element/util/miso-collapsible.js +0 -49
  38. package/src/element/util/miso-utility.js +0 -69
  39. package/src/element/util/utils.js +0 -3
@@ -13,8 +13,6 @@ const _excluded = ["value", "error", "status", "meta"];
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
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
- //import { triggerMisoAction } from '../element/util/utils.js';
17
-
18
16
  function statesEqual(a, b) {
19
17
  return a === b || a && b && a.status === b.status && a.error === b.error && a.value === b.value &&
20
18
  // skip deep equals
@@ -204,17 +202,6 @@ class ViewActor {
204
202
  silent
205
203
  });
206
204
  }
207
-
208
- /*
209
- triggerAction(data) {
210
- const { element } = this;
211
- if (!element) {
212
- return;
213
- }
214
- triggerMisoAction(element, data);
215
- }
216
- */
217
-
218
205
  _sliceData(data) {
219
206
  const {
220
207
  value,
@@ -22,6 +22,15 @@ function processData(data) {
22
22
  });
23
23
  }
24
24
  function processValue(value) {
25
+ /*
26
+ if (value.affiliation_products) {
27
+ const { affiliation_products, ...rest } = value;
28
+ value = {
29
+ ...rest,
30
+ affiliation: processMisoData(affiliation_products),
31
+ };
32
+ } else
33
+ */
25
34
  if (value.sovrn_aff) {
26
35
  const {
27
36
  sovrn_aff
@@ -61,14 +70,20 @@ function postProcessValue(value) {
61
70
  })
62
71
  });
63
72
  }
73
+ function processMisoData(products) {
74
+ return {
75
+ channel: 'miso',
76
+ products
77
+ };
78
+ }
64
79
  function processSovrnData(_ref) {
65
80
  let {
66
81
  products
67
82
  } = _ref,
68
- sovrn_aff = _objectWithoutPropertiesLoose(_ref, _excluded2);
83
+ data = _objectWithoutPropertiesLoose(_ref, _excluded2);
69
84
  return Object.assign({
70
85
  channel: 'sovrn'
71
- }, sovrn_aff, {
86
+ }, data, {
72
87
  products: products.map(processSovrnProduct)
73
88
  });
74
89
  }
@@ -61,14 +61,14 @@ class Sections extends _templates.Sections {
61
61
  phraseText
62
62
  } = this._helpers;
63
63
  const classes = [];
64
- //reasoningOptions.hide !== false && classes.push('hidden');
65
64
  reasoningOptions.expand && classes.push('expanded');
66
65
  return container(options, {
67
66
  name: 'reasoning',
68
67
  visibleWhen: 'nonempty'
69
- }, [element('miso-collapsible', {
68
+ }, [element('miso-stub', {
70
69
  classes,
71
- 'data-role': 'reasoning-container'
70
+ trait: 'collapsible',
71
+ 'data-role': 'reasoning-box'
72
72
  }, [element('div', {
73
73
  classes: ['miso-collapsible__header'],
74
74
  'data-role': 'toggle-expand'
@@ -167,6 +167,7 @@ class Helpers {
167
167
  }, {
168
168
  name,
169
169
  visibleWhen,
170
+ trait,
170
171
  logo = false
171
172
  }, body) {
172
173
  const classes = [`${classPrefix}__${name}-container`];
@@ -174,6 +175,7 @@ class Helpers {
174
175
  return this.element(this._context.CONAINER_TAG, {
175
176
  classes,
176
177
  visibleWhen,
178
+ trait,
177
179
  logo,
178
180
  parentQuestionId
179
181
  }, body);
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _misoStub = _interopRequireDefault(require("../util/miso-stub.js"));
7
8
  var _utils = require("../utils.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
10
  const ATTR_LOGO = 'logo';
9
11
  const DEFAULT_LOGO_VALUE = 'auto';
10
- const OBSERVED_ATTRIBUTES = Object.freeze([ATTR_LOGO]);
12
+ const OBSERVED_ATTRIBUTES = Object.freeze([..._misoStub.default.observedAttributes, ATTR_LOGO]);
11
13
  function logoAttrToProp(value) {
12
14
  if (!value) {
13
15
  return DEFAULT_LOGO_VALUE;
@@ -33,7 +35,7 @@ function logoPropToAttr(value) {
33
35
  throw new Error(`Invalid logo property value: ${value}.`);
34
36
  }
35
37
  }
36
- class MisoContainerElement extends HTMLElement {
38
+ class MisoContainerElement extends _misoStub.default {
37
39
  static get observedAttributes() {
38
40
  return OBSERVED_ATTRIBUTES;
39
41
  }
@@ -70,6 +72,7 @@ class MisoContainerElement extends HTMLElement {
70
72
 
71
73
  // lifecycle //
72
74
  async connectedCallback() {
75
+ super.connectedCallback();
73
76
  const client = this._client = await (0, _utils.getClient)(MisoContainerElement);
74
77
  if (document.body.contains(this)) {
75
78
  // in case already disconnected
@@ -78,6 +81,7 @@ class MisoContainerElement extends HTMLElement {
78
81
  }
79
82
  disconnectedCallback() {
80
83
  this._setWorkflow(undefined);
84
+ super.disconnectedCallback();
81
85
  }
82
86
  _getWorkflow(client) {
83
87
  throw new Error('Unimplemented');
@@ -99,6 +103,8 @@ class MisoContainerElement extends HTMLElement {
99
103
  case ATTR_LOGO:
100
104
  this._handleLogoUpdate(oldValue, newValue);
101
105
  break;
106
+ default:
107
+ super.attributeChangedCallback(attr, oldValue, newValue);
102
108
  }
103
109
  }
104
110
  _handleLogoUpdate(oldAttrValue, newAttrValue) {
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "MisoAffiliationElement", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _misoAffiliation.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "MisoAnswerElement", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -111,12 +117,6 @@ Object.defineProperty(exports, "MisoSourcesElement", {
111
117
  return _misoSources.default;
112
118
  }
113
119
  });
114
- Object.defineProperty(exports, "MisoSovrnAffiliationElement", {
115
- enumerable: true,
116
- get: function () {
117
- return _misoAffiliation.default;
118
- }
119
- });
120
120
  Object.defineProperty(exports, "MisoTotalElement", {
121
121
  enumerable: true,
122
122
  get: function () {
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "MisoBannerElement", {
9
9
  return _misoBanner.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "MisoCollapsibleElement", {
12
+ Object.defineProperty(exports, "MisoStubElement", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _misoCollapsible.default;
15
+ return _misoStub.default;
16
16
  }
17
17
  });
18
18
  var _misoBanner = _interopRequireDefault(require("./miso-banner.js"));
19
- var _misoCollapsible = _interopRequireDefault(require("./miso-collapsible.js"));
19
+ var _misoStub = _interopRequireDefault(require("./miso-stub.js"));
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const TAG_NAME = 'miso-stub';
8
+ const ATTR_TRAIT = 'trait';
9
+ const OBSERVED_ATTRIBUTES = Object.freeze([ATTR_TRAIT]);
10
+ class MisoStubElement extends HTMLElement {
11
+ static get tagName() {
12
+ return TAG_NAME;
13
+ }
14
+ static get observedAttributes() {
15
+ return OBSERVED_ATTRIBUTES;
16
+ }
17
+ constructor() {
18
+ super();
19
+ this._traits = [];
20
+ }
21
+
22
+ // lifecycle //
23
+ connectedCallback() {
24
+ this._syncTraits();
25
+ }
26
+ disconnectedCallback() {
27
+ for (const trait of this._traits) {
28
+ this._destroyTrait(trait);
29
+ }
30
+ this._traits = [];
31
+ }
32
+ attributeChangedCallback(attr) {
33
+ switch (attr) {
34
+ case ATTR_TRAIT:
35
+ this._syncTraits();
36
+ break;
37
+ }
38
+ }
39
+ _syncTraits() {
40
+ const names = (this.getAttribute(ATTR_TRAIT) || '').split(/\s+/).filter(Boolean);
41
+ const traits = [];
42
+ for (const trait of this._traits) {
43
+ if (!names.includes(trait.constructor.traitName)) {
44
+ this._destroyTrait(trait);
45
+ } else {
46
+ traits.push(trait);
47
+ }
48
+ }
49
+ if (names.length > 0) {
50
+ const availableTraits = getAvailableTraits(MisoStubElement.MisoClient);
51
+ for (const name of names) {
52
+ if (this._traits.find(trait => trait.constructor.traitName === name)) {
53
+ continue;
54
+ }
55
+ const TraitClass = availableTraits[name];
56
+ if (!TraitClass) {
57
+ console.warn(`Unknown trait: ${name}`);
58
+ continue;
59
+ }
60
+ const trait = new TraitClass(this);
61
+ traits.push(trait);
62
+ }
63
+ }
64
+ this._traits = traits;
65
+ }
66
+ _destroyTrait(trait) {
67
+ try {
68
+ trait._destroy && trait._destroy();
69
+ } catch (error) {
70
+ console.error(error);
71
+ }
72
+ }
73
+ }
74
+ exports.default = MisoStubElement;
75
+ function getAvailableTraits(MisoClient) {
76
+ const traits = MisoClient.ui && MisoClient.ui.traits || {};
77
+ return Object.values(traits).reduce((traits, trait) => {
78
+ traits[trait.traitName] = trait;
79
+ return traits;
80
+ }, {});
81
+ }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.applyCoerce = applyCoerce;
7
- exports.defineStatusGetters = defineStatusGetters;
8
7
  exports.getClient = getClient;
9
8
  exports.getContainer = getContainer;
10
9
  exports.getMisoClient = getMisoClient;
@@ -85,13 +84,4 @@ function coerceDefault(str) {
85
84
  return num;
86
85
  }
87
86
  return str;
88
- }
89
- function defineStatusGetters(prototype, statuses) {
90
- for (const status of statuses) {
91
- Object.defineProperty(prototype, status, {
92
- get() {
93
- return this.classList.contains(status);
94
- }
95
- });
96
- }
97
87
  }
@@ -128,7 +128,7 @@ function titleBlock({
128
128
  title,
129
129
  _title_with_markups
130
130
  }) {
131
- const text = _title_with_markups || (0, _commons.escapeHtml)(title);
131
+ const text = formatHtmlWithMarkup(_title_with_markups) || (0, _commons.escapeHtml)(title);
132
132
  return text ? `<div class="${className}__item-title">${text}</div>` : '';
133
133
  }
134
134
  function brandBlock({
@@ -149,7 +149,7 @@ function descriptionBlock({
149
149
  snippet,
150
150
  description
151
151
  }) {
152
- return snippet ? `<div class="${className}__item-snippet">${snippet}</div>` : description ? `<div class="${className}__item-desc">${(0, _commons.escapeHtml)(description)}</div>` : '';
152
+ return snippet ? `<div class="${className}__item-snippet">${formatHtmlWithMarkup(snippet)}</div>` : description ? `<div class="${className}__item-desc">${(0, _commons.escapeHtml)(description)}</div>` : '';
153
153
  }
154
154
  function dateBlock({
155
155
  className,
@@ -333,6 +333,10 @@ function formatNumber(number, fn = DEFAULT_NUMBER_OPTIONS) {
333
333
  throw new Error(`Invalid number format: ${fn}`);
334
334
  }
335
335
  }
336
+ function formatHtmlWithMarkup(html) {
337
+ // preserve space between two <mark> elements
338
+ return html && html.replace(/<\/mark>\s+<mark>/g, '</mark>&nbsp;<mark>');
339
+ }
336
340
  function asFunction(template = '') {
337
341
  return typeof template === 'function' ? template : () => template;
338
342
  }
@@ -340,6 +344,7 @@ const helpers = exports.helpers = Object.freeze({
340
344
  tagPair,
341
345
  formatDate,
342
346
  formatNumber,
347
+ formatHtmlWithMarkup,
343
348
  escapeHtml: _commons.escapeHtml,
344
349
  asFunction
345
350
  });
@@ -12,6 +12,7 @@ var elements = _interopRequireWildcard(require("./element/index.js"));
12
12
  var layouts = _interopRequireWildcard(require("./layout/index.js"));
13
13
  var sources = _interopRequireWildcard(require("./source.js"));
14
14
  var defaults = _interopRequireWildcard(require("./defaults/index.js"));
15
+ var traits = _interopRequireWildcard(require("./trait/index.js"));
15
16
  var _styles = require("./styles.js");
16
17
  var _misoContainer = _interopRequireDefault(require("./element/container/miso-container.js"));
17
18
  var _misoCombo = _interopRequireDefault(require("./element/combo/miso-combo.js"));
@@ -37,7 +38,8 @@ class UiPlugin extends _commons.Component {
37
38
  context.addSubtree(this);
38
39
  MisoClient.on('create', this._injectClient.bind(this));
39
40
  const ui = {
40
- defaults
41
+ defaults,
42
+ traits
41
43
  };
42
44
  (0, _commons.delegateGetters)(ui, this, ['layouts', 'combo', 'ready']);
43
45
  (0, _commons.defineValues)(this, {
@@ -68,9 +70,8 @@ class UiPlugin extends _commons.Component {
68
70
  others = _objectWithoutPropertiesLoose(elements, _excluded);
69
71
  // containers must go first, so their APIs will be ready before children are defined
70
72
  const ElementClasses = [...Object.values(combos), ...Object.values(containers), ...Object.values(roles), ...Object.values(others)];
71
- _misoContainer.default.MisoClient = MisoClient;
72
- _misoCombo.default.MisoClient = MisoClient;
73
- for (const ElementClass of ElementClasses) {
73
+ const ElementSuperClasses = [_misoContainer.default, _misoCombo.default];
74
+ for (const ElementClass of [...ElementSuperClasses, ...ElementClasses]) {
74
75
  ElementClass.MisoClient = MisoClient; // TODO: find better way
75
76
  }
76
77
 
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helpers = require("./helpers.js");
8
+ const CLASS_NAME = 'miso-collapsible';
9
+ const STATUS_EXPANDED = 'expanded';
10
+ const ACTIONS = [{
11
+ action: 'expand',
12
+ classAction: 'add',
13
+ className: STATUS_EXPANDED
14
+ }, {
15
+ action: 'collapse',
16
+ classAction: 'remove',
17
+ className: STATUS_EXPANDED
18
+ }];
19
+ const CLICKABLES = [{
20
+ role: 'expand',
21
+ action: 'expand'
22
+ }, {
23
+ role: 'collapse',
24
+ action: 'collapse'
25
+ }, {
26
+ role: 'toggle-expand',
27
+ action: 'toggle'
28
+ }];
29
+ class CollapsibleTrait {
30
+ static get traitName() {
31
+ return 'collapsible';
32
+ }
33
+ constructor(element) {
34
+ this._element = element;
35
+ element.collapsible = this;
36
+ element.classList.add(CLASS_NAME);
37
+ this._unsubscribes = [(0, _helpers.listenToClickables)(this)];
38
+ }
39
+ _destroy() {
40
+ for (const unsubscribe of this._unsubscribes || []) {
41
+ unsubscribe();
42
+ }
43
+ this._unsubscribes = [];
44
+ delete this._element.collapsible;
45
+ this._element.classList.remove(CLASS_NAME);
46
+ this._element = undefined;
47
+ }
48
+
49
+ // api //
50
+ toggle() {
51
+ this.expanded ? this.collapse() : this.expand();
52
+ }
53
+ }
54
+ exports.default = CollapsibleTrait;
55
+ (0, _helpers.defineStatusGetters)(CollapsibleTrait.prototype, [STATUS_EXPANDED]);
56
+ (0, _helpers.defineActions)(CollapsibleTrait.prototype, ACTIONS);
57
+ (0, _helpers.defineClickables)(CollapsibleTrait.prototype, CLICKABLES);
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defineActions = defineActions;
7
+ exports.defineClickables = defineClickables;
8
+ exports.defineStatusGetters = defineStatusGetters;
9
+ exports.listenToClickables = listenToClickables;
10
+ function defineStatusGetters(prototype, statuses) {
11
+ for (const status of statuses) {
12
+ Object.defineProperty(prototype, status, {
13
+ get() {
14
+ return this._element && this._element.classList.contains(status);
15
+ }
16
+ });
17
+ }
18
+ }
19
+ function defineActions(prototype, actions) {
20
+ for (const {
21
+ action,
22
+ classAction,
23
+ className
24
+ } of actions) {
25
+ prototype[action] = function () {
26
+ this._element && this._element.classList[classAction](className);
27
+ this[`_${action}`] && this[`_${action}`]();
28
+ };
29
+ }
30
+ }
31
+ function defineClickables(prototype, clickables) {
32
+ prototype._handleClick = function (event) {
33
+ const {
34
+ target,
35
+ button
36
+ } = event;
37
+ if (button !== 0) {
38
+ return; // only left click
39
+ }
40
+ for (let {
41
+ role,
42
+ selector,
43
+ action
44
+ } of clickables) {
45
+ selector = selector || `[data-role="${role}"]`;
46
+ if (!selector) {
47
+ continue;
48
+ }
49
+ if (target.closest(selector)) {
50
+ this[action]();
51
+ event.stopPropagation();
52
+ return;
53
+ }
54
+ }
55
+ };
56
+ }
57
+ function listenToClickables(addon) {
58
+ const element = addon._element;
59
+ if (!element) {
60
+ return () => {};
61
+ }
62
+ const handleClick = event => addon._handleClick(event);
63
+ element.addEventListener('click', handleClick);
64
+ return () => element.removeEventListener('click', handleClick);
65
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CollapsibleTrait", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _collapsible.default;
10
+ }
11
+ });
12
+ var _collapsible = _interopRequireDefault(require("./collapsible.js"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -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.12.1-beta.2';
7
+ var _default = exports.default = '1.12.1-beta.3';
@@ -141,7 +141,6 @@ class Ask extends _answerBased.default {
141
141
  _updateData(data) {
142
142
  super._updateData(data);
143
143
  this._triggerSuggestionsRefreshIfNecessary();
144
- this._showReasoningContainerIfNecessary(data);
145
144
  }
146
145
  _triggerSuggestionsRefreshIfNecessary() {
147
146
  const {
@@ -153,28 +152,6 @@ class Ask extends _answerBased.default {
153
152
  const view = next._views.get(_constants.ROLE.QUERY_SUGGESTIONS);
154
153
  view && view.refresh();
155
154
  }
156
- _showReasoningContainerIfNecessary({
157
- session,
158
- value
159
- } = {}) {
160
- if (!value || !value.reasoning) {
161
- return;
162
- }
163
- // TODO: shall we solve this issue with container?
164
- // TODO: shall we just look up on the miso-collapse element?
165
- const context = this._getSessionContext(session);
166
- if (context.reasoningShown) {
167
- return;
168
- }
169
- const element = this._getReasoningContainerElement();
170
- if (!element) {
171
- return;
172
- }
173
- if (typeof element.show === 'function') {
174
- element.show();
175
- context.reasoningShown = true;
176
- }
177
- }
178
155
 
179
156
  // view //
180
157
  _onReasoningViewUpdate({
@@ -184,7 +161,7 @@ class Ask extends _answerBased.default {
184
161
  if (status !== _constants.STATUS.READY || ongoing) {
185
162
  return;
186
163
  }
187
- const element = this._getReasoningContainerElement();
164
+ const element = this._getReasoningBoxElement();
188
165
  element && element.classList.add('done');
189
166
  }
190
167
 
@@ -233,10 +210,10 @@ class Ask extends _answerBased.default {
233
210
  this._questionId = undefined;
234
211
  }
235
212
  }
236
- _getReasoningContainerElement() {
213
+ _getReasoningBoxElement() {
237
214
  const view = this._views.get(_constants.ROLE.REASONING);
238
215
  const element = view && view.element;
239
- return element && element.closest('[data-role="reasoning-container"]');
216
+ return element && element.closest('[data-role="reasoning-box"]');
240
217
  }
241
218
 
242
219
  // destroy //
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.1-beta.2"
29
+ "@miso.ai/commons": "1.12.1-beta.3"
30
30
  },
31
- "version": "1.12.1-beta.2"
31
+ "version": "1.12.1-beta.3"
32
32
  }
package/src/actor/view.js CHANGED
@@ -3,7 +3,6 @@ import { STATUS, ROLE, isDataRole } from '../constants.js';
3
3
  import * as fields from './fields.js';
4
4
  import ProxyElement from '../util/proxy.js';
5
5
  import Tracker from './tracker.js';
6
- //import { triggerMisoAction } from '../element/util/utils.js';
7
6
 
8
7
  function statesEqual(a, b) {
9
8
  return a === b || (a && b &&
@@ -170,16 +169,6 @@ export default class ViewActor {
170
169
  this.hub.update(fields.view(role), state, { silent });
171
170
  }
172
171
 
173
- /*
174
- triggerAction(data) {
175
- const { element } = this;
176
- if (!element) {
177
- return;
178
- }
179
- triggerMisoAction(element, data);
180
- }
181
- */
182
-
183
172
  _sliceData(data) {
184
173
  const { value, error, status, meta, ...rest } = data;
185
174
  const sliced = {
@@ -12,6 +12,15 @@ export function processData(data) {
12
12
  }
13
13
 
14
14
  function processValue(value) {
15
+ /*
16
+ if (value.affiliation_products) {
17
+ const { affiliation_products, ...rest } = value;
18
+ value = {
19
+ ...rest,
20
+ affiliation: processMisoData(affiliation_products),
21
+ };
22
+ } else
23
+ */
15
24
  if (value.sovrn_aff) {
16
25
  const { sovrn_aff, ...rest } = value;
17
26
  value = {
@@ -48,10 +57,17 @@ function postProcessValue(value) {
48
57
  };
49
58
  }
50
59
 
51
- function processSovrnData({ products, ...sovrn_aff }) {
60
+ function processMisoData(products) {
61
+ return {
62
+ channel: 'miso',
63
+ products,
64
+ };
65
+ }
66
+
67
+ function processSovrnData({ products, ...data }) {
52
68
  return {
53
69
  channel: 'sovrn',
54
- ...sovrn_aff,
70
+ ...data,
55
71
  products: products.map(processSovrnProduct),
56
72
  };
57
73
  }
@@ -43,12 +43,12 @@ class Sections extends _Sections {
43
43
  const { phrases, reasoning: reasoningOptions = {} } = options;
44
44
  const { container, element, phraseText } = this._helpers;
45
45
  const classes = [];
46
- //reasoningOptions.hide !== false && classes.push('hidden');
47
46
  reasoningOptions.expand && classes.push('expanded');
48
47
  return container(options, { name: 'reasoning', visibleWhen: 'nonempty' }, [
49
- element('miso-collapsible', {
48
+ element('miso-stub', {
50
49
  classes,
51
- 'data-role': 'reasoning-container',
50
+ trait: 'collapsible',
51
+ 'data-role': 'reasoning-box',
52
52
  }, [
53
53
  element('div', {
54
54
  classes: ['miso-collapsible__header'],
@@ -126,10 +126,10 @@ export class Helpers {
126
126
  }, body);
127
127
  }
128
128
 
129
- container({ classPrefix, circledCitationIndex, parentQuestionId }, { name, visibleWhen, logo = false }, body) {
129
+ container({ classPrefix, circledCitationIndex, parentQuestionId }, { name, visibleWhen, trait, logo = false }, body) {
130
130
  const classes = [`${classPrefix}__${name}-container`];
131
131
  circledCitationIndex && classes.push('miso-circled-citation-index');
132
- return this.element(this._context.CONAINER_TAG, { classes, visibleWhen, logo, parentQuestionId }, body);
132
+ return this.element(this._context.CONAINER_TAG, { classes, visibleWhen, trait, logo, parentQuestionId }, body);
133
133
  }
134
134
 
135
135
  element(tag, attributes = {}, body = '') {