@miso.ai/client-sdk-ui 1.11.5-beta.6 → 1.11.5-beta.8
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.
- package/dist/cjs/layout/templates.js +19 -8
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/explore.js +12 -0
- package/package.json +2 -2
- package/src/layout/templates.js +15 -3
- package/src/version.js +1 -1
- package/src/workflow/explore.js +11 -0
|
@@ -263,19 +263,30 @@ 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}"
|
|
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() {
|
|
273
|
+
let link = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
274
|
+
const {
|
|
275
|
+
target = '_blank',
|
|
276
|
+
rel = 'noopener',
|
|
277
|
+
open = true
|
|
278
|
+
} = link; // TODO: other properties
|
|
279
|
+
let attrs = '';
|
|
280
|
+
if (open) {
|
|
281
|
+
if (target) {
|
|
282
|
+
attrs += ` target="${target}"`;
|
|
283
|
+
}
|
|
284
|
+
if (rel) {
|
|
285
|
+
attrs += ` rel="${rel}"`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return attrs;
|
|
289
|
+
}
|
|
279
290
|
const DEFAULT_DATE_OPTIONS = Object.freeze({
|
|
280
291
|
locale: 'en-US',
|
|
281
292
|
year: 'numeric',
|
package/dist/cjs/version.js
CHANGED
|
@@ -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
package/src/layout/templates.js
CHANGED
|
@@ -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}"
|
|
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.
|
|
1
|
+
export default '1.11.5-beta.8';
|
package/src/workflow/explore.js
CHANGED
|
@@ -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) {
|