@miso.ai/client-sdk-ui 1.11.5-beta.6 → 1.11.5-beta.7

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.
@@ -263,19 +263,29 @@ function tagPair(_ref13, _ref14) {
263
263
  role = 'item'
264
264
  } = _ref12,
265
265
  meta = _objectWithoutPropertiesLoose(_ref12, _excluded);
266
- const {
267
- link = {}
268
- } = options;
269
- const {
270
- target = '_blank',
271
- rel = 'noopener'
272
- } = link; // TODO: other properties
273
266
  const tag = meta.link !== false && url ? 'a' : 'div';
274
- const urlAttrs = meta.link !== false && url ? `href="${url}" target="${target}" rel="${rel}"` : '';
267
+ const urlAttrs = meta.link !== false && url ? `href="${url}" ${linkAttrs(options.link)}` : '';
275
268
  const productAttrs = product_id ? `${_constants.ATTR_DATA_MISO_PRODUCT_ID}="${product_id}"` : '';
276
269
  const roleAttrs = role ? `data-role="${role}"` : '';
277
270
  return [`<${tag} class="${className}__${classSuffix}" ${roleAttrs} ${productAttrs} ${urlAttrs}>`, `</${tag}>`];
278
271
  }
272
+ function linkAttrs(link) {
273
+ const {
274
+ target = '_blank',
275
+ rel = 'noopener',
276
+ open = true
277
+ } = link; // TODO: other properties
278
+ let attrs = '';
279
+ if (open) {
280
+ if (target) {
281
+ attrs += ` target="${target}"`;
282
+ }
283
+ if (rel) {
284
+ attrs += ` rel="${rel}"`;
285
+ }
286
+ }
287
+ return attrs;
288
+ }
279
289
  const DEFAULT_DATE_OPTIONS = Object.freeze({
280
290
  locale: 'en-US',
281
291
  year: 'numeric',
@@ -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.11.5-beta.6';
7
+ var _default = exports.default = '1.11.5-beta.7';
@@ -85,6 +85,18 @@ class Explore extends _base.default {
85
85
  }
86
86
  return super.useApi(options);
87
87
  }
88
+ useLink(fn, options) {
89
+ _useLink.UseLinkMixin.prototype.useLink.call(this, fn, options);
90
+ // also put options to layouts
91
+ if (options) {
92
+ this.useLayouts({
93
+ [_constants.ROLE.RELATED_QUESTIONS]: {
94
+ link: options
95
+ }
96
+ });
97
+ }
98
+ return this;
99
+ }
88
100
 
89
101
  // lifecycle //
90
102
  start() {
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.11.5-beta.6"
29
+ "@miso.ai/commons": "1.11.5-beta.7"
30
30
  },
31
- "version": "1.11.5-beta.6"
31
+ "version": "1.11.5-beta.7"
32
32
  }
@@ -187,15 +187,27 @@ export function cta(layout, data, meta) {
187
187
 
188
188
  // helpers //
189
189
  function tagPair({ className, options = {} }, { product_id, url }, { classSuffix = 'item-body', role = 'item', ...meta } = {}) {
190
- const { link = {} } = options;
191
- const { target = '_blank', rel = 'noopener' } = link; // TODO: other properties
192
190
  const tag = meta.link !== false && url ? 'a' : 'div';
193
- const urlAttrs = meta.link !== false && url ? `href="${url}" target="${target}" rel="${rel}"` : '';
191
+ const urlAttrs = meta.link !== false && url ? `href="${url}" ${linkAttrs(options.link)}` : '';
194
192
  const productAttrs = product_id ? `${ATTR_DATA_MISO_PRODUCT_ID}="${product_id}"` : '';
195
193
  const roleAttrs = role ? `data-role="${role}"` : '';
196
194
  return [`<${tag} class="${className}__${classSuffix}" ${roleAttrs} ${productAttrs} ${urlAttrs}>`, `</${tag}>`];
197
195
  }
198
196
 
197
+ function linkAttrs(link) {
198
+ const { target = '_blank', rel = 'noopener', open = true } = link; // TODO: other properties
199
+ let attrs = '';
200
+ if (open) {
201
+ if (target) {
202
+ attrs += ` target="${target}"`;
203
+ }
204
+ if (rel) {
205
+ attrs += ` rel="${rel}"`;
206
+ }
207
+ }
208
+ return attrs;
209
+ }
210
+
199
211
  const DEFAULT_DATE_OPTIONS = Object.freeze({ locale: 'en-US', year: 'numeric', month: 'short', day: 'numeric' });
200
212
  const DEFAULT_NUMBER_OPTIONS = 'en-US';
201
213
 
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.11.5-beta.6';
1
+ export default '1.11.5-beta.7';
@@ -87,6 +87,17 @@ export default class Explore extends Workflow {
87
87
  return super.useApi(options);
88
88
  }
89
89
 
90
+ useLink(fn, options) {
91
+ UseLinkMixin.prototype.useLink.call(this, fn, options);
92
+ // also put options to layouts
93
+ if (options) {
94
+ this.useLayouts({
95
+ [ROLE.RELATED_QUESTIONS]: { link: options },
96
+ });
97
+ }
98
+ return this;
99
+ }
100
+
90
101
  // lifecycle //
91
102
  start({ relatedQuestions = true } = {}) {
92
103
  if (this._linkFn === undefined) {