@nyaruka/temba-components 0.54.0 → 0.54.2
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 +15 -0
- package/dist/{9e03337b.js → 16170315.js} +22 -17
- package/dist/index.js +22 -17
- package/dist/locales/es.js +8 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fr.js +8 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/locale-codes.js +16 -0
- package/dist/locales/locale-codes.js.map +1 -0
- package/dist/locales/pt.js +8 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist/templates/components-body.html +1 -1
- package/dist/templates/components-head.html +1 -1
- package/out-tsc/src/RapidElement.js +2 -2
- package/out-tsc/src/RapidElement.js.map +1 -1
- package/out-tsc/src/aliaseditor/AliasEditor.js +2 -2
- package/out-tsc/src/aliaseditor/AliasEditor.js.map +1 -1
- package/out-tsc/src/contactsearch/ContactSearch.js +1 -0
- package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
- package/out-tsc/src/remote/Remote.js +0 -1
- package/out-tsc/src/remote/Remote.js.map +1 -1
- package/out-tsc/src/select/Select.js +33 -25
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/store/Store.js +2 -2
- package/out-tsc/src/store/Store.js.map +1 -1
- package/package.json +1 -1
- package/rollup.config.js +4 -3
- package/src/RapidElement.ts +2 -2
- package/src/aliaseditor/AliasEditor.ts +2 -2
- package/src/contactsearch/ContactSearch.ts +1 -1
- package/src/remote/Remote.ts +0 -1
- package/src/select/Select.ts +32 -28
- package/src/store/Store.ts +2 -2
package/src/select/Select.ts
CHANGED
|
@@ -80,6 +80,12 @@ export class Select extends FormElement {
|
|
|
80
80
|
cursor: text;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
.wrapper-bg {
|
|
84
|
+
background: #f3f3f3;
|
|
85
|
+
box-shadow: inset 0px 0px 4px rgb(0 0 0 / 10%);
|
|
86
|
+
border-radius: var(--curvature-widget);
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
.select-container {
|
|
84
90
|
display: flex;
|
|
85
91
|
flex-direction: row;
|
|
@@ -313,16 +319,13 @@ export class Select extends FormElement {
|
|
|
313
319
|
|
|
314
320
|
.info-text {
|
|
315
321
|
opacity: 1;
|
|
316
|
-
transition:
|
|
322
|
+
transition: padding-top var(--transition-speed) ease-in-out,
|
|
323
|
+
padding-bottom var(--transition-speed) ease-in-out;
|
|
317
324
|
margin-bottom: 16px;
|
|
318
|
-
margin-top: -1em;
|
|
319
325
|
padding: 0.5em 1em;
|
|
320
|
-
background: #f3f3f3;
|
|
321
|
-
padding-top: 1.5em;
|
|
322
326
|
border-radius: var(--curvature);
|
|
323
327
|
font-size: 0.9em;
|
|
324
328
|
color: rgba(0, 0, 0, 0.5);
|
|
325
|
-
box-shadow: inset 0px 0px 4px rgb(0 0 0 / 10%);
|
|
326
329
|
position: relative;
|
|
327
330
|
}
|
|
328
331
|
|
|
@@ -334,8 +337,8 @@ export class Select extends FormElement {
|
|
|
334
337
|
opacity: 0;
|
|
335
338
|
max-height: 0;
|
|
336
339
|
margin-bottom: 0px;
|
|
337
|
-
margin-top: -2em;
|
|
338
340
|
pointer-events: none;
|
|
341
|
+
padding: 0px;
|
|
339
342
|
}
|
|
340
343
|
`;
|
|
341
344
|
}
|
|
@@ -439,6 +442,9 @@ export class Select extends FormElement {
|
|
|
439
442
|
@property({ type: Array })
|
|
440
443
|
values: any[] = [];
|
|
441
444
|
|
|
445
|
+
@property({ type: Object })
|
|
446
|
+
selection: any;
|
|
447
|
+
|
|
442
448
|
@property({ attribute: false })
|
|
443
449
|
getName: (option: any) => string = (option: any) =>
|
|
444
450
|
option[this.nameKey || 'name'];
|
|
@@ -510,6 +516,9 @@ export class Select extends FormElement {
|
|
|
510
516
|
|
|
511
517
|
if (changedProperties.has('values')) {
|
|
512
518
|
this.updateInputs();
|
|
519
|
+
if (this.multi || this.values.length === 1) {
|
|
520
|
+
this.fireEvent('change');
|
|
521
|
+
}
|
|
513
522
|
}
|
|
514
523
|
|
|
515
524
|
// if our cache key changes, clear it out
|
|
@@ -586,14 +595,19 @@ export class Select extends FormElement {
|
|
|
586
595
|
const name = this.getAttribute('name');
|
|
587
596
|
|
|
588
597
|
if (name) {
|
|
589
|
-
this.values.
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
598
|
+
if (!this.multi && this.values.length === 1) {
|
|
599
|
+
this.selection = this.values[0];
|
|
600
|
+
this.value = this.serializeValue(this.values[0]);
|
|
601
|
+
} else {
|
|
602
|
+
this.values.forEach(value => {
|
|
603
|
+
const ele = document.createElement('input');
|
|
604
|
+
ele.setAttribute('type', 'hidden');
|
|
605
|
+
ele.setAttribute('name', name);
|
|
606
|
+
ele.setAttribute('value', this.serializeValue(value));
|
|
607
|
+
this.hiddenInputs.push(ele);
|
|
608
|
+
this.inputRoot.parentElement.appendChild(ele);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
597
611
|
}
|
|
598
612
|
}
|
|
599
613
|
}
|
|
@@ -615,8 +629,6 @@ export class Select extends FormElement {
|
|
|
615
629
|
this.next = null;
|
|
616
630
|
this.complete = true;
|
|
617
631
|
this.selectedIndex = -1;
|
|
618
|
-
|
|
619
|
-
this.fireEvent('change');
|
|
620
632
|
}
|
|
621
633
|
|
|
622
634
|
private isPastFetchThreshold() {
|
|
@@ -681,7 +693,6 @@ export class Select extends FormElement {
|
|
|
681
693
|
public handleRemoveSelection(selectionToRemove: any): void {
|
|
682
694
|
this.removeValue(selectionToRemove);
|
|
683
695
|
this.visibleOptions = [];
|
|
684
|
-
this.fireEvent('change');
|
|
685
696
|
}
|
|
686
697
|
|
|
687
698
|
private createArbitraryOptionDefault(): any {
|
|
@@ -995,8 +1006,6 @@ export class Select extends FormElement {
|
|
|
995
1006
|
if (!this.multi) {
|
|
996
1007
|
this.blur();
|
|
997
1008
|
}
|
|
998
|
-
|
|
999
|
-
this.fireEvent('change');
|
|
1000
1009
|
}
|
|
1001
1010
|
|
|
1002
1011
|
private handleKeyDown(evt: KeyboardEvent) {
|
|
@@ -1039,7 +1048,6 @@ export class Select extends FormElement {
|
|
|
1039
1048
|
this.popValue();
|
|
1040
1049
|
this.selectedIndex = -1;
|
|
1041
1050
|
}
|
|
1042
|
-
this.fireEvent('change');
|
|
1043
1051
|
} else {
|
|
1044
1052
|
this.selectedIndex = -1;
|
|
1045
1053
|
}
|
|
@@ -1119,7 +1127,6 @@ export class Select extends FormElement {
|
|
|
1119
1127
|
this.addValue(option);
|
|
1120
1128
|
} else {
|
|
1121
1129
|
this.setValues([option]);
|
|
1122
|
-
this.fireEvent('change');
|
|
1123
1130
|
}
|
|
1124
1131
|
}
|
|
1125
1132
|
}
|
|
@@ -1131,7 +1138,6 @@ export class Select extends FormElement {
|
|
|
1131
1138
|
fetchResults(this.endpoint).then((results: any) => {
|
|
1132
1139
|
if (results.length > 0) {
|
|
1133
1140
|
this.setValues([results[0]]);
|
|
1134
|
-
this.fireEvent('change');
|
|
1135
1141
|
}
|
|
1136
1142
|
});
|
|
1137
1143
|
} else {
|
|
@@ -1140,7 +1146,6 @@ export class Select extends FormElement {
|
|
|
1140
1146
|
} else {
|
|
1141
1147
|
this.setValues([this.staticOptions[0]]);
|
|
1142
1148
|
}
|
|
1143
|
-
this.fireEvent('change');
|
|
1144
1149
|
}
|
|
1145
1150
|
}
|
|
1146
1151
|
|
|
@@ -1189,8 +1194,6 @@ export class Select extends FormElement {
|
|
|
1189
1194
|
if (option.value === value) {
|
|
1190
1195
|
if (this.values.length === 0 || this.values[0].value !== '' + value) {
|
|
1191
1196
|
this.setValues([option]);
|
|
1192
|
-
|
|
1193
|
-
this.fireEvent('change');
|
|
1194
1197
|
}
|
|
1195
1198
|
return;
|
|
1196
1199
|
}
|
|
@@ -1201,7 +1204,6 @@ export class Select extends FormElement {
|
|
|
1201
1204
|
evt.preventDefault();
|
|
1202
1205
|
evt.stopPropagation();
|
|
1203
1206
|
this.setValues([]);
|
|
1204
|
-
this.fireEvent('change');
|
|
1205
1207
|
}
|
|
1206
1208
|
|
|
1207
1209
|
public setValues(values: any[]) {
|
|
@@ -1294,6 +1296,7 @@ export class Select extends FormElement {
|
|
|
1294
1296
|
>
|
|
1295
1297
|
|
|
1296
1298
|
|
|
1299
|
+
<div class="wrapper-bg">
|
|
1297
1300
|
<div
|
|
1298
1301
|
tabindex="0"
|
|
1299
1302
|
class="select-container ${classes}"
|
|
@@ -1359,10 +1362,11 @@ export class Select extends FormElement {
|
|
|
1359
1362
|
}
|
|
1360
1363
|
</div>
|
|
1361
1364
|
|
|
1362
|
-
|
|
1365
|
+
|
|
1363
1366
|
<div class="info-text ${!this.infoText ? 'hide' : ''} ${
|
|
1364
1367
|
this.focused ? 'focused' : ''
|
|
1365
|
-
}">${this.infoText}</div>
|
|
1368
|
+
}">${this.infoText}</div></div></div>
|
|
1369
|
+
|
|
1366
1370
|
|
|
1367
1371
|
<temba-options
|
|
1368
1372
|
@temba-selection=${this.handleOptionSelection}
|
package/src/store/Store.ts
CHANGED
|
@@ -25,12 +25,12 @@ import Lru from 'tiny-lru';
|
|
|
25
25
|
import { DateTime } from 'luxon';
|
|
26
26
|
import { css, html } from 'lit';
|
|
27
27
|
import { configureLocalization } from '@lit/localize';
|
|
28
|
-
import { sourceLocale, targetLocales } from '../locales/locale-codes
|
|
28
|
+
import { sourceLocale, targetLocales } from '../locales/locale-codes';
|
|
29
29
|
|
|
30
30
|
const { setLocale } = configureLocalization({
|
|
31
31
|
sourceLocale,
|
|
32
32
|
targetLocales,
|
|
33
|
-
loadLocale: locale => import(
|
|
33
|
+
loadLocale: locale => import(`./locales/${locale}.js`),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
export class Store extends RapidElement {
|