@nyaruka/temba-components 0.35.3 → 0.37.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.
Files changed (232) hide show
  1. package/.eslintrc.js +0 -2
  2. package/.github/workflows/build.yml +1 -0
  3. package/.github/workflows/publish.yml +2 -3
  4. package/.github/workflows/stale.yml +26 -0
  5. package/CHANGELOG.md +31 -0
  6. package/demo/index.html +1 -3
  7. package/dist/46adbabc.js +5792 -0
  8. package/dist/index.js +541 -487
  9. package/dist/sw.js +1 -1
  10. package/dist/sw.js.map +1 -1
  11. package/dist/templates/components-body.html +1 -1
  12. package/dist/templates/components-head.html +1 -1
  13. package/dist/workbox-919adfb7.js +2 -0
  14. package/dist/workbox-919adfb7.js.map +1 -0
  15. package/out-tsc/src/FormElement.js +1 -1
  16. package/out-tsc/src/FormElement.js.map +1 -1
  17. package/out-tsc/src/RefreshElement.js +1 -1
  18. package/out-tsc/src/RefreshElement.js.map +1 -1
  19. package/out-tsc/src/alert/Alert.js +1 -1
  20. package/out-tsc/src/alert/Alert.js.map +1 -1
  21. package/out-tsc/src/aliaseditor/AliasEditor.js +6 -6
  22. package/out-tsc/src/aliaseditor/AliasEditor.js.map +1 -1
  23. package/out-tsc/src/anchor/Anchor.js +1 -1
  24. package/out-tsc/src/anchor/Anchor.js.map +1 -1
  25. package/out-tsc/src/button/Button.js +1 -1
  26. package/out-tsc/src/button/Button.js.map +1 -1
  27. package/out-tsc/src/charcount/CharCount.js +1 -1
  28. package/out-tsc/src/charcount/CharCount.js.map +1 -1
  29. package/out-tsc/src/checkbox/Checkbox.js +1 -1
  30. package/out-tsc/src/checkbox/Checkbox.js.map +1 -1
  31. package/out-tsc/src/completion/Completion.js +3 -3
  32. package/out-tsc/src/completion/Completion.js.map +1 -1
  33. package/out-tsc/src/completion/helpers.js +2 -2
  34. package/out-tsc/src/completion/helpers.js.map +1 -1
  35. package/out-tsc/src/contacts/ContactChat.js +184 -156
  36. package/out-tsc/src/contacts/ContactChat.js.map +1 -1
  37. package/out-tsc/src/contacts/ContactDetails.js +1 -1
  38. package/out-tsc/src/contacts/ContactDetails.js.map +1 -1
  39. package/out-tsc/src/contacts/ContactFieldEditor.js +1 -1
  40. package/out-tsc/src/contacts/ContactFieldEditor.js.map +1 -1
  41. package/out-tsc/src/contacts/ContactFields.js +1 -1
  42. package/out-tsc/src/contacts/ContactFields.js.map +1 -1
  43. package/out-tsc/src/contacts/ContactHistory.js +1 -1
  44. package/out-tsc/src/contacts/ContactHistory.js.map +1 -1
  45. package/out-tsc/src/contacts/ContactName.js +1 -1
  46. package/out-tsc/src/contacts/ContactName.js.map +1 -1
  47. package/out-tsc/src/contacts/ContactNameFetch.js +1 -1
  48. package/out-tsc/src/contacts/ContactNameFetch.js.map +1 -1
  49. package/out-tsc/src/contacts/ContactPending.js +13 -13
  50. package/out-tsc/src/contacts/ContactPending.js.map +1 -1
  51. package/out-tsc/src/contacts/ContactStoreElement.js +1 -1
  52. package/out-tsc/src/contacts/ContactStoreElement.js.map +1 -1
  53. package/out-tsc/src/contacts/ContactTickets.js +1 -1
  54. package/out-tsc/src/contacts/ContactTickets.js.map +1 -1
  55. package/out-tsc/src/contacts/ContactUrn.js +1 -1
  56. package/out-tsc/src/contacts/ContactUrn.js.map +1 -1
  57. package/out-tsc/src/contactsearch/ContactSearch.js +1 -1
  58. package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
  59. package/out-tsc/src/date/TembaDate.js +1 -1
  60. package/out-tsc/src/date/TembaDate.js.map +1 -1
  61. package/out-tsc/src/datepicker/DatePicker.js +8 -8
  62. package/out-tsc/src/datepicker/DatePicker.js.map +1 -1
  63. package/out-tsc/src/dialog/Dialog.js +11 -11
  64. package/out-tsc/src/dialog/Dialog.js.map +1 -1
  65. package/out-tsc/src/dialog/Modax.js +16 -17
  66. package/out-tsc/src/dialog/Modax.js.map +1 -1
  67. package/out-tsc/src/dropdown/Dropdown.js +1 -1
  68. package/out-tsc/src/dropdown/Dropdown.js.map +1 -1
  69. package/out-tsc/src/fields/FieldManager.js +1 -1
  70. package/out-tsc/src/fields/FieldManager.js.map +1 -1
  71. package/out-tsc/src/flow/FlowStoreElement.js +1 -1
  72. package/out-tsc/src/flow/FlowStoreElement.js.map +1 -1
  73. package/out-tsc/src/formfield/FormField.js +1 -1
  74. package/out-tsc/src/formfield/FormField.js.map +1 -1
  75. package/out-tsc/src/label/Label.js +2 -2
  76. package/out-tsc/src/label/Label.js.map +1 -1
  77. package/out-tsc/src/leafletmap/LeafletMap.js +12 -12
  78. package/out-tsc/src/leafletmap/LeafletMap.js.map +1 -1
  79. package/out-tsc/src/list/ContentMenu.js +176 -0
  80. package/out-tsc/src/list/ContentMenu.js.map +1 -0
  81. package/out-tsc/src/list/RunList.js +13 -12
  82. package/out-tsc/src/list/RunList.js.map +1 -1
  83. package/out-tsc/src/list/SortableList.js +14 -14
  84. package/out-tsc/src/list/SortableList.js.map +1 -1
  85. package/out-tsc/src/list/TembaList.js +14 -16
  86. package/out-tsc/src/list/TembaList.js.map +1 -1
  87. package/out-tsc/src/list/TembaMenu.js +108 -108
  88. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  89. package/out-tsc/src/list/TicketList.js +8 -8
  90. package/out-tsc/src/list/TicketList.js.map +1 -1
  91. package/out-tsc/src/loading/Loading.js +2 -2
  92. package/out-tsc/src/loading/Loading.js.map +1 -1
  93. package/out-tsc/src/omnibox/Omnibox.js +2 -2
  94. package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
  95. package/out-tsc/src/options/Options.js +2 -2
  96. package/out-tsc/src/options/Options.js.map +1 -1
  97. package/out-tsc/src/remote/Remote.js +1 -1
  98. package/out-tsc/src/remote/Remote.js.map +1 -1
  99. package/out-tsc/src/select/Select.js +2 -2
  100. package/out-tsc/src/select/Select.js.map +1 -1
  101. package/out-tsc/src/shadowless/Shadowless.js +1 -1
  102. package/out-tsc/src/shadowless/Shadowless.js.map +1 -1
  103. package/out-tsc/src/slider/TembaSlider.js +2 -2
  104. package/out-tsc/src/slider/TembaSlider.js.map +1 -1
  105. package/out-tsc/src/store/Store.js +8 -5
  106. package/out-tsc/src/store/Store.js.map +1 -1
  107. package/out-tsc/src/store/StoreElement.js +1 -1
  108. package/out-tsc/src/store/StoreElement.js.map +1 -1
  109. package/out-tsc/src/tabpane/Tab.js +1 -1
  110. package/out-tsc/src/tabpane/Tab.js.map +1 -1
  111. package/out-tsc/src/tabpane/TabPane.js +1 -1
  112. package/out-tsc/src/tabpane/TabPane.js.map +1 -1
  113. package/out-tsc/src/textinput/TextInput.js +15 -15
  114. package/out-tsc/src/textinput/TextInput.js.map +1 -1
  115. package/out-tsc/src/tip/Tip.js +2 -2
  116. package/out-tsc/src/tip/Tip.js.map +1 -1
  117. package/out-tsc/src/utils/index.js +1 -6
  118. package/out-tsc/src/utils/index.js.map +1 -1
  119. package/out-tsc/src/vectoricon/VectorIcon.js +9 -9
  120. package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
  121. package/out-tsc/temba-modules.js +3 -0
  122. package/out-tsc/temba-modules.js.map +1 -1
  123. package/out-tsc/test/MouseHelper.js +1 -1
  124. package/out-tsc/test/MouseHelper.js.map +1 -1
  125. package/out-tsc/test/temba-contact-chat.test.js +93 -50
  126. package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
  127. package/out-tsc/test/temba-contact-history.test.js +1 -1
  128. package/out-tsc/test/temba-contact-history.test.js.map +1 -1
  129. package/out-tsc/test/temba-content-menu.test.js +71 -0
  130. package/out-tsc/test/temba-content-menu.test.js.map +1 -0
  131. package/out-tsc/test/temba-modax.test.js +18 -19
  132. package/out-tsc/test/temba-modax.test.js.map +1 -1
  133. package/out-tsc/test/temba-select.test.js +1 -0
  134. package/out-tsc/test/temba-select.test.js.map +1 -1
  135. package/out-tsc/test/temba-tip.test.js +4 -6
  136. package/out-tsc/test/temba-tip.test.js.map +1 -1
  137. package/out-tsc/test/utils.test.js +5 -17
  138. package/out-tsc/test/utils.test.js.map +1 -1
  139. package/package.json +16 -28
  140. package/rollup.config.js +13 -7
  141. package/screenshots/truth/contacts/{contact-active-show-chat-history.png → contact-active-show-chatbox.png} +0 -0
  142. package/screenshots/truth/contacts/contact-active-ticket-closed-show-reopen-button.png +0 -0
  143. package/screenshots/truth/contacts/contact-active-ticket-open-show-chatbox.png +0 -0
  144. package/screenshots/truth/contacts/{contact-archived-hide-chat-msg.png → contact-archived-hide-chatbox.png} +0 -0
  145. package/screenshots/truth/contacts/contact-archived-ticket-closed-hide-chatbox.png +0 -0
  146. package/screenshots/truth/contacts/{contact-archived-show-chat-history.png → contact-blocked-hide-chatbox.png} +0 -0
  147. package/screenshots/truth/contacts/{contact-blocked-hide-chat-msg.png → contact-stopped-hide-chatbox.png} +0 -0
  148. package/screenshots/truth/content-menu/button-no-items.png +0 -0
  149. package/screenshots/truth/content-menu/item-no-buttons.png +0 -0
  150. package/screenshots/truth/content-menu/items-and-buttons.png +0 -0
  151. package/src/FormElement.ts +1 -1
  152. package/src/RefreshElement.ts +1 -1
  153. package/src/alert/Alert.ts +1 -1
  154. package/src/aliaseditor/AliasEditor.ts +2 -2
  155. package/src/anchor/Anchor.ts +1 -1
  156. package/src/button/Button.ts +1 -1
  157. package/src/charcount/CharCount.ts +1 -1
  158. package/src/checkbox/Checkbox.ts +1 -1
  159. package/src/completion/Completion.ts +3 -3
  160. package/src/completion/helpers.ts +8 -2
  161. package/src/contacts/ContactChat.ts +185 -157
  162. package/src/contacts/ContactDetails.ts +1 -1
  163. package/src/contacts/ContactFieldEditor.ts +1 -1
  164. package/src/contacts/ContactFields.ts +1 -1
  165. package/src/contacts/ContactHistory.ts +1 -1
  166. package/src/contacts/ContactName.ts +1 -1
  167. package/src/contacts/ContactNameFetch.ts +1 -1
  168. package/src/contacts/ContactPending.ts +1 -1
  169. package/src/contacts/ContactStoreElement.ts +1 -1
  170. package/src/contacts/ContactTickets.ts +1 -1
  171. package/src/contacts/ContactUrn.ts +1 -1
  172. package/src/contactsearch/ContactSearch.ts +1 -1
  173. package/src/date/TembaDate.ts +1 -1
  174. package/src/datepicker/DatePicker.ts +1 -1
  175. package/src/dialog/Dialog.ts +2 -2
  176. package/src/dialog/Modax.ts +17 -24
  177. package/src/dropdown/Dropdown.ts +1 -1
  178. package/src/fields/FieldManager.ts +1 -1
  179. package/src/flow/FlowStoreElement.ts +1 -1
  180. package/src/formfield/FormField.ts +1 -1
  181. package/src/label/Label.ts +2 -2
  182. package/src/leafletmap/LeafletMap.ts +1 -1
  183. package/src/list/ContentMenu.ts +192 -0
  184. package/src/list/RunList.ts +4 -3
  185. package/src/list/SortableList.ts +1 -1
  186. package/src/list/TembaList.ts +2 -4
  187. package/src/list/TembaMenu.ts +1 -1
  188. package/src/list/TicketList.ts +1 -1
  189. package/src/loading/Loading.ts +2 -2
  190. package/src/omnibox/Omnibox.ts +2 -2
  191. package/src/options/Options.ts +2 -2
  192. package/src/remote/Remote.ts +1 -1
  193. package/src/select/Select.ts +2 -2
  194. package/src/shadowless/Shadowless.ts +1 -1
  195. package/src/slider/TembaSlider.ts +2 -2
  196. package/src/store/Store.ts +11 -7
  197. package/src/store/StoreElement.ts +1 -1
  198. package/src/tabpane/Tab.ts +1 -1
  199. package/src/tabpane/TabPane.ts +1 -1
  200. package/src/textinput/TextInput.ts +3 -3
  201. package/src/tip/Tip.ts +6 -6
  202. package/src/untyped.d.ts +0 -2
  203. package/src/utils/index.ts +1 -5
  204. package/src/vectoricon/VectorIcon.ts +1 -1
  205. package/temba-modules.ts +3 -0
  206. package/test/MouseHelper.ts +1 -1
  207. package/test/temba-contact-chat.test.ts +148 -62
  208. package/test/temba-contact-history.test.ts +1 -1
  209. package/test/temba-content-menu.test.ts +100 -0
  210. package/test/temba-modax.test.ts +25 -21
  211. package/test/temba-select.test.ts +2 -0
  212. package/test/temba-tip.test.ts +10 -5
  213. package/test/utils.test.ts +6 -19
  214. package/test-assets/contacts/{contact-barak-archived → contact-barack-archived} +1 -1
  215. package/test-assets/contacts/contact-carter-active +52 -0
  216. package/test-assets/contacts/contact-michelle-blocked +1 -1
  217. package/test-assets/contacts/contact-tim-stopped +1 -1
  218. package/test-assets/list/content-menu-archived-contacts.json +12 -0
  219. package/test-assets/list/content-menu-contact-read.json +49 -0
  220. package/test-assets/list/content-menu-new-campaign.json +15 -0
  221. package/test-assets/tickets/empty.json +6 -0
  222. package/test-assets/tickets/ticket-barack-closed.json +22 -0
  223. package/test-assets/tickets/ticket-carter-closed.json +22 -0
  224. package/test-assets/tickets/ticket-carter-open.json +22 -0
  225. package/web-test-runner.config.mjs +21 -18
  226. package/dist/445f048b.js +0 -5738
  227. package/dist/workbox-80efdfd1.js +0 -2
  228. package/dist/workbox-80efdfd1.js.map +0 -1
  229. package/screenshots/truth/contacts/contact-active-show-chat-msg.png +0 -0
  230. package/screenshots/truth/contacts/contact-blocked-show-chat-history.png +0 -0
  231. package/screenshots/truth/contacts/contact-stopped-hide-chat-msg.png +0 -0
  232. package/screenshots/truth/contacts/contact-stopped-show-chat-history.png +0 -0
