@miso.ai/client-sdk-ui 1.11.0-beta.1 → 1.11.0-beta.11
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 +6 -7
- package/dist/cjs/actor/feedback.js +6 -39
- package/dist/cjs/actor/fields.js +14 -6
- package/dist/cjs/actor/hub.js +1 -2
- package/dist/cjs/actor/index.js +0 -7
- package/dist/cjs/actor/interactions.js +4 -15
- package/dist/cjs/actor/sessions.js +2 -33
- package/dist/cjs/actor/tracker.js +25 -26
- package/dist/cjs/actor/utils.js +0 -49
- package/dist/cjs/actor/view.js +40 -40
- package/dist/cjs/actor/views.js +32 -8
- package/dist/cjs/asset/svgs.js +18 -8
- package/dist/cjs/constants.js +18 -19
- package/dist/cjs/defaults/hybrid-search/answer-box.js +19 -3
- package/dist/cjs/defaults/hybrid-search/phrases.js +5 -5
- package/dist/cjs/defaults/hybrid-search/templates.js +37 -9
- package/dist/cjs/element/role/index.js +12 -5
- package/dist/cjs/element/role/{miso-hits.js → miso-more.js} +4 -4
- package/dist/cjs/element/role/miso-total.js +20 -0
- package/dist/cjs/layout/affiliation/affiliation.js +0 -3
- package/dist/cjs/layout/banner/banner.js +0 -4
- package/dist/cjs/layout/button/more-button.js +73 -0
- package/dist/cjs/layout/container/container.js +0 -3
- package/dist/cjs/layout/error/error.js +0 -4
- package/dist/cjs/layout/index.js +7 -0
- package/dist/cjs/layout/input/facets.js +5 -5
- package/dist/cjs/layout/input/option-list.js +0 -4
- package/dist/cjs/layout/input/search-box.js +35 -17
- package/dist/cjs/layout/list/cards.js +0 -3
- package/dist/cjs/layout/list/carousel.js +0 -3
- package/dist/cjs/layout/list/collection.js +22 -7
- package/dist/cjs/layout/list/list.js +0 -3
- package/dist/cjs/layout/radio/feedback.js +0 -3
- package/dist/cjs/layout/radio/radio.js +0 -4
- package/dist/cjs/layout/raf.js +4 -2
- package/dist/cjs/layout/text/text.js +0 -4
- package/dist/cjs/layout/text/typewriter/index.js +0 -3
- package/dist/cjs/layout/triggerable.js +79 -0
- package/dist/cjs/util/states.js +0 -15
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/answer-based.js +109 -111
- package/dist/cjs/workflow/ask.js +35 -27
- package/dist/cjs/workflow/asks.js +1 -1
- package/dist/cjs/workflow/autocompletable.js +33 -0
- package/dist/cjs/workflow/autocomplete.js +122 -0
- package/dist/cjs/workflow/base.js +169 -102
- package/dist/cjs/workflow/explore.js +26 -19
- package/dist/cjs/workflow/hybrid-search-answer.js +99 -0
- package/dist/cjs/workflow/hybrid-search-results.js +66 -0
- package/dist/cjs/workflow/hybrid-search-views.js +122 -0
- package/dist/cjs/workflow/hybrid-search.js +98 -103
- package/dist/cjs/workflow/options.js +32 -17
- package/dist/cjs/workflow/processors.js +191 -17
- package/dist/cjs/workflow/recommendation.js +36 -49
- package/dist/cjs/workflow/search-based.js +228 -0
- package/dist/cjs/workflow/search.js +21 -68
- package/package.json +2 -2
- package/src/actor/data.js +2 -4
- package/src/actor/feedback.js +6 -23
- package/src/actor/fields.js +14 -6
- package/src/actor/hub.js +1 -2
- package/src/actor/index.js +0 -1
- package/src/actor/interactions.js +4 -10
- package/src/actor/sessions.js +3 -30
- package/src/actor/tracker.js +25 -19
- package/src/actor/utils.js +0 -47
- package/src/actor/view.js +27 -15
- package/src/actor/views.js +36 -8
- package/src/asset/svgs.js +19 -7
- package/src/constants.js +25 -16
- package/src/defaults/hybrid-search/answer-box.js +17 -5
- package/src/defaults/hybrid-search/phrases.js +4 -4
- package/src/defaults/hybrid-search/templates.js +25 -9
- package/src/element/role/index.js +2 -1
- package/src/element/role/{miso-hits.js → miso-more.js} +3 -3
- package/src/element/role/miso-total.js +16 -0
- package/src/layout/affiliation/affiliation.js +1 -5
- package/src/layout/banner/banner.js +0 -5
- package/src/layout/button/more-button.js +69 -0
- package/src/layout/container/container.js +1 -5
- package/src/layout/error/error.js +0 -5
- package/src/layout/index.js +2 -1
- package/src/layout/input/facets.js +5 -6
- package/src/layout/input/option-list.js +0 -5
- package/src/layout/input/search-box.js +29 -19
- package/src/layout/list/cards.js +0 -4
- package/src/layout/list/carousel.js +0 -4
- package/src/layout/list/collection.js +21 -9
- package/src/layout/list/list.js +0 -4
- package/src/layout/radio/feedback.js +0 -4
- package/src/layout/radio/radio.js +0 -5
- package/src/layout/raf.js +2 -2
- package/src/layout/text/text.js +0 -5
- package/src/layout/text/typewriter/index.js +1 -5
- package/src/layout/trackable.js +1 -1
- package/src/layout/triggerable.js +76 -0
- package/src/util/states.js +0 -14
- package/src/version.js +1 -1
- package/src/workflow/answer-based.js +101 -77
- package/src/workflow/ask.js +33 -25
- package/src/workflow/asks.js +1 -1
- package/src/workflow/autocompletable.js +29 -0
- package/src/workflow/autocomplete.js +113 -0
- package/src/workflow/base.js +147 -93
- package/src/workflow/explore.js +23 -8
- package/src/workflow/hybrid-search-answer.js +92 -0
- package/src/workflow/hybrid-search-results.js +62 -0
- package/src/workflow/hybrid-search-views.js +124 -0
- package/src/workflow/hybrid-search.js +102 -73
- package/src/workflow/options.js +26 -11
- package/src/workflow/processors.js +169 -14
- package/src/workflow/recommendation.js +32 -33
- package/src/workflow/search-based.js +222 -0
- package/src/workflow/search.js +21 -65
- package/dist/cjs/actor/autocomplete.js +0 -160
- package/dist/cjs/workflow/utils.js +0 -42
- package/src/actor/autocomplete.js +0 -133
- package/src/workflow/utils.js +0 -29
package/dist/cjs/constants.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.
|
|
6
|
+
exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.PERFORMANCE_EVENT_TYPES = exports.ORGANIC_QUESTION_SOURCE = exports.EVENT_TYPE = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
|
|
7
7
|
exports.isDataRole = isDataRole;
|
|
8
|
+
exports.isPerformanceEventType = isPerformanceEventType;
|
|
9
|
+
exports.isProductRole = isProductRole;
|
|
8
10
|
exports.validateEventType = validateEventType;
|
|
9
11
|
exports.validateTrackingStatus = validateTrackingStatus;
|
|
10
12
|
const ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = `data-miso-unit-id`;
|
|
@@ -30,34 +32,31 @@ const ROLE = exports.ROLE = Object.freeze({
|
|
|
30
32
|
AFFILIATION: 'affiliation',
|
|
31
33
|
KEYWORDS: 'keywords',
|
|
32
34
|
FACETS: 'facets',
|
|
33
|
-
|
|
35
|
+
TOTAL: 'total',
|
|
36
|
+
MORE: 'more',
|
|
34
37
|
ERROR: 'error'
|
|
35
38
|
});
|
|
36
|
-
const DATA_ROLE_SET = new Set([ROLE.PRODUCTS, ROLE.CATEGORIES, ROLE.ATTRIBUTES, ROLE.RESULTS, ROLE.ITEMS, ROLE.QUESTION, ROLE.ANSWER, ROLE.SOURCES, ROLE.RELATED_RESOURCES, ROLE.QUERY_SUGGESTIONS, ROLE.RELATED_QUESTIONS, ROLE.AFFILIATION, ROLE.FACETS, ROLE.
|
|
39
|
+
const DATA_ROLE_SET = new Set([ROLE.PRODUCTS, ROLE.CATEGORIES, ROLE.ATTRIBUTES, ROLE.RESULTS, ROLE.ITEMS, ROLE.QUESTION, ROLE.ANSWER, ROLE.SOURCES, ROLE.RELATED_RESOURCES, ROLE.QUERY_SUGGESTIONS, ROLE.RELATED_QUESTIONS, ROLE.AFFILIATION, ROLE.FACETS, ROLE.TOTAL]);
|
|
37
40
|
function isDataRole(role) {
|
|
38
41
|
return DATA_ROLE_SET.has(role);
|
|
39
42
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
CONTAINER: 'container',
|
|
45
|
-
BANNER: 'banner',
|
|
46
|
-
LIST: 'list',
|
|
47
|
-
QUERY: 'query',
|
|
48
|
-
RADIO: 'radio',
|
|
49
|
-
FILTERS: 'filters',
|
|
50
|
-
TEXT: 'text',
|
|
51
|
-
AFFILIATION: 'affiliation',
|
|
52
|
-
ERROR: 'error'
|
|
53
|
-
});
|
|
43
|
+
const PRODUCT_ROLE_SET = new Set([ROLE.PRODUCTS, ROLE.SOURCES, ROLE.RELATED_RESOURCES]);
|
|
44
|
+
function isProductRole(role) {
|
|
45
|
+
return PRODUCT_ROLE_SET.has(role);
|
|
46
|
+
}
|
|
54
47
|
const EVENT_TYPE = exports.EVENT_TYPE = Object.freeze({
|
|
55
48
|
IMPRESSION: 'impression',
|
|
56
49
|
VIEWABLE: 'viewable',
|
|
57
50
|
CLICK: 'click',
|
|
58
|
-
SUBMIT: 'submit'
|
|
51
|
+
SUBMIT: 'submit',
|
|
52
|
+
FEEDBACK: 'feedback'
|
|
59
53
|
});
|
|
60
|
-
const TRACKING_EVENT_TYPES = exports.TRACKING_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK, EVENT_TYPE.SUBMIT];
|
|
54
|
+
const TRACKING_EVENT_TYPES = exports.TRACKING_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK, EVENT_TYPE.SUBMIT, EVENT_TYPE.FEEDBACK];
|
|
55
|
+
const PERFORMANCE_EVENT_TYPES = exports.PERFORMANCE_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK];
|
|
56
|
+
const PERFORMANCE_EVENT_TYPE_SET = new Set(PERFORMANCE_EVENT_TYPES);
|
|
57
|
+
function isPerformanceEventType(type) {
|
|
58
|
+
return PERFORMANCE_EVENT_TYPE_SET.has(type);
|
|
59
|
+
}
|
|
61
60
|
const TRACKING_STATUS = exports.TRACKING_STATUS = Object.freeze({
|
|
62
61
|
UNTRACKED: 'untracked',
|
|
63
62
|
TRACKING: 'tracking',
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _constants = require("./constants.js");
|
|
8
8
|
var _constants2 = require("../../constants.js");
|
|
9
|
+
var _index = require("../../actor/index.js");
|
|
9
10
|
var _phrases = require("./phrases.js");
|
|
10
11
|
const CLASS_OPEN = 'answer-box-open';
|
|
11
12
|
const CLASS_SHOWN = 'answer-box-shown';
|
|
@@ -29,7 +30,12 @@ class AnswerBox {
|
|
|
29
30
|
|
|
30
31
|
// expose widget API
|
|
31
32
|
workflow.answerBox = this;
|
|
32
|
-
workflow._unsubscribes.push(() =>
|
|
33
|
+
workflow._unsubscribes.push(() => {
|
|
34
|
+
if (workflow.answerBox === this) {
|
|
35
|
+
this.destroy();
|
|
36
|
+
workflow.answerBox = undefined;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
33
39
|
|
|
34
40
|
// handle toggle button clicks
|
|
35
41
|
const callback = event => this._handleClick(event);
|
|
@@ -38,7 +44,9 @@ class AnswerBox {
|
|
|
38
44
|
// sync state
|
|
39
45
|
this._syncWofkflowStatus();
|
|
40
46
|
this._syncButtonText();
|
|
41
|
-
this._unsubscribes = [() => element.removeEventListener('click', callback),
|
|
47
|
+
this._unsubscribes = [() => element.removeEventListener('click', callback),
|
|
48
|
+
// cling to data rather than view, as we may miss view event when tab is inactive due to raf
|
|
49
|
+
workflow._answer._hub.on(_index.fields.data(), () => this._syncWofkflowStatus())];
|
|
42
50
|
}
|
|
43
51
|
_handleClick(_ref) {
|
|
44
52
|
let {
|
|
@@ -56,7 +64,7 @@ class AnswerBox {
|
|
|
56
64
|
_syncWofkflowStatus() {
|
|
57
65
|
const {
|
|
58
66
|
status
|
|
59
|
-
} = this._workflow;
|
|
67
|
+
} = this._workflow._answer;
|
|
60
68
|
switch (status) {
|
|
61
69
|
case _constants2.STATUS.ERRONEOUS:
|
|
62
70
|
case _constants2.STATUS.READY:
|
|
@@ -75,6 +83,13 @@ class AnswerBox {
|
|
|
75
83
|
button.textContent = phrase;
|
|
76
84
|
}
|
|
77
85
|
}
|
|
86
|
+
_syncScroll() {
|
|
87
|
+
if (!this.isOpen) {
|
|
88
|
+
this._element.scrollIntoView({
|
|
89
|
+
behavior: 'smooth'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
78
93
|
destroy() {
|
|
79
94
|
for (const unsubscribe of this._unsubscribes) {
|
|
80
95
|
unsubscribe();
|
|
@@ -110,6 +125,7 @@ for (const [method, [action, className]] of Object.entries(METHODS)) {
|
|
|
110
125
|
this._updateBoxStatus(action, className);
|
|
111
126
|
if (className === CLASS_OPEN) {
|
|
112
127
|
this._syncButtonText();
|
|
128
|
+
this._syncScroll();
|
|
113
129
|
}
|
|
114
130
|
};
|
|
115
131
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sources = exports.showMore = exports.showLess = exports.question = exports.keywords =
|
|
6
|
+
exports.total = exports.sources = exports.showMore = exports.showLess = exports.question = exports.keywords = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* The phrase
|
|
8
|
+
* The phrase to display <miso-question>
|
|
9
9
|
*/
|
|
10
|
-
const question = exports.question = 'You asked
|
|
10
|
+
const question = exports.question = 'You asked “${value}”';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The phrase displayed right before <miso-sources>
|
|
@@ -20,8 +20,8 @@ const sources = exports.sources = 'Sources';
|
|
|
20
20
|
const keywords = exports.keywords = 'You searched for “${value}”';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* The phrase to display <miso-
|
|
23
|
+
* The phrase to display <miso-total>
|
|
24
24
|
*/
|
|
25
|
-
const
|
|
25
|
+
const total = exports.total = '${value} Results';
|
|
26
26
|
const showMore = exports.showMore = 'Show more';
|
|
27
27
|
const showLess = exports.showLess = 'Show less';
|
|
@@ -31,6 +31,15 @@ class Sections extends _templates.Sections {
|
|
|
31
31
|
classes: [`${classPrefix}__answer-box-inner`]
|
|
32
32
|
}, this.answerGroup(options)), this.answerBoxToggle(options)]);
|
|
33
33
|
}
|
|
34
|
+
question(options) {
|
|
35
|
+
const {
|
|
36
|
+
phrase
|
|
37
|
+
} = this._helpers;
|
|
38
|
+
return phrase(options, {
|
|
39
|
+
name: 'question',
|
|
40
|
+
tag: 'div'
|
|
41
|
+
}).replaceAll('${value}', '<miso-question></miso-question>');
|
|
42
|
+
}
|
|
34
43
|
answerBoxToggle(options) {
|
|
35
44
|
const {
|
|
36
45
|
element
|
|
@@ -51,8 +60,8 @@ class Sections extends _templates.Sections {
|
|
|
51
60
|
} = this._helpers;
|
|
52
61
|
return container(options, {
|
|
53
62
|
name: 'search-results',
|
|
54
|
-
visibleWhen: 'ready'
|
|
55
|
-
}, [this.searchResultsInfoGroup(options), this.searchResultsFilters(options), '<miso-products></miso-products>']);
|
|
63
|
+
visibleWhen: 'loading ready'
|
|
64
|
+
}, [this.searchResultsInfoGroup(options), this.searchResultsFilters(options), '<miso-products></miso-products>', this.more(options)]);
|
|
56
65
|
}
|
|
57
66
|
searchResultsInfoGroup(options) {
|
|
58
67
|
const {
|
|
@@ -63,7 +72,7 @@ class Sections extends _templates.Sections {
|
|
|
63
72
|
} = options;
|
|
64
73
|
return element('div', {
|
|
65
74
|
classes: [`${classPrefix}__search-results-info`]
|
|
66
|
-
}, [this.keywords(options), this.
|
|
75
|
+
}, [this.keywords(options), this.total(options)]);
|
|
67
76
|
}
|
|
68
77
|
searchResultsFilters(options) {
|
|
69
78
|
const {
|
|
@@ -86,15 +95,29 @@ class Sections extends _templates.Sections {
|
|
|
86
95
|
inline: true
|
|
87
96
|
}).replaceAll('${value}', '<miso-keywords></miso-keywords>');
|
|
88
97
|
}
|
|
89
|
-
|
|
98
|
+
total(options) {
|
|
90
99
|
const {
|
|
91
100
|
phrase
|
|
92
101
|
} = this._helpers;
|
|
93
102
|
return phrase(options, {
|
|
94
|
-
name: '
|
|
103
|
+
name: 'total',
|
|
95
104
|
tag: 'div',
|
|
96
105
|
inline: true
|
|
97
|
-
}).replaceAll('${value}', '<miso-
|
|
106
|
+
}).replaceAll('${value}', '<miso-total></miso-total>');
|
|
107
|
+
}
|
|
108
|
+
more(options) {
|
|
109
|
+
if (!options.moreButton) {
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
const {
|
|
113
|
+
element
|
|
114
|
+
} = this._helpers;
|
|
115
|
+
const {
|
|
116
|
+
classPrefix
|
|
117
|
+
} = options;
|
|
118
|
+
return element('div', {
|
|
119
|
+
classes: [`${classPrefix}__search-results-more-container`]
|
|
120
|
+
}, ['<miso-more></miso-more>']);
|
|
98
121
|
}
|
|
99
122
|
}
|
|
100
123
|
const helpers = exports.helpers = (0, _commons.externalize)(new _templates.Helpers(Object.assign({}, CONSTANTS, {
|
|
@@ -112,16 +135,21 @@ function root() {
|
|
|
112
135
|
} = helpers;
|
|
113
136
|
options = normalizeOptions(options);
|
|
114
137
|
const {
|
|
115
|
-
answerBox
|
|
138
|
+
answerBox,
|
|
139
|
+
answerGroup,
|
|
140
|
+
searchResultsGroup
|
|
116
141
|
} = sections;
|
|
142
|
+
const {
|
|
143
|
+
answerBox: answerBoxOptions = true
|
|
144
|
+
} = options;
|
|
117
145
|
return [section(options, {
|
|
118
146
|
name: 'question'
|
|
119
147
|
}, [container(options, {
|
|
120
148
|
name: 'query'
|
|
121
149
|
}, '<miso-query></miso-query>')]), section(options, {
|
|
122
150
|
name: 'answer'
|
|
123
|
-
}, [answerBox(options)]), section(options, {
|
|
151
|
+
}, answerBoxOptions ? [answerBox(options)] : answerGroup(options)), section(options, {
|
|
124
152
|
name: 'search-results'
|
|
125
|
-
},
|
|
153
|
+
}, searchResultsGroup(options))].join('');
|
|
126
154
|
}
|
|
127
155
|
;
|
|
@@ -33,16 +33,16 @@ Object.defineProperty(exports, "MisoFeedbackElement", {
|
|
|
33
33
|
return _misoFeedback.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "MisoKeywordsElement", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _misoKeywords.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "MisoMoreElement", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _misoMore.default;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "MisoProductsElement", {
|
|
@@ -99,6 +99,12 @@ Object.defineProperty(exports, "MisoSovrnAffiliationElement", {
|
|
|
99
99
|
return _misoAffiliation.default;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
+
Object.defineProperty(exports, "MisoTotalElement", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _misoTotal.default;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
102
108
|
var _misoComponent = _interopRequireDefault(require("./miso-component.js"));
|
|
103
109
|
var _misoQuery = _interopRequireDefault(require("./miso-query.js"));
|
|
104
110
|
var _misoQuerySuggestions = _interopRequireDefault(require("./miso-query-suggestions.js"));
|
|
@@ -112,7 +118,8 @@ var _misoRelatedResources = _interopRequireDefault(require("./miso-related-resou
|
|
|
112
118
|
var _misoRelatedQuestions = _interopRequireDefault(require("./miso-related-questions.js"));
|
|
113
119
|
var _misoAffiliation = _interopRequireDefault(require("./miso-affiliation.js"));
|
|
114
120
|
var _misoKeywords = _interopRequireDefault(require("./miso-keywords.js"));
|
|
115
|
-
var
|
|
121
|
+
var _misoTotal = _interopRequireDefault(require("./miso-total.js"));
|
|
116
122
|
var _misoFacets = _interopRequireDefault(require("./miso-facets.js"));
|
|
123
|
+
var _misoMore = _interopRequireDefault(require("./miso-more.js"));
|
|
117
124
|
var _misoError = _interopRequireDefault(require("./miso-error.js"));
|
|
118
125
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -7,14 +7,14 @@ exports.default = void 0;
|
|
|
7
7
|
var _misoComponent = _interopRequireDefault(require("./miso-component.js"));
|
|
8
8
|
var _constants = require("../../constants.js");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
class
|
|
10
|
+
class MisoMoreElement extends _misoComponent.default {
|
|
11
11
|
constructor() {
|
|
12
12
|
super({
|
|
13
|
-
role: _constants.ROLE.
|
|
13
|
+
role: _constants.ROLE.MORE
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
static get tagName() {
|
|
17
|
-
return 'miso-
|
|
17
|
+
return 'miso-more';
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.default =
|
|
20
|
+
exports.default = MisoMoreElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _misoComponent = _interopRequireDefault(require("./miso-component.js"));
|
|
8
|
+
var _constants = require("../../constants.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
class MisoTotalElement extends _misoComponent.default {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
role: _constants.ROLE.TOTAL
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
static get tagName() {
|
|
17
|
+
return 'miso-total';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = MisoTotalElement;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _constants = require("../../constants.js");
|
|
8
7
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
9
8
|
var _svgs = require("../svgs.js");
|
|
10
9
|
const _excluded = ["className", "templates"];
|
|
@@ -27,9 +26,6 @@ const DEFAULT_TEMPLATES = Object.freeze({
|
|
|
27
26
|
// TODO: give a role and make this customizable
|
|
28
27
|
|
|
29
28
|
class BannerLayout extends _template.default {
|
|
30
|
-
static get category() {
|
|
31
|
-
return _constants.LAYOUT_CATEGORY.BANNER;
|
|
32
|
-
}
|
|
33
29
|
static get type() {
|
|
34
30
|
return TYPE;
|
|
35
31
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _constants = require("../../constants.js");
|
|
8
|
+
var _index = require("../../actor/index.js");
|
|
9
|
+
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
|
+
const _excluded = ["className", "templates"];
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
13
|
+
const TYPE = 'more-button';
|
|
14
|
+
const DEFAULT_CLASSNAME = 'miso-more-button';
|
|
15
|
+
function root(layout, state) {
|
|
16
|
+
const {
|
|
17
|
+
className,
|
|
18
|
+
role,
|
|
19
|
+
templates
|
|
20
|
+
} = layout;
|
|
21
|
+
const roleAttr = role ? ` data-role="${role}"` : '';
|
|
22
|
+
const disabledAttr = state.status !== _constants.STATUS.READY ? ' disabled' : '';
|
|
23
|
+
return `
|
|
24
|
+
<div class="${className}"${roleAttr}${disabledAttr}>
|
|
25
|
+
${templates.text(layout)}
|
|
26
|
+
</div>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
const DEFAULT_TEMPLATES = Object.freeze({
|
|
30
|
+
root,
|
|
31
|
+
text
|
|
32
|
+
});
|
|
33
|
+
function text(layout) {
|
|
34
|
+
return 'More';
|
|
35
|
+
}
|
|
36
|
+
class MoreButtonLayout extends _template.default {
|
|
37
|
+
static get type() {
|
|
38
|
+
return TYPE;
|
|
39
|
+
}
|
|
40
|
+
static get defaultTemplates() {
|
|
41
|
+
return DEFAULT_TEMPLATES;
|
|
42
|
+
}
|
|
43
|
+
static get defaultClassName() {
|
|
44
|
+
return DEFAULT_CLASSNAME;
|
|
45
|
+
}
|
|
46
|
+
constructor() {
|
|
47
|
+
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
48
|
+
let {
|
|
49
|
+
className = DEFAULT_CLASSNAME,
|
|
50
|
+
templates
|
|
51
|
+
} = _ref,
|
|
52
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
53
|
+
super(Object.assign({
|
|
54
|
+
className,
|
|
55
|
+
templates: Object.assign({}, DEFAULT_TEMPLATES, templates)
|
|
56
|
+
}, options));
|
|
57
|
+
}
|
|
58
|
+
initialize(view) {
|
|
59
|
+
this._unsubscribes = [...this._unsubscribes, view.proxyElement.on('click', e => this._handleClick(e))];
|
|
60
|
+
}
|
|
61
|
+
_handleClick(event) {
|
|
62
|
+
// only left click
|
|
63
|
+
if (event.button !== 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const button = event.target.closest('data-role="more"');
|
|
67
|
+
if (!button || button.disabled) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this._view.hub.trigger(_index.fields.more());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = MoreButtonLayout;
|
|
@@ -13,9 +13,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
13
13
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
14
14
|
const TYPE = 'container';
|
|
15
15
|
class ContainerLayout extends _raf.default {
|
|
16
|
-
static get category() {
|
|
17
|
-
return _constants.LAYOUT_CATEGORY.CONTAINER;
|
|
18
|
-
}
|
|
19
16
|
static get type() {
|
|
20
17
|
return TYPE;
|
|
21
18
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _constants = require("../../constants.js");
|
|
8
7
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
9
8
|
const _excluded = ["className", "templates"];
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -33,9 +32,6 @@ const DEFAULT_TEMPLATES = Object.freeze({
|
|
|
33
32
|
message
|
|
34
33
|
});
|
|
35
34
|
class ErrorLayout extends _template.default {
|
|
36
|
-
static get category() {
|
|
37
|
-
return _constants.LAYOUT_CATEGORY.ERROR;
|
|
38
|
-
}
|
|
39
35
|
static get type() {
|
|
40
36
|
return TYPE;
|
|
41
37
|
}
|
package/dist/cjs/layout/index.js
CHANGED
|
@@ -63,6 +63,12 @@ Object.defineProperty(exports, "ListLayout", {
|
|
|
63
63
|
return _list.default;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(exports, "MoreButtonLayout", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _moreButton.default;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
66
72
|
Object.defineProperty(exports, "OptionListLayout", {
|
|
67
73
|
enumerable: true,
|
|
68
74
|
get: function () {
|
|
@@ -108,4 +114,5 @@ var _text = _interopRequireDefault(require("./text/text.js"));
|
|
|
108
114
|
var _index = _interopRequireDefault(require("./text/typewriter/index.js"));
|
|
109
115
|
var _affiliation = _interopRequireDefault(require("./affiliation/affiliation.js"));
|
|
110
116
|
var _facets = _interopRequireDefault(require("./input/facets.js"));
|
|
117
|
+
var _moreButton = _interopRequireDefault(require("./button/more-button.js"));
|
|
111
118
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _commons = require("@miso.ai/commons");
|
|
8
|
-
var _constants = require("../../constants.js");
|
|
9
8
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
9
|
var _bindings = _interopRequireDefault(require("../../util/bindings.js"));
|
|
11
10
|
const _excluded = ["className", "templates"];
|
|
@@ -126,9 +125,6 @@ function getSelectedValues(facets) {
|
|
|
126
125
|
return selections;
|
|
127
126
|
}
|
|
128
127
|
class FacetsLayout extends _template.default {
|
|
129
|
-
static get category() {
|
|
130
|
-
return _constants.LAYOUT_CATEGORY.FILTERS;
|
|
131
|
-
}
|
|
132
128
|
static get type() {
|
|
133
129
|
return TYPE;
|
|
134
130
|
}
|
|
@@ -161,10 +157,10 @@ class FacetsLayout extends _template.default {
|
|
|
161
157
|
}
|
|
162
158
|
_render(element, data, controls) {
|
|
163
159
|
super._render(element, data, controls);
|
|
164
|
-
this._syncSelections();
|
|
165
160
|
}
|
|
166
161
|
_afterRender(element, state) {
|
|
167
162
|
this._syncBindings(element, state);
|
|
163
|
+
this._syncSelections();
|
|
168
164
|
}
|
|
169
165
|
_unrender() {
|
|
170
166
|
this._clearBindings();
|
|
@@ -270,6 +266,10 @@ class FacetsLayout extends _template.default {
|
|
|
270
266
|
return Array.from(element.querySelectorAll(`[data-role="option"]`));
|
|
271
267
|
}
|
|
272
268
|
_handleClick(event) {
|
|
269
|
+
// only left click
|
|
270
|
+
if (event.button !== 0) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
273
|
const element = event.target.closest(`[data-role="option"]`);
|
|
274
274
|
if (!element) {
|
|
275
275
|
return;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _commons = require("@miso.ai/commons");
|
|
8
|
-
var _constants = require("../../constants.js");
|
|
9
8
|
var _index = require("../../actor/index.js");
|
|
10
9
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
11
10
|
var _trackable = require("../trackable.js");
|
|
@@ -54,9 +53,6 @@ const DEFAULT_TEMPLATES = Object.freeze({
|
|
|
54
53
|
option
|
|
55
54
|
});
|
|
56
55
|
class OptionListLayout extends _template.default {
|
|
57
|
-
static get category() {
|
|
58
|
-
return _constants.LAYOUT_CATEGORY.QUERY;
|
|
59
|
-
}
|
|
60
56
|
static get type() {
|
|
61
57
|
return TYPE;
|
|
62
58
|
}
|
|
@@ -19,26 +19,40 @@ const DEFAULT_AUTOCOMPLETE_CLASSNAME = 'miso-autocomplete';
|
|
|
19
19
|
function root(layout) {
|
|
20
20
|
const {
|
|
21
21
|
className,
|
|
22
|
+
templates,
|
|
22
23
|
role,
|
|
23
24
|
options,
|
|
24
|
-
workflow,
|
|
25
25
|
autocomplete
|
|
26
26
|
} = layout;
|
|
27
27
|
const {
|
|
28
|
-
placeholder
|
|
29
|
-
buttonText
|
|
28
|
+
placeholder
|
|
30
29
|
} = options;
|
|
31
30
|
const roleAttr = role ? `data-role="${role}"` : '';
|
|
32
|
-
const buttonContent = buttonText || workflow === 'search' ? _svgs.SEARCH : _svgs.SEND;
|
|
33
31
|
return `
|
|
34
32
|
<div class="${className}" ${roleAttr}>
|
|
35
33
|
<div class="${className}__input-group">
|
|
36
34
|
<input class="${className}__input" type="text" data-role="input" ${placeholder ? `placeholder="${placeholder}"` : ''}>
|
|
37
|
-
<button class="${className}__button" type="submit" data-role="submit">${buttonContent}</button>
|
|
35
|
+
<button class="${className}__button" type="submit" data-role="submit">${templates.buttonContent(layout)}</button>
|
|
38
36
|
</div>
|
|
39
37
|
<div class="${autocomplete.className}" data-role="autocomplete"></div>
|
|
40
38
|
</div>`.trim();
|
|
41
39
|
}
|
|
40
|
+
function buttonContent(layout) {
|
|
41
|
+
const {
|
|
42
|
+
templates,
|
|
43
|
+
options
|
|
44
|
+
} = layout;
|
|
45
|
+
if (options.buttonText) {
|
|
46
|
+
return options.buttonText; // legacy
|
|
47
|
+
}
|
|
48
|
+
const {
|
|
49
|
+
buttonText,
|
|
50
|
+
buttonIcon
|
|
51
|
+
} = templates;
|
|
52
|
+
const text = typeof buttonText === 'function' ? buttonText(layout) : `${buttonText}`;
|
|
53
|
+
const icon = typeof buttonIcon === 'function' ? buttonIcon(layout) : (0, _svgs.getIcon)(buttonIcon) || `${buttonIcon}`;
|
|
54
|
+
return text + icon;
|
|
55
|
+
}
|
|
42
56
|
function completions(layout, items) {
|
|
43
57
|
const {
|
|
44
58
|
templates,
|
|
@@ -93,10 +107,7 @@ function completionList(layout, type, items) {
|
|
|
93
107
|
className,
|
|
94
108
|
templates
|
|
95
109
|
} = layout;
|
|
96
|
-
return
|
|
97
|
-
<ul class="${className}__${type}-list" data-role="${type}-list">
|
|
98
|
-
${items.map(item => templates.completionItem(layout, type, item)).join('')}
|
|
99
|
-
</ul>`.trim();
|
|
110
|
+
return `<ul class="${className}__${type}-list" data-role="${type}-list">${items.map(item => templates.completionItem(layout, type, item)).join('')}</ul>`;
|
|
100
111
|
}
|
|
101
112
|
function completionItem(layout, type, item) {
|
|
102
113
|
const {
|
|
@@ -110,6 +121,9 @@ function completionItem(layout, type, item) {
|
|
|
110
121
|
}
|
|
111
122
|
const DEFAULT_TEMPLATES = Object.freeze({
|
|
112
123
|
root,
|
|
124
|
+
buttonContent,
|
|
125
|
+
buttonText: '',
|
|
126
|
+
buttonIcon: 'search',
|
|
113
127
|
completions,
|
|
114
128
|
completionList,
|
|
115
129
|
completionItem,
|
|
@@ -125,9 +139,6 @@ const DEFAULT_AUTOCOMPLETE_OPTIONS = Object.freeze({
|
|
|
125
139
|
debounce: 300
|
|
126
140
|
});
|
|
127
141
|
class SearchBoxLayout extends _template.default {
|
|
128
|
-
static get category() {
|
|
129
|
-
return _constants.LAYOUT_CATEGORY.QUERY;
|
|
130
|
-
}
|
|
131
142
|
static get type() {
|
|
132
143
|
return TYPE;
|
|
133
144
|
}
|
|
@@ -161,7 +172,7 @@ class SearchBoxLayout extends _template.default {
|
|
|
161
172
|
proxyElement,
|
|
162
173
|
hub
|
|
163
174
|
} = view;
|
|
164
|
-
this._unsubscribes = [...this._unsubscribes, proxyElement.on('input', e => this._syncInput(e)), proxyElement.on('keydown', e => this._handleKeyDown(e)), proxyElement.on('click', e => this._handleClick(e)), proxyElement.on('focusin', e => this._handleFocusIn(e)), proxyElement.on('focusout', e => this._handleFocusOut(e)), hub.on(_index.fields.
|
|
175
|
+
this._unsubscribes = [...this._unsubscribes, proxyElement.on('input', e => this._syncInput(e)), proxyElement.on('keydown', e => this._handleKeyDown(e)), proxyElement.on('click', e => this._handleClick(e)), proxyElement.on('focusin', e => this._handleFocusIn(e)), proxyElement.on('focusout', e => this._handleFocusOut(e)), hub.on(_index.fields.completions(), () => view.refresh({
|
|
165
176
|
force: true
|
|
166
177
|
}))];
|
|
167
178
|
}
|
|
@@ -195,7 +206,7 @@ class SearchBoxLayout extends _template.default {
|
|
|
195
206
|
state
|
|
196
207
|
});
|
|
197
208
|
return Object.assign({}, state, {
|
|
198
|
-
completions: this._view.hub.states[_index.fields.
|
|
209
|
+
completions: this._view.hub.states[_index.fields.completions()]
|
|
199
210
|
});
|
|
200
211
|
}
|
|
201
212
|
_render(element, data, controls) {
|
|
@@ -204,6 +215,8 @@ class SearchBoxLayout extends _template.default {
|
|
|
204
215
|
super._render(element, data, controls);
|
|
205
216
|
}
|
|
206
217
|
this._updateCompletions(element, data, controls);
|
|
218
|
+
}
|
|
219
|
+
_afterRender(element, state) {
|
|
207
220
|
this._fullfillFocusRequest(element);
|
|
208
221
|
this._fullfillValueRequest(element);
|
|
209
222
|
}
|
|
@@ -220,9 +233,12 @@ class SearchBoxLayout extends _template.default {
|
|
|
220
233
|
}
|
|
221
234
|
const {
|
|
222
235
|
status = _constants.STATUS.INITIAL,
|
|
223
|
-
|
|
236
|
+
session,
|
|
224
237
|
value: completions
|
|
225
238
|
} = state.completions;
|
|
239
|
+
const {
|
|
240
|
+
index
|
|
241
|
+
} = session;
|
|
226
242
|
if (rendered && rendered.completions.index === index && rendered.completions.status === status) {
|
|
227
243
|
return;
|
|
228
244
|
}
|
|
@@ -315,7 +331,7 @@ class SearchBoxLayout extends _template.default {
|
|
|
315
331
|
target,
|
|
316
332
|
isComposing
|
|
317
333
|
} = _ref8;
|
|
318
|
-
if (!isComposing && key === 'Enter' && target.matches('input')) {
|
|
334
|
+
if (!isComposing && key === 'Enter' && target.matches('[data-role="input"]')) {
|
|
319
335
|
this._submit(target.value);
|
|
320
336
|
target.blur();
|
|
321
337
|
}
|
|
@@ -384,7 +400,9 @@ class SearchBoxLayout extends _template.default {
|
|
|
384
400
|
if (!options) {
|
|
385
401
|
return;
|
|
386
402
|
}
|
|
387
|
-
this._view.tracker.submit(
|
|
403
|
+
this._view.tracker.submit({
|
|
404
|
+
value
|
|
405
|
+
}); // not array
|
|
388
406
|
}
|
|
389
407
|
}
|
|
390
408
|
exports.default = SearchBoxLayout;
|