rio-assist-widget 0.1.6 → 0.1.8
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/rio-assist.js +71 -49
- package/index.html +9 -17
- package/package.json +1 -1
- package/src/components/conversations-panel/conversations-panel.styles.ts +300 -294
- package/src/components/conversations-panel/conversations-panel.template.ts +184 -184
- package/src/components/fullscreen/fullscreen.styles.ts +185 -178
- package/src/components/mini-panel/mini-panel.styles.ts +346 -337
- package/src/components/mini-panel/mini-panel.template.ts +1 -1
- package/src/components/rio-assist/rio-assist.ts +281 -255
|
@@ -1,184 +1,184 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
-
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
-
import type { RioAssistWidget } from '../rio-assist/rio-assist';
|
|
5
|
-
|
|
6
|
-
const threePointsIconUrl = new URL('../../assets/icons/threePoints.png', import.meta.url).href;
|
|
7
|
-
const editIconUrl = new URL('../../assets/icons/edit.png', import.meta.url).href;
|
|
8
|
-
const trashIconUrl = new URL('../../assets/icons/trash.png', import.meta.url).href;
|
|
9
|
-
const searchIconUrl = new URL('../../assets/icons/searchIcon.png', import.meta.url).href;
|
|
10
|
-
const plusFileSelectionUrl = new URL('../../assets/icons/plusFileSelection.png', import.meta.url)
|
|
11
|
-
.href;
|
|
12
|
-
|
|
13
|
-
type ConversationsPanelVariant = 'drawer' | 'sidebar';
|
|
14
|
-
|
|
15
|
-
export const renderConversationsPanel = (
|
|
16
|
-
component: RioAssistWidget,
|
|
17
|
-
options: { variant?: ConversationsPanelVariant } = {},
|
|
18
|
-
) => {
|
|
19
|
-
const variant = options.variant ?? 'drawer';
|
|
20
|
-
const isSidebar = variant === 'sidebar';
|
|
21
|
-
const isOpen = isSidebar || component.showConversations;
|
|
22
|
-
|
|
23
|
-
return html`
|
|
24
|
-
<div
|
|
25
|
-
class=${classMap({
|
|
26
|
-
'conversations-panel': true,
|
|
27
|
-
'conversations-panel--open': isOpen,
|
|
28
|
-
'conversations-panel--sidebar': isSidebar,
|
|
29
|
-
})}
|
|
30
|
-
aria-hidden=${!isOpen}
|
|
31
|
-
@pointerdown=${(event: PointerEvent) =>
|
|
32
|
-
component.handleConversationsPanelPointer(event)}
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
class=${classMap({
|
|
36
|
-
'conversations-panel__surface': true,
|
|
37
|
-
'conversations-panel__surface--sidebar': isSidebar,
|
|
38
|
-
})}
|
|
39
|
-
>
|
|
40
|
-
${renderConversationSurface(component, variant)}
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
`;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const renderConversationSurface = (
|
|
47
|
-
component: RioAssistWidget,
|
|
48
|
-
variant: ConversationsPanelVariant,
|
|
49
|
-
) => {
|
|
50
|
-
const isSidebar = variant === 'sidebar';
|
|
51
|
-
|
|
52
|
-
const newConversationCta = isSidebar
|
|
53
|
-
? html`
|
|
54
|
-
<div
|
|
55
|
-
class=${classMap({
|
|
56
|
-
'new-conversation-cta': true,
|
|
57
|
-
open: component.showNewConversationShortcut,
|
|
58
|
-
})}
|
|
59
|
-
>
|
|
60
|
-
<button
|
|
61
|
-
type="button"
|
|
62
|
-
class="new-conversation-cta__button"
|
|
63
|
-
?disabled=${!component.hasActiveConversation}
|
|
64
|
-
aria-disabled=${!component.hasActiveConversation}
|
|
65
|
-
@click=${() => component.handleCreateConversation()}
|
|
66
|
-
>
|
|
67
|
-
<img src=${plusFileSelectionUrl} alt="" aria-hidden="true" />
|
|
68
|
-
<span>Iniciar nova conversa</span>
|
|
69
|
-
</button>
|
|
70
|
-
</div>
|
|
71
|
-
`
|
|
72
|
-
: null;
|
|
73
|
-
|
|
74
|
-
const list = html`
|
|
75
|
-
<div
|
|
76
|
-
class=${classMap({
|
|
77
|
-
'conversation-list': true,
|
|
78
|
-
'conversation-list--sidebar': isSidebar,
|
|
79
|
-
})}
|
|
80
|
-
@scroll=${isSidebar ? (event: Event) => component.handleConversationListScroll(event) : null}
|
|
81
|
-
>
|
|
82
|
-
${component.filteredConversations.map(
|
|
83
|
-
(conversation) => {
|
|
84
|
-
const menuOpen = component.conversationMenuId === conversation.id;
|
|
85
|
-
|
|
86
|
-
return html`
|
|
87
|
-
<div class="conversation-item">
|
|
88
|
-
<div class="conversation-item__text">
|
|
89
|
-
${conversation.title}
|
|
90
|
-
</div>
|
|
91
|
-
<button
|
|
92
|
-
class="conversation-menu-button"
|
|
93
|
-
type="button"
|
|
94
|
-
@click=${(event: Event) =>
|
|
95
|
-
component.handleConversationMenuToggle(event, conversation.id)}
|
|
96
|
-
>
|
|
97
|
-
<img src=${threePointsIconUrl} alt="" aria-hidden="true" />
|
|
98
|
-
</button>
|
|
99
|
-
${menuOpen
|
|
100
|
-
? html`
|
|
101
|
-
<div
|
|
102
|
-
class=${classMap({
|
|
103
|
-
'conversation-menu': true,
|
|
104
|
-
'conversation-menu--above':
|
|
105
|
-
component.conversationMenuPlacement === 'above',
|
|
106
|
-
})}
|
|
107
|
-
@click=${(event: Event) => event.stopPropagation()}
|
|
108
|
-
>
|
|
109
|
-
<button
|
|
110
|
-
type="button"
|
|
111
|
-
@click=${() =>
|
|
112
|
-
component.handleConversationAction('rename', conversation.id)}
|
|
113
|
-
>
|
|
114
|
-
<img src=${editIconUrl} alt="" aria-hidden="true" />
|
|
115
|
-
Renomear
|
|
116
|
-
</button>
|
|
117
|
-
<button
|
|
118
|
-
type="button"
|
|
119
|
-
@click=${() =>
|
|
120
|
-
component.handleConversationAction('delete', conversation.id)}
|
|
121
|
-
>
|
|
122
|
-
<img src=${trashIconUrl} alt="" aria-hidden="true" />
|
|
123
|
-
Excluir
|
|
124
|
-
</button>
|
|
125
|
-
</div>
|
|
126
|
-
`
|
|
127
|
-
: null}
|
|
128
|
-
</div>
|
|
129
|
-
`;
|
|
130
|
-
},
|
|
131
|
-
)}
|
|
132
|
-
</div>
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
return html`
|
|
136
|
-
${newConversationCta}
|
|
137
|
-
|
|
138
|
-
<div class="conversation-search">
|
|
139
|
-
<img class="search-icon" src=${searchIconUrl} alt="" aria-hidden="true" />
|
|
140
|
-
<input
|
|
141
|
-
type="text"
|
|
142
|
-
placeholder="Buscar nas conversas"
|
|
143
|
-
.value=${component.conversationSearch}
|
|
144
|
-
@input=${(event: InputEvent) => component.handleConversationSearch(event)}
|
|
145
|
-
/>
|
|
146
|
-
</div>
|
|
147
|
-
|
|
148
|
-
<div
|
|
149
|
-
class=${classMap({
|
|
150
|
-
'conversation-list-wrapper': true,
|
|
151
|
-
'conversation-list-wrapper--sidebar': isSidebar,
|
|
152
|
-
})}
|
|
153
|
-
>
|
|
154
|
-
${list}
|
|
155
|
-
${isSidebar
|
|
156
|
-
? html`
|
|
157
|
-
<div
|
|
158
|
-
class=${classMap({
|
|
159
|
-
'conversation-scrollbar': true,
|
|
160
|
-
'conversation-scrollbar--visible':
|
|
161
|
-
component.conversationScrollbar.visible,
|
|
162
|
-
})}
|
|
163
|
-
@pointerdown=${(event: PointerEvent) =>
|
|
164
|
-
component.handleConversationScrollbarPointerDown(event)}
|
|
165
|
-
@pointermove=${(event: PointerEvent) =>
|
|
166
|
-
component.handleConversationScrollbarPointerMove(event)}
|
|
167
|
-
@pointerup=${(event: PointerEvent) =>
|
|
168
|
-
component.handleConversationScrollbarPointerUp(event)}
|
|
169
|
-
@pointercancel=${(event: PointerEvent) =>
|
|
170
|
-
component.handleConversationScrollbarPointerUp(event)}
|
|
171
|
-
>
|
|
172
|
-
<span
|
|
173
|
-
class="conversation-scrollbar__thumb"
|
|
174
|
-
style=${styleMap({
|
|
175
|
-
height: `${component.conversationScrollbar.height}%`,
|
|
176
|
-
top: `${component.conversationScrollbar.top}%`,
|
|
177
|
-
})}
|
|
178
|
-
></span>
|
|
179
|
-
</div>
|
|
180
|
-
`
|
|
181
|
-
: null}
|
|
182
|
-
</div>
|
|
183
|
-
`;
|
|
184
|
-
};
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
+
import type { RioAssistWidget } from '../rio-assist/rio-assist';
|
|
5
|
+
|
|
6
|
+
const threePointsIconUrl = new URL('../../assets/icons/threePoints.png', import.meta.url).href;
|
|
7
|
+
const editIconUrl = new URL('../../assets/icons/edit.png', import.meta.url).href;
|
|
8
|
+
const trashIconUrl = new URL('../../assets/icons/trash.png', import.meta.url).href;
|
|
9
|
+
const searchIconUrl = new URL('../../assets/icons/searchIcon.png', import.meta.url).href;
|
|
10
|
+
const plusFileSelectionUrl = new URL('../../assets/icons/plusFileSelection.png', import.meta.url)
|
|
11
|
+
.href;
|
|
12
|
+
|
|
13
|
+
type ConversationsPanelVariant = 'drawer' | 'sidebar';
|
|
14
|
+
|
|
15
|
+
export const renderConversationsPanel = (
|
|
16
|
+
component: RioAssistWidget,
|
|
17
|
+
options: { variant?: ConversationsPanelVariant } = {},
|
|
18
|
+
) => {
|
|
19
|
+
const variant = options.variant ?? 'drawer';
|
|
20
|
+
const isSidebar = variant === 'sidebar';
|
|
21
|
+
const isOpen = isSidebar || component.showConversations;
|
|
22
|
+
|
|
23
|
+
return html`
|
|
24
|
+
<div
|
|
25
|
+
class=${classMap({
|
|
26
|
+
'conversations-panel': true,
|
|
27
|
+
'conversations-panel--open': isOpen,
|
|
28
|
+
'conversations-panel--sidebar': isSidebar,
|
|
29
|
+
})}
|
|
30
|
+
aria-hidden=${!isOpen}
|
|
31
|
+
@pointerdown=${(event: PointerEvent) =>
|
|
32
|
+
component.handleConversationsPanelPointer(event)}
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
class=${classMap({
|
|
36
|
+
'conversations-panel__surface': true,
|
|
37
|
+
'conversations-panel__surface--sidebar': isSidebar,
|
|
38
|
+
})}
|
|
39
|
+
>
|
|
40
|
+
${renderConversationSurface(component, variant)}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const renderConversationSurface = (
|
|
47
|
+
component: RioAssistWidget,
|
|
48
|
+
variant: ConversationsPanelVariant,
|
|
49
|
+
) => {
|
|
50
|
+
const isSidebar = variant === 'sidebar';
|
|
51
|
+
|
|
52
|
+
const newConversationCta = isSidebar
|
|
53
|
+
? html`
|
|
54
|
+
<div
|
|
55
|
+
class=${classMap({
|
|
56
|
+
'new-conversation-cta': true,
|
|
57
|
+
open: component.showNewConversationShortcut,
|
|
58
|
+
})}
|
|
59
|
+
>
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
class="new-conversation-cta__button"
|
|
63
|
+
?disabled=${!component.hasActiveConversation}
|
|
64
|
+
aria-disabled=${!component.hasActiveConversation}
|
|
65
|
+
@click=${() => component.handleCreateConversation()}
|
|
66
|
+
>
|
|
67
|
+
<img src=${plusFileSelectionUrl} alt="" aria-hidden="true" />
|
|
68
|
+
<span>Iniciar nova conversa</span>
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
`
|
|
72
|
+
: null;
|
|
73
|
+
|
|
74
|
+
const list = html`
|
|
75
|
+
<div
|
|
76
|
+
class=${classMap({
|
|
77
|
+
'conversation-list': true,
|
|
78
|
+
'conversation-list--sidebar': isSidebar,
|
|
79
|
+
})}
|
|
80
|
+
@scroll=${isSidebar ? (event: Event) => component.handleConversationListScroll(event) : null}
|
|
81
|
+
>
|
|
82
|
+
${component.filteredConversations.map(
|
|
83
|
+
(conversation) => {
|
|
84
|
+
const menuOpen = component.conversationMenuId === conversation.id;
|
|
85
|
+
|
|
86
|
+
return html`
|
|
87
|
+
<div class="conversation-item">
|
|
88
|
+
<div class="conversation-item__text">
|
|
89
|
+
${conversation.title}
|
|
90
|
+
</div>
|
|
91
|
+
<button
|
|
92
|
+
class="conversation-menu-button"
|
|
93
|
+
type="button"
|
|
94
|
+
@click=${(event: Event) =>
|
|
95
|
+
component.handleConversationMenuToggle(event, conversation.id)}
|
|
96
|
+
>
|
|
97
|
+
<img src=${threePointsIconUrl} alt="" aria-hidden="true" />
|
|
98
|
+
</button>
|
|
99
|
+
${menuOpen
|
|
100
|
+
? html`
|
|
101
|
+
<div
|
|
102
|
+
class=${classMap({
|
|
103
|
+
'conversation-menu': true,
|
|
104
|
+
'conversation-menu--above':
|
|
105
|
+
component.conversationMenuPlacement === 'above',
|
|
106
|
+
})}
|
|
107
|
+
@click=${(event: Event) => event.stopPropagation()}
|
|
108
|
+
>
|
|
109
|
+
<button
|
|
110
|
+
type="button"
|
|
111
|
+
@click=${() =>
|
|
112
|
+
component.handleConversationAction('rename', conversation.id)}
|
|
113
|
+
>
|
|
114
|
+
<img src=${editIconUrl} alt="" aria-hidden="true" />
|
|
115
|
+
Renomear
|
|
116
|
+
</button>
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
@click=${() =>
|
|
120
|
+
component.handleConversationAction('delete', conversation.id)}
|
|
121
|
+
>
|
|
122
|
+
<img src=${trashIconUrl} alt="" aria-hidden="true" />
|
|
123
|
+
Excluir
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
`
|
|
127
|
+
: null}
|
|
128
|
+
</div>
|
|
129
|
+
`;
|
|
130
|
+
},
|
|
131
|
+
)}
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
return html`
|
|
136
|
+
${newConversationCta}
|
|
137
|
+
|
|
138
|
+
<div class="conversation-search">
|
|
139
|
+
<img class="search-icon" src=${searchIconUrl} alt="" aria-hidden="true" />
|
|
140
|
+
<input
|
|
141
|
+
type="text"
|
|
142
|
+
placeholder="Buscar nas conversas"
|
|
143
|
+
.value=${component.conversationSearch}
|
|
144
|
+
@input=${(event: InputEvent) => component.handleConversationSearch(event)}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div
|
|
149
|
+
class=${classMap({
|
|
150
|
+
'conversation-list-wrapper': true,
|
|
151
|
+
'conversation-list-wrapper--sidebar': isSidebar,
|
|
152
|
+
})}
|
|
153
|
+
>
|
|
154
|
+
${list}
|
|
155
|
+
${isSidebar
|
|
156
|
+
? html`
|
|
157
|
+
<div
|
|
158
|
+
class=${classMap({
|
|
159
|
+
'conversation-scrollbar': true,
|
|
160
|
+
'conversation-scrollbar--visible':
|
|
161
|
+
component.conversationScrollbar.visible,
|
|
162
|
+
})}
|
|
163
|
+
@pointerdown=${(event: PointerEvent) =>
|
|
164
|
+
component.handleConversationScrollbarPointerDown(event)}
|
|
165
|
+
@pointermove=${(event: PointerEvent) =>
|
|
166
|
+
component.handleConversationScrollbarPointerMove(event)}
|
|
167
|
+
@pointerup=${(event: PointerEvent) =>
|
|
168
|
+
component.handleConversationScrollbarPointerUp(event)}
|
|
169
|
+
@pointercancel=${(event: PointerEvent) =>
|
|
170
|
+
component.handleConversationScrollbarPointerUp(event)}
|
|
171
|
+
>
|
|
172
|
+
<span
|
|
173
|
+
class="conversation-scrollbar__thumb"
|
|
174
|
+
style=${styleMap({
|
|
175
|
+
height: `${component.conversationScrollbar.height}%`,
|
|
176
|
+
top: `${component.conversationScrollbar.top}%`,
|
|
177
|
+
})}
|
|
178
|
+
></span>
|
|
179
|
+
</div>
|
|
180
|
+
`
|
|
181
|
+
: null}
|
|
182
|
+
</div>
|
|
183
|
+
`;
|
|
184
|
+
};
|