@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,170 @@
|
|
|
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 _constants = require("../../constants.js");
|
|
9
|
+
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
|
+
var _svgs = require("../../asset/svgs.js");
|
|
11
|
+
var _prompt = _interopRequireDefault(require("../../util/prompt.js"));
|
|
12
|
+
var _confirm = _interopRequireDefault(require("../../util/confirm.js"));
|
|
13
|
+
const _excluded = ["className", "templates"],
|
|
14
|
+
_excluded2 = ["message"];
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
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; }
|
|
17
|
+
const TYPE = _constants.LAYOUT_TYPE.BUTTON;
|
|
18
|
+
const DEFAULT_CLASSNAME = 'miso-button';
|
|
19
|
+
function root(layout, state) {
|
|
20
|
+
const {
|
|
21
|
+
className,
|
|
22
|
+
role,
|
|
23
|
+
templates
|
|
24
|
+
} = layout;
|
|
25
|
+
const roleAttr = role ? ` data-role="${role}"` : '';
|
|
26
|
+
const disabledAttr = layout._isDisabled(state) ? ' disabled' : '';
|
|
27
|
+
return `<button type="button" class="${className}"${roleAttr}${disabledAttr}>${templates.icon(layout, state)}${templates.text(layout, state)}</button>`;
|
|
28
|
+
}
|
|
29
|
+
function icon(layout) {
|
|
30
|
+
const {
|
|
31
|
+
icon
|
|
32
|
+
} = layout.options;
|
|
33
|
+
return icon ? (0, _svgs.getIcon)(icon) : '';
|
|
34
|
+
}
|
|
35
|
+
function text(layout) {
|
|
36
|
+
const {
|
|
37
|
+
className,
|
|
38
|
+
options: {
|
|
39
|
+
text
|
|
40
|
+
}
|
|
41
|
+
} = layout;
|
|
42
|
+
return text ? `<span class="${className}__text">${(0, _commons.escapeHtml)(text)}</span>` : '';
|
|
43
|
+
}
|
|
44
|
+
const DEFAULT_TEMPLATES = Object.freeze({
|
|
45
|
+
root,
|
|
46
|
+
icon,
|
|
47
|
+
text
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A generic button: an icon and a label, both configurable (`icon` is an icon
|
|
52
|
+
* name, `text` the label; either can be omitted), emitting a `submit` view
|
|
53
|
+
* event when clicked — for the workflow to act on, per role.
|
|
54
|
+
*
|
|
55
|
+
* It carries no data of its own, so it renders in any state; use it for
|
|
56
|
+
* actions that stand apart from the data they act on, such as the new chat
|
|
57
|
+
* button (role `new_thread`) of the chat history interface.
|
|
58
|
+
*
|
|
59
|
+
* With a `prompt` option, the click asks for a text through the shared
|
|
60
|
+
* prompt dialog first, pre-filled with the control's current value — the
|
|
61
|
+
* role's mapped data value, as of the latest render — and the submit event
|
|
62
|
+
* carries the confirmed text as `value`; a cancelled, cleared, or unchanged
|
|
63
|
+
* dialog submits nothing. Use it for actions that take a text input, such
|
|
64
|
+
* as the rename button (role `rename`) of the conversation header, whose
|
|
65
|
+
* role maps to `'thread.title'`.
|
|
66
|
+
*
|
|
67
|
+
* With a `confirm` option, the click asks through the shared confirm dialog
|
|
68
|
+
* first, and submits only when confirmed; the option's `message` may be a
|
|
69
|
+
* function of the control's current value. Use it for destructive actions,
|
|
70
|
+
* such as the delete button (role `delete`) of a thread item's context menu.
|
|
71
|
+
*
|
|
72
|
+
* The control's current value is the role's mapped data value, put through
|
|
73
|
+
* the `value` option when given — map the role to a record and let `value`
|
|
74
|
+
* pick the text the dialogs work with. A `disabled` option (a boolean, or a
|
|
75
|
+
* function of the mapped value) renders the button's disabled state from
|
|
76
|
+
* the data, re-evaluated on every commit — e.g. rename/delete disable while
|
|
77
|
+
* their thread record has no thread id yet (a thread being created is not
|
|
78
|
+
* addressable), enabling in place when the resolution patches the record.
|
|
79
|
+
*/
|
|
80
|
+
class ButtonLayout extends _template.default {
|
|
81
|
+
static get type() {
|
|
82
|
+
return TYPE;
|
|
83
|
+
}
|
|
84
|
+
static get defaultTemplates() {
|
|
85
|
+
return DEFAULT_TEMPLATES;
|
|
86
|
+
}
|
|
87
|
+
static get defaultClassName() {
|
|
88
|
+
return DEFAULT_CLASSNAME;
|
|
89
|
+
}
|
|
90
|
+
constructor(_ref = {}) {
|
|
91
|
+
let {
|
|
92
|
+
className = DEFAULT_CLASSNAME,
|
|
93
|
+
templates
|
|
94
|
+
} = _ref,
|
|
95
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
96
|
+
super(Object.assign({
|
|
97
|
+
className,
|
|
98
|
+
templates: Object.assign({}, DEFAULT_TEMPLATES, templates)
|
|
99
|
+
}, options));
|
|
100
|
+
}
|
|
101
|
+
initialize(view) {
|
|
102
|
+
this._unsubscribes = [...this._unsubscribes, view.proxyElement.on('click', event => this._handleClick(event))];
|
|
103
|
+
}
|
|
104
|
+
_handleClick(event) {
|
|
105
|
+
// only left click
|
|
106
|
+
if (event.button !== 0) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const button = event.target.closest(`button.${this.className}`);
|
|
110
|
+
if (!button || button.disabled) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.options.prompt ? this._submitViaPrompt(event) : this.options.confirm ? this._submitViaConfirm(event) : this._submit(event);
|
|
114
|
+
}
|
|
115
|
+
_submit(event, payload) {
|
|
116
|
+
const {
|
|
117
|
+
session
|
|
118
|
+
} = this._view._state || {};
|
|
119
|
+
this._view._emit('submit', Object.assign({
|
|
120
|
+
session,
|
|
121
|
+
domEvent: event
|
|
122
|
+
}, payload));
|
|
123
|
+
}
|
|
124
|
+
async _submitViaPrompt(event) {
|
|
125
|
+
const current = this._currentValue();
|
|
126
|
+
const value = await (0, _prompt.default)(Object.assign({
|
|
127
|
+
value: typeof current === 'string' ? current : ''
|
|
128
|
+
}, this.options.prompt));
|
|
129
|
+
if (!value || value === current) {
|
|
130
|
+
return; // cancelled, cleared, or unchanged
|
|
131
|
+
}
|
|
132
|
+
this._submit(event, {
|
|
133
|
+
value
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async _submitViaConfirm(event) {
|
|
137
|
+
const _this$options$confirm = this.options.confirm,
|
|
138
|
+
{
|
|
139
|
+
message
|
|
140
|
+
} = _this$options$confirm,
|
|
141
|
+
options = _objectWithoutPropertiesLoose(_this$options$confirm, _excluded2);
|
|
142
|
+
const confirmed = await (0, _confirm.default)(Object.assign({}, options, {
|
|
143
|
+
message: typeof message === 'function' ? message(this._currentValue()) : message
|
|
144
|
+
}));
|
|
145
|
+
if (!confirmed) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this._submit(event);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The current value of the control: the role's mapped data value, as of
|
|
153
|
+
* the latest render, put through the `value` option when given.
|
|
154
|
+
*/
|
|
155
|
+
_currentValue() {
|
|
156
|
+
const state = this._element && this._rendered.get(this._element);
|
|
157
|
+
const raw = state && state.value;
|
|
158
|
+
const {
|
|
159
|
+
value
|
|
160
|
+
} = this.options;
|
|
161
|
+
return typeof value === 'function' ? value(raw) : raw;
|
|
162
|
+
}
|
|
163
|
+
_isDisabled(state) {
|
|
164
|
+
const {
|
|
165
|
+
disabled
|
|
166
|
+
} = this.options;
|
|
167
|
+
return typeof disabled === 'function' ? !!disabled(state && state.value) : !!disabled;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.default = ButtonLayout;
|
|
@@ -0,0 +1,116 @@
|
|
|
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 _constants = require("../../constants.js");
|
|
9
|
+
var _button = _interopRequireDefault(require("./button.js"));
|
|
10
|
+
var _svgs = require("../../asset/svgs.js");
|
|
11
|
+
const _excluded = ["className", "templates"];
|
|
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.CHECKBOX;
|
|
15
|
+
const DEFAULT_CLASSNAME = 'miso-checkbox';
|
|
16
|
+
function root(layout, state) {
|
|
17
|
+
const {
|
|
18
|
+
className,
|
|
19
|
+
role,
|
|
20
|
+
templates
|
|
21
|
+
} = layout;
|
|
22
|
+
const checked = isChecked(state);
|
|
23
|
+
const roleAttr = role ? ` data-role="${role}"` : '';
|
|
24
|
+
const checkedAttr = checked ? ' data-checked' : '';
|
|
25
|
+
const disabledAttr = layout._isDisabled(state) ? ' disabled' : '';
|
|
26
|
+
return `<button type="button" class="${className}" role="switch" aria-checked="${checked}"${roleAttr}${checkedAttr}${disabledAttr}>${templates.icon(layout, state)}${templates.text(layout, state)}</button>`;
|
|
27
|
+
}
|
|
28
|
+
function icon(layout, state) {
|
|
29
|
+
const {
|
|
30
|
+
icon,
|
|
31
|
+
checkedIcon = icon
|
|
32
|
+
} = layout.options;
|
|
33
|
+
const name = isChecked(state) ? checkedIcon : icon;
|
|
34
|
+
return name ? (0, _svgs.getIcon)(name) : '';
|
|
35
|
+
}
|
|
36
|
+
function text(layout, state) {
|
|
37
|
+
const {
|
|
38
|
+
className,
|
|
39
|
+
options: {
|
|
40
|
+
text,
|
|
41
|
+
checkedText = text
|
|
42
|
+
}
|
|
43
|
+
} = layout;
|
|
44
|
+
const value = isChecked(state) ? checkedText : text;
|
|
45
|
+
return value ? `<span class="${className}__text">${(0, _commons.escapeHtml)(value)}</span>` : '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// the checked state is the mapped data value, so it renders from data alone
|
|
49
|
+
function isChecked({
|
|
50
|
+
value
|
|
51
|
+
} = {}) {
|
|
52
|
+
return value === true;
|
|
53
|
+
}
|
|
54
|
+
const DEFAULT_TEMPLATES = Object.freeze({
|
|
55
|
+
root,
|
|
56
|
+
icon,
|
|
57
|
+
text
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A checkbox that looks like a button: an icon and a label, each with an
|
|
62
|
+
* optional checked variant (`icon`/`text` and `checkedIcon`/`checkedText`,
|
|
63
|
+
* the latter falling back to the former). It is a switch — semantically a
|
|
64
|
+
* checkbox (`role="switch"`, `aria-checked`), visually a button — for
|
|
65
|
+
* on/off state a user toggles, such as the answer-updates subscription of
|
|
66
|
+
* the conversation panel (role `subscription`).
|
|
67
|
+
*
|
|
68
|
+
* The checked state comes from the data (the mapped value is the boolean —
|
|
69
|
+
* e.g. role `subscription` maps to `'thread.subscribed'`), so a click emits
|
|
70
|
+
* a `change` view event carrying the requested state (`{ checked }`) and
|
|
71
|
+
* nothing else: the workflow acts on it and the new state arrives back down
|
|
72
|
+
* the data path, like any other rendering.
|
|
73
|
+
*/
|
|
74
|
+
class CheckboxLayout extends _button.default {
|
|
75
|
+
static get type() {
|
|
76
|
+
return TYPE;
|
|
77
|
+
}
|
|
78
|
+
static get defaultTemplates() {
|
|
79
|
+
return DEFAULT_TEMPLATES;
|
|
80
|
+
}
|
|
81
|
+
static get defaultClassName() {
|
|
82
|
+
return DEFAULT_CLASSNAME;
|
|
83
|
+
}
|
|
84
|
+
constructor(_ref = {}) {
|
|
85
|
+
let {
|
|
86
|
+
className = DEFAULT_CLASSNAME,
|
|
87
|
+
templates
|
|
88
|
+
} = _ref,
|
|
89
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
90
|
+
super(Object.assign({
|
|
91
|
+
className,
|
|
92
|
+
templates: Object.assign({}, DEFAULT_TEMPLATES, templates)
|
|
93
|
+
}, options));
|
|
94
|
+
}
|
|
95
|
+
_handleClick(event) {
|
|
96
|
+
// only left click
|
|
97
|
+
if (event.button !== 0) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const button = event.target.closest(`button.${this.className}`);
|
|
101
|
+
if (!button || button.disabled) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// what the user toggles is the control's current value
|
|
105
|
+
const checked = this._currentValue() === true;
|
|
106
|
+
const {
|
|
107
|
+
session
|
|
108
|
+
} = this._view._state || {};
|
|
109
|
+
this._view._emit('change', {
|
|
110
|
+
session,
|
|
111
|
+
checked: !checked,
|
|
112
|
+
domEvent: event
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.default = CheckboxLayout;
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _constants = require("../../constants.js");
|
|
8
|
-
var
|
|
8
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
9
9
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
10
|
var _templates = require("../templates.js");
|
|
11
11
|
const _excluded = ["className", "templates"];
|
|
12
12
|
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 (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
14
|
-
const TYPE =
|
|
14
|
+
const TYPE = _constants.LAYOUT_TYPE.MORE_BUTTON;
|
|
15
15
|
const DEFAULT_CLASSNAME = 'miso-more-button';
|
|
16
16
|
function root(layout, state) {
|
|
17
17
|
const {
|
|
@@ -67,7 +67,7 @@ class MoreButtonLayout extends _template.default {
|
|
|
67
67
|
if (!button || button.disabled) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
this._view.hub.trigger(
|
|
70
|
+
this._view.hub.trigger(_clientSdkWorkflow.fields.more());
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
exports.default = MoreButtonLayout;
|
|
@@ -12,7 +12,7 @@ var _dom = require("../../util/dom.js");
|
|
|
12
12
|
const _excluded = ["logo"];
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
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 =
|
|
15
|
+
const TYPE = _constants.LAYOUT_TYPE.CONTAINER;
|
|
16
16
|
class ContainerLayout extends _raf.default {
|
|
17
17
|
static get type() {
|
|
18
18
|
return TYPE;
|
|
@@ -0,0 +1,99 @@
|
|
|
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 _container = _interopRequireDefault(require("./container.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const TYPE = _constants.LAYOUT_TYPE.ITEM_CONTAINER;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The container layout of a collection's item subworkflow (a thread of the
|
|
14
|
+
* thread list, a message of the conversation panel): the standard container
|
|
15
|
+
* duties (status attributes, banner, trackings), plus the item-level
|
|
16
|
+
* behaviors — currently the context menu (vertical dots + popup).
|
|
17
|
+
*
|
|
18
|
+
* The menu is handled by contract, not rendered here: the item template
|
|
19
|
+
* supplies the markup (e.g. the threads layout's threadMenuBlock), marking
|
|
20
|
+
* the toggle button `data-role="item-menu-button"` and the popup
|
|
21
|
+
* `data-role="item-menu"`, and this layout drives their open/close behavior
|
|
22
|
+
* — toggle on the button; any other click on the item (a menu action
|
|
23
|
+
* included) closes it, and so does a click outside the item, which is also
|
|
24
|
+
* how opening one item's menu closes another's. The menu contents are
|
|
25
|
+
* typically role elements binding to the item workflow (e.g. the thread
|
|
26
|
+
* item's `<miso-rename>`/`<miso-delete>` buttons), so the actions stay the
|
|
27
|
+
* workflow's own controls. Collection shells treat clicks carrying the
|
|
28
|
+
* menu data-roles as item-internal (e.g. the threads layout does not
|
|
29
|
+
* select); an item template without menu markup simply has nothing to
|
|
30
|
+
* drive. Ownership is guarded: the layout only ever drives its own item's
|
|
31
|
+
* menu — a menu or click inside a nested container element is that
|
|
32
|
+
* container's own layout's — so the layout is inert on the list panel
|
|
33
|
+
* itself, whose options bag it shares with the items.
|
|
34
|
+
*/
|
|
35
|
+
class ItemContainerLayout extends _container.default {
|
|
36
|
+
static get type() {
|
|
37
|
+
return TYPE;
|
|
38
|
+
}
|
|
39
|
+
initialize(view) {
|
|
40
|
+
this._unsubscribes.push(view.proxyElement.on('click', event => this._handleClick(event)));
|
|
41
|
+
if (typeof document !== 'undefined') {
|
|
42
|
+
const onDocumentClick = event => {
|
|
43
|
+
const element = this._element;
|
|
44
|
+
if (element && !element.contains(event.target)) {
|
|
45
|
+
this._closeMenu();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
document.addEventListener('click', onDocumentClick);
|
|
49
|
+
this._unsubscribes.push(() => document.removeEventListener('click', onDocumentClick));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// menu //
|
|
54
|
+
_handleClick(event) {
|
|
55
|
+
// only left click
|
|
56
|
+
if (event.button !== 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// a click inside a nested container element belongs to that
|
|
60
|
+
// container's own layout (this layout may also host the list panel,
|
|
61
|
+
// whose subtree holds the items)
|
|
62
|
+
if (!this._owns(event.target)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (event.target.closest(`[data-role="item-menu-button"]`)) {
|
|
66
|
+
this._toggleMenu();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// any other click on the item — a menu action included — closes the menu
|
|
70
|
+
this._closeMenu();
|
|
71
|
+
}
|
|
72
|
+
_getMenu() {
|
|
73
|
+
const menu = this._element && this._element.querySelector(`[data-role="item-menu"]`);
|
|
74
|
+
// only its own item's menu: one found inside a nested container
|
|
75
|
+
// element is that container's own layout's to drive
|
|
76
|
+
return menu && this._owns(menu) ? menu : undefined;
|
|
77
|
+
}
|
|
78
|
+
_owns(node) {
|
|
79
|
+
for (let el = node; el && el !== this._element; el = el.parentElement) {
|
|
80
|
+
if (el.isContainer) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
_toggleMenu() {
|
|
87
|
+
const menu = this._getMenu();
|
|
88
|
+
if (menu) {
|
|
89
|
+
menu.hidden = !menu.hidden;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
_closeMenu() {
|
|
93
|
+
const menu = this._getMenu();
|
|
94
|
+
if (menu && !menu.hidden) {
|
|
95
|
+
menu.hidden = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.default = ItemContainerLayout;
|
|
@@ -4,11 +4,12 @@ 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 _template = _interopRequireDefault(require("../template.js"));
|
|
8
9
|
const _excluded = ["className", "templates"];
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
-
const TYPE =
|
|
12
|
+
const TYPE = _constants.LAYOUT_TYPE.ERROR;
|
|
12
13
|
const DEFAULT_CLASSNAME = 'miso-error';
|
|
13
14
|
function root(layout, state) {
|
|
14
15
|
const {
|
package/dist/cjs/layout/index.js
CHANGED
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "BannerLayout", {
|
|
|
15
15
|
return _banner.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "ButtonLayout", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _button.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "CardsLayout", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function () {
|
|
@@ -27,6 +33,12 @@ Object.defineProperty(exports, "CarouselLayout", {
|
|
|
27
33
|
return _carousel.default;
|
|
28
34
|
}
|
|
29
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "CheckboxLayout", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _checkbox.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
30
42
|
Object.defineProperty(exports, "CollectionLayout", {
|
|
31
43
|
enumerable: true,
|
|
32
44
|
get: function () {
|
|
@@ -69,12 +81,24 @@ Object.defineProperty(exports, "HorizontalLayout", {
|
|
|
69
81
|
return _horizontal.default;
|
|
70
82
|
}
|
|
71
83
|
});
|
|
84
|
+
Object.defineProperty(exports, "ItemContainerLayout", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _itemContainer.default;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
72
90
|
Object.defineProperty(exports, "ListLayout", {
|
|
73
91
|
enumerable: true,
|
|
74
92
|
get: function () {
|
|
75
93
|
return _list.default;
|
|
76
94
|
}
|
|
77
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "MessagesLayout", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _messages.default;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
78
102
|
Object.defineProperty(exports, "MoreButtonLayout", {
|
|
79
103
|
enumerable: true,
|
|
80
104
|
get: function () {
|
|
@@ -87,6 +111,12 @@ Object.defineProperty(exports, "OptionListLayout", {
|
|
|
87
111
|
return _optionList.default;
|
|
88
112
|
}
|
|
89
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "QuestionLayout", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _question.default;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
90
120
|
Object.defineProperty(exports, "SearchBoxLayout", {
|
|
91
121
|
enumerable: true,
|
|
92
122
|
get: function () {
|
|
@@ -111,6 +141,12 @@ Object.defineProperty(exports, "TextLayout", {
|
|
|
111
141
|
return _text.default;
|
|
112
142
|
}
|
|
113
143
|
});
|
|
144
|
+
Object.defineProperty(exports, "ThreadsLayout", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _threads.default;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
114
150
|
Object.defineProperty(exports, "TypewriterLayout", {
|
|
115
151
|
enumerable: true,
|
|
116
152
|
get: function () {
|
|
@@ -119,10 +155,13 @@ Object.defineProperty(exports, "TypewriterLayout", {
|
|
|
119
155
|
});
|
|
120
156
|
var _template = _interopRequireDefault(require("./template.js"));
|
|
121
157
|
var _container = _interopRequireDefault(require("./container/container.js"));
|
|
158
|
+
var _itemContainer = _interopRequireDefault(require("./container/item-container.js"));
|
|
122
159
|
var _error = _interopRequireDefault(require("./error/error.js"));
|
|
123
160
|
var _banner = _interopRequireDefault(require("./banner/banner.js"));
|
|
124
161
|
var _collection = _interopRequireDefault(require("./list/collection.js"));
|
|
125
162
|
var _list = _interopRequireDefault(require("./list/list.js"));
|
|
163
|
+
var _threads = _interopRequireDefault(require("./list/threads.js"));
|
|
164
|
+
var _messages = _interopRequireDefault(require("./list/messages.js"));
|
|
126
165
|
var _horizontal = _interopRequireDefault(require("./list/horizontal.js"));
|
|
127
166
|
var _cards = _interopRequireDefault(require("./list/cards.js"));
|
|
128
167
|
var _carousel = _interopRequireDefault(require("./list/carousel.js"));
|
|
@@ -131,9 +170,12 @@ var _searchBox = _interopRequireDefault(require("./input/search-box.js"));
|
|
|
131
170
|
var _optionList = _interopRequireDefault(require("./input/option-list.js"));
|
|
132
171
|
var _feedback = _interopRequireDefault(require("./radio/feedback.js"));
|
|
133
172
|
var _text = _interopRequireDefault(require("./text/text.js"));
|
|
173
|
+
var _question = _interopRequireDefault(require("./text/question.js"));
|
|
134
174
|
var _index = _interopRequireDefault(require("./text/typewriter/index.js"));
|
|
135
175
|
var _affiliation = _interopRequireDefault(require("./affiliation/affiliation.js"));
|
|
136
176
|
var _facets = _interopRequireDefault(require("./input/facets.js"));
|
|
137
177
|
var _select = _interopRequireDefault(require("./input/select.js"));
|
|
138
178
|
var _moreButton = _interopRequireDefault(require("./button/more-button.js"));
|
|
179
|
+
var _button = _interopRequireDefault(require("./button/button.js"));
|
|
180
|
+
var _checkbox = _interopRequireDefault(require("./button/checkbox.js"));
|
|
139
181
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -4,14 +4,15 @@ 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
|
-
var
|
|
9
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
9
10
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
11
|
var _bindings = _interopRequireDefault(require("../../util/bindings.js"));
|
|
11
12
|
const _excluded = ["className", "templates"];
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
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; }
|
|
14
|
-
const TYPE =
|
|
15
|
+
const TYPE = _constants.LAYOUT_TYPE.FACETS;
|
|
15
16
|
const DEFAULT_CLASSNAME = 'miso-facets';
|
|
16
17
|
const DEDAULT_FACET_CLASSNAME = 'miso-facet';
|
|
17
18
|
const CUSTOM_ATTRIBUTES_PREFIX = 'custom_attributes.';
|
|
@@ -158,7 +159,7 @@ class FacetsLayout extends _template.default {
|
|
|
158
159
|
this._clearBindings();
|
|
159
160
|
}
|
|
160
161
|
_syncSelections() {
|
|
161
|
-
const selectedValues = getSelectedValues(this._view.hub.states[
|
|
162
|
+
const selectedValues = getSelectedValues(this._view.hub.states[_clientSdkWorkflow.fields.filters()].facets);
|
|
162
163
|
for (const {
|
|
163
164
|
value: {
|
|
164
165
|
field,
|
|
@@ -4,15 +4,16 @@ 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
|
-
var
|
|
9
|
+
var _clientSdkWorkflow = require("@miso.ai/client-sdk-workflow");
|
|
9
10
|
var _template = _interopRequireDefault(require("../template.js"));
|
|
10
11
|
var _trackable = require("../mixin/trackable.js");
|
|
11
12
|
var _dom = require("../../util/dom.js");
|
|
12
13
|
const _excluded = ["className", "templates"];
|
|
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.OPTION_LIST;
|
|
16
17
|
const DEFAULT_CLASSNAME = 'miso-option-list';
|
|
17
18
|
function root(layout, state) {
|
|
18
19
|
const {
|