@miso.ai/client-sdk-ui 1.13.0-beta.4 → 1.13.0-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.
- package/dist/cjs/defaults/hybrid-search/phrases.js +1 -1
- package/dist/cjs/layout/text/text.js +10 -6
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/explore.js +1 -0
- package/dist/cjs/workflow/search-based.js +16 -1
- package/package.json +7 -3
- package/src/defaults/hybrid-search/phrases.js +1 -1
- package/src/layout/text/text.js +8 -3
- package/src/version.js +1 -1
- package/src/workflow/explore.js +1 -0
- package/src/workflow/search-based.js +11 -1
|
@@ -22,6 +22,6 @@ const keywords = exports.keywords = 'You searched for “${value}”';
|
|
|
22
22
|
/**
|
|
23
23
|
* The phrase to display <miso-total>
|
|
24
24
|
*/
|
|
25
|
-
const total = exports.total = '${value}
|
|
25
|
+
const total = exports.total = '${value}';
|
|
26
26
|
const showMore = exports.showMore = 'Show more';
|
|
27
27
|
const showLess = exports.showLess = 'Show less';
|
|
@@ -11,9 +11,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
11
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
|
-
function root(layout, {
|
|
15
|
-
value
|
|
16
|
-
}) {
|
|
14
|
+
function root(layout, state) {
|
|
17
15
|
const {
|
|
18
16
|
className,
|
|
19
17
|
role,
|
|
@@ -23,8 +21,13 @@ function root(layout, {
|
|
|
23
21
|
}
|
|
24
22
|
} = layout;
|
|
25
23
|
const roleAttr = role ? `data-role="${role}"` : '';
|
|
26
|
-
const
|
|
27
|
-
return raw ?
|
|
24
|
+
const text = layout.templates.content(layout, state);
|
|
25
|
+
return raw ? text : `<${tag} class="${className}" ${roleAttr}>${text}</${tag}>`;
|
|
26
|
+
}
|
|
27
|
+
function content(layout, {
|
|
28
|
+
value
|
|
29
|
+
}) {
|
|
30
|
+
return value !== undefined ? (0, _commons.escapeHtml)(getFormatFunction(layout)(value)) : '';
|
|
28
31
|
}
|
|
29
32
|
function getFormatFunction(layout) {
|
|
30
33
|
let {
|
|
@@ -55,7 +58,8 @@ function getFormatFunction(layout) {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
const DEFAULT_TEMPLATES = Object.freeze({
|
|
58
|
-
root
|
|
61
|
+
root,
|
|
62
|
+
content
|
|
59
63
|
});
|
|
60
64
|
class TextLayout extends _template.default {
|
|
61
65
|
static get type() {
|
package/dist/cjs/version.js
CHANGED
|
@@ -187,6 +187,7 @@ class Explore extends _unit.default {
|
|
|
187
187
|
}));
|
|
188
188
|
}
|
|
189
189
|
_getSubmitUrl(args) {
|
|
190
|
+
// TODO: if trending_questions -> qs = '_trending'
|
|
190
191
|
let url = _useLink.UseLinkMixin.prototype._getSubmitUrl.call(this, args);
|
|
191
192
|
if (!args.generated || !this._productId) {
|
|
192
193
|
return url;
|
|
@@ -22,6 +22,19 @@ const DEFAULT_API_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAUL
|
|
|
22
22
|
rows: DEFAULT_ROWS
|
|
23
23
|
})
|
|
24
24
|
}));
|
|
25
|
+
function totalContent(layout, {
|
|
26
|
+
value
|
|
27
|
+
}) {
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
const {
|
|
32
|
+
formatNumber
|
|
33
|
+
} = layout.templates.helpers;
|
|
34
|
+
const formatted = formatNumber(value);
|
|
35
|
+
const label = value === 1 ? 'result' : 'results';
|
|
36
|
+
return `${formatted} ${label}`;
|
|
37
|
+
}
|
|
25
38
|
const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LAYOUTS, {
|
|
26
39
|
[_constants.ROLE.QUERY]: [_index2.SearchBoxLayout.type],
|
|
27
40
|
[_constants.ROLE.PRODUCTS]: [_index2.ListLayout.type, {
|
|
@@ -33,7 +46,9 @@ const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LA
|
|
|
33
46
|
}],
|
|
34
47
|
[_constants.ROLE.TOTAL]: [_index2.TextLayout.type, {
|
|
35
48
|
raw: true,
|
|
36
|
-
|
|
49
|
+
templates: {
|
|
50
|
+
content: totalContent
|
|
51
|
+
}
|
|
37
52
|
}],
|
|
38
53
|
[_constants.ROLE.FACETS]: [_index2.FacetsLayout.type],
|
|
39
54
|
[_constants.ROLE.SORT]: [_index2.SelectLayout.type],
|
package/package.json
CHANGED
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
"build:cjs": "BABEL_ENV=cjs npx babel src --root-mode upward --out-dir dist/cjs",
|
|
17
17
|
"build": "npm run build:clean && npm run build:cjs"
|
|
18
18
|
},
|
|
19
|
-
"repository":
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/MisoAI/miso-client-js-sdk.git",
|
|
22
|
+
"directory": "packages/client-sdk-ui"
|
|
23
|
+
},
|
|
20
24
|
"homepage": "https://misoai.github.io/miso-client-js-sdk/sdk",
|
|
21
25
|
"license": "MIT",
|
|
22
26
|
"contributors": [
|
|
@@ -26,7 +30,7 @@
|
|
|
26
30
|
"url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"@miso.ai/commons": "1.13.0-beta.
|
|
33
|
+
"@miso.ai/commons": "1.13.0-beta.5"
|
|
30
34
|
},
|
|
31
|
-
"version": "1.13.0-beta.
|
|
35
|
+
"version": "1.13.0-beta.5"
|
|
32
36
|
}
|
|
@@ -16,7 +16,7 @@ export const keywords = 'You searched for “${value}”';
|
|
|
16
16
|
/**
|
|
17
17
|
* The phrase to display <miso-total>
|
|
18
18
|
*/
|
|
19
|
-
export const total = '${value}
|
|
19
|
+
export const total = '${value}';
|
|
20
20
|
|
|
21
21
|
export const showMore = 'Show more';
|
|
22
22
|
export const showLess = 'Show less';
|
package/src/layout/text/text.js
CHANGED
|
@@ -4,11 +4,15 @@ import TemplateBasedLayout from '../template.js';
|
|
|
4
4
|
const TYPE = 'text';
|
|
5
5
|
const DEFAULT_CLASSNAME = 'miso-text';
|
|
6
6
|
|
|
7
|
-
function root(layout,
|
|
7
|
+
function root(layout, state) {
|
|
8
8
|
const { className, role, options: { raw = false, tag } } = layout;
|
|
9
9
|
const roleAttr = role ? `data-role="${role}"` : '';
|
|
10
|
-
const
|
|
11
|
-
return raw ?
|
|
10
|
+
const text = layout.templates.content(layout, state);
|
|
11
|
+
return raw ? text : `<${tag} class="${className}" ${roleAttr}>${text}</${tag}>`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function content(layout, { value }) {
|
|
15
|
+
return value !== undefined ? escapeHtml(getFormatFunction(layout)(value)) : '';
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
function getFormatFunction(layout) {
|
|
@@ -37,6 +41,7 @@ function getFormatFunction(layout) {
|
|
|
37
41
|
|
|
38
42
|
const DEFAULT_TEMPLATES = Object.freeze({
|
|
39
43
|
root,
|
|
44
|
+
content,
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
export default class TextLayout extends TemplateBasedLayout {
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.13.0-beta.
|
|
1
|
+
export default '1.13.0-beta.5';
|
package/src/workflow/explore.js
CHANGED
|
@@ -170,6 +170,7 @@ export default class Explore extends UnitWorkflow {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
_getSubmitUrl(args) {
|
|
173
|
+
// TODO: if trending_questions -> qs = '_trending'
|
|
173
174
|
let url = UseLinkMixin.prototype._getSubmitUrl.call(this, args);
|
|
174
175
|
if (!args.generated || !this._productId) {
|
|
175
176
|
return url;
|
|
@@ -20,12 +20,22 @@ const DEFAULT_API_OPTIONS = Object.freeze({
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
function totalContent(layout, { value }) {
|
|
24
|
+
if (value === undefined) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
const { formatNumber } = layout.templates.helpers;
|
|
28
|
+
const formatted = formatNumber(value);
|
|
29
|
+
const label = value === 1 ? 'result' : 'results';
|
|
30
|
+
return `${formatted} ${label}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
const DEFAULT_LAYOUTS = Object.freeze({
|
|
24
34
|
...Workflow.DEFAULT_LAYOUTS,
|
|
25
35
|
[ROLE.QUERY]: [SearchBoxLayout.type],
|
|
26
36
|
[ROLE.PRODUCTS]: [ListLayout.type, { incremental: true, infiniteScroll: true }],
|
|
27
37
|
[ROLE.KEYWORDS]: [TextLayout.type, { raw: true }],
|
|
28
|
-
[ROLE.TOTAL]: [TextLayout.type, { raw: true,
|
|
38
|
+
[ROLE.TOTAL]: [TextLayout.type, { raw: true, templates: { content: totalContent } }],
|
|
29
39
|
[ROLE.FACETS]: [FacetsLayout.type],
|
|
30
40
|
[ROLE.SORT]: [SelectLayout.type],
|
|
31
41
|
[ROLE.MORE]: [MoreButtonLayout.type],
|