@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.
@@ -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} Results';
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 content = value !== undefined ? (0, _commons.escapeHtml)(getFormatFunction(layout)(value)) : '';
27
- return raw ? content : `<${tag} class="${className}" ${roleAttr}>${content}</${tag}>`;
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() {
@@ -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.13.0-beta.4';
7
+ var _default = exports.default = '1.13.0-beta.5';
@@ -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
- format: 'number'
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": "MisoAI/miso-client-js-sdk",
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.4"
33
+ "@miso.ai/commons": "1.13.0-beta.5"
30
34
  },
31
- "version": "1.13.0-beta.4"
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} Results';
19
+ export const total = '${value}';
20
20
 
21
21
  export const showMore = 'Show more';
22
22
  export const showLess = 'Show less';
@@ -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, { value }) {
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 content = value !== undefined ? escapeHtml(getFormatFunction(layout)(value)) : '';
11
- return raw ? content : `<${tag} class="${className}" ${roleAttr}>${content}</${tag}>`;
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.4';
1
+ export default '1.13.0-beta.5';
@@ -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, format: 'number' }],
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],