@nyaruka/temba-components 0.33.2 → 0.33.4
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/.github/workflows/build.yml +4 -5
- package/CHANGELOG.md +11 -0
- package/demo/index.html +4 -4
- package/dist/{92cedc79.js → a374554b.js} +323 -82
- package/dist/index.js +323 -82
- 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/FormElement.js +9 -6
- package/out-tsc/src/FormElement.js.map +1 -1
- package/out-tsc/src/contacts/ContactDetails.js +1 -1
- package/out-tsc/src/contacts/ContactDetails.js.map +1 -1
- package/out-tsc/src/contacts/ContactFields.js +6 -5
- package/out-tsc/src/contacts/ContactFields.js.map +1 -1
- package/out-tsc/src/contacts/ContactHistory.js +4 -4
- package/out-tsc/src/contacts/ContactHistory.js.map +1 -1
- package/out-tsc/src/fields/FieldManager.js +323 -0
- package/out-tsc/src/fields/FieldManager.js.map +1 -0
- package/out-tsc/src/interfaces.js +3 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +193 -0
- package/out-tsc/src/list/SortableList.js.map +1 -0
- package/out-tsc/src/store/Store.js +28 -17
- package/out-tsc/src/store/Store.js.map +1 -1
- package/out-tsc/src/store/StoreElement.js +1 -0
- package/out-tsc/src/store/StoreElement.js.map +1 -1
- package/out-tsc/src/tabpane/TabPane.js +19 -4
- package/out-tsc/src/tabpane/TabPane.js.map +1 -1
- package/out-tsc/src/vectoricon/index.js +4 -0
- package/out-tsc/src/vectoricon/index.js.map +1 -1
- package/out-tsc/temba-modules.js +4 -0
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/temba-field-manager.test.js +47 -0
- package/out-tsc/test/temba-field-manager.test.js.map +1 -0
- package/out-tsc/test/temba-sortable-list.test.js +48 -0
- package/out-tsc/test/temba-sortable-list.test.js.map +1 -0
- package/out-tsc/test/temba-store.test.js +1 -1
- package/out-tsc/test/temba-store.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/fields-filtered.png +0 -0
- package/screenshots/truth/list/fields-hovered.png +0 -0
- package/screenshots/truth/list/fields.png +0 -0
- package/screenshots/truth/list/sortable-dragging.png +0 -0
- package/screenshots/truth/list/sortable-dropped.png +0 -0
- package/screenshots/truth/list/sortable.png +0 -0
- package/src/FormElement.ts +9 -6
- package/src/contacts/ContactDetails.ts +1 -1
- package/src/contacts/ContactFields.ts +6 -5
- package/src/contacts/ContactHistory.ts +4 -4
- package/src/fields/FieldManager.ts +353 -0
- package/src/interfaces.ts +5 -1
- package/src/list/SortableList.ts +224 -0
- package/src/store/Store.ts +34 -21
- package/src/store/StoreElement.ts +1 -0
- package/src/tabpane/TabPane.ts +19 -4
- package/src/vectoricon/index.ts +4 -0
- package/static/svg/index.pdf +137 -0
- package/temba-modules.ts +4 -0
- package/test/temba-field-manager.test.ts +60 -0
- package/test/temba-sortable-list.test.ts +58 -0
- package/test/temba-store.test.ts +1 -1
- package/test-assets/store/fields.json +50 -5
package/src/store/Store.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class Store extends RapidElement {
|
|
|
64
64
|
private groups: { [uuid: string]: ContactGroup } = {};
|
|
65
65
|
private languages: any = {};
|
|
66
66
|
private workspace: Workspace;
|
|
67
|
-
private
|
|
67
|
+
private featuredFields: ContactField[] = [];
|
|
68
68
|
|
|
69
69
|
private langService = new HumanizeDurationLanguage();
|
|
70
70
|
private humanizer = new HumanizeDuration(this.langService);
|
|
@@ -103,24 +103,7 @@ export class Store extends RapidElement {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (this.fieldsEndpoint) {
|
|
106
|
-
fetches.push(
|
|
107
|
-
getAssets(this.fieldsEndpoint).then((assets: Asset[]) => {
|
|
108
|
-
this.keyedAssets['fields'] = [];
|
|
109
|
-
this.pinnedFields = [];
|
|
110
|
-
|
|
111
|
-
assets.forEach((field: ContactField) => {
|
|
112
|
-
this.keyedAssets['fields'].push(field.key);
|
|
113
|
-
this.fields[field.key] = field;
|
|
114
|
-
if (field.pinned) {
|
|
115
|
-
this.pinnedFields.push(field);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
this.pinnedFields.sort((a, b) => {
|
|
120
|
-
return b.priority - a.priority;
|
|
121
|
-
});
|
|
122
|
-
})
|
|
123
|
-
);
|
|
106
|
+
fetches.push(this.refreshFields());
|
|
124
107
|
}
|
|
125
108
|
|
|
126
109
|
if (this.globalsEndpoint) {
|
|
@@ -183,6 +166,32 @@ export class Store extends RapidElement {
|
|
|
183
166
|
return 'en';
|
|
184
167
|
}
|
|
185
168
|
|
|
169
|
+
public refreshFields() {
|
|
170
|
+
return getAssets(this.fieldsEndpoint).then((assets: Asset[]) => {
|
|
171
|
+
this.keyedAssets['fields'] = [];
|
|
172
|
+
this.featuredFields = [];
|
|
173
|
+
|
|
174
|
+
assets.forEach((field: ContactField) => {
|
|
175
|
+
this.keyedAssets['fields'].push(field.key);
|
|
176
|
+
this.fields[field.key] = field;
|
|
177
|
+
if (field.featured) {
|
|
178
|
+
this.featuredFields.push(field);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
this.featuredFields.sort((a, b) => {
|
|
183
|
+
return b.priority - a.priority;
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
this.keyedAssets['fields'].sort();
|
|
187
|
+
|
|
188
|
+
this.fireCustomEvent(CustomEventType.StoreUpdated, {
|
|
189
|
+
url: this.fieldsEndpoint,
|
|
190
|
+
data: this.keyedAssets['fields'],
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
186
195
|
public getShortDuration(
|
|
187
196
|
isoDateA: string,
|
|
188
197
|
isoDateB: string = null,
|
|
@@ -232,12 +241,16 @@ export class Store extends RapidElement {
|
|
|
232
241
|
return this.keyedAssets;
|
|
233
242
|
}
|
|
234
243
|
|
|
244
|
+
public getFieldKeys(): string[] {
|
|
245
|
+
return this.keyedAssets['fields'];
|
|
246
|
+
}
|
|
247
|
+
|
|
235
248
|
public getContactField(key: string): ContactField {
|
|
236
249
|
return this.fields[key];
|
|
237
250
|
}
|
|
238
251
|
|
|
239
|
-
public
|
|
240
|
-
return this.
|
|
252
|
+
public getFeaturedFields(): ContactField[] {
|
|
253
|
+
return this.featuredFields;
|
|
241
254
|
}
|
|
242
255
|
|
|
243
256
|
public getLanguageName(iso: string) {
|
package/src/tabpane/TabPane.ts
CHANGED
|
@@ -16,7 +16,6 @@ export class TabPane extends RapidElement {
|
|
|
16
16
|
|
|
17
17
|
.tabs {
|
|
18
18
|
display: flex;
|
|
19
|
-
padding-left: 0.18em;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.tab {
|
|
@@ -25,6 +24,7 @@ export class TabPane extends RapidElement {
|
|
|
25
24
|
margin: 0em 0em;
|
|
26
25
|
cursor: pointer;
|
|
27
26
|
display: flex;
|
|
27
|
+
font-size: 1.1em;
|
|
28
28
|
align-items: center;
|
|
29
29
|
border-radius: var(--curvature);
|
|
30
30
|
border-bottom-right-radius: 0px;
|
|
@@ -48,7 +48,7 @@ export class TabPane extends RapidElement {
|
|
|
48
48
|
max-width: 80px;
|
|
49
49
|
margin-right: 0.4em;
|
|
50
50
|
overflow: hidden;
|
|
51
|
-
transition: max-width 500ms ease-in-out;
|
|
51
|
+
transition: max-width 500ms ease-in-out, margin 500ms ease-in-out;
|
|
52
52
|
white-space: nowrap;
|
|
53
53
|
text-overflow: ellipsis;
|
|
54
54
|
}
|
|
@@ -70,12 +70,27 @@ export class TabPane extends RapidElement {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.tab
|
|
73
|
+
.tab {
|
|
74
|
+
transform: scale(0.9) translateY(-0.05em);
|
|
75
|
+
--icon-color: #aaa;
|
|
76
|
+
color: #aaa;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.tab.selected,
|
|
80
|
+
.tab.selected:hover {
|
|
74
81
|
cursor: default;
|
|
75
82
|
box-shadow: 2px 1px 3px 2px rgba(0, 0, 0, 0.07);
|
|
76
83
|
background: #fff;
|
|
77
|
-
transform: scale(1
|
|
84
|
+
transform: scale(1) translateY(0em);
|
|
78
85
|
z-index: 0;
|
|
86
|
+
--icon-color: #666;
|
|
87
|
+
color: #666;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.tab:hover {
|
|
91
|
+
--icon-color: #666;
|
|
92
|
+
color: #666;
|
|
93
|
+
background: rgba(0, 0, 0, 0.02);
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
.pane {
|
package/src/vectoricon/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export enum Icon {
|
|
|
42
42
|
inbox = 'inbox-01',
|
|
43
43
|
label = 'tag-01',
|
|
44
44
|
language = 'globe-01',
|
|
45
|
+
link = 'link-external-01',
|
|
45
46
|
log = 'file-02',
|
|
46
47
|
menu = 'menu-01',
|
|
47
48
|
menu_collapse = 'chevron-left-double',
|
|
@@ -53,6 +54,7 @@ export enum Icon {
|
|
|
53
54
|
org_suspended = 'slash-circle-01',
|
|
54
55
|
org_verified = 'check-verified-02',
|
|
55
56
|
org_flagged = 'flag-01',
|
|
57
|
+
featured = 'star-01',
|
|
56
58
|
resthooks = 'share-07',
|
|
57
59
|
restore = 'play',
|
|
58
60
|
search = 'search-refraction',
|
|
@@ -60,6 +62,7 @@ export enum Icon {
|
|
|
60
62
|
select_clear = 'x',
|
|
61
63
|
service = 'magic-wand-01',
|
|
62
64
|
settings = 'settings-02',
|
|
65
|
+
sort = 'chevron-selector-vertical',
|
|
63
66
|
staff = 'hard-drive',
|
|
64
67
|
tickets = 'agent',
|
|
65
68
|
tickets_all = 'archive',
|
|
@@ -73,6 +76,7 @@ export enum Icon {
|
|
|
73
76
|
triggers = 'signal-01',
|
|
74
77
|
updated = 'edit-02',
|
|
75
78
|
upload = 'upload-cloud-01',
|
|
79
|
+
usages = 'link-04',
|
|
76
80
|
user = 'users-01',
|
|
77
81
|
users = 'users-01',
|
|
78
82
|
user_beta = 'shield-zap',
|
package/static/svg/index.pdf
CHANGED
|
@@ -678981,3 +678981,140 @@ trailer
|
|
|
678981
678981
|
startxref
|
|
678982
678982
|
23873054
|
|
678983
678983
|
%%EOF
|
|
678984
|
+
428 0 obj
|
|
678985
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 2180 ] /Resources 425 0 R
|
|
678986
|
+
/Parent 5607 0 R /Rotate 0 /Contents 426 0 R >>
|
|
678987
|
+
endobj
|
|
678988
|
+
744 0 obj
|
|
678989
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 1140 ] /Resources 741 0 R
|
|
678990
|
+
/Parent 5607 0 R /Rotate 0 /Contents 742 0 R >>
|
|
678991
|
+
endobj
|
|
678992
|
+
1114 0 obj
|
|
678993
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 740 ] /Resources 1111 0 R
|
|
678994
|
+
/Parent 5607 0 R /Rotate 0 /Contents 1112 0 R >>
|
|
678995
|
+
endobj
|
|
678996
|
+
1344 0 obj
|
|
678997
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 660 ] /Resources 1341 0 R
|
|
678998
|
+
/Parent 5607 0 R /Rotate 0 /Contents 1342 0 R >>
|
|
678999
|
+
endobj
|
|
679000
|
+
1612 0 obj
|
|
679001
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 820 ] /Resources 1609 0 R
|
|
679002
|
+
/Parent 5607 0 R /Rotate 0 /Contents 1610 0 R >>
|
|
679003
|
+
endobj
|
|
679004
|
+
1972 0 obj
|
|
679005
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 860 ] /Resources 1969 0 R
|
|
679006
|
+
/Parent 5607 0 R /Rotate 0 /Contents 1970 0 R >>
|
|
679007
|
+
endobj
|
|
679008
|
+
2206 0 obj
|
|
679009
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 500 ] /Resources 2203 0 R
|
|
679010
|
+
/Parent 5607 0 R /Rotate 0 /Contents 2204 0 R >>
|
|
679011
|
+
endobj
|
|
679012
|
+
2408 0 obj
|
|
679013
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 500 ] /Resources 2405 0 R
|
|
679014
|
+
/Parent 5607 0 R /Rotate 0 /Contents 2406 0 R >>
|
|
679015
|
+
endobj
|
|
679016
|
+
2718 0 obj
|
|
679017
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 1300 ] /Resources 2715 0 R
|
|
679018
|
+
/Parent 5607 0 R /Rotate 0 /Contents 2716 0 R >>
|
|
679019
|
+
endobj
|
|
679020
|
+
3060 0 obj
|
|
679021
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 820 ] /Resources 3057 0 R
|
|
679022
|
+
/Parent 5607 0 R /Rotate 0 /Contents 3058 0 R >>
|
|
679023
|
+
endobj
|
|
679024
|
+
3370 0 obj
|
|
679025
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 820 ] /Resources 3367 0 R
|
|
679026
|
+
/Parent 5607 0 R /Rotate 0 /Contents 3368 0 R >>
|
|
679027
|
+
endobj
|
|
679028
|
+
3586 0 obj
|
|
679029
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 580 ] /Resources 3583 0 R
|
|
679030
|
+
/Parent 5607 0 R /Rotate 0 /Contents 3584 0 R >>
|
|
679031
|
+
endobj
|
|
679032
|
+
3920 0 obj
|
|
679033
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 1020 ] /Resources 3917 0 R
|
|
679034
|
+
/Parent 5607 0 R /Rotate 0 /Contents 3918 0 R >>
|
|
679035
|
+
endobj
|
|
679036
|
+
4180 0 obj
|
|
679037
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 540 ] /Resources 4177 0 R
|
|
679038
|
+
/Parent 5607 0 R /Rotate 0 /Contents 4178 0 R >>
|
|
679039
|
+
endobj
|
|
679040
|
+
4484 0 obj
|
|
679041
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 500 ] /Resources 4481 0 R
|
|
679042
|
+
/Parent 5607 0 R /Rotate 0 /Contents 4482 0 R >>
|
|
679043
|
+
endobj
|
|
679044
|
+
4786 0 obj
|
|
679045
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 1260 ] /Resources 4783 0 R
|
|
679046
|
+
/Parent 5607 0 R /Rotate 0 /Contents 4784 0 R >>
|
|
679047
|
+
endobj
|
|
679048
|
+
5004 0 obj
|
|
679049
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 660 ] /Resources 5001 0 R
|
|
679050
|
+
/Parent 5607 0 R /Rotate 0 /Contents 5002 0 R >>
|
|
679051
|
+
endobj
|
|
679052
|
+
5334 0 obj
|
|
679053
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 740 ] /Resources 5331 0 R
|
|
679054
|
+
/Parent 5607 0 R /Rotate 0 /Contents 5332 0 R >>
|
|
679055
|
+
endobj
|
|
679056
|
+
5606 0 obj
|
|
679057
|
+
<< /Annots [ ] /Type /Page /MediaBox [ 0 0 1144 540 ] /Resources 5603 0 R
|
|
679058
|
+
/Parent 5607 0 R /Rotate 0 /Contents 5604 0 R >>
|
|
679059
|
+
endobj
|
|
679060
|
+
5608 0 obj
|
|
679061
|
+
<< /Info 5612 0 R /Pages 5607 0 R /Type /Catalog >>
|
|
679062
|
+
endobj
|
|
679063
|
+
5611 0 obj
|
|
679064
|
+
<< /Producer (macOS Version 13.0 \(Build 22A380\) Quartz PDFContext, AppendMode 1.1)
|
|
679065
|
+
/ModDate (D:20221123223204Z00'00') >>
|
|
679066
|
+
endobj
|
|
679067
|
+
5612 0 obj
|
|
679068
|
+
5611 0 R
|
|
679069
|
+
endobj
|
|
679070
|
+
xref
|
|
679071
|
+
0 1
|
|
679072
|
+
0000000000 65535 f
|
|
679073
|
+
428 1
|
|
679074
|
+
0023873794 00000 n
|
|
679075
|
+
744 1
|
|
679076
|
+
0023873933 00000 n
|
|
679077
|
+
1114 1
|
|
679078
|
+
0023874072 00000 n
|
|
679079
|
+
1344 1
|
|
679080
|
+
0023874213 00000 n
|
|
679081
|
+
1612 1
|
|
679082
|
+
0023874354 00000 n
|
|
679083
|
+
1972 1
|
|
679084
|
+
0023874495 00000 n
|
|
679085
|
+
2206 1
|
|
679086
|
+
0023874636 00000 n
|
|
679087
|
+
2408 1
|
|
679088
|
+
0023874777 00000 n
|
|
679089
|
+
2718 1
|
|
679090
|
+
0023874918 00000 n
|
|
679091
|
+
3060 1
|
|
679092
|
+
0023875060 00000 n
|
|
679093
|
+
3370 1
|
|
679094
|
+
0023875201 00000 n
|
|
679095
|
+
3586 1
|
|
679096
|
+
0023875342 00000 n
|
|
679097
|
+
3920 1
|
|
679098
|
+
0023875483 00000 n
|
|
679099
|
+
4180 1
|
|
679100
|
+
0023875625 00000 n
|
|
679101
|
+
4484 1
|
|
679102
|
+
0023875766 00000 n
|
|
679103
|
+
4786 1
|
|
679104
|
+
0023875907 00000 n
|
|
679105
|
+
5004 1
|
|
679106
|
+
0023876049 00000 n
|
|
679107
|
+
5334 1
|
|
679108
|
+
0023876190 00000 n
|
|
679109
|
+
5606 1
|
|
679110
|
+
0023876331 00000 n
|
|
679111
|
+
5608 1
|
|
679112
|
+
0023876472 00000 n
|
|
679113
|
+
5611 2
|
|
679114
|
+
0023876542 00000 n
|
|
679115
|
+
0023876683 00000 n
|
|
679116
|
+
trailer
|
|
679117
|
+
<< /ID [<736F6D65><4E10FAFFE2B63EFBBAEF432EF16DE3AD> ] /Root 5608 0 R /Size 5613 /Prev 23873054 >>
|
|
679118
|
+
startxref
|
|
679119
|
+
23876710
|
|
679120
|
+
%%EOF
|
package/temba-modules.ts
CHANGED
|
@@ -39,6 +39,8 @@ import { RunList } from './src/list/RunList';
|
|
|
39
39
|
import { FlowStoreElement } from './src/flow/FlowStoreElement';
|
|
40
40
|
import { ContactNameFetch } from './src/contacts/ContactNameFetch';
|
|
41
41
|
import DatePicker from './src/datepicker/DatePicker';
|
|
42
|
+
import { FieldManager } from './src/fields/FieldManager';
|
|
43
|
+
import { SortableList } from './src/list/SortableList';
|
|
42
44
|
|
|
43
45
|
export function addCustomElement(name: string, comp: any) {
|
|
44
46
|
if (!window.customElements.get(name)) {
|
|
@@ -63,6 +65,7 @@ addCustomElement('temba-contact-name', ContactName);
|
|
|
63
65
|
addCustomElement('temba-contact-name-fetch', ContactNameFetch);
|
|
64
66
|
addCustomElement('temba-contact-field', ContactFieldEditor);
|
|
65
67
|
addCustomElement('temba-contact-fields', ContactFields);
|
|
68
|
+
addCustomElement('temba-field-manager', FieldManager);
|
|
66
69
|
addCustomElement('temba-urn', ContactUrn);
|
|
67
70
|
|
|
68
71
|
addCustomElement('temba-field', FormField);
|
|
@@ -74,6 +77,7 @@ addCustomElement('temba-contact-chat', ContactChat);
|
|
|
74
77
|
addCustomElement('temba-contact-details', ContactDetails);
|
|
75
78
|
addCustomElement('temba-ticket-list', TicketList);
|
|
76
79
|
addCustomElement('temba-list', TembaList);
|
|
80
|
+
addCustomElement('temba-sortable-list', SortableList);
|
|
77
81
|
addCustomElement('temba-run-list', RunList);
|
|
78
82
|
addCustomElement('temba-flow-details', FlowStoreElement);
|
|
79
83
|
addCustomElement('temba-label', Label);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { FieldManager } from '../src/fields/FieldManager';
|
|
4
|
+
import {
|
|
5
|
+
assertScreenshot,
|
|
6
|
+
getAttributes,
|
|
7
|
+
getClip,
|
|
8
|
+
loadStore,
|
|
9
|
+
} from './utils.test';
|
|
10
|
+
|
|
11
|
+
const BORING_LIST = html`<temba-field-manager />`;
|
|
12
|
+
|
|
13
|
+
export const getEle = async (attrs: any = {}) => {
|
|
14
|
+
const fm = html`<temba-field-manager
|
|
15
|
+
${getAttributes(attrs)}
|
|
16
|
+
></temba-field-manager>`;
|
|
17
|
+
const parentNode = document.createElement('div');
|
|
18
|
+
parentNode.setAttribute('style', 'width: 600px;');
|
|
19
|
+
return (await fixture(fm, { parentNode })) as FieldManager;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('temba-field-manager', () => {
|
|
23
|
+
it('renders default', async () => {
|
|
24
|
+
await loadStore();
|
|
25
|
+
const fm: FieldManager = await getEle();
|
|
26
|
+
await assertScreenshot('list/fields', getClip(fm));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('filters', async () => {
|
|
30
|
+
await loadStore();
|
|
31
|
+
const fm: FieldManager = await getEle();
|
|
32
|
+
(fm.shadowRoot.querySelector('#search') as HTMLDivElement).click();
|
|
33
|
+
await type('at');
|
|
34
|
+
await assertScreenshot('list/fields-filtered', getClip(fm));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('hovers', async () => {
|
|
38
|
+
await loadStore();
|
|
39
|
+
const fm: FieldManager = await getEle();
|
|
40
|
+
|
|
41
|
+
// hover over the first item
|
|
42
|
+
const first = fm.shadowRoot.querySelector('.sortable') as HTMLDivElement;
|
|
43
|
+
const bounds = first.getBoundingClientRect();
|
|
44
|
+
await moveMouse(bounds.left + 20, bounds.top + 10);
|
|
45
|
+
await assertScreenshot('list/fields-hovered', getClip(fm));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('drags featured down', async () => {
|
|
49
|
+
await loadStore();
|
|
50
|
+
const fm: FieldManager = await getEle();
|
|
51
|
+
const first = fm.shadowRoot.querySelector('.sortable') as HTMLDivElement;
|
|
52
|
+
const bounds = first.getBoundingClientRect();
|
|
53
|
+
|
|
54
|
+
// drag our item
|
|
55
|
+
await moveMouse(bounds.left + 20, bounds.top + 10);
|
|
56
|
+
await mouseDown();
|
|
57
|
+
await moveMouse(bounds.left + 30, bounds.bottom + 20);
|
|
58
|
+
await assertScreenshot('list/fields-dragging', getClip(fm));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { expect, fixture, oneEvent } from '@open-wc/testing';
|
|
2
|
+
import { html, TemplateResult } from 'lit';
|
|
3
|
+
import { CustomEventType } from '../src/interfaces';
|
|
4
|
+
import { SortableList } from '../src/list/SortableList';
|
|
5
|
+
import { assertScreenshot, getClip } from './utils.test';
|
|
6
|
+
|
|
7
|
+
const BORING_LIST = html`
|
|
8
|
+
<temba-sortable-list>
|
|
9
|
+
<div class="sortable" id="chicken" style="padding:10px">Chicken</div>
|
|
10
|
+
<div class="sortable" id="fish" style="padding:10px">Fish</div>
|
|
11
|
+
</temba-sortable-list>
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const createSorter = async (def: TemplateResult) => {
|
|
15
|
+
const parentNode = document.createElement('div');
|
|
16
|
+
parentNode.setAttribute('style', 'width: 200px;');
|
|
17
|
+
return (await fixture(def, { parentNode })) as SortableList;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('temba-sortable-list', () => {
|
|
21
|
+
it('renders default', async () => {
|
|
22
|
+
const list: SortableList = await createSorter(BORING_LIST);
|
|
23
|
+
await assertScreenshot('list/sortable', getClip(list));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('drags', async () => {
|
|
27
|
+
const list: SortableList = await createSorter(BORING_LIST);
|
|
28
|
+
const orderChanged = oneEvent(list, CustomEventType.OrderChanged);
|
|
29
|
+
const updated = oneEvent(list, 'change');
|
|
30
|
+
|
|
31
|
+
const bounds = list.getBoundingClientRect();
|
|
32
|
+
|
|
33
|
+
await moveMouse(bounds.left + 20, bounds.bottom - 10);
|
|
34
|
+
await mouseDown();
|
|
35
|
+
await moveMouse(bounds.left + 30, bounds.top + 20);
|
|
36
|
+
|
|
37
|
+
// we should fire an order changed event
|
|
38
|
+
const orderEvent = await orderChanged;
|
|
39
|
+
expect(orderEvent.detail).to.deep.equal({
|
|
40
|
+
from: 'fish',
|
|
41
|
+
to: 'chicken',
|
|
42
|
+
fromIdx: 1,
|
|
43
|
+
toIdx: 0,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// should be hovered
|
|
47
|
+
await assertScreenshot('list/sortable-dragging', getClip(list));
|
|
48
|
+
|
|
49
|
+
// now lets drop, it'll look the same as before dragging since
|
|
50
|
+
// its the consuming elements job to do the reordering
|
|
51
|
+
await mouseUp();
|
|
52
|
+
await assertScreenshot('list/sortable-dropped', getClip(list));
|
|
53
|
+
|
|
54
|
+
// we should fire a change event
|
|
55
|
+
const changeEvent = await updated;
|
|
56
|
+
expect(changeEvent.type).to.equal('change');
|
|
57
|
+
});
|
|
58
|
+
});
|
package/test/temba-store.test.ts
CHANGED
|
@@ -34,7 +34,7 @@ describe('temba-store', () => {
|
|
|
34
34
|
"<temba-store fields='/test-assets/store/fields.json'></temba-store>"
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
assert.equal(store.getKeyedAssets().fields.length,
|
|
37
|
+
assert.equal(store.getKeyedAssets().fields.length, 8);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it('exposes postUrl', async () => {
|
|
@@ -2,10 +2,55 @@
|
|
|
2
2
|
"next": null,
|
|
3
3
|
"previous": null,
|
|
4
4
|
"results": [
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
{
|
|
6
|
+
"key": "rating",
|
|
7
|
+
"label": "Rating",
|
|
8
|
+
"value_type": "text",
|
|
9
|
+
"featured": true,
|
|
10
|
+
"usages": { "campaign_events": 0, "flows": 1, "groups": 0 }
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"key": "conversion",
|
|
14
|
+
"label": "Conversion",
|
|
15
|
+
"value_type": "text",
|
|
16
|
+
"usages": { "campaign_events": 0, "flows": 0, "groups": 1 }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"key": "district",
|
|
20
|
+
"label": "District",
|
|
21
|
+
"value_type": "district",
|
|
22
|
+
"usages": { "campaign_events": 1, "flows": 0, "groups": 0 }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"key": "ward",
|
|
26
|
+
"label": "Ward",
|
|
27
|
+
"value_type": "ward",
|
|
28
|
+
"featured": true,
|
|
29
|
+
"usages": { "campaign_events": 0, "flows": 0, "groups": 0 }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"key": "state",
|
|
33
|
+
"label": "State",
|
|
34
|
+
"value_type": "state",
|
|
35
|
+
"usages": { "campaign_events": 0, "flows": 0, "groups": 0 }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"key": "joined",
|
|
39
|
+
"label": "Joined On",
|
|
40
|
+
"value_type": "datetime",
|
|
41
|
+
"usages": { "campaign_events": 0, "flows": 0, "groups": 0 }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"key": "age",
|
|
45
|
+
"label": "Age",
|
|
46
|
+
"value_type": "numeric",
|
|
47
|
+
"usages": { "campaign_events": 0, "flows": 1, "groups": 0 }
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"key": "gender",
|
|
51
|
+
"label": "Gender",
|
|
52
|
+
"value_type": "text",
|
|
53
|
+
"usages": { "campaign_events": 0, "flows": 0, "groups": 0 }
|
|
54
|
+
}
|
|
10
55
|
]
|
|
11
56
|
}
|