@@ -9,7 +9,7 @@ import {
9
9
  Path,
10
10
  } from 'leaflet';
11
11
  import { css, html, LitElement } from 'lit';
12
- import { property } from 'lit/decorators';
12
+ import { property } from 'lit/decorators.js';
13
13
 
14
14
  import { FeatureProperties } from '../interfaces';
15
15
  import { getUrl, WebResponse } from '../utils';
@@ -0,0 +1,192 @@
1
+ import { TemplateResult, html, css } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import { CustomEventType } from '../interfaces';
4
+
5
+ import { RapidElement } from '../RapidElement';
6
+ import { getUrl, WebResponse } from '../utils';
7
+
8
+ const HEADERS = {
9
+ 'Temba-Content-Menu': '1',
10
+ 'Temba-Spa': '1',
11
+ };
12
+ export interface ContentMenuItem {
13
+ type: string;
14
+ as_button: boolean;
15
+ label: string;
16
+ url: string;
17
+ disabled: boolean;
18
+ modal_id: string;
19
+ on_submit: string;
20
+ primary: boolean;
21
+ title: string;
22
+ on_click: null;
23
+ link_class: string;
24
+ }
25
+
26
+ export enum ContentMenuItemType {
27
+ LINK = 'link',
28
+ JS = 'js',
29
+ URL_POST = 'url_post',
30
+ MODAX = 'modax',
31
+ DIVIDER = 'divider',
32
+ }
33
+
34
+ export class ContentMenu extends RapidElement {
35
+ static get styles() {
36
+ return css`
37
+ .container {
38
+ --button-y: 0.4em;
39
+ --button-x: 1em;
40
+ display: flex;
41
+ }
42
+
43
+ .button_item,
44
+ .primary_button_item {
45
+ margin-left: 1rem;
46
+ }
47
+
48
+ .toggle {
49
+ --icon-color: rgb(102, 102, 102);
50
+ padding: 0.5rem;
51
+ margin-left: 0.5rem;
52
+ }
53
+
54
+ .toggle:hover {
55
+ background: rgba(0, 0, 0, 0.05);
56
+ border-radius: var(--curvature);
57
+ --icon-color: rgb(136, 136, 136);
58
+ }
59
+
60
+ .dropdown {
61
+ padding: 1rem 1.5rem;
62
+ color: rgb(45, 45, 45);
63
+ z-index: 50;
64
+ min-width: 200px;
65
+ }
66
+
67
+ .divider {
68
+ border-bottom: 1px solid rgb(237, 237, 237);
69
+ margin: 1rem -1.5em;
70
+ }
71
+
72
+ .item {
73
+ white-space: nowrap;
74
+ margin: 0.2em 0em;
75
+ font-size: 1.1rem;
76
+ cursor: pointer;
77
+ font-weight: 400;
78
+ }
79
+
80
+ .item:hover {
81
+ color: rgb(var(--primary-rgb));
82
+ }
83
+ `;
84
+ }
85
+
86
+ @property({ type: String })
87
+ endpoint: string;
88
+
89
+ @property({ type: Number })
90
+ legacy: number;
91
+
92
+ @property({ type: Array, attribute: false })
93
+ buttons: ContentMenuItem[] = [];
94
+
95
+ @property({ type: Array, attribute: false })
96
+ items: ContentMenuItem[] = [];
97
+
98
+ private fetchContentMenu() {
99
+ const url = this.endpoint;
100
+ if (url) {
101
+ const legacy = this.legacy;
102
+ const headers = HEADERS;
103
+ if (legacy) {
104
+ delete headers['Temba-Spa'];
105
+ }
106
+
107
+ //ok, fetch the content menu
108
+ getUrl(url, null, headers)
109
+ .then((response: WebResponse) => {
110
+ const json = response.json;
111
+ const contentMenu = json.items as ContentMenuItem[];
112
+
113
+ //populate (or initialize) the buttons and items
114
+ if (contentMenu) {
115
+ this.buttons = contentMenu.filter(item => item.as_button);
116
+ this.items = contentMenu.filter(item => !item.as_button);
117
+ } else {
118
+ this.buttons = [];
119
+ this.items = [];
120
+ }
121
+
122
+ //fire custom loaded event type when we're finished
123
+ this.fireCustomEvent(CustomEventType.Loaded, {
124
+ buttons: this.buttons,
125
+ items: this.items,
126
+ });
127
+ })
128
+ .catch((error: any) => {
129
+ console.error(error);
130
+ });
131
+ }
132
+ }
133
+
134
+ public refresh() {
135
+ this.fetchContentMenu();
136
+ }
137
+
138
+ protected updated(changes: Map<string, any>) {
139
+ super.updated(changes);
140
+
141
+ if (changes.has('endpoint') || changes.has('legacy')) {
142
+ this.fetchContentMenu();
143
+ }
144
+ }
145
+
146
+ private handleItemClicked(item: ContentMenuItem) {
147
+ this.fireCustomEvent(CustomEventType.Selection, item);
148
+ }
149
+
150
+ public render(): TemplateResult {
151
+ return html`
152
+ <div class="container">
153
+ ${this.buttons.map(button => {
154
+ return html`<temba-button
155
+ class="${button.primary ? 'primary_button_item' : 'button_item'}"
156
+ name=${button.label}
157
+ @click=${() => this.handleItemClicked(button)}
158
+ >
159
+ ${button.label}
160
+ </temba-button>`;
161
+ })}
162
+ ${this.items && this.items.length > 0
163
+ ? html` <temba-dropdown
164
+ arrowsize="8"
165
+ arrowoffset="-12"
166
+ offsetx="-200"
167
+ offsety="6"
168
+ >
169
+ <div slot="toggle" class="toggle">
170
+ <temba-icon name="menu" size="1.5"></temba-icon>
171
+ </div>
172
+ <div slot="dropdown" class="dropdown">
173
+ ${this.items.map(item => {
174
+ if (item.type === ContentMenuItemType.DIVIDER) {
175
+ return html` <div class="divider"></div>`;
176
+ } else {
177
+ return html` <div
178
+ class="item"
179
+ name=${item.label}
180
+ @click=${() => this.handleItemClicked(item)}
181
+ >
182
+ ${item.label}
183
+ </div>`;
184
+ }
185
+ })}
186
+ </div>
187
+ </temba-dropdown>`
188
+ : null}
189
+ </div>
190
+ `;
191
+ }
192
+ }
@@ -1,8 +1,9 @@
1
1
  import { html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { Checkbox } from '../checkbox/Checkbox';
4
4
  import { Select } from '../select/Select';
5
5
  import { capitalize } from '../utils';
6
+ import { Icon } from '../vectoricon';
6
7
  import { TembaList } from './TembaList';
7
8
 
8
9
  const FLOW_COLOR = 'rgb(223, 65, 159)';
@@ -268,7 +269,7 @@ export class RunList extends TembaList {
268
269
  <temba-date
269
270
  value="${this.selectedRun.created_on}"
270
271
  display="duration"
271
- />
272
+ ></temba-date>
272
273
  </div>`}
273
274
  </div>
274
275
  </div>
@@ -286,7 +287,7 @@ export class RunList extends TembaList {
286
287
  <temba-icon
287
288
  clickable
288
289
  style="margin-left:0.75em;"
289
- name="trash"
290
+ name=${Icon.delete}
290
291
  onclick="deleteRun(${this.selectedRun.id});"
291
292
  ></temba-icon>
292
293
  </div>
@@ -1,5 +1,5 @@
1
1
  import { css, html, PropertyValueMap, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement } from '../RapidElement';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { Store } from '../store/Store';
@@ -143,9 +143,7 @@ export class TembaList extends RapidElement {
143
143
  }
144
144
 
145
145
  if (changedProperties.has('mostRecentItem')) {
146
- if (this.mostRecentItem) {
147
- this.fireCustomEvent(CustomEventType.Refreshed);
148
- }
146
+ this.fireCustomEvent(CustomEventType.Refreshed);
149
147
  }
150
148
 
151
149
  if (changedProperties.has('cursorIndex')) {
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { fetchResults, getClasses } from '../utils';
@@ -1,5 +1,5 @@
1
1
  import { html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { TembaList } from './TembaList';
4
4
  import { timeSince } from '../utils';
5
5
  import { Contact } from '../interfaces';
@@ -1,6 +1,6 @@
1
1
  import { html, TemplateResult, css, LitElement } from 'lit';
2
- import { property } from 'lit/decorators';
3
- import { styleMap } from 'lit-html/directives/style-map';
2
+ import { property } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit-html/directives/style-map.js';
4
4
  import { range } from '../utils';
5
5
 
6
6
  export class Loading extends LitElement {
@@ -1,6 +1,6 @@
1
1
  import { TemplateResult, html, css } from 'lit';
2
- import { property } from 'lit/decorators';
3
- import { styleMap } from 'lit-html/directives/style-map';
2
+ import { property } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit-html/directives/style-map.js';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { Select } from '../select/Select';
6
6
  import { Icon } from '../vectoricon';
@@ -1,8 +1,8 @@
1
1
  import { TemplateResult, html, css } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement, EventHandler } from '../RapidElement';
5
- import { styleMap } from 'lit-html/directives/style-map';
5
+ import { styleMap } from 'lit-html/directives/style-map.js';
6
6
  import {
7
7
  getClasses,
8
8
  getScrollParent,
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property, customElement } from 'lit/decorators';
2
+ import { property, customElement } from 'lit/decorators.js';
3
3
  import { RapidElement } from '../RapidElement';
4
4
 
5
5
  @customElement('temba-remote')
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  import { TemplateResult, html, css } from 'lit';
3
- import { property } from 'lit/decorators';
3
+ import { property } from 'lit/decorators.js';
4
4
  import {
5
5
  getUrl,
6
6
  getClasses,
@@ -20,7 +20,7 @@ import {
20
20
  executeCompletionQuery,
21
21
  } from '../completion/helpers';
22
22
  import { Store } from '../store/Store';
23
- import { styleMap } from 'lit-html/directives/style-map';
23
+ import { styleMap } from 'lit-html/directives/style-map.js';
24
24
  import { Icon } from '../vectoricon';
25
25
 
26
26
  const LOOK_AHEAD = 20;
@@ -1,4 +1,4 @@
1
- import { customElement, property } from 'lit/decorators';
1
+ import { customElement, property } from 'lit/decorators.js';
2
2
  import { TemplateResult, LitElement } from 'lit';
3
3
 
4
4
  @customElement('temba-shadowless')
@@ -1,6 +1,6 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { styleMap } from 'lit-html/directives/style-map';
3
- import { property } from 'lit/decorators';
2
+ import { styleMap } from 'lit-html/directives/style-map.js';
3
+ import { property } from 'lit/decorators.js';
4
4
  import { FormElement } from '../FormElement';
5
5
  import { getClasses } from '../utils';
6
6
 
@@ -1,4 +1,4 @@
1
- import { property } from 'lit/decorators';
1
+ import { property } from 'lit/decorators.js';
2
2
  import {
3
3
  fetchResults,
4
4
  getUrl,
@@ -6,6 +6,8 @@ import {
6
6
  Asset,
7
7
  WebResponse,
8
8
  postUrl,
9
+ postJSON,
10
+ postForm,
9
11
  } from '../utils';
10
12
  import {
11
13
  ContactField,
@@ -18,10 +20,6 @@ import {
18
20
  } from '../interfaces';
19
21
  import { RapidElement } from '../RapidElement';
20
22
  import Lru from 'tiny-lru';
21
- import {
22
- HumanizeDurationLanguage,
23
- HumanizeDuration,
24
- } from 'humanize-duration-ts';
25
23
  import { DateTime } from 'luxon';
26
24
 
27
25
  export class Store extends RapidElement {
@@ -66,8 +64,6 @@ export class Store extends RapidElement {
66
64
  private workspace: Workspace;
67
65
  private featuredFields: ContactField[] = [];
68
66
 
69
- private langService = new HumanizeDurationLanguage();
70
- private humanizer = new HumanizeDuration(this.langService);
71
67
 
72
68
  // http promise to monitor for completeness
73
69
  public httpComplete: Promise<void | WebResponse[]>;
@@ -263,6 +259,14 @@ export class Store extends RapidElement {
263
259
  .toLocaleString(DateTime.DATETIME_SHORT);
264
260
  }
265
261
 
262
+ public postJSON(url: string, payload: any = '') {
263
+ return postJSON(url, payload);
264
+ }
265
+
266
+ public postForm(url: string, payload: any | FormData) {
267
+ return postForm(url, payload);
268
+ }
269
+
266
270
  public postUrl(
267
271
  url: string,
268
272
  payload: any = '',
@@ -1,5 +1,5 @@
1
1
  import { PropertyValueMap } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { Store } from './Store';
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { RapidElement } from '../RapidElement';
4
4
  import { getClasses } from '../utils';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { CustomEventType } from '../interfaces';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { getClasses } from '../utils';
@@ -1,7 +1,7 @@
1
1
  import { TemplateResult, html, css } from 'lit';
2
- import { property } from 'lit/decorators';
3
- import { ifDefined } from 'lit-html/directives/if-defined';
4
- import { styleMap } from 'lit-html/directives/style-map';
2
+ import { property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit-html/directives/if-defined.js';
4
+ import { styleMap } from 'lit-html/directives/style-map.js';
5
5
  import { FormElement } from '../FormElement';
6
6
  import { Modax } from '../dialog/Modax';
7
7
  import { sanitize } from './helpers';
package/src/tip/Tip.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators';
3
- import { styleMap } from 'lit-html/directives/style-map';
2
+ import { property } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit-html/directives/style-map.js';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { getClasses } from '../utils';
6
6
  import { getCenter, getMiddle } from './helpers';
@@ -61,6 +61,7 @@ export class Tip extends RapidElement {
61
61
  }
62
62
  `;
63
63
  }
64
+
64
65
  @property({ type: String })
65
66
  text: string;
66
67
 
@@ -86,11 +87,13 @@ export class Tip extends RapidElement {
86
87
  poppedTop: boolean;
87
88
 
88
89
  arrow: string;
89
-
90
90
  arrowTop: number;
91
91
  arrowLeft: number;
92
92
  arrowDirection: string;
93
93
 
94
+ lastEnter = 0;
95
+ failSafe = 0;
96
+
94
97
  public updated(changed: Map<string, any>) {
95
98
  if ((changed.has('visible') || changed.has('text')) && this.visible) {
96
99
  this.calculatePosition();
@@ -148,9 +151,6 @@ export class Tip extends RapidElement {
148
151
  }
149
152
  }
150
153
 
151
- lastEnter = 0;
152
- failSafe = 0;
153
-
154
154
  private handleMouseEnter() {
155
155
  this.lastEnter = window.setTimeout(() => {
156
156
  this.visible = true;
package/src/untyped.d.ts CHANGED
@@ -16,5 +16,3 @@ declare function moveMouse(x: number, y: number);
16
16
  declare function mouseDown();
17
17
  declare function mouseUp();
18
18
  declare function setViewport({}: any);
19
-
20
- declare function readStaticFile(filename: string);
@@ -234,11 +234,7 @@ export const postFormData = (
234
234
  postUrl(url, formData, true)
235
235
  .then(response => {
236
236
  if (response.status >= 200 && response.status < 300) {
237
- if (response.json.status === 'success' || response.status === 201) {
238
- resolve(response);
239
- } else {
240
- reject({ errors: response.json.errors });
241
- }
237
+ resolve(response);
242
238
  }
243
239
  reject('Server failure');
244
240
  })
@@ -1,5 +1,5 @@
1
1
  import { LitElement, TemplateResult, html, css } from 'lit';
2
- import { property } from 'lit/decorators';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { Icon } from '.';
4
4
 
5
5
  import { getClasses } from '../utils';
package/temba-modules.ts CHANGED
@@ -41,6 +41,7 @@ import { ContactNameFetch } from './src/contacts/ContactNameFetch';
41
41
  import DatePicker from './src/datepicker/DatePicker';
42
42
  import { FieldManager } from './src/fields/FieldManager';
43
43
  import { SortableList } from './src/list/SortableList';
44
+ import { ContentMenu } from './src/list/ContentMenu';
44
45
  import { TembaDate } from './src/date/TembaDate';
45
46
 
46
47
  export function addCustomElement(name: string, comp: any) {
@@ -69,6 +70,7 @@ addCustomElement('temba-contact-field', ContactFieldEditor);
69
70
  addCustomElement('temba-contact-fields', ContactFields);
70
71
  addCustomElement('temba-field-manager', FieldManager);
71
72
  addCustomElement('temba-urn', ContactUrn);
73
+ addCustomElement('temba-content-menu', ContentMenu);
72
74
 
73
75
  addCustomElement('temba-field', FormField);
74
76
  addCustomElement('temba-dialog', Dialog);
@@ -93,3 +95,4 @@ addCustomElement('temba-contact-badges', ContactBadges);
93
95
  addCustomElement('temba-contact-pending', ContactPending);
94
96
  addCustomElement('temba-contact-tickets', ContactTickets);
95
97
  addCustomElement('temba-slider', TembaSlider);
98
+ addCustomElement('temba-content-menu', ContentMenu);
@@ -1,5 +1,5 @@
1
1
  import { css, html, TemplateResult } from 'lit';
2
- import { customElement } from 'lit/decorators';
2
+ import { customElement } from 'lit/decorators.js';
3
3
  import { RapidElement } from '../src/RapidElement';
4
4
 
5
5
  @customElement('mouse-helper')