@miso.ai/client-sdk-ui 1.13.2-beta.1 → 1.14.0-beta.3
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 +17 -4
- package/dist/cjs/combo/ask/index.js +2 -2
- package/dist/cjs/constants.js +120 -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 +259 -0
- package/dist/cjs/element/container/index.js +28 -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-message-item.js +91 -0
- package/dist/cjs/element/container/miso-recommendation.js +1 -1
- package/dist/cjs/element/container/miso-search.js +1 -1
- package/dist/cjs/element/container/miso-thread-item.js +91 -0
- package/dist/cjs/element/context/miso-follow-ups.js +1 -1
- package/dist/cjs/element/role/index.js +49 -0
- package/dist/cjs/element/role/miso-delete.js +20 -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 +170 -0
- package/dist/cjs/layout/button/checkbox.js +116 -0
- package/dist/cjs/layout/button/more-button.js +3 -3
- package/dist/cjs/layout/container/container.js +1 -1
- package/dist/cjs/layout/container/item-container.js +99 -0
- package/dist/cjs/layout/error/error.js +2 -1
- package/dist/cjs/layout/index.js +42 -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 +50 -12
- 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 +13 -1
- 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 +359 -0
- package/dist/cjs/layout/list/threads.js +199 -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 +97 -0
- package/dist/cjs/layout/text/question.js +71 -0
- package/dist/cjs/layout/text/text.js +2 -1
- package/dist/cjs/layout/text/typewriter/index.js +18 -23
- package/dist/cjs/plugin.js +43 -104
- package/dist/cjs/util/confirm.js +33 -0
- package/dist/cjs/util/dom.js +21 -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 +51 -104
- package/src/asset/svgs.js +16 -3
- package/src/combo/ask/index.js +2 -2
- package/src/constants.js +39 -147
- package/src/defaults/ask/controls.js +1 -1
- package/src/defaults/hybrid-search/answer-box.js +2 -2
- package/src/defaults.js +174 -0
- package/src/element/container/index.js +4 -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-message-item.js +94 -0
- package/src/element/container/miso-recommendation.js +1 -1
- package/src/element/container/miso-search.js +1 -1
- package/src/element/container/miso-thread-item.js +94 -0
- package/src/element/context/miso-follow-ups.js +1 -1
- package/src/element/role/index.js +7 -0
- package/src/element/role/miso-delete.js +16 -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 +152 -0
- package/src/layout/button/checkbox.js +92 -0
- package/src/layout/button/more-button.js +3 -3
- package/src/layout/container/container.js +2 -2
- package/src/layout/container/item-container.js +99 -0
- package/src/layout/error/error.js +2 -1
- package/src/layout/index.js +6 -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 +45 -8
- 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 +15 -2
- 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 +316 -0
- package/src/layout/list/threads.js +166 -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 +97 -0
- package/src/layout/text/question.js +58 -0
- package/src/layout/text/text.js +2 -1
- package/src/layout/text/typewriter/index.js +15 -18
- package/src/plugin.js +31 -117
- package/src/util/confirm.js +28 -0
- package/src/util/dom.js +16 -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
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
8
|
+
var _constants = require("../../constants.js");
|
|
9
|
+
var _collection = _interopRequireDefault(require("./collection.js"));
|
|
10
|
+
var _dom = require("../../util/dom.js");
|
|
11
|
+
const _excluded = ["className"];
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
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; }
|
|
14
|
+
const TYPE = _constants.LAYOUT_TYPE.THREADS;
|
|
15
|
+
const DEFAULT_CLASSNAME = 'miso-threads';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The thread list of the chat history interface: a shell that renders one
|
|
19
|
+
* <miso-thread-item> container element per thread item, incrementally —
|
|
20
|
+
* fresh items land at either end of the list: a newly created thread
|
|
21
|
+
* renders as a prepended item (the list is newest-first), while an older
|
|
22
|
+
* page fetched by the more flow (infinite scroll: the collection layout's
|
|
23
|
+
* stock trigger, viewable at the list's bottom, fires the `more` hub
|
|
24
|
+
* field) renders as appended items — told apart by which boundary the
|
|
25
|
+
* already-rendered records line up with. The content
|
|
26
|
+
* of an item is not rendered here: each <miso-thread-item> is assigned its item
|
|
27
|
+
* subworkflow (workflow._getThreadWorkflow, off the item binding) in the
|
|
28
|
+
* post-render sync pass, and the role elements inside (the title, and the
|
|
29
|
+
* context menu's rename/delete buttons) render through that workflow's own
|
|
30
|
+
* layouts — so a record change re-renders the affected item's roles alone.
|
|
31
|
+
*
|
|
32
|
+
* The shell keeps the list-level behaviors. Selection comes with the data:
|
|
33
|
+
* the history workflow stamps `selectedThreadId` into its value and
|
|
34
|
+
* decorates each thread record with a `selected` flag, so any selection
|
|
35
|
+
* change flows down the regular data path; in-place state changes on
|
|
36
|
+
* existing items (selected, unread, the thread identity of a settled
|
|
37
|
+
* placeholder) are applied by `_syncItems` after each render, reading the
|
|
38
|
+
* fresh values off the item bindings — no item re-render needed. Each item
|
|
39
|
+
* carries a context menu (vertical dots), but that is the thread workflow's
|
|
40
|
+
* too: its item-container layout inserts and toggles it — the shell only
|
|
41
|
+
* keeps menu clicks (by their item-menu data-roles) from selecting.
|
|
42
|
+
*/
|
|
43
|
+
class ThreadsLayout extends _collection.default {
|
|
44
|
+
static get type() {
|
|
45
|
+
return TYPE;
|
|
46
|
+
}
|
|
47
|
+
static get defaultClassName() {
|
|
48
|
+
return DEFAULT_CLASSNAME;
|
|
49
|
+
}
|
|
50
|
+
constructor(_ref = {}) {
|
|
51
|
+
let {
|
|
52
|
+
className = DEFAULT_CLASSNAME
|
|
53
|
+
} = _ref,
|
|
54
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
55
|
+
super(Object.assign({
|
|
56
|
+
className
|
|
57
|
+
}, options));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// item identity: the thread id, or the local placeholder id standing in
|
|
61
|
+
// for it while a thread is being created — the workflow adopts the thread
|
|
62
|
+
// id at the settle, so the element and its workflow survive it
|
|
63
|
+
_getItemKey(thread) {
|
|
64
|
+
return thread.thread_id || thread.placeholder_id || thread;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// incremental renders cover a pure prepend (a created thread) or a pure
|
|
68
|
+
// append (an older page) — anything else re-renders in full
|
|
69
|
+
_shallRenderIncrementally(state, rendered) {
|
|
70
|
+
if (!super._shallRenderIncrementally(state, rendered)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const values = this._getItems(state) || [];
|
|
74
|
+
const renderedValues = rendered.value;
|
|
75
|
+
const count = values.length - renderedValues.length;
|
|
76
|
+
return count === 0 ||
|
|
77
|
+
// in-place changes only
|
|
78
|
+
this._getItemKey(values[0]) === this._getItemKey(renderedValues[0]) ||
|
|
79
|
+
// appended
|
|
80
|
+
this._getItemKey(values[count]) === this._getItemKey(renderedValues[0]); // prepended
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// the fresh items land at the head (a newly created thread — the list is
|
|
84
|
+
// newest-first) or at the tail (an older page fetched by the more flow):
|
|
85
|
+
// told apart by which boundary the already-rendered records line up with
|
|
86
|
+
_html(state, rendered, incremental) {
|
|
87
|
+
if (!incremental) {
|
|
88
|
+
return this.templates.root(this, state);
|
|
89
|
+
}
|
|
90
|
+
const values = this._getItems(state) || [];
|
|
91
|
+
const renderedValues = rendered.value;
|
|
92
|
+
const count = values.length - renderedValues.length;
|
|
93
|
+
if (count === 0) {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
if (this._getItemKey(values[0]) === this._getItemKey(renderedValues[0])) {
|
|
97
|
+
const fresh = values.slice(renderedValues.length);
|
|
98
|
+
return {
|
|
99
|
+
position: 'beforeend',
|
|
100
|
+
items: this.templates.items(this, state, fresh, {
|
|
101
|
+
offset: renderedValues.length
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const fresh = values.slice(0, count);
|
|
106
|
+
return {
|
|
107
|
+
position: 'afterbegin',
|
|
108
|
+
items: this.templates.items(this, state, fresh, {
|
|
109
|
+
offset: 0
|
|
110
|
+
})
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
_render(element, {
|
|
114
|
+
state
|
|
115
|
+
}, {
|
|
116
|
+
notifyUpdate
|
|
117
|
+
}) {
|
|
118
|
+
const {
|
|
119
|
+
incremental,
|
|
120
|
+
html
|
|
121
|
+
} = state;
|
|
122
|
+
if (incremental) {
|
|
123
|
+
if (html) {
|
|
124
|
+
this._getListElement(element).insertAdjacentHTML(html.position, html.items);
|
|
125
|
+
} else {
|
|
126
|
+
notifyUpdate(false);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
element.innerHTML = html;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
_afterRender(element, state) {
|
|
133
|
+
super._afterRender(element, state); // syncs bindings to the latest values
|
|
134
|
+
this._syncWorkflows(element);
|
|
135
|
+
this._syncItems(element);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// assign each <miso-thread-item> its item subworkflow, off the item binding
|
|
139
|
+
_syncWorkflows(element) {
|
|
140
|
+
const workflow = this._view && this._view.workflow;
|
|
141
|
+
if (!workflow || typeof workflow._getThreadWorkflow !== 'function') {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
for (const item of this._getItemElements(element)) {
|
|
145
|
+
const binding = this._bindings.get(item);
|
|
146
|
+
if (binding && item.isContainer) {
|
|
147
|
+
item.workflow = workflow._getThreadWorkflow(binding.value);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// sync in-place item state changes from the bound values onto the existing
|
|
153
|
+
// item elements: selection/unread state, and the thread identity of a
|
|
154
|
+
// placeholder that settled into its real record — the item contents render
|
|
155
|
+
// through the thread workflows, outside this layout's render cycle
|
|
156
|
+
_syncItems(element) {
|
|
157
|
+
for (const item of this._getItemElements(element)) {
|
|
158
|
+
const binding = this._bindings.get(item);
|
|
159
|
+
if (!binding) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const {
|
|
163
|
+
value
|
|
164
|
+
} = binding;
|
|
165
|
+
(0, _dom.setOrRemoveAttribute)(item, 'data-selected', value.selected ? '' : undefined);
|
|
166
|
+
(0, _dom.setOrRemoveAttribute)(item, 'data-unread', (0, _clientSdkWorkflow.isThreadUnread)(value) ? '' : undefined);
|
|
167
|
+
(0, _dom.setOrRemoveAttribute)(item, 'data-thread-id', value.thread_id || undefined);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// a click on a thread item means selection — a navigation action, not a
|
|
172
|
+
// content-engagement click: emit a select view event and skip click tracking
|
|
173
|
+
_onClick(event) {
|
|
174
|
+
if (event.target.closest(`[data-role="item-menu-button"], [data-role="item-menu"]`)) {
|
|
175
|
+
return; // the item's own context menu, owned by its container layout
|
|
176
|
+
}
|
|
177
|
+
const element = event.target.closest(`[data-role="item"]`);
|
|
178
|
+
if (!element) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const binding = this._bindings.get(element);
|
|
182
|
+
if (!binding) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const {
|
|
186
|
+
session
|
|
187
|
+
} = this._view._state;
|
|
188
|
+
const {
|
|
189
|
+
value
|
|
190
|
+
} = binding;
|
|
191
|
+
this._view._emit('select', {
|
|
192
|
+
session,
|
|
193
|
+
value,
|
|
194
|
+
element: binding.element,
|
|
195
|
+
domEvent: event
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.default = ThreadsLayout;
|
|
@@ -8,7 +8,7 @@ exports.makeTrackable = makeTrackable;
|
|
|
8
8
|
var _commons = require("@miso.ai/commons");
|
|
9
9
|
var _bindings = _interopRequireDefault(require("../../util/bindings.js"));
|
|
10
10
|
var _viewables = _interopRequireDefault(require("../../util/viewables.js"));
|
|
11
|
-
var
|
|
11
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function makeTrackable(prototype) {
|
|
14
14
|
(0, _commons.mixin)(prototype, TrackableMixin.prototype);
|
|
@@ -36,8 +36,7 @@ class TrackableMixin {
|
|
|
36
36
|
this._onBindingsUpdate(bounds, unbounds);
|
|
37
37
|
}
|
|
38
38
|
_getItemKey(value) {
|
|
39
|
-
|
|
40
|
-
return value.product_id || value.text || value.id || value;
|
|
39
|
+
return this._view.tracker.getItemKey(value);
|
|
41
40
|
}
|
|
42
41
|
_getItems(state) {
|
|
43
42
|
throw new Error(`Not implemented.`);
|
|
@@ -92,8 +91,8 @@ class TrackableMixin {
|
|
|
92
91
|
const {
|
|
93
92
|
click: options
|
|
94
93
|
} = this._view.tracker.options || {};
|
|
95
|
-
if ((0,
|
|
96
|
-
(0,
|
|
94
|
+
if ((0, _clientSdkWorkflow.validateClick)(options, event, binding)) {
|
|
95
|
+
(0, _clientSdkWorkflow.markAsTracked)(event);
|
|
97
96
|
this._view.tracker.click([binding.value]);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -7,7 +7,7 @@ exports.TriggerableMixin = void 0;
|
|
|
7
7
|
exports.makeTriggerable = makeTriggerable;
|
|
8
8
|
var _commons = require("@miso.ai/commons");
|
|
9
9
|
var _constants = require("../../constants.js");
|
|
10
|
-
var
|
|
10
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
11
11
|
function makeTriggerable(prototype) {
|
|
12
12
|
(0, _commons.mixin)(prototype, TriggerableMixin.prototype);
|
|
13
13
|
}
|
|
@@ -63,7 +63,7 @@ class TriggerableMixin {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
_onTrigger() {
|
|
66
|
-
this._view.hub.trigger(
|
|
66
|
+
this._view.hub.trigger(_clientSdkWorkflow.fields.more());
|
|
67
67
|
}
|
|
68
68
|
_untrackTrigger() {
|
|
69
69
|
if (!this._trigger) {
|
|
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _constants = require("../../constants.js");
|
|
8
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
8
9
|
var _radio = _interopRequireDefault(require("./radio.js"));
|
|
9
10
|
var _svgs = require("../svgs.js");
|
|
10
11
|
const _excluded = ["className", "templates"];
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
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; }
|
|
13
|
-
const TYPE =
|
|
14
|
+
const TYPE = _constants.LAYOUT_TYPE.FEEDBACK;
|
|
14
15
|
const DEFAULT_CLASSNAME = 'miso-feedback';
|
|
15
16
|
const OPTIONS = ['helpful', 'unhelpful'];
|
|
16
17
|
function options(layout) {
|
|
@@ -78,7 +79,7 @@ class FeedbackLayout extends _radio.default {
|
|
|
78
79
|
super(Object.assign({
|
|
79
80
|
className,
|
|
80
81
|
templates: Object.assign({}, DEFAULT_TEMPLATES, templates),
|
|
81
|
-
field:
|
|
82
|
+
field: _clientSdkWorkflow.fields.feedback()
|
|
82
83
|
}, options));
|
|
83
84
|
if (options.text === false && options.icon === false) {
|
|
84
85
|
throw new Error('At least one of options.text or options.icon must be enabled');
|
|
@@ -22,14 +22,23 @@ exports.image = image;
|
|
|
22
22
|
exports.imageBlock = imageBlock;
|
|
23
23
|
exports.imageInfoBlock = imageInfoBlock;
|
|
24
24
|
exports.indexBlock = indexBlock;
|
|
25
|
+
exports.message = message;
|
|
26
|
+
exports.messageBody = messageBody;
|
|
27
|
+
exports.messageErrorBlock = messageErrorBlock;
|
|
28
|
+
exports.messageSourcesBlock = messageSourcesBlock;
|
|
25
29
|
exports.priceBlock = priceBlock;
|
|
26
30
|
exports.product = product;
|
|
27
31
|
exports.productInfoBlock = productInfoBlock;
|
|
28
32
|
exports.question = question;
|
|
29
33
|
exports.requiresImplementation = requiresImplementation;
|
|
34
|
+
exports.thread = thread;
|
|
35
|
+
exports.threadBody = threadBody;
|
|
36
|
+
exports.threadMenuBlock = threadMenuBlock;
|
|
30
37
|
exports.titleBlock = titleBlock;
|
|
31
38
|
exports.unimplemented = unimplemented;
|
|
32
39
|
var _commons = require("@miso.ai/commons");
|
|
40
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
41
|
+
var _svgs = require("../asset/svgs.js");
|
|
33
42
|
var _constants = require("../constants.js");
|
|
34
43
|
const _excluded = ["classSuffix", "role"];
|
|
35
44
|
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; }
|
|
@@ -55,6 +64,94 @@ function question(layout, state, data) {
|
|
|
55
64
|
const [openTag, closeTag] = tagPair(layout, data);
|
|
56
65
|
return `${openTag}${data.value || data.text || data}${closeTag}`;
|
|
57
66
|
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A thread item is a <miso-thread-item> container element hosting the thread
|
|
70
|
+
* item subworkflow — the threads layout is a shell: it assigns the workflow
|
|
71
|
+
* (and syncs the item-level attributes) in its post-render pass, and the
|
|
72
|
+
* content renders through the thread workflow's own layouts: the title role
|
|
73
|
+
* element in the body, plus the context menu (with the
|
|
74
|
+
* rename/subscription/delete role elements) inserted as chrome by the workflow's item-container layout. The
|
|
75
|
+
* item state renders as attributes right in the template (and stays in
|
|
76
|
+
* sync thereafter): the thread identity, the selection, and the unread
|
|
77
|
+
* mark.
|
|
78
|
+
*/
|
|
79
|
+
function thread(layout, state, data) {
|
|
80
|
+
const {
|
|
81
|
+
className,
|
|
82
|
+
templates
|
|
83
|
+
} = layout;
|
|
84
|
+
const threadId = data.thread_id;
|
|
85
|
+
const threadIdAttr = threadId ? ` data-thread-id="${threadId}"` : '';
|
|
86
|
+
const unreadAttr = (0, _clientSdkWorkflow.isThreadUnread)(data) ? ' data-unread' : '';
|
|
87
|
+
const selectedAttr = data.selected ? ' data-selected' : '';
|
|
88
|
+
return [`<miso-thread-item class="${className}__item-body" data-role="item"${threadIdAttr}${unreadAttr}${selectedAttr}>`, (templates.threadBody || threadBody)(layout, data), `</miso-thread-item>`].join('');
|
|
89
|
+
}
|
|
90
|
+
function threadBody(layout, data) {
|
|
91
|
+
const {
|
|
92
|
+
className,
|
|
93
|
+
templates
|
|
94
|
+
} = layout;
|
|
95
|
+
return `<miso-title class="${className}__title"></miso-title>` + (templates.threadMenuBlock || threadMenuBlock)(layout, data);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// the item-menu data-roles are the contract with the thread workflow's
|
|
99
|
+
// item-container layout, which drives the menu's open/close behavior; the
|
|
100
|
+
// menu items are the thread workflow's own controls, rendered by the
|
|
101
|
+
// generic button layout with a prompt (rename) or a confirm (delete) dialog,
|
|
102
|
+
// and by the checkbox layout (the subscription toggle)
|
|
103
|
+
function threadMenuBlock({
|
|
104
|
+
className
|
|
105
|
+
}) {
|
|
106
|
+
return `<button type="button" class="${className}__menu-button" data-role="item-menu-button" aria-label="Thread actions" aria-haspopup="menu">${(0, _svgs.getIcon)('dots-vertical')}</button>` + `<div class="${className}__menu" data-role="item-menu" role="menu" hidden>` + `<miso-rename class="${className}__menu-item"></miso-rename>` + `<miso-subscription class="${className}__menu-item"></miso-subscription>` + `<miso-delete class="${className}__menu-item ${className}__menu-item--danger"></miso-delete>` + `</div>`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A message item is a <miso-message-item> container element hosting the message
|
|
111
|
+
* item subworkflow — the messages layout is a shell: it assigns the workflow
|
|
112
|
+
* (and the item-level attributes) in its post-render sync pass, and the role
|
|
113
|
+
* elements inside render the actual content through the message workflow's
|
|
114
|
+
* own layouts.
|
|
115
|
+
*/
|
|
116
|
+
function message(layout, state, data) {
|
|
117
|
+
const {
|
|
118
|
+
className,
|
|
119
|
+
templates
|
|
120
|
+
} = layout;
|
|
121
|
+
// miso-circled-citation-index covers both the citation links in the answer
|
|
122
|
+
// and the indexes on the source cards, as the hybrid-search UI scopes it
|
|
123
|
+
return [`<miso-message-item class="${className}__item-body miso-circled-citation-index" data-role="item">`, (templates.messageBody || messageBody)(layout, data), `</miso-message-item>`].join('');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// the regular content is packed together, so the erroneous presentation
|
|
127
|
+
// swaps it out wholesale for the error notice (the content wrapper hides by
|
|
128
|
+
// a class rule off the item's status — visible-when suits the notice, but
|
|
129
|
+
// not a wrapper: it forces `display: block !important` and only negates in
|
|
130
|
+
// combination with positive terms)
|
|
131
|
+
function messageBody(layout) {
|
|
132
|
+
const {
|
|
133
|
+
className,
|
|
134
|
+
templates
|
|
135
|
+
} = layout;
|
|
136
|
+
return `<div class="${className}__content">` + `<miso-question class="${className}__question" hidden></miso-question>` + `<miso-answer class="${className}__answer"></miso-answer>` + `<miso-feedback class="${className}__feedback"></miso-feedback>` + (templates.messageSourcesBlock || messageSourcesBlock)(layout) + `</div>` + (templates.messageErrorBlock || messageErrorBlock)(layout);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// the sources with their heading, as the hybrid-search UI presents them —
|
|
140
|
+
// shown once the item carries content (visible-when nonempty), so no
|
|
141
|
+
// orphan heading sits over a message still loading
|
|
142
|
+
function messageSourcesBlock({
|
|
143
|
+
className
|
|
144
|
+
}) {
|
|
145
|
+
return `<div class="${className}__sources-container" visible-when="nonempty">` + `<h3 class="${className}__sources-phrase">Sources</h3>` + `<miso-sources class="${className}__sources"></miso-sources>` + `</div>`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// shown by the item's own status (visible-when): a message whose content
|
|
149
|
+
// fetch failed for good presents this in place of its content
|
|
150
|
+
function messageErrorBlock({
|
|
151
|
+
className
|
|
152
|
+
}) {
|
|
153
|
+
return `<div class="${className}__error" visible-when="erroneous">This message could not be loaded.</div>`;
|
|
154
|
+
}
|
|
58
155
|
function article(layout, state, data, meta) {
|
|
59
156
|
const {
|
|
60
157
|
templates
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _commons = require("@miso.ai/commons");
|
|
8
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
9
|
+
var _constants = require("../../constants.js");
|
|
10
|
+
var _dom = require("../../util/dom.js");
|
|
11
|
+
var _text = _interopRequireDefault(require("./text.js"));
|
|
12
|
+
const _excluded = ["className", "tag", "author", "templates"];
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
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; }
|
|
15
|
+
const TYPE = _constants.LAYOUT_TYPE.QUESTION;
|
|
16
|
+
const DEFAULT_CLASSNAME = 'miso-question';
|
|
17
|
+
|
|
18
|
+
// the author label: only a question written by the answer-updates monitor is
|
|
19
|
+
// labeled — the user's own questions carry none
|
|
20
|
+
function defaultAuthor(message) {
|
|
21
|
+
return (0, _clientSdkWorkflow.isUpdateMessage)(message) ? 'Written by Miso' : undefined;
|
|
22
|
+
}
|
|
23
|
+
function content(layout, {
|
|
24
|
+
value
|
|
25
|
+
}) {
|
|
26
|
+
const question = value && value.question;
|
|
27
|
+
return question ? (0, _commons.escapeHtml)(question) : '';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The question of a message: a text layout taking the whole message record —
|
|
32
|
+
* the text is the `question` field, and the authorship is stamped as data
|
|
33
|
+
* attributes on the host element (`data-author` drives the CSS label badge,
|
|
34
|
+
* `data-generated-by` the bubble color), re-applied on every render, since
|
|
35
|
+
* the metadata arrives with the answers response, after the stub render. The
|
|
36
|
+
* host element hides while there is no question text to show. The author
|
|
37
|
+
* label is configurable via the `author` option (message -> label text).
|
|
38
|
+
*/
|
|
39
|
+
class QuestionLayout extends _text.default {
|
|
40
|
+
static get type() {
|
|
41
|
+
return TYPE;
|
|
42
|
+
}
|
|
43
|
+
static get defaultClassName() {
|
|
44
|
+
return DEFAULT_CLASSNAME;
|
|
45
|
+
}
|
|
46
|
+
constructor(_ref = {}) {
|
|
47
|
+
let {
|
|
48
|
+
className = DEFAULT_CLASSNAME,
|
|
49
|
+
tag = 'div',
|
|
50
|
+
author = defaultAuthor,
|
|
51
|
+
templates
|
|
52
|
+
} = _ref,
|
|
53
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
54
|
+
super(Object.assign({
|
|
55
|
+
className,
|
|
56
|
+
tag,
|
|
57
|
+
author,
|
|
58
|
+
templates: Object.assign({
|
|
59
|
+
content
|
|
60
|
+
}, templates)
|
|
61
|
+
}, options));
|
|
62
|
+
}
|
|
63
|
+
_afterRender(element, state) {
|
|
64
|
+
super._afterRender(element, state);
|
|
65
|
+
const message = state.value || {};
|
|
66
|
+
element.hidden = !message.question;
|
|
67
|
+
(0, _dom.setOrRemoveAttribute)(element, 'data-author', this.options.author(message));
|
|
68
|
+
(0, _dom.setOrRemoveAttribute)(element, 'data-generated-by', message.metadata && message.metadata.miso_generated_by || undefined);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.default = QuestionLayout;
|
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _constants = require("../../constants.js");
|
|
7
8
|
var _commons = require("@miso.ai/commons");
|
|
8
9
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
9
10
|
const _excluded = ["className", "templates", "tag"];
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
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
|
-
const TYPE =
|
|
13
|
+
const TYPE = _constants.LAYOUT_TYPE.TEXT;
|
|
13
14
|
const DEFAULT_CLASSNAME = 'miso-text';
|
|
14
15
|
function root(layout, state) {
|
|
15
16
|
const {
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _commons = require("@miso.ai/commons");
|
|
8
8
|
var _constants = require("../../../constants.js");
|
|
9
|
+
var _dom = require("../../../util/dom.js");
|
|
9
10
|
var _progressive = _interopRequireDefault(require("../../progressive.js"));
|
|
10
11
|
var _plaintext = _interopRequireDefault(require("./plaintext.js"));
|
|
11
12
|
var _utils = require("./utils.js");
|
|
12
13
|
const _excluded = ["className", "tag", "format", "tooltip", "speed", "acceleration", "nextCursorFn"];
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
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; }
|
|
15
|
-
const TYPE =
|
|
16
|
+
const TYPE = _constants.LAYOUT_TYPE.TYPEWRITER;
|
|
16
17
|
const DEFAULT_CLASSNAME = 'miso-typewriter';
|
|
17
18
|
class TypewriterLayout extends _progressive.default {
|
|
18
19
|
static get type() {
|
|
@@ -72,10 +73,12 @@ class TypewriterLayout extends _progressive.default {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
async _setupForMarkdown() {
|
|
75
|
-
const
|
|
76
|
+
const client = this._view.workflow._client;
|
|
77
|
+
const plugin = await TypewriterLayout.MisoClient.plugins.install('std:ui-markdown');
|
|
76
78
|
if (!this._view) {
|
|
77
79
|
return; // destroyed
|
|
78
80
|
}
|
|
81
|
+
const context = plugin.getContext(client);
|
|
79
82
|
const cursorClass = (0, _utils.cursorClassName)(this.className);
|
|
80
83
|
const {
|
|
81
84
|
onDebug,
|
|
@@ -158,6 +161,17 @@ class TypewriterLayout extends _progressive.default {
|
|
|
158
161
|
// new typing streak
|
|
159
162
|
result = this._renderer.clear(container, rendered);
|
|
160
163
|
} else {
|
|
164
|
+
result = rendered;
|
|
165
|
+
}
|
|
166
|
+
if (this.options.instant && state.done && !result.cursor) {
|
|
167
|
+
// instant mode: content that finishes before any of it was typed —
|
|
168
|
+
// arrived complete (e.g. a loaded conversation message), or completed
|
|
169
|
+
// while the cursor was still at the start — renders in one shot; only
|
|
170
|
+
// content streaming in as it is generated types out
|
|
171
|
+
result = this._renderer.update(container, result, Object.assign({}, state, {
|
|
172
|
+
cursor: Infinity
|
|
173
|
+
}));
|
|
174
|
+
} else if (!newStreak) {
|
|
161
175
|
const cursor = this._getNextCursor(rendered.cursor, state.doneAt, rendered.timestamp, state.timestamp);
|
|
162
176
|
result = this._renderer.update(container, rendered, Object.assign({}, state, {
|
|
163
177
|
cursor
|
|
@@ -226,7 +240,7 @@ class TypewriterLayout extends _progressive.default {
|
|
|
226
240
|
url: href,
|
|
227
241
|
text: innerText ? innerText.trim() : '',
|
|
228
242
|
className: className || '',
|
|
229
|
-
attributes: dumpElementAttributes(anchorElement)
|
|
243
|
+
attributes: (0, _dom.dumpElementAttributes)(anchorElement)
|
|
230
244
|
}));
|
|
231
245
|
}
|
|
232
246
|
}
|
|
@@ -234,23 +248,4 @@ class TypewriterLayout extends _progressive.default {
|
|
|
234
248
|
}
|
|
235
249
|
}
|
|
236
250
|
}
|
|
237
|
-
exports.default = TypewriterLayout;
|
|
238
|
-
function dumpElementAttributes(element) {
|
|
239
|
-
const {
|
|
240
|
-
attributes
|
|
241
|
-
} = element;
|
|
242
|
-
const attrs = {};
|
|
243
|
-
for (const {
|
|
244
|
-
name,
|
|
245
|
-
value
|
|
246
|
-
} of attributes) {
|
|
247
|
-
if (name.startsWith('data-')) {
|
|
248
|
-
attrs[name] = value;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
try {
|
|
252
|
-
return JSON.stringify(attrs);
|
|
253
|
-
} catch (e) {
|
|
254
|
-
return '{}';
|
|
255
|
-
}
|
|
256
|
-
}
|
|
251
|
+
exports.default = TypewriterLayout;
|