@nyaruka/temba-components 0.120.1 → 0.120.3

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/demo/index.html CHANGED
@@ -1,298 +1,403 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link
6
+ href="/static/css/temba-components.css"
7
+ rel="stylesheet"
8
+ type="text/css"
9
+ />
10
+
11
+ <link
12
+ href="https://fonts.googleapis.com/css?family=Roboto+Mono:300|Roboto:300,400,500"
13
+ rel="stylesheet"
14
+ />
15
+
16
+ <style>
17
+ .linked {
18
+ text-decoration: underline;
19
+ color: blue;
20
+ cursor: pointer;
21
+ }
3
22
 
4
- <head>
5
- <meta charset="utf-8" />
6
- <link href="/static/css/temba-components.css" rel="stylesheet" type="text/css" />
7
-
8
- <link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300|Roboto:300,400,500" rel="stylesheet" />
9
-
10
- <style>
11
- .linked {
12
- text-decoration: underline;
13
- color: blue;
14
- cursor: pointer;
15
- }
16
-
17
- .example {
18
- border: 0px solid gray;
19
- padding: 10px;
20
- max-width: 500px;
21
- --temba-select-selected-font-size: 1em;
22
- }
23
-
24
- temba-dropdown.open {
25
- --icon-background: rgb(241, 241, 241);
26
- --icon-circle-size: 0.35em;
27
- }
28
-
29
- .more {
30
- background: rgba(0, 0, 0, .1);
31
- padding: 0.5em
32
- }
33
-
34
- .open .more,
35
- .more:hover {
36
- background: rgba(0, 0, 0, .3);
37
- }
38
-
39
- body {
40
- background: #f3f3f3;
41
- }
42
-
43
- temba-tabs {
44
- margin: 2em;
45
- }
46
-
47
- temba-tabs *,
48
- temba-tab * {
49
- opacity: 0;
50
- }
51
-
52
- temba-tabs:defined *,
53
- temba-tab:defined * {
54
- opacity: 1;
55
- }
56
-
57
- temba-tab {
58
- padding: 1em;
59
- }
60
-
61
- .dropdown {
62
- padding: 2em;
63
- }
64
-
65
- .dropdown .title {
66
- font-weight: 400;
67
- margin-bottom: 0.5em;
68
- }
69
-
70
- .dropdown .item {
71
- padding: 0.5em;
72
- }
73
-
74
- .header {
75
- margin-bottom: 1em;
76
- font-size: 2em;
77
- font-weight: 400;
78
- color: #777;
79
- display: inline;
80
- }
81
-
82
- temba-dropdown {
83
- position: relative;
84
- display: inline-block;
85
- margin: 0em 0.5em;
86
- }
87
-
88
- temba-slider {
89
- margin-top: 1em;
90
- }
91
-
92
- temba-datepicker,
93
- temba-select,
94
- temba-textinput,
95
- temba-completion {
96
- margin: 0.5em;
97
- flex-grow: 1;
98
- }
99
- </style>
100
- <script type="module">
101
- import '../out-tsc/temba-modules.js';
102
- </script>
103
- <script>
104
-
105
- function handleDateChange(event) {
106
-
107
- }
108
-
109
- // var static_url = '/static/';
110
- function handleColorChange(event) {
111
- var color = event.target.values[0].name;
112
- if (color == 'Green') {
113
- event.target.infoText = 'Green is super dangerous!';
114
- } else {
115
- event.target.infoText = null;
23
+ .example {
24
+ border: 0px solid gray;
25
+ padding: 10px;
26
+ max-width: 500px;
27
+ --temba-select-selected-font-size: 1em;
116
28
  }
117
- }
118
-
119
- function storeTest() {
120
- var store = document.querySelector("temba-store");
121
- store.getResults("http://localhost.textit.in:8888/api/v2/fields.json", { force: true }).then(function (response) {
122
- console.log(response);
123
- })
124
- }
125
-
126
- </script>
127
- </head>
128
-
129
- <body>
130
- <temba-webchat channel="967cd415-8616-4b11-b38f-60f70e0999f4"></temba-webchat>
131
- <temba-store completion="/static/api/completion.json" functions="/static/api/functions.json"
132
- fields="/static/api/fields.json" globals="/static/api/globals.json" groups="/static/api/groups.json"></temba-store>
133
-
134
- <temba-dropdown>
135
- <div style="display:inline-block; margin-bottom:1em;" slot="toggle">
136
- <temba-icon name="menu" size="1.3" clickable></temba-icon>
137
- </div>
138
- <div slot="dropdown" class="dropdown" style="width:250px; padding:0.5em 1em;">
139
- <div class="item">
140
- <div class="title">Check this out!</div>
141
- <div class="details">temba-dropdown lets you do little popup menus like this.</div>
142
- </div>
143
- </div>
144
- </temba-dropdown>
145
29
 
146
- <div class="header">temba-components</div>
147
- <!--temba-image-picker name="avatar" label="Profile Picture" shape="circle"></temba-image-picker-->
148
- <!--temba-webchat channel="9e6b37a8-c649-48b3-92d1-dfa7c00b85dc"></temba-webchat-->
149
- <!-- temba-template-editor url="/static/api/templates.json" lang="eng" template="580b124f-32cb-4003-b9e5-9eb783e29101"
150
- params="{&quot;body&quot;:[&quot;this&quot;, &quot;&quot;, &quot;that&quot;]}">
151
- </temba-template-editor-->
30
+ temba-dropdown.open {
31
+ --icon-background: rgb(241, 241, 241);
32
+ --icon-circle-size: 0.35em;
33
+ }
152
34
 
153
- <temba-tabs collapses index="0">
154
- <temba-tab name="Overview" icon="default">
155
- <temba-progress style="margin-bottom:8px" total="100" current="25" eta="2030-09-17T07:00:00.000Z"></temba-progress>
156
-
157
- <div style="display:flex;flex-wrap: wrap;">
158
- <temba-checkbox label="Check this out" checked></temba-checkbox>
159
- <temba-select placeholder="Select a color" clearable>
160
- <temba-option name="Red" value="0"></temba-option>
161
- <temba-option name="Green" value="1"></temba-option>
162
- <temba-option name="Blue" value="2"></temba-option>
163
- </temba-select>
164
-
165
- <temba-datepicker time value="2022-10-02 01:00:00+00:00" timezone="Africa/Lagos"
166
- onChange="handleDateChange(event)"></temba-datepicker>
35
+ .more {
36
+ background: rgba(0, 0, 0, 0.1);
37
+ padding: 0.5em;
38
+ }
167
39
 
168
- </div>
40
+ .open .more,
41
+ .more:hover {
42
+ background: rgba(0, 0, 0, 0.3);
43
+ }
169
44
 
170
- <temba-slider style="margin-bottom: 1em" value="50" min="0" max="100" range></temba-slider>
171
- <temba-textinput value="plain text"></temba-textinput>
172
- <temba-completion value="you complete me @cont"></temba-completion>
173
- </temba-tab>
174
-
175
- <temba-tab name="datepicker" icon="datepicker">
176
- <div style="display:flex;flex-wrap: wrap;">
177
- <temba-datepicker time value="2020-01-20T14:00+00:00" timezone="UTC"
178
- onChange="handleDateChange(event)"></temba-datepicker>
179
- <temba-datepicker value="2022-10-09" onChange="handleDateChange(event)"></temba-datepicker>
180
- <temba-datepicker time timezone="" value="2022-09-29T20:20:00.000000Z"></temba-datepicker>
181
- <temba-datepicker time onChange="handleDateChange(event)"></temba-datepicker>
182
- <temba-datepicker time value="2022-10-03 01:00:00+00:00" onChange="handleDateChange(event)"></temba-datepicker>
183
- <temba-datepicker time value="2022-10-04 01:00:00+00:00" timezone="Africa/Nairobi"
184
- onChange="handleDateChange(event)"></temba-datepicker>
185
- <temba-datepicker time value="2022-10-05 01:00:00+00:00" timezone="Africa/Lagos"
186
- onChange="handleDateChange(event)"></temba-datepicker>
187
- <temba-datepicker time value="2022-10-06 01:00:00+00:00" timezone="America/Phoenix"
188
- onChange="handleDateChange(event)"></temba-datepicker>
189
- <temba-datepicker time value="2022-10-07 01:00:00+00:00" timezone="America/Phoenix"
190
- onChange="handleDateChange(event)"></temba-datepicker>
45
+ body {
46
+ background: #f3f3f3;
47
+ }
191
48
 
192
- </div>
193
- <div style="display:flex;margin-top:0.5em">
49
+ temba-tabs {
50
+ margin: 2em;
51
+ }
194
52
 
53
+ temba-tabs *,
54
+ temba-tab * {
55
+ opacity: 0;
56
+ }
195
57
 
196
- </div>
58
+ temba-tabs:defined *,
59
+ temba-tab:defined * {
60
+ opacity: 1;
61
+ }
197
62
 
198
- </temba-tab>
63
+ temba-tab {
64
+ padding: 1em;
65
+ }
199
66
 
200
- <temba-tab name="slider" icon="slider">
67
+ .dropdown {
68
+ padding: 2em;
69
+ }
201
70
 
71
+ .dropdown .title {
72
+ font-weight: 400;
73
+ margin-bottom: 0.5em;
74
+ }
202
75
 
203
- <div class="example">
204
- With Range
205
- <temba-slider value="50" min="0" max="100" range></temba-slider>
206
- </div>
76
+ .dropdown .item {
77
+ padding: 0.5em;
78
+ }
207
79
 
208
- <div class="example">
209
- Without Range
210
- <temba-slider value="50" min="0" max="100"></temba-slider>
211
- </div>
80
+ .header {
81
+ margin-bottom: 1em;
82
+ font-size: 2em;
83
+ font-weight: 400;
84
+ color: #777;
85
+ display: inline;
86
+ }
212
87
 
213
- </temba-tab>
88
+ temba-dropdown {
89
+ position: relative;
90
+ display: inline-block;
91
+ margin: 0em 0.5em;
92
+ }
214
93
 
215
- <temba-tab name="select" icon="select">
94
+ temba-slider {
95
+ margin-top: 1em;
96
+ }
216
97
 
217
- <div class="example">
218
- <temba-select placeholder="Select a color" info_text="Some colors are very dangerous, choose wisely"
219
- onchange="handleColorChange(event)">
220
- <temba-option name="Red" value="0"></temba-option>
221
- <temba-option name="Green" value="1"></temba-option>
222
- <temba-option name="Blue" value="2"></temba-option>
223
- </temba-select>
224
- </div>
98
+ temba-datepicker,
99
+ temba-select,
100
+ temba-textinput,
101
+ temba-completion {
102
+ margin: 0.5em;
103
+ flex-grow: 1;
104
+ }
105
+ </style>
106
+ <script type="module">
107
+ import '../out-tsc/temba-modules.js';
108
+ </script>
109
+ <script>
110
+ function handleDateChange(event) {}
111
+
112
+ // var static_url = '/static/';
113
+ function handleColorChange(event) {
114
+ var color = event.target.values[0].name;
115
+ if (color == 'Green') {
116
+ event.target.infoText = 'Green is super dangerous!';
117
+ } else {
118
+ event.target.infoText = null;
119
+ }
120
+ }
225
121
 
226
- <div class="example">
227
- <temba-select placeholder="Select a color" clearable>
228
- <temba-option name="Red" value="0"></temba-option>
229
- <temba-option name="Green" value="1"></temba-option>
230
- <temba-option name="Blue" value="2"></temba-option>
231
- </temba-select>
122
+ function storeTest() {
123
+ var store = document.querySelector('temba-store');
124
+ store
125
+ .getResults('http://localhost.textit.in:8888/api/v2/fields.json', {
126
+ force: true
127
+ })
128
+ .then(function (response) {
129
+ console.log(response);
130
+ });
131
+ }
132
+ </script>
133
+ </head>
134
+
135
+ <body>
136
+ <temba-webchat
137
+ channel="967cd415-8616-4b11-b38f-60f70e0999f4"
138
+ ></temba-webchat>
139
+ <temba-store
140
+ completion="/static/api/completion.json"
141
+ functions="/static/api/functions.json"
142
+ fields="/static/api/fields.json"
143
+ globals="/static/api/globals.json"
144
+ groups="/static/api/groups.json"
145
+ ></temba-store>
146
+
147
+ <temba-dropdown>
148
+ <div style="display: inline-block; margin-bottom: 1em" slot="toggle">
149
+ <temba-icon name="menu" size="1.3" clickable></temba-icon>
232
150
  </div>
233
-
234
- <div class="example">
235
- <temba-select placeholder="Select a color" expressions="message" values='[{"name":"Red","value":"0"}]'
236
- searchable multi>
237
- <temba-option name="Red" value="0"></temba-option>
238
- <temba-option name="Green" value="1"></temba-option>
239
- <temba-option name="Blue" value="2"></temba-option>
240
- </temba-select>
151
+ <div
152
+ slot="dropdown"
153
+ class="dropdown"
154
+ style="width: 250px; padding: 0.5em 1em"
155
+ >
156
+ <div class="item">
157
+ <div class="title">Check this out!</div>
158
+ <div class="details">
159
+ temba-dropdown lets you do little popup menus like this.
160
+ </div>
161
+ </div>
241
162
  </div>
163
+ </temba-dropdown>
242
164
 
243
- <div class="example">
244
- <temba-select name="Color" label="Color" help_text="I'm not really enabled at the moment"
245
- placeholder="Select a color" expressions="message" values='[{"name":"Red","value":"0"}]' searchable multi
246
- disabled>
247
- <temba-option name="Red" value="0"></temba-option>
248
- <temba-option name="Green" value="1"></temba-option>
249
- <temba-option name="Blue" value="2"></temba-option>
250
- </temba-select>
251
- </div>
165
+ <div class="header">temba-components</div>
166
+ <!--temba-image-picker name="avatar" label="Profile Picture" shape="circle"></temba-image-picker-->
167
+ <!--temba-webchat channel="9e6b37a8-c649-48b3-92d1-dfa7c00b85dc"></temba-webchat-->
168
+ <!-- temba-template-editor url="/static/api/templates.json" lang="eng" template="580b124f-32cb-4003-b9e5-9eb783e29101"
169
+ params="{&quot;body&quot;:[&quot;this&quot;, &quot;&quot;, &quot;that&quot;]}">
170
+ </temba-template-editor-->
252
171
 
253
- <div class="example">
254
- <script>
255
- function toggleSelect(evt) {
256
- document.getElementById('select-toggle').disabled = !evt.currentTarget
257
- .checked;
258
- }
259
- </script>
260
- <div style="display: flex; align-items: center">
261
- <temba-checkbox onchange="toggleSelect(event)" checked></temba-checkbox>
262
- <temba-select style="margin-left: 10px" id="select-toggle" placeholder="Select a color" expressions="message">
172
+ <temba-tabs collapses index="0">
173
+ <temba-tab name="Overview" icon="default">
174
+ <temba-progress
175
+ style="margin-bottom: 8px"
176
+ total="100"
177
+ current="25"
178
+ eta="2030-09-17T07:00:00.000Z"
179
+ ></temba-progress>
180
+
181
+ <div style="display: flex; flex-wrap: wrap">
182
+ <temba-checkbox label="Check this out" checked></temba-checkbox>
183
+ <temba-select placeholder="Select a color" clearable>
263
184
  <temba-option name="Red" value="0"></temba-option>
264
185
  <temba-option name="Green" value="1"></temba-option>
265
186
  <temba-option name="Blue" value="2"></temba-option>
266
187
  </temba-select>
188
+
189
+ <temba-datepicker
190
+ time
191
+ value="2022-10-02 01:00:00+00:00"
192
+ timezone="Africa/Lagos"
193
+ onChange="handleDateChange(event)"
194
+ ></temba-datepicker>
267
195
  </div>
268
- </div>
269
196
 
270
- </temba-tab>
197
+ <temba-slider
198
+ style="margin-bottom: 1em"
199
+ value="50"
200
+ min="0"
201
+ max="100"
202
+ range
203
+ ></temba-slider>
204
+ <temba-textinput value="plain text"></temba-textinput>
205
+ <temba-completion value="you complete me @cont"></temba-completion>
206
+ </temba-tab>
207
+
208
+ <temba-tab name="datepicker" icon="datepicker">
209
+ <div style="display: flex; flex-wrap: wrap">
210
+ <temba-datepicker
211
+ time
212
+ value="2020-01-20T14:00+00:00"
213
+ timezone="UTC"
214
+ onChange="handleDateChange(event)"
215
+ ></temba-datepicker>
216
+ <temba-datepicker
217
+ value="2022-10-09"
218
+ onChange="handleDateChange(event)"
219
+ ></temba-datepicker>
220
+ <temba-datepicker
221
+ time
222
+ timezone=""
223
+ value="2022-09-29T20:20:00.000000Z"
224
+ ></temba-datepicker>
225
+ <temba-datepicker
226
+ time
227
+ onChange="handleDateChange(event)"
228
+ ></temba-datepicker>
229
+ <temba-datepicker
230
+ time
231
+ value="2022-10-03 01:00:00+00:00"
232
+ onChange="handleDateChange(event)"
233
+ ></temba-datepicker>
234
+ <temba-datepicker
235
+ time
236
+ value="2022-10-04 01:00:00+00:00"
237
+ timezone="Africa/Nairobi"
238
+ onChange="handleDateChange(event)"
239
+ ></temba-datepicker>
240
+ <temba-datepicker
241
+ time
242
+ value="2022-10-05 01:00:00+00:00"
243
+ timezone="Africa/Lagos"
244
+ onChange="handleDateChange(event)"
245
+ ></temba-datepicker>
246
+ <temba-datepicker
247
+ time
248
+ value="2022-10-06 01:00:00+00:00"
249
+ timezone="America/Phoenix"
250
+ onChange="handleDateChange(event)"
251
+ ></temba-datepicker>
252
+ <temba-datepicker
253
+ time
254
+ value="2022-10-07 01:00:00+00:00"
255
+ timezone="America/Phoenix"
256
+ onChange="handleDateChange(event)"
257
+ ></temba-datepicker>
258
+ </div>
259
+ <div style="display: flex; margin-top: 0.5em"></div>
260
+ </temba-tab>
271
261
 
272
- <temba-tab name="textinput" icon="edit-05">
262
+ <temba-tab name="slider" icon="slider">
263
+ <div class="example">
264
+ With Range
265
+ <temba-slider value="50" min="0" max="100" range></temba-slider>
266
+ </div>
273
267
 
274
- <div class="example">
275
- <temba-textinput value="plain text"></temba-textinput>
276
- </div>
268
+ <div class="example">
269
+ Without Range
270
+ <temba-slider value="50" min="0" max="100"></temba-slider>
271
+ </div>
272
+ </temba-tab>
273
+
274
+ <temba-tab name="select" icon="select">
275
+ <div class="example">
276
+ <temba-select
277
+ placeholder="Select a color"
278
+ info_text="Some colors are very dangerous, choose wisely"
279
+ onchange="handleColorChange(event)"
280
+ >
281
+ <temba-option name="Red" value="0"></temba-option>
282
+ <temba-option name="Green" value="1"></temba-option>
283
+ <temba-option name="Blue" value="2"></temba-option>
284
+ </temba-select>
285
+ </div>
277
286
 
278
- <div class="example">
279
- <temba-completion value="you complete me @cont"></temba-completion>
280
- </div>
287
+ <div class="example">
288
+ <temba-select placeholder="Select a color" clearable>
289
+ <temba-option name="Red" value="0"></temba-option>
290
+ <temba-option name="Green" value="1"></temba-option>
291
+ <temba-option name="Blue" value="2"></temba-option>
292
+ </temba-select>
293
+ </div>
281
294
 
282
- <div class="example">
283
- <temba-textinput name="start" label="Start Time"
284
- help_text="This is something you should think long and hard about" placeholder="Put something down, for real"
285
- value="2020-11-28 15:03" clearable datetimepicker></temba-textinput>
286
- </div>
295
+ <div class="example">
296
+ <temba-select
297
+ placeholder="Select a color"
298
+ expressions="message"
299
+ values='[{"name":"Red","value":"0"}]'
300
+ searchable
301
+ multi
302
+ >
303
+ <temba-option name="Red" value="0"></temba-option>
304
+ <temba-option name="Green" value="1"></temba-option>
305
+ <temba-option name="Blue" value="2"></temba-option>
306
+ </temba-select>
307
+ </div>
287
308
 
288
- <div class="example">
289
- <temba-completion counter="temba-charcount" value="This is a GSM charcounter in a textarea" gsm
290
- textarea></temba-completion>
291
- <temba-charcount text='count this text'></temba-charcount>
292
- </div>
293
- </temba-tab>
309
+ <div class="example">
310
+ <temba-select
311
+ placeholder="Select 2 colors"
312
+ name="Color2"
313
+ label="Select up to 2 colors"
314
+ expressions="message"
315
+ maxItems="2"
316
+ values='[{"name":"Red","value":"0"}]'
317
+ searchable
318
+ multi
319
+ >
320
+ <temba-option name="Red" value="0"></temba-option>
321
+ <temba-option name="Green" value="1"></temba-option>
322
+ <temba-option name="Blue" value="2"></temba-option>
323
+ </temba-select>
324
+ </div>
294
325
 
295
- </temba-tabs>
296
- </body>
326
+ <div class="example">
327
+ <temba-select
328
+ name="Color"
329
+ label="Color"
330
+ help_text="I'm not really enabled at the moment"
331
+ placeholder="Select a color"
332
+ expressions="message"
333
+ values='[{"name":"Red","value":"0"}]'
334
+ searchable
335
+ multi
336
+ disabled
337
+ >
338
+ <temba-option name="Red" value="0"></temba-option>
339
+ <temba-option name="Green" value="1"></temba-option>
340
+ <temba-option name="Blue" value="2"></temba-option>
341
+ </temba-select>
342
+ </div>
297
343
 
298
- </html>
344
+ <div class="example">
345
+ <script>
346
+ function toggleSelect(evt) {
347
+ document.getElementById('select-toggle').disabled =
348
+ !evt.currentTarget.checked;
349
+ }
350
+ </script>
351
+ <div style="display: flex; align-items: center">
352
+ <temba-checkbox
353
+ onchange="toggleSelect(event)"
354
+ checked
355
+ ></temba-checkbox>
356
+ <temba-select
357
+ style="margin-left: 10px"
358
+ id="select-toggle"
359
+ placeholder="Select a color"
360
+ expressions="message"
361
+ >
362
+ <temba-option name="Red" value="0"></temba-option>
363
+ <temba-option name="Green" value="1"></temba-option>
364
+ <temba-option name="Blue" value="2"></temba-option>
365
+ </temba-select>
366
+ </div>
367
+ </div>
368
+ </temba-tab>
369
+
370
+ <temba-tab name="textinput" icon="edit-05">
371
+ <div class="example">
372
+ <temba-textinput value="plain text"></temba-textinput>
373
+ </div>
374
+
375
+ <div class="example">
376
+ <temba-completion value="you complete me @cont"></temba-completion>
377
+ </div>
378
+
379
+ <div class="example">
380
+ <temba-textinput
381
+ name="start"
382
+ label="Start Time"
383
+ help_text="This is something you should think long and hard about"
384
+ placeholder="Put something down, for real"
385
+ value="2020-11-28 15:03"
386
+ clearable
387
+ datetimepicker
388
+ ></temba-textinput>
389
+ </div>
390
+
391
+ <div class="example">
392
+ <temba-completion
393
+ counter="temba-charcount"
394
+ value="This is a GSM charcounter in a textarea"
395
+ gsm
396
+ textarea
397
+ ></temba-completion>
398
+ <temba-charcount text="count this text"></temba-charcount>
399
+ </div>
400
+ </temba-tab>
401
+ </temba-tabs>
402
+ </body>
403
+ </html>