@miso.ai/client-sdk-ui 1.11.5-beta.5 → 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.
- package/dist/cjs/actor/data.js +4 -2
- package/dist/cjs/layout/templates.js +18 -8
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/explore.js +12 -0
- package/package.json +2 -2
- package/src/actor/data.js +4 -2
- package/src/layout/templates.js +15 -3
- package/src/version.js +1 -1
- package/src/workflow/explore.js +11 -0
package/dist/cjs/actor/data.js
CHANGED
|
@@ -28,11 +28,12 @@ class DataActor {
|
|
|
28
28
|
return this._source;
|
|
29
29
|
}
|
|
30
30
|
_handleSession(session) {
|
|
31
|
-
//
|
|
31
|
+
// this is mandatory in any case
|
|
32
|
+
/*
|
|
32
33
|
if (!this.active) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
*/
|
|
36
37
|
// abort ongoing data fetch if any
|
|
37
38
|
if (!this._session || session.index !== this._session.index) {
|
|
38
39
|
// new session, abort preview data fetch if necessary
|
|
@@ -44,6 +45,7 @@ class DataActor {
|
|
|
44
45
|
}
|
|
45
46
|
this._session = session;
|
|
46
47
|
|
|
48
|
+
// TODO: move this to workflow
|
|
47
49
|
// reflect session update
|
|
48
50
|
this._emitResponse({
|
|
49
51
|
session
|
|
@@ -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}"
|
|
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',
|
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/actor/data.js
CHANGED
|
@@ -22,11 +22,12 @@ export default class DataActor {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
_handleSession(session) {
|
|
25
|
-
//
|
|
25
|
+
// this is mandatory in any case
|
|
26
|
+
/*
|
|
26
27
|
if (!this.active) {
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
*/
|
|
30
31
|
// abort ongoing data fetch if any
|
|
31
32
|
if (!this._session || (session.index !== this._session.index)) {
|
|
32
33
|
// new session, abort preview data fetch if necessary
|
|
@@ -38,6 +39,7 @@ export default class DataActor {
|
|
|
38
39
|
}
|
|
39
40
|
this._session = session;
|
|
40
41
|
|
|
42
|
+
// TODO: move this to workflow
|
|
41
43
|
// reflect session update
|
|
42
44
|
this._emitResponse({ session });
|
|
43
45
|
}
|
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.7';
|
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) {
|