@miso.ai/client-sdk-ui 1.13.2-beta.0 → 1.14.0-beta.2
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/asset/svgs.js +15 -4
- package/dist/cjs/combo/ask/index.js +2 -2
- package/dist/cjs/constants.js +118 -98
- package/dist/cjs/defaults/ask/controls.js +1 -1
- package/dist/cjs/defaults/hybrid-search/answer-box.js +4 -4
- package/dist/cjs/defaults.js +169 -0
- package/dist/cjs/element/container/index.js +14 -0
- package/dist/cjs/element/container/miso-ask.js +3 -3
- package/dist/cjs/element/container/miso-conversation.js +21 -0
- package/dist/cjs/element/container/miso-explore.js +1 -1
- package/dist/cjs/element/container/miso-history.js +21 -0
- package/dist/cjs/element/container/miso-hybrid-search.js +1 -1
- package/dist/cjs/element/container/miso-recommendation.js +1 -1
- package/dist/cjs/element/container/miso-search.js +1 -1
- package/dist/cjs/element/context/miso-follow-ups.js +1 -1
- package/dist/cjs/element/role/index.js +42 -0
- package/dist/cjs/element/role/miso-messages.js +20 -0
- package/dist/cjs/element/role/miso-new-thread.js +20 -0
- package/dist/cjs/element/role/miso-rename.js +20 -0
- package/dist/cjs/element/role/miso-subscription.js +20 -0
- package/dist/cjs/element/role/miso-threads.js +20 -0
- package/dist/cjs/element/role/miso-title.js +20 -0
- package/dist/cjs/layout/affiliation/affiliation.js +1 -1
- package/dist/cjs/layout/banner/banner.js +2 -1
- package/dist/cjs/layout/button/button.js +130 -0
- package/dist/cjs/layout/button/checkbox.js +115 -0
- package/dist/cjs/layout/button/more-button.js +3 -3
- package/dist/cjs/layout/container/container.js +1 -1
- package/dist/cjs/layout/error/error.js +2 -1
- package/dist/cjs/layout/index.js +28 -0
- package/dist/cjs/layout/input/facets.js +4 -3
- package/dist/cjs/layout/input/option-list.js +3 -2
- package/dist/cjs/layout/input/search-box.js +42 -9
- package/dist/cjs/layout/input/select.js +2 -1
- package/dist/cjs/layout/list/cards.js +2 -1
- package/dist/cjs/layout/list/carousel.js +2 -1
- package/dist/cjs/layout/list/collection.js +5 -0
- package/dist/cjs/layout/list/gallery.js +2 -1
- package/dist/cjs/layout/list/horizontal.js +2 -1
- package/dist/cjs/layout/list/list.js +2 -1
- package/dist/cjs/layout/list/messages.js +346 -0
- package/dist/cjs/layout/list/threads.js +257 -0
- package/dist/cjs/layout/mixin/trackable.js +4 -5
- package/dist/cjs/layout/mixin/triggerable.js +2 -2
- package/dist/cjs/layout/radio/feedback.js +4 -3
- package/dist/cjs/layout/templates.js +70 -0
- package/dist/cjs/layout/text/text.js +2 -1
- package/dist/cjs/layout/text/typewriter/index.js +4 -2
- package/dist/cjs/plugin.js +43 -104
- package/dist/cjs/util/confirm.js +33 -0
- package/dist/cjs/util/modal.js +48 -0
- package/dist/cjs/util/prompt.js +47 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +5 -4
- package/src/CLAUDE.md +48 -105
- package/src/asset/svgs.js +14 -3
- package/src/combo/ask/index.js +2 -2
- package/src/constants.js +37 -147
- package/src/defaults/ask/controls.js +1 -1
- package/src/defaults/hybrid-search/answer-box.js +2 -2
- package/src/defaults.js +107 -0
- package/src/element/container/index.js +2 -0
- package/src/element/container/miso-ask.js +3 -3
- package/src/element/container/miso-conversation.js +19 -0
- package/src/element/container/miso-explore.js +1 -1
- package/src/element/container/miso-history.js +19 -0
- package/src/element/container/miso-hybrid-search.js +1 -1
- package/src/element/container/miso-recommendation.js +1 -1
- package/src/element/container/miso-search.js +1 -1
- package/src/element/context/miso-follow-ups.js +1 -1
- package/src/element/role/index.js +6 -0
- package/src/element/role/miso-messages.js +16 -0
- package/src/element/role/miso-new-thread.js +16 -0
- package/src/element/role/miso-rename.js +16 -0
- package/src/element/role/miso-subscription.js +16 -0
- package/src/element/role/miso-threads.js +16 -0
- package/src/element/role/miso-title.js +16 -0
- package/src/layout/affiliation/affiliation.js +2 -2
- package/src/layout/banner/banner.js +2 -1
- package/src/layout/button/button.js +116 -0
- package/src/layout/button/checkbox.js +91 -0
- package/src/layout/button/more-button.js +3 -3
- package/src/layout/container/container.js +2 -2
- package/src/layout/error/error.js +2 -1
- package/src/layout/index.js +4 -0
- package/src/layout/input/facets.js +3 -2
- package/src/layout/input/option-list.js +3 -2
- package/src/layout/input/search-box.js +41 -6
- package/src/layout/input/select.js +2 -1
- package/src/layout/list/cards.js +2 -1
- package/src/layout/list/carousel.js +2 -1
- package/src/layout/list/collection.js +6 -1
- package/src/layout/list/gallery.js +2 -1
- package/src/layout/list/horizontal.js +2 -1
- package/src/layout/list/list.js +2 -1
- package/src/layout/list/messages.js +318 -0
- package/src/layout/list/threads.js +206 -0
- package/src/layout/mixin/trackable.js +2 -3
- package/src/layout/mixin/triggerable.js +1 -1
- package/src/layout/radio/feedback.js +3 -2
- package/src/layout/templates.js +62 -0
- package/src/layout/text/text.js +2 -1
- package/src/layout/text/typewriter/index.js +5 -3
- package/src/plugin.js +31 -117
- package/src/util/confirm.js +28 -0
- package/src/util/modal.js +49 -0
- package/src/util/prompt.js +42 -0
- package/src/version.js +1 -1
- package/dist/cjs/actor/data.js +0 -132
- package/dist/cjs/actor/feedback.js +0 -29
- package/dist/cjs/actor/fields.js +0 -57
- package/dist/cjs/actor/filters.js +0 -161
- package/dist/cjs/actor/hub.js +0 -57
- package/dist/cjs/actor/index.js +0 -73
- package/dist/cjs/actor/interactions.js +0 -36
- package/dist/cjs/actor/sessions.js +0 -25
- package/dist/cjs/actor/tracker-states.js +0 -61
- package/dist/cjs/actor/tracker.js +0 -109
- package/dist/cjs/actor/trackers.js +0 -52
- package/dist/cjs/actor/utils.js +0 -15
- package/dist/cjs/actor/view.js +0 -294
- package/dist/cjs/actor/views.js +0 -209
- package/dist/cjs/source.js +0 -27
- package/dist/cjs/util/proxy.js +0 -88
- package/dist/cjs/util/trackers.js +0 -88
- package/dist/cjs/workflow/affiliations.js +0 -140
- package/dist/cjs/workflow/answer-based.js +0 -337
- package/dist/cjs/workflow/ask.js +0 -319
- package/dist/cjs/workflow/asks.js +0 -150
- package/dist/cjs/workflow/autocompletable.js +0 -63
- package/dist/cjs/workflow/autocomplete.js +0 -120
- package/dist/cjs/workflow/base.js +0 -418
- package/dist/cjs/workflow/context.js +0 -19
- package/dist/cjs/workflow/explore.js +0 -210
- package/dist/cjs/workflow/explores.js +0 -21
- package/dist/cjs/workflow/hybrid-search-answer.js +0 -88
- package/dist/cjs/workflow/hybrid-search-views.js +0 -109
- package/dist/cjs/workflow/hybrid-search.js +0 -213
- package/dist/cjs/workflow/index.js +0 -41
- package/dist/cjs/workflow/options/api.js +0 -41
- package/dist/cjs/workflow/options/auto-query.js +0 -97
- package/dist/cjs/workflow/options/configurable.js +0 -45
- package/dist/cjs/workflow/options/data-processor.js +0 -20
- package/dist/cjs/workflow/options/filters.js +0 -15
- package/dist/cjs/workflow/options/index.js +0 -126
- package/dist/cjs/workflow/options/interactions.js +0 -41
- package/dist/cjs/workflow/options/layouts.js +0 -79
- package/dist/cjs/workflow/options/options.js +0 -156
- package/dist/cjs/workflow/options/pagination.js +0 -25
- package/dist/cjs/workflow/options/roles.js +0 -15
- package/dist/cjs/workflow/options/templates.js +0 -30
- package/dist/cjs/workflow/options/trackers.js +0 -83
- package/dist/cjs/workflow/options/utils.js +0 -33
- package/dist/cjs/workflow/processors.js +0 -607
- package/dist/cjs/workflow/recommendation.js +0 -57
- package/dist/cjs/workflow/recommendations.js +0 -18
- package/dist/cjs/workflow/search-based.js +0 -337
- package/dist/cjs/workflow/search.js +0 -64
- package/dist/cjs/workflow/unit.js +0 -57
- package/dist/cjs/workflow/units.js +0 -42
- package/dist/cjs/workflow/use-link.js +0 -49
- package/src/actor/data.js +0 -106
- package/src/actor/feedback.js +0 -28
- package/src/actor/fields.js +0 -51
- package/src/actor/filters.js +0 -149
- package/src/actor/hub.js +0 -47
- package/src/actor/index.js +0 -10
- package/src/actor/interactions.js +0 -32
- package/src/actor/sessions.js +0 -21
- package/src/actor/tracker-states.js +0 -57
- package/src/actor/tracker.js +0 -104
- package/src/actor/trackers.js +0 -45
- package/src/actor/utils.js +0 -7
- package/src/actor/view.js +0 -272
- package/src/actor/views.js +0 -224
- package/src/source.js +0 -17
- package/src/util/proxy.js +0 -81
- package/src/util/trackers.js +0 -84
- package/src/workflow/affiliations.js +0 -121
- package/src/workflow/answer-based.js +0 -312
- package/src/workflow/ask.js +0 -284
- package/src/workflow/asks.js +0 -143
- package/src/workflow/autocompletable.js +0 -67
- package/src/workflow/autocomplete.js +0 -114
- package/src/workflow/base.js +0 -396
- package/src/workflow/context.js +0 -16
- package/src/workflow/explore.js +0 -194
- package/src/workflow/explores.js +0 -18
- package/src/workflow/hybrid-search-answer.js +0 -73
- package/src/workflow/hybrid-search-views.js +0 -116
- package/src/workflow/hybrid-search.js +0 -230
- package/src/workflow/index.js +0 -5
- package/src/workflow/options/api.js +0 -31
- package/src/workflow/options/auto-query.js +0 -70
- package/src/workflow/options/configurable.js +0 -48
- package/src/workflow/options/data-processor.js +0 -15
- package/src/workflow/options/filters.js +0 -10
- package/src/workflow/options/index.js +0 -11
- package/src/workflow/options/interactions.js +0 -36
- package/src/workflow/options/layouts.js +0 -73
- package/src/workflow/options/options.js +0 -175
- package/src/workflow/options/pagination.js +0 -18
- package/src/workflow/options/roles.js +0 -12
- package/src/workflow/options/templates.js +0 -27
- package/src/workflow/options/trackers.js +0 -80
- package/src/workflow/options/utils.js +0 -26
- package/src/workflow/processors.js +0 -490
- package/src/workflow/recommendation.js +0 -63
- package/src/workflow/recommendations.js +0 -14
- package/src/workflow/search-based.js +0 -329
- package/src/workflow/search.js +0 -73
- package/src/workflow/unit.js +0 -51
- package/src/workflow/units.js +0 -43
- package/src/workflow/use-link.js +0 -41
package/src/defaults.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ROLE, LAYOUT_TYPE } from './constants.js';
|
|
2
|
+
import { compactArticle, compactArticleInfoBlock } from './layout/templates.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default layout options of each workflow, keyed by workflow name. The UI
|
|
6
|
+
* plugin seeds the workflow plugin's defaults store with these values at
|
|
7
|
+
* install. The tables mirror the workflow class hierarchy.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const BASE_LAYOUTS = {
|
|
11
|
+
[ROLE.CONTAINER]: LAYOUT_TYPE.CONTAINER,
|
|
12
|
+
[ROLE.ERROR]: LAYOUT_TYPE.ERROR,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const ANSWER_BASED_LAYOUTS = {
|
|
16
|
+
...BASE_LAYOUTS,
|
|
17
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX, { placeholder: 'Ask a question' }],
|
|
18
|
+
[ROLE.QUESTION]: [LAYOUT_TYPE.TEXT, { tag: 'h2' }],
|
|
19
|
+
[ROLE.ANSWER]: LAYOUT_TYPE.TYPEWRITER,
|
|
20
|
+
[ROLE.FEEDBACK]: LAYOUT_TYPE.FEEDBACK,
|
|
21
|
+
[ROLE.IMAGES]: [LAYOUT_TYPE.GALLERY, { incremental: true, itemType: 'image' }],
|
|
22
|
+
[ROLE.SOURCES]: [LAYOUT_TYPE.LIST, { incremental: true, itemType: 'article', templates: { ordered: true } }],
|
|
23
|
+
[ROLE.AFFILIATION]: [LAYOUT_TYPE.AFFILIATION, { incremental: true, itemType: 'affiliation', link: { rel: 'noopener nofollow' } }],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function totalContent(layout, { value }) {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
const { formatNumber } = layout.templates.helpers;
|
|
31
|
+
const formatted = formatNumber(value);
|
|
32
|
+
const label = value === 1 ? 'result' : 'results';
|
|
33
|
+
return `${formatted} ${label}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SEARCH_BASED_LAYOUTS = {
|
|
37
|
+
...BASE_LAYOUTS,
|
|
38
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX],
|
|
39
|
+
[ROLE.PRODUCTS]: [LAYOUT_TYPE.LIST, { incremental: true, infiniteScroll: true }],
|
|
40
|
+
[ROLE.KEYWORDS]: [LAYOUT_TYPE.TEXT, { raw: true }],
|
|
41
|
+
[ROLE.TOTAL]: [LAYOUT_TYPE.TEXT, { raw: true, templates: { content: totalContent } }],
|
|
42
|
+
[ROLE.FACETS]: [LAYOUT_TYPE.FACETS],
|
|
43
|
+
[ROLE.SORT]: [LAYOUT_TYPE.SELECT],
|
|
44
|
+
[ROLE.MORE]: [LAYOUT_TYPE.MORE_BUTTON],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const defaultLayouts = Object.freeze({
|
|
48
|
+
|
|
49
|
+
'ask': Object.freeze({
|
|
50
|
+
...ANSWER_BASED_LAYOUTS,
|
|
51
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX, { templates: { buttonIcon: 'send' } }],
|
|
52
|
+
[ROLE.REASONING]: LAYOUT_TYPE.TYPEWRITER,
|
|
53
|
+
[ROLE.RELATED_RESOURCES]: [LAYOUT_TYPE.LIST, { incremental: true, itemType: 'article' }],
|
|
54
|
+
[ROLE.QUERY_SUGGESTIONS]: LAYOUT_TYPE.OPTION_LIST,
|
|
55
|
+
[ROLE.FOLLOW_UP_QUESTIONS]: LAYOUT_TYPE.OPTION_LIST,
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
'search': Object.freeze({
|
|
59
|
+
...SEARCH_BASED_LAYOUTS,
|
|
60
|
+
}),
|
|
61
|
+
|
|
62
|
+
'hybrid-search': Object.freeze({
|
|
63
|
+
...ANSWER_BASED_LAYOUTS,
|
|
64
|
+
...SEARCH_BASED_LAYOUTS,
|
|
65
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX, { placeholder: '' }],
|
|
66
|
+
[ROLE.QUESTION]: [LAYOUT_TYPE.TEXT, { raw: true }],
|
|
67
|
+
[ROLE.SOURCES]: [
|
|
68
|
+
LAYOUT_TYPE.HORIZONTAL,
|
|
69
|
+
{
|
|
70
|
+
incremental: true,
|
|
71
|
+
itemType: 'article',
|
|
72
|
+
templates: {
|
|
73
|
+
ordered: true,
|
|
74
|
+
article: compactArticle,
|
|
75
|
+
articleInfoBlock: compactArticleInfoBlock
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
}),
|
|
80
|
+
|
|
81
|
+
'recommendation': Object.freeze({
|
|
82
|
+
...BASE_LAYOUTS,
|
|
83
|
+
[ROLE.PRODUCTS]: LAYOUT_TYPE.LIST,
|
|
84
|
+
}),
|
|
85
|
+
|
|
86
|
+
'explore': Object.freeze({
|
|
87
|
+
...BASE_LAYOUTS,
|
|
88
|
+
[ROLE.RELATED_QUESTIONS]: [LAYOUT_TYPE.LIST, { itemType: 'question', link: { rel: 'noopener nofollow' } }], // TODO: should define by useLink()
|
|
89
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX, { placeholder: 'Ask a question' }],
|
|
90
|
+
}),
|
|
91
|
+
|
|
92
|
+
'history': Object.freeze({
|
|
93
|
+
...BASE_LAYOUTS,
|
|
94
|
+
[ROLE.THREADS]: [LAYOUT_TYPE.THREADS, { itemType: 'thread', incremental: true }],
|
|
95
|
+
[ROLE.NEW_THREAD]: [LAYOUT_TYPE.BUTTON, { icon: 'plus', text: 'New chat' }],
|
|
96
|
+
}),
|
|
97
|
+
|
|
98
|
+
'conversation': Object.freeze({
|
|
99
|
+
...BASE_LAYOUTS,
|
|
100
|
+
[ROLE.MESSAGES]: [LAYOUT_TYPE.MESSAGES, { itemType: 'message', incremental: true }],
|
|
101
|
+
[ROLE.QUERY]: [LAYOUT_TYPE.SEARCH_BOX, { placeholder: 'Ask a follow-up question', clearOnSubmit: true, blurOnSubmit: false, disableWhenOngoing: true, templates: { buttonIcon: 'send' } }],
|
|
102
|
+
[ROLE.TITLE]: [LAYOUT_TYPE.TEXT, { tag: 'div' }],
|
|
103
|
+
[ROLE.RENAME]: [LAYOUT_TYPE.BUTTON, { icon: 'pencil', prompt: { title: 'Rename thread', placeholder: 'Thread name', confirmText: 'Rename' } }],
|
|
104
|
+
[ROLE.SUBSCRIPTION]: [LAYOUT_TYPE.CHECKBOX, { icon: 'bell', text: 'Subscribe', checkedIcon: 'bell-fill', checkedText: 'Subscribed' }],
|
|
105
|
+
}),
|
|
106
|
+
|
|
107
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as MisoAskElement } from './miso-ask.js';
|
|
2
2
|
export { default as MisoExploreElement } from './miso-explore.js';
|
|
3
|
+
export { default as MisoHistoryElement } from './miso-history.js';
|
|
4
|
+
export { default as MisoConversationElement } from './miso-conversation.js';
|
|
3
5
|
export { default as MisoHybridSearchElement } from './miso-hybrid-search.js';
|
|
4
6
|
export { default as MisoSearchElement } from './miso-search.js';
|
|
5
7
|
export { default as MisoRecommendationElement } from './miso-recommendation.js';
|
|
@@ -22,13 +22,13 @@ export default class MisoAskElement extends MisoContainerElement {
|
|
|
22
22
|
|
|
23
23
|
_getWorkflow(client) {
|
|
24
24
|
if (this.boundToActiveWorkflow) {
|
|
25
|
-
return client.
|
|
25
|
+
return client.workflows.asks.active;
|
|
26
26
|
}
|
|
27
27
|
return this._getWorkflowByParentQuestionId(client, this.parentQuestionId);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
_getWorkflowByParentQuestionId(client, id) {
|
|
31
|
-
return client.
|
|
31
|
+
return client.workflows.asks.getByParentQuestionId(id, { autoCreate: true });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// properties //
|
|
@@ -66,7 +66,7 @@ export default class MisoAskElement extends MisoContainerElement {
|
|
|
66
66
|
async connectedCallback() {
|
|
67
67
|
await super.connectedCallback();
|
|
68
68
|
if (document.body.contains(this)) { // in case already disconnected
|
|
69
|
-
const context = this._client.
|
|
69
|
+
const context = this._client.workflows.asks;
|
|
70
70
|
this._unsubscribes = [
|
|
71
71
|
...(this._unsubscribes || []),
|
|
72
72
|
context.on('active', (event) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import MisoContainerElement from './miso-container.js';
|
|
2
|
+
|
|
3
|
+
const TAG_NAME = 'miso-conversation';
|
|
4
|
+
|
|
5
|
+
export default class MisoConversationElement extends MisoContainerElement {
|
|
6
|
+
|
|
7
|
+
static get tagName() {
|
|
8
|
+
return TAG_NAME;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return MisoContainerElement.observedAttributes;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_getWorkflow(client) {
|
|
16
|
+
return client.workflows.conversation;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import MisoContainerElement from './miso-container.js';
|
|
2
|
+
|
|
3
|
+
const TAG_NAME = 'miso-history';
|
|
4
|
+
|
|
5
|
+
export default class MisoHistoryElement extends MisoContainerElement {
|
|
6
|
+
|
|
7
|
+
static get tagName() {
|
|
8
|
+
return TAG_NAME;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return MisoContainerElement.observedAttributes;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_getWorkflow(client) {
|
|
16
|
+
return client.workflows.history;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -18,4 +18,10 @@ export { default as MisoTotalElement } from './miso-total.js';
|
|
|
18
18
|
export { default as MisoFacetsElement } from './miso-facets.js';
|
|
19
19
|
export { default as MisoMoreElement } from './miso-more.js';
|
|
20
20
|
export { default as MisoSortElement } from './miso-sort.js';
|
|
21
|
+
export { default as MisoThreadsElement } from './miso-threads.js';
|
|
22
|
+
export { default as MisoNewThreadElement } from './miso-new-thread.js';
|
|
23
|
+
export { default as MisoTitleElement } from './miso-title.js';
|
|
24
|
+
export { default as MisoRenameElement } from './miso-rename.js';
|
|
25
|
+
export { default as MisoSubscriptionElement } from './miso-subscription.js';
|
|
26
|
+
export { default as MisoMessagesElement } from './miso-messages.js';
|
|
21
27
|
export { default as MisoErrorElement } from './miso-error.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoMessagesElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.MESSAGES,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-messages';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoNewThreadElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.NEW_THREAD,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-new-thread';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoRenameElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.RENAME,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-rename';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoSubscriptionElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.SUBSCRIPTION,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-subscription';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoThreadsElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.THREADS,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-threads';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MisoComponentElement from './miso-component.js';
|
|
2
|
+
import { ROLE } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
export default class MisoTitleElement extends MisoComponentElement {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
role: ROLE.TITLE,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get tagName() {
|
|
13
|
+
return 'miso-title';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CarouselItemViewabilityObserver, requestAnimationFrame as raf } from '@miso.ai/commons';
|
|
2
|
-
import { STATUS } from '../../constants.js';
|
|
2
|
+
import { STATUS, LAYOUT_TYPE } from '../../constants.js';
|
|
3
3
|
import CollectionLayout from '../list/collection.js';
|
|
4
4
|
import { affiliation, helpers } from '../templates.js';
|
|
5
5
|
import { TRIANGLE } from '../../asset/svgs.js';
|
|
6
6
|
import { setOrRemoveAttribute } from '../../util/dom.js';
|
|
7
7
|
|
|
8
|
-
const TYPE =
|
|
8
|
+
const TYPE = LAYOUT_TYPE.AFFILIATION;
|
|
9
9
|
const DEFAULT_CLASSNAME = 'miso-affiliation';
|
|
10
10
|
|
|
11
11
|
function root(layout, state) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { LAYOUT_TYPE } from '../../constants.js';
|
|
1
2
|
import TemplateBasedLayout from '../template.js';
|
|
2
3
|
import { LOGO } from '../svgs.js';
|
|
3
4
|
|
|
4
|
-
const TYPE =
|
|
5
|
+
const TYPE = LAYOUT_TYPE.BANNER;
|
|
5
6
|
const DEFAULT_CLASSNAME = 'miso-banner';
|
|
6
7
|
|
|
7
8
|
function root(layout) {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { escapeHtml } from '@miso.ai/commons';
|
|
2
|
+
import { LAYOUT_TYPE } from '../../constants.js';
|
|
3
|
+
import TemplateBasedLayout from '../template.js';
|
|
4
|
+
import { getIcon } from '../../asset/svgs.js';
|
|
5
|
+
import prompt from '../../util/prompt.js';
|
|
6
|
+
|
|
7
|
+
const TYPE = LAYOUT_TYPE.BUTTON;
|
|
8
|
+
const DEFAULT_CLASSNAME = 'miso-button';
|
|
9
|
+
|
|
10
|
+
function root(layout, state) {
|
|
11
|
+
const { className, role, templates } = layout;
|
|
12
|
+
const roleAttr = role ? ` data-role="${role}"` : '';
|
|
13
|
+
return `<button type="button" class="${className}"${roleAttr}>${templates.icon(layout, state)}${templates.text(layout, state)}</button>`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function icon(layout) {
|
|
17
|
+
const { icon } = layout.options;
|
|
18
|
+
return icon ? getIcon(icon) : '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function text(layout) {
|
|
22
|
+
const { className, options: { text } } = layout;
|
|
23
|
+
return text ? `<span class="${className}__text">${escapeHtml(text)}</span>` : '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const DEFAULT_TEMPLATES = Object.freeze({
|
|
27
|
+
root,
|
|
28
|
+
icon,
|
|
29
|
+
text,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A generic button: an icon and a label, both configurable (`icon` is an icon
|
|
34
|
+
* name, `text` the label; either can be omitted), emitting a `submit` view
|
|
35
|
+
* event when clicked — for the workflow to act on, per role.
|
|
36
|
+
*
|
|
37
|
+
* It carries no data of its own, so it renders in any state; use it for
|
|
38
|
+
* actions that stand apart from the data they act on, such as the new chat
|
|
39
|
+
* button (role `new_thread`) of the chat history interface.
|
|
40
|
+
*
|
|
41
|
+
* With a `prompt` option, the click asks for a text through the shared
|
|
42
|
+
* prompt dialog first, pre-filled with the control's current value — the
|
|
43
|
+
* role's mapped data value, as of the latest render — and the submit event
|
|
44
|
+
* carries the confirmed text as `value`; a cancelled, cleared, or unchanged
|
|
45
|
+
* dialog submits nothing. Use it for actions that take a text input, such
|
|
46
|
+
* as the rename button (role `rename`) of the conversation header, whose
|
|
47
|
+
* role maps to `'thread.title'`.
|
|
48
|
+
*/
|
|
49
|
+
export default class ButtonLayout extends TemplateBasedLayout {
|
|
50
|
+
|
|
51
|
+
static get type() {
|
|
52
|
+
return TYPE;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static get defaultTemplates() {
|
|
56
|
+
return DEFAULT_TEMPLATES;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get defaultClassName() {
|
|
60
|
+
return DEFAULT_CLASSNAME;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
constructor({ className = DEFAULT_CLASSNAME, templates, ...options } = {}) {
|
|
64
|
+
super({
|
|
65
|
+
className,
|
|
66
|
+
templates: { ...DEFAULT_TEMPLATES, ...templates },
|
|
67
|
+
...options,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
initialize(view) {
|
|
72
|
+
this._unsubscribes = [
|
|
73
|
+
...this._unsubscribes,
|
|
74
|
+
view.proxyElement.on('click', event => this._handleClick(event)),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_handleClick(event) {
|
|
79
|
+
// only left click
|
|
80
|
+
if (event.button !== 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const button = event.target.closest(`button.${this.className}`);
|
|
84
|
+
if (!button || button.disabled) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.options.prompt ? this._submitViaPrompt(event) : this._submit(event);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
_submit(event, payload) {
|
|
91
|
+
const { session } = this._view._state || {};
|
|
92
|
+
this._view._emit('submit', { session, domEvent: event, ...payload });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async _submitViaPrompt(event) {
|
|
96
|
+
const current = this._currentValue();
|
|
97
|
+
const value = await prompt({
|
|
98
|
+
value: typeof current === 'string' ? current : '',
|
|
99
|
+
...this.options.prompt,
|
|
100
|
+
});
|
|
101
|
+
if (!value || value === current) {
|
|
102
|
+
return; // cancelled, cleared, or unchanged
|
|
103
|
+
}
|
|
104
|
+
this._submit(event, { value });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The current value of the control: the role's mapped data value, as of
|
|
109
|
+
* the latest render.
|
|
110
|
+
*/
|
|
111
|
+
_currentValue() {
|
|
112
|
+
const state = this._element && this._rendered.get(this._element);
|
|
113
|
+
return state && state.value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { escapeHtml } from '@miso.ai/commons';
|
|
2
|
+
import { LAYOUT_TYPE } from '../../constants.js';
|
|
3
|
+
import ButtonLayout from './button.js';
|
|
4
|
+
import { getIcon } from '../../asset/svgs.js';
|
|
5
|
+
|
|
6
|
+
const TYPE = LAYOUT_TYPE.CHECKBOX;
|
|
7
|
+
const DEFAULT_CLASSNAME = 'miso-checkbox';
|
|
8
|
+
|
|
9
|
+
function root(layout, state) {
|
|
10
|
+
const { className, role, templates } = layout;
|
|
11
|
+
const checked = isChecked(state);
|
|
12
|
+
const roleAttr = role ? ` data-role="${role}"` : '';
|
|
13
|
+
const checkedAttr = checked ? ' data-checked' : '';
|
|
14
|
+
return `<button type="button" class="${className}" role="switch" aria-checked="${checked}"${roleAttr}${checkedAttr}>${templates.icon(layout, state)}${templates.text(layout, state)}</button>`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function icon(layout, state) {
|
|
18
|
+
const { icon, checkedIcon = icon } = layout.options;
|
|
19
|
+
const name = isChecked(state) ? checkedIcon : icon;
|
|
20
|
+
return name ? getIcon(name) : '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function text(layout, state) {
|
|
24
|
+
const { className, options: { text, checkedText = text } } = layout;
|
|
25
|
+
const value = isChecked(state) ? checkedText : text;
|
|
26
|
+
return value ? `<span class="${className}__text">${escapeHtml(value)}</span>` : '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// the checked state is the mapped data value, so it renders from data alone
|
|
30
|
+
function isChecked({ value } = {}) {
|
|
31
|
+
return value === true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const DEFAULT_TEMPLATES = Object.freeze({
|
|
35
|
+
root,
|
|
36
|
+
icon,
|
|
37
|
+
text,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A checkbox that looks like a button: an icon and a label, each with an
|
|
42
|
+
* optional checked variant (`icon`/`text` and `checkedIcon`/`checkedText`,
|
|
43
|
+
* the latter falling back to the former). It is a switch — semantically a
|
|
44
|
+
* checkbox (`role="switch"`, `aria-checked`), visually a button — for
|
|
45
|
+
* on/off state a user toggles, such as the answer-updates subscription of
|
|
46
|
+
* the conversation panel (role `subscription`).
|
|
47
|
+
*
|
|
48
|
+
* The checked state comes from the data (the mapped value is the boolean —
|
|
49
|
+
* e.g. role `subscription` maps to `'thread.subscribed'`), so a click emits
|
|
50
|
+
* a `change` view event carrying the requested state (`{ checked }`) and
|
|
51
|
+
* nothing else: the workflow acts on it and the new state arrives back down
|
|
52
|
+
* the data path, like any other rendering.
|
|
53
|
+
*/
|
|
54
|
+
export default class CheckboxLayout extends ButtonLayout {
|
|
55
|
+
|
|
56
|
+
static get type() {
|
|
57
|
+
return TYPE;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static get defaultTemplates() {
|
|
61
|
+
return DEFAULT_TEMPLATES;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static get defaultClassName() {
|
|
65
|
+
return DEFAULT_CLASSNAME;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor({ className = DEFAULT_CLASSNAME, templates, ...options } = {}) {
|
|
69
|
+
super({
|
|
70
|
+
className,
|
|
71
|
+
templates: { ...DEFAULT_TEMPLATES, ...templates },
|
|
72
|
+
...options,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_handleClick(event) {
|
|
77
|
+
// only left click
|
|
78
|
+
if (event.button !== 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const button = event.target.closest(`button.${this.className}`);
|
|
82
|
+
if (!button || button.disabled) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// what the user toggles is the control's current value
|
|
86
|
+
const checked = this._currentValue() === true;
|
|
87
|
+
const { session } = this._view._state || {};
|
|
88
|
+
this._view._emit('change', { session, checked: !checked, domEvent: event });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { STATUS } from '../../constants.js';
|
|
2
|
-
import { fields } from '
|
|
1
|
+
import { STATUS, LAYOUT_TYPE } from '../../constants.js';
|
|
2
|
+
import { fields } from '@miso.ai/client-sdk-workflow';
|
|
3
3
|
import TemplateBasedLayout from '../template.js';
|
|
4
4
|
import { helpers } from '../templates.js';
|
|
5
5
|
|
|
6
|
-
const TYPE =
|
|
6
|
+
const TYPE = LAYOUT_TYPE.MORE_BUTTON;
|
|
7
7
|
const DEFAULT_CLASSNAME = 'miso-more-button';
|
|
8
8
|
|
|
9
9
|
function root(layout, state) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ROLE, STATUS } from '../../constants.js';
|
|
1
|
+
import { ROLE, STATUS, LAYOUT_TYPE } from '../../constants.js';
|
|
2
2
|
import RafLayout from '../raf.js';
|
|
3
3
|
import MisoBannerElement from '../../element/util/miso-banner.js';
|
|
4
4
|
import Viewables from '../../util/viewables.js';
|
|
5
5
|
import { setOrRemoveAttribute } from '../../util/dom.js';
|
|
6
6
|
|
|
7
|
-
const TYPE =
|
|
7
|
+
const TYPE = LAYOUT_TYPE.CONTAINER;
|
|
8
8
|
|
|
9
9
|
export default class ContainerLayout extends RafLayout {
|
|
10
10
|
|
package/src/layout/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { default as ErrorLayout } from './error/error.js';
|
|
|
4
4
|
export { default as BannerLayout } from './banner/banner.js';
|
|
5
5
|
export { default as CollectionLayout } from './list/collection.js';
|
|
6
6
|
export { default as ListLayout } from './list/list.js';
|
|
7
|
+
export { default as ThreadsLayout } from './list/threads.js';
|
|
8
|
+
export { default as MessagesLayout } from './list/messages.js';
|
|
7
9
|
export { default as HorizontalLayout } from './list/horizontal.js';
|
|
8
10
|
export { default as CardsLayout } from './list/cards.js';
|
|
9
11
|
export { default as CarouselLayout } from './list/carousel.js';
|
|
@@ -17,3 +19,5 @@ export { default as AffiliationLayout } from './affiliation/affiliation.js';
|
|
|
17
19
|
export { default as FacetsLayout } from './input/facets.js';
|
|
18
20
|
export { default as SelectLayout } from './input/select.js';
|
|
19
21
|
export { default as MoreButtonLayout } from './button/more-button.js';
|
|
22
|
+
export { default as ButtonLayout } from './button/button.js';
|
|
23
|
+
export { default as CheckboxLayout } from './button/checkbox.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { LAYOUT_TYPE } from '../../constants.js';
|
|
1
2
|
import { escapeHtml } from '@miso.ai/commons';
|
|
2
|
-
import { fields } from '
|
|
3
|
+
import { fields } from '@miso.ai/client-sdk-workflow';
|
|
3
4
|
import TemplateBasedLayout from '../template.js';
|
|
4
5
|
import Bindings from '../../util/bindings.js';
|
|
5
6
|
|
|
6
|
-
const TYPE =
|
|
7
|
+
const TYPE = LAYOUT_TYPE.FACETS;
|
|
7
8
|
const DEFAULT_CLASSNAME = 'miso-facets';
|
|
8
9
|
const DEDAULT_FACET_CLASSNAME = 'miso-facet';
|
|
9
10
|
const CUSTOM_ATTRIBUTES_PREFIX = 'custom_attributes.';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { LAYOUT_TYPE } from '../../constants.js';
|
|
1
2
|
import { escapeHtml } from '@miso.ai/commons';
|
|
2
|
-
import { fields } from '
|
|
3
|
+
import { fields } from '@miso.ai/client-sdk-workflow';
|
|
3
4
|
import TemplateBasedLayout from '../template.js';
|
|
4
5
|
import { makeTrackable } from '../mixin/trackable.js';
|
|
5
6
|
import { addOrRemoveClass } from '../../util/dom.js';
|
|
6
7
|
|
|
7
|
-
const TYPE =
|
|
8
|
+
const TYPE = LAYOUT_TYPE.OPTION_LIST;
|
|
8
9
|
const DEFAULT_CLASSNAME = 'miso-option-list';
|
|
9
10
|
|
|
10
11
|
function root(layout, state) {
|