@nyaruka/temba-components 0.113.0 → 0.114.1
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/CHANGELOG.md +27 -2
- package/demo/index.html +1 -1
- package/dist/temba-components.js +793 -966
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/aliaseditor/AliasEditor.js.map +1 -1
- package/out-tsc/src/button/Button.js +6 -2
- package/out-tsc/src/button/Button.js.map +1 -1
- package/out-tsc/src/chat/Chat.js +29 -7
- package/out-tsc/src/chat/Chat.js.map +1 -1
- package/out-tsc/src/compose/Compose.js +10 -5
- package/out-tsc/src/compose/Compose.js.map +1 -1
- package/out-tsc/src/contacts/ContactChat.js +240 -114
- package/out-tsc/src/contacts/ContactChat.js.map +1 -1
- package/out-tsc/src/contacts/ContactFieldEditor.js.map +1 -1
- package/out-tsc/src/contacts/events.js.map +1 -1
- package/out-tsc/src/contacts/helpers.js +5 -1
- package/out-tsc/src/contacts/helpers.js.map +1 -1
- package/out-tsc/src/contactsearch/ContactSearch.js +1 -1
- package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
- package/out-tsc/src/dropdown/Dropdown.js +121 -108
- package/out-tsc/src/dropdown/Dropdown.js.map +1 -1
- package/out-tsc/src/interfaces.js +2 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/list/ContentMenu.js +11 -8
- package/out-tsc/src/list/ContentMenu.js.map +1 -1
- package/out-tsc/src/list/RunList.js.map +1 -1
- package/out-tsc/src/list/TembaList.js +21 -14
- package/out-tsc/src/list/TembaList.js.map +1 -1
- package/out-tsc/src/list/TembaMenu.js +11 -12
- package/out-tsc/src/list/TembaMenu.js.map +1 -1
- package/out-tsc/src/list/TicketList.js +10 -0
- package/out-tsc/src/list/TicketList.js.map +1 -1
- package/out-tsc/src/omnibox/Omnibox.js +33 -90
- package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
- package/out-tsc/src/options/Options.js +49 -47
- package/out-tsc/src/options/Options.js.map +1 -1
- package/out-tsc/src/select/PopupSelect.js +57 -0
- package/out-tsc/src/select/PopupSelect.js.map +1 -0
- package/out-tsc/src/select/Select.js +194 -144
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/select/UserSelect.js +67 -0
- package/out-tsc/src/select/UserSelect.js.map +1 -0
- package/out-tsc/src/store/Store.js +65 -14
- package/out-tsc/src/store/Store.js.map +1 -1
- package/out-tsc/src/tabpane/TabPane.js +72 -115
- package/out-tsc/src/tabpane/TabPane.js.map +1 -1
- package/out-tsc/src/textinput/TextInput.js +1 -0
- package/out-tsc/src/textinput/TextInput.js.map +1 -1
- package/out-tsc/src/user/TembaUser.js +24 -37
- package/out-tsc/src/user/TembaUser.js.map +1 -1
- package/out-tsc/src/utils/index.js +13 -6
- package/out-tsc/src/utils/index.js.map +1 -1
- package/out-tsc/temba-modules.js +4 -2
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/temba-omnibox.test.js +43 -4
- package/out-tsc/test/temba-omnibox.test.js.map +1 -1
- package/out-tsc/test/temba-select.test.js +121 -65
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +4 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/compose/attachments-tab.png +0 -0
- package/screenshots/truth/compose/attachments-with-files-focused.png +0 -0
- package/screenshots/truth/compose/attachments-with-files.png +0 -0
- package/screenshots/truth/compose/intial-text.png +0 -0
- package/screenshots/truth/compose/no-counter.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
- package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
- package/screenshots/truth/contacts/chat-failure.png +0 -0
- package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-archived-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-blocked-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-stopped-contact.png +0 -0
- package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
- package/screenshots/truth/content-menu/item-no-buttons.png +0 -0
- package/screenshots/truth/content-menu/items-and-buttons.png +0 -0
- package/screenshots/truth/omnibox/selected.png +0 -0
- package/screenshots/truth/select/enabled-multi-selection.png +0 -0
- package/screenshots/truth/select/endpoint-initial-value-updated.png +0 -0
- package/screenshots/truth/select/endpoint-initial-value.png +0 -0
- package/screenshots/truth/select/expressions.png +0 -0
- package/screenshots/truth/select/functions.png +0 -0
- package/screenshots/truth/select/initial-value.png +0 -0
- package/screenshots/truth/select/multi-with-endpoint.png +0 -0
- package/screenshots/truth/select/multiple-initial-values.png +0 -0
- package/screenshots/truth/select/selected-multi-test.png +0 -0
- package/screenshots/truth/select/static-initial-value.png +0 -0
- package/screenshots/truth/select/static-initial-via-selected.png +0 -0
- package/screenshots/truth/select/value-initial.png +0 -0
- package/src/aliaseditor/AliasEditor.ts +1 -1
- package/src/button/Button.ts +6 -2
- package/src/chat/Chat.ts +28 -6
- package/src/compose/Compose.ts +11 -6
- package/src/contacts/ContactChat.ts +260 -118
- package/src/contacts/ContactFieldEditor.ts +1 -1
- package/src/contacts/events.ts +1 -0
- package/src/contacts/helpers.ts +8 -1
- package/src/contactsearch/ContactSearch.ts +3 -3
- package/src/dropdown/Dropdown.ts +142 -103
- package/src/interfaces.ts +4 -1
- package/src/list/ContentMenu.ts +11 -9
- package/src/list/RunList.ts +3 -1
- package/src/list/TembaList.ts +24 -14
- package/src/list/TembaMenu.ts +14 -15
- package/src/list/TicketList.ts +11 -0
- package/src/omnibox/Omnibox.ts +34 -95
- package/src/options/Options.ts +57 -60
- package/src/select/PopupSelect.ts +53 -0
- package/src/select/Select.ts +182 -112
- package/src/select/UserSelect.ts +71 -0
- package/src/store/Store.ts +72 -21
- package/src/tabpane/TabPane.ts +79 -113
- package/src/textinput/TextInput.ts +1 -0
- package/src/user/TembaUser.ts +30 -41
- package/src/utils/index.ts +12 -8
- package/temba-modules.ts +4 -2
- package/test/temba-omnibox.test.ts +56 -4
- package/test/temba-select.test.ts +170 -56
- package/test/utils.test.ts +5 -0
- package/test-assets/select/omnibox.json +55 -0
- package/web-test-runner.config.mjs +16 -4
- package/out-tsc/src/contacts/ContactTickets.js +0 -462
- package/out-tsc/src/contacts/ContactTickets.js.map +0 -1
- package/out-tsc/test/temba-contact-tickets.test.js +0 -36
- package/out-tsc/test/temba-contact-tickets.test.js.map +0 -1
- package/src/contacts/ContactTickets.ts +0 -490
- package/test/temba-contact-tickets.test.ts +0 -52
package/src/utils/index.ts
CHANGED
|
@@ -516,6 +516,18 @@ export class Stubbable {
|
|
|
516
516
|
|
|
517
517
|
export const stubbable = new Stubbable();
|
|
518
518
|
|
|
519
|
+
export const spreadAttributes = (obj): TemplateResult[] => {
|
|
520
|
+
return Object.entries(obj).map(([key, value]) => {
|
|
521
|
+
if (key.startsWith('@')) {
|
|
522
|
+
return html`@${key.slice(1)}=${value}`;
|
|
523
|
+
} else if (key.startsWith('.')) {
|
|
524
|
+
return html`.${key.slice(1)}=${value}`;
|
|
525
|
+
} else {
|
|
526
|
+
return html`${key}=${value}`;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
|
|
519
531
|
export const timeSince = (
|
|
520
532
|
date: Date,
|
|
521
533
|
options: { compareDate?: Date; hideRecentText?: boolean; suffix?: string } = {
|
|
@@ -730,14 +742,6 @@ export const stopEvent = (event: Event) => {
|
|
|
730
742
|
}
|
|
731
743
|
};
|
|
732
744
|
|
|
733
|
-
export const getFullName = (user: User) => {
|
|
734
|
-
if (user.first_name && user.last_name) {
|
|
735
|
-
return `${user.first_name} ${user.last_name}`;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
return user.email;
|
|
739
|
-
};
|
|
740
|
-
|
|
741
745
|
/**
|
|
742
746
|
* Extracts 2-letter initials from text like a workspace or user name
|
|
743
747
|
* @param text the input text
|
package/temba-modules.ts
CHANGED
|
@@ -32,7 +32,6 @@ import { ContactFieldEditor } from './src/contacts/ContactFieldEditor';
|
|
|
32
32
|
|
|
33
33
|
import { ContactBadges } from './src/contacts/ContactBadges';
|
|
34
34
|
import { ContactPending } from './src/contacts/ContactPending';
|
|
35
|
-
import { ContactTickets } from './src/contacts/ContactTickets';
|
|
36
35
|
import { TembaSlider } from './src/slider/TembaSlider';
|
|
37
36
|
import { RunList } from './src/list/RunList';
|
|
38
37
|
import { FlowStoreElement } from './src/flow/FlowStoreElement';
|
|
@@ -62,6 +61,8 @@ import { OutboxMonitor } from './src/outboxmonitor/OutboxMonitor';
|
|
|
62
61
|
import { ProgressBar } from './src/progress/ProgressBar';
|
|
63
62
|
import { StartProgress } from './src/progress/StartProgress';
|
|
64
63
|
import { ShortcutList } from './src/list/ShortcutList';
|
|
64
|
+
import { PopupSelect } from './src/select/PopupSelect';
|
|
65
|
+
import { UserSelect } from './src/select/UserSelect';
|
|
65
66
|
|
|
66
67
|
export function addCustomElement(name: string, comp: any) {
|
|
67
68
|
if (!window.customElements.get(name)) {
|
|
@@ -114,7 +115,6 @@ addCustomElement('temba-tabs', TabPane);
|
|
|
114
115
|
addCustomElement('temba-tab', Tab);
|
|
115
116
|
addCustomElement('temba-contact-badges', ContactBadges);
|
|
116
117
|
addCustomElement('temba-contact-pending', ContactPending);
|
|
117
|
-
addCustomElement('temba-contact-tickets', ContactTickets);
|
|
118
118
|
addCustomElement('temba-slider', TembaSlider);
|
|
119
119
|
addCustomElement('temba-content-menu', ContentMenu);
|
|
120
120
|
addCustomElement('temba-compose', Compose);
|
|
@@ -134,3 +134,5 @@ addCustomElement('temba-outbox-monitor', OutboxMonitor);
|
|
|
134
134
|
addCustomElement('temba-progress', ProgressBar);
|
|
135
135
|
addCustomElement('temba-start-progress', StartProgress);
|
|
136
136
|
addCustomElement('temba-shortcuts', ShortcutList);
|
|
137
|
+
addCustomElement('temba-popup-select', PopupSelect);
|
|
138
|
+
addCustomElement('temba-user-select', UserSelect);
|
|
@@ -1,14 +1,66 @@
|
|
|
1
1
|
import { fixture, assert } from '@open-wc/testing';
|
|
2
2
|
import { Omnibox } from '../src/omnibox/Omnibox';
|
|
3
|
-
import './utils.test';
|
|
3
|
+
import { assertScreenshot, getClip } from './utils.test';
|
|
4
|
+
import { openAndClick } from './temba-select.test';
|
|
5
|
+
import { useFakeTimers, spy } from 'sinon';
|
|
4
6
|
|
|
5
|
-
export const getHTML = () => {
|
|
6
|
-
|
|
7
|
+
export const getHTML = (attrs: any = { name: 'recipients' }): string => {
|
|
8
|
+
const selectHTML = `
|
|
9
|
+
<temba-omnibox${Object.keys(attrs)
|
|
10
|
+
.map((name: string) => {
|
|
11
|
+
// check if it's a string attribute
|
|
12
|
+
if (typeof attrs[name] === 'string') {
|
|
13
|
+
return ` ${name}="${attrs[name].replace(/"/g, '"')}"`;
|
|
14
|
+
}
|
|
15
|
+
return ` ${name}="${attrs[name]}"`;
|
|
16
|
+
})
|
|
17
|
+
.join(' ')}>
|
|
18
|
+
</temba-select>`;
|
|
19
|
+
return selectHTML;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const createOmnibox = async (
|
|
23
|
+
clock: any,
|
|
24
|
+
attrs: any = {}
|
|
25
|
+
): Promise<Omnibox> => {
|
|
26
|
+
const parentNode = document.createElement('div');
|
|
27
|
+
parentNode.setAttribute('style', 'width: 250px;');
|
|
28
|
+
|
|
29
|
+
const omnibox: Omnibox = await fixture(getHTML(attrs), { parentNode });
|
|
30
|
+
clock.runAll();
|
|
31
|
+
await omnibox.updateComplete;
|
|
32
|
+
return omnibox;
|
|
7
33
|
};
|
|
8
34
|
|
|
9
35
|
describe('temba-omnibox', () => {
|
|
36
|
+
let clock: any;
|
|
37
|
+
beforeEach(function () {
|
|
38
|
+
clock = useFakeTimers();
|
|
39
|
+
setViewport({ width: 500, height: 1000, deviceScaleFactor: 2 });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(function () {
|
|
43
|
+
clock.restore();
|
|
44
|
+
});
|
|
45
|
+
|
|
10
46
|
it('can be created', async () => {
|
|
11
|
-
const omnibox: Omnibox = await fixture(
|
|
47
|
+
const omnibox: Omnibox = await fixture(
|
|
48
|
+
getHTML({ endpoint: '/test-assets/select/omnibox.json' })
|
|
49
|
+
);
|
|
12
50
|
assert.instanceOf(omnibox, Omnibox);
|
|
13
51
|
});
|
|
52
|
+
|
|
53
|
+
it('fires change events on selection', async () => {
|
|
54
|
+
const omnibox: Omnibox = await createOmnibox(clock, {
|
|
55
|
+
endpoint: '/test-assets/select/omnibox.json'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const changeEvent = spy();
|
|
59
|
+
omnibox.addEventListener('change', changeEvent);
|
|
60
|
+
|
|
61
|
+
await openAndClick(clock, omnibox, 0);
|
|
62
|
+
assert(changeEvent.called, 'change event not fired');
|
|
63
|
+
|
|
64
|
+
await assertScreenshot('omnibox/selected', getClip(omnibox));
|
|
65
|
+
});
|
|
14
66
|
});
|