@nyaruka/temba-components 0.159.0 → 0.159.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 +7 -0
- package/dist/temba-components.js +18 -3
- package/dist/temba-components.js.map +1 -1
- package/package.json +1 -1
- package/src/events/eventRenderers.ts +29 -0
- package/src/events.ts +22 -0
- package/src/list/ContentList.ts +11 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html, TemplateResult } from 'lit';
|
|
2
2
|
import {
|
|
3
|
+
AirtimeCreatedEvent,
|
|
3
4
|
AirtimeTransferredEvent,
|
|
4
5
|
CallEvent,
|
|
5
6
|
ChatStartedEvent,
|
|
@@ -17,6 +18,7 @@ import { getLanguageName } from '../languages';
|
|
|
17
18
|
import { oxfordFn } from '../utils';
|
|
18
19
|
|
|
19
20
|
export enum Events {
|
|
21
|
+
AIRTIME_CREATED = 'airtime_created',
|
|
20
22
|
AIRTIME_TRANSFERRED = 'airtime_transferred',
|
|
21
23
|
BROADCAST_CREATED = 'broadcast_created',
|
|
22
24
|
CALL_CREATED = 'call_created',
|
|
@@ -370,6 +372,30 @@ export const renderAirtimeTransferredEvent = (
|
|
|
370
372
|
</div>`;
|
|
371
373
|
};
|
|
372
374
|
|
|
375
|
+
export const renderAirtimeCreatedEvent = (
|
|
376
|
+
event: AirtimeCreatedEvent
|
|
377
|
+
): TemplateResult => {
|
|
378
|
+
const status = event._status?.status ?? 'created';
|
|
379
|
+
const amount = html`${valueText(event.amount)} ${event.currency}`;
|
|
380
|
+
|
|
381
|
+
switch (status) {
|
|
382
|
+
case 'reversed':
|
|
383
|
+
return html`<div>Airtime transfer reversed</div>`;
|
|
384
|
+
case 'rejected':
|
|
385
|
+
case 'cancelled':
|
|
386
|
+
case 'declined':
|
|
387
|
+
return html`<div>Airtime transfer failed</div>`;
|
|
388
|
+
case 'completed':
|
|
389
|
+
return html`<div style=${eventLineStyle}>
|
|
390
|
+
Transferred ${amount} of airtime
|
|
391
|
+
</div>`;
|
|
392
|
+
default:
|
|
393
|
+
return html`<div style=${eventLineStyle}>
|
|
394
|
+
Sending ${amount} of airtime
|
|
395
|
+
</div>`;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
373
399
|
export const renderContactLanguageChangedEvent = (
|
|
374
400
|
event: ContactLanguageChangedEvent
|
|
375
401
|
): TemplateResult => {
|
|
@@ -560,6 +586,9 @@ export const renderEvent = (
|
|
|
560
586
|
case Events.WARNING:
|
|
561
587
|
content = renderDiagnosticEvent(event, isSimulation);
|
|
562
588
|
break;
|
|
589
|
+
case Events.AIRTIME_CREATED:
|
|
590
|
+
content = renderAirtimeCreatedEvent(event as AirtimeCreatedEvent);
|
|
591
|
+
break;
|
|
563
592
|
case Events.AIRTIME_TRANSFERRED:
|
|
564
593
|
content = renderAirtimeTransferredEvent(event as AirtimeTransferredEvent);
|
|
565
594
|
break;
|
package/src/events.ts
CHANGED
|
@@ -90,6 +90,28 @@ export interface AirtimeTransferredEvent extends ContactEvent {
|
|
|
90
90
|
amount: string;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
export type AirtimeStatus =
|
|
94
|
+
| 'created'
|
|
95
|
+
| 'confirmed'
|
|
96
|
+
| 'rejected'
|
|
97
|
+
| 'cancelled'
|
|
98
|
+
| 'submitted'
|
|
99
|
+
| 'completed'
|
|
100
|
+
| 'reversed'
|
|
101
|
+
| 'declined';
|
|
102
|
+
|
|
103
|
+
export interface AirtimeCreatedEvent extends ContactEvent {
|
|
104
|
+
sender: string;
|
|
105
|
+
recipient: string;
|
|
106
|
+
currency: string;
|
|
107
|
+
amount: string;
|
|
108
|
+
external_id?: string;
|
|
109
|
+
_status?: {
|
|
110
|
+
created_on: string;
|
|
111
|
+
status: AirtimeStatus;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
93
115
|
export type CallStartedEvent = ContactEvent;
|
|
94
116
|
|
|
95
117
|
export interface ContactHistoryPage {
|
package/src/list/ContentList.ts
CHANGED
|
@@ -716,9 +716,20 @@ export class ContentList<T = any> extends RapidElement {
|
|
|
716
716
|
padding: 0 6px 0 0;
|
|
717
717
|
--icon-color: var(--text-3);
|
|
718
718
|
}
|
|
719
|
+
/* Reserve the icon's footprint on the wrapper itself so the
|
|
720
|
+
icon column's intrinsic width is the same whether
|
|
721
|
+
<temba-icon> has upgraded or not — without this, the column
|
|
722
|
+
briefly measures as just the cell's right-padding (6px) and
|
|
723
|
+
the downstream pinned columns end up positioned ~14px to
|
|
724
|
+
the left, which races with whatever moment we snapshot.
|
|
725
|
+
<temba-icon size="1"> renders at 1em, so we reserve 1em
|
|
726
|
+
square and let the icon paint into it. */
|
|
719
727
|
.icon-inner {
|
|
720
728
|
display: flex;
|
|
721
729
|
align-items: center;
|
|
730
|
+
justify-content: center;
|
|
731
|
+
width: 1em;
|
|
732
|
+
height: 1em;
|
|
722
733
|
}
|
|
723
734
|
tr.row.selected .icon-cell {
|
|
724
735
|
--icon-color: var(--accent-700);
|