@nyaruka/temba-components 0.170.1 → 0.172.0
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 +24 -0
- package/dist/temba-components.js +763 -703
- package/dist/temba-components.js.map +1 -1
- package/package.json +1 -1
- package/src/RapidElement.ts +83 -41
- package/src/events/eventRenderers.ts +4 -0
- package/src/flow/Editor.ts +202 -42
- package/src/flow/FlowSearch.ts +12 -392
- package/src/flow/actions/send_msg.ts +2 -1
- package/src/flow/actions/set_contact_field.ts +1 -0
- package/src/flow/actions/set_contact_name.ts +1 -0
- package/src/flow/dependencies.ts +115 -0
- package/src/flow/nodes/split_by_ticket.ts +1 -0
- package/src/flow/nodes/wait_for_dial.ts +1 -0
- package/src/form/RangePicker.ts +137 -97
- package/src/layout/SearchModal.ts +564 -0
- package/src/list/ContentList.ts +7 -1
- package/src/list/FlowList.ts +82 -0
- package/src/list/TembaMenu.ts +71 -13
- package/src/live/ContactChat.ts +247 -70
- package/src/live/ContactWatch.ts +166 -63
- package/src/live/Realtime.ts +155 -4
- package/src/live/SocketService.ts +115 -10
- package/src/live/TicketSearch.ts +290 -0
- package/src/live/Watchers.ts +93 -0
- package/src/simulator/Simulator.ts +59 -36
- package/src/store/AppState.ts +97 -10
- package/src/store/Store.ts +478 -6
- package/src/store/identity.ts +28 -0
- package/src/utils.ts +10 -8
- package/temba-modules.ts +2 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const UNHYPHENATED_UUID = /^[0-9a-f]{32}$/;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Canonicalizes a uuid the way the server does, so a reference embedded in a
|
|
5
|
+
* flow definition in some other form (uppercase, braced, unhyphenated) still
|
|
6
|
+
* matches the normalized uuid the endpoint echoes back.
|
|
7
|
+
*
|
|
8
|
+
* This lives in its own module with no imports so both the store's asset cache
|
|
9
|
+
* and the flow definition rewriter can share it - they sit on opposite sides of
|
|
10
|
+
* a `Store -> AppState -> dependencies` chain, so a shared helper in either one
|
|
11
|
+
* would close an import cycle.
|
|
12
|
+
*/
|
|
13
|
+
export const normalizeUuid = (uuid: string): string => {
|
|
14
|
+
const trimmed = uuid
|
|
15
|
+
.trim()
|
|
16
|
+
.replace(/^\{|\}$/g, '')
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
if (UNHYPHENATED_UUID.test(trimmed)) {
|
|
19
|
+
return [
|
|
20
|
+
trimmed.slice(0, 8),
|
|
21
|
+
trimmed.slice(8, 12),
|
|
22
|
+
trimmed.slice(12, 16),
|
|
23
|
+
trimmed.slice(16, 20),
|
|
24
|
+
trimmed.slice(20)
|
|
25
|
+
].join('-');
|
|
26
|
+
}
|
|
27
|
+
return trimmed;
|
|
28
|
+
};
|
package/src/utils.ts
CHANGED
|
@@ -47,8 +47,8 @@ interface KeyedAsset {
|
|
|
47
47
|
key?: string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
interface AssetPage {
|
|
51
|
-
assets:
|
|
50
|
+
interface AssetPage<T = Asset> {
|
|
51
|
+
assets: T[];
|
|
52
52
|
next: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -233,8 +233,10 @@ export const fetchResults = async (
|
|
|
233
233
|
return results;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
/** Fetches one page of an asset endpoint. The caller names the shape it
|
|
237
|
+
* expects, since these endpoints serve everything from groups to shortcuts. */
|
|
238
|
+
export const getAssetPage = <T = Asset>(url: string): Promise<AssetPage<T>> => {
|
|
239
|
+
return new Promise<AssetPage<T>>((resolve, reject) => {
|
|
238
240
|
getUrl(url)
|
|
239
241
|
.then((response: WebResponse) => {
|
|
240
242
|
if (response.status >= 200 && response.status < 300) {
|
|
@@ -250,15 +252,15 @@ export const getAssetPage = (url: string): Promise<AssetPage> => {
|
|
|
250
252
|
});
|
|
251
253
|
};
|
|
252
254
|
|
|
253
|
-
export const getAssets = async (url: string): Promise<
|
|
255
|
+
export const getAssets = async <T = Asset>(url: string): Promise<T[]> => {
|
|
254
256
|
if (!url) {
|
|
255
|
-
return new Promise<
|
|
257
|
+
return new Promise<T[]>((resolve) => resolve([]));
|
|
256
258
|
}
|
|
257
259
|
|
|
258
|
-
let assets:
|
|
260
|
+
let assets: T[] = [];
|
|
259
261
|
let pageUrl = url;
|
|
260
262
|
while (pageUrl) {
|
|
261
|
-
const assetPage = await getAssetPage(pageUrl);
|
|
263
|
+
const assetPage = await getAssetPage<T>(pageUrl);
|
|
262
264
|
if (assetPage.assets) {
|
|
263
265
|
assets = assets.concat(assetPage.assets);
|
|
264
266
|
pageUrl = assetPage.next;
|
package/temba-modules.ts
CHANGED
|
@@ -95,6 +95,7 @@ import { CardStack } from './src/layout/CardStack';
|
|
|
95
95
|
import { CardLayout } from './src/layout/CardLayout';
|
|
96
96
|
import { Simulator } from './src/simulator/Simulator';
|
|
97
97
|
import { FlowSearch } from './src/flow/FlowSearch';
|
|
98
|
+
import { TicketSearch } from './src/live/TicketSearch';
|
|
98
99
|
import { IssuesWindow } from './src/flow/IssuesWindow';
|
|
99
100
|
import { RevisionsWindow } from './src/flow/RevisionsWindow';
|
|
100
101
|
import { AutoTranslate } from './src/flow/AutoTranslate';
|
|
@@ -205,6 +206,7 @@ addCustomElement('temba-floating-tab', FloatingTab);
|
|
|
205
206
|
addCustomElement('temba-floating-window', FloatingWindow);
|
|
206
207
|
addCustomElement('temba-simulator', Simulator);
|
|
207
208
|
addCustomElement('temba-flow-search', FlowSearch);
|
|
209
|
+
addCustomElement('temba-ticket-search', TicketSearch);
|
|
208
210
|
addCustomElement('temba-issues-window', IssuesWindow);
|
|
209
211
|
addCustomElement('temba-revisions-window', RevisionsWindow);
|
|
210
212
|
addCustomElement('temba-auto-translate', AutoTranslate);
|